harnesstap 1.4.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/apply-ZGEAY6YZ.js +50 -0
- package/dist/{approve-FBGYQGWN.js → approve-VPVMU2MM.js} +10 -13
- package/dist/{approve-FBGYQGWN.js.map → approve-VPVMU2MM.js.map} +1 -1
- package/dist/{audit-VI4QZ6X2.js → audit-AO7AGET3.js} +11 -15
- package/dist/{audit-VI4QZ6X2.js.map → audit-AO7AGET3.js.map} +1 -1
- package/dist/{auth-4CQCDS2W.js → auth-7YRIJNXU.js} +10 -12
- package/dist/{auth-4CQCDS2W.js.map → auth-7YRIJNXU.js.map} +1 -1
- package/dist/bin.js +13 -34
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-OML4HXKT.js → chunk-262KZULH.js} +16 -22
- package/dist/chunk-262KZULH.js.map +1 -0
- package/dist/{chunk-ZUASVASP.js → chunk-26QGX47N.js} +26097 -16881
- package/dist/chunk-26QGX47N.js.map +1 -0
- package/dist/{chunk-3P6BWL5F.js → chunk-27IPOVKQ.js} +2 -2
- package/dist/{chunk-M4KLHJ6U.js → chunk-2BESDRYP.js} +8 -10
- package/dist/{chunk-M4KLHJ6U.js.map → chunk-2BESDRYP.js.map} +1 -1
- package/dist/{chunk-PCMON7Y2.js → chunk-2BWIEB2G.js} +8 -10
- package/dist/{chunk-PCMON7Y2.js.map → chunk-2BWIEB2G.js.map} +1 -1
- package/dist/{chunk-XTVGCVU4.js → chunk-2NMLWSUH.js} +41 -42
- package/dist/chunk-2NMLWSUH.js.map +1 -0
- package/dist/{chunk-TQ2NA4Z4.js → chunk-4E3G4H5B.js} +8 -2
- package/dist/chunk-4E3G4H5B.js.map +1 -0
- package/dist/chunk-4QCGTUTM.js +61 -0
- package/dist/chunk-4QCGTUTM.js.map +1 -0
- package/dist/{chunk-TPEJFLV7.js → chunk-6RKJZW2N.js} +4 -6
- package/dist/{chunk-TPEJFLV7.js.map → chunk-6RKJZW2N.js.map} +1 -1
- package/dist/{chunk-JQOKQKQT.js → chunk-7IBFH736.js} +2 -2
- package/dist/{chunk-P2C7JPLD.js → chunk-CKJIS2FM.js} +6 -6
- package/dist/{chunk-R7ZOYVN3.js → chunk-CUOEQQFI.js} +187 -59
- package/dist/chunk-CUOEQQFI.js.map +1 -0
- package/dist/{chunk-REHRUNBB.js → chunk-CWXCZBJR.js} +70 -5
- package/dist/chunk-CWXCZBJR.js.map +1 -0
- package/dist/{chunk-4ZQ2SCGY.js → chunk-FLYQEB6D.js} +509 -207
- package/dist/chunk-FLYQEB6D.js.map +1 -0
- package/dist/{chunk-U6DXASQP.js → chunk-HC7IZY75.js} +2 -2
- package/dist/{chunk-UVVZHWD2.js → chunk-I4DKV63E.js} +2 -2
- package/dist/{chunk-PNGF5EV2.js → chunk-JEC5PWNH.js} +2 -2
- package/dist/{chunk-MR7IOHSX.js → chunk-KFIRABC7.js} +16 -22
- package/dist/{chunk-MR7IOHSX.js.map → chunk-KFIRABC7.js.map} +1 -1
- package/dist/{chunk-6LTLYV5D.js → chunk-LGWFLVZQ.js} +1064 -265
- package/dist/chunk-LGWFLVZQ.js.map +1 -0
- package/dist/{chunk-RDG5DT7S.js → chunk-LX6PMOOC.js} +54 -40
- package/dist/chunk-LX6PMOOC.js.map +1 -0
- package/dist/{chunk-WGP4GUYZ.js → chunk-MILGCNBK.js} +9 -11
- package/dist/{chunk-WGP4GUYZ.js.map → chunk-MILGCNBK.js.map} +1 -1
- package/dist/chunk-MKLJBW5N.js +14 -0
- package/dist/{chunk-N3ZCH64F.js → chunk-MSKTWYHG.js} +86 -32
- package/dist/chunk-MSKTWYHG.js.map +1 -0
- package/dist/{chunk-WG5A6EAU.js → chunk-MTCCUYBZ.js} +821 -28
- package/dist/chunk-MTCCUYBZ.js.map +1 -0
- package/dist/{chunk-BPWFQKI5.js → chunk-NIFKCS7J.js} +2 -2
- package/dist/{chunk-43BDGVN3.js → chunk-NWOYPK2O.js} +56 -9
- package/dist/chunk-NWOYPK2O.js.map +1 -0
- package/dist/{chunk-3FS775NP.js → chunk-NXILQDJG.js} +85 -4
- package/dist/chunk-NXILQDJG.js.map +1 -0
- package/dist/chunk-QF73VLAW.js +31673 -0
- package/dist/chunk-QF73VLAW.js.map +1 -0
- package/dist/{chunk-RFQ3N7FB.js → chunk-QHCGA6LC.js} +11 -19
- package/dist/chunk-QHCGA6LC.js.map +1 -0
- package/dist/{chunk-L6YZE5MY.js → chunk-QPJZKWML.js} +5 -7
- package/dist/{chunk-L6YZE5MY.js.map → chunk-QPJZKWML.js.map} +1 -1
- package/dist/{chunk-ULCD6DJE.js → chunk-RM7VP6ID.js} +24 -61
- package/dist/chunk-RM7VP6ID.js.map +1 -0
- package/dist/{chunk-7HP6AAI3.js → chunk-SMLO5YPI.js} +2 -2
- package/dist/{chunk-73OJQTBW.js → chunk-T2JBSRGG.js} +2 -2
- package/dist/{chunk-IE7B6Q5K.js → chunk-U5Y6WKKT.js} +17 -18
- package/dist/chunk-U5Y6WKKT.js.map +1 -0
- package/dist/chunk-UEA4NCY2.js +106 -0
- package/dist/chunk-UEA4NCY2.js.map +1 -0
- package/dist/chunk-VAPCU2FX.js +70 -0
- package/dist/chunk-VAPCU2FX.js.map +1 -0
- package/dist/{chunk-RVEXPMM3.js → chunk-WEJVFNRO.js} +3 -5
- package/dist/{chunk-RVEXPMM3.js.map → chunk-WEJVFNRO.js.map} +1 -1
- package/dist/{chunk-IMROMZ2K.js → chunk-WWFVMCTR.js} +19 -14
- package/dist/chunk-WWFVMCTR.js.map +1 -0
- package/dist/chunk-XPONNOBR.js +102 -0
- package/dist/chunk-XPONNOBR.js.map +1 -0
- package/dist/{chunk-N3VGY3T3.js → chunk-Y3HJ2F2W.js} +7 -5
- package/dist/{chunk-N3VGY3T3.js.map → chunk-Y3HJ2F2W.js.map} +1 -1
- package/dist/{chunk-2A36HWDE.js → chunk-Y4I7ZCAE.js} +129 -136
- package/dist/chunk-Y4I7ZCAE.js.map +1 -0
- package/dist/{chunk-GRASK6M6.js → chunk-ZREU2UHM.js} +5 -5
- package/dist/{chunk-QA5U36JN.js → chunk-ZT7ANP3H.js} +774 -364
- package/dist/chunk-ZT7ANP3H.js.map +1 -0
- package/dist/{chunk-EOPFER6N.js → chunk-ZUXFPAVX.js} +19 -5
- package/dist/chunk-ZUXFPAVX.js.map +1 -0
- package/dist/{chunk-D432JAXV.js → chunk-ZWB6YXVQ.js} +153 -25
- package/dist/chunk-ZWB6YXVQ.js.map +1 -0
- package/dist/{chunk-23XSG7LI.js → chunk-ZZQDJGWX.js} +4 -4
- package/dist/{compile-GXADKGH5.js → compile-IMJHVXQO.js} +33 -37
- package/dist/{compile-GXADKGH5.js.map → compile-IMJHVXQO.js.map} +1 -1
- package/dist/{config-JMHNA2U5.js → config-FVVN3NWL.js} +16 -21
- package/dist/{config-JMHNA2U5.js.map → config-FVVN3NWL.js.map} +1 -1
- package/dist/cursor-local-install-JS5KSOES.js +94 -0
- package/dist/{cursor-local-install-46RWRBDT.js.map → cursor-local-install-JS5KSOES.js.map} +1 -1
- package/dist/{cursor-local-install-46RWRBDT.js → cursor-local-install-QU5R2FV5.js} +8 -12
- package/dist/cursor-local-install-QU5R2FV5.js.map +1 -0
- package/dist/{doctor-N7ZULPOL.js → doctor-A7VUJSCP.js} +14 -17
- package/dist/doctor-A7VUJSCP.js.map +1 -0
- package/dist/{environment-OBB3WU5B.js → environment-6INIUBNC.js} +42 -50
- package/dist/environment-6INIUBNC.js.map +1 -0
- package/dist/{github-PBYBGOLH.js → github-TFJT3P53.js} +9 -10
- package/dist/{github-PBYBGOLH.js.map → github-TFJT3P53.js.map} +1 -1
- package/dist/{harness-7KYATIV6.js → harness-WQNC5HPZ.js} +46 -84
- package/dist/harness-WQNC5HPZ.js.map +1 -0
- package/dist/{help-EE3AJQD4.js → help-NMS3EXJB.js} +15 -20
- package/dist/{help-EE3AJQD4.js.map → help-NMS3EXJB.js.map} +1 -1
- package/dist/{help-VXWKLQ6A.js → help-VW4RIICD.js} +57 -575
- package/dist/help-VW4RIICD.js.map +1 -0
- package/dist/host-plugin-view-kept-HYCHDB4D.js +139 -0
- package/dist/host-plugin-view-kept-HYCHDB4D.js.map +1 -0
- package/dist/index.js +12 -16
- package/dist/{init-LBTMPDVJ.js → init-RXYL5ZUE.js} +33 -41
- package/dist/{init-LBTMPDVJ.js.map → init-RXYL5ZUE.js.map} +1 -1
- package/dist/live-read-cache-BHU6L7MA.js +13 -0
- package/dist/live-read-cache-NQU7M2C7.js +12 -0
- package/dist/{lock-WLJRXRVK.js → lock-3H3Z65DS.js} +9 -12
- package/dist/{lock-WLJRXRVK.js.map → lock-3H3Z65DS.js.map} +1 -1
- package/dist/{marketplace-GXSV6QIY.js → marketplace-KW35PJCY.js} +26 -79
- package/dist/marketplace-KW35PJCY.js.map +1 -0
- package/dist/{mcp-XPDWWU75.js → mcp-2HUGVDJ5.js} +33 -37
- package/dist/{mcp-XPDWWU75.js.map → mcp-2HUGVDJ5.js.map} +1 -1
- package/dist/{migrate-SBUIWN3U.js → migrate-6VAPYNXI.js} +93 -34
- package/dist/migrate-6VAPYNXI.js.map +1 -0
- package/dist/notifications-Y7KQCN6K.js +154 -0
- package/dist/notifications-Y7KQCN6K.js.map +1 -0
- package/dist/open-FADABB2S.js +20 -0
- package/dist/{pack-A73LDVOX.js → pack-NTECD3BZ.js} +10 -14
- package/dist/{pack-A73LDVOX.js.map → pack-NTECD3BZ.js.map} +1 -1
- package/dist/plugin-T2YFCYIO.js +47 -0
- package/dist/plugin-from-project-FGX5AHW6.js +15 -0
- package/dist/{policy-6VY3CMSU.js → policy-3FOWB4GR.js} +9 -12
- package/dist/{policy-6VY3CMSU.js.map → policy-3FOWB4GR.js.map} +1 -1
- package/dist/{profile-YCKPMRRU.js → profile-HM3ROXXB.js} +108 -78
- package/dist/profile-HM3ROXXB.js.map +1 -0
- package/dist/{project-KHPPBKPN.js → project-3DTXKMI6.js} +512 -119
- package/dist/project-3DTXKMI6.js.map +1 -0
- package/dist/{resource-IJU3FAN5.js → resource-TZDZAVZ6.js} +55 -45
- package/dist/resource-TZDZAVZ6.js.map +1 -0
- package/dist/status-refresh-worker.js +1155 -0
- package/dist/status-refresh-worker.js.map +1 -0
- package/dist/{version-Z66FWWMQ.js → version-AMZJHJIB.js} +3 -3
- package/dist/version-AMZJHJIB.js.map +1 -0
- package/package.json +16 -11
- package/dist/apply-SUNDXRJ3.js +0 -54
- package/dist/chunk-2A36HWDE.js.map +0 -1
- package/dist/chunk-2H7UOFLK.js +0 -11
- package/dist/chunk-3FS775NP.js.map +0 -1
- package/dist/chunk-43BDGVN3.js.map +0 -1
- package/dist/chunk-4ZQ2SCGY.js.map +0 -1
- package/dist/chunk-6LTLYV5D.js.map +0 -1
- package/dist/chunk-D432JAXV.js.map +0 -1
- package/dist/chunk-DF4Z7LAD.js +0 -3463
- package/dist/chunk-DF4Z7LAD.js.map +0 -1
- package/dist/chunk-EOPFER6N.js.map +0 -1
- package/dist/chunk-G6WKY2W4.js +0 -389
- package/dist/chunk-G6WKY2W4.js.map +0 -1
- package/dist/chunk-IE7B6Q5K.js.map +0 -1
- package/dist/chunk-IMROMZ2K.js.map +0 -1
- package/dist/chunk-M2U3J7UX.js +0 -46
- package/dist/chunk-M2U3J7UX.js.map +0 -1
- package/dist/chunk-N3ZCH64F.js.map +0 -1
- package/dist/chunk-NAGAJ5UM.js +0 -145
- package/dist/chunk-NAGAJ5UM.js.map +0 -1
- package/dist/chunk-OML4HXKT.js.map +0 -1
- package/dist/chunk-QA5U36JN.js.map +0 -1
- package/dist/chunk-R7ZOYVN3.js.map +0 -1
- package/dist/chunk-RDG5DT7S.js.map +0 -1
- package/dist/chunk-REHRUNBB.js.map +0 -1
- package/dist/chunk-RFQ3N7FB.js.map +0 -1
- package/dist/chunk-TQ2NA4Z4.js.map +0 -1
- package/dist/chunk-ULCD6DJE.js.map +0 -1
- package/dist/chunk-WG5A6EAU.js.map +0 -1
- package/dist/chunk-XGTTOO4R.js +0 -84
- package/dist/chunk-XGTTOO4R.js.map +0 -1
- package/dist/chunk-XTVGCVU4.js.map +0 -1
- package/dist/chunk-XUJKZQZA.js +0 -235
- package/dist/chunk-XUJKZQZA.js.map +0 -1
- package/dist/chunk-ZUASVASP.js.map +0 -1
- package/dist/doctor-N7ZULPOL.js.map +0 -1
- package/dist/environment-OBB3WU5B.js.map +0 -1
- package/dist/harness-7KYATIV6.js.map +0 -1
- package/dist/help-VXWKLQ6A.js.map +0 -1
- package/dist/live-read-cache-TUSP7U3D.js +0 -10
- package/dist/marketplace-GXSV6QIY.js.map +0 -1
- package/dist/migrate-SBUIWN3U.js.map +0 -1
- package/dist/open-HDGLYYVU.js +0 -24
- package/dist/plugin-CEO6ZJM5.js +0 -51
- package/dist/plugin-from-project-UK7VJVUP.js +0 -18
- package/dist/profile-YCKPMRRU.js.map +0 -1
- package/dist/project-KHPPBKPN.js.map +0 -1
- package/dist/resource-IJU3FAN5.js.map +0 -1
- /package/dist/{apply-SUNDXRJ3.js.map → apply-ZGEAY6YZ.js.map} +0 -0
- /package/dist/{chunk-3P6BWL5F.js.map → chunk-27IPOVKQ.js.map} +0 -0
- /package/dist/{chunk-JQOKQKQT.js.map → chunk-7IBFH736.js.map} +0 -0
- /package/dist/{chunk-P2C7JPLD.js.map → chunk-CKJIS2FM.js.map} +0 -0
- /package/dist/{chunk-U6DXASQP.js.map → chunk-HC7IZY75.js.map} +0 -0
- /package/dist/{chunk-UVVZHWD2.js.map → chunk-I4DKV63E.js.map} +0 -0
- /package/dist/{chunk-PNGF5EV2.js.map → chunk-JEC5PWNH.js.map} +0 -0
- /package/dist/{chunk-2H7UOFLK.js.map → chunk-MKLJBW5N.js.map} +0 -0
- /package/dist/{chunk-BPWFQKI5.js.map → chunk-NIFKCS7J.js.map} +0 -0
- /package/dist/{chunk-7HP6AAI3.js.map → chunk-SMLO5YPI.js.map} +0 -0
- /package/dist/{chunk-73OJQTBW.js.map → chunk-T2JBSRGG.js.map} +0 -0
- /package/dist/{chunk-GRASK6M6.js.map → chunk-ZREU2UHM.js.map} +0 -0
- /package/dist/{chunk-23XSG7LI.js.map → chunk-ZZQDJGWX.js.map} +0 -0
- /package/dist/{live-read-cache-TUSP7U3D.js.map → live-read-cache-BHU6L7MA.js.map} +0 -0
- /package/dist/{open-HDGLYYVU.js.map → live-read-cache-NQU7M2C7.js.map} +0 -0
- /package/dist/{plugin-CEO6ZJM5.js.map → open-FADABB2S.js.map} +0 -0
- /package/dist/{plugin-from-project-UK7VJVUP.js.map → plugin-T2YFCYIO.js.map} +0 -0
- /package/dist/{version-Z66FWWMQ.js.map → plugin-from-project-FGX5AHW6.js.map} +0 -0
|
@@ -1,39 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
diagnosePackageFiles,
|
|
3
|
+
formatResourceCounts,
|
|
4
|
+
formatSkippedEntry
|
|
5
|
+
} from "./chunk-4QCGTUTM.js";
|
|
1
6
|
import {
|
|
2
7
|
formatEnvironmentToml,
|
|
3
8
|
importEnvironmentToml,
|
|
4
9
|
listEnvironmentDocuments
|
|
5
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-SMLO5YPI.js";
|
|
6
11
|
import {
|
|
7
12
|
formatResourceSelectionLabel,
|
|
8
|
-
shortenHomePath,
|
|
9
13
|
sortResourcesByUpdatedAt,
|
|
10
14
|
toResourceListRows
|
|
11
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-RM7VP6ID.js";
|
|
12
16
|
import {
|
|
13
17
|
toPluginChoices
|
|
14
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-27IPOVKQ.js";
|
|
15
19
|
import "./chunk-KRI4R7EM.js";
|
|
16
|
-
import "./chunk-XGTTOO4R.js";
|
|
17
|
-
import {
|
|
18
|
-
promptForSearchableChoice,
|
|
19
|
-
promptForValue,
|
|
20
|
-
shouldUseWizard
|
|
21
|
-
} from "./chunk-NAGAJ5UM.js";
|
|
22
20
|
import {
|
|
23
21
|
initializeSchema
|
|
24
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-NXILQDJG.js";
|
|
25
23
|
import {
|
|
26
24
|
configureCommandGroup
|
|
27
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-NWOYPK2O.js";
|
|
28
26
|
import "./chunk-I6XFZLTJ.js";
|
|
29
27
|
import {
|
|
30
28
|
parseOutputFormat,
|
|
31
29
|
printJson
|
|
32
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-4E3G4H5B.js";
|
|
33
31
|
import {
|
|
34
32
|
fail,
|
|
35
33
|
failCaught
|
|
36
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-QHCGA6LC.js";
|
|
37
35
|
import {
|
|
38
36
|
ManifestValidationError,
|
|
39
37
|
assertArchiveMembersContained,
|
|
@@ -42,6 +40,7 @@ import {
|
|
|
42
40
|
buildApPackageFilesForResource,
|
|
43
41
|
envelopeFromFiles,
|
|
44
42
|
getHarnessPreference,
|
|
43
|
+
getLatestSnapshot,
|
|
45
44
|
getPlugin,
|
|
46
45
|
getPluginById,
|
|
47
46
|
getPluginResources,
|
|
@@ -55,6 +54,7 @@ import {
|
|
|
55
54
|
listContainedFiles,
|
|
56
55
|
listPluginDependencies,
|
|
57
56
|
listPlugins,
|
|
57
|
+
listProjects,
|
|
58
58
|
listResources,
|
|
59
59
|
loadVerifiedPackageFiles,
|
|
60
60
|
parseApEnvelope,
|
|
@@ -67,31 +67,29 @@ import {
|
|
|
67
67
|
resolveResource,
|
|
68
68
|
setHarnessPreference,
|
|
69
69
|
setPluginResourceOverride,
|
|
70
|
+
shortenHomePath,
|
|
70
71
|
slugifyApName,
|
|
71
72
|
writeApEnvelope,
|
|
72
73
|
writeApPackageFiles,
|
|
73
74
|
writeApZipArchive
|
|
74
|
-
} from "./chunk-
|
|
75
|
-
import "./chunk-6LTLYV5D.js";
|
|
76
|
-
import "./chunk-N3ZCH64F.js";
|
|
75
|
+
} from "./chunk-26QGX47N.js";
|
|
77
76
|
import {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
promptForSearchableChoice,
|
|
78
|
+
promptForValue,
|
|
79
|
+
shouldUseWizard
|
|
80
|
+
} from "./chunk-LGWFLVZQ.js";
|
|
81
|
+
import "./chunk-MSKTWYHG.js";
|
|
83
82
|
import {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
import "./chunk-G6WKY2W4.js";
|
|
88
|
-
import "./chunk-73OJQTBW.js";
|
|
83
|
+
loadSettings
|
|
84
|
+
} from "./chunk-CWXCZBJR.js";
|
|
85
|
+
import "./chunk-T2JBSRGG.js";
|
|
89
86
|
import {
|
|
90
87
|
formatCount,
|
|
91
88
|
getDb,
|
|
92
89
|
getHarnesstapDir,
|
|
93
|
-
skippedInvalidPluginExport
|
|
94
|
-
|
|
90
|
+
skippedInvalidPluginExport,
|
|
91
|
+
ui
|
|
92
|
+
} from "./chunk-MTCCUYBZ.js";
|
|
95
93
|
|
|
96
94
|
// src/services/migrate-scope.ts
|
|
97
95
|
import { existsSync as existsSync3, statSync as statSync3 } from "fs";
|
|
@@ -440,6 +438,21 @@ function importResourceFromFile(filePath) {
|
|
|
440
438
|
}
|
|
441
439
|
|
|
442
440
|
// src/services/migrate-scope.ts
|
|
441
|
+
var ImportSkippedFilesError = class extends Error {
|
|
442
|
+
diagnostics;
|
|
443
|
+
constructor(diagnostics) {
|
|
444
|
+
const count = diagnostics.skipped.length;
|
|
445
|
+
super(
|
|
446
|
+
[
|
|
447
|
+
`Not imported: ${count} ${count === 1 ? "file was" : "files were"} skipped.`,
|
|
448
|
+
...diagnostics.skipped.map((item) => ` ${formatSkippedEntry(item)}`),
|
|
449
|
+
"Fix the files, or pass --no-strict to import the rest anyway."
|
|
450
|
+
].join("\n")
|
|
451
|
+
);
|
|
452
|
+
this.name = "ImportSkippedFilesError";
|
|
453
|
+
this.diagnostics = diagnostics;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
443
456
|
function countScopeFlags(opts) {
|
|
444
457
|
let count = 0;
|
|
445
458
|
if (opts.workspace) count++;
|
|
@@ -646,7 +659,7 @@ function exportScopedMigration(resolved, opts) {
|
|
|
646
659
|
}
|
|
647
660
|
}
|
|
648
661
|
}
|
|
649
|
-
function importScopedMigration(scope, filePath) {
|
|
662
|
+
function importScopedMigration(scope, filePath, options = {}) {
|
|
650
663
|
const resolved = resolve3(filePath);
|
|
651
664
|
switch (scope) {
|
|
652
665
|
case "workspace": {
|
|
@@ -660,12 +673,18 @@ function importScopedMigration(scope, filePath) {
|
|
|
660
673
|
}
|
|
661
674
|
case "plugin": {
|
|
662
675
|
const files = loadVerifiedPackageFiles(resolved);
|
|
676
|
+
const diagnostics = diagnosePackageFiles(files);
|
|
677
|
+
if (options.strict && diagnostics.skipped.length > 0) {
|
|
678
|
+
throw new ImportSkippedFilesError(diagnostics);
|
|
679
|
+
}
|
|
663
680
|
const plugin = importApPackageFiles(files);
|
|
664
681
|
return {
|
|
665
682
|
scope: "plugin",
|
|
666
683
|
plugin: plugin.name,
|
|
667
684
|
plugins: [plugin.name],
|
|
668
|
-
resources_imported: getPluginResources(plugin.id).length
|
|
685
|
+
resources_imported: getPluginResources(plugin.id).length,
|
|
686
|
+
skipped: diagnostics.skipped,
|
|
687
|
+
resource_counts: diagnostics.counts
|
|
669
688
|
};
|
|
670
689
|
}
|
|
671
690
|
case "resource": {
|
|
@@ -876,7 +895,7 @@ function printMigrateExportHuman(result) {
|
|
|
876
895
|
switch (result.scope) {
|
|
877
896
|
case "workspace":
|
|
878
897
|
ui.success(
|
|
879
|
-
`Exported migration archive ${ui.icons.hint} ${output} ${ui.icons.bullet} ${result.manifest.plugin_count}
|
|
898
|
+
`Exported migration archive ${ui.icons.hint} ${output} ${ui.icons.bullet} ${formatCount(result.manifest.plugin_count, "plugin")}, ${formatCount(result.manifest.environment_count, "environment")}`
|
|
880
899
|
);
|
|
881
900
|
return;
|
|
882
901
|
case "plugin":
|
|
@@ -903,9 +922,18 @@ function printMigrateImportHuman(result) {
|
|
|
903
922
|
);
|
|
904
923
|
return;
|
|
905
924
|
case "plugin":
|
|
925
|
+
for (const item of result.skipped) {
|
|
926
|
+
ui.warn(`skipped ${formatSkippedEntry(item)}`);
|
|
927
|
+
}
|
|
906
928
|
ui.success(
|
|
907
929
|
`Imported plugin ${ui.theme.accent(result.plugin)} ${ui.icons.bullet} ${formatCount(result.resources_imported, "resource")}`
|
|
908
930
|
);
|
|
931
|
+
ui.info(`Resources, imported of discovered: ${formatResourceCounts(result.resource_counts)}`);
|
|
932
|
+
if (result.skipped.length > 0) {
|
|
933
|
+
ui.warn(
|
|
934
|
+
`${formatCount(result.skipped.length, "file")} not imported. Fix them and import again; --strict refuses the import instead.`
|
|
935
|
+
);
|
|
936
|
+
}
|
|
909
937
|
return;
|
|
910
938
|
case "resource":
|
|
911
939
|
ui.success(
|
|
@@ -988,13 +1016,41 @@ async function handleMigrateImportCommand(file, opts = {}) {
|
|
|
988
1016
|
}
|
|
989
1017
|
try {
|
|
990
1018
|
const scope = scopeOverride ?? resolveImportScope({ ...opts, file: importFile });
|
|
991
|
-
const
|
|
1019
|
+
const strict = opts.strict ?? !shouldUseWizard({
|
|
1020
|
+
interactive: true,
|
|
1021
|
+
noInteractive: opts.noInteractive,
|
|
1022
|
+
format: opts.format,
|
|
1023
|
+
missingRequiredArgs: false
|
|
1024
|
+
});
|
|
1025
|
+
const result = importScopedMigration(scope, importFile, { strict });
|
|
992
1026
|
if (format === "json") {
|
|
993
1027
|
printJson(result);
|
|
994
1028
|
return;
|
|
995
1029
|
}
|
|
996
1030
|
printMigrateImportHuman(result);
|
|
997
1031
|
} catch (err) {
|
|
1032
|
+
if (err instanceof ImportSkippedFilesError) {
|
|
1033
|
+
if (format === "json") {
|
|
1034
|
+
printJson({
|
|
1035
|
+
scope: "plugin",
|
|
1036
|
+
imported: false,
|
|
1037
|
+
error: "skipped_files",
|
|
1038
|
+
skipped: err.diagnostics.skipped,
|
|
1039
|
+
resource_counts: err.diagnostics.counts
|
|
1040
|
+
});
|
|
1041
|
+
process.exitCode = 1;
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
for (const item of err.diagnostics.skipped) {
|
|
1045
|
+
ui.warn(`skipped ${formatSkippedEntry(item)}`);
|
|
1046
|
+
}
|
|
1047
|
+
ui.info(`Would import, of discovered: ${formatResourceCounts(err.diagnostics.counts)}`);
|
|
1048
|
+
fail(
|
|
1049
|
+
`Not imported: ${formatCount(err.diagnostics.skipped.length, "file")} would be skipped.`,
|
|
1050
|
+
{ hint: "Fix the files, or pass --no-strict to import the rest anyway." }
|
|
1051
|
+
);
|
|
1052
|
+
return;
|
|
1053
|
+
}
|
|
998
1054
|
failCaught(err);
|
|
999
1055
|
}
|
|
1000
1056
|
}
|
|
@@ -1045,6 +1101,9 @@ function registerMigrateCommands(root) {
|
|
|
1045
1101
|
"[file]",
|
|
1046
1102
|
"package directory, .ap.json envelope, or .tar.gz workspace archive"
|
|
1047
1103
|
).option("--workspace", "Force workspace archive import").option("--plugin", "Force Agent Plugins package import").option("--resource", "Force single-resource package import").option(
|
|
1104
|
+
"--strict",
|
|
1105
|
+
"Refuse a plugin package with skipped files (default when not interactive)"
|
|
1106
|
+
).option("--no-strict", "Import a plugin package even when some files are skipped").option(
|
|
1048
1107
|
"--environment",
|
|
1049
1108
|
"Removed: environments are machine-local; use --workspace"
|
|
1050
1109
|
).option("--format <mode>", "Output format: human or json", "human").description("Import workspace, plugin, or resource from file").action(handleMigrateImportCommand);
|
|
@@ -1055,4 +1114,4 @@ function registerMigrateCommands(root) {
|
|
|
1055
1114
|
export {
|
|
1056
1115
|
registerMigrateCommands
|
|
1057
1116
|
};
|
|
1058
|
-
//# sourceMappingURL=migrate-
|
|
1117
|
+
//# sourceMappingURL=migrate-6VAPYNXI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/migrate-scope.ts","../src/services/migrate.ts","../src/services/resource-import-export.ts","../src/services/order-to-override-migration.ts","../src/services/wizards/migrate-export.ts","../src/services/wizards/migrate-import.ts","../src/cli/commands/migrate.ts"],"sourcesContent":["import { existsSync, statSync } from \"node:fs\";\nimport { extname, join, resolve } from \"node:path\";\nimport { getPlugin, getPluginResources } from \"../models/plugin-model.js\";\nimport type { Plugin } from \"../types.js\";\nimport {\n buildApPackageFiles,\n writeApPackageFiles,\n writeApZipArchive,\n} from \"./agent-plugins/files.js\";\nimport { importApPackageFiles } from \"./agent-plugins/import.js\";\nimport {\n diagnosePackageFiles,\n formatSkippedEntry,\n type PackageImportDiagnostics,\n type PackageResourceCount,\n} from \"./agent-plugins/import-diagnostics.js\";\nimport type { ApLoadSkipped } from \"./agent-plugins/spec-load.js\";\nimport {\n isApEnvelopePath,\n writeApEnvelope,\n} from \"./agent-plugins/envelope.js\";\nimport { slugifyApName } from \"./agent-plugins/name.js\";\nimport { loadVerifiedPackageFiles } from \"./apm-bundle.js\";\nimport {\n isLegacyTomlTransportPath,\n legacyTomlTransportRejection,\n} from \"./legacy-toml-transport.js\";\nimport type { AnyMigrateManifest, MigrateManifest } from \"./migrate.js\";\nimport { exportMigrationState, importMigrationState } from \"./migrate.js\";\nimport { assertPluginsCleanForShare } from \"./plugin-versioning.js\";\nimport {\n exportResourceToFile,\n formatResourceSelector,\n importResourceFromFile,\n} from \"./resource-import-export.js\";\n\nexport type MigrateScope = \"workspace\" | \"plugin\" | \"resource\";\n\nexport interface MigrateExportCliOpts {\n file?: string;\n outputFile?: string;\n workspace?: boolean;\n plugin?: string;\n resource?: string;\n /** Deprecated: rejected by {@link rejectEnvironmentScope}. */\n environment?: string;\n includePlugins?: boolean;\n embedPlugins?: boolean;\n singleFile?: boolean;\n /** Write a .zip of the Agent Plugins package. */\n archive?: boolean;\n /** Also write Copilot files and Codex hook settings. Plugin scope only. */\n vendorExtensions?: boolean;\n onSkip?: (message: string) => void;\n}\n\nexport interface MigrateImportCliOpts {\n file?: string;\n workspace?: boolean;\n plugin?: boolean;\n resource?: boolean;\n /** Deprecated: rejected by {@link rejectEnvironmentScope}. */\n environment?: boolean | string;\n}\n\nexport type WorkspaceExportResult = {\n scope: \"workspace\";\n output: string;\n manifest: MigrateManifest;\n};\n\nexport type PluginExportResult = {\n scope: \"plugin\";\n output: string;\n plugins: string[];\n files: string[];\n};\n\nexport type ResourceExportResult = {\n scope: \"resource\";\n output: string;\n resource: string;\n files: string[];\n};\n\nexport type ScopedExportResult =\n | WorkspaceExportResult\n | PluginExportResult\n | ResourceExportResult;\n\nexport type WorkspaceImportResult = {\n scope: \"workspace\";\n manifest: AnyMigrateManifest;\n plugins_imported: number;\n environments_imported: number;\n};\n\nexport type PluginImportResult = {\n scope: \"plugin\";\n plugin: string;\n plugins: string[];\n resources_imported: number;\n /** Package files that were not imported, with the reason for each. */\n skipped: ApLoadSkipped[];\n /** Discovered versus imported resources per type. */\n resource_counts: PackageResourceCount[];\n};\n\nexport interface ScopedImportOptions {\n /** Refuse a plugin package that would leave files behind; nothing is written. */\n strict?: boolean;\n}\n\n/** Strict plugin import found files it would not import. */\nexport class ImportSkippedFilesError extends Error {\n readonly diagnostics: PackageImportDiagnostics;\n\n constructor(diagnostics: PackageImportDiagnostics) {\n const count = diagnostics.skipped.length;\n super(\n [\n `Not imported: ${count} ${count === 1 ? \"file was\" : \"files were\"} skipped.`,\n ...diagnostics.skipped.map((item) => ` ${formatSkippedEntry(item)}`),\n \"Fix the files, or pass --no-strict to import the rest anyway.\",\n ].join(\"\\n\"),\n );\n this.name = \"ImportSkippedFilesError\";\n this.diagnostics = diagnostics;\n }\n}\n\nexport type ResourceImportResult = {\n scope: \"resource\";\n resource: string;\n action: \"created\" | \"updated\" | \"unchanged\";\n};\n\nexport type ScopedImportResult =\n | WorkspaceImportResult\n | PluginImportResult\n | ResourceImportResult;\n\nfunction countScopeFlags(opts: {\n workspace?: boolean;\n plugin?: string | boolean;\n resource?: string | boolean;\n}): number {\n let count = 0;\n if (opts.workspace) count++;\n if (opts.plugin) count++;\n if (opts.resource) count++;\n return count;\n}\n\nexport function assertExclusiveScopeFlags(opts: {\n workspace?: boolean;\n plugin?: string | boolean;\n resource?: string | boolean;\n}): void {\n if (countScopeFlags(opts) > 1) {\n throw new Error(\"Choose only one of --workspace, --plugin, or --resource.\");\n }\n}\n\nexport function rejectEnvironmentScope(opts: { environment?: string | boolean }): void {\n if (opts.environment) {\n throw new Error(\n \"Environments are no longer exported on their own: they are machine-local \" +\n \"secret references. Use --workspace to back them up with everything else.\",\n );\n }\n}\n\nfunction embedPlugins(opts: MigrateExportCliOpts): boolean {\n return opts.includePlugins ?? opts.embedPlugins ?? false;\n}\n\nfunction resolvePluginOrThrow(selector: string): Plugin {\n const first = selector.split(\",\")[0]?.trim() ?? selector;\n const plugin = getPlugin(first);\n if (!plugin) {\n throw new Error(`Plugin not found: ${first}`);\n }\n return plugin;\n}\n\nexport function resolveExportScope(opts: MigrateExportCliOpts): {\n scope: MigrateScope;\n outputPath: string;\n pluginSelector?: string;\n resourceSelector?: string;\n singleFile: boolean;\n archive: boolean;\n} {\n rejectEnvironmentScope(opts);\n assertExclusiveScopeFlags(opts);\n const outputPath = opts.outputFile ?? opts.file;\n const resolvedExplicit =\n outputPath && outputPath.length > 0 ? resolve(outputPath) : undefined;\n const pathIsZip = resolvedExplicit?.toLowerCase().endsWith(\".zip\") === true;\n const archive = opts.archive === true || pathIsZip;\n if (opts.singleFile === true && archive) {\n throw new Error(\"Choose a package directory, a .zip, or a .ap.json envelope.\");\n }\n const singleFile =\n !archive && (\n opts.singleFile === true\n || (resolvedExplicit != null && isApEnvelopePath(resolvedExplicit))\n );\n\n if (opts.plugin) {\n const firstPlugin = opts.plugin.split(\",\")[0]?.trim() ?? \"plugin\";\n const apName = slugifyApName(firstPlugin);\n const path = resolvedExplicit ?? resolve(\n archive ? `${apName}.zip` : singleFile ? `${apName}.ap.json` : apName,\n );\n return {\n scope: \"plugin\",\n outputPath: path,\n pluginSelector: opts.plugin,\n singleFile,\n archive,\n };\n }\n\n if (opts.resource) {\n const colon = opts.resource.indexOf(\":\");\n const rest = colon === -1 ? opts.resource : opts.resource.slice(colon + 1);\n const name = slugifyApName(rest.split(\"@\")[0] ?? \"export\");\n const path = resolvedExplicit ?? resolve(singleFile ? `${name}.ap.json` : name);\n if (archive) {\n throw new Error(\"Resource export writes a directory or a .ap.json envelope.\");\n }\n return {\n scope: \"resource\",\n outputPath: path,\n resourceSelector: opts.resource,\n singleFile,\n archive: false,\n };\n }\n\n if (opts.workspace) {\n if (!outputPath || outputPath.length === 0) {\n throw new Error(\"Output path is required for workspace export.\");\n }\n return { scope: \"workspace\", outputPath: resolve(outputPath), singleFile: false, archive: false };\n }\n\n if (outputPath && outputPath.length > 0) {\n const resolvedOutput = resolve(outputPath);\n const lower = resolvedOutput.toLowerCase();\n if (lower.endsWith(\".tar.gz\")) {\n return { scope: \"workspace\", outputPath: resolvedOutput, singleFile: false, archive: false };\n }\n if (\n extname(resolvedOutput).toLowerCase() === \".json\"\n && !isApEnvelopePath(resolvedOutput)\n ) {\n return { scope: \"workspace\", outputPath: resolvedOutput, singleFile: false, archive: false };\n }\n }\n\n throw new Error(\n \"Specify export scope: --workspace, --plugin <name>, or --resource <selector>.\",\n );\n}\n\nexport function detectImportScopeFromFile(filePath: string): MigrateScope {\n const resolved = resolve(filePath);\n if (statSync(resolved).isDirectory()) {\n if (!existsSync(join(resolved, \"plugin.json\"))) {\n throw new Error(\n `${resolved} is a directory but has no plugin.json: expected an Agent Plugins package.`,\n );\n }\n return \"plugin\";\n }\n const lower = resolved.toLowerCase();\n if (lower.endsWith(\".tar.gz\")) return \"workspace\";\n if (isApEnvelopePath(resolved) || lower.endsWith(\".zip\")) return \"plugin\";\n if (isLegacyTomlTransportPath(resolved)) {\n throw new Error(legacyTomlTransportRejection(resolved));\n }\n throw new Error(\n `Cannot tell what ${resolved} is. Pass an Agent Plugins package directory, ` +\n \"an .ap.json envelope, or a .tar.gz workspace archive.\",\n );\n}\n\nexport function resolveImportScope(opts: MigrateImportCliOpts): MigrateScope {\n rejectEnvironmentScope(opts);\n assertExclusiveScopeFlags({\n workspace: opts.workspace,\n plugin: opts.plugin,\n resource: opts.resource,\n });\n if (!opts.file || opts.file.length === 0) {\n throw new Error(\"Import file path is required.\");\n }\n\n let scope: MigrateScope;\n if (opts.workspace) {\n scope = \"workspace\";\n } else if (opts.plugin) {\n scope = \"plugin\";\n } else if (opts.resource) {\n scope = \"resource\";\n } else {\n return detectImportScopeFromFile(opts.file);\n }\n\n const detected = detectImportScopeFromFile(opts.file);\n if (detected !== scope) {\n throw new Error(\n `Import file looks like ${detected} data but --${scope} was specified.`,\n );\n }\n return scope;\n}\n\nexport function exportScopedMigration(\n resolved: ReturnType<typeof resolveExportScope>,\n opts: MigrateExportCliOpts,\n): ScopedExportResult {\n const includePlugins = embedPlugins(opts);\n\n switch (resolved.scope) {\n case \"workspace\": {\n const manifest = exportMigrationState({\n outputPath: resolved.outputPath,\n includePlugins,\n ...(opts.onSkip ? { onSkip: opts.onSkip } : {}),\n });\n return {\n scope: \"workspace\",\n output: resolved.outputPath,\n manifest,\n };\n }\n case \"plugin\": {\n if (!resolved.pluginSelector) {\n throw new Error(\"Plugin selector is required for plugin export.\");\n }\n const plugin = resolvePluginOrThrow(resolved.pluginSelector);\n assertPluginsCleanForShare([plugin]);\n const files = buildApPackageFiles(plugin.id, {\n vendorExtensions: opts.vendorExtensions === true,\n });\n let written: string[];\n if (resolved.archive) {\n if (existsSync(resolved.outputPath) && statSync(resolved.outputPath).isDirectory()) {\n throw new Error(\n `Refusing to replace directory ${resolved.outputPath} with a zip archive.`,\n );\n }\n written = writeApZipArchive(files, resolved.outputPath);\n } else if (resolved.singleFile) {\n writeApEnvelope(files, resolved.outputPath);\n written = Object.keys(files).sort();\n } else {\n written = writeApPackageFiles(files, resolved.outputPath);\n }\n return {\n scope: \"plugin\",\n output: resolved.outputPath,\n plugins: [plugin.name],\n files: written,\n };\n }\n case \"resource\": {\n if (!resolved.resourceSelector) {\n throw new Error(\"Resource selector is required for resource export.\");\n }\n const exportDoc = exportResourceToFile(\n resolved.resourceSelector,\n resolved.outputPath,\n { singleFile: resolved.singleFile },\n );\n return {\n scope: \"resource\",\n output: resolved.outputPath,\n resource: formatResourceSelector(exportDoc),\n files: exportDoc.files,\n };\n }\n default: {\n const neverScope: never = resolved.scope;\n throw new Error(`Unsupported export scope: ${neverScope}`);\n }\n }\n}\n\nexport function importScopedMigration(\n scope: MigrateScope,\n filePath: string,\n options: ScopedImportOptions = {},\n): ScopedImportResult {\n const resolved = resolve(filePath);\n\n switch (scope) {\n case \"workspace\": {\n const result = importMigrationState({ archivePath: resolved });\n return {\n scope: \"workspace\",\n manifest: result.manifest,\n plugins_imported: result.plugins_imported,\n environments_imported: result.environments_imported,\n };\n }\n case \"plugin\": {\n const files = loadVerifiedPackageFiles(resolved);\n const diagnostics = diagnosePackageFiles(files);\n if (options.strict && diagnostics.skipped.length > 0) {\n throw new ImportSkippedFilesError(diagnostics);\n }\n const plugin = importApPackageFiles(files);\n return {\n scope: \"plugin\",\n plugin: plugin.name,\n plugins: [plugin.name],\n resources_imported: getPluginResources(plugin.id).length,\n skipped: diagnostics.skipped,\n resource_counts: diagnostics.counts,\n };\n }\n case \"resource\": {\n const result = importResourceFromFile(resolved);\n return {\n scope: \"resource\",\n resource: formatResourceSelector(result.resource),\n action: result.action,\n };\n }\n default: {\n const neverScope: never = scope;\n throw new Error(`Unsupported import scope: ${neverScope}`);\n }\n }\n}\n","import {\n cpSync,\n existsSync,\n mkdirSync,\n mkdtempSync,\n readFileSync,\n readdirSync,\n rmSync,\n statSync,\n writeFileSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join, resolve } from \"node:path\";\nimport { execSync } from \"node:child_process\";\nimport { getHarnesstapDir } from \"../db/connection.js\";\nimport { getHarnessPreference, setHarnessPreference } from \"../models/harness.js\";\nimport { listPlugins } from \"../models/plugin-model.js\";\nimport { loadSettings } from \"../config/settings.js\";\nimport type { HarnesstapSettings } from \"../config/settings.js\";\nimport type { HarnessPreference, HarnessSelection } from \"../types.js\";\nimport { registeredFromLegacyParts } from \"./harness-targets.js\";\nimport {\n formatEnvironmentToml,\n importEnvironmentToml,\n listEnvironmentDocuments,\n} from \"./environment-import-export.js\";\nimport { listContainedFiles, assertArchiveMembersContained } from \"../utils/path-containment.js\";\nimport {\n buildApPackageFiles,\n writeApPackageFiles,\n readApPackageFiles,\n} from \"./agent-plugins/files.js\";\nimport { importApPackageFiles } from \"./agent-plugins/import.js\";\nimport { slugifyApName } from \"./agent-plugins/name.js\";\nimport { ManifestValidationError } from \"./agent-plugins/validate.js\";\nimport { skippedInvalidPluginExport } from \"../copy/cli.js\";\nimport {\n envelopeFromFiles,\n parseApEnvelope,\n} from \"./agent-plugins/envelope.js\";\nimport { isLegacyPluginTomlPath } from \"./legacy-toml-transport.js\";\n\nfunction selectionFromArchive(raw: unknown): HarnessSelection {\n const rec = (raw ?? {}) as Record<string, unknown>;\n if (Array.isArray(rec.registered_harnesses)) {\n return {\n registered_harnesses: rec.registered_harnesses.filter(\n (entry): entry is string => typeof entry === \"string\",\n ),\n };\n }\n return {\n registered_harnesses: registeredFromLegacyParts(\n typeof rec.main_harness === \"string\" ? rec.main_harness : null,\n Array.isArray(rec.alias_harnesses)\n ? rec.alias_harnesses.filter((entry): entry is string => typeof entry === \"string\")\n : [],\n ),\n };\n}\n\nexport const MIGRATE_MANIFEST_VERSION_V1 = 1 as const;\nexport const MIGRATE_MANIFEST_VERSION = 2 as const;\n\nexport interface MigrateManifestV1 {\n version: typeof MIGRATE_MANIFEST_VERSION_V1;\n exported_at: string;\n plugin_count: number;\n include_plugins: boolean;\n includes_active_profile: boolean;\n}\n\nexport interface MigrateManifest {\n version: typeof MIGRATE_MANIFEST_VERSION;\n exported_at: string;\n plugin_count: number;\n environment_count: number;\n /** Slugified plugin directory names packed under `plugins/`. */\n plugins: string[];\n include_plugins: boolean;\n includes_active_profile: boolean;\n}\n\nexport type AnyMigrateManifest = MigrateManifestV1 | MigrateManifest;\n\nexport interface MigrateExportOptions {\n outputPath: string;\n includePlugins?: boolean;\n onSkip?: (message: string) => void;\n}\n\nexport interface MigrateImportOptions {\n archivePath: string;\n}\n\nfunction writeJson(path: string, data: unknown): void {\n writeFileSync(path, JSON.stringify(data, null, 2), \"utf-8\");\n}\n\nfunction listArchiveMembers(archivePath: string): string[] {\n const listing = execSync(`tar -tzf \"${archivePath}\"`, {\n encoding: \"utf-8\",\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n return listing\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter((line) => line.length > 0);\n}\n\nfunction extractArchive(archivePath: string, destDir: string): void {\n const resolved = resolve(archivePath);\n if (resolved.endsWith(\".json\") && !resolved.endsWith(\".ap.json\")) {\n mkdirSync(join(destDir, \"state\"), { recursive: true });\n cpSync(resolved, join(destDir, \"state\", \"migrate.json\"));\n return;\n }\n // Reject path-traversal members before write; post-walk only sees files under destDir.\n assertArchiveMembersContained(destDir, listArchiveMembers(resolved));\n execSync(`tar -xzf \"${resolved}\" -C \"${destDir}\"`, { stdio: \"pipe\" });\n // Catch in-tree symlink escapes that resolve outside the destination.\n listContainedFiles(destDir);\n}\n\nfunction createArchive(sourceDir: string, outputPath: string): void {\n const resolved = resolve(outputPath);\n if (resolved.endsWith(\".json\") && !resolved.endsWith(\".ap.json\")) {\n const manifest = readFileSync(join(sourceDir, \"manifest.json\"), \"utf-8\");\n const environmentsDir = join(sourceDir, \"environments\");\n const pluginsDir = join(sourceDir, \"plugins\");\n const plugins: unknown[] = [];\n if (existsSync(pluginsDir)) {\n for (const entry of readdirSync(pluginsDir)) {\n const packageDir = join(pluginsDir, entry);\n if (!statSync(packageDir).isDirectory()) continue;\n if (!existsSync(join(packageDir, \"plugin.json\"))) {\n throw new Error(\n `Archive plugin directory ${entry} is missing plugin.json`,\n );\n }\n plugins.push(envelopeFromFiles(readApPackageFiles(packageDir)));\n }\n }\n const state: Record<string, unknown> = {\n manifest: JSON.parse(manifest) as AnyMigrateManifest,\n harness: existsSync(join(sourceDir, \"harness.json\"))\n ? JSON.parse(readFileSync(join(sourceDir, \"harness.json\"), \"utf-8\"))\n : null,\n config: existsSync(join(sourceDir, \"config.json\"))\n ? JSON.parse(readFileSync(join(sourceDir, \"config.json\"), \"utf-8\"))\n : null,\n active_profile: existsSync(join(sourceDir, \"active-profile.json\"))\n ? JSON.parse(readFileSync(join(sourceDir, \"active-profile.json\"), \"utf-8\"))\n : null,\n plugins,\n };\n if (existsSync(environmentsDir)) {\n state.environments = readdirSync(environmentsDir)\n .filter((f) => f.endsWith(\".toml\"))\n .map((f) => readFileSync(join(environmentsDir, f), \"utf-8\"));\n }\n writeFileSync(resolved, JSON.stringify(state, null, 2), \"utf-8\");\n return;\n }\n execSync(`tar -czf \"${resolved}\" -C \"${sourceDir}\" .`, { stdio: \"pipe\" });\n}\n\nfunction dirnameSafe(path: string): string {\n const idx = path.lastIndexOf(\"/\");\n return idx >= 0 ? path.slice(0, idx) : \".\";\n}\n\nfunction isMigrateManifestV1(manifest: AnyMigrateManifest): manifest is MigrateManifestV1 {\n return manifest.version === MIGRATE_MANIFEST_VERSION_V1;\n}\n\n/**\n * Export all plugins, environments, harness preferences, and config into an archive.\n */\nexport function exportMigrationState(opts: MigrateExportOptions): MigrateManifest {\n const workDir = mkdtempSync(join(tmpdir(), \"harnesstap-migrate-\"));\n const pluginsDir = join(workDir, \"plugins\");\n const environmentsDir = join(workDir, \"environments\");\n mkdirSync(pluginsDir, { recursive: true });\n mkdirSync(environmentsDir, { recursive: true });\n\n const plugins = listPlugins();\n const pluginNames: string[] = [];\n for (const plugin of plugins) {\n const slug = slugifyApName(plugin.name);\n const packageDir = join(pluginsDir, slug);\n try {\n writeApPackageFiles(buildApPackageFiles(plugin.id), packageDir);\n pluginNames.push(slug);\n } catch (error) {\n if (error instanceof ManifestValidationError) {\n opts.onSkip?.(skippedInvalidPluginExport(plugin.name));\n continue;\n }\n throw error;\n }\n }\n\n const environments = listEnvironmentDocuments();\n for (const environment of environments) {\n writeFileSync(\n join(environmentsDir, `${environment.name}.toml`),\n formatEnvironmentToml(environment),\n \"utf-8\",\n );\n }\n\n const harness = getHarnessPreference();\n if (harness) {\n writeJson(join(workDir, \"harness.json\"), harness);\n }\n\n const config = loadSettings(getHarnesstapDir());\n writeJson(join(workDir, \"config.json\"), config);\n const harnesstapDir = getHarnesstapDir();\n const activeProfilePath = join(harnesstapDir, \"active-profile.json\");\n const includesActiveProfile = existsSync(activeProfilePath);\n if (includesActiveProfile) {\n cpSync(activeProfilePath, join(workDir, \"active-profile.json\"));\n }\n\n const manifest: MigrateManifest = {\n version: MIGRATE_MANIFEST_VERSION,\n exported_at: new Date().toISOString(),\n plugin_count: plugins.length,\n environment_count: environments.length,\n plugins: pluginNames,\n include_plugins: opts.includePlugins ?? false,\n includes_active_profile: includesActiveProfile,\n };\n writeJson(join(workDir, \"manifest.json\"), manifest);\n\n mkdirSync(dirnameSafe(resolve(opts.outputPath)), { recursive: true });\n createArchive(workDir, opts.outputPath);\n rmSync(workDir, { recursive: true, force: true });\n\n return manifest;\n}\n\nfunction importEnvironmentsFromDir(environmentsDir: string): number {\n if (!existsSync(environmentsDir)) {\n return 0;\n }\n let imported = 0;\n for (const file of readdirSync(environmentsDir)) {\n if (!file.endsWith(\".toml\")) continue;\n importEnvironmentToml(readFileSync(join(environmentsDir, file), \"utf-8\"));\n imported++;\n }\n return imported;\n}\n\nfunction importPluginsFromDir(pluginsDir: string): number {\n if (!existsSync(pluginsDir)) {\n return 0;\n }\n let imported = 0;\n for (const entry of readdirSync(pluginsDir)) {\n const packageDir = join(pluginsDir, entry);\n if (!statSync(packageDir).isDirectory()) {\n if (isLegacyPluginTomlPath(entry) || entry.endsWith(\".toml\")) {\n throw new Error(\n \"This archive stores plugins as TOML, which is no longer supported. \" +\n \"Re-export with a current CLI to produce Agent Plugins packages.\",\n );\n }\n continue;\n }\n if (!existsSync(join(packageDir, \"plugin.json\"))) {\n throw new Error(\n `Archive plugin directory ${entry} is missing plugin.json`,\n );\n }\n importApPackageFiles(readApPackageFiles(packageDir));\n imported++;\n }\n return imported;\n}\n\n/**\n * Import a migration archive produced by exportMigrationState.\n */\nexport function importMigrationState(opts: MigrateImportOptions): {\n manifest: AnyMigrateManifest;\n plugins_imported: number;\n environments_imported: number;\n} {\n const workDir = mkdtempSync(join(tmpdir(), \"harnesstap-migrate-import-\"));\n\n try {\n extractArchive(opts.archivePath, workDir);\n\n let manifest: AnyMigrateManifest;\n let pluginsDir: string;\n let environmentsDir: string;\n let harnessPath: string;\n let configPath: string;\n\n if (existsSync(join(workDir, \"state\", \"migrate.json\"))) {\n const state = JSON.parse(\n readFileSync(join(workDir, \"state\", \"migrate.json\"), \"utf-8\"),\n ) as {\n manifest: AnyMigrateManifest;\n harness: HarnessPreference | null;\n config: HarnesstapSettings;\n active_profile: { name?: string } | null;\n plugins: unknown[];\n environments?: string[];\n };\n manifest = state.manifest;\n pluginsDir = join(workDir, \"import-plugins\");\n environmentsDir = join(workDir, \"import-environments\");\n mkdirSync(pluginsDir, { recursive: true });\n mkdirSync(environmentsDir, { recursive: true });\n for (let i = 0; i < state.plugins.length; i++) {\n const packageDir = join(pluginsDir, `plugin-${i}`);\n const envelopeRaw = JSON.stringify(state.plugins[i]);\n const files = parseApEnvelope(envelopeRaw, `archive plugin ${i}`);\n writeApPackageFiles(files, packageDir);\n }\n if (state.environments) {\n for (let i = 0; i < state.environments.length; i++) {\n writeFileSync(\n join(environmentsDir, `environment-${i}.toml`),\n state.environments[i] ?? \"\",\n \"utf-8\",\n );\n }\n }\n if (state.harness) {\n writeJson(join(workDir, \"harness.json\"), state.harness);\n }\n writeJson(join(workDir, \"config.json\"), state.config);\n if (state.active_profile) {\n writeJson(join(workDir, \"active-profile.json\"), state.active_profile);\n }\n harnessPath = join(workDir, \"harness.json\");\n configPath = join(workDir, \"config.json\");\n } else {\n manifest = JSON.parse(\n readFileSync(join(workDir, \"manifest.json\"), \"utf-8\"),\n ) as AnyMigrateManifest;\n pluginsDir = join(workDir, \"plugins\");\n environmentsDir = join(workDir, \"environments\");\n harnessPath = join(workDir, \"harness.json\");\n configPath = join(workDir, \"config.json\");\n }\n const activeProfilePath = join(workDir, \"active-profile.json\");\n\n if (isMigrateManifestV1(manifest)) {\n throw new Error(\n \"This archive uses manifest version 1, which stored plugins as TOML. \" +\n \"Version 1 archives were never released and are not supported.\",\n );\n }\n\n const manifestVersion = manifest.version;\n if (manifestVersion !== MIGRATE_MANIFEST_VERSION) {\n throw new Error(`Unsupported migration manifest version: ${manifestVersion}`);\n }\n\n const pluginsImported = importPluginsFromDir(pluginsDir);\n const environmentsImported = importEnvironmentsFromDir(environmentsDir);\n\n if (existsSync(harnessPath)) {\n const harness = JSON.parse(\n readFileSync(harnessPath, \"utf-8\"),\n ) as HarnessPreference;\n setHarnessPreference(selectionFromArchive(harness));\n }\n\n if (existsSync(configPath)) {\n const config = JSON.parse(\n readFileSync(configPath, \"utf-8\"),\n ) as HarnesstapSettings;\n const targetDir = getHarnesstapDir();\n mkdirSync(targetDir, { recursive: true });\n writeJson(join(targetDir, \"config.json\"), config);\n }\n if (existsSync(activeProfilePath)) {\n const activeProfile = JSON.parse(\n readFileSync(activeProfilePath, \"utf-8\"),\n ) as { name?: string };\n const targetDir = getHarnesstapDir();\n mkdirSync(targetDir, { recursive: true });\n writeJson(join(targetDir, \"active-profile.json\"), activeProfile);\n }\n\n return {\n manifest,\n plugins_imported: pluginsImported,\n environments_imported: environmentsImported,\n };\n } finally {\n rmSync(workDir, { recursive: true, force: true });\n }\n}\n","import { existsSync, statSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { getPluginResources } from \"../models/plugin-model.js\";\nimport { getResource, resolveResource } from \"../models/resource.js\";\nimport type { Resource } from \"../types.js\";\nimport {\n buildApPackageFilesForResource,\n readApPackageFiles,\n writeApPackageFiles,\n} from \"./agent-plugins/files.js\";\nimport {\n isApEnvelopePath,\n readApEnvelope,\n writeApEnvelope,\n} from \"./agent-plugins/envelope.js\";\nimport { importApPackageFiles } from \"./agent-plugins/import.js\";\nimport { isCompositionResourceType } from \"./plugin-composition.js\";\nimport { parseResourceSelector } from \"./resource-selector.js\";\n\nexport interface ResourcePackageExportResult {\n type: Resource[\"type\"];\n name: string;\n description: string;\n content: string;\n metadata: Resource[\"metadata\"];\n namespace: string;\n origin_kind: Resource[\"origin_kind\"];\n origin_ref: string;\n content_hash: string;\n content_blob_ref: string;\n files: string[];\n}\n\nexport function formatResourceSelector(\n resource: Pick<Resource, \"type\" | \"name\" | \"namespace\">,\n): string {\n const namePart = resource.namespace\n ? `${resource.name}@${resource.namespace}`\n : resource.name;\n return `${resource.type}:${namePart}`;\n}\n\nexport function exportResourceToFile(\n selector: string,\n filePath: string,\n options?: { singleFile?: boolean },\n): ResourcePackageExportResult {\n const parsed = parseResourceSelector(selector);\n if (parsed.type && isCompositionResourceType(parsed.type)) {\n throw new Error(\n `Cannot export composition resource type: ${parsed.type}`,\n );\n }\n const resolved = resolveResource(selector);\n if (resolved.status !== \"found\") {\n throw new Error(\n resolved.status === \"ambiguous\"\n ? `Ambiguous resource selector: ${selector}`\n : `Resource not found: ${selector}`,\n );\n }\n if (isCompositionResourceType(resolved.resource.type)) {\n throw new Error(\n `Cannot export composition resource type: ${resolved.resource.type}`,\n );\n }\n const out = resolve(filePath);\n const files = buildApPackageFilesForResource(resolved.resource.id);\n const singleFile = options?.singleFile === true || isApEnvelopePath(out);\n const written = singleFile\n ? (writeApEnvelope(files, out), Object.keys(files).sort())\n : writeApPackageFiles(files, out);\n const { id: _id, created_at: _c, updated_at: _u, source: _s, ...payload } =\n resolved.resource;\n return {\n ...payload,\n files: written,\n };\n}\n\nexport function importResourceFromFile(filePath: string): {\n resource: Resource;\n action: \"created\" | \"updated\" | \"unchanged\";\n} {\n const resolved = resolve(filePath);\n if (!existsSync(resolved)) {\n throw new Error(`Path not found: ${resolved}`);\n }\n const packageFiles = statSync(resolved).isDirectory()\n ? readApPackageFiles(resolved)\n : isApEnvelopePath(resolved)\n ? readApEnvelope(resolved)\n : (() => {\n throw new Error(\n `${resolved} is not an Agent Plugins package directory or .ap.json envelope.`,\n );\n })();\n\n const plugin = importApPackageFiles(packageFiles);\n const resources = getPluginResources(plugin.id);\n const resource = resources[0];\n if (!resource) {\n throw new Error(`Package ${resolved} did not contain any resources.`);\n }\n const stored = getResource(resource.id) ?? resource;\n return {\n resource: stored,\n action: \"created\",\n };\n}\n","import {\n getPluginById,\n getPluginResources,\n listPluginDependencies,\n listPlugins,\n} from \"../models/plugin-model.js\";\nimport { listProjects } from \"../models/project.js\";\nimport { getLatestSnapshot } from \"../models/snapshot.js\";\nimport type { SnapshotState } from \"../types.js\";\nimport { setPluginResourceOverride } from \"./plugin-overrides.js\";\nimport {\n type ResolutionResult,\n resolutionKey,\n resolveComposition,\n} from \"./resolve/index.js\";\n\nexport interface OrderMigrationReport {\n projectsWithSnapshot: number;\n projectsWithoutSnapshot: number;\n overridesWritten: Array<{ root: string; key: string; winner: string }>;\n warnings: string[];\n}\n\nexport interface MigrateOrderToOverridesOptions {\n /** When true, report overrides that would be written without persisting them. */\n dryRun?: boolean;\n}\n\n/**\n * Reproduce previously applied results under nearest-to-root precedence.\n *\n * For every project with a recorded apply snapshot, compare the resource that\n * the old ordered merge materialized against the one resolution now picks. Where\n * they differ, write an explicit `overrides.resources` entry on the root so the\n * applied result is unchanged. Projects with no snapshot get a warning listing\n * the resources whose winner may change.\n */\nexport function migrateOrderToOverrides(\n options: MigrateOrderToOverridesOptions = {},\n): OrderMigrationReport {\n const report: OrderMigrationReport = {\n projectsWithSnapshot: 0,\n projectsWithoutSnapshot: 0,\n overridesWritten: [],\n warnings: [],\n };\n const dryRun = options.dryRun === true;\n\n for (const project of listProjects()) {\n const snapshot = getLatestSnapshot(project.id);\n const state = snapshot?.state as SnapshotState | undefined;\n const rootPlugin = state?.plugins?.[state.plugins.length - 1];\n if (!rootPlugin) {\n report.projectsWithoutSnapshot += 1;\n continue;\n }\n report.projectsWithSnapshot += 1;\n\n let resolution: ResolutionResult;\n try {\n resolution = resolveComposition({ rootSelectors: [rootPlugin.name] });\n } catch {\n report.warnings.push(\n `${project.name}: ${rootPlugin.name} no longer resolves; run ` +\n `\\`ht plugin apply ${rootPlugin.name} --explain\\` to inspect.`,\n );\n continue;\n }\n\n const previousWinnerByKey = new Map<string, string>();\n for (const resource of state?.resources ?? []) {\n const owner = ownerPluginName(resource.id, resolution.selected);\n if (owner) {\n previousWinnerByKey.set(resolutionKey(resource), owner);\n }\n }\n\n for (const decision of resolution.decisions) {\n const previous = previousWinnerByKey.get(decision.key);\n if (!previous || previous === decision.winner.pluginName) continue;\n if (!dryRun) {\n setPluginResourceOverride(resolution.root.pluginId, decision.key, previous);\n }\n report.overridesWritten.push({\n root: resolution.root.name,\n key: decision.key,\n winner: previous,\n });\n }\n }\n\n // Projects with no snapshot: name the resources whose winner may change.\n if (report.projectsWithoutSnapshot > 0) {\n for (const project of listProjects()) {\n if (getLatestSnapshot(project.id)) continue;\n const contested = collectContestedKeys();\n if (contested.keys.length > 0) {\n report.warnings.push(\n `${project.name}: no apply snapshot recorded, so previous winners are unknown. ` +\n `Contested: ${contested.keys.join(\", \")}. ` +\n `Run \\`ht plugin apply ${contested.explainRoot} --explain\\` to inspect.`,\n );\n } else {\n report.warnings.push(\n `${project.name}: no apply snapshot recorded, so previous winners are unknown.`,\n );\n }\n }\n }\n\n return report;\n}\n\nfunction collectContestedKeys(): { keys: string[]; explainRoot: string } {\n const keys: string[] = [];\n let explainRoot = \"<root>\";\n for (const plugin of listPlugins()) {\n if (listPluginDependencies(plugin.id).length === 0) continue;\n try {\n const resolution = resolveComposition({ rootSelectors: [plugin.name] });\n for (const decision of resolution.decisions) {\n if (decision.losers.length === 0) continue;\n if (!keys.includes(decision.key)) {\n keys.push(decision.key);\n }\n }\n if (explainRoot === \"<root>\") {\n explainRoot = plugin.name;\n }\n } catch {\n // Skip plugins that no longer resolve; the project-level warning still fires.\n }\n }\n return { keys, explainRoot };\n}\n\nfunction ownerPluginName(\n resourceId: string,\n selected: ReturnType<typeof resolveComposition>[\"selected\"],\n): string | undefined {\n for (const frame of selected) {\n const plugin = getPluginById(frame.pluginId);\n if (!plugin) continue;\n if (getPluginResources(plugin.id).some((resource) => resource.id === resourceId)) {\n return plugin.name;\n }\n }\n return undefined;\n}\n","import inquirer from \"inquirer\";\nimport { listResources } from \"../../models/resource.js\";\nimport { toPluginChoices } from \"../completion/choices.js\";\nimport type { MigrateScope } from \"../migrate-scope.js\";\nimport { isCompositionResourceType } from \"../plugin-composition.js\";\nimport { slugifyApName } from \"../agent-plugins/name.js\";\nimport {\n formatResourceSelectionLabel,\n sortResourcesByUpdatedAt,\n toResourceListRows,\n} from \"../../ui/resource-list-render.js\";\nimport { promptForSearchableChoice, promptForValue } from \"./shared.js\";\n\nexport type MigrateExportWizardResult = {\n scope: MigrateScope;\n outputPath: string;\n plugin?: string;\n resource?: string;\n embedPlugins?: boolean;\n singleFile?: boolean;\n};\n\nexport async function runMigrateExportWizard(): Promise<MigrateExportWizardResult> {\n const { scope } = await inquirer.prompt<{ scope: MigrateScope }>([\n {\n type: \"list\",\n name: \"scope\",\n message: \"What should be exported?\",\n choices: [\n { name: \"Workspace (full local library)\", value: \"workspace\" },\n { name: \"Plugin\", value: \"plugin\" },\n { name: \"Resource\", value: \"resource\" },\n ],\n },\n ]);\n\n if (scope === \"plugin\") {\n const choices = toPluginChoices();\n const plugin = choices.length > 0\n ? await promptForSearchableChoice({ message: \"Which plugin?\", choices })\n : await promptForValue({ message: \"Plugin name or ID\" });\n const firstPlugin = plugin.split(\",\")[0]?.trim() ?? \"plugin\";\n const apName = slugifyApName(firstPlugin);\n const { singleFile } = await inquirer.prompt<{ singleFile: boolean }>([\n {\n type: \"confirm\",\n name: \"singleFile\",\n message: \"Write a single .ap.json envelope?\",\n default: false,\n },\n ]);\n const outputPath = await promptForValue({\n message: \"Output path\",\n default: singleFile ? `./${apName}.ap.json` : `./${apName}`,\n });\n return { scope, plugin, outputPath, singleFile };\n }\n\n if (scope === \"resource\") {\n const resources = sortResourcesByUpdatedAt(\n toResourceListRows(listResources()).filter(\n (resource) => !isCompositionResourceType(resource.type),\n ),\n );\n if (resources.length === 0) {\n throw new Error(\n \"No exportable resources in workspace. Scan or create resources first.\",\n );\n }\n const choices = resources.map((resource) => ({\n name: formatResourceSelectionLabel(resource),\n value: `${resource.type}:${resource.name}${resource.namespace ? `@${resource.namespace}` : \"\"}`,\n }));\n const resource = await promptForSearchableChoice({\n message: \"Which resource?\",\n choices,\n });\n const rest = resource.split(\":\")[1] ?? \"resource\";\n const name = slugifyApName(rest.split(\"@\")[0] ?? \"resource\");\n const { singleFile } = await inquirer.prompt<{ singleFile: boolean }>([\n {\n type: \"confirm\",\n name: \"singleFile\",\n message: \"Write a single .ap.json envelope?\",\n default: false,\n },\n ]);\n const outputPath = await promptForValue({\n message: \"Output path\",\n default: singleFile ? `./${name}.ap.json` : `./${name}`,\n });\n return { scope, resource, outputPath, singleFile };\n }\n\n const outputPath = await promptForValue({\n message: \"Output archive path\",\n default: \"./harnesstap-backup.tar.gz\",\n });\n const { embed } = await inquirer.prompt<{ embed: boolean }>([\n {\n type: \"confirm\",\n name: \"embed\",\n message: \"Embed plugin trees in plugin exports?\",\n default: false,\n },\n ]);\n return { scope, outputPath, embedPlugins: embed };\n}\n","import {\n detectImportScopeFromFile,\n type MigrateScope,\n} from \"../migrate-scope.js\";\nimport { promptForValue } from \"./shared.js\";\n\nexport async function runMigrateImportWizard(): Promise<{\n file: string;\n scope: MigrateScope;\n}> {\n const file = await promptForValue({ message: \"Import file path\" });\n const scope = detectImportScopeFromFile(file);\n return { file, scope };\n}\n","import type { Command } from \"commander\";\nimport { getDb } from \"../../db/connection.js\";\nimport { initializeSchema } from \"../../db/schema.js\";\nimport {\n formatResourceCounts,\n formatSkippedEntry,\n} from \"../../services/agent-plugins/import-diagnostics.js\";\nimport {\n exportScopedMigration,\n ImportSkippedFilesError,\n importScopedMigration,\n resolveExportScope,\n resolveImportScope,\n type ScopedExportResult,\n type ScopedImportResult,\n} from \"../../services/migrate-scope.js\";\nimport {\n migrateOrderToOverrides,\n type OrderMigrationReport,\n} from \"../../services/order-to-override-migration.js\";\nimport { runMigrateExportWizard } from \"../../services/wizards/migrate-export.js\";\nimport { runMigrateImportWizard } from \"../../services/wizards/migrate-import.js\";\nimport { shouldUseWizard } from \"../../services/wizards/shared.js\";\nimport { ui } from \"../../ui/index.js\";\nimport { shortenHomePath } from \"../../utils/home-path.js\";\nimport { parseOutputFormat, printJson } from \"../../utils/output-format.js\";\nimport { formatCount } from \"../formatting.js\";\nimport { configureCommandGroup } from \"../help.js\";\nimport { fail, failCaught } from \"../shared.js\";\n\nfunction printMigrateExportHuman(result: ScopedExportResult): void {\n const output = shortenHomePath(result.output);\n switch (result.scope) {\n case \"workspace\":\n ui.success(\n `Exported migration archive ${ui.icons.hint} ${output} ${ui.icons.bullet} ${formatCount(result.manifest.plugin_count, \"plugin\")}, ${formatCount(result.manifest.environment_count, \"environment\")}`,\n );\n return;\n case \"plugin\":\n ui.success(\n `Exported plugin ${ui.theme.accent(result.plugins.join(\", \"))} ${ui.icons.hint} ${output}`,\n );\n return;\n case \"resource\":\n ui.success(\n `Exported resource ${ui.theme.accent(result.resource)} ${ui.icons.hint} ${output}`,\n );\n return;\n default: {\n const neverResult: never = result;\n throw new Error(`Unsupported export result: ${String(neverResult)}`);\n }\n }\n}\n\nfunction printMigrateImportHuman(result: ScopedImportResult): void {\n switch (result.scope) {\n case \"workspace\":\n ui.success(\n `Imported migration archive ${ui.icons.bullet} ${formatCount(result.plugins_imported, \"plugin\")}, ${formatCount(result.environments_imported, \"environment\")}`,\n );\n return;\n case \"plugin\":\n for (const item of result.skipped) {\n ui.warn(`skipped ${formatSkippedEntry(item)}`);\n }\n ui.success(\n `Imported plugin ${ui.theme.accent(result.plugin)} ${ui.icons.bullet} ${formatCount(result.resources_imported, \"resource\")}`,\n );\n ui.info(`Resources, imported of discovered: ${formatResourceCounts(result.resource_counts)}`);\n if (result.skipped.length > 0) {\n ui.warn(\n `${formatCount(result.skipped.length, \"file\")} not imported. Fix them and import again; --strict refuses the import instead.`,\n );\n }\n return;\n case \"resource\":\n ui.success(\n `Imported resource ${ui.theme.accent(result.resource)} ${ui.icons.bullet} ${result.action}`,\n );\n return;\n default: {\n const neverResult: never = result;\n throw new Error(`Unsupported import result: ${String(neverResult)}`);\n }\n }\n}\n\nasync function handleMigrateExportCommand(\n file: string | undefined,\n opts: {\n file?: string;\n workspace?: boolean;\n plugin?: string;\n resource?: string;\n environment?: string;\n includePlugins?: boolean;\n embedPlugins?: boolean;\n singleFile?: boolean;\n archive?: boolean;\n vendorExtensions?: boolean;\n format?: string;\n noInteractive?: boolean;\n interactive?: boolean;\n },\n): Promise<void> {\n const db = getDb();\n initializeSchema(db, { allowLegacyRead: true });\n const format = parseOutputFormat(opts.format);\n\n let exportOpts = {\n ...opts,\n file: opts.file ?? file,\n };\n\n const useWizard = shouldUseWizard({\n interactive: opts.interactive,\n noInteractive: opts.noInteractive,\n format: opts.format,\n missingRequiredArgs:\n !exportOpts.file\n && !exportOpts.plugin\n && !exportOpts.resource\n && !exportOpts.environment\n && !exportOpts.workspace,\n });\n\n if (useWizard) {\n const wizard = await runMigrateExportWizard();\n exportOpts = {\n ...exportOpts,\n file: wizard.outputPath,\n workspace: wizard.scope === \"workspace\" ? true : undefined,\n plugin: wizard.plugin,\n resource: wizard.resource,\n includePlugins: wizard.embedPlugins,\n singleFile: wizard.singleFile,\n };\n }\n\n try {\n const resolved = resolveExportScope(exportOpts);\n const result = exportScopedMigration(resolved, {\n ...exportOpts,\n onSkip: (message) => ui.warn(message),\n });\n if (format === \"json\") {\n if (result.scope === \"workspace\") {\n printJson({ ...result.manifest, output: result.output, scope: result.scope });\n return;\n }\n printJson(result);\n return;\n }\n printMigrateExportHuman(result);\n } catch (err) {\n fail(err instanceof Error ? err.message : String(err));\n process.exitCode = 1;\n }\n}\n\nasync function handleMigrateImportCommand(\n file: string | undefined,\n opts: {\n workspace?: boolean;\n plugin?: boolean;\n resource?: boolean;\n environment?: boolean;\n strict?: boolean;\n format?: string;\n noInteractive?: boolean;\n interactive?: boolean;\n } = {},\n): Promise<void> {\n const db = getDb();\n initializeSchema(db);\n const format = parseOutputFormat(opts.format);\n\n let importFile = file;\n let scopeOverride: ReturnType<typeof resolveImportScope> | undefined;\n\n const useWizard = shouldUseWizard({\n interactive: opts.interactive,\n noInteractive: opts.noInteractive,\n format: opts.format,\n missingRequiredArgs: !importFile,\n });\n\n if (useWizard) {\n const wizard = await runMigrateImportWizard();\n importFile = wizard.file;\n scopeOverride = wizard.scope;\n }\n\n if (!importFile) {\n fail(\"Import file path is required.\");\n process.exitCode = 1;\n return;\n }\n\n try {\n const scope = scopeOverride ?? resolveImportScope({ ...opts, file: importFile });\n // Scripts and CI fail on skipped files unless they opt out with --no-strict.\n const strict = opts.strict ?? !shouldUseWizard({\n interactive: true,\n noInteractive: opts.noInteractive,\n format: opts.format,\n missingRequiredArgs: false,\n });\n const result = importScopedMigration(scope, importFile, { strict });\n if (format === \"json\") {\n printJson(result);\n return;\n }\n printMigrateImportHuman(result);\n } catch (err) {\n if (err instanceof ImportSkippedFilesError) {\n if (format === \"json\") {\n printJson({\n scope: \"plugin\",\n imported: false,\n error: \"skipped_files\",\n skipped: err.diagnostics.skipped,\n resource_counts: err.diagnostics.counts,\n });\n process.exitCode = 1;\n return;\n }\n for (const item of err.diagnostics.skipped) {\n ui.warn(`skipped ${formatSkippedEntry(item)}`);\n }\n ui.info(`Would import, of discovered: ${formatResourceCounts(err.diagnostics.counts)}`);\n fail(\n `Not imported: ${formatCount(err.diagnostics.skipped.length, \"file\")} would be skipped.`,\n { hint: \"Fix the files, or pass --no-strict to import the rest anyway.\" },\n );\n return;\n }\n failCaught(err);\n }\n}\n\nfunction printMigrateResolveOrderHuman(\n report: OrderMigrationReport,\n dryRun: boolean,\n): void {\n const dryRunSuffix = dryRun ? ` ${ui.icons.bullet} dry-run` : \"\";\n if (report.overridesWritten.length === 0) {\n const aligned =\n report.projectsWithSnapshot > 0\n ? \"Last applied winners already match current resolution. No overrides to write\"\n : \"No apply snapshots to compare. No overrides to write\";\n ui.success(`${aligned}${dryRunSuffix}`);\n } else {\n const overrideCount = formatCount(report.overridesWritten.length, \"override\");\n const projectCount = formatCount(report.projectsWithSnapshot, \"project\");\n const verb = dryRun ? \"Would write\" : \"Wrote\";\n ui.success(\n `${verb} ${overrideCount} across ${projectCount}${dryRunSuffix}`,\n );\n }\n for (const warning of report.warnings) {\n ui.warn(warning);\n }\n}\n\nfunction handleMigrateResolveOrderCommand(opts: {\n dryRun?: boolean;\n format?: string;\n}): void {\n const db = getDb();\n initializeSchema(db, { allowLegacyRead: true });\n const format = parseOutputFormat(opts.format);\n const dryRun = opts.dryRun === true;\n const report = migrateOrderToOverrides({ dryRun });\n if (format === \"json\") {\n printJson(report);\n return;\n }\n printMigrateResolveOrderHuman(report, dryRun);\n}\n\nexport function registerMigrateCommands(root: Command): void {\n const migrateCmd = configureCommandGroup(\n root\n .command(\"migrate\")\n .alias(\"m\")\n .description(\"Export or import workspace, plugins, or resources for offline sharing\"),\n );\n\n migrateCmd\n .command(\"export\")\n .argument(\n \"[file]\",\n \"Output path (package directory, .ap.json envelope, or .tar.gz workspace archive)\",\n )\n .option(\"--workspace\", \"Export full workspace archive\")\n .option(\"--plugin <name>\", \"Export plugin(s); comma-separated names or IDs\")\n .option(\"--resource <selector>\", \"Export one resource (type:name or type:name@namespace)\")\n .option(\n \"--environment <name>\",\n \"Removed: environments are machine-local; use --workspace\",\n )\n .option(\"--single-file\", \"Write a .ap.json envelope instead of a package directory\")\n .option(\"--archive\", \"Write a .zip of the Agent Plugins package\")\n .option(\n \"--vendor-extensions\",\n \"Also write com.github.copilot files and Codex hook settings\",\n )\n .option(\"-o, --file <path>\", \"Output path (overrides positional)\")\n .option(\"--include-plugins\", \"Embed plugin trees (workspace scope)\")\n .option(\"--embed-plugins\", \"Alias for --include-plugins\")\n .option(\"--format <mode>\", \"Output format: human or json\", \"human\")\n .description(\"Export workspace, plugin, or resource for offline sharing\")\n .action(handleMigrateExportCommand);\n\n migrateCmd\n .command(\"import\")\n .argument(\n \"[file]\",\n \"package directory, .ap.json envelope, or .tar.gz workspace archive\",\n )\n .option(\"--workspace\", \"Force workspace archive import\")\n .option(\"--plugin\", \"Force Agent Plugins package import\")\n .option(\"--resource\", \"Force single-resource package import\")\n .option(\n \"--strict\",\n \"Refuse a plugin package with skipped files (default when not interactive)\",\n )\n .option(\"--no-strict\", \"Import a plugin package even when some files are skipped\")\n .option(\n \"--environment\",\n \"Removed: environments are machine-local; use --workspace\",\n )\n .option(\"--format <mode>\", \"Output format: human or json\", \"human\")\n .description(\"Import workspace, plugin, or resource from file\")\n .action(handleMigrateImportCommand);\n\n migrateCmd\n .command(\"resolve-order\")\n .option(\"--dry-run\", \"Report what would be written without writing\")\n .option(\"--format <mode>\", \"Output format: human or json\", \"human\")\n .description(\n \"Pin last-applied resource winners as overrides where current resolution would pick a different plugin\",\n )\n .action(handleMigrateResolveOrderCommand);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,cAAAA,aAAY,YAAAC,iBAAgB;AACrC,SAAS,SAAS,QAAAC,OAAM,WAAAC,gBAAe;;;ACDvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,MAAM,eAAe;AAC9B,SAAS,gBAAgB;AA6BzB,SAAS,qBAAqB,KAAgC;AAC5D,QAAM,MAAO,OAAO,CAAC;AACrB,MAAI,MAAM,QAAQ,IAAI,oBAAoB,GAAG;AAC3C,WAAO;AAAA,MACL,sBAAsB,I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AQ,MAAM;AAC9C;AAEO,SAAS,wBAAwB,MAAqB;AAC3D,QAAM,aAAa;AAAA,IACjB,KACG,QAAQ,SAAS,EACjB,MAAM,GAAG,EACT,YAAY,uEAAuE;AAAA,EACxF;AAEA,aACG,QAAQ,QAAQ,EAChB;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,eAAe,+BAA+B,EACrD,OAAO,mBAAmB,gDAAgD,EAC1E,OAAO,yBAAyB,wDAAwD,EACxF;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,iBAAiB,0DAA0D,EAClF,OAAO,aAAa,2CAA2C,EAC/D;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,qBAAqB,oCAAoC,EAChE,OAAO,qBAAqB,sCAAsC,EAClE,OAAO,mBAAmB,6BAA6B,EACvD,OAAO,mBAAmB,gCAAgC,OAAO,EACjE,YAAY,2DAA2D,EACvE,OAAO,0BAA0B;AAEpC,aACG,QAAQ,QAAQ,EAChB;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,eAAe,gCAAgC,EACtD,OAAO,YAAY,oCAAoC,EACvD,OAAO,cAAc,sCAAsC,EAC3D;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,eAAe,0DAA0D,EAChF;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,mBAAmB,gCAAgC,OAAO,EACjE,YAAY,iDAAiD,EAC7D,OAAO,0BAA0B;AAEpC,aACG,QAAQ,eAAe,EACvB,OAAO,aAAa,8CAA8C,EAClE,OAAO,mBAAmB,gCAAgC,OAAO,EACjE;AAAA,IACC;AAAA,EACF,EACC,OAAO,gCAAgC;AAC5C;","names":["existsSync","statSync","join","resolve","existsSync","statSync","resolve","resolve","existsSync","statSync","resolve","statSync","existsSync","join","outputPath","resource"]}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderCliError
|
|
3
|
+
} from "./chunk-LX6PMOOC.js";
|
|
4
|
+
import {
|
|
5
|
+
initializeSchema
|
|
6
|
+
} from "./chunk-NXILQDJG.js";
|
|
7
|
+
import "./chunk-NWOYPK2O.js";
|
|
8
|
+
import {
|
|
9
|
+
canPromptInteractively
|
|
10
|
+
} from "./chunk-XPONNOBR.js";
|
|
11
|
+
import "./chunk-I6XFZLTJ.js";
|
|
12
|
+
import {
|
|
13
|
+
parseOutputFormat,
|
|
14
|
+
printJson
|
|
15
|
+
} from "./chunk-4E3G4H5B.js";
|
|
16
|
+
import "./chunk-QHCGA6LC.js";
|
|
17
|
+
import {
|
|
18
|
+
getNotification,
|
|
19
|
+
listNotifications,
|
|
20
|
+
listPrunableNotifications,
|
|
21
|
+
markAllNotificationsRead,
|
|
22
|
+
markNotificationRead,
|
|
23
|
+
parseAge,
|
|
24
|
+
pruneNotifications,
|
|
25
|
+
unreadNotificationCount
|
|
26
|
+
} from "./chunk-26QGX47N.js";
|
|
27
|
+
import {
|
|
28
|
+
isPromptCancellationError,
|
|
29
|
+
promptForChoice
|
|
30
|
+
} from "./chunk-LGWFLVZQ.js";
|
|
31
|
+
import "./chunk-MSKTWYHG.js";
|
|
32
|
+
import "./chunk-CWXCZBJR.js";
|
|
33
|
+
import "./chunk-T2JBSRGG.js";
|
|
34
|
+
import {
|
|
35
|
+
formatCount,
|
|
36
|
+
getDb,
|
|
37
|
+
ui
|
|
38
|
+
} from "./chunk-MTCCUYBZ.js";
|
|
39
|
+
|
|
40
|
+
// src/cli/handlers/notifications.ts
|
|
41
|
+
var NotificationsUsageError = class extends Error {
|
|
42
|
+
constructor(message) {
|
|
43
|
+
super(message);
|
|
44
|
+
this.name = "NotificationsUsageError";
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
function localTime(iso) {
|
|
48
|
+
const date = new Date(iso);
|
|
49
|
+
if (Number.isNaN(date.getTime())) return iso;
|
|
50
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
51
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
52
|
+
}
|
|
53
|
+
function printRow(row) {
|
|
54
|
+
const marker = row.read_at ? " " : "*";
|
|
55
|
+
console.log(`${marker} ${row.id} ${localTime(row.created_at)} ${row.title}`);
|
|
56
|
+
if (row.body) console.log(` ${row.body}`);
|
|
57
|
+
}
|
|
58
|
+
function handleNotificationsListCommand(opts) {
|
|
59
|
+
const format = parseOutputFormat(opts.format);
|
|
60
|
+
const limit = opts.limit === void 0 ? 50 : Number(opts.limit);
|
|
61
|
+
if (!Number.isInteger(limit) || limit < 1) throw new NotificationsUsageError("--limit must be a positive number.");
|
|
62
|
+
const items = listNotifications({ filter: opts.all ? "all" : "unread", limit });
|
|
63
|
+
const unread = unreadNotificationCount();
|
|
64
|
+
if (format === "json") {
|
|
65
|
+
printJson({ items, unread_count: unread });
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (items.length === 0) {
|
|
69
|
+
ui.info(opts.all ? "No notifications." : "No unread notifications.");
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
for (const row of items) printRow(row);
|
|
73
|
+
console.log("");
|
|
74
|
+
ui.info(`${formatCount(unread, "unread notification")}. Mark as read with ht notifications read <id> or --all.`);
|
|
75
|
+
}
|
|
76
|
+
function handleNotificationsReadCommand(id, opts) {
|
|
77
|
+
const format = parseOutputFormat(opts.format);
|
|
78
|
+
if (opts.all && id) throw new NotificationsUsageError("Pass a notification id or --all, not both.");
|
|
79
|
+
if (!opts.all && !id) throw new NotificationsUsageError("Pass a notification id, or --all to mark every one as read.");
|
|
80
|
+
if (opts.all) {
|
|
81
|
+
const marked = markAllNotificationsRead();
|
|
82
|
+
if (format === "json") printJson({ marked, unread_count: 0 });
|
|
83
|
+
else ui.success(`Marked ${formatCount(marked, "notification")} as read.`);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (!getNotification(id)) throw new NotificationsUsageError(`No notification ${id}.`);
|
|
87
|
+
const row = markNotificationRead(id);
|
|
88
|
+
if (format === "json") printJson({ item: row, unread_count: unreadNotificationCount() });
|
|
89
|
+
else ui.success(`Marked ${id} as read.`);
|
|
90
|
+
}
|
|
91
|
+
async function handleNotificationsPruneCommand(opts, deps = { interactive: canPromptInteractively(), choose: promptForChoice }) {
|
|
92
|
+
const format = parseOutputFormat(opts.format);
|
|
93
|
+
if (!opts.olderThan) throw new NotificationsUsageError("Pass --older-than, for example --older-than 90d.");
|
|
94
|
+
const age = parseAge(opts.olderThan);
|
|
95
|
+
if (age === null) throw new NotificationsUsageError(`--older-than takes hours, days or weeks, such as 12h, 90d or 2w; got ${opts.olderThan}.`);
|
|
96
|
+
const candidates = listPrunableNotifications(age);
|
|
97
|
+
if (candidates.length === 0) {
|
|
98
|
+
if (format === "json") printJson({ deleted: 0 });
|
|
99
|
+
else ui.info(`No read notifications older than ${opts.olderThan}.`);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (!opts.yes) {
|
|
103
|
+
if (!deps.interactive) {
|
|
104
|
+
throw new NotificationsUsageError(
|
|
105
|
+
`This deletes ${formatCount(candidates.length, "read notification")} older than ${opts.olderThan}. Pass --yes to confirm.`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
let answer;
|
|
109
|
+
try {
|
|
110
|
+
answer = await deps.choose({
|
|
111
|
+
message: `Delete ${formatCount(candidates.length, "read notification")} older than ${opts.olderThan}?`,
|
|
112
|
+
default: "cancel",
|
|
113
|
+
choices: [
|
|
114
|
+
{ name: "Cancel", value: "cancel" },
|
|
115
|
+
{ name: "Delete", value: "delete" }
|
|
116
|
+
]
|
|
117
|
+
});
|
|
118
|
+
} catch (error) {
|
|
119
|
+
if (!isPromptCancellationError(error)) throw error;
|
|
120
|
+
answer = "cancel";
|
|
121
|
+
}
|
|
122
|
+
if (answer !== "delete") {
|
|
123
|
+
ui.info("Nothing deleted.");
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const deleted = pruneNotifications(age);
|
|
128
|
+
if (format === "json") printJson({ deleted });
|
|
129
|
+
else ui.success(`Deleted ${formatCount(deleted, "read notification")} older than ${opts.olderThan}.`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/cli/commands/notifications.ts
|
|
133
|
+
function merged(command) {
|
|
134
|
+
return command.optsWithGlobals();
|
|
135
|
+
}
|
|
136
|
+
async function run(work) {
|
|
137
|
+
try {
|
|
138
|
+
initializeSchema(getDb());
|
|
139
|
+
await work();
|
|
140
|
+
} catch (error) {
|
|
141
|
+
process.exitCode = 1;
|
|
142
|
+
renderCliError(error);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function registerNotificationsCommands(root) {
|
|
146
|
+
const cmd = root.command("notifications").description("List plugin update notifications (unread by default)").option("-a, --all", "Include read notifications").option("--limit <n>", "Most recent notifications to show", "50").option("--format <mode>", "Output format: human or json", "human").helpCommand(false).action((_opts, command) => run(() => handleNotificationsListCommand(merged(command))));
|
|
147
|
+
cmd.command("list").option("-a, --all", "Include read notifications").option("--limit <n>", "Most recent notifications to show").option("--format <mode>", "Output format: human or json").description("List plugin update notifications (unread by default); same as ht notifications").action((_opts, command) => run(() => handleNotificationsListCommand(merged(command))));
|
|
148
|
+
cmd.command("read").argument("[id]", "Notification id").option("-a, --all", "Mark every notification as read").option("--format <mode>", "Output format: human or json").description("Mark a notification, or all of them, as read").action((id, _opts, command) => run(() => handleNotificationsReadCommand(id, merged(command))));
|
|
149
|
+
cmd.command("prune").requiredOption("--older-than <age>", "Age such as 12h, 90d or 2w").option("-y, --yes", "Delete without asking").option("--format <mode>", "Output format: human or json").description("Delete read notifications older than an age, after confirmation").action((_opts, command) => run(() => handleNotificationsPruneCommand(merged(command))));
|
|
150
|
+
}
|
|
151
|
+
export {
|
|
152
|
+
registerNotificationsCommands
|
|
153
|
+
};
|
|
154
|
+
//# sourceMappingURL=notifications-Y7KQCN6K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/handlers/notifications.ts","../src/cli/commands/notifications.ts"],"sourcesContent":["import {\n getNotification,\n listNotifications,\n listPrunableNotifications,\n markAllNotificationsRead,\n markNotificationRead,\n parseAge,\n pruneNotifications,\n unreadNotificationCount,\n type NotificationRow,\n} from \"../../services/notifications.js\";\nimport {\n isPromptCancellationError,\n promptForChoice,\n} from \"../../services/wizards/shared.js\";\nimport { ui } from \"../../ui/index.js\";\nimport { formatCount } from \"../formatting.js\";\nimport { parseOutputFormat, printJson } from \"../../utils/output-format.js\";\nimport { canPromptInteractively } from \"./plugin-auto-update.js\";\n\nexport class NotificationsUsageError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"NotificationsUsageError\";\n }\n}\n\nfunction localTime(iso: string): string {\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return iso;\n const pad = (value: number) => String(value).padStart(2, \"0\");\n return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;\n}\n\nfunction printRow(row: NotificationRow): void {\n const marker = row.read_at ? \" \" : \"*\";\n console.log(`${marker} ${row.id} ${localTime(row.created_at)} ${row.title}`);\n if (row.body) console.log(` ${row.body}`);\n}\n\nexport function handleNotificationsListCommand(opts: { all?: boolean; limit?: string; format?: string }): void {\n const format = parseOutputFormat(opts.format);\n const limit = opts.limit === undefined ? 50 : Number(opts.limit);\n if (!Number.isInteger(limit) || limit < 1) throw new NotificationsUsageError(\"--limit must be a positive number.\");\n const items = listNotifications({ filter: opts.all ? \"all\" : \"unread\", limit });\n const unread = unreadNotificationCount();\n if (format === \"json\") {\n printJson({ items, unread_count: unread });\n return;\n }\n if (items.length === 0) {\n ui.info(opts.all ? \"No notifications.\" : \"No unread notifications.\");\n return;\n }\n for (const row of items) printRow(row);\n console.log(\"\");\n ui.info(`${formatCount(unread, \"unread notification\")}. Mark as read with ht notifications read <id> or --all.`);\n}\n\nexport function handleNotificationsReadCommand(id: string | undefined, opts: { all?: boolean; format?: string }): void {\n const format = parseOutputFormat(opts.format);\n if (opts.all && id) throw new NotificationsUsageError(\"Pass a notification id or --all, not both.\");\n if (!opts.all && !id) throw new NotificationsUsageError(\"Pass a notification id, or --all to mark every one as read.\");\n if (opts.all) {\n const marked = markAllNotificationsRead();\n if (format === \"json\") printJson({ marked, unread_count: 0 });\n else ui.success(`Marked ${formatCount(marked, \"notification\")} as read.`);\n return;\n }\n if (!getNotification(id!)) throw new NotificationsUsageError(`No notification ${id}.`);\n const row = markNotificationRead(id!);\n if (format === \"json\") printJson({ item: row, unread_count: unreadNotificationCount() });\n else ui.success(`Marked ${id} as read.`);\n}\n\nexport interface PruneDeps {\n interactive: boolean;\n choose: typeof promptForChoice;\n}\n\n/**\n * Deletes read notifications older than the given age. Nothing is deleted\n * without --yes or an explicit answer in an interactive terminal; unread\n * notifications are never pruned.\n */\nexport async function handleNotificationsPruneCommand(\n opts: { olderThan?: string; yes?: boolean; format?: string },\n deps: PruneDeps = { interactive: canPromptInteractively(), choose: promptForChoice },\n): Promise<void> {\n const format = parseOutputFormat(opts.format);\n if (!opts.olderThan) throw new NotificationsUsageError(\"Pass --older-than, for example --older-than 90d.\");\n const age = parseAge(opts.olderThan);\n if (age === null) throw new NotificationsUsageError(`--older-than takes hours, days or weeks, such as 12h, 90d or 2w; got ${opts.olderThan}.`);\n const candidates = listPrunableNotifications(age);\n if (candidates.length === 0) {\n if (format === \"json\") printJson({ deleted: 0 });\n else ui.info(`No read notifications older than ${opts.olderThan}.`);\n return;\n }\n if (!opts.yes) {\n if (!deps.interactive) {\n throw new NotificationsUsageError(\n `This deletes ${formatCount(candidates.length, \"read notification\")} older than ${opts.olderThan}. Pass --yes to confirm.`,\n );\n }\n let answer: \"delete\" | \"cancel\";\n try {\n answer = await deps.choose<\"delete\" | \"cancel\">({\n message: `Delete ${formatCount(candidates.length, \"read notification\")} older than ${opts.olderThan}?`,\n default: \"cancel\",\n choices: [\n { name: \"Cancel\", value: \"cancel\" },\n { name: \"Delete\", value: \"delete\" },\n ],\n });\n } catch (error) {\n if (!isPromptCancellationError(error)) throw error;\n answer = \"cancel\";\n }\n if (answer !== \"delete\") {\n ui.info(\"Nothing deleted.\");\n return;\n }\n }\n const deleted = pruneNotifications(age);\n if (format === \"json\") printJson({ deleted });\n else ui.success(`Deleted ${formatCount(deleted, \"read notification\")} older than ${opts.olderThan}.`);\n}\n","import type { Command } from \"commander\";\n\ntype ListOpts = { all?: boolean; limit?: string; format?: string };\n\n/** `--all` after a subcommand can land on the group; read it from both. */\nfunction merged<T extends object>(command: Command): T {\n return command.optsWithGlobals<T>();\n}\nimport { getDb } from \"../../db/connection.js\";\nimport { initializeSchema } from \"../../db/schema.js\";\nimport {\n handleNotificationsListCommand,\n handleNotificationsPruneCommand,\n handleNotificationsReadCommand,\n} from \"../handlers/notifications.js\";\nimport { renderCliError } from \"../runtime.js\";\n\nasync function run(work: () => void | Promise<void>): Promise<void> {\n try {\n initializeSchema(getDb());\n await work();\n } catch (error) {\n process.exitCode = 1;\n renderCliError(error);\n }\n}\n\nexport function registerNotificationsCommands(root: Command): void {\n const cmd = root\n .command(\"notifications\")\n .description(\"List plugin update notifications (unread by default)\")\n .option(\"-a, --all\", \"Include read notifications\")\n .option(\"--limit <n>\", \"Most recent notifications to show\", \"50\")\n .option(\"--format <mode>\", \"Output format: human or json\", \"human\")\n .helpCommand(false)\n .action((_opts: ListOpts, command: Command) => run(() => handleNotificationsListCommand(merged<ListOpts>(command))));\n\n cmd\n .command(\"list\")\n .option(\"-a, --all\", \"Include read notifications\")\n .option(\"--limit <n>\", \"Most recent notifications to show\")\n .option(\"--format <mode>\", \"Output format: human or json\")\n .description(\"List plugin update notifications (unread by default); same as ht notifications\")\n .action((_opts: ListOpts, command: Command) => run(() => handleNotificationsListCommand(merged<ListOpts>(command))));\n\n cmd\n .command(\"read\")\n .argument(\"[id]\", \"Notification id\")\n .option(\"-a, --all\", \"Mark every notification as read\")\n .option(\"--format <mode>\", \"Output format: human or json\")\n .description(\"Mark a notification, or all of them, as read\")\n .action((id: string | undefined, _opts: ListOpts, command: Command) =>\n run(() => handleNotificationsReadCommand(id, merged<ListOpts>(command))));\n\n cmd\n .command(\"prune\")\n .requiredOption(\"--older-than <age>\", \"Age such as 12h, 90d or 2w\")\n .option(\"-y, --yes\", \"Delete without asking\")\n .option(\"--format <mode>\", \"Output format: human or json\")\n .description(\"Delete read notifications older than an age, after confirmation\")\n .action((_opts: unknown, command: Command) =>\n run(() => handleNotificationsPruneCommand(merged<{ olderThan?: string; yes?: boolean; format?: string }>(command))));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBO,IAAM,0BAAN,cAAsC,MAAM;AAAA,EACjD,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEA,SAAS,UAAU,KAAqB;AACtC,QAAM,OAAO,IAAI,KAAK,GAAG;AACzB,MAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,EAAG,QAAO;AACzC,QAAM,MAAM,CAAC,UAAkB,OAAO,KAAK,EAAE,SAAS,GAAG,GAAG;AAC5D,SAAO,GAAG,KAAK,YAAY,CAAC,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,IAAI,KAAK,QAAQ,CAAC,CAAC,IAAI,IAAI,KAAK,SAAS,CAAC,CAAC,IAAI,IAAI,KAAK,WAAW,CAAC,CAAC;AACnI;AAEA,SAAS,SAAS,KAA4B;AAC5C,QAAM,SAAS,IAAI,UAAU,MAAM;AACnC,UAAQ,IAAI,GAAG,MAAM,IAAI,IAAI,EAAE,KAAK,UAAU,IAAI,UAAU,CAAC,KAAK,IAAI,KAAK,EAAE;AAC7E,MAAI,IAAI,KAAM,SAAQ,IAAI,KAAK,IAAI,IAAI,EAAE;AAC3C;AAEO,SAAS,+BAA+B,MAAgE;AAC7G,QAAM,SAAS,kBAAkB,KAAK,MAAM;A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unk-MILGCNBK.js";
|
|
4
|
+
import "./chunk-Y3HJ2F2W.js";
|
|
5
|
+
import "./chunk-ZREU2UHM.js";
|
|
6
|
+
import "./chunk-LX6PMOOC.js";
|
|
7
|
+
import "./chunk-NXILQDJG.js";
|
|
8
|
+
import "./chunk-NWOYPK2O.js";
|
|
9
|
+
import "./chunk-4E3G4H5B.js";
|
|
10
|
+
import "./chunk-QHCGA6LC.js";
|
|
11
|
+
import "./chunk-26QGX47N.js";
|
|
12
|
+
import "./chunk-LGWFLVZQ.js";
|
|
13
|
+
import "./chunk-MSKTWYHG.js";
|
|
14
|
+
import "./chunk-CWXCZBJR.js";
|
|
15
|
+
import "./chunk-T2JBSRGG.js";
|
|
16
|
+
import "./chunk-MTCCUYBZ.js";
|
|
17
|
+
export {
|
|
18
|
+
registerOpenCommand
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=open-FADABB2S.js.map
|