{"record":{"id":"69d7928b9680ecb6","repo":"coleam00/Archon","slug":"cannot-identify-main-workflow-yaml-in-directory-e","errorCode":null,"errorMessage":"Cannot identify main workflow YAML in directory. Expected '${slug}.yaml' or a single .yaml file.","messagePattern":"Cannot identify main workflow YAML in directory\\. Expected '(.+?)\\.yaml' or a single \\.yaml file\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":5225,"sourceCode":"  entry: MarketplaceEntryJson,\n  slug: string,\n  archonDir: string,\n  force: boolean | undefined,\n  existsSync: (p: string) => boolean,\n  mkdirSync: (p: string, opts: { recursive: boolean }) => void,\n  writeFileSync: (p: string, data: string) => void\n): Promise<void> {\n  const { owner, repo, path } = parseGitHubUrl(entry.sourceUrl);\n  const items = await fetchGitHubDirectory(owner, repo, path, entry.sha);\n\n  // Identify the main workflow YAML (named <slug>.yaml or the only .yaml in root)\n  const yamlFiles = items.filter(f => f.type === 'file' && f.name.endsWith('.yaml'));\n  const mainYaml =\n    yamlFiles.find(f => f.name === `${slug}.yaml`) ??\n    (yamlFiles.length === 1 ? yamlFiles[0] : undefined);\n\n  if (!mainYaml) {\n    throw new Error(\n      `Cannot identify main workflow YAML in directory. Expected '${slug}.yaml' or a single .yaml file.`\n    );\n  }\n\n  const workflowsDir = join(archonDir, 'workflows');\n  const destWorkflow = join(workflowsDir, `${slug}.yaml`);\n\n  if (existsSync(destWorkflow) && !force) {\n    throw new Error(\n      `Workflow '${slug}' already exists at ${destWorkflow}.\\nUse --force to overwrite.`\n    );\n  }\n\n  // Install the main workflow YAML\n  const mainContent = await downloadRawFile(owner, repo, mainYaml.path, entry.sha);\n  mkdirSync(workflowsDir, { recursive: true });\n  writeFileSync(destWorkflow, mainContent);\n  console.log(`  Workflow: ${destWorkflow}`);","sourceCodeStart":5207,"sourceCodeEnd":5243,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L5207-L5243","documentation":"For directory-sourced marketplace entries, the installer must pick one main YAML file from the downloaded listing: prefer `<slug>.yaml`, else the sole `.yaml` file. If neither rule resolves a candidate — multiple YAML files and none named after the slug — the command cannot decide which is the workflow entrypoint and aborts.","triggerScenarios":"`installFromDirectory` filters the GitHub contents listing to `.yaml` files, then finds neither `f.name === '${slug}.yaml'` nor exactly one candidate: directory has multiple YAMLs with different names, or zero YAML files (only `.yml` or other assets).","commonSituations":"Marketplace directory contains several workflow YAMLs without a `<slug>.yaml` (e.g. `lint.yaml`, `review.yaml`); repo uses `.yml` extension which the filter does not accept; slug renamed so `<slug>.yaml` no longer matches; directory only holds supporting files.","solutions":["Name the primary workflow `<slug>.yaml` inside the source directory, or leave exactly one `.yaml` file","Remove or move helper YAMLs into a subdirectory so only one remains","If the repo uses `.yml`, rename to `.yaml` (the installer only filters `.yaml`)","Update the marketplace entry's path to point at a directory following the convention"],"exampleFix":"// before\nrepo/workflows-my-pack/{review.yaml, lint.yaml}   // slug: my-pack → ambiguous\n// after\nrepo/workflows-my-pack/my-pack.yaml   // matches '<slug>.yaml'\nrepo/workflows-my-pack/steps/lint.yaml // supporting files out of the way","handlingStrategy":"validation","validationCode":"const yamls = items.filter(f => f.type === 'file' && f.name.endsWith('.yaml'));\nconst main = yamls.find(f => f.name === `${slug}.yaml`) ?? (yamls.length === 1 ? yamls[0] : null);\nif (!main) throw new Error(`No unambiguous main YAML for '${slug}' (candidates: ${yamls.map(f=>f.name).join(', ')})`);","typeGuard":"function hasUnambiguousMainYaml(items: GitHubContentItem[], slug: string): boolean {\n  const yamls = items.filter(f => f.type === 'file' && f.name.endsWith('.yaml'));\n  return yamls.some(f => f.name === `${slug}.yaml`) || yamls.length === 1;\n}","tryCatchPattern":"try {\n  await workflowInstallCommand(slug);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Cannot identify main workflow YAML')) {\n    // restructure the source directory per the <slug>.yaml convention\n  } else throw e;\n}","preventionTips":["Publish marketplace directories with a `<slug>.yaml` entrypoint","Keep auxiliary YAMLs in subdirectories or non-.yaml extensions","Use `.yaml` (not `.yml`) for workflow files in marketplace repos","Rename entries when slugs change so `<slug>.yaml` keeps matching"],"tags":["marketplace","file-selection","ambiguity","github"],"backgroundTag":"ambiguous-entrypoint-file","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}