harnesstap 1.3.1 → 1.4.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 (217) hide show
  1. package/README.md +2 -0
  2. package/dist/apply-SUNDXRJ3.js +54 -0
  3. package/dist/{approve-KQNCNH2R.js → approve-FBGYQGWN.js} +14 -15
  4. package/dist/{approve-KQNCNH2R.js.map → approve-FBGYQGWN.js.map} +1 -1
  5. package/dist/{audit-SLYOZCMI.js → audit-VI4QZ6X2.js} +30 -39
  6. package/dist/{audit-SLYOZCMI.js.map → audit-VI4QZ6X2.js.map} +1 -1
  7. package/dist/{auth-3IEVICFT.js → auth-4CQCDS2W.js} +17 -19
  8. package/dist/{auth-3IEVICFT.js.map → auth-4CQCDS2W.js.map} +1 -1
  9. package/dist/bin.js +3 -3
  10. package/dist/{chunk-KDDXZBMC.js → chunk-23XSG7LI.js} +7 -11
  11. package/dist/{chunk-KDDXZBMC.js.map → chunk-23XSG7LI.js.map} +1 -1
  12. package/dist/{chunk-YDD3ES2K.js → chunk-2A36HWDE.js} +63 -13
  13. package/dist/chunk-2A36HWDE.js.map +1 -0
  14. package/dist/{chunk-IK524ZDW.js → chunk-3FS775NP.js} +51 -4
  15. package/dist/chunk-3FS775NP.js.map +1 -0
  16. package/dist/{chunk-IBOABSIA.js → chunk-3P6BWL5F.js} +2 -2
  17. package/dist/{chunk-G26HZZDJ.js → chunk-43BDGVN3.js} +19 -6
  18. package/dist/chunk-43BDGVN3.js.map +1 -0
  19. package/dist/{chunk-TYULB6ZY.js → chunk-4ZQ2SCGY.js} +146 -78
  20. package/dist/chunk-4ZQ2SCGY.js.map +1 -0
  21. package/dist/{chunk-6BY4BV5G.js → chunk-6LTLYV5D.js} +353 -230
  22. package/dist/chunk-6LTLYV5D.js.map +1 -0
  23. package/dist/{chunk-GQKKX7OE.js → chunk-73OJQTBW.js} +6 -2
  24. package/dist/chunk-73OJQTBW.js.map +1 -0
  25. package/dist/{chunk-IRU7NBOT.js → chunk-7HP6AAI3.js} +2 -2
  26. package/dist/{chunk-MWXA4PFE.js → chunk-BPWFQKI5.js} +5 -7
  27. package/dist/{chunk-MWXA4PFE.js.map → chunk-BPWFQKI5.js.map} +1 -1
  28. package/dist/{chunk-3RBYT7QN.js → chunk-D432JAXV.js} +44 -19
  29. package/dist/chunk-D432JAXV.js.map +1 -0
  30. package/dist/chunk-DF4Z7LAD.js +3463 -0
  31. package/dist/chunk-DF4Z7LAD.js.map +1 -0
  32. package/dist/{chunk-J4CKQXQ6.js → chunk-EOPFER6N.js} +71 -318
  33. package/dist/chunk-EOPFER6N.js.map +1 -0
  34. package/dist/chunk-G6WKY2W4.js +389 -0
  35. package/dist/chunk-G6WKY2W4.js.map +1 -0
  36. package/dist/{chunk-JKGSJGCC.js → chunk-GRASK6M6.js} +5 -5
  37. package/dist/{chunk-63U7QWNY.js → chunk-IE7B6Q5K.js} +33 -39
  38. package/dist/chunk-IE7B6Q5K.js.map +1 -0
  39. package/dist/{chunk-VC6OKCJF.js → chunk-IMROMZ2K.js} +7 -4
  40. package/dist/{chunk-VC6OKCJF.js.map → chunk-IMROMZ2K.js.map} +1 -1
  41. package/dist/{chunk-DV74UZJI.js → chunk-L6YZE5MY.js} +3 -3
  42. package/dist/{chunk-SNVAMWB7.js → chunk-M2U3J7UX.js} +7 -1
  43. package/dist/chunk-M2U3J7UX.js.map +1 -0
  44. package/dist/{chunk-BSOBXLYI.js → chunk-M4KLHJ6U.js} +16 -13
  45. package/dist/chunk-M4KLHJ6U.js.map +1 -0
  46. package/dist/{chunk-VL7BGD47.js → chunk-MR7IOHSX.js} +16 -19
  47. package/dist/chunk-MR7IOHSX.js.map +1 -0
  48. package/dist/{chunk-4KNQZDZC.js → chunk-N3VGY3T3.js} +15 -15
  49. package/dist/chunk-N3VGY3T3.js.map +1 -0
  50. package/dist/{chunk-ZY2MZ2KQ.js → chunk-N3ZCH64F.js} +496 -10
  51. package/dist/chunk-N3ZCH64F.js.map +1 -0
  52. package/dist/{chunk-H6DVP2SI.js → chunk-OML4HXKT.js} +20 -22
  53. package/dist/chunk-OML4HXKT.js.map +1 -0
  54. package/dist/{chunk-NJ7WRKIQ.js → chunk-P2C7JPLD.js} +3 -3
  55. package/dist/{chunk-LNJ3WZZX.js → chunk-PCMON7Y2.js} +7 -7
  56. package/dist/{chunk-VL2NWCZV.js → chunk-PNGF5EV2.js} +2 -2
  57. package/dist/{chunk-SZNBUIDR.js → chunk-QA5U36JN.js} +199 -215
  58. package/dist/chunk-QA5U36JN.js.map +1 -0
  59. package/dist/{chunk-KDAV2GUT.js → chunk-R7ZOYVN3.js} +241 -126
  60. package/dist/chunk-R7ZOYVN3.js.map +1 -0
  61. package/dist/{chunk-QO4LBDVI.js → chunk-RDG5DT7S.js} +45 -49
  62. package/dist/{chunk-QO4LBDVI.js.map → chunk-RDG5DT7S.js.map} +1 -1
  63. package/dist/{chunk-VQVUJYYY.js → chunk-REHRUNBB.js} +8 -3
  64. package/dist/chunk-REHRUNBB.js.map +1 -0
  65. package/dist/{chunk-DXKAKKLP.js → chunk-RFQ3N7FB.js} +19 -29
  66. package/dist/chunk-RFQ3N7FB.js.map +1 -0
  67. package/dist/{chunk-C4QBVVEH.js → chunk-RVEXPMM3.js} +3 -3
  68. package/dist/{chunk-XFZQVYIN.js → chunk-TPEJFLV7.js} +13 -15
  69. package/dist/{chunk-XFZQVYIN.js.map → chunk-TPEJFLV7.js.map} +1 -1
  70. package/dist/{chunk-7LWH5SWH.js → chunk-U6DXASQP.js} +2 -2
  71. package/dist/{chunk-BIBUCC2E.js → chunk-ULCD6DJE.js} +30 -8
  72. package/dist/chunk-ULCD6DJE.js.map +1 -0
  73. package/dist/{chunk-KMWHZSEG.js → chunk-UVVZHWD2.js} +2 -2
  74. package/dist/{chunk-DWVAR4BP.js → chunk-WG5A6EAU.js} +270 -12
  75. package/dist/chunk-WG5A6EAU.js.map +1 -0
  76. package/dist/{chunk-QRZPQNLX.js → chunk-WGP4GUYZ.js} +10 -10
  77. package/dist/{chunk-F2L4VNQK.js → chunk-XTVGCVU4.js} +124 -83
  78. package/dist/chunk-XTVGCVU4.js.map +1 -0
  79. package/dist/{chunk-EIWXS4RM.js → chunk-XUJKZQZA.js} +8 -8
  80. package/dist/chunk-XUJKZQZA.js.map +1 -0
  81. package/dist/chunk-ZUASVASP.js +30317 -0
  82. package/dist/chunk-ZUASVASP.js.map +1 -0
  83. package/dist/{compile-57EEIUMB.js → compile-GXADKGH5.js} +37 -50
  84. package/dist/{compile-57EEIUMB.js.map → compile-GXADKGH5.js.map} +1 -1
  85. package/dist/{config-4EJ3D7QJ.js → config-JMHNA2U5.js} +22 -35
  86. package/dist/{config-4EJ3D7QJ.js.map → config-JMHNA2U5.js.map} +1 -1
  87. package/dist/cursor-local-install-46RWRBDT.js +98 -0
  88. package/dist/cursor-local-install-46RWRBDT.js.map +1 -0
  89. package/dist/{doctor-EEV6P5CH.js → doctor-N7ZULPOL.js} +18 -19
  90. package/dist/{doctor-EEV6P5CH.js.map → doctor-N7ZULPOL.js.map} +1 -1
  91. package/dist/{environment-WFEG4DAT.js → environment-OBB3WU5B.js} +60 -71
  92. package/dist/{environment-WFEG4DAT.js.map → environment-OBB3WU5B.js.map} +1 -1
  93. package/dist/{github-BSMQD72A.js → github-PBYBGOLH.js} +17 -17
  94. package/dist/{harness-VX3PNVQW.js → harness-7KYATIV6.js} +56 -67
  95. package/dist/{harness-VX3PNVQW.js.map → harness-7KYATIV6.js.map} +1 -1
  96. package/dist/{help-AW2HKX63.js → help-EE3AJQD4.js} +48 -52
  97. package/dist/help-EE3AJQD4.js.map +1 -0
  98. package/dist/{help-BVFOZD7E.js → help-VXWKLQ6A.js} +55 -15
  99. package/dist/help-VXWKLQ6A.js.map +1 -0
  100. package/dist/index.d.ts +7 -0
  101. package/dist/index.js +16 -24
  102. package/dist/{init-SPN2GEZ4.js → init-LBTMPDVJ.js} +43 -56
  103. package/dist/init-LBTMPDVJ.js.map +1 -0
  104. package/dist/live-read-cache-TUSP7U3D.js +10 -0
  105. package/dist/{lock-K2LLUU7H.js → lock-WLJRXRVK.js} +16 -16
  106. package/dist/{marketplace-VEKSWGX3.js → marketplace-GXSV6QIY.js} +62 -28
  107. package/dist/marketplace-GXSV6QIY.js.map +1 -0
  108. package/dist/{mcp-T6DKIKSF.js → mcp-XPDWWU75.js} +35 -48
  109. package/dist/{mcp-T6DKIKSF.js.map → mcp-XPDWWU75.js.map} +1 -1
  110. package/dist/{migrate-OO37WSB2.js → migrate-SBUIWN3U.js} +79 -64
  111. package/dist/migrate-SBUIWN3U.js.map +1 -0
  112. package/dist/open-HDGLYYVU.js +24 -0
  113. package/dist/{pack-V32UPC7W.js → pack-A73LDVOX.js} +16 -22
  114. package/dist/{pack-V32UPC7W.js.map → pack-A73LDVOX.js.map} +1 -1
  115. package/dist/plugin-CEO6ZJM5.js +51 -0
  116. package/dist/plugin-from-project-UK7VJVUP.js +18 -0
  117. package/dist/{policy-F5MKZNOC.js → policy-6VY3CMSU.js} +13 -14
  118. package/dist/{policy-F5MKZNOC.js.map → policy-6VY3CMSU.js.map} +1 -1
  119. package/dist/{profile-H4PMH4XT.js → profile-YCKPMRRU.js} +96 -102
  120. package/dist/profile-YCKPMRRU.js.map +1 -0
  121. package/dist/{project-QVNEJJGH.js → project-KHPPBKPN.js} +63 -77
  122. package/dist/{project-QVNEJJGH.js.map → project-KHPPBKPN.js.map} +1 -1
  123. package/dist/{resource-GL4RLSGI.js → resource-IJU3FAN5.js} +42 -49
  124. package/dist/{resource-GL4RLSGI.js.map → resource-IJU3FAN5.js.map} +1 -1
  125. package/dist/{version-PBHZK44K.js → version-Z66FWWMQ.js} +2 -2
  126. package/dist/version-Z66FWWMQ.js.map +1 -0
  127. package/package.json +4 -1
  128. package/schemas/fixtures/confidence.ap.json +1 -1
  129. package/schemas/fixtures/context7.ap.json +1 -1
  130. package/schemas/fixtures/legacy-schema-v1.ap.json +13 -0
  131. package/schemas/fixtures/legacy-schemas-v1.ap.json +13 -0
  132. package/schemas/fixtures/minimal-with-schema.ap.json +1 -1
  133. package/schemas/fixtures/superpowers.ap.json +1 -1
  134. package/schemas/fixtures/third-party-skills.ap.json +1 -1
  135. package/dist/apply-2GRNKR5H.js +0 -67
  136. package/dist/chunk-2EIJYDNI.js +0 -10945
  137. package/dist/chunk-2EIJYDNI.js.map +0 -1
  138. package/dist/chunk-3IWTJCPA.js +0 -6448
  139. package/dist/chunk-3IWTJCPA.js.map +0 -1
  140. package/dist/chunk-3IZ7SEGT.js +0 -346
  141. package/dist/chunk-3IZ7SEGT.js.map +0 -1
  142. package/dist/chunk-3RBYT7QN.js.map +0 -1
  143. package/dist/chunk-4KNQZDZC.js.map +0 -1
  144. package/dist/chunk-63U7QWNY.js.map +0 -1
  145. package/dist/chunk-6BY4BV5G.js.map +0 -1
  146. package/dist/chunk-7L2K4N25.js +0 -610
  147. package/dist/chunk-7L2K4N25.js.map +0 -1
  148. package/dist/chunk-BIBUCC2E.js.map +0 -1
  149. package/dist/chunk-BSOBXLYI.js.map +0 -1
  150. package/dist/chunk-DWVAR4BP.js.map +0 -1
  151. package/dist/chunk-DXKAKKLP.js.map +0 -1
  152. package/dist/chunk-EIWXS4RM.js.map +0 -1
  153. package/dist/chunk-EWBCFAF3.js +0 -681
  154. package/dist/chunk-EWBCFAF3.js.map +0 -1
  155. package/dist/chunk-F2L4VNQK.js.map +0 -1
  156. package/dist/chunk-G26HZZDJ.js.map +0 -1
  157. package/dist/chunk-GQKKX7OE.js.map +0 -1
  158. package/dist/chunk-GRJY22U6.js +0 -691
  159. package/dist/chunk-GRJY22U6.js.map +0 -1
  160. package/dist/chunk-H6DVP2SI.js.map +0 -1
  161. package/dist/chunk-HVVPTCKR.js +0 -1173
  162. package/dist/chunk-HVVPTCKR.js.map +0 -1
  163. package/dist/chunk-IK524ZDW.js.map +0 -1
  164. package/dist/chunk-J4CKQXQ6.js.map +0 -1
  165. package/dist/chunk-JRFUTIEH.js +0 -426
  166. package/dist/chunk-JRFUTIEH.js.map +0 -1
  167. package/dist/chunk-K2BPYEH5.js +0 -491
  168. package/dist/chunk-K2BPYEH5.js.map +0 -1
  169. package/dist/chunk-KCQC7YBK.js +0 -7795
  170. package/dist/chunk-KCQC7YBK.js.map +0 -1
  171. package/dist/chunk-KDAV2GUT.js.map +0 -1
  172. package/dist/chunk-MY62SSKC.js +0 -183
  173. package/dist/chunk-MY62SSKC.js.map +0 -1
  174. package/dist/chunk-PXU2OS26.js +0 -238
  175. package/dist/chunk-PXU2OS26.js.map +0 -1
  176. package/dist/chunk-SNVAMWB7.js.map +0 -1
  177. package/dist/chunk-SPRVUATR.js +0 -430
  178. package/dist/chunk-SPRVUATR.js.map +0 -1
  179. package/dist/chunk-SY7G5QEI.js +0 -35
  180. package/dist/chunk-SY7G5QEI.js.map +0 -1
  181. package/dist/chunk-SZNBUIDR.js.map +0 -1
  182. package/dist/chunk-TYULB6ZY.js.map +0 -1
  183. package/dist/chunk-UJYFTXHV.js +0 -296
  184. package/dist/chunk-UJYFTXHV.js.map +0 -1
  185. package/dist/chunk-VL7BGD47.js.map +0 -1
  186. package/dist/chunk-VQVUJYYY.js.map +0 -1
  187. package/dist/chunk-XQFT4PEP.js +0 -60
  188. package/dist/chunk-XQFT4PEP.js.map +0 -1
  189. package/dist/chunk-YDD3ES2K.js.map +0 -1
  190. package/dist/chunk-ZY2MZ2KQ.js.map +0 -1
  191. package/dist/help-AW2HKX63.js.map +0 -1
  192. package/dist/help-BVFOZD7E.js.map +0 -1
  193. package/dist/init-SPN2GEZ4.js.map +0 -1
  194. package/dist/marketplace-VEKSWGX3.js.map +0 -1
  195. package/dist/migrate-OO37WSB2.js.map +0 -1
  196. package/dist/open-3V3QK5RK.js +0 -32
  197. package/dist/plugin-KOBNQ7GT.js +0 -64
  198. package/dist/plugin-from-project-X3VO3MB6.js +0 -16
  199. package/dist/profile-H4PMH4XT.js.map +0 -1
  200. /package/dist/{apply-2GRNKR5H.js.map → apply-SUNDXRJ3.js.map} +0 -0
  201. /package/dist/{chunk-IBOABSIA.js.map → chunk-3P6BWL5F.js.map} +0 -0
  202. /package/dist/{chunk-IRU7NBOT.js.map → chunk-7HP6AAI3.js.map} +0 -0
  203. /package/dist/{chunk-JKGSJGCC.js.map → chunk-GRASK6M6.js.map} +0 -0
  204. /package/dist/{chunk-DV74UZJI.js.map → chunk-L6YZE5MY.js.map} +0 -0
  205. /package/dist/{chunk-NJ7WRKIQ.js.map → chunk-P2C7JPLD.js.map} +0 -0
  206. /package/dist/{chunk-LNJ3WZZX.js.map → chunk-PCMON7Y2.js.map} +0 -0
  207. /package/dist/{chunk-VL2NWCZV.js.map → chunk-PNGF5EV2.js.map} +0 -0
  208. /package/dist/{chunk-C4QBVVEH.js.map → chunk-RVEXPMM3.js.map} +0 -0
  209. /package/dist/{chunk-7LWH5SWH.js.map → chunk-U6DXASQP.js.map} +0 -0
  210. /package/dist/{chunk-KMWHZSEG.js.map → chunk-UVVZHWD2.js.map} +0 -0
  211. /package/dist/{chunk-QRZPQNLX.js.map → chunk-WGP4GUYZ.js.map} +0 -0
  212. /package/dist/{github-BSMQD72A.js.map → github-PBYBGOLH.js.map} +0 -0
  213. /package/dist/{open-3V3QK5RK.js.map → live-read-cache-TUSP7U3D.js.map} +0 -0
  214. /package/dist/{lock-K2LLUU7H.js.map → lock-WLJRXRVK.js.map} +0 -0
  215. /package/dist/{plugin-KOBNQ7GT.js.map → open-HDGLYYVU.js.map} +0 -0
  216. /package/dist/{plugin-from-project-X3VO3MB6.js.map → plugin-CEO6ZJM5.js.map} +0 -0
  217. /package/dist/{version-PBHZK44K.js.map → plugin-from-project-UK7VJVUP.js.map} +0 -0
@@ -1 +0,0 @@
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 { 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\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 dryRunSectionHeader,\n dryRunWouldLine,\n keptFilesHeader,\n keptReasonLabel,\n snapshotSavedUndoLine,\n} from \"../copy/cli.js\";\nimport { ui } from \"../ui/index.js\";\n\nexport interface ApplyKeptFile {\n path: string;\n reason: \"modified\" | \"unmanaged\";\n}\n\nexport function keptFromSkippedRemovals(\n skipped: readonly { path: string; reason: string }[] | undefined,\n): ApplyKeptFile[] {\n return (skipped ?? []).flatMap((entry) => {\n const reason = removalSkipReason(entry.reason);\n return reason ? [{ path: entry.path, reason }] : [];\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 }[];\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 for (const skipped of payload.skipped_removals ?? []) {\n if (skipped.reason === \"missing\") {\n continue;\n }\n if (skipped.message) {\n ui.warn(skipped.message);\n }\n }\n if (!payload.dry_run && payload.removal_backup && (payload.removed_files?.length ?? 0) > 0) {\n ui.info(`Backup: ${payload.removal_backup}`);\n }\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)}`);\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)}`);\n }\n console.log(`${CLI_COPY.forceRemoveHint} ht apply --force-remove`);\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 console.log(\n applyWroteLine({\n wrote: input.wrote,\n removed: input.removed,\n kept: input.kept.length,\n unchanged: input.unchanged,\n }),\n );\n if (input.wrote > 0 || input.removed > 0) {\n printKeptFiles(input.kept);\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 { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { listMaterializationsForRootPath } from \"../models/resource-materialization.js\";\nimport { hashOnDiskFile } from \"./safe-file-removal.js\";\nimport { isEmptyBuiltinProfile, isProfilePlugin } from \"../constants/profile.js\";\nimport { getLatestGlobalApplySnapshotForProfile } from \"../models/global-apply-snapshot.js\";\nimport { resolvePluginSelector } from \"../models/plugin-model.js\";\nimport { resolveHomeRoot } from \"../utils/home-root.js\";\nimport { getActiveProfileName } from \"./active-profile.js\";\nimport {\n applyProfilePlugin,\n clearGlobalProfileApply,\n collectProfilePluginIds,\n type ApplyProfilePluginResult,\n} from \"./profile-apply.js\";\nimport { mergePluginsForApply } from \"./plugin-apply-merge.js\";\nimport { fileContentsEquivalentForDrift } from \"./file-contents-drift.js\";\nimport { withAffectedResources } from \"./scoped-file-content-delta.js\";\nimport type { DriftFileChange } from \"./project-drift.js\";\nimport { detectNotStagedProfileResources } from \"./profile-untracked-resources.js\";\nimport {\n buildProfileContents,\n type ProfileContents,\n} from \"./profile-contents.js\";\nimport {\n buildHostManagedStatus,\n profileSkillNameMap,\n type HostManagedStatus,\n} from \"./cursor-host-managed-skills.js\";\nimport {\n buildHarnessLiveStatusMap,\n classifyGlobalDriftChanges,\n collectOwnedGlobalProfileFiles,\n computeGlobalProfilePanelStatus,\n countMissingHarnessRows,\n declaredMcpFromExpectedFiles,\n resolveProjectDriftSummary,\n type GlobalProfileDriftSummary,\n type GlobalProfilePanelStatus,\n type GlobalProfileStatusDepth,\n type HarnessLiveStatus,\n} from \"./global-profile-status-panel.js\";\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\nfunction readGlobalFile(homeRoot: string, relativePath: string): string | null {\n const fullPath = join(homeRoot, relativePath);\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 = collectOwnedGlobalProfileFiles(input.snapshotId);\n const { owned, nonOwned } = classifyGlobalDriftChanges(input.changes, ownedFiles);\n\n const declaredPins =\n input.pluginIds && input.pluginIds.length > 0\n ? 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 harnesses = buildHarnessLiveStatusMap({\n depth: input.depth,\n homeRoot,\n declaredPins,\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 ? buildProfileContents(input.activeProfile)\n : null;\n const hostManaged =\n input.depth === \"full\"\n ? buildHostManagedStatus({\n homeRoot,\n profileSkills: profileSkillNameMap(contents?.resources ?? []),\n })\n : undefined;\n\n const projectDrift = 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 = 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 detectNotStagedProfileResources({\n profileSelector: status.active_profile,\n scope: \"home\",\n ...(harness ? { harness } : {}),\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\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 activeProfile = getActiveProfileName() ?? null;\n if (!activeProfile) {\n return finalizeGlobalProfileStatus(\n {\n depth,\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 );\n }\n\n const plugin = 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 finalizeGlobalProfileStatus({\n depth,\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 });\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 finalizeGlobalProfileStatus({\n depth,\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 }\n\n return finalizeGlobalProfileStatus({\n depth,\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 });\n }\n\n if (!isProfilePlugin(plugin)) {\n return finalizeGlobalProfileStatus({\n depth,\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 });\n }\n\n const latestSnapshot = getLatestGlobalApplySnapshotForProfile(activeProfile);\n const homeRoot = resolveHomeRoot();\n const pluginIds = collectProfilePluginIds(plugin);\n let expectedApply: ApplyProfilePluginResult;\n try {\n expectedApply = await applyProfilePlugin(activeProfile, {\n dryRun: true,\n harness: input.harness,\n conflictPolicy: \"replace\",\n pull: false,\n pinSkillEmits: false,\n mergeLiveSkillMarkdown: false,\n });\n } catch (error) {\n return finalizeGlobalProfileStatus({\n depth,\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 });\n }\n\n const stackInSync = latestSnapshot\n ? pluginIdsMatch(latestSnapshot.plugin_ids, expectedApply.configured_plugin_ids)\n : false;\n\n const changes: DriftFileChange[] = [];\n for (const file of expectedApply.expected_files ?? []) {\n const current = readGlobalFile(homeRoot, file.path);\n const owned = listMaterializationsForRootPath(homeRoot, file.path);\n if (current === null) {\n if (owned.length === 0) {\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 changes.push(\n withAffectedResources(\n { path: file.path, type: \"modified\" },\n file.content,\n current,\n ),\n );\n continue;\n }\n if (!fileContentsEquivalentForDrift(file.path, current, file.content)) {\n changes.push(\n withAffectedResources(\n { path: file.path, type: \"modified\" },\n file.content,\n current,\n ),\n );\n }\n }\n\n const applied = Boolean(latestSnapshot);\n const hasDrift = !applied || !stackInSync || changes.length > 0;\n\n return finalizeGlobalProfileStatus(\n {\n depth,\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 );\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 return readFileSync(fullPath, \"utf-8\");\n } catch {\n return null;\n }\n}\n\nfunction lastWrittenContent(profileName: string, relativePath: string): string | undefined {\n const snapshot = getLatestGlobalApplySnapshotForProfile(profileName);\n if (!snapshot?.state) {\n return undefined;\n }\n return flattenLiveRestoreFiles(snapshot.state).find((file) => file.path === relativePath)?.content;\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, \"utf-8\");\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} 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 if (status.changes.length === 0) {\n return \"continue\";\n }\n\n const count = status.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 status.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: status.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,KAAK;AACnB,WAAO;AAAA,EACT;AACA,MAAI,QAAQ,WAAW,IAAI,KAAK,QAAQ,WAAW,KAAK,GAAG;AACzD,WAAO,KAAK,MAAM,QAAQ,MAAM,CAAC,CAAC;AAAA,EACpC;AACA,SAAO,WAAW,OAAO,IAAI,UAAU,QAAQ,OAAO;AACxD;AAEO,SAAS,gBACd,KACA,MACQ;AACR,QAAM,WAAW,QAAQ,eAAe,KAAK,MAAM,QAAQ,gBAAgB,CAAC,CAAC;AAC7E,MAAI,MAAM,aAAa,CAAC,WAAW,QAAQ,GAAG;AAC5C,UAAM,IAAI,cAAc,KAAK,QAAQ;AAAA,EACvC;AACA,SAAO;AACT;;;AC5BO,SAAS,2BAA2B,MAGxB;AACjB,QAAM,SAAS,KAAK,aAAa,gBAAgB,KAAK,UAAU,IAAI;AACpE,MACE,WAAW,aACX,WAAW,UACX,WAAW,YACX,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QAAQ,QAAQ;AAAA,IACtB,SAAS,QAAQ;AAAA,IACjB,SAAS,QAAQ;AAAA,EACnB,CAAC;AAEL,MAAI,mBAAmB,CAAC,QAAQ;AAC9B,0BAAsB,eAAe;AAAA,EACvC;AAEA,MAAI,CAAC,QAAQ;AACX,UAAM,OAAO,MAAM,mCAAmC;AAAA,MACpD,mBAAmB;AAAA,MACnB,SAAS,QAAQ;AAAA,MACjB,KAAK,QAAQ;AAAA,MACb,QAAQ,QAAQ;AAAA,IAClB,CAAC;AACD,QAAI,SAAS,SAAS;AACpB,YAAM,IAAI,MAAM,2BAA2B;AAAA,IAC7C;AAAA,EACF;AAEA,QAAM,iBAAiB,2BAA2B;AAAA,IAChD,YAAY,QAAQ;AAAA,IACpB,eAAe,QAAQ,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","existsSync","readFileSync","join","resolve","join","existsSync","readFileSync","resolve","conflictPolicy"]}
@@ -1,183 +0,0 @@
1
- import {
2
- PACK_LOCKFILE_NAME,
3
- normalizeSha256,
4
- readZipArchive,
5
- sha256Hex
6
- } from "./chunk-GRJY22U6.js";
7
- import {
8
- BundleSymlinkError,
9
- isApEnvelopePath,
10
- listContainedRegularFiles,
11
- packageFileFromBytes,
12
- readApEnvelope
13
- } from "./chunk-2EIJYDNI.js";
14
-
15
- // src/services/legacy-toml-transport.ts
16
- var LEGACY_PLUGIN_SUFFIX = `.harnesstap${".toml"}`;
17
- var LEGACY_ENVIRONMENT_SUFFIX = `.environment${".toml"}`;
18
- function isLegacyPluginTomlPath(filePath) {
19
- return filePath.toLowerCase().endsWith(LEGACY_PLUGIN_SUFFIX);
20
- }
21
- function isLegacyEnvironmentTomlPath(filePath) {
22
- return filePath.toLowerCase().endsWith(LEGACY_ENVIRONMENT_SUFFIX);
23
- }
24
- function isLegacyTomlTransportPath(filePath) {
25
- return isLegacyPluginTomlPath(filePath) || isLegacyEnvironmentTomlPath(filePath);
26
- }
27
- function legacyTomlTransportRejection(filePath) {
28
- return `${filePath} is a HarnessTap TOML transport file, which is no longer supported. Portable artifacts are Agent Plugins packages: a directory with a plugin.json, or a single .ap.json envelope.`;
29
- }
30
-
31
- // src/services/apm-bundle.ts
32
- import { existsSync, lstatSync, readFileSync, statSync } from "fs";
33
- import { join, resolve } from "path";
34
- import { parse as parseYaml } from "yaml";
35
- var BundleIntegrityError = class extends Error {
36
- constructor(message) {
37
- super(message);
38
- this.name = "BundleIntegrityError";
39
- }
40
- };
41
- function isRecord(value) {
42
- return value !== null && typeof value === "object" && !Array.isArray(value);
43
- }
44
- function readBundleLock(files) {
45
- const lockBytes = files[PACK_LOCKFILE_NAME];
46
- if (!lockBytes) return void 0;
47
- const parsed = parseYaml(lockBytes.toString("utf8"));
48
- return isRecord(parsed) ? parsed : void 0;
49
- }
50
- function bundleFileMap(lock) {
51
- const pack = lock?.pack;
52
- if (!isRecord(pack) || !isRecord(pack.bundle_files)) {
53
- return void 0;
54
- }
55
- return Object.fromEntries(
56
- Object.entries(pack.bundle_files).map(([path, hash]) => [path, String(hash)])
57
- );
58
- }
59
- function verifyPackedBundleBytes(files) {
60
- const listed = bundleFileMap(readBundleLock(files));
61
- if (!listed) {
62
- return;
63
- }
64
- const listedPaths = Object.keys(listed).sort();
65
- const presentPaths = Object.keys(files).filter((path) => path !== PACK_LOCKFILE_NAME).sort();
66
- for (const relativePath of listedPaths) {
67
- if (relativePath.split("/").includes("..") || relativePath.startsWith("/")) {
68
- throw new BundleIntegrityError(
69
- `Unsafe pack.bundle_files path ${relativePath}: pack aborted closed`
70
- );
71
- }
72
- const bytes = files[relativePath];
73
- if (!bytes) {
74
- throw new BundleIntegrityError(
75
- `Bundle is missing ${relativePath} listed in pack.bundle_files`
76
- );
77
- }
78
- const expected = listed[relativePath];
79
- if (!expected) continue;
80
- const actual = sha256Hex(bytes);
81
- if (normalizeSha256(expected) !== actual) {
82
- throw new BundleIntegrityError(
83
- `Bundle hash mismatch for ${relativePath}: lockfile records ${normalizeSha256(expected)}, file is ${actual}`
84
- );
85
- }
86
- }
87
- for (const relativePath of presentPaths) {
88
- if (listed[relativePath] === void 0) {
89
- throw new BundleIntegrityError(
90
- `Bundle contains extra file ${relativePath} that is not listed in pack.bundle_files`
91
- );
92
- }
93
- }
94
- }
95
- function filesFromDirectory(packageDir) {
96
- if (lstatSync(packageDir).isSymbolicLink()) {
97
- throw new BundleSymlinkError(".");
98
- }
99
- const files = {};
100
- for (const relativePath of listContainedRegularFiles(packageDir).sort()) {
101
- files[relativePath] = readFileSync(join(packageDir, relativePath));
102
- }
103
- return files;
104
- }
105
- function filesFromZip(archivePath) {
106
- const members = readZipArchive(readFileSync(archivePath));
107
- const files = {};
108
- for (const member of members) {
109
- files[member.path] = member.data;
110
- }
111
- return files;
112
- }
113
- function toPackageFiles(files) {
114
- const result = {};
115
- for (const relativePath of Object.keys(files).sort()) {
116
- const bytes = files[relativePath];
117
- if (!bytes) continue;
118
- result[relativePath] = packageFileFromBytes(bytes);
119
- }
120
- return result;
121
- }
122
- function bytesFromPackageFiles(files) {
123
- const result = {};
124
- for (const [relativePath, entry] of Object.entries(files)) {
125
- if (!entry) continue;
126
- result[relativePath] = entry.encoding === "base64" ? Buffer.from(entry.content, "base64") : Buffer.from(entry.content, "utf8");
127
- }
128
- return result;
129
- }
130
- function isZipBundlePath(source) {
131
- return source.toLowerCase().endsWith(".zip");
132
- }
133
- function looksLikeFilesystemPath(source) {
134
- return source.includes("/") || source.includes("\\") || source.startsWith(".");
135
- }
136
- function isPluginPackageDirectory(source) {
137
- try {
138
- const resolved = resolve(source);
139
- return existsSync(resolved) && statSync(resolved).isDirectory() && existsSync(join(resolved, "plugin.json"));
140
- } catch {
141
- return false;
142
- }
143
- }
144
- function loadVerifiedPackageFiles(filePath) {
145
- const resolved = resolve(filePath);
146
- if (isLegacyTomlTransportPath(resolved)) {
147
- throw new Error(legacyTomlTransportRejection(resolved));
148
- }
149
- if (isApEnvelopePath(resolved)) {
150
- const files = readApEnvelope(resolved);
151
- verifyPackedBundleBytes(bytesFromPackageFiles(files));
152
- return files;
153
- }
154
- if (isZipBundlePath(resolved)) {
155
- const files = filesFromZip(resolved);
156
- verifyPackedBundleBytes(files);
157
- return toPackageFiles(files);
158
- }
159
- if (existsSync(resolved) && statSync(resolved).isDirectory()) {
160
- if (!existsSync(join(resolved, "plugin.json"))) {
161
- throw new Error(
162
- `${resolved} is a directory but has no plugin.json: expected an Agent Plugins package.`
163
- );
164
- }
165
- const files = filesFromDirectory(resolved);
166
- verifyPackedBundleBytes(files);
167
- return toPackageFiles(files);
168
- }
169
- throw new Error(
170
- `Cannot tell what ${resolved} is. Pass an Agent Plugins package directory, a .zip bundle, or an .ap.json envelope.`
171
- );
172
- }
173
-
174
- export {
175
- isLegacyPluginTomlPath,
176
- isLegacyTomlTransportPath,
177
- legacyTomlTransportRejection,
178
- isZipBundlePath,
179
- looksLikeFilesystemPath,
180
- isPluginPackageDirectory,
181
- loadVerifiedPackageFiles
182
- };
183
- //# sourceMappingURL=chunk-MY62SSKC.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/services/legacy-toml-transport.ts","../src/services/apm-bundle.ts"],"sourcesContent":["/** Suffixes for deleted TOML transport formats (kept for clear rejection errors). */\nconst LEGACY_PLUGIN_SUFFIX = `.harnesstap${\".toml\"}`;\nconst LEGACY_ENVIRONMENT_SUFFIX = `.environment${\".toml\"}`;\n\nexport function isLegacyPluginTomlPath(filePath: string): boolean {\n return filePath.toLowerCase().endsWith(LEGACY_PLUGIN_SUFFIX);\n}\n\nexport function isLegacyEnvironmentTomlPath(filePath: string): boolean {\n return filePath.toLowerCase().endsWith(LEGACY_ENVIRONMENT_SUFFIX);\n}\n\nexport function isLegacyTomlTransportPath(filePath: string): boolean {\n return isLegacyPluginTomlPath(filePath) || isLegacyEnvironmentTomlPath(filePath);\n}\n\nexport function legacyTomlTransportRejection(filePath: string): string {\n return (\n `${filePath} is a HarnessTap TOML transport file, which is no longer supported. ` +\n \"Portable artifacts are Agent Plugins packages: a directory with a plugin.json, \" +\n \"or a single .ap.json envelope.\"\n );\n}\n","import { existsSync, lstatSync, readFileSync, statSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { parse as parseYaml } from \"yaml\";\nimport {\n packageFileFromBytes,\n type ApPackageFiles,\n} from \"./agent-plugins/files.js\";\nimport { isApEnvelopePath, readApEnvelope } from \"./agent-plugins/envelope.js\";\nimport { PACK_LOCKFILE_NAME, normalizeSha256, sha256Hex } from \"./apm-pack.js\";\nimport {\n isLegacyTomlTransportPath,\n legacyTomlTransportRejection,\n} from \"./legacy-toml-transport.js\";\nimport {\n BundleSymlinkError,\n listContainedRegularFiles,\n} from \"../utils/path-containment.js\";\nimport { readZipArchive } from \"../utils/zip-archive.js\";\n\nexport class BundleIntegrityError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"BundleIntegrityError\";\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction readBundleLock(files: Record<string, Buffer>): Record<string, unknown> | undefined {\n const lockBytes = files[PACK_LOCKFILE_NAME];\n if (!lockBytes) return undefined;\n const parsed = parseYaml(lockBytes.toString(\"utf8\"));\n return isRecord(parsed) ? parsed : undefined;\n}\n\nfunction bundleFileMap(lock: Record<string, unknown> | undefined): Record<string, string> | undefined {\n const pack = lock?.pack;\n if (!isRecord(pack) || !isRecord(pack.bundle_files)) {\n return undefined;\n }\n return Object.fromEntries(\n Object.entries(pack.bundle_files).map(([path, hash]) => [path, String(hash)]),\n );\n}\n\nexport function verifyPackedBundleBytes(files: Record<string, Buffer>): void {\n const listed = bundleFileMap(readBundleLock(files));\n if (!listed) {\n return;\n }\n\n const listedPaths = Object.keys(listed).sort();\n const presentPaths = Object.keys(files)\n .filter((path) => path !== PACK_LOCKFILE_NAME)\n .sort();\n\n for (const relativePath of listedPaths) {\n if (relativePath.split(\"/\").includes(\"..\") || relativePath.startsWith(\"/\")) {\n throw new BundleIntegrityError(\n `Unsafe pack.bundle_files path ${relativePath}: pack aborted closed`,\n );\n }\n const bytes = files[relativePath];\n if (!bytes) {\n throw new BundleIntegrityError(\n `Bundle is missing ${relativePath} listed in pack.bundle_files`,\n );\n }\n const expected = listed[relativePath];\n if (!expected) continue;\n const actual = sha256Hex(bytes);\n if (normalizeSha256(expected) !== actual) {\n throw new BundleIntegrityError(\n `Bundle hash mismatch for ${relativePath}: lockfile records ${normalizeSha256(expected)}, file is ${actual}`,\n );\n }\n }\n\n for (const relativePath of presentPaths) {\n if (listed[relativePath] === undefined) {\n throw new BundleIntegrityError(\n `Bundle contains extra file ${relativePath} that is not listed in pack.bundle_files`,\n );\n }\n }\n}\n\nfunction filesFromDirectory(packageDir: string): Record<string, Buffer> {\n if (lstatSync(packageDir).isSymbolicLink()) {\n throw new BundleSymlinkError(\".\");\n }\n const files: Record<string, Buffer> = {};\n for (const relativePath of listContainedRegularFiles(packageDir).sort()) {\n files[relativePath] = readFileSync(join(packageDir, relativePath));\n }\n return files;\n}\n\nfunction filesFromZip(archivePath: string): Record<string, Buffer> {\n const members = readZipArchive(readFileSync(archivePath));\n const files: Record<string, Buffer> = {};\n for (const member of members) {\n files[member.path] = member.data;\n }\n return files;\n}\n\nfunction toPackageFiles(files: Record<string, Buffer>): ApPackageFiles {\n const result: ApPackageFiles = {};\n for (const relativePath of Object.keys(files).sort()) {\n const bytes = files[relativePath];\n if (!bytes) continue;\n result[relativePath] = packageFileFromBytes(bytes);\n }\n return result;\n}\n\nfunction bytesFromPackageFiles(files: ApPackageFiles): Record<string, Buffer> {\n const result: Record<string, Buffer> = {};\n for (const [relativePath, entry] of Object.entries(files)) {\n if (!entry) continue;\n result[relativePath] =\n entry.encoding === \"base64\"\n ? Buffer.from(entry.content, \"base64\")\n : Buffer.from(entry.content, \"utf8\");\n }\n return result;\n}\n\nexport function isZipBundlePath(source: string): boolean {\n return source.toLowerCase().endsWith(\".zip\");\n}\n\nexport function looksLikeFilesystemPath(source: string): boolean {\n return source.includes(\"/\") || source.includes(\"\\\\\") || source.startsWith(\".\");\n}\n\nexport function isPluginPackageDirectory(source: string): boolean {\n try {\n const resolved = resolve(source);\n return (\n existsSync(resolved)\n && statSync(resolved).isDirectory()\n && existsSync(join(resolved, \"plugin.json\"))\n );\n } catch {\n return false;\n }\n}\n\nexport function loadVerifiedPackageFiles(filePath: string): ApPackageFiles {\n const resolved = resolve(filePath);\n if (isLegacyTomlTransportPath(resolved)) {\n throw new Error(legacyTomlTransportRejection(resolved));\n }\n\n if (isApEnvelopePath(resolved)) {\n const files = readApEnvelope(resolved);\n verifyPackedBundleBytes(bytesFromPackageFiles(files));\n return files;\n }\n\n if (isZipBundlePath(resolved)) {\n const files = filesFromZip(resolved);\n verifyPackedBundleBytes(files);\n return toPackageFiles(files);\n }\n\n if (existsSync(resolved) && statSync(resolved).isDirectory()) {\n if (!existsSync(join(resolved, \"plugin.json\"))) {\n throw new Error(\n `${resolved} is a directory but has no plugin.json: expected an Agent Plugins package.`,\n );\n }\n const files = filesFromDirectory(resolved);\n verifyPackedBundleBytes(files);\n return toPackageFiles(files);\n }\n\n throw new Error(\n `Cannot tell what ${resolved} is. Pass an Agent Plugins package directory, a .zip bundle, or an .ap.json envelope.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C,4BAAwB,sBAAsB,KAAK,CAAC;AACpD,WAAO;AAAA,EACT;AAEA,MAAI,gBAAgB,QAAQ,GAAG;AAC7B,UAAM,QAAQ,aAAa,QAAQ;AACnC,4BAAwB,KAAK;AAC7B,WAAO,eAAe,KAAK;AAAA,EAC7B;AAEA,MAAI,WAAW,QAAQ,KAAK,SAAS,QAAQ,EAAE,YAAY,GAAG;AAC5D,QAAI,CAAC,WAAW,KAAK,UAAU,aAAa,CAAC,GAAG;AAC9C,YAAM,IAAI;AAAA,QACR,GAAG,QAAQ;AAAA,MACb;AAAA,IACF;AACA,UAAM,QAAQ,mBAAmB,QAAQ;AACzC,4BAAwB,KAAK;AAC7B,WAAO,eAAe,KAAK;AAAA,EAC7B;AAEA,QAAM,IAAI;AAAA,IACR,oBAAoB,QAAQ;AAAA,EAC9B;AACF;","names":[]}
@@ -1,238 +0,0 @@
1
- import {
2
- resolveEnvironmentSelector,
3
- resolvePluginSelector
4
- } from "./chunk-2EIJYDNI.js";
5
-
6
- // src/services/environment-selectors.ts
7
- function resolveEnvironmentOrThrow(selector) {
8
- const result = resolveEnvironmentSelector(selector);
9
- if (result.status === "found" && result.environment) {
10
- return result.environment;
11
- }
12
- if (result.status === "ambiguous") {
13
- const matches = (result.matches ?? []).map((environment) => environment.id).join(", ");
14
- throw new Error(`Environment selector is ambiguous: ${selector} (${matches})`);
15
- }
16
- throw new Error(`Environment not found: ${selector}`);
17
- }
18
- function resolveConfiguredPluginOrThrow(selector) {
19
- const plugin = resolvePluginSelector(selector);
20
- if (!plugin) {
21
- throw new Error(`Configured plugin not found: ${selector}`);
22
- }
23
- return plugin;
24
- }
25
-
26
- // src/ui/hook-display.ts
27
- var KNOWN_HOOK_EVENTS = [
28
- "SessionStart",
29
- "SessionEnd",
30
- "UserPromptSubmit",
31
- "PreToolUse",
32
- "PostToolUse",
33
- "Notification",
34
- "PermissionRequest",
35
- "PreCompact",
36
- "Stop",
37
- "SubagentStop",
38
- "Setup"
39
- ];
40
- var INTERPRETERS = /* @__PURE__ */ new Set([
41
- "node",
42
- "nodejs",
43
- "bun",
44
- "deno",
45
- "python",
46
- "python3",
47
- "python2",
48
- "bash",
49
- "sh",
50
- "zsh",
51
- "fish",
52
- "cmd",
53
- "cmd.exe",
54
- "powershell",
55
- "powershell.exe",
56
- "pwsh",
57
- "npx",
58
- "pnpm",
59
- "yarn",
60
- "bunx",
61
- "ts-node",
62
- "tsx",
63
- "env",
64
- "uvx"
65
- ]);
66
- var LAUNCHER_FOLLOWERS = /* @__PURE__ */ new Set(["dlx", "exec"]);
67
- function compactEventKey(value) {
68
- return value.replace(/[_\-\s]+/g, "").toLowerCase();
69
- }
70
- function normalizeHookEventName(event) {
71
- const trimmed = event.trim();
72
- if (!trimmed) {
73
- return trimmed;
74
- }
75
- const compact = compactEventKey(trimmed);
76
- const known = KNOWN_HOOK_EVENTS.find((name) => name.toLowerCase() === compact);
77
- if (known) {
78
- return known;
79
- }
80
- if (/^[A-Za-z][A-Za-z0-9]*$/.test(trimmed)) {
81
- return capitalizeFirst(trimmed);
82
- }
83
- return trimmed.split(/[_\-\s]+/).filter(Boolean).map(capitalizeFirst).join("");
84
- }
85
- function capitalizeFirst(value) {
86
- const head = value.slice(0, 1);
87
- return `${head.toUpperCase()}${value.slice(1)}`;
88
- }
89
- function eventFromHookResourceName(name) {
90
- const trimmed = name?.trim() ?? "";
91
- if (!trimmed) {
92
- return void 0;
93
- }
94
- const compactName = compactEventKey(trimmed);
95
- const known = [...KNOWN_HOOK_EVENTS].sort((left, right) => right.length - left.length).find((event) => {
96
- const compact = event.toLowerCase();
97
- return compactName === compact || compactName.startsWith(compact);
98
- });
99
- if (known) {
100
- return known;
101
- }
102
- const dash = trimmed.search(/[-_\s]/);
103
- if (dash > 0) {
104
- return normalizeHookEventName(trimmed.slice(0, dash));
105
- }
106
- return normalizeHookEventName(trimmed);
107
- }
108
- function stripWrappingQuotes(token) {
109
- if (token.startsWith('"') && token.endsWith('"') || token.startsWith("'") && token.endsWith("'")) {
110
- return token.slice(1, -1);
111
- }
112
- return token;
113
- }
114
- function pathBasename(path) {
115
- const trimmed = stripWrappingQuotes(path.trim()).replace(/[\\/]+$/, "");
116
- if (!trimmed) {
117
- return "";
118
- }
119
- const parts = trimmed.split(/[/\\]/).filter(Boolean);
120
- return parts[parts.length - 1] ?? trimmed;
121
- }
122
- function tokenizeCommand(command) {
123
- const tokens = [];
124
- const pattern = /"([^"]*)"|'([^']*)'|(\S+)/g;
125
- for (const match of command.matchAll(pattern)) {
126
- const token = match[1] ?? match[2] ?? match[3] ?? "";
127
- if (token) {
128
- tokens.push(token);
129
- }
130
- }
131
- return tokens;
132
- }
133
- function isFlagToken(token) {
134
- return token.startsWith("-");
135
- }
136
- function isLauncherToken(token) {
137
- const base = pathBasename(token).toLowerCase();
138
- return INTERPRETERS.has(base) || LAUNCHER_FOLLOWERS.has(base);
139
- }
140
- function hookCommandShortToken(command) {
141
- const trimmed = command.trim();
142
- if (!trimmed) {
143
- return "";
144
- }
145
- const tokens = tokenizeCommand(trimmed).filter((token) => !/^\w+=/.test(token));
146
- if (tokens.length === 0) {
147
- return pathBasename(trimmed);
148
- }
149
- for (const token of tokens) {
150
- if (isFlagToken(token) || isLauncherToken(token)) {
151
- continue;
152
- }
153
- return pathBasename(token);
154
- }
155
- const first = tokens[0] ?? "";
156
- return pathBasename(first);
157
- }
158
- function stringField(value) {
159
- return typeof value === "string" ? value.trim() : "";
160
- }
161
- function hookEntryType(entry) {
162
- if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
163
- return "";
164
- }
165
- return stringField(entry.type);
166
- }
167
- function asHookMetadata(value) {
168
- if (!value || typeof value !== "object" || Array.isArray(value)) {
169
- return void 0;
170
- }
171
- return value;
172
- }
173
- function hookDisplayInputFromResource(resource) {
174
- const metadata = asHookMetadata(resource.metadata);
175
- const hook = resource.hook ?? void 0;
176
- const event = resource.event ?? hook?.event ?? stringField(metadata?.event);
177
- const script = resource.script ?? hook?.script ?? stringField(metadata?.script) ?? resource.content ?? "";
178
- const matcher = resource.matcher ?? hook?.matcher ?? stringField(metadata?.matcher);
179
- const hookType = resource.hookType ?? hook?.type ?? hookEntryType(metadata?.hook_entry);
180
- return {
181
- event: event || void 0,
182
- name: resource.name,
183
- script: script || void 0,
184
- content: resource.content,
185
- matcher: matcher || void 0,
186
- hookType: hookType || void 0,
187
- hook,
188
- metadata
189
- };
190
- }
191
- function hookInventoryWireFromResource(resource) {
192
- if (resource.type !== "hook") {
193
- return void 0;
194
- }
195
- const metadata = asHookMetadata(resource.metadata);
196
- const event = stringField(metadata?.event);
197
- const script = stringField(metadata?.script) || stringField(resource.content);
198
- if (!event && !script) {
199
- return void 0;
200
- }
201
- const matcher = stringField(metadata?.matcher);
202
- const type = hookEntryType(metadata?.hook_entry);
203
- return {
204
- event,
205
- script,
206
- ...matcher ? { matcher } : {},
207
- ...type ? { type } : {}
208
- };
209
- }
210
- function resolvedEvent(input) {
211
- const raw = input.event?.trim() || eventFromHookResourceName(input.name) || "";
212
- return raw ? normalizeHookEventName(raw) : "";
213
- }
214
- function resolvedCommand(input) {
215
- return (input.script ?? input.content ?? "").trim();
216
- }
217
- function formatHookInventoryLabel(input) {
218
- const resolved = hookDisplayInputFromResource(input);
219
- const command = resolvedCommand(resolved);
220
- const short = hookCommandShortToken(command);
221
- const event = resolvedEvent(resolved);
222
- if (!short) {
223
- return resolved.name?.trim() || event;
224
- }
225
- if (!event) {
226
- return short;
227
- }
228
- return `${event}: ${short}`;
229
- }
230
-
231
- export {
232
- hookDisplayInputFromResource,
233
- hookInventoryWireFromResource,
234
- formatHookInventoryLabel,
235
- resolveEnvironmentOrThrow,
236
- resolveConfiguredPluginOrThrow
237
- };
238
- //# sourceMappingURL=chunk-PXU2OS26.js.map