opencastle 1.7.0 → 1.7.2
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.
- package/README.md +64 -151
- package/dist/cli/baseline.d.ts.map +1 -1
- package/dist/cli/baseline.js +8 -0
- package/dist/cli/baseline.js.map +1 -1
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +7 -2
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/layers.d.ts.map +1 -1
- package/dist/cli/layers.js +18 -0
- package/dist/cli/layers.js.map +1 -1
- package/dist/cli/layers.test.js +17 -0
- package/dist/cli/layers.test.js.map +1 -1
- package/dist/cli/manifest.d.ts +9 -0
- package/dist/cli/manifest.d.ts.map +1 -1
- package/dist/cli/manifest.js +12 -0
- package/dist/cli/manifest.js.map +1 -1
- package/dist/cli/promote-command.test.js +7 -0
- package/dist/cli/promote-command.test.js.map +1 -1
- package/dist/cli/promote.d.ts +7 -1
- package/dist/cli/promote.d.ts.map +1 -1
- package/dist/cli/promote.js +16 -2
- package/dist/cli/promote.js.map +1 -1
- package/dist/cli/team-commands.test.js +25 -0
- package/dist/cli/team-commands.test.js.map +1 -1
- package/dist/cli/team-config.d.ts +7 -2
- package/dist/cli/team-config.d.ts.map +1 -1
- package/dist/cli/team-config.js +8 -3
- package/dist/cli/team-config.js.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +10 -13
- package/dist/cli/update.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/baseline.ts +10 -0
- package/src/cli/init.ts +7 -2
- package/src/cli/layers.test.ts +20 -0
- package/src/cli/layers.ts +18 -0
- package/src/cli/manifest.ts +13 -0
- package/src/cli/promote-command.test.ts +8 -0
- package/src/cli/promote.ts +16 -2
- package/src/cli/team-commands.test.ts +28 -0
- package/src/cli/team-config.ts +10 -3
- package/src/cli/update.ts +12 -14
package/src/cli/init.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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
9
|
import { getCustomizationsTransform, isPreselected } from './stack-config.js'
|
|
@@ -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
|
-
|
|
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.
|
package/src/cli/layers.test.ts
CHANGED
|
@@ -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
|
@@ -766,6 +766,24 @@ export function resolveSources(opts: ResolveOptions): ResolvedSources {
|
|
|
766
766
|
for (const written of layer.config.exclude ?? []) {
|
|
767
767
|
// Servers are excluded where servers are merged, below.
|
|
768
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
|
+
}
|
|
769
787
|
const renamed = items.has(written) ? null : integrationSkill(written)
|
|
770
788
|
if (renamed) {
|
|
771
789
|
issues.push({
|
package/src/cli/manifest.ts
CHANGED
|
@@ -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
|
*/
|
|
@@ -62,6 +62,14 @@ describe.skipIf(!built)('opencastle promote', () => {
|
|
|
62
62
|
expect(existsSync(join(project, '.claude', 'skills', 'deploy-runbook', 'scripts', 'rollback.sh'))).toBe(true)
|
|
63
63
|
})
|
|
64
64
|
|
|
65
|
+
it('looks in Claude Code’s config directory where CLAUDE_CONFIG_DIR moves it, as promote memory does', () => {
|
|
66
|
+
config = join(root, 'elsewhere')
|
|
67
|
+
write(config, { 'skills/sql-tips/SKILL.md': skill('sql-tips') })
|
|
68
|
+
const out = run(project, 'promote', 'skill', 'sql-tips', '--dry-run')
|
|
69
|
+
expect(out.status, out.stderr).toBe(0)
|
|
70
|
+
expect(out.stdout).toContain(join('elsewhere', 'skills', 'sql-tips'))
|
|
71
|
+
})
|
|
72
|
+
|
|
65
73
|
it('finds one in the shared .agents/skills/ too', () => {
|
|
66
74
|
write(home, { '.agents/skills/deploy-runbook/SKILL.md': skill('deploy-runbook') })
|
|
67
75
|
expect(run(project, 'promote', 'skill', 'deploy-runbook').status).toBe(0)
|
package/src/cli/promote.ts
CHANGED
|
@@ -103,10 +103,24 @@ function filesIn(dir: string): string[] {
|
|
|
103
103
|
|
|
104
104
|
// ── skill ─────────────────────────────────────────────────────
|
|
105
105
|
|
|
106
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* Where assistants keep a person's own skills.
|
|
108
|
+
*
|
|
109
|
+
* Claude Code's and Codex's under their config homes when those are moved:
|
|
110
|
+
* `promote memory` read `CLAUDE_CONFIG_DIR` and this did not, so one person's
|
|
111
|
+
* memories and skills were looked for in two different places.
|
|
112
|
+
*/
|
|
107
113
|
export function personalSkillDirs(): string[] {
|
|
108
114
|
const h = home()
|
|
109
|
-
|
|
115
|
+
const claude = process.env.CLAUDE_CONFIG_DIR || join(h, '.claude')
|
|
116
|
+
const codex = process.env.CODEX_HOME || join(h, '.codex')
|
|
117
|
+
return [
|
|
118
|
+
join(claude, 'skills'),
|
|
119
|
+
join(h, '.agents', 'skills'),
|
|
120
|
+
join(codex, 'skills'),
|
|
121
|
+
join(h, '.cursor', 'skills'),
|
|
122
|
+
join(h, '.copilot', 'skills'),
|
|
123
|
+
]
|
|
110
124
|
}
|
|
111
125
|
|
|
112
126
|
function findSkill(ref: string, cwd: string): string {
|
|
@@ -172,6 +172,25 @@ describe.skipIf(!built)('a repository extending a baseline', () => {
|
|
|
172
172
|
expect(init.out).toContain('in your shell — .env is committed here')
|
|
173
173
|
})
|
|
174
174
|
|
|
175
|
+
it('init run again leaves an unchanged manifest alone, timestamp and all', () => {
|
|
176
|
+
const path = join(dir, '.opencastle', 'manifest.json')
|
|
177
|
+
const before = readFileSync(path, 'utf8')
|
|
178
|
+
expect(run(dir, ['init', '--yes']).code).toBe(0)
|
|
179
|
+
expect(readFileSync(path, 'utf8')).toBe(before)
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
it('sync does not call a project healthy over a server only a person can fix', () => {
|
|
183
|
+
// Not on the baseline's allowlist, and added by hand: sync cannot change it.
|
|
184
|
+
const mcp = join(dir, '.vscode', 'mcp.json')
|
|
185
|
+
const config = JSON.parse(readFileSync(mcp, 'utf8'))
|
|
186
|
+
config.servers['my-tool'] = { command: 'npx', args: ['-y', 'my-tool-mcp@1.0.0'] }
|
|
187
|
+
writeFileSync(mcp, JSON.stringify(config, null, 2))
|
|
188
|
+
const sync = run(dir, ['sync', '--yes'])
|
|
189
|
+
expect(sync.code).toBe(0)
|
|
190
|
+
expect(sync.out).toContain('1 MCP server entry needs fixing by hand')
|
|
191
|
+
expect(sync.out).toContain('npx opencastle doctor')
|
|
192
|
+
})
|
|
193
|
+
|
|
175
194
|
it('init refuses to downgrade too', () => {
|
|
176
195
|
const path = join(dir, '.opencastle', 'manifest.json')
|
|
177
196
|
const manifest = JSON.parse(readFileSync(path, 'utf8'))
|
|
@@ -258,6 +277,15 @@ describe.skipIf(!built)('a baseline package', () => {
|
|
|
258
277
|
expect(report.contributes).toMatchObject({ skills: 1, instructions: 1 })
|
|
259
278
|
})
|
|
260
279
|
|
|
280
|
+
it('warns when the baseline is over its own context budget before a repository adds anything', () => {
|
|
281
|
+
run(dir, ['baseline', 'init', 'base', '--name', '@acme/base'])
|
|
282
|
+
const config = join(dir, 'base', 'dev.opencastle', 'config.json')
|
|
283
|
+
writeFileSync(config, readFileSync(config, 'utf8').replace(/"contextBudget": \d+/, '"contextBudget": 100'))
|
|
284
|
+
const check = run(dir, ['baseline', 'check', 'base'])
|
|
285
|
+
expect(check.code).toBe(0)
|
|
286
|
+
expect(check.out).toMatch(/dev\.opencastle\/config\.json: policy\.contextBudget is 100 tokens, but a repository extending this baseline starts at ~\d+/)
|
|
287
|
+
})
|
|
288
|
+
|
|
261
289
|
it('fails one whose layer sits outside the package, as every consumer would', () => {
|
|
262
290
|
run(dir, ['baseline', 'init', 'base', '--name', '@acme/base'])
|
|
263
291
|
const path = join(dir, 'base', 'package.json')
|
package/src/cli/team-config.ts
CHANGED
|
@@ -40,8 +40,15 @@ export interface TeamIssue {
|
|
|
40
40
|
|
|
41
41
|
const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/
|
|
42
42
|
export const ITEM_REF = new RegExp(`^(${CONTENT_KINDS.join('|')})/[A-Za-z0-9][A-Za-z0-9._-]*$`)
|
|
43
|
-
/**
|
|
44
|
-
|
|
43
|
+
/**
|
|
44
|
+
* What `exclude` may name: content, or an MCP server a layer below defines.
|
|
45
|
+
* Content takes `*` for any run of characters within a name — `skills/*` leaves
|
|
46
|
+
* out every skill from below, where a team that wanted only its own had to list
|
|
47
|
+
* each of them.
|
|
48
|
+
*/
|
|
49
|
+
export const EXCLUDE_REF = new RegExp(
|
|
50
|
+
`^(?:(${CONTENT_KINDS.join('|')})/[A-Za-z0-9*][A-Za-z0-9._*-]*|mcpServers/[A-Za-z0-9][A-Za-z0-9._-]*)$`,
|
|
51
|
+
)
|
|
45
52
|
|
|
46
53
|
const ItemRef = v.pipe(
|
|
47
54
|
v.string(),
|
|
@@ -49,7 +56,7 @@ const ItemRef = v.pipe(
|
|
|
49
56
|
)
|
|
50
57
|
const ExcludeRef = v.pipe(
|
|
51
58
|
v.string(),
|
|
52
|
-
v.regex(EXCLUDE_REF, 'must name a kind and an item, e.g. "skills/seo-patterns" or "mcpServers/Slack"'),
|
|
59
|
+
v.regex(EXCLUDE_REF, 'must name a kind and an item, e.g. "skills/seo-patterns", "skills/*" or "mcpServers/Slack"'),
|
|
53
60
|
)
|
|
54
61
|
|
|
55
62
|
const McpServer = v.strictObject({
|
package/src/cli/update.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isAbsolute, resolve, relative, join, dirname } from 'node:path'
|
|
2
2
|
import { existsSync } from 'node:fs'
|
|
3
3
|
import { readFile, mkdir, writeFile, unlink, copyFile, readdir, rm } from 'node:fs/promises'
|
|
4
|
-
import { readManifest, writeManifest } from './manifest.js'
|
|
4
|
+
import { readManifest, writeManifest, manifestMeaning } from './manifest.js'
|
|
5
5
|
import { multiselect, confirm, closePrompts, stdinIsExhausted, c } from './prompt.js'
|
|
6
6
|
import { isLegacyStack, migrateStackConfig, IDE_LABELS } from './types.js'
|
|
7
7
|
import { TECH_PLUGINS, TEAM_PLUGINS } from '../orchestrator/plugins/index.js'
|
|
@@ -50,19 +50,6 @@ function reportTeamIssues(resolved: ResolvedSources): void {
|
|
|
50
50
|
console.error('')
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
/**
|
|
54
|
-
* The manifest without the field that changes on every write.
|
|
55
|
-
*
|
|
56
|
-
* `updatedAt` changed on every sync, so two branches that both synced always
|
|
57
|
-
* conflicted on the manifest — in the one file every command reads first,
|
|
58
|
-
* where a conflict makes every command stop. Written only when something it
|
|
59
|
-
* records has actually changed.
|
|
60
|
-
*/
|
|
61
|
-
function manifestMeaning(m: Record<string, unknown>): string {
|
|
62
|
-
const { updatedAt: _u, installedAt: _i, ...rest } = m
|
|
63
|
-
return JSON.stringify(rest)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
53
|
const UPDATE_HELP = `
|
|
67
54
|
npx opencastle update [options]
|
|
68
55
|
|
|
@@ -261,6 +248,10 @@ export default async function update({
|
|
|
261
248
|
// generated file by hand — and gating on version equality meant `sync --check`
|
|
262
249
|
// could report drift while `sync` insisted everything was up to date. Compare
|
|
263
250
|
// against a fresh compile instead; recompiling is idempotent and cheap.
|
|
251
|
+
// MCP entries only a person can fix. They do not make `sync` recompile, but
|
|
252
|
+
// saying everything matches over them, while `sync --check` fails on them,
|
|
253
|
+
// told the user the opposite of the check.
|
|
254
|
+
let forAPerson = 0
|
|
264
255
|
const needsSync = await (async () => {
|
|
265
256
|
if (manifest.version !== pkg.version || forceFlag || reconfigureFlag) return true
|
|
266
257
|
// A generated config that will not parse is work outstanding, and the drift
|
|
@@ -306,6 +297,7 @@ export default async function update({
|
|
|
306
297
|
try {
|
|
307
298
|
const { buildCheckReport } = await import('./sync-check.js')
|
|
308
299
|
const report = await buildCheckReport(pkgRoot, projectRoot)
|
|
300
|
+
forAPerson = report.drift.filter((d) => d.origin === 'mcp' && d.kind === 'unreducible').length
|
|
309
301
|
// Not a broken MCP server only a person can fix: recompiling cannot clear
|
|
310
302
|
// it, and doing so on every run rewrote the committed manifest for nothing.
|
|
311
303
|
return report.drift.some((d) => !(d.origin === 'mcp' && d.kind === 'unreducible'))
|
|
@@ -342,6 +334,12 @@ export default async function update({
|
|
|
342
334
|
|
|
343
335
|
if (!needsSync && !dryRun) {
|
|
344
336
|
console.log(` ${c.green('✓')} Everything matches its sources (v${pkg.version}).`)
|
|
337
|
+
if (forAPerson > 0) {
|
|
338
|
+
console.log(
|
|
339
|
+
` ${c.yellow('!')} ${forAPerson} MCP server entr${forAPerson === 1 ? 'y needs' : 'ies need'} fixing by hand, ` +
|
|
340
|
+
`which sync cannot do — ${c.cyan('npx opencastle doctor')} names ${forAPerson === 1 ? 'it' : 'them'}.`,
|
|
341
|
+
)
|
|
342
|
+
}
|
|
345
343
|
// `--yes` means "do not ask me anything". This one slipped the guard, so a CI
|
|
346
344
|
// runner holding stdin open would block here on an up-to-date project, and
|
|
347
345
|
// `add`, which routes through sync, asked twice for one instruction.
|