@ken-jo/agent-connector 0.4.43 → 0.4.61
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-ZUHMOGLV.js → action-AIB2W4DU.js} +12 -12
- package/dist/{amazon-q-UFLBUSHG.js → amazon-q-PH7OFPJD.js} +7 -11
- package/dist/amazon-q-PH7OFPJD.js.map +1 -0
- package/dist/{amp-5DJK7VAL.js → amp-ZYRC2VCH.js} +38 -63
- package/dist/amp-ZYRC2VCH.js.map +1 -0
- package/dist/{antigravity-NWP2TUG6.js → antigravity-PM5NMS2J.js} +5 -5
- package/dist/{antigravity-cli-KPNLE7X4.js → antigravity-cli-LN25XGWX.js} +5 -5
- package/dist/{chunk-LETB5HCK.js → chunk-3QCDVSMX.js} +2 -2
- package/dist/{chunk-ERV4TKRV.js → chunk-4K5HEGVE.js} +2 -2
- package/dist/{chunk-H3BATOBP.js → chunk-AAOYOAQT.js} +2 -2
- package/dist/{chunk-2RPHDVHW.js → chunk-AEQRMVRB.js} +2 -2
- package/dist/{chunk-L7ESV37V.js → chunk-BZOOVTFG.js} +4 -2
- package/dist/chunk-BZOOVTFG.js.map +1 -0
- package/dist/{chunk-3Q6YEDCG.js → chunk-C3TFA4CJ.js} +17 -45
- package/dist/chunk-C3TFA4CJ.js.map +1 -0
- package/dist/{chunk-QY42WGBX.js → chunk-D65GIBCG.js} +34 -3
- package/dist/chunk-D65GIBCG.js.map +1 -0
- package/dist/{chunk-RAJBLK2V.js → chunk-FVARNRCE.js} +26 -10
- package/dist/chunk-FVARNRCE.js.map +1 -0
- package/dist/{chunk-A767JFHW.js → chunk-GI4FDVWI.js} +65 -35
- package/dist/chunk-GI4FDVWI.js.map +1 -0
- package/dist/{chunk-5HSLICR3.js → chunk-IDKI42JW.js} +36 -36
- package/dist/{chunk-54B5HAVT.js → chunk-JZIM33C2.js} +10 -7
- package/dist/chunk-JZIM33C2.js.map +1 -0
- package/dist/{chunk-3ZZK4KXG.js → chunk-KAEYJGK7.js} +18 -18
- package/dist/{chunk-ZY25RG4Y.js → chunk-LBOGRZGY.js} +4 -2
- package/dist/chunk-LBOGRZGY.js.map +1 -0
- package/dist/{chunk-VDSXVNEH.js → chunk-NFMHYIN2.js} +5 -5
- package/dist/{chunk-XW46WVR2.js → chunk-O3HIYTBK.js} +10 -5
- package/dist/chunk-O3HIYTBK.js.map +1 -0
- package/dist/{chunk-AQ53TOH4.js → chunk-O4BKQSPP.js} +7 -4
- package/dist/chunk-O4BKQSPP.js.map +1 -0
- package/dist/{chunk-YG3KFOOQ.js → chunk-QP35SRUZ.js} +2 -2
- package/dist/{chunk-4CBHYWUG.js → chunk-RFYQXT7C.js} +7 -7
- package/dist/{chunk-5TMIJ7AY.js → chunk-RGQTN7K3.js} +5 -5
- package/dist/{chunk-M3H7PQWT.js → chunk-WOUGWPZQ.js} +4 -2
- package/dist/chunk-WOUGWPZQ.js.map +1 -0
- package/dist/{chunk-F4DSMVZ7.js → chunk-ZQCT63JU.js} +2 -2
- package/dist/{claude-code-YNNKQCCR.js → claude-code-GCXXEWUN.js} +15 -8
- package/dist/claude-code-GCXXEWUN.js.map +1 -0
- package/dist/cli/sdk.js +7 -7
- package/dist/cli.js +1 -1
- package/dist/{cline-AGFJF4AC.js → cline-KHZLG7CU.js} +4 -4
- package/dist/{codebuff-YUQ4PN7G.js → codebuff-EQGWZEP4.js} +4 -4
- package/dist/{codex-FLU37DV3.js → codex-7X7RC6JJ.js} +32 -6
- package/dist/codex-7X7RC6JJ.js.map +1 -0
- package/dist/{continue-ZMI4YN75.js → continue-V4MB3WQ3.js} +9 -5
- package/dist/continue-V4MB3WQ3.js.map +1 -0
- package/dist/{copilot-cli-XPRJ5MQB.js → copilot-cli-7EPIJHFM.js} +12 -32
- package/dist/copilot-cli-7EPIJHFM.js.map +1 -0
- package/dist/{crush-3OB5ZTCC.js → crush-3AAA75C5.js} +4 -4
- package/dist/{cursor-F4HYO2FP.js → cursor-DTYZROKS.js} +5 -5
- package/dist/{detect-FXGBSNQU.js → detect-LWZEM7SN.js} +4 -4
- package/dist/{doctor-2O65SAPG.js → doctor-54P4JFA6.js} +14 -14
- package/dist/{droid-NZCKYKOV.js → droid-QMNO5WZ2.js} +6 -12
- package/dist/droid-QMNO5WZ2.js.map +1 -0
- package/dist/{gemini-cli-3ZGCXUDD.js → gemini-cli-7JU7ZWQL.js} +19 -6
- package/dist/gemini-cli-7JU7ZWQL.js.map +1 -0
- package/dist/{goose-MGGNVXJP.js → goose-36TJNDKD.js} +16 -22
- package/dist/goose-36TJNDKD.js.map +1 -0
- package/dist/{hermes-L3CBJ37L.js → hermes-S4JZ6H42.js} +44 -22
- package/dist/hermes-S4JZ6H42.js.map +1 -0
- package/dist/{hook-D3PY6TDK.js → hook-UT3Q43AB.js} +12 -12
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/{install-SVBIK4VJ.js → install-F4OIDYAK.js} +14 -14
- package/dist/{introspect-B164-hj3.d.ts → introspect-BFcXpfUp.d.ts} +1 -1
- package/dist/{jetbrains-copilot-M2LHJBAW.js → jetbrains-copilot-6QLKUCAY.js} +17 -12
- package/dist/jetbrains-copilot-6QLKUCAY.js.map +1 -0
- package/dist/{kilo-RMRP2EL7.js → kilo-WLZOYKZK.js} +18 -55
- package/dist/kilo-WLZOYKZK.js.map +1 -0
- package/dist/{kilo-cli-6ITBNHTH.js → kilo-cli-FBX4OFIZ.js} +18 -55
- package/dist/kilo-cli-FBX4OFIZ.js.map +1 -0
- package/dist/{kimi-I35VOOY4.js → kimi-7YXRAQ6Z.js} +28 -14
- package/dist/kimi-7YXRAQ6Z.js.map +1 -0
- package/dist/{kiro-2K5UJVGC.js → kiro-CSBQA6EX.js} +5 -5
- package/dist/kiro-CSBQA6EX.js.map +1 -0
- package/dist/{leaderboard-ZMZST52G.js → leaderboard-ZIAXBUWD.js} +5 -5
- package/dist/{mimo-code-K7AMX2QW.js → mimo-code-GYJNEULG.js} +21 -56
- package/dist/mimo-code-GYJNEULG.js.map +1 -0
- package/dist/{mux-GT7FWVLH.js → mux-DAIC3VY7.js} +4 -4
- package/dist/{nemoclaw-GQMS6CUM.js → nemoclaw-GS3XA7V2.js} +5 -5
- package/dist/{omp-2RPYIZUF.js → omp-O6KNB4MM.js} +17 -46
- package/dist/omp-O6KNB4MM.js.map +1 -0
- package/dist/{openclaw-P5GMEEGC.js → openclaw-344VBMLY.js} +5 -5
- package/dist/{opencode-5D2SK3EX.js → opencode-JPHRZPDQ.js} +21 -56
- package/dist/opencode-JPHRZPDQ.js.map +1 -0
- package/dist/{package-EDYQF6C6.js → package-5FRMSWRT.js} +11 -11
- package/dist/{pi-ZMM4KJTO.js → pi-EFBTBI2B.js} +4 -4
- package/dist/{qwen-code-4ZLVGN2C.js → qwen-code-CLSMTMHX.js} +12 -5
- package/dist/qwen-code-CLSMTMHX.js.map +1 -0
- package/dist/{roo-code-67QGLQRM.js → roo-code-YIX3RPR2.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-427CCEYA.js → serve-NQBXN4FG.js} +12 -12
- package/dist/{status-6IHRW6PI.js → status-5ZM6LXHV.js} +10 -10
- package/dist/{statusline-2CKH5RHO.js → statusline-O76BCBUK.js} +11 -11
- package/dist/{telemetry-WNVKL7HW.js → telemetry-NO7UUUSJ.js} +10 -10
- package/dist/{trae-TMJPHWZ5.js → trae-JESXQKAF.js} +4 -4
- package/dist/{types-COSBYpKs.d.ts → types-ChUrvw0j.d.ts} +8 -8
- package/dist/{uninstall-QFCDXGKR.js → uninstall-QCROBR6A.js} +14 -14
- package/dist/{upgrade-PP46DURC.js → upgrade-KJ4QRZDZ.js} +14 -14
- package/dist/{usage-VDORZJPT.js → usage-UY6DCND6.js} +2 -2
- package/dist/{usage-event-4533OURF.js → usage-event-T4HWQDZF.js} +11 -11
- package/dist/{vscode-copilot-H7JKUKLZ.js → vscode-copilot-56USZ5X4.js} +26 -19
- package/dist/vscode-copilot-56USZ5X4.js.map +1 -0
- package/dist/{warp-SVDVKQQI.js → warp-Y6JNLLGR.js} +4 -4
- package/dist/{windsurf-H36YKOMR.js → windsurf-X7QCJ3XR.js} +4 -4
- package/dist/{zed-LHWJALLZ.js → zed-L3ML5MHF.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-54B5HAVT.js.map +0 -1
- package/dist/chunk-A767JFHW.js.map +0 -1
- package/dist/chunk-AQ53TOH4.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-RAJBLK2V.js.map +0 -1
- package/dist/chunk-XW46WVR2.js.map +0 -1
- package/dist/chunk-ZY25RG4Y.js.map +0 -1
- package/dist/claude-code-YNNKQCCR.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-I35VOOY4.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/vscode-copilot-H7JKUKLZ.js.map +0 -1
- /package/dist/{action-ZUHMOGLV.js.map → action-AIB2W4DU.js.map} +0 -0
- /package/dist/{antigravity-NWP2TUG6.js.map → antigravity-PM5NMS2J.js.map} +0 -0
- /package/dist/{antigravity-cli-KPNLE7X4.js.map → antigravity-cli-LN25XGWX.js.map} +0 -0
- /package/dist/{chunk-LETB5HCK.js.map → chunk-3QCDVSMX.js.map} +0 -0
- /package/dist/{chunk-ERV4TKRV.js.map → chunk-4K5HEGVE.js.map} +0 -0
- /package/dist/{chunk-H3BATOBP.js.map → chunk-AAOYOAQT.js.map} +0 -0
- /package/dist/{chunk-2RPHDVHW.js.map → chunk-AEQRMVRB.js.map} +0 -0
- /package/dist/{chunk-5HSLICR3.js.map → chunk-IDKI42JW.js.map} +0 -0
- /package/dist/{chunk-3ZZK4KXG.js.map → chunk-KAEYJGK7.js.map} +0 -0
- /package/dist/{chunk-VDSXVNEH.js.map → chunk-NFMHYIN2.js.map} +0 -0
- /package/dist/{chunk-YG3KFOOQ.js.map → chunk-QP35SRUZ.js.map} +0 -0
- /package/dist/{chunk-4CBHYWUG.js.map → chunk-RFYQXT7C.js.map} +0 -0
- /package/dist/{chunk-5TMIJ7AY.js.map → chunk-RGQTN7K3.js.map} +0 -0
- /package/dist/{chunk-F4DSMVZ7.js.map → chunk-ZQCT63JU.js.map} +0 -0
- /package/dist/{cline-AGFJF4AC.js.map → cline-KHZLG7CU.js.map} +0 -0
- /package/dist/{codebuff-YUQ4PN7G.js.map → codebuff-EQGWZEP4.js.map} +0 -0
- /package/dist/{crush-3OB5ZTCC.js.map → crush-3AAA75C5.js.map} +0 -0
- /package/dist/{cursor-F4HYO2FP.js.map → cursor-DTYZROKS.js.map} +0 -0
- /package/dist/{detect-FXGBSNQU.js.map → detect-LWZEM7SN.js.map} +0 -0
- /package/dist/{doctor-2O65SAPG.js.map → doctor-54P4JFA6.js.map} +0 -0
- /package/dist/{hook-D3PY6TDK.js.map → hook-UT3Q43AB.js.map} +0 -0
- /package/dist/{install-SVBIK4VJ.js.map → install-F4OIDYAK.js.map} +0 -0
- /package/dist/{leaderboard-ZMZST52G.js.map → leaderboard-ZIAXBUWD.js.map} +0 -0
- /package/dist/{mux-GT7FWVLH.js.map → mux-DAIC3VY7.js.map} +0 -0
- /package/dist/{nemoclaw-GQMS6CUM.js.map → nemoclaw-GS3XA7V2.js.map} +0 -0
- /package/dist/{openclaw-P5GMEEGC.js.map → openclaw-344VBMLY.js.map} +0 -0
- /package/dist/{package-EDYQF6C6.js.map → package-5FRMSWRT.js.map} +0 -0
- /package/dist/{pi-ZMM4KJTO.js.map → pi-EFBTBI2B.js.map} +0 -0
- /package/dist/{roo-code-67QGLQRM.js.map → roo-code-YIX3RPR2.js.map} +0 -0
- /package/dist/{serve-427CCEYA.js.map → serve-NQBXN4FG.js.map} +0 -0
- /package/dist/{status-6IHRW6PI.js.map → status-5ZM6LXHV.js.map} +0 -0
- /package/dist/{statusline-2CKH5RHO.js.map → statusline-O76BCBUK.js.map} +0 -0
- /package/dist/{telemetry-WNVKL7HW.js.map → telemetry-NO7UUUSJ.js.map} +0 -0
- /package/dist/{trae-TMJPHWZ5.js.map → trae-JESXQKAF.js.map} +0 -0
- /package/dist/{uninstall-QFCDXGKR.js.map → uninstall-QCROBR6A.js.map} +0 -0
- /package/dist/{upgrade-PP46DURC.js.map → upgrade-KJ4QRZDZ.js.map} +0 -0
- /package/dist/{usage-VDORZJPT.js.map → usage-UY6DCND6.js.map} +0 -0
- /package/dist/{usage-event-4533OURF.js.map → usage-event-T4HWQDZF.js.map} +0 -0
- /package/dist/{warp-SVDVKQQI.js.map → warp-Y6JNLLGR.js.map} +0 -0
- /package/dist/{windsurf-H36YKOMR.js.map → windsurf-X7QCJ3XR.js.map} +0 -0
- /package/dist/{zed-LHWJALLZ.js.map → zed-L3ML5MHF.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/hermes/index.ts"],"sourcesContent":["/**\n * adapters/hermes — Hermes Agent platform adapter for agent-connector.\n *\n * Hermes is a json-stdio host whose ENTIRE configuration — both the MCP servers\n * and the lifecycle hooks — lives in a single user-scope YAML file:\n *\n * ~/.hermes/config.yaml\n *\n * Because the file is YAML, the BaseAdapter JSON helpers do not apply; this\n * adapter merges via core/yaml's readYaml/writeYaml, preserving any unrelated\n * config the user has authored.\n *\n * - MCP servers: top-level snake_case root key `mcp_servers`. The stdio entry\n * uses the portable field names { command, args, env } (unlike Goose's\n * cmd/envs). Hermes has no native env interpolation, so `${env:VAR}` refs are\n * resolved to literals at install time.\n *\n * - Hooks: a top-level `hooks` map keyed by Hermes' NATIVE snake_case event\n * names (pre_tool_call / post_tool_call / on_session_start / on_session_end /\n * subagent_stop — NOT the canonical PascalCase names; see EVENT_TO_HERMES).\n * Each value is a\n * list of shell-hook entries { matcher, command:\"<homeBin> hook …\", timeout }.\n * The command keeps the canonical event token so the runtime dispatcher\n * (parseEvent/formatReply) stays consistent. Hermes shell hooks pipe the\n * event JSON to the command on stdin and read the reply JSON from stdout —\n * the same wire protocol as Claude Code, so the runtime parse/format mirror\n * the Claude adapter (a Claude-like JSON shape; the exact Hermes field map is\n * documented inline where it could vary).\n *\n * Since hooks are external shell commands (not an in-process plugin), Hermes\n * cannot let a hook rewrite tool arguments — canModifyArgs is false. Hermes has\n * no SSE transport, so only stdio + http are advertised.\n */\n\nimport { existsSync, statSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\nimport { BaseAdapter } from \"../base.js\";\nimport type { Adapter, HookReply, InstallContext, MemoryTarget, NormalizedEvent } from \"../spi.js\";\nimport type {\n ChangeRecord,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n NotificationEvent,\n PlatformCapabilities,\n PlatformId,\n PostToolUseEvent,\n PostCompactEvent,\n PreCompactEvent,\n PreToolUseEvent,\n SessionEndEvent,\n SessionStartEvent,\n ServerDef,\n StopEvent,\n SubagentStopEvent,\n UserPromptSubmitEvent,\n} from \"../../core/types.js\";\nimport { removeFromObjectMap, upsertInObjectMap } from \"../../core/object-map.js\";\nimport { readYaml, writeYaml, yamlObjectMapCodec } from \"../../core/yaml.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport {\n buildHomeBinHookCommand,\n buildWrappedStdio,\n isHomeBinActionCommand,\n isHomeBinHookCommand,\n} from \"../../core/spawn.js\";\nimport { renderSkillMd } from \"../claude-code/render.js\";\n\nconst HOST: PlatformId = \"hermes\";\n/** Root key under which Hermes stores MCP servers in config.yaml (snake_case). */\nconst MCP_ROOT_KEY = \"mcp_servers\";\n/** Top-level key under which Hermes stores shell hooks in config.yaml. */\nconst HOOKS_KEY = \"hooks\";\n/**\n * Top-level map under which Hermes stores `/<id>` slash commands. A\n * `{ type: \"exec\", command }` entry runs the shell command directly, bypassing\n * the LLM — the action emitter's target.\n */\nconst QUICK_COMMANDS_KEY = \"quick_commands\";\n/** Default per-hook timeout (seconds) when the connector declares none. */\nconst DEFAULT_HOOK_TIMEOUT = 60;\n/**\n * Documented per-hook timeout bounds (seconds). Hermes' hooks.md states\n * `timeout: <seconds>` is \"default 60, capped at 300\" and that `timeout > 300`\n * is clamped with a warning by the host. There is no documented minimum; the\n * 1s floor is defensive so a sub-second connector timeoutMs never rounds to 0.\n */\nconst HOOK_TIMEOUT_MAX = 300;\nconst HOOK_TIMEOUT_MIN = 1;\n\n/** One Hermes quick-command entry (a `/<id>` slash command). */\ninterface HermesQuickCommand {\n type: \"exec\";\n command: string;\n}\n\n/**\n * Canonical → Hermes native hook event name. Hermes keys its `hooks:` block by\n * its OWN snake_case lifecycle names (pre_tool_call / post_tool_call /\n * on_session_start / on_session_end — see docs/research/platform-research.json),\n * NOT the canonical PascalCase names. A connector event is only wired when it\n * appears here AND is declared by the connector; everything else is reported as\n * a warn/skip at install time.\n */\nconst EVENT_TO_HERMES: Partial<Record<HookEventName, string>> = {\n PreToolUse: \"pre_tool_call\",\n PostToolUse: \"post_tool_call\",\n SessionStart: \"on_session_start\",\n SessionEnd: \"on_session_end\",\n // Hermes is a STOP-ONLY subagent host: subagent_stop fires when a\n // delegate_task child exits (child_status ∈ completed/failed/interrupted/\n // error); there is NO subagent_start analog. PermissionRequest is also\n // deliberately ABSENT: Hermes' pre_approval_request/post_approval_response\n // hooks OBSERVE the approval prompt but carry no decision control, so a\n // PermissionRequest handler could never be honored — install skip-warns it.\n SubagentStop: \"subagent_stop\",\n};\n\n/** Hermes stdio MCP entry — portable field names (command/args/env). */\ninterface HermesStdioServer {\n command: string;\n args?: string[];\n env?: Record<string, string>;\n}\n\n/**\n * Hermes remote HTTP MCP entry — `{ url, headers? }` under the SAME mcp_servers\n * key (no transport/type discriminator). Per the Hermes Agent docs\n * (website/docs/user-guide/features/mcp.md \"HTTP servers\"); OAuth servers add\n * `auth: oauth`, which AC's static-header model does not express.\n */\ninterface HermesHttpServer {\n url: string;\n headers?: Record<string, string>;\n}\n\n/** One Hermes shell-hook entry. */\ninterface HermesHookEntry {\n /** Tool-name matcher (empty = all). Tool events only; \"\" elsewhere. */\n matcher: string;\n /** The home-bin hook command Hermes invokes (event JSON on stdin). */\n command: string;\n /** Hook timeout in seconds. */\n timeout: number;\n}\n\n/**\n * Raw Hermes hook stdin payload — the ACTUAL wire shape emitted by Hermes'\n * `agent/shell_hooks.py::_serialize_payload` (NousResearch/hermes-agent), NOT a\n * Claude-like guess. The serializer keeps ONLY these top-level keys:\n *\n * { hook_event_name, tool_name, tool_input, session_id, cwd, extra }\n *\n * where `tool_name`/`tool_input` come from the invoke kwargs `tool_name`/`args`,\n * `session_id` from `session_id` ?? `parent_session_id`, and EVERY other kwarg\n * is nested under `extra` (see `_TOP_LEVEL_PAYLOAD_KEYS` = {tool_name, args,\n * session_id, parent_session_id}). So all per-event result/status/child fields\n * are read from `extra.*` — top-level reads for them are always undefined.\n */\ninterface HermesWireInput {\n session_id?: string;\n cwd?: string;\n hook_event_name?: string;\n tool_name?: string;\n /** Top-level: the serializer lifts the `args` kwarg here (PreToolUse). */\n tool_input?: Record<string, unknown>;\n /**\n * Every non-allowlisted invoke kwarg nests here. Per-event contents (verified\n * against the host source):\n * - post_tool_call: result, status (\"ok\"|\"error\"), error_type, error_message,\n * duration_ms, task_id, tool_call_id, turn_id, api_request_id, middleware_trace\n * - subagent_stop: child_session_id, child_role, child_summary, child_status\n * (\"completed\"|\"failed\"|\"interrupted\"|\"error\"), duration_ms, parent_turn_id\n * - on_session_start: model, platform\n * - on_session_end: completed (bool), interrupted (bool), task_id, turn_id,\n * model, platform\n */\n extra?: HermesExtra;\n /** Injected by the entrypoint so the runtime knows which connector to dispatch. */\n connector?: string;\n}\n\n/** The `extra` envelope — non-allowlisted invoke kwargs, by event (see above). */\ninterface HermesExtra {\n // post_tool_call\n result?: unknown;\n status?: string;\n error_type?: string;\n error_message?: string;\n // subagent_stop\n child_session_id?: string;\n child_role?: string;\n child_summary?: string;\n child_status?: string;\n // on_session_end\n completed?: boolean;\n interrupted?: boolean;\n // on_session_start / on_session_end\n model?: string;\n platform?: string;\n // ── Defensive only ──────────────────────────────────────────────────────\n // Hermes does NOT fire UserPromptSubmit / PreCompact / PostCompact / Stop /\n // Notification (the matching capabilities are false; install warn-skips them).\n // Were any ever mis-routed here, the serializer would still nest its kwargs\n // under `extra`, so these defensive parse arms read from extra — they never\n // resurface as invented top-level fields.\n prompt?: string;\n trigger?: string;\n stop_hook_active?: boolean;\n message?: string;\n}\n\nexport class HermesAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"Hermes Agent\";\n readonly paradigm: HookParadigm = \"json-stdio\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: AGENTS.md-first managed block. memoryTargets below probes\n // for .hermes.md / HERMES.md (first context category wins on hermes —\n // AGENTS.md is ignored when they exist); ~/.hermes holds identity/volatile\n // files (SOUL.md, MEMORY.md), not a rules surface → user-scope skip-warn.\n supportsMemory: true,\n preToolUse: true,\n postToolUse: true,\n preCompact: false,\n // Hermes exposes on_session_start / on_session_end lifecycle hooks.\n sessionStart: true,\n sessionEnd: true,\n userPromptSubmit: false,\n stop: false,\n notification: false,\n // Newer events: Hermes ships subagent_stop (stop-only — no subagent_start\n // analog). permissionRequest stays unset because pre_approval_request is\n // observe-only (no decision control); postToolUseFailure stays unset (a\n // tool failure arrives merged into post_tool_call's result, not as a\n // dedicated event). Install reports the standard skip-warn for those.\n subagentStop: true,\n // Shell hooks cannot rewrite tool args/output in-process.\n canModifyArgs: false,\n canModifyOutput: false,\n canInjectSessionContext: true,\n // Hermes has no SSE transport.\n transports: [\"stdio\", \"http\"],\n // Content surface: Hermes auto-discovers dir-per-skill SKILL.md from its\n // LOCAL skills root ~/.hermes/skills — the \"single source of truth,\n // read-write\" dir (hermes-agent.nousresearch.com/docs/user-guide/features/\n // skills, fetched 2026-06-16). The directory name becomes the skill's\n // install slug; frontmatter is { name, description } + optional\n // metadata.hermes.*. USER scope only — there is no documented hermes-owned\n // project skills dir (~/.agents/skills is the cross-tool external dir, not\n // ours), so a project-scope install skip-warns via the base default.\n supportsSkills: true,\n // Native passthrough hooks: Hermes documents many host-specific lifecycle\n // events with NO canonical analog — pre_llm_call / post_llm_call /\n // on_session_finalize / on_session_reset / pre_gateway_dispatch /\n // pre_approval_request / post_approval_response / transform_tool_result\n // (docs/research/platform-research.json). They are host-specific (below the\n // >=3-host core bar; docs/research/host-specific-hook-events-design.md). A\n // connector reaches them by declaring platforms[\"hermes\"].nativeHooks;\n // installHooks files those event-name keys verbatim into the YAML hooks map,\n // and the generic uninstall reverses them.\n supportsNativeHooks: true,\n // Actions surface: Hermes ships `quick_commands.<id>: { type: \"exec\",\n // command }` — a `/<id>` slash command that runs the shell command directly,\n // bypassing the LLM (hermes-agent.nousresearch.com/docs/user-guide/cli:\n // \"custom commands that run shell commands instantly without invoking the\n // LLM\"). We emit one per declared action bound to the home-bin action verb.\n supportsActions: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(_projectDir: string): DetectedPlatform {\n const configPath = this.userConfigPath();\n const configDir = dirname(configPath);\n const installed = existsSync(configDir) || existsSync(configPath);\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath,\n scope: \"user\",\n reason: installed\n ? `found Hermes config at ${configPath}`\n : `no Hermes config at ${configPath}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Memory surface: .hermes.md / HERMES.md shadow probe (project) ────────\n // Hermes assembles project context by FIRST CATEGORY WINS: .hermes.md or\n // HERMES.md (cwd walking up to the git root) → AGENTS.md (cwd only) →\n // CLAUDE.md (cwd only). When a hermes-native file exists our block must live\n // there or it is never loaded. Reason strings note the cwd-only AGENTS.md\n // read and hermes' ~20k-chars-per-file truncation.\n protected override memoryTargets(ctx: InstallContext): MemoryTarget[] {\n if (this.memoryOverride(ctx)?.path || ctx.scope !== \"project\") {\n return super.memoryTargets(ctx); // user scope: no rules surface → skip-warn\n }\n for (const name of [\".hermes.md\", \"HERMES.md\"]) {\n const candidate = join(ctx.projectDir, name);\n if (existsSync(candidate)) {\n return [\n {\n path: candidate,\n reason: `${name} shadows AGENTS.md on hermes (first context category wins)`,\n budgetBytes: 18 * 1024, // hermes truncates each context file at ~20k chars\n },\n ];\n }\n }\n return [\n {\n path: join(ctx.projectDir, \"AGENTS.md\"),\n reason:\n \"AGENTS.md (hermes reads it from the cwd only — run from the project root; ~20k chars/file truncation)\",\n budgetBytes: 18 * 1024,\n },\n ];\n }\n\n // ── Native paths (server + hooks share the SAME file) ─────────────────────\n\n override getConfigDir(_ctx: InstallContext): string {\n return dirname(this.userConfigPath());\n }\n\n override getServerConfigPath(_ctx: InstallContext): string {\n return this.userConfigPath();\n }\n\n /** Same file as the server config — Hermes hooks live in config.yaml. */\n override getHookConfigPath(_ctx: InstallContext): string {\n return this.userConfigPath();\n }\n\n private userConfigPath(): string {\n return join(homedir(), \".hermes\", \"config.yaml\");\n }\n\n // ── MCP server install / uninstall (YAML mcp_servers) ─────────────────────\n\n override installServer(ctx: InstallContext): ChangeRecord[] {\n const { connector, dryRun } = ctx;\n const path = this.getServerConfigPath(ctx);\n const server = this.effectiveServer(ctx);\n\n if (!server) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path,\n detail: connector.server\n ? \"server registration disabled for hermes\"\n : \"connector declares no MCP server\",\n },\n ];\n }\n // Hermes registers stdio sidecars ({command,args,env}) AND remote HTTP\n // servers ({url,headers}) under the same mcp_servers key. It has no SSE\n // transport (docs: website/docs/user-guide/features/mcp.md), so anything\n // else is reported, never silently dropped.\n const isStdio = server.transport === \"stdio\" && !!server.command;\n const isHttp = server.transport === \"http\" && !!server.url;\n if (!isStdio && !isHttp) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path,\n detail: `transport \"${server.transport}\" not registrable in ${MCP_ROOT_KEY} (stdio + http only)`,\n },\n ];\n }\n\n const symlink = this.symlinkPathWarning(path);\n if (symlink) return [symlink];\n\n const entry = this.renderServerEntry(ctx, server);\n\n return [\n upsertInObjectMap({\n codec: yamlObjectMapCodec(),\n rootKey: MCP_ROOT_KEY,\n policy: \"coerce\",\n platform: this.id,\n configPath: path,\n entryId: connector.id,\n entry,\n dryRun,\n }),\n ];\n }\n\n override uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const { connector, dryRun } = ctx;\n const path = this.getServerConfigPath(ctx);\n const symlink = this.symlinkPathWarning(path);\n if (symlink) return [symlink];\n\n return [\n removeFromObjectMap({\n codec: yamlObjectMapCodec(),\n rootKey: MCP_ROOT_KEY,\n policy: \"coerce\",\n platform: this.id,\n configPath: path,\n entryId: connector.id,\n dryRun,\n }),\n ];\n }\n\n /**\n * Render the MCP entry — a remote HTTP `{ url, headers? }` or a stdio sidecar\n * `{ command, args, env }`. Hermes has no native interpolation, so env-refs\n * resolve to literals here. The stdio path honors the telemetry serve-wrapper.\n */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): HermesStdioServer | HermesHttpServer {\n // Remote HTTP — { url, headers? }. Never telemetry-wrapped (a URL has no\n // local command to route through the serve proxy). Hermes has no native env\n // token, so ${env:VAR} refs in url/headers resolve to literals.\n if (server.transport === \"http\") {\n const entry: HermesHttpServer = { url: resolveEnvRefsDeep(server.url ?? \"\") };\n if (server.headers && Object.keys(server.headers).length > 0) {\n const headers: Record<string, string> = {};\n for (const [k, v] of Object.entries(resolveEnvRefsDeep(server.headers))) {\n headers[k] = String(v);\n }\n entry.headers = headers;\n }\n return entry;\n }\n\n let command = server.command as string;\n let args = [...(server.args ?? [])];\n\n ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));\n\n command = resolveEnvRefsDeep(command);\n args = resolveEnvRefsDeep(args);\n\n const entry: HermesStdioServer = { command };\n if (args.length > 0) entry.args = args;\n if (server.env && Object.keys(server.env).length > 0) {\n const env: Record<string, string> = {};\n for (const [k, v] of Object.entries(resolveEnvRefsDeep(server.env))) {\n env[k] = String(v);\n }\n entry.env = env;\n }\n return entry;\n }\n\n // ── Hook install / uninstall (YAML hooks map in the SAME config.yaml) ─────\n\n override installHooks(ctx: InstallContext): ChangeRecord[] {\n const { connector, dryRun } = ctx;\n const path = this.getHookConfigPath(ctx);\n const override = connector.platforms[HOST];\n\n // `hooks: false` disables only the NORMALIZED events. nativeHooks is a\n // sibling, hermes-scoped declaration on the same override and installs\n // regardless.\n const events = override?.hooks === false ? [] : connector.hookEvents;\n const nativeHooks = override?.nativeHooks ?? {};\n const nativeEvents = Object.keys(nativeHooks);\n\n if (events.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 hermes\" : \"connector declares no hooks\",\n },\n ];\n }\n\n const symlink = this.symlinkPathWarning(path);\n if (symlink) return [symlink];\n\n const cfg = readYaml<Record<string, unknown>>(path) ?? {};\n const hooks = this.hooksBucket(cfg);\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n for (const event of events) {\n const hermesEvent = EVENT_TO_HERMES[event];\n if (!hermesEvent) {\n // No Hermes equivalent for this canonical event — report and skip.\n changes.push({\n platform: this.id,\n action: \"warn\",\n path,\n detail: `${event} has no Hermes hook equivalent — skipped`,\n });\n continue;\n }\n\n // The hook command keeps the CANONICAL event token so the runtime\n // dispatcher (parseEvent/formatReply) stays consistent; only the YAML KEY\n // the entry is filed under is the native Hermes name.\n const command = buildHomeBinHookCommand(ctx.homeBinPath, HOST, event, connector.id);\n const matcher = connector.hooks[event]?.matcher ?? \"\";\n const timeout = this.hookTimeout(connector.server);\n const desired: HermesHookEntry = { matcher, command, timeout };\n\n const bucket = Array.isArray(hooks[hermesEvent])\n ? (hooks[hermesEvent] as HermesHookEntry[])\n : (hooks[hermesEvent] = [] as HermesHookEntry[]);\n const idx = bucket.findIndex((e) => this.isOurCommand(e?.command, ctx));\n\n if (idx >= 0) {\n if (JSON.stringify(bucket[idx]) === JSON.stringify(desired)) {\n changes.push({ platform: this.id, action: \"skip\", path, detail: `${HOOKS_KEY}.${hermesEvent}` });\n continue;\n }\n bucket[idx] = desired;\n changes.push({ platform: this.id, action: \"update\", path, detail: `${HOOKS_KEY}.${hermesEvent}` });\n } else {\n bucket.push(desired);\n changes.push({ platform: this.id, action: \"create\", path, detail: `${HOOKS_KEY}.${hermesEvent}` });\n }\n mutated = true;\n }\n\n // NATIVE passthrough events: Hermes-native event-name keys (e.g. pre_llm_call,\n // transform_tool_result) filed VERBATIM into the YAML hooks map — no\n // EVENT_TO_HERMES mapping, since they ARE Hermes events. Same entry shape +\n // idempotency, matched by EXACT command so a native key coinciding with a\n // mapped canonical key never clobbers it.\n for (const event of nativeEvents) {\n const command = buildHomeBinHookCommand(ctx.homeBinPath, HOST, event, connector.id);\n const matcher = nativeHooks[event]?.matcher ?? \"\";\n const timeout = this.hookTimeout(connector.server);\n const desired: HermesHookEntry = { matcher, command, timeout };\n const bucket = Array.isArray(hooks[event])\n ? (hooks[event] as HermesHookEntry[])\n : (hooks[event] = [] as HermesHookEntry[]);\n const idx = bucket.findIndex((e) => e?.command === command);\n if (idx >= 0) {\n if (JSON.stringify(bucket[idx]) === JSON.stringify(desired)) {\n changes.push({ platform: this.id, action: \"skip\", path, detail: `${HOOKS_KEY}.${event} (native)` });\n } else {\n bucket[idx] = desired;\n changes.push({ platform: this.id, action: \"update\", path, detail: `${HOOKS_KEY}.${event} (native)` });\n mutated = true;\n }\n } else {\n bucket.push(desired);\n changes.push({ platform: this.id, action: \"create\", path, detail: `${HOOKS_KEY}.${event} (native)` });\n mutated = true;\n }\n }\n\n if (mutated) writeYaml(path, cfg, dryRun);\n return changes;\n }\n\n override uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n const path = this.getHookConfigPath(ctx);\n const symlink = this.symlinkPathWarning(path);\n if (symlink) return [symlink];\n\n const cfg = readYaml<Record<string, unknown>>(path);\n const hooksRaw = cfg?.[HOOKS_KEY];\n if (\n !cfg ||\n !hooksRaw ||\n typeof hooksRaw !== \"object\" ||\n Array.isArray(hooksRaw)\n ) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no hooks section present\" }];\n }\n const hooks = hooksRaw as Record<string, unknown>;\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n for (const event of Object.keys(hooks)) {\n const bucket = hooks[event];\n if (!Array.isArray(bucket)) continue;\n const kept = (bucket as HermesHookEntry[]).filter(\n (e) => !this.isOurCommand(e?.command, ctx),\n );\n if (kept.length === bucket.length) continue;\n mutated = true;\n if (kept.length > 0) hooks[event] = kept;\n else delete hooks[event];\n changes.push({\n platform: this.id,\n action: \"remove\",\n path,\n detail: `${HOOKS_KEY}.${event} (${bucket.length - kept.length})`,\n });\n }\n\n if (mutated) writeYaml(path, cfg, ctx.dryRun);\n if (changes.length === 0) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no matching hook entries\" }];\n }\n return changes;\n }\n\n // ── Action surface (quick_commands map in the SAME config.yaml) ───────────\n // Each declared action emits `quick_commands.<id>: { type: \"exec\", command }`\n // where command is the home-bin action verb — a `/<id>` slash command that\n // runs it directly, bypassing the LLM. MERGE-preserve: never clobber another\n // entry. Set-if-absent per id; if `quick_commands.<id>` exists and is NOT\n // ours, skip-warn (the configPatch ownership semantics).\n\n override installActions(ctx: InstallContext): ChangeRecord[] {\n const { connector, dryRun } = ctx;\n const path = this.getHookConfigPath(ctx);\n\n if (connector.platforms[HOST]?.actions === false) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"actions disabled for hermes\" }];\n }\n const triggers = this.actionTriggers(ctx);\n if (triggers.length === 0) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"connector declares no actions\" }];\n }\n\n const symlink = this.symlinkPathWarning(path);\n if (symlink) return [symlink];\n\n const cfg = readYaml<Record<string, unknown>>(path) ?? {};\n const bucket = this.objectBucket(cfg, QUICK_COMMANDS_KEY);\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n for (const trigger of triggers) {\n const desired: HermesQuickCommand = { type: \"exec\", command: trigger.command };\n const existing = bucket[trigger.id];\n if (existing !== undefined) {\n // Set-if-absent: only re-write an entry that is already OURS (an\n // exec entry whose command is our action verb for this connector).\n if (!this.isOurQuickCommand(existing, ctx)) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n path,\n detail: `${QUICK_COMMANDS_KEY}.${trigger.id} exists and is not ours — skipped`,\n });\n continue;\n }\n if (JSON.stringify(existing) === JSON.stringify(desired)) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path,\n detail: `${QUICK_COMMANDS_KEY}.${trigger.id}`,\n });\n continue;\n }\n bucket[trigger.id] = desired;\n changes.push({\n platform: this.id,\n action: \"update\",\n path,\n detail: `${QUICK_COMMANDS_KEY}.${trigger.id}`,\n });\n } else {\n bucket[trigger.id] = desired;\n changes.push({\n platform: this.id,\n action: \"create\",\n path,\n detail: `${QUICK_COMMANDS_KEY}.${trigger.id}`,\n });\n }\n mutated = true;\n }\n\n if (mutated) writeYaml(path, cfg, dryRun);\n return changes;\n }\n\n override uninstallActions(ctx: InstallContext): ChangeRecord[] {\n const path = this.getHookConfigPath(ctx);\n const symlink = this.symlinkPathWarning(path);\n if (symlink) return [symlink];\n\n const cfg = readYaml<Record<string, unknown>>(path);\n const bucketRaw = cfg?.[QUICK_COMMANDS_KEY];\n if (\n !cfg ||\n !bucketRaw ||\n typeof bucketRaw !== \"object\" ||\n Array.isArray(bucketRaw)\n ) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no quick_commands section present\" }];\n }\n const bucket = bucketRaw as Record<string, unknown>;\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n // Remove ONLY our exec entries; leave foreign entries (and the map itself\n // when any remain) untouched.\n for (const id of Object.keys(bucket)) {\n if (!this.isOurQuickCommand(bucket[id], ctx)) continue;\n delete bucket[id];\n mutated = true;\n changes.push({\n platform: this.id,\n action: \"remove\",\n path,\n detail: `${QUICK_COMMANDS_KEY}.${id}`,\n });\n }\n\n if (mutated) {\n // Drop an emptied map so we leave no orphan key behind.\n if (Object.keys(bucket).length === 0) delete cfg[QUICK_COMMANDS_KEY];\n writeYaml(path, cfg, ctx.dryRun);\n }\n if (changes.length === 0) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no matching quick_commands entries\" }];\n }\n return changes;\n }\n\n /** True when a quick-command entry is OUR exec action verb for this connector. */\n private isOurQuickCommand(entry: unknown, ctx: InstallContext): boolean {\n if (!entry || typeof entry !== \"object\" || Array.isArray(entry)) return false;\n const e = entry as Partial<HermesQuickCommand>;\n if (e.type !== \"exec\" || typeof e.command !== \"string\") return false;\n return isHomeBinActionCommand(e.command, ctx.homeBinPath, ctx.connector.id);\n }\n\n /** True when a hook command is ours (anchored home-bin + connector id). */\n private isOurCommand(command: string | undefined, ctx: InstallContext): boolean {\n return isHomeBinHookCommand(command, ctx.homeBinPath, ctx.connector.id);\n }\n\n private hookTimeout(server: ServerDef | undefined): number {\n const ms = server?.timeoutMs;\n if (typeof ms === \"number\" && ms > 0) {\n // Hermes documents `timeout: <seconds>` as \"default 60, capped at 300\";\n // a value > 300 is clamped with a warning by Hermes itself (see hooks.md\n // on NousResearch/hermes-agent). Clamp here so we never emit a value the\n // host would reject/cap. No documented minimum, but a positive timeoutMs\n // must not round down to 0 (an undocumented, ambiguous \"no/instant\"\n // timeout), so floor at 1s. In-range values (1000–300000ms) are unchanged.\n return Math.min(HOOK_TIMEOUT_MAX, Math.max(HOOK_TIMEOUT_MIN, Math.round(ms / 1000)));\n }\n return DEFAULT_HOOK_TIMEOUT;\n }\n\n // ── Content surface: skills (dir-per-skill SKILL.md) ─────────────────────\n // CONTENT-ONLY: pure native-file writers, mirroring goose/openclaw. No\n // runtime dispatch, no home-bin pointer, no telemetry wrap. Idempotent\n // (byte-identical → skip) via writeContentFile and reversible via\n // removeContentFile + removeDirIfEmpty. Honors platforms[\"hermes\"].skills\n // === false. No config.yaml entry — Hermes auto-discovers ~/.hermes/skills.\n //\n // USER scope only: ~/.hermes/skills/<name>/SKILL.md (the documented local,\n // read-write \"single source of truth\"). Project scope skip-warns — there is\n // no hermes-owned project skills dir documented.\n\n /** The user-scope skills ROOT dir (~/.hermes/skills). */\n private skillsDir(): string {\n return join(dirname(this.userConfigPath()), \"skills\");\n }\n\n /** Per-skill directory: ~/.hermes/skills/<name>. */\n private skillDir(name: string): string {\n return join(this.skillsDir(), 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 hermes\" }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n if (ctx.scope !== \"user\") {\n // Hermes documents only the user-scope ~/.hermes/skills root; there is no\n // hermes-owned project skills dir. Report rather than guess a path.\n return [\n {\n platform: this.id,\n action: \"warn\",\n detail:\n `no project-scope skills dir on hermes (~/.hermes/skills is user-scope only); ` +\n `${connector.skills.length} skipped`,\n },\n ];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(skill.name);\n // Guard a skills path occupied by a regular FILE (would throw ENOTDIR on\n // mkdir): skip-warn rather than crash (the cline `.clinerules`-is-a-file\n // precedent). The skills root or the per-skill dir is the likely culprit.\n const blockingFile = this.firstFileOnSkillPath(dir);\n if (blockingFile !== null) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: blockingFile,\n detail: `${blockingFile} is a file, not a directory; skill \"${skill.name}\" skipped`,\n });\n continue;\n }\n changes.push(\n this.writeContentFile(join(dir, \"SKILL.md\"), renderSkillMd(skill), ctx.dryRun),\n );\n // Bundle any resource files beside SKILL.md (relative path → contents).\n // Defense-in-depth: skip+warn on any key that escapes the skill dir\n // (config-time validation already rejects these, but never trust input).\n for (const [rel, contents] of Object.entries(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `skill resource \"${rel}\" escapes the skill dir; skipped`,\n });\n continue;\n }\n changes.push(this.writeContentFile(target, contents, ctx.dryRun));\n }\n }\n return changes;\n }\n\n /**\n * Walk from the skills root (~/.hermes/skills) down to `leaf` and return the\n * FIRST segment that exists as a regular file (a mkdir there throws ENOTDIR),\n * else null — so installSkills can skip-warn instead of crashing.\n */\n private firstFileOnSkillPath(leaf: string): string | null {\n const root = this.skillsDir();\n const segments: string[] = [];\n let cur = leaf;\n while (cur.length >= root.length) {\n segments.unshift(cur);\n if (cur === root) break;\n const parent = dirname(cur);\n if (parent === cur) break;\n cur = parent;\n }\n for (const p of segments) {\n if (!existsSync(p)) return null;\n try {\n if (statSync(p).isFile()) return p;\n } catch {\n return null;\n }\n }\n return null;\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 if (ctx.scope !== \"user\") {\n // Nothing is written at project scope (install skip-warned), so nothing\n // to clean — report the same scope reason as install for symmetry.\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: \"no project-scope skills dir on hermes (user-scope only); nothing to remove\",\n },\n ];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(skill.name);\n // Remove only the files we wrote (SKILL.md + declared resources), then the\n // skill dir itself when we own its full contents.\n changes.push(this.removeContentFile(join(dir, \"SKILL.md\"), ctx.dryRun));\n for (const rel of Object.keys(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) continue; // never delete outside the skill dir\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n // Only remove the skill dir when WE own its full contents — never rm -rf a\n // dir that still holds user-added / sibling-tool / shared files.\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n // ── Diagnostics ──────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const path = this.getServerConfigPath(ctx);\n const id = ctx.connector.id;\n const homeBin = ctx.homeBinPath;\n const hookEvents = ctx.connector.hookEvents;\n return [\n {\n name: `${this.name}: config.yaml present`,\n check: () =>\n existsSync(path)\n ? { status: \"OK\", detail: path }\n : { status: \"FAIL\", detail: `not found: ${path}` },\n },\n {\n name: `${this.name}: ${MCP_ROOT_KEY}.${id} registered`,\n check: () => {\n // Only assert what the connector declares: a server-less connector\n // never writes an mcp entry, so its absence is healthy.\n if (!ctx.connector.server) return { status: \"OK\", detail: \"no MCP server declared\" };\n const cfg = readYaml<Record<string, unknown>>(path);\n const bucket = cfg?.[MCP_ROOT_KEY];\n const present =\n typeof bucket === \"object\" &&\n bucket !== null &&\n !Array.isArray(bucket) &&\n id in (bucket as Record<string, unknown>);\n return present\n ? { status: \"OK\", detail: `${MCP_ROOT_KEY}.${id}` }\n : { status: \"FAIL\", detail: `${MCP_ROOT_KEY}.${id} not found in ${path}` };\n },\n },\n {\n name: `${this.name}: hook command registered`,\n check: () => {\n if (hookEvents.length === 0) return { status: \"OK\", detail: \"no hooks declared\" };\n const cfg = readYaml<Record<string, unknown>>(path);\n const hooks = cfg?.[HOOKS_KEY];\n if (!hooks || typeof hooks !== \"object\" || Array.isArray(hooks)) {\n return { status: \"FAIL\", detail: `no ${HOOKS_KEY} section in ${path}` };\n }\n const registered = Object.values(hooks as Record<string, unknown>).some(\n (bucket) =>\n Array.isArray(bucket) &&\n (bucket as HermesHookEntry[]).some((e) =>\n isHomeBinHookCommand(e?.command, homeBin, id),\n ),\n );\n return registered\n ? { status: \"OK\", detail: \"hook command present\" }\n : { status: \"FAIL\", detail: `no hook for ${id} in ${path}` };\n },\n },\n ];\n }\n\n // ── Runtime: parse Hermes stdin JSON → normalized event ──────────────────\n\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as HermesWireInput;\n const base = {\n hostPlatform: HOST,\n connectorId: typeof input.connector === \"string\" ? input.connector : \"\",\n sessionId: typeof input.session_id === \"string\" ? input.session_id : \"\",\n ...(typeof input.cwd === \"string\" ? { projectDir: input.cwd } : {}),\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 // VERIFIED (NousResearch/hermes-agent model_tools.py:856-871 +\n // shell_hooks.py::_serialize_payload): post_tool_call's `result` kwarg is\n // NOT allowlisted, so it lands at extra.result — top-level tool_output/\n // tool_response are NEVER emitted. Read extra.result for the output.\n const extra = input.extra ?? {};\n const out = toStringOrUndefined(extra.result);\n // VERIFIED: there is no `is_error` boolean. The host emits status\n // (\"ok\"|\"error\") + error_type/error_message (model_tools.py:815-821,\n // _tool_result_observer_fields), all under extra. Derive isError from a\n // non-ok status or a present error_type; emit only when determinable.\n const isError =\n typeof extra.status === \"string\"\n ? extra.status !== \"ok\"\n : typeof extra.error_type === \"string\"\n ? true\n : undefined;\n const ev: PostToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n ...(out !== undefined ? { toolOutput: out } : {}),\n ...(typeof isError === \"boolean\" ? { isError } : {}),\n };\n return ev;\n }\n case \"SessionStart\": {\n // VERIFIED (NousResearch/hermes-agent conversation_loop.py:340-344):\n // on_session_start is invoked with { session_id, model, platform } only —\n // there is NO `source`/start-reason kwarg (model/platform land under\n // extra). Hermes fires on_session_start ONLY for a brand-new session (not\n // on continuation), so the canonical \"startup\" is the single honest\n // value; there is no compact/resume/clear discriminator to normalize.\n const ev: SessionStartEvent = { ...base, source: \"startup\" };\n return ev;\n }\n case \"SessionEnd\": {\n // VERIFIED (NousResearch/hermes-agent turn_finalizer.py:415-423):\n // on_session_end is invoked with completed:bool / interrupted:bool (both\n // under extra) — there is NO top-level `reason` kwarg. Derive a reason\n // string from the two booleans (interrupted wins; else completed).\n const extra = input.extra ?? {};\n const reason =\n extra.interrupted === true\n ? \"interrupted\"\n : extra.completed === true\n ? \"completed\"\n : undefined;\n const ev: SessionEndEvent = {\n ...base,\n ...(reason !== undefined ? { reason } : {}),\n };\n return ev;\n }\n // The five arms below parse events Hermes does NOT fire (userPromptSubmit/\n // preCompact/stop/notification capabilities are false; PostCompact unset).\n // They stay as defensive normalizers for a manual/mis-routed dispatch, and\n // read from `extra` because that is the only envelope Hermes' serializer\n // produces — never an invented top-level field.\n case \"UserPromptSubmit\": {\n const extra = input.extra ?? {};\n const ev: UserPromptSubmitEvent = {\n ...base,\n prompt: typeof extra.prompt === \"string\" ? extra.prompt : \"\",\n };\n return ev;\n }\n case \"PreCompact\": {\n const extra = input.extra ?? {};\n const ev: PreCompactEvent = {\n ...base,\n ...(extra.trigger === \"auto\" || extra.trigger === \"manual\"\n ? { trigger: extra.trigger }\n : {}),\n };\n return ev;\n }\n case \"PostCompact\": {\n // Hermes does not fire PostCompact natively (postCompact unset →\n // warn-skip at install). Parsed defensively, mirroring PreCompact, so a\n // manual/mis-routed dispatch normalizes instead of hitting the guard.\n const extra = input.extra ?? {};\n const ev: PostCompactEvent = {\n ...base,\n ...(extra.trigger === \"auto\" || extra.trigger === \"manual\"\n ? { trigger: extra.trigger }\n : {}),\n };\n return ev;\n }\n case \"Stop\": {\n const extra = input.extra ?? {};\n const ev: StopEvent = {\n ...base,\n ...(typeof extra.stop_hook_active === \"boolean\"\n ? { stopHookActive: extra.stop_hook_active }\n : {}),\n };\n return ev;\n }\n case \"Notification\": {\n const extra = input.extra ?? {};\n const ev: NotificationEvent = {\n ...base,\n message: typeof extra.message === \"string\" ? extra.message : \"\",\n };\n return ev;\n }\n case \"SubagentStop\": {\n // VERIFIED (NousResearch/hermes-agent delegate_tool.py:2520-2529): the\n // subagent_stop invoke passes parent_session_id, child_session_id,\n // child_role, child_summary, child_status, duration_ms. Only\n // parent_session_id is allowlisted (→ top-level session_id); EVERY child_*\n // field nests under extra. So the id/role/output all come from extra.* —\n // top-level agent_id/agent_type/child_id/last_assistant_message/\n // stop_hook_active are NEVER emitted by Hermes. child_status (∈ completed/\n // failed/interrupted/error) stays accessible via `raw`.\n const extra = input.extra ?? {};\n const ev: SubagentStopEvent = {\n ...base,\n ...(typeof extra.child_session_id === \"string\"\n ? { agentId: extra.child_session_id }\n : {}),\n ...(typeof extra.child_role === \"string\"\n ? { agentType: extra.child_role }\n : {}),\n ...(typeof extra.child_summary === \"string\"\n ? { lastAssistantMessage: extra.child_summary }\n : {}),\n };\n return ev;\n }\n case \"PermissionRequest\":\n case \"PostToolUseFailure\":\n case \"SubagentStart\": {\n // No Hermes analog: pre_approval_request is observe-only (no decision\n // control), tool failures arrive merged into post_tool_call, and there\n // is no subagent_start. Install already skip-warns these; a runtime\n // dispatch is a mis-route — fail loudly.\n throw new Error(`unsupported hermes hook event: ${String(event)}`);\n }\n default: {\n const _never: never = event;\n throw new Error(`unsupported hermes hook event: ${String(_never)}`);\n }\n }\n }\n\n // ── Runtime: normalized response → Hermes native hook reply ──────────────\n // Hermes shell hooks read a JSON reply from stdout (exit 0 = allow). We emit a\n // Claude-like `hookSpecificOutput` wrapper; if Hermes' exact reply schema\n // differs, this is the single place to adjust the mapping.\n\n formatReply(event: HookEventName, response: HookResponse): HookReply {\n const decision = response.decision ?? \"allow\";\n\n if (decision === \"deny\") {\n // SubagentStop deny carries Stop semantics — it keeps the subagent\n // running with `reason` as its next instruction — and (like Claude's\n // Stop class) is honored only as the TOP-LEVEL {\"decision\":\"block\",\n // \"reason\"}, not as a permissionDecision envelope.\n if (event === \"SubagentStop\") {\n return this.stdout({\n decision: \"block\",\n reason: response.reason ?? \"Blocked by hook\",\n });\n }\n return this.stdout({\n hookSpecificOutput: {\n hookEventName: event,\n permissionDecision: \"deny\",\n permissionDecisionReason: response.reason ?? \"Blocked by hook\",\n },\n });\n }\n\n if (decision === \"ask\") {\n return this.stdout({\n hookSpecificOutput: {\n hookEventName: event,\n permissionDecision: \"ask\",\n permissionDecisionReason: response.reason ?? \"Confirmation required by hook\",\n },\n });\n }\n\n if (decision === \"context\" && response.additionalContext) {\n return this.stdout({\n hookSpecificOutput: { hookEventName: event, additionalContext: response.additionalContext },\n });\n }\n\n // allow / modify (unsupported — shell hooks can't rewrite args) / void.\n return { exitCode: 0 };\n }\n\n private stdout(payload: unknown): HookReply {\n return { exitCode: 0, stdout: JSON.stringify(payload) };\n }\n\n // ── Internal helpers ──────────────────────────────────────────────────────\n\n /** Resolve the per-platform server override into an effective ServerDef. */\n private effectiveServer(ctx: InstallContext): ServerDef | undefined {\n const override = ctx.connector.platforms[this.id]?.server;\n if (override === false) return undefined;\n const base = ctx.connector.server;\n if (!base) return undefined;\n return override && typeof override === \"object\" ? { ...base, ...override } : base;\n }\n\n /** Get-or-create an object bucket (map) at `cfg[key]`. */\n private objectBucket(cfg: Record<string, unknown>, key: string): Record<string, unknown> {\n const existing = cfg[key];\n if (existing && typeof existing === \"object\" && !Array.isArray(existing)) {\n return existing as Record<string, unknown>;\n }\n const fresh: Record<string, unknown> = {};\n cfg[key] = fresh;\n return fresh;\n }\n\n /** Get-or-create the hooks map at `cfg.hooks`. */\n private hooksBucket(cfg: Record<string, unknown>): Record<string, unknown> {\n return this.objectBucket(cfg, HOOKS_KEY);\n }\n}\n\n/** Coerce an unknown value into a string for the normalized event. */\nfunction toStringOrUndefined(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 HermesAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,SAAS,YAAY,gBAAgB;AACrC,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY;AAoC9B,IAAM,OAAmB;AAEzB,IAAM,eAAe;AAErB,IAAM,YAAY;AAMlB,IAAM,qBAAqB;AAE3B,IAAM,uBAAuB;AAO7B,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AAgBzB,IAAM,kBAA0D;AAAA,EAC9D,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,cAAc;AAAA,EACd,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOZ,cAAc;AAChB;AAgGO,IAAM,gBAAN,cAA4B,YAA+B;AAAA,EACvD,KAAiB;AAAA,EACjB,OAAO;AAAA,EACP,WAAyB;AAAA,EAEzB,eAAqC;AAAA;AAAA;AAAA;AAAA;AAAA,IAK5C,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,YAAY;AAAA;AAAA,IAEZ,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,MAAM;AAAA,IACN,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMd,cAAc;AAAA;AAAA,IAEd,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,yBAAyB;AAAA;AAAA,IAEzB,YAAY,CAAC,SAA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AAW,IAAI,GAAG;AACxB,QAAI,YAAY,OAAO,aAAa,YAAY,CAAC,MAAM,QAAQ,QAAQ,GAAG;AACxE,aAAO;AAAA,IACT;AACA,UAAM,QAAiC,CAAC;AACxC,QAAI,GAAG,IAAI;AACX,WAAO;AAAA,EACT;AAAA;AAAA,EAGQ,YAAY,KAAuD;AACzE,WAAO,KAAK,aAAa,KAAK,SAAS;AAAA,EACzC;AACF;AAGA,SAAS,oBAAoB,OAAoC;AAC/D,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,cAAc;AACzC,IAAO,iBAAQ;","names":["entry"]}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
fail
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-KAEYJGK7.js";
|
|
5
|
+
import "./chunk-RFYQXT7C.js";
|
|
6
6
|
import "./chunk-OP4KBXUO.js";
|
|
7
7
|
import "./chunk-7QRUZAUG.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-QP35SRUZ.js";
|
|
9
9
|
import {
|
|
10
10
|
isNativeHookDeclared,
|
|
11
11
|
runHook,
|
|
12
12
|
runNativeHook
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-NFMHYIN2.js";
|
|
14
|
+
import "./chunk-ZQCT63JU.js";
|
|
15
15
|
import "./chunk-KHO5WNTP.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-O4BKQSPP.js";
|
|
17
|
+
import "./chunk-JZIM33C2.js";
|
|
18
|
+
import "./chunk-IDKI42JW.js";
|
|
19
|
+
import "./chunk-BZOOVTFG.js";
|
|
20
20
|
import "./chunk-TO57WYBB.js";
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-LBOGRZGY.js";
|
|
22
|
+
import "./chunk-D65GIBCG.js";
|
|
23
23
|
|
|
24
24
|
// src/cli/commands/hook.ts
|
|
25
25
|
import { parseArgs } from "util";
|
|
@@ -93,4 +93,4 @@ export {
|
|
|
93
93
|
HOOK_EVENTS,
|
|
94
94
|
run
|
|
95
95
|
};
|
|
96
|
-
//# sourceMappingURL=hook-
|
|
96
|
+
//# sourceMappingURL=hook-UT3Q43AB.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ActionDef, C as CommandDef, c as ConfigPatchDef, d as ConnectorConfig, R as ResolvedConnector, e as HookEventName, H as HookDefinition, M as MemoryDef, N as NativeHookDef, w as SkillDef, y as StatuslineDef, B as SubagentDef } from './types-
|
|
2
|
-
export { a as ActionResult, b as AuthSpec, V as ChangeRecord, W as DetectedPlatform, X as DiagnosticResult, E as EventPayloadMap, f as HookParadigm, g as HookResponse, h as HooksConfig, i as HostCtx, Y as InstallResult, I as InstallScope, j as NativeHookEvent, k as NotificationEvent, l as PermissionRequestEvent, m as PlatformCapabilities, P as PlatformId, n as PlatformMemoryOverride, o as PlatformOverride, p as PostToolUseEvent, q as PostToolUseFailureEvent, r as PreCompactEvent, s as PreToolUseEvent, S as ServerDef, u as SessionEndEvent, v as SessionStartEvent, x as StatuslineContext, z as StopEvent, D as SubagentStartEvent, F as SubagentStopEvent, T as TelemetryAccessor, K as TelemetryConfig, L as TelemetryUsageSummary, O as ToolFilter, Q as Transport, U as UserPromptSubmitEvent } from './types-
|
|
1
|
+
import { A as ActionDef, C as CommandDef, c as ConfigPatchDef, d as ConnectorConfig, R as ResolvedConnector, e as HookEventName, H as HookDefinition, M as MemoryDef, N as NativeHookDef, w as SkillDef, y as StatuslineDef, B as SubagentDef } from './types-ChUrvw0j.js';
|
|
2
|
+
export { a as ActionResult, b as AuthSpec, V as ChangeRecord, W as DetectedPlatform, X as DiagnosticResult, E as EventPayloadMap, f as HookParadigm, g as HookResponse, h as HooksConfig, i as HostCtx, Y as InstallResult, I as InstallScope, j as NativeHookEvent, k as NotificationEvent, l as PermissionRequestEvent, m as PlatformCapabilities, P as PlatformId, n as PlatformMemoryOverride, o as PlatformOverride, p as PostToolUseEvent, q as PostToolUseFailureEvent, r as PreCompactEvent, s as PreToolUseEvent, S as ServerDef, u as SessionEndEvent, v as SessionStartEvent, x as StatuslineContext, z as StopEvent, D as SubagentStartEvent, F as SubagentStopEvent, T as TelemetryAccessor, K as TelemetryConfig, L as TelemetryUsageSummary, O as ToolFilter, Q as Transport, U as UserPromptSubmitEvent } from './types-ChUrvw0j.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* core/define-connector — the public write-once entry point.
|
package/dist/index.js
CHANGED
|
@@ -11,11 +11,11 @@ import {
|
|
|
11
11
|
defineSkill,
|
|
12
12
|
defineStatusline,
|
|
13
13
|
defineSubagent
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-JZIM33C2.js";
|
|
15
|
+
import "./chunk-IDKI42JW.js";
|
|
16
|
+
import "./chunk-BZOOVTFG.js";
|
|
17
|
+
import "./chunk-LBOGRZGY.js";
|
|
18
|
+
import "./chunk-D65GIBCG.js";
|
|
19
19
|
export {
|
|
20
20
|
ConnectorConfigError,
|
|
21
21
|
defineAction,
|
|
@@ -3,35 +3,35 @@ import {
|
|
|
3
3
|
installConnector,
|
|
4
4
|
installViaMarketplace,
|
|
5
5
|
parseInstallMethod
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-FVARNRCE.js";
|
|
7
|
+
import "./chunk-RGQTN7K3.js";
|
|
8
|
+
import "./chunk-WOUGWPZQ.js";
|
|
9
|
+
import "./chunk-O3HIYTBK.js";
|
|
10
10
|
import {
|
|
11
11
|
fail,
|
|
12
12
|
parseScope,
|
|
13
13
|
parseTargets,
|
|
14
14
|
print,
|
|
15
15
|
renderInstallResult
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-KAEYJGK7.js";
|
|
17
17
|
import "./chunk-7QRUZAUG.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-QP35SRUZ.js";
|
|
19
19
|
import "./chunk-KHO5WNTP.js";
|
|
20
20
|
import {
|
|
21
21
|
findConnectorConfig,
|
|
22
22
|
loadConnectorFromPath
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
23
|
+
} from "./chunk-O4BKQSPP.js";
|
|
24
|
+
import "./chunk-JZIM33C2.js";
|
|
25
|
+
import "./chunk-IDKI42JW.js";
|
|
26
|
+
import "./chunk-BZOOVTFG.js";
|
|
27
27
|
import "./chunk-OPXAP3AC.js";
|
|
28
28
|
import "./chunk-UM5S7DKK.js";
|
|
29
29
|
import "./chunk-H53QZQJI.js";
|
|
30
30
|
import "./chunk-DBQMX75U.js";
|
|
31
|
-
import "./chunk-
|
|
31
|
+
import "./chunk-GI4FDVWI.js";
|
|
32
32
|
import "./chunk-TO57WYBB.js";
|
|
33
|
-
import "./chunk-
|
|
34
|
-
import "./chunk-
|
|
33
|
+
import "./chunk-LBOGRZGY.js";
|
|
34
|
+
import "./chunk-D65GIBCG.js";
|
|
35
35
|
|
|
36
36
|
// src/cli/commands/install.ts
|
|
37
37
|
import { parseArgs } from "util";
|
|
@@ -93,4 +93,4 @@ async function run(argv) {
|
|
|
93
93
|
export {
|
|
94
94
|
run
|
|
95
95
|
};
|
|
96
|
-
//# sourceMappingURL=install-
|
|
96
|
+
//# sourceMappingURL=install-F4OIDYAK.js.map
|
|
@@ -5,16 +5,16 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
BaseAdapter,
|
|
7
7
|
renderSkillMd
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-GI4FDVWI.js";
|
|
9
9
|
import {
|
|
10
10
|
buildHomeBinHookCommand,
|
|
11
11
|
isHomeBinHookCommand
|
|
12
12
|
} from "./chunk-TO57WYBB.js";
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-LBOGRZGY.js";
|
|
14
|
+
import "./chunk-D65GIBCG.js";
|
|
15
15
|
|
|
16
16
|
// src/adapters/jetbrains-copilot/index.ts
|
|
17
|
-
import { existsSync
|
|
17
|
+
import { existsSync } from "fs";
|
|
18
18
|
import { dirname, join } from "path";
|
|
19
19
|
var HOST = "jetbrains-copilot";
|
|
20
20
|
var JETBRAINS_HOOKS_VERSION = 1;
|
|
@@ -189,6 +189,8 @@ var JetBrainsCopilotAdapter = class extends BaseAdapter {
|
|
|
189
189
|
];
|
|
190
190
|
}
|
|
191
191
|
const hooksPath = this.getHookConfigPath(ctx);
|
|
192
|
+
const symlink = this.symlinkPathWarning(hooksPath);
|
|
193
|
+
if (symlink) return [symlink];
|
|
192
194
|
const file = this.readJson(hooksPath) ?? {};
|
|
193
195
|
const __skip = this.malformedHookRootSkip(hooksPath, file.hooks);
|
|
194
196
|
if (__skip) return [__skip];
|
|
@@ -279,6 +281,8 @@ var JetBrainsCopilotAdapter = class extends BaseAdapter {
|
|
|
279
281
|
}
|
|
280
282
|
uninstallHooks(ctx) {
|
|
281
283
|
const hooksPath = this.getHookConfigPath(ctx);
|
|
284
|
+
const symlink = this.symlinkPathWarning(hooksPath);
|
|
285
|
+
if (symlink) return [symlink];
|
|
282
286
|
const file = this.readJson(hooksPath);
|
|
283
287
|
const hooks = file?.hooks;
|
|
284
288
|
if (!file || !hooks) {
|
|
@@ -313,13 +317,14 @@ var JetBrainsCopilotAdapter = class extends BaseAdapter {
|
|
|
313
317
|
}
|
|
314
318
|
if (mutated) {
|
|
315
319
|
if (Object.keys(hooks).length === 0) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
320
|
+
changes.push(
|
|
321
|
+
this.removeManagedFile(
|
|
322
|
+
hooksPath,
|
|
323
|
+
ctx.dryRun,
|
|
324
|
+
"removed empty connector hooks file",
|
|
325
|
+
"no hooks file present"
|
|
326
|
+
)
|
|
327
|
+
);
|
|
323
328
|
changes.push(this.removeDirIfEmpty(dirname(hooksPath), ctx.dryRun));
|
|
324
329
|
} else {
|
|
325
330
|
this.writeJson(hooksPath, file, ctx.dryRun);
|
|
@@ -684,4 +689,4 @@ export {
|
|
|
684
689
|
adapter,
|
|
685
690
|
jetbrains_copilot_default as default
|
|
686
691
|
};
|
|
687
|
-
//# sourceMappingURL=jetbrains-copilot-
|
|
692
|
+
//# sourceMappingURL=jetbrains-copilot-6QLKUCAY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/jetbrains-copilot/index.ts"],"sourcesContent":["/**\n * adapters/jetbrains-copilot — JetBrains Copilot platform adapter for agent-connector.\n *\n * JetBrains Copilot shares the Copilot hook paradigm with VS Code Copilot\n * (Claude-compatible json-stdio), but diverges on MCP registration:\n *\n * - MCP servers: JetBrains stores MCP server registration via the IDE Settings\n * UI (Settings > Tools > GitHub Copilot > MCP > Configure), NOT in any file\n * we can reliably write — the runtime owns the `servers` key behind the UI.\n * So `installServer` writes NOTHING and returns a \"warn\" ChangeRecord telling\n * the user to add the server via the JetBrains MCP settings UI. Writing a\n * bogus file would be ignored at best and corrupt real UI state at worst.\n * `getHealthChecks` surfaces this as a WARN (not FAIL).\n *\n * - Hooks (Copilot Preview hooks): file-based and identical in shape to VS Code\n * Copilot. We write one per-connector file at\n * <projectDir>/.github/hooks/<connector-id>.json shaped as:\n * { \"version\": 1, \"hooks\": { <Event>: [ { \"type\": \"command\", \"command\" } ] } }\n * The top-level `version: 1` is REQUIRED — the Copilot hooks runtime rejects a\n * version-less file and no hooks fire. Each entry is a FLAT { type, command }\n * object (no Claude-style { matcher, hooks:[...] } wrapper). JetBrains parses\n * matchers but IGNORES them — ALL hooks fire on ALL tools — so we omit the\n * matcher entirely rather than persist an advisory one that never applies.\n *\n * - Reply: Claude-compatible JSON on stdout (exit 0), a `hookSpecificOutput`\n * object keyed by the PascalCase `hookEventName` carrying permissionDecision\n * (deny|ask) + permissionDecisionReason and additionalContext. This mirrors\n * vscode-copilot/claude-code exactly EXCEPT JetBrains cannot rewrite tool\n * input (canModifyArgs:false), so a \"modify\" decision degrades to allow.\n *\n * Env interpolation: GitHub Copilot does not document a portable native env\n * token for the hooks file, and the hooks file only ever carries our home-bin\n * hook command (no secrets), so there is nothing to interpolate here. MCP env\n * interpolation is moot because we never write the MCP file.\n */\n\nimport { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\nimport { BaseAdapter } from \"../base.js\";\nimport type { Adapter, HookReply, InstallContext, NormalizedEvent } from \"../spi.js\";\nimport type {\n ChangeRecord,\n CommandDef,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n NotificationEvent,\n PlatformCapabilities,\n PlatformId,\n PostToolUseEvent,\n PostCompactEvent,\n PreCompactEvent,\n PreToolUseEvent,\n SessionEndEvent,\n SessionStartEvent,\n StopEvent,\n UserPromptSubmitEvent,\n} from \"../../core/types.js\";\nimport {\n buildHomeBinHookCommand,\n isHomeBinHookCommand,\n} from \"../../core/spawn.js\";\nimport { renderSkillMd } from \"../claude-code/render.js\";\nimport { normalizeSessionSource } from \"../claude-code/wire.js\";\n\nconst HOST: PlatformId = \"jetbrains-copilot\";\n\n/** Top-level version the Copilot hooks runtime requires; a version-less file is rejected. */\nconst JETBRAINS_HOOKS_VERSION = 1;\n\n/**\n * JetBrains Copilot reads PascalCase hook event names from its hooks file —\n * identical to VS Code Copilot / Claude Code. Only the events JetBrains actually\n * delivers are registered; everything else has no Copilot equivalent and is\n * reported as a warn/skip at install time.\n */\nconst EVENT_MAP: Partial<Record<HookEventName, string>> = {\n PreToolUse: \"PreToolUse\",\n PostToolUse: \"PostToolUse\",\n PreCompact: \"PreCompact\",\n SessionStart: \"SessionStart\",\n SessionEnd: \"SessionEnd\",\n UserPromptSubmit: \"UserPromptSubmit\",\n};\n\n/** A single JetBrains Copilot native hook entry — a flat command object. */\ninterface JetBrainsHookEntry {\n type: \"command\";\n command: string;\n}\n\n/** The shape of a JetBrains Copilot .github/hooks/<connector>.json file. */\ninterface JetBrainsHooksFile {\n version?: number;\n hooks?: Record<string, JetBrainsHookEntry[]>;\n}\n\n/** Raw JetBrains Copilot hook stdin payload (Claude-compatible snake_case fields). */\ninterface JetBrainsWireInput {\n session_id?: string;\n transcript_path?: string;\n cwd?: string;\n workspace_roots?: string[];\n hook_event_name?: string;\n\n // tool events\n tool_name?: string;\n tool_input?: Record<string, unknown>;\n tool_response?: unknown;\n tool_output?: string;\n error_message?: string;\n\n // SessionStart\n source?: string;\n // SessionEnd\n reason?: string;\n // UserPromptSubmit\n prompt?: string;\n // PreCompact\n trigger?: string;\n // Stop\n stop_hook_active?: boolean;\n // Notification\n message?: string;\n\n /** Injected by the entrypoint so the runtime knows which connector to dispatch. */\n connector?: string;\n}\n\nexport class JetBrainsCopilotAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"JetBrains Copilot\";\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 // JetBrains Copilot's Preview hooks runtime delivers Pre/PostToolUse,\n // PreCompact, SessionStart, SessionEnd, and UserPromptSubmit (GitHub's\n // hooks-reference) — same surface as VS Code Copilot, whose reply contract\n // this adapter mirrors exactly (see formatReply: UserPromptSubmit/PostToolUse\n // deny → top-level {decision:block}). Stop stays unwired (refuted for\n // JetBrains: an unimplemented feature request, not in the documented schema).\n preToolUse: true,\n postToolUse: true,\n preCompact: true,\n sessionStart: true,\n sessionEnd: true,\n userPromptSubmit: true,\n stop: false,\n notification: false,\n // Newer events: the JetBrains Copilot Preview hooks runtime documents no\n // permission-dialog, tool-failure, or subagent lifecycle events, so\n // permissionRequest / postToolUseFailure / subagentStart / subagentStop\n // stay unset — install reports the standard skip-warn for them.\n // Per the JetBrains spec this host is deny/ask-only: a PreToolUse hook\n // CANNOT rewrite tool input, and PostToolUse cannot rewrite tool output.\n canModifyArgs: false,\n canModifyOutput: false,\n canInjectSessionContext: true,\n // MCP is managed via the IDE Settings UI (Settings > Tools > GitHub Copilot\n // > MCP). The UI accepts local stdio servers AND remote Streamable HTTP / SSE\n // servers; AC writes no file, so this list only describes what the UI accepts\n // (install reports a UI-managed warn for every transport).\n transports: [\"stdio\", \"http\", \"sse\"],\n // Content surfaces: JetBrains Copilot consumes the GitHub Copilot .github/\n // files (it has no distinct authoring location), so it is an ALIAS of the\n // vscode-copilot writer for prompt files and Agent Skills. It has no native\n // subagent/chat-mode surface, so subagents stay unsupported (BaseAdapter\n // returns the skip/warn default).\n supportsCommands: true,\n supportsSkills: true,\n supportsSubagents: false,\n // Native passthrough: GitHub's JetBrains-Copilot changelog documents an\n // errorOccurred / ErrorOccurred lifecycle event with NO canonical\n // HookEventName analog (PostToolUseFailure is tool-scoped, not a session-wide\n // error event). A connector reaches it via platforms[\"jetbrains-copilot\"].\n // nativeHooks; installHooks files the event-name key VERBATIM and the generic\n // uninstall reverses it. PascalCase ErrorOccurred matches the adapter's\n // Claude-compatible payload dialect (GitHub hooks-reference accepts both).\n supportsNativeHooks: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n // JetBrains Copilot integration is observable through two markers:\n // • the project hooks tree (<projectDir>/.github/hooks) we write to, and\n // • our per-connector hooks file specifically.\n // There is no reliable user-profile MCP file to probe (the UI owns it), so\n // detection is project-scoped and keyed on the hooks footprint.\n const githubDir = join(projectDir, \".github\");\n const hooksDir = join(githubDir, \"hooks\");\n const installed = existsSync(hooksDir) || existsSync(githubDir);\n const configPath = hooksDir;\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath,\n scope: \"project\",\n reason: installed\n ? `found JetBrains Copilot hooks tree at ${hooksDir}`\n : `no JetBrains Copilot hooks tree at ${hooksDir}`,\n confidence: installed ? \"medium\" : \"low\",\n };\n }\n\n // ── Native paths ─────────────────────────────────────────────────────────\n\n /** Hooks live under the workspace .github tree for both scopes. */\n getConfigDir(ctx: InstallContext): string {\n return join(ctx.projectDir, \".github\");\n }\n\n /**\n * MCP server registration has NO writable file on JetBrains — the IDE owns it\n * behind the Settings UI. We still return a stable path (the hooks file) so the\n * base-adapter `doctor`/`backupSettings` helpers have a sensible target rather\n * than a nonexistent/bogus MCP path. `installServer` never writes here.\n */\n getServerConfigPath(ctx: InstallContext): string {\n return this.getHookConfigPath(ctx);\n }\n\n /**\n * Hook registration lives in the workspace-discovered .github/hooks tree, which\n * JetBrains Copilot scans for *.json hook files. We write one file per connector\n * so installs/uninstalls never clobber another connector's hooks. Anchored on\n * projectDir for both scopes — .github/hooks is a workspace concept (there is no\n * user-profile equivalent in the Copilot hooks schema).\n */\n getHookConfigPath(ctx: InstallContext): string {\n return join(ctx.projectDir, \".github\", \"hooks\", `${ctx.connector.id}.json`);\n }\n\n // ── MCP server install / uninstall ───────────────────────────────────────\n\n /**\n * JetBrains MCP registration is UI-only. We never write a file: a bogus file is\n * ignored at best and corrupts real UI-managed state at worst. Emit a \"warn\"\n * ChangeRecord that tells the user exactly where to add the server by hand.\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 jetbrains-copilot\"\n : \"connector declares no MCP server\",\n },\n ];\n }\n\n return [\n {\n platform: this.id,\n action: \"warn\",\n detail:\n `JetBrains Copilot manages MCP servers via the IDE Settings UI — ` +\n `add \"${connector.id}\" manually under Settings > Tools > GitHub Copilot ` +\n `> MCP > Configure (no file is written here).`,\n },\n ];\n }\n\n /**\n * Nothing was written for the MCP server, so there is nothing to remove. Mirror\n * the install-time guidance as a \"warn\" so an uninstall report is honest about\n * the UI-managed entry the user may still want to remove by hand.\n */\n uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (!connector.server || connector.platforms[HOST]?.server === false) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: \"no MCP server was registered for jetbrains-copilot\",\n },\n ];\n }\n return [\n {\n platform: this.id,\n action: \"warn\",\n detail:\n `JetBrains Copilot MCP servers are UI-managed — if \"${connector.id}\" was ` +\n `added manually, remove it under Settings > Tools > GitHub Copilot > MCP.`,\n },\n ];\n }\n\n // ── Hook install / uninstall ─────────────────────────────────────────────\n\n installHooks(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n const override = connector.platforms[HOST];\n const hooksDisabled = override?.hooks === false;\n // `hooks: false` disables only the NORMALIZED events; nativeHooks is a\n // sibling, jetbrains-copilot-scoped declaration that installs regardless.\n const normalizedEvents = hooksDisabled ? [] : connector.hookEvents;\n const nativeHooks = override?.nativeHooks ?? {};\n const nativeEvents = Object.keys(nativeHooks);\n\n if (normalizedEvents.length === 0 && nativeEvents.length === 0) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: hooksDisabled\n ? \"hooks disabled for jetbrains-copilot\"\n : \"connector declares no hooks\",\n },\n ];\n }\n\n const hooksPath = this.getHookConfigPath(ctx);\n const symlink = this.symlinkPathWarning(hooksPath);\n if (symlink) return [symlink];\n\n const file = this.readJson<JetBrainsHooksFile>(hooksPath) ?? {};\n const __skip = this.malformedHookRootSkip(hooksPath, (file as Record<string, unknown>).hooks);\n if (__skip) return [__skip];\n const hooks = (file.hooks ??= {});\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n for (const event of normalizedEvents) {\n const jetbrainsEvent = EVENT_MAP[event];\n if (!jetbrainsEvent) {\n // No JetBrains Copilot equivalent for this normalized event — report+skip.\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: hooksPath,\n detail: `${event} has no JetBrains Copilot hook equivalent — skipped`,\n });\n continue;\n }\n\n const command = buildHomeBinHookCommand(ctx.homeBinPath, HOST, event, connector.id);\n // Matchers are IGNORED by JetBrains (all hooks fire on all tools), so we omit\n // the matcher entirely — a flat { type, command } entry.\n const entry: JetBrainsHookEntry = { type: \"command\", command };\n\n const bucket = (hooks[jetbrainsEvent] ??= []);\n const existingIdx = bucket.findIndex((e) => this.isOurCommand(e.command, ctx));\n\n if (existingIdx >= 0) {\n if (JSON.stringify(bucket[existingIdx]) === JSON.stringify(entry)) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: hooksPath,\n detail: `hooks.${jetbrainsEvent} already registered`,\n });\n continue;\n }\n bucket[existingIdx] = entry;\n changes.push({\n platform: this.id,\n action: \"update\",\n path: hooksPath,\n detail: `hooks.${jetbrainsEvent}`,\n });\n } else {\n bucket.push(entry);\n changes.push({\n platform: this.id,\n action: \"create\",\n path: hooksPath,\n detail: `hooks.${jetbrainsEvent}`,\n });\n }\n mutated = true;\n }\n\n // NATIVE passthrough events: jetbrains-copilot-native event-name keys (e.g.\n // ErrorOccurred) filed VERBATIM into the hooks map — no EVENT_MAP, since they\n // ARE Copilot events. Flat { type, command } entry (matchers are ignored);\n // matched by EXACT command so a native key coinciding with a normalized one\n // never clobbers it.\n for (const nativeEvent of nativeEvents) {\n const command = buildHomeBinHookCommand(ctx.homeBinPath, HOST, nativeEvent, connector.id);\n const entry: JetBrainsHookEntry = { type: \"command\", command };\n const bucket = (hooks[nativeEvent] ??= []);\n const existingIdx = bucket.findIndex((e) => e.command === command);\n if (existingIdx >= 0) {\n if (JSON.stringify(bucket[existingIdx]) === JSON.stringify(entry)) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: hooksPath,\n detail: `hooks.${nativeEvent} (native) already registered`,\n });\n continue;\n }\n bucket[existingIdx] = entry;\n changes.push({\n platform: this.id,\n action: \"update\",\n path: hooksPath,\n detail: `hooks.${nativeEvent} (native)`,\n });\n } else {\n bucket.push(entry);\n changes.push({\n platform: this.id,\n action: \"create\",\n path: hooksPath,\n detail: `hooks.${nativeEvent} (native)`,\n });\n }\n mutated = true;\n }\n\n if (mutated) {\n // The top-level version is REQUIRED — a version-less file is rejected and\n // no hooks fire. Always (re)assert it when we write.\n file.version = JETBRAINS_HOOKS_VERSION;\n this.writeJson(hooksPath, file, ctx.dryRun);\n }\n return changes;\n }\n\n uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n const hooksPath = this.getHookConfigPath(ctx);\n const symlink = this.symlinkPathWarning(hooksPath);\n if (symlink) return [symlink];\n\n const file = this.readJson<JetBrainsHooksFile>(hooksPath);\n const hooks = file?.hooks;\n if (!file || !hooks) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: hooksPath,\n detail: \"no hooks section present\",\n },\n ];\n }\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n for (const jetbrainsEvent of Object.keys(hooks)) {\n const bucket = hooks[jetbrainsEvent];\n if (!Array.isArray(bucket)) continue;\n\n const before = bucket.length;\n // Only strip OUR connector's home-bin commands — never another connector's\n // (isHomeBinHookCommand is id-anchored against a shared-prefix collision).\n const next = bucket.filter((e) => !this.isOurCommand(e.command, ctx));\n const removed = before - next.length;\n if (removed > 0) {\n if (next.length > 0) hooks[jetbrainsEvent] = next;\n else delete hooks[jetbrainsEvent];\n changes.push({\n platform: this.id,\n action: \"remove\",\n path: hooksPath,\n detail: `hooks.${jetbrainsEvent} (${removed})`,\n });\n mutated = true;\n }\n }\n\n if (mutated) {\n // The hooks file is connector-OWNED (<connector-id>.json), so when our\n // strip leaves it with NO hooks we must DELETE the whole file rather than\n // rewrite a `{ \"hooks\": {}, \"version\": 1 }` shell — an empty shell is an\n // orphan per-connector file that lingers after uninstall. A non-empty\n // result still belongs to us, so we rewrite it as before. dryRun reports\n // the would-be remove without mutating the filesystem.\n if (Object.keys(hooks).length === 0) {\n changes.push(\n this.removeManagedFile(\n hooksPath,\n ctx.dryRun,\n \"removed empty connector hooks file\",\n \"no hooks file present\",\n ),\n );\n // Clean up the parent .github/hooks dir only when it is now empty (it is\n // a per-connector tree; leave it in place if other connectors' files\n // remain).\n changes.push(this.removeDirIfEmpty(dirname(hooksPath), ctx.dryRun));\n } else {\n this.writeJson(hooksPath, file, ctx.dryRun);\n }\n }\n if (changes.length === 0) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: hooksPath,\n detail: \"no matching hook entries\",\n });\n }\n return changes;\n }\n\n /** 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 // ── Content surfaces: commands / skills ──────────────────────────────────\n // CONTENT-ONLY: pure native-file writers under the workspace .github/ tree\n // ({prompts,skills}). No runtime dispatch, no home-bin pointer, no telemetry\n // wrap. Each method is idempotent (byte-identical → skip) via\n // BaseAdapter.writeContentFile and reversible via removeContentFile. Honors\n // platforms[\"jetbrains-copilot\"] per-surface false to skip.\n //\n // ALIAS of vscode-copilot: JetBrains consumes the GitHub Copilot .github/\n // files and has no distinct authoring location, so the rendered content +\n // paths here are IDENTICAL to the vscode-copilot writer.\n //\n // SHARED .github TREE: vscode-copilot, copilot-cli, and jetbrains-copilot all\n // write under the SAME project <projectDir>/.github tree. The rendered content\n // is identical and idempotent across those connectors, and uninstall here only\n // removes the files THIS connector declared — never another writer's files.\n //\n // SCOPE NOTE: .github is a workspace concept and this adapter is project-\n // scoped (no user-profile .github authoring location exists in the Copilot\n // prompt/skill discovery), so the content root is always the project .github\n // tree — the same dir getConfigDir already anchors on.\n\n /** Root of the content tree — the project .github tree (see getConfigDir). */\n private contentRootDir(ctx: InstallContext): string {\n return this.getConfigDir(ctx);\n }\n\n private promptsDir(ctx: InstallContext): string {\n return join(this.contentRootDir(ctx), \"prompts\");\n }\n private skillsDir(ctx: InstallContext): string {\n return join(this.contentRootDir(ctx), \"skills\");\n }\n\n /** Native command file path: <ghDir>/prompts/<name>.prompt.md. */\n private commandPath(ctx: InstallContext, name: string): string {\n return join(this.promptsDir(ctx), `${name}.prompt.md`);\n }\n /** Native skill dir: <ghDir>/skills/<name>. */\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.skillsDir(ctx), name);\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 jetbrains-copilot\" }];\n }\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.writeContentFile(\n this.commandPath(ctx, cmd.name),\n this.renderCommand(cmd),\n ctx.dryRun,\n ),\n );\n }\n\n override uninstallCommands(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.commands.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no commands\" }];\n }\n return connector.commands.map((cmd) =>\n this.removeContentFile(this.commandPath(ctx, cmd.name), ctx.dryRun),\n );\n }\n\n /** Render a Copilot prompt file: md+frontmatter(description, tools, model, argument-hint). */\n private renderCommand(cmd: CommandDef): string {\n const frontmatter: Record<string, unknown> = {};\n if (cmd.description !== undefined) frontmatter.description = cmd.description;\n // Copilot prompt files express tool access as a `tools` array, sourced from\n // the portable tools.allow policy.\n const allow = cmd.tools?.allow;\n if (allow && allow.length > 0) frontmatter.tools = [...allow];\n if (cmd.model !== undefined) frontmatter.model = cmd.model;\n if (cmd.argumentHint !== undefined) frontmatter[\"argument-hint\"] = cmd.argumentHint;\n if (cmd.extra) Object.assign(frontmatter, cmd.extra);\n return this.renderFrontmatterMd(frontmatter, cmd.prompt);\n }\n\n // ── Skills ────────────────────────────────────────────────────────────────\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 jetbrains-copilot\" }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n changes.push(\n this.writeContentFile(join(dir, \"SKILL.md\"), renderSkillMd(skill), ctx.dryRun),\n );\n // Bundle any resource files beside SKILL.md (relative path → contents).\n // Defense-in-depth: skip+warn on any key that escapes the skill dir\n // (config-time validation already rejects these, but never trust input).\n for (const [rel, contents] of Object.entries(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `skill resource \"${rel}\" escapes the skill dir; skipped`,\n });\n continue;\n }\n changes.push(this.writeContentFile(target, contents, ctx.dryRun));\n }\n }\n return changes;\n }\n\n override uninstallSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n // Remove only the files we wrote (SKILL.md + declared resources), then the\n // skill dir itself when we own its full contents.\n changes.push(this.removeContentFile(join(dir, \"SKILL.md\"), ctx.dryRun));\n for (const rel of Object.keys(skill.resources ?? {})) {\n const target = this.resolveWithin(dir, rel);\n if (target === null) continue; // never delete outside the skill dir\n changes.push(this.removeContentFile(target, ctx.dryRun));\n }\n // Only remove the skill dir when WE own its full contents — never rm -rf a\n // dir that still holds user-added / sibling-tool / shared files.\n changes.push(this.removeDirIfEmpty(dir, ctx.dryRun));\n }\n return changes;\n }\n\n // ── Diagnostics ──────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const hooksPath = this.getHookConfigPath(ctx);\n const connectorId = ctx.connector.id;\n const homeBin = ctx.homeBinPath;\n const hookEvents = ctx.connector.hookEvents;\n const hasServer =\n ctx.connector.server != null &&\n ctx.connector.platforms[HOST]?.server !== false;\n const checks: HealthCheck[] = [\n {\n // MCP cannot be verified from disk — JetBrains owns it behind the UI.\n // BaseAdapter.doctor maps != OK to a hard FAIL, but an unverifiable\n // UI-managed surface must NOT hard-fail doctor (that contradicts the\n // install-time WARN). Return OK with a verify-in-UI detail instead.\n name: `${this.name}: MCP server (UI-managed)`,\n check: () =>\n hasServer\n ? {\n status: \"OK\",\n detail:\n \"MCP is UI-managed — verify in Settings > Tools > GitHub Copilot > MCP\",\n }\n : { status: \"OK\", detail: \"connector declares no MCP server\" },\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 file = this.readJson<JetBrainsHooksFile>(hooksPath);\n if (!file) return { status: \"FAIL\", detail: `not found: ${hooksPath}` };\n if (file.version !== JETBRAINS_HOOKS_VERSION) {\n return {\n status: \"FAIL\",\n detail: `${hooksPath} missing required \"version\": ${JETBRAINS_HOOKS_VERSION} — Copilot rejects it`,\n };\n }\n const registered = Object.values(file.hooks ?? {}).some((entries) =>\n (entries ?? []).some((e) =>\n isHomeBinHookCommand(e.command, homeBin, connectorId),\n ),\n );\n return registered\n ? { status: \"OK\", detail: \"hook command present\" }\n : { status: \"FAIL\", detail: `no hook for ${connectorId} in ${hooksPath}` };\n },\n },\n ];\n\n // Content-surface checks: only assert presence of the files this connector\n // declares (skip silently for surfaces it never asked for). Subagents are\n // unsupported here, so they are never checked.\n for (const cmd of ctx.connector.commands) {\n const p = this.commandPath(ctx, cmd.name);\n checks.push({\n name: `${this.name}: command ${cmd.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n for (const skill of ctx.connector.skills) {\n const p = join(this.skillDir(ctx, skill.name), \"SKILL.md\");\n checks.push({\n name: `${this.name}: skill ${skill.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n return checks;\n }\n\n // ── Runtime: parse JetBrains Copilot stdin JSON → normalized event ────────\n\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as JetBrainsWireInput;\n const connectorId = typeof input.connector === \"string\" ? input.connector : \"\";\n const sessionId = extractSessionId(input);\n const projectDir = this.getProjectDir(input);\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 toolOutput =\n toolResponseToString(input.tool_response) ??\n input.tool_output ??\n input.error_message;\n const ev: PostToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n ...(toolOutput !== undefined ? { toolOutput } : {}),\n ...(input.error_message ? { isError: true } : {}),\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 // JetBrains Copilot does not fire PostCompact natively (postCompact\n // unset → warn-skip at install). Parsed defensively, mirroring\n // PreCompact, so a manual/mis-routed dispatch normalizes instead of\n // hitting the guard.\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 \"SessionStart\": {\n const ev: SessionStartEvent = {\n ...base,\n source: normalizeSessionSource(input.source ?? input.trigger),\n };\n return ev;\n }\n case \"SessionEnd\": {\n const ev: SessionEndEvent = {\n ...base,\n ...(typeof input.reason === \"string\" ? { reason: input.reason } : {}),\n };\n return ev;\n }\n case \"UserPromptSubmit\": {\n const ev: UserPromptSubmitEvent = {\n ...base,\n prompt: typeof input.prompt === \"string\" ? input.prompt : \"\",\n };\n return ev;\n }\n case \"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 case \"PostToolUseFailure\":\n case \"SubagentStart\":\n case \"SubagentStop\": {\n // No JetBrains Copilot analog — its Preview hooks runtime documents no\n // permission-dialog, tool-failure, or subagent lifecycle events.\n // Install already skip-warns these via EVENT_MAP; a runtime dispatch is\n // a mis-route — fail loudly.\n throw new Error(`unsupported jetbrains-copilot hook event: ${String(event)}`);\n }\n default: {\n // Exhaustive guard — every HookEventName is handled above. (JetBrains only\n // delivers the four it declares; the rest are handled defensively so a\n // mis-dispatch stays inert rather than crashing.)\n const _never: never = event;\n throw new Error(`unsupported jetbrains-copilot hook event: ${String(_never)}`);\n }\n }\n }\n\n /** Resolve the project dir from the wire payload, preferring the explicit cwd. */\n private getProjectDir(input: JetBrainsWireInput): string | undefined {\n return input.cwd ?? input.workspace_roots?.[0] ?? undefined;\n }\n\n // ── Runtime: normalized response → JetBrains Copilot native hook reply ────\n\n formatReply(event: HookEventName, response: HookResponse): HookReply {\n const hookEventName = event;\n const decision = response.decision ?? \"allow\";\n\n // deny → block the action with a reason (exit 0; JSON carries the decision).\n // JetBrains Copilot's reply is Claude-compatible, identical to vscode-copilot:\n // `hookSpecificOutput.permissionDecision` is read ONLY for the pre-execution\n // PreToolUse permission event. The post-execution / turn-control events —\n // PostToolUse, UserPromptSubmit, Stop, SubagentStop — block via the TOP-LEVEL\n // {\"decision\":\"block\",\"reason\"} instead (PostToolUse runs AFTER the tool, so a\n // permissionDecision there is silently ignored). Mirrors vscode-copilot #56/#58.\n if (decision === \"deny\") {\n if (\n event === \"PostToolUse\" ||\n event === \"UserPromptSubmit\" ||\n event === \"Stop\" ||\n event === \"SubagentStop\"\n ) {\n return this.stdout({\n decision: \"block\",\n reason: response.reason ?? \"Blocked by hook\",\n });\n }\n return this.stdout({\n hookSpecificOutput: {\n hookEventName,\n permissionDecision: \"deny\",\n permissionDecisionReason: response.reason ?? \"Blocked by hook\",\n },\n });\n }\n\n // ask → prompt the user to confirm.\n if (decision === \"ask\") {\n return this.stdout({\n hookSpecificOutput: {\n hookEventName,\n permissionDecision: \"ask\",\n permissionDecisionReason:\n response.reason ?? \"Confirmation required by hook\",\n },\n });\n }\n\n // modify → unsupported on JetBrains (canModifyArgs:false): a PreToolUse hook\n // cannot rewrite tool input here, so degrade to allow rather than emit an\n // updatedInput the host will ignore.\n\n // context → inject soft guidance (also the SessionStart context path).\n if (decision === \"context\" && response.additionalContext) {\n return this.stdout({\n hookSpecificOutput: { hookEventName, additionalContext: response.additionalContext },\n });\n }\n\n // allow / void / modify-degradation / unsupported → pass through with exit 0.\n return { exitCode: 0 };\n }\n\n private stdout(payload: unknown): HookReply {\n return { exitCode: 0, stdout: JSON.stringify(payload) };\n }\n}\n\n/**\n * Extract a stable session id from a JetBrains Copilot wire payload. Priority\n * mirrors the Claude-compatible wire: transcript UUID > session_id > \"\" (the\n * framework uses \"\" when no id is available — no ppid fabrication here).\n */\nfunction extractSessionId(input: JetBrainsWireInput): string {\n if (typeof input.transcript_path === \"string\") {\n const m = input.transcript_path.match(/([a-f0-9-]{36})\\.jsonl$/);\n if (m && m[1]) return m[1];\n }\n if (typeof input.session_id === \"string\" && input.session_id !== \"\") {\n return input.session_id;\n }\n return \"\";\n}\n\n/** Coerce a Claude-compatible PostToolUse `tool_response` into a string. */\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 JetBrainsCopilotAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,SAAS,kBAAkB;AAC3B,SAAS,SAAS,YAAY;AA+B9B,IAAM,OAAmB;AAGzB,IAAM,0BAA0B;AAQhC,IAAM,YAAoD;AAAA,EACxD,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,kBAAkB;AACpB;AA8CO,IAAM,0BAAN,cAAsC,YAA+B;AAAA,EACjE,KAAiB;AAAA,EACjB,OAAO;AAAA,EACP,WAAyB;AAAA,EAEzB,eAAqC;AAAA;AAAA;AAAA,IAG5C,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOhB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,MAAM;AAAA,IACN,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOd,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA,IAKzB,YAAY,CAAC,SAAS,QAAQ,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMnC,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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MAAM;AAAA,EACf;AACA,SAAO;AACT;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,wBAAwB;AACnD,IAAO,4BAAQ;","names":[]}
|
|
@@ -12,24 +12,17 @@ import {
|
|
|
12
12
|
BaseAdapter,
|
|
13
13
|
renderOpenCodeSubagentMd,
|
|
14
14
|
renderSkillMd
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-GI4FDVWI.js";
|
|
16
16
|
import {
|
|
17
17
|
buildWrappedStdio
|
|
18
18
|
} from "./chunk-TO57WYBB.js";
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-LBOGRZGY.js";
|
|
20
|
+
import "./chunk-D65GIBCG.js";
|
|
21
21
|
|
|
22
22
|
// src/adapters/kilo/index.ts
|
|
23
|
-
import {
|
|
24
|
-
chmodSync,
|
|
25
|
-
existsSync,
|
|
26
|
-
mkdirSync,
|
|
27
|
-
readFileSync,
|
|
28
|
-
rmSync,
|
|
29
|
-
writeFileSync
|
|
30
|
-
} from "fs";
|
|
23
|
+
import { existsSync } from "fs";
|
|
31
24
|
import { homedir, platform as osPlatform } from "os";
|
|
32
|
-
import {
|
|
25
|
+
import { join } from "path";
|
|
33
26
|
var HOST = "kilo";
|
|
34
27
|
var MCP_ROOT_KEY = "mcp";
|
|
35
28
|
var PLUGIN_ARRAY_KEY = "plugin";
|
|
@@ -260,22 +253,15 @@ var KiloAdapter = class extends BaseAdapter {
|
|
|
260
253
|
}
|
|
261
254
|
const changes = [];
|
|
262
255
|
for (const file of this.synthesizePlugin(ctx)) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
changes.push({
|
|
274
|
-
platform: this.id,
|
|
275
|
-
action,
|
|
276
|
-
path: file.path,
|
|
277
|
-
detail: `kilo plugin module (${this.hookDetail(ctx)})`
|
|
278
|
-
});
|
|
256
|
+
changes.push(
|
|
257
|
+
this.writeManagedFile(
|
|
258
|
+
file.path,
|
|
259
|
+
file.contents,
|
|
260
|
+
ctx.dryRun,
|
|
261
|
+
`kilo plugin module (${this.hookDetail(ctx)})`,
|
|
262
|
+
file.executable
|
|
263
|
+
)
|
|
264
|
+
);
|
|
279
265
|
}
|
|
280
266
|
changes.push(this.upsertPluginInArray(configPath, pluginPath, ctx.dryRun));
|
|
281
267
|
return changes;
|
|
@@ -297,22 +283,9 @@ var KiloAdapter = class extends BaseAdapter {
|
|
|
297
283
|
const configPath = this.getServerConfigPath(ctx);
|
|
298
284
|
const changes = [];
|
|
299
285
|
changes.push(this.removePluginFromArray(configPath, pluginPath, ctx.dryRun));
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
platform: this.id,
|
|
304
|
-
action: "remove",
|
|
305
|
-
path: pluginPath,
|
|
306
|
-
detail: "kilo plugin module"
|
|
307
|
-
});
|
|
308
|
-
} else {
|
|
309
|
-
changes.push({
|
|
310
|
-
platform: this.id,
|
|
311
|
-
action: "skip",
|
|
312
|
-
path: pluginPath,
|
|
313
|
-
detail: "no kilo plugin module present"
|
|
314
|
-
});
|
|
315
|
-
}
|
|
286
|
+
changes.push(
|
|
287
|
+
this.removeManagedFile(pluginPath, ctx.dryRun, "kilo plugin module", "no kilo plugin module present")
|
|
288
|
+
);
|
|
316
289
|
changes.push(this.removeDirIfEmpty(this.pluginDir(ctx), ctx.dryRun));
|
|
317
290
|
return changes;
|
|
318
291
|
}
|
|
@@ -861,17 +834,7 @@ export default plugin;
|
|
|
861
834
|
return checks;
|
|
862
835
|
}
|
|
863
836
|
/** Read a file, returning undefined on any error (idempotency compare). */
|
|
864
|
-
safeRead(path) {
|
|
865
|
-
try {
|
|
866
|
-
return readFileSync(path, "utf8");
|
|
867
|
-
} catch {
|
|
868
|
-
return void 0;
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
837
|
};
|
|
872
|
-
function ensureDir(dir) {
|
|
873
|
-
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
874
|
-
}
|
|
875
838
|
var adapter = new KiloAdapter();
|
|
876
839
|
var kilo_default = adapter;
|
|
877
840
|
export {
|
|
@@ -879,4 +842,4 @@ export {
|
|
|
879
842
|
adapter,
|
|
880
843
|
kilo_default as default
|
|
881
844
|
};
|
|
882
|
-
//# sourceMappingURL=kilo-
|
|
845
|
+
//# sourceMappingURL=kilo-WLZOYKZK.js.map
|