{"version":3,"file":"skills-sync.mjs","names":["delay","isRecord","readIfExists","parseToml","syncTarget","syncTarget"],"sources":["../../src/resolve.ts","../../src/harness.ts","../../src/harnesses/antigravity.ts","../../src/harnesses/claude.ts","../../src/harnesses/codex.ts","../../src/harnesses/cursor.ts","../../src/harnesses/freebuff.ts","../../src/harnesses/gemini.ts","../../src/harnesses/github-copilot.ts","../../src/harnesses/grok.ts","../../src/harnesses/mastracode.ts","../../src/harnesses/omp.ts","../../src/harnesses/opencode.ts","../../src/harnesses/pi.ts","../../src/harnesses/prime-agent.ts","../../src/harnesses/index.ts","../../src/registry.ts","../../src/mcp-servers.ts","../../src/agents-sync.ts","../../src/directory-link.ts","../../src/prompt-sync.ts","../../src/skills-sync.ts"],"sourcesContent":["import os from \"node:os\";\nimport { join } from \"node:path\";\nimport type { ResolveOptions } from \"./types.ts\";\n\n/**\n * Every marker a path template can carry, matched in one pass so a substituted\n * value is never scanned for markers again.\n */\nconst PATH_MARKERS = /^~(?=\\/|$)|\\$\\{HOME\\}|\\$\\{PROJECT_ROOT\\}|\\$\\{TMPDIR\\}|%([^%]+)%/g;\n\nexport function resolvePathTemplate(template: string, options: ResolveOptions = {}): string {\n  const homeDir = options.homeDir ?? os.homedir();\n  const projectRoot = options.projectRoot ?? process.cwd();\n\n  return template.replaceAll(PATH_MARKERS, (match: string, name: string | undefined) => {\n    if (match === \"${PROJECT_ROOT}\") return projectRoot;\n    if (match === \"${TMPDIR}\") return options.tempDir ?? os.tmpdir();\n    if (name === undefined) return homeDir;\n    return process.env[name] ?? match;\n  });\n}\n\n/**\n * The agntn config directory: $XDG_CONFIG_HOME/agntn or ~/.config/agntn.\n *\n * @param options - Path-resolution overrides.\n * @returns {string} The resolved agntn configuration directory.\n */\nexport function agntnConfigDir(options: ResolveOptions = {}): string {\n  const base =\n    process.env.XDG_CONFIG_HOME && process.env.XDG_CONFIG_HOME !== \"\"\n      ? process.env.XDG_CONFIG_HOME\n      : join(options.homeDir ?? os.homedir(), \".config\");\n  return join(base, \"agntn\");\n}\n\n/**\n * The agntn data directory: $XDG_DATA_HOME/agntn or ~/.local/share/agntn.\n *\n * @param options - Path-resolution overrides.\n * @returns {string} The resolved agntn data directory.\n */\nexport function agntnDataDir(options: ResolveOptions = {}): string {\n  const base =\n    process.env.XDG_DATA_HOME && process.env.XDG_DATA_HOME !== \"\"\n      ? process.env.XDG_DATA_HOME\n      : join(options.homeDir ?? os.homedir(), \".local\", \"share\");\n  return join(base, \"agntn\");\n}\n","import { addAbortListener } from \"node:events\";\nimport { existsSync, statSync } from \"node:fs\";\nimport { execFile, execFileSync, spawn } from \"node:child_process\";\nimport type { ChildProcessByStdio } from \"node:child_process\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport { join } from \"node:path\";\nimport type { Readable } from \"node:stream\";\nimport type {\n  HarnessDetection,\n  HarnessId,\n  HarnessInvocation,\n  HarnessInvocationModes,\n  HarnessModelListing,\n  InvokeOptions,\n  EnvOverride,\n  InvokeResult,\n  ListModelsOptions,\n  ListModelsResult,\n  AvailableModel,\n  McpConfigFile,\n  PathCandidate,\n  PromptTemplateSyncTarget,\n  SkillsSyncTarget,\n  StorageDescriptor,\n  HarnessCapabilities,\n  ResolveOptions,\n  ResolvedPaths,\n  Platform,\n} from \"./types.ts\";\nimport { resolvePathTemplate } from \"./resolve.ts\";\n\n/**\n * Swaps the default root at the start of a resolved path for the value the\n * harness reads instead; a path outside that root comes back unchanged.\n *\n * @param path - Resolved path.\n * @param root - Resolved default root.\n * @param value - Value of the override variable.\n * @returns {string} The path under the moved root.\n */\nfunction moveRoot(path: string, root: string, value: string): string {\n  if (path === root) return value;\n  const rest = path.slice(root.length);\n  return path.startsWith(root) && (rest.startsWith(\"/\") || rest.startsWith(\"\\\\\"))\n    ? value + rest\n    : path;\n}\n\nconst SUPPORTED_PLATFORMS: Record<Platform, true> = {\n  linux: true,\n  darwin: true,\n  win32: true,\n};\n\ntype CommandOptions = Readonly<{\n  cwd?: string;\n  env?: Readonly<Record<string, string>>;\n  timeoutMs?: number;\n  signal?: AbortSignal;\n}>;\n\n/** Set on every harness {@link Harness.invoke} starts, so a nested `harnesses` can refuse. */\nconst PARENT_ENV = \"AGNTN_HARNESSES_PARENT\";\n\ntype InvocationOptions = Readonly<{\n  model?: string;\n  effort?: string;\n  structured?: boolean;\n  tools?: boolean;\n  readOnly?: boolean;\n}>;\n\ntype InvocationMode = keyof HarnessInvocationModes;\n\nconst ALTERNATE_INVOCATION_MODE: Partial<Record<InvocationMode, InvocationMode>> = {\n  advisor: \"agent\",\n  advisorStructured: \"agentStructured\",\n  agent: \"advisor\",\n  agentStructured: \"advisorStructured\",\n};\n\nconst INVOCATION_MODE_DESCRIPTION: Record<InvocationMode, string> = {\n  advisor: \"advisor without tools\",\n  advisorStructured: \"structured (JSON) advisor without tools\",\n  readOnly: \"read-only full agent\",\n  readOnlyStructured: \"structured (JSON) read-only full agent\",\n  agent: \"full agent\",\n  agentStructured: \"structured (JSON) full agent\",\n};\n\nconst INVOCATION_RETRY_HINT: Partial<Record<InvocationMode, string>> = {\n  advisor: \"; retry with tools: true to start its full agent\",\n  advisorStructured: \"; retry with tools: true to start its full agent\",\n  agent: \"; retry with tools: false to use its advisor without tools\",\n  agentStructured: \"; retry with tools: false to use its advisor without tools\",\n};\n\nfunction requestedInvocationMode(options: InvocationOptions): InvocationMode {\n  if (options.readOnly === true) {\n    return options.structured === true ? \"readOnlyStructured\" : \"readOnly\";\n  }\n  if (options.tools === true) return options.structured === true ? \"agentStructured\" : \"agent\";\n  return options.structured === true ? \"advisorStructured\" : \"advisor\";\n}\n\n/** One lowercase word, so an effort can never turn into a flag of its own. */\nconst EFFORT_PATTERN = /^[a-z]+$/u;\n\n/**\n * Rejects a model or effort the harness can't take. No mode switch fixes that, so no retry.\n *\n * @param id - Harness id for the message.\n * @param invocation - Templates that decide which selections exist.\n * @param options - Requested model and effort.\n * @returns {string | null} The rejection, or null when both are accepted.\n */\nexport function selectionError(\n  id: string,\n  invocation: HarnessInvocation,\n  options: InvocationOptions,\n): string | null {\n  if (options.model !== undefined && !invocation.modelArgs) {\n    return `Harness ${id} does not support model selection`;\n  }\n  if (options.effort === undefined) return null;\n  if (!invocation.effortArgs) return `Harness ${id} does not support reasoning effort`;\n  return EFFORT_PATTERN.test(options.effort)\n    ? null\n    : \"Reasoning effort must be one lowercase word, such as low or high\";\n}\n\n/**\n * Explains an explicit `tools: false` beside `readOnly: true`, or returns null.\n * Read-only access still hands the harness tools, so the pair is rejected\n * instead of one flag silently overriding the other.\n *\n * @param id - Harness id for the message.\n * @param invocation - Templates that decide which retries are offered.\n * @param options - Requested execution mode.\n * @returns {string | null} The conflict with its executable retries, or null.\n */\nfunction accessConflictError(\n  id: string,\n  invocation: HarnessInvocation,\n  options: InvocationOptions,\n): string | null {\n  if (options.readOnly !== true || options.tools !== false) return null;\n\n  const retries: string[] = [];\n  if (invocationTemplate(invocation, requestedInvocationMode(options))) {\n    retries.push(\"tools: true to keep its read-only tools\");\n  }\n  if (invocationTemplate(invocation, requestedInvocationMode({ ...options, readOnly: false }))) {\n    retries.push(\"readOnly: false to use its advisor without tools\");\n  }\n  const error = `Harness ${id} cannot run readOnly with tools: false, since read-only access still uses tools`;\n  return retries.length === 0 ? error : `${error}; retry with ${retries.join(\", or with \")}`;\n}\n\nfunction invocationTemplate(\n  invocation: HarnessInvocation,\n  mode: InvocationMode,\n): readonly string[] | undefined {\n  switch (mode) {\n    case \"advisor\":\n      return invocation.noToolsArgs;\n    case \"advisorStructured\":\n      return invocation.noToolsJsonArgs;\n    case \"readOnly\":\n      return invocation.readOnlyArgs;\n    case \"readOnlyStructured\":\n      return invocation.readOnlyJsonArgs;\n    case \"agent\":\n      return invocation.args;\n    case \"agentStructured\":\n      return invocation.jsonArgs;\n  }\n}\n\nfunction invocationRetryHint(\n  invocation: HarnessInvocation,\n  mode: InvocationMode,\n  options: InvocationOptions,\n): string {\n  const withoutStructured = requestedInvocationMode({ ...options, structured: false });\n  if (options.structured === true) {\n    if (invocationTemplate(invocation, withoutStructured)) {\n      return \"; retry with structured: false\";\n    }\n    const alternateWithoutStructured = ALTERNATE_INVOCATION_MODE[withoutStructured];\n    if (\n      alternateWithoutStructured !== undefined &&\n      invocationTemplate(invocation, alternateWithoutStructured)\n    ) {\n      return `; retry with structured: false and tools: ${!options.tools}`;\n    }\n  }\n\n  const alternateMode = ALTERNATE_INVOCATION_MODE[mode];\n  const alternateAvailable =\n    alternateMode === undefined ? undefined : invocationTemplate(invocation, alternateMode);\n  return alternateAvailable ? (INVOCATION_RETRY_HINT[mode] ?? \"\") : \"\";\n}\n\n/**\n * Orders two dotted versions numerically; a pre-release tag sorts below its release.\n *\n * @param a - Left version.\n * @param b - Right version.\n * @returns {number} Negative when a is older, positive when newer, zero when equal.\n */\nfunction compareVersions(a: string, b: string): number {\n  const [aBase = \"\", aPre] = a.split(\"-\", 2);\n  const [bBase = \"\", bPre] = b.split(\"-\", 2);\n  const left = aBase.split(\".\").map(Number);\n  const right = bBase.split(\".\").map(Number);\n  for (let i = 0; i < Math.max(left.length, right.length); i++) {\n    const diff = (left[i] ?? 0) - (right[i] ?? 0);\n    if (diff !== 0) return diff;\n  }\n  return Number(aPre === undefined) - Number(bPre === undefined);\n}\n\n/**\n * Refuses read-only runs on a CLI older than the recipe's version floor. An unknown version fails closed.\n *\n * @param id - Harness id for the message.\n * @param invocation - Recipe that may carry `readOnlyMinVersion`.\n * @param installed - Version the installed CLI reports, or null when it can't tell.\n * @returns {string | null} The incompatibility, or null when no floor applies or the version meets it.\n */\nexport function readOnlyVersionError(\n  id: string,\n  invocation: HarnessInvocation | null,\n  installed: string | null,\n): string | null {\n  const floor = invocation?.readOnlyMinVersion;\n  if (floor === undefined) return null;\n  const error = `Harness ${id} requires version ${floor} or newer for read-only runs`;\n  if (installed === null) return `${error}; installed version unknown`;\n  if (compareVersions(installed, floor) < 0) return `${error}; installed ${installed}`;\n  return null;\n}\n\nfunction fillArgs(\n  args: readonly string[] | undefined,\n  placeholder: string,\n  value: string | undefined,\n): string[] {\n  if (value === undefined || !args) return [];\n  return args.map((arg) => arg.replaceAll(placeholder, () => value));\n}\n\nfunction buildInvocationArgs(\n  template: readonly string[],\n  prompt: string,\n  invocation: HarnessInvocation,\n  options: InvocationOptions,\n): string[] {\n  return [\n    ...fillArgs(template, \"{prompt}\", prompt),\n    ...fillArgs(invocation.modelArgs, \"{model}\", options.model),\n    ...fillArgs(invocation.effortArgs, \"{effort}\", options.effort),\n  ];\n}\n\nfunction signalProcessGroup(pid: number, signal: NodeJS.Signals): void {\n  try {\n    process.kill(-pid, signal);\n  } catch (error) {\n    if (!(error instanceof Error && \"code\" in error && error.code === \"ESRCH\")) throw error;\n  }\n}\n\n/**\n * Keep escalation alive even when the root exits before its descendants.\n * @param pid - Root of the command's process group or Windows tree.\n */\nasync function terminateCommand(pid: number): Promise<void> {\n  if (process.platform === \"win32\") {\n    await new Promise<void>((resolve, reject) => {\n      execFile(\n        join(process.env.SystemRoot ?? \"C:\\\\Windows\", \"System32\", \"taskkill.exe\"),\n        [\"/PID\", String(pid), \"/T\", \"/F\"],\n        { windowsHide: true, timeout: 2000, killSignal: \"SIGKILL\" },\n        (error) => (error ? reject(error) : resolve()),\n      );\n    });\n    return;\n  }\n\n  signalProcessGroup(pid, \"SIGTERM\");\n  await delay(500);\n  signalProcessGroup(pid, \"SIGKILL\");\n}\n\n/**\n * Tells a missing cwd from a missing binary, both `spawn <command> ENOENT` from Node.\n *\n * @param command - Command that was spawned.\n * @param cwd - Working directory passed to the spawn, if any.\n * @param error - Error thrown by `spawn` or emitted by the child.\n * @returns {unknown} The error with a message that names the cause, keeping its `code`.\n */\nfunction spawnError(command: string, cwd: string | undefined, error: unknown): unknown {\n  if (!(error instanceof Error && \"code\" in error)) return error;\n  if (error.code !== \"ENOENT\" && error.code !== \"ENOTDIR\") return error;\n  let message: string;\n  if (cwd !== undefined && !isDirectory(cwd)) {\n    message = existsSync(cwd)\n      ? `Working directory is not a directory: ${cwd}`\n      : `Working directory not found: ${cwd}`;\n  } else if (error.code === \"ENOENT\") {\n    message = `Command not found: ${command}. Install it or add it to PATH`;\n  } else {\n    return error;\n  }\n  return Object.assign(new Error(message, { cause: error }), { code: error.code });\n}\n\nfunction isDirectory(path: string): boolean {\n  try {\n    return statSync(path).isDirectory();\n  } catch {\n    return false;\n  }\n}\n\n/** An `<invoke>` or `<function_calls>` tag, with or without a namespace prefix. */\nconst TOOL_CALL_TEXT = /<(?:[\\w-]+:)?(?:invoke|function_calls)\\b/u;\n\nfunction executeCommand(\n  command: string,\n  args: readonly string[],\n  options: CommandOptions,\n): Promise<InvokeResult> {\n  return new Promise((resolve, reject) => {\n    let stdout = \"\";\n    let stderr = \"\";\n    let stopped: \"timeout\" | \"abort\" | undefined;\n    let lastOutputAt = performance.now();\n    let idleMs: number | undefined;\n    let settled = false;\n    let timer: ReturnType<typeof setTimeout> | undefined;\n    let abortListener: ReturnType<typeof addAbortListener> | undefined;\n\n    if (options.signal?.aborted) {\n      stopped = \"abort\";\n      finish(null);\n      return;\n    }\n\n    let child: ChildProcessByStdio<null, Readable, Readable>;\n    try {\n      child = spawn(command, args, {\n        cwd: options.cwd,\n        env: options.env ? { ...process.env, ...options.env } : process.env,\n        stdio: [\"ignore\", \"pipe\", \"pipe\"],\n        detached:\n          process.platform !== \"win32\" &&\n          (Boolean(options.timeoutMs) || options.signal !== undefined),\n      });\n    } catch (error) {\n      fail(spawnError(command, options.cwd, error));\n      return;\n    }\n\n    if (options.timeoutMs) timer = setTimeout(() => stop(\"timeout\"), options.timeoutMs);\n    if (options.signal) abortListener = addAbortListener(options.signal, () => stop(\"abort\"));\n\n    // A stream decoder keeps a multibyte character split across two chunks whole.\n    child.stdout.setEncoding(\"utf8\");\n    child.stderr.setEncoding(\"utf8\");\n    child.stdout.on(\"data\", (chunk: string) => {\n      stdout += chunk;\n      lastOutputAt = performance.now();\n    });\n    child.stderr.on(\"data\", (chunk: string) => {\n      stderr += chunk;\n      lastOutputAt = performance.now();\n    });\n    child.on(\"error\", (error) => fail(spawnError(command, options.cwd, error)));\n    child.on(\"close\", (code) => {\n      if (stopped === undefined) finish(code);\n    });\n\n    function cleanup(): void {\n      if (timer) clearTimeout(timer);\n      abortListener?.[Symbol.dispose]();\n    }\n\n    function fail(error: unknown): void {\n      if (settled) return;\n      settled = true;\n      cleanup();\n      reject(error);\n    }\n\n    function stop(reason: \"timeout\" | \"abort\"): void {\n      if (settled || stopped !== undefined) return;\n      stopped = reason;\n      idleMs = Math.round(performance.now() - lastOutputAt);\n      cleanup();\n      if (child.pid === undefined) return;\n      void terminateCommand(child.pid).then(\n        () => {\n          child.stdout.destroy();\n          child.stderr.destroy();\n          finish(null);\n        },\n        (error: unknown) => {\n          child.stdout.destroy();\n          child.stderr.destroy();\n          fail(error);\n        },\n      );\n    }\n\n    function finish(code: number | null): void {\n      if (settled) return;\n      settled = true;\n      cleanup();\n      resolve({\n        command,\n        args: [...args],\n        stdout,\n        stderr,\n        exitCode: stopped === undefined ? code : null,\n        timedOut: stopped === \"timeout\",\n        aborted: stopped === \"abort\",\n        ...(idleMs === undefined ? {} : { idleMs }),\n      });\n    }\n  });\n}\n\nexport abstract class Harness {\n  abstract readonly id: HarnessId;\n  abstract readonly name: string;\n  abstract readonly binaries: string[];\n  abstract readonly config: PathCandidate[];\n  abstract readonly sessions: PathCandidate[];\n  abstract readonly persistence: StorageDescriptor[];\n  abstract readonly instructions: PathCandidate[];\n  abstract readonly skills: PathCandidate[];\n  /** User-scope skills directory that skill synchronization links; null when none is verified. */\n  readonly skillsSyncTarget: SkillsSyncTarget | null = null;\n  abstract readonly commands: PathCandidate[];\n  /** Reusable prompt files; empty when no CLI template location is verified. */\n  readonly promptTemplates: PathCandidate[] = [];\n  /** Stable user-scope destination used by prompt template synchronization. */\n  readonly promptTemplateSyncTarget: PromptTemplateSyncTarget | null = null;\n  abstract readonly hooks: PathCandidate[];\n  /** Where the harness keeps its temp files; empty when not verified. */\n  readonly temp: PathCandidate[] = [];\n  /** Environment variables that move a root of this harness; empty when none is verified. */\n  readonly envOverrides: EnvOverride[] = [];\n  abstract readonly capabilities: HarnessCapabilities;\n  abstract readonly detection: HarnessDetection;\n  /** Non-interactive invocation recipe; null when the harness has no headless mode. */\n  abstract readonly invocation: HarnessInvocation | null;\n  /** Native model-listing recipe; null when the harness cannot enumerate available models. */\n  readonly modelListing: HarnessModelListing | null = null;\n  /** Config files that hold MCP server definitions; empty when unknown or unsupported. */\n  readonly mcpConfigs: McpConfigFile[] = [];\n  /**\n   * The user-scope global instructions file this harness reads, as a path\n   * template; null when there is no stable file (or another harness's file\n   * covers it via vendor compatibility).\n   */\n  readonly agentsFile: string | null = null;\n\n  isInstalled(): boolean {\n    const cmd = process.platform === \"win32\" ? \"where\" : \"which\";\n    return this.binaries.some((binary) => {\n      try {\n        execFileSync(cmd, [binary], { stdio: \"pipe\" });\n        return true;\n      } catch {\n        return false;\n      }\n    });\n  }\n\n  detectEnv(): boolean {\n    return this.detection.envVars.some((v) => !!process.env[v]);\n  }\n\n  detectProject(cwd?: string): boolean {\n    const dir = cwd ?? process.cwd();\n    return this.detection.projectMarkers.some((marker) => existsSync(join(dir, marker)));\n  }\n\n  get version(): string | null {\n    for (const binary of this.binaries) {\n      try {\n        const output = execFileSync(binary, [\"--version\"], {\n          encoding: \"utf8\",\n          stdio: [\"pipe\", \"pipe\", \"pipe\"],\n          timeout: 5000,\n        });\n        const match = output.match(/(\\d+\\.\\d+\\.\\d+(?:-[\\w.]+)?)/);\n        if (match?.[1]) return match[1];\n      } catch {\n        continue;\n      }\n    }\n    return null;\n  }\n\n  /**\n   * Invocation modes available without fallback or prompt-only restrictions.\n   *\n   * @returns {HarnessInvocationModes} The exact supported invocation modes.\n   */\n  get invocationModes(): HarnessInvocationModes {\n    return {\n      advisor: this.invocation?.noToolsArgs !== undefined,\n      advisorStructured: this.invocation?.noToolsJsonArgs !== undefined,\n      readOnly: this.invocation?.readOnlyArgs !== undefined,\n      readOnlyStructured: this.invocation?.readOnlyJsonArgs !== undefined,\n      agent: this.invocation?.args !== undefined,\n      agentStructured: this.invocation?.jsonArgs !== undefined,\n    };\n  }\n\n  /**\n   * Whether a read-only run still has network for what it starts, MCP servers included.\n   *\n   * @param platform - Platform to answer for; defaults to this one.\n   * @returns {boolean | null} The checked answer, or null when nobody checked.\n   */\n  readOnlyNetwork(platform: string = process.platform): boolean | null {\n    const { readOnly, readOnlyStructured } = this.invocationModes;\n    const network = readOnly || readOnlyStructured ? this.invocation?.readOnlyNetwork : undefined;\n    if (network === undefined || !Object.hasOwn(network, platform)) return null;\n    return network[platform as Platform] ?? null;\n  }\n\n  /**\n   * Expands the invocation template for one prompt, without spawning anything.\n   * Returns null when the harness has no headless mode, or no structured mode\n   * when `structured` is requested.\n   *\n   * @param prompt - Prompt inserted into the invocation template.\n   * @param options - Requested model and execution mode.\n   * @returns {{ command: string, args: string[] } | null} The executable invocation, or null.\n   */\n  buildInvocation(\n    prompt: string,\n    options: InvocationOptions = {},\n  ): { command: string; args: string[] } | null {\n    if (!this.invocation) return null;\n    const command = this.invocation.binary ?? this.binaries[0];\n    if (!command) return null;\n    if (selectionError(this.id, this.invocation, options) !== null) return null;\n    if (accessConflictError(this.id, this.invocation, options) !== null) return null;\n    const template = invocationTemplate(this.invocation, requestedInvocationMode(options));\n    if (!template) return null;\n    return { command, args: buildInvocationArgs(template, prompt, this.invocation, options) };\n  }\n\n  /**\n   * Explains why an invocation option set cannot be built, or returns null when supported.\n   *\n   * @param options - Requested model and execution mode.\n   * @returns {string | null} The incompatibility reason, or null when supported.\n   */\n  invocationError(options: InvocationOptions = {}): string | null {\n    if (!this.invocation) return `Harness ${this.id} has no non-interactive invocation`;\n    const unsupported = selectionError(this.id, this.invocation, options);\n    if (unsupported !== null) return unsupported;\n    const conflict = accessConflictError(this.id, this.invocation, options);\n    if (conflict !== null) return conflict;\n    const mode = requestedInvocationMode(options);\n    if (invocationTemplate(this.invocation, mode)) return null;\n\n    const error = `Harness ${this.id} has no ${INVOCATION_MODE_DESCRIPTION[mode]} invocation`;\n    return `${error}${invocationRetryHint(this.invocation, mode, options)}`;\n  }\n\n  /**\n   * Runs one prompt through the harness non-interactively and collects the\n   * output. stdin is closed so a harness that falls back to interactive mode\n   * exits instead of waiting forever. Inside a harness that `invoke` started, it rejects.\n   *\n   * @param prompt - Prompt sent to the harness.\n   * @param options - Invocation, environment, timeout, and cancellation options.\n   * @returns {Promise<InvokeResult>} The completed process result.\n   */\n  invoke(prompt: string, options: InvokeOptions = {}): Promise<InvokeResult> {\n    const parent = process.env[PARENT_ENV];\n    if (parent) {\n      return Promise.reject(\n        new Error(\n          `Nested run refused: this process already runs inside ${parent}, started by harnesses. ` +\n            `${this.id} under it would stack agents, and in a read-only sandbox it gets no network ` +\n            `and hangs until the deadline. Answer without it`,\n        ),\n      );\n    }\n\n    const invocationOptions = {\n      model: options.model,\n      effort: options.effort,\n      structured: options.structured,\n      tools: options.tools,\n      readOnly: options.readOnly,\n    };\n    const built = this.buildInvocation(prompt, invocationOptions);\n    if (!built) {\n      return Promise.reject(\n        new Error(this.invocationError(invocationOptions) ?? \"Invalid invocation\"),\n      );\n    }\n    const versionError = this.readOnlyVersionError(invocationOptions);\n    if (versionError) return Promise.reject(new Error(versionError));\n\n    const command = { ...options, env: { ...options.env, [PARENT_ENV]: this.id } };\n    const advisor = requestedInvocationMode(invocationOptions).startsWith(\"advisor\");\n    const streamArgs = options.structured ? undefined : this.invocation?.streamArgs;\n    const run = streamArgs\n      ? executeCommand(built.command, [...built.args, ...streamArgs], command).then((result) => ({\n          ...result,\n          stdout: this.foldStreamOutput(result.stdout, !result.timedOut && !result.aborted),\n        }))\n      : executeCommand(built.command, built.args, command);\n    return run.then((result) =>\n      advisor && TOOL_CALL_TEXT.test(result.stdout)\n        ? { ...result, toolCallsAsText: true as const }\n        : result,\n    );\n  }\n\n  /**\n   * Turns the events a `streamArgs` run printed back into the text the plain\n   * run would have printed.\n   *\n   * @param _stdout - Event output as captured, possibly cut short.\n   * @param _complete - False when a deadline or cancellation stopped the run.\n   * @returns {string} The answer text, or what the model had written so far.\n   */\n  protected foldStreamOutput(_stdout: string, _complete: boolean): string {\n    throw new Error(`Harness ${this.id} does not implement stream output folding`);\n  }\n\n  /**\n   * Explains why the installed CLI cannot run a read-only recipe that carries a\n   * version floor, or returns null when no floor applies or the installed\n   * version meets it. An unknown version fails closed, like a missing recipe.\n   *\n   * @param options - Requested execution mode.\n   * @returns {string | null} The version incompatibility, or null when the run may proceed.\n   */\n  private readOnlyVersionError(options: InvocationOptions): string | null {\n    if (this.invocation?.readOnlyMinVersion === undefined || options.readOnly !== true) return null;\n    return readOnlyVersionError(this.id, this.invocation, this.version);\n  }\n\n  /**\n   * Expands the native model-listing recipe without spawning anything.\n   *\n   * @param search - Optional model search filter; without native `searchArgs` it is applied\n   *   to the parsed output instead, so the command is the unfiltered one.\n   * @returns {{ command: string, args: string[] } | null} The command, or null when unsupported.\n   */\n  buildModelListInvocation(search?: string): { command: string; args: string[] } | null {\n    if (!this.modelListing) return null;\n    const command = this.binaries[0];\n    if (!command) return null;\n    const template =\n      search === undefined\n        ? this.modelListing.args\n        : (this.modelListing.searchArgs ?? this.modelListing.args);\n    return {\n      command,\n      args: template.map((arg) => arg.replaceAll(\"{search}\", () => search ?? \"\")),\n    };\n  }\n\n  /**\n   * Runs the harness's native model-listing command and normalizes its output.\n   * stdin is closed for the same reason as {@link invoke}.\n   *\n   * @param options - Search, environment, timeout, and cancellation options.\n   * @returns {Promise<ListModelsResult>} The normalized command and model result.\n   */\n  async listModels(options: ListModelsOptions = {}): Promise<ListModelsResult> {\n    const built = this.buildModelListInvocation(options.search);\n    if (!built) throw new Error(`Harness ${this.id} does not support model listing`);\n\n    const result = await executeCommand(built.command, built.args, options);\n    if (result.timedOut || result.aborted || result.exitCode !== 0)\n      return { ...result, models: [] };\n\n    const models = this.parseModelListingOutput(result.stdout);\n    if (options.search === undefined || this.modelListing?.searchArgs) return { ...result, models };\n    const search = options.search.toLowerCase();\n    return { ...result, models: models.filter((model) => model.id.toLowerCase().includes(search)) };\n  }\n\n  /**\n   * The value `model` takes for one listed model: `provider/id` unless the\n   * harness overrides it.\n   *\n   * @param model - A model returned by {@link listModels}.\n   * @returns {string} The selector this harness's `modelArgs` accept.\n   */\n  modelSelector(model: Readonly<AvailableModel>): string {\n    return `${model.provider}/${model.id}`;\n  }\n\n  /**\n   * Converts a successful native model-listing response to the shared shape.\n   *\n   * @param _stdout - Native command output to parse.\n   */\n  protected parseModelListingOutput(_stdout: string): AvailableModel[] {\n    throw new Error(`Harness ${this.id} does not implement model-list output parsing`);\n  }\n\n  /**\n   * Filters one candidate list to the platform and expands its path\n   * templates: the shared pipeline behind {@link resolve} and the MCP\n   * config surface.\n   *\n   * @param entries - Candidate paths to filter and resolve.\n   * @param options - Platform and path-resolution overrides.\n   * @returns {T[]} Resolved candidates supported on the selected platform.\n   */\n  resolveCandidates<T extends PathCandidate>(\n    entries: readonly T[],\n    options: ResolveOptions = {},\n  ): T[] {\n    const raw = options.platform ?? process.platform;\n\n    if (!Object.hasOwn(SUPPORTED_PLATFORMS, raw)) {\n      throw new Error(`Unsupported platform: ${raw}. Expected one of: linux, darwin, win32`);\n    }\n\n    const platform = raw as Platform;\n\n    return entries\n      .filter((entry) => !entry.platforms || entry.platforms.includes(platform))\n      .map((entry) => ({ ...entry, path: resolvePathTemplate(entry.path, options) }));\n  }\n\n  resolve(options: ResolveOptions = {}): ResolvedPaths {\n    return {\n      config: this.resolveCandidates(this.config, options),\n      sessions: this.resolveCandidates(this.sessions, options),\n      instructions: this.resolveCandidates(this.instructions, options),\n      skills: this.resolveCandidates(this.skills, options),\n      skillsSyncTarget:\n        this.skillsSyncTarget === null\n          ? null\n          : (this.resolveCandidates([this.skillsSyncTarget], options)[0] ?? null),\n      commands: this.resolveCandidates(this.commands, options),\n      promptTemplates: this.resolveCandidates(this.promptTemplates, options),\n      promptTemplateSyncTarget:\n        this.promptTemplateSyncTarget === null\n          ? null\n          : (this.resolveCandidates([this.promptTemplateSyncTarget], options)[0] ?? null),\n      hooks: this.resolveCandidates(this.hooks, options),\n      temp: this.resolveTemp(options),\n    };\n  }\n\n  /**\n   * Temp roots for the platform. A `temp` override set in the environment\n   * replaces its default root, the same move the harness makes itself.\n   *\n   * @param options - Platform and path-resolution overrides.\n   * @returns {PathCandidate[]} Resolved temp roots.\n   */\n  private resolveTemp(options: ResolveOptions): PathCandidate[] {\n    const temp = this.resolveCandidates(this.temp, options);\n    const override = this.resolveCandidates(this.envOverrides, options).find((entry) =>\n      entry.relocates.includes(\"temp\"),\n    );\n    const value = override ? process.env[override.variable] : undefined;\n    if (!override || !value) return temp;\n    return temp.map((entry) => ({ ...entry, path: moveRoot(entry.path, override.path, value) }));\n  }\n}\n\nexport type HarnessConstructor = new () => Harness;\n","import { stripVTControlCharacters } from \"node:util\";\nimport { Harness } from \"../harness.ts\";\nimport type { AvailableModel } from \"../types.ts\";\n\n/**\n * Parses `agy models`: one `id<TAB>label` row per model on stdout, while the\n * `Fetching available models...` line goes to stderr. Every model runs through\n * Google's Antigravity service, the Claude and GPT-OSS ones included, so they\n * all carry the `google` provider.\n *\n * @param stdout - Native model-listing output.\n * @returns {AvailableModel[]} The listed models, in the CLI's order.\n */\nexport function parseAntigravityModels(stdout: string): AvailableModel[] {\n  const lines = stripVTControlCharacters(stdout)\n    .split(/\\r?\\n/)\n    .map((line) => line.trim())\n    .filter(Boolean);\n  if (lines.length === 0) throw new Error(\"Unexpected empty Antigravity model-list output\");\n\n  return lines.map((line) => {\n    const match = /^(\\S+)\\t.+$/.exec(line);\n    if (!match?.[1])\n      throw new Error(`Unexpected Antigravity model-list row: ${JSON.stringify(line)}`);\n    return { provider: \"google\", id: match[1] };\n  });\n}\n\nexport default class Antigravity extends Harness {\n  readonly id = \"antigravity\";\n  readonly name = \"Google Antigravity CLI\";\n  readonly binaries = [\"agy\"];\n  readonly capabilities = {\n    mcp: true,\n    vision: true,\n    audio: true,\n    video: true,\n    tools: true,\n    streaming: true,\n  };\n  readonly config: Harness[\"config\"] = [\n    {\n      path: \"~/.gemini/config/config.json\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Shared Antigravity configuration and user settings.\",\n    },\n    {\n      path: \"~/.gemini/antigravity-cli/settings.json\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"CLI-specific settings, including trusted workspaces.\",\n    },\n    {\n      path: \"~/.gemini/config/skills.json\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Explicit registrations of skill directories outside the default locations.\",\n    },\n    {\n      path: \"~/.gemini/config/plugins.json\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Explicit registrations of plugin directories outside the default locations.\",\n    },\n    {\n      path: \".agents/skills.json\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Workspace registrations of skill directories outside .agents/skills/.\",\n    },\n    {\n      path: \".agents/plugins.json\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Workspace registrations of plugin directories outside .agents/plugins/.\",\n    },\n  ];\n  readonly sessions: Harness[\"sessions\"] = [\n    {\n      path: \"~/.gemini/antigravity-cli/conversations/\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Persisted CLI conversations.\",\n    },\n    {\n      path: \"~/.gemini/antigravity-cli/history.jsonl\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"CLI prompt history.\",\n    },\n    {\n      path: \"~/.gemini/antigravity-cli/conversation_summaries.db\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Conversation summary index.\",\n    },\n  ];\n  readonly persistence: Harness[\"persistence\"] = [\n    { format: \"JSON\", level: \"official\", note: \"Settings and project metadata.\" },\n    { format: \"JSONL\", level: \"official\", note: \"Prompt history.\" },\n    { format: \"SQLite\", level: \"official\", note: \"Conversation summary index.\" },\n    { format: \"Protocol Buffers\", level: \"official\", note: \"Conversation and runtime state.\" },\n  ];\n  readonly instructions: Harness[\"instructions\"] = [\n    {\n      path: \"~/.gemini/config/AGENTS.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global rules in the shared Antigravity customization root.\",\n    },\n    {\n      path: \"AGENTS.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Workspace instructions; GEMINI.md is also supported.\",\n    },\n    {\n      path: \"GEMINI.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Workspace instructions compatible with Gemini CLI.\",\n    },\n  ];\n  readonly skills: Harness[\"skills\"] = [\n    { path: \".agents/skills/\", scope: \"project\", level: \"official\" },\n    { path: \"~/.gemini/config/skills/\", scope: \"user\", level: \"official\" },\n  ];\n  override readonly skillsSyncTarget: Harness[\"skillsSyncTarget\"] = {\n    path: \"~/.gemini/config/skills/\",\n    scope: \"user\",\n    level: \"official\",\n  };\n  readonly commands: Harness[\"commands\"] = [];\n  readonly hooks: Harness[\"hooks\"] = [\n    { path: \".agents/hooks.json\", scope: \"project\", level: \"official\" },\n    { path: \"~/.gemini/config/hooks.json\", scope: \"user\", level: \"official\" },\n  ];\n  readonly invocation: Harness[\"invocation\"] = {\n    args: [\"--print\", \"{prompt}\"],\n    jsonArgs: [\"--print\", \"--output-format\", \"json\", \"{prompt}\"],\n    modelArgs: [\"--model\", \"{model}\"],\n    level: \"official\",\n    note: \"Non-interactive print mode.\",\n  };\n  override readonly modelListing: Harness[\"modelListing\"] = {\n    args: [\"models\"],\n    level: \"official\",\n    note: \"Prints one id and display name per row, with no default marked and no filter; verified with 1.2.5.\",\n  };\n  override readonly mcpConfigs: Harness[\"mcpConfigs\"] = [\n    {\n      path: \"~/.gemini/config/mcp_config.json\",\n      scope: \"user\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"antigravity\",\n    },\n  ];\n  override readonly agentsFile = \"~/.gemini/config/AGENTS.md\";\n  readonly detection = {\n    envVars: [],\n    projectMarkers: [\".antigravitycli\"],\n  };\n\n  protected override parseModelListingOutput(stdout: string): AvailableModel[] {\n    return parseAntigravityModels(stdout);\n  }\n\n  /**\n   * `agy --model` refuses `google/<id>`, so the bare id is the selector.\n   *\n   * @param model - A model returned by {@link listModels}.\n   * @returns {string} The model id.\n   */\n  override modelSelector(model: Readonly<AvailableModel>): string {\n    return model.id;\n  }\n}\n","import { Harness } from \"../harness.ts\";\n\n/** The fields of a Claude `stream-json` event the text fold reads; the rest stays unknown. */\ninterface ClaudeStreamEvent {\n  readonly type?: unknown;\n  readonly result?: unknown;\n  readonly event?: {\n    readonly type?: unknown;\n    readonly content_block?: { readonly type?: unknown } | null;\n    readonly delta?: { readonly type?: unknown; readonly text?: unknown } | null;\n  } | null;\n}\n\nfunction parseStreamLine(line: string): ClaudeStreamEvent | undefined {\n  try {\n    const parsed: unknown = JSON.parse(line);\n    // Every protocol message carries a string type; any other JSON is output to keep.\n    return typeof parsed === \"object\" &&\n      parsed !== null &&\n      \"type\" in parsed &&\n      typeof parsed.type === \"string\"\n      ? (parsed as ClaudeStreamEvent)\n      : undefined;\n  } catch {\n    return undefined;\n  }\n}\n\nfunction startsTextBlock(event: ClaudeStreamEvent): boolean {\n  return (\n    event.type === \"stream_event\" &&\n    event.event?.type === \"content_block_start\" &&\n    event.event.content_block?.type === \"text\"\n  );\n}\n\nfunction textDelta(event: ClaudeStreamEvent): string | undefined {\n  if (event.type !== \"stream_event\" || event.event?.type !== \"content_block_delta\")\n    return undefined;\n  const delta = event.event.delta;\n  return delta?.type === \"text_delta\" && typeof delta.text === \"string\" ? delta.text : undefined;\n}\n\n/** Collects one run's events line by line. */\nclass ClaudeStreamFold {\n  /** Text blocks streamed so far, in order. */\n  private readonly blocks: string[] = [];\n  /** Output lines that are not events. */\n  private readonly other: string[] = [];\n  private result: string | undefined;\n\n  add(line: string): void {\n    if (line.trim().length === 0) return;\n    const event = parseStreamLine(line);\n    if (!event) {\n      this.other.push(line);\n      return;\n    }\n    if (event.type === \"result\" && typeof event.result === \"string\") this.result = event.result;\n    if (startsTextBlock(event)) this.blocks.push(\"\");\n    const text = textDelta(event);\n    if (text !== undefined) this.blocks.push((this.blocks.pop() ?? \"\") + text);\n  }\n\n  text(complete: boolean): string {\n    const prefix = this.other.map((line) => `${line}\\n`).join(\"\");\n    if (complete && this.result !== undefined) return `${prefix}${this.result}\\n`;\n    const text = this.blocks.filter((block) => block.length > 0).join(\"\\n\\n\");\n    return text.length > 0 ? `${prefix}${text}\\n` : prefix;\n  }\n}\n\n/**\n * Folds `claude -p --output-format stream-json --include-partial-messages` back\n * into what plain `claude -p` prints. A finished run takes the `result` event,\n * which carries the same text, errors included. A stopped run has none, so it\n * gets the text blocks streamed so far, one paragraph each. Lines that are not\n * events pass through, except an event the stop cut in half.\n *\n * @param stdout - Captured event output.\n * @param complete - False when a deadline or cancellation stopped the run.\n * @returns {string} The plain text answer, or the part written before the stop.\n */\nexport function foldClaudeStream(stdout: string, complete: boolean): string {\n  const lines = stdout.split(\"\\n\");\n  // A stop can cut the last event in half; one that still parses stays.\n  const tail = lines.at(-1);\n  if (!complete && tail?.startsWith(\"{\") && parseStreamLine(tail) === undefined) lines.pop();\n  const fold = new ClaudeStreamFold();\n  for (const line of lines) fold.add(line);\n  return fold.text(complete);\n}\n\n/** A toolless Claude without this writes `<invoke>` blocks as text and makes up their output. */\nconst ADVISOR_SYSTEM_PROMPT =\n  \"This run has no tools: nothing can be called, run or read, and no tool output will come back. \" +\n  \"Never write a tool call as text, such as an <invoke> or <function_calls> block. \" +\n  \"Answer from reasoning alone, and mark any value you did not derive in the answer itself as unverified.\";\n\nexport default class Claude extends Harness {\n  readonly id = \"claude\";\n  readonly name = \"Anthropic Claude Code\";\n  readonly binaries = [\"claude\"];\n  readonly capabilities = {\n    mcp: true,\n    vision: true,\n    audio: false,\n    video: false,\n    tools: true,\n    streaming: true,\n  };\n  readonly config: Harness[\"config\"] = [\n    { path: \"~/.claude/settings.json\", scope: \"user\", level: \"official\" },\n    {\n      path: \"~/.claude.json\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global MCP server configurations.\",\n    },\n    {\n      path: \".claude/settings.json\",\n      scope: \"project\",\n      level: \"official\",\n    },\n    {\n      path: \".claude/settings.local.json\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Local overrides, typically gitignored.\",\n    },\n    {\n      path: \".claude/.mcp.json\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Project-scoped MCP server configurations.\",\n    },\n    {\n      path: \"/etc/claude-code/managed-settings.json\",\n      scope: \"system\",\n      level: \"official\",\n      platforms: [\"linux\"],\n      note: \"Enterprise managed settings.\",\n    },\n    {\n      path: \"/Library/Application Support/ClaudeCode/managed-settings.json\",\n      scope: \"system\",\n      level: \"official\",\n      platforms: [\"darwin\"],\n      note: \"Enterprise managed settings.\",\n    },\n  ];\n  readonly sessions: Harness[\"sessions\"] = [\n    {\n      path: \"~/.claude/projects/<dash-encoded-cwd>/*.jsonl\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Per-project session transcripts in JSONL format.\",\n    },\n    {\n      path: \"~/.claude/history.jsonl\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Global prompt history across all projects.\",\n    },\n  ];\n  readonly persistence: Harness[\"persistence\"] = [\n    { format: \"JSON\", level: \"official\", note: \"Settings and MCP config files.\" },\n    {\n      format: \"JSONL\",\n      level: \"official\",\n      note: \"Session transcripts and global history.\",\n    },\n  ];\n  readonly instructions: Harness[\"instructions\"] = [\n    { path: \"CLAUDE.md\", scope: \"project\", level: \"official\" },\n    {\n      path: \".claude/CLAUDE.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Alternative project-level location.\",\n    },\n    {\n      path: \"~/.claude/CLAUDE.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level instructions.\",\n    },\n  ];\n  readonly skills: Harness[\"skills\"] = [\n    { path: \".claude/skills/\", scope: \"project\", level: \"official\" },\n    {\n      path: \"~/.claude/skills/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level skills.\",\n    },\n  ];\n  override readonly skillsSyncTarget: Harness[\"skillsSyncTarget\"] = {\n    path: \"~/.claude/skills/\",\n    scope: \"user\",\n    level: \"official\",\n  };\n  readonly commands: Harness[\"commands\"] = [\n    {\n      path: \".claude/commands/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Legacy slash commands, merged into skills.\",\n    },\n    {\n      path: \"~/.claude/commands/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Legacy global slash commands.\",\n    },\n  ];\n  override readonly promptTemplates = this.commands;\n  override readonly promptTemplateSyncTarget: Harness[\"promptTemplateSyncTarget\"] = {\n    path: \"~/.claude/commands/\",\n    scope: \"user\",\n    level: \"official\",\n    format: \"markdown\",\n  };\n  readonly hooks: Harness[\"hooks\"] = [\n    { path: \".claude/hooks/\", scope: \"project\", level: \"official\" },\n    {\n      path: \"~/.claude/hooks/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level hooks.\",\n    },\n  ];\n  readonly invocation: Harness[\"invocation\"] = {\n    args: [\"-p\", \"{prompt}\"],\n    jsonArgs: [\"-p\", \"--output-format\", \"json\", \"{prompt}\"],\n    noToolsArgs: [\n      \"-p\",\n      \"{prompt}\",\n      \"--append-system-prompt\",\n      ADVISOR_SYSTEM_PROMPT,\n      \"--strict-mcp-config\",\n      \"--tools\",\n      \"\",\n    ],\n    noToolsJsonArgs: [\n      \"-p\",\n      \"--output-format\",\n      \"json\",\n      \"{prompt}\",\n      \"--append-system-prompt\",\n      ADVISOR_SYSTEM_PROMPT,\n      \"--strict-mcp-config\",\n      \"--tools\",\n      \"\",\n    ],\n    readOnlyArgs: [\"-p\", \"{prompt}\", \"--strict-mcp-config\", \"--tools\", \"Read,Glob,Grep\"],\n    readOnlyJsonArgs: [\n      \"-p\",\n      \"--output-format\",\n      \"json\",\n      \"{prompt}\",\n      \"--strict-mcp-config\",\n      \"--tools\",\n      \"Read,Glob,Grep\",\n    ],\n    readOnlyMinVersion: \"2.1.175\",\n    modelArgs: [\"--model\", \"{model}\"],\n    effortArgs: [\"--effort\", \"{effort}\"],\n    streamArgs: [\"--output-format\", \"stream-json\", \"--verbose\", \"--include-partial-messages\"],\n    level: \"official\",\n    note: \"Headless print mode; add --output-format json for structured output. Plain text runs stream events instead and fold them back, since text mode prints nothing until the answer is complete and a timeout would lose all of it; --include-partial-messages streams a single long answer too, checked on 2.1.280. --tools only covers the built-in set, so every mode without the full agent adds --strict-mcp-config to drop configured MCP servers too; without it an advisor still sees every user and project MCP tool, checked on 2.1.280. Read-only runs keep the built-in Read, Glob and Grep tools, so no write tool exists whatever permission mode the settings carry; verified on 2.1.175 and 2.1.268. --permission-mode plan does not qualify: its shell commands run through the auto mode classifier, which let a file write through. Advisor runs append a system prompt saying no tools exist: without it Sonnet wrote `<invoke>` blocks as text in 3 of 3 runs on 2.1.289, with it in none.\",\n  };\n  override readonly mcpConfigs: Harness[\"mcpConfigs\"] = [\n    {\n      path: \"~/.claude.json\",\n      scope: \"user\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"standard\",\n    },\n    {\n      path: \".mcp.json\",\n      scope: \"project\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"standard\",\n    },\n  ];\n  override readonly temp: Harness[\"temp\"] = [\n    {\n      path: \"${TMPDIR}/claude-<uid>/\",\n      scope: \"data\",\n      level: \"official\",\n      platforms: [\"linux\"],\n      note: \"Session scratchpads sit under <dash-encoded-cwd>/<session-id>/scratchpad.\",\n    },\n    { path: \"/tmp/claude-<uid>/\", scope: \"data\", level: \"official\", platforms: [\"darwin\"] },\n    { path: \"${TMPDIR}/claude/\", scope: \"data\", level: \"official\", platforms: [\"win32\"] },\n  ];\n  override readonly envOverrides: Harness[\"envOverrides\"] = [\n    {\n      variable: \"CLAUDE_CONFIG_DIR\",\n      path: \"~/.claude\",\n      scope: \"user\",\n      level: \"official\",\n      relocates: [\n        \"config\",\n        \"sessions\",\n        \"instructions\",\n        \"skills\",\n        \"commands\",\n        \"promptTemplates\",\n        \"hooks\",\n      ],\n      note: \"Read from the shell or the env block of user or managed settings, not project settings.\",\n    },\n    {\n      variable: \"CLAUDE_CODE_TMPDIR\",\n      path: \"${TMPDIR}\",\n      scope: \"data\",\n      level: \"official\",\n      platforms: [\"linux\", \"win32\"],\n      relocates: [\"temp\"],\n      note: \"Read from the shell or the env block of user or managed settings, not project settings.\",\n    },\n    {\n      variable: \"CLAUDE_CODE_TMPDIR\",\n      path: \"/tmp\",\n      scope: \"data\",\n      level: \"official\",\n      platforms: [\"darwin\"],\n      relocates: [\"temp\"],\n      note: \"Read from the shell or the env block of user or managed settings, not project settings.\",\n    },\n  ];\n  override readonly agentsFile = \"~/.claude/CLAUDE.md\";\n  readonly detection = {\n    envVars: [\"CLAUDE_CODE\", \"CLAUDECODE\", \"CLAUDE_CODE_ENTRYPOINT\", \"CLAUDE_CONFIG_DIR\"],\n    projectMarkers: [\n      \".claude/settings.json\",\n      \".claude/settings.local.json\",\n      \".claude/skills\",\n      \"CLAUDE.md\",\n    ],\n  };\n\n  protected override foldStreamOutput(stdout: string, complete: boolean): string {\n    return foldClaudeStream(stdout, complete);\n  }\n}\n","import { Harness } from \"../harness.ts\";\nimport type { AvailableModel } from \"../types.ts\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Maps one catalog entry, or skips it when Codex leaves it out of its own picker.\n *\n * @param entry - One element of `models`.\n * @returns {AvailableModel | undefined} The model, or undefined for a hidden one.\n */\nfunction codexModel(entry: unknown): AvailableModel | undefined {\n  if (!isRecord(entry) || typeof entry[\"slug\"] !== \"string\")\n    throw new Error(`Unexpected Codex model-list entry: ${JSON.stringify(entry)?.slice(0, 200)}`);\n  if (entry[\"visibility\"] !== \"list\") return undefined;\n  const {\n    display_name: name,\n    context_window: contextWindow,\n    supported_reasoning_levels: levels,\n    input_modalities: input,\n  } = entry;\n  return {\n    provider: \"openai\",\n    id: entry[\"slug\"],\n    ...(typeof name === \"string\" ? { name } : {}),\n    ...(typeof contextWindow === \"number\" ? { contextWindow } : {}),\n    ...(Array.isArray(levels) ? { thinking: levels.length > 0 } : {}),\n    ...(Array.isArray(input) ? { images: input.includes(\"image\") } : {}),\n  };\n}\n\n/**\n * Parses `codex debug models`, the catalog Codex picks from, minus the models it hides.\n *\n * @param stdout - Native model-listing output.\n * @returns {AvailableModel[]} The listed models, in the CLI's order.\n */\nexport function parseCodexModels(stdout: string): AvailableModel[] {\n  let parsed: unknown;\n  try {\n    parsed = JSON.parse(stdout);\n  } catch {\n    throw new Error(`Unexpected Codex model-list output: ${JSON.stringify(stdout.slice(0, 200))}`);\n  }\n  if (!isRecord(parsed) || !Array.isArray(parsed[\"models\"]))\n    throw new Error(`Unexpected Codex model-list output: ${JSON.stringify(stdout.slice(0, 200))}`);\n\n  return parsed[\"models\"].flatMap((entry: unknown) => codexModel(entry) ?? []);\n}\n\nexport default class Codex extends Harness {\n  readonly id = \"codex\";\n  readonly name = \"OpenAI Codex CLI\";\n  readonly binaries = [\"codex\"];\n  readonly capabilities = {\n    mcp: true,\n    vision: true,\n    audio: false,\n    video: false,\n    tools: true,\n    streaming: true,\n  };\n  readonly config: Harness[\"config\"] = [\n    { path: \"~/.codex/config.toml\", scope: \"user\", level: \"official\" },\n    {\n      path: \".codex/config.toml\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Searched from cwd up to project root (.git boundary).\",\n    },\n    {\n      path: \"/etc/codex/config.toml\",\n      scope: \"system\",\n      level: \"official\",\n      platforms: [\"linux\", \"darwin\"],\n    },\n  ];\n  readonly sessions: Harness[\"sessions\"] = [\n    {\n      path: \"~/.codex/sessions/\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Session rollouts in JSONL format, organized by date.\",\n    },\n    {\n      path: \"~/.codex/history.jsonl\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Command history.\",\n    },\n    {\n      path: \"~/.codex/state_5.sqlite\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"SQLite state database for threads and agent state.\",\n    },\n  ];\n  readonly persistence: Harness[\"persistence\"] = [\n    { format: \"TOML\", level: \"official\", note: \"Configuration files.\" },\n    { format: \"JSONL\", level: \"official\", note: \"Conversation transcripts.\" },\n    { format: \"SQLite\", level: \"official\", note: \"Thread and agent state.\" },\n  ];\n  readonly instructions: Harness[\"instructions\"] = [\n    { path: \"AGENTS.md\", scope: \"project\", level: \"official\" },\n    {\n      path: \"AGENTS.override.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Local override, takes precedence over AGENTS.md.\",\n    },\n    {\n      path: \"~/.codex/AGENTS.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level instructions.\",\n    },\n    {\n      path: \"~/.codex/AGENTS.override.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global override, takes precedence over global AGENTS.md.\",\n    },\n  ];\n  readonly skills: Harness[\"skills\"] = [\n    { path: \".codex/skills/\", scope: \"project\", level: \"official\" },\n    { path: \".agents/skills/\", scope: \"project\", level: \"official\" },\n    {\n      path: \"~/.codex/skills/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Deprecated, use ~/.agents/skills/ instead.\",\n    },\n    { path: \"~/.agents/skills/\", scope: \"user\", level: \"official\" },\n    {\n      path: \"/etc/codex/skills/\",\n      scope: \"system\",\n      level: \"official\",\n      platforms: [\"linux\", \"darwin\"],\n    },\n  ];\n  override readonly skillsSyncTarget: Harness[\"skillsSyncTarget\"] = {\n    path: \"~/.agents/skills/\",\n    scope: \"user\",\n    level: \"official\",\n  };\n  readonly commands: Harness[\"commands\"] = [\n    {\n      path: \"~/.codex/prompts/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Deprecated Markdown prompts invoked as /prompts:name. Top-level files only; use skills for shared prompts.\",\n    },\n  ];\n  override readonly promptTemplates = this.commands;\n  override readonly promptTemplateSyncTarget: Harness[\"promptTemplateSyncTarget\"] = {\n    path: \"~/.codex/prompts/\",\n    scope: \"user\",\n    level: \"official\",\n    format: \"markdown\",\n  };\n  readonly hooks: Harness[\"hooks\"] = [];\n  readonly invocation: Harness[\"invocation\"] = {\n    args: [\"exec\", \"--skip-git-repo-check\", \"{prompt}\"],\n    jsonArgs: [\"exec\", \"--skip-git-repo-check\", \"--json\", \"{prompt}\"],\n    readOnlyArgs: [\"exec\", \"--skip-git-repo-check\", \"--sandbox\", \"read-only\", \"{prompt}\"],\n    readOnlyJsonArgs: [\n      \"exec\",\n      \"--skip-git-repo-check\",\n      \"--sandbox\",\n      \"read-only\",\n      \"--json\",\n      \"{prompt}\",\n    ],\n    modelArgs: [\"--model\", \"{model}\"],\n    effortArgs: [\"-c\", \"model_reasoning_effort={effort}\"],\n    level: \"official\",\n    note: \"Non-interactive exec subcommand; add --json for structured output.\",\n  };\n  override readonly modelListing: Harness[\"modelListing\"] = {\n    args: [\"debug\", \"models\"],\n    level: \"official\",\n    note: \"Prints the model catalog as JSON, refreshed from OpenAI unless --bundled, with no filter of its own; only models Codex shows in its picker are kept. It lives under debug, so the shape can move between releases; verified with 0.160.0.\",\n  };\n  override readonly mcpConfigs: Harness[\"mcpConfigs\"] = [\n    {\n      path: \"~/.codex/config.toml\",\n      scope: \"user\",\n      level: \"official\",\n      format: \"toml\",\n      key: [\"mcp_servers\"],\n      dialect: \"standard\",\n    },\n    {\n      path: \".codex/config.toml\",\n      scope: \"project\",\n      level: \"official\",\n      format: \"toml\",\n      key: [\"mcp_servers\"],\n      dialect: \"standard\",\n    },\n  ];\n  override readonly envOverrides: Harness[\"envOverrides\"] = [\n    {\n      variable: \"CODEX_HOME\",\n      path: \"~/.codex\",\n      scope: \"user\",\n      level: \"official\",\n      relocates: [\"config\", \"sessions\", \"instructions\", \"skills\", \"commands\", \"promptTemplates\"],\n    },\n  ];\n  override readonly agentsFile = \"~/.codex/AGENTS.md\";\n  readonly detection = {\n    envVars: [],\n    projectMarkers: [\".codex\", \"AGENTS.md\", \"AGENTS.override.md\", \".agents/skills\"],\n  };\n\n  /**\n   * `codex --model` takes the bare slug, so the selector leaves `openai/` off.\n   *\n   * @param model - A model returned by {@link listModels}.\n   * @returns {string} The model id.\n   */\n  override modelSelector(model: Readonly<AvailableModel>): string {\n    return model.id;\n  }\n\n  protected override parseModelListingOutput(stdout: string): AvailableModel[] {\n    return parseCodexModels(stdout);\n  }\n}\n","import { Harness } from \"../harness.ts\";\n\nexport default class Cursor extends Harness {\n  readonly id = \"cursor\";\n  readonly name = \"Cursor\";\n  readonly binaries = [\"cursor\"];\n  readonly capabilities = {\n    mcp: true,\n    vision: true,\n    audio: false,\n    video: false,\n    tools: true,\n    streaming: true,\n  };\n  readonly config: Harness[\"config\"] = [\n    {\n      path: \"~/.cursor/settings.json\",\n      scope: \"user\",\n      level: \"official\",\n    },\n  ];\n  readonly sessions: Harness[\"sessions\"] = [];\n  readonly persistence: Harness[\"persistence\"] = [\n    { format: \"JSON\", level: \"official\", note: \"Settings and rules files.\" },\n  ];\n  readonly instructions: Harness[\"instructions\"] = [\n    {\n      path: \".cursor/rules/skilld-activation.mdc\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"MDC format rule for skill activation.\",\n    },\n    {\n      path: \".cursorrules\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Legacy project-level instructions.\",\n    },\n  ];\n  readonly skills: Harness[\"skills\"] = [\n    { path: \".cursor/skills/\", scope: \"project\", level: \"official\" },\n    {\n      path: \"~/.cursor/skills/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level skills.\",\n    },\n    {\n      path: \".claude/skills/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Cursor natively scans Claude skills directory.\",\n    },\n    {\n      path: \".codex/skills/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Cursor natively scans Codex skills directory.\",\n    },\n  ];\n  override readonly skillsSyncTarget: Harness[\"skillsSyncTarget\"] = {\n    path: \"~/.cursor/skills/\",\n    scope: \"user\",\n    level: \"official\",\n  };\n  readonly commands: Harness[\"commands\"] = [];\n  readonly hooks: Harness[\"hooks\"] = [];\n  readonly invocation: Harness[\"invocation\"] = {\n    binary: \"cursor-agent\",\n    args: [\"-p\", \"{prompt}\"],\n    jsonArgs: [\"-p\", \"--output-format\", \"json\", \"{prompt}\"],\n    level: \"community\",\n    note: \"Cursor CLI agent binary, separate from the editor binary.\",\n  };\n  override readonly mcpConfigs: Harness[\"mcpConfigs\"] = [\n    {\n      path: \"~/.cursor/mcp.json\",\n      scope: \"user\",\n      level: \"community\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"standard\",\n    },\n    {\n      path: \".cursor/mcp.json\",\n      scope: \"project\",\n      level: \"community\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"standard\",\n    },\n  ];\n  readonly detection = {\n    envVars: [\"CURSOR_SESSION\", \"CURSOR_TRACE_ID\"],\n    projectMarkers: [\".cursor\", \".cursorrules\"],\n  };\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { Harness } from \"../harness.ts\";\n\nexport default class Freebuff extends Harness {\n  readonly id = \"freebuff\";\n  readonly name = \"Freebuff\";\n  readonly binaries = [\"freebuff\"];\n\n  override get version(): string | null {\n    const configDir = join(homedir(), \".config\", \"manicode\");\n    const binaryName = process.platform === \"win32\" ? \"freebuff.exe\" : \"freebuff\";\n    if (!existsSync(join(configDir, binaryName))) return null;\n\n    try {\n      const metadata: unknown = JSON.parse(\n        readFileSync(join(configDir, \"freebuff-metadata.json\"), \"utf8\"),\n      );\n      if (\n        typeof metadata === \"object\" &&\n        metadata !== null &&\n        \"version\" in metadata &&\n        typeof metadata.version === \"string\" &&\n        metadata.version !== \"\"\n      ) {\n        return metadata.version;\n      }\n    } catch {\n      return null;\n    }\n\n    return null;\n  }\n\n  readonly capabilities = {\n    mcp: true,\n    vision: true,\n    audio: false,\n    video: false,\n    tools: true,\n    streaming: true,\n  };\n  readonly config: Harness[\"config\"] = [\n    {\n      path: \"~/.config/manicode/settings.json\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Freebuff is Codebuff-based; user data lives under ~/.config/manicode/ on all platforms.\",\n    },\n    {\n      path: \"~/.config/manicode/credentials.json\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Authentication credentials.\",\n    },\n  ];\n  readonly sessions: Harness[\"sessions\"] = [\n    {\n      path: \"~/.config/manicode/projects/<project-name>/chats/<timestamp>/\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Per-chat directories with chat-messages.json, chat-meta.json, run-state.json, and log.jsonl.\",\n    },\n    {\n      path: \"~/.config/manicode/message-history.json\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Prompt history.\",\n    },\n  ];\n  readonly persistence: Harness[\"persistence\"] = [\n    {\n      format: \"JSON\",\n      level: \"official\",\n      note: \"Settings, credentials, chat messages, and run state.\",\n    },\n    { format: \"JSONL\", level: \"official\", note: \"Per-chat logs (log.jsonl).\" },\n  ];\n  readonly instructions: Harness[\"instructions\"] = [\n    {\n      path: \"AGENTS.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Knowledge files; scaffolded by the init flow. knowledge.md, *.knowledge.md, and CLAUDE.md in any project directory are loaded the same way.\",\n    },\n    {\n      path: \"knowledge.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Per-directory project knowledge.\",\n    },\n    {\n      path: \"~/.AGENTS.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"User-level knowledge files in the home directory; ~/.knowledge.md and ~/.CLAUDE.md are accepted too. Read-only for the agent.\",\n    },\n  ];\n  readonly skills: Harness[\"skills\"] = [\n    {\n      path: \".agents/skills/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Also the install target for community skills via npx skills add; .agents/types/ holds agent template types.\",\n    },\n  ];\n  readonly commands: Harness[\"commands\"] = [];\n  readonly hooks: Harness[\"hooks\"] = [];\n  readonly invocation: Harness[\"invocation\"] = null;\n  override readonly mcpConfigs: Harness[\"mcpConfigs\"] = [\n    {\n      path: \"~/.agents/mcp.json\",\n      scope: \"user\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"standard\",\n    },\n    {\n      path: \".agents/mcp.json\",\n      scope: \"project\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"standard\",\n      note: \"The parent directory's .agents/mcp.json is scanned too; agent templates can also embed their own mcpServers.\",\n    },\n  ];\n  override readonly agentsFile = \"~/.AGENTS.md\";\n  readonly detection = {\n    envVars: [],\n    projectMarkers: [\".agents\", \"knowledge.md\"],\n  };\n}\n","import { Harness } from \"../harness.ts\";\n\nexport default class Gemini extends Harness {\n  readonly id = \"gemini\";\n  readonly name = \"Google Gemini CLI\";\n  readonly binaries = [\"gemini\"];\n  readonly capabilities = {\n    mcp: true,\n    vision: true,\n    audio: true,\n    video: false,\n    tools: true,\n    streaming: true,\n  };\n  readonly config: Harness[\"config\"] = [\n    {\n      path: \"~/.gemini/settings.json\",\n      scope: \"user\",\n      level: \"official\",\n    },\n    {\n      path: \".gemini/settings.json\",\n      scope: \"project\",\n      level: \"official\",\n    },\n    {\n      path: \"/etc/gemini-cli/settings.json\",\n      scope: \"system\",\n      level: \"official\",\n      platforms: [\"linux\"],\n    },\n    {\n      path: \"/Library/Application Support/GeminiCli/settings.json\",\n      scope: \"system\",\n      level: \"official\",\n      platforms: [\"darwin\"],\n    },\n    {\n      path: \"%PROGRAMDATA%/gemini-cli/settings.json\",\n      scope: \"system\",\n      level: \"official\",\n      platforms: [\"win32\"],\n    },\n  ];\n  readonly sessions: Harness[\"sessions\"] = [\n    {\n      path: \"~/.gemini/history/<project-id>/\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Conversation history per project (project-id is a slug from projects.json).\",\n    },\n    {\n      path: \"~/.gemini/tmp/<project-id>/chats/\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Active chat session data.\",\n    },\n  ];\n  readonly persistence: Harness[\"persistence\"] = [\n    { format: \"JSON\", level: \"official\", note: \"Settings files.\" },\n    {\n      format: \"JSON\",\n      level: \"official\",\n      note: \"Session and history records.\",\n    },\n  ];\n  readonly instructions: Harness[\"instructions\"] = [\n    { path: \"GEMINI.md\", scope: \"project\", level: \"official\" },\n    {\n      path: \"~/.gemini/GEMINI.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global instruction/memory file.\",\n    },\n  ];\n  readonly skills: Harness[\"skills\"] = [\n    { path: \".gemini/skills/\", scope: \"project\", level: \"official\" },\n    { path: \".agents/skills/\", scope: \"project\", level: \"official\" },\n    { path: \"~/.gemini/skills/\", scope: \"user\", level: \"official\" },\n    { path: \"~/.agents/skills/\", scope: \"user\", level: \"official\" },\n  ];\n  override readonly skillsSyncTarget: Harness[\"skillsSyncTarget\"] = {\n    path: \"~/.gemini/skills/\",\n    scope: \"user\",\n    level: \"official\",\n  };\n  readonly commands: Harness[\"commands\"] = [\n    {\n      path: \".gemini/commands/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Custom commands in TOML format.\",\n    },\n    {\n      path: \"~/.gemini/commands/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global custom commands in TOML format.\",\n    },\n  ];\n  override readonly promptTemplates = this.commands;\n  override readonly promptTemplateSyncTarget: Harness[\"promptTemplateSyncTarget\"] = {\n    path: \"~/.gemini/commands/\",\n    scope: \"user\",\n    level: \"official\",\n    format: \"gemini-toml\",\n  };\n  readonly hooks: Harness[\"hooks\"] = [];\n  readonly invocation: Harness[\"invocation\"] = {\n    args: [\"-p\", \"{prompt}\"],\n    jsonArgs: [\"-p\", \"{prompt}\", \"--output-format\", \"json\"],\n    modelArgs: [\"--model\", \"{model}\"],\n    level: \"official\",\n    note: \"Non-interactive (headless) mode.\",\n  };\n  override readonly mcpConfigs: Harness[\"mcpConfigs\"] = [\n    {\n      path: \"~/.gemini/settings.json\",\n      scope: \"user\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"standard\",\n    },\n    {\n      path: \".gemini/settings.json\",\n      scope: \"project\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"standard\",\n    },\n  ];\n  override readonly agentsFile = \"~/.gemini/GEMINI.md\";\n  readonly detection = {\n    envVars: [\"GEMINI_CLI\"],\n    projectMarkers: [\".gemini\", \"GEMINI.md\"],\n  };\n}\n","import { Harness } from \"../harness.ts\";\n\nexport default class GitHubCopilot extends Harness {\n  readonly id = \"github-copilot\";\n  readonly name = \"GitHub Copilot\";\n  readonly binaries = [\"copilot\"];\n  readonly capabilities = {\n    mcp: true,\n    vision: true,\n    audio: false,\n    video: false,\n    tools: true,\n    streaming: true,\n  };\n  readonly config: Harness[\"config\"] = [\n    {\n      path: \"~/.copilot/config.json\",\n      scope: \"user\",\n      level: \"inferred\",\n    },\n  ];\n  readonly sessions: Harness[\"sessions\"] = [];\n  readonly persistence: Harness[\"persistence\"] = [\n    { format: \"JSON\", level: \"official\", note: \"Configuration files.\" },\n  ];\n  readonly instructions: Harness[\"instructions\"] = [\n    {\n      path: \".github/copilot-instructions.md\",\n      scope: \"project\",\n      level: \"official\",\n    },\n    {\n      path: \".github/instructions/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Modular instructions in .instructions.md files.\",\n    },\n  ];\n  readonly skills: Harness[\"skills\"] = [\n    { path: \".github/skills/\", scope: \"project\", level: \"official\" },\n    {\n      path: \".claude/skills/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Copilot auto-detects Claude skills directory.\",\n    },\n  ];\n  readonly commands: Harness[\"commands\"] = [];\n  readonly hooks: Harness[\"hooks\"] = [];\n  readonly invocation: Harness[\"invocation\"] = {\n    binary: \"copilot\",\n    args: [\"-p\", \"{prompt}\"],\n    level: \"community\",\n    note: \"GitHub Copilot CLI, separate from the editor integration.\",\n  };\n  override readonly mcpConfigs: Harness[\"mcpConfigs\"] = [\n    {\n      path: \".vscode/mcp.json\",\n      scope: \"project\",\n      level: \"community\",\n      format: \"json\",\n      key: [\"servers\"],\n      dialect: \"vscode\",\n    },\n  ];\n  readonly detection = {\n    envVars: [\"COPILOT_RUN_APP\"],\n    projectMarkers: [\".github/copilot-instructions.md\", \".github/skills\", \".github/instructions\"],\n  };\n}\n","import { stripVTControlCharacters } from \"node:util\";\nimport { Harness } from \"../harness.ts\";\nimport type { AvailableModel } from \"../types.ts\";\n\n/**\n * Parses `grok models`: a login line, the default model, then an\n * `Available models:` list with `*` on the default and `-` on the rest.\n *\n * @param stdout - Native model-listing output.\n * @returns {AvailableModel[]} The listed xAI models, the default one flagged.\n */\nexport function parseGrokModels(stdout: string): AvailableModel[] {\n  const lines = stripVTControlCharacters(stdout)\n    .split(/\\r?\\n/)\n    .map((line) => line.trim())\n    .filter(Boolean);\n  const start = lines.indexOf(\"Available models:\");\n  if (start === -1) throw new Error(`Unexpected Grok model-list output: ${JSON.stringify(stdout)}`);\n\n  return lines.slice(start + 1).map((line) => {\n    const match = /^([*-])\\s+(\\S+)(?:\\s+\\(default\\))?$/.exec(line);\n    if (!match?.[2]) throw new Error(`Unexpected Grok model-list row: ${JSON.stringify(line)}`);\n    return { provider: \"xai\", id: match[2], ...(match[1] === \"*\" ? { default: true } : {}) };\n  });\n}\n\nexport default class Grok extends Harness {\n  readonly id = \"grok\";\n  readonly name = \"xAI Grok CLI\";\n  readonly binaries = [\"grok\"];\n  readonly capabilities = {\n    mcp: true,\n    vision: true,\n    audio: false,\n    video: false,\n    tools: true,\n    streaming: true,\n  };\n  readonly config: Harness[\"config\"] = [\n    {\n      path: \"~/.grok/config.toml\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Base directory overridable with GROK_HOME.\",\n    },\n    {\n      path: \".grok/config.toml\",\n      scope: \"project\",\n      level: \"official\",\n    },\n  ];\n  readonly sessions: Harness[\"sessions\"] = [\n    {\n      path: \"~/.grok/sessions/<encoded-cwd>/<session-id>/updates.jsonl\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Authoritative ACP session update stream (conversation + tool calls); session dirs also hold chat_history.jsonl, summary.json, rewind_points.jsonl.\",\n    },\n    {\n      path: \"~/.grok/sessions/<encoded-cwd>/prompt_history.jsonl\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Per-project prompt history.\",\n    },\n  ];\n  readonly persistence: Harness[\"persistence\"] = [\n    { format: \"TOML\", level: \"official\", note: \"Configuration files.\" },\n    {\n      format: \"JSONL\",\n      level: \"official\",\n      note: \"Session update streams, chat history, prompt history.\",\n    },\n    {\n      format: \"JSON\",\n      level: \"official\",\n      note: \"Session state files (summary.json, plan.json, signals.json).\",\n    },\n    {\n      format: \"SQLite\",\n      level: \"official\",\n      note: \"Local FTS5 index over session titles and prompts for sessions search.\",\n    },\n  ];\n  readonly instructions: Harness[\"instructions\"] = [\n    {\n      path: \"AGENTS.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Also accepts Agents.md, AGENT.md, Claude.md, CLAUDE.md, CLAUDE.local.md; every matching file in a directory is loaded.\",\n    },\n    {\n      path: \".grok/rules/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"*.md rules scanned at each level from repo root to cwd; .claude/rules/ and .cursor/rules/ scanned via vendor compatibility.\",\n    },\n    {\n      path: \"~/.grok/rules/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level rules.\",\n    },\n  ];\n  readonly skills: Harness[\"skills\"] = [\n    { path: \".grok/skills/\", scope: \"project\", level: \"official\" },\n    {\n      path: \"~/.grok/skills/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level skills.\",\n    },\n  ];\n  override readonly skillsSyncTarget: Harness[\"skillsSyncTarget\"] = {\n    path: \"~/.grok/skills/\",\n    scope: \"user\",\n    level: \"official\",\n  };\n  readonly commands: Harness[\"commands\"] = [\n    { path: \".grok/commands/\", scope: \"project\", level: \"official\" },\n    {\n      path: \"~/.grok/commands/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level slash commands.\",\n    },\n  ];\n  readonly hooks: Harness[\"hooks\"] = [\n    { path: \".grok/hooks/\", scope: \"project\", level: \"official\" },\n    {\n      path: \"~/.grok/hooks/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"JSON hook definitions (e.g. session-start.json); Claude/Cursor hook sources scanned via vendor compatibility.\",\n    },\n  ];\n  readonly invocation: Harness[\"invocation\"] = {\n    args: [\"-p\", \"{prompt}\"],\n    jsonArgs: [\"-p\", \"{prompt}\", \"--output-format\", \"json\"],\n    readOnlyArgs: [\"-p\", \"{prompt}\", \"--sandbox\", \"read-only\"],\n    readOnlyJsonArgs: [\"-p\", \"{prompt}\", \"--sandbox\", \"read-only\", \"--output-format\", \"json\"],\n    readOnlyMinVersion: \"1.0.13\",\n    readOnlyNetwork: { linux: false, darwin: true },\n    modelArgs: [\"--model\", \"{model}\"],\n    effortArgs: [\"--reasoning-effort\", \"{effort}\"],\n    level: \"official\",\n    note: \"-p is short for --single; add --output-format json for structured output. --sandbox read-only is kernel-enforced (Landlock, Seatbelt) regardless of the inherited permission mode and still allows writes to ~/.grok and temp dirs; verified on Linux with 1.0.13 and 1.0.25. On Linux it also cuts the network of every child process through seccomp, MCP servers included, so their lookups die on EAI_AGAIN while Grok's own web search keeps working; seen with 1.0.41. macOS skips that part.\",\n  };\n  override readonly modelListing: Harness[\"modelListing\"] = {\n    args: [\"models\"],\n    level: \"official\",\n    note: \"Prints bare ids with the default marked; verified with 1.0.41.\",\n  };\n  override readonly mcpConfigs: Harness[\"mcpConfigs\"] = [\n    {\n      path: \"~/.grok/config.toml\",\n      scope: \"user\",\n      level: \"official\",\n      format: \"toml\",\n      key: [\"mcp_servers\"],\n      dialect: \"standard\",\n      note: \"grok mcp add/remove manage this file; Claude and Cursor configs are also scanned via vendor compatibility.\",\n    },\n    {\n      path: \".grok/config.toml\",\n      scope: \"project\",\n      level: \"official\",\n      format: \"toml\",\n      key: [\"mcp_servers\"],\n      dialect: \"standard\",\n    },\n  ];\n  readonly detection = {\n    envVars: [\"GROK_SESSION_ID\", \"GROK_WORKSPACE_ROOT\", \"GROK_HOME\"],\n    projectMarkers: [\".grok\"],\n  };\n\n  protected override parseModelListingOutput(stdout: string): AvailableModel[] {\n    return parseGrokModels(stdout);\n  }\n}\n","import { execFileSync } from \"node:child_process\";\nimport { readFileSync, realpathSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { Harness } from \"../harness.ts\";\n\nfunction packageVersion(commandPath: string): string | null {\n  try {\n    const require = createRequire(realpathSync(commandPath));\n    const metadata: unknown = JSON.parse(\n      readFileSync(require.resolve(\"mastracode/package.json\"), \"utf8\"),\n    );\n    if (\n      typeof metadata === \"object\" &&\n      metadata !== null &&\n      \"version\" in metadata &&\n      typeof metadata.version === \"string\" &&\n      metadata.version !== \"\"\n    ) {\n      return metadata.version;\n    }\n  } catch {\n    return null;\n  }\n  return null;\n}\n\nexport default class MastraCode extends Harness {\n  readonly id = \"mastracode\";\n  readonly name = \"Mastra Code\";\n  readonly binaries = [\"mastracode\"];\n\n  override get version(): string | null {\n    const locator = process.platform === \"win32\" ? \"where\" : \"which\";\n    let output: string;\n    try {\n      output = execFileSync(locator, [this.binaries[0] ?? \"mastracode\"], {\n        encoding: \"utf8\",\n        stdio: [\"pipe\", \"pipe\", \"pipe\"],\n        timeout: 5000,\n      });\n    } catch {\n      return null;\n    }\n\n    const paths = output.split(/\\r?\\n/u).filter((path) => path !== \"\");\n    for (const path of paths) {\n      const version = packageVersion(path);\n      if (version !== null) return version;\n    }\n    return null;\n  }\n  readonly capabilities = {\n    mcp: true,\n    vision: true,\n    audio: false,\n    video: false,\n    tools: true,\n    streaming: true,\n  };\n  readonly config: Harness[\"config\"] = [\n    {\n      path: \".mastracode/mcp.json\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Project-scoped MCP server configurations.\",\n    },\n    {\n      path: \"~/.mastracode/mcp.json\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global MCP server configurations.\",\n    },\n    {\n      path: \".mcp.json\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Claude Code compatible project MCP servers, read below .mastracode/mcp.json.\",\n    },\n    {\n      path: \".mastracode/hooks.json\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Project-scoped hooks.\",\n    },\n    {\n      path: \"~/.mastracode/hooks.json\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global hooks.\",\n    },\n  ];\n  readonly sessions: Harness[\"sessions\"] = [\n    {\n      path: \"~/.local/share/mastracode/mastra.db\",\n      scope: \"data\",\n      level: \"official\",\n      platforms: [\"linux\"],\n      note: \"LibSQL database with threads, messages, and observational memory.\",\n    },\n  ];\n  readonly persistence: Harness[\"persistence\"] = [\n    { format: \"JSON\", level: \"official\", note: \"MCP and hooks config files.\" },\n    {\n      format: \"SQLite\",\n      level: \"official\",\n      note: \"LibSQL database for threads, messages, and observational memory.\",\n    },\n  ];\n  readonly instructions: Harness[\"instructions\"] = [\n    { path: \"AGENTS.md\", scope: \"project\", level: \"official\" },\n    {\n      path: \"CLAUDE.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Supported for Claude Code compatibility.\",\n    },\n    {\n      path: \".claude/CLAUDE.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Claude Code compatible.\",\n    },\n    {\n      path: \".mastracode/AGENTS.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Alternative project-level location.\",\n    },\n    {\n      path: \"~/.claude/CLAUDE.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Claude Code compatible.\",\n    },\n    {\n      path: \"~/.mastracode/AGENTS.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level instructions.\",\n    },\n  ];\n  readonly skills: Harness[\"skills\"] = [\n    { path: \".mastracode/skills/\", scope: \"project\", level: \"official\" },\n    {\n      path: \"~/.mastracode/skills/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level skills.\",\n    },\n    {\n      path: \".claude/skills/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Claude Code compatible.\",\n    },\n    {\n      path: \"~/.claude/skills/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Claude Code compatible.\",\n    },\n  ];\n  override readonly skillsSyncTarget: Harness[\"skillsSyncTarget\"] = {\n    path: \"~/.mastracode/skills/\",\n    scope: \"user\",\n    level: \"official\",\n  };\n  readonly commands: Harness[\"commands\"] = [\n    {\n      path: \".mastracode/commands/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Markdown prompt commands; subdirectories become colon-separated command names.\",\n    },\n    {\n      path: \"~/.mastracode/commands/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global Markdown prompt commands.\",\n    },\n    {\n      path: \".claude/commands/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Claude compatibility.\",\n    },\n    {\n      path: \"~/.claude/commands/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Claude compatibility.\",\n    },\n    {\n      path: \".opencode/command/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Mastra's OpenCode compatibility loader uses the singular command directory.\",\n    },\n    {\n      path: \"~/.opencode/command/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Mastra's OpenCode compatibility loader uses the singular command directory.\",\n    },\n  ];\n  override readonly promptTemplates = this.commands;\n  override readonly promptTemplateSyncTarget: Harness[\"promptTemplateSyncTarget\"] = {\n    path: \"~/.mastracode/commands/\",\n    scope: \"user\",\n    level: \"official\",\n    format: \"markdown\",\n  };\n  readonly hooks: Harness[\"hooks\"] = [\n    {\n      path: \".mastracode/hooks.json\",\n      scope: \"project\",\n      level: \"official\",\n    },\n    {\n      path: \"~/.mastracode/hooks.json\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global hooks.\",\n    },\n  ];\n  readonly invocation: Harness[\"invocation\"] = null;\n  override readonly mcpConfigs: Harness[\"mcpConfigs\"] = [\n    {\n      path: \"~/.mastracode/mcp.json\",\n      scope: \"user\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"mastracode\",\n      note: \"An entry with command is stdio and one with url is HTTP, type is ignored. Loaded above mcpServers from the project's .claude/settings.local.json and below both project files, later names winning.\",\n    },\n    {\n      path: \".mastracode/mcp.json\",\n      scope: \"project\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"mastracode\",\n      note: \"Highest priority, overrides the other files entry by entry.\",\n    },\n    {\n      path: \".mcp.json\",\n      scope: \"project\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"mastracode\",\n      note: \"Claude Code's project file, read between the user file and .mastracode/mcp.json. Project writes go to .mastracode/mcp.json, this one is Claude's to edit.\",\n    },\n  ];\n  readonly detection = {\n    envVars: [],\n    projectMarkers: [\".mastracode\"],\n  };\n}\n","import { Harness } from \"../harness.ts\";\nimport type { AvailableModel } from \"../types.ts\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Parses `omp models --json`, where `reasoning` is the flag Pi prints as `thinking`.\n *\n * @param stdout - Native model-listing output.\n * @returns {AvailableModel[]} The listed models, in the CLI's order.\n */\nexport function parseOmpModels(stdout: string): AvailableModel[] {\n  let parsed: unknown;\n  try {\n    parsed = JSON.parse(stdout);\n  } catch {\n    throw new Error(`Unexpected OMP model-list output: ${JSON.stringify(stdout.slice(0, 200))}`);\n  }\n  if (!isRecord(parsed) || !Array.isArray(parsed[\"models\"]))\n    throw new Error(`Unexpected OMP model-list output: ${JSON.stringify(stdout.slice(0, 200))}`);\n\n  return parsed[\"models\"].map((entry: unknown) => {\n    if (\n      !isRecord(entry) ||\n      typeof entry[\"provider\"] !== \"string\" ||\n      typeof entry[\"id\"] !== \"string\"\n    )\n      throw new Error(`Unexpected OMP model-list entry: ${JSON.stringify(entry)}`);\n    const { contextWindow, maxTokens, reasoning, input } = entry;\n    return {\n      provider: entry[\"provider\"],\n      id: entry[\"id\"],\n      ...(typeof contextWindow === \"number\" ? { contextWindow } : {}),\n      ...(typeof maxTokens === \"number\" ? { maxOutputTokens: maxTokens } : {}),\n      ...(typeof reasoning === \"boolean\" ? { thinking: reasoning } : {}),\n      ...(Array.isArray(input) ? { images: input.includes(\"image\") } : {}),\n    };\n  });\n}\n\nexport default class Omp extends Harness {\n  readonly id = \"omp\";\n  readonly name = \"OMP (oh-my-pi)\";\n  readonly binaries = [\"omp\"];\n  readonly capabilities = {\n    mcp: true,\n    vision: true,\n    audio: false,\n    video: false,\n    tools: true,\n    streaming: true,\n  };\n  readonly config: Harness[\"config\"] = [\n    {\n      path: \"~/.omp/agent/config.yml\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Profiles use ~/.omp/profiles/<name>/agent.\",\n    },\n    {\n      path: \"~/.omp/agent/settings.json\",\n      scope: \"user\",\n      level: \"official\",\n    },\n    {\n      path: \"~/.omp/agent/mcp.json\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"MCP server configurations.\",\n    },\n    { path: \".omp/config.yml\", scope: \"project\", level: \"official\" },\n    { path: \".omp/settings.json\", scope: \"project\", level: \"official\" },\n  ];\n  readonly sessions: Harness[\"sessions\"] = [\n    {\n      path: \"~/.omp/agent/sessions/<dash-encoded-cwd>/<timestamp>_<session-id>.jsonl\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Per-project session transcripts in JSONL format; session ids are UUIDv7.\",\n    },\n    {\n      path: \"~/.omp/agent/history.db\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"SQLite prompt history.\",\n    },\n    {\n      path: \"~/.omp/agent/agent.db\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"SQLite agent state database.\",\n    },\n  ];\n  readonly persistence: Harness[\"persistence\"] = [\n    { format: \"YAML\", level: \"official\", note: \"config.yml configuration files.\" },\n    {\n      format: \"JSON\",\n      level: \"official\",\n      note: \"settings.json and mcp.json.\",\n    },\n    { format: \"JSONL\", level: \"official\", note: \"Session transcripts.\" },\n    {\n      format: \"SQLite\",\n      level: \"official\",\n      note: \"Agent state, prompt history, model catalog (agent.db, history.db, models.db).\",\n    },\n  ];\n  readonly instructions: Harness[\"instructions\"] = [\n    {\n      path: \"AGENTS.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Discovered by walking up from cwd; CLAUDE.md and other vendor files loaded via compatibility providers (claude, codex, gemini, cursor, opencode, and more).\",\n    },\n    { path: \".omp/AGENTS.md\", scope: \"project\", level: \"official\" },\n    {\n      path: \".omp/RULES.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Sticky always-apply rules.\",\n    },\n    {\n      path: \"~/.omp/agent/AGENTS.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level instructions.\",\n    },\n    {\n      path: \"~/.omp/agent/RULES.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global sticky always-apply rules.\",\n    },\n    {\n      path: \"~/.omp/agent/PERSONALITY.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Overrides the system prompt's personality block; replaces the configured personality preset.\",\n    },\n  ];\n  readonly skills: Harness[\"skills\"] = [\n    {\n      path: \".omp/skills/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Scanned in ancestor directories from cwd, closest first.\",\n    },\n    { path: \"~/.omp/agent/skills/\", scope: \"user\", level: \"official\" },\n    {\n      path: \"~/.omp/agent/managed-skills/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Auto-generated managed skills.\",\n    },\n  ];\n  override readonly skillsSyncTarget: Harness[\"skillsSyncTarget\"] = {\n    path: \"~/.omp/agent/skills/\",\n    scope: \"user\",\n    level: \"official\",\n  };\n  readonly commands: Harness[\"commands\"] = [\n    {\n      path: \".omp/commands/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Markdown prompt commands and TypeScript commands; only Markdown files are templates.\",\n    },\n    {\n      path: \"~/.omp/agent/commands/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global Markdown prompt commands and TypeScript commands; only Markdown files are templates.\",\n    },\n  ];\n  override readonly promptTemplates: Harness[\"promptTemplates\"] = [\n    ...this.commands,\n    {\n      path: \".omp/prompts/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Markdown prompt templates invoked as /name; subdirectories are scanned.\",\n    },\n    {\n      path: \"~/.omp/agent/prompts/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global Markdown prompt templates, separate from executable commands.\",\n    },\n  ];\n  override readonly promptTemplateSyncTarget: Harness[\"promptTemplateSyncTarget\"] = {\n    path: \"~/.omp/agent/prompts/\",\n    scope: \"user\",\n    level: \"official\",\n    format: \"markdown\",\n  };\n  readonly hooks: Harness[\"hooks\"] = [];\n  readonly invocation: Harness[\"invocation\"] = {\n    args: [\"-p\", \"{prompt}\"],\n    jsonArgs: [\"-p\", \"--mode\", \"json\", \"{prompt}\"],\n    modelArgs: [\"--model={model}\"],\n    effortArgs: [\"--thinking={effort}\"],\n    level: \"official\",\n    note: \"Add --mode json for structured event output. --no-tools disables only OMP's bundled tools, so it cannot provide an advisor mode without tools.\",\n  };\n  override readonly modelListing: Harness[\"modelListing\"] = {\n    args: [\"models\", \"--json\", \"--kind\", \"chat\", \"--no-extensions\"],\n    searchArgs: [\"models\", \"find\", \"--json\", \"--kind\", \"chat\", \"--no-extensions\", \"--\", \"{search}\"],\n    level: \"official\",\n    note: \"Lists chat models with configured provider authentication as JSON; find matches a substring of the provider, id or name, ignoring case. --no-extensions keeps extension load errors out of the run; verified with 18.4.10.\",\n  };\n  override readonly mcpConfigs: Harness[\"mcpConfigs\"] = [\n    {\n      path: \"~/.omp/agent/mcp.json\",\n      scope: \"user\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"standard\",\n    },\n    {\n      path: \".omp/mcp.json\",\n      scope: \"project\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"standard\",\n    },\n  ];\n  override readonly envOverrides: Harness[\"envOverrides\"] = [\n    {\n      variable: \"PI_CODING_AGENT_DIR\",\n      path: \"~/.omp/agent\",\n      scope: \"user\",\n      level: \"official\",\n      relocates: [\"config\", \"sessions\", \"instructions\", \"skills\", \"commands\", \"promptTemplates\"],\n      note: \"Ignored under a named profile (OMP_PROFILE). On Linux, after omp config init-xdg, data, state and cache live under $XDG_*_HOME/omp instead.\",\n    },\n  ];\n  override readonly agentsFile = \"~/.omp/agent/AGENTS.md\";\n  readonly detection = {\n    envVars: [\"OMP_PROFILE\", \"PI_CODING_AGENT_DIR\"],\n    projectMarkers: [\".omp\"],\n  };\n\n  protected override parseModelListingOutput(stdout: string): AvailableModel[] {\n    return parseOmpModels(stdout);\n  }\n}\n","import { Harness } from \"../harness.ts\";\n\nexport default class OpenCode extends Harness {\n  readonly id = \"opencode\";\n  readonly name = \"OpenCode CLI\";\n  readonly binaries = [\"opencode\"];\n  readonly capabilities = {\n    mcp: true,\n    vision: true,\n    audio: false,\n    video: false,\n    tools: true,\n    streaming: true,\n  };\n  readonly config: Harness[\"config\"] = [\n    {\n      path: \"~/.config/opencode/opencode.jsonc\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"XDG-based, same path on all platforms.\",\n    },\n    {\n      path: \"~/.config/opencode/opencode.json\",\n      scope: \"user\",\n      level: \"official\",\n    },\n    {\n      path: \"opencode.jsonc\",\n      scope: \"project\",\n      level: \"official\",\n    },\n    {\n      path: \"opencode.json\",\n      scope: \"project\",\n      level: \"official\",\n    },\n    {\n      path: \".opencode/opencode.jsonc\",\n      scope: \"project\",\n      level: \"official\",\n    },\n    {\n      path: \".opencode/opencode.json\",\n      scope: \"project\",\n      level: \"official\",\n    },\n  ];\n  readonly sessions: Harness[\"sessions\"] = [\n    {\n      path: \"~/.local/share/opencode/opencode.db\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"SQLite database with sessions, messages, and parts. XDG-based, same path on all platforms.\",\n    },\n  ];\n  readonly persistence: Harness[\"persistence\"] = [\n    { format: \"JSON/JSONC\", level: \"official\", note: \"Config files.\" },\n    {\n      format: \"SQLite\",\n      level: \"official\",\n      note: \"Session and message storage via Drizzle ORM.\",\n    },\n  ];\n  readonly instructions: Harness[\"instructions\"] = [\n    { path: \"AGENTS.md\", scope: \"project\", level: \"official\" },\n    {\n      path: \"CLAUDE.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Supported for Claude Code compatibility.\",\n    },\n    {\n      path: \"~/.config/opencode/AGENTS.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level instructions.\",\n    },\n  ];\n  readonly skills: Harness[\"skills\"] = [\n    { path: \".opencode/skills/\", scope: \"project\", level: \"official\" },\n    {\n      path: \".claude/skills/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Claude Code compatible.\",\n    },\n    { path: \".agents/skills/\", scope: \"project\", level: \"official\" },\n    { path: \"~/.config/opencode/skills/\", scope: \"user\", level: \"official\" },\n    {\n      path: \"~/.claude/skills/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Claude Code compatible.\",\n    },\n    { path: \"~/.agents/skills/\", scope: \"user\", level: \"official\" },\n  ];\n  override readonly skillsSyncTarget: Harness[\"skillsSyncTarget\"] = {\n    path: \"~/.config/opencode/skills/\",\n    scope: \"user\",\n    level: \"official\",\n    note: \"OpenCode also scans ~/.claude/skills/ and ~/.agents/skills/; skill names must be unique across them.\",\n  };\n  readonly commands: Harness[\"commands\"] = [\n    {\n      path: \".opencode/commands/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Markdown prompt commands; also configurable through command entries in opencode.json.\",\n    },\n    {\n      path: \"~/.config/opencode/commands/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global Markdown prompt commands.\",\n    },\n  ];\n  override readonly promptTemplates = this.commands;\n  override readonly promptTemplateSyncTarget: Harness[\"promptTemplateSyncTarget\"] = {\n    path: \"~/.config/opencode/commands/\",\n    scope: \"user\",\n    level: \"official\",\n    format: \"markdown\",\n  };\n  readonly hooks: Harness[\"hooks\"] = [];\n  readonly invocation: Harness[\"invocation\"] = {\n    args: [\"run\", \"{prompt}\"],\n    jsonArgs: [\"run\", \"--format\", \"json\", \"{prompt}\"],\n    modelArgs: [\"--model\", \"{model}\"],\n    level: \"official\",\n  };\n  override readonly mcpConfigs: Harness[\"mcpConfigs\"] = [\n    {\n      path: \"~/.config/opencode/opencode.json\",\n      scope: \"user\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcp\"],\n      dialect: \"opencode\",\n    },\n    {\n      path: \"opencode.json\",\n      scope: \"project\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcp\"],\n      dialect: \"opencode\",\n    },\n  ];\n  override readonly agentsFile = \"~/.config/opencode/AGENTS.md\";\n  readonly detection = {\n    envVars: [],\n    projectMarkers: [\".opencode\", \"opencode.jsonc\", \"opencode.json\"],\n  };\n}\n","import { stripVTControlCharacters } from \"node:util\";\nimport { Harness } from \"../harness.ts\";\nimport type { AvailableModel } from \"../types.ts\";\n\nconst MODEL_HEADERS = [\"provider\", \"model\", \"context\", \"max-out\", \"thinking\", \"images\"];\n\nfunction parseTokenCount(value: string, harness: string): number {\n  const match = /^(\\d+(?:\\.\\d+)?)([KM])?$/.exec(value);\n  if (!match?.[1]) throw new Error(`Invalid ${harness} token count: ${JSON.stringify(value)}`);\n  const multiplier = match[2] === \"M\" ? 1_000_000 : match[2] === \"K\" ? 1_000 : 1;\n  return Number(match[1]) * multiplier;\n}\n\nfunction parseBoolean(value: string, column: string, harness: string): boolean {\n  if (value === \"yes\") return true;\n  if (value === \"no\") return false;\n  throw new Error(`Invalid ${harness} ${column} value: ${JSON.stringify(value)}`);\n}\n\n/**\n * Parses the model table Pi and its forks print, one row per model with\n * two or more spaces between columns.\n *\n * @param stdout - Native model-listing output.\n * @param harness - Harness name for error messages.\n * @returns {AvailableModel[]} The normalized models; empty when the CLI reports no matching models.\n */\nexport function parsePiModelTable(stdout: string, harness: string): AvailableModel[] {\n  const lines = stripVTControlCharacters(stdout)\n    .split(/\\r?\\n/)\n    .map((line) => line.trim())\n    .filter(Boolean);\n  const first = lines[0];\n  if (!first) throw new Error(`Unexpected empty ${harness} model-list output`);\n  if (first.startsWith(\"No models available.\") || first.startsWith(\"No models matching \")) {\n    return [];\n  }\n\n  const headers = first.split(/\\s{2,}/);\n  if (\n    headers.length !== MODEL_HEADERS.length ||\n    headers.some((value, i) => value !== MODEL_HEADERS[i])\n  ) {\n    throw new Error(`Unexpected ${harness} model-list header: ${JSON.stringify(first)}`);\n  }\n\n  return lines.slice(1).map((line) => {\n    const columns = line.split(/\\s{2,}/);\n    const [provider, id, context, maxOutput, thinking, images] = columns;\n    if (\n      columns.length !== MODEL_HEADERS.length ||\n      !provider ||\n      !id ||\n      !context ||\n      !maxOutput ||\n      !thinking ||\n      !images\n    ) {\n      throw new Error(`Unexpected ${harness} model-list row: ${JSON.stringify(line)}`);\n    }\n    return {\n      provider,\n      id,\n      contextWindow: parseTokenCount(context, harness),\n      maxOutputTokens: parseTokenCount(maxOutput, harness),\n      thinking: parseBoolean(thinking, \"thinking\", harness),\n      images: parseBoolean(images, \"images\", harness),\n    };\n  });\n}\n\nexport default class Pi extends Harness {\n  readonly id = \"pi\";\n  readonly name = \"Pi Coding Agent\";\n  readonly binaries = [\"pi\"];\n  readonly capabilities = {\n    mcp: true,\n    vision: true,\n    audio: false,\n    video: false,\n    tools: true,\n    streaming: true,\n  };\n  readonly config: Harness[\"config\"] = [\n    {\n      path: \"~/.pi/agent/settings.json\",\n      scope: \"user\",\n      level: \"official\",\n    },\n    { path: \".pi/settings.json\", scope: \"project\", level: \"official\" },\n  ];\n  readonly sessions: Harness[\"sessions\"] = [\n    {\n      path: \"~/.pi/agent/sessions/<dash-encoded-cwd>/<timestamp>_<session-id>.jsonl\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Per-project session transcripts in JSONL format; session ids are UUIDv7. Overridable with --session-dir.\",\n    },\n  ];\n  readonly persistence: Harness[\"persistence\"] = [\n    {\n      format: \"JSON\",\n      level: \"official\",\n      note: \"Settings, auth, trust, models, and keybindings files.\",\n    },\n    { format: \"JSONL\", level: \"official\", note: \"Session transcripts.\" },\n  ];\n  readonly instructions: Harness[\"instructions\"] = [\n    {\n      path: \"AGENTS.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Loaded from parent directories and cwd; CLAUDE.md accepted as an alternative, AGENTS.override.md takes precedence over both in a directory.\",\n    },\n    {\n      path: \".pi/SYSTEM.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Replaces the default system prompt; APPEND_SYSTEM.md appends instead.\",\n    },\n    {\n      path: \"~/.pi/agent/AGENTS.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level instructions.\",\n    },\n    {\n      path: \"~/.pi/agent/SYSTEM.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global system prompt replacement; APPEND_SYSTEM.md appends instead.\",\n    },\n  ];\n  readonly skills: Harness[\"skills\"] = [\n    { path: \".pi/skills/\", scope: \"project\", level: \"official\" },\n    {\n      path: \"~/.pi/agent/skills/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level skills.\",\n    },\n  ];\n  override readonly skillsSyncTarget: Harness[\"skillsSyncTarget\"] = {\n    path: \"~/.pi/agent/skills/\",\n    scope: \"user\",\n    level: \"official\",\n  };\n  readonly commands: Harness[\"commands\"] = [\n    {\n      path: \".pi/prompts/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Prompt templates invoked as slash commands.\",\n    },\n    {\n      path: \"~/.pi/agent/prompts/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level prompt templates.\",\n    },\n  ];\n  override readonly promptTemplates = this.commands;\n  override readonly promptTemplateSyncTarget: Harness[\"promptTemplateSyncTarget\"] = {\n    path: \"~/.pi/agent/prompts/\",\n    scope: \"user\",\n    level: \"official\",\n    format: \"markdown\",\n  };\n  readonly hooks: Harness[\"hooks\"] = [];\n  readonly invocation: Harness[\"invocation\"] = {\n    args: [\"-p\", \"{prompt}\"],\n    jsonArgs: [\"-p\", \"--mode\", \"json\", \"{prompt}\"],\n    noToolsArgs: [\"-p\", \"--no-tools\", \"{prompt}\"],\n    noToolsJsonArgs: [\"-p\", \"--no-tools\", \"--mode\", \"json\", \"{prompt}\"],\n    readOnlyArgs: [\"-p\", \"--tools\", \"read,grep,find,ls\", \"{prompt}\"],\n    readOnlyJsonArgs: [\"-p\", \"--tools\", \"read,grep,find,ls\", \"--mode\", \"json\", \"{prompt}\"],\n    modelArgs: [\"--model\", \"{model}\"],\n    effortArgs: [\"--thinking\", \"{effort}\"],\n    level: \"official\",\n    note: \"Add --mode json for structured event output.\",\n  };\n  override readonly modelListing: Harness[\"modelListing\"] = {\n    args: [\"--list-models\"],\n    searchArgs: [\"--list-models\", \"{search}\"],\n    level: \"official\",\n    note: \"Lists models with configured provider authentication; accepts an optional fuzzy search.\",\n  };\n  override readonly mcpConfigs: Harness[\"mcpConfigs\"] = [\n    {\n      path: \"~/.pi/agent/mcp.json\",\n      scope: \"user\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"pi\",\n      note: \"Read by the built-in MCP extension, which -builtin:mcp in the extensions setting turns off.\",\n    },\n    {\n      path: \".pi/mcp.json\",\n      scope: \"project\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"pi\",\n      note: \"Read only after the project is trusted.\",\n    },\n  ];\n  override readonly envOverrides: Harness[\"envOverrides\"] = [\n    {\n      variable: \"PI_CODING_AGENT_DIR\",\n      path: \"~/.pi/agent\",\n      scope: \"user\",\n      level: \"official\",\n      relocates: [\"config\", \"sessions\", \"instructions\", \"skills\", \"commands\", \"promptTemplates\"],\n      note: \"A leading ~ in the value is expanded.\",\n    },\n    {\n      variable: \"PI_CODING_AGENT_SESSION_DIR\",\n      path: \"~/.pi/agent/sessions\",\n      scope: \"data\",\n      level: \"official\",\n      relocates: [\"sessions\"],\n      note: \"Takes precedence over PI_CODING_AGENT_DIR for sessions; --session-dir beats both.\",\n    },\n  ];\n  override readonly agentsFile = \"~/.pi/agent/AGENTS.md\";\n  readonly detection = {\n    envVars: [\"PI_CODING_AGENT\", \"PI_SESSION_ID\", \"PI_SESSION_FILE\"],\n    projectMarkers: [\".pi\"],\n  };\n\n  protected override parseModelListingOutput(stdout: string): AvailableModel[] {\n    return parsePiModelTable(stdout, \"Pi\");\n  }\n}\n","import { Harness } from \"../harness.ts\";\nimport { parsePiModelTable } from \"./pi.ts\";\nimport type { AvailableModel } from \"../types.ts\";\n\nexport default class PrimeAgent extends Harness {\n  readonly id = \"prime-agent\";\n  readonly name = \"Prime Agent\";\n  readonly binaries = [\"prime-agent\"];\n  readonly capabilities = {\n    mcp: true,\n    vision: true,\n    audio: false,\n    video: false,\n    tools: true,\n    streaming: true,\n  };\n  readonly config: Harness[\"config\"] = [\n    {\n      path: \"~/.prime/agent/settings.json\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Config dir overridable with PRIME_AGENT_CODING_AGENT_DIR.\",\n    },\n    { path: \".prime/agent/settings.json\", scope: \"project\", level: \"official\" },\n  ];\n  readonly sessions: Harness[\"sessions\"] = [\n    {\n      path: \"~/.prime/agent/sessions/<session-id>.jsonl\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Flat directory of JSONL transcripts whose header records the working directory; session ids are UUIDv7. Overridable with PRIME_AGENT_SESSION_DIR or --session-dir.\",\n    },\n    {\n      path: \"~/.prime/agent/session-artifacts/<session-id>/\",\n      scope: \"data\",\n      level: \"official\",\n      note: \"Per-session Python kernel state, scheduled jobs, harness state and child session transcripts under sub-<id>/.\",\n    },\n  ];\n  readonly persistence: Harness[\"persistence\"] = [\n    {\n      format: \"JSON\",\n      level: \"official\",\n      note: \"Settings, auth, telemetry, model cache and session artifact state files.\",\n    },\n    {\n      format: \"JSONL\",\n      level: \"official\",\n      note: \"Session transcripts, the RLM spawn ledger and structured logs.\",\n    },\n    {\n      format: \"dill\",\n      level: \"official\",\n      note: \"Pickled Python REPL state (kernel-state.dill) in session artifacts.\",\n    },\n  ];\n  readonly instructions: Harness[\"instructions\"] = [\n    {\n      path: \"AGENTS.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Loaded from parent directories and cwd; CLAUDE.md accepted as an alternative.\",\n    },\n    {\n      path: \".prime/agent/SYSTEM.md\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Replaces the default system prompt; APPEND_SYSTEM.md appends instead.\",\n    },\n    {\n      path: \"~/.prime/agent/AGENTS.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level instructions; CLAUDE.md accepted as an alternative.\",\n    },\n    {\n      path: \"~/.prime/agent/SYSTEM.md\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global system prompt replacement; APPEND_SYSTEM.md appends instead.\",\n    },\n  ];\n  readonly skills: Harness[\"skills\"] = [\n    { path: \".prime/agent/skills/\", scope: \"project\", level: \"official\" },\n    {\n      path: \".agents/skills/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Also scanned in ancestor directories up to the Git repository root; root .md files are ignored there.\",\n    },\n    {\n      path: \"~/.prime/agent/skills/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level skills.\",\n    },\n    {\n      path: \"~/.agents/skills/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Shared skills directory; root .md files are ignored there.\",\n    },\n  ];\n  override readonly skillsSyncTarget: Harness[\"skillsSyncTarget\"] = {\n    path: \"~/.prime/agent/skills/\",\n    scope: \"user\",\n    level: \"official\",\n  };\n  readonly commands: Harness[\"commands\"] = [\n    {\n      path: \".prime/agent/prompts/\",\n      scope: \"project\",\n      level: \"official\",\n      note: \"Prompt templates invoked as slash commands.\",\n    },\n    {\n      path: \"~/.prime/agent/prompts/\",\n      scope: \"user\",\n      level: \"official\",\n      note: \"Global user-level prompt templates.\",\n    },\n  ];\n  override readonly promptTemplates = this.commands;\n  override readonly promptTemplateSyncTarget: Harness[\"promptTemplateSyncTarget\"] = {\n    path: \"~/.prime/agent/prompts/\",\n    scope: \"user\",\n    level: \"official\",\n    format: \"markdown\",\n  };\n  readonly hooks: Harness[\"hooks\"] = [];\n  readonly invocation: Harness[\"invocation\"] = {\n    args: [\"-p\", \"{prompt}\"],\n    jsonArgs: [\"-p\", \"--mode\", \"json\", \"{prompt}\"],\n    noToolsArgs: [\"-p\", \"--no-tools\", \"{prompt}\"],\n    noToolsJsonArgs: [\"-p\", \"--no-tools\", \"--mode\", \"json\", \"{prompt}\"],\n    modelArgs: [\"--model\", \"{model}\"],\n    level: \"official\",\n    note: \"Add --mode json for structured event output. No read-only mode: the only built-in tool is a Python REPL and the worker and kernel processes are not a security sandbox.\",\n  };\n  override readonly modelListing: Harness[\"modelListing\"] = {\n    args: [\"model\", \"list\"],\n    searchArgs: [\"model\", \"list\", \"{search}\"],\n    level: \"official\",\n    note: \"Lists models with configured provider authentication; accepts an optional fuzzy search. --list-models was removed.\",\n  };\n  override readonly mcpConfigs: Harness[\"mcpConfigs\"] = [\n    {\n      path: \"~/.prime/agent/settings.json\",\n      scope: \"user\",\n      level: \"official\",\n      format: \"json\",\n      key: [\"mcpServers\"],\n      dialect: \"prime\",\n      note: 'prime-agent mcp add/remove manage this map; project settings entries are ignored for execution. Stdio env values are {\"env\": \"NAME\"} references, written from \"${NAME}\" values; literals are refused because the kernel rejects them at connect time.',\n    },\n  ];\n  override readonly agentsFile = \"~/.prime/agent/AGENTS.md\";\n  readonly detection = {\n    envVars: [\"PRIME_AGENT_KERNEL_OWNER_PID\"],\n    projectMarkers: [\".prime/agent\"],\n  };\n\n  protected override parseModelListingOutput(stdout: string): AvailableModel[] {\n    return parsePiModelTable(stdout, \"Prime Agent\");\n  }\n}\n","import type { HarnessConstructor } from \"../harness.ts\";\nimport Antigravity from \"./antigravity.ts\";\nimport Claude from \"./claude.ts\";\nimport Codex from \"./codex.ts\";\nimport Cursor from \"./cursor.ts\";\nimport Freebuff from \"./freebuff.ts\";\nimport Gemini from \"./gemini.ts\";\nimport GitHubCopilot from \"./github-copilot.ts\";\nimport Grok from \"./grok.ts\";\nimport MastraCode from \"./mastracode.ts\";\nimport Omp from \"./omp.ts\";\nimport OpenCode from \"./opencode.ts\";\nimport Pi from \"./pi.ts\";\nimport PrimeAgent from \"./prime-agent.ts\";\n\nexport const harnesses: HarnessConstructor[] = [\n  Antigravity,\n  Claude,\n  Codex,\n  Cursor,\n  Freebuff,\n  Gemini,\n  GitHubCopilot,\n  Grok,\n  MastraCode,\n  Omp,\n  OpenCode,\n  // Prime Agent is a Pi fork that still exports PI_CODING_AGENT, so its own\n  // env marker must be checked before Pi's.\n  PrimeAgent,\n  Pi,\n];\n","import type { Harness, HarnessConstructor } from \"./harness.ts\";\nimport { harnesses } from \"./harnesses/index.ts\";\nimport type { HarnessId } from \"./types.ts\";\n\nlet registry: Map<HarnessId, Harness> | undefined;\n\nfunction getRegistry(): Map<HarnessId, Harness> {\n  if (!registry) {\n    registry = new Map();\n    for (const HarnessClass of harnesses) {\n      const harness = new HarnessClass();\n      registry.set(harness.id, harness);\n    }\n  }\n  return registry;\n}\n\nexport function registerHarness(HarnessClass: HarnessConstructor): Harness {\n  const harness = new HarnessClass();\n  getRegistry().set(harness.id, harness);\n  return harness;\n}\n\nexport function getHarness(id: HarnessId): Harness {\n  const harness = getRegistry().get(id);\n  if (!harness) throw new Error(`Unknown harness: ${id}`);\n  return harness;\n}\n\nexport function listHarnesses(): HarnessId[] {\n  return [...getRegistry().keys()];\n}\n\nexport function isHarnessId(id: string): id is HarnessId {\n  return getRegistry().has(id as HarnessId);\n}\n\nexport function getAllHarnesses(): Harness[] {\n  return [...getRegistry().values()];\n}\n\n/**\n * Detect the active agent from environment variables.\n * Returns the first match since env detection is unambiguous.\n *\n * @returns {Harness | null} The detected harness, or null when none matches.\n */\nexport function detectHarnessFromEnv(): Harness | null {\n  for (const harness of getRegistry().values()) {\n    if (harness.detectEnv()) return harness;\n  }\n  return null;\n}\n\n/**\n * Detect which agents have project-level markers in the given directory.\n * Returns all matches (multiple agents can be configured in the same project).\n *\n * @param cwd - Directory to inspect; defaults to the current working directory.\n * @returns {Harness[]} Every harness whose project markers match.\n */\nexport function detectProjectHarnesses(cwd?: string): Harness[] {\n  return [...getRegistry().values()].filter((harness) => harness.detectProject(cwd));\n}\n\n/**\n * Detect the most likely active agent. Priority:\n * 1. Env vars (running inside agent = unambiguous)\n * 2. Single project-level match\n * 3. null if ambiguous or no match\n *\n * @param cwd - Directory to inspect for project markers.\n * @returns {Harness | null} The unambiguous active harness, or null.\n */\nexport function detectHarness(cwd?: string): Harness | null {\n  const fromEnv = detectHarnessFromEnv();\n  if (fromEnv) return fromEnv;\n\n  let match: Harness | null = null;\n  for (const harness of getRegistry().values()) {\n    if (harness.detectProject(cwd)) {\n      if (match) return null;\n      match = harness;\n    }\n  }\n  return match;\n}\n","/**\n * Normalized MCP server management across harness config dialects.\n *\n * Reads and writes work for every declared config file. JSON writes are a\n * parse/serialize round trip. TOML configs (codex, grok) carry user comments\n * that a round trip would destroy, so TOML writes are surgical line edits:\n * only the target server's section is removed or appended, the result is\n * re-parsed and checked against the intended state before anything is\n * written, and every write lands atomically via a temp file rename.\n */\nimport { mkdirSync, readFileSync, renameSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, isAbsolute, join } from \"node:path\";\nimport { parse as parseToml } from \"smol-toml\";\nimport type { Harness } from \"./harness.ts\";\nimport { agntnConfigDir } from \"./resolve.ts\";\nimport type { EvidenceLevel, McpConfigFile, McpServerConfig, ResolveOptions } from \"./types.ts\";\n\n/** One resolved config file together with the servers it declares. */\nexport interface McpConfigListing {\n  path: string;\n  scope: McpConfigFile[\"scope\"];\n  format: McpConfigFile[\"format\"];\n  level: EvidenceLevel;\n  note?: string;\n  exists: boolean;\n  servers: McpServerConfig[];\n  /** Set when the file exists but could not be parsed. */\n  error?: string;\n}\n\n/**\n * MCP config project paths are anchored to the project root, unlike the\n * plain candidate surface which leaves them relative for display.\n *\n * @param harness - Harness whose MCP config paths should be resolved.\n * @param options - Platform and path-resolution overrides.\n * @returns {Array<{ entry: McpConfigFile, path: string }>} Resolved config descriptors.\n */\nfunction resolveConfigs(\n  harness: Harness,\n  options: ResolveOptions,\n): Array<{ entry: McpConfigFile; path: string }> {\n  return harness.resolveCandidates(harness.mcpConfigs, options).map((entry) => ({\n    entry,\n    path: isAbsolute(entry.path)\n      ? entry.path\n      : join(options.projectRoot ?? process.cwd(), entry.path),\n  }));\n}\n\n/**\n * Reads a file, mapping a missing one to null instead of an error.\n *\n * @param path - File path to read.\n * @returns {string | null} File contents, or null when missing.\n */\nfunction readIfExists(path: string): string | null {\n  try {\n    return readFileSync(path, \"utf8\");\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return null;\n    throw error;\n  }\n}\n\nfunction drill(\n  /* oxlint-disable-next-line typescript/prefer-readonly-parameter-types */\n  root: Record<string, unknown>,\n  key: readonly string[],\n  create?: \"create\",\n): Record<string, unknown> | undefined {\n  let node: unknown = root;\n  for (const part of key) {\n    if (typeof node !== \"object\" || node === null) return undefined;\n    const record = node as Record<string, unknown>;\n    if (create && (typeof record[part] !== \"object\" || record[part] === null)) {\n      record[part] = {};\n    }\n    node = record[part];\n  }\n  return typeof node === \"object\" && node !== null ? (node as Record<string, unknown>) : undefined;\n}\n\nfunction isObjectRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === \"object\" && value !== null;\n}\n\nfunction asStringRecord(value: unknown): Record<string, string> | undefined {\n  if (!isObjectRecord(value) || Array.isArray(value)) return undefined;\n  const out: Record<string, string> = {};\n  for (const [k, v] of Object.entries(value)) {\n    if (typeof v === \"string\") out[k] = v;\n  }\n  return Object.keys(out).length > 0 ? out : undefined;\n}\n\nfunction asStringArray(value: unknown): string[] | undefined {\n  if (!Array.isArray(value)) return undefined;\n  return value.filter((item): item is string => typeof item === \"string\");\n}\n\n/**\n * Builds an object with the undefined-valued keys left out.\n *\n * @param source - Object whose undefined properties should be omitted.\n * @returns {T} The compacted object.\n */\nfunction compact<T extends Record<string, unknown>>(source: T): T {\n  return Object.fromEntries(Object.entries(source).filter(([, value]) => value !== undefined)) as T;\n}\n\nfunction stringField(record: Readonly<Record<string, unknown>>, key: string): string | undefined {\n  const value = record[key];\n  return typeof value === \"string\" ? value : undefined;\n}\n\nfunction booleanField(record: Readonly<Record<string, unknown>>, key: string): boolean | undefined {\n  const value = record[key];\n  return typeof value === \"boolean\" ? value : undefined;\n}\n\nfunction normalizeAntigravity(\n  name: string,\n  raw: Readonly<Record<string, unknown>>,\n): McpServerConfig {\n  const url = stringField(raw, \"serverUrl\");\n  return compact({\n    name,\n    transport: url ? (\"sse\" as const) : (\"stdio\" as const),\n    command: stringField(raw, \"command\"),\n    args: asStringArray(raw.args),\n    env: asStringRecord(raw.env),\n    url,\n  });\n}\n\nfunction normalizeOpenCode(name: string, raw: Readonly<Record<string, unknown>>): McpServerConfig {\n  const command = asStringArray(raw.command) ?? [];\n  const url = stringField(raw, \"url\");\n  return compact({\n    name,\n    transport: raw.type === \"remote\" || url ? (\"http\" as const) : (\"stdio\" as const),\n    command: command[0],\n    args: command.length > 1 ? command.slice(1) : undefined,\n    env: asStringRecord(raw.environment),\n    url,\n    headers: asStringRecord(raw.headers),\n    enabled: booleanField(raw, \"enabled\"),\n  });\n}\n\nfunction standardUrl(raw: Readonly<Record<string, unknown>>): string | undefined {\n  return stringField(raw, \"httpUrl\") ?? stringField(raw, \"url\");\n}\n\nfunction standardTransport(\n  declared: string | undefined,\n  url: string | undefined,\n): McpServerConfig[\"transport\"] {\n  if (declared === \"sse\") return \"sse\";\n  if (declared === \"http\" || url) return \"http\";\n  return \"stdio\";\n}\n\nfunction normalizeStandard(name: string, raw: Readonly<Record<string, unknown>>): McpServerConfig {\n  const url = standardUrl(raw);\n  return compact({\n    name,\n    transport: standardTransport(stringField(raw, \"type\"), url),\n    command: stringField(raw, \"command\"),\n    args: asStringArray(raw.args),\n    env: asStringRecord(raw.env),\n    url,\n    headers: asStringRecord(raw.headers),\n    enabled: booleanField(raw, \"enabled\"),\n  });\n}\n\n/** An env value that is exactly `${NAME}` stands for the variable NAME of the harness environment. */\nconst ENV_REFERENCE = /^\\$\\{([A-Za-z_][A-Za-z0-9_]*)\\}$/;\n\n/** Thrown when a server's env cannot be written the way the target dialect requires. */\nexport class McpEnvError extends Error {\n  override readonly name = \"McpEnvError\";\n}\n\n/** Thrown when the target dialect cannot carry a server's transport. */\nexport class McpTransportError extends Error {\n  override readonly name = \"McpTransportError\";\n}\n\nfunction envReference(value: string): string | undefined {\n  return ENV_REFERENCE.exec(value)?.[1];\n}\n\n/**\n * Reads a Prime Agent env map, where each value is a {\"env\": \"NAME\"}\n * reference, into the shared `${NAME}` spelling. Literal strings are kept\n * as found so the listing shows what the file holds.\n *\n * @param value - Raw `env` field of a Prime Agent server entry.\n * @returns {Record<string, string> | undefined} The env map, or undefined when empty.\n */\nfunction primeEnv(value: unknown): Record<string, string> | undefined {\n  if (!isObjectRecord(value) || Array.isArray(value)) return undefined;\n  const out: Record<string, string> = {};\n  for (const [key, raw] of Object.entries(value)) {\n    if (typeof raw === \"string\") out[key] = raw;\n    else if (isObjectRecord(raw) && typeof raw.env === \"string\") out[key] = `\\${${raw.env}}`;\n  }\n  return Object.keys(out).length > 0 ? out : undefined;\n}\n\nfunction normalizePrime(name: string, raw: Readonly<Record<string, unknown>>): McpServerConfig {\n  return compact({ ...normalizeStandard(name, raw), env: primeEnv(raw.env) });\n}\n\n/**\n * Stdio from `command`, HTTP from `url`, SSE settled at connect time: `type` says nothing here.\n *\n * @param name - Server name from the containing map.\n * @param raw - Raw Mastra Code server entry.\n * @returns {McpServerConfig} The normalized server entry.\n */\nfunction normalizeMastracode(\n  name: string,\n  raw: Readonly<Record<string, unknown>>,\n): McpServerConfig {\n  const url = stringField(raw, \"url\");\n  return compact({\n    name,\n    transport: url ? (\"http\" as const) : (\"stdio\" as const),\n    command: stringField(raw, \"command\"),\n    args: asStringArray(raw.args),\n    env: asStringRecord(raw.env),\n    url,\n    headers: asStringRecord(raw.headers),\n  });\n}\n\n/**\n * Maps one raw config entry to the normalized shape, per dialect.\n *\n * @param name - Server name from the containing map.\n * @param raw - Raw dialect-specific server entry.\n * @param dialect - Harness config dialect.\n * @returns {McpServerConfig} The normalized server entry.\n */\nfunction normalizeEntry(\n  name: string,\n  raw: Readonly<Record<string, unknown>>,\n  dialect: McpConfigFile[\"dialect\"],\n): McpServerConfig {\n  if (dialect === \"antigravity\") return normalizeAntigravity(name, raw);\n  if (dialect === \"mastracode\") return normalizeMastracode(name, raw);\n  if (dialect === \"opencode\") return normalizeOpenCode(name, raw);\n  if (dialect === \"prime\") return normalizePrime(name, raw);\n  return normalizeStandard(name, raw);\n}\n\nfunction denormalizeAntigravity(server: McpServerConfig): Record<string, unknown> {\n  if (server.url) return { serverUrl: server.url };\n  return compact({\n    command: server.command,\n    args: server.args?.length ? server.args : undefined,\n    env: server.env,\n  });\n}\n\nfunction denormalizeOpenCode(server: McpServerConfig): Record<string, unknown> {\n  if (server.url) {\n    return compact({\n      type: \"remote\",\n      url: server.url,\n      headers: server.headers,\n      enabled: server.enabled,\n    });\n  }\n  return compact({\n    type: \"local\",\n    command: [server.command ?? \"\", ...(server.args ?? [])],\n    environment: server.env,\n    enabled: server.enabled,\n  });\n}\n\nfunction denormalizeMastracode(server: McpServerConfig): Record<string, unknown> {\n  if (server.url) return compact({ url: server.url, headers: server.headers });\n  return compact({\n    command: server.command,\n    args: server.args?.length ? server.args : undefined,\n    env: server.env,\n  });\n}\n\nfunction denormalizeStandard(server: McpServerConfig): Record<string, unknown> {\n  return compact({\n    type: server.transport,\n    command: server.command,\n    args: server.args?.length ? server.args : undefined,\n    env: server.env,\n    url: server.url,\n    headers: server.headers,\n    enabled: server.enabled,\n  });\n}\n\n/**\n * Prime Agent's kernel hands stdio servers a trimmed environment plus the\n * variables the entry names, so its env map holds references only. A\n * literal has no way in and is refused rather than written as a server\n * that fails on its first connection.\n *\n * @param server - Normalized server whose env values are `${NAME}` references.\n * @returns {Record<string, unknown>} The Prime Agent entry.\n */\nfunction denormalizePrime(server: McpServerConfig): Record<string, unknown> {\n  const env = server.env\n    ? Object.fromEntries(\n        Object.entries(server.env).map(([key, value]) => [\n          key,\n          { env: requirePrimeReference(server, key, value) },\n        ]),\n      )\n    : undefined;\n  return compact({ ...denormalizeStandard(server), env });\n}\n\nfunction requirePrimeReference(server: McpServerConfig, key: string, value: string): string {\n  const reference = envReference(value);\n  if (reference === undefined) {\n    throw new McpEnvError(\n      `${server.name}: Prime Agent takes only environment references in env; write ${key} as \"\\${NAME}\" and export NAME where prime-agent runs`,\n    );\n  }\n  return reference;\n}\n\n/**\n * Shapes a server's env for one dialect before it is compared or written:\n * Prime Agent keeps `${NAME}` references and refuses literals, every other\n * dialect gets the references resolved from the environment of this\n * process, the same way `~` and `${HOME}` are expanded before a sync.\n *\n * @param server - Normalized server, possibly carrying references.\n * @param dialect - Target harness config dialect.\n * @returns {McpServerConfig} The server as the dialect can hold it.\n */\nfunction resolveEnvReferences(\n  server: McpServerConfig,\n  dialect: McpConfigFile[\"dialect\"],\n): McpServerConfig {\n  if (!server.env) return server;\n  if (dialect === \"prime\") {\n    for (const [key, value] of Object.entries(server.env))\n      requirePrimeReference(server, key, value);\n    return server;\n  }\n  const env: Record<string, string> = {};\n  for (const [key, value] of Object.entries(server.env)) {\n    const reference = envReference(value);\n    if (reference === undefined) {\n      env[key] = value;\n      continue;\n    }\n    // process.env inherits Object.prototype, so a bare lookup would turn\n    // ${constructor} into a function; only own string values count.\n    const resolved = Object.hasOwn(process.env, reference) ? process.env[reference] : undefined;\n    if (typeof resolved !== \"string\") {\n      throw new McpEnvError(\n        `${server.name}: env ${key} references ${reference}, which is not set in this environment`,\n      );\n    }\n    env[key] = resolved;\n  }\n  return { ...server, env };\n}\n\n/**\n * Env references per {@link resolveEnvReferences}, minus `sse` and `enabled` for Mastra Code.\n * Pi rejects `sse`, and an sse url is rarely the streamable HTTP endpoint, so it's refused.\n *\n * @param server - Normalized server from the master list or a caller.\n * @param dialect - Target harness config dialect.\n * @returns {McpServerConfig} The server as the dialect can hold it.\n */\nfunction shapeForDialect(\n  server: McpServerConfig,\n  dialect: McpConfigFile[\"dialect\"],\n): McpServerConfig {\n  const shaped = resolveEnvReferences(server, dialect);\n  if (dialect === \"pi\" && shaped.transport === \"sse\") {\n    throw new McpTransportError(\n      `${server.name}: Pi takes stdio and streamable HTTP servers, not sse; point url at the server's streamable HTTP endpoint`,\n    );\n  }\n  if (dialect !== \"mastracode\") return shaped;\n  return compact({\n    ...shaped,\n    transport: shaped.url ? (\"http\" as const) : (\"stdio\" as const),\n    enabled: undefined,\n  });\n}\n\n/**\n * Converts a normalized server back to the raw shape one dialect expects.\n *\n * @param server - Normalized server configuration.\n * @param dialect - Target harness config dialect.\n * @returns {Record<string, unknown>} The dialect-specific entry.\n */\nfunction denormalizeEntry(\n  server: McpServerConfig,\n  dialect: McpConfigFile[\"dialect\"],\n): Record<string, unknown> {\n  if (dialect === \"antigravity\") return denormalizeAntigravity(server);\n  if (dialect === \"mastracode\") return denormalizeMastracode(server);\n  if (dialect === \"opencode\") return denormalizeOpenCode(server);\n  if (dialect === \"prime\") return denormalizePrime(server);\n  return denormalizeStandard(server);\n}\n\n/** Entry fields the standard family reads or writes; Pi keeps the rest on a replace. */\nconst STANDARD_FIELDS: ReadonlySet<string> = new Set([\n  \"type\",\n  \"command\",\n  \"args\",\n  \"env\",\n  \"url\",\n  \"httpUrl\",\n  \"headers\",\n  \"enabled\",\n]);\n\n/**\n * A Pi entry that keeps its transport keeps `exposure`, `description` and the other fields Pi adds.\n *\n * @param previous - Raw entry stored under the server name, if any.\n * @param server - Normalized server being written.\n * @param dialect - Target harness config dialect.\n * @returns {Record<string, unknown>} The raw entry to store.\n */\nfunction replacementEntry(\n  previous: unknown,\n  server: McpServerConfig,\n  dialect: McpConfigFile[\"dialect\"],\n): Record<string, unknown> {\n  const entry = denormalizeEntry(server, dialect);\n  if (dialect !== \"pi\" || !isObjectRecord(previous)) return entry;\n  if (normalizeStandard(server.name, previous).transport !== server.transport) return entry;\n  const kept = Object.entries(previous).filter(([key]) => !STANDARD_FIELDS.has(key));\n  return { ...entry, ...Object.fromEntries(kept) };\n}\n\nfunction listingBase(entry: McpConfigFile, path: string): McpConfigListing {\n  return compact({\n    path,\n    scope: entry.scope,\n    format: entry.format,\n    level: entry.level,\n    note: entry.note,\n    exists: false,\n    servers: [],\n  });\n}\n\nfunction configServerMap(raw: string, entry: McpConfigFile): Record<string, unknown> {\n  const parsed = entry.format === \"toml\" ? parseToml(raw) : (JSON.parse(raw) as unknown);\n  return drill(isObjectRecord(parsed) ? parsed : {}, entry.key) ?? {};\n}\n\nfunction normalizeServerMap(\n  map: Readonly<Record<string, unknown>>,\n  dialect: McpConfigFile[\"dialect\"],\n): McpServerConfig[] {\n  const servers: McpServerConfig[] = [];\n  for (const [name, rawEntry] of Object.entries(map)) {\n    if (isObjectRecord(rawEntry)) servers.push(normalizeEntry(name, rawEntry, dialect));\n  }\n  return servers;\n}\n\nfunction listMcpConfig(entry: McpConfigFile, path: string): McpConfigListing {\n  const base = listingBase(entry, path);\n  try {\n    const raw = readIfExists(path);\n    if (raw === null) return base;\n    const servers = normalizeServerMap(configServerMap(raw, entry), entry.dialect);\n    return { ...base, exists: true, servers };\n  } catch (error) {\n    return {\n      ...base,\n      exists: true,\n      error: error instanceof Error ? error.message : String(error),\n    };\n  }\n}\n\n/**\n * Lists the MCP servers a harness has configured, per declared config file.\n * Missing files come back with `exists: false`; unparsable ones carry `error`.\n *\n * @param harness - Harness whose configs should be read.\n * @param options - Platform and path-resolution overrides.\n * @returns {McpConfigListing[]} One listing per declared config file.\n */\nexport function listMcpServers(harness: Harness, options: ResolveOptions = {}): McpConfigListing[] {\n  return resolveConfigs(harness, options).map(({ entry, path }) => listMcpConfig(entry, path));\n}\n\nfunction writableConfig(\n  harness: Harness,\n  scope: \"user\" | \"project\",\n  options: ResolveOptions,\n): { entry: McpConfigFile; path: string } {\n  const config = resolveConfigs(harness, options).find(({ entry }) => entry.scope === scope);\n  if (!config) {\n    throw new Error(`Harness ${harness.id} has no ${scope}-scope MCP config`);\n  }\n  return config;\n}\n\nfunction writeAtomically(path: string, content: string): void {\n  mkdirSync(dirname(path), { recursive: true });\n  const temp = join(dirname(path), `.${Date.now()}-${process.pid}.mcp.tmp`);\n  writeFileSync(temp, content);\n  renameSync(temp, path);\n}\n\nfunction tomlValue(value: string): string {\n  return JSON.stringify(value);\n}\n\nfunction tomlKeyPart(name: string): string {\n  return /^[A-Za-z0-9_-]+$/.test(name) ? name : JSON.stringify(name);\n}\n\n/**\n * Renders one server as TOML sections, scalars before sub-tables.\n *\n * @param key - TOML path containing the server map.\n * @param server - Server to serialize.\n * @returns {string} The rendered TOML section block.\n */\nfunction tomlSections(key: readonly string[], server: McpServerConfig): string {\n  const head = [...key, server.name].map(tomlKeyPart).join(\".\");\n  const lines = [`[${head}]`];\n  if (server.command) lines.push(`command = ${tomlValue(server.command)}`);\n  if (server.args?.length) lines.push(`args = [${server.args.map(tomlValue).join(\", \")}]`);\n  if (server.url) lines.push(`url = ${tomlValue(server.url)}`);\n  if (server.enabled !== undefined) lines.push(`enabled = ${server.enabled}`);\n  for (const [subKey, record] of [\n    [\"env\", server.env],\n    [\"headers\", server.headers],\n  ] as const) {\n    if (!record) continue;\n    lines.push(\"\", `[${head}.${subKey}]`);\n    for (const [k, v] of Object.entries(record)) {\n      lines.push(`${tomlKeyPart(k)} = ${tomlValue(v)}`);\n    }\n  }\n  return `${lines.join(\"\\n\")}\\n`;\n}\n\n/**\n * Deletes the lines that define one server in a TOML config: its\n * `[key.name]` section (with sub-tables) and any `name = {...}` inline\n * assignment inside the bare `[key]` table. Every other line survives\n * byte-for-byte, comments included.\n *\n * @param raw - Original TOML text.\n * @param key - TOML path containing the server map.\n * @param name - Server name to remove.\n * @returns {string} TOML text without the target server.\n */\nfunction stripTomlServer(raw: string, key: readonly string[], name: string): string {\n  const prefix = RegExp.escape(key.map(tomlKeyPart).join(\".\"));\n  const namePart = `(?:${RegExp.escape(tomlKeyPart(name))}|${RegExp.escape(JSON.stringify(name))})`;\n  const sectionRe = new RegExp(`^\\\\s*\\\\[${prefix}\\\\.${namePart}(\\\\.[^\\\\]]+)?\\\\]`);\n  const bareTableRe = new RegExp(`^\\\\s*\\\\[${prefix}\\\\]\\\\s*(#.*)?$`);\n  const anyHeaderRe = /^\\s*\\[/;\n  const inlineRe = new RegExp(`^\\\\s*${namePart}\\\\s*=`);\n\n  const kept: string[] = [];\n  let inTargetSection = false;\n  let inBareTable = false;\n  for (const line of raw.split(\"\\n\")) {\n    if (anyHeaderRe.test(line)) {\n      inTargetSection = sectionRe.test(line);\n      inBareTable = bareTableRe.test(line);\n    } else if (inBareTable && inlineRe.test(line)) {\n      continue;\n    }\n    if (inTargetSection) continue;\n    kept.push(line);\n  }\n  return kept.join(\"\\n\");\n}\n\nfunction serverMapFromToml(raw: string, key: readonly string[]): Record<string, unknown> {\n  const parsed = parseToml(raw);\n  return drill(parsed as Record<string, unknown>, key) ?? {};\n}\n\n/**\n * Verifies a surgical TOML edit before it is written: the result must still\n * parse, hold the expected state for the target server, and leave every other\n * server untouched.\n *\n * @param beforeMap - Server map before the edit.\n * @param after - Candidate TOML text after the edit.\n * @param key - TOML path containing the server map.\n * @param name - Target server name.\n * @param shouldExist - Whether the target must remain after the edit.\n */\nfunction assertTomlEdit(\n  beforeMap: Readonly<Record<string, unknown>>,\n  after: string,\n  key: readonly string[],\n  name: string,\n  shouldExist: boolean,\n): void {\n  let afterMap: Record<string, unknown>;\n  try {\n    afterMap = serverMapFromToml(after, key);\n  } catch (error) {\n    throw new Error(\n      `TOML edit produced an unparsable file, aborting: ${error instanceof Error ? error.message : String(error)}`,\n    );\n  }\n\n  if (Object.hasOwn(afterMap, name) !== shouldExist) {\n    throw new Error(\n      `TOML edit did not leave server ${name} ${shouldExist ? \"present\" : \"absent\"}, aborting`,\n    );\n  }\n\n  for (const other of new Set([...Object.keys(beforeMap), ...Object.keys(afterMap)])) {\n    if (other === name) continue;\n    if (JSON.stringify(beforeMap[other]) !== JSON.stringify(afterMap[other])) {\n      throw new Error(`TOML edit touched servers other than ${name}, aborting`);\n    }\n  }\n}\n\nfunction addTomlServer(path: string, key: readonly string[], server: McpServerConfig): boolean {\n  const before = readIfExists(path) ?? \"\";\n  const beforeMap = serverMapFromToml(before, key);\n  const replaced = Object.hasOwn(beforeMap, server.name);\n  const stripped = replaced ? stripTomlServer(before, key, server.name) : before;\n  const body = stripped.replace(/\\s+$/, \"\");\n  const after = body ? `${body}\\n\\n${tomlSections(key, server)}` : tomlSections(key, server);\n  assertTomlEdit(beforeMap, after, key, server.name, true);\n  writeAtomically(path, after);\n  return replaced;\n}\n\nfunction removeTomlServer(path: string, key: readonly string[], name: string): boolean {\n  const before = readIfExists(path);\n  if (before === null) return false;\n  const beforeMap = serverMapFromToml(before, key);\n  if (!Object.hasOwn(beforeMap, name)) return false;\n  const after = stripTomlServer(before, key, name);\n  assertTomlEdit(beforeMap, after, key, name, false);\n  writeAtomically(path, after);\n  return true;\n}\n\n/**\n * Adds (or replaces) one MCP server in a harness's config. The rest of the\n * file is preserved: JSON through a parse/serialize round trip (formatting\n * normalizes to two-space indentation), TOML through a surgical line edit.\n *\n * @param harness - Target harness.\n * @param server - Normalized server configuration to write.\n * @param scope - User or project config scope.\n * @param options - Platform and path-resolution overrides.\n * @returns {{ path: string, replaced: boolean }} The written path and replacement status.\n */\nexport function addMcpServer(\n  harness: Harness,\n  server: McpServerConfig,\n  scope: \"user\" | \"project\" = \"user\",\n  options: ResolveOptions = {},\n): { path: string; replaced: boolean } {\n  const { entry, path } = writableConfig(harness, scope, options);\n  const resolved = shapeForDialect(server, entry.dialect);\n\n  if (entry.format === \"toml\") {\n    return { path, replaced: addTomlServer(path, entry.key, resolved) };\n  }\n\n  const root = JSON.parse(readIfExists(path) ?? \"{}\") as Record<string, unknown>;\n  const map = drill(root, entry.key, \"create\");\n  if (!map) throw new Error(`Config at ${path} has a non-object at ${entry.key.join(\".\")}`);\n\n  const replaced = Object.hasOwn(map, server.name);\n  map[server.name] = replacementEntry(map[server.name], resolved, entry.dialect);\n  writeAtomically(path, `${JSON.stringify(root, null, 2)}\\n`);\n  return { path, replaced };\n}\n\n/**\n * Removes one MCP server from a harness's config.\n *\n * @param harness - Target harness.\n * @param name - Server name to remove.\n * @param scope - User or project config scope.\n * @param options - Platform and path-resolution overrides.\n * @returns {{ path: string, removed: boolean }} The targeted path and removal status.\n */\nexport function removeMcpServer(\n  harness: Harness,\n  name: string,\n  scope: \"user\" | \"project\" = \"user\",\n  options: ResolveOptions = {},\n): { path: string; removed: boolean } {\n  const { entry, path } = writableConfig(harness, scope, options);\n\n  if (entry.format === \"toml\") {\n    return { path, removed: removeTomlServer(path, entry.key, name) };\n  }\n\n  const raw = readIfExists(path);\n  if (raw === null) return { path, removed: false };\n\n  const root = JSON.parse(raw) as Record<string, unknown>;\n  const map = drill(root, entry.key);\n  if (!map || !Object.hasOwn(map, name)) return { path, removed: false };\n\n  delete map[name];\n  writeAtomically(path, `${JSON.stringify(root, null, 2)}\\n`);\n  return { path, removed: true };\n}\n\ntype JsoncState = \"code\" | \"string\" | \"escape\" | \"line-comment\" | \"block-comment\";\n\ntype JsoncContext = Readonly<{\n  text: string;\n  index: number;\n  character: string;\n  next: string | undefined;\n}>;\n\ntype JsoncStep = Readonly<{\n  state: JsoncState;\n  output: string;\n  advance: number;\n}>;\n\ntype JsoncScanner = (context: JsoncContext) => JsoncStep;\n\nfunction trailingJsoncComma(text: string, index: number): boolean {\n  const rest = text.slice(index + 1);\n  const significant = rest.replaceAll(/\\/\\/[^\\n]*|\\/\\*[\\s\\S]*?\\*\\/|\\s+/g, \"\");\n  return significant.startsWith(\"}\") || significant.startsWith(\"]\");\n}\n\nfunction scanJsoncCode(context: JsoncContext): JsoncStep {\n  const { character, next } = context;\n  if (character === '\"') return { state: \"string\", output: character, advance: 0 };\n  if (character === \"/\" && next === \"/\") {\n    return { state: \"line-comment\", output: \"\", advance: 1 };\n  }\n  if (character === \"/\" && next === \"*\") {\n    return { state: \"block-comment\", output: \"\", advance: 1 };\n  }\n  if (character === \",\" && trailingJsoncComma(context.text, context.index)) {\n    return { state: \"code\", output: \"\", advance: 0 };\n  }\n  return { state: \"code\", output: character, advance: 0 };\n}\n\nfunction scanJsoncString({ character }: JsoncContext): JsoncStep {\n  if (character === \"\\\\\") return { state: \"escape\", output: character, advance: 0 };\n  if (character === '\"') return { state: \"code\", output: character, advance: 0 };\n  return { state: \"string\", output: character, advance: 0 };\n}\n\nfunction scanJsoncEscape({ character }: JsoncContext): JsoncStep {\n  return { state: \"string\", output: character, advance: 0 };\n}\n\nfunction scanJsoncLineComment({ character }: JsoncContext): JsoncStep {\n  if (character === \"\\n\") return { state: \"code\", output: character, advance: 0 };\n  return { state: \"line-comment\", output: \"\", advance: 0 };\n}\n\nfunction scanJsoncBlockComment({ character, next }: JsoncContext): JsoncStep {\n  if (character === \"*\" && next === \"/\") {\n    return { state: \"code\", output: \"\", advance: 1 };\n  }\n  return { state: \"block-comment\", output: \"\", advance: 0 };\n}\n\nconst JSONC_SCANNERS: Record<JsoncState, JsoncScanner> = {\n  code: scanJsoncCode,\n  string: scanJsoncString,\n  escape: scanJsoncEscape,\n  \"line-comment\": scanJsoncLineComment,\n  \"block-comment\": scanJsoncBlockComment,\n};\n\n/**\n * Strips JSONC extensions (comments and trailing commas) so the master sync\n * file can be read with JSON.parse. String contents are left untouched.\n *\n * @param text - JSONC source text.\n * @returns {unknown} The parsed JSON value.\n */\nexport function parseJsonc(text: string): unknown {\n  let out = \"\";\n  let state: JsoncState = \"code\";\n  for (let index = 0; index < text.length; index++) {\n    const character = text[index] as string;\n    const step: JsoncStep = JSONC_SCANNERS[state]({\n      text,\n      index,\n      character,\n      next: text[index + 1],\n    });\n    out += step.output;\n    state = step.state;\n    index += step.advance;\n  }\n  return JSON.parse(out);\n}\n\n/**\n * Resolves the master sync file path: $XDG_CONFIG_HOME or ~/.config.\n *\n * @param options - Path-resolution overrides.\n * @returns {string} The resolved master MCP config path.\n */\nexport function masterMcpPath(options: ResolveOptions = {}): string {\n  return join(agntnConfigDir(options), \"mcp.jsonc\");\n}\n\n/** One harness's outcome of a sync run. */\nexport interface SyncTargetResult {\n  id: string;\n  path?: string;\n  /** Reason this harness could not be targeted; `results` is empty then. */\n  skipped?: string;\n  /** Set when the master list excludes this harness; master-listed names are withdrawn. */\n  excluded?: true;\n  results: Array<{\n    name: string;\n    action: \"added\" | \"replaced\" | \"removed\" | \"kept\" | \"unchanged\" | \"skipped\";\n    /** Why a master server could not be written to this harness. */\n    reason?: string;\n  }>;\n}\n\n/** Outcome of resetting the harness configs to the master list. */\nexport interface SyncReport {\n  source: string;\n  servers: string[];\n  targets: SyncTargetResult[];\n}\n\nfunction canonical(server: McpServerConfig): string {\n  return JSON.stringify(\n    Object.fromEntries(Object.entries(server).sort(([a], [b]) => a.localeCompare(b))),\n  );\n}\n\n/**\n * Expands a leading `~` and `${HOME}` in master-list values. Harnesses spawn\n * MCP commands without a shell, so the expansion has to happen here: the\n * synced configs always carry absolute paths.\n *\n * @param value - Master-list value to expand.\n * @param home - Home directory used for expansion.\n * @returns {string} The expanded value.\n */\nfunction expandHome(value: string, home: string): string {\n  return value.replaceAll(/^~(?=\\/|$)|\\$\\{HOME\\}/g, () => home);\n}\n\nfunction expandServerHome(server: McpServerConfig, home: string): McpServerConfig {\n  return compact({\n    ...server,\n    command: server.command === undefined ? undefined : expandHome(server.command, home),\n    args: server.args?.map((arg) => expandHome(arg, home)),\n    env: server.env\n      ? Object.fromEntries(Object.entries(server.env).map(([k, v]) => [k, expandHome(v, home)]))\n      : undefined,\n  });\n}\n\nfunction requiredMasterServerMap(\n  root: Readonly<Record<string, unknown>>,\n  path: string,\n): Record<string, unknown> {\n  const map = drill(root as Record<string, unknown>, [\"mcpServers\"]);\n  if (!map || Array.isArray(map)) {\n    throw new Error(`Master MCP list at ${path} has no mcpServers object`);\n  }\n  return map;\n}\n\nfunction normalizeMasterServers(\n  map: Readonly<Record<string, unknown>>,\n  home: string,\n): McpServerConfig[] {\n  const servers: McpServerConfig[] = [];\n  for (const [name, rawEntry] of Object.entries(map)) {\n    if (isObjectRecord(rawEntry)) {\n      servers.push(expandServerHome(normalizeEntry(name, rawEntry, \"standard\"), home));\n    }\n  }\n  return servers;\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n  return Array.isArray(value) && value.every((item) => typeof item === \"string\");\n}\n\nfunction masterExcludes(value: unknown, path: string): string[] {\n  if (value === undefined) return [];\n  if (!isStringArray(value)) {\n    throw new Error(\n      `Master MCP list at ${path} has an invalid excludes: expected an array of harness ids`,\n    );\n  }\n  return value;\n}\n\nfunction masterKeep(value: unknown, path: string): Record<string, string[]> {\n  if (value === undefined) return {};\n  if (\n    !isObjectRecord(value) ||\n    Array.isArray(value) ||\n    !Object.values(value).every(isStringArray)\n  ) {\n    throw new Error(\n      `Master MCP list at ${path} has an invalid keep: expected harness ids mapped to arrays of server names`,\n    );\n  }\n  return value as Record<string, string[]>;\n}\n\n/**\n * Reads and normalizes the master list; throws when the file is missing or invalid.\n *\n * @param options - Path-resolution overrides.\n * @returns {{ path: string, servers: McpServerConfig[], excludes: string[], keep: Record<string, string[]> }} The master list.\n */\nexport function readMasterMcpServers(options: ResolveOptions = {}): {\n  path: string;\n  servers: McpServerConfig[];\n  /** Harness ids the master list opts out of syncing. */\n  excludes: string[];\n  /** Per harness id, its own server names that sync leaves in place. */\n  keep: Record<string, string[]>;\n} {\n  const path = masterMcpPath(options);\n  const raw = readIfExists(path);\n  if (raw === null) throw new Error(`No master MCP list at ${path}`);\n\n  const parsed = parseJsonc(raw);\n  const root = isObjectRecord(parsed) ? parsed : {};\n  const map = requiredMasterServerMap(root, path);\n  return {\n    path,\n    servers: normalizeMasterServers(map, options.homeDir ?? homedir()),\n    excludes: masterExcludes(root.excludes, path),\n    keep: masterKeep(root.keep, path),\n  };\n}\n\ntype MasterSyncInput = Readonly<{\n  path: string;\n  servers: readonly McpServerConfig[];\n  excludes: readonly string[];\n  keep: Readonly<Record<string, readonly string[]>>;\n}>;\n\nfunction optionalPath(path: string | undefined): {} | { path: string } {\n  return path === undefined ? {} : { path };\n}\n\nfunction existingServers(listing: McpConfigListing | undefined): Map<string, string> {\n  return new Map((listing?.servers ?? []).map((server) => [server.name, canonical(server)]));\n}\n\nfunction withdrawMasterServersFromExcludedHarness(\n  harness: Harness,\n  existing: ReadonlyMap<string, string>,\n  masterNames: ReadonlySet<string>,\n  initialPath: string | undefined,\n  options: ResolveOptions,\n): SyncTargetResult {\n  const results: SyncTargetResult[\"results\"] = [];\n  let path = initialPath;\n  for (const name of existing.keys()) {\n    if (!masterNames.has(name)) continue;\n    const removed = removeMcpServer(harness, name, \"user\", options);\n    if (removed.removed) {\n      path = removed.path;\n      results.push({ name, action: \"removed\" });\n    }\n  }\n  return { id: harness.id, ...optionalPath(path), excluded: true, results };\n}\n\n/**\n * A server the target dialect cannot hold, skipped in a sync instead of stopping it.\n *\n * @param error - Error thrown while shaping or writing one server.\n * @returns {boolean} Whether the error is one of the refusals a sync reports.\n */\nfunction cannotHold(error: unknown): error is McpEnvError | McpTransportError {\n  return error instanceof McpEnvError || error instanceof McpTransportError;\n}\n\nfunction removeExtraServers(\n  harness: Harness,\n  existing: ReadonlyMap<string, string>,\n  masterNames: ReadonlySet<string>,\n  keep: Readonly<Record<string, readonly string[]>>,\n  options: ResolveOptions,\n): { path?: string; results: SyncTargetResult[\"results\"] } {\n  const kept = (Object.hasOwn(keep, harness.id) ? keep[harness.id] : undefined) ?? [];\n  const results: SyncTargetResult[\"results\"] = [];\n  let path: string | undefined;\n  for (const name of existing.keys()) {\n    if (masterNames.has(name)) continue;\n    if (kept.includes(name)) {\n      results.push({ name, action: \"kept\" });\n      continue;\n    }\n    const removed = removeMcpServer(harness, name, \"user\", options);\n    if (removed.removed) {\n      path = removed.path;\n      results.push({ name, action: \"removed\" });\n    }\n  }\n  return { ...optionalPath(path), results };\n}\n\nfunction syncIncludedHarness(\n  harness: Harness,\n  master: MasterSyncInput,\n  existing: ReadonlyMap<string, string>,\n  masterNames: ReadonlySet<string>,\n  initialPath: string | undefined,\n  options: ResolveOptions,\n): SyncTargetResult {\n  const results: SyncTargetResult[\"results\"] = [];\n  let path = initialPath;\n  const { dialect } = writableConfig(harness, \"user\", options).entry;\n  for (const server of master.servers) {\n    try {\n      const resolved = shapeForDialect(server, dialect);\n      if (existing.get(server.name) === canonical(resolved)) {\n        results.push({ name: server.name, action: \"unchanged\" });\n        continue;\n      }\n      const written = addMcpServer(harness, resolved, \"user\", options);\n      path = written.path;\n      results.push({ name: server.name, action: written.replaced ? \"replaced\" : \"added\" });\n    } catch (error) {\n      // One server the dialect cannot hold must not stop the rest of the list.\n      if (!cannotHold(error)) throw error;\n      results.push({ name: server.name, action: \"skipped\", reason: error.message });\n    }\n  }\n  const extras = removeExtraServers(harness, existing, masterNames, master.keep, options);\n  results.push(...extras.results);\n  return { id: harness.id, ...optionalPath(extras.path ?? path), results };\n}\n\nfunction syncMcpTarget(\n  harness: Harness,\n  master: MasterSyncInput,\n  masterNames: ReadonlySet<string>,\n  options: ResolveOptions,\n): SyncTargetResult {\n  const hasUserConfig = harness.mcpConfigs.some((candidate) => candidate.scope === \"user\");\n  if (!hasUserConfig) {\n    return { id: harness.id, skipped: \"no user-scope MCP config\", results: [] };\n  }\n\n  const listing = listMcpServers(harness, options).find((item) => item.scope === \"user\");\n  if (listing?.error) {\n    return {\n      id: harness.id,\n      path: listing.path,\n      skipped: `existing config is unreadable: ${listing.error}`,\n      results: [],\n    };\n  }\n\n  const existing = existingServers(listing);\n  if (master.excludes.includes(harness.id)) {\n    return withdrawMasterServersFromExcludedHarness(\n      harness,\n      existing,\n      masterNames,\n      listing?.path,\n      options,\n    );\n  }\n  return syncIncludedHarness(harness, master, existing, masterNames, listing?.path, options);\n}\n\n/**\n * Resets each harness's user-scope MCP config to exactly the master list:\n * missing servers are added, drifted ones replaced, and servers absent from\n * the master are removed unless its `keep` names them for that harness. The\n * master file is the single source of truth, exceptions included.\n *\n * @param harnesses - Harnesses to synchronize.\n * @param options - Platform and path-resolution overrides.\n * @returns {SyncReport} Per-harness synchronization outcomes.\n */\nexport function syncMcpServers(\n  harnesses: readonly Harness[],\n  options: ResolveOptions = {},\n): SyncReport {\n  const master = readMasterMcpServers(options);\n  const masterNames = new Set(master.servers.map((server) => server.name));\n  return {\n    source: master.path,\n    servers: master.servers.map((server) => server.name),\n    targets: harnesses.map((harness) => syncMcpTarget(harness, master, masterNames, options)),\n  };\n}\n","/**\n * Symlink-based sync of the global agent instructions file across harnesses.\n *\n * The master file (default ~/.config/agntn/AGENTS.md, overridable via\n * ~/.config/agntn/agents.jsonc) is the single physical copy; every harness's\n * user-scope instructions file becomes a symlink to it, so an edit made\n * through any harness lands in the master and is visible everywhere at once.\n * Explicit companion files are linked beside each instructions target. Sync\n * is a doctor: it creates missing links, repairs wrong ones, adopts diverged\n * regular files (content moved to a backup, then relinked), and in check mode\n * only reports.\n */\nimport {\n  copyFileSync,\n  cpSync,\n  lstatSync,\n  mkdirSync,\n  readFileSync,\n  readlinkSync,\n  renameSync,\n  rmSync,\n  symlinkSync,\n  unlinkSync,\n} from \"node:fs\";\nimport { basename, dirname, isAbsolute, join, posix, resolve, win32 } from \"node:path\";\nimport type { Harness } from \"./harness.ts\";\nimport { parseJsonc } from \"./mcp-servers.ts\";\nimport { agntnConfigDir, resolvePathTemplate } from \"./resolve.ts\";\nimport type { ResolveOptions } from \"./types.ts\";\n\n/** Configuration read from agents.jsonc. */\nexport interface AgentsConfig {\n  /** The master instructions file every harness links to. */\n  source: string;\n  /** Relative files to link beside every harness instructions target. */\n  companions: string[];\n  /** Harness ids the sync leaves untouched. */\n  excludes: string[];\n  /** Path the config was read from; absent when defaults were used. */\n  configPath?: string;\n}\n\nexport type AgentsSyncAction = \"linked\" | \"relinked\" | \"adopted\" | \"unchanged\" | \"skipped\";\n\n/** One companion file's outcome for a harness target. */\nexport interface AgentsCompanionTargetResult {\n  readonly source: string;\n  readonly path: string;\n  readonly action: Exclude<AgentsSyncAction, \"skipped\">;\n  /** Backup path for an adopted file, or a check-mode note. */\n  readonly detail?: string;\n}\n\n/** One harness's outcome of an agents sync run. */\nexport interface AgentsTargetResult {\n  id: string;\n  path?: string;\n  action: AgentsSyncAction;\n  /** Reason for a skip, or the backup path for an adopted diverged file. */\n  detail?: string;\n  /** Companion outcomes, present when companions are configured. */\n  companions?: readonly AgentsCompanionTargetResult[];\n}\n\n/** Outcome of one agents sync/doctor run. */\nexport interface AgentsSyncReport {\n  source: string;\n  check: boolean;\n  targets: AgentsTargetResult[];\n}\n\nfunction readIfExists(path: string): string | null {\n  try {\n    return readFileSync(path, \"utf8\");\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return null;\n    throw error;\n  }\n}\n\nfunction agentsConfigRecord(raw: string, configPath: string): Record<string, unknown> {\n  const parsed = parseJsonc(raw);\n  if (typeof parsed !== \"object\" || parsed === null) {\n    throw new Error(`Agents config at ${configPath} is not an object`);\n  }\n  return parsed as Record<string, unknown>;\n}\n\nfunction agentsSource(\n  value: unknown,\n  defaultSource: string,\n  options: ResolveOptions,\n  configPath: string,\n): string {\n  if (value === undefined) return defaultSource;\n  if (typeof value !== \"string\" || value.length === 0) {\n    throw new Error(`Agents config at ${configPath} has an invalid source: expected a path string`);\n  }\n  const expanded = resolvePathTemplate(value, options);\n  // A relative source would produce cwd-dependent, dangling links in every\n  // harness, so anchor it to the config directory it was declared in.\n  return isAbsolute(expanded) ? expanded : join(agntnConfigDir(options), expanded);\n}\n\nfunction agentsExcludes(value: unknown, configPath: string): string[] {\n  if (value === undefined) return [];\n  if (!Array.isArray(value) || value.some((item) => typeof item !== \"string\")) {\n    throw new Error(\n      `Agents config at ${configPath} has an invalid excludes: expected an array of harness ids`,\n    );\n  }\n  return value as string[];\n}\n\nfunction companionPath(value: string, configPath: string): string {\n  const normalized = posix.normalize(value.replaceAll(\"\\\\\", \"/\"));\n  if (\n    normalized === \".\" ||\n    normalized === \"..\" ||\n    normalized.startsWith(\"../\") ||\n    posix.isAbsolute(normalized) ||\n    win32.parse(value).root !== \"\"\n  ) {\n    throw new Error(\n      `Agents config at ${configPath} has an unsafe companion path: ${JSON.stringify(normalized)}`,\n    );\n  }\n  return normalized.endsWith(\"/\") ? normalized.slice(0, -1) : normalized;\n}\n\nfunction comparablePath(path: string): string {\n  // Reject lexical and case-only aliases on every platform so one config\n  // remains portable to the case-insensitive filesystems common on Windows\n  // and macOS.\n  return resolve(path).toLowerCase();\n}\n\nfunction agentsCompanions(value: unknown, configPath: string): string[] {\n  if (value === undefined) return [];\n  if (!Array.isArray(value) || value.some((item) => typeof item !== \"string\")) {\n    throw new Error(\n      `Agents config at ${configPath} has invalid companions: expected an array of relative paths`,\n    );\n  }\n\n  const companions = (value as string[]).map((path) => companionPath(path, configPath));\n  const comparable = companions.map(comparablePath);\n  if (new Set(comparable).size !== comparable.length) {\n    throw new Error(`Agents config at ${configPath} has duplicate companion paths`);\n  }\n  return companions;\n}\n\n/**\n * Reads agents.jsonc; missing file falls back to defaults.\n *\n * @param options - Path-resolution overrides.\n * @returns {AgentsConfig} The normalized sync configuration.\n */\nexport function readAgentsConfig(options: ResolveOptions = {}): AgentsConfig {\n  const configPath = join(agntnConfigDir(options), \"agents.jsonc\");\n  const defaults: AgentsConfig = {\n    source: join(agntnConfigDir(options), \"AGENTS.md\"),\n    companions: [],\n    excludes: [],\n  };\n\n  const raw = readIfExists(configPath);\n  if (raw === null) return defaults;\n\n  const record = agentsConfigRecord(raw, configPath);\n  return {\n    source: agentsSource(record.source, defaults.source, options, configPath),\n    companions: agentsCompanions(record.companions, configPath),\n    excludes: agentsExcludes(record.excludes, configPath),\n    configPath,\n  };\n}\n\ntype LinkState =\n  | { readonly kind: \"missing\" }\n  | { readonly kind: \"correct-link\" }\n  | { readonly kind: \"wrong-link\" }\n  | { readonly kind: \"identical-file\" }\n  | { readonly kind: \"diverged-file\" };\n\nfunction inspectRegularFile(path: string, source: string): LinkState {\n  const content = readIfExists(path) ?? \"\";\n  const sourceContent = readIfExists(source) ?? \"\";\n  if (content.trim() === \"\" || content === sourceContent) return { kind: \"identical-file\" };\n  return { kind: \"diverged-file\" };\n}\n\nfunction inspectTarget(path: string, source: string): LinkState {\n  let stats;\n  try {\n    stats = lstatSync(path);\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return { kind: \"missing\" };\n    throw error;\n  }\n\n  if (stats.isSymbolicLink()) {\n    // Compare the literal link target, not realpath: the master path is the\n    // stable interface (it may itself be a link into a versioned backend),\n    // and a harness file linking straight past it would stop following when\n    // the backend behind the master changes.\n    const target = readlinkSync(path);\n    const resolved = isAbsolute(target) ? target : resolve(dirname(path), target);\n    return resolved === source ? { kind: \"correct-link\" } : { kind: \"wrong-link\" };\n  }\n\n  return inspectRegularFile(path, source);\n}\n\n/**\n * Replaces whatever sits at `path` with a symlink to `source`, atomically.\n *\n * @param path - Harness instructions path to replace.\n * @param source - Master instructions path to link.\n */\nfunction relink(path: string, source: string): void {\n  mkdirSync(dirname(path), { recursive: true });\n  const temp = join(dirname(path), `.${Date.now()}-${process.pid}.agents.tmp`);\n  symlinkSync(source, temp);\n  renameSync(temp, path);\n}\n\n/**\n * Moves a regular file or directory, falling back to copy and delete when `to`\n * sits on another filesystem, where a bare rename fails with EXDEV.\n *\n * @param from - File or directory to move.\n * @param to - Destination path.\n */\nexport function moveFile(from: string, to: string): void {\n  try {\n    renameSync(from, to);\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code !== \"EXDEV\") throw error;\n    if (lstatSync(from).isDirectory()) {\n      cpSync(from, to, { recursive: true, verbatimSymlinks: true });\n      rmSync(from, { recursive: true });\n      return;\n    }\n    copyFileSync(from, to);\n    unlinkSync(from);\n  }\n}\n\ntype AgentsFileResult = Omit<AgentsCompanionTargetResult, \"source\">;\n\nconst CHECK_ACTION: Record<LinkState[\"kind\"], AgentsFileResult[\"action\"]> = {\n  missing: \"linked\",\n  \"correct-link\": \"unchanged\",\n  \"wrong-link\": \"relinked\",\n  \"identical-file\": \"relinked\",\n  \"diverged-file\": \"adopted\",\n};\n\nfunction applyFileTarget(\n  id: string,\n  path: string,\n  source: string,\n  state: LinkState,\n  options: ResolveOptions,\n): AgentsFileResult {\n  if (state.kind === \"diverged-file\") {\n    const backupDir = join(agntnConfigDir(options), \"diverged\");\n    mkdirSync(backupDir, { recursive: true });\n    const backup = join(backupDir, `${id}-${basename(path)}-${Date.now()}.md`);\n    moveFile(path, backup);\n    relink(path, source);\n    return { path, action: \"adopted\", detail: backup };\n  }\n\n  if (state.kind === \"wrong-link\") unlinkSync(path);\n  if (state.kind === \"wrong-link\" || state.kind === \"identical-file\") {\n    relink(path, source);\n    return { path, action: \"relinked\" };\n  }\n\n  relink(path, source);\n  return { path, action: \"linked\" };\n}\n\nfunction syncFileTarget(\n  id: string,\n  path: string,\n  source: string,\n  check: boolean,\n  options: ResolveOptions,\n): AgentsFileResult {\n  const state = inspectTarget(path, source);\n  if (state.kind === \"correct-link\") return { path, action: \"unchanged\" };\n  if (check) {\n    return {\n      path,\n      action: CHECK_ACTION[state.kind],\n      detail: \"check mode: not applied\",\n    };\n  }\n  return applyFileTarget(id, path, source, state, options);\n}\n\nfunction syncTarget(\n  harness: Harness,\n  config: AgentsConfig,\n  check: boolean,\n  options: ResolveOptions,\n): AgentsTargetResult {\n  if (config.excludes.includes(harness.id)) {\n    return { id: harness.id, action: \"skipped\", detail: \"excluded by the agents config\" };\n  }\n  if (!harness.agentsFile) {\n    return {\n      id: harness.id,\n      action: \"skipped\",\n      detail: \"no stable user-scope instructions file\",\n    };\n  }\n\n  const path = resolvePathTemplate(harness.agentsFile, options);\n  const target = syncFileTarget(harness.id, path, config.source, check, options);\n  if (config.companions.length === 0) return { id: harness.id, ...target };\n\n  const companions = config.companions.map((relativePath) => {\n    const source = resolve(dirname(config.source), relativePath);\n    const companionPath = resolve(dirname(path), relativePath);\n    return {\n      source,\n      ...syncFileTarget(harness.id, companionPath, source, check, options),\n    };\n  });\n  return { id: harness.id, ...target, companions };\n}\n\nfunction preflightCompanions(\n  harnesses: readonly Harness[],\n  config: AgentsConfig,\n  options: ResolveOptions,\n): void {\n  for (const relativePath of config.companions) {\n    const source = resolve(dirname(config.source), relativePath);\n    if (comparablePath(source) === comparablePath(config.source)) {\n      throw new Error(`Companion path resolves to the master agents file: ${relativePath}`);\n    }\n    if (readIfExists(source) === null) {\n      throw new Error(`No companion agents file at ${source}`);\n    }\n  }\n\n  for (const harness of harnesses) {\n    if (config.excludes.includes(harness.id) || !harness.agentsFile) continue;\n    const path = resolvePathTemplate(harness.agentsFile, options);\n    const collision = config.companions.find(\n      (relativePath) =>\n        comparablePath(resolve(dirname(path), relativePath)) === comparablePath(path),\n    );\n    if (collision !== undefined) {\n      throw new Error(`Companion path collides with ${harness.id} instructions: ${collision}`);\n    }\n  }\n}\n\n/**\n * Links every harness's user-scope instructions file to the master. In check\n * mode nothing is written; the report shows what a real run would do.\n *\n * @param harnesses - Harnesses to inspect or update.\n * @param check - Report intended changes without writing them.\n * @param options - Path-resolution overrides.\n * @returns {AgentsSyncReport} Per-harness synchronization outcomes.\n */\nexport function syncAgentsFiles(\n  harnesses: readonly Harness[],\n  check = false,\n  options: ResolveOptions = {},\n): AgentsSyncReport {\n  const config = readAgentsConfig(options);\n  if (readIfExists(config.source) === null) {\n    throw new Error(`No master agents file at ${config.source}`);\n  }\n  preflightCompanions(harnesses, config, options);\n  return {\n    source: config.source,\n    check,\n    targets: harnesses.map((harness) => syncTarget(harness, config, check, options)),\n  };\n}\n","/**\n * Directory links shared by prompt template and skill synchronization.\n * A harness destination becomes one link to the canonical source directory,\n * so an entry any harness adds or edits lands in the shared source.\n */\nimport { randomUUID } from \"node:crypto\";\nimport {\n  lstatSync,\n  mkdirSync,\n  readdirSync,\n  readlinkSync,\n  realpathSync,\n  renameSync,\n  rmdirSync,\n  symlinkSync,\n  unlinkSync,\n} from \"node:fs\";\nimport { basename, dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport { moveFile } from \"./agents-sync.ts\";\nimport { agntnDataDir } from \"./resolve.ts\";\nimport type { ResolveOptions } from \"./types.ts\";\n\n/** Kind of synchronized directory; names the backup folder under `diverged/`. */\nexport type LinkedDirectoryKind = \"prompts\" | \"skills\";\n\nexport type DirectoryLinkAction = \"linked\" | \"relinked\" | \"adopted\" | \"unchanged\" | \"skipped\";\n\n/** Outcome of linking one harness destination to the source directory. */\nexport interface DirectoryLinkOutcome {\n  readonly action: DirectoryLinkAction;\n  /** Backup path, skip reason, or a check-mode note. */\n  readonly detail?: string;\n}\n\nexport const CHECK_DETAIL = \"check mode: not applied\";\n\nexport function linkTarget(path: string): string {\n  const target = readlinkSync(path);\n  return isAbsolute(target) ? target : resolve(dirname(path), target);\n}\n\nexport function isInsideDirectory(path: string, directory: string): boolean {\n  const remainder = relative(directory, path);\n  return remainder !== \"\" && !remainder.startsWith(\"..\") && !isAbsolute(remainder);\n}\n\nexport function tempPath(path: string, kind: string): string {\n  return join(dirname(path), `.${basename(path)}-${randomUUID()}.${kind}.tmp`);\n}\n\nfunction realDirectory(path: string): string {\n  try {\n    return realpathSync(path);\n  } catch {\n    return resolve(path);\n  }\n}\n\n/**\n * Moves a destination into `diverged/<kind>/<id>` under the agntn data\n * directory. A symlink is recreated there instead of moving its target.\n *\n * @param kind - Synchronized directory kind.\n * @param id - Harness id.\n * @param path - Destination to move away.\n * @param options - Path-resolution overrides.\n * @returns {string} The backup path.\n */\nexport function backupDestination(\n  kind: LinkedDirectoryKind,\n  id: string,\n  path: string,\n  options: ResolveOptions,\n): string {\n  const backupDir = join(agntnDataDir(options), \"diverged\", kind, id);\n  mkdirSync(backupDir, { recursive: true });\n  const backup = join(backupDir, `${basename(path)}-${Date.now()}-${randomUUID()}`);\n  if (lstatSync(path).isSymbolicLink()) {\n    symlinkSync(linkTarget(path), backup);\n    unlinkSync(path);\n    return backup;\n  }\n  moveFile(path, backup);\n  return backup;\n}\n\nfunction linkDirectory(path: string, source: string, kind: LinkedDirectoryKind): void {\n  mkdirSync(dirname(path), { recursive: true });\n  const temp = tempPath(path, `${kind}-link`);\n  // Junctions let Windows link a directory without symlink privileges.\n  symlinkSync(source, temp, \"junction\");\n  renameSync(temp, path);\n}\n\ntype DirectoryState =\n  | {\n      readonly kind:\n        | \"missing\"\n        | \"correct-link\"\n        | \"wrong-link\"\n        | \"local-files\"\n        | \"not-directory\"\n        | \"source\";\n    }\n  | { readonly kind: \"legacy-links\"; readonly entries: readonly string[] };\n\nconst DIRECTORY_ACTION: Record<DirectoryState[\"kind\"], DirectoryLinkAction> = {\n  missing: \"linked\",\n  \"correct-link\": \"unchanged\",\n  \"wrong-link\": \"relinked\",\n  \"legacy-links\": \"relinked\",\n  \"local-files\": \"adopted\",\n  \"not-directory\": \"skipped\",\n  source: \"skipped\",\n};\n\nconst SKIP_DETAIL: Partial<Record<DirectoryState[\"kind\"], string>> = {\n  \"not-directory\": \"destination exists and is not a directory or symlink\",\n  source: \"destination holds the source directory\",\n};\n\nfunction isEntryLink(path: string, sourceDirs: readonly string[]): boolean {\n  if (!lstatSync(path).isSymbolicLink()) return false;\n  const target = linkTarget(path);\n  return sourceDirs.some((directory) => isInsideDirectory(target, directory));\n}\n\n// Relinking a destination the source chain passes through would leave the\n// source pointing at itself.\nfunction linksThrough(sourceDir: string, targetDir: string): boolean {\n  let path = sourceDir;\n  for (let hop = 0; hop < 32; hop++) {\n    if (path === targetDir || isInsideDirectory(path, targetDir)) return true;\n    try {\n      if (!lstatSync(path).isSymbolicLink()) return false;\n    } catch {\n      return false;\n    }\n    path = linkTarget(path);\n  }\n  return false;\n}\n\nfunction inspectDirectory(targetDir: string, sourceDir: string): DirectoryState {\n  let stats;\n  try {\n    stats = lstatSync(targetDir);\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return { kind: \"missing\" };\n    throw error;\n  }\n\n  if (stats.isSymbolicLink()) {\n    if (linkTarget(targetDir) === sourceDir) return { kind: \"correct-link\" };\n    return { kind: linksThrough(sourceDir, targetDir) ? \"source\" : \"wrong-link\" };\n  }\n  if (!stats.isDirectory()) return { kind: \"not-directory\" };\n  return inspectLocalDirectory(targetDir, sourceDir);\n}\n\nfunction inspectLocalDirectory(targetDir: string, sourceDir: string): DirectoryState {\n  // The source may itself be a link into this destination; moving the\n  // destination away would then take the source content with it.\n  const realSource = realDirectory(sourceDir);\n  const realTarget = realpathSync(targetDir);\n  if (realSource === realTarget || isInsideDirectory(realSource, realTarget)) {\n    return { kind: \"source\" };\n  }\n\n  // Per-entry links into the source carry nothing worth a backup.\n  const sourceDirs = realSource === sourceDir ? [sourceDir] : [sourceDir, realSource];\n  const entries = readdirSync(targetDir).map((entry) => join(targetDir, entry));\n  return entries.every((entry) => isEntryLink(entry, sourceDirs))\n    ? { kind: \"legacy-links\", entries }\n    : { kind: \"local-files\" };\n}\n\nfunction clearDirectory(\n  kind: LinkedDirectoryKind,\n  id: string,\n  targetDir: string,\n  state: DirectoryState,\n  options: ResolveOptions,\n): string | undefined {\n  if (state.kind === \"wrong-link\" || state.kind === \"local-files\") {\n    return backupDestination(kind, id, targetDir, options);\n  }\n  if (state.kind === \"legacy-links\") {\n    for (const entry of state.entries) unlinkSync(entry);\n    rmdirSync(targetDir);\n  }\n  return undefined;\n}\n\n/**\n * Makes `targetDir` one link to `sourceDir`. Per-entry links into the source\n * are replaced; a wrong link or local content is backed up first. In check\n * mode nothing is written.\n *\n * @param kind - Synchronized directory kind.\n * @param id - Harness id, used for the backup folder.\n * @param targetDir - Harness destination.\n * @param sourceDir - Canonical source directory.\n * @param check - Report the intended change without writing it.\n * @param options - Path-resolution overrides.\n * @returns {DirectoryLinkOutcome} The action taken or intended.\n */\nexport function syncDirectoryLink(\n  kind: LinkedDirectoryKind,\n  id: string,\n  targetDir: string,\n  sourceDir: string,\n  check: boolean,\n  options: ResolveOptions,\n): DirectoryLinkOutcome {\n  const state = inspectDirectory(targetDir, sourceDir);\n  const action = DIRECTORY_ACTION[state.kind];\n  if (state.kind === \"correct-link\") return { action };\n  const skip = SKIP_DETAIL[state.kind];\n  if (skip !== undefined) return { action, detail: skip };\n  if (check) return { action, detail: CHECK_DETAIL };\n\n  const detail = clearDirectory(kind, id, targetDir, state, options);\n  linkDirectory(targetDir, sourceDir, kind);\n  return { action, detail };\n}\n","import {\n  lstatSync,\n  mkdirSync,\n  readFileSync,\n  readdirSync,\n  renameSync,\n  unlinkSync,\n  writeFileSync,\n} from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { basename, dirname, extname, join, resolve } from \"node:path\";\nimport {\n  CHECK_DETAIL,\n  backupDestination,\n  isInsideDirectory,\n  syncDirectoryLink,\n  tempPath,\n} from \"./directory-link.ts\";\nimport type { Harness } from \"./harness.ts\";\nimport { agntnDataDir } from \"./resolve.ts\";\nimport type { PromptTemplateSyncTarget, ResolveOptions } from \"./types.ts\";\n\nconst GENERATED_MARKER = \"# Generated by @agntn/harnesses from \";\nconst PORTABLE_PROMPT_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/u;\n\nexport type PromptSyncAction =\n  | \"linked\"\n  | \"generated\"\n  | \"relinked\"\n  | \"replaced\"\n  | \"adopted\"\n  | \"removed\"\n  | \"unchanged\"\n  | \"skipped\";\n\n/** One prompt template's outcome at a harness destination. */\nexport interface PromptTemplateTargetResult {\n  readonly name: string;\n  readonly source?: string;\n  readonly path: string;\n  readonly action: PromptSyncAction;\n  /** Backup path, skip reason, or a check-mode note. */\n  readonly detail?: string;\n}\n\n/** One harness's outcome of a prompt template sync run. */\nexport interface PromptSyncTargetResult {\n  readonly id: string;\n  readonly path?: string;\n  readonly format?: PromptTemplateSyncTarget[\"format\"];\n  /** Outcome for a Markdown destination, which is one link to the whole source directory. */\n  readonly action?: PromptSyncAction;\n  /** Backup path, skip reason, or a check-mode note. */\n  readonly detail?: string;\n  readonly templates: readonly PromptTemplateTargetResult[];\n}\n\n/** Outcome of one prompt template sync run. */\nexport interface PromptSyncReport {\n  readonly source: string;\n  readonly check: boolean;\n  readonly templates: readonly string[];\n  readonly targets: readonly PromptSyncTargetResult[];\n}\n\ninterface PromptTemplate {\n  readonly name: string;\n  readonly path: string;\n  readonly content: string;\n  readonly gemini?: string;\n}\n\ntype DestinationState =\n  | { readonly kind: \"missing\" }\n  | { readonly kind: \"owned-file\"; readonly content: string }\n  | { readonly kind: \"unmanaged-file\" }\n  | { readonly kind: \"unsupported\" };\n\nconst GEMINI_ACTION: Record<DestinationState[\"kind\"], PromptSyncAction> = {\n  missing: \"generated\",\n  \"owned-file\": \"replaced\",\n  \"unmanaged-file\": \"adopted\",\n  unsupported: \"skipped\",\n};\n\nconst GEMINI_BACKUP: Record<DestinationState[\"kind\"], boolean> = {\n  missing: false,\n  \"owned-file\": true,\n  \"unmanaged-file\": true,\n  unsupported: false,\n};\n\nfunction readTemplates(sourceDir: string, check: boolean): PromptTemplate[] {\n  let entries;\n  try {\n    entries = readdirSync(sourceDir, { withFileTypes: true });\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n    if (!check) mkdirSync(sourceDir, { recursive: true });\n    return [];\n  }\n\n  const templates = entries\n    .filter(\n      (entry) =>\n        (entry.isFile() || entry.isSymbolicLink()) && extname(entry.name).toLowerCase() === \".md\",\n    )\n    .map((entry) => {\n      const name = basename(entry.name, extname(entry.name));\n      if (!PORTABLE_PROMPT_NAME.test(name)) {\n        throw new TypeError(`Invalid prompt template filename: ${entry.name}`);\n      }\n      const path = join(sourceDir, entry.name);\n      return {\n        name,\n        path,\n        content: readFileSync(path, \"utf8\"),\n      };\n    })\n    .sort((left, right) => left.name.localeCompare(right.name));\n\n  const names = templates.map((template) => template.name.toLowerCase());\n  if (new Set(names).size !== names.length) {\n    throw new Error(`Duplicate prompt template names in ${sourceDir}`);\n  }\n  return templates;\n}\n\nfunction generatedSource(content: string): string | null {\n  const firstLine = content.split(\"\\n\", 1)[0] ?? \"\";\n  if (!firstLine.startsWith(GENERATED_MARKER)) return null;\n  try {\n    const source: unknown = JSON.parse(firstLine.slice(GENERATED_MARKER.length));\n    return typeof source === \"string\" ? source : null;\n  } catch {\n    return null;\n  }\n}\n\nfunction inspectDestination(path: string): DestinationState {\n  let stats;\n  try {\n    stats = lstatSync(path);\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return { kind: \"missing\" };\n    throw error;\n  }\n\n  if (stats.isSymbolicLink()) return { kind: \"unmanaged-file\" };\n  if (!stats.isFile()) return { kind: \"unsupported\" };\n\n  const content = readFileSync(path, \"utf8\");\n  if (generatedSource(content) !== null) return { kind: \"owned-file\", content };\n  return { kind: \"unmanaged-file\" };\n}\n\nfunction writeTemplate(path: string, content: string): void {\n  mkdirSync(dirname(path), { recursive: true });\n  const temp = tempPath(path, \"prompt-write\");\n  writeFileSync(temp, content);\n  renameSync(temp, path);\n}\n\n// yaml is most of the modules a package import loads, and only Gemini's\n// frontmatter needs it. A lazy require keeps the sync API synchronous.\nfunction parseYaml(raw: string): unknown {\n  const load = createRequire(import.meta.url);\n  const yaml = load(\"yaml\") as typeof import(\"yaml\");\n  return yaml.parse(raw);\n}\n\nfunction frontmatterDescription(raw: string, path: string): string | undefined {\n  const frontmatter: unknown = parseYaml(raw);\n  if (frontmatter === null) return undefined;\n  if (typeof frontmatter !== \"object\" || Array.isArray(frontmatter)) {\n    throw new TypeError(`Prompt template frontmatter is not an object: ${path}`);\n  }\n  const description = (frontmatter as Record<string, unknown>).description;\n  if (description !== undefined && typeof description !== \"string\") {\n    throw new TypeError(`Prompt template description is not a string: ${path}`);\n  }\n  return description;\n}\n\nfunction parseMarkdownTemplate(template: PromptTemplate): {\n  readonly description?: string;\n  readonly prompt: string;\n} {\n  const match = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---(?:\\r?\\n|$)/.exec(template.content);\n  if (match === null) return { prompt: template.content.replaceAll(\"$ARGUMENTS\", \"{{args}}\") };\n\n  const description = frontmatterDescription(match[1] ?? \"\", template.path);\n  return {\n    ...(description === undefined ? {} : { description }),\n    prompt: template.content.slice(match[0].length).replaceAll(\"$ARGUMENTS\", \"{{args}}\"),\n  };\n}\nfunction geminiContent(template: PromptTemplate): string {\n  const parsed = parseMarkdownTemplate(template);\n  const fields = [\n    `${GENERATED_MARKER}${JSON.stringify(template.path)}`,\n    ...(parsed.description === undefined\n      ? []\n      : [`description = ${JSON.stringify(parsed.description)}`]),\n    `prompt = ${JSON.stringify(parsed.prompt)}`,\n    \"\",\n  ];\n  return fields.join(\"\\n\");\n}\n\nfunction syncGeminiTemplate(\n  id: string,\n  targetDir: string,\n  template: PromptTemplate,\n  check: boolean,\n  options: ResolveOptions,\n): PromptTemplateTargetResult {\n  const path = join(targetDir, `${template.name}.toml`);\n  const content = template.gemini ?? geminiContent(template);\n  const state = inspectDestination(path);\n  if (state.kind === \"owned-file\" && state.content === content) {\n    return { name: template.name, source: template.path, path, action: \"unchanged\" };\n  }\n  if (state.kind === \"unsupported\") {\n    return {\n      name: template.name,\n      source: template.path,\n      path,\n      action: \"skipped\",\n      detail: \"destination exists and is not a file or symlink\",\n    };\n  }\n\n  const action = GEMINI_ACTION[state.kind];\n  if (check) {\n    return { name: template.name, source: template.path, path, action, detail: CHECK_DETAIL };\n  }\n\n  let detail: string | undefined;\n  if (GEMINI_BACKUP[state.kind]) detail = backupDestination(\"prompts\", id, path, options);\n  writeTemplate(path, content);\n  return { name: template.name, source: template.path, path, action, detail };\n}\n\nfunction staleGeminiSource(path: string, sourceDir: string): string | null {\n  let content: string;\n  try {\n    content = readFileSync(path, \"utf8\");\n  } catch {\n    return null;\n  }\n  const source = generatedSource(content);\n  if (source === null) return null;\n  return isInsideDirectory(source, sourceDir) ? source : null;\n}\n\n// The Gemini directory keeps only commands generated from the source. Stale\n// generated files are deleted; anything else is moved to a backup.\nfunction pruneGeminiTarget(\n  id: string,\n  targetDir: string,\n  sourceDir: string,\n  activeNames: ReadonlySet<string>,\n  check: boolean,\n  options: ResolveOptions,\n): PromptTemplateTargetResult[] {\n  let entries;\n  try {\n    entries = readdirSync(targetDir);\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return [];\n    throw error;\n  }\n\n  return entries\n    .filter((entry) => !activeNames.has(entry))\n    .map((entry): PromptTemplateTargetResult => {\n      const path = join(targetDir, entry);\n      const name = basename(entry, extname(entry));\n      const source = staleGeminiSource(path, sourceDir);\n      if (check) {\n        return {\n          name,\n          ...(source === null ? {} : { source }),\n          path,\n          action: \"removed\",\n          detail: CHECK_DETAIL,\n        };\n      }\n      if (source !== null) {\n        unlinkSync(path);\n        return { name, source, path, action: \"removed\" };\n      }\n      return {\n        name,\n        path,\n        action: \"removed\",\n        detail: backupDestination(\"prompts\", id, path, options),\n      };\n    });\n}\n\nfunction syncTarget(\n  harness: Harness,\n  templates: readonly PromptTemplate[],\n  sourceDir: string,\n  check: boolean,\n  options: ResolveOptions,\n): PromptSyncTargetResult {\n  const target = harness.promptTemplateSyncTarget;\n  if (target === null) {\n    return {\n      id: harness.id,\n      detail: \"no stable user-scope prompt template destination\",\n      templates: [],\n    };\n  }\n\n  const resolved = harness.resolveCandidates([target], options)[0];\n  if (resolved === undefined) {\n    return {\n      id: harness.id,\n      detail: \"prompt template destination is unavailable on this platform\",\n      templates: [],\n    };\n  }\n  // Registry paths end in a separator, which a directory symlink cannot carry.\n  const targetDir = resolve(resolved.path);\n  if (resolved.format === \"markdown\") {\n    return {\n      id: harness.id,\n      path: targetDir,\n      format: resolved.format,\n      ...syncDirectoryLink(\"prompts\", harness.id, targetDir, sourceDir, check, options),\n      templates: [],\n    };\n  }\n\n  const results = templates.map((template) =>\n    syncGeminiTemplate(harness.id, targetDir, template, check, options),\n  );\n  const activeNames = new Set(templates.map((template) => `${template.name}.toml`));\n  results.push(...pruneGeminiTarget(harness.id, targetDir, sourceDir, activeNames, check, options));\n  return {\n    id: harness.id,\n    path: targetDir,\n    format: resolved.format,\n    templates: results,\n  };\n}\n\n/**\n * Synchronizes canonical Markdown prompt templates into each harness's stable\n * user-scope destination. A Markdown harness's destination becomes one symlink\n * to the source directory; Gemini's directory holds only TOML commands\n * generated from it. Anything else found there is backed up first. In check\n * mode nothing is written.\n *\n * @param harnesses - Harnesses to inspect or update.\n * @param check - Report intended changes without writing them.\n * @param options - Path-resolution overrides.\n * @returns {PromptSyncReport} Per-harness synchronization outcomes.\n */\nexport function syncPromptTemplates(\n  harnesses: readonly Harness[],\n  check = false,\n  options: ResolveOptions = {},\n): PromptSyncReport {\n  const source = join(agntnDataDir(options), \"prompts\");\n  const templates = readTemplates(source, check);\n  const prepared = harnesses.some(\n    (harness) => harness.promptTemplateSyncTarget?.format === \"gemini-toml\",\n  )\n    ? templates.map((template) => ({ ...template, gemini: geminiContent(template) }))\n    : templates;\n  return {\n    source,\n    check,\n    templates: prepared.map((template) => template.name),\n    targets: harnesses.map((harness) => syncTarget(harness, prepared, source, check, options)),\n  };\n}\n","import { existsSync, mkdirSync, readdirSync, statSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { syncDirectoryLink } from \"./directory-link.ts\";\nimport type { DirectoryLinkAction } from \"./directory-link.ts\";\nimport type { Harness } from \"./harness.ts\";\nimport { agntnDataDir } from \"./resolve.ts\";\nimport type { ResolveOptions } from \"./types.ts\";\n\nexport type SkillsSyncAction = DirectoryLinkAction;\n\n/** One harness's outcome of a skill sync run. */\nexport interface SkillsSyncTargetResult {\n  readonly id: string;\n  readonly path?: string;\n  readonly action: SkillsSyncAction;\n  /** Backup path, skip reason, or a check-mode note. */\n  readonly detail?: string;\n}\n\n/** Outcome of one skill sync run. */\nexport interface SkillsSyncReport {\n  readonly source: string;\n  readonly check: boolean;\n  /** Source subdirectories that hold a SKILL.md. */\n  readonly skills: readonly string[];\n  readonly targets: readonly SkillsSyncTargetResult[];\n}\n\nfunction readSkills(sourceDir: string, check: boolean): string[] {\n  let entries;\n  try {\n    entries = readdirSync(sourceDir);\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n    if (!check) mkdirSync(sourceDir, { recursive: true });\n    return [];\n  }\n\n  return entries\n    .filter((entry) => {\n      const path = join(sourceDir, entry);\n      try {\n        return statSync(path).isDirectory() && existsSync(join(path, \"SKILL.md\"));\n      } catch {\n        return false;\n      }\n    })\n    .sort((left, right) => left.localeCompare(right));\n}\n\nfunction syncTarget(\n  harness: Harness,\n  sourceDir: string,\n  check: boolean,\n  options: ResolveOptions,\n): SkillsSyncTargetResult {\n  const target = harness.skillsSyncTarget;\n  if (target === null) {\n    return { id: harness.id, action: \"skipped\", detail: \"no stable user-scope skills directory\" };\n  }\n\n  const resolved = harness.resolveCandidates([target], options)[0];\n  if (resolved === undefined) {\n    return {\n      id: harness.id,\n      action: \"skipped\",\n      detail: \"skills directory is unavailable on this platform\",\n    };\n  }\n  // Registry paths end in a separator, which a directory symlink cannot carry.\n  const targetDir = resolve(resolved.path);\n  return {\n    id: harness.id,\n    path: targetDir,\n    ...syncDirectoryLink(\"skills\", harness.id, targetDir, sourceDir, check, options),\n  };\n}\n\n/**\n * Links each harness's user-scope skills directory to the canonical skills\n * directory under the agntn XDG data directory, so a skill added or edited\n * through any harness lands in one place. Per-skill links into the source are\n * replaced; any other content is backed up first. In check mode nothing is\n * written.\n *\n * @param harnesses - Harnesses to inspect or update.\n * @param check - Report intended changes without writing them.\n * @param options - Path-resolution overrides.\n * @returns {SkillsSyncReport} Per-harness synchronization outcomes.\n */\nexport function syncSkills(\n  harnesses: readonly Harness[],\n  check = false,\n  options: ResolveOptions = {},\n): SkillsSyncReport {\n  const source = join(agntnDataDir(options), \"skills\");\n  const skills = readSkills(source, check);\n  return {\n    source,\n    check,\n    skills,\n    targets: harnesses.map((harness) => syncTarget(harness, source, check, options)),\n  };\n}\n"],"mappings":";;;;;;;;;;;AAQA,MAAM,eAAe;AAErB,SAAgB,oBAAoB,UAAkB,UAA0B,CAAC,GAAW;CAC1F,MAAM,UAAU,QAAQ,WAAW,GAAG,QAAQ;CAC9C,MAAM,cAAc,QAAQ,eAAe,QAAQ,IAAI;CAEvD,OAAO,SAAS,WAAW,eAAe,OAAe,SAA6B;EACpF,IAAI,UAAU,mBAAmB,OAAO;EACxC,IAAI,UAAU,aAAa,O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;EACnC;GAAE,MAAM;GAA2B,OAAO;GAAQ,OAAO;EAAW;EACpE;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,MAAM;EACR;EACA;GACE,MAAM;GACN,OAAO;GACP,OAAO;EACT;EACA;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,MAAM;EACR;EACA;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,MAAM;EACR;EACA;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,WAAW,CAAC,OAAO;GACnB,MAAM;EACR;EACA;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,WAAW,CAAC,QAAQ;GACpB,MAAM;EACR;CACF;CACA,WAAyC,CACvC;EACE,MAAM;EACN,OAAO;EACP,OAAO;EACP,MAAM;CACR,GACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;EACP,MAAM;CACR,CACF;CACA,cAA+C,CAC7C;EAAE,QAAQ;EAAQ,OAAO;EAAY,MAAM;CAAiC,GAC5E;EACE,QAAQ;EACR,OAAO;EACP,MAAM;CACR,CACF;CACA,eAAiD;EAC/C;GAAE,MAAM;GAAa,OAAO;GAAW,OAAO;EAAW;EACzD;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,MAAM;EACR;EACA;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,MAAM;EACR;CACF;CACA,SAAqC,CACnC;EAAE,MAAM;EAAmB,OAAO;EAAW,OAAO;CAAW,GAC/D;EACE,MAAM;EACN,OAAO;EACP,OAAO;EACP,MAAM;CACR,CACF;CACA,mBAAkE;EAChE,MAAM;EACN,OAAO;EACP,OAAO;CACT;CACA,WAAyC,CACvC;EACE,MAAM;EACN,OAAO;EACP,OAAO;EACP,MAAM;CACR,GACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;EACP,MAAM;CACR,CACF;CACA,kBAAoC,KAAK;CACzC,2BAAkF;EAChF,MAAM;EACN,OAAO;EACP,OAAO;EACP,QAAQ;CACV;CACA,QAAmC,CACjC;EAAE,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;GACN,OAAO;GACP,OAAO;GACP,MAAM;EACR;EACA;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,MAAM;EACR;EACA;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,MAAM;EACR;CACF;CACA,mBAAkE;EAChE,MAAM;EACN,OAAO;EACP,OAAO;CACT;CACA,WAAyC;EACvC;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,MAAM;EACR;EACA;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,MAAM;EACR;EACA;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,MAAM;EACR;EACA;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,MAAM;EACR;EACA;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,MAAM;EACR;EACA;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,MAAM;EACR;CACF;CACA,kBAAoC,KAAK;CACzC,2BAAkF;EAChF,MAAM;EACN,OAAO;EACP,OAAO;EACP,QAAQ;CACV;CACA,QAAmC,CACjC;EACE,MAAM;EACN,OAAO;EACP,OAAO;CACT,GACA;EACE,MAAM;EACN,OAAO;EACP,OAAO;EACP,MAAM;CACR,CACF;CACA,aAA6C;CAC7C,aAAsD;EACpD;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,QAAQ;GACR,KAAK,CAAC,YAAY;GAClB,SAAS;GACT,MAAM;EACR;EACA;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,QAAQ;GACR,KAAK,CAAC,YAAY;GAClB,SAAS;GACT,MAAM;EACR;EACA;GACE,MAAM;GACN,OAAO;GACP,OAAO;GACP,QAAQ;GACR,KAAK,CAAC,YAAY;GAClB,SAAS;GACT,MAAM;EACR;CACF;CACA,YAAqB;EACnB,SAAS,CAAC;EACV,gBAAgB,CAAC,aAAa;CAChC;AACF;;;AChQA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC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