harnesstap 1.4.0 → 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 (210) hide show
  1. package/README.md +2 -0
  2. package/dist/apply-FTAIL3X3.js +50 -0
  3. package/dist/{approve-FBGYQGWN.js → approve-R6AWQB3I.js} +10 -13
  4. package/dist/{approve-FBGYQGWN.js.map → approve-R6AWQB3I.js.map} +1 -1
  5. package/dist/{audit-VI4QZ6X2.js → audit-2HNKFPSU.js} +11 -15
  6. package/dist/{audit-VI4QZ6X2.js.map → audit-2HNKFPSU.js.map} +1 -1
  7. package/dist/{auth-4CQCDS2W.js → auth-C54KRLNF.js} +10 -12
  8. package/dist/{auth-4CQCDS2W.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-IE7B6Q5K.js → chunk-2XDYQXP2.js} +17 -18
  12. package/dist/chunk-2XDYQXP2.js.map +1 -0
  13. package/dist/{chunk-L6YZE5MY.js → chunk-3277RVZT.js} +5 -7
  14. package/dist/{chunk-L6YZE5MY.js.map → chunk-3277RVZT.js.map} +1 -1
  15. package/dist/{chunk-QA5U36JN.js → chunk-3Q72LZPJ.js} +764 -340
  16. package/dist/chunk-3Q72LZPJ.js.map +1 -0
  17. package/dist/{chunk-OML4HXKT.js → chunk-42E2MPES.js} +16 -22
  18. package/dist/chunk-42E2MPES.js.map +1 -0
  19. package/dist/{chunk-4ZQ2SCGY.js → chunk-5HACBPK2.js} +509 -207
  20. package/dist/chunk-5HACBPK2.js.map +1 -0
  21. package/dist/{chunk-GRASK6M6.js → chunk-6FXJIKEG.js} +5 -5
  22. package/dist/{chunk-73OJQTBW.js → chunk-A3TZT4WT.js} +2 -2
  23. package/dist/{chunk-ZUASVASP.js → chunk-BUA7WFI4.js} +27034 -18024
  24. package/dist/chunk-BUA7WFI4.js.map +1 -0
  25. package/dist/{chunk-U6DXASQP.js → chunk-CBSDMRMY.js} +2 -2
  26. package/dist/{chunk-RDG5DT7S.js → chunk-CR2TYMKC.js} +54 -40
  27. package/dist/chunk-CR2TYMKC.js.map +1 -0
  28. package/dist/{chunk-REHRUNBB.js → chunk-CWXCZBJR.js} +70 -5
  29. package/dist/chunk-CWXCZBJR.js.map +1 -0
  30. package/dist/{chunk-R7ZOYVN3.js → chunk-D7R577XZ.js} +187 -59
  31. package/dist/chunk-D7R577XZ.js.map +1 -0
  32. package/dist/{chunk-P2C7JPLD.js → chunk-EPXAOEBB.js} +6 -6
  33. package/dist/{chunk-D432JAXV.js → chunk-GZU4LVFF.js} +153 -25
  34. package/dist/chunk-GZU4LVFF.js.map +1 -0
  35. package/dist/chunk-HV3ENT2F.js +61 -0
  36. package/dist/chunk-HV3ENT2F.js.map +1 -0
  37. package/dist/{chunk-3P6BWL5F.js → chunk-K4UDZUJ2.js} +2 -2
  38. package/dist/{chunk-ULCD6DJE.js → chunk-L6BJCRBU.js} +14 -39
  39. package/dist/chunk-L6BJCRBU.js.map +1 -0
  40. package/dist/{chunk-M4KLHJ6U.js → chunk-M6FEDSHY.js} +8 -10
  41. package/dist/{chunk-M4KLHJ6U.js.map → chunk-M6FEDSHY.js.map} +1 -1
  42. package/dist/chunk-M7PHQ3UC.js +31491 -0
  43. package/dist/chunk-M7PHQ3UC.js.map +1 -0
  44. package/dist/{chunk-PNGF5EV2.js → chunk-MHLAIGIM.js} +2 -2
  45. package/dist/{chunk-BPWFQKI5.js → chunk-MHMFF6A5.js} +2 -2
  46. package/dist/chunk-MKLJBW5N.js +14 -0
  47. package/dist/{chunk-MR7IOHSX.js → chunk-MQCAPCAF.js} +16 -22
  48. package/dist/{chunk-MR7IOHSX.js.map → chunk-MQCAPCAF.js.map} +1 -1
  49. package/dist/{chunk-N3VGY3T3.js → chunk-MQCH3YZ5.js} +7 -5
  50. package/dist/{chunk-N3VGY3T3.js.map → chunk-MQCH3YZ5.js.map} +1 -1
  51. package/dist/{chunk-WG5A6EAU.js → chunk-OHZNDV4A.js} +821 -28
  52. package/dist/chunk-OHZNDV4A.js.map +1 -0
  53. package/dist/{chunk-WGP4GUYZ.js → chunk-OWE3OSX6.js} +9 -11
  54. package/dist/{chunk-WGP4GUYZ.js.map → chunk-OWE3OSX6.js.map} +1 -1
  55. package/dist/{chunk-RVEXPMM3.js → chunk-PCNHBMBU.js} +3 -5
  56. package/dist/{chunk-RVEXPMM3.js.map → chunk-PCNHBMBU.js.map} +1 -1
  57. package/dist/{chunk-23XSG7LI.js → chunk-QGTDQNVV.js} +4 -4
  58. package/dist/{chunk-UVVZHWD2.js → chunk-R27VZIF6.js} +2 -2
  59. package/dist/{chunk-TQ2NA4Z4.js → chunk-R4NV3Q7G.js} +8 -2
  60. package/dist/chunk-R4NV3Q7G.js.map +1 -0
  61. package/dist/{chunk-EOPFER6N.js → chunk-R6VFJKZB.js} +19 -5
  62. package/dist/chunk-R6VFJKZB.js.map +1 -0
  63. package/dist/{chunk-3FS775NP.js → chunk-RQLVXJH2.js} +85 -4
  64. package/dist/chunk-RQLVXJH2.js.map +1 -0
  65. package/dist/{chunk-JQOKQKQT.js → chunk-S2D5PWAO.js} +2 -2
  66. package/dist/{chunk-43BDGVN3.js → chunk-T4EKNX2Q.js} +56 -9
  67. package/dist/chunk-T4EKNX2Q.js.map +1 -0
  68. package/dist/{chunk-XTVGCVU4.js → chunk-TERYL7JH.js} +36 -37
  69. package/dist/chunk-TERYL7JH.js.map +1 -0
  70. package/dist/{chunk-6LTLYV5D.js → chunk-UC27MQ3T.js} +1064 -265
  71. package/dist/chunk-UC27MQ3T.js.map +1 -0
  72. package/dist/chunk-UEA4NCY2.js +106 -0
  73. package/dist/chunk-UEA4NCY2.js.map +1 -0
  74. package/dist/{chunk-7HP6AAI3.js → chunk-UK2IV2ZQ.js} +2 -2
  75. package/dist/{chunk-PCMON7Y2.js → chunk-UZCAYOIQ.js} +8 -10
  76. package/dist/{chunk-PCMON7Y2.js.map → chunk-UZCAYOIQ.js.map} +1 -1
  77. package/dist/{chunk-N3ZCH64F.js → chunk-V4UNYSZO.js} +86 -32
  78. package/dist/chunk-V4UNYSZO.js.map +1 -0
  79. package/dist/chunk-VAPCU2FX.js +70 -0
  80. package/dist/chunk-VAPCU2FX.js.map +1 -0
  81. package/dist/{chunk-RFQ3N7FB.js → chunk-WGVU3LA5.js} +11 -9
  82. package/dist/chunk-WGVU3LA5.js.map +1 -0
  83. package/dist/{chunk-IMROMZ2K.js → chunk-WQ3F4O7U.js} +19 -14
  84. package/dist/chunk-WQ3F4O7U.js.map +1 -0
  85. package/dist/chunk-XNS4I3W6.js +102 -0
  86. package/dist/chunk-XNS4I3W6.js.map +1 -0
  87. package/dist/{chunk-2A36HWDE.js → chunk-Y4I7ZCAE.js} +129 -136
  88. package/dist/chunk-Y4I7ZCAE.js.map +1 -0
  89. package/dist/{chunk-TPEJFLV7.js → chunk-ZKMSHLXP.js} +4 -6
  90. package/dist/{chunk-TPEJFLV7.js.map → chunk-ZKMSHLXP.js.map} +1 -1
  91. package/dist/{compile-GXADKGH5.js → compile-B2QG6BAQ.js} +33 -37
  92. package/dist/{compile-GXADKGH5.js.map → compile-B2QG6BAQ.js.map} +1 -1
  93. package/dist/{config-JMHNA2U5.js → config-D3F6ICZ2.js} +16 -21
  94. package/dist/{config-JMHNA2U5.js.map → config-D3F6ICZ2.js.map} +1 -1
  95. package/dist/{cursor-local-install-46RWRBDT.js → cursor-local-install-4HDIBX22.js} +8 -12
  96. package/dist/{cursor-local-install-46RWRBDT.js.map → cursor-local-install-4HDIBX22.js.map} +1 -1
  97. package/dist/cursor-local-install-LL367GZY.js +94 -0
  98. package/dist/cursor-local-install-LL367GZY.js.map +1 -0
  99. package/dist/{doctor-N7ZULPOL.js → doctor-QSGETVDE.js} +14 -17
  100. package/dist/doctor-QSGETVDE.js.map +1 -0
  101. package/dist/{environment-OBB3WU5B.js → environment-2JS4RWQA.js} +42 -50
  102. package/dist/environment-2JS4RWQA.js.map +1 -0
  103. package/dist/{github-PBYBGOLH.js → github-JXSTHLY2.js} +9 -10
  104. package/dist/{github-PBYBGOLH.js.map → github-JXSTHLY2.js.map} +1 -1
  105. package/dist/{harness-7KYATIV6.js → harness-GBI3AMLH.js} +25 -31
  106. package/dist/{harness-7KYATIV6.js.map → harness-GBI3AMLH.js.map} +1 -1
  107. package/dist/{help-EE3AJQD4.js → help-EC52ERIE.js} +15 -20
  108. package/dist/{help-EE3AJQD4.js.map → help-EC52ERIE.js.map} +1 -1
  109. package/dist/{help-VXWKLQ6A.js → help-VIRMBOPJ.js} +57 -575
  110. package/dist/help-VIRMBOPJ.js.map +1 -0
  111. package/dist/host-plugin-view-kept-XKHD6NGU.js +139 -0
  112. package/dist/host-plugin-view-kept-XKHD6NGU.js.map +1 -0
  113. package/dist/index.js +12 -16
  114. package/dist/{init-LBTMPDVJ.js → init-OK3K6ILG.js} +33 -41
  115. package/dist/{init-LBTMPDVJ.js.map → init-OK3K6ILG.js.map} +1 -1
  116. package/dist/live-read-cache-ESQQJBNS.js +13 -0
  117. package/dist/live-read-cache-WPUFHVMZ.js +12 -0
  118. package/dist/{lock-WLJRXRVK.js → lock-AA2F4I3K.js} +9 -12
  119. package/dist/{lock-WLJRXRVK.js.map → lock-AA2F4I3K.js.map} +1 -1
  120. package/dist/{marketplace-GXSV6QIY.js → marketplace-QUYCV23F.js} +26 -79
  121. package/dist/marketplace-QUYCV23F.js.map +1 -0
  122. package/dist/{mcp-XPDWWU75.js → mcp-CIHSR4DD.js} +33 -37
  123. package/dist/{mcp-XPDWWU75.js.map → mcp-CIHSR4DD.js.map} +1 -1
  124. package/dist/{migrate-SBUIWN3U.js → migrate-TQPEZYS5.js} +93 -34
  125. package/dist/migrate-TQPEZYS5.js.map +1 -0
  126. package/dist/notifications-TAELTPDW.js +154 -0
  127. package/dist/notifications-TAELTPDW.js.map +1 -0
  128. package/dist/open-D3GWGDSQ.js +20 -0
  129. package/dist/{pack-A73LDVOX.js → pack-VUO4UBWL.js} +10 -14
  130. package/dist/{pack-A73LDVOX.js.map → pack-VUO4UBWL.js.map} +1 -1
  131. package/dist/plugin-L3466DHK.js +47 -0
  132. package/dist/plugin-from-project-U5UGKTJH.js +15 -0
  133. package/dist/{policy-6VY3CMSU.js → policy-Z5TL4N3V.js} +9 -12
  134. package/dist/{policy-6VY3CMSU.js.map → policy-Z5TL4N3V.js.map} +1 -1
  135. package/dist/{profile-YCKPMRRU.js → profile-QFI7SL3S.js} +108 -78
  136. package/dist/profile-QFI7SL3S.js.map +1 -0
  137. package/dist/{project-KHPPBKPN.js → project-3KR3EPYR.js} +486 -60
  138. package/dist/project-3KR3EPYR.js.map +1 -0
  139. package/dist/{resource-IJU3FAN5.js → resource-45BPRQ7V.js} +55 -45
  140. package/dist/resource-45BPRQ7V.js.map +1 -0
  141. package/dist/status-refresh-worker.js +1155 -0
  142. package/dist/status-refresh-worker.js.map +1 -0
  143. package/dist/{version-Z66FWWMQ.js → version-QUJZGTZ5.js} +3 -3
  144. package/dist/version-QUJZGTZ5.js.map +1 -0
  145. package/package.json +16 -11
  146. package/dist/apply-SUNDXRJ3.js +0 -54
  147. package/dist/chunk-2A36HWDE.js.map +0 -1
  148. package/dist/chunk-2H7UOFLK.js +0 -11
  149. package/dist/chunk-3FS775NP.js.map +0 -1
  150. package/dist/chunk-43BDGVN3.js.map +0 -1
  151. package/dist/chunk-4ZQ2SCGY.js.map +0 -1
  152. package/dist/chunk-6LTLYV5D.js.map +0 -1
  153. package/dist/chunk-D432JAXV.js.map +0 -1
  154. package/dist/chunk-DF4Z7LAD.js +0 -3463
  155. package/dist/chunk-DF4Z7LAD.js.map +0 -1
  156. package/dist/chunk-EOPFER6N.js.map +0 -1
  157. package/dist/chunk-G6WKY2W4.js +0 -389
  158. package/dist/chunk-G6WKY2W4.js.map +0 -1
  159. package/dist/chunk-IE7B6Q5K.js.map +0 -1
  160. package/dist/chunk-IMROMZ2K.js.map +0 -1
  161. package/dist/chunk-M2U3J7UX.js +0 -46
  162. package/dist/chunk-M2U3J7UX.js.map +0 -1
  163. package/dist/chunk-N3ZCH64F.js.map +0 -1
  164. package/dist/chunk-NAGAJ5UM.js +0 -145
  165. package/dist/chunk-NAGAJ5UM.js.map +0 -1
  166. package/dist/chunk-OML4HXKT.js.map +0 -1
  167. package/dist/chunk-QA5U36JN.js.map +0 -1
  168. package/dist/chunk-R7ZOYVN3.js.map +0 -1
  169. package/dist/chunk-RDG5DT7S.js.map +0 -1
  170. package/dist/chunk-REHRUNBB.js.map +0 -1
  171. package/dist/chunk-RFQ3N7FB.js.map +0 -1
  172. package/dist/chunk-TQ2NA4Z4.js.map +0 -1
  173. package/dist/chunk-ULCD6DJE.js.map +0 -1
  174. package/dist/chunk-WG5A6EAU.js.map +0 -1
  175. package/dist/chunk-XGTTOO4R.js +0 -84
  176. package/dist/chunk-XGTTOO4R.js.map +0 -1
  177. package/dist/chunk-XTVGCVU4.js.map +0 -1
  178. package/dist/chunk-XUJKZQZA.js +0 -235
  179. package/dist/chunk-XUJKZQZA.js.map +0 -1
  180. package/dist/chunk-ZUASVASP.js.map +0 -1
  181. package/dist/doctor-N7ZULPOL.js.map +0 -1
  182. package/dist/environment-OBB3WU5B.js.map +0 -1
  183. package/dist/help-VXWKLQ6A.js.map +0 -1
  184. package/dist/live-read-cache-TUSP7U3D.js +0 -10
  185. package/dist/marketplace-GXSV6QIY.js.map +0 -1
  186. package/dist/migrate-SBUIWN3U.js.map +0 -1
  187. package/dist/open-HDGLYYVU.js +0 -24
  188. package/dist/plugin-CEO6ZJM5.js +0 -51
  189. package/dist/plugin-from-project-UK7VJVUP.js +0 -18
  190. package/dist/profile-YCKPMRRU.js.map +0 -1
  191. package/dist/project-KHPPBKPN.js.map +0 -1
  192. package/dist/resource-IJU3FAN5.js.map +0 -1
  193. /package/dist/{apply-SUNDXRJ3.js.map → apply-FTAIL3X3.js.map} +0 -0
  194. /package/dist/{chunk-GRASK6M6.js.map → chunk-6FXJIKEG.js.map} +0 -0
  195. /package/dist/{chunk-73OJQTBW.js.map → chunk-A3TZT4WT.js.map} +0 -0
  196. /package/dist/{chunk-U6DXASQP.js.map → chunk-CBSDMRMY.js.map} +0 -0
  197. /package/dist/{chunk-P2C7JPLD.js.map → chunk-EPXAOEBB.js.map} +0 -0
  198. /package/dist/{chunk-3P6BWL5F.js.map → chunk-K4UDZUJ2.js.map} +0 -0
  199. /package/dist/{chunk-PNGF5EV2.js.map → chunk-MHLAIGIM.js.map} +0 -0
  200. /package/dist/{chunk-BPWFQKI5.js.map → chunk-MHMFF6A5.js.map} +0 -0
  201. /package/dist/{chunk-2H7UOFLK.js.map → chunk-MKLJBW5N.js.map} +0 -0
  202. /package/dist/{chunk-23XSG7LI.js.map → chunk-QGTDQNVV.js.map} +0 -0
  203. /package/dist/{chunk-UVVZHWD2.js.map → chunk-R27VZIF6.js.map} +0 -0
  204. /package/dist/{chunk-JQOKQKQT.js.map → chunk-S2D5PWAO.js.map} +0 -0
  205. /package/dist/{chunk-7HP6AAI3.js.map → chunk-UK2IV2ZQ.js.map} +0 -0
  206. /package/dist/{live-read-cache-TUSP7U3D.js.map → live-read-cache-ESQQJBNS.js.map} +0 -0
  207. /package/dist/{open-HDGLYYVU.js.map → live-read-cache-WPUFHVMZ.js.map} +0 -0
  208. /package/dist/{plugin-CEO6ZJM5.js.map → open-D3GWGDSQ.js.map} +0 -0
  209. /package/dist/{plugin-from-project-UK7VJVUP.js.map → plugin-L3466DHK.js.map} +0 -0
  210. /package/dist/{version-Z66FWWMQ.js.map → plugin-from-project-U5UGKTJH.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/copy/plurals.ts","../src/version.ts","../package.json","../src/copy/cli.ts","../src/db/native-module.ts","../src/db/connection.ts","../src/services/status-trace.ts","../src/db/write-generation.ts","../src/utils/fetch-with-timeout.ts","../src/utils/git-errors.ts"],"sourcesContent":["/**\n * Shared count/plural helper for CLI and Desktop (W3-2).\n * Desktop can import this module or mirror `apps/desktop/src/lib/plurals.ts`.\n */\n\nexport function formatCount(count: number, noun: string, plural = `${noun}s`): string {\n return `${count} ${count === 1 ? noun : plural}`;\n}\n\nexport function pluralNoun(count: number, noun: string, plural = `${noun}s`): string {\n return count === 1 ? noun : plural;\n}\n","import { execFileSync } from \"node:child_process\";\nimport packageJson from \"../package.json\" with { type: \"json\" };\n\ndeclare const __HT_VERSION__: string | undefined;\n\nconst GIT_SHA = /^[0-9a-f]{7,40}$/i;\n\nexport interface DevBuildVersionOptions {\n isRelease?: boolean;\n gitSha?: string | null;\n}\n\nfunction compactGitSha(sha: string | null | undefined): string | undefined {\n const trimmed = sha?.trim().toLowerCase();\n if (!trimmed || !GIT_SHA.test(trimmed)) {\n return undefined;\n }\n return trimmed.slice(0, 7);\n}\n\n/** True when a release workflow baked a publishable version (no `-dev+sha`). */\nexport function isReleaseBuild(env: NodeJS.ProcessEnv = process.env): boolean {\n return env.HT_RELEASE === \"1\" || env.HARNESSTAP_RELEASE === \"1\";\n}\n\n/** Best-effort git SHA for the `-dev+sha` suffix. */\nexport function readGitSha(\n env: NodeJS.ProcessEnv = process.env,\n cwd: string = process.cwd(),\n): string | undefined {\n const fromEnv = compactGitSha(env.HT_GIT_SHA ?? env.GITHUB_SHA);\n if (fromEnv) {\n return fromEnv;\n }\n try {\n const sha = execFileSync(\"git\", [\"rev-parse\", \"HEAD\"], {\n cwd,\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n }).trim();\n return compactGitSha(sha);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Append `-dev+<sha>` on non-release builds so CLI and Desktop can tell a\n * local/CI binary from a published version. Release builds return `version`\n * unchanged. Desktop should call this helper when reporting a newer-schema DB.\n */\nexport function formatDevBuildVersion(\n version: string,\n options: DevBuildVersionOptions = {},\n): string {\n const trimmed = version.trim();\n if (options.isRelease) {\n return trimmed;\n }\n if (trimmed.includes(\"-dev+\")) {\n return trimmed;\n }\n const sha = compactGitSha(options.gitSha);\n if (!sha) {\n return `${trimmed}-dev`;\n }\n return `${trimmed}-dev+${sha}`;\n}\n\n/** Version baked into tsup and the compiled sidecar (`__HT_VERSION__`). */\nexport function resolveBuildVersion(env: NodeJS.ProcessEnv = process.env): string {\n return formatDevBuildVersion(packageJson.version, {\n isRelease: isReleaseBuild(env),\n gitSha: readGitSha(env),\n });\n}\n\nfunction resolvePackageVersion(): string {\n // tsup and the sidecar build define __HT_VERSION__; the JSON import is the\n // source/test fallback and is inlined by every bundler, never read at runtime.\n if (typeof __HT_VERSION__ === \"string\" && __HT_VERSION__.length > 0) {\n return __HT_VERSION__;\n }\n return resolveBuildVersion();\n}\n\nexport const PACKAGE_VERSION: string = resolvePackageVersion();\n","{\n \"name\": \"harnesstap\",\n \"version\": \"1.4.0\",\n \"description\": \"Agent harness configuration toolkit for Claude Code, Codex, Cursor, and other coding CLIs\",\n \"type\": \"module\",\n \"packageManager\": \"bun@1.3.9\",\n \"files\": [\n \"dist\",\n \"LICENSE\",\n \"README.md\",\n \"schemas\"\n ],\n \"bin\": {\n \"harnesstap\": \"./dist/bin.js\",\n \"ht\": \"./dist/bin.js\"\n },\n \"scripts\": {\n \"build\": \"bun scripts/generate-scenarios.ts && rm -rf dist && tsup\",\n \"generate:scenarios\": \"bun scripts/generate-scenarios.ts\",\n \"check:packaged-help\": \"bun scripts/check-packaged-help.ts\",\n \"snapshot:released-cli\": \"bun scripts/snapshot-released-cli.ts\",\n \"build:sidecar\": \"bash scripts/build-sidecar.sh\",\n \"check:compiled-sidecar\": \"bun scripts/check-compiled-sidecar.ts\",\n \"desktop:cleanup\": \"bash apps/desktop/scripts/cleanup-stale-dev.sh\",\n \"desktop:prepare-sidecar\": \"bash apps/desktop/scripts/prepare-sidecar.sh\",\n \"desktop:watch-sidecar\": \"bun apps/desktop/scripts/watch-sidecar.ts\",\n \"desktop:icons\": \"cd apps/desktop && bun run icons\",\n \"desktop:dev\": \"bash apps/desktop/scripts/desktop-dev.sh\",\n \"desktop:build\": \"bun run desktop:prepare-sidecar && cd apps/desktop && bun install && bun run tauri build && bash scripts/reseal-macos-app.sh\",\n \"desktop:install\": \"bun apps/desktop/scripts/install-local.ts\",\n \"desktop:e2e:build\": \"bash apps/desktop/scripts/e2e-build.sh\",\n \"desktop:e2e\": \"bash apps/desktop/scripts/e2e-run.sh\",\n \"desktop:demo-agent\": \"bash apps/desktop/scripts/demo-home.sh\",\n \"desktop:shots\": \"cd apps/desktop && bun run shots\",\n \"desktop:check\": \"bash apps/desktop/scripts/desktop-check.sh\",\n \"dev\": \"tsup --watch\",\n \"start\": \"bun src/bin.ts\",\n \"start:dist\": \"node dist/bin.js\",\n \"link\": \"bun run build && bun link\",\n \"unlink\": \"bun unlink\",\n \"test\": \"bun test --timeout 30000\",\n \"test:run\": \"bun test --dots --timeout 30000\",\n \"test:core\": \"bun test --dots test/models test/db test/config test/utils test/telemetry test/scripts\",\n \"test:platforms\": \"bun test --dots test/platforms\",\n \"test:plugins\": \"bun test --dots test/plugins\",\n \"test:services\": \"bun test --dots test/services test/integration test/agent/init-apply-noop.test.ts\",\n \"test:cli\": \"bun test --dots test/cli test/ui test/helpers\",\n \"test:docs\": \"bun test --dots test/docs\",\n \"lint\": \"biome lint .\",\n \"lint:fix\": \"biome lint --write --unsafe .\",\n \"lint:css\": \"bun scripts/check-css-tokens.ts\",\n \"check:cli-error-contract\": \"bun scripts/check-cli-error-contract.ts\",\n \"check:copy\": \"bun scripts/check-copy.ts\",\n \"check:agent-plugins-spec\": \"bun test test/services/agent-plugins/spec-schema-guard.test.ts test/services/agent-plugins/spec-mcp.test.ts test/services/agent-plugins/spec-load.test.ts\",\n \"typecheck\": \"tsc --noEmit\",\n \"clean\": \"rm -rf dist && find . -maxdepth 1 -name '*.bun-build' -delete\",\n \"preflight\": \"bun run lint && bun run lint:css && bun run check:cli-error-contract && bun run check:copy && bun run typecheck && bun run test:run && bun run build\",\n \"prepublishOnly\": \"bun run build\",\n \"docs:vhs\": \"bash scripts/generate-vhs-scenarios.sh\",\n \"check:scenario-docs\": \"bash scripts/check-scenario-docs.sh\",\n \"check:scenario-smoke\": \"bun test test/cli/scenario-smoke.test.ts\",\n \"check:sqlite-wal-smoke\": \"bun scripts/sqlite-wal-write-smoke.ts\",\n \"sync:cloud-docs\": \"bash scripts/sync-cloud-cli-docs.sh\"\n },\n \"keywords\": [\n \"ai\",\n \"coding-assistant\",\n \"cli\",\n \"configuration\",\n \"claude-code\",\n \"cursor\",\n \"codex\",\n \"skills\",\n \"layers\"\n ],\n \"license\": \"Apache-2.0\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/harnesstap/harnesstap.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/harnesstap/harnesstap/issues\"\n },\n \"homepage\": \"https://github.com/harnesstap/harnesstap#readme\",\n \"engines\": {\n \"node\": \">=22.12.0\"\n },\n \"dependencies\": {\n \"@inquirer/core\": \"^10.3.2\",\n \"@inquirer/search\": \"^3.2.2\",\n \"better-sqlite3\": \"^12.11.1\",\n \"chalk\": \"^5.4.1\",\n \"cli-table3\": \"^0.6.5\",\n \"commander\": \"^13.1.0\",\n \"gray-matter\": \"^4.0.3\",\n \"inquirer\": \"^12.3.0\",\n \"jsonc-parser\": \"^3.3.1\",\n \"ora\": \"^9.4.0\",\n \"picomatch\": \"^4.0.2\",\n \"semver\": \"^7.8.0\",\n \"smol-toml\": \"^1.3.1\",\n \"ulid\": \"^2.3.0\",\n \"yaml\": \"^2.7.0\"\n },\n \"devDependencies\": {\n \"@biomejs/biome\": \"^2.4.10\",\n \"@inquirer/testing\": \"^3.3.8\",\n \"@types/better-sqlite3\": \"^7.6.12\",\n \"@types/node\": \"^22.10.0\",\n \"@types/semver\": \"^7.7.1\",\n \"ajv\": \"^8.20.0\",\n \"happy-dom\": \"17.4.4\",\n \"tsup\": \"^8.3.5\",\n \"typescript\": \"^5.7.0\"\n }\n}\n","/**\n * User-facing CLI copy. ASCII punctuation only (DS-6).\n * Command hints always start with `ht`.\n */\n\nimport { pluralNoun } from \"./plurals.js\";\n\nexport const DRY_RUN_NOTHING_CHANGED = \"Dry run. Nothing was changed.\";\n\nexport const NATIVE_MODULE_MISMATCH_MESSAGE =\n \"HarnessTap was installed under a different Node.js version. Run: npm rebuild -g harnesstap\";\n\n/** Quote a user-provided token so a pasted hint parses as one Commander argument. */\nexport function quoteCliArg(value: string): string {\n if (value.length === 0) {\n return '\"\"';\n }\n if (/^[A-Za-z0-9_./:@+=-]+$/.test(value)) {\n return value;\n }\n return `\"${value.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"')}\"`;\n}\n\nexport function formatHtCommand(path: string): string {\n return `ht ${path}`.trim();\n}\n\nexport function quoted(name: string): string {\n return `\"${name}\"`;\n}\n\nexport function skippedInvalidPluginExport(name: string): string {\n return `Warning: Skipped plugin ${quoted(name)}. Its version is not valid semver.`;\n}\n\nexport function marketplaceUnreachable(source: string): string {\n return `Error: Couldn't reach ${source}.`;\n}\n\nexport function marketplaceUnreachableHint(): string {\n return \"Check the URL, or sign in with ht github login if it's private.\";\n}\n\nexport function marketplacePathMissing(path: string): string {\n return `Error: Couldn't find a marketplace at ${quoted(path)}.`;\n}\n\nexport function marketplacePathNotMarketplace(path: string): string {\n return `Error: ${quoted(path)} is not a marketplace. It needs a marketplace.json file.`;\n}\n\nexport function marketplaceAddFailedNothingSaved(): string {\n return \"Nothing was saved.\";\n}\n\nexport function installPinnedPluginsPrompt(names: string[]): string {\n if (names.length === 1) {\n const only = names[0];\n return `Install pinned plugin ${quoted(only ?? \"\")} into the package cache?`;\n }\n return `Install ${String(names.length)} pinned plugins into the package cache?`;\n}\n\nexport function installPinnedPluginsNeedsYes(): string {\n return \"Error: Pass --yes to install pinned plugins without a prompt.\";\n}\n\nexport function installPinnedPluginsHint(profileName?: string): string {\n if (profileName) {\n return `Run ht profile use ${quoted(profileName)} --yes to install them.`;\n }\n return \"Run ht profile use --yes to install them.\";\n}\n\nexport function missingMarketplacePluginHint(pluginName: string): string {\n return `Run ht profile use to install ${quoted(pluginName)}.`;\n}\n\nexport function skippedHostPluginHook(hookName: string): string {\n return `Skipped hook ${hookName}. It only works when the plugin is installed as a host plugin.`;\n}\n\nexport function skippedDuplicateCommand(name: string): string {\n return `Skipped command ${quoted(name)}. A skill already uses that name.`;\n}\n\n/** Quote a user-provided name in error text (DS-6). */\nexport function quoteName(name: string): string {\n return `\"${name.replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll(\"\\\"\", \"\\\\\\\"\")}\"`;\n}\n\nfunction hintToken(value: string): string {\n if (/^[A-Za-z0-9_./:@+=,-]+$/.test(value)) {\n return value;\n }\n return quoteName(value);\n}\n\n/** `ht` plus shell-quoted arguments. Names with spaces stay one token. */\nexport function formatHtArgs(args: readonly string[]): string {\n return [\"ht\", ...args.map(hintToken)].join(\" \");\n}\n\n/** Turn markdown links into terminal text. Relative targets keep the label only. */\nexport function plainTerminalText(value: string): string {\n return value.replace(\n /\\[([^\\]]+)\\]\\(([^)]+)\\)/g,\n (_match, label: string, target: string) => {\n if (target.startsWith(\"http://\") || target.startsWith(\"https://\")) {\n return `${label} (${target})`;\n }\n return label;\n },\n );\n}\n\nexport function ensureErrorPrefix(message: string): string {\n const stripped = message.replace(/^error:\\s*/i, \"\").trim();\n if (stripped.length === 0) {\n return \"Error: Something went wrong.\";\n }\n const sentence = /[.!?]$/.test(stripped) ? stripped : `${stripped}.`;\n return `Error: ${sentence}`;\n}\n\nexport function ensureWarningPrefix(message: string): string {\n const stripped = message.replace(/^warning:\\s*/i, \"\").trim();\n const sentence = /[.!?]$/.test(stripped) ? stripped : `${stripped}.`;\n return `Warning: ${sentence}`;\n}\n\nexport const CLI_HINTS = {\n seeOptions: (commandPath: string): string =>\n commandPath.trim().length > 0\n ? `Run ht ${commandPath.trim()} --help to see the options.`\n : \"Run ht --help to see the options.\",\n pluginList: \"Run ht plugin list to see your plugins.\",\n resourceList: \"Run ht resource list to see your resources.\",\n profileUseExample: 'For example: ht profile use \"global default\"',\n authLogin: \"Run ht auth login to sign in.\",\n githubLogin: marketplaceUnreachableHint(),\n onConflictReplace: \"Use --on-conflict replace to replace it.\",\n unsavedChanges: \"Run again with --changes save, stash or discard.\",\n updateNpm: \"Update with: npm i -g harnesstap\",\n mcpSearch: (name: string): string => `Run ht mcp search ${hintToken(name)} to find it.`,\n scopeAdd: (name: string, harnesses: string): string =>\n `Run ht resource scope ${hintToken(name)} --add ${hintToken(harnesses)}.`,\n portableMcpTip: (name: string, harnessList: string, command: string): string =>\n `Tip: ${quoteName(name)} also works on ${harnessList}. Run ${command}.`,\n forceRemove: \"To remove them too, run: ht apply --force-remove\",\n revert: \"Snapshot saved. Undo with: ht revert\",\n stashPop: \"Bring them back with: ht profile stash pop\",\n harnessSet: \"Run ht harness set to pick your harnesses.\",\n harnessSetOrFlag: \"Run ht harness set, or pass --harness <slugs>.\",\n} as const;\n\nexport const CLI_ERRORS = {\n pluginNotFound: (name: string): string => `No plugin named ${quoteName(name)}.`,\n resourceNotFound: (name: string): string => `No resource named ${quoteName(name)}.`,\n invalidResourceType: (value: string, valid: readonly string[]): string =>\n `${quoteName(value)} isn't a resource type. Valid: ${valid.join(\", \")}.`,\n conflictingResourceTypes: (a: string, b: string): string =>\n `Conflicting type filters: ${quoteName(a)} and ${quoteName(b)}.`,\n pluginAlreadyExists: (name: string): string =>\n `A plugin named ${quoteName(name)} already exists.`,\n environmentAlreadyExists: (name: string): string =>\n `An environment named ${quoteName(name)} already exists.`,\n notAuthenticated: \"Not authenticated to HarnessTap Cloud.\",\n directoryNotFound: (path: string): string => `Directory not found: ${path}.`,\n fileNotFound: (path: string): string => `File not found: ${path}.`,\n gitUnreachable: (url: string): string => `Couldn't reach ${url}.`,\n gitUnreachableGeneric: \"Couldn't reach that git repository.\",\n uniqueConstraintGeneric: \"That name already exists.\",\n missingProfileName: \"Pass a profile name.\",\n noProfileNamed: (name: string): string => `No profile named ${quoteName(name)}.`,\n invalidPluginName: (name: string): string =>\n `${quoteName(name)} isn't a valid plugin name. Use a non-empty name without /, \\\\, .. or control characters.`,\n emptyPluginName: \"Pass a plugin name.\",\n invalidFormat: (value: string): string => `Invalid --format value: ${value}. Use human or json.`,\n mcpNotInLibrary: (name: string): string => `${quoteName(name)} isn't in your library.`,\n newerSchema: \"This data was saved by a newer HarnessTap.\",\n noHarnesses: \"Not set up for any harness yet.\",\n unsavedChanges: (name: string, count: number): string =>\n `${quoteName(name)} has ${count} unsaved change${count === 1 ? \"\" : \"s\"}.`,\n resourceSyncStale: (count: number): string =>\n `${count} linked resource${count === 1 ? \"\" : \"s\"} ${count === 1 ? \"is\" : \"are\"} stale.`,\n} as const;\n\nexport const SCOPE_COPY = {\n allHarnesses: \"Applies to all your harnesses\",\n notSetUp: \"Not set up for any harness yet\",\n} as const;\n\nexport const SWITCH_CHANGES_VALUES = [\"save\", \"stash\", \"discard\"] as const;\nexport type SwitchChangesValue = (typeof SWITCH_CHANGES_VALUES)[number];\n\nexport const SWITCH_CHANGES_FLAG_HELP =\n \"What to do with unsaved changes: save, stash or discard\";\n\nexport const DEVICE_LOGIN_WAITING =\n \"Waiting for you to approve in the browser. The code expires in 15 minutes. Press Ctrl+C to cancel.\";\n\nexport function initPickHarnessesLine(): string {\n return `Pick your harnesses: ${formatHtCommand(\"harness set\")}`;\n}\n\nexport function initCompletionHintLine(\n shell: \"bash\" | \"zsh\" | \"fish\" | undefined,\n): string {\n switch (shell) {\n case \"bash\":\n return `Enable tab completion: ${formatHtCommand(\"init completion bash >> ~/.bashrc\")}`;\n case \"zsh\":\n return `Enable tab completion: ${formatHtCommand(\"init completion zsh >> ~/.zshrc\")}`;\n case \"fish\":\n return `Enable tab completion: ${formatHtCommand(\"init completion fish > ~/.config/fish/completions/ht.fish\")}`;\n default:\n return `Enable tab completion: ${formatHtCommand(\"init completion <bash|zsh|fish>\")}`;\n }\n}\n\nexport const CLI_COPY = {\n dryRunNothingChanged: DRY_RUN_NOTHING_CHANGED,\n everythingUpToDate: \"Everything is up to date.\",\n snapshotSavedUndo: \"Snapshot saved. Undo with:\",\n forceRemoveHint: \"To remove them too, run:\",\n keptYouChanged: \"you changed it\",\n keptNotMade: \"not made by HarnessTap\",\n viewSnapshot: \"View snapshot\",\n keptFilesIntro:\n \"files you changed or that HarnessTap didn't create:\",\n} as const;\n\nexport function alreadyExistsOnConflictHint(kind: string, name: string): string {\n return `A ${kind} named \"${name}\" already exists. Use --on-conflict replace to replace it.`;\n}\n\n/**\n * Hint after a cancelled apply. One file says \"it\"; two or more say \"them\".\n */\nexport function onConflictReplaceHint(conflicts: readonly string[]): string {\n const count = new Set(\n conflicts.map((path) => path.trim()).filter((path) => path.length > 0),\n ).size;\n if (count > 1) {\n return \"Use --on-conflict replace to replace them.\";\n }\n return CLI_HINTS.onConflictReplace;\n}\n\n/**\n * Human line for a cancelled apply. Names every conflicting path.\n * Pair with onConflictReplaceHint.\n */\nexport function applyCancelledMessage(\n conflicts: readonly string[],\n scope: \"profile\" | \"apply\" = \"apply\",\n): string {\n const paths = [\n ...new Set(\n conflicts.map((path) => path.trim()).filter((path) => path.length > 0),\n ),\n ];\n const lead = scope === \"profile\" ? \"Profile apply cancelled.\" : \"Apply cancelled.\";\n if (paths.length === 0) {\n return lead;\n }\n const listed = paths.map((path) => quoteCliArg(path)).join(\", \");\n if (paths.length === 1) {\n return `${lead} ${listed} would change.`;\n }\n return `${lead} These files would change: ${listed}.`;\n}\n\nexport function unsavedChangesLine(profileName: string, count: number): string {\n return CLI_ERRORS.unsavedChanges(profileName, count);\n}\n\nexport function unsavedChangesFlagHint(): string {\n return CLI_HINTS.unsavedChanges;\n}\n\nexport function savedChangesLine(profileName: string, count: number): string {\n return `Saved ${count} ${pluralNoun(count, \"change\")} to ${quoteName(profileName)}.`;\n}\n\nexport function stashedChangesLine(count: number, popCommand: string): string {\n return `Stashed ${count} ${pluralNoun(count, \"change\")}. Bring them back with: ${popCommand}`;\n}\n\nexport function discardedChangesLine(count: number): string {\n return `Discarded ${count} ${pluralNoun(count, \"change\")}.`;\n}\n\nexport function discardConfirm(count: number): string {\n return `Discard ${count} ${pluralNoun(count, \"change\")}? A snapshot keeps a copy.`;\n}\n\nexport const PREVIEW_LABELS = {\n willWrite: \"Will write\",\n upToDate: \"Up to date\",\n notInProfile: \"Not in profile\",\n willRemove: \"Will remove\",\n keptChanged: \"Kept. You changed it.\",\n keptUnmanaged: \"Kept. Not made by HarnessTap.\",\n dryRunHeader: DRY_RUN_NOTHING_CHANGED,\n everythingUpToDate: (unchanged: number): string => `Everything is up to date. ${unchanged} unchanged.`,\n} as const;\n\nexport function applyWroteLine(input: {\n wrote: number;\n removed: number;\n kept: number;\n unchanged?: number;\n omitUnchanged?: boolean;\n}): string {\n if (input.wrote === 0 && input.removed === 0 && input.kept === 0) {\n return input.unchanged !== undefined\n ? `${CLI_COPY.everythingUpToDate} ${input.unchanged} unchanged.`\n : CLI_COPY.everythingUpToDate;\n }\n if (input.wrote === 0 && input.removed === 0) {\n const line = `Wrote 0, removed 0, kept ${input.kept}`;\n if (!input.omitUnchanged && input.unchanged !== undefined && input.unchanged > 0) {\n return `${line}, unchanged ${input.unchanged}.`;\n }\n return `${line}.`;\n }\n const parts: string[] = [];\n if (input.wrote > 0) parts.push(`Wrote ${input.wrote}`);\n if (input.removed > 0) parts.push(`removed ${input.removed}`);\n if (input.kept > 0) parts.push(`kept ${input.kept}`);\n if (parts.length === 0) {\n return input.unchanged !== undefined\n ? `${CLI_COPY.everythingUpToDate} ${input.unchanged} unchanged.`\n : CLI_COPY.everythingUpToDate;\n }\n if (!input.omitUnchanged && input.unchanged !== undefined && input.unchanged > 0) {\n parts.push(`unchanged ${input.unchanged}`);\n }\n const [first, ...rest] = parts;\n const head = first ?? \"\";\n if (rest.length === 0) {\n return `${head}.`;\n }\n return `${head}, ${rest.join(\", \")}.`;\n}\n\nexport function applyHeaderLine(profileName: string, harnessCount: number): string {\n const noun = harnessCount === 1 ? \"harness\" : \"harnesses\";\n return `Applied \"${profileName}\" to ${harnessCount} ${noun}.`;\n}\n\nexport function dryRunWouldLine(input: {\n write: number;\n remove: number;\n keep: number;\n unchanged: number;\n}): string {\n return `Would write ${input.write}, remove ${input.remove}, keep ${input.keep}. ${input.unchanged} unchanged.`;\n}\n\nexport function dryRunStashLine(count: number, profileName: string): string {\n return `Dry run. Would stash ${count} changes from \"${profileName}\".`;\n}\n\nexport function snapshotSavedUndoLine(revertCommand: string): string {\n return `${CLI_COPY.snapshotSavedUndo} ${revertCommand}`;\n}\n\nexport function keptFilesHeader(count: number): string {\n return `Kept ${count} ${CLI_COPY.keptFilesIntro}`;\n}\n\nexport function restoredRemovedLine(\n restored: number,\n removed: number,\n options: { dryRun?: boolean } = {},\n): string {\n if (options.dryRun) {\n return `Would restore ${restored}, would remove ${removed}.`;\n }\n return `Restored ${restored}, removed ${removed}.`;\n}\n\nexport function dryRunSectionHeader(\n kind: \"write\" | \"remove\" | \"keep\",\n count: number,\n): string {\n switch (kind) {\n case \"write\":\n return `Would write (${count})`;\n case \"remove\":\n return `Would remove (${count})`;\n case \"keep\":\n return `Would keep (${count})`;\n default: {\n const _exhaustive: never = kind;\n return _exhaustive;\n }\n }\n}\n\nexport function keptReasonLabel(reason: \"modified\" | \"unmanaged\"): string {\n switch (reason) {\n case \"modified\":\n return CLI_COPY.keptYouChanged;\n case \"unmanaged\":\n return CLI_COPY.keptNotMade;\n default: {\n const _exhaustive: never = reason;\n return _exhaustive;\n }\n }\n}\n","import { NATIVE_MODULE_MISMATCH_MESSAGE } from \"../copy/cli.js\";\n\nexport { NATIVE_MODULE_MISMATCH_MESSAGE };\n\nfunction shouldShowNativeModuleDetails(): boolean {\n if (process.env.HARNESSTAP_DEBUG === \"1\") {\n return true;\n }\n return process.argv.includes(\"-v\") || process.argv.includes(\"--verbose\");\n}\n\nexport function isNativeModuleMismatch(error: unknown): boolean {\n if (!error || typeof error !== \"object\") {\n return false;\n }\n const err = error as { code?: unknown; message?: unknown };\n const code = typeof err.code === \"string\" ? err.code : \"\";\n const message = typeof err.message === \"string\" ? err.message : String(error);\n if (code === \"ERR_DLOPEN_FAILED\") {\n return true;\n }\n return message.includes(\"NODE_MODULE_VERSION\") || message.includes(\"ERR_DLOPEN\");\n}\n\nexport function reportNativeModuleMismatch(cause?: unknown): never {\n if (shouldShowNativeModuleDetails() && cause !== undefined) {\n console.error(cause);\n }\n console.error(NATIVE_MODULE_MISMATCH_MESSAGE);\n process.exit(1);\n}\n\n/** Run a native sqlite load; print the DS-6 one-liner on ABI mismatch. */\nexport function withNativeModuleGuard<T>(load: () => T): T {\n try {\n return load();\n } catch (error) {\n if (isNativeModuleMismatch(error)) {\n reportNativeModuleMismatch(error);\n }\n throw error;\n }\n}\n","import { existsSync, mkdirSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport { withNativeModuleGuard } from \"./native-module.js\";\nimport type { SqliteDatabase, SqliteDatabaseConstructor } from \"./types.js\";\nimport { trackStatusWrites } from \"./write-generation.js\";\n\nconst require = createRequire(import.meta.url);\n\nlet instance: SqliteDatabase | null = null;\nlet instancePath: string | null = null;\n\nfunction loadBetterSqlite3(): SqliteDatabaseConstructor {\n return withNativeModuleGuard(\n () => require(\"better-sqlite3\") as SqliteDatabaseConstructor,\n );\n}\n\nfunction resolveDatabaseConstructor(): SqliteDatabaseConstructor {\n if (\"Bun\" in globalThis) {\n return (require(\"bun:sqlite\") as { Database: SqliteDatabaseConstructor })\n .Database;\n }\n\n return loadBetterSqlite3();\n}\n\nfunction usesBunSqlite(): boolean {\n return \"Bun\" in globalThis;\n}\n\nfunction wrapDatabase(db: SqliteDatabase): SqliteDatabase {\n return {\n prepare<Row = unknown>(sql: string) {\n const statement = db.prepare<Row>(sql);\n return {\n run: (...params: unknown[]) => statement.run(...params),\n get: (...params: unknown[]) => {\n const row = statement.get(...params);\n return row ?? undefined;\n },\n all: (...params: unknown[]) => statement.all(...params),\n };\n },\n exec: (sql: string) => db.exec(sql),\n transaction: <T extends (...args: never[]) => unknown>(fn: T) =>\n db.transaction(fn),\n close: () => db.close(),\n };\n}\n\nfunction resolveHarnesstapDir(): string {\n if (process.env.HARNESSTAP_HOME) {\n return process.env.HARNESSTAP_HOME;\n }\n const homePath = process.env.HOME ?? process.env.USERPROFILE ?? homedir();\n return join(homePath, \".harnesstap\");\n}\n\n/** HarnessTap data dir for a given user home (isolates tests that pass a custom homeRoot). */\nexport function harnesstapDirForHomeRoot(homeRoot: string): string {\n if (process.env.HARNESSTAP_HOME) {\n return process.env.HARNESSTAP_HOME;\n }\n return join(homeRoot, \".harnesstap\");\n}\n\nfunction resolveDbPath(): string {\n return join(resolveHarnesstapDir(), \"harnesstap.db\");\n}\n\nfunction resolveConfigJsoncPath(): string {\n return join(resolveHarnesstapDir(), \"config.jsonc\");\n}\n\nfunction resolveLegacyConfigPath(): string {\n return join(resolveHarnesstapDir(), \"config.json\");\n}\n\nexport function getDbPath(): string {\n return resolveDbPath();\n}\n\nexport function getHarnesstapDir(): string {\n return resolveHarnesstapDir();\n}\n\nexport function getConfigJsoncPath(): string {\n return resolveConfigJsoncPath();\n}\n\nexport function getLegacyConfigPath(): string {\n return resolveLegacyConfigPath();\n}\n\nfunction isCompletionMode(): boolean {\n return process.env.HARNESSTAP_COMPLETE === \"1\";\n}\n\nexport function getDb(): SqliteDatabase {\n const dbPath = resolveDbPath();\n const completionMode = isCompletionMode();\n\n if (instance && instancePath === dbPath) {\n return instance;\n }\n\n if (instance) {\n instance.close();\n instance = null;\n instancePath = null;\n }\n\n if (completionMode) {\n if (!existsSync(dbPath)) {\n throw new Error(`HarnessTap database not found: ${dbPath}`);\n }\n } else {\n mkdirSync(resolveHarnesstapDir(), { recursive: true });\n }\n\n const Database = resolveDatabaseConstructor();\n const rawDb = withNativeModuleGuard(() =>\n completionMode\n ? new Database(dbPath, { readonly: true })\n : new Database(dbPath),\n );\n instance = trackStatusWrites(usesBunSqlite() ? wrapDatabase(rawDb) : rawDb);\n instancePath = dbPath;\n if (!completionMode) {\n instance.exec(\"PRAGMA journal_mode = WAL\");\n instance.exec(\"PRAGMA busy_timeout = 5000\");\n }\n instance.exec(\"PRAGMA foreign_keys = ON\");\n\n return instance;\n}\n\n/**\n * SQLite `data_version` on this connection. It moves when another\n * connection commits (the CLI, or the status worker), not on this\n * connection's own writes.\n */\nexport function readDbDataVersion(): number {\n try {\n const row = getDb().prepare<{ data_version: number }>(\"PRAGMA data_version\").get();\n return row?.data_version ?? 0;\n } catch {\n return -1;\n }\n}\n\nexport function closeDb(): void {\n if (instance) {\n instance.close();\n instance = null;\n instancePath = null;\n }\n}\n","import { AsyncLocalStorage } from \"node:async_hooks\";\n\n/**\n * Per-phase timing for one status computation. Enabled only when\n * HARNESSTAP_STATUS_CACHE_DEBUG=1 at process start. When it is off, every\n * helper returns after one boolean check.\n *\n * Each traced computation prints one line per phase to stderr, which the\n * desktop app appends to `ht-agent.log`:\n *\n * [status-trace] run=3 phase=dry-run.generate-files ms=41.2 n=3 self=12.0 \\\n * fs=dir:120,stat:410,read:96/388KB db=q:14,ms:0.6 files=212 \\\n * top=claude-code:30.1,cursor:9.0,codex:2.1\n *\n * `ms` is inclusive wall time summed over `n` calls, `self` excludes nested\n * phases, `fs` and `db` count work done while the phase was the innermost\n * one (fs counts come from the scan helpers, not every fs call), and `top`\n * lists the slowest items with their inclusive ms.\n */\nexport const statusTraceEnabled = process.env.HARNESSTAP_STATUS_CACHE_DEBUG === \"1\";\n\nconst TOP_ITEMS = 6;\n\ninterface PhaseStats {\n ms: number;\n childMs: number;\n calls: number;\n dirs: number;\n stats: number;\n reads: number;\n readBytes: number;\n dbQueries: number;\n dbMs: number;\n top: Array<{ item: string; ms: number }>;\n counts: Map<string, number>;\n}\n\ninterface Frame {\n phase: string;\n started: number;\n childMs: number;\n}\n\ninterface Trace {\n id: number;\n label: string;\n started: number;\n phases: Map<string, PhaseStats>;\n stack: Frame[];\n slowSql: Map<string, { n: number; ms: number }>;\n}\n\nconst storage = new AsyncLocalStorage<Trace>();\nlet traceSeq = 0;\n\nfunction stats(trace: Trace, phase: string): PhaseStats {\n let entry = trace.phases.get(phase);\n if (!entry) {\n entry = {\n ms: 0,\n childMs: 0,\n calls: 0,\n dirs: 0,\n stats: 0,\n reads: 0,\n readBytes: 0,\n dbQueries: 0,\n dbMs: 0,\n top: [],\n counts: new Map(),\n };\n trace.phases.set(phase, entry);\n }\n return entry;\n}\n\nfunction innermost(trace: Trace): PhaseStats {\n const frame = trace.stack[trace.stack.length - 1];\n return stats(trace, frame ? frame.phase : \"(other)\");\n}\n\nfunction noteTop(entry: PhaseStats, item: string, ms: number): void {\n const top = entry.top;\n const existing = top.find((row) => row.item === item);\n if (existing) {\n existing.ms += ms;\n } else if (top.length < TOP_ITEMS) {\n top.push({ item, ms });\n } else if (ms > top[top.length - 1]!.ms) {\n top[top.length - 1] = { item, ms };\n } else {\n return;\n }\n top.sort((left, right) => right.ms - left.ms);\n}\n\nfunction finishFrame(trace: Trace, frame: Frame, item: string | undefined): void {\n const elapsed = performance.now() - frame.started;\n const index = trace.stack.lastIndexOf(frame);\n if (index >= 0) trace.stack.splice(index, 1);\n const entry = stats(trace, frame.phase);\n entry.ms += elapsed;\n entry.childMs += frame.childMs;\n entry.calls += 1;\n if (item !== undefined) noteTop(entry, item, elapsed);\n const parent = trace.stack[index - 1];\n if (parent) parent.childMs += elapsed;\n}\n\n/**\n * Time `fn` as `phase`. `item` names what this call worked on (a scan root,\n * a harness, a plugin) for the slowest-items list.\n */\nexport function traceSpan<T>(phase: string, fn: () => T, item?: string): T {\n if (!statusTraceEnabled) return fn();\n const trace = storage.getStore();\n if (!trace) return fn();\n const frame: Frame = { phase, started: performance.now(), childMs: 0 };\n trace.stack.push(frame);\n let result: T;\n try {\n result = fn();\n } catch (error) {\n finishFrame(trace, frame, item);\n throw error;\n }\n if (result && typeof (result as { then?: unknown }).then === \"function\") {\n return (result as unknown as Promise<unknown>).finally(() => finishFrame(trace, frame, item)) as T;\n }\n finishFrame(trace, frame, item);\n return result;\n}\n\n/** Add `n` to a named counter on `phase` (for example plugins or files seen). */\nexport function traceCount(phase: string, counter: string, n = 1): void {\n if (!statusTraceEnabled) return;\n const trace = storage.getStore();\n if (!trace) return;\n const entry = stats(trace, phase);\n entry.counts.set(counter, (entry.counts.get(counter) ?? 0) + n);\n}\n\n/** Record a phase measured elsewhere, such as the worker message round trip. */\nexport function traceRecord(label: string, fields: Record<string, number | string>): void {\n if (!statusTraceEnabled) return;\n const parts = Object.entries(fields).map(([key, value]) =>\n `${key}=${typeof value === \"number\" ? value.toFixed(1) : value}`,\n );\n console.error(`[status-trace] ${label} ${parts.join(\" \")}`);\n}\n\n/** Note one SQL statement run while a trace is active. */\nexport function traceDb(sql: string, ms: number): void {\n const trace = storage.getStore();\n if (!trace) return;\n const entry = innermost(trace);\n entry.dbQueries += 1;\n entry.dbMs += ms;\n const key = sql.replace(/\\s+/g, \" \").trim().slice(0, 60);\n const row = trace.slowSql.get(key) ?? { n: 0, ms: 0 };\n row.n += 1;\n row.ms += ms;\n trace.slowSql.set(key, row);\n}\n\nfunction kb(bytes: number): string {\n return `${Math.round(bytes / 1024)}KB`;\n}\n\nfunction formatPhase(trace: Trace, phase: string, entry: PhaseStats): string {\n const parts = [\n `[status-trace] run=${trace.id} phase=${phase}`,\n `ms=${entry.ms.toFixed(1)}`,\n `n=${entry.calls}`,\n `self=${Math.max(0, entry.ms - entry.childMs).toFixed(1)}`,\n ];\n if (entry.dirs || entry.stats || entry.reads) {\n parts.push(\n `fs=dir:${entry.dirs},stat:${entry.stats},read:${entry.reads}/${kb(entry.readBytes)}`,\n );\n }\n if (entry.dbQueries) parts.push(`db=q:${entry.dbQueries},ms:${entry.dbMs.toFixed(1)}`);\n for (const [counter, value] of entry.counts) parts.push(`${counter}=${value}`);\n if (entry.top.length > 0) {\n parts.push(`top=${entry.top.map((row) => `${row.item}:${row.ms.toFixed(1)}`).join(\",\")}`);\n }\n return parts.join(\" \");\n}\n\nfunction report(trace: Trace): void {\n const total = performance.now() - trace.started;\n const lines = [`[status-trace] run=${trace.id} phase=total ms=${total.toFixed(1)} label=${trace.label}`];\n const ordered = [...trace.phases.entries()].sort((left, right) => right[1].ms - left[1].ms);\n for (const [phase, entry] of ordered) lines.push(formatPhase(trace, phase, entry));\n const sql = [...trace.slowSql.entries()].sort((left, right) => right[1].ms - left[1].ms).slice(0, TOP_ITEMS);\n if (sql.length > 0) {\n lines.push(\n `[status-trace] run=${trace.id} phase=db.top ${sql.map(([key, row]) => `\"${key}\":n=${row.n},ms=${row.ms.toFixed(1)}`).join(\" \")}`,\n );\n }\n console.error(lines.join(\"\\n\"));\n}\n\n/** Run one status computation under a trace and print its phase lines. */\nexport function runTracedStatus<T>(label: string, fn: () => Promise<T>): Promise<T> {\n if (!statusTraceEnabled) return fn();\n const trace: Trace = {\n id: ++traceSeq,\n label,\n started: performance.now(),\n phases: new Map(),\n stack: [],\n slowSql: new Map(),\n };\n return storage.run(trace, () => fn().finally(() => report(trace)));\n}\n\n/**\n * Count file system work against the innermost phase. Call sites are the\n * scan helpers status uses (plugin caches, manifests, signatures). A\n * monkeypatch of `node:fs` would miss bundled code in the compiled sidecar.\n */\nexport function traceFs(kind: \"dir\" | \"stat\" | \"read\", bytes = 0): void {\n if (!statusTraceEnabled) return;\n const trace = storage.getStore();\n if (!trace) return;\n const entry = innermost(trace);\n if (kind === \"dir\") entry.dirs += 1;\n else if (kind === \"stat\") entry.stats += 1;\n else {\n entry.reads += 1;\n entry.readBytes += bytes;\n }\n}\n","import { statusTraceEnabled, traceDb } from \"../services/status-trace.js\";\nimport type { SqliteDatabase, SqliteRunResult, SqliteStatement } from \"./types.js\";\n\n/**\n * Counts committed statements on this thread's connection that can change\n * status output. The status cache compares it instead of the mtime or size\n * of `harnesstap.db`, its `-wal`, or its `-shm` file, which SQLite moves on\n * plain reads and checkpoints.\n */\nlet statusWriteGeneration = 0;\n\nconst WRITE_STATEMENT = /^\\s*(?:WITH\\b[\\s\\S]*?\\b)?(INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|ALTER)\\b/i;\n\n/**\n * A new library resource is not referenced by any profile, environment, or\n * project until a link row is inserted, and that insert counts. Status does\n * not list unlinked library resources, so a plain insert into `resources`\n * does not count. `INSERT OR REPLACE` can rewrite a linked row, so it counts.\n */\nconst STATUS_IRRELEVANT_WRITE = /^\\s*INSERT\\s+INTO\\s+resources\\b/i;\n\nexport function statementAffectsStatus(sql: string): boolean {\n if (!WRITE_STATEMENT.test(sql)) return false;\n return !STATUS_IRRELEVANT_WRITE.test(sql);\n}\n\nfunction scriptAffectsStatus(sql: string): boolean {\n return sql\n .split(\";\")\n .some((part) => part.trim().length > 0 && !/^\\s*PRAGMA\\b/i.test(part) && statementAffectsStatus(part));\n}\n\nexport function bumpStatusWriteGeneration(): void {\n statusWriteGeneration += 1;\n}\n\nexport function readStatusWriteGeneration(): number {\n return statusWriteGeneration;\n}\n\n/** Wrap a connection so status-relevant writes bump the generation. */\nexport function trackStatusWrites(db: SqliteDatabase): SqliteDatabase {\n // Compiling a statement costs more than running most of ours. Reuse them.\n const statements = new Map<string, SqliteStatement<unknown>>();\n const prepareTracked = <Row>(sql: string): SqliteStatement<Row> => {\n const statement = statusTraceEnabled ? timedStatement(sql, db.prepare<Row>(sql)) : db.prepare<Row>(sql);\n if (!statementAffectsStatus(sql)) return statement;\n return {\n run: (...params: unknown[]): SqliteRunResult => {\n const result = statement.run(...params);\n if (result.changes > 0) statusWriteGeneration += 1;\n return result;\n },\n get: (...params: unknown[]) => statement.get(...params),\n all: (...params: unknown[]) => statement.all(...params),\n };\n };\n return {\n prepare<Row = unknown>(sql: string): SqliteStatement<Row> {\n const cached = statements.get(sql);\n if (cached) return cached as SqliteStatement<Row>;\n const statement = prepareTracked<Row>(sql);\n if (statements.size >= 512) statements.clear();\n statements.set(sql, statement as SqliteStatement<unknown>);\n return statement;\n },\n exec: (sql: string) => {\n // A schema change can invalidate compiled statements.\n if (/\\b(CREATE|DROP|ALTER)\\b/i.test(sql)) statements.clear();\n db.exec(sql);\n if (scriptAffectsStatus(sql)) statusWriteGeneration += 1;\n },\n transaction: <T extends (...args: never[]) => unknown>(fn: T) => db.transaction(fn),\n close: () => {\n statements.clear();\n db.close();\n },\n };\n}\n\n/** Debug only: time each query for the status trace. */\nfunction timedStatement<Row>(sql: string, statement: SqliteStatement<Row>): SqliteStatement<Row> {\n const timed = <R>(fn: () => R): R => {\n const started = performance.now();\n try {\n return fn();\n } finally {\n traceDb(sql, performance.now() - started);\n }\n };\n return {\n run: (...params: unknown[]) => timed(() => statement.run(...params)),\n get: (...params: unknown[]) => timed(() => statement.get(...params)),\n all: (...params: unknown[]) => timed(() => statement.all(...params)),\n };\n}\n","export const DEFAULT_TIMEOUT_MS = 30_000;\nconst DEFAULT_RETRIES = 2;\n\nexport const CATALOG_LIST_TIMEOUT_MESSAGE =\n \"Catalog request timed out (30s). Try again, or list local plugins without --remote.\";\n\nexport async function fetchWithTimeout(\n input: string | URL,\n init?: RequestInit & { timeoutMs?: number; retries?: number },\n): Promise<Response> {\n const timeoutMs = init?.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const retries = init?.retries ?? DEFAULT_RETRIES;\n let lastError: unknown;\n\n for (let attempt = 0; attempt <= retries; attempt += 1) {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n try {\n const { timeoutMs: _t, retries: _r, ...fetchInit } = init ?? {};\n return await fetch(input, { ...fetchInit, signal: controller.signal });\n } catch (error) {\n lastError = error;\n if (attempt === retries) break;\n await new Promise((r) => setTimeout(r, 250 * (attempt + 1)));\n } finally {\n clearTimeout(timer);\n }\n }\n\n throw new Error(\n `Request timed out after ${timeoutMs}ms (${retries + 1} attempts): ${String(input)}`,\n { cause: lastError },\n );\n}\n\nexport function isRequestTimeoutError(error: unknown): boolean {\n return error instanceof Error && error.message.startsWith(\"Request timed out after\");\n}\n\nexport function formatCatalogRequestError(error: unknown): string {\n if (isRequestTimeoutError(error)) {\n return CATALOG_LIST_TIMEOUT_MESSAGE;\n }\n return error instanceof Error ? error.message : String(error);\n}\n","export function mapGitStderr(stderr: string, url?: string): string {\n if (stderr.startsWith(\"Couldn't reach\")) {\n return stderr.endsWith(\".\") ? stderr : `${stderr}.`;\n }\n if (url) {\n return `Couldn't reach ${url}.`;\n }\n return \"Couldn't reach that git repository.\";\n}\n\nexport function gitFailureHint(): string {\n return \"Check the URL, or sign in with ht github login if it's private.\";\n}\n"],"mappings":";;;;;;;AAKO,SAAS,YAAY,OAAe,MAAc,SAAS,GAAG,IAAI,KAAa;AACpF,SAAO,GAAG,KAAK,IAAI,UAAU,IAAI,OAAO,MAAM;AAChD;AAEO,SAAS,WAAW,OAAe,MAAc,SAAS,GAAG,IAAI,KAAa;AACnF,SAAO,UAAU,IAAI,OAAO;AAC9B;;;ACXA,SAAS,oBAAoB;;;ACA7B;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,gBAAkB;AAAA,EAClB,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,KAAO;AAAA,IACL,YAAc;AAAA,IACd,IAAM;AAAA,EACR;AAAA,EACA,SAAW;AAAA,IACT,OAAS;AAAA,IACT,sBAAsB;AAAA,IACtB,uBAAuB;AAAA,IACvB,yBAAyB;AAAA,IACzB,iBAAiB;AAAA,IACjB,0BAA0B;AAAA,IAC1B,mBAAmB;AAAA,IACnB,2BAA2B;AAAA,IAC3B,yBAAyB;AAAA,IACzB,iBAAiB;AAAA,IACjB,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,mBAAmB;AAAA,IACnB,qBAAqB;AAAA,IACrB,eAAe;AAAA,IACf,sBAAsB;AAAA,IACtB,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,IACjB,KAAO;AAAA,IACP,OAAS;AAAA,IACT,cAAc;AAAA,IACd,MAAQ;AAAA,IACR,QAAU;AAAA,IACV,MAAQ;AAAA,IACR,YAAY;AAAA,IACZ,aAAa;AAAA,IACb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ACjE,MAAI,OAAO,WAAW,gBAAgB,GAAG;AACvC,WAAO,OAAO,SAAS,GAAG,IAAI,SAAS,GAAG,MAAM;AAAA,EAClD;AACA,MAAI,KAAK;AACP,WAAO,kBAAkB,GAAG;AAAA,EAC9B;AACA,SAAO;AACT;AAEO,SAAS,iBAAyB;AACvC,SAAO;AACT;","names":["require"]}
@@ -1,84 +0,0 @@
1
- // src/ui/list-viewport.ts
2
- var DEFAULT_SECTION_TABLE_OVERHEAD_LINES = 5;
3
- var BORDERED_TABLE_LINES_PER_ROW = 2;
4
- var VIEWPORT_CHROME_LINES = {
5
- resourceList: 5,
6
- catalogBrowse: 8,
7
- catalogSearch: 10,
8
- pluginEdit: 7,
9
- environmentEdit: 5,
10
- environmentList: 5,
11
- pluginListBrowse: 6
12
- };
13
- function computeRemoteListFetchLimit(terminalRowCount, chromeLines, opts) {
14
- const visible = computeMaxVisibleTableRows(terminalRowCount, chromeLines);
15
- const min = opts?.min ?? 10;
16
- if (opts?.search) {
17
- return Math.max(min, 25, visible + 5);
18
- }
19
- return Math.max(min, visible + 5);
20
- }
21
- function computeMaxVisibleRows(terminalRowCount, chromeLines = VIEWPORT_CHROME_LINES.resourceList, sectionOverhead = DEFAULT_SECTION_TABLE_OVERHEAD_LINES) {
22
- const budget = terminalRowCount - chromeLines - sectionOverhead;
23
- return Math.max(3, budget - 1);
24
- }
25
- function computeMaxVisibleTableRows(terminalRowCount, chromeLines = VIEWPORT_CHROME_LINES.resourceList, opts) {
26
- const sectionOverhead = opts?.sectionOverhead ?? DEFAULT_SECTION_TABLE_OVERHEAD_LINES;
27
- const linesPerRow = (opts?.linesPerRow ?? BORDERED_TABLE_LINES_PER_ROW) + (opts?.wrapReservePerRow ?? 1);
28
- const bodyBudget = terminalRowCount - chromeLines - sectionOverhead;
29
- if (bodyBudget <= linesPerRow) {
30
- return 2;
31
- }
32
- return Math.max(2, Math.floor(bodyBudget / linesPerRow) - 1);
33
- }
34
- function resolveSectionViewport(sectionLength, activeIndex, maxVisibleRows) {
35
- if (sectionLength <= maxVisibleRows) {
36
- return { start: 0, end: sectionLength };
37
- }
38
- const middle = Math.floor(maxVisibleRows / 2);
39
- let start = activeIndex - middle;
40
- if (start < 0) start = 0;
41
- if (start + maxVisibleRows > sectionLength) {
42
- start = sectionLength - maxVisibleRows;
43
- }
44
- return { start, end: start + maxVisibleRows };
45
- }
46
- var HINT_SEPARATOR = " \xB7 ";
47
- var HINT_INDENT = " ";
48
- function renderFoldedHintLine(segments, maxWidth) {
49
- if (segments.length === 0) {
50
- return "";
51
- }
52
- const normalizedWidth = Math.max(10, maxWidth);
53
- const lines = [];
54
- let current = HINT_INDENT;
55
- for (const segment of segments) {
56
- const piece = segment.length > normalizedWidth - HINT_INDENT.length ? `${segment.slice(0, Math.max(0, normalizedWidth - HINT_INDENT.length - 3))}...` : segment;
57
- const candidate = current === HINT_INDENT ? `${current}${piece}` : `${current}${HINT_SEPARATOR}${piece}`;
58
- if (candidate.length <= normalizedWidth) {
59
- current = candidate;
60
- continue;
61
- }
62
- if (current !== HINT_INDENT) {
63
- lines.push(current);
64
- current = `${HINT_INDENT}${piece}`;
65
- continue;
66
- }
67
- lines.push(candidate);
68
- current = HINT_INDENT;
69
- }
70
- if (current !== HINT_INDENT) {
71
- lines.push(current);
72
- }
73
- return lines.join("\n");
74
- }
75
-
76
- export {
77
- VIEWPORT_CHROME_LINES,
78
- computeRemoteListFetchLimit,
79
- computeMaxVisibleRows,
80
- computeMaxVisibleTableRows,
81
- resolveSectionViewport,
82
- renderFoldedHintLine
83
- };
84
- //# sourceMappingURL=chunk-XGTTOO4R.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ui/list-viewport.ts"],"sourcesContent":["export type SectionViewport = {\n start: number;\n end: number;\n};\n\nexport const DEFAULT_SECTION_TABLE_OVERHEAD_LINES = 5;\n\n/** cli-table3 bordered rows use a horizontal rule plus content (~2 lines each). */\nexport const BORDERED_TABLE_LINES_PER_ROW = 2;\n\nexport const VIEWPORT_CHROME_LINES = {\n resourceList: 5,\n catalogBrowse: 8,\n catalogSearch: 10,\n pluginEdit: 7,\n environmentEdit: 5,\n environmentList: 5,\n pluginListBrowse: 6,\n} as const;\n\nexport function computeRemoteListFetchLimit(\n terminalRowCount: number,\n chromeLines: number,\n opts?: { min?: number; search?: boolean },\n): number {\n const visible = computeMaxVisibleTableRows(terminalRowCount, chromeLines);\n const min = opts?.min ?? 10;\n if (opts?.search) {\n return Math.max(min, 25, visible + 5);\n }\n return Math.max(min, visible + 5);\n}\n\nexport function computeMaxVisibleRows(\n terminalRowCount: number,\n chromeLines: number = VIEWPORT_CHROME_LINES.resourceList,\n sectionOverhead: number = DEFAULT_SECTION_TABLE_OVERHEAD_LINES,\n): number {\n const budget = terminalRowCount - chromeLines - sectionOverhead;\n return Math.max(3, budget - 1);\n}\n\nexport function computeMaxVisibleTableRows(\n terminalRowCount: number,\n chromeLines: number = VIEWPORT_CHROME_LINES.resourceList,\n opts?: {\n sectionOverhead?: number;\n linesPerRow?: number;\n wrapReservePerRow?: number;\n },\n): number {\n const sectionOverhead = opts?.sectionOverhead ?? DEFAULT_SECTION_TABLE_OVERHEAD_LINES;\n const linesPerRow =\n (opts?.linesPerRow ?? BORDERED_TABLE_LINES_PER_ROW)\n + (opts?.wrapReservePerRow ?? 1);\n const bodyBudget = terminalRowCount - chromeLines - sectionOverhead;\n if (bodyBudget <= linesPerRow) {\n return 2;\n }\n return Math.max(2, Math.floor(bodyBudget / linesPerRow) - 1);\n}\n\nexport function resolveSectionViewport(\n sectionLength: number,\n activeIndex: number,\n maxVisibleRows: number,\n): SectionViewport {\n if (sectionLength <= maxVisibleRows) {\n return { start: 0, end: sectionLength };\n }\n const middle = Math.floor(maxVisibleRows / 2);\n let start = activeIndex - middle;\n if (start < 0) start = 0;\n if (start + maxVisibleRows > sectionLength) {\n start = sectionLength - maxVisibleRows;\n }\n return { start, end: start + maxVisibleRows };\n}\n\nexport function renderFlatOverflowHints(\n viewport: SectionViewport,\n totalLength: number,\n): string[] {\n const hints: string[] = [];\n if (viewport.start > 0) {\n hints.push(` ↑ ${viewport.start} above`);\n }\n if (viewport.end < totalLength) {\n hints.push(` ↓ ${totalLength - viewport.end} more`);\n }\n return hints;\n}\n\nconst HINT_SEPARATOR = \" · \";\nconst HINT_INDENT = \" \";\n\nexport function renderFoldedHintLine(segments: string[], maxWidth: number): string {\n if (segments.length === 0) {\n return \"\";\n }\n\n const normalizedWidth = Math.max(10, maxWidth);\n const lines: string[] = [];\n let current = HINT_INDENT;\n\n for (const segment of segments) {\n const piece =\n segment.length > normalizedWidth - HINT_INDENT.length\n ? `${segment.slice(0, Math.max(0, normalizedWidth - HINT_INDENT.length - 3))}...`\n : segment;\n\n const candidate =\n current === HINT_INDENT\n ? `${current}${piece}`\n : `${current}${HINT_SEPARATOR}${piece}`;\n\n if (candidate.length <= normalizedWidth) {\n current = candidate;\n continue;\n }\n\n if (current !== HINT_INDENT) {\n lines.push(current);\n current = `${HINT_INDENT}${piece}`;\n continue;\n }\n\n lines.push(candidate);\n current = HINT_INDENT;\n }\n\n if (current !== HINT_INDENT) {\n lines.push(current);\n }\n\n return lines.join(\"\\n\");\n}\n"],"mappings":";AAKO,IAAM,uCAAuC;AAG7C,IAAM,+BAA+B;AAErC,IAAM,wBAAwB;AAAA,EACnC,cAAc;AAAA,EACd,eAAe;AAAA,EACf,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,kBAAkB;AACpB;AAEO,SAAS,4BACd,kBACA,aACA,MACQ;AACR,QAAM,UAAU,2BAA2B,kBAAkB,WAAW;AACxE,QAAM,MAAM,MAAM,OAAO;AACzB,MAAI,MAAM,QAAQ;AAChB,WAAO,KAAK,IAAI,KAAK,IAAI,UAAU,CAAC;AAAA,EACtC;AACA,SAAO,KAAK,IAAI,KAAK,UAAU,CAAC;AAClC;AAEO,SAAS,sBACd,kBACA,cAAsB,sBAAsB,cAC5C,kBAA0B,s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AACvC,gBAAU;AACV;AAAA,IACF;AAEA,QAAI,YAAY,aAAa;AAC3B,YAAM,KAAK,OAAO;AAClB,gBAAU,GAAG,WAAW,GAAG,KAAK;AAChC;AAAA,IACF;AAEA,UAAM,KAAK,SAAS;AACpB,cAAU;AAAA,EACZ;AAEA,MAAI,YAAY,aAAa;AAC3B,UAAM,KAAK,OAAO;AAAA,EACpB;AAEA,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/copy/scope.ts","../src/cli/commands/profile-live-files.ts","../src/services/profile-file-diff.ts","../src/services/profile-apply-preview.ts","../src/services/apply-preview-inherited.ts","../src/services/profile-remove-resource.ts","../src/services/profile-restore-file.ts","../src/cli/handlers/profile-live-files.ts","../src/cli/commands/profile-preview.ts","../src/cli/commands/parity-register.ts"],"sourcesContent":["import { getPlatform } from \"../platforms/registry.js\";\nimport type { HarnessScope } from \"../services/harness-scope.js\";\n\n/** DS-1 scope copy. ASCII punctuation only. */\n\nexport const SCOPE_COPY = {\n appliesToAll: \"Applies to all your harnesses\",\n notSetUp: \"Not set up for any harness yet\",\n detectHarnesses: \"Detect harnesses\",\n foundInSettingsSuffix: \"Found in its settings.\",\n useOn: \"Use on\",\n selectAll: \"Select all\",\n none: \"None\",\n emptyHint: \"Pick at least one harness\",\n linkedTooltip: \"These read the same folder, so they share one setting\",\n allTooltip: \"On all harnesses. Pick which ones\",\n orphanedTooltip: \"Its harnesses are gone. Pick new ones\",\n alsoUseOnPrefix: \"Also use on\",\n notNow: \"Not now\",\n willWrite: \"Will write\",\n upToDate: \"Up to date\",\n notInProfile: \"Not in profile\",\n willRemove: \"Will remove\",\n keptYouChanged: \"Kept. You changed it.\",\n keptNotMadeByHarnessTap: \"Kept. Not made by HarnessTap.\",\n} as const;\n\nexport function harnessDisplayName(id: string): string {\n return getPlatform(id)?.name ?? id;\n}\n\n/** Join display names: \"A and B\" / \"A, B and C\". */\nexport function formatHarnessList(names: readonly string[]): string {\n if (names.length === 0) {\n return \"\";\n }\n if (names.length === 1) {\n return names[0] ?? \"\";\n }\n if (names.length === 2) {\n return `${names[0]} and ${names[1]}`;\n }\n return `${names.slice(0, -1).join(\", \")} and ${names[names.length - 1]}`;\n}\n\nexport function formatHarnessIds(ids: readonly string[]): string {\n return formatHarnessList(ids.map(harnessDisplayName));\n}\n\n/**\n * Subset scope line: \"Only on Claude Code and Codex\",\n * or \"Only on Claude Code, Codex, Cursor and {n} more\" for 4+.\n */\nexport function subsetScopeLine(ids: readonly string[]): string {\n if (ids.length === 0) {\n return SCOPE_COPY.notSetUp;\n }\n if (ids.length <= 3) {\n return `Only on ${formatHarnessIds(ids)}`;\n }\n const visible = ids.slice(0, 3).map(harnessDisplayName);\n const extra = ids.length - visible.length;\n return `Only on ${visible.join(\", \")} and ${extra} more`;\n}\n\nexport function scopeLine(\n scope: HarnessScope,\n options?: { originPortable?: boolean },\n): string {\n if (scope.kind === \"all\") {\n return SCOPE_COPY.appliesToAll;\n }\n const line = subsetScopeLine(scope.harnesses);\n if (options?.originPortable && scope.harnesses.length === 1) {\n return `${line}. ${SCOPE_COPY.foundInSettingsSuffix}`;\n }\n return line;\n}\n\nexport function alsoUseOnLabel(ids: readonly string[]): string {\n if (ids.length <= 3) {\n return `${SCOPE_COPY.alsoUseOnPrefix} ${formatHarnessIds(ids)}`;\n }\n const visible = ids.slice(0, 3).map(harnessDisplayName);\n const extra = ids.length - visible.length;\n return `${SCOPE_COPY.alsoUseOnPrefix} ${visible.join(\", \")} and ${extra} more`;\n}\n\nexport function portableMcpTooltip(ids: readonly string[]): string {\n return `This server works anywhere. Add it to ${formatHarnessIds(ids)} too.`;\n}\n\nexport function nowOnToast(ids: readonly string[]): string {\n return `Now on ${formatHarnessIds(ids)}`;\n}\n\nexport function skippedNotUsedOnFooter(count: number, harnessId: string): string {\n return `${count} skipped. Not used on ${harnessDisplayName(harnessId)}.`;\n}\n\nexport function portableScopeTip(input: {\n resourceName: string;\n targetIds: readonly string[];\n command: string;\n}): string {\n return `Tip: \"${input.resourceName}\" also works on ${formatHarnessIds(input.targetIds)}. Run ${input.command}.`;\n}\n","import { Option, type Command } from \"commander\";\nimport { isPromptCancellationError } from \"../../services/wizards/shared.js\";\nimport { CliUsageError } from \"../../services/cli-errors.js\";\nimport { COMMAND_HELP_REGISTRY } from \"../../services/cli-help-registry.js\";\nimport { ui } from \"../../ui/index.js\";\nimport { renderCliError } from \"../runtime.js\";\nimport { fail } from \"../shared.js\";\nimport {\n handleProfileAddAllResourcesCommand,\n handleProfileAddResourceCommand,\n handleProfileCommitResourceCommand,\n handleProfileFileDiffCommand,\n handleProfileRemoveResourceCommand,\n handleProfileRestoreFileCommand,\n} from \"../handlers/profile-live-files.js\";\n\nfunction addFormatInteractiveOptions(cmd: Command): Command {\n return cmd\n .option(\"--format <mode>\", \"Output format: human or json\", \"human\")\n .option(\"--no-interactive\", \"Disable interactive prompts\")\n .option(\"--interactive\", \"Enable interactive prompts\");\n}\n\nfunction addLiveScopeOptions(cmd: Command): Command {\n return addFormatInteractiveOptions(cmd)\n .addOption(\n new Option(\"--scope <home|project>\", \"home or project\")\n .choices([\"home\", \"project\"])\n .makeOptionMandatory(),\n )\n .option(\"--project <path>\", \"Project path (required when --scope project)\")\n .option(\"--harness <slug>\", \"Harness slug\");\n}\n\nasync function runLiveAction(work: () => Promise<void>): Promise<void> {\n try {\n await work();\n } catch (err) {\n if (isPromptCancellationError(err)) {\n ui.info(\"Operation cancelled.\");\n process.exitCode = 0;\n return;\n }\n process.exitCode = 1;\n if (err instanceof CliUsageError) {\n renderCliError(err);\n return;\n }\n fail(err instanceof Error ? err.message : String(err));\n }\n}\n\nfunction assignLiveFileHelp(): void {\n COMMAND_HELP_REGISTRY[\"profile.add-resource\"] = {\n description: \"Adopt one untracked on-disk resource into the profile library\",\n examples: [\n \"profile add-resource work --selector skill:foo --scope home\",\n \"profile add-resource work --selector skill:foo --scope project --project . --format json\",\n ],\n };\n COMMAND_HELP_REGISTRY[\"profile.add-all-resources\"] = {\n description: \"Adopt every untracked material resource in the scope\",\n examples: [\n \"profile add-all-resources work --scope home\",\n \"profile add-all-resources work --scope project --project . --format json\",\n ],\n };\n COMMAND_HELP_REGISTRY[\"profile.commit-resource\"] = {\n description: \"Snapshot live disk into the profile library\",\n examples: [\n \"profile commit-resource work --path .claude/skills/foo/SKILL.md --scope home\",\n \"profile commit-resource work --selector skill:foo --scope home --format json\",\n ],\n };\n COMMAND_HELP_REGISTRY[\"profile.remove-resource\"] = {\n description: \"Detach a material resource from the profile stack\",\n examples: [\n \"profile remove-resource work --selector skill:foo -y\",\n \"profile remove-resource work --selector skill:foo --format json -y\",\n ],\n };\n COMMAND_HELP_REGISTRY[\"profile.restore-file\"] = {\n description: \"Overwrite the live managed file with the profile snapshot\",\n examples: [\n \"profile restore-file work --path .claude/skills/foo/SKILL.md --scope home -y\",\n \"profile restore-file work --path .claude/skills/foo/SKILL.md --scope home --format json -y\",\n ],\n };\n COMMAND_HELP_REGISTRY[\"profile.file-diff\"] = {\n description: \"Show live content vs after-apply (profile) as a unified diff\",\n examples: [\n \"profile file-diff work --path .claude/skills/foo/SKILL.md --scope home\",\n \"profile file-diff work --path .claude/skills/foo/SKILL.md --scope home --format json\",\n ],\n };\n}\n\nexport function registerProfileLiveFileCommands(profileCmd: Command): void {\n assignLiveFileHelp();\n\n addLiveScopeOptions(\n profileCmd\n .command(\"add-resource\")\n .argument(\"<name>\", \"Profile plugin name or selector\")\n .requiredOption(\"--selector <type:name>\", \"Resource selector\")\n .description(\"Adopt one untracked on-disk resource into the profile library\"),\n ).action(async (name: string, opts) => {\n await runLiveAction(() => handleProfileAddResourceCommand(name, opts));\n });\n\n addLiveScopeOptions(\n profileCmd\n .command(\"add-all-resources\")\n .argument(\"<name>\", \"Profile plugin name or selector\")\n .description(\"Adopt every untracked material resource in the scope\"),\n ).action(async (name: string, opts) => {\n await runLiveAction(() => handleProfileAddAllResourcesCommand(name, opts));\n });\n\n addLiveScopeOptions(\n profileCmd\n .command(\"commit-resource\")\n .argument(\"<name>\", \"Profile plugin name or selector\")\n .option(\"--path <path>\", \"Managed relative path\")\n .option(\"--selector <type:name>\", \"Resource selector\")\n .description(\"Snapshot live disk into the profile library\"),\n ).action(async (name: string, opts) => {\n await runLiveAction(() => handleProfileCommitResourceCommand(name, opts));\n });\n\n addFormatInteractiveOptions(\n profileCmd\n .command(\"remove-resource\")\n .argument(\"<name>\", \"Profile plugin name or selector\")\n .requiredOption(\"--selector <type:name>\", \"Resource selector\")\n .option(\"--plugin-id <id>\", \"Plugin id in the profile stack\")\n .option(\"-y, --yes\", \"Skip the confirmation prompt\")\n .description(\"Detach a material resource from the profile stack\"),\n ).action(async (name: string, opts) => {\n await runLiveAction(() => handleProfileRemoveResourceCommand(name, opts));\n });\n\n addLiveScopeOptions(\n profileCmd\n .command(\"restore-file\")\n .argument(\"<name>\", \"Profile plugin name or selector\")\n .requiredOption(\"--path <path>\", \"Managed relative path\")\n .option(\"-y, --yes\", \"Skip the confirmation prompt\")\n .description(\"Overwrite the live managed file with the profile snapshot\"),\n ).action(async (name: string, opts) => {\n await runLiveAction(() => handleProfileRestoreFileCommand(name, opts));\n });\n\n addLiveScopeOptions(\n profileCmd\n .command(\"file-diff\")\n .argument(\"<name>\", \"Profile plugin name or selector\")\n .requiredOption(\"--path <path>\", \"Managed relative path\")\n .description(\"Show live content vs after-apply (profile) as a unified diff\"),\n ).action(async (name: string, opts) => {\n await runLiveAction(() => handleProfileFileDiffCommand(name, opts));\n });\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { isAbsolute, join } from \"node:path\";\nimport {\n collectExpectedManagedFiles,\n type ProfileApplyPreviewScope,\n} from \"./profile-apply-preview.js\";\nimport {\n isMcpConfigManagedPath,\n resourceKeyFromManagedPath,\n} from \"./profile-commit-resource.js\";\nimport { scopeHostConfigToResource } from \"./host-config-resource-detail.js\";\nimport { scopeMcpConfigToServer } from \"./mcp-resource-detail.js\";\nimport { isMergeableHostConfigPath } from \"./merged-host-config.js\";\nimport { normalizeManagedPath } from \"./profile-untracked-resources.js\";\n\nexport interface ManagedFileDiff {\n path: string;\n absolute_path: string;\n /** Expected content from the profile (last applied / would-apply snapshot). */\n expected: string;\n /** Current on-disk content, or null if the file is missing. */\n current: string | null;\n}\n\nconst ONE_TO_ONE_DIFF_TYPES = new Set([\"skill\", \"agent\", \"command\", \"rule\", \"instruction\"]);\nconst HOST_CONFIG_DIFF_TYPES = new Set([\"permission\", \"hook\", \"env_var\"]);\n\nfunction readLiveFile(absolutePath: string): string | null {\n if (!existsSync(absolutePath)) {\n return null;\n }\n try {\n return readFileSync(absolutePath, \"utf-8\");\n } catch {\n return null;\n }\n}\n\nfunction namesEqualIgnoreCase(left: string, right: string): boolean {\n return left.toLowerCase() === right.toLowerCase();\n}\n\nfunction pathsReferToSameManagedFile(\n left: string,\n right: string,\n rootPath: string,\n): boolean {\n const a = normalizeManagedPath(left, rootPath);\n const b = normalizeManagedPath(right, rootPath);\n if (a === b) {\n return true;\n }\n return a.endsWith(`/${b}`) || b.endsWith(`/${a}`);\n}\n\nfunction resolveLiveAbsolute(path: string, rootPath: string): string {\n const normalized = normalizeManagedPath(path, rootPath);\n if (isAbsolute(normalized)) {\n return normalized;\n }\n return join(rootPath, normalized);\n}\n\nfunction resourceMatchesFile(\n resource: { type: string; name: string },\n filePath: string,\n rootPath: string,\n): boolean {\n const mapped = resourceKeyFromManagedPath(filePath, rootPath);\n return (\n mapped !== null\n && mapped.type === resource.type\n && namesEqualIgnoreCase(mapped.name, resource.name)\n );\n}\n\nfunction findExpectedManagedFile(input: {\n expectedFiles: Array<{ path: string; content: string }>;\n requestedPath: string;\n rootPath: string;\n resource?: { type: string; name: string };\n}): { path: string; content: string } | undefined {\n const byPath = input.expectedFiles.find((file) =>\n pathsReferToSameManagedFile(file.path, input.requestedPath, input.rootPath),\n );\n const resource = input.resource;\n if (!resource?.type || !resource.name.trim()) {\n return byPath;\n }\n\n const byIdentity = input.expectedFiles.find((file) =>\n resourceMatchesFile(resource, file.path, input.rootPath),\n );\n\n if (ONE_TO_ONE_DIFF_TYPES.has(resource.type)) {\n if (byPath && resourceMatchesFile(resource, byPath.path, input.rootPath)) {\n return byPath;\n }\n return byIdentity ?? byPath;\n }\n\n if (resource.type === \"mcp_server\") {\n if (byPath && isMcpConfigManagedPath(byPath.path, input.rootPath)) {\n return byPath;\n }\n return (\n input.expectedFiles.find((file) =>\n isMcpConfigManagedPath(file.path, input.rootPath),\n )\n ?? byPath\n );\n }\n\n if (HOST_CONFIG_DIFF_TYPES.has(resource.type)) {\n if (byPath && isMergeableHostConfigPath(byPath.path)) {\n return byPath;\n }\n return (\n input.expectedFiles.find((file) => isMergeableHostConfigPath(file.path))\n ?? byPath\n );\n }\n\n return byIdentity ?? byPath;\n}\n\nfunction resolveCurrentAbsolute(input: {\n requestedPath: string;\n matchPath: string;\n rootPath: string;\n resource?: { type: string; name: string };\n}): string {\n const matchAbs = join(\n input.rootPath,\n normalizeManagedPath(input.matchPath, input.rootPath),\n );\n const requestedAbs = resolveLiveAbsolute(input.requestedPath, input.rootPath);\n if (input.resource && ONE_TO_ONE_DIFF_TYPES.has(input.resource.type)) {\n return matchAbs;\n }\n if (existsSync(requestedAbs)) {\n return requestedAbs;\n }\n return matchAbs;\n}\n\nfunction applyResourceScope(input: {\n relativePath: string;\n rootPath: string;\n expected: string;\n current: string | null;\n resource?: { type: string; name: string };\n}): { expected: string; current: string | null } {\n const resourceName = input.resource?.name.trim() ?? \"\";\n const resourceType = input.resource?.type ?? \"\";\n if (!resourceName || !resourceType) {\n return { expected: input.expected, current: input.current };\n }\n\n if (\n resourceType === \"mcp_server\"\n && isMcpConfigManagedPath(input.relativePath, input.rootPath)\n ) {\n return {\n expected: scopeMcpConfigToServer(input.expected, resourceName) ?? input.expected,\n current: scopeMcpConfigToServer(input.current, resourceName),\n };\n }\n\n if (\n HOST_CONFIG_DIFF_TYPES.has(resourceType)\n && isMergeableHostConfigPath(input.relativePath)\n ) {\n const resource = { type: resourceType, name: resourceName };\n return {\n expected: scopeHostConfigToResource(input.expected, resource) ?? input.expected,\n current: scopeHostConfigToResource(input.current, resource),\n };\n }\n\n return { expected: input.expected, current: input.current };\n}\n\nexport async function getManagedFileDiff(input: {\n profileSelector: string;\n path: string;\n scope: ProfileApplyPreviewScope;\n projectPath?: string;\n harness?: string;\n resource?: { type: string; name: string };\n}): Promise<ManagedFileDiff> {\n const profile = input.profileSelector.trim();\n const requestedPath = input.path.trim();\n\n const collected = await collectExpectedManagedFiles({\n profile,\n scope: input.scope,\n ...(input.projectPath ? { projectPath: input.projectPath } : {}),\n ...(input.harness ? { harness: input.harness } : {}),\n });\n\n if (collected.warning) {\n throw new Error(collected.warning);\n }\n\n const match = findExpectedManagedFile({\n expectedFiles: collected.expectedFiles,\n requestedPath,\n rootPath: collected.rootPath,\n ...(input.resource ? { resource: input.resource } : {}),\n });\n\n if (!match) {\n const liveAbsolute = resolveLiveAbsolute(requestedPath, collected.rootPath);\n if (\n input.resource?.type === \"agent\"\n && readLiveFile(liveAbsolute) !== null\n ) {\n const relativePath = normalizeManagedPath(liveAbsolute, collected.rootPath);\n const live = readLiveFile(liveAbsolute) ?? \"\";\n return {\n path: relativePath,\n absolute_path: liveAbsolute,\n expected: live,\n current: live,\n };\n }\n throw new Error(`Path is not a managed file for this profile: ${input.path}`);\n }\n\n const relativePath = normalizeManagedPath(match.path, collected.rootPath);\n const absolutePath = resolveCurrentAbsolute({\n requestedPath,\n matchPath: match.path,\n rootPath: collected.rootPath,\n ...(input.resource ? { resource: input.resource } : {}),\n });\n const scoped = applyResourceScope({\n relativePath,\n rootPath: collected.rootPath,\n expected: match.content,\n current: readLiveFile(absolutePath),\n ...(input.resource ? { resource: input.resource } : {}),\n });\n\n return {\n path: relativePath,\n absolute_path: absolutePath,\n expected: scoped.expected,\n current: scoped.current,\n };\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { isEmptyBuiltinProfile, isProfilePlugin } from \"../constants/profile.js\";\nimport { resolvePluginSelector } from \"../models/plugin-model.js\";\nimport { getProjectByLocalPath, getProjectByOrigin } from \"../models/project.js\";\nimport { getLatestSnapshot } from \"../models/snapshot.js\";\nimport type { McpServerMetadata, Resource } from \"../types.js\";\nimport { resolveHomeRoot } from \"../utils/home-root.js\";\nimport { getActiveProfileName } from \"./active-profile.js\";\nimport { generateFiles } from \"./applier.js\";\nimport {\n collectOwnedPreviewResources,\n expectedFileMatchesLiveForPreview,\n omitInheritedPluginFileChanges,\n} from \"./apply-preview-inherited.js\";\nimport {\n isTransparentCrossHarnessGap,\n resourceScopesForPlugins,\n} from \"./cross-harness-gap.js\";\nimport {\n buildHostManagedStatus,\n type HostManagedStatus,\n profileSkillNameMap,\n} from \"./cursor-host-managed-skills.js\";\nimport { fileContentsEquivalentForDrift } from \"./file-contents-drift.js\";\nimport { isNativeAgentPluginCachePath } from \"./native-agent-plugins.js\";\nimport { getGitOrigin, normalizeGitUrl } from \"./git.js\";\nimport {\n buildHarnessLiveStatusMap,\n declaredMcpFromExpectedFiles,\n type HarnessLiveStatus,\n} from \"./global-profile-status-panel.js\";\nimport type { HarnessScope } from \"./harness-scope.js\";\nimport {\n isMergeableHostConfigPath,\n} from \"./merged-host-config.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 type ProfileContentsResource,\n} from \"./profile-contents.js\";\nimport { detectNotStagedProfileResources } from \"./profile-untracked-resources.js\";\nimport type { DriftFileChange } from \"./project-drift.js\";\nimport {\n type RecoveryAction,\n SingletonConflictError,\n UnsatisfiableConstraintError,\n} from \"./resolve/types.js\";\nimport {\n emptyPlannedRemovals,\n groupPlannedRemovals,\n type PlannedRemovalGroup,\n type PlannedRemovals,\n planSafeFileRemovals,\n} from \"./safe-file-removal.js\";\nimport { detectPlatforms } from \"./scanner.js\";\nimport { withAffectedResources } from \"./scoped-file-content-delta.js\";\n\nexport type ProfileApplyPreviewScope = \"home\" | \"project\";\n\nexport interface ProfileApplyPreviewRequest {\n profile: string;\n scope: ProfileApplyPreviewScope;\n projectPath?: string;\n harness?: string;\n}\n\nexport interface ProfileApplyPreview {\n profile: string;\n scope: ProfileApplyPreviewScope;\n contents: ProfileContents | null;\n harnesses?: Record<string, HarnessLiveStatus>;\n /** Material resources on disk not attached to the target profile (not staged). */\n not_staged: ProfileContentsResource[];\n /** @deprecated Use not_staged. */\n untracked_resources: ProfileContentsResource[];\n files: {\n expected_count: number;\n /** File changes for tracked (profile-managed) paths only. */\n changes: DriftFileChange[];\n root_path: string;\n /** Resource identities owned by the target apply set (including inherited plugin material). */\n owned_resources?: Array<{ type: string; name: string }>;\n };\n /** Planned whole-file removals grouped by ownership (DT-3). */\n removals: PlannedRemovals;\n relative_to_active: boolean;\n warning?: string;\n recovery_actions?: RecoveryAction[];\n /** App-managed inventory for home scope; never applied or persisted. */\n host_managed?: HostManagedStatus;\n}\n\nfunction warningFromError(error: unknown): {\n warning: string;\n recovery_actions?: RecoveryAction[];\n} {\n if (error instanceof UnsatisfiableConstraintError) {\n return {\n warning: error.message,\n recovery_actions: error.actions,\n };\n }\n if (error instanceof SingletonConflictError) {\n return {\n warning: error.message,\n recovery_actions: error.actions,\n };\n }\n return {\n warning: error instanceof Error ? error.message : String(error),\n };\n}\n\nfunction notProfileWarning(pluginName: string): {\n warning: string;\n recovery_actions: RecoveryAction[];\n} {\n return {\n warning: `plugin \"${pluginName}\" is not tagged as a profile`,\n recovery_actions: [\n {\n id: \"tag-as-profile\",\n label: `Tag ${pluginName} as a profile`,\n pluginName,\n },\n ],\n };\n}\n\nfunction spreadWarningFields(input: {\n warning?: string;\n recovery_actions?: RecoveryAction[];\n}): { warning?: string; recovery_actions?: RecoveryAction[] } {\n return {\n ...(input.warning ? { warning: input.warning } : {}),\n ...(input.recovery_actions ? { recovery_actions: input.recovery_actions } : {}),\n };\n}\n\nfunction readRootFile(rootPath: string, relativePath: string): string | null {\n const fullPath = join(rootPath, 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 declaredMcpFromExpectedApply(expectedApply: ApplyProfilePluginResult): {\n namesByHarness: Record<string, string[]>;\n configsByHarness: Record<string, Record<string, McpServerMetadata>>;\n} {\n return declaredMcpFromExpectedFiles(\n expectedApply.harnesses,\n expectedApply.expected_files ?? [],\n );\n}\n\nfunction uniqueExpectedFiles(\n expectedFiles: Array<{ path: string; content: string }>,\n): Array<{ path: string; content: string }> {\n const seen = new Set<string>();\n const unique: Array<{ path: string; content: string }> = [];\n for (const file of expectedFiles) {\n if (seen.has(file.path)) {\n continue;\n }\n seen.add(file.path);\n unique.push(file);\n }\n return unique;\n}\n\nfunction compareExpectedFiles(\n rootPath: string,\n expectedFiles: Array<{ path: string; content: string }>,\n): DriftFileChange[] {\n const changes: DriftFileChange[] = [];\n const homeRoot = resolveHomeRoot();\n for (const file of uniqueExpectedFiles(expectedFiles)) {\n if (isNativeAgentPluginCachePath(file.path)) continue;\n const current = readRootFile(rootPath, file.path);\n if (expectedFileMatchesLiveForPreview(homeRoot, file, current)) {\n continue;\n }\n if (current === null) {\n changes.push(\n withAffectedResources({ path: file.path, type: \"deleted\" }, file.content, null),\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 return changes;\n}\n\n/**\n * Hide \"would add\" gaps for alternate harness materializations when the same\n * profile resource is already present on disk under another harness path, and\n * leftover extra-harness copies when apply still keeps that resource elsewhere,\n * including extra-harness content noise when another copy already matches.\n * Apply still writes or deletes those files; File changes stays transparent.\n */\nexport function omitTransparentCrossHarnessAdds(\n rootPath: string,\n expectedFiles: Array<{ path: string; content: string }>,\n changes: DriftFileChange[],\n scopeByResource?: ReadonlyMap<string, HarnessScope>,\n): DriftFileChange[] {\n const siblingPathsByResource = new Map<string, string[]>();\n for (const file of uniqueExpectedFiles(expectedFiles)) {\n const mapped = resourceKeyFromManagedPath(file.path);\n if (!mapped) {\n continue;\n }\n const key = `${mapped.type}:${mapped.name}`;\n const siblings = siblingPathsByResource.get(key) ?? [];\n siblings.push(file.path);\n siblingPathsByResource.set(key, siblings);\n }\n\n return changes.filter((change) => {\n const mapped = resourceKeyFromManagedPath(change.path);\n if (!mapped) {\n return true;\n }\n const siblings = siblingPathsByResource.get(`${mapped.type}:${mapped.name}`) ?? [];\n switch (change.type) {\n case \"deleted\": {\n const onDiskSiblingPaths = siblings.filter(\n (path) =>\n path !== change.path && readRootFile(rootPath, path) !== null,\n );\n return !isTransparentCrossHarnessGap({\n path: change.path,\n onDiskSiblingPaths,\n scope: scopeByResource?.get(`${mapped.type}:${mapped.name}`),\n });\n }\n case \"added\":\n return siblings.length === 0;\n case \"modified\": {\n const siblingMatches = siblings.some((path) => {\n if (path === change.path) {\n return false;\n }\n const expected = expectedFiles.find((file) => file.path === path);\n if (!expected) {\n return false;\n }\n const current = readRootFile(rootPath, path);\n if (current === null) {\n return false;\n }\n return fileContentsEquivalentForDrift(\n path,\n current,\n expected.content,\n );\n });\n return !siblingMatches;\n }\n default: {\n const neverType: never = change.type;\n return neverType;\n }\n }\n });\n}\n\n/**\n * Claude `.claude/settings.json` is a shared host config. Apply merges\n * profile-managed keys and never deletes the whole file, so preview must not\n * list it as a would-delete (`added`) stack item.\n */\nfunction omitMergeableHostConfigRemovals(\n changes: DriftFileChange[],\n): DriftFileChange[] {\n return changes.filter(\n (change) =>\n !(change.type === \"added\" && isMergeableHostConfigPath(change.path)),\n );\n}\n\nfunction withMappedResources(changes: DriftFileChange[]): DriftFileChange[] {\n return changes.map((change) => {\n const mapped = resourceKeyFromManagedPath(change.path);\n return mapped ? { ...change, resource: mapped } : change;\n });\n}\n\n/**\n * Map planned apply removals into File changes as drift \"added\" (on disk, not\n * expected → apply would delete). Skip paths that are already gone so Target\n * preview does not show phantom − rows.\n */\nfunction pushRemovalChange(\n next: DriftFileChange[],\n seen: Set<string>,\n rootPath: string,\n path: string,\n removal_group: PlannedRemovalGroup,\n): void {\n if (seen.has(path) || isMergeableHostConfigPath(path)) {\n return;\n }\n if (readRootFile(rootPath, path) === null) {\n return;\n }\n seen.add(path);\n next.push({ path, type: \"added\", removal_group });\n}\n\nfunction classifyPreviewRemovals(\n rootPath: string,\n removedFiles: string[] | undefined,\n skippedRemovals?: ApplyProfilePluginResult[\"skipped_removals\"],\n extraPaths: readonly string[] = [],\n): PlannedRemovals {\n const candidates = [\n ...new Set([\n ...(removedFiles ?? []),\n ...(skippedRemovals ?? [])\n .filter((skip) => skip.reason !== \"missing\")\n .map((skip) => skip.path),\n ...extraPaths,\n ]),\n ];\n const groups = groupPlannedRemovals(planSafeFileRemovals(rootPath, candidates));\n const pull = (list: string[], path: string) => {\n const index = list.indexOf(path);\n if (index >= 0) {\n list.splice(index, 1);\n }\n };\n for (const skip of skippedRemovals ?? []) {\n if (skip.reason === \"missing\") {\n continue;\n }\n if (skip.reason === \"modified\") {\n pull(groups.owned_unmodified, skip.path);\n pull(groups.unmanaged, skip.path);\n if (!groups.owned_modified.includes(skip.path)) {\n groups.owned_modified.push(skip.path);\n }\n continue;\n }\n if (skip.reason === \"unmanaged\" || skip.reason === \"preexisting\") {\n pull(groups.owned_unmodified, skip.path);\n pull(groups.owned_modified, skip.path);\n if (!groups.unmanaged.includes(skip.path)) {\n groups.unmanaged.push(skip.path);\n }\n }\n }\n return groups;\n}\n\nexport function withManagedRemovals(\n rootPath: string,\n changes: DriftFileChange[],\n removedFiles: string[] | undefined,\n skippedRemovals?: ApplyProfilePluginResult[\"skipped_removals\"],\n): DriftFileChange[] {\n const groups = classifyPreviewRemovals(\n rootPath,\n removedFiles,\n skippedRemovals,\n );\n const classified = changes.filter((change) => change.type !== \"added\");\n const seen = new Set(classified.map((change) => change.path));\n for (const path of groups.owned_unmodified) {\n pushRemovalChange(classified, seen, rootPath, path, \"owned_unmodified\");\n }\n for (const path of groups.owned_modified) {\n pushRemovalChange(classified, seen, rootPath, path, \"owned_modified\");\n }\n for (const path of groups.unmanaged) {\n pushRemovalChange(classified, seen, rootPath, path, \"unmanaged\");\n }\n return annotateKeptContentDiffs(classified, groups);\n}\n\n/**\n * A content diff that apply will skip (user-modified or unmanaged) is a keep,\n * same groups as the confirm dialog. It must not stay labeled as a write.\n */\nfunction annotateKeptContentDiffs(\n changes: DriftFileChange[],\n groups: PlannedRemovals,\n): DriftFileChange[] {\n if (groups.owned_modified.length === 0 && groups.unmanaged.length === 0) {\n return changes;\n }\n const modified = new Set(groups.owned_modified);\n const unmanaged = new Set(groups.unmanaged);\n return changes.map((change) => {\n if (change.type !== \"modified\" || change.removal_group) {\n return change;\n }\n if (modified.has(change.path)) {\n return { ...change, removal_group: \"owned_modified\" as const };\n }\n if (unmanaged.has(change.path)) {\n return { ...change, removal_group: \"unmanaged\" as const };\n }\n return change;\n });\n}\n\nfunction targetPinRefs(pluginIds?: string[]): Set<string> {\n if (!pluginIds || pluginIds.length === 0) {\n return new Set();\n }\n return new Set(\n mergePluginsForApply(pluginIds).pluginPins.map((pin) => pin.ref),\n );\n}\n\nfunction buildPreviewFileChanges(\n rootPath: string,\n expectedFiles: Array<{ path: string; content: string }>,\n removedFiles: string[] | undefined,\n pluginIds?: string[],\n skippedRemovals?: ApplyProfilePluginResult[\"skipped_removals\"],\n): DriftFileChange[] {\n const mapped = withMappedResources(\n omitMergeableHostConfigRemovals(\n omitTransparentCrossHarnessAdds(\n rootPath,\n expectedFiles,\n withManagedRemovals(\n rootPath,\n compareExpectedFiles(rootPath, expectedFiles),\n removedFiles,\n skippedRemovals,\n ),\n resourceScopesForPlugins(pluginIds),\n ),\n ),\n );\n return omitInheritedPluginFileChanges(\n resolveHomeRoot(),\n mapped,\n targetPinRefs(pluginIds),\n );\n}\n\nfunction previewFilesResult(\n rootPath: string,\n expectedFiles: Array<{ path: string; content: string }>,\n removedFiles: string[] | undefined,\n pluginIds?: string[],\n skippedRemovals?: ApplyProfilePluginResult[\"skipped_removals\"],\n): ProfileApplyPreview[\"files\"] {\n return {\n expected_count: expectedFiles.length,\n changes: buildPreviewFileChanges(\n rootPath,\n expectedFiles,\n removedFiles,\n pluginIds,\n skippedRemovals,\n ),\n root_path: rootPath,\n owned_resources: collectOwnedPreviewResources(expectedFiles),\n };\n}\n\nfunction previewRemovals(\n rootPath: string,\n removedFiles: string[] | undefined,\n skippedRemovals?: ApplyProfilePluginResult[\"skipped_removals\"],\n): PlannedRemovals {\n return classifyPreviewRemovals(rootPath, removedFiles, skippedRemovals);\n}\n\nfunction isMaterialResource(resource: Resource): boolean {\n return resource.type !== \"plugin\";\n}\n\nexport interface CollectExpectedManagedFilesInput {\n profile: string;\n scope: ProfileApplyPreviewScope;\n projectPath?: string;\n harness?: string;\n}\n\nexport interface CollectExpectedManagedFilesResult {\n rootPath: string;\n expectedFiles: Array<{ path: string; content: string }>;\n warning?: string;\n recovery_actions?: RecoveryAction[];\n expectedApply?: ApplyProfilePluginResult;\n pluginIds?: string[];\n removedFiles?: string[];\n}\n\nasync function collectHomeExpectedManagedFiles(\n profile: string,\n harness?: string,\n): Promise<CollectExpectedManagedFilesResult> {\n const homeRoot = resolveHomeRoot();\n\n if (isEmptyBuiltinProfile(profile)) {\n try {\n const expectedApply = await clearGlobalProfileApply({\n dryRun: true,\n harness,\n conflictPolicy: \"replace\",\n pull: false,\n });\n return {\n rootPath: homeRoot,\n expectedFiles: uniqueExpectedFiles(expectedApply.expected_files ?? []),\n expectedApply,\n removedFiles: expectedApply.removed_files,\n };\n } catch (error) {\n return {\n rootPath: homeRoot,\n expectedFiles: [],\n ...warningFromError(error),\n };\n }\n }\n\n const plugin = resolvePluginSelector(profile);\n if (!plugin) {\n return {\n rootPath: homeRoot,\n expectedFiles: [],\n warning: `missing plugin \"${profile}\"`,\n };\n }\n if (!isProfilePlugin(plugin)) {\n return {\n rootPath: homeRoot,\n expectedFiles: [],\n ...notProfileWarning(plugin.name),\n };\n }\n\n const pluginIds = collectProfilePluginIds(plugin);\n try {\n const expectedApply = await applyProfilePlugin(profile, {\n dryRun: true,\n harness,\n conflictPolicy: \"replace\",\n pull: false,\n });\n return {\n rootPath: homeRoot,\n expectedFiles: uniqueExpectedFiles(expectedApply.expected_files ?? []),\n expectedApply,\n pluginIds,\n removedFiles: expectedApply.removed_files,\n };\n } catch (error) {\n return {\n rootPath: homeRoot,\n expectedFiles: [],\n pluginIds,\n ...warningFromError(error),\n };\n }\n}\n\nfunction snapshotPreviousPaths(resolvedRoot: string): string[] {\n const gitOriginRaw = getGitOrigin(resolvedRoot);\n const gitOrigin = gitOriginRaw ? normalizeGitUrl(gitOriginRaw) : null;\n const project =\n getProjectByLocalPath(resolvedRoot)\n ?? (gitOrigin ? getProjectByOrigin(gitOrigin) : undefined)\n ?? null;\n const snapshot = project ? getLatestSnapshot(project.id) : null;\n return snapshot\n ? Object.values(snapshot.state.platform_files).flatMap((files) =>\n Object.keys(files),\n )\n : [];\n}\n\nasync function collectProjectExpectedManagedFiles(\n profile: string,\n projectPath?: string,\n harness?: string,\n): Promise<CollectExpectedManagedFilesResult> {\n if (!projectPath) {\n return {\n rootPath: resolve(\"\"),\n expectedFiles: [],\n warning: \"projectPath is required for project scope\",\n };\n }\n\n const resolvedRoot = resolve(projectPath);\n const plugin = resolvePluginSelector(profile);\n if (!plugin) {\n return {\n rootPath: resolvedRoot,\n expectedFiles: [],\n warning: `missing plugin \"${profile}\"`,\n };\n }\n if (!isProfilePlugin(plugin) && !isEmptyBuiltinProfile(profile)) {\n return {\n rootPath: resolvedRoot,\n expectedFiles: [],\n ...notProfileWarning(plugin.name),\n };\n }\n\n const detected = detectPlatforms(resolvedRoot);\n const platformIds = harness\n ? detected.filter((id) => id === harness)\n : detected;\n\n if (isEmptyBuiltinProfile(profile) || platformIds.length === 0) {\n return {\n rootPath: resolvedRoot,\n expectedFiles: [],\n removedFiles: snapshotPreviousPaths(resolvedRoot),\n };\n }\n\n const pluginIds = collectProfilePluginIds(plugin);\n const merged = mergePluginsForApply(pluginIds);\n const material = merged.resources.filter(isMaterialResource);\n try {\n const generated = await generateFiles(material, platformIds, resolvedRoot, {\n target: \"project\",\n claudeConfig: merged.claude,\n });\n const expectedFiles = uniqueExpectedFiles(\n generated.flatMap((result) =>\n result.files.map((file) => ({ path: file.path, content: file.content })),\n ),\n );\n const previousPaths = snapshotPreviousPaths(resolvedRoot);\n const desired = new Set(expectedFiles.map((file) => file.path));\n const removedFiles = previousPaths.filter((path) => !desired.has(path));\n return {\n rootPath: resolvedRoot,\n expectedFiles,\n pluginIds,\n removedFiles,\n };\n } catch (error) {\n return {\n rootPath: resolvedRoot,\n expectedFiles: [],\n pluginIds,\n ...warningFromError(error),\n };\n }\n}\n\nexport async function collectExpectedManagedFiles(\n input: CollectExpectedManagedFilesInput,\n): Promise<CollectExpectedManagedFilesResult> {\n if (input.scope === \"project\") {\n return collectProjectExpectedManagedFiles(\n input.profile,\n input.projectPath,\n input.harness,\n );\n }\n return collectHomeExpectedManagedFiles(input.profile, input.harness);\n}\n\nasync function previewHomeApply(\n profile: string,\n harness?: string,\n): Promise<\n Pick<ProfileApplyPreview, \"harnesses\" | \"files\" | \"removals\" | \"warning\" | \"recovery_actions\">\n> {\n const collected = await collectHomeExpectedManagedFiles(profile, harness);\n\n if (collected.warning) {\n if (collected.pluginIds) {\n const merged = mergePluginsForApply(collected.pluginIds);\n const declaredMcpByHarness = {\n \"claude-code\": merged.resources\n .filter((resource) => resource.type === \"mcp_server\")\n .map((resource) => resource.name),\n cursor: merged.resources\n .filter((resource) => resource.type === \"mcp_server\")\n .map((resource) => resource.name),\n };\n return {\n harnesses: buildHarnessLiveStatusMap({\n depth: \"full\",\n homeRoot: collected.rootPath,\n declaredPins: merged.pluginPins,\n declaredMcpByHarness,\n }),\n files: {\n expected_count: 0,\n changes: withMappedResources([]),\n root_path: collected.rootPath,\n },\n removals: emptyPlannedRemovals(),\n ...spreadWarningFields(collected),\n };\n }\n return {\n files: {\n expected_count: 0,\n changes: withMappedResources([]),\n root_path: collected.rootPath,\n },\n removals: emptyPlannedRemovals(),\n ...spreadWarningFields(collected),\n };\n }\n\n if (isEmptyBuiltinProfile(profile)) {\n return {\n harnesses: buildHarnessLiveStatusMap({\n depth: \"full\",\n homeRoot: collected.rootPath,\n declaredPins: [],\n declaredMcpByHarness: {},\n }),\n files: previewFilesResult(\n collected.rootPath,\n collected.expectedFiles,\n collected.removedFiles,\n collected.pluginIds,\n collected.expectedApply?.skipped_removals,\n ),\n removals: previewRemovals(\n collected.rootPath,\n collected.removedFiles,\n collected.expectedApply?.skipped_removals,\n ),\n };\n }\n\n const declaredPins = collected.pluginIds\n ? mergePluginsForApply(collected.pluginIds).pluginPins\n : [];\n const declaredMcp = collected.expectedApply\n ? declaredMcpFromExpectedApply(collected.expectedApply)\n : { namesByHarness: {}, configsByHarness: {} };\n return {\n harnesses: buildHarnessLiveStatusMap({\n depth: \"full\",\n homeRoot: collected.rootPath,\n declaredPins,\n declaredMcpByHarness: declaredMcp.namesByHarness,\n expectedMcpConfigsByHarness: declaredMcp.configsByHarness,\n }),\n files: previewFilesResult(\n collected.rootPath,\n collected.expectedFiles,\n collected.removedFiles,\n collected.pluginIds,\n collected.expectedApply?.skipped_removals,\n ),\n removals: previewRemovals(\n collected.rootPath,\n collected.removedFiles,\n collected.expectedApply?.skipped_removals,\n ),\n };\n}\n\nasync function previewProjectApply(\n profile: string,\n projectPath?: string,\n harness?: string,\n): Promise<Pick<ProfileApplyPreview, \"files\" | \"removals\" | \"warning\" | \"recovery_actions\">> {\n const collected = await collectProjectExpectedManagedFiles(\n profile,\n projectPath,\n harness,\n );\n\n return {\n files: previewFilesResult(\n collected.rootPath,\n collected.expectedFiles,\n collected.removedFiles,\n collected.pluginIds,\n collected.expectedApply?.skipped_removals,\n ),\n removals: previewRemovals(\n collected.rootPath,\n collected.removedFiles,\n collected.expectedApply?.skipped_removals,\n ),\n ...spreadWarningFields(collected),\n };\n}\n\nexport async function previewProfileApply(\n input: ProfileApplyPreviewRequest,\n): Promise<ProfileApplyPreview> {\n const profile = input.profile.trim();\n const contents = buildProfileContents(profile);\n const relativeToActive = getActiveProfileName() === profile;\n const notStaged = await detectNotStagedProfileResources({\n profileSelector: profile,\n scope: input.scope,\n ...(input.projectPath ? { projectPath: input.projectPath } : {}),\n ...(input.harness ? { harness: input.harness } : {}),\n });\n\n if (input.scope === \"project\") {\n const projectPreview = await previewProjectApply(\n profile,\n input.projectPath,\n input.harness,\n );\n return {\n profile,\n scope: \"project\",\n contents,\n not_staged: notStaged,\n untracked_resources: notStaged,\n files: projectPreview.files,\n removals: projectPreview.removals,\n relative_to_active: relativeToActive,\n ...spreadWarningFields(projectPreview),\n };\n }\n\n const homePreview = await previewHomeApply(profile, input.harness);\n return {\n profile,\n scope: \"home\",\n contents,\n not_staged: notStaged,\n untracked_resources: notStaged,\n ...(homePreview.harnesses ? { harnesses: homePreview.harnesses } : {}),\n files: homePreview.files,\n removals: homePreview.removals,\n relative_to_active: relativeToActive,\n host_managed: buildHostManagedStatus({\n homeRoot: homePreview.files.root_path,\n profileSkills: profileSkillNameMap(contents?.resources ?? []),\n }),\n ...spreadWarningFields(homePreview),\n };\n}\n","import { findResourceByKey, getResource } from \"../models/resource.js\";\nimport type { Resource, ResourceType } from \"../types.js\";\nimport { MATERIAL_RESOURCE_TYPES } from \"../types.js\";\nimport {\n mcpConfigContentsEquivalent,\n parseMcpServersDocument,\n} from \"./mcp-config-bridge.js\";\nimport { fileContentsEquivalentForDrift } from \"./file-contents-drift.js\";\nimport { hostPluginPinIsInstalled, listHostNativeMcpNames } from \"./host-native-mcp.js\";\nimport {\n isMcpConfigManagedPath,\n resourceKeyFromManagedPath,\n} from \"./profile-commit-resource.js\";\nimport type { DriftFileChange } from \"./project-drift.js\";\n\nconst MATERIAL_TYPE_SET = new Set<string>(MATERIAL_RESOURCE_TYPES);\n\nexport interface OwnedPreviewResource {\n type: string;\n name: string;\n}\n\nfunction findMaterialResource(type: string, name: string): Resource | undefined {\n if (!MATERIAL_TYPE_SET.has(type)) {\n return undefined;\n }\n return (\n getResource(`${type}:${name}`)\n ?? findResourceByKey(type as ResourceType, name, \"\")\n );\n}\n\nfunction nativeMcpNamesForPath(homeRoot: string, path: string): Set<string> {\n const normalized = path.replace(/\\\\/g, \"/\");\n if (normalized.includes(\".cursor/\") && /(^|\\/)mcp\\.json$/i.test(normalized)) {\n return listHostNativeMcpNames(homeRoot, \"cursor\");\n }\n if (\n /(^|\\/)\\.mcp\\.json$/i.test(normalized)\n || /(^|\\/)\\.claude\\.json$/i.test(normalized)\n ) {\n return listHostNativeMcpNames(homeRoot, \"claude-code\");\n }\n return new Set();\n}\n\n/**\n * Treat host-native plugin MCP servers as already present when comparing\n * expected vs live MCP config for apply preview.\n */\nexport function mcpPreviewContentsEquivalent(\n current: string | null,\n expected: string,\n nativeNames: ReadonlySet<string>,\n): boolean {\n let expectedDocument: unknown;\n try {\n expectedDocument = JSON.parse(expected) as unknown;\n } catch {\n return false;\n }\n const expectedServers = parseMcpServersDocument(expectedDocument);\n const expectedNames = Object.keys(expectedServers);\n const nonNativeExpected = expectedNames.filter((name) => !nativeNames.has(name));\n\n if (current === null) {\n return expectedNames.length === 0 || nonNativeExpected.length === 0;\n }\n\n let currentDocument: unknown;\n try {\n currentDocument = JSON.parse(current) as unknown;\n } catch {\n return false;\n }\n const currentServers = parseMcpServersDocument(currentDocument);\n const mergedCurrent: Record<string, (typeof expectedServers)[string]> = {\n ...currentServers,\n };\n for (const name of expectedNames) {\n const expectedMeta = expectedServers[name];\n if (nativeNames.has(name) && expectedMeta && !(name in mergedCurrent)) {\n mergedCurrent[name] = expectedMeta;\n }\n }\n\n return mcpConfigContentsEquivalent(\n JSON.stringify({ mcpServers: mergedCurrent }),\n JSON.stringify({ mcpServers: expectedServers }),\n );\n}\n\nexport function collectOwnedPreviewResources(\n expectedFiles: Array<{ path: string; content: string }>,\n): OwnedPreviewResource[] {\n const order: string[] = [];\n const byKey = new Map<string, OwnedPreviewResource>();\n const add = (type: string, name: string) => {\n const key = `${type}:${name}`;\n if (byKey.has(key)) {\n return;\n }\n order.push(key);\n byKey.set(key, { type, name });\n };\n\n for (const file of expectedFiles) {\n const mapped = resourceKeyFromManagedPath(file.path);\n if (mapped) {\n add(mapped.type, mapped.name);\n }\n if (!isMcpConfigManagedPath(file.path)) {\n continue;\n }\n try {\n const document = JSON.parse(file.content) as unknown;\n for (const name of Object.keys(parseMcpServersDocument(document))) {\n add(\"mcp_server\", name);\n }\n } catch {\n // skip invalid MCP payloads\n }\n }\n\n return order\n .map((key) => byKey.get(key))\n .filter((entry): entry is OwnedPreviewResource => entry !== undefined);\n}\n\nfunction resourceIsDeployedHostPluginOwned(\n type: string,\n name: string,\n homeRoot: string,\n): { originRef: string; installed: boolean } | null {\n const resource = findMaterialResource(type, name);\n if (\n !resource\n || resource.origin_kind !== \"marketplace_link\"\n || !resource.origin_ref\n ) {\n return null;\n }\n return {\n originRef: resource.origin_ref,\n installed: hostPluginPinIsInstalled(homeRoot, resource.origin_ref),\n };\n}\n\n/**\n * Drop stack/file preview noise for resources already deployed by an installed\n * host plugin (marketplace pin). MCP config paths are handled separately.\n */\nexport function omitInheritedPluginFileChanges(\n homeRoot: string,\n changes: DriftFileChange[],\n targetPinRefs: ReadonlySet<string>,\n): DriftFileChange[] {\n return changes.filter((change) => {\n if (isMcpConfigManagedPath(change.path)) {\n return true;\n }\n const mapped = change.resource ?? resourceKeyFromManagedPath(change.path);\n if (!mapped || mapped.type === \"mcp_server\") {\n return true;\n }\n const owned = resourceIsDeployedHostPluginOwned(\n mapped.type,\n mapped.name,\n homeRoot,\n );\n if (!owned?.installed) {\n return true;\n }\n switch (change.type) {\n case \"deleted\":\n case \"modified\":\n return false;\n case \"added\":\n return !targetPinRefs.has(owned.originRef);\n default: {\n const neverType: never = change.type;\n return neverType;\n }\n }\n });\n}\n\nexport function expectedFileMatchesLiveForPreview(\n homeRoot: string,\n file: { path: string; content: string },\n current: string | null,\n): boolean {\n if (isMcpConfigManagedPath(file.path)) {\n const nativeNames = nativeMcpNamesForPath(homeRoot, file.path);\n if (nativeNames.size > 0) {\n return mcpPreviewContentsEquivalent(current, file.content, nativeNames);\n }\n }\n if (current === null) {\n return false;\n }\n return fileContentsEquivalentForDrift(file.path, current, file.content);\n}\n","import { isProfilePlugin } from \"../constants/profile.js\";\nimport {\n getPluginResources,\n removeResourceFromPlugin,\n resolvePluginSelector,\n touchPluginUpdatedAt,\n} from \"../models/plugin-model.js\";\nimport { resolveResource } from \"../models/resource.js\";\nimport { collectProfilePluginIds } from \"./profile-apply.js\";\nimport { markPluginDirty } from \"./plugin-versioning.js\";\nimport {\n type ProfileContentsResource,\n toContentsResource,\n} from \"./profile-contents.js\";\n\nconst COMPOSITION_RESOURCE_TYPES = new Set([\"plugin\"]);\n\nexport function removeResourceFromProfile(input: {\n profileSelector: string;\n resourceType: string;\n resourceName: string;\n pluginId?: string;\n}): ProfileContentsResource {\n const profilePlugin = resolvePluginSelector(input.profileSelector);\n if (!profilePlugin) {\n throw new Error(`Profile not found: ${input.profileSelector}`);\n }\n if (!isProfilePlugin(profilePlugin)) {\n throw new Error(`Plugin \"${profilePlugin.name}\" is not tagged as a profile`);\n }\n if (COMPOSITION_RESOURCE_TYPES.has(input.resourceType)) {\n throw new Error(`Cannot remove composition resource type: ${input.resourceType}`);\n }\n\n const stackPluginIds = collectProfilePluginIds(profilePlugin);\n const stackPluginIdSet = new Set(stackPluginIds);\n if (input.pluginId && !stackPluginIdSet.has(input.pluginId)) {\n throw new Error(`Plugin is not part of profile stack: ${input.pluginId}`);\n }\n\n const selector = `${input.resourceType}:${input.resourceName}`;\n const resolved = resolveResource(selector, { mode: \"compose\" });\n if (resolved.status === \"not_found\") {\n throw new Error(`Resource not found in profile: ${selector}`);\n }\n if (resolved.status === \"ambiguous\") {\n throw new Error(`Ambiguous resource selector: ${selector}`);\n }\n\n const resourceId = resolved.resource.id;\n const searchPluginIds = input.pluginId ? [input.pluginId] : stackPluginIds;\n let removedFromPluginId: string | null = null;\n for (const pluginId of searchPluginIds) {\n const attached = getPluginResources(pluginId);\n if (attached.some((resource) => resource.id === resourceId)) {\n markPluginDirty(pluginId);\n removeResourceFromPlugin(pluginId, resourceId);\n touchPluginUpdatedAt(pluginId);\n removedFromPluginId = pluginId;\n break;\n }\n }\n\n if (!removedFromPluginId) {\n throw new Error(`Resource is not attached to profile: ${selector}`);\n }\n\n return toContentsResource(resolved.resource);\n}\n","import { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport {\n collectExpectedManagedFiles,\n type ProfileApplyPreviewScope,\n} from \"./profile-apply-preview.js\";\nimport { normalizeManagedPath } from \"./profile-untracked-resources.js\";\n\nexport async function restoreManagedFile(input: {\n profileSelector: string;\n path: string;\n scope: ProfileApplyPreviewScope;\n projectPath?: string;\n harness?: string;\n}): Promise<{ path: string; absolute_path: string }> {\n const profile = input.profileSelector.trim();\n const requestedPath = normalizeManagedPath(input.path.trim());\n\n const collected = await collectExpectedManagedFiles({\n profile,\n scope: input.scope,\n ...(input.projectPath ? { projectPath: input.projectPath } : {}),\n ...(input.harness ? { harness: input.harness } : {}),\n });\n\n if (collected.warning) {\n throw new Error(collected.warning);\n }\n\n const match = collected.expectedFiles.find((file) => {\n const normalized = normalizeManagedPath(file.path, collected.rootPath);\n return (\n normalized === requestedPath\n || normalizeManagedPath(file.path) === requestedPath\n );\n });\n\n if (!match) {\n throw new Error(`Path is not a managed file for this profile: ${input.path}`);\n }\n\n const relativePath = normalizeManagedPath(match.path, collected.rootPath);\n const absolutePath = join(collected.rootPath, relativePath);\n\n mkdirSync(dirname(absolutePath), { recursive: true });\n writeFileSync(absolutePath, match.content, \"utf-8\");\n\n return { path: relativePath, absolute_path: absolutePath };\n}\n","import { getDb } from \"../../db/connection.js\";\nimport { initializeSchema } from \"../../db/schema.js\";\nimport { missingRequiredArg } from \"../../services/cli-errors.js\";\nimport { parseResourceSelector } from \"../../services/resource-selector.js\";\nimport type { ProfileApplyPreviewScope } from \"../../services/profile-apply-preview.js\";\nimport {\n commitManagedPathFromLive,\n commitManagedResourceFromLive,\n} from \"../../services/profile-commit-resource.js\";\nimport { getManagedFileDiff } from \"../../services/profile-file-diff.js\";\nimport { removeResourceFromProfile } from \"../../services/profile-remove-resource.js\";\nimport { restoreManagedFile } from \"../../services/profile-restore-file.js\";\nimport {\n addAllUntrackedResourcesToProfile,\n addResourceToProfile,\n} from \"../../services/profile-untracked-resources.js\";\nimport {\n promptForConfirmation,\n shouldUseBrowsePicker,\n} from \"../../services/wizards/shared.js\";\nimport { ui } from \"../../ui/index.js\";\nimport { parseOutputFormat, printJson } from \"../../utils/output-format.js\";\nimport { buildUnifiedDiffLines } from \"../../utils/unified-diff.js\";\n\nexport interface LiveScopeOpts {\n scope?: string;\n project?: string;\n harness?: string;\n format?: string;\n interactive?: boolean;\n noInteractive?: boolean;\n}\n\nexport interface ConfirmOpts {\n yes?: boolean;\n format?: string;\n noInteractive?: boolean;\n}\n\nfunction initDb(): void {\n const db = getDb();\n initializeSchema(db);\n}\n\nfunction requireTypeNameSelector(\n raw: string | undefined,\n commandPath: string,\n): { type: string; name: string } {\n if (!raw) {\n throw missingRequiredArg(\"selector\", commandPath);\n }\n const parsed = parseResourceSelector(raw);\n if (!parsed.type || parsed.name.trim().length === 0) {\n throw missingRequiredArg(\"selector\", commandPath);\n }\n return { type: parsed.type, name: parsed.name };\n}\n\nfunction requireLiveScope(\n opts: LiveScopeOpts,\n commandPath: string,\n): {\n scope: ProfileApplyPreviewScope;\n projectPath?: string;\n harness?: string;\n} {\n if (opts.scope !== \"home\" && opts.scope !== \"project\") {\n throw missingRequiredArg(\"scope\", commandPath);\n }\n const harness = opts.harness?.trim();\n if (opts.scope === \"project\") {\n const projectPath = opts.project?.trim();\n if (!projectPath) {\n throw missingRequiredArg(\"project\", commandPath);\n }\n return {\n scope: opts.scope,\n projectPath,\n ...(harness ? { harness } : {}),\n };\n }\n return {\n scope: opts.scope,\n ...(harness ? { harness } : {}),\n };\n}\n\nasync function confirmOrRefuse(input: {\n message: string;\n yes?: boolean;\n format?: string;\n noInteractive?: boolean;\n}): Promise<\"proceed\" | \"cancelled\" | \"refused\"> {\n if (input.yes) {\n return \"proceed\";\n }\n if (shouldUseBrowsePicker({\n noInteractive: input.noInteractive,\n format: input.format,\n })) {\n const confirmed = await promptForConfirmation({\n message: input.message,\n default: false,\n });\n if (!confirmed) {\n ui.info(\"Operation cancelled.\");\n return \"cancelled\";\n }\n return \"proceed\";\n }\n process.exitCode = 1;\n ui.hint(\"Pass -y to confirm.\");\n return \"refused\";\n}\n\nexport async function handleProfileAddResourceCommand(\n name: string,\n opts: LiveScopeOpts & { selector?: string },\n): Promise<void> {\n initDb();\n const format = parseOutputFormat(opts.format);\n const selector = requireTypeNameSelector(opts.selector, \"profile add-resource\");\n const scope = requireLiveScope(opts, \"profile add-resource\");\n const resource = await addResourceToProfile({\n profileSelector: name,\n resourceType: selector.type,\n resourceName: selector.name,\n ...scope,\n });\n if (format === \"json\") {\n printJson({ resource });\n return;\n }\n ui.success(`Added ${selector.type}:${selector.name} to profile ${name}.`);\n}\n\nexport async function handleProfileAddAllResourcesCommand(\n name: string,\n opts: LiveScopeOpts,\n): Promise<void> {\n initDb();\n const format = parseOutputFormat(opts.format);\n const scope = requireLiveScope(opts, \"profile add-all-resources\");\n const result = await addAllUntrackedResourcesToProfile({\n profileSelector: name,\n ...scope,\n });\n if (format === \"json\") {\n printJson(result);\n return;\n }\n const noun = result.added_count === 1 ? \"resource\" : \"resources\";\n ui.success(`Added ${result.added_count} ${noun} to profile ${name}.`);\n}\n\nexport async function handleProfileCommitResourceCommand(\n name: string,\n opts: LiveScopeOpts & { path?: string; selector?: string },\n): Promise<void> {\n initDb();\n const format = parseOutputFormat(opts.format);\n const scope = requireLiveScope(opts, \"profile commit-resource\");\n const path = opts.path?.trim() ?? \"\";\n const hasSelector = Boolean(opts.selector?.trim());\n if (!path && !hasSelector) {\n throw missingRequiredArg(\"path\", \"profile commit-resource\");\n }\n\n if (path && !hasSelector) {\n const resources = await commitManagedPathFromLive({\n profileSelector: name,\n path,\n ...scope,\n });\n if (format === \"json\") {\n printJson({ resource: resources[0] ?? null, resources });\n return;\n }\n ui.success(`Committed ${path} into profile ${name}.`);\n return;\n }\n\n const selector = requireTypeNameSelector(opts.selector, \"profile commit-resource\");\n if (path) {\n const resources = await commitManagedPathFromLive({\n profileSelector: name,\n path,\n resourceType: selector.type,\n resourceName: selector.name,\n ...scope,\n });\n if (format === \"json\") {\n printJson({ resource: resources[0] ?? null, resources });\n return;\n }\n ui.success(`Committed ${path} into profile ${name}.`);\n return;\n }\n\n const resource = await commitManagedResourceFromLive({\n profileSelector: name,\n resourceType: selector.type,\n resourceName: selector.name,\n ...scope,\n });\n if (format === \"json\") {\n printJson({ resource });\n return;\n }\n ui.success(`Committed ${selector.type}:${selector.name} into profile ${name}.`);\n}\n\nexport async function handleProfileRemoveResourceCommand(\n name: string,\n opts: ConfirmOpts & { selector?: string; pluginId?: string },\n): Promise<void> {\n initDb();\n const format = parseOutputFormat(opts.format);\n const selector = requireTypeNameSelector(opts.selector, \"profile remove-resource\");\n const gate = await confirmOrRefuse({\n message: `Remove ${selector.type}:${selector.name} from profile ${name}?`,\n yes: opts.yes,\n format: opts.format,\n noInteractive: opts.noInteractive,\n });\n if (gate !== \"proceed\") {\n return;\n }\n const resource = removeResourceFromProfile({\n profileSelector: name,\n resourceType: selector.type,\n resourceName: selector.name,\n ...(opts.pluginId?.trim() ? { pluginId: opts.pluginId.trim() } : {}),\n });\n if (format === \"json\") {\n printJson({ resource });\n return;\n }\n ui.success(`Removed ${selector.type}:${selector.name} from profile ${name}.`);\n}\n\nexport async function handleProfileRestoreFileCommand(\n name: string,\n opts: LiveScopeOpts & ConfirmOpts & { path?: string },\n): Promise<void> {\n initDb();\n const format = parseOutputFormat(opts.format);\n const scope = requireLiveScope(opts, \"profile restore-file\");\n const path = opts.path?.trim() ?? \"\";\n if (!path) {\n throw missingRequiredArg(\"path\", \"profile restore-file\");\n }\n const gate = await confirmOrRefuse({\n message:\n `Overwrite ${path} with the profile version? Live edits cannot be restored.`,\n yes: opts.yes,\n format: opts.format,\n noInteractive: opts.noInteractive,\n });\n if (gate !== \"proceed\") {\n return;\n }\n const result = await restoreManagedFile({\n profileSelector: name,\n path,\n ...scope,\n });\n if (format === \"json\") {\n printJson(result);\n return;\n }\n ui.success(`Restored ${result.path}.`);\n}\n\nexport async function handleProfileFileDiffCommand(\n name: string,\n opts: LiveScopeOpts & { path?: string },\n): Promise<void> {\n initDb();\n const format = parseOutputFormat(opts.format);\n const scope = requireLiveScope(opts, \"profile file-diff\");\n const path = opts.path?.trim() ?? \"\";\n if (!path) {\n throw missingRequiredArg(\"path\", \"profile file-diff\");\n }\n const diff = await getManagedFileDiff({\n profileSelector: name,\n path,\n ...scope,\n });\n if (format === \"json\") {\n printJson({\n path: diff.path,\n absolute_path: diff.absolute_path,\n expected: diff.expected,\n current: diff.current,\n });\n return;\n }\n const lines = buildUnifiedDiffLines(diff.path, diff.current ?? \"\", diff.expected);\n console.log(lines.map((line) => line.text).join(\"\\n\"));\n}\n","import type { Command } from \"commander\";\nimport { portableScopeTip, SCOPE_COPY, scopeLine } from \"../../copy/scope.js\";\nimport { getDb } from \"../../db/connection.js\";\nimport { initializeSchema } from \"../../db/schema.js\";\nimport { getHarnessPreference } from \"../../models/harness.js\";\nimport { resolvePluginSelector } from \"../../models/plugin-model.js\";\nimport { getActiveProfileName } from \"../../services/active-profile.js\";\nimport { CliUsageError, missingRequiredArg } from \"../../services/cli-errors.js\";\nimport { COMMAND_HELP_REGISTRY } from \"../../services/cli-help-registry.js\";\nimport { resourceHarnessScope } from \"../../services/harness-scope.js\";\nimport { registeredHarnessesOf } from \"../../services/harness-targets.js\";\nimport { isPortableMcpResource } from \"../../services/mcp-target.js\";\nimport { mergePluginsForApply } from \"../../services/plugin-apply-merge.js\";\nimport { collectProfilePluginIds } from \"../../services/profile-apply.js\";\nimport {\n type ProfileApplyPreview,\n type ProfileApplyPreviewScope,\n previewProfileApply,\n} from \"../../services/profile-apply-preview.js\";\nimport { type DriftFileChange, driftChangeIsKept } from \"../../services/project-drift.js\";\nimport { isPromptCancellationError } from \"../../services/wizards/shared.js\";\nimport { ui } from \"../../ui/index.js\";\nimport { parseOutputFormat, printJson } from \"../../utils/output-format.js\";\nimport { formatCount } from \"../formatting.js\";\nimport { resolvePluginMutationTarget } from \"../handlers/resolve-plugin-mutation-target.js\";\nimport { renderCliError } from \"../runtime.js\";\nimport { formatCommand } from \"../shared.js\";\n\nconst CLI_PREVIEW_SCOPES = [\"home\", \"project\", \"both\"] as const;\ntype CliPreviewScope = (typeof CLI_PREVIEW_SCOPES)[number];\n\nconst PROFILE_PREVIEW_HELP = {\n description:\n \"Show apply preview for a profile (contents, files, untracked, recovery) without writing\",\n examples: [\n \"profile preview\",\n \"profile preview work --format json\",\n \"profile preview work --scope project --project .\",\n \"profile preview work --scope both\",\n ],\n} as const;\n\nfunction isCliPreviewScope(value: string): value is CliPreviewScope {\n return (CLI_PREVIEW_SCOPES as readonly string[]).includes(value);\n}\n\nfunction parseCliPreviewScope(value: string | undefined): CliPreviewScope {\n const scope = value ?? \"home\";\n if (!isCliPreviewScope(scope)) {\n throw new CliUsageError(\n `Invalid --scope value: ${scope}. Use home, project, or both.`,\n );\n }\n return scope;\n}\n\nfunction resolveProjectPathForScope(\n scope: CliPreviewScope,\n project: string | undefined,\n): string | undefined {\n if (scope === \"home\") {\n return undefined;\n }\n const projectPath = (project ?? \".\").trim();\n if (!projectPath) {\n throw new CliUsageError(\"projectPath is required for project scope\");\n }\n return projectPath;\n}\n\nasync function resolvePreviewProfileName(input: {\n name: string | undefined;\n format?: string;\n interactive?: boolean;\n noInteractive?: boolean;\n}): Promise<string | undefined> {\n const trimmed = input.name?.trim();\n if (trimmed) {\n return trimmed;\n }\n const active = getActiveProfileName();\n if (active) {\n return active;\n }\n return resolvePluginMutationTarget({\n pluginName: undefined,\n profileMode: true,\n interactive: input.interactive,\n noInteractive: input.noInteractive,\n format: input.format,\n message: \"Which profile do you want to preview?\",\n });\n}\n\nfunction engineScopes(scope: CliPreviewScope): ProfileApplyPreviewScope[] {\n switch (scope) {\n case \"home\":\n return [\"home\"];\n case \"project\":\n return [\"project\"];\n case \"both\":\n return [\"home\", \"project\"];\n default: {\n const _exhaustive: never = scope;\n return _exhaustive;\n }\n }\n}\n\nasync function loadPreview(input: {\n profile: string;\n scope: ProfileApplyPreviewScope;\n projectPath?: string;\n harness?: string;\n}): Promise<ProfileApplyPreview> {\n return previewProfileApply({\n profile: input.profile,\n scope: input.scope,\n ...(input.projectPath ? { projectPath: input.projectPath } : {}),\n ...(input.harness ? { harness: input.harness } : {}),\n });\n}\n\nfunction printInstallGaps(preview: ProfileApplyPreview): void {\n if (preview.scope !== \"home\" || !preview.harnesses) {\n return;\n }\n for (const status of Object.values(preview.harnesses)) {\n for (const plugin of status.plugins) {\n if (plugin.state === \"missing\") {\n ui.dim(`plugin ${plugin.id} not installed`);\n }\n }\n for (const mcp of status.mcp) {\n switch (mcp.state) {\n case \"missing\":\n ui.dim(`mcp ${mcp.name} not installed`);\n break;\n case \"mismatch\":\n ui.dim(`mcp ${mcp.name} different value`);\n break;\n case \"present\":\n case \"extra\":\n break;\n default: {\n const _exhaustive: never = mcp.state;\n void _exhaustive;\n break;\n }\n }\n }\n }\n}\n\nfunction printHostManagedCollisions(preview: ProfileApplyPreview): void {\n const collisionCount = preview.host_managed?.cursor?.collisions.length ?? 0;\n if (collisionCount > 0) {\n ui.warn(\n `${formatCount(collisionCount, \"Cursor host-managed skill name collision\")} with user or profile skills.`,\n );\n }\n}\n\nfunction previewChangeLabel(change: DriftFileChange): string {\n if (driftChangeIsKept(change)) {\n return previewRemovalLabel(change.removal_group);\n }\n switch (change.type) {\n case \"deleted\":\n case \"modified\":\n return SCOPE_COPY.willWrite;\n case \"added\":\n return previewRemovalLabel(change.removal_group);\n default: {\n const unhandled: never = change.type;\n return String(unhandled);\n }\n }\n}\n\nfunction previewRemovalLabel(\n group: DriftFileChange[\"removal_group\"],\n): string {\n switch (group) {\n case \"owned_modified\":\n return SCOPE_COPY.keptYouChanged;\n case \"unmanaged\":\n return SCOPE_COPY.keptNotMadeByHarnessTap;\n case \"owned_unmodified\":\n case undefined:\n return SCOPE_COPY.willRemove;\n default: {\n const unhandled: never = group;\n return String(unhandled);\n }\n }\n}\n\nfunction printPortableMcpTips(preview: ProfileApplyPreview): void {\n const plugin = resolvePluginSelector(preview.profile);\n if (!plugin) {\n return;\n }\n const registered = registeredHarnessesOf(getHarnessPreference());\n if (registered.length === 0) {\n return;\n }\n const resources = mergePluginsForApply(collectProfilePluginIds(plugin)).resources;\n for (const resource of resources) {\n if (!isPortableMcpResource(resource)) {\n continue;\n }\n const scope = resourceHarnessScope(resource);\n if (scope.kind !== \"subset\") {\n continue;\n }\n const extra = registered.filter((id) => !scope.harnesses.includes(id));\n if (extra.length === 0) {\n continue;\n }\n const command = formatCommand([\n \"resource\",\n \"scope\",\n resource.name,\n \"--add\",\n extra.join(\",\"),\n ]);\n ui.hint(\n portableScopeTip({\n resourceName: resource.name,\n targetIds: extra,\n command,\n }),\n );\n }\n}\n\nfunction printHumanPreview(preview: ProfileApplyPreview): void {\n ui.info(\n `Profile ${preview.profile} scope=${preview.scope} root=${preview.files.root_path}`,\n );\n if (preview.relative_to_active) {\n ui.dim(\"already active\");\n }\n\n if (preview.warning) {\n ui.warn(preview.warning);\n }\n\n ui.subheader(\"Contents\");\n const contents = preview.contents;\n const hasPlugins = (contents?.plugins.length ?? 0) > 0;\n const hasPins = (contents?.plugin_pins.length ?? 0) > 0;\n if (contents?.stack_summary) {\n ui.dim(contents.stack_summary);\n }\n if (!contents || (!hasPlugins && !hasPins)) {\n ui.hint(\"Add plugins or resources from your library.\");\n } else {\n for (const plugin of contents.plugins) {\n ui.info(`plugin ${plugin.name}@${plugin.version}`);\n for (const resource of plugin.resources) {\n const scope = resource.harness_scope\n ? scopeLine(\n Array.isArray(resource.harness_scope)\n ? { kind: \"subset\", harnesses: resource.harness_scope }\n : { kind: \"all\" },\n )\n : SCOPE_COPY.appliesToAll;\n ui.dim(` ${resource.type}:${resource.name} ${scope}`);\n }\n }\n for (const pin of contents.plugin_pins) {\n ui.info(`pin ${pin.ref}@${pin.version_constraint}`);\n }\n }\n\n ui.subheader(\"Files\");\n const keptCount = preview.files.changes.filter((change) => driftChangeIsKept(change)).length;\n const wouldChange = preview.files.changes.length - keptCount;\n const keptSuffix = keptCount > 0 ? ` · ${keptCount} kept` : \"\";\n ui.dim(\n `${wouldChange} would change${keptSuffix} · ${preview.files.expected_count} managed`,\n );\n if (preview.files.changes.length === 0) {\n ui.hint(\"No file changes.\");\n } else {\n for (const change of preview.files.changes) {\n const resource = change.resource\n ? ` [${change.resource.type}:${change.resource.name}]`\n : \"\";\n ui.info(`${previewChangeLabel(change)} ${change.path}${resource}`);\n }\n }\n printInstallGaps(preview);\n\n const untracked = preview.not_staged.length > 0\n ? preview.not_staged\n : preview.untracked_resources;\n if (untracked.length > 0) {\n ui.subheader(SCOPE_COPY.notInProfile);\n for (const resource of untracked) {\n ui.info(`${resource.type}:${resource.name} ${resource.source}`);\n }\n }\n\n if (preview.recovery_actions && preview.recovery_actions.length > 0) {\n ui.subheader(\"Recovery\");\n for (const action of preview.recovery_actions) {\n ui.warn(`${action.id} ${action.label}`);\n }\n ui.hint(\"Recovery stays interactive on apply; preview does not run these.\");\n ui.hint(\"File adopt/restore is a separate command.\");\n }\n\n printHostManagedCollisions(preview);\n printPortableMcpTips(preview);\n}\n\nexport async function handleProfilePreviewCommand(\n name: string | undefined,\n opts: {\n scope?: string;\n project?: string;\n harness?: string;\n format?: string;\n interactive?: boolean;\n noInteractive?: boolean;\n },\n): Promise<void> {\n const db = getDb();\n initializeSchema(db);\n const format = parseOutputFormat(opts.format);\n const cliScope = parseCliPreviewScope(opts.scope);\n const projectPath = resolveProjectPathForScope(cliScope, opts.project);\n const harness = opts.harness?.trim() || undefined;\n\n const resolvedName = await resolvePreviewProfileName({\n name,\n format: opts.format,\n interactive: opts.interactive,\n noInteractive: opts.noInteractive,\n });\n if (!resolvedName) {\n process.exitCode = 1;\n renderCliError(missingRequiredArg(\"name\", \"profile preview\"));\n return;\n }\n\n const scopes = engineScopes(cliScope);\n const previews: ProfileApplyPreview[] = [];\n for (const scope of scopes) {\n previews.push(\n await loadPreview({\n profile: resolvedName,\n scope,\n projectPath,\n harness,\n }),\n );\n }\n\n if (format === \"json\") {\n if (cliScope === \"both\") {\n printJson({ home: previews[0], project: previews[1] });\n } else {\n printJson(previews[0]);\n }\n return;\n }\n\n if (cliScope === \"both\") {\n const [homePreview, projectPreview] = previews;\n if (homePreview === undefined || projectPreview === undefined) {\n throw new Error(\"expected home and project apply previews\");\n }\n ui.header(\"Home\");\n printHumanPreview(homePreview);\n ui.header(\"Project\");\n printHumanPreview(projectPreview);\n return;\n }\n\n const [preview] = previews;\n if (preview === undefined) {\n throw new Error(\"expected apply preview\");\n }\n printHumanPreview(preview);\n}\n\nexport function registerProfilePreviewCommand(profileCmd: Command): void {\n COMMAND_HELP_REGISTRY[\"profile.preview\"] = {\n description: PROFILE_PREVIEW_HELP.description,\n examples: [...PROFILE_PREVIEW_HELP.examples],\n };\n\n profileCmd\n .command(\"preview\")\n .argument(\"[name]\", \"Profile plugin name or selector\")\n .option(\"--scope <home|project|both>\", \"Apply preview scope\", \"home\")\n .option(\"--project <path>\", \"Project directory for project scope\", \".\")\n .option(\"--harness <slugs>\", \"Comma-separated harness slugs forwarded to preview\")\n .option(\"--format <mode>\", \"Output format: human or json\", \"human\")\n .option(\"--no-interactive\", \"Disable interactive wizards\")\n .option(\"--interactive\", \"Prompt instead of relying on explicit flags\")\n .description(PROFILE_PREVIEW_HELP.description)\n .action(async (\n name: string | undefined,\n opts: {\n scope?: string;\n project?: string;\n harness?: string;\n format?: string;\n interactive?: boolean;\n noInteractive?: boolean;\n },\n ) => {\n try {\n await handleProfilePreviewCommand(name, opts);\n } catch (error) {\n if (isPromptCancellationError(error)) {\n process.exitCode = 1;\n return;\n }\n process.exitCode = 1;\n renderCliError(error);\n }\n });\n}\n","import type { Command } from \"commander\";\nimport { registerOpenCommand } from \"./open.js\";\nimport { registerProfileLiveFileCommands } from \"./profile-live-files.js\";\nimport { registerProfilePreviewCommand } from \"./profile-preview.js\";\nimport { registerResourceDirectoriesCommand } from \"./resource-directories.js\";\n\nexport function registerParityCommands(root: Command): void {\n registerOpenCommand(root);\n}\n\nexport function registerProfileParityCommands(profileCmd: Command): void {\n registerProfilePreviewCommand(profileCmd);\n registerProfileLiveFileCommands(profileCmd);\n}\n\nexport function registerResourceParityCommands(resourceCmd: Command): void {\n registerResourceDirectoriesCommand(resourceCmd);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,IAAM,aAAa;AAAA,EACxB,cAAc;AAAA,EACd,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,uBAAuB;AAAA,EACvB,OAAO;AAAA,EACP,WAAW;AAAA,EACX,MAAM;AAAA,EACN,WAAW;AAAA,EACX,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,yBAAyB;AAC3B;AAEO,SAAS,mBAAmB,IAAoB;AACrD,SAAO,YAAY,EAAE,GAAG,QAAQ;AAClC;AAGO,SAAS,kBAAkB,OAAkC;AAClE,MA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AAA,IAClC,UAAU,CAAC,GAAG,qBAAqB,QAAQ;AAAA,EAC7C;AAEA,aACG,QAAQ,SAAS,EACjB,SAAS,UAAU,iCAAiC,EACpD,OAAO,+BAA+B,uBAAuB,MAAM,EACnE,OAAO,oBAAoB,uCAAuC,GAAG,EACrE,OAAO,qBAAqB,oDAAoD,EAChF,OAAO,mBAAmB,gCAAgC,OAAO,EACjE,OAAO,oBAAoB,6BAA6B,EACxD,OAAO,iBAAiB,6CAA6C,EACrE,YAAY,qBAAqB,WAAW,EAC5C,OAAO,OACN,MACA,SAQG;AACH,QAAI;AACF,YAAM,4BAA4B,MAAM,IAAI;AAAA,IAC9C,SAAS,OAAO;AACd,UAAI,0BAA0B,KAAK,GAAG;AACpC,gBAAQ,WAAW;AACnB;AAAA,MACF;AACA,cAAQ,WAAW;AACnB,qBAAe,KAAK;AAAA,IACtB;AAAA,EACF,CAAC;AACL;;;AClaO,SAAS,8BAA8B,YAA2B;AACvE,gCAA8B,UAAU;AACxC,kCAAgC,UAAU;AAC5C;AAEO,SAAS,+BAA+B,aAA4B;AACzE,qCAAmC,WAAW;AAChD;","names":["existsSync","readFileSync","join","targetPinRefs","existsSync","readFileSync","join","relativePath","join","join"]}