opencastle 1.12.2 → 1.12.4
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/dist/cli/foreign-skills.d.ts +12 -0
- package/dist/cli/foreign-skills.d.ts.map +1 -0
- package/dist/cli/foreign-skills.js +70 -0
- package/dist/cli/foreign-skills.js.map +1 -0
- package/dist/cli/foreign-skills.test.d.ts +2 -0
- package/dist/cli/foreign-skills.test.d.ts.map +1 -0
- package/dist/cli/foreign-skills.test.js +100 -0
- package/dist/cli/foreign-skills.test.js.map +1 -0
- package/dist/cli/init-stack-order.test.d.ts +2 -0
- package/dist/cli/init-stack-order.test.d.ts.map +1 -0
- package/dist/cli/init-stack-order.test.js +52 -0
- package/dist/cli/init-stack-order.test.js.map +1 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +24 -3
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/sync-check.d.ts +4 -1
- package/dist/cli/sync-check.d.ts.map +1 -1
- package/dist/cli/sync-check.js +25 -2
- package/dist/cli/sync-check.js.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +15 -0
- package/dist/cli/update.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/foreign-skills.test.ts +117 -0
- package/src/cli/foreign-skills.ts +74 -0
- package/src/cli/init-stack-order.test.ts +61 -0
- package/src/cli/init.ts +23 -3
- package/src/cli/sync-check.ts +28 -3
- package/src/cli/update.ts +16 -0
package/src/cli/init.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { resolveSources, materialize, hasErrors, formatIssues, requiredEnvVars }
|
|
|
23
23
|
import { writeLessonRules } from './lessons-rules.js'
|
|
24
24
|
import { memoryHooksDrift } from './memory-hooks.js'
|
|
25
25
|
import { buildLock, writeLock, priorTeam } from './lock.js'
|
|
26
|
+
import { adoptForeignSkills, foreignSkills, skillFolders } from './foreign-skills.js'
|
|
26
27
|
import { parseVersion, compareVersions } from './version-range.js'
|
|
27
28
|
import { COMMAND_NAMESPACE } from './command-namespace.js'
|
|
28
29
|
|
|
@@ -297,8 +298,15 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
|
|
|
297
298
|
return [rel, existsSync(resolve(projectRoot, rel))]
|
|
298
299
|
}),
|
|
299
300
|
)
|
|
300
|
-
|
|
301
|
-
|
|
301
|
+
// The compiled agents name their tools in this order. A re-run lists them as
|
|
302
|
+
// the manifest already does, new ones after, or adding a target re-sorts the
|
|
303
|
+
// list and rewrites every agent with the same tools.
|
|
304
|
+
const keepOrder = (next: string[], before: readonly string[] = []): string[] => [
|
|
305
|
+
...before.filter((t) => next.includes(t)),
|
|
306
|
+
...next.filter((t) => !before.includes(t)),
|
|
307
|
+
]
|
|
308
|
+
const techTools = keepOrder(selection.techTools, isReinit ? existing?.stack?.techTools : undefined)
|
|
309
|
+
const teamTools = keepOrder(selection.teamTools, isReinit ? existing?.stack?.teamTools : undefined)
|
|
302
310
|
|
|
303
311
|
const stack: StackConfig = {
|
|
304
312
|
ides: ides as IdeChoice[],
|
|
@@ -321,7 +329,19 @@ export default async function init({ pkgRoot, args }: CliContext): Promise<void>
|
|
|
321
329
|
// The team's sources, before anything is written. A repository that already
|
|
322
330
|
// carries `.opencastle/config.json` — a clone of a team project being set up
|
|
323
331
|
// again — must compile to the same standard `sync` holds it to, or refuse.
|
|
324
|
-
|
|
332
|
+
let resolved = resolveSources({ pkgRoot, projectRoot, stack, repoInfo: combinedRepoInfo })
|
|
333
|
+
// Skills another tool already wrote where a target compiles them become the
|
|
334
|
+
// team's first, so this compile writes them for every assistant instead of
|
|
335
|
+
// leaving them for the next sync to sweep (foreign-skills.ts).
|
|
336
|
+
if (!dryRun && !hasErrors(resolved)) {
|
|
337
|
+
const foreign = foreignSkills(projectRoot, skillFolders((await declaredManagedPaths(ides)).framework), new Set(resolved.items.keys()))
|
|
338
|
+
if (foreign.length > 0) {
|
|
339
|
+
adoptForeignSkills(projectRoot, foreign)
|
|
340
|
+
console.log(` ${c.green('✓')} Kept ${foreign.length} skill(s) another tool added — moved into .opencastle/skills/, so every assistant gets ${foreign.length === 1 ? 'it' : 'them'}:`)
|
|
341
|
+
for (const f of foreign) console.log(` ${c.dim(`${f.from} → .opencastle/skills/${f.name}`)}`)
|
|
342
|
+
resolved = resolveSources({ pkgRoot, projectRoot, stack, repoInfo: combinedRepoInfo })
|
|
343
|
+
}
|
|
344
|
+
}
|
|
325
345
|
if (hasErrors(resolved)) {
|
|
326
346
|
const errors = resolved.issues.filter((i) => i.level === 'error')
|
|
327
347
|
console.error(`\n ${c.red('✗')} The team's sources have ${errors.length} problem(s); nothing was written.\n`)
|
package/src/cli/sync-check.ts
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
diagnoseManagedFile,
|
|
26
26
|
} from './managed-block.js'
|
|
27
27
|
import { c } from './prompt.js'
|
|
28
|
+
import { foreignSkills, skillFolders } from './foreign-skills.js'
|
|
28
29
|
import { reportToGitHub, COMPARISON_FAILED } from './github-report.js'
|
|
29
30
|
import type { CliContext, IdeChoice, StackConfig } from './types.js'
|
|
30
31
|
|
|
@@ -64,8 +65,11 @@ export interface Drift {
|
|
|
64
65
|
* `team` is a problem in the team's own sources — a config that will not
|
|
65
66
|
* parse, a baseline that is not installed, a policy the sources break. The
|
|
66
67
|
* comparison cannot run until it is fixed, and `sync` refuses to compile.
|
|
68
|
+
*
|
|
69
|
+
* `foreign` is a skill another tool wrote into a compiled folder, which
|
|
70
|
+
* `sync` keeps by moving it into the team's sources (foreign-skills.ts).
|
|
67
71
|
*/
|
|
68
|
-
origin?: 'mcp' | 'team' | 'version' | 'memory'
|
|
72
|
+
origin?: 'mcp' | 'team' | 'version' | 'memory' | 'foreign'
|
|
69
73
|
/** The classifier's own words, so the checker and `doctor` cannot diverge. */
|
|
70
74
|
detail?: string
|
|
71
75
|
/** What resolves it, per entry — these do not share a remedy. */
|
|
@@ -382,6 +386,20 @@ async function compareProject(
|
|
|
382
386
|
}
|
|
383
387
|
}
|
|
384
388
|
|
|
389
|
+
// A skill another tool wrote into a compiled folder is not swept: `sync`
|
|
390
|
+
// makes it the team's (foreign-skills.ts). Still drift, since the other
|
|
391
|
+
// assistants lack it until then, but it is not "removed on the next sync".
|
|
392
|
+
{
|
|
393
|
+
const framework = (await Promise.all(ides.map(async (ide) => (await IDE_ADAPTERS[ide]()).getManagedPaths().framework))).flat()
|
|
394
|
+
for (const skill of foreignSkills(projectRoot, skillFolders(framework), new Set(resolved.items.keys()))) {
|
|
395
|
+
for (const d of drift) {
|
|
396
|
+
if (d.kind !== 'extra' || (d.path !== skill.from && !d.path.startsWith(`${skill.from}/`))) continue
|
|
397
|
+
d.origin = 'foreign'
|
|
398
|
+
d.detail = `added by another tool — sync moves it into .opencastle/skills/${skill.name}/`
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
385
403
|
// The lock: what every assistant is given, as `sync` would record it now.
|
|
386
404
|
// Compared like any generated file, because it is one — a stale lock is a
|
|
387
405
|
// review of something other than what was compiled.
|
|
@@ -771,9 +789,16 @@ function render(report: CheckReport): void {
|
|
|
771
789
|
for (const d of missingFiles) console.log(` ${c.red('-')} ${d.path} ${c.dim(`(${d.ide})`)}`)
|
|
772
790
|
console.log('')
|
|
773
791
|
}
|
|
774
|
-
|
|
792
|
+
const kept = extra.filter((d) => d.origin === 'foreign')
|
|
793
|
+
const swept = extra.filter((d) => d.origin !== 'foreign')
|
|
794
|
+
if (kept.length > 0) {
|
|
795
|
+
console.log(` ${c.bold('Skills another tool added')} ${c.dim('(the next sync keeps them: moved into .opencastle/skills/ and compiled for every assistant)')}`)
|
|
796
|
+
for (const d of kept) console.log(` ${c.green('+')} ${d.path} ${c.dim(`(${d.ide})`)}`)
|
|
797
|
+
console.log('')
|
|
798
|
+
}
|
|
799
|
+
if (swept.length > 0) {
|
|
775
800
|
console.log(` ${c.bold('Not produced by any source')} ${c.dim('(removed on the next sync)')}`)
|
|
776
|
-
for (const d of
|
|
801
|
+
for (const d of swept) console.log(` ${c.red('+')} ${d.path} ${c.dim(`(${d.ide}${d.detail ? ` — ${d.detail}` : ''})`)}`)
|
|
777
802
|
console.log('')
|
|
778
803
|
}
|
|
779
804
|
|
package/src/cli/update.ts
CHANGED
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
type ResolvedSources,
|
|
30
30
|
} from './layers.js'
|
|
31
31
|
import { buildLock, writeLock, readLock, LOCK_REL, priorTeam } from './lock.js'
|
|
32
|
+
import { adoptForeignSkills, foreignSkills, skillFolders } from './foreign-skills.js'
|
|
32
33
|
import { parseVersion, compareVersions } from './version-range.js'
|
|
33
34
|
import { COMMAND_NAMESPACE } from './command-namespace.js'
|
|
34
35
|
import { parseMcpConfigText } from './mcp-file.js'
|
|
@@ -225,6 +226,21 @@ export default async function update({
|
|
|
225
226
|
console.error(` ${c.dim('npm install, or your package manager\'s — or pass --allow-downgrade to go back on purpose.')}\n`)
|
|
226
227
|
process.exit(1)
|
|
227
228
|
}
|
|
229
|
+
|
|
230
|
+
// Skills another tool wrote into a folder this compiles: made the team's
|
|
231
|
+
// before anything is compiled, so this sync writes them for every assistant
|
|
232
|
+
// instead of sweeping them (foreign-skills.ts).
|
|
233
|
+
const framework = (await resolveManagedPaths({ ...manifest, ides })).framework
|
|
234
|
+
const foreign = foreignSkills(projectRoot, skillFolders(framework), new Set(early.items.keys()))
|
|
235
|
+
if (foreign.length > 0) {
|
|
236
|
+
const dry = args.includes('--dry-run') || args.includes('--dryRun')
|
|
237
|
+
if (!dry) adoptForeignSkills(projectRoot, foreign)
|
|
238
|
+
console.log(
|
|
239
|
+
` ${c.green('✓')} ${dry ? 'Would keep' : 'Kept'} ${foreign.length} skill(s) another tool added — ` +
|
|
240
|
+
`${dry ? 'moving' : 'moved'} into .opencastle/skills/, so every assistant gets ${foreign.length === 1 ? 'it' : 'them'}:`,
|
|
241
|
+
)
|
|
242
|
+
for (const s of foreign) console.log(` ${c.dim(`${s.from} → .opencastle/skills/${s.name}`)}`)
|
|
243
|
+
}
|
|
228
244
|
}
|
|
229
245
|
|
|
230
246
|
// ── Recreate the local-only directories ─────────────────────────
|