opencastle 1.6.4 → 1.7.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 (76) hide show
  1. package/dist/cli/baseline.d.ts.map +1 -1
  2. package/dist/cli/baseline.js +8 -0
  3. package/dist/cli/baseline.js.map +1 -1
  4. package/dist/cli/bootstrap.d.ts.map +1 -1
  5. package/dist/cli/bootstrap.js +31 -9
  6. package/dist/cli/bootstrap.js.map +1 -1
  7. package/dist/cli/bootstrap.test.js +10 -0
  8. package/dist/cli/bootstrap.test.js.map +1 -1
  9. package/dist/cli/detect.d.ts.map +1 -1
  10. package/dist/cli/detect.js +32 -0
  11. package/dist/cli/detect.js.map +1 -1
  12. package/dist/cli/detect.test.js +23 -0
  13. package/dist/cli/detect.test.js.map +1 -1
  14. package/dist/cli/init.d.ts.map +1 -1
  15. package/dist/cli/init.js +10 -5
  16. package/dist/cli/init.js.map +1 -1
  17. package/dist/cli/layers.d.ts.map +1 -1
  18. package/dist/cli/layers.js +21 -1
  19. package/dist/cli/layers.js.map +1 -1
  20. package/dist/cli/layers.test.js +17 -0
  21. package/dist/cli/layers.test.js.map +1 -1
  22. package/dist/cli/manifest.d.ts +9 -0
  23. package/dist/cli/manifest.d.ts.map +1 -1
  24. package/dist/cli/manifest.js +12 -0
  25. package/dist/cli/manifest.js.map +1 -1
  26. package/dist/cli/project-facts-lang.d.ts +36 -0
  27. package/dist/cli/project-facts-lang.d.ts.map +1 -0
  28. package/dist/cli/project-facts-lang.js +323 -0
  29. package/dist/cli/project-facts-lang.js.map +1 -0
  30. package/dist/cli/project-facts.d.ts +5 -0
  31. package/dist/cli/project-facts.d.ts.map +1 -1
  32. package/dist/cli/project-facts.js +28 -11
  33. package/dist/cli/project-facts.js.map +1 -1
  34. package/dist/cli/project-facts.test.js +70 -0
  35. package/dist/cli/project-facts.test.js.map +1 -1
  36. package/dist/cli/promote-command.test.js +7 -0
  37. package/dist/cli/promote-command.test.js.map +1 -1
  38. package/dist/cli/promote.d.ts +7 -1
  39. package/dist/cli/promote.d.ts.map +1 -1
  40. package/dist/cli/promote.js +16 -2
  41. package/dist/cli/promote.js.map +1 -1
  42. package/dist/cli/stack-config-update.test.js +21 -1
  43. package/dist/cli/stack-config-update.test.js.map +1 -1
  44. package/dist/cli/stack-config.d.ts +20 -0
  45. package/dist/cli/stack-config.d.ts.map +1 -1
  46. package/dist/cli/stack-config.js +36 -0
  47. package/dist/cli/stack-config.js.map +1 -1
  48. package/dist/cli/team-commands.test.js +25 -0
  49. package/dist/cli/team-commands.test.js.map +1 -1
  50. package/dist/cli/team-config.d.ts +7 -2
  51. package/dist/cli/team-config.d.ts.map +1 -1
  52. package/dist/cli/team-config.js +8 -3
  53. package/dist/cli/team-config.js.map +1 -1
  54. package/dist/cli/update.d.ts.map +1 -1
  55. package/dist/cli/update.js +13 -16
  56. package/dist/cli/update.js.map +1 -1
  57. package/package.json +1 -1
  58. package/src/cli/baseline.ts +10 -0
  59. package/src/cli/bootstrap.test.ts +11 -0
  60. package/src/cli/bootstrap.ts +31 -9
  61. package/src/cli/detect.test.ts +27 -0
  62. package/src/cli/detect.ts +29 -0
  63. package/src/cli/init.ts +10 -5
  64. package/src/cli/layers.test.ts +20 -0
  65. package/src/cli/layers.ts +20 -1
  66. package/src/cli/manifest.ts +13 -0
  67. package/src/cli/project-facts-lang.ts +338 -0
  68. package/src/cli/project-facts.test.ts +75 -0
  69. package/src/cli/project-facts.ts +31 -11
  70. package/src/cli/promote-command.test.ts +8 -0
  71. package/src/cli/promote.ts +16 -2
  72. package/src/cli/stack-config-update.test.ts +25 -1
  73. package/src/cli/stack-config.ts +36 -0
  74. package/src/cli/team-commands.test.ts +28 -0
  75. package/src/cli/team-config.ts +10 -3
  76. package/src/cli/update.ts +15 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencastle",
3
- "version": "1.6.4",
3
+ "version": "1.7.1",
4
4
  "type": "module",
5
5
  "description": "Write your AI config once, for every assistant and every teammate: compiles instructions, agents, skills, commands and MCP servers for Claude Code, Copilot, Cursor, Windsurf, OpenCode, Codex and Antigravity, shared across your team's repositories.",
6
6
  "bin": {
@@ -324,6 +324,16 @@ function check(pkgRoot: string, dir: string): CheckReport {
324
324
  try {
325
325
  const r = contentReport(source)
326
326
  contextTokens = tokensOf(r.instructionChars + r.indexChars)
327
+ // Its own budget, already spent: every repository extending it starts
328
+ // over it, and doctor warns in each of them about content they did
329
+ // not add. The check said "Ready to publish" over that.
330
+ const budget = resolved.policy.contextBudget
331
+ if (budget && contextTokens > budget.tokens) {
332
+ warnings.push(
333
+ `${shown(resolved.layers.find((l) => l.kind === 'baseline')?.configFile ?? 'config.json')}: policy.contextBudget is ${budget.tokens} tokens, but a repository extending this baseline starts at ~${contextTokens}, before adding anything\n` +
334
+ `→ raise the budget, or move always-loaded instructions into skills, which load only when a task needs them`,
335
+ )
336
+ }
327
337
  } finally {
328
338
  source.dispose()
329
339
  }
@@ -188,6 +188,17 @@ describe('bootstrapCustomizations', () => {
188
188
  expect(content).toMatch(/^npm test\s+# vitest$/m)
189
189
  })
190
190
 
191
+ it('writes a Python service as Python: its tool, its commands, no npm', async () => {
192
+ await writeFile(join(tempDir, 'pyproject.toml'), '[tool.poetry.dependencies]\npython = "^3.11"\nfastapi = "^0.110"\npytest = "^8"\n', 'utf8')
193
+ await writeFile(join(tempDir, 'poetry.lock'), '', 'utf8')
194
+ await bootstrapCustomizations(tempDir, { language: 'python', frameworks: ['fastapi'] }, STACK_EMPTY)
195
+ const content = await readFile(join(tempDir, '.opencastle', 'project.instructions.md'), 'utf8')
196
+ expect(content).toContain('Python · package manager `poetry`')
197
+ expect(content).toMatch(/^poetry run pytest\s+# run the tests$/m)
198
+ expect(content).toContain('| Framework | FastAPI | 0.110 |')
199
+ expect(content).not.toMatch(/\bnpm\b/)
200
+ })
201
+
191
202
  // ── 9. Empty repoInfo ────────────────────────────────────────
192
203
 
193
204
  it('handles empty repoInfo gracefully without crashing', async () => {
@@ -89,17 +89,30 @@ function devLine(facts: ProjectFacts): string | null {
89
89
 
90
90
  const SCRIPT_ORDER = ['dev', 'build', 'start', 'test', 'lint', 'typecheck', 'type-check', 'format']
91
91
 
92
+ /** At most `max` characters, cut between words: `--cov-config=se` read as a different flag. */
93
+ function clip(text: string, max: number): string {
94
+ if (text.length <= max) return text
95
+ const cut = text.slice(0, max - 1)
96
+ return `${cut.slice(0, Math.max(cut.lastIndexOf(' '), max / 2)).trimEnd()} …`
97
+ }
98
+
92
99
  function keyCommands(facts: ProjectFacts): string | null {
93
100
  const names = Object.keys(facts.scripts).filter((s) => !/^(pre|post)/.test(s))
94
- if (names.length === 0) return null
101
+ if (names.length === 0 && facts.commands.length === 0) return null
95
102
  names.sort((a, b) => {
96
103
  const ia = SCRIPT_ORDER.indexOf(a)
97
104
  const ib = SCRIPT_ORDER.indexOf(b)
98
105
  return (ia === -1 ? 99 : ia) - (ib === -1 ? 99 : ib) || a.localeCompare(b)
99
106
  })
100
107
  const run = (s: string) => runScript(facts, s)
101
- const width = Math.max(...names.slice(0, 14).map((s) => run(s).length))
102
- const lines = names.slice(0, 14).map((s) => `${run(s).padEnd(width)} # ${facts.scripts[s].slice(0, 70)}`)
108
+ // package.json's scripts, then what a Makefile, justfile, `scripts/` or the
109
+ // language's own tools declare.
110
+ const rows: Array<[string, string]> = [
111
+ ...names.slice(0, 14).map((s): [string, string] => [run(s), clip(facts.scripts[s], 70)]),
112
+ ...facts.commands.map((c): [string, string] => [c.cmd, clip(c.does, 70)]),
113
+ ]
114
+ const width = Math.max(...rows.map(([cmd]) => cmd.length))
115
+ const lines = rows.map(([cmd, does]) => (does ? `${cmd.padEnd(width)} # ${does}` : cmd))
103
116
  const ci = facts.ciCommands.length
104
117
  ? ['', `CI (${inline(facts.ciWorkflows, 3)}) runs: ${inline(facts.ciCommands, 8)} — a change passes these before it merges.`]
105
118
  : []
@@ -166,8 +179,10 @@ function renderProjectInstructions(facts: ProjectFacts, info: RepoInfo, stack: S
166
179
  facts.name ? `**${facts.name}**` : null,
167
180
  facts.description ? `— ${facts.description}` : null,
168
181
  ].filter(Boolean).join(' ')
169
- const language = { typescript: 'TypeScript', javascript: 'JavaScript' }[facts.language ?? ''] ?? facts.language
170
- const basics = [language, facts.nodeVersion ? `Node ${facts.nodeVersion}` : null, `package manager ${code(facts.packageManager)}`, facts.workspaces.length ? `${info.monorepo ?? 'workspaces'} monorepo` : null]
182
+ const language = { typescript: 'TypeScript', javascript: 'JavaScript', python: 'Python', go: 'Go' }[facts.language ?? ''] ?? facts.language
183
+ // Go modules are not a package manager to name; nothing found is nothing said.
184
+ const manager = facts.packageManager && facts.packageManager !== 'go' ? `package manager ${code(facts.packageManager)}` : null
185
+ const basics = [language, facts.nodeVersion ? `Node ${facts.nodeVersion}` : null, manager, facts.workspaces.length ? `${info.monorepo ?? 'workspaces'} monorepo` : null]
171
186
  .filter(Boolean).join(' · ')
172
187
 
173
188
  const stackRows = facts.stack.map((s) => [s.layer, s.name, s.version ?? '—'])
@@ -211,7 +226,7 @@ function renderProjectInstructions(facts: ProjectFacts, info: RepoInfo, stack: S
211
226
  // ── stack/*.md ─────────────────────────────────────────────────
212
227
 
213
228
  /** The frameworks that serve an API, in the order one is named for it. */
214
- const SERVES_API = ['Next.js', 'Astro', 'SvelteKit', 'Remix', 'Nuxt', 'Express', 'Fastify', 'Hono']
229
+ const SERVES_API = ['Next.js', 'Astro', 'SvelteKit', 'Remix', 'Nuxt', 'Express', 'Fastify', 'Hono', 'FastAPI', 'Django', 'Flask', 'Gin', 'Echo', 'chi', 'Fiber']
215
230
 
216
231
  function renderApiConfig(facts: ProjectFacts, info: RepoInfo): string {
217
232
  const frameworks = facts.stack.filter((s) => s.layer === 'Framework')
@@ -223,7 +238,11 @@ function renderApiConfig(facts: ProjectFacts, info: RepoInfo): string {
223
238
  [fw ? `Framework: ${fw.name}${fw.version ? ` ${fw.version}` : ''}.` : null, READ_BY(['api-patterns'])].filter(Boolean).join(' '),
224
239
  ['## Endpoints', '', facts.api.length
225
240
  ? table(['Endpoint', 'Methods', 'File'], facts.api.map((a) => [code(a.route), a.methods.join(', ') || '—', code(a.file)]))
226
- : facts.rpcRouters.length ? 'No route files: the API is tRPC, below.' : 'None found in route files.'].join('\n'),
241
+ : facts.rpcRouters.length ? 'No route files: the API is tRPC, below.' : 'None found in route files.',
242
+ // Go routers are grouped in code that passes the group around; the paths
243
+ // are what each file declares.
244
+ ...(facts.api.some((a) => a.file.endsWith('.go')) ? ['', 'Paths are as each file declares them, relative to the router group it is registered on.'] : []),
245
+ ].join('\n'),
227
246
  facts.rpcRouters.length ? ['## tRPC routers', '', ...facts.rpcRouters.map((f) => `- ${code(f)}`)].join('\n') : null,
228
247
  facts.serverActions.length ? ['## Server Actions', '', ...facts.serverActions.map((f) => `- ${code(f)}`)].join('\n') : null,
229
248
  facts.middleware ? ['## Middleware', '', `${code(facts.middleware)} runs before matching requests.`].join('\n') : null,
@@ -275,7 +294,10 @@ function renderCmsConfig(facts: ProjectFacts, provider: string): string {
275
294
 
276
295
  function renderTestingConfig(facts: ProjectFacts, info: RepoInfo, browserChecks: boolean): string {
277
296
  const dirs = [...new Set(facts.testFiles.map((f) => f.split('/').slice(0, -1).join('/') || '.'))].slice(0, 6)
278
- const testScripts = Object.keys(facts.scripts).filter((s) => /^(test|e2e)/.test(s)).map((s) => `${facts.packageManager} run ${s}`)
297
+ const testScripts = [
298
+ ...Object.keys(facts.scripts).filter((s) => /^(test|e2e)/.test(s)).map((s) => `${facts.packageManager} run ${s}`),
299
+ ...facts.commands.filter((c) => /\b(test|pytest)\b/.test(c.cmd)).map((c) => c.cmd),
300
+ ]
279
301
  const configs = facts.testConfigs
280
302
  const frameworks = facts.testFrameworks.length ? facts.testFrameworks : (info.testing ?? []).map(displayName)
281
303
  const bp = facts.breakpoints
@@ -284,7 +306,7 @@ function renderTestingConfig(facts: ProjectFacts, info: RepoInfo, browserChecks:
284
306
  HEADER,
285
307
  READ_BY(['testing-workflow', browserChecks ? 'browser-testing' : null]),
286
308
  [
287
- frameworks.length ? `**Frameworks:** ${frameworks.join(', ')}${configs.length ? ` (${inline(configs)})` : ''}` : '**Frameworks:** none in package.json.',
309
+ frameworks.length ? `**Frameworks:** ${frameworks.join(', ')}${configs.length ? ` (${inline(configs)})` : ''}` : '**Frameworks:** none found.',
288
310
  facts.testFiles.length ? `**Test files:** ${facts.testFiles.length}, in ${inline(dirs, 6)}` : '**Test files:** none found.',
289
311
  testScripts.length ? `**Run:** ${inline(testScripts)}` : null,
290
312
  facts.coverage.length ? `**Coverage required:** ${facts.coverage.join(', ')} (from the test config)` : null,
@@ -299,6 +299,33 @@ describe('detectRepoInfo', () => {
299
299
 
300
300
  // ── buildDetectedToolsSet ──────────────────────────────────────
301
301
 
302
+ describe('detectRepoInfo — Python and Go', () => {
303
+ let dir: string
304
+ beforeEach(async () => { dir = await mkdtemp(join(tmpdir(), 'opencastle-lang-')) })
305
+ afterEach(async () => { await rm(dir, { recursive: true, force: true }) })
306
+
307
+ it('reads a FastAPI service as Python with its framework, and no JavaScript package manager', async () => {
308
+ await writeFile(join(dir, 'pyproject.toml'), '[tool.poetry.dependencies]\npython = "^3.11"\nfastapi = "^0.110"\n')
309
+ const info = await detectRepoInfo(dir)
310
+ expect(info.language).toBe('python')
311
+ expect(info.frameworks).toEqual(['fastapi'])
312
+ expect(info.packageManager).toBeUndefined()
313
+ })
314
+
315
+ it('reads a Go module with Gin', async () => {
316
+ await writeFile(join(dir, 'go.mod'), 'module x\n\ngo 1.22\n\nrequire github.com/gin-gonic/gin v1.10.0\n')
317
+ const info = await detectRepoInfo(dir)
318
+ expect(info.language).toBe('go')
319
+ expect(info.frameworks).toEqual(['gin'])
320
+ })
321
+
322
+ it('keeps TypeScript for a project that has both', async () => {
323
+ await writeFile(join(dir, 'tsconfig.json'), '{}')
324
+ await writeFile(join(dir, 'requirements.txt'), 'flask\n')
325
+ expect((await detectRepoInfo(dir)).language).toBe('typescript')
326
+ })
327
+ })
328
+
302
329
  describe('buildDetectedToolsSet', () => {
303
330
  it('maps detection labels to plugin IDs', () => {
304
331
  const set = buildDetectedToolsSet({
package/src/cli/detect.ts CHANGED
@@ -389,6 +389,11 @@ export async function detectRepoInfo(projectRoot: string): Promise<RepoInfo> {
389
389
  }
390
390
  }
391
391
 
392
+ // ── 6b. Python or Go, when nothing JavaScript said otherwise ──
393
+ // Read for the language and the web framework, which decide what the project
394
+ // is given: a FastAPI service has no use for TypeScript or SEO rules.
395
+ if (!info.language) await detectPythonOrGo(projectRoot, info)
396
+
392
397
  // ── 7. Detect CSS modules via src scan ──────────────────────
393
398
  if (!info.styling.includes('css-modules')) {
394
399
  const hasCssModules = await scanForPattern(projectRoot, /\.module\.(css|scss|sass)$/);
@@ -416,6 +421,30 @@ export async function detectRepoInfo(projectRoot: string): Promise<RepoInfo> {
416
421
 
417
422
  // ── Internal helpers ──────────────────────────────────────────
418
423
 
424
+ /** Framework packages of Python and Go projects, by how their manifest names them. */
425
+ const PYTHON_FRAMEWORKS: Array<[RegExp, string]> = [[/\bfastapi\b/i, 'fastapi'], [/\bdjango\b/i, 'django'], [/\bflask\b/i, 'flask']]
426
+ const GO_FRAMEWORKS: Array<[RegExp, string]> = [
427
+ [/github\.com\/gin-gonic\/gin\b/, 'gin'], [/github\.com\/labstack\/echo\b/, 'echo'],
428
+ [/github\.com\/go-chi\/chi\b/, 'chi'], [/github\.com\/gofiber\/fiber\b/, 'fiber'],
429
+ ]
430
+
431
+ async function detectPythonOrGo(root: string, info: RepoInfoInternal): Promise<void> {
432
+ const read = (rel: string): Promise<string> => readFile(resolve(root, rel), 'utf8').catch(() => '')
433
+ if (await fileExists(resolve(root, 'go.mod'))) {
434
+ info.language = 'go'
435
+ info.configFiles.push('go.mod')
436
+ const mod = await read('go.mod')
437
+ for (const [re, label] of GO_FRAMEWORKS) if (re.test(mod)) addUnique(info.frameworks, label)
438
+ return
439
+ }
440
+ const manifests = (await checkFiles(root, ['pyproject.toml', 'requirements.txt', 'setup.py', 'setup.cfg', 'Pipfile']))
441
+ if (manifests.length === 0) return
442
+ info.language = 'python'
443
+ info.configFiles.push(...manifests)
444
+ const text = (await Promise.all(manifests.map(read))).join('\n')
445
+ for (const [re, label] of PYTHON_FRAMEWORKS) if (re.test(text)) addUnique(info.frameworks, label)
446
+ }
447
+
419
448
  async function checkFiles(root: string, files: string[]): Promise<string[]> {
420
449
  const found: string[] = [];
421
450
  for (const f of files) {
package/src/cli/init.ts CHANGED
@@ -3,10 +3,10 @@ import { readFile, unlink } from 'node:fs/promises'
3
3
  import { existsSync } from 'node:fs'
4
4
  import { execFileSync } from 'node:child_process'
5
5
  import { multiselect, confirm, closePrompts, c } from './prompt.js'
6
- import { readManifest, writeManifest, createManifest } from './manifest.js'
6
+ import { readManifest, writeManifest, createManifest, manifestMeaning } from './manifest.js'
7
7
  import { removeDirIfExists, copyDir, getOrchestratorRoot } from './copy.js'
8
8
  import { updateGitignore } from './gitignore.js'
9
- import { getCustomizationsTransform } from './stack-config.js'
9
+ import { getCustomizationsTransform, isPreselected } from './stack-config.js'
10
10
  import { getMcpConfigRelPath, stripManagedMcpServers, retireLegacyMcpConfig } from './mcp.js'
11
11
  import { getPluginsBySubCategory } from '../orchestrator/plugins/index.js'
12
12
  import type { PluginConfig } from '../orchestrator/plugins/types.js'
@@ -98,7 +98,7 @@ export function detectSelection(
98
98
  getPluginsBySubCategory(sc as PluginConfig['subCategory']),
99
99
  )
100
100
  for (const p of plugins) {
101
- if (!p.preselected && !detected.has(p.id) && !kept.has(p.id)) continue
101
+ if (!isPreselected(p, repoInfo) && !detected.has(p.id) && !kept.has(p.id)) continue
102
102
  if (p.category === 'team') teamTools.push(p.id)
103
103
  else techTools.push(p.id)
104
104
  }
@@ -160,7 +160,7 @@ async function promptSelection(
160
160
  label: p.label,
161
161
  hint: p.hint,
162
162
  value: p.id,
163
- ...((p.preselected || detectedTools.has(p.id) || existingTools.has(p.id)) && { selected: true }),
163
+ ...((isPreselected(p, repoInfo) || detectedTools.has(p.id) || existingTools.has(p.id)) && { selected: true }),
164
164
  })),
165
165
  )
166
166
  for (const id of selected) {
@@ -706,7 +706,12 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
706
706
  // differed from what the next sync saw and that sync rewrote the manifest —
707
707
  // a committed file changing on a run that changed nothing about the project.
708
708
  manifest.repoInfo = mergeStackIntoRepoInfo(await detectRepoInfo(projectRoot), stack)
709
- await writeManifest(projectRoot, manifest)
709
+ // Nothing it records changed: leave it, timestamp and all. A second `init`
710
+ // rewrote `updatedAt`, a diff in a committed file from a run that changed
711
+ // nothing — the same reason `sync` compares before it writes.
712
+ if (!existing || manifestMeaning(manifest) !== manifestMeaning(existing)) {
713
+ await writeManifest(projectRoot, manifest)
714
+ }
710
715
 
711
716
  // ── Update .gitignore ───────────────────────────────────────────
712
717
  // Only local artefacts and .env; the generated config is meant to be committed.
@@ -89,6 +89,11 @@ describe('the config file', () => {
89
89
  expect(issues[0].fix).toContain('"extends"')
90
90
  })
91
91
 
92
+ it('accepts a pattern in an exclude of content, and not of a server', () => {
93
+ expect(parseTeamConfig('{ "exclude": ["skills/*", "agents/content-*"] }', 'x').issues).toEqual([])
94
+ expect(parseTeamConfig('{ "exclude": ["mcpServers/*"] }', 'x').issues).not.toEqual([])
95
+ })
96
+
92
97
  it('rejects an exclude that names no kind', () => {
93
98
  const { issues } = parseTeamConfig('{ "exclude": ["seo-patterns"] }', 'x')
94
99
  expect(issues[0].message).toMatch(/must name a kind/)
@@ -221,6 +226,21 @@ describe('resolving layers', () => {
221
226
  expect(r.issues).toEqual([expect.objectContaining({ level: 'warning', message: expect.stringContaining('skills/no-such-skill') })])
222
227
  })
223
228
 
229
+ it('excludes by pattern: skills/* leaves out every skill from below', () => {
230
+ write(project, { '.opencastle/config.json': '{ "exclude": ["skills/*", "workflows/data-*"] }' })
231
+ const r = resolveHere()
232
+ expect([...r.items.keys()].filter((k) => k.startsWith('skills/'))).toEqual([])
233
+ expect(r.items.has('workflows/data-pipeline')).toBe(false)
234
+ expect(r.items.has('workflows/refactoring')).toBe(true)
235
+ expect(r.excluded.length).toBeGreaterThan(5)
236
+ expect(r.issues).toEqual([])
237
+ })
238
+
239
+ it('warns about a pattern that matches nothing', () => {
240
+ write(project, { '.opencastle/config.json': '{ "exclude": ["skills/no-such-*"] }' })
241
+ expect(resolveHere().issues).toEqual([expect.objectContaining({ level: 'warning', message: expect.stringContaining('matches nothing') })])
242
+ })
243
+
224
244
  it('does not call an exclude of something the stack already left out a mistake', () => {
225
245
  write(project, { '.opencastle/config.json': '{ "exclude": ["agents/content-engineer"] }' })
226
246
  expect(resolveHere().issues).toEqual([])
package/src/cli/layers.ts CHANGED
@@ -14,7 +14,7 @@ import { join, resolve, relative, dirname, isAbsolute, sep } from 'node:path'
14
14
  import { tmpdir } from 'node:os'
15
15
  import { PLUGINS } from '../orchestrator/plugins/index.js'
16
16
  import { getOrchestratorRoot, getPluginsRoot } from './copy.js'
17
- import { getExcludedSkills, getExcludedAgents, getIncludedPluginIds, getIncludedMcpServers, getRequiredMcpEnvVars } from './stack-config.js'
17
+ import { getExcludedSkills, getExcludedAgents, getIncludedPluginIds, getIncludedMcpServers, getRequiredMcpEnvVars, getExcludedCoreSkills } from './stack-config.js'
18
18
  import { splitFrontmatter, parseFrontmatterString } from './adapters/frontmatter.js'
19
19
  import { packageLaunch, isPinned } from './mcp-audit.js'
20
20
  import { disallowedBy, hostDisallowedBy, findInlineSecret, emptyPolicy, globMatch, hostOfUrl, hostAllowedBy, type EffectivePolicy } from './policy.js'
@@ -713,6 +713,7 @@ export function resolveSources(opts: ResolveOptions): ResolvedSources {
713
713
  // exclusions anyone wrote, so a team layer naming one is not a mistake.
714
714
  const stackOut = new Set<string>()
715
715
  const excludedSkills = stack ? getExcludedSkills(stack) : new Set<string>()
716
+ for (const name of getExcludedCoreSkills(repoInfo)) excludedSkills.add(name)
716
717
  const excludedAgents = stack ? getExcludedAgents(stack) : new Set<string>()
717
718
  for (const item of scanLayer(core, projectRoot).items) {
718
719
  if (item.kind === 'skills' && excludedSkills.has(item.name)) {
@@ -765,6 +766,24 @@ export function resolveSources(opts: ResolveOptions): ResolvedSources {
765
766
  for (const written of layer.config.exclude ?? []) {
766
767
  // Servers are excluded where servers are merged, below.
767
768
  if (written.startsWith('mcpServers/')) continue
769
+ if (written.includes('*')) {
770
+ const literal = written.split('*').map((part) => part.replace(/[.+?^${}()|[\]\\]/g, '\\$&'))
771
+ const pattern = new RegExp(`^${literal.join('[^/]*')}$`)
772
+ const hits = [...items.keys()].filter((ref) => pattern.test(ref))
773
+ for (const ref of hits) {
774
+ excluded.push({ ref, by: layer.id, from: items.get(ref)!.layer })
775
+ items.delete(ref)
776
+ }
777
+ if (hits.length === 0) {
778
+ issues.push({
779
+ level: 'warning',
780
+ where,
781
+ message: `excludes ${written}, which matches nothing a layer below provides`,
782
+ fix: 'check the pattern — npx opencastle explain lists everything that is compiled',
783
+ })
784
+ }
785
+ continue
786
+ }
768
787
  const renamed = items.has(written) ? null : integrationSkill(written)
769
788
  if (renamed) {
770
789
  issues.push({
@@ -82,6 +82,19 @@ export async function writeManifest(
82
82
  await writeFile(path, JSON.stringify(manifest, null, 2) + '\n');
83
83
  }
84
84
 
85
+ /**
86
+ * The manifest without the fields that change on every write.
87
+ *
88
+ * `updatedAt` changed on every sync, so two branches that both synced always
89
+ * conflicted on the manifest — in the one file every command reads first,
90
+ * where a conflict makes every command stop. It is written only when something
91
+ * it records has actually changed.
92
+ */
93
+ export function manifestMeaning(m: object): string {
94
+ const { updatedAt: _u, installedAt: _i, ...rest } = m as Record<string, unknown>;
95
+ return JSON.stringify(rest);
96
+ }
97
+
85
98
  /**
86
99
  * Create a fresh manifest object.
87
100
  */