From 82d588a339fae0f63c3a3aeb79bb00c587d066d6 Mon Sep 17 00:00:00 2001 From: Codeman maintainer Date: Tue, 13 Oct 2026 18:28:34 +0200 Subject: [PATCH] docs(mcp-sync): the alt config file is written when it parses (#599 merge-time fix) Three comments said `altPath` is never written, but run() makes the alt file the write target when the primary is absent. The behaviour is fine (a JSONC file with comments fails the parse guard and is never written); the comments now say so, so nobody loosens the path rule on that belief. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/config/cli-registry/schema.ts | 3 ++- src/mcp-sync.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/config/cli-registry/schema.ts b/src/config/cli-registry/schema.ts index 320282c5..8bdcc281 100644 --- a/src/config/cli-registry/schema.ts +++ b/src/config/cli-registry/schema.ts @@ -453,7 +453,8 @@ const capabilitiesSchema = z .object({ // Home-relative, no traversal: sync writes to this path. path: mcpRelativePath, - // Home-relative fallback read when `path` is absent (never written). + // Home-relative fallback used when `path` is absent. Same no-traversal rule as `path`: + // sync reads it and, when it parses as plain JSON, writes to it. altPath: mcpRelativePath.optional(), // Every value must be a known McpConfigFormat (types.ts); mcp-sync.ts's dialect table is // keyed by the same type, so an adapter-less format fails to compile there. diff --git a/src/mcp-sync.ts b/src/mcp-sync.ts index b87ecc9d..1c8a28dc 100644 --- a/src/mcp-sync.ts +++ b/src/mcp-sync.ts @@ -66,7 +66,10 @@ export interface McpSyncTarget { label: string; /** Home-relative default location of the config file. */ path: string; - /** Home-relative fallback file read when `path` is absent (never written). */ + /** + * Home-relative fallback file used when `path` is absent: read, and written in place when it + * parses (a JSONC file with comments fails the parse and is never written). + */ altPath?: string; format: McpFormat; /** The env var the CLI reads to move the file, and the path under it (`mcpConfig.relocation`). */ @@ -612,7 +615,8 @@ function resolveFile( /** * The alternate config file for a target (`McpSyncTarget.altPath`), honouring the same relocation * as the primary file: the alt lives in the same directory, so the relocated path is the primary's - * directory plus the alt filename. Like the primary, it is only ever read, never written. + * directory plus the alt filename. Once chosen it is read and written exactly like the primary; a + * JSONC file with comments fails the parse guard and is never written. */ function resolveAltFile( t: McpSyncTarget,