opencastle 0.38.2 → 1.1.0

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 (299) hide show
  1. package/README.md +89 -4
  2. package/bin/cli.mjs +20 -3
  3. package/dist/cli/adapters/antigravity.d.ts +1 -1
  4. package/dist/cli/adapters/antigravity.d.ts.map +1 -1
  5. package/dist/cli/adapters/claude-code.d.ts +8 -4
  6. package/dist/cli/adapters/claude-code.d.ts.map +1 -1
  7. package/dist/cli/adapters/claude-code.js +13 -7
  8. package/dist/cli/adapters/claude-code.js.map +1 -1
  9. package/dist/cli/adapters/codex.d.ts +1 -1
  10. package/dist/cli/adapters/codex.d.ts.map +1 -1
  11. package/dist/cli/adapters/cursor.d.ts +1 -1
  12. package/dist/cli/adapters/cursor.d.ts.map +1 -1
  13. package/dist/cli/adapters/opencode.d.ts +1 -1
  14. package/dist/cli/adapters/opencode.d.ts.map +1 -1
  15. package/dist/cli/adapters/rules-dir-base.d.ts +3 -2
  16. package/dist/cli/adapters/rules-dir-base.d.ts.map +1 -1
  17. package/dist/cli/adapters/rules-dir-base.js +13 -25
  18. package/dist/cli/adapters/rules-dir-base.js.map +1 -1
  19. package/dist/cli/adapters/single-file-base.d.ts +8 -1
  20. package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
  21. package/dist/cli/adapters/single-file-base.js +43 -46
  22. package/dist/cli/adapters/single-file-base.js.map +1 -1
  23. package/dist/cli/adapters/vscode.d.ts +14 -3
  24. package/dist/cli/adapters/vscode.d.ts.map +1 -1
  25. package/dist/cli/adapters/vscode.js +63 -75
  26. package/dist/cli/adapters/vscode.js.map +1 -1
  27. package/dist/cli/adapters/windsurf.d.ts +1 -1
  28. package/dist/cli/adapters/windsurf.d.ts.map +1 -1
  29. package/dist/cli/baseline.d.ts +3 -0
  30. package/dist/cli/baseline.d.ts.map +1 -0
  31. package/dist/cli/baseline.js +280 -0
  32. package/dist/cli/baseline.js.map +1 -0
  33. package/dist/cli/ci.d.ts +18 -0
  34. package/dist/cli/ci.d.ts.map +1 -0
  35. package/dist/cli/ci.js +279 -0
  36. package/dist/cli/ci.js.map +1 -0
  37. package/dist/cli/command-namespace.d.ts +91 -0
  38. package/dist/cli/command-namespace.d.ts.map +1 -0
  39. package/dist/cli/command-namespace.js +218 -0
  40. package/dist/cli/command-namespace.js.map +1 -0
  41. package/dist/cli/command-namespace.test.d.ts +2 -0
  42. package/dist/cli/command-namespace.test.d.ts.map +1 -0
  43. package/dist/cli/command-namespace.test.js +356 -0
  44. package/dist/cli/command-namespace.test.js.map +1 -0
  45. package/dist/cli/copy.d.ts +1 -1
  46. package/dist/cli/copy.d.ts.map +1 -1
  47. package/dist/cli/copy.js +3 -2
  48. package/dist/cli/copy.js.map +1 -1
  49. package/dist/cli/dispatcher.test.js +2 -2
  50. package/dist/cli/dispatcher.test.js.map +1 -1
  51. package/dist/cli/docs-accuracy.test.js +5 -0
  52. package/dist/cli/docs-accuracy.test.js.map +1 -1
  53. package/dist/cli/doctor.d.ts +3 -3
  54. package/dist/cli/doctor.d.ts.map +1 -1
  55. package/dist/cli/doctor.js +66 -9
  56. package/dist/cli/doctor.js.map +1 -1
  57. package/dist/cli/doctor.test.js +2 -2
  58. package/dist/cli/doctor.test.js.map +1 -1
  59. package/dist/cli/explain.d.ts +3 -0
  60. package/dist/cli/explain.d.ts.map +1 -0
  61. package/dist/cli/explain.js +222 -0
  62. package/dist/cli/explain.js.map +1 -0
  63. package/dist/cli/fleet.d.ts +30 -0
  64. package/dist/cli/fleet.d.ts.map +1 -0
  65. package/dist/cli/fleet.js +149 -0
  66. package/dist/cli/fleet.js.map +1 -0
  67. package/dist/cli/github-report.d.ts +49 -0
  68. package/dist/cli/github-report.d.ts.map +1 -0
  69. package/dist/cli/github-report.js +161 -0
  70. package/dist/cli/github-report.js.map +1 -0
  71. package/dist/cli/github-report.test.d.ts +2 -0
  72. package/dist/cli/github-report.test.d.ts.map +1 -0
  73. package/dist/cli/github-report.test.js +146 -0
  74. package/dist/cli/github-report.test.js.map +1 -0
  75. package/dist/cli/init.d.ts.map +1 -1
  76. package/dist/cli/init.js +171 -96
  77. package/dist/cli/init.js.map +1 -1
  78. package/dist/cli/init.test.js +35 -29
  79. package/dist/cli/init.test.js.map +1 -1
  80. package/dist/cli/layers.d.ts +152 -0
  81. package/dist/cli/layers.d.ts.map +1 -0
  82. package/dist/cli/layers.js +932 -0
  83. package/dist/cli/layers.js.map +1 -0
  84. package/dist/cli/layers.test.d.ts +2 -0
  85. package/dist/cli/layers.test.d.ts.map +1 -0
  86. package/dist/cli/layers.test.js +483 -0
  87. package/dist/cli/layers.test.js.map +1 -0
  88. package/dist/cli/lock.d.ts +130 -0
  89. package/dist/cli/lock.d.ts.map +1 -0
  90. package/dist/cli/lock.js +320 -0
  91. package/dist/cli/lock.js.map +1 -0
  92. package/dist/cli/managed-paths.d.ts +18 -1
  93. package/dist/cli/managed-paths.d.ts.map +1 -1
  94. package/dist/cli/managed-paths.js +72 -2
  95. package/dist/cli/managed-paths.js.map +1 -1
  96. package/dist/cli/manifest.d.ts.map +1 -1
  97. package/dist/cli/manifest.js +2 -0
  98. package/dist/cli/manifest.js.map +1 -1
  99. package/dist/cli/mcp-audit.d.ts +164 -0
  100. package/dist/cli/mcp-audit.d.ts.map +1 -0
  101. package/dist/cli/mcp-audit.js +504 -0
  102. package/dist/cli/mcp-audit.js.map +1 -0
  103. package/dist/cli/mcp-audit.test.d.ts +2 -0
  104. package/dist/cli/mcp-audit.test.d.ts.map +1 -0
  105. package/dist/cli/mcp-audit.test.js +215 -0
  106. package/dist/cli/mcp-audit.test.js.map +1 -0
  107. package/dist/cli/mcp-upgrade.test.d.ts +2 -0
  108. package/dist/cli/mcp-upgrade.test.d.ts.map +1 -0
  109. package/dist/cli/mcp-upgrade.test.js +118 -0
  110. package/dist/cli/mcp-upgrade.test.js.map +1 -0
  111. package/dist/cli/mcp.d.ts +74 -5
  112. package/dist/cli/mcp.d.ts.map +1 -1
  113. package/dist/cli/mcp.js +340 -32
  114. package/dist/cli/mcp.js.map +1 -1
  115. package/dist/cli/policy.d.ts +58 -0
  116. package/dist/cli/policy.d.ts.map +1 -0
  117. package/dist/cli/policy.js +194 -0
  118. package/dist/cli/policy.js.map +1 -0
  119. package/dist/cli/publish-workflow.test.js +55 -1
  120. package/dist/cli/publish-workflow.test.js.map +1 -1
  121. package/dist/cli/remove.d.ts.map +1 -1
  122. package/dist/cli/remove.js +25 -6
  123. package/dist/cli/remove.js.map +1 -1
  124. package/dist/cli/review.d.ts +25 -0
  125. package/dist/cli/review.d.ts.map +1 -0
  126. package/dist/cli/review.js +437 -0
  127. package/dist/cli/review.js.map +1 -0
  128. package/dist/cli/status.d.ts +2 -0
  129. package/dist/cli/status.d.ts.map +1 -1
  130. package/dist/cli/status.js +25 -4
  131. package/dist/cli/status.js.map +1 -1
  132. package/dist/cli/status.test.js +5 -3
  133. package/dist/cli/status.test.js.map +1 -1
  134. package/dist/cli/sync-check.d.ts +16 -1
  135. package/dist/cli/sync-check.d.ts.map +1 -1
  136. package/dist/cli/sync-check.js +241 -17
  137. package/dist/cli/sync-check.js.map +1 -1
  138. package/dist/cli/sync-check.test.js +14 -8
  139. package/dist/cli/sync-check.test.js.map +1 -1
  140. package/dist/cli/sync.d.ts.map +1 -1
  141. package/dist/cli/sync.js +2 -0
  142. package/dist/cli/sync.js.map +1 -1
  143. package/dist/cli/team-ci.test.d.ts +2 -0
  144. package/dist/cli/team-ci.test.d.ts.map +1 -0
  145. package/dist/cli/team-ci.test.js +169 -0
  146. package/dist/cli/team-ci.test.js.map +1 -0
  147. package/dist/cli/team-commands.test.d.ts +2 -0
  148. package/dist/cli/team-commands.test.d.ts.map +1 -0
  149. package/dist/cli/team-commands.test.js +233 -0
  150. package/dist/cli/team-commands.test.js.map +1 -0
  151. package/dist/cli/team-config.d.ts +88 -0
  152. package/dist/cli/team-config.d.ts.map +1 -0
  153. package/dist/cli/team-config.js +261 -0
  154. package/dist/cli/team-config.js.map +1 -0
  155. package/dist/cli/team-health.d.ts +49 -0
  156. package/dist/cli/team-health.d.ts.map +1 -0
  157. package/dist/cli/team-health.js +205 -0
  158. package/dist/cli/team-health.js.map +1 -0
  159. package/dist/cli/team-sources.test.d.ts +2 -0
  160. package/dist/cli/team-sources.test.d.ts.map +1 -0
  161. package/dist/cli/team-sources.test.js +542 -0
  162. package/dist/cli/team-sources.test.js.map +1 -0
  163. package/dist/cli/types.d.ts +48 -2
  164. package/dist/cli/types.d.ts.map +1 -1
  165. package/dist/cli/types.js.map +1 -1
  166. package/dist/cli/update.d.ts.map +1 -1
  167. package/dist/cli/update.js +218 -44
  168. package/dist/cli/update.js.map +1 -1
  169. package/dist/cli/version-range.d.ts +24 -0
  170. package/dist/cli/version-range.d.ts.map +1 -0
  171. package/dist/cli/version-range.js +157 -0
  172. package/dist/cli/version-range.js.map +1 -0
  173. package/dist/cli/website-plugins.test.d.ts +2 -0
  174. package/dist/cli/website-plugins.test.d.ts.map +1 -0
  175. package/dist/cli/website-plugins.test.js +34 -0
  176. package/dist/cli/website-plugins.test.js.map +1 -0
  177. package/dist/orchestrator/plugins/chrome-devtools/config.d.ts.map +1 -1
  178. package/dist/orchestrator/plugins/chrome-devtools/config.js +11 -1
  179. package/dist/orchestrator/plugins/chrome-devtools/config.js.map +1 -1
  180. package/dist/orchestrator/plugins/contentful/config.d.ts.map +1 -1
  181. package/dist/orchestrator/plugins/contentful/config.js +11 -1
  182. package/dist/orchestrator/plugins/contentful/config.js.map +1 -1
  183. package/dist/orchestrator/plugins/convex/config.d.ts.map +1 -1
  184. package/dist/orchestrator/plugins/convex/config.js +11 -1
  185. package/dist/orchestrator/plugins/convex/config.js.map +1 -1
  186. package/dist/orchestrator/plugins/coolify/config.d.ts.map +1 -1
  187. package/dist/orchestrator/plugins/coolify/config.js +14 -1
  188. package/dist/orchestrator/plugins/coolify/config.js.map +1 -1
  189. package/dist/orchestrator/plugins/figma/config.d.ts.map +1 -1
  190. package/dist/orchestrator/plugins/figma/config.js +24 -13
  191. package/dist/orchestrator/plugins/figma/config.js.map +1 -1
  192. package/dist/orchestrator/plugins/linear/config.d.ts.map +1 -1
  193. package/dist/orchestrator/plugins/linear/config.js +27 -17
  194. package/dist/orchestrator/plugins/linear/config.js.map +1 -1
  195. package/dist/orchestrator/plugins/netlify/config.d.ts.map +1 -1
  196. package/dist/orchestrator/plugins/netlify/config.js +23 -9
  197. package/dist/orchestrator/plugins/netlify/config.js.map +1 -1
  198. package/dist/orchestrator/plugins/nextjs/config.d.ts.map +1 -1
  199. package/dist/orchestrator/plugins/nextjs/config.js +11 -1
  200. package/dist/orchestrator/plugins/nextjs/config.js.map +1 -1
  201. package/dist/orchestrator/plugins/nx/config.d.ts.map +1 -1
  202. package/dist/orchestrator/plugins/nx/config.js +11 -1
  203. package/dist/orchestrator/plugins/nx/config.js.map +1 -1
  204. package/dist/orchestrator/plugins/pins.test.d.ts +2 -0
  205. package/dist/orchestrator/plugins/pins.test.d.ts.map +1 -0
  206. package/dist/orchestrator/plugins/pins.test.js +78 -0
  207. package/dist/orchestrator/plugins/pins.test.js.map +1 -0
  208. package/dist/orchestrator/plugins/playwright/config.d.ts.map +1 -1
  209. package/dist/orchestrator/plugins/playwright/config.js +11 -1
  210. package/dist/orchestrator/plugins/playwright/config.js.map +1 -1
  211. package/dist/orchestrator/plugins/prisma/config.d.ts.map +1 -1
  212. package/dist/orchestrator/plugins/prisma/config.js +17 -2
  213. package/dist/orchestrator/plugins/prisma/config.js.map +1 -1
  214. package/dist/orchestrator/plugins/resend/config.d.ts.map +1 -1
  215. package/dist/orchestrator/plugins/resend/config.js +17 -1
  216. package/dist/orchestrator/plugins/resend/config.js.map +1 -1
  217. package/dist/orchestrator/plugins/sentry/config.d.ts.map +1 -1
  218. package/dist/orchestrator/plugins/sentry/config.js +13 -1
  219. package/dist/orchestrator/plugins/sentry/config.js.map +1 -1
  220. package/dist/orchestrator/plugins/slack/config.d.ts.map +1 -1
  221. package/dist/orchestrator/plugins/slack/config.js +20 -1
  222. package/dist/orchestrator/plugins/slack/config.js.map +1 -1
  223. package/dist/orchestrator/plugins/strapi/config.d.ts.map +1 -1
  224. package/dist/orchestrator/plugins/strapi/config.js +11 -1
  225. package/dist/orchestrator/plugins/strapi/config.js.map +1 -1
  226. package/dist/orchestrator/plugins/trello/config.d.ts.map +1 -1
  227. package/dist/orchestrator/plugins/trello/config.js +21 -1
  228. package/dist/orchestrator/plugins/trello/config.js.map +1 -1
  229. package/dist/orchestrator/plugins/types.d.ts +22 -0
  230. package/dist/orchestrator/plugins/types.d.ts.map +1 -1
  231. package/package.json +4 -2
  232. package/src/cli/adapters/claude-code.ts +13 -7
  233. package/src/cli/adapters/rules-dir-base.ts +23 -44
  234. package/src/cli/adapters/single-file-base.ts +65 -50
  235. package/src/cli/adapters/vscode.ts +75 -77
  236. package/src/cli/baseline.ts +289 -0
  237. package/src/cli/ci.ts +289 -0
  238. package/src/cli/command-namespace.test.ts +417 -0
  239. package/src/cli/command-namespace.ts +222 -0
  240. package/src/cli/copy.ts +6 -2
  241. package/src/cli/dispatcher.test.ts +2 -2
  242. package/src/cli/docs-accuracy.test.ts +5 -0
  243. package/src/cli/doctor.test.ts +2 -2
  244. package/src/cli/doctor.ts +92 -6
  245. package/src/cli/explain.ts +222 -0
  246. package/src/cli/fleet.ts +176 -0
  247. package/src/cli/github-report.test.ts +158 -0
  248. package/src/cli/github-report.ts +179 -0
  249. package/src/cli/init.test.ts +36 -31
  250. package/src/cli/init.ts +174 -96
  251. package/src/cli/layers.test.ts +525 -0
  252. package/src/cli/layers.ts +1089 -0
  253. package/src/cli/lock.ts +395 -0
  254. package/src/cli/managed-paths.ts +73 -3
  255. package/src/cli/manifest.ts +2 -0
  256. package/src/cli/mcp-audit.test.ts +259 -0
  257. package/src/cli/mcp-audit.ts +619 -0
  258. package/src/cli/mcp-upgrade.test.ts +135 -0
  259. package/src/cli/mcp.ts +373 -34
  260. package/src/cli/policy.ts +207 -0
  261. package/src/cli/publish-workflow.test.ts +60 -1
  262. package/src/cli/remove.ts +28 -6
  263. package/src/cli/review.ts +457 -0
  264. package/src/cli/status.test.ts +5 -3
  265. package/src/cli/status.ts +29 -4
  266. package/src/cli/sync-check.test.ts +16 -8
  267. package/src/cli/sync-check.ts +264 -17
  268. package/src/cli/sync.ts +2 -0
  269. package/src/cli/team-ci.test.ts +195 -0
  270. package/src/cli/team-commands.test.ts +253 -0
  271. package/src/cli/team-config.ts +289 -0
  272. package/src/cli/team-health.ts +234 -0
  273. package/src/cli/team-sources.test.ts +578 -0
  274. package/src/cli/types.ts +51 -1
  275. package/src/cli/update.ts +229 -44
  276. package/src/cli/version-range.ts +150 -0
  277. package/src/cli/website-plugins.test.ts +41 -0
  278. package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
  279. package/src/orchestrator/plugins/chrome-devtools/config.ts +11 -1
  280. package/src/orchestrator/plugins/contentful/config.ts +11 -1
  281. package/src/orchestrator/plugins/convex/config.ts +11 -1
  282. package/src/orchestrator/plugins/coolify/config.ts +14 -1
  283. package/src/orchestrator/plugins/figma/SKILL.md +18 -14
  284. package/src/orchestrator/plugins/figma/config.ts +24 -13
  285. package/src/orchestrator/plugins/linear/SKILL.md +6 -14
  286. package/src/orchestrator/plugins/linear/config.ts +27 -17
  287. package/src/orchestrator/plugins/netlify/config.ts +23 -9
  288. package/src/orchestrator/plugins/nextjs/config.ts +11 -1
  289. package/src/orchestrator/plugins/nx/config.ts +11 -1
  290. package/src/orchestrator/plugins/pins.test.ts +80 -0
  291. package/src/orchestrator/plugins/playwright/config.ts +11 -1
  292. package/src/orchestrator/plugins/prisma/config.ts +17 -2
  293. package/src/orchestrator/plugins/resend/config.ts +17 -1
  294. package/src/orchestrator/plugins/sentry/config.ts +13 -1
  295. package/src/orchestrator/plugins/slack/config.ts +20 -1
  296. package/src/orchestrator/plugins/strapi/config.ts +11 -1
  297. package/src/orchestrator/plugins/trello/config.ts +21 -1
  298. package/src/orchestrator/plugins/types.ts +24 -0
  299. package/src/orchestrator/prompts/bootstrap-customizations.prompt.md +4 -4
@@ -0,0 +1,457 @@
1
+ import { execFileSync } from 'node:child_process'
2
+ import { appendFileSync, existsSync, readFileSync } from 'node:fs'
3
+ import { resolve } from 'node:path'
4
+ import { readManifest } from './manifest.js'
5
+ import { resolveStack } from './stack-config.js'
6
+ import { resolveSources, materialize, hasErrors, formatIssues, refuseOlderCli } from './layers.js'
7
+ import { buildLock, parseLock, serializeLock, LOCK_REL, type Lock, type LockServer, priorTeam } from './lock.js'
8
+ import { c } from './prompt.js'
9
+ import type { CliContext } from './types.js'
10
+
11
+ /**
12
+ * `opencastle review`: what a change to the team's AI config *means*.
13
+ *
14
+ * One edit to a baseline regenerates dozens of files in seven formats. The diff
15
+ * a reviewer is shown is that regeneration, and nobody reads a hundred lines of
16
+ * generated Markdown to find the one line that matters — the new MCP server
17
+ * every developer's agent can now start with their credentials, or the rule
18
+ * that quietly stopped applying. This reads the lock at the base and at the
19
+ * head and says, in sentences, what every assistant gains, loses and now does
20
+ * differently, with what deserves a careful look marked as such.
21
+ */
22
+
23
+ const HELP = `
24
+ opencastle review [options]
25
+
26
+ Explain what a change to the AI assistant config does: which skills, agents,
27
+ instructions and MCP servers every assistant gains, loses or gets changed,
28
+ which baselines moved, what the team's policy now allows, and how much more
29
+ context every assistant loads. Reads .opencastle/lock.json at the base and
30
+ compares it with what the current sources compile to.
31
+
32
+ Options:
33
+ --base <ref> What to compare against (default: HEAD; on a GitHub Actions
34
+ pull request, origin/<base branch>)
35
+ --markdown Print Markdown, e.g. for a pull request comment
36
+ --json Machine-readable output
37
+ --help, -h Show this help
38
+
39
+ On GitHub Actions the Markdown is also added to the job summary.
40
+ `
41
+
42
+ export type Attention = 'review' | 'info'
43
+
44
+ export interface ReviewLine {
45
+ /** Grouping for rendering. */
46
+ section: 'layers' | 'targets' | 'content' | 'mcp' | 'policy' | 'context'
47
+ text: string
48
+ /** `review` marks what a reviewer should look at closely. */
49
+ level: Attention
50
+ }
51
+
52
+ export interface ReviewReport {
53
+ base: string
54
+ firstLock: boolean
55
+ lines: ReviewLine[]
56
+ /** Set when the committed lock is not what the sources compile to. */
57
+ staleLock?: boolean
58
+ }
59
+
60
+ const KIND_LABEL: Record<string, [string, string]> = {
61
+ skills: ['skill', 'skills'],
62
+ agents: ['agent', 'agents'],
63
+ instructions: ['always-loaded instruction', 'always-loaded instructions'],
64
+ prompts: ['prompt', 'prompts'],
65
+ workflows: ['workflow', 'workflows'],
66
+ }
67
+
68
+ function splitRef(ref: string): [string, string] {
69
+ const at = ref.indexOf('/')
70
+ return [ref.slice(0, at), ref.slice(at + 1)]
71
+ }
72
+
73
+ function list(items: string[]): string {
74
+ if (items.length <= 1) return items.join('')
75
+ return `${items.slice(0, -1).join(', ')} and ${items[items.length - 1]}`
76
+ }
77
+
78
+ /** `npx -y pkg@1.2.3` and `npx -y pkg@1.3.0` are the same server, upgraded. */
79
+ function sameServerNewVersion(a: LockServer, b: LockServer): [string, string] | null {
80
+ if (a.transport !== 'stdio' || b.transport !== 'stdio') return null
81
+ const re = /((?:@[^\s/@]+\/)?[^\s@]+)@(\d[^\s]*)/
82
+ const ma = re.exec(a.launch)
83
+ const mb = re.exec(b.launch)
84
+ if (!ma || !mb || ma[1] !== mb[1]) return null
85
+ if (a.launch.replace(ma[0], '') !== b.launch.replace(mb[0], '')) return null
86
+ return [ma[2], mb[2]]
87
+ }
88
+
89
+ function hostOf(url: string): string {
90
+ try {
91
+ return new URL(url.replace(/\$\{[^}]*\}/g, 'x')).host
92
+ } catch {
93
+ return url
94
+ }
95
+ }
96
+
97
+ function describeServer(s: LockServer): string {
98
+ const where = s.transport === 'http' ? `remote, ${hostOf(s.launch)}` : `runs \`${s.launch}\``
99
+ const env = s.env?.length ? `; reads ${s.env.join(', ')}` : ''
100
+ return `${where}${env}`
101
+ }
102
+
103
+ function origin(from: string): string {
104
+ if (from.startsWith('plugin:')) return `the ${from.slice(7)} integration`
105
+ if (from === 'opencastle') return 'OpenCastle'
106
+ return from === 'project' ? 'this project' : from
107
+ }
108
+
109
+ /**
110
+ * A project's first lock, summarised. Listing every item as "new" produced a
111
+ * hundred lines on the upgrade that introduced the lock, with OpenCastle's own
112
+ * instructions flagged for review — noise that trains people to skip the
113
+ * summary. What is worth reading is what is not OpenCastle's.
114
+ */
115
+ function firstLockSummary(head: Lock): ReviewLine[] {
116
+ const lines: ReviewLine[] = []
117
+ const add = (section: ReviewLine['section'], text: string, level: Attention = 'info'): void => {
118
+ lines.push({ section, text, level })
119
+ }
120
+ for (const l of head.layers) {
121
+ if (l.kind === 'baseline') add('layers', `Extends ${l.id}${l.version ? ` ${l.version}` : ''}`, 'review')
122
+ }
123
+ const own = Object.entries(head.content).filter(([, i]) => i.from !== 'opencastle' && !i.from.startsWith('plugin:'))
124
+ for (const [ref, item] of own) {
125
+ const [kind, name] = splitRef(ref)
126
+ add('content', `${KIND_LABEL[kind]?.[0] ?? kind} **${name}** from ${origin(item.from)}`, kind === 'instructions' ? 'review' : 'info')
127
+ }
128
+ const core = Object.keys(head.content).length - own.length
129
+ add('content', own.length > 0 ? `and ${core} item(s) from OpenCastle and its integrations` : `${core} item(s) from OpenCastle and its integrations`)
130
+ for (const [key, s] of Object.entries(head.mcp)) {
131
+ add('mcp', `MCP server **${key}** from ${origin(s.from)} — ${describeServer(s)}`, s.from.startsWith('plugin:') ? 'info' : 'review')
132
+ }
133
+ add('context', `Every assistant loads ~${head.context.tokens} tokens before the task`)
134
+ return lines
135
+ }
136
+
137
+ /** Compare two locks. `base` null means the project had none — its first lock. */
138
+ export function diffLocks(base: Lock | null, head: Lock): ReviewLine[] {
139
+ if (!base) return firstLockSummary(head)
140
+ const lines: ReviewLine[] = []
141
+ const add = (section: ReviewLine['section'], text: string, level: Attention = 'info'): void => {
142
+ lines.push({ section, text, level })
143
+ }
144
+ const b: Lock = base ?? {
145
+ lockfileVersion: head.lockfileVersion,
146
+ opencastle: head.opencastle,
147
+ targets: [],
148
+ integrations: [],
149
+ layers: [],
150
+ content: {},
151
+ mcp: {},
152
+ context: { tokens: 0, instructions: 0, index: 0 },
153
+ }
154
+
155
+ // ── Layers ──────────────────────────────────────────────────
156
+ if (base && b.opencastle !== head.opencastle) add('layers', `OpenCastle ${b.opencastle} → ${head.opencastle}`)
157
+ const bl = new Map(b.layers.map((l) => [l.id, l]))
158
+ const hl = new Map(head.layers.map((l) => [l.id, l]))
159
+ for (const [id, l] of hl) {
160
+ if (l.kind === 'core') continue
161
+ const was = bl.get(id)
162
+ if (!was) {
163
+ if (l.kind === 'baseline') add('layers', `Now extends ${id}${l.version ? ` ${l.version}` : ''}`, 'review')
164
+ continue
165
+ }
166
+ if (was.version !== l.version) add('layers', `${id} ${was.version ?? '?'} → ${l.version ?? '?'}`)
167
+ else if (was.integrity && l.integrity && was.integrity !== l.integrity) {
168
+ add('layers', `${id} changed without a version change — its contents are not what ${l.version ?? 'this version'} was`, 'review')
169
+ }
170
+ }
171
+ for (const [id, l] of bl) {
172
+ if (l.kind === 'baseline' && !hl.has(id)) add('layers', `No longer extends ${id}`, 'review')
173
+ }
174
+
175
+ // ── Targets and integrations ────────────────────────────────
176
+ const gainedT = head.targets.filter((t) => !b.targets.includes(t))
177
+ const lostT = b.targets.filter((t) => !head.targets.includes(t))
178
+ if (base && gainedT.length) add('targets', `Now also compiled for ${list(gainedT)}`)
179
+ if (lostT.length) add('targets', `No longer compiled for ${list(lostT)}`)
180
+ const gainedI = head.integrations.filter((t) => !b.integrations.includes(t))
181
+ const lostI = b.integrations.filter((t) => !head.integrations.includes(t))
182
+ if (gainedI.length) add('targets', `Integrations added: ${list(gainedI)}`)
183
+ if (lostI.length) add('targets', `Integrations removed: ${list(lostI)}`)
184
+
185
+ // ── Content ─────────────────────────────────────────────────
186
+ const excludedNow = head.excluded ?? {}
187
+ const required = new Set(b.policy?.require ?? [])
188
+ for (const [ref, item] of Object.entries(head.content)) {
189
+ const was = b.content[ref]
190
+ const [kind, name] = splitRef(ref)
191
+ const label = KIND_LABEL[kind]?.[0] ?? kind
192
+ if (!was) {
193
+ const desc = item.description ? ` — ${item.description}` : ''
194
+ const tokens = item.tokens ? ` (~${item.tokens} tokens, loaded on every request)` : ''
195
+ add('content', `New ${label} **${name}** from ${origin(item.from)}${tokens}${desc}`, kind === 'instructions' ? 'review' : 'info')
196
+ continue
197
+ }
198
+ if (was.from !== item.from) {
199
+ add(
200
+ 'content',
201
+ `${label} **${name}** now comes from ${origin(item.from)} (was ${origin(was.from)})`,
202
+ required.has(ref) ? 'review' : 'info',
203
+ )
204
+ } else if (was.sha !== item.sha) {
205
+ const delta = item.tokens !== undefined && was.tokens !== undefined && item.tokens !== was.tokens
206
+ ? ` (~${was.tokens} → ~${item.tokens} tokens)`
207
+ : ''
208
+ add('content', `${label} **${name}** changed${delta} — ${origin(item.from)}`, kind === 'instructions' ? 'review' : 'info')
209
+ }
210
+ }
211
+ for (const [ref, was] of Object.entries(b.content)) {
212
+ if (head.content[ref]) continue
213
+ const [kind, name] = splitRef(ref)
214
+ const label = KIND_LABEL[kind]?.[0] ?? kind
215
+ const by = excludedNow[ref]
216
+ add(
217
+ 'content',
218
+ `${label} **${name}** removed${by ? ` — excluded by ${origin(by)}` : ''} (was from ${origin(was.from)})`,
219
+ required.has(ref) ? 'review' : 'info',
220
+ )
221
+ }
222
+
223
+ // ── MCP ─────────────────────────────────────────────────────
224
+ for (const [key, s] of Object.entries(head.mcp)) {
225
+ const was = b.mcp[key]
226
+ if (!was) {
227
+ // Every new server is code an agent runs with a developer's credentials.
228
+ add('mcp', `New MCP server **${key}** from ${origin(s.from)} — ${describeServer(s)}`, 'review')
229
+ continue
230
+ }
231
+ if (was.launch === s.launch && was.transport === s.transport) {
232
+ const bEnv = (was.env ?? []).join(',')
233
+ const hEnv = (s.env ?? []).join(',')
234
+ if (bEnv !== hEnv) add('mcp', `MCP server **${key}** now reads ${s.env?.length ? s.env.join(', ') : 'no variables'}`, 'review')
235
+ else if (was.sha !== s.sha) {
236
+ add('mcp', `MCP server **${key}** has different settings — its environment or headers changed (${origin(s.from)})`, 'review')
237
+ }
238
+ continue
239
+ }
240
+ const bump = sameServerNewVersion(was, s)
241
+ if (bump) add('mcp', `MCP server **${key}**: ${bump[0]} → ${bump[1]}`)
242
+ else add('mcp', `MCP server **${key}** now ${describeServer(s)} (was: ${describeServer(was)})`, 'review')
243
+ }
244
+ for (const [key, was] of Object.entries(b.mcp)) {
245
+ if (head.mcp[key]) continue
246
+ const blocked = head.blocked?.[key]
247
+ add('mcp', `MCP server **${key}** removed${blocked ? ` — ${blocked}` : ''} (was from ${origin(was.from)})`)
248
+ }
249
+
250
+ // ── Policy ──────────────────────────────────────────────────
251
+ // Per layer, because that is how it applies: a server must be on every
252
+ // layer's list. A union of the lists read as "still allowed" after the one
253
+ // list that actually restricted something was dropped.
254
+ const bp = b.policy ?? {}
255
+ const hp = head.policy ?? {}
256
+ const perLayer = (
257
+ before: Record<string, string[]> | undefined,
258
+ after: Record<string, string[]> | undefined,
259
+ what: { noun: string; gone: string; now: string },
260
+ ): void => {
261
+ for (const [by, was] of Object.entries(before ?? {})) {
262
+ const now = after?.[by]
263
+ if (!now) {
264
+ add('policy', `${origin(by)} no longer restricts ${what.gone}`, 'review')
265
+ continue
266
+ }
267
+ const grew = now.filter((x) => !was.includes(x))
268
+ const shrank = was.filter((x) => !now.includes(x))
269
+ if (grew.length) add('policy', `${origin(by)}'s ${what.noun} now also allows ${list(grew)}`, 'review')
270
+ if (shrank.length) add('policy', `${origin(by)}'s ${what.noun} no longer allows ${list(shrank)}`)
271
+ }
272
+ for (const [by, now] of Object.entries(after ?? {})) {
273
+ if (!before?.[by]) add('policy', `${origin(by)} now ${what.now}: ${list(now)}`)
274
+ }
275
+ }
276
+ perLayer(bp.allow, hp.allow, { noun: 'MCP allowlist', gone: 'which MCP servers may run', now: 'allows only these MCP servers' })
277
+ perLayer(bp.remoteHosts, hp.remoteHosts, {
278
+ noun: 'remote host list',
279
+ gone: 'which hosts remote MCP servers may reach',
280
+ now: 'lets remote MCP servers reach only',
281
+ })
282
+ if (bp.requirePinned && !hp.requirePinned) add('policy', 'MCP servers no longer have to be pinned to an exact version', 'review')
283
+ if (!bp.requirePinned && hp.requirePinned) add('policy', `MCP servers must now be pinned (${origin(hp.requirePinned)})`)
284
+ const reqB = new Set(bp.require ?? [])
285
+ const reqH = new Set(hp.require ?? [])
286
+ const unrequired = [...reqB].filter((r) => !reqH.has(r))
287
+ const newlyRequired = [...reqH].filter((r) => !reqB.has(r))
288
+ if (unrequired.length) add('policy', `No longer required: ${list(unrequired)}`, 'review')
289
+ if (newlyRequired.length) add('policy', `Now required: ${list(newlyRequired)}`)
290
+ if (bp.contextBudget !== hp.contextBudget) {
291
+ add('policy', `Context budget ${bp.contextBudget ?? 'none'} → ${hp.contextBudget ?? 'none'} tokens`, hp.contextBudget === undefined ? 'review' : 'info')
292
+ }
293
+
294
+ // ── Context ─────────────────────────────────────────────────
295
+ if (base && b.context.tokens !== head.context.tokens) {
296
+ const pct = b.context.tokens > 0 ? Math.round(((head.context.tokens - b.context.tokens) / b.context.tokens) * 100) : 0
297
+ const over = hp.contextBudget && head.context.tokens > hp.contextBudget ? `, over the ${hp.contextBudget}-token budget` : ''
298
+ add(
299
+ 'context',
300
+ `Every assistant loads ~${head.context.tokens} tokens before the task (was ~${b.context.tokens}, ${pct >= 0 ? '+' : ''}${pct}%${over})`,
301
+ pct > 10 || over ? 'review' : 'info',
302
+ )
303
+ }
304
+ return lines
305
+ }
306
+
307
+ const SECTION_TITLE: Record<ReviewLine['section'], string> = {
308
+ layers: 'Layers',
309
+ targets: 'Targets and integrations',
310
+ content: 'What every assistant reads',
311
+ mcp: 'MCP servers',
312
+ policy: 'Policy',
313
+ context: 'Context',
314
+ }
315
+
316
+ export function reviewMarkdown(report: ReviewReport): string {
317
+ const out: string[] = ['### OpenCastle — what this change does to the AI assistants', '']
318
+ if (report.staleLock) {
319
+ out.push(`> ⚠️ \`${LOCK_REL}\` is not what the sources compile to. Run \`npx opencastle sync\` and commit it.`, '')
320
+ }
321
+ if (report.lines.length === 0) {
322
+ out.push(`No change to what any assistant is given (compared with \`${report.base}\`).`)
323
+ return out.join('\n') + '\n'
324
+ }
325
+ const flagged = report.lines.filter((l) => l.level === 'review').length
326
+ out.push(
327
+ report.firstLock
328
+ ? `First lock for this project (nothing at \`${report.base}\` to compare with).`
329
+ : `Compared with \`${report.base}\`. ${flagged > 0 ? `**${flagged} change(s) marked ⚠️ deserve a careful look.**` : 'Nothing here needs special attention.'}`,
330
+ '',
331
+ )
332
+ for (const section of Object.keys(SECTION_TITLE) as ReviewLine['section'][]) {
333
+ const ls = report.lines.filter((l) => l.section === section)
334
+ if (ls.length === 0) continue
335
+ out.push(`**${SECTION_TITLE[section]}**`, '')
336
+ for (const l of ls) out.push(`- ${l.level === 'review' ? '⚠️ ' : ''}${l.text}`)
337
+ out.push('')
338
+ }
339
+ return out.join('\n')
340
+ }
341
+
342
+ function renderTerminal(report: ReviewReport): void {
343
+ console.log(`\n 🏰 ${c.bold('OpenCastle review')} ${c.dim(`— compared with ${report.base}`)}\n`)
344
+ if (report.staleLock) {
345
+ console.log(` ${c.yellow('!')} ${LOCK_REL} is not what the sources compile to — run ${c.cyan('opencastle sync')}\n`)
346
+ }
347
+ if (report.lines.length === 0) {
348
+ console.log(` ${c.green('✓')} No change to what any assistant is given.\n`)
349
+ return
350
+ }
351
+ for (const section of Object.keys(SECTION_TITLE) as ReviewLine['section'][]) {
352
+ const ls = report.lines.filter((l) => l.section === section)
353
+ if (ls.length === 0) continue
354
+ console.log(` ${c.bold(SECTION_TITLE[section])}`)
355
+ for (const l of ls) {
356
+ const text = l.text.replace(/\*\*([^*]+)\*\*/g, (_m, t: string) => c.bold(t)).replace(/`([^`]+)`/g, (_m, t: string) => c.cyan(t))
357
+ console.log(` ${l.level === 'review' ? c.yellow('⚠') : c.dim('•')} ${text}`)
358
+ }
359
+ console.log('')
360
+ }
361
+ const flagged = report.lines.filter((l) => l.level === 'review').length
362
+ if (flagged > 0) console.log(` ${c.yellow(`${flagged} change(s) deserve a careful look.`)}\n`)
363
+ }
364
+
365
+ /** The lock as committed at `ref`, or null when the project had none there. */
366
+ export function lockAtRef(projectRoot: string, ref: string): Lock | null {
367
+ let prefix: string
368
+ try {
369
+ prefix = execFileSync('git', ['rev-parse', '--show-prefix'], { cwd: projectRoot, encoding: 'utf8' }).trim()
370
+ } catch {
371
+ throw new Error('this is not a git repository, so there is no base to compare with')
372
+ }
373
+ try {
374
+ execFileSync('git', ['rev-parse', '--verify', '--quiet', `${ref}^{commit}`], { cwd: projectRoot, stdio: 'ignore' })
375
+ } catch {
376
+ throw new Error(
377
+ `"${ref}" is not a commit here — in CI, fetch the base branch (actions/checkout with fetch-depth: 0)`,
378
+ )
379
+ }
380
+ try {
381
+ const text = execFileSync('git', ['show', `${ref}:${prefix}${LOCK_REL}`], {
382
+ cwd: projectRoot,
383
+ encoding: 'utf8',
384
+ stdio: ['ignore', 'pipe', 'ignore'],
385
+ })
386
+ return parseLock(text)
387
+ } catch {
388
+ return null
389
+ }
390
+ }
391
+
392
+ /** What the sources compile to now, as a lock; or the committed one if they do not resolve. */
393
+ async function headLock(pkgRoot: string, projectRoot: string): Promise<{ lock: Lock; stale: boolean }> {
394
+ const manifest = await readManifest(projectRoot)
395
+ if (!manifest) throw new Error('OpenCastle is not set up here — run opencastle init')
396
+ refuseOlderCli(pkgRoot, manifest.version)
397
+ const ides = (manifest.ides?.length ? manifest.ides : [manifest.ide]).filter(Boolean)
398
+ const stack = resolveStack({ ...manifest, ides })
399
+ const resolved = resolveSources({ pkgRoot, projectRoot, stack, repoInfo: manifest.repoInfo })
400
+ if (hasErrors(resolved)) {
401
+ throw new Error(`the team's sources do not resolve:\n${formatIssues(resolved.issues.filter((i) => i.level === 'error')).join('\n')}`)
402
+ }
403
+ const source = materialize(resolved, pkgRoot, ...priorTeam(projectRoot))
404
+ try {
405
+ const lock = buildLock(source, { ides, stack, repoInfo: manifest.repoInfo })
406
+ const committed = resolve(projectRoot, LOCK_REL)
407
+ const stale = !existsSync(committed) || readFileSync(committed, 'utf8').replace(/\r\n/g, '\n') !== serializeLock(lock)
408
+ return { lock, stale }
409
+ } finally {
410
+ source.dispose()
411
+ }
412
+ }
413
+
414
+ export function defaultBase(env: NodeJS.ProcessEnv = process.env): string {
415
+ if (env.GITHUB_ACTIONS === 'true' && env.GITHUB_BASE_REF) return `origin/${env.GITHUB_BASE_REF}`
416
+ return 'HEAD'
417
+ }
418
+
419
+ export default async function review({ pkgRoot, args }: CliContext): Promise<void> {
420
+ if (args.includes('--help') || args.includes('-h')) {
421
+ console.log(HELP)
422
+ return
423
+ }
424
+ const projectRoot = process.cwd()
425
+ const at = args.indexOf('--base')
426
+ if (at !== -1 && (!args[at + 1] || args[at + 1].startsWith('-'))) {
427
+ console.error(` ${c.red('✗')} --base needs a git ref, e.g. --base origin/main`)
428
+ process.exit(1)
429
+ }
430
+ const base = at !== -1 ? args[at + 1] : defaultBase()
431
+
432
+ let report: ReviewReport
433
+ try {
434
+ const before = lockAtRef(projectRoot, base)
435
+ const { lock, stale } = await headLock(pkgRoot, projectRoot)
436
+ report = { base, firstLock: before === null, lines: diffLocks(before, lock), staleLock: stale }
437
+ } catch (err) {
438
+ console.error(`\n ${c.red('✗')} Cannot review: ${(err as Error).message}\n`)
439
+ process.exit(1)
440
+ }
441
+
442
+ const markdown = reviewMarkdown(report)
443
+ if (args.includes('--json')) console.log(JSON.stringify(report, null, 2))
444
+ else if (args.includes('--markdown')) console.log(markdown)
445
+ else renderTerminal(report)
446
+
447
+ // Beside the drift table `sync --check` writes, so a reviewer sees what the
448
+ // change does next to whether it was compiled.
449
+ const summary = process.env.GITHUB_STEP_SUMMARY
450
+ if (process.env.GITHUB_ACTIONS === 'true' && summary) {
451
+ try {
452
+ appendFileSync(summary, markdown + '\n')
453
+ } catch {
454
+ // The summary is a courtesy; the output above stands.
455
+ }
456
+ }
457
+ }
@@ -32,7 +32,7 @@ async function installManifest(projectRoot: string, over: Partial<Manifest> = {}
32
32
  writeFileSync(join(projectRoot, '.opencastle', ...f.split('/')), '{}\n')
33
33
  }
34
34
  await writeManifest(projectRoot, {
35
- version: '9.9.9',
35
+ version: '0.0.0',
36
36
  ide: 'vscode',
37
37
  ides: ['vscode'],
38
38
  installedAt: new Date().toISOString(),
@@ -120,7 +120,7 @@ describe('status report', () => {
120
120
  const report = await buildStatusReport(pkgRoot, projectRoot)
121
121
 
122
122
  expect(report.installed).toBe(true)
123
- expect(report.version).toBe('9.9.9')
123
+ expect(report.version).toBe('0.0.0')
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)
@@ -198,6 +198,7 @@ describe('status and sync --check give the same answer', () => {
198
198
  async function installVscode(): Promise<void> {
199
199
  const { IDE_ADAPTERS } = await import('./adapters/index.js')
200
200
  const { writeManifest } = await import('./manifest.js')
201
+ const { recordLockFor } = await import('./lock.js')
201
202
  const stack = { ides: ['vscode'] as const, techTools: [], teamTools: [] }
202
203
  const adapter = await IDE_ADAPTERS['vscode']()
203
204
  await adapter.install(pkgRoot, projectRoot, stack as never, undefined)
@@ -206,13 +207,14 @@ describe('status and sync --check give the same answer', () => {
206
207
  writeFileSync(join(projectRoot, '.opencastle', ...f.split('/')), '{}\n')
207
208
  }
208
209
  await writeManifest(projectRoot, {
209
- version: '9.9.9',
210
+ version: '0.0.1',
210
211
  ide: 'vscode',
211
212
  ides: ['vscode'],
212
213
  installedAt: new Date().toISOString(),
213
214
  updatedAt: new Date().toISOString(),
214
215
  stack: stack as never,
215
216
  })
217
+ await recordLockFor(pkgRoot, projectRoot, { ides: ['vscode'], stack: stack as never })
216
218
  }
217
219
 
218
220
  it('agrees that a freshly compiled project is clean', async () => {
package/src/cli/status.ts CHANGED
@@ -51,6 +51,8 @@ export interface StatusReport {
51
51
  unmanaged: string[]
52
52
  nextCommand?: string
53
53
  nextReason?: string
54
+ /** The baselines the committed lock records, as `name version`. */
55
+ baselines?: string[]
54
56
  }
55
57
 
56
58
  /** Newest mtime under a directory tree, or 0 when absent. */
@@ -198,8 +200,15 @@ export async function buildStatusReport(pkgRoot: string, projectRoot: string): P
198
200
  try {
199
201
  const { buildCheckReport } = await import('./sync-check.js')
200
202
  const report = await buildCheckReport(pkgRoot, projectRoot)
201
- stale = report.drift.length > 0
202
- for (const d of report.drift) drifted.add(d.ide)
203
+ // A broken MCP server only a person can fix is not stale output: `doctor`'s
204
+ // failing check reports it, with its remedy, in the next line of this screen.
205
+ // Nor is a problem in the team's own sources, which stops the comparison
206
+ // before it starts; `doctor`'s team check names it, with the fix.
207
+ const outdatedOutput = report.drift.filter(
208
+ (d) => !(d.origin === 'mcp' && d.kind === 'unreducible') && d.origin !== 'team' && d.origin !== 'version',
209
+ )
210
+ stale = outdatedOutput.length > 0
211
+ for (const d of outdatedOutput) drifted.add(d.ide)
203
212
  } catch (err) {
204
213
  // The comparison could not run — but that alone does not say whose fault it
205
214
  // is. A package without its sources is our problem and no reason to call
@@ -267,8 +276,8 @@ export async function buildStatusReport(pkgRoot: string, projectRoot: string): P
267
276
  // the "one fact, two interpreters" split this surface was restructured to
268
277
  // remove, still standing in the surface it was restructured for.
269
278
  const results = [
270
- ...(await runSharedChecks(projectRoot, manifest)),
271
- ...(await runAdapterChecks(projectRoot, manifest)),
279
+ ...(await runSharedChecks(projectRoot, manifest, pkgRoot)),
280
+ ...(await runAdapterChecks(projectRoot, manifest, pkgRoot)),
272
281
  ]
273
282
  failing = results.filter((r) => !r.ok).map((r) => r.label)
274
283
  } catch (err) {
@@ -312,9 +321,23 @@ export async function buildStatusReport(pkgRoot: string, projectRoot: string): P
312
321
  nextReason = `${unmanaged.join(', ')} config exists but is not being compiled`
313
322
  }
314
323
 
324
+ // From the sources as they are now, not the committed lock: after an edit
325
+ // to `extends` the lock still names the old baseline until the next sync.
326
+ let baselines: string[] = []
327
+ try {
328
+ const { resolveSources } = await import('./layers.js')
329
+ const { resolveStack } = await import('./stack-config.js')
330
+ baselines = resolveSources({ pkgRoot, projectRoot, stack: resolveStack(manifest), repoInfo: manifest.repoInfo })
331
+ .layers.filter((l) => l.kind === 'baseline')
332
+ .map((l) => `${l.id}${l.version ? ` ${l.version}` : ''}`)
333
+ } catch {
334
+ baselines = []
335
+ }
336
+
315
337
  return {
316
338
  installed: true,
317
339
  missingRequired,
340
+ ...(baselines.length > 0 && { baselines }),
318
341
  version: manifest.version,
319
342
  ides: adapters.map((a) => a.ide),
320
343
  targets,
@@ -359,6 +382,8 @@ function render(report: StatusReport): void {
359
382
  (report.stale ? c.yellow(' — generated files no longer match their sources') : ''),
360
383
  )
361
384
 
385
+ if (report.baselines?.length) console.log(` ${c.dim('Extends')} ${report.baselines.join(', ')}`)
386
+
362
387
  for (const t of report.targets) {
363
388
  // Per target. Folding `nextCommand` back in marked all seven targets
364
389
  // "needs a sync" when one had drifted.
@@ -12,7 +12,15 @@ import { join, resolve } from 'node:path'
12
12
  import { describe, it, expect, beforeEach, afterEach } from 'vitest'
13
13
  import { buildCheckReport } from './sync-check.js'
14
14
  import { IDE_ADAPTERS } from './adapters/index.js'
15
- import { writeManifest } from './manifest.js'
15
+ import { writeManifest as writeManifestOnly } from './manifest.js'
16
+ import { recordLockFor } from './lock.js'
17
+ import type { Manifest } from './types.js'
18
+
19
+ /** A compile writes the manifest and the lock; tests that compile by hand do both. */
20
+ async function writeManifest(root: string, manifest: Manifest): Promise<void> {
21
+ await writeManifestOnly(root, manifest)
22
+ await recordLockFor(resolve(import.meta.dirname, '..', '..'), root, manifest)
23
+ }
16
24
  import type { StackConfig } from './types.js'
17
25
 
18
26
  const pkgRoot = resolve(import.meta.dirname, '..', '..')
@@ -26,7 +34,7 @@ describe('drift detection', () => {
26
34
  const adapter = await IDE_ADAPTERS['vscode']()
27
35
  await adapter.install(pkgRoot, projectRoot, stack, undefined)
28
36
  await writeManifest(projectRoot, {
29
- version: '9.9.9',
37
+ version: '0.0.1',
30
38
  ide: 'vscode',
31
39
  ides: ['vscode'],
32
40
  installedAt: new Date().toISOString(),
@@ -149,7 +157,7 @@ describe('drift detection', () => {
149
157
  it('skips ide ids the manifest names but the tool does not know', async () => {
150
158
  await install()
151
159
  await writeManifest(projectRoot, {
152
- version: '9.9.9',
160
+ version: '0.0.1',
153
161
  ide: 'vscode',
154
162
  ides: ['vscode', 'not-a-real-ide'],
155
163
  installedAt: new Date().toISOString(),
@@ -185,7 +193,7 @@ describe('two targets that share a root file', () => {
185
193
  await adapter.install(pkgRoot, projectRoot, bothStack, undefined)
186
194
  }
187
195
  await writeManifest(projectRoot, {
188
- version: '9.9.9',
196
+ version: '0.0.1',
189
197
  ide: 'opencode',
190
198
  ides: ['opencode', 'codex'],
191
199
  installedAt: new Date().toISOString(),
@@ -246,7 +254,7 @@ describe('every reported extra is one that sync actually removes', () => {
246
254
  const ideStack = { ides: [ide], techTools: [], teamTools: [] } as unknown as StackConfig
247
255
  await adapter.install(pkgRoot, projectRoot, ideStack, undefined)
248
256
  await writeManifest(projectRoot, {
249
- version: '9.9.9',
257
+ version: '0.0.1',
250
258
  ide,
251
259
  ides: [ide],
252
260
  installedAt: new Date().toISOString(),
@@ -286,7 +294,7 @@ describe('every reported extra is one that sync actually removes', () => {
286
294
  const ideStack = { ides: [ide], techTools: [], teamTools: [] } as unknown as StackConfig
287
295
  await adapter.install(pkgRoot, projectRoot, ideStack, undefined)
288
296
  await writeManifest(projectRoot, {
289
- version: '9.9.9',
297
+ version: '0.0.1',
290
298
  ide,
291
299
  ides: [ide],
292
300
  installedAt: new Date().toISOString(),
@@ -359,7 +367,7 @@ describe('line endings are git\'s business, not the checker\'s', () => {
359
367
  const adapter = await IDE_ADAPTERS['vscode']()
360
368
  await adapter.install(pkgRoot, projectRoot, stack, undefined)
361
369
  await writeManifest(projectRoot, {
362
- version: '9.9.9',
370
+ version: '0.0.1',
363
371
  ide: 'vscode',
364
372
  ides: ['vscode'],
365
373
  installedAt: new Date().toISOString(),
@@ -412,7 +420,7 @@ describe('install then check is clean, whatever the root file looks like', () =>
412
420
 
413
421
  await adapter.install(pkgRoot, projectRoot, stack, undefined)
414
422
  await writeManifest(projectRoot, {
415
- version: '9.9.9',
423
+ version: '0.0.1',
416
424
  ide: 'vscode',
417
425
  ides: ['vscode'],
418
426
  installedAt: new Date().toISOString(),