@ken-jo/agent-connector 0.4.7 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/dist/{action-YCU53FNE.js → action-RWPRIZIC.js} +10 -10
  2. package/dist/{amazon-q-W574ZX35.js → amazon-q-5LJOB5L3.js} +6 -18
  3. package/dist/amazon-q-5LJOB5L3.js.map +1 -0
  4. package/dist/{amp-JPBQJJVM.js → amp-PU4LFSY6.js} +16 -48
  5. package/dist/amp-PU4LFSY6.js.map +1 -0
  6. package/dist/{antigravity-VK2Y3FGV.js → antigravity-DWW35HZO.js} +6 -5
  7. package/dist/{antigravity-cli-D4PCCUG2.js → antigravity-cli-VTQ6DNWL.js} +6 -5
  8. package/dist/{antigravity-cli-D4PCCUG2.js.map → antigravity-cli-VTQ6DNWL.js.map} +1 -1
  9. package/dist/{chunk-F5RX62T7.js → chunk-7QRUZAUG.js} +2 -2
  10. package/dist/{chunk-G5CQHVQG.js → chunk-7TVBFRVI.js} +12 -15
  11. package/dist/chunk-7TVBFRVI.js.map +1 -0
  12. package/dist/{chunk-CYOAH23F.js → chunk-A2T4Q7RM.js} +18 -18
  13. package/dist/{chunk-7ECYDK5T.js → chunk-CDVOBKSG.js} +4 -4
  14. package/dist/{chunk-DT6Y7XBI.js → chunk-CENEXP7K.js} +9 -38
  15. package/dist/chunk-CENEXP7K.js.map +1 -0
  16. package/dist/chunk-FBJQGRET.js +38 -0
  17. package/dist/chunk-FBJQGRET.js.map +1 -0
  18. package/dist/{chunk-WZA4CSGJ.js → chunk-H53QZQJI.js} +15 -2
  19. package/dist/chunk-H53QZQJI.js.map +1 -0
  20. package/dist/{chunk-MDNX7HTN.js → chunk-HOE2MN36.js} +2 -2
  21. package/dist/{chunk-7L6ITC4T.js → chunk-IEGR4TP3.js} +22 -6
  22. package/dist/chunk-IEGR4TP3.js.map +1 -0
  23. package/dist/{chunk-PFDUGDOA.js → chunk-KG6T3YNJ.js} +3 -3
  24. package/dist/{chunk-YQLQJZ7S.js → chunk-MOW2RKHX.js} +2 -2
  25. package/dist/{chunk-SDPIT4HW.js → chunk-NYR55UT7.js} +2 -2
  26. package/dist/{chunk-WFXWJITA.js → chunk-OZ5EXXQV.js} +2 -2
  27. package/dist/{chunk-I5MLE6S7.js → chunk-TO57WYBB.js} +15 -1
  28. package/dist/chunk-TO57WYBB.js.map +1 -0
  29. package/dist/chunk-UM5S7DKK.js +33 -0
  30. package/dist/chunk-UM5S7DKK.js.map +1 -0
  31. package/dist/{chunk-6RYPUR6O.js → chunk-VRKTVCYJ.js} +7 -7
  32. package/dist/{chunk-HAIMYUEY.js → chunk-WI6YSXOC.js} +3 -3
  33. package/dist/{chunk-2F5QH3D4.js → chunk-XQUUNAGC.js} +36 -36
  34. package/dist/{chunk-TZQBASI7.js → chunk-YS2NYJ6R.js} +13 -49
  35. package/dist/chunk-YS2NYJ6R.js.map +1 -0
  36. package/dist/{chunk-SPWFUHHK.js → chunk-YYISBXOM.js} +7 -7
  37. package/dist/{claude-code-ROSIILTM.js → claude-code-64X6RR2S.js} +15 -38
  38. package/dist/claude-code-64X6RR2S.js.map +1 -0
  39. package/dist/cli/sdk.js +4 -4
  40. package/dist/cli.js +1 -1
  41. package/dist/{cline-JUTO4V27.js → cline-T7ZDJYZQ.js} +15 -47
  42. package/dist/cline-T7ZDJYZQ.js.map +1 -0
  43. package/dist/{codebuff-2QUHL6HO.js → codebuff-PPPY3SJV.js} +9 -40
  44. package/dist/codebuff-PPPY3SJV.js.map +1 -0
  45. package/dist/{codex-YBBTIDD4.js → codex-EEVN43C2.js} +26 -62
  46. package/dist/codex-EEVN43C2.js.map +1 -0
  47. package/dist/{continue-W4TU4JSB.js → continue-VLLZO4PM.js} +9 -32
  48. package/dist/continue-VLLZO4PM.js.map +1 -0
  49. package/dist/{copilot-cli-Y74SOP5G.js → copilot-cli-A7G5WB4N.js} +15 -64
  50. package/dist/copilot-cli-A7G5WB4N.js.map +1 -0
  51. package/dist/{crush-GMEWLXK5.js → crush-AH24GDDB.js} +15 -42
  52. package/dist/crush-AH24GDDB.js.map +1 -0
  53. package/dist/{cursor-JBS4B3Q4.js → cursor-GJBSMXI6.js} +13 -51
  54. package/dist/cursor-GJBSMXI6.js.map +1 -0
  55. package/dist/{detect-2NIXILMZ.js → detect-YDCZNV4W.js} +4 -4
  56. package/dist/{doctor-QWJBWALA.js → doctor-DGC7P3P7.js} +13 -12
  57. package/dist/{doctor-QWJBWALA.js.map → doctor-DGC7P3P7.js.map} +1 -1
  58. package/dist/{droid-TJMTNCQE.js → droid-RBWCFKL3.js} +17 -40
  59. package/dist/droid-RBWCFKL3.js.map +1 -0
  60. package/dist/{gemini-cli-RAONGZRG.js → gemini-cli-CFPFEJEA.js} +15 -63
  61. package/dist/gemini-cli-CFPFEJEA.js.map +1 -0
  62. package/dist/{goose-G4KKM6YU.js → goose-UBJVQFUE.js} +18 -54
  63. package/dist/goose-UBJVQFUE.js.map +1 -0
  64. package/dist/{hermes-PJDTJE6F.js → hermes-6FXGXLNL.js} +14 -52
  65. package/dist/hermes-6FXGXLNL.js.map +1 -0
  66. package/dist/{hook-FDGIQPRC.js → hook-CDGSCASQ.js} +10 -10
  67. package/dist/index.js +2 -2
  68. package/dist/{install-TLG3QVP3.js → install-2D3UKEME.js} +13 -12
  69. package/dist/{install-TLG3QVP3.js.map → install-2D3UKEME.js.map} +1 -1
  70. package/dist/{jetbrains-copilot-DNXSLQE5.js → jetbrains-copilot-K26KMA3U.js} +10 -37
  71. package/dist/jetbrains-copilot-K26KMA3U.js.map +1 -0
  72. package/dist/{kilo-FERJ3X46.js → kilo-BKZJ26RM.js} +26 -90
  73. package/dist/kilo-BKZJ26RM.js.map +1 -0
  74. package/dist/{kilo-cli-TDCONH5G.js → kilo-cli-6UVWCXQD.js} +17 -48
  75. package/dist/kilo-cli-6UVWCXQD.js.map +1 -0
  76. package/dist/{kimi-RIRD4J5J.js → kimi-QALYPSRR.js} +10 -31
  77. package/dist/kimi-QALYPSRR.js.map +1 -0
  78. package/dist/{kiro-X7JVLAN7.js → kiro-J5J42I5Z.js} +10 -31
  79. package/dist/kiro-J5J42I5Z.js.map +1 -0
  80. package/dist/{leaderboard-MXGENYXN.js → leaderboard-VZQXNWTX.js} +2 -2
  81. package/dist/{mimo-code-RFLQ727H.js → mimo-code-BEE622P2.js} +22 -87
  82. package/dist/mimo-code-BEE622P2.js.map +1 -0
  83. package/dist/{mux-D77HBSBU.js → mux-5HTNKK4K.js} +9 -39
  84. package/dist/mux-5HTNKK4K.js.map +1 -0
  85. package/dist/{nemoclaw-LXUTMR56.js → nemoclaw-DNFIZFDF.js} +5 -5
  86. package/dist/{omp-CO7IXURG.js → omp-I3UTRBNP.js} +16 -48
  87. package/dist/omp-I3UTRBNP.js.map +1 -0
  88. package/dist/{openclaw-XWJLEW35.js → openclaw-QE2LMWIF.js} +5 -5
  89. package/dist/{opencode-QKZ5EIYU.js → opencode-ZFSUYJXI.js} +22 -88
  90. package/dist/opencode-ZFSUYJXI.js.map +1 -0
  91. package/dist/{package-IA56LSC3.js → package-BSCCMW4E.js} +8 -8
  92. package/dist/{pi-YGBXYWY5.js → pi-H2KBBDDJ.js} +4 -4
  93. package/dist/{qwen-code-E2MSEZK6.js → qwen-code-5LE34FNE.js} +10 -31
  94. package/dist/qwen-code-5LE34FNE.js.map +1 -0
  95. package/dist/{roo-code-AGGJ473T.js → roo-code-XH4GCYIS.js} +15 -52
  96. package/dist/roo-code-XH4GCYIS.js.map +1 -0
  97. package/dist/runtime/index.js +8 -8
  98. package/dist/sdk/index.js +3 -3
  99. package/dist/sdk/test.js +5 -5
  100. package/dist/{serve-RNUCK5F7.js → serve-MQNGPY2H.js} +10 -10
  101. package/dist/{status-JOX6RLJU.js → status-MRHVRDFY.js} +8 -7
  102. package/dist/{status-JOX6RLJU.js.map → status-MRHVRDFY.js.map} +1 -1
  103. package/dist/{statusline-ZVFI5DRT.js → statusline-IYWA75TR.js} +9 -9
  104. package/dist/{telemetry-3FN6HDVU.js → telemetry-IONIOMLC.js} +5 -5
  105. package/dist/{trae-6L226ZDU.js → trae-RVNRSV7X.js} +10 -39
  106. package/dist/trae-RVNRSV7X.js.map +1 -0
  107. package/dist/{uninstall-SCKZYB4J.js → uninstall-ESLSVCLE.js} +13 -12
  108. package/dist/{uninstall-SCKZYB4J.js.map → uninstall-ESLSVCLE.js.map} +1 -1
  109. package/dist/{upgrade-WU3KZWR4.js → upgrade-VICY5T64.js} +13 -12
  110. package/dist/{upgrade-WU3KZWR4.js.map → upgrade-VICY5T64.js.map} +1 -1
  111. package/dist/{usage-G72SF7JG.js → usage-TCUWV2YZ.js} +2 -2
  112. package/dist/{usage-event-DHSEBO5T.js → usage-event-CBZZP37Q.js} +9 -9
  113. package/dist/{vscode-copilot-6EOZDLXC.js → vscode-copilot-B2QBBHJW.js} +15 -65
  114. package/dist/vscode-copilot-B2QBBHJW.js.map +1 -0
  115. package/dist/{warp-N5YYN5BF.js → warp-5R54ST3N.js} +7 -19
  116. package/dist/warp-5R54ST3N.js.map +1 -0
  117. package/dist/{windsurf-4TGSJIVV.js → windsurf-L32UEOLY.js} +6 -18
  118. package/dist/windsurf-L32UEOLY.js.map +1 -0
  119. package/dist/{zed-6P2UFWXU.js → zed-FDJHJZKD.js} +11 -21
  120. package/dist/zed-FDJHJZKD.js.map +1 -0
  121. package/package.json +1 -1
  122. package/dist/amazon-q-W574ZX35.js.map +0 -1
  123. package/dist/amp-JPBQJJVM.js.map +0 -1
  124. package/dist/chunk-7L6ITC4T.js.map +0 -1
  125. package/dist/chunk-DT6Y7XBI.js.map +0 -1
  126. package/dist/chunk-G5CQHVQG.js.map +0 -1
  127. package/dist/chunk-I5MLE6S7.js.map +0 -1
  128. package/dist/chunk-TZQBASI7.js.map +0 -1
  129. package/dist/chunk-WZA4CSGJ.js.map +0 -1
  130. package/dist/claude-code-ROSIILTM.js.map +0 -1
  131. package/dist/cline-JUTO4V27.js.map +0 -1
  132. package/dist/codebuff-2QUHL6HO.js.map +0 -1
  133. package/dist/codex-YBBTIDD4.js.map +0 -1
  134. package/dist/continue-W4TU4JSB.js.map +0 -1
  135. package/dist/copilot-cli-Y74SOP5G.js.map +0 -1
  136. package/dist/crush-GMEWLXK5.js.map +0 -1
  137. package/dist/cursor-JBS4B3Q4.js.map +0 -1
  138. package/dist/droid-TJMTNCQE.js.map +0 -1
  139. package/dist/gemini-cli-RAONGZRG.js.map +0 -1
  140. package/dist/goose-G4KKM6YU.js.map +0 -1
  141. package/dist/hermes-PJDTJE6F.js.map +0 -1
  142. package/dist/jetbrains-copilot-DNXSLQE5.js.map +0 -1
  143. package/dist/kilo-FERJ3X46.js.map +0 -1
  144. package/dist/kilo-cli-TDCONH5G.js.map +0 -1
  145. package/dist/kimi-RIRD4J5J.js.map +0 -1
  146. package/dist/kiro-X7JVLAN7.js.map +0 -1
  147. package/dist/mimo-code-RFLQ727H.js.map +0 -1
  148. package/dist/mux-D77HBSBU.js.map +0 -1
  149. package/dist/omp-CO7IXURG.js.map +0 -1
  150. package/dist/opencode-QKZ5EIYU.js.map +0 -1
  151. package/dist/qwen-code-E2MSEZK6.js.map +0 -1
  152. package/dist/roo-code-AGGJ473T.js.map +0 -1
  153. package/dist/trae-6L226ZDU.js.map +0 -1
  154. package/dist/vscode-copilot-6EOZDLXC.js.map +0 -1
  155. package/dist/warp-N5YYN5BF.js.map +0 -1
  156. package/dist/windsurf-4TGSJIVV.js.map +0 -1
  157. package/dist/zed-6P2UFWXU.js.map +0 -1
  158. /package/dist/{action-YCU53FNE.js.map → action-RWPRIZIC.js.map} +0 -0
  159. /package/dist/{antigravity-VK2Y3FGV.js.map → antigravity-DWW35HZO.js.map} +0 -0
  160. /package/dist/{chunk-F5RX62T7.js.map → chunk-7QRUZAUG.js.map} +0 -0
  161. /package/dist/{chunk-CYOAH23F.js.map → chunk-A2T4Q7RM.js.map} +0 -0
  162. /package/dist/{chunk-7ECYDK5T.js.map → chunk-CDVOBKSG.js.map} +0 -0
  163. /package/dist/{chunk-MDNX7HTN.js.map → chunk-HOE2MN36.js.map} +0 -0
  164. /package/dist/{chunk-PFDUGDOA.js.map → chunk-KG6T3YNJ.js.map} +0 -0
  165. /package/dist/{chunk-YQLQJZ7S.js.map → chunk-MOW2RKHX.js.map} +0 -0
  166. /package/dist/{chunk-SDPIT4HW.js.map → chunk-NYR55UT7.js.map} +0 -0
  167. /package/dist/{chunk-WFXWJITA.js.map → chunk-OZ5EXXQV.js.map} +0 -0
  168. /package/dist/{chunk-6RYPUR6O.js.map → chunk-VRKTVCYJ.js.map} +0 -0
  169. /package/dist/{chunk-HAIMYUEY.js.map → chunk-WI6YSXOC.js.map} +0 -0
  170. /package/dist/{chunk-2F5QH3D4.js.map → chunk-XQUUNAGC.js.map} +0 -0
  171. /package/dist/{chunk-SPWFUHHK.js.map → chunk-YYISBXOM.js.map} +0 -0
  172. /package/dist/{detect-2NIXILMZ.js.map → detect-YDCZNV4W.js.map} +0 -0
  173. /package/dist/{hook-FDGIQPRC.js.map → hook-CDGSCASQ.js.map} +0 -0
  174. /package/dist/{leaderboard-MXGENYXN.js.map → leaderboard-VZQXNWTX.js.map} +0 -0
  175. /package/dist/{nemoclaw-LXUTMR56.js.map → nemoclaw-DNFIZFDF.js.map} +0 -0
  176. /package/dist/{openclaw-XWJLEW35.js.map → openclaw-QE2LMWIF.js.map} +0 -0
  177. /package/dist/{package-IA56LSC3.js.map → package-BSCCMW4E.js.map} +0 -0
  178. /package/dist/{pi-YGBXYWY5.js.map → pi-H2KBBDDJ.js.map} +0 -0
  179. /package/dist/{serve-RNUCK5F7.js.map → serve-MQNGPY2H.js.map} +0 -0
  180. /package/dist/{statusline-ZVFI5DRT.js.map → statusline-IYWA75TR.js.map} +0 -0
  181. /package/dist/{telemetry-3FN6HDVU.js.map → telemetry-IONIOMLC.js.map} +0 -0
  182. /package/dist/{usage-G72SF7JG.js.map → usage-TCUWV2YZ.js.map} +0 -0
  183. /package/dist/{usage-event-DHSEBO5T.js.map → usage-event-CBZZP37Q.js.map} +0 -0
@@ -1,17 +1,22 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ normalizeSessionSource
4
+ } from "./chunk-H53QZQJI.js";
2
5
  import {
3
6
  resolveEnvRefsDeep
4
7
  } from "./chunk-DBQMX75U.js";
5
8
  import {
6
9
  BaseAdapter
7
- } from "./chunk-PFDUGDOA.js";
8
- import "./chunk-7L6ITC4T.js";
10
+ } from "./chunk-KG6T3YNJ.js";
11
+ import {
12
+ renderSkillMd,
13
+ renderSubagentMd
14
+ } from "./chunk-IEGR4TP3.js";
9
15
  import {
10
16
  buildHomeBinHookCommand,
11
- buildServeWrapperCommand,
12
- isHomeBinHookCommand,
13
- shouldWrapForTelemetry
14
- } from "./chunk-I5MLE6S7.js";
17
+ buildWrappedStdio,
18
+ isHomeBinHookCommand
19
+ } from "./chunk-TO57WYBB.js";
15
20
  import "./chunk-N6HH7K6P.js";
16
21
  import "./chunk-TRQKHP7D.js";
17
22
 
@@ -151,18 +156,7 @@ var CopilotCliAdapter = class extends BaseAdapter {
151
156
  if (transport === "stdio") {
152
157
  let command = server.command ?? "";
153
158
  let args = [...server.args ?? []];
154
- if (shouldWrapForTelemetry(server, ctx.connector.telemetry)) {
155
- const wrapped = buildServeWrapperCommand(
156
- ctx.homeBinPath,
157
- ctx.connector.id,
158
- command,
159
- args,
160
- ctx.scope,
161
- this.id
162
- );
163
- command = wrapped.command;
164
- args = wrapped.args;
165
- }
159
+ ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));
166
160
  const entry2 = {
167
161
  type: "local",
168
162
  command: resolveEnvRefsDeep(command),
@@ -401,7 +395,7 @@ var CopilotCliAdapter = class extends BaseAdapter {
401
395
  for (const skill of connector.skills) {
402
396
  const dir = this.skillDir(ctx, skill.name);
403
397
  changes.push(
404
- this.writeContentFile(join(dir, "SKILL.md"), this.renderSkill(skill), ctx.dryRun)
398
+ this.writeContentFile(join(dir, "SKILL.md"), renderSkillMd(skill), ctx.dryRun)
405
399
  );
406
400
  for (const [rel, contents] of Object.entries(skill.resources ?? {})) {
407
401
  const target = this.resolveWithin(dir, rel);
@@ -436,25 +430,6 @@ var CopilotCliAdapter = class extends BaseAdapter {
436
430
  }
437
431
  return changes;
438
432
  }
439
- /**
440
- * Render a skill's SKILL.md: frontmatter (name, description + optional model,
441
- * allowed-tools, disable-model-invocation) + body. Uniform Agent Skills shape
442
- * shared across every skill-supporting connector.
443
- */
444
- renderSkill(skill) {
445
- const frontmatter = {
446
- name: skill.name,
447
- description: skill.description
448
- };
449
- if (skill.model !== void 0) frontmatter.model = skill.model;
450
- const allow = skill.tools?.allow;
451
- if (allow && allow.length > 0) frontmatter["allowed-tools"] = allow.join(", ");
452
- if (skill.disableModelInvocation !== void 0) {
453
- frontmatter["disable-model-invocation"] = skill.disableModelInvocation;
454
- }
455
- if (skill.extra) Object.assign(frontmatter, skill.extra);
456
- return this.renderFrontmatterMd(frontmatter, skill.body);
457
- }
458
433
  // ── Subagents ───────────────────────────────────────────────────────────────
459
434
  installSubagents(ctx) {
460
435
  const { connector } = ctx;
@@ -467,7 +442,7 @@ var CopilotCliAdapter = class extends BaseAdapter {
467
442
  return connector.subagents.map(
468
443
  (agent) => this.writeContentFile(
469
444
  this.subagentPath(ctx, agent.name),
470
- this.renderSubagent(agent),
445
+ renderSubagentMd(agent),
471
446
  ctx.dryRun
472
447
  )
473
448
  );
@@ -481,18 +456,6 @@ var CopilotCliAdapter = class extends BaseAdapter {
481
456
  (agent) => this.removeContentFile(this.subagentPath(ctx, agent.name), ctx.dryRun)
482
457
  );
483
458
  }
484
- /** Render a subagent to md+frontmatter (name, description, tools, model) + prompt body. */
485
- renderSubagent(agent) {
486
- const frontmatter = {
487
- name: agent.name,
488
- description: agent.description
489
- };
490
- const allow = agent.tools?.allow;
491
- if (allow && allow.length > 0) frontmatter.tools = allow.join(", ");
492
- if (agent.model !== void 0) frontmatter.model = agent.model;
493
- if (agent.extra) Object.assign(frontmatter, agent.extra);
494
- return this.renderFrontmatterMd(frontmatter, agent.prompt);
495
- }
496
459
  // ── Diagnostics ──────────────────────────────────────────────────────────
497
460
  getHealthChecks(ctx) {
498
461
  const mcpPath = this.getServerConfigPath(ctx);
@@ -767,18 +730,6 @@ function toolResponseToString(value) {
767
730
  return String(value);
768
731
  }
769
732
  }
770
- function normalizeSessionSource(source) {
771
- switch (source) {
772
- case "compact":
773
- return "compact";
774
- case "resume":
775
- return "resume";
776
- case "clear":
777
- return "clear";
778
- default:
779
- return "startup";
780
- }
781
- }
782
733
  var adapter = new CopilotCliAdapter();
783
734
  var copilot_cli_default = adapter;
784
735
  export {
@@ -786,4 +737,4 @@ export {
786
737
  adapter,
787
738
  copilot_cli_default as default
788
739
  };
789
- //# sourceMappingURL=copilot-cli-Y74SOP5G.js.map
740
+ //# sourceMappingURL=copilot-cli-A7G5WB4N.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapters/copilot-cli/index.ts"],"sourcesContent":["/**\n * adapters/copilot-cli — GitHub Copilot CLI platform adapter for agent-connector.\n *\n * GitHub Copilot CLI is a json-stdio host: the host pipes a JSON payload to a\n * hook command on stdin and reads JSON/exit-code back. Its hook event names and\n * reply shape are Claude-compatible (PascalCase events, `hookSpecificOutput`\n * reply wrapper), so the normalized HookEventName values map 1:1 — no event\n * rename table is needed.\n *\n * Native config (user/global only — Copilot CLI has no project-scoped config):\n * - MCP servers: ~/.copilot/mcp-config.json, root key \"mcpServers\". An stdio\n * server is written with type \"local\" (the host also accepts \"stdio\") plus\n * `tools: [\"*\"]`. Remote servers use type \"http\".\n * - Hooks: a Claude-compatible hooks file shaped `{ version: 1, hooks: { … } }`\n * discovered from ~/.copilot/hooks/*.json. We write a single dedicated file,\n * ~/.copilot/hooks/agent-connector.json, so we never disturb a user's own\n * hook files and removal is a clean, scoped operation. Each event maps to an\n * array of flat command entries `{ matcher?, hooks: [{ type:\"command\", command }] }`\n * — the Claude shape, which Copilot CLI reads.\n * - Reply: a `hookSpecificOutput` object keyed by `hookEventName` carrying\n * `permissionDecision` (allow|deny|ask) + `permissionDecisionReason`,\n * `additionalContext`, and (PreToolUse) `updatedInput`. PreToolUse is\n * fail-closed on the host side; exit 0 + JSON refines the decision.\n *\n * Env handling: the host is not documented to support `${env:VAR}` interpolation\n * inside mcp-config.json, so env/header/url refs are resolved to literals at\n * install time via resolveEnvRefsDeep (the safe default for a no-native-interp\n * host, matching the Codex adapter's approach).\n *\n * Content surfaces (surfaces-design §4-5): Copilot CLI exposes skills and\n * subagents but NO prompt-file command surface, so commands inherit the\n * BaseAdapter skip/warn default (supportsCommands stays false).\n * - skills: folder-per-skill `<dir>/skills/<name>/SKILL.md` (+ resource files).\n * user scope → ~/.copilot/skills; project scope → <projectDir>/.github/skills.\n * - subagents: user scope → ~/.copilot/agents/<name>.agent.md; project scope →\n * <projectDir>/.github/agents/<name>.agent.md (md + frontmatter:\n * name, description, tools, model).\n * The .github/ tree is shared with the vscode-copilot and jetbrains-copilot\n * connectors; we write identical, idempotent content and on uninstall remove\n * only the files this connector wrote.\n *\n * Grounded in docs/research/understand-report.md §2 (Platform Integration\n * Matrix, \"GitHub Copilot CLI\" row).\n */\n\nimport { existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\n\nimport { BaseAdapter } from \"../base.js\";\nimport type { Adapter, HookReply, InstallContext, MemoryTarget, NormalizedEvent } from \"../spi.js\";\nimport type {\n ChangeRecord,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n NotificationEvent,\n PermissionRequestEvent,\n PlatformCapabilities,\n PlatformId,\n PostToolUseEvent,\n PostToolUseFailureEvent,\n PostCompactEvent,\n PreCompactEvent,\n PreToolUseEvent,\n ServerDef,\n SessionEndEvent,\n SessionStartEvent,\n StopEvent,\n SubagentStartEvent,\n SubagentStopEvent,\n Transport,\n UserPromptSubmitEvent,\n} from \"../../core/types.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport {\n buildHomeBinHookCommand,\n buildWrappedStdio,\n isHomeBinHookCommand,\n} from \"../../core/spawn.js\";\nimport { renderSkillMd, renderSubagentMd } from \"../claude-code/render.js\";\nimport { normalizeSessionSource } from \"../claude-code/wire.js\";\n\nconst HOST: PlatformId = \"copilot-cli\";\nconst MCP_ROOT_KEY = \"mcpServers\";\n\n/** Native hooks-file version Copilot CLI expects (`{ version: 1, hooks: {…} }`). */\nconst COPILOT_HOOKS_VERSION = 1;\n\n/**\n * Copilot CLI accepts both camelCase and PascalCase hook event names; PascalCase\n * is the portable, Claude/VS Code-compatible form (and selects the snake_case\n * payload dialect), so we emit it directly. Our normalized HookEventName values\n * are already PascalCase and match 1:1, hence no rename table — every declared\n * event has a native equivalent, including the newer four: subagentStart\n * (additionalContext only, matcher on agent name), subagentStop (can block and\n * force continuation), permissionRequest (decision control), and\n * postToolUseFailure (recovery guidance; the host also has a broader\n * errorOccurred event with no normalized analog — reachable via\n * platforms[\"copilot-cli\"].nativeHooks, see capabilities.supportsNativeHooks).\n */\ntype CopilotHookEvent = HookEventName;\n\n/** A single Copilot CLI hook registration entry (Claude-shaped). */\ninterface CopilotHookEntry {\n matcher: string;\n hooks: Array<{ type: \"command\"; command: string }>;\n}\n\n/** The shape of the Copilot CLI hooks file we own. */\ninterface CopilotHooksFile {\n version?: number;\n hooks?: Record<string, CopilotHookEntry[]>;\n}\n\n/** Native MCP server entry shapes Copilot CLI accepts under `mcpServers`. */\ninterface CopilotLocalServer {\n /** stdio transport is registered as type \"local\" (host also accepts \"stdio\"). */\n type: \"local\";\n command: string;\n args?: string[];\n env?: Record<string, string>;\n cwd?: string;\n tools: string[];\n}\ninterface CopilotHttpServer {\n /** Remote transport: \"http\" (Streamable HTTP) or \"sse\" (legacy). */\n type: \"http\" | \"sse\";\n url: string;\n headers?: Record<string, string>;\n tools: string[];\n}\n\n/** Raw Copilot CLI hook stdin payload (Claude-style: PascalCase event, snake_case fields). */\ninterface CopilotWireInput {\n connector?: unknown;\n session_id?: string;\n transcript_path?: string;\n cwd?: string;\n hook_event_name?: string;\n\n // tool events\n tool_name?: string;\n tool_input?: Record<string, unknown>;\n tool_response?: unknown;\n\n // SessionStart\n source?: string;\n // SessionEnd\n reason?: string;\n // UserPromptSubmit\n prompt?: string;\n // PreCompact\n trigger?: string;\n // Stop / SubagentStop\n stop_hook_active?: boolean;\n // Notification\n message?: string;\n\n // PermissionRequest — permission-update entries the dialog would offer.\n permission_suggestions?: unknown[];\n\n // PostToolUseFailure\n tool_use_id?: string;\n error?: string;\n is_interrupt?: boolean;\n duration_ms?: number;\n\n // SubagentStart / SubagentStop — agent_type is unreliable on SubagentStop\n // (Claude-compatible quirk); treat both as optional everywhere.\n agent_id?: string;\n agent_type?: string;\n // SubagentStop — the subagent's OWN transcript + its final response text.\n agent_transcript_path?: string;\n last_assistant_message?: string;\n}\n\nexport class CopilotCliAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"GitHub Copilot CLI\";\n readonly paradigm: HookParadigm = \"json-stdio\";\n\n readonly capabilities: PlatformCapabilities = {\n // Memory surface: AGENTS.md-first managed block (project <projectDir>/AGENTS.md\n // via the base default; user scope → ~/.copilot/copilot-instructions.md below).\n supportsMemory: true,\n // Copilot CLI delivers the full Claude-compatible lifecycle event set.\n preToolUse: true,\n postToolUse: true,\n preCompact: true,\n sessionStart: true,\n sessionEnd: true,\n userPromptSubmit: true,\n stop: true,\n notification: true,\n // Newer events — Copilot CLI has native analogs for all four:\n // permissionRequest (decision control), postToolUseFailure (recovery\n // guidance), subagentStart (context-only), subagentStop (blockable).\n permissionRequest: true,\n postToolUseFailure: true,\n subagentStart: true,\n subagentStop: true,\n // PreToolUse is fail-closed and can rewrite tool input (updatedInput); a\n // PostToolUse hook cannot rewrite already-emitted tool output.\n canModifyArgs: true,\n canModifyOutput: false,\n canInjectSessionContext: true,\n // Copilot CLI's mcp-config.json `type` accepts stdio (written \"local\"),\n // http (Streamable HTTP), and sse (legacy) — per GitHub's add-mcp-servers docs.\n transports: [\"stdio\", \"http\", \"sse\"],\n // Content surfaces: Copilot CLI exposes skills + subagents, but has no\n // prompt-file command surface, so commands stay false (inherits BaseAdapter\n // skip/warn).\n supportsCommands: false,\n supportsSkills: true,\n supportsSubagents: true,\n // Native passthrough: Copilot CLI documents an `errorOccurred` lifecycle\n // event (plus camelCase aliases) with NO canonical HookEventName analog —\n // below the >=3-host core bar (docs/research/host-specific-hook-events-design.md).\n // A connector reaches it via platforms[\"copilot-cli\"].nativeHooks; installHooks\n // files the event-name key VERBATIM with the same home-bin command shape, and\n // the generic uninstall reverses it.\n supportsNativeHooks: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(_projectDir: string): DetectedPlatform {\n const userDir = join(homedir(), \".copilot\");\n const mcpConfig = join(userDir, \"mcp-config.json\");\n const hooksDir = join(userDir, \"hooks\");\n const installed =\n existsSync(userDir) || existsSync(mcpConfig) || existsSync(hooksDir);\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath: mcpConfig,\n scope: \"user\",\n reason: installed\n ? `found GitHub Copilot CLI config under ${userDir}`\n : `no GitHub Copilot CLI config at ${userDir}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Memory surface: user-scope global instructions file ─────────────────\n // Project scope stays on the AGENTS.md base default (root AGENTS.md is the\n // primary instructions file). User scope targets Copilot CLI's documented\n // $HOME/.copilot/copilot-instructions.md — a markdown file shared with other\n // writers, so the managed block (not whole-file ownership) applies as usual.\n protected override memoryTargets(ctx: InstallContext): MemoryTarget[] {\n if (this.memoryOverride(ctx)?.path || ctx.scope !== \"user\") {\n return super.memoryTargets(ctx);\n }\n return [\n {\n path: join(homedir(), \".copilot\", \"copilot-instructions.md\"),\n reason: \"copilot-cli global instructions (~/.copilot/copilot-instructions.md)\",\n },\n ];\n }\n\n // ── Native paths ─────────────────────────────────────────────────────────\n\n /** Copilot CLI is user/global only — scope is ignored. */\n getConfigDir(_ctx: InstallContext): string {\n return join(homedir(), \".copilot\");\n }\n\n getServerConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"mcp-config.json\");\n }\n\n /**\n * Copilot CLI discovers hooks from any `~/.copilot/hooks/*.json`. We write a\n * single dedicated file so we never disturb the user's own hook files and\n * uninstall is a clean, scoped operation.\n */\n getHookConfigPath(ctx: InstallContext): string {\n return join(this.getConfigDir(ctx), \"hooks\", \"agent-connector.json\");\n }\n\n // ── MCP server install / uninstall ───────────────────────────────────────\n\n installServer(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n const override = connector.platforms[HOST]?.server;\n if (!connector.server || override === false) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: connector.server\n ? \"server registration disabled for copilot-cli\"\n : \"connector declares no MCP server\",\n },\n ];\n }\n\n // Shallow-merge any per-platform server override into the base ServerDef.\n const server: ServerDef =\n override && typeof override === \"object\"\n ? { ...connector.server, ...override }\n : connector.server;\n\n const serverPath = this.getServerConfigPath(ctx);\n const entry = this.renderServerEntry(ctx, server);\n\n return [\n this.upsertServerInJson(serverPath, MCP_ROOT_KEY, connector.id, entry, ctx.dryRun),\n ];\n }\n\n uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const serverPath = this.getServerConfigPath(ctx);\n return [\n this.removeServerFromJson(serverPath, MCP_ROOT_KEY, ctx.connector.id, ctx.dryRun),\n ];\n }\n\n /** Render a normalized ServerDef into Copilot CLI's native mcpServers entry. */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): CopilotLocalServer | CopilotHttpServer {\n const transport: Transport = server.transport;\n const tools = this.renderTools(server);\n\n if (transport === \"stdio\") {\n let command = server.command ?? \"\";\n let args = [...(server.args ?? [])];\n\n // Transparent telemetry wrapping: route the real command through\n // `<homeBin> serve --connector <id> -- <command> <args...>`.\n ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));\n\n const entry: CopilotLocalServer = {\n type: \"local\",\n command: resolveEnvRefsDeep(command),\n tools,\n };\n if (args.length > 0) entry.args = args.map((a) => resolveEnvRefsDeep(a));\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n if (server.cwd) entry.cwd = resolveEnvRefsDeep(server.cwd);\n return entry;\n }\n\n // remote (Streamable http / legacy sse) — Copilot registers a URL keyed by\n // its `type`. AC's canonical \"sse\" → \"sse\"; everything else → \"http\".\n const entry: CopilotHttpServer = {\n type: server.transport === \"sse\" ? \"sse\" : \"http\",\n url: resolveEnvRefsDeep(server.url ?? \"\"),\n tools,\n };\n const headers = this.renderEnv(server.headers);\n if (headers) entry.headers = headers;\n return entry;\n }\n\n /**\n * Render env/header values. Copilot CLI is not documented to support native\n * `${env:VAR}` interpolation in mcp-config.json, so refs resolve to literals\n * at install time (the safe default for a no-native-interp host).\n */\n private renderEnv(\n env: Record<string, string> | undefined,\n ): Record<string, string> | undefined {\n if (!env || Object.keys(env).length === 0) return undefined;\n return resolveEnvRefsDeep({ ...env });\n }\n\n /** Render the tool allow-list. Copilot CLI expects `tools` on every entry; default [\"*\"]. */\n private renderTools(server: ServerDef): string[] {\n const include = server.tools?.include;\n return include && include.length > 0 ? [...include] : [\"*\"];\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, copilot-cli-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 copilot-cli\"\n : \"connector declares no hooks\",\n },\n ];\n }\n\n const hooksPath = this.getHookConfigPath(ctx);\n const file = this.readJson<CopilotHooksFile>(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 // PascalCase events map 1:1 to Copilot CLI's native event names.\n const copilotEvent: CopilotHookEvent = event;\n const command = buildHomeBinHookCommand(ctx.homeBinPath, HOST, event, connector.id);\n const matcher = connector.hooks[event]?.matcher ?? \"\";\n const entry: CopilotHookEntry = {\n matcher,\n hooks: [{ type: \"command\", command }],\n };\n\n const bucket = (hooks[copilotEvent] ??= []);\n const existingIdx = bucket.findIndex((e) => this.entryHasOurCommand(e, ctx));\n\n if (existingIdx >= 0) {\n if (JSON.stringify(bucket[existingIdx]) === JSON.stringify(entry)) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: hooksPath,\n detail: `hooks.${copilotEvent} 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.${copilotEvent}`,\n });\n } else {\n bucket.push(entry);\n changes.push({\n platform: this.id,\n action: \"create\",\n path: hooksPath,\n detail: `hooks.${copilotEvent}`,\n });\n }\n mutated = true;\n }\n\n // NATIVE passthrough events: copilot-cli-native event-name keys (e.g.\n // ErrorOccurred) filed VERBATIM into the hooks map — no EVENT_MAP, since they\n // ARE Copilot events. The command keeps the native token; matched by EXACT\n // command so a native key coinciding with a normalized one never clobbers it.\n for (const nativeEvent of nativeEvents) {\n const command = buildHomeBinHookCommand(ctx.homeBinPath, HOST, nativeEvent, connector.id);\n const entry: CopilotHookEntry = {\n matcher: nativeHooks[nativeEvent]?.matcher ?? \"\",\n hooks: [{ type: \"command\", command }],\n };\n const bucket = (hooks[nativeEvent] ??= []);\n const existingIdx = bucket.findIndex((e) => e.hooks?.[0]?.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 file.version = COPILOT_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 file = this.readJson<CopilotHooksFile>(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 copilotEvent of Object.keys(hooks)) {\n const bucket = hooks[copilotEvent];\n if (!Array.isArray(bucket)) continue;\n\n // Strip our hook command from each entry; drop entries left empty so we\n // never remove another connector's (or the user's own) hook commands.\n const next: CopilotHookEntry[] = [];\n let removed = 0;\n for (const e of bucket) {\n const innerBefore = e.hooks?.length ?? 0;\n const inner = (e.hooks ?? []).filter((h) => !this.isOurCommand(h.command, ctx));\n removed += innerBefore - inner.length;\n if (inner.length > 0) next.push({ matcher: e.matcher ?? \"\", hooks: inner });\n }\n\n if (removed > 0) {\n if (next.length > 0) hooks[copilotEvent] = next;\n else delete hooks[copilotEvent];\n changes.push({\n platform: this.id,\n action: \"remove\",\n path: hooksPath,\n detail: `hooks.${copilotEvent} (${removed})`,\n });\n mutated = true;\n }\n }\n\n if (mutated) this.writeJson(hooksPath, file, ctx.dryRun);\n if (changes.length === 0) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: hooksPath,\n detail: \"no matching hook entries\",\n });\n }\n return changes;\n }\n\n private entryHasOurCommand(entry: CopilotHookEntry, ctx: InstallContext): boolean {\n return (entry.hooks ?? []).some((h) => this.isOurCommand(h.command, ctx));\n }\n\n /** True when a hook command references our home binary AND this connector id\n * (anchored so a shared-prefix id can't collide — see isHomeBinHookCommand). */\n private isOurCommand(command: string | undefined, ctx: InstallContext): boolean {\n return isHomeBinHookCommand(command, ctx.homeBinPath, ctx.connector.id);\n }\n\n // ── Content surfaces: skills / subagents ─────────────────────────────────\n // CONTENT-ONLY: pure native-file writers. No runtime dispatch, no home-bin\n // pointer, no telemetry wrap. Each method is idempotent (byte-identical →\n // skip) via BaseAdapter.writeContentFile and reversible via removeContentFile.\n // Honors platforms[\"copilot-cli\"] per-surface false to skip. Commands are\n // unsupported here — they inherit the BaseAdapter skip/warn default.\n //\n // Path scoping: user scope lives under ~/.copilot (getConfigDir); project\n // scope lives under the shared <projectDir>/.github tree (the same files\n // vscode-copilot / jetbrains-copilot would write). We write identical content\n // and on uninstall remove only the files this connector wrote.\n\n /** Root dir for content surfaces: ~/.copilot (user) or <projectDir>/.github (project). */\n private contentDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".github\")\n : this.getConfigDir(ctx);\n }\n\n private skillsDir(ctx: InstallContext): string {\n return join(this.contentDir(ctx), \"skills\");\n }\n private agentsDir(ctx: InstallContext): string {\n return join(this.contentDir(ctx), \"agents\");\n }\n\n /** Native skill dir: <contentDir>/skills/<name>. */\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.skillsDir(ctx), name);\n }\n /** Native subagent file path: <contentDir>/agents/<name>.agent.md. */\n private subagentPath(ctx: InstallContext, name: string): string {\n return join(this.agentsDir(ctx), `${name}.agent.md`);\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 copilot-cli\" }];\n }\n if (connector.skills.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no skills\" }];\n }\n const changes: ChangeRecord[] = [];\n for (const skill of connector.skills) {\n const dir = this.skillDir(ctx, skill.name);\n changes.push(\n this.writeContentFile(join(dir, \"SKILL.md\"), renderSkillMd(skill), ctx.dryRun),\n );\n // 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 // ── Subagents ───────────────────────────────────────────────────────────────\n\n override installSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.subagents === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"subagents disabled for copilot-cli\" }];\n }\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n return connector.subagents.map((agent) =>\n this.writeContentFile(\n this.subagentPath(ctx, agent.name),\n renderSubagentMd(agent),\n ctx.dryRun,\n ),\n );\n }\n\n override uninstallSubagents(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.subagents.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no subagents\" }];\n }\n return connector.subagents.map((agent) =>\n this.removeContentFile(this.subagentPath(ctx, agent.name), ctx.dryRun),\n );\n }\n\n // ── Diagnostics ──────────────────────────────────────────────────────────\n\n override getHealthChecks(ctx: InstallContext): readonly HealthCheck[] {\n const mcpPath = this.getServerConfigPath(ctx);\n const hooksPath = this.getHookConfigPath(ctx);\n const connectorId = ctx.connector.id;\n const homeBin = ctx.homeBinPath;\n const hookEvents = ctx.connector.hookEvents;\n const checks: HealthCheck[] = [\n {\n name: `${this.name}: mcp-config.json present`,\n check: () =>\n existsSync(mcpPath)\n ? { status: \"OK\", detail: mcpPath }\n : { status: \"FAIL\", detail: `not found: ${mcpPath}` },\n },\n {\n name: `${this.name}: hook command registered`,\n check: () => {\n if (hookEvents.length === 0) {\n return { status: \"OK\", detail: \"no hooks declared\" };\n }\n const file = this.readJson<CopilotHooksFile>(hooksPath);\n if (!file) return { status: \"FAIL\", detail: `cannot read ${hooksPath}` };\n const hooks = file.hooks ?? {};\n const registered = Object.values(hooks).some((entries) =>\n (entries ?? []).some((e) =>\n (e.hooks ?? []).some((h) =>\n isHomeBinHookCommand(h.command, homeBin, connectorId),\n ),\n ),\n );\n return registered\n ? { status: \"OK\", detail: \"hook command present\" }\n : { status: \"FAIL\", detail: `no hook for ${connectorId} in ${hooksPath}` };\n },\n },\n ];\n\n // Content-surface checks: only assert presence of the surfaces this\n // connector declares (skip silently for surfaces it never asked for).\n // Commands are unsupported on Copilot CLI, so no command check.\n for (const skill of ctx.connector.skills) {\n const p = join(this.skillDir(ctx, skill.name), \"SKILL.md\");\n checks.push({\n name: `${this.name}: skill ${skill.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n for (const agent of ctx.connector.subagents) {\n const p = this.subagentPath(ctx, agent.name);\n checks.push({\n name: `${this.name}: subagent ${agent.name} present`,\n check: () =>\n existsSync(p) ? { status: \"OK\", detail: p } : { status: \"FAIL\", detail: `not found: ${p}` },\n });\n }\n return checks;\n }\n\n // ── Runtime: parse Copilot CLI stdin JSON → normalized event ─────────────\n\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as CopilotWireInput;\n const connectorId = typeof input.connector === \"string\" ? input.connector : \"\";\n const sessionId = extractSessionId(input);\n const projectDir = typeof input.cwd === \"string\" ? input.cwd : undefined;\n\n const base = {\n hostPlatform: HOST,\n connectorId,\n sessionId,\n raw,\n ...(projectDir !== undefined ? { projectDir } : {}),\n } as const;\n\n switch (event) {\n case \"PreToolUse\": {\n const ev: PreToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n };\n return ev;\n }\n case \"PostToolUse\": {\n const toolOutput = toolResponseToString(input.tool_response);\n const ev: PostToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n ...(toolOutput !== undefined ? { toolOutput } : {}),\n };\n return ev;\n }\n case \"SessionStart\": {\n const ev: SessionStartEvent = {\n ...base,\n source: normalizeSessionSource(input.source),\n };\n return ev;\n }\n case \"SessionEnd\": {\n const ev: SessionEndEvent = {\n ...base,\n ...(typeof input.reason === \"string\" ? { reason: input.reason } : {}),\n };\n return ev;\n }\n case \"UserPromptSubmit\": {\n const ev: UserPromptSubmitEvent = {\n ...base,\n prompt: typeof input.prompt === \"string\" ? input.prompt : \"\",\n };\n return ev;\n }\n case \"PreCompact\": {\n const ev: PreCompactEvent = {\n ...base,\n ...(input.trigger === \"auto\" || input.trigger === \"manual\"\n ? { trigger: input.trigger }\n : {}),\n };\n return ev;\n }\n case \"PostCompact\": {\n // Copilot CLI 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 ev: PostCompactEvent = {\n ...base,\n ...(input.trigger === \"auto\" || input.trigger === \"manual\"\n ? { trigger: input.trigger }\n : {}),\n };\n return ev;\n }\n case \"Stop\": {\n const ev: StopEvent = {\n ...base,\n ...(typeof input.stop_hook_active === \"boolean\"\n ? { stopHookActive: input.stop_hook_active }\n : {}),\n };\n return ev;\n }\n case \"Notification\": {\n const ev: NotificationEvent = {\n ...base,\n message: typeof input.message === \"string\" ? input.message : \"\",\n };\n return ev;\n }\n case \"PermissionRequest\": {\n const ev: PermissionRequestEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n ...(Array.isArray(input.permission_suggestions)\n ? { permissionSuggestions: input.permission_suggestions }\n : {}),\n };\n return ev;\n }\n case \"PostToolUseFailure\": {\n const ev: PostToolUseFailureEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n error: typeof input.error === \"string\" ? input.error : \"\",\n ...(typeof input.tool_use_id === \"string\"\n ? { toolUseId: input.tool_use_id }\n : {}),\n ...(typeof input.is_interrupt === \"boolean\"\n ? { isInterrupt: input.is_interrupt }\n : {}),\n ...(typeof input.duration_ms === \"number\"\n ? { durationMs: input.duration_ms }\n : {}),\n };\n return ev;\n }\n case \"SubagentStart\": {\n const ev: SubagentStartEvent = {\n ...base,\n ...(typeof input.agent_id === \"string\" ? { agentId: input.agent_id } : {}),\n ...(typeof input.agent_type === \"string\"\n ? { agentType: input.agent_type }\n : {}),\n };\n return ev;\n }\n case \"SubagentStop\": {\n // agent_id/agent_type stay optional — hosts do not reliably populate\n // agent_type on SubagentStop (Claude-compatible quirk).\n const ev: SubagentStopEvent = {\n ...base,\n ...(typeof input.agent_id === \"string\" ? { agentId: input.agent_id } : {}),\n ...(typeof input.agent_type === \"string\"\n ? { agentType: input.agent_type }\n : {}),\n ...(typeof input.agent_transcript_path === \"string\"\n ? { agentTranscriptPath: input.agent_transcript_path }\n : {}),\n ...(typeof input.last_assistant_message === \"string\"\n ? { lastAssistantMessage: input.last_assistant_message }\n : {}),\n ...(typeof input.stop_hook_active === \"boolean\"\n ? { stopHookActive: input.stop_hook_active }\n : {}),\n };\n return ev;\n }\n default: {\n // Exhaustive guard — every HookEventName is handled above.\n const _never: never = event;\n throw new Error(`unsupported copilot-cli hook event: ${String(_never)}`);\n }\n }\n }\n\n // ── Runtime: normalized response → Copilot CLI native hook reply ─────────\n\n formatReply(event: HookEventName, response: HookResponse): HookReply {\n const hookEventName = event;\n const decision = response.decision ?? \"allow\";\n\n // PermissionRequest replies use the Claude-compatible nested\n // decision{behavior} envelope and are the ONE event where an EXPLICIT\n // \"allow\" is an ACTIVE grant (it suppresses the permission dialog) rather\n // than passthrough:\n // allow → decision{behavior:\"allow\"} (+updatedInput when set);\n // the host still enforces its own deny rules.\n // modify → an allow grant carrying updatedInput.\n // deny → decision{behavior:\"deny\", message}.\n // ask/context/void → NO decision output: fall through to the native\n // dialog (the dialog IS the ask).\n if (event === \"PermissionRequest\") {\n if (response.decision === \"deny\") {\n return this.stdout({\n hookSpecificOutput: {\n hookEventName,\n decision: {\n behavior: \"deny\",\n message: response.reason ?? \"Blocked by hook\",\n },\n },\n });\n }\n if (\n response.decision === \"allow\" ||\n (response.decision === \"modify\" && response.updatedInput)\n ) {\n return this.stdout({\n hookSpecificOutput: {\n hookEventName,\n decision: {\n behavior: \"allow\",\n ...(response.updatedInput\n ? { updatedInput: response.updatedInput }\n : {}),\n },\n },\n });\n }\n return { exitCode: 0 };\n }\n\n // PostToolUseFailure (recovery guidance beside the error) and SubagentStart\n // (context prepended to the SUBAGENT's conversation — creation is not\n // blockable on Copilot CLI) are observe/context-only: \"context\" emits\n // additionalContext, and a \"deny\" DEGRADES to the same shape carrying the\n // reason. Everything else passes through.\n if (event === \"PostToolUseFailure\" || event === \"SubagentStart\") {\n const context =\n decision === \"context\"\n ? response.additionalContext\n : decision === \"deny\"\n ? response.reason ?? response.additionalContext\n : undefined;\n if (context) {\n return this.stdout({\n hookSpecificOutput: { hookEventName, additionalContext: context },\n });\n }\n return { exitCode: 0 };\n }\n\n // deny → block the action with a reason (exit 0; JSON carries the decision).\n // SubagentStop is the Stop-semantics exception: like Claude, the block is\n // the TOP-LEVEL {\"decision\":\"block\",\"reason\"} — it keeps the subagent\n // running with `reason` as its next instruction (the host \"can block and\n // force continuation\").\n if (decision === \"deny\") {\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,\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: response.reason ?? \"Confirmation required by hook\",\n },\n });\n }\n\n // modify → rewrite PreToolUse input (only where Copilot CLI supports it).\n if (decision === \"modify\") {\n if (event === \"PreToolUse\" && response.updatedInput) {\n return this.stdout({\n hookSpecificOutput: { hookEventName, updatedInput: response.updatedInput },\n });\n }\n // Output rewrite is unsupported on Copilot CLI; fall through to allow.\n }\n\n // context → inject soft guidance (also the SessionStart context path).\n if (decision === \"context\" && response.additionalContext) {\n return this.stdout({\n hookSpecificOutput: { hookEventName, additionalContext: response.additionalContext },\n });\n }\n\n // allow / void / unsupported-degradation → pass through with exit 0.\n return { exitCode: 0 };\n }\n\n private stdout(payload: unknown): HookReply {\n return { exitCode: 0, stdout: JSON.stringify(payload) };\n }\n}\n\n/**\n * Extract a stable session id from a Copilot CLI wire payload.\n * Priority mirrors the Claude wire protocol: transcript UUID > session_id > \"\".\n */\nfunction extractSessionId(input: CopilotWireInput): 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 Copilot PostToolUse `tool_response` into a string for the normalized event. */\nfunction toolResponseToString(value: unknown): string | undefined {\n if (value == null) return undefined;\n if (typeof value === \"string\") return value;\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\nexport const adapter = new CopilotCliAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,YAAY;AAsCrB,IAAM,OAAmB;AACzB,IAAM,eAAe;AAGrB,IAAM,wBAAwB;AA0FvB,IAAM,oBAAN,cAAgC,YAA+B;AAAA,EAC3D,KAAiB;AAAA,EACjB,OAAO;AAAA,EACP,WAAyB;AAAA,EAEzB,eAAqC;AAAA;AAAA;AAAA,IAG5C,gBAAgB;AAAA;AAAA,IAEhB,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,IAId,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,IACpB,eAAe;AAAA,IACf,cAAc;AAAA;AAAA;AAAA,IAGd,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,yBAAyB;AAAA;AAAA;AAAA,IAGzB,YAAY,CAAC,SAAS,QAAQ,KAAK;AAAA;AAAA;AAAA;AAAA,IAInC,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOnB,qBAAqB;AAAA,EACvB;AAAA;AAAA,EAIA,gBAAgB,aAAuC;AACrD,UAAM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,EAAE;AAAA,EACvB;AAAA,EAEQ,OAAO,SAA6B;AAC1C,WAAO,EAAE,UAAU,GAAG,QAAQ,KAAK,UAAU,OAAO,EAAE;AAAA,EACxD;AACF;AAMA,SAAS,iBAAiB,OAAiC;AACzD,MAAI,OAAO,MAAM,oBAAoB,UAAU;AAC7C,UAAM,IAAI,MAAM,gBAAgB,MAAM,yBAAyB;AAC/D,QAAI,KAAK,EAAE,CAAC,EAAG,QAAO,EAAE,CAAC;AAAA,EAC3B;AACA,MAAI,OAAO,MAAM,eAAe,YAAY,MAAM,eAAe,IAAI;AACnE,WAAO,MAAM;AAAA,EACf;AACA,SAAO;AACT;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,kBAAkB;AAC7C,IAAO,sBAAQ;","names":["entry"]}
@@ -1,24 +1,28 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ localAppData
4
+ } from "./chunk-UM5S7DKK.js";
2
5
  import {
3
6
  resolveEnvRefsDeep
4
7
  } from "./chunk-DBQMX75U.js";
5
8
  import {
6
9
  BaseAdapter
7
- } from "./chunk-PFDUGDOA.js";
8
- import "./chunk-7L6ITC4T.js";
10
+ } from "./chunk-KG6T3YNJ.js";
11
+ import {
12
+ renderSkillMd
13
+ } from "./chunk-IEGR4TP3.js";
9
14
  import {
10
15
  buildHomeBinHookCommand,
11
- buildServeWrapperCommand,
12
- isHomeBinHookCommand,
13
- shouldWrapForTelemetry
14
- } from "./chunk-I5MLE6S7.js";
16
+ buildWrappedStdio,
17
+ isHomeBinHookCommand
18
+ } from "./chunk-TO57WYBB.js";
15
19
  import "./chunk-N6HH7K6P.js";
16
20
  import "./chunk-TRQKHP7D.js";
17
21
 
18
22
  // src/adapters/crush/index.ts
19
23
  import { existsSync, statSync } from "fs";
20
24
  import { homedir } from "os";
21
- import { dirname, join, resolve } from "path";
25
+ import { dirname, join } from "path";
22
26
  var HOST = "crush";
23
27
  var MCP_ROOT_KEY = "mcp";
24
28
  var STDIO_TIMEOUT_SECONDS = 120;
@@ -114,8 +118,7 @@ var CrushAdapter = class extends BaseAdapter {
114
118
  */
115
119
  userConfigDir() {
116
120
  if (process.platform === "win32") {
117
- const localAppData = process.env.LOCALAPPDATA && process.env.LOCALAPPDATA.trim() !== "" ? process.env.LOCALAPPDATA : resolve(homedir(), "AppData", "Local");
118
- return join(localAppData, "crush");
121
+ return join(localAppData(), "crush");
119
122
  }
120
123
  return join(homedir(), ".config", "crush");
121
124
  }
@@ -157,18 +160,7 @@ var CrushAdapter = class extends BaseAdapter {
157
160
  if (transport === "stdio") {
158
161
  let command = server.command ?? "";
159
162
  let args = [...server.args ?? []];
160
- if (shouldWrapForTelemetry(server, ctx.connector.telemetry)) {
161
- const wrapped = buildServeWrapperCommand(
162
- ctx.homeBinPath,
163
- ctx.connector.id,
164
- command,
165
- args,
166
- ctx.scope,
167
- this.id
168
- );
169
- command = wrapped.command;
170
- args = wrapped.args;
171
- }
163
+ ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));
172
164
  command = resolveEnvRefsDeep(command);
173
165
  args = resolveEnvRefsDeep(args);
174
166
  const entry2 = {
@@ -354,7 +346,7 @@ var CrushAdapter = class extends BaseAdapter {
354
346
  continue;
355
347
  }
356
348
  changes.push(
357
- this.writeContentFile(join(dir, "SKILL.md"), this.renderSkill(skill), ctx.dryRun)
349
+ this.writeContentFile(join(dir, "SKILL.md"), renderSkillMd(skill), ctx.dryRun)
358
350
  );
359
351
  for (const [rel, contents] of Object.entries(skill.resources ?? {})) {
360
352
  const target = this.resolveWithin(dir, rel);
@@ -389,25 +381,6 @@ var CrushAdapter = class extends BaseAdapter {
389
381
  }
390
382
  return changes;
391
383
  }
392
- /**
393
- * Render a skill's SKILL.md: frontmatter (name, description + optional model,
394
- * allowed-tools, disable-model-invocation) + body. UNIFORM with every other
395
- * skill-supporting platform — only the parent dir differs.
396
- */
397
- renderSkill(skill) {
398
- const frontmatter = {
399
- name: skill.name,
400
- description: skill.description
401
- };
402
- if (skill.model !== void 0) frontmatter.model = skill.model;
403
- const allow = skill.tools?.allow;
404
- if (allow && allow.length > 0) frontmatter["allowed-tools"] = allow.join(", ");
405
- if (skill.disableModelInvocation !== void 0) {
406
- frontmatter["disable-model-invocation"] = skill.disableModelInvocation;
407
- }
408
- if (skill.extra) Object.assign(frontmatter, skill.extra);
409
- return this.renderFrontmatterMd(frontmatter, skill.body);
410
- }
411
384
  // ── Diagnostics ──────────────────────────────────────────────────────────
412
385
  getHealthChecks(ctx) {
413
386
  const configPath = this.getServerConfigPath(ctx);
@@ -511,4 +484,4 @@ export {
511
484
  adapter,
512
485
  crush_default as default
513
486
  };
514
- //# sourceMappingURL=crush-GMEWLXK5.js.map
487
+ //# sourceMappingURL=crush-AH24GDDB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapters/crush/index.ts"],"sourcesContent":["/**\n * adapters/crush — Crush (Charm) platform adapter for agent-connector.\n *\n * Crush is a json-stdio host. A single JSON config file holds BOTH the MCP\n * server registrations and the hook registrations, and agent-connector MERGES\n * into it (never replaces it — unrelated keys are preserved verbatim):\n * - User scope: ~/.config/crush/crush.json\n * (Windows: %LOCALAPPDATA%\\crush\\crush.json)\n * - Project scope: ./.crush.json (preferred) or ./crush.json\n *\n * MCP servers live under the ROOT KEY \"mcp\" (NOT \"mcpServers\"). A stdio entry is\n * { type:\"stdio\", command, args, env, timeout:120, disabled:false }.\n * Hooks live under the top-level \"hooks\" key. Crush supports PreToolUse ONLY;\n * the hook reads the host's JSON on stdin and writes a JSON object on stdout\n * carrying a `decision` field. A deny is `{ decision:\"deny\", reason }` on\n * stdout (exit 0); an allow is an empty stdout (exit 0). Crush cannot rewrite\n * tool args/output nor inject session context — every non-deny decision (and\n * every non-PreToolUse event) degrades to a silent allow.\n *\n * SECURITY NOTE: Crush expands `$(...)` command substitution in its config file\n * at load time. We therefore NEVER emit shell-substitution syntax into the\n * command/args/env we write — every value is a literal path/string built by the\n * spawn helpers (which quote, not interpolate). Connector ids are kebab-case and\n * the home-bin path is an absolute literal, so nothing we write can be coerced\n * into a `$(...)` substitution.\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, NormalizedEvent } from \"../spi.js\";\nimport type {\n ChangeRecord,\n DetectedPlatform,\n HealthCheck,\n HookEventName,\n HookParadigm,\n HookResponse,\n PlatformCapabilities,\n PlatformId,\n PreToolUseEvent,\n ServerDef,\n Transport,\n} from \"../../core/types.js\";\nimport { resolveEnvRefsDeep } from \"../../core/interpolate.js\";\nimport { localAppData } from \"../../core/host-paths.js\";\nimport {\n buildHomeBinHookCommand,\n buildWrappedStdio,\n isHomeBinHookCommand,\n} from \"../../core/spawn.js\";\nimport { renderSkillMd } from \"../claude-code/render.js\";\n\nconst HOST: PlatformId = \"crush\";\n/** Crush registers MCP servers under \"mcp\" — NOT the \"mcpServers\" of Claude/Gemini. */\nconst MCP_ROOT_KEY = \"mcp\";\n/** Default per-server timeout (seconds) Crush expects on a stdio entry. */\nconst STDIO_TIMEOUT_SECONDS = 120;\n\n/**\n * Crush hook events agent-connector can register. Crush honors PreToolUse ONLY,\n * and only its deny decision is meaningful; every other normalized event has no\n * Crush equivalent and is skipped at install time.\n */\nconst CRUSH_HOOK_EVENTS = [\"PreToolUse\"] as const;\ntype CrushHookEventName = (typeof CRUSH_HOOK_EVENTS)[number];\n\n/**\n * Newer canonical events with NO Crush analog: there is no permission-dialog,\n * tool-failure, or subagent lifecycle hook. Declared hooks for these warn-skip\n * at install so the degradation is reported, never silent. (The legacy silent\n * drop of the other unwired events — SessionStart, Stop, … — predates this\n * convention and is deliberately left untouched.)\n */\nconst WARN_SKIP_EVENTS: ReadonlySet<HookEventName> = new Set([\n \"PermissionRequest\",\n \"PostToolUseFailure\",\n \"SubagentStart\",\n \"SubagentStop\",\n]);\n\n// ─────────────────────────────────────────────────────────────────────────\n// Native config shapes (only the parts we touch; rest preserved verbatim)\n// ─────────────────────────────────────────────────────────────────────────\n\n/** One hook registration entry as Crush stores it under top-level \"hooks\". */\ninterface CrushHookEntry {\n matcher?: string;\n command: string;\n [key: string]: unknown;\n}\n\n/** Crush's crush.json shape — only the keys we read/merge. */\ninterface CrushConfigFile {\n mcp?: Record<string, unknown>;\n hooks?: Record<string, CrushHookEntry[]>;\n [key: string]: unknown;\n}\n\n/** Native stdio MCP server entry under \"mcp\". */\ninterface CrushStdioServer {\n type: \"stdio\";\n command: string;\n args: string[];\n env?: Record<string, string>;\n timeout: number;\n disabled: boolean;\n}\n\n/** Native HTTP MCP server entry under \"mcp\". */\ninterface CrushHttpServer {\n type: \"http\";\n url: string;\n headers?: Record<string, string>;\n timeout: number;\n disabled: boolean;\n}\n\n/** Raw Crush hook stdin payload (Claude-style: PascalCase event, snake_case fields). */\ninterface CrushHookInput {\n tool_name?: string;\n tool_input?: Record<string, unknown>;\n session_id?: string;\n cwd?: string;\n hook_event_name?: string;\n connector?: unknown;\n}\n\nexport class CrushAdapter extends BaseAdapter implements Adapter {\n readonly id: PlatformId = HOST;\n readonly name = \"Crush\";\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 // PreToolUse deny is the only hook decision Crush honors.\n preToolUse: true,\n postToolUse: false,\n preCompact: false,\n sessionStart: false,\n sessionEnd: false,\n userPromptSubmit: false,\n stop: false,\n notification: false,\n // Newer events: Crush honors PreToolUse ONLY — no permission-dialog,\n // tool-failure, or subagent lifecycle events exist, so permissionRequest /\n // postToolUseFailure / subagentStart / subagentStop stay unset — install\n // reports the standard skip-warn for them.\n // Crush is deny-only: it cannot rewrite tool args/output nor inject context.\n canModifyArgs: false,\n canModifyOutput: false,\n canInjectSessionContext: false,\n transports: [\"stdio\", \"http\"],\n // Content surface: Crush auto-discovers Agent-Skills dirs (dir-per-skill\n // SKILL.md). Paths are HARD-CODED — no crush.json entry needed\n // (charmbracelet/crush internal/config/load.go GlobalSkillsDirs +\n // ProjectSkillsDir, fetched 2026-06-16):\n // project → <projectDir>/.crush/skills/<name>/SKILL.md (crush-native, in\n // projectSkillSubdirs; preferred over .agents/.claude/.cursor)\n // user → ~/.config/crush/skills/<name>/SKILL.md (home.Config()/crush/\n // skills; XDG_CONFIG_HOME or ~/.config).\n supportsSkills: true,\n };\n\n // ── Detection ────────────────────────────────────────────────────────────\n\n detectInstalled(projectDir: string): DetectedPlatform {\n const userDir = this.userConfigDir();\n const userConfig = join(userDir, \"crush.json\");\n const projectDot = join(projectDir, \".crush.json\");\n const projectBare = join(projectDir, \"crush.json\");\n const userInstalled = existsSync(userDir) || existsSync(userConfig);\n const projInstalled = existsSync(projectDot) || existsSync(projectBare);\n const installed = userInstalled || projInstalled;\n // Report the scope/path that actually matched so a project-only install is\n // not misreported as a (non-existent) user install.\n const scope = projInstalled && !userInstalled ? \"project\" : \"user\";\n const projectPath = existsSync(projectBare) && !existsSync(projectDot) ? projectBare : projectDot;\n const configPath = scope === \"project\" ? projectPath : userConfig;\n return {\n id: this.id,\n name: this.name,\n installed,\n paradigm: this.paradigm,\n capabilities: this.capabilities,\n configPath,\n scope,\n reason: installed\n ? scope === \"project\"\n ? `found project Crush config at ${configPath}`\n : `found Crush config under ${userDir}`\n : `no Crush config at ${userConfig}`,\n confidence: installed ? \"high\" : \"low\",\n };\n }\n\n // ── Native paths ─────────────────────────────────────────────────────────\n\n getConfigDir(ctx: InstallContext): string {\n return ctx.scope === \"project\" ? ctx.projectDir : this.userConfigDir();\n }\n\n /** MCP servers and hooks share ONE crush.json file. */\n getServerConfigPath(ctx: InstallContext): string {\n if (ctx.scope === \"project\") {\n // Prefer ./.crush.json, but MERGE into an existing ./crush.json if that is\n // the file already present (so we don't fork the user's config in two).\n const dot = join(ctx.projectDir, \".crush.json\");\n const bare = join(ctx.projectDir, \"crush.json\");\n if (existsSync(bare) && !existsSync(dot)) return bare;\n return dot;\n }\n return join(this.userConfigDir(), \"crush.json\");\n }\n\n /** Hooks live in the SAME crush.json under the top-level \"hooks\" key. */\n getHookConfigPath(ctx: InstallContext): string {\n return this.getServerConfigPath(ctx);\n }\n\n /**\n * Crush's user config dir:\n * - Windows: %LOCALAPPDATA%\\crush (Local; falls back to AppData/Local)\n * - macOS / Linux: ~/.config/crush\n */\n private userConfigDir(): string {\n if (process.platform === \"win32\") {\n return join(localAppData(), \"crush\");\n }\n return join(homedir(), \".config\", \"crush\");\n }\n\n // ── MCP server install / uninstall (crush.json → mcp.<id>) ───────────────\n\n installServer(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n const override = connector.platforms[HOST]?.server;\n if (!connector.server || override === false) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n detail: connector.server\n ? \"server registration disabled for crush\"\n : \"connector declares no MCP server\",\n },\n ];\n }\n\n // Shallow-merge any per-platform server override into the base ServerDef.\n const server: ServerDef =\n override && typeof override === \"object\"\n ? { ...connector.server, ...override }\n : connector.server;\n\n const serverPath = this.getServerConfigPath(ctx);\n const entry = this.renderServerEntry(ctx, server);\n\n return [\n this.upsertServerInJson(serverPath, MCP_ROOT_KEY, connector.id, entry, ctx.dryRun),\n ];\n }\n\n uninstallServer(ctx: InstallContext): ChangeRecord[] {\n const serverPath = this.getServerConfigPath(ctx);\n return [\n this.removeServerFromJson(serverPath, MCP_ROOT_KEY, ctx.connector.id, ctx.dryRun),\n ];\n }\n\n /**\n * Render a normalized ServerDef into Crush's native \"mcp\" entry. Crush has no\n * documented native `${env:VAR}` interpolation — and it expands `$(...)` at\n * load time — so refs are resolved to LITERALS at install time (the safe\n * posture for a host without native interpolation, matching Codex/Kimi).\n */\n private renderServerEntry(\n ctx: InstallContext,\n server: ServerDef,\n ): CrushStdioServer | CrushHttpServer {\n const transport: Transport = server.transport;\n const disabled = server.enabled === false;\n\n if (transport === \"stdio\") {\n let command = server.command ?? \"\";\n let args = [...(server.args ?? [])];\n\n // Transparent telemetry wrapping: route the real command through\n // `<homeBin> serve --connector <id> -- <command> <args...>`.\n ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));\n\n // Resolve to literals — never emit `$(...)` Crush would expand at load.\n command = resolveEnvRefsDeep(command);\n args = resolveEnvRefsDeep(args);\n\n const entry: CrushStdioServer = {\n type: \"stdio\",\n command,\n args,\n timeout: STDIO_TIMEOUT_SECONDS,\n disabled,\n };\n const env = this.renderEnv(server.env);\n if (env) entry.env = env;\n return entry;\n }\n\n // http (and any other remote transport we surface) — Crush registers a URL.\n const entry: CrushHttpServer = {\n type: \"http\",\n url: resolveEnvRefsDeep(server.url ?? \"\"),\n timeout: STDIO_TIMEOUT_SECONDS,\n disabled,\n };\n const headers = this.renderEnv(server.headers);\n if (headers) entry.headers = headers;\n return entry;\n }\n\n /** Resolve env/header values to literals (no native interpolation on Crush). */\n private renderEnv(\n env: Record<string, string> | undefined,\n ): Record<string, string> | undefined {\n if (!env || Object.keys(env).length === 0) return undefined;\n const out: Record<string, string> = {};\n for (const [k, v] of Object.entries(resolveEnvRefsDeep({ ...env }))) {\n out[k] = String(v);\n }\n return out;\n }\n\n // ── Hook install / uninstall (crush.json → hooks.PreToolUse[]) ───────────\n\n installHooks(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.hooks === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"hooks disabled for crush\" }];\n }\n\n const events = this.effectiveHookEvents(ctx);\n const dropped = this.warnSkipHookEvents(ctx);\n const path = this.getHookConfigPath(ctx);\n\n if (events.length === 0 && dropped.length === 0) {\n return [{ platform: this.id, action: \"skip\", path, detail: \"no hooks declared\" }];\n }\n\n const cfg = this.readJson<CrushConfigFile>(path) ?? {};\n const __skip = this.malformedHookRootSkip(path, (cfg as Record<string, unknown>).hooks);\n if (__skip) return [__skip];\n const hooks = (cfg.hooks ??= {});\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n // Declared events Crush cannot fire are reported, never silently dropped.\n for (const event of dropped) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n path,\n detail: `${event} has no Crush hook equivalent — skipped`,\n });\n }\n\n for (const event of events) {\n const command = buildHomeBinHookCommand(ctx.homeBinPath, HOST, event, connector.id);\n const matcher = connector.hooks[event]?.matcher ?? \"\";\n const entry: CrushHookEntry = { matcher, command };\n\n const bucket = (hooks[event] ??= []);\n const existingIdx = bucket.findIndex((e) => this.isOurHook(e, ctx));\n\n if (existingIdx >= 0) {\n if (JSON.stringify(bucket[existingIdx]) === JSON.stringify(entry)) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path,\n detail: `hooks.${event} already registered`,\n });\n continue;\n }\n bucket[existingIdx] = entry;\n changes.push({ platform: this.id, action: \"update\", path, detail: `hooks.${event}` });\n } else {\n bucket.push(entry);\n changes.push({ platform: this.id, action: \"create\", path, detail: `hooks.${event}` });\n }\n mutated = true;\n }\n\n if (mutated) this.writeJson(path, cfg, ctx.dryRun);\n return changes;\n }\n\n uninstallHooks(ctx: InstallContext): ChangeRecord[] {\n const path = this.getHookConfigPath(ctx);\n const cfg = this.readJson<CrushConfigFile>(path);\n const hooks = cfg?.hooks;\n if (!cfg || !hooks) {\n return [\n { platform: this.id, action: \"skip\", path, detail: \"no hooks section present\" },\n ];\n }\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n for (const event of Object.keys(hooks)) {\n const bucket = hooks[event];\n if (!Array.isArray(bucket)) continue;\n\n // Keep every entry that is NOT ours (anchored match) so a shared-prefix\n // connector id — or the user's own hook — is never stripped.\n const kept = bucket.filter((e) => !this.isOurHook(e, ctx));\n const removed = bucket.length - kept.length;\n if (removed > 0) {\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.${event} (${removed})`,\n });\n mutated = true;\n }\n }\n\n if (mutated) this.writeJson(path, cfg, ctx.dryRun);\n if (changes.length === 0) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path,\n detail: \"no matching hook entries\",\n });\n }\n return changes;\n }\n\n // ── Internal helpers ─────────────────────────────────────────────────────\n\n /** Which canonical hook events to register for Crush, honoring overrides. */\n private effectiveHookEvents(ctx: InstallContext): CrushHookEventName[] {\n if (ctx.connector.platforms[HOST]?.hooks === false) return [];\n return CRUSH_HOOK_EVENTS.filter((e) => ctx.connector.hookEvents.includes(e));\n }\n\n /** Declared events Crush has no analog for — install reports a warn-skip. */\n private warnSkipHookEvents(ctx: InstallContext): HookEventName[] {\n if (ctx.connector.platforms[HOST]?.hooks === false) return [];\n return ctx.connector.hookEvents.filter((e) => WARN_SKIP_EVENTS.has(e));\n }\n\n /**\n * Does this hook entry belong to this connector? Anchored on the home-bin +\n * connector-id token (isHomeBinHookCommand) so uninstalling a shared-prefix\n * connector id never strips a sibling's hook.\n */\n private isOurHook(entry: CrushHookEntry | undefined, ctx: InstallContext): boolean {\n if (!entry || typeof entry !== \"object\") return false;\n return isHomeBinHookCommand(entry.command, ctx.homeBinPath, ctx.connector.id);\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. Each write is\n // idempotent (byte-identical → skip) via writeContentFile and reversible via\n // removeContentFile + removeDirIfEmpty (never rm -rf a shared dir). Honors\n // platforms[\"crush\"].skills === false. No crush.json entry is written — Crush\n // auto-discovers these hard-coded dirs (load.go GlobalSkillsDirs/ProjectSkillsDir).\n //\n // Native locations (Agent-Skills spec — dir-per-skill SKILL.md + resources):\n // project → <projectDir>/.crush/skills/<name>/SKILL.md\n // user → ~/.config/crush/skills/<name>/SKILL.md\n\n /** The skills ROOT dir for ctx.scope (parent of every per-skill dir). */\n private skillsDir(ctx: InstallContext): string {\n return ctx.scope === \"project\"\n ? join(ctx.projectDir, \".crush\", \"skills\")\n : join(this.userConfigDir(), \"skills\");\n }\n\n /** Per-skill directory: <skillsDir>/<name>. */\n private skillDir(ctx: InstallContext, name: string): string {\n return join(this.skillsDir(ctx), name);\n }\n\n override installSkills(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (connector.platforms[HOST]?.skills === false) {\n return [{ platform: this.id, action: \"skip\", detail: \"skills disabled for crush\" }];\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 // 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 per-skill dir or any parent up to the scope root counts.\n const blockingFile = firstFileOnPath(this.skillsDir(ctx), 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 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 configPath = this.getServerConfigPath(ctx);\n const connectorId = ctx.connector.id;\n const homeBin = ctx.homeBinPath;\n const hookEvents = this.effectiveHookEvents(ctx);\n return [\n {\n name: `${this.name}: crush.json present`,\n check: () =>\n existsSync(configPath)\n ? { status: \"OK\", detail: configPath }\n : { status: \"FAIL\", detail: `not found: ${configPath}` },\n },\n {\n name: `${this.name}: mcp.${connectorId} registered`,\n check: () => {\n if (!ctx.connector.server) return { status: \"OK\", detail: \"no MCP server declared\" };\n const cfg = this.readJson<CrushConfigFile>(configPath);\n const bucket = cfg?.[MCP_ROOT_KEY];\n const present =\n typeof bucket === \"object\" && bucket !== null && connectorId in bucket;\n return present\n ? { status: \"OK\", detail: `mcp.${connectorId}` }\n : { status: \"FAIL\", detail: `mcp.${connectorId} not found in ${configPath}` };\n },\n },\n {\n name: `${this.name}: hook command registered`,\n check: () => {\n if (hookEvents.length === 0) {\n return { status: \"OK\", detail: \"no hooks declared\" };\n }\n const cfg = this.readJson<CrushConfigFile>(configPath);\n if (!cfg) return { status: \"FAIL\", detail: `cannot read ${configPath}` };\n const hooks = cfg.hooks ?? {};\n const registered = Object.values(hooks).some((entries) =>\n (entries ?? []).some((e) => isHomeBinHookCommand(e?.command, homeBin, connectorId)),\n );\n return registered\n ? { status: \"OK\", detail: \"hook command present\" }\n : { status: \"FAIL\", detail: `no hook for ${connectorId} in ${configPath}` };\n },\n },\n ];\n }\n\n // ── Runtime: parse Crush stdin JSON → normalized event ───────────────────\n\n parseEvent(event: HookEventName, raw: unknown): NormalizedEvent {\n const input = (raw ?? {}) as CrushHookInput;\n const connectorId = typeof input.connector === \"string\" ? input.connector : \"\";\n const sessionId = typeof input.session_id === \"string\" ? input.session_id : \"\";\n const projectDir = typeof input.cwd === \"string\" ? input.cwd : undefined;\n\n const base = {\n hostPlatform: HOST,\n connectorId,\n sessionId,\n raw,\n ...(projectDir !== undefined ? { projectDir } : {}),\n } as const;\n\n if (event === \"PreToolUse\") {\n const ev: PreToolUseEvent = {\n ...base,\n toolName: input.tool_name ?? \"\",\n toolInput: input.tool_input ?? {},\n };\n return ev;\n }\n\n // Crush only ever delivers PreToolUse. Surface anything else loudly rather\n // than silently mis-parsing a payload the host cannot actually produce.\n throw new Error(`unsupported crush hook event: ${String(event)}`);\n }\n\n // ── Runtime: normalized response → Crush native hook reply ───────────────\n\n formatReply(event: HookEventName, response: HookResponse): HookReply {\n const decision = response.decision ?? \"allow\";\n\n // deny → Crush blocks the pending tool call via a stdout JSON object with a\n // `decision:\"deny\"` (+ reason). Only PreToolUse is honored; every other\n // event/decision degrades to a silent allow.\n if (decision === \"deny\" && event === \"PreToolUse\") {\n return this.stdout({\n decision: \"deny\",\n reason: response.reason ?? \"Blocked by hook\",\n });\n }\n\n // allow / modify / context / ask / unsupported → pass through (exit 0, empty\n // stdout). Crush cannot rewrite args/output or inject context, so those are\n // dropped fail-open here (the deny path above is the only fail-safe lever).\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 * Walk every path segment from `root` down to (and including) `leaf` and return\n * the FIRST one that exists as a regular file (which would make a mkdir for the\n * skill dir throw ENOTDIR), else null. Used to skip-warn instead of crashing\n * when a user has a `.crush/skills` file where we need a directory.\n */\nfunction firstFileOnPath(root: string, leaf: string): string | null {\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; // nothing planted from here down\n try {\n if (statSync(p).isFile()) return p;\n } catch {\n return null;\n }\n }\n return null;\n}\n\nexport const adapter = new CrushAdapter();\nexport default adapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAS,YAAY,gBAAgB;AACrC,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY;AA0B9B,IAAM,OAAmB;AAEzB,IAAM,eAAe;AAErB,IAAM,wBAAwB;AAO9B,IAAM,oBAAoB,CAAC,YAAY;AAUvC,IAAM,mBAA+C,oBAAI,IAAI;AAAA,EAC3D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAiDM,IAAM,eAAN,cAA2B,YAA+B;AAAA,EACtD,KAAiB;AAAA,EACjB,OAAO;AAAA,EACP,WAAyB;AAAA,EAEzB,eAAqC;AAAA;AAAA;AAAA,IAG5C,gBAAgB;AAAA;AAAA,IAEhB,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,IAMd,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,yBAAyB;AAAA,IACzB,YAAY,CAAC,SAAS,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAS5B,gBAAgB;AAAA,EAClB;AAAA;AAAA,EAIA,gBAAgB,YAAsC;AACpD,UA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AAI,MAAM;AACV,SAAO,IAAI,UAAU,KAAK,QAAQ;AAChC,aAAS,QAAQ,GAAG;AACpB,QAAI,QAAQ,KAAM;AAClB,UAAM,SAAS,QAAQ,GAAG;AAC1B,QAAI,WAAW,IAAK;AACpB,UAAM;AAAA,EACR;AACA,aAAW,KAAK,UAAU;AACxB,QAAI,CAAC,WAAW,CAAC,EAAG,QAAO;AAC3B,QAAI;AACF,UAAI,SAAS,CAAC,EAAE,OAAO,EAAG,QAAO;AAAA,IACnC,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEO,IAAM,UAAU,IAAI,aAAa;AACxC,IAAO,gBAAQ;","names":["entry"]}
@@ -1,16 +1,20 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ normalizeSessionSource
4
+ } from "./chunk-H53QZQJI.js";
2
5
  import {
3
6
  rewriteEnvRefs
4
7
  } from "./chunk-DBQMX75U.js";
5
8
  import {
6
9
  BaseAdapter
7
- } from "./chunk-PFDUGDOA.js";
8
- import "./chunk-7L6ITC4T.js";
10
+ } from "./chunk-KG6T3YNJ.js";
11
+ import {
12
+ renderSkillMd
13
+ } from "./chunk-IEGR4TP3.js";
9
14
  import {
10
- buildServeWrapperCommand,
11
- isHomeBinHookCommand,
12
- shouldWrapForTelemetry
13
- } from "./chunk-I5MLE6S7.js";
15
+ buildWrappedStdio,
16
+ isHomeBinHookCommand
17
+ } from "./chunk-TO57WYBB.js";
14
18
  import "./chunk-N6HH7K6P.js";
15
19
  import "./chunk-TRQKHP7D.js";
16
20
 
@@ -163,18 +167,7 @@ var CursorAdapter = class extends BaseAdapter {
163
167
  if (transport === "stdio") {
164
168
  let command = server.command ?? "";
165
169
  let args = [...server.args ?? []];
166
- if (shouldWrapForTelemetry(server, ctx.connector.telemetry)) {
167
- const wrapped = buildServeWrapperCommand(
168
- ctx.homeBinPath,
169
- ctx.connector.id,
170
- command,
171
- args,
172
- ctx.scope,
173
- this.id
174
- );
175
- command = wrapped.command;
176
- args = wrapped.args;
177
- }
170
+ ({ command, args } = buildWrappedStdio(ctx, server, this.id, command, args));
178
171
  const entry2 = { command: this.rewrite(command) };
179
172
  if (args.length > 0) entry2.args = args.map((a) => this.rewrite(a));
180
173
  const env = this.renderEnv(server.env);
@@ -359,7 +352,7 @@ ${cmd.prompt}
359
352
  for (const skill of connector.skills) {
360
353
  const dir = this.skillDir(ctx, skill.name);
361
354
  changes.push(
362
- this.writeContentFile(join(dir, "SKILL.md"), this.renderSkill(skill), ctx.dryRun)
355
+ this.writeContentFile(join(dir, "SKILL.md"), renderSkillMd(skill), ctx.dryRun)
363
356
  );
364
357
  for (const [rel, contents] of Object.entries(skill.resources ?? {})) {
365
358
  const target = this.resolveWithin(dir, rel);
@@ -394,25 +387,6 @@ ${cmd.prompt}
394
387
  }
395
388
  return changes;
396
389
  }
397
- /**
398
- * Render a skill's SKILL.md: frontmatter (name, description + optional model,
399
- * allowed-tools, disable-model-invocation) + body. Uniform across platforms;
400
- * only the parent dir differs.
401
- */
402
- renderSkill(skill) {
403
- const frontmatter = {
404
- name: skill.name,
405
- description: skill.description
406
- };
407
- if (skill.model !== void 0) frontmatter.model = skill.model;
408
- const allow = skill.tools?.allow;
409
- if (allow && allow.length > 0) frontmatter["allowed-tools"] = allow.join(", ");
410
- if (skill.disableModelInvocation !== void 0) {
411
- frontmatter["disable-model-invocation"] = skill.disableModelInvocation;
412
- }
413
- if (skill.extra) Object.assign(frontmatter, skill.extra);
414
- return this.renderFrontmatterMd(frontmatter, skill.body);
415
- }
416
390
  // ── Subagents ───────────────────────────────────────────────────────────────
417
391
  installSubagents(ctx) {
418
392
  const { connector } = ctx;
@@ -661,18 +635,6 @@ function extractSessionId(input) {
661
635
  if (typeof input.session_id === "string") return input.session_id;
662
636
  return "";
663
637
  }
664
- function normalizeSessionSource(source) {
665
- switch (source) {
666
- case "compact":
667
- return "compact";
668
- case "resume":
669
- return "resume";
670
- case "clear":
671
- return "clear";
672
- default:
673
- return "startup";
674
- }
675
- }
676
638
  var adapter = new CursorAdapter();
677
639
  var cursor_default = adapter;
678
640
  export {
@@ -680,4 +642,4 @@ export {
680
642
  adapter,
681
643
  cursor_default as default
682
644
  };
683
- //# sourceMappingURL=cursor-JBS4B3Q4.js.map
645
+ //# sourceMappingURL=cursor-GJBSMXI6.js.map