@ken-jo/agent-connector 0.4.7 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{action-YCU53FNE.js → action-RWPRIZIC.js} +10 -10
- package/dist/{amazon-q-W574ZX35.js → amazon-q-5LJOB5L3.js} +6 -18
- package/dist/amazon-q-5LJOB5L3.js.map +1 -0
- package/dist/{amp-JPBQJJVM.js → amp-PU4LFSY6.js} +16 -48
- package/dist/amp-PU4LFSY6.js.map +1 -0
- package/dist/{antigravity-VK2Y3FGV.js → antigravity-DWW35HZO.js} +6 -5
- package/dist/{antigravity-cli-D4PCCUG2.js → antigravity-cli-VTQ6DNWL.js} +6 -5
- package/dist/{antigravity-cli-D4PCCUG2.js.map → antigravity-cli-VTQ6DNWL.js.map} +1 -1
- package/dist/{chunk-F5RX62T7.js → chunk-7QRUZAUG.js} +2 -2
- package/dist/{chunk-G5CQHVQG.js → chunk-7TVBFRVI.js} +12 -15
- package/dist/chunk-7TVBFRVI.js.map +1 -0
- package/dist/{chunk-CYOAH23F.js → chunk-A2T4Q7RM.js} +18 -18
- package/dist/{chunk-7ECYDK5T.js → chunk-CDVOBKSG.js} +4 -4
- package/dist/{chunk-DT6Y7XBI.js → chunk-CENEXP7K.js} +9 -38
- package/dist/chunk-CENEXP7K.js.map +1 -0
- package/dist/chunk-FBJQGRET.js +38 -0
- package/dist/chunk-FBJQGRET.js.map +1 -0
- package/dist/{chunk-WZA4CSGJ.js → chunk-H53QZQJI.js} +15 -2
- package/dist/chunk-H53QZQJI.js.map +1 -0
- package/dist/{chunk-MDNX7HTN.js → chunk-HOE2MN36.js} +2 -2
- package/dist/{chunk-7L6ITC4T.js → chunk-IEGR4TP3.js} +22 -6
- package/dist/chunk-IEGR4TP3.js.map +1 -0
- package/dist/{chunk-PFDUGDOA.js → chunk-KG6T3YNJ.js} +3 -3
- package/dist/{chunk-YQLQJZ7S.js → chunk-MOW2RKHX.js} +2 -2
- package/dist/{chunk-SDPIT4HW.js → chunk-NYR55UT7.js} +2 -2
- package/dist/{chunk-WFXWJITA.js → chunk-OZ5EXXQV.js} +2 -2
- package/dist/{chunk-I5MLE6S7.js → chunk-TO57WYBB.js} +15 -1
- package/dist/chunk-TO57WYBB.js.map +1 -0
- package/dist/chunk-UM5S7DKK.js +33 -0
- package/dist/chunk-UM5S7DKK.js.map +1 -0
- package/dist/{chunk-6RYPUR6O.js → chunk-VRKTVCYJ.js} +7 -7
- package/dist/{chunk-HAIMYUEY.js → chunk-WI6YSXOC.js} +3 -3
- package/dist/{chunk-2F5QH3D4.js → chunk-XQUUNAGC.js} +36 -36
- package/dist/{chunk-TZQBASI7.js → chunk-YS2NYJ6R.js} +13 -49
- package/dist/chunk-YS2NYJ6R.js.map +1 -0
- package/dist/{chunk-SPWFUHHK.js → chunk-YYISBXOM.js} +7 -7
- package/dist/{claude-code-ROSIILTM.js → claude-code-64X6RR2S.js} +15 -38
- package/dist/claude-code-64X6RR2S.js.map +1 -0
- package/dist/cli/sdk.js +4 -4
- package/dist/cli.js +1 -1
- package/dist/{cline-JUTO4V27.js → cline-T7ZDJYZQ.js} +15 -47
- package/dist/cline-T7ZDJYZQ.js.map +1 -0
- package/dist/{codebuff-2QUHL6HO.js → codebuff-PPPY3SJV.js} +9 -40
- package/dist/codebuff-PPPY3SJV.js.map +1 -0
- package/dist/{codex-YBBTIDD4.js → codex-EEVN43C2.js} +26 -62
- package/dist/codex-EEVN43C2.js.map +1 -0
- package/dist/{continue-W4TU4JSB.js → continue-VLLZO4PM.js} +9 -32
- package/dist/continue-VLLZO4PM.js.map +1 -0
- package/dist/{copilot-cli-Y74SOP5G.js → copilot-cli-A7G5WB4N.js} +15 -64
- package/dist/copilot-cli-A7G5WB4N.js.map +1 -0
- package/dist/{crush-GMEWLXK5.js → crush-AH24GDDB.js} +15 -42
- package/dist/crush-AH24GDDB.js.map +1 -0
- package/dist/{cursor-JBS4B3Q4.js → cursor-GJBSMXI6.js} +13 -51
- package/dist/cursor-GJBSMXI6.js.map +1 -0
- package/dist/{detect-2NIXILMZ.js → detect-YDCZNV4W.js} +4 -4
- package/dist/{doctor-QWJBWALA.js → doctor-DGC7P3P7.js} +13 -12
- package/dist/{doctor-QWJBWALA.js.map → doctor-DGC7P3P7.js.map} +1 -1
- package/dist/{droid-TJMTNCQE.js → droid-RBWCFKL3.js} +17 -40
- package/dist/droid-RBWCFKL3.js.map +1 -0
- package/dist/{gemini-cli-RAONGZRG.js → gemini-cli-CFPFEJEA.js} +15 -63
- package/dist/gemini-cli-CFPFEJEA.js.map +1 -0
- package/dist/{goose-G4KKM6YU.js → goose-UBJVQFUE.js} +18 -54
- package/dist/goose-UBJVQFUE.js.map +1 -0
- package/dist/{hermes-PJDTJE6F.js → hermes-6FXGXLNL.js} +14 -52
- package/dist/hermes-6FXGXLNL.js.map +1 -0
- package/dist/{hook-FDGIQPRC.js → hook-CDGSCASQ.js} +10 -10
- package/dist/index.js +2 -2
- package/dist/{install-TLG3QVP3.js → install-2D3UKEME.js} +13 -12
- package/dist/{install-TLG3QVP3.js.map → install-2D3UKEME.js.map} +1 -1
- package/dist/{jetbrains-copilot-DNXSLQE5.js → jetbrains-copilot-K26KMA3U.js} +10 -37
- package/dist/jetbrains-copilot-K26KMA3U.js.map +1 -0
- package/dist/{kilo-FERJ3X46.js → kilo-BKZJ26RM.js} +26 -90
- package/dist/kilo-BKZJ26RM.js.map +1 -0
- package/dist/{kilo-cli-TDCONH5G.js → kilo-cli-6UVWCXQD.js} +17 -48
- package/dist/kilo-cli-6UVWCXQD.js.map +1 -0
- package/dist/{kimi-RIRD4J5J.js → kimi-QALYPSRR.js} +10 -31
- package/dist/kimi-QALYPSRR.js.map +1 -0
- package/dist/{kiro-X7JVLAN7.js → kiro-J5J42I5Z.js} +10 -31
- package/dist/kiro-J5J42I5Z.js.map +1 -0
- package/dist/{leaderboard-MXGENYXN.js → leaderboard-VZQXNWTX.js} +2 -2
- package/dist/{mimo-code-RFLQ727H.js → mimo-code-BEE622P2.js} +22 -87
- package/dist/mimo-code-BEE622P2.js.map +1 -0
- package/dist/{mux-D77HBSBU.js → mux-5HTNKK4K.js} +9 -39
- package/dist/mux-5HTNKK4K.js.map +1 -0
- package/dist/{nemoclaw-LXUTMR56.js → nemoclaw-DNFIZFDF.js} +5 -5
- package/dist/{omp-CO7IXURG.js → omp-I3UTRBNP.js} +16 -48
- package/dist/omp-I3UTRBNP.js.map +1 -0
- package/dist/{openclaw-XWJLEW35.js → openclaw-QE2LMWIF.js} +5 -5
- package/dist/{opencode-QKZ5EIYU.js → opencode-ZFSUYJXI.js} +22 -88
- package/dist/opencode-ZFSUYJXI.js.map +1 -0
- package/dist/{package-IA56LSC3.js → package-BSCCMW4E.js} +8 -8
- package/dist/{pi-YGBXYWY5.js → pi-H2KBBDDJ.js} +4 -4
- package/dist/{qwen-code-E2MSEZK6.js → qwen-code-5LE34FNE.js} +10 -31
- package/dist/qwen-code-5LE34FNE.js.map +1 -0
- package/dist/{roo-code-AGGJ473T.js → roo-code-XH4GCYIS.js} +15 -52
- package/dist/roo-code-XH4GCYIS.js.map +1 -0
- package/dist/runtime/index.js +8 -8
- package/dist/sdk/index.js +3 -3
- package/dist/sdk/test.js +5 -5
- package/dist/{serve-RNUCK5F7.js → serve-MQNGPY2H.js} +10 -10
- package/dist/{status-JOX6RLJU.js → status-MRHVRDFY.js} +8 -7
- package/dist/{status-JOX6RLJU.js.map → status-MRHVRDFY.js.map} +1 -1
- package/dist/{statusline-ZVFI5DRT.js → statusline-IYWA75TR.js} +9 -9
- package/dist/{telemetry-3FN6HDVU.js → telemetry-IONIOMLC.js} +5 -5
- package/dist/{trae-6L226ZDU.js → trae-RVNRSV7X.js} +10 -39
- package/dist/trae-RVNRSV7X.js.map +1 -0
- package/dist/{uninstall-SCKZYB4J.js → uninstall-ESLSVCLE.js} +13 -12
- package/dist/{uninstall-SCKZYB4J.js.map → uninstall-ESLSVCLE.js.map} +1 -1
- package/dist/{upgrade-WU3KZWR4.js → upgrade-VICY5T64.js} +13 -12
- package/dist/{upgrade-WU3KZWR4.js.map → upgrade-VICY5T64.js.map} +1 -1
- package/dist/{usage-G72SF7JG.js → usage-TCUWV2YZ.js} +2 -2
- package/dist/{usage-event-DHSEBO5T.js → usage-event-CBZZP37Q.js} +9 -9
- package/dist/{vscode-copilot-6EOZDLXC.js → vscode-copilot-B2QBBHJW.js} +15 -65
- package/dist/vscode-copilot-B2QBBHJW.js.map +1 -0
- package/dist/{warp-N5YYN5BF.js → warp-5R54ST3N.js} +7 -19
- package/dist/warp-5R54ST3N.js.map +1 -0
- package/dist/{windsurf-4TGSJIVV.js → windsurf-L32UEOLY.js} +6 -18
- package/dist/windsurf-L32UEOLY.js.map +1 -0
- package/dist/{zed-6P2UFWXU.js → zed-FDJHJZKD.js} +11 -21
- package/dist/zed-FDJHJZKD.js.map +1 -0
- package/package.json +1 -1
- package/dist/amazon-q-W574ZX35.js.map +0 -1
- package/dist/amp-JPBQJJVM.js.map +0 -1
- package/dist/chunk-7L6ITC4T.js.map +0 -1
- package/dist/chunk-DT6Y7XBI.js.map +0 -1
- package/dist/chunk-G5CQHVQG.js.map +0 -1
- package/dist/chunk-I5MLE6S7.js.map +0 -1
- package/dist/chunk-TZQBASI7.js.map +0 -1
- package/dist/chunk-WZA4CSGJ.js.map +0 -1
- package/dist/claude-code-ROSIILTM.js.map +0 -1
- package/dist/cline-JUTO4V27.js.map +0 -1
- package/dist/codebuff-2QUHL6HO.js.map +0 -1
- package/dist/codex-YBBTIDD4.js.map +0 -1
- package/dist/continue-W4TU4JSB.js.map +0 -1
- package/dist/copilot-cli-Y74SOP5G.js.map +0 -1
- package/dist/crush-GMEWLXK5.js.map +0 -1
- package/dist/cursor-JBS4B3Q4.js.map +0 -1
- package/dist/droid-TJMTNCQE.js.map +0 -1
- package/dist/gemini-cli-RAONGZRG.js.map +0 -1
- package/dist/goose-G4KKM6YU.js.map +0 -1
- package/dist/hermes-PJDTJE6F.js.map +0 -1
- package/dist/jetbrains-copilot-DNXSLQE5.js.map +0 -1
- package/dist/kilo-FERJ3X46.js.map +0 -1
- package/dist/kilo-cli-TDCONH5G.js.map +0 -1
- package/dist/kimi-RIRD4J5J.js.map +0 -1
- package/dist/kiro-X7JVLAN7.js.map +0 -1
- package/dist/mimo-code-RFLQ727H.js.map +0 -1
- package/dist/mux-D77HBSBU.js.map +0 -1
- package/dist/omp-CO7IXURG.js.map +0 -1
- package/dist/opencode-QKZ5EIYU.js.map +0 -1
- package/dist/qwen-code-E2MSEZK6.js.map +0 -1
- package/dist/roo-code-AGGJ473T.js.map +0 -1
- package/dist/trae-6L226ZDU.js.map +0 -1
- package/dist/vscode-copilot-6EOZDLXC.js.map +0 -1
- package/dist/warp-N5YYN5BF.js.map +0 -1
- package/dist/windsurf-4TGSJIVV.js.map +0 -1
- package/dist/zed-6P2UFWXU.js.map +0 -1
- /package/dist/{action-YCU53FNE.js.map → action-RWPRIZIC.js.map} +0 -0
- /package/dist/{antigravity-VK2Y3FGV.js.map → antigravity-DWW35HZO.js.map} +0 -0
- /package/dist/{chunk-F5RX62T7.js.map → chunk-7QRUZAUG.js.map} +0 -0
- /package/dist/{chunk-CYOAH23F.js.map → chunk-A2T4Q7RM.js.map} +0 -0
- /package/dist/{chunk-7ECYDK5T.js.map → chunk-CDVOBKSG.js.map} +0 -0
- /package/dist/{chunk-MDNX7HTN.js.map → chunk-HOE2MN36.js.map} +0 -0
- /package/dist/{chunk-PFDUGDOA.js.map → chunk-KG6T3YNJ.js.map} +0 -0
- /package/dist/{chunk-YQLQJZ7S.js.map → chunk-MOW2RKHX.js.map} +0 -0
- /package/dist/{chunk-SDPIT4HW.js.map → chunk-NYR55UT7.js.map} +0 -0
- /package/dist/{chunk-WFXWJITA.js.map → chunk-OZ5EXXQV.js.map} +0 -0
- /package/dist/{chunk-6RYPUR6O.js.map → chunk-VRKTVCYJ.js.map} +0 -0
- /package/dist/{chunk-HAIMYUEY.js.map → chunk-WI6YSXOC.js.map} +0 -0
- /package/dist/{chunk-2F5QH3D4.js.map → chunk-XQUUNAGC.js.map} +0 -0
- /package/dist/{chunk-SPWFUHHK.js.map → chunk-YYISBXOM.js.map} +0 -0
- /package/dist/{detect-2NIXILMZ.js.map → detect-YDCZNV4W.js.map} +0 -0
- /package/dist/{hook-FDGIQPRC.js.map → hook-CDGSCASQ.js.map} +0 -0
- /package/dist/{leaderboard-MXGENYXN.js.map → leaderboard-VZQXNWTX.js.map} +0 -0
- /package/dist/{nemoclaw-LXUTMR56.js.map → nemoclaw-DNFIZFDF.js.map} +0 -0
- /package/dist/{openclaw-XWJLEW35.js.map → openclaw-QE2LMWIF.js.map} +0 -0
- /package/dist/{package-IA56LSC3.js.map → package-BSCCMW4E.js.map} +0 -0
- /package/dist/{pi-YGBXYWY5.js.map → pi-H2KBBDDJ.js.map} +0 -0
- /package/dist/{serve-RNUCK5F7.js.map → serve-MQNGPY2H.js.map} +0 -0
- /package/dist/{statusline-ZVFI5DRT.js.map → statusline-IYWA75TR.js.map} +0 -0
- /package/dist/{telemetry-3FN6HDVU.js.map → telemetry-IONIOMLC.js.map} +0 -0
- /package/dist/{usage-G72SF7JG.js.map → usage-TCUWV2YZ.js.map} +0 -0
- /package/dist/{usage-event-DHSEBO5T.js.map → usage-event-CBZZP37Q.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapters/antigravity/index.ts"],"sourcesContent":["/**\n * adapters/antigravity — Google Antigravity (IDE) platform adapter.\n *\n * Antigravity is a Gemini-family host that, as of the 2.0 line, exposes a real\n * lifecycle-hook system on top of MCP — so this adapter is `json-stdio` (not the\n * old `mcp-only` framing): the host pipes a JSON payload to a hook command on\n * stdin and reads a JSON control object back, the same paradigm as Claude Code /\n * Gemini CLI. It installs the MCP server, lifecycle hooks, slash-command\n * Workflows, and Agent Skills.\n *\n * CONFIRMED-BY-INSTALL (2026-06-03, docs/research/antigravity-paths-confirmed.md):\n * a real machine with Antigravity IDE + `agy` CLI v1.0.0 shows the canonical user\n * customization root is `~/.gemini/antigravity/` — `~/.gemini/antigravity/mcp_config.json`\n * EXISTS and `~/.gemini/config/mcp_config.json` does NOT. So the fresh-install\n * default user MCP path is `~/.gemini/antigravity/mcp_config.json` (candidate[0]);\n * the `config/` and `antigravity-cli/` paths remain probed fallbacks only (honored\n * when a pre-existing config is found there, never the fresh default).\n *\n * STILL MEDIUM-CONFIDENCE / PATH-PROBING: hooks.json and the global skills dir were\n * NOT present on the observed install, so those locations stay corroborated-but-not-\n * byte-verified. Every user-scope path is PROBED at runtime — prefer a candidate\n * that already exists on disk, else fall back to the canonical path — and the doctor\n * flags each probed path with \"verify for your Antigravity version.\" We NEVER\n * hard-code a single guessed path, and any unsupported event or surface warn-skips\n * (never throws) at install time.\n *\n * Native config formats:\n * - MCP config (JSONC; we WRITE plain JSON), root key \"mcpServers\". stdio is\n * `{ command, args, env }`; a remote server is `{ serverUrl, headers }`\n * (NOTE: the key is `serverUrl`, NOT `url` and NOT Gemini CLI's `httpUrl`).\n * user scope → prefer existing of:\n * ~/.gemini/antigravity/mcp_config.json (CONFIRMED canonical)\n * ~/.gemini/config/mcp_config.json (probed fallback)\n * ~/.gemini/antigravity-cli/mcp_config.json (probed fallback)\n * else default to candidate[0] (antigravity/).\n * project scope → <projectDir>/.agents/mcp_config.json\n * - Hooks: a SEPARATE hooks.json in the customization dir (NOT the mcp_config),\n * project → <projectDir>/.agents/hooks.json\n * user → <resolvedUserConfigDir>/hooks.json\n * Shape: { hooks: { <Event>: [ { matcher, hooks:[{ type:\"command\", command }] } ] } }.\n * Supported events: PreToolUse, PostToolUse, SessionStart, Stop. All other\n * normalized events warn-skip. I/O fields are camelCase (see parse/format).\n * - Commands = \"Workflows\": markdown `.md` (body = the prompt; an optional\n * leading description line). Project prefer existing <proj>/.agent/workflows\n * or <proj>/.agents/workflows (default .agent/workflows per launch docs);\n * user ~/.gemini/antigravity/global_workflows.\n * - Skills = Agent Skills (uniform SKILL.md). Project\n * <proj>/.agents/skills/<name>/SKILL.md; user PROBE\n * ~/.gemini/antigravity-cli/skills then ~/.gemini/skills (NEVER\n * ~/.gemini/antigravity/skills — reportedly broken). NOTE: the global skills\n * dir was NOT present on the confirmed install, so it stays medium-confidence\n * + doctor \"verify for your version.\"\n * - Subagents: declarative subagents exist only inside a plugin bundle, which\n * agent-connector does not emit; supportsSubagents is false and the\n * BaseAdapter skip/warn default applies.\n *\n * Env handling: Antigravity (Gemini family) documents no `${env:VAR}` token of\n * the framework's syntax, so env/header/url refs are resolved to literals at\n * install time via resolveEnvRefsDeep — the safe default matching the Gemini CLI\n * adapter.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\nimport { BaseAdapter } from \"../base.js\";\nimport type { Adapter, HookReply, InstallContext, NormalizedEvent } from \"../spi.js\";\nimport type {\n ChangeRecord,\n CommandDef,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n PlatformCapabilities,\n PlatformId,\n PostToolUseEvent,\n PreToolUseEvent,\n ServerDef,\n SessionStartEvent,\n SkillDef,\n StopEvent,\n Transport,\n} from \"../../core/types.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport {\n buildHomeBinHookCommand,\n buildServeWrapperCommand,\n buildUsageEventCommand,\n isHomeBinHookCommand,\n isHostNativeUsageEnabled,\n isUsageEventCommand,\n shouldWrapForTelemetry,\n} from \"../../core/spawn.js\";\n\nconst HOST: PlatformId = \"antigravity\";\nconst MCP_ROOT_KEY = \"mcpServers\";\n\n/**\n * Known user-scope MCP config candidates, in preference order. We pick the first\n * that already exists on disk; otherwise we default to candidate[0]\n * (~/.gemini/antigravity/mcp_config.json — CONFIRMED canonical on a real install:\n * docs/research/antigravity-paths-confirmed.md). The `config/` and CLI-only\n * `antigravity-cli/` paths are kept ONLY as probed fallbacks so a pre-existing\n * config in either is still honored, but neither is ever the fresh-install default.\n */\nconst USER_CONFIG_CANDIDATES = [\n [\".gemini\", \"antigravity\", \"mcp_config.json\"],\n [\".gemini\", \"config\", \"mcp_config.json\"],\n [\".gemini\", \"antigravity-cli\", \"mcp_config.json\"],\n] as const;\n\n/**\n * Antigravity's supported lifecycle hook events. These happen to share the\n * normalized PascalCase names 1:1; everything else has no Antigravity equivalent\n * and is reported as a warn/skip at install time.\n */\nconst SUPPORTED_EVENTS: ReadonlySet<HookEventName> = new Set<HookEventName>([\n \"PreToolUse\",\n \"PostToolUse\",\n \"SessionStart\",\n \"Stop\",\n]);\n\n/**\n * Native hooks.json key for the OPT-IN host-native turn-usage hook (enricher 4a).\n * Antigravity shares the Gemini-family `AfterModel` model-turn hook, whose payload\n * carries `usageMetadata`. This is a host-native-only sink (no connector handler);\n * it is installed ONLY when host-native capture is enabled and records a DISTINCT\n * `model_turn` telemetry row that is never summed with the per-MCP `serve` rows.\n */\nconst USAGE_HOOK_EVENT = \"AfterModel\";\n\n/** A single Antigravity native hook registration entry (nested, Claude-shaped). */\ninterface AntigravityHookEntry {\n matcher: string;\n hooks: Array<{ type: \"command\"; command: string }>;\n}\n\n/** The shape of Antigravity's hooks.json (only the parts we touch). */\ninterface AntigravityHooksFile {\n hooks?: Record<string, AntigravityHookEntry[]>;\n [key: string]: unknown;\n}\n\n/**\n * Native MCP server entry shapes Antigravity accepts under `mcpServers`.\n * A stdio server is `{ command, args, env }`; a remote server is\n * `{ serverUrl, headers }` — the key is `serverUrl` (NOT `url`).\n */\ninterface AntigravityStdioServer {\n command: string;\n args?: string[];\n env?: Record<string, string>;\n}\ninterface AntigravityHttpServer {\n serverUrl: string;\n headers?: Record<string, string>;\n}\n\n/** Raw Antigravity hook stdin payload (camelCase wire fields). */\ninterface AntigravityWireInput {\n connector?: unknown;\n toolName?: string;\n toolInput?: Record<string, unknown>;\n toolOutput?: string;\n isError?: boolean;\n sessionId?: string;\n cwd?: string;\n source?: string;\n reason?: string;\n stopHookActive?: boolean;\n}\n\nexport class AntigravityAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name: string = \"Google Antigravity\";\n readonly paradigm: HookParadigm = \"json-stdio\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: AGENTS.md-first managed block via the BaseAdapter default\n // (memoryTargets: project <projectDir>/AGENTS.md; user scope where documented).\n supportsMemory: true,\n // Antigravity 2.0 fires PreToolUse / PostToolUse / SessionStart / Stop.\n preToolUse: true,\n postToolUse: true,\n sessionStart: true,\n stop: true,\n // No documented equivalents — kept false; the corresponding normalized\n // events warn-skip at install time.\n preCompact: false,\n sessionEnd: false,\n userPromptSubmit: false,\n notification: false,\n // Newer events: no documented permission-dialog, tool-failure, or subagent\n // lifecycle hooks on Antigravity (IDE or `agy` CLI — the CLI adapter\n // inherits this surface), so permissionRequest / postToolUseFailure /\n // subagentStart / subagentStop stay unset — install reports the standard\n // skip-warn for them.\n // Transform-category hooks can rewrite tool input and tool output; the\n // SessionStart hook can inject additional context.\n canModifyArgs: true,\n canModifyOutput: true,\n canInjectSessionContext: true,\n // Antigravity registers stdio, SSE, and Streamable HTTP MCP servers.\n transports: [\"stdio\", \"sse\", \"http\"],\n // Content surfaces: Workflows (markdown commands) + Agent Skills (SKILL.md).\n // Declarative subagents exist only inside a plugin bundle (not emitted), so\n // subagents are unsupported and inherit the BaseAdapter skip/warn default.\n supportsCommands: true,\n supportsSkills: true,\n supportsSubagents: false,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userConfig = this.resolveUserConfigPath();\n const userDir = join(homedir(), \".gemini\");\n const projectConfig = join(projectDir, \".agents\", \"mcp_config.json\");\n\n const userInstalled =\n existsSync(userDir) ||\n this.userConfigCandidates().some((parts) => existsSync(join(homedir(), ...parts)));\n const projInstalled = existsSync(projectConfig);\n const installed = userInstalled || projInstalled;\n\n // Report the scope/path that actually matched, so a project-only install\n // isn't misreported as a (non-existent) user install.\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const configPath = scope === \"project\" ? projectConfig : userConfig;\n\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath,\n scope,\n reason: installed\n ? scope === \"project\"\n ? `found project Antigravity config at ${projectConfig}`\n : `found Antigravity config under ${userDir}`\n : `no Antigravity config at ${userDir} or ${projectConfig}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Native paths ─────────────────────────────────────────────────────────\n\n getConfigDir(ctx: InstallContext): string {\n if (ctx.scope === \"project\") return join(ctx.projectDir, \".agents\");\n // User scope: parent dir of the resolved user mcp_config.json.\n return dirname(this.resolveUserConfigPath());\n }\n\n getServerConfigPath(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".agents\", \"mcp_config.json\")\n : this.resolveUserConfigPath();\n }\n\n /**\n * Hooks live in a SEPARATE hooks.json in the customization dir — NOT the\n * mcp_config.json. Project → <proj>/.agents/hooks.json; user →\n * <resolvedUserConfigDir>/hooks.json (the dir holding the resolved user MCP\n * config). Path is medium-confidence and surfaced by the doctor.\n */\n getHookConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"hooks.json\");\n }\n\n /**\n * The user-scope MCP config candidates, in preference order. Overridable by\n * forks (e.g. the Antigravity CLI) that resolve a different user-scope root\n * while reusing resolveUserConfigPath's prefer-existing-else-candidate[0] logic.\n */\n protected userConfigCandidates(): ReadonlyArray<readonly string[]> {\n return USER_CONFIG_CANDIDATES;\n }\n\n /**\n * Pick the user-scope mcp_config.json: prefer a candidate that already exists,\n * else default to candidate[0] (the CONFIRMED canonical ~/.gemini/antigravity path).\n */\n protected resolveUserConfigPath(): string {\n const home = homedir();\n const candidates = this.userConfigCandidates();\n for (const parts of candidates) {\n const p = join(home, ...parts);\n if (existsSync(p)) return p;\n }\n const fallback = candidates[0];\n if (fallback === undefined) {\n // Defensive: a non-empty candidate list is an invariant, but never throw.\n return join(home, \".gemini\", \"antigravity\", \"mcp_config.json\");\n }\n return join(home, ...fallback);\n }\n\n /**\n * Resolve the Workflows (slash-command) dir, prefer-existing-else-canonical.\n * project → prefer existing <proj>/.agent/workflows or <proj>/.agents/workflows;\n * default .agent/workflows (launch-era singular `.agent`).\n * user → ~/.gemini/antigravity/global_workflows.\n */\n protected resolveWorkflowsDir(ctx: InstallContext): string {\n if (ctx.scope === \"project\") {\n const singular = join(ctx.projectDir, \".agent\", \"workflows\");\n const plural = join(ctx.projectDir, \".agents\", \"workflows\");\n if (existsSync(singular)) return singular;\n if (existsSync(plural)) return plural;\n return singular;\n }\n return join(homedir(), \".gemini\", \"antigravity\", \"global_workflows\");\n }\n\n /**\n * Resolve the Agent Skills dir, prefer-existing-else-canonical.\n * project → <proj>/.agents/skills (plural — matches mcp/skills convention).\n * user → prefer existing ~/.gemini/antigravity-cli/skills, else\n * ~/.gemini/skills. NEVER ~/.gemini/antigravity/skills\n * (reportedly broken), so it is not a candidate.\n */\n protected resolveSkillsDir(ctx: InstallContext): string {\n if (ctx.scope === \"project\") {\n return join(ctx.projectDir, \".agents\", \"skills\");\n }\n const home = homedir();\n const cliSkills = join(home, \".gemini\", \"antigravity-cli\", \"skills\");\n const sharedSkills = join(home, \".gemini\", \"skills\");\n if (existsSync(cliSkills)) return cliSkills;\n if (existsSync(sharedSkills)) return sharedSkills;\n return cliSkills;\n }\n\n // ── MCP server install / uninstall ───────────────────────────────────────\n\n installServer(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n const override = connector.platforms[this.id]?.server;\n if (!connector.server || override === false) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: connector.server\n ? `server registration disabled for ${this.id}`\n : \"connector declares no MCP server\",\n },\n ];\n }\n\n // Shallow-merge any per-platform server override into the base ServerDef.\n const server: ServerDef =\n override && typeof override === \"object\"\n ? { ...connector.server, ...override }\n : connector.server;\n\n const serverPath = this.getServerConfigPath(ctx);\n const entry = this.renderServerEntry(ctx, server);\n\n return [\n this.upsertServerInJson(serverPath, MCP_ROOT_KEY, connector.id, entry, ctx.dryRun),\n ];\n }\n\n uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const serverPath = this.getServerConfigPath(ctx);\n return [\n this.removeServerFromJson(serverPath, MCP_ROOT_KEY, ctx.connector.id, ctx.dryRun),\n ];\n }\n\n /** Render a normalized ServerDef into Antigravity's native mcpServers entry. */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): AntigravityStdioServer | AntigravityHttpServer {\n const transport: Transport = server.transport;\n\n if (transport === \"stdio\") {\n let command = server.command ?? \"\";\n let args = [...(server.args ?? [])];\n\n // Transparent telemetry wrapping: route the real command through\n // `<homeBin> serve --connector <id> --scope <scope> -- <command> <args...>`.\n if (shouldWrapForTelemetry(server, ctx.connector.telemetry)) {\n const wrapped = buildServeWrapperCommand(\n ctx.homeBinPath,\n ctx.connector.id,\n command,\n args,\n ctx.scope,\n this.id,\n );\n command = wrapped.command;\n args = wrapped.args;\n }\n\n // Antigravity (Gemini family) has no documented native interpolation token,\n // so resolve every ${env:VAR} to a literal at install time.\n const entry: AntigravityStdioServer = { command: resolveEnvRefsDeep(command) };\n if (args.length > 0) entry.args = resolveEnvRefsDeep(args);\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n return entry;\n }\n\n // sse / http (and any other remote transport) — Antigravity registers a URL\n // under the `serverUrl` key (NOT `url`).\n const entry: AntigravityHttpServer = { serverUrl: resolveEnvRefsDeep(server.url ?? \"\") };\n const headers = this.renderEnv(server.headers);\n if (headers) entry.headers = headers;\n return entry;\n }\n\n /**\n * Render env/header values. Antigravity documents no native interpolation\n * token, so resolve `${env:VAR}` references to literals at install time.\n */\n private renderEnv(\n env: Record<string, string> | undefined,\n ): Record<string, string> | undefined {\n if (!env || Object.keys(env).length === 0) return undefined;\n return resolveEnvRefsDeep({ ...env });\n }\n\n // ── Hook install / uninstall ─────────────────────────────────────────────\n\n installHooks(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[this.id]?.hooks === false) {\n return [{ platform: this.id, action: \"skip\", detail: `hooks disabled for ${this.id}` }];\n }\n // The opt-in host-native usage hook (4a) needs no connector handler, so it may\n // be installed even when the connector declares no normalized hook events.\n const hostNative = isHostNativeUsageEnabled(connector.telemetry);\n if (connector.hookEvents.length === 0 && !hostNative) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no hooks\" }];\n }\n\n const hooksPath = this.getHookConfigPath(ctx);\n // OVERWRITE GUARD: never clobber a present-but-unparseable hooks.json.\n if (this.isPresentButUnparseable(hooksPath)) {\n return [\n {\n platform: this.id,\n action: \"warn\",\n path: hooksPath,\n detail: `existing ${hooksPath} is not parseable; left untouched (back it up / fix it, then re-run)`,\n },\n ];\n }\n\n const file = this.readJson<AntigravityHooksFile>(hooksPath) ?? {};\n const __skip = this.malformedHookRootSkip(hooksPath, (file as Record<string, unknown>).hooks);\n if (__skip) return [__skip];\n const hooks = (file.hooks ??= {});\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n for (const event of connector.hookEvents) {\n if (!SUPPORTED_EVENTS.has(event)) {\n // No Antigravity equivalent for this normalized event — report.\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: hooksPath,\n detail: `${event} has no Antigravity hook equivalent — skipped`,\n });\n continue;\n }\n\n const command = buildHomeBinHookCommand(ctx.homeBinPath, this.id, event, connector.id);\n const matcher = connector.hooks[event]?.matcher ?? \"\";\n const entry: AntigravityHookEntry = {\n matcher,\n hooks: [{ type: \"command\", command }],\n };\n\n const bucket = (hooks[event] ??= []);\n const existingIdx = bucket.findIndex((e) => this.entryHasOurCommand(e, ctx));\n\n if (existingIdx >= 0) {\n if (JSON.stringify(bucket[existingIdx]) === JSON.stringify(entry)) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: hooksPath,\n detail: `hooks.${event} already registered`,\n });\n continue;\n }\n bucket[existingIdx] = entry;\n changes.push({\n platform: this.id,\n action: \"update\",\n path: hooksPath,\n detail: `hooks.${event}`,\n });\n } else {\n bucket.push(entry);\n changes.push({\n platform: this.id,\n action: \"create\",\n path: hooksPath,\n detail: `hooks.${event}`,\n });\n }\n mutated = true;\n }\n\n // OPT-IN host-native usage hook (4a): register the AfterModel `usage-event`\n // sink when enabled. Records a DISTINCT `model_turn` row (whole-conversation),\n // never summed with the per-MCP `serve`-proxy rows.\n if (hostNative) {\n if (this.installUsageHook(hooks, ctx, hooksPath, changes)) mutated = true;\n }\n\n if (mutated) this.writeJson(hooksPath, file, ctx.dryRun);\n return changes;\n }\n\n /**\n * Register the opt-in AfterModel host-native usage hook (4a) into `hooks`.\n * Idempotent (byte-identical → skip, drift → update); returns true on mutation.\n * The command is the hidden `usage-event` entrypoint (NOT a connector hook), so\n * it carries an empty matcher. Reads `this.id` so the CLI fork installs its own\n * `usage-event antigravity-cli …` variant.\n */\n private installUsageHook(\n hooks: Record<string, AntigravityHookEntry[]>,\n ctx: InstallContext,\n hooksPath: string,\n changes: ChangeRecord[],\n ): boolean {\n const command = buildUsageEventCommand(ctx.homeBinPath, this.id, ctx.connector.id);\n const entry: AntigravityHookEntry = {\n matcher: \"\",\n hooks: [{ type: \"command\", command }],\n };\n const bucket = (hooks[USAGE_HOOK_EVENT] ??= []);\n const existingIdx = bucket.findIndex((e) =>\n (e.hooks ?? []).some((h) => isUsageEventCommand(h.command, ctx.homeBinPath, ctx.connector.id)),\n );\n\n if (existingIdx >= 0) {\n if (JSON.stringify(bucket[existingIdx]) === JSON.stringify(entry)) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: hooksPath,\n detail: `hooks.${USAGE_HOOK_EVENT} (host-native usage) already registered`,\n });\n return false;\n }\n bucket[existingIdx] = entry;\n changes.push({\n platform: this.id,\n action: \"update\",\n path: hooksPath,\n detail: `hooks.${USAGE_HOOK_EVENT} (host-native usage)`,\n });\n } else {\n bucket.push(entry);\n changes.push({\n platform: this.id,\n action: \"create\",\n path: hooksPath,\n detail: `hooks.${USAGE_HOOK_EVENT} (host-native usage)`,\n });\n }\n return true;\n }\n\n uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n const hooksPath = this.getHookConfigPath(ctx);\n const file = this.readJson<AntigravityHooksFile>(hooksPath);\n const hooks = file?.hooks;\n if (!file || !hooks) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: hooksPath,\n detail: \"no hooks section present\",\n },\n ];\n }\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n for (const event of Object.keys(hooks)) {\n const bucket = hooks[event];\n if (!Array.isArray(bucket)) continue;\n\n // Strip our hook command from each entry; drop entries left empty so we\n // never remove another connector's (or the user's own) hook commands.\n const next: AntigravityHookEntry[] = [];\n let removed = 0;\n for (const e of bucket) {\n const innerBefore = e.hooks?.length ?? 0;\n const inner = (e.hooks ?? []).filter((h) => !this.isOurCommand(h.command, ctx));\n removed += innerBefore - inner.length;\n if (inner.length > 0) next.push({ matcher: e.matcher ?? \"\", hooks: inner });\n }\n\n if (removed > 0) {\n if (next.length > 0) hooks[event] = next;\n else delete hooks[event];\n changes.push({\n platform: this.id,\n action: \"remove\",\n path: hooksPath,\n detail: `hooks.${event} (${removed})`,\n });\n mutated = true;\n }\n }\n\n if (mutated) this.writeJson(hooksPath, file, ctx.dryRun);\n if (changes.length === 0) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: hooksPath,\n detail: \"no matching hook entries\",\n });\n }\n return changes;\n }\n\n private entryHasOurCommand(entry: AntigravityHookEntry, ctx: InstallContext): boolean {\n return (entry.hooks ?? []).some((h) => this.isOurCommand(h.command, ctx));\n }\n\n /**\n * True when a hook command is ONE OF OURS for this connector — the universal\n * `hook` dispatcher OR the opt-in `usage-event` sink. Both are anchored on the\n * connector id (see isHomeBinHookCommand) so a shared-prefix id can't collide,\n * and so uninstall reverses the AfterModel usage hook too.\n */\n private isOurCommand(command: string | undefined, ctx: InstallContext): boolean {\n return (\n isHomeBinHookCommand(command, ctx.homeBinPath, ctx.connector.id) ||\n isUsageEventCommand(command, ctx.homeBinPath, ctx.connector.id)\n );\n }\n\n // ── Content surfaces: commands (Workflows) / skills ───────────────────────\n // CONTENT-ONLY: pure native-file writers under the probed workflows / skills\n // dirs. No runtime dispatch, no home-bin pointer, no telemetry wrap. Each\n // method is idempotent (byte-identical → skip) via BaseAdapter.writeContentFile\n // and reversible via removeContentFile. Honors platforms[\"antigravity\"]\n // per-surface false to skip. Commands are markdown Workflows (NOT TOML, unlike\n // gemini-cli); skills are the uniform Claude-compatible SKILL.md. Subagents are\n // unsupported (plugin-bundle-only) and inherit the BaseAdapter skip/warn.\n\n /** Native Workflow file path: <workflowsDir>/<name>.md. */\n private commandPath(ctx: InstallContext, name: string): string {\n return join(this.resolveWorkflowsDir(ctx), `${name}.md`);\n }\n /** Native skill dir: <skillsDir>/<name>. */\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.resolveSkillsDir(ctx), name);\n }\n\n // ── Commands (Workflows) ──────────────────────────────────────────────────\n\n override installCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[this.id]?.commands === false) {\n return [{ platform: this.id, action: \"skip\", detail: `commands disabled for ${this.id}` }];\n }\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.writeContentFile(this.commandPath(ctx, cmd.name), this.renderCommand(cmd), ctx.dryRun),\n );\n }\n\n override uninstallCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.removeContentFile(this.commandPath(ctx, cmd.name), ctx.dryRun),\n );\n }\n\n /**\n * Render a command to an Antigravity Workflow: a plain markdown `.md` whose\n * body is the command prompt, optionally preceded by a leading description\n * line. No frontmatter / TOML (unlike gemini-cli).\n */\n private renderCommand(cmd: CommandDef): string {\n const body = cmd.prompt.endsWith(\"\\n\") ? cmd.prompt : `${cmd.prompt}\\n`;\n if (cmd.description !== undefined && cmd.description !== \"\") {\n return `${cmd.description}\\n\\n${body}`;\n }\n return body;\n }\n\n // ── Skills ────────────────────────────────────────────────────────────────\n\n override installSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[this.id]?.skills === false) {\n return [{ platform: this.id, action: \"skip\", detail: `skills disabled for ${this.id}` }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n changes.push(\n this.writeContentFile(join(dir, \"SKILL.md\"), this.renderSkill(skill), ctx.dryRun),\n );\n // Bundle any resource files beside SKILL.md (relative path → contents).\n // Defense-in-depth: skip+warn on any key that escapes the skill dir.\n for (const [rel, contents] of Object.entries(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `skill resource \"${rel}\" escapes the skill dir; skipped`,\n });\n continue;\n }\n changes.push(this.writeContentFile(target, contents, ctx.dryRun));\n }\n }\n return changes;\n }\n\n override uninstallSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n // Remove only the files we wrote (SKILL.md + declared resources), then the\n // skill dir itself when we own its full contents.\n changes.push(this.removeContentFile(join(dir, \"SKILL.md\"), ctx.dryRun));\n for (const rel of Object.keys(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) continue; // never delete outside the skill dir\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n // Only remove the skill dir when WE own its full contents — never rm -rf a\n // dir that still holds user-added / sibling-tool / shared files.\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n /**\n * Render a skill's SKILL.md: frontmatter (name, description + optional model,\n * allowed-tools, disable-model-invocation) + body. Uniform across platforms.\n */\n private renderSkill(skill: SkillDef): string {\n const frontmatter: Record<string, unknown> = {\n name: skill.name,\n description: skill.description,\n };\n if (skill.model !== undefined) frontmatter.model = skill.model;\n const allow = skill.tools?.allow;\n if (allow && allow.length > 0) frontmatter[\"allowed-tools\"] = allow.join(\", \");\n if (skill.disableModelInvocation !== undefined) {\n frontmatter[\"disable-model-invocation\"] = skill.disableModelInvocation;\n }\n if (skill.extra) Object.assign(frontmatter, skill.extra);\n return this.renderFrontmatterMd(frontmatter, skill.body);\n }\n\n // ── Diagnostics ──────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const mcpPath = this.getServerConfigPath(ctx);\n const hooksPath = this.getHookConfigPath(ctx);\n const connectorId = ctx.connector.id;\n const homeBin = ctx.homeBinPath;\n const hookEvents = ctx.connector.hookEvents;\n const workflowsDir = this.resolveWorkflowsDir(ctx);\n const skillsDir = this.resolveSkillsDir(ctx);\n\n const checks: HealthCheck[] = [\n {\n name: `${this.name}: mcp_config.json present`,\n check: () =>\n existsSync(mcpPath)\n ? { status: \"OK\", detail: `${mcpPath} (path probed; verify for your Antigravity version)` }\n : { status: \"FAIL\", detail: `not found: ${mcpPath} (path probed; verify for your Antigravity version)` },\n },\n {\n name: `${this.name}: server entry registered`,\n check: () => {\n if (!ctx.connector.server) {\n return { status: \"OK\", detail: \"no MCP server declared\" };\n }\n const cfg = this.readJson<{ [k: string]: Record<string, unknown> }>(mcpPath);\n const bucket = cfg?.[MCP_ROOT_KEY];\n if (!cfg || !bucket) {\n return { status: \"FAIL\", detail: `no ${MCP_ROOT_KEY} in ${mcpPath}` };\n }\n return connectorId in bucket\n ? { status: \"OK\", detail: `${MCP_ROOT_KEY}.${connectorId} present` }\n : {\n status: \"FAIL\",\n detail: `no ${MCP_ROOT_KEY}.${connectorId} in ${mcpPath}`,\n };\n },\n },\n {\n name: `${this.name}: hooks.json hook command registered`,\n check: () => {\n if (hookEvents.length === 0) {\n return { status: \"OK\", detail: \"no hooks declared\" };\n }\n const file = this.readJson<AntigravityHooksFile>(hooksPath);\n if (!file) {\n return {\n status: \"FAIL\",\n detail: `not found: ${hooksPath} (path probed; verify for your Antigravity version)`,\n };\n }\n const hooks = file.hooks ?? {};\n const registered = Object.values(hooks).some((entries) =>\n (entries ?? []).some((e) =>\n (e.hooks ?? []).some((h) =>\n isHomeBinHookCommand(h.command, homeBin, connectorId),\n ),\n ),\n );\n return registered\n ? { status: \"OK\", detail: `hook command present in ${hooksPath}` }\n : { status: \"FAIL\", detail: `no hook for ${connectorId} in ${hooksPath}` };\n },\n },\n ];\n\n // Content-surface checks: only assert presence of the files this connector\n // declares (skip silently for surfaces it never asked for). The probed dirs\n // are noted so doctor output makes the medium-confidence path explicit.\n for (const cmd of ctx.connector.commands) {\n const p = join(workflowsDir, `${cmd.name}.md`);\n checks.push({\n name: `${this.name}: workflow ${cmd.name} present`,\n check: () =>\n existsSync(p)\n ? { status: \"OK\", detail: `${p} (workflows dir probed; verify for your version)` }\n : { status: \"FAIL\", detail: `not found: ${p} (workflows dir probed; verify for your version)` },\n });\n }\n for (const skill of ctx.connector.skills) {\n const p = join(skillsDir, skill.name, \"SKILL.md\");\n checks.push({\n name: `${this.name}: skill ${skill.name} present`,\n check: () =>\n existsSync(p)\n ? { status: \"OK\", detail: `${p} (skills dir probed; verify for your version)` }\n : { status: \"FAIL\", detail: `not found: ${p} (skills dir probed; verify for your version)` },\n });\n }\n return checks;\n }\n\n // ── Runtime: parse Antigravity stdin JSON → normalized event ──────────────\n\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as AntigravityWireInput;\n const connectorId = typeof input.connector === \"string\" ? input.connector : \"\";\n const sessionId = typeof input.sessionId === \"string\" ? input.sessionId : \"\";\n const projectDir = typeof input.cwd === \"string\" ? input.cwd : undefined;\n\n const base = {\n hostPlatform: this.id,\n connectorId,\n sessionId,\n raw,\n ...(projectDir !== undefined ? { projectDir } : {}),\n } as const;\n\n switch (event) {\n case \"PreToolUse\": {\n const ev: PreToolUseEvent = {\n ...base,\n toolName: input.toolName ?? \"\",\n toolInput: input.toolInput ?? {},\n };\n return ev;\n }\n case \"PostToolUse\": {\n const ev: PostToolUseEvent = {\n ...base,\n toolName: input.toolName ?? \"\",\n toolInput: input.toolInput ?? {},\n ...(input.toolOutput !== undefined ? { toolOutput: input.toolOutput } : {}),\n ...(input.isError === true ? { isError: true } : {}),\n };\n return ev;\n }\n case \"SessionStart\": {\n const ev: SessionStartEvent = {\n ...base,\n source: normalizeSessionSource(input.source),\n };\n return ev;\n }\n case \"Stop\": {\n const ev: StopEvent = {\n ...base,\n ...(typeof input.stopHookActive === \"boolean\"\n ? { stopHookActive: input.stopHookActive }\n : {}),\n };\n return ev;\n }\n default: {\n // Antigravity only delivers the four SUPPORTED_EVENTS. If the runtime\n // dispatches anything else, surface it loudly rather than mis-parse.\n throw new Error(`unsupported ${this.id} hook event: ${String(event)}`);\n }\n }\n }\n\n // ── Runtime: normalized response → Antigravity native hook reply ──────────\n\n formatReply(event: HookEventName, response: HookResponse): HookReply {\n const decision = response.decision ?? \"allow\";\n\n // deny → Antigravity blocks the action via a top-level `decision:\"deny\"` +\n // reason (the Decide category).\n if (decision === \"deny\") {\n return this.stdout({\n decision: \"deny\",\n reason: response.reason ?? \"Blocked by hook\",\n });\n }\n\n // ask → Antigravity has no native \"ask\"; degrade to deny to stay fail-safe.\n if (decision === \"ask\") {\n return this.stdout({\n decision: \"deny\",\n reason: response.reason ?? \"Action requires user confirmation (security policy)\",\n });\n }\n\n // modify → Transform category. camelCase: rewrite PreToolUse input via\n // updatedInput; rewrite PostToolUse output via updatedOutput.\n if (decision === \"modify\") {\n if (event === \"PreToolUse\" && response.updatedInput) {\n return this.stdout({ updatedInput: response.updatedInput });\n }\n if (event === \"PostToolUse\" && response.updatedOutput !== undefined) {\n return this.stdout({ updatedOutput: response.updatedOutput });\n }\n // Nothing to apply; fall through to allow.\n }\n\n // context → inject soft guidance via additionalContext (the SessionStart\n // context-injection path).\n if (decision === \"context\" && response.additionalContext) {\n return this.stdout({ additionalContext: response.additionalContext });\n }\n\n // allow / void / unsupported-degradation → pass through with exit 0.\n return { exitCode: 0 };\n }\n\n private stdout(payload: unknown): HookReply {\n return { exitCode: 0, stdout: JSON.stringify(payload) };\n }\n}\n\nfunction normalizeSessionSource(source: string | undefined): SessionStartEvent[\"source\"] {\n switch (source) {\n case \"compact\":\n return \"compact\";\n case \"resume\":\n return \"resume\";\n case \"clear\":\n return \"clear\";\n default:\n return \"startup\";\n }\n}\n\nexport const adapter = new AntigravityAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8DA,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY;AAiC9B,IAAM,OAAmB;AACzB,IAAM,eAAe;AAUrB,IAAM,yBAAyB;AAAA,EAC7B,CAAC,WAAW,eAAe,iBAAiB;AAAA,EAC5C,CAAC,WAAW,UAAU,iBAAiB;AAAA,EACvC,CAAC,WAAW,mBAAmB,iBAAiB;AAClD;AAOA,IAAM,mBAA+C,oBAAI,IAAmB;AAAA,EAC1E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AASD,IAAM,mBAAmB;AA2ClB,IAAM,qBAAN,cAAiC,YAA+B;AAAA,EAC5D,KAAiB;AAAA,EACjB,OAAe;AAAA,EACf,WAAyB;AAAA,EAEzB,eAAqC;AAAA;AAAA;AAAA,IAG5C,gBAAgB;AAAA;AAAA,IAEhB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,cAAc;AAAA,IACd,MAAM;AAAA;AAAA;AAAA,IAGN,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQ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aAAO;AAAA,EACX;AACF;AAEO,IAAM,UAAU,IAAI,mBAAmB;AAC9C,IAAO,sBAAQ;","names":["entry"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapters/claude-code/wire.ts"],"sourcesContent":["/**\n * adapters/claude-code/wire — Claude Code hook wire protocol.\n *\n * Claude Code pipes a JSON object to a hook command on stdin and reads a JSON\n * object (or empty) from stdout, interpreting the exit code as well. This module\n * captures the exact stdin shape and the canonical reply shape so the adapter's\n * parse/format methods are a single source of truth.\n *\n * Stdin (documented Claude Code hook input):\n * {\n * session_id, transcript_path, cwd, hook_event_name,\n * tool_name, tool_input, tool_response, // tool events\n * permission_suggestions, // PermissionRequest\n * tool_use_id, error, is_interrupt, duration_ms, // PostToolUseFailure\n * agent_id, agent_type, // SubagentStart/Stop\n * agent_transcript_path, last_assistant_message, // SubagentStop\n * source, // SessionStart\n * reason, // SessionEnd\n * prompt, // UserPromptSubmit\n * trigger, // PreCompact\n * stop_hook_active, // Stop / SubagentStop\n * message // Notification\n * }\n *\n * Stdout (canonical reply): a `hookSpecificOutput` object keyed by\n * `hookEventName`, carrying `permissionDecision` (allow|deny|ask) +\n * `permissionDecisionReason`, `additionalContext`, and (PreToolUse)\n * `updatedInput`; PermissionRequest instead takes a nested\n * `decision: { behavior: \"allow\"|\"deny\", ... }`; Stop-class blocks\n * (Stop / SubagentStop / UserPromptSubmit / PostToolUse) take the TOP-LEVEL\n * `{\"decision\":\"block\",\"reason\"}`. Exit 0 = proceed; the JSON refines the\n * decision.\n */\n\n/** Canonical Claude Code hook event names (the values of `hook_event_name`). */\nexport const CLAUDE_HOOK_EVENTS = [\n \"PreToolUse\",\n \"PostToolUse\",\n \"PreCompact\",\n \"SessionStart\",\n \"SessionEnd\",\n \"UserPromptSubmit\",\n \"Stop\",\n \"Notification\",\n \"PermissionRequest\",\n \"PostToolUseFailure\",\n \"SubagentStart\",\n \"SubagentStop\",\n] as const;\n\nexport type ClaudeHookEvent = (typeof CLAUDE_HOOK_EVENTS)[number];\n\n/**\n * Raw Claude Code hook stdin payload. Every field is optional — a given event\n * only populates the subset relevant to it. `connector` is NOT a Claude field;\n * it is threaded in by the universal entrypoint so parseEvent can recover the\n * connector id (the home binary passes `--connector <id>` and may inject it).\n */\nexport interface ClaudeWireInput {\n session_id?: string;\n transcript_path?: string;\n cwd?: string;\n hook_event_name?: string;\n\n // tool events\n tool_name?: string;\n tool_input?: Record<string, unknown>;\n /** PostToolUse result payload (string or structured). */\n tool_response?: unknown;\n\n // PermissionRequest — permission-update entries the dialog would offer.\n // NOTE: the docs explicitly state PermissionRequest has NO tool_use_id.\n permission_suggestions?: unknown[];\n\n // PostToolUseFailure\n tool_use_id?: string;\n error?: string;\n is_interrupt?: boolean;\n duration_ms?: number;\n\n // SubagentStart / SubagentStop — agent_type is unreliable on SubagentStop\n // (the SDK may not populate it); treat both as optional everywhere.\n agent_id?: string;\n agent_type?: string;\n // SubagentStop — the subagent's OWN transcript (transcript_path stays the\n // parent session's) + the text of its final response.\n agent_transcript_path?: string;\n last_assistant_message?: string;\n\n // SessionStart\n source?: string;\n // SessionEnd\n reason?: string;\n // UserPromptSubmit\n prompt?: string;\n // PreCompact\n trigger?: string;\n // Stop / SubagentStop\n stop_hook_active?: boolean;\n // Notification\n message?: string;\n\n /** Injected by the entrypoint so the runtime knows which connector to dispatch. */\n connector?: string;\n}\n\n/**\n * Extract a stable session id from a Claude wire payload.\n * Priority mirrors the proven adapter: transcript UUID > session_id > \"\".\n * (The framework's normalized event uses \"\" when no id is available, per\n * core/types BaseEvent.sessionId docstring — no ppid fabrication here.)\n */\nexport function extractSessionId(input: ClaudeWireInput): string {\n if (typeof input.transcript_path === \"string\") {\n const m = input.transcript_path.match(/([a-f0-9-]{36})\\.jsonl$/);\n if (m && m[1]) return m[1];\n }\n if (typeof input.session_id === \"string\" && input.session_id !== \"\") {\n return input.session_id;\n }\n return \"\";\n}\n\n/** Coerce a Claude PostToolUse `tool_response` into a string for the normalized event. */\nexport function toolResponseToString(value: unknown): string | undefined {\n if (value == null) return undefined;\n if (typeof value === \"string\") return value;\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n"],"mappings":";;;AAgHO,SAAS,iBAAiB,OAAgC;AAC/D,MAAI,OAAO,MAAM,oBAAoB,UAAU;AAC7C,UAAM,IAAI,MAAM,gBAAgB,MAAM,yBAAyB;AAC/D,QAAI,KAAK,EAAE,CAAC,EAAG,QAAO,EAAE,CAAC;AAAA,EAC3B;AACA,MAAI,OAAO,MAAM,eAAe,YAAY,MAAM,eAAe,IAAI;AACnE,WAAO,MAAM;AAAA,EACf;AACA,SAAO;AACT;AAGO,SAAS,qBAAqB,OAAoC;AACvE,MAAI,SAAS,KAAM,QAAO;AAC1B,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,MAAI;AACF,WAAO,KAAK,UAAU,KAAK;AAAA,EAC7B,QAAQ;AACN,WAAO,OAAO,KAAK;AAAA,EACrB;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapters/claude-code/index.ts"],"sourcesContent":["/**\n * adapters/claude-code — Claude Code platform adapter for agent-connector.\n *\n * Generalized from context-mode's proven 15-platform Claude adapter: the served\n * identity is now `ctx.connector` (not a hardcoded \"context-mode\"), and every\n * hook command points at the single stable home binary\n * (`buildHomeBinHookCommand`) so one framework update propagates everywhere.\n *\n * Claude Code is a json-stdio host:\n * - MCP servers: user scope → ~/.claude.json (\"mcpServers\"); project scope →\n * <projectDir>/.mcp.json (\"mcpServers\").\n * - Hooks: <configDir>/settings.json under \"hooks\", keyed by event name, each\n * value an array of { matcher, hooks:[{ type:\"command\", command }] }.\n * - Reply: a `hookSpecificOutput` object (allow|deny|ask + reason,\n * additionalContext, updatedInput) on stdout with exit 0.\n */\n\nimport { copyFileSync, existsSync, lstatSync, readFileSync, realpathSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { basename, dirname, join } from \"node:path\";\n\nimport { BaseAdapter, type HookMergeDescriptor } from \"../base.js\";\nimport type { Adapter, HookReply, InstallContext, MemoryTarget, NormalizedEvent } from \"../spi.js\";\nimport type {\n ChangeRecord,\n CommandDef,\n ConfigPatchDef,\n DetectedPlatform,\n DiagnosticResult,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n JsonValue,\n NotificationEvent,\n PermissionRequestEvent,\n PlatformCapabilities,\n PlatformId,\n PostCompactEvent,\n PostToolUseEvent,\n PostToolUseFailureEvent,\n PreCompactEvent,\n PreToolUseEvent,\n SessionEndEvent,\n SessionStartEvent,\n ServerDef,\n SkillDef,\n StatuslineContext,\n StopEvent,\n SubagentDef,\n SubagentStartEvent,\n SubagentStopEvent,\n Transport,\n UserPromptSubmitEvent,\n} from \"../../core/types.js\";\nimport { resolveEnvRefsDeep, rewriteEnvRefs } from \"../../core/interpolate.js\";\nimport {\n buildHomeBinStatuslineCommand,\n buildServeWrapperCommand,\n isHomeBinHookCommand,\n isHomeBinStatuslineCommand,\n shouldWrapForTelemetry,\n} from \"../../core/spawn.js\";\nimport {\n type ConfigPatchLedgerEntry,\n addLedgerOwner,\n configPatchManualEdit,\n configPatchNamespaceViolation,\n createLedgerEntry,\n describeJsonValue,\n dropLedgerEntry,\n findLedgerEntry,\n hashJsonValue,\n isValidConfigPatchKey,\n jsonDeepEquals,\n ledgerEntriesOwnedBy,\n loadConfigPatchLedger,\n removeLedgerOwner,\n saveConfigPatchLedger,\n} from \"../../core/config-patch-ledger.js\";\nimport { readRegisteredMeta } from \"../../core/load-connector.js\";\nimport {\n linesOutsideFences,\n listManagedBlocks,\n loadMemoryLedger,\n recordMemoryTarget,\n removeBlocksFromText,\n removeManagedBlocksFile,\n saveMemoryLedger,\n upsertManagedBlockFile,\n} from \"../../core/managed-block.js\";\nimport { backupsDir, ensureDir } from \"../../core/paths.js\";\nimport {\n type ClaudeHookEvent,\n type ClaudeWireInput,\n extractSessionId,\n toolResponseToString,\n} from \"./wire.js\";\nimport { renderCommandMd, renderSkillMd, renderSubagentMd } from \"./render.js\";\n\nconst HOST: PlatformId = \"claude-code\";\nconst MCP_ROOT_KEY = \"mcpServers\";\n\n/**\n * settings.json leaf key the statusline surface owns. Wired through the SAME\n * set-if-absent ownership ledger as configPatch (it is NOT on the configPatch\n * sensitive-key denylist — verified — and is a single top-level leaf), so a\n * non-AC statusLine is never clobbered.\n */\nconst STATUSLINE_KEY = \"statusLine\";\n\n/**\n * Reserved blockId of the SHARED `@AGENTS.md` import bridge in CLAUDE.md\n * (agents-import mode). The `_shared/` prefix cannot collide with a connector\n * blockId (connector ids match ^[a-z0-9][a-z0-9-]*$), and the bridge is\n * refcounted namespace-wide: it is removed only when the LAST agent-connector\n * block leaves the sibling AGENTS.md.\n */\nconst CLAUDE_AGENTS_IMPORT_BLOCK_ID = \"_shared/claude-agents-import\";\n\n/** A single hook registration entry as Claude Code stores it in settings.json. */\ninterface ClaudeHookEntry {\n matcher: string;\n hooks: Array<{ type: \"command\"; command: string }>;\n}\n\n/** Native MCP server entry shapes Claude Code accepts under `mcpServers`. */\ninterface ClaudeStdioServer {\n type: \"stdio\";\n command: string;\n args: string[];\n env?: Record<string, string>;\n cwd?: string;\n}\ninterface ClaudeHttpServer {\n type: \"http\";\n url: string;\n headers?: Record<string, string>;\n}\n\n/**\n * Claude Code statusLine command stdin payload (the documented status-line hook\n * input). Every field optional — a refresh only carries what the host knows.\n * `version` and any unmodeled fields stay in StatuslineContext.raw.\n */\ninterface ClaudeStatuslineInput {\n session_id?: string;\n transcript_path?: string;\n cwd?: string;\n version?: string;\n model?: { id?: string; display_name?: string };\n workspace?: { current_dir?: string; project_dir?: string };\n cost?: { total_cost_usd?: number };\n}\n\nexport class ClaudeCodeAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"Claude Code\";\n readonly paradigm: HookParadigm = \"json-stdio\";\n\n readonly capabilities: PlatformCapabilities = {\n preToolUse: true,\n postToolUse: true,\n preCompact: true,\n sessionStart: true,\n sessionEnd: true,\n userPromptSubmit: true,\n stop: true,\n notification: true,\n // Newer events — Claude Code is the reference host for all four.\n permissionRequest: true,\n postToolUseFailure: true,\n subagentStart: true,\n subagentStop: true,\n // Claude Code can rewrite PreToolUse input (updatedInput) but does NOT let a\n // PostToolUse hook rewrite already-emitted tool output.\n canModifyArgs: true,\n canModifyOutput: false,\n canInjectSessionContext: true,\n // Native passthrough hooks: settings.json hook keys are free-form event\n // names, so any host event (TaskCreated, TeammateIdle, WorktreeCreate, …)\n // declared under platforms[\"claude-code\"].nativeHooks installs verbatim.\n supportsNativeHooks: true,\n // Declarative host-config key patches: claude-code is the ONLY v1 host\n // (set-if-absent leaf keys in settings.json, refcounted ownership ledger,\n // sensitive-key denylist — see SENSITIVE_KEY_RULES below).\n supportsConfigPatch: true,\n // Statusline surface: claude-code is the ONLY v1 host. installStatusline\n // wires settings.json.statusLine = {type:\"command\", command:<home-bin\n // statusline cmd>} through the SAME set-if-absent ownership ledger as\n // configPatch (never clobbers a statusLine agent-connector does not own).\n supportsStatusline: true,\n transports: [\"stdio\", \"http\"],\n // Content surfaces: Claude Code is the reference implementation for all three.\n supportsCommands: true,\n supportsSkills: true,\n supportsSubagents: true,\n // Memory surface — EXCEPTION host: Claude Code reads CLAUDE.md, NOT\n // AGENTS.md (docs are explicit; no AGENTS.md support through v2.1.172), so\n // memoryTargets/installMemory below override the base AGENTS.md default.\n supportsMemory: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userDir = join(homedir(), \".claude\");\n const userSettings = join(userDir, \"settings.json\");\n const userServers = join(homedir(), \".claude.json\");\n const projectServers = join(projectDir, \".mcp.json\");\n const userInstalled =\n existsSync(userDir) || existsSync(userSettings) || existsSync(userServers);\n const projInstalled = existsSync(projectServers);\n const installed = userInstalled || projInstalled;\n // Report the scope/path/reason for the marker that actually matched, so a\n // project-only install isn't misreported as a (non-existent) user install.\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const configPath = scope === \"project\" ? projectServers : userSettings;\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath,\n scope,\n reason: installed\n ? scope === \"project\"\n ? `found project Claude Code config at ${projectServers}`\n : `found Claude Code config under ${userDir}`\n : `no Claude Code config at ${userDir}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Native paths ─────────────────────────────────────────────────────────\n\n getConfigDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".claude\")\n : join(homedir(), \".claude\");\n }\n\n getServerConfigPath(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".mcp.json\")\n : join(homedir(), \".claude.json\");\n }\n\n getHookConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"settings.json\");\n }\n\n // ── MCP server install / uninstall ───────────────────────────────────────\n\n installServer(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n const override = connector.platforms[HOST]?.server;\n if (!connector.server || override === false) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: connector.server\n ? \"server registration disabled for claude-code\"\n : \"connector declares no MCP server\",\n },\n ];\n }\n\n // Shallow-merge any per-platform server override into the base ServerDef.\n const server: ServerDef =\n override && typeof override === \"object\"\n ? { ...connector.server, ...override }\n : connector.server;\n\n const serverPath = this.getServerConfigPath(ctx);\n const entry = this.renderServerEntry(ctx, server);\n\n return [\n this.upsertServerInJson(serverPath, MCP_ROOT_KEY, connector.id, entry, ctx.dryRun),\n ];\n }\n\n uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const serverPath = this.getServerConfigPath(ctx);\n return [\n this.removeServerFromJson(serverPath, MCP_ROOT_KEY, ctx.connector.id, ctx.dryRun),\n ];\n }\n\n /** Render a normalized ServerDef into Claude Code's native mcpServers entry. */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): ClaudeStdioServer | ClaudeHttpServer {\n const transport: Transport = server.transport;\n\n if (transport === \"stdio\") {\n let command = server.command ?? \"\";\n let args = [...(server.args ?? [])];\n\n // Transparent telemetry wrapping: route the real command through\n // `<homeBin> serve --connector <id> -- <command> <args...>`.\n if (shouldWrapForTelemetry(server, ctx.connector.telemetry)) {\n const wrapped = buildServeWrapperCommand(\n ctx.homeBinPath,\n ctx.connector.id,\n command,\n args,\n ctx.scope,\n this.id,\n );\n command = wrapped.command;\n args = wrapped.args;\n }\n\n const entry: ClaudeStdioServer = { type: \"stdio\", command, args };\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n if (server.cwd) entry.cwd = resolveEnvRefsDeep(server.cwd);\n return entry;\n }\n\n // http (and any other remote transport we surface) — Claude registers a URL.\n const entry: ClaudeHttpServer = {\n type: \"http\",\n url: rewriteEnvRefs(server.url ?? \"\", claudeEnvToken),\n };\n if (server.headers) {\n entry.headers = this.renderEnv(server.headers) ?? {};\n }\n return entry;\n }\n\n /**\n * Render env/header values. Claude Code supports its own `${VAR}` native\n * interpolation, so translate `${env:VAR}` refs to that native token rather\n * than baking secrets into the file. Literals pass through unchanged.\n */\n private renderEnv(\n env: Record<string, string> | undefined,\n ): Record<string, string> | undefined {\n if (!env || Object.keys(env).length === 0) return undefined;\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(env)) {\n out[k] = rewriteEnvRefs(v, claudeEnvToken);\n }\n return out;\n }\n\n // ── Hook install / uninstall ─────────────────────────────────────────────\n\n installHooks(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n const override = connector.platforms[HOST];\n\n // `hooks: false` disables only the NORMALIZED hooks. nativeHooks is a\n // sibling, explicitly claude-code-scoped declaration on the same override —\n // it installs regardless (the dev wrote both keys on the same object).\n const normalizedEvents = override?.hooks === false ? [] : connector.hookEvents;\n const nativeHooks = override?.nativeHooks ?? {};\n const nativeEvents = Object.keys(nativeHooks);\n\n if (normalizedEvents.length === 0 && nativeEvents.length === 0) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail:\n override?.hooks === false\n ? \"hooks disabled for claude-code\"\n : \"connector declares no hooks\",\n },\n ];\n }\n\n const settingsPath = this.getHookConfigPath(ctx);\n\n // One pass over normalized + NATIVE events: native event-name keys are\n // written VERBATIM (e.g. \"TaskCreated\"), matcher from the def, and the\n // exact same home-bin command shape — so uninstall/doctor/telemetry treat\n // both identically.\n const pending: Array<{ event: string; matcher: string }> = [\n ...normalizedEvents.map((event) => ({\n event: event as string,\n matcher: connector.hooks[event]?.matcher ?? \"\",\n })),\n ...nativeEvents.map((event) => ({\n event,\n matcher: nativeHooks[event]?.matcher ?? \"\",\n })),\n ];\n\n return this.upsertHookEntries(ctx, settingsPath, pending, this.hookDescriptor());\n }\n\n uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n return this.removeHookEntries(ctx, this.getHookConfigPath(ctx), this.hookDescriptor());\n }\n\n /**\n * Claude's hook-merge descriptor (NESTED shape `{ matcher, hooks: [...] }`):\n * - install find = THIS exact command present in the entry's inner `hooks`;\n * - uninstall = inner-strip ONLY (connector-generic `isOurCommand` over the\n * inner commands, drop entries left empty) — claude never removes a whole\n * entry by ownership, so `ownsEntryForRemove` is a never-true predicate;\n * - every detail string is the literal claude-code wording.\n */\n private hookDescriptor(): HookMergeDescriptor<ClaudeHookEntry> {\n return {\n renderEntry: (_event, matcher, command) => ({\n matcher,\n hooks: [{ type: \"command\", command }],\n }),\n entryOwnsCommand: (entry, command) =>\n (entry.hooks ?? []).some((h) => h.command === command),\n ownsEntryForRemove: () => () => false,\n stripInner: (ctx) => (entry) => {\n const innerBefore = entry.hooks?.length ?? 0;\n const inner = (entry.hooks ?? []).filter((h) => !this.isOurCommand(h.command, ctx));\n return {\n next: inner.length > 0 ? { matcher: entry.matcher ?? \"\", hooks: inner } : null,\n removed: innerBefore - inner.length,\n };\n },\n skipDetail: (event) => `hooks.${event} already registered`,\n removeDetail: (event, removed) => `hooks.${event} (${removed})`,\n absentDetail: \"no hooks section present\",\n noMatchDetail: \"no matching hook entries\",\n };\n }\n\n // ── Declarative host-config key patches (configPatch) ────────────────────\n // FIXED semantics (docs/ARCHITECTURE.md §4): set-if-absent on a single\n // dotted LEAF key of settings.json, skip-warn on ANY conflict (present key,\n // non-object intermediate, drift), refcounted ownership in the persisted\n // ledger at <dataRoot>/state/config-patches.json. Reuses the adapter's\n // existing whole-file settings.json JSON IO (the same handling the hook\n // install performs on this exact file) — Claude Code itself rewrites this\n // file, so format preservation is a non-issue here. NOTE for future hosts:\n // VS Code JSONC needs jsonc-parser modify/applyEdits and Codex TOML needs an\n // anchored edit — core/toml.ts's round-trip is BANNED for configPatch.\n\n /** The ONLY file configPatch may touch on claude-code: settings.json at scope. */\n getPatchableConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"settings.json\");\n }\n\n override installConfigPatches(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n const patches = connector.platforms[HOST]?.configPatch ?? [];\n if (patches.length === 0) {\n return [\n { platform: this.id, action: \"skip\", detail: \"connector declares no configPatch entries\" },\n ];\n }\n return this.applyConfigPatches(ctx, patches);\n }\n\n /**\n * The shared set-if-absent / ownership-ledger apply loop behind BOTH\n * {@link installConfigPatches} and {@link installStatusline}. Routing the\n * statusline through the EXACT same path is how a connector's statusLine\n * inherits the configPatch contract verbatim: never clobber a statusLine\n * agent-connector does not own (skip-warn), record prior state + owner,\n * refcounted across connectors, reversible by uninstallConfigPatches.\n */\n private applyConfigPatches(\n ctx: InstallContext,\n patches: ConfigPatchDef[],\n opts: { surfaceLabel?: \"configPatch\" | \"statusline\" } = {},\n ): ChangeRecord[] {\n // The user-facing surface name in every ChangeRecord.detail. \"statusline\"\n // routes the AC-modeled statusLine key through this loop INTERNALLY — that\n // key is namespace-reserved against raw configPatch, so the internal path\n // bypasses the namespace guard (the surface, not a smuggled patch, owns it).\n const surfaceLabel = opts.surfaceLabel ?? \"configPatch\";\n const internal = surfaceLabel !== \"configPatch\";\n const { connector } = ctx;\n const filePath = this.getPatchableConfigPath(ctx);\n // OVERWRITE GUARD (upsertServerInJson precedent): never round-trip a\n // present-but-unparseable settings file into `{}`.\n if (this.isPresentButUnparseable(filePath)) {\n return [\n {\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail: `existing ${filePath} is not parseable; configPatch left unapplied (back it up / fix it, then re-run)`,\n },\n ];\n }\n const settings = this.readJson<Record<string, unknown>>(filePath) ?? {};\n if (typeof settings !== \"object\" || Array.isArray(settings)) {\n return [\n {\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail: `existing ${filePath} is not a JSON object; configPatch left unapplied`,\n },\n ];\n }\n\n const ledger = loadConfigPatchLedger(ctx.dataRoot);\n const changes: ChangeRecord[] = [];\n let fileMutated = false;\n let ledgerMutated = false;\n\n for (const patch of patches) {\n // Defense in depth: re-validate grammar + AC-namespace here (a connector\n // loaded from raw meta/JSON must not bypass defineConnector's checks).\n if (!isValidConfigPatchKey(patch.key)) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail:\n `configPatch ${JSON.stringify(patch.key)} refused: not a dotted leaf path ` +\n `(segments must match [A-Za-z0-9_-]+; no array indices)`,\n });\n continue;\n }\n // The statusline surface intentionally models the (now namespace-reserved)\n // statusLine key, so its internal patches skip this guard.\n if (!internal) {\n const namespace = configPatchNamespaceViolation(patch.key);\n if (namespace) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `configPatch refused: ${namespace}`,\n });\n continue;\n }\n }\n // SENSITIVE-KEY DENYLIST — hard refuse, no override flag in v1.\n const sensitive = claudeSensitiveKeyViolation(patch.key);\n if (sensitive) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail:\n `configPatch ${patch.key} refused: matches the claude-code sensitive-key ` +\n `denylist (${sensitive}); security-relevant keys are never patched`,\n });\n continue;\n }\n\n // `${env:VAR}` refs resolve at install time, matching server-entry behavior.\n const desired = resolveEnvRefsDeep(patch.value) as JsonValue;\n const segments = patch.key.split(\".\");\n const leaf = readJsonLeaf(settings, segments);\n const entry = findLedgerEntry(ledger, HOST, filePath, patch.key);\n\n if (leaf.kind === \"blocked\") {\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail:\n `${surfaceLabel} ${patch.key} skipped: \"${leaf.atPath}\" exists but is not an ` +\n `object — ${configPatchManualEdit(patch)}`,\n });\n continue;\n }\n\n if (leaf.kind === \"absent\") {\n // SET-IF-ABSENT: the one write path. Intermediates created only as needed.\n writeJsonLeaf(settings, segments, desired);\n fileMutated = true;\n if (entry) {\n // Stale ledger row (key was deleted out from under us): re-assert the\n // value, keep existing owners (they still rely on the key existing),\n // and record what was actually (re)written.\n entry.writtenValue = desired;\n entry.writtenValueHash = hashJsonValue(desired);\n addLedgerOwner(entry, connector.id, connector.version);\n } else {\n createLedgerEntry(ledger, {\n platform: HOST,\n file: filePath,\n key: patch.key,\n value: desired,\n connectorId: connector.id,\n connectorVersion: connector.version,\n });\n }\n ledgerMutated = true;\n changes.push({\n platform: this.id,\n action: \"create\",\n path: filePath,\n detail: `${surfaceLabel} ${patch.key}: <absent> → ${describeJsonValue(desired)} (${patch.reason})`,\n });\n continue;\n }\n\n // Key PRESENT — never overwrite; the only question is ownership/refcount.\n if (!entry) {\n // User- (or other-tool-) owned. No ownership is taken even when values\n // happen to match — uninstall must never delete a key we did not create.\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail:\n `${surfaceLabel} ${patch.key} skipped: already set to ${describeJsonValue(leaf.value)} ` +\n `(not created by agent-connector; desired ${describeJsonValue(desired)}) — ` +\n configPatchManualEdit(patch),\n });\n continue;\n }\n\n if (!jsonDeepEquals(leaf.value, entry.writtenValue)) {\n // DRIFT: the user edited the value after we wrote it. Never revert —\n // sync re-asserts only ABSENT keys.\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail:\n `${surfaceLabel} ${patch.key}: value changed since install ` +\n `(current ${describeJsonValue(leaf.value)}, wrote ${describeJsonValue(entry.writtenValue)}); ` +\n `leaving in place — ${configPatchManualEdit(patch)}`,\n });\n continue;\n }\n\n if (jsonDeepEquals(desired, leaf.value)) {\n // Same value we own: register as co-owner (refcount++) or plain\n // idempotent skip when this connector is already an owner.\n const owners = entry.owners.map((o) => o.connectorId);\n if (addLedgerOwner(entry, connector.id, connector.version)) {\n ledgerMutated = true;\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: filePath,\n detail: `${surfaceLabel} ${patch.key} already installed; registered as co-owner (co-owned with ${owners.join(\", \")})`,\n });\n } else {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: filePath,\n detail: `${surfaceLabel} ${patch.key} already installed`,\n });\n }\n continue;\n }\n\n // FIRST-WRITER-WINS: another connector owns this key with a different value.\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail:\n `${surfaceLabel} ${patch.key} skipped: already owned by ${entry.owners\n .map((o) => o.connectorId)\n .join(\", \")} with a different value ` +\n `(current ${describeJsonValue(leaf.value)}, desired ${describeJsonValue(desired)}) — ` +\n configPatchManualEdit(patch),\n });\n }\n\n if (fileMutated) this.writeJson(filePath, settings, ctx.dryRun);\n if (ledgerMutated && !ctx.dryRun) saveConfigPatchLedger(ctx.dataRoot, ledger);\n return changes;\n }\n\n override uninstallConfigPatches(ctx: InstallContext): ChangeRecord[] {\n const connectorId = ctx.connector.id;\n const ledger = loadConfigPatchLedger(ctx.dataRoot);\n // Keyed off the LEDGER (not the declaration): releases ownership for every\n // file/scope this connector ever patched, even when the uninstall context\n // is a minimal synthetic connector or the scope flag differs from install.\n // EXCLUDE the statusLine key — that surface releases via uninstallStatusline\n // (the installer runs both), so this never double-processes the same row.\n const owned = ledgerEntriesOwnedBy(ledger, HOST, connectorId).filter(\n (e) => e.key !== STATUSLINE_KEY,\n );\n const declared = ctx.connector.platforms[HOST]?.configPatch ?? [];\n const changes: ChangeRecord[] = [];\n\n // Declared patches with NO ownership record anywhere: never delete a key\n // we did not create (rule 1) — explicit skip so the outcome is never silent.\n const ownedKeys = new Set(owned.map((e) => e.key));\n for (const patch of declared) {\n if (!ownedKeys.has(patch.key)) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n detail: `configPatch ${patch.key}: no ownership recorded; left untouched`,\n });\n }\n }\n if (owned.length === 0) return changes;\n changes.push(...this.releaseOwnedConfigPatches(ctx, ledger, owned));\n return changes;\n }\n\n /**\n * The shared last-owner-verified release loop behind BOTH\n * {@link uninstallConfigPatches} and {@link uninstallStatusline}: for each\n * already-selected owned ledger entry, drop this connector's ownership and\n * remove the key ONLY when last-owner ∧ value-unchanged ∧ prior-absent (else\n * skip-warn + leave the key). Saves the ledger when it mutated.\n */\n private releaseOwnedConfigPatches(\n ctx: InstallContext,\n ledger: ReturnType<typeof loadConfigPatchLedger>,\n owned: ConfigPatchLedgerEntry[],\n opts: { surfaceLabel?: \"configPatch\" | \"statusline\" } = {},\n ): ChangeRecord[] {\n const surfaceLabel = opts.surfaceLabel ?? \"configPatch\";\n const connectorId = ctx.connector.id;\n const changes: ChangeRecord[] = [];\n let ledgerMutated = false;\n const backedUp = new Set<string>();\n\n // Group by file (entries may span scopes/files).\n const byFile = new Map<string, ConfigPatchLedgerEntry[]>();\n for (const entry of owned) {\n const bucket = byFile.get(entry.file) ?? [];\n bucket.push(entry);\n byFile.set(entry.file, bucket);\n }\n\n for (const [filePath, entries] of byFile) {\n const unparseable = this.isPresentButUnparseable(filePath);\n const settings = unparseable\n ? null\n : this.readJson<Record<string, unknown>>(filePath);\n let fileMutated = false;\n\n for (const entry of entries) {\n const { lastOwner } = removeLedgerOwner(entry, connectorId);\n ledgerMutated = true;\n\n if (!lastOwner) {\n // The shared-flag case: A uninstalls, B still relies on the key.\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: filePath,\n detail: `${surfaceLabel} ${entry.key} retained: still owned by ${entry.owners\n .map((o) => o.connectorId)\n .join(\", \")}`,\n });\n continue;\n }\n\n // Last owner out → the ledger row is dropped on every branch below;\n // the KEY is removed only on the fully-verified branch.\n dropLedgerEntry(ledger, entry);\n\n if (unparseable) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail: `${surfaceLabel} ${entry.key}: ${filePath} is not parseable; key left in place (ownership released)`,\n });\n continue;\n }\n if (!settings || typeof settings !== \"object\" || Array.isArray(settings)) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: filePath,\n detail: `${surfaceLabel} ${entry.key} already absent (no settings file); ownership record dropped`,\n });\n continue;\n }\n const leaf = readJsonLeaf(settings, entry.key.split(\".\"));\n if (leaf.kind !== \"present\") {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: filePath,\n detail: `${surfaceLabel} ${entry.key} already absent; ownership record dropped`,\n });\n continue;\n }\n if (entry.prior?.present !== false || !jsonDeepEquals(leaf.value, entry.writtenValue)) {\n // User edited the value after install (or the row predates the\n // set-if-absent guarantee): deleting would clobber them. Leave it.\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: filePath,\n detail:\n `${surfaceLabel} ${entry.key}: value changed since install ` +\n `(current ${describeJsonValue(leaf.value)}, wrote ${describeJsonValue(entry.writtenValue)}); ` +\n `left in place`,\n });\n continue;\n }\n\n // VERIFIED: last owner + current === writtenValue + prior was absent.\n // Back up the exact file before its first mutation, then delete the\n // leaf key (intermediate objects we created are left in place).\n if (!ctx.dryRun && !backedUp.has(filePath) && existsSync(filePath)) {\n const backup = this.backupFileForConfigPatch(filePath);\n backedUp.add(filePath);\n if (backup) {\n changes.push({\n platform: this.id,\n action: \"create\",\n path: backup,\n detail: \"backed up settings before configPatch removal\",\n });\n }\n }\n deleteJsonLeaf(settings, entry.key.split(\".\"));\n fileMutated = true;\n changes.push({\n platform: this.id,\n action: \"remove\",\n path: filePath,\n detail: `${surfaceLabel} ${entry.key} removed (was ${describeJsonValue(entry.writtenValue)})`,\n });\n }\n\n if (fileMutated && settings) this.writeJson(filePath, settings, ctx.dryRun);\n }\n\n if (ledgerMutated && !ctx.dryRun) saveConfigPatchLedger(ctx.dataRoot, ledger);\n return changes;\n }\n\n // ── Statusline surface (a HUD/status line) ────────────────────────────────\n // Wires settings.json.statusLine = { type:\"command\", command:<home-bin\n // statusline cmd> } through the SAME ownership ledger as configPatch: a\n // synthetic ConfigPatchDef routed through applyConfigPatches, so the statusLine\n // inherits the full set-if-absent contract verbatim — never clobbers a\n // statusLine agent-connector does not own (skip-warn), records prior state +\n // owner, reversible. The home-bin command makes the host exec\n // `<homeBin> statusline claude-code --connector <id>` for every status refresh,\n // which re-imports the connector module and renders the line (runtime/\n // statusline-entrypoint). No telemetry in v1.\n\n /** The synthetic statusLine configPatch this connector would write. */\n private statuslineConfigPatch(ctx: InstallContext): ConfigPatchDef {\n const command = buildHomeBinStatuslineCommand(ctx.homeBinPath, HOST, ctx.connector.id);\n return {\n key: STATUSLINE_KEY,\n value: { type: \"command\", command },\n reason: \"agent-connector statusline surface\",\n };\n }\n\n override installStatusline(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.statusline == null) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no statusline\" }];\n }\n if (connector.platforms[HOST]?.statusline === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"statusline disabled for claude-code\" }];\n }\n // Reuse the configPatch apply path (set-if-absent, ownership ledger, skip-warn\n // on any non-AC statusLine). This is the SAME machinery installConfigPatches\n // uses on this exact file, so the ownership semantics are identical — only the\n // surface LABEL differs (statusLine is namespace-reserved against raw\n // configPatch; this internal path bypasses that guard and owns the key).\n return this.applyConfigPatches(ctx, [this.statuslineConfigPatch(ctx)], {\n surfaceLabel: \"statusline\",\n });\n }\n\n override uninstallStatusline(ctx: InstallContext): ChangeRecord[] {\n const ledger = loadConfigPatchLedger(ctx.dataRoot);\n // Release ONLY the statusLine ledger row this connector owns (keyed off the\n // ledger, not the declaration, so an id-only synthetic uninstall still\n // reclaims it). Same last-owner-verified delete as uninstallConfigPatches.\n const owned = ledgerEntriesOwnedBy(ledger, HOST, ctx.connector.id).filter(\n (e) => e.key === STATUSLINE_KEY,\n );\n if (owned.length === 0) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: \"statusline: no ownership recorded; left untouched\",\n },\n ];\n }\n return this.releaseOwnedConfigPatches(ctx, ledger, owned, {\n surfaceLabel: \"statusline\",\n });\n }\n\n /**\n * Parse Claude Code's statusLine stdin JSON into the normalized\n * {@link StatuslineContext}. Claude pipes a JSON object to the statusLine\n * command on stdin (model, workspace, cost, etc.); fields the payload omits\n * stay undefined. `raw` keeps the verbatim payload (incl. `version`).\n */\n parseStatusInput(raw: unknown): StatuslineContext {\n const input = (raw ?? {}) as ClaudeStatuslineInput;\n const model: { id?: string; displayName?: string } = {};\n if (typeof input.model?.id === \"string\") model.id = input.model.id;\n if (typeof input.model?.display_name === \"string\") {\n model.displayName = input.model.display_name;\n }\n const cwd =\n typeof input.cwd === \"string\"\n ? input.cwd\n : typeof input.workspace?.current_dir === \"string\"\n ? input.workspace.current_dir\n : undefined;\n\n const ctx: StatuslineContext = {\n host: HOST,\n capabilities: this.capabilities,\n raw,\n };\n if (typeof input.session_id === \"string\" && input.session_id !== \"\") {\n ctx.sessionId = input.session_id;\n }\n if (cwd !== undefined) ctx.cwd = cwd;\n if (model.id !== undefined || model.displayName !== undefined) ctx.model = model;\n if (typeof input.cost?.total_cost_usd === \"number\") {\n ctx.cost = { totalUsd: input.cost.total_cost_usd };\n }\n if (typeof input.transcript_path === \"string\") {\n ctx.transcriptPath = input.transcript_path;\n }\n return ctx;\n }\n\n /** Format the rendered status line into Claude's native reply: stdout = line, exit 0. */\n formatStatusOutput(rendered: string): HookReply {\n return { exitCode: 0, stdout: rendered };\n }\n\n /**\n * Back up ONE exact file (the ledger-recorded patch target, which may belong\n * to a different scope than the current ctx) into the standard backups dir.\n * Best-effort: a failed copy returns null and the caller proceeds — the\n * removal is already value-verified.\n */\n private backupFileForConfigPatch(filePath: string): string | null {\n try {\n ensureDir(backupsDir());\n const stamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n const dest = join(backupsDir(), `${this.id}-${stamp}-${basename(filePath)}`);\n copyFileSync(filePath, dest);\n return dest;\n } catch {\n return null;\n }\n }\n\n /**\n * Doctor: per-ledger-entry configPatch state for this connector —\n * ok → key present and still exactly what we wrote;\n * drifted → user changed the value (we print the manual edit, NEVER\n * auto-fix — sync re-asserts only absent keys);\n * missing → key deleted by the user; sync will re-assert it;\n * orphaned → ledger row whose owners' connector records are all gone.\n * Plus a re-print of the manual edit for declared patches that hold no\n * ownership (skipped at install).\n */\n private configPatchDiagnostics(ctx: InstallContext): DiagnosticResult[] {\n const results: DiagnosticResult[] = [];\n const ledger = loadConfigPatchLedger(ctx.dataRoot);\n const connectorId = ctx.connector.id;\n // EXCLUDE the statusLine row: it is owned by the statusline surface and gets\n // its own dedicated health check in getHealthChecks. Reporting it here too\n // would double-report the key and (on a user edit) print a bogus configPatch\n // \"drifted\" hint to restore a configPatch the connector never declared.\n const platformEntries = ledger.entries.filter(\n (e) => e.platform === this.id && e.key !== STATUSLINE_KEY,\n );\n\n for (const entry of platformEntries) {\n const ownedByThis = entry.owners.some((o) => o.connectorId === connectorId);\n if (!ownedByThis) {\n // ORPHAN check (global hygiene): every owner's connector record is gone.\n const orphaned =\n entry.owners.length === 0 ||\n entry.owners.every((o) => readRegisteredMeta(o.connectorId) === null);\n if (orphaned) {\n results.push({\n check: `${this.name}: configPatch ${entry.key}`,\n status: \"warn\",\n message:\n `orphaned ledger entry in ${entry.file}: owning connector record(s) ` +\n `gone (${entry.owners.map((o) => o.connectorId).join(\", \") || \"none\"})`,\n fix:\n `re-run \\`agent-connector uninstall <owner-id>\\` to release it, or remove ` +\n `${entry.key} from ${entry.file} manually`,\n });\n }\n continue;\n }\n\n const state = this.configPatchState(entry);\n if (state.kind === \"ok\") {\n results.push({\n check: `${this.name}: configPatch ${entry.key}`,\n status: \"pass\",\n message: `ok — ${entry.key} = ${describeJsonValue(entry.writtenValue)} (${entry.file})`,\n });\n } else if (state.kind === \"missing\") {\n results.push({\n check: `${this.name}: configPatch ${entry.key}`,\n status: \"warn\",\n message: `missing — key deleted from ${entry.file} since install`,\n fix: `agent-connector install (sync) will re-assert it`,\n fixable: true,\n });\n } else {\n results.push({\n check: `${this.name}: configPatch ${entry.key}`,\n status: \"warn\",\n message:\n `drifted — value changed since install (current ${describeJsonValue(state.current)}, ` +\n `wrote ${describeJsonValue(entry.writtenValue)}); never auto-fixed`,\n fix: `manual edit if wanted: set ${entry.key} = ${describeJsonValue(entry.writtenValue)} in ${entry.file}`,\n });\n }\n }\n\n // Declared-but-unowned patches: re-print the manual edit (the patch was\n // skipped at install — conflict, denylist, or simply not installed yet).\n const declared = ctx.connector.platforms[HOST]?.configPatch ?? [];\n const ownedKeys = new Set(\n ledgerEntriesOwnedBy(ledger, HOST, connectorId).map((e) => e.key),\n );\n for (const patch of declared) {\n if (ownedKeys.has(patch.key)) continue;\n results.push({\n check: `${this.name}: configPatch ${patch.key}`,\n status: \"warn\",\n message: `declared but not owned (skipped at install or not yet installed)`,\n fix: configPatchManualEdit(patch),\n });\n }\n return results;\n }\n\n /** Current on-disk state of one owned ledger entry. */\n private configPatchState(\n entry: ConfigPatchLedgerEntry,\n ): { kind: \"ok\" } | { kind: \"missing\" } | { kind: \"drifted\"; current: JsonValue } {\n const settings = this.readJson<Record<string, unknown>>(entry.file);\n if (!settings || typeof settings !== \"object\" || Array.isArray(settings)) {\n return { kind: \"missing\" };\n }\n const leaf = readJsonLeaf(settings, entry.key.split(\".\"));\n if (leaf.kind !== \"present\") return { kind: \"missing\" };\n if (jsonDeepEquals(leaf.value, entry.writtenValue)) return { kind: \"ok\" };\n return { kind: \"drifted\", current: leaf.value };\n }\n\n override doctor(ctx: InstallContext): DiagnosticResult[] {\n const results = super.doctor(ctx);\n results.push(...this.configPatchDiagnostics(ctx));\n return results;\n }\n\n // ── Content surfaces: commands / skills / subagents ──────────────────────\n // CONTENT-ONLY: pure native-file writers under <configDir>/{commands,skills,\n // agents}. No runtime dispatch, no home-bin pointer, no telemetry wrap. Each\n // method is idempotent (byte-identical → skip) via BaseAdapter.writeContentFile\n // and reversible via removeContentFile. Honors platforms[\"claude-code\"]\n // per-surface false to skip.\n\n private commandsDir(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"commands\");\n }\n private skillsDir(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"skills\");\n }\n private agentsDir(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"agents\");\n }\n\n /** Native command file path: <configDir>/commands/<name>.md. */\n private commandPath(ctx: InstallContext, name: string): string {\n return join(this.commandsDir(ctx), `${name}.md`);\n }\n /** Native skill dir: <configDir>/skills/<name>. */\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.skillsDir(ctx), name);\n }\n /** Native subagent file path: <configDir>/agents/<name>.md. */\n private subagentPath(ctx: InstallContext, name: string): string {\n return join(this.agentsDir(ctx), `${name}.md`);\n }\n\n // ── Commands ──────────────────────────────────────────────────────────────\n\n override installCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.commands === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"commands disabled for claude-code\" }];\n }\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.writeContentFile(\n this.commandPath(ctx, cmd.name),\n this.renderCommand(cmd),\n ctx.dryRun,\n ),\n );\n }\n\n override uninstallCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.removeContentFile(this.commandPath(ctx, cmd.name), ctx.dryRun),\n );\n }\n\n /** Render a command to md+frontmatter (delegates to the shared renderer). */\n private renderCommand(cmd: CommandDef): string {\n return renderCommandMd(cmd);\n }\n\n // ── Skills ────────────────────────────────────────────────────────────────\n\n override installSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.skills === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"skills disabled for claude-code\" }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n changes.push(\n this.writeContentFile(join(dir, \"SKILL.md\"), this.renderSkill(skill), ctx.dryRun),\n );\n // Bundle any resource files beside SKILL.md (relative path → contents).\n // Defense-in-depth: skip+warn on any key that escapes the skill dir\n // (config-time validation already rejects these, but never trust input).\n for (const [rel, contents] of Object.entries(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `skill resource \"${rel}\" escapes the skill dir; skipped`,\n });\n continue;\n }\n changes.push(this.writeContentFile(target, contents, ctx.dryRun));\n }\n }\n return changes;\n }\n\n override uninstallSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n // Remove only the files we wrote (SKILL.md + declared resources), then the\n // skill dir itself when we own its full contents.\n changes.push(this.removeContentFile(join(dir, \"SKILL.md\"), ctx.dryRun));\n for (const rel of Object.keys(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) continue; // never delete outside the skill dir\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n // Only remove the skill dir when WE own its full contents — never rm -rf a\n // dir that still holds user-added / sibling-tool / shared files.\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n /** Render a skill's SKILL.md (delegates to the shared renderer). */\n private renderSkill(skill: SkillDef): string {\n return renderSkillMd(skill);\n }\n\n // ── Subagents ───────────────────────────────────────────────────────────────\n\n override installSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.subagents === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"subagents disabled for claude-code\" }];\n }\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n return connector.subagents.map((agent) =>\n this.writeContentFile(\n this.subagentPath(ctx, agent.name),\n this.renderSubagent(agent),\n ctx.dryRun,\n ),\n );\n }\n\n override uninstallSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n return connector.subagents.map((agent) =>\n this.removeContentFile(this.subagentPath(ctx, agent.name), ctx.dryRun),\n );\n }\n\n /** Render a subagent to md+frontmatter (delegates to the shared renderer). */\n private renderSubagent(agent: SubagentDef): string {\n return renderSubagentMd(agent);\n }\n\n // ── Memory surface: CLAUDE.md managed block + AGENTS.md interop ────────────\n // EXCEPTION host. Claude Code reads CLAUDE.md, NOT AGENTS.md (docs verbatim:\n // \"Claude Code reads CLAUDE.md, not AGENTS.md\"; no AGENTS.md support through\n // v2.1.172), so the base AGENTS.md-first default is overridden:\n // - mode \"block\" (default): the managed block goes straight into CLAUDE.md.\n // HTML-comment markers are CORRECT here — Claude strips HTML comments\n // from CLAUDE.md before context injection, so the markers and the\n // do-not-edit notice are INVISIBLE to the model while remaining fully\n // parseable by us for sync/doctor/uninstall.\n // - mode \"agents-import\" (opt-in via platforms[\"claude-code\"].memory.mode):\n // canonical block goes into AGENTS.md, plus a SHARED `@AGENTS.md` import\n // bridge block in CLAUDE.md (Anthropic's documented interop). Opt-in\n // because the import makes Claude read the ENTIRE AGENTS.md — a behavior\n // change agent-connector must not make silently.\n // - AUTO interop: when CLAUDE.md ALREADY imports `@AGENTS.md` (a line\n // outside code fences and outside our own blocks) or IS a symlink\n // resolving to AGENTS.md, the canonical block goes to AGENTS.md and\n // CLAUDE.md is NOT touched — the pre-existing user wiring is never\n // claimed as agent-connector-managed (prevents double-reads and writes\n // \"through\" a symlink). Order-independent: keyed off the import/symlink\n // existing, never off whether the AGENTS.md block was written yet.\n\n /** CLAUDE.md path: project `<projectDir>/CLAUDE.md`, user `~/.claude/CLAUDE.md`. */\n private claudeMdPath(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \"CLAUDE.md\")\n : join(homedir(), \".claude\", \"CLAUDE.md\");\n }\n\n /** Sibling AGENTS.md at the same scope (agents-import / auto-interop target). */\n private agentsMdPath(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \"AGENTS.md\")\n : join(homedir(), \".claude\", \"AGENTS.md\");\n }\n\n /**\n * True when the user ALREADY wired CLAUDE.md to AGENTS.md themselves:\n * an `@AGENTS.md` import line outside code fences and outside agent-connector\n * managed blocks (our own bridge must not count), or CLAUDE.md being a\n * symlink that resolves to the sibling AGENTS.md.\n */\n private claudeMdWiredToAgentsMd(ctx: InstallContext): boolean {\n const claudeMd = this.claudeMdPath(ctx);\n if (!existsSync(claudeMd)) return false;\n try {\n if (lstatSync(claudeMd).isSymbolicLink()) {\n const agentsMd = this.agentsMdPath(ctx);\n const resolved = realpathSync(claudeMd);\n const agentsResolved = existsSync(agentsMd) ? realpathSync(agentsMd) : agentsMd;\n if (resolved === agentsResolved) return true;\n }\n } catch {\n /* unreadable link — fall through to the content probe */\n }\n let raw: string;\n try {\n raw = readFileSync(claudeMd, \"utf8\");\n } catch {\n return false;\n }\n // Strip every agent-connector managed block first so OUR bridge import is\n // never mistaken for user wiring (idempotence across modes).\n const withoutBlocks = removeBlocksFromText(raw, { blockIdPrefix: \"\" }).text;\n const importRe = /(^|\\s)@(?:AGENTS\\.md|~\\/\\.claude\\/AGENTS\\.md)(\\s|$)/;\n return linesOutsideFences(withoutBlocks).some((line) => importRe.test(line));\n }\n\n /**\n * Effective memory mode for this install:\n * \"user-import\" — the user already wired CLAUDE.md→AGENTS.md (wins over\n * everything; we never write a duplicate or a second import);\n * \"agents-import\" — explicit opt-in via platforms[\"claude-code\"].memory.mode;\n * \"block\" — the default (managed block directly in CLAUDE.md).\n */\n private effectiveMemoryMode(ctx: InstallContext): \"block\" | \"agents-import\" | \"user-import\" {\n if (this.claudeMdWiredToAgentsMd(ctx)) return \"user-import\";\n return this.memoryOverride(ctx)?.mode === \"agents-import\" ? \"agents-import\" : \"block\";\n }\n\n protected override memoryTargets(ctx: InstallContext): MemoryTarget[] {\n // An explicit path override keeps the base resolution (escape hatch wins).\n if (this.memoryOverride(ctx)?.path) return super.memoryTargets(ctx);\n if (ctx.scope !== \"project\" && ctx.scope !== \"user\") return [];\n const mode = this.effectiveMemoryMode(ctx);\n if (mode === \"block\") {\n return [\n {\n path: this.claudeMdPath(ctx),\n reason:\n \"CLAUDE.md (Claude Code reads CLAUDE.md, not AGENTS.md; \" +\n \"HTML-comment markers are stripped from the model's context)\",\n },\n ];\n }\n return [\n {\n path: this.agentsMdPath(ctx),\n reason:\n mode === \"user-import\"\n ? \"AGENTS.md (CLAUDE.md already imports/symlinks it — user wiring respected)\"\n : \"AGENTS.md (agents-import mode; @AGENTS.md bridge managed in CLAUDE.md)\",\n },\n ];\n }\n\n override installMemory(ctx: InstallContext): ChangeRecord[] {\n const changes = super.installMemory(ctx);\n const { connector } = ctx;\n // Bridge management applies only when the generic path actually installed.\n if (connector.platforms[HOST]?.memory === false || (connector.memory ?? []).length === 0) {\n return changes;\n }\n if (ctx.scope !== \"project\" && ctx.scope !== \"user\") return changes;\n if (this.memoryOverride(ctx)?.path) return changes;\n\n const mode = this.effectiveMemoryMode(ctx);\n if (mode === \"user-import\") {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: this.claudeMdPath(ctx),\n detail:\n \"memory: CLAUDE.md already imports AGENTS.md; canonical block in AGENTS.md \" +\n \"suffices (pre-existing user import never claimed as managed)\",\n });\n return changes;\n }\n if (mode !== \"agents-import\") return changes;\n\n // agents-import: ensure the SHARED `@AGENTS.md` bridge block in CLAUDE.md.\n const claudeMd = this.claudeMdPath(ctx);\n const importLine = ctx.scope === \"project\" ? \"@AGENTS.md\" : \"@~/.claude/AGENTS.md\";\n const res = upsertManagedBlockFile(claudeMd, {\n blockId: CLAUDE_AGENTS_IMPORT_BLOCK_ID,\n connectorId: \"_shared\",\n content: importLine,\n notice:\n \"Managed by agent-connector (shared bridge). This import makes Claude Code read \" +\n \"AGENTS.md; it is removed automatically when the last agent-connector block \" +\n \"leaves AGENTS.md.\",\n force: ctx.force ?? false,\n dryRun: ctx.dryRun,\n });\n changes.push({\n platform: this.id,\n action: res.action,\n path: claudeMd,\n detail: `memory: ${res.detail} — @AGENTS.md import bridge (agents-import mode)`,\n });\n if (res.backupPath) {\n changes.push({\n platform: this.id,\n action: \"create\",\n path: res.backupPath,\n detail: \"backed up CLAUDE.md before destructive change\",\n });\n }\n if (res.action !== \"warn\" && !ctx.dryRun) {\n const ledger = loadMemoryLedger(connector.id);\n recordMemoryTarget(ledger, {\n platform: this.id,\n scope: ctx.scope,\n path: claudeMd,\n blockId: CLAUDE_AGENTS_IMPORT_BLOCK_ID,\n createdFile: res.createdFile,\n hash: res.hash,\n });\n saveMemoryLedger(connector.id, ledger);\n }\n return changes;\n }\n\n override uninstallMemory(ctx: InstallContext): ChangeRecord[] {\n // Capture bridge facts BEFORE super prunes this platform's ledger rows.\n const priorRows = loadMemoryLedger(ctx.connector.id).targets.filter(\n (t) => t.platform === this.id && t.blockId === CLAUDE_AGENTS_IMPORT_BLOCK_ID,\n );\n const changes = super.uninstallMemory(ctx);\n\n // Bridge candidates: the current-scope CLAUDE.md plus any CLAUDE.md the\n // ledger recorded a bridge in (scope drift between install and uninstall).\n const pairs = new Map<string, { agentsMd: string; createdFile: boolean }>();\n if (ctx.scope === \"project\" || ctx.scope === \"user\") {\n pairs.set(this.claudeMdPath(ctx), {\n agentsMd: this.agentsMdPath(ctx),\n createdFile: false,\n });\n }\n for (const row of priorRows) {\n const existing = pairs.get(row.path);\n pairs.set(row.path, {\n agentsMd: existing?.agentsMd ?? join(dirname(row.path), \"AGENTS.md\"),\n createdFile: (existing?.createdFile ?? false) || row.createdFile,\n });\n }\n for (const [claudeMd, { agentsMd, createdFile }] of pairs) {\n changes.push(...this.releaseAgentsImportBridge(ctx, claudeMd, agentsMd, createdFile));\n }\n return changes;\n }\n\n /**\n * Refcounted bridge release: remove the `_shared/claude-agents-import` block\n * from CLAUDE.md ONLY when the sibling AGENTS.md holds zero agent-connector\n * blocks from OTHER connectors (namespace-wide count, excluding this\n * connector's own blocks so the answer is identical on dry-run and real run).\n * A user-authored `@AGENTS.md` import (no markers) is NEVER touched.\n */\n private releaseAgentsImportBridge(\n ctx: InstallContext,\n claudeMd: string,\n agentsMd: string,\n createdFile: boolean,\n ): ChangeRecord[] {\n if (!existsSync(claudeMd)) return [];\n let raw: string;\n try {\n raw = readFileSync(claudeMd, \"utf8\");\n } catch {\n return [];\n }\n if (!listManagedBlocks(raw).some((b) => b.blockId === CLAUDE_AGENTS_IMPORT_BLOCK_ID)) {\n return []; // no managed bridge here (user wiring or block mode) — nothing to release\n }\n let remaining = 0;\n if (existsSync(agentsMd)) {\n try {\n remaining = listManagedBlocks(readFileSync(agentsMd, \"utf8\")).filter(\n (b) => !b.blockId.startsWith(`${ctx.connector.id}/`),\n ).length;\n } catch {\n remaining = 1; // unreadable → conservative: keep the bridge\n }\n }\n if (remaining > 0) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: claudeMd,\n detail:\n `memory: @AGENTS.md import bridge retained — ${remaining} agent-connector ` +\n `block(s) from other connectors remain in ${agentsMd}`,\n },\n ];\n }\n return removeManagedBlocksFile(\n claudeMd,\n { blockId: CLAUDE_AGENTS_IMPORT_BLOCK_ID },\n { dryRun: ctx.dryRun, deleteFileIfCreated: createdFile },\n ).map((r) => ({\n platform: this.id,\n action: r.action,\n path: r.path,\n detail: `memory: ${r.detail}`,\n }));\n }\n\n /** True when a hook command references our home binary AND this connector id\n * (anchored so a shared-prefix id can't collide — see isHomeBinHookCommand). */\n private isOurCommand(command: string | undefined, ctx: InstallContext): boolean {\n return isHomeBinHookCommand(command, ctx.homeBinPath, ctx.connector.id);\n }\n\n // ── Diagnostics ──────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const settingsPath = this.getHookConfigPath(ctx);\n const connectorId = ctx.connector.id;\n const homeBin = ctx.homeBinPath;\n const hookEvents = ctx.connector.hookEvents;\n // Native passthrough hooks count toward \"declares hooks\" ONLY when declared\n // for this platform (the serialized meta keeps the event-name keys, so this\n // works for doctor's handler-less meta-derived connectors too).\n const declaredHookCount =\n hookEvents.length +\n Object.keys(ctx.connector.platforms[HOST]?.nativeHooks ?? {}).length;\n const checks: HealthCheck[] = [\n {\n name: `${this.name}: settings.json present`,\n check: () => {\n // Same \"only assert what the connector declares\" rule as the\n // content-surface checks below: a hookless connector never writes\n // hooks into settings.json, so its absence is healthy, not a failure.\n if (declaredHookCount === 0) {\n return { status: \"OK\", detail: \"no hooks declared\" };\n }\n return existsSync(settingsPath)\n ? { status: \"OK\", detail: settingsPath }\n : { status: \"FAIL\", detail: `not found: ${settingsPath}` };\n },\n },\n {\n name: `${this.name}: hook command registered`,\n check: () => {\n if (declaredHookCount === 0) {\n return { status: \"OK\", detail: \"no hooks declared\" };\n }\n const settings = this.readJson<{ hooks?: Record<string, ClaudeHookEntry[]> }>(\n settingsPath,\n );\n if (!settings) return { status: \"FAIL\", detail: `cannot read ${settingsPath}` };\n const hooks = settings.hooks ?? {};\n const registered = Object.values(hooks).some((entries) =>\n (entries ?? []).some((e) =>\n (e.hooks ?? []).some((h) =>\n isHomeBinHookCommand(h.command, homeBin, connectorId),\n ),\n ),\n );\n return registered\n ? { status: \"OK\", detail: \"hook command present\" }\n : {\n status: \"FAIL\",\n detail: `no hook for ${connectorId} in ${settingsPath}`,\n };\n },\n },\n ];\n\n // Content-surface checks: only assert presence of the files this connector\n // declares (skip silently for surfaces it never asked for).\n for (const cmd of ctx.connector.commands) {\n const p = this.commandPath(ctx, cmd.name);\n checks.push({\n name: `${this.name}: command ${cmd.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n for (const skill of ctx.connector.skills) {\n const p = join(this.skillDir(ctx, skill.name), \"SKILL.md\");\n checks.push({\n name: `${this.name}: skill ${skill.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n for (const agent of ctx.connector.subagents) {\n const p = this.subagentPath(ctx, agent.name);\n checks.push({\n name: `${this.name}: subagent ${agent.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n\n // Statusline check: only assert it when the connector declares one AND it\n // is not disabled for this host. settings.json.statusLine.command must be OUR\n // home-bin statusline command (ok); present but not ours → drifted/skip-warn\n // (never our concern to fix); absent → missing.\n // Fire the check when the connector DECLARES a statusline (the live-config\n // doctor path) OR when the ownership ledger holds a statusLine row this\n // connector owns (the REGISTERED-connector path: connectorFromMeta can't\n // re-expose the render fn, so statusline comes back undefined — but the\n // ledger row proves the surface was wired). Mirrors uninstallStatusline,\n // which is also ledger-keyed; without this the wired statusLine has ZERO\n // doctor coverage in the registered path (configPatchDiagnostics excludes it).\n const statuslineLedgerOwned = ledgerEntriesOwnedBy(\n loadConfigPatchLedger(ctx.dataRoot),\n HOST,\n connectorId,\n ).some((e) => e.key === STATUSLINE_KEY);\n if (\n (ctx.connector.statusline != null || statuslineLedgerOwned) &&\n ctx.connector.platforms[HOST]?.statusline !== false\n ) {\n checks.push({\n name: `${this.name}: statusline wired`,\n check: () => {\n const settings = this.readJson<{ statusLine?: { command?: unknown } }>(settingsPath);\n const command = settings?.statusLine?.command;\n if (command === undefined) {\n return { status: \"FAIL\", detail: `statusLine not set in ${settingsPath}` };\n }\n if (\n typeof command === \"string\" &&\n isHomeBinStatuslineCommand(command, homeBin, connectorId)\n ) {\n return { status: \"OK\", detail: \"statusLine command present\" };\n }\n // Present but not ours — a non-AC statusLine we must never clobber.\n return {\n status: \"FAIL\",\n detail: `statusLine in ${settingsPath} is not agent-connector's (left untouched)`,\n };\n },\n });\n }\n return checks;\n }\n\n // ── Runtime: parse Claude stdin JSON → normalized event ──────────────────\n\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as ClaudeWireInput;\n const connectorId = typeof input.connector === \"string\" ? input.connector : \"\";\n const sessionId = extractSessionId(input);\n const projectDir = typeof input.cwd === \"string\" ? input.cwd : undefined;\n\n const base = {\n hostPlatform: HOST,\n connectorId,\n sessionId,\n raw,\n ...(projectDir !== undefined ? { projectDir } : {}),\n } as const;\n\n switch (event) {\n case \"PreToolUse\": {\n const ev: PreToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n };\n return ev;\n }\n case \"PostToolUse\": {\n const ev: PostToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n ...(toolResponseToString(input.tool_response) !== undefined\n ? { toolOutput: toolResponseToString(input.tool_response) }\n : {}),\n };\n return ev;\n }\n case \"SessionStart\": {\n const ev: SessionStartEvent = {\n ...base,\n source: normalizeSessionSource(input.source),\n };\n return ev;\n }\n case \"SessionEnd\": {\n const ev: SessionEndEvent = {\n ...base,\n ...(typeof input.reason === \"string\" ? { reason: input.reason } : {}),\n };\n return ev;\n }\n case \"UserPromptSubmit\": {\n const ev: UserPromptSubmitEvent = {\n ...base,\n prompt: typeof input.prompt === \"string\" ? input.prompt : \"\",\n };\n return ev;\n }\n case \"PreCompact\": {\n const ev: PreCompactEvent = {\n ...base,\n ...(input.trigger === \"auto\" || input.trigger === \"manual\"\n ? { trigger: input.trigger }\n : {}),\n };\n return ev;\n }\n case \"Stop\": {\n const ev: StopEvent = {\n ...base,\n ...(typeof input.stop_hook_active === \"boolean\"\n ? { stopHookActive: input.stop_hook_active }\n : {}),\n };\n return ev;\n }\n case \"Notification\": {\n const ev: NotificationEvent = {\n ...base,\n message: typeof input.message === \"string\" ? input.message : \"\",\n };\n return ev;\n }\n case \"PermissionRequest\": {\n const ev: PermissionRequestEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n ...(Array.isArray(input.permission_suggestions)\n ? { permissionSuggestions: input.permission_suggestions }\n : {}),\n };\n return ev;\n }\n case \"PostToolUseFailure\": {\n const ev: PostToolUseFailureEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n error: typeof input.error === \"string\" ? input.error : \"\",\n ...(typeof input.tool_use_id === \"string\"\n ? { toolUseId: input.tool_use_id }\n : {}),\n ...(typeof input.is_interrupt === \"boolean\"\n ? { isInterrupt: input.is_interrupt }\n : {}),\n ...(typeof input.duration_ms === \"number\"\n ? { durationMs: input.duration_ms }\n : {}),\n };\n return ev;\n }\n case \"SubagentStart\": {\n const ev: SubagentStartEvent = {\n ...base,\n ...(typeof input.agent_id === \"string\" ? { agentId: input.agent_id } : {}),\n ...(typeof input.agent_type === \"string\"\n ? { agentType: input.agent_type }\n : {}),\n };\n return ev;\n }\n case \"SubagentStop\": {\n // agent_id/agent_type stay optional — the SDK does not reliably\n // populate agent_type on SubagentStop (real-world quirk).\n const ev: SubagentStopEvent = {\n ...base,\n ...(typeof input.agent_id === \"string\" ? { agentId: input.agent_id } : {}),\n ...(typeof input.agent_type === \"string\"\n ? { agentType: input.agent_type }\n : {}),\n ...(typeof input.agent_transcript_path === \"string\"\n ? { agentTranscriptPath: input.agent_transcript_path }\n : {}),\n ...(typeof input.last_assistant_message === \"string\"\n ? { lastAssistantMessage: input.last_assistant_message }\n : {}),\n ...(typeof input.stop_hook_active === \"boolean\"\n ? { stopHookActive: input.stop_hook_active }\n : {}),\n };\n return ev;\n }\n case \"PostCompact\": {\n // Claude Code does NOT wire PostCompact as a normalized lifecycle hook\n // (capabilities.postCompact is unset, so installHooks never registers\n // it) — but the exhaustive guard below requires a case for every\n // HookEventName. This arm is a SAFE passthrough: it normalizes the\n // PreCompact-shaped `trigger` defensively, so a manual\n // `hook claude-code PostCompact` invocation normalizes instead of\n // throwing. It mirrors the PreCompact case byte-for-byte.\n const ev: PostCompactEvent = {\n ...base,\n ...(input.trigger === \"auto\" || input.trigger === \"manual\"\n ? { trigger: input.trigger }\n : {}),\n };\n return ev;\n }\n default: {\n // Exhaustive guard — every HookEventName is handled above.\n const _never: never = event;\n throw new Error(`unsupported claude-code hook event: ${String(_never)}`);\n }\n }\n }\n\n // ── Runtime: normalized response → Claude native hook reply ──────────────\n\n formatReply(event: HookEventName, response: HookResponse): HookReply {\n const hookEventName = event as ClaudeHookEvent;\n const decision = response.decision ?? \"allow\";\n\n // PermissionRequest replies use Claude's nested decision{behavior} envelope\n // and are the ONE event where an EXPLICIT \"allow\" is an ACTIVE grant (it\n // suppresses the permission dialog) rather than passthrough:\n // allow → decision{behavior:\"allow\"} (+updatedInput when set);\n // Claude still enforces its own deny rules — an allow\n // never overrides a matching deny rule (host-enforced).\n // modify → an allow grant carrying updatedInput.\n // deny → decision{behavior:\"deny\", message} (shown to Claude).\n // ask/context/void → NO decision output: fall through to the native\n // dialog (the dialog IS the ask).\n if (event === \"PermissionRequest\") {\n if (response.decision === \"deny\") {\n return this.stdout({\n hookSpecificOutput: {\n hookEventName,\n decision: {\n behavior: \"deny\",\n message: response.reason ?? \"Blocked by hook\",\n },\n },\n });\n }\n if (\n response.decision === \"allow\" ||\n (response.decision === \"modify\" && response.updatedInput)\n ) {\n return this.stdout({\n hookSpecificOutput: {\n hookEventName,\n decision: {\n behavior: \"allow\",\n ...(response.updatedInput\n ? { updatedInput: response.updatedInput }\n : {}),\n },\n },\n });\n }\n return { exitCode: 0 };\n }\n\n // PostToolUseFailure (feedback beside the error) and SubagentStart (context\n // injected at the start of the SUBAGENT's conversation) are observe/context-\n // only on Claude: \"context\" emits additionalContext, and a \"deny\" DEGRADES\n // to the same shape carrying the reason (the tool already failed / the\n // spawn is not blockable). Everything else passes through.\n if (event === \"PostToolUseFailure\" || event === \"SubagentStart\") {\n const context =\n decision === \"context\"\n ? response.additionalContext\n : decision === \"deny\"\n ? response.reason ?? response.additionalContext\n : undefined;\n if (context) {\n return this.stdout({\n hookSpecificOutput: { hookEventName, additionalContext: context },\n });\n }\n return { exitCode: 0 };\n }\n\n // deny → block the action with a reason (exit 0; JSON carries the decision).\n // Claude's deny shape is EVENT-SPECIFIC: PreToolUse uses\n // hookSpecificOutput.permissionDecision, but Stop / SubagentStop /\n // UserPromptSubmit / PostToolUse honor only the TOP-LEVEL\n // {\"decision\":\"block\",\"reason\"} — rendering those as permissionDecision is\n // silently ignored by Claude (found porting oh-my-claudecode: its ralph\n // persistence loop denies the Stop event, which never blocked through the\n // old shape). A SubagentStop block keeps the subagent running with `reason`\n // as its next instruction (Stop semantics).\n if (decision === \"deny\") {\n if (\n event === \"Stop\" ||\n event === \"SubagentStop\" ||\n event === \"UserPromptSubmit\" ||\n event === \"PostToolUse\"\n ) {\n return this.stdout({\n decision: \"block\",\n reason: response.reason ?? \"Blocked by hook\",\n });\n }\n return this.stdout({\n hookSpecificOutput: {\n hookEventName,\n permissionDecision: \"deny\",\n permissionDecisionReason: response.reason ?? \"Blocked by hook\",\n },\n });\n }\n\n // ask → prompt the user to confirm.\n if (decision === \"ask\") {\n return this.stdout({\n hookSpecificOutput: {\n hookEventName,\n permissionDecision: \"ask\",\n permissionDecisionReason:\n response.reason ?? \"Confirmation required by hook\",\n },\n });\n }\n\n // modify → rewrite PreToolUse input (only where Claude supports it).\n if (decision === \"modify\") {\n if (event === \"PreToolUse\" && response.updatedInput) {\n return this.stdout({\n hookSpecificOutput: { hookEventName, updatedInput: response.updatedInput },\n });\n }\n // Output rewrite is unsupported on Claude; fall through to allow.\n }\n\n // context → inject soft guidance (also the SessionStart context path).\n if (decision === \"context\" && response.additionalContext) {\n return this.stdout({\n hookSpecificOutput: { hookEventName, additionalContext: response.additionalContext },\n });\n }\n\n // allow / void / unsupported-degradation → pass through with exit 0.\n return { exitCode: 0 };\n }\n\n private stdout(payload: unknown): HookReply {\n return { exitCode: 0, stdout: JSON.stringify(payload) };\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// configPatch: sensitive-key denylist + JSON leaf-path helpers\n// ─────────────────────────────────────────────────────────────────────────\n\n/**\n * SENSITIVE-KEY DENYLIST (claude-code, v1) — THE documented list. configPatch\n * targeting any key below is HARD-REFUSED (warn ChangeRecord, never applied;\n * no override flag in v1). Rationale: configPatch writes bare host keys with\n * no inherent attribution, and these keys are security-relevant — permission\n * grants, tool allowlists, credential/auth helpers, login pinning, and any\n * env var that can reroute credentials or traffic. The OMC case\n * `env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS` passes; credential rerouting and\n * self-granted permissions do not. Reviewed whenever the host matrix updates.\n *\n * permissions, permissions.* — self-granted permission rules\n * allowedTools / disallowedTools (.*) — tool allowlist tampering\n * apiKey* (e.g. apiKeyHelper) — credential helpers\n * awsAuthRefresh / awsCredentialExport — AWS credential plumbing\n * forceLoginMethod / forceLoginOrgUUID — login/org pinning\n * otelHeadersHelper — telemetry-header (token) helper\n * hooks*, mcpServers* (+ enable/enabled/disabledMcpjsonServers)\n * — refused upstream by the\n * agent-connector NAMESPACE guard\n * env.ANTHROPIC_* — API key / base-URL rerouting\n * env.AWS_* — AWS credentials\n * env.*_PROXY — traffic interception\n * env.*TOKEN* / env.*KEY* / env.*SECRET* — generic credential patterns\n */\nconst SENSITIVE_KEY_RULES: ReadonlyArray<{ re: RegExp; label: string }> = [\n { re: /^permissions(\\.|$)/, label: \"permissions\" },\n { re: /^allowedTools(\\.|$)/, label: \"allowedTools\" },\n { re: /^disallowedTools(\\.|$)/, label: \"disallowedTools\" },\n { re: /^apiKey/i, label: \"apiKey*\" },\n { re: /^awsAuthRefresh$/, label: \"awsAuthRefresh\" },\n { re: /^awsCredentialExport$/, label: \"awsCredentialExport\" },\n { re: /^forceLoginMethod$/, label: \"forceLoginMethod\" },\n { re: /^forceLoginOrgUUID$/, label: \"forceLoginOrgUUID\" },\n { re: /^otelHeadersHelper$/, label: \"otelHeadersHelper\" },\n { re: /^env\\.ANTHROPIC_/, label: \"env.ANTHROPIC_*\" },\n { re: /^env\\.AWS_/, label: \"env.AWS_*\" },\n { re: /^env\\.[^.]*_PROXY(\\.|$)/i, label: \"env.*_PROXY\" },\n { re: /^env\\.[^.]*TOKEN/i, label: \"env.*TOKEN*\" },\n { re: /^env\\.[^.]*KEY/i, label: \"env.*KEY*\" },\n { re: /^env\\.[^.]*SECRET/i, label: \"env.*SECRET*\" },\n];\n\n/**\n * The matched denylist pattern label when `key` is sensitive on claude-code,\n * else null. Exported so tests and docs stay pinned to the real list.\n */\nexport function claudeSensitiveKeyViolation(key: string): string | null {\n for (const rule of SENSITIVE_KEY_RULES) {\n if (rule.re.test(key)) return rule.label;\n }\n return null;\n}\n\n/** Result of looking up a dotted leaf path in a parsed JSON object. */\ntype JsonLeafLookup =\n | { kind: \"absent\" }\n | { kind: \"present\"; value: JsonValue }\n | { kind: \"blocked\"; atPath: string };\n\n/**\n * Walk `segments` (a validated dotted leaf path) through `root`. \"blocked\"\n * reports the first intermediate that exists but is not a plain object —\n * the skip-warn case (we never replace a non-object intermediate).\n */\nfunction readJsonLeaf(root: Record<string, unknown>, segments: string[]): JsonLeafLookup {\n let node: Record<string, unknown> = root;\n for (let i = 0; i < segments.length - 1; i++) {\n const next = node[segments[i]!];\n if (next === undefined) return { kind: \"absent\" };\n if (next === null || typeof next !== \"object\" || Array.isArray(next)) {\n return { kind: \"blocked\", atPath: segments.slice(0, i + 1).join(\".\") };\n }\n node = next as Record<string, unknown>;\n }\n const leaf = node[segments[segments.length - 1]!];\n if (leaf === undefined) return { kind: \"absent\" };\n return { kind: \"present\", value: leaf as JsonValue };\n}\n\n/**\n * Write `value` at the leaf, creating ONLY absent intermediate objects along\n * the way (callers must have verified the path is not blocked).\n */\nfunction writeJsonLeaf(\n root: Record<string, unknown>,\n segments: string[],\n value: JsonValue,\n): void {\n let node: Record<string, unknown> = root;\n for (let i = 0; i < segments.length - 1; i++) {\n const seg = segments[i]!;\n const next = node[seg];\n if (next === undefined) {\n const created: Record<string, unknown> = {};\n node[seg] = created;\n node = created;\n } else {\n node = next as Record<string, unknown>;\n }\n }\n node[segments[segments.length - 1]!] = value;\n}\n\n/**\n * Delete the leaf key only. Intermediate objects — even ones we created — are\n * deliberately left in place (harmless; pruning risks collateral).\n */\nfunction deleteJsonLeaf(root: Record<string, unknown>, segments: string[]): void {\n let node: Record<string, unknown> = root;\n for (let i = 0; i < segments.length - 1; i++) {\n const next = node[segments[i]!];\n if (next === null || typeof next !== \"object\" || Array.isArray(next)) return;\n node = next as Record<string, unknown>;\n }\n delete node[segments[segments.length - 1]!];\n}\n\n/** Claude Code native interpolation token: `${env:VAR}` → `${VAR}`. */\nfunction claudeEnvToken(name: string): string {\n return `\\${${name}}`;\n}\n\nfunction normalizeSessionSource(source: string | undefined): SessionStartEvent[\"source\"] {\n switch (source) {\n case \"compact\":\n return \"compact\";\n case \"resume\":\n return \"resume\";\n case \"clear\":\n return \"clear\";\n default:\n return \"startup\";\n }\n}\n\nexport const adapter = new ClaudeCodeAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,SAAS,cAAc,YAAY,WAAW,cAAc,oBAAoB;AAChF,SAAS,eAAe;AACxB,SAAS,UAAU,SAAS,YAAY;AAiFxC,IAAM,OAAmB;AACzB,IAAM,eAAe;AAQrB,IAAM,iBAAiB;AASvB,IAAM,gCAAgC;AAqC/B,IAAM,oBAAN,cAAgC,YAA+B;AAAA,EAC3D,KAAiB;AAAA,EACjB,OAAO;AAAA,EACP,WAAyB;AAAA,EAEzB,eAAqC;AAAA,IAC5C,YAAY;AAAA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O,EAAE,MAAM,WAAW,OAAO,KAAkB;AACrD;AAMA,SAAS,cACP,MACA,UACA,OACM;AACN,MAAI,OAAgC;AACpC,WAAS,IAAI,GAAG,IAAI,SAAS,SAAS,GAAG,KAAK;AAC5C,UAAM,MAAM,SAAS,CAAC;AACtB,UAAM,OAAO,KAAK,GAAG;AACrB,QAAI,SAAS,QAAW;AACtB,YAAM,UAAmC,CAAC;AAC1C,WAAK,GAAG,IAAI;AACZ,aAAO;AAAA,IACT,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF;AACA,OAAK,SAAS,SAAS,SAAS,CAAC,CAAE,IAAI;AACzC;AAMA,SAAS,eAAe,MAA+B,UAA0B;AAC/E,MAAI,OAAgC;AACpC,WAAS,IAAI,GAAG,IAAI,SAAS,SAAS,GAAG,KAAK;AAC5C,UAAM,OAAO,KAAK,SAAS,CAAC,CAAE;AAC9B,QAAI,SAAS,QAAQ,OAAO,SAAS,YAAY,MAAM,QAAQ,IAAI,EAAG;AACtE,WAAO;AAAA,EACT;AACA,SAAO,KAAK,SAAS,SAAS,SAAS,CAAC,CAAE;AAC5C;AAGA,SAAS,eAAe,MAAsB;AAC5C,SAAO,MAAM,IAAI;AACnB;AAEA,SAAS,uBAAuB,QAAyD;AACvF,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEO,IAAM,UAAU,IAAI,kBAAkB;AAC7C,IAAO,sBAAQ;","names":["entry"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapters/cline/index.ts"],"sourcesContent":["/**\n * adapters/cline — Cline (VS Code extension) platform adapter.\n *\n * Cline (`saoudrizwan.claude-dev`) is the most-installed AI coding VS Code\n * extension and the PARENT that Roo Code (`rooveterinaryinc.roo-cline`) and Kilo\n * Code (`kilocode.kilo-code`) forked. From agent-connector's perspective it is an\n * **mcp-only** host: it exposes no lifecycle hook / event-callback plugin API, so\n * MCP server registration is the only runtime surface we install and every hook\n * capability is reported false. This mirrors the Roo Code adapter (a Cline fork).\n *\n * SCOPE NOTE: this adapter targets the VS Code EXTENSION, NOT the newer Cline\n * CLI/SDK (which would live under ~/.cline and is a separate future adapter).\n *\n * MCP config (cline/cline `main`, disk.ts GlobalFileNames):\n * - USER SCOPE ONLY → <vscodeUserDir>/globalStorage/saoudrizwan.claude-dev/\n * settings/cline_mcp_settings.json (root key \"mcpServers\").\n * There is NO project-scope MCP file — the VS Code extension only reads this\n * single global path (so, unlike roo-code, there is no `.roo/mcp.json` branch\n * and no legacy-filename probe: `cline_mcp_settings.json` is Cline's canonical,\n * never-renamed settings file).\n * Per-server shape: stdio { command, args?, env?, disabled? }; remote\n * { url, type:\"sse\"|\"streamableHttp\" }. An untyped remote url defaults to sse\n * in Cline, so we ALWAYS write `type` explicitly for remote entries.\n *\n * VS Code user-dir resolution (cross-OS) — reused VERBATIM from roo-code:\n * - macOS → ~/Library/Application Support/Code/User\n * - Linux → ~/.config/Code/User\n * - Windows → %APPDATA%/Code/User (falls back to ~/AppData/Roaming/Code/User)\n *\n * Memory / commands / skills (docs.cline.bot) — the `.clinerules` content tree:\n * - memory → project <projectDir>/.clinerules/agent-connector.md (DIRECTORY\n * form); user ~/Documents/Cline/Rules/agent-connector.md. Markdown.\n * - command → project <projectDir>/.clinerules/workflows/<name>.md; user\n * ~/Documents/Cline/Workflows/<name>.md. (Cline \"Workflows\" are the\n * slash-command equivalent.) Plain markdown (frontmatter + body).\n * - skill → project <projectDir>/.clinerules/skills/<name>/SKILL.md;\n * user ~/.cline/skills/<name>/SKILL.md (homedir/.cline, cross-OS)\n * (SKILL.md-in-named-dir, YAML frontmatter; both scopes are\n * documented in cline/cline docs/customization/skills.mdx).\n *\n * READ-ONLY interop (NEVER written under this adapter): Cline also reads\n * `.cursor/rules`, `AGENTS.md`, `.claude/skills`, `.agents/skills` for cross-tool\n * interop. Those are other tools' surfaces — AC owns only the `.clinerules`/\n * Documents-dir paths above.\n *\n * Env interpolation: Cline's settings file documents no native `${env:VAR}`\n * token, so every `${env:VAR}` reference is resolved to a literal at install time\n * (the no-native-token path, same as roo-code / gemini-cli).\n *\n * The hook \"config path\" is the SAME MCP settings file (there is no hook file),\n * so the generic doctor/backup behave sensibly.\n */\n\nimport { existsSync, statSync } from \"node:fs\";\nimport { homedir, platform as osPlatform } from \"node:os\";\nimport { join } from \"node:path\";\n\nimport { BaseAdapter } from \"../base.js\";\nimport type { Adapter, InstallContext, MemoryTarget } from \"../spi.js\";\nimport type {\n ChangeRecord,\n CommandDef,\n DetectedPlatform,\n HealthCheck,\n HookParadigm,\n PlatformCapabilities,\n PlatformId,\n ServerDef,\n SkillDef,\n Transport,\n} from \"../../core/types.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport {\n buildServeWrapperCommand,\n shouldWrapForTelemetry,\n} from \"../../core/spawn.js\";\n\nconst HOST: PlatformId = \"cline\";\nconst MCP_ROOT_KEY = \"mcpServers\";\n\n/** Cline extension id → its VS Code globalStorage folder. */\nconst CLINE_EXTENSION_ID = \"saoudrizwan.claude-dev\";\n/** User-scope MCP settings filename — Cline's canonical, never-renamed name. */\nconst MCP_SETTINGS_FILE = \"cline_mcp_settings.json\";\n\n/**\n * Native MCP server entry shapes Cline accepts under `mcpServers`. We write the\n * minimal stdio shape { command, args?, env?, disabled }; for remote servers we\n * ALWAYS emit `type` (Cline defaults an untyped url to sse, so the type must be\n * explicit to register a streamable-http server).\n */\ninterface ClineStdioServer {\n command: string;\n args?: string[];\n env?: Record<string, string>;\n disabled: boolean;\n}\ninterface ClineRemoteServer {\n url: string;\n type: \"sse\" | \"streamableHttp\";\n headers?: Record<string, string>;\n disabled: boolean;\n}\n\n/**\n * Resolve the cross-OS VS Code per-user data directory (the \"User\" folder that\n * contains `globalStorage`). REUSED VERBATIM from the roo-code adapter — Cline\n * is its parent and the published extension lives under the same stable \"Code\"\n * tree. See module header for the per-platform mapping.\n */\nfunction vscodeUserDir(): string {\n const home = homedir();\n switch (osPlatform()) {\n case \"darwin\":\n return join(home, \"Library\", \"Application Support\", \"Code\", \"User\");\n case \"win32\": {\n const appData = process.env.APPDATA ?? join(home, \"AppData\", \"Roaming\");\n return join(appData, \"Code\", \"User\");\n }\n default:\n // Linux / other POSIX: XDG-style config dir.\n return join(home, \".config\", \"Code\", \"User\");\n }\n}\n\n/**\n * Resolve the cross-OS user Documents directory. Cline's user-scope memory +\n * workflows live under `<documentsDir>/Cline/{Rules,Workflows}`.\n *\n * CAVEAT (documented, honest approximation — NOT a fabricated path): on Windows\n * the real Cline uses the MyDocuments known-folder, which a user CAN relocate\n * (we do not read the registry to discover a moved folder). `~/Documents` is the\n * Windows default and covers the common case. POSIX additionally honors\n * `XDG_DOCUMENTS_DIR` when set. The path SHAPE `Documents/Cline/{Rules,Workflows}`\n * is source-verified against docs.cline.bot.\n */\nfunction documentsDir(): string {\n if (osPlatform() === \"win32\") {\n return join(homedir(), \"Documents\");\n }\n const xdg = process.env.XDG_DOCUMENTS_DIR;\n return xdg && xdg.trim() !== \"\" ? xdg : join(homedir(), \"Documents\");\n}\n\nexport class ClineAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"Cline\";\n readonly paradigm: HookParadigm = \"mcp-only\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: the `.clinerules` content tree (project\n // <projectDir>/.clinerules/agent-connector.md; user\n // ~/Documents/Cline/Rules/agent-connector.md) — overrides memoryTargets()\n // below (Cline does NOT use the AGENTS.md base default for its OWN file).\n supportsMemory: true,\n // Cline has no lifecycle hook system — every hook capability is false.\n preToolUse: false,\n postToolUse: false,\n preCompact: false,\n sessionStart: false,\n sessionEnd: false,\n userPromptSubmit: false,\n stop: false,\n notification: false,\n canModifyArgs: false,\n canModifyOutput: false,\n canInjectSessionContext: false,\n // Cline registers stdio, SSE, and Streamable HTTP MCP servers.\n transports: [\"stdio\", \"sse\", \"http\"],\n // Content surfaces: Workflows (the slash-command equivalent) and AgentSkills.\n // command → <clineRulesDir>/workflows/<name>.md (md + optional frontmatter)\n // skill → <projectDir>/.clinerules/skills/<name>/SKILL.md (project only)\n supportsCommands: true,\n supportsSkills: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userSettings = this.userSettingsPath();\n const userExtDir = join(\n vscodeUserDir(),\n \"globalStorage\",\n CLINE_EXTENSION_ID,\n );\n // Project marker: the `.clinerules` content root (file OR directory form).\n const projectRules = join(projectDir, \".clinerules\");\n\n const userMatch = existsSync(userSettings) || existsSync(userExtDir);\n const projectMatch = existsSync(projectRules);\n const installed = userMatch || projectMatch;\n\n // Prefer the user scope/path when present; otherwise surface the project one.\n const scope = userMatch || !projectMatch ? \"user\" : \"project\";\n const configPath = scope === \"user\" ? userSettings : projectRules;\n const reason = installed\n ? userMatch\n ? `found Cline globalStorage under ${userExtDir}`\n : `found Cline project rules at ${projectRules}`\n : `no Cline config at ${userExtDir} or ${projectRules}`;\n\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath,\n scope,\n reason,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Native paths ─────────────────────────────────────────────────────────\n\n /** Absolute path to the user-scope MCP settings file (VS Code globalStorage). */\n private userSettingsPath(): string {\n return join(\n vscodeUserDir(),\n \"globalStorage\",\n CLINE_EXTENSION_ID,\n \"settings\",\n MCP_SETTINGS_FILE,\n );\n }\n\n /**\n * MCP config is USER-SCOPE ONLY (the VS Code ext reads one global file). At\n * project scope we still return the global path so a project-scope install\n * lands the server where Cline actually reads it.\n */\n getConfigDir(_ctx: InstallContext): string {\n return join(\n vscodeUserDir(),\n \"globalStorage\",\n CLINE_EXTENSION_ID,\n \"settings\",\n );\n }\n\n getServerConfigPath(_ctx: InstallContext): string {\n return this.userSettingsPath();\n }\n\n /**\n * Cline has no hook file — hooks are not a thing here. The hook \"config path\"\n * is the same MCP settings file so the generic doctor/backup behave sensibly.\n */\n getHookConfigPath(ctx: InstallContext): string {\n return this.getServerConfigPath(ctx);\n }\n\n // ── Memory surface: the `.clinerules` content tree ───────────────────────\n // Cline uses .clinerules (NOT AGENTS.md) for its OWN rules, so this override\n // replaces the AGENTS.md base default entirely:\n // project → <projectDir>/.clinerules/agent-connector.md (DIRECTORY form)\n // user → ~/Documents/Cline/Rules/agent-connector.md\n // When `.clinerules` exists as a single FILE (the legacy single-file form),\n // we must NOT create a `.clinerules/agent-connector.md` underneath it — that\n // would throw ENOTDIR — so we return [] here and installMemory() emits a\n // precise skip-warn (see below) rather than clobbering the user's file.\n protected override memoryTargets(ctx: InstallContext): MemoryTarget[] {\n // An explicit platforms[cline].memory.path override wins (escape hatch).\n if (this.memoryOverride(ctx)?.path) return super.memoryTargets(ctx);\n if (ctx.scope === \"project\") {\n if (this.clineRulesIsFile(ctx.projectDir)) return [];\n return [\n {\n path: join(ctx.projectDir, \".clinerules\", \"agent-connector.md\"),\n reason: \"cline project rules dir (.clinerules/; agent-connector-owned file)\",\n },\n ];\n }\n if (ctx.scope === \"user\") {\n return [\n {\n path: join(documentsDir(), \"Cline\", \"Rules\", \"agent-connector.md\"),\n reason: \"cline user rules dir (~/Documents/Cline/Rules; agent-connector-owned file)\",\n },\n ];\n }\n return [];\n }\n\n /**\n * Override installMemory ONLY to surface a precise warn when `.clinerules`\n * exists as a single FILE at project scope (so memoryTargets() returned []):\n * we never clobber the user's single-file rules. All other behavior delegates\n * to the base implementation.\n */\n override installMemory(ctx: InstallContext): ChangeRecord[] {\n if (\n ctx.scope === \"project\" &&\n !this.memoryOverride(ctx)?.path &&\n (ctx.connector.memory ?? []).length > 0 &&\n ctx.connector.platforms[this.id]?.memory !== false &&\n this.clineRulesIsFile(ctx.projectDir)\n ) {\n return [\n {\n platform: this.id,\n action: \"warn\",\n path: join(ctx.projectDir, \".clinerules\"),\n detail:\n \"existing .clinerules is a single file (legacy form); left untouched — \" +\n \"convert it to a .clinerules/ directory to receive agent-connector memory\",\n },\n ];\n }\n return super.installMemory(ctx);\n }\n\n /** True when `<dir>/.clinerules` exists and is a regular FILE (not a directory). */\n private clineRulesIsFile(dir: string): boolean {\n const p = join(dir, \".clinerules\");\n if (!existsSync(p)) return false;\n try {\n return statSync(p).isFile();\n } catch {\n return false;\n }\n }\n\n // ── MCP server install / uninstall ───────────────────────────────────────\n\n installServer(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n const override = connector.platforms[HOST]?.server;\n if (!connector.server || override === false) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: connector.server\n ? \"server registration disabled for cline\"\n : \"connector declares no MCP server\",\n },\n ];\n }\n\n // Shallow-merge any per-platform server override into the base ServerDef.\n const server: ServerDef =\n override && typeof override === \"object\"\n ? { ...connector.server, ...override }\n : connector.server;\n\n const serverPath = this.getServerConfigPath(ctx);\n const entry = this.renderServerEntry(ctx, server);\n\n return [\n this.upsertServerInJson(serverPath, MCP_ROOT_KEY, connector.id, entry, ctx.dryRun),\n ];\n }\n\n uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const serverPath = this.getServerConfigPath(ctx);\n return [\n this.removeServerFromJson(serverPath, MCP_ROOT_KEY, ctx.connector.id, ctx.dryRun),\n ];\n }\n\n /** Render a normalized ServerDef into Cline's native mcpServers entry. */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): ClineStdioServer | ClineRemoteServer {\n const transport: Transport = server.transport;\n\n if (transport === \"stdio\") {\n let command = server.command ?? \"\";\n let args = [...(server.args ?? [])];\n\n // Transparent telemetry wrapping: route the real command through\n // `<homeBin> serve --connector <id> -- <command> <args...>`.\n if (shouldWrapForTelemetry(server, ctx.connector.telemetry)) {\n const wrapped = buildServeWrapperCommand(\n ctx.homeBinPath,\n ctx.connector.id,\n command,\n args,\n ctx.scope,\n this.id,\n );\n command = wrapped.command;\n args = wrapped.args;\n }\n\n // Cline documents no native interpolation token, so resolve every\n // ${env:VAR} to a literal at install time.\n const entry: ClineStdioServer = {\n command: resolveEnvRefsDeep(command),\n // Honor the per-call server's enabled flag — a server marked\n // enabled:false installs disabled (mirror roo-code).\n disabled: server.enabled === false,\n };\n if (args.length > 0) entry.args = resolveEnvRefsDeep(args);\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n return entry;\n }\n\n // sse / http (and any other remote transport) — Cline registers a URL. We\n // ALWAYS emit `type` (an untyped url defaults to sse in Cline, so streamable\n // http must be explicit): map our \"http\" transport to \"streamableHttp\".\n const entry: ClineRemoteServer = {\n url: resolveEnvRefsDeep(server.url ?? \"\"),\n type: transport === \"http\" ? \"streamableHttp\" : \"sse\",\n disabled: server.enabled === false,\n };\n const headers = this.renderEnv(server.headers);\n if (headers) entry.headers = headers;\n return entry;\n }\n\n /**\n * Render env/header values. Cline documents no native interpolation token, so\n * resolve `${env:VAR}` references to literals at install time.\n */\n private renderEnv(\n env: Record<string, string> | undefined,\n ): Record<string, string> | undefined {\n if (!env || Object.keys(env).length === 0) return undefined;\n return resolveEnvRefsDeep({ ...env });\n }\n\n // ── Hooks (unavailable — Cline is mcp-only) ──────────────────────────────\n\n installHooks(_ctx: InstallContext): ChangeRecord[] {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: \"hooks unavailable (Cline is mcp-only)\",\n },\n ];\n }\n\n uninstallHooks(_ctx: InstallContext): ChangeRecord[] {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: \"hooks unavailable (Cline is mcp-only)\",\n },\n ];\n }\n\n // ── Content surfaces: commands (Workflows) / skills ──────────────────────\n // CONTENT-ONLY: pure native-file writers. No runtime dispatch, no home-bin\n // pointer, no telemetry wrap. Each method is idempotent (byte-identical →\n // skip) via writeContentFile and reversible via removeContentFile. Honors\n // platforms[\"cline\"] per-surface false to skip.\n //\n // Native locations (the `.clinerules` content tree + the Documents-dir):\n // command → project <projectDir>/.clinerules/workflows/<name>.md\n // user ~/Documents/Cline/Workflows/<name>.md\n // skill → project <projectDir>/.clinerules/skills/<name>/SKILL.md\n // user (undocumented for the VS Code ext → skip-warn)\n\n /** The project-scope `.clinerules` content root. */\n private clineRulesDir(ctx: InstallContext): string {\n return join(ctx.projectDir, \".clinerules\");\n }\n\n private commandPath(ctx: InstallContext, name: string): string {\n return ctx.scope === \"project\"\n ? join(this.clineRulesDir(ctx), \"workflows\", `${name}.md`)\n : join(documentsDir(), \"Cline\", \"Workflows\", `${name}.md`);\n }\n\n private skillDir(ctx: InstallContext, name: string): string {\n // User/global scope → ~/.cline/skills/<name> (homedir/.cline, cross-OS via\n // homedir(); primary-verified cline/cline docs/customization/skills.mdx).\n // Project scope → <projectDir>/.clinerules/skills/<name> (a documented\n // project skills location alongside .cline/skills; AC owns the .clinerules tree).\n if (ctx.scope !== \"project\") {\n return join(homedir(), \".cline\", \"skills\", name);\n }\n return join(this.clineRulesDir(ctx), \"skills\", name);\n }\n\n // ── Commands (Workflows — both scopes) ────────────────────────────────────\n\n override installCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[this.id]?.commands === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"commands disabled for cline\" }];\n }\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.writeContentFile(this.commandPath(ctx, cmd.name), this.renderCommand(cmd), ctx.dryRun),\n );\n }\n\n override uninstallCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.removeContentFile(this.commandPath(ctx, cmd.name), ctx.dryRun),\n );\n }\n\n /** Render a command (Cline Workflow) to md + optional frontmatter. */\n private renderCommand(cmd: CommandDef): string {\n const frontmatter: Record<string, unknown> = {};\n if (cmd.description !== undefined) frontmatter.description = cmd.description;\n if (cmd.argumentHint !== undefined) frontmatter[\"argument-hint\"] = cmd.argumentHint;\n if (cmd.extra) Object.assign(frontmatter, cmd.extra);\n return this.renderFrontmatterMd(frontmatter, cmd.prompt);\n }\n\n // ── Skills (project .clinerules/skills + user ~/.cline/skills) ────────────\n\n override installSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[this.id]?.skills === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"skills disabled for cline\" }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n changes.push(\n this.writeContentFile(join(dir, \"SKILL.md\"), this.renderSkill(skill), ctx.dryRun),\n );\n // Bundle any resource files beside SKILL.md (relative path → contents).\n // Defense-in-depth: skip+warn on any key that escapes the skill dir\n // (config-time validation already rejects these, but never trust input).\n for (const [rel, contents] of Object.entries(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `skill resource \"${rel}\" escapes the skill dir; skipped`,\n });\n continue;\n }\n changes.push(this.writeContentFile(target, contents, ctx.dryRun));\n }\n }\n return changes;\n }\n\n override uninstallSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n // Remove only the files we wrote (SKILL.md + declared resources), then the\n // skill dir itself when we own its full contents.\n changes.push(this.removeContentFile(join(dir, \"SKILL.md\"), ctx.dryRun));\n for (const rel of Object.keys(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) continue; // never delete outside the skill dir\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n // Only remove the skill dir when WE own its full contents — never rm -rf a\n // dir that still holds user-added / sibling-tool / shared files.\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n /**\n * Render a skill's SKILL.md: frontmatter (name, description + optional model,\n * allowed-tools, disable-model-invocation) + body. UNIFORM with every other\n * skill-supporting platform — only the parent dir differs.\n */\n private renderSkill(skill: SkillDef): string {\n const frontmatter: Record<string, unknown> = {\n name: skill.name,\n description: skill.description,\n };\n if (skill.model !== undefined) frontmatter.model = skill.model;\n const allow = skill.tools?.allow;\n if (allow && allow.length > 0) frontmatter[\"allowed-tools\"] = allow.join(\", \");\n if (skill.disableModelInvocation !== undefined) {\n frontmatter[\"disable-model-invocation\"] = skill.disableModelInvocation;\n }\n if (skill.extra) Object.assign(frontmatter, skill.extra);\n return this.renderFrontmatterMd(frontmatter, skill.body);\n }\n\n // ── Diagnostics ──────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const mcpPath = this.getServerConfigPath(ctx);\n const connectorId = ctx.connector.id;\n return [\n {\n name: `${this.name}: MCP settings present`,\n check: () =>\n existsSync(mcpPath)\n ? { status: \"OK\", detail: mcpPath }\n : { status: \"FAIL\", detail: `not found: ${mcpPath}` },\n },\n {\n name: `${this.name}: server entry registered`,\n check: () => {\n // Only assert what the connector declares: a server-less connector —\n // e.g. a catalog-only bundle of skills/commands — never writes an\n // mcpServers entry, so its absence is healthy.\n if (!ctx.connector.server) {\n return { status: \"OK\", detail: \"no MCP server declared\" };\n }\n const cfg = this.readJson<{ [k: string]: Record<string, unknown> }>(mcpPath);\n const bucket = cfg?.[MCP_ROOT_KEY];\n if (!cfg || !bucket) {\n return { status: \"FAIL\", detail: `no ${MCP_ROOT_KEY} in ${mcpPath}` };\n }\n return connectorId in bucket\n ? { status: \"OK\", detail: `${MCP_ROOT_KEY}.${connectorId} present` }\n : {\n status: \"FAIL\",\n detail: `no ${MCP_ROOT_KEY}.${connectorId} in ${mcpPath}`,\n };\n },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