harnesstap 1.3.2 → 1.6.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 (245) hide show
  1. package/README.md +4 -0
  2. package/dist/apply-FTAIL3X3.js +50 -0
  3. package/dist/{approve-L7IFSYBO.js → approve-R6AWQB3I.js} +12 -16
  4. package/dist/{approve-L7IFSYBO.js.map → approve-R6AWQB3I.js.map} +1 -1
  5. package/dist/{audit-PBJDK7A4.js → audit-2HNKFPSU.js} +26 -39
  6. package/dist/{audit-PBJDK7A4.js.map → audit-2HNKFPSU.js.map} +1 -1
  7. package/dist/{auth-OM73RLNS.js → auth-C54KRLNF.js} +17 -21
  8. package/dist/{auth-OM73RLNS.js.map → auth-C54KRLNF.js.map} +1 -1
  9. package/dist/bin.js +13 -34
  10. package/dist/bin.js.map +1 -1
  11. package/dist/{chunk-R4PTE774.js → chunk-2XDYQXP2.js} +34 -41
  12. package/dist/chunk-2XDYQXP2.js.map +1 -0
  13. package/dist/{chunk-G5RWVZZ7.js → chunk-3277RVZT.js} +5 -7
  14. package/dist/{chunk-G5RWVZZ7.js.map → chunk-3277RVZT.js.map} +1 -1
  15. package/dist/{chunk-6JMVGKMD.js → chunk-3Q72LZPJ.js} +936 -528
  16. package/dist/chunk-3Q72LZPJ.js.map +1 -0
  17. package/dist/{chunk-U472S6IB.js → chunk-42E2MPES.js} +19 -27
  18. package/dist/chunk-42E2MPES.js.map +1 -0
  19. package/dist/{chunk-CZ4T75PP.js → chunk-5HACBPK2.js} +622 -252
  20. package/dist/chunk-5HACBPK2.js.map +1 -0
  21. package/dist/{chunk-IHW4PCDT.js → chunk-6FXJIKEG.js} +6 -6
  22. package/dist/{chunk-OPVIX7E4.js → chunk-A3TZT4WT.js} +6 -2
  23. package/dist/chunk-A3TZT4WT.js.map +1 -0
  24. package/dist/chunk-BUA7WFI4.js +39327 -0
  25. package/dist/chunk-BUA7WFI4.js.map +1 -0
  26. package/dist/{chunk-IAZNF35S.js → chunk-CBSDMRMY.js} +2 -2
  27. package/dist/{chunk-YVJQ2QDG.js → chunk-CR2TYMKC.js} +65 -55
  28. package/dist/chunk-CR2TYMKC.js.map +1 -0
  29. package/dist/{chunk-VQVUJYYY.js → chunk-CWXCZBJR.js} +76 -6
  30. package/dist/chunk-CWXCZBJR.js.map +1 -0
  31. package/dist/{chunk-AVZOFMJX.js → chunk-D7R577XZ.js} +381 -138
  32. package/dist/chunk-D7R577XZ.js.map +1 -0
  33. package/dist/{chunk-3EGM4IUI.js → chunk-EPXAOEBB.js} +6 -6
  34. package/dist/{chunk-64R32MG2.js → chunk-GZU4LVFF.js} +179 -26
  35. package/dist/chunk-GZU4LVFF.js.map +1 -0
  36. package/dist/chunk-HV3ENT2F.js +61 -0
  37. package/dist/chunk-HV3ENT2F.js.map +1 -0
  38. package/dist/{chunk-XCPWLGPB.js → chunk-K4UDZUJ2.js} +2 -2
  39. package/dist/{chunk-OQ4KBUN2.js → chunk-L6BJCRBU.js} +13 -16
  40. package/dist/chunk-L6BJCRBU.js.map +1 -0
  41. package/dist/{chunk-AFKCNFPP.js → chunk-M6FEDSHY.js} +16 -15
  42. package/dist/chunk-M6FEDSHY.js.map +1 -0
  43. package/dist/chunk-M7PHQ3UC.js +31491 -0
  44. package/dist/chunk-M7PHQ3UC.js.map +1 -0
  45. package/dist/{chunk-FBYAIBHP.js → chunk-MHLAIGIM.js} +2 -2
  46. package/dist/{chunk-ENHDEB7Z.js → chunk-MHMFF6A5.js} +5 -7
  47. package/dist/{chunk-ENHDEB7Z.js.map → chunk-MHMFF6A5.js.map} +1 -1
  48. package/dist/chunk-MKLJBW5N.js +14 -0
  49. package/dist/{chunk-XRXFJTAT.js → chunk-MQCAPCAF.js} +17 -26
  50. package/dist/chunk-MQCAPCAF.js.map +1 -0
  51. package/dist/{chunk-UEHDEADL.js → chunk-MQCH3YZ5.js} +15 -13
  52. package/dist/chunk-MQCH3YZ5.js.map +1 -0
  53. package/dist/chunk-OHZNDV4A.js +1707 -0
  54. package/dist/chunk-OHZNDV4A.js.map +1 -0
  55. package/dist/{chunk-LGWUTV5Q.js → chunk-OWE3OSX6.js} +11 -13
  56. package/dist/{chunk-LGWUTV5Q.js.map → chunk-OWE3OSX6.js.map} +1 -1
  57. package/dist/{chunk-EY4ES5MG.js → chunk-PCNHBMBU.js} +3 -5
  58. package/dist/{chunk-EY4ES5MG.js.map → chunk-PCNHBMBU.js.map} +1 -1
  59. package/dist/{chunk-YRGM7RAD.js → chunk-QGTDQNVV.js} +7 -11
  60. package/dist/{chunk-YRGM7RAD.js.map → chunk-QGTDQNVV.js.map} +1 -1
  61. package/dist/{chunk-BXSS2S4W.js → chunk-R27VZIF6.js} +2 -2
  62. package/dist/{chunk-TQ2NA4Z4.js → chunk-R4NV3Q7G.js} +8 -2
  63. package/dist/chunk-R4NV3Q7G.js.map +1 -0
  64. package/dist/{chunk-FUV7QYBS.js → chunk-R6VFJKZB.js} +86 -319
  65. package/dist/chunk-R6VFJKZB.js.map +1 -0
  66. package/dist/{chunk-QNAIDM6W.js → chunk-RQLVXJH2.js} +132 -4
  67. package/dist/chunk-RQLVXJH2.js.map +1 -0
  68. package/dist/{chunk-JQOKQKQT.js → chunk-S2D5PWAO.js} +2 -2
  69. package/dist/{chunk-JJJJ2RAD.js → chunk-T4EKNX2Q.js} +71 -11
  70. package/dist/chunk-T4EKNX2Q.js.map +1 -0
  71. package/dist/{chunk-GWQVYGRD.js → chunk-TERYL7JH.js} +118 -78
  72. package/dist/chunk-TERYL7JH.js.map +1 -0
  73. package/dist/chunk-UC27MQ3T.js +1920 -0
  74. package/dist/chunk-UC27MQ3T.js.map +1 -0
  75. package/dist/chunk-UEA4NCY2.js +106 -0
  76. package/dist/chunk-UEA4NCY2.js.map +1 -0
  77. package/dist/{chunk-WXRPQICX.js → chunk-UK2IV2ZQ.js} +2 -2
  78. package/dist/{chunk-MFCZN253.js → chunk-UZCAYOIQ.js} +8 -10
  79. package/dist/{chunk-MFCZN253.js.map → chunk-UZCAYOIQ.js.map} +1 -1
  80. package/dist/{chunk-IKAGGJEO.js → chunk-V4UNYSZO.js} +558 -18
  81. package/dist/chunk-V4UNYSZO.js.map +1 -0
  82. package/dist/chunk-VAPCU2FX.js +70 -0
  83. package/dist/chunk-VAPCU2FX.js.map +1 -0
  84. package/dist/{chunk-Y2JGMICO.js → chunk-WGVU3LA5.js} +25 -33
  85. package/dist/chunk-WGVU3LA5.js.map +1 -0
  86. package/dist/{chunk-UNRR4KH5.js → chunk-WQ3F4O7U.js} +20 -14
  87. package/dist/chunk-WQ3F4O7U.js.map +1 -0
  88. package/dist/chunk-XNS4I3W6.js +102 -0
  89. package/dist/chunk-XNS4I3W6.js.map +1 -0
  90. package/dist/{chunk-LDVXYN6F.js → chunk-Y4I7ZCAE.js} +178 -135
  91. package/dist/chunk-Y4I7ZCAE.js.map +1 -0
  92. package/dist/{chunk-6I3RY6R5.js → chunk-ZKMSHLXP.js} +11 -15
  93. package/dist/{chunk-6I3RY6R5.js.map → chunk-ZKMSHLXP.js.map} +1 -1
  94. package/dist/{compile-SDOASKGL.js → compile-B2QG6BAQ.js} +37 -54
  95. package/dist/{compile-SDOASKGL.js.map → compile-B2QG6BAQ.js.map} +1 -1
  96. package/dist/{config-4VZTVZKF.js → config-D3F6ICZ2.js} +21 -39
  97. package/dist/{config-4VZTVZKF.js.map → config-D3F6ICZ2.js.map} +1 -1
  98. package/dist/cursor-local-install-4HDIBX22.js +94 -0
  99. package/dist/cursor-local-install-4HDIBX22.js.map +1 -0
  100. package/dist/cursor-local-install-LL367GZY.js +94 -0
  101. package/dist/cursor-local-install-LL367GZY.js.map +1 -0
  102. package/dist/{doctor-HH6CFBRQ.js → doctor-QSGETVDE.js} +19 -23
  103. package/dist/doctor-QSGETVDE.js.map +1 -0
  104. package/dist/{environment-K7YMJJYN.js → environment-2JS4RWQA.js} +69 -88
  105. package/dist/environment-2JS4RWQA.js.map +1 -0
  106. package/dist/{github-A6TYG7WS.js → github-JXSTHLY2.js} +14 -15
  107. package/dist/{github-A6TYG7WS.js.map → github-JXSTHLY2.js.map} +1 -1
  108. package/dist/{harness-772XBFZQ.js → harness-GBI3AMLH.js} +48 -65
  109. package/dist/{harness-772XBFZQ.js.map → harness-GBI3AMLH.js.map} +1 -1
  110. package/dist/{help-QR4VTJZU.js → help-EC52ERIE.js} +43 -52
  111. package/dist/help-EC52ERIE.js.map +1 -0
  112. package/dist/{help-TLHNRJJ6.js → help-VIRMBOPJ.js} +73 -551
  113. package/dist/help-VIRMBOPJ.js.map +1 -0
  114. package/dist/host-plugin-view-kept-XKHD6NGU.js +139 -0
  115. package/dist/host-plugin-view-kept-XKHD6NGU.js.map +1 -0
  116. package/dist/index.d.ts +7 -0
  117. package/dist/index.js +10 -22
  118. package/dist/{init-AOKFPZHG.js → init-OK3K6ILG.js} +49 -70
  119. package/dist/init-OK3K6ILG.js.map +1 -0
  120. package/dist/live-read-cache-ESQQJBNS.js +13 -0
  121. package/dist/live-read-cache-WPUFHVMZ.js +12 -0
  122. package/dist/{lock-INAXNLMC.js → lock-AA2F4I3K.js} +13 -16
  123. package/dist/{lock-INAXNLMC.js.map → lock-AA2F4I3K.js.map} +1 -1
  124. package/dist/{marketplace-TUVLLPBG.js → marketplace-QUYCV23F.js} +75 -94
  125. package/dist/marketplace-QUYCV23F.js.map +1 -0
  126. package/dist/{mcp-MMWGRASN.js → mcp-CIHSR4DD.js} +35 -52
  127. package/dist/{mcp-MMWGRASN.js.map → mcp-CIHSR4DD.js.map} +1 -1
  128. package/dist/{migrate-55S4XODX.js → migrate-TQPEZYS5.js} +148 -74
  129. package/dist/migrate-TQPEZYS5.js.map +1 -0
  130. package/dist/notifications-TAELTPDW.js +154 -0
  131. package/dist/notifications-TAELTPDW.js.map +1 -0
  132. package/dist/open-D3GWGDSQ.js +20 -0
  133. package/dist/{pack-VZIBS42E.js → pack-VUO4UBWL.js} +12 -22
  134. package/dist/{pack-VZIBS42E.js.map → pack-VUO4UBWL.js.map} +1 -1
  135. package/dist/plugin-L3466DHK.js +47 -0
  136. package/dist/plugin-from-project-U5UGKTJH.js +15 -0
  137. package/dist/plugin-from-project-U5UGKTJH.js.map +1 -0
  138. package/dist/{policy-P3HGLEZS.js → policy-Z5TL4N3V.js} +11 -15
  139. package/dist/{policy-P3HGLEZS.js.map → policy-Z5TL4N3V.js.map} +1 -1
  140. package/dist/{profile-STS3CZUK.js → profile-QFI7SL3S.js} +167 -143
  141. package/dist/profile-QFI7SL3S.js.map +1 -0
  142. package/dist/{project-R4DGM3ZG.js → project-3KR3EPYR.js} +506 -94
  143. package/dist/project-3KR3EPYR.js.map +1 -0
  144. package/dist/{resource-GJVEDXVZ.js → resource-45BPRQ7V.js} +66 -63
  145. package/dist/resource-45BPRQ7V.js.map +1 -0
  146. package/dist/status-refresh-worker.js +1155 -0
  147. package/dist/status-refresh-worker.js.map +1 -0
  148. package/dist/{version-FUHV4O6U.js → version-QUJZGTZ5.js} +3 -3
  149. package/dist/version-QUJZGTZ5.js.map +1 -0
  150. package/package.json +17 -11
  151. package/dist/apply-Q5SFF3FY.js +0 -67
  152. package/dist/chunk-24V5ZSIF.js +0 -658
  153. package/dist/chunk-24V5ZSIF.js.map +0 -1
  154. package/dist/chunk-2H7UOFLK.js +0 -11
  155. package/dist/chunk-3JOPDYQD.js +0 -730
  156. package/dist/chunk-3JOPDYQD.js.map +0 -1
  157. package/dist/chunk-555XE3NJ.js +0 -60
  158. package/dist/chunk-555XE3NJ.js.map +0 -1
  159. package/dist/chunk-64R32MG2.js.map +0 -1
  160. package/dist/chunk-6JMVGKMD.js.map +0 -1
  161. package/dist/chunk-6ZWKF3YZ.js +0 -7795
  162. package/dist/chunk-6ZWKF3YZ.js.map +0 -1
  163. package/dist/chunk-AFKCNFPP.js.map +0 -1
  164. package/dist/chunk-AUWWL6KX.js +0 -296
  165. package/dist/chunk-AUWWL6KX.js.map +0 -1
  166. package/dist/chunk-AVZOFMJX.js.map +0 -1
  167. package/dist/chunk-CZ4T75PP.js.map +0 -1
  168. package/dist/chunk-FUV7QYBS.js.map +0 -1
  169. package/dist/chunk-GWQVYGRD.js.map +0 -1
  170. package/dist/chunk-HENOKIBB.js +0 -346
  171. package/dist/chunk-HENOKIBB.js.map +0 -1
  172. package/dist/chunk-HWL67OCJ.js +0 -238
  173. package/dist/chunk-HWL67OCJ.js.map +0 -1
  174. package/dist/chunk-IKAGGJEO.js.map +0 -1
  175. package/dist/chunk-JJJJ2RAD.js.map +0 -1
  176. package/dist/chunk-JRFUTIEH.js +0 -426
  177. package/dist/chunk-JRFUTIEH.js.map +0 -1
  178. package/dist/chunk-KJIFZLHN.js +0 -11066
  179. package/dist/chunk-KJIFZLHN.js.map +0 -1
  180. package/dist/chunk-LDVXYN6F.js.map +0 -1
  181. package/dist/chunk-MHOTXMD2.js +0 -430
  182. package/dist/chunk-MHOTXMD2.js.map +0 -1
  183. package/dist/chunk-NAGAJ5UM.js +0 -145
  184. package/dist/chunk-NAGAJ5UM.js.map +0 -1
  185. package/dist/chunk-NEPUP33Q.js +0 -35
  186. package/dist/chunk-NEPUP33Q.js.map +0 -1
  187. package/dist/chunk-OPVIX7E4.js.map +0 -1
  188. package/dist/chunk-OQ4KBUN2.js.map +0 -1
  189. package/dist/chunk-OXVCYRZB.js +0 -491
  190. package/dist/chunk-OXVCYRZB.js.map +0 -1
  191. package/dist/chunk-PJQAMC6L.js +0 -183
  192. package/dist/chunk-PJQAMC6L.js.map +0 -1
  193. package/dist/chunk-PW5QXRBA.js +0 -1173
  194. package/dist/chunk-PW5QXRBA.js.map +0 -1
  195. package/dist/chunk-QNAIDM6W.js.map +0 -1
  196. package/dist/chunk-R4PTE774.js.map +0 -1
  197. package/dist/chunk-S2E4KSYW.js +0 -610
  198. package/dist/chunk-S2E4KSYW.js.map +0 -1
  199. package/dist/chunk-SNVAMWB7.js +0 -40
  200. package/dist/chunk-SNVAMWB7.js.map +0 -1
  201. package/dist/chunk-TQ2NA4Z4.js.map +0 -1
  202. package/dist/chunk-U472S6IB.js.map +0 -1
  203. package/dist/chunk-UEHDEADL.js.map +0 -1
  204. package/dist/chunk-UNRR4KH5.js.map +0 -1
  205. package/dist/chunk-VQVUJYYY.js.map +0 -1
  206. package/dist/chunk-XGTTOO4R.js +0 -84
  207. package/dist/chunk-XGTTOO4R.js.map +0 -1
  208. package/dist/chunk-XRXFJTAT.js.map +0 -1
  209. package/dist/chunk-Y2JGMICO.js.map +0 -1
  210. package/dist/chunk-YVJQ2QDG.js.map +0 -1
  211. package/dist/chunk-YX7MVSDA.js +0 -235
  212. package/dist/chunk-YX7MVSDA.js.map +0 -1
  213. package/dist/chunk-ZGRBIBO7.js +0 -681
  214. package/dist/chunk-ZGRBIBO7.js.map +0 -1
  215. package/dist/chunk-ZTBAMBAI.js +0 -6448
  216. package/dist/chunk-ZTBAMBAI.js.map +0 -1
  217. package/dist/chunk-ZVANUFPF.js +0 -1035
  218. package/dist/chunk-ZVANUFPF.js.map +0 -1
  219. package/dist/doctor-HH6CFBRQ.js.map +0 -1
  220. package/dist/environment-K7YMJJYN.js.map +0 -1
  221. package/dist/help-QR4VTJZU.js.map +0 -1
  222. package/dist/help-TLHNRJJ6.js.map +0 -1
  223. package/dist/init-AOKFPZHG.js.map +0 -1
  224. package/dist/marketplace-TUVLLPBG.js.map +0 -1
  225. package/dist/migrate-55S4XODX.js.map +0 -1
  226. package/dist/open-SLFQV45J.js +0 -32
  227. package/dist/plugin-WLEFFBRY.js +0 -64
  228. package/dist/plugin-from-project-UV2O364T.js +0 -16
  229. package/dist/profile-STS3CZUK.js.map +0 -1
  230. package/dist/project-R4DGM3ZG.js.map +0 -1
  231. package/dist/resource-GJVEDXVZ.js.map +0 -1
  232. /package/dist/{apply-Q5SFF3FY.js.map → apply-FTAIL3X3.js.map} +0 -0
  233. /package/dist/{chunk-IHW4PCDT.js.map → chunk-6FXJIKEG.js.map} +0 -0
  234. /package/dist/{chunk-IAZNF35S.js.map → chunk-CBSDMRMY.js.map} +0 -0
  235. /package/dist/{chunk-3EGM4IUI.js.map → chunk-EPXAOEBB.js.map} +0 -0
  236. /package/dist/{chunk-XCPWLGPB.js.map → chunk-K4UDZUJ2.js.map} +0 -0
  237. /package/dist/{chunk-FBYAIBHP.js.map → chunk-MHLAIGIM.js.map} +0 -0
  238. /package/dist/{chunk-2H7UOFLK.js.map → chunk-MKLJBW5N.js.map} +0 -0
  239. /package/dist/{chunk-BXSS2S4W.js.map → chunk-R27VZIF6.js.map} +0 -0
  240. /package/dist/{chunk-JQOKQKQT.js.map → chunk-S2D5PWAO.js.map} +0 -0
  241. /package/dist/{chunk-WXRPQICX.js.map → chunk-UK2IV2ZQ.js.map} +0 -0
  242. /package/dist/{open-SLFQV45J.js.map → live-read-cache-ESQQJBNS.js.map} +0 -0
  243. /package/dist/{plugin-WLEFFBRY.js.map → live-read-cache-WPUFHVMZ.js.map} +0 -0
  244. /package/dist/{plugin-from-project-UV2O364T.js.map → open-D3GWGDSQ.js.map} +0 -0
  245. /package/dist/{version-FUHV4O6U.js.map → plugin-L3466DHK.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/services/status-refresh-worker.ts","../src/services/global-profile-drift.ts","../src/services/cross-harness-gap.ts","../src/utils/unified-diff.ts","../src/services/host-config-resource-detail.ts","../src/services/mcp-resource-detail.ts","../src/services/scoped-file-content-delta.ts"],"sourcesContent":["import { describeStatusRefreshError } from \"./status-refresh-error.js\";\nimport { join } from \"node:path\";\nimport { parentPort } from \"node:worker_threads\";\nimport { resolveHomeRoot, setHomeRootOverride } from \"../utils/home-root.js\";\nimport { statusTraceEnabled } from \"./status-trace.js\";\nimport { loadGlobalProfileStatusSnapshot } from \"./global-profile-drift.js\";\nimport {\n armStatusWatches,\n closeStatusWatches,\n releaseStatusWatchesForOtherHomes,\n collectFingerprintPaths,\n} from \"./status-read-cache.js\";\n\ninterface RefreshRequest {\n op?: \"pause-watches\";\n id?: number;\n home?: string;\n userProfile?: string;\n harnesstapHome?: string;\n depth?: string;\n harness?: string;\n projectPath?: string;\n delayMs?: number;\n}\n\nfunction applyEnv(request: RefreshRequest): void {\n if (request.home) {\n process.env.HOME = request.home;\n setHomeRootOverride(request.home);\n }\n if (request.userProfile) process.env.USERPROFILE = request.userProfile;\n if (request.harnesstapHome) {\n process.env.HARNESSTAP_HOME = request.harnesstapHome;\n } else if (request.home) {\n // HOME itself cannot be changed in a Bun 1.3 worker. Point the database\n // at the request home so status does not read the worker's startup home.\n process.env.HARNESSTAP_HOME = join(request.home, \".harnesstap\");\n } else {\n delete process.env.HARNESSTAP_HOME;\n }\n}\n\nfunction depthOf(depth: string | undefined): \"fast\" | \"full\" {\n return depth === \"fast\" ? \"fast\" : \"full\";\n}\n\nlet chain: Promise<void> = Promise.resolve();\n\nparentPort?.on(\"message\", (request: RefreshRequest) => {\n if (request.op === \"pause-watches\") {\n closeStatusWatches();\n return;\n }\n const requestId = request.id;\n if (requestId === undefined) return;\n const run = chain.then(async () => {\n try {\n applyEnv(request);\n // Stop watching a previous home before this read, so its teardown\n // is not reported as an edit.\n releaseStatusWatchesForOtherHomes(resolveHomeRoot());\n if (request.delayMs && request.delayMs > 0) {\n const shared = new SharedArrayBuffer(4);\n Atomics.wait(new Int32Array(shared), 0, 0, request.delayMs);\n }\n const computeStarted = statusTraceEnabled ? performance.now() : 0;\n const loaded = await loadGlobalProfileStatusSnapshot({\n depth: depthOf(request.depth),\n harness: request.harness,\n projectPath: request.projectPath,\n });\n const computeMs = statusTraceEnabled ? performance.now() - computeStarted : 0;\n const collected = collectFingerprintPaths(request.projectPath, loaded.watchedPaths);\n const jsonStarted = statusTraceEnabled ? performance.now() : 0;\n const json = JSON.stringify(loaded.value);\n const value = JSON.parse(json);\n const jsonMs = statusTraceEnabled ? performance.now() - jsonStarted : 0;\n parentPort?.postMessage({\n id: requestId,\n ok: true,\n ...(statusTraceEnabled ? { trace: { computeMs, jsonMs, bytes: json.length } } : {}),\n value,\n watchedPaths: loaded.watchedPaths,\n watchPaths: collected.paths,\n });\n // Watch after the result is queued so this thread's fs.watch cannot sit on the request.\n const created = armStatusWatches(collected.paths, collected.recursive, resolveHomeRoot());\n parentPort?.postMessage({ op: \"watch-report\", created });\n } catch (error) {\n parentPort?.postMessage({\n id: requestId,\n ok: false,\n error: describeStatusRefreshError(error),\n });\n }\n });\n chain = run.then(() => undefined, () => undefined);\n});\n","import { runTracedStatus, traceCount, traceSpan } from \"./status-trace.js\";\nimport { unreadNotificationCount } from \"./notifications.js\";\nimport { readUpstreamCheckSummary, type UpstreamCheckSummary } from \"./upstream-check-read.js\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { harnesstapDirForHomeRoot } from \"../db/connection.js\";\nimport { diffHostPluginView } from \"./package-cache/host-plugin.js\";\nimport { emittedHostPluginTree } from \"./host-plugin-serialize.js\";\nimport {\n CLAUDE_KNOWN_MARKETPLACES_PATH,\n HARNESSTAP_CLAUDE_MARKETPLACES_ROOT,\n claudeChangedMarketplaces,\n harnessTapClaudeMarketplaceManifestPath,\n} from \"./claude-marketplace-registration.js\";\nimport { hostPluginPackageDir } from \"./package-cache/paths.js\";\nimport { isEmptyBuiltinProfile, isProfilePlugin } from \"../constants/profile.js\";\nimport { getLatestGlobalApplySnapshotForProfile } from \"../models/global-apply-snapshot.js\";\nimport { resolvePluginSelector } from \"../models/plugin-model.js\";\nimport { listMaterializationsForRootPath } from \"../models/resource-materialization.js\";\nimport { resolveHomeRoot } from \"../utils/home-root.js\";\nimport { getActiveProfileName } from \"./active-profile.js\";\nimport {\n isTransparentCrossHarnessGap,\n resourceScopesForPlugins,\n liveSkillCopiesForMissingPath,\n} from \"./cross-harness-gap.js\";\nimport {\n buildHostManagedStatus,\n type HostManagedStatus,\n profileSkillNameMap,\n} from \"./cursor-host-managed-skills.js\";\nimport { binaryExpectedFileMatchesDisk, fileContentsEquivalentForDrift } from \"./file-contents-drift.js\";\nimport { isNativeAgentPluginCachePath } from \"./native-agent-plugins.js\";\nimport {\n buildHarnessLiveStatusMap,\n classifyGlobalDriftChanges,\n collectOwnedGlobalProfileFiles,\n computeGlobalProfilePanelStatus,\n countMissingHarnessRows,\n declaredMcpFromExpectedFiles,\n filesOnlyMarketplacePinRefs,\n listMissingHarnessRows,\n type GlobalProfileDriftSummary,\n type GlobalProfilePanelStatus,\n type GlobalProfileStatusDepth,\n type HarnessLiveStatus,\n resolveProjectDriftSummary,\n} from \"./global-profile-status-panel.js\";\nimport type { HarnessScope } from \"./harness-scope.js\";\nimport { mergePluginsForApply } from \"./plugin-apply-merge.js\";\nimport {\n type ApplyProfilePluginResult,\n applyProfilePlugin,\n clearGlobalProfileApply,\n collectProfilePluginIds,\n} from \"./profile-apply.js\";\nimport { resourceKeyFromManagedPath } from \"./profile-commit-resource.js\";\nimport {\n buildProfileContents,\n type ProfileContents,\n} from \"./profile-contents.js\";\nimport { detectNotStagedProfileResources } from \"./profile-untracked-resources.js\";\nimport { type DriftFileChange, driftChangeIsKept } from \"./project-drift.js\";\nimport { hashOnDiskFile } from \"./safe-file-removal.js\";\nimport { withAffectedResources } from \"./scoped-file-content-delta.js\";\nimport { readDiskTextOnce } from \"./status-disk-read.js\";\nimport { inStatusComputation, runInStatusComputation } from \"./status-computation.js\";\nimport { withStatusReadCache } from \"./status-read-cache.js\";\n\ntype StatusFieldInput = Parameters<typeof buildBaseStatusFields>[0];\n\ninterface DriftCore {\n fields: Omit<StatusFieldInput, \"depth\">;\n harness?: string;\n watchedPaths: string[];\n}\n\nlet driftCoreComputes = 0;\n\n/** How many times the dry-run core has actually run. Tests use this. */\nexport function readDriftCoreComputeCount(): number {\n return driftCoreComputes;\n}\n\nfunction driftCore(\n fields: Omit<StatusFieldInput, \"depth\">,\n harness: string | undefined,\n homeRoot: string,\n): DriftCore {\n const watchedPaths = (fields.expectedApply?.expected_files ?? []).map((file) =>\n join(homeRoot, file.path),\n );\n return { fields, harness, watchedPaths };\n}\n\nexport interface GlobalProfileStatus {\n active_profile: string | null;\n profile_exists: boolean;\n applied: boolean;\n snapshot_id: string | null;\n snapshot_at: string | null;\n stack_in_sync: boolean;\n has_drift: boolean;\n changes: DriftFileChange[];\n warning?: string;\n depth: GlobalProfileStatusDepth;\n as_of: string;\n panel: GlobalProfilePanelStatus;\n harnesses: Record<string, HarnessLiveStatus>;\n drift_summary: GlobalProfileDriftSummary;\n contents?: ProfileContents | null;\n untracked_resource_count?: number;\n /** Alias for untracked_resource_count (not-staged working-tree resources). */\n not_staged_count?: number;\n /** App-managed inventory (full depth only); never applied or persisted. */\n host_managed?: HostManagedStatus;\n /**\n * True when this payload is the previous result and a fresh read is running.\n * Absent or false after apply, switch, and install, which wait for a new read.\n */\n refreshing?: boolean;\n /** Pending upstream updates from the last check. Read from the table only, never the network. */\n updates?: UpstreamCheckSummary;\n /** Unread notifications, for the Desktop bell. One indexed count, outside the cache. */\n unread_count?: number;\n}\n\n/**\n * One answer to \"is the global state in sync with the active profile\" for the\n * human output, `profile status --check`, and the JSON panel: file drift plus\n * declared plugins and MCP servers a full status found missing.\n */\nexport function globalProfileStatusGaps(status: GlobalProfileStatus): {\n inSync: boolean;\n missing: Array<{ harness: string; kind: \"plugin\" | \"mcp\"; id: string }>;\n} {\n const missing = status.depth === \"full\" ? listMissingHarnessRows(status.harnesses) : [];\n return { inSync: !status.has_drift && missing.length === 0, missing };\n}\n\nconst HOST_PLUGIN_VIEW_PATH = /^(\\.claude\\/plugins\\/cache\\/([^/]+)\\/([^/]+)\\/([^/]+))\\//;\n\n/** True for a file inside a host plugin cache folder, which apply refreshes from the plugin. */\nexport function isHostPluginViewPath(path: string): boolean {\n return HOST_PLUGIN_VIEW_PATH.test(path.replaceAll(\"\\\\\", \"/\"));\n}\n\n/**\n * A host plugin cache folder (`~/.claude/plugins/cache/<mkt>/<name>/<ver>`)\n * is emitted from itself, so comparing the expected files with the disk finds\n * nothing even when it holds the user's files instead of the plugin's. Compare\n * each such folder with HarnessTap's copy of the plugin instead. Files a\n * refresh would keep are reported as kept, not as pending writes.\n */\nexport function hostPluginFolderChanges(\n homeRoot: string,\n expectedFiles: ReadonlyArray<{ path: string }>,\n known: readonly DriftFileChange[],\n): DriftFileChange[] {\n const folders = new Map<string, { marketplace: string; name: string; version: string }>();\n for (const file of expectedFiles) {\n const match = HOST_PLUGIN_VIEW_PATH.exec(file.path.replaceAll(\"\\\\\", \"/\"));\n if (!match?.[1] || !match[2] || !match[3] || !match[4]) continue;\n folders.set(match[1], { marketplace: match[2], name: match[3], version: match[4] });\n }\n if (folders.size === 0) return [];\n const seen = new Set(known.map((change) => change.path));\n const harnesstapDir = harnesstapDirForHomeRoot(homeRoot);\n const changes: DriftFileChange[] = [];\n for (const [folder, plugin] of folders) {\n const canonicalDir = hostPluginPackageDir(harnesstapDir, plugin.marketplace, plugin.name, plugin.version);\n const differences = diffHostPluginView({\n homeRoot,\n hostView: join(homeRoot, folder),\n canonicalDir,\n });\n // Spec plugins are translated for the host on write (`mcp.json` becomes\n // `.mcp.json`, for example), so compare with what the apply writes.\n const emitted = differences.length > 0\n ? emittedHostPluginTree(canonicalDir, \"claude-code\", plugin.name)\n : new Map<string, { content: string; encoding?: \"utf8\" | \"base64\" }>();\n for (const difference of differences) {\n const path = `${folder}/${difference.path}`;\n if (seen.has(path)) continue;\n const written = emitted.get(difference.path);\n if (difference.state === \"missing\" ? !written : matchesEmitted(join(homeRoot, path), written)) {\n continue;\n }\n seen.add(path);\n if (difference.state === \"missing\") changes.push({ path, type: \"deleted\" });\n else if (difference.state === \"stale\") changes.push({ path, type: \"modified\" });\n else if (difference.state === \"modified\") {\n // HarnessTap wrote the file and it changed since: in Claude Code's\n // plugin cache, that is Claude Code updating the plugin.\n changes.push({ path, type: \"modified\", removal_group: \"owned_modified\", changed_by: \"claude-code\" });\n } else {\n changes.push({ path, type: \"modified\", removal_group: \"unmanaged\" });\n }\n }\n }\n return changes;\n}\n\nfunction matchesEmitted(\n fullPath: string,\n file: { content: string; encoding?: \"utf8\" | \"base64\" } | undefined,\n): boolean {\n if (!file) return false;\n const binary = binaryExpectedFileMatchesDisk(fullPath, file);\n if (binary !== undefined) return binary;\n try {\n return readFileSync(fullPath, \"utf-8\") === file.content;\n } catch {\n return false;\n }\n}\n\nfunction isHarnessTapClaudeMarketplaceFile(path: string): boolean {\n return path.replaceAll(\"\\\\\", \"/\").startsWith(`${HARNESSTAP_CLAUDE_MARKETPLACES_ROOT}/`);\n}\n\n/**\n * Marketplace entries HarnessTap registers for this profile that Claude Code\n * rewrote since. Apply leaves them as they are, so the file itself matches\n * what apply would write; report each entry as a kept change.\n */\nexport function claudeChangedMarketplaceEntries(\n homeRoot: string,\n expectedFiles: ReadonlyArray<{ path: string }>,\n): DriftFileChange[] {\n const wanted = new Set(expectedFiles.map((file) => file.path));\n return [...claudeChangedMarketplaces(homeRoot)]\n .filter((marketplace) => wanted.has(harnessTapClaudeMarketplaceManifestPath(marketplace)))\n .sort()\n .map((marketplace) => ({\n path: CLAUDE_KNOWN_MARKETPLACES_PATH,\n type: \"modified\" as const,\n removal_group: \"owned_modified\" as const,\n changed_by: \"claude-code\" as const,\n detail: `marketplace ${marketplace}`,\n }));\n}\n\nfunction keptContentDiff(\n path: string,\n keptModified: ReadonlySet<string>,\n keptUnmanaged: ReadonlySet<string>,\n): DriftFileChange {\n if (keptModified.has(path)) {\n return { path, type: \"modified\", removal_group: \"owned_modified\" };\n }\n if (keptUnmanaged.has(path)) {\n return { path, type: \"modified\", removal_group: \"unmanaged\" };\n }\n return { path, type: \"modified\" };\n}\n\nfunction isMissingExpectedFileTransparent(\n homeRoot: string,\n path: string,\n expectedPathsByResource: ReadonlyMap<string, readonly string[]>,\n scopeByResource: ReadonlyMap<string, HarnessScope>,\n harnesses: readonly string[],\n): boolean {\n const mapped = resourceKeyFromManagedPath(path);\n if (!mapped) {\n return true;\n }\n const key = `${mapped.type}:${mapped.name}`;\n const siblings = expectedPathsByResource.get(key) ?? [];\n const onDiskSiblingPaths = siblings.filter(\n (sibling) => sibling !== path && readGlobalFile(homeRoot, sibling) !== null,\n );\n for (const live of liveSkillCopiesForMissingPath(path, harnesses, (candidate) => readGlobalFile(homeRoot, candidate) !== null)) {\n if (!onDiskSiblingPaths.includes(live)) onDiskSiblingPaths.push(live);\n }\n return isTransparentCrossHarnessGap({\n path,\n onDiskSiblingPaths,\n scope: scopeByResource.get(key),\n });\n}\n\nfunction readGlobalFile(homeRoot: string, relativePath: string): string | null {\n const fullPath = join(homeRoot, relativePath);\n if (!inStatusComputation()) return readGlobalFileUncached(fullPath);\n if (!existsSync(fullPath)) return null;\n return readDiskTextOnce(fullPath);\n}\n\nfunction readGlobalFileUncached(fullPath: string): string | null {\n if (!existsSync(fullPath)) {\n return null;\n }\n try {\n return readFileSync(fullPath, \"utf-8\");\n } catch {\n return null;\n }\n}\n\nfunction pluginIdsMatch(left: string[], right: string[]): boolean {\n if (left.length !== right.length) {\n return false;\n }\n return left.every((pluginId, index) => pluginId === right[index]);\n}\n\nfunction declaredMcpFromExpectedApply(expectedApply: ApplyProfilePluginResult) {\n return declaredMcpFromExpectedFiles(\n expectedApply.harnesses,\n expectedApply.expected_files ?? [],\n );\n}\n\nfunction declaredMcpNamesFromMergedPlugins(pluginIds: string[]): Record<string, string[]> {\n const merged = mergePluginsForApply(pluginIds);\n const names = merged.resources\n .filter((resource) => resource.type === \"mcp_server\")\n .map((resource) => resource.name);\n return {\n \"claude-code\": names,\n cursor: names,\n };\n}\n\nfunction buildBaseStatusFields(input: {\n depth: GlobalProfileStatusDepth;\n activeProfile: string | null;\n profileExists: boolean;\n applied: boolean;\n snapshotId: string | null;\n snapshotAt: string | null;\n stackInSync: boolean;\n hasDrift: boolean;\n changes: DriftFileChange[];\n warning?: string;\n projectPath?: string;\n expectedApply?: ApplyProfilePluginResult;\n pluginIds?: string[];\n}): GlobalProfileStatus {\n const asOf = new Date().toISOString();\n const homeRoot = resolveHomeRoot();\n const ownedFiles = traceSpan(\"db.owned-files\", () => collectOwnedGlobalProfileFiles(input.snapshotId));\n const blockingChanges = input.changes.filter((change) => !driftChangeIsKept(change));\n const { owned, nonOwned } = classifyGlobalDriftChanges(blockingChanges, ownedFiles);\n\n const declaredPins =\n input.pluginIds && input.pluginIds.length > 0\n ? traceSpan(\"base.merge-plugins\", () => mergePluginsForApply(input.pluginIds ?? []).pluginPins)\n : [];\n const declaredFromExpected = input.expectedApply\n ? declaredMcpFromExpectedApply(input.expectedApply)\n : null;\n const declaredMcpByHarness =\n declaredFromExpected?.namesByHarness\n ?? (input.pluginIds\n ? declaredMcpNamesFromMergedPlugins(input.pluginIds)\n : { \"claude-code\": [], cursor: [] });\n\n const filesOnlyPinRefs = input.expectedApply?.resolution\n ? {\n \"claude-code\": filesOnlyMarketplacePinRefs(input.expectedApply.resolution, \"claude-code\"),\n cursor: filesOnlyMarketplacePinRefs(input.expectedApply.resolution, \"cursor\"),\n }\n : undefined;\n\n const harnesses = traceSpan(\"base.harness-live-status\", () => buildHarnessLiveStatusMap({\n depth: input.depth,\n homeRoot,\n declaredPins,\n ...(filesOnlyPinRefs ? { filesOnlyPinRefs } : {}),\n declaredMcpByHarness,\n ...(declaredFromExpected\n ? { expectedMcpConfigsByHarness: declaredFromExpected.configsByHarness }\n : {}),\n }));\n const { missingPlugins, missingMcp } =\n input.depth === \"full\"\n ? countMissingHarnessRows(harnesses)\n : { missingPlugins: 0, missingMcp: 0 };\n\n const contents = input.activeProfile\n ? traceSpan(\"base.profile-contents\", () => buildProfileContents(input.activeProfile ?? \"\"))\n : null;\n const hostManaged =\n input.depth === \"full\"\n ? traceSpan(\"base.host-managed\", () =>\n buildHostManagedStatus({\n homeRoot,\n profileSkills: profileSkillNameMap(contents?.resources ?? []),\n }),\n )\n : undefined;\n\n const projectDrift = traceSpan(\"base.project-drift\", () => resolveProjectDriftSummary(input.projectPath));\n const panel = computeGlobalProfilePanelStatus({\n depth: input.depth,\n applied: input.applied,\n activeProfile: input.activeProfile,\n stackInSync: input.stackInSync,\n ownedDriftCount: owned.length,\n nonOwnedDriftCount: nonOwned.length,\n missingPluginCount: missingPlugins,\n missingMcpCount: missingMcp,\n projectDrift,\n warning: input.warning,\n hostManagedCollisionCount: hostManaged?.cursor?.collisions.length ?? 0,\n });\n\n const driftSummary: GlobalProfileDriftSummary = {\n global: {\n status: !input.applied\n ? \"pending\"\n : input.hasDrift\n ? \"drifted\"\n : \"clean\",\n owned_changes: owned.length,\n non_owned_changes: nonOwned.length,\n },\n ...(projectDrift ? { project: projectDrift } : {}),\n };\n\n return {\n active_profile: input.activeProfile,\n profile_exists: input.profileExists,\n applied: input.applied,\n snapshot_id: input.snapshotId,\n snapshot_at: input.snapshotAt,\n stack_in_sync: input.stackInSync,\n has_drift: input.hasDrift,\n changes: input.changes,\n ...(input.warning ? { warning: input.warning } : {}),\n depth: input.depth,\n as_of: asOf,\n panel,\n harnesses,\n drift_summary: driftSummary,\n contents,\n ...(hostManaged ? { host_managed: hostManaged } : {}),\n };\n}\n\nasync function finalizeGlobalProfileStatus(\n fields: Parameters<typeof buildBaseStatusFields>[0],\n harness?: string,\n): Promise<GlobalProfileStatus> {\n const status = traceSpan(\"base\", () => buildBaseStatusFields(fields));\n if (\n fields.depth !== \"full\"\n || !status.active_profile\n || isEmptyBuiltinProfile(status.active_profile)\n ) {\n return status;\n }\n try {\n const notStaged = await traceSpan(\"not-staged\", () =>\n detectNotStagedProfileResources({\n profileSelector: status.active_profile ?? \"\",\n scope: \"home\",\n ...(harness ? { harness } : {}),\n }),\n );\n return {\n ...status,\n untracked_resource_count: notStaged.length,\n not_staged_count: notStaged.length,\n };\n } catch {\n return status;\n }\n}\n\n/**\n * Fast depth keeps the same drift fields as a full read (`changes`,\n * `has_drift`, `stack_in_sync`, `drift_summary`). The desktop drift pill\n * replaces those from every fast poll, so a cold fast read still runs the\n * dry-run. The full result, including that dry-run and profile contents, is\n * cached. A warm read is a map lookup while file watchers are healthy.\n * Status does not read Cursor's state.vscdb or logs folder. Where a watcher\n * could not be installed, mtimes and sizes of the remaining files are\n * checked instead.\n * A later read of the same depth skips the dry-run. Cold and refresh both\n * run on the background worker. The caller waits for a cold read, and the\n * main thread does not run that dry-run. When a watched input changes, the\n * previous result is returned with `refreshing` set. A warm or stale\n * response does not wait for that read. A status-relevant database write on\n * this process, or a commit from another process (`data_version`), drops the\n * snapshot, so the next read waits and includes that write. Apply, switch,\n * and install clear the cache first,\n * so the next read waits and is not stale. Overlapping callers share one\n * in-flight computation.\n */\nexport async function detectGlobalProfileStatus(input: {\n harness?: string;\n depth?: GlobalProfileStatusDepth;\n projectPath?: string;\n} = {}): Promise<GlobalProfileStatus> {\n const depth = input.depth ?? \"full\";\n const request = {\n depth,\n harness: input.harness,\n projectPath: input.projectPath,\n };\n const status = await withStatusReadCache(request, () => runInStatusComputation(async () => {\n const core = await withStatusReadCache(\n { ...request, includeDepth: false },\n async () => {\n const loaded = await loadDriftCore(input);\n return { value: loaded, watchedPaths: loaded.watchedPaths };\n },\n );\n const projected = await finalizeGlobalProfileStatus(\n { ...core.fields, depth },\n core.harness,\n );\n return { value: projected, watchedPaths: core.watchedPaths };\n }), { staleWhileRefresh: true });\n return {\n ...status,\n as_of: new Date().toISOString(),\n refreshing: status.refreshing === true,\n // Outside the cache: one indexed read, so a finished check shows at once.\n updates: readUpstreamCheckSummary(),\n unread_count: unreadNotificationCount(),\n };\n}\n\n/**\n * Full status computation with no cache. The refresh worker runs this off the\n * request thread. A warm or stale response must not wait for it.\n */\nexport async function loadGlobalProfileStatusSnapshot(input: {\n harness?: string;\n depth?: GlobalProfileStatusDepth;\n projectPath?: string;\n} = {}): Promise<{ value: GlobalProfileStatus; watchedPaths: string[] }> {\n const depth = input.depth ?? \"full\";\n return runInStatusComputation(() =>\n runTracedStatus(`depth=${depth} harness=${input.harness ?? \"*\"}`, async () => {\n const loaded = await traceSpan(\"drift-core\", () => loadDriftCore(input));\n const projected = await traceSpan(\"finalize\", () =>\n finalizeGlobalProfileStatus({ ...loaded.fields, depth }, loaded.harness),\n );\n return { value: projected, watchedPaths: loaded.watchedPaths };\n }),\n );\n}\n\nasync function loadDriftCore(input: {\n harness?: string;\n depth?: GlobalProfileStatusDepth;\n projectPath?: string;\n}): Promise<DriftCore> {\n driftCoreComputes += 1;\n const homeRoot = resolveHomeRoot();\n const activeProfile = getActiveProfileName() ?? null;\n if (!activeProfile) {\n return driftCore(\n {\n activeProfile: null,\n profileExists: false,\n applied: false,\n snapshotId: null,\n snapshotAt: null,\n stackInSync: false,\n hasDrift: false,\n changes: [],\n projectPath: input.projectPath,\n },\n input.harness,\n homeRoot,\n );\n }\n\n const plugin = traceSpan(\"db.resolve-profile\", () => resolvePluginSelector(activeProfile));\n if (!plugin) {\n if (isEmptyBuiltinProfile(activeProfile)) {\n const latestSnapshot = getLatestGlobalApplySnapshotForProfile(activeProfile);\n let expectedApply: ApplyProfilePluginResult;\n try {\n expectedApply = await clearGlobalProfileApply({\n dryRun: true,\n harness: input.harness,\n conflictPolicy: \"replace\",\n pull: false,\n });\n } catch (error) {\n return driftCore({\n activeProfile,\n profileExists: true,\n applied: Boolean(latestSnapshot),\n snapshotId: latestSnapshot?.id ?? null,\n snapshotAt: latestSnapshot?.created_at ?? null,\n stackInSync: false,\n hasDrift: true,\n changes: [],\n warning: error instanceof Error ? error.message : String(error),\n projectPath: input.projectPath,\n pluginIds: [],\n }, input.harness, homeRoot);\n }\n\n const stackInSync = latestSnapshot\n ? pluginIdsMatch(latestSnapshot.plugin_ids, expectedApply.configured_plugin_ids)\n : false;\n const applied = Boolean(latestSnapshot);\n const hasDrift = !applied || !stackInSync;\n\n return driftCore({\n activeProfile,\n profileExists: true,\n applied,\n snapshotId: latestSnapshot?.id ?? null,\n snapshotAt: latestSnapshot?.created_at ?? null,\n stackInSync,\n hasDrift,\n changes: [],\n projectPath: input.projectPath,\n expectedApply,\n pluginIds: [],\n }, input.harness, homeRoot);\n }\n\n return driftCore({\n activeProfile,\n profileExists: false,\n applied: false,\n snapshotId: null,\n snapshotAt: null,\n stackInSync: false,\n hasDrift: true,\n changes: [],\n warning: `missing plugin \"${activeProfile}\"`,\n projectPath: input.projectPath,\n }, input.harness, homeRoot);\n }\n\n if (!isProfilePlugin(plugin)) {\n return driftCore({\n activeProfile,\n profileExists: true,\n applied: false,\n snapshotId: null,\n snapshotAt: null,\n stackInSync: false,\n hasDrift: true,\n changes: [],\n warning: `plugin \"${plugin.name}\" is not tagged as a profile`,\n projectPath: input.projectPath,\n }, input.harness, homeRoot);\n }\n\n const latestSnapshot = getLatestGlobalApplySnapshotForProfile(activeProfile);\n const pluginIds = collectProfilePluginIds(plugin);\n let expectedApply: ApplyProfilePluginResult;\n try {\n expectedApply = await traceSpan(\"dry-run\", () =>\n applyProfilePlugin(activeProfile, {\n dryRun: true,\n harness: input.harness,\n conflictPolicy: \"replace\",\n pull: false,\n pinSkillEmits: false,\n mergeLiveSkillMarkdown: false,\n }),\n );\n traceCount(\"dry-run\", \"expected_files\", expectedApply.expected_files?.length ?? 0);\n } catch (error) {\n return driftCore({\n activeProfile,\n profileExists: true,\n applied: Boolean(latestSnapshot),\n snapshotId: latestSnapshot?.id ?? null,\n snapshotAt: latestSnapshot?.created_at ?? null,\n stackInSync: false,\n hasDrift: true,\n changes: [],\n warning: error instanceof Error ? error.message : String(error),\n projectPath: input.projectPath,\n pluginIds,\n }, input.harness, homeRoot);\n }\n\n const stackInSync = latestSnapshot\n ? pluginIdsMatch(latestSnapshot.plugin_ids, expectedApply.configured_plugin_ids)\n : false;\n\n const changes: DriftFileChange[] = [];\n const keptModified = new Set(expectedApply.removals?.owned_modified ?? []);\n const keptUnmanaged = new Set(expectedApply.removals?.unmanaged ?? []);\n const scopeByResource = resourceScopesForPlugins(pluginIds);\n const expectedPathsByResource = new Map<string, string[]>();\n for (const file of expectedApply.expected_files ?? []) {\n const mapped = resourceKeyFromManagedPath(file.path);\n if (!mapped) {\n continue;\n }\n const key = `${mapped.type}:${mapped.name}`;\n const paths = expectedPathsByResource.get(key) ?? [];\n paths.push(file.path);\n expectedPathsByResource.set(key, paths);\n }\n traceSpan(\"drift.compare-files\", () => {\n for (const file of expectedApply.expected_files ?? []) {\n if (isNativeAgentPluginCachePath(file.path)) continue;\n // Compared with HarnessTap's copy of the plugin below.\n if (isHostPluginViewPath(file.path)) continue;\n if (binaryExpectedFileMatchesDisk(join(homeRoot, file.path), file)) continue;\n const current = readGlobalFile(homeRoot, file.path);\n const owned = listMaterializationsForRootPath(homeRoot, file.path);\n if (current === null) {\n if (owned.length === 0 && isMissingExpectedFileTransparent(\n homeRoot,\n file.path,\n expectedPathsByResource,\n scopeByResource,\n expectedApply.harnesses,\n )) {\n continue;\n }\n changes.push(\n withAffectedResources({ path: file.path, type: \"deleted\" }, file.content, null),\n );\n continue;\n }\n if (owned.length > 0) {\n const diskHash = hashOnDiskFile(join(homeRoot, file.path));\n if (owned.some((row) => row.generated_hash === diskHash)) {\n continue;\n }\n if (fileContentsEquivalentForDrift(file.path, current, file.content)) {\n continue;\n }\n if (isHarnessTapClaudeMarketplaceFile(file.path)) {\n // Apply keeps a marketplace file HarnessTap wrote that changed since.\n changes.push({ path: file.path, type: \"modified\", removal_group: \"owned_modified\", changed_by: \"claude-code\" });\n continue;\n }\n changes.push(\n withAffectedResources(\n keptContentDiff(file.path, keptModified, keptUnmanaged),\n file.content,\n current,\n ),\n );\n continue;\n }\n if (!fileContentsEquivalentForDrift(file.path, current, file.content)) {\n changes.push(\n withAffectedResources(\n keptContentDiff(file.path, keptModified, keptUnmanaged),\n file.content,\n current,\n ),\n );\n }\n }\n });\n\n traceSpan(\"drift.host-plugin-folders\", () => {\n changes.push(...hostPluginFolderChanges(homeRoot, expectedApply.expected_files ?? [], changes));\n });\n changes.push(...claudeChangedMarketplaceEntries(homeRoot, expectedApply.expected_files ?? []));\n\n const applied = Boolean(latestSnapshot);\n const blockingChanges = changes.filter((change) => !driftChangeIsKept(change));\n const hasDrift = !applied || !stackInSync || blockingChanges.length > 0;\n\n return driftCore(\n {\n activeProfile,\n profileExists: true,\n applied,\n snapshotId: latestSnapshot?.id ?? null,\n snapshotAt: latestSnapshot?.created_at ?? null,\n stackInSync,\n hasDrift,\n changes,\n projectPath: input.projectPath,\n expectedApply,\n pluginIds,\n },\n input.harness,\n homeRoot,\n );\n}\n","import { getAllPlatforms } from \"../platforms/registry.js\";\nimport {\n resourceHarnessScope,\n type HarnessScope,\n} from \"./harness-scope.js\";\nimport { mergePluginsForApply } from \"./plugin-apply-merge.js\";\nimport { parseSkillEmitPath, skillConsumeDirs } from \"./shared-emit-paths.js\";\n\nconst consumeDirsByPlatform = new Map<string, ReadonlySet<string>>();\n\nfunction consumeDirsForPlatform(platformId: string): ReadonlySet<string> {\n const cached = consumeDirsByPlatform.get(platformId);\n if (cached) {\n return cached;\n }\n const dirs = new Set<string>([\n ...skillConsumeDirs(platformId, \"global\"),\n ...skillConsumeDirs(platformId, \"project\"),\n ]);\n consumeDirsByPlatform.set(platformId, dirs);\n return dirs;\n}\n\nfunction platformsConsumingSkillDir(skillsDir: string): string[] {\n const ids: string[] = [];\n for (const platform of getAllPlatforms()) {\n if (consumeDirsForPlatform(platform.id).has(skillsDir)) {\n ids.push(platform.id);\n }\n }\n return ids;\n}\n\nexport function resourceScopesForPlugins(\n pluginIds: readonly string[] | undefined,\n): Map<string, HarnessScope> {\n const map = new Map<string, HarnessScope>();\n if (!pluginIds || pluginIds.length === 0) {\n return map;\n }\n for (const resource of mergePluginsForApply([...pluginIds]).resources) {\n map.set(`${resource.type}:${resource.name}`, resourceHarnessScope(resource));\n }\n return map;\n}\n\n/**\n * A missing harness copy is transparent when another on-disk copy already\n * covers it. A subset scope is not covered by a sibling the new harness\n * cannot read (Codex does not read ~/.claude/skills).\n */\nexport function isTransparentCrossHarnessGap(input: {\n path: string;\n onDiskSiblingPaths: readonly string[];\n scope?: HarnessScope;\n}): boolean {\n if (input.onDiskSiblingPaths.length === 0) {\n return false;\n }\n if (!input.scope || input.scope.kind === \"all\") {\n return true;\n }\n const missingDir = parseSkillEmitPath(input.path)?.skillsDir;\n if (!missingDir) {\n return true;\n }\n const scoped = new Set(input.scope.harnesses);\n const consumers = platformsConsumingSkillDir(missingDir).filter((id) => scoped.has(id));\n if (consumers.length === 0) {\n return true;\n }\n return consumers.every((id) => {\n const dirs = consumeDirsForPlatform(id);\n return input.onDiskSiblingPaths.some((path) => {\n const dir = parseSkillEmitPath(path)?.skillsDir;\n return dir !== undefined && dirs.has(dir);\n });\n });\n}\n\n/**\n * On-disk copies of a missing skill file in another folder that a harness\n * reading the missing folder also reads. Apply places the skill on such a\n * live copy (for example ~/.agents/skills, which Cursor reads) instead of\n * writing the harness default, so status must not call the default missing.\n */\nexport function liveSkillCopiesForMissingPath(\n path: string,\n harnesses: readonly string[],\n exists: (relativePath: string) => boolean,\n): string[] {\n const parsed = parseSkillEmitPath(path);\n if (!parsed) {\n return [];\n }\n const active = new Set(harnesses);\n const dirs = new Set<string>();\n for (const id of platformsConsumingSkillDir(parsed.skillsDir)) {\n if (!active.has(id)) continue;\n for (const dir of consumeDirsForPlatform(id)) {\n if (dir !== parsed.skillsDir) dirs.add(dir);\n }\n }\n return [...dirs]\n .map((dir) => `${dir}${parsed.name}/${parsed.rest}`)\n .filter((candidate) => exists(candidate));\n}\n","/**\n * Line-oriented unified diff (git-style +/-) from live content to after-apply content.\n */\n\nexport type UnifiedDiffLineKind = \"meta\" | \"hunk\" | \"context\" | \"add\" | \"remove\";\n\nexport interface UnifiedDiffLine {\n kind: UnifiedDiffLineKind;\n text: string;\n}\n\ntype Op = { kind: \"equal\" | \"insert\" | \"delete\"; line: string };\n\nfunction splitLines(text: string): string[] {\n if (text.length === 0) {\n return [];\n }\n const parts = text.split(\"\\n\");\n if (text.endsWith(\"\\n\")) {\n return parts.slice(0, -1);\n }\n return parts;\n}\n\n/** Classic LCS → per-line equal/insert/delete ops. */\nfunction computeOps(oldLines: string[], newLines: string[]): Op[] {\n const m = oldLines.length;\n const n = newLines.length;\n const dp: number[][] = Array.from({ length: m + 1 }, () =>\n Array.from({ length: n + 1 }, () => 0),\n );\n\n for (let i = m - 1; i >= 0; i--) {\n for (let j = n - 1; j >= 0; j--) {\n if (oldLines[i] === newLines[j]) {\n dp[i]![j] = (dp[i + 1]![j + 1] ?? 0) + 1;\n } else {\n dp[i]![j] = Math.max(dp[i + 1]![j] ?? 0, dp[i]![j + 1] ?? 0);\n }\n }\n }\n\n const ops: Op[] = [];\n let i = 0;\n let j = 0;\n while (i < m && j < n) {\n if (oldLines[i] === newLines[j]) {\n ops.push({ kind: \"equal\", line: oldLines[i]! });\n i++;\n j++;\n } else if ((dp[i + 1]![j] ?? 0) >= (dp[i]![j + 1] ?? 0)) {\n ops.push({ kind: \"delete\", line: oldLines[i]! });\n i++;\n } else {\n ops.push({ kind: \"insert\", line: newLines[j]! });\n j++;\n }\n }\n while (i < m) {\n ops.push({ kind: \"delete\", line: oldLines[i]! });\n i++;\n }\n while (j < n) {\n ops.push({ kind: \"insert\", line: newLines[j]! });\n j++;\n }\n return ops;\n}\n\nfunction advanceLine(op: Op, oldLine: number, newLine: number): {\n oldLine: number;\n newLine: number;\n} {\n switch (op.kind) {\n case \"equal\":\n return { oldLine: oldLine + 1, newLine: newLine + 1 };\n case \"delete\":\n return { oldLine: oldLine + 1, newLine };\n case \"insert\":\n return { oldLine, newLine: newLine + 1 };\n default: {\n const _never: never = op.kind;\n return _never;\n }\n }\n}\n\n/**\n * Build unified-diff lines: live (from) → after-apply (to).\n */\nexport function buildUnifiedDiffLines(\n path: string,\n from: string,\n to: string,\n contextLines = 3,\n): UnifiedDiffLine[] {\n const ops = computeOps(splitLines(from), splitLines(to));\n if (ops.every((op) => op.kind === \"equal\")) {\n return [{ kind: \"meta\", text: \"(no content differences)\" }];\n }\n\n const result: UnifiedDiffLine[] = [\n { kind: \"meta\", text: `--- live/${path}` },\n { kind: \"meta\", text: `+++ after-apply/${path}` },\n ];\n\n // Include change ops plus ±contextLines of surrounding equal lines.\n const include = new Array<boolean>(ops.length).fill(false);\n for (let index = 0; index < ops.length; index++) {\n if (ops[index]!.kind === \"equal\") {\n continue;\n }\n include[index] = true;\n let before = 0;\n for (let k = index - 1; k >= 0 && before < contextLines; k--) {\n include[k] = true;\n if (ops[k]!.kind === \"equal\") {\n before++;\n }\n }\n let after = 0;\n for (let k = index + 1; k < ops.length && after < contextLines; k++) {\n include[k] = true;\n if (ops[k]!.kind === \"equal\") {\n after++;\n }\n }\n }\n\n let opIndex = 0;\n let oldLine = 1;\n let newLine = 1;\n\n while (opIndex < ops.length) {\n if (!include[opIndex]) {\n const advanced = advanceLine(ops[opIndex]!, oldLine, newLine);\n oldLine = advanced.oldLine;\n newLine = advanced.newLine;\n opIndex++;\n continue;\n }\n\n const hunkStart = opIndex;\n const hunkOldStart = oldLine;\n const hunkNewStart = newLine;\n while (opIndex < ops.length && include[opIndex]) {\n opIndex++;\n }\n const hunkEnd = opIndex;\n\n let oldCount = 0;\n let newCount = 0;\n const body: UnifiedDiffLine[] = [];\n for (let k = hunkStart; k < hunkEnd; k++) {\n const op = ops[k]!;\n switch (op.kind) {\n case \"equal\":\n body.push({ kind: \"context\", text: ` ${op.line}` });\n oldCount++;\n newCount++;\n break;\n case \"delete\":\n body.push({ kind: \"remove\", text: `-${op.line}` });\n oldCount++;\n break;\n case \"insert\":\n body.push({ kind: \"add\", text: `+${op.line}` });\n newCount++;\n break;\n default: {\n const _never: never = op.kind;\n return _never;\n }\n }\n const advanced = advanceLine(op, oldLine, newLine);\n oldLine = advanced.oldLine;\n newLine = advanced.newLine;\n }\n\n result.push({\n kind: \"hunk\",\n text: `@@ -${hunkOldStart},${oldCount} +${hunkNewStart},${newCount} @@`,\n });\n result.push(...body);\n }\n\n return result;\n}\n\n/** True when FileDiff would show a non-empty live → after-apply body. */\nexport function fileDiffHasContentChange(\n path: string,\n current: string,\n expected: string,\n): boolean {\n const { added, removed } = countUnifiedDiffChanges(\n buildUnifiedDiffLines(path, current, expected),\n );\n return added > 0 || removed > 0;\n}\n\nexport function countUnifiedDiffChanges(lines: UnifiedDiffLine[]): {\n added: number;\n removed: number;\n} {\n let added = 0;\n let removed = 0;\n for (const line of lines) {\n switch (line.kind) {\n case \"add\":\n added++;\n break;\n case \"remove\":\n removed++;\n break;\n case \"meta\":\n case \"hunk\":\n case \"context\":\n break;\n default: {\n const _never: never = line.kind;\n return _never;\n }\n }\n }\n return { added, removed };\n}\n","import type { HookMetadata, PermissionMetadata } from \"../types.js\";\nimport { parseHooksJsonContent } from \"./hook-serialization.js\";\n\nconst PERMISSION_ACTIONS = [\"allow\", \"deny\", \"ask\"] as const satisfies ReadonlyArray<\n PermissionMetadata[\"action\"]\n>;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction formatJsonFragment(value: unknown): string {\n return `${JSON.stringify(value, null, 2)}\\n`;\n}\n\nfunction parseJsonObject(content: string): Record<string, unknown> | null {\n try {\n const parsed: unknown = JSON.parse(content);\n return isRecord(parsed) ? parsed : null;\n } catch {\n return null;\n }\n}\n\nconst PERMISSION_RESOURCE_TYPES = [\"permission\", \"hook\", \"env_var\"] as const;\n\n/** Permission, hook, and env var identities present in a shared settings file. */\nexport function hostConfigResourcesFromContent(\n content: string,\n): Array<{ type: (typeof PERMISSION_RESOURCE_TYPES)[number]; name: string }> {\n const resources: Array<{\n type: (typeof PERMISSION_RESOURCE_TYPES)[number];\n name: string;\n }> = [];\n const seen = new Set<string>();\n const add = (\n type: (typeof PERMISSION_RESOURCE_TYPES)[number],\n name: string,\n ) => {\n const trimmed = name.trim();\n if (!trimmed) {\n return;\n }\n const key = `${type}:${trimmed}`;\n if (seen.has(key)) {\n return;\n }\n seen.add(key);\n resources.push({ type, name: trimmed });\n };\n\n const document = parseJsonObject(content);\n if (document && isRecord(document.permissions)) {\n for (const action of PERMISSION_ACTIONS) {\n const list = document.permissions[action];\n if (!Array.isArray(list)) {\n continue;\n }\n for (const pattern of list) {\n if (typeof pattern === \"string\" && pattern.trim()) {\n add(\"permission\", `${action}-${pattern}`);\n }\n }\n }\n }\n for (const hook of hookResourcesFromContent(content)) {\n add(\"hook\", hook.name);\n }\n if (document && isRecord(document.env)) {\n for (const name of Object.keys(document.env)) {\n add(\"env_var\", name);\n }\n }\n return resources;\n}\n\nexport function parsePermissionResourceName(\n name: string,\n): Pick<PermissionMetadata, \"action\" | \"pattern\"> | null {\n const trimmed = name.trim();\n for (const action of PERMISSION_ACTIONS) {\n const prefix = `${action}-`;\n if (trimmed.startsWith(prefix) && trimmed.length > prefix.length) {\n return { action, pattern: trimmed.slice(prefix.length) };\n }\n }\n return null;\n}\n\nfunction permissionPatternPresent(\n permissions: unknown,\n action: PermissionMetadata[\"action\"],\n pattern: string,\n): boolean {\n if (!isRecord(permissions)) {\n return false;\n }\n const list = permissions[action];\n return Array.isArray(list) && list.some((item) => item === pattern);\n}\n\nfunction hookResourcesFromContent(content: string) {\n const direct = parseHooksJsonContent(content, \"\");\n if (direct.length > 0) {\n return direct;\n }\n const document = parseJsonObject(content);\n if (!document) {\n return [];\n }\n return parseHooksJsonContent(JSON.stringify({ hooks: document }), \"\");\n}\n\nfunction scopeToPermission(content: string, name: string): string {\n const parsed = parsePermissionResourceName(name);\n if (!parsed) {\n return content;\n }\n const document = parseJsonObject(content);\n if (!document) {\n return content;\n }\n if (permissionPatternPresent(document.permissions, parsed.action, parsed.pattern)) {\n return formatJsonFragment({\n permissions: { [parsed.action]: [parsed.pattern] },\n });\n }\n return formatJsonFragment({ permissions: {} });\n}\n\nfunction scopeToHook(content: string, name: string): string {\n if (!parseJsonObject(content)) {\n return content;\n }\n const needle = name.trim().toLowerCase();\n const match = hookResourcesFromContent(content).find(\n (resource) => resource.name.toLowerCase() === needle,\n );\n if (!match) {\n return formatJsonFragment({ hooks: {} });\n }\n const metadata = match.metadata as HookMetadata;\n const entry = metadata.hook_entry ?? { command: match.content };\n return formatJsonFragment({\n hooks: { [metadata.event]: [entry] },\n });\n}\n\nfunction scopeToEnvVar(content: string, name: string): string {\n const document = parseJsonObject(content);\n if (!document) {\n return content;\n }\n if (!isRecord(document.env) || !Object.hasOwn(document.env, name)) {\n return formatJsonFragment({ env: {} });\n }\n return formatJsonFragment({ env: { [name]: document.env[name] } });\n}\n\n/**\n * Restrict a shared host settings payload to one permission, hook, or env var\n * so live→after-apply diffs do not include sibling keys in the same file.\n */\nexport function scopeHostConfigToResource(\n content: string | null,\n resource: { type: string; name: string },\n): string | null {\n if (content === null) {\n return null;\n }\n const name = resource.name.trim();\n if (!name) {\n return content;\n }\n switch (resource.type) {\n case \"permission\":\n return scopeToPermission(content, name);\n case \"hook\":\n return scopeToHook(content, name);\n case \"env_var\":\n return scopeToEnvVar(content, name);\n default:\n return content;\n }\n}\n","import type { Resource, ResourceMetadata } from \"../types.js\";\nimport {\n emitCursorMcpServerEntry,\n parseMcpServerEntry,\n} from \"./mcp-config-bridge.js\";\nimport { readResourceContentFromPathHint } from \"./resource-editor-path.js\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\ntype McpServersWrapperKey = \"mcpServers\" | \"mcp_servers\" | \"mcp\";\n\nconst MCP_SERVERS_WRAPPER_KEYS = [\n \"mcpServers\",\n \"mcp_servers\",\n \"mcp\",\n] as const satisfies readonly McpServersWrapperKey[];\n\nfunction mcpServersWrapperKey(\n document: Record<string, unknown>,\n): McpServersWrapperKey | null {\n for (const key of MCP_SERVERS_WRAPPER_KEYS) {\n if (isRecord(document[key])) {\n return key;\n }\n }\n return null;\n}\n\n/** Server keys in an aggregate MCP JSON config (`mcpServers` / `mcp_servers` / `mcp`). */\nexport function mcpServerNamesFromConfig(content: string): string[] {\n try {\n const document = JSON.parse(content) as unknown;\n const servers = mcpServersRecord(document);\n return servers ? Object.keys(servers) : [];\n } catch {\n return [];\n }\n}\n\nfunction mcpServersRecord(document: unknown): Record<string, unknown> | null {\n if (!isRecord(document)) {\n return null;\n }\n const key = mcpServersWrapperKey(document);\n if (!key) {\n return null;\n }\n const serversRaw = document[key];\n return isRecord(serversRaw) ? serversRaw : null;\n}\n\nfunction formatMcpServersFragment(\n wrapper: McpServersWrapperKey,\n servers: Record<string, unknown>,\n): string {\n return `${JSON.stringify({ [wrapper]: servers }, null, 2)}\\n`;\n}\n\n/**\n * Restrict an MCP config payload to one server key so live→after-apply diffs\n * do not include sibling servers in the same file.\n */\nexport function scopeMcpConfigToServer(\n content: string | null,\n serverName: string,\n): string | null {\n if (content === null) {\n return null;\n }\n const name = serverName.trim();\n if (!name) {\n return content;\n }\n try {\n const document = JSON.parse(content) as unknown;\n if (!isRecord(document)) {\n return content;\n }\n const wrapper = mcpServersWrapperKey(document);\n if (!wrapper) {\n return content;\n }\n const servers = document[wrapper];\n if (!isRecord(servers)) {\n return content;\n }\n const scoped = Object.hasOwn(servers, name)\n ? { [name]: servers[name] }\n : {};\n return formatMcpServersFragment(wrapper, scoped);\n } catch {\n return content;\n }\n}\n\n/** Pretty-print one server entry as an `mcpServers` document fragment. */\nexport function formatMcpServerConfig(name: string, entry: unknown): string {\n return `${JSON.stringify({ mcpServers: { [name]: entry } }, null, 2)}\\n`;\n}\n\nexport function extractMcpServerConfigFromFile(\n fileContent: string,\n name: string,\n): string | null {\n try {\n const document = JSON.parse(fileContent) as unknown;\n const servers = mcpServersRecord(document);\n if (!servers || !Object.hasOwn(servers, name)) {\n return null;\n }\n return formatMcpServerConfig(name, servers[name]);\n } catch {\n return null;\n }\n}\n\nfunction formatMcpServerFromMetadata(\n name: string,\n metadata: ResourceMetadata,\n): string | null {\n const parsed = parseMcpServerEntry(metadata);\n if (!parsed) {\n return null;\n }\n const entry = emitCursorMcpServerEntry(parsed);\n if (Object.keys(entry).length === 0) {\n return null;\n }\n return formatMcpServerConfig(name, entry);\n}\n\nexport function overlayMcpServerDetail(\n resource: Pick<\n Resource,\n \"type\" | \"name\" | \"source\" | \"origin_ref\" | \"content\" | \"metadata\" | \"updated_at\"\n >,\n pathHint?: string | null,\n): { content: string; updatedAt: string } {\n if (resource.type !== \"mcp_server\") {\n return { content: resource.content, updatedAt: resource.updated_at };\n }\n\n const candidates = [pathHint, resource.source, resource.origin_ref];\n for (const candidate of candidates) {\n const trimmed = candidate?.trim();\n if (!trimmed || trimmed === \"manual\") {\n continue;\n }\n try {\n const onDisk = readResourceContentFromPathHint(trimmed);\n const extracted = extractMcpServerConfigFromFile(onDisk.content, resource.name);\n if (extracted) {\n return { content: extracted, updatedAt: onDisk.updatedAt };\n }\n } catch {\n // try the next path candidate\n }\n }\n\n const fromMetadata = formatMcpServerFromMetadata(\n resource.name,\n resource.metadata,\n );\n if (fromMetadata) {\n return { content: fromMetadata, updatedAt: resource.updated_at };\n }\n\n return { content: resource.content, updatedAt: resource.updated_at };\n}\n","import { fileDiffHasContentChange } from \"../utils/unified-diff.js\";\nimport {\n hostConfigResourcesFromContent,\n scopeHostConfigToResource,\n} from \"./host-config-resource-detail.js\";\nimport {\n mcpServerNamesFromConfig,\n scopeMcpConfigToServer,\n} from \"./mcp-resource-detail.js\";\nimport {\n isClaudeSettingsPath,\n isClaudeUserJsonPath,\n isMuseSettingsPath,\n} from \"./merged-host-config.js\";\nimport {\n isMcpConfigManagedPath,\n resourceKeyFromManagedPath,\n} from \"./profile-commit-resource.js\";\nimport type { DriftFileChange } from \"./project-drift.js\";\n\nexport interface ManagedFileResourceIdentity {\n type: string;\n name: string;\n}\n\nfunction resourceKey(resource: ManagedFileResourceIdentity): string {\n return `${resource.type}:${resource.name}`;\n}\n\nfunction collectIdentities(\n path: string,\n contents: Array<string | null>,\n): ManagedFileResourceIdentity[] {\n const order: ManagedFileResourceIdentity[] = [];\n const seen = new Set<string>();\n const add = (resource: ManagedFileResourceIdentity) => {\n const key = resourceKey(resource);\n if (seen.has(key)) {\n return;\n }\n seen.add(key);\n order.push(resource);\n };\n\n const mapped = resourceKeyFromManagedPath(path);\n if (mapped) {\n add(mapped);\n }\n\n const inspectMcp =\n isMcpConfigManagedPath(path) || isClaudeUserJsonPath(path);\n const inspectHost = isClaudeSettingsPath(path) || isMuseSettingsPath(path);\n\n for (const content of contents) {\n if (!content) {\n continue;\n }\n if (inspectMcp) {\n for (const name of mcpServerNamesFromConfig(content)) {\n add({ type: \"mcp_server\", name });\n }\n }\n if (inspectHost) {\n for (const resource of hostConfigResourcesFromContent(content)) {\n add(resource);\n }\n }\n }\n return order;\n}\n\nfunction scopedBodies(\n expected: string,\n current: string | null,\n resource: ManagedFileResourceIdentity,\n): { expected: string; current: string | null } {\n if (resource.type === \"mcp_server\") {\n return {\n expected: scopeMcpConfigToServer(expected, resource.name) ?? expected,\n current: scopeMcpConfigToServer(current, resource.name),\n };\n }\n if (\n resource.type === \"permission\"\n || resource.type === \"hook\"\n || resource.type === \"env_var\"\n ) {\n return {\n expected: scopeHostConfigToResource(expected, resource) ?? expected,\n current: scopeHostConfigToResource(current, resource),\n };\n }\n return { expected, current };\n}\n\nfunction scopedContentsDiffer(\n path: string,\n expected: string,\n current: string | null,\n resource: ManagedFileResourceIdentity,\n): boolean {\n const scoped = scopedBodies(expected, current, resource);\n if (scoped.current === null) {\n return true;\n }\n return fileDiffHasContentChange(path, scoped.current, scoped.expected);\n}\n\n/** Resource identities in a shared config whose scoped live vs expected content differs. */\nexport function affectedResourcesForManagedFileDiff(input: {\n path: string;\n expected: string;\n current: string | null;\n}): ManagedFileResourceIdentity[] {\n const identities = collectIdentities(input.path, [input.expected, input.current]);\n const affected = identities.filter((resource) =>\n scopedContentsDiffer(input.path, input.expected, input.current, resource),\n );\n return affected.sort((left, right) => {\n const typeOrder = left.type.localeCompare(right.type);\n return typeOrder !== 0 ? typeOrder : left.name.localeCompare(right.name);\n });\n}\n\nexport function withAffectedResources(\n change: DriftFileChange,\n expected: string,\n current: string | null,\n): DriftFileChange {\n const affected_resources = affectedResourcesForManagedFileDiff({\n path: change.path,\n expected,\n current,\n });\n return { ...change, affected_resources };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,QAAAA,aAAY;AACrB,SAAS,kBAAkB;;;ACC3B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B,YAAY,IAAI,IAAI,cAAc;AACtE,kBAAY,YAAY;AAAA,QACtB,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,GAAI,qBAAqB,EAAE,OAAO,EAAE,WAAW,QAAQ,OAAO,KAAK,OAAO,EAAE,IAAI,CAAC;AAAA,QACjF;AAAA,QACA,cAAc,OAAO;AAAA,QACrB,YAAY,UAAU;AAAA,MACxB,CAAC;AAED,YAAM,UAAU,iBAAiB,UAAU,OAAO,UAAU,WAAW,gBAAgB,CAAC;AACxF,kBAAY,YAAY,EAAE,IAAI,gBAAgB,QAAQ,CAAC;AAAA,IACzD,SAAS,OAAO;AACd,kBAAY,YAAY;AAAA,QACtB,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,OAAO,2BAA2B,KAAK;AAAA,MACzC,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACD,UAAQ,IAAI,KAAK,MAAM,QAAW,MAAM,MAAS;AACnD,CAAC;","names":["join","i","j","isRecord","latestSnapshot","expectedApply","stackInSync","applied","hasDrift","join"]}
@@ -5,8 +5,8 @@ import {
5
5
  isReleaseBuild,
6
6
  readGitSha,
7
7
  resolveBuildVersion
8
- } from "./chunk-UNRR4KH5.js";
9
- import "./chunk-2H7UOFLK.js";
8
+ } from "./chunk-WQ3F4O7U.js";
9
+ import "./chunk-MKLJBW5N.js";
10
10
  export {
11
11
  PACKAGE_VERSION,
12
12
  formatDevBuildVersion,
@@ -14,4 +14,4 @@ export {
14
14
  readGitSha,
15
15
  resolveBuildVersion
16
16
  };
17
- //# sourceMappingURL=version-FUHV4O6U.js.map
17
+ //# sourceMappingURL=version-QUJZGTZ5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "harnesstap",
3
- "version": "1.3.2",
3
+ "version": "1.6.0",
4
4
  "description": "Agent harness configuration toolkit for Claude Code, Codex, Cursor, and other coding CLIs",
5
5
  "type": "module",
6
6
  "packageManager": "bun@1.3.9",
@@ -40,25 +40,28 @@
40
40
  "unlink": "bun unlink",
41
41
  "test": "bun test --timeout 30000",
42
42
  "test:run": "bun test --dots --timeout 30000",
43
- "test:core": "bun test --dots test/models test/db test/config test/utils test/telemetry test/scripts",
44
- "test:platforms": "bun test --dots test/platforms",
45
- "test:plugins": "bun test --dots test/plugins",
46
- "test:services": "bun test --dots test/services test/integration test/agent/init-apply-noop.test.ts",
47
- "test:cli": "bun test --dots test/cli test/ui test/helpers",
48
- "test:docs": "bun test --dots test/docs",
43
+ "test:core": "bun test --dots --timeout 30000 test/models test/db test/config test/utils test/telemetry test/scripts",
44
+ "test:platforms": "bun test --dots --timeout 30000 test/platforms",
45
+ "test:plugins": "bun test --dots --timeout 30000 test/plugins",
46
+ "test:services": "bun test --dots --timeout 30000 test/services test/integration",
47
+ "test:cli": "bun test --dots --timeout 30000 test/cli test/ui test/helpers",
48
+ "test:agent": "bun test --dots --timeout 30000 test/agent",
49
+ "test:desktop": "bun test --dots --timeout 30000 test/desktop",
50
+ "test:docs": "bun test --dots --timeout 30000 test/docs",
49
51
  "lint": "biome lint .",
50
52
  "lint:fix": "biome lint --write --unsafe .",
51
53
  "lint:css": "bun scripts/check-css-tokens.ts",
52
54
  "check:cli-error-contract": "bun scripts/check-cli-error-contract.ts",
53
55
  "check:copy": "bun scripts/check-copy.ts",
54
- "check:agent-plugins-spec": "bun test test/services/agent-plugins/spec-schema-guard.test.ts test/services/agent-plugins/spec-mcp.test.ts",
56
+ "check:agent-plugins-spec": "bun test --timeout 30000 test/services/agent-plugins/spec-schema-guard.test.ts test/services/agent-plugins/spec-mcp.test.ts test/services/agent-plugins/spec-load.test.ts",
55
57
  "typecheck": "tsc --noEmit",
56
58
  "clean": "rm -rf dist && find . -maxdepth 1 -name '*.bun-build' -delete",
57
59
  "preflight": "bun run lint && bun run lint:css && bun run check:cli-error-contract && bun run check:copy && bun run typecheck && bun run test:run && bun run build",
58
- "prepublishOnly": "bun run build",
60
+ "prepublishOnly": "HT_RELEASE=1 bun run build",
61
+ "check:release-version": "bash scripts/check-release-version.sh",
59
62
  "docs:vhs": "bash scripts/generate-vhs-scenarios.sh",
60
63
  "check:scenario-docs": "bash scripts/check-scenario-docs.sh",
61
- "check:scenario-smoke": "bun test test/cli/scenario-smoke.test.ts",
64
+ "check:scenario-smoke": "bun test --timeout 30000 test/cli/scenario-smoke.test.ts",
62
65
  "check:sqlite-wal-smoke": "bun scripts/sqlite-wal-write-smoke.ts",
63
66
  "sync:cloud-docs": "bash scripts/sync-cloud-cli-docs.sh"
64
67
  },
@@ -88,7 +91,6 @@
88
91
  "dependencies": {
89
92
  "@inquirer/core": "^10.3.2",
90
93
  "@inquirer/search": "^3.2.2",
91
- "better-sqlite3": "^12.11.1",
92
94
  "chalk": "^5.4.1",
93
95
  "cli-table3": "^0.6.5",
94
96
  "commander": "^13.1.0",
@@ -102,6 +104,9 @@
102
104
  "ulid": "^2.3.0",
103
105
  "yaml": "^2.7.0"
104
106
  },
107
+ "optionalDependencies": {
108
+ "better-sqlite3": "^12.11.1"
109
+ },
105
110
  "devDependencies": {
106
111
  "@biomejs/biome": "^2.4.10",
107
112
  "@inquirer/testing": "^3.3.8",
@@ -109,6 +114,7 @@
109
114
  "@types/node": "^22.10.0",
110
115
  "@types/semver": "^7.7.1",
111
116
  "ajv": "^8.20.0",
117
+ "happy-dom": "17.4.4",
112
118
  "tsup": "^8.3.5",
113
119
  "typescript": "^5.7.0"
114
120
  }
@@ -1,67 +0,0 @@
1
- import {
2
- handleApplyCommand,
3
- handleInstallCommand,
4
- registerApplyCommand,
5
- registerInstallCommand
6
- } from "./chunk-R4PTE774.js";
7
- import "./chunk-6JMVGKMD.js";
8
- import "./chunk-64R32MG2.js";
9
- import "./chunk-OQ4KBUN2.js";
10
- import "./chunk-CZ4T75PP.js";
11
- import "./chunk-XRXFJTAT.js";
12
- import "./chunk-PJQAMC6L.js";
13
- import "./chunk-UEHDEADL.js";
14
- import "./chunk-3JOPDYQD.js";
15
- import "./chunk-AVZOFMJX.js";
16
- import "./chunk-FUV7QYBS.js";
17
- import "./chunk-WXRPQICX.js";
18
- import "./chunk-VZQG2JDV.js";
19
- import "./chunk-FBYAIBHP.js";
20
- import "./chunk-XCPWLGPB.js";
21
- import "./chunk-3EGM4IUI.js";
22
- import "./chunk-KRI4R7EM.js";
23
- import "./chunk-U472S6IB.js";
24
- import "./chunk-YX7MVSDA.js";
25
- import "./chunk-IHW4PCDT.js";
26
- import "./chunk-BXSS2S4W.js";
27
- import "./chunk-XGTTOO4R.js";
28
- import "./chunk-37E5M4JX.js";
29
- import "./chunk-JQOKQKQT.js";
30
- import "./chunk-3FIWOI3H.js";
31
- import "./chunk-CHQGE2HF.js";
32
- import "./chunk-YVJQ2QDG.js";
33
- import "./chunk-6ZWKF3YZ.js";
34
- import "./chunk-HWL67OCJ.js";
35
- import "./chunk-NAGAJ5UM.js";
36
- import "./chunk-QNAIDM6W.js";
37
- import "./chunk-NEPUP33Q.js";
38
- import "./chunk-555XE3NJ.js";
39
- import "./chunk-ENHDEB7Z.js";
40
- import "./chunk-HENOKIBB.js";
41
- import "./chunk-I6XFZLTJ.js";
42
- import "./chunk-S2E4KSYW.js";
43
- import "./chunk-JRFUTIEH.js";
44
- import "./chunk-AUWWL6KX.js";
45
- import "./chunk-ZTBAMBAI.js";
46
- import "./chunk-YRGM7RAD.js";
47
- import "./chunk-PW5QXRBA.js";
48
- import "./chunk-MHOTXMD2.js";
49
- import "./chunk-ZGRBIBO7.js";
50
- import "./chunk-KJIFZLHN.js";
51
- import "./chunk-ZVANUFPF.js";
52
- import "./chunk-OPVIX7E4.js";
53
- import "./chunk-OXVCYRZB.js";
54
- import "./chunk-JJJJ2RAD.js";
55
- import "./chunk-TQ2NA4Z4.js";
56
- import "./chunk-Y2JGMICO.js";
57
- import "./chunk-LDVXYN6F.js";
58
- import "./chunk-IKAGGJEO.js";
59
- import "./chunk-VQVUJYYY.js";
60
- import "./chunk-24V5ZSIF.js";
61
- export {
62
- handleApplyCommand,
63
- handleInstallCommand,
64
- registerApplyCommand,
65
- registerInstallCommand
66
- };
67
- //# sourceMappingURL=apply-Q5SFF3FY.js.map