@skillsmith/core 0.9.0 → 0.10.0

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 (313) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/src/api/client.d.ts.map +1 -1
  4. package/dist/src/api/client.js +6 -0
  5. package/dist/src/api/client.js.map +1 -1
  6. package/dist/src/api/client.test.d.ts +9 -0
  7. package/dist/src/api/client.test.d.ts.map +1 -0
  8. package/dist/src/api/client.test.js +81 -0
  9. package/dist/src/api/client.test.js.map +1 -0
  10. package/dist/src/exports/services.d.ts +3 -1
  11. package/dist/src/exports/services.d.ts.map +1 -1
  12. package/dist/src/exports/services.js +7 -1
  13. package/dist/src/exports/services.js.map +1 -1
  14. package/dist/src/index.d.ts +3 -3
  15. package/dist/src/index.d.ts.map +1 -1
  16. package/dist/src/index.js +5 -2
  17. package/dist/src/index.js.map +1 -1
  18. package/dist/src/install/agent-config-merge.json-array.d.ts +29 -0
  19. package/dist/src/install/agent-config-merge.json-array.d.ts.map +1 -0
  20. package/dist/src/install/agent-config-merge.json-array.js +100 -0
  21. package/dist/src/install/agent-config-merge.json-array.js.map +1 -0
  22. package/dist/src/install/agent-config-merge.json.d.ts +37 -0
  23. package/dist/src/install/agent-config-merge.json.d.ts.map +1 -0
  24. package/dist/src/install/agent-config-merge.json.js +134 -0
  25. package/dist/src/install/agent-config-merge.json.js.map +1 -0
  26. package/dist/src/install/agent-config-merge.toml-block.d.ts +48 -0
  27. package/dist/src/install/agent-config-merge.toml-block.d.ts.map +1 -0
  28. package/dist/src/install/agent-config-merge.toml-block.js +107 -0
  29. package/dist/src/install/agent-config-merge.toml-block.js.map +1 -0
  30. package/dist/src/install/agent-config-merge.types.d.ts +87 -0
  31. package/dist/src/install/agent-config-merge.types.d.ts.map +1 -0
  32. package/dist/src/install/agent-config-merge.types.js +83 -0
  33. package/dist/src/install/agent-config-merge.types.js.map +1 -0
  34. package/dist/src/install/agent-config-merge.yaml.d.ts +46 -0
  35. package/dist/src/install/agent-config-merge.yaml.d.ts.map +1 -0
  36. package/dist/src/install/agent-config-merge.yaml.js +133 -0
  37. package/dist/src/install/agent-config-merge.yaml.js.map +1 -0
  38. package/dist/src/install/agent-config-merge.yaml.test.d.ts +2 -0
  39. package/dist/src/install/agent-config-merge.yaml.test.d.ts.map +1 -0
  40. package/dist/src/install/agent-config-merge.yaml.test.js +210 -0
  41. package/dist/src/install/agent-config-merge.yaml.test.js.map +1 -0
  42. package/dist/src/install/agent-harness-targets.d.ts +98 -0
  43. package/dist/src/install/agent-harness-targets.d.ts.map +1 -0
  44. package/dist/src/install/agent-harness-targets.js +154 -0
  45. package/dist/src/install/agent-harness-targets.js.map +1 -0
  46. package/dist/src/install/agent-home-relocate.d.ts +29 -0
  47. package/dist/src/install/agent-home-relocate.d.ts.map +1 -0
  48. package/dist/src/install/agent-home-relocate.js +38 -0
  49. package/dist/src/install/agent-home-relocate.js.map +1 -0
  50. package/dist/src/install/agent-manifest-path-guard.d.ts +55 -0
  51. package/dist/src/install/agent-manifest-path-guard.d.ts.map +1 -0
  52. package/dist/src/install/agent-manifest-path-guard.js +109 -0
  53. package/dist/src/install/agent-manifest-path-guard.js.map +1 -0
  54. package/dist/src/install/agent-manifest-path-guard.test.d.ts +2 -0
  55. package/dist/src/install/agent-manifest-path-guard.test.d.ts.map +1 -0
  56. package/dist/src/install/agent-manifest-path-guard.test.js +72 -0
  57. package/dist/src/install/agent-manifest-path-guard.test.js.map +1 -0
  58. package/dist/src/install/agent-manifest.d.ts +58 -0
  59. package/dist/src/install/agent-manifest.d.ts.map +1 -0
  60. package/dist/src/install/agent-manifest.js +103 -0
  61. package/dist/src/install/agent-manifest.js.map +1 -0
  62. package/dist/src/install/agent-pack-installer.d.ts +39 -0
  63. package/dist/src/install/agent-pack-installer.d.ts.map +1 -0
  64. package/dist/src/install/agent-pack-installer.entry.d.ts +55 -0
  65. package/dist/src/install/agent-pack-installer.entry.d.ts.map +1 -0
  66. package/dist/src/install/agent-pack-installer.entry.js +90 -0
  67. package/dist/src/install/agent-pack-installer.entry.js.map +1 -0
  68. package/dist/src/install/agent-pack-installer.fs-helpers.d.ts +33 -0
  69. package/dist/src/install/agent-pack-installer.fs-helpers.d.ts.map +1 -0
  70. package/dist/src/install/agent-pack-installer.fs-helpers.js +59 -0
  71. package/dist/src/install/agent-pack-installer.fs-helpers.js.map +1 -0
  72. package/dist/src/install/agent-pack-installer.harness.d.ts +66 -0
  73. package/dist/src/install/agent-pack-installer.harness.d.ts.map +1 -0
  74. package/dist/src/install/agent-pack-installer.harness.js +310 -0
  75. package/dist/src/install/agent-pack-installer.harness.js.map +1 -0
  76. package/dist/src/install/agent-pack-installer.js +221 -0
  77. package/dist/src/install/agent-pack-installer.js.map +1 -0
  78. package/dist/src/install/agent-pack-installer.preserve.test.d.ts +11 -0
  79. package/dist/src/install/agent-pack-installer.preserve.test.d.ts.map +1 -0
  80. package/dist/src/install/agent-pack-installer.preserve.test.js +72 -0
  81. package/dist/src/install/agent-pack-installer.preserve.test.js.map +1 -0
  82. package/dist/src/install/agent-pack-installer.test.d.ts +2 -0
  83. package/dist/src/install/agent-pack-installer.test.d.ts.map +1 -0
  84. package/dist/src/install/agent-pack-installer.test.js +350 -0
  85. package/dist/src/install/agent-pack-installer.test.js.map +1 -0
  86. package/dist/src/install/agent-pack-installer.types.d.ts +51 -0
  87. package/dist/src/install/agent-pack-installer.types.d.ts.map +1 -0
  88. package/dist/src/install/agent-pack-installer.types.js +16 -0
  89. package/dist/src/install/agent-pack-installer.types.js.map +1 -0
  90. package/dist/src/install/agent-pack-uninstaller.d.ts +43 -0
  91. package/dist/src/install/agent-pack-uninstaller.d.ts.map +1 -0
  92. package/dist/src/install/agent-pack-uninstaller.js +113 -0
  93. package/dist/src/install/agent-pack-uninstaller.js.map +1 -0
  94. package/dist/src/install/agent-pack-uninstaller.test.d.ts +2 -0
  95. package/dist/src/install/agent-pack-uninstaller.test.d.ts.map +1 -0
  96. package/dist/src/install/agent-pack-uninstaller.test.js +212 -0
  97. package/dist/src/install/agent-pack-uninstaller.test.js.map +1 -0
  98. package/dist/src/install/index.d.ts +7 -0
  99. package/dist/src/install/index.d.ts.map +1 -1
  100. package/dist/src/install/index.js +7 -0
  101. package/dist/src/install/index.js.map +1 -1
  102. package/dist/src/install/paths.d.ts +1 -1
  103. package/dist/src/install/paths.d.ts.map +1 -1
  104. package/dist/src/install/paths.js +4 -0
  105. package/dist/src/install/paths.js.map +1 -1
  106. package/dist/src/install/paths.test.js +15 -0
  107. package/dist/src/install/paths.test.js.map +1 -1
  108. package/dist/src/journal/hash.d.ts +13 -0
  109. package/dist/src/journal/hash.d.ts.map +1 -0
  110. package/dist/src/journal/hash.js +16 -0
  111. package/dist/src/journal/hash.js.map +1 -0
  112. package/dist/src/journal/index.d.ts +15 -0
  113. package/dist/src/journal/index.d.ts.map +1 -0
  114. package/dist/src/journal/index.js +15 -0
  115. package/dist/src/journal/index.js.map +1 -0
  116. package/dist/src/journal/journal.test.d.ts +16 -0
  117. package/dist/src/journal/journal.test.d.ts.map +1 -0
  118. package/dist/src/journal/journal.test.js +171 -0
  119. package/dist/src/journal/journal.test.js.map +1 -0
  120. package/dist/src/journal/path.d.ts +44 -0
  121. package/dist/src/journal/path.d.ts.map +1 -0
  122. package/dist/src/journal/path.js +61 -0
  123. package/dist/src/journal/path.js.map +1 -0
  124. package/dist/src/journal/reader.d.ts +38 -0
  125. package/dist/src/journal/reader.d.ts.map +1 -0
  126. package/dist/src/journal/reader.js +93 -0
  127. package/dist/src/journal/reader.js.map +1 -0
  128. package/dist/src/journal/types.d.ts +87 -0
  129. package/dist/src/journal/types.d.ts.map +1 -0
  130. package/dist/src/journal/types.js +21 -0
  131. package/dist/src/journal/types.js.map +1 -0
  132. package/dist/src/journal/writer.d.ts +52 -0
  133. package/dist/src/journal/writer.d.ts.map +1 -0
  134. package/dist/src/journal/writer.js +125 -0
  135. package/dist/src/journal/writer.js.map +1 -0
  136. package/dist/src/paywall-triggers/index.d.ts +13 -0
  137. package/dist/src/paywall-triggers/index.d.ts.map +1 -0
  138. package/dist/src/paywall-triggers/index.js +13 -0
  139. package/dist/src/paywall-triggers/index.js.map +1 -0
  140. package/dist/src/paywall-triggers/path.d.ts +47 -0
  141. package/dist/src/paywall-triggers/path.d.ts.map +1 -0
  142. package/dist/src/paywall-triggers/path.js +73 -0
  143. package/dist/src/paywall-triggers/path.js.map +1 -0
  144. package/dist/src/paywall-triggers/store.d.ts +75 -0
  145. package/dist/src/paywall-triggers/store.d.ts.map +1 -0
  146. package/dist/src/paywall-triggers/store.js +122 -0
  147. package/dist/src/paywall-triggers/store.js.map +1 -0
  148. package/dist/src/paywall-triggers/store.test.d.ts +2 -0
  149. package/dist/src/paywall-triggers/store.test.d.ts.map +1 -0
  150. package/dist/src/paywall-triggers/store.test.js +121 -0
  151. package/dist/src/paywall-triggers/store.test.js.map +1 -0
  152. package/dist/src/paywall-triggers/types.d.ts +24 -0
  153. package/dist/src/paywall-triggers/types.d.ts.map +1 -0
  154. package/dist/src/paywall-triggers/types.js +13 -0
  155. package/dist/src/paywall-triggers/types.js.map +1 -0
  156. package/dist/src/security/scanner/SecurityScanner.compound.d.ts +13 -0
  157. package/dist/src/security/scanner/SecurityScanner.compound.d.ts.map +1 -0
  158. package/dist/src/security/scanner/SecurityScanner.compound.js +127 -0
  159. package/dist/src/security/scanner/SecurityScanner.compound.js.map +1 -0
  160. package/dist/src/security/scanner/SecurityScanner.d.ts.map +1 -1
  161. package/dist/src/security/scanner/SecurityScanner.js +10 -1
  162. package/dist/src/security/scanner/SecurityScanner.js.map +1 -1
  163. package/dist/src/security/scanner/SecurityScanner.pii.d.ts +23 -0
  164. package/dist/src/security/scanner/SecurityScanner.pii.d.ts.map +1 -0
  165. package/dist/src/security/scanner/SecurityScanner.pii.js +152 -0
  166. package/dist/src/security/scanner/SecurityScanner.pii.js.map +1 -0
  167. package/dist/src/security/scanner/SecurityScanner.scanners.d.ts +5 -12
  168. package/dist/src/security/scanner/SecurityScanner.scanners.d.ts.map +1 -1
  169. package/dist/src/security/scanner/SecurityScanner.scanners.js +63 -137
  170. package/dist/src/security/scanner/SecurityScanner.scanners.js.map +1 -1
  171. package/dist/src/security/scanner/patterns.d.ts +2 -0
  172. package/dist/src/security/scanner/patterns.d.ts.map +1 -1
  173. package/dist/src/security/scanner/patterns.js +79 -11
  174. package/dist/src/security/scanner/patterns.js.map +1 -1
  175. package/dist/src/security/scanner/types.d.ts +2 -0
  176. package/dist/src/security/scanner/types.d.ts.map +1 -1
  177. package/dist/src/services/agent-pack/agent-pack.test.d.ts +18 -0
  178. package/dist/src/services/agent-pack/agent-pack.test.d.ts.map +1 -0
  179. package/dist/src/services/agent-pack/agent-pack.test.js +344 -0
  180. package/dist/src/services/agent-pack/agent-pack.test.js.map +1 -0
  181. package/dist/src/services/agent-pack/hooks.d.ts +29 -0
  182. package/dist/src/services/agent-pack/hooks.d.ts.map +1 -0
  183. package/dist/src/services/agent-pack/hooks.js +139 -0
  184. package/dist/src/services/agent-pack/hooks.js.map +1 -0
  185. package/dist/src/services/agent-pack/index.d.ts +26 -0
  186. package/dist/src/services/agent-pack/index.d.ts.map +1 -0
  187. package/dist/src/services/agent-pack/index.js +109 -0
  188. package/dist/src/services/agent-pack/index.js.map +1 -0
  189. package/dist/src/services/agent-pack/prompt-source.d.ts +47 -0
  190. package/dist/src/services/agent-pack/prompt-source.d.ts.map +1 -0
  191. package/dist/src/services/agent-pack/prompt-source.js +182 -0
  192. package/dist/src/services/agent-pack/prompt-source.js.map +1 -0
  193. package/dist/src/services/agent-pack/shims.d.ts +40 -0
  194. package/dist/src/services/agent-pack/shims.d.ts.map +1 -0
  195. package/dist/src/services/agent-pack/shims.js +96 -0
  196. package/dist/src/services/agent-pack/shims.js.map +1 -0
  197. package/dist/src/services/agent-pack/skill-md.d.ts +35 -0
  198. package/dist/src/services/agent-pack/skill-md.d.ts.map +1 -0
  199. package/dist/src/services/agent-pack/skill-md.js +89 -0
  200. package/dist/src/services/agent-pack/skill-md.js.map +1 -0
  201. package/dist/src/services/agent-pack/types.d.ts +118 -0
  202. package/dist/src/services/agent-pack/types.d.ts.map +1 -0
  203. package/dist/src/services/agent-pack/types.js +61 -0
  204. package/dist/src/services/agent-pack/types.js.map +1 -0
  205. package/dist/src/services/agent-tool-profile.d.ts +59 -0
  206. package/dist/src/services/agent-tool-profile.d.ts.map +1 -0
  207. package/dist/src/services/agent-tool-profile.js +76 -0
  208. package/dist/src/services/agent-tool-profile.js.map +1 -0
  209. package/dist/src/services/agent-tool-profile.test.d.ts +2 -0
  210. package/dist/src/services/agent-tool-profile.test.d.ts.map +1 -0
  211. package/dist/src/services/agent-tool-profile.test.js +28 -0
  212. package/dist/src/services/agent-tool-profile.test.js.map +1 -0
  213. package/dist/src/services/bundled-sibling-scan.d.ts +111 -0
  214. package/dist/src/services/bundled-sibling-scan.d.ts.map +1 -0
  215. package/dist/src/services/bundled-sibling-scan.js +170 -0
  216. package/dist/src/services/bundled-sibling-scan.js.map +1 -0
  217. package/dist/src/services/skill-installation.io.d.ts +16 -5
  218. package/dist/src/services/skill-installation.io.d.ts.map +1 -1
  219. package/dist/src/services/skill-installation.io.js +44 -20
  220. package/dist/src/services/skill-installation.io.js.map +1 -1
  221. package/dist/src/services/skill-installation.policy.d.ts +96 -0
  222. package/dist/src/services/skill-installation.policy.d.ts.map +1 -0
  223. package/dist/src/services/skill-installation.policy.js +144 -0
  224. package/dist/src/services/skill-installation.policy.js.map +1 -0
  225. package/dist/src/services/skill-installation.service.d.ts.map +1 -1
  226. package/dist/src/services/skill-installation.service.js +9 -3
  227. package/dist/src/services/skill-installation.service.js.map +1 -1
  228. package/dist/src/sources/index.d.ts +1 -0
  229. package/dist/src/sources/index.d.ts.map +1 -1
  230. package/dist/src/sources/index.js +4 -0
  231. package/dist/src/sources/index.js.map +1 -1
  232. package/dist/src/sync/index.d.ts +1 -1
  233. package/dist/src/sync/index.d.ts.map +1 -1
  234. package/dist/src/sync/index.js +1 -1
  235. package/dist/src/sync/index.js.map +1 -1
  236. package/dist/src/sync/inventory-client.d.ts +16 -0
  237. package/dist/src/sync/inventory-client.d.ts.map +1 -1
  238. package/dist/src/sync/inventory-client.js +54 -0
  239. package/dist/src/sync/inventory-client.js.map +1 -1
  240. package/dist/src/sync/inventory-client.test.js +67 -1
  241. package/dist/src/sync/inventory-client.test.js.map +1 -1
  242. package/dist/src/sync/inventory-collector.d.ts.map +1 -1
  243. package/dist/src/sync/inventory-collector.js +32 -5
  244. package/dist/src/sync/inventory-collector.js.map +1 -1
  245. package/dist/src/sync/inventory-collector.test.js +50 -1
  246. package/dist/src/sync/inventory-collector.test.js.map +1 -1
  247. package/dist/src/sync/inventory-types.d.ts +9 -0
  248. package/dist/src/sync/inventory-types.d.ts.map +1 -1
  249. package/dist/src/sync/inventory-types.js +3 -0
  250. package/dist/src/sync/inventory-types.js.map +1 -1
  251. package/dist/src/telemetry/agent-marker.d.ts +137 -0
  252. package/dist/src/telemetry/agent-marker.d.ts.map +1 -0
  253. package/dist/src/telemetry/agent-marker.js +242 -0
  254. package/dist/src/telemetry/agent-marker.js.map +1 -0
  255. package/dist/src/telemetry/agent-marker.test.d.ts +13 -0
  256. package/dist/src/telemetry/agent-marker.test.d.ts.map +1 -0
  257. package/dist/src/telemetry/agent-marker.test.js +202 -0
  258. package/dist/src/telemetry/agent-marker.test.js.map +1 -0
  259. package/dist/src/telemetry/index.d.ts +2 -1
  260. package/dist/src/telemetry/index.d.ts.map +1 -1
  261. package/dist/src/telemetry/index.js +6 -1
  262. package/dist/src/telemetry/index.js.map +1 -1
  263. package/dist/src/telemetry/posthog.d.ts +10 -0
  264. package/dist/src/telemetry/posthog.d.ts.map +1 -1
  265. package/dist/src/telemetry/posthog.js +5 -1
  266. package/dist/src/telemetry/posthog.js.map +1 -1
  267. package/dist/src/telemetry/wrap.d.ts +28 -7
  268. package/dist/src/telemetry/wrap.d.ts.map +1 -1
  269. package/dist/src/telemetry/wrap.gate.test.d.ts +22 -0
  270. package/dist/src/telemetry/wrap.gate.test.d.ts.map +1 -0
  271. package/dist/src/telemetry/wrap.gate.test.js +197 -0
  272. package/dist/src/telemetry/wrap.gate.test.js.map +1 -0
  273. package/dist/src/telemetry/wrap.js +111 -26
  274. package/dist/src/telemetry/wrap.js.map +1 -1
  275. package/dist/src/telemetry/wrap.marker.test.d.ts +16 -0
  276. package/dist/src/telemetry/wrap.marker.test.d.ts.map +1 -0
  277. package/dist/src/telemetry/wrap.marker.test.js +185 -0
  278. package/dist/src/telemetry/wrap.marker.test.js.map +1 -0
  279. package/dist/src/telemetry/wrap.test.js +4 -0
  280. package/dist/src/telemetry/wrap.test.js.map +1 -1
  281. package/dist/tests/SecurityScanner.exec.test.js +60 -0
  282. package/dist/tests/SecurityScanner.exec.test.js.map +1 -1
  283. package/dist/tests/security/ContinuousSecurity.test.js +10 -4
  284. package/dist/tests/security/ContinuousSecurity.test.js.map +1 -1
  285. package/dist/tests/security/SecurityScanner.chmod-evasion.test.d.ts +2 -0
  286. package/dist/tests/security/SecurityScanner.chmod-evasion.test.d.ts.map +1 -0
  287. package/dist/tests/security/SecurityScanner.chmod-evasion.test.js +126 -0
  288. package/dist/tests/security/SecurityScanner.chmod-evasion.test.js.map +1 -0
  289. package/dist/tests/security/chmod-compound.test.d.ts +2 -0
  290. package/dist/tests/security/chmod-compound.test.d.ts.map +1 -0
  291. package/dist/tests/security/chmod-compound.test.js +188 -0
  292. package/dist/tests/security/chmod-compound.test.js.map +1 -0
  293. package/dist/tests/security/pii-detection.test.js +24 -0
  294. package/dist/tests/security/pii-detection.test.js.map +1 -1
  295. package/dist/tests/security/scanner-regression-guard.test.d.ts +23 -7
  296. package/dist/tests/security/scanner-regression-guard.test.d.ts.map +1 -1
  297. package/dist/tests/security/scanner-regression-guard.test.js +27 -11
  298. package/dist/tests/security/scanner-regression-guard.test.js.map +1 -1
  299. package/dist/tests/security/sensitive-path-fp.test.d.ts +2 -0
  300. package/dist/tests/security/sensitive-path-fp.test.d.ts.map +1 -0
  301. package/dist/tests/security/sensitive-path-fp.test.js +142 -0
  302. package/dist/tests/security/sensitive-path-fp.test.js.map +1 -0
  303. package/dist/tests/services/bundled-sibling-scan.test.d.ts +2 -0
  304. package/dist/tests/services/bundled-sibling-scan.test.d.ts.map +1 -0
  305. package/dist/tests/services/bundled-sibling-scan.test.js +139 -0
  306. package/dist/tests/services/bundled-sibling-scan.test.js.map +1 -0
  307. package/dist/tests/unit/services/skill-installation.io.test.js +166 -0
  308. package/dist/tests/unit/services/skill-installation.io.test.js.map +1 -1
  309. package/dist/tests/unit/services/skill-installation.policy.test.d.ts +8 -0
  310. package/dist/tests/unit/services/skill-installation.policy.test.d.ts.map +1 -0
  311. package/dist/tests/unit/services/skill-installation.policy.test.js +151 -0
  312. package/dist/tests/unit/services/skill-installation.policy.test.js.map +1 -0
  313. package/package.json +23 -3
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Entry-value builders for `sklx agent install` (SMI-5456 Wave 1 Step 5).
3
+ *
4
+ * Pure functions producing the exact MCP-server registration value + the
5
+ * Codex TOML blocks the installer merges in. Separated from the
6
+ * orchestrator so the "what do we install" shape is independently testable
7
+ * from "where do we write it".
8
+ *
9
+ * @module @skillsmith/core/install/agent-pack-installer.entry
10
+ */
11
+ import { AGENT_TOOL_PROFILE_ENV_VAR, AGENT_TOOL_PROFILE_VALUE, } from '../services/agent-tool-profile.js';
12
+ /**
13
+ * The `skillsmith` MCP server registration value for `mcpServers`-convention
14
+ * harnesses (claude-code, cursor, copilot, windsurf; hermes uses the same
15
+ * field names under YAML). OpenCode does NOT use this shape — see
16
+ * {@link buildOpenCodeMcpEntryValue}.
17
+ */
18
+ export function buildAgentMcpEntryValue() {
19
+ return {
20
+ command: 'npx',
21
+ args: ['-y', '@skillsmith/mcp-server'],
22
+ env: {
23
+ [AGENT_TOOL_PROFILE_ENV_VAR]: AGENT_TOOL_PROFILE_VALUE,
24
+ },
25
+ };
26
+ }
27
+ /**
28
+ * OpenCode's `mcp`-key entry value (Step-6 verified against
29
+ * opencode.ai/docs/mcp-servers/): entries are typed `local|remote`,
30
+ * `command` is an ARRAY (command + args combined), and the env-var field is
31
+ * named `environment`, not `env`. Writing the generic mcpServers shape here
32
+ * would produce an entry OpenCode's config schema rejects.
33
+ */
34
+ export function buildOpenCodeMcpEntryValue() {
35
+ return {
36
+ type: 'local',
37
+ command: ['npx', '-y', '@skillsmith/mcp-server'],
38
+ enabled: true,
39
+ environment: {
40
+ [AGENT_TOOL_PROFILE_ENV_VAR]: AGENT_TOOL_PROFILE_VALUE,
41
+ },
42
+ };
43
+ }
44
+ /** Codex `[mcp_servers.skillsmith]` TOML block (text between our markers). */
45
+ export function buildCodexMcpTomlBlock() {
46
+ return [
47
+ '[mcp_servers.skillsmith]',
48
+ 'command = "npx"',
49
+ 'args = ["-y", "@skillsmith/mcp-server"]',
50
+ '',
51
+ '[mcp_servers.skillsmith.env]',
52
+ `${AGENT_TOOL_PROFILE_ENV_VAR} = "${AGENT_TOOL_PROFILE_VALUE}"`,
53
+ ].join('\n');
54
+ }
55
+ /** Regex matching a bare (non-marker-delimited) `[mcp_servers.skillsmith]` table header. */
56
+ export const CODEX_MCP_FOREIGN_HEADER = /^\[mcp_servers\.skillsmith(\.[a-zA-Z0-9_]+)?\]/m;
57
+ /** Regex matching a bare (non-marker-delimited) `[agents.skillsmith-agent]` table header. */
58
+ export const CODEX_AGENTS_FOREIGN_HEADER = /^\[agents\.skillsmith-agent(\.[a-zA-Z0-9_]+)?\]/m;
59
+ /**
60
+ * Codex `[[hooks.SessionStart]]` TOML block (text between our markers) —
61
+ * shape verified by the Step-6 eval worker against
62
+ * developers.openai.com/codex/hooks: inline array-of-tables
63
+ * `[[hooks.SessionStart]]` with a nested `[[hooks.SessionStart.hooks]]`
64
+ * array carrying `{type, command, timeout, statusMessage}`. Only `type` +
65
+ * `command` are emitted (timeout/statusMessage stay at Codex defaults).
66
+ * `JSON.stringify` produces a valid TOML basic string for the absolute
67
+ * script path — same quoting convention as `renderCodexToml` (shims.ts).
68
+ */
69
+ export function buildCodexSessionStartHookBlock(sessionStartScriptPath) {
70
+ return [
71
+ '[[hooks.SessionStart]]',
72
+ '',
73
+ '[[hooks.SessionStart.hooks]]',
74
+ 'type = "command"',
75
+ `command = ${JSON.stringify(sessionStartScriptPath)}`,
76
+ ].join('\n');
77
+ }
78
+ /**
79
+ * Regex matching a SINGLE-bracket `[hooks.SessionStart]` table header — a
80
+ * user config that defined `hooks.SessionStart` as a plain TABLE. Appending
81
+ * our `[[hooks.SessionStart]]` array-of-tables entry to such a file would
82
+ * produce INVALID TOML (a key cannot be both a table and an array of
83
+ * tables), so that is the genuine-conflict case. A foreign DOUBLE-bracket
84
+ * `[[hooks.SessionStart]]` (the user's own hook) is deliberately NOT
85
+ * matched: TOML permits re-opening an array of tables anywhere in the
86
+ * document, so appending our own `[[hooks.SessionStart]]` entry alongside a
87
+ * user's is valid and non-destructive — both hooks run.
88
+ */
89
+ export const CODEX_HOOKS_TABLE_CONFLICT_HEADER = /^\[hooks\.SessionStart\]/m;
90
+ //# sourceMappingURL=agent-pack-installer.entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-pack-installer.entry.js","sourceRoot":"","sources":["../../../src/install/agent-pack-installer.entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,mCAAmC,CAAA;AAE1C;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO;QACL,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,CAAC,IAAI,EAAE,wBAAwB,CAAC;QACtC,GAAG,EAAE;YACH,CAAC,0BAA0B,CAAC,EAAE,wBAAwB;SACvD;KACF,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO;QACL,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,wBAAwB,CAAC;QAChD,OAAO,EAAE,IAAI;QACb,WAAW,EAAE;YACX,CAAC,0BAA0B,CAAC,EAAE,wBAAwB;SACvD;KACF,CAAA;AACH,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,sBAAsB;IACpC,OAAO;QACL,0BAA0B;QAC1B,iBAAiB;QACjB,yCAAyC;QACzC,EAAE;QACF,8BAA8B;QAC9B,GAAG,0BAA0B,OAAO,wBAAwB,GAAG;KAChE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC;AAED,4FAA4F;AAC5F,MAAM,CAAC,MAAM,wBAAwB,GAAG,iDAAiD,CAAA;AAEzF,6FAA6F;AAC7F,MAAM,CAAC,MAAM,2BAA2B,GAAG,kDAAkD,CAAA;AAE7F;;;;;;;;;GASG;AACH,MAAM,UAAU,+BAA+B,CAAC,sBAA8B;IAC5E,OAAO;QACL,wBAAwB;QACxB,EAAE;QACF,8BAA8B;QAC9B,kBAAkB;QAClB,aAAa,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC,EAAE;KACtD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,2BAA2B,CAAA"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Filesystem primitives shared by `installAgentPack` (SMI-5456 Wave 1 Step 5).
3
+ *
4
+ * `writeOwnedArtifactFile` is the idempotency backbone for the P-5
5
+ * "double-install produces identical filesystem state, no duplicate
6
+ * backups" test: byte-identical content at an already-correct path is a
7
+ * true no-op (no write, no backup, no manifest churn beyond re-recording the
8
+ * same entry).
9
+ *
10
+ * @module @skillsmith/core/install/agent-pack-installer.fs-helpers
11
+ */
12
+ export interface WriteOwnedFileOptions {
13
+ path: string;
14
+ content: string;
15
+ executable: boolean;
16
+ backupDir: string;
17
+ }
18
+ export interface WriteOwnedFileResult {
19
+ /** True when a write actually happened (content or executable-bit changed, or the file was new). */
20
+ changed: boolean;
21
+ /** Backup of PRE-EXISTING different content, or null (nothing existed, or content already matched). */
22
+ backupPath: string | null;
23
+ }
24
+ /**
25
+ * Write a file the installer fully owns by path convention (SKILL.md copies,
26
+ * shim files, hook scripts). Idempotent: re-writing identical content with
27
+ * the correct executable bit is a no-op. A pre-existing file with DIFFERENT
28
+ * content is backed up before being overwritten (defensive — these paths are
29
+ * namespaced (`skillsmith-agent`) so a genuine foreign collision is unlikely,
30
+ * but never silently destroying user data is the house floor).
31
+ */
32
+ export declare function writeOwnedArtifactFile(opts: WriteOwnedFileOptions): WriteOwnedFileResult;
33
+ //# sourceMappingURL=agent-pack-installer.fs-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-pack-installer.fs-helpers.d.ts","sourceRoot":"","sources":["../../../src/install/agent-pack-installer.fs-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,OAAO,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC,oGAAoG;IACpG,OAAO,EAAE,OAAO,CAAA;IAChB,uGAAuG;IACvG,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1B;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,qBAAqB,GAAG,oBAAoB,CAoBxF"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Filesystem primitives shared by `installAgentPack` (SMI-5456 Wave 1 Step 5).
3
+ *
4
+ * `writeOwnedArtifactFile` is the idempotency backbone for the P-5
5
+ * "double-install produces identical filesystem state, no duplicate
6
+ * backups" test: byte-identical content at an already-correct path is a
7
+ * true no-op (no write, no backup, no manifest churn beyond re-recording the
8
+ * same entry).
9
+ *
10
+ * @module @skillsmith/core/install/agent-pack-installer.fs-helpers
11
+ */
12
+ import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
13
+ import { dirname, join } from 'node:path';
14
+ /**
15
+ * Write a file the installer fully owns by path convention (SKILL.md copies,
16
+ * shim files, hook scripts). Idempotent: re-writing identical content with
17
+ * the correct executable bit is a no-op. A pre-existing file with DIFFERENT
18
+ * content is backed up before being overwritten (defensive — these paths are
19
+ * namespaced (`skillsmith-agent`) so a genuine foreign collision is unlikely,
20
+ * but never silently destroying user data is the house floor).
21
+ */
22
+ export function writeOwnedArtifactFile(opts) {
23
+ const { path, content, executable, backupDir } = opts;
24
+ if (existsSync(path)) {
25
+ const existing = readFileSync(path, 'utf-8');
26
+ const currentlyExecutable = isExecutable(path);
27
+ if (existing === content && currentlyExecutable === executable) {
28
+ return { changed: false, backupPath: null };
29
+ }
30
+ const backupPath = writeBackup(path, backupDir);
31
+ mkdirSync(dirname(path), { recursive: true });
32
+ writeFileSync(path, content, 'utf-8');
33
+ if (executable)
34
+ chmodSync(path, 0o755);
35
+ return { changed: true, backupPath };
36
+ }
37
+ mkdirSync(dirname(path), { recursive: true });
38
+ writeFileSync(path, content, 'utf-8');
39
+ if (executable)
40
+ chmodSync(path, 0o755);
41
+ return { changed: true, backupPath: null };
42
+ }
43
+ function isExecutable(path) {
44
+ try {
45
+ return (statSync(path).mode & 0o111) !== 0;
46
+ }
47
+ catch {
48
+ return false;
49
+ }
50
+ }
51
+ function writeBackup(sourcePath, backupDir) {
52
+ mkdirSync(backupDir, { recursive: true, mode: 0o700 });
53
+ const stamp = new Date().toISOString().replace(/[:.]/g, '-');
54
+ const baseName = sourcePath.split('/').pop() ?? 'file';
55
+ const backupPath = join(backupDir, `${stamp}-${baseName}.bak`);
56
+ writeFileSync(backupPath, readFileSync(sourcePath, 'utf-8'), { mode: 0o600 });
57
+ return backupPath;
58
+ }
59
+ //# sourceMappingURL=agent-pack-installer.fs-helpers.js.map
@@ -0,0 +1 @@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,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IACrC,IAAI,UAAU;QAAE,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACtC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAA;AAC5C,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,UAAkB,EAAE,SAAiB;IACxD,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IACtD,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IAC5D,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,MAAM,CAAA;IACtD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,EAAE,GAAG,KAAK,IAAI,QAAQ,MAAM,CAAC,CAAA;IAC9D,aAAa,CAAC,UAAU,EAAE,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IAC7E,OAAO,UAAU,CAAA;AACnB,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Per-harness install step for `installAgentPack` (SMI-5456 Wave 1 Step 5).
3
+ *
4
+ * One function per concern (shim, hooks, MCP registration) so the
5
+ * orchestrator (`agent-pack-installer.ts`) stays a readable top-level loop.
6
+ * Every function is additive to `entries`/`report` in place — the caller
7
+ * owns aggregation and the manifest save.
8
+ *
9
+ * @module @skillsmith/core/install/agent-pack-installer.harness
10
+ */
11
+ import type { AgentPackArtifact, HarnessId } from '../services/agent-pack/index.js';
12
+ import { type McpHarnessId } from './agent-harness-targets.js';
13
+ import type { AgentManifestEntry } from './agent-manifest.js';
14
+ import type { HarnessInstallReport } from './agent-pack-installer.types.js';
15
+ export interface HarnessInstallCtx {
16
+ homeDir: string | undefined;
17
+ force: boolean;
18
+ backupDir: string;
19
+ entries: AgentManifestEntry[];
20
+ /**
21
+ * Config-file paths already backed up during THIS install run. Shared
22
+ * across every merge call so a harness whose hooks + MCP registration
23
+ * share one file (claude-code: `settings.json`; codex: `config.toml`)
24
+ * only backs it up once, capturing genuine pre-install state rather than
25
+ * repeatedly "backing up" content this same run already wrote.
26
+ */
27
+ backedUpPaths: Set<string>;
28
+ }
29
+ /** Write the named-agent shim for `harness` when a target exists (claude-code/copilot/opencode). */
30
+ export declare function installShim(harness: HarnessId, artifact: AgentPackArtifact | undefined, ctx: HarnessInstallCtx, report: HarnessInstallReport): void;
31
+ /** Install + wire SessionStart/SessionEnd hook scripts for claude-code/cursor (JSON hook config). */
32
+ export declare function installJsonHooks(harness: 'claude-code' | 'cursor', startArtifact: AgentPackArtifact | undefined, endArtifact: AgentPackArtifact | undefined, ctx: HarnessInstallCtx, report: HarnessInstallReport): void;
33
+ /**
34
+ * Install hook scripts for Codex (+x) and wire the SessionStart hook into
35
+ * `~/.codex/config.toml` as a marker-delimited `[[hooks.SessionStart]]`
36
+ * array-of-tables block (shape Step-6-verified against
37
+ * developers.openai.com/codex/hooks).
38
+ *
39
+ * SessionStart ONLY — deliberate, do not "complete" this:
40
+ * - Codex has NO SessionEnd event. There is nothing to wire the
41
+ * session-end.sh cleanup script to.
42
+ * - Codex's Stop event fires PER-TURN, not per-session. Wiring the marker
43
+ * cleanup there would delete the agent-mediation marker file after the
44
+ * FIRST turn, silently unmarking every subsequent tool call in the same
45
+ * session and corrupting the mediation-share metric the whole Wave-1
46
+ * bet is measured by.
47
+ * - Cleanup therefore rides the server's 12h marker TTL
48
+ * (`telemetry/agent-marker.ts` `AGENT_MARKER_TTL_MS`) — the same
49
+ * crash-backstop path every harness already relies on.
50
+ *
51
+ * session-end.sh is still installed (inert on Codex — nothing invokes it):
52
+ * it keeps the on-disk script tree identical across hook-capable harnesses
53
+ * and stays manifest-tracked, so uninstall removes it like any other owned
54
+ * file. Zero uninstall complication.
55
+ */
56
+ export declare function installCodexHooks(startArtifact: AgentPackArtifact | undefined, endArtifact: AgentPackArtifact | undefined, ctx: HarnessInstallCtx, report: HarnessInstallReport): void;
57
+ /**
58
+ * Codex's named-agent "shim" is a `[agents.skillsmith-agent]` TOML entry
59
+ * merged into the same `~/.codex/config.toml` as its MCP registration —
60
+ * the artifact's content (`shims/codex/agents.toml`, rendered by the
61
+ * locked `renderCodexToml`) is already the exact block text to install.
62
+ */
63
+ export declare function installCodexAgentsShim(artifact: AgentPackArtifact | undefined, ctx: HarnessInstallCtx, report: HarnessInstallReport): void;
64
+ /** Merge the `skillsmith` MCP server registration for any of the 7 MCP-capable harnesses. */
65
+ export declare function installMcpConfig(harness: McpHarnessId, ctx: HarnessInstallCtx, report: HarnessInstallReport): void;
66
+ //# sourceMappingURL=agent-pack-installer.harness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-pack-installer.harness.d.ts","sourceRoot":"","sources":["../../../src/install/agent-pack-installer.harness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAA;AACnF,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAA;AAgBnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAqB3E,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,KAAK,EAAE,OAAO,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,kBAAkB,EAAE,CAAA;IAC7B;;;;;;OAMG;IACH,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAC3B;AAED,oGAAoG;AACpG,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,iBAAiB,GAAG,SAAS,EACvC,GAAG,EAAE,iBAAiB,EACtB,MAAM,EAAE,oBAAoB,GAC3B,IAAI,CAoBN;AAED,qGAAqG;AACrG,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,aAAa,GAAG,QAAQ,EACjC,aAAa,EAAE,iBAAiB,GAAG,SAAS,EAC5C,WAAW,EAAE,iBAAiB,GAAG,SAAS,EAC1C,GAAG,EAAE,iBAAiB,EACtB,MAAM,EAAE,oBAAoB,GAC3B,IAAI,CAgEN;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,iBAAiB,GAAG,SAAS,EAC5C,WAAW,EAAE,iBAAiB,GAAG,SAAS,EAC1C,GAAG,EAAE,iBAAiB,EACtB,MAAM,EAAE,oBAAoB,GAC3B,IAAI,CAmEN;AAgBD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,iBAAiB,GAAG,SAAS,EACvC,GAAG,EAAE,iBAAiB,EACtB,MAAM,EAAE,oBAAoB,GAC3B,IAAI,CA+BN;AAED,6FAA6F;AAC7F,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,EACrB,GAAG,EAAE,iBAAiB,EACtB,MAAM,EAAE,oBAAoB,GAC3B,IAAI,CAwDN"}
@@ -0,0 +1,310 @@
1
+ /**
2
+ * Per-harness install step for `installAgentPack` (SMI-5456 Wave 1 Step 5).
3
+ *
4
+ * One function per concern (shim, hooks, MCP registration) so the
5
+ * orchestrator (`agent-pack-installer.ts`) stays a readable top-level loop.
6
+ * Every function is additive to `entries`/`report` in place — the caller
7
+ * owns aggregation and the manifest save.
8
+ *
9
+ * @module @skillsmith/core/install/agent-pack-installer.harness
10
+ */
11
+ import { join } from 'node:path';
12
+ import { AGENT_HOOK_TARGETS, AGENT_MCP_TARGETS, AGENT_SHIM_TARGETS, } from './agent-harness-targets.js';
13
+ import { mergeJsonMcpEntry } from './agent-config-merge.json.js';
14
+ import { mergeYamlMcpEntry } from './agent-config-merge.yaml.js';
15
+ import { mergeTomlBlock } from './agent-config-merge.toml-block.js';
16
+ import { mergeJsonArrayEntry } from './agent-config-merge.json-array.js';
17
+ import { CODEX_AGENTS_FOREIGN_HEADER, CODEX_HOOKS_TABLE_CONFLICT_HEADER, CODEX_MCP_FOREIGN_HEADER, buildAgentMcpEntryValue, buildCodexMcpTomlBlock, buildCodexSessionStartHookBlock, buildOpenCodeMcpEntryValue, } from './agent-pack-installer.entry.js';
18
+ import { relocateUnderHome } from './agent-home-relocate.js';
19
+ import { writeOwnedArtifactFile } from './agent-pack-installer.fs-helpers.js';
20
+ /**
21
+ * A merge "succeeded" (our content is present in the file, whether this
22
+ * call wrote it or it already matched) whenever status is 'created',
23
+ * 'updated', OR 'unchanged'. Manifest entries must be pushed for ALL THREE —
24
+ * not just 'created'/'updated' — because the manifest is rebuilt fresh every
25
+ * `installAgentPack` run (`entries: []` at the top of the function): an
26
+ * 'unchanged' result on a re-install is not a no-op from the manifest's
27
+ * perspective, it is "this path is still part of what's installed." Gating
28
+ * the push on 'created'/'updated' only would silently drop that path from
29
+ * the manifest the moment a re-install found it already correct — the
30
+ * P-5 double-install-idempotency test caught this losing 3 of 12 entries.
31
+ * Only 'conflict' (we deliberately left a foreign entry untouched — nothing
32
+ * of ours is there) and 'error' (the write failed) are excluded.
33
+ */
34
+ function mergeSucceeded(status) {
35
+ return status === 'created' || status === 'updated' || status === 'unchanged';
36
+ }
37
+ /** Write the named-agent shim for `harness` when a target exists (claude-code/copilot/opencode). */
38
+ export function installShim(harness, artifact, ctx, report) {
39
+ const target = AGENT_SHIM_TARGETS[harness];
40
+ if (!target || !artifact)
41
+ return;
42
+ const path = relocateUnderHome(target.path, ctx.homeDir);
43
+ const result = writeOwnedArtifactFile({
44
+ path,
45
+ content: artifact.content,
46
+ executable: false,
47
+ backupDir: ctx.backupDir,
48
+ });
49
+ report.shimWritten = true;
50
+ ctx.entries.push({
51
+ path,
52
+ kind: 'shim',
53
+ harness,
54
+ backupPath: result.backupPath,
55
+ executable: false,
56
+ });
57
+ if (result.backupPath)
58
+ report.notes.push(`shim: pre-existing content backed up to ${result.backupPath}`);
59
+ }
60
+ /** Install + wire SessionStart/SessionEnd hook scripts for claude-code/cursor (JSON hook config). */
61
+ export function installJsonHooks(harness, startArtifact, endArtifact, ctx, report) {
62
+ const target = AGENT_HOOK_TARGETS[harness];
63
+ if (!target || !startArtifact || !endArtifact)
64
+ return;
65
+ const scriptDir = relocateUnderHome(target.scriptDir, ctx.homeDir);
66
+ const startPath = join(scriptDir, 'session-start.sh');
67
+ const endPath = join(scriptDir, 'session-end.sh');
68
+ const startResult = writeOwnedArtifactFile({
69
+ path: startPath,
70
+ content: startArtifact.content,
71
+ executable: true,
72
+ backupDir: ctx.backupDir,
73
+ });
74
+ const endResult = writeOwnedArtifactFile({
75
+ path: endPath,
76
+ content: endArtifact.content,
77
+ executable: true,
78
+ backupDir: ctx.backupDir,
79
+ });
80
+ ctx.entries.push({
81
+ path: startPath,
82
+ kind: 'hook-script',
83
+ harness,
84
+ backupPath: startResult.backupPath,
85
+ executable: true,
86
+ }, {
87
+ path: endPath,
88
+ kind: 'hook-script',
89
+ harness,
90
+ backupPath: endResult.backupPath,
91
+ executable: true,
92
+ });
93
+ report.hooksInstalled = true;
94
+ const configPath = relocateUnderHome(target.configPath, ctx.homeDir);
95
+ const startWire = mergeJsonArrayEntry({
96
+ path: configPath,
97
+ keyPath: target.sessionStartKeyPath,
98
+ entry: hookMatcherEntry(startPath),
99
+ isOurEntry: (item) => hookEntryCommand(item) === startPath,
100
+ backupDir: ctx.backupDir,
101
+ alreadyBackedUpPaths: ctx.backedUpPaths,
102
+ });
103
+ const endWire = mergeJsonArrayEntry({
104
+ path: configPath,
105
+ keyPath: target.sessionEndKeyPath,
106
+ entry: hookMatcherEntry(endPath),
107
+ isOurEntry: (item) => hookEntryCommand(item) === endPath,
108
+ backupDir: ctx.backupDir,
109
+ alreadyBackedUpPaths: ctx.backedUpPaths,
110
+ });
111
+ report.hookConfig.push(startWire, endWire);
112
+ if (mergeSucceeded(startWire.status) || mergeSucceeded(endWire.status)) {
113
+ ctx.entries.push({
114
+ path: configPath,
115
+ kind: 'hook-config',
116
+ harness,
117
+ backupPath: startWire.backupPath ?? endWire.backupPath,
118
+ executable: false,
119
+ });
120
+ }
121
+ }
122
+ /**
123
+ * Install hook scripts for Codex (+x) and wire the SessionStart hook into
124
+ * `~/.codex/config.toml` as a marker-delimited `[[hooks.SessionStart]]`
125
+ * array-of-tables block (shape Step-6-verified against
126
+ * developers.openai.com/codex/hooks).
127
+ *
128
+ * SessionStart ONLY — deliberate, do not "complete" this:
129
+ * - Codex has NO SessionEnd event. There is nothing to wire the
130
+ * session-end.sh cleanup script to.
131
+ * - Codex's Stop event fires PER-TURN, not per-session. Wiring the marker
132
+ * cleanup there would delete the agent-mediation marker file after the
133
+ * FIRST turn, silently unmarking every subsequent tool call in the same
134
+ * session and corrupting the mediation-share metric the whole Wave-1
135
+ * bet is measured by.
136
+ * - Cleanup therefore rides the server's 12h marker TTL
137
+ * (`telemetry/agent-marker.ts` `AGENT_MARKER_TTL_MS`) — the same
138
+ * crash-backstop path every harness already relies on.
139
+ *
140
+ * session-end.sh is still installed (inert on Codex — nothing invokes it):
141
+ * it keeps the on-disk script tree identical across hook-capable harnesses
142
+ * and stays manifest-tracked, so uninstall removes it like any other owned
143
+ * file. Zero uninstall complication.
144
+ */
145
+ export function installCodexHooks(startArtifact, endArtifact, ctx, report) {
146
+ const target = AGENT_HOOK_TARGETS.codex;
147
+ if (!target || !startArtifact || !endArtifact)
148
+ return;
149
+ const scriptDir = relocateUnderHome(target.scriptDir, ctx.homeDir);
150
+ const startPath = join(scriptDir, 'session-start.sh');
151
+ const endPath = join(scriptDir, 'session-end.sh');
152
+ const startResult = writeOwnedArtifactFile({
153
+ path: startPath,
154
+ content: startArtifact.content,
155
+ executable: true,
156
+ backupDir: ctx.backupDir,
157
+ });
158
+ const endResult = writeOwnedArtifactFile({
159
+ path: endPath,
160
+ content: endArtifact.content,
161
+ executable: true,
162
+ backupDir: ctx.backupDir,
163
+ });
164
+ ctx.entries.push({
165
+ path: startPath,
166
+ kind: 'hook-script',
167
+ harness: 'codex',
168
+ backupPath: startResult.backupPath,
169
+ executable: true,
170
+ }, {
171
+ path: endPath,
172
+ kind: 'hook-script',
173
+ harness: 'codex',
174
+ backupPath: endResult.backupPath,
175
+ executable: true,
176
+ });
177
+ report.hooksInstalled = true;
178
+ const configPath = relocateUnderHome(target.configPath, ctx.homeDir);
179
+ const wire = mergeTomlBlock({
180
+ path: configPath,
181
+ markerId: 'hooks.SessionStart',
182
+ blockContent: buildCodexSessionStartHookBlock(startPath),
183
+ foreignHeaderPattern: CODEX_HOOKS_TABLE_CONFLICT_HEADER,
184
+ backupDir: ctx.backupDir,
185
+ force: ctx.force,
186
+ alreadyBackedUpPaths: ctx.backedUpPaths,
187
+ });
188
+ report.hookConfig.push(wire);
189
+ if (mergeSucceeded(wire.status)) {
190
+ ctx.entries.push({
191
+ path: configPath,
192
+ kind: 'hook-config',
193
+ harness: 'codex',
194
+ backupPath: wire.backupPath,
195
+ executable: false,
196
+ });
197
+ }
198
+ if (wire.status === 'conflict') {
199
+ report.notes.push(`Codex hook wiring skipped: ${configPath} defines [hooks.SessionStart] as a plain TOML table — appending our [[hooks.SessionStart]] array entry would make the file invalid TOML. Wire ${startPath} manually.`);
200
+ }
201
+ if (wire.status === 'error') {
202
+ report.notes.push(`Codex hook wiring failed at ${configPath}: ${wire.errorMessage}`);
203
+ }
204
+ report.notes.push('Codex: session-end.sh installed but not wired — Codex has no SessionEnd event and its Stop event fires per-turn (wiring cleanup there would break session-scoped mediation marking); marker cleanup rides the server-side 12h TTL.');
205
+ }
206
+ function hookMatcherEntry(scriptPath) {
207
+ return { matcher: '', hooks: [{ type: 'command', command: scriptPath }] };
208
+ }
209
+ function hookEntryCommand(item) {
210
+ if (!item || typeof item !== 'object')
211
+ return undefined;
212
+ const hooks = item.hooks;
213
+ if (!Array.isArray(hooks) || hooks.length === 0)
214
+ return undefined;
215
+ const first = hooks[0];
216
+ if (!first || typeof first !== 'object')
217
+ return undefined;
218
+ const command = first.command;
219
+ return typeof command === 'string' ? command : undefined;
220
+ }
221
+ /**
222
+ * Codex's named-agent "shim" is a `[agents.skillsmith-agent]` TOML entry
223
+ * merged into the same `~/.codex/config.toml` as its MCP registration —
224
+ * the artifact's content (`shims/codex/agents.toml`, rendered by the
225
+ * locked `renderCodexToml`) is already the exact block text to install.
226
+ */
227
+ export function installCodexAgentsShim(artifact, ctx, report) {
228
+ const target = AGENT_MCP_TARGETS.codex;
229
+ if (!artifact)
230
+ return;
231
+ const path = relocateUnderHome(target.path, ctx.homeDir);
232
+ const result = mergeTomlBlock({
233
+ path,
234
+ markerId: 'agents.skillsmith-agent',
235
+ blockContent: artifact.content,
236
+ foreignHeaderPattern: CODEX_AGENTS_FOREIGN_HEADER,
237
+ backupDir: ctx.backupDir,
238
+ force: ctx.force,
239
+ alreadyBackedUpPaths: ctx.backedUpPaths,
240
+ });
241
+ if (mergeSucceeded(result.status)) {
242
+ report.shimWritten = true;
243
+ ctx.entries.push({
244
+ path,
245
+ kind: 'shim',
246
+ harness: 'codex',
247
+ backupPath: result.backupPath,
248
+ executable: false,
249
+ });
250
+ }
251
+ if (result.status === 'conflict') {
252
+ report.notes.push(`Codex agent entry at ${path} already has a hand-written [agents.skillsmith-agent] table — left untouched.`);
253
+ }
254
+ if (result.status === 'error') {
255
+ report.notes.push(`Codex agent entry merge failed at ${path}: ${result.errorMessage}`);
256
+ }
257
+ }
258
+ /** Merge the `skillsmith` MCP server registration for any of the 7 MCP-capable harnesses. */
259
+ export function installMcpConfig(harness, ctx, report) {
260
+ const target = AGENT_MCP_TARGETS[harness];
261
+ const path = relocateUnderHome(target.path, ctx.homeDir);
262
+ // OpenCode's entry schema is structurally different from the mcpServers
263
+ // convention (typed local|remote, command-array, `environment`) — see
264
+ // buildOpenCodeMcpEntryValue.
265
+ const entryValue = harness === 'opencode' ? buildOpenCodeMcpEntryValue() : buildAgentMcpEntryValue();
266
+ const result = target.format === 'json'
267
+ ? mergeJsonMcpEntry({
268
+ path,
269
+ keyPath: target.keyPath,
270
+ entryValue,
271
+ backupDir: ctx.backupDir,
272
+ force: ctx.force,
273
+ alreadyBackedUpPaths: ctx.backedUpPaths,
274
+ })
275
+ : target.format === 'yaml'
276
+ ? mergeYamlMcpEntry({
277
+ path,
278
+ mcpServersKey: target.keyPath[0] ?? 'mcp_servers',
279
+ entryValue,
280
+ backupDir: ctx.backupDir,
281
+ force: ctx.force,
282
+ alreadyBackedUpPaths: ctx.backedUpPaths,
283
+ })
284
+ : mergeTomlBlock({
285
+ path,
286
+ markerId: 'mcp_servers.skillsmith',
287
+ blockContent: buildCodexMcpTomlBlock(),
288
+ foreignHeaderPattern: CODEX_MCP_FOREIGN_HEADER,
289
+ backupDir: ctx.backupDir,
290
+ force: ctx.force,
291
+ alreadyBackedUpPaths: ctx.backedUpPaths,
292
+ });
293
+ report.mcpConfig = result;
294
+ if (mergeSucceeded(result.status)) {
295
+ ctx.entries.push({
296
+ path,
297
+ kind: 'mcp-config',
298
+ harness,
299
+ backupPath: result.backupPath,
300
+ executable: false,
301
+ });
302
+ }
303
+ if (result.status === 'conflict') {
304
+ report.notes.push(`MCP config at ${path} already has a 'skillsmith' entry that doesn't look like ours — left untouched. Re-run with --force to overwrite, or edit ${path} manually.`);
305
+ }
306
+ if (result.status === 'error') {
307
+ report.notes.push(`MCP config merge failed at ${path}: ${result.errorMessage}`);
308
+ }
309
+ }
310
+ //# sourceMappingURL=agent-pack-installer.harness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-pack-installer.harness.js","sourceRoot":"","sources":["../../../src/install/agent-pack-installer.harness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,GAEnB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EACL,2BAA2B,EAC3B,iCAAiC,EACjC,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,EACtB,+BAA+B,EAC/B,0BAA0B,GAC3B,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAA;AAK7E;;;;;;;;;;;;;GAaG;AACH,SAAS,cAAc,CAAC,MAA6B;IACnD,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,WAAW,CAAA;AAC/E,CAAC;AAiBD,oGAAoG;AACpG,MAAM,UAAU,WAAW,CACzB,OAAkB,EAClB,QAAuC,EACvC,GAAsB,EACtB,MAA4B;IAE5B,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAA;IAC1C,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ;QAAE,OAAM;IAChC,MAAM,IAAI,GAAG,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACxD,MAAM,MAAM,GAAG,sBAAsB,CAA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