buddy-agent-harness 0.13.0 → 0.14.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.
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/skill-scripts/doctor.mjs +2 -2
- package/dist/skill-scripts/init.mjs +2 -2
- package/dist/skill-scripts/mcp.mjs +2 -2
- package/dist/skill-scripts/reference.mjs +2 -2
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/skills/doctor-buddy-agent-harness/SKILL.md +1 -1
- package/skills/doctor-buddy-agent-harness/references/harnesses/copilot-cli.md +2 -2
- package/skills/doctor-buddy-agent-harness/references/harnesses/cursor.md +1 -1
- package/skills/doctor-buddy-agent-harness/references/harnesses/gemini-cli.md +1 -1
- package/skills/doctor-buddy-agent-harness/references/harnesses/windsurf.md +1 -1
- package/skills/doctor-buddy-agent-harness/scripts/doctor.mjs +2 -2
- package/skills/init-buddy-agent-harness/SKILL.md +5 -3
- package/skills/init-buddy-agent-harness/references/harnesses/cursor.md +14 -8
- package/skills/init-buddy-agent-harness/scripts/doctor.mjs +2 -2
- package/skills/init-buddy-agent-harness/scripts/init.mjs +2 -2
- package/skills/reference/README.md +53 -0
- package/skills/reference/SKILL.md +77 -0
- package/skills/reference/references/create.md +56 -0
- package/skills/{load-reference/SKILL.md → reference/references/load.md} +2 -7
- package/skills/{load-reference → reference}/scripts/reference.mjs +2 -2
- package/skills/repair/SKILL.md +1 -1
- package/skills/repair/scripts/doctor.mjs +2 -2
- package/skills/repair/scripts/mcp.mjs +2 -2
- package/src/diagnose-bridges/doctor-guidance.ts +2 -2
- package/src/references/{load-reference-invocation.ts → reference-invocation.ts} +3 -3
- package/src/references/reference.command.ts +1 -1
- package/src/skill-scripts/launchers.ts +1 -1
- package/skills/load-reference/README.md +0 -33
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["readJson","readJson","claudeCode","codex","parseToml","literalsIn","read","parse","namePattern","layersFor","isDirectory","layersFor","rootOption","stringifyToml","read","writeRecord","read","enabledPlugins"],"sources":["../src/is-record/is-record.ts","../src/command-output/command-output.ts","../src/dep-plugins/dep-plugins.ts","../src/dep-plugins/resolve.ts","../src/dep-plugins/generate.ts","../src/dep-plugins/harness-plugins.ts","../src/dep-plugins/reconcile.ts","../src/dep-plugins/dep-plugins.command.ts","../src/diagnose-bridges/directory-files.ts","../src/harness-registry/harness-registry.ts","../src/diagnose-bridges/locator.ts","../src/diagnose-bridges/doctor-guidance.ts","../src/diagnose-configuration/diagnose-configuration.ts","../src/diagnose-mcp/mcp-model.ts","../src/mcp-dialects/mcp-dialects.ts","../src/diagnose-bridges/json-with-comments.ts","../src/diagnose-mcp/mcp-sources.ts","../src/diagnose-mcp/mcp-baseline.ts","../src/diagnose-mcp/mcp-secrets.ts","../src/diagnose-mcp/diagnose-mcp.ts","../src/diagnose-nonstandard/diagnose-nonstandard.ts","../src/references/reference-document.ts","../src/references/resolve-reference.ts","../src/references/reference-catalog.ts","../src/governance-overrides/governance-overrides.ts","../src/references/harness-layers.ts","../src/references/reference-layers.ts","../src/skill-projection/skill-projection.ts","../src/diagnose-bridges/agents-files.ts","../src/diagnose-bridges/diagnose-instructions.ts","../src/diagnose-bridges/git-bridge-state.ts","../src/diagnose-bridges/diagnose-bridges.ts","../src/diagnose-bridges/doctor.command.ts","../src/governance-overrides/governance.command.ts","../src/references/reference.command.ts","../src/initialize-harnesses/initialize-harnesses.ts","../src/initialize-harnesses/init.command.ts","../src/config-edit/toml-edit.ts","../src/reconcile-mcp/reconcile-mcp.ts","../src/reconcile-mcp/reconcile.command.ts","../src/config-edit/jsonc-edit.ts","../src/project-mcp/mcp-edit.ts","../src/project-mcp/project-mcp.ts","../src/project-mcp/mcp.command.ts","../src/cli.ts","../src/mcp-inventory/mcp-inventory.ts"],"sourcesContent":["export function isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n","import { sep } from 'node:path'\nimport { encode } from '@toon-format/toon'\nimport { isRecord } from '../is-record/is-record.ts'\n\nexport type OutputFormat = 'json' | 'toon' | 'text'\n\nconst formats: readonly OutputFormat[] = ['toon', 'json', 'text']\n\n/** Rejects anything but the supported formats so an unknown value never falls back silently. */\nexport function parseFormat(value: string | undefined): OutputFormat {\n\tif (!formats.includes(value as OutputFormat)) throw new Error('--format must be toon, json, or text.')\n\treturn value as OutputFormat\n}\n\n/** The single stdout boundary: internal logic stays on plain objects, encoding happens here. */\nexport function writeResult(value: object, format: OutputFormat): void {\n\tprocess.stdout.write(`${encodeResult(value, format)}\\n`)\n}\n\n/**\n * Writes a document exactly as read, bypassing the encoders — a Markdown body run through TOON or\n * the text renderer comes back as one escaped line. A command writes one or the other, never both.\n */\nexport function writeDocument(content: string): void {\n\tprocess.stdout.write(content.endsWith('\\n') ? content : `${content}\\n`)\n}\n\nfunction encodeResult(value: object, format: OutputFormat): string {\n\tif (format === 'json') return JSON.stringify(value)\n\treturn format === 'text' ? renderText(value) : encode(value)\n}\n\nfunction cell(value: unknown): string {\n\treturn value === undefined ? '' : String(value)\n}\n\nfunction table(rows: Record<string, unknown>[]): string[] {\n\tconst columns = [...new Set(rows.flatMap((row) => Object.keys(row)))]\n\tconst widths = columns.map((column) => Math.max(column.length, ...rows.map((row) => cell(row[column]).length)))\n\tconst line = (values: string[]) =>\n\t\t` ${values.map((value, index) => value.padEnd(widths[index] as number)).join(' ')}`.trimEnd()\n\treturn [line(columns), ...rows.map((row) => line(columns.map((column) => cell(row[column]))))]\n}\n\n/** Renders for a person, not an agent — TOON stays the default since that's what an agent parses. */\nexport function renderText(value: object): string {\n\tconst blocks = Object.entries(value).map(([key, item]) => {\n\t\tif (!Array.isArray(item)) return [`${key}: ${isRecord(item) ? JSON.stringify(item) : String(item)}`]\n\t\tif (!item.length) return [`${key}: (none)`]\n\t\tconst body = item.every(isRecord) ? table(item) : item.map((entry) => ` - ${String(entry)}`)\n\t\treturn [`${key}:`, ...body]\n\t})\n\n\t// Blank line between blocks so a following scalar doesn't read as another row of the table\n\t// above it.\n\treturn blocks\n\t\t.flatMap((block, index) => {\n\t\t\tconst previous = blocks[index - 1]\n\t\t\treturn previous && (previous.length > 1 || block.length > 1) ? ['', ...block] : block\n\t\t})\n\t\t.join('\\n')\n}\n\n/**\n * AXI §10: collapses the home directory to `~` so a path in a report is portable to another\n * machine.\n */\nexport function collapseHome(home: string, path: string): string {\n\treturn home && path.startsWith(home + sep) ? `~${path.slice(home.length)}` : path\n}\n\nexport function displayBinPath(home: string, executable: string | undefined): string {\n\treturn executable ? collapseHome(home, executable) : 'buddy-agent-harness'\n}\n","/** Pure. Resolution against `node_modules` lives in `resolve.ts`. */\n\nexport type DepPlugin = {\n\tpackage: string\n\t/** The manifest's own name; may differ from `package`. */\n\tplugin: string\n\t/** The version installed, not the manifest's declared range. */\n\tversion: string\n\tdescription?: string\n}\n\n/** `npm`, not `path`: a path source must sit at the repository root, which this catalog does not. */\nexport type NpmSource = {\n\tsource: 'npm'\n\tpackage: string\n\tversion: string\n}\n\nexport type CatalogEntry = {\n\tname: string\n\tsource: NpmSource\n\tdescription?: string\n}\n\n/** `owner` must be an object; a bare string is a schema error, not an accepted shorthand. */\nexport type Catalog = {\n\tname: string\n\towner: { name: string }\n\tdescription: string\n\tplugins: CatalogEntry[]\n}\n\n/** Generic marketplace names: a second registration under one of these replaces the first, silently. */\nconst GENERIC_NAMES = new Set(['deps', 'dependencies', 'local', 'plugins', 'marketplace', 'plugin', 'default'])\n\nexport function isGenericName(name: string): boolean {\n\treturn GENERIC_NAMES.has(name.toLowerCase())\n}\n\n/**\n * Folds a scope into the name (`@acme/web` → `acme-web`) rather than dropping it — the unscoped\n * part collides more often.\n */\nexport function marketplaceName(packageName: string): string {\n\tconst folded = packageName.replace(/^@/, '').replace(/\\//g, '-')\n\tconst cleaned = folded\n\t\t.replace(/[^a-zA-Z0-9-_.]/g, '-')\n\t\t.replace(/-+/g, '-')\n\t\t.replace(/^-|-$/g, '')\n\treturn cleaned || 'agent-plugins'\n}\n\n/**\n * Includes `devDependencies` — a plugin can supply a project's testing or release workflow.\n * Transitive dependencies are excluded; see `resolve.ts`.\n */\nexport function declaredDependencies(manifest: unknown): string[] {\n\tif (!manifest || typeof manifest !== 'object') return []\n\tconst record = manifest as Record<string, unknown>\n\tconst names = new Set<string>()\n\tfor (const field of ['dependencies', 'devDependencies']) {\n\t\tconst group = record[field]\n\t\tif (!group || typeof group !== 'object') continue\n\t\tfor (const name of Object.keys(group as Record<string, unknown>)) names.add(name)\n\t}\n\treturn [...names].sort()\n}\n\nexport type BuildCatalogOptions = {\n\tname: string\n\towner: string\n\tplugins: readonly DepPlugin[]\n}\n\n/**\n * Derived in full every run, never merged with what's on disk. Entries are sorted so unchanged\n * inputs serialize identically, which `--check` relies on.\n */\nexport function buildCatalog({ name, owner, plugins }: BuildCatalogOptions): Catalog {\n\tconst entries = [...plugins]\n\t\t.sort((a, b) => a.plugin.localeCompare(b.plugin))\n\t\t.map(({ plugin, package: pkg, version, description }): CatalogEntry => {\n\t\t\tconst source: NpmSource = { source: 'npm', package: pkg, version }\n\t\t\treturn description ? { name: plugin, source, description } : { name: plugin, source }\n\t\t})\n\n\treturn {\n\t\tname,\n\t\towner: { name: owner },\n\t\tdescription: 'Plugins provided by this repository’s dependencies. Generated — do not edit.',\n\t\tplugins: entries,\n\t}\n}\n\n/** Includes the trailing newline. */\nexport function serializeCatalog(catalog: Catalog): string {\n\treturn `${JSON.stringify(catalog, null, '\\t')}\\n`\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { dirname, join } from 'node:path'\nimport type { DepPlugin } from './dep-plugins.ts'\n\nexport type SkipReason = 'unresolved' | 'no-manifest' | 'unnamed'\n\nexport type ResolveOutcome = { ok: true; plugin: DepPlugin } | { ok: false; package: string; reason: SkipReason }\n\nfunction readJson(path: string): unknown {\n\ttry {\n\t\treturn JSON.parse(readFileSync(path, 'utf8'))\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nfunction ancestorCandidates(startDir: string, pkg: string): string[] {\n\tconst segments = pkg.split('/')\n\tconst candidates: string[] = []\n\tlet dir = startDir\n\tfor (;;) {\n\t\tcandidates.push(join(dir, 'node_modules', ...segments))\n\t\tconst parent = dirname(dir)\n\t\tif (parent === dir) break\n\t\tdir = parent\n\t}\n\treturn candidates\n}\n\n/**\n * Anchored at the declaring manifest (required for pnpm's isolation), then falls back to a\n * `node_modules` walk — an `exports` map without a `./package.json` entry blocks the first.\n */\nexport function packageDir(pkg: string, fromManifest: string): string | undefined {\n\ttry {\n\t\tconst require = createRequire(fromManifest)\n\t\treturn dirname(require.resolve(`${pkg}/package.json`))\n\t} catch {}\n\tfor (const candidate of ancestorCandidates(dirname(fromManifest), pkg)) {\n\t\tif (existsSync(join(candidate, 'package.json'))) return candidate\n\t}\n\treturn undefined\n}\n\n/** A manifest lives at the package root — the Agent Plugins Specification's pinned location. */\nexport function readDepPlugin(pkg: string, fromManifest: string): ResolveOutcome {\n\tconst dir = packageDir(pkg, fromManifest)\n\tif (!dir) return { ok: false, package: pkg, reason: 'unresolved' }\n\n\tconst manifest = readJson(join(dir, 'plugin.json'))\n\tif (!manifest || typeof manifest !== 'object') return { ok: false, package: pkg, reason: 'no-manifest' }\n\n\tconst record = manifest as Record<string, unknown>\n\tconst name = typeof record['name'] === 'string' ? record['name'] : undefined\n\tif (!name) return { ok: false, package: pkg, reason: 'unnamed' }\n\n\t// The installed version, not the manifest's declared range — npm installs by this number.\n\tconst installed = readJson(join(dir, 'package.json')) as { version?: unknown } | undefined\n\tconst version = typeof installed?.version === 'string' ? installed.version : undefined\n\tif (!version) return { ok: false, package: pkg, reason: 'no-manifest' }\n\n\tconst description = typeof record['description'] === 'string' ? record['description'] : undefined\n\treturn {\n\t\tok: true,\n\t\tplugin: description\n\t\t\t? { package: pkg, plugin: name, version, description }\n\t\t\t: { package: pkg, plugin: name, version },\n\t}\n}\n\n/**\n * True under Yarn PnP, where packages live in zip archives rather than directories — nothing here\n * has an installable directory.\n */\nexport function isPnp(): boolean {\n\treturn Boolean((process.versions as Record<string, string | undefined>)['pnp'])\n}\n","import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport {\n\tbuildCatalog,\n\ttype Catalog,\n\ttype DepPlugin,\n\tdeclaredDependencies,\n\tisGenericName,\n\tmarketplaceName,\n\tserializeCatalog,\n} from './dep-plugins.ts'\nimport { isPnp, readDepPlugin, type SkipReason } from './resolve.ts'\n\n/**\n * Not the repository root's `.claude-plugin/` — that's the repo's own published catalog; merging\n * would leak dependency plugins into it.\n */\nexport const CATALOG_DIR: string = join('.agents', 'buddy-agent-harness')\nexport const CATALOG_PATH: string = join(CATALOG_DIR, '.claude-plugin', 'marketplace.json')\n\nexport type Skipped = { package: string; reason: SkipReason }\n\nexport type DerivedCatalog = {\n\tcatalog: Catalog\n\tplugins: DepPlugin[]\n\t/** Only the dependencies that failed to resolve at all; a dependency with no plugin is not news. */\n\tunresolved: Skipped[]\n\tgenericName: boolean\n\t/** True under Yarn PnP: no dependency has an installable directory. */\n\tpnp: boolean\n}\n\nfunction readManifest(path: string): Record<string, unknown> {\n\treturn JSON.parse(readFileSync(path, 'utf8')) as Record<string, unknown>\n}\n\nexport function deriveCatalog(root: string): DerivedCatalog {\n\tconst manifestPath = join(root, 'package.json')\n\tconst manifest = readManifest(manifestPath)\n\n\tconst plugins: DepPlugin[] = []\n\tconst unresolved: Skipped[] = []\n\tfor (const pkg of declaredDependencies(manifest)) {\n\t\tconst outcome = readDepPlugin(pkg, manifestPath)\n\t\tif (outcome.ok) plugins.push(outcome.plugin)\n\t\telse if (outcome.reason === 'unresolved') unresolved.push({ package: pkg, reason: outcome.reason })\n\t}\n\n\tconst owner = typeof manifest['name'] === 'string' ? manifest['name'] : 'unknown'\n\tconst name = marketplaceName(owner)\n\n\treturn {\n\t\tcatalog: buildCatalog({ name, owner, plugins }),\n\t\tplugins,\n\t\tunresolved,\n\t\tgenericName: isGenericName(name),\n\t\tpnp: isPnp(),\n\t}\n}\n\nexport type WriteOutcome = 'created' | 'updated' | 'unchanged'\n\n/**\n * Compares serialized bytes, not parsed values — that's what makes `--check` a comparison rather\n * than an interpretation.\n */\nexport function catalogStatus(root: string, catalog: Catalog): WriteOutcome {\n\tlet current: string | undefined\n\ttry {\n\t\tcurrent = readFileSync(join(root, CATALOG_PATH), 'utf8')\n\t} catch {\n\t\tcurrent = undefined\n\t}\n\tif (current === serializeCatalog(catalog)) return 'unchanged'\n\treturn current === undefined ? 'created' : 'updated'\n}\n\n/** A write that would change nothing writes nothing. */\nexport function writeCatalog(root: string, catalog: Catalog): WriteOutcome {\n\tconst outcome = catalogStatus(root, catalog)\n\tif (outcome === 'unchanged') return outcome\n\n\tconst path = join(root, CATALOG_PATH)\n\tmkdirSync(dirname(path), { recursive: true })\n\twriteFileSync(path, serializeCatalog(catalog))\n\treturn outcome\n}\n","// E-* IDs below: .research/agentic-configuration-standards/evidence.md\n\nimport { existsSync, readdirSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nexport type PluginRuntimeName = 'claude-code' | 'codex'\n\nexport type InstalledPlugin = {\n\t/** `<plugin>@<marketplace>` */\n\tid: string\n\tversion: string\n\tscope: string\n\tprojectPath?: string\n}\n\nexport type RegisteredMarketplace = { name: string; path: string }\n\n/** Read, never written: installing is the runtime's own job, done through its own CLI. */\nexport type HarnessPluginState = {\n\tinstalled: InstalledPlugin[]\n\tmarketplaces: RegisteredMarketplace[]\n}\n\nexport type PluginRuntime = {\n\tname: PluginRuntimeName\n\tinstalledOnMachine(home: string, env?: NodeJS.ProcessEnv): boolean\n\tstate(home: string, env?: NodeJS.ProcessEnv): HarnessPluginState\n\tregister(catalogDir: string): string\n\tinstall(id: string): string\n\tupdate(id: string): string\n\tuninstall(id: string): string\n\t/** Empty where a runtime re-reads the catalog on install and needs no separate refresh. */\n\trefreshMarketplace(marketplace: string): string\n\t/** False where one install serves every repository on the machine. */\n\tscoped: boolean\n}\n\n// E-COPILOT-03\nexport const COPILOT_LIMITATION =\n\t'Copilot CLI rejects an npm marketplace source, so it cannot install from this catalog. It needs a path-sourced catalog, which cannot reach node_modules from a subdirectory.'\n\nfunction readJson(path: string): unknown {\n\ttry {\n\t\treturn JSON.parse(readFileSync(path, 'utf8'))\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nfunction directories(path: string): string[] {\n\ttry {\n\t\treturn readdirSync(path, { withFileTypes: true })\n\t\t\t.filter((entry) => entry.isDirectory())\n\t\t\t.map((entry) => entry.name)\n\t} catch {\n\t\treturn []\n\t}\n}\n\n// ── Claude Code ──\n\nexport function claudeConfigDir(home: string, env: NodeJS.ProcessEnv = process.env): string {\n\treturn env['CLAUDE_CONFIG_DIR'] || join(home, '.claude')\n}\n\n// E-CC-17: one array per plugin id, an element per scope and project.\nexport function readClaudeState(configDir: string): HarnessPluginState {\n\tconst installedFile = readJson(join(configDir, 'plugins', 'installed_plugins.json')) as\n\t\t| { plugins?: Record<string, unknown> }\n\t\t| undefined\n\tconst installed: InstalledPlugin[] = []\n\tfor (const [id, entries] of Object.entries(installedFile?.plugins ?? {})) {\n\t\tif (!Array.isArray(entries)) continue\n\t\tfor (const entry of entries) {\n\t\t\tif (!entry || typeof entry !== 'object') continue\n\t\t\tconst record = entry as Record<string, unknown>\n\t\t\tconst version = typeof record['version'] === 'string' ? record['version'] : undefined\n\t\t\tconst scope = typeof record['scope'] === 'string' ? record['scope'] : undefined\n\t\t\tif (!version || !scope) continue\n\t\t\tconst projectPath = typeof record['projectPath'] === 'string' ? record['projectPath'] : undefined\n\t\t\tinstalled.push(projectPath ? { id, version, scope, projectPath } : { id, version, scope })\n\t\t}\n\t}\n\n\tconst knownFile = readJson(join(configDir, 'plugins', 'known_marketplaces.json')) as\n\t\t| Record<string, { source?: { path?: unknown } }>\n\t\t| undefined\n\tconst marketplaces: RegisteredMarketplace[] = []\n\tfor (const [name, value] of Object.entries(knownFile ?? {})) {\n\t\tmarketplaces.push({ name, path: typeof value?.source?.path === 'string' ? value.source.path : '' })\n\t}\n\n\treturn { installed, marketplaces }\n}\n\nexport const claudeCode: PluginRuntime = {\n\tname: 'claude-code',\n\tscoped: true,\n\tinstalledOnMachine: (home, env = process.env) => existsSync(claudeConfigDir(home, env)),\n\tstate: (home, env = process.env) => readClaudeState(claudeConfigDir(home, env)),\n\tregister: (catalogDir) => `claude plugin marketplace add ./${catalogDir} --scope project`,\n\tinstall: (id) => `claude plugin install ${id} --scope project`,\n\t// Not `install`, a silent no-op (E-CC-15); `--scope project` is required on every verb (E-CC-16).\n\tupdate: (id) => `claude plugin update ${id} --scope project`,\n\tuninstall: (id) => `claude plugin uninstall ${id} --scope project`,\n\trefreshMarketplace: (marketplace) => `claude plugin marketplace update ${marketplace}`,\n}\n\n// ── Codex ──\n\nexport function codexHome(home: string, env: NodeJS.ProcessEnv = process.env): string {\n\treturn env['CODEX_HOME'] || join(home, '.codex')\n}\n\n// E-CODEX-04: the version is only in the cache path. The TOML scan is deliberately narrow: a misread\n// only suggests re-registering, which is harmless to re-run.\nexport function readCodexState(home: string): HarnessPluginState {\n\tconst cacheRoot = join(home, 'plugins', 'cache')\n\tconst installed: InstalledPlugin[] = []\n\tfor (const marketplace of directories(cacheRoot)) {\n\t\tfor (const plugin of directories(join(cacheRoot, marketplace))) {\n\t\t\tfor (const version of directories(join(cacheRoot, marketplace, plugin))) {\n\t\t\t\tinstalled.push({ id: `${plugin}@${marketplace}`, version, scope: 'user' })\n\t\t\t}\n\t\t}\n\t}\n\n\tconst marketplaces: RegisteredMarketplace[] = []\n\tlet config = ''\n\ttry {\n\t\tconfig = readFileSync(join(home, 'config.toml'), 'utf8')\n\t} catch {\n\t\tconfig = ''\n\t}\n\tlet current: RegisteredMarketplace | undefined\n\tfor (const line of config.split('\\n')) {\n\t\tconst header = /^\\s*\\[marketplaces\\.(?:\"([^\"]+)\"|([^\\]]+))\\]\\s*$/.exec(line)\n\t\tif (header) {\n\t\t\tcurrent = { name: (header[1] ?? header[2]) as string, path: '' }\n\t\t\tmarketplaces.push(current)\n\t\t\tcontinue\n\t\t}\n\t\tif (/^\\s*\\[/.test(line)) {\n\t\t\tcurrent = undefined\n\t\t\tcontinue\n\t\t}\n\t\tconst source = current ? /^\\s*source\\s*=\\s*\"([^\"]*)\"\\s*$/.exec(line) : undefined\n\t\tif (source?.[1] && current) current.path = source[1]\n\t}\n\n\treturn { installed, marketplaces }\n}\n\nexport const codex: PluginRuntime = {\n\tname: 'codex',\n\t// E-CODEX-03: unscoped, so only the derived marketplace name keeps two repositories apart.\n\tscoped: false,\n\tinstalledOnMachine: (home, env = process.env) => existsSync(codexHome(home, env)),\n\tstate: (home, env = process.env) => readCodexState(codexHome(home, env)),\n\tregister: (catalogDir) => `codex plugin marketplace add ./${catalogDir}`,\n\tinstall: (id) => `codex plugin add ${id}`,\n\t// E-CODEX-03: no update verb; `add` replaces the cached copy.\n\tupdate: (id) => `codex plugin add ${id}`,\n\tuninstall: (id) => `codex plugin remove ${id}`,\n\t// E-CODEX-03: `add` already re-reads a local catalog.\n\trefreshMarketplace: () => '',\n}\n\n// Copilot CLI (E-COPILOT-03) and Cursor (E-CUR-04) have no CLI this can drive.\nexport const runtimes: readonly PluginRuntime[] = [claudeCode, codex]\n","/** Pure. Reading harness state lives in `harness-plugins.ts`. */\n\nimport type { Catalog } from './dep-plugins.ts'\nimport type { InstalledPlugin, RegisteredMarketplace } from './harness-plugins.ts'\n\nexport type ActionKind = 'register' | 'install' | 'update' | 'uninstall'\n\nexport type Action = {\n\tkind: ActionKind\n\t/** `<plugin>@<marketplace>`, or the marketplace name for `register`. */\n\tsubject: string\n\tdetail: string\n}\n\nexport type Reconciliation = {\n\tactions: Action[]\n\t/**\n\t * Set when a marketplace of this name is registered against a different directory — the harness\n\t * gives no error for this on its own.\n\t */\n\tcollision?: string\n\tunregistered: boolean\n}\n\nexport type ReconcileOptions = {\n\tcatalog: Catalog\n\t/** Where the catalog lives, relative to the repository root. */\n\tcatalogDir: string\n\t/** Absolute repository root, used to keep another project's installs out of the comparison. */\n\troot: string\n\tinstalled: readonly InstalledPlugin[]\n\tmarketplaces: readonly RegisteredMarketplace[]\n\t/**\n\t * False for a runtime with no per-repo scope (Codex): every install under this marketplace\n\t * counts as this repository's, since nothing else distinguishes them.\n\t */\n\tscoped?: boolean\n}\n\n/**\n * Excludes a user-scoped install on a scoped runtime — it's shared machine-wide, so it can't\n * satisfy this repository's catalog alone.\n */\nfunction ours(\n\tinstalled: readonly InstalledPlugin[],\n\tmarketplace: string,\n\troot: string,\n\tscoped: boolean,\n): InstalledPlugin[] {\n\tconst suffix = `@${marketplace}`\n\treturn installed.filter((entry) => entry.id.endsWith(suffix) && (!scoped || entry.projectPath === root))\n}\n\nexport function reconcile({\n\tcatalog,\n\tcatalogDir,\n\troot,\n\tinstalled,\n\tmarketplaces,\n\tscoped = true,\n}: ReconcileOptions): Reconciliation {\n\tconst registration = marketplaces.find((entry) => entry.name === catalog.name)\n\tconst actions: Action[] = []\n\n\t// Reported, not repaired: re-registering would just steal the name from whoever holds it.\n\tconst expected = catalogDir.split(/[\\\\/]/).filter(Boolean)\n\tconst pointsHere = registration ? expected.every((segment) => registration.path.includes(segment)) : false\n\tconst collision = registration && !pointsHere ? registration.path : undefined\n\n\tif (!registration) {\n\t\tactions.push({\n\t\t\tkind: 'register',\n\t\t\tsubject: catalog.name,\n\t\t\tdetail: 'marketplace is not registered with this harness',\n\t\t})\n\t}\n\n\tconst mine = ours(installed, catalog.name, root, scoped)\n\tconst byId = new Map(mine.map((entry) => [entry.id, entry]))\n\n\tfor (const entry of catalog.plugins) {\n\t\tconst id = `${entry.name}@${catalog.name}`\n\t\tconst current = byId.get(id)\n\t\tif (!current) {\n\t\t\tactions.push({ kind: 'install', subject: id, detail: `not installed; catalog pins ${entry.source.version}` })\n\t\t\tcontinue\n\t\t}\n\t\tif (current.version !== entry.source.version) {\n\t\t\tactions.push({\n\t\t\t\tkind: 'update',\n\t\t\t\tsubject: id,\n\t\t\t\tdetail: `installed ${current.version}, catalog pins ${entry.source.version}`,\n\t\t\t})\n\t\t}\n\t}\n\n\t// Nothing else removes these — the harness leaves a plugin dropped from the catalog installed\n\t// and failing to load.\n\tconst wanted = new Set(catalog.plugins.map((entry) => `${entry.name}@${catalog.name}`))\n\tfor (const entry of mine) {\n\t\tif (!wanted.has(entry.id)) {\n\t\t\tactions.push({\n\t\t\t\tkind: 'uninstall',\n\t\t\t\tsubject: entry.id,\n\t\t\t\tdetail: 'installed but no longer in the catalog; it will report a load failure until removed',\n\t\t\t})\n\t\t}\n\t}\n\n\treturn {\n\t\tactions,\n\t\t...(collision ? { collision } : {}),\n\t\tunregistered: !registration,\n\t}\n}\n","import { homedir } from 'node:os'\nimport { resolve } from 'node:path'\nimport type { cli } from 'clibuilder'\nimport { command, exitCodes, z } from 'clibuilder'\nimport { parseFormat, writeResult } from '../command-output/command-output.ts'\nimport { CATALOG_DIR, CATALOG_PATH, catalogStatus, deriveCatalog, type WriteOutcome, writeCatalog } from './generate.ts'\nimport { COPILOT_LIMITATION, type PluginRuntime, runtimes } from './harness-plugins.ts'\nimport { type Action, reconcile } from './reconcile.ts'\n\nexport type DepPluginsReport = {\n\tcatalog: string\n\tmarketplace: string\n\toutcome: WriteOutcome | 'would-change' | 'current'\n\t/** Emitted even when empty, so a healthy run states its zero explicitly. */\n\tplugins: { name: string; package: string; version: string }[] | string\n\tharness: { runtime: string; status: string }[] | string\n\t/**\n\t * Reported, never run — writes outside the repo and shouldn't happen unasked.\n\t * One flat row per action, not nested under runtime: TOON renders a flat record as a table but collapses a nested array to JSON.\n\t */\n\tactions: { runtime: string; do: string; subject: string; why: string }[] | string\n\tnotes?: string[]\n\thelp?: string[]\n}\n\nfunction commandFor(runtime: PluginRuntime, action: Action, marketplace: string): string {\n\tswitch (action.kind) {\n\t\tcase 'register':\n\t\t\treturn runtime.register(CATALOG_DIR)\n\t\tcase 'install':\n\t\t\treturn runtime.install(action.subject)\n\t\tcase 'update': {\n\t\t\t// Some runtimes cache the catalog and must refresh before update, or they reinstall the\n\t\t\t// stale cached version; Codex re-reads on every add and needs none.\n\t\t\tconst refresh = runtime.refreshMarketplace(marketplace)\n\t\t\tconst update = runtime.update(action.subject)\n\t\t\treturn refresh ? `${refresh} && ${update}` : update\n\t\t}\n\t\tcase 'uninstall':\n\t\t\treturn runtime.uninstall(action.subject)\n\t}\n}\n\nfunction notesFor(derived: ReturnType<typeof deriveCatalog>): string[] {\n\tconst notes: string[] = []\n\tif (derived.pnp) {\n\t\tnotes.push(\n\t\t\t'Yarn Plug’n’Play is active: dependencies live inside zip archives, so no harness can install from them. Set nodeLinker: node-modules, or unplug the plugin dependencies.',\n\t\t)\n\t}\n\tif (derived.genericName) {\n\t\tnotes.push(\n\t\t\t`Marketplace name \"${derived.catalog.name}\" is generic. Registering a second marketplace under a name already in use replaces the first silently, and the install that follows reports \"already installed\" — the repository then runs the other one's versions.`,\n\t\t)\n\t}\n\tfor (const { package: pkg } of derived.unresolved) {\n\t\tnotes.push(`Declared dependency \"${pkg}\" is not installed; install dependencies before generating.`)\n\t}\n\treturn notes\n}\n\nexport const depPluginsCommand: cli.Command = command({\n\tname: 'dep-plugins',\n\tdescription:\n\t\t'Derive the marketplace catalog for plugins shipped by this repository’s dependencies, so a harness can install them. Writes the catalog; installing is the harness’s own job.',\n\toptions: {\n\t\troot: {\n\t\t\tdescription: 'Repository directory. Defaults to the current directory.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\tcheck: {\n\t\t\tdescription: 'Report whether the catalog is current without writing it. For CI and postinstall.',\n\t\t\ttype: z.optional(z.boolean()),\n\t\t},\n\t\tformat: {\n\t\t\tdescription: 'Output format: toon (default), json, or text for a human-readable report.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'toon',\n\t\t},\n\t},\n\trun(args) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst root = args.root ?? process.cwd()\n\t\t\tconst derived = deriveCatalog(root)\n\n\t\t\tconst outcome = args.check\n\t\t\t\t? catalogStatus(root, derived.catalog) === 'unchanged'\n\t\t\t\t\t? ('current' as const)\n\t\t\t\t\t: ('would-change' as const)\n\t\t\t\t: writeCatalog(root, derived.catalog)\n\n\t\t\t// Reads each harness's own state files, never its CLI — a report shouldn't require that\n\t\t\t// runtime to be launchable here.\n\t\t\tconst home = homedir()\n\t\t\tconst notes = notesFor(derived)\n\t\t\tconst detected = runtimes.filter((candidate) => candidate.installedOnMachine(home))\n\t\t\tconst harness: { runtime: string; status: string }[] = []\n\t\t\tconst actions: { runtime: string; do: string; subject: string; why: string }[] = []\n\n\t\t\tfor (const runtime of detected) {\n\t\t\t\tconst state = runtime.state(home)\n\t\t\t\tconst delta = reconcile({\n\t\t\t\t\tcatalog: derived.catalog,\n\t\t\t\t\tcatalogDir: CATALOG_DIR,\n\t\t\t\t\troot: resolve(root),\n\t\t\t\t\tinstalled: state.installed,\n\t\t\t\t\tmarketplaces: state.marketplaces,\n\t\t\t\t\tscoped: runtime.scoped,\n\t\t\t\t})\n\t\t\t\tif (delta.collision) {\n\t\t\t\t\tnotes.push(\n\t\t\t\t\t\t`${runtime.name}: marketplace \"${derived.catalog.name}\" is already registered against ${delta.collision}. Registering over it replaces the other repository's silently, and the install that follows reports \"already installed\" — rename this repository's marketplace instead.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tharness.push({\n\t\t\t\t\truntime: runtime.name,\n\t\t\t\t\tstatus: delta.actions.length ? `${delta.actions.length} to apply` : 'in sync',\n\t\t\t\t})\n\t\t\t\tfor (const action of delta.actions) {\n\t\t\t\t\tactions.push({\n\t\t\t\t\t\truntime: runtime.name,\n\t\t\t\t\t\tdo: commandFor(runtime, action, derived.catalog.name),\n\t\t\t\t\t\tsubject: action.subject,\n\t\t\t\t\t\twhy: action.detail,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (derived.plugins.length) notes.push(COPILOT_LIMITATION)\n\n\t\t\tconst report: DepPluginsReport = {\n\t\t\t\tcatalog: CATALOG_PATH,\n\t\t\t\tmarketplace: derived.catalog.name,\n\t\t\t\toutcome,\n\t\t\t\tplugins: derived.plugins.length\n\t\t\t\t\t? derived.plugins.map(({ plugin, package: pkg, version }) => ({ name: plugin, package: pkg, version }))\n\t\t\t\t\t: '0 dependencies ship a plugin — nothing to install',\n\t\t\t\tharness: harness.length ? harness : 'no supported harness detected on this machine',\n\t\t\t\tactions: actions.length ? actions : '0 actions — every detected harness matches the catalog',\n\t\t\t\t...(notes.length ? { notes } : {}),\n\t\t\t}\n\t\t\twriteResult(report, format)\n\n\t\t\t// Exit code reflects staleness under --check only; everything else is in the report, not\n\t\t\t// the exit code.\n\t\t\treturn outcome === 'would-change' ? exitCodes.error : exitCodes.success\n\t\t} catch (error) {\n\t\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'Catalog generation failed.'}\\n`)\n\t\t\treturn exitCodes.error\n\t\t}\n\t},\n})\n","import { readdirSync } from 'node:fs'\nimport { join, posix, relative, sep } from 'node:path'\n\n/** A directory that does not exist reads as empty: `doctor` never creates one to look at it. */\nexport function filesUnder(directory: string): string[] {\n\ttry {\n\t\treturn readdirSync(directory, { recursive: true, withFileTypes: true })\n\t\t\t.filter((entry) => entry.isFile())\n\t\t\t.map((entry) => relative(directory, join(entry.parentPath, entry.name)).split(sep).join(posix.sep))\n\t\t\t.sort()\n\t} catch {\n\t\treturn []\n\t}\n}\n","import { lstatSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { type HarnessId, skillsDirectories } from '@cyberuni/agent-harness'\nimport type { InstructionBridge } from './instruction-bridge.ts'\nimport type { McpConfig } from './mcp-config.ts'\nimport type { NonstandardArtifact } from './nonstandard-artifact.ts'\n\nexport type HarnessName =\n\t| 'claude-code'\n\t| 'cursor'\n\t| 'codex'\n\t| 'copilot-cli'\n\t| 'gemini-cli'\n\t| 'devin-desktop'\n\t| 'windsurf'\n\t/**\n\t * No `harnessRegistry` entry — recognized by `listMcpServers` only, so `McpServerEntry.harness`\n\t * can name them.\n\t */\n\t| 'vscode'\n\t| 'opencode'\n\t| 'zed'\n\n/** The two scopes a harness reads configuration at. Their roots differ; their shape does not. */\nexport type HarnessScopeName = 'project' | 'user'\n\n/** What one harness does at one scope; paths are relative to that scope's root. */\nexport type HarnessScope = {\n\t/** The directory whose presence means this harness is configured at this scope. */\n\tdetect: string\n\t/** The projection target for `.agents/skills`; absent when the harness reads it there natively. */\n\tskillsDirectory?: string\n\t/**\n\t * What the harness needs at this scope to read `AGENTS.md`; diagnosed and gated, never written\n\t * by `init`.\n\t */\n\tinstructionBridge?: InstructionBridge\n\t/** Files whose presence beside `AGENTS.md` stop the harness reading it. */\n\tshadowedBy?: readonly string[]\n\t/** Where this harness keeps its own MCP servers; `doctor` compares against it and never writes. */\n\tmcpConfig?: McpConfig\n\t/** What this harness reads that no other can, reported so it can be converted to canonical form. */\n\tnonstandard?: readonly NonstandardArtifact[]\n}\n\nexport type Harness = {\n\tname: HarnessName\n\t/** What this harness does inside a repository. `init` and `doctor` act only here. */\n\tproject: HarnessScope\n\t/**\n\t * Outside any repository; absent when no user-scope path is documented (e.g. Devin).\n\t * Diagnosable, never written.\n\t */\n\tuser?: HarnessScope\n\t/** Set when this name has been superseded; the value is the name that replaces it. */\n\tdeprecated?: HarnessName\n}\n\n/**\n * Throws on a harness `skillsDirectories` does not confirm: treating it as native would silently\n * drop a projection it may need.\n */\nexport function skillsProjection(\n\tharness: HarnessId,\n\tscope: HarnessScopeName,\n\tdirectories: readonly string[] | undefined = skillsDirectories(harness)?.[scope],\n): Pick<HarnessScope, 'skillsDirectory'> {\n\tconst listed = directories ?? []\n\tconst [first] = listed\n\tif (first === undefined)\n\t\tthrow new Error(`@cyberuni/agent-harness records no ${scope} skills directories for ${harness}.`)\n\treturn listed.includes('.agents/skills') ? {} : { skillsDirectory: first }\n}\n\n/**\n * Skills directories come from `@cyberuni/agent-harness`, except for the harnesses it does not know\n * (`devin-desktop`, `windsurf`); see `.research/agentic-configuration-standards/` for the rest.\n */\nexport const harnessRegistry: readonly Harness[] = [\n\t{\n\t\tname: 'claude-code',\n\t\tproject: {\n\t\t\tdetect: '.claude',\n\t\t\t...skillsProjection('claude-code', 'project'),\n\t\t\tshadowedBy: ['CLAUDE.md', '.claude/CLAUDE.md', 'CLAUDE.local.md'],\n\t\t\tmcpConfig: { path: '.mcp.json', key: 'mcpServers', format: 'json', dialect: 'claude-code' },\n\t\t\tnonstandard: [\n\t\t\t\t{ path: '.claude/commands', shape: 'directory', kind: 'command' },\n\t\t\t\t{ path: '.claude/rules', shape: 'directory', kind: 'rule' },\n\t\t\t\t{ path: '.claude/agents', shape: 'directory', kind: 'subagent' },\n\t\t\t],\n\t\t},\n\t\tuser: { detect: '.claude', ...skillsProjection('claude-code', 'user') },\n\t},\n\t{\n\t\tname: 'cursor',\n\t\tproject: {\n\t\t\tdetect: '.cursor',\n\t\t\t...skillsProjection('cursor', 'project'),\n\t\t\tmcpConfig: { path: '.cursor/mcp.json', key: 'mcpServers', format: 'json', dialect: 'cursor' },\n\t\t\tnonstandard: [\n\t\t\t\t{ path: '.cursorrules', shape: 'file', kind: 'instructions' },\n\t\t\t\t{ path: '.cursor/rules', shape: 'directory', kind: 'rule' },\n\t\t\t\t{ path: '.cursor/commands', shape: 'directory', kind: 'command' },\n\t\t\t\t{ path: '.cursor/skills', shape: 'directory', kind: 'skill' },\n\t\t\t],\n\t\t},\n\t\tuser: { detect: '.cursor', ...skillsProjection('cursor', 'user') },\n\t},\n\t{\n\t\tname: 'codex',\n\t\tproject: {\n\t\t\tdetect: '.codex',\n\t\t\t...skillsProjection('codex', 'project'),\n\t\t\tmcpConfig: { path: '.codex/config.toml', key: 'mcp_servers', format: 'toml', dialect: 'codex', shared: true },\n\t\t\tnonstandard: [{ path: '.codex/skills', shape: 'directory', kind: 'skill' }],\n\t\t},\n\t\tuser: { detect: '.codex', ...skillsProjection('codex', 'user') },\n\t},\n\t{\n\t\tname: 'copilot-cli',\n\t\tproject: {\n\t\t\tdetect: '.github/skills',\n\t\t\t...skillsProjection('copilot-cli', 'project'),\n\t\t\tnonstandard: [\n\t\t\t\t{ path: '.github/copilot-instructions.md', shape: 'file', kind: 'instructions' },\n\t\t\t\t{ path: '.github/instructions', shape: 'directory', kind: 'instructions' },\n\t\t\t\t{ path: '.github/skills', shape: 'directory', kind: 'skill' },\n\t\t\t],\n\t\t},\n\t\tuser: { detect: '.copilot', ...skillsProjection('copilot-cli', 'user') },\n\t},\n\t{\n\t\tname: 'gemini-cli',\n\t\tproject: {\n\t\t\tdetect: '.gemini',\n\t\t\t...skillsProjection('gemini-cli', 'project'),\n\t\t\tinstructionBridge: { kind: 'settings-entry', path: '.gemini/settings.json', key: 'context.fileName' },\n\t\t\tmcpConfig: {\n\t\t\t\tpath: '.gemini/settings.json',\n\t\t\t\tkey: 'mcpServers',\n\t\t\t\tformat: 'json',\n\t\t\t\tdialect: 'gemini-cli',\n\t\t\t\tshared: true,\n\t\t\t},\n\t\t\tnonstandard: [\n\t\t\t\t{ path: 'GEMINI.md', shape: 'file', kind: 'instructions' },\n\t\t\t\t{ path: '.gemini/skills', shape: 'directory', kind: 'skill' },\n\t\t\t],\n\t\t},\n\t\tuser: { detect: '.gemini', ...skillsProjection('gemini-cli', 'user') },\n\t},\n\t{ name: 'devin-desktop', project: { detect: '.devin' } },\n\t{\n\t\tname: 'windsurf',\n\t\tproject: {\n\t\t\tdetect: '.windsurf',\n\t\t\tskillsDirectory: '.windsurf/skills',\n\t\t\tnonstandard: [\n\t\t\t\t{ path: '.windsurfrules', shape: 'file', kind: 'instructions' },\n\t\t\t\t{ path: '.windsurf/rules', shape: 'directory', kind: 'rule' },\n\t\t\t],\n\t\t},\n\t\tdeprecated: 'devin-desktop',\n\t},\n]\n\nconst harnessNames = new Set<string>(harnessRegistry.map((harness) => harness.name))\n\nfunction isHarnessName(value: string): value is HarnessName {\n\treturn harnessNames.has(value)\n}\n\n/**\n * An unknown name throws rather than being dropped — silently falling back to the defaults would\n * misreport what was diagnosed.\n */\nexport function parseHarnesses(value: string | undefined): HarnessName[] {\n\tconst requested = (value ?? '')\n\t\t.split(',')\n\t\t.map((name) => name.trim())\n\t\t.filter(Boolean)\n\tconst unsupported = requested.filter((name) => !isHarnessName(name))\n\tif (unsupported.length)\n\t\tthrow new Error(\n\t\t\t`Unsupported harness: ${unsupported.join(', ')}. Supported: ${harnessRegistry\n\t\t\t\t.map((harness) => harness.name)\n\t\t\t\t.join(', ')}.`,\n\t\t)\n\treturn requested.filter(isHarnessName)\n}\n\n/** Enabled whether or not the repository already contains their directories. */\nconst defaultHarnesses: readonly HarnessName[] = ['claude-code', 'cursor']\n\nfunction directoryExists(path: string): boolean {\n\ttry {\n\t\treturn lstatSync(path).isDirectory()\n\t} catch {\n\t\treturn false\n\t}\n}\n\n/** The default harnesses, plus the preferred ones, plus every harness whose directory is present. */\nexport function selectHarnesses(root: string, preferred: readonly HarnessName[]): Harness[] {\n\tconst enabled = new Set<HarnessName>([...defaultHarnesses, ...preferred])\n\treturn harnessRegistry.filter(\n\t\t(harness) => enabled.has(harness.name) || directoryExists(join(root, harness.project.detect)),\n\t)\n}\n","/**\n * Position only: a parser's own error message quotes the offending line, and in MCP configuration\n * that line holds a credential.\n */\nexport type Position = { line: number; column: number }\n\n/**\n * Never recover a part by splitting a locator's rendered string back apart — no separator survives\n * a server named `io.github.foo`.\n */\nexport type Locator = {\n\t/** Repository-relative path of the file the finding is about. */\n\tfile: string\n\t/** The MCP server inside that file, when the finding is about one. */\n\tserver?: string\n\t/** The field inside that server, dotted for the per-name fields — `command`, `env.LINEAR_TOKEN`. */\n\tfield?: string\n\t/** Where a file that does not parse failed, when the parser gave a position. */\n\tposition?: Position | undefined\n}\n\n/** The locator as one string: the finding's `path`, and what a repair names. */\nexport function locatorText({ file, server, field, position }: Locator): string {\n\tif (position) return `${file}#L${position.line}:${position.column}`\n\tif (server === undefined) return file\n\treturn `${file}#servers.${server}${field === undefined ? '' : `.${field}`}`\n}\n","import { readdirSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport type { Harness, HarnessScope } from '../harness-registry/harness-registry.ts'\nimport { harnessRegistry } from '../harness-registry/harness-registry.ts'\nimport type { NonstandardKind } from '../harness-registry/nonstandard-artifact.ts'\nimport { type Locator, locatorText } from './locator.ts'\n\n/**\n * The one place `doctor`'s guidance is written: `skills/doctor-buddy-agent-harness/SKILL.md` is\n * generated from this table, so the shipped skill cannot drift from what the command says.\n */\n\n/** Every way a skills bridge fails to resolve, or resolves and is still unsafe, in the order `doctor` reports them. */\nexport type BridgeProblem =\n\t| 'no-canonical'\n\t| 'missing'\n\t| 'degraded'\n\t| 'stale'\n\t| 'diverged-bridge'\n\t| 'diverged-canonical'\n\t| 'diverged-both'\n\t| 'diverged-unknown'\n\t| 'unpinned-copy'\n\n/**\n * Configuration that is present and **wrong**; repaired by the `repair` skill, since `init` never\n * corrects a file the user already wrote.\n */\nexport type ConfigurationFault = 'deprecated-harness' | 'ignored-bridge' | 'unread-local-override' | 'unloadable-skill'\n\n/**\n * Every way the golden MCP server set and a harness's copy of it can disagree, plus the two\n * credential findings.\n */\nexport type McpProblem =\n\t| 'mcp-golden-unreadable'\n\t| 'mcp-target-unreadable'\n\t| 'mcp-unprojected'\n\t| 'mcp-undeclared'\n\t| 'mcp-diverged-target'\n\t| 'mcp-diverged-golden'\n\t| 'mcp-diverged-both'\n\t| 'mcp-diverged-unknown'\n\t| 'mcp-literal-secret'\n\t| 'mcp-committed-secret'\n\n/**\n * Configuration that works, but only for one harness — not wrong, not missing, just narrower reach\n * than the repository intends.\n */\nexport type NonstandardProblem =\n\t| 'nonstandard-instructions'\n\t| 'nonstandard-rule'\n\t| 'nonstandard-command'\n\t| 'nonstandard-skill'\n\t| 'nonstandard-subagent'\n\n/** Every way a harness can end up reading none of `AGENTS.md`. */\nexport type InstructionProblem =\n\t| 'no-instructions'\n\t| 'instructions-missing'\n\t| 'instructions-unbridged'\n\t| 'instructions-unreadable'\n\t| 'instructions-shadowing'\n\t| 'instructions-superseded'\n\n/** Everything `doctor` can report against, across every section. */\nexport type DoctorProblem = BridgeProblem | InstructionProblem | ConfigurationFault | McpProblem | NonstandardProblem\n\n/** Alias kept for callers that name the whole set rather than one section. */\nexport type ConfigurationProblem = DoctorProblem\n\nexport type RepairAction = {\n\t/** A shell invocation that completes the repair, or empty when none does. */\n\tcommand: string\n\t/** The imperative, in prose, always present and complete on its own. */\n\tinstruction: string\n}\n\nexport type Repair = {\n\tproblem: DoctorProblem\n\t/** What `doctor` prints in the `findings` row for this problem. */\n\tdetail: string\n\t/**\n\t * `at` carries the finding in parts; read fields off it rather than splitting the rendered\n\t * locator — no separator survives a server named `io.github.foo`.\n\t */\n\trepair(at: Locator, cli: string): RepairAction\n\t/**\n\t * Delegates bridge rebuilds to the `init-buddy-agent-harness` skill rather than `init`, since\n\t * rebuilding can move user-authored skills.\n\t */\n\tskillRepair(at: Locator): string\n}\n\n/**\n * One row of a repair table, keyed by problem; a `Record<Problem, RepairRow>` fails to compile\n * until every union variant has a row.\n */\nexport type RepairRow = Omit<Repair, 'problem'>\n\n/**\n * Turns a table into the list `doctor` reports; the cast is safe because a `Record<P, RepairRow>`'s\n * keys are `P` by construction.\n */\nfunction repairsOf<Problem extends DoctorProblem>(table: Record<Problem, RepairRow>): readonly Repair[] {\n\treturn (Object.entries(table) as [Problem, RepairRow][]).map(([problem, row]) => ({ problem, ...row }))\n}\n\nexport const commandInvocation = 'buddy-agent-harness'\nexport const skillInvocation = (version: string) => `npx -y ${commandInvocation}@^${version}`\n\n/** Any `npx` invocation of this CLI, pinned or not, so a stale pin is rewritten rather than doubled. */\nexport const anyNpxInvocation: RegExp = /npx -y buddy-agent-harness(@[^\\s`]+)?/g\n\n/** A hand-written `SKILL.md` whose pinned `npx` fallback the generator rewrites in place. */\nexport type PinTarget = { path: string; expected: string }\n\n/**\n * Every hand-written `SKILL.md` under `skillsRoot` naming an `npx` invocation of this package,\n * found by scanning `skills/` rather than a maintained list; `doctor`'s own `SKILL.md` is excluded\n * since `renderDoctorSkill` writes it whole.\n */\nexport function handWrittenPinTargets(skillsRoot: string, version: string): PinTarget[] {\n\tlet skillNames: string[]\n\ttry {\n\t\tskillNames = readdirSync(skillsRoot, { withFileTypes: true })\n\t\t\t.filter((entry) => entry.isDirectory())\n\t\t\t.map((entry) => entry.name)\n\t} catch {\n\t\tskillNames = []\n\t}\n\n\tconst targets: PinTarget[] = []\n\tfor (const skill of [...skillNames].sort()) {\n\t\tif (skill === doctorSkill.name) continue\n\t\tlet content: string\n\t\ttry {\n\t\t\tcontent = readFileSync(join(skillsRoot, skill, 'SKILL.md'), 'utf8')\n\t\t} catch {\n\t\t\tcontinue\n\t\t}\n\t\tif (!content.includes(`npx -y ${commandInvocation}`)) continue\n\t\ttargets.push({\n\t\t\tpath: join(skillsRoot, skill, 'SKILL.md'),\n\t\t\texpected: content.replaceAll(anyNpxInvocation, skillInvocation(version)),\n\t\t})\n\t}\n\treturn targets\n}\n\n/** Named for the subcommand it runs, so a stack trace or process list shows which one it was. */\nexport const launcherFor = (subcommand: string) => `scripts/${subcommand}.mjs`\n\n/**\n * `node` stays in front: the script ships without an executable bit, and its shebang is a no-op on\n * Windows.\n */\nexport const launcherInvocation = (subcommand: string) => `node ${launcherFor(subcommand)}`\n\nexport const repairSkillInvocation = '/buddy-agent-harness:repair'\n\n/**\n * Qualified rather than bare `init`: a skill name is global to the harness loading it, while the\n * subcommand is scoped to this CLI.\n */\nexport const initSkillName = 'init-buddy-agent-harness'\n\nexport const initSkillInvocation: string = `/buddy-agent-harness:${initSkillName}`\n\n/** Where the user authors the golden MCP server set, named in every MCP repair that points at it. */\nconst goldenSet = '.agents/buddy-agent-harness/mcp.toml'\n\nconst bridgeTable: Record<BridgeProblem, RepairRow> = {\n\t'no-canonical': {\n\t\tdetail: 'the canonical skill directory does not exist, so no bridge can resolve',\n\t\trepair: (_at, cli) => ({\n\t\t\tcommand: `${cli} init`,\n\t\t\tinstruction: `run \\`${cli} init\\` to create .agents/skills and the bridges into it`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${initSkillInvocation}\\`, which creates \\`.agents/skills\\` and the bridges`,\n\t},\n\tmissing: {\n\t\tdetail: 'no bridge at this path — the harness sees zero project skills',\n\t\trepair: ({ file }, cli) => ({\n\t\t\tcommand: `${cli} init`,\n\t\t\tinstruction: `run \\`${cli} init\\` to create the bridge at ${file}`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${initSkillInvocation}\\``,\n\t},\n\tdegraded: {\n\t\tdetail: 'expected a directory but found a regular file — checkout without core.symlinks',\n\t\trepair: ({ file }, cli) => ({\n\t\t\tcommand: `${cli} init --copy --force ${file}`,\n\t\t\tinstruction: `run \\`${cli} init --copy --force ${file}\\` to rebuild ${file} as a real directory`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `run \\`${initSkillInvocation} --copy --force ${file}\\``,\n\t},\n\tstale: {\n\t\tdetail: 'symlink does not resolve to .agents/skills',\n\t\trepair: ({ file }, cli) => ({\n\t\t\tcommand: `${cli} init --force ${file}`,\n\t\t\tinstruction: `run \\`${cli} init --force ${file}\\` to repoint ${file} at .agents/skills`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `run \\`${initSkillInvocation} --force ${file}\\``,\n\t},\n\t'diverged-bridge': {\n\t\tdetail: 'only the bridge changed since the two last agreed — an agent wrote through the copy',\n\t\t// No command: `init` only ever builds a bridge from the canonical directory, so no flag\n\t\t// promotes the bridge's content back into it.\n\t\trepair: ({ file }, cli) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `replace .agents/skills with ${file} to keep the newer edit, then run \\`${cli} init --force ${file}\\``,\n\t\t}),\n\t\tskillRepair: ({ file }) =>\n\t\t\t`replace .agents/skills with ${file} to keep the newer edit, then run \\`${initSkillInvocation} --force ${file}\\``,\n\t},\n\t'diverged-canonical': {\n\t\tdetail: 'only .agents/skills changed since the two last agreed — the copy is stale',\n\t\trepair: ({ file }, cli) => ({\n\t\t\tcommand: `${cli} init --copy --force ${file}`,\n\t\t\tinstruction: `run \\`${cli} init --copy --force ${file}\\` to rebuild ${file} from the newer .agents/skills`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `run \\`${initSkillInvocation} --copy --force ${file}\\``,\n\t},\n\t'diverged-both': {\n\t\tdetail: 'both sides changed since they last agreed — rebuilding would discard one of them',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `reconcile .agents/skills with ${file} by hand — rebuilding would discard one of them; \\`git diff --no-index .agents/skills ${file}\\` shows what differs`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `run \\`git diff --no-index .agents/skills ${file}\\` and reconcile by hand`,\n\t},\n\t'diverged-unknown': {\n\t\tdetail: 'contents differ and no commit where they agreed was found — which side moved is unknown',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `reconcile .agents/skills with ${file} by hand — which side moved is unknown; \\`git diff --no-index .agents/skills ${file}\\` shows what differs`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `run \\`git diff --no-index .agents/skills ${file}\\` and reconcile by hand`,\n\t},\n\t'unpinned-copy': {\n\t\tdetail: 'tracked copy without the skip-worktree bit — the tree is dirty with content that must not be committed',\n\t\t// Reads paths back from git rather than assuming them: the tracked entry is a symlink on a\n\t\t// Windows checkout, but individual files in a committed copy.\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: `git ls-files -z ${file} | xargs -0 git update-index --skip-worktree`,\n\t\t\tinstruction: `run \\`git ls-files -z ${file} | xargs -0 git update-index --skip-worktree\\` to restore the skip-worktree bit`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `run \\`git ls-files -z ${file} | xargs -0 git update-index --skip-worktree\\``,\n\t},\n}\n\nexport const bridgeRepairs: readonly Repair[] = repairsOf(bridgeTable)\n\n/**\n * Everything reported in `instructions`: bridges into `AGENTS.md` and the files that suppress it.\n * Every repair is the `init-buddy-agent-harness` skill's judgment, never a shell command.\n */\nconst instructionTable: Record<InstructionProblem, RepairRow> = {\n\t'no-instructions': {\n\t\tdetail: 'no AGENTS.md at the repository root, so the instructions this repository has reach one harness at most',\n\t\trepair: () => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `hand this to \\`${initSkillInvocation}\\`, which consolidates what the repository has into AGENTS.md, or derives it`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${initSkillInvocation}\\`, which consolidates or derives AGENTS.md`,\n\t},\n\t'instructions-missing': {\n\t\tdetail: 'no instruction bridge at this path — the harness reads none of AGENTS.md',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `hand ${file} to \\`${initSkillInvocation}\\`, which writes the bridge into it`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${initSkillInvocation}\\``,\n\t},\n\t'instructions-unbridged': {\n\t\tdetail: 'the file is present but names AGENTS.md nowhere — the harness reads none of it',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `hand ${file} to \\`${initSkillInvocation}\\`, which adds the bridge without discarding what the file already says`,\n\t\t}),\n\t\tskillRepair: () =>\n\t\t\t`run \\`${initSkillInvocation}\\`, which adds the bridge without discarding what the file already says`,\n\t},\n\t'instructions-shadowing': {\n\t\tdetail: 'this file suppresses the AGENTS.md beside it — the harness reads this instead, and none of AGENTS.md',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `hand ${file} to \\`${initSkillInvocation}\\`, which consolidates what it says into AGENTS.md, or adds an @AGENTS.md import above it where the file has to stay`,\n\t\t}),\n\t\tskillRepair: () =>\n\t\t\t`run \\`${initSkillInvocation}\\`, which consolidates the file into AGENTS.md or imports AGENTS.md from it`,\n\t},\n\t'instructions-superseded': {\n\t\tdetail: 'a bridge from before the harness read AGENTS.md itself — it still works, and nothing needs it',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `remove ${file}, or keep it for sessions that cannot read AGENTS.md directly — \\`${initSkillInvocation}\\` offers the choice`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${initSkillInvocation}\\`, which offers to remove it`,\n\t},\n\t'instructions-unreadable': {\n\t\tdetail: 'the settings file does not parse, so the harness reads none of it',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `fix the JSON in ${file} by hand, then hand it to \\`${initSkillInvocation}\\``,\n\t\t}),\n\t\tskillRepair: () => `fix the JSON by hand, then run \\`${initSkillInvocation}\\``,\n\t},\n}\n\nexport const instructionRepairs: readonly Repair[] = repairsOf(instructionTable)\n\nconst configurationTable: Record<ConfigurationFault, RepairRow> = {\n\t'deprecated-harness': {\n\t\tdetail:\n\t\t\t'a projection under a harness name that has been superseded — the replacement reads .agents/skills natively and needs no projection at all',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `remove ${file} and enable the harness that replaced it — \\`${repairSkillInvocation}\\` offers the correction`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${repairSkillInvocation}\\``,\n\t},\n\t'ignored-bridge': {\n\t\tdetail: 'a .gitignore rule matches this bridge — an untracked bridge swallows a real edit silently',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `narrow or remove the .gitignore rule matching ${file} — \\`${repairSkillInvocation}\\` offers the correction`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${repairSkillInvocation}\\``,\n\t},\n\t'unread-local-override': {\n\t\tdetail: 'no harness reads this filename, so everything in it is invisible to every agent',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `move ${file} to CLAUDE.local.md, or consolidate it into AGENTS.md — \\`${repairSkillInvocation}\\` offers the correction`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${repairSkillInvocation}\\``,\n\t},\n\t'unloadable-skill': {\n\t\tdetail: 'frontmatter that does not parse, or no description — either one makes a harness skip the skill outright',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `quote the description in ${file}, or add one — \\`${repairSkillInvocation}\\` offers the correction`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${repairSkillInvocation}\\``,\n\t},\n}\n\nexport const configurationRepairs: readonly Repair[] = repairsOf(configurationTable)\n\n/**\n * Every repair names a locator rather than a file, and the locator never carries a credential\n * value.\n */\nconst mcpTable: Record<McpProblem, RepairRow> = {\n\t'mcp-golden-unreadable': {\n\t\tdetail:\n\t\t\t'the golden MCP set does not parse — the locator gives the line and column, and nothing else can be said about it',\n\t\trepair: (at) => ({ command: '', instruction: `fix the TOML at ${locatorText(at)}` }),\n\t\tskillRepair: (at) =>\n\t\t\t`fix the TOML at ${locatorText(at)} by hand — the reported line and column are all that can be quoted, because the parser's own message repeats the offending line and that line is the one holding the credential`,\n\t},\n\t'mcp-target-unreadable': {\n\t\tdetail:\n\t\t\t'this harness config does not parse, so the harness starts none of its servers and nothing in it can be compared',\n\t\trepair: (at) => ({ command: '', instruction: `fix the syntax of ${locatorText(at)}` }),\n\t\tskillRepair: (at) => `fix the syntax of ${locatorText(at)} by hand`,\n\t},\n\t'mcp-unprojected': {\n\t\tdetail: 'the golden set declares this server and the harness config does not carry it',\n\t\trepair: ({ file, server }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `add the server ${server} to ${file}, or drop it from the golden set — \\`${repairSkillInvocation}\\` offers the correction`,\n\t\t}),\n\t\tskillRepair: (at) =>\n\t\t\t`hand ${locatorText(at)} to \\`${repairSkillInvocation}\\`, which projects it from its golden entry with \\`mcp project\\` — or drop it from the golden set`,\n\t},\n\t'mcp-undeclared': {\n\t\tdetail: 'the harness config carries this server and the golden set does not declare it',\n\t\trepair: ({ file, server }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `add the server ${server} to ${goldenSet}, or drop it from ${file} — \\`${repairSkillInvocation}\\` offers the import`,\n\t\t}),\n\t\tskillRepair: (at) =>\n\t\t\t`hand ${locatorText(at)} to \\`${repairSkillInvocation}\\`, which imports it field by field with \\`mcp reconcile\\`, refusing any literal credential — or drop it from ${at.file}`,\n\t},\n\t'mcp-diverged-target': {\n\t\tdetail: 'only the harness config changed since the two last agreed — the edit was made through the copy',\n\t\trepair: (at) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `reconcile the value at ${locatorText(at)} back into ${goldenSet} — \\`${repairSkillInvocation}\\` offers the import`,\n\t\t}),\n\t\tskillRepair: (at) =>\n\t\t\t`hand ${locatorText(at)} to \\`${repairSkillInvocation}\\`, which imports the field into ${goldenSet} with \\`mcp reconcile\\` once approved`,\n\t},\n\t'mcp-diverged-golden': {\n\t\tdetail: 'only the golden set changed since the two last agreed — the harness copy is stale',\n\t\trepair: (at) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `update ${locatorText(at)} from the golden entry — \\`${repairSkillInvocation}\\` offers the correction`,\n\t\t}),\n\t\tskillRepair: (at) =>\n\t\t\t`hand ${locatorText(at)} to \\`${repairSkillInvocation}\\`, which updates it from the golden entry with \\`mcp project\\``,\n\t},\n\t'mcp-diverged-both': {\n\t\tdetail: 'both sides changed since they last agreed — merging either way would discard the other',\n\t\trepair: (at) => ({ command: '', instruction: `reconcile ${locatorText(at)} against ${goldenSet} by hand` }),\n\t\tskillRepair: (at) =>\n\t\t\t`reconcile ${locatorText(at)} against ${goldenSet} by hand — never merge a three-way conflict automatically`,\n\t},\n\t'mcp-diverged-unknown': {\n\t\tdetail:\n\t\t\t'the two disagree and no baseline says which side moved — neither history nor a last-projected record covers this server',\n\t\trepair: (at) => ({ command: '', instruction: `compare ${locatorText(at)} against ${goldenSet} by hand` }),\n\t\tskillRepair: (at) => `compare ${locatorText(at)} against ${goldenSet} by hand`,\n\t},\n\t'mcp-literal-secret': {\n\t\tdetail: 'a credential-bearing field holds a literal rather than a reference to an environment variable',\n\t\trepair: (at) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `move the value at ${locatorText(at)} into an environment variable and reference it`,\n\t\t}),\n\t\tskillRepair: (at) =>\n\t\t\t`move the value at ${locatorText(at)} into an environment variable and reference it — read the value from the file, never from this report, and never repeat it back`,\n\t},\n\t'mcp-committed-secret': {\n\t\tdetail:\n\t\t\t'a credential-bearing field holds a literal in a git-tracked file — the credential is committed, and moving it does not un-commit it',\n\t\trepair: (at) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `rotate the credential behind ${locatorText(at)}, then reference it from an environment variable`,\n\t\t}),\n\t\tskillRepair: (at) =>\n\t\t\t`rotate the credential behind ${locatorText(at)} at its issuer, then reference it from an environment variable — it is in the repository's history, so moving it is not enough`,\n\t},\n}\n\nexport const mcpRepairs: readonly Repair[] = repairsOf(mcpTable)\n\n/**\n * Every repair here is a conversion owned by the `init-buddy-agent-harness` skill, except\n * `nonstandard-subagent`, which names no owner since no cross-harness format exists to convert to.\n */\nconst nonstandardTable: Record<NonstandardProblem, RepairRow> = {\n\t'nonstandard-instructions': {\n\t\tdetail: 'instruction content only one harness reads — AGENTS.md carries the same prose to all of them',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `consolidate ${file} into AGENTS.md and leave a generated bridge in its place — \\`${initSkillInvocation}\\` offers the consolidation`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `hand ${file} to \\`${initSkillInvocation}\\`, which consolidates it into AGENTS.md`,\n\t},\n\t'nonstandard-rule': {\n\t\tdetail: 'a path-scoped rule only one harness reads — a skill reaches every harness where the scoping is incidental',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `convert ${file} into a skill under .agents/skills where its guidance is not tied to the paths it names — \\`${initSkillInvocation}\\` offers the conversion; keep it where the path scoping is the point`,\n\t\t}),\n\t\tskillRepair: ({ file }) =>\n\t\t\t`hand ${file} to \\`${initSkillInvocation}\\` to convert into a skill, unless the path scoping is load-bearing`,\n\t},\n\t'nonstandard-command': {\n\t\tdetail: 'a harness command file — a skill is the portable form, and this harness reads skills too',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `move ${file} to .agents/skills/<name>/SKILL.md — \\`${initSkillInvocation}\\` offers the move`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `hand ${file} to \\`${initSkillInvocation}\\`, which moves it to .agents/skills`,\n\t},\n\t'nonstandard-skill': {\n\t\tdetail: 'a skill under a harness directory rather than the canonical one, where only that harness finds it',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `move ${file} to .agents/skills and project it back where the harness needs one — \\`${initSkillInvocation}\\` offers the move`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `hand ${file} to \\`${initSkillInvocation}\\`, which moves it to .agents/skills`,\n\t},\n\t'nonstandard-subagent': {\n\t\tdetail:\n\t\t\t'a subagent definition with no cross-harness form — nothing outside this harness can read it, and no canonical form exists yet',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `leave ${file} where it is and record that it reaches one harness only — no portable form exists to convert it to`,\n\t\t}),\n\t\tskillRepair: ({ file }) =>\n\t\t\t`leave ${file} in place — no portable form exists yet, so this is work for a person rather than a skill`,\n\t},\n}\n\nexport const nonstandardRepairs: readonly Repair[] = repairsOf(nonstandardTable)\n\n/**\n * Annotated over the whole union rather than inferred, so an added problem fails to compile until\n * its section carries it.\n */\nconst doctorTable: Record<DoctorProblem, RepairRow> = {\n\t...bridgeTable,\n\t...instructionTable,\n\t...configurationTable,\n\t...mcpTable,\n\t...nonstandardTable,\n}\n\nexport const doctorRepairs: readonly Repair[] = repairsOf(doctorTable)\n\n/** The repair for one problem. Total by construction: the table is keyed by the union. */\nexport function repairFor(problem: DoctorProblem): Repair {\n\treturn { problem, ...doctorTable[problem] }\n}\n\nexport const doctorSkill = {\n\tname: 'doctor-buddy-agent-harness',\n\tdescription:\n\t\t'Use this skill when a repository loads no project skills, when skills are missing after a clone, when a harness appears to be ignoring AGENTS.md, or when checking whether the agent configuration bridges into .claude/skills and the other harness files still resolve.',\n} as const\n\n/** Written into the generated skill so a reader knows not to edit it in place. */\nexport const generatedSkillWarning =\n\t'<!-- Generated from src/diagnose-bridges/doctor-guidance.ts by scripts/generate-skills.ts. Do not edit by hand. -->'\n\n/**\n * A file the generator writes under `skills/doctor-buddy-agent-harness/`, path relative to that\n * directory.\n */\nexport type GeneratedDoc = { path: string; content: string }\n\n/** A repair table, rendered for the skill's reader. */\nfunction repairTable(repairs: readonly Repair[]): string {\n\t// A repair may itself contain a pipe, which would otherwise end the table cell early.\n\tconst cell = (value: string) => value.replaceAll('|', '\\\\|')\n\treturn `| Finding | What it means | Repair |\n| --- | --- | --- |\n${repairs\n\t.map((entry) => `| \\`${entry.problem}\\` | ${entry.detail} | ${cell(entry.skillRepair({ file: '<path>' }))} |`)\n\t.join('\\n')}`\n}\n\n/**\n * The shipped `doctor-buddy-agent-harness` skill; the finding tables live in the reference pages\n * below, not here.\n */\nexport function renderDoctorSkill(version: string): string {\n\treturn `---\nname: ${doctorSkill.name}\ndescription: ${doctorSkill.description}\n---\n\n${generatedSkillWarning}\n\n# Harness Doctor\n\nA repository keeps one canonical configuration: \\`.agents/skills\\` for its skills and \\`AGENTS.md\\` for its instructions. Harnesses that cannot read those get bridges pointing at them: Claude Code needs the skills projection, and Gemini CLI needs the instruction bridge — each reads the other canonical path itself. A bridge that stops resolving is silent: the harness finds nothing and loads zero project skills, with no warning anywhere.\n\nInstructions fail two ways, both as quiet. A bridge that stops resolving costs more than a skills one, because the harness then reads none of the repository's instructions at all. And a harness that reads \\`AGENTS.md\\` natively still reads none of it when a file it prefers sits beside it — a \\`CLAUDE.md\\` next to an \\`AGENTS.md\\` is read *instead of* it, unless it imports it.\n\nDiagnose it:\n\n\\`\\`\\`sh\n${launcherInvocation('doctor')}\n\\`\\`\\`\n\nThat path is relative to this skill's own directory: \\`scripts/doctor.mjs\\` is a self-contained bundle built from this package's source and shipped inside the skill folder through the npm package, so it runs against the current working directory with nothing downloaded and no \\`node_modules\\` needed. Fall back to \\`${skillInvocation(version)} doctor\\` when \\`scripts/doctor.mjs\\` is missing or cannot be run — the case for a skill installed from git rather than from the npm package, which does not carry the bundle.\n\nThe command is read-only. It never repairs anything, so it is safe to run at any point, including from a session-start hook.\n\n## Reading the report\n\n\\`bridges\\` lists every skills bridge \\`init\\` would create for this repository, each with a \\`status\\` of \\`ok\\`, \\`missing\\`, \\`degraded\\`, \\`stale\\`, or \\`diverged\\`.\n\n\\`instructions\\` is everything standing between a harness and \\`AGENTS.md\\`, with a \\`status\\` of \\`ok\\`, \\`missing\\`, \\`unbridged\\`, \\`unreadable\\`, \\`shadowing\\`, or \\`superseded\\`. The last two are not bridges: they are files that suppress an \\`AGENTS.md\\` the harness would otherwise read by itself. A separate section because nothing about any of them is shared with \\`bridges\\`: a different \\`kind\\`, a different status vocabulary, and a repair that is never a command.\n\n\\`findings\\` explains each problem and carries more than the two sections above: the configuration, MCP, and non-standard findings have no section of their own, because they are about files rather than about bridges. \\`help\\` carries each repair, one row per distinct repair, with two columns:\n\n- \\`command\\` — a shell invocation that, run exactly as given, **completes** the repair.\n- \\`instruction\\` — the same repair in the imperative, always present and complete on its own.\n\n\\`command\\` is empty whenever no single invocation does the job, and that emptiness is the signal: act on \\`instruction\\` and do not assemble a command out of it. A runnable invocation quoted *inside* an \\`instruction\\` is not the repair either — \\`diverged-both\\` names \\`git diff --no-index\\` because the diff shows you what differs, not because running it reconciles anything. Apply the repair, then re-run \\`doctor\\`.\n\nNothing in \\`help\\` is wrapped. An earlier version prefixed every repair with \\`Run\\`, which read as an instruction to paste prose into a shell.\n\nDo not run an \\`init\\` command yourself. Rebuilding a skills bridge can move skills a user wrote, and rewriting an instruction file touches prose a person authored — both are the \\`init-buddy-agent-harness\\` skill's judgment, so hand the repair to \\`${initSkillInvocation}\\` instead. Every such repair carries an empty \\`command\\`: a skill invocation has no shell equivalent at all.\n\nWhen every bridge resolves, \\`findings\\` says so outright rather than being empty.\n\nThe default output is TOON, which is what you parse. Add \\`--format text\\` when you need to show the same report to a person, or \\`--format json\\`.\n\n## Where the detail is\n\nEvery \\`problem\\` name routes to exactly one page. Load the page for the finding in front of you and leave the rest unread — the tables are long, and reading four families to act on one is what this split exists to stop.\n\n| Page | Load it for |\n| --- | --- |\n| \\`references/bridges.md\\` | any \\`bridges\\` row that is not \\`ok\\` |\n| \\`references/instructions.md\\` | any \\`instructions\\` row that is not \\`ok\\` |\n| \\`references/configuration.md\\` | a finding about the configuration around the bridges rather than a bridge |\n| \\`references/mcp.md\\` | any finding whose path is an MCP locator — **always** before acting on a credential finding |\n| \\`references/nonstandard.md\\` | a finding about configuration only one harness can read |\n| \\`references/harnesses/<name>.md\\` | the paths and files one named harness uses |\n\n## Rules\n\n- Never repair a \\`diverged-both\\` or \\`diverged-unknown\\` bridge by re-running \\`init\\`. Rebuilding overwrites whichever side holds the newer edit. Reconcile the two directories first.\n- Edit skills at \\`.agents/skills/<name>/SKILL.md\\`. Editing through a bridge is only safe when that bridge is a symlink.\n- Do not add bridges to \\`.gitignore\\`. An untracked bridge swallows a real edit silently.\n- Never repeat a value from a file an \\`mcp-literal-secret\\` or \\`mcp-committed-secret\\` finding points at. The report withheld it on purpose, and quoting it back puts it in the transcript anyway.\n- Write instructions in \\`AGENTS.md\\`, never in \\`CLAUDE.md\\`. Content written there reaches one harness, drifts from the canonical file, and — because Claude Code prefers it — takes \\`AGENTS.md\\` out of that harness's context entirely.\n`\n}\n\n/** Where each kind of harness-exclusive artifact is meant to end up, for the per-harness tables. */\nfunction conversionOf(kind: NonstandardKind): string {\n\tswitch (kind) {\n\t\tcase 'instructions':\n\t\t\treturn '`AGENTS.md`, with a generated bridge left behind'\n\t\tcase 'rule':\n\t\t\treturn 'a skill, where the path scoping is incidental'\n\t\tcase 'command':\n\t\t\treturn '`.agents/skills/<name>/SKILL.md`'\n\t\tcase 'skill':\n\t\t\treturn '`.agents/skills`, projected back if needed'\n\t\tcase 'subagent':\n\t\t\treturn 'nothing yet — no cross-harness format exists'\n\t}\n}\n\n/** How one harness's scope reads, for its generated reference page. */\nfunction scopeRows(scope: HarnessScope): string {\n\tconst bridge = scope.instructionBridge\n\tconst mcp = scope.mcpConfig\n\treturn [\n\t\t`| detection directory | \\`${scope.detect}\\` |`,\n\t\t`| skills projection | ${scope.skillsDirectory ? `\\`${scope.skillsDirectory}\\` — written by \\`init\\`` : 'none — reads `.agents/skills` natively'} |`,\n\t\t`| instruction bridge | ${\n\t\t\tbridge === undefined ? 'none' : `\\`${bridge.path}\\` — \\`AGENTS.md\\` in the \\`${bridge.key}\\` entry`\n\t\t} |`,\n\t\t...(scope.shadowedBy\n\t\t\t? [\n\t\t\t\t\t`| suppresses \\`AGENTS.md\\` | ${scope.shadowedBy\n\t\t\t\t\t\t.map((path) => `\\`${path}\\``)\n\t\t\t\t\t\t.join(\n\t\t\t\t\t\t\t', ',\n\t\t\t\t\t\t)} — this harness reads \\`AGENTS.md\\` itself, and reads one of these instead where it finds one |`,\n\t\t\t\t]\n\t\t\t: []),\n\t\t`| MCP configuration | ${mcp === undefined ? 'none' : `\\`${mcp.path}\\` — the \\`${mcp.key}\\` key, ${mcp.format}${mcp.shared ? ', shared with other settings' : ''}`} |`,\n\t].join('\\n')\n}\n\n/**\n * Generated from the registry rather than written by hand, so a page can't drift from the paths the\n * detectors actually use.\n */\nfunction harnessPage(harness: Harness, hasInitReference: boolean): GeneratedDoc {\n\tconst deprecated =\n\t\tharness.deprecated === undefined\n\t\t\t? ''\n\t\t\t: `\\n> **Superseded by \\`${harness.deprecated}\\`.** The legacy paths still work, so a projection here keeps resolving and \\`doctor\\` reports the name as deprecated rather than broken. New repositories should enable \\`${harness.deprecated}\\`.\\n`\n\n\tconst user =\n\t\tharness.user === undefined\n\t\t\t? '\\nNo user-scope paths are primary-sourced for this harness, so `doctor` describes none.\\n'\n\t\t\t: `\\n## User scope\n\nDescribed, never written: \\`init\\` and \\`doctor\\` both work inside a repository.\n\n| What | Path |\n| --- | --- |\n${scopeRows(harness.user)}\n`\n\n\tconst artifacts = harness.project.nonstandard ?? []\n\tconst nonstandard =\n\t\tartifacts.length === 0\n\t\t\t? ''\n\t\t\t: `\\n## Configuration only this harness reads\n\nReported by \\`doctor\\` so it can be converted; see \\`../nonstandard.md\\` for what each conversion is.\n\n| Path | Kind | Converts to |\n| --- | --- | --- |\n${artifacts\n\t.map(\n\t\t(artifact) =>\n\t\t\t`| \\`${artifact.path}${artifact.shape === 'directory' ? '/' : ''}\\` | ${artifact.kind} | ${conversionOf(artifact.kind)} |`,\n\t)\n\t.join('\\n')}\n`\n\n\tconst editorial = hasInitReference\n\t\t? `\\n## Judgment about this harness\\n\\nWhat to generate for it, what to leave alone, and which claims are contested: \\`../../../${initSkillName}/references/harnesses/${harness.name}.md\\`. That page is hand-written and is the one to read before writing anything for this harness.\\n`\n\t\t: ''\n\n\treturn {\n\t\tpath: `references/harnesses/${harness.name}.md`,\n\t\tcontent: `${generatedSkillWarning}\n\n# ${harness.name}\n${deprecated}\n## Project scope\n\nWhere \\`doctor\\` looks inside a repository.\n\n| What | Path |\n| --- | --- |\n${scopeRows(harness.project)}\n${user}${nonstandard}${editorial}`,\n\t}\n}\n\n/**\n * `initReferences` is read off the filesystem rather than maintained here, so a hand-written\n * harness page is linked without a second edit.\n */\nexport function renderDoctorReferences(initReferences: ReadonlySet<string>): GeneratedDoc[] {\n\treturn [\n\t\t{\n\t\t\tpath: 'references/bridges.md',\n\t\t\tcontent: `${generatedSkillWarning}\n\n# Skills bridge findings\n\n${repairTable(bridgeRepairs)}\n\nSubstitute the reported bridge path for \\`<path>\\`.\n\n## The Windows case\n\nThe common failure is \\`degraded\\`. Creating a symlink on Windows needs a privilege most accounts do not have, and Git for Windows gates it separately with \\`core.symlinks\\`, which its installer leaves off. With \\`core.symlinks=false\\` git does not error — it writes the symlink out as a regular file whose contents are the target path. \\`${initSkillInvocation} --copy --force\\` rebuilds every bridge as a real directory on that machine; name one bridge to rebuild only that one.\n\nA copy is a snapshot rather than a live projection, and an agent that edits a skill through it writes into the copy instead of into \\`.agents/skills\\`. That is what the \\`diverged\\` findings catch.\n`,\n\t\t},\n\t\t{\n\t\t\tpath: 'references/instructions.md',\n\t\t\tcontent: `${generatedSkillWarning}\n\n# Instruction findings\n\nTwo shapes, one section. A **bridge** is what a harness needs before it can read \\`AGENTS.md\\` at all — Gemini CLI is the only one left that needs one. A **shadow** is the reverse: a file sitting beside an \\`AGENTS.md\\` that a harness reading it natively prefers, so the canonical file is never read. Claude Code is the case, and the files are \\`CLAUDE.md\\`, \\`.claude/CLAUDE.md\\`, and \\`CLAUDE.local.md\\`.\n\n${repairTable(instructionRepairs)}\n\n\\`unbridged\\` is the one to read carefully. The file is there and looks fine, and it names \\`AGENTS.md\\` nowhere — a \\`.gemini/settings.json\\` another tool rewrote without \\`AGENTS.md\\` in \\`context.fileName\\`. Never fix it by replacing the file: the content that displaced the bridge may be the only copy of something.\n\n\\`shadowing\\` is the same failure from the other direction, and the most expensive finding in this section: nothing is missing, nothing looks wrong, and the harness is reading a file the rest of the repository does not maintain. Consolidate what the file says into \\`AGENTS.md\\`, or — where the file has to stay, as a gitignored \\`CLAUDE.local.md\\` does — put an \\`@AGENTS.md\\` import in it so both load.\n\n\\`superseded\\` is not a fault. It is the bridge this tool used to write, still working and no longer needed, and there is one reason to keep it: sessions that cannot read \\`AGENTS.md\\` directly — a Claude Code before v2.1.277, a third-party provider such as Amazon Bedrock, telemetry disabled, or hooks disabled. Offer the removal; do not make it.\n\nShadows are reported per directory holding an \\`AGENTS.md\\`, so a monorepo gets one row per suppressed file rather than one per repository. A \\`CLAUDE.md\\` in one subtree says nothing about another.\n`,\n\t\t},\n\t\t{\n\t\t\tpath: 'references/configuration.md',\n\t\t\tcontent: `${generatedSkillWarning}\n\n# Configuration findings\n\nThe bridges resolve, and the configuration around them is still wrong: a superseded harness name, a git-ignored bridge, a local-override file nothing reads, a skill whose frontmatter makes every harness skip it. None of these is an \\`init\\` flag — \\`init\\` consolidates and creates, and will not correct a file the user already wrote. They go to the \\`repair\\` skill, which offers each correction with its before and after and writes only what is approved.\n\n${repairTable(configurationRepairs)}\n`,\n\t\t},\n\t\t{\n\t\t\tpath: 'references/mcp.md',\n\t\t\tcontent: `${generatedSkillWarning}\n\n# MCP findings\n\nA repository may keep a **golden MCP server set** at \\`${goldenSet}\\` — one canonical entry per server, in the superset of fields the supported hosts accept, written by the user. Where it exists, \\`doctor\\` compares it against each harness's own MCP configuration and reports how the two have drifted. **No golden set means no MCP drift findings at all**, and a harness with no MCP file yet has nothing that could have drifted.\n\nComparison is semantic. Six config keys across three file formats means no two of these files are ever byte-equal, so each side is parsed into one model and the models are compared. Each harness file is read in that harness's own spelling, and only over the fields it has a place for: a golden \\`description\\` Cursor cannot hold is not drift. A field the golden set leaves unset is never a difference, however a harness fills it in: a host restating its own default and a user's deliberate edit are indistinguishable there, and treating both as changes is what makes a golden set accumulate noise.\n\nEach finding names a **locator**, not a file: \\`.cursor/mcp.json#servers.linear.command\\` is the server and field, and that is what you route on.\n\n${repairTable(mcpRepairs)}\n\n## Credentials\n\nThe two secret findings are the ones to handle carefully.\n\n- **The report never contains the value.** It gives you the locator and stops. Read the value out of the file named in the locator, and do not repeat it into your reply, into a commit message, or into any other file. There is no truncated preview to work from because a truncated credential is a leaked credential in the same transcript.\n- **\\`mcp-committed-secret\\` is not \\`mcp-literal-secret\\` with worse wording.** The file is tracked, so the value is in the repository's history and every clone already has it. Moving it into an environment variable fixes the working tree and changes nothing about that. Rotate it at its issuer first.\n- **A reference passes.** \\`\\${LINEAR_TOKEN}\\` and \\`Bearer \\${LINEAR_TOKEN}\\` are the documented ways to write these fields and are never reported. The test is that shape, not how random the value looks.\n- **An unreadable golden set is reported by position only.** The parser's own message quotes the line it failed on, and in this file that line is the one holding the credential — so neither the message nor the offending line is ever carried into the report. Open the file at the reported line and column.\n`,\n\t\t},\n\t\t{\n\t\t\tpath: 'references/nonstandard.md',\n\t\t\tcontent: `${generatedSkillWarning}\n\n# Non-standard configuration\n\nConfiguration only one harness can read. Nothing here is broken — a Cursor rule does exactly what it says — which is why none of it is in the other four families. What these findings report is **reach**: guidance that lands in one tool and nowhere else, where nobody finds out except by noticing an agent behave differently somewhere else.\n\nEach finding names the canonical form it converts to. The direction is always the same: move the content to a canonical source, and let the harness file be **generated** from it rather than authored beside it. A repository with none of these is the target; it is a direction to walk, not a gate to pass.\n\n${repairTable(nonstandardRepairs)}\n\n## Two of them need judgment, not a move\n\n**A path-scoped rule may have nowhere to go.** \\`AGENTS.md\\` scopes by directory nesting and a skill is loaded on relevance, so neither reproduces \"these globs and no others\". Where the scoping is incidental — a rule that happens to name paths but says something generally true — a skill carries it everywhere. Where the scoping is the point, leave it, and the finding stays as the record of why.\n\n**A subagent has no portable form at all.** No cross-harness format exists, so the finding is the gap rather than a repair. It names no skill, and it is work for a person if it is work at all.\n\n## What is not reported\n\nA harness directory that is a **symlink** is a projection someone already made, not configuration authored here. An artifact is reported whether or not its harness is enabled: a \\`.cursorrules\\` in a repository nobody opens in Cursor is still instruction content \\`AGENTS.md\\` does not carry, and filtering by the enabled set would hide exactly the drift worth converting.\n\nHooks, LSP settings, and output styles are not covered yet. Their event names and shapes differ by harness with no safe projection, and half-reporting them would be worse than the silence.\n`,\n\t\t},\n\t\t...harnessRegistry.map((harness) => harnessPage(harness, initReferences.has(harness.name))),\n\t]\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { filesUnder } from '../diagnose-bridges/directory-files.ts'\nimport { type ConfigurationProblem, type RepairAction, repairFor } from '../diagnose-bridges/doctor-guidance.ts'\nimport type { GitBridgeState } from '../diagnose-bridges/git-bridge-state.ts'\nimport { selectHarnesses } from '../harness-registry/harness-registry.ts'\n\n/**\n * The configuration half of `doctor` — present-and-wrong findings about a harness's config, not\n * whether something is missing (`init`'s job) or an instruction bridge (`diagnose-instructions`'s).\n * Read-only.\n */\nexport type ConfigurationFinding = {\n\t/** Repository-relative path the finding is about. */\n\tpath: string\n\tproblem: ConfigurationProblem\n\tdetail: string\n\t/**\n\t * What repairs it, already carrying the path; `command` is always empty since every fault here\n\t * is judgment.\n\t */\n\trepair: RepairAction\n}\n\nexport type DiagnoseConfigurationOptions = {\n\troot: string\n\tgit: GitBridgeState\n\t/** How to name this tool in the repair commands. */\n\tcli: string\n}\n\nconst canonicalSkills = '.agents/skills'\nconst localOverride = 'AGENTS.local.md'\n\n/**\n * The two frontmatter faults that make a harness skip a skill outright (see\n * `skills/init-buddy-agent-harness/references/frontmatter.md`): unparseable YAML, and a missing\n * `description`. A name/directory mismatch only warns and still loads, so it's not checked here.\n * Checked directly for an unquoted colon rather than by parsing YAML — the package ships no parser.\n */\nfunction frontmatterFault(body: string): 'unparseable' | 'no-description' | undefined {\n\tconst block = /^---\\n([\\s\\S]*?)\\n---/.exec(body)\n\tif (!block) return 'unparseable'\n\tconst description = /^description:[ \\t]*(.*)$/m.exec(block[1] as string)\n\tconst value = description?.[1]?.trim()\n\tif (!value) return 'no-description'\n\tconst quoted = /^(['\"]).*\\1$/.test(value)\n\tif (!quoted && /:\\s/.test(value)) return 'unparseable'\n\treturn undefined\n}\n\n/**\n * Takes no harness preference, unlike `diagnoseBridges`: every check here needs the projection to\n * already exist on disk, which already selects the harness — a preference could never add a finding.\n */\nexport function diagnoseConfiguration({ root, git, cli }: DiagnoseConfigurationOptions): ConfigurationFinding[] {\n\tconst findings: ConfigurationFinding[] = []\n\tconst add = (path: string, problem: ConfigurationProblem) => {\n\t\tconst { detail, repair } = repairFor(problem)\n\t\tfindings.push({ path, problem, detail, repair: repair({ file: path }, cli) })\n\t}\n\n\tconst harnesses = selectHarnesses(root, [])\n\n\t// A superseded name whose projection still exists — `init` keeps projecting since the old path\n\t// still works, so nothing else flags it as stale.\n\tfor (const harness of harnesses) {\n\t\tconst projection = harness.project.skillsDirectory\n\t\tif (harness.deprecated && projection && existsSync(join(root, projection))) add(projection, 'deprecated-harness')\n\t}\n\n\t// An ignored bridge is untracked, and an untracked bridge swallows a real edit silently.\n\tfor (const harness of harnesses) {\n\t\tconst path = harness.project.skillsDirectory\n\t\tif (path && existsSync(join(root, path)) && git.isIgnored(path)) add(path, 'ignored-bridge')\n\t}\n\n\t// No harness reads this filename, so whatever it holds is invisible to every agent.\n\tif (existsSync(join(root, localOverride))) add(localOverride, 'unread-local-override')\n\n\t// `filesUnder` already confirmed these are readable files, so a failure here is a genuine IO\n\t// error, not a guard to add.\n\tfor (const file of filesUnder(join(root, canonicalSkills)).filter((file) => file.endsWith('SKILL.md'))) {\n\t\tif (frontmatterFault(readFileSync(join(root, canonicalSkills, file), 'utf8')))\n\t\t\tadd(`${canonicalSkills}/${file}`, 'unloadable-skill')\n\t}\n\n\treturn findings\n}\n","import { isRecord } from '../is-record/is-record.ts'\nexport type McpTransport = 'stdio' | 'http' | 'sse'\n\n/** A superset of every host's fields (E-MCP-05): carry what the user wrote, never invent a value. */\nexport type McpServer = {\n\ttransport?: McpTransport\n\tcommand?: string\n\targs?: readonly string[]\n\tenv?: Readonly<Record<string, string>>\n\turl?: string\n\theaders?: Readonly<Record<string, string>>\n\tdescription?: string\n\tenabled?: boolean\n\ttimeout?: number\n\tsource?: string\n}\n\n/** Every field of the model, in the order a finding reports them. */\nexport const mcpFields = [\n\t'transport',\n\t'command',\n\t'args',\n\t'env',\n\t'url',\n\t'headers',\n\t'description',\n\t'enabled',\n\t'timeout',\n\t'source',\n] as const\n\nexport type McpField = (typeof mcpFields)[number]\n\n/** The two fields holding one value per name rather than a single value. */\nconst mapFields = new Set<McpField>(['env', 'headers'])\n\n/** Arrays compare ordered (`args` is a command line); maps compare by sorted entries. */\nfunction sameValue(field: McpField, left: unknown, right: unknown): boolean {\n\tif (mapFields.has(field) && isRecord(left) && isRecord(right)) {\n\t\tconst keys = Object.keys(left)\n\t\treturn keys.length === Object.keys(right).length && keys.every((key) => left[key] === right[key])\n\t}\n\treturn JSON.stringify(left) === JSON.stringify(right)\n}\n\n/** Only over `fields`: a golden field the target has no place for is dropped on write, not drift. */\nexport function divergingFields(\n\tgolden: McpServer,\n\ttarget: McpServer,\n\tfields: ReadonlySet<McpField> = new Set(mcpFields),\n): McpField[] {\n\treturn mcpFields.filter((field) => {\n\t\tif (!fields.has(field)) return false\n\t\tconst declared = golden[field]\n\t\tif (declared === undefined) return false\n\t\tif (mapFields.has(field) && isRecord(declared) && isRecord(target[field])) {\n\t\t\tconst observed = target[field] as Record<string, unknown>\n\t\t\treturn Object.keys(declared).some((key) => declared[key] !== observed[key])\n\t\t}\n\t\treturn !sameValue(field, declared, target[field])\n\t})\n}\n\n/** Whether one field of two models agrees, for naming the side that moved. */\nexport function sameField(field: McpField, left: McpServer | undefined, right: McpServer | undefined): boolean {\n\treturn sameValue(field, left?.[field], right?.[field])\n}\n\nfunction stringMap(value: unknown): Record<string, string> | undefined {\n\tif (!isRecord(value)) return undefined\n\tconst entries = Object.entries(value).filter(([, item]) => typeof item === 'string') as [string, string][]\n\treturn entries.length ? Object.fromEntries(entries) : undefined\n}\n\nconst transports = new Set<string>(['stdio', 'http', 'sse'])\n\n/**\n * Infers transport when unstated (`url` → `http`, `command` → `stdio`), so a `url` entry in one\n * file compares equal to a `type: http` entry in another.\n */\nfunction transportOf(entry: Record<string, unknown>): McpTransport | undefined {\n\tconst declared = entry['type'] ?? entry['transport']\n\tif (typeof declared === 'string' && transports.has(declared)) return declared as McpTransport\n\tif (typeof entry['url'] === 'string') return 'http'\n\tif (typeof entry['command'] === 'string') return 'stdio'\n\treturn undefined\n}\n\n/**\n * One host or golden entry, converted into the shared model; a field of the wrong type is dropped\n * rather than carried through, so a `timeout` that is a string does not report as a divergence.\n * Also used by `mcp-inventory.ts`, which normalizes its own raw shapes into these same fields\n * first.\n */\nexport function serverFrom(entry: Record<string, unknown>): McpServer {\n\tconst args = Array.isArray(entry['args']) && entry['args'].every((item) => typeof item === 'string')\n\tconst transport = transportOf(entry)\n\tconst env = stringMap(entry['env'])\n\tconst headers = stringMap(entry['headers'])\n\treturn {\n\t\t...(transport ? { transport } : {}),\n\t\t...(typeof entry['command'] === 'string' ? { command: entry['command'] } : {}),\n\t\t...(args ? { args: entry['args'] as string[] } : {}),\n\t\t...(env ? { env } : {}),\n\t\t...(typeof entry['url'] === 'string' ? { url: entry['url'] } : {}),\n\t\t...(headers ? { headers } : {}),\n\t\t...(typeof entry['description'] === 'string' ? { description: entry['description'] } : {}),\n\t\t...(typeof entry['enabled'] === 'boolean' ? { enabled: entry['enabled'] } : {}),\n\t\t...(typeof entry['timeout'] === 'number' ? { timeout: entry['timeout'] } : {}),\n\t\t...(typeof entry['source'] === 'string' ? { source: entry['source'] } : {}),\n\t}\n}\n","import { type McpField, type McpServer, serverFrom } from '../diagnose-mcp/mcp-model.ts'\nimport { isRecord } from '../is-record/is-record.ts'\n\nexport type McpDialectName = 'claude-code' | 'cursor' | 'codex' | 'gemini-cli'\n\nexport type McpRendering =\n\t| { kind: 'entry'; entry: Record<string, unknown> }\n\t| { kind: 'refused'; field: McpField; reason: string }\n\n/**\n * One harness's MCP entry shape, both ways, per `.research/mcp-canonical-location/` E-MCP-12 to\n * E-MCP-16. `write` and `read` are a pair: whatever `write` emits, `read` returns the same model\n * over `fields`.\n */\nexport type McpDialect = {\n\t/** The golden fields this harness has a place for; the rest are dropped on write and never compared. */\n\tfields: ReadonlySet<McpField>\n\t/** Values the harness documents as its own default: present in its file, they may be the harness's, not the user's. */\n\tdefaults?: Partial<McpServer>\n\tread(entry: Record<string, unknown>): McpServer\n\twrite(server: McpServer): McpRendering\n}\n\n/** `${NAME}` — the golden set's one reference form, translated per target. */\nconst plainReference = /^\\$\\{([A-Za-z_][A-Za-z0-9_]*)\\}$/\n/** Any reference form a harness might expand, plain or not. */\nconst anyReference = /\\$\\{[^}]*\\}|\\$[A-Za-z_]/\n\nclass Refusal extends Error {\n\tconstructor(\n\t\treadonly field: McpField,\n\t\treadonly reason: string,\n\t) {\n\t\tsuper(reason)\n\t}\n}\n\nfunction refuse(field: McpField, reason: string): never {\n\tthrow new Refusal(field, reason)\n}\n\nfunction rendering(render: () => Record<string, unknown>): McpRendering {\n\ttry {\n\t\treturn { kind: 'entry', entry: render() }\n\t} catch (error) {\n\t\tif (!(error instanceof Refusal)) throw error\n\t\treturn { kind: 'refused', field: error.field, reason: error.reason }\n\t}\n}\n\n/** Either a runnable command or an address — a server with neither has nothing to write. */\nfunction assertRunnable(server: McpServer): void {\n\tif (server.transport === 'stdio' ? !server.command : !server.url)\n\t\trefuse(\n\t\t\tserver.transport === 'stdio' ? 'command' : 'url',\n\t\t\t'the golden set leaves it unset and the target requires it',\n\t\t)\n}\n\nfunction defined(entry: Record<string, unknown>): Record<string, unknown> {\n\treturn Object.fromEntries(Object.entries(entry).filter(([, value]) => value !== undefined))\n}\n\nfunction mapValues(\n\tvalues: Readonly<Record<string, string>> | undefined,\n\tmap: (value: string) => string,\n): Record<string, string> | undefined {\n\treturn values && Object.fromEntries(Object.entries(values).map(([key, value]) => [key, map(value)]))\n}\n\n/** The fields that run a server, restricted to a target that expands no reference in them. */\nfunction noReferenceIn(server: McpServer, fields: readonly ('command' | 'args' | 'url')[], harness: string): void {\n\tfor (const field of fields) {\n\t\tconst value = server[field]\n\t\tconst values = Array.isArray(value) ? value : [value]\n\t\tif (values.some((item) => typeof item === 'string' && anyReference.test(item)))\n\t\t\trefuse(field, `${harness} documents no reference expansion here`)\n\t}\n}\n\nconst claudeCode: McpDialect = {\n\tfields: new Set(['transport', 'command', 'args', 'env', 'url', 'headers', 'description', 'timeout']),\n\tread: serverFrom,\n\twrite: (server) =>\n\t\trendering(() => {\n\t\t\tassertRunnable(server)\n\t\t\treturn defined({\n\t\t\t\ttype: server.transport,\n\t\t\t\tcommand: server.command,\n\t\t\t\targs: server.args,\n\t\t\t\tenv: server.env,\n\t\t\t\turl: server.url,\n\t\t\t\theaders: server.headers,\n\t\t\t\tdescription: server.description,\n\t\t\t\ttimeout: server.timeout,\n\t\t\t})\n\t\t}),\n}\n\n/** Cursor spells a reference `${env:NAME}` and has no default form (E-MCP-13). */\nfunction toCursor(value: string, field: McpField): string {\n\treturn value.replace(/\\$\\{([^}]*)\\}|\\$[A-Za-z_]/g, (match, name: string | undefined) => {\n\t\tif (name === undefined || !plainReference.test(match))\n\t\t\trefuse(field, 'Cursor expands only a plain variable reference, with no default')\n\t\treturn `\\${env:${name}}`\n\t})\n}\n\nfunction fromCursor(value: string): string {\n\treturn value.replace(/\\$\\{env:([A-Za-z_][A-Za-z0-9_]*)\\}/g, (_, name: string) => `\\${${name}}`)\n}\n\nfunction fromCursorEntry(entry: Record<string, unknown>): Record<string, unknown> {\n\tconst strings = (value: unknown) => (typeof value === 'string' ? fromCursor(value) : value)\n\tconst map = (value: unknown) =>\n\t\tisRecord(value) ? Object.fromEntries(Object.entries(value).map(([key, item]) => [key, strings(item)])) : value\n\treturn {\n\t\t...entry,\n\t\tcommand: strings(entry['command']),\n\t\targs: Array.isArray(entry['args']) ? entry['args'].map(strings) : entry['args'],\n\t\tenv: map(entry['env']),\n\t\turl: strings(entry['url']),\n\t\theaders: map(entry['headers']),\n\t}\n}\n\n/**\n * Cursor documents `type: \"stdio\"` and no field choosing between SSE and streamable HTTP (E-MCP-13),\n * so a remote server's transport is not a field it holds.\n */\nconst cursor: McpDialect = {\n\tfields: new Set(['command', 'args', 'env', 'url', 'headers']),\n\tread: (entry) => serverFrom(fromCursorEntry(entry)),\n\twrite: (server) =>\n\t\trendering(() => {\n\t\t\tassertRunnable(server)\n\t\t\tconst stdio = server.transport === 'stdio'\n\t\t\treturn defined({\n\t\t\t\ttype: stdio ? 'stdio' : undefined,\n\t\t\t\tcommand: server.command && toCursor(server.command, 'command'),\n\t\t\t\targs: server.args?.map((arg) => toCursor(arg, 'args')),\n\t\t\t\tenv: mapValues(server.env, (value) => toCursor(value, 'env')),\n\t\t\t\turl: server.url && toCursor(server.url, 'url'),\n\t\t\t\theaders: mapValues(server.headers, (value) => toCursor(value, 'headers')),\n\t\t\t})\n\t\t}),\n}\n\nconst bearer = /^Bearer \\$\\{([A-Za-z_][A-Za-z0-9_]*)\\}$/\n\n/**\n * Codex expands no reference in a string and reaches the environment only through named fields\n * (E-MCP-14): `env_vars` passes a variable through under its own name, `env_http_headers` and\n * `bearer_token_env_var` fill a header from one.\n */\nfunction codexEnv(env: Readonly<Record<string, string>> | undefined): Record<string, unknown> {\n\tconst literal: Record<string, string> = {}\n\tconst passed: string[] = []\n\tfor (const [key, value] of Object.entries(env ?? {})) {\n\t\tconst name = plainReference.exec(value)?.[1]\n\t\tif (name === key) passed.push(key)\n\t\telse if (anyReference.test(value)) refuse('env', 'Codex passes a variable through only under its own name')\n\t\telse literal[key] = value\n\t}\n\treturn defined({\n\t\tenv: Object.keys(literal).length ? literal : undefined,\n\t\tenv_vars: passed.length ? passed : undefined,\n\t})\n}\n\nfunction codexHeaders(headers: Readonly<Record<string, string>> | undefined): Record<string, unknown> {\n\tconst literal: Record<string, string> = {}\n\tconst fromEnv: Record<string, string> = {}\n\tlet token: string | undefined\n\tfor (const [key, value] of Object.entries(headers ?? {})) {\n\t\tconst name = plainReference.exec(value)?.[1]\n\t\tconst bearerName = bearer.exec(value)?.[1]\n\t\tif (bearerName && key === 'Authorization') token = bearerName\n\t\telse if (name) fromEnv[key] = name\n\t\telse if (anyReference.test(value))\n\t\t\trefuse('headers', 'Codex fills a header only from a whole variable reference, or Bearer and one')\n\t\telse literal[key] = value\n\t}\n\treturn defined({\n\t\thttp_headers: Object.keys(literal).length ? literal : undefined,\n\t\tenv_http_headers: Object.keys(fromEnv).length ? fromEnv : undefined,\n\t\tbearer_token_env_var: token,\n\t})\n}\n\nfunction stringRecord(value: unknown): Record<string, string> {\n\tif (!isRecord(value)) return {}\n\treturn Object.fromEntries(Object.entries(value).filter(([, item]) => typeof item === 'string')) as Record<\n\t\tstring,\n\t\tstring\n\t>\n}\n\nfunction fromCodex(entry: Record<string, unknown>): Record<string, unknown> {\n\tconst passed = Array.isArray(entry['env_vars']) ? entry['env_vars'].filter((name) => typeof name === 'string') : []\n\tconst env = { ...stringRecord(entry['env']), ...Object.fromEntries(passed.map((name) => [name, `\\${${name}}`])) }\n\tconst token = entry['bearer_token_env_var']\n\tconst headers = {\n\t\t...stringRecord(entry['http_headers']),\n\t\t...Object.fromEntries(\n\t\t\tObject.entries(stringRecord(entry['env_http_headers'])).map(([key, name]) => [key, `\\${${name}}`]),\n\t\t),\n\t\t...(typeof token === 'string' ? { Authorization: `Bearer \\${${token}}` } : {}),\n\t}\n\tconst seconds = entry['tool_timeout_sec']\n\treturn {\n\t\tcommand: entry['command'],\n\t\targs: entry['args'],\n\t\tenv,\n\t\turl: entry['url'],\n\t\theaders,\n\t\tenabled: entry['enabled'],\n\t\ttimeout: typeof seconds === 'number' ? Math.round(seconds * 1000) : undefined,\n\t}\n}\n\nconst codex: McpDialect = {\n\tfields: new Set(['transport', 'command', 'args', 'env', 'url', 'headers', 'enabled', 'timeout']),\n\tdefaults: { timeout: 60_000 },\n\tread: (entry) => serverFrom(fromCodex(entry)),\n\twrite: (server) =>\n\t\trendering(() => {\n\t\t\tif (server.transport === 'sse') refuse('transport', 'Codex supports no SSE transport')\n\t\t\tassertRunnable(server)\n\t\t\tnoReferenceIn(server, ['command', 'args', 'url'], 'Codex')\n\t\t\treturn defined({\n\t\t\t\tcommand: server.command,\n\t\t\t\targs: server.args,\n\t\t\t\t...codexEnv(server.env),\n\t\t\t\turl: server.url,\n\t\t\t\t...codexHeaders(server.headers),\n\t\t\t\tenabled: server.enabled,\n\t\t\t\ttool_timeout_sec: server.timeout === undefined ? undefined : server.timeout / 1000,\n\t\t\t})\n\t\t}),\n}\n\n/**\n * Gemini CLI splits the two remote transports into two fields (E-MCP-15), and expands `${NAME}` and\n * `${NAME:-default}` in every string of its settings file (E-MCP-18), so a reference passes through.\n */\nfunction fromGemini(entry: Record<string, unknown>): Record<string, unknown> {\n\tconst { httpUrl, url, ...rest } = entry\n\tif (typeof httpUrl === 'string') return { ...rest, type: 'http', url: httpUrl }\n\treturn typeof url === 'string' ? { ...rest, type: 'sse', url } : rest\n}\n\nconst geminiCli: McpDialect = {\n\tfields: new Set(['transport', 'command', 'args', 'env', 'url', 'headers', 'timeout']),\n\tdefaults: { timeout: 600_000 },\n\tread: (entry) => serverFrom(fromGemini(entry)),\n\twrite: (server) =>\n\t\trendering(() => {\n\t\t\tassertRunnable(server)\n\t\t\treturn defined({\n\t\t\t\tcommand: server.command,\n\t\t\t\targs: server.args,\n\t\t\t\tenv: server.env,\n\t\t\t\turl: server.transport === 'sse' ? server.url : undefined,\n\t\t\t\thttpUrl: server.transport === 'http' ? server.url : undefined,\n\t\t\t\theaders: server.headers,\n\t\t\t\ttimeout: server.timeout,\n\t\t\t})\n\t\t}),\n}\n\nexport const mcpDialects: Record<McpDialectName, McpDialect> = {\n\t'claude-code': claudeCode,\n\tcursor,\n\tcodex,\n\t'gemini-cli': geminiCli,\n}\n","// Gemini CLI strips comments from `settings.json` before parsing (E-JSON-01). Trailing commas stay an\n// error: nothing documents them as accepted.\nexport function stripJsonComments(source: string): string {\n\tlet output = ''\n\tlet index = 0\n\tlet inString = false\n\tlet escaped = false\n\n\twhile (index < source.length) {\n\t\tconst character = source[index] as string\n\n\t\tif (inString) {\n\t\t\toutput += character\n\t\t\tif (escaped) escaped = false\n\t\t\telse if (character === '\\\\') escaped = true\n\t\t\telse if (character === '\"') inString = false\n\t\t\tindex += 1\n\t\t\tcontinue\n\t\t}\n\n\t\tif (character === '\"') {\n\t\t\tinString = true\n\t\t\toutput += character\n\t\t\tindex += 1\n\t\t\tcontinue\n\t\t}\n\n\t\t// A `//` inside a string is an ordinary URL; outside one it can only start a comment.\n\t\tif (character === '/' && source[index + 1] === '/') {\n\t\t\twhile (index < source.length && source[index] !== '\\n') index += 1\n\t\t\tcontinue\n\t\t}\n\n\t\tif (character === '/' && source[index + 1] === '*') {\n\t\t\tindex += 2\n\t\t\twhile (index < source.length && !(source[index] === '*' && source[index + 1] === '/')) index += 1\n\t\t\tindex += 2\n\t\t\tcontinue\n\t\t}\n\n\t\toutput += character\n\t\tindex += 1\n\t}\n\n\treturn output\n}\n\n/** The parsed value, or `undefined` when the file is not JSON even once its comments are gone. */\nexport function parseJsonWithComments(source: string): unknown {\n\ttry {\n\t\treturn JSON.parse(stripJsonComments(source))\n\t} catch {\n\t\treturn undefined\n\t}\n}\n","import { parse as parseToml } from 'smol-toml'\nimport { parseJsonWithComments } from '../diagnose-bridges/json-with-comments.ts'\nimport type { Position } from '../diagnose-bridges/locator.ts'\nimport { selectHarnesses } from '../harness-registry/harness-registry.ts'\nimport type { McpConfig } from '../harness-registry/mcp-config.ts'\nimport { isRecord } from '../is-record/is-record.ts'\nimport { mcpDialects } from '../mcp-dialects/mcp-dialects.ts'\nimport { type McpServer, serverFrom } from './mcp-model.ts'\n\n/** Where the golden set lives, and why it is namespaced rather than sitting at `.agents/mcp.json`. */\nexport const goldenSetPath = '.agents/buddy-agent-harness/mcp.toml'\n\nconst goldenKey = 'servers'\n\n/**\n * The distinct MCP files the enabled harnesses read. No `--harness` preference is accepted: every\n * harness documenting an MCP file is already selected without one, so a preference could never add\n * a target.\n */\nexport function mcpTargets(root: string): McpConfig[] {\n\tconst seen = new Set<string>()\n\treturn selectHarnesses(root, [])\n\t\t.map((harness) => harness.project.mcpConfig)\n\t\t.filter((config): config is McpConfig => config !== undefined)\n\t\t.filter((config) => !seen.has(config.path) && seen.add(config.path))\n}\n\nexport type ParsedServers =\n\t/** The file is absent. Nothing to compare, and not a fault. */\n\t| { kind: 'absent' }\n\t| { kind: 'servers'; servers: Map<string, McpServer> }\n\t| { kind: 'unreadable'; position?: Position | undefined }\n\nfunction serversUnder(\n\tdocument: unknown,\n\tkey: string,\n\tread: (entry: Record<string, unknown>) => McpServer = serverFrom,\n): Map<string, McpServer> {\n\tconst table = isRecord(document) ? document[key] : undefined\n\tif (!isRecord(table)) return new Map()\n\treturn new Map(\n\t\tObject.entries(table)\n\t\t\t.filter(([, entry]) => isRecord(entry))\n\t\t\t.map(([name, entry]) => [name, read(entry as Record<string, unknown>)]),\n\t)\n}\n\n/**\n * Only line and column — never `message` or `codeblock`, which quote the source line and could echo\n * a credential.\n */\nexport function positionOf(error: unknown): Position | undefined {\n\tif (!isRecord(error)) return undefined\n\tconst { line, column } = error\n\treturn typeof line === 'number' && typeof column === 'number' ? { line, column } : undefined\n}\n\n/** The golden set, parsed. Absent is the common case and is not a fault. */\nexport function parseGoldenSet(source: string | undefined): ParsedServers {\n\tif (source === undefined) return { kind: 'absent' }\n\ttry {\n\t\treturn { kind: 'servers', servers: serversUnder(parseToml(source), goldenKey) }\n\t} catch (error) {\n\t\treturn { kind: 'unreadable', position: positionOf(error) }\n\t}\n}\n\n/**\n * One harness's config, parsed under its own key only — `.gemini/settings.json` also carries the\n * instruction bridge. JSON is parsed with comments stripped, matching Gemini CLI's own loader.\n */\nexport function parseTarget(config: McpConfig, source: string | undefined): ParsedServers {\n\tif (source === undefined) return { kind: 'absent' }\n\tif (config.format === 'toml') {\n\t\ttry {\n\t\t\treturn { kind: 'servers', servers: serversUnder(parseToml(source), config.key, mcpDialects[config.dialect].read) }\n\t\t} catch {\n\t\t\treturn { kind: 'unreadable' }\n\t\t}\n\t}\n\tconst document = parseJsonWithComments(source)\n\t// A literal `null` parses successfully and holds no servers — reported the same as `{}`, not as\n\t// unreadable.\n\tif (document === undefined) return { kind: 'unreadable' }\n\treturn { kind: 'servers', servers: serversUnder(document, config.key, mcpDialects[config.dialect].read) }\n}\n","import type { GitBridgeState } from '../diagnose-bridges/git-bridge-state.ts'\nimport { parseJsonWithComments } from '../diagnose-bridges/json-with-comments.ts'\nimport type { McpConfig } from '../harness-registry/mcp-config.ts'\nimport { isRecord } from '../is-record/is-record.ts'\nimport { type McpField, type McpServer, sameField } from './mcp-model.ts'\nimport { goldenSetPath, type ParsedServers, parseGoldenSet, parseTarget } from './mcp-sources.ts'\n\n/** Which side of a diverged server moved since the two last agreed. */\nexport type McpDirection = 'target' | 'golden' | 'both' | 'unknown'\n\n/**\n * Where the record of what was last written to each target lives, beside the golden set it came\n * from.\n */\nexport const projectionRecordPath = '.agents/buddy-agent-harness/mcp.projected.json'\n\nexport function parseProjectionRecord(source: string | undefined): Map<string, Map<string, McpServer>> {\n\tconst document = source === undefined ? undefined : parseJsonWithComments(source)\n\tconst targets = isRecord(document) ? document['targets'] : undefined\n\tif (!isRecord(targets)) return new Map()\n\treturn new Map(\n\t\tObject.entries(targets)\n\t\t\t.filter(([, servers]) => isRecord(servers))\n\t\t\t.map(([path, servers]) => [\n\t\t\t\tpath,\n\t\t\t\tnew Map(\n\t\t\t\t\tObject.entries(servers as Record<string, unknown>)\n\t\t\t\t\t\t.filter(([, server]) => isRecord(server))\n\t\t\t\t\t\t.map(([name, server]) => [name, server as McpServer]),\n\t\t\t\t),\n\t\t\t]),\n\t)\n}\n\n/** The record as written back: one object per target, one golden model per server. */\nexport function formatProjectionRecord(record: Map<string, Map<string, McpServer>>): string {\n\tconst targets = Object.fromEntries([...record].map(([path, servers]) => [path, Object.fromEntries(servers)]))\n\treturn `${JSON.stringify({ targets }, null, 2)}\\n`\n}\n\nexport type BaselineOptions = {\n\tgit: GitBridgeState\n\trecord: Map<string, Map<string, McpServer>>\n}\n\nexport class McpBaseline {\n\tconstructor(private readonly options: BaselineOptions) {}\n\n\t/**\n\t * Memoized per instance: unmemoized, `lastAgreed` would repeat the same `git show` and parse\n\t * for every diverged field. The memo dies with the instance, so it never answers for a working\n\t * tree that has since moved on.\n\t */\n\tprivate readonly parsed = new Map<string, ParsedServers>()\n\tprivate readonly walked = new Map<string, string[]>()\n\n\tdirectionOf(config: McpConfig, name: string, field: McpField, golden: McpServer, target: McpServer): McpDirection {\n\t\tconst base = this.baseFor(config, name, field)\n\t\tif (base === undefined) return 'unknown'\n\t\tconst goldenMoved = !sameField(field, golden, base)\n\t\tconst targetMoved = !sameField(field, target, base)\n\t\tif (goldenMoved && targetMoved) return 'both'\n\t\treturn targetMoved ? 'target' : 'golden'\n\t}\n\n\t/** The server as the two sides last agreed on `field`, or `undefined` when no baseline can say. */\n\tbaseFor(config: McpConfig, name: string, field: McpField): McpServer | undefined {\n\t\tconst recorded = this.options.record.get(config.path)?.get(name)\n\t\tif (recorded) return recorded\n\t\treturn this.lastAgreed(config, name, field)\n\t}\n\n\t/**\n\t * Compared at model granularity, not blob bytes — the two files never share bytes, so a\n\t * reformat wouldn't register as agreement lost.\n\t */\n\tprivate lastAgreed(config: McpConfig, name: string, field: McpField): McpServer | undefined {\n\t\tfor (const commit of this.commitsTouching(config)) {\n\t\t\tconst golden = this.parseAt(commit, goldenSetPath, parseGoldenSet)\n\t\t\tconst target = this.parseAt(commit, config.path, (source) => parseTarget(config, source))\n\t\t\tif (golden.kind !== 'servers' || target.kind !== 'servers') continue\n\t\t\tconst left = golden.servers.get(name)\n\t\t\tconst right = target.servers.get(name)\n\t\t\tif (left && right && sameField(field, left, right)) return left\n\t\t}\n\t\treturn undefined\n\t}\n\n\tprivate commitsTouching(config: McpConfig): string[] {\n\t\tconst walked = this.walked.get(config.path)\n\t\tif (walked) return walked\n\t\tconst commits = this.options.git.commitsTouching([goldenSetPath, config.path])\n\t\tthis.walked.set(config.path, commits)\n\t\treturn commits\n\t}\n\n\tprivate parseAt(commit: string, path: string, parse: (source: string | undefined) => ParsedServers): ParsedServers {\n\t\tconst key = `${commit}\\u0000${path}`\n\t\tconst parsed = this.parsed.get(key)\n\t\tif (parsed) return parsed\n\t\tconst result = parse(this.options.git.contentAt(commit, path))\n\t\tthis.parsed.set(key, result)\n\t\treturn result\n\t}\n}\n","import type { McpServer } from './mcp-model.ts'\n\n/**\n * Finding a literal credential in MCP configuration, without ever handling one: every function\n * here answers where, never what, and the value itself never leaves this module — redaction lives\n * here, once, rather than being trusted to each of `doctor`'s three output formats.\n */\n\n/**\n * Marks a field as credential-bearing anywhere in its name — safe as a substring, since none of\n * these turn up inside an innocent word.\n */\nconst credentialWord = /token|secret|password|passwd|credential/i\n\n/**\n * Marks a field only as a whole name segment: `key`/`auth` are common inside innocent words like\n * `MONKEY` or `AUTHOR`.\n */\nconst credentialSegment = new Set(['key', 'apikey', 'auth', 'authorization', 'bearer'])\n\n/** A field name split the two ways these are written: `API_KEY` and `apiKey` alike. */\nfunction segmentsOf(key: string): string[] {\n\treturn key\n\t\t.replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n\t\t.split(/[^A-Za-z0-9]+/)\n\t\t.filter(Boolean)\n\t\t.map((segment) => segment.toLowerCase())\n}\n\n/**\n * A value that names a secret rather than holding one: `${VAR}`, `$VAR`, `${env:VAR}`,\n * `${input:id}`. Classification is by shape, not entropy — a short password and a base64 blob look\n * identical to an entropy test.\n */\nconst reference = /\\$\\{[^}]+\\}|\\$[A-Za-z_][A-Za-z0-9_]*/\n\n/**\n * True unless a reference appears anywhere in the value — `Bearer ${LINEAR_TOKEN}` is the\n * documented template form, so requiring the whole value to be a reference would flag it as\n * literal.\n */\nfunction holdsLiteral(value: string): boolean {\n\treturn !reference.test(value)\n}\n\nfunction credentialKey(key: string): boolean {\n\treturn credentialWord.test(key) || segmentsOf(key).some((segment) => credentialSegment.has(segment))\n}\n\n/**\n * A password in the URL's userinfo, or a credential-named query parameter holding a literal. An\n * unparseable URL is not reported — malformed, not leaky.\n */\nfunction urlHoldsCredential(value: string): boolean {\n\tlet url: URL\n\ttry {\n\t\turl = new URL(value)\n\t} catch {\n\t\treturn false\n\t}\n\tif (url.password) return true\n\tfor (const [key, parameter] of url.searchParams) if (credentialKey(key) && holdsLiteral(parameter)) return true\n\treturn false\n}\n\nfunction literalsIn(field: 'env' | 'headers', values: Readonly<Record<string, string>> | undefined): string[] {\n\treturn Object.entries(values ?? {})\n\t\t.filter(([key, value]) => credentialKey(key) && holdsLiteral(value))\n\t\t.map(([key]) => `${field}.${key}`)\n}\n\n/** Field paths only — never a truncated value; `sk-ab…` is still a leak into the same transcript. */\nexport function credentialFields(server: McpServer): string[] {\n\treturn [\n\t\t...literalsIn('env', server.env),\n\t\t...literalsIn('headers', server.headers),\n\t\t...(server.url && urlHoldsCredential(server.url) ? ['url'] : []),\n\t]\n}\n\n/**\n * Drops a `--flag=value` pair whose flag names a credential and whose value is a literal; a\n * positional argument or a flag with no `=` has no key to test and passes through.\n */\nexport function nonSecretArgs(args: readonly string[] | undefined): string[] {\n\treturn (args ?? []).filter((arg) => {\n\t\tconst at = arg.indexOf('=')\n\t\tif (at === -1) return true\n\t\treturn !(credentialKey(arg.slice(0, at)) && holdsLiteral(arg.slice(at + 1)))\n\t})\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { type McpProblem, repairFor } from '../diagnose-bridges/doctor-guidance.ts'\nimport type { GitBridgeState } from '../diagnose-bridges/git-bridge-state.ts'\nimport { type Locator, locatorText } from '../diagnose-bridges/locator.ts'\nimport type { ConfigurationFinding } from '../diagnose-configuration/diagnose-configuration.ts'\nimport type { McpConfig } from '../harness-registry/mcp-config.ts'\nimport { mcpDialects } from '../mcp-dialects/mcp-dialects.ts'\nimport { McpBaseline, type McpDirection, parseProjectionRecord, projectionRecordPath } from './mcp-baseline.ts'\nimport { divergingFields, type McpServer } from './mcp-model.ts'\nimport { credentialFields } from './mcp-secrets.ts'\nimport { goldenSetPath, mcpTargets, parseGoldenSet, parseTarget } from './mcp-sources.ts'\n\nexport type DiagnoseMcpOptions = {\n\troot: string\n\tgit: GitBridgeState\n\t/** How to name this tool in the repair commands. */\n\tcli: string\n}\n\nfunction read(root: string, path: string): string | undefined {\n\tconst absolute = join(root, path)\n\treturn existsSync(absolute) ? readFileSync(absolute, 'utf8') : undefined\n}\n\nconst divergence: Record<McpDirection, McpProblem> = {\n\ttarget: 'mcp-diverged-target',\n\tgolden: 'mcp-diverged-golden',\n\tboth: 'mcp-diverged-both',\n\tunknown: 'mcp-diverged-unknown',\n}\n\nexport function diagnoseMcp({ root, git, cli }: DiagnoseMcpOptions): ConfigurationFinding[] {\n\tconst findings: ConfigurationFinding[] = []\n\t// The locator is built once and never parsed back — a server name like `io.github.foo` would\n\t// not survive a split.\n\tconst add = (at: Locator, problem: McpProblem) => {\n\t\tconst { detail, repair } = repairFor(problem)\n\t\tfindings.push({ path: locatorText(at), problem, detail, repair: repair(at, cli) })\n\t}\n\n\tconst reportSecrets = (path: string, servers: Map<string, McpServer>) => {\n\t\tconst committed = git.trackingOf(path) !== 'untracked'\n\t\tfor (const [name, server] of servers)\n\t\t\tfor (const field of credentialFields(server))\n\t\t\t\tadd({ file: path, server: name, field }, committed ? 'mcp-committed-secret' : 'mcp-literal-secret')\n\t}\n\n\t// Read first so an unreadable target is reported even without a golden set — that harness can't\n\t// read the file either.\n\tconst targets = new Map<string, Map<string, McpServer>>()\n\tconst configs: McpConfig[] = []\n\tfor (const config of mcpTargets(root)) {\n\t\tconst parsed = parseTarget(config, read(root, config.path))\n\t\tif (parsed.kind === 'unreadable') {\n\t\t\tadd({ file: config.path }, 'mcp-target-unreadable')\n\t\t\tcontinue\n\t\t}\n\t\t// No file yet means nothing has drifted — writing one is projection, a write this command\n\t\t// doesn't do.\n\t\tif (parsed.kind === 'absent') continue\n\t\treportSecrets(config.path, parsed.servers)\n\t\ttargets.set(config.path, parsed.servers)\n\t\tconfigs.push(config)\n\t}\n\n\tconst golden = parseGoldenSet(read(root, goldenSetPath))\n\tif (golden.kind === 'unreadable') {\n\t\tadd({ file: goldenSetPath, position: golden.position }, 'mcp-golden-unreadable')\n\t\treturn findings\n\t}\n\tif (golden.kind === 'absent') return findings\n\treportSecrets(goldenSetPath, golden.servers)\n\n\tconst baseline = new McpBaseline({ git, record: parseProjectionRecord(read(root, projectionRecordPath)) })\n\n\tfor (const config of configs) {\n\t\tconst servers = targets.get(config.path) as Map<string, McpServer>\n\t\tfor (const [name, declared] of golden.servers) {\n\t\t\tconst carried = servers.get(name)\n\t\t\tif (!carried) {\n\t\t\t\tadd({ file: config.path, server: name }, 'mcp-unprojected')\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const field of divergingFields(declared, carried, mcpDialects[config.dialect].fields))\n\t\t\t\tadd(\n\t\t\t\t\t{ file: config.path, server: name, field },\n\t\t\t\t\tdivergence[baseline.directionOf(config, name, field, declared, carried)],\n\t\t\t\t)\n\t\t}\n\t\tfor (const name of servers.keys())\n\t\t\tif (!golden.servers.has(name)) add({ file: config.path, server: name }, 'mcp-undeclared')\n\t}\n\n\treturn findings\n}\n","import { lstatSync, readFileSync } from 'node:fs'\nimport { join, posix } from 'node:path'\nimport { filesUnder } from '../diagnose-bridges/directory-files.ts'\nimport { type NonstandardProblem, type RepairAction, repairFor } from '../diagnose-bridges/doctor-guidance.ts'\nimport { harnessRegistry } from '../harness-registry/harness-registry.ts'\nimport type { NonstandardArtifact, NonstandardKind } from '../harness-registry/nonstandard-artifact.ts'\n\n/**\n * Configuration that works for exactly one harness — not a fault to fix, since e.g. a Cursor rule\n * does what it says; each finding just names the canonical form to convert to. Read-only.\n */\nexport type NonstandardFinding = {\n\t/** Repository-relative path of the artifact, POSIX-separated. */\n\tpath: string\n\tproblem: NonstandardProblem\n\tdetail: string\n\t/** The conversion. `command` is always empty: every one of these is judgment about content. */\n\trepair: RepairAction\n}\n\nexport type DiagnoseNonstandardOptions = {\n\troot: string\n\t/** How to name this tool in the repair commands. */\n\tcli: string\n}\n\nconst problemOf: Record<NonstandardKind, NonstandardProblem> = {\n\tinstructions: 'nonstandard-instructions',\n\trule: 'nonstandard-rule',\n\tcommand: 'nonstandard-command',\n\tskill: 'nonstandard-skill',\n\tsubagent: 'nonstandard-subagent',\n}\n\n/**\n * `globs:` with a value binds a `.mdc` rule to paths — `AGENTS.md` has no equivalent, so that rule\n * converts to a skill; without it, the rule is always-on prose that `AGENTS.md` holds verbatim.\n * Read from frontmatter rather than assumed, since guessing wrong sends prose to the wrong destination.\n */\nfunction scopedByGlobs(body: string): boolean {\n\tconst block = /^---\\n([\\s\\S]*?)\\n---/.exec(body)\n\tif (!block) return false\n\tconst globs = /^globs:[ \\t]*(.*)$/m.exec(block[1] as string)\n\tconst value = globs?.[1]?.trim()\n\treturn value !== undefined && value.length > 0 && value !== '[]'\n}\n\n/** Every skill directory below `directory`, named by its `SKILL.md`. */\nfunction skillFiles(directory: string): string[] {\n\treturn filesUnder(directory).filter((file) => file.endsWith('SKILL.md'))\n}\n\n/**\n * A symlinked path is already a projection, not authored config — reporting it would tell a repo to\n * convert what it already converted.\n */\nfunction authoredHere(path: string): boolean {\n\ttry {\n\t\treturn !lstatSync(path).isSymbolicLink()\n\t} catch {\n\t\treturn false\n\t}\n}\n\nfunction artifactFiles(root: string, artifact: NonstandardArtifact): string[] {\n\tconst absolute = join(root, artifact.path)\n\t// A path that is not there fails this too — `lstat` throws and the catch reads as \"not ours\".\n\tif (!authoredHere(absolute)) return []\n\tif (artifact.shape === 'file') return [artifact.path]\n\tconst below = artifact.kind === 'skill' ? skillFiles(absolute) : filesUnder(absolute)\n\treturn below.map((file) => posix.join(artifact.path, file))\n}\n\n/**\n * Takes no harness preference or enabled set, unlike the other detectors — an artifact matters\n * whether or not its harness is enabled here, so filtering by the enabled set would hide it.\n */\nexport function diagnoseNonstandard({ root, cli }: DiagnoseNonstandardOptions): NonstandardFinding[] {\n\tconst findings: NonstandardFinding[] = []\n\n\tfor (const harness of harnessRegistry) {\n\t\tfor (const artifact of harness.project.nonstandard ?? []) {\n\t\t\tfor (const path of artifactFiles(root, artifact)) {\n\t\t\t\tconst kind =\n\t\t\t\t\tartifact.kind === 'rule' && path.endsWith('.mdc') && !scopedByGlobs(readFileSync(join(root, path), 'utf8'))\n\t\t\t\t\t\t? 'instructions'\n\t\t\t\t\t\t: artifact.kind\n\t\t\t\tconst problem = problemOf[kind]\n\t\t\t\tconst { detail, repair } = repairFor(problem)\n\t\t\t\tfindings.push({ path, problem, detail, repair: repair({ file: path }, cli) })\n\t\t\t}\n\t\t}\n\t}\n\n\t// No dedupe — one artifact is declared by one harness (enforced by `harness-registry.test.ts`);\n\t// collapsing a duplicate would hide a registry mistake.\n\treturn findings.sort((left, right) => left.path.localeCompare(right.path))\n}\n","import { parse } from 'yaml'\nimport { isRecord } from '../is-record/is-record.ts'\n\nexport type MergeMode = 'first-wins' | 'combine' | 'merge-sections'\n\nconst mergeModes: readonly MergeMode[] = ['first-wins', 'combine', 'merge-sections']\n\nexport type ParsedDocument = { metadata: Record<string, unknown>; body: string }\n\nconst frontmatterPattern = /^---[ \\t]*\\r?\\n([\\s\\S]*?)\\r?\\n(?:---|\\.\\.\\.)[ \\t]*(?:\\r?\\n|$)/\n\n/** Frontmatter that is not a YAML mapping is dropped with a warning, never passed off as body text. */\nexport function parseDocument(raw: string, warn: (message: string) => void): ParsedDocument {\n\tconst match = frontmatterPattern.exec(raw)\n\tif (!match) return { metadata: {}, body: raw }\n\tconst body = raw.slice(match[0].length)\n\ttry {\n\t\tconst value: unknown = parse(match[1] as string)\n\t\tif (value === null || value === undefined) return { metadata: {}, body }\n\t\tif (isRecord(value)) return { metadata: value, body }\n\t} catch {}\n\twarn('frontmatter is not a YAML mapping; it is ignored')\n\treturn { metadata: {}, body }\n}\n\nexport function readMergeMode(metadata: Record<string, unknown>, warn: (message: string) => void): MergeMode {\n\tconst value = metadata['merge']\n\tif (value === undefined) return 'first-wins'\n\tif (mergeModes.includes(value as MergeMode)) return value as MergeMode\n\twarn(`unknown merge mode \"${String(value)}\"; read as first-wins`)\n\treturn 'first-wins'\n}\n\nconst mergeCommentPattern = /^\\s*<!--\\s*merge:\\s*([\\w-]*)\\s*-->\\s*$/\nconst headingPattern = /^ {0,3}(#{1,6})(?:[ \\t]+(.*?))?(?:[ \\t]+#+)?[ \\t]*$/\nconst fenceOpenPattern = /^ {0,3}(`{3,}|~{3,})/\n\n/**\n * Tracks fenced code blocks line by line — a `#` or a merge comment inside one is body text, and the\n * one thing a Markdown-unaware split gets wrong.\n */\nfunction fenceTracker() {\n\tlet fence: string | undefined\n\treturn (line: string): boolean => {\n\t\tif (fence) {\n\t\t\tconst closing = new RegExp(`^ {0,3}${fence[0] === '`' ? '`' : '~'}{${fence.length},}\\\\s*$`)\n\t\t\tif (closing.test(line)) fence = undefined\n\t\t\treturn true\n\t\t}\n\t\tconst open = fenceOpenPattern.exec(line)\n\t\tif (open) {\n\t\t\tfence = open[1]\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n}\n\nexport function stripMergeComments(body: string): string {\n\tconst inFence = fenceTracker()\n\treturn body\n\t\t.split('\\n')\n\t\t.filter((line) => inFence(line) || !mergeCommentPattern.test(line))\n\t\t.join('\\n')\n}\n\nexport type SectionOp = 'replace' | 'combine' | 'remove'\n\nexport type Section = {\n\tlevel: number\n\ttitle: string\n\theading: string\n\top: SectionOp\n\tbody: string[]\n\tchildren: Section[]\n}\n\nexport type SectionTree = { preamble: string[]; children: Section[] }\n\nfunction sectionKey(title: string): string {\n\treturn title.trim().replace(/\\s+/g, ' ').toLowerCase()\n}\n\nfunction displayHeading(section: Section): string {\n\treturn `${'#'.repeat(section.level)} ${section.title}`\n}\n\nexport function parseSections(body: string, warn: (message: string) => void): SectionTree {\n\tconst tree: SectionTree = { preamble: [], children: [] }\n\tconst stack: Section[] = []\n\tconst inFence = fenceTracker()\n\tlet awaitingOp: Section | undefined\n\tfor (const line of body.split('\\n')) {\n\t\tconst current = stack.at(-1)\n\t\tconst fenced = inFence(line)\n\t\tconst heading = fenced ? null : headingPattern.exec(line)\n\t\tif (heading) {\n\t\t\tconst level = (heading[1] as string).length\n\t\t\tconst title = (heading[2] ?? '').trim()\n\t\t\tconst section: Section = { level, title, heading: line.trimEnd(), op: 'replace', body: [], children: [] }\n\t\t\twhile ((stack.at(-1)?.level ?? 0) >= level) stack.pop()\n\t\t\t;(stack.at(-1)?.children ?? tree.children).push(section)\n\t\t\tstack.push(section)\n\t\t\tawaitingOp = section\n\t\t\tcontinue\n\t\t}\n\t\tif (awaitingOp && !fenced) {\n\t\t\tif (!line.trim()) continue\n\t\t\tconst comment = mergeCommentPattern.exec(line)\n\t\t\tif (comment) {\n\t\t\t\tconst op = comment[1] as string\n\t\t\t\tif (op === 'replace' || op === 'combine' || op === 'remove') awaitingOp.op = op\n\t\t\t\telse warn(`unknown section merge \"${op}\" under \"${displayHeading(awaitingOp)}\"; read as replace`)\n\t\t\t\tawaitingOp = undefined\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tawaitingOp = undefined\n\t\t;(current?.body ?? tree.preamble).push(line)\n\t}\n\treturn tree\n}\n\nfunction trimBlank(lines: readonly string[]): string[] {\n\tlet start = 0\n\tlet end = lines.length\n\twhile (start < end && !(lines[start] as string).trim()) start++\n\twhile (end > start && !(lines[end - 1] as string).trim()) end--\n\treturn lines.slice(start, end)\n}\n\nfunction warnDuplicates(sections: readonly Section[], path: string, where: string, warn: (message: string) => void) {\n\tconst seen = new Set<string>()\n\tfor (const section of sections) {\n\t\tconst key = sectionKey(section.title)\n\t\tif (seen.has(key)) {\n\t\t\twarn(`heading path \"${path}${displayHeading(section)}\" appears more than once in ${where}; the first is matched`)\n\t\t}\n\t\tseen.add(key)\n\t}\n}\n\nfunction warnUnmatched(section: Section, path: string, where: string, warn: (message: string) => void) {\n\twarn(`\"<!-- merge: ${section.op} -->\" on \"${path}${displayHeading(section)}\" in ${where} matches no section below`)\n}\n\n/** A section placed without merging has nothing below its subsections, so their merge comments match nothing. */\nfunction place(section: Section, path: string, where: string, warn: (message: string) => void): Section {\n\tconst childPath = `${path}${displayHeading(section)} > `\n\tconst children = section.children.flatMap((child) => {\n\t\tif (child.op !== 'replace') warnUnmatched(child, childPath, where, warn)\n\t\treturn child.op === 'remove' ? [] : [place(child, childPath, where, warn)]\n\t})\n\treturn { ...section, children }\n}\n\nfunction mergeChildren(\n\tbase: readonly Section[],\n\toverlay: readonly Section[],\n\tpath: string,\n\twhere: string,\n\twarn: (message: string) => void,\n): Section[] {\n\twarnDuplicates(base, path, 'the layers below', warn)\n\twarnDuplicates(overlay, path, where, warn)\n\tconst slots: (Section | undefined)[] = [...base]\n\tconst appended: Section[] = []\n\tconst matched = new Set<number>()\n\tfor (const section of overlay) {\n\t\tconst key = sectionKey(section.title)\n\t\tconst index = base.findIndex((candidate, i) => !matched.has(i) && sectionKey(candidate.title) === key)\n\t\tif (index === -1) {\n\t\t\tif (section.op !== 'replace') warnUnmatched(section, path, where, warn)\n\t\t\tif (section.op !== 'remove') appended.push(place(section, path, where, warn))\n\t\t\tcontinue\n\t\t}\n\t\t// Only the first occurrence of a duplicated path is matched; a second overlay section with the\n\t\t// same path finds nothing left and is appended.\n\t\tfor (let i = 0; i < base.length; i++) if (sectionKey((base[i] as Section).title) === key) matched.add(i)\n\t\tconst target = base[index] as Section\n\t\tif (section.op === 'remove') slots[index] = undefined\n\t\telse if (section.op === 'combine') {\n\t\t\tconst baseBody = trimBlank(target.body)\n\t\t\tconst overlayBody = trimBlank(section.body)\n\t\t\tslots[index] = {\n\t\t\t\t...target,\n\t\t\t\tbody: baseBody.length && overlayBody.length ? [...baseBody, '', ...overlayBody] : [...baseBody, ...overlayBody],\n\t\t\t\tchildren: mergeChildren(target.children, section.children, `${path}${displayHeading(target)} > `, where, warn),\n\t\t\t}\n\t\t} else slots[index] = place(section, path, where, warn)\n\t}\n\treturn [...slots.filter((slot): slot is Section => slot !== undefined), ...appended]\n}\n\n/** `where` names the overlay in warnings, so a person can find the heading it is about. */\nexport function mergeSections(\n\tbase: SectionTree,\n\toverlay: SectionTree,\n\twhere: string,\n\twarn: (message: string) => void,\n): SectionTree {\n\tconst overlayPreamble = trimBlank(overlay.preamble)\n\treturn {\n\t\tpreamble: overlayPreamble.length ? overlayPreamble : base.preamble,\n\t\tchildren: mergeChildren(base.children, overlay.children, '', where, warn),\n\t}\n}\n\nexport function renderSections(tree: SectionTree): string {\n\tconst blocks: string[] = []\n\tconst preamble = trimBlank(tree.preamble)\n\tif (preamble.length) blocks.push(preamble.join('\\n'))\n\tconst visit = (section: Section) => {\n\t\tconst body = trimBlank(section.body)\n\t\tblocks.push(body.length ? `${section.heading}\\n\\n${body.join('\\n')}` : section.heading)\n\t\tfor (const child of section.children) visit(child)\n\t}\n\tfor (const section of tree.children) visit(section)\n\treturn `${blocks.join('\\n\\n')}\\n`\n}\n","import { type Dirent, readdirSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport {\n\ttype MergeMode,\n\tmergeSections,\n\tparseDocument,\n\tparseSections,\n\treadMergeMode,\n\trenderSections,\n\tstripMergeComments,\n} from './reference-document.ts'\nimport type { ReferenceLayer, ReferenceTier } from './reference-layers.ts'\n\nexport type ReferenceName = { name: string; plugin: string | undefined; raw: string }\n\nconst namePattern = /^[a-z0-9]+(?:[-.][a-z0-9]+)*$/i\nconst pluginPattern = /^(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]*$/i\n\n/**\n * Rejects rather than sanitizes — silently answering a different question is how untrusted input\n * reads a file outside the layer. The plugin qualifier is only ever compared with known plugin\n * names, never joined into a path.\n */\nexport function parseReferenceName(value: string): ReferenceName {\n\tif (value.endsWith('.md')) {\n\t\tthrow new Error(`\"${value}\" names a file. Ask for the reference by name, without the .md extension.`)\n\t}\n\tconst slash = value.lastIndexOf('/')\n\tconst name = slash === -1 ? value : value.slice(slash + 1)\n\tconst plugin = slash === -1 ? undefined : value.slice(0, slash)\n\tif (!namePattern.test(name) || (plugin !== undefined && !pluginPattern.test(plugin))) {\n\t\tthrow new Error(\n\t\t\t`\"${value}\" is not a reference name. A name is letters, digits, hyphens, and dots, optionally after \"<plugin>/\" — not a path.`,\n\t\t)\n\t}\n\treturn { name, plugin, raw: value }\n}\n\nconst folderCandidates = ['README.md', 'index.md', 'SKILL.md']\n\n/** Search order within one layer; the first that reads wins. */\nexport function candidateFiles(name: string): string[] {\n\treturn [`${name}.md`, ...folderCandidates.map((file) => `${name}/${file}`)]\n}\n\nexport type TraceEntry = {\n\ttier: ReferenceTier\n\tplugin: string\n\tpath: string\n\tfound: boolean\n\tcandidate: string\n\tmerge: string\n\toutcome: string\n\t/** The layer's own frontmatter `description`, so `list` can show it per row. */\n\tdescription: string\n}\n\nexport type UsedLayer = { tier: ReferenceTier; plugin: string; path: string; merge: MergeMode }\n\nexport type ReferenceStatus = 'found' | 'missing' | 'ambiguous'\n\nexport type ResolvedReference = {\n\tname: string\n\tstatus: ReferenceStatus\n\ttier?: ReferenceTier\n\tplugin?: string\n\tpath?: string\n\tmerge?: MergeMode\n\tmetadata?: Record<string, unknown>\n\tcontent?: string\n\tlayers: UsedLayer[]\n\twarnings: string[]\n\t/** Qualified names to ask for instead, when two plugins hold an unqualified name. */\n\tplugins: string[]\n\ttrace: TraceEntry[]\n}\n\ntype FoundDocument = {\n\tlayer: ReferenceLayer\n\tentry: TraceEntry\n\tmetadata: Record<string, unknown>\n\tbody: string\n\tmerge: MergeMode\n}\n\nexport type ResolveOptions = {\n\t/** How a path is shown in a label or a warning — the command collapses the home directory. */\n\tdisplay?: (path: string) => string\n}\n\nfunction tryRead(path: string): string | undefined {\n\ttry {\n\t\treturn readFileSync(path, 'utf8')\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nfunction pluginLabel(layer: ReferenceLayer): string {\n\treturn layer.plugins[0] ?? ''\n}\n\nfunction layerName(layer: ReferenceLayer): string {\n\treturn layer.tier === 'plugin' ? `plugin ${pluginLabel(layer)}` : layer.tier\n}\n\nfunction layersFor(ref: ReferenceName, layers: readonly ReferenceLayer[]): ReferenceLayer[] {\n\tconst plugin = ref.plugin\n\tif (plugin === undefined) return [...layers]\n\tconst named = layers.filter((layer) => layer.tier !== 'plugin' || layer.plugins.includes(plugin))\n\tif (named.some((layer) => layer.tier === 'plugin')) return named\n\t// A placeholder so the trace says the plugin asked for is not there, rather than saying nothing.\n\treturn [...named, { tier: 'plugin', dir: `(no dependency named ${plugin})`, plugins: [plugin], status: '' }]\n}\n\nexport function resolveReference(\n\tref: ReferenceName,\n\tlayers: readonly ReferenceLayer[],\n\t{ display = (path) => path }: ResolveOptions = {},\n): ResolvedReference {\n\tconst warnings: string[] = []\n\tconst trace: TraceEntry[] = []\n\tconst found: FoundDocument[] = []\n\n\tfor (const layer of layersFor(ref, layers)) {\n\t\tconst entry: TraceEntry = {\n\t\t\ttier: layer.tier,\n\t\t\tplugin: pluginLabel(layer),\n\t\t\tpath: layer.dir,\n\t\t\tfound: false,\n\t\t\tcandidate: '',\n\t\t\tmerge: '',\n\t\t\toutcome: 'missing',\n\t\t\tdescription: '',\n\t\t}\n\t\ttrace.push(entry)\n\t\tif (layer.skipped) {\n\t\t\tentry.outcome = layer.skipped\n\t\t\tcontinue\n\t\t}\n\t\tconst hits = candidateFiles(ref.name).flatMap((candidate) => {\n\t\t\tconst raw = tryRead(join(layer.dir, candidate))\n\t\t\treturn raw === undefined ? [] : [{ candidate, raw }]\n\t\t})\n\t\tconst [hit, ...ignored] = hits\n\t\tif (!hit) continue\n\t\tfor (const other of ignored) {\n\t\t\twarnings.push(\n\t\t\t\t`${display(join(layer.dir, other.candidate))} is ignored: ${hit.candidate} answers first in that folder`,\n\t\t\t)\n\t\t}\n\t\tconst path = join(layer.dir, hit.candidate)\n\t\tconst warn = (message: string) => warnings.push(`${display(path)}: ${message}`)\n\t\tconst { metadata, body } = parseDocument(hit.raw, warn)\n\t\tconst merge = readMergeMode(metadata, warn)\n\t\tconst description = typeof metadata['description'] === 'string' ? metadata['description'] : ''\n\t\tObject.assign(entry, { path, found: true, candidate: hit.candidate, merge, outcome: '', description })\n\t\tfound.push({ layer, entry, metadata, body, merge })\n\t}\n\n\tconst result: ResolvedReference = { name: ref.raw, status: 'missing', layers: [], warnings, plugins: [], trace }\n\n\tconst stop = found.findIndex(({ merge }) => merge === 'first-wins')\n\tconst chain = stop === -1 ? found : found.slice(0, stop + 1)\n\tconst shadowed = stop === -1 ? [] : found.slice(stop + 1)\n\tconst base = chain.at(-1)\n\n\t// Plugins are alternatives, not a stack: once resolution reaches the plugin tier, two plugins\n\t// holding the name leave nothing to choose between them.\n\tconst holders = [...new Set(found.filter(({ layer }) => layer.tier === 'plugin').map(({ entry }) => entry.plugin))]\n\tif (ref.plugin === undefined && holders.length > 1 && chain.some(({ layer }) => layer.tier === 'plugin')) {\n\t\tfor (const { entry } of found) entry.outcome = 'ambiguous'\n\t\tresult.status = 'ambiguous'\n\t\tresult.plugins = holders.map((plugin) => `${plugin}/${ref.name}`)\n\t\treturn result\n\t}\n\tfor (const document of shadowed) {\n\t\tdocument.entry.outcome = `shadowed by ${(base as FoundDocument).layer.tier} (first-wins)`\n\t}\n\tif (!base) return result\n\n\tfor (const { entry } of chain) entry.outcome = 'used'\n\tconst top = chain[0] as FoundDocument\n\treturn {\n\t\t...result,\n\t\tstatus: 'found',\n\t\ttier: top.layer.tier,\n\t\tplugin: top.entry.plugin,\n\t\tpath: top.entry.path,\n\t\tmerge: top.merge,\n\t\t// Lower layers first, so each document above overrides a key the one below also sets.\n\t\tmetadata: Object.assign({}, ...[...chain].reverse().map(({ metadata }) => metadata)),\n\t\tcontent: withNewline(stripMergeComments(fold(chain, display, (message) => warnings.push(message)))),\n\t\tlayers: chain.map(({ layer, entry, merge }) => ({\n\t\t\ttier: layer.tier,\n\t\t\tplugin: entry.plugin,\n\t\t\tpath: entry.path,\n\t\t\tmerge,\n\t\t})),\n\t}\n}\n\ntype Part = { labels: string[]; body: string }\n\n/** Bottom-up: the base is the lowest document read, and each document above says how it applies. */\nfunction fold(chain: readonly FoundDocument[], display: (path: string) => string, warn: (message: string) => void) {\n\tconst label = ({ layer, entry }: FoundDocument) => `${layerName(layer)} ${display(entry.path)}`\n\tconst [base, ...above] = [...chain].reverse() as [FoundDocument, ...FoundDocument[]]\n\tlet parts: Part[] = [{ labels: [label(base)], body: base.body }]\n\tfor (const document of above) {\n\t\tif (document.merge === 'combine') {\n\t\t\tparts = [{ labels: [label(document)], body: document.body }, ...parts]\n\t\t\tcontinue\n\t\t}\n\t\tconst below = parts.map(({ body }) => body.trim()).join('\\n\\n')\n\t\tconst merged = mergeSections(parseSections(below, warn), parseSections(document.body, warn), label(document), warn)\n\t\tparts = [{ labels: [label(document), ...parts.flatMap(({ labels }) => labels)], body: renderSections(merged) }]\n\t}\n\tif (parts.length === 1) return (parts[0] as Part).body\n\treturn [\n\t\t`> Combined from ${parts.length} layers, highest precedence first. Where they conflict, the first layer wins.`,\n\t\t...parts.map(({ labels, body }) => `<!-- layer: ${labels.join(', ')} -->\\n\\n${body.trim()}`),\n\t].join('\\n\\n')\n}\n\nfunction withNewline(content: string): string {\n\treturn content.endsWith('\\n') ? content : `${content}\\n`\n}\n\n/** Every name a layer holds in any candidate form; empty for a layer that is missing or unreadable. */\nexport function layerNames(dir: string): string[] {\n\tlet entries: Dirent[]\n\ttry {\n\t\tentries = readdirSync(dir, { withFileTypes: true })\n\t} catch {\n\t\treturn []\n\t}\n\tconst names = new Set<string>()\n\tfor (const entry of entries) {\n\t\tconst name = entry.isFile() && entry.name.endsWith('.md') ? entry.name.slice(0, -3) : entry.name\n\t\tif (!namePattern.test(name)) continue\n\t\tif (\n\t\t\tentry.isFile()\n\t\t\t\t? entry.name.endsWith('.md')\n\t\t\t\t: folderCandidates.some((file) => tryRead(join(dir, name, file)) !== undefined)\n\t\t) {\n\t\t\tnames.add(name)\n\t\t}\n\t}\n\treturn [...names]\n}\n\nexport function referenceNames(layers: readonly ReferenceLayer[]): string[] {\n\treturn [...new Set(layers.flatMap(({ dir, skipped }) => (skipped ? [] : layerNames(dir))))].sort((a, b) =>\n\t\ta.localeCompare(b),\n\t)\n}\n","import type { ReferenceLayer, ReferenceTier } from './reference-layers.ts'\nimport {\n\tparseReferenceName,\n\ttype ResolvedReference,\n\ttype ResolveOptions,\n\treferenceNames,\n\tresolveReference,\n} from './resolve-reference.ts'\n\nexport type ReferenceRow = {\n\tname: string\n\ttier: ReferenceTier\n\tplugin: string\n\tpath: string\n\tstatus: string\n\tdescription: string\n}\n\nexport type ReferenceListing = { rows: ReferenceRow[]; warnings: string[] }\n\n/** One row per name per layer holding it, with the status resolution gave that layer. */\nexport function listReferences(layers: readonly ReferenceLayer[], options: ResolveOptions = {}): ReferenceListing {\n\tconst rows: ReferenceRow[] = []\n\tconst warnings = new Set<string>()\n\tfor (const name of referenceNames(layers)) {\n\t\tconst resolved = resolveReference(parseReferenceName(name), layers, options)\n\t\tfor (const warning of resolved.warnings) warnings.add(warning)\n\t\tfor (const entry of resolved.trace) {\n\t\t\tif (!entry.found) continue\n\t\t\trows.push({\n\t\t\t\tname,\n\t\t\t\ttier: entry.tier,\n\t\t\t\tplugin: entry.plugin,\n\t\t\t\tpath: entry.path,\n\t\t\t\tstatus:\n\t\t\t\t\tentry.outcome === 'ambiguous' ? `ambiguous — ask for one of ${resolved.plugins.join(', ')}` : entry.outcome,\n\t\t\t\tdescription: entry.description,\n\t\t\t})\n\t\t}\n\t}\n\treturn { rows, warnings: [...warnings] }\n}\n\nexport type MatchKind = 'name' | 'prefix' | 'close name' | 'description' | 'heading' | 'body'\n\nconst matchOrder: readonly MatchKind[] = ['name', 'prefix', 'close name', 'description', 'heading', 'body']\n\nexport type SearchMatch = { name: string; tier: ReferenceTier; match: MatchKind; description: string }\n\nfunction distance(a: string, b: string): number {\n\tlet previous = Array.from({ length: b.length + 1 }, (_, i) => i)\n\tfor (let i = 1; i <= a.length; i++) {\n\t\tconst current = [i]\n\t\tfor (let j = 1; j <= b.length; j++) {\n\t\t\tconst substitution = (previous[j - 1] as number) + (a[i - 1] === b[j - 1] ? 0 : 1)\n\t\t\tcurrent.push(Math.min((previous[j] as number) + 1, (current[j - 1] as number) + 1, substitution))\n\t\t}\n\t\tprevious = current\n\t}\n\treturn previous[b.length] as number\n}\n\nfunction headings(content: string): string {\n\tlet fenced = false\n\tconst lines: string[] = []\n\tfor (const line of content.split('\\n')) {\n\t\tif (/^ {0,3}(`{3,}|~{3,})/.test(line)) fenced = !fenced\n\t\telse if (!fenced && /^ {0,3}#{1,6}\\s/.test(line)) lines.push(line)\n\t}\n\treturn lines.join('\\n')\n}\n\nfunction tagText(value: unknown): string {\n\tif (Array.isArray(value)) return value.map(String).join(' ')\n\treturn typeof value === 'string' ? value : ''\n}\n\nfunction matchKind(name: string, reference: ResolvedReference, query: string): MatchKind | undefined {\n\tconst bare = name.slice(name.lastIndexOf('/') + 1).toLowerCase()\n\tif (bare === query || name.toLowerCase() === query) return 'name'\n\tif (bare.startsWith(query)) return 'prefix'\n\tif (bare.includes(query) || distance(bare, query) <= Math.max(1, Math.floor(query.length / 4))) return 'close name'\n\tconst terms = query.split(/\\s+/)\n\tconst holds = (text: string) => {\n\t\tconst lower = text.toLowerCase()\n\t\treturn terms.every((term) => lower.includes(term))\n\t}\n\tconst metadata = reference.metadata as Record<string, unknown>\n\tconst description = typeof metadata['description'] === 'string' ? metadata['description'] : ''\n\tif (holds(`${description} ${tagText(metadata['tags'])}`)) return 'description'\n\tconst content = reference.content as string\n\tif (holds(headings(content))) return 'heading'\n\tif (holds(content)) return 'body'\n\treturn undefined\n}\n\n/**\n * Every name resolves the way `show` would; a name two plugins hold is searched once per plugin, as\n * the qualified name `show` would need.\n */\nexport function searchReferences(\n\tquery: string,\n\tlayers: readonly ReferenceLayer[],\n\toptions: ResolveOptions = {},\n): SearchMatch[] {\n\tconst normalized = query.trim().toLowerCase()\n\tconst matches: SearchMatch[] = []\n\tfor (const name of referenceNames(layers)) {\n\t\tconst resolved = resolveReference(parseReferenceName(name), layers, options)\n\t\tconst candidates =\n\t\t\tresolved.status === 'ambiguous'\n\t\t\t\t? resolved.plugins.map((qualified) => resolveReference(parseReferenceName(qualified), layers, options))\n\t\t\t\t: [resolved]\n\t\t// Every name listed is backed by a readable file, so each of these resolves as found.\n\t\tfor (const reference of candidates.filter(({ status }) => status === 'found')) {\n\t\t\tconst match = matchKind(reference.name, reference, normalized)\n\t\t\tif (!match) continue\n\t\t\tconst description = (reference.metadata as Record<string, unknown>)['description']\n\t\t\tmatches.push({\n\t\t\t\tname: reference.name,\n\t\t\t\ttier: reference.tier as ReferenceTier,\n\t\t\t\tmatch,\n\t\t\t\tdescription: typeof description === 'string' ? description.split('\\n')[0]?.trim() || '' : '',\n\t\t\t})\n\t\t}\n\t}\n\treturn matches.sort(\n\t\t(a, b) => matchOrder.indexOf(a.match) - matchOrder.indexOf(b.match) || a.name.localeCompare(b.name),\n\t)\n}\n","import { existsSync, readdirSync, readFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/**\n * Order here is search order. `package` is the only member that isn't an override —\n * `--overrides-only` promises never to return it.\n */\nexport type GovernanceScope = 'project' | 'user' | 'managed' | 'managed-deprecated' | 'package'\n\nexport type GovernanceLayer = { scope: GovernanceScope; dir: string }\n\n/** A governance located but not read: what `list` reports. */\nexport type GovernanceEntry = { name: string; scope: GovernanceScope; path: string }\n\n/** A governance located and read: what `show` reports. */\nexport type GovernanceDocument = GovernanceEntry & { content: string }\n\nexport type LayerOptions = {\n\troot: string\n\thome: string\n\tplatform: NodeJS.Platform\n\t/** `%ProgramData%`, read only on Windows. */\n\tprogramData?: string | undefined\n}\n\nexport function managedGovernancesDir(platform: NodeJS.Platform, programData?: string | undefined): string {\n\tif (platform === 'darwin') return '/Library/Application Support/BuddyAgentHarness/governances'\n\tif (platform === 'win32') return join(programData || 'C:\\\\ProgramData', 'BuddyAgentHarness', 'governances')\n\treturn '/etc/buddy-agent-harness/governances'\n}\n\n/**\n * Still read below the layer above, so a machine already using it keeps working; reported as\n * deprecated so an admin knows to move it.\n */\nexport function deprecatedManagedGovernancesDir(platform: NodeJS.Platform, programData?: string | undefined): string {\n\tif (platform === 'darwin') return '/Library/Application Support/UniPlugin/governances'\n\tif (platform === 'win32') return join(programData || 'C:\\\\ProgramData', 'UniPlugin', 'governances')\n\treturn '/etc/universal-plugin/governances'\n}\n\nexport function projectGovernancesDir(root: string): string {\n\treturn join(root, '.agents', 'governances')\n}\n\nexport function userGovernancesDir(home: string): string {\n\treturn join(home, '.agents', 'governances')\n}\n\n/**\n * Walks up to the nearest `package.json` rather than a relative literal — this module sits at a\n * different depth in `src/` vs the bundle.\n */\nexport function packageGovernancesDir(from: string = fileURLToPath(import.meta.url)): string {\n\tlet dir = dirname(from)\n\tfor (;;) {\n\t\tif (existsSync(join(dir, 'package.json'))) return join(dir, 'governances')\n\t\tconst parent = dirname(dir)\n\t\tif (parent === dir) return join(dir, 'governances')\n\t\tdir = parent\n\t}\n}\n\nexport function governanceLayers({ root, home, platform, programData }: LayerOptions): GovernanceLayer[] {\n\treturn [\n\t\t{ scope: 'project', dir: projectGovernancesDir(root) },\n\t\t{ scope: 'user', dir: userGovernancesDir(home) },\n\t\t{ scope: 'managed', dir: managedGovernancesDir(platform, programData) },\n\t\t{ scope: 'managed-deprecated', dir: deprecatedManagedGovernancesDir(platform, programData) },\n\t\t{ scope: 'package', dir: packageGovernancesDir() },\n\t]\n}\n\n/**\n * Filters by scope rather than slicing the list, so a layer added later can't quietly become an\n * override by position.\n */\nexport function overrideLayers(layers: readonly GovernanceLayer[]): GovernanceLayer[] {\n\treturn layers.filter((layer) => layer.scope !== 'package')\n}\n\nconst namePattern = /^[a-z0-9]+(?:[-.][a-z0-9]+)*$/i\n\n/**\n * Rejects rather than sanitizes — silently answering a different question is how untrusted input\n * reads a file outside the layer.\n */\nexport function parseGovernanceName(value: string): string {\n\t// Caught before the pattern, which would accept it and then look for `<name>.md.md`.\n\tif (value.endsWith('.md')) {\n\t\tthrow new Error(`\"${value}\" names a file. Ask for the governance by name, without the .md extension.`)\n\t}\n\tif (!namePattern.test(value)) {\n\t\tthrow new Error(`\"${value}\" is not a governance name. A name is letters, digits, hyphens, and dots — not a path.`)\n\t}\n\treturn value\n}\n\nfunction tryReadDocument(path: string): string | undefined {\n\ttry {\n\t\treturn readFileSync(path, 'utf8')\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/** Empty for a layer that's missing, unreadable, or not a directory — never throws. */\nfunction documentNames(dir: string): string[] {\n\ttry {\n\t\treturn readdirSync(dir, { withFileTypes: true })\n\t\t\t.filter((entry) => entry.isFile() && entry.name.endsWith('.md'))\n\t\t\t.map((entry) => entry.name.slice(0, -3))\n\t} catch {\n\t\treturn []\n\t}\n}\n\n/** The first layer that holds the name wins; the rest are not read. */\nexport function resolveGovernance(name: string, layers: readonly GovernanceLayer[]): GovernanceDocument | undefined {\n\tfor (const { scope, dir } of layers) {\n\t\tconst path = join(dir, `${name}.md`)\n\t\tconst content = tryReadDocument(path)\n\t\tif (content !== undefined) return { name, scope, path, content }\n\t}\n\treturn undefined\n}\n\n/** Every name any layer holds, each reported at the layer that would win, sorted by name. */\nexport function listGovernances(layers: readonly GovernanceLayer[]): GovernanceEntry[] {\n\tconst found = new Map<string, GovernanceEntry>()\n\tfor (const { scope, dir } of layers) {\n\t\tfor (const name of documentNames(dir)) {\n\t\t\tif (!found.has(name)) found.set(name, { name, scope, path: join(dir, `${name}.md`) })\n\t\t}\n\t}\n\treturn [...found.values()].sort((a, b) => a.name.localeCompare(b.name))\n}\n","import { join, posix, win32 } from 'node:path'\nimport {\n\tdetectHarness,\n\tenabledPlugins,\n\ttype HarnessEnvironment,\n\ttype HarnessId,\n\ttype InstalledPlugin,\n\tinstalledPlugins,\n\ttype ManagedPolicyKind,\n\tmanagedPolicyLocations,\n} from '@cyberuni/agent-harness'\nimport type { ReferenceLayer } from './reference-layers.ts'\n\ntype Env = Readonly<Record<string, string | undefined>>\n\n/** Nested harnesses leave `detectHarness` at `unknown`; each candidate is still a harness in play. */\nexport function detectedHarnesses(env: Env): readonly HarnessId[] {\n\treturn detectHarness({ env }).candidates\n}\n\nconst unreadableKind: Partial<Record<ManagedPolicyKind, string>> = {\n\t'macos-managed-preferences': 'a macOS managed-preferences domain delivered by MDM',\n\t'windows-registry': 'a Windows registry key delivered by MDM or Group Policy',\n\tserver: 'server-side settings',\n}\n\nfunction skippedLayer(\n\ttier: ReferenceLayer['tier'],\n\tdir: string,\n\tskipped: string,\n\tplugins: string[] = [],\n): ReferenceLayer {\n\treturn { tier, dir, plugins, status: skipped, skipped }\n}\n\n/**\n * The folder holding a harness's managed files gets a `references/` beside them. A `directory`\n * location inside that folder, such as a drop-in `managed-settings.d`, is part of it, not a folder\n * of its own.\n */\nfunction managedFolders(harness: HarnessId, platform: NodeJS.Platform, env: Env) {\n\tconst path = platform === 'win32' ? win32 : posix\n\tconst locations = managedPolicyLocations(harness, { platform, env })\n\tconst folders = [\n\t\t...new Set(\n\t\t\tlocations.flatMap(({ kind, location }) =>\n\t\t\t\tkind === 'file' ? [path.dirname(location)] : kind === 'directory' ? [location] : [],\n\t\t\t),\n\t\t),\n\t]\n\tconst outermost = folders.filter((folder) => !folders.some((other) => folder.startsWith(other + path.sep)))\n\treturn {\n\t\tread: outermost.map((folder) => path.join(folder, 'references')),\n\t\tunread: locations.flatMap(({ kind, location }) => {\n\t\t\tconst where = unreadableKind[kind]\n\t\t\treturn where\n\t\t\t\t? [{ location, reason: `not read — ${harness} keeps this policy in ${where}, which cannot be read locally` }]\n\t\t\t\t: []\n\t\t}),\n\t}\n}\n\nexport function harnessManagedLayers(\n\tharnesses: readonly HarnessId[],\n\tplatform: NodeJS.Platform,\n\tenv: Env,\n): ReferenceLayer[] {\n\tif (!harnesses.length) {\n\t\treturn [\n\t\t\tskippedLayer('managed', '(no harness detected)', 'not read — no harness detected, so no harness managed folder'),\n\t\t]\n\t}\n\treturn harnesses.flatMap((harness) => {\n\t\tconst { read, unread } = managedFolders(harness, platform, env)\n\t\treturn [\n\t\t\t...read.map((dir): ReferenceLayer => ({ tier: 'managed', dir, plugins: [], status: '' })),\n\t\t\t...unread.map(({ location, reason }) => skippedLayer('managed', location, reason)),\n\t\t]\n\t})\n}\n\n/**\n * Claude Code installs one plugin at several scopes; a project- or local-scoped install loads only in\n * its own project, so the nearest folder of the walk picks it, and a user install answers elsewhere.\n */\nfunction activeInstall(installs: readonly InstalledPlugin[], chain: readonly string[]): InstalledPlugin | undefined {\n\tfor (const dir of chain) {\n\t\tconst install = installs.find(({ projectPath }) => projectPath === dir)\n\t\tif (install) return install\n\t}\n\treturn installs.find(({ projectPath }) => projectPath === undefined)\n}\n\n/**\n * Only plugins the harness has enabled: installing a plugin never activates it, and a reference is\n * instruction text an agent follows.\n */\nexport async function enabledPluginLayers(\n\tharnesses: readonly HarnessId[],\n\tchain: readonly string[],\n\tenvironment: HarnessEnvironment,\n): Promise<ReferenceLayer[]> {\n\tconst layers: ReferenceLayer[] = []\n\tfor (const harness of harnesses) {\n\t\tconst [enabled, installed] = await Promise.all([\n\t\t\tenabledPlugins(harness, environment),\n\t\t\tinstalledPlugins(harness, environment),\n\t\t])\n\t\tif (!enabled.supported) {\n\t\t\tlayers.push(\n\t\t\t\tskippedLayer(\n\t\t\t\t\t'plugin',\n\t\t\t\t\t`(${harness} enabled plugins)`,\n\t\t\t\t\t`not read — ${harness} keeps no readable record of enabled plugins`,\n\t\t\t\t),\n\t\t\t)\n\t\t\tcontinue\n\t\t}\n\t\tif (enabled.unread.length) {\n\t\t\tlayers.push(\n\t\t\t\tskippedLayer(\n\t\t\t\t\t'plugin',\n\t\t\t\t\t`(${harness} plugin policy)`,\n\t\t\t\t\t`not read — ${enabled.unread.join('; ')} may also enable or disable ${harness} plugins`,\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t\tfor (const { id, enabled: on } of enabled.plugins) {\n\t\t\tif (!on) continue\n\t\t\tconst plugin = id.split('@')[0] as string\n\t\t\tconst install = activeInstall(\n\t\t\t\tinstalled.plugins.filter((candidate) => candidate.id === id),\n\t\t\t\tchain,\n\t\t\t)\n\t\t\tif (install) {\n\t\t\t\tlayers.push({ tier: 'plugin', dir: join(install.path, 'references'), plugins: [plugin], status: '' })\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlayers.push(\n\t\t\t\tskippedLayer(\n\t\t\t\t\t'plugin',\n\t\t\t\t\t`(${id})`,\n\t\t\t\t\t`not read — enabled in ${harness}, but no install folder for this project is recorded`,\n\t\t\t\t\t[plugin],\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t}\n\treturn layers\n}\n","import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs'\nimport { dirname, join, resolve } from 'node:path'\nimport { declaredDependencies } from '../dep-plugins/dep-plugins.ts'\nimport { packageDir } from '../dep-plugins/resolve.ts'\nimport {\n\tdeprecatedManagedGovernancesDir,\n\tmanagedGovernancesDir,\n\tpackageGovernancesDir,\n} from '../governance-overrides/governance-overrides.ts'\nimport { isRecord } from '../is-record/is-record.ts'\nimport { detectedHarnesses, enabledPluginLayers, harnessManagedLayers } from './harness-layers.ts'\n\n/** Order here is precedence order, highest first. */\nexport type ReferenceTier = 'managed' | 'project' | 'user' | 'plugin'\n\nexport type ReferenceLayer = {\n\ttier: ReferenceTier\n\tdir: string\n\t/** Every name a qualified `<plugin>/<name>` may use for this layer; empty outside the plugin tier. */\n\tplugins: string[]\n\t/** Empty unless the layer is legacy, deprecated, or skipped; then it says why. */\n\tstatus: string\n\t/** Set when the layer is never read, and why: policy held in MDM, or a plugin with no install folder. */\n\tskipped?: string\n}\n\nexport type ReferenceLayerOptions = {\n\troot: string\n\thome: string\n\tplatform: NodeJS.Platform\n\tprogramData?: string | undefined\n\t/** This package's own root, the `buddy-agent-harness` plugin. */\n\tpackageRoot?: string | undefined\n\t/** Detects the harness and reads its settings. Defaults to `process.env`. */\n\tenv?: Readonly<Record<string, string | undefined>>\n}\n\nexport const PACKAGE_PLUGIN = 'buddy-agent-harness'\nexport const LEGACY_STATUS = 'legacy — move these documents to references/ beside it'\nexport const DEPRECATED_STATUS = 'deprecated — move these documents to the managed references/ layer'\n\nexport function managedReferencesDir(platform: NodeJS.Platform, programData?: string | undefined): string {\n\treturn join(dirname(managedGovernancesDir(platform, programData)), 'references')\n}\n\nexport function projectReferencesDir(root: string): string {\n\treturn join(root, '.agents', 'references')\n}\n\nexport function projectReferenceLayers(root: string): ReferenceLayer[] {\n\treturn [\n\t\t{ tier: 'project', dir: projectReferencesDir(root), plugins: [], status: '' },\n\t\t{ tier: 'project', dir: join(root, '.agents', 'governances'), plugins: [], status: LEGACY_STATUS },\n\t]\n}\n\nfunction readJson(path: string): unknown {\n\ttry {\n\t\treturn JSON.parse(readFileSync(path, 'utf8'))\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nfunction isRepositoryRoot(dir: string): boolean {\n\tif (existsSync(join(dir, '.git')) || existsSync(join(dir, 'pnpm-workspace.yaml'))) return true\n\tconst manifest = readJson(join(dir, 'package.json'))\n\treturn isRecord(manifest) && manifest['workspaces'] !== undefined\n}\n\n/**\n * `root` and each folder above it up to the repository root, nearest first. With no repository root\n * above, `root` alone: a walk that never finds one would read every ancestor up to the filesystem root.\n */\nexport function projectChain(root: string): string[] {\n\tconst start = resolve(root)\n\tconst chain: string[] = []\n\tlet dir = start\n\tfor (;;) {\n\t\tchain.push(dir)\n\t\tif (isRepositoryRoot(dir)) return chain\n\t\tconst parent = dirname(dir)\n\t\tif (parent === dir) return [start]\n\t\tdir = parent\n\t}\n}\n\nfunction isDirectory(path: string): boolean {\n\ttry {\n\t\treturn statSync(path).isDirectory()\n\t} catch {\n\t\treturn false\n\t}\n}\n\nfunction nearestManifest(root: string): string | undefined {\n\tlet dir = root\n\tfor (;;) {\n\t\tconst path = join(dir, 'package.json')\n\t\tif (existsSync(path)) return path\n\t\tconst parent = dirname(dir)\n\t\tif (parent === dir) return undefined\n\t\tdir = parent\n\t}\n}\n\nfunction canonical(path: string): string {\n\ttry {\n\t\treturn realpathSync(path)\n\t} catch {\n\t\treturn path\n\t}\n}\n\n/**\n * Declared dependencies only: a transitive package never becomes a plugin, because a reference is\n * instruction text an agent follows.\n */\nfunction dependencyLayers(root: string, skip: ReadonlySet<string>): ReferenceLayer[] {\n\tconst manifestPath = nearestManifest(root)\n\tif (!manifestPath) return []\n\tconst layers: ReferenceLayer[] = []\n\tfor (const pkg of declaredDependencies(readJson(manifestPath))) {\n\t\tconst dir = packageDir(pkg, manifestPath)\n\t\tif (!dir || skip.has(canonical(dir))) continue\n\t\tconst references = join(dir, 'references')\n\t\tif (!isDirectory(references)) continue\n\t\tconst manifest = readJson(join(dir, 'plugin.json'))\n\t\tconst manifestName = isRecord(manifest) && typeof manifest['name'] === 'string' ? manifest['name'] : undefined\n\t\tconst plugins = manifestName && manifestName !== pkg ? [pkg, manifestName] : [pkg]\n\t\tlayers.push({ tier: 'plugin', dir: references, plugins, status: '' })\n\t}\n\treturn layers\n}\n\nexport async function referenceLayers({\n\troot,\n\thome,\n\tplatform,\n\tprogramData,\n\tpackageRoot = dirname(packageGovernancesDir()),\n\tenv = process.env,\n}: ReferenceLayerOptions): Promise<ReferenceLayer[]> {\n\tconst layer = (tier: ReferenceTier, dir: string, status = ''): ReferenceLayer => ({\n\t\ttier,\n\t\tdir,\n\t\tplugins: [],\n\t\tstatus,\n\t})\n\tconst self = [PACKAGE_PLUGIN]\n\tconst harnesses = detectedHarnesses(env)\n\tconst chain = projectChain(root)\n\tconst ownRoot = canonical(packageRoot)\n\tconst enabled = await enabledPluginLayers(harnesses, chain, { env, homedir: home, cwd: resolve(root), platform })\n\tconst layers: ReferenceLayer[] = [\n\t\tlayer('managed', managedReferencesDir(platform, programData)),\n\t\t...harnessManagedLayers(harnesses, platform, env),\n\t\tlayer('managed', managedGovernancesDir(platform, programData), LEGACY_STATUS),\n\t\tlayer('managed', deprecatedManagedGovernancesDir(platform, programData), DEPRECATED_STATUS),\n\t\t...chain.flatMap(projectReferenceLayers),\n\t\tlayer('user', join(home, '.agents', 'references')),\n\t\tlayer('user', join(home, '.agents', 'governances'), LEGACY_STATUS),\n\t\t{ tier: 'plugin', dir: join(packageRoot, 'references'), plugins: self, status: '' },\n\t\t{ tier: 'plugin', dir: join(packageRoot, 'governances'), plugins: self, status: LEGACY_STATUS },\n\t\t...enabled.filter(({ dir, skipped }) => skipped || (isDirectory(dir) && canonical(dirname(dir)) !== ownRoot)),\n\t\t...dependencyLayers(root, new Set([ownRoot])),\n\t]\n\t// A repository checked out at the home directory would read the same folder as project and user.\n\tconst seen = new Set<string>()\n\treturn layers.filter(({ dir }) => !seen.has(dir) && seen.add(dir))\n}\n","import { cpSync, lstatSync, mkdirSync, readdirSync, realpathSync, rmSync, symlinkSync } from 'node:fs'\nimport { platform } from 'node:os'\nimport { dirname, join, relative, resolve } from 'node:path'\nimport type { Harness, HarnessName } from '../harness-registry/harness-registry.ts'\n\nfunction skillNames(skillsDirectory: string): string[] {\n\treturn readdirSync(skillsDirectory, { withFileTypes: true })\n\t\t.filter((entry) => entry.isDirectory())\n\t\t.map((entry) => entry.name)\n\t\t.sort()\n}\n\nfunction pathOccupied(path: string): boolean {\n\ttry {\n\t\tlstatSync(path)\n\t\treturn true\n\t} catch {\n\t\treturn false\n\t}\n}\n\n/**\n * Compares resolved paths, not link text, so an absolute link, a Windows junction, or a link\n * reached through a parent symlink all read as correct.\n */\nexport function linksTo(target: string, canonical: string): boolean {\n\ttry {\n\t\tif (!lstatSync(target).isSymbolicLink()) return false\n\t\treturn realpathSync(target) === realpathSync(canonical)\n\t} catch {\n\t\treturn false\n\t}\n}\n\n/** Creates the canonical directory when absent, so a fresh repository reports zero skills. */\nexport function countSkills(canonicalSkills: string): number {\n\tmkdirSync(canonicalSkills, { recursive: true })\n\treturn skillNames(canonicalSkills).length\n}\n\n/**\n * Windows junctions resolve a relative target against the process directory, not the link's own, so\n * Windows gets an absolute path; everywhere else stays relative to survive the repository moving.\n */\nfunction linkTarget(target: string, canonicalSkills: string): string {\n\treturn platform() === 'win32' ? resolve(canonicalSkills) : relative(dirname(target), canonicalSkills)\n}\n\n/**\n * `true` = every conflicting target; a list names them individually so a run can't reach past what\n * it named; `false`/empty = none, which is what stops the run on conflict.\n */\nexport type ForceSelection = boolean | readonly string[]\n\n/**\n * A valueless `--force` arrives as the literal string `\"true\"` — the parser's flag encoding — and\n * means every target; anything else is a comma-separated list.\n */\nexport function parseForce(value: string): ForceSelection {\n\tif (value === 'true') return true\n\tif (value === 'false') return false\n\treturn value\n\t\t.split(',')\n\t\t.map((target) => target.trim())\n\t\t.filter((target) => target.length > 0)\n}\n\nexport type ProjectSkillsOptions = {\n\troot: string\n\tcanonicalSkills: string\n\tharnesses: readonly Harness[]\n\tcopy: boolean\n\tforce: ForceSelection\n}\n\nexport type ProjectSkillsResult = {\n\tlinked: HarnessName[]\n\tskipped: HarnessName[]\n}\n\n/**\n * Resolves both sides so the repo-relative path a conflict message prints also selects it back, and\n * so does an absolute path naming the same directory.\n */\nfunction namesTarget(root: string, target: string, given: string): boolean {\n\treturn resolve(root, given) === resolve(target)\n}\n\n/** Symlinks by default; falls back to a copy where the platform refuses the link. */\nexport function projectSkills({\n\troot,\n\tcanonicalSkills,\n\tharnesses,\n\tcopy,\n\tforce,\n}: ProjectSkillsOptions): ProjectSkillsResult {\n\tconst projections = harnesses\n\t\t.filter((harness) => harness.project.skillsDirectory)\n\t\t.map((harness) => ({\n\t\t\tharness,\n\t\t\ttarget: join(root, harness.project.skillsDirectory as string),\n\t\t}))\n\n\tconst named = Array.isArray(force) ? force : []\n\t// An unmatched force target is a typo, not a narrower run — ignoring it would misattribute the\n\t// conflict error it was meant to avoid.\n\tconst unknown = named.filter((given) => !projections.some(({ target }) => namesTarget(root, target, given)))\n\tif (unknown.length) {\n\t\tthrow new Error(\n\t\t\t`No skill target matches:\\n${unknown.map((given) => `- ${given}`).join('\\n')}\\n` +\n\t\t\t\t`Targets for the enabled harnesses:\\n${projections.map(({ target }) => `- ${relative(root, target)}`).join('\\n')}`,\n\t\t)\n\t}\n\n\tconst forces = (target: string): boolean => force === true || named.some((given) => namesTarget(root, target, given))\n\n\tconst conflicts = projections.filter(({ target }) => pathOccupied(target) && !linksTo(target, canonicalSkills))\n\tconst blocked = conflicts.filter(({ target }) => !forces(target))\n\n\t// No target named: nothing distinguishes one conflict from another, so refuse before writing.\n\t// A target named: the unnamed conflicts are what this run was told to leave alone, so skip and\n\t// report them instead of refusing.\n\tif (blocked.length && named.length === 0) {\n\t\tthrow new Error(\n\t\t\t`Refusing to replace existing skill targets:\\n${blocked.map(({ target }) => `- ${relative(root, target)}`).join('\\n')}`,\n\t\t)\n\t}\n\n\tconst skipped = new Set(blocked.map(({ harness }) => harness.name))\n\n\tfor (const { harness, target } of projections) {\n\t\tif (skipped.has(harness.name)) continue\n\t\tmkdirSync(dirname(target), { recursive: true })\n\t\tif (linksTo(target, canonicalSkills)) continue\n\t\tif (pathOccupied(target)) rmSync(target, { recursive: true, force: true })\n\t\tif (copy) {\n\t\t\tcpSync(canonicalSkills, target, { recursive: true })\n\t\t\tcontinue\n\t\t}\n\t\ttry {\n\t\t\tsymlinkSync(linkTarget(target, canonicalSkills), target, platform() === 'win32' ? 'junction' : undefined)\n\t\t} catch (error) {\n\t\t\tif (pathOccupied(target)) throw error\n\t\t\tcpSync(canonicalSkills, target, { recursive: true })\n\t\t}\n\t}\n\n\treturn {\n\t\tlinked: projections.filter(({ harness }) => !skipped.has(harness.name)).map(({ harness }) => harness.name),\n\t\tskipped: projections.filter(({ harness }) => skipped.has(harness.name)).map(({ harness }) => harness.name),\n\t}\n}\n","import { type Dirent, existsSync, readdirSync } from 'node:fs'\nimport { join, posix } from 'node:path'\n\n/** Directories that never hold instructions this repository is responsible for bridging. */\nconst pruned = new Set(['node_modules'])\n\n/**\n * Dot-directories are pruned along with `node_modules`: `.agents/AGENTS.md` is canonical shared\n * instructions, not a subtree-scoped file.\n */\nexport function agentsFileDirectories(root: string): string[] {\n\tconst found: string[] = []\n\n\tconst walk = (relative: string): void => {\n\t\tif (existsSync(join(root, relative, 'AGENTS.md'))) found.push(relative)\n\t\tlet entries: Dirent[]\n\t\ttry {\n\t\t\tentries = readdirSync(join(root, relative), { withFileTypes: true })\n\t\t} catch {\n\t\t\treturn\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tif (!entry.isDirectory() || entry.name.startsWith('.') || pruned.has(entry.name)) continue\n\t\t\twalk(relative ? posix.join(relative, entry.name) : entry.name)\n\t\t}\n\t}\n\n\twalk('')\n\treturn found.sort()\n}\n","import { lstatSync, readFileSync, readlinkSync } from 'node:fs'\nimport { join, posix } from 'node:path'\nimport type { Harness, HarnessName } from '../harness-registry/harness-registry.ts'\nimport type { InstructionBridge } from '../harness-registry/instruction-bridge.ts'\nimport { agentsFileDirectories } from './agents-files.ts'\nimport type { BridgeFinding } from './diagnose-bridges.ts'\nimport { type InstructionProblem, repairFor } from './doctor-guidance.ts'\nimport { parseJsonWithComments } from './json-with-comments.ts'\n\n/** What is on disk where an instruction bridge belongs, or where a shadowing file may sit. */\nexport type InstructionKind = 'import' | 'symlink' | 'settings-entry' | 'file' | 'none'\n/**\n * `shadowing` and `superseded` describe a file suppressing `AGENTS.md`, not a missing bridge;\n * `unbridged` is a bridge file present but not wired to it.\n */\nexport type InstructionStatus = 'ok' | 'missing' | 'unbridged' | 'unreadable' | 'shadowing' | 'superseded'\n\nexport type InstructionReport = {\n\tharness: HarnessName\n\t/** Repository-relative path of the file that carries the bridge, or that shadows `AGENTS.md`. */\n\tpath: string\n\tkind: InstructionKind\n\tstatus: InstructionStatus\n}\n\nexport const canonicalInstructions = 'AGENTS.md'\n\ntype Inspection = {\n\tkind: InstructionKind\n\tstatus: InstructionStatus\n\tproblem?: InstructionProblem\n}\n\n/** A shadow that is on disk always carries a problem: it is a fault, or an offer to remove it. */\ntype ShadowInspection = Inspection & { problem: InstructionProblem }\n\n/** Reads a dotted key out of parsed JSON without asserting anything about the rest of the file. */\nfunction valueAt(settings: unknown, key: string): unknown {\n\treturn key.split('.').reduce<unknown>((value, segment) => {\n\t\tif (typeof value !== 'object' || value === null) return undefined\n\t\treturn (value as Record<string, unknown>)[segment]\n\t}, settings)\n}\n\nfunction exists(target: string): boolean {\n\ttry {\n\t\tlstatSync(target)\n\t\treturn true\n\t} catch {\n\t\treturn false\n\t}\n}\n\nfunction inspectSettingsEntry(target: string, key: string): Inspection {\n\tlet source: string\n\ttry {\n\t\tsource = readFileSync(target, 'utf8')\n\t} catch {\n\t\treturn { kind: 'none', status: 'missing', problem: 'instructions-missing' }\n\t}\n\n\tconst settings = parseJsonWithComments(source)\n\tif (settings === undefined) return { kind: 'file', status: 'unreadable', problem: 'instructions-unreadable' }\n\n\tconst entry = valueAt(settings, key)\n\treturn Array.isArray(entry) && entry.includes(canonicalInstructions)\n\t\t? { kind: 'settings-entry', status: 'ok' }\n\t\t: { kind: 'file', status: 'unbridged', problem: 'instructions-unbridged' }\n}\n\nfunction inspectShadow(target: string): ShadowInspection | undefined {\n\tlet stats: ReturnType<typeof lstatSync>\n\ttry {\n\t\tstats = lstatSync(target)\n\t} catch {\n\t\treturn undefined\n\t}\n\n\tif (stats.isSymbolicLink())\n\t\treturn readlinkSync(target) === canonicalInstructions\n\t\t\t? { kind: 'symlink', status: 'superseded', problem: 'instructions-superseded' }\n\t\t\t: { kind: 'symlink', status: 'shadowing', problem: 'instructions-shadowing' }\n\n\tlet body: string\n\ttry {\n\t\tbody = readFileSync(target, 'utf8')\n\t} catch {\n\t\treturn { kind: 'file', status: 'unreadable', problem: 'instructions-unreadable' }\n\t}\n\n\tconst imported = body.split('\\n').some((line) => line.trim() === `@${canonicalInstructions}`)\n\treturn imported\n\t\t? { kind: 'import', status: 'superseded', problem: 'instructions-superseded' }\n\t\t: { kind: 'file', status: 'shadowing', problem: 'instructions-shadowing' }\n}\n\n/**\n * Checks two things: whether each instruction bridge resolves, and whether anything suppresses a\n * harness that reads `AGENTS.md` natively.\n */\nexport function diagnoseInstructions(\n\troot: string,\n\tharnesses: readonly Harness[],\n\tcli: string,\n): { instructions: InstructionReport[]; findings: BridgeFinding[] } {\n\t// Project scope only: the user-scope bridges are neither written nor read by this tool.\n\tconst bridged = harnesses\n\t\t.map((harness) => ({ name: harness.name, bridge: harness.project.instructionBridge }))\n\t\t.filter((harness): harness is { name: HarnessName; bridge: InstructionBridge } => Boolean(harness.bridge))\n\n\tconst instructions: InstructionReport[] = []\n\tconst findings: BridgeFinding[] = []\n\tconst directories = agentsFileDirectories(root)\n\n\t// Reported only when something depends on the file: a bridge pointing at it, or a shadow with\n\t// no canonical file beside it.\n\tconst shadowsAtRoot = harnesses.some((harness) =>\n\t\t(harness.project.shadowedBy ?? []).some((shadow) => exists(join(root, shadow))),\n\t)\n\tif ((bridged.length || shadowsAtRoot) && !directories.includes('')) {\n\t\tconst { detail, repair } = repairFor('no-instructions')\n\t\tfindings.push({\n\t\t\tpath: canonicalInstructions,\n\t\t\tproblem: 'no-instructions',\n\t\t\tdetail,\n\t\t\trepair: repair({ file: canonicalInstructions }, cli),\n\t\t})\n\t}\n\n\tfor (const { name, bridge } of bridged) {\n\t\tconst inspection = inspectSettingsEntry(join(root, bridge.path), bridge.key)\n\t\tinstructions.push({ harness: name, path: bridge.path, kind: inspection.kind, status: inspection.status })\n\t\tif (inspection.problem) {\n\t\t\tconst { detail, repair } = repairFor(inspection.problem)\n\t\t\tfindings.push({\n\t\t\t\tpath: bridge.path,\n\t\t\t\tproblem: inspection.problem,\n\t\t\t\tdetail,\n\t\t\t\trepair: repair({ file: bridge.path }, cli),\n\t\t\t})\n\t\t}\n\t}\n\n\t// Per directory holding an `AGENTS.md`, not per repository: a `CLAUDE.md` in one subtree says\n\t// nothing about another.\n\tfor (const harness of harnesses) {\n\t\tfor (const shadow of harness.project.shadowedBy ?? []) {\n\t\t\tfor (const directory of directories) {\n\t\t\t\tconst path = directory ? posix.join(directory, shadow) : shadow\n\t\t\t\tconst inspection = inspectShadow(join(root, path))\n\t\t\t\tif (!inspection) continue\n\t\t\t\t// Every shadow that is there is a finding; only its absence is silent.\n\t\t\t\tinstructions.push({ harness: harness.name, path, kind: inspection.kind, status: inspection.status })\n\t\t\t\tconst { detail, repair } = repairFor(inspection.problem)\n\t\t\t\tfindings.push({ path, problem: inspection.problem, detail, repair: repair({ file: path }, cli) })\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { instructions, findings }\n}\n","import { execFileSync } from 'node:child_process'\nimport { join } from 'node:path'\nimport { filesUnder } from './directory-files.ts'\n\n/** Which side of a diverged bridge moved since the last commit where the two agreed. */\nexport type DivergenceDirection = 'bridge' | 'canonical' | 'both' | 'unknown'\n\n/** Whether a path is tracked, and if so whether its skip-worktree bit is still set. */\nexport type TrackingState = 'untracked' | 'tracked' | 'skip-worktree'\n\nfunction git(root: string, args: string[], input?: string): string | undefined {\n\ttry {\n\t\treturn execFileSync('git', args, {\n\t\t\tcwd: root,\n\t\t\tencoding: 'utf8',\n\t\t\t...(input === undefined ? {} : { input }),\n\t\t\tstdio: ['pipe', 'pipe', 'pipe'],\n\t\t})\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nfunction lines(output: string | undefined): string[] {\n\treturn (output ?? '').split('\\n').filter(Boolean)\n}\n\n/**\n * Every method degrades to \"cannot tell\" rather than throwing, so `doctor` still reports on a\n * tarball or a repository with no commits.\n */\nexport class GitBridgeState {\n\t/** `''` at the top, `undefined` outside a repository. */\n\tprivate readonly repoRootPrefix: string | undefined\n\n\tconstructor(private readonly root: string) {\n\t\tthis.repoRootPrefix = git(root, ['rev-parse', '--show-prefix'])?.trim()\n\t}\n\n\t/** The skip-worktree bit is a hint some checkouts clear, so it is verified rather than assumed. */\n\ttrackingOf(path: string): TrackingState {\n\t\tif (this.repoRootPrefix === undefined) return 'untracked'\n\t\tconst entries = lines(git(this.root, ['ls-files', '-v', '--', path]))\n\t\tif (!entries.length) return 'untracked'\n\t\treturn entries.every((entry) => entry.startsWith('S')) ? 'skip-worktree' : 'tracked'\n\t}\n\n\t/**\n\t * Asked of git rather than matched against the file, so a rule on a parent directory is caught\n\t * too.\n\t */\n\tisIgnored(path: string): boolean {\n\t\tif (this.repoRootPrefix === undefined) return false\n\t\treturn git(this.root, ['check-ignore', '-q', '--', path]) !== undefined\n\t}\n\n\t/**\n\t * Bounded to the last 200 commits: a baseline outside that range costs more to find than it's\n\t * worth acting on.\n\t */\n\tcommitsTouching(paths: readonly string[]): string[] {\n\t\tif (this.repoRootPrefix === undefined) return []\n\t\treturn lines(git(this.root, ['rev-list', '-n', '200', 'HEAD', '--', ...paths]))\n\t}\n\n\t/** One file's content at one commit, or `undefined` when it did not exist there. */\n\tcontentAt(commit: string, path: string): string | undefined {\n\t\tif (this.repoRootPrefix === undefined) return undefined\n\t\treturn git(this.root, ['show', `${commit}:${this.repoRootPrefix}${path}`])\n\t}\n\n\tdirectionOf(bridge: string, canonical: string): DivergenceDirection {\n\t\tif (this.repoRootPrefix === undefined) return 'unknown'\n\t\tconst base = this.lastAgreedTree(bridge, canonical)\n\t\tif (base === undefined) return 'unknown'\n\t\tconst bridgeMoved = !this.matchesTree(bridge, base)\n\t\tconst canonicalMoved = !this.matchesTree(canonical, base)\n\t\tif (bridgeMoved && canonicalMoved) return 'both'\n\t\tif (bridgeMoved) return 'bridge'\n\t\treturn 'canonical'\n\t}\n\n\t/** The tree of the newest commit where both paths held identical content. */\n\tprivate lastAgreedTree(bridge: string, canonical: string): string | undefined {\n\t\tfor (const commit of lines(git(this.root, ['rev-list', '-n', '200', 'HEAD', '--', bridge, canonical]))) {\n\t\t\tconst bridgeObject = git(this.root, [\n\t\t\t\t'rev-parse',\n\t\t\t\t'-q',\n\t\t\t\t'--verify',\n\t\t\t\t`${commit}:${this.repoRootPrefix}${bridge}`,\n\t\t\t])?.trim()\n\t\t\tif (!bridgeObject) continue\n\t\t\tconst canonicalObject = git(this.root, [\n\t\t\t\t'rev-parse',\n\t\t\t\t'-q',\n\t\t\t\t'--verify',\n\t\t\t\t`${commit}:${this.repoRootPrefix}${canonical}`,\n\t\t\t])?.trim()\n\t\t\tif (bridgeObject === canonicalObject) return bridgeObject\n\t\t}\n\t\treturn undefined\n\t}\n\n\t/**\n\t * Compares by object id via `hash-object` rather than hashing in-process, so it follows\n\t * whatever object format the repository uses.\n\t */\n\tprivate matchesTree(directory: string, tree: string): boolean {\n\t\tconst expected = new Map(\n\t\t\tlines(git(this.root, ['ls-tree', '-r', tree])).map((entry) => {\n\t\t\t\tconst [meta, path] = entry.split('\\t')\n\t\t\t\treturn [path, (meta as string).split(' ')[2] as string] as const\n\t\t\t}),\n\t\t)\n\t\tconst files = filesUnder(join(this.root, directory))\n\t\tif (files.length !== expected.size || files.some((file) => !expected.has(file))) return false\n\t\tconst hashed = lines(\n\t\t\tgit(this.root, ['hash-object', '--stdin-paths'], files.map((file) => join(directory, file)).join('\\n')),\n\t\t)\n\t\treturn hashed.length === files.length && files.every((file, index) => expected.get(file) === hashed[index])\n\t}\n}\n","import { lstatSync, readFileSync, statSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { type HarnessName, selectHarnesses } from '../harness-registry/harness-registry.ts'\nimport { linksTo } from '../skill-projection/skill-projection.ts'\nimport { diagnoseInstructions, type InstructionReport } from './diagnose-instructions.ts'\nimport { filesUnder } from './directory-files.ts'\nimport { type BridgeProblem, type DoctorProblem, type RepairAction, repairFor } from './doctor-guidance.ts'\nimport { type DivergenceDirection, GitBridgeState } from './git-bridge-state.ts'\n\nexport type BridgeKind = 'symlink' | 'copy' | 'file' | 'none'\nexport type BridgeStatus = 'ok' | 'missing' | 'degraded' | 'stale' | 'diverged'\n\nexport type BridgeReport = {\n\tharness: HarnessName\n\t/** Repository-relative, as the harness registry declares it. */\n\tpath: string\n\tkind: BridgeKind\n\tstatus: BridgeStatus\n}\n\nexport type BridgeFinding = {\n\tpath: string\n\t/**\n\t * Emitted so a caller routes on a name rather than matching `detail` prose, which would break\n\t * when the wording changes.\n\t */\n\tproblem: DoctorProblem\n\tdetail: string\n\t/** What repairs this finding, already carrying the bridge path. Empty `command` means judgment. */\n\trepair: RepairAction\n}\n\nexport type DivergenceReport = {\n\tpath: string\n\tdirection: DivergenceDirection\n}\n\nexport type DiagnoseOptions = {\n\troot: string\n\tharnesses?: HarnessName[]\n\t/** How to name this tool in the repair commands. */\n\tcli: string\n}\n\nexport type DiagnoseResult = {\n\tbridges: BridgeReport[]\n\t/**\n\t * Kept out of `bridges` on purpose: a different `kind`/`status` vocabulary, and a repair that\n\t * is never a command.\n\t */\n\tinstructions: InstructionReport[]\n\tdivergence: DivergenceReport[]\n\tfindings: BridgeFinding[]\n}\n\nconst canonicalPath = '.agents/skills'\n\nfunction pathState(target: string): 'missing' | 'symlink' | 'directory' | 'file' {\n\ttry {\n\t\tconst stats = lstatSync(target)\n\t\tif (stats.isSymbolicLink()) return 'symlink'\n\t\treturn stats.isDirectory() ? 'directory' : 'file'\n\t} catch {\n\t\treturn 'missing'\n\t}\n}\n\nfunction isDirectory(path: string): boolean {\n\ttry {\n\t\treturn statSync(path).isDirectory()\n\t} catch {\n\t\treturn false\n\t}\n}\n\nfunction sameContent(left: string, right: string): boolean {\n\tconst leftFiles = filesUnder(left)\n\tconst rightFiles = filesUnder(right)\n\treturn (\n\t\tleftFiles.length === rightFiles.length &&\n\t\tleftFiles.every(\n\t\t\t(file, index) =>\n\t\t\t\trightFiles[index] === file && readFileSync(join(left, file)).equals(readFileSync(join(right, file))),\n\t\t)\n\t)\n}\n\ntype Inspection = {\n\tkind: BridgeKind\n\tstatus: BridgeStatus\n\tproblem?: BridgeProblem\n\tdirection?: DivergenceDirection\n}\n\nfunction inspect(target: string, path: string, canonical: string, git: GitBridgeState): Inspection {\n\tswitch (pathState(target)) {\n\t\tcase 'missing':\n\t\t\treturn { kind: 'none', status: 'missing', problem: 'missing' }\n\t\t// git with `core.symlinks=false` writes the link out as a regular file holding the target path.\n\t\tcase 'file':\n\t\t\treturn { kind: 'file', status: 'degraded', problem: 'degraded' }\n\t\t// The same test `init` uses to decide a projection is already correct.\n\t\tcase 'symlink':\n\t\t\treturn linksTo(target, canonical)\n\t\t\t\t? { kind: 'symlink', status: 'ok' }\n\t\t\t\t: { kind: 'symlink', status: 'stale', problem: 'stale' }\n\t\tdefault: {\n\t\t\tif (!sameContent(target, canonical)) {\n\t\t\t\tconst direction = git.directionOf(path, canonicalPath)\n\t\t\t\treturn { kind: 'copy', status: 'diverged', problem: `diverged-${direction}`, direction }\n\t\t\t}\n\t\t\t// Stays out of `git status` only while the skip-worktree bit survives.\n\t\t\treturn git.trackingOf(path) === 'tracked'\n\t\t\t\t? { kind: 'copy', status: 'ok', problem: 'unpinned-copy' }\n\t\t\t\t: { kind: 'copy', status: 'ok' }\n\t\t}\n\t}\n}\n\n/**\n * Read-only: nothing is created, moved, or repaired — the caller decides what to run from the\n * repair each finding carries.\n */\nexport function diagnoseBridges({ root, harnesses: preferred = [], cli }: DiagnoseOptions): DiagnoseResult {\n\tconst canonical = join(root, '.agents', 'skills')\n\tconst git = new GitBridgeState(root)\n\tconst selected = selectHarnesses(root, preferred)\n\tconst bridged = selected\n\t\t.map((harness) => ({ name: harness.name, skillsDirectory: harness.project.skillsDirectory }))\n\t\t.filter((harness): harness is { name: HarnessName; skillsDirectory: string } => Boolean(harness.skillsDirectory))\n\n\tconst bridges: BridgeReport[] = []\n\tconst divergence: DivergenceReport[] = []\n\tconst findings: BridgeFinding[] = []\n\n\tif (!isDirectory(canonical)) {\n\t\tconst { detail, repair } = repairFor('no-canonical')\n\t\tfindings.push({\n\t\t\tpath: canonicalPath,\n\t\t\tproblem: 'no-canonical',\n\t\t\tdetail,\n\t\t\trepair: repair({ file: canonicalPath }, cli),\n\t\t})\n\t}\n\n\tfor (const harness of bridged) {\n\t\tconst path = harness.skillsDirectory\n\t\tconst inspection = inspect(join(root, path), path, canonical, git)\n\t\tbridges.push({ harness: harness.name, path, kind: inspection.kind, status: inspection.status })\n\t\tif (inspection.direction) divergence.push({ path, direction: inspection.direction })\n\t\tif (inspection.problem) {\n\t\t\tconst { detail, repair } = repairFor(inspection.problem)\n\t\t\tfindings.push({ path, problem: inspection.problem, detail, repair: repair({ file: path }, cli) })\n\t\t}\n\t}\n\n\tconst instructions = diagnoseInstructions(root, selected, cli)\n\tfindings.push(...instructions.findings)\n\n\treturn { bridges, instructions: instructions.instructions, divergence, findings }\n}\n","import { homedir } from 'node:os'\nimport type { cli } from 'clibuilder'\nimport { command, exitCodes, z } from 'clibuilder'\nimport { collapseHome, displayBinPath, parseFormat, writeResult } from '../command-output/command-output.ts'\nimport { type ConfigurationFinding, diagnoseConfiguration } from '../diagnose-configuration/diagnose-configuration.ts'\nimport { diagnoseMcp } from '../diagnose-mcp/diagnose-mcp.ts'\nimport { diagnoseNonstandard } from '../diagnose-nonstandard/diagnose-nonstandard.ts'\nimport { parseHarnesses } from '../harness-registry/harness-registry.ts'\nimport { listReferences, type ReferenceRow } from '../references/reference-catalog.ts'\nimport { referenceLayers } from '../references/reference-layers.ts'\nimport { type DiagnoseResult, diagnoseBridges } from './diagnose-bridges.ts'\nimport { commandInvocation, type DoctorProblem, type RepairAction } from './doctor-guidance.ts'\nimport { GitBridgeState } from './git-bridge-state.ts'\n\nexport type DoctorReference = Pick<ReferenceRow, 'name' | 'tier' | 'path' | 'status'>\n\nexport type DoctorReport = {\n\tbin: string\n\tbridges: DiagnoseResult['bridges']\n\tinstructions: DiagnoseResult['instructions']\n\t/**\n\t * References the managed, project, and user tiers hold, with the status `reference list` gives;\n\t * reported rather than diagnosed, since a reference is a choice, not a fault.\n\t */\n\treferences: DoctorReference[] | string\n\tdivergence?: DiagnoseResult['divergence']\n\t/**\n\t * The repair is lifted out into `help`; `problem` stays on the row so a caller routes without\n\t * parsing `detail` prose.\n\t */\n\tfindings: { path: string; problem: DoctorProblem; detail: string }[] | string\n\t/**\n\t * One entry per distinct repair; `command` is always emitted, empty when there is none — an\n\t * optional key would break TOON's tabular form.\n\t */\n\thelp?: RepairAction[]\n}\n\n/**\n * AXI §5: the healthy answer states the zero with context, so an agent doesn't re-run to confirm\n * nothing was wrong.\n */\nexport function buildDoctorReport(\n\tbin: string,\n\tresult: DiagnoseResult,\n\tconfiguration: ConfigurationFinding[] = [],\n\theld: DoctorReference[] = [],\n): DoctorReport {\n\tconst findings = [...result.findings, ...configuration]\n\tconst references = held.length ? held : '0 references — no layer outside the plugin tier holds one'\n\t// Counted together so a reader doesn't add up two numbers to learn that nothing is wrong.\n\tif (!findings.length) {\n\t\tconst count = result.bridges.length + result.instructions.length\n\t\tconst bridges = count === 1 ? 'the 1 bridge resolves' : `all ${count} bridges resolve`\n\t\treturn {\n\t\t\tbin,\n\t\t\tbridges: result.bridges,\n\t\t\tinstructions: result.instructions,\n\t\t\treferences,\n\t\t\tfindings: `0 problems found — ${bridges} and the configuration around them is current`,\n\t\t}\n\t}\n\n\treturn {\n\t\tbin,\n\t\tbridges: result.bridges,\n\t\tinstructions: result.instructions,\n\t\treferences,\n\t\t...(result.divergence.length ? { divergence: result.divergence } : {}),\n\t\tfindings: findings.map(({ path, problem, detail }) => ({ path, problem, detail })),\n\t\t// Deduped on the whole pair: several findings often share one repair, and repeating it\n\t\t// reads as more work than there is.\n\t\thelp: [\n\t\t\t...new Map(\n\t\t\t\tfindings.map((finding) => [`${finding.repair.command}\\u0000${finding.repair.instruction}`, finding.repair]),\n\t\t\t).values(),\n\t\t],\n\t}\n}\n\nexport const doctorCommand: cli.Command = command({\n\tname: 'doctor',\n\tdescription:\n\t\t\"Report whether this repository's harness bridges still resolve — skills into .agents/skills, instructions into AGENTS.md. Read-only.\",\n\toptions: {\n\t\troot: {\n\t\t\tdescription: 'Repository or package directory. Defaults to the current directory.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\tharness: {\n\t\t\tdescription: 'Comma-separated harnesses to check in addition to Claude Code and Cursor, e.g. codex,gemini-cli.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\tformat: {\n\t\t\tdescription: 'Output format: toon (default), json, or text for a human-readable report.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'toon',\n\t\t},\n\t},\n\tasync run(args) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst harnesses = parseHarnesses(args.harness)\n\t\t\tconst root = args.root ?? process.cwd()\n\t\t\tconst home = homedir()\n\t\t\tconst result = diagnoseBridges({\n\t\t\t\troot,\n\t\t\t\t...(harnesses.length ? { harnesses } : {}),\n\t\t\t\tcli: commandInvocation,\n\t\t\t})\n\t\t\tconst git = new GitBridgeState(root)\n\t\t\tconst configuration = [\n\t\t\t\t...diagnoseConfiguration({ root, git, cli: commandInvocation }),\n\t\t\t\t...diagnoseMcp({ root, git, cli: commandInvocation }),\n\t\t\t\t...diagnoseNonstandard({ root, cli: commandInvocation }),\n\t\t\t]\n\t\t\tconst { rows } = listReferences(\n\t\t\t\tawait referenceLayers({\n\t\t\t\t\troot,\n\t\t\t\t\thome,\n\t\t\t\t\tplatform: process.platform,\n\t\t\t\t\tprogramData: process.env['ProgramData'],\n\t\t\t\t\tenv: process.env,\n\t\t\t\t}),\n\t\t\t)\n\t\t\t// Resolved across every tier so each status matches `reference list`, but plugin rows are\n\t\t\t// left out: what a plugin ships is its own business, not a repository setting.\n\t\t\tconst held = rows\n\t\t\t\t.filter(({ tier }) => tier !== 'plugin')\n\t\t\t\t.map(({ name, tier, path, status }) => ({ name, tier, path: collapseHome(home, path), status }))\n\t\t\t// Exit stays 0 even with findings: a non-zero code reads to an agent as \"this command\n\t\t\t// is broken\".\n\t\t\twriteResult(buildDoctorReport(displayBinPath(home, process.argv[1]), result, configuration, held), format)\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'Harness diagnosis failed.'}\\n`)\n\t\t\t// Returned, not written: a caller that is not the process has no other way to learn of\n\t\t\t// the failure.\n\t\t\treturn exitCodes.error\n\t\t}\n\t},\n})\n","import { homedir } from 'node:os'\nimport type { cli } from 'clibuilder'\nimport { command, exitCodes, z } from 'clibuilder'\nimport { collapseHome, parseFormat, writeDocument, writeResult } from '../command-output/command-output.ts'\nimport {\n\ttype GovernanceLayer,\n\ttype GovernanceScope,\n\tgovernanceLayers,\n\tlistGovernances,\n\toverrideLayers,\n\tparseGovernanceName,\n\tresolveGovernance,\n} from './governance-overrides.ts'\n\nexport type GovernanceListReport = {\n\t/**\n\t * `status` is always a string, not optional — an optional key would drop this array out of\n\t * TOON's tabular form into a nested list.\n\t */\n\tlayers: { scope: GovernanceScope; path: string; status: string }[]\n\t/** Emitted even when empty, so a healthy run states its zero explicitly. */\n\tgovernances: { name: string; scope: GovernanceScope; path: string }[] | string\n}\n\nexport type GovernanceShowReport = {\n\tname: string\n\tscope: GovernanceScope\n\tpath: string\n\tcontent: string\n}\n\ntype Args = { root: string | undefined; format: string | undefined; 'overrides-only': boolean | undefined }\n\nfunction layersFor(args: Args): GovernanceLayer[] {\n\tconst layers = governanceLayers({\n\t\troot: args.root ?? process.cwd(),\n\t\thome: homedir(),\n\t\tplatform: process.platform,\n\t\tprogramData: process.env['ProgramData'],\n\t})\n\treturn args['overrides-only'] ? overrideLayers(layers) : layers\n}\n\nexport const GOVERNANCE_DEPRECATED =\n\t'warning: \"governance\" is deprecated and will be removed in the next major version; use \"reference show|list\" instead.\\n'\n\nexport const DEPRECATED_MANAGED = 'deprecated — move these documents to the managed layer above'\n\nconst rootOption = {\n\tdescription: 'Repository or package directory. Defaults to the current directory.',\n\ttype: z.optional(z.string()),\n}\n\nconst overridesOnlyOption = {\n\tdescription:\n\t\t'Resolve only the project, user, and machine-wide layers. Never returns a governance this package ships, and exits non-zero when no layer has one.',\n\ttype: z.optional(z.boolean()),\n}\n\nexport const governanceListCommand: cli.Command = command({\n\tname: 'list',\n\tdescription: 'List every governance the override layers hold, each at the layer that would win.',\n\toptions: {\n\t\troot: rootOption,\n\t\t'overrides-only': overridesOnlyOption,\n\t\tformat: {\n\t\t\tdescription: 'Output format: toon (default), json, or text for a human-readable report.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'toon',\n\t\t},\n\t},\n\trun(args: Args) {\n\t\tprocess.stderr.write(GOVERNANCE_DEPRECATED)\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst home = homedir()\n\t\t\tconst layers = layersFor(args)\n\t\t\tconst entries = listGovernances(layers)\n\t\t\tconst report: GovernanceListReport = {\n\t\t\t\tlayers: layers.map(({ scope, dir }) => ({\n\t\t\t\t\tscope,\n\t\t\t\t\tpath: collapseHome(home, dir),\n\t\t\t\t\tstatus: scope === 'managed-deprecated' ? DEPRECATED_MANAGED : '',\n\t\t\t\t})),\n\t\t\t\tgovernances: entries.length\n\t\t\t\t\t? entries.map(({ name, scope, path }) => ({ name, scope, path: collapseHome(home, path) }))\n\t\t\t\t\t: '0 governances — no layer holds one',\n\t\t\t}\n\t\t\twriteResult(report, format)\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'Governance listing failed.'}\\n`)\n\t\t\treturn exitCodes.error\n\t\t}\n\t},\n})\n\nexport const governanceShowCommand: cli.Command = command({\n\tname: 'show',\n\tdescription: 'Print one governance document, resolved through the layers in order.',\n\targuments: [{ name: 'name', description: 'The governance name, without the `.md` extension.', type: z.string() }],\n\toptions: {\n\t\troot: rootOption,\n\t\t'overrides-only': overridesOnlyOption,\n\t\tformat: {\n\t\t\tdescription:\n\t\t\t\t'Output format: text (default) writes the document itself; toon and json wrap it with the layer it came from.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'text',\n\t\t},\n\t},\n\trun(args: Args & { name: string }) {\n\t\tprocess.stderr.write(GOVERNANCE_DEPRECATED)\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst name = parseGovernanceName(args.name)\n\t\t\tconst found = resolveGovernance(name, layersFor(args))\n\t\t\tif (!found) {\n\t\t\t\t// stderr, not stdout — a caller piping the document off stdout must never see this\n\t\t\t\t// prose\n\t\t\t\t// mixed in.\n\t\t\t\tprocess.stderr.write(\n\t\t\t\t\targs['overrides-only']\n\t\t\t\t\t\t? `error: no override for governance \"${name}\" in the project, user, or machine-wide layer.\\n`\n\t\t\t\t\t\t: `error: no governance named \"${name}\" in any layer.\\n`,\n\t\t\t\t)\n\t\t\t\treturn exitCodes.error\n\t\t\t}\n\t\t\tif (format === 'text') {\n\t\t\t\twriteDocument(found.content)\n\t\t\t} else {\n\t\t\t\tconst report: GovernanceShowReport = {\n\t\t\t\t\tname: found.name,\n\t\t\t\t\tscope: found.scope,\n\t\t\t\t\tpath: collapseHome(homedir(), found.path),\n\t\t\t\t\tcontent: found.content,\n\t\t\t\t}\n\t\t\t\twriteResult(report, format)\n\t\t\t}\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'Governance lookup failed.'}\\n`)\n\t\t\treturn exitCodes.error\n\t\t}\n\t},\n})\n\nexport const governanceCommand: cli.Command = command({\n\tname: 'governance',\n\tdescription:\n\t\t'Deprecated: use `reference`. Read the governance documents the project, user, and machine-wide override layers hold. Read-only.',\n\tcommands: [governanceListCommand, governanceShowCommand],\n})\n","import { homedir } from 'node:os'\nimport type { cli } from 'clibuilder'\nimport { command, exitCodes, z } from 'clibuilder'\nimport {\n\tcollapseHome,\n\ttype OutputFormat,\n\tparseFormat,\n\trenderText,\n\twriteDocument,\n\twriteResult,\n} from '../command-output/command-output.ts'\nimport { listReferences, type ReferenceRow, type SearchMatch, searchReferences } from './reference-catalog.ts'\nimport { type ReferenceLayer, type ReferenceTier, referenceLayers } from './reference-layers.ts'\nimport {\n\tparseReferenceName,\n\ttype ResolvedReference,\n\tresolveReference,\n\ttype TraceEntry,\n\ttype UsedLayer,\n} from './resolve-reference.ts'\n\n/** One per name asked, in the order asked — the contract the `load-reference` skill builds on. */\nexport type ReferenceShowEntry = {\n\tname: string\n\tstatus: ResolvedReference['status']\n\ttier?: ReferenceTier\n\tplugin?: string\n\tpath?: string\n\tmerge?: string\n\tmetadata?: Record<string, unknown>\n\tcontent?: string\n\tlayers?: UsedLayer[]\n\twarnings: string[]\n\tsuggestions?: string[]\n\tplugins?: string[]\n\ttrace?: Omit<TraceEntry, 'description'>[]\n}\n\nexport type ReferenceListReport = {\n\tlayers: { tier: ReferenceTier; plugin: string; path: string; status: string }[]\n\t/** Emitted even when empty, so a healthy run states its zero explicitly. */\n\treferences: ReferenceRow[] | string\n\twarnings?: string[]\n}\n\nexport type ReferenceSearchReport = { query: string; references: SearchMatch[] | string }\n\ntype CommonArgs = { root: string | undefined; format: string | undefined }\n\nconst rootOption = {\n\tdescription:\n\t\t'Directory the project tier is read from, and each folder above it up to the repository root. Defaults to the current directory.',\n\ttype: z.optional(z.string()),\n}\n\nfunction layersFor(args: CommonArgs, home: string): Promise<ReferenceLayer[]> {\n\treturn referenceLayers({\n\t\troot: args.root ?? process.cwd(),\n\t\thome,\n\t\tplatform: process.platform,\n\t\tprogramData: process.env['ProgramData'],\n\t\tenv: process.env,\n\t})\n}\n\nfunction fail(error: unknown, fallback: string): number {\n\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : fallback}\\n`)\n\treturn exitCodes.error\n}\n\nfunction showEntry(\n\tresolved: ResolvedReference,\n\thome: string,\n\tsuggestions: string[],\n\ttrace: boolean,\n): ReferenceShowEntry {\n\tconst entry: ReferenceShowEntry = { name: resolved.name, status: resolved.status, warnings: [] }\n\tif (resolved.status === 'found') {\n\t\tObject.assign(entry, {\n\t\t\ttier: resolved.tier,\n\t\t\tplugin: resolved.plugin,\n\t\t\tpath: collapseHome(home, resolved.path as string),\n\t\t\tmerge: resolved.merge,\n\t\t\tmetadata: resolved.metadata,\n\t\t\tcontent: resolved.content,\n\t\t\tlayers: resolved.layers.map((layer) => ({ ...layer, path: collapseHome(home, layer.path) })),\n\t\t})\n\t}\n\tif (resolved.status === 'missing') entry.suggestions = suggestions\n\tif (resolved.status === 'ambiguous') entry.plugins = resolved.plugins\n\tentry.warnings = resolved.warnings\n\tif (trace) {\n\t\tentry.trace = resolved.trace.map(({ description: _, ...step }) => ({\n\t\t\t...step,\n\t\t\tpath: collapseHome(home, step.path),\n\t\t}))\n\t}\n\treturn entry\n}\n\nfunction missReason(entry: ReferenceShowEntry): string {\n\tif (entry.status === 'ambiguous') {\n\t\treturn `\"${entry.name}\" is held by more than one plugin; ask for one of ${(entry.plugins as string[]).join(', ')}.`\n\t}\n\tconst hint = entry.suggestions?.length ? ` Did you mean: ${entry.suggestions.join(', ')}?` : ''\n\treturn `no reference named \"${entry.name}\" in any tier.${hint}`\n}\n\nfunction writeShowText(entries: readonly ReferenceShowEntry[]): void {\n\tif (entries.length === 1) {\n\t\tconst [entry] = entries as [ReferenceShowEntry]\n\t\tif (entry.content !== undefined) writeDocument(entry.content)\n\t\treturn\n\t}\n\tconst blocks = entries.map((entry) =>\n\t\tentry.content === undefined\n\t\t\t? `<reference name=\"${entry.name}\" status=\"${entry.status}\" />`\n\t\t\t: `<reference name=\"${entry.name}\" tier=\"${entry.tier}\">\\n${entry.content}</reference>`,\n\t)\n\twriteDocument(blocks.join('\\n\\n'))\n}\n\nfunction writeShowStderr(entries: readonly ReferenceShowEntry[], format: OutputFormat): void {\n\tfor (const entry of entries) {\n\t\tif (format === 'text') {\n\t\t\tfor (const warning of entry.warnings) process.stderr.write(`warning: ${warning}\\n`)\n\t\t\tif (entry.trace) process.stderr.write(`${renderText({ [`trace ${entry.name}`]: entry.trace })}\\n`)\n\t\t}\n\t\tif (entry.status !== 'found') process.stderr.write(`error: ${missReason(entry)}\\n`)\n\t}\n}\n\nexport const referenceShowCommand: cli.Command = command({\n\tname: 'show',\n\tdescription: 'Print one or more references, each resolved through the tiers and combined as its layers ask.',\n\targuments: [\n\t\t{\n\t\t\tname: 'names',\n\t\t\tdescription: 'Reference names, without the `.md` extension; `<plugin>/<name>` picks one plugin.',\n\t\t\ttype: z.array(z.string()),\n\t\t},\n\t],\n\toptions: {\n\t\troot: rootOption,\n\t\ttrace: {\n\t\t\tdescription: 'Report every path checked, the file that matched, the merge mode, and why a layer was dropped.',\n\t\t\ttype: z.optional(z.boolean()),\n\t\t},\n\t\tformat: {\n\t\t\tdescription:\n\t\t\t\t'Output format: text (default) writes the documents themselves; toon and json return an array with metadata.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'text',\n\t\t},\n\t},\n\tasync run(args: CommonArgs & { names: string[]; trace: boolean | undefined }) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst names = args.names.map(parseReferenceName)\n\t\t\tif (!names.length) throw new Error('Name at least one reference.')\n\t\t\tconst home = homedir()\n\t\t\tconst layers = await layersFor(args, home)\n\t\t\tconst display = (path: string) => collapseHome(home, path)\n\t\t\tconst entries = names.map((name) => {\n\t\t\t\tconst resolved = resolveReference(name, layers, { display })\n\t\t\t\tconst suggestions =\n\t\t\t\t\tresolved.status === 'missing'\n\t\t\t\t\t\t? searchReferences(name.name, layers, { display })\n\t\t\t\t\t\t\t\t.slice(0, 3)\n\t\t\t\t\t\t\t\t.map((match) => match.name)\n\t\t\t\t\t\t: []\n\t\t\t\treturn showEntry(resolved, home, suggestions, Boolean(args.trace))\n\t\t\t})\n\t\t\tif (format === 'text') writeShowText(entries)\n\t\t\telse writeResult(entries, format)\n\t\t\twriteShowStderr(entries, format)\n\t\t\treturn entries.every((entry) => entry.status === 'found') ? exitCodes.success : exitCodes.error\n\t\t} catch (error) {\n\t\t\treturn fail(error, 'Reference lookup failed.')\n\t\t}\n\t},\n})\n\nconst listFormatOption = {\n\tdescription: 'Output format: toon (default), json, or text for a human-readable report.',\n\ttype: z.optional(z.string()),\n\tdefault: 'toon',\n}\n\nexport const referenceListCommand: cli.Command = command({\n\tname: 'list',\n\tdescription: 'List every layer, and every reference at every layer that holds it, marked used or shadowed.',\n\toptions: { root: rootOption, format: listFormatOption },\n\tasync run(args: CommonArgs) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst home = homedir()\n\t\t\tconst layers = await layersFor(args, home)\n\t\t\tconst { rows, warnings } = listReferences(layers, { display: (path) => collapseHome(home, path) })\n\t\t\tconst report: ReferenceListReport = {\n\t\t\t\tlayers: layers.map(({ tier, plugins, dir, status }) => ({\n\t\t\t\t\ttier,\n\t\t\t\t\tplugin: plugins[0] ?? '',\n\t\t\t\t\tpath: collapseHome(home, dir),\n\t\t\t\t\tstatus,\n\t\t\t\t})),\n\t\t\t\treferences: rows.length\n\t\t\t\t\t? rows.map((row) => ({ ...row, path: collapseHome(home, row.path) }))\n\t\t\t\t\t: '0 references — no layer holds one',\n\t\t\t}\n\t\t\tif (warnings.length) report.warnings = warnings\n\t\t\twriteResult(report, format)\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\treturn fail(error, 'Reference listing failed.')\n\t\t}\n\t},\n})\n\nexport const referenceSearchCommand: cli.Command = command({\n\tname: 'search',\n\tdescription: 'Find references by name, description, tags, headings, or body, best match first.',\n\targuments: [{ name: 'query', description: 'What the reference is about.', type: z.string() }],\n\toptions: { root: rootOption, format: listFormatOption },\n\tasync run(args: CommonArgs & { query: string }) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst query = args.query.trim()\n\t\t\tif (!query) throw new Error('Search needs a query.')\n\t\t\tconst home = homedir()\n\t\t\tconst matches = searchReferences(query, await layersFor(args, home), {\n\t\t\t\tdisplay: (path) => collapseHome(home, path),\n\t\t\t})\n\t\t\tconst report: ReferenceSearchReport = {\n\t\t\t\tquery,\n\t\t\t\treferences: matches.length ? matches : `0 references match \"${query}\"`,\n\t\t\t}\n\t\t\twriteResult(report, format)\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\treturn fail(error, 'Reference search failed.')\n\t\t}\n\t},\n})\n\nexport const referenceCommand: cli.Command = command({\n\tname: 'reference',\n\tdescription:\n\t\t'Read on-demand reference documents by name, layered across the managed, project, user, and plugin tiers. Read-only.',\n\tcommands: [referenceShowCommand, referenceListCommand, referenceSearchCommand],\n})\n","import { mkdirSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { type HarnessName, selectHarnesses } from '../harness-registry/harness-registry.ts'\nimport { projectReferenceLayers, projectReferencesDir } from '../references/reference-layers.ts'\nimport { referenceNames } from '../references/resolve-reference.ts'\nimport { countSkills, type ForceSelection, projectSkills } from '../skill-projection/skill-projection.ts'\n\nexport type InitializeOptions = {\n\troot: string\n\tharnesses?: HarnessName[]\n\tcopy?: boolean\n\tforce?: ForceSelection\n}\nexport type InitializeResult = {\n\troot: string\n\tharnesses: HarnessName[]\n\tnative: HarnessName[]\n\tlinked: HarnessName[]\n\t/**\n\t * Enabled harnesses left untouched because their target conflicts and `--force` did not name\n\t * it.\n\t */\n\tskipped: HarnessName[]\n\t/** Enabled harnesses whose name has been superseded, as `{ name, replacedBy }`. */\n\tdeprecated: { name: HarnessName; replacedBy: HarnessName }[]\n\tskills: number\n\t/**\n\t * References the project tier holds, legacy `governances/` included; `.agents/references` is\n\t * created when absent and counted, like `skills`, so a fresh repo reports zero rather than\n\t * leaving it unclear.\n\t */\n\treferences: number\n\tcopied: boolean\n}\n\nexport function initializeHarnesses({\n\troot,\n\tharnesses: preferred = [],\n\tcopy = false,\n\tforce = false,\n}: InitializeOptions): InitializeResult {\n\tconst canonicalSkills = join(root, '.agents', 'skills')\n\tconst skills = countSkills(canonicalSkills)\n\tmkdirSync(projectReferencesDir(root), { recursive: true })\n\tconst references = referenceNames(projectReferenceLayers(root)).length\n\tconst harnesses = selectHarnesses(root, preferred)\n\tconst { linked, skipped } = projectSkills({ root, canonicalSkills, harnesses, copy, force })\n\n\treturn {\n\t\troot,\n\t\tharnesses: harnesses.map((harness) => harness.name),\n\t\tnative: harnesses.filter((harness) => !harness.project.skillsDirectory).map((harness) => harness.name),\n\t\tlinked,\n\t\tskipped,\n\t\tdeprecated: harnesses\n\t\t\t.filter((harness) => harness.deprecated)\n\t\t\t.map((harness) => ({ name: harness.name, replacedBy: harness.deprecated as HarnessName })),\n\t\tskills,\n\t\treferences,\n\t\tcopied: copy,\n\t}\n}\n","import type { cli } from 'clibuilder'\nimport { command, exitCodes, z } from 'clibuilder'\nimport { parseFormat, writeResult } from '../command-output/command-output.ts'\nimport { doctorCommand } from '../diagnose-bridges/doctor.command.ts'\nimport { governanceCommand } from '../governance-overrides/governance.command.ts'\nimport { parseHarnesses } from '../harness-registry/harness-registry.ts'\nimport { referenceCommand } from '../references/reference.command.ts'\nimport { parseForce } from '../skill-projection/skill-projection.ts'\nimport { initializeHarnesses } from './initialize-harnesses.ts'\n\nexport const initCommand: cli.Command = command({\n\tname: 'init',\n\tdescription: 'Set up canonical agent skills for the harnesses already enabled in a repository.',\n\toptions: {\n\t\troot: {\n\t\t\tdescription: 'Repository or package directory. Defaults to the current directory.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\tharness: {\n\t\t\tdescription: 'Comma-separated harnesses to enable in addition to Claude Code and Cursor, e.g. codex,gemini-cli.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\tcopy: {\n\t\t\tdescription: 'Copy skills instead of linking them.',\n\t\t\ttype: z.optional(z.boolean()),\n\t\t},\n\t\tforce: {\n\t\t\tdescription:\n\t\t\t\t'Replace conflicting target skill directories. Names the targets to replace, comma-separated (e.g. .claude/skills); given alone it replaces every conflicting target.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\tformat: {\n\t\t\tdescription: 'Output format: toon (default), json, or text for a human-readable report.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'toon',\n\t\t},\n\t},\n\trun(args) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst harnesses = parseHarnesses(args.harness)\n\t\t\twriteResult(\n\t\t\t\tinitializeHarnesses({\n\t\t\t\t\troot: args.root ?? process.cwd(),\n\t\t\t\t\t...(harnesses.length ? { harnesses } : {}),\n\t\t\t\t\t...(args.copy === undefined ? {} : { copy: args.copy }),\n\t\t\t\t\t...(args.force === undefined ? {} : { force: parseForce(args.force) }),\n\t\t\t\t}),\n\t\t\t\tformat,\n\t\t\t)\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'Harness initialization failed.'}\\n`)\n\t\t\t// Returned, not written — writing it here reports failure past `run`, not to it, so a\n\t\t\t// non-process caller never learns of it.\n\t\t\treturn exitCodes.error\n\t\t}\n\t},\n})\n\n// Named `agent-harness`, not `harness` — `repobuddy` mounts every plugin into one namespace, and\n// `harness` is generic enough to collide.\nexport const harnessCommand: cli.Command = command({\n\tname: 'agent-harness',\n\tdescription: 'Commands for configuring agent harness compatibility.',\n\tcommands: [initCommand, doctorCommand, referenceCommand, governanceCommand],\n})\n\nexport function activate({ addCommand }: { addCommand(command: typeof harnessCommand): void }): void {\n\taddCommand(harnessCommand)\n}\n","import { stringify as stringifyToml } from 'smol-toml'\nimport { type AST, parseTOML } from 'toml-eslint-parser'\nimport type { ConfigEdit } from './config-edit.ts'\n\nfunction nested(path: string[], value: Record<string, unknown>): Record<string, unknown> {\n\treturn path.reduceRight<Record<string, unknown>>((inner, key) => ({ [key]: inner }), value)\n}\n\n/** `value` as the table at `path`, with its sub-tables, in the form `smol-toml` writes it. */\nexport function renderTomlTable(path: string[], value: Record<string, unknown>): string {\n\treturn stringifyToml(nested(path, value))\n}\n\n/** Appends the table at `path` after the last byte of `source`, which stays as it is. */\nexport function appendTomlTable(source: string, path: string[], value: Record<string, unknown>): string {\n\tconst separator = source === '' || source.endsWith('\\n') ? '' : '\\n'\n\treturn `${source}${separator}\\n${renderTomlTable(path, value)}`\n}\n\nfunction keyNames(key: AST.TOMLKey): string[] {\n\treturn key.keys.map((part) => (part.type === 'TOMLBare' ? part.name : part.value))\n}\n\nfunction startsWith(key: readonly (string | number)[], prefix: string[]): boolean {\n\treturn prefix.length <= key.length && prefix.every((part, index) => key[index] === part)\n}\n\n/** Either key names a place inside the other, so a value at one defines or holds the other. */\nfunction overlaps(key: string[], path: string[]): boolean {\n\treturn startsWith(key, path) || startsWith(path, key)\n}\n\n/**\n * Replaces the table at `path` and every `[path.*]` sub-table, wherever they sit, keeping every\n * byte outside them. Only the `[table]` header form is replaced: a table written inline or as\n * dotted keys, or holding an array of tables, is refused as `shape`, and so is one whose header is\n * only implied by a sub-table. `smol-toml` keeps no source offsets, so `toml-eslint-parser`\n * locates the tables; values still come from `smol-toml`.\n */\nexport function replaceTomlTable(source: string, path: string[], value: Record<string, unknown>): ConfigEdit {\n\tlet program: AST.TOMLProgram\n\ttry {\n\t\tprogram = parseTOML(source)\n\t} catch {\n\t\treturn { kind: 'refused', reason: 'unreadable' }\n\t}\n\tconst owned: AST.TOMLTable[] = []\n\tfor (const node of program.body[0].body) {\n\t\tif (node.type === 'TOMLKeyValue') {\n\t\t\tif (overlaps(keyNames(node.key), path)) return { kind: 'refused', reason: 'shape' }\n\t\t\tcontinue\n\t\t}\n\t\tif (startsWith(node.resolvedKey, path)) {\n\t\t\tif (node.kind === 'array') return { kind: 'refused', reason: 'shape' }\n\t\t\towned.push(node)\n\t\t\tcontinue\n\t\t}\n\t\tconst table = node.resolvedKey as string[]\n\t\tif (node.body.some((pair) => overlaps([...table, ...keyNames(pair.key)], path)))\n\t\t\treturn { kind: 'refused', reason: 'shape' }\n\t}\n\tif (!owned.length) return { kind: 'refused', reason: 'absent' }\n\tif (!owned.some((table) => table.resolvedKey.length === path.length)) return { kind: 'refused', reason: 'shape' }\n\t// A table's range ends at its last value; a comment after that value on the same line is still its.\n\tconst spans = owned.map((table): [number, number] => {\n\t\tconst lineEnd = source.slice(table.range[1]).search(/\\r?\\n/)\n\t\treturn [table.range[0], lineEnd < 0 ? source.length : table.range[1] + lineEnd]\n\t})\n\tconst inside = (offset: number) => spans.some(([start, end]) => start <= offset && offset < end)\n\tif (program.comments.some((comment) => inside(comment.range[0]))) return { kind: 'refused', reason: 'comment' }\n\n\tconst [first, ...rest] = spans as [[number, number], ...[number, number][]]\n\tlet text = source\n\tfor (const [start, end] of rest.reverse()) {\n\t\tconst before = text.slice(0, start)\n\t\tconst after = text.slice(end).replace(/^\\r?\\n/, '')\n\t\ttext = /\\n\\r?\\n$/.test(before) ? `${before}${after.replace(/^\\r?\\n/, '')}` : `${before}${after}`\n\t}\n\tconst rendered = renderTomlTable(path, value).trimEnd()\n\treturn { kind: 'edited', text: `${text.slice(0, first[0])}${rendered}${text.slice(first[1])}` }\n}\n\nconst bareKey = /^[A-Za-z0-9_-]+$/\n\nfunction tomlKey(name: string): string {\n\treturn bareKey.test(name) ? name : JSON.stringify(name)\n}\n\n/** One value in TOML inline syntax: a map stays on its line as an inline table, not a sub-table. */\nexport function renderTomlInline(value: unknown): string {\n\tif (typeof value === 'object' && value !== null && !Array.isArray(value))\n\t\treturn `{ ${Object.entries(value)\n\t\t\t.map(([name, item]) => `${tomlKey(name)} = ${renderTomlInline(item)}`)\n\t\t\t.join(', ')} }`\n\treturn stringifyToml({ v: value }).slice('v = '.length).trimEnd()\n}\n\n/**\n * Appends the table at `path` with every value inline, so a later field edit finds each value on\n * one line of that table rather than in a sub-table.\n */\nexport function appendInlineTomlTable(source: string, path: string[], value: Record<string, unknown>): string {\n\tconst separator = source === '' || source.endsWith('\\n') ? '' : '\\n'\n\tconst lines = Object.entries(value).map(([name, item]) => `${tomlKey(name)} = ${renderTomlInline(item)}\\n`)\n\treturn `${source}${separator}\\n[${path.map(tomlKey).join('.')}]\\n${lines.join('')}`\n}\n\nfunction lineEndAt(source: string, offset: number): number {\n\tconst end = source.indexOf('\\n', offset)\n\treturn end === -1 ? source.length : end\n}\n\n/**\n * Sets, adds, or (with `undefined`) removes the one key `name` of the `[path]` table, keeping every\n * byte outside that key-value line. Only a key written directly in the table's own `[header]` form\n * is taken apart: a table written inline or as dotted keys is `absent`, and a key spread over dotted\n * keys or a sub-table is `shape`.\n */\nexport function setTomlKey(source: string, path: string[], name: string, value: unknown): ConfigEdit {\n\tlet program: AST.TOMLProgram\n\ttry {\n\t\tprogram = parseTOML(source)\n\t} catch {\n\t\treturn { kind: 'refused', reason: 'unreadable' }\n\t}\n\tconst tables = program.body[0].body.filter((node): node is AST.TOMLTable => node.type === 'TOMLTable')\n\tconst table = tables.find(\n\t\t(node) => node.kind === 'standard' && node.resolvedKey.length === path.length && startsWith(node.resolvedKey, path),\n\t)\n\tif (!table) return { kind: 'refused', reason: 'absent' }\n\tconst pairs = table.body\n\tconst spread =\n\t\ttables.some((node) => startsWith(node.resolvedKey, [...path, name])) ||\n\t\tpairs.some((pair) => keyNames(pair.key)[0] === name && pair.key.keys.length > 1)\n\tif (spread) return { kind: 'refused', reason: 'shape' }\n\n\tconst pair = pairs.find((item) => item.key.keys.length === 1 && keyNames(item.key)[0] === name)\n\tif (pair && value !== undefined)\n\t\treturn {\n\t\t\tkind: 'edited',\n\t\t\ttext: `${source.slice(0, pair.value.range[0])}${renderTomlInline(value)}${source.slice(pair.value.range[1])}`,\n\t\t}\n\tif (pair) {\n\t\t// TOML holds one key-value per line, so the whole line and its trailing comment go with it.\n\t\tconst start = source.lastIndexOf('\\n', pair.range[0] - 1) + 1\n\t\tconst end = lineEndAt(source, pair.range[1])\n\t\treturn { kind: 'edited', text: `${source.slice(0, start)}${source.slice(Math.min(end + 1, source.length))}` }\n\t}\n\tif (value === undefined) return { kind: 'edited', text: source }\n\tconst after = lineEndAt(source, pairs.at(-1)?.range[1] ?? table.range[0])\n\treturn {\n\t\tkind: 'edited',\n\t\ttext: `${source.slice(0, after)}\\n${tomlKey(name)} = ${renderTomlInline(value)}${source.slice(after)}`,\n\t}\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport { appendInlineTomlTable, renderTomlInline, setTomlKey } from '../config-edit/toml-edit.ts'\nimport type { GitBridgeState } from '../diagnose-bridges/git-bridge-state.ts'\nimport { locatorText, type Position } from '../diagnose-bridges/locator.ts'\nimport {\n\tformatProjectionRecord,\n\tMcpBaseline,\n\tparseProjectionRecord,\n\tprojectionRecordPath,\n} from '../diagnose-mcp/mcp-baseline.ts'\nimport { divergingFields, type McpField, type McpServer, mcpFields, sameField } from '../diagnose-mcp/mcp-model.ts'\nimport { credentialFields, nonSecretArgs } from '../diagnose-mcp/mcp-secrets.ts'\nimport { goldenSetPath, mcpTargets, parseGoldenSet, parseTarget } from '../diagnose-mcp/mcp-sources.ts'\nimport type { McpConfig } from '../harness-registry/mcp-config.ts'\nimport { isRecord } from '../is-record/is-record.ts'\nimport { mcpDialects } from '../mcp-dialects/mcp-dialects.ts'\n\n/**\n * `import` is offered and waits for approval; `imported` was approved and written; `edit` was\n * approved but cannot be spliced in byte-safely, so `value` is for a person to apply; `skip` and\n * `refuse` are never importable, whatever is approved.\n */\nexport type ReconcileAction = 'import' | 'imported' | 'edit' | 'skip' | 'refuse'\n\nexport type ReconcileRow = {\n\t/** The locator `doctor` reports, and what `--accept` names to approve this one field. */\n\tpath: string\n\taction: ReconcileAction\n\tdetail: string\n\t/** The field as it would read in the golden set; never set on a row refusing a credential. */\n\tvalue?: string\n}\n\nexport type ReconcilePlan =\n\t| { kind: 'absent' }\n\t| { kind: 'unreadable'; position?: Position | undefined }\n\t/** An approval named something not importable; nothing was written. */\n\t| { kind: 'rejected'; reasons: string[] }\n\t| { kind: 'planned'; rows: ReconcileRow[]; written: boolean }\n\nexport type ReconcileMcpOptions = {\n\troot: string\n\tgit: GitBridgeState\n\t/** The locators approved, one field each. Empty is a dry run. */\n\taccept: readonly string[]\n}\n\ntype Offer = {\n\trow: ReconcileRow\n\tconfig: McpConfig\n\tserver: string\n\tfield: McpField\n\t/** `undefined` removes the field from the golden set. */\n\tvalue: unknown\n\tcarried: McpServer\n\t/** The golden server does not exist yet: approving adds it. */\n\tadds: boolean\n}\n\nfunction read(root: string, path: string): string | undefined {\n\tconst absolute = join(root, path)\n\treturn existsSync(absolute) ? readFileSync(absolute, 'utf8') : undefined\n}\n\nconst held = {\n\tboth: 'both sides changed since the last projection — a three-way conflict for a person to settle, never imported',\n\tunknown: 'no baseline says which side changed — compare the two by hand; never imported',\n}\n\n/** Transport the golden set would infer anyway: stating it would record the harness's spelling, not a choice. */\nfunction inferredTransport(server: McpServer): McpServer['transport'] {\n\treturn server.url === undefined ? 'stdio' : 'http'\n}\n\n/** Only the names the golden set speaks for: a name only the harness carries is never compared, so never pulled. */\nfunction mapValue(declared: unknown, carried: unknown): Record<string, string> | undefined {\n\tconst kept = Object.entries(declared as Record<string, string>).flatMap(([name]) => {\n\t\tconst value = isRecord(carried) ? carried[name] : undefined\n\t\treturn typeof value === 'string' ? [[name, value]] : []\n\t})\n\treturn kept.length ? Object.fromEntries(kept) : undefined\n}\n\nexport function reconcileMcp({ root, git, accept }: ReconcileMcpOptions): ReconcilePlan {\n\tconst goldenSource = read(root, goldenSetPath)\n\tconst golden = parseGoldenSet(goldenSource)\n\tif (golden.kind !== 'servers') return golden\n\n\tconst record = parseProjectionRecord(read(root, projectionRecordPath))\n\tconst baseline = new McpBaseline({ git, record })\n\tconst rows: ReconcileRow[] = []\n\tconst offers: Offer[] = []\n\n\tfor (const config of mcpTargets(root)) {\n\t\tconst parsed = parseTarget(config, read(root, config.path))\n\t\tif (parsed.kind === 'unreadable') {\n\t\t\trows.push({ path: config.path, action: 'refuse', detail: 'the target does not parse' })\n\t\t\tcontinue\n\t\t}\n\t\tif (parsed.kind === 'absent') continue\n\t\tconst dialect = mcpDialects[config.dialect]\n\n\t\tfor (const [server, carried] of parsed.servers) {\n\t\t\tconst declared = golden.servers.get(server)\n\t\t\tconst at = (field: string) => locatorText({ file: config.path, server, field })\n\t\t\tconst offer = (field: McpField, proposed: unknown) => {\n\t\t\t\tconst literals = literalsIn(field, proposed)\n\t\t\t\tfor (const literal of literals)\n\t\t\t\t\trows.push({\n\t\t\t\t\t\tpath: at(literal),\n\t\t\t\t\t\taction: 'refuse',\n\t\t\t\t\t\tdetail: `${literal} holds a literal credential, which never enters the golden set — set it in the environment and reference it as \\${VAR}`,\n\t\t\t\t\t})\n\t\t\t\tconst value = withoutLiterals(field, proposed, literals, declared)\n\t\t\t\tif (literals.length && (value === undefined || sameField(field, { [field]: value }, declared))) return\n\t\t\t\tconst fallback = dialect.defaults?.[field]\n\t\t\t\tif (fallback !== undefined && sameField(field, { [field]: value }, { [field]: fallback })) {\n\t\t\t\t\trows.push({\n\t\t\t\t\t\tpath: at(field),\n\t\t\t\t\t\taction: 'skip',\n\t\t\t\t\t\tdetail: `${config.dialect} fills this in by default, so it may not be the user's — set it in the golden set by hand if it is`,\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst row: ReconcileRow = {\n\t\t\t\t\tpath: at(field),\n\t\t\t\t\taction: 'import',\n\t\t\t\t\tdetail: declared\n\t\t\t\t\t\t? 'only the harness changed it — approve to take it into the golden set'\n\t\t\t\t\t\t: 'the golden set does not declare this server — approve each field to add it',\n\t\t\t\t\tvalue: value === undefined ? '(unset)' : `${field} = ${renderTomlInline(value)}`,\n\t\t\t\t}\n\t\t\t\trows.push(row)\n\t\t\t\toffers.push({ row, config, server, field, value, carried, adds: !declared })\n\t\t\t}\n\n\t\t\tif (!declared) {\n\t\t\t\tfor (const field of mcpFields) {\n\t\t\t\t\tif (!dialect.fields.has(field) || carried[field] === undefined) continue\n\t\t\t\t\tif (field === 'transport' && carried.transport === inferredTransport(carried)) continue\n\t\t\t\t\toffer(field, carried[field])\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const field of divergingFields(declared, carried, dialect.fields)) {\n\t\t\t\tconst direction = baseline.directionOf(config, server, field, declared, carried)\n\t\t\t\t// The golden side ahead is `mcp project`'s to write, not this command's.\n\t\t\t\tif (direction === 'golden') continue\n\t\t\t\tif (direction === 'target')\n\t\t\t\t\toffer(\n\t\t\t\t\t\tfield,\n\t\t\t\t\t\tfield === 'env' || field === 'headers' ? mapValue(declared[field], carried[field]) : carried[field],\n\t\t\t\t\t)\n\t\t\t\telse rows.push({ path: at(field), action: 'skip', detail: held[direction] })\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!accept.length) return { kind: 'planned', rows, written: false }\n\tconst approved = approve(offers, rows, accept)\n\tif (approved.kind === 'rejected') return approved\n\n\tlet source = goldenSource as string\n\tconst imported: Offer[] = []\n\tfor (const [server, group] of groupByServer(approved.offers)) {\n\t\tif (group[0]?.adds) {\n\t\t\tconst added: McpServer = Object.fromEntries(\n\t\t\t\tmcpFields.flatMap((field) => {\n\t\t\t\t\tconst offer = group.find((item) => item.field === field)\n\t\t\t\t\treturn offer ? [[field, offer.value]] : []\n\t\t\t\t}),\n\t\t\t)\n\t\t\tsource = land(source, appendInlineTomlTable(source, ['servers', server], added), server, added, group, imported)\n\t\t\tcontinue\n\t\t}\n\t\tfor (const offer of group) {\n\t\t\tconst current = parseGoldenSet(source) as { kind: 'servers'; servers: Map<string, McpServer> }\n\t\t\tconst expected = { ...current.servers.get(server), [offer.field]: offer.value }\n\t\t\tif (offer.value === undefined) delete expected[offer.field]\n\t\t\tconst edit = setTomlKey(source, ['servers', server], offer.field, offer.value)\n\t\t\tsource = land(source, edit.kind === 'edited' ? edit.text : undefined, server, expected, [offer], imported)\n\t\t}\n\t}\n\n\tif (source !== goldenSource) {\n\t\twriteFileSync(join(root, goldenSetPath), source)\n\t\twriteRecord(\n\t\t\troot,\n\t\t\trecord,\n\t\t\tbaseline,\n\t\t\timported,\n\t\t\tparseGoldenSet(source) as { kind: 'servers'; servers: Map<string, McpServer> },\n\t\t)\n\t}\n\treturn { kind: 'planned', rows, written: true }\n}\n\nfunction literalsIn(field: McpField, value: unknown): string[] {\n\tif (value === undefined) return []\n\tif (field === 'args') return nonSecretArgs(value as string[]).length === (value as string[]).length ? [] : ['args']\n\tif (field !== 'env' && field !== 'headers' && field !== 'url') return []\n\treturn credentialFields({ [field]: value })\n}\n\n/**\n * A map keeps its other names, and a refused name keeps what the golden set already says for it;\n * any other field holding a literal is refused whole.\n */\nfunction withoutLiterals(\n\tfield: McpField,\n\tvalue: unknown,\n\tliterals: string[],\n\tdeclared: McpServer | undefined,\n): unknown {\n\tif (!literals.length) return value\n\tif (field !== 'env' && field !== 'headers') return undefined\n\tconst kept = { ...(value as Record<string, string>) }\n\tfor (const literal of literals) {\n\t\tconst name = literal.slice(field.length + 1)\n\t\tconst golden = declared?.[field]?.[name]\n\t\tif (golden === undefined) delete kept[name]\n\t\telse kept[name] = golden\n\t}\n\treturn Object.keys(kept).length ? kept : undefined\n}\n\nfunction approve(\n\toffers: Offer[],\n\trows: ReconcileRow[],\n\taccept: readonly string[],\n): { kind: 'rejected'; reasons: string[] } | { kind: 'approved'; offers: Offer[] } {\n\tconst reasons: string[] = []\n\tconst chosen: Offer[] = []\n\tfor (const path of new Set(accept)) {\n\t\tconst offer = offers.find((item) => item.row.path === path)\n\t\tif (offer) chosen.push(offer)\n\t\telse {\n\t\t\tconst row = rows.find((item) => item.path === path)\n\t\t\treasons.push(\n\t\t\t\trow ? `${path} is ${row.action}, not importable: ${row.detail}` : `${path} names no importable field`,\n\t\t\t)\n\t\t}\n\t}\n\tfor (const [server, group] of groupByServer(chosen)) {\n\t\tfor (const field of new Set(group.map((offer) => offer.field))) {\n\t\t\tconst values = group.filter((offer) => offer.field === field)\n\t\t\tif (values.some((offer) => !sameField(field, { [field]: offer.value }, { [field]: values[0]?.value })))\n\t\t\t\treasons.push(\n\t\t\t\t\t`servers.${server}.${field} is approved from more than one target with different values — approve one`,\n\t\t\t\t)\n\t\t}\n\t\tif (group[0]?.adds && !group.some((offer) => offer.field === 'command' || offer.field === 'url'))\n\t\t\treasons.push(`servers.${server} would be added with nothing to run — approve its command or url too`)\n\t}\n\treturn reasons.length ? { kind: 'rejected', reasons } : { kind: 'approved', offers: chosen }\n}\n\nfunction groupByServer(offers: Offer[]): Map<string, Offer[]> {\n\tconst groups = new Map<string, Offer[]>()\n\tfor (const offer of offers) groups.set(offer.server, [...(groups.get(offer.server) ?? []), offer])\n\treturn groups\n}\n\n/**\n * Accepts the new text only when it reads back as the expected server with every other server\n * untouched; anything else is handed over as an `edit`, never written on trust.\n */\nfunction land(\n\tsource: string,\n\tnext: string | undefined,\n\tserver: string,\n\texpected: McpServer,\n\toffers: Offer[],\n\timported: Offer[],\n): string {\n\tconst before = parseGoldenSet(source) as { kind: 'servers'; servers: Map<string, McpServer> }\n\tconst after = next === undefined ? undefined : parseGoldenSet(next)\n\tconst holds =\n\t\tafter?.kind === 'servers' &&\n\t\t// A transport the text leaves unstated reads back inferred.\n\t\tmcpFields.every(\n\t\t\t(field) =>\n\t\t\t\t(field === 'transport' && expected.transport === undefined) ||\n\t\t\t\tsameField(field, after.servers.get(server), expected),\n\t\t) &&\n\t\t[...before.servers].every(\n\t\t\t([name, kept]) => name === server || JSON.stringify(after.servers.get(name)) === JSON.stringify(kept),\n\t\t)\n\tfor (const offer of offers) {\n\t\toffer.row.action = holds ? 'imported' : 'edit'\n\t\toffer.row.detail = holds\n\t\t\t? 'written into the golden set'\n\t\t\t: 'the golden set writes this server in a shape that cannot be edited byte-safely — apply the value by hand'\n\t}\n\tif (!holds) return source\n\timported.push(...offers)\n\treturn next as string\n}\n\n/**\n * The imported field now agrees on both sides. A server the record has no entry for is recorded\n * only when every other field's baseline is known, so the record never asserts an agreement no\n * baseline supports.\n */\nfunction writeRecord(\n\troot: string,\n\trecord: Map<string, Map<string, McpServer>>,\n\tbaseline: McpBaseline,\n\timported: Offer[],\n\tgolden: { servers: Map<string, McpServer> },\n): void {\n\tfor (const offer of imported) {\n\t\tconst servers = record.get(offer.config.path) ?? new Map<string, McpServer>()\n\t\tconst recorded = servers.get(offer.server)\n\t\tconst entry = recorded\n\t\t\t? { ...recorded, [offer.field]: offer.value }\n\t\t\t: baseEntry(offer, baseline, golden.servers.get(offer.server) as McpServer)\n\t\tif (!entry) continue\n\t\tif (offer.value === undefined) delete entry[offer.field]\n\t\tservers.set(offer.server, entry)\n\t\trecord.set(offer.config.path, servers)\n\t}\n\tconst absolute = join(root, projectionRecordPath)\n\tmkdirSync(dirname(absolute), { recursive: true })\n\twriteFileSync(absolute, formatProjectionRecord(record))\n}\n\nfunction baseEntry(offer: Offer, baseline: McpBaseline, golden: McpServer): McpServer | undefined {\n\tif (offer.adds) return { ...golden }\n\tconst entry: Record<string, unknown> = {}\n\tfor (const field of mcpDialects[offer.config.dialect].fields) {\n\t\tif (golden[field] === undefined) continue\n\t\tif (sameField(field, golden, offer.carried)) {\n\t\t\tentry[field] = golden[field]\n\t\t\tcontinue\n\t\t}\n\t\tconst base = baseline.baseFor(offer.config, offer.server, field)\n\t\tif (!base) return undefined\n\t\tentry[field] = base[field]\n\t}\n\treturn entry as McpServer\n}\n","import type { cli } from 'clibuilder'\nimport { command, exitCodes, z } from 'clibuilder'\nimport { parseFormat, writeResult } from '../command-output/command-output.ts'\nimport { GitBridgeState } from '../diagnose-bridges/git-bridge-state.ts'\nimport { projectionRecordPath } from '../diagnose-mcp/mcp-baseline.ts'\nimport { goldenSetPath } from '../diagnose-mcp/mcp-sources.ts'\nimport { type ReconcileRow, reconcileMcp } from './reconcile-mcp.ts'\n\nexport type ReconcileReport = {\n\tgolden: string\n\tmode: string\n\t/** Emitted even when empty, so a run that finds nothing states its zero. */\n\tfields: ReconcileRow[] | string\n\trecord: string\n}\n\nexport const mcpReconcileCommand: cli.Command = command({\n\tname: 'reconcile',\n\tdescription:\n\t\t'Import a harness-side MCP change into the golden set, one approved field at a time. A dry run unless --accept names a field.',\n\toptions: {\n\t\troot: {\n\t\t\tdescription: 'Repository or package directory. Defaults to the current directory.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\taccept: {\n\t\t\tdescription:\n\t\t\t\t'Approve one field by the path a dry run lists for it; repeat for each field. There is no approve-all.',\n\t\t\ttype: z.optional(z.array(z.string())),\n\t\t},\n\t\tformat: {\n\t\t\tdescription: 'Output format: toon (default), json, or text for a human-readable report.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'toon',\n\t\t},\n\t},\n\trun(args) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst root = args.root ?? process.cwd()\n\t\t\tconst accept = args.accept ?? []\n\t\t\tconst plan = reconcileMcp({ root, git: new GitBridgeState(root), accept })\n\t\t\tif (plan.kind === 'unreadable') {\n\t\t\t\t// Position only: the parser's message quotes the line, and that line may hold a credential.\n\t\t\t\tconst at = plan.position ? ` at line ${plan.position.line}, column ${plan.position.column}` : ''\n\t\t\t\tprocess.stderr.write(`error: ${goldenSetPath} does not parse${at}.\\n`)\n\t\t\t\treturn exitCodes.error\n\t\t\t}\n\t\t\tif (plan.kind === 'rejected') {\n\t\t\t\tprocess.stderr.write(`error: nothing written.\\n${plan.reasons.map((reason) => `- ${reason}\\n`).join('')}`)\n\t\t\t\treturn exitCodes.error\n\t\t\t}\n\t\t\tif (plan.kind === 'absent') {\n\t\t\t\twriteResult(\n\t\t\t\t\t{\n\t\t\t\t\t\tgolden: `0 servers — no golden set at ${goldenSetPath}`,\n\t\t\t\t\t\tmode: 'nothing to reconcile into',\n\t\t\t\t\t\tfields: '0 fields',\n\t\t\t\t\t\trecord: 'not written',\n\t\t\t\t\t} satisfies ReconcileReport,\n\t\t\t\t\tformat,\n\t\t\t\t)\n\t\t\t\treturn exitCodes.success\n\t\t\t}\n\t\t\tconst report: ReconcileReport = {\n\t\t\t\tgolden: goldenSetPath,\n\t\t\t\tmode: plan.written\n\t\t\t\t\t? 'written — only the fields named by --accept'\n\t\t\t\t\t: 'dry run — nothing written; re-run with --accept <path> for each approved field',\n\t\t\t\tfields: plan.rows.length ? plan.rows : '0 fields — no harness holds a change the golden set lacks',\n\t\t\t\trecord: plan.written ? projectionRecordPath : 'not written — dry run',\n\t\t\t}\n\t\t\twriteResult(report, format)\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'MCP reconcile failed.'}\\n`)\n\t\t\treturn exitCodes.error\n\t\t}\n\t},\n})\n","import { findNodeAtLocation, type Node, parseTree } from 'jsonc-parser'\nimport { stripJsonComments } from '../diagnose-bridges/json-with-comments.ts'\nimport type { ConfigEdit } from './config-edit.ts'\n\n/** The one indent unit a file already uses, so an inserted value reads like its neighbours. */\nfunction indentUnit(source: string): string {\n\tconst indented = /\\n([ \\t]+)\\S/.exec(source)\n\treturn indented ? (indented[1] as string) : ' '\n}\n\nfunction jsonAt(value: unknown, unit: string, depth: number): string {\n\treturn JSON.stringify(value, null, unit).replaceAll('\\n', `\\n${unit.repeat(depth)}`)\n}\n\nfunction objectAt(root: Node | undefined, path: string[]): Node | undefined {\n\tconst node = root && (path.length ? findNodeAtLocation(root, path) : root)\n\treturn node?.type === 'object' ? node : undefined\n}\n\n/**\n * Adds `name` to the object at `path`, or `undefined` when there is no object there or it already\n * holds `name`. `jsonc-parser`'s own `modify` reformats the properties beside the one it inserts,\n * so the text is spliced at the parse tree's offsets instead: every byte outside the insertion\n * survives, comments included.\n */\nexport function insertJsonProperty(source: string, path: string[], name: string, value: unknown): string | undefined {\n\tconst container = objectAt(parseTree(source), path)\n\tif (!container || findNodeAtLocation(container, [name])) return undefined\n\tconst depth = path.length + 1\n\tconst unit = indentUnit(source)\n\tconst property = `${unit.repeat(depth)}${JSON.stringify(name)}: ${jsonAt(value, unit, depth)}`\n\tconst last = container.children?.at(-1)\n\tif (last) {\n\t\tconst end = last.offset + last.length\n\t\treturn `${source.slice(0, end)},\\n${property}${source.slice(end)}`\n\t}\n\tconst open = container.offset + 1\n\tconst close = container.offset + container.length - 1\n\treturn `${source.slice(0, open)}\\n${property}\\n${unit.repeat(depth - 1)}${source.slice(close)}`\n}\n\n/** Replaces the value at `path`, keeping every byte outside it. A comment inside the value is refused. */\nexport function replaceJsonValue(source: string, path: string[], value: unknown): ConfigEdit {\n\tconst root = parseTree(source)\n\tconst node = root && findNodeAtLocation(root, path)\n\tif (!node) return { kind: 'refused', reason: 'absent' }\n\tconst end = node.offset + node.length\n\tconst text = source.slice(node.offset, end)\n\tif (stripJsonComments(text) !== text) return { kind: 'refused', reason: 'comment' }\n\treturn {\n\t\tkind: 'edited',\n\t\ttext: `${source.slice(0, node.offset)}${jsonAt(value, indentUnit(source), path.length)}${source.slice(end)}`,\n\t}\n}\n","import { insertJsonProperty, replaceJsonValue } from '../config-edit/jsonc-edit.ts'\nimport { appendTomlTable, renderTomlTable, replaceTomlTable } from '../config-edit/toml-edit.ts'\nimport type { McpConfig } from '../harness-registry/mcp-config.ts'\n\nexport type McpEntry = Record<string, unknown>\n\n/** A new file holding only the MCP key, in the format the target reads. */\nexport function createFile(config: McpConfig, name: string, entry: McpEntry): string {\n\treturn config.format === 'toml'\n\t\t? renderTomlTable([config.key, name], entry)\n\t\t: `${JSON.stringify({ [config.key]: { [name]: entry } }, null, 2)}\\n`\n}\n\n/**\n * Adds one server to an existing file without touching a byte of what is already there, or\n * `undefined` when the file's shape leaves no safe place to put it.\n */\nexport function appendServer(config: McpConfig, source: string, name: string, entry: McpEntry): string | undefined {\n\tif (config.format === 'toml') return appendTomlTable(source, [config.key, name], entry)\n\treturn (\n\t\tinsertJsonProperty(source, [config.key], name, entry) ??\n\t\tinsertJsonProperty(source, [], config.key, { [name]: entry })\n\t)\n}\n\n/**\n * Replaces one server's entry in place, keeping every byte outside it, or `undefined` when it cannot:\n * the entry holds a comment the replacement would drop, which is the user's and not this command's\n * to drop, or is written in a form the editor does not replace.\n */\nexport function replaceServer(config: McpConfig, source: string, name: string, entry: McpEntry): string | undefined {\n\tconst edit =\n\t\tconfig.format === 'toml'\n\t\t\t? replaceTomlTable(source, [config.key, name], entry)\n\t\t\t: replaceJsonValue(source, [config.key, name], entry)\n\treturn edit.kind === 'edited' ? edit.text : undefined\n}\n\n/** The entry as it would read in the target, for a person or a skill to apply by hand. */\nexport function renderEntry(config: McpConfig, name: string, entry: McpEntry): string {\n\treturn config.format === 'toml'\n\t\t? renderTomlTable([config.key, name], entry)\n\t\t: JSON.stringify({ [name]: entry }, null, 2)\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport type { GitBridgeState } from '../diagnose-bridges/git-bridge-state.ts'\nimport type { Position } from '../diagnose-bridges/locator.ts'\nimport {\n\tformatProjectionRecord,\n\tMcpBaseline,\n\ttype McpDirection,\n\tparseProjectionRecord,\n\tprojectionRecordPath,\n} from '../diagnose-mcp/mcp-baseline.ts'\nimport { divergingFields, type McpServer } from '../diagnose-mcp/mcp-model.ts'\nimport { credentialFields } from '../diagnose-mcp/mcp-secrets.ts'\nimport { goldenSetPath, mcpTargets, parseGoldenSet, parseTarget } from '../diagnose-mcp/mcp-sources.ts'\nimport type { McpConfig } from '../harness-registry/mcp-config.ts'\nimport { mcpDialects } from '../mcp-dialects/mcp-dialects.ts'\nimport { appendServer, createFile, type McpEntry, renderEntry, replaceServer } from './mcp-edit.ts'\n\n/**\n * `add` and `update` are what the command writes; `edit` is a change it will not make itself and\n * hands over as text; `skip` and `refuse` write nothing.\n */\nexport type ProjectionAction = 'add' | 'update' | 'edit' | 'skip' | 'refuse'\n\nexport type ProjectionRow = { target: string; server: string; action: ProjectionAction; detail: string }\n\n/**\n * Every row that changes a server, with the entry as it would read in the target — the after to\n * show beside the file as it stands, and for an `edit` the text to apply by hand.\n */\nexport type ProjectionEntry = { target: string; server: string; action: ProjectionAction; entry: string }\n\nexport type ProjectionPlan =\n\t| { kind: 'absent' }\n\t| { kind: 'unreadable'; position?: Position | undefined }\n\t| { kind: 'planned'; rows: ProjectionRow[]; entries: ProjectionEntry[]; written: boolean }\n\nexport type ProjectMcpOptions = {\n\troot: string\n\tgit: GitBridgeState\n\t/** Apply the plan and write the last-projected record; without it nothing on disk changes. */\n\twrite: boolean\n}\n\nfunction read(root: string, path: string): string | undefined {\n\tconst absolute = join(root, path)\n\treturn existsSync(absolute) ? readFileSync(absolute, 'utf8') : undefined\n}\n\nconst moved: Record<Exclude<McpDirection, 'golden'>, string> = {\n\ttarget: 'the target changed since the last projection — reconcile it into the golden set first',\n\tboth: 'both sides changed since the last projection — a three-way conflict for a person to settle',\n\tunknown: 'no baseline says which side changed — compare the two by hand',\n}\n\n/** The worst direction among the diverged fields: one field the target moved is enough to hold back. */\nfunction heldBack(directions: McpDirection[]): Exclude<McpDirection, 'golden'> | undefined {\n\treturn (['both', 'unknown', 'target'] as const).find((direction) => directions.includes(direction))\n}\n\ntype TargetPlan = {\n\tconfig: McpConfig\n\tsource: string | undefined\n\tservers: Map<string, McpServer>\n\t/** The file did not exist before this run; every server in it is part of creating it. */\n\tcreated: boolean\n\t/** Servers whose target copy agrees with the golden set once this plan is applied. */\n\tagreed: Map<string, McpServer>\n}\n\n/**\n * Projects the golden set into every enabled harness's MCP file. Only a server the golden set is\n * plainly ahead on is written — absent from the target, or changed on the golden side alone. A\n * target-side change is never overwritten: that is reconcile's, and needs a person.\n */\nexport function projectMcp({ root, git, write }: ProjectMcpOptions): ProjectionPlan {\n\tconst golden = parseGoldenSet(read(root, goldenSetPath))\n\tif (golden.kind !== 'servers') return golden\n\n\tconst record = parseProjectionRecord(read(root, projectionRecordPath))\n\tconst baseline = new McpBaseline({ git, record })\n\tconst rows: ProjectionRow[] = []\n\tconst entries: ProjectionEntry[] = []\n\tconst plans: TargetPlan[] = []\n\n\tfor (const config of mcpTargets(root)) {\n\t\tconst source = read(root, config.path)\n\t\tconst parsed = parseTarget(config, source)\n\t\tif (parsed.kind === 'unreadable') {\n\t\t\trows.push({ target: config.path, server: '', action: 'refuse', detail: 'the target does not parse' })\n\t\t\tcontinue\n\t\t}\n\t\tconst plan: TargetPlan = {\n\t\t\tconfig,\n\t\t\tsource,\n\t\t\tcreated: source === undefined,\n\t\t\tservers: parsed.kind === 'servers' ? parsed.servers : new Map(),\n\t\t\tagreed: new Map(),\n\t\t}\n\t\tplans.push(plan)\n\t\tconst dialect = mcpDialects[config.dialect]\n\n\t\tfor (const [name, declared] of golden.servers) {\n\t\t\tconst row = (action: ProjectionAction, detail: string) =>\n\t\t\t\trows.push({ target: config.path, server: name, action, detail })\n\t\t\tconst literal = credentialFields(declared)[0]\n\t\t\tif (literal) {\n\t\t\t\trow('refuse', `the golden set holds a literal credential at ${literal} — reference it as \\${VAR} first`)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst rendering = dialect.write(declared)\n\t\t\tif (rendering.kind === 'refused') {\n\t\t\t\trow('refuse', `${rendering.field}: ${rendering.reason}`)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst carried = plan.servers.get(name)\n\t\t\tif (!carried) {\n\t\t\t\tconst next =\n\t\t\t\t\tplan.source === undefined\n\t\t\t\t\t\t? createFile(config, name, rendering.entry)\n\t\t\t\t\t\t: appendServer(config, plan.source, name, rendering.entry)\n\t\t\t\tapply(\n\t\t\t\t\tplan,\n\t\t\t\t\tname,\n\t\t\t\t\tdeclared,\n\t\t\t\t\trendering.entry,\n\t\t\t\t\tnext,\n\t\t\t\t\tplan.created ? 'creates the file' : 'appends the server',\n\t\t\t\t\trow,\n\t\t\t\t\tentries,\n\t\t\t\t)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst diverged = divergingFields(declared, carried, dialect.fields)\n\t\t\tif (!diverged.length) {\n\t\t\t\tplan.agreed.set(name, declared)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst direction = heldBack(diverged.map((field) => baseline.directionOf(config, name, field, declared, carried)))\n\t\t\tif (direction) {\n\t\t\t\trow('skip', moved[direction])\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst next = replaceServer(config, plan.source as string, name, rendering.entry)\n\t\t\tapply(plan, name, declared, rendering.entry, next, `replaces ${diverged.join(', ')}`, row, entries)\n\t\t}\n\t}\n\n\tif (write) {\n\t\tfor (const plan of plans)\n\t\t\tif (plan.source !== undefined && plan.source !== read(root, plan.config.path)) writeTarget(root, plan)\n\t\twriteRecord(root, record, plans)\n\t}\n\treturn { kind: 'planned', rows, entries, written: write }\n}\n\n/**\n * Accepts the new text only when it reads back as the golden server with every other server\n * untouched; anything else becomes an `edit` for a person, rather than a write this command\n * cannot vouch for.\n */\nfunction apply(\n\tplan: TargetPlan,\n\tname: string,\n\tdeclared: McpServer,\n\tentry: McpEntry,\n\tnext: string | undefined,\n\tdetail: string,\n\trow: (action: ProjectionAction, detail: string) => void,\n\tentries: ProjectionEntry[],\n): void {\n\tconst adding = !plan.servers.has(name)\n\tconst accepted = next !== undefined && readsBack(plan, name, declared, next)\n\tconst action: ProjectionAction = accepted ? (adding ? 'add' : 'update') : 'edit'\n\tentries.push({ target: plan.config.path, server: name, action, entry: renderEntry(plan.config, name, entry) })\n\tif (!accepted) {\n\t\trow(\n\t\t\t'edit',\n\t\t\tadding\n\t\t\t\t? 'the file has no safe place to add it — apply the entry by hand'\n\t\t\t\t: 'an in-place change here is applied by hand',\n\t\t)\n\t\treturn\n\t}\n\tplan.source = next\n\tplan.servers = (parseTarget(plan.config, next) as { kind: 'servers'; servers: Map<string, McpServer> }).servers\n\tplan.agreed.set(name, declared)\n\trow(action, detail)\n}\n\nfunction readsBack(plan: TargetPlan, name: string, declared: McpServer, next: string): boolean {\n\tconst parsed = parseTarget(plan.config, next)\n\tif (parsed.kind !== 'servers') return false\n\tconst written = parsed.servers.get(name)\n\tconst fields = mcpDialects[plan.config.dialect].fields\n\tif (!written || divergingFields(declared, written, fields).length) return false\n\treturn [...plan.servers].every(([other, server]) => {\n\t\tif (other === name) return true\n\t\tconst kept = parsed.servers.get(other)\n\t\treturn kept !== undefined && JSON.stringify(kept) === JSON.stringify(server)\n\t})\n}\n\nfunction writeTarget(root: string, plan: TargetPlan): void {\n\tconst absolute = join(root, plan.config.path)\n\tmkdirSync(dirname(absolute), { recursive: true })\n\twriteFileSync(absolute, plan.source as string)\n}\n\n/** What each target last agreed on, kept per server so a server this run did not touch keeps its entry. */\nfunction writeRecord(root: string, record: Map<string, Map<string, McpServer>>, plans: TargetPlan[]): void {\n\tfor (const plan of plans) {\n\t\tconst servers = record.get(plan.config.path) ?? new Map<string, McpServer>()\n\t\tfor (const [name, server] of plan.agreed) servers.set(name, server)\n\t\tif (servers.size) record.set(plan.config.path, servers)\n\t}\n\tconst absolute = join(root, projectionRecordPath)\n\tmkdirSync(dirname(absolute), { recursive: true })\n\twriteFileSync(absolute, formatProjectionRecord(record))\n}\n","import type { cli } from 'clibuilder'\nimport { command, exitCodes, z } from 'clibuilder'\nimport { parseFormat, writeResult } from '../command-output/command-output.ts'\nimport { GitBridgeState } from '../diagnose-bridges/git-bridge-state.ts'\nimport { projectionRecordPath } from '../diagnose-mcp/mcp-baseline.ts'\nimport { goldenSetPath } from '../diagnose-mcp/mcp-sources.ts'\nimport { mcpReconcileCommand } from '../reconcile-mcp/reconcile.command.ts'\nimport { type ProjectionEntry, type ProjectionRow, projectMcp } from './project-mcp.ts'\n\nexport type ProjectionReport = {\n\tgolden: string\n\tmode: string\n\t/** Emitted even when empty, so a run that changes nothing states its zero. */\n\tactions: ProjectionRow[] | string\n\t/** Omitted when no row changes a server. */\n\tentries?: ProjectionEntry[]\n\trecord: string\n}\n\nexport const mcpProjectCommand: cli.Command = command({\n\tname: 'project',\n\tdescription:\n\t\t'Project the golden MCP server set into each enabled harness. A dry run unless --write; never overwrites a change made on the harness side.',\n\toptions: {\n\t\troot: {\n\t\t\tdescription: 'Repository or package directory. Defaults to the current directory.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\twrite: {\n\t\t\tdescription: 'Apply the plan and record what was projected. Without it nothing on disk changes.',\n\t\t\ttype: z.optional(z.boolean()),\n\t\t},\n\t\tformat: {\n\t\t\tdescription: 'Output format: toon (default), json, or text for a human-readable report.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'toon',\n\t\t},\n\t},\n\trun(args) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst root = args.root ?? process.cwd()\n\t\t\tconst write = args.write === true\n\t\t\tconst plan = projectMcp({ root, git: new GitBridgeState(root), write })\n\t\t\tif (plan.kind === 'unreadable') {\n\t\t\t\t// Position only: the parser's message quotes the line, and that line may hold a credential.\n\t\t\t\tconst at = plan.position ? ` at line ${plan.position.line}, column ${plan.position.column}` : ''\n\t\t\t\tprocess.stderr.write(`error: ${goldenSetPath} does not parse${at}.\\n`)\n\t\t\t\treturn exitCodes.error\n\t\t\t}\n\t\t\tif (plan.kind === 'absent') {\n\t\t\t\twriteResult(\n\t\t\t\t\t{\n\t\t\t\t\t\tgolden: `0 servers — no golden set at ${goldenSetPath}`,\n\t\t\t\t\t\tmode: 'nothing to project',\n\t\t\t\t\t\tactions: '0 changes',\n\t\t\t\t\t\trecord: 'not written',\n\t\t\t\t\t} satisfies ProjectionReport,\n\t\t\t\t\tformat,\n\t\t\t\t)\n\t\t\t\treturn exitCodes.success\n\t\t\t}\n\t\t\tconst report: ProjectionReport = {\n\t\t\t\tgolden: goldenSetPath,\n\t\t\t\tmode: write ? 'written' : 'dry run — nothing written; re-run with --write to apply',\n\t\t\t\tactions: plan.rows.length ? plan.rows : '0 changes — every enabled harness already carries the golden set',\n\t\t\t\t...(plan.entries.length ? { entries: plan.entries } : {}),\n\t\t\t\trecord: write ? projectionRecordPath : 'not written — dry run',\n\t\t\t}\n\t\t\twriteResult(report, format)\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'MCP projection failed.'}\\n`)\n\t\t\treturn exitCodes.error\n\t\t}\n\t},\n})\n\nexport const mcpCommand: cli.Command = command({\n\tname: 'mcp',\n\tdescription: 'Work with the golden MCP server set at .agents/buddy-agent-harness/mcp.toml.',\n\tcommands: [mcpProjectCommand, mcpReconcileCommand],\n})\n","import { readFileSync } from 'node:fs'\nimport { cli, exitCodes } from 'clibuilder'\nimport { depPluginsCommand } from './dep-plugins/dep-plugins.command.ts'\nimport { doctorCommand } from './diagnose-bridges/doctor.command.ts'\nimport { governanceCommand } from './governance-overrides/governance.command.ts'\nimport { initCommand } from './initialize-harnesses/init.command.ts'\nimport { mcpCommand } from './project-mcp/mcp.command.ts'\nimport { referenceCommand } from './references/reference.command.ts'\n\n/**\n * `../package.json` resolves from both `src/cli.ts` and the bundled `dist/cli.mjs` — one directory\n * under the package root — but not from a skill-script bundle, shipped deeper with no package tree\n * beside it; that build defines `__PACKAGE_VERSION__` as a literal instead. `typeof` is safe against\n * an identifier no other build declares — it reads `'undefined'` rather than throwing.\n */\ndeclare const __PACKAGE_VERSION__: string | undefined\nconst version =\n\ttypeof __PACKAGE_VERSION__ !== 'undefined'\n\t\t? __PACKAGE_VERSION__\n\t\t: (JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version as string)\n\n// A factory, not a module-level constant: `cli()` builds state, and state built at import time\n// would be shared by every later call in the process.\nfunction app() {\n\treturn cli({\n\t\tname: 'buddy-agent-harness',\n\t\tversion,\n\t\tdescription: 'Initialize agent harness skill compatibility in consumer repositories.',\n\t})\n\t\t.command(initCommand)\n\t\t.command(doctorCommand)\n\t\t.command(mcpCommand)\n\t\t.command(depPluginsCommand)\n\t\t.command(referenceCommand)\n\t\t.command(governanceCommand)\n}\n\n/**\n * The application boundary: argv in, exit code out — returned rather than written, so a caller that\n * is not the process (a skill launcher, a test) can act on it.\n */\nexport async function run(argv: string[]): Promise<number> {\n\ttry {\n\t\tconst code = await app().parse<number | undefined>(argv)\n\t\treturn typeof code === 'number' ? code : exitCodes.success\n\t} catch (error) {\n\t\t// stderr, not stdout — stdout carries TOON an agent parses; an error there would land\n\t\t// mid-parse.\n\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'Invalid command.'}\\n`)\n\t\treturn exitCodes.usage\n\t}\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { homedir, platform } from 'node:os'\nimport { basename, join, resolve } from 'node:path'\nimport { parseJsonWithComments } from '../diagnose-bridges/json-with-comments.ts'\nimport { type McpServer, type McpTransport, serverFrom } from '../diagnose-mcp/mcp-model.ts'\nimport { nonSecretArgs } from '../diagnose-mcp/mcp-secrets.ts'\nimport { parseTarget } from '../diagnose-mcp/mcp-sources.ts'\nimport { type HarnessName, type HarnessScopeName, harnessRegistry } from '../harness-registry/harness-registry.ts'\nimport type { McpConfig } from '../harness-registry/mcp-config.ts'\nimport { isRecord } from '../is-record/is-record.ts'\n\n/**\n * `local`: Claude Code's per-project entry inside `~/.claude.json`. `plugin`: a server an installed\n * Claude Code plugin ships, named on `McpServerEntry.plugin`.\n */\nexport type McpServerScope = HarnessScopeName | 'local' | 'plugin'\n\n/** Not wired into `doctor`: adding a harness here never changes what `doctor` reads. */\nfunction userScopeConfig(\n\tharness: HarnessName,\n\thome: string,\n\tenv: Readonly<Record<string, string | undefined>>,\n): { file: string; config: McpConfig } | undefined {\n\tswitch (harness) {\n\t\tcase 'claude-code':\n\t\t\treturn {\n\t\t\t\tfile: join(home, '.claude.json'),\n\t\t\t\tconfig: { path: '.claude.json', key: 'mcpServers', format: 'json', dialect: 'claude-code' },\n\t\t\t}\n\t\tcase 'cursor':\n\t\t\treturn {\n\t\t\t\tfile: join(home, '.cursor', 'mcp.json'),\n\t\t\t\tconfig: { path: '.cursor/mcp.json', key: 'mcpServers', format: 'json', dialect: 'cursor' },\n\t\t\t}\n\t\tcase 'codex':\n\t\t\treturn {\n\t\t\t\tfile: join(env['CODEX_HOME'] || join(home, '.codex'), 'config.toml'),\n\t\t\t\tconfig: { path: 'config.toml', key: 'mcp_servers', format: 'toml', dialect: 'codex' },\n\t\t\t}\n\t\tcase 'copilot-cli':\n\t\t\treturn {\n\t\t\t\tfile: join(env['COPILOT_HOME'] || join(home, '.copilot'), 'mcp-config.json'),\n\t\t\t\tconfig: { path: 'mcp-config.json', key: 'mcpServers', format: 'json', dialect: 'claude-code' },\n\t\t\t}\n\t\tcase 'gemini-cli':\n\t\t\treturn {\n\t\t\t\tfile: join(home, '.gemini', 'settings.json'),\n\t\t\t\tconfig: {\n\t\t\t\t\tpath: '.gemini/settings.json',\n\t\t\t\t\tkey: 'mcpServers',\n\t\t\t\t\tformat: 'json',\n\t\t\t\t\tdialect: 'gemini-cli',\n\t\t\t\t\tshared: true,\n\t\t\t\t},\n\t\t\t}\n\t\tdefault:\n\t\t\treturn undefined\n\t}\n}\n\nfunction read(file: string): string | undefined {\n\treturn existsSync(file) ? readFileSync(file, 'utf8') : undefined\n}\n\n/** A URL trimmed to its origin and path, dropping any query string a token could ride in on. */\nfunction safeUrl(value: string | undefined): string | undefined {\n\tif (!value) return undefined\n\ttry {\n\t\tconst url = new URL(value)\n\t\treturn `${url.origin}${url.pathname}`\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/** One configured MCP server, redacted of everything that could carry a credential. */\nexport type McpServerEntry = {\n\tharness: HarnessName\n\tscope: McpServerScope\n\t/** The absolute path of the config file this entry was read from. */\n\tconfigFile: string\n\t/** The name the server is declared under. */\n\tname: string\n\ttransport: McpTransport | undefined\n\t/** The command's basename, never its full path. */\n\tcommand: string | undefined\n\t/** `args`, with any credential-bearing `--flag=value` pair dropped. */\n\targs: readonly string[]\n\t/** The URL's origin and path, never its query string. */\n\turl: string | undefined\n\tenabled: boolean\n\t/** The plugin id this server came from, set only when `scope` is `'plugin'`. */\n\tplugin?: string\n}\n\nexport type ListMcpServersOptions = {\n\t/** The project directory to read project-scope configuration from. */\n\tprojectDir: string\n\t/** Overrides `os.homedir()`, for a test that must not touch the real one. */\n\thomeDir?: string\n\t/**\n\t * Overrides `process.env`, for a test — read only for `CODEX_HOME`, `COPILOT_HOME`, and\n\t * `XDG_CONFIG_HOME`.\n\t */\n\tenv?: Readonly<Record<string, string | undefined>>\n\t/** Overrides `os.platform()`, so the VS Code user directory is testable on every OS. */\n\tplatform?: NodeJS.Platform\n}\n\nfunction toEntry(\n\tharness: HarnessName,\n\tscope: McpServerScope,\n\tfile: string,\n\tname: string,\n\tserver: McpServer,\n\tplugin?: string,\n): McpServerEntry {\n\treturn {\n\t\tharness,\n\t\tscope,\n\t\tconfigFile: file,\n\t\tname,\n\t\ttransport: server.transport,\n\t\tcommand: server.command ? basename(server.command) : undefined,\n\t\targs: nonSecretArgs(server.args),\n\t\turl: safeUrl(server.url),\n\t\tenabled: server.enabled !== false,\n\t\t...(plugin ? { plugin } : {}),\n\t}\n}\n\nfunction entriesFrom(harness: HarnessName, scope: McpServerScope, file: string, config: McpConfig): McpServerEntry[] {\n\tconst parsed = parseTarget(config, read(file))\n\tif (parsed.kind !== 'servers') return []\n\treturn [...parsed.servers].map(([name, server]) => toEntry(harness, scope, file, name, server))\n}\n\n/**\n * Reshapes what `serverFrom` doesn't recognize: OpenCode's `command` array, Zed's `command` object,\n * and Windsurf's `serverUrl` alias for `url`.\n */\nfunction normalizeRawEntry(raw: Record<string, unknown>): Record<string, unknown> {\n\tconst command = raw['command']\n\tif (Array.isArray(command)) {\n\t\tconst [first, ...rest] = command as unknown[]\n\t\treturn { ...raw, command: first, args: raw['args'] ?? rest }\n\t}\n\tif (isRecord(command)) {\n\t\treturn { ...raw, command: command['path'], args: raw['args'] ?? command['args'] }\n\t}\n\tif (raw['url'] === undefined && typeof raw['serverUrl'] === 'string') {\n\t\treturn { ...raw, url: raw['serverUrl'] }\n\t}\n\treturn raw\n}\n\n/** Every server under `key` in an already-parsed JSON(C) document, normalized and converted. */\nfunction serversFromDocument(document: unknown, key: string): Map<string, McpServer> {\n\tconst table = isRecord(document) ? document[key] : undefined\n\tif (!isRecord(table)) return new Map()\n\treturn new Map(\n\t\tObject.entries(table)\n\t\t\t.filter((pair): pair is [string, Record<string, unknown>] => isRecord(pair[1]))\n\t\t\t.map(([name, entry]) => [name, serverFrom(normalizeRawEntry(entry))]),\n\t)\n}\n\nfunction entriesFromDocument(\n\tharness: HarnessName,\n\tscope: McpServerScope,\n\tfile: string,\n\tdocument: unknown,\n\tkey: string,\n\toptions: { plugin?: string; forceDisabled?: boolean } = {},\n): McpServerEntry[] {\n\treturn [...serversFromDocument(document, key)].map(([name, server]) => {\n\t\tconst entry = toEntry(harness, scope, file, name, server, options.plugin)\n\t\treturn options.forceDisabled ? { ...entry, enabled: false } : entry\n\t})\n}\n\n/**\n * Where VS Code keeps its user-scope settings, per platform — mirrors what VS Code itself\n * documents.\n */\nfunction vscodeUserDir(env: Readonly<Record<string, string | undefined>>, home: string, plat: NodeJS.Platform): string {\n\tif (plat === 'win32') return join(env['APPDATA'] || join(home, 'AppData', 'Roaming'), 'Code', 'User')\n\tif (plat === 'darwin') return join(home, 'Library', 'Application Support', 'Code', 'User')\n\treturn join(env['XDG_CONFIG_HOME'] || join(home, '.config'), 'Code', 'User')\n}\n\ntype ExtraSource = {\n\tharness: HarnessName\n\tscope: McpServerScope\n\tfile: string\n\tkey: string\n}\n\n// Sources with no registry entry. Windsurf's legacy path is read as `devin-desktop`, its new name\n// (E-WS-02).\nfunction extraSources(\n\tprojectDir: string,\n\thome: string,\n\tenv: Readonly<Record<string, string | undefined>>,\n\tplat: NodeJS.Platform,\n): ExtraSource[] {\n\tconst xdg = env['XDG_CONFIG_HOME'] || join(home, '.config')\n\treturn [\n\t\t{ harness: 'vscode', scope: 'user', file: join(vscodeUserDir(env, home, plat), 'mcp.json'), key: 'servers' },\n\t\t{ harness: 'vscode', scope: 'project', file: join(projectDir, '.vscode', 'mcp.json'), key: 'servers' },\n\t\t{\n\t\t\tharness: 'devin-desktop',\n\t\t\tscope: 'user',\n\t\t\tfile: join(home, '.codeium', 'windsurf', 'mcp_config.json'),\n\t\t\tkey: 'mcpServers',\n\t\t},\n\t\t{ harness: 'opencode', scope: 'user', file: join(xdg, 'opencode', 'opencode.json'), key: 'mcp' },\n\t\t{ harness: 'opencode', scope: 'project', file: join(projectDir, 'opencode.json'), key: 'mcp' },\n\t\t{ harness: 'zed', scope: 'user', file: join(xdg, 'zed', 'settings.json'), key: 'context_servers' },\n\t\t{ harness: 'zed', scope: 'project', file: join(projectDir, '.zed', 'settings.json'), key: 'context_servers' },\n\t]\n}\n\n/**\n * Claude Code's per-project servers: `~/.claude.json`'s `projects[projectDir].mcpServers`, distinct\n * from the file's top-level `mcpServers` (read as `'user'` scope above).\n */\nfunction claudeLocalEntries(home: string, projectDir: string): McpServerEntry[] {\n\tconst file = join(home, '.claude.json')\n\tconst text = read(file)\n\tif (text === undefined) return []\n\tconst document = parseJsonWithComments(text)\n\tconst projects = isRecord(document) ? document['projects'] : undefined\n\tconst project = isRecord(projects) ? projects[resolve(projectDir)] : undefined\n\tif (!isRecord(project)) return []\n\treturn entriesFromDocument('claude-code', 'local', file, project, 'mcpServers')\n}\n\n/** `enabledPlugins`, merged from global settings up through project-local settings, last write wins. */\nfunction enabledPlugins(home: string, projectDir: string): Record<string, boolean> {\n\tconst enabled: Record<string, boolean> = {}\n\tfor (const file of [\n\t\tjoin(home, '.claude', 'settings.json'),\n\t\tjoin(projectDir, '.claude', 'settings.json'),\n\t\tjoin(projectDir, '.claude', 'settings.local.json'),\n\t]) {\n\t\tconst text = read(file)\n\t\tif (text === undefined) continue\n\t\tconst document = parseJsonWithComments(text)\n\t\tconst table = isRecord(document) ? document['enabledPlugins'] : undefined\n\t\tif (!isRecord(table)) continue\n\t\tfor (const [id, value] of Object.entries(table)) if (typeof value === 'boolean') enabled[id] = value\n\t}\n\treturn enabled\n}\n\n/**\n * Servers shipped by installed Claude Code plugins, with `enabled` forced by the plugin's own\n * enabled state rather than the server's own field.\n */\nfunction pluginEntries(home: string, projectDir: string): McpServerEntry[] {\n\tconst file = join(home, '.claude', 'plugins', 'installed_plugins.json')\n\tconst text = read(file)\n\tif (text === undefined) return []\n\tconst document = parseJsonWithComments(text)\n\tconst installed = isRecord(document) ? document['plugins'] : undefined\n\tif (!isRecord(installed)) return []\n\n\tconst enabled = enabledPlugins(home, projectDir)\n\tconst absoluteProject = resolve(projectDir)\n\tconst entries: McpServerEntry[] = []\n\n\tfor (const [id, list] of Object.entries(installed)) {\n\t\tif (!Array.isArray(list)) continue\n\t\tfor (const install of list) {\n\t\t\tif (!isRecord(install)) continue\n\t\t\tconst projectPath = install['projectPath']\n\t\t\tif (typeof projectPath === 'string' && resolve(projectPath) !== absoluteProject) continue\n\t\t\tconst installPath = install['installPath']\n\t\t\tif (typeof installPath !== 'string') continue\n\n\t\t\tconst mcpFile = join(installPath, '.mcp.json')\n\t\t\tconst mcpText = read(mcpFile)\n\t\t\tif (mcpText === undefined) continue\n\t\t\tconst mcpDocument = parseJsonWithComments(mcpText)\n\t\t\tif (!isRecord(mcpDocument)) continue\n\n\t\t\t// A plugin's `.mcp.json` may list servers under `mcpServers`, or at the file's top level.\n\t\t\tconst document2 = isRecord(mcpDocument['mcpServers']) ? mcpDocument : { mcpServers: mcpDocument }\n\t\t\tentries.push(\n\t\t\t\t...entriesFromDocument('claude-code', 'plugin', mcpFile, document2, 'mcpServers', {\n\t\t\t\t\tplugin: id,\n\t\t\t\t\tforceDisabled: enabled[id] !== true,\n\t\t\t\t}),\n\t\t\t)\n\t\t}\n\t}\n\treturn entries\n}\n\n/**\n * Every configured MCP server across supported harnesses and scopes, redacted of credentials. A\n * missing or unparseable file contributes no entries silently — this reports an inventory, not a\n * diagnosis.\n */\nexport function listMcpServers(options: ListMcpServersOptions): McpServerEntry[] {\n\tconst home = options.homeDir ?? homedir()\n\tconst env = options.env ?? process.env\n\tconst plat = options.platform ?? platform()\n\tconst entries: McpServerEntry[] = []\n\n\tfor (const harness of harnessRegistry) {\n\t\tif (harness.deprecated) continue\n\n\t\tconst project = harness.project.mcpConfig\n\t\tif (project) entries.push(...entriesFrom(harness.name, 'project', join(options.projectDir, project.path), project))\n\n\t\tconst user = userScopeConfig(harness.name, home, env)\n\t\tif (user) entries.push(...entriesFrom(harness.name, 'user', user.file, user.config))\n\t}\n\n\tentries.push(...claudeLocalEntries(home, options.projectDir))\n\tentries.push(...pluginEntries(home, options.projectDir))\n\n\tfor (const source of extraSources(options.projectDir, home, env, plat)) {\n\t\tconst text = read(source.file)\n\t\tif (text === undefined) continue\n\t\tconst document = parseJsonWithComments(text)\n\t\tif (document === undefined) continue\n\t\tentries.push(...entriesFromDocument(source.harness, source.scope, source.file, document, source.key))\n\t}\n\n\treturn entries\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAgB,SAAS,OAAkD;CAC1E,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC3E;;;ACIA,MAAM,UAAmC;CAAC;CAAQ;CAAQ;AAAM;;AAGhE,SAAgB,YAAY,OAAyC;CACpE,IAAI,CAAC,QAAQ,SAAS,KAAqB,GAAG,MAAM,IAAI,MAAM,uCAAuC;CACrG,OAAO;AACR;;AAGA,SAAgB,YAAY,OAAe,QAA4B;CACtE,QAAQ,OAAO,MAAM,GAAG,aAAa,OAAO,MAAM,EAAE,GAAG;AACxD;;;;;AAMA,SAAgB,cAAc,SAAuB;CACpD,QAAQ,OAAO,MAAM,QAAQ,SAAS,IAAI,IAAI,UAAU,GAAG,QAAQ,GAA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AK,GAAG,oBAAoB,OAAO,SAAS,OAAO,OAAO,OAAO,MAAM,UAAU,OAAO,GAAG,CAAC;CACrG;CAEA,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["readJson","readJson","claudeCode","codex","parseToml","literalsIn","read","parse","namePattern","layersFor","isDirectory","layersFor","rootOption","stringifyToml","read","writeRecord","read","enabledPlugins"],"sources":["../src/is-record/is-record.ts","../src/command-output/command-output.ts","../src/dep-plugins/dep-plugins.ts","../src/dep-plugins/resolve.ts","../src/dep-plugins/generate.ts","../src/dep-plugins/harness-plugins.ts","../src/dep-plugins/reconcile.ts","../src/dep-plugins/dep-plugins.command.ts","../src/diagnose-bridges/directory-files.ts","../src/harness-registry/harness-registry.ts","../src/diagnose-bridges/locator.ts","../src/diagnose-bridges/doctor-guidance.ts","../src/diagnose-configuration/diagnose-configuration.ts","../src/diagnose-mcp/mcp-model.ts","../src/mcp-dialects/mcp-dialects.ts","../src/diagnose-bridges/json-with-comments.ts","../src/diagnose-mcp/mcp-sources.ts","../src/diagnose-mcp/mcp-baseline.ts","../src/diagnose-mcp/mcp-secrets.ts","../src/diagnose-mcp/diagnose-mcp.ts","../src/diagnose-nonstandard/diagnose-nonstandard.ts","../src/references/reference-document.ts","../src/references/resolve-reference.ts","../src/references/reference-catalog.ts","../src/governance-overrides/governance-overrides.ts","../src/references/harness-layers.ts","../src/references/reference-layers.ts","../src/skill-projection/skill-projection.ts","../src/diagnose-bridges/agents-files.ts","../src/diagnose-bridges/diagnose-instructions.ts","../src/diagnose-bridges/git-bridge-state.ts","../src/diagnose-bridges/diagnose-bridges.ts","../src/diagnose-bridges/doctor.command.ts","../src/governance-overrides/governance.command.ts","../src/references/reference.command.ts","../src/initialize-harnesses/initialize-harnesses.ts","../src/initialize-harnesses/init.command.ts","../src/config-edit/toml-edit.ts","../src/reconcile-mcp/reconcile-mcp.ts","../src/reconcile-mcp/reconcile.command.ts","../src/config-edit/jsonc-edit.ts","../src/project-mcp/mcp-edit.ts","../src/project-mcp/project-mcp.ts","../src/project-mcp/mcp.command.ts","../src/cli.ts","../src/mcp-inventory/mcp-inventory.ts"],"sourcesContent":["export function isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n","import { sep } from 'node:path'\nimport { encode } from '@toon-format/toon'\nimport { isRecord } from '../is-record/is-record.ts'\n\nexport type OutputFormat = 'json' | 'toon' | 'text'\n\nconst formats: readonly OutputFormat[] = ['toon', 'json', 'text']\n\n/** Rejects anything but the supported formats so an unknown value never falls back silently. */\nexport function parseFormat(value: string | undefined): OutputFormat {\n\tif (!formats.includes(value as OutputFormat)) throw new Error('--format must be toon, json, or text.')\n\treturn value as OutputFormat\n}\n\n/** The single stdout boundary: internal logic stays on plain objects, encoding happens here. */\nexport function writeResult(value: object, format: OutputFormat): void {\n\tprocess.stdout.write(`${encodeResult(value, format)}\\n`)\n}\n\n/**\n * Writes a document exactly as read, bypassing the encoders — a Markdown body run through TOON or\n * the text renderer comes back as one escaped line. A command writes one or the other, never both.\n */\nexport function writeDocument(content: string): void {\n\tprocess.stdout.write(content.endsWith('\\n') ? content : `${content}\\n`)\n}\n\nfunction encodeResult(value: object, format: OutputFormat): string {\n\tif (format === 'json') return JSON.stringify(value)\n\treturn format === 'text' ? renderText(value) : encode(value)\n}\n\nfunction cell(value: unknown): string {\n\treturn value === undefined ? '' : String(value)\n}\n\nfunction table(rows: Record<string, unknown>[]): string[] {\n\tconst columns = [...new Set(rows.flatMap((row) => Object.keys(row)))]\n\tconst widths = columns.map((column) => Math.max(column.length, ...rows.map((row) => cell(row[column]).length)))\n\tconst line = (values: string[]) =>\n\t\t` ${values.map((value, index) => value.padEnd(widths[index] as number)).join(' ')}`.trimEnd()\n\treturn [line(columns), ...rows.map((row) => line(columns.map((column) => cell(row[column]))))]\n}\n\n/** Renders for a person, not an agent — TOON stays the default since that's what an agent parses. */\nexport function renderText(value: object): string {\n\tconst blocks = Object.entries(value).map(([key, item]) => {\n\t\tif (!Array.isArray(item)) return [`${key}: ${isRecord(item) ? JSON.stringify(item) : String(item)}`]\n\t\tif (!item.length) return [`${key}: (none)`]\n\t\tconst body = item.every(isRecord) ? table(item) : item.map((entry) => ` - ${String(entry)}`)\n\t\treturn [`${key}:`, ...body]\n\t})\n\n\t// Blank line between blocks so a following scalar doesn't read as another row of the table\n\t// above it.\n\treturn blocks\n\t\t.flatMap((block, index) => {\n\t\t\tconst previous = blocks[index - 1]\n\t\t\treturn previous && (previous.length > 1 || block.length > 1) ? ['', ...block] : block\n\t\t})\n\t\t.join('\\n')\n}\n\n/**\n * AXI §10: collapses the home directory to `~` so a path in a report is portable to another\n * machine.\n */\nexport function collapseHome(home: string, path: string): string {\n\treturn home && path.startsWith(home + sep) ? `~${path.slice(home.length)}` : path\n}\n\nexport function displayBinPath(home: string, executable: string | undefined): string {\n\treturn executable ? collapseHome(home, executable) : 'buddy-agent-harness'\n}\n","/** Pure. Resolution against `node_modules` lives in `resolve.ts`. */\n\nexport type DepPlugin = {\n\tpackage: string\n\t/** The manifest's own name; may differ from `package`. */\n\tplugin: string\n\t/** The version installed, not the manifest's declared range. */\n\tversion: string\n\tdescription?: string\n}\n\n/** `npm`, not `path`: a path source must sit at the repository root, which this catalog does not. */\nexport type NpmSource = {\n\tsource: 'npm'\n\tpackage: string\n\tversion: string\n}\n\nexport type CatalogEntry = {\n\tname: string\n\tsource: NpmSource\n\tdescription?: string\n}\n\n/** `owner` must be an object; a bare string is a schema error, not an accepted shorthand. */\nexport type Catalog = {\n\tname: string\n\towner: { name: string }\n\tdescription: string\n\tplugins: CatalogEntry[]\n}\n\n/** Generic marketplace names: a second registration under one of these replaces the first, silently. */\nconst GENERIC_NAMES = new Set(['deps', 'dependencies', 'local', 'plugins', 'marketplace', 'plugin', 'default'])\n\nexport function isGenericName(name: string): boolean {\n\treturn GENERIC_NAMES.has(name.toLowerCase())\n}\n\n/**\n * Folds a scope into the name (`@acme/web` → `acme-web`) rather than dropping it — the unscoped\n * part collides more often.\n */\nexport function marketplaceName(packageName: string): string {\n\tconst folded = packageName.replace(/^@/, '').replace(/\\//g, '-')\n\tconst cleaned = folded\n\t\t.replace(/[^a-zA-Z0-9-_.]/g, '-')\n\t\t.replace(/-+/g, '-')\n\t\t.replace(/^-|-$/g, '')\n\treturn cleaned || 'agent-plugins'\n}\n\n/**\n * Includes `devDependencies` — a plugin can supply a project's testing or release workflow.\n * Transitive dependencies are excluded; see `resolve.ts`.\n */\nexport function declaredDependencies(manifest: unknown): string[] {\n\tif (!manifest || typeof manifest !== 'object') return []\n\tconst record = manifest as Record<string, unknown>\n\tconst names = new Set<string>()\n\tfor (const field of ['dependencies', 'devDependencies']) {\n\t\tconst group = record[field]\n\t\tif (!group || typeof group !== 'object') continue\n\t\tfor (const name of Object.keys(group as Record<string, unknown>)) names.add(name)\n\t}\n\treturn [...names].sort()\n}\n\nexport type BuildCatalogOptions = {\n\tname: string\n\towner: string\n\tplugins: readonly DepPlugin[]\n}\n\n/**\n * Derived in full every run, never merged with what's on disk. Entries are sorted so unchanged\n * inputs serialize identically, which `--check` relies on.\n */\nexport function buildCatalog({ name, owner, plugins }: BuildCatalogOptions): Catalog {\n\tconst entries = [...plugins]\n\t\t.sort((a, b) => a.plugin.localeCompare(b.plugin))\n\t\t.map(({ plugin, package: pkg, version, description }): CatalogEntry => {\n\t\t\tconst source: NpmSource = { source: 'npm', package: pkg, version }\n\t\t\treturn description ? { name: plugin, source, description } : { name: plugin, source }\n\t\t})\n\n\treturn {\n\t\tname,\n\t\towner: { name: owner },\n\t\tdescription: 'Plugins provided by this repository’s dependencies. Generated — do not edit.',\n\t\tplugins: entries,\n\t}\n}\n\n/** Includes the trailing newline. */\nexport function serializeCatalog(catalog: Catalog): string {\n\treturn `${JSON.stringify(catalog, null, '\\t')}\\n`\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { dirname, join } from 'node:path'\nimport type { DepPlugin } from './dep-plugins.ts'\n\nexport type SkipReason = 'unresolved' | 'no-manifest' | 'unnamed'\n\nexport type ResolveOutcome = { ok: true; plugin: DepPlugin } | { ok: false; package: string; reason: SkipReason }\n\nfunction readJson(path: string): unknown {\n\ttry {\n\t\treturn JSON.parse(readFileSync(path, 'utf8'))\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nfunction ancestorCandidates(startDir: string, pkg: string): string[] {\n\tconst segments = pkg.split('/')\n\tconst candidates: string[] = []\n\tlet dir = startDir\n\tfor (;;) {\n\t\tcandidates.push(join(dir, 'node_modules', ...segments))\n\t\tconst parent = dirname(dir)\n\t\tif (parent === dir) break\n\t\tdir = parent\n\t}\n\treturn candidates\n}\n\n/**\n * Anchored at the declaring manifest (required for pnpm's isolation), then falls back to a\n * `node_modules` walk — an `exports` map without a `./package.json` entry blocks the first.\n */\nexport function packageDir(pkg: string, fromManifest: string): string | undefined {\n\ttry {\n\t\tconst require = createRequire(fromManifest)\n\t\treturn dirname(require.resolve(`${pkg}/package.json`))\n\t} catch {}\n\tfor (const candidate of ancestorCandidates(dirname(fromManifest), pkg)) {\n\t\tif (existsSync(join(candidate, 'package.json'))) return candidate\n\t}\n\treturn undefined\n}\n\n/** A manifest lives at the package root — the Agent Plugins Specification's pinned location. */\nexport function readDepPlugin(pkg: string, fromManifest: string): ResolveOutcome {\n\tconst dir = packageDir(pkg, fromManifest)\n\tif (!dir) return { ok: false, package: pkg, reason: 'unresolved' }\n\n\tconst manifest = readJson(join(dir, 'plugin.json'))\n\tif (!manifest || typeof manifest !== 'object') return { ok: false, package: pkg, reason: 'no-manifest' }\n\n\tconst record = manifest as Record<string, unknown>\n\tconst name = typeof record['name'] === 'string' ? record['name'] : undefined\n\tif (!name) return { ok: false, package: pkg, reason: 'unnamed' }\n\n\t// The installed version, not the manifest's declared range — npm installs by this number.\n\tconst installed = readJson(join(dir, 'package.json')) as { version?: unknown } | undefined\n\tconst version = typeof installed?.version === 'string' ? installed.version : undefined\n\tif (!version) return { ok: false, package: pkg, reason: 'no-manifest' }\n\n\tconst description = typeof record['description'] === 'string' ? record['description'] : undefined\n\treturn {\n\t\tok: true,\n\t\tplugin: description\n\t\t\t? { package: pkg, plugin: name, version, description }\n\t\t\t: { package: pkg, plugin: name, version },\n\t}\n}\n\n/**\n * True under Yarn PnP, where packages live in zip archives rather than directories — nothing here\n * has an installable directory.\n */\nexport function isPnp(): boolean {\n\treturn Boolean((process.versions as Record<string, string | undefined>)['pnp'])\n}\n","import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport {\n\tbuildCatalog,\n\ttype Catalog,\n\ttype DepPlugin,\n\tdeclaredDependencies,\n\tisGenericName,\n\tmarketplaceName,\n\tserializeCatalog,\n} from './dep-plugins.ts'\nimport { isPnp, readDepPlugin, type SkipReason } from './resolve.ts'\n\n/**\n * Not the repository root's `.claude-plugin/` — that's the repo's own published catalog; merging\n * would leak dependency plugins into it.\n */\nexport const CATALOG_DIR: string = join('.agents', 'buddy-agent-harness')\nexport const CATALOG_PATH: string = join(CATALOG_DIR, '.claude-plugin', 'marketplace.json')\n\nexport type Skipped = { package: string; reason: SkipReason }\n\nexport type DerivedCatalog = {\n\tcatalog: Catalog\n\tplugins: DepPlugin[]\n\t/** Only the dependencies that failed to resolve at all; a dependency with no plugin is not news. */\n\tunresolved: Skipped[]\n\tgenericName: boolean\n\t/** True under Yarn PnP: no dependency has an installable directory. */\n\tpnp: boolean\n}\n\nfunction readManifest(path: string): Record<string, unknown> {\n\treturn JSON.parse(readFileSync(path, 'utf8')) as Record<string, unknown>\n}\n\nexport function deriveCatalog(root: string): DerivedCatalog {\n\tconst manifestPath = join(root, 'package.json')\n\tconst manifest = readManifest(manifestPath)\n\n\tconst plugins: DepPlugin[] = []\n\tconst unresolved: Skipped[] = []\n\tfor (const pkg of declaredDependencies(manifest)) {\n\t\tconst outcome = readDepPlugin(pkg, manifestPath)\n\t\tif (outcome.ok) plugins.push(outcome.plugin)\n\t\telse if (outcome.reason === 'unresolved') unresolved.push({ package: pkg, reason: outcome.reason })\n\t}\n\n\tconst owner = typeof manifest['name'] === 'string' ? manifest['name'] : 'unknown'\n\tconst name = marketplaceName(owner)\n\n\treturn {\n\t\tcatalog: buildCatalog({ name, owner, plugins }),\n\t\tplugins,\n\t\tunresolved,\n\t\tgenericName: isGenericName(name),\n\t\tpnp: isPnp(),\n\t}\n}\n\nexport type WriteOutcome = 'created' | 'updated' | 'unchanged'\n\n/**\n * Compares serialized bytes, not parsed values — that's what makes `--check` a comparison rather\n * than an interpretation.\n */\nexport function catalogStatus(root: string, catalog: Catalog): WriteOutcome {\n\tlet current: string | undefined\n\ttry {\n\t\tcurrent = readFileSync(join(root, CATALOG_PATH), 'utf8')\n\t} catch {\n\t\tcurrent = undefined\n\t}\n\tif (current === serializeCatalog(catalog)) return 'unchanged'\n\treturn current === undefined ? 'created' : 'updated'\n}\n\n/** A write that would change nothing writes nothing. */\nexport function writeCatalog(root: string, catalog: Catalog): WriteOutcome {\n\tconst outcome = catalogStatus(root, catalog)\n\tif (outcome === 'unchanged') return outcome\n\n\tconst path = join(root, CATALOG_PATH)\n\tmkdirSync(dirname(path), { recursive: true })\n\twriteFileSync(path, serializeCatalog(catalog))\n\treturn outcome\n}\n","// E-* IDs below: .research/agentic-configuration-standards/evidence.md\n\nimport { existsSync, readdirSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nexport type PluginRuntimeName = 'claude-code' | 'codex'\n\nexport type InstalledPlugin = {\n\t/** `<plugin>@<marketplace>` */\n\tid: string\n\tversion: string\n\tscope: string\n\tprojectPath?: string\n}\n\nexport type RegisteredMarketplace = { name: string; path: string }\n\n/** Read, never written: installing is the runtime's own job, done through its own CLI. */\nexport type HarnessPluginState = {\n\tinstalled: InstalledPlugin[]\n\tmarketplaces: RegisteredMarketplace[]\n}\n\nexport type PluginRuntime = {\n\tname: PluginRuntimeName\n\tinstalledOnMachine(home: string, env?: NodeJS.ProcessEnv): boolean\n\tstate(home: string, env?: NodeJS.ProcessEnv): HarnessPluginState\n\tregister(catalogDir: string): string\n\tinstall(id: string): string\n\tupdate(id: string): string\n\tuninstall(id: string): string\n\t/** Empty where a runtime re-reads the catalog on install and needs no separate refresh. */\n\trefreshMarketplace(marketplace: string): string\n\t/** False where one install serves every repository on the machine. */\n\tscoped: boolean\n}\n\n// E-COPILOT-03\nexport const COPILOT_LIMITATION =\n\t'Copilot CLI rejects an npm marketplace source, so it cannot install from this catalog. It needs a path-sourced catalog, which cannot reach node_modules from a subdirectory.'\n\nfunction readJson(path: string): unknown {\n\ttry {\n\t\treturn JSON.parse(readFileSync(path, 'utf8'))\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nfunction directories(path: string): string[] {\n\ttry {\n\t\treturn readdirSync(path, { withFileTypes: true })\n\t\t\t.filter((entry) => entry.isDirectory())\n\t\t\t.map((entry) => entry.name)\n\t} catch {\n\t\treturn []\n\t}\n}\n\n// ── Claude Code ──\n\nexport function claudeConfigDir(home: string, env: NodeJS.ProcessEnv = process.env): string {\n\treturn env['CLAUDE_CONFIG_DIR'] || join(home, '.claude')\n}\n\n// E-CC-17: one array per plugin id, an element per scope and project.\nexport function readClaudeState(configDir: string): HarnessPluginState {\n\tconst installedFile = readJson(join(configDir, 'plugins', 'installed_plugins.json')) as\n\t\t| { plugins?: Record<string, unknown> }\n\t\t| undefined\n\tconst installed: InstalledPlugin[] = []\n\tfor (const [id, entries] of Object.entries(installedFile?.plugins ?? {})) {\n\t\tif (!Array.isArray(entries)) continue\n\t\tfor (const entry of entries) {\n\t\t\tif (!entry || typeof entry !== 'object') continue\n\t\t\tconst record = entry as Record<string, unknown>\n\t\t\tconst version = typeof record['version'] === 'string' ? record['version'] : undefined\n\t\t\tconst scope = typeof record['scope'] === 'string' ? record['scope'] : undefined\n\t\t\tif (!version || !scope) continue\n\t\t\tconst projectPath = typeof record['projectPath'] === 'string' ? record['projectPath'] : undefined\n\t\t\tinstalled.push(projectPath ? { id, version, scope, projectPath } : { id, version, scope })\n\t\t}\n\t}\n\n\tconst knownFile = readJson(join(configDir, 'plugins', 'known_marketplaces.json')) as\n\t\t| Record<string, { source?: { path?: unknown } }>\n\t\t| undefined\n\tconst marketplaces: RegisteredMarketplace[] = []\n\tfor (const [name, value] of Object.entries(knownFile ?? {})) {\n\t\tmarketplaces.push({ name, path: typeof value?.source?.path === 'string' ? value.source.path : '' })\n\t}\n\n\treturn { installed, marketplaces }\n}\n\nexport const claudeCode: PluginRuntime = {\n\tname: 'claude-code',\n\tscoped: true,\n\tinstalledOnMachine: (home, env = process.env) => existsSync(claudeConfigDir(home, env)),\n\tstate: (home, env = process.env) => readClaudeState(claudeConfigDir(home, env)),\n\tregister: (catalogDir) => `claude plugin marketplace add ./${catalogDir} --scope project`,\n\tinstall: (id) => `claude plugin install ${id} --scope project`,\n\t// Not `install`, a silent no-op (E-CC-15); `--scope project` is required on every verb (E-CC-16).\n\tupdate: (id) => `claude plugin update ${id} --scope project`,\n\tuninstall: (id) => `claude plugin uninstall ${id} --scope project`,\n\trefreshMarketplace: (marketplace) => `claude plugin marketplace update ${marketplace}`,\n}\n\n// ── Codex ──\n\nexport function codexHome(home: string, env: NodeJS.ProcessEnv = process.env): string {\n\treturn env['CODEX_HOME'] || join(home, '.codex')\n}\n\n// E-CODEX-04: the version is only in the cache path. The TOML scan is deliberately narrow: a misread\n// only suggests re-registering, which is harmless to re-run.\nexport function readCodexState(home: string): HarnessPluginState {\n\tconst cacheRoot = join(home, 'plugins', 'cache')\n\tconst installed: InstalledPlugin[] = []\n\tfor (const marketplace of directories(cacheRoot)) {\n\t\tfor (const plugin of directories(join(cacheRoot, marketplace))) {\n\t\t\tfor (const version of directories(join(cacheRoot, marketplace, plugin))) {\n\t\t\t\tinstalled.push({ id: `${plugin}@${marketplace}`, version, scope: 'user' })\n\t\t\t}\n\t\t}\n\t}\n\n\tconst marketplaces: RegisteredMarketplace[] = []\n\tlet config = ''\n\ttry {\n\t\tconfig = readFileSync(join(home, 'config.toml'), 'utf8')\n\t} catch {\n\t\tconfig = ''\n\t}\n\tlet current: RegisteredMarketplace | undefined\n\tfor (const line of config.split('\\n')) {\n\t\tconst header = /^\\s*\\[marketplaces\\.(?:\"([^\"]+)\"|([^\\]]+))\\]\\s*$/.exec(line)\n\t\tif (header) {\n\t\t\tcurrent = { name: (header[1] ?? header[2]) as string, path: '' }\n\t\t\tmarketplaces.push(current)\n\t\t\tcontinue\n\t\t}\n\t\tif (/^\\s*\\[/.test(line)) {\n\t\t\tcurrent = undefined\n\t\t\tcontinue\n\t\t}\n\t\tconst source = current ? /^\\s*source\\s*=\\s*\"([^\"]*)\"\\s*$/.exec(line) : undefined\n\t\tif (source?.[1] && current) current.path = source[1]\n\t}\n\n\treturn { installed, marketplaces }\n}\n\nexport const codex: PluginRuntime = {\n\tname: 'codex',\n\t// E-CODEX-03: unscoped, so only the derived marketplace name keeps two repositories apart.\n\tscoped: false,\n\tinstalledOnMachine: (home, env = process.env) => existsSync(codexHome(home, env)),\n\tstate: (home, env = process.env) => readCodexState(codexHome(home, env)),\n\tregister: (catalogDir) => `codex plugin marketplace add ./${catalogDir}`,\n\tinstall: (id) => `codex plugin add ${id}`,\n\t// E-CODEX-03: no update verb; `add` replaces the cached copy.\n\tupdate: (id) => `codex plugin add ${id}`,\n\tuninstall: (id) => `codex plugin remove ${id}`,\n\t// E-CODEX-03: `add` already re-reads a local catalog.\n\trefreshMarketplace: () => '',\n}\n\n// Copilot CLI (E-COPILOT-03) and Cursor (E-CUR-04) have no CLI this can drive.\nexport const runtimes: readonly PluginRuntime[] = [claudeCode, codex]\n","/** Pure. Reading harness state lives in `harness-plugins.ts`. */\n\nimport type { Catalog } from './dep-plugins.ts'\nimport type { InstalledPlugin, RegisteredMarketplace } from './harness-plugins.ts'\n\nexport type ActionKind = 'register' | 'install' | 'update' | 'uninstall'\n\nexport type Action = {\n\tkind: ActionKind\n\t/** `<plugin>@<marketplace>`, or the marketplace name for `register`. */\n\tsubject: string\n\tdetail: string\n}\n\nexport type Reconciliation = {\n\tactions: Action[]\n\t/**\n\t * Set when a marketplace of this name is registered against a different directory — the harness\n\t * gives no error for this on its own.\n\t */\n\tcollision?: string\n\tunregistered: boolean\n}\n\nexport type ReconcileOptions = {\n\tcatalog: Catalog\n\t/** Where the catalog lives, relative to the repository root. */\n\tcatalogDir: string\n\t/** Absolute repository root, used to keep another project's installs out of the comparison. */\n\troot: string\n\tinstalled: readonly InstalledPlugin[]\n\tmarketplaces: readonly RegisteredMarketplace[]\n\t/**\n\t * False for a runtime with no per-repo scope (Codex): every install under this marketplace\n\t * counts as this repository's, since nothing else distinguishes them.\n\t */\n\tscoped?: boolean\n}\n\n/**\n * Excludes a user-scoped install on a scoped runtime — it's shared machine-wide, so it can't\n * satisfy this repository's catalog alone.\n */\nfunction ours(\n\tinstalled: readonly InstalledPlugin[],\n\tmarketplace: string,\n\troot: string,\n\tscoped: boolean,\n): InstalledPlugin[] {\n\tconst suffix = `@${marketplace}`\n\treturn installed.filter((entry) => entry.id.endsWith(suffix) && (!scoped || entry.projectPath === root))\n}\n\nexport function reconcile({\n\tcatalog,\n\tcatalogDir,\n\troot,\n\tinstalled,\n\tmarketplaces,\n\tscoped = true,\n}: ReconcileOptions): Reconciliation {\n\tconst registration = marketplaces.find((entry) => entry.name === catalog.name)\n\tconst actions: Action[] = []\n\n\t// Reported, not repaired: re-registering would just steal the name from whoever holds it.\n\tconst expected = catalogDir.split(/[\\\\/]/).filter(Boolean)\n\tconst pointsHere = registration ? expected.every((segment) => registration.path.includes(segment)) : false\n\tconst collision = registration && !pointsHere ? registration.path : undefined\n\n\tif (!registration) {\n\t\tactions.push({\n\t\t\tkind: 'register',\n\t\t\tsubject: catalog.name,\n\t\t\tdetail: 'marketplace is not registered with this harness',\n\t\t})\n\t}\n\n\tconst mine = ours(installed, catalog.name, root, scoped)\n\tconst byId = new Map(mine.map((entry) => [entry.id, entry]))\n\n\tfor (const entry of catalog.plugins) {\n\t\tconst id = `${entry.name}@${catalog.name}`\n\t\tconst current = byId.get(id)\n\t\tif (!current) {\n\t\t\tactions.push({ kind: 'install', subject: id, detail: `not installed; catalog pins ${entry.source.version}` })\n\t\t\tcontinue\n\t\t}\n\t\tif (current.version !== entry.source.version) {\n\t\t\tactions.push({\n\t\t\t\tkind: 'update',\n\t\t\t\tsubject: id,\n\t\t\t\tdetail: `installed ${current.version}, catalog pins ${entry.source.version}`,\n\t\t\t})\n\t\t}\n\t}\n\n\t// Nothing else removes these — the harness leaves a plugin dropped from the catalog installed\n\t// and failing to load.\n\tconst wanted = new Set(catalog.plugins.map((entry) => `${entry.name}@${catalog.name}`))\n\tfor (const entry of mine) {\n\t\tif (!wanted.has(entry.id)) {\n\t\t\tactions.push({\n\t\t\t\tkind: 'uninstall',\n\t\t\t\tsubject: entry.id,\n\t\t\t\tdetail: 'installed but no longer in the catalog; it will report a load failure until removed',\n\t\t\t})\n\t\t}\n\t}\n\n\treturn {\n\t\tactions,\n\t\t...(collision ? { collision } : {}),\n\t\tunregistered: !registration,\n\t}\n}\n","import { homedir } from 'node:os'\nimport { resolve } from 'node:path'\nimport type { cli } from 'clibuilder'\nimport { command, exitCodes, z } from 'clibuilder'\nimport { parseFormat, writeResult } from '../command-output/command-output.ts'\nimport { CATALOG_DIR, CATALOG_PATH, catalogStatus, deriveCatalog, type WriteOutcome, writeCatalog } from './generate.ts'\nimport { COPILOT_LIMITATION, type PluginRuntime, runtimes } from './harness-plugins.ts'\nimport { type Action, reconcile } from './reconcile.ts'\n\nexport type DepPluginsReport = {\n\tcatalog: string\n\tmarketplace: string\n\toutcome: WriteOutcome | 'would-change' | 'current'\n\t/** Emitted even when empty, so a healthy run states its zero explicitly. */\n\tplugins: { name: string; package: string; version: string }[] | string\n\tharness: { runtime: string; status: string }[] | string\n\t/**\n\t * Reported, never run — writes outside the repo and shouldn't happen unasked.\n\t * One flat row per action, not nested under runtime: TOON renders a flat record as a table but collapses a nested array to JSON.\n\t */\n\tactions: { runtime: string; do: string; subject: string; why: string }[] | string\n\tnotes?: string[]\n\thelp?: string[]\n}\n\nfunction commandFor(runtime: PluginRuntime, action: Action, marketplace: string): string {\n\tswitch (action.kind) {\n\t\tcase 'register':\n\t\t\treturn runtime.register(CATALOG_DIR)\n\t\tcase 'install':\n\t\t\treturn runtime.install(action.subject)\n\t\tcase 'update': {\n\t\t\t// Some runtimes cache the catalog and must refresh before update, or they reinstall the\n\t\t\t// stale cached version; Codex re-reads on every add and needs none.\n\t\t\tconst refresh = runtime.refreshMarketplace(marketplace)\n\t\t\tconst update = runtime.update(action.subject)\n\t\t\treturn refresh ? `${refresh} && ${update}` : update\n\t\t}\n\t\tcase 'uninstall':\n\t\t\treturn runtime.uninstall(action.subject)\n\t}\n}\n\nfunction notesFor(derived: ReturnType<typeof deriveCatalog>): string[] {\n\tconst notes: string[] = []\n\tif (derived.pnp) {\n\t\tnotes.push(\n\t\t\t'Yarn Plug’n’Play is active: dependencies live inside zip archives, so no harness can install from them. Set nodeLinker: node-modules, or unplug the plugin dependencies.',\n\t\t)\n\t}\n\tif (derived.genericName) {\n\t\tnotes.push(\n\t\t\t`Marketplace name \"${derived.catalog.name}\" is generic. Registering a second marketplace under a name already in use replaces the first silently, and the install that follows reports \"already installed\" — the repository then runs the other one's versions.`,\n\t\t)\n\t}\n\tfor (const { package: pkg } of derived.unresolved) {\n\t\tnotes.push(`Declared dependency \"${pkg}\" is not installed; install dependencies before generating.`)\n\t}\n\treturn notes\n}\n\nexport const depPluginsCommand: cli.Command = command({\n\tname: 'dep-plugins',\n\tdescription:\n\t\t'Derive the marketplace catalog for plugins shipped by this repository’s dependencies, so a harness can install them. Writes the catalog; installing is the harness’s own job.',\n\toptions: {\n\t\troot: {\n\t\t\tdescription: 'Repository directory. Defaults to the current directory.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\tcheck: {\n\t\t\tdescription: 'Report whether the catalog is current without writing it. For CI and postinstall.',\n\t\t\ttype: z.optional(z.boolean()),\n\t\t},\n\t\tformat: {\n\t\t\tdescription: 'Output format: toon (default), json, or text for a human-readable report.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'toon',\n\t\t},\n\t},\n\trun(args) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst root = args.root ?? process.cwd()\n\t\t\tconst derived = deriveCatalog(root)\n\n\t\t\tconst outcome = args.check\n\t\t\t\t? catalogStatus(root, derived.catalog) === 'unchanged'\n\t\t\t\t\t? ('current' as const)\n\t\t\t\t\t: ('would-change' as const)\n\t\t\t\t: writeCatalog(root, derived.catalog)\n\n\t\t\t// Reads each harness's own state files, never its CLI — a report shouldn't require that\n\t\t\t// runtime to be launchable here.\n\t\t\tconst home = homedir()\n\t\t\tconst notes = notesFor(derived)\n\t\t\tconst detected = runtimes.filter((candidate) => candidate.installedOnMachine(home))\n\t\t\tconst harness: { runtime: string; status: string }[] = []\n\t\t\tconst actions: { runtime: string; do: string; subject: string; why: string }[] = []\n\n\t\t\tfor (const runtime of detected) {\n\t\t\t\tconst state = runtime.state(home)\n\t\t\t\tconst delta = reconcile({\n\t\t\t\t\tcatalog: derived.catalog,\n\t\t\t\t\tcatalogDir: CATALOG_DIR,\n\t\t\t\t\troot: resolve(root),\n\t\t\t\t\tinstalled: state.installed,\n\t\t\t\t\tmarketplaces: state.marketplaces,\n\t\t\t\t\tscoped: runtime.scoped,\n\t\t\t\t})\n\t\t\t\tif (delta.collision) {\n\t\t\t\t\tnotes.push(\n\t\t\t\t\t\t`${runtime.name}: marketplace \"${derived.catalog.name}\" is already registered against ${delta.collision}. Registering over it replaces the other repository's silently, and the install that follows reports \"already installed\" — rename this repository's marketplace instead.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tharness.push({\n\t\t\t\t\truntime: runtime.name,\n\t\t\t\t\tstatus: delta.actions.length ? `${delta.actions.length} to apply` : 'in sync',\n\t\t\t\t})\n\t\t\t\tfor (const action of delta.actions) {\n\t\t\t\t\tactions.push({\n\t\t\t\t\t\truntime: runtime.name,\n\t\t\t\t\t\tdo: commandFor(runtime, action, derived.catalog.name),\n\t\t\t\t\t\tsubject: action.subject,\n\t\t\t\t\t\twhy: action.detail,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (derived.plugins.length) notes.push(COPILOT_LIMITATION)\n\n\t\t\tconst report: DepPluginsReport = {\n\t\t\t\tcatalog: CATALOG_PATH,\n\t\t\t\tmarketplace: derived.catalog.name,\n\t\t\t\toutcome,\n\t\t\t\tplugins: derived.plugins.length\n\t\t\t\t\t? derived.plugins.map(({ plugin, package: pkg, version }) => ({ name: plugin, package: pkg, version }))\n\t\t\t\t\t: '0 dependencies ship a plugin — nothing to install',\n\t\t\t\tharness: harness.length ? harness : 'no supported harness detected on this machine',\n\t\t\t\tactions: actions.length ? actions : '0 actions — every detected harness matches the catalog',\n\t\t\t\t...(notes.length ? { notes } : {}),\n\t\t\t}\n\t\t\twriteResult(report, format)\n\n\t\t\t// Exit code reflects staleness under --check only; everything else is in the report, not\n\t\t\t// the exit code.\n\t\t\treturn outcome === 'would-change' ? exitCodes.error : exitCodes.success\n\t\t} catch (error) {\n\t\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'Catalog generation failed.'}\\n`)\n\t\t\treturn exitCodes.error\n\t\t}\n\t},\n})\n","import { readdirSync } from 'node:fs'\nimport { join, posix, relative, sep } from 'node:path'\n\n/** A directory that does not exist reads as empty: `doctor` never creates one to look at it. */\nexport function filesUnder(directory: string): string[] {\n\ttry {\n\t\treturn readdirSync(directory, { recursive: true, withFileTypes: true })\n\t\t\t.filter((entry) => entry.isFile())\n\t\t\t.map((entry) => relative(directory, join(entry.parentPath, entry.name)).split(sep).join(posix.sep))\n\t\t\t.sort()\n\t} catch {\n\t\treturn []\n\t}\n}\n","import { lstatSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { type HarnessId, skillsDirectories } from '@cyberuni/agent-harness'\nimport type { InstructionBridge } from './instruction-bridge.ts'\nimport type { McpConfig } from './mcp-config.ts'\nimport type { NonstandardArtifact } from './nonstandard-artifact.ts'\n\nexport type HarnessName =\n\t| 'claude-code'\n\t| 'cursor'\n\t| 'codex'\n\t| 'copilot-cli'\n\t| 'gemini-cli'\n\t| 'devin-desktop'\n\t| 'windsurf'\n\t/**\n\t * No `harnessRegistry` entry — recognized by `listMcpServers` only, so `McpServerEntry.harness`\n\t * can name them.\n\t */\n\t| 'vscode'\n\t| 'opencode'\n\t| 'zed'\n\n/** The two scopes a harness reads configuration at. Their roots differ; their shape does not. */\nexport type HarnessScopeName = 'project' | 'user'\n\n/** What one harness does at one scope; paths are relative to that scope's root. */\nexport type HarnessScope = {\n\t/** The directory whose presence means this harness is configured at this scope. */\n\tdetect: string\n\t/** The projection target for `.agents/skills`; absent when the harness reads it there natively. */\n\tskillsDirectory?: string\n\t/**\n\t * What the harness needs at this scope to read `AGENTS.md`; diagnosed and gated, never written\n\t * by `init`.\n\t */\n\tinstructionBridge?: InstructionBridge\n\t/** Files whose presence beside `AGENTS.md` stop the harness reading it. */\n\tshadowedBy?: readonly string[]\n\t/** Where this harness keeps its own MCP servers; `doctor` compares against it and never writes. */\n\tmcpConfig?: McpConfig\n\t/** What this harness reads that no other can, reported so it can be converted to canonical form. */\n\tnonstandard?: readonly NonstandardArtifact[]\n}\n\nexport type Harness = {\n\tname: HarnessName\n\t/** What this harness does inside a repository. `init` and `doctor` act only here. */\n\tproject: HarnessScope\n\t/**\n\t * Outside any repository; absent when no user-scope path is documented (e.g. Devin).\n\t * Diagnosable, never written.\n\t */\n\tuser?: HarnessScope\n\t/** Set when this name has been superseded; the value is the name that replaces it. */\n\tdeprecated?: HarnessName\n}\n\n/**\n * Throws on a harness `skillsDirectories` does not confirm: treating it as native would silently\n * drop a projection it may need.\n */\nexport function skillsProjection(\n\tharness: HarnessId,\n\tscope: HarnessScopeName,\n\tdirectories: readonly string[] | undefined = skillsDirectories(harness)?.[scope],\n): Pick<HarnessScope, 'skillsDirectory'> {\n\tconst listed = directories ?? []\n\tconst [first] = listed\n\tif (first === undefined)\n\t\tthrow new Error(`@cyberuni/agent-harness records no ${scope} skills directories for ${harness}.`)\n\treturn listed.includes('.agents/skills') ? {} : { skillsDirectory: first }\n}\n\n/**\n * Skills directories come from `@cyberuni/agent-harness`, except for the harnesses it does not know\n * (`devin-desktop`, `windsurf`); see `.research/agentic-configuration-standards/` for the rest.\n */\nexport const harnessRegistry: readonly Harness[] = [\n\t{\n\t\tname: 'claude-code',\n\t\tproject: {\n\t\t\tdetect: '.claude',\n\t\t\t...skillsProjection('claude-code', 'project'),\n\t\t\tshadowedBy: ['CLAUDE.md', '.claude/CLAUDE.md', 'CLAUDE.local.md'],\n\t\t\tmcpConfig: { path: '.mcp.json', key: 'mcpServers', format: 'json', dialect: 'claude-code' },\n\t\t\tnonstandard: [\n\t\t\t\t{ path: '.claude/commands', shape: 'directory', kind: 'command' },\n\t\t\t\t{ path: '.claude/rules', shape: 'directory', kind: 'rule' },\n\t\t\t\t{ path: '.claude/agents', shape: 'directory', kind: 'subagent' },\n\t\t\t],\n\t\t},\n\t\tuser: { detect: '.claude', ...skillsProjection('claude-code', 'user') },\n\t},\n\t{\n\t\tname: 'cursor',\n\t\tproject: {\n\t\t\tdetect: '.cursor',\n\t\t\t...skillsProjection('cursor', 'project'),\n\t\t\tmcpConfig: { path: '.cursor/mcp.json', key: 'mcpServers', format: 'json', dialect: 'cursor' },\n\t\t\tnonstandard: [\n\t\t\t\t{ path: '.cursorrules', shape: 'file', kind: 'instructions' },\n\t\t\t\t{ path: '.cursor/rules', shape: 'directory', kind: 'rule' },\n\t\t\t\t{ path: '.cursor/commands', shape: 'directory', kind: 'command' },\n\t\t\t\t{ path: '.cursor/skills', shape: 'directory', kind: 'skill' },\n\t\t\t],\n\t\t},\n\t\tuser: { detect: '.cursor', ...skillsProjection('cursor', 'user') },\n\t},\n\t{\n\t\tname: 'codex',\n\t\tproject: {\n\t\t\tdetect: '.codex',\n\t\t\t...skillsProjection('codex', 'project'),\n\t\t\tmcpConfig: { path: '.codex/config.toml', key: 'mcp_servers', format: 'toml', dialect: 'codex', shared: true },\n\t\t\tnonstandard: [{ path: '.codex/skills', shape: 'directory', kind: 'skill' }],\n\t\t},\n\t\tuser: { detect: '.codex', ...skillsProjection('codex', 'user') },\n\t},\n\t{\n\t\tname: 'copilot-cli',\n\t\tproject: {\n\t\t\tdetect: '.github/skills',\n\t\t\t...skillsProjection('copilot-cli', 'project'),\n\t\t\tnonstandard: [\n\t\t\t\t{ path: '.github/copilot-instructions.md', shape: 'file', kind: 'instructions' },\n\t\t\t\t{ path: '.github/instructions', shape: 'directory', kind: 'instructions' },\n\t\t\t\t{ path: '.github/skills', shape: 'directory', kind: 'skill' },\n\t\t\t],\n\t\t},\n\t\tuser: { detect: '.copilot', ...skillsProjection('copilot-cli', 'user') },\n\t},\n\t{\n\t\tname: 'gemini-cli',\n\t\tproject: {\n\t\t\tdetect: '.gemini',\n\t\t\t...skillsProjection('gemini-cli', 'project'),\n\t\t\tinstructionBridge: { kind: 'settings-entry', path: '.gemini/settings.json', key: 'context.fileName' },\n\t\t\tmcpConfig: {\n\t\t\t\tpath: '.gemini/settings.json',\n\t\t\t\tkey: 'mcpServers',\n\t\t\t\tformat: 'json',\n\t\t\t\tdialect: 'gemini-cli',\n\t\t\t\tshared: true,\n\t\t\t},\n\t\t\tnonstandard: [\n\t\t\t\t{ path: 'GEMINI.md', shape: 'file', kind: 'instructions' },\n\t\t\t\t{ path: '.gemini/skills', shape: 'directory', kind: 'skill' },\n\t\t\t],\n\t\t},\n\t\tuser: { detect: '.gemini', ...skillsProjection('gemini-cli', 'user') },\n\t},\n\t{ name: 'devin-desktop', project: { detect: '.devin' } },\n\t{\n\t\tname: 'windsurf',\n\t\tproject: {\n\t\t\tdetect: '.windsurf',\n\t\t\tskillsDirectory: '.windsurf/skills',\n\t\t\tnonstandard: [\n\t\t\t\t{ path: '.windsurfrules', shape: 'file', kind: 'instructions' },\n\t\t\t\t{ path: '.windsurf/rules', shape: 'directory', kind: 'rule' },\n\t\t\t],\n\t\t},\n\t\tdeprecated: 'devin-desktop',\n\t},\n]\n\nconst harnessNames = new Set<string>(harnessRegistry.map((harness) => harness.name))\n\nfunction isHarnessName(value: string): value is HarnessName {\n\treturn harnessNames.has(value)\n}\n\n/**\n * An unknown name throws rather than being dropped — silently falling back to the defaults would\n * misreport what was diagnosed.\n */\nexport function parseHarnesses(value: string | undefined): HarnessName[] {\n\tconst requested = (value ?? '')\n\t\t.split(',')\n\t\t.map((name) => name.trim())\n\t\t.filter(Boolean)\n\tconst unsupported = requested.filter((name) => !isHarnessName(name))\n\tif (unsupported.length)\n\t\tthrow new Error(\n\t\t\t`Unsupported harness: ${unsupported.join(', ')}. Supported: ${harnessRegistry\n\t\t\t\t.map((harness) => harness.name)\n\t\t\t\t.join(', ')}.`,\n\t\t)\n\treturn requested.filter(isHarnessName)\n}\n\n/** Enabled whether or not the repository already contains their directories. */\nconst defaultHarnesses: readonly HarnessName[] = ['claude-code', 'cursor']\n\nfunction directoryExists(path: string): boolean {\n\ttry {\n\t\treturn lstatSync(path).isDirectory()\n\t} catch {\n\t\treturn false\n\t}\n}\n\n/** The default harnesses, plus the preferred ones, plus every harness whose directory is present. */\nexport function selectHarnesses(root: string, preferred: readonly HarnessName[]): Harness[] {\n\tconst enabled = new Set<HarnessName>([...defaultHarnesses, ...preferred])\n\treturn harnessRegistry.filter(\n\t\t(harness) => enabled.has(harness.name) || directoryExists(join(root, harness.project.detect)),\n\t)\n}\n","/**\n * Position only: a parser's own error message quotes the offending line, and in MCP configuration\n * that line holds a credential.\n */\nexport type Position = { line: number; column: number }\n\n/**\n * Never recover a part by splitting a locator's rendered string back apart — no separator survives\n * a server named `io.github.foo`.\n */\nexport type Locator = {\n\t/** Repository-relative path of the file the finding is about. */\n\tfile: string\n\t/** The MCP server inside that file, when the finding is about one. */\n\tserver?: string\n\t/** The field inside that server, dotted for the per-name fields — `command`, `env.LINEAR_TOKEN`. */\n\tfield?: string\n\t/** Where a file that does not parse failed, when the parser gave a position. */\n\tposition?: Position | undefined\n}\n\n/** The locator as one string: the finding's `path`, and what a repair names. */\nexport function locatorText({ file, server, field, position }: Locator): string {\n\tif (position) return `${file}#L${position.line}:${position.column}`\n\tif (server === undefined) return file\n\treturn `${file}#servers.${server}${field === undefined ? '' : `.${field}`}`\n}\n","import { readdirSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport type { Harness, HarnessScope } from '../harness-registry/harness-registry.ts'\nimport { harnessRegistry } from '../harness-registry/harness-registry.ts'\nimport type { NonstandardKind } from '../harness-registry/nonstandard-artifact.ts'\nimport { type Locator, locatorText } from './locator.ts'\n\n/**\n * The one place `doctor`'s guidance is written: `skills/doctor-buddy-agent-harness/SKILL.md` is\n * generated from this table, so the shipped skill cannot drift from what the command says.\n */\n\n/** Every way a skills bridge fails to resolve, or resolves and is still unsafe, in the order `doctor` reports them. */\nexport type BridgeProblem =\n\t| 'no-canonical'\n\t| 'missing'\n\t| 'degraded'\n\t| 'stale'\n\t| 'diverged-bridge'\n\t| 'diverged-canonical'\n\t| 'diverged-both'\n\t| 'diverged-unknown'\n\t| 'unpinned-copy'\n\n/**\n * Configuration that is present and **wrong**; repaired by the `repair` skill, since `init` never\n * corrects a file the user already wrote.\n */\nexport type ConfigurationFault = 'deprecated-harness' | 'ignored-bridge' | 'unread-local-override' | 'unloadable-skill'\n\n/**\n * Every way the golden MCP server set and a harness's copy of it can disagree, plus the two\n * credential findings.\n */\nexport type McpProblem =\n\t| 'mcp-golden-unreadable'\n\t| 'mcp-target-unreadable'\n\t| 'mcp-unprojected'\n\t| 'mcp-undeclared'\n\t| 'mcp-diverged-target'\n\t| 'mcp-diverged-golden'\n\t| 'mcp-diverged-both'\n\t| 'mcp-diverged-unknown'\n\t| 'mcp-literal-secret'\n\t| 'mcp-committed-secret'\n\n/**\n * Configuration that works, but only for one harness — not wrong, not missing, just narrower reach\n * than the repository intends.\n */\nexport type NonstandardProblem =\n\t| 'nonstandard-instructions'\n\t| 'nonstandard-rule'\n\t| 'nonstandard-command'\n\t| 'nonstandard-skill'\n\t| 'nonstandard-subagent'\n\n/** Every way a harness can end up reading none of `AGENTS.md`. */\nexport type InstructionProblem =\n\t| 'no-instructions'\n\t| 'instructions-missing'\n\t| 'instructions-unbridged'\n\t| 'instructions-unreadable'\n\t| 'instructions-shadowing'\n\t| 'instructions-superseded'\n\n/** Everything `doctor` can report against, across every section. */\nexport type DoctorProblem = BridgeProblem | InstructionProblem | ConfigurationFault | McpProblem | NonstandardProblem\n\n/** Alias kept for callers that name the whole set rather than one section. */\nexport type ConfigurationProblem = DoctorProblem\n\nexport type RepairAction = {\n\t/** A shell invocation that completes the repair, or empty when none does. */\n\tcommand: string\n\t/** The imperative, in prose, always present and complete on its own. */\n\tinstruction: string\n}\n\nexport type Repair = {\n\tproblem: DoctorProblem\n\t/** What `doctor` prints in the `findings` row for this problem. */\n\tdetail: string\n\t/**\n\t * `at` carries the finding in parts; read fields off it rather than splitting the rendered\n\t * locator — no separator survives a server named `io.github.foo`.\n\t */\n\trepair(at: Locator, cli: string): RepairAction\n\t/**\n\t * Delegates bridge rebuilds to the `init-buddy-agent-harness` skill rather than `init`, since\n\t * rebuilding can move user-authored skills.\n\t */\n\tskillRepair(at: Locator): string\n}\n\n/**\n * One row of a repair table, keyed by problem; a `Record<Problem, RepairRow>` fails to compile\n * until every union variant has a row.\n */\nexport type RepairRow = Omit<Repair, 'problem'>\n\n/**\n * Turns a table into the list `doctor` reports; the cast is safe because a `Record<P, RepairRow>`'s\n * keys are `P` by construction.\n */\nfunction repairsOf<Problem extends DoctorProblem>(table: Record<Problem, RepairRow>): readonly Repair[] {\n\treturn (Object.entries(table) as [Problem, RepairRow][]).map(([problem, row]) => ({ problem, ...row }))\n}\n\nexport const commandInvocation = 'buddy-agent-harness'\nexport const skillInvocation = (version: string) => `npx -y ${commandInvocation}@^${version}`\n\n/** Any `npx` invocation of this CLI, pinned or not, so a stale pin is rewritten rather than doubled. */\nexport const anyNpxInvocation: RegExp = /npx -y buddy-agent-harness(@[^\\s`]+)?/g\n\n/** A hand-written `SKILL.md` whose pinned `npx` fallback the generator rewrites in place. */\nexport type PinTarget = { path: string; expected: string }\n\n/**\n * Every hand-written `SKILL.md` under `skillsRoot` naming an `npx` invocation of this package,\n * found by scanning `skills/` rather than a maintained list; `doctor`'s own `SKILL.md` is excluded\n * since `renderDoctorSkill` writes it whole.\n */\nexport function handWrittenPinTargets(skillsRoot: string, version: string): PinTarget[] {\n\tlet skillNames: string[]\n\ttry {\n\t\tskillNames = readdirSync(skillsRoot, { withFileTypes: true })\n\t\t\t.filter((entry) => entry.isDirectory())\n\t\t\t.map((entry) => entry.name)\n\t} catch {\n\t\tskillNames = []\n\t}\n\n\tconst targets: PinTarget[] = []\n\tfor (const skill of [...skillNames].sort()) {\n\t\tif (skill === doctorSkill.name) continue\n\t\tlet content: string\n\t\ttry {\n\t\t\tcontent = readFileSync(join(skillsRoot, skill, 'SKILL.md'), 'utf8')\n\t\t} catch {\n\t\t\tcontinue\n\t\t}\n\t\tif (!content.includes(`npx -y ${commandInvocation}`)) continue\n\t\ttargets.push({\n\t\t\tpath: join(skillsRoot, skill, 'SKILL.md'),\n\t\t\texpected: content.replaceAll(anyNpxInvocation, skillInvocation(version)),\n\t\t})\n\t}\n\treturn targets\n}\n\n/** Named for the subcommand it runs, so a stack trace or process list shows which one it was. */\nexport const launcherFor = (subcommand: string) => `scripts/${subcommand}.mjs`\n\n/**\n * `node` stays in front: the script ships without an executable bit, and its shebang is a no-op on\n * Windows.\n */\nexport const launcherInvocation = (subcommand: string) => `node ${launcherFor(subcommand)}`\n\nexport const repairSkillInvocation = '/buddy-agent-harness:repair'\n\n/**\n * Qualified rather than bare `init`: a skill name is global to the harness loading it, while the\n * subcommand is scoped to this CLI.\n */\nexport const initSkillName = 'init-buddy-agent-harness'\n\nexport const initSkillInvocation: string = `/buddy-agent-harness:${initSkillName}`\n\n/** Where the user authors the golden MCP server set, named in every MCP repair that points at it. */\nconst goldenSet = '.agents/buddy-agent-harness/mcp.toml'\n\nconst bridgeTable: Record<BridgeProblem, RepairRow> = {\n\t'no-canonical': {\n\t\tdetail: 'the canonical skill directory does not exist, so no bridge can resolve',\n\t\trepair: (_at, cli) => ({\n\t\t\tcommand: `${cli} init`,\n\t\t\tinstruction: `run \\`${cli} init\\` to create .agents/skills and the bridges into it`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${initSkillInvocation}\\`, which creates \\`.agents/skills\\` and the bridges`,\n\t},\n\tmissing: {\n\t\tdetail: 'no bridge at this path — the harness sees zero project skills',\n\t\trepair: ({ file }, cli) => ({\n\t\t\tcommand: `${cli} init`,\n\t\t\tinstruction: `run \\`${cli} init\\` to create the bridge at ${file}`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${initSkillInvocation}\\``,\n\t},\n\tdegraded: {\n\t\tdetail: 'expected a directory but found a regular file — checkout without core.symlinks',\n\t\trepair: ({ file }, cli) => ({\n\t\t\tcommand: `${cli} init --copy --force ${file}`,\n\t\t\tinstruction: `run \\`${cli} init --copy --force ${file}\\` to rebuild ${file} as a real directory`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `run \\`${initSkillInvocation} --copy --force ${file}\\``,\n\t},\n\tstale: {\n\t\tdetail: 'symlink does not resolve to .agents/skills',\n\t\trepair: ({ file }, cli) => ({\n\t\t\tcommand: `${cli} init --force ${file}`,\n\t\t\tinstruction: `run \\`${cli} init --force ${file}\\` to repoint ${file} at .agents/skills`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `run \\`${initSkillInvocation} --force ${file}\\``,\n\t},\n\t'diverged-bridge': {\n\t\tdetail: 'only the bridge changed since the two last agreed — an agent wrote through the copy',\n\t\t// No command: `init` only ever builds a bridge from the canonical directory, so no flag\n\t\t// promotes the bridge's content back into it.\n\t\trepair: ({ file }, cli) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `replace .agents/skills with ${file} to keep the newer edit, then run \\`${cli} init --force ${file}\\``,\n\t\t}),\n\t\tskillRepair: ({ file }) =>\n\t\t\t`replace .agents/skills with ${file} to keep the newer edit, then run \\`${initSkillInvocation} --force ${file}\\``,\n\t},\n\t'diverged-canonical': {\n\t\tdetail: 'only .agents/skills changed since the two last agreed — the copy is stale',\n\t\trepair: ({ file }, cli) => ({\n\t\t\tcommand: `${cli} init --copy --force ${file}`,\n\t\t\tinstruction: `run \\`${cli} init --copy --force ${file}\\` to rebuild ${file} from the newer .agents/skills`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `run \\`${initSkillInvocation} --copy --force ${file}\\``,\n\t},\n\t'diverged-both': {\n\t\tdetail: 'both sides changed since they last agreed — rebuilding would discard one of them',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `reconcile .agents/skills with ${file} by hand — rebuilding would discard one of them; \\`git diff --no-index .agents/skills ${file}\\` shows what differs`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `run \\`git diff --no-index .agents/skills ${file}\\` and reconcile by hand`,\n\t},\n\t'diverged-unknown': {\n\t\tdetail: 'contents differ and no commit where they agreed was found — which side moved is unknown',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `reconcile .agents/skills with ${file} by hand — which side moved is unknown; \\`git diff --no-index .agents/skills ${file}\\` shows what differs`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `run \\`git diff --no-index .agents/skills ${file}\\` and reconcile by hand`,\n\t},\n\t'unpinned-copy': {\n\t\tdetail: 'tracked copy without the skip-worktree bit — the tree is dirty with content that must not be committed',\n\t\t// Reads paths back from git rather than assuming them: the tracked entry is a symlink on a\n\t\t// Windows checkout, but individual files in a committed copy.\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: `git ls-files -z ${file} | xargs -0 git update-index --skip-worktree`,\n\t\t\tinstruction: `run \\`git ls-files -z ${file} | xargs -0 git update-index --skip-worktree\\` to restore the skip-worktree bit`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `run \\`git ls-files -z ${file} | xargs -0 git update-index --skip-worktree\\``,\n\t},\n}\n\nexport const bridgeRepairs: readonly Repair[] = repairsOf(bridgeTable)\n\n/**\n * Everything reported in `instructions`: bridges into `AGENTS.md` and the files that suppress it.\n * Every repair is the `init-buddy-agent-harness` skill's judgment, never a shell command.\n */\nconst instructionTable: Record<InstructionProblem, RepairRow> = {\n\t'no-instructions': {\n\t\tdetail: 'no AGENTS.md at the repository root, so the instructions this repository has reach one harness at most',\n\t\trepair: () => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `hand this to \\`${initSkillInvocation}\\`, which consolidates what the repository has into AGENTS.md, or derives it`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${initSkillInvocation}\\`, which consolidates or derives AGENTS.md`,\n\t},\n\t'instructions-missing': {\n\t\tdetail: 'no instruction bridge at this path — the harness reads none of AGENTS.md',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `hand ${file} to \\`${initSkillInvocation}\\`, which writes the bridge into it`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${initSkillInvocation}\\``,\n\t},\n\t'instructions-unbridged': {\n\t\tdetail: 'the file is present but names AGENTS.md nowhere — the harness reads none of it',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `hand ${file} to \\`${initSkillInvocation}\\`, which adds the bridge without discarding what the file already says`,\n\t\t}),\n\t\tskillRepair: () =>\n\t\t\t`run \\`${initSkillInvocation}\\`, which adds the bridge without discarding what the file already says`,\n\t},\n\t'instructions-shadowing': {\n\t\tdetail: 'this file suppresses the AGENTS.md beside it — the harness reads this instead, and none of AGENTS.md',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `hand ${file} to \\`${initSkillInvocation}\\`, which consolidates what it says into AGENTS.md, or adds an @AGENTS.md import above it where the file has to stay`,\n\t\t}),\n\t\tskillRepair: () =>\n\t\t\t`run \\`${initSkillInvocation}\\`, which consolidates the file into AGENTS.md or imports AGENTS.md from it`,\n\t},\n\t'instructions-superseded': {\n\t\tdetail: 'a bridge from before the harness read AGENTS.md itself — it still works, and nothing needs it',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `remove ${file}, or keep it for sessions that cannot read AGENTS.md directly — \\`${initSkillInvocation}\\` offers the choice`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${initSkillInvocation}\\`, which offers to remove it`,\n\t},\n\t'instructions-unreadable': {\n\t\tdetail: 'the settings file does not parse, so the harness reads none of it',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `fix the JSON in ${file} by hand, then hand it to \\`${initSkillInvocation}\\``,\n\t\t}),\n\t\tskillRepair: () => `fix the JSON by hand, then run \\`${initSkillInvocation}\\``,\n\t},\n}\n\nexport const instructionRepairs: readonly Repair[] = repairsOf(instructionTable)\n\nconst configurationTable: Record<ConfigurationFault, RepairRow> = {\n\t'deprecated-harness': {\n\t\tdetail:\n\t\t\t'a projection under a harness name that has been superseded — the replacement reads .agents/skills natively and needs no projection at all',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `remove ${file} and enable the harness that replaced it — \\`${repairSkillInvocation}\\` offers the correction`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${repairSkillInvocation}\\``,\n\t},\n\t'ignored-bridge': {\n\t\tdetail: 'a .gitignore rule matches this bridge — an untracked bridge swallows a real edit silently',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `narrow or remove the .gitignore rule matching ${file} — \\`${repairSkillInvocation}\\` offers the correction`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${repairSkillInvocation}\\``,\n\t},\n\t'unread-local-override': {\n\t\tdetail: 'no harness reads this filename, so everything in it is invisible to every agent',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `move ${file} to CLAUDE.local.md, or consolidate it into AGENTS.md — \\`${repairSkillInvocation}\\` offers the correction`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${repairSkillInvocation}\\``,\n\t},\n\t'unloadable-skill': {\n\t\tdetail: 'frontmatter that does not parse, or no description — either one makes a harness skip the skill outright',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `quote the description in ${file}, or add one — \\`${repairSkillInvocation}\\` offers the correction`,\n\t\t}),\n\t\tskillRepair: () => `run \\`${repairSkillInvocation}\\``,\n\t},\n}\n\nexport const configurationRepairs: readonly Repair[] = repairsOf(configurationTable)\n\n/**\n * Every repair names a locator rather than a file, and the locator never carries a credential\n * value.\n */\nconst mcpTable: Record<McpProblem, RepairRow> = {\n\t'mcp-golden-unreadable': {\n\t\tdetail:\n\t\t\t'the golden MCP set does not parse — the locator gives the line and column, and nothing else can be said about it',\n\t\trepair: (at) => ({ command: '', instruction: `fix the TOML at ${locatorText(at)}` }),\n\t\tskillRepair: (at) =>\n\t\t\t`fix the TOML at ${locatorText(at)} by hand — the reported line and column are all that can be quoted, because the parser's own message repeats the offending line and that line is the one holding the credential`,\n\t},\n\t'mcp-target-unreadable': {\n\t\tdetail:\n\t\t\t'this harness config does not parse, so the harness starts none of its servers and nothing in it can be compared',\n\t\trepair: (at) => ({ command: '', instruction: `fix the syntax of ${locatorText(at)}` }),\n\t\tskillRepair: (at) => `fix the syntax of ${locatorText(at)} by hand`,\n\t},\n\t'mcp-unprojected': {\n\t\tdetail: 'the golden set declares this server and the harness config does not carry it',\n\t\trepair: ({ file, server }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `add the server ${server} to ${file}, or drop it from the golden set — \\`${repairSkillInvocation}\\` offers the correction`,\n\t\t}),\n\t\tskillRepair: (at) =>\n\t\t\t`hand ${locatorText(at)} to \\`${repairSkillInvocation}\\`, which projects it from its golden entry with \\`mcp project\\` — or drop it from the golden set`,\n\t},\n\t'mcp-undeclared': {\n\t\tdetail: 'the harness config carries this server and the golden set does not declare it',\n\t\trepair: ({ file, server }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `add the server ${server} to ${goldenSet}, or drop it from ${file} — \\`${repairSkillInvocation}\\` offers the import`,\n\t\t}),\n\t\tskillRepair: (at) =>\n\t\t\t`hand ${locatorText(at)} to \\`${repairSkillInvocation}\\`, which imports it field by field with \\`mcp reconcile\\`, refusing any literal credential — or drop it from ${at.file}`,\n\t},\n\t'mcp-diverged-target': {\n\t\tdetail: 'only the harness config changed since the two last agreed — the edit was made through the copy',\n\t\trepair: (at) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `reconcile the value at ${locatorText(at)} back into ${goldenSet} — \\`${repairSkillInvocation}\\` offers the import`,\n\t\t}),\n\t\tskillRepair: (at) =>\n\t\t\t`hand ${locatorText(at)} to \\`${repairSkillInvocation}\\`, which imports the field into ${goldenSet} with \\`mcp reconcile\\` once approved`,\n\t},\n\t'mcp-diverged-golden': {\n\t\tdetail: 'only the golden set changed since the two last agreed — the harness copy is stale',\n\t\trepair: (at) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `update ${locatorText(at)} from the golden entry — \\`${repairSkillInvocation}\\` offers the correction`,\n\t\t}),\n\t\tskillRepair: (at) =>\n\t\t\t`hand ${locatorText(at)} to \\`${repairSkillInvocation}\\`, which updates it from the golden entry with \\`mcp project\\``,\n\t},\n\t'mcp-diverged-both': {\n\t\tdetail: 'both sides changed since they last agreed — merging either way would discard the other',\n\t\trepair: (at) => ({ command: '', instruction: `reconcile ${locatorText(at)} against ${goldenSet} by hand` }),\n\t\tskillRepair: (at) =>\n\t\t\t`reconcile ${locatorText(at)} against ${goldenSet} by hand — never merge a three-way conflict automatically`,\n\t},\n\t'mcp-diverged-unknown': {\n\t\tdetail:\n\t\t\t'the two disagree and no baseline says which side moved — neither history nor a last-projected record covers this server',\n\t\trepair: (at) => ({ command: '', instruction: `compare ${locatorText(at)} against ${goldenSet} by hand` }),\n\t\tskillRepair: (at) => `compare ${locatorText(at)} against ${goldenSet} by hand`,\n\t},\n\t'mcp-literal-secret': {\n\t\tdetail: 'a credential-bearing field holds a literal rather than a reference to an environment variable',\n\t\trepair: (at) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `move the value at ${locatorText(at)} into an environment variable and reference it`,\n\t\t}),\n\t\tskillRepair: (at) =>\n\t\t\t`move the value at ${locatorText(at)} into an environment variable and reference it — read the value from the file, never from this report, and never repeat it back`,\n\t},\n\t'mcp-committed-secret': {\n\t\tdetail:\n\t\t\t'a credential-bearing field holds a literal in a git-tracked file — the credential is committed, and moving it does not un-commit it',\n\t\trepair: (at) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `rotate the credential behind ${locatorText(at)}, then reference it from an environment variable`,\n\t\t}),\n\t\tskillRepair: (at) =>\n\t\t\t`rotate the credential behind ${locatorText(at)} at its issuer, then reference it from an environment variable — it is in the repository's history, so moving it is not enough`,\n\t},\n}\n\nexport const mcpRepairs: readonly Repair[] = repairsOf(mcpTable)\n\n/**\n * Every repair here is a conversion owned by the `init-buddy-agent-harness` skill, except\n * `nonstandard-subagent`, which names no owner since no cross-harness format exists to convert to.\n */\nconst nonstandardTable: Record<NonstandardProblem, RepairRow> = {\n\t'nonstandard-instructions': {\n\t\tdetail: 'instruction content only one harness reads — AGENTS.md carries the same prose to all of them',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `consolidate ${file} into AGENTS.md — \\`${initSkillInvocation}\\` offers the consolidation, and keeps the content reachable where this harness needs it`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `hand ${file} to \\`${initSkillInvocation}\\`, which consolidates it into AGENTS.md`,\n\t},\n\t'nonstandard-rule': {\n\t\tdetail: 'a path-scoped rule only one harness reads — a skill reaches every harness where the scoping is incidental',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `convert ${file} into a skill under .agents/skills where its guidance is not tied to the paths it names — \\`${initSkillInvocation}\\` offers the conversion; keep it where the path scoping is the point`,\n\t\t}),\n\t\tskillRepair: ({ file }) =>\n\t\t\t`hand ${file} to \\`${initSkillInvocation}\\` to convert into a skill, unless the path scoping is load-bearing`,\n\t},\n\t'nonstandard-command': {\n\t\tdetail: 'a harness command file — a skill is the portable form, and this harness reads skills too',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `move ${file} to .agents/skills/<name>/SKILL.md — \\`${initSkillInvocation}\\` offers the move`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `hand ${file} to \\`${initSkillInvocation}\\`, which moves it to .agents/skills`,\n\t},\n\t'nonstandard-skill': {\n\t\tdetail: 'a skill under a harness directory rather than the canonical one, where only that harness finds it',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `move ${file} to .agents/skills and project it back where the harness needs one — \\`${initSkillInvocation}\\` offers the move`,\n\t\t}),\n\t\tskillRepair: ({ file }) => `hand ${file} to \\`${initSkillInvocation}\\`, which moves it to .agents/skills`,\n\t},\n\t'nonstandard-subagent': {\n\t\tdetail:\n\t\t\t'a subagent definition with no cross-harness form — nothing outside this harness can read it, and no canonical form exists yet',\n\t\trepair: ({ file }) => ({\n\t\t\tcommand: '',\n\t\t\tinstruction: `leave ${file} where it is and record that it reaches one harness only — no portable form exists to convert it to`,\n\t\t}),\n\t\tskillRepair: ({ file }) =>\n\t\t\t`leave ${file} in place — no portable form exists yet, so this is work for a person rather than a skill`,\n\t},\n}\n\nexport const nonstandardRepairs: readonly Repair[] = repairsOf(nonstandardTable)\n\n/**\n * Annotated over the whole union rather than inferred, so an added problem fails to compile until\n * its section carries it.\n */\nconst doctorTable: Record<DoctorProblem, RepairRow> = {\n\t...bridgeTable,\n\t...instructionTable,\n\t...configurationTable,\n\t...mcpTable,\n\t...nonstandardTable,\n}\n\nexport const doctorRepairs: readonly Repair[] = repairsOf(doctorTable)\n\n/** The repair for one problem. Total by construction: the table is keyed by the union. */\nexport function repairFor(problem: DoctorProblem): Repair {\n\treturn { problem, ...doctorTable[problem] }\n}\n\nexport const doctorSkill = {\n\tname: 'doctor-buddy-agent-harness',\n\tdescription:\n\t\t'Use this skill when a repository loads no project skills, when skills are missing after a clone, when a harness appears to be ignoring AGENTS.md, or when checking whether the agent configuration bridges into .claude/skills and the other harness files still resolve.',\n} as const\n\n/** Written into the generated skill so a reader knows not to edit it in place. */\nexport const generatedSkillWarning =\n\t'<!-- Generated from src/diagnose-bridges/doctor-guidance.ts by scripts/generate-skills.ts. Do not edit by hand. -->'\n\n/**\n * A file the generator writes under `skills/doctor-buddy-agent-harness/`, path relative to that\n * directory.\n */\nexport type GeneratedDoc = { path: string; content: string }\n\n/** A repair table, rendered for the skill's reader. */\nfunction repairTable(repairs: readonly Repair[]): string {\n\t// A repair may itself contain a pipe, which would otherwise end the table cell early.\n\tconst cell = (value: string) => value.replaceAll('|', '\\\\|')\n\treturn `| Finding | What it means | Repair |\n| --- | --- | --- |\n${repairs\n\t.map((entry) => `| \\`${entry.problem}\\` | ${entry.detail} | ${cell(entry.skillRepair({ file: '<path>' }))} |`)\n\t.join('\\n')}`\n}\n\n/**\n * The shipped `doctor-buddy-agent-harness` skill; the finding tables live in the reference pages\n * below, not here.\n */\nexport function renderDoctorSkill(version: string): string {\n\treturn `---\nname: ${doctorSkill.name}\ndescription: ${doctorSkill.description}\n---\n\n${generatedSkillWarning}\n\n# Harness Doctor\n\nA repository keeps one canonical configuration: \\`.agents/skills\\` for its skills and \\`AGENTS.md\\` for its instructions. Harnesses that cannot read those get bridges pointing at them: Claude Code needs the skills projection, and Gemini CLI needs the instruction bridge — each reads the other canonical path itself. A bridge that stops resolving is silent: the harness finds nothing and loads zero project skills, with no warning anywhere.\n\nInstructions fail two ways, both as quiet. A bridge that stops resolving costs more than a skills one, because the harness then reads none of the repository's instructions at all. And a harness that reads \\`AGENTS.md\\` natively still reads none of it when a file it prefers sits beside it — a \\`CLAUDE.md\\` next to an \\`AGENTS.md\\` is read *instead of* it, unless it imports it.\n\nDiagnose it:\n\n\\`\\`\\`sh\n${launcherInvocation('doctor')}\n\\`\\`\\`\n\nThat path is relative to this skill's own directory: \\`scripts/doctor.mjs\\` is a self-contained bundle built from this package's source and shipped inside the skill folder through the npm package, so it runs against the current working directory with nothing downloaded and no \\`node_modules\\` needed. Fall back to \\`${skillInvocation(version)} doctor\\` when \\`scripts/doctor.mjs\\` is missing or cannot be run — the case for a skill installed from git rather than from the npm package, which does not carry the bundle.\n\nThe command is read-only. It never repairs anything, so it is safe to run at any point, including from a session-start hook.\n\n## Reading the report\n\n\\`bridges\\` lists every skills bridge \\`init\\` would create for this repository, each with a \\`status\\` of \\`ok\\`, \\`missing\\`, \\`degraded\\`, \\`stale\\`, or \\`diverged\\`.\n\n\\`instructions\\` is everything standing between a harness and \\`AGENTS.md\\`, with a \\`status\\` of \\`ok\\`, \\`missing\\`, \\`unbridged\\`, \\`unreadable\\`, \\`shadowing\\`, or \\`superseded\\`. The last two are not bridges: they are files that suppress an \\`AGENTS.md\\` the harness would otherwise read by itself. A separate section because nothing about any of them is shared with \\`bridges\\`: a different \\`kind\\`, a different status vocabulary, and a repair that is never a command.\n\n\\`findings\\` explains each problem and carries more than the two sections above: the configuration, MCP, and non-standard findings have no section of their own, because they are about files rather than about bridges. \\`help\\` carries each repair, one row per distinct repair, with two columns:\n\n- \\`command\\` — a shell invocation that, run exactly as given, **completes** the repair.\n- \\`instruction\\` — the same repair in the imperative, always present and complete on its own.\n\n\\`command\\` is empty whenever no single invocation does the job, and that emptiness is the signal: act on \\`instruction\\` and do not assemble a command out of it. A runnable invocation quoted *inside* an \\`instruction\\` is not the repair either — \\`diverged-both\\` names \\`git diff --no-index\\` because the diff shows you what differs, not because running it reconciles anything. Apply the repair, then re-run \\`doctor\\`.\n\nNothing in \\`help\\` is wrapped. An earlier version prefixed every repair with \\`Run\\`, which read as an instruction to paste prose into a shell.\n\nDo not run an \\`init\\` command yourself. Rebuilding a skills bridge can move skills a user wrote, and rewriting an instruction file touches prose a person authored — both are the \\`init-buddy-agent-harness\\` skill's judgment, so hand the repair to \\`${initSkillInvocation}\\` instead. Every such repair carries an empty \\`command\\`: a skill invocation has no shell equivalent at all.\n\nWhen every bridge resolves, \\`findings\\` says so outright rather than being empty.\n\nThe default output is TOON, which is what you parse. Add \\`--format text\\` when you need to show the same report to a person, or \\`--format json\\`.\n\n## Where the detail is\n\nEvery \\`problem\\` name routes to exactly one page. Load the page for the finding in front of you and leave the rest unread — the tables are long, and reading four families to act on one is what this split exists to stop.\n\n| Page | Load it for |\n| --- | --- |\n| \\`references/bridges.md\\` | any \\`bridges\\` row that is not \\`ok\\` |\n| \\`references/instructions.md\\` | any \\`instructions\\` row that is not \\`ok\\` |\n| \\`references/configuration.md\\` | a finding about the configuration around the bridges rather than a bridge |\n| \\`references/mcp.md\\` | any finding whose path is an MCP locator — **always** before acting on a credential finding |\n| \\`references/nonstandard.md\\` | a finding about configuration only one harness can read |\n| \\`references/harnesses/<name>.md\\` | the paths and files one named harness uses |\n\n## Rules\n\n- Never repair a \\`diverged-both\\` or \\`diverged-unknown\\` bridge by re-running \\`init\\`. Rebuilding overwrites whichever side holds the newer edit. Reconcile the two directories first.\n- Edit skills at \\`.agents/skills/<name>/SKILL.md\\`. Editing through a bridge is only safe when that bridge is a symlink.\n- Do not add bridges to \\`.gitignore\\`. An untracked bridge swallows a real edit silently.\n- Never repeat a value from a file an \\`mcp-literal-secret\\` or \\`mcp-committed-secret\\` finding points at. The report withheld it on purpose, and quoting it back puts it in the transcript anyway.\n- Write instructions in \\`AGENTS.md\\`, never in \\`CLAUDE.md\\`. Content written there reaches one harness, drifts from the canonical file, and — because Claude Code prefers it — takes \\`AGENTS.md\\` out of that harness's context entirely.\n`\n}\n\n/** Where each kind of harness-exclusive artifact is meant to end up, for the per-harness tables. */\nfunction conversionOf(kind: NonstandardKind): string {\n\tswitch (kind) {\n\t\tcase 'instructions':\n\t\t\treturn '`AGENTS.md`, keeping the content reachable for this harness'\n\t\tcase 'rule':\n\t\t\treturn 'a skill, where the path scoping is incidental'\n\t\tcase 'command':\n\t\t\treturn '`.agents/skills/<name>/SKILL.md`'\n\t\tcase 'skill':\n\t\t\treturn '`.agents/skills`, projected back if needed'\n\t\tcase 'subagent':\n\t\t\treturn 'nothing yet — no cross-harness format exists'\n\t}\n}\n\n/** How one harness's scope reads, for its generated reference page. */\nfunction scopeRows(scope: HarnessScope): string {\n\tconst bridge = scope.instructionBridge\n\tconst mcp = scope.mcpConfig\n\treturn [\n\t\t`| detection directory | \\`${scope.detect}\\` |`,\n\t\t`| skills projection | ${scope.skillsDirectory ? `\\`${scope.skillsDirectory}\\` — written by \\`init\\`` : 'none — reads `.agents/skills` natively'} |`,\n\t\t`| instruction bridge | ${\n\t\t\tbridge === undefined ? 'none' : `\\`${bridge.path}\\` — \\`AGENTS.md\\` in the \\`${bridge.key}\\` entry`\n\t\t} |`,\n\t\t...(scope.shadowedBy\n\t\t\t? [\n\t\t\t\t\t`| suppresses \\`AGENTS.md\\` | ${scope.shadowedBy\n\t\t\t\t\t\t.map((path) => `\\`${path}\\``)\n\t\t\t\t\t\t.join(\n\t\t\t\t\t\t\t', ',\n\t\t\t\t\t\t)} — this harness reads \\`AGENTS.md\\` itself, and reads one of these instead where it finds one |`,\n\t\t\t\t]\n\t\t\t: []),\n\t\t`| MCP configuration | ${mcp === undefined ? 'none' : `\\`${mcp.path}\\` — the \\`${mcp.key}\\` key, ${mcp.format}${mcp.shared ? ', shared with other settings' : ''}`} |`,\n\t].join('\\n')\n}\n\n/**\n * Generated from the registry rather than written by hand, so a page can't drift from the paths the\n * detectors actually use.\n */\nfunction harnessPage(harness: Harness, hasInitReference: boolean): GeneratedDoc {\n\tconst deprecated =\n\t\tharness.deprecated === undefined\n\t\t\t? ''\n\t\t\t: `\\n> **Superseded by \\`${harness.deprecated}\\`.** The legacy paths still work, so a projection here keeps resolving and \\`doctor\\` reports the name as deprecated rather than broken. New repositories should enable \\`${harness.deprecated}\\`.\\n`\n\n\tconst user =\n\t\tharness.user === undefined\n\t\t\t? '\\nNo user-scope paths are primary-sourced for this harness, so `doctor` describes none.\\n'\n\t\t\t: `\\n## User scope\n\nDescribed, never written: \\`init\\` and \\`doctor\\` both work inside a repository.\n\n| What | Path |\n| --- | --- |\n${scopeRows(harness.user)}\n`\n\n\tconst artifacts = harness.project.nonstandard ?? []\n\tconst nonstandard =\n\t\tartifacts.length === 0\n\t\t\t? ''\n\t\t\t: `\\n## Configuration only this harness reads\n\nReported by \\`doctor\\` so it can be converted; see \\`../nonstandard.md\\` for what each conversion is.\n\n| Path | Kind | Converts to |\n| --- | --- | --- |\n${artifacts\n\t.map(\n\t\t(artifact) =>\n\t\t\t`| \\`${artifact.path}${artifact.shape === 'directory' ? '/' : ''}\\` | ${artifact.kind} | ${conversionOf(artifact.kind)} |`,\n\t)\n\t.join('\\n')}\n`\n\n\tconst editorial = hasInitReference\n\t\t? `\\n## Judgment about this harness\\n\\nWhat to generate for it, what to leave alone, and which claims are contested: \\`../../../${initSkillName}/references/harnesses/${harness.name}.md\\`. That page is hand-written and is the one to read before writing anything for this harness.\\n`\n\t\t: ''\n\n\treturn {\n\t\tpath: `references/harnesses/${harness.name}.md`,\n\t\tcontent: `${generatedSkillWarning}\n\n# ${harness.name}\n${deprecated}\n## Project scope\n\nWhere \\`doctor\\` looks inside a repository.\n\n| What | Path |\n| --- | --- |\n${scopeRows(harness.project)}\n${user}${nonstandard}${editorial}`,\n\t}\n}\n\n/**\n * `initReferences` is read off the filesystem rather than maintained here, so a hand-written\n * harness page is linked without a second edit.\n */\nexport function renderDoctorReferences(initReferences: ReadonlySet<string>): GeneratedDoc[] {\n\treturn [\n\t\t{\n\t\t\tpath: 'references/bridges.md',\n\t\t\tcontent: `${generatedSkillWarning}\n\n# Skills bridge findings\n\n${repairTable(bridgeRepairs)}\n\nSubstitute the reported bridge path for \\`<path>\\`.\n\n## The Windows case\n\nThe common failure is \\`degraded\\`. Creating a symlink on Windows needs a privilege most accounts do not have, and Git for Windows gates it separately with \\`core.symlinks\\`, which its installer leaves off. With \\`core.symlinks=false\\` git does not error — it writes the symlink out as a regular file whose contents are the target path. \\`${initSkillInvocation} --copy --force\\` rebuilds every bridge as a real directory on that machine; name one bridge to rebuild only that one.\n\nA copy is a snapshot rather than a live projection, and an agent that edits a skill through it writes into the copy instead of into \\`.agents/skills\\`. That is what the \\`diverged\\` findings catch.\n`,\n\t\t},\n\t\t{\n\t\t\tpath: 'references/instructions.md',\n\t\t\tcontent: `${generatedSkillWarning}\n\n# Instruction findings\n\nTwo shapes, one section. A **bridge** is what a harness needs before it can read \\`AGENTS.md\\` at all — Gemini CLI is the only one left that needs one. A **shadow** is the reverse: a file sitting beside an \\`AGENTS.md\\` that a harness reading it natively prefers, so the canonical file is never read. Claude Code is the case, and the files are \\`CLAUDE.md\\`, \\`.claude/CLAUDE.md\\`, and \\`CLAUDE.local.md\\`.\n\n${repairTable(instructionRepairs)}\n\n\\`unbridged\\` is the one to read carefully. The file is there and looks fine, and it names \\`AGENTS.md\\` nowhere — a \\`.gemini/settings.json\\` another tool rewrote without \\`AGENTS.md\\` in \\`context.fileName\\`. Never fix it by replacing the file: the content that displaced the bridge may be the only copy of something.\n\n\\`shadowing\\` is the same failure from the other direction, and the most expensive finding in this section: nothing is missing, nothing looks wrong, and the harness is reading a file the rest of the repository does not maintain. Consolidate what the file says into \\`AGENTS.md\\`, or — where the file has to stay, as a gitignored \\`CLAUDE.local.md\\` does — put an \\`@AGENTS.md\\` import in it so both load.\n\n\\`superseded\\` is not a fault. It is the bridge this tool used to write, still working and no longer needed, and there is one reason to keep it: sessions that cannot read \\`AGENTS.md\\` directly — a Claude Code before v2.1.277, a third-party provider such as Amazon Bedrock, telemetry disabled, or hooks disabled. Offer the removal; do not make it.\n\nShadows are reported per directory holding an \\`AGENTS.md\\`, so a monorepo gets one row per suppressed file rather than one per repository. A \\`CLAUDE.md\\` in one subtree says nothing about another.\n`,\n\t\t},\n\t\t{\n\t\t\tpath: 'references/configuration.md',\n\t\t\tcontent: `${generatedSkillWarning}\n\n# Configuration findings\n\nThe bridges resolve, and the configuration around them is still wrong: a superseded harness name, a git-ignored bridge, a local-override file nothing reads, a skill whose frontmatter makes every harness skip it. None of these is an \\`init\\` flag — \\`init\\` consolidates and creates, and will not correct a file the user already wrote. They go to the \\`repair\\` skill, which offers each correction with its before and after and writes only what is approved.\n\n${repairTable(configurationRepairs)}\n`,\n\t\t},\n\t\t{\n\t\t\tpath: 'references/mcp.md',\n\t\t\tcontent: `${generatedSkillWarning}\n\n# MCP findings\n\nA repository may keep a **golden MCP server set** at \\`${goldenSet}\\` — one canonical entry per server, in the superset of fields the supported hosts accept, written by the user. Where it exists, \\`doctor\\` compares it against each harness's own MCP configuration and reports how the two have drifted. **No golden set means no MCP drift findings at all**, and a harness with no MCP file yet has nothing that could have drifted.\n\nComparison is semantic. Six config keys across three file formats means no two of these files are ever byte-equal, so each side is parsed into one model and the models are compared. Each harness file is read in that harness's own spelling, and only over the fields it has a place for: a golden \\`description\\` Cursor cannot hold is not drift. A field the golden set leaves unset is never a difference, however a harness fills it in: a host restating its own default and a user's deliberate edit are indistinguishable there, and treating both as changes is what makes a golden set accumulate noise.\n\nEach finding names a **locator**, not a file: \\`.cursor/mcp.json#servers.linear.command\\` is the server and field, and that is what you route on.\n\n${repairTable(mcpRepairs)}\n\n## Credentials\n\nThe two secret findings are the ones to handle carefully.\n\n- **The report never contains the value.** It gives you the locator and stops. Read the value out of the file named in the locator, and do not repeat it into your reply, into a commit message, or into any other file. There is no truncated preview to work from because a truncated credential is a leaked credential in the same transcript.\n- **\\`mcp-committed-secret\\` is not \\`mcp-literal-secret\\` with worse wording.** The file is tracked, so the value is in the repository's history and every clone already has it. Moving it into an environment variable fixes the working tree and changes nothing about that. Rotate it at its issuer first.\n- **A reference passes.** \\`\\${LINEAR_TOKEN}\\` and \\`Bearer \\${LINEAR_TOKEN}\\` are the documented ways to write these fields and are never reported. The test is that shape, not how random the value looks.\n- **An unreadable golden set is reported by position only.** The parser's own message quotes the line it failed on, and in this file that line is the one holding the credential — so neither the message nor the offending line is ever carried into the report. Open the file at the reported line and column.\n`,\n\t\t},\n\t\t{\n\t\t\tpath: 'references/nonstandard.md',\n\t\t\tcontent: `${generatedSkillWarning}\n\n# Non-standard configuration\n\nConfiguration only one harness can read. Nothing here is broken — a Cursor rule does exactly what it says — which is why none of it is in the other four families. What these findings report is **reach**: guidance that lands in one tool and nowhere else, where nobody finds out except by noticing an agent behave differently somewhere else.\n\nEach finding names the canonical form it converts to. The direction is always the same: move the content to a canonical source, and let the harness file be **generated** from it rather than authored beside it. A repository with none of these is the target; it is a direction to walk, not a gate to pass.\n\n${repairTable(nonstandardRepairs)}\n\n## Two of them need judgment, not a move\n\n**A path-scoped rule may have nowhere to go.** \\`AGENTS.md\\` scopes by directory nesting and a skill is loaded on relevance, so neither reproduces \"these globs and no others\". Where the scoping is incidental — a rule that happens to name paths but says something generally true — a skill carries it everywhere. Where the scoping is the point, leave it, and the finding stays as the record of why.\n\n**A subagent has no portable form at all.** No cross-harness format exists, so the finding is the gap rather than a repair. It names no skill, and it is work for a person if it is work at all.\n\n## What is not reported\n\nA harness directory that is a **symlink** is a projection someone already made, not configuration authored here. An artifact is reported whether or not its harness is enabled: a \\`.cursorrules\\` in a repository nobody opens in Cursor is still instruction content \\`AGENTS.md\\` does not carry, and filtering by the enabled set would hide exactly the drift worth converting.\n\nHooks, LSP settings, and output styles are not covered yet. Their event names and shapes differ by harness with no safe projection, and half-reporting them would be worse than the silence.\n`,\n\t\t},\n\t\t...harnessRegistry.map((harness) => harnessPage(harness, initReferences.has(harness.name))),\n\t]\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { filesUnder } from '../diagnose-bridges/directory-files.ts'\nimport { type ConfigurationProblem, type RepairAction, repairFor } from '../diagnose-bridges/doctor-guidance.ts'\nimport type { GitBridgeState } from '../diagnose-bridges/git-bridge-state.ts'\nimport { selectHarnesses } from '../harness-registry/harness-registry.ts'\n\n/**\n * The configuration half of `doctor` — present-and-wrong findings about a harness's config, not\n * whether something is missing (`init`'s job) or an instruction bridge (`diagnose-instructions`'s).\n * Read-only.\n */\nexport type ConfigurationFinding = {\n\t/** Repository-relative path the finding is about. */\n\tpath: string\n\tproblem: ConfigurationProblem\n\tdetail: string\n\t/**\n\t * What repairs it, already carrying the path; `command` is always empty since every fault here\n\t * is judgment.\n\t */\n\trepair: RepairAction\n}\n\nexport type DiagnoseConfigurationOptions = {\n\troot: string\n\tgit: GitBridgeState\n\t/** How to name this tool in the repair commands. */\n\tcli: string\n}\n\nconst canonicalSkills = '.agents/skills'\nconst localOverride = 'AGENTS.local.md'\n\n/**\n * The two frontmatter faults that make a harness skip a skill outright (see\n * `skills/init-buddy-agent-harness/references/frontmatter.md`): unparseable YAML, and a missing\n * `description`. A name/directory mismatch only warns and still loads, so it's not checked here.\n * Checked directly for an unquoted colon rather than by parsing YAML — the package ships no parser.\n */\nfunction frontmatterFault(body: string): 'unparseable' | 'no-description' | undefined {\n\tconst block = /^---\\n([\\s\\S]*?)\\n---/.exec(body)\n\tif (!block) return 'unparseable'\n\tconst description = /^description:[ \\t]*(.*)$/m.exec(block[1] as string)\n\tconst value = description?.[1]?.trim()\n\tif (!value) return 'no-description'\n\tconst quoted = /^(['\"]).*\\1$/.test(value)\n\tif (!quoted && /:\\s/.test(value)) return 'unparseable'\n\treturn undefined\n}\n\n/**\n * Takes no harness preference, unlike `diagnoseBridges`: every check here needs the projection to\n * already exist on disk, which already selects the harness — a preference could never add a finding.\n */\nexport function diagnoseConfiguration({ root, git, cli }: DiagnoseConfigurationOptions): ConfigurationFinding[] {\n\tconst findings: ConfigurationFinding[] = []\n\tconst add = (path: string, problem: ConfigurationProblem) => {\n\t\tconst { detail, repair } = repairFor(problem)\n\t\tfindings.push({ path, problem, detail, repair: repair({ file: path }, cli) })\n\t}\n\n\tconst harnesses = selectHarnesses(root, [])\n\n\t// A superseded name whose projection still exists — `init` keeps projecting since the old path\n\t// still works, so nothing else flags it as stale.\n\tfor (const harness of harnesses) {\n\t\tconst projection = harness.project.skillsDirectory\n\t\tif (harness.deprecated && projection && existsSync(join(root, projection))) add(projection, 'deprecated-harness')\n\t}\n\n\t// An ignored bridge is untracked, and an untracked bridge swallows a real edit silently.\n\tfor (const harness of harnesses) {\n\t\tconst path = harness.project.skillsDirectory\n\t\tif (path && existsSync(join(root, path)) && git.isIgnored(path)) add(path, 'ignored-bridge')\n\t}\n\n\t// No harness reads this filename, so whatever it holds is invisible to every agent.\n\tif (existsSync(join(root, localOverride))) add(localOverride, 'unread-local-override')\n\n\t// `filesUnder` already confirmed these are readable files, so a failure here is a genuine IO\n\t// error, not a guard to add.\n\tfor (const file of filesUnder(join(root, canonicalSkills)).filter((file) => file.endsWith('SKILL.md'))) {\n\t\tif (frontmatterFault(readFileSync(join(root, canonicalSkills, file), 'utf8')))\n\t\t\tadd(`${canonicalSkills}/${file}`, 'unloadable-skill')\n\t}\n\n\treturn findings\n}\n","import { isRecord } from '../is-record/is-record.ts'\nexport type McpTransport = 'stdio' | 'http' | 'sse'\n\n/** A superset of every host's fields (E-MCP-05): carry what the user wrote, never invent a value. */\nexport type McpServer = {\n\ttransport?: McpTransport\n\tcommand?: string\n\targs?: readonly string[]\n\tenv?: Readonly<Record<string, string>>\n\turl?: string\n\theaders?: Readonly<Record<string, string>>\n\tdescription?: string\n\tenabled?: boolean\n\ttimeout?: number\n\tsource?: string\n}\n\n/** Every field of the model, in the order a finding reports them. */\nexport const mcpFields = [\n\t'transport',\n\t'command',\n\t'args',\n\t'env',\n\t'url',\n\t'headers',\n\t'description',\n\t'enabled',\n\t'timeout',\n\t'source',\n] as const\n\nexport type McpField = (typeof mcpFields)[number]\n\n/** The two fields holding one value per name rather than a single value. */\nconst mapFields = new Set<McpField>(['env', 'headers'])\n\n/** Arrays compare ordered (`args` is a command line); maps compare by sorted entries. */\nfunction sameValue(field: McpField, left: unknown, right: unknown): boolean {\n\tif (mapFields.has(field) && isRecord(left) && isRecord(right)) {\n\t\tconst keys = Object.keys(left)\n\t\treturn keys.length === Object.keys(right).length && keys.every((key) => left[key] === right[key])\n\t}\n\treturn JSON.stringify(left) === JSON.stringify(right)\n}\n\n/** Only over `fields`: a golden field the target has no place for is dropped on write, not drift. */\nexport function divergingFields(\n\tgolden: McpServer,\n\ttarget: McpServer,\n\tfields: ReadonlySet<McpField> = new Set(mcpFields),\n): McpField[] {\n\treturn mcpFields.filter((field) => {\n\t\tif (!fields.has(field)) return false\n\t\tconst declared = golden[field]\n\t\tif (declared === undefined) return false\n\t\tif (mapFields.has(field) && isRecord(declared) && isRecord(target[field])) {\n\t\t\tconst observed = target[field] as Record<string, unknown>\n\t\t\treturn Object.keys(declared).some((key) => declared[key] !== observed[key])\n\t\t}\n\t\treturn !sameValue(field, declared, target[field])\n\t})\n}\n\n/** Whether one field of two models agrees, for naming the side that moved. */\nexport function sameField(field: McpField, left: McpServer | undefined, right: McpServer | undefined): boolean {\n\treturn sameValue(field, left?.[field], right?.[field])\n}\n\nfunction stringMap(value: unknown): Record<string, string> | undefined {\n\tif (!isRecord(value)) return undefined\n\tconst entries = Object.entries(value).filter(([, item]) => typeof item === 'string') as [string, string][]\n\treturn entries.length ? Object.fromEntries(entries) : undefined\n}\n\nconst transports = new Set<string>(['stdio', 'http', 'sse'])\n\n/**\n * Infers transport when unstated (`url` → `http`, `command` → `stdio`), so a `url` entry in one\n * file compares equal to a `type: http` entry in another.\n */\nfunction transportOf(entry: Record<string, unknown>): McpTransport | undefined {\n\tconst declared = entry['type'] ?? entry['transport']\n\tif (typeof declared === 'string' && transports.has(declared)) return declared as McpTransport\n\tif (typeof entry['url'] === 'string') return 'http'\n\tif (typeof entry['command'] === 'string') return 'stdio'\n\treturn undefined\n}\n\n/**\n * One host or golden entry, converted into the shared model; a field of the wrong type is dropped\n * rather than carried through, so a `timeout` that is a string does not report as a divergence.\n * Also used by `mcp-inventory.ts`, which normalizes its own raw shapes into these same fields\n * first.\n */\nexport function serverFrom(entry: Record<string, unknown>): McpServer {\n\tconst args = Array.isArray(entry['args']) && entry['args'].every((item) => typeof item === 'string')\n\tconst transport = transportOf(entry)\n\tconst env = stringMap(entry['env'])\n\tconst headers = stringMap(entry['headers'])\n\treturn {\n\t\t...(transport ? { transport } : {}),\n\t\t...(typeof entry['command'] === 'string' ? { command: entry['command'] } : {}),\n\t\t...(args ? { args: entry['args'] as string[] } : {}),\n\t\t...(env ? { env } : {}),\n\t\t...(typeof entry['url'] === 'string' ? { url: entry['url'] } : {}),\n\t\t...(headers ? { headers } : {}),\n\t\t...(typeof entry['description'] === 'string' ? { description: entry['description'] } : {}),\n\t\t...(typeof entry['enabled'] === 'boolean' ? { enabled: entry['enabled'] } : {}),\n\t\t...(typeof entry['timeout'] === 'number' ? { timeout: entry['timeout'] } : {}),\n\t\t...(typeof entry['source'] === 'string' ? { source: entry['source'] } : {}),\n\t}\n}\n","import { type McpField, type McpServer, serverFrom } from '../diagnose-mcp/mcp-model.ts'\nimport { isRecord } from '../is-record/is-record.ts'\n\nexport type McpDialectName = 'claude-code' | 'cursor' | 'codex' | 'gemini-cli'\n\nexport type McpRendering =\n\t| { kind: 'entry'; entry: Record<string, unknown> }\n\t| { kind: 'refused'; field: McpField; reason: string }\n\n/**\n * One harness's MCP entry shape, both ways, per `.research/mcp-canonical-location/` E-MCP-12 to\n * E-MCP-16. `write` and `read` are a pair: whatever `write` emits, `read` returns the same model\n * over `fields`.\n */\nexport type McpDialect = {\n\t/** The golden fields this harness has a place for; the rest are dropped on write and never compared. */\n\tfields: ReadonlySet<McpField>\n\t/** Values the harness documents as its own default: present in its file, they may be the harness's, not the user's. */\n\tdefaults?: Partial<McpServer>\n\tread(entry: Record<string, unknown>): McpServer\n\twrite(server: McpServer): McpRendering\n}\n\n/** `${NAME}` — the golden set's one reference form, translated per target. */\nconst plainReference = /^\\$\\{([A-Za-z_][A-Za-z0-9_]*)\\}$/\n/** Any reference form a harness might expand, plain or not. */\nconst anyReference = /\\$\\{[^}]*\\}|\\$[A-Za-z_]/\n\nclass Refusal extends Error {\n\tconstructor(\n\t\treadonly field: McpField,\n\t\treadonly reason: string,\n\t) {\n\t\tsuper(reason)\n\t}\n}\n\nfunction refuse(field: McpField, reason: string): never {\n\tthrow new Refusal(field, reason)\n}\n\nfunction rendering(render: () => Record<string, unknown>): McpRendering {\n\ttry {\n\t\treturn { kind: 'entry', entry: render() }\n\t} catch (error) {\n\t\tif (!(error instanceof Refusal)) throw error\n\t\treturn { kind: 'refused', field: error.field, reason: error.reason }\n\t}\n}\n\n/** Either a runnable command or an address — a server with neither has nothing to write. */\nfunction assertRunnable(server: McpServer): void {\n\tif (server.transport === 'stdio' ? !server.command : !server.url)\n\t\trefuse(\n\t\t\tserver.transport === 'stdio' ? 'command' : 'url',\n\t\t\t'the golden set leaves it unset and the target requires it',\n\t\t)\n}\n\nfunction defined(entry: Record<string, unknown>): Record<string, unknown> {\n\treturn Object.fromEntries(Object.entries(entry).filter(([, value]) => value !== undefined))\n}\n\nfunction mapValues(\n\tvalues: Readonly<Record<string, string>> | undefined,\n\tmap: (value: string) => string,\n): Record<string, string> | undefined {\n\treturn values && Object.fromEntries(Object.entries(values).map(([key, value]) => [key, map(value)]))\n}\n\n/** The fields that run a server, restricted to a target that expands no reference in them. */\nfunction noReferenceIn(server: McpServer, fields: readonly ('command' | 'args' | 'url')[], harness: string): void {\n\tfor (const field of fields) {\n\t\tconst value = server[field]\n\t\tconst values = Array.isArray(value) ? value : [value]\n\t\tif (values.some((item) => typeof item === 'string' && anyReference.test(item)))\n\t\t\trefuse(field, `${harness} documents no reference expansion here`)\n\t}\n}\n\nconst claudeCode: McpDialect = {\n\tfields: new Set(['transport', 'command', 'args', 'env', 'url', 'headers', 'description', 'timeout']),\n\tread: serverFrom,\n\twrite: (server) =>\n\t\trendering(() => {\n\t\t\tassertRunnable(server)\n\t\t\treturn defined({\n\t\t\t\ttype: server.transport,\n\t\t\t\tcommand: server.command,\n\t\t\t\targs: server.args,\n\t\t\t\tenv: server.env,\n\t\t\t\turl: server.url,\n\t\t\t\theaders: server.headers,\n\t\t\t\tdescription: server.description,\n\t\t\t\ttimeout: server.timeout,\n\t\t\t})\n\t\t}),\n}\n\n/** Cursor spells a reference `${env:NAME}` and has no default form (E-MCP-13). */\nfunction toCursor(value: string, field: McpField): string {\n\treturn value.replace(/\\$\\{([^}]*)\\}|\\$[A-Za-z_]/g, (match, name: string | undefined) => {\n\t\tif (name === undefined || !plainReference.test(match))\n\t\t\trefuse(field, 'Cursor expands only a plain variable reference, with no default')\n\t\treturn `\\${env:${name}}`\n\t})\n}\n\nfunction fromCursor(value: string): string {\n\treturn value.replace(/\\$\\{env:([A-Za-z_][A-Za-z0-9_]*)\\}/g, (_, name: string) => `\\${${name}}`)\n}\n\nfunction fromCursorEntry(entry: Record<string, unknown>): Record<string, unknown> {\n\tconst strings = (value: unknown) => (typeof value === 'string' ? fromCursor(value) : value)\n\tconst map = (value: unknown) =>\n\t\tisRecord(value) ? Object.fromEntries(Object.entries(value).map(([key, item]) => [key, strings(item)])) : value\n\treturn {\n\t\t...entry,\n\t\tcommand: strings(entry['command']),\n\t\targs: Array.isArray(entry['args']) ? entry['args'].map(strings) : entry['args'],\n\t\tenv: map(entry['env']),\n\t\turl: strings(entry['url']),\n\t\theaders: map(entry['headers']),\n\t}\n}\n\n/**\n * Cursor documents `type: \"stdio\"` and no field choosing between SSE and streamable HTTP (E-MCP-13),\n * so a remote server's transport is not a field it holds.\n */\nconst cursor: McpDialect = {\n\tfields: new Set(['command', 'args', 'env', 'url', 'headers']),\n\tread: (entry) => serverFrom(fromCursorEntry(entry)),\n\twrite: (server) =>\n\t\trendering(() => {\n\t\t\tassertRunnable(server)\n\t\t\tconst stdio = server.transport === 'stdio'\n\t\t\treturn defined({\n\t\t\t\ttype: stdio ? 'stdio' : undefined,\n\t\t\t\tcommand: server.command && toCursor(server.command, 'command'),\n\t\t\t\targs: server.args?.map((arg) => toCursor(arg, 'args')),\n\t\t\t\tenv: mapValues(server.env, (value) => toCursor(value, 'env')),\n\t\t\t\turl: server.url && toCursor(server.url, 'url'),\n\t\t\t\theaders: mapValues(server.headers, (value) => toCursor(value, 'headers')),\n\t\t\t})\n\t\t}),\n}\n\nconst bearer = /^Bearer \\$\\{([A-Za-z_][A-Za-z0-9_]*)\\}$/\n\n/**\n * Codex expands no reference in a string and reaches the environment only through named fields\n * (E-MCP-14): `env_vars` passes a variable through under its own name, `env_http_headers` and\n * `bearer_token_env_var` fill a header from one.\n */\nfunction codexEnv(env: Readonly<Record<string, string>> | undefined): Record<string, unknown> {\n\tconst literal: Record<string, string> = {}\n\tconst passed: string[] = []\n\tfor (const [key, value] of Object.entries(env ?? {})) {\n\t\tconst name = plainReference.exec(value)?.[1]\n\t\tif (name === key) passed.push(key)\n\t\telse if (anyReference.test(value)) refuse('env', 'Codex passes a variable through only under its own name')\n\t\telse literal[key] = value\n\t}\n\treturn defined({\n\t\tenv: Object.keys(literal).length ? literal : undefined,\n\t\tenv_vars: passed.length ? passed : undefined,\n\t})\n}\n\nfunction codexHeaders(headers: Readonly<Record<string, string>> | undefined): Record<string, unknown> {\n\tconst literal: Record<string, string> = {}\n\tconst fromEnv: Record<string, string> = {}\n\tlet token: string | undefined\n\tfor (const [key, value] of Object.entries(headers ?? {})) {\n\t\tconst name = plainReference.exec(value)?.[1]\n\t\tconst bearerName = bearer.exec(value)?.[1]\n\t\tif (bearerName && key === 'Authorization') token = bearerName\n\t\telse if (name) fromEnv[key] = name\n\t\telse if (anyReference.test(value))\n\t\t\trefuse('headers', 'Codex fills a header only from a whole variable reference, or Bearer and one')\n\t\telse literal[key] = value\n\t}\n\treturn defined({\n\t\thttp_headers: Object.keys(literal).length ? literal : undefined,\n\t\tenv_http_headers: Object.keys(fromEnv).length ? fromEnv : undefined,\n\t\tbearer_token_env_var: token,\n\t})\n}\n\nfunction stringRecord(value: unknown): Record<string, string> {\n\tif (!isRecord(value)) return {}\n\treturn Object.fromEntries(Object.entries(value).filter(([, item]) => typeof item === 'string')) as Record<\n\t\tstring,\n\t\tstring\n\t>\n}\n\nfunction fromCodex(entry: Record<string, unknown>): Record<string, unknown> {\n\tconst passed = Array.isArray(entry['env_vars']) ? entry['env_vars'].filter((name) => typeof name === 'string') : []\n\tconst env = { ...stringRecord(entry['env']), ...Object.fromEntries(passed.map((name) => [name, `\\${${name}}`])) }\n\tconst token = entry['bearer_token_env_var']\n\tconst headers = {\n\t\t...stringRecord(entry['http_headers']),\n\t\t...Object.fromEntries(\n\t\t\tObject.entries(stringRecord(entry['env_http_headers'])).map(([key, name]) => [key, `\\${${name}}`]),\n\t\t),\n\t\t...(typeof token === 'string' ? { Authorization: `Bearer \\${${token}}` } : {}),\n\t}\n\tconst seconds = entry['tool_timeout_sec']\n\treturn {\n\t\tcommand: entry['command'],\n\t\targs: entry['args'],\n\t\tenv,\n\t\turl: entry['url'],\n\t\theaders,\n\t\tenabled: entry['enabled'],\n\t\ttimeout: typeof seconds === 'number' ? Math.round(seconds * 1000) : undefined,\n\t}\n}\n\nconst codex: McpDialect = {\n\tfields: new Set(['transport', 'command', 'args', 'env', 'url', 'headers', 'enabled', 'timeout']),\n\tdefaults: { timeout: 60_000 },\n\tread: (entry) => serverFrom(fromCodex(entry)),\n\twrite: (server) =>\n\t\trendering(() => {\n\t\t\tif (server.transport === 'sse') refuse('transport', 'Codex supports no SSE transport')\n\t\t\tassertRunnable(server)\n\t\t\tnoReferenceIn(server, ['command', 'args', 'url'], 'Codex')\n\t\t\treturn defined({\n\t\t\t\tcommand: server.command,\n\t\t\t\targs: server.args,\n\t\t\t\t...codexEnv(server.env),\n\t\t\t\turl: server.url,\n\t\t\t\t...codexHeaders(server.headers),\n\t\t\t\tenabled: server.enabled,\n\t\t\t\ttool_timeout_sec: server.timeout === undefined ? undefined : server.timeout / 1000,\n\t\t\t})\n\t\t}),\n}\n\n/**\n * Gemini CLI splits the two remote transports into two fields (E-MCP-15), and expands `${NAME}` and\n * `${NAME:-default}` in every string of its settings file (E-MCP-18), so a reference passes through.\n */\nfunction fromGemini(entry: Record<string, unknown>): Record<string, unknown> {\n\tconst { httpUrl, url, ...rest } = entry\n\tif (typeof httpUrl === 'string') return { ...rest, type: 'http', url: httpUrl }\n\treturn typeof url === 'string' ? { ...rest, type: 'sse', url } : rest\n}\n\nconst geminiCli: McpDialect = {\n\tfields: new Set(['transport', 'command', 'args', 'env', 'url', 'headers', 'timeout']),\n\tdefaults: { timeout: 600_000 },\n\tread: (entry) => serverFrom(fromGemini(entry)),\n\twrite: (server) =>\n\t\trendering(() => {\n\t\t\tassertRunnable(server)\n\t\t\treturn defined({\n\t\t\t\tcommand: server.command,\n\t\t\t\targs: server.args,\n\t\t\t\tenv: server.env,\n\t\t\t\turl: server.transport === 'sse' ? server.url : undefined,\n\t\t\t\thttpUrl: server.transport === 'http' ? server.url : undefined,\n\t\t\t\theaders: server.headers,\n\t\t\t\ttimeout: server.timeout,\n\t\t\t})\n\t\t}),\n}\n\nexport const mcpDialects: Record<McpDialectName, McpDialect> = {\n\t'claude-code': claudeCode,\n\tcursor,\n\tcodex,\n\t'gemini-cli': geminiCli,\n}\n","// Gemini CLI strips comments from `settings.json` before parsing (E-JSON-01). Trailing commas stay an\n// error: nothing documents them as accepted.\nexport function stripJsonComments(source: string): string {\n\tlet output = ''\n\tlet index = 0\n\tlet inString = false\n\tlet escaped = false\n\n\twhile (index < source.length) {\n\t\tconst character = source[index] as string\n\n\t\tif (inString) {\n\t\t\toutput += character\n\t\t\tif (escaped) escaped = false\n\t\t\telse if (character === '\\\\') escaped = true\n\t\t\telse if (character === '\"') inString = false\n\t\t\tindex += 1\n\t\t\tcontinue\n\t\t}\n\n\t\tif (character === '\"') {\n\t\t\tinString = true\n\t\t\toutput += character\n\t\t\tindex += 1\n\t\t\tcontinue\n\t\t}\n\n\t\t// A `//` inside a string is an ordinary URL; outside one it can only start a comment.\n\t\tif (character === '/' && source[index + 1] === '/') {\n\t\t\twhile (index < source.length && source[index] !== '\\n') index += 1\n\t\t\tcontinue\n\t\t}\n\n\t\tif (character === '/' && source[index + 1] === '*') {\n\t\t\tindex += 2\n\t\t\twhile (index < source.length && !(source[index] === '*' && source[index + 1] === '/')) index += 1\n\t\t\tindex += 2\n\t\t\tcontinue\n\t\t}\n\n\t\toutput += character\n\t\tindex += 1\n\t}\n\n\treturn output\n}\n\n/** The parsed value, or `undefined` when the file is not JSON even once its comments are gone. */\nexport function parseJsonWithComments(source: string): unknown {\n\ttry {\n\t\treturn JSON.parse(stripJsonComments(source))\n\t} catch {\n\t\treturn undefined\n\t}\n}\n","import { parse as parseToml } from 'smol-toml'\nimport { parseJsonWithComments } from '../diagnose-bridges/json-with-comments.ts'\nimport type { Position } from '../diagnose-bridges/locator.ts'\nimport { selectHarnesses } from '../harness-registry/harness-registry.ts'\nimport type { McpConfig } from '../harness-registry/mcp-config.ts'\nimport { isRecord } from '../is-record/is-record.ts'\nimport { mcpDialects } from '../mcp-dialects/mcp-dialects.ts'\nimport { type McpServer, serverFrom } from './mcp-model.ts'\n\n/** Where the golden set lives, and why it is namespaced rather than sitting at `.agents/mcp.json`. */\nexport const goldenSetPath = '.agents/buddy-agent-harness/mcp.toml'\n\nconst goldenKey = 'servers'\n\n/**\n * The distinct MCP files the enabled harnesses read. No `--harness` preference is accepted: every\n * harness documenting an MCP file is already selected without one, so a preference could never add\n * a target.\n */\nexport function mcpTargets(root: string): McpConfig[] {\n\tconst seen = new Set<string>()\n\treturn selectHarnesses(root, [])\n\t\t.map((harness) => harness.project.mcpConfig)\n\t\t.filter((config): config is McpConfig => config !== undefined)\n\t\t.filter((config) => !seen.has(config.path) && seen.add(config.path))\n}\n\nexport type ParsedServers =\n\t/** The file is absent. Nothing to compare, and not a fault. */\n\t| { kind: 'absent' }\n\t| { kind: 'servers'; servers: Map<string, McpServer> }\n\t| { kind: 'unreadable'; position?: Position | undefined }\n\nfunction serversUnder(\n\tdocument: unknown,\n\tkey: string,\n\tread: (entry: Record<string, unknown>) => McpServer = serverFrom,\n): Map<string, McpServer> {\n\tconst table = isRecord(document) ? document[key] : undefined\n\tif (!isRecord(table)) return new Map()\n\treturn new Map(\n\t\tObject.entries(table)\n\t\t\t.filter(([, entry]) => isRecord(entry))\n\t\t\t.map(([name, entry]) => [name, read(entry as Record<string, unknown>)]),\n\t)\n}\n\n/**\n * Only line and column — never `message` or `codeblock`, which quote the source line and could echo\n * a credential.\n */\nexport function positionOf(error: unknown): Position | undefined {\n\tif (!isRecord(error)) return undefined\n\tconst { line, column } = error\n\treturn typeof line === 'number' && typeof column === 'number' ? { line, column } : undefined\n}\n\n/** The golden set, parsed. Absent is the common case and is not a fault. */\nexport function parseGoldenSet(source: string | undefined): ParsedServers {\n\tif (source === undefined) return { kind: 'absent' }\n\ttry {\n\t\treturn { kind: 'servers', servers: serversUnder(parseToml(source), goldenKey) }\n\t} catch (error) {\n\t\treturn { kind: 'unreadable', position: positionOf(error) }\n\t}\n}\n\n/**\n * One harness's config, parsed under its own key only — `.gemini/settings.json` also carries the\n * instruction bridge. JSON is parsed with comments stripped, matching Gemini CLI's own loader.\n */\nexport function parseTarget(config: McpConfig, source: string | undefined): ParsedServers {\n\tif (source === undefined) return { kind: 'absent' }\n\tif (config.format === 'toml') {\n\t\ttry {\n\t\t\treturn { kind: 'servers', servers: serversUnder(parseToml(source), config.key, mcpDialects[config.dialect].read) }\n\t\t} catch {\n\t\t\treturn { kind: 'unreadable' }\n\t\t}\n\t}\n\tconst document = parseJsonWithComments(source)\n\t// A literal `null` parses successfully and holds no servers — reported the same as `{}`, not as\n\t// unreadable.\n\tif (document === undefined) return { kind: 'unreadable' }\n\treturn { kind: 'servers', servers: serversUnder(document, config.key, mcpDialects[config.dialect].read) }\n}\n","import type { GitBridgeState } from '../diagnose-bridges/git-bridge-state.ts'\nimport { parseJsonWithComments } from '../diagnose-bridges/json-with-comments.ts'\nimport type { McpConfig } from '../harness-registry/mcp-config.ts'\nimport { isRecord } from '../is-record/is-record.ts'\nimport { type McpField, type McpServer, sameField } from './mcp-model.ts'\nimport { goldenSetPath, type ParsedServers, parseGoldenSet, parseTarget } from './mcp-sources.ts'\n\n/** Which side of a diverged server moved since the two last agreed. */\nexport type McpDirection = 'target' | 'golden' | 'both' | 'unknown'\n\n/**\n * Where the record of what was last written to each target lives, beside the golden set it came\n * from.\n */\nexport const projectionRecordPath = '.agents/buddy-agent-harness/mcp.projected.json'\n\nexport function parseProjectionRecord(source: string | undefined): Map<string, Map<string, McpServer>> {\n\tconst document = source === undefined ? undefined : parseJsonWithComments(source)\n\tconst targets = isRecord(document) ? document['targets'] : undefined\n\tif (!isRecord(targets)) return new Map()\n\treturn new Map(\n\t\tObject.entries(targets)\n\t\t\t.filter(([, servers]) => isRecord(servers))\n\t\t\t.map(([path, servers]) => [\n\t\t\t\tpath,\n\t\t\t\tnew Map(\n\t\t\t\t\tObject.entries(servers as Record<string, unknown>)\n\t\t\t\t\t\t.filter(([, server]) => isRecord(server))\n\t\t\t\t\t\t.map(([name, server]) => [name, server as McpServer]),\n\t\t\t\t),\n\t\t\t]),\n\t)\n}\n\n/** The record as written back: one object per target, one golden model per server. */\nexport function formatProjectionRecord(record: Map<string, Map<string, McpServer>>): string {\n\tconst targets = Object.fromEntries([...record].map(([path, servers]) => [path, Object.fromEntries(servers)]))\n\treturn `${JSON.stringify({ targets }, null, 2)}\\n`\n}\n\nexport type BaselineOptions = {\n\tgit: GitBridgeState\n\trecord: Map<string, Map<string, McpServer>>\n}\n\nexport class McpBaseline {\n\tconstructor(private readonly options: BaselineOptions) {}\n\n\t/**\n\t * Memoized per instance: unmemoized, `lastAgreed` would repeat the same `git show` and parse\n\t * for every diverged field. The memo dies with the instance, so it never answers for a working\n\t * tree that has since moved on.\n\t */\n\tprivate readonly parsed = new Map<string, ParsedServers>()\n\tprivate readonly walked = new Map<string, string[]>()\n\n\tdirectionOf(config: McpConfig, name: string, field: McpField, golden: McpServer, target: McpServer): McpDirection {\n\t\tconst base = this.baseFor(config, name, field)\n\t\tif (base === undefined) return 'unknown'\n\t\tconst goldenMoved = !sameField(field, golden, base)\n\t\tconst targetMoved = !sameField(field, target, base)\n\t\tif (goldenMoved && targetMoved) return 'both'\n\t\treturn targetMoved ? 'target' : 'golden'\n\t}\n\n\t/** The server as the two sides last agreed on `field`, or `undefined` when no baseline can say. */\n\tbaseFor(config: McpConfig, name: string, field: McpField): McpServer | undefined {\n\t\tconst recorded = this.options.record.get(config.path)?.get(name)\n\t\tif (recorded) return recorded\n\t\treturn this.lastAgreed(config, name, field)\n\t}\n\n\t/**\n\t * Compared at model granularity, not blob bytes — the two files never share bytes, so a\n\t * reformat wouldn't register as agreement lost.\n\t */\n\tprivate lastAgreed(config: McpConfig, name: string, field: McpField): McpServer | undefined {\n\t\tfor (const commit of this.commitsTouching(config)) {\n\t\t\tconst golden = this.parseAt(commit, goldenSetPath, parseGoldenSet)\n\t\t\tconst target = this.parseAt(commit, config.path, (source) => parseTarget(config, source))\n\t\t\tif (golden.kind !== 'servers' || target.kind !== 'servers') continue\n\t\t\tconst left = golden.servers.get(name)\n\t\t\tconst right = target.servers.get(name)\n\t\t\tif (left && right && sameField(field, left, right)) return left\n\t\t}\n\t\treturn undefined\n\t}\n\n\tprivate commitsTouching(config: McpConfig): string[] {\n\t\tconst walked = this.walked.get(config.path)\n\t\tif (walked) return walked\n\t\tconst commits = this.options.git.commitsTouching([goldenSetPath, config.path])\n\t\tthis.walked.set(config.path, commits)\n\t\treturn commits\n\t}\n\n\tprivate parseAt(commit: string, path: string, parse: (source: string | undefined) => ParsedServers): ParsedServers {\n\t\tconst key = `${commit}\\u0000${path}`\n\t\tconst parsed = this.parsed.get(key)\n\t\tif (parsed) return parsed\n\t\tconst result = parse(this.options.git.contentAt(commit, path))\n\t\tthis.parsed.set(key, result)\n\t\treturn result\n\t}\n}\n","import type { McpServer } from './mcp-model.ts'\n\n/**\n * Finding a literal credential in MCP configuration, without ever handling one: every function\n * here answers where, never what, and the value itself never leaves this module — redaction lives\n * here, once, rather than being trusted to each of `doctor`'s three output formats.\n */\n\n/**\n * Marks a field as credential-bearing anywhere in its name — safe as a substring, since none of\n * these turn up inside an innocent word.\n */\nconst credentialWord = /token|secret|password|passwd|credential/i\n\n/**\n * Marks a field only as a whole name segment: `key`/`auth` are common inside innocent words like\n * `MONKEY` or `AUTHOR`.\n */\nconst credentialSegment = new Set(['key', 'apikey', 'auth', 'authorization', 'bearer'])\n\n/** A field name split the two ways these are written: `API_KEY` and `apiKey` alike. */\nfunction segmentsOf(key: string): string[] {\n\treturn key\n\t\t.replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n\t\t.split(/[^A-Za-z0-9]+/)\n\t\t.filter(Boolean)\n\t\t.map((segment) => segment.toLowerCase())\n}\n\n/**\n * A value that names a secret rather than holding one: `${VAR}`, `$VAR`, `${env:VAR}`,\n * `${input:id}`. Classification is by shape, not entropy — a short password and a base64 blob look\n * identical to an entropy test.\n */\nconst reference = /\\$\\{[^}]+\\}|\\$[A-Za-z_][A-Za-z0-9_]*/\n\n/**\n * True unless a reference appears anywhere in the value — `Bearer ${LINEAR_TOKEN}` is the\n * documented template form, so requiring the whole value to be a reference would flag it as\n * literal.\n */\nfunction holdsLiteral(value: string): boolean {\n\treturn !reference.test(value)\n}\n\nfunction credentialKey(key: string): boolean {\n\treturn credentialWord.test(key) || segmentsOf(key).some((segment) => credentialSegment.has(segment))\n}\n\n/**\n * A password in the URL's userinfo, or a credential-named query parameter holding a literal. An\n * unparseable URL is not reported — malformed, not leaky.\n */\nfunction urlHoldsCredential(value: string): boolean {\n\tlet url: URL\n\ttry {\n\t\turl = new URL(value)\n\t} catch {\n\t\treturn false\n\t}\n\tif (url.password) return true\n\tfor (const [key, parameter] of url.searchParams) if (credentialKey(key) && holdsLiteral(parameter)) return true\n\treturn false\n}\n\nfunction literalsIn(field: 'env' | 'headers', values: Readonly<Record<string, string>> | undefined): string[] {\n\treturn Object.entries(values ?? {})\n\t\t.filter(([key, value]) => credentialKey(key) && holdsLiteral(value))\n\t\t.map(([key]) => `${field}.${key}`)\n}\n\n/** Field paths only — never a truncated value; `sk-ab…` is still a leak into the same transcript. */\nexport function credentialFields(server: McpServer): string[] {\n\treturn [\n\t\t...literalsIn('env', server.env),\n\t\t...literalsIn('headers', server.headers),\n\t\t...(server.url && urlHoldsCredential(server.url) ? ['url'] : []),\n\t]\n}\n\n/**\n * Drops a `--flag=value` pair whose flag names a credential and whose value is a literal; a\n * positional argument or a flag with no `=` has no key to test and passes through.\n */\nexport function nonSecretArgs(args: readonly string[] | undefined): string[] {\n\treturn (args ?? []).filter((arg) => {\n\t\tconst at = arg.indexOf('=')\n\t\tif (at === -1) return true\n\t\treturn !(credentialKey(arg.slice(0, at)) && holdsLiteral(arg.slice(at + 1)))\n\t})\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { type McpProblem, repairFor } from '../diagnose-bridges/doctor-guidance.ts'\nimport type { GitBridgeState } from '../diagnose-bridges/git-bridge-state.ts'\nimport { type Locator, locatorText } from '../diagnose-bridges/locator.ts'\nimport type { ConfigurationFinding } from '../diagnose-configuration/diagnose-configuration.ts'\nimport type { McpConfig } from '../harness-registry/mcp-config.ts'\nimport { mcpDialects } from '../mcp-dialects/mcp-dialects.ts'\nimport { McpBaseline, type McpDirection, parseProjectionRecord, projectionRecordPath } from './mcp-baseline.ts'\nimport { divergingFields, type McpServer } from './mcp-model.ts'\nimport { credentialFields } from './mcp-secrets.ts'\nimport { goldenSetPath, mcpTargets, parseGoldenSet, parseTarget } from './mcp-sources.ts'\n\nexport type DiagnoseMcpOptions = {\n\troot: string\n\tgit: GitBridgeState\n\t/** How to name this tool in the repair commands. */\n\tcli: string\n}\n\nfunction read(root: string, path: string): string | undefined {\n\tconst absolute = join(root, path)\n\treturn existsSync(absolute) ? readFileSync(absolute, 'utf8') : undefined\n}\n\nconst divergence: Record<McpDirection, McpProblem> = {\n\ttarget: 'mcp-diverged-target',\n\tgolden: 'mcp-diverged-golden',\n\tboth: 'mcp-diverged-both',\n\tunknown: 'mcp-diverged-unknown',\n}\n\nexport function diagnoseMcp({ root, git, cli }: DiagnoseMcpOptions): ConfigurationFinding[] {\n\tconst findings: ConfigurationFinding[] = []\n\t// The locator is built once and never parsed back — a server name like `io.github.foo` would\n\t// not survive a split.\n\tconst add = (at: Locator, problem: McpProblem) => {\n\t\tconst { detail, repair } = repairFor(problem)\n\t\tfindings.push({ path: locatorText(at), problem, detail, repair: repair(at, cli) })\n\t}\n\n\tconst reportSecrets = (path: string, servers: Map<string, McpServer>) => {\n\t\tconst committed = git.trackingOf(path) !== 'untracked'\n\t\tfor (const [name, server] of servers)\n\t\t\tfor (const field of credentialFields(server))\n\t\t\t\tadd({ file: path, server: name, field }, committed ? 'mcp-committed-secret' : 'mcp-literal-secret')\n\t}\n\n\t// Read first so an unreadable target is reported even without a golden set — that harness can't\n\t// read the file either.\n\tconst targets = new Map<string, Map<string, McpServer>>()\n\tconst configs: McpConfig[] = []\n\tfor (const config of mcpTargets(root)) {\n\t\tconst parsed = parseTarget(config, read(root, config.path))\n\t\tif (parsed.kind === 'unreadable') {\n\t\t\tadd({ file: config.path }, 'mcp-target-unreadable')\n\t\t\tcontinue\n\t\t}\n\t\t// No file yet means nothing has drifted — writing one is projection, a write this command\n\t\t// doesn't do.\n\t\tif (parsed.kind === 'absent') continue\n\t\treportSecrets(config.path, parsed.servers)\n\t\ttargets.set(config.path, parsed.servers)\n\t\tconfigs.push(config)\n\t}\n\n\tconst golden = parseGoldenSet(read(root, goldenSetPath))\n\tif (golden.kind === 'unreadable') {\n\t\tadd({ file: goldenSetPath, position: golden.position }, 'mcp-golden-unreadable')\n\t\treturn findings\n\t}\n\tif (golden.kind === 'absent') return findings\n\treportSecrets(goldenSetPath, golden.servers)\n\n\tconst baseline = new McpBaseline({ git, record: parseProjectionRecord(read(root, projectionRecordPath)) })\n\n\tfor (const config of configs) {\n\t\tconst servers = targets.get(config.path) as Map<string, McpServer>\n\t\tfor (const [name, declared] of golden.servers) {\n\t\t\tconst carried = servers.get(name)\n\t\t\tif (!carried) {\n\t\t\t\tadd({ file: config.path, server: name }, 'mcp-unprojected')\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const field of divergingFields(declared, carried, mcpDialects[config.dialect].fields))\n\t\t\t\tadd(\n\t\t\t\t\t{ file: config.path, server: name, field },\n\t\t\t\t\tdivergence[baseline.directionOf(config, name, field, declared, carried)],\n\t\t\t\t)\n\t\t}\n\t\tfor (const name of servers.keys())\n\t\t\tif (!golden.servers.has(name)) add({ file: config.path, server: name }, 'mcp-undeclared')\n\t}\n\n\treturn findings\n}\n","import { lstatSync, readFileSync } from 'node:fs'\nimport { join, posix } from 'node:path'\nimport { filesUnder } from '../diagnose-bridges/directory-files.ts'\nimport { type NonstandardProblem, type RepairAction, repairFor } from '../diagnose-bridges/doctor-guidance.ts'\nimport { harnessRegistry } from '../harness-registry/harness-registry.ts'\nimport type { NonstandardArtifact, NonstandardKind } from '../harness-registry/nonstandard-artifact.ts'\n\n/**\n * Configuration that works for exactly one harness — not a fault to fix, since e.g. a Cursor rule\n * does what it says; each finding just names the canonical form to convert to. Read-only.\n */\nexport type NonstandardFinding = {\n\t/** Repository-relative path of the artifact, POSIX-separated. */\n\tpath: string\n\tproblem: NonstandardProblem\n\tdetail: string\n\t/** The conversion. `command` is always empty: every one of these is judgment about content. */\n\trepair: RepairAction\n}\n\nexport type DiagnoseNonstandardOptions = {\n\troot: string\n\t/** How to name this tool in the repair commands. */\n\tcli: string\n}\n\nconst problemOf: Record<NonstandardKind, NonstandardProblem> = {\n\tinstructions: 'nonstandard-instructions',\n\trule: 'nonstandard-rule',\n\tcommand: 'nonstandard-command',\n\tskill: 'nonstandard-skill',\n\tsubagent: 'nonstandard-subagent',\n}\n\n/**\n * `globs:` with a value binds a `.mdc` rule to paths — `AGENTS.md` has no equivalent, so that rule\n * converts to a skill; without it, the rule is always-on prose that `AGENTS.md` holds verbatim.\n * Read from frontmatter rather than assumed, since guessing wrong sends prose to the wrong destination.\n */\nfunction scopedByGlobs(body: string): boolean {\n\tconst block = /^---\\n([\\s\\S]*?)\\n---/.exec(body)\n\tif (!block) return false\n\tconst globs = /^globs:[ \\t]*(.*)$/m.exec(block[1] as string)\n\tconst value = globs?.[1]?.trim()\n\treturn value !== undefined && value.length > 0 && value !== '[]'\n}\n\n/** Every skill directory below `directory`, named by its `SKILL.md`. */\nfunction skillFiles(directory: string): string[] {\n\treturn filesUnder(directory).filter((file) => file.endsWith('SKILL.md'))\n}\n\n/**\n * A symlinked path is already a projection, not authored config — reporting it would tell a repo to\n * convert what it already converted.\n */\nfunction authoredHere(path: string): boolean {\n\ttry {\n\t\treturn !lstatSync(path).isSymbolicLink()\n\t} catch {\n\t\treturn false\n\t}\n}\n\nfunction artifactFiles(root: string, artifact: NonstandardArtifact): string[] {\n\tconst absolute = join(root, artifact.path)\n\t// A path that is not there fails this too — `lstat` throws and the catch reads as \"not ours\".\n\tif (!authoredHere(absolute)) return []\n\tif (artifact.shape === 'file') return [artifact.path]\n\tconst below = artifact.kind === 'skill' ? skillFiles(absolute) : filesUnder(absolute)\n\treturn below.map((file) => posix.join(artifact.path, file))\n}\n\n/**\n * Takes no harness preference or enabled set, unlike the other detectors — an artifact matters\n * whether or not its harness is enabled here, so filtering by the enabled set would hide it.\n */\nexport function diagnoseNonstandard({ root, cli }: DiagnoseNonstandardOptions): NonstandardFinding[] {\n\tconst findings: NonstandardFinding[] = []\n\n\tfor (const harness of harnessRegistry) {\n\t\tfor (const artifact of harness.project.nonstandard ?? []) {\n\t\t\tfor (const path of artifactFiles(root, artifact)) {\n\t\t\t\tconst kind =\n\t\t\t\t\tartifact.kind === 'rule' && path.endsWith('.mdc') && !scopedByGlobs(readFileSync(join(root, path), 'utf8'))\n\t\t\t\t\t\t? 'instructions'\n\t\t\t\t\t\t: artifact.kind\n\t\t\t\tconst problem = problemOf[kind]\n\t\t\t\tconst { detail, repair } = repairFor(problem)\n\t\t\t\tfindings.push({ path, problem, detail, repair: repair({ file: path }, cli) })\n\t\t\t}\n\t\t}\n\t}\n\n\t// No dedupe — one artifact is declared by one harness (enforced by `harness-registry.test.ts`);\n\t// collapsing a duplicate would hide a registry mistake.\n\treturn findings.sort((left, right) => left.path.localeCompare(right.path))\n}\n","import { parse } from 'yaml'\nimport { isRecord } from '../is-record/is-record.ts'\n\nexport type MergeMode = 'first-wins' | 'combine' | 'merge-sections'\n\nconst mergeModes: readonly MergeMode[] = ['first-wins', 'combine', 'merge-sections']\n\nexport type ParsedDocument = { metadata: Record<string, unknown>; body: string }\n\nconst frontmatterPattern = /^---[ \\t]*\\r?\\n([\\s\\S]*?)\\r?\\n(?:---|\\.\\.\\.)[ \\t]*(?:\\r?\\n|$)/\n\n/** Frontmatter that is not a YAML mapping is dropped with a warning, never passed off as body text. */\nexport function parseDocument(raw: string, warn: (message: string) => void): ParsedDocument {\n\tconst match = frontmatterPattern.exec(raw)\n\tif (!match) return { metadata: {}, body: raw }\n\tconst body = raw.slice(match[0].length)\n\ttry {\n\t\tconst value: unknown = parse(match[1] as string)\n\t\tif (value === null || value === undefined) return { metadata: {}, body }\n\t\tif (isRecord(value)) return { metadata: value, body }\n\t} catch {}\n\twarn('frontmatter is not a YAML mapping; it is ignored')\n\treturn { metadata: {}, body }\n}\n\nexport function readMergeMode(metadata: Record<string, unknown>, warn: (message: string) => void): MergeMode {\n\tconst value = metadata['merge']\n\tif (value === undefined) return 'first-wins'\n\tif (mergeModes.includes(value as MergeMode)) return value as MergeMode\n\twarn(`unknown merge mode \"${String(value)}\"; read as first-wins`)\n\treturn 'first-wins'\n}\n\nconst mergeCommentPattern = /^\\s*<!--\\s*merge:\\s*([\\w-]*)\\s*-->\\s*$/\nconst headingPattern = /^ {0,3}(#{1,6})(?:[ \\t]+(.*?))?(?:[ \\t]+#+)?[ \\t]*$/\nconst fenceOpenPattern = /^ {0,3}(`{3,}|~{3,})/\n\n/**\n * Tracks fenced code blocks line by line — a `#` or a merge comment inside one is body text, and the\n * one thing a Markdown-unaware split gets wrong.\n */\nfunction fenceTracker() {\n\tlet fence: string | undefined\n\treturn (line: string): boolean => {\n\t\tif (fence) {\n\t\t\tconst closing = new RegExp(`^ {0,3}${fence[0] === '`' ? '`' : '~'}{${fence.length},}\\\\s*$`)\n\t\t\tif (closing.test(line)) fence = undefined\n\t\t\treturn true\n\t\t}\n\t\tconst open = fenceOpenPattern.exec(line)\n\t\tif (open) {\n\t\t\tfence = open[1]\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n}\n\nexport function stripMergeComments(body: string): string {\n\tconst inFence = fenceTracker()\n\treturn body\n\t\t.split('\\n')\n\t\t.filter((line) => inFence(line) || !mergeCommentPattern.test(line))\n\t\t.join('\\n')\n}\n\nexport type SectionOp = 'replace' | 'combine' | 'remove'\n\nexport type Section = {\n\tlevel: number\n\ttitle: string\n\theading: string\n\top: SectionOp\n\tbody: string[]\n\tchildren: Section[]\n}\n\nexport type SectionTree = { preamble: string[]; children: Section[] }\n\nfunction sectionKey(title: string): string {\n\treturn title.trim().replace(/\\s+/g, ' ').toLowerCase()\n}\n\nfunction displayHeading(section: Section): string {\n\treturn `${'#'.repeat(section.level)} ${section.title}`\n}\n\nexport function parseSections(body: string, warn: (message: string) => void): SectionTree {\n\tconst tree: SectionTree = { preamble: [], children: [] }\n\tconst stack: Section[] = []\n\tconst inFence = fenceTracker()\n\tlet awaitingOp: Section | undefined\n\tfor (const line of body.split('\\n')) {\n\t\tconst current = stack.at(-1)\n\t\tconst fenced = inFence(line)\n\t\tconst heading = fenced ? null : headingPattern.exec(line)\n\t\tif (heading) {\n\t\t\tconst level = (heading[1] as string).length\n\t\t\tconst title = (heading[2] ?? '').trim()\n\t\t\tconst section: Section = { level, title, heading: line.trimEnd(), op: 'replace', body: [], children: [] }\n\t\t\twhile ((stack.at(-1)?.level ?? 0) >= level) stack.pop()\n\t\t\t;(stack.at(-1)?.children ?? tree.children).push(section)\n\t\t\tstack.push(section)\n\t\t\tawaitingOp = section\n\t\t\tcontinue\n\t\t}\n\t\tif (awaitingOp && !fenced) {\n\t\t\tif (!line.trim()) continue\n\t\t\tconst comment = mergeCommentPattern.exec(line)\n\t\t\tif (comment) {\n\t\t\t\tconst op = comment[1] as string\n\t\t\t\tif (op === 'replace' || op === 'combine' || op === 'remove') awaitingOp.op = op\n\t\t\t\telse warn(`unknown section merge \"${op}\" under \"${displayHeading(awaitingOp)}\"; read as replace`)\n\t\t\t\tawaitingOp = undefined\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tawaitingOp = undefined\n\t\t;(current?.body ?? tree.preamble).push(line)\n\t}\n\treturn tree\n}\n\nfunction trimBlank(lines: readonly string[]): string[] {\n\tlet start = 0\n\tlet end = lines.length\n\twhile (start < end && !(lines[start] as string).trim()) start++\n\twhile (end > start && !(lines[end - 1] as string).trim()) end--\n\treturn lines.slice(start, end)\n}\n\nfunction warnDuplicates(sections: readonly Section[], path: string, where: string, warn: (message: string) => void) {\n\tconst seen = new Set<string>()\n\tfor (const section of sections) {\n\t\tconst key = sectionKey(section.title)\n\t\tif (seen.has(key)) {\n\t\t\twarn(`heading path \"${path}${displayHeading(section)}\" appears more than once in ${where}; the first is matched`)\n\t\t}\n\t\tseen.add(key)\n\t}\n}\n\nfunction warnUnmatched(section: Section, path: string, where: string, warn: (message: string) => void) {\n\twarn(`\"<!-- merge: ${section.op} -->\" on \"${path}${displayHeading(section)}\" in ${where} matches no section below`)\n}\n\n/** A section placed without merging has nothing below its subsections, so their merge comments match nothing. */\nfunction place(section: Section, path: string, where: string, warn: (message: string) => void): Section {\n\tconst childPath = `${path}${displayHeading(section)} > `\n\tconst children = section.children.flatMap((child) => {\n\t\tif (child.op !== 'replace') warnUnmatched(child, childPath, where, warn)\n\t\treturn child.op === 'remove' ? [] : [place(child, childPath, where, warn)]\n\t})\n\treturn { ...section, children }\n}\n\nfunction mergeChildren(\n\tbase: readonly Section[],\n\toverlay: readonly Section[],\n\tpath: string,\n\twhere: string,\n\twarn: (message: string) => void,\n): Section[] {\n\twarnDuplicates(base, path, 'the layers below', warn)\n\twarnDuplicates(overlay, path, where, warn)\n\tconst slots: (Section | undefined)[] = [...base]\n\tconst appended: Section[] = []\n\tconst matched = new Set<number>()\n\tfor (const section of overlay) {\n\t\tconst key = sectionKey(section.title)\n\t\tconst index = base.findIndex((candidate, i) => !matched.has(i) && sectionKey(candidate.title) === key)\n\t\tif (index === -1) {\n\t\t\tif (section.op !== 'replace') warnUnmatched(section, path, where, warn)\n\t\t\tif (section.op !== 'remove') appended.push(place(section, path, where, warn))\n\t\t\tcontinue\n\t\t}\n\t\t// Only the first occurrence of a duplicated path is matched; a second overlay section with the\n\t\t// same path finds nothing left and is appended.\n\t\tfor (let i = 0; i < base.length; i++) if (sectionKey((base[i] as Section).title) === key) matched.add(i)\n\t\tconst target = base[index] as Section\n\t\tif (section.op === 'remove') slots[index] = undefined\n\t\telse if (section.op === 'combine') {\n\t\t\tconst baseBody = trimBlank(target.body)\n\t\t\tconst overlayBody = trimBlank(section.body)\n\t\t\tslots[index] = {\n\t\t\t\t...target,\n\t\t\t\tbody: baseBody.length && overlayBody.length ? [...baseBody, '', ...overlayBody] : [...baseBody, ...overlayBody],\n\t\t\t\tchildren: mergeChildren(target.children, section.children, `${path}${displayHeading(target)} > `, where, warn),\n\t\t\t}\n\t\t} else slots[index] = place(section, path, where, warn)\n\t}\n\treturn [...slots.filter((slot): slot is Section => slot !== undefined), ...appended]\n}\n\n/** `where` names the overlay in warnings, so a person can find the heading it is about. */\nexport function mergeSections(\n\tbase: SectionTree,\n\toverlay: SectionTree,\n\twhere: string,\n\twarn: (message: string) => void,\n): SectionTree {\n\tconst overlayPreamble = trimBlank(overlay.preamble)\n\treturn {\n\t\tpreamble: overlayPreamble.length ? overlayPreamble : base.preamble,\n\t\tchildren: mergeChildren(base.children, overlay.children, '', where, warn),\n\t}\n}\n\nexport function renderSections(tree: SectionTree): string {\n\tconst blocks: string[] = []\n\tconst preamble = trimBlank(tree.preamble)\n\tif (preamble.length) blocks.push(preamble.join('\\n'))\n\tconst visit = (section: Section) => {\n\t\tconst body = trimBlank(section.body)\n\t\tblocks.push(body.length ? `${section.heading}\\n\\n${body.join('\\n')}` : section.heading)\n\t\tfor (const child of section.children) visit(child)\n\t}\n\tfor (const section of tree.children) visit(section)\n\treturn `${blocks.join('\\n\\n')}\\n`\n}\n","import { type Dirent, readdirSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport {\n\ttype MergeMode,\n\tmergeSections,\n\tparseDocument,\n\tparseSections,\n\treadMergeMode,\n\trenderSections,\n\tstripMergeComments,\n} from './reference-document.ts'\nimport type { ReferenceLayer, ReferenceTier } from './reference-layers.ts'\n\nexport type ReferenceName = { name: string; plugin: string | undefined; raw: string }\n\nconst namePattern = /^[a-z0-9]+(?:[-.][a-z0-9]+)*$/i\nconst pluginPattern = /^(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]*$/i\n\n/**\n * Rejects rather than sanitizes — silently answering a different question is how untrusted input\n * reads a file outside the layer. The plugin qualifier is only ever compared with known plugin\n * names, never joined into a path.\n */\nexport function parseReferenceName(value: string): ReferenceName {\n\tif (value.endsWith('.md')) {\n\t\tthrow new Error(`\"${value}\" names a file. Ask for the reference by name, without the .md extension.`)\n\t}\n\tconst slash = value.lastIndexOf('/')\n\tconst name = slash === -1 ? value : value.slice(slash + 1)\n\tconst plugin = slash === -1 ? undefined : value.slice(0, slash)\n\tif (!namePattern.test(name) || (plugin !== undefined && !pluginPattern.test(plugin))) {\n\t\tthrow new Error(\n\t\t\t`\"${value}\" is not a reference name. A name is letters, digits, hyphens, and dots, optionally after \"<plugin>/\" — not a path.`,\n\t\t)\n\t}\n\treturn { name, plugin, raw: value }\n}\n\nconst folderCandidates = ['README.md', 'index.md', 'SKILL.md']\n\n/** Search order within one layer; the first that reads wins. */\nexport function candidateFiles(name: string): string[] {\n\treturn [`${name}.md`, ...folderCandidates.map((file) => `${name}/${file}`)]\n}\n\nexport type TraceEntry = {\n\ttier: ReferenceTier\n\tplugin: string\n\tpath: string\n\tfound: boolean\n\tcandidate: string\n\tmerge: string\n\toutcome: string\n\t/** The layer's own frontmatter `description`, so `list` can show it per row. */\n\tdescription: string\n}\n\nexport type UsedLayer = { tier: ReferenceTier; plugin: string; path: string; merge: MergeMode }\n\nexport type ReferenceStatus = 'found' | 'missing' | 'ambiguous'\n\nexport type ResolvedReference = {\n\tname: string\n\tstatus: ReferenceStatus\n\ttier?: ReferenceTier\n\tplugin?: string\n\tpath?: string\n\tmerge?: MergeMode\n\tmetadata?: Record<string, unknown>\n\tcontent?: string\n\tlayers: UsedLayer[]\n\twarnings: string[]\n\t/** Qualified names to ask for instead, when two plugins hold an unqualified name. */\n\tplugins: string[]\n\ttrace: TraceEntry[]\n}\n\ntype FoundDocument = {\n\tlayer: ReferenceLayer\n\tentry: TraceEntry\n\tmetadata: Record<string, unknown>\n\tbody: string\n\tmerge: MergeMode\n}\n\nexport type ResolveOptions = {\n\t/** How a path is shown in a label or a warning — the command collapses the home directory. */\n\tdisplay?: (path: string) => string\n}\n\nfunction tryRead(path: string): string | undefined {\n\ttry {\n\t\treturn readFileSync(path, 'utf8')\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nfunction pluginLabel(layer: ReferenceLayer): string {\n\treturn layer.plugins[0] ?? ''\n}\n\nfunction layerName(layer: ReferenceLayer): string {\n\treturn layer.tier === 'plugin' ? `plugin ${pluginLabel(layer)}` : layer.tier\n}\n\nfunction layersFor(ref: ReferenceName, layers: readonly ReferenceLayer[]): ReferenceLayer[] {\n\tconst plugin = ref.plugin\n\tif (plugin === undefined) return [...layers]\n\tconst named = layers.filter((layer) => layer.tier !== 'plugin' || layer.plugins.includes(plugin))\n\tif (named.some((layer) => layer.tier === 'plugin')) return named\n\t// A placeholder so the trace says the plugin asked for is not there, rather than saying nothing.\n\treturn [...named, { tier: 'plugin', dir: `(no dependency named ${plugin})`, plugins: [plugin], status: '' }]\n}\n\nexport function resolveReference(\n\tref: ReferenceName,\n\tlayers: readonly ReferenceLayer[],\n\t{ display = (path) => path }: ResolveOptions = {},\n): ResolvedReference {\n\tconst warnings: string[] = []\n\tconst trace: TraceEntry[] = []\n\tconst found: FoundDocument[] = []\n\n\tfor (const layer of layersFor(ref, layers)) {\n\t\tconst entry: TraceEntry = {\n\t\t\ttier: layer.tier,\n\t\t\tplugin: pluginLabel(layer),\n\t\t\tpath: layer.dir,\n\t\t\tfound: false,\n\t\t\tcandidate: '',\n\t\t\tmerge: '',\n\t\t\toutcome: 'missing',\n\t\t\tdescription: '',\n\t\t}\n\t\ttrace.push(entry)\n\t\tif (layer.skipped) {\n\t\t\tentry.outcome = layer.skipped\n\t\t\tcontinue\n\t\t}\n\t\tconst hits = candidateFiles(ref.name).flatMap((candidate) => {\n\t\t\tconst raw = tryRead(join(layer.dir, candidate))\n\t\t\treturn raw === undefined ? [] : [{ candidate, raw }]\n\t\t})\n\t\tconst [hit, ...ignored] = hits\n\t\tif (!hit) continue\n\t\tfor (const other of ignored) {\n\t\t\twarnings.push(\n\t\t\t\t`${display(join(layer.dir, other.candidate))} is ignored: ${hit.candidate} answers first in that folder`,\n\t\t\t)\n\t\t}\n\t\tconst path = join(layer.dir, hit.candidate)\n\t\tconst warn = (message: string) => warnings.push(`${display(path)}: ${message}`)\n\t\tconst { metadata, body } = parseDocument(hit.raw, warn)\n\t\tconst merge = readMergeMode(metadata, warn)\n\t\tconst description = typeof metadata['description'] === 'string' ? metadata['description'] : ''\n\t\tObject.assign(entry, { path, found: true, candidate: hit.candidate, merge, outcome: '', description })\n\t\tfound.push({ layer, entry, metadata, body, merge })\n\t}\n\n\tconst result: ResolvedReference = { name: ref.raw, status: 'missing', layers: [], warnings, plugins: [], trace }\n\n\tconst stop = found.findIndex(({ merge }) => merge === 'first-wins')\n\tconst chain = stop === -1 ? found : found.slice(0, stop + 1)\n\tconst shadowed = stop === -1 ? [] : found.slice(stop + 1)\n\tconst base = chain.at(-1)\n\n\t// Plugins are alternatives, not a stack: once resolution reaches the plugin tier, two plugins\n\t// holding the name leave nothing to choose between them.\n\tconst holders = [...new Set(found.filter(({ layer }) => layer.tier === 'plugin').map(({ entry }) => entry.plugin))]\n\tif (ref.plugin === undefined && holders.length > 1 && chain.some(({ layer }) => layer.tier === 'plugin')) {\n\t\tfor (const { entry } of found) entry.outcome = 'ambiguous'\n\t\tresult.status = 'ambiguous'\n\t\tresult.plugins = holders.map((plugin) => `${plugin}/${ref.name}`)\n\t\treturn result\n\t}\n\tfor (const document of shadowed) {\n\t\tdocument.entry.outcome = `shadowed by ${(base as FoundDocument).layer.tier} (first-wins)`\n\t}\n\tif (!base) return result\n\n\tfor (const { entry } of chain) entry.outcome = 'used'\n\tconst top = chain[0] as FoundDocument\n\treturn {\n\t\t...result,\n\t\tstatus: 'found',\n\t\ttier: top.layer.tier,\n\t\tplugin: top.entry.plugin,\n\t\tpath: top.entry.path,\n\t\tmerge: top.merge,\n\t\t// Lower layers first, so each document above overrides a key the one below also sets.\n\t\tmetadata: Object.assign({}, ...[...chain].reverse().map(({ metadata }) => metadata)),\n\t\tcontent: withNewline(stripMergeComments(fold(chain, display, (message) => warnings.push(message)))),\n\t\tlayers: chain.map(({ layer, entry, merge }) => ({\n\t\t\ttier: layer.tier,\n\t\t\tplugin: entry.plugin,\n\t\t\tpath: entry.path,\n\t\t\tmerge,\n\t\t})),\n\t}\n}\n\ntype Part = { labels: string[]; body: string }\n\n/** Bottom-up: the base is the lowest document read, and each document above says how it applies. */\nfunction fold(chain: readonly FoundDocument[], display: (path: string) => string, warn: (message: string) => void) {\n\tconst label = ({ layer, entry }: FoundDocument) => `${layerName(layer)} ${display(entry.path)}`\n\tconst [base, ...above] = [...chain].reverse() as [FoundDocument, ...FoundDocument[]]\n\tlet parts: Part[] = [{ labels: [label(base)], body: base.body }]\n\tfor (const document of above) {\n\t\tif (document.merge === 'combine') {\n\t\t\tparts = [{ labels: [label(document)], body: document.body }, ...parts]\n\t\t\tcontinue\n\t\t}\n\t\tconst below = parts.map(({ body }) => body.trim()).join('\\n\\n')\n\t\tconst merged = mergeSections(parseSections(below, warn), parseSections(document.body, warn), label(document), warn)\n\t\tparts = [{ labels: [label(document), ...parts.flatMap(({ labels }) => labels)], body: renderSections(merged) }]\n\t}\n\tif (parts.length === 1) return (parts[0] as Part).body\n\treturn [\n\t\t`> Combined from ${parts.length} layers, highest precedence first. Where they conflict, the first layer wins.`,\n\t\t...parts.map(({ labels, body }) => `<!-- layer: ${labels.join(', ')} -->\\n\\n${body.trim()}`),\n\t].join('\\n\\n')\n}\n\nfunction withNewline(content: string): string {\n\treturn content.endsWith('\\n') ? content : `${content}\\n`\n}\n\n/** Every name a layer holds in any candidate form; empty for a layer that is missing or unreadable. */\nexport function layerNames(dir: string): string[] {\n\tlet entries: Dirent[]\n\ttry {\n\t\tentries = readdirSync(dir, { withFileTypes: true })\n\t} catch {\n\t\treturn []\n\t}\n\tconst names = new Set<string>()\n\tfor (const entry of entries) {\n\t\tconst name = entry.isFile() && entry.name.endsWith('.md') ? entry.name.slice(0, -3) : entry.name\n\t\tif (!namePattern.test(name)) continue\n\t\tif (\n\t\t\tentry.isFile()\n\t\t\t\t? entry.name.endsWith('.md')\n\t\t\t\t: folderCandidates.some((file) => tryRead(join(dir, name, file)) !== undefined)\n\t\t) {\n\t\t\tnames.add(name)\n\t\t}\n\t}\n\treturn [...names]\n}\n\nexport function referenceNames(layers: readonly ReferenceLayer[]): string[] {\n\treturn [...new Set(layers.flatMap(({ dir, skipped }) => (skipped ? [] : layerNames(dir))))].sort((a, b) =>\n\t\ta.localeCompare(b),\n\t)\n}\n","import type { ReferenceLayer, ReferenceTier } from './reference-layers.ts'\nimport {\n\tparseReferenceName,\n\ttype ResolvedReference,\n\ttype ResolveOptions,\n\treferenceNames,\n\tresolveReference,\n} from './resolve-reference.ts'\n\nexport type ReferenceRow = {\n\tname: string\n\ttier: ReferenceTier\n\tplugin: string\n\tpath: string\n\tstatus: string\n\tdescription: string\n}\n\nexport type ReferenceListing = { rows: ReferenceRow[]; warnings: string[] }\n\n/** One row per name per layer holding it, with the status resolution gave that layer. */\nexport function listReferences(layers: readonly ReferenceLayer[], options: ResolveOptions = {}): ReferenceListing {\n\tconst rows: ReferenceRow[] = []\n\tconst warnings = new Set<string>()\n\tfor (const name of referenceNames(layers)) {\n\t\tconst resolved = resolveReference(parseReferenceName(name), layers, options)\n\t\tfor (const warning of resolved.warnings) warnings.add(warning)\n\t\tfor (const entry of resolved.trace) {\n\t\t\tif (!entry.found) continue\n\t\t\trows.push({\n\t\t\t\tname,\n\t\t\t\ttier: entry.tier,\n\t\t\t\tplugin: entry.plugin,\n\t\t\t\tpath: entry.path,\n\t\t\t\tstatus:\n\t\t\t\t\tentry.outcome === 'ambiguous' ? `ambiguous — ask for one of ${resolved.plugins.join(', ')}` : entry.outcome,\n\t\t\t\tdescription: entry.description,\n\t\t\t})\n\t\t}\n\t}\n\treturn { rows, warnings: [...warnings] }\n}\n\nexport type MatchKind = 'name' | 'prefix' | 'close name' | 'description' | 'heading' | 'body'\n\nconst matchOrder: readonly MatchKind[] = ['name', 'prefix', 'close name', 'description', 'heading', 'body']\n\nexport type SearchMatch = { name: string; tier: ReferenceTier; match: MatchKind; description: string }\n\nfunction distance(a: string, b: string): number {\n\tlet previous = Array.from({ length: b.length + 1 }, (_, i) => i)\n\tfor (let i = 1; i <= a.length; i++) {\n\t\tconst current = [i]\n\t\tfor (let j = 1; j <= b.length; j++) {\n\t\t\tconst substitution = (previous[j - 1] as number) + (a[i - 1] === b[j - 1] ? 0 : 1)\n\t\t\tcurrent.push(Math.min((previous[j] as number) + 1, (current[j - 1] as number) + 1, substitution))\n\t\t}\n\t\tprevious = current\n\t}\n\treturn previous[b.length] as number\n}\n\nfunction headings(content: string): string {\n\tlet fenced = false\n\tconst lines: string[] = []\n\tfor (const line of content.split('\\n')) {\n\t\tif (/^ {0,3}(`{3,}|~{3,})/.test(line)) fenced = !fenced\n\t\telse if (!fenced && /^ {0,3}#{1,6}\\s/.test(line)) lines.push(line)\n\t}\n\treturn lines.join('\\n')\n}\n\nfunction tagText(value: unknown): string {\n\tif (Array.isArray(value)) return value.map(String).join(' ')\n\treturn typeof value === 'string' ? value : ''\n}\n\nfunction matchKind(name: string, reference: ResolvedReference, query: string): MatchKind | undefined {\n\tconst bare = name.slice(name.lastIndexOf('/') + 1).toLowerCase()\n\tif (bare === query || name.toLowerCase() === query) return 'name'\n\tif (bare.startsWith(query)) return 'prefix'\n\tif (bare.includes(query) || distance(bare, query) <= Math.max(1, Math.floor(query.length / 4))) return 'close name'\n\tconst terms = query.split(/\\s+/)\n\tconst holds = (text: string) => {\n\t\tconst lower = text.toLowerCase()\n\t\treturn terms.every((term) => lower.includes(term))\n\t}\n\tconst metadata = reference.metadata as Record<string, unknown>\n\tconst description = typeof metadata['description'] === 'string' ? metadata['description'] : ''\n\tif (holds(`${description} ${tagText(metadata['tags'])}`)) return 'description'\n\tconst content = reference.content as string\n\tif (holds(headings(content))) return 'heading'\n\tif (holds(content)) return 'body'\n\treturn undefined\n}\n\n/**\n * Every name resolves the way `show` would; a name two plugins hold is searched once per plugin, as\n * the qualified name `show` would need.\n */\nexport function searchReferences(\n\tquery: string,\n\tlayers: readonly ReferenceLayer[],\n\toptions: ResolveOptions = {},\n): SearchMatch[] {\n\tconst normalized = query.trim().toLowerCase()\n\tconst matches: SearchMatch[] = []\n\tfor (const name of referenceNames(layers)) {\n\t\tconst resolved = resolveReference(parseReferenceName(name), layers, options)\n\t\tconst candidates =\n\t\t\tresolved.status === 'ambiguous'\n\t\t\t\t? resolved.plugins.map((qualified) => resolveReference(parseReferenceName(qualified), layers, options))\n\t\t\t\t: [resolved]\n\t\t// Every name listed is backed by a readable file, so each of these resolves as found.\n\t\tfor (const reference of candidates.filter(({ status }) => status === 'found')) {\n\t\t\tconst match = matchKind(reference.name, reference, normalized)\n\t\t\tif (!match) continue\n\t\t\tconst description = (reference.metadata as Record<string, unknown>)['description']\n\t\t\tmatches.push({\n\t\t\t\tname: reference.name,\n\t\t\t\ttier: reference.tier as ReferenceTier,\n\t\t\t\tmatch,\n\t\t\t\tdescription: typeof description === 'string' ? description.split('\\n')[0]?.trim() || '' : '',\n\t\t\t})\n\t\t}\n\t}\n\treturn matches.sort(\n\t\t(a, b) => matchOrder.indexOf(a.match) - matchOrder.indexOf(b.match) || a.name.localeCompare(b.name),\n\t)\n}\n","import { existsSync, readdirSync, readFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/**\n * Order here is search order. `package` is the only member that isn't an override —\n * `--overrides-only` promises never to return it.\n */\nexport type GovernanceScope = 'project' | 'user' | 'managed' | 'managed-deprecated' | 'package'\n\nexport type GovernanceLayer = { scope: GovernanceScope; dir: string }\n\n/** A governance located but not read: what `list` reports. */\nexport type GovernanceEntry = { name: string; scope: GovernanceScope; path: string }\n\n/** A governance located and read: what `show` reports. */\nexport type GovernanceDocument = GovernanceEntry & { content: string }\n\nexport type LayerOptions = {\n\troot: string\n\thome: string\n\tplatform: NodeJS.Platform\n\t/** `%ProgramData%`, read only on Windows. */\n\tprogramData?: string | undefined\n}\n\nexport function managedGovernancesDir(platform: NodeJS.Platform, programData?: string | undefined): string {\n\tif (platform === 'darwin') return '/Library/Application Support/BuddyAgentHarness/governances'\n\tif (platform === 'win32') return join(programData || 'C:\\\\ProgramData', 'BuddyAgentHarness', 'governances')\n\treturn '/etc/buddy-agent-harness/governances'\n}\n\n/**\n * Still read below the layer above, so a machine already using it keeps working; reported as\n * deprecated so an admin knows to move it.\n */\nexport function deprecatedManagedGovernancesDir(platform: NodeJS.Platform, programData?: string | undefined): string {\n\tif (platform === 'darwin') return '/Library/Application Support/UniPlugin/governances'\n\tif (platform === 'win32') return join(programData || 'C:\\\\ProgramData', 'UniPlugin', 'governances')\n\treturn '/etc/universal-plugin/governances'\n}\n\nexport function projectGovernancesDir(root: string): string {\n\treturn join(root, '.agents', 'governances')\n}\n\nexport function userGovernancesDir(home: string): string {\n\treturn join(home, '.agents', 'governances')\n}\n\n/**\n * Walks up to the nearest `package.json` rather than a relative literal — this module sits at a\n * different depth in `src/` vs the bundle.\n */\nexport function packageGovernancesDir(from: string = fileURLToPath(import.meta.url)): string {\n\tlet dir = dirname(from)\n\tfor (;;) {\n\t\tif (existsSync(join(dir, 'package.json'))) return join(dir, 'governances')\n\t\tconst parent = dirname(dir)\n\t\tif (parent === dir) return join(dir, 'governances')\n\t\tdir = parent\n\t}\n}\n\nexport function governanceLayers({ root, home, platform, programData }: LayerOptions): GovernanceLayer[] {\n\treturn [\n\t\t{ scope: 'project', dir: projectGovernancesDir(root) },\n\t\t{ scope: 'user', dir: userGovernancesDir(home) },\n\t\t{ scope: 'managed', dir: managedGovernancesDir(platform, programData) },\n\t\t{ scope: 'managed-deprecated', dir: deprecatedManagedGovernancesDir(platform, programData) },\n\t\t{ scope: 'package', dir: packageGovernancesDir() },\n\t]\n}\n\n/**\n * Filters by scope rather than slicing the list, so a layer added later can't quietly become an\n * override by position.\n */\nexport function overrideLayers(layers: readonly GovernanceLayer[]): GovernanceLayer[] {\n\treturn layers.filter((layer) => layer.scope !== 'package')\n}\n\nconst namePattern = /^[a-z0-9]+(?:[-.][a-z0-9]+)*$/i\n\n/**\n * Rejects rather than sanitizes — silently answering a different question is how untrusted input\n * reads a file outside the layer.\n */\nexport function parseGovernanceName(value: string): string {\n\t// Caught before the pattern, which would accept it and then look for `<name>.md.md`.\n\tif (value.endsWith('.md')) {\n\t\tthrow new Error(`\"${value}\" names a file. Ask for the governance by name, without the .md extension.`)\n\t}\n\tif (!namePattern.test(value)) {\n\t\tthrow new Error(`\"${value}\" is not a governance name. A name is letters, digits, hyphens, and dots — not a path.`)\n\t}\n\treturn value\n}\n\nfunction tryReadDocument(path: string): string | undefined {\n\ttry {\n\t\treturn readFileSync(path, 'utf8')\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/** Empty for a layer that's missing, unreadable, or not a directory — never throws. */\nfunction documentNames(dir: string): string[] {\n\ttry {\n\t\treturn readdirSync(dir, { withFileTypes: true })\n\t\t\t.filter((entry) => entry.isFile() && entry.name.endsWith('.md'))\n\t\t\t.map((entry) => entry.name.slice(0, -3))\n\t} catch {\n\t\treturn []\n\t}\n}\n\n/** The first layer that holds the name wins; the rest are not read. */\nexport function resolveGovernance(name: string, layers: readonly GovernanceLayer[]): GovernanceDocument | undefined {\n\tfor (const { scope, dir } of layers) {\n\t\tconst path = join(dir, `${name}.md`)\n\t\tconst content = tryReadDocument(path)\n\t\tif (content !== undefined) return { name, scope, path, content }\n\t}\n\treturn undefined\n}\n\n/** Every name any layer holds, each reported at the layer that would win, sorted by name. */\nexport function listGovernances(layers: readonly GovernanceLayer[]): GovernanceEntry[] {\n\tconst found = new Map<string, GovernanceEntry>()\n\tfor (const { scope, dir } of layers) {\n\t\tfor (const name of documentNames(dir)) {\n\t\t\tif (!found.has(name)) found.set(name, { name, scope, path: join(dir, `${name}.md`) })\n\t\t}\n\t}\n\treturn [...found.values()].sort((a, b) => a.name.localeCompare(b.name))\n}\n","import { join, posix, win32 } from 'node:path'\nimport {\n\tdetectHarness,\n\tenabledPlugins,\n\ttype HarnessEnvironment,\n\ttype HarnessId,\n\ttype InstalledPlugin,\n\tinstalledPlugins,\n\ttype ManagedPolicyKind,\n\tmanagedPolicyLocations,\n} from '@cyberuni/agent-harness'\nimport type { ReferenceLayer } from './reference-layers.ts'\n\ntype Env = Readonly<Record<string, string | undefined>>\n\n/** Nested harnesses leave `detectHarness` at `unknown`; each candidate is still a harness in play. */\nexport function detectedHarnesses(env: Env): readonly HarnessId[] {\n\treturn detectHarness({ env }).candidates\n}\n\nconst unreadableKind: Partial<Record<ManagedPolicyKind, string>> = {\n\t'macos-managed-preferences': 'a macOS managed-preferences domain delivered by MDM',\n\t'windows-registry': 'a Windows registry key delivered by MDM or Group Policy',\n\tserver: 'server-side settings',\n}\n\nfunction skippedLayer(\n\ttier: ReferenceLayer['tier'],\n\tdir: string,\n\tskipped: string,\n\tplugins: string[] = [],\n): ReferenceLayer {\n\treturn { tier, dir, plugins, status: skipped, skipped }\n}\n\n/**\n * The folder holding a harness's managed files gets a `references/` beside them. A `directory`\n * location inside that folder, such as a drop-in `managed-settings.d`, is part of it, not a folder\n * of its own.\n */\nfunction managedFolders(harness: HarnessId, platform: NodeJS.Platform, env: Env) {\n\tconst path = platform === 'win32' ? win32 : posix\n\tconst locations = managedPolicyLocations(harness, { platform, env })\n\tconst folders = [\n\t\t...new Set(\n\t\t\tlocations.flatMap(({ kind, location }) =>\n\t\t\t\tkind === 'file' ? [path.dirname(location)] : kind === 'directory' ? [location] : [],\n\t\t\t),\n\t\t),\n\t]\n\tconst outermost = folders.filter((folder) => !folders.some((other) => folder.startsWith(other + path.sep)))\n\treturn {\n\t\tread: outermost.map((folder) => path.join(folder, 'references')),\n\t\tunread: locations.flatMap(({ kind, location }) => {\n\t\t\tconst where = unreadableKind[kind]\n\t\t\treturn where\n\t\t\t\t? [{ location, reason: `not read — ${harness} keeps this policy in ${where}, which cannot be read locally` }]\n\t\t\t\t: []\n\t\t}),\n\t}\n}\n\nexport function harnessManagedLayers(\n\tharnesses: readonly HarnessId[],\n\tplatform: NodeJS.Platform,\n\tenv: Env,\n): ReferenceLayer[] {\n\tif (!harnesses.length) {\n\t\treturn [\n\t\t\tskippedLayer('managed', '(no harness detected)', 'not read — no harness detected, so no harness managed folder'),\n\t\t]\n\t}\n\treturn harnesses.flatMap((harness) => {\n\t\tconst { read, unread } = managedFolders(harness, platform, env)\n\t\treturn [\n\t\t\t...read.map((dir): ReferenceLayer => ({ tier: 'managed', dir, plugins: [], status: '' })),\n\t\t\t...unread.map(({ location, reason }) => skippedLayer('managed', location, reason)),\n\t\t]\n\t})\n}\n\n/**\n * Claude Code installs one plugin at several scopes; a project- or local-scoped install loads only in\n * its own project, so the nearest folder of the walk picks it, and a user install answers elsewhere.\n */\nfunction activeInstall(installs: readonly InstalledPlugin[], chain: readonly string[]): InstalledPlugin | undefined {\n\tfor (const dir of chain) {\n\t\tconst install = installs.find(({ projectPath }) => projectPath === dir)\n\t\tif (install) return install\n\t}\n\treturn installs.find(({ projectPath }) => projectPath === undefined)\n}\n\n/**\n * Only plugins the harness has enabled: installing a plugin never activates it, and a reference is\n * instruction text an agent follows.\n */\nexport async function enabledPluginLayers(\n\tharnesses: readonly HarnessId[],\n\tchain: readonly string[],\n\tenvironment: HarnessEnvironment,\n): Promise<ReferenceLayer[]> {\n\tconst layers: ReferenceLayer[] = []\n\tfor (const harness of harnesses) {\n\t\tconst [enabled, installed] = await Promise.all([\n\t\t\tenabledPlugins(harness, environment),\n\t\t\tinstalledPlugins(harness, environment),\n\t\t])\n\t\tif (!enabled.supported) {\n\t\t\tlayers.push(\n\t\t\t\tskippedLayer(\n\t\t\t\t\t'plugin',\n\t\t\t\t\t`(${harness} enabled plugins)`,\n\t\t\t\t\t`not read — ${harness} keeps no readable record of enabled plugins`,\n\t\t\t\t),\n\t\t\t)\n\t\t\tcontinue\n\t\t}\n\t\tif (enabled.unread.length) {\n\t\t\tlayers.push(\n\t\t\t\tskippedLayer(\n\t\t\t\t\t'plugin',\n\t\t\t\t\t`(${harness} plugin policy)`,\n\t\t\t\t\t`not read — ${enabled.unread.join('; ')} may also enable or disable ${harness} plugins`,\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t\tfor (const { id, enabled: on } of enabled.plugins) {\n\t\t\tif (!on) continue\n\t\t\tconst plugin = id.split('@')[0] as string\n\t\t\tconst install = activeInstall(\n\t\t\t\tinstalled.plugins.filter((candidate) => candidate.id === id),\n\t\t\t\tchain,\n\t\t\t)\n\t\t\tif (install) {\n\t\t\t\tlayers.push({ tier: 'plugin', dir: join(install.path, 'references'), plugins: [plugin], status: '' })\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tlayers.push(\n\t\t\t\tskippedLayer(\n\t\t\t\t\t'plugin',\n\t\t\t\t\t`(${id})`,\n\t\t\t\t\t`not read — enabled in ${harness}, but no install folder for this project is recorded`,\n\t\t\t\t\t[plugin],\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\t}\n\treturn layers\n}\n","import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs'\nimport { dirname, join, resolve } from 'node:path'\nimport { declaredDependencies } from '../dep-plugins/dep-plugins.ts'\nimport { packageDir } from '../dep-plugins/resolve.ts'\nimport {\n\tdeprecatedManagedGovernancesDir,\n\tmanagedGovernancesDir,\n\tpackageGovernancesDir,\n} from '../governance-overrides/governance-overrides.ts'\nimport { isRecord } from '../is-record/is-record.ts'\nimport { detectedHarnesses, enabledPluginLayers, harnessManagedLayers } from './harness-layers.ts'\n\n/** Order here is precedence order, highest first. */\nexport type ReferenceTier = 'managed' | 'project' | 'user' | 'plugin'\n\nexport type ReferenceLayer = {\n\ttier: ReferenceTier\n\tdir: string\n\t/** Every name a qualified `<plugin>/<name>` may use for this layer; empty outside the plugin tier. */\n\tplugins: string[]\n\t/** Empty unless the layer is legacy, deprecated, or skipped; then it says why. */\n\tstatus: string\n\t/** Set when the layer is never read, and why: policy held in MDM, or a plugin with no install folder. */\n\tskipped?: string\n}\n\nexport type ReferenceLayerOptions = {\n\troot: string\n\thome: string\n\tplatform: NodeJS.Platform\n\tprogramData?: string | undefined\n\t/** This package's own root, the `buddy-agent-harness` plugin. */\n\tpackageRoot?: string | undefined\n\t/** Detects the harness and reads its settings. Defaults to `process.env`. */\n\tenv?: Readonly<Record<string, string | undefined>>\n}\n\nexport const PACKAGE_PLUGIN = 'buddy-agent-harness'\nexport const LEGACY_STATUS = 'legacy — move these documents to references/ beside it'\nexport const DEPRECATED_STATUS = 'deprecated — move these documents to the managed references/ layer'\n\nexport function managedReferencesDir(platform: NodeJS.Platform, programData?: string | undefined): string {\n\treturn join(dirname(managedGovernancesDir(platform, programData)), 'references')\n}\n\nexport function projectReferencesDir(root: string): string {\n\treturn join(root, '.agents', 'references')\n}\n\nexport function projectReferenceLayers(root: string): ReferenceLayer[] {\n\treturn [\n\t\t{ tier: 'project', dir: projectReferencesDir(root), plugins: [], status: '' },\n\t\t{ tier: 'project', dir: join(root, '.agents', 'governances'), plugins: [], status: LEGACY_STATUS },\n\t]\n}\n\nfunction readJson(path: string): unknown {\n\ttry {\n\t\treturn JSON.parse(readFileSync(path, 'utf8'))\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nfunction isRepositoryRoot(dir: string): boolean {\n\tif (existsSync(join(dir, '.git')) || existsSync(join(dir, 'pnpm-workspace.yaml'))) return true\n\tconst manifest = readJson(join(dir, 'package.json'))\n\treturn isRecord(manifest) && manifest['workspaces'] !== undefined\n}\n\n/**\n * `root` and each folder above it up to the repository root, nearest first. With no repository root\n * above, `root` alone: a walk that never finds one would read every ancestor up to the filesystem root.\n */\nexport function projectChain(root: string): string[] {\n\tconst start = resolve(root)\n\tconst chain: string[] = []\n\tlet dir = start\n\tfor (;;) {\n\t\tchain.push(dir)\n\t\tif (isRepositoryRoot(dir)) return chain\n\t\tconst parent = dirname(dir)\n\t\tif (parent === dir) return [start]\n\t\tdir = parent\n\t}\n}\n\nfunction isDirectory(path: string): boolean {\n\ttry {\n\t\treturn statSync(path).isDirectory()\n\t} catch {\n\t\treturn false\n\t}\n}\n\nfunction nearestManifest(root: string): string | undefined {\n\tlet dir = root\n\tfor (;;) {\n\t\tconst path = join(dir, 'package.json')\n\t\tif (existsSync(path)) return path\n\t\tconst parent = dirname(dir)\n\t\tif (parent === dir) return undefined\n\t\tdir = parent\n\t}\n}\n\nfunction canonical(path: string): string {\n\ttry {\n\t\treturn realpathSync(path)\n\t} catch {\n\t\treturn path\n\t}\n}\n\n/**\n * Declared dependencies only: a transitive package never becomes a plugin, because a reference is\n * instruction text an agent follows.\n */\nfunction dependencyLayers(root: string, skip: ReadonlySet<string>): ReferenceLayer[] {\n\tconst manifestPath = nearestManifest(root)\n\tif (!manifestPath) return []\n\tconst layers: ReferenceLayer[] = []\n\tfor (const pkg of declaredDependencies(readJson(manifestPath))) {\n\t\tconst dir = packageDir(pkg, manifestPath)\n\t\tif (!dir || skip.has(canonical(dir))) continue\n\t\tconst references = join(dir, 'references')\n\t\tif (!isDirectory(references)) continue\n\t\tconst manifest = readJson(join(dir, 'plugin.json'))\n\t\tconst manifestName = isRecord(manifest) && typeof manifest['name'] === 'string' ? manifest['name'] : undefined\n\t\tconst plugins = manifestName && manifestName !== pkg ? [pkg, manifestName] : [pkg]\n\t\tlayers.push({ tier: 'plugin', dir: references, plugins, status: '' })\n\t}\n\treturn layers\n}\n\nexport async function referenceLayers({\n\troot,\n\thome,\n\tplatform,\n\tprogramData,\n\tpackageRoot = dirname(packageGovernancesDir()),\n\tenv = process.env,\n}: ReferenceLayerOptions): Promise<ReferenceLayer[]> {\n\tconst layer = (tier: ReferenceTier, dir: string, status = ''): ReferenceLayer => ({\n\t\ttier,\n\t\tdir,\n\t\tplugins: [],\n\t\tstatus,\n\t})\n\tconst self = [PACKAGE_PLUGIN]\n\tconst harnesses = detectedHarnesses(env)\n\tconst chain = projectChain(root)\n\tconst ownRoot = canonical(packageRoot)\n\tconst enabled = await enabledPluginLayers(harnesses, chain, { env, homedir: home, cwd: resolve(root), platform })\n\tconst layers: ReferenceLayer[] = [\n\t\tlayer('managed', managedReferencesDir(platform, programData)),\n\t\t...harnessManagedLayers(harnesses, platform, env),\n\t\tlayer('managed', managedGovernancesDir(platform, programData), LEGACY_STATUS),\n\t\tlayer('managed', deprecatedManagedGovernancesDir(platform, programData), DEPRECATED_STATUS),\n\t\t...chain.flatMap(projectReferenceLayers),\n\t\tlayer('user', join(home, '.agents', 'references')),\n\t\tlayer('user', join(home, '.agents', 'governances'), LEGACY_STATUS),\n\t\t{ tier: 'plugin', dir: join(packageRoot, 'references'), plugins: self, status: '' },\n\t\t{ tier: 'plugin', dir: join(packageRoot, 'governances'), plugins: self, status: LEGACY_STATUS },\n\t\t...enabled.filter(({ dir, skipped }) => skipped || (isDirectory(dir) && canonical(dirname(dir)) !== ownRoot)),\n\t\t...dependencyLayers(root, new Set([ownRoot])),\n\t]\n\t// A repository checked out at the home directory would read the same folder as project and user.\n\tconst seen = new Set<string>()\n\treturn layers.filter(({ dir }) => !seen.has(dir) && seen.add(dir))\n}\n","import { cpSync, lstatSync, mkdirSync, readdirSync, realpathSync, rmSync, symlinkSync } from 'node:fs'\nimport { platform } from 'node:os'\nimport { dirname, join, relative, resolve } from 'node:path'\nimport type { Harness, HarnessName } from '../harness-registry/harness-registry.ts'\n\nfunction skillNames(skillsDirectory: string): string[] {\n\treturn readdirSync(skillsDirectory, { withFileTypes: true })\n\t\t.filter((entry) => entry.isDirectory())\n\t\t.map((entry) => entry.name)\n\t\t.sort()\n}\n\nfunction pathOccupied(path: string): boolean {\n\ttry {\n\t\tlstatSync(path)\n\t\treturn true\n\t} catch {\n\t\treturn false\n\t}\n}\n\n/**\n * Compares resolved paths, not link text, so an absolute link, a Windows junction, or a link\n * reached through a parent symlink all read as correct.\n */\nexport function linksTo(target: string, canonical: string): boolean {\n\ttry {\n\t\tif (!lstatSync(target).isSymbolicLink()) return false\n\t\treturn realpathSync(target) === realpathSync(canonical)\n\t} catch {\n\t\treturn false\n\t}\n}\n\n/** Creates the canonical directory when absent, so a fresh repository reports zero skills. */\nexport function countSkills(canonicalSkills: string): number {\n\tmkdirSync(canonicalSkills, { recursive: true })\n\treturn skillNames(canonicalSkills).length\n}\n\n/**\n * Windows junctions resolve a relative target against the process directory, not the link's own, so\n * Windows gets an absolute path; everywhere else stays relative to survive the repository moving.\n */\nfunction linkTarget(target: string, canonicalSkills: string): string {\n\treturn platform() === 'win32' ? resolve(canonicalSkills) : relative(dirname(target), canonicalSkills)\n}\n\n/**\n * `true` = every conflicting target; a list names them individually so a run can't reach past what\n * it named; `false`/empty = none, which is what stops the run on conflict.\n */\nexport type ForceSelection = boolean | readonly string[]\n\n/**\n * A valueless `--force` arrives as the literal string `\"true\"` — the parser's flag encoding — and\n * means every target; anything else is a comma-separated list.\n */\nexport function parseForce(value: string): ForceSelection {\n\tif (value === 'true') return true\n\tif (value === 'false') return false\n\treturn value\n\t\t.split(',')\n\t\t.map((target) => target.trim())\n\t\t.filter((target) => target.length > 0)\n}\n\nexport type ProjectSkillsOptions = {\n\troot: string\n\tcanonicalSkills: string\n\tharnesses: readonly Harness[]\n\tcopy: boolean\n\tforce: ForceSelection\n}\n\nexport type ProjectSkillsResult = {\n\tlinked: HarnessName[]\n\tskipped: HarnessName[]\n}\n\n/**\n * Resolves both sides so the repo-relative path a conflict message prints also selects it back, and\n * so does an absolute path naming the same directory.\n */\nfunction namesTarget(root: string, target: string, given: string): boolean {\n\treturn resolve(root, given) === resolve(target)\n}\n\n/** Symlinks by default; falls back to a copy where the platform refuses the link. */\nexport function projectSkills({\n\troot,\n\tcanonicalSkills,\n\tharnesses,\n\tcopy,\n\tforce,\n}: ProjectSkillsOptions): ProjectSkillsResult {\n\tconst projections = harnesses\n\t\t.filter((harness) => harness.project.skillsDirectory)\n\t\t.map((harness) => ({\n\t\t\tharness,\n\t\t\ttarget: join(root, harness.project.skillsDirectory as string),\n\t\t}))\n\n\tconst named = Array.isArray(force) ? force : []\n\t// An unmatched force target is a typo, not a narrower run — ignoring it would misattribute the\n\t// conflict error it was meant to avoid.\n\tconst unknown = named.filter((given) => !projections.some(({ target }) => namesTarget(root, target, given)))\n\tif (unknown.length) {\n\t\tthrow new Error(\n\t\t\t`No skill target matches:\\n${unknown.map((given) => `- ${given}`).join('\\n')}\\n` +\n\t\t\t\t`Targets for the enabled harnesses:\\n${projections.map(({ target }) => `- ${relative(root, target)}`).join('\\n')}`,\n\t\t)\n\t}\n\n\tconst forces = (target: string): boolean => force === true || named.some((given) => namesTarget(root, target, given))\n\n\tconst conflicts = projections.filter(({ target }) => pathOccupied(target) && !linksTo(target, canonicalSkills))\n\tconst blocked = conflicts.filter(({ target }) => !forces(target))\n\n\t// No target named: nothing distinguishes one conflict from another, so refuse before writing.\n\t// A target named: the unnamed conflicts are what this run was told to leave alone, so skip and\n\t// report them instead of refusing.\n\tif (blocked.length && named.length === 0) {\n\t\tthrow new Error(\n\t\t\t`Refusing to replace existing skill targets:\\n${blocked.map(({ target }) => `- ${relative(root, target)}`).join('\\n')}`,\n\t\t)\n\t}\n\n\tconst skipped = new Set(blocked.map(({ harness }) => harness.name))\n\n\tfor (const { harness, target } of projections) {\n\t\tif (skipped.has(harness.name)) continue\n\t\tmkdirSync(dirname(target), { recursive: true })\n\t\tif (linksTo(target, canonicalSkills)) continue\n\t\tif (pathOccupied(target)) rmSync(target, { recursive: true, force: true })\n\t\tif (copy) {\n\t\t\tcpSync(canonicalSkills, target, { recursive: true })\n\t\t\tcontinue\n\t\t}\n\t\ttry {\n\t\t\tsymlinkSync(linkTarget(target, canonicalSkills), target, platform() === 'win32' ? 'junction' : undefined)\n\t\t} catch (error) {\n\t\t\tif (pathOccupied(target)) throw error\n\t\t\tcpSync(canonicalSkills, target, { recursive: true })\n\t\t}\n\t}\n\n\treturn {\n\t\tlinked: projections.filter(({ harness }) => !skipped.has(harness.name)).map(({ harness }) => harness.name),\n\t\tskipped: projections.filter(({ harness }) => skipped.has(harness.name)).map(({ harness }) => harness.name),\n\t}\n}\n","import { type Dirent, existsSync, readdirSync } from 'node:fs'\nimport { join, posix } from 'node:path'\n\n/** Directories that never hold instructions this repository is responsible for bridging. */\nconst pruned = new Set(['node_modules'])\n\n/**\n * Dot-directories are pruned along with `node_modules`: `.agents/AGENTS.md` is canonical shared\n * instructions, not a subtree-scoped file.\n */\nexport function agentsFileDirectories(root: string): string[] {\n\tconst found: string[] = []\n\n\tconst walk = (relative: string): void => {\n\t\tif (existsSync(join(root, relative, 'AGENTS.md'))) found.push(relative)\n\t\tlet entries: Dirent[]\n\t\ttry {\n\t\t\tentries = readdirSync(join(root, relative), { withFileTypes: true })\n\t\t} catch {\n\t\t\treturn\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tif (!entry.isDirectory() || entry.name.startsWith('.') || pruned.has(entry.name)) continue\n\t\t\twalk(relative ? posix.join(relative, entry.name) : entry.name)\n\t\t}\n\t}\n\n\twalk('')\n\treturn found.sort()\n}\n","import { lstatSync, readFileSync, readlinkSync } from 'node:fs'\nimport { join, posix } from 'node:path'\nimport type { Harness, HarnessName } from '../harness-registry/harness-registry.ts'\nimport type { InstructionBridge } from '../harness-registry/instruction-bridge.ts'\nimport { agentsFileDirectories } from './agents-files.ts'\nimport type { BridgeFinding } from './diagnose-bridges.ts'\nimport { type InstructionProblem, repairFor } from './doctor-guidance.ts'\nimport { parseJsonWithComments } from './json-with-comments.ts'\n\n/** What is on disk where an instruction bridge belongs, or where a shadowing file may sit. */\nexport type InstructionKind = 'import' | 'symlink' | 'settings-entry' | 'file' | 'none'\n/**\n * `shadowing` and `superseded` describe a file suppressing `AGENTS.md`, not a missing bridge;\n * `unbridged` is a bridge file present but not wired to it.\n */\nexport type InstructionStatus = 'ok' | 'missing' | 'unbridged' | 'unreadable' | 'shadowing' | 'superseded'\n\nexport type InstructionReport = {\n\tharness: HarnessName\n\t/** Repository-relative path of the file that carries the bridge, or that shadows `AGENTS.md`. */\n\tpath: string\n\tkind: InstructionKind\n\tstatus: InstructionStatus\n}\n\nexport const canonicalInstructions = 'AGENTS.md'\n\ntype Inspection = {\n\tkind: InstructionKind\n\tstatus: InstructionStatus\n\tproblem?: InstructionProblem\n}\n\n/** A shadow that is on disk always carries a problem: it is a fault, or an offer to remove it. */\ntype ShadowInspection = Inspection & { problem: InstructionProblem }\n\n/** Reads a dotted key out of parsed JSON without asserting anything about the rest of the file. */\nfunction valueAt(settings: unknown, key: string): unknown {\n\treturn key.split('.').reduce<unknown>((value, segment) => {\n\t\tif (typeof value !== 'object' || value === null) return undefined\n\t\treturn (value as Record<string, unknown>)[segment]\n\t}, settings)\n}\n\nfunction exists(target: string): boolean {\n\ttry {\n\t\tlstatSync(target)\n\t\treturn true\n\t} catch {\n\t\treturn false\n\t}\n}\n\nfunction inspectSettingsEntry(target: string, key: string): Inspection {\n\tlet source: string\n\ttry {\n\t\tsource = readFileSync(target, 'utf8')\n\t} catch {\n\t\treturn { kind: 'none', status: 'missing', problem: 'instructions-missing' }\n\t}\n\n\tconst settings = parseJsonWithComments(source)\n\tif (settings === undefined) return { kind: 'file', status: 'unreadable', problem: 'instructions-unreadable' }\n\n\tconst entry = valueAt(settings, key)\n\treturn Array.isArray(entry) && entry.includes(canonicalInstructions)\n\t\t? { kind: 'settings-entry', status: 'ok' }\n\t\t: { kind: 'file', status: 'unbridged', problem: 'instructions-unbridged' }\n}\n\nfunction inspectShadow(target: string): ShadowInspection | undefined {\n\tlet stats: ReturnType<typeof lstatSync>\n\ttry {\n\t\tstats = lstatSync(target)\n\t} catch {\n\t\treturn undefined\n\t}\n\n\tif (stats.isSymbolicLink())\n\t\treturn readlinkSync(target) === canonicalInstructions\n\t\t\t? { kind: 'symlink', status: 'superseded', problem: 'instructions-superseded' }\n\t\t\t: { kind: 'symlink', status: 'shadowing', problem: 'instructions-shadowing' }\n\n\tlet body: string\n\ttry {\n\t\tbody = readFileSync(target, 'utf8')\n\t} catch {\n\t\treturn { kind: 'file', status: 'unreadable', problem: 'instructions-unreadable' }\n\t}\n\n\tconst imported = body.split('\\n').some((line) => line.trim() === `@${canonicalInstructions}`)\n\treturn imported\n\t\t? { kind: 'import', status: 'superseded', problem: 'instructions-superseded' }\n\t\t: { kind: 'file', status: 'shadowing', problem: 'instructions-shadowing' }\n}\n\n/**\n * Checks two things: whether each instruction bridge resolves, and whether anything suppresses a\n * harness that reads `AGENTS.md` natively.\n */\nexport function diagnoseInstructions(\n\troot: string,\n\tharnesses: readonly Harness[],\n\tcli: string,\n): { instructions: InstructionReport[]; findings: BridgeFinding[] } {\n\t// Project scope only: the user-scope bridges are neither written nor read by this tool.\n\tconst bridged = harnesses\n\t\t.map((harness) => ({ name: harness.name, bridge: harness.project.instructionBridge }))\n\t\t.filter((harness): harness is { name: HarnessName; bridge: InstructionBridge } => Boolean(harness.bridge))\n\n\tconst instructions: InstructionReport[] = []\n\tconst findings: BridgeFinding[] = []\n\tconst directories = agentsFileDirectories(root)\n\n\t// Reported only when something depends on the file: a bridge pointing at it, or a shadow with\n\t// no canonical file beside it.\n\tconst shadowsAtRoot = harnesses.some((harness) =>\n\t\t(harness.project.shadowedBy ?? []).some((shadow) => exists(join(root, shadow))),\n\t)\n\tif ((bridged.length || shadowsAtRoot) && !directories.includes('')) {\n\t\tconst { detail, repair } = repairFor('no-instructions')\n\t\tfindings.push({\n\t\t\tpath: canonicalInstructions,\n\t\t\tproblem: 'no-instructions',\n\t\t\tdetail,\n\t\t\trepair: repair({ file: canonicalInstructions }, cli),\n\t\t})\n\t}\n\n\tfor (const { name, bridge } of bridged) {\n\t\tconst inspection = inspectSettingsEntry(join(root, bridge.path), bridge.key)\n\t\tinstructions.push({ harness: name, path: bridge.path, kind: inspection.kind, status: inspection.status })\n\t\tif (inspection.problem) {\n\t\t\tconst { detail, repair } = repairFor(inspection.problem)\n\t\t\tfindings.push({\n\t\t\t\tpath: bridge.path,\n\t\t\t\tproblem: inspection.problem,\n\t\t\t\tdetail,\n\t\t\t\trepair: repair({ file: bridge.path }, cli),\n\t\t\t})\n\t\t}\n\t}\n\n\t// Per directory holding an `AGENTS.md`, not per repository: a `CLAUDE.md` in one subtree says\n\t// nothing about another.\n\tfor (const harness of harnesses) {\n\t\tfor (const shadow of harness.project.shadowedBy ?? []) {\n\t\t\tfor (const directory of directories) {\n\t\t\t\tconst path = directory ? posix.join(directory, shadow) : shadow\n\t\t\t\tconst inspection = inspectShadow(join(root, path))\n\t\t\t\tif (!inspection) continue\n\t\t\t\t// Every shadow that is there is a finding; only its absence is silent.\n\t\t\t\tinstructions.push({ harness: harness.name, path, kind: inspection.kind, status: inspection.status })\n\t\t\t\tconst { detail, repair } = repairFor(inspection.problem)\n\t\t\t\tfindings.push({ path, problem: inspection.problem, detail, repair: repair({ file: path }, cli) })\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { instructions, findings }\n}\n","import { execFileSync } from 'node:child_process'\nimport { join } from 'node:path'\nimport { filesUnder } from './directory-files.ts'\n\n/** Which side of a diverged bridge moved since the last commit where the two agreed. */\nexport type DivergenceDirection = 'bridge' | 'canonical' | 'both' | 'unknown'\n\n/** Whether a path is tracked, and if so whether its skip-worktree bit is still set. */\nexport type TrackingState = 'untracked' | 'tracked' | 'skip-worktree'\n\nfunction git(root: string, args: string[], input?: string): string | undefined {\n\ttry {\n\t\treturn execFileSync('git', args, {\n\t\t\tcwd: root,\n\t\t\tencoding: 'utf8',\n\t\t\t...(input === undefined ? {} : { input }),\n\t\t\tstdio: ['pipe', 'pipe', 'pipe'],\n\t\t})\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nfunction lines(output: string | undefined): string[] {\n\treturn (output ?? '').split('\\n').filter(Boolean)\n}\n\n/**\n * Every method degrades to \"cannot tell\" rather than throwing, so `doctor` still reports on a\n * tarball or a repository with no commits.\n */\nexport class GitBridgeState {\n\t/** `''` at the top, `undefined` outside a repository. */\n\tprivate readonly repoRootPrefix: string | undefined\n\n\tconstructor(private readonly root: string) {\n\t\tthis.repoRootPrefix = git(root, ['rev-parse', '--show-prefix'])?.trim()\n\t}\n\n\t/** The skip-worktree bit is a hint some checkouts clear, so it is verified rather than assumed. */\n\ttrackingOf(path: string): TrackingState {\n\t\tif (this.repoRootPrefix === undefined) return 'untracked'\n\t\tconst entries = lines(git(this.root, ['ls-files', '-v', '--', path]))\n\t\tif (!entries.length) return 'untracked'\n\t\treturn entries.every((entry) => entry.startsWith('S')) ? 'skip-worktree' : 'tracked'\n\t}\n\n\t/**\n\t * Asked of git rather than matched against the file, so a rule on a parent directory is caught\n\t * too.\n\t */\n\tisIgnored(path: string): boolean {\n\t\tif (this.repoRootPrefix === undefined) return false\n\t\treturn git(this.root, ['check-ignore', '-q', '--', path]) !== undefined\n\t}\n\n\t/**\n\t * Bounded to the last 200 commits: a baseline outside that range costs more to find than it's\n\t * worth acting on.\n\t */\n\tcommitsTouching(paths: readonly string[]): string[] {\n\t\tif (this.repoRootPrefix === undefined) return []\n\t\treturn lines(git(this.root, ['rev-list', '-n', '200', 'HEAD', '--', ...paths]))\n\t}\n\n\t/** One file's content at one commit, or `undefined` when it did not exist there. */\n\tcontentAt(commit: string, path: string): string | undefined {\n\t\tif (this.repoRootPrefix === undefined) return undefined\n\t\treturn git(this.root, ['show', `${commit}:${this.repoRootPrefix}${path}`])\n\t}\n\n\tdirectionOf(bridge: string, canonical: string): DivergenceDirection {\n\t\tif (this.repoRootPrefix === undefined) return 'unknown'\n\t\tconst base = this.lastAgreedTree(bridge, canonical)\n\t\tif (base === undefined) return 'unknown'\n\t\tconst bridgeMoved = !this.matchesTree(bridge, base)\n\t\tconst canonicalMoved = !this.matchesTree(canonical, base)\n\t\tif (bridgeMoved && canonicalMoved) return 'both'\n\t\tif (bridgeMoved) return 'bridge'\n\t\treturn 'canonical'\n\t}\n\n\t/** The tree of the newest commit where both paths held identical content. */\n\tprivate lastAgreedTree(bridge: string, canonical: string): string | undefined {\n\t\tfor (const commit of lines(git(this.root, ['rev-list', '-n', '200', 'HEAD', '--', bridge, canonical]))) {\n\t\t\tconst bridgeObject = git(this.root, [\n\t\t\t\t'rev-parse',\n\t\t\t\t'-q',\n\t\t\t\t'--verify',\n\t\t\t\t`${commit}:${this.repoRootPrefix}${bridge}`,\n\t\t\t])?.trim()\n\t\t\tif (!bridgeObject) continue\n\t\t\tconst canonicalObject = git(this.root, [\n\t\t\t\t'rev-parse',\n\t\t\t\t'-q',\n\t\t\t\t'--verify',\n\t\t\t\t`${commit}:${this.repoRootPrefix}${canonical}`,\n\t\t\t])?.trim()\n\t\t\tif (bridgeObject === canonicalObject) return bridgeObject\n\t\t}\n\t\treturn undefined\n\t}\n\n\t/**\n\t * Compares by object id via `hash-object` rather than hashing in-process, so it follows\n\t * whatever object format the repository uses.\n\t */\n\tprivate matchesTree(directory: string, tree: string): boolean {\n\t\tconst expected = new Map(\n\t\t\tlines(git(this.root, ['ls-tree', '-r', tree])).map((entry) => {\n\t\t\t\tconst [meta, path] = entry.split('\\t')\n\t\t\t\treturn [path, (meta as string).split(' ')[2] as string] as const\n\t\t\t}),\n\t\t)\n\t\tconst files = filesUnder(join(this.root, directory))\n\t\tif (files.length !== expected.size || files.some((file) => !expected.has(file))) return false\n\t\tconst hashed = lines(\n\t\t\tgit(this.root, ['hash-object', '--stdin-paths'], files.map((file) => join(directory, file)).join('\\n')),\n\t\t)\n\t\treturn hashed.length === files.length && files.every((file, index) => expected.get(file) === hashed[index])\n\t}\n}\n","import { lstatSync, readFileSync, statSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { type HarnessName, selectHarnesses } from '../harness-registry/harness-registry.ts'\nimport { linksTo } from '../skill-projection/skill-projection.ts'\nimport { diagnoseInstructions, type InstructionReport } from './diagnose-instructions.ts'\nimport { filesUnder } from './directory-files.ts'\nimport { type BridgeProblem, type DoctorProblem, type RepairAction, repairFor } from './doctor-guidance.ts'\nimport { type DivergenceDirection, GitBridgeState } from './git-bridge-state.ts'\n\nexport type BridgeKind = 'symlink' | 'copy' | 'file' | 'none'\nexport type BridgeStatus = 'ok' | 'missing' | 'degraded' | 'stale' | 'diverged'\n\nexport type BridgeReport = {\n\tharness: HarnessName\n\t/** Repository-relative, as the harness registry declares it. */\n\tpath: string\n\tkind: BridgeKind\n\tstatus: BridgeStatus\n}\n\nexport type BridgeFinding = {\n\tpath: string\n\t/**\n\t * Emitted so a caller routes on a name rather than matching `detail` prose, which would break\n\t * when the wording changes.\n\t */\n\tproblem: DoctorProblem\n\tdetail: string\n\t/** What repairs this finding, already carrying the bridge path. Empty `command` means judgment. */\n\trepair: RepairAction\n}\n\nexport type DivergenceReport = {\n\tpath: string\n\tdirection: DivergenceDirection\n}\n\nexport type DiagnoseOptions = {\n\troot: string\n\tharnesses?: HarnessName[]\n\t/** How to name this tool in the repair commands. */\n\tcli: string\n}\n\nexport type DiagnoseResult = {\n\tbridges: BridgeReport[]\n\t/**\n\t * Kept out of `bridges` on purpose: a different `kind`/`status` vocabulary, and a repair that\n\t * is never a command.\n\t */\n\tinstructions: InstructionReport[]\n\tdivergence: DivergenceReport[]\n\tfindings: BridgeFinding[]\n}\n\nconst canonicalPath = '.agents/skills'\n\nfunction pathState(target: string): 'missing' | 'symlink' | 'directory' | 'file' {\n\ttry {\n\t\tconst stats = lstatSync(target)\n\t\tif (stats.isSymbolicLink()) return 'symlink'\n\t\treturn stats.isDirectory() ? 'directory' : 'file'\n\t} catch {\n\t\treturn 'missing'\n\t}\n}\n\nfunction isDirectory(path: string): boolean {\n\ttry {\n\t\treturn statSync(path).isDirectory()\n\t} catch {\n\t\treturn false\n\t}\n}\n\nfunction sameContent(left: string, right: string): boolean {\n\tconst leftFiles = filesUnder(left)\n\tconst rightFiles = filesUnder(right)\n\treturn (\n\t\tleftFiles.length === rightFiles.length &&\n\t\tleftFiles.every(\n\t\t\t(file, index) =>\n\t\t\t\trightFiles[index] === file && readFileSync(join(left, file)).equals(readFileSync(join(right, file))),\n\t\t)\n\t)\n}\n\ntype Inspection = {\n\tkind: BridgeKind\n\tstatus: BridgeStatus\n\tproblem?: BridgeProblem\n\tdirection?: DivergenceDirection\n}\n\nfunction inspect(target: string, path: string, canonical: string, git: GitBridgeState): Inspection {\n\tswitch (pathState(target)) {\n\t\tcase 'missing':\n\t\t\treturn { kind: 'none', status: 'missing', problem: 'missing' }\n\t\t// git with `core.symlinks=false` writes the link out as a regular file holding the target path.\n\t\tcase 'file':\n\t\t\treturn { kind: 'file', status: 'degraded', problem: 'degraded' }\n\t\t// The same test `init` uses to decide a projection is already correct.\n\t\tcase 'symlink':\n\t\t\treturn linksTo(target, canonical)\n\t\t\t\t? { kind: 'symlink', status: 'ok' }\n\t\t\t\t: { kind: 'symlink', status: 'stale', problem: 'stale' }\n\t\tdefault: {\n\t\t\tif (!sameContent(target, canonical)) {\n\t\t\t\tconst direction = git.directionOf(path, canonicalPath)\n\t\t\t\treturn { kind: 'copy', status: 'diverged', problem: `diverged-${direction}`, direction }\n\t\t\t}\n\t\t\t// Stays out of `git status` only while the skip-worktree bit survives.\n\t\t\treturn git.trackingOf(path) === 'tracked'\n\t\t\t\t? { kind: 'copy', status: 'ok', problem: 'unpinned-copy' }\n\t\t\t\t: { kind: 'copy', status: 'ok' }\n\t\t}\n\t}\n}\n\n/**\n * Read-only: nothing is created, moved, or repaired — the caller decides what to run from the\n * repair each finding carries.\n */\nexport function diagnoseBridges({ root, harnesses: preferred = [], cli }: DiagnoseOptions): DiagnoseResult {\n\tconst canonical = join(root, '.agents', 'skills')\n\tconst git = new GitBridgeState(root)\n\tconst selected = selectHarnesses(root, preferred)\n\tconst bridged = selected\n\t\t.map((harness) => ({ name: harness.name, skillsDirectory: harness.project.skillsDirectory }))\n\t\t.filter((harness): harness is { name: HarnessName; skillsDirectory: string } => Boolean(harness.skillsDirectory))\n\n\tconst bridges: BridgeReport[] = []\n\tconst divergence: DivergenceReport[] = []\n\tconst findings: BridgeFinding[] = []\n\n\tif (!isDirectory(canonical)) {\n\t\tconst { detail, repair } = repairFor('no-canonical')\n\t\tfindings.push({\n\t\t\tpath: canonicalPath,\n\t\t\tproblem: 'no-canonical',\n\t\t\tdetail,\n\t\t\trepair: repair({ file: canonicalPath }, cli),\n\t\t})\n\t}\n\n\tfor (const harness of bridged) {\n\t\tconst path = harness.skillsDirectory\n\t\tconst inspection = inspect(join(root, path), path, canonical, git)\n\t\tbridges.push({ harness: harness.name, path, kind: inspection.kind, status: inspection.status })\n\t\tif (inspection.direction) divergence.push({ path, direction: inspection.direction })\n\t\tif (inspection.problem) {\n\t\t\tconst { detail, repair } = repairFor(inspection.problem)\n\t\t\tfindings.push({ path, problem: inspection.problem, detail, repair: repair({ file: path }, cli) })\n\t\t}\n\t}\n\n\tconst instructions = diagnoseInstructions(root, selected, cli)\n\tfindings.push(...instructions.findings)\n\n\treturn { bridges, instructions: instructions.instructions, divergence, findings }\n}\n","import { homedir } from 'node:os'\nimport type { cli } from 'clibuilder'\nimport { command, exitCodes, z } from 'clibuilder'\nimport { collapseHome, displayBinPath, parseFormat, writeResult } from '../command-output/command-output.ts'\nimport { type ConfigurationFinding, diagnoseConfiguration } from '../diagnose-configuration/diagnose-configuration.ts'\nimport { diagnoseMcp } from '../diagnose-mcp/diagnose-mcp.ts'\nimport { diagnoseNonstandard } from '../diagnose-nonstandard/diagnose-nonstandard.ts'\nimport { parseHarnesses } from '../harness-registry/harness-registry.ts'\nimport { listReferences, type ReferenceRow } from '../references/reference-catalog.ts'\nimport { referenceLayers } from '../references/reference-layers.ts'\nimport { type DiagnoseResult, diagnoseBridges } from './diagnose-bridges.ts'\nimport { commandInvocation, type DoctorProblem, type RepairAction } from './doctor-guidance.ts'\nimport { GitBridgeState } from './git-bridge-state.ts'\n\nexport type DoctorReference = Pick<ReferenceRow, 'name' | 'tier' | 'path' | 'status'>\n\nexport type DoctorReport = {\n\tbin: string\n\tbridges: DiagnoseResult['bridges']\n\tinstructions: DiagnoseResult['instructions']\n\t/**\n\t * References the managed, project, and user tiers hold, with the status `reference list` gives;\n\t * reported rather than diagnosed, since a reference is a choice, not a fault.\n\t */\n\treferences: DoctorReference[] | string\n\tdivergence?: DiagnoseResult['divergence']\n\t/**\n\t * The repair is lifted out into `help`; `problem` stays on the row so a caller routes without\n\t * parsing `detail` prose.\n\t */\n\tfindings: { path: string; problem: DoctorProblem; detail: string }[] | string\n\t/**\n\t * One entry per distinct repair; `command` is always emitted, empty when there is none — an\n\t * optional key would break TOON's tabular form.\n\t */\n\thelp?: RepairAction[]\n}\n\n/**\n * AXI §5: the healthy answer states the zero with context, so an agent doesn't re-run to confirm\n * nothing was wrong.\n */\nexport function buildDoctorReport(\n\tbin: string,\n\tresult: DiagnoseResult,\n\tconfiguration: ConfigurationFinding[] = [],\n\theld: DoctorReference[] = [],\n): DoctorReport {\n\tconst findings = [...result.findings, ...configuration]\n\tconst references = held.length ? held : '0 references — no layer outside the plugin tier holds one'\n\t// Counted together so a reader doesn't add up two numbers to learn that nothing is wrong.\n\tif (!findings.length) {\n\t\tconst count = result.bridges.length + result.instructions.length\n\t\tconst bridges = count === 1 ? 'the 1 bridge resolves' : `all ${count} bridges resolve`\n\t\treturn {\n\t\t\tbin,\n\t\t\tbridges: result.bridges,\n\t\t\tinstructions: result.instructions,\n\t\t\treferences,\n\t\t\tfindings: `0 problems found — ${bridges} and the configuration around them is current`,\n\t\t}\n\t}\n\n\treturn {\n\t\tbin,\n\t\tbridges: result.bridges,\n\t\tinstructions: result.instructions,\n\t\treferences,\n\t\t...(result.divergence.length ? { divergence: result.divergence } : {}),\n\t\tfindings: findings.map(({ path, problem, detail }) => ({ path, problem, detail })),\n\t\t// Deduped on the whole pair: several findings often share one repair, and repeating it\n\t\t// reads as more work than there is.\n\t\thelp: [\n\t\t\t...new Map(\n\t\t\t\tfindings.map((finding) => [`${finding.repair.command}\\u0000${finding.repair.instruction}`, finding.repair]),\n\t\t\t).values(),\n\t\t],\n\t}\n}\n\nexport const doctorCommand: cli.Command = command({\n\tname: 'doctor',\n\tdescription:\n\t\t\"Report whether this repository's harness bridges still resolve — skills into .agents/skills, instructions into AGENTS.md. Read-only.\",\n\toptions: {\n\t\troot: {\n\t\t\tdescription: 'Repository or package directory. Defaults to the current directory.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\tharness: {\n\t\t\tdescription: 'Comma-separated harnesses to check in addition to Claude Code and Cursor, e.g. codex,gemini-cli.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\tformat: {\n\t\t\tdescription: 'Output format: toon (default), json, or text for a human-readable report.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'toon',\n\t\t},\n\t},\n\tasync run(args) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst harnesses = parseHarnesses(args.harness)\n\t\t\tconst root = args.root ?? process.cwd()\n\t\t\tconst home = homedir()\n\t\t\tconst result = diagnoseBridges({\n\t\t\t\troot,\n\t\t\t\t...(harnesses.length ? { harnesses } : {}),\n\t\t\t\tcli: commandInvocation,\n\t\t\t})\n\t\t\tconst git = new GitBridgeState(root)\n\t\t\tconst configuration = [\n\t\t\t\t...diagnoseConfiguration({ root, git, cli: commandInvocation }),\n\t\t\t\t...diagnoseMcp({ root, git, cli: commandInvocation }),\n\t\t\t\t...diagnoseNonstandard({ root, cli: commandInvocation }),\n\t\t\t]\n\t\t\tconst { rows } = listReferences(\n\t\t\t\tawait referenceLayers({\n\t\t\t\t\troot,\n\t\t\t\t\thome,\n\t\t\t\t\tplatform: process.platform,\n\t\t\t\t\tprogramData: process.env['ProgramData'],\n\t\t\t\t\tenv: process.env,\n\t\t\t\t}),\n\t\t\t)\n\t\t\t// Resolved across every tier so each status matches `reference list`, but plugin rows are\n\t\t\t// left out: what a plugin ships is its own business, not a repository setting.\n\t\t\tconst held = rows\n\t\t\t\t.filter(({ tier }) => tier !== 'plugin')\n\t\t\t\t.map(({ name, tier, path, status }) => ({ name, tier, path: collapseHome(home, path), status }))\n\t\t\t// Exit stays 0 even with findings: a non-zero code reads to an agent as \"this command\n\t\t\t// is broken\".\n\t\t\twriteResult(buildDoctorReport(displayBinPath(home, process.argv[1]), result, configuration, held), format)\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'Harness diagnosis failed.'}\\n`)\n\t\t\t// Returned, not written: a caller that is not the process has no other way to learn of\n\t\t\t// the failure.\n\t\t\treturn exitCodes.error\n\t\t}\n\t},\n})\n","import { homedir } from 'node:os'\nimport type { cli } from 'clibuilder'\nimport { command, exitCodes, z } from 'clibuilder'\nimport { collapseHome, parseFormat, writeDocument, writeResult } from '../command-output/command-output.ts'\nimport {\n\ttype GovernanceLayer,\n\ttype GovernanceScope,\n\tgovernanceLayers,\n\tlistGovernances,\n\toverrideLayers,\n\tparseGovernanceName,\n\tresolveGovernance,\n} from './governance-overrides.ts'\n\nexport type GovernanceListReport = {\n\t/**\n\t * `status` is always a string, not optional — an optional key would drop this array out of\n\t * TOON's tabular form into a nested list.\n\t */\n\tlayers: { scope: GovernanceScope; path: string; status: string }[]\n\t/** Emitted even when empty, so a healthy run states its zero explicitly. */\n\tgovernances: { name: string; scope: GovernanceScope; path: string }[] | string\n}\n\nexport type GovernanceShowReport = {\n\tname: string\n\tscope: GovernanceScope\n\tpath: string\n\tcontent: string\n}\n\ntype Args = { root: string | undefined; format: string | undefined; 'overrides-only': boolean | undefined }\n\nfunction layersFor(args: Args): GovernanceLayer[] {\n\tconst layers = governanceLayers({\n\t\troot: args.root ?? process.cwd(),\n\t\thome: homedir(),\n\t\tplatform: process.platform,\n\t\tprogramData: process.env['ProgramData'],\n\t})\n\treturn args['overrides-only'] ? overrideLayers(layers) : layers\n}\n\nexport const GOVERNANCE_DEPRECATED =\n\t'warning: \"governance\" is deprecated and will be removed in the next major version; use \"reference show|list\" instead.\\n'\n\nexport const DEPRECATED_MANAGED = 'deprecated — move these documents to the managed layer above'\n\nconst rootOption = {\n\tdescription: 'Repository or package directory. Defaults to the current directory.',\n\ttype: z.optional(z.string()),\n}\n\nconst overridesOnlyOption = {\n\tdescription:\n\t\t'Resolve only the project, user, and machine-wide layers. Never returns a governance this package ships, and exits non-zero when no layer has one.',\n\ttype: z.optional(z.boolean()),\n}\n\nexport const governanceListCommand: cli.Command = command({\n\tname: 'list',\n\tdescription: 'List every governance the override layers hold, each at the layer that would win.',\n\toptions: {\n\t\troot: rootOption,\n\t\t'overrides-only': overridesOnlyOption,\n\t\tformat: {\n\t\t\tdescription: 'Output format: toon (default), json, or text for a human-readable report.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'toon',\n\t\t},\n\t},\n\trun(args: Args) {\n\t\tprocess.stderr.write(GOVERNANCE_DEPRECATED)\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst home = homedir()\n\t\t\tconst layers = layersFor(args)\n\t\t\tconst entries = listGovernances(layers)\n\t\t\tconst report: GovernanceListReport = {\n\t\t\t\tlayers: layers.map(({ scope, dir }) => ({\n\t\t\t\t\tscope,\n\t\t\t\t\tpath: collapseHome(home, dir),\n\t\t\t\t\tstatus: scope === 'managed-deprecated' ? DEPRECATED_MANAGED : '',\n\t\t\t\t})),\n\t\t\t\tgovernances: entries.length\n\t\t\t\t\t? entries.map(({ name, scope, path }) => ({ name, scope, path: collapseHome(home, path) }))\n\t\t\t\t\t: '0 governances — no layer holds one',\n\t\t\t}\n\t\t\twriteResult(report, format)\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'Governance listing failed.'}\\n`)\n\t\t\treturn exitCodes.error\n\t\t}\n\t},\n})\n\nexport const governanceShowCommand: cli.Command = command({\n\tname: 'show',\n\tdescription: 'Print one governance document, resolved through the layers in order.',\n\targuments: [{ name: 'name', description: 'The governance name, without the `.md` extension.', type: z.string() }],\n\toptions: {\n\t\troot: rootOption,\n\t\t'overrides-only': overridesOnlyOption,\n\t\tformat: {\n\t\t\tdescription:\n\t\t\t\t'Output format: text (default) writes the document itself; toon and json wrap it with the layer it came from.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'text',\n\t\t},\n\t},\n\trun(args: Args & { name: string }) {\n\t\tprocess.stderr.write(GOVERNANCE_DEPRECATED)\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst name = parseGovernanceName(args.name)\n\t\t\tconst found = resolveGovernance(name, layersFor(args))\n\t\t\tif (!found) {\n\t\t\t\t// stderr, not stdout — a caller piping the document off stdout must never see this\n\t\t\t\t// prose\n\t\t\t\t// mixed in.\n\t\t\t\tprocess.stderr.write(\n\t\t\t\t\targs['overrides-only']\n\t\t\t\t\t\t? `error: no override for governance \"${name}\" in the project, user, or machine-wide layer.\\n`\n\t\t\t\t\t\t: `error: no governance named \"${name}\" in any layer.\\n`,\n\t\t\t\t)\n\t\t\t\treturn exitCodes.error\n\t\t\t}\n\t\t\tif (format === 'text') {\n\t\t\t\twriteDocument(found.content)\n\t\t\t} else {\n\t\t\t\tconst report: GovernanceShowReport = {\n\t\t\t\t\tname: found.name,\n\t\t\t\t\tscope: found.scope,\n\t\t\t\t\tpath: collapseHome(homedir(), found.path),\n\t\t\t\t\tcontent: found.content,\n\t\t\t\t}\n\t\t\t\twriteResult(report, format)\n\t\t\t}\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'Governance lookup failed.'}\\n`)\n\t\t\treturn exitCodes.error\n\t\t}\n\t},\n})\n\nexport const governanceCommand: cli.Command = command({\n\tname: 'governance',\n\tdescription:\n\t\t'Deprecated: use `reference`. Read the governance documents the project, user, and machine-wide override layers hold. Read-only.',\n\tcommands: [governanceListCommand, governanceShowCommand],\n})\n","import { homedir } from 'node:os'\nimport type { cli } from 'clibuilder'\nimport { command, exitCodes, z } from 'clibuilder'\nimport {\n\tcollapseHome,\n\ttype OutputFormat,\n\tparseFormat,\n\trenderText,\n\twriteDocument,\n\twriteResult,\n} from '../command-output/command-output.ts'\nimport { listReferences, type ReferenceRow, type SearchMatch, searchReferences } from './reference-catalog.ts'\nimport { type ReferenceLayer, type ReferenceTier, referenceLayers } from './reference-layers.ts'\nimport {\n\tparseReferenceName,\n\ttype ResolvedReference,\n\tresolveReference,\n\ttype TraceEntry,\n\ttype UsedLayer,\n} from './resolve-reference.ts'\n\n/** One per name asked, in the order asked — the contract the `reference` skill's Load mode builds on. */\nexport type ReferenceShowEntry = {\n\tname: string\n\tstatus: ResolvedReference['status']\n\ttier?: ReferenceTier\n\tplugin?: string\n\tpath?: string\n\tmerge?: string\n\tmetadata?: Record<string, unknown>\n\tcontent?: string\n\tlayers?: UsedLayer[]\n\twarnings: string[]\n\tsuggestions?: string[]\n\tplugins?: string[]\n\ttrace?: Omit<TraceEntry, 'description'>[]\n}\n\nexport type ReferenceListReport = {\n\tlayers: { tier: ReferenceTier; plugin: string; path: string; status: string }[]\n\t/** Emitted even when empty, so a healthy run states its zero explicitly. */\n\treferences: ReferenceRow[] | string\n\twarnings?: string[]\n}\n\nexport type ReferenceSearchReport = { query: string; references: SearchMatch[] | string }\n\ntype CommonArgs = { root: string | undefined; format: string | undefined }\n\nconst rootOption = {\n\tdescription:\n\t\t'Directory the project tier is read from, and each folder above it up to the repository root. Defaults to the current directory.',\n\ttype: z.optional(z.string()),\n}\n\nfunction layersFor(args: CommonArgs, home: string): Promise<ReferenceLayer[]> {\n\treturn referenceLayers({\n\t\troot: args.root ?? process.cwd(),\n\t\thome,\n\t\tplatform: process.platform,\n\t\tprogramData: process.env['ProgramData'],\n\t\tenv: process.env,\n\t})\n}\n\nfunction fail(error: unknown, fallback: string): number {\n\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : fallback}\\n`)\n\treturn exitCodes.error\n}\n\nfunction showEntry(\n\tresolved: ResolvedReference,\n\thome: string,\n\tsuggestions: string[],\n\ttrace: boolean,\n): ReferenceShowEntry {\n\tconst entry: ReferenceShowEntry = { name: resolved.name, status: resolved.status, warnings: [] }\n\tif (resolved.status === 'found') {\n\t\tObject.assign(entry, {\n\t\t\ttier: resolved.tier,\n\t\t\tplugin: resolved.plugin,\n\t\t\tpath: collapseHome(home, resolved.path as string),\n\t\t\tmerge: resolved.merge,\n\t\t\tmetadata: resolved.metadata,\n\t\t\tcontent: resolved.content,\n\t\t\tlayers: resolved.layers.map((layer) => ({ ...layer, path: collapseHome(home, layer.path) })),\n\t\t})\n\t}\n\tif (resolved.status === 'missing') entry.suggestions = suggestions\n\tif (resolved.status === 'ambiguous') entry.plugins = resolved.plugins\n\tentry.warnings = resolved.warnings\n\tif (trace) {\n\t\tentry.trace = resolved.trace.map(({ description: _, ...step }) => ({\n\t\t\t...step,\n\t\t\tpath: collapseHome(home, step.path),\n\t\t}))\n\t}\n\treturn entry\n}\n\nfunction missReason(entry: ReferenceShowEntry): string {\n\tif (entry.status === 'ambiguous') {\n\t\treturn `\"${entry.name}\" is held by more than one plugin; ask for one of ${(entry.plugins as string[]).join(', ')}.`\n\t}\n\tconst hint = entry.suggestions?.length ? ` Did you mean: ${entry.suggestions.join(', ')}?` : ''\n\treturn `no reference named \"${entry.name}\" in any tier.${hint}`\n}\n\nfunction writeShowText(entries: readonly ReferenceShowEntry[]): void {\n\tif (entries.length === 1) {\n\t\tconst [entry] = entries as [ReferenceShowEntry]\n\t\tif (entry.content !== undefined) writeDocument(entry.content)\n\t\treturn\n\t}\n\tconst blocks = entries.map((entry) =>\n\t\tentry.content === undefined\n\t\t\t? `<reference name=\"${entry.name}\" status=\"${entry.status}\" />`\n\t\t\t: `<reference name=\"${entry.name}\" tier=\"${entry.tier}\">\\n${entry.content}</reference>`,\n\t)\n\twriteDocument(blocks.join('\\n\\n'))\n}\n\nfunction writeShowStderr(entries: readonly ReferenceShowEntry[], format: OutputFormat): void {\n\tfor (const entry of entries) {\n\t\tif (format === 'text') {\n\t\t\tfor (const warning of entry.warnings) process.stderr.write(`warning: ${warning}\\n`)\n\t\t\tif (entry.trace) process.stderr.write(`${renderText({ [`trace ${entry.name}`]: entry.trace })}\\n`)\n\t\t}\n\t\tif (entry.status !== 'found') process.stderr.write(`error: ${missReason(entry)}\\n`)\n\t}\n}\n\nexport const referenceShowCommand: cli.Command = command({\n\tname: 'show',\n\tdescription: 'Print one or more references, each resolved through the tiers and combined as its layers ask.',\n\targuments: [\n\t\t{\n\t\t\tname: 'names',\n\t\t\tdescription: 'Reference names, without the `.md` extension; `<plugin>/<name>` picks one plugin.',\n\t\t\ttype: z.array(z.string()),\n\t\t},\n\t],\n\toptions: {\n\t\troot: rootOption,\n\t\ttrace: {\n\t\t\tdescription: 'Report every path checked, the file that matched, the merge mode, and why a layer was dropped.',\n\t\t\ttype: z.optional(z.boolean()),\n\t\t},\n\t\tformat: {\n\t\t\tdescription:\n\t\t\t\t'Output format: text (default) writes the documents themselves; toon and json return an array with metadata.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'text',\n\t\t},\n\t},\n\tasync run(args: CommonArgs & { names: string[]; trace: boolean | undefined }) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst names = args.names.map(parseReferenceName)\n\t\t\tif (!names.length) throw new Error('Name at least one reference.')\n\t\t\tconst home = homedir()\n\t\t\tconst layers = await layersFor(args, home)\n\t\t\tconst display = (path: string) => collapseHome(home, path)\n\t\t\tconst entries = names.map((name) => {\n\t\t\t\tconst resolved = resolveReference(name, layers, { display })\n\t\t\t\tconst suggestions =\n\t\t\t\t\tresolved.status === 'missing'\n\t\t\t\t\t\t? searchReferences(name.name, layers, { display })\n\t\t\t\t\t\t\t\t.slice(0, 3)\n\t\t\t\t\t\t\t\t.map((match) => match.name)\n\t\t\t\t\t\t: []\n\t\t\t\treturn showEntry(resolved, home, suggestions, Boolean(args.trace))\n\t\t\t})\n\t\t\tif (format === 'text') writeShowText(entries)\n\t\t\telse writeResult(entries, format)\n\t\t\twriteShowStderr(entries, format)\n\t\t\treturn entries.every((entry) => entry.status === 'found') ? exitCodes.success : exitCodes.error\n\t\t} catch (error) {\n\t\t\treturn fail(error, 'Reference lookup failed.')\n\t\t}\n\t},\n})\n\nconst listFormatOption = {\n\tdescription: 'Output format: toon (default), json, or text for a human-readable report.',\n\ttype: z.optional(z.string()),\n\tdefault: 'toon',\n}\n\nexport const referenceListCommand: cli.Command = command({\n\tname: 'list',\n\tdescription: 'List every layer, and every reference at every layer that holds it, marked used or shadowed.',\n\toptions: { root: rootOption, format: listFormatOption },\n\tasync run(args: CommonArgs) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst home = homedir()\n\t\t\tconst layers = await layersFor(args, home)\n\t\t\tconst { rows, warnings } = listReferences(layers, { display: (path) => collapseHome(home, path) })\n\t\t\tconst report: ReferenceListReport = {\n\t\t\t\tlayers: layers.map(({ tier, plugins, dir, status }) => ({\n\t\t\t\t\ttier,\n\t\t\t\t\tplugin: plugins[0] ?? '',\n\t\t\t\t\tpath: collapseHome(home, dir),\n\t\t\t\t\tstatus,\n\t\t\t\t})),\n\t\t\t\treferences: rows.length\n\t\t\t\t\t? rows.map((row) => ({ ...row, path: collapseHome(home, row.path) }))\n\t\t\t\t\t: '0 references — no layer holds one',\n\t\t\t}\n\t\t\tif (warnings.length) report.warnings = warnings\n\t\t\twriteResult(report, format)\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\treturn fail(error, 'Reference listing failed.')\n\t\t}\n\t},\n})\n\nexport const referenceSearchCommand: cli.Command = command({\n\tname: 'search',\n\tdescription: 'Find references by name, description, tags, headings, or body, best match first.',\n\targuments: [{ name: 'query', description: 'What the reference is about.', type: z.string() }],\n\toptions: { root: rootOption, format: listFormatOption },\n\tasync run(args: CommonArgs & { query: string }) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst query = args.query.trim()\n\t\t\tif (!query) throw new Error('Search needs a query.')\n\t\t\tconst home = homedir()\n\t\t\tconst matches = searchReferences(query, await layersFor(args, home), {\n\t\t\t\tdisplay: (path) => collapseHome(home, path),\n\t\t\t})\n\t\t\tconst report: ReferenceSearchReport = {\n\t\t\t\tquery,\n\t\t\t\treferences: matches.length ? matches : `0 references match \"${query}\"`,\n\t\t\t}\n\t\t\twriteResult(report, format)\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\treturn fail(error, 'Reference search failed.')\n\t\t}\n\t},\n})\n\nexport const referenceCommand: cli.Command = command({\n\tname: 'reference',\n\tdescription:\n\t\t'Read on-demand reference documents by name, layered across the managed, project, user, and plugin tiers. Read-only.',\n\tcommands: [referenceShowCommand, referenceListCommand, referenceSearchCommand],\n})\n","import { mkdirSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { type HarnessName, selectHarnesses } from '../harness-registry/harness-registry.ts'\nimport { projectReferenceLayers, projectReferencesDir } from '../references/reference-layers.ts'\nimport { referenceNames } from '../references/resolve-reference.ts'\nimport { countSkills, type ForceSelection, projectSkills } from '../skill-projection/skill-projection.ts'\n\nexport type InitializeOptions = {\n\troot: string\n\tharnesses?: HarnessName[]\n\tcopy?: boolean\n\tforce?: ForceSelection\n}\nexport type InitializeResult = {\n\troot: string\n\tharnesses: HarnessName[]\n\tnative: HarnessName[]\n\tlinked: HarnessName[]\n\t/**\n\t * Enabled harnesses left untouched because their target conflicts and `--force` did not name\n\t * it.\n\t */\n\tskipped: HarnessName[]\n\t/** Enabled harnesses whose name has been superseded, as `{ name, replacedBy }`. */\n\tdeprecated: { name: HarnessName; replacedBy: HarnessName }[]\n\tskills: number\n\t/**\n\t * References the project tier holds, legacy `governances/` included; `.agents/references` is\n\t * created when absent and counted, like `skills`, so a fresh repo reports zero rather than\n\t * leaving it unclear.\n\t */\n\treferences: number\n\tcopied: boolean\n}\n\nexport function initializeHarnesses({\n\troot,\n\tharnesses: preferred = [],\n\tcopy = false,\n\tforce = false,\n}: InitializeOptions): InitializeResult {\n\tconst canonicalSkills = join(root, '.agents', 'skills')\n\tconst skills = countSkills(canonicalSkills)\n\tmkdirSync(projectReferencesDir(root), { recursive: true })\n\tconst references = referenceNames(projectReferenceLayers(root)).length\n\tconst harnesses = selectHarnesses(root, preferred)\n\tconst { linked, skipped } = projectSkills({ root, canonicalSkills, harnesses, copy, force })\n\n\treturn {\n\t\troot,\n\t\tharnesses: harnesses.map((harness) => harness.name),\n\t\tnative: harnesses.filter((harness) => !harness.project.skillsDirectory).map((harness) => harness.name),\n\t\tlinked,\n\t\tskipped,\n\t\tdeprecated: harnesses\n\t\t\t.filter((harness) => harness.deprecated)\n\t\t\t.map((harness) => ({ name: harness.name, replacedBy: harness.deprecated as HarnessName })),\n\t\tskills,\n\t\treferences,\n\t\tcopied: copy,\n\t}\n}\n","import type { cli } from 'clibuilder'\nimport { command, exitCodes, z } from 'clibuilder'\nimport { parseFormat, writeResult } from '../command-output/command-output.ts'\nimport { doctorCommand } from '../diagnose-bridges/doctor.command.ts'\nimport { governanceCommand } from '../governance-overrides/governance.command.ts'\nimport { parseHarnesses } from '../harness-registry/harness-registry.ts'\nimport { referenceCommand } from '../references/reference.command.ts'\nimport { parseForce } from '../skill-projection/skill-projection.ts'\nimport { initializeHarnesses } from './initialize-harnesses.ts'\n\nexport const initCommand: cli.Command = command({\n\tname: 'init',\n\tdescription: 'Set up canonical agent skills for the harnesses already enabled in a repository.',\n\toptions: {\n\t\troot: {\n\t\t\tdescription: 'Repository or package directory. Defaults to the current directory.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\tharness: {\n\t\t\tdescription: 'Comma-separated harnesses to enable in addition to Claude Code and Cursor, e.g. codex,gemini-cli.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\tcopy: {\n\t\t\tdescription: 'Copy skills instead of linking them.',\n\t\t\ttype: z.optional(z.boolean()),\n\t\t},\n\t\tforce: {\n\t\t\tdescription:\n\t\t\t\t'Replace conflicting target skill directories. Names the targets to replace, comma-separated (e.g. .claude/skills); given alone it replaces every conflicting target.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\tformat: {\n\t\t\tdescription: 'Output format: toon (default), json, or text for a human-readable report.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'toon',\n\t\t},\n\t},\n\trun(args) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst harnesses = parseHarnesses(args.harness)\n\t\t\twriteResult(\n\t\t\t\tinitializeHarnesses({\n\t\t\t\t\troot: args.root ?? process.cwd(),\n\t\t\t\t\t...(harnesses.length ? { harnesses } : {}),\n\t\t\t\t\t...(args.copy === undefined ? {} : { copy: args.copy }),\n\t\t\t\t\t...(args.force === undefined ? {} : { force: parseForce(args.force) }),\n\t\t\t\t}),\n\t\t\t\tformat,\n\t\t\t)\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'Harness initialization failed.'}\\n`)\n\t\t\t// Returned, not written — writing it here reports failure past `run`, not to it, so a\n\t\t\t// non-process caller never learns of it.\n\t\t\treturn exitCodes.error\n\t\t}\n\t},\n})\n\n// Named `agent-harness`, not `harness` — `repobuddy` mounts every plugin into one namespace, and\n// `harness` is generic enough to collide.\nexport const harnessCommand: cli.Command = command({\n\tname: 'agent-harness',\n\tdescription: 'Commands for configuring agent harness compatibility.',\n\tcommands: [initCommand, doctorCommand, referenceCommand, governanceCommand],\n})\n\nexport function activate({ addCommand }: { addCommand(command: typeof harnessCommand): void }): void {\n\taddCommand(harnessCommand)\n}\n","import { stringify as stringifyToml } from 'smol-toml'\nimport { type AST, parseTOML } from 'toml-eslint-parser'\nimport type { ConfigEdit } from './config-edit.ts'\n\nfunction nested(path: string[], value: Record<string, unknown>): Record<string, unknown> {\n\treturn path.reduceRight<Record<string, unknown>>((inner, key) => ({ [key]: inner }), value)\n}\n\n/** `value` as the table at `path`, with its sub-tables, in the form `smol-toml` writes it. */\nexport function renderTomlTable(path: string[], value: Record<string, unknown>): string {\n\treturn stringifyToml(nested(path, value))\n}\n\n/** Appends the table at `path` after the last byte of `source`, which stays as it is. */\nexport function appendTomlTable(source: string, path: string[], value: Record<string, unknown>): string {\n\tconst separator = source === '' || source.endsWith('\\n') ? '' : '\\n'\n\treturn `${source}${separator}\\n${renderTomlTable(path, value)}`\n}\n\nfunction keyNames(key: AST.TOMLKey): string[] {\n\treturn key.keys.map((part) => (part.type === 'TOMLBare' ? part.name : part.value))\n}\n\nfunction startsWith(key: readonly (string | number)[], prefix: string[]): boolean {\n\treturn prefix.length <= key.length && prefix.every((part, index) => key[index] === part)\n}\n\n/** Either key names a place inside the other, so a value at one defines or holds the other. */\nfunction overlaps(key: string[], path: string[]): boolean {\n\treturn startsWith(key, path) || startsWith(path, key)\n}\n\n/**\n * Replaces the table at `path` and every `[path.*]` sub-table, wherever they sit, keeping every\n * byte outside them. Only the `[table]` header form is replaced: a table written inline or as\n * dotted keys, or holding an array of tables, is refused as `shape`, and so is one whose header is\n * only implied by a sub-table. `smol-toml` keeps no source offsets, so `toml-eslint-parser`\n * locates the tables; values still come from `smol-toml`.\n */\nexport function replaceTomlTable(source: string, path: string[], value: Record<string, unknown>): ConfigEdit {\n\tlet program: AST.TOMLProgram\n\ttry {\n\t\tprogram = parseTOML(source)\n\t} catch {\n\t\treturn { kind: 'refused', reason: 'unreadable' }\n\t}\n\tconst owned: AST.TOMLTable[] = []\n\tfor (const node of program.body[0].body) {\n\t\tif (node.type === 'TOMLKeyValue') {\n\t\t\tif (overlaps(keyNames(node.key), path)) return { kind: 'refused', reason: 'shape' }\n\t\t\tcontinue\n\t\t}\n\t\tif (startsWith(node.resolvedKey, path)) {\n\t\t\tif (node.kind === 'array') return { kind: 'refused', reason: 'shape' }\n\t\t\towned.push(node)\n\t\t\tcontinue\n\t\t}\n\t\tconst table = node.resolvedKey as string[]\n\t\tif (node.body.some((pair) => overlaps([...table, ...keyNames(pair.key)], path)))\n\t\t\treturn { kind: 'refused', reason: 'shape' }\n\t}\n\tif (!owned.length) return { kind: 'refused', reason: 'absent' }\n\tif (!owned.some((table) => table.resolvedKey.length === path.length)) return { kind: 'refused', reason: 'shape' }\n\t// A table's range ends at its last value; a comment after that value on the same line is still its.\n\tconst spans = owned.map((table): [number, number] => {\n\t\tconst lineEnd = source.slice(table.range[1]).search(/\\r?\\n/)\n\t\treturn [table.range[0], lineEnd < 0 ? source.length : table.range[1] + lineEnd]\n\t})\n\tconst inside = (offset: number) => spans.some(([start, end]) => start <= offset && offset < end)\n\tif (program.comments.some((comment) => inside(comment.range[0]))) return { kind: 'refused', reason: 'comment' }\n\n\tconst [first, ...rest] = spans as [[number, number], ...[number, number][]]\n\tlet text = source\n\tfor (const [start, end] of rest.reverse()) {\n\t\tconst before = text.slice(0, start)\n\t\tconst after = text.slice(end).replace(/^\\r?\\n/, '')\n\t\ttext = /\\n\\r?\\n$/.test(before) ? `${before}${after.replace(/^\\r?\\n/, '')}` : `${before}${after}`\n\t}\n\tconst rendered = renderTomlTable(path, value).trimEnd()\n\treturn { kind: 'edited', text: `${text.slice(0, first[0])}${rendered}${text.slice(first[1])}` }\n}\n\nconst bareKey = /^[A-Za-z0-9_-]+$/\n\nfunction tomlKey(name: string): string {\n\treturn bareKey.test(name) ? name : JSON.stringify(name)\n}\n\n/** One value in TOML inline syntax: a map stays on its line as an inline table, not a sub-table. */\nexport function renderTomlInline(value: unknown): string {\n\tif (typeof value === 'object' && value !== null && !Array.isArray(value))\n\t\treturn `{ ${Object.entries(value)\n\t\t\t.map(([name, item]) => `${tomlKey(name)} = ${renderTomlInline(item)}`)\n\t\t\t.join(', ')} }`\n\treturn stringifyToml({ v: value }).slice('v = '.length).trimEnd()\n}\n\n/**\n * Appends the table at `path` with every value inline, so a later field edit finds each value on\n * one line of that table rather than in a sub-table.\n */\nexport function appendInlineTomlTable(source: string, path: string[], value: Record<string, unknown>): string {\n\tconst separator = source === '' || source.endsWith('\\n') ? '' : '\\n'\n\tconst lines = Object.entries(value).map(([name, item]) => `${tomlKey(name)} = ${renderTomlInline(item)}\\n`)\n\treturn `${source}${separator}\\n[${path.map(tomlKey).join('.')}]\\n${lines.join('')}`\n}\n\nfunction lineEndAt(source: string, offset: number): number {\n\tconst end = source.indexOf('\\n', offset)\n\treturn end === -1 ? source.length : end\n}\n\n/**\n * Sets, adds, or (with `undefined`) removes the one key `name` of the `[path]` table, keeping every\n * byte outside that key-value line. Only a key written directly in the table's own `[header]` form\n * is taken apart: a table written inline or as dotted keys is `absent`, and a key spread over dotted\n * keys or a sub-table is `shape`.\n */\nexport function setTomlKey(source: string, path: string[], name: string, value: unknown): ConfigEdit {\n\tlet program: AST.TOMLProgram\n\ttry {\n\t\tprogram = parseTOML(source)\n\t} catch {\n\t\treturn { kind: 'refused', reason: 'unreadable' }\n\t}\n\tconst tables = program.body[0].body.filter((node): node is AST.TOMLTable => node.type === 'TOMLTable')\n\tconst table = tables.find(\n\t\t(node) => node.kind === 'standard' && node.resolvedKey.length === path.length && startsWith(node.resolvedKey, path),\n\t)\n\tif (!table) return { kind: 'refused', reason: 'absent' }\n\tconst pairs = table.body\n\tconst spread =\n\t\ttables.some((node) => startsWith(node.resolvedKey, [...path, name])) ||\n\t\tpairs.some((pair) => keyNames(pair.key)[0] === name && pair.key.keys.length > 1)\n\tif (spread) return { kind: 'refused', reason: 'shape' }\n\n\tconst pair = pairs.find((item) => item.key.keys.length === 1 && keyNames(item.key)[0] === name)\n\tif (pair && value !== undefined)\n\t\treturn {\n\t\t\tkind: 'edited',\n\t\t\ttext: `${source.slice(0, pair.value.range[0])}${renderTomlInline(value)}${source.slice(pair.value.range[1])}`,\n\t\t}\n\tif (pair) {\n\t\t// TOML holds one key-value per line, so the whole line and its trailing comment go with it.\n\t\tconst start = source.lastIndexOf('\\n', pair.range[0] - 1) + 1\n\t\tconst end = lineEndAt(source, pair.range[1])\n\t\treturn { kind: 'edited', text: `${source.slice(0, start)}${source.slice(Math.min(end + 1, source.length))}` }\n\t}\n\tif (value === undefined) return { kind: 'edited', text: source }\n\tconst after = lineEndAt(source, pairs.at(-1)?.range[1] ?? table.range[0])\n\treturn {\n\t\tkind: 'edited',\n\t\ttext: `${source.slice(0, after)}\\n${tomlKey(name)} = ${renderTomlInline(value)}${source.slice(after)}`,\n\t}\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport { appendInlineTomlTable, renderTomlInline, setTomlKey } from '../config-edit/toml-edit.ts'\nimport type { GitBridgeState } from '../diagnose-bridges/git-bridge-state.ts'\nimport { locatorText, type Position } from '../diagnose-bridges/locator.ts'\nimport {\n\tformatProjectionRecord,\n\tMcpBaseline,\n\tparseProjectionRecord,\n\tprojectionRecordPath,\n} from '../diagnose-mcp/mcp-baseline.ts'\nimport { divergingFields, type McpField, type McpServer, mcpFields, sameField } from '../diagnose-mcp/mcp-model.ts'\nimport { credentialFields, nonSecretArgs } from '../diagnose-mcp/mcp-secrets.ts'\nimport { goldenSetPath, mcpTargets, parseGoldenSet, parseTarget } from '../diagnose-mcp/mcp-sources.ts'\nimport type { McpConfig } from '../harness-registry/mcp-config.ts'\nimport { isRecord } from '../is-record/is-record.ts'\nimport { mcpDialects } from '../mcp-dialects/mcp-dialects.ts'\n\n/**\n * `import` is offered and waits for approval; `imported` was approved and written; `edit` was\n * approved but cannot be spliced in byte-safely, so `value` is for a person to apply; `skip` and\n * `refuse` are never importable, whatever is approved.\n */\nexport type ReconcileAction = 'import' | 'imported' | 'edit' | 'skip' | 'refuse'\n\nexport type ReconcileRow = {\n\t/** The locator `doctor` reports, and what `--accept` names to approve this one field. */\n\tpath: string\n\taction: ReconcileAction\n\tdetail: string\n\t/** The field as it would read in the golden set; never set on a row refusing a credential. */\n\tvalue?: string\n}\n\nexport type ReconcilePlan =\n\t| { kind: 'absent' }\n\t| { kind: 'unreadable'; position?: Position | undefined }\n\t/** An approval named something not importable; nothing was written. */\n\t| { kind: 'rejected'; reasons: string[] }\n\t| { kind: 'planned'; rows: ReconcileRow[]; written: boolean }\n\nexport type ReconcileMcpOptions = {\n\troot: string\n\tgit: GitBridgeState\n\t/** The locators approved, one field each. Empty is a dry run. */\n\taccept: readonly string[]\n}\n\ntype Offer = {\n\trow: ReconcileRow\n\tconfig: McpConfig\n\tserver: string\n\tfield: McpField\n\t/** `undefined` removes the field from the golden set. */\n\tvalue: unknown\n\tcarried: McpServer\n\t/** The golden server does not exist yet: approving adds it. */\n\tadds: boolean\n}\n\nfunction read(root: string, path: string): string | undefined {\n\tconst absolute = join(root, path)\n\treturn existsSync(absolute) ? readFileSync(absolute, 'utf8') : undefined\n}\n\nconst held = {\n\tboth: 'both sides changed since the last projection — a three-way conflict for a person to settle, never imported',\n\tunknown: 'no baseline says which side changed — compare the two by hand; never imported',\n}\n\n/** Transport the golden set would infer anyway: stating it would record the harness's spelling, not a choice. */\nfunction inferredTransport(server: McpServer): McpServer['transport'] {\n\treturn server.url === undefined ? 'stdio' : 'http'\n}\n\n/** Only the names the golden set speaks for: a name only the harness carries is never compared, so never pulled. */\nfunction mapValue(declared: unknown, carried: unknown): Record<string, string> | undefined {\n\tconst kept = Object.entries(declared as Record<string, string>).flatMap(([name]) => {\n\t\tconst value = isRecord(carried) ? carried[name] : undefined\n\t\treturn typeof value === 'string' ? [[name, value]] : []\n\t})\n\treturn kept.length ? Object.fromEntries(kept) : undefined\n}\n\nexport function reconcileMcp({ root, git, accept }: ReconcileMcpOptions): ReconcilePlan {\n\tconst goldenSource = read(root, goldenSetPath)\n\tconst golden = parseGoldenSet(goldenSource)\n\tif (golden.kind !== 'servers') return golden\n\n\tconst record = parseProjectionRecord(read(root, projectionRecordPath))\n\tconst baseline = new McpBaseline({ git, record })\n\tconst rows: ReconcileRow[] = []\n\tconst offers: Offer[] = []\n\n\tfor (const config of mcpTargets(root)) {\n\t\tconst parsed = parseTarget(config, read(root, config.path))\n\t\tif (parsed.kind === 'unreadable') {\n\t\t\trows.push({ path: config.path, action: 'refuse', detail: 'the target does not parse' })\n\t\t\tcontinue\n\t\t}\n\t\tif (parsed.kind === 'absent') continue\n\t\tconst dialect = mcpDialects[config.dialect]\n\n\t\tfor (const [server, carried] of parsed.servers) {\n\t\t\tconst declared = golden.servers.get(server)\n\t\t\tconst at = (field: string) => locatorText({ file: config.path, server, field })\n\t\t\tconst offer = (field: McpField, proposed: unknown) => {\n\t\t\t\tconst literals = literalsIn(field, proposed)\n\t\t\t\tfor (const literal of literals)\n\t\t\t\t\trows.push({\n\t\t\t\t\t\tpath: at(literal),\n\t\t\t\t\t\taction: 'refuse',\n\t\t\t\t\t\tdetail: `${literal} holds a literal credential, which never enters the golden set — set it in the environment and reference it as \\${VAR}`,\n\t\t\t\t\t})\n\t\t\t\tconst value = withoutLiterals(field, proposed, literals, declared)\n\t\t\t\tif (literals.length && (value === undefined || sameField(field, { [field]: value }, declared))) return\n\t\t\t\tconst fallback = dialect.defaults?.[field]\n\t\t\t\tif (fallback !== undefined && sameField(field, { [field]: value }, { [field]: fallback })) {\n\t\t\t\t\trows.push({\n\t\t\t\t\t\tpath: at(field),\n\t\t\t\t\t\taction: 'skip',\n\t\t\t\t\t\tdetail: `${config.dialect} fills this in by default, so it may not be the user's — set it in the golden set by hand if it is`,\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst row: ReconcileRow = {\n\t\t\t\t\tpath: at(field),\n\t\t\t\t\taction: 'import',\n\t\t\t\t\tdetail: declared\n\t\t\t\t\t\t? 'only the harness changed it — approve to take it into the golden set'\n\t\t\t\t\t\t: 'the golden set does not declare this server — approve each field to add it',\n\t\t\t\t\tvalue: value === undefined ? '(unset)' : `${field} = ${renderTomlInline(value)}`,\n\t\t\t\t}\n\t\t\t\trows.push(row)\n\t\t\t\toffers.push({ row, config, server, field, value, carried, adds: !declared })\n\t\t\t}\n\n\t\t\tif (!declared) {\n\t\t\t\tfor (const field of mcpFields) {\n\t\t\t\t\tif (!dialect.fields.has(field) || carried[field] === undefined) continue\n\t\t\t\t\tif (field === 'transport' && carried.transport === inferredTransport(carried)) continue\n\t\t\t\t\toffer(field, carried[field])\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const field of divergingFields(declared, carried, dialect.fields)) {\n\t\t\t\tconst direction = baseline.directionOf(config, server, field, declared, carried)\n\t\t\t\t// The golden side ahead is `mcp project`'s to write, not this command's.\n\t\t\t\tif (direction === 'golden') continue\n\t\t\t\tif (direction === 'target')\n\t\t\t\t\toffer(\n\t\t\t\t\t\tfield,\n\t\t\t\t\t\tfield === 'env' || field === 'headers' ? mapValue(declared[field], carried[field]) : carried[field],\n\t\t\t\t\t)\n\t\t\t\telse rows.push({ path: at(field), action: 'skip', detail: held[direction] })\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!accept.length) return { kind: 'planned', rows, written: false }\n\tconst approved = approve(offers, rows, accept)\n\tif (approved.kind === 'rejected') return approved\n\n\tlet source = goldenSource as string\n\tconst imported: Offer[] = []\n\tfor (const [server, group] of groupByServer(approved.offers)) {\n\t\tif (group[0]?.adds) {\n\t\t\tconst added: McpServer = Object.fromEntries(\n\t\t\t\tmcpFields.flatMap((field) => {\n\t\t\t\t\tconst offer = group.find((item) => item.field === field)\n\t\t\t\t\treturn offer ? [[field, offer.value]] : []\n\t\t\t\t}),\n\t\t\t)\n\t\t\tsource = land(source, appendInlineTomlTable(source, ['servers', server], added), server, added, group, imported)\n\t\t\tcontinue\n\t\t}\n\t\tfor (const offer of group) {\n\t\t\tconst current = parseGoldenSet(source) as { kind: 'servers'; servers: Map<string, McpServer> }\n\t\t\tconst expected = { ...current.servers.get(server), [offer.field]: offer.value }\n\t\t\tif (offer.value === undefined) delete expected[offer.field]\n\t\t\tconst edit = setTomlKey(source, ['servers', server], offer.field, offer.value)\n\t\t\tsource = land(source, edit.kind === 'edited' ? edit.text : undefined, server, expected, [offer], imported)\n\t\t}\n\t}\n\n\tif (source !== goldenSource) {\n\t\twriteFileSync(join(root, goldenSetPath), source)\n\t\twriteRecord(\n\t\t\troot,\n\t\t\trecord,\n\t\t\tbaseline,\n\t\t\timported,\n\t\t\tparseGoldenSet(source) as { kind: 'servers'; servers: Map<string, McpServer> },\n\t\t)\n\t}\n\treturn { kind: 'planned', rows, written: true }\n}\n\nfunction literalsIn(field: McpField, value: unknown): string[] {\n\tif (value === undefined) return []\n\tif (field === 'args') return nonSecretArgs(value as string[]).length === (value as string[]).length ? [] : ['args']\n\tif (field !== 'env' && field !== 'headers' && field !== 'url') return []\n\treturn credentialFields({ [field]: value })\n}\n\n/**\n * A map keeps its other names, and a refused name keeps what the golden set already says for it;\n * any other field holding a literal is refused whole.\n */\nfunction withoutLiterals(\n\tfield: McpField,\n\tvalue: unknown,\n\tliterals: string[],\n\tdeclared: McpServer | undefined,\n): unknown {\n\tif (!literals.length) return value\n\tif (field !== 'env' && field !== 'headers') return undefined\n\tconst kept = { ...(value as Record<string, string>) }\n\tfor (const literal of literals) {\n\t\tconst name = literal.slice(field.length + 1)\n\t\tconst golden = declared?.[field]?.[name]\n\t\tif (golden === undefined) delete kept[name]\n\t\telse kept[name] = golden\n\t}\n\treturn Object.keys(kept).length ? kept : undefined\n}\n\nfunction approve(\n\toffers: Offer[],\n\trows: ReconcileRow[],\n\taccept: readonly string[],\n): { kind: 'rejected'; reasons: string[] } | { kind: 'approved'; offers: Offer[] } {\n\tconst reasons: string[] = []\n\tconst chosen: Offer[] = []\n\tfor (const path of new Set(accept)) {\n\t\tconst offer = offers.find((item) => item.row.path === path)\n\t\tif (offer) chosen.push(offer)\n\t\telse {\n\t\t\tconst row = rows.find((item) => item.path === path)\n\t\t\treasons.push(\n\t\t\t\trow ? `${path} is ${row.action}, not importable: ${row.detail}` : `${path} names no importable field`,\n\t\t\t)\n\t\t}\n\t}\n\tfor (const [server, group] of groupByServer(chosen)) {\n\t\tfor (const field of new Set(group.map((offer) => offer.field))) {\n\t\t\tconst values = group.filter((offer) => offer.field === field)\n\t\t\tif (values.some((offer) => !sameField(field, { [field]: offer.value }, { [field]: values[0]?.value })))\n\t\t\t\treasons.push(\n\t\t\t\t\t`servers.${server}.${field} is approved from more than one target with different values — approve one`,\n\t\t\t\t)\n\t\t}\n\t\tif (group[0]?.adds && !group.some((offer) => offer.field === 'command' || offer.field === 'url'))\n\t\t\treasons.push(`servers.${server} would be added with nothing to run — approve its command or url too`)\n\t}\n\treturn reasons.length ? { kind: 'rejected', reasons } : { kind: 'approved', offers: chosen }\n}\n\nfunction groupByServer(offers: Offer[]): Map<string, Offer[]> {\n\tconst groups = new Map<string, Offer[]>()\n\tfor (const offer of offers) groups.set(offer.server, [...(groups.get(offer.server) ?? []), offer])\n\treturn groups\n}\n\n/**\n * Accepts the new text only when it reads back as the expected server with every other server\n * untouched; anything else is handed over as an `edit`, never written on trust.\n */\nfunction land(\n\tsource: string,\n\tnext: string | undefined,\n\tserver: string,\n\texpected: McpServer,\n\toffers: Offer[],\n\timported: Offer[],\n): string {\n\tconst before = parseGoldenSet(source) as { kind: 'servers'; servers: Map<string, McpServer> }\n\tconst after = next === undefined ? undefined : parseGoldenSet(next)\n\tconst holds =\n\t\tafter?.kind === 'servers' &&\n\t\t// A transport the text leaves unstated reads back inferred.\n\t\tmcpFields.every(\n\t\t\t(field) =>\n\t\t\t\t(field === 'transport' && expected.transport === undefined) ||\n\t\t\t\tsameField(field, after.servers.get(server), expected),\n\t\t) &&\n\t\t[...before.servers].every(\n\t\t\t([name, kept]) => name === server || JSON.stringify(after.servers.get(name)) === JSON.stringify(kept),\n\t\t)\n\tfor (const offer of offers) {\n\t\toffer.row.action = holds ? 'imported' : 'edit'\n\t\toffer.row.detail = holds\n\t\t\t? 'written into the golden set'\n\t\t\t: 'the golden set writes this server in a shape that cannot be edited byte-safely — apply the value by hand'\n\t}\n\tif (!holds) return source\n\timported.push(...offers)\n\treturn next as string\n}\n\n/**\n * The imported field now agrees on both sides. A server the record has no entry for is recorded\n * only when every other field's baseline is known, so the record never asserts an agreement no\n * baseline supports.\n */\nfunction writeRecord(\n\troot: string,\n\trecord: Map<string, Map<string, McpServer>>,\n\tbaseline: McpBaseline,\n\timported: Offer[],\n\tgolden: { servers: Map<string, McpServer> },\n): void {\n\tfor (const offer of imported) {\n\t\tconst servers = record.get(offer.config.path) ?? new Map<string, McpServer>()\n\t\tconst recorded = servers.get(offer.server)\n\t\tconst entry = recorded\n\t\t\t? { ...recorded, [offer.field]: offer.value }\n\t\t\t: baseEntry(offer, baseline, golden.servers.get(offer.server) as McpServer)\n\t\tif (!entry) continue\n\t\tif (offer.value === undefined) delete entry[offer.field]\n\t\tservers.set(offer.server, entry)\n\t\trecord.set(offer.config.path, servers)\n\t}\n\tconst absolute = join(root, projectionRecordPath)\n\tmkdirSync(dirname(absolute), { recursive: true })\n\twriteFileSync(absolute, formatProjectionRecord(record))\n}\n\nfunction baseEntry(offer: Offer, baseline: McpBaseline, golden: McpServer): McpServer | undefined {\n\tif (offer.adds) return { ...golden }\n\tconst entry: Record<string, unknown> = {}\n\tfor (const field of mcpDialects[offer.config.dialect].fields) {\n\t\tif (golden[field] === undefined) continue\n\t\tif (sameField(field, golden, offer.carried)) {\n\t\t\tentry[field] = golden[field]\n\t\t\tcontinue\n\t\t}\n\t\tconst base = baseline.baseFor(offer.config, offer.server, field)\n\t\tif (!base) return undefined\n\t\tentry[field] = base[field]\n\t}\n\treturn entry as McpServer\n}\n","import type { cli } from 'clibuilder'\nimport { command, exitCodes, z } from 'clibuilder'\nimport { parseFormat, writeResult } from '../command-output/command-output.ts'\nimport { GitBridgeState } from '../diagnose-bridges/git-bridge-state.ts'\nimport { projectionRecordPath } from '../diagnose-mcp/mcp-baseline.ts'\nimport { goldenSetPath } from '../diagnose-mcp/mcp-sources.ts'\nimport { type ReconcileRow, reconcileMcp } from './reconcile-mcp.ts'\n\nexport type ReconcileReport = {\n\tgolden: string\n\tmode: string\n\t/** Emitted even when empty, so a run that finds nothing states its zero. */\n\tfields: ReconcileRow[] | string\n\trecord: string\n}\n\nexport const mcpReconcileCommand: cli.Command = command({\n\tname: 'reconcile',\n\tdescription:\n\t\t'Import a harness-side MCP change into the golden set, one approved field at a time. A dry run unless --accept names a field.',\n\toptions: {\n\t\troot: {\n\t\t\tdescription: 'Repository or package directory. Defaults to the current directory.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\taccept: {\n\t\t\tdescription:\n\t\t\t\t'Approve one field by the path a dry run lists for it; repeat for each field. There is no approve-all.',\n\t\t\ttype: z.optional(z.array(z.string())),\n\t\t},\n\t\tformat: {\n\t\t\tdescription: 'Output format: toon (default), json, or text for a human-readable report.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'toon',\n\t\t},\n\t},\n\trun(args) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst root = args.root ?? process.cwd()\n\t\t\tconst accept = args.accept ?? []\n\t\t\tconst plan = reconcileMcp({ root, git: new GitBridgeState(root), accept })\n\t\t\tif (plan.kind === 'unreadable') {\n\t\t\t\t// Position only: the parser's message quotes the line, and that line may hold a credential.\n\t\t\t\tconst at = plan.position ? ` at line ${plan.position.line}, column ${plan.position.column}` : ''\n\t\t\t\tprocess.stderr.write(`error: ${goldenSetPath} does not parse${at}.\\n`)\n\t\t\t\treturn exitCodes.error\n\t\t\t}\n\t\t\tif (plan.kind === 'rejected') {\n\t\t\t\tprocess.stderr.write(`error: nothing written.\\n${plan.reasons.map((reason) => `- ${reason}\\n`).join('')}`)\n\t\t\t\treturn exitCodes.error\n\t\t\t}\n\t\t\tif (plan.kind === 'absent') {\n\t\t\t\twriteResult(\n\t\t\t\t\t{\n\t\t\t\t\t\tgolden: `0 servers — no golden set at ${goldenSetPath}`,\n\t\t\t\t\t\tmode: 'nothing to reconcile into',\n\t\t\t\t\t\tfields: '0 fields',\n\t\t\t\t\t\trecord: 'not written',\n\t\t\t\t\t} satisfies ReconcileReport,\n\t\t\t\t\tformat,\n\t\t\t\t)\n\t\t\t\treturn exitCodes.success\n\t\t\t}\n\t\t\tconst report: ReconcileReport = {\n\t\t\t\tgolden: goldenSetPath,\n\t\t\t\tmode: plan.written\n\t\t\t\t\t? 'written — only the fields named by --accept'\n\t\t\t\t\t: 'dry run — nothing written; re-run with --accept <path> for each approved field',\n\t\t\t\tfields: plan.rows.length ? plan.rows : '0 fields — no harness holds a change the golden set lacks',\n\t\t\t\trecord: plan.written ? projectionRecordPath : 'not written — dry run',\n\t\t\t}\n\t\t\twriteResult(report, format)\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'MCP reconcile failed.'}\\n`)\n\t\t\treturn exitCodes.error\n\t\t}\n\t},\n})\n","import { findNodeAtLocation, type Node, parseTree } from 'jsonc-parser'\nimport { stripJsonComments } from '../diagnose-bridges/json-with-comments.ts'\nimport type { ConfigEdit } from './config-edit.ts'\n\n/** The one indent unit a file already uses, so an inserted value reads like its neighbours. */\nfunction indentUnit(source: string): string {\n\tconst indented = /\\n([ \\t]+)\\S/.exec(source)\n\treturn indented ? (indented[1] as string) : ' '\n}\n\nfunction jsonAt(value: unknown, unit: string, depth: number): string {\n\treturn JSON.stringify(value, null, unit).replaceAll('\\n', `\\n${unit.repeat(depth)}`)\n}\n\nfunction objectAt(root: Node | undefined, path: string[]): Node | undefined {\n\tconst node = root && (path.length ? findNodeAtLocation(root, path) : root)\n\treturn node?.type === 'object' ? node : undefined\n}\n\n/**\n * Adds `name` to the object at `path`, or `undefined` when there is no object there or it already\n * holds `name`. `jsonc-parser`'s own `modify` reformats the properties beside the one it inserts,\n * so the text is spliced at the parse tree's offsets instead: every byte outside the insertion\n * survives, comments included.\n */\nexport function insertJsonProperty(source: string, path: string[], name: string, value: unknown): string | undefined {\n\tconst container = objectAt(parseTree(source), path)\n\tif (!container || findNodeAtLocation(container, [name])) return undefined\n\tconst depth = path.length + 1\n\tconst unit = indentUnit(source)\n\tconst property = `${unit.repeat(depth)}${JSON.stringify(name)}: ${jsonAt(value, unit, depth)}`\n\tconst last = container.children?.at(-1)\n\tif (last) {\n\t\tconst end = last.offset + last.length\n\t\treturn `${source.slice(0, end)},\\n${property}${source.slice(end)}`\n\t}\n\tconst open = container.offset + 1\n\tconst close = container.offset + container.length - 1\n\treturn `${source.slice(0, open)}\\n${property}\\n${unit.repeat(depth - 1)}${source.slice(close)}`\n}\n\n/** Replaces the value at `path`, keeping every byte outside it. A comment inside the value is refused. */\nexport function replaceJsonValue(source: string, path: string[], value: unknown): ConfigEdit {\n\tconst root = parseTree(source)\n\tconst node = root && findNodeAtLocation(root, path)\n\tif (!node) return { kind: 'refused', reason: 'absent' }\n\tconst end = node.offset + node.length\n\tconst text = source.slice(node.offset, end)\n\tif (stripJsonComments(text) !== text) return { kind: 'refused', reason: 'comment' }\n\treturn {\n\t\tkind: 'edited',\n\t\ttext: `${source.slice(0, node.offset)}${jsonAt(value, indentUnit(source), path.length)}${source.slice(end)}`,\n\t}\n}\n","import { insertJsonProperty, replaceJsonValue } from '../config-edit/jsonc-edit.ts'\nimport { appendTomlTable, renderTomlTable, replaceTomlTable } from '../config-edit/toml-edit.ts'\nimport type { McpConfig } from '../harness-registry/mcp-config.ts'\n\nexport type McpEntry = Record<string, unknown>\n\n/** A new file holding only the MCP key, in the format the target reads. */\nexport function createFile(config: McpConfig, name: string, entry: McpEntry): string {\n\treturn config.format === 'toml'\n\t\t? renderTomlTable([config.key, name], entry)\n\t\t: `${JSON.stringify({ [config.key]: { [name]: entry } }, null, 2)}\\n`\n}\n\n/**\n * Adds one server to an existing file without touching a byte of what is already there, or\n * `undefined` when the file's shape leaves no safe place to put it.\n */\nexport function appendServer(config: McpConfig, source: string, name: string, entry: McpEntry): string | undefined {\n\tif (config.format === 'toml') return appendTomlTable(source, [config.key, name], entry)\n\treturn (\n\t\tinsertJsonProperty(source, [config.key], name, entry) ??\n\t\tinsertJsonProperty(source, [], config.key, { [name]: entry })\n\t)\n}\n\n/**\n * Replaces one server's entry in place, keeping every byte outside it, or `undefined` when it cannot:\n * the entry holds a comment the replacement would drop, which is the user's and not this command's\n * to drop, or is written in a form the editor does not replace.\n */\nexport function replaceServer(config: McpConfig, source: string, name: string, entry: McpEntry): string | undefined {\n\tconst edit =\n\t\tconfig.format === 'toml'\n\t\t\t? replaceTomlTable(source, [config.key, name], entry)\n\t\t\t: replaceJsonValue(source, [config.key, name], entry)\n\treturn edit.kind === 'edited' ? edit.text : undefined\n}\n\n/** The entry as it would read in the target, for a person or a skill to apply by hand. */\nexport function renderEntry(config: McpConfig, name: string, entry: McpEntry): string {\n\treturn config.format === 'toml'\n\t\t? renderTomlTable([config.key, name], entry)\n\t\t: JSON.stringify({ [name]: entry }, null, 2)\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport type { GitBridgeState } from '../diagnose-bridges/git-bridge-state.ts'\nimport type { Position } from '../diagnose-bridges/locator.ts'\nimport {\n\tformatProjectionRecord,\n\tMcpBaseline,\n\ttype McpDirection,\n\tparseProjectionRecord,\n\tprojectionRecordPath,\n} from '../diagnose-mcp/mcp-baseline.ts'\nimport { divergingFields, type McpServer } from '../diagnose-mcp/mcp-model.ts'\nimport { credentialFields } from '../diagnose-mcp/mcp-secrets.ts'\nimport { goldenSetPath, mcpTargets, parseGoldenSet, parseTarget } from '../diagnose-mcp/mcp-sources.ts'\nimport type { McpConfig } from '../harness-registry/mcp-config.ts'\nimport { mcpDialects } from '../mcp-dialects/mcp-dialects.ts'\nimport { appendServer, createFile, type McpEntry, renderEntry, replaceServer } from './mcp-edit.ts'\n\n/**\n * `add` and `update` are what the command writes; `edit` is a change it will not make itself and\n * hands over as text; `skip` and `refuse` write nothing.\n */\nexport type ProjectionAction = 'add' | 'update' | 'edit' | 'skip' | 'refuse'\n\nexport type ProjectionRow = { target: string; server: string; action: ProjectionAction; detail: string }\n\n/**\n * Every row that changes a server, with the entry as it would read in the target — the after to\n * show beside the file as it stands, and for an `edit` the text to apply by hand.\n */\nexport type ProjectionEntry = { target: string; server: string; action: ProjectionAction; entry: string }\n\nexport type ProjectionPlan =\n\t| { kind: 'absent' }\n\t| { kind: 'unreadable'; position?: Position | undefined }\n\t| { kind: 'planned'; rows: ProjectionRow[]; entries: ProjectionEntry[]; written: boolean }\n\nexport type ProjectMcpOptions = {\n\troot: string\n\tgit: GitBridgeState\n\t/** Apply the plan and write the last-projected record; without it nothing on disk changes. */\n\twrite: boolean\n}\n\nfunction read(root: string, path: string): string | undefined {\n\tconst absolute = join(root, path)\n\treturn existsSync(absolute) ? readFileSync(absolute, 'utf8') : undefined\n}\n\nconst moved: Record<Exclude<McpDirection, 'golden'>, string> = {\n\ttarget: 'the target changed since the last projection — reconcile it into the golden set first',\n\tboth: 'both sides changed since the last projection — a three-way conflict for a person to settle',\n\tunknown: 'no baseline says which side changed — compare the two by hand',\n}\n\n/** The worst direction among the diverged fields: one field the target moved is enough to hold back. */\nfunction heldBack(directions: McpDirection[]): Exclude<McpDirection, 'golden'> | undefined {\n\treturn (['both', 'unknown', 'target'] as const).find((direction) => directions.includes(direction))\n}\n\ntype TargetPlan = {\n\tconfig: McpConfig\n\tsource: string | undefined\n\tservers: Map<string, McpServer>\n\t/** The file did not exist before this run; every server in it is part of creating it. */\n\tcreated: boolean\n\t/** Servers whose target copy agrees with the golden set once this plan is applied. */\n\tagreed: Map<string, McpServer>\n}\n\n/**\n * Projects the golden set into every enabled harness's MCP file. Only a server the golden set is\n * plainly ahead on is written — absent from the target, or changed on the golden side alone. A\n * target-side change is never overwritten: that is reconcile's, and needs a person.\n */\nexport function projectMcp({ root, git, write }: ProjectMcpOptions): ProjectionPlan {\n\tconst golden = parseGoldenSet(read(root, goldenSetPath))\n\tif (golden.kind !== 'servers') return golden\n\n\tconst record = parseProjectionRecord(read(root, projectionRecordPath))\n\tconst baseline = new McpBaseline({ git, record })\n\tconst rows: ProjectionRow[] = []\n\tconst entries: ProjectionEntry[] = []\n\tconst plans: TargetPlan[] = []\n\n\tfor (const config of mcpTargets(root)) {\n\t\tconst source = read(root, config.path)\n\t\tconst parsed = parseTarget(config, source)\n\t\tif (parsed.kind === 'unreadable') {\n\t\t\trows.push({ target: config.path, server: '', action: 'refuse', detail: 'the target does not parse' })\n\t\t\tcontinue\n\t\t}\n\t\tconst plan: TargetPlan = {\n\t\t\tconfig,\n\t\t\tsource,\n\t\t\tcreated: source === undefined,\n\t\t\tservers: parsed.kind === 'servers' ? parsed.servers : new Map(),\n\t\t\tagreed: new Map(),\n\t\t}\n\t\tplans.push(plan)\n\t\tconst dialect = mcpDialects[config.dialect]\n\n\t\tfor (const [name, declared] of golden.servers) {\n\t\t\tconst row = (action: ProjectionAction, detail: string) =>\n\t\t\t\trows.push({ target: config.path, server: name, action, detail })\n\t\t\tconst literal = credentialFields(declared)[0]\n\t\t\tif (literal) {\n\t\t\t\trow('refuse', `the golden set holds a literal credential at ${literal} — reference it as \\${VAR} first`)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst rendering = dialect.write(declared)\n\t\t\tif (rendering.kind === 'refused') {\n\t\t\t\trow('refuse', `${rendering.field}: ${rendering.reason}`)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst carried = plan.servers.get(name)\n\t\t\tif (!carried) {\n\t\t\t\tconst next =\n\t\t\t\t\tplan.source === undefined\n\t\t\t\t\t\t? createFile(config, name, rendering.entry)\n\t\t\t\t\t\t: appendServer(config, plan.source, name, rendering.entry)\n\t\t\t\tapply(\n\t\t\t\t\tplan,\n\t\t\t\t\tname,\n\t\t\t\t\tdeclared,\n\t\t\t\t\trendering.entry,\n\t\t\t\t\tnext,\n\t\t\t\t\tplan.created ? 'creates the file' : 'appends the server',\n\t\t\t\t\trow,\n\t\t\t\t\tentries,\n\t\t\t\t)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst diverged = divergingFields(declared, carried, dialect.fields)\n\t\t\tif (!diverged.length) {\n\t\t\t\tplan.agreed.set(name, declared)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst direction = heldBack(diverged.map((field) => baseline.directionOf(config, name, field, declared, carried)))\n\t\t\tif (direction) {\n\t\t\t\trow('skip', moved[direction])\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst next = replaceServer(config, plan.source as string, name, rendering.entry)\n\t\t\tapply(plan, name, declared, rendering.entry, next, `replaces ${diverged.join(', ')}`, row, entries)\n\t\t}\n\t}\n\n\tif (write) {\n\t\tfor (const plan of plans)\n\t\t\tif (plan.source !== undefined && plan.source !== read(root, plan.config.path)) writeTarget(root, plan)\n\t\twriteRecord(root, record, plans)\n\t}\n\treturn { kind: 'planned', rows, entries, written: write }\n}\n\n/**\n * Accepts the new text only when it reads back as the golden server with every other server\n * untouched; anything else becomes an `edit` for a person, rather than a write this command\n * cannot vouch for.\n */\nfunction apply(\n\tplan: TargetPlan,\n\tname: string,\n\tdeclared: McpServer,\n\tentry: McpEntry,\n\tnext: string | undefined,\n\tdetail: string,\n\trow: (action: ProjectionAction, detail: string) => void,\n\tentries: ProjectionEntry[],\n): void {\n\tconst adding = !plan.servers.has(name)\n\tconst accepted = next !== undefined && readsBack(plan, name, declared, next)\n\tconst action: ProjectionAction = accepted ? (adding ? 'add' : 'update') : 'edit'\n\tentries.push({ target: plan.config.path, server: name, action, entry: renderEntry(plan.config, name, entry) })\n\tif (!accepted) {\n\t\trow(\n\t\t\t'edit',\n\t\t\tadding\n\t\t\t\t? 'the file has no safe place to add it — apply the entry by hand'\n\t\t\t\t: 'an in-place change here is applied by hand',\n\t\t)\n\t\treturn\n\t}\n\tplan.source = next\n\tplan.servers = (parseTarget(plan.config, next) as { kind: 'servers'; servers: Map<string, McpServer> }).servers\n\tplan.agreed.set(name, declared)\n\trow(action, detail)\n}\n\nfunction readsBack(plan: TargetPlan, name: string, declared: McpServer, next: string): boolean {\n\tconst parsed = parseTarget(plan.config, next)\n\tif (parsed.kind !== 'servers') return false\n\tconst written = parsed.servers.get(name)\n\tconst fields = mcpDialects[plan.config.dialect].fields\n\tif (!written || divergingFields(declared, written, fields).length) return false\n\treturn [...plan.servers].every(([other, server]) => {\n\t\tif (other === name) return true\n\t\tconst kept = parsed.servers.get(other)\n\t\treturn kept !== undefined && JSON.stringify(kept) === JSON.stringify(server)\n\t})\n}\n\nfunction writeTarget(root: string, plan: TargetPlan): void {\n\tconst absolute = join(root, plan.config.path)\n\tmkdirSync(dirname(absolute), { recursive: true })\n\twriteFileSync(absolute, plan.source as string)\n}\n\n/** What each target last agreed on, kept per server so a server this run did not touch keeps its entry. */\nfunction writeRecord(root: string, record: Map<string, Map<string, McpServer>>, plans: TargetPlan[]): void {\n\tfor (const plan of plans) {\n\t\tconst servers = record.get(plan.config.path) ?? new Map<string, McpServer>()\n\t\tfor (const [name, server] of plan.agreed) servers.set(name, server)\n\t\tif (servers.size) record.set(plan.config.path, servers)\n\t}\n\tconst absolute = join(root, projectionRecordPath)\n\tmkdirSync(dirname(absolute), { recursive: true })\n\twriteFileSync(absolute, formatProjectionRecord(record))\n}\n","import type { cli } from 'clibuilder'\nimport { command, exitCodes, z } from 'clibuilder'\nimport { parseFormat, writeResult } from '../command-output/command-output.ts'\nimport { GitBridgeState } from '../diagnose-bridges/git-bridge-state.ts'\nimport { projectionRecordPath } from '../diagnose-mcp/mcp-baseline.ts'\nimport { goldenSetPath } from '../diagnose-mcp/mcp-sources.ts'\nimport { mcpReconcileCommand } from '../reconcile-mcp/reconcile.command.ts'\nimport { type ProjectionEntry, type ProjectionRow, projectMcp } from './project-mcp.ts'\n\nexport type ProjectionReport = {\n\tgolden: string\n\tmode: string\n\t/** Emitted even when empty, so a run that changes nothing states its zero. */\n\tactions: ProjectionRow[] | string\n\t/** Omitted when no row changes a server. */\n\tentries?: ProjectionEntry[]\n\trecord: string\n}\n\nexport const mcpProjectCommand: cli.Command = command({\n\tname: 'project',\n\tdescription:\n\t\t'Project the golden MCP server set into each enabled harness. A dry run unless --write; never overwrites a change made on the harness side.',\n\toptions: {\n\t\troot: {\n\t\t\tdescription: 'Repository or package directory. Defaults to the current directory.',\n\t\t\ttype: z.optional(z.string()),\n\t\t},\n\t\twrite: {\n\t\t\tdescription: 'Apply the plan and record what was projected. Without it nothing on disk changes.',\n\t\t\ttype: z.optional(z.boolean()),\n\t\t},\n\t\tformat: {\n\t\t\tdescription: 'Output format: toon (default), json, or text for a human-readable report.',\n\t\t\ttype: z.optional(z.string()),\n\t\t\tdefault: 'toon',\n\t\t},\n\t},\n\trun(args) {\n\t\ttry {\n\t\t\tconst format = parseFormat(args.format)\n\t\t\tconst root = args.root ?? process.cwd()\n\t\t\tconst write = args.write === true\n\t\t\tconst plan = projectMcp({ root, git: new GitBridgeState(root), write })\n\t\t\tif (plan.kind === 'unreadable') {\n\t\t\t\t// Position only: the parser's message quotes the line, and that line may hold a credential.\n\t\t\t\tconst at = plan.position ? ` at line ${plan.position.line}, column ${plan.position.column}` : ''\n\t\t\t\tprocess.stderr.write(`error: ${goldenSetPath} does not parse${at}.\\n`)\n\t\t\t\treturn exitCodes.error\n\t\t\t}\n\t\t\tif (plan.kind === 'absent') {\n\t\t\t\twriteResult(\n\t\t\t\t\t{\n\t\t\t\t\t\tgolden: `0 servers — no golden set at ${goldenSetPath}`,\n\t\t\t\t\t\tmode: 'nothing to project',\n\t\t\t\t\t\tactions: '0 changes',\n\t\t\t\t\t\trecord: 'not written',\n\t\t\t\t\t} satisfies ProjectionReport,\n\t\t\t\t\tformat,\n\t\t\t\t)\n\t\t\t\treturn exitCodes.success\n\t\t\t}\n\t\t\tconst report: ProjectionReport = {\n\t\t\t\tgolden: goldenSetPath,\n\t\t\t\tmode: write ? 'written' : 'dry run — nothing written; re-run with --write to apply',\n\t\t\t\tactions: plan.rows.length ? plan.rows : '0 changes — every enabled harness already carries the golden set',\n\t\t\t\t...(plan.entries.length ? { entries: plan.entries } : {}),\n\t\t\t\trecord: write ? projectionRecordPath : 'not written — dry run',\n\t\t\t}\n\t\t\twriteResult(report, format)\n\t\t\treturn exitCodes.success\n\t\t} catch (error) {\n\t\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'MCP projection failed.'}\\n`)\n\t\t\treturn exitCodes.error\n\t\t}\n\t},\n})\n\nexport const mcpCommand: cli.Command = command({\n\tname: 'mcp',\n\tdescription: 'Work with the golden MCP server set at .agents/buddy-agent-harness/mcp.toml.',\n\tcommands: [mcpProjectCommand, mcpReconcileCommand],\n})\n","import { readFileSync } from 'node:fs'\nimport { cli, exitCodes } from 'clibuilder'\nimport { depPluginsCommand } from './dep-plugins/dep-plugins.command.ts'\nimport { doctorCommand } from './diagnose-bridges/doctor.command.ts'\nimport { governanceCommand } from './governance-overrides/governance.command.ts'\nimport { initCommand } from './initialize-harnesses/init.command.ts'\nimport { mcpCommand } from './project-mcp/mcp.command.ts'\nimport { referenceCommand } from './references/reference.command.ts'\n\n/**\n * `../package.json` resolves from both `src/cli.ts` and the bundled `dist/cli.mjs` — one directory\n * under the package root — but not from a skill-script bundle, shipped deeper with no package tree\n * beside it; that build defines `__PACKAGE_VERSION__` as a literal instead. `typeof` is safe against\n * an identifier no other build declares — it reads `'undefined'` rather than throwing.\n */\ndeclare const __PACKAGE_VERSION__: string | undefined\nconst version =\n\ttypeof __PACKAGE_VERSION__ !== 'undefined'\n\t\t? __PACKAGE_VERSION__\n\t\t: (JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version as string)\n\n// A factory, not a module-level constant: `cli()` builds state, and state built at import time\n// would be shared by every later call in the process.\nfunction app() {\n\treturn cli({\n\t\tname: 'buddy-agent-harness',\n\t\tversion,\n\t\tdescription: 'Initialize agent harness skill compatibility in consumer repositories.',\n\t})\n\t\t.command(initCommand)\n\t\t.command(doctorCommand)\n\t\t.command(mcpCommand)\n\t\t.command(depPluginsCommand)\n\t\t.command(referenceCommand)\n\t\t.command(governanceCommand)\n}\n\n/**\n * The application boundary: argv in, exit code out — returned rather than written, so a caller that\n * is not the process (a skill launcher, a test) can act on it.\n */\nexport async function run(argv: string[]): Promise<number> {\n\ttry {\n\t\tconst code = await app().parse<number | undefined>(argv)\n\t\treturn typeof code === 'number' ? code : exitCodes.success\n\t} catch (error) {\n\t\t// stderr, not stdout — stdout carries TOON an agent parses; an error there would land\n\t\t// mid-parse.\n\t\tprocess.stderr.write(`error: ${error instanceof Error ? error.message : 'Invalid command.'}\\n`)\n\t\treturn exitCodes.usage\n\t}\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { homedir, platform } from 'node:os'\nimport { basename, join, resolve } from 'node:path'\nimport { parseJsonWithComments } from '../diagnose-bridges/json-with-comments.ts'\nimport { type McpServer, type McpTransport, serverFrom } from '../diagnose-mcp/mcp-model.ts'\nimport { nonSecretArgs } from '../diagnose-mcp/mcp-secrets.ts'\nimport { parseTarget } from '../diagnose-mcp/mcp-sources.ts'\nimport { type HarnessName, type HarnessScopeName, harnessRegistry } from '../harness-registry/harness-registry.ts'\nimport type { McpConfig } from '../harness-registry/mcp-config.ts'\nimport { isRecord } from '../is-record/is-record.ts'\n\n/**\n * `local`: Claude Code's per-project entry inside `~/.claude.json`. `plugin`: a server an installed\n * Claude Code plugin ships, named on `McpServerEntry.plugin`.\n */\nexport type McpServerScope = HarnessScopeName | 'local' | 'plugin'\n\n/** Not wired into `doctor`: adding a harness here never changes what `doctor` reads. */\nfunction userScopeConfig(\n\tharness: HarnessName,\n\thome: string,\n\tenv: Readonly<Record<string, string | undefined>>,\n): { file: string; config: McpConfig } | undefined {\n\tswitch (harness) {\n\t\tcase 'claude-code':\n\t\t\treturn {\n\t\t\t\tfile: join(home, '.claude.json'),\n\t\t\t\tconfig: { path: '.claude.json', key: 'mcpServers', format: 'json', dialect: 'claude-code' },\n\t\t\t}\n\t\tcase 'cursor':\n\t\t\treturn {\n\t\t\t\tfile: join(home, '.cursor', 'mcp.json'),\n\t\t\t\tconfig: { path: '.cursor/mcp.json', key: 'mcpServers', format: 'json', dialect: 'cursor' },\n\t\t\t}\n\t\tcase 'codex':\n\t\t\treturn {\n\t\t\t\tfile: join(env['CODEX_HOME'] || join(home, '.codex'), 'config.toml'),\n\t\t\t\tconfig: { path: 'config.toml', key: 'mcp_servers', format: 'toml', dialect: 'codex' },\n\t\t\t}\n\t\tcase 'copilot-cli':\n\t\t\treturn {\n\t\t\t\tfile: join(env['COPILOT_HOME'] || join(home, '.copilot'), 'mcp-config.json'),\n\t\t\t\tconfig: { path: 'mcp-config.json', key: 'mcpServers', format: 'json', dialect: 'claude-code' },\n\t\t\t}\n\t\tcase 'gemini-cli':\n\t\t\treturn {\n\t\t\t\tfile: join(home, '.gemini', 'settings.json'),\n\t\t\t\tconfig: {\n\t\t\t\t\tpath: '.gemini/settings.json',\n\t\t\t\t\tkey: 'mcpServers',\n\t\t\t\t\tformat: 'json',\n\t\t\t\t\tdialect: 'gemini-cli',\n\t\t\t\t\tshared: true,\n\t\t\t\t},\n\t\t\t}\n\t\tdefault:\n\t\t\treturn undefined\n\t}\n}\n\nfunction read(file: string): string | undefined {\n\treturn existsSync(file) ? readFileSync(file, 'utf8') : undefined\n}\n\n/** A URL trimmed to its origin and path, dropping any query string a token could ride in on. */\nfunction safeUrl(value: string | undefined): string | undefined {\n\tif (!value) return undefined\n\ttry {\n\t\tconst url = new URL(value)\n\t\treturn `${url.origin}${url.pathname}`\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/** One configured MCP server, redacted of everything that could carry a credential. */\nexport type McpServerEntry = {\n\tharness: HarnessName\n\tscope: McpServerScope\n\t/** The absolute path of the config file this entry was read from. */\n\tconfigFile: string\n\t/** The name the server is declared under. */\n\tname: string\n\ttransport: McpTransport | undefined\n\t/** The command's basename, never its full path. */\n\tcommand: string | undefined\n\t/** `args`, with any credential-bearing `--flag=value` pair dropped. */\n\targs: readonly string[]\n\t/** The URL's origin and path, never its query string. */\n\turl: string | undefined\n\tenabled: boolean\n\t/** The plugin id this server came from, set only when `scope` is `'plugin'`. */\n\tplugin?: string\n}\n\nexport type ListMcpServersOptions = {\n\t/** The project directory to read project-scope configuration from. */\n\tprojectDir: string\n\t/** Overrides `os.homedir()`, for a test that must not touch the real one. */\n\thomeDir?: string\n\t/**\n\t * Overrides `process.env`, for a test — read only for `CODEX_HOME`, `COPILOT_HOME`, and\n\t * `XDG_CONFIG_HOME`.\n\t */\n\tenv?: Readonly<Record<string, string | undefined>>\n\t/** Overrides `os.platform()`, so the VS Code user directory is testable on every OS. */\n\tplatform?: NodeJS.Platform\n}\n\nfunction toEntry(\n\tharness: HarnessName,\n\tscope: McpServerScope,\n\tfile: string,\n\tname: string,\n\tserver: McpServer,\n\tplugin?: string,\n): McpServerEntry {\n\treturn {\n\t\tharness,\n\t\tscope,\n\t\tconfigFile: file,\n\t\tname,\n\t\ttransport: server.transport,\n\t\tcommand: server.command ? basename(server.command) : undefined,\n\t\targs: nonSecretArgs(server.args),\n\t\turl: safeUrl(server.url),\n\t\tenabled: server.enabled !== false,\n\t\t...(plugin ? { plugin } : {}),\n\t}\n}\n\nfunction entriesFrom(harness: HarnessName, scope: McpServerScope, file: string, config: McpConfig): McpServerEntry[] {\n\tconst parsed = parseTarget(config, read(file))\n\tif (parsed.kind !== 'servers') return []\n\treturn [...parsed.servers].map(([name, server]) => toEntry(harness, scope, file, name, server))\n}\n\n/**\n * Reshapes what `serverFrom` doesn't recognize: OpenCode's `command` array, Zed's `command` object,\n * and Windsurf's `serverUrl` alias for `url`.\n */\nfunction normalizeRawEntry(raw: Record<string, unknown>): Record<string, unknown> {\n\tconst command = raw['command']\n\tif (Array.isArray(command)) {\n\t\tconst [first, ...rest] = command as unknown[]\n\t\treturn { ...raw, command: first, args: raw['args'] ?? rest }\n\t}\n\tif (isRecord(command)) {\n\t\treturn { ...raw, command: command['path'], args: raw['args'] ?? command['args'] }\n\t}\n\tif (raw['url'] === undefined && typeof raw['serverUrl'] === 'string') {\n\t\treturn { ...raw, url: raw['serverUrl'] }\n\t}\n\treturn raw\n}\n\n/** Every server under `key` in an already-parsed JSON(C) document, normalized and converted. */\nfunction serversFromDocument(document: unknown, key: string): Map<string, McpServer> {\n\tconst table = isRecord(document) ? document[key] : undefined\n\tif (!isRecord(table)) return new Map()\n\treturn new Map(\n\t\tObject.entries(table)\n\t\t\t.filter((pair): pair is [string, Record<string, unknown>] => isRecord(pair[1]))\n\t\t\t.map(([name, entry]) => [name, serverFrom(normalizeRawEntry(entry))]),\n\t)\n}\n\nfunction entriesFromDocument(\n\tharness: HarnessName,\n\tscope: McpServerScope,\n\tfile: string,\n\tdocument: unknown,\n\tkey: string,\n\toptions: { plugin?: string; forceDisabled?: boolean } = {},\n): McpServerEntry[] {\n\treturn [...serversFromDocument(document, key)].map(([name, server]) => {\n\t\tconst entry = toEntry(harness, scope, file, name, server, options.plugin)\n\t\treturn options.forceDisabled ? { ...entry, enabled: false } : entry\n\t})\n}\n\n/**\n * Where VS Code keeps its user-scope settings, per platform — mirrors what VS Code itself\n * documents.\n */\nfunction vscodeUserDir(env: Readonly<Record<string, string | undefined>>, home: string, plat: NodeJS.Platform): string {\n\tif (plat === 'win32') return join(env['APPDATA'] || join(home, 'AppData', 'Roaming'), 'Code', 'User')\n\tif (plat === 'darwin') return join(home, 'Library', 'Application Support', 'Code', 'User')\n\treturn join(env['XDG_CONFIG_HOME'] || join(home, '.config'), 'Code', 'User')\n}\n\ntype ExtraSource = {\n\tharness: HarnessName\n\tscope: McpServerScope\n\tfile: string\n\tkey: string\n}\n\n// Sources with no registry entry. Windsurf's legacy path is read as `devin-desktop`, its new name\n// (E-WS-02).\nfunction extraSources(\n\tprojectDir: string,\n\thome: string,\n\tenv: Readonly<Record<string, string | undefined>>,\n\tplat: NodeJS.Platform,\n): ExtraSource[] {\n\tconst xdg = env['XDG_CONFIG_HOME'] || join(home, '.config')\n\treturn [\n\t\t{ harness: 'vscode', scope: 'user', file: join(vscodeUserDir(env, home, plat), 'mcp.json'), key: 'servers' },\n\t\t{ harness: 'vscode', scope: 'project', file: join(projectDir, '.vscode', 'mcp.json'), key: 'servers' },\n\t\t{\n\t\t\tharness: 'devin-desktop',\n\t\t\tscope: 'user',\n\t\t\tfile: join(home, '.codeium', 'windsurf', 'mcp_config.json'),\n\t\t\tkey: 'mcpServers',\n\t\t},\n\t\t{ harness: 'opencode', scope: 'user', file: join(xdg, 'opencode', 'opencode.json'), key: 'mcp' },\n\t\t{ harness: 'opencode', scope: 'project', file: join(projectDir, 'opencode.json'), key: 'mcp' },\n\t\t{ harness: 'zed', scope: 'user', file: join(xdg, 'zed', 'settings.json'), key: 'context_servers' },\n\t\t{ harness: 'zed', scope: 'project', file: join(projectDir, '.zed', 'settings.json'), key: 'context_servers' },\n\t]\n}\n\n/**\n * Claude Code's per-project servers: `~/.claude.json`'s `projects[projectDir].mcpServers`, distinct\n * from the file's top-level `mcpServers` (read as `'user'` scope above).\n */\nfunction claudeLocalEntries(home: string, projectDir: string): McpServerEntry[] {\n\tconst file = join(home, '.claude.json')\n\tconst text = read(file)\n\tif (text === undefined) return []\n\tconst document = parseJsonWithComments(text)\n\tconst projects = isRecord(document) ? document['projects'] : undefined\n\tconst project = isRecord(projects) ? projects[resolve(projectDir)] : undefined\n\tif (!isRecord(project)) return []\n\treturn entriesFromDocument('claude-code', 'local', file, project, 'mcpServers')\n}\n\n/** `enabledPlugins`, merged from global settings up through project-local settings, last write wins. */\nfunction enabledPlugins(home: string, projectDir: string): Record<string, boolean> {\n\tconst enabled: Record<string, boolean> = {}\n\tfor (const file of [\n\t\tjoin(home, '.claude', 'settings.json'),\n\t\tjoin(projectDir, '.claude', 'settings.json'),\n\t\tjoin(projectDir, '.claude', 'settings.local.json'),\n\t]) {\n\t\tconst text = read(file)\n\t\tif (text === undefined) continue\n\t\tconst document = parseJsonWithComments(text)\n\t\tconst table = isRecord(document) ? document['enabledPlugins'] : undefined\n\t\tif (!isRecord(table)) continue\n\t\tfor (const [id, value] of Object.entries(table)) if (typeof value === 'boolean') enabled[id] = value\n\t}\n\treturn enabled\n}\n\n/**\n * Servers shipped by installed Claude Code plugins, with `enabled` forced by the plugin's own\n * enabled state rather than the server's own field.\n */\nfunction pluginEntries(home: string, projectDir: string): McpServerEntry[] {\n\tconst file = join(home, '.claude', 'plugins', 'installed_plugins.json')\n\tconst text = read(file)\n\tif (text === undefined) return []\n\tconst document = parseJsonWithComments(text)\n\tconst installed = isRecord(document) ? document['plugins'] : undefined\n\tif (!isRecord(installed)) return []\n\n\tconst enabled = enabledPlugins(home, projectDir)\n\tconst absoluteProject = resolve(projectDir)\n\tconst entries: McpServerEntry[] = []\n\n\tfor (const [id, list] of Object.entries(installed)) {\n\t\tif (!Array.isArray(list)) continue\n\t\tfor (const install of list) {\n\t\t\tif (!isRecord(install)) continue\n\t\t\tconst projectPath = install['projectPath']\n\t\t\tif (typeof projectPath === 'string' && resolve(projectPath) !== absoluteProject) continue\n\t\t\tconst installPath = install['installPath']\n\t\t\tif (typeof installPath !== 'string') continue\n\n\t\t\tconst mcpFile = join(installPath, '.mcp.json')\n\t\t\tconst mcpText = read(mcpFile)\n\t\t\tif (mcpText === undefined) continue\n\t\t\tconst mcpDocument = parseJsonWithComments(mcpText)\n\t\t\tif (!isRecord(mcpDocument)) continue\n\n\t\t\t// A plugin's `.mcp.json` may list servers under `mcpServers`, or at the file's top level.\n\t\t\tconst document2 = isRecord(mcpDocument['mcpServers']) ? mcpDocument : { mcpServers: mcpDocument }\n\t\t\tentries.push(\n\t\t\t\t...entriesFromDocument('claude-code', 'plugin', mcpFile, document2, 'mcpServers', {\n\t\t\t\t\tplugin: id,\n\t\t\t\t\tforceDisabled: enabled[id] !== true,\n\t\t\t\t}),\n\t\t\t)\n\t\t}\n\t}\n\treturn entries\n}\n\n/**\n * Every configured MCP server across supported harnesses and scopes, redacted of credentials. A\n * missing or unparseable file contributes no entries silently — this reports an inventory, not a\n * diagnosis.\n */\nexport function listMcpServers(options: ListMcpServersOptions): McpServerEntry[] {\n\tconst home = options.homeDir ?? homedir()\n\tconst env = options.env ?? process.env\n\tconst plat = options.platform ?? platform()\n\tconst entries: McpServerEntry[] = []\n\n\tfor (const harness of harnessRegistry) {\n\t\tif (harness.deprecated) continue\n\n\t\tconst project = harness.project.mcpConfig\n\t\tif (project) entries.push(...entriesFrom(harness.name, 'project', join(options.projectDir, project.path), project))\n\n\t\tconst user = userScopeConfig(harness.name, home, env)\n\t\tif (user) entries.push(...entriesFrom(harness.name, 'user', user.file, user.config))\n\t}\n\n\tentries.push(...claudeLocalEntries(home, options.projectDir))\n\tentries.push(...pluginEntries(home, options.projectDir))\n\n\tfor (const source of extraSources(options.projectDir, home, env, plat)) {\n\t\tconst text = read(source.file)\n\t\tif (text === undefined) continue\n\t\tconst document = parseJsonWithComments(text)\n\t\tif (document === undefined) continue\n\t\tentries.push(...entriesFromDocument(source.harness, source.scope, source.file, document, source.key))\n\t}\n\n\treturn entries\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAgB,SAAS,OAAkD;CAC1E,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC3E;;;ACIA,MAAM,UAAmC;CAAC;CAAQ;CAAQ;AAAM;;AAGhE,SAAgB,YAAY,OAAyC;CACpE,IAAI,CAAC,QAAQ,SAAS,KAAqB,GAAG,MAAM,IAAI,MAAM,uCAAuC;CACrG,OAAO;AACR;;AAGA,SAAgB,YAAY,OAAe,QAA4B;CACtE,QAAQ,OAAO,MAAM,GAAG,aAAa,OAAO,MAAM,EAAE,GAAG;AACxD;;;;;AAMA,SAAgB,cAAc,SAAuB;CACpD,QAAQ,OAAO,MAAM,QAAQ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