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
@@ -1,101 +1,128 @@
1
1
  import {
2
- buildHarnessLiveStatusMap,
3
- classifyGlobalDriftChanges,
4
- collectOwnedGlobalProfileFiles,
5
- computeGlobalProfilePanelStatus,
6
- countMissingHarnessRows,
7
- declaredMcpFromExpectedFiles,
8
- resolveProjectDriftSummary,
2
+ isTransparentCrossHarnessGap,
3
+ liveSkillCopiesForMissingPath,
4
+ resourceScopesForPlugins,
9
5
  withAffectedResources
10
- } from "./chunk-FUV7QYBS.js";
6
+ } from "./chunk-R6VFJKZB.js";
11
7
  import {
12
8
  formatEnvironmentToml,
13
9
  importEnvironmentToml
14
- } from "./chunk-WXRPQICX.js";
10
+ } from "./chunk-UK2IV2ZQ.js";
15
11
  import {
16
12
  MISSING_PROJECT_CONFIG_MESSAGE
17
13
  } from "./chunk-VZQG2JDV.js";
18
14
  import {
15
+ ON_CONFLICT_VALUE_HELP,
16
+ parseOnConflict
17
+ } from "./chunk-WGVU3LA5.js";
18
+ import {
19
+ CLAUDE_KNOWN_MARKETPLACES_PATH,
20
+ HARNESSTAP_CLAUDE_MARKETPLACES_ROOT,
21
+ addResourceToPlugin,
19
22
  applyProfilePlugin,
23
+ binaryExpectedFileMatchesDisk,
20
24
  buildContentsFromResources,
25
+ buildHarnessLiveStatusMap,
21
26
  buildHostManagedStatus,
22
27
  buildProfileContents,
23
28
  captureUntrackedResourcesForStash,
29
+ classifyGlobalDriftChanges,
30
+ claudeChangedMarketplaces,
24
31
  clearActiveProfileName,
25
32
  clearGlobalProfileApply,
33
+ collectOwnedGlobalProfileFiles,
26
34
  collectProfilePluginIds,
27
35
  commitManagedPathFromLive,
36
+ computeGlobalProfilePanelStatus,
37
+ countMissingHarnessRows,
38
+ createPlugin,
39
+ declaredMcpFromExpectedFiles,
28
40
  detectNotStagedProfileResources,
41
+ diffHostPluginView,
42
+ driftChangeIsKept,
43
+ emittedHostPluginTree,
29
44
  fileContentsEquivalentForDrift,
45
+ filesOnlyMarketplacePinRefs,
46
+ findProjectConfig,
30
47
  flattenLiveRestoreFiles,
31
48
  getActiveProfileName,
32
49
  getGlobalActiveEnvironmentName,
33
50
  getLatestGlobalApplySnapshotForProfile,
51
+ getProfileEntry,
52
+ harnessTapClaudeMarketplaceManifestPath,
34
53
  hashOnDiskFile,
54
+ hostPluginPackageDir,
35
55
  installPluginFromCatalog,
56
+ isClaudePluginRegistryPath,
57
+ isEmptyBuiltinProfile,
58
+ isNativeAgentPluginCachePath,
59
+ isProfilePlugin,
36
60
  listMaterializationsForRootPath,
61
+ listMissingHarnessRows,
37
62
  mergePluginsForApply,
63
+ normalizeResourceInput,
38
64
  profileSkillNameMap,
65
+ readDiskTextOnce,
66
+ readUpstreamCheckSummary,
39
67
  removeUntrackedStashFiles,
68
+ resolvePluginSelector,
69
+ resolveProfileEnvironment,
70
+ resolveProjectDriftSummary,
71
+ resourceKeyFromManagedPath,
40
72
  restoreUntrackedStashFiles,
41
73
  stashedFilesToDriftChanges,
74
+ unreadNotificationCount,
75
+ upsertResource,
42
76
  useEnvironmentCommand,
43
77
  useProfileCommand,
44
- withProfileApplyLock
45
- } from "./chunk-6ZWKF3YZ.js";
78
+ withProfileApplyLock,
79
+ withStatusReadCache
80
+ } from "./chunk-BUA7WFI4.js";
46
81
  import {
82
+ inStatusComputation,
47
83
  promptForChoice,
48
84
  promptForConfirmation,
49
85
  promptForSearchableChoice,
86
+ resolveHomeRoot,
87
+ runInStatusComputation,
50
88
  shouldUseBrowsePicker,
51
89
  shouldUseWizard
52
- } from "./chunk-NAGAJ5UM.js";
53
- import {
54
- isEmptyBuiltinProfile,
55
- isProfilePlugin
56
- } from "./chunk-NEPUP33Q.js";
57
- import {
58
- findProjectConfig,
59
- getProfileEntry,
60
- resolveProfileEnvironment
61
- } from "./chunk-HENOKIBB.js";
62
- import {
63
- addResourceToPlugin,
64
- createPlugin,
65
- normalizeResourceInput,
66
- resolveHomeRoot,
67
- resolvePluginSelector,
68
- upsertResource
69
- } from "./chunk-KJIFZLHN.js";
70
- import {
71
- ON_CONFLICT_VALUE_HELP,
72
- parseOnConflict
73
- } from "./chunk-Y2JGMICO.js";
74
- import {
75
- ui
76
- } from "./chunk-LDVXYN6F.js";
90
+ } from "./chunk-UC27MQ3T.js";
77
91
  import {
78
92
  parsePluginSelector,
79
93
  resolveRemotePluginSelector
80
- } from "./chunk-IKAGGJEO.js";
94
+ } from "./chunk-V4UNYSZO.js";
81
95
  import {
82
96
  CLI_COPY,
97
+ CLI_HINTS,
83
98
  SWITCH_CHANGES_VALUES,
99
+ allKeptHostPluginViewPaths,
100
+ applyCancelledMessage,
84
101
  applyHeaderLine,
85
102
  applyWroteLine,
86
103
  discardConfirm,
87
104
  discardedChangesLine,
88
105
  dryRunSectionHeader,
89
106
  dryRunWouldLine,
107
+ forceRemoveHintLine,
90
108
  getHarnesstapDir,
109
+ harnesstapDirForHomeRoot,
110
+ hostPluginViewChangeCounts,
111
+ hostPluginViewForceReplace,
91
112
  keptFilesHeader,
92
113
  keptReasonLabel,
114
+ keptReportedBeforeLine,
115
+ onConflictReplaceHint,
116
+ pendingKeptHostPluginViewPaths,
93
117
  savedChangesLine,
94
118
  snapshotSavedUndoLine,
95
119
  stashedChangesLine,
120
+ traceCount,
121
+ traceSpan,
122
+ ui,
96
123
  unsavedChangesFlagHint,
97
124
  unsavedChangesLine
98
- } from "./chunk-24V5ZSIF.js";
125
+ } from "./chunk-OHZNDV4A.js";
99
126
 
100
127
  // src/utils/user-path.ts
101
128
  import { existsSync } from "fs";
@@ -139,6 +166,12 @@ function resolveApplyConflictPolicy(opts) {
139
166
  }
140
167
  return "prompt";
141
168
  }
169
+ function reportApplyCancelled(conflicts, scope = "apply") {
170
+ process.exitCode = 1;
171
+ ui.warn(applyCancelledMessage(conflicts, scope), {
172
+ hint: onConflictReplaceHint(conflicts)
173
+ });
174
+ }
142
175
  async function promptMaterializationConflict(conflict) {
143
176
  const ownerSummary = conflict.owners.length > 0 ? conflict.owners.map((owner) => `${owner.plugin_name}@${owner.plugin_version ?? "?"}`).join(", ") : "another plugin or manual edit";
144
177
  ui.warn(`File already exists: ${conflict.path}`);
@@ -157,7 +190,10 @@ async function promptMaterializationConflict(conflict) {
157
190
  function keptFromSkippedRemovals(skipped) {
158
191
  return (skipped ?? []).flatMap((entry) => {
159
192
  const reason = removalSkipReason(entry.reason);
160
- return reason ? [{ path: entry.path, reason }] : [];
193
+ if (!reason) return [];
194
+ return [
195
+ entry.forceable === false ? { path: entry.path, reason, forceable: false } : { path: entry.path, reason }
196
+ ];
161
197
  });
162
198
  }
163
199
  function printApplyPayload(payload) {
@@ -181,17 +217,18 @@ function printApplyPayload(payload) {
181
217
  snapshotId: payload.snapshot_id
182
218
  });
183
219
  }
220
+ const listedKept = kept.length > 0;
184
221
  for (const skipped of payload.skipped_removals ?? []) {
185
222
  if (skipped.reason === "missing") {
186
223
  continue;
187
224
  }
225
+ if (listedKept && removalSkipReason(skipped.reason)) {
226
+ continue;
227
+ }
188
228
  if (skipped.message) {
189
229
  ui.warn(skipped.message);
190
230
  }
191
231
  }
192
- if (!payload.dry_run && payload.removal_backup && (payload.removed_files?.length ?? 0) > 0) {
193
- ui.info(`Backup: ${payload.removal_backup}`);
194
- }
195
232
  }
196
233
  function printApplyDryRun(input) {
197
234
  if (input.header !== false) {
@@ -213,7 +250,7 @@ function printApplyDryRun(input) {
213
250
  if (input.wouldKeep.length > 0) {
214
251
  console.log(dryRunSectionHeader("keep", input.wouldKeep.length));
215
252
  for (const entry of input.wouldKeep) {
216
- console.log(` ${entry.path} ${keptReasonLabel(entry.reason)}`);
253
+ console.log(` ${entry.path} ${keptReasonLabel(entry.reason, entry.path)}`);
217
254
  }
218
255
  }
219
256
  console.log("");
@@ -232,22 +269,39 @@ function printKeptFiles(kept) {
232
269
  }
233
270
  console.log(keptFilesHeader(kept.length));
234
271
  for (const entry of kept) {
235
- console.log(` ${entry.path} ${keptReasonLabel(entry.reason)}`);
272
+ console.log(` ${entry.path} ${keptReasonLabel(entry.reason, entry.path)}`);
236
273
  }
237
- console.log(`${CLI_COPY.forceRemoveHint} ht apply --force-remove`);
274
+ if (kept.every((entry) => isClaudePluginRegistryPath(entry.path))) {
275
+ return;
276
+ }
277
+ const forceable = kept.filter(
278
+ (entry) => entry.forceable !== false && !isClaudePluginRegistryPath(entry.path)
279
+ );
280
+ console.log(
281
+ hostPluginViewForceReplace() || forceable.length === 0 ? CLI_HINTS.forceRemoveAlreadyUsed : forceRemoveHintLine(forceable.length)
282
+ );
238
283
  }
239
284
  function printApplySuccess(input) {
240
285
  console.log(applyHeaderLine(input.name, input.harnessCount));
286
+ const pluginFolder = hostPluginViewChangeCounts();
287
+ const folderKept = new Set(pendingKeptHostPluginViewPaths());
288
+ const kept = input.kept.filter((entry) => !folderKept.has(entry.path));
289
+ const listedPaths = /* @__PURE__ */ new Set([...folderKept, ...kept.map((entry) => entry.path)]);
290
+ const reportedBefore = allKeptHostPluginViewPaths().filter((path) => !listedPaths.has(path));
291
+ const keptTotal = listedPaths.size + new Set(reportedBefore).size;
241
292
  console.log(
242
293
  applyWroteLine({
243
- wrote: input.wrote,
244
- removed: input.removed,
245
- kept: input.kept.length,
294
+ wrote: input.wrote + pluginFolder.replaced + pluginFolder.added,
295
+ removed: input.removed + pluginFolder.removed,
296
+ kept: keptTotal,
246
297
  unchanged: input.unchanged
247
298
  })
248
299
  );
249
- if (input.wrote > 0 || input.removed > 0) {
250
- printKeptFiles(input.kept);
300
+ if (kept.length > 0) {
301
+ printKeptFiles(kept);
302
+ }
303
+ if (reportedBefore.length > 0) {
304
+ console.log(keptReportedBeforeLine(new Set(reportedBefore).size));
251
305
  }
252
306
  if (input.snapshotId) {
253
307
  console.log(snapshotSavedUndoLine(`ht revert ${input.snapshotId}`));
@@ -266,8 +320,117 @@ function removalSkipReason(reason) {
266
320
  // src/services/global-profile-drift.ts
267
321
  import { existsSync as existsSync2, readFileSync } from "fs";
268
322
  import { join as join2 } from "path";
323
+ var driftCoreComputes = 0;
324
+ function driftCore(fields, harness, homeRoot) {
325
+ const watchedPaths = (fields.expectedApply?.expected_files ?? []).map(
326
+ (file) => join2(homeRoot, file.path)
327
+ );
328
+ return { fields, harness, watchedPaths };
329
+ }
330
+ function globalProfileStatusGaps(status) {
331
+ const missing = status.depth === "full" ? listMissingHarnessRows(status.harnesses) : [];
332
+ return { inSync: !status.has_drift && missing.length === 0, missing };
333
+ }
334
+ var HOST_PLUGIN_VIEW_PATH = /^(\.claude\/plugins\/cache\/([^/]+)\/([^/]+)\/([^/]+))\//;
335
+ function isHostPluginViewPath(path) {
336
+ return HOST_PLUGIN_VIEW_PATH.test(path.replaceAll("\\", "/"));
337
+ }
338
+ function hostPluginFolderChanges(homeRoot, expectedFiles, known) {
339
+ const folders = /* @__PURE__ */ new Map();
340
+ for (const file of expectedFiles) {
341
+ const match = HOST_PLUGIN_VIEW_PATH.exec(file.path.replaceAll("\\", "/"));
342
+ if (!match?.[1] || !match[2] || !match[3] || !match[4]) continue;
343
+ folders.set(match[1], { marketplace: match[2], name: match[3], version: match[4] });
344
+ }
345
+ if (folders.size === 0) return [];
346
+ const seen = new Set(known.map((change) => change.path));
347
+ const harnesstapDir = harnesstapDirForHomeRoot(homeRoot);
348
+ const changes = [];
349
+ for (const [folder, plugin] of folders) {
350
+ const canonicalDir = hostPluginPackageDir(harnesstapDir, plugin.marketplace, plugin.name, plugin.version);
351
+ const differences = diffHostPluginView({
352
+ homeRoot,
353
+ hostView: join2(homeRoot, folder),
354
+ canonicalDir
355
+ });
356
+ const emitted = differences.length > 0 ? emittedHostPluginTree(canonicalDir, "claude-code", plugin.name) : /* @__PURE__ */ new Map();
357
+ for (const difference of differences) {
358
+ const path = `${folder}/${difference.path}`;
359
+ if (seen.has(path)) continue;
360
+ const written = emitted.get(difference.path);
361
+ if (difference.state === "missing" ? !written : matchesEmitted(join2(homeRoot, path), written)) {
362
+ continue;
363
+ }
364
+ seen.add(path);
365
+ if (difference.state === "missing") changes.push({ path, type: "deleted" });
366
+ else if (difference.state === "stale") changes.push({ path, type: "modified" });
367
+ else if (difference.state === "modified") {
368
+ changes.push({ path, type: "modified", removal_group: "owned_modified", changed_by: "claude-code" });
369
+ } else {
370
+ changes.push({ path, type: "modified", removal_group: "unmanaged" });
371
+ }
372
+ }
373
+ }
374
+ return changes;
375
+ }
376
+ function matchesEmitted(fullPath, file) {
377
+ if (!file) return false;
378
+ const binary = binaryExpectedFileMatchesDisk(fullPath, file);
379
+ if (binary !== void 0) return binary;
380
+ try {
381
+ return readFileSync(fullPath, "utf-8") === file.content;
382
+ } catch {
383
+ return false;
384
+ }
385
+ }
386
+ function isHarnessTapClaudeMarketplaceFile(path) {
387
+ return path.replaceAll("\\", "/").startsWith(`${HARNESSTAP_CLAUDE_MARKETPLACES_ROOT}/`);
388
+ }
389
+ function claudeChangedMarketplaceEntries(homeRoot, expectedFiles) {
390
+ const wanted = new Set(expectedFiles.map((file) => file.path));
391
+ return [...claudeChangedMarketplaces(homeRoot)].filter((marketplace) => wanted.has(harnessTapClaudeMarketplaceManifestPath(marketplace))).sort().map((marketplace) => ({
392
+ path: CLAUDE_KNOWN_MARKETPLACES_PATH,
393
+ type: "modified",
394
+ removal_group: "owned_modified",
395
+ changed_by: "claude-code",
396
+ detail: `marketplace ${marketplace}`
397
+ }));
398
+ }
399
+ function keptContentDiff(path, keptModified, keptUnmanaged) {
400
+ if (keptModified.has(path)) {
401
+ return { path, type: "modified", removal_group: "owned_modified" };
402
+ }
403
+ if (keptUnmanaged.has(path)) {
404
+ return { path, type: "modified", removal_group: "unmanaged" };
405
+ }
406
+ return { path, type: "modified" };
407
+ }
408
+ function isMissingExpectedFileTransparent(homeRoot, path, expectedPathsByResource, scopeByResource, harnesses) {
409
+ const mapped = resourceKeyFromManagedPath(path);
410
+ if (!mapped) {
411
+ return true;
412
+ }
413
+ const key = `${mapped.type}:${mapped.name}`;
414
+ const siblings = expectedPathsByResource.get(key) ?? [];
415
+ const onDiskSiblingPaths = siblings.filter(
416
+ (sibling) => sibling !== path && readGlobalFile(homeRoot, sibling) !== null
417
+ );
418
+ for (const live of liveSkillCopiesForMissingPath(path, harnesses, (candidate) => readGlobalFile(homeRoot, candidate) !== null)) {
419
+ if (!onDiskSiblingPaths.includes(live)) onDiskSiblingPaths.push(live);
420
+ }
421
+ return isTransparentCrossHarnessGap({
422
+ path,
423
+ onDiskSiblingPaths,
424
+ scope: scopeByResource.get(key)
425
+ });
426
+ }
269
427
  function readGlobalFile(homeRoot, relativePath) {
270
428
  const fullPath = join2(homeRoot, relativePath);
429
+ if (!inStatusComputation()) return readGlobalFileUncached(fullPath);
430
+ if (!existsSync2(fullPath)) return null;
431
+ return readDiskTextOnce(fullPath);
432
+ }
433
+ function readGlobalFileUncached(fullPath) {
271
434
  if (!existsSync2(fullPath)) {
272
435
  return null;
273
436
  }
@@ -300,25 +463,34 @@ function declaredMcpNamesFromMergedPlugins(pluginIds) {
300
463
  function buildBaseStatusFields(input) {
301
464
  const asOf = (/* @__PURE__ */ new Date()).toISOString();
302
465
  const homeRoot = resolveHomeRoot();
303
- const ownedFiles = collectOwnedGlobalProfileFiles(input.snapshotId);
304
- const { owned, nonOwned } = classifyGlobalDriftChanges(input.changes, ownedFiles);
305
- const declaredPins = input.pluginIds && input.pluginIds.length > 0 ? mergePluginsForApply(input.pluginIds).pluginPins : [];
466
+ const ownedFiles = traceSpan("db.owned-files", () => collectOwnedGlobalProfileFiles(input.snapshotId));
467
+ const blockingChanges = input.changes.filter((change) => !driftChangeIsKept(change));
468
+ const { owned, nonOwned } = classifyGlobalDriftChanges(blockingChanges, ownedFiles);
469
+ const declaredPins = input.pluginIds && input.pluginIds.length > 0 ? traceSpan("base.merge-plugins", () => mergePluginsForApply(input.pluginIds ?? []).pluginPins) : [];
306
470
  const declaredFromExpected = input.expectedApply ? declaredMcpFromExpectedApply(input.expectedApply) : null;
307
471
  const declaredMcpByHarness = declaredFromExpected?.namesByHarness ?? (input.pluginIds ? declaredMcpNamesFromMergedPlugins(input.pluginIds) : { "claude-code": [], cursor: [] });
308
- const harnesses = buildHarnessLiveStatusMap({
472
+ const filesOnlyPinRefs = input.expectedApply?.resolution ? {
473
+ "claude-code": filesOnlyMarketplacePinRefs(input.expectedApply.resolution, "claude-code"),
474
+ cursor: filesOnlyMarketplacePinRefs(input.expectedApply.resolution, "cursor")
475
+ } : void 0;
476
+ const harnesses = traceSpan("base.harness-live-status", () => buildHarnessLiveStatusMap({
309
477
  depth: input.depth,
310
478
  homeRoot,
311
479
  declaredPins,
480
+ ...filesOnlyPinRefs ? { filesOnlyPinRefs } : {},
312
481
  declaredMcpByHarness,
313
482
  ...declaredFromExpected ? { expectedMcpConfigsByHarness: declaredFromExpected.configsByHarness } : {}
314
- });
483
+ }));
315
484
  const { missingPlugins, missingMcp } = input.depth === "full" ? countMissingHarnessRows(harnesses) : { missingPlugins: 0, missingMcp: 0 };
316
- const contents = input.activeProfile ? buildProfileContents(input.activeProfile) : null;
317
- const hostManaged = input.depth === "full" ? buildHostManagedStatus({
318
- homeRoot,
319
- profileSkills: profileSkillNameMap(contents?.resources ?? [])
320
- }) : void 0;
321
- const projectDrift = resolveProjectDriftSummary(input.projectPath);
485
+ const contents = input.activeProfile ? traceSpan("base.profile-contents", () => buildProfileContents(input.activeProfile ?? "")) : null;
486
+ const hostManaged = input.depth === "full" ? traceSpan(
487
+ "base.host-managed",
488
+ () => buildHostManagedStatus({
489
+ homeRoot,
490
+ profileSkills: profileSkillNameMap(contents?.resources ?? [])
491
+ })
492
+ ) : void 0;
493
+ const projectDrift = traceSpan("base.project-drift", () => resolveProjectDriftSummary(input.projectPath));
322
494
  const panel = computeGlobalProfilePanelStatus({
323
495
  depth: input.depth,
324
496
  applied: input.applied,
@@ -360,16 +532,19 @@ function buildBaseStatusFields(input) {
360
532
  };
361
533
  }
362
534
  async function finalizeGlobalProfileStatus(fields, harness) {
363
- const status = buildBaseStatusFields(fields);
535
+ const status = traceSpan("base", () => buildBaseStatusFields(fields));
364
536
  if (fields.depth !== "full" || !status.active_profile || isEmptyBuiltinProfile(status.active_profile)) {
365
537
  return status;
366
538
  }
367
539
  try {
368
- const notStaged = await detectNotStagedProfileResources({
369
- profileSelector: status.active_profile,
370
- scope: "home",
371
- ...harness ? { harness } : {}
372
- });
540
+ const notStaged = await traceSpan(
541
+ "not-staged",
542
+ () => detectNotStagedProfileResources({
543
+ profileSelector: status.active_profile ?? "",
544
+ scope: "home",
545
+ ...harness ? { harness } : {}
546
+ })
547
+ );
373
548
  return {
374
549
  ...status,
375
550
  untracked_resource_count: notStaged.length,
@@ -381,11 +556,41 @@ async function finalizeGlobalProfileStatus(fields, harness) {
381
556
  }
382
557
  async function detectGlobalProfileStatus(input = {}) {
383
558
  const depth = input.depth ?? "full";
559
+ const request = {
560
+ depth,
561
+ harness: input.harness,
562
+ projectPath: input.projectPath
563
+ };
564
+ const status = await withStatusReadCache(request, () => runInStatusComputation(async () => {
565
+ const core = await withStatusReadCache(
566
+ { ...request, includeDepth: false },
567
+ async () => {
568
+ const loaded = await loadDriftCore(input);
569
+ return { value: loaded, watchedPaths: loaded.watchedPaths };
570
+ }
571
+ );
572
+ const projected = await finalizeGlobalProfileStatus(
573
+ { ...core.fields, depth },
574
+ core.harness
575
+ );
576
+ return { value: projected, watchedPaths: core.watchedPaths };
577
+ }), { staleWhileRefresh: true });
578
+ return {
579
+ ...status,
580
+ as_of: (/* @__PURE__ */ new Date()).toISOString(),
581
+ refreshing: status.refreshing === true,
582
+ // Outside the cache: one indexed read, so a finished check shows at once.
583
+ updates: readUpstreamCheckSummary(),
584
+ unread_count: unreadNotificationCount()
585
+ };
586
+ }
587
+ async function loadDriftCore(input) {
588
+ driftCoreComputes += 1;
589
+ const homeRoot = resolveHomeRoot();
384
590
  const activeProfile = getActiveProfileName() ?? null;
385
591
  if (!activeProfile) {
386
- return finalizeGlobalProfileStatus(
592
+ return driftCore(
387
593
  {
388
- depth,
389
594
  activeProfile: null,
390
595
  profileExists: false,
391
596
  applied: false,
@@ -396,10 +601,11 @@ async function detectGlobalProfileStatus(input = {}) {
396
601
  changes: [],
397
602
  projectPath: input.projectPath
398
603
  },
399
- input.harness
604
+ input.harness,
605
+ homeRoot
400
606
  );
401
607
  }
402
- const plugin = resolvePluginSelector(activeProfile);
608
+ const plugin = traceSpan("db.resolve-profile", () => resolvePluginSelector(activeProfile));
403
609
  if (!plugin) {
404
610
  if (isEmptyBuiltinProfile(activeProfile)) {
405
611
  const latestSnapshot2 = getLatestGlobalApplySnapshotForProfile(activeProfile);
@@ -412,8 +618,7 @@ async function detectGlobalProfileStatus(input = {}) {
412
618
  pull: false
413
619
  });
414
620
  } catch (error) {
415
- return finalizeGlobalProfileStatus({
416
- depth,
621
+ return driftCore({
417
622
  activeProfile,
418
623
  profileExists: true,
419
624
  applied: Boolean(latestSnapshot2),
@@ -425,13 +630,12 @@ async function detectGlobalProfileStatus(input = {}) {
425
630
  warning: error instanceof Error ? error.message : String(error),
426
631
  projectPath: input.projectPath,
427
632
  pluginIds: []
428
- });
633
+ }, input.harness, homeRoot);
429
634
  }
430
635
  const stackInSync2 = latestSnapshot2 ? pluginIdsMatch(latestSnapshot2.plugin_ids, expectedApply2.configured_plugin_ids) : false;
431
636
  const applied2 = Boolean(latestSnapshot2);
432
637
  const hasDrift2 = !applied2 || !stackInSync2;
433
- return finalizeGlobalProfileStatus({
434
- depth,
638
+ return driftCore({
435
639
  activeProfile,
436
640
  profileExists: true,
437
641
  applied: applied2,
@@ -443,10 +647,9 @@ async function detectGlobalProfileStatus(input = {}) {
443
647
  projectPath: input.projectPath,
444
648
  expectedApply: expectedApply2,
445
649
  pluginIds: []
446
- });
650
+ }, input.harness, homeRoot);
447
651
  }
448
- return finalizeGlobalProfileStatus({
449
- depth,
652
+ return driftCore({
450
653
  activeProfile,
451
654
  profileExists: false,
452
655
  applied: false,
@@ -457,11 +660,10 @@ async function detectGlobalProfileStatus(input = {}) {
457
660
  changes: [],
458
661
  warning: `missing plugin "${activeProfile}"`,
459
662
  projectPath: input.projectPath
460
- });
663
+ }, input.harness, homeRoot);
461
664
  }
462
665
  if (!isProfilePlugin(plugin)) {
463
- return finalizeGlobalProfileStatus({
464
- depth,
666
+ return driftCore({
465
667
  activeProfile,
466
668
  profileExists: true,
467
669
  applied: false,
@@ -472,24 +674,26 @@ async function detectGlobalProfileStatus(input = {}) {
472
674
  changes: [],
473
675
  warning: `plugin "${plugin.name}" is not tagged as a profile`,
474
676
  projectPath: input.projectPath
475
- });
677
+ }, input.harness, homeRoot);
476
678
  }
477
679
  const latestSnapshot = getLatestGlobalApplySnapshotForProfile(activeProfile);
478
- const homeRoot = resolveHomeRoot();
479
680
  const pluginIds = collectProfilePluginIds(plugin);
480
681
  let expectedApply;
481
682
  try {
482
- expectedApply = await applyProfilePlugin(activeProfile, {
483
- dryRun: true,
484
- harness: input.harness,
485
- conflictPolicy: "replace",
486
- pull: false,
487
- pinSkillEmits: false,
488
- mergeLiveSkillMarkdown: false
489
- });
683
+ expectedApply = await traceSpan(
684
+ "dry-run",
685
+ () => applyProfilePlugin(activeProfile, {
686
+ dryRun: true,
687
+ harness: input.harness,
688
+ conflictPolicy: "replace",
689
+ pull: false,
690
+ pinSkillEmits: false,
691
+ mergeLiveSkillMarkdown: false
692
+ })
693
+ );
694
+ traceCount("dry-run", "expected_files", expectedApply.expected_files?.length ?? 0);
490
695
  } catch (error) {
491
- return finalizeGlobalProfileStatus({
492
- depth,
696
+ return driftCore({
493
697
  activeProfile,
494
698
  profileExists: true,
495
699
  applied: Boolean(latestSnapshot),
@@ -501,54 +705,87 @@ async function detectGlobalProfileStatus(input = {}) {
501
705
  warning: error instanceof Error ? error.message : String(error),
502
706
  projectPath: input.projectPath,
503
707
  pluginIds
504
- });
708
+ }, input.harness, homeRoot);
505
709
  }
506
710
  const stackInSync = latestSnapshot ? pluginIdsMatch(latestSnapshot.plugin_ids, expectedApply.configured_plugin_ids) : false;
507
711
  const changes = [];
712
+ const keptModified = new Set(expectedApply.removals?.owned_modified ?? []);
713
+ const keptUnmanaged = new Set(expectedApply.removals?.unmanaged ?? []);
714
+ const scopeByResource = resourceScopesForPlugins(pluginIds);
715
+ const expectedPathsByResource = /* @__PURE__ */ new Map();
508
716
  for (const file of expectedApply.expected_files ?? []) {
509
- const current = readGlobalFile(homeRoot, file.path);
510
- const owned = listMaterializationsForRootPath(homeRoot, file.path);
511
- if (current === null) {
512
- if (owned.length === 0) {
513
- continue;
514
- }
515
- changes.push(
516
- withAffectedResources({ path: file.path, type: "deleted" }, file.content, null)
517
- );
717
+ const mapped = resourceKeyFromManagedPath(file.path);
718
+ if (!mapped) {
518
719
  continue;
519
720
  }
520
- if (owned.length > 0) {
521
- const diskHash = hashOnDiskFile(join2(homeRoot, file.path));
522
- if (owned.some((row) => row.generated_hash === diskHash)) {
721
+ const key = `${mapped.type}:${mapped.name}`;
722
+ const paths = expectedPathsByResource.get(key) ?? [];
723
+ paths.push(file.path);
724
+ expectedPathsByResource.set(key, paths);
725
+ }
726
+ traceSpan("drift.compare-files", () => {
727
+ for (const file of expectedApply.expected_files ?? []) {
728
+ if (isNativeAgentPluginCachePath(file.path)) continue;
729
+ if (isHostPluginViewPath(file.path)) continue;
730
+ if (binaryExpectedFileMatchesDisk(join2(homeRoot, file.path), file)) continue;
731
+ const current = readGlobalFile(homeRoot, file.path);
732
+ const owned = listMaterializationsForRootPath(homeRoot, file.path);
733
+ if (current === null) {
734
+ if (owned.length === 0 && isMissingExpectedFileTransparent(
735
+ homeRoot,
736
+ file.path,
737
+ expectedPathsByResource,
738
+ scopeByResource,
739
+ expectedApply.harnesses
740
+ )) {
741
+ continue;
742
+ }
743
+ changes.push(
744
+ withAffectedResources({ path: file.path, type: "deleted" }, file.content, null)
745
+ );
523
746
  continue;
524
747
  }
525
- if (fileContentsEquivalentForDrift(file.path, current, file.content)) {
748
+ if (owned.length > 0) {
749
+ const diskHash = hashOnDiskFile(join2(homeRoot, file.path));
750
+ if (owned.some((row) => row.generated_hash === diskHash)) {
751
+ continue;
752
+ }
753
+ if (fileContentsEquivalentForDrift(file.path, current, file.content)) {
754
+ continue;
755
+ }
756
+ if (isHarnessTapClaudeMarketplaceFile(file.path)) {
757
+ changes.push({ path: file.path, type: "modified", removal_group: "owned_modified", changed_by: "claude-code" });
758
+ continue;
759
+ }
760
+ changes.push(
761
+ withAffectedResources(
762
+ keptContentDiff(file.path, keptModified, keptUnmanaged),
763
+ file.content,
764
+ current
765
+ )
766
+ );
526
767
  continue;
527
768
  }
528
- changes.push(
529
- withAffectedResources(
530
- { path: file.path, type: "modified" },
531
- file.content,
532
- current
533
- )
534
- );
535
- continue;
536
- }
537
- if (!fileContentsEquivalentForDrift(file.path, current, file.content)) {
538
- changes.push(
539
- withAffectedResources(
540
- { path: file.path, type: "modified" },
541
- file.content,
542
- current
543
- )
544
- );
769
+ if (!fileContentsEquivalentForDrift(file.path, current, file.content)) {
770
+ changes.push(
771
+ withAffectedResources(
772
+ keptContentDiff(file.path, keptModified, keptUnmanaged),
773
+ file.content,
774
+ current
775
+ )
776
+ );
777
+ }
545
778
  }
546
- }
779
+ });
780
+ traceSpan("drift.host-plugin-folders", () => {
781
+ changes.push(...hostPluginFolderChanges(homeRoot, expectedApply.expected_files ?? [], changes));
782
+ });
783
+ changes.push(...claudeChangedMarketplaceEntries(homeRoot, expectedApply.expected_files ?? []));
547
784
  const applied = Boolean(latestSnapshot);
548
- const hasDrift = !applied || !stackInSync || changes.length > 0;
549
- return finalizeGlobalProfileStatus(
785
+ const blockingChanges = changes.filter((change) => !driftChangeIsKept(change));
786
+ const hasDrift = !applied || !stackInSync || blockingChanges.length > 0;
787
+ return driftCore(
550
788
  {
551
- depth,
552
789
  activeProfile,
553
790
  profileExists: true,
554
791
  applied,
@@ -561,7 +798,8 @@ async function detectGlobalProfileStatus(input = {}) {
561
798
  expectedApply,
562
799
  pluginIds
563
800
  },
564
- input.harness
801
+ input.harness,
802
+ homeRoot
565
803
  );
566
804
  }
567
805
 
@@ -699,7 +937,9 @@ function readHomeFile(homeRoot, relativePath) {
699
937
  return null;
700
938
  }
701
939
  try {
702
- return readFileSync2(fullPath, "utf-8");
940
+ const bytes = readFileSync2(fullPath);
941
+ const text = bytes.toString("utf-8");
942
+ return Buffer.from(text, "utf-8").equals(bytes) ? text : null;
703
943
  } catch {
704
944
  return null;
705
945
  }
@@ -709,7 +949,7 @@ function lastWrittenContent(profileName, relativePath) {
709
949
  if (!snapshot?.state) {
710
950
  return void 0;
711
951
  }
712
- return flattenLiveRestoreFiles(snapshot.state).find((file) => file.path === relativePath)?.content;
952
+ return flattenLiveRestoreFiles(snapshot.state, snapshot.id).find((file) => file.path === relativePath)?.bytes;
713
953
  }
714
954
  async function stashManagedDriftChanges(input) {
715
955
  return withProfileApplyLock(async () => {
@@ -736,7 +976,7 @@ async function stashManagedDriftChanges(input) {
736
976
  }
737
977
  const fullPath = resolve2(homeRoot, file.path);
738
978
  mkdirSync(dirname(fullPath), { recursive: true });
739
- writeFileSync(fullPath, previous, "utf-8");
979
+ writeFileSync(fullPath, previous);
740
980
  }
741
981
  }
742
982
  if (input.dryRun) {
@@ -901,10 +1141,11 @@ async function maybeSyncActiveProfileBeforeSwitch(input) {
901
1141
  if (!status.active_profile || status.active_profile === input.targetProfileName) {
902
1142
  return "continue";
903
1143
  }
904
- if (status.changes.length === 0) {
1144
+ const changes = status.changes.filter((change) => !isHostPluginViewPath(change.path) && change.changed_by !== "claude-code");
1145
+ if (changes.length === 0) {
905
1146
  return "continue";
906
1147
  }
907
- const count = status.changes.length;
1148
+ const count = changes.length;
908
1149
  const parsedChanges = parseSwitchChanges(input.changes);
909
1150
  if (parsedChanges === "invalid") {
910
1151
  ui.danger("Error: Invalid --changes. Use save, stash or discard.");
@@ -937,7 +1178,7 @@ async function maybeSyncActiveProfileBeforeSwitch(input) {
937
1178
  case "cancel":
938
1179
  return "abort";
939
1180
  case "save": {
940
- for (const change of status.changes) {
1181
+ for (const change of changes) {
941
1182
  try {
942
1183
  await commitManagedPathFromLive({
943
1184
  profileSelector: status.active_profile,
@@ -953,7 +1194,7 @@ async function maybeSyncActiveProfileBeforeSwitch(input) {
953
1194
  }
954
1195
  case "stash": {
955
1196
  await stashManagedDriftChanges({
956
- changes: status.changes
1197
+ changes
957
1198
  });
958
1199
  ui.success(stashedChangesLine(count, "ht profile stash pop"));
959
1200
  return "continue";
@@ -1337,11 +1578,13 @@ async function executeProjectUse(options = {}) {
1337
1578
  export {
1338
1579
  resolveUserPath,
1339
1580
  resolveApplyConflictPolicy,
1581
+ reportApplyCancelled,
1340
1582
  promptMaterializationConflict,
1341
1583
  printApplyPayload,
1342
1584
  printApplyDryRun,
1343
1585
  printApplySuccess,
1344
1586
  removalSkipReason,
1587
+ globalProfileStatusGaps,
1345
1588
  detectGlobalProfileStatus,
1346
1589
  buildProjectProfileChoices,
1347
1590
  listProfileStashEntries,
@@ -1354,4 +1597,4 @@ export {
1354
1597
  importProjectConfigEnvironments,
1355
1598
  executeProjectUse
1356
1599
  };
1357
- //# sourceMappingURL=chunk-AVZOFMJX.js.map
1600
+ //# sourceMappingURL=chunk-D7R577XZ.js.map