harnesstap 1.3.2 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/README.md +4 -0
  2. package/dist/apply-FTAIL3X3.js +50 -0
  3. package/dist/{approve-L7IFSYBO.js → approve-R6AWQB3I.js} +12 -16
  4. package/dist/{approve-L7IFSYBO.js.map → approve-R6AWQB3I.js.map} +1 -1
  5. package/dist/{audit-PBJDK7A4.js → audit-2HNKFPSU.js} +26 -39
  6. package/dist/{audit-PBJDK7A4.js.map → audit-2HNKFPSU.js.map} +1 -1
  7. package/dist/{auth-OM73RLNS.js → auth-C54KRLNF.js} +17 -21
  8. package/dist/{auth-OM73RLNS.js.map → auth-C54KRLNF.js.map} +1 -1
  9. package/dist/bin.js +13 -34
  10. package/dist/bin.js.map +1 -1
  11. package/dist/{chunk-R4PTE774.js → chunk-2XDYQXP2.js} +34 -41
  12. package/dist/chunk-2XDYQXP2.js.map +1 -0
  13. package/dist/{chunk-G5RWVZZ7.js → chunk-3277RVZT.js} +5 -7
  14. package/dist/{chunk-G5RWVZZ7.js.map → chunk-3277RVZT.js.map} +1 -1
  15. package/dist/{chunk-6JMVGKMD.js → chunk-3Q72LZPJ.js} +936 -528
  16. package/dist/chunk-3Q72LZPJ.js.map +1 -0
  17. package/dist/{chunk-U472S6IB.js → chunk-42E2MPES.js} +19 -27
  18. package/dist/chunk-42E2MPES.js.map +1 -0
  19. package/dist/{chunk-CZ4T75PP.js → chunk-5HACBPK2.js} +622 -252
  20. package/dist/chunk-5HACBPK2.js.map +1 -0
  21. package/dist/{chunk-IHW4PCDT.js → chunk-6FXJIKEG.js} +6 -6
  22. package/dist/{chunk-OPVIX7E4.js → chunk-A3TZT4WT.js} +6 -2
  23. package/dist/chunk-A3TZT4WT.js.map +1 -0
  24. package/dist/chunk-BUA7WFI4.js +39327 -0
  25. package/dist/chunk-BUA7WFI4.js.map +1 -0
  26. package/dist/{chunk-IAZNF35S.js → chunk-CBSDMRMY.js} +2 -2
  27. package/dist/{chunk-YVJQ2QDG.js → chunk-CR2TYMKC.js} +65 -55
  28. package/dist/chunk-CR2TYMKC.js.map +1 -0
  29. package/dist/{chunk-VQVUJYYY.js → chunk-CWXCZBJR.js} +76 -6
  30. package/dist/chunk-CWXCZBJR.js.map +1 -0
  31. package/dist/{chunk-AVZOFMJX.js → chunk-D7R577XZ.js} +381 -138
  32. package/dist/chunk-D7R577XZ.js.map +1 -0
  33. package/dist/{chunk-3EGM4IUI.js → chunk-EPXAOEBB.js} +6 -6
  34. package/dist/{chunk-64R32MG2.js → chunk-GZU4LVFF.js} +179 -26
  35. package/dist/chunk-GZU4LVFF.js.map +1 -0
  36. package/dist/chunk-HV3ENT2F.js +61 -0
  37. package/dist/chunk-HV3ENT2F.js.map +1 -0
  38. package/dist/{chunk-XCPWLGPB.js → chunk-K4UDZUJ2.js} +2 -2
  39. package/dist/{chunk-OQ4KBUN2.js → chunk-L6BJCRBU.js} +13 -16
  40. package/dist/chunk-L6BJCRBU.js.map +1 -0
  41. package/dist/{chunk-AFKCNFPP.js → chunk-M6FEDSHY.js} +16 -15
  42. package/dist/chunk-M6FEDSHY.js.map +1 -0
  43. package/dist/chunk-M7PHQ3UC.js +31491 -0
  44. package/dist/chunk-M7PHQ3UC.js.map +1 -0
  45. package/dist/{chunk-FBYAIBHP.js → chunk-MHLAIGIM.js} +2 -2
  46. package/dist/{chunk-ENHDEB7Z.js → chunk-MHMFF6A5.js} +5 -7
  47. package/dist/{chunk-ENHDEB7Z.js.map → chunk-MHMFF6A5.js.map} +1 -1
  48. package/dist/chunk-MKLJBW5N.js +14 -0
  49. package/dist/{chunk-XRXFJTAT.js → chunk-MQCAPCAF.js} +17 -26
  50. package/dist/chunk-MQCAPCAF.js.map +1 -0
  51. package/dist/{chunk-UEHDEADL.js → chunk-MQCH3YZ5.js} +15 -13
  52. package/dist/chunk-MQCH3YZ5.js.map +1 -0
  53. package/dist/chunk-OHZNDV4A.js +1707 -0
  54. package/dist/chunk-OHZNDV4A.js.map +1 -0
  55. package/dist/{chunk-LGWUTV5Q.js → chunk-OWE3OSX6.js} +11 -13
  56. package/dist/{chunk-LGWUTV5Q.js.map → chunk-OWE3OSX6.js.map} +1 -1
  57. package/dist/{chunk-EY4ES5MG.js → chunk-PCNHBMBU.js} +3 -5
  58. package/dist/{chunk-EY4ES5MG.js.map → chunk-PCNHBMBU.js.map} +1 -1
  59. package/dist/{chunk-YRGM7RAD.js → chunk-QGTDQNVV.js} +7 -11
  60. package/dist/{chunk-YRGM7RAD.js.map → chunk-QGTDQNVV.js.map} +1 -1
  61. package/dist/{chunk-BXSS2S4W.js → chunk-R27VZIF6.js} +2 -2
  62. package/dist/{chunk-TQ2NA4Z4.js → chunk-R4NV3Q7G.js} +8 -2
  63. package/dist/chunk-R4NV3Q7G.js.map +1 -0
  64. package/dist/{chunk-FUV7QYBS.js → chunk-R6VFJKZB.js} +86 -319
  65. package/dist/chunk-R6VFJKZB.js.map +1 -0
  66. package/dist/{chunk-QNAIDM6W.js → chunk-RQLVXJH2.js} +132 -4
  67. package/dist/chunk-RQLVXJH2.js.map +1 -0
  68. package/dist/{chunk-JQOKQKQT.js → chunk-S2D5PWAO.js} +2 -2
  69. package/dist/{chunk-JJJJ2RAD.js → chunk-T4EKNX2Q.js} +71 -11
  70. package/dist/chunk-T4EKNX2Q.js.map +1 -0
  71. package/dist/{chunk-GWQVYGRD.js → chunk-TERYL7JH.js} +118 -78
  72. package/dist/chunk-TERYL7JH.js.map +1 -0
  73. package/dist/chunk-UC27MQ3T.js +1920 -0
  74. package/dist/chunk-UC27MQ3T.js.map +1 -0
  75. package/dist/chunk-UEA4NCY2.js +106 -0
  76. package/dist/chunk-UEA4NCY2.js.map +1 -0
  77. package/dist/{chunk-WXRPQICX.js → chunk-UK2IV2ZQ.js} +2 -2
  78. package/dist/{chunk-MFCZN253.js → chunk-UZCAYOIQ.js} +8 -10
  79. package/dist/{chunk-MFCZN253.js.map → chunk-UZCAYOIQ.js.map} +1 -1
  80. package/dist/{chunk-IKAGGJEO.js → chunk-V4UNYSZO.js} +558 -18
  81. package/dist/chunk-V4UNYSZO.js.map +1 -0
  82. package/dist/chunk-VAPCU2FX.js +70 -0
  83. package/dist/chunk-VAPCU2FX.js.map +1 -0
  84. package/dist/{chunk-Y2JGMICO.js → chunk-WGVU3LA5.js} +25 -33
  85. package/dist/chunk-WGVU3LA5.js.map +1 -0
  86. package/dist/{chunk-UNRR4KH5.js → chunk-WQ3F4O7U.js} +20 -14
  87. package/dist/chunk-WQ3F4O7U.js.map +1 -0
  88. package/dist/chunk-XNS4I3W6.js +102 -0
  89. package/dist/chunk-XNS4I3W6.js.map +1 -0
  90. package/dist/{chunk-LDVXYN6F.js → chunk-Y4I7ZCAE.js} +178 -135
  91. package/dist/chunk-Y4I7ZCAE.js.map +1 -0
  92. package/dist/{chunk-6I3RY6R5.js → chunk-ZKMSHLXP.js} +11 -15
  93. package/dist/{chunk-6I3RY6R5.js.map → chunk-ZKMSHLXP.js.map} +1 -1
  94. package/dist/{compile-SDOASKGL.js → compile-B2QG6BAQ.js} +37 -54
  95. package/dist/{compile-SDOASKGL.js.map → compile-B2QG6BAQ.js.map} +1 -1
  96. package/dist/{config-4VZTVZKF.js → config-D3F6ICZ2.js} +21 -39
  97. package/dist/{config-4VZTVZKF.js.map → config-D3F6ICZ2.js.map} +1 -1
  98. package/dist/cursor-local-install-4HDIBX22.js +94 -0
  99. package/dist/cursor-local-install-4HDIBX22.js.map +1 -0
  100. package/dist/cursor-local-install-LL367GZY.js +94 -0
  101. package/dist/cursor-local-install-LL367GZY.js.map +1 -0
  102. package/dist/{doctor-HH6CFBRQ.js → doctor-QSGETVDE.js} +19 -23
  103. package/dist/doctor-QSGETVDE.js.map +1 -0
  104. package/dist/{environment-K7YMJJYN.js → environment-2JS4RWQA.js} +69 -88
  105. package/dist/environment-2JS4RWQA.js.map +1 -0
  106. package/dist/{github-A6TYG7WS.js → github-JXSTHLY2.js} +14 -15
  107. package/dist/{github-A6TYG7WS.js.map → github-JXSTHLY2.js.map} +1 -1
  108. package/dist/{harness-772XBFZQ.js → harness-GBI3AMLH.js} +48 -65
  109. package/dist/{harness-772XBFZQ.js.map → harness-GBI3AMLH.js.map} +1 -1
  110. package/dist/{help-QR4VTJZU.js → help-EC52ERIE.js} +43 -52
  111. package/dist/help-EC52ERIE.js.map +1 -0
  112. package/dist/{help-TLHNRJJ6.js → help-VIRMBOPJ.js} +73 -551
  113. package/dist/help-VIRMBOPJ.js.map +1 -0
  114. package/dist/host-plugin-view-kept-XKHD6NGU.js +139 -0
  115. package/dist/host-plugin-view-kept-XKHD6NGU.js.map +1 -0
  116. package/dist/index.d.ts +7 -0
  117. package/dist/index.js +10 -22
  118. package/dist/{init-AOKFPZHG.js → init-OK3K6ILG.js} +49 -70
  119. package/dist/init-OK3K6ILG.js.map +1 -0
  120. package/dist/live-read-cache-ESQQJBNS.js +13 -0
  121. package/dist/live-read-cache-WPUFHVMZ.js +12 -0
  122. package/dist/{lock-INAXNLMC.js → lock-AA2F4I3K.js} +13 -16
  123. package/dist/{lock-INAXNLMC.js.map → lock-AA2F4I3K.js.map} +1 -1
  124. package/dist/{marketplace-TUVLLPBG.js → marketplace-QUYCV23F.js} +75 -94
  125. package/dist/marketplace-QUYCV23F.js.map +1 -0
  126. package/dist/{mcp-MMWGRASN.js → mcp-CIHSR4DD.js} +35 -52
  127. package/dist/{mcp-MMWGRASN.js.map → mcp-CIHSR4DD.js.map} +1 -1
  128. package/dist/{migrate-55S4XODX.js → migrate-TQPEZYS5.js} +148 -74
  129. package/dist/migrate-TQPEZYS5.js.map +1 -0
  130. package/dist/notifications-TAELTPDW.js +154 -0
  131. package/dist/notifications-TAELTPDW.js.map +1 -0
  132. package/dist/open-D3GWGDSQ.js +20 -0
  133. package/dist/{pack-VZIBS42E.js → pack-VUO4UBWL.js} +12 -22
  134. package/dist/{pack-VZIBS42E.js.map → pack-VUO4UBWL.js.map} +1 -1
  135. package/dist/plugin-L3466DHK.js +47 -0
  136. package/dist/plugin-from-project-U5UGKTJH.js +15 -0
  137. package/dist/plugin-from-project-U5UGKTJH.js.map +1 -0
  138. package/dist/{policy-P3HGLEZS.js → policy-Z5TL4N3V.js} +11 -15
  139. package/dist/{policy-P3HGLEZS.js.map → policy-Z5TL4N3V.js.map} +1 -1
  140. package/dist/{profile-STS3CZUK.js → profile-QFI7SL3S.js} +167 -143
  141. package/dist/profile-QFI7SL3S.js.map +1 -0
  142. package/dist/{project-R4DGM3ZG.js → project-3KR3EPYR.js} +506 -94
  143. package/dist/project-3KR3EPYR.js.map +1 -0
  144. package/dist/{resource-GJVEDXVZ.js → resource-45BPRQ7V.js} +66 -63
  145. package/dist/resource-45BPRQ7V.js.map +1 -0
  146. package/dist/status-refresh-worker.js +1155 -0
  147. package/dist/status-refresh-worker.js.map +1 -0
  148. package/dist/{version-FUHV4O6U.js → version-QUJZGTZ5.js} +3 -3
  149. package/dist/version-QUJZGTZ5.js.map +1 -0
  150. package/package.json +17 -11
  151. package/dist/apply-Q5SFF3FY.js +0 -67
  152. package/dist/chunk-24V5ZSIF.js +0 -658
  153. package/dist/chunk-24V5ZSIF.js.map +0 -1
  154. package/dist/chunk-2H7UOFLK.js +0 -11
  155. package/dist/chunk-3JOPDYQD.js +0 -730
  156. package/dist/chunk-3JOPDYQD.js.map +0 -1
  157. package/dist/chunk-555XE3NJ.js +0 -60
  158. package/dist/chunk-555XE3NJ.js.map +0 -1
  159. package/dist/chunk-64R32MG2.js.map +0 -1
  160. package/dist/chunk-6JMVGKMD.js.map +0 -1
  161. package/dist/chunk-6ZWKF3YZ.js +0 -7795
  162. package/dist/chunk-6ZWKF3YZ.js.map +0 -1
  163. package/dist/chunk-AFKCNFPP.js.map +0 -1
  164. package/dist/chunk-AUWWL6KX.js +0 -296
  165. package/dist/chunk-AUWWL6KX.js.map +0 -1
  166. package/dist/chunk-AVZOFMJX.js.map +0 -1
  167. package/dist/chunk-CZ4T75PP.js.map +0 -1
  168. package/dist/chunk-FUV7QYBS.js.map +0 -1
  169. package/dist/chunk-GWQVYGRD.js.map +0 -1
  170. package/dist/chunk-HENOKIBB.js +0 -346
  171. package/dist/chunk-HENOKIBB.js.map +0 -1
  172. package/dist/chunk-HWL67OCJ.js +0 -238
  173. package/dist/chunk-HWL67OCJ.js.map +0 -1
  174. package/dist/chunk-IKAGGJEO.js.map +0 -1
  175. package/dist/chunk-JJJJ2RAD.js.map +0 -1
  176. package/dist/chunk-JRFUTIEH.js +0 -426
  177. package/dist/chunk-JRFUTIEH.js.map +0 -1
  178. package/dist/chunk-KJIFZLHN.js +0 -11066
  179. package/dist/chunk-KJIFZLHN.js.map +0 -1
  180. package/dist/chunk-LDVXYN6F.js.map +0 -1
  181. package/dist/chunk-MHOTXMD2.js +0 -430
  182. package/dist/chunk-MHOTXMD2.js.map +0 -1
  183. package/dist/chunk-NAGAJ5UM.js +0 -145
  184. package/dist/chunk-NAGAJ5UM.js.map +0 -1
  185. package/dist/chunk-NEPUP33Q.js +0 -35
  186. package/dist/chunk-NEPUP33Q.js.map +0 -1
  187. package/dist/chunk-OPVIX7E4.js.map +0 -1
  188. package/dist/chunk-OQ4KBUN2.js.map +0 -1
  189. package/dist/chunk-OXVCYRZB.js +0 -491
  190. package/dist/chunk-OXVCYRZB.js.map +0 -1
  191. package/dist/chunk-PJQAMC6L.js +0 -183
  192. package/dist/chunk-PJQAMC6L.js.map +0 -1
  193. package/dist/chunk-PW5QXRBA.js +0 -1173
  194. package/dist/chunk-PW5QXRBA.js.map +0 -1
  195. package/dist/chunk-QNAIDM6W.js.map +0 -1
  196. package/dist/chunk-R4PTE774.js.map +0 -1
  197. package/dist/chunk-S2E4KSYW.js +0 -610
  198. package/dist/chunk-S2E4KSYW.js.map +0 -1
  199. package/dist/chunk-SNVAMWB7.js +0 -40
  200. package/dist/chunk-SNVAMWB7.js.map +0 -1
  201. package/dist/chunk-TQ2NA4Z4.js.map +0 -1
  202. package/dist/chunk-U472S6IB.js.map +0 -1
  203. package/dist/chunk-UEHDEADL.js.map +0 -1
  204. package/dist/chunk-UNRR4KH5.js.map +0 -1
  205. package/dist/chunk-VQVUJYYY.js.map +0 -1
  206. package/dist/chunk-XGTTOO4R.js +0 -84
  207. package/dist/chunk-XGTTOO4R.js.map +0 -1
  208. package/dist/chunk-XRXFJTAT.js.map +0 -1
  209. package/dist/chunk-Y2JGMICO.js.map +0 -1
  210. package/dist/chunk-YVJQ2QDG.js.map +0 -1
  211. package/dist/chunk-YX7MVSDA.js +0 -235
  212. package/dist/chunk-YX7MVSDA.js.map +0 -1
  213. package/dist/chunk-ZGRBIBO7.js +0 -681
  214. package/dist/chunk-ZGRBIBO7.js.map +0 -1
  215. package/dist/chunk-ZTBAMBAI.js +0 -6448
  216. package/dist/chunk-ZTBAMBAI.js.map +0 -1
  217. package/dist/chunk-ZVANUFPF.js +0 -1035
  218. package/dist/chunk-ZVANUFPF.js.map +0 -1
  219. package/dist/doctor-HH6CFBRQ.js.map +0 -1
  220. package/dist/environment-K7YMJJYN.js.map +0 -1
  221. package/dist/help-QR4VTJZU.js.map +0 -1
  222. package/dist/help-TLHNRJJ6.js.map +0 -1
  223. package/dist/init-AOKFPZHG.js.map +0 -1
  224. package/dist/marketplace-TUVLLPBG.js.map +0 -1
  225. package/dist/migrate-55S4XODX.js.map +0 -1
  226. package/dist/open-SLFQV45J.js +0 -32
  227. package/dist/plugin-WLEFFBRY.js +0 -64
  228. package/dist/plugin-from-project-UV2O364T.js +0 -16
  229. package/dist/profile-STS3CZUK.js.map +0 -1
  230. package/dist/project-R4DGM3ZG.js.map +0 -1
  231. package/dist/resource-GJVEDXVZ.js.map +0 -1
  232. /package/dist/{apply-Q5SFF3FY.js.map → apply-FTAIL3X3.js.map} +0 -0
  233. /package/dist/{chunk-IHW4PCDT.js.map → chunk-6FXJIKEG.js.map} +0 -0
  234. /package/dist/{chunk-IAZNF35S.js.map → chunk-CBSDMRMY.js.map} +0 -0
  235. /package/dist/{chunk-3EGM4IUI.js.map → chunk-EPXAOEBB.js.map} +0 -0
  236. /package/dist/{chunk-XCPWLGPB.js.map → chunk-K4UDZUJ2.js.map} +0 -0
  237. /package/dist/{chunk-FBYAIBHP.js.map → chunk-MHLAIGIM.js.map} +0 -0
  238. /package/dist/{chunk-2H7UOFLK.js.map → chunk-MKLJBW5N.js.map} +0 -0
  239. /package/dist/{chunk-BXSS2S4W.js.map → chunk-R27VZIF6.js.map} +0 -0
  240. /package/dist/{chunk-JQOKQKQT.js.map → chunk-S2D5PWAO.js.map} +0 -0
  241. /package/dist/{chunk-WXRPQICX.js.map → chunk-UK2IV2ZQ.js.map} +0 -0
  242. /package/dist/{open-SLFQV45J.js.map → live-read-cache-ESQQJBNS.js.map} +0 -0
  243. /package/dist/{plugin-WLEFFBRY.js.map → live-read-cache-WPUFHVMZ.js.map} +0 -0
  244. /package/dist/{plugin-from-project-UV2O364T.js.map → open-D3GWGDSQ.js.map} +0 -0
  245. /package/dist/{version-FUHV4O6U.js.map → plugin-L3466DHK.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/user-path.ts","../src/services/materialization-conflicts.ts","../src/cli/print-apply-summary.ts","../src/services/global-profile-drift.ts","../src/services/profile-stash.ts","../src/services/profile-switch-prompt.ts","../src/services/wizards/project-use.ts","../src/services/project-config-use.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { isAbsolute, join, resolve } from \"node:path\";\nimport { resolveHomeRoot } from \"./home-root.js\";\n\nexport class UserPathError extends Error {\n readonly input: string;\n\n constructor(input: string, resolved: string) {\n super(`Directory not found: ${input}.`);\n this.name = \"UserPathError\";\n this.input = input;\n this.resolved = resolved;\n }\n\n readonly resolved: string;\n}\n\nexport function expandUserPath(arg: string, home = resolveHomeRoot()): string {\n const trimmed = arg.trim();\n if (trimmed === \"~\") {\n return home;\n }\n if (trimmed.startsWith(\"~/\") || trimmed.startsWith(\"~\\\\\")) {\n return join(home, trimmed.slice(2));\n }\n return isAbsolute(trimmed) ? trimmed : resolve(trimmed);\n}\n\nexport function resolveUserPath(\n arg: string,\n opts?: { mustExist?: boolean; home?: string },\n): string {\n const resolved = resolve(expandUserPath(arg, opts?.home ?? resolveHomeRoot()));\n if (opts?.mustExist && !existsSync(resolved)) {\n throw new UserPathError(arg, resolved);\n }\n return resolved;\n}\n","import { ON_CONFLICT_VALUE_HELP, parseOnConflict } from \"../cli/on-conflict.js\";\nimport { applyCancelledMessage, onConflictReplaceHint } from \"../copy/cli.js\";\nimport { ui } from \"../ui/index.js\";\nimport type {\n ConflictPolicy,\n ConflictResolution,\n MaterializationConflict,\n} from \"./applier.js\";\nimport { promptForChoice } from \"./wizards/shared.js\";\n\nexport function resolveApplyConflictPolicy(opts: {\n onConflict?: string;\n noInteractive?: boolean;\n}): ConflictPolicy {\n const parsed = opts.onConflict ? parseOnConflict(opts.onConflict) : undefined;\n if (\n parsed === \"replace\" ||\n parsed === \"skip\" ||\n parsed === \"prompt\" ||\n parsed === \"cancel\"\n ) {\n return parsed;\n }\n if (\n opts.noInteractive ||\n process.env.CI === \"true\" ||\n process.env.HARNESSTAP_NO_INTERACTIVE === \"1\" ||\n !process.stdin.isTTY ||\n !process.stdout.isTTY\n ) {\n return \"cancel\";\n }\n return \"prompt\";\n}\n\n/** Name the conflicting files and give one --on-conflict hint. Sets exit code 1. */\nexport function reportApplyCancelled(\n conflicts: readonly string[],\n scope: \"profile\" | \"apply\" = \"apply\",\n): void {\n process.exitCode = 1;\n ui.warn(applyCancelledMessage(conflicts, scope), {\n hint: onConflictReplaceHint(conflicts),\n });\n}\n\nexport async function promptMaterializationConflict(\n conflict: MaterializationConflict,\n): Promise<ConflictResolution> {\n const ownerSummary =\n conflict.owners.length > 0\n ? conflict.owners\n .map((owner) => `${owner.plugin_name}@${owner.plugin_version ?? \"?\"}`)\n .join(\", \")\n : \"another plugin or manual edit\";\n\n ui.warn(`File already exists: ${conflict.path}`);\n ui.dim(` Previously written by: ${ownerSummary}`);\n\n return promptForChoice({\n message: `How should HarnessTap handle ${conflict.path}?`,\n choices: [\n { name: ON_CONFLICT_VALUE_HELP.replace, value: \"replace\" as const },\n { name: ON_CONFLICT_VALUE_HELP.skip, value: \"skip\" as const },\n { name: ON_CONFLICT_VALUE_HELP.cancel, value: \"cancel\" as const },\n ],\n });\n}\n","import {\n applyHeaderLine,\n applyWroteLine,\n CLI_COPY,\n CLI_HINTS,\n dryRunSectionHeader,\n dryRunWouldLine,\n forceRemoveHintLine,\n keptFilesHeader,\n keptReportedBeforeLine,\n keptReasonLabel,\n snapshotSavedUndoLine,\n} from \"../copy/cli.js\";\nimport {\n allKeptHostPluginViewPaths,\n hostPluginViewChangeCounts,\n hostPluginViewForceReplace,\n pendingKeptHostPluginViewPaths,\n} from \"../services/package-cache/host-plugin-view-policy.js\";\nimport { isClaudePluginRegistryPath } from \"../services/claude-plugin-registration-prune.js\";\nimport { ui } from \"../ui/index.js\";\n\nexport interface ApplyKeptFile {\n path: string;\n reason: \"modified\" | \"unmanaged\";\n /** False when --force-remove would not remove the file either. */\n forceable?: boolean;\n}\n\nexport function keptFromSkippedRemovals(\n skipped: readonly { path: string; reason: string; forceable?: boolean }[] | undefined,\n): ApplyKeptFile[] {\n return (skipped ?? []).flatMap((entry) => {\n const reason = removalSkipReason(entry.reason);\n if (!reason) return [];\n return [\n entry.forceable === false\n ? { path: entry.path, reason, forceable: false }\n : { path: entry.path, reason },\n ];\n });\n}\n\nexport function printApplyPayload(payload: {\n profile_name: string;\n harnesses: readonly string[];\n files: readonly unknown[];\n written_files: readonly string[];\n removed_files?: readonly string[];\n skipped_removals?: readonly { path: string; reason: string; message?: string; forceable?: boolean }[];\n snapshot_id?: string;\n dry_run?: boolean;\n removal_backup?: string;\n}): void {\n const kept = keptFromSkippedRemovals(payload.skipped_removals);\n const unchanged = Math.max(0, payload.files.length - payload.written_files.length);\n if (payload.dry_run) {\n printApplyDryRun({\n wouldWrite: payload.written_files,\n wouldRemove: payload.removed_files ?? [],\n wouldKeep: kept,\n unchanged,\n });\n } else {\n printApplySuccess({\n name: payload.profile_name,\n harnessCount: payload.harnesses.length,\n wrote: payload.written_files.length,\n removed: payload.removed_files?.length ?? 0,\n kept,\n unchanged,\n snapshotId: payload.snapshot_id,\n });\n }\n const listedKept = kept.length > 0;\n for (const skipped of payload.skipped_removals ?? []) {\n if (skipped.reason === \"missing\") {\n continue;\n }\n if (listedKept && removalSkipReason(skipped.reason)) {\n continue;\n }\n if (skipped.message) {\n ui.warn(skipped.message);\n }\n }\n // The removal itself already printed \"Removed N files. Backup: <dir>\"\n // (profile-apply warnSkippedRemovals), so the backup folder is not repeated.\n}\n\nexport function printApplyDryRun(input: {\n wouldWrite: readonly string[];\n wouldRemove: readonly string[];\n wouldKeep: readonly ApplyKeptFile[];\n unchanged: number;\n header?: string | false;\n}): void {\n if (input.header !== false) {\n console.log(input.header ?? CLI_COPY.dryRunNothingChanged);\n console.log(\"\");\n }\n if (input.wouldWrite.length > 0) {\n console.log(dryRunSectionHeader(\"write\", input.wouldWrite.length));\n for (const path of input.wouldWrite) {\n console.log(` ${path}`);\n }\n }\n if (input.wouldRemove.length > 0) {\n console.log(dryRunSectionHeader(\"remove\", input.wouldRemove.length));\n for (const path of input.wouldRemove) {\n console.log(` ${path}`);\n }\n }\n if (input.wouldKeep.length > 0) {\n console.log(dryRunSectionHeader(\"keep\", input.wouldKeep.length));\n for (const entry of input.wouldKeep) {\n console.log(` ${entry.path} ${keptReasonLabel(entry.reason, entry.path)}`);\n }\n }\n console.log(\"\");\n console.log(\n dryRunWouldLine({\n write: input.wouldWrite.length,\n remove: input.wouldRemove.length,\n keep: input.wouldKeep.length,\n unchanged: input.unchanged,\n }),\n );\n}\n\nexport function printKeptFiles(kept: readonly ApplyKeptFile[]): void {\n if (kept.length === 0) {\n return;\n }\n console.log(keptFilesHeader(kept.length));\n for (const entry of kept) {\n console.log(` ${entry.path} ${keptReasonLabel(entry.reason, entry.path)}`);\n }\n // HarnessTap keeps the entries Claude Code changed in its plugin registries\n // even with --force-remove, so suggesting it for those alone is wrong.\n if (kept.every((entry) => isClaudePluginRegistryPath(entry.path))) {\n return;\n }\n // With --force-remove already in effect, or when it would remove none of\n // these files, suggesting it is wrong.\n const forceable = kept.filter(\n (entry) => entry.forceable !== false && !isClaudePluginRegistryPath(entry.path),\n );\n console.log(\n hostPluginViewForceReplace() || forceable.length === 0\n ? CLI_HINTS.forceRemoveAlreadyUsed\n : forceRemoveHintLine(forceable.length),\n );\n}\n\nexport function printApplySuccess(input: {\n name: string;\n harnessCount: number;\n wrote: number;\n removed: number;\n kept: readonly ApplyKeptFile[];\n unchanged: number;\n snapshotId?: string;\n}): void {\n console.log(applyHeaderLine(input.name, input.harnessCount));\n // Files a plugin cache folder refresh added, replaced or removed count too, so the\n // line never says nothing changed next to \"Backed up and replaced ...\".\n const pluginFolder = hostPluginViewChangeCounts();\n // Kept files in a plugin cache folder get their own, more detailed notice.\n // List each kept file once, and count both.\n const folderKept = new Set(pendingKeptHostPluginViewPaths());\n const kept = input.kept.filter((entry) => !folderKept.has(entry.path));\n // Kept files in a plugin cache folder that an earlier apply already reported get no\n // notice again, but they are still kept, so the count and a pointer include them.\n const listedPaths = new Set([...folderKept, ...kept.map((entry) => entry.path)]);\n const reportedBefore = allKeptHostPluginViewPaths().filter((path) => !listedPaths.has(path));\n const keptTotal = listedPaths.size + new Set(reportedBefore).size;\n console.log(\n applyWroteLine({\n wrote: input.wrote + pluginFolder.replaced + pluginFolder.added,\n removed: input.removed + pluginFolder.removed,\n kept: keptTotal,\n unchanged: input.unchanged,\n }),\n );\n if (kept.length > 0) {\n printKeptFiles(kept);\n }\n if (reportedBefore.length > 0) {\n console.log(keptReportedBeforeLine(new Set(reportedBefore).size));\n }\n if (input.snapshotId) {\n console.log(snapshotSavedUndoLine(`ht revert ${input.snapshotId}`));\n }\n}\n\nexport function removalSkipReason(\n reason: string,\n): \"modified\" | \"unmanaged\" | undefined {\n if (reason === \"modified\") {\n return \"modified\";\n }\n if (reason === \"unmanaged\" || reason === \"preexisting\") {\n return \"unmanaged\";\n }\n return undefined;\n}\n","import { runTracedStatus, traceCount, traceSpan } from \"./status-trace.js\";\nimport { unreadNotificationCount } from \"./notifications.js\";\nimport { readUpstreamCheckSummary, type UpstreamCheckSummary } from \"./upstream-check-read.js\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { harnesstapDirForHomeRoot } from \"../db/connection.js\";\nimport { diffHostPluginView } from \"./package-cache/host-plugin.js\";\nimport { emittedHostPluginTree } from \"./host-plugin-serialize.js\";\nimport {\n CLAUDE_KNOWN_MARKETPLACES_PATH,\n HARNESSTAP_CLAUDE_MARKETPLACES_ROOT,\n claudeChangedMarketplaces,\n harnessTapClaudeMarketplaceManifestPath,\n} from \"./claude-marketplace-registration.js\";\nimport { hostPluginPackageDir } from \"./package-cache/paths.js\";\nimport { isEmptyBuiltinProfile, isProfilePlugin } from \"../constants/profile.js\";\nimport { getLatestGlobalApplySnapshotForProfile } from \"../models/global-apply-snapshot.js\";\nimport { resolvePluginSelector } from \"../models/plugin-model.js\";\nimport { listMaterializationsForRootPath } from \"../models/resource-materialization.js\";\nimport { resolveHomeRoot } from \"../utils/home-root.js\";\nimport { getActiveProfileName } from \"./active-profile.js\";\nimport {\n isTransparentCrossHarnessGap,\n resourceScopesForPlugins,\n liveSkillCopiesForMissingPath,\n} from \"./cross-harness-gap.js\";\nimport {\n buildHostManagedStatus,\n type HostManagedStatus,\n profileSkillNameMap,\n} from \"./cursor-host-managed-skills.js\";\nimport { binaryExpectedFileMatchesDisk, fileContentsEquivalentForDrift } from \"./file-contents-drift.js\";\nimport { isNativeAgentPluginCachePath } from \"./native-agent-plugins.js\";\nimport {\n buildHarnessLiveStatusMap,\n classifyGlobalDriftChanges,\n collectOwnedGlobalProfileFiles,\n computeGlobalProfilePanelStatus,\n countMissingHarnessRows,\n declaredMcpFromExpectedFiles,\n filesOnlyMarketplacePinRefs,\n listMissingHarnessRows,\n type GlobalProfileDriftSummary,\n type GlobalProfilePanelStatus,\n type GlobalProfileStatusDepth,\n type HarnessLiveStatus,\n resolveProjectDriftSummary,\n} from \"./global-profile-status-panel.js\";\nimport type { HarnessScope } from \"./harness-scope.js\";\nimport { mergePluginsForApply } from \"./plugin-apply-merge.js\";\nimport {\n type ApplyProfilePluginResult,\n applyProfilePlugin,\n clearGlobalProfileApply,\n collectProfilePluginIds,\n} from \"./profile-apply.js\";\nimport { resourceKeyFromManagedPath } from \"./profile-commit-resource.js\";\nimport {\n buildProfileContents,\n type ProfileContents,\n} from \"./profile-contents.js\";\nimport { detectNotStagedProfileResources } from \"./profile-untracked-resources.js\";\nimport { type DriftFileChange, driftChangeIsKept } from \"./project-drift.js\";\nimport { hashOnDiskFile } from \"./safe-file-removal.js\";\nimport { withAffectedResources } from \"./scoped-file-content-delta.js\";\nimport { readDiskTextOnce } from \"./status-disk-read.js\";\nimport { inStatusComputation, runInStatusComputation } from \"./status-computation.js\";\nimport { withStatusReadCache } from \"./status-read-cache.js\";\n\ntype StatusFieldInput = Parameters<typeof buildBaseStatusFields>[0];\n\ninterface DriftCore {\n fields: Omit<StatusFieldInput, \"depth\">;\n harness?: string;\n watchedPaths: string[];\n}\n\nlet driftCoreComputes = 0;\n\n/** How many times the dry-run core has actually run. Tests use this. */\nexport function readDriftCoreComputeCount(): number {\n return driftCoreComputes;\n}\n\nfunction driftCore(\n fields: Omit<StatusFieldInput, \"depth\">,\n harness: string | undefined,\n homeRoot: string,\n): DriftCore {\n const watchedPaths = (fields.expectedApply?.expected_files ?? []).map((file) =>\n join(homeRoot, file.path),\n );\n return { fields, harness, watchedPaths };\n}\n\nexport interface GlobalProfileStatus {\n active_profile: string | null;\n profile_exists: boolean;\n applied: boolean;\n snapshot_id: string | null;\n snapshot_at: string | null;\n stack_in_sync: boolean;\n has_drift: boolean;\n changes: DriftFileChange[];\n warning?: string;\n depth: GlobalProfileStatusDepth;\n as_of: string;\n panel: GlobalProfilePanelStatus;\n harnesses: Record<string, HarnessLiveStatus>;\n drift_summary: GlobalProfileDriftSummary;\n contents?: ProfileContents | null;\n untracked_resource_count?: number;\n /** Alias for untracked_resource_count (not-staged working-tree resources). */\n not_staged_count?: number;\n /** App-managed inventory (full depth only); never applied or persisted. */\n host_managed?: HostManagedStatus;\n /**\n * True when this payload is the previous result and a fresh read is running.\n * Absent or false after apply, switch, and install, which wait for a new read.\n */\n refreshing?: boolean;\n /** Pending upstream updates from the last check. Read from the table only, never the network. */\n updates?: UpstreamCheckSummary;\n /** Unread notifications, for the Desktop bell. One indexed count, outside the cache. */\n unread_count?: number;\n}\n\n/**\n * One answer to \"is the global state in sync with the active profile\" for the\n * human output, `profile status --check`, and the JSON panel: file drift plus\n * declared plugins and MCP servers a full status found missing.\n */\nexport function globalProfileStatusGaps(status: GlobalProfileStatus): {\n inSync: boolean;\n missing: Array<{ harness: string; kind: \"plugin\" | \"mcp\"; id: string }>;\n} {\n const missing = status.depth === \"full\" ? listMissingHarnessRows(status.harnesses) : [];\n return { inSync: !status.has_drift && missing.length === 0, missing };\n}\n\nconst HOST_PLUGIN_VIEW_PATH = /^(\\.claude\\/plugins\\/cache\\/([^/]+)\\/([^/]+)\\/([^/]+))\\//;\n\n/** True for a file inside a host plugin cache folder, which apply refreshes from the plugin. */\nexport function isHostPluginViewPath(path: string): boolean {\n return HOST_PLUGIN_VIEW_PATH.test(path.replaceAll(\"\\\\\", \"/\"));\n}\n\n/**\n * A host plugin cache folder (`~/.claude/plugins/cache/<mkt>/<name>/<ver>`)\n * is emitted from itself, so comparing the expected files with the disk finds\n * nothing even when it holds the user's files instead of the plugin's. Compare\n * each such folder with HarnessTap's copy of the plugin instead. Files a\n * refresh would keep are reported as kept, not as pending writes.\n */\nexport function hostPluginFolderChanges(\n homeRoot: string,\n expectedFiles: ReadonlyArray<{ path: string }>,\n known: readonly DriftFileChange[],\n): DriftFileChange[] {\n const folders = new Map<string, { marketplace: string; name: string; version: string }>();\n for (const file of expectedFiles) {\n const match = HOST_PLUGIN_VIEW_PATH.exec(file.path.replaceAll(\"\\\\\", \"/\"));\n if (!match?.[1] || !match[2] || !match[3] || !match[4]) continue;\n folders.set(match[1], { marketplace: match[2], name: match[3], version: match[4] });\n }\n if (folders.size === 0) return [];\n const seen = new Set(known.map((change) => change.path));\n const harnesstapDir = harnesstapDirForHomeRoot(homeRoot);\n const changes: DriftFileChange[] = [];\n for (const [folder, plugin] of folders) {\n const canonicalDir = hostPluginPackageDir(harnesstapDir, plugin.marketplace, plugin.name, plugin.version);\n const differences = diffHostPluginView({\n homeRoot,\n hostView: join(homeRoot, folder),\n canonicalDir,\n });\n // Spec plugins are translated for the host on write (`mcp.json` becomes\n // `.mcp.json`, for example), so compare with what the apply writes.\n const emitted = differences.length > 0\n ? emittedHostPluginTree(canonicalDir, \"claude-code\", plugin.name)\n : new Map<string, { content: string; encoding?: \"utf8\" | \"base64\" }>();\n for (const difference of differences) {\n const path = `${folder}/${difference.path}`;\n if (seen.has(path)) continue;\n const written = emitted.get(difference.path);\n if (difference.state === \"missing\" ? !written : matchesEmitted(join(homeRoot, path), written)) {\n continue;\n }\n seen.add(path);\n if (difference.state === \"missing\") changes.push({ path, type: \"deleted\" });\n else if (difference.state === \"stale\") changes.push({ path, type: \"modified\" });\n else if (difference.state === \"modified\") {\n // HarnessTap wrote the file and it changed since: in Claude Code's\n // plugin cache, that is Claude Code updating the plugin.\n changes.push({ path, type: \"modified\", removal_group: \"owned_modified\", changed_by: \"claude-code\" });\n } else {\n changes.push({ path, type: \"modified\", removal_group: \"unmanaged\" });\n }\n }\n }\n return changes;\n}\n\nfunction matchesEmitted(\n fullPath: string,\n file: { content: string; encoding?: \"utf8\" | \"base64\" } | undefined,\n): boolean {\n if (!file) return false;\n const binary = binaryExpectedFileMatchesDisk(fullPath, file);\n if (binary !== undefined) return binary;\n try {\n return readFileSync(fullPath, \"utf-8\") === file.content;\n } catch {\n return false;\n }\n}\n\nfunction isHarnessTapClaudeMarketplaceFile(path: string): boolean {\n return path.replaceAll(\"\\\\\", \"/\").startsWith(`${HARNESSTAP_CLAUDE_MARKETPLACES_ROOT}/`);\n}\n\n/**\n * Marketplace entries HarnessTap registers for this profile that Claude Code\n * rewrote since. Apply leaves them as they are, so the file itself matches\n * what apply would write; report each entry as a kept change.\n */\nexport function claudeChangedMarketplaceEntries(\n homeRoot: string,\n expectedFiles: ReadonlyArray<{ path: string }>,\n): DriftFileChange[] {\n const wanted = new Set(expectedFiles.map((file) => file.path));\n return [...claudeChangedMarketplaces(homeRoot)]\n .filter((marketplace) => wanted.has(harnessTapClaudeMarketplaceManifestPath(marketplace)))\n .sort()\n .map((marketplace) => ({\n path: CLAUDE_KNOWN_MARKETPLACES_PATH,\n type: \"modified\" as const,\n removal_group: \"owned_modified\" as const,\n changed_by: \"claude-code\" as const,\n detail: `marketplace ${marketplace}`,\n }));\n}\n\nfunction keptContentDiff(\n path: string,\n keptModified: ReadonlySet<string>,\n keptUnmanaged: ReadonlySet<string>,\n): DriftFileChange {\n if (keptModified.has(path)) {\n return { path, type: \"modified\", removal_group: \"owned_modified\" };\n }\n if (keptUnmanaged.has(path)) {\n return { path, type: \"modified\", removal_group: \"unmanaged\" };\n }\n return { path, type: \"modified\" };\n}\n\nfunction isMissingExpectedFileTransparent(\n homeRoot: string,\n path: string,\n expectedPathsByResource: ReadonlyMap<string, readonly string[]>,\n scopeByResource: ReadonlyMap<string, HarnessScope>,\n harnesses: readonly string[],\n): boolean {\n const mapped = resourceKeyFromManagedPath(path);\n if (!mapped) {\n return true;\n }\n const key = `${mapped.type}:${mapped.name}`;\n const siblings = expectedPathsByResource.get(key) ?? [];\n const onDiskSiblingPaths = siblings.filter(\n (sibling) => sibling !== path && readGlobalFile(homeRoot, sibling) !== null,\n );\n for (const live of liveSkillCopiesForMissingPath(path, harnesses, (candidate) => readGlobalFile(homeRoot, candidate) !== null)) {\n if (!onDiskSiblingPaths.includes(live)) onDiskSiblingPaths.push(live);\n }\n return isTransparentCrossHarnessGap({\n path,\n onDiskSiblingPaths,\n scope: scopeByResource.get(key),\n });\n}\n\nfunction readGlobalFile(homeRoot: string, relativePath: string): string | null {\n const fullPath = join(homeRoot, relativePath);\n if (!inStatusComputation()) return readGlobalFileUncached(fullPath);\n if (!existsSync(fullPath)) return null;\n return readDiskTextOnce(fullPath);\n}\n\nfunction readGlobalFileUncached(fullPath: string): string | null {\n if (!existsSync(fullPath)) {\n return null;\n }\n try {\n return readFileSync(fullPath, \"utf-8\");\n } catch {\n return null;\n }\n}\n\nfunction pluginIdsMatch(left: string[], right: string[]): boolean {\n if (left.length !== right.length) {\n return false;\n }\n return left.every((pluginId, index) => pluginId === right[index]);\n}\n\nfunction declaredMcpFromExpectedApply(expectedApply: ApplyProfilePluginResult) {\n return declaredMcpFromExpectedFiles(\n expectedApply.harnesses,\n expectedApply.expected_files ?? [],\n );\n}\n\nfunction declaredMcpNamesFromMergedPlugins(pluginIds: string[]): Record<string, string[]> {\n const merged = mergePluginsForApply(pluginIds);\n const names = merged.resources\n .filter((resource) => resource.type === \"mcp_server\")\n .map((resource) => resource.name);\n return {\n \"claude-code\": names,\n cursor: names,\n };\n}\n\nfunction buildBaseStatusFields(input: {\n depth: GlobalProfileStatusDepth;\n activeProfile: string | null;\n profileExists: boolean;\n applied: boolean;\n snapshotId: string | null;\n snapshotAt: string | null;\n stackInSync: boolean;\n hasDrift: boolean;\n changes: DriftFileChange[];\n warning?: string;\n projectPath?: string;\n expectedApply?: ApplyProfilePluginResult;\n pluginIds?: string[];\n}): GlobalProfileStatus {\n const asOf = new Date().toISOString();\n const homeRoot = resolveHomeRoot();\n const ownedFiles = traceSpan(\"db.owned-files\", () => collectOwnedGlobalProfileFiles(input.snapshotId));\n const blockingChanges = input.changes.filter((change) => !driftChangeIsKept(change));\n const { owned, nonOwned } = classifyGlobalDriftChanges(blockingChanges, ownedFiles);\n\n const declaredPins =\n input.pluginIds && input.pluginIds.length > 0\n ? traceSpan(\"base.merge-plugins\", () => mergePluginsForApply(input.pluginIds ?? []).pluginPins)\n : [];\n const declaredFromExpected = input.expectedApply\n ? declaredMcpFromExpectedApply(input.expectedApply)\n : null;\n const declaredMcpByHarness =\n declaredFromExpected?.namesByHarness\n ?? (input.pluginIds\n ? declaredMcpNamesFromMergedPlugins(input.pluginIds)\n : { \"claude-code\": [], cursor: [] });\n\n const filesOnlyPinRefs = input.expectedApply?.resolution\n ? {\n \"claude-code\": filesOnlyMarketplacePinRefs(input.expectedApply.resolution, \"claude-code\"),\n cursor: filesOnlyMarketplacePinRefs(input.expectedApply.resolution, \"cursor\"),\n }\n : undefined;\n\n const harnesses = traceSpan(\"base.harness-live-status\", () => buildHarnessLiveStatusMap({\n depth: input.depth,\n homeRoot,\n declaredPins,\n ...(filesOnlyPinRefs ? { filesOnlyPinRefs } : {}),\n declaredMcpByHarness,\n ...(declaredFromExpected\n ? { expectedMcpConfigsByHarness: declaredFromExpected.configsByHarness }\n : {}),\n }));\n const { missingPlugins, missingMcp } =\n input.depth === \"full\"\n ? countMissingHarnessRows(harnesses)\n : { missingPlugins: 0, missingMcp: 0 };\n\n const contents = input.activeProfile\n ? traceSpan(\"base.profile-contents\", () => buildProfileContents(input.activeProfile ?? \"\"))\n : null;\n const hostManaged =\n input.depth === \"full\"\n ? traceSpan(\"base.host-managed\", () =>\n buildHostManagedStatus({\n homeRoot,\n profileSkills: profileSkillNameMap(contents?.resources ?? []),\n }),\n )\n : undefined;\n\n const projectDrift = traceSpan(\"base.project-drift\", () => resolveProjectDriftSummary(input.projectPath));\n const panel = computeGlobalProfilePanelStatus({\n depth: input.depth,\n applied: input.applied,\n activeProfile: input.activeProfile,\n stackInSync: input.stackInSync,\n ownedDriftCount: owned.length,\n nonOwnedDriftCount: nonOwned.length,\n missingPluginCount: missingPlugins,\n missingMcpCount: missingMcp,\n projectDrift,\n warning: input.warning,\n hostManagedCollisionCount: hostManaged?.cursor?.collisions.length ?? 0,\n });\n\n const driftSummary: GlobalProfileDriftSummary = {\n global: {\n status: !input.applied\n ? \"pending\"\n : input.hasDrift\n ? \"drifted\"\n : \"clean\",\n owned_changes: owned.length,\n non_owned_changes: nonOwned.length,\n },\n ...(projectDrift ? { project: projectDrift } : {}),\n };\n\n return {\n active_profile: input.activeProfile,\n profile_exists: input.profileExists,\n applied: input.applied,\n snapshot_id: input.snapshotId,\n snapshot_at: input.snapshotAt,\n stack_in_sync: input.stackInSync,\n has_drift: input.hasDrift,\n changes: input.changes,\n ...(input.warning ? { warning: input.warning } : {}),\n depth: input.depth,\n as_of: asOf,\n panel,\n harnesses,\n drift_summary: driftSummary,\n contents,\n ...(hostManaged ? { host_managed: hostManaged } : {}),\n };\n}\n\nasync function finalizeGlobalProfileStatus(\n fields: Parameters<typeof buildBaseStatusFields>[0],\n harness?: string,\n): Promise<GlobalProfileStatus> {\n const status = traceSpan(\"base\", () => buildBaseStatusFields(fields));\n if (\n fields.depth !== \"full\"\n || !status.active_profile\n || isEmptyBuiltinProfile(status.active_profile)\n ) {\n return status;\n }\n try {\n const notStaged = await traceSpan(\"not-staged\", () =>\n detectNotStagedProfileResources({\n profileSelector: status.active_profile ?? \"\",\n scope: \"home\",\n ...(harness ? { harness } : {}),\n }),\n );\n return {\n ...status,\n untracked_resource_count: notStaged.length,\n not_staged_count: notStaged.length,\n };\n } catch {\n return status;\n }\n}\n\n/**\n * Fast depth keeps the same drift fields as a full read (`changes`,\n * `has_drift`, `stack_in_sync`, `drift_summary`). The desktop drift pill\n * replaces those from every fast poll, so a cold fast read still runs the\n * dry-run. The full result, including that dry-run and profile contents, is\n * cached. A warm read is a map lookup while file watchers are healthy.\n * Status does not read Cursor's state.vscdb or logs folder. Where a watcher\n * could not be installed, mtimes and sizes of the remaining files are\n * checked instead.\n * A later read of the same depth skips the dry-run. Cold and refresh both\n * run on the background worker. The caller waits for a cold read, and the\n * main thread does not run that dry-run. When a watched input changes, the\n * previous result is returned with `refreshing` set. A warm or stale\n * response does not wait for that read. A status-relevant database write on\n * this process, or a commit from another process (`data_version`), drops the\n * snapshot, so the next read waits and includes that write. Apply, switch,\n * and install clear the cache first,\n * so the next read waits and is not stale. Overlapping callers share one\n * in-flight computation.\n */\nexport async function detectGlobalProfileStatus(input: {\n harness?: string;\n depth?: GlobalProfileStatusDepth;\n projectPath?: string;\n} = {}): Promise<GlobalProfileStatus> {\n const depth = input.depth ?? \"full\";\n const request = {\n depth,\n harness: input.harness,\n projectPath: input.projectPath,\n };\n const status = await withStatusReadCache(request, () => runInStatusComputation(async () => {\n const core = await withStatusReadCache(\n { ...request, includeDepth: false },\n async () => {\n const loaded = await loadDriftCore(input);\n return { value: loaded, watchedPaths: loaded.watchedPaths };\n },\n );\n const projected = await finalizeGlobalProfileStatus(\n { ...core.fields, depth },\n core.harness,\n );\n return { value: projected, watchedPaths: core.watchedPaths };\n }), { staleWhileRefresh: true });\n return {\n ...status,\n as_of: new Date().toISOString(),\n refreshing: status.refreshing === true,\n // Outside the cache: one indexed read, so a finished check shows at once.\n updates: readUpstreamCheckSummary(),\n unread_count: unreadNotificationCount(),\n };\n}\n\n/**\n * Full status computation with no cache. The refresh worker runs this off the\n * request thread. A warm or stale response must not wait for it.\n */\nexport async function loadGlobalProfileStatusSnapshot(input: {\n harness?: string;\n depth?: GlobalProfileStatusDepth;\n projectPath?: string;\n} = {}): Promise<{ value: GlobalProfileStatus; watchedPaths: string[] }> {\n const depth = input.depth ?? \"full\";\n return runInStatusComputation(() =>\n runTracedStatus(`depth=${depth} harness=${input.harness ?? \"*\"}`, async () => {\n const loaded = await traceSpan(\"drift-core\", () => loadDriftCore(input));\n const projected = await traceSpan(\"finalize\", () =>\n finalizeGlobalProfileStatus({ ...loaded.fields, depth }, loaded.harness),\n );\n return { value: projected, watchedPaths: loaded.watchedPaths };\n }),\n );\n}\n\nasync function loadDriftCore(input: {\n harness?: string;\n depth?: GlobalProfileStatusDepth;\n projectPath?: string;\n}): Promise<DriftCore> {\n driftCoreComputes += 1;\n const homeRoot = resolveHomeRoot();\n const activeProfile = getActiveProfileName() ?? null;\n if (!activeProfile) {\n return driftCore(\n {\n activeProfile: null,\n profileExists: false,\n applied: false,\n snapshotId: null,\n snapshotAt: null,\n stackInSync: false,\n hasDrift: false,\n changes: [],\n projectPath: input.projectPath,\n },\n input.harness,\n homeRoot,\n );\n }\n\n const plugin = traceSpan(\"db.resolve-profile\", () => resolvePluginSelector(activeProfile));\n if (!plugin) {\n if (isEmptyBuiltinProfile(activeProfile)) {\n const latestSnapshot = getLatestGlobalApplySnapshotForProfile(activeProfile);\n let expectedApply: ApplyProfilePluginResult;\n try {\n expectedApply = await clearGlobalProfileApply({\n dryRun: true,\n harness: input.harness,\n conflictPolicy: \"replace\",\n pull: false,\n });\n } catch (error) {\n return driftCore({\n activeProfile,\n profileExists: true,\n applied: Boolean(latestSnapshot),\n snapshotId: latestSnapshot?.id ?? null,\n snapshotAt: latestSnapshot?.created_at ?? null,\n stackInSync: false,\n hasDrift: true,\n changes: [],\n warning: error instanceof Error ? error.message : String(error),\n projectPath: input.projectPath,\n pluginIds: [],\n }, input.harness, homeRoot);\n }\n\n const stackInSync = latestSnapshot\n ? pluginIdsMatch(latestSnapshot.plugin_ids, expectedApply.configured_plugin_ids)\n : false;\n const applied = Boolean(latestSnapshot);\n const hasDrift = !applied || !stackInSync;\n\n return driftCore({\n activeProfile,\n profileExists: true,\n applied,\n snapshotId: latestSnapshot?.id ?? null,\n snapshotAt: latestSnapshot?.created_at ?? null,\n stackInSync,\n hasDrift,\n changes: [],\n projectPath: input.projectPath,\n expectedApply,\n pluginIds: [],\n }, input.harness, homeRoot);\n }\n\n return driftCore({\n activeProfile,\n profileExists: false,\n applied: false,\n snapshotId: null,\n snapshotAt: null,\n stackInSync: false,\n hasDrift: true,\n changes: [],\n warning: `missing plugin \"${activeProfile}\"`,\n projectPath: input.projectPath,\n }, input.harness, homeRoot);\n }\n\n if (!isProfilePlugin(plugin)) {\n return driftCore({\n activeProfile,\n profileExists: true,\n applied: false,\n snapshotId: null,\n snapshotAt: null,\n stackInSync: false,\n hasDrift: true,\n changes: [],\n warning: `plugin \"${plugin.name}\" is not tagged as a profile`,\n projectPath: input.projectPath,\n }, input.harness, homeRoot);\n }\n\n const latestSnapshot = getLatestGlobalApplySnapshotForProfile(activeProfile);\n const pluginIds = collectProfilePluginIds(plugin);\n let expectedApply: ApplyProfilePluginResult;\n try {\n expectedApply = await traceSpan(\"dry-run\", () =>\n applyProfilePlugin(activeProfile, {\n dryRun: true,\n harness: input.harness,\n conflictPolicy: \"replace\",\n pull: false,\n pinSkillEmits: false,\n mergeLiveSkillMarkdown: false,\n }),\n );\n traceCount(\"dry-run\", \"expected_files\", expectedApply.expected_files?.length ?? 0);\n } catch (error) {\n return driftCore({\n activeProfile,\n profileExists: true,\n applied: Boolean(latestSnapshot),\n snapshotId: latestSnapshot?.id ?? null,\n snapshotAt: latestSnapshot?.created_at ?? null,\n stackInSync: false,\n hasDrift: true,\n changes: [],\n warning: error instanceof Error ? error.message : String(error),\n projectPath: input.projectPath,\n pluginIds,\n }, input.harness, homeRoot);\n }\n\n const stackInSync = latestSnapshot\n ? pluginIdsMatch(latestSnapshot.plugin_ids, expectedApply.configured_plugin_ids)\n : false;\n\n const changes: DriftFileChange[] = [];\n const keptModified = new Set(expectedApply.removals?.owned_modified ?? []);\n const keptUnmanaged = new Set(expectedApply.removals?.unmanaged ?? []);\n const scopeByResource = resourceScopesForPlugins(pluginIds);\n const expectedPathsByResource = new Map<string, string[]>();\n for (const file of expectedApply.expected_files ?? []) {\n const mapped = resourceKeyFromManagedPath(file.path);\n if (!mapped) {\n continue;\n }\n const key = `${mapped.type}:${mapped.name}`;\n const paths = expectedPathsByResource.get(key) ?? [];\n paths.push(file.path);\n expectedPathsByResource.set(key, paths);\n }\n traceSpan(\"drift.compare-files\", () => {\n for (const file of expectedApply.expected_files ?? []) {\n if (isNativeAgentPluginCachePath(file.path)) continue;\n // Compared with HarnessTap's copy of the plugin below.\n if (isHostPluginViewPath(file.path)) continue;\n if (binaryExpectedFileMatchesDisk(join(homeRoot, file.path), file)) continue;\n const current = readGlobalFile(homeRoot, file.path);\n const owned = listMaterializationsForRootPath(homeRoot, file.path);\n if (current === null) {\n if (owned.length === 0 && isMissingExpectedFileTransparent(\n homeRoot,\n file.path,\n expectedPathsByResource,\n scopeByResource,\n expectedApply.harnesses,\n )) {\n continue;\n }\n changes.push(\n withAffectedResources({ path: file.path, type: \"deleted\" }, file.content, null),\n );\n continue;\n }\n if (owned.length > 0) {\n const diskHash = hashOnDiskFile(join(homeRoot, file.path));\n if (owned.some((row) => row.generated_hash === diskHash)) {\n continue;\n }\n if (fileContentsEquivalentForDrift(file.path, current, file.content)) {\n continue;\n }\n if (isHarnessTapClaudeMarketplaceFile(file.path)) {\n // Apply keeps a marketplace file HarnessTap wrote that changed since.\n changes.push({ path: file.path, type: \"modified\", removal_group: \"owned_modified\", changed_by: \"claude-code\" });\n continue;\n }\n changes.push(\n withAffectedResources(\n keptContentDiff(file.path, keptModified, keptUnmanaged),\n file.content,\n current,\n ),\n );\n continue;\n }\n if (!fileContentsEquivalentForDrift(file.path, current, file.content)) {\n changes.push(\n withAffectedResources(\n keptContentDiff(file.path, keptModified, keptUnmanaged),\n file.content,\n current,\n ),\n );\n }\n }\n });\n\n traceSpan(\"drift.host-plugin-folders\", () => {\n changes.push(...hostPluginFolderChanges(homeRoot, expectedApply.expected_files ?? [], changes));\n });\n changes.push(...claudeChangedMarketplaceEntries(homeRoot, expectedApply.expected_files ?? []));\n\n const applied = Boolean(latestSnapshot);\n const blockingChanges = changes.filter((change) => !driftChangeIsKept(change));\n const hasDrift = !applied || !stackInSync || blockingChanges.length > 0;\n\n return driftCore(\n {\n activeProfile,\n profileExists: true,\n applied,\n snapshotId: latestSnapshot?.id ?? null,\n snapshotAt: latestSnapshot?.created_at ?? null,\n stackInSync,\n hasDrift,\n changes,\n projectPath: input.projectPath,\n expectedApply,\n pluginIds,\n },\n input.harness,\n homeRoot,\n );\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { ulid } from \"ulid\";\nimport { isEmptyBuiltinProfile } from \"../constants/profile.js\";\nimport { getHarnesstapDir } from \"../db/connection.js\";\nimport { getLatestGlobalApplySnapshotForProfile } from \"../models/global-apply-snapshot.js\";\nimport { getActiveProfileName } from \"./active-profile.js\";\nimport type { ApplyProfilePluginOptions } from \"./profile-apply.js\";\nimport { withProfileApplyLock } from \"./profile-apply-lock.js\";\nimport { flattenLiveRestoreFiles } from \"./snapshot-capture.js\";\nimport {\n buildProfileContents,\n type ProfileContents,\n} from \"./profile-contents.js\";\nimport type { DriftFileChange } from \"./project-drift.js\";\nimport {\n buildContentsFromResources,\n captureUntrackedResourcesForStash,\n removeUntrackedStashFiles,\n restoreUntrackedStashFiles,\n stashedFilesToDriftChanges,\n type StashedFileSnapshot,\n} from \"./profile-untracked-resources.js\";\nimport { resolveHomeRoot } from \"../utils/home-root.js\";\n\nexport interface ProfileStashEntry {\n id: string;\n profile_name: string;\n created_at: string;\n contents: ProfileContents;\n file_changes: DriftFileChange[];\n stashed_files: StashedFileSnapshot[];\n}\n\ninterface ProfileStashFile {\n entries: ProfileStashEntry[];\n}\n\nexport class ProfileStashError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ProfileStashError\";\n }\n}\n\nfunction emptyProfileContents(): ProfileContents {\n return {\n plugins: [],\n stack_resource_count: 0,\n stack_summary: null,\n type_counts: {},\n resources: [],\n plugin_pins: [],\n mcp_servers: [],\n };\n}\n\nfunction getProfileStashPath(): string {\n return join(getHarnesstapDir(), \"profile-stash.json\");\n}\n\nfunction isProfileContents(value: unknown): value is ProfileContents {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n const candidate = value as Partial<ProfileContents>;\n return Array.isArray(candidate.resources);\n}\n\nfunction isStashedFileSnapshot(value: unknown): value is StashedFileSnapshot {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n const candidate = value as Partial<StashedFileSnapshot>;\n return typeof candidate.path === \"string\" && typeof candidate.content === \"string\";\n}\n\nfunction hydrateStashEntry(raw: unknown): ProfileStashEntry | null {\n if (typeof raw !== \"object\" || raw === null) {\n return null;\n }\n const entry = raw as Partial<ProfileStashEntry>;\n if (\n typeof entry.id !== \"string\"\n || typeof entry.profile_name !== \"string\"\n || typeof entry.created_at !== \"string\"\n ) {\n return null;\n }\n\n const contents = isProfileContents(entry.contents)\n ? entry.contents\n : buildProfileContents(entry.profile_name) ?? emptyProfileContents();\n const fileChanges = Array.isArray(entry.file_changes)\n ? entry.file_changes.filter(\n (change): change is DriftFileChange =>\n typeof change === \"object\"\n && change !== null\n && typeof (change as DriftFileChange).path === \"string\"\n && typeof (change as DriftFileChange).type === \"string\",\n )\n : [];\n const stashedFiles = Array.isArray(entry.stashed_files)\n ? entry.stashed_files.filter(isStashedFileSnapshot)\n : [];\n\n return {\n id: entry.id,\n profile_name: entry.profile_name,\n created_at: entry.created_at,\n contents,\n file_changes: fileChanges,\n stashed_files: stashedFiles,\n };\n}\n\nfunction readProfileStashFile(): ProfileStashFile {\n const filePath = getProfileStashPath();\n if (!existsSync(filePath)) {\n return { entries: [] };\n }\n try {\n const parsed = JSON.parse(readFileSync(filePath, \"utf-8\")) as Partial<ProfileStashFile>;\n if (!Array.isArray(parsed.entries)) {\n return { entries: [] };\n }\n const entries = parsed.entries\n .map((entry) => hydrateStashEntry(entry))\n .filter((entry): entry is ProfileStashEntry => entry !== null);\n return { entries };\n } catch {\n return { entries: [] };\n }\n}\n\nfunction writeProfileStashFile(file: ProfileStashFile): void {\n const home = getHarnesstapDir();\n mkdirSync(home, { recursive: true });\n writeFileSync(\n getProfileStashPath(),\n `${JSON.stringify(file, null, 2)}\\n`,\n \"utf-8\",\n );\n}\n\nexport function listProfileStashEntries(): ProfileStashEntry[] {\n return readProfileStashFile().entries;\n}\n\nfunction pushProfileStashEntry(input: {\n profile_name: string;\n contents: ProfileContents;\n file_changes: DriftFileChange[];\n stashed_files: StashedFileSnapshot[];\n}): ProfileStashEntry {\n const file = readProfileStashFile();\n const entry: ProfileStashEntry = {\n id: ulid(),\n profile_name: input.profile_name,\n created_at: new Date().toISOString(),\n contents: input.contents,\n file_changes: input.file_changes,\n stashed_files: input.stashed_files,\n };\n file.entries.unshift(entry);\n writeProfileStashFile(file);\n return entry;\n}\n\nfunction popProfileStashEntry(): ProfileStashEntry | undefined {\n const file = readProfileStashFile();\n const entry = file.entries.shift();\n if (entry) {\n writeProfileStashFile(file);\n }\n return entry;\n}\n\nfunction peekProfileStashEntry(): ProfileStashEntry | undefined {\n return readProfileStashFile().entries[0];\n}\n\nfunction resolveStashableActiveProfile(): string {\n const activeProfile = getActiveProfileName();\n if (!activeProfile) {\n throw new ProfileStashError(\n \"No active profile to stash. Set one with profile use <name> first.\",\n );\n }\n if (isEmptyBuiltinProfile(activeProfile)) {\n throw new ProfileStashError(\n 'Legacy active profile \"empty\" has no stashable state. Run profile use <name>, then profile stash.',\n );\n }\n return activeProfile;\n}\n\nexport interface StashClearedUntrackedResult {\n dry_run: boolean;\n profile_name: string;\n removed_files: string[];\n}\n\nexport interface StashProfileResult {\n entry: ProfileStashEntry;\n cleared: StashClearedUntrackedResult;\n}\n\nfunction readHomeFile(homeRoot: string, relativePath: string): string | null {\n const fullPath = resolve(homeRoot, relativePath);\n if (!existsSync(fullPath)) {\n return null;\n }\n try {\n const bytes = readFileSync(fullPath);\n const text = bytes.toString(\"utf-8\");\n // The stash keeps text. A file that is not UTF-8 text (an image, a font)\n // would come back changed, so it is left in place, never stashed or rewritten.\n return Buffer.from(text, \"utf-8\").equals(bytes) ? text : null;\n } catch {\n return null;\n }\n}\n\nfunction lastWrittenContent(profileName: string, relativePath: string): Buffer | undefined {\n const snapshot = getLatestGlobalApplySnapshotForProfile(profileName);\n if (!snapshot?.state) {\n return undefined;\n }\n return flattenLiveRestoreFiles(snapshot.state, snapshot.id).find((file) => file.path === relativePath)?.bytes;\n}\n\n/**\n * Stash modified managed files (the same set `--changes save` walks) and restore\n * last-apply bytes when known. Never deletes the path.\n */\nexport async function stashManagedDriftChanges(input: {\n changes: DriftFileChange[];\n dryRun?: boolean;\n}): Promise<StashProfileResult> {\n return withProfileApplyLock(async () => {\n const profileName = resolveStashableActiveProfile();\n const homeRoot = resolveHomeRoot();\n const files: StashedFileSnapshot[] = [];\n for (const change of input.changes) {\n const current = readHomeFile(homeRoot, change.path);\n if (current === null) {\n continue;\n }\n files.push({ path: change.path, content: current });\n }\n if (files.length === 0) {\n throw new ProfileStashError(\"No unsaved changes to stash.\");\n }\n\n const contents = buildProfileContents(profileName) ?? emptyProfileContents();\n const fileChanges = stashedFilesToDriftChanges(files);\n\n if (!input.dryRun) {\n for (const file of files) {\n const previous = lastWrittenContent(profileName, file.path);\n if (previous === undefined) {\n continue;\n }\n const fullPath = resolve(homeRoot, file.path);\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, previous);\n }\n }\n\n if (input.dryRun) {\n return {\n entry: {\n id: \"dry-run\",\n profile_name: profileName,\n created_at: new Date().toISOString(),\n contents,\n file_changes: fileChanges,\n stashed_files: files,\n },\n cleared: {\n dry_run: true,\n profile_name: profileName,\n removed_files: [],\n },\n };\n }\n\n const entry = pushProfileStashEntry({\n profile_name: profileName,\n contents,\n file_changes: fileChanges,\n stashed_files: files,\n });\n return {\n entry,\n cleared: {\n dry_run: false,\n profile_name: profileName,\n removed_files: [],\n },\n };\n });\n}\n\nexport async function stashProfileCommand(\n options: ApplyProfilePluginOptions,\n): Promise<StashProfileResult> {\n return withProfileApplyLock(async () => {\n const profileName = resolveStashableActiveProfile();\n let capture: Awaited<ReturnType<typeof captureUntrackedResourcesForStash>>;\n try {\n capture = await captureUntrackedResourcesForStash({\n profileSelector: profileName,\n harness: options.harness,\n });\n } catch (error) {\n throw new ProfileStashError(\n error instanceof Error ? error.message : String(error),\n );\n }\n\n const homeRoot = resolveHomeRoot();\n const contents = buildContentsFromResources(capture.resources);\n const fileChanges = stashedFilesToDriftChanges(capture.files);\n const removedFiles = removeUntrackedStashFiles(\n homeRoot,\n capture.files,\n options.dryRun,\n );\n\n if (options.dryRun) {\n return {\n entry: {\n id: \"dry-run\",\n profile_name: profileName,\n created_at: new Date().toISOString(),\n contents,\n file_changes: fileChanges,\n stashed_files: capture.files,\n },\n cleared: {\n dry_run: true,\n profile_name: profileName,\n removed_files: removedFiles,\n },\n };\n }\n\n const entry = pushProfileStashEntry({\n profile_name: profileName,\n contents,\n file_changes: fileChanges,\n stashed_files: capture.files,\n });\n\n return {\n entry,\n cleared: {\n dry_run: false,\n profile_name: profileName,\n removed_files: removedFiles,\n },\n };\n });\n}\n\nexport interface RestoreStashedUntrackedResult {\n dry_run: boolean;\n profile_name: string;\n restored_files: string[];\n cancelled: boolean;\n}\n\nexport interface RestoreProfileStashResult {\n entry: ProfileStashEntry;\n restored: RestoreStashedUntrackedResult;\n removed: boolean;\n}\n\nexport async function popProfileStashCommand(\n options: ApplyProfilePluginOptions,\n): Promise<RestoreProfileStashResult> {\n return withProfileApplyLock(async () => {\n const entry = popProfileStashEntry();\n if (!entry) {\n throw new ProfileStashError(\"No stashed profile to restore.\");\n }\n const homeRoot = resolveHomeRoot();\n const restoredFiles = restoreUntrackedStashFiles(\n homeRoot,\n entry.stashed_files,\n options.dryRun,\n );\n return {\n entry,\n restored: {\n dry_run: options.dryRun === true,\n profile_name: entry.profile_name,\n restored_files: restoredFiles,\n cancelled: false,\n },\n removed: true,\n };\n });\n}\n\nexport async function applyProfileStashCommand(\n options: ApplyProfilePluginOptions,\n): Promise<RestoreProfileStashResult> {\n return withProfileApplyLock(async () => {\n const entry = peekProfileStashEntry();\n if (!entry) {\n throw new ProfileStashError(\"No stashed profile to restore.\");\n }\n const homeRoot = resolveHomeRoot();\n const restoredFiles = restoreUntrackedStashFiles(\n homeRoot,\n entry.stashed_files,\n options.dryRun,\n );\n return {\n entry,\n restored: {\n dry_run: options.dryRun === true,\n profile_name: entry.profile_name,\n restored_files: restoredFiles,\n cancelled: false,\n },\n removed: false,\n };\n });\n}\n","import {\n discardConfirm,\n discardedChangesLine,\n SWITCH_CHANGES_VALUES,\n type SwitchChangesValue,\n savedChangesLine,\n stashedChangesLine,\n unsavedChangesFlagHint,\n unsavedChangesLine,\n} from \"../copy/cli.js\";\nimport { ui } from \"../ui/index.js\";\nimport {\n detectGlobalProfileStatus,\n type GlobalProfileStatus,\n isHostPluginViewPath,\n} from \"./global-profile-drift.js\";\nimport { commitManagedPathFromLive } from \"./profile-commit-resource.js\";\nimport { stashManagedDriftChanges } from \"./profile-stash.js\";\nimport {\n promptForChoice,\n promptForConfirmation,\n shouldUseBrowsePicker,\n} from \"./wizards/shared.js\";\n\nexport type SwitchChangesDecision = \"continue\" | \"abort\";\n\nexport function parseSwitchChanges(\n raw: string | undefined,\n): SwitchChangesValue | \"invalid\" | undefined {\n if (raw === undefined || raw === \"\") {\n return undefined;\n }\n if ((SWITCH_CHANGES_VALUES as readonly string[]).includes(raw)) {\n return raw as SwitchChangesValue;\n }\n return \"invalid\";\n}\n\nexport async function maybeSyncActiveProfileBeforeSwitch(input: {\n targetProfileName: string;\n harness?: string;\n yes?: boolean;\n format?: string;\n changes?: string;\n noInteractive?: boolean;\n}): Promise<SwitchChangesDecision> {\n const format = input.format ?? \"human\";\n\n let status: GlobalProfileStatus;\n try {\n status = await detectGlobalProfileStatus({\n harness: input.harness,\n depth: \"full\",\n });\n } catch (error) {\n ui.warn(error instanceof Error ? error.message : String(error));\n return \"continue\";\n }\n\n if (!status.active_profile || status.active_profile === input.targetProfileName) {\n return \"continue\";\n }\n // Files in a plugin cache folder are the plugin's, not the profile's: they\n // cannot be saved to it, and apply keeps the user's own files there. They\n // are listed by `profile status` but are not unsaved changes. Neither are\n // the plugin registry entries Claude Code changed: apply keeps those too.\n const changes = status.changes.filter((change) =>\n !isHostPluginViewPath(change.path) && change.changed_by !== \"claude-code\");\n if (changes.length === 0) {\n return \"continue\";\n }\n\n const count = changes.length;\n const parsedChanges = parseSwitchChanges(input.changes);\n if (parsedChanges === \"invalid\") {\n ui.danger('Error: Invalid --changes. Use save, stash or discard.');\n return \"abort\";\n }\n\n const interactive =\n !input.yes\n && shouldUseBrowsePicker({\n noInteractive: input.noInteractive,\n format,\n });\n\n let action: SwitchChangesValue | \"cancel\";\n if (parsedChanges) {\n action = parsedChanges;\n } else if (!interactive) {\n ui.danger(`Error: ${unsavedChangesLine(status.active_profile, count)}`);\n ui.hint(unsavedChangesFlagHint());\n return \"abort\";\n } else {\n ui.warn(unsavedChangesLine(status.active_profile, count));\n action = await promptForChoice({\n message: \"What should HarnessTap do with them?\",\n choices: [\n { name: `Save them to \"${status.active_profile}\"`, value: \"save\" as const },\n { name: \"Stash them\", value: \"stash\" as const },\n { name: \"Discard them\", value: \"discard\" as const },\n { name: \"Cancel\", value: \"cancel\" as const },\n ],\n });\n }\n\n switch (action) {\n case \"cancel\":\n return \"abort\";\n case \"save\": {\n for (const change of changes) {\n try {\n await commitManagedPathFromLive({\n profileSelector: status.active_profile,\n path: change.path,\n scope: \"home\",\n ...(input.harness ? { harness: input.harness } : {}),\n });\n } catch {\n // Aggregate paths or unmapped files stay on disk; switch still proceeds.\n }\n }\n ui.success(savedChangesLine(status.active_profile, count));\n return \"continue\";\n }\n case \"stash\": {\n await stashManagedDriftChanges({\n changes,\n });\n ui.success(stashedChangesLine(count, \"ht profile stash pop\"));\n return \"continue\";\n }\n case \"discard\": {\n if (interactive && parsedChanges !== \"discard\") {\n const confirmed = await promptForConfirmation({\n message: discardConfirm(count),\n default: false,\n });\n if (!confirmed) {\n return \"abort\";\n }\n }\n ui.success(discardedChangesLine(count));\n return \"continue\";\n }\n default: {\n const unhandled: never = action;\n throw new Error(`Unhandled switch changes action: ${String(unhandled)}`);\n }\n }\n}\n","import {\n resolveProfileEnvironment,\n type ProjectProfileEntry,\n type ResolvedProjectConfig,\n} from \"../project-config.js\";\nimport {\n promptForChoice,\n promptForSearchableChoice,\n type PromptChoice,\n} from \"./shared.js\";\n\nfunction formatProfilePluginHint(entry: ProjectProfileEntry): string {\n switch (entry.source) {\n case \"catalog\":\n case \"local\":\n return entry.selector ?? entry.name;\n case \"inline\":\n return entry.plugin ?? entry.name;\n default: {\n const unhandledSource: never = entry.source;\n throw new Error(`Unhandled profile source: ${unhandledSource}`);\n }\n }\n}\n\nfunction formatProjectProfileChoiceName(\n config: ResolvedProjectConfig,\n entry: ProjectProfileEntry,\n): string {\n const parts = [entry.name, entry.source, formatProfilePluginHint(entry)];\n const environment = resolveProfileEnvironment(config, entry);\n if (environment) {\n parts.push(`env ${environment}`);\n }\n return parts.join(\" · \");\n}\n\nexport function buildProjectProfileChoices(\n config: ResolvedProjectConfig,\n): PromptChoice<string>[] {\n return config.profiles.map((entry) => ({\n name: formatProjectProfileChoiceName(config, entry),\n value: entry.name,\n }));\n}\n\nfunction resolveDefaultProfileKey(config: ResolvedProjectConfig): string | undefined {\n const defaultProfile = config.default_profile;\n if (!defaultProfile) {\n return undefined;\n }\n return config.profiles.some((profile) => profile.name === defaultProfile)\n ? defaultProfile\n : undefined;\n}\n\nexport async function promptForProjectProfile(\n config: ResolvedProjectConfig,\n): Promise<string> {\n const choices = buildProjectProfileChoices(config);\n const defaultProfile = resolveDefaultProfileKey(config);\n const message = \"Which project profile should be used?\";\n\n if (choices.length >= 5) {\n return promptForSearchableChoice({\n message,\n choices,\n default: defaultProfile,\n });\n }\n\n return promptForChoice({\n message,\n choices,\n default: defaultProfile,\n });\n}\n","import {\n isEmptyBuiltinProfile,\n isProfilePlugin,\n} from \"../constants/profile.js\";\nimport {\n addResourceToPlugin,\n createPlugin,\n resolvePluginSelector,\n} from \"../models/plugin-model.js\";\nimport {\n normalizeResourceInput,\n upsertResource,\n} from \"../models/resource.js\";\nimport type { ClaudePluginConfig, ResourceType } from \"../types.js\";\nimport { useEnvironmentCommand } from \"./environment-commands.js\";\nimport {\n formatEnvironmentToml,\n importEnvironmentToml,\n} from \"./environment-import-export.js\";\nimport { detectGlobalProfileStatus } from \"./global-profile-drift.js\";\nimport { installPluginFromCatalog } from \"./plugin-catalog-install.js\";\nimport { parsePluginSelector, resolveRemotePluginSelector } from \"./plugin-selector.js\";\nimport {\n promptMaterializationConflict,\n resolveApplyConflictPolicy,\n} from \"./materialization-conflicts.js\";\nimport {\n findProjectConfig,\n getProfileEntry,\n resolveProfileEnvironment,\n type ProjectProfileEntry,\n type ProjectPluginTable,\n type ResolvedProjectConfig,\n} from \"./project-config.js\";\nimport { MISSING_PROJECT_CONFIG_MESSAGE } from \"./project-config-messages.js\";\nimport { promptForProjectProfile } from \"./wizards/project-use.js\";\nimport { shouldUseWizard } from \"./wizards/shared.js\";\nimport { useProfileCommand } from \"./profile-commands.js\";\nimport { stashProfileCommand, ProfileStashError } from \"./profile-stash.js\";\nimport { maybeSyncActiveProfileBeforeSwitch } from \"./profile-switch-prompt.js\";\nimport { clearGlobalProfileApply, type ApplyProfilePluginResult } from \"./profile-apply.js\";\nimport { clearActiveProfileName, getActiveProfileName } from \"./active-profile.js\";\nimport { getGlobalActiveEnvironmentName } from \"./environment-session.js\";\n\nexport interface ProjectUseOptions {\n profile?: string;\n project?: string;\n dryRun?: boolean;\n force?: boolean;\n pull?: boolean;\n harness?: string;\n account?: string;\n baseUrl?: string;\n onConflict?: string;\n format?: string;\n yes?: boolean;\n interactive?: boolean;\n noInteractive?: boolean;\n}\n\nexport type ProjectUseResult =\n | {\n skipped: true;\n profile_key: string;\n plugin_name: string;\n environment_name?: string;\n }\n | ({\n skipped: false;\n profile_key: string;\n plugin_name: string;\n environment_name?: string;\n stashed?: boolean;\n stash_id?: string;\n } & ApplyProfilePluginResult);\n\nfunction assertProfilePlugin(plugin: { name: string; tags: string[] }, context: string): void {\n if (!isProfilePlugin(plugin)) {\n throw new Error(`Plugin \"${plugin.name}\" is not tagged as a profile (${context})`);\n }\n}\n\nfunction resolvePluginNameFromSelector(selector: string): string {\n const existing = resolvePluginSelector(selector);\n if (existing) {\n return existing.name;\n }\n return parsePluginSelector(selector).name;\n}\n\nexport function resolveExpectedPluginName(\n config: ResolvedProjectConfig,\n entry: ProjectProfileEntry,\n): string {\n switch (entry.source) {\n case \"catalog\":\n case \"local\": {\n const selector = entry.selector;\n if (!selector) {\n throw new Error(`Profile ${entry.name} is missing a plugin selector.`);\n }\n return resolvePluginNameFromSelector(selector);\n }\n case \"inline\": {\n const pluginKey = entry.plugin;\n if (!pluginKey) {\n throw new Error(`Inline profile ${entry.name} is missing a plugin reference.`);\n }\n const inlinePlugin = config.plugins.find((plugin) => plugin.name === pluginKey);\n return inlinePlugin?.name ?? pluginKey;\n }\n default: {\n const unhandledSource: never = entry.source;\n throw new Error(`Unhandled profile source: ${unhandledSource}`);\n }\n }\n}\n\nfunction resolvePreviewPluginName(\n config: ResolvedProjectConfig,\n entry: ProjectProfileEntry,\n): string {\n return resolveExpectedPluginName(config, entry);\n}\n\nfunction findInlinePluginTable(\n config: ResolvedProjectConfig,\n pluginKey: string,\n): ProjectPluginTable {\n const plugin = config.plugins.find((entry) => entry.name === pluginKey);\n if (!plugin) {\n throw new Error(`Inline profile references unknown plugin: ${pluginKey}`);\n }\n return plugin;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction importInlinePluginTable(pluginTable: ProjectPluginTable) {\n const resourcesRaw = Array.isArray(pluginTable.resources) ? pluginTable.resources : [];\n const plugin = createPlugin({\n name: pluginTable.name,\n version: typeof pluginTable.version === \"string\" ? pluginTable.version : \"1.0.0\",\n description: typeof pluginTable.description === \"string\" ? pluginTable.description : \"\",\n tags: Array.isArray(pluginTable.tags) ? pluginTable.tags.map(String) : [],\n ...(isRecord(pluginTable.claude)\n ? { claude: pluginTable.claude as ClaudePluginConfig }\n : {}),\n });\n\n for (const raw of resourcesRaw) {\n if (!isRecord(raw)) continue;\n const metadata = isRecord(raw.metadata)\n ? raw.metadata\n : typeof raw.metadata_json === \"string\"\n ? (JSON.parse(raw.metadata_json) as Record<string, unknown>)\n : {};\n const upserted = upsertResource(\n normalizeResourceInput({\n type: String(raw.type ?? \"\") as ResourceType,\n name: String(raw.name ?? \"\"),\n description: String(raw.description ?? \"\"),\n content: String(raw.content ?? \"\"),\n metadata,\n source: `project-inline:${pluginTable.name}`,\n namespace: String(raw.namespace ?? \"\"),\n origin_kind: (raw.origin_kind ?? \"manual\") as \"manual\",\n origin_ref: String(raw.origin_ref ?? \"\"),\n }),\n { policy: \"overwrite\" },\n );\n if (upserted.action === \"skipped\") {\n throw new Error(`Failed to import inline resource: ${String(raw.type)}:${String(raw.name)}`);\n }\n addResourceToPlugin(plugin.id, upserted.resource.id);\n }\n\n return plugin;\n}\n\nexport async function resolveProjectProfileKey(\n config: ResolvedProjectConfig,\n options: Pick<ProjectUseOptions, \"profile\" | \"format\" | \"interactive\" | \"noInteractive\">,\n): Promise<string> {\n if (options.profile) {\n getProfileEntry(config, options.profile);\n return options.profile;\n }\n\n if (config.profiles.length === 0) {\n throw new Error(\"Project config has no profiles\");\n }\n\n if (config.profiles.length === 1) {\n const [onlyProfile] = config.profiles;\n if (!onlyProfile) {\n throw new Error(\"Project config has no profiles\");\n }\n return onlyProfile.name;\n }\n\n if (\n shouldUseWizard({\n interactive: options.interactive,\n noInteractive: options.noInteractive,\n format: options.format,\n missingRequiredArgs: !options.profile,\n })\n ) {\n return promptForProjectProfile(config);\n }\n\n throw new Error(\"multiple profiles configured; pass --profile <name>\");\n}\n\nexport async function resolveProjectProfilePluginName(\n config: ResolvedProjectConfig,\n entry: ProjectProfileEntry,\n options: Pick<ProjectUseOptions, \"pull\" | \"account\" | \"baseUrl\">,\n): Promise<string> {\n const pull = options.pull ?? true;\n\n switch (entry.source) {\n case \"catalog\": {\n const selector = entry.selector;\n if (!selector) {\n throw new Error(`Catalog profile ${entry.name} is missing a plugin selector.`);\n }\n const existing = resolvePluginSelector(selector);\n if (existing) {\n assertProfilePlugin(existing, `catalog profile ${entry.name}`);\n return existing.name;\n }\n if (!pull) {\n throw new Error(\n `Profile plugin not found locally: ${selector}. Re-run with pull enabled or install the plugin first.`,\n );\n }\n\n const parsed = parsePluginSelector(selector);\n if (parsed.scope === \"published\") {\n const remote = resolveRemotePluginSelector(selector, {});\n const installed = await installPluginFromCatalog(remote, {\n account: options.account,\n baseUrl: options.baseUrl,\n });\n const plugin = resolvePluginSelector(installed.pluginName);\n if (!plugin) {\n throw new Error(`Plugin not found after catalog install: ${installed.pluginName}`);\n }\n assertProfilePlugin(plugin, `catalog profile ${entry.name}`);\n return plugin.name;\n }\n\n throw new Error(`Profile plugin not found locally: ${selector}`);\n }\n case \"local\": {\n const selector = entry.selector;\n if (!selector) {\n throw new Error(`Local profile ${entry.name} is missing a plugin selector.`);\n }\n const plugin = resolvePluginSelector(selector);\n if (!plugin) {\n throw new Error(`Profile plugin not found locally: ${selector}`);\n }\n assertProfilePlugin(plugin, `local profile ${entry.name}`);\n return plugin.name;\n }\n case \"inline\": {\n const pluginKey = entry.plugin;\n if (!pluginKey) {\n throw new Error(`Inline profile ${entry.name} is missing a plugin reference.`);\n }\n const pluginTable = findInlinePluginTable(config, pluginKey);\n const imported = importInlinePluginTable(pluginTable);\n assertProfilePlugin(imported, `inline profile ${entry.name}`);\n return imported.name;\n }\n default: {\n const unhandledSource: never = entry.source;\n throw new Error(`Unhandled profile source: ${unhandledSource}`);\n }\n }\n}\n\nexport async function importProjectConfigEnvironments(\n config: ResolvedProjectConfig,\n): Promise<void> {\n for (const environment of config.environments) {\n importEnvironmentToml(formatEnvironmentToml(environment), {\n createIfMissing: true,\n });\n }\n}\n\nexport async function shouldSkipProjectUse(input: {\n pluginName: string;\n environmentName?: string;\n force?: boolean;\n harness?: string;\n}): Promise<boolean> {\n if (input.force) {\n return false;\n }\n\n const activeProfile = getActiveProfileName();\n if (activeProfile !== input.pluginName) {\n return false;\n }\n\n const activeEnvironment = getGlobalActiveEnvironmentName();\n const environmentMatches =\n input.environmentName === undefined\n ? activeEnvironment === undefined\n : activeEnvironment === input.environmentName;\n if (!environmentMatches) {\n return false;\n }\n\n const status = await detectGlobalProfileStatus({ harness: input.harness });\n return (\n (!status.has_drift && status.stack_in_sync) ||\n (status.applied && !status.has_drift)\n );\n}\n\nexport async function executeProjectUse(\n options: ProjectUseOptions = {},\n): Promise<ProjectUseResult> {\n if (options.profile && isEmptyBuiltinProfile(options.profile)) {\n const conflictPolicy = resolveApplyConflictPolicy({\n onConflict: options.onConflict,\n noInteractive: options.noInteractive ?? options.format === \"json\",\n });\n let stashed: Awaited<ReturnType<typeof stashProfileCommand>> | undefined;\n try {\n stashed = await stashProfileCommand({\n harness: options.harness,\n dryRun: options.dryRun,\n conflictPolicy,\n pull: false,\n ...(conflictPolicy === \"prompt\"\n ? { conflictResolver: promptMaterializationConflict }\n : {}),\n });\n } catch (error) {\n if (!(error instanceof ProfileStashError)) {\n throw error;\n }\n }\n const cleared = await clearGlobalProfileApply({\n harness: options.harness,\n dryRun: options.dryRun,\n conflictPolicy,\n pull: false,\n ...(conflictPolicy === \"prompt\"\n ? { conflictResolver: promptMaterializationConflict }\n : {}),\n });\n if (!options.dryRun) {\n clearActiveProfileName();\n }\n return {\n skipped: false,\n profile_key: stashed?.entry.profile_name ?? getActiveProfileName() ?? \"empty\",\n plugin_name: cleared.profile_name,\n stashed: Boolean(stashed),\n ...(stashed ? { stash_id: stashed.entry.id } : {}),\n ...cleared,\n };\n }\n\n const config = findProjectConfig(options.project ?? process.cwd());\n if (!config) {\n throw new Error(MISSING_PROJECT_CONFIG_MESSAGE);\n }\n\n const profileKey = await resolveProjectProfileKey(config, {\n profile: options.profile,\n format: options.format,\n interactive: options.interactive,\n noInteractive: options.noInteractive,\n });\n const entry = getProfileEntry(config, profileKey);\n const environmentName = resolveProfileEnvironment(config, entry);\n const expectedPluginName = resolveExpectedPluginName(config, entry);\n const dryRun = options.dryRun === true;\n\n if (\n await shouldSkipProjectUse({\n pluginName: expectedPluginName,\n environmentName,\n force: options.force,\n harness: options.harness,\n })\n ) {\n return {\n skipped: true,\n profile_key: profileKey,\n plugin_name: expectedPluginName,\n ...(environmentName ? { environment_name: environmentName } : {}),\n };\n }\n\n if (!dryRun) {\n await importProjectConfigEnvironments(config);\n }\n\n const pluginName = dryRun\n ? resolvePreviewPluginName(config, entry)\n : await resolveProjectProfilePluginName(config, entry, {\n pull: options.pull ?? true,\n account: options.account,\n baseUrl: options.baseUrl,\n });\n\n if (environmentName && !dryRun) {\n useEnvironmentCommand(environmentName);\n }\n\n if (!dryRun) {\n const sync = await maybeSyncActiveProfileBeforeSwitch({\n targetProfileName: pluginName,\n harness: options.harness,\n yes: options.yes,\n format: options.format,\n });\n if (sync === \"abort\") {\n throw new Error(\"Profile switch cancelled.\");\n }\n }\n\n const conflictPolicy = resolveApplyConflictPolicy({\n onConflict: options.onConflict,\n noInteractive: options.noInteractive ?? options.format === \"json\",\n });\n const applied = await useProfileCommand(pluginName, {\n harness: options.harness,\n dryRun: options.dryRun,\n pull: options.pull ?? true,\n account: options.account,\n baseUrl: options.baseUrl,\n conflictPolicy,\n ...(conflictPolicy === \"prompt\"\n ? { conflictResolver: promptMaterializationConflict }\n : {}),\n });\n\n return {\n skipped: false,\n profile_key: profileKey,\n plugin_name: pluginName,\n ...(environmentName ? { environment_name: environmentName } : {}),\n ...applied,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,YAAY,MAAM,eAAe;AAGnC,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EAET,YAAY,OAAe,UAAkB;AAC3C,UAAM,wBAAwB,KAAK,GAAG;AACtC,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,WAAW;AAAA,EAClB;AAAA,EAES;AACX;AAEO,SAAS,eAAe,KAAa,OAAO,gBAAgB,GAAW;AAC5E,QAAM,UAAU,IAAI,KAAK;AACzB,MAAI,YAAY,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AQ,iBAAiB,QAAQ,WAAW;AAAA,EAC7D,CAAC;AACD,QAAM,UAAU,MAAM,kBAAkB,YAAY;AAAA,IAClD,SAAS,QAAQ;AAAA,IACjB,QAAQ,QAAQ;AAAA,IAChB,MAAM,QAAQ,QAAQ;AAAA,IACtB,SAAS,QAAQ;AAAA,IACjB,SAAS,QAAQ;AAAA,IACjB;AAAA,IACA,GAAI,mBAAmB,WACnB,EAAE,kBAAkB,8BAA8B,IAClD,CAAC;AAAA,EACP,CAAC;AAED,SAAO;AAAA,IACL,SAAS;AAAA,IACT,aAAa;AAAA,IACb,aAAa;AAAA,IACb,GAAI,kBAAkB,EAAE,kBAAkB,gBAAgB,IAAI,CAAC;AAAA,IAC/D,GAAG;AAAA,EACL;AACF;","names":["existsSync","join","join","existsSync","latestSnapshot","expectedApply","stackInSync","applied","hasDrift","join","existsSync","readFileSync","join","resolve","join","existsSync","readFileSync","resolve","conflictPolicy"]}
@@ -1,9 +1,6 @@
1
1
  import {
2
2
  useTerminalSize
3
- } from "./chunk-BXSS2S4W.js";
4
- import {
5
- renderFoldedHintLine
6
- } from "./chunk-XGTTOO4R.js";
3
+ } from "./chunk-R27VZIF6.js";
7
4
  import {
8
5
  buildHelpLine,
9
6
  clampActiveIndex,
@@ -13,9 +10,12 @@ import {
13
10
  isEscapeKey,
14
11
  isSearchCharacter
15
12
  } from "./chunk-3FIWOI3H.js";
13
+ import {
14
+ renderFoldedHintLine
15
+ } from "./chunk-BUA7WFI4.js";
16
16
  import {
17
17
  theme
18
- } from "./chunk-LDVXYN6F.js";
18
+ } from "./chunk-OHZNDV4A.js";
19
19
 
20
20
  // src/services/wizards/prompts/create-table-browser-prompt.ts
21
21
  import {
@@ -529,4 +529,4 @@ export {
529
529
  renderScrollableShowContent,
530
530
  createTableBrowserPrompt
531
531
  };
532
- //# sourceMappingURL=chunk-3EGM4IUI.js.map
532
+ //# sourceMappingURL=chunk-EPXAOEBB.js.map
@@ -6,44 +6,53 @@ import {
6
6
  isPackageEntryFileName,
7
7
  packageDirectoryDisplayPath,
8
8
  resourceHumanName
9
- } from "./chunk-OQ4KBUN2.js";
9
+ } from "./chunk-L6BJCRBU.js";
10
10
  import {
11
- resolveExistingResourceFilesystemPath
12
- } from "./chunk-6ZWKF3YZ.js";
13
- import {
14
- shouldUseWizard
15
- } from "./chunk-NAGAJ5UM.js";
11
+ parseOutputFormat
12
+ } from "./chunk-R4NV3Q7G.js";
16
13
  import {
14
+ PluginNotInMarketplaceError,
17
15
  RESOURCE_TYPES,
18
16
  getInstalledCursorPluginInstallPath,
19
17
  hostPluginPullUnavailableReason,
18
+ installMarketplacePinIntoCache,
19
+ isLiveLibraryRef,
20
20
  listContainedFilesPage,
21
21
  listHostPluginVersions,
22
+ listPlugins,
23
+ listResources,
22
24
  listResourcesMatchingOriginRef,
25
+ marketplaceIsConfigured,
26
+ marketplaceListsPlugin,
23
27
  parseDependencyRef,
24
- resolveHomeRoot,
28
+ readResourceContentFromPathHint,
29
+ registerDeclaredMarketplaces,
30
+ resolveExistingResourceFilesystemPath,
25
31
  resolveInstallRoot,
26
- resolveMarketplaceRoot
27
- } from "./chunk-KJIFZLHN.js";
32
+ resolveMarketplaceRoot,
33
+ shortenHomePath,
34
+ syncLinkedResources,
35
+ syncPluginResource
36
+ } from "./chunk-BUA7WFI4.js";
28
37
  import {
29
38
  builtinMarketplaceEntry,
39
+ findKnownMarketplace,
30
40
  listMarketplaces,
31
41
  normalizeMarketplaceUrl,
32
42
  readJsonFile,
33
- readMarketplaceManifest
34
- } from "./chunk-ZVANUFPF.js";
35
- import {
36
- parseOutputFormat
37
- } from "./chunk-TQ2NA4Z4.js";
43
+ readMarketplaceManifest,
44
+ refreshMarketplaceCatalog,
45
+ resolveHomeRoot,
46
+ shouldUseWizard,
47
+ wellKnownMarketplaceEntry
48
+ } from "./chunk-UC27MQ3T.js";
38
49
  import {
39
50
  formatRelativeTimeWithAbsolute,
51
+ getHarnesstapDir,
40
52
  renderPanel,
41
53
  renderSubheader,
42
54
  ui
43
- } from "./chunk-LDVXYN6F.js";
44
- import {
45
- getHarnesstapDir
46
- } from "./chunk-24V5ZSIF.js";
55
+ } from "./chunk-OHZNDV4A.js";
47
56
 
48
57
  // src/cli/handlers/resource-list.ts
49
58
  function makeResourceTypeColumn(width = 14) {
@@ -92,6 +101,128 @@ function resourceListRenderOptions(opts) {
92
101
  };
93
102
  }
94
103
 
104
+ // src/services/resource-sync-install.ts
105
+ function marketplaceDependencySelectorRef(selector) {
106
+ const trimmed = selector?.trim();
107
+ if (!trimmed) return void 0;
108
+ const ref = trimmed.replace(/^(plugin|plugin_pin):/, "");
109
+ return parseDependencyRef(ref).source_kind === "marketplace" ? ref : void 0;
110
+ }
111
+ function marketplaceIsResolvable(marketplace, homeRoot) {
112
+ return Boolean(
113
+ findKnownMarketplace(getHarnesstapDir(), marketplace) ?? wellKnownMarketplaceEntry(marketplace) ?? (marketplaceIsConfigured(homeRoot, marketplace) ? marketplace : void 0)
114
+ );
115
+ }
116
+ function marketplaceIsKnown(marketplace, homeRoot) {
117
+ if (marketplaceIsResolvable(marketplace, homeRoot)) return true;
118
+ return listPlugins().some((plugin) => Boolean(plugin.claude?.marketplaces?.[marketplace]));
119
+ }
120
+ function unknownMarketplaceReason(marketplace) {
121
+ return `marketplace ${marketplace} is not configured. Add it with ht marketplace add <git-url> --name ${marketplace}, then run this command again`;
122
+ }
123
+ function undeclaredDependencyReason(ref) {
124
+ return `no plugin depends on ${ref}, so there is nothing to install. Add it with ht plugin add ${ref} --to <plugin>, then run this command again`;
125
+ }
126
+ function registerMarketplaceDeclaredByLibrary(marketplace) {
127
+ const harnesstapDir = getHarnesstapDir();
128
+ if (findKnownMarketplace(harnesstapDir, marketplace)) return;
129
+ for (const plugin of listPlugins()) {
130
+ const entry = plugin.claude?.marketplaces?.[marketplace];
131
+ if (!entry) continue;
132
+ if (registerDeclaredMarketplaces({ marketplaces: { [marketplace]: entry } }, harnesstapDir).added.length > 0) {
133
+ return;
134
+ }
135
+ }
136
+ }
137
+ async function syncResourcesInstallingDependencies(options = {}) {
138
+ const ref = marketplaceDependencySelectorRef(options.selector);
139
+ const pins = ref ? listResources({ type: "plugin", includeComposition: true }).filter(
140
+ (resource) => resource.origin_ref === ref
141
+ ) : [];
142
+ if (!ref) {
143
+ return syncLinkedResources(options);
144
+ }
145
+ if (pins.length === 0) {
146
+ const result = await syncLinkedResources(options);
147
+ const marketplace = parseDependencyRef(ref).namespace;
148
+ const homeRoot2 = options.homeRoot ?? resolveHomeRoot();
149
+ registerMarketplaceDeclaredByLibrary(marketplace);
150
+ if (!marketplaceIsResolvable(marketplace, homeRoot2)) {
151
+ result.failed = [
152
+ ...result.failed ?? [],
153
+ { ref, reason: unknownMarketplaceReason(marketplace) }
154
+ ];
155
+ } else {
156
+ const pluginName = parseDependencyRef(ref).name;
157
+ const harnesstapDir = getHarnesstapDir();
158
+ const lookup = () => marketplaceListsPlugin({ homeRoot: homeRoot2, harnesstapDir, marketplace, pluginName });
159
+ let listed = lookup();
160
+ if (listed === void 0 && !options.dryRun && findKnownMarketplace(harnesstapDir, marketplace)) {
161
+ const refreshed = await refreshMarketplaceCatalog(harnesstapDir, {
162
+ name: marketplace,
163
+ force: false,
164
+ unattended: false
165
+ });
166
+ if (refreshed.ok) listed = lookup();
167
+ }
168
+ if (listed === false) {
169
+ result.failed = [
170
+ ...result.failed ?? [],
171
+ { ref, reason: new PluginNotInMarketplaceError(pluginName, marketplace).message }
172
+ ];
173
+ } else if (result.checked === 0) {
174
+ result.failed = [...result.failed ?? [], { ref, reason: undeclaredDependencyReason(ref) }];
175
+ }
176
+ }
177
+ return result;
178
+ }
179
+ const homeRoot = options.homeRoot ?? resolveHomeRoot();
180
+ const aggregated = {
181
+ checked: 0,
182
+ updated: [],
183
+ stale: [],
184
+ unchanged: [],
185
+ skipped: [],
186
+ failed: []
187
+ };
188
+ for (const pin of pins) {
189
+ if (!options.dryRun && !resolveInstallRoot(ref, homeRoot, options.claudePluginsRoot)) {
190
+ const metadata = pin.metadata;
191
+ const marketplace = parseDependencyRef(ref).namespace;
192
+ registerMarketplaceDeclaredByLibrary(marketplace);
193
+ if (!marketplaceIsResolvable(marketplace, homeRoot)) {
194
+ aggregated.checked += 1;
195
+ aggregated.stale.push({
196
+ resource: pin,
197
+ reason: unknownMarketplaceReason(marketplace)
198
+ });
199
+ aggregated.failed?.push({ ref, reason: unknownMarketplaceReason(marketplace) });
200
+ continue;
201
+ }
202
+ try {
203
+ await installMarketplacePinIntoCache({
204
+ originRef: ref,
205
+ versionConstraint: metadata.version_constraint,
206
+ homeRoot
207
+ });
208
+ } catch (error) {
209
+ aggregated.checked += 1;
210
+ const reason = error instanceof PluginNotInMarketplaceError ? error.message : `could not install ${ref}: ${error instanceof Error ? error.message : String(error)}`;
211
+ aggregated.stale.push({ resource: pin, reason });
212
+ aggregated.failed?.push({ ref, reason });
213
+ continue;
214
+ }
215
+ }
216
+ const result = await syncPluginResource(pin, { ...options, homeRoot });
217
+ aggregated.checked += result.checked;
218
+ aggregated.updated.push(...result.updated);
219
+ aggregated.stale.push(...result.stale);
220
+ aggregated.unchanged.push(...result.unchanged);
221
+ aggregated.skipped.push(...result.skipped);
222
+ }
223
+ return aggregated;
224
+ }
225
+
95
226
  // src/services/resource-show.ts
96
227
  import { readFileSync } from "fs";
97
228
 
@@ -422,15 +553,17 @@ function resourceShowExtras(resource) {
422
553
  return pluginResourceShowExtras(resource) ?? packageResourceShowExtras(resource);
423
554
  }
424
555
  function resourceShowPanelRows(resource, extras, opts) {
425
- const path = extras && "install_path" in extras && extras.install_path ? extras.install_path : packageDirectoryDisplayPath(resource.source);
556
+ const rawPath = extras && "install_path" in extras && extras.install_path ? extras.install_path : packageDirectoryDisplayPath(resource.source);
557
+ const path = rawPath ? shortenHomePath(rawPath) : rawPath;
558
+ const originRef = resource.origin_ref ? shortenHomePath(resource.origin_ref) : resource.origin_ref;
426
559
  const panelRows = [
427
560
  ["Type", resource.type],
428
561
  ["Name", resourceHumanName(resource)],
429
- ["Description", resource.description || ": "],
430
- ["Path", path || ": "],
562
+ ["Description", resource.description || "none"],
563
+ ["Path", path || "none"],
431
564
  ["Origin", formatOriginDisplayLabel(
432
565
  resource.origin_kind,
433
- resource.origin_ref,
566
+ originRef,
434
567
  { includeRef: resource.type !== "plugin" }
435
568
  )],
436
569
  ["Updated", formatRelativeTimeWithAbsolute(resource.updated_at)]
@@ -441,7 +574,7 @@ function resourceShowPanelRows(resource, extras, opts) {
441
574
  if (opts?.showAllFields) {
442
575
  panelRows.push(
443
576
  ["Source", resource.source],
444
- ["Content hash", resource.content_hash || ": "],
577
+ ["Content hash", resource.content_hash || "none"],
445
578
  ["ID", resource.id],
446
579
  ["Created", resource.created_at],
447
580
  ["Metadata", JSON.stringify(resource.metadata)]
@@ -474,11 +607,29 @@ function readContainedSkillBody(files) {
474
607
  return void 0;
475
608
  }
476
609
  }
610
+ function readOnDiskResourceBody(resource) {
611
+ const filesystemPath = resolveExistingResourceFilesystemPath(resource);
612
+ if (!filesystemPath) {
613
+ return void 0;
614
+ }
615
+ try {
616
+ return readResourceContentFromPathHint(filesystemPath).content;
617
+ } catch {
618
+ return void 0;
619
+ }
620
+ }
477
621
  function resolveResourceBody(resource, extras) {
478
- if (resource.type !== "plugin" && resource.content.trim().length > 0) {
622
+ if (resource.type === "plugin") {
623
+ return resource.content;
624
+ }
625
+ if (!isLiveLibraryRef(resource) && resource.content.trim().length > 0) {
479
626
  return resource.content;
480
627
  }
481
- if (resource.type !== "plugin" && extras && "contained_resources" in extras) {
628
+ const onDisk = readOnDiskResourceBody(resource);
629
+ if (onDisk !== void 0) {
630
+ return onDisk;
631
+ }
632
+ if (extras && "contained_resources" in extras) {
482
633
  const fromDisk = readContainedSkillBody(extras.contained_resources);
483
634
  if (fromDisk !== void 0) {
484
635
  return fromDisk;
@@ -534,7 +685,9 @@ export {
534
685
  resolveResourceListType,
535
686
  shouldUseInteractiveResourceList,
536
687
  resourceListRenderOptions,
688
+ marketplaceIsKnown,
689
+ syncResourcesInstallingDependencies,
537
690
  renderResourceShow,
538
691
  printResourceShow
539
692
  };
540
- //# sourceMappingURL=chunk-64R32MG2.js.map
693
+ //# sourceMappingURL=chunk-GZU4LVFF.js.map