@ken-jo/agent-connector 0.4.6 → 0.4.7

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 (153) hide show
  1. package/dist/{action-EV63GAPY.js → action-YCU53FNE.js} +8 -8
  2. package/dist/{amazon-q-COAL3764.js → amazon-q-W574ZX35.js} +2 -2
  3. package/dist/{amp-XJQ4TDAU.js → amp-JPBQJJVM.js} +2 -2
  4. package/dist/{antigravity-AMKKKHS4.js → antigravity-VK2Y3FGV.js} +3 -3
  5. package/dist/{antigravity-cli-XERXEH5W.js → antigravity-cli-D4PCCUG2.js} +3 -3
  6. package/dist/{chunk-BMD7ANKF.js → chunk-2F5QH3D4.js} +36 -36
  7. package/dist/{chunk-5G4EPJ4Y.js → chunk-6RYPUR6O.js} +5 -5
  8. package/dist/{chunk-2X4EH2D7.js → chunk-7ECYDK5T.js} +2 -2
  9. package/dist/{chunk-QC5A3TFQ.js → chunk-CYOAH23F.js} +18 -18
  10. package/dist/{chunk-RQPKL62M.js → chunk-DT6Y7XBI.js} +2 -2
  11. package/dist/{chunk-QOGMDOUX.js → chunk-HAIMYUEY.js} +3 -3
  12. package/dist/{chunk-DCK5FADX.js → chunk-MDNX7HTN.js} +2 -2
  13. package/dist/{chunk-EXLS7BSI.js → chunk-NLFPH4S2.js} +10 -2
  14. package/dist/chunk-NLFPH4S2.js.map +1 -0
  15. package/dist/{chunk-CPLK7GTE.js → chunk-PFDUGDOA.js} +351 -34
  16. package/dist/chunk-PFDUGDOA.js.map +1 -0
  17. package/dist/{chunk-EROJDXMW.js → chunk-SDPIT4HW.js} +2 -2
  18. package/dist/{chunk-H67V7DEL.js → chunk-SPWFUHHK.js} +5 -5
  19. package/dist/{chunk-LQRAPXS4.js → chunk-TZQBASI7.js} +4 -2
  20. package/dist/chunk-TZQBASI7.js.map +1 -0
  21. package/dist/{chunk-SRVAA2VN.js → chunk-WFXWJITA.js} +2 -2
  22. package/dist/{chunk-MZF2YCXX.js → chunk-YQLQJZ7S.js} +2 -2
  23. package/dist/{claude-code-T2LPFNC3.js → claude-code-ROSIILTM.js} +36 -100
  24. package/dist/claude-code-ROSIILTM.js.map +1 -0
  25. package/dist/cli/sdk.js +4 -4
  26. package/dist/cli.js +1 -1
  27. package/dist/{cline-WRYMNS7Z.js → cline-JUTO4V27.js} +2 -2
  28. package/dist/{codebuff-PODYPOOP.js → codebuff-2QUHL6HO.js} +2 -2
  29. package/dist/{codex-O4G7D7KK.js → codex-YBBTIDD4.js} +91 -112
  30. package/dist/codex-YBBTIDD4.js.map +1 -0
  31. package/dist/{continue-K43SUHLQ.js → continue-W4TU4JSB.js} +5 -3
  32. package/dist/continue-W4TU4JSB.js.map +1 -0
  33. package/dist/{copilot-cli-Q3SSPT4V.js → copilot-cli-Y74SOP5G.js} +4 -2
  34. package/dist/copilot-cli-Y74SOP5G.js.map +1 -0
  35. package/dist/{crush-MBEH2R3I.js → crush-GMEWLXK5.js} +4 -2
  36. package/dist/{crush-MBEH2R3I.js.map → crush-GMEWLXK5.js.map} +1 -1
  37. package/dist/{cursor-TMBXDYR4.js → cursor-JBS4B3Q4.js} +50 -134
  38. package/dist/cursor-JBS4B3Q4.js.map +1 -0
  39. package/dist/{detect-AHJIUMBO.js → detect-2NIXILMZ.js} +4 -4
  40. package/dist/{doctor-G5MLCPAB.js → doctor-QWJBWALA.js} +8 -8
  41. package/dist/{droid-JC2NT6S4.js → droid-TJMTNCQE.js} +48 -106
  42. package/dist/droid-TJMTNCQE.js.map +1 -0
  43. package/dist/{gemini-cli-ILR7M5X3.js → gemini-cli-RAONGZRG.js} +7 -2
  44. package/dist/gemini-cli-RAONGZRG.js.map +1 -0
  45. package/dist/{goose-SFO5BBGW.js → goose-G4KKM6YU.js} +91 -131
  46. package/dist/goose-G4KKM6YU.js.map +1 -0
  47. package/dist/{hermes-3N7WN4WS.js → hermes-PJDTJE6F.js} +29 -33
  48. package/dist/hermes-PJDTJE6F.js.map +1 -0
  49. package/dist/{hook-76JBKTUX.js → hook-FDGIQPRC.js} +8 -8
  50. package/dist/index.js +2 -2
  51. package/dist/{install-R7252QFH.js → install-TLG3QVP3.js} +8 -8
  52. package/dist/{jetbrains-copilot-NRZHI5PC.js → jetbrains-copilot-DNXSLQE5.js} +4 -2
  53. package/dist/jetbrains-copilot-DNXSLQE5.js.map +1 -0
  54. package/dist/{kilo-IX4T3OHJ.js → kilo-FERJ3X46.js} +2 -2
  55. package/dist/{kilo-cli-2AYCXBQD.js → kilo-cli-TDCONH5G.js} +2 -2
  56. package/dist/{kimi-2YFK2GBA.js → kimi-RIRD4J5J.js} +12 -2
  57. package/dist/kimi-RIRD4J5J.js.map +1 -0
  58. package/dist/{kiro-YL6AWUYG.js → kiro-X7JVLAN7.js} +4 -2
  59. package/dist/kiro-X7JVLAN7.js.map +1 -0
  60. package/dist/{leaderboard-V6VWA5ZV.js → leaderboard-MXGENYXN.js} +2 -2
  61. package/dist/{mimo-code-FTMGSKMQ.js → mimo-code-RFLQ727H.js} +2 -2
  62. package/dist/{mux-5XZFB44C.js → mux-D77HBSBU.js} +3 -17
  63. package/dist/mux-D77HBSBU.js.map +1 -0
  64. package/dist/{nemoclaw-CQYXZVQN.js → nemoclaw-LXUTMR56.js} +3 -3
  65. package/dist/{omp-2QMEY6HD.js → omp-CO7IXURG.js} +2 -2
  66. package/dist/{openclaw-UZC437RW.js → openclaw-XWJLEW35.js} +3 -3
  67. package/dist/{opencode-L4BGFP25.js → opencode-QKZ5EIYU.js} +2 -2
  68. package/dist/{package-DNLQTPNN.js → package-IA56LSC3.js} +6 -6
  69. package/dist/{pi-PVVPVWKG.js → pi-YGBXYWY5.js} +2 -2
  70. package/dist/{qwen-code-G4CXKUHR.js → qwen-code-E2MSEZK6.js} +55 -123
  71. package/dist/qwen-code-E2MSEZK6.js.map +1 -0
  72. package/dist/{roo-code-67TYJIQR.js → roo-code-AGGJ473T.js} +2 -2
  73. package/dist/runtime/index.js +6 -6
  74. package/dist/sdk/index.js +3 -3
  75. package/dist/sdk/test.js +5 -5
  76. package/dist/{serve-EOVWYBGZ.js → serve-RNUCK5F7.js} +8 -8
  77. package/dist/{status-VTD6XXLW.js → status-JOX6RLJU.js} +6 -6
  78. package/dist/{statusline-3ET5YPQ5.js → statusline-ZVFI5DRT.js} +7 -7
  79. package/dist/{telemetry-QCTMKDBQ.js → telemetry-3FN6HDVU.js} +5 -5
  80. package/dist/{trae-7CZZGOGI.js → trae-6L226ZDU.js} +2 -2
  81. package/dist/{uninstall-FL3SH2DT.js → uninstall-SCKZYB4J.js} +8 -8
  82. package/dist/{upgrade-SLFG2FCT.js → upgrade-WU3KZWR4.js} +8 -8
  83. package/dist/{usage-IRBLVUZM.js → usage-G72SF7JG.js} +2 -2
  84. package/dist/{usage-event-VFF77WYY.js → usage-event-DHSEBO5T.js} +7 -7
  85. package/dist/{vscode-copilot-MF2CDNMT.js → vscode-copilot-6EOZDLXC.js} +4 -2
  86. package/dist/vscode-copilot-6EOZDLXC.js.map +1 -0
  87. package/dist/{warp-VKG55TAT.js → warp-N5YYN5BF.js} +2 -2
  88. package/dist/{windsurf-FU5G4SHF.js → windsurf-4TGSJIVV.js} +2 -2
  89. package/dist/{zed-SFUHL3GS.js → zed-6P2UFWXU.js} +2 -2
  90. package/package.json +1 -1
  91. package/dist/chunk-CPLK7GTE.js.map +0 -1
  92. package/dist/chunk-EXLS7BSI.js.map +0 -1
  93. package/dist/chunk-LQRAPXS4.js.map +0 -1
  94. package/dist/claude-code-T2LPFNC3.js.map +0 -1
  95. package/dist/codex-O4G7D7KK.js.map +0 -1
  96. package/dist/continue-K43SUHLQ.js.map +0 -1
  97. package/dist/copilot-cli-Q3SSPT4V.js.map +0 -1
  98. package/dist/cursor-TMBXDYR4.js.map +0 -1
  99. package/dist/droid-JC2NT6S4.js.map +0 -1
  100. package/dist/gemini-cli-ILR7M5X3.js.map +0 -1
  101. package/dist/goose-SFO5BBGW.js.map +0 -1
  102. package/dist/hermes-3N7WN4WS.js.map +0 -1
  103. package/dist/jetbrains-copilot-NRZHI5PC.js.map +0 -1
  104. package/dist/kimi-2YFK2GBA.js.map +0 -1
  105. package/dist/kiro-YL6AWUYG.js.map +0 -1
  106. package/dist/mux-5XZFB44C.js.map +0 -1
  107. package/dist/qwen-code-G4CXKUHR.js.map +0 -1
  108. package/dist/vscode-copilot-MF2CDNMT.js.map +0 -1
  109. /package/dist/{action-EV63GAPY.js.map → action-YCU53FNE.js.map} +0 -0
  110. /package/dist/{amazon-q-COAL3764.js.map → amazon-q-W574ZX35.js.map} +0 -0
  111. /package/dist/{amp-XJQ4TDAU.js.map → amp-JPBQJJVM.js.map} +0 -0
  112. /package/dist/{antigravity-AMKKKHS4.js.map → antigravity-VK2Y3FGV.js.map} +0 -0
  113. /package/dist/{antigravity-cli-XERXEH5W.js.map → antigravity-cli-D4PCCUG2.js.map} +0 -0
  114. /package/dist/{chunk-BMD7ANKF.js.map → chunk-2F5QH3D4.js.map} +0 -0
  115. /package/dist/{chunk-5G4EPJ4Y.js.map → chunk-6RYPUR6O.js.map} +0 -0
  116. /package/dist/{chunk-2X4EH2D7.js.map → chunk-7ECYDK5T.js.map} +0 -0
  117. /package/dist/{chunk-QC5A3TFQ.js.map → chunk-CYOAH23F.js.map} +0 -0
  118. /package/dist/{chunk-RQPKL62M.js.map → chunk-DT6Y7XBI.js.map} +0 -0
  119. /package/dist/{chunk-QOGMDOUX.js.map → chunk-HAIMYUEY.js.map} +0 -0
  120. /package/dist/{chunk-DCK5FADX.js.map → chunk-MDNX7HTN.js.map} +0 -0
  121. /package/dist/{chunk-EROJDXMW.js.map → chunk-SDPIT4HW.js.map} +0 -0
  122. /package/dist/{chunk-H67V7DEL.js.map → chunk-SPWFUHHK.js.map} +0 -0
  123. /package/dist/{chunk-SRVAA2VN.js.map → chunk-WFXWJITA.js.map} +0 -0
  124. /package/dist/{chunk-MZF2YCXX.js.map → chunk-YQLQJZ7S.js.map} +0 -0
  125. /package/dist/{cline-WRYMNS7Z.js.map → cline-JUTO4V27.js.map} +0 -0
  126. /package/dist/{codebuff-PODYPOOP.js.map → codebuff-2QUHL6HO.js.map} +0 -0
  127. /package/dist/{detect-AHJIUMBO.js.map → detect-2NIXILMZ.js.map} +0 -0
  128. /package/dist/{doctor-G5MLCPAB.js.map → doctor-QWJBWALA.js.map} +0 -0
  129. /package/dist/{hook-76JBKTUX.js.map → hook-FDGIQPRC.js.map} +0 -0
  130. /package/dist/{install-R7252QFH.js.map → install-TLG3QVP3.js.map} +0 -0
  131. /package/dist/{kilo-IX4T3OHJ.js.map → kilo-FERJ3X46.js.map} +0 -0
  132. /package/dist/{kilo-cli-2AYCXBQD.js.map → kilo-cli-TDCONH5G.js.map} +0 -0
  133. /package/dist/{leaderboard-V6VWA5ZV.js.map → leaderboard-MXGENYXN.js.map} +0 -0
  134. /package/dist/{mimo-code-FTMGSKMQ.js.map → mimo-code-RFLQ727H.js.map} +0 -0
  135. /package/dist/{nemoclaw-CQYXZVQN.js.map → nemoclaw-LXUTMR56.js.map} +0 -0
  136. /package/dist/{omp-2QMEY6HD.js.map → omp-CO7IXURG.js.map} +0 -0
  137. /package/dist/{openclaw-UZC437RW.js.map → openclaw-XWJLEW35.js.map} +0 -0
  138. /package/dist/{opencode-L4BGFP25.js.map → opencode-QKZ5EIYU.js.map} +0 -0
  139. /package/dist/{package-DNLQTPNN.js.map → package-IA56LSC3.js.map} +0 -0
  140. /package/dist/{pi-PVVPVWKG.js.map → pi-YGBXYWY5.js.map} +0 -0
  141. /package/dist/{roo-code-67TYJIQR.js.map → roo-code-AGGJ473T.js.map} +0 -0
  142. /package/dist/{serve-EOVWYBGZ.js.map → serve-RNUCK5F7.js.map} +0 -0
  143. /package/dist/{status-VTD6XXLW.js.map → status-JOX6RLJU.js.map} +0 -0
  144. /package/dist/{statusline-3ET5YPQ5.js.map → statusline-ZVFI5DRT.js.map} +0 -0
  145. /package/dist/{telemetry-QCTMKDBQ.js.map → telemetry-3FN6HDVU.js.map} +0 -0
  146. /package/dist/{trae-7CZZGOGI.js.map → trae-6L226ZDU.js.map} +0 -0
  147. /package/dist/{uninstall-FL3SH2DT.js.map → uninstall-SCKZYB4J.js.map} +0 -0
  148. /package/dist/{upgrade-SLFG2FCT.js.map → upgrade-WU3KZWR4.js.map} +0 -0
  149. /package/dist/{usage-IRBLVUZM.js.map → usage-G72SF7JG.js.map} +0 -0
  150. /package/dist/{usage-event-VFF77WYY.js.map → usage-event-DHSEBO5T.js.map} +0 -0
  151. /package/dist/{warp-VKG55TAT.js.map → warp-N5YYN5BF.js.map} +0 -0
  152. /package/dist/{windsurf-FU5G4SHF.js.map → windsurf-4TGSJIVV.js.map} +0 -0
  153. /package/dist/{zed-SFUHL3GS.js.map → zed-6P2UFWXU.js.map} +0 -0
@@ -3,7 +3,8 @@ import {
3
3
  renderFrontmatterMd
4
4
  } from "./chunk-7L6ITC4T.js";
5
5
  import {
6
- buildHomeBinActionCommand
6
+ buildHomeBinActionCommand,
7
+ buildHomeBinHookCommand
7
8
  } from "./chunk-I5MLE6S7.js";
8
9
  import {
9
10
  MEMORY_CONTENT_SOFT_BUDGET_BYTES,
@@ -102,6 +103,88 @@ function parseJsonc(text) {
102
103
  return JSON.parse(stripJsonc(text));
103
104
  }
104
105
 
106
+ // src/core/object-map.ts
107
+ function isMalformedRootValue(value) {
108
+ return value != null && (typeof value !== "object" || Array.isArray(value));
109
+ }
110
+ function unparseableWarn(platform, configPath) {
111
+ return {
112
+ platform,
113
+ action: "warn",
114
+ path: configPath,
115
+ detail: `existing ${configPath} is not parseable; left untouched (back it up / fix it, then re-run)`
116
+ };
117
+ }
118
+ function malformedWarn(platform, rootKey, configPath) {
119
+ return {
120
+ platform,
121
+ action: "warn",
122
+ path: configPath,
123
+ detail: `existing "${rootKey}" in ${configPath} is not an object map; left untouched (fix it, then re-run)`
124
+ };
125
+ }
126
+ function upsertInObjectMap(o) {
127
+ const policy = o.policy ?? "warn-skip";
128
+ if (o.codec.isPresentButUnparseable(o.configPath)) {
129
+ return unparseableWarn(o.platform, o.configPath);
130
+ }
131
+ const cfg = o.codec.parse(o.configPath) ?? {};
132
+ if (isMalformedRootValue(cfg[o.rootKey])) {
133
+ if (policy === "warn-skip") return malformedWarn(o.platform, o.rootKey, o.configPath);
134
+ cfg[o.rootKey] = {};
135
+ }
136
+ const bucket = cfg[o.rootKey] ?? (cfg[o.rootKey] = {});
137
+ const before = JSON.stringify(bucket[o.entryId]);
138
+ const after = JSON.stringify(o.entry);
139
+ let action;
140
+ if (before === void 0) action = "create";
141
+ else if (before === after) action = "skip";
142
+ else action = "update";
143
+ if (action !== "skip") {
144
+ bucket[o.entryId] = o.entry;
145
+ o.codec.serialize(o.configPath, cfg, o.dryRun ?? false);
146
+ }
147
+ return {
148
+ platform: o.platform,
149
+ action,
150
+ path: o.configPath,
151
+ detail: `${o.rootKey}.${o.entryId}`
152
+ };
153
+ }
154
+ function removeFromObjectMap(o) {
155
+ const policy = o.policy ?? "warn-skip";
156
+ if (o.codec.isPresentButUnparseable(o.configPath)) {
157
+ return unparseableWarn(o.platform, o.configPath);
158
+ }
159
+ const cfg = o.codec.parse(o.configPath);
160
+ if (cfg && isMalformedRootValue(cfg[o.rootKey])) {
161
+ if (policy === "warn-skip") return malformedWarn(o.platform, o.rootKey, o.configPath);
162
+ return {
163
+ platform: o.platform,
164
+ action: "skip",
165
+ path: o.configPath,
166
+ detail: `${o.rootKey}.${o.entryId} absent`
167
+ };
168
+ }
169
+ const bucket = cfg?.[o.rootKey];
170
+ if (!cfg || !bucket || !(o.entryId in bucket)) {
171
+ return {
172
+ platform: o.platform,
173
+ action: "skip",
174
+ path: o.configPath,
175
+ detail: `${o.rootKey}.${o.entryId} absent`
176
+ };
177
+ }
178
+ delete bucket[o.entryId];
179
+ o.codec.serialize(o.configPath, cfg, o.dryRun ?? false);
180
+ return {
181
+ platform: o.platform,
182
+ action: "remove",
183
+ path: o.configPath,
184
+ detail: `${o.rootKey}.${o.entryId}`
185
+ };
186
+ }
187
+
105
188
  // src/adapters/base.ts
106
189
  import {
107
190
  copyFileSync,
@@ -114,6 +197,36 @@ import {
114
197
  } from "fs";
115
198
  import { homedir } from "os";
116
199
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "path";
200
+
201
+ // src/core/hook-array.ts
202
+ function upsertInArray(array, candidate, ownsEntry) {
203
+ const idx = array.findIndex(ownsEntry);
204
+ if (idx >= 0) {
205
+ if (JSON.stringify(array[idx]) === JSON.stringify(candidate)) {
206
+ return { array, action: "skip" };
207
+ }
208
+ const next = array.slice();
209
+ next[idx] = candidate;
210
+ return { array: next, action: "update" };
211
+ }
212
+ return { array: [...array, candidate], action: "create" };
213
+ }
214
+ function removeFromArray(array, ownsEntry, stripInner) {
215
+ if (!stripInner) {
216
+ const kept2 = array.filter((e) => !ownsEntry(e));
217
+ return { array: kept2, removed: array.length - kept2.length };
218
+ }
219
+ const kept = [];
220
+ let removed = 0;
221
+ for (const e of array) {
222
+ const r = stripInner(e);
223
+ removed += r.removed;
224
+ if (r.next !== null) kept.push(r.next);
225
+ }
226
+ return { array: kept, removed };
227
+ }
228
+
229
+ // src/adapters/base.ts
117
230
  var AGENTS_MD_USER_PATHS = {
118
231
  // codex resolves its own user path in-adapter ($CODEX_HOME with ~ expansion
119
232
  // + the AGENTS.override.md shadow probe) — deliberately no row here.
@@ -735,51 +848,253 @@ var BaseAdapter = class {
735
848
  `, "utf8");
736
849
  }
737
850
  /**
738
- * Upsert `entry` at `config[rootKey][serverId]` in a JSON file, creating the
739
- * file/object as needed. Returns a ChangeRecord describing create/update/skip.
740
- * Idempotent: an identical entry yields "skip".
851
+ * True when a PRESENT rootKey value is not a plain object map (the user
852
+ * hand-edited it to an array / string / number / boolean). Assigning a server
853
+ * entry into such a value would corrupt the file silently (a named property on
854
+ * an Array is dropped by JSON.stringify) or throw under strict mode (a property
855
+ * write / `in` operator against a primitive), so callers warn-and-skip. A
856
+ * `null`/`undefined` value is NOT malformed — it is the well-formed "absent"
857
+ * case the helpers create fresh.
741
858
  */
742
- upsertServerInJson(configPath, rootKey, serverId, entry, dryRun = false) {
743
- if (this.isPresentButUnparseable(configPath)) {
859
+ isMalformedRootValue(value) {
860
+ return isMalformedRootValue(value);
861
+ }
862
+ /**
863
+ * Warn-skip ChangeRecord when an existing JSON `hooks` config is present-but-
864
+ * malformed (root hand-edited to an array/primitive, or an existing event
865
+ * bucket is a non-array) — installing a hook into it would silently drop the
866
+ * entry (a named property on an Array is dropped by JSON.stringify) or throw
867
+ * under strict mode (a `.push`/property write against a primitive or non-array
868
+ * bucket). Returns null when the hooks config is well-formed, including the
869
+ * absent case the installers create fresh (proceed normally). Mirrors the
870
+ * server-root guard (isMalformedRootValue). All targeted hosts use the Claude-
871
+ * style `{ Event: Matcher[] }` shape, so every present event bucket must be an
872
+ * array; a non-array bucket is the same malformed class as a wrong-typed root.
873
+ */
874
+ malformedHookRootSkip(configPath, hooksRoot) {
875
+ if (hooksRoot == null) return null;
876
+ if (this.isMalformedRootValue(hooksRoot)) {
744
877
  return {
745
878
  platform: this.id,
746
879
  action: "warn",
747
880
  path: configPath,
748
- detail: `existing ${configPath} is not parseable; left untouched (back it up / fix it, then re-run)`
881
+ detail: `existing "hooks" in ${configPath} is not an object map; left untouched (fix it, then re-run)`
749
882
  };
750
883
  }
751
- const cfg = this.readJson(configPath) ?? {};
752
- const bucket = cfg[rootKey] ??= {};
753
- const before = JSON.stringify(bucket[serverId]);
754
- const after = JSON.stringify(entry);
755
- let action;
756
- if (before === void 0) action = "create";
757
- else if (before === after) action = "skip";
758
- else action = "update";
759
- if (action !== "skip") {
760
- bucket[serverId] = entry;
761
- this.writeJson(configPath, cfg, dryRun);
884
+ for (const v of Object.values(hooksRoot)) {
885
+ if (v !== void 0 && !Array.isArray(v)) {
886
+ return {
887
+ platform: this.id,
888
+ action: "warn",
889
+ path: configPath,
890
+ detail: `existing "hooks" in ${configPath} has a non-array event bucket; left untouched (fix it, then re-run)`
891
+ };
892
+ }
762
893
  }
763
- return { platform: this.id, action, path: configPath, detail: `${rootKey}.${serverId}` };
894
+ return null;
764
895
  }
765
- /** Remove `config[rootKey][serverId]` from a JSON file. */
766
- removeServerFromJson(configPath, rootKey, serverId, dryRun = false) {
767
- if (this.isPresentButUnparseable(configPath)) {
768
- return {
896
+ // ── Shared object-map hook-array merge engine ────────────────────────────
897
+ // installHooks/uninstallHooks for every json-stdio host that stores hooks as
898
+ // `{ <event>: HookEntry[] }` share ONE create/update/skip + strip/remove
899
+ // orchestration. The host supplies a {@link HookMergeDescriptor} carrying
900
+ // EVERY observable string and ownership predicate — the engine body hardcodes
901
+ // none of them, so per-host wording (skip/remove/absent/no-match details) and
902
+ // FLAT-vs-NESTED removal stay host-controlled and never drift to a lowest-
903
+ // common-denominator phrasing the suites (which assert by action) would miss.
904
+ // The write-gate is the `mutated` bool, matching the migrated host exactly.
905
+ /**
906
+ * Install: upsert each `{ event, matcher }` in `pending` into the object-map
907
+ * `hooks` root at `configPath`. Reproduces the canonical host's loop: read
908
+ * `?? {}`, warn-skip on a malformed `hooks` root, then per pending item render
909
+ * the entry, find the owned slot, and create/update/skip. Writes once at the
910
+ * end iff anything mutated.
911
+ *
912
+ * Hosts that fold their `nativeHooks` surface into `pending` (claude-code) pass
913
+ * no `native` arg. Hosts that keep the native surface SEPARATE — verbatim
914
+ * event keys, EXACT-command ownership, a distinct `(native)` detail — pass it
915
+ * as the optional `native` list (cursor); that pass runs after the normalized
916
+ * loop and before the single write. Omitting it is byte-identical to before.
917
+ */
918
+ /**
919
+ * Resolve the per-event hook bucket. With "coerce" policy a present-but-non-
920
+ * array bucket (hand-edited) is replaced by a fresh array; otherwise `??=` is
921
+ * used (the warn-skip path already rejected any non-array bucket via
922
+ * malformedHookRootSkip, so `??=` only ever fills the absent case).
923
+ */
924
+ coerceHookBucket(hooks, event, coerce) {
925
+ if (coerce) {
926
+ return Array.isArray(hooks[event]) ? hooks[event] : hooks[event] = [];
927
+ }
928
+ return hooks[event] ??= [];
929
+ }
930
+ upsertHookEntries(ctx, configPath, pending, descriptor, native) {
931
+ const file = this.readJson(configPath) ?? {};
932
+ const coerce = descriptor.malformedPolicy === "coerce";
933
+ let hooks;
934
+ if (coerce) {
935
+ const existing = file.hooks;
936
+ hooks = existing && typeof existing === "object" && !Array.isArray(existing) ? existing : file.hooks = {};
937
+ } else {
938
+ const skip = this.malformedHookRootSkip(configPath, file.hooks);
939
+ if (skip) return [skip];
940
+ hooks = file.hooks ??= {};
941
+ }
942
+ const changes = [];
943
+ let mutated = false;
944
+ for (const { event, matcher } of pending) {
945
+ const hostEvent = descriptor.mapEvent ? descriptor.mapEvent(event) : event;
946
+ if (hostEvent === void 0) {
947
+ changes.push({
948
+ platform: this.id,
949
+ action: "warn",
950
+ path: configPath,
951
+ detail: descriptor.unmappedWarnDetail(event)
952
+ });
953
+ continue;
954
+ }
955
+ const command = buildHomeBinHookCommand(
956
+ ctx.homeBinPath,
957
+ this.id,
958
+ event,
959
+ ctx.connector.id
960
+ );
961
+ const entry = descriptor.renderEntry(hostEvent, matcher, command);
962
+ const bucket = this.coerceHookBucket(hooks, hostEvent, coerce);
963
+ const r = upsertInArray(
964
+ bucket,
965
+ entry,
966
+ (e) => descriptor.entryOwnsCommand(e, command)
967
+ );
968
+ if (r.action !== "skip") {
969
+ hooks[hostEvent] = r.array;
970
+ mutated = true;
971
+ }
972
+ changes.push({
769
973
  platform: this.id,
770
- action: "warn",
974
+ action: r.action,
771
975
  path: configPath,
772
- detail: `existing ${configPath} is not parseable; left untouched (back it up / fix it, then re-run)`
773
- };
976
+ detail: r.action === "skip" ? descriptor.skipDetail(hostEvent) : `hooks.${hostEvent}`
977
+ });
774
978
  }
775
- const cfg = this.readJson(configPath);
776
- const bucket = cfg?.[rootKey];
777
- if (!cfg || !bucket || !(serverId in bucket)) {
778
- return { platform: this.id, action: "skip", path: configPath, detail: `${rootKey}.${serverId} absent` };
979
+ for (const { event, matcher } of native ?? []) {
980
+ const command = buildHomeBinHookCommand(
981
+ ctx.homeBinPath,
982
+ this.id,
983
+ event,
984
+ ctx.connector.id
985
+ );
986
+ const entry = descriptor.renderEntry(event, matcher, command);
987
+ const bucket = this.coerceHookBucket(hooks, event, coerce);
988
+ const r = upsertInArray(
989
+ bucket,
990
+ entry,
991
+ (e) => descriptor.nativeOwnsCommand(e, command)
992
+ );
993
+ if (r.action !== "skip") {
994
+ hooks[event] = r.array;
995
+ mutated = true;
996
+ }
997
+ changes.push({
998
+ platform: this.id,
999
+ action: r.action,
1000
+ path: configPath,
1001
+ detail: r.action === "skip" ? descriptor.nativeSkipDetail(event) : descriptor.nativeMutateDetail(event)
1002
+ });
1003
+ }
1004
+ if (mutated) {
1005
+ descriptor.onMutate?.(file);
1006
+ this.writeJson(configPath, file, ctx.dryRun);
779
1007
  }
780
- delete bucket[serverId];
781
- this.writeJson(configPath, cfg, dryRun);
782
- return { platform: this.id, action: "remove", path: configPath, detail: `${rootKey}.${serverId}` };
1008
+ return changes;
1009
+ }
1010
+ /**
1011
+ * Uninstall: strip owned content from every event bucket in the object-map
1012
+ * `hooks` root at `configPath`. NESTED hosts pass `descriptor.stripInner`
1013
+ * (strip owned inner commands, drop emptied entries; `removed` = inner
1014
+ * commands); FLAT hosts omit it (drop whole owned entries). Reproduces the
1015
+ * canonical host: read (NO `?? {}`), `[skip]` (absentDetail) when no hooks
1016
+ * section, per-event remove → delete-or-replace bucket, write once iff
1017
+ * mutated, and a single `[skip]` (noMatchDetail) when nothing matched.
1018
+ */
1019
+ removeHookEntries(ctx, configPath, descriptor) {
1020
+ const file = this.readJson(configPath);
1021
+ const hooks = file?.hooks;
1022
+ if (!file || !hooks) {
1023
+ return [
1024
+ {
1025
+ platform: this.id,
1026
+ action: "skip",
1027
+ path: configPath,
1028
+ detail: descriptor.absentDetail
1029
+ }
1030
+ ];
1031
+ }
1032
+ const changes = [];
1033
+ let mutated = false;
1034
+ const stripInner = descriptor.stripInner?.(ctx);
1035
+ for (const event of descriptor.removeEventKeys ?? Object.keys(hooks)) {
1036
+ const bucket = hooks[event];
1037
+ if (!Array.isArray(bucket)) continue;
1038
+ const ownsEntry = descriptor.ownsEntryForRemove(ctx, event);
1039
+ const r = removeFromArray(bucket, ownsEntry, stripInner);
1040
+ if (r.removed > 0) {
1041
+ if (r.array.length > 0) hooks[event] = r.array;
1042
+ else delete hooks[event];
1043
+ changes.push({
1044
+ platform: this.id,
1045
+ action: "remove",
1046
+ path: configPath,
1047
+ detail: descriptor.removeDetail(event, r.removed)
1048
+ });
1049
+ mutated = true;
1050
+ }
1051
+ }
1052
+ if (mutated) this.writeJson(configPath, file, ctx.dryRun);
1053
+ if (changes.length === 0) {
1054
+ changes.push({
1055
+ platform: this.id,
1056
+ action: "skip",
1057
+ path: configPath,
1058
+ detail: descriptor.noMatchDetail
1059
+ });
1060
+ }
1061
+ return changes;
1062
+ }
1063
+ /** Bind BaseAdapter's JSON leaf IO (readJson/writeJson + the unparseable
1064
+ * overwrite guard) as a Codec for the object-map engine. */
1065
+ jsonObjectMapCodec() {
1066
+ return {
1067
+ parse: (path) => this.readJson(path),
1068
+ serialize: (path, data, dryRun) => this.writeJson(path, data, dryRun),
1069
+ isPresentButUnparseable: (path) => this.isPresentButUnparseable(path)
1070
+ };
1071
+ }
1072
+ /**
1073
+ * Upsert `entry` at `config[rootKey][serverId]` in a JSON file, creating the
1074
+ * file/object as needed. Returns a ChangeRecord describing create/update/skip.
1075
+ * Idempotent: an identical entry yields "skip".
1076
+ */
1077
+ upsertServerInJson(configPath, rootKey, serverId, entry, dryRun = false) {
1078
+ return upsertInObjectMap({
1079
+ codec: this.jsonObjectMapCodec(),
1080
+ rootKey,
1081
+ platform: this.id,
1082
+ configPath,
1083
+ entryId: serverId,
1084
+ entry,
1085
+ dryRun
1086
+ });
1087
+ }
1088
+ /** Remove `config[rootKey][serverId]` from a JSON file. */
1089
+ removeServerFromJson(configPath, rootKey, serverId, dryRun = false) {
1090
+ return removeFromObjectMap({
1091
+ codec: this.jsonObjectMapCodec(),
1092
+ rootKey,
1093
+ platform: this.id,
1094
+ configPath,
1095
+ entryId: serverId,
1096
+ dryRun
1097
+ });
783
1098
  }
784
1099
  // ── Backup ───────────────────────────────────────────────────────────────
785
1100
  backupSettings(ctx) {
@@ -829,6 +1144,8 @@ var BaseAdapter = class {
829
1144
 
830
1145
  export {
831
1146
  parseJsonc,
1147
+ upsertInObjectMap,
1148
+ removeFromObjectMap,
832
1149
  BaseAdapter
833
1150
  };
834
- //# sourceMappingURL=chunk-CPLK7GTE.js.map
1151
+ //# sourceMappingURL=chunk-PFDUGDOA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/jsonc.ts","../src/core/object-map.ts","../src/adapters/base.ts","../src/core/hook-array.ts"],"sourcesContent":["/**\n * core/jsonc — tolerant JSONC / JSON5-lite parsing.\n *\n * Many hosts document their config file as JSONC (or JSON5): // line comments,\n * /* *\\/ block comments, and trailing commas are all legal. A strict JSON.parse\n * false-fails such a perfectly valid file → null → and a careless `?? {}` then\n * OVERWRITES the user's entire config with just our entry (data loss). To avoid\n * that, every JSON/JSONC adapter parses through `parseJsonc`, which strips\n * comments + trailing commas in ONE string-aware pass before JSON.parse.\n *\n * The single pass is deliberately string-literal aware: a // or /* inside a\n * quoted value (e.g. \"http://x//y\") is NOT a comment, and a comma inside a\n * string (e.g. \"a,]\") is NOT a trailing comma — both must survive verbatim.\n */\n\n/**\n * Strip // line comments, /* *\\/ block comments, and trailing commas from JSONC\n * text in a SINGLE string-aware pass.\n *\n * Rules:\n * - While inside a string literal, every character (including //, /*, and ,)\n * is copied verbatim; backslash escapes the next character.\n * - Outside a string, // … runs to end-of-line and /* … *\\/ to its close.\n * - A comma is dropped ONLY when the next non-whitespace, non-comment token is\n * a closing `}` or `]` (a trailing comma). A comma followed by another value\n * or by end-of-input is preserved (the latter lets JSON.parse report the\n * real syntax error instead of us masking it).\n */\nexport function stripJsonc(text: string): string {\n const n = text.length;\n let out = \"\";\n let i = 0;\n let inString = false;\n let quote = \"\";\n\n while (i < n) {\n const ch = text[i] as string;\n\n if (inString) {\n out += ch;\n if (ch === \"\\\\\") {\n // Copy the escaped character verbatim (covers \\\" \\\\ \\/ etc.).\n if (i + 1 < n) {\n out += text[i + 1] as string;\n i += 2;\n continue;\n }\n } else if (ch === quote) {\n inString = false;\n }\n i += 1;\n continue;\n }\n\n const next = i + 1 < n ? (text[i + 1] as string) : \"\";\n\n // Enter a string literal.\n if (ch === '\"' || ch === \"'\") {\n inString = true;\n quote = ch;\n out += ch;\n i += 1;\n continue;\n }\n\n // Line comment — skip to end of line (keep the newline for line tracking).\n if (ch === \"/\" && next === \"/\") {\n i += 2;\n while (i < n && text[i] !== \"\\n\") i += 1;\n continue;\n }\n\n // Block comment — skip to the closing */.\n if (ch === \"/\" && next === \"*\") {\n i += 2;\n while (i < n && !(text[i] === \"*\" && text[i + 1] === \"/\")) i += 1;\n i += 2; // consume the closing */\n continue;\n }\n\n // Trailing comma — drop it only when the next significant token (skipping\n // whitespace AND comments) is a closing } or ]. This stays string-aware\n // because we only reach here outside a string.\n if (ch === \",\") {\n const closer = nextSignificant(text, i + 1);\n if (closer === \"}\" || closer === \"]\") {\n i += 1; // drop the trailing comma\n continue;\n }\n }\n\n out += ch;\n i += 1;\n }\n\n return out;\n}\n\n/**\n * Peek the next significant (non-whitespace, non-comment) character at/after\n * `from`, returning \"\" at end-of-input. Used only outside string literals.\n */\nfunction nextSignificant(text: string, from: number): string {\n const n = text.length;\n let i = from;\n while (i < n) {\n const ch = text[i] as string;\n if (ch === \" \" || ch === \"\\t\" || ch === \"\\r\" || ch === \"\\n\") {\n i += 1;\n continue;\n }\n const next = i + 1 < n ? (text[i + 1] as string) : \"\";\n if (ch === \"/\" && next === \"/\") {\n i += 2;\n while (i < n && text[i] !== \"\\n\") i += 1;\n continue;\n }\n if (ch === \"/\" && next === \"*\") {\n i += 2;\n while (i < n && !(text[i] === \"*\" && text[i + 1] === \"/\")) i += 1;\n i += 2;\n continue;\n }\n return ch;\n }\n return \"\";\n}\n\n/**\n * Parse JSONC text tolerantly: strip comments + trailing commas, then JSON.parse.\n * Throws (like JSON.parse) on genuinely malformed input — callers that want a\n * fail-soft null should wrap in try/catch (BaseAdapter.readJson does).\n */\nexport function parseJsonc<T = unknown>(text: string): T {\n return JSON.parse(stripJsonc(text)) as T;\n}\n","import type { ChangeRecord } from \"./types.js\";\n\n/**\n * Format-agnostic upsert/remove for a config that stores entries in an object\n * map at config[rootKey][entryId]. Extracted from BaseAdapter.upsertServerInJson\n * / removeServerFromJson so JSON today (and other formats via a Codec later)\n * share ONE create/skip/update + overwrite/malformed-guard orchestration. The\n * JSON binding in BaseAdapter is a byte-identical wrapper over this.\n */\n\n/** The only format-specific surface: parse a config file to a record and\n * serialize it back. parse() fail-softs to null (absent or unparseable). */\nexport interface ObjectMapCodec {\n parse(path: string): Record<string, unknown> | null;\n serialize(path: string, data: Record<string, unknown>, dryRun: boolean): void;\n /** Detection half of the overwrite guard: present, non-empty, still unparseable. */\n isPresentButUnparseable(path: string): boolean;\n}\n\n/** What to do when config[rootKey] is present but the wrong type (hand-edited to\n * an array / primitive). \"warn-skip\" leaves the user's value untouched (the JSON\n * server/hook policy); \"coerce\" replaces it with a fresh {} and proceeds (the\n * TOML/YAML host policy, used by a later follow-up). */\nexport type MalformedRootPolicy = \"warn-skip\" | \"coerce\";\n\n/** True when a PRESENT value is not a plain object map (array / primitive).\n * null/undefined is NOT malformed — that is the well-formed \"absent\" case the\n * engine creates fresh. */\nexport function isMalformedRootValue(value: unknown): boolean {\n return value != null && (typeof value !== \"object\" || Array.isArray(value));\n}\n\nexport interface ObjectMapUpsertOptions {\n codec: ObjectMapCodec;\n rootKey: string;\n platform: string;\n configPath: string;\n entryId: string;\n entry: unknown;\n dryRun?: boolean;\n policy?: MalformedRootPolicy;\n}\n\nexport interface ObjectMapRemoveOptions {\n codec: ObjectMapCodec;\n rootKey: string;\n platform: string;\n configPath: string;\n entryId: string;\n dryRun?: boolean;\n policy?: MalformedRootPolicy;\n}\n\nfunction unparseableWarn(platform: string, configPath: string): ChangeRecord {\n return {\n platform: platform as ChangeRecord[\"platform\"],\n action: \"warn\",\n path: configPath,\n detail: `existing ${configPath} is not parseable; left untouched (back it up / fix it, then re-run)`,\n };\n}\n\nfunction malformedWarn(platform: string, rootKey: string, configPath: string): ChangeRecord {\n return {\n platform: platform as ChangeRecord[\"platform\"],\n action: \"warn\",\n path: configPath,\n detail: `existing \"${rootKey}\" in ${configPath} is not an object map; left untouched (fix it, then re-run)`,\n };\n}\n\nexport function upsertInObjectMap(o: ObjectMapUpsertOptions): ChangeRecord {\n const policy = o.policy ?? \"warn-skip\";\n if (o.codec.isPresentButUnparseable(o.configPath)) {\n return unparseableWarn(o.platform, o.configPath);\n }\n const cfg = o.codec.parse(o.configPath) ?? {};\n if (isMalformedRootValue(cfg[o.rootKey])) {\n if (policy === \"warn-skip\") return malformedWarn(o.platform, o.rootKey, o.configPath);\n cfg[o.rootKey] = {}; // coerce\n }\n const bucket = (cfg[o.rootKey] ?? (cfg[o.rootKey] = {})) as Record<string, unknown>;\n const before = JSON.stringify(bucket[o.entryId]);\n const after = JSON.stringify(o.entry);\n let action: ChangeRecord[\"action\"];\n if (before === undefined) action = \"create\";\n else if (before === after) action = \"skip\";\n else action = \"update\";\n if (action !== \"skip\") {\n bucket[o.entryId] = o.entry;\n o.codec.serialize(o.configPath, cfg, o.dryRun ?? false);\n }\n return {\n platform: o.platform as ChangeRecord[\"platform\"],\n action,\n path: o.configPath,\n detail: `${o.rootKey}.${o.entryId}`,\n };\n}\n\nexport function removeFromObjectMap(o: ObjectMapRemoveOptions): ChangeRecord {\n const policy = o.policy ?? \"warn-skip\";\n if (o.codec.isPresentButUnparseable(o.configPath)) {\n return unparseableWarn(o.platform, o.configPath);\n }\n const cfg = o.codec.parse(o.configPath);\n if (cfg && isMalformedRootValue(cfg[o.rootKey])) {\n if (policy === \"warn-skip\") return malformedWarn(o.platform, o.rootKey, o.configPath);\n // coerce: a malformed root holds nothing of ours to remove → absent skip\n return {\n platform: o.platform as ChangeRecord[\"platform\"],\n action: \"skip\",\n path: o.configPath,\n detail: `${o.rootKey}.${o.entryId} absent`,\n };\n }\n const bucket = cfg?.[o.rootKey] as Record<string, unknown> | undefined;\n if (!cfg || !bucket || !(o.entryId in bucket)) {\n return {\n platform: o.platform as ChangeRecord[\"platform\"],\n action: \"skip\",\n path: o.configPath,\n detail: `${o.rootKey}.${o.entryId} absent`,\n };\n }\n delete bucket[o.entryId];\n o.codec.serialize(o.configPath, cfg, o.dryRun ?? false);\n return {\n platform: o.platform as ChangeRecord[\"platform\"],\n action: \"remove\",\n path: o.configPath,\n detail: `${o.rootKey}.${o.entryId}`,\n };\n}\n","/**\n * adapters/base — shared adapter foundation.\n *\n * Provides JSON config IO, settings backup, and a default doctor. Per-platform\n * specifics (paths, capabilities, native render format, runtime parse/format)\n * are abstract and implemented by each adapter. TOML/YAML adapters override the\n * JSON helpers entirely.\n */\n\nimport {\n copyFileSync,\n existsSync,\n readdirSync,\n readFileSync,\n rmSync,\n statSync,\n writeFileSync,\n} from \"node:fs\";\nimport type { Dirent } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { basename, dirname, isAbsolute, join, relative, resolve, sep } from \"node:path\";\n\nimport type {\n ChangeRecord,\n DetectedPlatform,\n DiagnosticResult,\n HealthCheck,\n HookParadigm,\n PlatformCapabilities,\n PlatformId,\n PlatformMemoryOverride,\n} from \"../core/types.js\";\nimport { backupsDir, ensureDir } from \"../core/paths.js\";\nimport { parseJsonc } from \"../core/jsonc.js\";\nimport {\n isMalformedRootValue as isMalformedRootValueFn,\n removeFromObjectMap,\n upsertInObjectMap,\n type ObjectMapCodec,\n} from \"../core/object-map.js\";\nimport { removeFromArray, upsertInArray } from \"../core/hook-array.js\";\nimport { buildHomeBinActionCommand, buildHomeBinHookCommand } from \"../core/spawn.js\";\nimport {\n MEMORY_CONTENT_SOFT_BUDGET_BYTES,\n listManagedBlocks,\n loadMemoryLedger,\n recordMemoryTarget,\n removeManagedBlocksFile,\n saveMemoryLedger,\n upsertManagedBlockFile,\n} from \"../core/managed-block.js\";\nimport { renderFrontmatterMd } from \"./claude-code/render.js\";\nimport type { Adapter, InstallContext, MemoryTarget } from \"./spi.js\";\n\n/** Content-surface kinds with BaseAdapter default install/uninstall handling. */\ntype ContentSurface =\n | \"commands\"\n | \"skills\"\n | \"subagents\"\n | \"memory\"\n | \"statusline\"\n | \"actions\";\n\n/**\n * Per-host policy + observables for the shared object-map hook-array merge\n * engine ({@link BaseAdapter.upsertHookEntries} / {@link BaseAdapter.removeHookEntries}).\n * `E` is the host's per-event array element type (e.g. claude-code's\n * `{ matcher, hooks: [...] }`). EVERY observable string + ownership predicate\n * is carried here so the engine body hardcodes none of them and per-host\n * wording never drifts; a future host needing divergent details overrides only\n * its descriptor, not the engine.\n */\nexport interface HookMergeDescriptor<E> {\n /**\n * How to handle a present-but-malformed `hooks` root (an array / primitive\n * instead of an object map) on install:\n * - \"warn-skip\" (DEFAULT): route through {@link BaseAdapter.malformedHookRootSkip}\n * — surface a `warn`, write nothing, leave the user's value untouched. This\n * is byte-identical to the pre-axis engine, so existing hosts that omit the\n * field are unchanged.\n * - \"coerce\": replace a malformed root (and any non-array event bucket) with a\n * fresh object map / array, then proceed — matching the container hosts\n * (codex, goose) whose server path already coerces a malformed root.\n */\n malformedPolicy?: \"warn-skip\" | \"coerce\";\n /**\n * Canonical → host event name. `undefined` = the host has no equivalent for\n * this event → the engine emits a warn (via unmappedWarnDetail) and skips it.\n * Omit the field entirely for identity hosts (claude-code) — no warn path.\n */\n mapEvent?(event: string): string | undefined;\n /** Warn detail for an event mapEvent returns undefined for. Required iff mapEvent can return undefined. */\n unmappedWarnDetail?(event: string): string;\n /** Render one host entry from the event name, declared matcher, and home-bin command. */\n renderEntry(event: string, matcher: string, command: string): E;\n /** Upsert find: does `entry` already carry THIS specific command (idempotency check)? */\n entryOwnsCommand(entry: E, command: string): boolean;\n /**\n * Uninstall whole-entry predicate (FLAT hosts): does `entry` belong to us?\n * NESTED hosts supplying {@link stripInner} may return a never-true predicate —\n * the engine then only ever invokes `stripInner`. Bound to `ctx` because\n * ownership is connector-generic (ANY of our commands), wider than the\n * install-time specific-command check. The `event` param lets EVENT-SPECIFIC\n * hosts (codex, whose ownership is per-event by construction) match the\n * canonical event being stripped; hosts whose ownership is event-independent\n * (claude-code/droid/cursor/qwen) ignore it — a `(ctx) => …` arrow is assignable\n * to this 2-param type (fewer params is fine in TS), so they need no change.\n */\n ownsEntryForRemove(ctx: InstallContext, event: string): (entry: E) => boolean;\n /**\n * Uninstall inner-strip (NESTED hosts): strip our owned inner commands from\n * `entry`, returning the rebuilt entry (`null` when fully emptied) and the\n * count of inner commands removed. Omit for FLAT hosts.\n */\n stripInner?(ctx: InstallContext): (entry: E) => { next: E | null; removed: number };\n /** Idempotent-reinstall skip detail, e.g. `hooks.<event> already registered`. */\n skipDetail(event: string): string;\n /** Uninstall remove detail, e.g. `hooks.<event> (<n>)`. */\n removeDetail(event: string, removed: number): string;\n /** Uninstall skip detail when no hooks section is present at all. */\n absentDetail: string;\n /** Uninstall skip detail when a hooks section exists but nothing matched. */\n noMatchDetail: string;\n /**\n * Uninstall: the exact event keys to scan, in order. Omit (default) to scan\n * every key actually present (`Object.keys(hooks)`). EVENT-SPECIFIC hosts whose\n * ownership predicate rebuilds a per-event command (codex) MUST pin their fixed\n * event set here so a home-bin command hand-placed under a foreign event key is\n * left untouched — byte-identical to a fixed-event-list uninstall loop.\n */\n removeEventKeys?: readonly string[];\n /** Optional post-mutation hook on the whole parsed file, before the single write. */\n onMutate?(file: Record<string, unknown>): void;\n /**\n * Native-pass ownership find (EXACT command match, vs the normalized\n * entryOwnsCommand). Set only when a `native` list is passed.\n */\n nativeOwnsCommand?(entry: E, command: string): boolean;\n /** Native-pass skip detail, e.g. `hooks.<event> (native) already registered`. */\n nativeSkipDetail?(event: string): string;\n /** Native-pass create/update detail, e.g. `hooks.<event> (native)`. */\n nativeMutateDetail?(event: string): string;\n}\n\n/**\n * One resolved action trigger for an EMITTER adapter: the host-native trigger\n * the adapter writes runs `command`, which re-enters the home binary at the\n * `action` verb. `label`/`description` fall back to the action id when the\n * connector declared none. Produced by {@link BaseAdapter.actionTriggers}.\n */\nexport interface ActionTrigger {\n /** The action id — also the per-action file/key name on most hosts. */\n id: string;\n /** Display label (action.description ?? action.id). */\n label: string;\n /** One-line description (action.description ?? action.id). */\n description: string;\n /** `<homeBin> action <host> <id> --connector <connectorId>` (the verb the host runs). */\n command: string;\n}\n\n/**\n * Documented USER-scope AGENTS.md locations, per host (the AGENTS.md-first\n * research matrix). Only hosts with a REAL user/global AGENTS.md file are\n * listed. Hosts whose documented user-scope memory lives in a DIFFERENT file\n * (qwen-code ~/.qwen/QWEN.md, goose .goosehints, kilo/roo/kiro rules dirs,\n * copilot-cli copilot-instructions.md) override memoryTargets in-adapter;\n * hosts whose user rules are app/UI/cloud-managed (warp Drive, trae,\n * jetbrains/cursor settings UI) deliberately have no row — user-scope memory\n * there reports the standard skip-warn (the JetBrains-MCP precedent), never a\n * write into a file the host ignores.\n */\nconst AGENTS_MD_USER_PATHS: Partial<Record<PlatformId, () => MemoryTarget>> = {\n // codex resolves its own user path in-adapter ($CODEX_HOME with ~ expansion\n // + the AGENTS.override.md shadow probe) — deliberately no row here.\n zed: () => ({\n path:\n process.platform === \"win32\" && process.env.APPDATA\n ? join(process.env.APPDATA, \"Zed\", \"AGENTS.md\")\n : join(homedir(), \".config\", \"zed\", \"AGENTS.md\"),\n reason: \"zed personal instructions file\",\n }),\n amp: () => ({\n path: join(homedir(), \".config\", \"amp\", \"AGENTS.md\"),\n reason: \"amp user-scope AGENTS.md\",\n }),\n mux: () => ({\n path: join(homedir(), \".mux\", \"AGENTS.md\"),\n reason: \"mux global AGENTS.md\",\n }),\n pi: () => ({\n path: join(homedir(), \".pi\", \"agent\", \"AGENTS.md\"),\n reason: \"pi global AGENTS.md\",\n }),\n droid: () => ({\n path: join(homedir(), \".factory\", \"AGENTS.md\"),\n reason: \"droid (Factory) personal AGENTS.md\",\n }),\n opencode: () => ({\n path: join(homedir(), \".config\", \"opencode\", \"AGENTS.md\"),\n reason: \"opencode global AGENTS.md\",\n }),\n antigravity: () => ({\n path: join(homedir(), \".gemini\", \"AGENTS.md\"),\n reason: \"antigravity global rules (~/.gemini/AGENTS.md, shared tree)\",\n }),\n \"antigravity-cli\": () => ({\n path: join(homedir(), \".gemini\", \"AGENTS.md\"),\n reason: \"agy shares the IDE's ~/.gemini tree (idempotent upsert dedupes)\",\n }),\n omp: () => ({\n path: join(homedir(), \".omp\", \"agent\", \"AGENTS.md\"),\n reason: \"omp global AGENTS.md (pi-parity; verify for your version)\",\n }),\n};\n\nexport abstract class BaseAdapter implements Adapter {\n abstract readonly id: PlatformId;\n abstract readonly name: string;\n abstract readonly paradigm: HookParadigm;\n abstract readonly capabilities: PlatformCapabilities;\n\n abstract detectInstalled(projectDir: string): DetectedPlatform;\n abstract getConfigDir(ctx: InstallContext): string;\n abstract getServerConfigPath(ctx: InstallContext): string;\n abstract getHookConfigPath(ctx: InstallContext): string;\n abstract installServer(ctx: InstallContext): ChangeRecord[];\n abstract uninstallServer(ctx: InstallContext): ChangeRecord[];\n abstract installHooks(ctx: InstallContext): ChangeRecord[];\n abstract uninstallHooks(ctx: InstallContext): ChangeRecord[];\n\n // ── Content surfaces (commands / skills / subagents) ─────────────────────\n // CONCRETE (overridable) defaults so every adapter inherits all six methods\n // and the installer can call them without optional-chaining. Each returns a\n // single skip when the connector declares no entries of that surface, else a\n // single \"warn\" — mirroring the mcp-only hook handling. Supporting adapters\n // override only the surfaces they honor.\n\n installCommands(ctx: InstallContext): ChangeRecord[] {\n return this.unsupportedSurface(ctx, \"commands\", ctx.connector.commands.length);\n }\n uninstallCommands(ctx: InstallContext): ChangeRecord[] {\n return this.unsupportedSurface(ctx, \"commands\", ctx.connector.commands.length);\n }\n installSkills(ctx: InstallContext): ChangeRecord[] {\n return this.unsupportedSurface(ctx, \"skills\", ctx.connector.skills.length);\n }\n uninstallSkills(ctx: InstallContext): ChangeRecord[] {\n return this.unsupportedSurface(ctx, \"skills\", ctx.connector.skills.length);\n }\n installSubagents(ctx: InstallContext): ChangeRecord[] {\n return this.unsupportedSurface(ctx, \"subagents\", ctx.connector.subagents.length);\n }\n uninstallSubagents(ctx: InstallContext): ChangeRecord[] {\n return this.unsupportedSurface(ctx, \"subagents\", ctx.connector.subagents.length);\n }\n\n // ── Memory surface (managed marker blocks; AGENTS.md-first) ───────────────\n // ONE generic implementation for every supporting host: the per-adapter\n // `memoryTargets()` hook resolves WHERE to write (AGENTS.md defaults below;\n // claude-code → CLAUDE.md and gemini-cli → GEMINI.md override it), and the\n // core/managed-block engine performs the surgical, hash-stamped block edit.\n // Unlike commands/skills/subagents these files are SHARED and user-authored —\n // bytes outside this connector's own marker pair are never touched.\n\n /**\n * Resolve the memory/rules file(s) this host actually reads at ctx.scope.\n * Base default (AGENTS.md-first, owner mandate):\n * - an explicit `platforms[<id>].memory.path` override wins;\n * - project scope → `<projectDir>/AGENTS.md` (the agents.md standard);\n * - user scope → the host's documented user-scope AGENTS.md, when one\n * exists ({@link AGENTS_MD_USER_PATHS}); otherwise [] → skip-warn.\n * Exception hosts (claude-code, gemini-cli) override this hook.\n */\n protected memoryTargets(ctx: InstallContext): MemoryTarget[] {\n const override = this.memoryOverride(ctx);\n if (override?.path) {\n const base = ctx.scope === \"project\" ? ctx.projectDir : homedir();\n return [\n {\n path: isAbsolute(override.path) ? override.path : join(base, override.path),\n reason: `platforms.${this.id}.memory.path override`,\n },\n ];\n }\n if (ctx.scope === \"project\") {\n return [\n { path: join(ctx.projectDir, \"AGENTS.md\"), reason: \"AGENTS.md standard (project root)\" },\n ];\n }\n if (ctx.scope === \"user\") {\n const user = AGENTS_MD_USER_PATHS[this.id]?.();\n return user ? [user] : [];\n }\n return [];\n }\n\n /** The per-platform memory override object, when one is declared. */\n protected memoryOverride(ctx: InstallContext): PlatformMemoryOverride | undefined {\n const o = ctx.connector.platforms[this.id]?.memory;\n return o && typeof o === \"object\" ? o : undefined;\n }\n\n installMemory(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n // `?? []` tolerates pre-resolved connectors from versions before the\n // memory surface existed (the installer applies the same guard).\n const entries = connector.memory ?? [];\n if (connector.platforms[this.id]?.memory === false) {\n return [{ platform: this.id, action: \"skip\", detail: `memory disabled for ${this.id}` }];\n }\n if (entries.length === 0) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no memory\" }];\n }\n if (!(this.capabilities.supportsMemory ?? false)) {\n return this.unsupportedSurface(ctx, \"memory\", entries.length);\n }\n\n const changes: ChangeRecord[] = [];\n const override = this.memoryOverride(ctx);\n if (override?.mode && this.id !== \"claude-code\") {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail: `memory.mode is claude-code-only; ignored on ${this.id}`,\n });\n }\n if (ctx.scope !== \"project\" && ctx.scope !== \"user\") {\n // system/profile/managed memory files are admin-owned — out of scope (v1).\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail:\n `memory not supported at ${ctx.scope} scope on ${this.id} ` +\n `(managed/admin memory files are out of scope); ${entries.length} skipped`,\n });\n return changes;\n }\n const targets = this.memoryTargets(ctx);\n if (targets.length === 0) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n detail:\n `no ${ctx.scope}-scope memory file on ${this.id} ` +\n `(user rules are app/UI-managed or undocumented); ${entries.length} skipped`,\n });\n return changes;\n }\n changes.push(...this.writeMemoryBlocks(ctx, targets));\n return changes;\n }\n\n /**\n * Upsert every declared memory entry's block into every resolved target and\n * record the ownership ledger rows (`connectorDir(id)/memory-state.json`).\n * Shared by the base implementation and the exception-host overrides.\n */\n protected writeMemoryBlocks(ctx: InstallContext, targets: MemoryTarget[]): ChangeRecord[] {\n const changes: ChangeRecord[] = [];\n const ledger = loadMemoryLedger(ctx.connector.id);\n let ledgerMutated = false;\n\n for (const target of targets) {\n for (const entry of ctx.connector.memory ?? []) {\n const blockId = `${ctx.connector.id}/${entry.name ?? \"memory\"}`;\n const res = upsertManagedBlockFile(target.path, {\n blockId,\n connectorId: ctx.connector.id,\n content: entry.content,\n ...(target.commentStyle ? { commentStyle: target.commentStyle } : {}),\n force: ctx.force ?? false,\n dryRun: ctx.dryRun,\n });\n changes.push({\n platform: this.id,\n action: res.action,\n path: target.path,\n detail: `memory: ${res.detail} — ${target.reason}`,\n });\n if (res.backupPath) {\n changes.push({\n platform: this.id,\n action: \"create\",\n path: res.backupPath,\n detail: \"backed up memory file before destructive change\",\n });\n }\n const bytes = Buffer.byteLength(entry.content, \"utf8\");\n if (bytes > MEMORY_CONTENT_SOFT_BUDGET_BYTES) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: target.path,\n detail:\n `memory entry \"${entry.name ?? \"memory\"}\" is ${bytes} bytes ` +\n `(soft budget ${MEMORY_CONTENT_SOFT_BUDGET_BYTES}); this file is injected into ` +\n `every prompt — keep guidance terse`,\n });\n }\n if (res.action !== \"warn\") {\n recordMemoryTarget(ledger, {\n platform: this.id,\n scope: ctx.scope,\n path: target.path,\n blockId,\n createdFile: res.createdFile,\n hash: res.hash,\n });\n ledgerMutated = true;\n }\n }\n // Per-FILE budget (e.g. codex caps combined project docs at 32 KiB —\n // budgetBytes ≈ 28 KiB leaves headroom): warn when the whole target file\n // (user content + every block) outgrows what the host will actually load.\n if (target.budgetBytes !== undefined && !ctx.dryRun && existsSync(target.path)) {\n const fileBytes = statSync(target.path).size;\n if (fileBytes > target.budgetBytes) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: target.path,\n detail:\n `memory file is ${fileBytes} bytes — over this host's ~${target.budgetBytes}-byte ` +\n `budget; the host may truncate or drop it`,\n });\n }\n }\n }\n\n if (ledgerMutated && !ctx.dryRun) saveMemoryLedger(ctx.connector.id, ledger);\n return changes;\n }\n\n uninstallMemory(ctx: InstallContext): ChangeRecord[] {\n const { connector } = ctx;\n if (!(this.capabilities.supportsMemory ?? false)) {\n // Nothing could ever have been written by a non-supporting adapter.\n return this.unsupportedSurface(ctx, \"memory\", (connector.memory ?? []).length);\n }\n\n // Candidate files = union of (a) memoryTargets recomputed NOW (probe re-run\n // — catches teammate machines with no ledger; the markers in the committed\n // file are the source of truth) and (b) ledger rows for this platform from\n // EVERY scope (catches a scope flag that differs from install time).\n const ledger = loadMemoryLedger(connector.id);\n const mine = ledger.targets.filter((t) => t.platform === this.id);\n const candidates = new Map<string, { createdFile: boolean }>();\n if (ctx.scope === \"project\" || ctx.scope === \"user\") {\n for (const t of this.memoryTargets(ctx)) {\n candidates.set(t.path, { createdFile: false });\n }\n }\n for (const row of mine) {\n const existing = candidates.get(row.path);\n candidates.set(row.path, { createdFile: (existing?.createdFile ?? false) || row.createdFile });\n }\n if (candidates.size === 0) {\n return [\n { platform: this.id, action: \"skip\", detail: `no memory targets to clean on ${this.id}` },\n ];\n }\n\n // Prefix scan (`<connectorId>/`), NOT the declared entry list: renamed or\n // removed entries and stale blocks from older versions are reclaimed too.\n const changes: ChangeRecord[] = [];\n for (const [path, { createdFile }] of candidates) {\n const results = removeManagedBlocksFile(\n path,\n { blockIdPrefix: `${connector.id}/` },\n { dryRun: ctx.dryRun, deleteFileIfCreated: createdFile },\n );\n for (const r of results) {\n changes.push({\n platform: this.id,\n action: r.action,\n path: r.path,\n detail: `memory: ${r.detail}`,\n });\n if (r.backupPath) {\n changes.push({\n platform: this.id,\n action: \"create\",\n path: r.backupPath,\n detail: \"backed up memory file before block removal\",\n });\n }\n }\n }\n\n // Prune this connector's ledger rows for this platform (the file itself is\n // deleted when no rows remain). Markers stay the uninstall source of truth.\n if (!ctx.dryRun && mine.length > 0) {\n ledger.targets = ledger.targets.filter((t) => t.platform !== this.id);\n saveMemoryLedger(connector.id, ledger);\n }\n return changes;\n }\n\n /**\n * Doctor: per-ledger-row memory state for this platform — file present,\n * block present, and recorded-vs-actual inner hash (drift → warn, the\n * user edited inside our block; sync reports the same drift and never\n * clobbers it without --force).\n */\n protected memoryDiagnostics(ctx: InstallContext): DiagnosticResult[] {\n const results: DiagnosticResult[] = [];\n const rows = loadMemoryLedger(ctx.connector.id).targets.filter(\n (t) => t.platform === this.id,\n );\n for (const row of rows) {\n const check = `${this.name}: memory block ${row.blockId}`;\n if (!existsSync(row.path)) {\n results.push({\n check,\n status: \"warn\",\n message: `memory file missing: ${row.path}`,\n fix: \"agent-connector install (sync) will re-create the block\",\n fixable: true,\n });\n continue;\n }\n let raw: string;\n try {\n raw = readFileSync(row.path, \"utf8\");\n } catch {\n results.push({ check, status: \"warn\", message: `cannot read ${row.path}` });\n continue;\n }\n const block = listManagedBlocks(raw).find((b) => b.blockId === row.blockId);\n if (!block) {\n results.push({\n check,\n status: \"warn\",\n message: `managed block not found in ${row.path}`,\n fix: \"agent-connector install (sync) will re-append it\",\n fixable: true,\n });\n } else if (block.drifted) {\n results.push({\n check,\n status: \"warn\",\n message:\n `user-edited: inner content hash ${block.actualHash} differs from recorded ` +\n `${block.recordedHash} in ${row.path}; sync leaves it intact (use --force to overwrite)`,\n });\n } else {\n results.push({ check, status: \"pass\", message: `intact in ${row.path}` });\n }\n // Shadow-flip probe: re-run memoryTargets NOW for the row's scope — if\n // the host's resolution moved (a WARP.md / AGENTS.override.md / .rules /\n // .hermes.md appeared, gemini context.fileName changed), the written\n // block sits in a file the host no longer reads. The #1 wrong-file\n // risk; doctor is the detection layer.\n // (`_shared/` bridge rows deliberately live OUTSIDE memoryTargets —\n // e.g. claude-code's @AGENTS.md import in CLAUDE.md — skip those.)\n if (\n !row.blockId.startsWith(\"_shared/\") &&\n row.scope === ctx.scope &&\n (ctx.scope === \"project\" || ctx.scope === \"user\")\n ) {\n const current = this.memoryTargets(ctx);\n if (current.length > 0 && !current.some((t) => t.path === row.path)) {\n results.push({\n check,\n status: \"warn\",\n message:\n `${this.id} now resolves its ${row.scope}-scope memory file to ` +\n `${current[0]!.path} (${current[0]!.reason}) — the block in ${row.path} ` +\n `may no longer be read`,\n fix: \"agent-connector install (sync) re-probes and writes the file the host reads now\",\n fixable: true,\n });\n }\n }\n }\n return results;\n }\n\n // ── Declarative host-config key patches (configPatch) ─────────────────────\n // CONCRETE (overridable) defaults, mirroring the content surfaces above: the\n // installer additionally guards these behind capabilities.supportsConfigPatch\n // (the nativeHooks precedent), so these defaults only fire if a capability-\n // flagged adapter forgot to override them — still skip-warn, never silent.\n\n installConfigPatches(ctx: InstallContext): ChangeRecord[] {\n const count = (ctx.connector.platforms[this.id]?.configPatch ?? []).length;\n if (count === 0) {\n return [\n { platform: this.id, action: \"skip\", detail: \"connector declares no configPatch entries\" },\n ];\n }\n return [\n {\n platform: this.id,\n action: \"warn\",\n detail: `configPatch not supported on ${this.id}; ${count} skipped`,\n },\n ];\n }\n\n uninstallConfigPatches(_ctx: InstallContext): ChangeRecord[] {\n // Nothing was ever applied by a non-supporting adapter → nothing to release.\n return [];\n }\n\n // ── Statusline surface (a HUD/status line) ────────────────────────────────\n // CONCRETE (overridable) defaults, mirroring the content surfaces: the\n // installer calls these unconditionally (BaseAdapter defines them), and they\n // self-skip when the connector declares no statusline, else skip-warn on a\n // non-supporting host. Only claude-code overrides them today.\n\n installStatusline(ctx: InstallContext): ChangeRecord[] {\n if (ctx.connector.statusline == null) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no statusline\" }];\n }\n if (ctx.connector.platforms[this.id]?.statusline === false) {\n return [{ platform: this.id, action: \"skip\", detail: `statusline disabled for ${this.id}` }];\n }\n if (!(this.capabilities.supportsStatusline ?? false)) {\n return this.unsupportedSurface(ctx, \"statusline\", 1);\n }\n // A supporting adapter must override this; the default is the same skip-warn\n // safety net the configPatch defaults provide (never silent).\n return this.unsupportedSurface(ctx, \"statusline\", 1);\n }\n\n uninstallStatusline(ctx: InstallContext): ChangeRecord[] {\n if (ctx.connector.statusline == null) {\n return [{ platform: this.id, action: \"skip\", detail: \"connector declares no statusline\" }];\n }\n if (!(this.capabilities.supportsStatusline ?? false)) {\n // Nothing could ever have been written by a non-supporting adapter.\n return this.unsupportedSurface(ctx, \"statusline\", 1);\n }\n return this.unsupportedSurface(ctx, \"statusline\", 1);\n }\n\n // ── Action surface (a user-invokable action) ──────────────────────────────\n // CONCRETE (overridable) defaults, mirroring the statusline pair. v1 ships\n // ONLY the dispatch backbone: there is no verifiable host affordance to emit,\n // so EVERY host honestly skip-warns and NO adapter overrides these. (`?? []`\n // tolerates pre-resolved connectors from versions before the action surface\n // existed, exactly like installMemory.)\n\n installActions(ctx: InstallContext): ChangeRecord[] {\n return this.unsupportedSurface(ctx, \"actions\", (ctx.connector.actions ?? []).length);\n }\n uninstallActions(ctx: InstallContext): ChangeRecord[] {\n return this.unsupportedSurface(ctx, \"actions\", (ctx.connector.actions ?? []).length);\n }\n\n /**\n * Shared, surface-agnostic helper for the action EMITTERS: yield one\n * {@link ActionTrigger} per declared action, each carrying the home-bin verb\n * command the host trigger must run\n * (`<homeBin> action <host> <actionId> --connector <id>`, via\n * {@link buildHomeBinActionCommand}) plus a `label`/`description` that fall\n * back to the action id. Each supporting adapter iterates this and writes its\n * host-native trigger (hermes quick_commands / warp workflow / droid exec\n * file) — the per-host file shape is NOT this helper's concern, only the\n * common (id, label, description, command) tuple. Callers own the standard\n * guards (platforms[id].actions === false / empty actions).\n */\n protected actionTriggers(ctx: InstallContext): ActionTrigger[] {\n return (ctx.connector.actions ?? []).map((action) => ({\n id: action.id,\n label: action.description ?? action.id,\n description: action.description ?? action.id,\n command: buildHomeBinActionCommand(\n ctx.homeBinPath,\n this.id,\n action.id,\n ctx.connector.id,\n ),\n }));\n }\n\n /**\n * Default response for a content surface this platform cannot honor: a single\n * skip when the connector declares none of that surface, else a single \"warn\"\n * ChangeRecord noting how many were skipped. Mirrors mcp-only hook handling.\n */\n protected unsupportedSurface(\n _ctx: InstallContext,\n surface: ContentSurface,\n count: number,\n ): ChangeRecord[] {\n if (count === 0) {\n return [{ platform: this.id, action: \"skip\", detail: `connector declares no ${surface}` }];\n }\n return [\n {\n platform: this.id,\n action: \"warn\",\n detail: `${surface} not supported on ${this.id}; ${count} skipped`,\n },\n ];\n }\n\n // ── Content-file helpers (used by surface-supporting adapters) ────────────\n\n /**\n * Write a content file idempotently: \"skip\" when the existing bytes are\n * already identical, else \"create\"/\"update\". Creates parent dirs (mkdir -p).\n * Honors dryRun (computes the action but writes nothing).\n */\n protected writeContentFile(path: string, contents: string, dryRun: boolean): ChangeRecord {\n let action: ChangeRecord[\"action\"];\n if (!existsSync(path)) {\n action = \"create\";\n } else {\n let current: string | null = null;\n try {\n current = readFileSync(path, \"utf8\");\n } catch {\n current = null;\n }\n action = current === contents ? \"skip\" : \"update\";\n }\n if (action !== \"skip\" && !dryRun) {\n ensureDir(dirname(path));\n writeFileSync(path, contents, \"utf8\");\n }\n return { platform: this.id, action, path, detail: basename(path) };\n }\n\n /**\n * Remove a content file we wrote; \"skip\" when already absent. Honors dryRun.\n * Uses rmSync with `force` to also tolerate a path that is a directory tree\n * (e.g. a skill folder removed by the supporting adapter).\n */\n protected removeContentFile(path: string, dryRun: boolean): ChangeRecord {\n if (!existsSync(path)) {\n return { platform: this.id, action: \"skip\", path, detail: `${basename(path)} absent` };\n }\n if (!dryRun) {\n rmSync(path, { recursive: true, force: true });\n }\n return { platform: this.id, action: \"remove\", path, detail: basename(path) };\n }\n\n /**\n * Defense-in-depth path containment: resolve `rel` against `baseDir` and\n * return the absolute path ONLY when it stays inside `baseDir`. Returns null\n * when `rel` escapes (absolute path, `..` traversal, etc.) so a caller can\n * skip-and-warn rather than write/delete outside the surface dir. This is the\n * runtime backstop behind the config-time validation in normalizeSkills.\n */\n protected resolveWithin(baseDir: string, rel: string): string | null {\n const base = resolve(baseDir);\n const target = resolve(base, rel);\n if (target === base) return null; // rel resolved to the dir itself (e.g. \"\" / \".\")\n const rind = relative(base, target);\n // Outside when the relative path climbs out (`..`) or is itself absolute.\n if (rind === \"\" || rind.startsWith(\"..\") || resolve(base, rind) !== target) {\n return null;\n }\n if (rind === \"..\" || rind.startsWith(`..${sep}`)) return null;\n return target;\n }\n\n /**\n * Recursively report whether a directory tree contains any regular FILE (vs\n * only empty/nested-empty subdirectories). Symlinks count as files (we never\n * recurse through them). Used by removeDirIfEmpty to decide if a tree is safe\n * to drop. An unreadable entry is treated as \"a file is present\" (conservative).\n */\n private dirTreeHasFile(dir: string): boolean {\n let entries: Dirent[];\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch {\n return true; // unreadable → assume it holds data; do not remove\n }\n for (const e of entries) {\n if (e.isDirectory()) {\n if (this.dirTreeHasFile(join(dir, e.name))) return true;\n } else {\n return true; // a file / symlink / special → the tree is not \"empty\"\n }\n }\n return false;\n }\n\n /**\n * Remove a directory ONLY when its tree holds NO regular files — i.e. it is\n * empty or contains only (nested) empty directories, such as the intermediate\n * dirs our own nested skill resources created. Replaces the unconditional\n * `rm -rf <dir>` that uninstallSkills used to call, which destroyed user-added\n * files / sibling-tool files / shared skill dirs the connector never wrote.\n * When ANY file remains (at any depth) the whole tree is left in place and the\n * skip is noted. Honors dryRun (computes the action but removes nothing). A\n * missing dir is a no-op \"skip\".\n */\n protected removeDirIfEmpty(dir: string, dryRun: boolean): ChangeRecord {\n if (!existsSync(dir)) {\n return { platform: this.id, action: \"skip\", path: dir, detail: `${basename(dir)} absent` };\n }\n let stat: ReturnType<typeof statSync>;\n try {\n stat = statSync(dir);\n } catch {\n return {\n platform: this.id,\n action: \"skip\",\n path: dir,\n detail: `${basename(dir)} unreadable; left in place`,\n };\n }\n if (!stat.isDirectory()) {\n return {\n platform: this.id,\n action: \"skip\",\n path: dir,\n detail: `${basename(dir)} not a directory; left in place`,\n };\n }\n if (this.dirTreeHasFile(dir)) {\n return {\n platform: this.id,\n action: \"skip\",\n path: dir,\n detail: `${basename(dir)} still holds files we did not write; left in place`,\n };\n }\n if (!dryRun) {\n try {\n // The tree is files-free: only (possibly nested) empty dirs remain, which\n // are ours / inert. A recursive remove drops them without touching data.\n rmSync(dir, { recursive: true, force: true });\n } catch {\n // Lost a race or perms — non-fatal; report as a skip.\n return {\n platform: this.id,\n action: \"skip\",\n path: dir,\n detail: `${basename(dir)} could not be removed; left in place`,\n };\n }\n }\n return { platform: this.id, action: \"remove\", path: dir, detail: basename(dir) };\n }\n\n /**\n * Render a YAML-frontmatter + markdown body document:\n * \"---\\n\" + <yaml> + \"---\\n\\n\" + <body> + \"\\n\".\n * Delegates to the shared renderer (adapters/claude-code/render) so every\n * content-file path — adapters AND the plugin packager — emits identical bytes.\n */\n protected renderFrontmatterMd(\n frontmatter: Record<string, unknown>,\n body: string,\n ): string {\n return renderFrontmatterMd(frontmatter, body);\n }\n\n // ── JSON config helpers (used by JSON-format adapters) ───────────────────\n\n /**\n * Read + parse a JSON/JSONC config file, returning null when it is absent OR\n * unparseable. Parses TOLERANTLY via parseJsonc (strips // and /* *\\/ comments\n * and trailing commas) so a perfectly valid JSONC file never false-fails to\n * null — that null is what `?? {}` would otherwise turn into a clobbering\n * overwrite of the user's whole config.\n */\n protected readJson<T = Record<string, unknown>>(path: string): T | null {\n if (!existsSync(path)) return null;\n try {\n return parseJsonc<T>(readFileSync(path, \"utf8\"));\n } catch {\n return null;\n }\n }\n\n /**\n * True when `path` exists and holds non-whitespace content but readJson cannot\n * parse it (even after JSONC stripping). The overwrite guard: writing a\n * `{}`-based config over a present-but-broken settings file would silently\n * destroy the user's data, so callers warn-and-skip instead.\n */\n protected isPresentButUnparseable(path: string): boolean {\n if (!existsSync(path)) return false;\n let raw: string;\n try {\n if (statSync(path).size === 0) return false;\n raw = readFileSync(path, \"utf8\");\n } catch {\n return false;\n }\n if (raw.trim() === \"\") return false;\n return this.readJson(path) === null;\n }\n\n protected writeJson(path: string, data: unknown, dryRun = false): void {\n if (dryRun) return;\n ensureDir(dirname(path));\n writeFileSync(path, `${JSON.stringify(data, null, 2)}\\n`, \"utf8\");\n }\n\n /**\n * True when a PRESENT rootKey value is not a plain object map (the user\n * hand-edited it to an array / string / number / boolean). Assigning a server\n * entry into such a value would corrupt the file silently (a named property on\n * an Array is dropped by JSON.stringify) or throw under strict mode (a property\n * write / `in` operator against a primitive), so callers warn-and-skip. A\n * `null`/`undefined` value is NOT malformed — it is the well-formed \"absent\"\n * case the helpers create fresh.\n */\n protected isMalformedRootValue(value: unknown): boolean {\n return isMalformedRootValueFn(value);\n }\n\n /**\n * Warn-skip ChangeRecord when an existing JSON `hooks` config is present-but-\n * malformed (root hand-edited to an array/primitive, or an existing event\n * bucket is a non-array) — installing a hook into it would silently drop the\n * entry (a named property on an Array is dropped by JSON.stringify) or throw\n * under strict mode (a `.push`/property write against a primitive or non-array\n * bucket). Returns null when the hooks config is well-formed, including the\n * absent case the installers create fresh (proceed normally). Mirrors the\n * server-root guard (isMalformedRootValue). All targeted hosts use the Claude-\n * style `{ Event: Matcher[] }` shape, so every present event bucket must be an\n * array; a non-array bucket is the same malformed class as a wrong-typed root.\n */\n protected malformedHookRootSkip(configPath: string, hooksRoot: unknown): ChangeRecord | null {\n if (hooksRoot == null) return null; // absent → installer creates fresh\n if (this.isMalformedRootValue(hooksRoot)) {\n // array / primitive root\n return {\n platform: this.id,\n action: \"warn\",\n path: configPath,\n detail: `existing \"hooks\" in ${configPath} is not an object map; left untouched (fix it, then re-run)`,\n };\n }\n for (const v of Object.values(hooksRoot as Record<string, unknown>)) {\n if (v !== undefined && !Array.isArray(v)) {\n // an existing event bucket is a non-array\n return {\n platform: this.id,\n action: \"warn\",\n path: configPath,\n detail: `existing \"hooks\" in ${configPath} has a non-array event bucket; left untouched (fix it, then re-run)`,\n };\n }\n }\n return null;\n }\n\n // ── Shared object-map hook-array merge engine ────────────────────────────\n // installHooks/uninstallHooks for every json-stdio host that stores hooks as\n // `{ <event>: HookEntry[] }` share ONE create/update/skip + strip/remove\n // orchestration. The host supplies a {@link HookMergeDescriptor} carrying\n // EVERY observable string and ownership predicate — the engine body hardcodes\n // none of them, so per-host wording (skip/remove/absent/no-match details) and\n // FLAT-vs-NESTED removal stay host-controlled and never drift to a lowest-\n // common-denominator phrasing the suites (which assert by action) would miss.\n // The write-gate is the `mutated` bool, matching the migrated host exactly.\n\n /**\n * Install: upsert each `{ event, matcher }` in `pending` into the object-map\n * `hooks` root at `configPath`. Reproduces the canonical host's loop: read\n * `?? {}`, warn-skip on a malformed `hooks` root, then per pending item render\n * the entry, find the owned slot, and create/update/skip. Writes once at the\n * end iff anything mutated.\n *\n * Hosts that fold their `nativeHooks` surface into `pending` (claude-code) pass\n * no `native` arg. Hosts that keep the native surface SEPARATE — verbatim\n * event keys, EXACT-command ownership, a distinct `(native)` detail — pass it\n * as the optional `native` list (cursor); that pass runs after the normalized\n * loop and before the single write. Omitting it is byte-identical to before.\n */\n /**\n * Resolve the per-event hook bucket. With \"coerce\" policy a present-but-non-\n * array bucket (hand-edited) is replaced by a fresh array; otherwise `??=` is\n * used (the warn-skip path already rejected any non-array bucket via\n * malformedHookRootSkip, so `??=` only ever fills the absent case).\n */\n private coerceHookBucket<E>(\n hooks: Record<string, E[]>,\n event: string,\n coerce: boolean,\n ): E[] {\n if (coerce) {\n return Array.isArray(hooks[event]) ? hooks[event] : (hooks[event] = []);\n }\n return (hooks[event] ??= []);\n }\n\n protected upsertHookEntries<E>(\n ctx: InstallContext,\n configPath: string,\n pending: ReadonlyArray<{ event: string; matcher: string }>,\n descriptor: HookMergeDescriptor<E>,\n native?: ReadonlyArray<{ event: string; matcher: string }>,\n ): ChangeRecord[] {\n const file = this.readJson<Record<string, unknown>>(configPath) ?? {};\n const coerce = descriptor.malformedPolicy === \"coerce\";\n let hooks: Record<string, E[]>;\n if (coerce) {\n // COERCE policy: a present-but-malformed `hooks` root (array / primitive,\n // hand-edited) is replaced by a fresh object map; a well-formed object map\n // is kept as-is. Never warn, never throw — matches the container hosts'\n // server-path policy.\n const existing = file.hooks;\n hooks =\n existing && typeof existing === \"object\" && !Array.isArray(existing)\n ? (existing as Record<string, E[]>)\n : ((file.hooks = {}) as Record<string, E[]>);\n } else {\n const skip = this.malformedHookRootSkip(configPath, file.hooks);\n if (skip) return [skip];\n hooks = (file.hooks ??= {}) as Record<string, E[]>;\n }\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n\n for (const { event, matcher } of pending) {\n const hostEvent = descriptor.mapEvent ? descriptor.mapEvent(event) : event;\n if (hostEvent === undefined) {\n changes.push({\n platform: this.id,\n action: \"warn\",\n path: configPath,\n detail: descriptor.unmappedWarnDetail!(event),\n });\n continue;\n }\n // Command is built from the CANONICAL `event` (NOT hostEvent) — the home\n // binary dispatches on the canonical name; only the host's bucket key,\n // detail, and skipDetail use the mapped `hostEvent`.\n const command = buildHomeBinHookCommand(\n ctx.homeBinPath,\n this.id,\n event,\n ctx.connector.id,\n );\n const entry = descriptor.renderEntry(hostEvent, matcher, command);\n const bucket = this.coerceHookBucket(hooks, hostEvent, coerce);\n const r = upsertInArray(bucket, entry, (e) =>\n descriptor.entryOwnsCommand(e, command),\n );\n\n if (r.action !== \"skip\") {\n hooks[hostEvent] = r.array;\n mutated = true;\n }\n changes.push({\n platform: this.id,\n action: r.action,\n path: configPath,\n detail:\n r.action === \"skip\"\n ? descriptor.skipDetail(hostEvent)\n : `hooks.${hostEvent}`,\n });\n }\n\n // Native pass (json-stdio hosts with a verbatim `nativeHooks` surface):\n // native event-name keys are NOT mapEvent-mapped, are found by EXACT command\n // (so a native key coinciding with a normalized event's mapped key adds a\n // SECOND distinct command rather than clobbering it), and carry the `(native)`\n // detail. Hosts passing no `native` list skip this loop entirely → the\n // normalized-only behavior is byte-identical.\n for (const { event, matcher } of native ?? []) {\n const command = buildHomeBinHookCommand(\n ctx.homeBinPath,\n this.id,\n event,\n ctx.connector.id,\n );\n const entry = descriptor.renderEntry(event, matcher, command);\n const bucket = this.coerceHookBucket(hooks, event, coerce);\n const r = upsertInArray(bucket, entry, (e) =>\n descriptor.nativeOwnsCommand!(e, command),\n );\n if (r.action !== \"skip\") {\n hooks[event] = r.array;\n mutated = true;\n }\n changes.push({\n platform: this.id,\n action: r.action,\n path: configPath,\n detail:\n r.action === \"skip\"\n ? descriptor.nativeSkipDetail!(event)\n : descriptor.nativeMutateDetail!(event),\n });\n }\n\n if (mutated) {\n descriptor.onMutate?.(file);\n this.writeJson(configPath, file, ctx.dryRun);\n }\n return changes;\n }\n\n /**\n * Uninstall: strip owned content from every event bucket in the object-map\n * `hooks` root at `configPath`. NESTED hosts pass `descriptor.stripInner`\n * (strip owned inner commands, drop emptied entries; `removed` = inner\n * commands); FLAT hosts omit it (drop whole owned entries). Reproduces the\n * canonical host: read (NO `?? {}`), `[skip]` (absentDetail) when no hooks\n * section, per-event remove → delete-or-replace bucket, write once iff\n * mutated, and a single `[skip]` (noMatchDetail) when nothing matched.\n */\n protected removeHookEntries<E>(\n ctx: InstallContext,\n configPath: string,\n descriptor: HookMergeDescriptor<E>,\n ): ChangeRecord[] {\n const file = this.readJson<Record<string, unknown>>(configPath);\n const hooks = file?.hooks as Record<string, E[]> | undefined;\n if (!file || !hooks) {\n return [\n {\n platform: this.id,\n action: \"skip\",\n path: configPath,\n detail: descriptor.absentDetail,\n },\n ];\n }\n\n const changes: ChangeRecord[] = [];\n let mutated = false;\n // stripInner is event-independent for current hosts → computed once. The\n // whole-entry ownership predicate is rebuilt PER EVENT so EVENT-SPECIFIC\n // hosts (codex) can match the canonical event being stripped; event-agnostic\n // hosts simply ignore the param.\n const stripInner = descriptor.stripInner?.(ctx);\n\n // Default: scan every present key. EVENT-SPECIFIC hosts pin a fixed event set\n // (descriptor.removeEventKeys) so a foreign-key bucket is never inspected —\n // matching their original fixed-event-list uninstall loop byte-for-byte.\n for (const event of descriptor.removeEventKeys ?? Object.keys(hooks)) {\n const bucket = hooks[event];\n if (!Array.isArray(bucket)) continue;\n\n const ownsEntry = descriptor.ownsEntryForRemove(ctx, event);\n const r = removeFromArray(bucket, ownsEntry, stripInner);\n if (r.removed > 0) {\n if (r.array.length > 0) hooks[event] = r.array;\n else delete hooks[event];\n changes.push({\n platform: this.id,\n action: \"remove\",\n path: configPath,\n detail: descriptor.removeDetail(event, r.removed),\n });\n mutated = true;\n }\n }\n\n if (mutated) this.writeJson(configPath, file, ctx.dryRun);\n if (changes.length === 0) {\n changes.push({\n platform: this.id,\n action: \"skip\",\n path: configPath,\n detail: descriptor.noMatchDetail,\n });\n }\n return changes;\n }\n\n /** Bind BaseAdapter's JSON leaf IO (readJson/writeJson + the unparseable\n * overwrite guard) as a Codec for the object-map engine. */\n private jsonObjectMapCodec(): ObjectMapCodec {\n return {\n parse: (path) => this.readJson<Record<string, unknown>>(path),\n serialize: (path, data, dryRun) => this.writeJson(path, data, dryRun),\n isPresentButUnparseable: (path) => this.isPresentButUnparseable(path),\n };\n }\n\n /**\n * Upsert `entry` at `config[rootKey][serverId]` in a JSON file, creating the\n * file/object as needed. Returns a ChangeRecord describing create/update/skip.\n * Idempotent: an identical entry yields \"skip\".\n */\n protected upsertServerInJson(\n configPath: string,\n rootKey: string,\n serverId: string,\n entry: unknown,\n dryRun = false,\n ): ChangeRecord {\n return upsertInObjectMap({\n codec: this.jsonObjectMapCodec(),\n rootKey,\n platform: this.id,\n configPath,\n entryId: serverId,\n entry,\n dryRun,\n });\n }\n\n /** Remove `config[rootKey][serverId]` from a JSON file. */\n protected removeServerFromJson(\n configPath: string,\n rootKey: string,\n serverId: string,\n dryRun = false,\n ): ChangeRecord {\n return removeFromObjectMap({\n codec: this.jsonObjectMapCodec(),\n rootKey,\n platform: this.id,\n configPath,\n entryId: serverId,\n dryRun,\n });\n }\n\n // ── Backup ───────────────────────────────────────────────────────────────\n\n backupSettings(ctx: InstallContext): string | null {\n const files = [...new Set([this.getServerConfigPath(ctx), this.getHookConfigPath(ctx)])].filter(\n (f) => existsSync(f),\n );\n if (files.length === 0) return null;\n if (ctx.dryRun) return null;\n ensureDir(backupsDir());\n const stamp = new Date().toISOString().replace(/[:.]/g, \"-\");\n let last: string | null = null;\n for (const f of files) {\n const dest = join(backupsDir(), `${this.id}-${stamp}-${basename(f)}`);\n copyFileSync(f, dest);\n last = dest;\n }\n return last;\n }\n\n // ── Diagnostics ─────────────────────────────────────────────────────────\n\n getHealthChecks?(ctx: InstallContext): readonly HealthCheck[];\n\n doctor(ctx: InstallContext): DiagnosticResult[] {\n const results: DiagnosticResult[] = [];\n const cfg = this.getServerConfigPath(ctx);\n results.push(\n existsSync(cfg)\n ? { check: `${this.name}: config present`, status: \"pass\", message: cfg }\n : {\n check: `${this.name}: config present`,\n status: \"warn\",\n message: `not found: ${cfg}`,\n fix: `agent-connector install --targets ${this.id}`,\n // Only sync-recoverable when the connector actually declares a\n // server — a re-sync writes the config file only then. For a\n // serverless (memory/configPatch-only) connector the file is never\n // created, so marking it fixable would loop it into \"still failing\".\n fixable: !!ctx.connector.server,\n },\n );\n for (const hc of this.getHealthChecks?.(ctx) ?? []) {\n const r = hc.check();\n results.push({\n check: hc.name,\n status: r.status === \"OK\" ? \"pass\" : \"fail\",\n message: r.detail ?? r.status,\n });\n }\n // Memory-surface checks are ledger-driven: no installed memory → no rows →\n // no noise. Shared by every adapter (the overrides call super.doctor()).\n results.push(...this.memoryDiagnostics(ctx));\n return results;\n }\n}\n","/** Decision for one inner-array upsert. */\nexport type ArrayUpsertAction = \"create\" | \"update\" | \"skip\";\n\nexport interface ArrayUpsertResult<E> {\n array: E[];\n action: ArrayUpsertAction;\n}\n\n/**\n * Upsert one rendered `candidate` into a per-event hook array.\n * - find the FIRST entry the caller OWNS via `ownsEntry`;\n * - hit + JSON-equal → skip (array returned unchanged);\n * - hit + differs → update (replace that slot);\n * - miss → create (push).\n */\nexport function upsertInArray<E>(\n array: E[],\n candidate: E,\n ownsEntry: (entry: E) => boolean,\n): ArrayUpsertResult<E> {\n const idx = array.findIndex(ownsEntry);\n if (idx >= 0) {\n if (JSON.stringify(array[idx]) === JSON.stringify(candidate)) {\n return { array, action: \"skip\" };\n }\n const next = array.slice();\n next[idx] = candidate;\n return { array: next, action: \"update\" };\n }\n return { array: [...array, candidate], action: \"create\" };\n}\n\nexport interface ArrayRemoveResult<E> {\n array: E[];\n removed: number;\n}\n\n/**\n * Remove owned content from a per-event hook array.\n * - FLAT hosts: omit `stripInner` → drop whole entries matching `ownsEntry`;\n * `removed` = whole entries dropped.\n * - NESTED hosts: pass `stripInner` → strip owned inner commands and rebuild,\n * dropping entries left empty; `removed` = inner commands removed.\n */\nexport function removeFromArray<E>(\n array: E[],\n ownsEntry: (entry: E) => boolean,\n stripInner?: (entry: E) => { next: E | null; removed: number },\n): ArrayRemoveResult<E> {\n if (!stripInner) {\n const kept = array.filter((e) => !ownsEntry(e));\n return { array: kept, removed: array.length - kept.length };\n }\n const kept: E[] = [];\n let removed = 0;\n for (const e of array) {\n const r = stripInner(e);\n removed += r.removed;\n if (r.next !== null) kept.push(r.next);\n }\n return { array: kept, removed };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA4BO,SAAS,WAAW,MAAsB;AAC/C,QAAM,IAAI,KAAK;AACf,MAAI,MAAM;AACV,MAAI,IAAI;AACR,MAAI,WAAW;AACf,MAAI,QAAQ;AAEZ,SAAO,IAAI,GAAG;AACZ,UAAM,KAAK,KAAK,CAAC;AAEjB,QAAI,UAAU;AACZ,aAAO;AACP,UAAI,OAAO,MAAM;AAEf,YAAI,IAAI,IAAI,GAAG;AACb,iBAAO,KAAK,IAAI,CAAC;AACjB,eAAK;AACL;AAAA,QACF;AAAA,MACF,WAAW,OAAO,OAAO;AACvB,mBAAW;AAAA,MACb;AACA,WAAK;AACL;AAAA,IACF;AAEA,UAAM,OAAO,IAAI,IAAI,IAAK,KAAK,IAAI,CAAC,IAAe;AAGnD,QAAI,OAAO,OAAO,OAAO,KAAK;AAC5B,iBAAW;AACX,cAAQ;AACR,aAAO;AACP,WAAK;AACL;AAAA,IACF;AAGA,QAAI,OAAO,OAAO,SAAS,KAAK;AAC9B,WAAK;AACL,aAAO,IAAI,KAAK,KAAK,CAAC,MAAM,KAAM,MAAK;AACvC;AAAA,IACF;AAGA,QAAI,OAAO,OAAO,SAAS,KAAK;AAC9B,WAAK;AACL,aAAO,IAAI,KAAK,EAAE,KAAK,CAAC,MAAM,OAAO,KAAK,IAAI,CAAC,MAAM,KAAM,MAAK;AAChE,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