opencastle 1.6.2 → 1.6.3

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 (145) hide show
  1. package/bin/cli.mjs +13 -8
  2. package/dist/cli/add.js +7 -7
  3. package/dist/cli/add.js.map +1 -1
  4. package/dist/cli/baseline.js +6 -6
  5. package/dist/cli/baseline.js.map +1 -1
  6. package/dist/cli/bootstrap.d.ts.map +1 -1
  7. package/dist/cli/bootstrap.js +14 -5
  8. package/dist/cli/bootstrap.js.map +1 -1
  9. package/dist/cli/bootstrap.test.js +8 -0
  10. package/dist/cli/bootstrap.test.js.map +1 -1
  11. package/dist/cli/ci.d.ts.map +1 -1
  12. package/dist/cli/ci.js +19 -9
  13. package/dist/cli/ci.js.map +1 -1
  14. package/dist/cli/convoy/engine.js +1 -1
  15. package/dist/cli/convoy/engine.js.map +1 -1
  16. package/dist/cli/convoy/engine.test.js +1 -1
  17. package/dist/cli/convoy/engine.test.js.map +1 -1
  18. package/dist/cli/convoy/spec-builder.js +2 -2
  19. package/dist/cli/convoy/spec-builder.js.map +1 -1
  20. package/dist/cli/convoy/spec-builder.test.js +2 -2
  21. package/dist/cli/convoy/spec-builder.test.js.map +1 -1
  22. package/dist/cli/convoy-cmd.js +16 -16
  23. package/dist/cli/convoy-cmd.js.map +1 -1
  24. package/dist/cli/convoy-cmd.test.js +11 -11
  25. package/dist/cli/convoy-cmd.test.js.map +1 -1
  26. package/dist/cli/dashboard.js +2 -2
  27. package/dist/cli/dashboard.js.map +1 -1
  28. package/dist/cli/dispatcher.test.js +2 -2
  29. package/dist/cli/dispatcher.test.js.map +1 -1
  30. package/dist/cli/doctor.js +17 -17
  31. package/dist/cli/doctor.js.map +1 -1
  32. package/dist/cli/explain.js +2 -2
  33. package/dist/cli/explain.js.map +1 -1
  34. package/dist/cli/fleet.js +1 -1
  35. package/dist/cli/github-report.js +5 -5
  36. package/dist/cli/github-report.js.map +1 -1
  37. package/dist/cli/gitignore.js +1 -1
  38. package/dist/cli/gitignore.js.map +1 -1
  39. package/dist/cli/init.d.ts.map +1 -1
  40. package/dist/cli/init.js +27 -10
  41. package/dist/cli/init.js.map +1 -1
  42. package/dist/cli/layers.js +4 -4
  43. package/dist/cli/layers.js.map +1 -1
  44. package/dist/cli/lesson.js +12 -12
  45. package/dist/cli/lesson.js.map +1 -1
  46. package/dist/cli/lessons.d.ts.map +1 -1
  47. package/dist/cli/lessons.js +11 -7
  48. package/dist/cli/lessons.js.map +1 -1
  49. package/dist/cli/managed-block.js +1 -1
  50. package/dist/cli/managed-block.js.map +1 -1
  51. package/dist/cli/mcp-audit.js +6 -6
  52. package/dist/cli/mcp-audit.js.map +1 -1
  53. package/dist/cli/mcp-audit.test.js +5 -5
  54. package/dist/cli/mcp-audit.test.js.map +1 -1
  55. package/dist/cli/pipeline.js +6 -6
  56. package/dist/cli/pipeline.js.map +1 -1
  57. package/dist/cli/plugin.js +8 -8
  58. package/dist/cli/plugin.js.map +1 -1
  59. package/dist/cli/promote.js +5 -5
  60. package/dist/cli/promote.js.map +1 -1
  61. package/dist/cli/prompt.d.ts.map +1 -1
  62. package/dist/cli/prompt.js +15 -2
  63. package/dist/cli/prompt.js.map +1 -1
  64. package/dist/cli/prompt.test.js +33 -8
  65. package/dist/cli/prompt.test.js.map +1 -1
  66. package/dist/cli/remove.js +1 -1
  67. package/dist/cli/review.js +3 -3
  68. package/dist/cli/review.js.map +1 -1
  69. package/dist/cli/run/adapters/index.js +3 -3
  70. package/dist/cli/run/adapters/index.js.map +1 -1
  71. package/dist/cli/run/adapters/index.test.js +3 -3
  72. package/dist/cli/run/adapters/index.test.js.map +1 -1
  73. package/dist/cli/run/schema.js +3 -3
  74. package/dist/cli/run/schema.js.map +1 -1
  75. package/dist/cli/run.js +21 -21
  76. package/dist/cli/run.js.map +1 -1
  77. package/dist/cli/run.test.js +3 -3
  78. package/dist/cli/run.test.js.map +1 -1
  79. package/dist/cli/stack-config-update.test.js +18 -1
  80. package/dist/cli/stack-config-update.test.js.map +1 -1
  81. package/dist/cli/stack-config.d.ts.map +1 -1
  82. package/dist/cli/stack-config.js +10 -1
  83. package/dist/cli/stack-config.js.map +1 -1
  84. package/dist/cli/status.js +9 -9
  85. package/dist/cli/status.js.map +1 -1
  86. package/dist/cli/status.test.js +3 -3
  87. package/dist/cli/status.test.js.map +1 -1
  88. package/dist/cli/sync-check.js +16 -16
  89. package/dist/cli/sync-check.js.map +1 -1
  90. package/dist/cli/sync.js +1 -1
  91. package/dist/cli/team-ci.test.js +3 -3
  92. package/dist/cli/team-ci.test.js.map +1 -1
  93. package/dist/cli/team-commands.test.js +30 -1
  94. package/dist/cli/team-commands.test.js.map +1 -1
  95. package/dist/cli/update.d.ts.map +1 -1
  96. package/dist/cli/update.js +33 -8
  97. package/dist/cli/update.js.map +1 -1
  98. package/package.json +1 -1
  99. package/src/cli/add.ts +7 -7
  100. package/src/cli/baseline.ts +6 -6
  101. package/src/cli/bootstrap.test.ts +9 -0
  102. package/src/cli/bootstrap.ts +15 -5
  103. package/src/cli/ci.ts +17 -9
  104. package/src/cli/convoy/engine.test.ts +1 -1
  105. package/src/cli/convoy/engine.ts +1 -1
  106. package/src/cli/convoy/spec-builder.test.ts +2 -2
  107. package/src/cli/convoy/spec-builder.ts +2 -2
  108. package/src/cli/convoy-cmd.test.ts +11 -11
  109. package/src/cli/convoy-cmd.ts +18 -18
  110. package/src/cli/dashboard.ts +2 -2
  111. package/src/cli/dispatcher.test.ts +2 -2
  112. package/src/cli/doctor.ts +17 -17
  113. package/src/cli/explain.ts +2 -2
  114. package/src/cli/fleet.ts +1 -1
  115. package/src/cli/github-report.ts +5 -5
  116. package/src/cli/gitignore.ts +1 -1
  117. package/src/cli/init.ts +26 -10
  118. package/src/cli/layers.ts +4 -4
  119. package/src/cli/lesson.ts +12 -12
  120. package/src/cli/lessons.ts +11 -7
  121. package/src/cli/managed-block.ts +1 -1
  122. package/src/cli/mcp-audit.test.ts +5 -5
  123. package/src/cli/mcp-audit.ts +6 -6
  124. package/src/cli/pipeline.ts +6 -6
  125. package/src/cli/plugin.ts +8 -8
  126. package/src/cli/promote.ts +5 -5
  127. package/src/cli/prompt.test.ts +41 -13
  128. package/src/cli/prompt.ts +14 -2
  129. package/src/cli/remove.ts +1 -1
  130. package/src/cli/review.ts +3 -3
  131. package/src/cli/run/adapters/index.test.ts +3 -3
  132. package/src/cli/run/adapters/index.ts +3 -3
  133. package/src/cli/run/schema.ts +3 -3
  134. package/src/cli/run.test.ts +3 -3
  135. package/src/cli/run.ts +21 -21
  136. package/src/cli/stack-config-update.test.ts +22 -1
  137. package/src/cli/stack-config.ts +9 -1
  138. package/src/cli/status.test.ts +3 -3
  139. package/src/cli/status.ts +9 -9
  140. package/src/cli/sync-check.ts +16 -16
  141. package/src/cli/sync.ts +1 -1
  142. package/src/cli/team-ci.test.ts +3 -3
  143. package/src/cli/team-commands.test.ts +32 -1
  144. package/src/cli/update.ts +31 -8
  145. package/src/orchestrator/customizations/LESSONS-LEARNED.md +5 -3
package/src/cli/lesson.ts CHANGED
@@ -22,9 +22,9 @@ import {
22
22
  } from './lessons.js'
23
23
 
24
24
  const HELP = `
25
- opencastle lesson [add] --title <text> --category <cat> --severity <level> --problem <text> [options]
26
- opencastle lesson verify <id> [--cite <path[:line]>]...
27
- opencastle lesson archive <id> --into <file>
25
+ npx opencastle lesson [add] --title <text> --category <cat> --severity <level> --problem <text> [options]
26
+ npx opencastle lesson verify <id> [--cite <path[:line]>]...
27
+ npx opencastle lesson archive <id> --into <file>
28
28
 
29
29
  Record what an agent learned the hard way, as a file in .opencastle/lessons/,
30
30
  and rewrite the index agents read before they start (.opencastle/${LESSONS_INDEX}).
@@ -55,7 +55,7 @@ const HELP = `
55
55
  --help, -h Show this help
56
56
 
57
57
  Examples:
58
- opencastle lesson \\
58
+ npx opencastle lesson \\
59
59
  --title "Always quote shell variables" \\
60
60
  --category terminal \\
61
61
  --severity medium \\
@@ -64,8 +64,8 @@ const HELP = `
64
64
  --correct 'rm -rf "$DIR/old"' \\
65
65
  --cite scripts/clean.sh:12
66
66
 
67
- opencastle lesson verify 2026-10-02-always-quote-shell-variables
68
- opencastle lesson archive 2026-10-02-always-quote-shell-variables \\
67
+ npx opencastle lesson verify 2026-10-02-always-quote-shell-variables
68
+ npx opencastle lesson archive 2026-10-02-always-quote-shell-variables \\
69
69
  --into .opencastle/skills/git-workflow/SKILL.md
70
70
  `
71
71
 
@@ -124,7 +124,7 @@ function parse(args: string[]): Parsed {
124
124
  if (a === '--cite') out.cites.push(value.trim())
125
125
  else out.values.set(a, value)
126
126
  } else if (a.startsWith('-')) {
127
- fail(`unknown option ${a} — run "opencastle lesson --help"`)
127
+ fail(`unknown option ${a} — run "npx opencastle lesson --help"`)
128
128
  } else {
129
129
  out.positional.push(a)
130
130
  }
@@ -185,7 +185,7 @@ async function add(dir: string, projectRoot: string, p: Parsed): Promise<void> {
185
185
  !severity && '--severity',
186
186
  !problem && '--problem',
187
187
  ].filter(Boolean)
188
- if (missing.length > 0) fail(`Missing required flags: ${missing.join(', ')}\n Run "opencastle lesson --help" for usage.`)
188
+ if (missing.length > 0) fail(`Missing required flags: ${missing.join(', ')}\n Run "npx opencastle lesson --help" for usage.`)
189
189
  if (!isLessonCategory(category!)) fail(`Invalid --category "${category}". Must be one of: ${LESSON_CATEGORIES.join(', ')}`)
190
190
  if (!isLessonSeverity(severity!)) fail(`Invalid --severity "${severity}". Must be one of: ${LESSON_SEVERITIES.join(', ')}`)
191
191
  checkCitations(projectRoot, p.cites)
@@ -220,7 +220,7 @@ async function add(dir: string, projectRoot: string, p: Parsed): Promise<void> {
220
220
 
221
221
  async function verify(dir: string, projectRoot: string, p: Parsed): Promise<void> {
222
222
  const [ref] = p.positional
223
- if (!ref) fail('verify needs the id of a lesson, e.g. opencastle lesson verify 2026-10-02-always-quote-shell-variables')
223
+ if (!ref) fail('verify needs the id of a lesson, e.g. npx opencastle lesson verify 2026-10-02-always-quote-shell-variables')
224
224
  checkCitations(projectRoot, p.cites)
225
225
  if (!p.dryRun) reindex(dir)
226
226
  const { lessons } = readLessons(dir)
@@ -241,7 +241,7 @@ async function verify(dir: string, projectRoot: string, p: Parsed): Promise<void
241
241
  async function archive(dir: string, projectRoot: string, p: Parsed): Promise<void> {
242
242
  const [ref] = p.positional
243
243
  const into = p.values.get('--into')
244
- if (!ref) fail('archive needs the id of a lesson, e.g. opencastle lesson archive 2026-10-02-always-quote-shell-variables --into <file>')
244
+ if (!ref) fail('archive needs the id of a lesson, e.g. npx opencastle lesson archive 2026-10-02-always-quote-shell-variables --into <file>')
245
245
  if (!into) fail('archive needs --into <file>: the skill or instruction file the lesson was merged into')
246
246
  const problem = citationProblem(projectRoot, into)
247
247
  if (problem) fail(`--into: ${problem}`)
@@ -267,10 +267,10 @@ export default async function lesson({ args }: CliContext): Promise<void> {
267
267
  try {
268
268
  await stat(dir)
269
269
  } catch {
270
- fail(`no .opencastle/ directory at ${dir} — run opencastle init first`)
270
+ fail(`no .opencastle/ directory at ${dir} — run npx opencastle init first`)
271
271
  }
272
272
  if (sub === 'add' && p.positional.length > 0) {
273
- fail(`unexpected argument "${p.positional[0]}" — did you mean opencastle lesson verify or archive?`)
273
+ fail(`unexpected argument "${p.positional[0]}" — did you mean npx opencastle lesson verify or archive?`)
274
274
  }
275
275
  if (sub === 'add') return add(dir, projectRoot, p)
276
276
  if (sub === 'verify') return verify(dir, projectRoot, p)
@@ -238,9 +238,13 @@ export function renderIndex(lessons: Lesson[]): string {
238
238
  // A path, not a link: the folder is created with the first lesson, and a
239
239
  // link to it led nowhere until then.
240
240
  'Each lesson is a file in `.opencastle/lessons/`. Add one with',
241
- '`opencastle lesson --title ... --category ... --severity ... --problem ...`',
242
- '(and `--cite <path>` for the code it is about). Do not edit this index:',
243
- 'it is rewritten from those files by every `opencastle sync`.',
241
+ '`npx opencastle lesson --title ... --category ... --severity ... --problem ...`',
242
+ '(and `--cite <path>` for the code it is about). The category is one of',
243
+ // Spelled out: "--category ..." alone had agents guess, and a guess like
244
+ // `tooling` is refused.
245
+ `${LESSON_CATEGORIES.map((x) => `\`${x}\``).join(', ')};`,
246
+ `the severity ${LESSON_SEVERITIES.map((x) => `\`${x}\``).join(', ').replace(/, ([^,]+)$/, ' or $1')}. Do not edit this index:`,
247
+ 'it is rewritten from those files by every `npx opencastle sync`.',
244
248
  ]
245
249
  if (active.length === 0) out.push('', 'No lessons yet.')
246
250
  const categories = [...new Set(active.map((l) => l.category))].sort()
@@ -512,7 +516,7 @@ export function checkLessons(projectRoot: string): {
512
516
  const dir = join(projectRoot, '.opencastle')
513
517
  const drift = lessonsIndexDrift(dir)
514
518
  if (drift) {
515
- return { ok: true, warning: true, label, detail: `.opencastle/${LESSONS_INDEX} ${drift}`, fix: 'opencastle sync' }
519
+ return { ok: true, warning: true, label, detail: `.opencastle/${LESSONS_INDEX} ${drift}`, fix: 'npx opencastle sync' }
516
520
  }
517
521
  const { lessons, problems } = readLessons(dir)
518
522
  if (problems.length > 0) {
@@ -540,8 +544,8 @@ export function checkLessons(projectRoot: string): {
540
544
  label,
541
545
  detail: said.join('; '),
542
546
  fix:
543
- `check that each still holds, then opencastle lesson verify ${ids[0]}${ids.length > 1 ? ' (and the others)' : ''} — ` +
544
- 'with --cite <path> for a file that moved — or retire it with opencastle lesson archive <id> --into <file>',
547
+ `check that each still holds, then npx opencastle lesson verify ${ids[0]}${ids.length > 1 ? ' (and the others)' : ''} — ` +
548
+ 'with --cite <path> for a file that moved — or retire it with npx opencastle lesson archive <id> --into <file>',
545
549
  }
546
550
  }
547
551
  // Active lessons only: archiving is the remedy, and it does not shrink the
@@ -554,7 +558,7 @@ export function checkLessons(projectRoot: string): {
554
558
  warning: true,
555
559
  label,
556
560
  detail: `${active.length} active lessons, ~${indexTokens} tokens in the index agents read before every task`,
557
- fix: 'merge the lessons that recur into the skill or instruction file they are about, then opencastle lesson archive <id> --into <file>',
561
+ fix: 'merge the lessons that recur into the skill or instruction file they are about, then npx opencastle lesson archive <id> --into <file>',
558
562
  }
559
563
  }
560
564
  const cited = active.filter((l) => l.citations.length > 0).length
@@ -565,7 +565,7 @@ export function diagnoseManagedFile(
565
565
  state: 'doubled',
566
566
  fixable: true,
567
567
  detail: `holds ${blocks} OpenCastle blocks`,
568
- fix: 'opencastle sync',
568
+ fix: 'npx opencastle sync',
569
569
  }
570
570
  }
571
571
  // A stray marker with no block is not the same as a stray marker beside one.
@@ -206,7 +206,7 @@ describe('checkMcpSupplyChain', () => {
206
206
  write('.cursor/mcp.json', { mcpServers: { Playwright: { command: 'npx', args: ['-y', '@playwright/mcp@latest'] } } })
207
207
  const r = checkMcpSupplyChain(root, 'cursor')
208
208
  expect(r).toMatchObject({ ok: true, warning: true })
209
- expect(r.fix).toMatch(/^opencastle sync/)
209
+ expect(r.fix).toMatch(/^npx opencastle sync/)
210
210
  })
211
211
 
212
212
  it('does not send the user to sync for a server sync will not touch', () => {
@@ -218,8 +218,8 @@ describe('checkMcpSupplyChain', () => {
218
218
  it('does not say sync fixes a server that sync will delete', () => {
219
219
  write('.mcp.json', { mcpServers: { Supabase: { url: 'https://mcp.supabase.com/mcp' } } })
220
220
  const r = checkMcpSupplyChain(root, 'claude-code', new Set())
221
- expect(r.fix).toContain('opencastle sync removes Supabase')
222
- expect(r.fix).toContain('opencastle add supabase')
221
+ expect(r.fix).toContain('npx opencastle sync removes Supabase')
222
+ expect(r.fix).toContain('npx opencastle add supabase')
223
223
  expect(r.fix).not.toContain('fixes')
224
224
  })
225
225
 
@@ -238,9 +238,9 @@ describe('checkMcpSupplyChain', () => {
238
238
  },
239
239
  })
240
240
  const r = checkMcpSupplyChain(root, 'cursor')
241
- expect(r.fix).toContain('opencastle sync fixes chrome-devtools')
241
+ expect(r.fix).toContain('npx opencastle sync fixes chrome-devtools')
242
242
  expect(r.fix).toContain('Playwright changed since OpenCastle wrote them')
243
- expect(r.fix).toContain('opencastle sync --force')
243
+ expect(r.fix).toContain('npx opencastle sync --force')
244
244
  })
245
245
 
246
246
  it('fails on a server that cannot load', () => {
@@ -521,21 +521,21 @@ export function remedyFor(list: McpFinding[], rel: string): string {
521
521
  const edited = names((f) => f.sync === 'keeps' && Boolean(f.plugin) && !f.team)
522
522
  const teamSource = list.filter((f) => f.sync === 'keeps' && Boolean(f.team))
523
523
  const own = names((f) => f.sync === 'keeps' && !f.plugin && !f.team)
524
- if (replaced) parts.push(`opencastle sync fixes ${replaced} (still as OpenCastle wrote them)`)
525
- if (rewritten) parts.push(`opencastle sync rewrites ${rewritten} as the team config defines them`)
524
+ if (replaced) parts.push(`npx opencastle sync fixes ${replaced} (still as OpenCastle wrote them)`)
525
+ if (rewritten) parts.push(`npx opencastle sync rewrites ${rewritten} as the team config defines them`)
526
526
  if (removed.length > 0) {
527
527
  const servers = [...new Set(removed.map((f) => f.server))].join(', ')
528
528
  const packs = [...new Set(removed.map((f) => f.plugin))].join(' ')
529
- parts.push(`opencastle sync removes ${servers}, which this project's stack does not include — opencastle add ${packs} keeps it`)
529
+ parts.push(`npx opencastle sync removes ${servers}, which this project's stack does not include — npx opencastle add ${packs} keeps it`)
530
530
  }
531
- if (blocked) parts.push(`opencastle sync removes ${blocked}, which the team's config excludes or its MCP policy does not allow`)
532
- if (retired) parts.push(`opencastle sync removes ${retired}, which no team layer defines any more`)
531
+ if (blocked) parts.push(`npx opencastle sync removes ${blocked}, which the team's config excludes or its MCP policy does not allow`)
532
+ if (retired) parts.push(`npx opencastle sync removes ${retired}, which no team layer defines any more`)
533
533
  for (const where of new Set(teamSource.map((f) => f.team as string))) {
534
534
  parts.push(`fix ${names((f) => f.team === where && f.sync === 'keeps')} in ${where}, where it is defined`)
535
535
  }
536
536
  if (edited) {
537
537
  parts.push(
538
- `${edited} changed since OpenCastle wrote them — fix by hand, or delete the entry and run opencastle sync --force for the current default`,
538
+ `${edited} changed since OpenCastle wrote them — fix by hand, or delete the entry and run npx opencastle sync --force for the current default`,
539
539
  )
540
540
  }
541
541
  if (own) parts.push(`fix ${own} by hand in ${rel}`)
@@ -820,13 +820,13 @@ function describeSpend(s: PlanningSpend): string {
820
820
  // ── The command ─────────────────────────────────────────────────────────────
821
821
 
822
822
  const HELP = `
823
- opencastle convoy plan --prd <file> [options]
823
+ npx opencastle convoy plan --prd <file> [options]
824
824
 
825
825
  Plan again from a PRD you edited. The PRD is checked, broken into tasks and
826
826
  written as a spec; you see the plan and are asked before it runs.
827
827
 
828
828
  Options:
829
- --prd <file> The PRD to plan from (opencastle convoy "<task>" writes
829
+ --prd <file> The PRD to plan from (npx opencastle convoy "<task>" writes
830
830
  them to .opencastle/prds/)
831
831
  --yes, -y Run the plan without asking
832
832
  --dry-run Plan and write the spec, but do not run it
@@ -866,7 +866,7 @@ function parseArgs(args: string[], allowPrd: boolean): CliOptions {
866
866
  break
867
867
  case '--prd':
868
868
  if (!allowPrd) {
869
- console.error(` ✗ --prd belongs to \`opencastle convoy plan\`: plan from a task or from a PRD, not both.`)
869
+ console.error(` ✗ --prd belongs to \`npx opencastle convoy plan\`: plan from a task or from a PRD, not both.`)
870
870
  process.exit(1)
871
871
  }
872
872
  opts.prd = value(i++, arg)
@@ -928,7 +928,7 @@ async function chooseRuntime(projectRoot: string, explicit: string | null): Prom
928
928
  async function planThenRun(source: { task: string } | { prd: string }, opts: CliOptions, pkgRoot: string): Promise<void> {
929
929
  const projectRoot = process.cwd()
930
930
  const runtime = await chooseRuntime(findProjectRoot(projectRoot) ?? projectRoot, opts.adapter)
931
- console.log(`\n ${c.bold('opencastle convoy')} ${c.dim('— planning, read-only')}`)
931
+ console.log(`\n ${c.bold('npx opencastle convoy')} ${c.dim('— planning, read-only')}`)
932
932
  console.log(` ${c.dim('Runtime:')} ${runtime.detail}\n`)
933
933
 
934
934
  let outcome: PlanOutcome
@@ -949,7 +949,7 @@ async function planThenRun(source: { task: string } | { prd: string }, opts: Cli
949
949
  }
950
950
 
951
951
  for (const row of renderPlan(outcome, process.stdout.columns ?? 100)) console.log(row)
952
- const later = `opencastle convoy run ${relPath(outcome.specPath)}`
952
+ const later = `npx opencastle convoy run ${relPath(outcome.specPath)}`
953
953
 
954
954
  if (outcome.problems.length > 0) {
955
955
  console.error(` ${c.red('✗')} The plan still fails these checks, so it was not started:`)
@@ -1003,7 +1003,7 @@ export default async function pipeline({ args, pkgRoot }: CliContext): Promise<v
1003
1003
  return
1004
1004
  }
1005
1005
  if (opts.prd === null) {
1006
- console.error(' ✗ Name the PRD to plan from: opencastle convoy plan --prd <file>')
1006
+ console.error(' ✗ Name the PRD to plan from: npx opencastle convoy plan --prd <file>')
1007
1007
  console.log(HELP)
1008
1008
  process.exit(1)
1009
1009
  }
package/src/cli/plugin.ts CHANGED
@@ -25,7 +25,7 @@ import type { CliContext } from './types.js'
25
25
  */
26
26
 
27
27
  const HELP = `
28
- opencastle plugin <check|build|index> [dir] [options]
28
+ npx opencastle plugin <check|build|index> [dir] [options]
29
29
 
30
30
  Agent Plugins 1.0 is the open package format for skills and MCP servers
31
31
  (agent-plugins.org): plugin.json, skills/<name>/SKILL.md and mcp.json.
@@ -170,7 +170,7 @@ function listPlugins(root: string): { plugins: Listed[]; problems: string[] } {
170
170
  const at = join(dir, entry)
171
171
  if (!existsSync(join(at, 'plugin.json'))) continue
172
172
  if (!isAgentPlugin(at)) {
173
- problems.push(`plugins/${entry}: plugin.json does not declare an Agent Plugins version — run opencastle plugin check plugins/${entry}`)
173
+ problems.push(`plugins/${entry}: plugin.json does not declare an Agent Plugins version — run npx opencastle plugin check plugins/${entry}`)
174
174
  continue
175
175
  }
176
176
  const report = readAgentPlugin(at)
@@ -214,15 +214,15 @@ function printReport(dir: string, report: PluginReport, claudeStale: string[]):
214
214
  console.log(` Skills: ${report.skills.length > 0 ? report.skills.join(', ') : c.dim('none')}`)
215
215
  console.log(` MCP servers: ${Object.keys(report.servers).length > 0 ? Object.keys(report.servers).join(', ') : c.dim('none')}`)
216
216
  if (existsSync(join(report.root, EXTENSION_NAMESPACE))) {
217
- console.log(` ${EXTENSION_NAMESPACE}/: ${c.dim('OpenCastle content — check it with opencastle baseline check')}`)
217
+ console.log(` ${EXTENSION_NAMESPACE}/: ${c.dim('OpenCastle content — check it with npx opencastle baseline check')}`)
218
218
  }
219
219
  }
220
220
  for (const e of report.errors) console.log(` ${c.red('✗')} ${e}`)
221
- for (const s of claudeStale) console.log(` ${c.red('✗')} ${s} does not match plugin.json and mcp.json ${c.dim('— run opencastle plugin build')}`)
221
+ for (const s of claudeStale) console.log(` ${c.red('✗')} ${s} does not match plugin.json and mcp.json ${c.dim('— run npx opencastle plugin build')}`)
222
222
  for (const w of report.warnings) console.log(` ${c.yellow('!')} ${c.dim(w)}`)
223
223
  if (report.errors.length === 0 && claudeStale.length === 0) {
224
224
  console.log(`\n ${c.green('✓')} Loads in GitHub Copilot, VS Code, Cursor, Codex and Kiro as it is` +
225
- (existsSync(join(report.root, '.claude-plugin', 'plugin.json')) ? ', and in Claude Code.\n' : `.\n ${c.dim('Run opencastle plugin build to add the files Claude Code reads.')}\n`))
225
+ (existsSync(join(report.root, '.claude-plugin', 'plugin.json')) ? ', and in Claude Code.\n' : `.\n ${c.dim('Run npx opencastle plugin build to add the files Claude Code reads.')}\n`))
226
226
  } else {
227
227
  console.log(`\n ${c.red(`${report.errors.length + claudeStale.length} problem(s) to fix.`)}\n`)
228
228
  }
@@ -268,7 +268,7 @@ export default async function plugin({ args }: CliContext): Promise<void> {
268
268
  const changed = apply(root, claudeFiles(root, report), check)
269
269
  if (check) {
270
270
  if (changed.length > 0) {
271
- for (const f of changed) console.error(` ${c.red('✗')} ${f} does not match plugin.json and mcp.json — run opencastle plugin build`)
271
+ for (const f of changed) console.error(` ${c.red('✗')} ${f} does not match plugin.json and mcp.json — run npx opencastle plugin build`)
272
272
  process.exit(1)
273
273
  }
274
274
  console.log(` ${c.green('✓')} Claude Code's files match plugin.json and mcp.json`)
@@ -291,7 +291,7 @@ export default async function plugin({ args }: CliContext): Promise<void> {
291
291
  const noClaude = plugins.filter((p) => !p.claude)
292
292
  if (check) {
293
293
  if (changed.length > 0) {
294
- for (const f of changed) console.error(` ${c.red('✗')} ${f} does not list the plugins under plugins/ — run opencastle plugin index`)
294
+ for (const f of changed) console.error(` ${c.red('✗')} ${f} does not list the plugins under plugins/ — run npx opencastle plugin index`)
295
295
  process.exit(1)
296
296
  }
297
297
  console.log(` ${c.green('✓')} The marketplace files list all ${plugins.length} plugin(s)`)
@@ -303,7 +303,7 @@ export default async function plugin({ args }: CliContext): Promise<void> {
303
303
  : ` ${c.green('✓')} The marketplace files already list all ${plugins.length} plugin(s)`,
304
304
  )
305
305
  if (noClaude.length > 0) {
306
- console.log(` ${c.yellow('!')} ${noClaude.map((p) => `plugins/${p.dir}`).join(', ')} ${c.dim('— Claude Code needs .claude-plugin/plugin.json; run opencastle plugin build in each')}`)
306
+ console.log(` ${c.yellow('!')} ${noClaude.map((p) => `plugins/${p.dir}`).join(', ')} ${c.dim('— Claude Code needs .claude-plugin/plugin.json; run npx opencastle plugin build in each')}`)
307
307
  }
308
308
  console.log(` ${c.dim(`Add it: claude plugin marketplace add <owner>/<repo>, copilot plugin marketplace add <owner>/<repo>, codex plugin marketplace add <owner>/<repo>; in Cursor, Dashboard → Plugins → Team Marketplaces → Import.`)}`)
309
309
  }
@@ -30,7 +30,7 @@ import type { CliContext } from './types.js'
30
30
  */
31
31
 
32
32
  const HELP = `
33
- opencastle promote <skill|memory> [name|path] [options]
33
+ npx opencastle promote <skill|memory> [name|path] [options]
34
34
 
35
35
  Make what one person's assistant learned the team's: copy it into the
36
36
  team's sources, where the next sync compiles it into every assistant.
@@ -172,7 +172,7 @@ function promoteSkill(pkgRoot: string, args: string[], dryRun: boolean): void {
172
172
  const to = flag(args, '--to')
173
173
  const projectRoot = projectRootFrom(cwd)
174
174
  const destSkills = to ? skillsDirOf(resolve(cwd, to)) : join(projectRoot, '.opencastle', 'skills')
175
- if (!to && !existsSync(join(projectRoot, '.opencastle'))) fail('no .opencastle/ here — run opencastle init first, or promote it into a baseline with --to <dir>')
175
+ if (!to && !existsSync(join(projectRoot, '.opencastle'))) fail('no .opencastle/ here — run npx opencastle init first, or promote it into a baseline with --to <dir>')
176
176
  const dest = join(destSkills, name)
177
177
  const shown = relative(cwd, dest) || '.'
178
178
  if (existsSync(dest) && !args.includes('--force')) {
@@ -190,8 +190,8 @@ function promoteSkill(pkgRoot: string, args: string[], dryRun: boolean): void {
190
190
  if (core) console.log(` ${c.yellow('!')} OpenCastle ships a skill of that name; this one replaces it for everyone it reaches`)
191
191
  console.log(
192
192
  to
193
- ? ` ${c.dim('Next:')} ${c.cyan(`opencastle baseline check ${relative(cwd, resolve(cwd, to)) || '.'}`)}${c.dim(', then publish a new version.')}\n`
194
- : ` ${c.dim('Next:')} ${c.cyan('opencastle sync')} ${c.dim('compiles it into every assistant; commit it, and the pull request is where the team agrees.')}\n`,
193
+ ? ` ${c.dim('Next:')} ${c.cyan(`npx opencastle baseline check ${relative(cwd, resolve(cwd, to)) || '.'}`)}${c.dim(', then publish a new version.')}\n`
194
+ : ` ${c.dim('Next:')} ${c.cyan('npx opencastle sync')} ${c.dim('compiles it into every assistant; commit it, and the pull request is where the team agrees.')}\n`,
195
195
  )
196
196
  }
197
197
 
@@ -284,7 +284,7 @@ function titleOf(memory: Memory): string {
284
284
  function promoteMemory(args: string[], dryRun: boolean): void {
285
285
  const projectRoot = projectRootFrom(process.cwd())
286
286
  const customizations = join(projectRoot, '.opencastle')
287
- if (!existsSync(customizations)) fail('no .opencastle/ here — run opencastle init first')
287
+ if (!existsSync(customizations)) fail('no .opencastle/ here — run npx opencastle init first')
288
288
  const from = flag(args, '--from')
289
289
  const dir = from ? resolve(process.cwd(), from.replace(/^~(?=\/|$)/, home())) : claudeMemoryDir(projectRoot)
290
290
  if (!existsSync(dir)) {
@@ -1,4 +1,4 @@
1
- import { describe, it, expect, afterEach } from 'vitest';
1
+ import { describe, it, expect, afterEach, beforeEach } from 'vitest';
2
2
  import { computeVisibleWindow, c } from './prompt.js';
3
3
 
4
4
  describe('computeVisibleWindow', () => {
@@ -66,20 +66,48 @@ describe('computeVisibleWindow', () => {
66
66
  });
67
67
 
68
68
  describe('colours', () => {
69
- const saved = process.env.NO_COLOR;
69
+ const saved = { NO_COLOR: process.env.NO_COLOR, FORCE_COLOR: process.env.FORCE_COLOR, TERM: process.env.TERM }
70
+ const tty = process.stdout.isTTY
71
+ const setTty = (v: boolean | undefined) => Object.defineProperty(process.stdout, 'isTTY', { value: v, configurable: true })
72
+ beforeEach(() => {
73
+ delete process.env.NO_COLOR
74
+ delete process.env.FORCE_COLOR
75
+ delete process.env.TERM
76
+ })
70
77
  afterEach(() => {
71
- if (saved === undefined) delete process.env.NO_COLOR;
72
- else process.env.NO_COLOR = saved;
73
- });
78
+ for (const [k, v] of Object.entries(saved)) {
79
+ if (v === undefined) delete process.env[k]
80
+ else process.env[k] = v
81
+ }
82
+ setTty(tty)
83
+ })
74
84
 
75
- it('wrap text in an SGR sequence by default', () => {
76
- delete process.env.NO_COLOR;
77
- expect(c.green('ok')).toBe('\x1B[32mok\x1B[0m');
78
- });
85
+ it('wrap text in an SGR sequence on a terminal', () => {
86
+ setTty(true)
87
+ expect(c.green('ok')).toBe('\x1B[32mok\x1B[0m')
88
+ })
89
+
90
+ it('are left out when output is piped or redirected', () => {
91
+ setTty(false)
92
+ expect(c.green('ok')).toBe('ok')
93
+ })
94
+
95
+ it('are left out on a terminal that says it cannot show them', () => {
96
+ setTty(true)
97
+ process.env.TERM = 'dumb'
98
+ expect(c.green('ok')).toBe('ok')
99
+ })
79
100
 
80
101
  it('are left out when NO_COLOR is set (no-color.org)', () => {
81
- process.env.NO_COLOR = '1';
82
- expect(c.green('ok')).toBe('ok');
83
- expect(c.bold(c.dim('x'))).toBe('x');
84
- });
102
+ setTty(true)
103
+ process.env.NO_COLOR = '1'
104
+ expect(c.green('ok')).toBe('ok')
105
+ expect(c.bold(c.dim('x'))).toBe('x')
106
+ })
107
+
108
+ it('are put back anywhere by FORCE_COLOR', () => {
109
+ setTty(false)
110
+ process.env.FORCE_COLOR = '1'
111
+ expect(c.green('ok')).toBe('\x1B[32mok\x1B[0m')
112
+ })
85
113
  });
package/src/cli/prompt.ts CHANGED
@@ -16,9 +16,21 @@ function moveUp(n: number): string {
16
16
 
17
17
  // ── Color helpers ─────────────────────────────────────────────────
18
18
 
19
- /** One SGR style, unless `NO_COLOR` is set (https://no-color.org). Read per call, so a test can set it. */
19
+ /**
20
+ * Whether to colour output: on a terminal, unless `NO_COLOR` is set
21
+ * (https://no-color.org) or `TERM=dumb`; `FORCE_COLOR` turns it on anywhere.
22
+ * Piped or redirected output was coloured too, so a log file or `| grep` got
23
+ * escape codes. Read per call, so a test can set it.
24
+ */
25
+ function colourOn(): boolean {
26
+ if (process.env.NO_COLOR) return false;
27
+ if (process.env.FORCE_COLOR && process.env.FORCE_COLOR !== '0') return true;
28
+ return Boolean(process.stdout.isTTY) && process.env.TERM !== 'dumb';
29
+ }
30
+
31
+ /** One SGR style, when output is coloured at all. */
20
32
  const sgr = (code: string) => (s: string) =>
21
- process.env.NO_COLOR ? s : `\x1B[${code}m${s}\x1B[0m`;
33
+ colourOn() ? `\x1B[${code}m${s}\x1B[0m` : s;
22
34
 
23
35
  /** ANSI color helpers for CLI output. */
24
36
  export const c = {
package/src/cli/remove.ts CHANGED
@@ -25,7 +25,7 @@ import { parseMcpConfigText } from './mcp-file.js'
25
25
  */
26
26
 
27
27
  const REMOVE_HELP = `
28
- opencastle remove [options]
28
+ npx opencastle remove [options]
29
29
 
30
30
  Remove OpenCastle from this project. Asks whether to keep the generated
31
31
  files (so they become standalone) or delete everything.
package/src/cli/review.ts CHANGED
@@ -21,7 +21,7 @@ import type { CliContext } from './types.js'
21
21
  */
22
22
 
23
23
  const HELP = `
24
- opencastle review [options]
24
+ npx opencastle review [options]
25
25
 
26
26
  Explain what a change to the AI assistant config does: which skills, agents,
27
27
  instructions and MCP servers every assistant gains, loses or gets changed,
@@ -342,7 +342,7 @@ export function reviewMarkdown(report: ReviewReport): string {
342
342
  function renderTerminal(report: ReviewReport): void {
343
343
  console.log(`\n 🏰 ${c.bold('OpenCastle review')} ${c.dim(`— compared with ${report.base}`)}\n`)
344
344
  if (report.staleLock) {
345
- console.log(` ${c.yellow('!')} ${LOCK_REL} is not what the sources compile to — run ${c.cyan('opencastle sync')}\n`)
345
+ console.log(` ${c.yellow('!')} ${LOCK_REL} is not what the sources compile to — run ${c.cyan('npx opencastle sync')}\n`)
346
346
  }
347
347
  if (report.lines.length === 0) {
348
348
  console.log(` ${c.green('✓')} No change to what any assistant is given.\n`)
@@ -398,7 +398,7 @@ export function lockAtRef(projectRoot: string, ref: string): Lock | null {
398
398
  /** What the sources compile to now, as a lock; or the committed one if they do not resolve. */
399
399
  async function headLock(pkgRoot: string, projectRoot: string): Promise<{ lock: Lock; stale: boolean }> {
400
400
  const manifest = await readManifest(projectRoot)
401
- if (!manifest) throw new Error('OpenCastle is not set up here — run opencastle init')
401
+ if (!manifest) throw new Error('OpenCastle is not set up here — run npx opencastle init')
402
402
  refuseOlderCli(pkgRoot, manifest.version)
403
403
  const ides = (manifest.ides?.length ? manifest.ides : [manifest.ide]).filter(Boolean)
404
404
  const stack = resolveStack({ ...manifest, ides })
@@ -70,7 +70,7 @@ describe.skipIf(process.platform === 'win32')('resolveAdapter', () => {
70
70
  const projectRoot = setup(['claude', 'copilot'], { ides: ['vscode', 'claude-code'] })
71
71
  const r = await resolveAdapter({ projectRoot })
72
72
  expect(r).toMatchObject({ name: 'copilot', source: 'configured' })
73
- expect(r.detail).toBe('GitHub Copilot CLI — configured by opencastle init')
73
+ expect(r.detail).toBe('GitHub Copilot CLI — configured by npx opencastle init')
74
74
  })
75
75
 
76
76
  it('walks the configured assistants in order, saying which came first but is missing', async () => {
@@ -96,7 +96,7 @@ describe.skipIf(process.platform === 'win32')('resolveAdapter', () => {
96
96
  const projectRoot = setup(['codex'], { ides: ['claude-code'] })
97
97
  const r = await resolveAdapter({ projectRoot })
98
98
  expect(r).toMatchObject({ name: 'codex', source: 'detected' })
99
- expect(r.detail).toContain('opencastle init configured Claude Code, but `claude` is not on PATH')
99
+ expect(r.detail).toContain('npx opencastle init configured Claude Code, but `claude` is not on PATH')
100
100
  })
101
101
 
102
102
  it('detects in the order claude, codex, cursor, opencode, copilot', async () => {
@@ -115,7 +115,7 @@ describe.skipIf(process.platform === 'win32')('resolveAdapter', () => {
115
115
  it('does not count Copilot unless its CLI is on PATH, though its SDK is installed here', async () => {
116
116
  const projectRoot = setup([], { ides: ['vscode'] })
117
117
  const err = await resolveAdapter({ projectRoot }).catch((e: Error) => e)
118
- expect((err as Error).message).toContain('opencastle init configured GitHub Copilot CLI, but no agent CLI is on PATH')
118
+ expect((err as Error).message).toContain('npx opencastle init configured GitHub Copilot CLI, but no agent CLI is on PATH')
119
119
  expect((err as Error).message).toContain('npm install -g @github/copilot')
120
120
  })
121
121
 
@@ -148,7 +148,7 @@ export async function resolveAdapter(opts: {
148
148
  const also = notInstalled.length
149
149
  ? ` (${notInstalled.map((n) => RUNTIMES[n].label).join(', ')} came first but ${notInstalled.length === 1 ? 'is' : 'are'} not installed)`
150
150
  : ''
151
- return { name, adapter, source: 'configured', detail: `${RUNTIMES[name].label} — configured by opencastle init${also}` }
151
+ return { name, adapter, source: 'configured', detail: `${RUNTIMES[name].label} — configured by npx opencastle init${also}` }
152
152
  }
153
153
  notInstalled.push(name)
154
154
  }
@@ -158,7 +158,7 @@ export async function resolveAdapter(opts: {
158
158
  if (await adapter.isAvailable()) {
159
159
  const notes: string[] = []
160
160
  if (notInstalled.length) {
161
- notes.push(`opencastle init configured ${notInstalled.map((n) => RUNTIMES[n].label).join(' and ')}, but \`${notInstalled.map((n) => RUNTIMES[n].command).join('`, `')}\` is not on PATH`)
161
+ notes.push(`npx opencastle init configured ${notInstalled.map((n) => RUNTIMES[n].label).join(' and ')}, but \`${notInstalled.map((n) => RUNTIMES[n].command).join('`, `')}\` is not on PATH`)
162
162
  }
163
163
  if (noRuntime.length) notes.push(`${noRuntime.join(' and ')} has no command-line agent`)
164
164
  return {
@@ -172,7 +172,7 @@ export async function resolveAdapter(opts: {
172
172
 
173
173
  if (notInstalled.length) {
174
174
  throw new Error(
175
- `opencastle init configured ${notInstalled.map((n) => RUNTIMES[n].label).join(' and ')}, but no agent CLI is on PATH.\n` +
175
+ `npx opencastle init configured ${notInstalled.map((n) => RUNTIMES[n].label).join(' and ')}, but no agent CLI is on PATH.\n` +
176
176
  notInstalled.map((n) => ` ${RUNTIMES[n].label}: ${RUNTIMES[n].install}`).join('\n') +
177
177
  `\n Or install another runtime and pick it with --adapter <${NAMES.replace(/, /g, '|')}>.`,
178
178
  )
@@ -135,12 +135,12 @@ const RETIRED_DEFAULTS: Record<string, string> = {
135
135
  snippets: 'snippets were folded into skills',
136
136
  detect_drift: 'drift detection was removed; reviews and gates check the work instead',
137
137
  review_stages: 'the two-stage review was removed; `review` picks one fast review or a panel',
138
- mcp_approve_all: 'agents use the MCP servers and approvals in the project\'s own config, which `opencastle sync` writes',
138
+ mcp_approve_all: 'agents use the MCP servers and approvals in the project\'s own config, which `npx opencastle sync` writes',
139
139
  }
140
140
 
141
141
  /** Top-level and per-task keys retired the same way. */
142
142
  const RETIRED_SPEC_KEYS: Record<string, string> = {
143
- watch: 'watch mode was removed; run the spec again, or `opencastle convoy resume` to continue one',
143
+ watch: 'watch mode was removed; run the spec again, or `npx opencastle convoy resume` to continue one',
144
144
  }
145
145
  const RETIRED_TASK_KEYS: Record<string, string> = {
146
146
  detect_drift: 'drift detection was removed; reviews and gates check the work instead',
@@ -149,7 +149,7 @@ const RETIRED_TASK_KEYS: Record<string, string> = {
149
149
  /** What a version 2 (chained) spec is told to do instead. */
150
150
  const CHAIN_REPLACEMENT =
151
151
  'put every task in one version 1 spec and let `depends_on` order them — tasks that do not ' +
152
- 'depend on each other run in parallel. `opencastle convoy "<task>"` plans large work that way.'
152
+ 'depend on each other run in parallel. `npx opencastle convoy "<task>"` plans large work that way.'
153
153
 
154
154
  /**
155
155
  * Every key under `defaults` that something reads.
@@ -79,7 +79,7 @@ describe('parseRunArgs', () => {
79
79
  it('gives resume no spec, and says so for a stray word', () => {
80
80
  expect(parseRunArgs(['--dry-run'], 'resume')).toEqual(args({ dryRun: true }))
81
81
  expect((parseRunArgs(['task-1'], 'resume') as { error: string }).error).toMatch(/takes no name/)
82
- expect(parseRunArgs(['-f', 'a.yml'], 'resume')).toEqual({ error: '-f belongs to opencastle convoy run' })
82
+ expect(parseRunArgs(['-f', 'a.yml'], 'resume')).toEqual({ error: '-f belongs to npx opencastle convoy run' })
83
83
  })
84
84
  })
85
85
 
@@ -270,7 +270,7 @@ tasks:
270
270
  WRITE two.txt second
271
271
  `)
272
272
  expect(await runSpec(args({ spec }))).toBe(1)
273
- expect(text()).toMatch(/Resume with: opencastle convoy resume/)
273
+ expect(text()).toMatch(/Resume with: npx opencastle convoy resume/)
274
274
 
275
275
  rmSync(flag)
276
276
  out.length = 0
@@ -346,6 +346,6 @@ describe('convoy resume', () => {
346
346
  db.close()
347
347
  expect(await resumeLast(args())).toBe(1)
348
348
  expect(text()).toMatch(/is still running in another process/)
349
- expect(text()).toContain('opencastle convoy dashboard')
349
+ expect(text()).toContain('npx opencastle convoy dashboard')
350
350
  })
351
351
  })