opencastle 1.5.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/adapters/antigravity.d.ts +1 -1
  3. package/dist/cli/adapters/antigravity.d.ts.map +1 -1
  4. package/dist/cli/adapters/claude-code.d.ts +1 -1
  5. package/dist/cli/adapters/claude-code.d.ts.map +1 -1
  6. package/dist/cli/adapters/claude-code.js +1 -0
  7. package/dist/cli/adapters/claude-code.js.map +1 -1
  8. package/dist/cli/adapters/codex.d.ts +1 -1
  9. package/dist/cli/adapters/codex.d.ts.map +1 -1
  10. package/dist/cli/adapters/cursor.d.ts +1 -1
  11. package/dist/cli/adapters/cursor.d.ts.map +1 -1
  12. package/dist/cli/adapters/cursor.js +6 -0
  13. package/dist/cli/adapters/cursor.js.map +1 -1
  14. package/dist/cli/adapters/opencode.d.ts +1 -1
  15. package/dist/cli/adapters/opencode.d.ts.map +1 -1
  16. package/dist/cli/adapters/rules-dir-base.d.ts +13 -1
  17. package/dist/cli/adapters/rules-dir-base.d.ts.map +1 -1
  18. package/dist/cli/adapters/rules-dir-base.js +37 -18
  19. package/dist/cli/adapters/rules-dir-base.js.map +1 -1
  20. package/dist/cli/adapters/rules-dir-base.test.js +34 -0
  21. package/dist/cli/adapters/rules-dir-base.test.js.map +1 -1
  22. package/dist/cli/adapters/single-file-base.d.ts +8 -0
  23. package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
  24. package/dist/cli/adapters/single-file-base.js +48 -22
  25. package/dist/cli/adapters/single-file-base.js.map +1 -1
  26. package/dist/cli/adapters/windsurf.d.ts +1 -1
  27. package/dist/cli/adapters/windsurf.d.ts.map +1 -1
  28. package/dist/cli/bootstrap-on-init.test.js +11 -0
  29. package/dist/cli/bootstrap-on-init.test.js.map +1 -1
  30. package/dist/cli/command-namespace.test.js +17 -0
  31. package/dist/cli/command-namespace.test.js.map +1 -1
  32. package/dist/cli/convoy/engine.d.ts +12 -0
  33. package/dist/cli/convoy/engine.d.ts.map +1 -1
  34. package/dist/cli/convoy/engine.git.test.js +55 -0
  35. package/dist/cli/convoy/engine.git.test.js.map +1 -1
  36. package/dist/cli/convoy/engine.js +39 -1
  37. package/dist/cli/convoy/engine.js.map +1 -1
  38. package/dist/cli/convoy/findings.d.ts +35 -0
  39. package/dist/cli/convoy/findings.d.ts.map +1 -0
  40. package/dist/cli/convoy/findings.js +100 -0
  41. package/dist/cli/convoy/findings.js.map +1 -0
  42. package/dist/cli/convoy/findings.test.d.ts +2 -0
  43. package/dist/cli/convoy/findings.test.d.ts.map +1 -0
  44. package/dist/cli/convoy/findings.test.js +75 -0
  45. package/dist/cli/convoy/findings.test.js.map +1 -0
  46. package/dist/cli/convoy/isolation.d.ts.map +1 -1
  47. package/dist/cli/convoy/isolation.js +2 -1
  48. package/dist/cli/convoy/isolation.js.map +1 -1
  49. package/dist/cli/convoy/worktree.d.ts +5 -0
  50. package/dist/cli/convoy/worktree.d.ts.map +1 -1
  51. package/dist/cli/convoy/worktree.js +12 -0
  52. package/dist/cli/convoy/worktree.js.map +1 -1
  53. package/dist/cli/docs-accuracy.test.js +34 -0
  54. package/dist/cli/docs-accuracy.test.js.map +1 -1
  55. package/dist/cli/doctor.d.ts +11 -0
  56. package/dist/cli/doctor.d.ts.map +1 -1
  57. package/dist/cli/doctor.js +72 -8
  58. package/dist/cli/doctor.js.map +1 -1
  59. package/dist/cli/doctor.test.js +82 -1
  60. package/dist/cli/doctor.test.js.map +1 -1
  61. package/dist/cli/init.d.ts.map +1 -1
  62. package/dist/cli/init.js +58 -53
  63. package/dist/cli/init.js.map +1 -1
  64. package/dist/cli/init.test.js +28 -23
  65. package/dist/cli/init.test.js.map +1 -1
  66. package/dist/cli/layers.d.ts +20 -0
  67. package/dist/cli/layers.d.ts.map +1 -1
  68. package/dist/cli/layers.js +53 -1
  69. package/dist/cli/layers.js.map +1 -1
  70. package/dist/cli/layers.test.js +67 -1
  71. package/dist/cli/layers.test.js.map +1 -1
  72. package/dist/cli/lessons.d.ts +10 -0
  73. package/dist/cli/lessons.d.ts.map +1 -1
  74. package/dist/cli/lessons.js +26 -1
  75. package/dist/cli/lessons.js.map +1 -1
  76. package/dist/cli/lessons.test.js +38 -1
  77. package/dist/cli/lessons.test.js.map +1 -1
  78. package/dist/cli/plan.test.js +10 -8
  79. package/dist/cli/plan.test.js.map +1 -1
  80. package/dist/cli/sync-check.test.js +14 -2
  81. package/dist/cli/sync-check.test.js.map +1 -1
  82. package/dist/cli/types.d.ts +2 -1
  83. package/dist/cli/types.d.ts.map +1 -1
  84. package/dist/cli/types.js.map +1 -1
  85. package/dist/orchestrator/plugins/notion/config.d.ts.map +1 -1
  86. package/dist/orchestrator/plugins/notion/config.js +21 -17
  87. package/dist/orchestrator/plugins/notion/config.js.map +1 -1
  88. package/package.json +1 -1
  89. package/src/cli/adapters/claude-code.ts +1 -0
  90. package/src/cli/adapters/cursor.ts +6 -0
  91. package/src/cli/adapters/rules-dir-base.test.ts +41 -0
  92. package/src/cli/adapters/rules-dir-base.ts +47 -19
  93. package/src/cli/adapters/single-file-base.ts +63 -31
  94. package/src/cli/bootstrap-on-init.test.ts +12 -0
  95. package/src/cli/command-namespace.test.ts +17 -0
  96. package/src/cli/convoy/engine.git.test.ts +59 -0
  97. package/src/cli/convoy/engine.ts +44 -0
  98. package/src/cli/convoy/findings.test.ts +86 -0
  99. package/src/cli/convoy/findings.ts +129 -0
  100. package/src/cli/convoy/isolation.ts +2 -1
  101. package/src/cli/convoy/worktree.ts +12 -0
  102. package/src/cli/docs-accuracy.test.ts +42 -0
  103. package/src/cli/doctor.test.ts +101 -1
  104. package/src/cli/doctor.ts +75 -9
  105. package/src/cli/init.test.ts +27 -22
  106. package/src/cli/init.ts +62 -57
  107. package/src/cli/layers.test.ts +72 -1
  108. package/src/cli/layers.ts +52 -1
  109. package/src/cli/lessons.test.ts +48 -0
  110. package/src/cli/lessons.ts +27 -1
  111. package/src/cli/plan.test.ts +10 -8
  112. package/src/cli/sync-check.test.ts +16 -2
  113. package/src/cli/types.ts +2 -1
  114. package/src/orchestrator/agent-workflows/feature-implementation.md +1 -1
  115. package/src/orchestrator/agents/team-lead.agent.md +5 -5
  116. package/src/orchestrator/agents/testing-expert.agent.md +2 -2
  117. package/src/orchestrator/customizations/LESSONS-LEARNED.md +1 -1
  118. package/src/orchestrator/instructions/ai-optimization.instructions.md +6 -23
  119. package/src/orchestrator/instructions/general.instructions.md +22 -95
  120. package/src/orchestrator/plugins/astro/skills/astro-framework/SKILL.md +1 -3
  121. package/src/orchestrator/plugins/chrome-devtools/skills/browser-testing/SKILL.md +3 -5
  122. package/src/orchestrator/plugins/cloudflare/skills/cloudflare-platform/SKILL.md +2 -2
  123. package/src/orchestrator/plugins/contentful/skills/contentful-cms/SKILL.md +1 -1
  124. package/src/orchestrator/plugins/convex/skills/convex-database/SKILL.md +1 -3
  125. package/src/orchestrator/plugins/coolify/skills/coolify-deployment/SKILL.md +1 -1
  126. package/src/orchestrator/plugins/cypress/skills/cypress-testing/SKILL.md +1 -1
  127. package/src/orchestrator/plugins/drizzle/skills/drizzle-orm/SKILL.md +1 -1
  128. package/src/orchestrator/plugins/expo/skills/expo-development/SKILL.md +2 -2
  129. package/src/orchestrator/plugins/figma/skills/figma-design/SKILL.md +1 -3
  130. package/src/orchestrator/plugins/hetzner/skills/hetzner-cloud/SKILL.md +1 -1
  131. package/src/orchestrator/plugins/jira/skills/jira-management/SKILL.md +1 -3
  132. package/src/orchestrator/plugins/linear/skills/linear-task-management/SKILL.md +1 -3
  133. package/src/orchestrator/plugins/netlify/skills/netlify-deployment/SKILL.md +2 -2
  134. package/src/orchestrator/plugins/nextjs/skills/nextjs-framework/SKILL.md +13 -6
  135. package/src/orchestrator/plugins/notion/config.ts +21 -17
  136. package/src/orchestrator/plugins/notion/skills/notion-knowledge-management/SKILL.md +8 -16
  137. package/src/orchestrator/plugins/nx/skills/nx-workspace/SKILL.md +2 -4
  138. package/src/orchestrator/plugins/playwright/skills/playwright-testing/SKILL.md +1 -3
  139. package/src/orchestrator/plugins/prisma/skills/prisma-database/SKILL.md +1 -3
  140. package/src/orchestrator/plugins/resend/skills/resend-email/SKILL.md +2 -2
  141. package/src/orchestrator/plugins/sanity/skills/sanity-cms/SKILL.md +1 -3
  142. package/src/orchestrator/plugins/sentry/skills/sentry-monitoring/SKILL.md +1 -1
  143. package/src/orchestrator/plugins/slack/skills/slack-notifications/SKILL.md +1 -3
  144. package/src/orchestrator/plugins/strapi/skills/strapi-cms/SKILL.md +1 -3
  145. package/src/orchestrator/plugins/stripe/skills/stripe-payments/SKILL.md +4 -4
  146. package/src/orchestrator/plugins/supabase/skills/supabase-database/SKILL.md +3 -5
  147. package/src/orchestrator/plugins/teams/skills/teams-notifications/SKILL.md +1 -3
  148. package/src/orchestrator/plugins/trello/skills/trello-task-management/SKILL.md +1 -1
  149. package/src/orchestrator/plugins/turborepo/skills/turborepo-monorepo/SKILL.md +15 -88
  150. package/src/orchestrator/plugins/vercel/skills/vercel-deployment/SKILL.md +2 -2
  151. package/src/orchestrator/plugins/vitest/skills/vitest-testing/SKILL.md +17 -150
  152. package/src/orchestrator/prompts/assess-complexity.prompt.md +1 -0
  153. package/src/orchestrator/prompts/create-skill.prompt.md +13 -67
  154. package/src/orchestrator/prompts/fix-convoy.prompt.md +1 -0
  155. package/src/orchestrator/prompts/fix-prd.prompt.md +1 -0
  156. package/src/orchestrator/prompts/generate-prd.prompt.md +1 -0
  157. package/src/orchestrator/prompts/resolve-pr-comments.prompt.md +2 -2
  158. package/src/orchestrator/prompts/validate-convoy.prompt.md +1 -0
  159. package/src/orchestrator/prompts/validate-prd.prompt.md +1 -0
  160. package/src/orchestrator/skills/accessibility-standards/REFERENCE.md +17 -12
  161. package/src/orchestrator/skills/accessibility-standards/SKILL.md +1 -1
  162. package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +3 -5
  163. package/src/orchestrator/skills/agent-hooks/SKILL.md +8 -6
  164. package/src/orchestrator/skills/api-patterns/SKILL.md +1 -1
  165. package/src/orchestrator/skills/code-commenting/SKILL.md +1 -1
  166. package/src/orchestrator/skills/context-map/REFERENCE.md +0 -2
  167. package/src/orchestrator/skills/context-map/SKILL.md +2 -2
  168. package/src/orchestrator/skills/data-engineering/REFERENCE.md +3 -9
  169. package/src/orchestrator/skills/data-engineering/SKILL.md +9 -16
  170. package/src/orchestrator/skills/decomposition/SKILL.md +1 -1
  171. package/src/orchestrator/skills/deployment-infrastructure/SKILL.md +4 -4
  172. package/src/orchestrator/skills/documentation-standards/SKILL.md +4 -2
  173. package/src/orchestrator/skills/fast-review/REFERENCE.md +0 -2
  174. package/src/orchestrator/skills/fast-review/SKILL.md +5 -5
  175. package/src/orchestrator/skills/frontend-design/REFERENCE.md +6 -28
  176. package/src/orchestrator/skills/frontend-design/SKILL.md +19 -9
  177. package/src/orchestrator/skills/git-workflow/SKILL.md +1 -1
  178. package/src/orchestrator/skills/memory-merger/SKILL.md +13 -15
  179. package/src/orchestrator/skills/observability-logging/SKILL.md +1 -1
  180. package/src/orchestrator/skills/orchestration-protocols/REFERENCE.md +5 -9
  181. package/src/orchestrator/skills/orchestration-protocols/SKILL.md +6 -6
  182. package/src/orchestrator/skills/panel-majority-vote/REFERENCE.md +0 -4
  183. package/src/orchestrator/skills/panel-majority-vote/SKILL.md +1 -1
  184. package/src/orchestrator/skills/panel-majority-vote/panel-report.template.md +0 -2
  185. package/src/orchestrator/skills/performance-optimization/SKILL.md +2 -2
  186. package/src/orchestrator/skills/project-consistency/SKILL.md +2 -2
  187. package/src/orchestrator/skills/project-consistency/TEMPLATES.md +0 -4
  188. package/src/orchestrator/skills/react-development/SKILL.md +3 -3
  189. package/src/orchestrator/skills/security-hardening/SKILL.md +5 -5
  190. package/src/orchestrator/skills/self-improvement/LESSON-CATEGORIES.md +0 -2
  191. package/src/orchestrator/skills/self-improvement/SKILL.md +1 -1
  192. package/src/orchestrator/skills/seo-patterns/SKILL.md +1 -1
  193. package/src/orchestrator/skills/session-checkpoints/CHECKPOINT-TEMPLATE.md +0 -2
  194. package/src/orchestrator/skills/session-checkpoints/SKILL.md +1 -1
  195. package/src/orchestrator/skills/team-lead-reference/SKILL.md +1 -1
  196. package/src/orchestrator/skills/technical-writing/SKILL.md +8 -13
  197. package/src/orchestrator/skills/testing-workflow/SKILL.md +6 -6
  198. package/src/orchestrator/skills/typescript-best-practices/SKILL.md +1 -1
  199. package/src/orchestrator/skills/unslop/SKILL.md +1 -1
  200. package/src/orchestrator/skills/validation-gates/REFERENCE.md +6 -31
  201. package/src/orchestrator/skills/validation-gates/SKILL.md +12 -26
  202. package/src/orchestrator/skills/writing-for-agents/SKILL.md +2 -2
  203. package/src/orchestrator/skills/documentation-standards/WRITING-GUIDE.md +0 -39
  204. package/src/orchestrator/skills/frontend-design/COMPONENTS.md +0 -113
@@ -63,6 +63,15 @@ export interface RulesDirConfig {
63
63
  skillsDir: string
64
64
  /** The project MCP config, when it is not `<configDir>/mcp.json`. */
65
65
  mcpConfigPath?: string
66
+ /**
67
+ * Root files this assistant also applies to every conversation, and the
68
+ * targets that write them. With one of those selected the instructions are
69
+ * already in context through that file, so they are not written as rules as
70
+ * well: Cursor always applies `CLAUDE.md` and reads `AGENTS.md`, and with
71
+ * Claude Code, Codex or OpenCode also selected it loaded every instruction
72
+ * twice.
73
+ */
74
+ alsoReads?: Array<{ rootFile: string; writtenBy: IdeChoice[] }>
66
75
  }
67
76
 
68
77
  export interface RulesDirAdapter {
@@ -71,7 +80,7 @@ export interface RulesDirAdapter {
71
80
  install(pkgRoot: string, projectRoot: string, stack?: StackConfig, repoInfo?: RepoInfo, source?: CompileSource): Promise<CopyResults>
72
81
  update(pkgRoot: string, projectRoot: string, stack?: StackConfig, repoInfo?: RepoInfo, source?: CompileSource): Promise<CopyResults>
73
82
  getManagedPaths(): ManagedPaths
74
- getDoctorChecks(): DoctorCheck[]
83
+ getDoctorChecks(_ides?: readonly IdeChoice[]): DoctorCheck[]
75
84
  }
76
85
 
77
86
  /**
@@ -111,13 +120,23 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
111
120
  const rulesPrefix = `${configDir}/rules`
112
121
  const mcpPath = config.mcpConfigPath ?? `${configDir}/mcp.json`
113
122
 
114
- const rootIntro = [
115
- '# Project Instructions',
116
- '',
117
- `All conventions, architecture, and project context live in \`${rulesPrefix}/\`. Read those files before making changes. ` +
118
- `Skills are in \`${config.skillsDir}/\` — load one when a task matches its description.`,
119
- '',
120
- ].join('\n')
123
+ /** The root file that already carries the instructions, when a target that writes it is selected. */
124
+ function sharedRootFile(ides: readonly IdeChoice[] | undefined): string | null {
125
+ return config.alsoReads?.find((r) => ides?.some((i) => r.writtenBy.includes(i)))?.rootFile ?? null
126
+ }
127
+
128
+ function rootIntro(shared: string | null): string {
129
+ const instructions = shared
130
+ ? `This project's instructions are in \`${shared}\`, which ${ideLabel} also applies to every conversation — ` +
131
+ `they are not repeated here, so they load once. Agents, workflows and prompts are in \`${rulesPrefix}/\`. `
132
+ : `All conventions, architecture, and project context live in \`${rulesPrefix}/\`. Read those files before making changes. `
133
+ return [
134
+ '# Project Instructions',
135
+ '',
136
+ instructions + `Skills are in \`${config.skillsDir}/\` — load one when a task matches its description.`,
137
+ '',
138
+ ].join('\n')
139
+ }
121
140
 
122
141
  /** Strip the source file's compound extension and apply the IDE's own. */
123
142
  function ruleName(name: string): string {
@@ -288,16 +307,17 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
288
307
 
289
308
  // Merged, not skipped: a project that already has a rules file keeps it and
290
309
  // gains the generated pointer in a managed block below.
310
+ const shared = sharedRootFile(stack?.ides)
291
311
  const rootFile = resolve(projectRoot, rootRulesFile)
292
312
  {
293
- const merge = await writeManagedBlock(rootFile, rootIntro)
313
+ const merge = await writeManagedBlock(rootFile, rootIntro(shared))
294
314
  recordMerge(results, rootFile, merge)
295
315
  }
296
316
 
297
317
  const rulesRoot = resolve(projectRoot, configDir, 'rules')
298
318
  await mkdir(rulesRoot, { recursive: true })
299
319
 
300
- await convertDir(srcRoot, 'instructions', rulesRoot, results, { alwaysApply: true })
320
+ if (!shared) await convertDir(srcRoot, 'instructions', rulesRoot, results, { alwaysApply: true })
301
321
  await convertDir(srcRoot, 'agents', resolve(rulesRoot, 'agents'), results, agentOptions)
302
322
  await copySkills(srcRoot, projectRoot, results, false)
303
323
  await convertDir(srcRoot, 'agent-workflows', resolve(rulesRoot, 'agent-workflows'), results, workflowOptions(srcRoot))
@@ -318,15 +338,16 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
318
338
  _repoInfo?: RepoInfo,
319
339
  source?: CompileSource,
320
340
  ): Promise<CopyResults> {
321
- return withSource(pkgRoot, stack, source, (src) => updateFrom(src, projectRoot))
341
+ return withSource(pkgRoot, stack, source, (src) => updateFrom(src, projectRoot, stack))
322
342
  }
323
343
 
324
- async function updateFrom(src: CompileSource, projectRoot: string): Promise<CopyResults> {
344
+ async function updateFrom(src: CompileSource, projectRoot: string, stack: StackConfig | undefined): Promise<CopyResults> {
325
345
  const srcRoot = src.root
326
346
  const results: CopyResults = { copied: [], skipped: [], created: [] }
327
347
 
348
+ const shared = sharedRootFile(stack?.ides)
328
349
  const rootPath = resolve(projectRoot, rootRulesFile)
329
- const rootMerge = await writeManagedBlock(rootPath, rootIntro)
350
+ const rootMerge = await writeManagedBlock(rootPath, rootIntro(shared))
330
351
  // `unchanged` is not an update; counting it inflated the total by one on
331
352
  // every sync, on the same counter the recompilation bug had already made
332
353
  // meaningless.
@@ -348,10 +369,14 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
348
369
  for (const rel of filesUnderDir(root)) beforeSweep.set(resolve(root, rel), `${label}/${rel}`)
349
370
  }
350
371
 
351
- await convertDir(srcRoot, 'instructions', rulesRoot, results, {
352
- alwaysApply: true,
353
- overwrite: true,
354
- })
372
+ // Not written where a shared root file carries them: the sweep below then
373
+ // removes the copies an earlier sync wrote.
374
+ if (!shared) {
375
+ await convertDir(srcRoot, 'instructions', rulesRoot, results, {
376
+ alwaysApply: true,
377
+ overwrite: true,
378
+ })
379
+ }
355
380
  await convertDir(srcRoot, 'agents', resolve(rulesRoot, 'agents'), results, { ...agentOptions, overwrite: true })
356
381
  await copySkills(srcRoot, projectRoot, results, true)
357
382
  await convertDir(srcRoot, 'agent-workflows', resolve(rulesRoot, 'agent-workflows'), results, {
@@ -415,10 +440,13 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
415
440
  }
416
441
  }
417
442
 
418
- function getDoctorChecks(): DoctorCheck[] {
443
+ function getDoctorChecks(ides?: readonly IdeChoice[]): DoctorCheck[] {
444
+ const shared = sharedRootFile(ides)
419
445
  return [
420
446
  { label: `${ideLabel} rules file`, path: rootRulesFile, type: 'file' },
421
- { label: 'Instruction rules', path: `${rulesPrefix}/`, type: 'dir', countContents: true, countFilter: ruleExt },
447
+ shared
448
+ ? { label: `Instructions (in ${shared})`, path: shared, type: 'file' }
449
+ : { label: 'Instruction rules', path: `${rulesPrefix}/`, type: 'dir', countContents: true, countFilter: ruleExt },
422
450
  { label: 'Agent rules', path: `${rulesPrefix}/agents/`, type: 'dir', countContents: true, countFilter: ruleExt },
423
451
  { label: 'Skills directory', path: `${config.skillsDir}/`, type: 'dir', countContents: true },
424
452
  { label: 'Workflow rules', path: `${rulesPrefix}/agent-workflows/`, type: 'dir', countContents: true },
@@ -68,6 +68,14 @@ export interface SingleFileAdapterConfig {
68
68
  * agent inherits the session's tools and model.
69
69
  */
70
70
  agentFrontmatter?: boolean
71
+ /**
72
+ * The assistant lists the skills and agents it was given by itself, so the
73
+ * root file does not. Claude Code puts every skill's description and every
74
+ * subagent's description in context on its own; the "Available Skills" and
75
+ * "Agent Definitions" sections repeated them — about 3k tokens in a typical
76
+ * project, loaded twice in every session and again in every subagent.
77
+ */
78
+ listsSkillsAndAgents?: boolean
71
79
  }
72
80
 
73
81
  /** An agent's name as a subagent: its file name, lower-case and hyphenated. */
@@ -90,11 +98,20 @@ function commandDescription(content: string): string | undefined {
90
98
  return stripFrontmatter(content).match(/^#\s+(.+)$/m)?.[1]?.trim()
91
99
  }
92
100
 
93
- /** A command file: the body, under a description when the assistant lists one. */
101
+ /**
102
+ * A command file: the body, under a description when the assistant lists one.
103
+ *
104
+ * A convoy pipeline step (`pipeline: true`) is run by the CLI with its input
105
+ * filled in, never chosen by the model, so it is marked
106
+ * `disable-model-invocation`: Claude Code then leaves its description out of
107
+ * every session's context, and a person can still type it.
108
+ */
94
109
  function commandFile(content: string, withDescription: boolean): string {
95
110
  const body = stripFrontmatter(content) + '\n'
96
111
  const description = withDescription ? commandDescription(content) : undefined
97
- return description ? `---\ndescription: ${JSON.stringify(description)}\n---\n\n${body}` : body
112
+ if (!description) return body
113
+ const pipeline = parseFrontmatterMeta(content).pipeline === 'true'
114
+ return `---\ndescription: ${JSON.stringify(description)}\n${pipeline ? 'disable-model-invocation: true\n' : ''}---\n\n${body}`
98
115
  }
99
116
 
100
117
  /**
@@ -281,8 +298,10 @@ export function createSingleFileAdapter(
281
298
  sections.push(
282
299
  '# Project Instructions\n\n' +
283
300
  'All conventions, architecture, and project context are embedded below. ' +
284
- `Skills are in \`${refSkills}/\` — read them when a task matches. ` +
285
- `Agent definitions are in \`${refDir}/agents/\` — read the relevant file when adopting a persona.` +
301
+ (config.listsSkillsAndAgents
302
+ ? `The skills in \`${refSkills}/\` and the agents in \`${refDir}/agents/\` are listed by the assistant itself: load a skill when a task matches its description, and delegate to an agent by its description.`
303
+ : `Skills are in \`${refSkills}/\` — read them when a task matches. ` +
304
+ `Agent definitions are in \`${refDir}/agents/\` — read the relevant file when adopting a persona.`) +
286
305
  (sharedWith.length > 0
287
306
  ? `\n\nThis file is shared by more than one assistant. The same content is also installed under ${sharedWith
288
307
  .map((d) => `\`${d}/\``)
@@ -302,45 +321,58 @@ export function createSingleFileAdapter(
302
321
  }
303
322
  }
304
323
 
305
- // Agent reference
324
+ // Agent reference. An assistant that lists its subagents itself gets only
325
+ // what its listing lacks: which tier each agent's work wants.
306
326
  const agentsDir = resolve(srcRoot, 'agents')
307
327
  if (existsSync(agentsDir)) {
308
- const agentLines: string[] = ['\n---\n\n## Agent Definitions\n']
309
- agentLines.push(
310
- 'The following agent personas are available. Adopt the appropriate persona when asked.\n'
311
- )
312
- agentLines.push(
313
- 'Each names a capability tier — what kind of model the work wants. Pick a ' +
314
- 'concrete model yourself; you know which ones this account can reach.\n'
315
- )
316
- const usedTiers = new Set<Tier>()
328
+ const agents: Array<{ name: string; desc: string; tier: Tier }> = []
317
329
  for (const file of (await readdir(agentsDir)).sort()) {
318
330
  if (!file.endsWith('.md')) continue
319
- const meta = parseFrontmatterMeta(
320
- await readFile(resolve(agentsDir, file), 'utf8')
321
- )
322
- const name = meta['name'] ?? basename(file, '.agent.md')
323
- const desc = meta['description'] ?? ''
331
+ const meta = parseFrontmatterMeta(await readFile(resolve(agentsDir, file), 'utf8'))
324
332
  const declared = meta['tier'] ?? ''
325
- const tier = isTier(declared) ? declared : tierForAgent(basename(file, '.agent.md'))
326
- usedTiers.add(tier)
327
- agentLines.push(`- **${name}** *(${TIERS[tier].label})*: ${desc}`)
333
+ agents.push({
334
+ name: meta['name'] ?? basename(file, '.agent.md'),
335
+ desc: meta['description'] ?? '',
336
+ tier: isTier(declared) ? declared : tierForAgent(basename(file, '.agent.md')),
337
+ })
328
338
  }
329
- if (usedTiers.size > 0) {
330
- agentLines.push('')
331
- for (const id of TIER_IDS.filter((id) => usedTiers.has(id))) {
332
- agentLines.push(`- **${TIERS[id].label}** — ${TIERS[id].purpose}`)
339
+ const usedTiers = TIER_IDS.filter((id) => agents.some((a) => a.tier === id))
340
+ if (config.listsSkillsAndAgents) {
341
+ if (usedTiers.length > 0) {
342
+ sections.push(
343
+ [
344
+ '\n---\n\n## Agent Tiers\n',
345
+ 'Each agent names the kind of model its work wants; pick a concrete model you can reach.\n',
346
+ ...usedTiers.map((id) =>
347
+ `- *(${TIERS[id].label})* ${agents.filter((a) => a.tier === id).map((a) => a.name).join(', ')} — ${TIERS[id].purpose}`,
348
+ ),
349
+ ].join('\n'),
350
+ )
333
351
  }
352
+ } else {
353
+ const agentLines: string[] = ['\n---\n\n## Agent Definitions\n']
354
+ agentLines.push(
355
+ 'The following agent personas are available. Adopt the appropriate persona when asked.\n'
356
+ )
357
+ agentLines.push(
358
+ 'Each names a capability tier — what kind of model the work wants. Pick a ' +
359
+ 'concrete model yourself; you know which ones this account can reach.\n'
360
+ )
361
+ for (const a of agents) agentLines.push(`- **${a.name}** *(${TIERS[a.tier].label})*: ${a.desc}`)
362
+ if (usedTiers.length > 0) {
363
+ agentLines.push('')
364
+ for (const id of usedTiers) agentLines.push(`- **${TIERS[id].label}** — ${TIERS[id].purpose}`)
365
+ }
366
+ agentLines.push(
367
+ `\nFull agent definitions are in \`${refDir}/agents/\`. Read the relevant file when adopting a persona.`
368
+ )
369
+ sections.push(agentLines.join('\n'))
334
370
  }
335
- agentLines.push(
336
- `\nFull agent definitions are in \`${refDir}/agents/\`. Read the relevant file when adopting a persona.`
337
- )
338
- sections.push(agentLines.join('\n'))
339
371
  }
340
372
 
341
373
  // Skill index
342
374
  const skillsDir = resolve(srcRoot, 'skills')
343
- if (existsSync(skillsDir)) {
375
+ if (existsSync(skillsDir) && !config.listsSkillsAndAgents) {
344
376
  const skillLines: string[] = ['\n---\n\n## Available Skills\n']
345
377
  skillLines.push(
346
378
  'Skills are on-demand knowledge files. Read the file when the task matches.\n'
@@ -79,6 +79,18 @@ describe.skipIf(!cliBuilt)('init scans the project it initialises', () => {
79
79
  expect(text).not.toContain('TODO')
80
80
  })
81
81
 
82
+ it('loads the facts it wrote in every session, and the first check passes', () => {
83
+ run(projectRoot, 'init', '--yes')
84
+ const claude = readFileSync(join(projectRoot, 'CLAUDE.md'), 'utf8')
85
+ // Compiled into the always-loaded block, not left behind a "read this" line.
86
+ expect(claude).toContain('<!-- Source: instructions/project-context.instructions.md -->')
87
+ expect(claude).toContain('pnpm')
88
+ expect(claude).not.toContain('Still to describe')
89
+ // The facts were written before the assistants' files were compiled, so
90
+ // they agree from the start.
91
+ expect(() => execFileSync('node', [cli, 'sync', '--check'], { cwd: projectRoot, stdio: 'pipe' })).not.toThrow()
92
+ })
93
+
82
94
  it('leaves the user’s own notes alone when init is re-run', () => {
83
95
  run(projectRoot, 'init', '--yes')
84
96
  const stackFile = join(projectRoot, '.opencastle', 'stack', 'testing-config.md')
@@ -140,6 +140,23 @@ describe('Claude Code: /oc:<name>', () => {
140
140
  )
141
141
  })
142
142
 
143
+ it('keeps the convoy pipeline steps out of what the model is told it can run', async () => {
144
+ const src = materialize(resolveSources({ pkgRoot, projectRoot: project, stack }), pkgRoot)
145
+ try {
146
+ await (await IDE_ADAPTERS['claude-code']()).install(pkgRoot, project, stack, undefined, src)
147
+ } finally {
148
+ src.dispose()
149
+ }
150
+ const hidden = readdirSync(join(project, '.claude/commands/oc'))
151
+ .filter((f) => readFileSync(join(project, '.claude/commands/oc', f), 'utf8').includes('\ndisable-model-invocation: true\n'))
152
+ .sort()
153
+ // The CLI runs these with their input filled in; nobody chooses them.
154
+ expect(hidden).toEqual(['assess-complexity.md', 'fix-convoy.md', 'fix-prd.md', 'generate-prd.md', 'validate-convoy.md', 'validate-prd.md'])
155
+ // generate-convoy stays listed: the Team Lead plans in the editor by its rules.
156
+ expect(readFileSync(join(project, '.claude/commands/oc/generate-convoy.md'), 'utf8')).not.toContain('disable-model-invocation')
157
+ expect(readFileSync(join(project, '.claude/commands/oc/fix-prd.md'), 'utf8')).toMatch(/^---\ndescription: ".+"\ndisable-model-invocation: true\n---\n/)
158
+ })
159
+
143
160
  it('writes each agent as a subagent Claude Code registers: a name and a description', async () => {
144
161
  const src = materialize(resolveSources({ pkgRoot, projectRoot: project, stack }), pkgRoot)
145
162
  try {
@@ -460,3 +460,62 @@ describe('kept branches', () => {
460
460
  expect(task.output).toContain(kept!.branch)
461
461
  })
462
462
  })
463
+
464
+ describe('what workers report outside their task', () => {
465
+ const answer = (id: string) => [
466
+ `Done ${id}.`,
467
+ '',
468
+ '- [LESSON terminal] Run prisma generate before tsc — the client types are generated, not committed',
469
+ `[ISSUE] src/api.ts: the handler swallows a 404 (seen by ${id})`,
470
+ ].join('\n')
471
+ const reports: Behaviour = (task, options) => {
472
+ writeFileSync(join(options.cwd!, `${task.id}.txt`), 'x\n')
473
+ return { success: true, output: answer(task.id), exitCode: 0 }
474
+ }
475
+
476
+ it('adds the lessons to the branch once, as lesson files, and prints the issues', async () => {
477
+ // A project that commits its .opencastle/, as installs do.
478
+ writeFileSync(join(repo, '.gitignore'), '.opencastle/logs\n.opencastle/worktrees\n.opencastle/artifacts\n.opencastle/*.db\n.opencastle/*.db-*\n')
479
+ mkdirSync(join(repo, '.opencastle'), { recursive: true })
480
+ writeFileSync(join(repo, '.opencastle', 'project.instructions.md'), '# Project\n')
481
+ git('add', '-A')
482
+ git('commit', '-qm', 'opencastle')
483
+ let printed = ''
484
+ const result = await engine({
485
+ spec: spec([{ id: 'a', files: ['a.txt'] }, { id: 'b', files: ['b.txt'] }]),
486
+ adapter: stubAdapter(reports),
487
+ output: { write: (s: string) => { printed += s; return true }, isTTY: false },
488
+ }).run()
489
+
490
+ expect(result.status, whyNotDone(result.convoyId)).toBe('done')
491
+ const lessons = filesOn(result.branch!).filter((f) => f.startsWith('.opencastle/lessons/'))
492
+ expect(lessons).toHaveLength(1)
493
+ const file = git('show', `${result.branch}:${lessons[0]}`)
494
+ expect(file).toContain('title: "Run prisma generate before tsc"')
495
+ expect(file).toContain('category: "terminal"')
496
+ expect(file).toMatch(/source: "convoy .+, task a"/)
497
+ expect(git('show', `${result.branch}:.opencastle/LESSONS-LEARNED.md`)).toContain('Run prisma generate before tsc')
498
+ expect(git('log', '-1', '--format=%s', result.branch!)).toBe('convoy: 1 lesson(s) workers reported')
499
+ // Issues are printed, one per task that reported one.
500
+ expect(result.findings?.issues.map((i) => i.taskId).sort()).toEqual(['a', 'b'])
501
+ expect(printed).toContain('Lessons workers reported, added to the branch (1)')
502
+ expect(printed).toContain('the handler swallows a 404 (seen by a)')
503
+ // The user's checkout is untouched.
504
+ expect(git('status', '--porcelain')).toBe('')
505
+ expect(existsSync(join(repo, '.opencastle', 'lessons'))).toBe(false)
506
+ }, 30_000)
507
+
508
+ it('prints the lessons when the branch has no .opencastle/ to add them to', async () => {
509
+ let printed = ''
510
+ const result = await engine({
511
+ spec: spec([{ id: 'a', files: ['a.txt'] }]),
512
+ adapter: stubAdapter(reports),
513
+ output: { write: (s: string) => { printed += s; return true }, isTTY: false },
514
+ }).run()
515
+ expect(result.status, whyNotDone(result.convoyId)).toBe('done')
516
+ expect(filesOn(result.branch!).some((f) => f.startsWith('.opencastle/'))).toBe(false)
517
+ expect(result.findings?.recorded).toEqual([])
518
+ expect(result.findings?.unrecorded.map((l) => l.title)).toEqual(['Run prisma generate before tsc'])
519
+ expect(printed).toContain('Lessons workers reported (1)')
520
+ }, 30_000)
521
+ })
@@ -16,11 +16,13 @@ import {
16
16
  worktreesDirFor,
17
17
  workerBranchName,
18
18
  commitAllIn,
19
+ commitPathsIn,
19
20
  git,
20
21
  BranchInUseError,
21
22
  type WorktreeManager,
22
23
  } from './worktree.js'
23
24
  import { createMergeQueue, MergeConflictError, type MergeQueue } from './merge.js'
25
+ import { collectFindings, recordLessons, LESSON_PATHS, type ReportedIssue, type ReportedLesson } from './findings.js'
24
26
  import type {
25
27
  TaskRecord, ConvoyStatus, ConvoyTaskStatus, GuardConfig, CircuitBreakerConfig, TaskStep, Hook,
26
28
  TaskOutput, TaskInput, TDDGateConfig,
@@ -121,6 +123,14 @@ export interface ConvoyResult {
121
123
  logPath?: string
122
124
  /** Worker branches kept because their work could not be merged. */
123
125
  keptBranches?: Array<{ taskId: string; branch: string }>
126
+ /** What finished tasks reported outside their work. */
127
+ findings?: {
128
+ /** Lessons written to the branch, as `.opencastle/lessons/<id>.md`. */
129
+ recorded: Array<{ id: string; title: string }>
130
+ /** Lessons there was no `.opencastle/` or no git checkout to write to. */
131
+ unrecorded: ReportedLesson[]
132
+ issues: ReportedIssue[]
133
+ }
124
134
  }
125
135
 
126
136
  export interface ConvoyEngine {
@@ -2015,6 +2025,24 @@ async function runConvoy(ctx: RunContext): Promise<ConvoyResult> {
2015
2025
  }
2016
2026
  }
2017
2027
 
2028
+ // ── What workers found outside their tasks ───────────────────────────────
2029
+ // Read back from each finished task's stored answer, so a resumed run has
2030
+ // them all; lessons go on the branch, reviewed and merged with the work.
2031
+ const found = collectFindings(store.getTasksByConvoy(convoyId).filter(t => t.status === 'done'))
2032
+ let recorded: Array<{ id: string; title: string }> = []
2033
+ let unrecorded = found.lessons
2034
+ if (found.lessons.length > 0 && wtManager.commitAll && existsSync(join(workRoot, '.opencastle'))) {
2035
+ try {
2036
+ recorded = recordLessons(join(workRoot, '.opencastle'), found.lessons, convoyId)
2037
+ if (recorded.length > 0) {
2038
+ await commitPathsIn(workRoot, LESSON_PATHS, `convoy: ${recorded.length} lesson(s) workers reported`)
2039
+ }
2040
+ unrecorded = []
2041
+ } catch (err) {
2042
+ progress.line(` ${c.yellow('!')} could not record the lessons workers reported: ${firstLine((err as Error).message)}`)
2043
+ }
2044
+ }
2045
+
2018
2046
  // ── Final status ──────────────────────────────────────────────────────────
2019
2047
  const allTasksFinal = store.getTasksByConvoy(convoyId)
2020
2048
  const summary = summarize(allTasksFinal)
@@ -2051,6 +2079,9 @@ async function runConvoy(ctx: RunContext): Promise<ConvoyResult> {
2051
2079
  baseRef: ctx.baseRef,
2052
2080
  logPath: ndjsonPath,
2053
2081
  keptBranches: allTasksFinal.filter(t => t.branch).map(t => ({ taskId: t.id, branch: t.branch! })),
2082
+ ...(recorded.length + unrecorded.length + found.issues.length > 0 && {
2083
+ findings: { recorded, unrecorded, issues: found.issues },
2084
+ }),
2054
2085
  }
2055
2086
 
2056
2087
  function summarize(tasks: TaskRecord[]): ConvoyResult['summary'] {
@@ -2148,6 +2179,19 @@ function printSummary(progress: Progress, result: ConvoyResult, store: ConvoySto
2148
2179
  const cost = formatCost(result.cost.total_cost_usd, Boolean(result.cost.estimated))
2149
2180
  lines.push(` Spent: ${formatTokens(result.cost.total_tokens)} tokens${result.cost.estimated && !cost ? ' (est.)' : ''}${cost ? ` · ${cost}` : ''}`)
2150
2181
  }
2182
+ const f = result.findings
2183
+ if (f && f.recorded.length > 0) {
2184
+ lines.push(` Lessons workers reported, added to the branch (${f.recorded.length}):`)
2185
+ for (const l of f.recorded) lines.push(` ${c.dim('•')} ${l.title} ${c.dim(`(.opencastle/lessons/${l.id}.md)`)}`)
2186
+ }
2187
+ if (f && f.unrecorded.length > 0) {
2188
+ lines.push(` Lessons workers reported (${f.unrecorded.length}):`)
2189
+ for (const l of f.unrecorded) lines.push(` ${c.dim('•')} ${l.detail} ${c.dim(`(${l.taskId})`)}`)
2190
+ }
2191
+ if (f && f.issues.length > 0) {
2192
+ lines.push(` Issues workers found outside their tasks (${f.issues.length}):`)
2193
+ for (const i of f.issues) lines.push(` ${c.dim('•')} ${i.text} ${c.dim(`(${i.taskId})`)}`)
2194
+ }
2151
2195
  lines.push(` Convoy: ${result.convoyId}`)
2152
2196
  if (result.branch) {
2153
2197
  lines.push(` Branch: ${c.bold(result.branch)}${result.baseRef ? c.dim(` (from ${result.baseRef})`) : ''}`)
@@ -0,0 +1,86 @@
1
+ import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
2
+ import { tmpdir } from 'node:os'
3
+ import { join } from 'node:path'
4
+ import { afterEach, beforeEach, describe, expect, it } from 'vitest'
5
+ import { collectFindings, extractFindings, recordLessons } from './findings.js'
6
+ import { readLessons, renderLesson, syncLessons } from '../lessons.js'
7
+
8
+ describe('reading a worker’s answer', () => {
9
+ it('reads a lesson in each shape a worker writes one', () => {
10
+ const out = [
11
+ '[LESSON terminal] Quote paths in shell commands — the repo has a folder with a space',
12
+ '- [LESSON git] Rebase onto main before pushing -- CI checks the merge result',
13
+ '* **[LESSON]** Run the seed script before the e2e tests',
14
+ '[LESSON: database] Use the pooled URL in serverless functions – direct connections run out',
15
+ 'Not a lesson: [LESSON terminal] in the middle of a line',
16
+ ].join('\n')
17
+ expect(extractFindings('t1', out).lessons).toEqual([
18
+ { taskId: 't1', category: 'terminal', title: 'Quote paths in shell commands', detail: 'Quote paths in shell commands — the repo has a folder with a space' },
19
+ { taskId: 't1', category: 'git', title: 'Rebase onto main before pushing', detail: 'Rebase onto main before pushing -- CI checks the merge result' },
20
+ { taskId: 't1', category: 'general', title: 'Run the seed script before the e2e tests', detail: 'Run the seed script before the e2e tests' },
21
+ { taskId: 't1', category: 'database', title: 'Use the pooled URL in serverless functions', detail: 'Use the pooled URL in serverless functions – direct connections run out' },
22
+ ])
23
+ })
24
+
25
+ it('files a lesson under general when its category is not one there is', () => {
26
+ expect(extractFindings('t1', '[LESSON tooling] Use pnpm, not npm').lessons[0].category).toBe('general')
27
+ })
28
+
29
+ it('reads issues', () => {
30
+ expect(extractFindings('t2', 'ok\n- [ISSUE] src/a.ts: off by one in the pager\n[ISSUE]\n').issues).toEqual([
31
+ { taskId: 't2', text: 'src/a.ts: off by one in the pager' },
32
+ ])
33
+ })
34
+
35
+ it('keeps a lesson two workers reported once, and every issue', () => {
36
+ const found = collectFindings([
37
+ { id: 'a', output: '[LESSON] Run codegen first\n[ISSUE] x' },
38
+ { id: 'b', output: '[LESSON] run codegen first — again\n[ISSUE] y' },
39
+ { id: 'c', output: null },
40
+ ])
41
+ expect(found.lessons.map((l) => l.taskId)).toEqual(['a'])
42
+ expect(found.issues.map((i) => i.text)).toEqual(['x', 'y'])
43
+ })
44
+ })
45
+
46
+ describe('recording the lessons', () => {
47
+ let dir: string
48
+
49
+ beforeEach(() => {
50
+ dir = join(mkdtempSync(join(tmpdir(), 'oc-findings-')), '.opencastle')
51
+ mkdirSync(dir)
52
+ })
53
+
54
+ afterEach(() => rmSync(join(dir, '..'), { recursive: true, force: true }))
55
+
56
+ const reported = (title: string, detail = title) => ({ taskId: 'a', category: 'terminal', title, detail })
57
+
58
+ it('writes a lesson file with where it came from, and lists it in the index', () => {
59
+ const written = recordLessons(dir, [reported('Run codegen first', 'Run codegen first — types are generated')], 'cv-1')
60
+ expect(written).toHaveLength(1)
61
+ const [lesson] = readLessons(dir).lessons
62
+ expect(lesson).toMatchObject({ title: 'Run codegen first', category: 'terminal', severity: 'medium', source: 'convoy cv-1, task a', status: 'active' })
63
+ expect(lesson.body).toBe('**Problem:** Run codegen first — types are generated')
64
+ expect(readFileSync(join(dir, 'LESSONS-LEARNED.md'), 'utf8')).toContain('Run codegen first')
65
+ })
66
+
67
+ it('skips a lesson the project already has, so a resumed run adds nothing twice', () => {
68
+ mkdirSync(join(dir, 'lessons'))
69
+ writeFileSync(join(dir, 'lessons', 'x.md'), renderLesson({
70
+ id: 'x', title: 'Run codegen first', category: 'terminal', severity: 'high', added: '2026-10-01', citations: [], status: 'active', body: '**Problem:** p',
71
+ }))
72
+ syncLessons(dir)
73
+ expect(recordLessons(dir, [reported('run codegen first')], 'cv-1')).toEqual([])
74
+ expect(readdirSync(join(dir, 'lessons'))).toEqual(['x.md'])
75
+ })
76
+
77
+ it('skips a lesson that looks like it holds a credential', () => {
78
+ const key = ['AKIA', 'IOSFODNN7', 'EXAMPLE'].join('')
79
+ expect(recordLessons(dir, [reported('Use the deploy key', `Use the deploy key ${key}`)], 'cv-1')).toEqual([])
80
+ })
81
+
82
+ it('writes nothing where there is no .opencastle/', () => {
83
+ rmSync(dir, { recursive: true })
84
+ expect(recordLessons(dir, [reported('Run codegen first')], 'cv-1')).toEqual([])
85
+ })
86
+ })