Skip to content

Commit 06e8d6f

Browse files
fix: Clarify workshop directory search errors (#590)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 9c1dcbe commit 06e8d6f

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

packages/workshop-mcp/src/utils.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,12 @@ test('handleWorkshopDirectory normalizes playground to workshop root', async ()
164164
test('handleWorkshopDirectory rejects when no workshop directory found (aha)', async () => {
165165
await using fixture = await createTempDir()
166166
vi.mocked(console.error).mockImplementation(() => {})
167+
const searchStartDirectory = path.join(fixture.root, 'nested', 'deeper')
168+
const filesystemRoot = path.parse(searchStartDirectory).root
167169

168-
await expect(handleWorkshopDirectory(fixture.root)).rejects.toThrow(
169-
/No workshop directory found/,
170+
await mkdir(searchStartDirectory, { recursive: true })
171+
172+
await expect(handleWorkshopDirectory(searchStartDirectory)).rejects.toThrow(
173+
`No workshop directory found while searching upward from "${searchStartDirectory}" to filesystem root "${filesystemRoot}"`,
170174
)
171175
})

packages/workshop-mcp/src/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,14 @@ export async function handleWorkshopDirectory(workshopDirectory: string) {
4848
workshopDirectory = path.join(workshopDirectory, '..')
4949
}
5050

51+
const searchStartDirectory = workshopDirectory
52+
5153
while (true) {
5254
if (await isWorkshopDirectory(workshopDirectory)) break
5355
if (workshopDirectory === path.dirname(workshopDirectory)) {
54-
throw new Error(`No workshop directory found in "${workshopDirectory}"`)
56+
throw new Error(
57+
`No workshop directory found while searching upward from "${searchStartDirectory}" to filesystem root "${workshopDirectory}"`,
58+
)
5559
}
5660
workshopDirectory = path.dirname(workshopDirectory)
5761
}

0 commit comments

Comments
 (0)