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/run.ts CHANGED
@@ -25,23 +25,23 @@ import type { TaskSpec } from './convoy/spec-types.js'
25
25
  import type { CliContext } from './types.js'
26
26
 
27
27
  const RUN_HELP = `
28
- opencastle convoy run <spec.yml> [options]
28
+ npx opencastle convoy run <spec.yml> [options]
29
29
 
30
- Run a convoy spec: one you wrote, or one opencastle convoy "<task>" wrote to
30
+ Run a convoy spec: one you wrote, or one npx opencastle convoy "<task>" wrote to
31
31
  .opencastle/convoys/. The work lands on a branch of its own (the spec's
32
32
  branch, or convoy/<name>-<id>); your checkout is never touched.
33
33
 
34
34
  Options:
35
35
  --dry-run Check the spec and show what would run; start nothing
36
36
  --adapter, -a <name> Agent runtime: claude, codex, cursor, opencode or copilot
37
- (default: the spec's, else the one opencastle init set up)
37
+ (default: the spec's, else the one npx opencastle init set up)
38
38
  --concurrency, -c <n> Tasks at once (default: the spec's, else 4)
39
39
  --verbose Stream agent output
40
40
  --help, -h Show this help
41
41
  `
42
42
 
43
43
  const RESUME_HELP = `
44
- opencastle convoy resume [options]
44
+ npx opencastle convoy resume [options]
45
45
 
46
46
  Continue the newest run that is not done. Failed, timed-out and interrupted
47
47
  tasks run again, and so do the tasks a failure skipped; finished tasks are
@@ -74,18 +74,18 @@ const KNOWN_FLAGS = ['--dry-run', '--adapter', '-a', '--concurrency', '-c', '--v
74
74
  * because "unknown option" is the wrong answer to a flag our own docs taught.
75
75
  */
76
76
  export const REMOVED_FLAGS: Record<string, string> = {
77
- '--resume': 'Use: opencastle convoy resume',
78
- '--retry-failed': 'Use: opencastle convoy resume — it re-runs failed tasks too',
79
- '--status': 'Use: opencastle convoy — it shows the last run and what to do next',
80
- '--dlq-list': 'Failed tasks are listed by opencastle convoy, and re-run by opencastle convoy resume',
81
- '--dlq-resolve': 'Failed tasks are listed by opencastle convoy, and re-run by opencastle convoy resume',
82
- '--dlq-retry': 'Use: opencastle convoy resume',
83
- '--formula': 'Formulas are gone: write the spec out, or plan it with opencastle convoy "<task>"',
84
- '--set': 'Formulas are gone: write the spec out, or plan it with opencastle convoy "<task>"',
77
+ '--resume': 'Use: npx opencastle convoy resume',
78
+ '--retry-failed': 'Use: npx opencastle convoy resume — it re-runs failed tasks too',
79
+ '--status': 'Use: npx opencastle convoy — it shows the last run and what to do next',
80
+ '--dlq-list': 'Failed tasks are listed by npx opencastle convoy, and re-run by npx opencastle convoy resume',
81
+ '--dlq-resolve': 'Failed tasks are listed by npx opencastle convoy, and re-run by npx opencastle convoy resume',
82
+ '--dlq-retry': 'Use: npx opencastle convoy resume',
83
+ '--formula': 'Formulas are gone: write the spec out, or plan it with npx opencastle convoy "<task>"',
84
+ '--set': 'Formulas are gone: write the spec out, or plan it with npx opencastle convoy "<task>"',
85
85
  '--watch': 'Watch mode is gone: run the spec again when you want it run',
86
86
  '--watch-config': 'Watch mode is gone: run the spec again when you want it run',
87
87
  '--clear-scratchpad': 'Watch mode is gone: run the spec again when you want it run',
88
- '--report-dir': 'Runs are recorded in .opencastle/convoy.db. See them with opencastle convoy dashboard',
88
+ '--report-dir': 'Runs are recorded in .opencastle/convoy.db. See them with npx opencastle convoy dashboard',
89
89
  '--permission-mode': 'Set defaults.permission_mode in the spec instead',
90
90
  }
91
91
 
@@ -133,7 +133,7 @@ export function parseRunArgs(args: string[], command: 'run' | 'resume'): RunArgs
133
133
  }
134
134
  case '--file':
135
135
  case '-f': {
136
- if (command !== 'run') return { error: `${arg} belongs to opencastle convoy run` }
136
+ if (command !== 'run') return { error: `${arg} belongs to npx opencastle convoy run` }
137
137
  const v = value(i++, arg)
138
138
  if (typeof v !== 'string') return v
139
139
  if (out.spec !== null) return { error: `Two specs given: ${out.spec} and ${v}. Run one at a time.` }
@@ -227,7 +227,7 @@ async function drive(work: () => Promise<ConvoyResult>, projectRoot: string): Pr
227
227
  return result.exitCode ?? (result.status === 'done' ? 0 : 1)
228
228
  } catch (err) {
229
229
  if (err instanceof EngineAlreadyRunningError) {
230
- return fail(`${err.message}\n Watch it with: opencastle convoy dashboard`)
230
+ return fail(`${err.message}\n Watch it with: npx opencastle convoy dashboard`)
231
231
  }
232
232
  return fail((err as Error).message)
233
233
  } finally {
@@ -278,7 +278,7 @@ function describePlan(spec: TaskSpec, runtime: string): string[] {
278
278
  */
279
279
  export async function runSpec(args: RunArgs, opts: { runtime?: ResolvedAdapter } = {}): Promise<number> {
280
280
  if (!args.spec) {
281
- console.error(` ${c.red('✗')} Name the spec to run: opencastle convoy run <spec.yml>`)
281
+ console.error(` ${c.red('✗')} Name the spec to run: npx opencastle convoy run <spec.yml>`)
282
282
  console.error(` ${c.dim('Specs the planner wrote are in .opencastle/convoys/.')}`)
283
283
  return 1
284
284
  }
@@ -324,7 +324,7 @@ export async function runSpec(args: RunArgs, opts: { runtime?: ResolvedAdapter }
324
324
  if (runtimeProblem) return fail(runtimeProblem)
325
325
  const problem = spec.defaults?.permission_mode ? permissionModeError(runtime!.name, spec.defaults.permission_mode) : null
326
326
  if (problem) return fail(problem)
327
- console.log(` ${c.dim('Dry run — nothing started, nothing recorded. To run it:')} opencastle convoy run ${args.spec}`)
327
+ console.log(` ${c.dim('Dry run — nothing started, nothing recorded. To run it:')} npx opencastle convoy run ${args.spec}`)
328
328
  console.log('')
329
329
  return 0
330
330
  }
@@ -368,19 +368,19 @@ export async function resumeLast(args: RunArgs): Promise<number> {
368
368
  const runs = readRuns(projectRoot, 200)
369
369
  if (runs.length === 0) {
370
370
  console.error(` ${c.red('✗')} No convoy runs in this project yet.`)
371
- console.error(` ${c.dim('Start one:')} opencastle convoy "<task>"`)
371
+ console.error(` ${c.dim('Start one:')} npx opencastle convoy "<task>"`)
372
372
  return 1
373
373
  }
374
374
  const target = runs.find(unfinished)
375
375
  if (!target) {
376
376
  const last = runs[0]
377
377
  console.log(` Nothing to resume: the last run, ${c.bold(last.name)}, finished with all ${last.tasks_total} tasks done.`)
378
- console.log(` ${c.dim('Start another:')} opencastle convoy "<task>"`)
378
+ console.log(` ${c.dim('Start another:')} npx opencastle convoy "<task>"`)
379
379
  return 0
380
380
  }
381
381
  if (isRunAlive(projectRoot, target.id)) {
382
382
  console.error(` ${c.red('✗')} ${target.name} (${target.id}) is still running in another process.`)
383
- console.error(` ${c.dim('Watch it:')} opencastle convoy dashboard`)
383
+ console.error(` ${c.dim('Watch it:')} npx opencastle convoy dashboard`)
384
384
  return 1
385
385
  }
386
386
 
@@ -451,7 +451,7 @@ async function main(args: string[], command: 'run' | 'resume'): Promise<void> {
451
451
  const parsed = parseRunArgs(args, command)
452
452
  if ('error' in parsed) {
453
453
  console.error(` ${c.red('✗')} ${parsed.error}`)
454
- console.error(` Run "opencastle convoy ${command} --help" for usage.`)
454
+ console.error(` Run "npx opencastle convoy ${command} --help" for usage.`)
455
455
  exitWith(1)
456
456
  return
457
457
  }
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { updateSkillMatrixContent } from './stack-config.js';
2
+ import { updateSkillMatrixContent, isEnvVarSatisfied } from './stack-config.js';
3
3
  import type { StackConfig } from './types.js';
4
4
  import type { SkillMatrixData } from './stack-config.js';
5
5
 
@@ -49,6 +49,27 @@ function parse(result: string): SkillMatrixData {
49
49
  return JSON.parse(result);
50
50
  }
51
51
 
52
+ describe('isEnvVarSatisfied', () => {
53
+ const set = (env: string) => isEnvVarSatisfied('OC_TEST_TOKEN', env);
54
+
55
+ it('reads a value, exported or not, quoted or not', () => {
56
+ expect(set('OC_TEST_TOKEN=abc')).toBe(true);
57
+ expect(set('export OC_TEST_TOKEN = "abc"')).toBe(true);
58
+ expect(set('OC_TEST_TOKEN=#not-a-comment')).toBe(true);
59
+ });
60
+
61
+ it('does not take the next line for the value of an empty one', () => {
62
+ // The shape init writes: a placeholder, then the next variable's comment.
63
+ expect(set('OC_TEST_TOKEN=\n# Another token\nOTHER=x')).toBe(false);
64
+ });
65
+
66
+ it('counts empty quotes and a comment as no value', () => {
67
+ expect(set('OC_TEST_TOKEN=""')).toBe(false);
68
+ expect(set("OC_TEST_TOKEN='' # fill me")).toBe(false);
69
+ expect(set('OC_TEST_TOKEN= # fill me')).toBe(false);
70
+ });
71
+ });
72
+
52
73
  describe('updateSkillMatrixContent', () => {
53
74
  it('fills database slot when a database tool is selected', () => {
54
75
  const stack: StackConfig = { ides: ['vscode'], techTools: ['supabase'], teamTools: [] };
@@ -94,7 +94,15 @@ const MCP_ENV_REQUIREMENTS: McpEnvRequirement[] = Object.values(PLUGINS)
94
94
  */
95
95
  export function isEnvVarSatisfied(envVar: string, envFileContents: string): boolean {
96
96
  if (process.env[envVar]) return true
97
- return new RegExp(`^\\s*(?:export\\s+)?${envVar}\\s*=\\s*\\S`, 'm').test(envFileContents)
97
+ // Line by line: a pattern with `\s` after the `=` crossed the newline, so an
98
+ // empty `NAME=` that init wrote as a placeholder counted as set by whatever
99
+ // the next line held. A comment or empty quotes are no value either.
100
+ const assignment = new RegExp(`^[ \\t]*(?:export[ \\t]+)?${envVar}[ \\t]*=(.*)$`)
101
+ for (const line of envFileContents.split(/\r?\n/)) {
102
+ const value = assignment.exec(line)?.[1].replace(/[ \t]+#.*$/, '').trim()
103
+ if (value && value !== '""' && value !== "''") return true
104
+ }
105
+ return false
98
106
  }
99
107
 
100
108
  export function resolveStack(manifest: {
@@ -98,7 +98,7 @@ describe('status report', () => {
98
98
  it('reports not installed on a bare project and points at init', async () => {
99
99
  const report = await buildStatusReport(pkgRoot, projectRoot)
100
100
  expect(report.installed).toBe(false)
101
- expect(report.nextCommand).toBe('opencastle init')
101
+ expect(report.nextCommand).toBe('npx opencastle init')
102
102
  expect(report.unmanaged).toEqual([])
103
103
  })
104
104
 
@@ -124,7 +124,7 @@ describe('status report', () => {
124
124
  expect(report.ides).toEqual(['vscode'])
125
125
  expect(report.targets[0].present).toBe(false)
126
126
  expect(report.targets[0].missing.length).toBeGreaterThan(0)
127
- expect(report.nextCommand).toBe('opencastle sync')
127
+ expect(report.nextCommand).toBe('npx opencastle sync')
128
128
  expect(report.nextReason).toMatch(/missing generated files/)
129
129
  })
130
130
 
@@ -148,7 +148,7 @@ describe('status report', () => {
148
148
 
149
149
  const report = await buildStatusReport(pkgRoot, projectRoot)
150
150
  expect(report.stale).toBe(true)
151
- expect(report.nextCommand).toBe('opencastle sync')
151
+ expect(report.nextCommand).toBe('npx opencastle sync')
152
152
  expect(report.nextReason).toMatch(/no longer match their sources/)
153
153
  })
154
154
 
package/src/cli/status.ts CHANGED
@@ -152,7 +152,7 @@ export async function buildStatusReport(pkgRoot: string, projectRoot: string): P
152
152
  targets: [],
153
153
  stale: false,
154
154
  unmanaged: [],
155
- nextCommand: 'opencastle doctor',
155
+ nextCommand: 'npx opencastle doctor',
156
156
  nextReason:
157
157
  err.reason === 'unreadable'
158
158
  ? `${err.file} cannot be read — fix the permissions, or remove what is standing in its place`
@@ -170,7 +170,7 @@ export async function buildStatusReport(pkgRoot: string, projectRoot: string): P
170
170
  targets: [],
171
171
  stale: false,
172
172
  unmanaged,
173
- nextCommand: 'opencastle init',
173
+ nextCommand: 'npx opencastle init',
174
174
  nextReason: unmanaged.length
175
175
  ? `found existing config for ${unmanaged.join(', ')} — init can compile it for every other assistant`
176
176
  : 'set up AI assistant config for this project',
@@ -297,13 +297,13 @@ export async function buildStatusReport(pkgRoot: string, projectRoot: string): P
297
297
  // diagnostic that says "run sync". `doctor` is what is left when a failure
298
298
  // has no more specific command.
299
299
  if (missingRequired.length > 0) {
300
- nextCommand = 'opencastle sync'
300
+ nextCommand = 'npx opencastle sync'
301
301
  nextReason = `${missingRequired.length} required file(s) missing from .opencastle/`
302
302
  } else if (incomplete.length > 0) {
303
- nextCommand = 'opencastle sync'
303
+ nextCommand = 'npx opencastle sync'
304
304
  nextReason = `${incomplete.length} target${incomplete.length === 1 ? '' : 's'} missing generated files`
305
305
  } else if (failing.length > 0) {
306
- nextCommand = 'opencastle doctor'
306
+ nextCommand = 'npx opencastle doctor'
307
307
  nextReason = `${failing.length} check(s) failing: ${failing.join(', ')}`
308
308
  } else if (checkFailed) {
309
309
  // Last of the failure branches, because a comparison can also fail for
@@ -311,13 +311,13 @@ export async function buildStatusReport(pkgRoot: string, projectRoot: string): P
311
311
  // to fall through to an mtime heuristic that answered "no drift", so an
312
312
  // unreadable framework directory produced "Everything is current" while
313
313
  // `doctor` and `sync --check` both exited 1.
314
- nextCommand = 'opencastle doctor'
314
+ nextCommand = 'npx opencastle doctor'
315
315
  nextReason = `the drift check could not run (${checkFailed})`
316
316
  } else if (stale) {
317
- nextCommand = 'opencastle sync'
317
+ nextCommand = 'npx opencastle sync'
318
318
  nextReason = 'generated files no longer match their sources'
319
319
  } else if (unmanaged.length > 0) {
320
- nextCommand = 'opencastle init --customize'
320
+ nextCommand = 'npx opencastle init --customize'
321
321
  nextReason = `${unmanaged.join(', ')} config exists but is not being compiled`
322
322
  }
323
323
 
@@ -407,7 +407,7 @@ function render(report: StatusReport): void {
407
407
  console.log(` ${c.bold('Next:')} ${c.cyan(report.nextCommand)}`)
408
408
  if (report.nextReason) console.log(` ${c.dim(report.nextReason)}`)
409
409
  } else {
410
- console.log(` ${c.dim('Everything is current. Run')} ${c.cyan('opencastle doctor')} ${c.dim('for a deeper check.')}`)
410
+ console.log(` ${c.dim('Everything is current. Run')} ${c.cyan('npx opencastle doctor')} ${c.dim('for a deeper check.')}`)
411
411
  }
412
412
  console.log('')
413
413
  }
@@ -316,7 +316,7 @@ export async function buildCheckReport(pkgRoot: string, projectRoot: string): Pr
316
316
  path: i.where,
317
317
  kind: 'unreducible' as const,
318
318
  detail: i.message,
319
- fix: i.fix ?? 'fix it, then run opencastle sync',
319
+ fix: i.fix ?? 'fix it, then run npx opencastle sync',
320
320
  origin: 'team' as const,
321
321
  })),
322
322
  }
@@ -391,7 +391,7 @@ async function compareProject(
391
391
  path: LOCK_REL,
392
392
  kind: 'unreducible',
393
393
  detail: `cannot be read — ${(err as Error).message}`,
394
- fix: 'fix the permissions or delete the file, then run opencastle sync; this one needs a person',
394
+ fix: 'fix the permissions or delete the file, then run npx opencastle sync; this one needs a person',
395
395
  })
396
396
  }
397
397
  if (actual !== null && actual !== expected) {
@@ -538,7 +538,7 @@ async function compareProject(
538
538
  path: rel,
539
539
  kind: 'unreducible',
540
540
  detail: `cannot be read — ${(err as Error).message}`,
541
- fix: `fix the permissions on ${rel}, then run opencastle sync; this one needs a person`,
541
+ fix: `fix the permissions on ${rel}, then run npx opencastle sync; this one needs a person`,
542
542
  })
543
543
  continue
544
544
  }
@@ -547,7 +547,7 @@ async function compareProject(
547
547
  // should have: then the file is output `sync` owes.
548
548
  const owed = Object.keys(team.expected)
549
549
  if (owed.length > 0) {
550
- drift.push({ ide, path: rel, kind: 'outdated', detail: `the team's servers sync writes: ${owed.join(', ')}`, fix: 'opencastle sync', origin: 'mcp' })
550
+ drift.push({ ide, path: rel, kind: 'outdated', detail: `the team's servers sync writes: ${owed.join(', ')}`, fix: 'npx opencastle sync', origin: 'mcp' })
551
551
  }
552
552
  continue
553
553
  }
@@ -560,7 +560,7 @@ async function compareProject(
560
560
  path: rel,
561
561
  kind: 'unreducible',
562
562
  detail: `cannot be read — ${(err as Error).message}`,
563
- fix: `fix or delete ${rel}, then run opencastle sync; this one needs a person`,
563
+ fix: `fix or delete ${rel}, then run npx opencastle sync; this one needs a person`,
564
564
  })
565
565
  continue
566
566
  }
@@ -585,7 +585,7 @@ async function compareProject(
585
585
  teamDiffers.length > 0 ? `not as the team config defines them, so sync writes: ${teamDiffers.join(', ')}` : '',
586
586
  audit.removed.length > 0
587
587
  ? `not in this project's stack, so sync removes: ${audit.removed.join(', ')} ` +
588
- `(opencastle add ${pluginIds(audit.removed).join(' ')} keeps them)`
588
+ `(npx opencastle add ${pluginIds(audit.removed).join(' ')} keeps them)`
589
589
  : '',
590
590
  audit.blockedByPolicy.length > 0
591
591
  ? `sync removes ${audit.blockedByPolicy.map((k) => `${k} (${resolved.blocked.get(k) ?? "refused by the team's MCP policy"})`).join(', ')}`
@@ -593,7 +593,7 @@ async function compareProject(
593
593
  audit.retired.length > 0 ? `no longer defined by any team layer, so sync removes: ${audit.retired.join(', ')}` : '',
594
594
  ].filter(Boolean)
595
595
  if (changes.length > 0) {
596
- drift.push({ ide, path: rel, kind: 'outdated', detail: changes.join('; '), fix: 'opencastle sync', origin: 'mcp' })
596
+ drift.push({ ide, path: rel, kind: 'outdated', detail: changes.join('; '), fix: 'npx opencastle sync', origin: 'mcp' })
597
597
  }
598
598
  // Failures `sync` will not clear — an entry someone edited, or their own.
599
599
  // Unpinned ones are warnings in `doctor` and are not drift here either.
@@ -636,7 +636,7 @@ async function compareProject(
636
636
  path: '.opencastle/agents/',
637
637
  kind: 'unreducible',
638
638
  detail: `cannot be read — ${unreadableHolder.message}`,
639
- fix: 'fix the permissions on .opencastle/agents/, then run opencastle sync; this one needs a person',
639
+ fix: 'fix the permissions on .opencastle/agents/, then run npx opencastle sync; this one needs a person',
640
640
  })
641
641
  } else if (existsSync(matrix)) {
642
642
  try {
@@ -647,7 +647,7 @@ async function compareProject(
647
647
  path: '.opencastle/agents/skill-matrix.json',
648
648
  kind: 'unreducible',
649
649
  detail: `cannot be read — ${(err as Error).message}`,
650
- fix: 'fix or delete the file, then run opencastle sync; this one needs a person',
650
+ fix: 'fix or delete the file, then run npx opencastle sync; this one needs a person',
651
651
  })
652
652
  }
653
653
  }
@@ -658,7 +658,7 @@ async function compareProject(
658
658
  // is what this catches, and `sync` rebuilds it.
659
659
  {
660
660
  const why = lessonsIndexDrift(resolve(projectRoot, '.opencastle'))
661
- if (why) drift.push({ ide: 'all', path: `.opencastle/${LESSONS_INDEX}`, kind: 'outdated', detail: why, fix: 'opencastle sync' })
661
+ if (why) drift.push({ ide: 'all', path: `.opencastle/${LESSONS_INDEX}`, kind: 'outdated', detail: why, fix: 'npx opencastle sync' })
662
662
  }
663
663
 
664
664
  // A manifest that parses but names no target this release knows is not a
@@ -672,7 +672,7 @@ async function compareProject(
672
672
  path: '.opencastle/manifest.json',
673
673
  kind: 'unreducible',
674
674
  detail: 'names no target this release recognises, so nothing could be compared',
675
- fix: 'fix the "ides" field, or re-run opencastle init; this one needs a person',
675
+ fix: 'fix the "ides" field, or re-run npx opencastle init; this one needs a person',
676
676
  })
677
677
  }
678
678
 
@@ -682,7 +682,7 @@ async function compareProject(
682
682
  function render(report: CheckReport): void {
683
683
  if (!report.installed) {
684
684
  console.error(`\n ${c.red('✗')} No OpenCastle installation found here.`)
685
- console.error(` ${c.dim('Run')} ${c.cyan('opencastle init')} ${c.dim('first.')}\n`)
685
+ console.error(` ${c.dim('Run')} ${c.cyan('npx opencastle init')} ${c.dim('first.')}\n`)
686
686
  return
687
687
  }
688
688
 
@@ -785,13 +785,13 @@ function render(report: CheckReport): void {
785
785
  if (report.drift.length > unreducible.length && unreducible.length > 0) {
786
786
  // Both kinds: `sync` alone may not clear the rest — the lock, for one, is
787
787
  // held back while an MCP config cannot be read.
788
- console.log(` ${c.bold('Fix:')} ${c.dim('the ones that need a person first, then')} ${c.cyan('opencastle sync')}`)
788
+ console.log(` ${c.bold('Fix:')} ${c.dim('the ones that need a person first, then')} ${c.cyan('npx opencastle sync')}`)
789
789
  console.log(` ${c.dim('To keep an edit, move it into .opencastle/ instead — that directory is yours.')}\n`)
790
790
  } else if (report.drift.length > unreducible.length) {
791
- console.log(` ${c.bold('Fix:')} ${c.cyan('opencastle sync')}`)
791
+ console.log(` ${c.bold('Fix:')} ${c.cyan('npx opencastle sync')}`)
792
792
  console.log(` ${c.dim('To keep an edit, move it into .opencastle/ instead — that directory is yours.')}\n`)
793
793
  } else {
794
- console.log(` ${c.bold('Fix:')} ${c.dim('by hand — see above, then run')} ${c.cyan('opencastle doctor')}\n`)
794
+ console.log(` ${c.bold('Fix:')} ${c.dim('by hand — see above, then run')} ${c.cyan('npx opencastle doctor')}\n`)
795
795
  }
796
796
  }
797
797
 
@@ -816,7 +816,7 @@ export async function runCheck({ pkgRoot, args }: CliContext): Promise<void> {
816
816
  path: (err as Error).message,
817
817
  kind: 'unreducible',
818
818
  detail: COMPARISON_FAILED,
819
- fix: 'fix the path named above, then run opencastle sync; this one needs a person',
819
+ fix: 'fix the path named above, then run npx opencastle sync; this one needs a person',
820
820
  },
821
821
  ],
822
822
  }
package/src/cli/sync.ts CHANGED
@@ -11,7 +11,7 @@ import type { CliContext } from './types.js'
11
11
  */
12
12
 
13
13
  const SYNC_HELP = `
14
- opencastle sync [options]
14
+ npx opencastle sync [options]
15
15
 
16
16
  Compile the framework sources into every configured assistant target,
17
17
  preserving your customizations in .opencastle/.
@@ -58,7 +58,7 @@ describe.skipIf(!built)('a stale MCP default is fixed by the command doctor name
58
58
 
59
59
  const before = run(dir, ['doctor'])
60
60
  expect(before.code).toBe(1)
61
- expect(before.out).toContain('opencastle sync fixes Supabase')
61
+ expect(before.out).toContain('npx opencastle sync fixes Supabase')
62
62
  // The check a team runs in CI must not be green over what doctor fails.
63
63
  const check = run(dir, ['sync', '--check'])
64
64
  expect(check.code).toBe(1)
@@ -83,7 +83,7 @@ describe.skipIf(!built)('a stale MCP default is fixed by the command doctor name
83
83
  )
84
84
  const doctor = run(dir, ['doctor'])
85
85
  expect(doctor.code).toBe(1)
86
- expect(doctor.out).toContain('delete the entry and run opencastle sync --force')
86
+ expect(doctor.out).toContain('delete the entry and run npx opencastle sync --force')
87
87
  expect(run(dir, ['sync', '--check']).code).toBe(1)
88
88
 
89
89
  // Follow it literally.
@@ -108,7 +108,7 @@ describe.skipIf(!built)('a stale MCP default is fixed by the command doctor name
108
108
 
109
109
  const doctor = run(dir, ['doctor'])
110
110
  expect(doctor.code).toBe(1)
111
- expect(doctor.out).toContain('opencastle sync removes Figma')
111
+ expect(doctor.out).toContain('npx opencastle sync removes Figma')
112
112
  const check = run(dir, ['sync', '--check'])
113
113
  expect(check.code).toBe(1)
114
114
  expect(check.out).toContain('so sync removes: Figma')
@@ -150,6 +150,28 @@ describe.skipIf(!built)('a repository extending a baseline', () => {
150
150
  expect(down.out).toContain('Downgrading this project from OpenCastle 99.0.0')
151
151
  })
152
152
 
153
+ it('refuses a baseline older than the one the lock records — a node_modules from before the bump', () => {
154
+ installBaseline(dir, '1.3.0')
155
+ const sync = run(dir, ['sync', '--yes'])
156
+ expect(sync.code).toBe(1)
157
+ expect(sync.out).toContain('@acme/base 1.3.0 is installed here; this project was compiled with 1.4.0')
158
+ expect(JSON.parse(readFileSync(join(dir, '.opencastle', 'lock.json'), 'utf8')).layers[1].version).toBe('1.4.0')
159
+ const down = run(dir, ['sync', '--allow-downgrade', '--yes'])
160
+ expect(down.code).toBe(0)
161
+ expect(down.out).toContain('Downgrading @acme/base from 1.4.0 to 1.3.0')
162
+ })
163
+
164
+ it('adds nothing to a .env the repository commits', () => {
165
+ write(dir, { '.env': 'SHARED_DEFAULT=1\n' })
166
+ git(dir, 'add', '-f', '.env')
167
+ git(dir, '-c', 'user.email=t@t', '-c', 'user.name=t', 'commit', '-qm', 'shared defaults')
168
+ const init = run(dir, ['init', '--yes'])
169
+ expect(init.code).toBe(0)
170
+ expect(readFileSync(join(dir, '.env'), 'utf8')).toBe('SHARED_DEFAULT=1\n')
171
+ expect(init.out).toContain('.env is committed in this repository, so nothing was added to it')
172
+ expect(init.out).toContain('in your shell — .env is committed here')
173
+ })
174
+
153
175
  it('init refuses to downgrade too', () => {
154
176
  const path = join(dir, '.opencastle', 'manifest.json')
155
177
  const manifest = JSON.parse(readFileSync(path, 'utf8'))
@@ -198,7 +220,16 @@ describe.skipIf(!built)('a repository extending a baseline', () => {
198
220
  const workflow = readFileSync(join(dir, '.github', 'workflows', 'opencastle.yml'), 'utf8')
199
221
  expect(workflow).toContain('sync --check')
200
222
  expect(readFileSync(join(dir, '.github', 'CODEOWNERS'), 'utf8')).toContain('/.opencastle/lock.json @acme/platform')
201
- expect(run(dir, ['ci']).code).toBe(1)
223
+ // Again: the same workflow is done, not a conflict.
224
+ const again = run(dir, ['ci'])
225
+ expect(again.code).toBe(0)
226
+ expect(again.out).toContain('is already this workflow')
227
+ // A different file of that name is someone's; it needs --force.
228
+ writeFileSync(join(dir, '.github', 'workflows', 'opencastle.yml'), 'name: ours\n')
229
+ const theirs = run(dir, ['ci'])
230
+ expect(theirs.code).toBe(1)
231
+ expect(theirs.out).toContain('differs from the one OpenCastle writes')
232
+ expect(readFileSync(join(dir, '.github', 'workflows', 'opencastle.yml'), 'utf8')).toBe('name: ours\n')
202
233
  })
203
234
 
204
235
  it('reads the fleet from committed locks', () => {
package/src/cli/update.ts CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  requiredEnvVars,
30
30
  type ResolvedSources,
31
31
  } from './layers.js'
32
- import { buildLock, writeLock, LOCK_REL, priorTeam } from './lock.js'
32
+ import { buildLock, writeLock, readLock, LOCK_REL, priorTeam } from './lock.js'
33
33
  import { parseVersion, compareVersions } from './version-range.js'
34
34
  import { COMMAND_NAMESPACE } from './command-namespace.js'
35
35
  import { parseMcpConfigText } from './mcp-file.js'
@@ -65,7 +65,7 @@ function manifestMeaning(m: Record<string, unknown>): string {
65
65
  }
66
66
 
67
67
  const UPDATE_HELP = `
68
- opencastle update [options]
68
+ npx opencastle update [options]
69
69
 
70
70
  Update framework files to the latest version while preserving
71
71
  your customizations in the .opencastle/ directory.
@@ -73,8 +73,8 @@ const UPDATE_HELP = `
73
73
  Options:
74
74
  --dry-run Preview what would be changed without writing files
75
75
  --force Force update even if versions match
76
- --allow-downgrade Recompile with this OpenCastle even though a newer one
77
- compiled the project
76
+ --allow-downgrade Recompile with this OpenCastle, or an installed baseline,
77
+ even though a newer one compiled the project
78
78
  --reconfigure Choose the tech and team tools again (the assistants
79
79
  are chosen by opencastle init)
80
80
  --help, -h Show this help
@@ -217,6 +217,26 @@ export default async function update({
217
217
  reportTeamIssues(early)
218
218
  process.exit(1)
219
219
  }
220
+ // A baseline older than the one the lock records is a node_modules from
221
+ // before the bump, and compiling would quietly take the repository back to
222
+ // it: the next commit downgrades the team's standard with nobody choosing
223
+ // to. The guard above covers OpenCastle's own version only.
224
+ const locked = readLock(projectRoot)?.layers ?? []
225
+ for (const layer of early.layers) {
226
+ if (layer.kind !== 'baseline' || !layer.version) continue
227
+ const was = locked.find((l) => l.id === layer.id)?.version
228
+ const now = parseVersion(layer.version)
229
+ const then = was ? parseVersion(was) : null
230
+ if (!now || !then || compareVersions(now, then) >= 0) continue
231
+ if (args.includes('--allow-downgrade')) {
232
+ console.log(` ${c.yellow('!')} Downgrading ${layer.id} from ${was} to ${layer.version}, as asked.`)
233
+ continue
234
+ }
235
+ console.error(`\n ${c.red('✗')} ${layer.id} ${layer.version} is installed here; this project was compiled with ${was}.`)
236
+ console.error(` ${c.dim('Syncing would take the whole repository back to the older baseline. Install the dependencies again —')}`)
237
+ console.error(` ${c.dim('npm install, or your package manager\'s — or pass --allow-downgrade to go back on purpose.')}\n`)
238
+ process.exit(1)
239
+ }
220
240
  }
221
241
 
222
242
  // ── Recreate the local-only directories ─────────────────────────
@@ -326,7 +346,10 @@ export default async function update({
326
346
  // `--yes` means "do not ask me anything". This one slipped the guard, so a CI
327
347
  // runner holding stdin open would block here on an up-to-date project, and
328
348
  // `add`, which routes through sync, asked twice for one instruction.
329
- if (assumeYes) {
349
+ // Nobody to ask: a CI job, or input that is not a terminal. The question
350
+ // was printed anyway and answered with its default, a line of noise in
351
+ // every log.
352
+ if (assumeYes || !process.stdin.isTTY || (process.env.CI && process.env.CI !== 'false')) {
330
353
  closePrompts()
331
354
  return
332
355
  }
@@ -750,7 +773,7 @@ export default async function update({
750
773
  console.log(
751
774
  ` ${c.yellow('-')} Removed ${removedServers.size} MCP server(s) this project's stack no longer includes: ` +
752
775
  [...removedServers].sort().join(', ') +
753
- c.dim(' (opencastle add <pack> brings one back)'),
776
+ c.dim(' (npx opencastle add <pack> brings one back)'),
754
777
  )
755
778
  }
756
779
  if (teamWritten.size > 0) {
@@ -794,7 +817,7 @@ export default async function update({
794
817
  )
795
818
  }
796
819
  if (lockWritten) {
797
- console.log(` ${c.green('✓')} Updated ${LOCK_REL} ${c.dim('(opencastle review explains the change)')}`)
820
+ console.log(` ${c.green('✓')} Updated ${LOCK_REL} ${c.dim('(npx opencastle review explains the change)')}`)
798
821
  }
799
822
  if (lockHeld) {
800
823
  console.log(` ${c.yellow('!')} Left ${LOCK_REL} as it was until every MCP config can be read — fix the file named below and sync again.`)
@@ -900,7 +923,7 @@ export default async function update({
900
923
  for (const p of new Set(tornRoots)) {
901
924
  console.log(` ${c.bold(relative(projectRoot, p))}`)
902
925
  console.log(
903
- ` ${c.dim('└')} ${c.dim('text beside it may be stale generated output; only you can tell. Run')} ${c.cyan('opencastle doctor')}\n`,
926
+ ` ${c.dim('└')} ${c.dim('text beside it may be stale generated output; only you can tell. Run')} ${c.cyan('npx opencastle doctor')}\n`,
904
927
  )
905
928
  }
906
929
  }
@@ -7,8 +7,10 @@ tool quirk, a convention written down nowhere else. **Read this before you
7
7
  start work**, then open the lessons that match your task.
8
8
 
9
9
  Each lesson is a file in `.opencastle/lessons/`. Add one with
10
- `opencastle lesson --title ... --category ... --severity ... --problem ...`
11
- (and `--cite <path>` for the code it is about). Do not edit this index:
12
- it is rewritten from those files by every `opencastle sync`.
10
+ `npx opencastle lesson --title ... --category ... --severity ... --problem ...`
11
+ (and `--cite <path>` for the code it is about). The category is one of
12
+ `task-management`, `jira`, `mcp-tools`, `codebase-tool`, `terminal`, `framework`, `cms`, `database`, `git`, `deployment`, `browser-testing`, `general`;
13
+ the severity `high`, `medium` or `low`. Do not edit this index:
14
+ it is rewritten from those files by every `npx opencastle sync`.
13
15
 
14
16
  No lessons yet.