opencastle 1.0.0 → 1.1.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.
- package/README.md +9 -4
- package/dist/cli/adapters/claude-code.d.ts +8 -4
- package/dist/cli/adapters/claude-code.d.ts.map +1 -1
- package/dist/cli/adapters/claude-code.js +13 -7
- package/dist/cli/adapters/claude-code.js.map +1 -1
- package/dist/cli/adapters/codex.d.ts +19 -6
- package/dist/cli/adapters/codex.d.ts.map +1 -1
- package/dist/cli/adapters/codex.js +24 -7
- package/dist/cli/adapters/codex.js.map +1 -1
- package/dist/cli/adapters/single-file-base.d.ts +15 -1
- package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
- package/dist/cli/adapters/single-file-base.js +46 -21
- package/dist/cli/adapters/single-file-base.js.map +1 -1
- package/dist/cli/adapters/vscode.d.ts +11 -1
- package/dist/cli/adapters/vscode.d.ts.map +1 -1
- package/dist/cli/adapters/vscode.js +48 -8
- package/dist/cli/adapters/vscode.js.map +1 -1
- package/dist/cli/codex-target.test.d.ts +2 -0
- package/dist/cli/codex-target.test.d.ts.map +1 -0
- package/dist/cli/codex-target.test.js +154 -0
- package/dist/cli/codex-target.test.js.map +1 -0
- package/dist/cli/command-namespace.d.ts +91 -0
- package/dist/cli/command-namespace.d.ts.map +1 -0
- package/dist/cli/command-namespace.js +218 -0
- package/dist/cli/command-namespace.js.map +1 -0
- package/dist/cli/command-namespace.test.d.ts +2 -0
- package/dist/cli/command-namespace.test.d.ts.map +1 -0
- package/dist/cli/command-namespace.test.js +356 -0
- package/dist/cli/command-namespace.test.js.map +1 -0
- package/dist/cli/copy.d.ts +1 -1
- package/dist/cli/copy.d.ts.map +1 -1
- package/dist/cli/copy.js +3 -2
- package/dist/cli/copy.js.map +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +2 -1
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/doctor.test.js +2 -2
- package/dist/cli/doctor.test.js.map +1 -1
- package/dist/cli/explain.d.ts.map +1 -1
- package/dist/cli/explain.js +13 -1
- package/dist/cli/explain.js.map +1 -1
- package/dist/cli/github-report.js +1 -1
- package/dist/cli/github-report.js.map +1 -1
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +45 -10
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/init.test.js +31 -14
- package/dist/cli/init.test.js.map +1 -1
- package/dist/cli/managed-paths.d.ts +18 -1
- package/dist/cli/managed-paths.d.ts.map +1 -1
- package/dist/cli/managed-paths.js +74 -2
- package/dist/cli/managed-paths.js.map +1 -1
- package/dist/cli/manifest.d.ts.map +1 -1
- package/dist/cli/manifest.js +2 -0
- package/dist/cli/manifest.js.map +1 -1
- package/dist/cli/mcp-audit.d.ts.map +1 -1
- package/dist/cli/mcp-audit.js +7 -3
- package/dist/cli/mcp-audit.js.map +1 -1
- package/dist/cli/mcp-file.d.ts +37 -0
- package/dist/cli/mcp-file.d.ts.map +1 -0
- package/dist/cli/mcp-file.js +291 -0
- package/dist/cli/mcp-file.js.map +1 -0
- package/dist/cli/mcp-file.test.d.ts +2 -0
- package/dist/cli/mcp-file.test.d.ts.map +1 -0
- package/dist/cli/mcp-file.test.js +121 -0
- package/dist/cli/mcp-file.test.js.map +1 -0
- package/dist/cli/mcp.d.ts +15 -0
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +123 -56
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/remove.d.ts.map +1 -1
- package/dist/cli/remove.js +45 -8
- package/dist/cli/remove.js.map +1 -1
- package/dist/cli/sync-check.d.ts.map +1 -1
- package/dist/cli/sync-check.js +26 -7
- package/dist/cli/sync-check.js.map +1 -1
- package/dist/cli/sync-check.test.js +2 -2
- package/dist/cli/sync-check.test.js.map +1 -1
- package/dist/cli/types.d.ts +37 -2
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/types.js +3 -0
- package/dist/cli/types.js.map +1 -1
- package/dist/cli/unreadable-report.d.ts +7 -0
- package/dist/cli/unreadable-report.d.ts.map +1 -1
- package/dist/cli/unreadable-report.js +14 -0
- package/dist/cli/unreadable-report.js.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +69 -5
- package/dist/cli/update.js.map +1 -1
- package/package.json +3 -2
- package/src/cli/adapters/claude-code.ts +13 -7
- package/src/cli/adapters/codex.ts +25 -7
- package/src/cli/adapters/single-file-base.ts +66 -26
- package/src/cli/adapters/vscode.ts +51 -10
- package/src/cli/codex-target.test.ts +178 -0
- package/src/cli/command-namespace.test.ts +417 -0
- package/src/cli/command-namespace.ts +222 -0
- package/src/cli/copy.ts +6 -2
- package/src/cli/doctor.test.ts +2 -2
- package/src/cli/doctor.ts +3 -2
- package/src/cli/explain.ts +13 -1
- package/src/cli/github-report.ts +1 -1
- package/src/cli/init.test.ts +31 -14
- package/src/cli/init.ts +48 -11
- package/src/cli/managed-paths.ts +75 -3
- package/src/cli/manifest.ts +2 -0
- package/src/cli/mcp-audit.ts +7 -3
- package/src/cli/mcp-file.test.ts +138 -0
- package/src/cli/mcp-file.ts +302 -0
- package/src/cli/mcp.ts +130 -60
- package/src/cli/remove.ts +40 -8
- package/src/cli/sync-check.test.ts +2 -2
- package/src/cli/sync-check.ts +23 -6
- package/src/cli/types.ts +37 -2
- package/src/cli/unreadable-report.ts +14 -0
- package/src/cli/update.ts +73 -5
- package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
- package/src/orchestrator/prompts/bootstrap-customizations.prompt.md +4 -4
package/src/cli/remove.ts
CHANGED
|
@@ -6,11 +6,13 @@ import { removeDirIfExists } from './copy.js'
|
|
|
6
6
|
import { removeGitignoreBlock, predictGitignoreStrip, LOCAL_DIRS } from './gitignore.js'
|
|
7
7
|
import { confirm, select, closePrompts, c } from './prompt.js'
|
|
8
8
|
import { stripManagedBlockFromFile, predictStripFile } from './managed-block.js'
|
|
9
|
-
import { resolveManagedPaths } from './managed-paths.js'
|
|
10
|
-
import { stripManagedMcpServers, getMcpConfigRelPath, willKeepSomethingAfterStrip } from './mcp.js'
|
|
9
|
+
import { resolveManagedPaths, ownerOf, removeOwnedFiles } from './managed-paths.js'
|
|
10
|
+
import { stripManagedMcpServers, getMcpConfigRelPath, willKeepSomethingAfterStrip, retireLegacyMcpConfig, LEGACY_MCP_CONFIGS } from './mcp.js'
|
|
11
11
|
import { priorTeam } from './lock.js'
|
|
12
12
|
import { IDE_ADAPTERS } from './adapters/index.js'
|
|
13
13
|
import type { CliContext, IdeChoice } from './types.js'
|
|
14
|
+
import { whyLeftAlone } from './unreadable-report.js'
|
|
15
|
+
import { parseMcpConfigText } from './mcp-file.js'
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Removal, with the destructive choice made explicit rather than encoded in the
|
|
@@ -104,7 +106,7 @@ async function previewCoOwned(
|
|
|
104
106
|
let keepsSomething = true
|
|
105
107
|
let tookAnything = false
|
|
106
108
|
try {
|
|
107
|
-
const parsed =
|
|
109
|
+
const parsed = parseMcpConfigText(await readFile(abs, 'utf8'), p)
|
|
108
110
|
// Captured before the predicate runs — it edits `parsed` in place.
|
|
109
111
|
const untouched = JSON.stringify(parsed)
|
|
110
112
|
keepsSomething = willKeepSomethingAfterStrip(parsed, ideFor.get(p), ...priorTeam(projectRoot))
|
|
@@ -212,11 +214,29 @@ export default async function remove({ args }: CliContext): Promise<void> {
|
|
|
212
214
|
(id): id is IdeChoice => Boolean(id) && id in IDE_ADAPTERS,
|
|
213
215
|
)
|
|
214
216
|
const mcpOwner = new Map(ides.map((ide) => [getMcpConfigRelPath(ide), ide]))
|
|
215
|
-
|
|
217
|
+
// A config an earlier release wrote where its assistant never looked is ours
|
|
218
|
+
// to take back too. It has no owner in `mcpOwner` on purpose: it is in the
|
|
219
|
+
// shape it was written in, so the preview reads it as any config.
|
|
220
|
+
const legacyMcp = ides.flatMap((ide) => {
|
|
221
|
+
const rel = LEGACY_MCP_CONFIGS[ide]
|
|
222
|
+
return rel && existsSync(resolve(projectRoot, rel)) ? [rel] : []
|
|
223
|
+
})
|
|
224
|
+
const mcpPaths = new Set([...mcpOwner.keys(), ...legacyMcp])
|
|
216
225
|
// An install from before this field existed records nothing, and absence means
|
|
217
226
|
// "unknown" — which is treated as "not ours to delete".
|
|
218
227
|
const createdConfigs = new Set(manifest.createdConfigs ?? [])
|
|
219
|
-
|
|
228
|
+
// Commands a release before the namespace left at the top of `.claude/commands/`,
|
|
229
|
+
// outside today's framework directories — found by the banner they carry, so
|
|
230
|
+
// a command the user wrote there is not among them.
|
|
231
|
+
const legacyOutputs: string[] = []
|
|
232
|
+
const adapters = await Promise.all(ides.map((ide) => IDE_ADAPTERS[ide]()))
|
|
233
|
+
for (const adapter of adapters) {
|
|
234
|
+
legacyOutputs.push(...(adapter.getLegacyOutputs?.(projectRoot) ?? []))
|
|
235
|
+
}
|
|
236
|
+
const frameworkPaths = [
|
|
237
|
+
...managed.framework.filter((p) => !mcpPaths.has(p)),
|
|
238
|
+
...legacyOutputs.filter((p) => !managed.framework.includes(p)),
|
|
239
|
+
]
|
|
220
240
|
// `.opencastle/` is handled explicitly below, so drop it here — listing it in
|
|
221
241
|
// both places printed it twice and counted it twice in "Removed N path(s)".
|
|
222
242
|
const customizablePaths = managed.customizable.filter(
|
|
@@ -236,7 +256,9 @@ export default async function remove({ args }: CliContext): Promise<void> {
|
|
|
236
256
|
} else {
|
|
237
257
|
console.log(` ${c.bold('Deleted')}\n`)
|
|
238
258
|
for (const p of [...frameworkPaths, ...customizablePaths]) {
|
|
239
|
-
|
|
259
|
+
// A directory shared with the user — `.github/prompts/` — loses only ours.
|
|
260
|
+
const shared = ownerOf(adapters, p, projectRoot) ? c.dim(' — only the files OpenCastle wrote') : ''
|
|
261
|
+
console.log(` ${c.red('-')} ${c.dim(p)}${shared}`)
|
|
240
262
|
}
|
|
241
263
|
// Named plainly: this is the one path in the list that holds writing of the
|
|
242
264
|
// user's own, and the command spends the rest of its effort preserving
|
|
@@ -317,7 +339,10 @@ export default async function remove({ args }: CliContext): Promise<void> {
|
|
|
317
339
|
// Only if it was there. The manifest still lists paths for a target that
|
|
318
340
|
// has since been dropped, so the count claimed to have removed
|
|
319
341
|
// directories that had not existed for releases.
|
|
320
|
-
|
|
342
|
+
const owns = ownerOf(adapters, p, projectRoot)
|
|
343
|
+
if (owns) {
|
|
344
|
+
if (removeOwnedFiles(projectRoot, p, owns) > 0) removed++
|
|
345
|
+
} else if (existsSync(resolve(projectRoot, p))) {
|
|
321
346
|
await removeDirIfExists(resolve(projectRoot, p))
|
|
322
347
|
removed++
|
|
323
348
|
}
|
|
@@ -363,6 +388,13 @@ export default async function remove({ args }: CliContext): Promise<void> {
|
|
|
363
388
|
else if (outcome === 'unreadable') unreadable.push(getMcpConfigRelPath(ide))
|
|
364
389
|
const mcpParent = dirname(resolve(projectRoot, getMcpConfigRelPath(ide)))
|
|
365
390
|
if (mcpParent !== projectRoot) parents.add(mcpParent)
|
|
391
|
+
const legacyRel = LEGACY_MCP_CONFIGS[ide]
|
|
392
|
+
if (legacyRel) {
|
|
393
|
+
const legacy = await retireLegacyMcpConfig(projectRoot, ide, createdConfigs.has(legacyRel), ...priorTeam(projectRoot))
|
|
394
|
+
if (legacy === 'deleted') removed++
|
|
395
|
+
else if (legacy === 'stripped') stripped++
|
|
396
|
+
else if (legacy === 'unreadable') unreadable.push(legacyRel)
|
|
397
|
+
}
|
|
366
398
|
}
|
|
367
399
|
|
|
368
400
|
// The containers our own directories lived in. `.claude/agents/`, `skills/`
|
|
@@ -441,7 +473,7 @@ export default async function remove({ args }: CliContext): Promise<void> {
|
|
|
441
473
|
const [name, why] = entry.split('\u0000')
|
|
442
474
|
console.log(
|
|
443
475
|
` ${c.yellow('!')} Left ${name} alone — ` +
|
|
444
|
-
(why
|
|
476
|
+
whyLeftAlone(name, why),
|
|
445
477
|
)
|
|
446
478
|
}
|
|
447
479
|
if (keptDir) {
|
|
@@ -213,10 +213,10 @@ describe('two targets that share a root file', () => {
|
|
|
213
213
|
const text = readFileSync(join(projectRoot, 'AGENTS.md'), 'utf8')
|
|
214
214
|
expect(text).toContain('shared by more than one assistant')
|
|
215
215
|
expect(text).toContain('.opencode/skills/')
|
|
216
|
-
expect(text).
|
|
216
|
+
expect(text).toContain('`.codex/`, `.agents/skills/`')
|
|
217
217
|
// Both assistants still get their own files.
|
|
218
218
|
expect(existsSync(join(projectRoot, '.opencode', 'skills'))).toBe(true)
|
|
219
|
-
expect(existsSync(join(projectRoot, '.
|
|
219
|
+
expect(existsSync(join(projectRoot, '.agents', 'skills'))).toBe(true)
|
|
220
220
|
})
|
|
221
221
|
})
|
|
222
222
|
|
package/src/cli/sync-check.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { tmpdir } from 'node:os'
|
|
|
4
4
|
import { readManifest } from './manifest.js'
|
|
5
5
|
import { IDE_ADAPTERS } from './adapters/index.js'
|
|
6
6
|
import { detectRepoInfo, mergeStackIntoRepoInfo } from './detect.js'
|
|
7
|
-
import { getMcpConfigRelPath, expectedTeamEntries } from './mcp.js'
|
|
7
|
+
import { getMcpConfigRelPath, expectedTeamEntries, containerKeyFor } from './mcp.js'
|
|
8
|
+
import { parseMcpConfigText } from './mcp-file.js'
|
|
8
9
|
import { resolveStack, getIncludedMcpServers } from './stack-config.js'
|
|
9
10
|
import { auditMcpConfig, describeFindingUnder, remedyFor, isFailure, type TeamAuditContext } from './mcp-audit.js'
|
|
10
11
|
import { resolveSources, materialize, hasErrors, cliVersionOf, type CompileSource } from './layers.js'
|
|
@@ -164,6 +165,7 @@ function comparePath(
|
|
|
164
165
|
projectRoot: string,
|
|
165
166
|
ide: string,
|
|
166
167
|
drift: Drift[],
|
|
168
|
+
owns?: (_rel: string) => boolean,
|
|
167
169
|
): number {
|
|
168
170
|
const fresh = resolve(freshRoot, managedPath)
|
|
169
171
|
const actual = resolve(projectRoot, managedPath)
|
|
@@ -208,7 +210,11 @@ function comparePath(
|
|
|
208
210
|
const expected = new Set(generated)
|
|
209
211
|
for (const rel of filesUnder(actual)) {
|
|
210
212
|
if (expected.has(rel)) continue
|
|
211
|
-
|
|
213
|
+
const shown = `${managedPath.replace(/\/$/, '')}/${rel}`
|
|
214
|
+
// A file the target shares the directory with someone over — their own
|
|
215
|
+
// prompt beside ours in `.github/prompts/` — is not drift.
|
|
216
|
+
if (owns && !owns(shown)) continue
|
|
217
|
+
drift.push({ ide, path: shown, kind: 'extra' })
|
|
212
218
|
}
|
|
213
219
|
return checked
|
|
214
220
|
}
|
|
@@ -347,7 +353,18 @@ async function compareProject(
|
|
|
347
353
|
// most likely to be edited by hand, would be the only thing never checked.
|
|
348
354
|
const managed = adapter.getManagedPaths()
|
|
349
355
|
for (const managedPath of [...managed.framework, ...(managed.merged ?? [])]) {
|
|
350
|
-
checked += comparePath(managedPath, scratch, projectRoot, ide, drift
|
|
356
|
+
checked += comparePath(managedPath, scratch, projectRoot, ide, drift, adapter.ownsFile
|
|
357
|
+
? (rel) => adapter.ownsFile!(rel, projectRoot)
|
|
358
|
+
: undefined)
|
|
359
|
+
}
|
|
360
|
+
// Output an earlier release left where this one no longer writes — a
|
|
361
|
+
// stale `/bug-fix` beside `/oc:bug-fix`. The next sync removes it.
|
|
362
|
+
for (const rel of adapter.getLegacyOutputs?.(projectRoot) ?? []) {
|
|
363
|
+
const detail = 'written by a release before the oc: namespace'
|
|
364
|
+
// A legacy prompt inside a compared directory is already reported.
|
|
365
|
+
const seen = drift.find((d) => d.ide === ide && d.path === rel)
|
|
366
|
+
if (seen) seen.detail = detail
|
|
367
|
+
else drift.push({ ide, path: rel, kind: 'extra', detail })
|
|
351
368
|
}
|
|
352
369
|
} finally {
|
|
353
370
|
rmSync(scratch, { recursive: true, force: true })
|
|
@@ -535,7 +552,7 @@ async function compareProject(
|
|
|
535
552
|
}
|
|
536
553
|
let parsed: unknown
|
|
537
554
|
try {
|
|
538
|
-
parsed =
|
|
555
|
+
parsed = parseMcpConfigText(readFileSync(abs, 'utf8'), rel)
|
|
539
556
|
} catch (err) {
|
|
540
557
|
drift.push({
|
|
541
558
|
ide,
|
|
@@ -556,7 +573,7 @@ async function compareProject(
|
|
|
556
573
|
// Leaving the second out let `doctor` say "sync removes it" while this
|
|
557
574
|
// passed and `sync` short-circuited — a remedy that did nothing.
|
|
558
575
|
const teamKeys = new Set(Object.keys(team.expected))
|
|
559
|
-
const container = (parsed as Record<string, unknown> | null)?.[ide
|
|
576
|
+
const container = (parsed as Record<string, unknown> | null)?.[containerKeyFor(ide as IdeChoice)]
|
|
560
577
|
const present = new Set(container && typeof container === 'object' ? Object.keys(container as object) : [])
|
|
561
578
|
const pluginOutdated = audit.outdated.filter((k) => !teamKeys.has(k))
|
|
562
579
|
const teamMissing = audit.outdated.filter((k) => teamKeys.has(k) && !present.has(k))
|
|
@@ -712,7 +729,7 @@ function render(report: CheckReport): void {
|
|
|
712
729
|
}
|
|
713
730
|
if (extra.length > 0) {
|
|
714
731
|
console.log(` ${c.bold('Not produced by any source')} ${c.dim('(removed on the next sync)')}`)
|
|
715
|
-
for (const d of extra) console.log(` ${c.red('+')} ${d.path} ${c.dim(`(${d.ide})`)}`)
|
|
732
|
+
for (const d of extra) console.log(` ${c.red('+')} ${d.path} ${c.dim(`(${d.ide}${d.detail ? ` — ${d.detail}` : ''})`)}`)
|
|
716
733
|
console.log('')
|
|
717
734
|
}
|
|
718
735
|
|
package/src/cli/types.ts
CHANGED
|
@@ -110,6 +110,8 @@ export interface CopyResults {
|
|
|
110
110
|
export interface CopyDirOptions {
|
|
111
111
|
overwrite?: boolean;
|
|
112
112
|
filter?: (_name: string, _srcPath: string) => boolean;
|
|
113
|
+
/** The name a file is installed under, given its source name. Directories keep theirs. */
|
|
114
|
+
rename?: (_name: string) => string;
|
|
113
115
|
transform?: (
|
|
114
116
|
_content: string,
|
|
115
117
|
_srcPath: string
|
|
@@ -157,6 +159,13 @@ export interface Manifest {
|
|
|
157
159
|
* "unknown", which is treated as "not ours to delete".
|
|
158
160
|
*/
|
|
159
161
|
createdConfigs?: string[];
|
|
162
|
+
/**
|
|
163
|
+
* The namespace this install's commands are compiled under — `oc`. Absent on
|
|
164
|
+
* a project a release before the namespace compiled, which is how `sync`
|
|
165
|
+
* knows to look for the un-namespaced commands it left (`/bug-fix` beside
|
|
166
|
+
* `/oc:bug-fix`), and how it knows to stop looking afterwards.
|
|
167
|
+
*/
|
|
168
|
+
commandNamespace?: string;
|
|
160
169
|
stack?: StackConfig;
|
|
161
170
|
repoInfo?: RepoInfo;
|
|
162
171
|
}
|
|
@@ -212,6 +221,29 @@ export interface IdeAdapter {
|
|
|
212
221
|
): Promise<CopyResults>;
|
|
213
222
|
getManagedPaths(): ManagedPaths;
|
|
214
223
|
getDoctorChecks(): DoctorCheck[];
|
|
224
|
+
/**
|
|
225
|
+
* Files an earlier release wrote under a name this one no longer uses —
|
|
226
|
+
* `/bug-fix` before it became `/oc:bug-fix` — present on disk now, relative to
|
|
227
|
+
* the project root with forward slashes. `sync` removes them, `sync --check`
|
|
228
|
+
* reports them, `remove` takes them with the rest, and `init` reads them as a
|
|
229
|
+
* previous installation. Absent when a target has never renamed its output.
|
|
230
|
+
*/
|
|
231
|
+
getLegacyOutputs?(_projectRoot: string): string[];
|
|
232
|
+
/**
|
|
233
|
+
* Framework directories this target shares with the user — `.github/prompts/`,
|
|
234
|
+
* which VS Code reads only at its top, so OpenCastle's `oc.` files and a
|
|
235
|
+
* person's own sit side by side. `remove` and a dropped target's cleanup take
|
|
236
|
+
* only what `ownsFile` claims there; every other framework directory is
|
|
237
|
+
* removed whole.
|
|
238
|
+
*/
|
|
239
|
+
getSharedDirs?(): string[];
|
|
240
|
+
/**
|
|
241
|
+
* Whether a file under one of this target's framework directories is one it
|
|
242
|
+
* wrote. Sweeps and drift leave a file that answers no alone. Absent means
|
|
243
|
+
* every file there is the target's. `_rel` is relative to the project root,
|
|
244
|
+
* with forward slashes.
|
|
245
|
+
*/
|
|
246
|
+
ownsFile?(_rel: string, _projectRoot: string): boolean;
|
|
215
247
|
}
|
|
216
248
|
|
|
217
249
|
/** Select prompt option. */
|
|
@@ -259,12 +291,15 @@ export class UnreadableConfigError extends Error {
|
|
|
259
291
|
* "It is not valid JSON" was printed for a path that was a *directory* — the
|
|
260
292
|
* remedy offered ("fix the file") did not match the fault, and the user had
|
|
261
293
|
* nothing to act on.
|
|
294
|
+
*
|
|
295
|
+
* `uneditable` is a TOML config that parses but holds its MCP servers in a
|
|
296
|
+
* form that cannot be changed without rewriting the user's text.
|
|
262
297
|
*/
|
|
263
|
-
readonly reason: 'unparseable' | 'unreadable';
|
|
298
|
+
readonly reason: 'unparseable' | 'unreadable' | 'uneditable';
|
|
264
299
|
|
|
265
300
|
constructor(
|
|
266
301
|
public readonly file: string,
|
|
267
|
-
reason: 'unparseable' | 'unreadable' = 'unparseable',
|
|
302
|
+
reason: 'unparseable' | 'unreadable' | 'uneditable' = 'unparseable',
|
|
268
303
|
) {
|
|
269
304
|
super(`Cannot read ${file}`);
|
|
270
305
|
this.name = 'UnreadableConfigError';
|
|
@@ -14,6 +14,20 @@
|
|
|
14
14
|
* printing the same report from separately maintained copies of the same logic is
|
|
15
15
|
* the shape that produced the disagreement in the first place.
|
|
16
16
|
*/
|
|
17
|
+
/**
|
|
18
|
+
* Why a file was left alone, as the end of "Left <file> alone — …".
|
|
19
|
+
*
|
|
20
|
+
* Each caller used to spell this itself, as "it is not valid JSON" — true of
|
|
21
|
+
* every config until Codex's, which is TOML.
|
|
22
|
+
*/
|
|
23
|
+
export function whyLeftAlone(name: string, why: string | undefined): string {
|
|
24
|
+
if (why === 'unreadable') return 'it could not be read.'
|
|
25
|
+
if (why === 'uneditable') {
|
|
26
|
+
return 'its MCP servers are written in a form this cannot change without rewriting yours — give each one its own [mcp_servers.<name>] table.'
|
|
27
|
+
}
|
|
28
|
+
return `it is not valid ${name.endsWith('.toml') ? 'TOML' : 'JSON'}.`
|
|
29
|
+
}
|
|
30
|
+
|
|
17
31
|
export function noteUnreadable(into: string[], entry: string): void {
|
|
18
32
|
const SEP = '\u0000'
|
|
19
33
|
const [name, why] = entry.split(SEP)
|
package/src/cli/update.ts
CHANGED
|
@@ -13,13 +13,13 @@ import {
|
|
|
13
13
|
getCustomizationsTransform,
|
|
14
14
|
isEnvVarSatisfied,
|
|
15
15
|
} from './stack-config.js'
|
|
16
|
-
import { rebuildMcpConfig, getMcpConfigRelPath } from './mcp.js'
|
|
16
|
+
import { rebuildMcpConfig, getMcpConfigRelPath, retireLegacyMcpConfig, LEGACY_MCP_CONFIGS } from './mcp.js'
|
|
17
17
|
import { updateGitignore, LOCAL_DIRS } from './gitignore.js'
|
|
18
18
|
import { resolveManagedPaths, REQUIRED_CUSTOMIZATIONS } from './managed-paths.js'
|
|
19
19
|
import { detectRepoInfo, mergeStackIntoRepoInfo, buildDetectedToolsSet } from './detect.js'
|
|
20
20
|
import type { CliContext, IdeChoice, TechTool, TeamTool, StackConfig } from './types.js'
|
|
21
21
|
import { UnreadableConfigError } from './types.js'
|
|
22
|
-
import { noteUnreadable } from './unreadable-report.js'
|
|
22
|
+
import { noteUnreadable, whyLeftAlone } from './unreadable-report.js'
|
|
23
23
|
import {
|
|
24
24
|
resolveSources,
|
|
25
25
|
materialize,
|
|
@@ -31,6 +31,14 @@ import {
|
|
|
31
31
|
} from './layers.js'
|
|
32
32
|
import { buildLock, writeLock, LOCK_REL, priorTeam } from './lock.js'
|
|
33
33
|
import { parseVersion, compareVersions } from './version-range.js'
|
|
34
|
+
import { COMMAND_NAMESPACE } from './command-namespace.js'
|
|
35
|
+
import { parseMcpConfigText } from './mcp-file.js'
|
|
36
|
+
|
|
37
|
+
/** The config that replaced a legacy one, for the sentence that reports it. */
|
|
38
|
+
function configBesideLegacy(rel: string, ides: string[]): string {
|
|
39
|
+
const ide = ides.find((i) => LEGACY_MCP_CONFIGS[i as IdeChoice] === rel)
|
|
40
|
+
return ide ? getMcpConfigRelPath(ide as IdeChoice) : 'the assistant\'s own config'
|
|
41
|
+
}
|
|
34
42
|
|
|
35
43
|
/** Print what is wrong with the team's sources, and that nothing was written. */
|
|
36
44
|
function reportTeamIssues(resolved: ResolvedSources): void {
|
|
@@ -246,7 +254,7 @@ export default async function update({
|
|
|
246
254
|
const abs = resolve(projectRoot, rel)
|
|
247
255
|
if (!existsSync(abs)) continue
|
|
248
256
|
try {
|
|
249
|
-
|
|
257
|
+
parseMcpConfigText(await readFile(abs, 'utf8'), rel)
|
|
250
258
|
} catch {
|
|
251
259
|
return true
|
|
252
260
|
}
|
|
@@ -458,6 +466,14 @@ export default async function update({
|
|
|
458
466
|
for (const p of preview.framework) {
|
|
459
467
|
console.log(` ${c.yellow('↻')} ${p}`)
|
|
460
468
|
}
|
|
469
|
+
// Named here because they are deleted, not updated: commands an earlier
|
|
470
|
+
// release wrote before the `oc:` namespace.
|
|
471
|
+
const legacy: string[] = []
|
|
472
|
+
for (const ide of ides) legacy.push(...((await IDE_ADAPTERS[ide]()).getLegacyOutputs?.(projectRoot) ?? []))
|
|
473
|
+
if (legacy.length > 0) {
|
|
474
|
+
console.log(`\n ${c.dim('[dry-run]')} Files from before the oc: namespace that would be removed:\n`)
|
|
475
|
+
for (const p of legacy) console.log(` ${c.red('-')} ${p}`)
|
|
476
|
+
}
|
|
461
477
|
if (preview.merged.length > 0) {
|
|
462
478
|
console.log(`\n ${c.dim('[dry-run]')} Files where only the managed block changes:\n`)
|
|
463
479
|
for (const p of preview.merged) {
|
|
@@ -548,6 +564,21 @@ export default async function update({
|
|
|
548
564
|
const teamWritten = new Set<string>()
|
|
549
565
|
const teamRemoved = new Set<string>()
|
|
550
566
|
const upgradedServers = new Set<string>()
|
|
567
|
+
// Which MCP configs exist before this sync writes any, so one it creates is
|
|
568
|
+
// recorded as ours — as `init` records the ones it creates. A target whose
|
|
569
|
+
// config moved (Codex, to `.codex/config.toml`) gets its new file here, and
|
|
570
|
+
// without the record `remove` would strip it and leave an empty file behind.
|
|
571
|
+
const mcpConfigsBefore = new Map(
|
|
572
|
+
ides.map((ide) => {
|
|
573
|
+
const rel = getMcpConfigRelPath(ide as IdeChoice)
|
|
574
|
+
return [rel, existsSync(resolve(projectRoot, rel))] as const
|
|
575
|
+
}),
|
|
576
|
+
)
|
|
577
|
+
const createdConfigs = new Set(manifest.createdConfigs ?? [])
|
|
578
|
+
// Legacy MCP configs this sync took our servers out of: deleted, or kept for
|
|
579
|
+
// what the user added to them.
|
|
580
|
+
const legacyDeleted: string[] = []
|
|
581
|
+
const legacyKept: string[] = []
|
|
551
582
|
const removedServers = new Set<string>()
|
|
552
583
|
let lockWritten = false
|
|
553
584
|
let lockHeld = false
|
|
@@ -600,12 +631,33 @@ export default async function update({
|
|
|
600
631
|
await step()
|
|
601
632
|
} catch (err) {
|
|
602
633
|
if (!(err instanceof UnreadableConfigError)) throw err
|
|
603
|
-
noteUnreadable(unreadable, err.file)
|
|
634
|
+
noteUnreadable(unreadable, err.reason === 'unparseable' ? err.file : `${err.file}\u0000${err.reason}`)
|
|
604
635
|
}
|
|
605
636
|
}
|
|
606
637
|
}
|
|
607
638
|
}
|
|
608
639
|
|
|
640
|
+
// Configs an earlier release wrote where the assistant never reads them.
|
|
641
|
+
// Taken back after the new config is written, so a failure there leaves
|
|
642
|
+
// the servers in at least one place.
|
|
643
|
+
const [priorKeys, priorInputs] = priorTeam(projectRoot)
|
|
644
|
+
for (const ide of ides) {
|
|
645
|
+
const rel = LEGACY_MCP_CONFIGS[ide as IdeChoice]
|
|
646
|
+
if (!rel) continue
|
|
647
|
+
const outcome = await retireLegacyMcpConfig(
|
|
648
|
+
projectRoot,
|
|
649
|
+
ide as IdeChoice,
|
|
650
|
+
createdConfigs.has(rel),
|
|
651
|
+
[...new Set([...Object.keys(source.mcp.servers), ...priorKeys])],
|
|
652
|
+
priorInputs,
|
|
653
|
+
)
|
|
654
|
+
if (outcome === 'deleted') {
|
|
655
|
+
legacyDeleted.push(rel)
|
|
656
|
+
createdConfigs.delete(rel)
|
|
657
|
+
} else if (outcome === 'stripped') legacyKept.push(rel)
|
|
658
|
+
else if (outcome === 'unreadable') noteUnreadable(unreadable, rel)
|
|
659
|
+
}
|
|
660
|
+
|
|
609
661
|
// What every assistant is now given, for review. Written last, from the
|
|
610
662
|
// same source the targets were compiled from — and not at all while an MCP
|
|
611
663
|
// config could not be read. The lock is how the next sync knows which team
|
|
@@ -651,8 +703,15 @@ export default async function update({
|
|
|
651
703
|
manifest.version = pkg.version
|
|
652
704
|
manifest.ides = ides
|
|
653
705
|
manifest.managedPaths = allManagedPaths
|
|
706
|
+
// After the compile above, which has removed any un-namespaced commands an
|
|
707
|
+
// earlier release left: from here on the old names are free again.
|
|
708
|
+
manifest.commandNamespace = COMMAND_NAMESPACE
|
|
654
709
|
manifest.stack = newStack
|
|
655
710
|
manifest.repoInfo = mergeStackIntoRepoInfo(repoInfo, newStack)
|
|
711
|
+
for (const [rel, existed] of mcpConfigsBefore) {
|
|
712
|
+
if (!existed && existsSync(resolve(projectRoot, rel))) createdConfigs.add(rel)
|
|
713
|
+
}
|
|
714
|
+
if (createdConfigs.size > 0 || manifest.createdConfigs) manifest.createdConfigs = [...createdConfigs]
|
|
656
715
|
if (manifestMeaning(manifest as unknown as Record<string, unknown>) !== before) {
|
|
657
716
|
manifest.updatedAt = new Date().toISOString()
|
|
658
717
|
await writeManifest(projectRoot, manifest)
|
|
@@ -690,6 +749,15 @@ export default async function update({
|
|
|
690
749
|
if (teamWritten.size > 0) {
|
|
691
750
|
console.log(` ${c.green('✓')} Wrote the team's MCP server(s) as defined: ${[...teamWritten].sort().join(', ')}`)
|
|
692
751
|
}
|
|
752
|
+
for (const rel of legacyDeleted) {
|
|
753
|
+
console.log(` ${c.yellow('-')} Removed ${rel}, which its assistant never read ${c.dim(`(its servers are now in ${configBesideLegacy(rel, ides)})`)}`)
|
|
754
|
+
}
|
|
755
|
+
for (const rel of legacyKept) {
|
|
756
|
+
console.log(
|
|
757
|
+
` ${c.yellow('!')} Took OpenCastle's servers out of ${rel}, which its assistant never read. ` +
|
|
758
|
+
`What is left there is yours — move it to ${configBesideLegacy(rel, ides)}.`,
|
|
759
|
+
)
|
|
760
|
+
}
|
|
693
761
|
if (teamRemoved.size > 0) {
|
|
694
762
|
console.log(
|
|
695
763
|
` ${c.yellow('-')} Removed ${teamRemoved.size} MCP server(s) the team's layers retired or its policy does not allow: ` +
|
|
@@ -731,7 +799,7 @@ export default async function update({
|
|
|
731
799
|
const name = isAbsolute(abs) ? relative(projectRoot, abs) : abs
|
|
732
800
|
console.log(
|
|
733
801
|
` ${c.yellow('!')} Left ${name} alone — ` +
|
|
734
|
-
(why
|
|
802
|
+
whyLeftAlone(name, why),
|
|
735
803
|
)
|
|
736
804
|
console.log(` ${c.dim('Merge conflict? Fix the file and run sync again.')}`)
|
|
737
805
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
"hash": "
|
|
2
|
+
"hash": "a4fd7106",
|
|
3
3
|
"configHash": "30f8ea04",
|
|
4
|
-
"lockfileHash": "
|
|
5
|
-
"browserHash": "
|
|
4
|
+
"lockfileHash": "68c77928",
|
|
5
|
+
"browserHash": "b3c82596",
|
|
6
6
|
"optimized": {
|
|
7
7
|
"astro > cssesc": {
|
|
8
8
|
"src": "../../../../../node_modules/cssesc/cssesc.js",
|
|
9
9
|
"file": "astro___cssesc.js",
|
|
10
|
-
"fileHash": "
|
|
10
|
+
"fileHash": "efb66864",
|
|
11
11
|
"needsInterop": true
|
|
12
12
|
},
|
|
13
13
|
"astro > aria-query": {
|
|
14
14
|
"src": "../../../../../node_modules/aria-query/lib/index.js",
|
|
15
15
|
"file": "astro___aria-query.js",
|
|
16
|
-
"fileHash": "
|
|
16
|
+
"fileHash": "372fa031",
|
|
17
17
|
"needsInterop": true
|
|
18
18
|
},
|
|
19
19
|
"astro > axobject-query": {
|
|
20
20
|
"src": "../../../../../node_modules/axobject-query/lib/index.js",
|
|
21
21
|
"file": "astro___axobject-query.js",
|
|
22
|
-
"fileHash": "
|
|
22
|
+
"fileHash": "7c9d31bc",
|
|
23
23
|
"needsInterop": true
|
|
24
24
|
}
|
|
25
25
|
},
|
|
@@ -262,10 +262,10 @@ After your summary, suggest next steps:
|
|
|
262
262
|
Now that your `.opencastle/` configuration is complete, here's what you can do:
|
|
263
263
|
|
|
264
264
|
1. **Review remaining TODOs** — Scan `.opencastle/` for any remaining `<!-- TODO: verify -->` comments and fill in missing values (e.g., tracker team IDs that require API access)
|
|
265
|
-
2. **Implement a feature** — Use the **"Implement Feature"** prompt to have the Team Lead orchestrate a full feature build with task tracking, delegation, and verification
|
|
266
|
-
3. **Fix a bug** — Use the **"Bug Fix"** prompt for structured triage, root cause analysis, and fix with tracker tracking
|
|
267
|
-
4. **Brainstorm first** — Not sure how to approach something? Use the **"Brainstorm"** prompt to explore requirements and trade-offs before committing to a plan
|
|
268
|
-
5. **Generate a convoy spec** — Use the **"Generate Convoy"** prompt to create a `.convoy.yml` spec for autonomous convoy execution with `npx opencastle convoy run --file <spec>` CLI command.
|
|
265
|
+
2. **Implement a feature** — Use the **"Implement Feature"** prompt (`/oc:implement-feature` in Claude Code and Copilot) to have the Team Lead orchestrate a full feature build with task tracking, delegation, and verification
|
|
266
|
+
3. **Fix a bug** — Use the **"Bug Fix"** prompt (`/oc:bug-fix`) for structured triage, root cause analysis, and fix with tracker tracking
|
|
267
|
+
4. **Brainstorm first** — Not sure how to approach something? Use the **"Brainstorm"** prompt (`/oc:brainstorm`) to explore requirements and trade-offs before committing to a plan
|
|
268
|
+
5. **Generate a convoy spec** — Use the **"Generate Convoy"** prompt (`/oc:generate-convoy`) to create a `.convoy.yml` spec for autonomous convoy execution with `npx opencastle convoy run --file <spec>` CLI command.
|
|
269
269
|
|
|
270
270
|
## Guidelines
|
|
271
271
|
|