@ken-jo/agent-connector 0.4.44 → 0.4.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -4
- package/dist/{action-72J2TCKQ.js → action-RUM6GP23.js} +12 -12
- package/dist/{amazon-q-UFLBUSHG.js → amazon-q-KXVJFT7Q.js} +7 -11
- package/dist/amazon-q-KXVJFT7Q.js.map +1 -0
- package/dist/{amp-5DJK7VAL.js → amp-WAPHJYTK.js} +38 -63
- package/dist/amp-WAPHJYTK.js.map +1 -0
- package/dist/{antigravity-NWP2TUG6.js → antigravity-GF3RU42A.js} +5 -5
- package/dist/{antigravity-cli-KPNLE7X4.js → antigravity-cli-OH27IFH5.js} +5 -5
- package/dist/{chunk-QY42WGBX.js → chunk-2HCJV6UO.js} +33 -3
- package/dist/chunk-2HCJV6UO.js.map +1 -0
- package/dist/{chunk-ERV4TKRV.js → chunk-3Y23ZYYF.js} +10 -10
- package/dist/chunk-3Y23ZYYF.js.map +1 -0
- package/dist/{chunk-L7ESV37V.js → chunk-7CZKXXBD.js} +4 -2
- package/dist/chunk-7CZKXXBD.js.map +1 -0
- package/dist/{chunk-ZY25RG4Y.js → chunk-ALVXORZM.js} +4 -2
- package/dist/chunk-ALVXORZM.js.map +1 -0
- package/dist/{chunk-M3H7PQWT.js → chunk-AXAHW2KU.js} +4 -2
- package/dist/chunk-AXAHW2KU.js.map +1 -0
- package/dist/{chunk-CFM3JKIR.js → chunk-CSRBMJLU.js} +7 -7
- package/dist/{chunk-F4DSMVZ7.js → chunk-D6ZJS4ND.js} +2 -2
- package/dist/{chunk-B47MDOV3.js → chunk-E45SUUD7.js} +5 -5
- package/dist/{chunk-3Q6YEDCG.js → chunk-F5COBB5F.js} +17 -45
- package/dist/chunk-F5COBB5F.js.map +1 -0
- package/dist/{chunk-5M2SMDA4.js → chunk-GCRRX4MO.js} +2 -2
- package/dist/{chunk-2RPHDVHW.js → chunk-IU42THN7.js} +2 -2
- package/dist/{chunk-VPSHGDDQ.js → chunk-IZ4XQ23W.js} +26 -10
- package/dist/chunk-IZ4XQ23W.js.map +1 -0
- package/dist/{chunk-SBV2QJ5C.js → chunk-LS65GL2P.js} +36 -36
- package/dist/{chunk-IKEXNI2W.js → chunk-NXR4HM5N.js} +18 -18
- package/dist/{chunk-ASHAMORS.js → chunk-P5KA5NVR.js} +2 -2
- package/dist/{chunk-A767JFHW.js → chunk-RHML2NOB.js} +65 -35
- package/dist/chunk-RHML2NOB.js.map +1 -0
- package/dist/{chunk-UXG64P6R.js → chunk-RQCBBLTA.js} +7 -4
- package/dist/chunk-RQCBBLTA.js.map +1 -0
- package/dist/{chunk-LETB5HCK.js → chunk-TZ5KGCE2.js} +2 -2
- package/dist/{chunk-WZWK4ICE.js → chunk-UVBAH263.js} +10 -7
- package/dist/chunk-UVBAH263.js.map +1 -0
- package/dist/{chunk-E3GWKJU5.js → chunk-ZEFUDBTY.js} +5 -5
- package/dist/{chunk-XW46WVR2.js → chunk-ZSMGHEB5.js} +10 -5
- package/dist/chunk-ZSMGHEB5.js.map +1 -0
- package/dist/{claude-code-HXIVRZCY.js → claude-code-WLN43K7I.js} +15 -8
- package/dist/claude-code-WLN43K7I.js.map +1 -0
- package/dist/cli/sdk.js +7 -7
- package/dist/cli.js +1 -1
- package/dist/{cline-AGFJF4AC.js → cline-PEGTGVQD.js} +4 -4
- package/dist/{codebuff-YUQ4PN7G.js → codebuff-UG6LVSOM.js} +4 -4
- package/dist/{codex-FLU37DV3.js → codex-4LVDQXCD.js} +32 -6
- package/dist/codex-4LVDQXCD.js.map +1 -0
- package/dist/{continue-ZMI4YN75.js → continue-DYV5V55Y.js} +9 -5
- package/dist/continue-DYV5V55Y.js.map +1 -0
- package/dist/{copilot-cli-XPRJ5MQB.js → copilot-cli-NVFXFLUF.js} +66 -51
- package/dist/copilot-cli-NVFXFLUF.js.map +1 -0
- package/dist/{crush-3OB5ZTCC.js → crush-PP4HYZLT.js} +4 -4
- package/dist/{cursor-F4HYO2FP.js → cursor-XMXOZKAP.js} +5 -5
- package/dist/{detect-L3NJTBO5.js → detect-IZOWP5AA.js} +4 -4
- package/dist/{doctor-PUE4HO3N.js → doctor-5IVUQ2YH.js} +14 -14
- package/dist/{droid-NZCKYKOV.js → droid-ETNOUIPJ.js} +6 -12
- package/dist/droid-ETNOUIPJ.js.map +1 -0
- package/dist/{gemini-cli-3ZGCXUDD.js → gemini-cli-P7XJXWVH.js} +19 -6
- package/dist/gemini-cli-P7XJXWVH.js.map +1 -0
- package/dist/{goose-MGGNVXJP.js → goose-UZVA6MQC.js} +16 -22
- package/dist/goose-UZVA6MQC.js.map +1 -0
- package/dist/{hermes-L3CBJ37L.js → hermes-IC6R4CII.js} +44 -22
- package/dist/hermes-IC6R4CII.js.map +1 -0
- package/dist/{hook-S3DNNGZX.js → hook-7IUPIHCZ.js} +12 -12
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/{install-7SUJFRYO.js → install-EP6GPQ65.js} +14 -14
- package/dist/{introspect-B164-hj3.d.ts → introspect-BFcXpfUp.d.ts} +1 -1
- package/dist/{jetbrains-copilot-M2LHJBAW.js → jetbrains-copilot-MZO2RQGJ.js} +19 -15
- package/dist/jetbrains-copilot-MZO2RQGJ.js.map +1 -0
- package/dist/{kilo-RMRP2EL7.js → kilo-CCB34CQQ.js} +18 -55
- package/dist/kilo-CCB34CQQ.js.map +1 -0
- package/dist/{kilo-cli-6ITBNHTH.js → kilo-cli-EOMN3WC7.js} +18 -55
- package/dist/kilo-cli-EOMN3WC7.js.map +1 -0
- package/dist/{kimi-QYHWAY54.js → kimi-GUSJME55.js} +8 -4
- package/dist/kimi-GUSJME55.js.map +1 -0
- package/dist/{kiro-2K5UJVGC.js → kiro-6OHZ5RGV.js} +5 -5
- package/dist/kiro-6OHZ5RGV.js.map +1 -0
- package/dist/{leaderboard-2VAAOK3D.js → leaderboard-6I2E5XZK.js} +5 -5
- package/dist/{mimo-code-K7AMX2QW.js → mimo-code-ZPJJ6IIW.js} +21 -56
- package/dist/mimo-code-ZPJJ6IIW.js.map +1 -0
- package/dist/{mux-GT7FWVLH.js → mux-AFTVMGGM.js} +4 -4
- package/dist/{nemoclaw-GQMS6CUM.js → nemoclaw-D5EN4G2Q.js} +5 -5
- package/dist/{omp-2RPYIZUF.js → omp-GKI2PZ7G.js} +17 -46
- package/dist/omp-GKI2PZ7G.js.map +1 -0
- package/dist/{openclaw-P5GMEEGC.js → openclaw-A76PCNBV.js} +5 -5
- package/dist/{opencode-5D2SK3EX.js → opencode-M34E6PI7.js} +21 -56
- package/dist/opencode-M34E6PI7.js.map +1 -0
- package/dist/{package-VUX663ET.js → package-BWLV24OO.js} +11 -11
- package/dist/{pi-ZMM4KJTO.js → pi-HVG6ZWFE.js} +4 -4
- package/dist/{qwen-code-4ZLVGN2C.js → qwen-code-OWLM3I5P.js} +12 -5
- package/dist/qwen-code-OWLM3I5P.js.map +1 -0
- package/dist/{roo-code-67QGLQRM.js → roo-code-RFKKTNNI.js} +4 -4
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +10 -10
- package/dist/sdk/index.d.ts +3 -3
- package/dist/sdk/index.js +6 -6
- package/dist/sdk/test.d.ts +2 -2
- package/dist/sdk/test.js +9 -9
- package/dist/{serve-MOIIYFER.js → serve-CM4HZPMP.js} +12 -12
- package/dist/{status-SCBCWS7H.js → status-BPB4VLQX.js} +10 -10
- package/dist/{statusline-NRPDOPGA.js → statusline-HIKR2I4Q.js} +11 -11
- package/dist/{telemetry-Q55B5NSZ.js → telemetry-SBVUJYNE.js} +10 -10
- package/dist/{trae-TMJPHWZ5.js → trae-FVHQALK3.js} +4 -4
- package/dist/{types-COSBYpKs.d.ts → types-ChUrvw0j.d.ts} +8 -8
- package/dist/{uninstall-SNI7GPQD.js → uninstall-MO3RGGVE.js} +21 -14
- package/dist/uninstall-MO3RGGVE.js.map +1 -0
- package/dist/{upgrade-ZUNBJWJ7.js → upgrade-6XIGSPGY.js} +14 -14
- package/dist/{usage-UQDBIU42.js → usage-IBN36ZVW.js} +2 -2
- package/dist/{usage-event-HPG2BIAY.js → usage-event-4RJP37K6.js} +11 -11
- package/dist/{vscode-copilot-H7JKUKLZ.js → vscode-copilot-6FLDRTKV.js} +26 -19
- package/dist/vscode-copilot-6FLDRTKV.js.map +1 -0
- package/dist/{warp-SVDVKQQI.js → warp-7CC52UJV.js} +4 -4
- package/dist/{windsurf-H36YKOMR.js → windsurf-6ZLQMBQW.js} +4 -4
- package/dist/{zed-LHWJALLZ.js → zed-FULJMNBV.js} +4 -4
- package/package.json +2 -1
- package/dist/amazon-q-UFLBUSHG.js.map +0 -1
- package/dist/amp-5DJK7VAL.js.map +0 -1
- package/dist/chunk-3Q6YEDCG.js.map +0 -1
- package/dist/chunk-A767JFHW.js.map +0 -1
- package/dist/chunk-ERV4TKRV.js.map +0 -1
- package/dist/chunk-L7ESV37V.js.map +0 -1
- package/dist/chunk-M3H7PQWT.js.map +0 -1
- package/dist/chunk-QY42WGBX.js.map +0 -1
- package/dist/chunk-UXG64P6R.js.map +0 -1
- package/dist/chunk-VPSHGDDQ.js.map +0 -1
- package/dist/chunk-WZWK4ICE.js.map +0 -1
- package/dist/chunk-XW46WVR2.js.map +0 -1
- package/dist/chunk-ZY25RG4Y.js.map +0 -1
- package/dist/claude-code-HXIVRZCY.js.map +0 -1
- package/dist/codex-FLU37DV3.js.map +0 -1
- package/dist/continue-ZMI4YN75.js.map +0 -1
- package/dist/copilot-cli-XPRJ5MQB.js.map +0 -1
- package/dist/droid-NZCKYKOV.js.map +0 -1
- package/dist/gemini-cli-3ZGCXUDD.js.map +0 -1
- package/dist/goose-MGGNVXJP.js.map +0 -1
- package/dist/hermes-L3CBJ37L.js.map +0 -1
- package/dist/jetbrains-copilot-M2LHJBAW.js.map +0 -1
- package/dist/kilo-RMRP2EL7.js.map +0 -1
- package/dist/kilo-cli-6ITBNHTH.js.map +0 -1
- package/dist/kimi-QYHWAY54.js.map +0 -1
- package/dist/kiro-2K5UJVGC.js.map +0 -1
- package/dist/mimo-code-K7AMX2QW.js.map +0 -1
- package/dist/omp-2RPYIZUF.js.map +0 -1
- package/dist/opencode-5D2SK3EX.js.map +0 -1
- package/dist/qwen-code-4ZLVGN2C.js.map +0 -1
- package/dist/uninstall-SNI7GPQD.js.map +0 -1
- package/dist/vscode-copilot-H7JKUKLZ.js.map +0 -1
- /package/dist/{action-72J2TCKQ.js.map → action-RUM6GP23.js.map} +0 -0
- /package/dist/{antigravity-NWP2TUG6.js.map → antigravity-GF3RU42A.js.map} +0 -0
- /package/dist/{antigravity-cli-KPNLE7X4.js.map → antigravity-cli-OH27IFH5.js.map} +0 -0
- /package/dist/{chunk-CFM3JKIR.js.map → chunk-CSRBMJLU.js.map} +0 -0
- /package/dist/{chunk-F4DSMVZ7.js.map → chunk-D6ZJS4ND.js.map} +0 -0
- /package/dist/{chunk-B47MDOV3.js.map → chunk-E45SUUD7.js.map} +0 -0
- /package/dist/{chunk-5M2SMDA4.js.map → chunk-GCRRX4MO.js.map} +0 -0
- /package/dist/{chunk-2RPHDVHW.js.map → chunk-IU42THN7.js.map} +0 -0
- /package/dist/{chunk-SBV2QJ5C.js.map → chunk-LS65GL2P.js.map} +0 -0
- /package/dist/{chunk-IKEXNI2W.js.map → chunk-NXR4HM5N.js.map} +0 -0
- /package/dist/{chunk-ASHAMORS.js.map → chunk-P5KA5NVR.js.map} +0 -0
- /package/dist/{chunk-LETB5HCK.js.map → chunk-TZ5KGCE2.js.map} +0 -0
- /package/dist/{chunk-E3GWKJU5.js.map → chunk-ZEFUDBTY.js.map} +0 -0
- /package/dist/{cline-AGFJF4AC.js.map → cline-PEGTGVQD.js.map} +0 -0
- /package/dist/{codebuff-YUQ4PN7G.js.map → codebuff-UG6LVSOM.js.map} +0 -0
- /package/dist/{crush-3OB5ZTCC.js.map → crush-PP4HYZLT.js.map} +0 -0
- /package/dist/{cursor-F4HYO2FP.js.map → cursor-XMXOZKAP.js.map} +0 -0
- /package/dist/{detect-L3NJTBO5.js.map → detect-IZOWP5AA.js.map} +0 -0
- /package/dist/{doctor-PUE4HO3N.js.map → doctor-5IVUQ2YH.js.map} +0 -0
- /package/dist/{hook-S3DNNGZX.js.map → hook-7IUPIHCZ.js.map} +0 -0
- /package/dist/{install-7SUJFRYO.js.map → install-EP6GPQ65.js.map} +0 -0
- /package/dist/{leaderboard-2VAAOK3D.js.map → leaderboard-6I2E5XZK.js.map} +0 -0
- /package/dist/{mux-GT7FWVLH.js.map → mux-AFTVMGGM.js.map} +0 -0
- /package/dist/{nemoclaw-GQMS6CUM.js.map → nemoclaw-D5EN4G2Q.js.map} +0 -0
- /package/dist/{openclaw-P5GMEEGC.js.map → openclaw-A76PCNBV.js.map} +0 -0
- /package/dist/{package-VUX663ET.js.map → package-BWLV24OO.js.map} +0 -0
- /package/dist/{pi-ZMM4KJTO.js.map → pi-HVG6ZWFE.js.map} +0 -0
- /package/dist/{roo-code-67QGLQRM.js.map → roo-code-RFKKTNNI.js.map} +0 -0
- /package/dist/{serve-MOIIYFER.js.map → serve-CM4HZPMP.js.map} +0 -0
- /package/dist/{status-SCBCWS7H.js.map → status-BPB4VLQX.js.map} +0 -0
- /package/dist/{statusline-NRPDOPGA.js.map → statusline-HIKR2I4Q.js.map} +0 -0
- /package/dist/{telemetry-Q55B5NSZ.js.map → telemetry-SBVUJYNE.js.map} +0 -0
- /package/dist/{trae-TMJPHWZ5.js.map → trae-FVHQALK3.js.map} +0 -0
- /package/dist/{upgrade-ZUNBJWJ7.js.map → upgrade-6XIGSPGY.js.map} +0 -0
- /package/dist/{usage-UQDBIU42.js.map → usage-IBN36ZVW.js.map} +0 -0
- /package/dist/{usage-event-HPG2BIAY.js.map → usage-event-4RJP37K6.js.map} +0 -0
- /package/dist/{warp-SVDVKQQI.js.map → warp-7CC52UJV.js.map} +0 -0
- /package/dist/{windsurf-H36YKOMR.js.map → windsurf-6ZLQMBQW.js.map} +0 -0
- /package/dist/{zed-LHWJALLZ.js.map → zed-FULJMNBV.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/kilo-cli/index.ts"],"sourcesContent":["/**\n * adapters/kilo-cli — Kilo CLI platform adapter for agent-connector.\n *\n * The Kilo CLI (the `kilo` binary) is a **live-confirmed OpenCode fork**: a\n * SQLite-backed command-line agent (storage `~/.local/share/kilo/kilo.db`) that\n * loads `@kilocode/plugin` modules. It is DISTINCT from the Kilo Code VS Code\n * extension (adapter id \"kilo\", a Roo/Cline fork) — the two products carry\n * different platformIds so their config and usage never merge.\n *\n * Paradigm — **ts-plugin** (mirrors the OpenCode adapter):\n * The fork has no JSON hook table. Instead it loads JS/TS plugin modules whose\n * default export is a `@kilocode/plugin` PluginModule:\n * { id?, server: async (input) => Hooks }\n * where the returned `Hooks` object is keyed by the fork's event names\n * (\"tool.execute.before\", \"tool.execute.after\", a session/system event). The\n * `server` factory runs in-process inside Kilo and is handed mutable args/output\n * objects; it throws to block a tool call.\n *\n * Why we BRIDGE instead of importing handlers (identical rationale to OpenCode):\n * the connector's hook handlers are arbitrary developer code we must not import\n * into Kilo's runtime (wrong cwd, wrong deps, version skew). So instead of\n * importing handlers we synthesize a tiny, fully self-contained ESM plugin\n * module that imports NOTHING from agent-connector and, on each hook firing,\n * shells out to the ONE stable home binary's universal entrypoint\n * <homeBin> hook kilo-cli <event> --connector <id>\n * feeding the event payload on stdin and JSON.parsing the normalized\n * HookResponse back from stdout. Fail-open: any bridge error → no-op.\n *\n * User config dir (XDG): the kilo backend honors `$XDG_CONFIG_HOME`, so the user\n * scope resolves to `$XDG_CONFIG_HOME/kilo` when that env var is set & non-empty,\n * else `~/.config/kilo` (the default). This is the SAME backend dir the kilo\n * extension uses — every user-scope path below (writer, detection probe, plugin\n * dir, content surfaces) flows through `kiloCliConfigDir()` so they cannot\n * disagree with where the Kilo CLI actually reads.\n *\n * Registration (hooks — array + auto-discovery both work):\n * Since kilo v7.3.16 the fork auto-discovers every file in its plugin dir\n * (.kilo/plugin/*.js, ~/.config/kilo/plugin/*.js), so writing the file is\n * sufficient for discovery. We ALSO register the path in kilo.jsonc's `plugin`\n * array because both loading mechanisms coexist and the array write is harmless\n * (idempotent); older versions relied on it exclusively.\n *\n * Plugin module location (project | user):\n * user → ~/.config/kilo/plugin/<id>.js (XDG: $XDG_CONFIG_HOME/kilo/plugin/<id>.js)\n * project → <projectDir>/.kilo/plugin/<id>.js\n *\n * MCP config (the CLI's new-gen dialect — already correct, KEPT verbatim):\n * - user scope → ~/.config/kilo/kilo.jsonc (XDG: $XDG_CONFIG_HOME/kilo/kilo.jsonc)\n * - project scope → <projectDir>/.kilo/kilo.jsonc (project overrides global)\n * Both are JSON/JSONC; we write plain JSON, which is valid JSONC. The root key\n * is \"mcp\" (NOT the extension's \"mcpServers\").\n *\n * Server entry shape (mirrors OpenCode's new-gen dialect):\n * - stdio → { type: \"local\", command: [exe, ...args], environment: {...} }\n * NOTE the command is a single ARRAY (exe + args together), unlike\n * Claude/Cursor's scalar `command` + `args[]` split.\n * - remote → { type: \"remote\", url }\n *\n * The Kilo CLI documents no native `${env:VAR}` interpolation token, so env/url\n * refs are resolved to literals at install time (the no-native-token path).\n *\n * Content surfaces (live-confirmed, kilo v7.3.16; user dir is XDG-resolved):\n * - commands → .kilo/command/<name>.md (user ~/.config/kilo/command/)\n * - skills → .kilo/skills/<name>/SKILL.md (user ~/.config/kilo/skills/ or ~/.agents/skills)\n * - subagents → .kilo/agent/<name>.md with frontmatter mode:subagent\n *\n * Capability degradations (documented, never thrown):\n * - The fork has no \"ask\" gate. A decision of \"ask\" degrades to a block (throw\n * with the reason) in tool.execute.before — the safe direction.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\n\nimport { BaseAdapter } from \"../base.js\";\nimport { renderCommandMd, renderSkillMd } from \"../claude-code/render.js\";\nimport type {\n Adapter,\n GeneratedPluginFile,\n HookReply,\n InstallContext,\n MemoryTarget,\n NormalizedEvent,\n} from \"../spi.js\";\nimport type {\n ChangeRecord,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n PermissionRequestEvent,\n PlatformCapabilities,\n PlatformId,\n PostToolUseEvent,\n PreToolUseEvent,\n ServerDef,\n SessionStartEvent,\n StopEvent,\n Transport,\n UserPromptSubmitEvent,\n} from \"../../core/types.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport { renderBridgePrelude } from \"../../core/ts-plugin-bridge.js\";\nimport { xdgConfigHome } from \"../../core/host-paths.js\";\nimport {\n buildWrappedStdio,\n} from \"../../core/spawn.js\";\n\nconst HOST: PlatformId = \"kilo-cli\";\n/** New-generation root key for MCP servers — \"mcp\", not the extension's \"mcpServers\". */\nconst MCP_ROOT_KEY = \"mcp\";\n/** kilo.jsonc array of plugin module paths the fork loads (NOT auto-discovery). */\nconst PLUGIN_ARRAY_KEY = \"plugin\";\n/** New-generation config filename (JSON/JSONC). */\nconst CONFIG_FILE = \"kilo.jsonc\";\n/** The Kilo CLI's SQLite session store — a CLI-exclusive detection marker. */\nconst CLI_DB_RELPATH = [\".local\", \"share\", \"kilo\", \"kilo.db\"] as const;\n\n/**\n * Canonical → Kilo (OpenCode-fork) event name map. A connector hook event is\n * only emitted by the generated plugin when it appears here AND is declared by\n * the connector.\n *\n * The fork inherits OpenCode's tool-execution events; like OpenCode it has no\n * real SessionStart hook, so SessionStart maps to the same system-prompt\n * transform surrogate (the verified context-injection point) — we inject\n * additionalContext into the system prompt there.\n */\nconst EVENT_TO_KILO: Partial<Record<HookEventName, string>> = {\n PreToolUse: \"tool.execute.before\",\n PostToolUse: \"tool.execute.after\",\n SessionStart: \"experimental.chat.system.transform\",\n // chat.message fires when a new user message arrives (inspect/modify parts) →\n // canonical UserPromptSubmit (mirrors the mimo-code OpenCode fork).\n UserPromptSubmit: \"chat.message\",\n // permission.ask is the decision-capable gate (auto-allow/auto-deny). The\n // handler MUTATES output.status (\"ask\"|\"deny\"|\"allow\") — mirrors OpenCode.\n PermissionRequest: \"permission.ask\",\n // session.idle (\"session finished responding\") → canonical Stop. NOT a direct\n // hook key — dispatched through the generic `event` hook (event.type switch).\n // session.idle is doc-listed for the VS Code extension & CLI but its runtime\n // firing on a given Kilo build is not separately verified (an upstream FR for\n // session-lifecycle hooks exists); if it never fires, Stop is a silent no-op\n // (an acceptable degrade — it never mis-fires), so coverage may be optimistic.\n Stop: \"session.idle\",\n};\n\n/** Raw payload the generated plugin posts to the universal hook entrypoint. */\ninterface KiloBridgePayload {\n toolName?: string;\n toolInput?: Record<string, unknown>;\n toolOutput?: string;\n isError?: boolean;\n prompt?: string;\n sessionId?: string;\n projectDir?: string;\n}\n\n/**\n * Native MCP server entry shapes the Kilo CLI's new-gen config accepts under\n * `mcp`. QUIRK: a local (stdio) server keys its whole invocation as\n * `command: [...]` — a single array of [executable, ...args] — and env as\n * `environment`.\n */\ninterface KiloLocalServer {\n type: \"local\";\n command: string[];\n environment?: Record<string, string>;\n}\ninterface KiloRemoteServer {\n type: \"remote\";\n url: string;\n}\n\n/**\n * Resolve the kilo backend user config dir: `$XDG_CONFIG_HOME/kilo` when set,\n * else `~/.config/kilo`. This is the SAME backend dir the kilo extension uses\n * (kilo's own `kiloConfigDir()`), so the CLI writer, detection probe, and\n * content surfaces all agree with where the XDG-honoring Kilo CLI reads. When\n * `$XDG_CONFIG_HOME` is unset this is byte-identical to `~/.config/kilo`.\n */\nfunction kiloCliConfigDir(): string {\n return join(xdgConfigHome(), \"kilo\");\n}\n\nexport class KiloCliAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"Kilo CLI\";\n readonly paradigm: HookParadigm = \"ts-plugin\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: AGENTS.md-first managed block (project <projectDir>/AGENTS.md\n // via the base default; user scope → ~/.kilocode/rules/agent-connector.md below).\n supportsMemory: true,\n // Matches the OpenCode capability surface — the fork inherits its plugin\n // event model.\n preToolUse: true,\n postToolUse: true,\n // The fork's compaction hook is experimental and not wired here.\n preCompact: false,\n sessionStart: true,\n sessionEnd: false,\n // chat.message backs UserPromptSubmit; session.idle (via the generic `event`\n // hook) backs Stop.\n userPromptSubmit: true,\n stop: true,\n notification: false,\n // Newer events: the fork's decision-capable `permission.ask` plugin hook is\n // now wired (PermissionRequest → permission.ask, mutating output.status), and\n // session.idle (\"session finished responding\") backs Stop via the generic\n // `event` hook. subagents run as child sessions (bus events only) and tool\n // failure is merged into tool.execute.after / session.error, so\n // postToolUseFailure / subagentStart / subagentStop stay unset — the\n // generated bridge never references them and install reports them as\n // \"unsupported here\".\n permissionRequest: true,\n // tool.execute.before mutates output.args → input rewrite supported.\n canModifyArgs: true,\n // tool.execute.after mutates output.output → output rewrite supported.\n canModifyOutput: true,\n // injected via the system-prompt transform at session start.\n canInjectSessionContext: true,\n // The Kilo CLI registers stdio (local), SSE, and Streamable HTTP MCP servers.\n transports: [\"stdio\", \"sse\", \"http\"],\n // Content surfaces: live-confirmed on kilo v7.3.16 (see header).\n supportsCommands: true,\n supportsSkills: true,\n supportsSubagents: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userDir = kiloCliConfigDir();\n const userConfig = join(userDir, CONFIG_FILE);\n const projectConfig = join(projectDir, \".kilo\", CONFIG_FILE);\n // The SQLite session DB is a CLI-exclusive marker (the VS Code extension\n // never writes it), so it disambiguates the CLI from the \"kilo\" extension\n // even when neither writes a kilo.jsonc yet.\n const cliDb = join(homedir(), ...CLI_DB_RELPATH);\n const userInstalled = existsSync(userDir) || existsSync(cliDb);\n const projInstalled = existsSync(projectConfig);\n const installed = userInstalled || projInstalled;\n // Report the scope/path/reason for the marker that actually matched, so a\n // project-only install isn't misreported as a (non-existent) user install.\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const configPath = scope === \"project\" ? projectConfig : userConfig;\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath,\n scope,\n reason: installed\n ? scope === \"project\"\n ? `found project Kilo CLI config at ${projectConfig}`\n : existsSync(cliDb)\n ? `found Kilo CLI session store at ${cliDb}`\n : `found Kilo CLI config under ${userDir}`\n : `no Kilo CLI config at ${userDir} or session store at ${cliDb}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Memory surface: global rules dir at user scope ──────────────────────\n // Project scope stays on the AGENTS.md base default. User scope targets a\n // dedicated agent-connector.md in the legacy-compatible ~/.kilocode/rules/\n // dir (always loaded; avoids JSONC `instructions` edits in kilo.jsonc; the\n // AC-created file is cleanly deletable on uninstall). Shared backend with\n // the kilo extension — the convergent write dedupes via the content hash.\n protected override memoryTargets(ctx: InstallContext): MemoryTarget[] {\n if (this.memoryOverride(ctx)?.path || ctx.scope !== \"user\") {\n return super.memoryTargets(ctx);\n }\n return [\n {\n path: join(homedir(), \".kilocode\", \"rules\", \"agent-connector.md\"),\n reason: \"kilo global rules dir (~/.kilocode/rules; agent-connector-owned file)\",\n },\n ];\n }\n\n // ── Native paths ─────────────────────────────────────────────────────────\n\n getConfigDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".kilo\")\n : kiloCliConfigDir();\n }\n\n getServerConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), CONFIG_FILE);\n }\n\n /**\n * For ts-plugin hosts the \"hook config path\" is the generated plugin FILE.\n * Unlike OpenCode, writing the file is NOT sufficient: the fork loads only the\n * module paths listed in kilo.jsonc's `plugin` array, so installHooks also\n * registers this path there.\n */\n getHookConfigPath(ctx: InstallContext): string {\n return join(this.pluginDir(ctx), this.pluginFileName(ctx));\n }\n\n /** Plugin directory the synthesized module is written into, per scope. */\n private pluginDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".kilo\", \"plugin\")\n : join(kiloCliConfigDir(), \"plugin\");\n }\n\n /** Plugin module file name (one per connector, kebab-case id). */\n private pluginFileName(ctx: InstallContext): string {\n return `${ctx.connector.id}.js`;\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 kilo-cli\"\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 the Kilo CLI's new-gen `mcp` entry. */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): KiloLocalServer | KiloRemoteServer {\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 // QUIRK: the Kilo CLI's new-gen local server keys its whole invocation as\n // a single `command` ARRAY (executable + args together), like OpenCode.\n // The CLI has no documented native interpolation token, so resolve every\n // ${env:VAR} to a literal at install time.\n const entry: KiloLocalServer = {\n type: \"local\",\n command: resolveEnvRefsDeep([command, ...args]),\n };\n const env = this.renderEnv(server.env);\n if (env) entry.environment = env;\n return entry;\n }\n\n // sse / http (and any other remote transport) — the Kilo CLI registers a URL.\n const entry: KiloRemoteServer = {\n type: \"remote\",\n url: resolveEnvRefsDeep(server.url ?? \"\"),\n };\n return entry;\n }\n\n /**\n * Render env values. The Kilo CLI 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 // ── Hook install / uninstall (ts-plugin + explicit `plugin` array) ────────\n\n installHooks(ctx: InstallContext): ChangeRecord[] {\n const pluginPath = this.getHookConfigPath(ctx);\n const configPath = this.getServerConfigPath(ctx);\n\n if (ctx.connector.platforms[HOST]?.hooks === false) {\n return [\n { platform: this.id, action: \"skip\", path: pluginPath, detail: \"hooks disabled for kilo-cli\" },\n ];\n }\n if (ctx.connector.hookEvents.length === 0) {\n return [\n { platform: this.id, action: \"skip\", path: pluginPath, detail: \"connector declares no hooks\" },\n ];\n }\n\n const changes: ChangeRecord[] = [];\n\n // 1. Write the synthesized plugin module.\n for (const file of this.synthesizePlugin(ctx)) {\n changes.push(\n this.writeManagedFile(\n file.path,\n file.contents,\n ctx.dryRun,\n `kilo plugin module (${this.hookDetail(ctx)})`,\n file.executable,\n ),\n );\n }\n\n // 2. Register the module path in kilo.jsonc's `plugin` array (the fork does\n // NOT auto-discover by directory — it reads this array).\n changes.push(this.upsertPluginInArray(configPath, pluginPath, ctx.dryRun));\n\n return changes;\n }\n\n /**\n * Human-facing summary of which declared events the synthesized module ACTUALLY\n * wires. Only events present in EVENT_TO_KILO are mapped/wired; any declared\n * event with no Kilo mapping is reported separately as \"unsupported here\" so\n * the detail never overstates coverage.\n */\n private hookDetail(ctx: InstallContext): string {\n const declared = ctx.connector.hookEvents;\n const mapped = declared.filter((e) => EVENT_TO_KILO[e] !== undefined);\n const unsupported = declared.filter((e) => EVENT_TO_KILO[e] === undefined);\n const base = mapped.join(\",\");\n return unsupported.length > 0\n ? `${base}; unsupported here: ${unsupported.join(\",\")}`\n : base;\n }\n\n uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n const pluginPath = this.getHookConfigPath(ctx);\n const configPath = this.getServerConfigPath(ctx);\n const changes: ChangeRecord[] = [];\n\n // 1. Deregister the module path from kilo.jsonc's `plugin` array.\n changes.push(this.removePluginFromArray(configPath, pluginPath, ctx.dryRun));\n\n // 2. Remove the plugin module on disk.\n changes.push(\n this.removeManagedFile(pluginPath, ctx.dryRun, \"kilo plugin module\", \"no kilo plugin module present\"),\n );\n\n // 3. Drop the now-empty plugin dir (only if WE own its full contents).\n changes.push(this.removeDirIfEmpty(this.pluginDir(ctx), ctx.dryRun));\n\n return changes;\n }\n\n /** Upsert the module path into kilo.jsonc's top-level `plugin` array (idempotent). */\n private upsertPluginInArray(\n configPath: string,\n modulePath: string,\n dryRun: boolean,\n ): ChangeRecord {\n // OVERWRITE GUARD: never blank a present-but-unparseable kilo.jsonc.\n if (this.isPresentButUnparseable(configPath)) {\n return {\n platform: this.id,\n action: \"warn\",\n path: configPath,\n detail: `existing ${configPath} is not parseable; left untouched (back it up / fix it, then re-run)`,\n };\n }\n const cfg = this.readJson<Record<string, unknown>>(configPath) ?? {};\n const plugins = this.pluginArrayBucket(cfg);\n if (plugins.includes(modulePath)) {\n return {\n platform: this.id,\n action: \"skip\",\n path: configPath,\n detail: `${PLUGIN_ARRAY_KEY}[] already includes module`,\n };\n }\n plugins.push(modulePath);\n this.writeJson(configPath, cfg, dryRun);\n return {\n platform: this.id,\n action: \"create\",\n path: configPath,\n detail: `${PLUGIN_ARRAY_KEY}[] += module`,\n };\n }\n\n /** Remove the module path from kilo.jsonc's `plugin` array. */\n private removePluginFromArray(\n configPath: string,\n modulePath: string,\n dryRun: boolean,\n ): ChangeRecord {\n // OVERWRITE GUARD: a present-but-unparseable file would round-trip to `{}`.\n if (this.isPresentButUnparseable(configPath)) {\n return {\n platform: this.id,\n action: \"warn\",\n path: configPath,\n detail: `existing ${configPath} is not parseable; left untouched (back it up / fix it, then re-run)`,\n };\n }\n const cfg = this.readJson<Record<string, unknown>>(configPath);\n const raw = cfg?.[PLUGIN_ARRAY_KEY];\n const plugins = Array.isArray(raw) ? (raw as unknown[]) : undefined;\n const idx = plugins ? plugins.indexOf(modulePath) : -1;\n if (!cfg || !plugins || idx < 0) {\n return {\n platform: this.id,\n action: \"skip\",\n path: configPath,\n detail: `${PLUGIN_ARRAY_KEY}[] does not include module`,\n };\n }\n plugins.splice(idx, 1);\n this.writeJson(configPath, cfg, dryRun);\n return {\n platform: this.id,\n action: \"remove\",\n path: configPath,\n detail: `${PLUGIN_ARRAY_KEY}[] -= module`,\n };\n }\n\n /** Get-or-create the top-level `plugin` array as a mutable string array. */\n private pluginArrayBucket(cfg: Record<string, unknown>): string[] {\n const existing = cfg[PLUGIN_ARRAY_KEY];\n // Normalize to a fresh string[] (drop any non-string a user may have placed\n // here) and write it back so the caller mutates the live array.\n const plugins = Array.isArray(existing)\n ? existing.filter((p): p is string => typeof p === \"string\")\n : [];\n cfg[PLUGIN_ARRAY_KEY] = plugins;\n return plugins;\n }\n\n // ── Content surfaces: commands / skills / subagents ─────────────────────\n // CONTENT-ONLY: pure native-file writers under the kilo config dir.\n // No runtime dispatch, no home-bin pointer, no telemetry wrap. Each method\n // is idempotent (byte-identical → skip) via BaseAdapter.writeContentFile and\n // reversible via removeContentFile. Honors platforms[\"kilo-cli\"] per-surface\n // false opt-outs.\n //\n // Dirs (live-confirmed kilo v7.3.16 — kilo-pi-ground-truth.md):\n // commands → <kiloDir>/command/<name>.md\n // skills → <kiloDir>/skills/<name>/SKILL.md\n // subagents → <kiloDir>/agent/<name>.md (frontmatter mode:subagent)\n //\n // <kiloDir> (via getConfigDir):\n // project scope → <projectDir>/.kilo\n // user scope → ~/.config/kilo (XDG: $XDG_CONFIG_HOME/kilo)\n\n private commandsDir(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"command\");\n }\n private skillsDir(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"skills\");\n }\n private agentDir(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"agent\");\n }\n\n private commandPath(ctx: InstallContext, name: string): string {\n return join(this.commandsDir(ctx), `${name}.md`);\n }\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.skillsDir(ctx), name);\n }\n private subagentPath(ctx: InstallContext, name: string): string {\n return join(this.agentDir(ctx), `${name}.md`);\n }\n\n // ── Commands ───────────────────────────────────────────────────────────────\n\n override installCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.commands === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"commands disabled for kilo-cli\" }];\n }\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.writeContentFile(this.commandPath(ctx, cmd.name), renderCommandMd(cmd), ctx.dryRun),\n );\n }\n\n override uninstallCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.removeContentFile(this.commandPath(ctx, cmd.name), ctx.dryRun),\n );\n }\n\n // ── Skills ─────────────────────────────────────────────────────────────────\n\n override installSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.skills === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"skills disabled for kilo-cli\" }];\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 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 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;\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n // ── Subagents ──────────────────────────────────────────────────────────────\n\n override installSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.subagents === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"subagents disabled for kilo-cli\" }];\n }\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n return connector.subagents.map((agent) =>\n this.writeContentFile(\n this.subagentPath(ctx, agent.name),\n this.renderKiloSubagent(agent),\n ctx.dryRun,\n ),\n );\n }\n\n override uninstallSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n return connector.subagents.map((agent) =>\n this.removeContentFile(this.subagentPath(ctx, agent.name), ctx.dryRun),\n );\n }\n\n /**\n * Render a subagent to md+frontmatter for kilo-cli.\n * Kilo's shape is (description, mode:\"subagent\", model, permission) with the\n * system prompt as the body — mirrors the opencode adapter's renderSubagent.\n * `name` is NOT a frontmatter field — it comes from the filename.\n * `permission` is derived from the coarse `readonly` knob.\n */\n private renderKiloSubagent(agent: import(\"../../core/types.js\").SubagentDef): string {\n const frontmatter: Record<string, unknown> = {\n description: agent.description,\n mode: \"subagent\",\n };\n if (agent.model !== undefined) frontmatter.model = agent.model;\n if (agent.readonly === true) {\n frontmatter.permission = { edit: \"deny\", bash: \"deny\" };\n }\n if (agent.extra) Object.assign(frontmatter, agent.extra);\n // renderFrontmatterMd is inherited from BaseAdapter (delegates to render.ts).\n return this.renderFrontmatterMd(frontmatter, agent.prompt);\n }\n\n // ── ts-plugin synthesis ────────────────────────────────────────────────\n\n /**\n * Build ONE self-contained ESM plugin module for the Kilo CLI fork.\n *\n * The module imports nothing from agent-connector. It embeds two constants\n * (the absolute home-bin path and the connector id) and a `bridge()` helper\n * that shells out to the universal hook entrypoint via execFileSync, feeding\n * the Kilo payload on stdin and JSON.parsing the normalized HookResponse back\n * from stdout (fail-open: any error → null). Its default export is the\n * `@kilocode/plugin` PluginModule shape — { id, server: async (input) =>\n * ({ \"tool.execute.before\": …, \"tool.execute.after\": …, … }) } — keyed only by\n * the fork event names for the events this connector actually declares.\n */\n synthesizePlugin(ctx: InstallContext): GeneratedPluginFile[] {\n const path = this.getHookConfigPath(ctx);\n const contents = this.buildPluginSource(ctx);\n return [{ path, contents, executable: false }];\n }\n\n /** Compose the generated plugin source with plain string concatenation. */\n private buildPluginSource(ctx: InstallContext): string {\n // The Kilo event keys this connector declares (and that we can map).\n const events = ctx.connector.hookEvents.filter(\n (e): e is HookEventName => EVENT_TO_KILO[e] !== undefined,\n );\n const has = (e: HookEventName) => events.includes(e);\n\n const header = `/**\n * AUTO-GENERATED by agent-connector — DO NOT EDIT.\n *\n * Self-contained Kilo CLI plugin bridge for connector ${ctx.connector.id}.\n * It imports nothing from agent-connector: every hook invocation shells out to\n * the stable home binary's universal entrypoint and JSON-parses the normalized\n * response. Fail-open: any bridge error degrades to \"allow\".\n *\n * Default export is the @kilocode/plugin PluginModule shape\n * ({ id, server: async (input) => Hooks }); the fork loads it because its path\n * is registered in kilo.jsonc's \"plugin\" array.\n */\nimport { execFileSync, execSync } from \"node:child_process\";\n\n${renderBridgePrelude({\n homeBin: ctx.homeBinPath,\n connectorId: ctx.connector.id,\n hookSlug: \"kilo-cli\",\n payloadNoun: \"Kilo\",\n eventDoc: \" (PreToolUse|PostToolUse|SessionStart)\",\n failOpenComment: \"Fail-open — never wedge a tool call on a bridge error.\",\n})}\n`;\n\n const handlers: string[] = [];\n\n if (has(\"PreToolUse\")) {\n handlers.push(` // PreToolUse → block (throw) / rewrite args (mutate output.args).\n \"tool.execute.before\": async (input, output) => {\n const payload = {\n toolName: input.tool ?? \"\",\n toolInput: (output && output.args) ?? {},\n sessionId: input.sessionID ?? \"\",\n projectDir: PROJECT_DIR,\n };\n const res = bridge(\"PreToolUse\", payload);\n if (!res) return;\n // Kilo has no \"ask\" gate — degrade \"ask\" to a block (safe direction).\n if (res.decision === \"deny\" || res.decision === \"ask\") {\n throw new Error(res.reason || \"Blocked by ${ctx.connector.id}\");\n }\n if (res.updatedInput && output && output.args) {\n Object.assign(output.args, res.updatedInput);\n }\n },`);\n }\n\n if (has(\"PostToolUse\")) {\n handlers.push(` // PostToolUse → observe / rewrite tool output (mutate output.output).\n \"tool.execute.after\": async (input, output) => {\n const payload = {\n toolName: input.tool ?? \"\",\n toolInput: input.args ?? {},\n toolOutput: output ? output.output : undefined,\n sessionId: input.sessionID ?? \"\",\n projectDir: PROJECT_DIR,\n };\n const res = bridge(\"PostToolUse\", payload);\n if (!res) return;\n if (typeof res.updatedOutput === \"string\" && output) {\n output.output = res.updatedOutput;\n }\n },`);\n }\n\n if (has(\"SessionStart\")) {\n handlers.push(` // SessionStart surrogate → inject context into the system prompt.\n // The fork has no real SessionStart hook; the system-prompt transform is the\n // verified injection point (mirrors OpenCode).\n \"experimental.chat.system.transform\": async (input, output) => {\n const payload = {\n sessionId: (input && input.sessionID) ?? \"\",\n projectDir: PROJECT_DIR,\n };\n const res = bridge(\"SessionStart\", payload);\n if (!res) return;\n if (res.additionalContext && output && Array.isArray(output.system)) {\n // Insert at index 1 (after the header) to preserve the prompt-cache fold\n // (header must remain system[0]).\n output.system.splice(1, 0, res.additionalContext);\n }\n },`);\n }\n\n if (has(\"UserPromptSubmit\")) {\n handlers.push(` // UserPromptSubmit → context injection on prompt submission.\n // chat.message fires when a new user message arrives; output.parts holds the\n // prompt parts. Inject context by PUSHING a text part onto output.parts.\n // chat.message has NO documented block/abort, so a \"deny\" decision degrades\n // to a NO-OP (best-effort) — mirrors the mimo-code OpenCode fork.\n \"chat.message\": async (input, output) => {\n const promptText =\n output && Array.isArray(output.parts)\n ? output.parts\n .filter((p) => p && p.type === \"text\" && typeof p.text === \"string\")\n .map((p) => p.text)\n .join(\"\\\\n\")\n : \"\";\n const res = bridge(\"UserPromptSubmit\", {\n prompt: promptText,\n sessionId: (input && input.sessionID) || \"\",\n projectDir: PROJECT_DIR,\n });\n if (!res) return;\n if (res.additionalContext && output && Array.isArray(output.parts)) {\n output.parts.push({ type: \"text\", text: res.additionalContext });\n }\n },`);\n }\n\n if (has(\"PermissionRequest\")) {\n handlers.push(` // PermissionRequest → decision-capable permission gate.\n // permission.ask MUTATES output.status (\"ask\"|\"deny\"|\"allow\") — it does NOT\n // return a value (mirrors tool.execute.before mutating output.args). A\n // normalized \"deny\" maps to output.status \"deny\"; \"ask\" to \"ask\"; allow/void\n // leave the default status untouched.\n \"permission.ask\": async (input, output) => {\n const payload = {\n toolName: (input && (input.type || input.tool)) ?? \"\",\n toolInput: (input && (input.metadata || input.args)) ?? {},\n sessionId: (input && input.sessionID) ?? \"\",\n projectDir: PROJECT_DIR,\n };\n const res = bridge(\"PermissionRequest\", payload);\n if (!res || !output) return;\n if (res.decision === \"deny\") output.status = \"deny\";\n else if (res.decision === \"ask\") output.status = \"ask\";\n },`);\n }\n\n if (has(\"Stop\")) {\n handlers.push(` // Stop → session.idle (\"session finished responding\"). session.idle is NOT a\n // direct hook key — it is dispatched through the generic \\`event\\` hook\n // switching on event.type. A block decision throws to halt (Kilo has no\n // Stop-gate return value).\n event: async ({ event }) => {\n if (!event || event.type !== \"session.idle\") return;\n const res = bridge(\"Stop\", {\n sessionId: (event.properties && event.properties.sessionID) || \"\",\n projectDir: PROJECT_DIR,\n });\n if (res && res.decision === \"deny\") {\n throw new Error(res.reason || \"Stop blocked by ${ctx.connector.id}\");\n }\n },`);\n }\n\n const definition = `\nconst plugin = {\n id: CONNECTOR_ID,\n // @kilocode/plugin PluginModule: server(input) returns the Hooks object keyed\n // by the fork's event names. ctx.directory is the project root; fall back to cwd.\n server: async (input) => {\n const PROJECT_DIR =\n (input && (input.directory || (input.worktree && input.worktree.path))) ||\n process.cwd();\n\n return {\n${handlers.join(\"\\n\")}\n };\n },\n};\n\nexport default plugin;\n`;\n\n return header + definition;\n }\n\n // ── Runtime: parse OUR bridge payload → normalized event ───────────────\n\n /**\n * `raw` is the payload OUR generated plugin posts (NOT a host-native shape):\n * { toolName, toolInput, toolOutput?, isError?, sessionId, projectDir }\n * so this maps straight through.\n */\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as KiloBridgePayload;\n const base = {\n hostPlatform: HOST,\n connectorId: \"\",\n sessionId: typeof input.sessionId === \"string\" ? input.sessionId : \"\",\n raw,\n ...(typeof input.projectDir === \"string\" ? { projectDir: input.projectDir } : {}),\n } as const;\n\n switch (event) {\n case \"PreToolUse\": {\n const ev: PreToolUseEvent = {\n ...base,\n toolName: input.toolName ?? \"\",\n toolInput: input.toolInput ?? {},\n };\n return ev;\n }\n case \"PostToolUse\": {\n const ev: PostToolUseEvent = {\n ...base,\n toolName: input.toolName ?? \"\",\n toolInput: input.toolInput ?? {},\n ...(typeof input.toolOutput === \"string\" ? { toolOutput: input.toolOutput } : {}),\n ...(typeof input.isError === \"boolean\" ? { isError: input.isError } : {}),\n };\n return ev;\n }\n case \"SessionStart\": {\n const ev: SessionStartEvent = { ...base, source: \"startup\" };\n return ev;\n }\n case \"UserPromptSubmit\": {\n const ev: UserPromptSubmitEvent = {\n ...base,\n prompt: typeof input.prompt === \"string\" ? input.prompt : \"\",\n };\n return ev;\n }\n case \"PermissionRequest\": {\n const ev: PermissionRequestEvent = {\n ...base,\n toolName: input.toolName ?? \"\",\n toolInput: input.toolInput ?? {},\n };\n return ev;\n }\n case \"Stop\": {\n const ev: StopEvent = { ...base };\n return ev;\n }\n default:\n // Other canonical events are not surfaced by Kilo; treat as a\n // session-start-shaped no-op so the dispatcher fails open gracefully.\n return { ...base, source: \"startup\" } satisfies SessionStartEvent;\n }\n }\n\n // ── Runtime: normalized response → reply the generated bridge parses ───\n\n /**\n * Unlike json-stdio hosts (whose reply is the host's NATIVE control payload),\n * OUR generated bridge consumes this stdout directly. So the reply body is the\n * NORMALIZED HookResponse itself — the bridge JSON.parses it and reads\n * decision / updatedInput / updatedOutput / additionalContext.\n */\n formatReply(_event: HookEventName, response: HookResponse): HookReply {\n return {\n exitCode: 0,\n stdout: JSON.stringify(response ?? { decision: \"allow\" }),\n };\n }\n\n // ── Diagnostics ──────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const configPath = this.getServerConfigPath(ctx);\n const pluginPath = this.getHookConfigPath(ctx);\n const connectorId = ctx.connector.id;\n const hasHooks = ctx.connector.hookEvents.length > 0;\n\n return [\n {\n name: `${this.name}: ${CONFIG_FILE} present`,\n check: () =>\n existsSync(configPath)\n ? { status: \"OK\", detail: configPath }\n : { status: \"FAIL\", detail: `not found: ${configPath}` },\n },\n {\n name: `${this.name}: server entry registered`,\n check: () => {\n if (!ctx.connector.server) {\n return { status: \"OK\", detail: \"no MCP server declared\" };\n }\n const cfg = this.readJson<{ [k: string]: Record<string, unknown> }>(configPath);\n const bucket = cfg?.[MCP_ROOT_KEY];\n if (!cfg || !bucket) {\n return { status: \"FAIL\", detail: `no ${MCP_ROOT_KEY} in ${configPath}` };\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 ${configPath}`,\n };\n },\n },\n {\n name: `${this.name}: plugin module present`,\n check: () => {\n if (!hasHooks) return { status: \"OK\", detail: \"no hooks declared\" };\n return existsSync(pluginPath)\n ? { status: \"OK\", detail: pluginPath }\n : { status: \"FAIL\", detail: `not found: ${pluginPath}` };\n },\n },\n {\n name: `${this.name}: plugin registered in ${PLUGIN_ARRAY_KEY}[]`,\n check: () => {\n if (!hasHooks) return { status: \"OK\", detail: \"no hooks declared\" };\n const cfg = this.readJson<Record<string, unknown>>(configPath);\n const raw = cfg?.[PLUGIN_ARRAY_KEY];\n const plugins = Array.isArray(raw) ? (raw as unknown[]) : undefined;\n return plugins && plugins.includes(pluginPath)\n ? { status: \"OK\", detail: `${PLUGIN_ARRAY_KEY}[] includes module` }\n : {\n status: \"FAIL\",\n detail: `module not in ${PLUGIN_ARRAY_KEY}[] of ${configPath} (fork will not load it)`,\n };\n },\n },\n ];\n }\n\n /** Read a file, returning undefined on any error (idempotency compare). */\n}\n\nexport const adapter = new KiloCliAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuEA,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,YAAY;AAqCrB,IAAM,OAAmB;AAEzB,IAAM,eAAe;AAErB,IAAM,mBAAmB;AAEzB,IAAM,cAAc;AAEpB,IAAM,iBAAiB,CAAC,UAAU,SAAS,QAAQ,SAAS;AAY5D,IAAM,gBAAwD;AAAA,EAC5D,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,cAAc;AAAA;AAAA;AAAA,EAGd,kBAAkB;AAAA;AAAA;AAAA,EAGlB,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOnB,MAAM;AACR;AAoCA,SAAS,mBAA2B;AAClC,SAAO,KAAK,cAAc,GAAG,MAAM;AACrC;AAEO,IAAM,iBAAN,cAA6B,YAA+B;AAAA,EACxD,KAAiB;AAAA,EACjB,OAAO;AAAA,EACP,WAAyB;AA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,WAAW,QAAQ,SAAS,UAAU,IACzC,EAAE,QAAQ,MAAM,QAAQ,GAAG,gBAAgB,qBAAqB,IAChE;AAAA,YACE,QAAQ;AAAA,YACR,QAAQ,iBAAiB,gBAAgB,SAAS,UAAU;AAAA,UAC9D;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAGF;AAEO,IAAM,UAAU,IAAI,eAAe;AAC1C,IAAO,mBAAQ;","names":["entry"]}
|
|
@@ -8,16 +8,16 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
BaseAdapter,
|
|
10
10
|
renderSkillMd
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-RHML2NOB.js";
|
|
12
12
|
import {
|
|
13
13
|
buildHomeBinHookCommand,
|
|
14
14
|
buildWrappedStdio,
|
|
15
15
|
isHomeBinHookCommand
|
|
16
16
|
} from "./chunk-TO57WYBB.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-ALVXORZM.js";
|
|
18
18
|
import {
|
|
19
19
|
ensureDir
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-2HCJV6UO.js";
|
|
21
21
|
|
|
22
22
|
// src/adapters/kimi/index.ts
|
|
23
23
|
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
@@ -325,6 +325,8 @@ var KimiAdapter = class extends BaseAdapter {
|
|
|
325
325
|
}
|
|
326
326
|
];
|
|
327
327
|
}
|
|
328
|
+
const symlink = this.symlinkPathWarning(path);
|
|
329
|
+
if (symlink) return [symlink];
|
|
328
330
|
const cfg = this.readToml(path);
|
|
329
331
|
if (cfg.hooks !== void 0 && !Array.isArray(cfg.hooks)) {
|
|
330
332
|
return [
|
|
@@ -383,6 +385,8 @@ var KimiAdapter = class extends BaseAdapter {
|
|
|
383
385
|
}
|
|
384
386
|
uninstallHooks(ctx) {
|
|
385
387
|
const path = this.getHookConfigPath(ctx);
|
|
388
|
+
const symlink = this.symlinkPathWarning(path);
|
|
389
|
+
if (symlink) return [symlink];
|
|
386
390
|
if (!existsSync(path)) {
|
|
387
391
|
return [{ platform: this.id, action: "skip", path, detail: "no config.toml" }];
|
|
388
392
|
}
|
|
@@ -676,4 +680,4 @@ export {
|
|
|
676
680
|
adapter,
|
|
677
681
|
kimi_default as default
|
|
678
682
|
};
|
|
679
|
-
//# sourceMappingURL=kimi-
|
|
683
|
+
//# sourceMappingURL=kimi-GUSJME55.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/kimi/index.ts"],"sourcesContent":["/**\n * adapters/kimi — Kimi CLI (Moonshot) platform adapter for agent-connector.\n *\n * Kimi CLI is a json-stdio host: the runner pipes a JSON payload to a command on\n * stdin and reads an exit code (and optional reason) back. Two native config\n * files back the install. Their scope-resolution DIFFERS (verified against the\n * kimi-code source, MIT/public — see the Native paths section):\n * - mcp.json → `mcpServers.<id>` MCP registration (JSON, stdio shape:\n * {command,args,env}). Project-local at `<projectDir>/.kimi-code/mcp.json`\n * under project scope, else the user base dir (`$KIMI_CODE_HOME` ||\n * `~/.kimi-code`). Handled via BaseAdapter's JSON helpers.\n * - config.toml → `[[hooks]]` array-of-tables (TOML), each table — ALWAYS the\n * user base dir (Kimi reads no project-local config.toml).\n * { event, matcher, command }. Parsed/serialized with @iarna/toml: every\n * config VALUE (unrelated sections, sibling hooks, scalars) is preserved,\n * but a parse→stringify round-trip does NOT preserve user COMMENTS or the\n * original key ordering/formatting in config.toml (values survive; comments\n * and layout do not).\n *\n * Hook surface is intentionally narrow: Kimi CLI only honors a PreToolUse DENY.\n * It cannot rewrite tool args, rewrite tool output, or inject session context —\n * so every other decision degrades to a silent allow (exit 0). Kimi Code uses\n * the Claude/Codex reply shape: a PreToolUse deny is signalled with EXIT 0 plus\n * a `hookSpecificOutput` JSON object on stdout carrying\n * permissionDecision:\"deny\" + permissionDecisionReason — that is how Kimi's\n * runner blocks the pending tool call. An allow is exit 0 with empty stdout.\n *\n * E1 extension events (verified against moonshotai.github.io/kimi-cli hooks):\n * - PostToolUseFailure — native (tool_name, tool_input, error; tool-name\n * matcher). Feedback-only: Kimi's exit-0 protocol adds non-empty stdout to\n * context, so \"context\" (and a degraded \"deny\") emit plain-text stdout.\n * - SubagentStart / SubagentStop — native, but with Kimi-specific wire\n * fields: agent_name (→ normalized agentType; there is no agent_id) plus\n * prompt (start) / response (stop → lastAssistantMessage). SubagentStop\n * deny uses Kimi's generic block protocol: EXIT 2 with the reason on\n * stderr (fed back to the model as correction).\n * - PermissionRequest — fired just before Kimi waits for user approval\n * (observation only). Wired; its return value does not affect the flow.\n * - The remaining canonical events (PostToolUse, UserPromptSubmit, Stop,\n * SessionStart, SessionEnd, PreCompact, PostCompact, Notification) are all\n * documented Kimi hooks and now wired 1:1 (PascalCase). Of these only\n * UserPromptSubmit + Stop are BLOCKABLE — they share SubagentStop's exit-2\n * block protocol (deny → EXIT 2 + stderr reason); the rest are observation\n * only. Verified against the kimi-code hooks docs (kimi.com/code/docs/en/\n * kimi-code-cli/customization/hooks.html): \"Only blockable events\n * (PreToolUse, Stop, UserPromptSubmit) have return values that affect the\n * main flow. All other events are observation-only.\"\n *\n * Path confidence: the `~/.kimi-code` base + mcp.json (`mcpServers`) layout is\n * PRIMARY-DOC-CONFIRMED against the official Kimi Code CLI docs (config dir\n * `~/.kimi-code/`, override `$KIMI_CODE_HOME` — there is NO `$KIMI_HOME`;\n * moonshotai.github.io/kimi-code/en/configuration/config-files.html +\n * .../customization/mcp.html) and corroborated by a live `kimi doctor config`\n * probe of `@moonshot-ai/kimi-code` v0.18.0 (reads `~/.kimi-code`, honors\n * `$KIMI_CODE_HOME`, ignores `KIMI_HOME`). We still install + doctor-report\n * presence so a future path move surfaces as a FAIL rather than silently\n * misbehaving.\n *\n * NOT YET COVERED: three observation-only Kimi-only events — StopFailure,\n * PermissionResult, Interrupt — are documented but NOT promoted to the core\n * normalized model (each is below the ≥3-host bar for a core HookEventName).\n * A connector that needs them on Kimi can declare them via the nativeHooks\n * passthrough. Kimi also has a PLUGIN system (`<base>/plugins/<name>/\n * kimi.plugin.json`), not yet surfaced.\n */\n\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join, resolve } from \"node:path\";\n\nimport TOML from \"@iarna/toml\";\n\nimport { BaseAdapter } from \"../base.js\";\nimport type { Adapter, HookReply, InstallContext, NormalizedEvent } from \"../spi.js\";\nimport type {\n ChangeRecord,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n NotificationEvent,\n PermissionRequestEvent,\n PlatformCapabilities,\n PlatformId,\n PostToolUseEvent,\n PostToolUseFailureEvent,\n PostCompactEvent,\n PreCompactEvent,\n PreToolUseEvent,\n SessionEndEvent,\n SessionStartEvent,\n ServerDef,\n SkillDef,\n StopEvent,\n SubagentStartEvent,\n SubagentStopEvent,\n Transport,\n UserPromptSubmitEvent,\n} from \"../../core/types.js\";\nimport { renderSkillMd } from \"../claude-code/render.js\";\nimport { ensureDir } from \"../../core/paths.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport {\n buildHomeBinHookCommand,\n buildWrappedStdio,\n isHomeBinHookCommand,\n} from \"../../core/spawn.js\";\nimport { normalizeSessionSource } from \"../claude-code/wire.js\";\n\nconst HOST: PlatformId = \"kimi\";\nconst MCP_ROOT_KEY = \"mcpServers\";\n\n// ─────────────────────────────────────────────────────────────────────────\n// Native shapes\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Raw Kimi CLI hook payload (Claude-style: PascalCase event, snake_case fields). */\ninterface KimiHookInput {\n tool_name?: string;\n tool_input?: Record<string, unknown>;\n // PostToolUse (success) — tool output as a string (kimi turn/index.ts:739,\n // toolOutputText(output).slice(0,2000)). kimi has NO `tool_response` field\n // (0 hits repo-wide; that key is a Claude-Code false-friend); the EVENT TYPE\n // (PostToolUse vs PostToolUseFailure, chosen at turn/index.ts:731) encodes\n // success/failure, so there is also no `is_error` field on the wire.\n tool_output?: string;\n session_id?: string;\n cwd?: string;\n hook_event_name?: string;\n source?: string;\n // UserPromptSubmit — kimi sends `readonly ContentPart[]` (turn/index.ts:571,\n // sole call site; a text prompt is [{type:'text', text}], kosong\n // message.ts:3-6). SubagentStart sends a plain string. Accept both.\n prompt?: unknown;\n is_error?: boolean;\n stop_hook_active?: boolean;\n trigger?: string;\n message?: string;\n reason?: string;\n // PostToolUseFailure — kimi sends a KimiErrorPayload OBJECT\n // {code, message, name?, details?, retryable} (turn/index.ts:738 via\n // toKimiErrorPayload; agent-core errors/serialize.ts:22-27), NOT a string.\n error?: unknown;\n // SubagentStart / SubagentStop — Kimi sends agent_name (NOT agent_id /\n // agent_type) plus prompt (start) / response (stop).\n agent_name?: string;\n response?: string;\n connector?: string;\n}\n\n/** One `[[hooks]]` array-of-tables entry as Kimi stores it in config.toml. */\ninterface KimiTomlHook {\n event: string;\n matcher?: string;\n command: string;\n [key: string]: unknown;\n}\n\n/** Parsed config.toml shape we care about (rest preserved verbatim). */\ninterface KimiConfigToml {\n hooks?: KimiTomlHook[];\n [key: string]: unknown;\n}\n\n/** Native stdio MCP server entry under `mcpServers`. */\ninterface KimiStdioServer {\n command: string;\n args?: string[];\n env?: Record<string, string>;\n}\n\n/** Native remote MCP server entry under `mcpServers`. */\ninterface KimiHttpServer {\n url: string;\n /**\n * Present only for a legacy SSE endpoint. Per the kimi mcp docs a bare `url`\n * (no transport) IS an HTTP server; `transport:\"sse\"` selects the older\n * HTTP+SSE transport.\n */\n transport?: \"sse\";\n headers?: Record<string, string>;\n}\n\n/**\n * Kimi CLI hook events agent-connector registers: every canonical event in the\n * core model — Kimi documents all of them as native hooks (PascalCase 1:1). The\n * PreToolUse matcher below is charset-clean (Rust-regex safe: no look-around) so\n * Kimi's matcher accepts it; copied in spirit from the Codex/context-mode\n * matchers. Order mirrors the core ALL_EVENTS sequence.\n */\nconst KIMI_HOOK_EVENTS = [\n \"SessionStart\",\n \"SessionEnd\",\n \"UserPromptSubmit\",\n \"PreToolUse\",\n \"PostToolUse\",\n \"PreCompact\",\n \"Stop\",\n \"Notification\",\n \"PermissionRequest\",\n \"PostToolUseFailure\",\n \"SubagentStart\",\n \"SubagentStop\",\n \"PostCompact\",\n] as const;\ntype KimiHookEventName = (typeof KIMI_HOOK_EVENTS)[number];\n\n/**\n * Canonical events with NO Kimi analog. Kimi documents a native hook for EVERY\n * current core event, so this is empty today. It stays as the seam: if a future\n * core HookEventName lands that Kimi cannot fire, add it here and declared hooks\n * for it warn-skip at install — the degradation is reported, never silent.\n */\nconst WARN_SKIP_EVENTS: ReadonlySet<HookEventName> = new Set<HookEventName>([]);\n\nconst PRE_TOOL_USE_MATCHER =\n \"Bash|Shell|shell|exec_command|Read|Edit|Write|WebFetch|Agent|mcp__\";\n\n// ─────────────────────────────────────────────────────────────────────────\n// Adapter\n// ─────────────────────────────────────────────────────────────────────────\n\nexport class KimiAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"Kimi CLI\";\n readonly paradigm: HookParadigm = \"json-stdio\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: AGENTS.md-first managed block via the BaseAdapter default\n // (memoryTargets: project <projectDir>/AGENTS.md; user scope where documented).\n supportsMemory: true,\n // Kimi documents a native hook for EVERY canonical event. BLOCKABLE decisions\n // (deny that affects the flow) are honored only for PreToolUse, Stop and\n // UserPromptSubmit per the docs; the rest fire observation-only, but we still\n // register them so a connector's handler runs (e.g. for telemetry/context).\n preToolUse: true,\n postToolUse: true,\n preCompact: true,\n sessionStart: true,\n sessionEnd: true,\n userPromptSubmit: true,\n stop: true,\n notification: true,\n permissionRequest: true,\n postToolUseFailure: true,\n subagentStart: true,\n subagentStop: true,\n postCompact: true,\n // Kimi cannot rewrite args/output nor inject session context — deny-only.\n canModifyArgs: false,\n canModifyOutput: false,\n canInjectSessionContext: false,\n // Kimi documents three MCP transports: stdio, HTTP and (legacy) SSE — a\n // url entry with transport:\"sse\" (kimi.com/code/docs/en/kimi-code-cli/\n // customization/mcp.html: \"supports three MCP server connection methods\").\n transports: [\"stdio\", \"http\", \"sse\"],\n // Skills surface: Kimi reads SKILL.md from ~/.kimi-code/skills/<name>/SKILL.md\n // (user scope) and <projectDir>/.kimi-code/skills/<name>/SKILL.md (project\n // scope). Both are documented scan dirs (docs/en/customization/skills.md;\n // \"Project > User\" priority). Project-local mcp.json is likewise read\n // (docs/en/customization/mcp.md); config.toml/hooks are user-only.\n supportsSkills: true,\n // Native passthrough hooks: Kimi's observation-only single-host events —\n // StopFailure, PermissionResult, Interrupt — have NO normalized HookEventName\n // (below the >=3-host core bar; see\n // docs/research/host-specific-hook-events-design.md). A connector reaches them\n // by declaring platforms[\"kimi\"].nativeHooks; installHooks writes those\n // event-name [[hooks]] entries verbatim, and the generic uninstall reverses them.\n supportsNativeHooks: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(_projectDir: string): DetectedPlatform {\n const baseDir = this.baseDir();\n const mcpPath = join(baseDir, \"mcp.json\");\n const configPath = join(baseDir, \"config.toml\");\n const installed = existsSync(baseDir) || existsSync(mcpPath) || existsSync(configPath);\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath: mcpPath,\n scope: \"user\",\n reason: installed\n ? `found Kimi CLI config under ${baseDir}`\n : `no Kimi CLI config at ${baseDir}`,\n // Path confidence is high: the ~/.kimi-code base (override $KIMI_CODE_HOME) is\n // the primary-doc-verified shape (moonshotai.github.io/kimi-code/en/\n // configuration/config-files.html) and live-confirmed via `kimi doctor config`\n // on @moonshot-ai/kimi-code v0.18.0.\n confidence: \"high\",\n };\n }\n\n // ── Native paths ───────────────────────────────────────────────────────\n //\n // Kimi's config surfaces are NOT uniformly project-aware — each one resolves\n // from a different root, verified against the kimi-code source (MIT, public):\n // - mcp.json (MCP) → project-local SUPPORTED. config-loader.ts loads\n // three sources and `project: join(cwd, '.kimi-code', 'mcp.json')` wins\n // over user (`~/.kimi-code/mcp.json`). Doc: docs/en/customization/mcp.md\n // (\"Project level: .kimi-code/mcp.json\").\n // - skills → project-local SUPPORTED (.kimi-code/skills/, scanned\n // above the user dir). Doc: docs/en/customization/skills.md.\n // - config.toml (hooks) → USER-ONLY. config/path.ts resolveConfigPath()\n // resolves it solely from resolveKimiHome (KIMI_CODE_HOME ?? ~/.kimi-code);\n // config/toml.ts loadRuntimeConfigSafe reads that SINGLE file with no\n // cwd/project merge. There is no project-local config.toml — so a\n // project-scope install must still write hooks to the user base dir or\n // Kimi never loads them.\n // Hence getConfigDir() (the project-aware root) drives MCP + skills, while\n // getHookConfigPath() stays pinned to baseDir() regardless of scope.\n\n /**\n * Project-aware config dir: `<projectDir>/.kimi-code` for project scope, else\n * the user base dir. Mirrors codex's getConfigDir. Drives the surfaces Kimi\n * reads project-locally (mcp.json + skills) — NOT config.toml (see below).\n */\n getConfigDir(ctx: InstallContext): string {\n if (ctx.scope === \"project\") return join(ctx.projectDir, \".kimi-code\");\n return this.baseDir();\n }\n\n /** MCP registration file (JSON) — project-local under project scope. */\n getServerConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"mcp.json\");\n }\n\n /**\n * Hook registration file (TOML) — ALWAYS the user base dir. Kimi resolves\n * config.toml only from KIMI_CODE_HOME ?? ~/.kimi-code (no project-local\n * variant), so this intentionally ignores ctx.scope: a project-scope install\n * writes hooks here so Kimi actually fires them.\n */\n getHookConfigPath(_ctx: InstallContext): string {\n return join(this.baseDir(), \"config.toml\");\n }\n\n /**\n * `$KIMI_CODE_HOME` (with `~` expansion, then resolved) when set & non-empty,\n * else `~/.kimi-code`. This mirrors `codexConfigHome()` in core/host-paths.ts\n * (tilde-expand-then-default) so the writer and any probe agree on the dir.\n *\n * Per the official Kimi Code CLI docs the config dir is `~/.kimi-code/`,\n * overridable ONLY by `$KIMI_CODE_HOME` — there is NO `$KIMI_HOME` env var, so\n * the old `$KIMI_HOME`-first resolution was the bug (with `$KIMI_HOME` set the\n * adapter wrote where Kimi never reads). Doc:\n * moonshotai.github.io/kimi-code/en/configuration/config-files.html;\n * live-confirmed by `kimi doctor config` on @moonshot-ai/kimi-code v0.18.0.\n */\n private baseDir(): string {\n const env = process.env.KIMI_CODE_HOME;\n if (env && env.trim() !== \"\") {\n if (env.startsWith(\"~\")) {\n return join(homedir(), env.replace(/^~[/\\\\]?/, \"\"));\n }\n return resolve(env);\n }\n return join(homedir(), \".kimi-code\");\n }\n\n // ── MCP server install / uninstall (mcp.json → mcpServers.<id>) ──────────\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 kimi\"\n : \"connector declares no MCP server\",\n },\n ];\n }\n\n const server: ServerDef =\n override && typeof override === \"object\"\n ? { ...connector.server, ...override }\n : connector.server;\n\n const changes: ChangeRecord[] = [];\n // Honesty: Kimi documents only stdio/http/sse. A connector declaring another\n // transport (e.g. the non-spec \"ws\") is still rendered best-effort as a bare\n // URL entry, but the mismatch is REPORTED rather than silently misregistered\n // — same \"degradation is never silent\" posture as the hook warn-skips.\n if (!this.capabilities.transports.includes(server.transport)) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `transport \"${server.transport}\" is not a Kimi MCP transport (stdio/http/sse); registered best-effort as a URL entry`,\n });\n }\n\n const serverPath = this.getServerConfigPath(ctx);\n const entry = this.renderServerEntry(ctx, server);\n changes.push(\n this.upsertServerInJson(serverPath, MCP_ROOT_KEY, connector.id, entry, ctx.dryRun),\n );\n return changes;\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 /**\n * Render a normalized ServerDef into Kimi's native mcpServers entry. Kimi's\n * mcp.json has no documented native interpolation, so `${env:VAR}` refs are\n * resolved to literals at install time (same posture as the TOML hosts).\n */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): KimiStdioServer | KimiHttpServer {\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 through\n // `<homeBin> serve --connector <id> -- <command> <args...>`.\n ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));\n\n command = resolveEnvRefsDeep(command);\n args = resolveEnvRefsDeep(args);\n\n const entry: KimiStdioServer = { command };\n if (args.length > 0) entry.args = args;\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n return entry;\n }\n\n // Remote transports — Kimi registers a URL entry. A bare `url` is an HTTP\n // server; a legacy HTTP+SSE endpoint needs transport:\"sse\". (ws is not a\n // Kimi-documented transport — it falls through as a plain url, best-effort.)\n const entry: KimiHttpServer = { url: resolveEnvRefsDeep(server.url ?? \"\") };\n if (transport === \"sse\") entry.transport = \"sse\";\n const headers = this.renderEnv(server.headers);\n if (headers) entry.headers = headers;\n return entry;\n }\n\n /** Resolve env/header values to literals (no native interpolation on Kimi). */\n private renderEnv(\n env: Record<string, string> | undefined,\n ): Record<string, string> | undefined {\n if (!env || Object.keys(env).length === 0) return undefined;\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(resolveEnvRefsDeep(env))) {\n out[k] = String(v);\n }\n return out;\n }\n\n // ── Skills surface ────────────────────────────────────────────────────────\n // Kimi reads SKILL.md from <skills dir>/<name>/SKILL.md, scanning project then\n // user (docs/en/customization/skills.md, \"Project > User\"):\n // user scope: ~/.kimi-code/skills/<name>/SKILL.md\n // project scope: <projectDir>/.kimi-code/skills/<name>/SKILL.md\n // Derived from getConfigDir(ctx) so skills + mcp.json share ONE scope-resolved\n // root (config.toml/hooks deliberately do not — see getHookConfigPath).\n\n private skillsDir(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"skills\");\n }\n\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.skillsDir(ctx), 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 kimi\" }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n changes.push(\n this.writeContentFile(join(dir, \"SKILL.md\"), this.renderSkill(skill), ctx.dryRun),\n );\n 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 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;\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n private renderSkill(skill: SkillDef): string {\n return renderSkillMd(skill);\n }\n\n // ── Hook install / uninstall (config.toml → [[hooks]]) ───────────────────\n\n installHooks(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n const override = connector.platforms[HOST];\n\n // `hooks: false` disables only the NORMALIZED events (effectiveHookEvents /\n // warnSkipHookEvents already return [] for it). nativeHooks is a sibling,\n // kimi-scoped declaration on the same override and installs regardless.\n const events = this.effectiveHookEvents(ctx);\n const dropped = this.warnSkipHookEvents(ctx);\n const nativeHooks = override?.nativeHooks ?? {};\n const nativeEvents = Object.keys(nativeHooks);\n const path = this.getHookConfigPath(ctx);\n\n if (events.length === 0 && dropped.length === 0 && nativeEvents.length === 0) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path,\n detail: override?.hooks === false ? \"hooks disabled for kimi\" : \"no hooks declared\",\n },\n ];\n }\n\n const symlink = this.symlinkPathWarning(path);\n if (symlink) return [symlink];\n\n const cfg = this.readToml(path);\n // Kimi's `hooks` is an ARRAY-of-tables ([[hooks]]); the BaseAdapter object-map\n // guard would mis-flag it. Inverse guard: a present-but-non-array `hooks`\n // (hand-edited to an object/primitive) cannot take `.push`/`.findIndex` — warn\n // and skip so the user's malformed value is preserved untouched.\n if (cfg.hooks !== undefined && !Array.isArray(cfg.hooks)) {\n return [\n {\n platform: this.id,\n action: \"warn\",\n path,\n detail: `existing \"hooks\" in ${path} is not an array; left untouched (fix it, then re-run)`,\n },\n ];\n }\n const hooks = (cfg.hooks ??= []);\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n // Declared events Kimi cannot fire are reported, never silently dropped.\n for (const event of dropped) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n path,\n detail: `${event} has no Kimi CLI hook equivalent — skipped`,\n });\n }\n\n for (const event of events) {\n const desired = this.renderHook(ctx, event);\n // Match our entry FOR THIS EVENT — isOurHook alone would find whichever\n // of our entries comes first and clobber a sibling event's registration.\n const idx = hooks.findIndex((h) => this.isOurHook(ctx, h) && h?.event === event);\n if (idx < 0) {\n hooks.push(desired);\n changes.push({ platform: this.id, action: \"create\", path, detail: `hooks.${event}` });\n mutated = true;\n } else if (JSON.stringify(hooks[idx]) !== JSON.stringify(desired)) {\n hooks[idx] = desired;\n changes.push({ platform: this.id, action: \"update\", path, detail: `hooks.${event}` });\n mutated = true;\n } else {\n changes.push({ platform: this.id, action: \"skip\", path, detail: `hooks.${event}` });\n }\n }\n\n // NATIVE passthrough events: Kimi-native event names (e.g. StopFailure,\n // PermissionResult, Interrupt) written VERBATIM as [[hooks]] entries — no\n // canonical mapping, same command shape + idempotency. Matched by EXACT\n // command so a native name that coincides with a canonical event never\n // clobbers it.\n for (const event of nativeEvents) {\n const command = buildHomeBinHookCommand(ctx.homeBinPath, HOST, event, connector.id);\n const desired = { event, matcher: nativeHooks[event]?.matcher ?? \"\", command };\n const idx = hooks.findIndex((h) => h?.event === event && h?.command === command);\n if (idx < 0) {\n hooks.push(desired);\n changes.push({ platform: this.id, action: \"create\", path, detail: `hooks.${event} (native)` });\n mutated = true;\n } else if (JSON.stringify(hooks[idx]) !== JSON.stringify(desired)) {\n hooks[idx] = desired;\n changes.push({ platform: this.id, action: \"update\", path, detail: `hooks.${event} (native)` });\n mutated = true;\n } else {\n changes.push({ platform: this.id, action: \"skip\", path, detail: `hooks.${event} (native)` });\n }\n }\n\n if (mutated) this.writeToml(path, cfg, ctx.dryRun);\n return changes;\n }\n\n uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n const path = this.getHookConfigPath(ctx);\n const symlink = this.symlinkPathWarning(path);\n if (symlink) return [symlink];\n\n if (!existsSync(path)) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no config.toml\" }];\n }\n const cfg = this.readToml(path);\n const hooks = cfg.hooks;\n if (!Array.isArray(hooks) || hooks.length === 0) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no hooks present\" }];\n }\n\n const kept = hooks.filter((h) => !this.isOurHook(ctx, h));\n const removed = hooks.length - kept.length;\n if (removed === 0) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no agent-connector hooks present\" }];\n }\n\n if (kept.length > 0) cfg.hooks = kept;\n else delete cfg.hooks;\n this.writeToml(path, cfg, ctx.dryRun);\n return [{ platform: this.id, action: \"remove\", path, detail: `hooks (${removed})` }];\n }\n\n // ── Diagnostics ──────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const serverPath = this.getServerConfigPath(ctx);\n const hookPath = this.getHookConfigPath(ctx);\n const connectorId = ctx.connector.id;\n const homeBin = ctx.homeBinPath;\n const hookEvents = this.effectiveHookEvents(ctx);\n const checks: HealthCheck[] = [\n {\n name: `${this.name}: mcp.json present`,\n check: () =>\n existsSync(serverPath)\n ? { status: \"OK\", detail: serverPath }\n : { status: \"FAIL\", detail: `not found: ${serverPath}` },\n },\n {\n name: `${this.name}: mcpServers.${connectorId} registered`,\n check: () => {\n if (!ctx.connector.server) {\n return { status: \"OK\", detail: \"no MCP server declared\" };\n }\n const cfg = this.readJson<Record<string, Record<string, unknown>>>(serverPath);\n const bucket = cfg?.[MCP_ROOT_KEY];\n const present =\n typeof bucket === \"object\" && bucket !== null && connectorId in bucket;\n return present\n ? { status: \"OK\", detail: `mcpServers.${connectorId}` }\n : { status: \"FAIL\", detail: `mcpServers.${connectorId} not found in ${serverPath}` };\n },\n },\n {\n name: `${this.name}: hook command registered`,\n check: () => {\n if (hookEvents.length === 0) {\n return { status: \"OK\", detail: \"no hooks declared\" };\n }\n if (!existsSync(hookPath)) {\n return { status: \"FAIL\", detail: `not found: ${hookPath}` };\n }\n const cfg = this.readToml(hookPath);\n const registered = (cfg.hooks ?? []).some((h) =>\n isHomeBinHookCommand(h?.command, homeBin, connectorId),\n );\n return registered\n ? { status: \"OK\", detail: \"hook command present\" }\n : { status: \"FAIL\", detail: `no hook for ${connectorId} in ${hookPath}` };\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 return checks;\n }\n\n // ── Runtime: parse Kimi stdin JSON → normalized event ────────────────────\n\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as KimiHookInput;\n const connectorId = typeof input.connector === \"string\" ? input.connector : \"\";\n const sessionId = input.session_id ?? `pid-${process.ppid}`;\n const projectDir = input.cwd ?? process.env.KIMI_PROJECT_DIR ?? process.cwd();\n\n const base = {\n hostPlatform: HOST,\n connectorId,\n sessionId,\n projectDir,\n raw,\n } as const;\n\n switch (event) {\n case \"PreToolUse\": {\n const ev: PreToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n };\n return ev;\n }\n case \"PostToolUse\": {\n const ev: PostToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n ...(typeof input.tool_output === \"string\"\n ? { toolOutput: input.tool_output }\n : {}),\n // kimi sends no `is_error` on the wire; success is encoded by the\n // event type (PostToolUseFailure fires on failure), so `?? false`\n // is always the correct value here.\n isError: input.is_error ?? false,\n };\n return ev;\n }\n case \"SessionStart\": {\n const ev: SessionStartEvent = {\n ...base,\n source: normalizeSessionSource(input.source),\n };\n return ev;\n }\n case \"SessionEnd\": {\n const ev: SessionEndEvent = {\n ...base,\n ...(typeof input.message === \"string\" ? { reason: input.message } : {}),\n };\n return ev;\n }\n case \"UserPromptSubmit\": {\n const ev: UserPromptSubmitEvent = {\n ...base,\n prompt: extractPromptText(input.prompt),\n };\n return ev;\n }\n case \"PreCompact\": {\n const ev: PreCompactEvent = {\n ...base,\n ...(input.trigger === \"auto\" || input.trigger === \"manual\"\n ? { trigger: input.trigger }\n : {}),\n };\n return ev;\n }\n case \"PostCompact\": {\n // Kimi fires PostCompact after compaction completes (observation only),\n // payload `trigger`: manual|auto — mirrors PreCompact.\n const ev: PostCompactEvent = {\n ...base,\n ...(input.trigger === \"auto\" || input.trigger === \"manual\"\n ? { trigger: input.trigger }\n : {}),\n };\n return ev;\n }\n case \"Stop\": {\n const ev: StopEvent = {\n ...base,\n ...(typeof input.stop_hook_active === \"boolean\"\n ? { stopHookActive: input.stop_hook_active }\n : {}),\n };\n return ev;\n }\n case \"Notification\": {\n const ev: NotificationEvent = {\n ...base,\n message: typeof input.message === \"string\" ? input.message : \"\",\n };\n return ev;\n }\n case \"PermissionRequest\": {\n // Kimi fires PermissionRequest just before waiting for user approval\n // (observation only); payload subject is the tool name.\n const ev: PermissionRequestEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n };\n return ev;\n }\n case \"PostToolUseFailure\": {\n // Kimi documents tool_name/tool_input/error only (no tool_use_id /\n // is_interrupt / duration_ms) — the optionals stay unset.\n const ev: PostToolUseFailureEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n error: extractErrorMessage(input.error),\n };\n return ev;\n }\n case \"SubagentStart\": {\n // Kimi sends agent_name (the matcher subject) — normalize it as\n // agentType; there is no agent_id. The start prompt rides in `raw`.\n const ev: SubagentStartEvent = {\n ...base,\n ...(typeof input.agent_name === \"string\"\n ? { agentType: input.agent_name }\n : {}),\n };\n return ev;\n }\n case \"SubagentStop\": {\n const ev: SubagentStopEvent = {\n ...base,\n ...(typeof input.agent_name === \"string\"\n ? { agentType: input.agent_name }\n : {}),\n ...(typeof input.response === \"string\"\n ? { lastAssistantMessage: input.response }\n : {}),\n };\n return ev;\n }\n default: {\n const _never: never = event;\n throw new Error(`unsupported kimi hook event: ${String(_never)}`);\n }\n }\n }\n\n // ── Runtime: normalized response → Kimi native hook reply ────────────────\n\n formatReply(event: HookEventName, response: HookResponse): HookReply {\n const decision = response.decision ?? \"allow\";\n\n // deny → block the pending tool call. Kimi Code uses the Claude/Codex reply\n // shape: EXIT 0 + a `hookSpecificOutput` JSON object on stdout carrying\n // permissionDecision:\"deny\". PreToolUse is the only event using this\n // structured reply; the other blockable events (Stop, UserPromptSubmit,\n // SubagentStop) use the generic exit-2 protocol below.\n if (decision === \"deny\" && 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\n // PostToolUseFailure (feedback beside the error) and SubagentStart (context\n // for the subagent) are observe/context-only: Kimi's documented protocol\n // adds non-empty stdout on exit 0 to context, so \"context\" emits the text\n // PLAIN (no JSON envelope) and a \"deny\" DEGRADES to the same shape carrying\n // the reason (the tool already failed / the spawn is not blockable).\n if (event === \"PostToolUseFailure\" || event === \"SubagentStart\") {\n const context =\n decision === \"context\"\n ? response.additionalContext\n : decision === \"deny\"\n ? response.reason ?? response.additionalContext\n : undefined;\n if (context) return { exitCode: 0, stdout: context };\n return { exitCode: 0 };\n }\n\n // BLOCKABLE events via Kimi's generic block protocol: deny → EXIT 2 with the\n // reason on stderr (fed back to the model). Per the kimi-code docs the\n // blockable events are PreToolUse (handled above with its structured reply),\n // Stop and UserPromptSubmit; SubagentStop reuses the same Stop semantics. For\n // Stop the stderr reason lets the model continue; for UserPromptSubmit EXIT 2\n // blocks the turn (the model is not called). \"context\" rides the exit-0\n // stdout channel (Kimi appends non-empty stdout to context).\n if (event === \"SubagentStop\" || event === \"Stop\" || event === \"UserPromptSubmit\") {\n if (decision === \"deny\") {\n return { exitCode: 2, stderr: response.reason ?? \"Blocked by hook\" };\n }\n if (decision === \"context\" && response.additionalContext) {\n return { exitCode: 0, stdout: response.additionalContext };\n }\n return { exitCode: 0 };\n }\n\n // allow / modify / context / ask / unsupported-event → passthrough (exit 0,\n // empty stdout). Kimi cannot rewrite args/output or inject context, so those\n // are dropped.\n return { exitCode: 0 };\n }\n\n // ── Internal helpers ───────────────────────────────────────────────────\n\n /** Which canonical hook events to register for Kimi, honoring overrides. */\n private effectiveHookEvents(ctx: InstallContext): KimiHookEventName[] {\n if (ctx.connector.platforms[HOST]?.hooks === false) return [];\n return KIMI_HOOK_EVENTS.filter((e) => ctx.connector.hookEvents.includes(e));\n }\n\n /** Declared events Kimi has no analog for — install reports a warn-skip. */\n private warnSkipHookEvents(ctx: InstallContext): HookEventName[] {\n if (ctx.connector.platforms[HOST]?.hooks === false) return [];\n return ctx.connector.hookEvents.filter((e) => WARN_SKIP_EVENTS.has(e));\n }\n\n /**\n * Render one `[[hooks]]` entry pointing at the stable home binary. Only the\n * PreToolUse deny gate carries the native tool matcher; the E1 events register\n * \"\" (match every tool failure / agent name) and the universal entrypoint\n * applies the connector's own matcher at runtime.\n */\n private renderHook(ctx: InstallContext, event: KimiHookEventName): KimiTomlHook {\n const command = buildHomeBinHookCommand(ctx.homeBinPath, HOST, event, ctx.connector.id);\n return {\n event,\n matcher: event === \"PreToolUse\" ? PRE_TOOL_USE_MATCHER : \"\",\n command,\n };\n }\n\n /**\n * Does this `[[hooks]]` entry belong to this connector? Anchored on the\n * home-bin + connector-id token (isHomeBinHookCommand) so uninstalling a\n * shared-prefix connector id never strips a sibling's hook.\n */\n private isOurHook(ctx: InstallContext, hook: KimiTomlHook | undefined): boolean {\n if (!hook || typeof hook !== \"object\") return false;\n return isHomeBinHookCommand(hook.command, ctx.homeBinPath, ctx.connector.id);\n }\n\n // ── TOML config IO (config.toml is TOML; MCP stays JSON via BaseAdapter) ──\n\n private readToml(path: string): KimiConfigToml {\n if (!existsSync(path)) return {};\n try {\n return TOML.parse(readFileSync(path, \"utf8\")) as unknown as KimiConfigToml;\n } catch {\n return {};\n }\n }\n\n private writeToml(path: string, data: KimiConfigToml, dryRun: boolean): void {\n if (dryRun) return;\n ensureDir(dirname(path));\n // NOTE: a @iarna/toml parse→stringify round-trip preserves config VALUES but\n // NOT user comments or the original key ordering/formatting in config.toml.\n // Values are safe; comments authored by the user are not preserved.\n writeFileSync(path, TOML.stringify(data as never), \"utf8\");\n }\n}\n\n/**\n * Extract the prompt text from Kimi's UserPromptSubmit payload. Kimi sends\n * `readonly ContentPart[]` (turn/index.ts:571); a text prompt is\n * [{type:'text', text}] (kosong message.ts:3-6). Concatenate the `text` of the\n * text parts. A plain string (e.g. SubagentStart) is returned as-is.\n */\nfunction extractPromptText(prompt: unknown): string {\n if (typeof prompt === \"string\") return prompt;\n if (Array.isArray(prompt)) {\n return prompt\n .map((part) =>\n part && typeof (part as { text?: unknown }).text === \"string\"\n ? (part as { text: string }).text\n : \"\",\n )\n .join(\"\");\n }\n return \"\";\n}\n\n/**\n * Extract the failure message from Kimi's PostToolUseFailure payload. Kimi\n * sends a KimiErrorPayload object {code, message, ...} (turn/index.ts:738);\n * use its `message`. A plain string is accepted defensively.\n */\nfunction extractErrorMessage(error: unknown): string {\n if (typeof error === \"string\") return error;\n if (error && typeof (error as { message?: unknown }).message === \"string\") {\n return (error as { message: string }).message;\n }\n return \"\";\n}\n\nexport const adapter = new KimiAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkEA,SAAS,YAAY,cAAc,qBAAqB;AACxD,SAAS,eAAe;AACxB,SAAS,SAAS,MAAM,eAAe;AAEvC,OAAO,UAAU;AAwCjB,IAAM,OAAmB;AACzB,IAAM,eAAe;AAgFrB,IAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AASA,IAAM,mBAA+C,oBAAI,IAAmB,CAAC,CAAC;AAE9E,IAAM,uBACJ;AAMK,IAAM,cAAN,cAA0B,YAA+B;AAAA,EACrD,KAAiB;AAAA,EACjB,OAAO;AAAA,EACP,WAAyB;AAAA,EAEzB,eAAqC;AAAA;AAAA;AAAA,IAG5C,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA,IAKhB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,MAAM;AAAA,IACN,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,IACpB,eAAe;AAAA,IACf,cAAc;AAAA,IACd,aAAa;AAAA;AAAA,IA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names":["entry"]}
|
|
@@ -8,14 +8,14 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
BaseAdapter,
|
|
10
10
|
renderSkillMd
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-RHML2NOB.js";
|
|
12
12
|
import {
|
|
13
13
|
buildHomeBinHookCommand,
|
|
14
14
|
buildWrappedStdio,
|
|
15
15
|
isHomeBinHookCommand
|
|
16
16
|
} from "./chunk-TO57WYBB.js";
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-ALVXORZM.js";
|
|
18
|
+
import "./chunk-2HCJV6UO.js";
|
|
19
19
|
|
|
20
20
|
// src/adapters/kiro/index.ts
|
|
21
21
|
import { existsSync } from "fs";
|
|
@@ -471,7 +471,7 @@ var KiroAdapter = class extends BaseAdapter {
|
|
|
471
471
|
case "Stop": {
|
|
472
472
|
const ev = {
|
|
473
473
|
...base,
|
|
474
|
-
...typeof input.
|
|
474
|
+
...typeof input.assistant_response === "string" ? { lastAssistantMessage: input.assistant_response } : {}
|
|
475
475
|
};
|
|
476
476
|
return ev;
|
|
477
477
|
}
|
|
@@ -518,4 +518,4 @@ export {
|
|
|
518
518
|
adapter,
|
|
519
519
|
kiro_default as default
|
|
520
520
|
};
|
|
521
|
-
//# sourceMappingURL=kiro-
|
|
521
|
+
//# sourceMappingURL=kiro-6OHZ5RGV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/kiro/index.ts"],"sourcesContent":["/**\n * adapters/kiro — Kiro (AWS) platform adapter for agent-connector.\n *\n * Kiro is a json-stdio host with TWO native config surfaces that live in\n * DIFFERENT files (so getServerConfigPath ≠ getHookConfigPath):\n *\n * 1. MCP servers — `mcp.json` under `~/.kiro/settings/` (user) or\n * `<projectDir>/.kiro/settings/` (project). The file is JSONC; we WRITE\n * plain JSON (valid JSONC), mirroring the other JSON-config adapters. Root\n * key `mcpServers`; a stdio server is `{ command, args, env }`.\n * Ref: https://kiro.dev/docs/mcp/configuration/\n *\n * 2. Hooks — NOT a settings file but an AGENT file:\n * `~/.kiro/agents/kiro_default.json`. Kiro auto-loads the built-in default\n * agent `kiro_default` for a new chat session, so hooks must register on\n * THAT agent (a file literally named `default.json` would define an inactive\n * custom agent the user must `/agent`-swap to). We merge a `hooks` key into\n * the existing agent JSON, creating a minimal agent object if absent.\n * Ref: kiro.dev/docs/cli/custom-agents/configuration-reference#hooks-field\n *\n * Hook protocol is EXIT-CODE based (unlike Claude's JSON-decision wrapper):\n * - exit 0 → allow the action.\n * - exit 2 → block the action; the reason is written to stderr (PreToolUse).\n * - context injection → exit 0 with the guidance text written as PLAIN STDOUT\n * (NOT a JSON envelope). Kiro adds a hook's STDOUT to the agent's context\n * ONLY for agentSpawn and userPromptSubmit; for preToolUse / postToolUse /\n * stop the docs say STDOUT is \"captured but not shown\" — there is no\n * context channel, so a `context` decision on those degrades to exit 0.\n * Ref: https://kiro.dev/docs/cli/hooks (Hook output / Hook types).\n * Kiro CANNOT rewrite tool arguments or output (exit codes only), so\n * canModifyArgs / canModifyOutput are false; `modify` degrades to allow.\n *\n * Native hook event vocabulary differs from the canonical names and is mapped:\n * PreToolUse → preToolUse\n * PostToolUse → postToolUse\n * SessionStart → agentSpawn (Kiro's session-start equivalent)\n * UserPromptSubmit → userPromptSubmit\n * Stop → stop (documented Kiro hook)\n * Kiro has no equivalent for PreCompact / SessionEnd / Notification; those are\n * reported as a warn/skip at install time.\n *\n * Env handling: Kiro documents no `${env:VAR}` token of the framework's syntax,\n * so env/header/url refs are resolved to literals at install time via\n * resolveEnvRefsDeep — the safe default matching the Gemini/Codex adapters.\n *\n * Grounded in context-mode's proven Kiro adapter (src/adapters/kiro/*).\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, HookReply, InstallContext, MemoryTarget, NormalizedEvent } from \"../spi.js\";\nimport type {\n ChangeRecord,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n PlatformCapabilities,\n PlatformId,\n PostToolUseEvent,\n PreToolUseEvent,\n ServerDef,\n SessionStartEvent,\n SkillDef,\n StopEvent,\n Transport,\n UserPromptSubmitEvent,\n} from \"../../core/types.js\";\nimport { renderSkillMd } from \"../claude-code/render.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport {\n buildHomeBinHookCommand,\n buildWrappedStdio,\n isHomeBinHookCommand,\n} from \"../../core/spawn.js\";\nimport { normalizeSessionSource } from \"../claude-code/wire.js\";\n\nconst HOST: PlatformId = \"kiro\";\nconst MCP_ROOT_KEY = \"mcpServers\";\n\n/** The built-in agent Kiro auto-loads for a new chat session. */\nconst DEFAULT_AGENT_FILE = \"kiro_default.json\";\n\n/**\n * Kiro-native hook event names (the keys under an agent file's `hooks` object).\n * Only the events Kiro actually fires for the json-stdio command paradigm.\n */\nconst KIRO_EVENT = {\n preToolUse: \"preToolUse\",\n postToolUse: \"postToolUse\",\n agentSpawn: \"agentSpawn\",\n userPromptSubmit: \"userPromptSubmit\",\n stop: \"stop\",\n} as const;\n\n/**\n * Map canonical event names → Kiro's native hook event names. Only the events\n * Kiro supports are present; PreCompact / SessionEnd / Notification have no Kiro\n * equivalent and are reported as a warn/skip at install time.\n */\nconst EVENT_MAP: Partial<Record<HookEventName, string>> = {\n PreToolUse: KIRO_EVENT.preToolUse,\n PostToolUse: KIRO_EVENT.postToolUse,\n SessionStart: KIRO_EVENT.agentSpawn,\n UserPromptSubmit: KIRO_EVENT.userPromptSubmit,\n Stop: KIRO_EVENT.stop,\n};\n\n/**\n * Kiro events whose hook STDOUT is added to the agent's context: agentSpawn\n * (≈ SessionStart) and userPromptSubmit. For preToolUse / postToolUse / stop the\n * docs say STDOUT is \"captured but not shown to user\" — no context channel — so a\n * `context` decision on those degrades to a plain exit-0 pass-through.\n * Ref: https://kiro.dev/docs/cli/hooks\n */\nconst CONTEXT_EVENTS: ReadonlySet<string> = new Set([\n KIRO_EVENT.agentSpawn,\n KIRO_EVENT.userPromptSubmit,\n]);\n\n/** A single Kiro native hook registration entry (Claude-shaped, nested). */\ninterface KiroHookEntry {\n matcher: string;\n hooks: Array<{ type: \"command\"; command: string }>;\n}\n\n/** The shape of a Kiro agent file (only the parts we touch). */\ninterface KiroAgentFile {\n hooks?: Record<string, KiroHookEntry[]>;\n [key: string]: unknown;\n}\n\n/** The shape of Kiro's mcp.json (only the parts we touch). */\ninterface KiroMcpFile {\n mcpServers?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\n/** Native MCP server entry shapes Kiro accepts under `mcpServers`. */\ninterface KiroStdioServer {\n command: string;\n args?: string[];\n env?: Record<string, string>;\n cwd?: string;\n}\ninterface KiroHttpServer {\n url: string;\n headers?: Record<string, string>;\n}\n\n/**\n * Raw Kiro CLI hook stdin payload (snake_case wire fields).\n *\n * Fields are the ones Kiro ACTUALLY serializes onto a hook's stdin per\n * kiro.dev/docs/cli/hooks. NOTE the stop hook: its stdin is exactly\n * `{ hook_event_name, cwd, session_id, assistant_response }` — there is NO\n * `stop_hook_active` field (Kiro does not model a re-entrant stop-hook flag),\n * so we read `assistant_response` (the agent's last response text) rather than a\n * never-emitted boolean. Ref: kiro.dev/docs/cli/hooks (Stop Hook → Hook Event).\n */\ninterface KiroWireInput {\n connector?: unknown;\n hook_event_name?: string;\n cwd?: string;\n session_id?: string;\n tool_name?: string;\n tool_input?: Record<string, unknown>;\n tool_response?: unknown;\n source?: string;\n prompt?: string;\n /** Stop hook only: the text of the assistant's last response. */\n assistant_response?: string;\n}\n\nexport class KiroAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"Kiro\";\n readonly paradigm: HookParadigm = \"json-stdio\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: AGENTS.md-first managed block (project <projectDir>/AGENTS.md\n // via the base default — always included, no inclusion modes; user scope →\n // ~/.kiro/steering/agent-connector.md below).\n supportsMemory: true,\n preToolUse: true,\n postToolUse: true,\n preCompact: false,\n sessionStart: true,\n sessionEnd: false,\n // Kiro fires userPromptSubmit and stop, but it has no PreCompact /\n // SessionEnd / Notification equivalent.\n userPromptSubmit: true,\n stop: true,\n notification: false,\n // Newer events: Kiro's native set (agentSpawn / userPromptSubmit /\n // preToolUse / postToolUse / stop) has no permission-dialog, tool-failure,\n // or subagent lifecycle events, so permissionRequest / postToolUseFailure /\n // subagentStart / subagentStop stay unset — install reports the standard\n // skip-warn for them.\n // Kiro's hook protocol is exit-code only — a hook can allow (0), block (2),\n // or inject agentSpawn context, but it CANNOT rewrite tool args or output.\n canModifyArgs: false,\n canModifyOutput: false,\n // agentSpawn (and userPromptSubmit) add the hook's plain STDOUT to context.\n canInjectSessionContext: true,\n transports: [\"stdio\", \"http\"],\n // Skills: Kiro reads SKILL.md from .kiro/skills/<name>/SKILL.md (project)\n // and ~/.kiro/skills/<name>/SKILL.md (user).\n supportsSkills: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userDir = join(homedir(), \".kiro\");\n const userMcp = this.userMcpPath();\n const projectDirKiro = join(projectDir, \".kiro\");\n const projectMcp = this.projectMcpPath(projectDir);\n\n const userInstalled = existsSync(userDir) || existsSync(userMcp);\n const projInstalled = existsSync(projectDirKiro) || existsSync(projectMcp);\n const installed = userInstalled || projInstalled;\n // Report the scope/path that actually matched, so a project-only install\n // isn't misreported as a (non-existent) user install.\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const configPath = scope === \"project\" ? projectMcp : userMcp;\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath,\n scope,\n reason: installed\n ? scope === \"project\"\n ? `found project Kiro config at ${projectMcp}`\n : `found Kiro config under ${userDir}`\n : `no Kiro config at ${userDir}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Memory surface: global steering dir at user scope ───────────────────\n // Project scope stays on the AGENTS.md base default (workspace-root\n // AGENTS.md is always included, with no inclusion modes). User scope targets\n // a dedicated agent-connector.md in Kiro's documented ~/.kiro/steering/ dir\n // (default-always inclusion; AC-created → cleanly deletable on uninstall).\n protected override memoryTargets(ctx: InstallContext): MemoryTarget[] {\n if (this.memoryOverride(ctx)?.path || ctx.scope !== \"user\") {\n return super.memoryTargets(ctx);\n }\n return [\n {\n path: join(homedir(), \".kiro\", \"steering\", \"agent-connector.md\"),\n reason: \"kiro global steering dir (~/.kiro/steering; agent-connector-owned file)\",\n },\n ];\n }\n\n // ── Native paths ─────────────────────────────────────────────────────────\n\n getConfigDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".kiro\")\n : join(homedir(), \".kiro\");\n }\n\n /** MCP servers live in mcp.json under the scope's `.kiro/settings/`. */\n getServerConfigPath(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? this.projectMcpPath(ctx.projectDir)\n : this.userMcpPath();\n }\n\n /**\n * Hooks live in an AGENT file, NOT a settings file. Kiro auto-loads the\n * built-in default agent (`kiro_default`) for a new chat session, so we always\n * register hooks on the user-scope default agent — that is the agent Kiro\n * actually loads regardless of install scope.\n */\n getHookConfigPath(_ctx: InstallContext): string {\n return join(homedir(), \".kiro\", \"agents\", DEFAULT_AGENT_FILE);\n }\n\n private userMcpPath(): string {\n return join(homedir(), \".kiro\", \"settings\", \"mcp.json\");\n }\n\n private projectMcpPath(projectDir: string): string {\n return join(projectDir, \".kiro\", \"settings\", \"mcp.json\");\n }\n\n // ── MCP server install / uninstall ───────────────────────────────────────\n\n installServer(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n const override = connector.platforms[HOST]?.server;\n if (!connector.server || override === false) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: connector.server\n ? \"server registration disabled for kiro\"\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 Kiro's native mcpServers entry. */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): KiroStdioServer | KiroHttpServer {\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 // Kiro documents no native interpolation token, so resolve every\n // ${env:VAR} to a literal at install time.\n const entry: KiroStdioServer = { command: resolveEnvRefsDeep(command) };\n if (args.length > 0) entry.args = resolveEnvRefsDeep(args);\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n if (server.cwd) entry.cwd = resolveEnvRefsDeep(server.cwd);\n return entry;\n }\n\n // http (and any other remote transport) — Kiro registers a URL.\n const entry: KiroHttpServer = { url: resolveEnvRefsDeep(server.url ?? \"\") };\n const headers = this.renderEnv(server.headers);\n if (headers) entry.headers = headers;\n return entry;\n }\n\n /**\n * Render env/header values. Kiro 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 // ── Skills surface ───────────────────────────────────────────────────────\n // Kiro reads SKILL.md from:\n // project scope → <projectDir>/.kiro/skills/<name>/SKILL.md\n // user scope → ~/.kiro/skills/<name>/SKILL.md\n\n private skillsDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".kiro\", \"skills\")\n : join(homedir(), \".kiro\", \"skills\");\n }\n\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.skillsDir(ctx), 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 kiro\" }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n changes.push(\n this.writeContentFile(join(dir, \"SKILL.md\"), this.renderSkill(skill), ctx.dryRun),\n );\n 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 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;\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n private renderSkill(skill: SkillDef): string {\n return renderSkillMd(skill);\n }\n\n // ── Hook install / uninstall (merge into the agent file) ─────────────────\n\n installHooks(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.hooks === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"hooks disabled for kiro\" }];\n }\n if (connector.hookEvents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no hooks\" }];\n }\n\n const agentPath = this.getHookConfigPath(ctx);\n // Merge into the existing agent JSON; create a minimal agent object if absent.\n const agent = this.readJson<KiroAgentFile>(agentPath) ?? {};\n const __skip = this.malformedHookRootSkip(agentPath, (agent as Record<string, unknown>).hooks);\n if (__skip) return [__skip];\n const hooks = (agent.hooks ??= {});\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n for (const event of connector.hookEvents) {\n const kiroEvent = EVENT_MAP[event];\n if (!kiroEvent) {\n // No Kiro equivalent for this canonical event — report and continue.\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: agentPath,\n detail: `${event} has no Kiro hook equivalent — skipped`,\n });\n continue;\n }\n\n const command = buildHomeBinHookCommand(ctx.homeBinPath, HOST, event, connector.id);\n const matcher = connector.hooks[event]?.matcher ?? \"\";\n const entry: KiroHookEntry = {\n matcher,\n hooks: [{ type: \"command\", command }],\n };\n\n const bucket = (hooks[kiroEvent] ??= []);\n const existingIdx = bucket.findIndex((e) => this.entryHasOurCommand(e, ctx));\n\n if (existingIdx >= 0) {\n if (JSON.stringify(bucket[existingIdx]) === JSON.stringify(entry)) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: agentPath,\n detail: `hooks.${kiroEvent} already registered`,\n });\n continue;\n }\n bucket[existingIdx] = entry;\n changes.push({\n platform: this.id,\n action: \"update\",\n path: agentPath,\n detail: `hooks.${kiroEvent}`,\n });\n } else {\n bucket.push(entry);\n changes.push({\n platform: this.id,\n action: \"create\",\n path: agentPath,\n detail: `hooks.${kiroEvent}`,\n });\n }\n mutated = true;\n }\n\n if (mutated) this.writeJson(agentPath, agent, ctx.dryRun);\n return changes;\n }\n\n uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n const agentPath = this.getHookConfigPath(ctx);\n const agent = this.readJson<KiroAgentFile>(agentPath);\n const hooks = agent?.hooks;\n if (!agent || !hooks) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: agentPath,\n detail: \"no hooks section present\",\n },\n ];\n }\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n for (const kiroEvent of Object.keys(hooks)) {\n const bucket = hooks[kiroEvent];\n if (!Array.isArray(bucket)) continue;\n\n // Strip our hook command from each entry; drop entries left empty so we\n // never remove another connector's (or the user's own) hook commands.\n const next: KiroHookEntry[] = [];\n let removed = 0;\n for (const e of bucket) {\n const innerBefore = e.hooks?.length ?? 0;\n const inner = (e.hooks ?? []).filter((h) => !this.isOurCommand(h.command, ctx));\n removed += innerBefore - inner.length;\n if (inner.length > 0) next.push({ matcher: e.matcher ?? \"\", hooks: inner });\n }\n\n if (removed > 0) {\n if (next.length > 0) hooks[kiroEvent] = next;\n else delete hooks[kiroEvent];\n changes.push({\n platform: this.id,\n action: \"remove\",\n path: agentPath,\n detail: `hooks.${kiroEvent} (${removed})`,\n });\n mutated = true;\n }\n }\n\n if (mutated) this.writeJson(agentPath, agent, ctx.dryRun);\n if (changes.length === 0) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: agentPath,\n detail: \"no matching hook entries\",\n });\n }\n return changes;\n }\n\n private entryHasOurCommand(entry: KiroHookEntry, ctx: InstallContext): boolean {\n return (entry.hooks ?? []).some((h) => this.isOurCommand(h.command, ctx));\n }\n\n /** True when a hook command references our home binary AND this connector id\n * (anchored so a shared-prefix id can't collide — see isHomeBinHookCommand). */\n private isOurCommand(command: string | undefined, ctx: InstallContext): boolean {\n return isHomeBinHookCommand(command, ctx.homeBinPath, ctx.connector.id);\n }\n\n // ── Diagnostics ──────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const mcpPath = this.getServerConfigPath(ctx);\n const agentPath = this.getHookConfigPath(ctx);\n const connectorId = ctx.connector.id;\n const homeBin = ctx.homeBinPath;\n const hookEvents = ctx.connector.hookEvents;\n return [\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 (same rule as the hook\n // check below): a server-less connector never writes an mcpServers\n // 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<KiroMcpFile>(mcpPath);\n const bucket = cfg?.mcpServers;\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 : { status: \"FAIL\", detail: `no ${MCP_ROOT_KEY}.${connectorId} in ${mcpPath}` };\n },\n },\n {\n name: `${this.name}: hook command registered`,\n check: () => {\n if (hookEvents.length === 0) {\n return { status: \"OK\", detail: \"no hooks declared\" };\n }\n const agent = this.readJson<KiroAgentFile>(agentPath);\n if (!agent) return { status: \"FAIL\", detail: `cannot read ${agentPath}` };\n const hooks = agent.hooks ?? {};\n const registered = Object.values(hooks).some((entries) =>\n (entries ?? []).some((e) =>\n (e.hooks ?? []).some((h) =>\n isHomeBinHookCommand(h.command, homeBin, connectorId),\n ),\n ),\n );\n return registered\n ? { status: \"OK\", detail: \"hook command present\" }\n : { status: \"FAIL\", detail: `no hook for ${connectorId} in ${agentPath}` };\n },\n },\n ];\n }\n\n // ── Runtime: parse Kiro stdin JSON → normalized event ────────────────────\n\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as KiroWireInput;\n const connectorId = typeof input.connector === \"string\" ? input.connector : \"\";\n const sessionId = typeof input.session_id === \"string\" ? input.session_id : \"\";\n const projectDir = typeof input.cwd === \"string\" ? input.cwd : undefined;\n\n const base = {\n hostPlatform: HOST,\n connectorId,\n sessionId,\n raw,\n ...(projectDir !== undefined ? { projectDir } : {}),\n } as const;\n\n switch (event) {\n case \"PreToolUse\": {\n const ev: PreToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n };\n return ev;\n }\n case \"PostToolUse\": {\n const ev: PostToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n ...(toolResponseToString(input.tool_response) !== undefined\n ? { toolOutput: toolResponseToString(input.tool_response) }\n : {}),\n };\n return ev;\n }\n case \"SessionStart\": {\n const ev: SessionStartEvent = {\n ...base,\n source: normalizeSessionSource(input.source),\n };\n return ev;\n }\n case \"UserPromptSubmit\": {\n const ev: UserPromptSubmitEvent = {\n ...base,\n prompt: typeof input.prompt === \"string\" ? input.prompt : \"\",\n };\n return ev;\n }\n case \"Stop\": {\n // Kiro's stop stdin is EXACTLY { hook_event_name, cwd, session_id,\n // assistant_response } — there is no `stop_hook_active` flag (reading it\n // always yielded undefined), so we read the real `assistant_response`\n // (the agent's last response text) instead and surface it as\n // lastAssistantMessage. Ref: kiro.dev/docs/cli/hooks (Stop Hook Event).\n const ev: StopEvent & { lastAssistantMessage?: string } = {\n ...base,\n ...(typeof input.assistant_response === \"string\"\n ? { lastAssistantMessage: input.assistant_response }\n : {}),\n };\n return ev;\n }\n default: {\n // Kiro never delivers PreCompact / SessionEnd / Notification nor the\n // newer PermissionRequest / PostToolUseFailure / SubagentStart /\n // SubagentStop (no native equivalents). If the runtime dispatches one\n // anyway, surface it loudly rather than silently mis-parse.\n throw new Error(`unsupported kiro hook event: ${String(event)}`);\n }\n }\n }\n\n // ── Runtime: normalized response → Kiro native (exit-code) hook reply ─────\n\n formatReply(event: HookEventName, response: HookResponse): HookReply {\n const decision = response.decision ?? \"allow\";\n\n // deny → block the action: exit 2 with the reason on stderr.\n if (decision === \"deny\") {\n return { exitCode: 2, stderr: response.reason ?? \"Blocked by hook\" };\n }\n\n // ask → Kiro has no native \"ask\"; degrade to deny (exit 2) to stay fail-safe.\n if (decision === \"ask\") {\n return {\n exitCode: 2,\n stderr: response.reason ?? \"Action requires user confirmation (security policy)\",\n };\n }\n\n // Stop → exit-code only (deny already handled above as exit 2). There is no\n // context/additionalContext channel on a Stop hook, so anything non-deny\n // passes through with exit 0 (do not fall into the context branch).\n if (event === \"Stop\") {\n return { exitCode: 0 };\n }\n\n // context → inject soft guidance. Kiro adds a hook's PLAIN STDOUT to the\n // agent's context (no JSON envelope), but ONLY for the agentSpawn and\n // userPromptSubmit events; preToolUse / postToolUse have no context channel\n // (their STDOUT is \"captured but not shown\"). So emit the raw text on stdout\n // only when the FIRING event maps to a context-supporting Kiro event;\n // otherwise the context decision degrades to a plain exit-0 pass-through\n // rather than a mislabeled/ineffective payload. exit 0 = allow.\n // Ref: https://kiro.dev/docs/cli/hooks\n const kiroEvent = EVENT_MAP[event];\n if (\n decision === \"context\" &&\n response.additionalContext &&\n kiroEvent !== undefined &&\n CONTEXT_EVENTS.has(kiroEvent)\n ) {\n return { exitCode: 0, stdout: response.additionalContext };\n }\n\n // modify is unsupported on Kiro (exit-code protocol — cannot rewrite\n // args/output); allow / void → pass through with exit 0.\n return { exitCode: 0 };\n }\n}\n\n/** Coerce a Kiro PostToolUse `tool_response` into a string for the normalized event. */\nfunction toolResponseToString(value: unknown): string | undefined {\n if (value == null) return undefined;\n if (typeof value === \"string\") return value;\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\nexport const adapter = new KiroAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgDA,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,YAAY;AA+BrB,IAAM,OAAmB;AACzB,IAAM,eAAe;AAGrB,IAAM,qBAAqB;AAM3B,IAAM,aAAa;AAAA,EACjB,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,YAAY;AA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B;AAAA,IACrE;AAGA,QAAI,aAAa,OAAO;AACtB,aAAO;AAAA,QACL,UAAU;AAAA,QACV,QAAQ,SAAS,UAAU;AAAA,MAC7B;AAAA,IACF;AAKA,QAAI,UAAU,QAAQ;AACpB,aAAO,EAAE,UAAU,EAAE;AAAA,IACvB;AAUA,UAAM,YAAY,UAAU,KAAK;AACjC,QACE,aAAa,aACb,SAAS,qBACT,cAAc,UACd,eAAe,IAAI,SAAS,GAC5B;AACA,aAAO,EAAE,UAAU,GAAG,QAAQ,SAAS,kBAAkB;AAAA,IAC3D;AAIA,WAAO,EAAE,UAAU,EAAE;AAAA,EACvB;AACF;AAGA,SAAS,qBAAqB,OAAoC;AAChE,MAAI,SAAS,KAAM,QAAO;AAC1B,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,MAAI;AACF,WAAO,KAAK,UAAU,KAAK;AAAA,EAC7B,QAAQ;AACN,WAAO,OAAO,KAAK;AAAA,EACrB;AACF;AAEO,IAAM,UAAU,IAAI,YAAY;AACvC,IAAO,eAAQ;","names":["entry"]}
|
|
@@ -10,14 +10,14 @@ import {
|
|
|
10
10
|
hostNativeTurns,
|
|
11
11
|
isScopeFilter,
|
|
12
12
|
mcpLeaderboard
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-TZ5KGCE2.js";
|
|
14
14
|
import "./chunk-XD7MY6HB.js";
|
|
15
15
|
import {
|
|
16
16
|
fail,
|
|
17
17
|
print
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-NXR4HM5N.js";
|
|
19
|
+
import "./chunk-D6ZJS4ND.js";
|
|
20
|
+
import "./chunk-2HCJV6UO.js";
|
|
21
21
|
|
|
22
22
|
// src/cli/commands/leaderboard.ts
|
|
23
23
|
import { parseArgs } from "util";
|
|
@@ -134,4 +134,4 @@ export {
|
|
|
134
134
|
parseSince,
|
|
135
135
|
run
|
|
136
136
|
};
|
|
137
|
-
//# sourceMappingURL=leaderboard-
|
|
137
|
+
//# sourceMappingURL=leaderboard-6I2E5XZK.js.map
|
|
@@ -9,24 +9,17 @@ import {
|
|
|
9
9
|
BaseAdapter,
|
|
10
10
|
renderOpenCodeSubagentMd,
|
|
11
11
|
renderSkillMd
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-RHML2NOB.js";
|
|
13
13
|
import {
|
|
14
14
|
buildWrappedStdio
|
|
15
15
|
} from "./chunk-TO57WYBB.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-ALVXORZM.js";
|
|
17
|
+
import "./chunk-2HCJV6UO.js";
|
|
18
18
|
|
|
19
19
|
// src/adapters/mimo-code/index.ts
|
|
20
|
-
import {
|
|
21
|
-
chmodSync,
|
|
22
|
-
existsSync,
|
|
23
|
-
mkdirSync,
|
|
24
|
-
readFileSync,
|
|
25
|
-
rmSync,
|
|
26
|
-
writeFileSync
|
|
27
|
-
} from "fs";
|
|
20
|
+
import { existsSync } from "fs";
|
|
28
21
|
import { homedir } from "os";
|
|
29
|
-
import {
|
|
22
|
+
import { join } from "path";
|
|
30
23
|
var HOST = "mimo-code";
|
|
31
24
|
var MCP_ROOT_KEY = "mcp";
|
|
32
25
|
var CONFIG_DIR_NAME = "mimocode";
|
|
@@ -259,22 +252,15 @@ var MiMoCodeAdapter = class extends BaseAdapter {
|
|
|
259
252
|
const files = this.synthesizePlugin(ctx);
|
|
260
253
|
const changes = [];
|
|
261
254
|
for (const file of files) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
changes.push({
|
|
273
|
-
platform: this.id,
|
|
274
|
-
action,
|
|
275
|
-
path: file.path,
|
|
276
|
-
detail: `mimo-code plugin module (${this.hookDetail(ctx)})`
|
|
277
|
-
});
|
|
255
|
+
changes.push(
|
|
256
|
+
this.writeManagedFile(
|
|
257
|
+
file.path,
|
|
258
|
+
file.contents,
|
|
259
|
+
ctx.dryRun,
|
|
260
|
+
`mimo-code plugin module (${this.hookDetail(ctx)})`,
|
|
261
|
+
file.executable
|
|
262
|
+
)
|
|
263
|
+
);
|
|
278
264
|
}
|
|
279
265
|
return changes;
|
|
280
266
|
}
|
|
@@ -293,24 +279,13 @@ var MiMoCodeAdapter = class extends BaseAdapter {
|
|
|
293
279
|
}
|
|
294
280
|
uninstallHooks(ctx) {
|
|
295
281
|
const pluginPath = this.getHookConfigPath(ctx);
|
|
296
|
-
if (!existsSync(pluginPath)) {
|
|
297
|
-
return [
|
|
298
|
-
{
|
|
299
|
-
platform: this.id,
|
|
300
|
-
action: "skip",
|
|
301
|
-
path: pluginPath,
|
|
302
|
-
detail: "no mimo-code plugin module present"
|
|
303
|
-
}
|
|
304
|
-
];
|
|
305
|
-
}
|
|
306
|
-
if (!ctx.dryRun) rmSync(pluginPath, { force: true });
|
|
307
282
|
return [
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
283
|
+
this.removeManagedFile(
|
|
284
|
+
pluginPath,
|
|
285
|
+
ctx.dryRun,
|
|
286
|
+
"mimo-code plugin module",
|
|
287
|
+
"no mimo-code plugin module present"
|
|
288
|
+
)
|
|
314
289
|
];
|
|
315
290
|
}
|
|
316
291
|
// ── Content surfaces: commands / skills / subagents ──────────────────────
|
|
@@ -733,17 +708,7 @@ ${handlers.join("\n")}
|
|
|
733
708
|
return checks;
|
|
734
709
|
}
|
|
735
710
|
/** Read a file, returning undefined on any error (idempotency compare). */
|
|
736
|
-
safeRead(path) {
|
|
737
|
-
try {
|
|
738
|
-
return readFileSync(path, "utf8");
|
|
739
|
-
} catch {
|
|
740
|
-
return void 0;
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
711
|
};
|
|
744
|
-
function ensureDir(dir) {
|
|
745
|
-
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
746
|
-
}
|
|
747
712
|
var adapter = new MiMoCodeAdapter();
|
|
748
713
|
var mimo_code_default = adapter;
|
|
749
714
|
export {
|
|
@@ -751,4 +716,4 @@ export {
|
|
|
751
716
|
adapter,
|
|
752
717
|
mimo_code_default as default
|
|
753
718
|
};
|
|
754
|
-
//# sourceMappingURL=mimo-code-
|
|
719
|
+
//# sourceMappingURL=mimo-code-ZPJJ6IIW.js.map
|