harnesstap 1.4.0 → 1.6.1

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 (211) hide show
  1. package/README.md +3 -1
  2. package/dist/apply-ZGEAY6YZ.js +50 -0
  3. package/dist/{approve-FBGYQGWN.js → approve-VPVMU2MM.js} +10 -13
  4. package/dist/{approve-FBGYQGWN.js.map → approve-VPVMU2MM.js.map} +1 -1
  5. package/dist/{audit-VI4QZ6X2.js → audit-AO7AGET3.js} +11 -15
  6. package/dist/{audit-VI4QZ6X2.js.map → audit-AO7AGET3.js.map} +1 -1
  7. package/dist/{auth-4CQCDS2W.js → auth-7YRIJNXU.js} +10 -12
  8. package/dist/{auth-4CQCDS2W.js.map → auth-7YRIJNXU.js.map} +1 -1
  9. package/dist/bin.js +13 -34
  10. package/dist/bin.js.map +1 -1
  11. package/dist/{chunk-OML4HXKT.js → chunk-262KZULH.js} +16 -22
  12. package/dist/chunk-262KZULH.js.map +1 -0
  13. package/dist/{chunk-ZUASVASP.js → chunk-26QGX47N.js} +26097 -16881
  14. package/dist/chunk-26QGX47N.js.map +1 -0
  15. package/dist/{chunk-3P6BWL5F.js → chunk-27IPOVKQ.js} +2 -2
  16. package/dist/{chunk-M4KLHJ6U.js → chunk-2BESDRYP.js} +8 -10
  17. package/dist/{chunk-M4KLHJ6U.js.map → chunk-2BESDRYP.js.map} +1 -1
  18. package/dist/{chunk-PCMON7Y2.js → chunk-2BWIEB2G.js} +8 -10
  19. package/dist/{chunk-PCMON7Y2.js.map → chunk-2BWIEB2G.js.map} +1 -1
  20. package/dist/{chunk-XTVGCVU4.js → chunk-2NMLWSUH.js} +41 -42
  21. package/dist/chunk-2NMLWSUH.js.map +1 -0
  22. package/dist/{chunk-TQ2NA4Z4.js → chunk-4E3G4H5B.js} +8 -2
  23. package/dist/chunk-4E3G4H5B.js.map +1 -0
  24. package/dist/chunk-4QCGTUTM.js +61 -0
  25. package/dist/chunk-4QCGTUTM.js.map +1 -0
  26. package/dist/{chunk-TPEJFLV7.js → chunk-6RKJZW2N.js} +4 -6
  27. package/dist/{chunk-TPEJFLV7.js.map → chunk-6RKJZW2N.js.map} +1 -1
  28. package/dist/{chunk-JQOKQKQT.js → chunk-7IBFH736.js} +2 -2
  29. package/dist/{chunk-P2C7JPLD.js → chunk-CKJIS2FM.js} +6 -6
  30. package/dist/{chunk-R7ZOYVN3.js → chunk-CUOEQQFI.js} +187 -59
  31. package/dist/chunk-CUOEQQFI.js.map +1 -0
  32. package/dist/{chunk-REHRUNBB.js → chunk-CWXCZBJR.js} +70 -5
  33. package/dist/chunk-CWXCZBJR.js.map +1 -0
  34. package/dist/{chunk-4ZQ2SCGY.js → chunk-FLYQEB6D.js} +509 -207
  35. package/dist/chunk-FLYQEB6D.js.map +1 -0
  36. package/dist/{chunk-U6DXASQP.js → chunk-HC7IZY75.js} +2 -2
  37. package/dist/{chunk-UVVZHWD2.js → chunk-I4DKV63E.js} +2 -2
  38. package/dist/{chunk-PNGF5EV2.js → chunk-JEC5PWNH.js} +2 -2
  39. package/dist/{chunk-MR7IOHSX.js → chunk-KFIRABC7.js} +16 -22
  40. package/dist/{chunk-MR7IOHSX.js.map → chunk-KFIRABC7.js.map} +1 -1
  41. package/dist/{chunk-6LTLYV5D.js → chunk-LGWFLVZQ.js} +1064 -265
  42. package/dist/chunk-LGWFLVZQ.js.map +1 -0
  43. package/dist/{chunk-RDG5DT7S.js → chunk-LX6PMOOC.js} +54 -40
  44. package/dist/chunk-LX6PMOOC.js.map +1 -0
  45. package/dist/{chunk-WGP4GUYZ.js → chunk-MILGCNBK.js} +9 -11
  46. package/dist/{chunk-WGP4GUYZ.js.map → chunk-MILGCNBK.js.map} +1 -1
  47. package/dist/chunk-MKLJBW5N.js +14 -0
  48. package/dist/{chunk-N3ZCH64F.js → chunk-MSKTWYHG.js} +86 -32
  49. package/dist/chunk-MSKTWYHG.js.map +1 -0
  50. package/dist/{chunk-WG5A6EAU.js → chunk-MTCCUYBZ.js} +821 -28
  51. package/dist/chunk-MTCCUYBZ.js.map +1 -0
  52. package/dist/{chunk-BPWFQKI5.js → chunk-NIFKCS7J.js} +2 -2
  53. package/dist/{chunk-43BDGVN3.js → chunk-NWOYPK2O.js} +56 -9
  54. package/dist/chunk-NWOYPK2O.js.map +1 -0
  55. package/dist/{chunk-3FS775NP.js → chunk-NXILQDJG.js} +85 -4
  56. package/dist/chunk-NXILQDJG.js.map +1 -0
  57. package/dist/chunk-QF73VLAW.js +31673 -0
  58. package/dist/chunk-QF73VLAW.js.map +1 -0
  59. package/dist/{chunk-RFQ3N7FB.js → chunk-QHCGA6LC.js} +11 -19
  60. package/dist/chunk-QHCGA6LC.js.map +1 -0
  61. package/dist/{chunk-L6YZE5MY.js → chunk-QPJZKWML.js} +5 -7
  62. package/dist/{chunk-L6YZE5MY.js.map → chunk-QPJZKWML.js.map} +1 -1
  63. package/dist/{chunk-ULCD6DJE.js → chunk-RM7VP6ID.js} +24 -61
  64. package/dist/chunk-RM7VP6ID.js.map +1 -0
  65. package/dist/{chunk-7HP6AAI3.js → chunk-SMLO5YPI.js} +2 -2
  66. package/dist/{chunk-73OJQTBW.js → chunk-T2JBSRGG.js} +2 -2
  67. package/dist/{chunk-IE7B6Q5K.js → chunk-U5Y6WKKT.js} +17 -18
  68. package/dist/chunk-U5Y6WKKT.js.map +1 -0
  69. package/dist/chunk-UEA4NCY2.js +106 -0
  70. package/dist/chunk-UEA4NCY2.js.map +1 -0
  71. package/dist/chunk-VAPCU2FX.js +70 -0
  72. package/dist/chunk-VAPCU2FX.js.map +1 -0
  73. package/dist/{chunk-RVEXPMM3.js → chunk-WEJVFNRO.js} +3 -5
  74. package/dist/{chunk-RVEXPMM3.js.map → chunk-WEJVFNRO.js.map} +1 -1
  75. package/dist/{chunk-IMROMZ2K.js → chunk-WWFVMCTR.js} +19 -14
  76. package/dist/chunk-WWFVMCTR.js.map +1 -0
  77. package/dist/chunk-XPONNOBR.js +102 -0
  78. package/dist/chunk-XPONNOBR.js.map +1 -0
  79. package/dist/{chunk-N3VGY3T3.js → chunk-Y3HJ2F2W.js} +7 -5
  80. package/dist/{chunk-N3VGY3T3.js.map → chunk-Y3HJ2F2W.js.map} +1 -1
  81. package/dist/{chunk-2A36HWDE.js → chunk-Y4I7ZCAE.js} +129 -136
  82. package/dist/chunk-Y4I7ZCAE.js.map +1 -0
  83. package/dist/{chunk-GRASK6M6.js → chunk-ZREU2UHM.js} +5 -5
  84. package/dist/{chunk-QA5U36JN.js → chunk-ZT7ANP3H.js} +774 -364
  85. package/dist/chunk-ZT7ANP3H.js.map +1 -0
  86. package/dist/{chunk-EOPFER6N.js → chunk-ZUXFPAVX.js} +19 -5
  87. package/dist/chunk-ZUXFPAVX.js.map +1 -0
  88. package/dist/{chunk-D432JAXV.js → chunk-ZWB6YXVQ.js} +153 -25
  89. package/dist/chunk-ZWB6YXVQ.js.map +1 -0
  90. package/dist/{chunk-23XSG7LI.js → chunk-ZZQDJGWX.js} +4 -4
  91. package/dist/{compile-GXADKGH5.js → compile-IMJHVXQO.js} +33 -37
  92. package/dist/{compile-GXADKGH5.js.map → compile-IMJHVXQO.js.map} +1 -1
  93. package/dist/{config-JMHNA2U5.js → config-FVVN3NWL.js} +16 -21
  94. package/dist/{config-JMHNA2U5.js.map → config-FVVN3NWL.js.map} +1 -1
  95. package/dist/cursor-local-install-JS5KSOES.js +94 -0
  96. package/dist/{cursor-local-install-46RWRBDT.js.map → cursor-local-install-JS5KSOES.js.map} +1 -1
  97. package/dist/{cursor-local-install-46RWRBDT.js → cursor-local-install-QU5R2FV5.js} +8 -12
  98. package/dist/cursor-local-install-QU5R2FV5.js.map +1 -0
  99. package/dist/{doctor-N7ZULPOL.js → doctor-A7VUJSCP.js} +14 -17
  100. package/dist/doctor-A7VUJSCP.js.map +1 -0
  101. package/dist/{environment-OBB3WU5B.js → environment-6INIUBNC.js} +42 -50
  102. package/dist/environment-6INIUBNC.js.map +1 -0
  103. package/dist/{github-PBYBGOLH.js → github-TFJT3P53.js} +9 -10
  104. package/dist/{github-PBYBGOLH.js.map → github-TFJT3P53.js.map} +1 -1
  105. package/dist/{harness-7KYATIV6.js → harness-WQNC5HPZ.js} +46 -84
  106. package/dist/harness-WQNC5HPZ.js.map +1 -0
  107. package/dist/{help-EE3AJQD4.js → help-NMS3EXJB.js} +15 -20
  108. package/dist/{help-EE3AJQD4.js.map → help-NMS3EXJB.js.map} +1 -1
  109. package/dist/{help-VXWKLQ6A.js → help-VW4RIICD.js} +57 -575
  110. package/dist/help-VW4RIICD.js.map +1 -0
  111. package/dist/host-plugin-view-kept-HYCHDB4D.js +139 -0
  112. package/dist/host-plugin-view-kept-HYCHDB4D.js.map +1 -0
  113. package/dist/index.js +12 -16
  114. package/dist/{init-LBTMPDVJ.js → init-RXYL5ZUE.js} +33 -41
  115. package/dist/{init-LBTMPDVJ.js.map → init-RXYL5ZUE.js.map} +1 -1
  116. package/dist/live-read-cache-BHU6L7MA.js +13 -0
  117. package/dist/live-read-cache-NQU7M2C7.js +12 -0
  118. package/dist/{lock-WLJRXRVK.js → lock-3H3Z65DS.js} +9 -12
  119. package/dist/{lock-WLJRXRVK.js.map → lock-3H3Z65DS.js.map} +1 -1
  120. package/dist/{marketplace-GXSV6QIY.js → marketplace-KW35PJCY.js} +26 -79
  121. package/dist/marketplace-KW35PJCY.js.map +1 -0
  122. package/dist/{mcp-XPDWWU75.js → mcp-2HUGVDJ5.js} +33 -37
  123. package/dist/{mcp-XPDWWU75.js.map → mcp-2HUGVDJ5.js.map} +1 -1
  124. package/dist/{migrate-SBUIWN3U.js → migrate-6VAPYNXI.js} +93 -34
  125. package/dist/migrate-6VAPYNXI.js.map +1 -0
  126. package/dist/notifications-Y7KQCN6K.js +154 -0
  127. package/dist/notifications-Y7KQCN6K.js.map +1 -0
  128. package/dist/open-FADABB2S.js +20 -0
  129. package/dist/{pack-A73LDVOX.js → pack-NTECD3BZ.js} +10 -14
  130. package/dist/{pack-A73LDVOX.js.map → pack-NTECD3BZ.js.map} +1 -1
  131. package/dist/plugin-T2YFCYIO.js +47 -0
  132. package/dist/plugin-from-project-FGX5AHW6.js +15 -0
  133. package/dist/{policy-6VY3CMSU.js → policy-3FOWB4GR.js} +9 -12
  134. package/dist/{policy-6VY3CMSU.js.map → policy-3FOWB4GR.js.map} +1 -1
  135. package/dist/{profile-YCKPMRRU.js → profile-HM3ROXXB.js} +108 -78
  136. package/dist/profile-HM3ROXXB.js.map +1 -0
  137. package/dist/{project-KHPPBKPN.js → project-3DTXKMI6.js} +512 -119
  138. package/dist/project-3DTXKMI6.js.map +1 -0
  139. package/dist/{resource-IJU3FAN5.js → resource-TZDZAVZ6.js} +55 -45
  140. package/dist/resource-TZDZAVZ6.js.map +1 -0
  141. package/dist/status-refresh-worker.js +1155 -0
  142. package/dist/status-refresh-worker.js.map +1 -0
  143. package/dist/{version-Z66FWWMQ.js → version-AMZJHJIB.js} +3 -3
  144. package/dist/version-AMZJHJIB.js.map +1 -0
  145. package/package.json +16 -11
  146. package/dist/apply-SUNDXRJ3.js +0 -54
  147. package/dist/chunk-2A36HWDE.js.map +0 -1
  148. package/dist/chunk-2H7UOFLK.js +0 -11
  149. package/dist/chunk-3FS775NP.js.map +0 -1
  150. package/dist/chunk-43BDGVN3.js.map +0 -1
  151. package/dist/chunk-4ZQ2SCGY.js.map +0 -1
  152. package/dist/chunk-6LTLYV5D.js.map +0 -1
  153. package/dist/chunk-D432JAXV.js.map +0 -1
  154. package/dist/chunk-DF4Z7LAD.js +0 -3463
  155. package/dist/chunk-DF4Z7LAD.js.map +0 -1
  156. package/dist/chunk-EOPFER6N.js.map +0 -1
  157. package/dist/chunk-G6WKY2W4.js +0 -389
  158. package/dist/chunk-G6WKY2W4.js.map +0 -1
  159. package/dist/chunk-IE7B6Q5K.js.map +0 -1
  160. package/dist/chunk-IMROMZ2K.js.map +0 -1
  161. package/dist/chunk-M2U3J7UX.js +0 -46
  162. package/dist/chunk-M2U3J7UX.js.map +0 -1
  163. package/dist/chunk-N3ZCH64F.js.map +0 -1
  164. package/dist/chunk-NAGAJ5UM.js +0 -145
  165. package/dist/chunk-NAGAJ5UM.js.map +0 -1
  166. package/dist/chunk-OML4HXKT.js.map +0 -1
  167. package/dist/chunk-QA5U36JN.js.map +0 -1
  168. package/dist/chunk-R7ZOYVN3.js.map +0 -1
  169. package/dist/chunk-RDG5DT7S.js.map +0 -1
  170. package/dist/chunk-REHRUNBB.js.map +0 -1
  171. package/dist/chunk-RFQ3N7FB.js.map +0 -1
  172. package/dist/chunk-TQ2NA4Z4.js.map +0 -1
  173. package/dist/chunk-ULCD6DJE.js.map +0 -1
  174. package/dist/chunk-WG5A6EAU.js.map +0 -1
  175. package/dist/chunk-XGTTOO4R.js +0 -84
  176. package/dist/chunk-XGTTOO4R.js.map +0 -1
  177. package/dist/chunk-XTVGCVU4.js.map +0 -1
  178. package/dist/chunk-XUJKZQZA.js +0 -235
  179. package/dist/chunk-XUJKZQZA.js.map +0 -1
  180. package/dist/chunk-ZUASVASP.js.map +0 -1
  181. package/dist/doctor-N7ZULPOL.js.map +0 -1
  182. package/dist/environment-OBB3WU5B.js.map +0 -1
  183. package/dist/harness-7KYATIV6.js.map +0 -1
  184. package/dist/help-VXWKLQ6A.js.map +0 -1
  185. package/dist/live-read-cache-TUSP7U3D.js +0 -10
  186. package/dist/marketplace-GXSV6QIY.js.map +0 -1
  187. package/dist/migrate-SBUIWN3U.js.map +0 -1
  188. package/dist/open-HDGLYYVU.js +0 -24
  189. package/dist/plugin-CEO6ZJM5.js +0 -51
  190. package/dist/plugin-from-project-UK7VJVUP.js +0 -18
  191. package/dist/profile-YCKPMRRU.js.map +0 -1
  192. package/dist/project-KHPPBKPN.js.map +0 -1
  193. package/dist/resource-IJU3FAN5.js.map +0 -1
  194. /package/dist/{apply-SUNDXRJ3.js.map → apply-ZGEAY6YZ.js.map} +0 -0
  195. /package/dist/{chunk-3P6BWL5F.js.map → chunk-27IPOVKQ.js.map} +0 -0
  196. /package/dist/{chunk-JQOKQKQT.js.map → chunk-7IBFH736.js.map} +0 -0
  197. /package/dist/{chunk-P2C7JPLD.js.map → chunk-CKJIS2FM.js.map} +0 -0
  198. /package/dist/{chunk-U6DXASQP.js.map → chunk-HC7IZY75.js.map} +0 -0
  199. /package/dist/{chunk-UVVZHWD2.js.map → chunk-I4DKV63E.js.map} +0 -0
  200. /package/dist/{chunk-PNGF5EV2.js.map → chunk-JEC5PWNH.js.map} +0 -0
  201. /package/dist/{chunk-2H7UOFLK.js.map → chunk-MKLJBW5N.js.map} +0 -0
  202. /package/dist/{chunk-BPWFQKI5.js.map → chunk-NIFKCS7J.js.map} +0 -0
  203. /package/dist/{chunk-7HP6AAI3.js.map → chunk-SMLO5YPI.js.map} +0 -0
  204. /package/dist/{chunk-73OJQTBW.js.map → chunk-T2JBSRGG.js.map} +0 -0
  205. /package/dist/{chunk-GRASK6M6.js.map → chunk-ZREU2UHM.js.map} +0 -0
  206. /package/dist/{chunk-23XSG7LI.js.map → chunk-ZZQDJGWX.js.map} +0 -0
  207. /package/dist/{live-read-cache-TUSP7U3D.js.map → live-read-cache-BHU6L7MA.js.map} +0 -0
  208. /package/dist/{open-HDGLYYVU.js.map → live-read-cache-NQU7M2C7.js.map} +0 -0
  209. /package/dist/{plugin-CEO6ZJM5.js.map → open-FADABB2S.js.map} +0 -0
  210. /package/dist/{plugin-from-project-UK7VJVUP.js.map → plugin-T2YFCYIO.js.map} +0 -0
  211. /package/dist/{version-Z66FWWMQ.js.map → plugin-from-project-FGX5AHW6.js.map} +0 -0
@@ -0,0 +1,1155 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ CLAUDE_KNOWN_MARKETPLACES_PATH,
4
+ HARNESSTAP_CLAUDE_MARKETPLACES_ROOT,
5
+ applyProfilePlugin,
6
+ armStatusWatches,
7
+ binaryExpectedFileMatchesDisk,
8
+ buildHarnessLiveStatusMap,
9
+ buildHostManagedStatus,
10
+ buildProfileContents,
11
+ classifyGlobalDriftChanges,
12
+ claudeChangedMarketplaces,
13
+ clearGlobalProfileApply,
14
+ closeStatusWatches,
15
+ collectFingerprintPaths,
16
+ collectOwnedGlobalProfileFiles,
17
+ collectProfilePluginIds,
18
+ computeGlobalProfilePanelStatus,
19
+ countMissingHarnessRows,
20
+ declaredMcpFromExpectedFiles,
21
+ describeStatusRefreshError,
22
+ detectNotStagedProfileResources,
23
+ diffHostPluginView,
24
+ driftChangeIsKept,
25
+ emittedHostPluginTree,
26
+ fileContentsEquivalentForDrift,
27
+ filesOnlyMarketplacePinRefs,
28
+ getActiveProfileName,
29
+ getAllPlatforms,
30
+ getLatestGlobalApplySnapshotForProfile,
31
+ harnessTapClaudeMarketplaceManifestPath,
32
+ harnesstapDirForHomeRoot,
33
+ hashOnDiskFile,
34
+ hostPluginPackageDir,
35
+ inStatusComputation,
36
+ isClaudeSettingsPath,
37
+ isClaudeUserJsonPath,
38
+ isEmptyBuiltinProfile,
39
+ isMcpConfigManagedPath,
40
+ isMuseSettingsPath,
41
+ isNativeAgentPluginCachePath,
42
+ isProfilePlugin,
43
+ listMaterializationsForRootPath,
44
+ mergePluginsForApply,
45
+ parseHooksJsonContent,
46
+ parseSkillEmitPath,
47
+ profileSkillNameMap,
48
+ readDiskTextOnce,
49
+ releaseStatusWatchesForOtherHomes,
50
+ resolveHomeRoot,
51
+ resolvePluginSelector,
52
+ resolveProjectDriftSummary,
53
+ resourceHarnessScope,
54
+ resourceKeyFromManagedPath,
55
+ runInStatusComputation,
56
+ runTracedStatus,
57
+ setHomeRootOverride,
58
+ skillConsumeDirs,
59
+ statusTraceEnabled,
60
+ traceCount,
61
+ traceSpan
62
+ } from "./chunk-QF73VLAW.js";
63
+ import "./chunk-VAPCU2FX.js";
64
+ import "./chunk-Y4I7ZCAE.js";
65
+ import "./chunk-UEA4NCY2.js";
66
+ import "./chunk-WWFVMCTR.js";
67
+ import "./chunk-MKLJBW5N.js";
68
+
69
+ // src/services/status-refresh-worker.ts
70
+ import { join as join2 } from "path";
71
+ import { parentPort } from "worker_threads";
72
+
73
+ // src/services/global-profile-drift.ts
74
+ import { existsSync, readFileSync } from "fs";
75
+ import { join } from "path";
76
+
77
+ // src/services/cross-harness-gap.ts
78
+ var consumeDirsByPlatform = /* @__PURE__ */ new Map();
79
+ function consumeDirsForPlatform(platformId) {
80
+ const cached = consumeDirsByPlatform.get(platformId);
81
+ if (cached) {
82
+ return cached;
83
+ }
84
+ const dirs = /* @__PURE__ */ new Set([
85
+ ...skillConsumeDirs(platformId, "global"),
86
+ ...skillConsumeDirs(platformId, "project")
87
+ ]);
88
+ consumeDirsByPlatform.set(platformId, dirs);
89
+ return dirs;
90
+ }
91
+ function platformsConsumingSkillDir(skillsDir) {
92
+ const ids = [];
93
+ for (const platform of getAllPlatforms()) {
94
+ if (consumeDirsForPlatform(platform.id).has(skillsDir)) {
95
+ ids.push(platform.id);
96
+ }
97
+ }
98
+ return ids;
99
+ }
100
+ function resourceScopesForPlugins(pluginIds) {
101
+ const map = /* @__PURE__ */ new Map();
102
+ if (!pluginIds || pluginIds.length === 0) {
103
+ return map;
104
+ }
105
+ for (const resource of mergePluginsForApply([...pluginIds]).resources) {
106
+ map.set(`${resource.type}:${resource.name}`, resourceHarnessScope(resource));
107
+ }
108
+ return map;
109
+ }
110
+ function isTransparentCrossHarnessGap(input) {
111
+ if (input.onDiskSiblingPaths.length === 0) {
112
+ return false;
113
+ }
114
+ if (!input.scope || input.scope.kind === "all") {
115
+ return true;
116
+ }
117
+ const missingDir = parseSkillEmitPath(input.path)?.skillsDir;
118
+ if (!missingDir) {
119
+ return true;
120
+ }
121
+ const scoped = new Set(input.scope.harnesses);
122
+ const consumers = platformsConsumingSkillDir(missingDir).filter((id) => scoped.has(id));
123
+ if (consumers.length === 0) {
124
+ return true;
125
+ }
126
+ return consumers.every((id) => {
127
+ const dirs = consumeDirsForPlatform(id);
128
+ return input.onDiskSiblingPaths.some((path) => {
129
+ const dir = parseSkillEmitPath(path)?.skillsDir;
130
+ return dir !== void 0 && dirs.has(dir);
131
+ });
132
+ });
133
+ }
134
+ function liveSkillCopiesForMissingPath(path, harnesses, exists) {
135
+ const parsed = parseSkillEmitPath(path);
136
+ if (!parsed) {
137
+ return [];
138
+ }
139
+ const active = new Set(harnesses);
140
+ const dirs = /* @__PURE__ */ new Set();
141
+ for (const id of platformsConsumingSkillDir(parsed.skillsDir)) {
142
+ if (!active.has(id)) continue;
143
+ for (const dir of consumeDirsForPlatform(id)) {
144
+ if (dir !== parsed.skillsDir) dirs.add(dir);
145
+ }
146
+ }
147
+ return [...dirs].map((dir) => `${dir}${parsed.name}/${parsed.rest}`).filter((candidate) => exists(candidate));
148
+ }
149
+
150
+ // src/utils/unified-diff.ts
151
+ function splitLines(text) {
152
+ if (text.length === 0) {
153
+ return [];
154
+ }
155
+ const parts = text.split("\n");
156
+ if (text.endsWith("\n")) {
157
+ return parts.slice(0, -1);
158
+ }
159
+ return parts;
160
+ }
161
+ function computeOps(oldLines, newLines) {
162
+ const m = oldLines.length;
163
+ const n = newLines.length;
164
+ const dp = Array.from(
165
+ { length: m + 1 },
166
+ () => Array.from({ length: n + 1 }, () => 0)
167
+ );
168
+ for (let i2 = m - 1; i2 >= 0; i2--) {
169
+ for (let j2 = n - 1; j2 >= 0; j2--) {
170
+ if (oldLines[i2] === newLines[j2]) {
171
+ dp[i2][j2] = (dp[i2 + 1][j2 + 1] ?? 0) + 1;
172
+ } else {
173
+ dp[i2][j2] = Math.max(dp[i2 + 1][j2] ?? 0, dp[i2][j2 + 1] ?? 0);
174
+ }
175
+ }
176
+ }
177
+ const ops = [];
178
+ let i = 0;
179
+ let j = 0;
180
+ while (i < m && j < n) {
181
+ if (oldLines[i] === newLines[j]) {
182
+ ops.push({ kind: "equal", line: oldLines[i] });
183
+ i++;
184
+ j++;
185
+ } else if ((dp[i + 1][j] ?? 0) >= (dp[i][j + 1] ?? 0)) {
186
+ ops.push({ kind: "delete", line: oldLines[i] });
187
+ i++;
188
+ } else {
189
+ ops.push({ kind: "insert", line: newLines[j] });
190
+ j++;
191
+ }
192
+ }
193
+ while (i < m) {
194
+ ops.push({ kind: "delete", line: oldLines[i] });
195
+ i++;
196
+ }
197
+ while (j < n) {
198
+ ops.push({ kind: "insert", line: newLines[j] });
199
+ j++;
200
+ }
201
+ return ops;
202
+ }
203
+ function advanceLine(op, oldLine, newLine) {
204
+ switch (op.kind) {
205
+ case "equal":
206
+ return { oldLine: oldLine + 1, newLine: newLine + 1 };
207
+ case "delete":
208
+ return { oldLine: oldLine + 1, newLine };
209
+ case "insert":
210
+ return { oldLine, newLine: newLine + 1 };
211
+ default: {
212
+ const _never = op.kind;
213
+ return _never;
214
+ }
215
+ }
216
+ }
217
+ function buildUnifiedDiffLines(path, from, to, contextLines = 3) {
218
+ const ops = computeOps(splitLines(from), splitLines(to));
219
+ if (ops.every((op) => op.kind === "equal")) {
220
+ return [{ kind: "meta", text: "(no content differences)" }];
221
+ }
222
+ const result = [
223
+ { kind: "meta", text: `--- live/${path}` },
224
+ { kind: "meta", text: `+++ after-apply/${path}` }
225
+ ];
226
+ const include = new Array(ops.length).fill(false);
227
+ for (let index = 0; index < ops.length; index++) {
228
+ if (ops[index].kind === "equal") {
229
+ continue;
230
+ }
231
+ include[index] = true;
232
+ let before = 0;
233
+ for (let k = index - 1; k >= 0 && before < contextLines; k--) {
234
+ include[k] = true;
235
+ if (ops[k].kind === "equal") {
236
+ before++;
237
+ }
238
+ }
239
+ let after = 0;
240
+ for (let k = index + 1; k < ops.length && after < contextLines; k++) {
241
+ include[k] = true;
242
+ if (ops[k].kind === "equal") {
243
+ after++;
244
+ }
245
+ }
246
+ }
247
+ let opIndex = 0;
248
+ let oldLine = 1;
249
+ let newLine = 1;
250
+ while (opIndex < ops.length) {
251
+ if (!include[opIndex]) {
252
+ const advanced = advanceLine(ops[opIndex], oldLine, newLine);
253
+ oldLine = advanced.oldLine;
254
+ newLine = advanced.newLine;
255
+ opIndex++;
256
+ continue;
257
+ }
258
+ const hunkStart = opIndex;
259
+ const hunkOldStart = oldLine;
260
+ const hunkNewStart = newLine;
261
+ while (opIndex < ops.length && include[opIndex]) {
262
+ opIndex++;
263
+ }
264
+ const hunkEnd = opIndex;
265
+ let oldCount = 0;
266
+ let newCount = 0;
267
+ const body = [];
268
+ for (let k = hunkStart; k < hunkEnd; k++) {
269
+ const op = ops[k];
270
+ switch (op.kind) {
271
+ case "equal":
272
+ body.push({ kind: "context", text: ` ${op.line}` });
273
+ oldCount++;
274
+ newCount++;
275
+ break;
276
+ case "delete":
277
+ body.push({ kind: "remove", text: `-${op.line}` });
278
+ oldCount++;
279
+ break;
280
+ case "insert":
281
+ body.push({ kind: "add", text: `+${op.line}` });
282
+ newCount++;
283
+ break;
284
+ default: {
285
+ const _never = op.kind;
286
+ return _never;
287
+ }
288
+ }
289
+ const advanced = advanceLine(op, oldLine, newLine);
290
+ oldLine = advanced.oldLine;
291
+ newLine = advanced.newLine;
292
+ }
293
+ result.push({
294
+ kind: "hunk",
295
+ text: `@@ -${hunkOldStart},${oldCount} +${hunkNewStart},${newCount} @@`
296
+ });
297
+ result.push(...body);
298
+ }
299
+ return result;
300
+ }
301
+ function fileDiffHasContentChange(path, current, expected) {
302
+ const { added, removed } = countUnifiedDiffChanges(
303
+ buildUnifiedDiffLines(path, current, expected)
304
+ );
305
+ return added > 0 || removed > 0;
306
+ }
307
+ function countUnifiedDiffChanges(lines) {
308
+ let added = 0;
309
+ let removed = 0;
310
+ for (const line of lines) {
311
+ switch (line.kind) {
312
+ case "add":
313
+ added++;
314
+ break;
315
+ case "remove":
316
+ removed++;
317
+ break;
318
+ case "meta":
319
+ case "hunk":
320
+ case "context":
321
+ break;
322
+ default: {
323
+ const _never = line.kind;
324
+ return _never;
325
+ }
326
+ }
327
+ }
328
+ return { added, removed };
329
+ }
330
+
331
+ // src/services/host-config-resource-detail.ts
332
+ var PERMISSION_ACTIONS = ["allow", "deny", "ask"];
333
+ function isRecord(value) {
334
+ return typeof value === "object" && value !== null && !Array.isArray(value);
335
+ }
336
+ function formatJsonFragment(value) {
337
+ return `${JSON.stringify(value, null, 2)}
338
+ `;
339
+ }
340
+ function parseJsonObject(content) {
341
+ try {
342
+ const parsed = JSON.parse(content);
343
+ return isRecord(parsed) ? parsed : null;
344
+ } catch {
345
+ return null;
346
+ }
347
+ }
348
+ function hostConfigResourcesFromContent(content) {
349
+ const resources = [];
350
+ const seen = /* @__PURE__ */ new Set();
351
+ const add = (type, name) => {
352
+ const trimmed = name.trim();
353
+ if (!trimmed) {
354
+ return;
355
+ }
356
+ const key = `${type}:${trimmed}`;
357
+ if (seen.has(key)) {
358
+ return;
359
+ }
360
+ seen.add(key);
361
+ resources.push({ type, name: trimmed });
362
+ };
363
+ const document = parseJsonObject(content);
364
+ if (document && isRecord(document.permissions)) {
365
+ for (const action of PERMISSION_ACTIONS) {
366
+ const list = document.permissions[action];
367
+ if (!Array.isArray(list)) {
368
+ continue;
369
+ }
370
+ for (const pattern of list) {
371
+ if (typeof pattern === "string" && pattern.trim()) {
372
+ add("permission", `${action}-${pattern}`);
373
+ }
374
+ }
375
+ }
376
+ }
377
+ for (const hook of hookResourcesFromContent(content)) {
378
+ add("hook", hook.name);
379
+ }
380
+ if (document && isRecord(document.env)) {
381
+ for (const name of Object.keys(document.env)) {
382
+ add("env_var", name);
383
+ }
384
+ }
385
+ return resources;
386
+ }
387
+ function parsePermissionResourceName(name) {
388
+ const trimmed = name.trim();
389
+ for (const action of PERMISSION_ACTIONS) {
390
+ const prefix = `${action}-`;
391
+ if (trimmed.startsWith(prefix) && trimmed.length > prefix.length) {
392
+ return { action, pattern: trimmed.slice(prefix.length) };
393
+ }
394
+ }
395
+ return null;
396
+ }
397
+ function permissionPatternPresent(permissions, action, pattern) {
398
+ if (!isRecord(permissions)) {
399
+ return false;
400
+ }
401
+ const list = permissions[action];
402
+ return Array.isArray(list) && list.some((item) => item === pattern);
403
+ }
404
+ function hookResourcesFromContent(content) {
405
+ const direct = parseHooksJsonContent(content, "");
406
+ if (direct.length > 0) {
407
+ return direct;
408
+ }
409
+ const document = parseJsonObject(content);
410
+ if (!document) {
411
+ return [];
412
+ }
413
+ return parseHooksJsonContent(JSON.stringify({ hooks: document }), "");
414
+ }
415
+ function scopeToPermission(content, name) {
416
+ const parsed = parsePermissionResourceName(name);
417
+ if (!parsed) {
418
+ return content;
419
+ }
420
+ const document = parseJsonObject(content);
421
+ if (!document) {
422
+ return content;
423
+ }
424
+ if (permissionPatternPresent(document.permissions, parsed.action, parsed.pattern)) {
425
+ return formatJsonFragment({
426
+ permissions: { [parsed.action]: [parsed.pattern] }
427
+ });
428
+ }
429
+ return formatJsonFragment({ permissions: {} });
430
+ }
431
+ function scopeToHook(content, name) {
432
+ if (!parseJsonObject(content)) {
433
+ return content;
434
+ }
435
+ const needle = name.trim().toLowerCase();
436
+ const match = hookResourcesFromContent(content).find(
437
+ (resource) => resource.name.toLowerCase() === needle
438
+ );
439
+ if (!match) {
440
+ return formatJsonFragment({ hooks: {} });
441
+ }
442
+ const metadata = match.metadata;
443
+ const entry = metadata.hook_entry ?? { command: match.content };
444
+ return formatJsonFragment({
445
+ hooks: { [metadata.event]: [entry] }
446
+ });
447
+ }
448
+ function scopeToEnvVar(content, name) {
449
+ const document = parseJsonObject(content);
450
+ if (!document) {
451
+ return content;
452
+ }
453
+ if (!isRecord(document.env) || !Object.hasOwn(document.env, name)) {
454
+ return formatJsonFragment({ env: {} });
455
+ }
456
+ return formatJsonFragment({ env: { [name]: document.env[name] } });
457
+ }
458
+ function scopeHostConfigToResource(content, resource) {
459
+ if (content === null) {
460
+ return null;
461
+ }
462
+ const name = resource.name.trim();
463
+ if (!name) {
464
+ return content;
465
+ }
466
+ switch (resource.type) {
467
+ case "permission":
468
+ return scopeToPermission(content, name);
469
+ case "hook":
470
+ return scopeToHook(content, name);
471
+ case "env_var":
472
+ return scopeToEnvVar(content, name);
473
+ default:
474
+ return content;
475
+ }
476
+ }
477
+
478
+ // src/services/mcp-resource-detail.ts
479
+ function isRecord2(value) {
480
+ return typeof value === "object" && value !== null && !Array.isArray(value);
481
+ }
482
+ var MCP_SERVERS_WRAPPER_KEYS = [
483
+ "mcpServers",
484
+ "mcp_servers",
485
+ "mcp"
486
+ ];
487
+ function mcpServersWrapperKey(document) {
488
+ for (const key of MCP_SERVERS_WRAPPER_KEYS) {
489
+ if (isRecord2(document[key])) {
490
+ return key;
491
+ }
492
+ }
493
+ return null;
494
+ }
495
+ function mcpServerNamesFromConfig(content) {
496
+ try {
497
+ const document = JSON.parse(content);
498
+ const servers = mcpServersRecord(document);
499
+ return servers ? Object.keys(servers) : [];
500
+ } catch {
501
+ return [];
502
+ }
503
+ }
504
+ function mcpServersRecord(document) {
505
+ if (!isRecord2(document)) {
506
+ return null;
507
+ }
508
+ const key = mcpServersWrapperKey(document);
509
+ if (!key) {
510
+ return null;
511
+ }
512
+ const serversRaw = document[key];
513
+ return isRecord2(serversRaw) ? serversRaw : null;
514
+ }
515
+ function formatMcpServersFragment(wrapper, servers) {
516
+ return `${JSON.stringify({ [wrapper]: servers }, null, 2)}
517
+ `;
518
+ }
519
+ function scopeMcpConfigToServer(content, serverName) {
520
+ if (content === null) {
521
+ return null;
522
+ }
523
+ const name = serverName.trim();
524
+ if (!name) {
525
+ return content;
526
+ }
527
+ try {
528
+ const document = JSON.parse(content);
529
+ if (!isRecord2(document)) {
530
+ return content;
531
+ }
532
+ const wrapper = mcpServersWrapperKey(document);
533
+ if (!wrapper) {
534
+ return content;
535
+ }
536
+ const servers = document[wrapper];
537
+ if (!isRecord2(servers)) {
538
+ return content;
539
+ }
540
+ const scoped = Object.hasOwn(servers, name) ? { [name]: servers[name] } : {};
541
+ return formatMcpServersFragment(wrapper, scoped);
542
+ } catch {
543
+ return content;
544
+ }
545
+ }
546
+
547
+ // src/services/scoped-file-content-delta.ts
548
+ function resourceKey(resource) {
549
+ return `${resource.type}:${resource.name}`;
550
+ }
551
+ function collectIdentities(path, contents) {
552
+ const order = [];
553
+ const seen = /* @__PURE__ */ new Set();
554
+ const add = (resource) => {
555
+ const key = resourceKey(resource);
556
+ if (seen.has(key)) {
557
+ return;
558
+ }
559
+ seen.add(key);
560
+ order.push(resource);
561
+ };
562
+ const mapped = resourceKeyFromManagedPath(path);
563
+ if (mapped) {
564
+ add(mapped);
565
+ }
566
+ const inspectMcp = isMcpConfigManagedPath(path) || isClaudeUserJsonPath(path);
567
+ const inspectHost = isClaudeSettingsPath(path) || isMuseSettingsPath(path);
568
+ for (const content of contents) {
569
+ if (!content) {
570
+ continue;
571
+ }
572
+ if (inspectMcp) {
573
+ for (const name of mcpServerNamesFromConfig(content)) {
574
+ add({ type: "mcp_server", name });
575
+ }
576
+ }
577
+ if (inspectHost) {
578
+ for (const resource of hostConfigResourcesFromContent(content)) {
579
+ add(resource);
580
+ }
581
+ }
582
+ }
583
+ return order;
584
+ }
585
+ function scopedBodies(expected, current, resource) {
586
+ if (resource.type === "mcp_server") {
587
+ return {
588
+ expected: scopeMcpConfigToServer(expected, resource.name) ?? expected,
589
+ current: scopeMcpConfigToServer(current, resource.name)
590
+ };
591
+ }
592
+ if (resource.type === "permission" || resource.type === "hook" || resource.type === "env_var") {
593
+ return {
594
+ expected: scopeHostConfigToResource(expected, resource) ?? expected,
595
+ current: scopeHostConfigToResource(current, resource)
596
+ };
597
+ }
598
+ return { expected, current };
599
+ }
600
+ function scopedContentsDiffer(path, expected, current, resource) {
601
+ const scoped = scopedBodies(expected, current, resource);
602
+ if (scoped.current === null) {
603
+ return true;
604
+ }
605
+ return fileDiffHasContentChange(path, scoped.current, scoped.expected);
606
+ }
607
+ function affectedResourcesForManagedFileDiff(input) {
608
+ const identities = collectIdentities(input.path, [input.expected, input.current]);
609
+ const affected = identities.filter(
610
+ (resource) => scopedContentsDiffer(input.path, input.expected, input.current, resource)
611
+ );
612
+ return affected.sort((left, right) => {
613
+ const typeOrder = left.type.localeCompare(right.type);
614
+ return typeOrder !== 0 ? typeOrder : left.name.localeCompare(right.name);
615
+ });
616
+ }
617
+ function withAffectedResources(change, expected, current) {
618
+ const affected_resources = affectedResourcesForManagedFileDiff({
619
+ path: change.path,
620
+ expected,
621
+ current
622
+ });
623
+ return { ...change, affected_resources };
624
+ }
625
+
626
+ // src/services/global-profile-drift.ts
627
+ var driftCoreComputes = 0;
628
+ function driftCore(fields, harness, homeRoot) {
629
+ const watchedPaths = (fields.expectedApply?.expected_files ?? []).map(
630
+ (file) => join(homeRoot, file.path)
631
+ );
632
+ return { fields, harness, watchedPaths };
633
+ }
634
+ var HOST_PLUGIN_VIEW_PATH = /^(\.claude\/plugins\/cache\/([^/]+)\/([^/]+)\/([^/]+))\//;
635
+ function isHostPluginViewPath(path) {
636
+ return HOST_PLUGIN_VIEW_PATH.test(path.replaceAll("\\", "/"));
637
+ }
638
+ function hostPluginFolderChanges(homeRoot, expectedFiles, known) {
639
+ const folders = /* @__PURE__ */ new Map();
640
+ for (const file of expectedFiles) {
641
+ const match = HOST_PLUGIN_VIEW_PATH.exec(file.path.replaceAll("\\", "/"));
642
+ if (!match?.[1] || !match[2] || !match[3] || !match[4]) continue;
643
+ folders.set(match[1], { marketplace: match[2], name: match[3], version: match[4] });
644
+ }
645
+ if (folders.size === 0) return [];
646
+ const seen = new Set(known.map((change) => change.path));
647
+ const harnesstapDir = harnesstapDirForHomeRoot(homeRoot);
648
+ const changes = [];
649
+ for (const [folder, plugin] of folders) {
650
+ const canonicalDir = hostPluginPackageDir(harnesstapDir, plugin.marketplace, plugin.name, plugin.version);
651
+ const differences = diffHostPluginView({
652
+ homeRoot,
653
+ hostView: join(homeRoot, folder),
654
+ canonicalDir
655
+ });
656
+ const emitted = differences.length > 0 ? emittedHostPluginTree(canonicalDir, "claude-code", plugin.name) : /* @__PURE__ */ new Map();
657
+ for (const difference of differences) {
658
+ const path = `${folder}/${difference.path}`;
659
+ if (seen.has(path)) continue;
660
+ const written = emitted.get(difference.path);
661
+ if (difference.state === "missing" ? !written : matchesEmitted(join(homeRoot, path), written)) {
662
+ continue;
663
+ }
664
+ seen.add(path);
665
+ if (difference.state === "missing") changes.push({ path, type: "deleted" });
666
+ else if (difference.state === "stale") changes.push({ path, type: "modified" });
667
+ else if (difference.state === "modified") {
668
+ changes.push({ path, type: "modified", removal_group: "owned_modified", changed_by: "claude-code" });
669
+ } else {
670
+ changes.push({ path, type: "modified", removal_group: "unmanaged" });
671
+ }
672
+ }
673
+ }
674
+ return changes;
675
+ }
676
+ function matchesEmitted(fullPath, file) {
677
+ if (!file) return false;
678
+ const binary = binaryExpectedFileMatchesDisk(fullPath, file);
679
+ if (binary !== void 0) return binary;
680
+ try {
681
+ return readFileSync(fullPath, "utf-8") === file.content;
682
+ } catch {
683
+ return false;
684
+ }
685
+ }
686
+ function isHarnessTapClaudeMarketplaceFile(path) {
687
+ return path.replaceAll("\\", "/").startsWith(`${HARNESSTAP_CLAUDE_MARKETPLACES_ROOT}/`);
688
+ }
689
+ function claudeChangedMarketplaceEntries(homeRoot, expectedFiles) {
690
+ const wanted = new Set(expectedFiles.map((file) => file.path));
691
+ return [...claudeChangedMarketplaces(homeRoot)].filter((marketplace) => wanted.has(harnessTapClaudeMarketplaceManifestPath(marketplace))).sort().map((marketplace) => ({
692
+ path: CLAUDE_KNOWN_MARKETPLACES_PATH,
693
+ type: "modified",
694
+ removal_group: "owned_modified",
695
+ changed_by: "claude-code",
696
+ detail: `marketplace ${marketplace}`
697
+ }));
698
+ }
699
+ function keptContentDiff(path, keptModified, keptUnmanaged) {
700
+ if (keptModified.has(path)) {
701
+ return { path, type: "modified", removal_group: "owned_modified" };
702
+ }
703
+ if (keptUnmanaged.has(path)) {
704
+ return { path, type: "modified", removal_group: "unmanaged" };
705
+ }
706
+ return { path, type: "modified" };
707
+ }
708
+ function isMissingExpectedFileTransparent(homeRoot, path, expectedPathsByResource, scopeByResource, harnesses) {
709
+ const mapped = resourceKeyFromManagedPath(path);
710
+ if (!mapped) {
711
+ return true;
712
+ }
713
+ const key = `${mapped.type}:${mapped.name}`;
714
+ const siblings = expectedPathsByResource.get(key) ?? [];
715
+ const onDiskSiblingPaths = siblings.filter(
716
+ (sibling) => sibling !== path && readGlobalFile(homeRoot, sibling) !== null
717
+ );
718
+ for (const live of liveSkillCopiesForMissingPath(path, harnesses, (candidate) => readGlobalFile(homeRoot, candidate) !== null)) {
719
+ if (!onDiskSiblingPaths.includes(live)) onDiskSiblingPaths.push(live);
720
+ }
721
+ return isTransparentCrossHarnessGap({
722
+ path,
723
+ onDiskSiblingPaths,
724
+ scope: scopeByResource.get(key)
725
+ });
726
+ }
727
+ function readGlobalFile(homeRoot, relativePath) {
728
+ const fullPath = join(homeRoot, relativePath);
729
+ if (!inStatusComputation()) return readGlobalFileUncached(fullPath);
730
+ if (!existsSync(fullPath)) return null;
731
+ return readDiskTextOnce(fullPath);
732
+ }
733
+ function readGlobalFileUncached(fullPath) {
734
+ if (!existsSync(fullPath)) {
735
+ return null;
736
+ }
737
+ try {
738
+ return readFileSync(fullPath, "utf-8");
739
+ } catch {
740
+ return null;
741
+ }
742
+ }
743
+ function pluginIdsMatch(left, right) {
744
+ if (left.length !== right.length) {
745
+ return false;
746
+ }
747
+ return left.every((pluginId, index) => pluginId === right[index]);
748
+ }
749
+ function declaredMcpFromExpectedApply(expectedApply) {
750
+ return declaredMcpFromExpectedFiles(
751
+ expectedApply.harnesses,
752
+ expectedApply.expected_files ?? []
753
+ );
754
+ }
755
+ function declaredMcpNamesFromMergedPlugins(pluginIds) {
756
+ const merged = mergePluginsForApply(pluginIds);
757
+ const names = merged.resources.filter((resource) => resource.type === "mcp_server").map((resource) => resource.name);
758
+ return {
759
+ "claude-code": names,
760
+ cursor: names
761
+ };
762
+ }
763
+ function buildBaseStatusFields(input) {
764
+ const asOf = (/* @__PURE__ */ new Date()).toISOString();
765
+ const homeRoot = resolveHomeRoot();
766
+ const ownedFiles = traceSpan("db.owned-files", () => collectOwnedGlobalProfileFiles(input.snapshotId));
767
+ const blockingChanges = input.changes.filter((change) => !driftChangeIsKept(change));
768
+ const { owned, nonOwned } = classifyGlobalDriftChanges(blockingChanges, ownedFiles);
769
+ const declaredPins = input.pluginIds && input.pluginIds.length > 0 ? traceSpan("base.merge-plugins", () => mergePluginsForApply(input.pluginIds ?? []).pluginPins) : [];
770
+ const declaredFromExpected = input.expectedApply ? declaredMcpFromExpectedApply(input.expectedApply) : null;
771
+ const declaredMcpByHarness = declaredFromExpected?.namesByHarness ?? (input.pluginIds ? declaredMcpNamesFromMergedPlugins(input.pluginIds) : { "claude-code": [], cursor: [] });
772
+ const filesOnlyPinRefs = input.expectedApply?.resolution ? {
773
+ "claude-code": filesOnlyMarketplacePinRefs(input.expectedApply.resolution, "claude-code"),
774
+ cursor: filesOnlyMarketplacePinRefs(input.expectedApply.resolution, "cursor")
775
+ } : void 0;
776
+ const harnesses = traceSpan("base.harness-live-status", () => buildHarnessLiveStatusMap({
777
+ depth: input.depth,
778
+ homeRoot,
779
+ declaredPins,
780
+ ...filesOnlyPinRefs ? { filesOnlyPinRefs } : {},
781
+ declaredMcpByHarness,
782
+ ...declaredFromExpected ? { expectedMcpConfigsByHarness: declaredFromExpected.configsByHarness } : {}
783
+ }));
784
+ const { missingPlugins, missingMcp } = input.depth === "full" ? countMissingHarnessRows(harnesses) : { missingPlugins: 0, missingMcp: 0 };
785
+ const contents = input.activeProfile ? traceSpan("base.profile-contents", () => buildProfileContents(input.activeProfile ?? "")) : null;
786
+ const hostManaged = input.depth === "full" ? traceSpan(
787
+ "base.host-managed",
788
+ () => buildHostManagedStatus({
789
+ homeRoot,
790
+ profileSkills: profileSkillNameMap(contents?.resources ?? [])
791
+ })
792
+ ) : void 0;
793
+ const projectDrift = traceSpan("base.project-drift", () => resolveProjectDriftSummary(input.projectPath));
794
+ const panel = computeGlobalProfilePanelStatus({
795
+ depth: input.depth,
796
+ applied: input.applied,
797
+ activeProfile: input.activeProfile,
798
+ stackInSync: input.stackInSync,
799
+ ownedDriftCount: owned.length,
800
+ nonOwnedDriftCount: nonOwned.length,
801
+ missingPluginCount: missingPlugins,
802
+ missingMcpCount: missingMcp,
803
+ projectDrift,
804
+ warning: input.warning,
805
+ hostManagedCollisionCount: hostManaged?.cursor?.collisions.length ?? 0
806
+ });
807
+ const driftSummary = {
808
+ global: {
809
+ status: !input.applied ? "pending" : input.hasDrift ? "drifted" : "clean",
810
+ owned_changes: owned.length,
811
+ non_owned_changes: nonOwned.length
812
+ },
813
+ ...projectDrift ? { project: projectDrift } : {}
814
+ };
815
+ return {
816
+ active_profile: input.activeProfile,
817
+ profile_exists: input.profileExists,
818
+ applied: input.applied,
819
+ snapshot_id: input.snapshotId,
820
+ snapshot_at: input.snapshotAt,
821
+ stack_in_sync: input.stackInSync,
822
+ has_drift: input.hasDrift,
823
+ changes: input.changes,
824
+ ...input.warning ? { warning: input.warning } : {},
825
+ depth: input.depth,
826
+ as_of: asOf,
827
+ panel,
828
+ harnesses,
829
+ drift_summary: driftSummary,
830
+ contents,
831
+ ...hostManaged ? { host_managed: hostManaged } : {}
832
+ };
833
+ }
834
+ async function finalizeGlobalProfileStatus(fields, harness) {
835
+ const status = traceSpan("base", () => buildBaseStatusFields(fields));
836
+ if (fields.depth !== "full" || !status.active_profile || isEmptyBuiltinProfile(status.active_profile)) {
837
+ return status;
838
+ }
839
+ try {
840
+ const notStaged = await traceSpan(
841
+ "not-staged",
842
+ () => detectNotStagedProfileResources({
843
+ profileSelector: status.active_profile ?? "",
844
+ scope: "home",
845
+ ...harness ? { harness } : {}
846
+ })
847
+ );
848
+ return {
849
+ ...status,
850
+ untracked_resource_count: notStaged.length,
851
+ not_staged_count: notStaged.length
852
+ };
853
+ } catch {
854
+ return status;
855
+ }
856
+ }
857
+ async function loadGlobalProfileStatusSnapshot(input = {}) {
858
+ const depth = input.depth ?? "full";
859
+ return runInStatusComputation(
860
+ () => runTracedStatus(`depth=${depth} harness=${input.harness ?? "*"}`, async () => {
861
+ const loaded = await traceSpan("drift-core", () => loadDriftCore(input));
862
+ const projected = await traceSpan(
863
+ "finalize",
864
+ () => finalizeGlobalProfileStatus({ ...loaded.fields, depth }, loaded.harness)
865
+ );
866
+ return { value: projected, watchedPaths: loaded.watchedPaths };
867
+ })
868
+ );
869
+ }
870
+ async function loadDriftCore(input) {
871
+ driftCoreComputes += 1;
872
+ const homeRoot = resolveHomeRoot();
873
+ const activeProfile = getActiveProfileName() ?? null;
874
+ if (!activeProfile) {
875
+ return driftCore(
876
+ {
877
+ activeProfile: null,
878
+ profileExists: false,
879
+ applied: false,
880
+ snapshotId: null,
881
+ snapshotAt: null,
882
+ stackInSync: false,
883
+ hasDrift: false,
884
+ changes: [],
885
+ projectPath: input.projectPath
886
+ },
887
+ input.harness,
888
+ homeRoot
889
+ );
890
+ }
891
+ const plugin = traceSpan("db.resolve-profile", () => resolvePluginSelector(activeProfile));
892
+ if (!plugin) {
893
+ if (isEmptyBuiltinProfile(activeProfile)) {
894
+ const latestSnapshot2 = getLatestGlobalApplySnapshotForProfile(activeProfile);
895
+ let expectedApply2;
896
+ try {
897
+ expectedApply2 = await clearGlobalProfileApply({
898
+ dryRun: true,
899
+ harness: input.harness,
900
+ conflictPolicy: "replace",
901
+ pull: false
902
+ });
903
+ } catch (error) {
904
+ return driftCore({
905
+ activeProfile,
906
+ profileExists: true,
907
+ applied: Boolean(latestSnapshot2),
908
+ snapshotId: latestSnapshot2?.id ?? null,
909
+ snapshotAt: latestSnapshot2?.created_at ?? null,
910
+ stackInSync: false,
911
+ hasDrift: true,
912
+ changes: [],
913
+ warning: error instanceof Error ? error.message : String(error),
914
+ projectPath: input.projectPath,
915
+ pluginIds: []
916
+ }, input.harness, homeRoot);
917
+ }
918
+ const stackInSync2 = latestSnapshot2 ? pluginIdsMatch(latestSnapshot2.plugin_ids, expectedApply2.configured_plugin_ids) : false;
919
+ const applied2 = Boolean(latestSnapshot2);
920
+ const hasDrift2 = !applied2 || !stackInSync2;
921
+ return driftCore({
922
+ activeProfile,
923
+ profileExists: true,
924
+ applied: applied2,
925
+ snapshotId: latestSnapshot2?.id ?? null,
926
+ snapshotAt: latestSnapshot2?.created_at ?? null,
927
+ stackInSync: stackInSync2,
928
+ hasDrift: hasDrift2,
929
+ changes: [],
930
+ projectPath: input.projectPath,
931
+ expectedApply: expectedApply2,
932
+ pluginIds: []
933
+ }, input.harness, homeRoot);
934
+ }
935
+ return driftCore({
936
+ activeProfile,
937
+ profileExists: false,
938
+ applied: false,
939
+ snapshotId: null,
940
+ snapshotAt: null,
941
+ stackInSync: false,
942
+ hasDrift: true,
943
+ changes: [],
944
+ warning: `missing plugin "${activeProfile}"`,
945
+ projectPath: input.projectPath
946
+ }, input.harness, homeRoot);
947
+ }
948
+ if (!isProfilePlugin(plugin)) {
949
+ return driftCore({
950
+ activeProfile,
951
+ profileExists: true,
952
+ applied: false,
953
+ snapshotId: null,
954
+ snapshotAt: null,
955
+ stackInSync: false,
956
+ hasDrift: true,
957
+ changes: [],
958
+ warning: `plugin "${plugin.name}" is not tagged as a profile`,
959
+ projectPath: input.projectPath
960
+ }, input.harness, homeRoot);
961
+ }
962
+ const latestSnapshot = getLatestGlobalApplySnapshotForProfile(activeProfile);
963
+ const pluginIds = collectProfilePluginIds(plugin);
964
+ let expectedApply;
965
+ try {
966
+ expectedApply = await traceSpan(
967
+ "dry-run",
968
+ () => applyProfilePlugin(activeProfile, {
969
+ dryRun: true,
970
+ harness: input.harness,
971
+ conflictPolicy: "replace",
972
+ pull: false,
973
+ pinSkillEmits: false,
974
+ mergeLiveSkillMarkdown: false
975
+ })
976
+ );
977
+ traceCount("dry-run", "expected_files", expectedApply.expected_files?.length ?? 0);
978
+ } catch (error) {
979
+ return driftCore({
980
+ activeProfile,
981
+ profileExists: true,
982
+ applied: Boolean(latestSnapshot),
983
+ snapshotId: latestSnapshot?.id ?? null,
984
+ snapshotAt: latestSnapshot?.created_at ?? null,
985
+ stackInSync: false,
986
+ hasDrift: true,
987
+ changes: [],
988
+ warning: error instanceof Error ? error.message : String(error),
989
+ projectPath: input.projectPath,
990
+ pluginIds
991
+ }, input.harness, homeRoot);
992
+ }
993
+ const stackInSync = latestSnapshot ? pluginIdsMatch(latestSnapshot.plugin_ids, expectedApply.configured_plugin_ids) : false;
994
+ const changes = [];
995
+ const keptModified = new Set(expectedApply.removals?.owned_modified ?? []);
996
+ const keptUnmanaged = new Set(expectedApply.removals?.unmanaged ?? []);
997
+ const scopeByResource = resourceScopesForPlugins(pluginIds);
998
+ const expectedPathsByResource = /* @__PURE__ */ new Map();
999
+ for (const file of expectedApply.expected_files ?? []) {
1000
+ const mapped = resourceKeyFromManagedPath(file.path);
1001
+ if (!mapped) {
1002
+ continue;
1003
+ }
1004
+ const key = `${mapped.type}:${mapped.name}`;
1005
+ const paths = expectedPathsByResource.get(key) ?? [];
1006
+ paths.push(file.path);
1007
+ expectedPathsByResource.set(key, paths);
1008
+ }
1009
+ traceSpan("drift.compare-files", () => {
1010
+ for (const file of expectedApply.expected_files ?? []) {
1011
+ if (isNativeAgentPluginCachePath(file.path)) continue;
1012
+ if (isHostPluginViewPath(file.path)) continue;
1013
+ if (binaryExpectedFileMatchesDisk(join(homeRoot, file.path), file)) continue;
1014
+ const current = readGlobalFile(homeRoot, file.path);
1015
+ const owned = listMaterializationsForRootPath(homeRoot, file.path);
1016
+ if (current === null) {
1017
+ if (owned.length === 0 && isMissingExpectedFileTransparent(
1018
+ homeRoot,
1019
+ file.path,
1020
+ expectedPathsByResource,
1021
+ scopeByResource,
1022
+ expectedApply.harnesses
1023
+ )) {
1024
+ continue;
1025
+ }
1026
+ changes.push(
1027
+ withAffectedResources({ path: file.path, type: "deleted" }, file.content, null)
1028
+ );
1029
+ continue;
1030
+ }
1031
+ if (owned.length > 0) {
1032
+ const diskHash = hashOnDiskFile(join(homeRoot, file.path));
1033
+ if (owned.some((row) => row.generated_hash === diskHash)) {
1034
+ continue;
1035
+ }
1036
+ if (fileContentsEquivalentForDrift(file.path, current, file.content)) {
1037
+ continue;
1038
+ }
1039
+ if (isHarnessTapClaudeMarketplaceFile(file.path)) {
1040
+ changes.push({ path: file.path, type: "modified", removal_group: "owned_modified", changed_by: "claude-code" });
1041
+ continue;
1042
+ }
1043
+ changes.push(
1044
+ withAffectedResources(
1045
+ keptContentDiff(file.path, keptModified, keptUnmanaged),
1046
+ file.content,
1047
+ current
1048
+ )
1049
+ );
1050
+ continue;
1051
+ }
1052
+ if (!fileContentsEquivalentForDrift(file.path, current, file.content)) {
1053
+ changes.push(
1054
+ withAffectedResources(
1055
+ keptContentDiff(file.path, keptModified, keptUnmanaged),
1056
+ file.content,
1057
+ current
1058
+ )
1059
+ );
1060
+ }
1061
+ }
1062
+ });
1063
+ traceSpan("drift.host-plugin-folders", () => {
1064
+ changes.push(...hostPluginFolderChanges(homeRoot, expectedApply.expected_files ?? [], changes));
1065
+ });
1066
+ changes.push(...claudeChangedMarketplaceEntries(homeRoot, expectedApply.expected_files ?? []));
1067
+ const applied = Boolean(latestSnapshot);
1068
+ const blockingChanges = changes.filter((change) => !driftChangeIsKept(change));
1069
+ const hasDrift = !applied || !stackInSync || blockingChanges.length > 0;
1070
+ return driftCore(
1071
+ {
1072
+ activeProfile,
1073
+ profileExists: true,
1074
+ applied,
1075
+ snapshotId: latestSnapshot?.id ?? null,
1076
+ snapshotAt: latestSnapshot?.created_at ?? null,
1077
+ stackInSync,
1078
+ hasDrift,
1079
+ changes,
1080
+ projectPath: input.projectPath,
1081
+ expectedApply,
1082
+ pluginIds
1083
+ },
1084
+ input.harness,
1085
+ homeRoot
1086
+ );
1087
+ }
1088
+
1089
+ // src/services/status-refresh-worker.ts
1090
+ function applyEnv(request) {
1091
+ if (request.home) {
1092
+ process.env.HOME = request.home;
1093
+ setHomeRootOverride(request.home);
1094
+ }
1095
+ if (request.userProfile) process.env.USERPROFILE = request.userProfile;
1096
+ if (request.harnesstapHome) {
1097
+ process.env.HARNESSTAP_HOME = request.harnesstapHome;
1098
+ } else if (request.home) {
1099
+ process.env.HARNESSTAP_HOME = join2(request.home, ".harnesstap");
1100
+ } else {
1101
+ delete process.env.HARNESSTAP_HOME;
1102
+ }
1103
+ }
1104
+ function depthOf(depth) {
1105
+ return depth === "fast" ? "fast" : "full";
1106
+ }
1107
+ var chain = Promise.resolve();
1108
+ parentPort?.on("message", (request) => {
1109
+ if (request.op === "pause-watches") {
1110
+ closeStatusWatches();
1111
+ return;
1112
+ }
1113
+ const requestId = request.id;
1114
+ if (requestId === void 0) return;
1115
+ const run = chain.then(async () => {
1116
+ try {
1117
+ applyEnv(request);
1118
+ releaseStatusWatchesForOtherHomes(resolveHomeRoot());
1119
+ if (request.delayMs && request.delayMs > 0) {
1120
+ const shared = new SharedArrayBuffer(4);
1121
+ Atomics.wait(new Int32Array(shared), 0, 0, request.delayMs);
1122
+ }
1123
+ const computeStarted = statusTraceEnabled ? performance.now() : 0;
1124
+ const loaded = await loadGlobalProfileStatusSnapshot({
1125
+ depth: depthOf(request.depth),
1126
+ harness: request.harness,
1127
+ projectPath: request.projectPath
1128
+ });
1129
+ const computeMs = statusTraceEnabled ? performance.now() - computeStarted : 0;
1130
+ const collected = collectFingerprintPaths(request.projectPath, loaded.watchedPaths);
1131
+ const jsonStarted = statusTraceEnabled ? performance.now() : 0;
1132
+ const json = JSON.stringify(loaded.value);
1133
+ const value = JSON.parse(json);
1134
+ const jsonMs = statusTraceEnabled ? performance.now() - jsonStarted : 0;
1135
+ parentPort?.postMessage({
1136
+ id: requestId,
1137
+ ok: true,
1138
+ ...statusTraceEnabled ? { trace: { computeMs, jsonMs, bytes: json.length } } : {},
1139
+ value,
1140
+ watchedPaths: loaded.watchedPaths,
1141
+ watchPaths: collected.paths
1142
+ });
1143
+ const created = armStatusWatches(collected.paths, collected.recursive, resolveHomeRoot());
1144
+ parentPort?.postMessage({ op: "watch-report", created });
1145
+ } catch (error) {
1146
+ parentPort?.postMessage({
1147
+ id: requestId,
1148
+ ok: false,
1149
+ error: describeStatusRefreshError(error)
1150
+ });
1151
+ }
1152
+ });
1153
+ chain = run.then(() => void 0, () => void 0);
1154
+ });
1155
+ //# sourceMappingURL=status-refresh-worker.js.map