opencastle 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/README.md +90 -125
  2. package/bin/cli.mjs +12 -1
  3. package/dist/cli/adapters/antigravity.d.ts +0 -1
  4. package/dist/cli/adapters/antigravity.d.ts.map +1 -1
  5. package/dist/cli/adapters/antigravity.js +2 -1
  6. package/dist/cli/adapters/antigravity.js.map +1 -1
  7. package/dist/cli/adapters/claude-code.d.ts +5 -4
  8. package/dist/cli/adapters/claude-code.d.ts.map +1 -1
  9. package/dist/cli/adapters/claude-code.js +7 -4
  10. package/dist/cli/adapters/claude-code.js.map +1 -1
  11. package/dist/cli/adapters/cursor.d.ts.map +1 -1
  12. package/dist/cli/adapters/cursor.js +8 -1
  13. package/dist/cli/adapters/cursor.js.map +1 -1
  14. package/dist/cli/adapters/opencode.d.ts +12 -5
  15. package/dist/cli/adapters/opencode.d.ts.map +1 -1
  16. package/dist/cli/adapters/opencode.js +17 -5
  17. package/dist/cli/adapters/opencode.js.map +1 -1
  18. package/dist/cli/adapters/rules-dir-base.d.ts +12 -1
  19. package/dist/cli/adapters/rules-dir-base.d.ts.map +1 -1
  20. package/dist/cli/adapters/rules-dir-base.js +43 -57
  21. package/dist/cli/adapters/rules-dir-base.js.map +1 -1
  22. package/dist/cli/adapters/rules-dir-base.test.js +27 -18
  23. package/dist/cli/adapters/rules-dir-base.test.js.map +1 -1
  24. package/dist/cli/adapters/single-file-base.d.ts +29 -0
  25. package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
  26. package/dist/cli/adapters/single-file-base.js +49 -16
  27. package/dist/cli/adapters/single-file-base.js.map +1 -1
  28. package/dist/cli/adapters/vscode.d.ts +2 -1
  29. package/dist/cli/adapters/vscode.d.ts.map +1 -1
  30. package/dist/cli/adapters/vscode.js +2 -1
  31. package/dist/cli/adapters/vscode.js.map +1 -1
  32. package/dist/cli/adapters/windsurf.d.ts.map +1 -1
  33. package/dist/cli/adapters/windsurf.js +11 -1
  34. package/dist/cli/adapters/windsurf.js.map +1 -1
  35. package/dist/cli/agent-plugin.test.js +12 -0
  36. package/dist/cli/agent-plugin.test.js.map +1 -1
  37. package/dist/cli/baseline.d.ts.map +1 -1
  38. package/dist/cli/baseline.js +15 -8
  39. package/dist/cli/baseline.js.map +1 -1
  40. package/dist/cli/bootstrap.d.ts.map +1 -1
  41. package/dist/cli/bootstrap.js +20 -0
  42. package/dist/cli/bootstrap.js.map +1 -1
  43. package/dist/cli/ci.d.ts.map +1 -1
  44. package/dist/cli/ci.js +24 -8
  45. package/dist/cli/ci.js.map +1 -1
  46. package/dist/cli/codex-target.test.js +14 -1
  47. package/dist/cli/codex-target.test.js.map +1 -1
  48. package/dist/cli/command-namespace.test.js +33 -0
  49. package/dist/cli/command-namespace.test.js.map +1 -1
  50. package/dist/cli/convoy-cmd.d.ts.map +1 -1
  51. package/dist/cli/convoy-cmd.js +2 -1
  52. package/dist/cli/convoy-cmd.js.map +1 -1
  53. package/dist/cli/dispatcher.test.js +6 -0
  54. package/dist/cli/dispatcher.test.js.map +1 -1
  55. package/dist/cli/docs-accuracy.test.js +33 -8
  56. package/dist/cli/docs-accuracy.test.js.map +1 -1
  57. package/dist/cli/doctor.d.ts.map +1 -1
  58. package/dist/cli/doctor.js +9 -6
  59. package/dist/cli/doctor.js.map +1 -1
  60. package/dist/cli/doctor.test.js +2 -2
  61. package/dist/cli/doctor.test.js.map +1 -1
  62. package/dist/cli/explain.d.ts +5 -0
  63. package/dist/cli/explain.d.ts.map +1 -1
  64. package/dist/cli/explain.js +38 -2
  65. package/dist/cli/explain.js.map +1 -1
  66. package/dist/cli/init-own-files.test.d.ts +2 -0
  67. package/dist/cli/init-own-files.test.d.ts.map +1 -0
  68. package/dist/cli/init-own-files.test.js +133 -0
  69. package/dist/cli/init-own-files.test.js.map +1 -0
  70. package/dist/cli/init.d.ts.map +1 -1
  71. package/dist/cli/init.js +106 -7
  72. package/dist/cli/init.js.map +1 -1
  73. package/dist/cli/init.test.js +52 -27
  74. package/dist/cli/init.test.js.map +1 -1
  75. package/dist/cli/layers.d.ts.map +1 -1
  76. package/dist/cli/layers.js +13 -4
  77. package/dist/cli/layers.js.map +1 -1
  78. package/dist/cli/lesson.d.ts.map +1 -1
  79. package/dist/cli/lesson.js +6 -5
  80. package/dist/cli/lesson.js.map +1 -1
  81. package/dist/cli/managed-paths.d.ts.map +1 -1
  82. package/dist/cli/managed-paths.js +3 -1
  83. package/dist/cli/managed-paths.js.map +1 -1
  84. package/dist/cli/mcp-audit.d.ts.map +1 -1
  85. package/dist/cli/mcp-audit.js +2 -0
  86. package/dist/cli/mcp-audit.js.map +1 -1
  87. package/dist/cli/mcp-upgrade.test.js +24 -1
  88. package/dist/cli/mcp-upgrade.test.js.map +1 -1
  89. package/dist/cli/mcp.d.ts.map +1 -1
  90. package/dist/cli/mcp.js +22 -3
  91. package/dist/cli/mcp.js.map +1 -1
  92. package/dist/cli/prompt.d.ts.map +1 -1
  93. package/dist/cli/prompt.js +9 -7
  94. package/dist/cli/prompt.js.map +1 -1
  95. package/dist/cli/prompt.test.js +20 -2
  96. package/dist/cli/prompt.test.js.map +1 -1
  97. package/dist/cli/remove.d.ts.map +1 -1
  98. package/dist/cli/remove.js +3 -1
  99. package/dist/cli/remove.js.map +1 -1
  100. package/dist/cli/review.d.ts.map +1 -1
  101. package/dist/cli/review.js +7 -1
  102. package/dist/cli/review.js.map +1 -1
  103. package/dist/cli/sync-check.d.ts.map +1 -1
  104. package/dist/cli/sync-check.js +12 -3
  105. package/dist/cli/sync-check.js.map +1 -1
  106. package/dist/cli/sync-check.test.js +5 -4
  107. package/dist/cli/sync-check.test.js.map +1 -1
  108. package/dist/cli/sync.d.ts.map +1 -1
  109. package/dist/cli/sync.js +3 -2
  110. package/dist/cli/sync.js.map +1 -1
  111. package/dist/cli/team-commands.test.js +12 -0
  112. package/dist/cli/team-commands.test.js.map +1 -1
  113. package/dist/cli/team-sources.test.js +10 -0
  114. package/dist/cli/team-sources.test.js.map +1 -1
  115. package/dist/cli/types.d.ts +1 -1
  116. package/dist/cli/types.d.ts.map +1 -1
  117. package/dist/cli/update.d.ts.map +1 -1
  118. package/dist/cli/update.js +4 -3
  119. package/dist/cli/update.js.map +1 -1
  120. package/dist/cli/website-plugins.test.js +51 -2
  121. package/dist/cli/website-plugins.test.js.map +1 -1
  122. package/dist/cli/windsurf-target.test.d.ts +2 -0
  123. package/dist/cli/windsurf-target.test.d.ts.map +1 -0
  124. package/dist/cli/windsurf-target.test.js +62 -0
  125. package/dist/cli/windsurf-target.test.js.map +1 -0
  126. package/dist/orchestrator/plugins/coolify/config.d.ts.map +1 -1
  127. package/dist/orchestrator/plugins/coolify/config.js +13 -0
  128. package/dist/orchestrator/plugins/coolify/config.js.map +1 -1
  129. package/dist/orchestrator/plugins/registry.test.d.ts +2 -0
  130. package/dist/orchestrator/plugins/registry.test.d.ts.map +1 -0
  131. package/dist/orchestrator/plugins/registry.test.js +37 -0
  132. package/dist/orchestrator/plugins/registry.test.js.map +1 -0
  133. package/dist/orchestrator/plugins/sentry/config.d.ts.map +1 -1
  134. package/dist/orchestrator/plugins/sentry/config.js +13 -0
  135. package/dist/orchestrator/plugins/sentry/config.js.map +1 -1
  136. package/package.json +1 -1
  137. package/src/cli/adapters/antigravity.ts +2 -1
  138. package/src/cli/adapters/claude-code.ts +7 -4
  139. package/src/cli/adapters/cursor.ts +8 -1
  140. package/src/cli/adapters/opencode.ts +18 -6
  141. package/src/cli/adapters/rules-dir-base.test.ts +28 -18
  142. package/src/cli/adapters/rules-dir-base.ts +51 -90
  143. package/src/cli/adapters/single-file-base.ts +77 -16
  144. package/src/cli/adapters/vscode.ts +2 -1
  145. package/src/cli/adapters/windsurf.ts +11 -1
  146. package/src/cli/agent-plugin.test.ts +14 -0
  147. package/src/cli/baseline.ts +16 -6
  148. package/src/cli/bootstrap.ts +23 -0
  149. package/src/cli/ci.ts +25 -8
  150. package/src/cli/codex-target.test.ts +15 -1
  151. package/src/cli/command-namespace.test.ts +35 -0
  152. package/src/cli/convoy/TELEMETRY.md +64 -62
  153. package/src/cli/convoy-cmd.ts +2 -1
  154. package/src/cli/dispatcher.test.ts +7 -0
  155. package/src/cli/docs-accuracy.test.ts +34 -7
  156. package/src/cli/doctor.test.ts +2 -2
  157. package/src/cli/doctor.ts +9 -6
  158. package/src/cli/explain.ts +36 -2
  159. package/src/cli/init-own-files.test.ts +156 -0
  160. package/src/cli/init.test.ts +55 -27
  161. package/src/cli/init.ts +104 -7
  162. package/src/cli/layers.ts +13 -4
  163. package/src/cli/lesson.ts +6 -5
  164. package/src/cli/managed-paths.ts +3 -1
  165. package/src/cli/mcp-audit.ts +2 -0
  166. package/src/cli/mcp-upgrade.test.ts +26 -1
  167. package/src/cli/mcp.ts +22 -3
  168. package/src/cli/prompt.test.ts +21 -2
  169. package/src/cli/prompt.ts +11 -7
  170. package/src/cli/remove.ts +3 -0
  171. package/src/cli/review.ts +7 -1
  172. package/src/cli/sync-check.test.ts +5 -4
  173. package/src/cli/sync-check.ts +12 -3
  174. package/src/cli/sync.ts +3 -2
  175. package/src/cli/team-commands.test.ts +16 -0
  176. package/src/cli/team-sources.test.ts +11 -0
  177. package/src/cli/types.ts +1 -1
  178. package/src/cli/update.ts +4 -3
  179. package/src/cli/website-plugins.test.ts +55 -5
  180. package/src/cli/windsurf-target.test.ts +70 -0
  181. package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
  182. package/src/orchestrator/agents/team-lead.agent.md +2 -2
  183. package/src/orchestrator/customizations/README.md +58 -13
  184. package/src/orchestrator/customizations/logs/README.md +23 -18
  185. package/src/orchestrator/instructions/general.instructions.md +1 -1
  186. package/src/orchestrator/plugins/coolify/config.ts +13 -0
  187. package/src/orchestrator/plugins/registry.test.ts +42 -0
  188. package/src/orchestrator/plugins/sentry/config.ts +13 -0
  189. package/src/orchestrator/prompts/bootstrap-customizations.prompt.md +44 -49
  190. package/src/orchestrator/prompts/brainstorm.prompt.md +2 -2
  191. package/src/orchestrator/prompts/bug-fix.prompt.md +5 -4
  192. package/src/orchestrator/prompts/create-skill.prompt.md +29 -39
  193. package/src/orchestrator/prompts/generate-convoy.prompt.md +1 -1
  194. package/src/orchestrator/prompts/generate-prd.prompt.md +1 -1
  195. package/src/orchestrator/prompts/implement-feature.prompt.md +7 -6
@@ -1,5 +1,7 @@
1
- import { existsSync, readFileSync } from 'node:fs'
2
- import { resolve } from 'node:path'
1
+ import { existsSync, readFileSync, realpathSync } from 'node:fs'
2
+ import { homedir } from 'node:os'
3
+ import { join, resolve } from 'node:path'
4
+ import { parse as parseToml } from 'smol-toml'
3
5
  import { readManifest } from './manifest.js'
4
6
  import { resolveStack, isEnvVarSatisfied } from './stack-config.js'
5
7
  import { resolveSources, materialize, hasErrors, formatIssues, requiredEnvVars, refuseOlderCli } from './layers.js'
@@ -92,10 +94,41 @@ async function build(pkgRoot: string, projectRoot: string): Promise<ExplainRepor
92
94
  setup.push({ server: key, need: 'sign-in', ok: true, how: 'your assistant opens a browser to sign in the first time it starts the server' })
93
95
  }
94
96
  }
97
+ // Codex loads a project's `.codex/config.toml` only once the user has
98
+ // trusted the project, so every server written there waits on that.
99
+ if (ides.includes('codex') && Object.keys(lock.mcp).length > 0) {
100
+ setup.push({
101
+ server: 'Codex CLI',
102
+ need: 'trust',
103
+ ok: codexTrusts(projectRoot),
104
+ how: 'Codex reads .codex/config.toml, and so every MCP server here, only in a project you trust — run codex in this directory and trust it when it asks',
105
+ })
106
+ }
95
107
  const notes = resolved.issues.filter((i) => i.level === 'warning').map((i) => `${i.where}: ${i.message}`)
96
108
  return { targets, lock, setup, notes }
97
109
  }
98
110
 
111
+ /**
112
+ * Whether Codex has been told to trust this project: `trust_level = "trusted"`
113
+ * under `[projects."<path>"]` in its own config, `$CODEX_HOME/config.toml`.
114
+ */
115
+ export function codexTrusts(projectRoot: string): boolean {
116
+ const file = join(process.env.CODEX_HOME || join(process.env.HOME || homedir(), '.codex'), 'config.toml')
117
+ let projects: Record<string, { trust_level?: unknown }>
118
+ try {
119
+ projects = ((parseToml(readFileSync(file, 'utf8')) as { projects?: Record<string, { trust_level?: unknown }> }).projects ?? {})
120
+ } catch {
121
+ return false
122
+ }
123
+ const spellings = new Set([projectRoot])
124
+ try {
125
+ spellings.add(realpathSync(projectRoot))
126
+ } catch {
127
+ // The path as given is the only spelling there is.
128
+ }
129
+ return [...spellings].some((p) => projects[p]?.trust_level === 'trusted')
130
+ }
131
+
99
132
  function render(report: ExplainReport, all: boolean): void {
100
133
  const { lock } = report
101
134
  const out = (s = ''): void => console.log(s)
@@ -191,6 +224,7 @@ function render(report: ExplainReport, all: boolean): void {
191
224
  if (report.setup.length === 0) out(` ${c.green('✓')} Nothing to set up — every server works without a variable or a sign-in.`)
192
225
  for (const s of report.setup) {
193
226
  if (s.need === 'sign-in') out(` ${c.cyan('→')} ${s.server}: ${s.how}`)
227
+ else if (s.need === 'trust') out(` ${s.ok ? c.green('✓') : c.red('✗')} ${s.ok ? 'Codex trusts this project' : 'Codex does not trust this project yet'} ${c.dim(`— ${s.how}`)}`)
194
228
  else out(` ${s.ok ? c.green('✓') : c.red('✗')} ${s.need} ${c.dim(`— ${s.how}${s.ok ? '' : '; set it in .env or your shell'}`)}`)
195
229
  }
196
230
  out('')
@@ -0,0 +1,156 @@
1
+ /**
2
+ * What `init` says about files that were there before it.
3
+ *
4
+ * A target is often detected because of a file of the user's in its own rules
5
+ * directory — `.cursor/rules/team.mdc` is what makes Cursor a target — and that
6
+ * directory is generated, so the next `sync` removes the file. `init` used to
7
+ * say nothing, and the first anyone heard of it was `sync` naming a file it had
8
+ * just deleted. The same accounting is what makes "Left N existing files
9
+ * untouched" mean files that were there: a fresh seven-target install said 205,
10
+ * every one of them written a moment earlier by the target before.
11
+ */
12
+ import { describe, it, expect, beforeEach, afterEach } from 'vitest'
13
+ import { execFileSync } from 'node:child_process'
14
+ import { mkdtempSync, mkdirSync, rmSync, writeFileSync, readFileSync, existsSync } from 'node:fs'
15
+ import { tmpdir } from 'node:os'
16
+ import { join, resolve } from 'node:path'
17
+
18
+ const repoRoot = resolve(import.meta.dirname, '..', '..')
19
+ const cli = join(repoRoot, 'bin', 'cli.mjs')
20
+
21
+ // `bin/cli.mjs` loads the command modules from `dist/`. CI builds before
22
+ // `npm test`, so nothing here is skipped there.
23
+ const cliBuilt = existsSync(join(repoRoot, 'dist', 'cli', 'init.js'))
24
+
25
+ describe.skipIf(!cliBuilt)('init and the files already there', () => {
26
+ let projectRoot: string
27
+ let home: string
28
+
29
+ const run = (...args: string[]): string =>
30
+ execFileSync('node', [cli, ...args], {
31
+ cwd: projectRoot,
32
+ encoding: 'utf8',
33
+ stdio: ['ignore', 'pipe', 'pipe'],
34
+ // A scratch home, so nothing of the person running the tests is read, and
35
+ // plain text to assert on.
36
+ env: { ...process.env, HOME: home, CLAUDE_CONFIG_DIR: join(home, '.claude'), CODEX_HOME: join(home, '.codex'), NO_COLOR: '1' },
37
+ })
38
+
39
+ beforeEach(() => {
40
+ projectRoot = mkdtempSync(join(tmpdir(), 'oc-own-files-'))
41
+ home = mkdtempSync(join(tmpdir(), 'oc-own-files-home-'))
42
+ execFileSync('git', ['init', '-q'], { cwd: projectRoot })
43
+ })
44
+
45
+ afterEach(() => {
46
+ rmSync(projectRoot, { recursive: true, force: true })
47
+ rmSync(home, { recursive: true, force: true })
48
+ })
49
+
50
+ it('names a rule of yours in a generated directory, and leaves it in place', () => {
51
+ mkdirSync(join(projectRoot, '.cursor', 'rules'), { recursive: true })
52
+ writeFileSync(join(projectRoot, '.cursor', 'rules', 'team.mdc'), '---\nalwaysApply: true\n---\nUse tabs.\n')
53
+
54
+ const out = run('init', '--yes')
55
+
56
+ expect(out).toContain('1 file of yours is in a directory OpenCastle generates')
57
+ expect(out).toContain('.cursor/rules/team.mdc')
58
+ expect(out).toContain('The next sync removes it')
59
+ expect(readFileSync(join(projectRoot, '.cursor', 'rules', 'team.mdc'), 'utf8')).toContain('Use tabs.')
60
+ })
61
+
62
+ it('says nothing of the kind when there is nothing of yours there', () => {
63
+ writeFileSync(join(projectRoot, 'CLAUDE.md'), '# House rules\n')
64
+ expect(run('init', '--yes')).not.toContain('of yours')
65
+ })
66
+
67
+ it('counts nothing as left alone on a fresh install for several targets that share a directory', () => {
68
+ // Cursor, Windsurf and OpenCode all write `.agents/skills/`.
69
+ writeFileSync(join(projectRoot, '.cursorrules'), 'rules\n')
70
+ writeFileSync(join(projectRoot, '.windsurfrules'), 'rules\n')
71
+ writeFileSync(join(projectRoot, 'opencode.json'), '{}\n')
72
+
73
+ const out = run('init', '--yes')
74
+
75
+ expect(out).not.toMatch(/Left \d+ existing files? untouched/)
76
+ const manifest = JSON.parse(readFileSync(join(projectRoot, '.opencastle', 'manifest.json'), 'utf8'))
77
+ const customizable: string[] = manifest.managedPaths.customizable
78
+ expect(customizable.filter((p) => p === '.opencastle/')).toHaveLength(1)
79
+ expect(new Set(manifest.managedPaths.framework).size).toBe(manifest.managedPaths.framework.length)
80
+ })
81
+
82
+ it('leaves out the notes for a database and a CMS the project does not use', () => {
83
+ writeFileSync(join(projectRoot, 'CLAUDE.md'), '# House rules\n')
84
+ run('init', '--yes')
85
+ expect(existsSync(join(projectRoot, '.opencastle', 'stack', 'supabase-config.md'))).toBe(false)
86
+ expect(existsSync(join(projectRoot, '.opencastle', 'stack', 'sanity-config.md'))).toBe(false)
87
+ })
88
+
89
+ it('writes the MCP config of an assistant a second init adds', () => {
90
+ // Recompiling the new target instead of installing it left it with no
91
+ // servers, and every check said all was well.
92
+ writeFileSync(join(projectRoot, 'CLAUDE.md'), '# House rules\n')
93
+ run('init', '--yes')
94
+ writeFileSync(join(projectRoot, '.cursorrules'), 'rules\n')
95
+ run('init', '--yes')
96
+ expect(existsSync(join(projectRoot, '.cursor', 'mcp.json'))).toBe(true)
97
+ })
98
+
99
+ it('does not put back, on a second init, the templates the first one pruned', () => {
100
+ writeFileSync(join(projectRoot, 'CLAUDE.md'), '# House rules\n')
101
+ run('init', '--yes')
102
+ const stack = join(projectRoot, '.opencastle', 'stack')
103
+ for (const name of ['cms-config.md', 'database-config.md', 'sanity-config.md', 'supabase-config.md']) {
104
+ expect(existsSync(join(stack, name)), name).toBe(false)
105
+ }
106
+ run('init', '--yes')
107
+ for (const name of ['cms-config.md', 'database-config.md', 'sanity-config.md', 'supabase-config.md']) {
108
+ expect(existsSync(join(stack, name)), `${name} after a second init`).toBe(false)
109
+ }
110
+ })
111
+
112
+ it('keeps the notes for the one it does use', () => {
113
+ writeFileSync(join(projectRoot, 'CLAUDE.md'), '# House rules\n')
114
+ writeFileSync(join(projectRoot, 'package.json'), JSON.stringify({ name: 'x', dependencies: { '@supabase/supabase-js': '2.0.0' } }))
115
+ run('init', '--yes')
116
+ expect(existsSync(join(projectRoot, '.opencastle', 'stack', 'supabase-config.md'))).toBe(true)
117
+ expect(existsSync(join(projectRoot, '.opencastle', 'stack', 'sanity-config.md'))).toBe(false)
118
+ })
119
+ })
120
+
121
+ describe.skipIf(!cliBuilt)('sync --check on a lessons index that is behind', () => {
122
+ let projectRoot: string
123
+ let home: string
124
+
125
+ beforeEach(() => {
126
+ projectRoot = mkdtempSync(join(tmpdir(), 'oc-lessons-check-'))
127
+ home = mkdtempSync(join(tmpdir(), 'oc-lessons-check-home-'))
128
+ execFileSync('git', ['init', '-q'], { cwd: projectRoot })
129
+ })
130
+
131
+ afterEach(() => {
132
+ rmSync(projectRoot, { recursive: true, force: true })
133
+ rmSync(home, { recursive: true, force: true })
134
+ })
135
+
136
+ it('files it under the sources that changed, not under MCP servers', () => {
137
+ const env = { ...process.env, HOME: home, CLAUDE_CONFIG_DIR: join(home, '.claude'), CODEX_HOME: join(home, '.codex'), NO_COLOR: '1' }
138
+ writeFileSync(join(projectRoot, 'CLAUDE.md'), '# House rules\n')
139
+ execFileSync('node', [cli, 'init', '--yes'], { cwd: projectRoot, env, stdio: 'ignore' })
140
+ // A lesson that arrived in a merge, with the index not yet rebuilt.
141
+ mkdirSync(join(projectRoot, '.opencastle', 'lessons'), { recursive: true })
142
+ writeFileSync(
143
+ join(projectRoot, '.opencastle', 'lessons', '2026-10-03-quote-shell-variables.md'),
144
+ '---\nid: "2026-10-03-quote-shell-variables"\ntitle: "Quote shell variables"\ncategory: "terminal"\nseverity: "medium"\nadded: "2026-10-03"\n---\n\n**Problem:** Unquoted variables break on spaces.\n',
145
+ )
146
+ let out = ''
147
+ try {
148
+ execFileSync('node', [cli, 'sync', '--check'], { cwd: projectRoot, env, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] })
149
+ } catch (err) {
150
+ out = String((err as { stdout?: string }).stdout ?? '')
151
+ }
152
+ expect(out).toContain('.opencastle/LESSONS-LEARNED.md')
153
+ expect(out).toContain('Sources changed since the last sync')
154
+ expect(out).not.toContain('MCP servers sync would change')
155
+ })
156
+ })
@@ -15,7 +15,7 @@
15
15
  */
16
16
 
17
17
  import { describe, it, expect, beforeEach, afterEach } from 'vitest'
18
- import { mkdtemp, readFile, readdir, rename, rm, unlink, writeFile } from 'node:fs/promises'
18
+ import { mkdir, mkdtemp, readFile, readdir, rename, rm, unlink, writeFile } from 'node:fs/promises'
19
19
  import { join, resolve } from 'node:path'
20
20
  import { tmpdir } from 'node:os'
21
21
  import { existsSync } from 'node:fs'
@@ -660,24 +660,28 @@ describe('Cursor adapter install', () => {
660
660
  expect(agents).toContain('content-engineer.mdc')
661
661
  })
662
662
 
663
- it('converts skills to .mdc in skills/ subdirectory', async () => {
663
+ it('writes skills as Agent Skills in .agents/skills/, which Cursor reads', async () => {
664
664
  const adapter = await IDE_ADAPTERS['cursor']()
665
665
  await adapter.install(PKG_ROOT, tempDir, STACK_SANITY_LINEAR, EMPTY_REPO_INFO)
666
666
 
667
- const skillsDir = join(tempDir, '.cursor', 'rules', 'skills')
667
+ const skillsDir = join(tempDir, '.agents', 'skills')
668
668
  const skills = await readdir(skillsDir)
669
669
 
670
670
  // Core skills should be present
671
- expect(skills).toContain('self-improvement.mdc')
672
- expect(skills).toContain('testing-workflow.mdc')
671
+ expect(skills).toContain('self-improvement')
672
+ expect(skills).toContain('testing-workflow')
673
+ expect(existsSync(join(skillsDir, 'testing-workflow', 'SKILL.md'))).toBe(true)
673
674
 
674
- // Selected plugin skills as .mdc
675
- expect(skills).toContain('sanity-cms.mdc')
676
- expect(skills).toContain('linear-task-management.mdc')
675
+ // Selected plugin skills
676
+ expect(skills).toContain('sanity-cms')
677
+ expect(skills).toContain('linear-task-management')
677
678
 
678
679
  // Unselected plugin skills should not be present
679
- expect(skills).not.toContain('supabase-database.mdc')
680
- expect(skills).not.toContain('slack-notifications.mdc')
680
+ expect(skills).not.toContain('supabase-database')
681
+ expect(skills).not.toContain('slack-notifications')
682
+
683
+ // Not as rules any more
684
+ expect(existsSync(join(tempDir, '.cursor', 'rules', 'skills'))).toBe(false)
681
685
  })
682
686
 
683
687
  it('generates Cursor MCP config with mcpServers format', async () => {
@@ -797,7 +801,7 @@ describe('Claude Code adapter install', () => {
797
801
  expect(content).not.toContain('**supabase-database**')
798
802
  })
799
803
 
800
- it('strips frontmatter from agent files in .claude/agents/', async () => {
804
+ it('writes agent files in .claude/agents/ with only the frontmatter Claude Code reads', async () => {
801
805
  const adapter = await IDE_ADAPTERS['claude-code']()
802
806
  await adapter.install(PKG_ROOT, tempDir, STACK_EMPTY, EMPTY_REPO_INFO)
803
807
 
@@ -808,9 +812,10 @@ describe('Claude Code adapter install', () => {
808
812
  expect(agents).not.toContain('data-engineer.agent.md')
809
813
 
810
814
  const devAgent = await readFile(join(agentsDir, 'developer.agent.md'), 'utf8')
811
- // Should NOT start with frontmatter
812
- expect(devAgent).not.toMatch(/^---\n/)
813
- // Should contain the body content (starts with comment or heading)
815
+ // A name and a description make it a subagent; the source's VS Code fields
816
+ // (tools, tier, handoffs) are not carried over.
817
+ expect(devAgent).toMatch(/^---\nname: developer\ndescription: "[^"\n]+"\n---\n/)
818
+ expect(devAgent).not.toMatch(/^tier:/m)
814
819
  expect(devAgent).toContain('Developer')
815
820
  })
816
821
 
@@ -915,16 +920,27 @@ describe('OpenCode adapter install', () => {
915
920
 
916
921
  const content = await readFile(join(tempDir, 'AGENTS.md'), 'utf8')
917
922
  expect(content).toContain('# Project Instructions')
918
- expect(content).toContain('.opencode/skills/')
923
+ expect(content).toContain('.agents/skills/')
919
924
  expect(content).toContain('.opencode/agents/')
920
925
  })
921
926
 
927
+ it('removes the .opencode/skills/ an earlier release wrote', async () => {
928
+ const adapter = await IDE_ADAPTERS['opencode']()
929
+ await adapter.install(PKG_ROOT, tempDir, STACK_EMPTY, EMPTY_REPO_INFO)
930
+ await mkdir(join(tempDir, '.opencode', 'skills', 'testing-workflow'), { recursive: true })
931
+ await writeFile(join(tempDir, '.opencode', 'skills', 'testing-workflow', 'SKILL.md'), 'old')
932
+ const result = await adapter.update(PKG_ROOT, tempDir, STACK_EMPTY, EMPTY_REPO_INFO)
933
+ expect(existsSync(join(tempDir, '.opencode', 'skills'))).toBe(false)
934
+ expect(result.deleted).toContain('.opencode/skills/')
935
+ })
936
+
922
937
  it('creates files in .opencode/ directory structure', async () => {
923
938
  const adapter = await IDE_ADAPTERS['opencode']()
924
939
  await adapter.install(PKG_ROOT, tempDir, STACK_SANITY_LINEAR, EMPTY_REPO_INFO)
925
940
 
926
941
  expect(existsSync(join(tempDir, '.opencode', 'agents'))).toBe(true)
927
- expect(existsSync(join(tempDir, '.opencode', 'skills'))).toBe(true)
942
+ expect(existsSync(join(tempDir, '.agents', 'skills', 'sanity-cms', 'SKILL.md'))).toBe(true)
943
+ expect(existsSync(join(tempDir, '.opencode', 'skills'))).toBe(false)
928
944
  expect(existsSync(join(tempDir, '.opencode', 'prompts'))).toBe(true)
929
945
  expect(existsSync(join(tempDir, '.opencode', 'workflows'))).toBe(true)
930
946
  })
@@ -977,7 +993,7 @@ describe('OpenCode adapter install', () => {
977
993
  expect(paths.merged).toContain('AGENTS.md')
978
994
  expect(paths.framework).not.toContain('AGENTS.md')
979
995
  expect(paths.framework).toContain('.opencode/agents/')
980
- expect(paths.framework).toContain('.opencode/skills/')
996
+ expect(paths.framework).toContain('.agents/skills/')
981
997
  expect(paths.framework).toContain('.opencode/prompts/')
982
998
  expect(paths.framework).toContain('.opencode/workflows/')
983
999
 
@@ -1047,21 +1063,18 @@ describe('Windsurf adapter install', () => {
1047
1063
  expect(files.length).toBeGreaterThan(0)
1048
1064
  })
1049
1065
 
1050
- it('creates skill rules in .windsurf/rules/skills/', async () => {
1066
+ it('writes skills as Agent Skills in .agents/skills/, which Devin Desktop reads', async () => {
1051
1067
  const adapter = await IDE_ADAPTERS['windsurf']()
1052
1068
  await adapter.install(PKG_ROOT, tmpDir, STACK_SANITY_LINEAR)
1053
- const skillsDir = join(tmpDir, '.windsurf', 'rules', 'skills')
1054
- expect(existsSync(skillsDir)).toBe(true)
1055
- const files = (await readdir(skillsDir)).filter(f => f.endsWith('.md'))
1056
- expect(files.length).toBeGreaterThan(0)
1069
+ expect(existsSync(join(tmpDir, '.agents', 'skills', 'sanity-cms', 'SKILL.md'))).toBe(true)
1070
+ expect(existsSync(join(tmpDir, '.windsurf', 'rules', 'skills'))).toBe(false)
1057
1071
  })
1058
1072
 
1059
- it('generates Windsurf MCP config with mcpServers format', async () => {
1073
+ it('writes MCP servers to .devin/mcp_config.json, the project file Devin Local reads', async () => {
1060
1074
  const adapter = await IDE_ADAPTERS['windsurf']()
1061
1075
  await adapter.install(PKG_ROOT, tmpDir, STACK_SANITY_LINEAR)
1062
- const mcpPath = join(tmpDir, '.windsurf', 'mcp.json')
1063
- expect(existsSync(mcpPath)).toBe(true)
1064
- const mcp = await readJson(mcpPath)
1076
+ expect(existsSync(join(tmpDir, '.windsurf', 'mcp.json'))).toBe(false)
1077
+ const mcp = await readJson(join(tmpDir, '.devin', 'mcp_config.json'))
1065
1078
  expect(mcp).toHaveProperty('mcpServers')
1066
1079
  })
1067
1080
 
@@ -1071,7 +1084,8 @@ describe('Windsurf adapter install', () => {
1071
1084
  expect(paths.merged).toContain('.windsurfrules')
1072
1085
  expect(paths.framework).not.toContain('.windsurfrules')
1073
1086
  expect(paths.framework.some(p => p.includes('.windsurf/rules/'))).toBe(true)
1074
- expect(paths.customizable).toContain('.windsurf/mcp.json')
1087
+ expect(paths.customizable).toContain('.devin/mcp_config.json')
1088
+ expect(paths.framework).toContain('.agents/skills/')
1075
1089
  })
1076
1090
  })
1077
1091
 
@@ -1148,6 +1162,20 @@ describe('Antigravity adapter install', () => {
1148
1162
  expect(content).toContain('.agents/')
1149
1163
  })
1150
1164
 
1165
+ it('points GEMINI.md at AGENTS.md when Codex or OpenCode writes it, so instructions load once', async () => {
1166
+ const both: StackConfig = { ...STACK_SANITY_LINEAR, ides: ['antigravity', 'codex'] }
1167
+ for (const ide of ['antigravity', 'codex'] as const) await (await IDE_ADAPTERS[ide]()).install(PKG_ROOT, tmpDir, both)
1168
+ const gemini = await readFile(join(tmpDir, 'GEMINI.md'), 'utf8')
1169
+ expect(gemini).toContain('are in `AGENTS.md`, which this assistant also reads')
1170
+ expect(gemini).not.toContain('## Available Skills')
1171
+ expect(await readFile(join(tmpDir, 'AGENTS.md'), 'utf8')).toContain('## Available Skills')
1172
+
1173
+ // Alone, it carries everything itself.
1174
+ await rm(join(tmpDir, 'GEMINI.md'))
1175
+ await (await IDE_ADAPTERS['antigravity']()).install(PKG_ROOT, tmpDir, { ...both, ides: ['antigravity'] })
1176
+ expect(await readFile(join(tmpDir, 'GEMINI.md'), 'utf8')).toContain('## Available Skills')
1177
+ })
1178
+
1151
1179
  it('creates files in .agents/ directory structure', async () => {
1152
1180
  const adapter = await IDE_ADAPTERS['antigravity']()
1153
1181
  await adapter.install(PKG_ROOT, tmpDir, STACK_SANITY_LINEAR)
package/src/cli/init.ts CHANGED
@@ -11,6 +11,7 @@ import { getPluginsBySubCategory } from '../orchestrator/plugins/index.js'
11
11
  import type { PluginConfig } from '../orchestrator/plugins/types.js'
12
12
  import { detectRepoInfo, mergeStackIntoRepoInfo, formatRepoInfo, buildDetectedToolsSet, detectCurrentIde, detectAssistantConfigs } from './detect.js'
13
13
  import { IDE_ADAPTERS } from './adapters/index.js'
14
+ import { filesUnderDir } from './adapters/single-file-base.js'
14
15
  import { IDE_LABELS } from './types.js'
15
16
  import type { CliContext, CopyResults, IdeAdapter, IdeChoice, TechTool, TeamTool, StackConfig } from './types.js'
16
17
  import { bootstrapCustomizations } from './bootstrap.js'
@@ -423,6 +424,33 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
423
424
  }
424
425
 
425
426
  // ── Run adapters for each selected IDE ──────────────────────────
427
+ // Files already in the directories the chosen targets generate. A target is
428
+ // often detected *because* of one — `.cursor/rules/team.mdc` is what made
429
+ // Cursor a target — and the directory is the target's own, so the next `sync`
430
+ // removes it as output with no source. `init` said nothing about it; the
431
+ // first anyone heard was `sync` naming a file it had just deleted.
432
+ const inGeneratedDirs = new Set<string>()
433
+ for (const ide of ides) {
434
+ const adapter = await IDE_ADAPTERS[ide]()
435
+ for (const dir of adapter.getManagedPaths().framework) {
436
+ if (!dir.endsWith('/')) continue
437
+ for (const rel of filesUnderDir(resolve(projectRoot, dir))) {
438
+ // A prompt of yours beside ours in `.github/prompts/` stays; only what a
439
+ // target claims is at risk.
440
+ if (adapter.ownsFile && !adapter.ownsFile(`${dir}${rel}`, projectRoot)) continue
441
+ inGeneratedDirs.add(resolve(projectRoot, dir, rel))
442
+ }
443
+ }
444
+ }
445
+ const produced = new Set<string>()
446
+ const removedByReinit: string[] = []
447
+ const previousIdes = new Set<string>(existing?.ides ?? (existing?.ide ? [existing.ide] : []))
448
+ // Skipped means "was already there", and with several targets sharing
449
+ // `.agents/skills/` the second one found the first one's output: a fresh
450
+ // seven-target install reported "Left 205 existing files untouched".
451
+ const createdThisRun = new Set<string>()
452
+ const leftAlone = new Set<string>()
453
+
426
454
  let totalCreated = 0
427
455
  let totalSkipped = 0
428
456
  const skippedPaths: string[] = []
@@ -460,9 +488,14 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
460
488
  // failed the same way, and `remove --all` refused to uninstall what it had
461
489
  // just installed. Single-target installs write the root file first and so
462
490
  // throw before anything lands, which is why this only showed up with two.
491
+ // An assistant added by `init --customize` is a first install for that
492
+ // target. Recompiling it instead never wrote its MCP config — `update`
493
+ // leaves that to `sync`, and `sync` found nothing to do — so the new
494
+ // assistant ran with no servers while every check reported all clear.
495
+ const compiledBefore = isReinit && previousIdes.has(ide)
463
496
  let results: CopyResults
464
497
  try {
465
- results = isReinit
498
+ results = compiledBefore
466
499
  ? await adapter.update(pkgRoot, projectRoot, stack, combinedRepoInfo, source)
467
500
  : await adapter.install(pkgRoot, projectRoot, stack, combinedRepoInfo, source)
468
501
  } catch (err) {
@@ -470,8 +503,16 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
470
503
  continue
471
504
  }
472
505
  totalCreated += results.created.length
473
- totalSkipped += results.skipped.length
474
- skippedPaths.push(...results.skipped)
506
+ for (const p of results.skipped) {
507
+ if (createdThisRun.has(resolve(projectRoot, p))) continue
508
+ leftAlone.add(resolve(projectRoot, p))
509
+ skippedPaths.push(p)
510
+ }
511
+ for (const p of results.created) createdThisRun.add(resolve(projectRoot, p))
512
+ for (const abs of [...results.created, ...results.copied, ...results.skipped, ...(results.visited ?? [])]) {
513
+ produced.add(resolve(projectRoot, abs))
514
+ }
515
+ removedByReinit.push(...(results.deleted ?? []))
475
516
  for (const file of results.unreadable ?? []) {
476
517
  noteUnreadable(unreadable, file)
477
518
  }
@@ -484,8 +525,15 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
484
525
  tornRoots.push(...(results.tornRoots ?? []))
485
526
 
486
527
  const managed = adapter.getManagedPaths()
487
- allManagedPaths.framework.push(...managed.framework)
488
- allManagedPaths.customizable.push(...managed.customizable)
528
+ // Deduplicated like `merged` below: every target declares `.opencastle/`,
529
+ // so a four-target manifest listed it four times and the first `sync`
530
+ // rewrote the manifest to say it once.
531
+ for (const f of managed.framework) {
532
+ if (!allManagedPaths.framework.includes(f)) allManagedPaths.framework.push(f)
533
+ }
534
+ for (const f of managed.customizable) {
535
+ if (!allManagedPaths.customizable.includes(f)) allManagedPaths.customizable.push(f)
536
+ }
489
537
  // Deduplicated: opencode and codex share AGENTS.md, so a per-adapter push
490
538
  // listed it twice — "Merged into your existing …, AGENTS.md, AGENTS.md".
491
539
  for (const m of managed.merged ?? []) {
@@ -493,6 +541,8 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
493
541
  }
494
542
  }
495
543
 
544
+ totalSkipped = leftAlone.size
545
+
496
546
  // If all files were skipped (orphaned install — no manifest but files exist).
497
547
  //
498
548
  // Or if a release before the `oc:` namespace left its commands here. The
@@ -546,6 +596,10 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
546
596
  // opposite of what happened, on the one path that exists to overwrite.
547
597
  totalCreated += results.created.length + results.copied.length
548
598
  totalSkipped += results.skipped.length
599
+ for (const abs of [...results.created, ...results.copied, ...results.skipped, ...(results.visited ?? [])]) {
600
+ produced.add(resolve(projectRoot, abs))
601
+ }
602
+ removedByReinit.push(...(results.deleted ?? []))
549
603
  for (const file of results.unreadable ?? []) {
550
604
  noteUnreadable(unreadable, file)
551
605
  }
@@ -571,7 +625,15 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
571
625
  if (existsSync(custSrcDir)) {
572
626
  const custDestDir = resolve(projectRoot, '.opencastle')
573
627
  const custTransform = getCustomizationsTransform(stack)
574
- const sub = await copyDir(custSrcDir, custDestDir, { transform: custTransform })
628
+ // Over an existing `.opencastle/`, the templates bootstrap prunes or renames
629
+ // on the first run — `stack/`, the tracker config — stay as that run left
630
+ // them. Copying them again put back every one it had removed: a project
631
+ // with no CMS got `cms-config.md` and `sanity-config.md` on its second init.
632
+ const prunedOnce = (rel: string) => rel === 'stack' || rel.startsWith('stack/') || rel === 'project/tracker-config.md'
633
+ const sub = await copyDir(custSrcDir, custDestDir, {
634
+ transform: custTransform,
635
+ filter: (_name, srcPath) => !(alreadyScaffolded && prunedOnce(relative(custSrcDir, srcPath).split('\\').join('/'))),
636
+ })
575
637
  totalCreated += sub.created.length
576
638
  totalSkipped += sub.skipped.length
577
639
  }
@@ -696,6 +758,36 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
696
758
  console.log(` ${c.dim('→')} Left ${totalSkipped} existing ${noun} untouched`)
697
759
  }
698
760
 
761
+ // Re-running `init` recompiles with `sync`'s sweep, and said nothing of what
762
+ // the sweep removed; `sync` names every file.
763
+ const removed = [...new Set(removedByReinit)].filter((rel) => !existsSync(resolve(projectRoot, rel)))
764
+ if (removed.length > 0) {
765
+ console.log(`\n ${c.yellow('!')} Removed ${removed.length} file(s) no longer produced by any source:\n`)
766
+ for (const rel of removed.slice(0, 10)) console.log(` ${c.dim(rel)}`)
767
+ if (removed.length > 10) console.log(` ${c.dim(`… and ${removed.length - 10} more`)}`)
768
+ }
769
+
770
+ // Files of the user's in a directory a target now owns. Left in place, so the
771
+ // assistant keeps reading them today — but `sync` removes them, and
772
+ // `sync --check` fails on them, so say so now rather than at the deletion.
773
+ const theirs = [...inGeneratedDirs]
774
+ .filter((abs) => !produced.has(abs) && existsSync(abs))
775
+ .map((abs) => relative(projectRoot, abs).split('\\').join('/'))
776
+ if (theirs.length > 0) {
777
+ const one = theirs.length === 1
778
+ const it = one ? 'it' : 'them'
779
+ console.log(
780
+ `\n ${c.yellow('⚠')} ${theirs.length} ${one ? 'file of yours is' : 'files of yours are'} in a directory OpenCastle generates:\n`,
781
+ )
782
+ for (const rel of theirs.slice(0, 10)) console.log(` ${c.bold(rel)}`)
783
+ if (theirs.length > 10) console.log(` ${c.dim(`… and ${theirs.length - 10} more`)}`)
784
+ console.log(`\n ${c.dim(`The next sync removes ${it}; until then sync --check reports ${it}.`)}`)
785
+ console.log(
786
+ ` ${c.dim(`To keep ${it}, move ${it} into .opencastle/ (instructions/, skills/<name>/ or agents/),`)}`,
787
+ )
788
+ console.log(` ${c.dim('and the next sync compiles it for every assistant.')}`)
789
+ }
790
+
699
791
  // Name the root files that already existed and were merged rather than replaced.
700
792
  const mergedRoots: string[] = []
701
793
  for (const p of allManagedPaths.merged) {
@@ -865,8 +957,13 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
865
957
  `${c.cyan(`/${COMMAND_NAMESPACE}:bootstrap-customizations`)} first on an existing codebase`,
866
958
  )
867
959
  }
960
+ // Everything, not only `.opencastle/`: the generated config is committed on
961
+ // purpose (the `.gitignore` block says so, and `doctor` checks it), and this
962
+ // line was the one place that told people to commit the sources alone.
963
+ step++
964
+ console.log(` ${step}. Commit what this wrote, .opencastle/ included — teammates get the same setup on clone`)
868
965
  step++
869
- console.log(` ${step}. Commit the .opencastle/ folder to your repository`)
966
+ console.log(` ${step}. ${c.cyan('opencastle ci')} — fail a pull request whose generated config no longer matches`)
870
967
 
871
968
  // Name the assistants not yet being compiled for — the reason to come back.
872
969
  const configured = new Set(ides)
package/src/cli/layers.ts CHANGED
@@ -327,10 +327,19 @@ export function filesUnder(root: string, within?: string[], onSkip?: (abs: strin
327
327
  return out
328
328
  }
329
329
 
330
- /** A digest of what a layer contributes: its config and its content directories. */
331
- function layerIntegrity(root: string): string {
330
+ /**
331
+ * A digest of what a layer contributes: its config and its content directories.
332
+ *
333
+ * An Agent Plugin keeps only its skills at the root; its servers are in
334
+ * `mcp.json` and everything else in `dev.opencastle/`. Hashing the root alone
335
+ * left all of that out, so an instruction edited without a version bump moved
336
+ * nothing in the lock and `review` had nothing to say about it.
337
+ */
338
+ function layerIntegrity(root: string, extensionRoot?: string): string {
332
339
  const hash = createHash('sha256')
333
- const parts = [LAYER_CONFIG_FILE, ...CONTENT_KINDS.map((k) => LAYER_DIR[k])]
340
+ const own = [LAYER_CONFIG_FILE, ...CONTENT_KINDS.map((k) => LAYER_DIR[k])]
341
+ const ext = extensionRoot ? relative(root, extensionRoot).split(sep).join('/') : null
342
+ const parts = ext ? [...own, 'plugin.json', 'mcp.json', ...own.map((p) => `${ext}/${p}`)] : own
334
343
  for (const part of parts) {
335
344
  const abs = join(root, part)
336
345
  if (!existsSync(abs)) continue
@@ -525,7 +534,7 @@ function loadExtends(
525
534
  for (const inner of plugin.config.extends ?? []) {
526
535
  loadExtends(inner, plugin.extensionRoot, plugin.configFile, [...chain, real], ctx)
527
536
  }
528
- ctx.layers.push({ id, kind: 'baseline', root, version: version ?? plugin.version, integrity: layerIntegrity(root), ...plugin })
537
+ ctx.layers.push({ id, kind: 'baseline', root, version: version ?? plugin.version, integrity: layerIntegrity(root, plugin.extensionRoot), ...plugin })
529
538
  return
530
539
  }
531
540
 
package/src/cli/lesson.ts CHANGED
@@ -60,12 +60,13 @@ const HELP = `
60
60
  --category terminal \\
61
61
  --severity medium \\
62
62
  --problem "Unquoted variables break on paths with spaces" \\
63
- --wrong 'rm -rf \\$DIR/old' \\
64
- --correct 'rm -rf "\\$DIR/old"' \\
63
+ --wrong 'rm -rf $DIR/old' \\
64
+ --correct 'rm -rf "$DIR/old"' \\
65
65
  --cite scripts/clean.sh:12
66
66
 
67
67
  opencastle lesson verify 2026-10-02-always-quote-shell-variables
68
- opencastle lesson archive LES-004 --into .opencastle/skills/git-workflow/SKILL.md
68
+ opencastle lesson archive 2026-10-02-always-quote-shell-variables \\
69
+ --into .opencastle/skills/git-workflow/SKILL.md
69
70
  `
70
71
 
71
72
  /** The `.opencastle/` this lesson belongs to: the override, or the nearest one up from here. */
@@ -219,7 +220,7 @@ async function add(dir: string, projectRoot: string, p: Parsed): Promise<void> {
219
220
 
220
221
  async function verify(dir: string, projectRoot: string, p: Parsed): Promise<void> {
221
222
  const [ref] = p.positional
222
- if (!ref) fail('verify needs the id of a lesson, e.g. opencastle lesson verify LES-004')
223
+ if (!ref) fail('verify needs the id of a lesson, e.g. opencastle lesson verify 2026-10-02-always-quote-shell-variables')
223
224
  checkCitations(projectRoot, p.cites)
224
225
  if (!p.dryRun) reindex(dir)
225
226
  const { lessons } = readLessons(dir)
@@ -240,7 +241,7 @@ async function verify(dir: string, projectRoot: string, p: Parsed): Promise<void
240
241
  async function archive(dir: string, projectRoot: string, p: Parsed): Promise<void> {
241
242
  const [ref] = p.positional
242
243
  const into = p.values.get('--into')
243
- if (!ref) fail('archive needs the id of a lesson, e.g. opencastle lesson archive LES-004 --into <file>')
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
245
  if (!into) fail('archive needs --into <file>: the skill or instruction file the lesson was merged into')
245
246
  const problem = citationProblem(projectRoot, into)
246
247
  if (problem) fail(`--into: ${problem}`)
@@ -49,8 +49,10 @@ export const ROOT_INSTRUCTION_FILES = [
49
49
  */
50
50
  const SUPERSEDED_FRAMEWORK: Record<string, string> = {
51
51
  '.claude/commands/': `.claude/${CLAUDE_COMMANDS_DIR}/`,
52
- // Codex never read `.codex/skills/`; its skills moved to the shared location.
52
+ // Codex never read `.codex/skills/`; its skills moved to the shared location,
53
+ // and OpenCode's followed.
53
54
  '.codex/skills/': '.agents/skills/',
55
+ '.opencode/skills/': '.agents/skills/',
54
56
  }
55
57
 
56
58
  function unique(values: string[]): string[] {