@ken-jo/agent-connector 0.4.26 → 0.4.44

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.
Files changed (152) hide show
  1. package/dist/{action-AZRZ3V7E.js → action-72J2TCKQ.js} +8 -8
  2. package/dist/{amazon-q-BWSOHTW5.js → amazon-q-UFLBUSHG.js} +15 -16
  3. package/dist/amazon-q-UFLBUSHG.js.map +1 -0
  4. package/dist/{amp-TF5X6OGH.js → amp-5DJK7VAL.js} +3 -5
  5. package/dist/{amp-TF5X6OGH.js.map → amp-5DJK7VAL.js.map} +1 -1
  6. package/dist/{antigravity-3XHBPXZK.js → antigravity-NWP2TUG6.js} +3 -4
  7. package/dist/{antigravity-cli-TJGOBUPK.js → antigravity-cli-KPNLE7X4.js} +3 -4
  8. package/dist/{antigravity-cli-TJGOBUPK.js.map → antigravity-cli-KPNLE7X4.js.map} +1 -1
  9. package/dist/{chunk-YRBFSZ2G.js → chunk-3Q6YEDCG.js} +3 -5
  10. package/dist/{chunk-YRBFSZ2G.js.map → chunk-3Q6YEDCG.js.map} +1 -1
  11. package/dist/{chunk-Q5HR4ADS.js → chunk-5M2SMDA4.js} +2 -2
  12. package/dist/{chunk-3I7UG52L.js → chunk-A767JFHW.js} +65 -4
  13. package/dist/chunk-A767JFHW.js.map +1 -0
  14. package/dist/{chunk-JLMD3IGK.js → chunk-ASHAMORS.js} +2 -2
  15. package/dist/{chunk-YKVNI44Y.js → chunk-B47MDOV3.js} +3 -3
  16. package/dist/{chunk-ZVTPSV5Z.js → chunk-CFM3JKIR.js} +5 -5
  17. package/dist/{chunk-HZDU3J4U.js → chunk-E3GWKJU5.js} +20 -4
  18. package/dist/chunk-E3GWKJU5.js.map +1 -0
  19. package/dist/{chunk-KD4BE5MW.js → chunk-ERV4TKRV.js} +3 -5
  20. package/dist/{chunk-KD4BE5MW.js.map → chunk-ERV4TKRV.js.map} +1 -1
  21. package/dist/{chunk-25BNMXPP.js → chunk-IKEXNI2W.js} +18 -18
  22. package/dist/{chunk-HU6DZZBG.js → chunk-SBV2QJ5C.js} +36 -36
  23. package/dist/{chunk-OLI5SD6I.js → chunk-UXG64P6R.js} +2 -2
  24. package/dist/{chunk-IW46JIQM.js → chunk-VPSHGDDQ.js} +5 -5
  25. package/dist/{chunk-YEJCNOET.js → chunk-WZWK4ICE.js} +2 -2
  26. package/dist/{cursor-R5QB4YR4.js → chunk-XW46WVR2.js} +11 -12
  27. package/dist/chunk-XW46WVR2.js.map +1 -0
  28. package/dist/{claude-code-JLPFUZ4V.js → claude-code-HXIVRZCY.js} +6 -8
  29. package/dist/{claude-code-JLPFUZ4V.js.map → claude-code-HXIVRZCY.js.map} +1 -1
  30. package/dist/cli/sdk.js +4 -4
  31. package/dist/cli.js +1 -1
  32. package/dist/{cline-GBP3EVSX.js → cline-AGFJF4AC.js} +3 -5
  33. package/dist/{cline-GBP3EVSX.js.map → cline-AGFJF4AC.js.map} +1 -1
  34. package/dist/{codebuff-WMKFUVER.js → codebuff-YUQ4PN7G.js} +3 -5
  35. package/dist/{codebuff-WMKFUVER.js.map → codebuff-YUQ4PN7G.js.map} +1 -1
  36. package/dist/{codex-5CZR5XKX.js → codex-FLU37DV3.js} +26 -11
  37. package/dist/codex-FLU37DV3.js.map +1 -0
  38. package/dist/{continue-3AGXWM5W.js → continue-ZMI4YN75.js} +2 -3
  39. package/dist/{continue-3AGXWM5W.js.map → continue-ZMI4YN75.js.map} +1 -1
  40. package/dist/{copilot-cli-IH4P3GRZ.js → copilot-cli-XPRJ5MQB.js} +29 -5
  41. package/dist/copilot-cli-XPRJ5MQB.js.map +1 -0
  42. package/dist/{crush-FDBL3JEK.js → crush-3OB5ZTCC.js} +11 -10
  43. package/dist/crush-3OB5ZTCC.js.map +1 -0
  44. package/dist/cursor-F4HYO2FP.js +22 -0
  45. package/dist/{detect-L5OZPVFO.js → detect-L3NJTBO5.js} +4 -4
  46. package/dist/{doctor-WDIQ2YFE.js → doctor-PUE4HO3N.js} +13 -10
  47. package/dist/{doctor-WDIQ2YFE.js.map → doctor-PUE4HO3N.js.map} +1 -1
  48. package/dist/{droid-X2QHQL7D.js → droid-NZCKYKOV.js} +3 -5
  49. package/dist/{droid-X2QHQL7D.js.map → droid-NZCKYKOV.js.map} +1 -1
  50. package/dist/{gemini-cli-HCN7XKSX.js → gemini-cli-3ZGCXUDD.js} +3 -5
  51. package/dist/{gemini-cli-HCN7XKSX.js.map → gemini-cli-3ZGCXUDD.js.map} +1 -1
  52. package/dist/{goose-ILMM76JP.js → goose-MGGNVXJP.js} +56 -9
  53. package/dist/goose-MGGNVXJP.js.map +1 -0
  54. package/dist/{hermes-YX2ODUZL.js → hermes-L3CBJ37L.js} +8 -6
  55. package/dist/hermes-L3CBJ37L.js.map +1 -0
  56. package/dist/{hook-JRDQ56BN.js → hook-S3DNNGZX.js} +8 -8
  57. package/dist/index.js +2 -2
  58. package/dist/{install-HRCVPRAQ.js → install-7SUJFRYO.js} +13 -10
  59. package/dist/{install-HRCVPRAQ.js.map → install-7SUJFRYO.js.map} +1 -1
  60. package/dist/{jetbrains-copilot-QESFUN6W.js → jetbrains-copilot-M2LHJBAW.js} +3 -5
  61. package/dist/{jetbrains-copilot-QESFUN6W.js.map → jetbrains-copilot-M2LHJBAW.js.map} +1 -1
  62. package/dist/{kilo-POTCYIRG.js → kilo-RMRP2EL7.js} +3 -5
  63. package/dist/{kilo-POTCYIRG.js.map → kilo-RMRP2EL7.js.map} +1 -1
  64. package/dist/{kilo-cli-MO6FSMH2.js → kilo-cli-6ITBNHTH.js} +14 -10
  65. package/dist/kilo-cli-6ITBNHTH.js.map +1 -0
  66. package/dist/{kimi-RXS36OJP.js → kimi-QYHWAY54.js} +65 -25
  67. package/dist/kimi-QYHWAY54.js.map +1 -0
  68. package/dist/{kiro-VTLX7CMF.js → kiro-2K5UJVGC.js} +11 -16
  69. package/dist/kiro-2K5UJVGC.js.map +1 -0
  70. package/dist/{leaderboard-ASGR3E2U.js → leaderboard-2VAAOK3D.js} +2 -2
  71. package/dist/{mimo-code-F4BWMESO.js → mimo-code-K7AMX2QW.js} +3 -5
  72. package/dist/{mimo-code-F4BWMESO.js.map → mimo-code-K7AMX2QW.js.map} +1 -1
  73. package/dist/{mux-2YFCYFM7.js → mux-GT7FWVLH.js} +3 -5
  74. package/dist/{mux-2YFCYFM7.js.map → mux-GT7FWVLH.js.map} +1 -1
  75. package/dist/{nemoclaw-QDB6O22A.js → nemoclaw-GQMS6CUM.js} +3 -4
  76. package/dist/{nemoclaw-QDB6O22A.js.map → nemoclaw-GQMS6CUM.js.map} +1 -1
  77. package/dist/{omp-P2JNAEPN.js → omp-2RPYIZUF.js} +2 -3
  78. package/dist/{omp-P2JNAEPN.js.map → omp-2RPYIZUF.js.map} +1 -1
  79. package/dist/{openclaw-3UMBSSZM.js → openclaw-P5GMEEGC.js} +3 -4
  80. package/dist/openclaw-P5GMEEGC.js.map +1 -0
  81. package/dist/{opencode-Q6H4YT66.js → opencode-5D2SK3EX.js} +3 -5
  82. package/dist/{opencode-Q6H4YT66.js.map → opencode-5D2SK3EX.js.map} +1 -1
  83. package/dist/{package-IXBSG7HD.js → package-VUX663ET.js} +10 -7
  84. package/dist/{package-IXBSG7HD.js.map → package-VUX663ET.js.map} +1 -1
  85. package/dist/{pi-GW25LPC3.js → pi-ZMM4KJTO.js} +2 -3
  86. package/dist/{pi-GW25LPC3.js.map → pi-ZMM4KJTO.js.map} +1 -1
  87. package/dist/{qwen-code-R6XXEEHJ.js → qwen-code-4ZLVGN2C.js} +9 -11
  88. package/dist/qwen-code-4ZLVGN2C.js.map +1 -0
  89. package/dist/{roo-code-EZPNFC5V.js → roo-code-67QGLQRM.js} +4 -5
  90. package/dist/roo-code-67QGLQRM.js.map +1 -0
  91. package/dist/runtime/index.js +6 -6
  92. package/dist/sdk/index.js +3 -3
  93. package/dist/sdk/test.js +5 -5
  94. package/dist/{serve-CFBQYKRB.js → serve-MOIIYFER.js} +8 -8
  95. package/dist/{status-ASBFEFQQ.js → status-SCBCWS7H.js} +6 -6
  96. package/dist/{statusline-WKLWSM7I.js → statusline-NRPDOPGA.js} +7 -7
  97. package/dist/{telemetry-64GCGNIW.js → telemetry-Q55B5NSZ.js} +5 -5
  98. package/dist/{trae-6VQW2UVP.js → trae-TMJPHWZ5.js} +3 -5
  99. package/dist/{trae-6VQW2UVP.js.map → trae-TMJPHWZ5.js.map} +1 -1
  100. package/dist/{uninstall-KDJYE5ET.js → uninstall-SNI7GPQD.js} +13 -10
  101. package/dist/{uninstall-KDJYE5ET.js.map → uninstall-SNI7GPQD.js.map} +1 -1
  102. package/dist/{upgrade-YQRVYR5U.js → upgrade-ZUNBJWJ7.js} +13 -10
  103. package/dist/{upgrade-YQRVYR5U.js.map → upgrade-ZUNBJWJ7.js.map} +1 -1
  104. package/dist/{usage-OV2BDZKF.js → usage-UQDBIU42.js} +2 -2
  105. package/dist/{usage-event-KPI3NEX3.js → usage-event-HPG2BIAY.js} +7 -7
  106. package/dist/{vscode-copilot-UOEEV4P3.js → vscode-copilot-H7JKUKLZ.js} +19 -8
  107. package/dist/vscode-copilot-H7JKUKLZ.js.map +1 -0
  108. package/dist/{warp-LUK2BPCU.js → warp-SVDVKQQI.js} +3 -5
  109. package/dist/{warp-LUK2BPCU.js.map → warp-SVDVKQQI.js.map} +1 -1
  110. package/dist/{windsurf-NZ3G42NQ.js → windsurf-H36YKOMR.js} +3 -5
  111. package/dist/{windsurf-NZ3G42NQ.js.map → windsurf-H36YKOMR.js.map} +1 -1
  112. package/dist/{zed-LGWGZ4EO.js → zed-LHWJALLZ.js} +3 -5
  113. package/dist/{zed-LGWGZ4EO.js.map → zed-LHWJALLZ.js.map} +1 -1
  114. package/package.json +1 -1
  115. package/dist/amazon-q-BWSOHTW5.js.map +0 -1
  116. package/dist/chunk-3I7UG52L.js.map +0 -1
  117. package/dist/chunk-HZDU3J4U.js.map +0 -1
  118. package/dist/chunk-IEGR4TP3.js +0 -70
  119. package/dist/chunk-IEGR4TP3.js.map +0 -1
  120. package/dist/codex-5CZR5XKX.js.map +0 -1
  121. package/dist/copilot-cli-IH4P3GRZ.js.map +0 -1
  122. package/dist/crush-FDBL3JEK.js.map +0 -1
  123. package/dist/cursor-R5QB4YR4.js.map +0 -1
  124. package/dist/goose-ILMM76JP.js.map +0 -1
  125. package/dist/hermes-YX2ODUZL.js.map +0 -1
  126. package/dist/kilo-cli-MO6FSMH2.js.map +0 -1
  127. package/dist/kimi-RXS36OJP.js.map +0 -1
  128. package/dist/kiro-VTLX7CMF.js.map +0 -1
  129. package/dist/qwen-code-R6XXEEHJ.js.map +0 -1
  130. package/dist/roo-code-EZPNFC5V.js.map +0 -1
  131. package/dist/vscode-copilot-UOEEV4P3.js.map +0 -1
  132. /package/dist/{action-AZRZ3V7E.js.map → action-72J2TCKQ.js.map} +0 -0
  133. /package/dist/{antigravity-3XHBPXZK.js.map → antigravity-NWP2TUG6.js.map} +0 -0
  134. /package/dist/{chunk-Q5HR4ADS.js.map → chunk-5M2SMDA4.js.map} +0 -0
  135. /package/dist/{chunk-JLMD3IGK.js.map → chunk-ASHAMORS.js.map} +0 -0
  136. /package/dist/{chunk-YKVNI44Y.js.map → chunk-B47MDOV3.js.map} +0 -0
  137. /package/dist/{chunk-ZVTPSV5Z.js.map → chunk-CFM3JKIR.js.map} +0 -0
  138. /package/dist/{chunk-25BNMXPP.js.map → chunk-IKEXNI2W.js.map} +0 -0
  139. /package/dist/{chunk-HU6DZZBG.js.map → chunk-SBV2QJ5C.js.map} +0 -0
  140. /package/dist/{chunk-OLI5SD6I.js.map → chunk-UXG64P6R.js.map} +0 -0
  141. /package/dist/{chunk-IW46JIQM.js.map → chunk-VPSHGDDQ.js.map} +0 -0
  142. /package/dist/{chunk-YEJCNOET.js.map → chunk-WZWK4ICE.js.map} +0 -0
  143. /package/dist/{openclaw-3UMBSSZM.js.map → cursor-F4HYO2FP.js.map} +0 -0
  144. /package/dist/{detect-L5OZPVFO.js.map → detect-L3NJTBO5.js.map} +0 -0
  145. /package/dist/{hook-JRDQ56BN.js.map → hook-S3DNNGZX.js.map} +0 -0
  146. /package/dist/{leaderboard-ASGR3E2U.js.map → leaderboard-2VAAOK3D.js.map} +0 -0
  147. /package/dist/{serve-CFBQYKRB.js.map → serve-MOIIYFER.js.map} +0 -0
  148. /package/dist/{status-ASBFEFQQ.js.map → status-SCBCWS7H.js.map} +0 -0
  149. /package/dist/{statusline-WKLWSM7I.js.map → statusline-NRPDOPGA.js.map} +0 -0
  150. /package/dist/{telemetry-64GCGNIW.js.map → telemetry-Q55B5NSZ.js.map} +0 -0
  151. /package/dist/{usage-OV2BDZKF.js.map → usage-UQDBIU42.js.map} +0 -0
  152. /package/dist/{usage-event-KPI3NEX3.js.map → usage-event-HPG2BIAY.js.map} +0 -0
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  main
4
- } from "./chunk-25BNMXPP.js";
4
+ } from "./chunk-IKEXNI2W.js";
5
5
 
6
6
  // src/cli/index.ts
7
7
  main(process.argv.slice(2)).then((code) => {
@@ -3,12 +3,10 @@ import {
3
3
  resolveEnvRefsDeep
4
4
  } from "./chunk-DBQMX75U.js";
5
5
  import {
6
- BaseAdapter
7
- } from "./chunk-3I7UG52L.js";
8
- import {
6
+ BaseAdapter,
9
7
  renderCommandMd,
10
8
  renderSkillMd
11
- } from "./chunk-IEGR4TP3.js";
9
+ } from "./chunk-A767JFHW.js";
12
10
  import {
13
11
  buildWrappedStdio
14
12
  } from "./chunk-TO57WYBB.js";
@@ -407,4 +405,4 @@ export {
407
405
  adapter,
408
406
  cline_default as default
409
407
  };
410
- //# sourceMappingURL=cline-GBP3EVSX.js.map
408
+ //# sourceMappingURL=cline-AGFJF4AC.js.map
@@ -1 +1 @@
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 DetectedPlatform,\n HealthCheck,\n HookParadigm,\n PlatformCapabilities,\n PlatformId,\n ServerDef,\n Transport,\n} from \"../../core/types.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport {\n buildWrappedStdio,\n} from \"../../core/spawn.js\";\nimport { renderCommandMd, renderSkillMd } from \"../claude-code/render.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 ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));\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(\n this.commandPath(ctx, cmd.name),\n renderCommandMd(cmd, { includeToolsAndModel: false }),\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 // ── 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\"), renderSkillMd(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 // ── 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 },\n },\n ];\n }\n}\n\nexport const adapter = new ClineAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqDA,SAAS,YAAY,gBAAgB;AACrC,SAAS,SAAS,YAAY,kBAAkB;AAChD,SAAS,YAAY;AAoBrB,IAAM,OAAmB;AACzB,IAAM,eAAe;AAGrB,IAAM,qBAAqB;AAE3B,IAAM,oBAAoB;AA2B1B,SAAS,gBAAwB;AAC/B,QAAM,OAAO,QAAQ;AACrB,UAAQ,WAAW,GAAG;AAAA,IACpB,KAAK;AACH,aAAO,KAAK,MAAM,WAAW,uBAAuB,QAAQ,MAAM;AAAA,IACpE,KAAK,SAAS;AACZ,YAAM,UAAU,QAAQ,IAAI,WAAW,KAAK,MAAM,WAAW,SAAS;AACtE,aAAO,KAAK,SAAS,QAAQ,MAAM;AAAA,IACrC;AAAA,IACA;AAEE,aAAO,KAAK,MAAM,WAAW,QAAQ,MAAM;AAAA,EAC/C;AACF;AAaA,SAAS,eAAuB;AAC9B,MAAI,WAAW,MAAM,SAAS;AAC5B,WAAO,KAAK,QAAQ,GAAG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AY,IAAI,WAAW,OAAO,OAAO;AAAA,UACzD;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,UAAU,IAAI,aAAa;AACxC,IAAO,gBAAQ;","names":["entry"]}
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 DetectedPlatform,\n HealthCheck,\n HookParadigm,\n PlatformCapabilities,\n PlatformId,\n ServerDef,\n Transport,\n} from \"../../core/types.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport {\n buildWrappedStdio,\n} from \"../../core/spawn.js\";\nimport { renderCommandMd, renderSkillMd } from \"../claude-code/render.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 ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));\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(\n this.commandPath(ctx, cmd.name),\n renderCommandMd(cmd, { includeToolsAndModel: false }),\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 // ── 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\"), renderSkillMd(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 // ── 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 },\n },\n ];\n }\n}\n\nexport const adapter = new ClineAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;AAqDA,SAAS,YAAY,gBAAgB;AACrC,SAAS,SAAS,YAAY,kBAAkB;AAChD,SAAS,YAAY;AAoBrB,IAAM,OAAmB;AACzB,IAAM,eAAe;AAGrB,IAAM,qBAAqB;AAE3B,IAAM,oBAAoB;AA2B1B,SAAS,gBAAwB;AAC/B,QAAM,OAAO,QAAQ;AACrB,UAAQ,WAAW,GAAG;AAAA,IACpB,KAAK;AACH,aAAO,KAAK,MAAM,WAAW,uBAAuB,QAAQ,MAAM;AAAA,I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C3E,gBAAM,SAAS,MAAM,YAAY;AACjC,cAAI,CAAC,OAAO,CAAC,QAAQ;AACnB,mBAAO,EAAE,QAAQ,QAAQ,QAAQ,MAAM,YAAY,OAAO,OAAO,GAAG;AAAA,UACtE;AACA,iBAAO,eAAe,SAClB,EAAE,QAAQ,MAAM,QAAQ,GAAG,YAAY,IAAI,WAAW,WAAW,IACjE;AAAA,YACE,QAAQ;AAAA,YACR,QAAQ,MAAM,YAAY,IAAI,WAAW,OAAO,OAAO;AAAA,UACzD;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,UAAU,IAAI,aAAa;AACxC,IAAO,gBAAQ;","names":["entry"]}
@@ -3,11 +3,9 @@ import {
3
3
  rewriteEnvRefs
4
4
  } from "./chunk-DBQMX75U.js";
5
5
  import {
6
- BaseAdapter
7
- } from "./chunk-3I7UG52L.js";
8
- import {
6
+ BaseAdapter,
9
7
  renderSkillMd
10
- } from "./chunk-IEGR4TP3.js";
8
+ } from "./chunk-A767JFHW.js";
11
9
  import {
12
10
  buildWrappedStdio
13
11
  } from "./chunk-TO57WYBB.js";
@@ -415,4 +413,4 @@ export {
415
413
  adapter,
416
414
  codebuff_default as default
417
415
  };
418
- //# sourceMappingURL=codebuff-WMKFUVER.js.map
416
+ //# sourceMappingURL=codebuff-YUQ4PN7G.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/adapters/codebuff/index.ts"],"sourcesContent":["/**\n * adapters/codebuff — Codebuff platform adapter for agent-connector.\n *\n * Codebuff is an **mcp-only** host: it exposes no lifecycle hook system, and MCP\n * is its extensibility mechanism. This adapter therefore installs only the MCP\n * server and reports hooks as unavailable (mirrors the Warp reference path that\n * validates the `mcp-only` paradigm end-to-end).\n *\n * MCP config (SPEC):\n * - project scope (preferred) → <projectDir>/.agents/mcp.json\n * - user scope → ~/.agents/mcp.json\n * Both are JSON, root key \"mcpServers\". There is no separate hook file — the\n * hook \"config path\" is the same mcp.json so the generic doctor/backup behave\n * sensibly.\n *\n * A stdio server entry is the standard `{ type:\"stdio\", command, args, env }`\n * shape. Codebuff supports native `$VAR` interpolation, so `${env:VAR}` refs are\n * rewritten to Codebuff's native `$VAR` token (rewriteEnvRefs) rather than being\n * resolved to literals — secrets are never baked into the config file.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\n\nimport { BaseAdapter } from \"../base.js\";\nimport type { Adapter, InstallContext } from \"../spi.js\";\nimport type {\n ChangeRecord,\n DetectedPlatform,\n HealthCheck,\n HookParadigm,\n PlatformCapabilities,\n PlatformId,\n ServerDef,\n SubagentDef,\n Transport,\n} from \"../../core/types.js\";\nimport { rewriteEnvRefs } from \"../../core/interpolate.js\";\nimport {\n buildWrappedStdio,\n} from \"../../core/spawn.js\";\nimport { renderSkillMd } from \"../claude-code/render.js\";\n\nconst HOST: PlatformId = \"codebuff\";\nconst MCP_ROOT_KEY = \"mcpServers\";\n\n/**\n * Render `${env:VAR}`/`${env:VAR:-default}` into Codebuff's native `$VAR` token.\n *\n * When the portable ref carried a default (`${env:VAR:-fallback}`), Codebuff's\n * native `$VAR` token cannot express it — so a bare native token would silently\n * DROP the default. Instead, resolve the default at install time: emit the live\n * value when VAR is set and non-empty, else the literal fallback. The native\n * token is only emitted when there is no default to preserve.\n */\nconst toNativeRef = (name: string, def?: string): string => {\n if (def !== undefined) {\n const v = process.env[name];\n return v != null && v !== \"\" ? v : def;\n }\n return `$${name}`;\n};\n\n/** Recursively rewrite every `${env:VAR}` ref in a JSON-ish value to `$VAR`. */\nfunction rewriteEnvRefsDeep<T>(value: T): T {\n if (typeof value === \"string\") {\n return rewriteEnvRefs(value, toNativeRef) as unknown as T;\n }\n if (Array.isArray(value)) {\n return value.map((v) => rewriteEnvRefsDeep(v)) as unknown as T;\n }\n if (value && typeof value === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) out[k] = rewriteEnvRefsDeep(v);\n return out as T;\n }\n return value;\n}\n\n/**\n * Render one AgentDefinition field as a ` key: value,` line for the emitted\n * `.agents/<id>.ts` module. The value is serialized with JSON.stringify (correct\n * string/array/object escaping); a known-identifier key is emitted unquoted, and\n * anything else (only reachable via `extra`) is quoted. Multi-line JSON (arrays /\n * nested objects) is reindented so it sits under the 2-space object body.\n */\nfunction renderAgentField(key: string, value: unknown): string {\n const k = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : JSON.stringify(key);\n const json = JSON.stringify(value, null, 2);\n const v = json.includes(\"\\n\") ? json.replace(/\\n/g, \"\\n \") : json;\n return ` ${k}: ${v},`;\n}\n\n/**\n * Native MCP server entry shapes Codebuff accepts under `mcpServers`.\n * A stdio entry is tagged with `type:\"stdio\"`; remote transports carry a `url`.\n */\ninterface CodebuffStdioServer {\n type: \"stdio\";\n command: string;\n args?: string[];\n env?: Record<string, string>;\n}\ninterface CodebuffHttpServer {\n type: \"http\";\n url: string;\n headers?: Record<string, string>;\n}\n\nexport class CodebuffAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"Codebuff\";\n readonly paradigm: HookParadigm = \"mcp-only\";\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 // Codebuff 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 // Codebuff registers stdio and Streamable HTTP MCP servers.\n transports: [\"stdio\", \"http\"],\n // Content surfaces: Codebuff reads AgentSkills from\n // <configDir>/skills/<name>/SKILL.md (configDir is .agents, so the path is\n // .agents/skills/<name>/SKILL.md). Verified against codebuff source\n // sdk/src/skills/load-skills.ts — the frontmatter `name` MUST equal the dir\n // name. Commands have no native Codebuff surface. Subagents ARE natively\n // supported — executable .agents/*.ts AgentDefinition modules (codebuff docs:\n // \"Create a new TypeScript file in .agents/\") — and are now WIRED:\n // installSubagents emits one `.agents/<id>.ts` AgentDefinition module per\n // declared subagent (PROJECT scope; see renderSubagent), each\n // default-exporting the AgentDefinition object WITHOUT the type-only\n // `agent-definition` import (erased at runtime; emitting it would only couple\n // the module to a generated types file that may not exist).\n supportsSkills: true,\n supportsSubagents: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userDir = join(homedir(), \".agents\");\n const userMcp = join(userDir, \"mcp.json\");\n const projDir = join(projectDir, \".agents\");\n const projMcp = join(projDir, \"mcp.json\");\n\n const userInstalled = existsSync(userDir) || existsSync(userMcp);\n const projInstalled = existsSync(projDir) || existsSync(projMcp);\n const installed = userInstalled || projInstalled;\n // Project is the preferred scope; fall back to user when only that matched.\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const configPath = scope === \"project\" ? projMcp : userMcp;\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 ? `found Codebuff config (${scope})`\n : `no .agents config dir at ${userDir} or ${projDir}`,\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, \".agents\")\n : join(homedir(), \".agents\");\n }\n\n getServerConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"mcp.json\");\n }\n\n /**\n * Codebuff has no hook file — hooks are not a thing here. The hook \"config\n * path\" is the same mcp.json so the generic doctor/backup behave sensibly.\n */\n getHookConfigPath(ctx: InstallContext): string {\n return this.getServerConfigPath(ctx);\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 codebuff\"\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 Codebuff's native mcpServers entry. */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): CodebuffStdioServer | CodebuffHttpServer {\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 ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));\n\n // Codebuff supports native `$VAR` interpolation, so rewrite every\n // ${env:VAR} ref to `$VAR` rather than baking literals into the config.\n const entry: CodebuffStdioServer = {\n type: \"stdio\",\n command: rewriteEnvRefsDeep(command),\n };\n if (args.length > 0) entry.args = rewriteEnvRefsDeep(args);\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n return entry;\n }\n\n // http (and any other remote transport) — Codebuff registers a URL.\n const entry: CodebuffHttpServer = {\n type: \"http\",\n url: rewriteEnvRefsDeep(server.url ?? \"\"),\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. Codebuff supports native `$VAR` interpolation, so\n * rewrite `${env:VAR}` references to `$VAR` rather than resolving to literals.\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 rewriteEnvRefsDeep({ ...env });\n }\n\n // ── Content surfaces: 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[\"codebuff\"].skills === false to skip. Both user and project scope\n // are supported (configDir resolves per scope).\n //\n // Native location:\n // skill → <configDir>/skills/<name>/SKILL.md (+ resources)\n // configDir is .agents, so .agents/skills/<name>/SKILL.md. Verified\n // against codebuff source sdk/src/skills/load-skills.ts — the\n // frontmatter `name` MUST equal the dir name.\n\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.getConfigDir(ctx), \"skills\", name);\n }\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 codebuff\" }];\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\"), renderSkillMd(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 // ── Content surfaces: subagents ───────────────────────────────────────────\n // CONTENT-ONLY: pure native-file writers (no runtime dispatch, no home-bin\n // pointer, no telemetry wrap). Idempotent via writeContentFile, reversible via\n // removeContentFile. Honors platforms[\"codebuff\"].subagents === false.\n //\n // Native location: codebuff agents are executable TypeScript modules in the\n // PROJECT .agents/ dir — <projectDir>/.agents/<id>.ts (codebuff docs:\n // \"Create a new TypeScript file in .agents/\"). No user-scope agents dir is\n // documented, so user scope warn-skips (the warp/amp project-scoped precedent).\n\n /** Native subagent module path: <configDir>/<name>.ts (= .agents/<name>.ts). */\n private subagentPath(ctx: InstallContext, name: string): string {\n return join(this.getConfigDir(ctx), `${name}.ts`);\n }\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 codebuff\" }];\n }\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n // codebuff agents live in the PROJECT .agents/ dir; no user-scope agents dir\n // is documented, so user scope warn-skips (mirrors warp/amp project-scoped).\n if (ctx.scope !== \"project\") {\n return [\n {\n platform: this.id,\n action: \"warn\",\n detail:\n \"codebuff subagents are project-scoped only (.agents/*.ts; no documented \" +\n `user-scope agents dir); ${connector.subagents.length} skipped`,\n },\n ];\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 if (ctx.scope !== \"project\") {\n return [\n { platform: this.id, action: \"skip\", detail: \"codebuff subagents are project-scoped only\" },\n ];\n }\n return connector.subagents.map((agent) =>\n this.removeContentFile(this.subagentPath(ctx, agent.name), ctx.dryRun),\n );\n }\n\n /**\n * Render a subagent into a Codebuff `.agents/<id>.ts` AgentDefinition module:\n *\n * const definition = {\n * id: \"<name>\",\n * ...\n * };\n *\n * export default definition;\n *\n * Emitted WITHOUT the `import { AgentDefinition } from './types/agent-definition'`\n * line the docs show: that import is TYPE-ONLY (erased at runtime), so omitting\n * it avoids coupling the module to a generated types file that may not exist —\n * a bare object literal + default export is a complete, valid AgentDefinition.\n *\n * Field mapping (ONLY fields AC's SubagentDef can populate; nothing fabricated):\n * id ← name (already kebab-case → a valid codebuff id)\n * displayName ← name\n * spawnerPrompt ← description (the delegation hint)\n * model ← model (OMITTED when the connector declares none)\n * toolNames ← tools.allow (OMITTED when none declared)\n * instructionsPrompt ← prompt (the system prompt / instructions body)\n * SubagentDef.readonly is NOT mapped: Codebuff expresses tool access through the\n * `toolNames` allowlist and documents no read-only permission flag, and AC has no\n * verified read-only tool taxonomy to synthesize one — so a readonly hint is\n * carried only if the author restricts `tools.allow` themselves (or via `extra`).\n * `extra` is merged LAST as the documented escape hatch — the only way to reach\n * codebuff AgentDefinition fields AC does not model (version, outputMode,\n * spawnableAgents, inputSchema, …); its values come from the connector author,\n * never invented here.\n */\n private renderSubagent(agent: SubagentDef): string {\n const def: Record<string, unknown> = {\n id: agent.name,\n displayName: agent.name,\n spawnerPrompt: agent.description,\n };\n if (agent.model !== undefined) def.model = agent.model;\n const allow = agent.tools?.allow;\n if (allow && allow.length > 0) def.toolNames = [...allow];\n def.instructionsPrompt = agent.prompt;\n if (agent.extra) Object.assign(def, agent.extra);\n\n const body = Object.entries(def)\n .map(([k, v]) => renderAgentField(k, v))\n .join(\"\\n\");\n return `const definition = {\\n${body}\\n};\\n\\nexport default definition;\\n`;\n }\n\n // ── Hooks (unavailable — Codebuff is mcp-only) ────────────────────────────\n\n installHooks(_ctx: InstallContext): ChangeRecord[] {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: \"hooks unavailable (Codebuff 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 (Codebuff is mcp-only)\",\n },\n ];\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 const checks: HealthCheck[] = [\n {\n name: `${this.name}: mcp.json 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 // never writes a server 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 },\n },\n ];\n\n // Content-surface checks: assert presence only for the skills this connector\n // declares (a skill-less connector writes none, so absence is healthy).\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 // Subagent checks: codebuff agents are PROJECT-scoped .agents/*.ts modules,\n // so assert presence only at project scope (user scope warn-skips install).\n if (ctx.scope === \"project\") {\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 return checks;\n }\n}\n\nexport const adapter = new CodebuffAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,YAAY;AAqBrB,IAAM,OAAmB;AACzB,IAAM,eAAe;AAWrB,IAAM,cAAc,CAAC,MAAc,QAAyB;AAC1D,MAAI,QAAQ,QAAW;AACrB,UAAM,IAAI,QAAQ,IAAI,IAAI;AAC1B,WAAO,KAAK,QAAQ,MAAM,KAAK,IAAI;AAAA,EACrC;AACA,SAAO,IAAI,IAAI;AACjB;AAGA,SAAS,mBAAsB,OAAa;AAC1C,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,eAAe,OAAO,WAAW;AAAA,EAC1C;AACA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,IAAI,CAAC,MAAM,mBAAmB,CAAC,CAAC;AAAA,EAC/C;AACA,MAAI,SAAS,OAAO,UAAU,UAAU;AACtC,UAAM,MAA+B,CAAC;AACtC,eAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,KAA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AAE,IAAI,EAAE,QAAQ,QAAQ,QAAQ,cAAc,CAAC,GAAG;AAAA,MAC9F,CAAC;AAAA,IACH;AAGA,QAAI,IAAI,UAAU,WAAW;AAC3B,iBAAW,SAAS,IAAI,UAAU,WAAW;AAC3C,cAAM,IAAI,KAAK,aAAa,KAAK,MAAM,IAAI;AAC3C,eAAO,KAAK;AAAA,UACV,MAAM,GAAG,KAAK,IAAI,cAAc,MAAM,IAAI;AAAA,UAC1C,OAAO,MACL,WAAW,CAAC,IAAI,EAAE,QAAQ,MAAM,QAAQ,EAAE,IAAI,EAAE,QAAQ,QAAQ,QAAQ,cAAc,CAAC,GAAG;AAAA,QAC9F,CAAC;AAAA,MACH;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;AAEO,IAAM,UAAU,IAAI,gBAAgB;AAC3C,IAAO,mBAAQ;","names":["entry"]}
1
+ {"version":3,"sources":["../src/adapters/codebuff/index.ts"],"sourcesContent":["/**\n * adapters/codebuff — Codebuff platform adapter for agent-connector.\n *\n * Codebuff is an **mcp-only** host: it exposes no lifecycle hook system, and MCP\n * is its extensibility mechanism. This adapter therefore installs only the MCP\n * server and reports hooks as unavailable (mirrors the Warp reference path that\n * validates the `mcp-only` paradigm end-to-end).\n *\n * MCP config (SPEC):\n * - project scope (preferred) → <projectDir>/.agents/mcp.json\n * - user scope → ~/.agents/mcp.json\n * Both are JSON, root key \"mcpServers\". There is no separate hook file — the\n * hook \"config path\" is the same mcp.json so the generic doctor/backup behave\n * sensibly.\n *\n * A stdio server entry is the standard `{ type:\"stdio\", command, args, env }`\n * shape. Codebuff supports native `$VAR` interpolation, so `${env:VAR}` refs are\n * rewritten to Codebuff's native `$VAR` token (rewriteEnvRefs) rather than being\n * resolved to literals — secrets are never baked into the config file.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\n\nimport { BaseAdapter } from \"../base.js\";\nimport type { Adapter, InstallContext } from \"../spi.js\";\nimport type {\n ChangeRecord,\n DetectedPlatform,\n HealthCheck,\n HookParadigm,\n PlatformCapabilities,\n PlatformId,\n ServerDef,\n SubagentDef,\n Transport,\n} from \"../../core/types.js\";\nimport { rewriteEnvRefs } from \"../../core/interpolate.js\";\nimport {\n buildWrappedStdio,\n} from \"../../core/spawn.js\";\nimport { renderSkillMd } from \"../claude-code/render.js\";\n\nconst HOST: PlatformId = \"codebuff\";\nconst MCP_ROOT_KEY = \"mcpServers\";\n\n/**\n * Render `${env:VAR}`/`${env:VAR:-default}` into Codebuff's native `$VAR` token.\n *\n * When the portable ref carried a default (`${env:VAR:-fallback}`), Codebuff's\n * native `$VAR` token cannot express it — so a bare native token would silently\n * DROP the default. Instead, resolve the default at install time: emit the live\n * value when VAR is set and non-empty, else the literal fallback. The native\n * token is only emitted when there is no default to preserve.\n */\nconst toNativeRef = (name: string, def?: string): string => {\n if (def !== undefined) {\n const v = process.env[name];\n return v != null && v !== \"\" ? v : def;\n }\n return `$${name}`;\n};\n\n/** Recursively rewrite every `${env:VAR}` ref in a JSON-ish value to `$VAR`. */\nfunction rewriteEnvRefsDeep<T>(value: T): T {\n if (typeof value === \"string\") {\n return rewriteEnvRefs(value, toNativeRef) as unknown as T;\n }\n if (Array.isArray(value)) {\n return value.map((v) => rewriteEnvRefsDeep(v)) as unknown as T;\n }\n if (value && typeof value === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) out[k] = rewriteEnvRefsDeep(v);\n return out as T;\n }\n return value;\n}\n\n/**\n * Render one AgentDefinition field as a ` key: value,` line for the emitted\n * `.agents/<id>.ts` module. The value is serialized with JSON.stringify (correct\n * string/array/object escaping); a known-identifier key is emitted unquoted, and\n * anything else (only reachable via `extra`) is quoted. Multi-line JSON (arrays /\n * nested objects) is reindented so it sits under the 2-space object body.\n */\nfunction renderAgentField(key: string, value: unknown): string {\n const k = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : JSON.stringify(key);\n const json = JSON.stringify(value, null, 2);\n const v = json.includes(\"\\n\") ? json.replace(/\\n/g, \"\\n \") : json;\n return ` ${k}: ${v},`;\n}\n\n/**\n * Native MCP server entry shapes Codebuff accepts under `mcpServers`.\n * A stdio entry is tagged with `type:\"stdio\"`; remote transports carry a `url`.\n */\ninterface CodebuffStdioServer {\n type: \"stdio\";\n command: string;\n args?: string[];\n env?: Record<string, string>;\n}\ninterface CodebuffHttpServer {\n type: \"http\";\n url: string;\n headers?: Record<string, string>;\n}\n\nexport class CodebuffAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"Codebuff\";\n readonly paradigm: HookParadigm = \"mcp-only\";\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 // Codebuff 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 // Codebuff registers stdio and Streamable HTTP MCP servers.\n transports: [\"stdio\", \"http\"],\n // Content surfaces: Codebuff reads AgentSkills from\n // <configDir>/skills/<name>/SKILL.md (configDir is .agents, so the path is\n // .agents/skills/<name>/SKILL.md). Verified against codebuff source\n // sdk/src/skills/load-skills.ts — the frontmatter `name` MUST equal the dir\n // name. Commands have no native Codebuff surface. Subagents ARE natively\n // supported — executable .agents/*.ts AgentDefinition modules (codebuff docs:\n // \"Create a new TypeScript file in .agents/\") — and are now WIRED:\n // installSubagents emits one `.agents/<id>.ts` AgentDefinition module per\n // declared subagent (PROJECT scope; see renderSubagent), each\n // default-exporting the AgentDefinition object WITHOUT the type-only\n // `agent-definition` import (erased at runtime; emitting it would only couple\n // the module to a generated types file that may not exist).\n supportsSkills: true,\n supportsSubagents: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userDir = join(homedir(), \".agents\");\n const userMcp = join(userDir, \"mcp.json\");\n const projDir = join(projectDir, \".agents\");\n const projMcp = join(projDir, \"mcp.json\");\n\n const userInstalled = existsSync(userDir) || existsSync(userMcp);\n const projInstalled = existsSync(projDir) || existsSync(projMcp);\n const installed = userInstalled || projInstalled;\n // Project is the preferred scope; fall back to user when only that matched.\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const configPath = scope === \"project\" ? projMcp : userMcp;\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 ? `found Codebuff config (${scope})`\n : `no .agents config dir at ${userDir} or ${projDir}`,\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, \".agents\")\n : join(homedir(), \".agents\");\n }\n\n getServerConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"mcp.json\");\n }\n\n /**\n * Codebuff has no hook file — hooks are not a thing here. The hook \"config\n * path\" is the same mcp.json so the generic doctor/backup behave sensibly.\n */\n getHookConfigPath(ctx: InstallContext): string {\n return this.getServerConfigPath(ctx);\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 codebuff\"\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 Codebuff's native mcpServers entry. */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): CodebuffStdioServer | CodebuffHttpServer {\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 ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));\n\n // Codebuff supports native `$VAR` interpolation, so rewrite every\n // ${env:VAR} ref to `$VAR` rather than baking literals into the config.\n const entry: CodebuffStdioServer = {\n type: \"stdio\",\n command: rewriteEnvRefsDeep(command),\n };\n if (args.length > 0) entry.args = rewriteEnvRefsDeep(args);\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n return entry;\n }\n\n // http (and any other remote transport) — Codebuff registers a URL.\n const entry: CodebuffHttpServer = {\n type: \"http\",\n url: rewriteEnvRefsDeep(server.url ?? \"\"),\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. Codebuff supports native `$VAR` interpolation, so\n * rewrite `${env:VAR}` references to `$VAR` rather than resolving to literals.\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 rewriteEnvRefsDeep({ ...env });\n }\n\n // ── Content surfaces: 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[\"codebuff\"].skills === false to skip. Both user and project scope\n // are supported (configDir resolves per scope).\n //\n // Native location:\n // skill → <configDir>/skills/<name>/SKILL.md (+ resources)\n // configDir is .agents, so .agents/skills/<name>/SKILL.md. Verified\n // against codebuff source sdk/src/skills/load-skills.ts — the\n // frontmatter `name` MUST equal the dir name.\n\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.getConfigDir(ctx), \"skills\", name);\n }\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 codebuff\" }];\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\"), renderSkillMd(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 // ── Content surfaces: subagents ───────────────────────────────────────────\n // CONTENT-ONLY: pure native-file writers (no runtime dispatch, no home-bin\n // pointer, no telemetry wrap). Idempotent via writeContentFile, reversible via\n // removeContentFile. Honors platforms[\"codebuff\"].subagents === false.\n //\n // Native location: codebuff agents are executable TypeScript modules in the\n // PROJECT .agents/ dir — <projectDir>/.agents/<id>.ts (codebuff docs:\n // \"Create a new TypeScript file in .agents/\"). No user-scope agents dir is\n // documented, so user scope warn-skips (the warp/amp project-scoped precedent).\n\n /** Native subagent module path: <configDir>/<name>.ts (= .agents/<name>.ts). */\n private subagentPath(ctx: InstallContext, name: string): string {\n return join(this.getConfigDir(ctx), `${name}.ts`);\n }\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 codebuff\" }];\n }\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n // codebuff agents live in the PROJECT .agents/ dir; no user-scope agents dir\n // is documented, so user scope warn-skips (mirrors warp/amp project-scoped).\n if (ctx.scope !== \"project\") {\n return [\n {\n platform: this.id,\n action: \"warn\",\n detail:\n \"codebuff subagents are project-scoped only (.agents/*.ts; no documented \" +\n `user-scope agents dir); ${connector.subagents.length} skipped`,\n },\n ];\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 if (ctx.scope !== \"project\") {\n return [\n { platform: this.id, action: \"skip\", detail: \"codebuff subagents are project-scoped only\" },\n ];\n }\n return connector.subagents.map((agent) =>\n this.removeContentFile(this.subagentPath(ctx, agent.name), ctx.dryRun),\n );\n }\n\n /**\n * Render a subagent into a Codebuff `.agents/<id>.ts` AgentDefinition module:\n *\n * const definition = {\n * id: \"<name>\",\n * ...\n * };\n *\n * export default definition;\n *\n * Emitted WITHOUT the `import { AgentDefinition } from './types/agent-definition'`\n * line the docs show: that import is TYPE-ONLY (erased at runtime), so omitting\n * it avoids coupling the module to a generated types file that may not exist —\n * a bare object literal + default export is a complete, valid AgentDefinition.\n *\n * Field mapping (ONLY fields AC's SubagentDef can populate; nothing fabricated):\n * id ← name (already kebab-case → a valid codebuff id)\n * displayName ← name\n * spawnerPrompt ← description (the delegation hint)\n * model ← model (OMITTED when the connector declares none)\n * toolNames ← tools.allow (OMITTED when none declared)\n * instructionsPrompt ← prompt (the system prompt / instructions body)\n * SubagentDef.readonly is NOT mapped: Codebuff expresses tool access through the\n * `toolNames` allowlist and documents no read-only permission flag, and AC has no\n * verified read-only tool taxonomy to synthesize one — so a readonly hint is\n * carried only if the author restricts `tools.allow` themselves (or via `extra`).\n * `extra` is merged LAST as the documented escape hatch — the only way to reach\n * codebuff AgentDefinition fields AC does not model (version, outputMode,\n * spawnableAgents, inputSchema, …); its values come from the connector author,\n * never invented here.\n */\n private renderSubagent(agent: SubagentDef): string {\n const def: Record<string, unknown> = {\n id: agent.name,\n displayName: agent.name,\n spawnerPrompt: agent.description,\n };\n if (agent.model !== undefined) def.model = agent.model;\n const allow = agent.tools?.allow;\n if (allow && allow.length > 0) def.toolNames = [...allow];\n def.instructionsPrompt = agent.prompt;\n if (agent.extra) Object.assign(def, agent.extra);\n\n const body = Object.entries(def)\n .map(([k, v]) => renderAgentField(k, v))\n .join(\"\\n\");\n return `const definition = {\\n${body}\\n};\\n\\nexport default definition;\\n`;\n }\n\n // ── Hooks (unavailable — Codebuff is mcp-only) ────────────────────────────\n\n installHooks(_ctx: InstallContext): ChangeRecord[] {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: \"hooks unavailable (Codebuff 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 (Codebuff is mcp-only)\",\n },\n ];\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 const checks: HealthCheck[] = [\n {\n name: `${this.name}: mcp.json 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 // never writes a server 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 },\n },\n ];\n\n // Content-surface checks: assert presence only for the skills this connector\n // declares (a skill-less connector writes none, so absence is healthy).\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 // Subagent checks: codebuff agents are PROJECT-scoped .agents/*.ts modules,\n // so assert presence only at project scope (user scope warn-skips install).\n if (ctx.scope === \"project\") {\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 return checks;\n }\n}\n\nexport const adapter = new CodebuffAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,YAAY;AAqBrB,IAAM,OAAmB;AACzB,IAAM,eAAe;AAWrB,IAAM,cAAc,CAAC,MAAc,QAAyB;AAC1D,MAAI,QAAQ,QAAW;AACrB,UAAM,IAAI,QAAQ,IAAI,IAAI;AAC1B,WAAO,KAAK,QAAQ,MAAM,KAAK,IAAI;AAAA,EACrC;AACA,SAAO,IAAI,IAAI;AACjB;AAGA,SAAS,mBAAsB,OAAa;AAC1C,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,eAAe,OAAO,WAAW;AAAA,EAC1C;AACA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,IAAI,CAAC,MAAM,mBAAmB,CAAC,CAAC;AAAA,EAC/C;AACA,MAAI,SAAS,OAAO,UAAU,UAAU;AACtC,UAAM,MAA+B,CAAC;AACtC,eAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,KAAK,EAAG,KAAI,CAAC,IAAI,mBAAmB,CAAC;AACzE,WAAO;AAAA,EACT;AACA,SAAO;AACT;AASA,SAAS,iBAAiB,KAAa,OAAwB;AAC7D,QAAM,IAAI,6BAA6B,KAAK,GAAG,IAAI,MAAM,KAAK,UAAU,GAAG;AAC3E,QAAM,OAAO,KAAK,UAAU,OAAO,MAAM,CAAC;AAC1C,QAAM,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,QAAQ,OAAO,MAAM,IAAI;AAC9D,SAAO,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EAAE,QAAQ,MAAM,QAAQ,EAAE,IAAI,EAAE,QAAQ,QAAQ,QAAQ,cAAc,CAAC,GAAG;AAAA,QAC9F,CAAC;AAAA,MACH;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;AAEO,IAAM,UAAU,IAAI,gBAAgB;AAC3C,IAAO,mBAAQ;","names":["entry"]}
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- codexConfigHome
4
- } from "./chunk-UM5S7DKK.js";
5
2
  import {
6
3
  writeTomlString
7
4
  } from "./chunk-OPXAP3AC.js";
5
+ import {
6
+ codexConfigHome
7
+ } from "./chunk-UM5S7DKK.js";
8
8
  import {
9
9
  normalizeSessionSource
10
10
  } from "./chunk-H53QZQJI.js";
@@ -14,12 +14,10 @@ import {
14
14
  import {
15
15
  BaseAdapter,
16
16
  removeFromObjectMap,
17
- upsertInObjectMap
18
- } from "./chunk-3I7UG52L.js";
19
- import {
20
17
  renderCommandMd,
21
- renderSkillMd
22
- } from "./chunk-IEGR4TP3.js";
18
+ renderSkillMd,
19
+ upsertInObjectMap
20
+ } from "./chunk-A767JFHW.js";
23
21
  import {
24
22
  buildHomeBinHookCommand,
25
23
  buildWrappedStdio
@@ -74,7 +72,9 @@ var CodexAdapter = class extends BaseAdapter {
74
72
  // (developers.openai.com/codex/hooks). Observational only — the reply
75
73
  // contract mirrors PreCompact (cannot block/modify a completed compaction).
76
74
  postCompact: true,
77
- canModifyArgs: false,
75
+ // PreToolUse updatedInput rewrite is honored upstream (paired with
76
+ // permissionDecision:"allow"); PostToolUse output rewrite is not (see header).
77
+ canModifyArgs: true,
78
78
  canModifyOutput: false,
79
79
  canInjectSessionContext: true,
80
80
  transports: ["stdio", "http"],
@@ -632,7 +632,22 @@ var CodexAdapter = class extends BaseAdapter {
632
632
  }
633
633
  return { exitCode: 0 };
634
634
  }
635
- if (response.additionalContext && (event === "SessionStart" || event === "PostToolUse")) {
635
+ if (response.decision === "modify") {
636
+ if (event === "PreToolUse" && response.updatedInput) {
637
+ return {
638
+ exitCode: 0,
639
+ stdout: JSON.stringify({
640
+ hookSpecificOutput: {
641
+ hookEventName: "PreToolUse",
642
+ permissionDecision: "allow",
643
+ updatedInput: response.updatedInput
644
+ }
645
+ })
646
+ };
647
+ }
648
+ return { exitCode: 0 };
649
+ }
650
+ if (response.additionalContext && (event === "SessionStart" || event === "PostToolUse" || event === "PreToolUse")) {
636
651
  return {
637
652
  exitCode: 0,
638
653
  stdout: JSON.stringify({
@@ -722,4 +737,4 @@ export {
722
737
  adapter,
723
738
  codex_default as default
724
739
  };
725
- //# sourceMappingURL=codex-5CZR5XKX.js.map
740
+ //# sourceMappingURL=codex-FLU37DV3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapters/codex/index.ts"],"sourcesContent":["/**\n * adapters/codex — Codex CLI platform adapter for agent-connector.\n *\n * Codex CLI hook paradigm is \"json-stdio\": the host pipes a JSON payload to a\n * command on stdin and reads JSON/exit-code back — the same wire protocol as\n * Claude Code (PascalCase fields, `hookSpecificOutput` reply wrapper).\n *\n * Two native config files live under the Codex config dir\n * (`$CODEX_HOME` || `~/.codex`, mirrored to `<projectDir>/.codex` for project\n * scope):\n * - config.toml → `[mcp_servers.<id>]` MCP registration (TOML, NO native\n * interpolation, so env-refs are resolved to literals at install time).\n * - hooks.json → Claude-compatible hook registration ({ matcher, hooks }).\n *\n * Grounded in context-mode's proven Codex adapter (configs/codex/{config.toml,\n * hooks.json}, src/adapters/codex/*) — exact TOML MCP shape + hook JSON schema.\n *\n * Codex capabilities (upstream, verified against openai/codex source at the\n * stable release tags noted):\n * - PreToolUse `updatedInput` rewrite IS honored (PR #20527, commit d08906a9,\n * stable since codex 0.131.0; applied in the shell/mcp/apply_patch tool\n * handlers, confirmed present through 0.141.0) — hence canModifyArgs is now\n * TRUE. Codex's output_parser.rs requires the rewrite to be paired with\n * `permissionDecision:\"allow\"` (an allow WITHOUT updatedInput, and an\n * updatedInput WITHOUT allow, are both rejected as invalid), so \"modify\"\n * emits the allow+updatedInput envelope together. The still-open tracking\n * issue openai/codex#18491 is now scoped to a NARROWER gap — read_file/grep\n * have no PreToolUse handler yet — not to updatedInput itself, which works\n * for every tool that fires PreToolUse (shell/Bash, apply_patch, MCP).\n * - PostToolUse `updatedMCPToolOutput` is still explicitly rejected as\n * \"unsupported\" by output_parser.rs (no output-rewrite field on\n * PostToolUseOutput at 0.141.0) — hence canModifyOutput stays FALSE.\n *\n * E1 extension events (verified against developers.openai.com/codex/hooks):\n * - PermissionRequest — native, decision-capable via the nested\n * hookSpecificOutput.decision{behavior:\"allow\"|\"deny\", message?} envelope.\n * Codex docs: updatedInput / updatedPermissions / interrupt FAIL CLOSED on\n * this event, so they are never emitted here.\n * - SubagentStart — native; hookSpecificOutput.additionalContext is injected\n * as developer context for the subagent (not blockable).\n * - SubagentStop — native; the documented continuation shape is the TOP-LEVEL\n * {\"decision\":\"block\",\"reason\"} (Stop semantics: keeps the subagent going).\n * - PostToolUseFailure — NO Codex analog (PostToolUse only); declared hooks\n * for it warn-skip at install and the capability flag stays unset.\n * - PostCompact — native (Codex's hook system fires both PreCompact and\n * PostCompact); observe-only, normalizing the `trigger` (manual|auto)\n * exactly like PreCompact, with a passthrough formatReply.\n */\n\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\nimport TOML from \"@iarna/toml\";\n\nimport type {\n ChangeRecord,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n PlatformCapabilities,\n PlatformId,\n ServerDef,\n SkillDef,\n SubagentDef,\n} from \"../../core/types.js\";\nimport { ensureDir } from \"../../core/paths.js\";\nimport { codexConfigHome } from \"../../core/host-paths.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport {\n removeFromObjectMap,\n upsertInObjectMap,\n type ObjectMapCodec,\n} from \"../../core/object-map.js\";\nimport { writeTomlString } from \"../../core/toml.js\";\nimport {\n buildHomeBinHookCommand,\n buildWrappedStdio,\n} from \"../../core/spawn.js\";\nimport { renderCommandMd, renderSkillMd } from \"../claude-code/render.js\";\nimport { normalizeSessionSource } from \"../claude-code/wire.js\";\nimport { BaseAdapter, type HookMergeDescriptor } from \"../base.js\";\nimport type {\n HookReply,\n InstallContext,\n MemoryTarget,\n NormalizedEvent,\n} from \"../spi.js\";\n\n// ─────────────────────────────────────────────────────────────────────────\n// Native shapes\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Raw Codex hook payload (PascalCase event, snake_case fields — Claude-style). */\ninterface CodexHookInput {\n tool_name?: string;\n tool_input?: Record<string, unknown>;\n tool_response?: string;\n session_id?: string;\n cwd?: string;\n hook_event_name?: string;\n source?: string;\n prompt?: string;\n is_error?: boolean;\n stop_hook_active?: boolean;\n trigger?: string;\n message?: string;\n // PostToolUseFailure-style failure field. Codex has NO failure event today;\n // parsed defensively only (the Claude-compatible wire would carry it).\n error?: string;\n // SubagentStart / SubagentStop (agent_type is the matcher subject).\n agent_id?: string;\n agent_type?: string;\n // SubagentStop only — the subagent's own transcript + final message.\n agent_transcript_path?: string;\n last_assistant_message?: string;\n}\n\n/** One hook entry inside hooks.json (Claude-compatible). */\ninterface CodexHookEntry {\n matcher?: string;\n hooks: Array<{ type: \"command\"; command: string }>;\n}\n\n/** Rendered `[mcp_servers.<id>]` table — string env table, no interpolation. */\ninterface CodexMcpEntry {\n // stdio transport\n command?: string;\n args?: string[];\n env?: Record<string, string>;\n // streamable HTTP transport (remote): codex infers the transport from `url`\n // (no explicit transport key). Verified against codex-cli 0.139.0.\n url?: string;\n bearer_token_env_var?: string;\n http_headers?: Record<string, string>;\n}\n\n/**\n * Codex hook events agent-connector registers, in the canonical → native order.\n * Codex uses the same PascalCase event names as Claude Code; the home-binary\n * hook command receives the lowercased event token.\n */\nconst CODEX_HOOK_EVENTS = [\n \"SessionStart\",\n \"PreToolUse\",\n \"PostToolUse\",\n \"PreCompact\",\n \"UserPromptSubmit\",\n \"Stop\",\n \"PermissionRequest\",\n \"SubagentStart\",\n \"SubagentStop\",\n \"PostCompact\",\n] as const;\n\ntype CodexHookEventName = (typeof CODEX_HOOK_EVENTS)[number];\n\n/**\n * Newer canonical events with NO Codex analog: Codex ships PostToolUse only —\n * there is no failure event on the live hooks page. Declared hooks for these\n * warn-skip at install so the degradation is reported, never silent. (The\n * legacy SessionEnd / Notification silent filter predates this convention and\n * is deliberately left untouched.)\n */\nconst WARN_SKIP_EVENTS: ReadonlySet<HookEventName> = new Set([\"PostToolUseFailure\"]);\n\n/**\n * PreToolUse matcher — canonical Codex tool names + bare MCP tool names +\n * external MCP catch-all literal. Charset-clean ([A-Za-z0-9_|] only) so Codex's\n * Rust `regex` exact-matcher short-circuits (no look-around, which Codex\n * rejects at boot). Copied from context-mode's proven matcher.\n */\nconst PRE_TOOL_USE_MATCHER =\n \"local_shell|shell|shell_command|exec_command|Bash|Shell|apply_patch|Edit|Write|grep_files|mcp__\";\n\n// ─────────────────────────────────────────────────────────────────────────\n// Adapter\n// ─────────────────────────────────────────────────────────────────────────\n\nexport class CodexAdapter extends BaseAdapter {\n readonly id: PlatformId = \"codex\";\n readonly name = \"Codex CLI\";\n readonly paradigm: HookParadigm = \"json-stdio\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: AGENTS.md-first managed block. memoryTargets below probes\n // AGENTS.override.md first (it shadows AGENTS.md per directory on codex).\n supportsMemory: true,\n preToolUse: true,\n postToolUse: true,\n preCompact: true,\n sessionStart: true,\n sessionEnd: false,\n userPromptSubmit: true,\n stop: true,\n notification: false,\n // E1 events: PermissionRequest (decision-capable) + SubagentStart/Stop are\n // Codex-native. postToolUseFailure stays unset — Codex has no failure event,\n // so a declared hook for it warn-skips at install.\n permissionRequest: true,\n subagentStart: true,\n subagentStop: true,\n // PostCompact: Codex's hook system fires both PreCompact and PostCompact\n // (developers.openai.com/codex/hooks). Observational only — the reply\n // contract mirrors PreCompact (cannot block/modify a completed compaction).\n postCompact: true,\n // PreToolUse updatedInput rewrite is honored upstream (paired with\n // permissionDecision:\"allow\"); PostToolUse output rewrite is not (see header).\n canModifyArgs: true,\n canModifyOutput: false,\n canInjectSessionContext: true,\n transports: [\"stdio\", \"http\"],\n // Content surfaces: Codex implements all three.\n // command → ~/.codex/prompts/<name>.md (md+frontmatter, USER SCOPE ONLY)\n // skill → project: .codex/skills/<name>/SKILL.md · user: ~/.agents/skills/<name>/SKILL.md\n // subagent → <codexDir>/agents/<name>.toml (TOML)\n supportsCommands: true,\n supportsSkills: true,\n supportsSubagents: true,\n };\n\n // ── Detection ──────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userDir = this.userConfigDir();\n const projDir = join(projectDir, \".codex\");\n const userCfg = join(userDir, \"config.toml\");\n const projCfg = join(projDir, \"config.toml\");\n\n const userInstalled = existsSync(userDir) || existsSync(userCfg);\n const projInstalled = existsSync(projDir) || existsSync(projCfg);\n const installed = userInstalled || projInstalled;\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const configPath = scope === \"project\" ? projCfg : userCfg;\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 ? `Found Codex config dir (${scope})`\n : `No .codex config dir at ${userDir} or ${projDir}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Native paths ───────────────────────────────────────────────────────\n\n override getConfigDir(ctx: InstallContext): string {\n if (ctx.scope === \"project\") return join(ctx.projectDir, \".codex\");\n return this.userConfigDir();\n }\n\n override getServerConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"config.toml\");\n }\n\n override getHookConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"hooks.json\");\n }\n\n // ── Memory surface: AGENTS.override.md probe + 32 KiB doc-cap budget ─────\n // Codex reads AGENTS.override.md > AGENTS.md per directory (one file per\n // directory), so when the override file exists OUR block must live there or\n // it is never loaded. Combined project docs are capped at 32 KiB\n // (`project_doc_max_bytes`), hence the ~28 KiB per-file budget warn.\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 budgetBytes = 28 * 1024;\n const dir = ctx.scope === \"project\" ? ctx.projectDir : this.userConfigDir();\n const overrideMd = join(dir, \"AGENTS.override.md\");\n if (existsSync(overrideMd)) {\n return [\n {\n path: overrideMd,\n reason: \"AGENTS.override.md shadows AGENTS.md on codex (one doc per directory)\",\n budgetBytes,\n },\n ];\n }\n return [\n {\n path: join(dir, \"AGENTS.md\"),\n reason:\n ctx.scope === \"project\"\n ? \"AGENTS.md standard (project root; codex is the format's originator)\"\n : \"codex global guidance ($CODEX_HOME/AGENTS.md)\",\n budgetBytes,\n },\n ];\n }\n\n /** `$CODEX_HOME` (tilde-expanded, then resolved) || `~/.codex` for user\n * scope. Shared with marketplace detection via `codexConfigHome` so the\n * config writer and the install probe never target different dirs. */\n private userConfigDir(): string {\n return codexConfigHome();\n }\n\n // ── TOML config IO (override JSON helpers — config.toml is TOML) ─────────\n\n private readToml(path: string): Record<string, unknown> {\n if (!existsSync(path)) return {};\n try {\n return TOML.parse(readFileSync(path, \"utf8\")) as Record<string, unknown>;\n } catch {\n return {};\n }\n }\n\n private writeToml(path: string, data: Record<string, unknown>, dryRun: boolean): void {\n if (dryRun) return;\n ensureDir(dirname(path));\n // @iarna/toml's stringify type wants its JsonMap; our object is structurally compatible.\n writeFileSync(path, TOML.stringify(data as never), \"utf8\");\n }\n\n /** An ObjectMapCodec over config.toml for the core/object-map engine.\n * `isPresentButUnparseable` is `() => false`: readToml fail-softs to {} and the\n * server path has historically coerced/overwritten rather than warn-skip on an\n * unparseable file — preserved here for byte-identical behavior. */\n private tomlObjectMapCodec(): ObjectMapCodec {\n return {\n parse: (path) => this.readToml(path),\n serialize: (path, data, dryRun) => this.writeToml(path, data, dryRun),\n isPresentButUnparseable: () => false,\n };\n }\n\n // ── Install server (config.toml → [mcp_servers.<id>]) ───────────────────\n\n override installServer(ctx: InstallContext): ChangeRecord[] {\n const { connector, dryRun } = ctx;\n const server = this.effectiveServer(ctx);\n const path = this.getServerConfigPath(ctx);\n\n if (!server) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no server declared\" }];\n }\n const isStdio = server.transport === \"stdio\" && !!server.command;\n const isHttp = server.transport === \"http\" && !!server.url;\n if (!isStdio && !isHttp) {\n // Codex config.toml [mcp_servers] supports stdio (command) + streamable\n // HTTP (url). Other remote transports (sse/ws) have no codex analog.\n return [\n {\n platform: this.id,\n action: \"skip\",\n path,\n detail: `transport \"${server.transport}\" not registrable in config.toml (stdio + streamable-http only)`,\n },\n ];\n }\n\n const entry = this.renderMcpEntry(ctx, server);\n\n return [\n upsertInObjectMap({\n codec: this.tomlObjectMapCodec(),\n rootKey: \"mcp_servers\",\n policy: \"coerce\",\n platform: this.id,\n configPath: path,\n entryId: connector.id,\n entry,\n dryRun,\n }),\n ];\n }\n\n override uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const { connector, dryRun } = ctx;\n const path = this.getServerConfigPath(ctx);\n return [\n removeFromObjectMap({\n codec: this.tomlObjectMapCodec(),\n rootKey: \"mcp_servers\",\n policy: \"coerce\",\n platform: this.id,\n configPath: path,\n entryId: connector.id,\n dryRun,\n }),\n ];\n }\n\n // ── Install hooks (hooks.json) ──────────────────────────────────────────\n\n override installHooks(ctx: InstallContext): ChangeRecord[] {\n const path = this.getHookConfigPath(ctx);\n const events = this.effectiveHookEvents(ctx);\n const dropped = this.warnSkipHookEvents(ctx);\n\n if (events.length === 0 && dropped.length === 0) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no hooks declared\" }];\n }\n\n // HOST-ORDERED pending: warn-skip events (mapEvent → undefined → warn) FIRST,\n // then the supported events in CODEX_HOOK_EVENTS order. Events neither\n // supported nor in WARN_SKIP_EVENTS are never enqueued → silently dropped, as\n // before. matcher is \"\" for every item; renderEntry derives the real matcher\n // from the event (PreToolUse/PermissionRequest), never from this field.\n const pending = [\n ...dropped.map((event) => ({ event: event as string, matcher: \"\" })),\n ...events.map((event) => ({ event: event as string, matcher: \"\" })),\n ];\n return this.upsertHookEntries(ctx, path, pending, this.hookDescriptor(ctx));\n }\n\n override uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n return this.removeHookEntries(ctx, this.getHookConfigPath(ctx), this.hookDescriptor(ctx));\n }\n\n /**\n * Codex hook-merge policy for the shared object-map engine. EVENT-SPECIFIC by\n * construction: every observable (coerce root + bucket, the path-normalized\n * per-event ownership find, the event-derived matcher with `hooks`-then-\n * `matcher` key order, the BARE `hooks.<event>` skip/remove details with NO\n * count, the warn wording, and the absent/no-match skips) is carried here so\n * the engine reproduces the prior in-adapter loop byte-for-byte.\n */\n private hookDescriptor(ctx: InstallContext): HookMergeDescriptor<CodexHookEntry> {\n return {\n // Codex's server path coerces a malformed root; the hook path matches it.\n malformedPolicy: \"coerce\",\n // Supported event → identity; a WARN_SKIP event (PostToolUseFailure, which\n // is the only thing `dropped` ever contains) → undefined → warn.\n mapEvent: (e) =>\n (CODEX_HOOK_EVENTS as readonly string[]).includes(e) ? e : undefined,\n unmappedWarnDetail: (e) => `${e} has no Codex hook equivalent — skipped`,\n renderEntry: (event, _matcher, command) => {\n const entry: CodexHookEntry = { hooks: [{ type: \"command\", command }] };\n // KEY ORDER: hooks THEN matcher. Matcher is EVENT-derived, not from the\n // connector's declared matcher: PermissionRequest matches tool names like\n // PreToolUse (charset-clean), everything else registers \"\" (all).\n entry.matcher =\n event === \"PreToolUse\" || event === \"PermissionRequest\" ? PRE_TOOL_USE_MATCHER : \"\";\n return entry;\n },\n // Idempotency find for the CANONICAL event the engine built `command` from —\n // path-normalized, exact-command, the body of isOurEntry's command check.\n entryOwnsCommand: (entry, command) =>\n Array.isArray(entry.hooks) &&\n entry.hooks.some(\n (h) => (h.command ?? \"\").replace(/\\\\/g, \"/\") === command.replace(/\\\\/g, \"/\"),\n ),\n // FLAT whole-entry removal, EVENT-SPECIFIC: isOurEntry rebuilds our command\n // from the event key being stripped, so a SubagentStop entry is never matched\n // while iterating the PreToolUse bucket.\n ownsEntryForRemove: (c, event) => (entry) =>\n this.isOurEntry(c, event as CodexHookEventName, entry),\n skipDetail: (e) => `hooks.${e}`,\n removeDetail: (e, _n) => `hooks.${e}`,\n absentDetail: \"no hooks.json\",\n noMatchDetail: \"no agent-connector hooks present\",\n // Uninstall scans EXACTLY codex's fixed event set (not Object.keys), so a\n // home-bin command hand-placed under a foreign event key is left untouched —\n // byte-identical to the prior `for (const event of CODEX_HOOK_EVENTS)` loop.\n removeEventKeys: CODEX_HOOK_EVENTS,\n };\n }\n\n // ── Health checks (default doctor renders these) ────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const path = this.getServerConfigPath(ctx);\n const id = ctx.connector.id;\n const checks: HealthCheck[] = [\n {\n name: `${this.name}: config.toml exists`,\n check: () =>\n existsSync(path)\n ? { status: \"OK\", detail: path }\n : { status: \"FAIL\", detail: `not found: ${path}` },\n },\n {\n name: `${this.name}: mcp_servers.${id} registered`,\n check: () => {\n // Only assert what the connector declares (same rule as the\n // content-surface checks below): a server-less connector — e.g. a\n // catalog-only bundle of agents/skills/commands — never writes an\n // [mcp_servers.<id>] table, so its absence is healthy.\n if (!ctx.connector.server) {\n return { status: \"OK\", detail: \"no MCP server declared\" };\n }\n const cfg = this.readToml(path);\n const bucket = cfg[\"mcp_servers\"];\n const present =\n typeof bucket === \"object\" &&\n bucket !== null &&\n id in (bucket as Record<string, unknown>);\n return present\n ? { status: \"OK\", detail: `mcp_servers.${id}` }\n : { status: \"FAIL\", detail: `mcp_servers.${id} not found in ${path}` };\n },\n },\n ];\n\n // Content-surface checks: assert presence only for surfaces this connector\n // declares. Codex commands are user-scope only, so a project-scope install\n // won't have written them — only check command files in user scope.\n if (ctx.scope !== \"project\") {\n for (const cmd of ctx.connector.commands) {\n const p = this.commandPath(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 }\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 return checks;\n }\n\n // ── Content surfaces: commands / skills / subagents ──────────────────────\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[\"codex\"] per-surface false to skip.\n //\n // Native locations:\n // command → ~/.codex/prompts/<name>.md md+frontmatter(description,argument-hint)\n // USER SCOPE ONLY — project scope yields a single \"warn\".\n // skill → project: <projectDir>/.codex/skills/<name>/SKILL.md (+ resources)\n // user: ~/.agents/skills/<name>/SKILL.md (~/.codex/skills is deprecated)\n // subagent → <codexDir>/agents/<name>.toml TOML via writeTomlString\n\n /** Command files always live under the USER codex dir: ~/.codex/prompts. */\n private commandPath(name: string): string {\n return join(this.userConfigDir(), \"prompts\", `${name}.md`);\n }\n private skillDir(ctx: InstallContext, name: string): string {\n // Project scope: <projectDir>/.codex/skills/<name> — the Project config-layer\n // skills root (codex-rs/core-skills/src/loader.rs, ConfigLayerSource::Project),\n // NOT deprecated. User scope: $HOME/.agents/skills/<name> — codex's CURRENT\n // user skills root. The older $CODEX_HOME/skills (~/.codex/skills) is still\n // read but the loader labels it a \"Deprecated user skills location, kept for\n // backward compatibility\". .agents is anchored to the OS home (home_dir), NOT\n // $CODEX_HOME — so use homedir() here, never userConfigDir() (which honors\n // CODEX_HOME).\n if (ctx.scope === \"project\") return join(this.getConfigDir(ctx), \"skills\", name);\n return join(homedir(), \".agents\", \"skills\", name);\n }\n private subagentPath(ctx: InstallContext, name: string): string {\n return join(this.getConfigDir(ctx), \"agents\", `${name}.toml`);\n }\n\n // ── Commands (USER SCOPE ONLY) ───────────────────────────────────────────\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 codex\" }];\n }\n if (ctx.scope === \"project\") {\n return [{ platform: this.id, action: \"warn\", detail: \"codex commands are user-scope only\" }];\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(cmd.name),\n renderCommandMd(cmd, { includeToolsAndModel: false }),\n ctx.dryRun,\n ),\n );\n }\n\n override uninstallCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (ctx.scope === \"project\") {\n return [{ platform: this.id, action: \"warn\", detail: \"codex commands are user-scope only\" }];\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.removeContentFile(this.commandPath(cmd.name), ctx.dryRun),\n );\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 codex\" }];\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 const rendered = renderSkillMd(skill);\n changes.push(this.writeContentFile(join(dir, \"SKILL.md\"), rendered, ctx.dryRun));\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 // Migrate away an AC-owned copy at the deprecated user skills root so the\n // skill is not double-registered after the move to ~/.agents/skills.\n changes.push(...this.migrateDeprecatedUserSkill(ctx, skill, rendered));\n }\n return changes;\n }\n\n /**\n * One-time, opt-out-safe migration: prior AC versions wrote user-scope skills\n * to the now-deprecated $CODEX_HOME/skills/<name> root, which codex STILL reads\n * (kept for backward compatibility). Once we write the same skill to the current\n * ~/.agents/skills root, codex would register it TWICE (same frontmatter name,\n * two User-scope roots). If a SKILL.md exists at the deprecated path AND is\n * byte-identical to what we render — i.e. AC-owned, not hand-authored — remove\n * it (and its now-empty dir). The content-equality guard guarantees we never\n * delete a skill a user placed there by hand. No-op for project scope (where\n * .codex/skills is the valid, non-deprecated Project config-layer path) and when\n * a custom CODEX_HOME would make the deprecated path coincide with the new one.\n */\n private migrateDeprecatedUserSkill(\n ctx: InstallContext,\n skill: SkillDef,\n rendered: string,\n ): ChangeRecord[] {\n if (ctx.scope === \"project\") return [];\n const deprecated = join(this.userConfigDir(), \"skills\", skill.name, \"SKILL.md\");\n // Never touch the file we just wrote (pathological CODEX_HOME === ~/.agents).\n if (deprecated === join(this.skillDir(ctx, skill.name), \"SKILL.md\")) return [];\n if (!existsSync(deprecated)) return [];\n if (readFileSync(deprecated, \"utf8\") !== rendered) return []; // hand-authored — leave it\n return [\n this.removeContentFile(deprecated, ctx.dryRun),\n this.removeDirIfEmpty(dirname(deprecated), ctx.dryRun),\n ];\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 // ── Subagents (TOML) ─────────────────────────────────────────────────────\n\n override installSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[this.id]?.subagents === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"subagents disabled for codex\" }];\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(this.subagentPath(ctx, agent.name), this.renderSubagent(agent), ctx.dryRun),\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 /**\n * Render a subagent to a Codex agent TOML file:\n * { name, description, developer_instructions: prompt, model }.\n * model is omitted when undefined so Codex applies its default.\n */\n private renderSubagent(agent: SubagentDef): string {\n const table: Record<string, unknown> = {\n name: agent.name,\n description: agent.description,\n developer_instructions: agent.prompt,\n };\n if (agent.model !== undefined) table.model = agent.model;\n if (agent.extra) Object.assign(table, agent.extra);\n return writeTomlString(table);\n }\n\n // ── Runtime dispatch ────────────────────────────────────────────────────\n\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as CodexHookInput;\n const base = {\n hostPlatform: this.id,\n connectorId: \"\",\n sessionId: input.session_id ?? `pid-${process.ppid}`,\n projectDir: input.cwd ?? process.env.CODEX_PROJECT_DIR ?? process.cwd(),\n raw,\n };\n\n switch (event) {\n case \"PreToolUse\":\n return {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n };\n case \"PostToolUse\":\n return {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n toolOutput: input.tool_response,\n isError: input.is_error ?? false,\n };\n case \"SessionStart\":\n return { ...base, source: normalizeSessionSource(input.source) };\n case \"SessionEnd\":\n return { ...base, reason: input.message };\n case \"UserPromptSubmit\":\n return { ...base, prompt: input.prompt ?? \"\" };\n case \"PreCompact\":\n return { ...base, trigger: input.trigger === \"manual\" ? \"manual\" : \"auto\" };\n case \"PostCompact\":\n // Post-compaction sibling of PreCompact — same `trigger` normalization\n // (manual|auto), observe-only. Codex's PostCompact payload mirrors\n // PreCompact's; everything else rides on `raw`.\n return { ...base, trigger: input.trigger === \"manual\" ? \"manual\" : \"auto\" };\n case \"Stop\":\n return { ...base, stopHookActive: input.stop_hook_active ?? false };\n case \"Notification\":\n return { ...base, message: input.message ?? \"\" };\n case \"PermissionRequest\":\n // Codex documents tool_name/tool_input (+tool_input.description); it has\n // no permission_suggestions field, so the normalized optional stays unset.\n return {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n };\n case \"PostToolUseFailure\":\n // No Codex analog — never fired natively. Parsed defensively (Claude-\n // compatible wire) so a manual `hook codex PostToolUseFailure` invocation\n // still normalizes instead of throwing.\n return {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n error: input.error ?? \"\",\n };\n case \"SubagentStart\":\n return {\n ...base,\n ...(typeof input.agent_id === \"string\" ? { agentId: input.agent_id } : {}),\n ...(typeof input.agent_type === \"string\" ? { agentType: input.agent_type } : {}),\n };\n case \"SubagentStop\":\n // agent_id/agent_type stay optional — never depend on hosts populating\n // them on stop (the Claude-family SDK quirk).\n return {\n ...base,\n ...(typeof input.agent_id === \"string\" ? { agentId: input.agent_id } : {}),\n ...(typeof input.agent_type === \"string\" ? { agentType: input.agent_type } : {}),\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 }\n }\n\n formatReply(event: HookEventName, response: HookResponse): HookReply {\n // Codex (like Claude Code) reads a `hookSpecificOutput` JSON wrapper from\n // stdout; exit code 0 = allow. Fields the host cannot honor are dropped.\n\n // PermissionRequest uses Codex's nested decision{behavior} envelope and is\n // the ONE event where an EXPLICIT \"allow\" is an ACTIVE grant (suppresses the\n // approval prompt). ask/context/void → NO decision output: fall through to\n // the normal approval flow (the prompt IS the ask). Codex docs: updatedInput\n // / updatedPermissions / interrupt FAIL CLOSED on this event, so \"modify\"\n // also falls through — emitting a bare allow would grant the ORIGINAL input\n // the handler wanted rewritten.\n if (event === \"PermissionRequest\") {\n if (response.decision === \"deny\") {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: \"PermissionRequest\",\n decision: {\n behavior: \"deny\",\n message: response.reason ?? \"Blocked by hook\",\n },\n },\n }),\n };\n }\n if (response.decision === \"allow\") {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: \"PermissionRequest\",\n decision: { behavior: \"allow\" },\n },\n }),\n };\n }\n return { exitCode: 0 };\n }\n\n // SubagentStart is observe/context-only on Codex (continue:false is parsed\n // but does not stop the subagent): \"context\" injects additionalContext as\n // developer context for the SUBAGENT, and a \"deny\" DEGRADES to the same\n // shape carrying the reason.\n if (event === \"SubagentStart\") {\n const context =\n response.decision === \"context\"\n ? response.additionalContext\n : response.decision === \"deny\"\n ? response.reason ?? response.additionalContext\n : undefined;\n if (context) {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: \"SubagentStart\",\n additionalContext: context,\n },\n }),\n };\n }\n return { exitCode: 0 };\n }\n\n if (response.decision === \"deny\") {\n // PreToolUse deny is honored; other events fail-open to allow.\n if (event === \"PreToolUse\") {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: \"PreToolUse\",\n permissionDecision: \"deny\",\n permissionDecisionReason: response.reason ?? \"Blocked by hook\",\n },\n }),\n };\n }\n // SubagentStop deny = Stop semantics: the documented continuation shape is\n // the TOP-LEVEL {\"decision\":\"block\",\"reason\"} (keeps the subagent going\n // with `reason` as its next instruction).\n if (event === \"SubagentStop\") {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n decision: \"block\",\n reason: response.reason ?? \"Blocked by hook\",\n }),\n };\n }\n return { exitCode: 0 };\n }\n\n // modify → rewrite PreToolUse tool input. Codex applies `updatedInput`\n // (PR #20527, stable since 0.131.0) but its output_parser.rs only accepts it\n // when paired with permissionDecision:\"allow\" — emitting updatedInput alone\n // (the Claude Code shape) is rejected as \"updatedInput without\n // permissionDecision:allow\", and an allow alone is rejected too, so the pair\n // is emitted together. Other events fail open (no updatedInput surface).\n if (response.decision === \"modify\") {\n if (event === \"PreToolUse\" && response.updatedInput) {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: \"PreToolUse\",\n permissionDecision: \"allow\",\n updatedInput: response.updatedInput,\n },\n }),\n };\n }\n return { exitCode: 0 };\n }\n\n // Context injection: honored on SessionStart, PostToolUse, and PreToolUse\n // (additionalContext — PreToolUse support shipped via PR #20692, stable since\n // codex 0.130.0; injected independent of any permission decision).\n // (SubagentStop accepts only the common output fields — no additionalContext.)\n if (\n response.additionalContext &&\n (event === \"SessionStart\" || event === \"PostToolUse\" || event === \"PreToolUse\")\n ) {\n return {\n exitCode: 0,\n stdout: JSON.stringify({\n hookSpecificOutput: {\n hookEventName: event,\n additionalContext: response.additionalContext,\n },\n }),\n };\n }\n\n // \"allow\" / unsupported-on-Codex (ask) → passthrough.\n return { exitCode: 0 };\n }\n\n // ── Internal helpers ────────────────────────────────────────────────────\n\n /** Resolve the per-platform server override into an effective ServerDef. */\n private effectiveServer(ctx: InstallContext): ServerDef | undefined {\n const override = ctx.connector.platforms[this.id]?.server;\n if (override === false) return undefined;\n const base = ctx.connector.server;\n if (!base) return undefined;\n return override ? { ...base, ...override } : base;\n }\n\n /** Which canonical hook events to register for Codex, honoring overrides. */\n private effectiveHookEvents(ctx: InstallContext): CodexHookEventName[] {\n const override = ctx.connector.platforms[this.id]?.hooks;\n if (override === false) return [];\n return CODEX_HOOK_EVENTS.filter((e) => ctx.connector.hookEvents.includes(e));\n }\n\n /** Declared events Codex has no analog for — install reports a warn-skip. */\n private warnSkipHookEvents(ctx: InstallContext): HookEventName[] {\n const override = ctx.connector.platforms[this.id]?.hooks;\n if (override === false) return [];\n return ctx.connector.hookEvents.filter((e) => WARN_SKIP_EVENTS.has(e));\n }\n\n /**\n * Render the `[mcp_servers.<id>]` table. TOML has NO interpolation, so every\n * `${env:VAR}` is resolved to a literal at install time. The env table is a\n * plain string→string map. Honors the telemetry serve-wrapper.\n */\n private renderMcpEntry(ctx: InstallContext, server: ServerDef): CodexMcpEntry {\n // Streamable HTTP server: codex infers the transport from `url` (no explicit\n // transport key). VERIFIED against codex-cli 0.139.0 — `codex mcp add <id>\n // --url <U> --bearer-token-env-var <E>` writes:\n // [mcp_servers.<id>]\n // url = \"…\"\n // bearer_token_env_var = \"…\" (only with bearerEnv auth)\n // Telemetry serve-wrapping is stdio-only (remote cannot be intercepted).\n // installServer's guard only lets stdio+command or http+url reach here, so\n // this branch is exactly the streamable-HTTP case (lock-step with the guard).\n if (server.transport === \"http\") {\n const remote: CodexMcpEntry = { url: resolveEnvRefsDeep(server.url ?? \"\") };\n if (server.auth?.type === \"bearerEnv\" && server.auth.bearerEnvVar) {\n remote.bearer_token_env_var = server.auth.bearerEnvVar;\n }\n if (server.headers && Object.keys(server.headers).length > 0) {\n const headers: Record<string, string> = {};\n for (const [k, v] of Object.entries(resolveEnvRefsDeep(server.headers))) {\n headers[k] = String(v);\n }\n remote.http_headers = headers;\n }\n return remote;\n }\n let command = server.command as string;\n let args = [...(server.args ?? [])];\n\n ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));\n\n // Resolve env-refs to literals (TOML cannot interpolate).\n command = resolveEnvRefsDeep(command);\n args = resolveEnvRefsDeep(args);\n\n const entry: CodexMcpEntry = { command };\n if (args.length > 0) entry.args = args;\n\n if (server.env && Object.keys(server.env).length > 0) {\n const env: Record<string, string> = {};\n for (const [k, v] of Object.entries(resolveEnvRefsDeep(server.env))) {\n env[k] = String(v);\n }\n entry.env = env;\n }\n return entry;\n }\n\n /**\n * Does this hooks.json entry belong to this connector for `event`? EVENT-\n * SPECIFIC + path-normalized exact-command match. The engine binds this per\n * event in the uninstall (whole-entry FLAT removal) and the install idempotency\n * find reuses its command body via the descriptor's entryOwnsCommand.\n */\n private isOurEntry(ctx: InstallContext, event: CodexHookEventName, entry: CodexHookEntry): boolean {\n if (!entry || typeof entry !== \"object\" || !Array.isArray(entry.hooks)) return false;\n const ours = buildHomeBinHookCommand(ctx.homeBinPath, \"codex\", event, ctx.connector.id);\n const needle = ours.replace(/\\\\/g, \"/\");\n return entry.hooks.some((h) => (h.command ?? \"\").replace(/\\\\/g, \"/\") === needle);\n }\n}\n\nexport const adapter = new CodexAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;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