diff --git a/biome.json b/biome.json index b1d0c18..4cc600d 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/2.4.15/schema.json", + "$schema": "https://biomejs.dev/schemas/2.4.14/schema.json", "files": { "includes": [ "**", diff --git a/packages/cli-workflow/src/__tests__/workflow-resolution.test.ts b/packages/cli-workflow/src/__tests__/workflow-resolution.test.ts index d8d8106..664c265 100644 --- a/packages/cli-workflow/src/__tests__/workflow-resolution.test.ts +++ b/packages/cli-workflow/src/__tests__/workflow-resolution.test.ts @@ -279,11 +279,17 @@ describe("Strategy 3: Local Discovery", () => { await makeUwfStore(storageRoot); const workflowDir = join(projectRoot, ".workflow"); await mkdir(workflowDir, { recursive: true }); - await writeFile(join(workflowDir, "solve-issue.yaml"), await createWorkflowYaml("solve-issue", "flat")); + await writeFile( + join(workflowDir, "solve-issue.yaml"), + await createWorkflowYaml("solve-issue", "flat"), + ); const folderDir = join(workflowDir, "solve-issue"); await mkdir(folderDir, { recursive: true }); - await writeFile(join(folderDir, "index.yaml"), await createWorkflowYaml("solve-issue", "folder")); + await writeFile( + join(folderDir, "index.yaml"), + await createWorkflowYaml("solve-issue", "folder"), + ); const result = await cmdThreadStart(storageRoot, "solve-issue", "prompt", projectRoot); diff --git a/packages/cli-workflow/src/commands/workflow.ts b/packages/cli-workflow/src/commands/workflow.ts index 45be273..8dc2b05 100644 --- a/packages/cli-workflow/src/commands/workflow.ts +++ b/packages/cli-workflow/src/commands/workflow.ts @@ -125,7 +125,9 @@ export async function cmdWorkflowAdd( let raw: unknown; try { - raw = parse(text, { customTags: [createIncludeTag(dirname(resolvePath(filePath)))] }) as unknown; + raw = parse(text, { + customTags: [createIncludeTag(dirname(resolvePath(filePath)))], + }) as unknown; } catch (e) { fail(`invalid YAML: ${e instanceof Error ? e.message : String(e)}`); } diff --git a/packages/cli-workflow/src/store.ts b/packages/cli-workflow/src/store.ts index e8578ee..f491f71 100644 --- a/packages/cli-workflow/src/store.ts +++ b/packages/cli-workflow/src/store.ts @@ -20,6 +20,30 @@ export type ProjectWorkflowEntry = { filePath: string; }; +/** Extract workflow name from a YAML filename (strip .yaml/.yml extension). */ +function stemFromYaml(name: string): string { + if (name.endsWith(".yaml")) return name.slice(0, -5); + if (name.endsWith(".yml")) return name.slice(0, -4); + return name; +} + +/** Check if a directory contains an index.yaml or index.yml workflow file. */ +async function findIndexWorkflow( + dir: string, + dirName: string, +): Promise { + for (const indexName of ["index.yaml", "index.yml"]) { + const indexPath = join(dir, dirName, indexName); + try { + await access(indexPath); + return { name: dirName, filePath: indexPath }; + } catch { + // not found, try next + } + } + return null; +} + /** * Scan a single directory for workflow entries (flat YAML files + folder/index.yaml). * Returns discovered entries. Returns empty array if directory does not exist. @@ -39,18 +63,11 @@ async function scanWorkflowDir(dir: string): Promise { const result: ProjectWorkflowEntry[] = []; for (const entry of dirents) { if (entry.isFile() && (entry.name.endsWith(".yaml") || entry.name.endsWith(".yml"))) { - const stem = entry.name.endsWith(".yaml") ? entry.name.slice(0, -5) : entry.name.slice(0, -4); - result.push({ name: stem, filePath: join(dir, entry.name) }); + result.push({ name: stemFromYaml(entry.name), filePath: join(dir, entry.name) }); } else if (entry.isDirectory()) { - for (const indexName of ["index.yaml", "index.yml"]) { - const indexPath = join(dir, entry.name, indexName); - try { - await access(indexPath); - result.push({ name: entry.name, filePath: indexPath }); - break; - } catch { - // not found, try next - } + const found = await findIndexWorkflow(dir, entry.name); + if (found !== null) { + result.push(found); } } }