opencastle 1.4.1 → 1.4.2

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 (70) hide show
  1. package/dist/cli/adapters/adapter-contract.test.js +85 -2
  2. package/dist/cli/adapters/adapter-contract.test.js.map +1 -1
  3. package/dist/cli/adapters/antigravity.d.ts +5 -4
  4. package/dist/cli/adapters/antigravity.d.ts.map +1 -1
  5. package/dist/cli/adapters/antigravity.js +5 -4
  6. package/dist/cli/adapters/antigravity.js.map +1 -1
  7. package/dist/cli/adapters/rules-dir-base.d.ts.map +1 -1
  8. package/dist/cli/adapters/rules-dir-base.js +25 -19
  9. package/dist/cli/adapters/rules-dir-base.js.map +1 -1
  10. package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
  11. package/dist/cli/adapters/single-file-base.js +10 -7
  12. package/dist/cli/adapters/single-file-base.js.map +1 -1
  13. package/dist/cli/adapters/vscode.d.ts.map +1 -1
  14. package/dist/cli/adapters/vscode.js +11 -5
  15. package/dist/cli/adapters/vscode.js.map +1 -1
  16. package/dist/cli/adapters/workflows.d.ts +33 -0
  17. package/dist/cli/adapters/workflows.d.ts.map +1 -0
  18. package/dist/cli/adapters/workflows.js +58 -0
  19. package/dist/cli/adapters/workflows.js.map +1 -0
  20. package/dist/cli/adapters/workflows.test.d.ts +2 -0
  21. package/dist/cli/adapters/workflows.test.d.ts.map +1 -0
  22. package/dist/cli/adapters/workflows.test.js +62 -0
  23. package/dist/cli/adapters/workflows.test.js.map +1 -0
  24. package/dist/cli/docs-accuracy.test.js +3 -3
  25. package/dist/cli/docs-accuracy.test.js.map +1 -1
  26. package/dist/cli/explain.d.ts.map +1 -1
  27. package/dist/cli/explain.js +3 -1
  28. package/dist/cli/explain.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/cli/adapters/adapter-contract.test.ts +89 -2
  31. package/src/cli/adapters/antigravity.ts +5 -4
  32. package/src/cli/adapters/rules-dir-base.ts +30 -19
  33. package/src/cli/adapters/single-file-base.ts +10 -6
  34. package/src/cli/adapters/vscode.ts +11 -4
  35. package/src/cli/adapters/workflows.test.ts +70 -0
  36. package/src/cli/adapters/workflows.ts +62 -0
  37. package/src/cli/docs-accuracy.test.ts +3 -3
  38. package/src/cli/explain.ts +3 -1
  39. package/src/orchestrator/agent-workflows/README.md +2 -0
  40. package/src/orchestrator/agent-workflows/bug-fix.md +3 -3
  41. package/src/orchestrator/agent-workflows/data-pipeline.md +2 -2
  42. package/src/orchestrator/agent-workflows/database-migration.md +2 -2
  43. package/src/orchestrator/agent-workflows/feature-implementation.md +2 -2
  44. package/src/orchestrator/agent-workflows/performance-optimization.md +3 -3
  45. package/src/orchestrator/agent-workflows/refactoring.md +2 -2
  46. package/src/orchestrator/agent-workflows/schema-changes.md +2 -2
  47. package/src/orchestrator/agent-workflows/security-audit.md +2 -2
  48. package/src/orchestrator/agents/architect.agent.md +1 -1
  49. package/src/orchestrator/agents/content-engineer.agent.md +1 -1
  50. package/src/orchestrator/agents/data-engineer.agent.md +1 -1
  51. package/src/orchestrator/agents/developer.agent.md +1 -1
  52. package/src/orchestrator/agents/devops-expert.agent.md +1 -1
  53. package/src/orchestrator/agents/performance-expert.agent.md +1 -1
  54. package/src/orchestrator/agents/researcher.agent.md +1 -1
  55. package/src/orchestrator/agents/security-expert.agent.md +1 -1
  56. package/src/orchestrator/agents/team-lead.agent.md +3 -4
  57. package/src/orchestrator/agents/testing-expert.agent.md +1 -1
  58. package/src/orchestrator/agents/ui-ux-expert.agent.md +1 -1
  59. package/src/orchestrator/agents/writer.agent.md +1 -1
  60. package/src/orchestrator/instructions/general.instructions.md +2 -2
  61. package/src/orchestrator/plugins/chrome-devtools/skills/browser-testing/SKILL.md +1 -1
  62. package/src/orchestrator/plugins/nx/skills/nx-workspace/SKILL.md +1 -1
  63. package/src/orchestrator/prompts/brainstorm.prompt.md +1 -1
  64. package/src/orchestrator/prompts/bug-fix.prompt.md +3 -3
  65. package/src/orchestrator/prompts/implement-feature.prompt.md +2 -2
  66. package/src/orchestrator/prompts/quick-refinement.prompt.md +2 -2
  67. package/src/orchestrator/skills/api-patterns/SKILL.md +1 -1
  68. package/src/orchestrator/skills/deployment-infrastructure/SKILL.md +1 -1
  69. package/src/orchestrator/skills/team-lead-reference/SKILL.md +11 -11
  70. package/src/orchestrator/skills/validation-gates/SKILL.md +1 -1
@@ -7,6 +7,7 @@ import { scaffoldMcpConfigInto } from '../mcp.js'
7
7
  import type { CopyResults, DoctorCheck, IdeChoice, ManagedPaths, RepoInfo, StackConfig } from '../types.js'
8
8
  import { splitFrontmatter, parseFrontmatterString } from './frontmatter.js'
9
9
  import { writeManagedBlock, recordMerge } from '../managed-block.js'
10
+ import { SHARED_PHASE_FILE, inlineSharedPhase, pointAtWorkflows, readSharedPhase } from './workflows.js'
10
11
 
11
12
  /**
12
13
  * Shared implementation for IDEs that take a root rules file plus a directory of
@@ -128,14 +129,17 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
128
129
  interface ConvertFileOptions {
129
130
  alwaysApply?: boolean
130
131
  descriptionFallback?: string
132
+ /** Rewrites the body for this target before it is written. */
133
+ transform?: (body: string) => string
131
134
  }
132
135
 
133
136
  async function convertFile(
134
137
  srcPath: string,
135
- { alwaysApply = false, descriptionFallback = '' }: ConvertFileOptions = {},
138
+ { alwaysApply = false, descriptionFallback = '', transform }: ConvertFileOptions = {},
136
139
  ): Promise<string> {
137
140
  const content = await readFile(srcPath, 'utf8')
138
- const { frontmatter, body } = splitFrontmatter(content)
141
+ const { frontmatter, body: source } = splitFrontmatter(content)
142
+ const body = transform ? transform(source) : source
139
143
  const meta = parseFrontmatterString(frontmatter)
140
144
 
141
145
  // Description: frontmatter > fallback > first heading
@@ -203,6 +207,7 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
203
207
  removeExt?: string
204
208
  overwrite?: boolean
205
209
  excludeFiles?: Set<string>
210
+ transform?: (body: string) => string
206
211
  }
207
212
 
208
213
  async function convertDir(
@@ -210,7 +215,7 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
210
215
  dirName: string,
211
216
  destDir: string,
212
217
  results: CopyResults,
213
- { alwaysApply, descriptionPrefix, removeExt, overwrite, excludeFiles }: ConvertDirOptions = {},
218
+ { alwaysApply, descriptionPrefix, removeExt, overwrite, excludeFiles, transform }: ConvertDirOptions = {},
214
219
  ): Promise<void> {
215
220
  const srcDir = resolve(srcRoot, dirName)
216
221
  if (!existsSync(srcDir)) return
@@ -226,13 +231,30 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
226
231
  await writeConverted(
227
232
  resolve(srcDir, file),
228
233
  resolve(destDir, ruleName(file)),
229
- { alwaysApply: alwaysApply ?? false, descriptionFallback: fallback },
234
+ { alwaysApply: alwaysApply ?? false, descriptionFallback: fallback, transform },
230
235
  results,
231
236
  overwrite,
232
237
  )
233
238
  }
234
239
  }
235
240
 
241
+ /** Agents, pointed at the templates where this target writes them. */
242
+ const agentOptions: ConvertDirOptions = {
243
+ descriptionPrefix: 'Agent: ',
244
+ removeExt: '.agent.md',
245
+ transform: (body) => pointAtWorkflows(body, `${rulesPrefix}/agent-workflows/`),
246
+ }
247
+
248
+ /** The templates, each with the shared delivery phase in it, and not the phase on its own. */
249
+ function workflowOptions(srcRoot: string): ConvertDirOptions {
250
+ const shared = readSharedPhase(srcRoot)
251
+ return {
252
+ descriptionPrefix: 'Workflow: ',
253
+ excludeFiles: new Set(['README.md', SHARED_PHASE_FILE]),
254
+ transform: (body) => inlineSharedPhase(body, shared),
255
+ }
256
+ }
257
+
236
258
  /** Skills as Agent Skills: each `<name>/` folder, every file in it, frontmatter kept. */
237
259
  async function copySkills(srcRoot: string, projectRoot: string, results: CopyResults, overwrite: boolean): Promise<void> {
238
260
  const skillsDir = resolve(srcRoot, 'skills')
@@ -276,15 +298,9 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
276
298
  await mkdir(rulesRoot, { recursive: true })
277
299
 
278
300
  await convertDir(srcRoot, 'instructions', rulesRoot, results, { alwaysApply: true })
279
- await convertDir(srcRoot, 'agents', resolve(rulesRoot, 'agents'), results, {
280
- descriptionPrefix: 'Agent: ',
281
- removeExt: '.agent.md',
282
- })
301
+ await convertDir(srcRoot, 'agents', resolve(rulesRoot, 'agents'), results, agentOptions)
283
302
  await copySkills(srcRoot, projectRoot, results, false)
284
- await convertDir(srcRoot, 'agent-workflows', resolve(rulesRoot, 'agent-workflows'), results, {
285
- descriptionPrefix: 'Workflow: ',
286
- excludeFiles: new Set(['README.md']),
287
- })
303
+ await convertDir(srcRoot, 'agent-workflows', resolve(rulesRoot, 'agent-workflows'), results, workflowOptions(srcRoot))
288
304
  await convertDir(srcRoot, 'prompts', resolve(rulesRoot, 'prompts'), results, {
289
305
  descriptionPrefix: 'Prompt: ',
290
306
  removeExt: '.prompt.md',
@@ -336,16 +352,11 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
336
352
  alwaysApply: true,
337
353
  overwrite: true,
338
354
  })
339
- await convertDir(srcRoot, 'agents', resolve(rulesRoot, 'agents'), results, {
340
- descriptionPrefix: 'Agent: ',
341
- removeExt: '.agent.md',
342
- overwrite: true,
343
- })
355
+ await convertDir(srcRoot, 'agents', resolve(rulesRoot, 'agents'), results, { ...agentOptions, overwrite: true })
344
356
  await copySkills(srcRoot, projectRoot, results, true)
345
357
  await convertDir(srcRoot, 'agent-workflows', resolve(rulesRoot, 'agent-workflows'), results, {
346
- descriptionPrefix: 'Workflow: ',
358
+ ...workflowOptions(srcRoot),
347
359
  overwrite: true,
348
- excludeFiles: new Set(['README.md']),
349
360
  })
350
361
  await convertDir(srcRoot, 'prompts', resolve(rulesRoot, 'prompts'), results, {
351
362
  descriptionPrefix: 'Prompt: ',
@@ -8,6 +8,7 @@ import { scaffoldMcpConfigInto } from '../mcp.js'
8
8
  import { withSource, type CompileSource } from '../layers.js'
9
9
  import type { CopyResults, DoctorCheck, IdeAdapter, IdeChoice, ManagedPaths, RepoInfo, StackConfig } from '../types.js'
10
10
  import { stripFrontmatter, parseFrontmatterMeta } from './frontmatter.js'
11
+ import { inlineSharedPhase, isWorkflowTemplate, pointAtWorkflows, readSharedPhase } from './workflows.js'
11
12
 
12
13
  /**
13
14
  * Configuration for adapters that produce a single root instructions file
@@ -389,15 +390,17 @@ export function createSingleFileAdapter(
389
390
 
390
391
  const dotDirPath = resolve(projectRoot, config.dotDir)
391
392
 
392
- // 2. Agent definitions → dotDir/agents/
393
+ // 2. Agent definitions → dotDir/agents/, pointed at the templates where
394
+ // this target writes them (step 5)
393
395
  const agentsDir = resolve(srcRoot, 'agents')
394
396
  if (existsSync(agentsDir)) {
395
397
  const destAgents = resolve(dotDirPath, 'agents')
396
398
  await mkdir(destAgents, { recursive: true })
399
+ const workflowsAt = `${config.dotDir}/${config.workflowsDir}/${config.workflowPrefix ? `${config.workflowPrefix}*.md` : ''}`
397
400
  for (const file of await readdir(agentsDir)) {
398
401
  if (!file.endsWith('.md')) continue
399
402
  const destPath = resolve(destAgents, file)
400
- const content = await readFile(resolve(agentsDir, file), 'utf8')
403
+ const content = pointAtWorkflows(await readFile(resolve(agentsDir, file), 'utf8'), workflowsAt)
401
404
  await emit(projectRoot, destPath, agentFile(file, content, config.agentFrontmatter === true), overwrite, results)
402
405
  }
403
406
  }
@@ -446,17 +449,18 @@ export function createSingleFileAdapter(
446
449
  }
447
450
  }
448
451
 
449
- // 5. Agent Workflows → dotDir/<workflowsDir>/<prefix><name>.md
452
+ // 5. Agent Workflows → dotDir/<workflowsDir>/<prefix><name>.md, each with
453
+ // the shared delivery phase in it
450
454
  const wfDir = resolve(srcRoot, 'agent-workflows')
451
455
  if (existsSync(wfDir)) {
452
456
  const destWf = resolve(dotDirPath, config.workflowsDir)
453
457
  await mkdir(destWf, { recursive: true })
458
+ const shared = readSharedPhase(srcRoot)
454
459
  for (const file of await readdir(wfDir)) {
455
- if (!file.endsWith('.md')) continue
456
- if (file === 'README.md') continue
460
+ if (!isWorkflowTemplate(file)) continue
457
461
  const name = basename(file, '.md')
458
462
  const destPath = resolve(destWf, `${config.workflowPrefix}${name}.md`)
459
- const content = await readFile(resolve(wfDir, file), 'utf8')
463
+ const content = inlineSharedPhase(await readFile(resolve(wfDir, file), 'utf8'), shared)
460
464
  await emit(projectRoot, destPath, commandFile(content, config.commandDescriptions === true), overwrite, results)
461
465
  }
462
466
  }
@@ -8,6 +8,7 @@ import { getAgentTransform } from '../stack-config.js'
8
8
  import { withSource, type CompileSource } from '../layers.js'
9
9
  import type { CopyResults, CopyDirOptions, DoctorCheck, ManagedPaths, RepoInfo, StackConfig } from '../types.js'
10
10
  import { isOurVscodePrompt, legacyVscodePrompts, vscodePromptFile, withCommandName } from '../command-namespace.js'
11
+ import { inlineSharedPhase, isWorkflowTemplate, readSharedPhase } from './workflows.js'
11
12
 
12
13
  /**
13
14
  * VS Code / GitHub Copilot adapter.
@@ -45,6 +46,7 @@ const FRAMEWORK_DIRS = [
45
46
  */
46
47
  function copyRulesFor(
47
48
  dir: string,
49
+ srcRoot: string,
48
50
  stack?: StackConfig,
49
51
  ): Pick<CopyDirOptions, 'filter' | 'transform' | 'rename'> {
50
52
  if (dir === 'agents') {
@@ -65,8 +67,13 @@ function copyRulesFor(
65
67
  }
66
68
  if (dir === 'agent-workflows') {
67
69
  // The directory's own README documents the templates for contributors; it is
68
- // not one of them, and no other adapter installs it.
69
- return { filter: (name) => name !== 'README.md' }
70
+ // not one of them, and no other adapter installs it. The shared delivery
71
+ // phase goes into each template, as it does for every other target.
72
+ const shared = readSharedPhase(srcRoot)
73
+ return {
74
+ filter: isWorkflowTemplate,
75
+ transform: (content) => inlineSharedPhase(content, shared),
76
+ }
70
77
  }
71
78
  return {}
72
79
  }
@@ -141,7 +148,7 @@ async function installFrom(
141
148
  if (!existsSync(srcDir)) continue
142
149
  const destDir = resolve(destRoot, dir)
143
150
 
144
- const sub = await copyDir(srcDir, destDir, copyRulesFor(dir, stack))
151
+ const sub = await copyDir(srcDir, destDir, copyRulesFor(dir, srcRoot, stack))
145
152
  mergeCopyResults(results, sub)
146
153
  }
147
154
 
@@ -214,7 +221,7 @@ async function updateFrom(src: CompileSource, projectRoot: string, stack: StackC
214
221
  if (!existsSync(srcDir)) continue
215
222
  const destDir = resolve(destRoot, dir)
216
223
 
217
- const sub = await copyDir(srcDir, destDir, { overwrite: true, ...copyRulesFor(dir, stack) })
224
+ const sub = await copyDir(srcDir, destDir, { overwrite: true, ...copyRulesFor(dir, srcRoot, stack) })
218
225
  mergeCopyResults(results, sub)
219
226
  for (const abs of sub.visited ?? []) visited.add(abs)
220
227
  }
@@ -0,0 +1,70 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { inlineSharedPhase, isWorkflowTemplate, pointAtWorkflows } from './workflows.js'
3
+
4
+ const TEMPLATE = [
5
+ '# Workflow: Bug Fix',
6
+ '',
7
+ '### Phase 5: Delivery',
8
+ '',
9
+ '> **See [shared-delivery-phase.md](shared-delivery-phase.md) for the standard delivery steps.**',
10
+ '>',
11
+ '> Commit → Push → PR → tracker linkage. Team Lead owns delivery.',
12
+ '',
13
+ '## After',
14
+ '',
15
+ ].join('\n')
16
+
17
+ const SHARED = [
18
+ '<!-- ⚠️ This file is managed by OpenCastle. -->',
19
+ '',
20
+ '# Shared Delivery Phase',
21
+ '',
22
+ 'This phase is referenced by all workflow templates.',
23
+ '',
24
+ '## Steps',
25
+ '',
26
+ '1. **Do NOT merge**',
27
+ '',
28
+ '### Detail',
29
+ '',
30
+ ].join('\n')
31
+
32
+ describe('inlineSharedPhase', () => {
33
+ it('puts the phase where the pointer was, nested under the delivery heading', () => {
34
+ const out = inlineSharedPhase(TEMPLATE, SHARED)
35
+ expect(out).toContain('### Phase 5: Delivery\n\n#### Steps\n\n1. **Do NOT merge**\n\n##### Detail\n')
36
+ expect(out).not.toContain('shared-delivery-phase.md')
37
+ expect(out).not.toContain('Shared Delivery Phase')
38
+ expect(out).not.toContain('This file is managed')
39
+ expect(out).toContain('\n## After\n')
40
+ })
41
+
42
+ it('leaves a template without the pointer as it is', () => {
43
+ const own = '# Workflow: Ours\n\n## Phase 1: Do it\n'
44
+ expect(inlineSharedPhase(own, SHARED)).toBe(own)
45
+ })
46
+
47
+ it('keeps the words and drops the link when a layer left the phase out', () => {
48
+ const out = inlineSharedPhase(TEMPLATE, null)
49
+ expect(out).not.toContain('](shared-delivery-phase.md)')
50
+ expect(out).toContain('See the shared delivery phase for the standard delivery steps.')
51
+ })
52
+ })
53
+
54
+ describe('isWorkflowTemplate', () => {
55
+ it('is a template unless it is the README or the shared phase', () => {
56
+ expect(isWorkflowTemplate('bug-fix.md')).toBe(true)
57
+ expect(isWorkflowTemplate('README.md')).toBe(false)
58
+ expect(isWorkflowTemplate('shared-delivery-phase.md')).toBe(false)
59
+ expect(isWorkflowTemplate('notes.txt')).toBe(false)
60
+ })
61
+ })
62
+
63
+ describe('pointAtWorkflows', () => {
64
+ it("replaces Copilot's folder with this target's, and nothing else", () => {
65
+ const text = 'Search `.github/agent-workflows/`. Keep `.github/workflows/ci.yml`.'
66
+ expect(pointAtWorkflows(text, '.claude/commands/oc/workflow-*.md')).toBe(
67
+ 'Search `.claude/commands/oc/workflow-*.md`. Keep `.github/workflows/ci.yml`.',
68
+ )
69
+ })
70
+ })
@@ -0,0 +1,62 @@
1
+ import { existsSync, readFileSync } from 'node:fs'
2
+ import { resolve } from 'node:path'
3
+ import { stripFrontmatter } from './frontmatter.js'
4
+
5
+ /**
6
+ * The phase every workflow template ends with, written once in the source.
7
+ *
8
+ * It used to be installed beside the templates and linked from each of them,
9
+ * which worked in exactly one layout. Claude Code names its copy
10
+ * `workflow-shared-delivery-phase.md` and Cursor `shared-delivery-phase.mdc`,
11
+ * so the link `shared-delivery-phase.md` led nowhere there; and in Claude Code
12
+ * the fragment became a command of its own, `/oc:workflow-shared-delivery-phase`,
13
+ * that runs nothing. Each template now carries the phase itself, so a template
14
+ * is whole wherever it is read and the fragment is never installed.
15
+ */
16
+ export const SHARED_PHASE_FILE = 'shared-delivery-phase.md'
17
+
18
+ /** Is this file in `agent-workflows/` a template someone can run? */
19
+ export function isWorkflowTemplate(name: string): boolean {
20
+ return name.endsWith('.md') && name !== 'README.md' && name !== SHARED_PHASE_FILE
21
+ }
22
+
23
+ /** The shared phase as compiled from `srcRoot`, or null when no layer provides it. */
24
+ export function readSharedPhase(srcRoot: string): string | null {
25
+ const path = resolve(srcRoot, 'agent-workflows', SHARED_PHASE_FILE)
26
+ return existsSync(path) ? readFileSync(path, 'utf8') : null
27
+ }
28
+
29
+ /** A pointer to the shared phase: a blockquote whose first line links to it. */
30
+ const POINTER = /^>[^\n]*\]\(shared-delivery-phase\.md\)[^\n]*\n(?:>[^\n]*\n?)*/m
31
+
32
+ /**
33
+ * The template with its pointer to the shared phase replaced by the phase.
34
+ *
35
+ * The phase's own title and introduction are left out, and its sections are
36
+ * nested under the template's delivery heading. Without the phase — a team
37
+ * layer excluded it — the link is reduced to its words, so nothing points at a
38
+ * file that was never written.
39
+ */
40
+ export function inlineSharedPhase(template: string, shared: string | null): string {
41
+ if (!POINTER.test(template)) return template
42
+ if (shared === null) {
43
+ return template.replace(/\[([^\]]+)\]\(shared-delivery-phase\.md\)/g, 'the shared delivery phase')
44
+ }
45
+ const body = stripFrontmatter(shared)
46
+ .replace(/^<!--[\s\S]*?-->\s*/, '')
47
+ .replace(/^#\s[^\n]*\n+/, '')
48
+ // Everything before the first section is the phase describing itself.
49
+ const sections = body.slice(Math.max(0, body.search(/^##\s/m))).trim()
50
+ const nested = sections.replace(/^(#{2,4})(\s)/gm, '##$1$2')
51
+ return template.replace(POINTER, `${nested}\n`)
52
+ }
53
+
54
+ /**
55
+ * The source names the templates' folder as VS Code installs it,
56
+ * `.github/agent-workflows/`. Every other target writes them somewhere else,
57
+ * and the Team Lead was sent to search a folder that only a Copilot project
58
+ * has. `where` is this target's folder, or the glob for its files.
59
+ */
60
+ export function pointAtWorkflows(content: string, where: string): string {
61
+ return content.replaceAll('`.github/agent-workflows/`', `\`${where}\``)
62
+ }
@@ -43,9 +43,9 @@ const actual = {
43
43
  skills: countDirEntries(join(orchestrator, 'skills'), () => true),
44
44
  plugins: countDirEntries(join(orchestrator, 'plugins'), (n) => !n.endsWith('.ts')),
45
45
  // README.md documents the directory for contributors; it is not a template,
46
- // and no adapter installs it. shared-delivery-phase.md is installed, but it is
47
- // the phase every template ends with, not a template of its own — counting it
48
- // made the README say 9 while the template tables everywhere else list 8.
46
+ // and no adapter installs it. shared-delivery-phase.md is the phase every
47
+ // template ends with, compiled into each, not a template of its own — counting
48
+ // it made the README say 9 while the template tables everywhere else list 8.
49
49
  workflows: countDirEntries(
50
50
  join(orchestrator, 'agent-workflows'),
51
51
  (n) => n.endsWith('.md') && n !== 'README.md' && n !== 'shared-delivery-phase.md',
@@ -11,6 +11,7 @@ import { PLUGINS } from '../orchestrator/plugins/index.js'
11
11
  import { c } from './prompt.js'
12
12
  import { IDE_LABELS, type CliContext, type IdeChoice } from './types.js'
13
13
  import { COMMAND_NAMESPACE } from './command-namespace.js'
14
+ import { isWorkflowTemplate } from './adapters/workflows.js'
14
15
 
15
16
  /**
16
17
  * `opencastle explain`: what a new teammate's assistant is given here, and
@@ -163,7 +164,8 @@ function render(report: ExplainReport, all: boolean): void {
163
164
  ...(report.targets.some((t) => t.id === 'vscode') ? ['Copilot'] : []),
164
165
  ]
165
166
  for (const kind of ['skills', 'agents', 'prompts', 'workflows'] as const) {
166
- const items = ofKind(kind)
167
+ // The shared delivery phase is compiled into every template, not run on its own.
168
+ const items = ofKind(kind).filter(([ref]) => kind !== 'workflows' || isWorkflowTemplate(`${ref.slice(kind.length + 1)}.md`))
167
169
  if (items.length === 0) continue
168
170
  const team = items.filter(([, i]) => i.from !== 'opencastle' && !i.from.startsWith('plugin:'))
169
171
  const integrations = items.filter(([, i]) => i.from.startsWith('plugin:'))
@@ -22,3 +22,5 @@ Declarative workflow templates for common orchestration patterns. Inspired by Sa
22
22
  | [Schema Changes](schema-changes.md) | CMS schema modifications, query updates, content model changes |
23
23
  | [Database Migration](database-migration.md) | Database migrations, RLS policies, type generation, rollback |
24
24
  | [Refactoring](refactoring.md) | Safe code refactoring with baseline metrics and behavior preservation |
25
+
26
+ Every template ends by pointing at [the shared delivery phase](shared-delivery-phase.md). The compiler replaces that pointer with the phase itself, so each installed template is complete and the phase is not installed on its own.
@@ -18,7 +18,7 @@ Phase 5: Delivery (direct, Team Lead)
18
18
 
19
19
  ## Branch & Delivery Strategy
20
20
 
21
- Follow the **Delivery Outcome** in `general.instructions.md` and the **Branch Ownership** rules in `team-lead.agent.md`. Branch naming: `fix/<ticket-id>-<short-description>`.
21
+ The Team Lead creates the branch before any delegation and delivers it as the Delivery phase below describes. Branch naming: `fix/<ticket-id>-<short-description>`.
22
22
 
23
23
  ---
24
24
 
@@ -46,7 +46,7 @@ Follow the **Delivery Outcome** in `general.instructions.md` and the **Branch Ow
46
46
  - [ ] Bug **confirmed reproduced** with screenshot evidence (or documented as non-reproducible with investigation notes)
47
47
  - [ ] Severity assessed
48
48
  - [ ] Tracker issue created with reproduction steps and screenshot
49
- - [ ] Affected apps identified (see `project.instructions.md` for inventory)
49
+ - [ ] Affected apps identified (see `.opencastle/project.instructions.md` for inventory)
50
50
 
51
51
  ---
52
52
 
@@ -119,7 +119,7 @@ Follow the **Delivery Outcome** in `general.instructions.md` and the **Branch Ow
119
119
  - [ ] No regressions introduced
120
120
  - [ ] Tracker issue moved to Done
121
121
  - [ ] Known issues updated (if applicable)
122
- - [ ] Delivery Outcome completed (see `general.instructions.md`) — branch pushed, PR opened (not merged), tracker linked
122
+ - [ ] Delivery phase completed — branch pushed, PR opened (not merged), tracker linked
123
123
 
124
124
  ---
125
125
 
@@ -21,7 +21,7 @@ Phase 6: Delivery (direct, Team Lead)
21
21
 
22
22
  ## Branch & Delivery Strategy
23
23
 
24
- Follow the **Delivery Outcome** in `general.instructions.md` and the **Branch Ownership** rules in `team-lead.agent.md`. Branch naming: `feat/<ticket-id>-<short-description>`. Only code changes are committed — NDJSON data files in `tmp/` are NOT committed to Git.
24
+ The Team Lead creates the branch before any delegation and delivers it as the Delivery phase below describes. Branch naming: `feat/<ticket-id>-<short-description>`. Only code changes are committed — NDJSON data files in `tmp/` are NOT committed to Git.
25
25
 
26
26
  ---
27
27
 
@@ -137,7 +137,7 @@ Follow the **Delivery Outcome** in `general.instructions.md` and the **Branch Ow
137
137
  - [ ] Import statistics logged
138
138
  - [ ] <0.1% failure rate
139
139
  - [ ] Output contract returned
140
- - [ ] Delivery Outcome completed (see `general.instructions.md`) — branch pushed, PR opened (not merged), tracker linked
140
+ - [ ] Delivery phase completed — branch pushed, PR opened (not merged), tracker linked
141
141
 
142
142
  ---
143
143
 
@@ -21,7 +21,7 @@ Phase 6: Delivery (direct, Team Lead)
21
21
 
22
22
  ## Branch & Delivery Strategy
23
23
 
24
- Follow the **Delivery Outcome** in `general.instructions.md` and the **Branch Ownership** rules in `team-lead.agent.md`. Branch naming: `feat/<ticket-id>-<short-description>` or `fix/<ticket-id>-<short-description>`.
24
+ The Team Lead creates the branch before any delegation and delivers it as the Delivery phase below describes. Branch naming: `feat/<ticket-id>-<short-description>` or `fix/<ticket-id>-<short-description>`.
25
25
 
26
26
  ---
27
27
 
@@ -150,7 +150,7 @@ Follow the **Delivery Outcome** in `general.instructions.md` and the **Branch Ow
150
150
  - [ ] Panel review passed (if auth/RLS changes)
151
151
  - [ ] Rollback procedure documented
152
152
  - [ ] Tracker issue moved to Done
153
- - [ ] Delivery Outcome completed (see `general.instructions.md`) — branch pushed, PR opened (not merged), tracker linked
153
+ - [ ] Delivery phase completed — branch pushed, PR opened (not merged), tracker linked
154
154
 
155
155
  ---
156
156
 
@@ -128,7 +128,7 @@ If there are no open questions, explicitly state: "No open questions — plan is
128
128
 
129
129
  ### Typical Partitions
130
130
 
131
- > For project-specific paths, see `project.instructions.md` and the relevant `stack/` customization files.
131
+ > For project-specific paths, see `.opencastle/project.instructions.md` and the relevant `.opencastle/stack/` files.
132
132
 
133
133
  | Track | Agent | Files | Purpose |
134
134
  |-------|-------|-------|----------|
@@ -221,7 +221,7 @@ If there are no open questions, explicitly state: "No open questions — plan is
221
221
  - [ ] Full build passes
222
222
  - [ ] **Final smoke test passed** — complete user flow verified end-to-end
223
223
  - [ ] Roadmap updated
224
- - [ ] Delivery Outcome completed (see `general.instructions.md`) — branch pushed, PR opened (not merged), tracker linked
224
+ - [ ] Delivery phase completed — branch pushed, PR opened (not merged), tracker linked
225
225
 
226
226
  ---
227
227
 
@@ -18,7 +18,7 @@ Phase 5: Delivery (direct, Team Lead)
18
18
 
19
19
  ## Branch & Delivery Strategy
20
20
 
21
- Follow the **Delivery Outcome** in `general.instructions.md` and the **Branch Ownership** rules in `team-lead.agent.md`. Branch naming: `perf/<ticket-id>-<short-description>` or `feat/<ticket-id>-<short-description>`.
21
+ The Team Lead creates the branch before any delegation and delivers it as the Delivery phase below describes. Branch naming: `perf/<ticket-id>-<short-description>` or `feat/<ticket-id>-<short-description>`.
22
22
 
23
23
  ---
24
24
 
@@ -38,7 +38,7 @@ Follow the **Delivery Outcome** in `general.instructions.md` and the **Branch Ow
38
38
 
39
39
  ### Key Pages to Measure
40
40
 
41
- > See `project.instructions.md` for the app inventory and key routes. Prioritize pages with the most traffic and the most complex rendering.
41
+ > See `.opencastle/project.instructions.md` for the app inventory and key routes. Prioritize pages with the most traffic and the most complex rendering.
42
42
 
43
43
  ### Exit Criteria
44
44
 
@@ -116,7 +116,7 @@ Follow the **Delivery Outcome** in `general.instructions.md` and the **Branch Ow
116
116
  - [ ] No functional regressions
117
117
  - [ ] Results documented in tracker issue
118
118
  - [ ] Roadmap updated
119
- - [ ] Delivery Outcome completed (see `general.instructions.md`) — branch pushed, PR opened (not merged), tracker linked
119
+ - [ ] Delivery phase completed — branch pushed, PR opened (not merged), tracker linked
120
120
 
121
121
  ---
122
122
 
@@ -19,7 +19,7 @@ Phase 6: Delivery (direct, Team Lead)
19
19
 
20
20
  ## Branch & Delivery Strategy
21
21
 
22
- Follow the **Delivery Outcome** in `general.instructions.md` and the **Branch Ownership** rules in `team-lead.agent.md`. Branch naming: `refactor/<ticket-id>-<short-description>`.
22
+ The Team Lead creates the branch before any delegation and delivers it as the Delivery phase below describes. Branch naming: `refactor/<ticket-id>-<short-description>`.
23
23
 
24
24
  ---
25
25
 
@@ -133,7 +133,7 @@ The refactoring agent owns only the scoped files. No changes outside the partiti
133
133
  ### Exit Criteria
134
134
 
135
135
  - [ ] Panel PASS (2/3 majority)
136
- - [ ] Delivery Outcome completed (see `general.instructions.md`) — branch pushed, PR opened (not merged), tracker linked
136
+ - [ ] Delivery phase completed — branch pushed, PR opened (not merged), tracker linked
137
137
 
138
138
  ---
139
139
 
@@ -21,7 +21,7 @@ Phase 6: Delivery (direct, Team Lead)
21
21
 
22
22
  ## Branch & Delivery Strategy
23
23
 
24
- Follow the **Delivery Outcome** in `general.instructions.md` and the **Branch Ownership** rules in `team-lead.agent.md`. Branch naming: `feat/<ticket-id>-<short-description>` or `chore/<ticket-id>-<short-description>`.
24
+ The Team Lead creates the branch before any delegation and delivers it as the Delivery phase below describes. Branch naming: `feat/<ticket-id>-<short-description>` or `chore/<ticket-id>-<short-description>`.
25
25
 
26
26
  ---
27
27
 
@@ -155,7 +155,7 @@ Follow the **Delivery Outcome** in `general.instructions.md` and the **Branch Ow
155
155
  - [ ] Both apps verified (if shared code changed)
156
156
  - [ ] Data model documentation updated (if applicable)
157
157
  - [ ] Tracker issue moved to Done
158
- - [ ] Delivery Outcome completed (see `general.instructions.md`) — branch pushed, PR opened (not merged), tracker linked
158
+ - [ ] Delivery phase completed — branch pushed, PR opened (not merged), tracker linked
159
159
 
160
160
  ---
161
161
 
@@ -19,7 +19,7 @@ Phase 6: Delivery (direct, Team Lead)
19
19
 
20
20
  ## Branch & Delivery Strategy
21
21
 
22
- Follow the **Delivery Outcome** in `general.instructions.md` and the **Branch Ownership** rules in `team-lead.agent.md`. Branch naming: `fix/<ticket-id>-<short-description>` for remediations.
22
+ The Team Lead creates the branch before any delegation and delivers it as the Delivery phase below describes. Branch naming: `fix/<ticket-id>-<short-description>` for remediations.
23
23
 
24
24
  ---
25
25
 
@@ -139,7 +139,7 @@ Follow the **Delivery Outcome** in `general.instructions.md` and the **Branch Ow
139
139
  - [ ] Panel review passed (if applicable)
140
140
  - [ ] Known issues updated for accepted risks
141
141
  - [ ] All tracker issues updated
142
- - [ ] Delivery Outcome completed (see `general.instructions.md`) — branch pushed, PR opened (not merged), tracker linked
142
+ - [ ] Delivery phase completed — branch pushed, PR opened (not merged), tracker linked
143
143
 
144
144
  ---
145
145
 
@@ -14,7 +14,7 @@ architecture, performance at scale, i18n, monetization.
14
14
 
15
15
  ## Skills
16
16
 
17
- Resolve skills (slots, direct) via [skill-matrix.json](.opencastle/agents/skill-matrix.json).
17
+ Resolve skills (slots, direct) via `.opencastle/agents/skill-matrix.json`.
18
18
 
19
19
  ## Rules
20
20
 
@@ -12,7 +12,7 @@ CMS schema design, content queries and modeling, releases, studio customization.
12
12
 
13
13
  ## Skills
14
14
 
15
- Resolve skills (slots, direct) via [skill-matrix.json](.opencastle/agents/skill-matrix.json).
15
+ Resolve skills (slots, direct) via `.opencastle/agents/skill-matrix.json`.
16
16
 
17
17
  ## Rules
18
18
 
@@ -13,7 +13,7 @@ policies that guard them, and the pipelines that fill them.
13
13
 
14
14
  ## Skills
15
15
 
16
- Resolve skills (slots, direct) via [skill-matrix.json](.opencastle/agents/skill-matrix.json).
16
+ Resolve skills (slots, direct) via `.opencastle/agents/skill-matrix.json`.
17
17
 
18
18
  ## Rules — schema and migrations
19
19
 
@@ -13,7 +13,7 @@ feature implementation.
13
13
 
14
14
  ## Skills
15
15
 
16
- Resolve skills (slots, direct) via [skill-matrix.json](.opencastle/agents/skill-matrix.json).
16
+ Resolve skills (slots, direct) via `.opencastle/agents/skill-matrix.json`.
17
17
 
18
18
  ## Rules
19
19
 
@@ -13,7 +13,7 @@ pre-release verification, changelogs.
13
13
 
14
14
  ## Skills
15
15
 
16
- Resolve skills (slots, direct) via [skill-matrix.json](.opencastle/agents/skill-matrix.json).
16
+ Resolve skills (slots, direct) via `.opencastle/agents/skill-matrix.json`.
17
17
 
18
18
  ## Rules — deployment
19
19
 
@@ -12,7 +12,7 @@ Frontend, backend, and build performance.
12
12
 
13
13
  ## Skills
14
14
 
15
- Resolve skills (slots, direct) via [skill-matrix.json](.opencastle/agents/skill-matrix.json).
15
+ Resolve skills (slots, direct) via `.opencastle/agents/skill-matrix.json`.
16
16
 
17
17
  ## Rules
18
18
 
@@ -12,7 +12,7 @@ Codebase exploration: find information, map patterns, report back.
12
12
 
13
13
  ## Skills
14
14
 
15
- Resolve skills (slots, direct) via [skill-matrix.json](.opencastle/agents/skill-matrix.json).
15
+ Resolve skills (slots, direct) via `.opencastle/agents/skill-matrix.json`.
16
16
 
17
17
  ## Rules
18
18
 
@@ -13,7 +13,7 @@ API security, vulnerability management.
13
13
 
14
14
  ## Skills
15
15
 
16
- Resolve skills (slots, direct) via [skill-matrix.json](.opencastle/agents/skill-matrix.json).
16
+ Resolve skills (slots, direct) via `.opencastle/agents/skill-matrix.json`.
17
17
 
18
18
  ## Rules
19
19