@unbrained/pm-cli 2026.5.30 → 2026.6.5
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/CHANGELOG.md +152 -0
- package/dist/cli/argv-utils.js +7 -3
- package/dist/cli/argv-utils.js.map +1 -1
- package/dist/cli/bootstrap-args.d.ts +1 -0
- package/dist/cli/bootstrap-args.js +23 -3
- package/dist/cli/bootstrap-args.js.map +1 -1
- package/dist/cli/commands/calendar.js +96 -10
- package/dist/cli/commands/calendar.js.map +1 -1
- package/dist/cli/commands/close-many.d.ts +63 -0
- package/dist/cli/commands/close-many.js +302 -0
- package/dist/cli/commands/close-many.js.map +1 -0
- package/dist/cli/commands/completion.d.ts +1 -0
- package/dist/cli/commands/completion.js +241 -27
- package/dist/cli/commands/completion.js.map +1 -1
- package/dist/cli/commands/config.d.ts +4 -4
- package/dist/cli/commands/config.js +115 -3
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/contracts.js +191 -162
- package/dist/cli/commands/contracts.js.map +1 -1
- package/dist/cli/commands/create.d.ts +1 -0
- package/dist/cli/commands/create.js +109 -116
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/commands/extension/doctor.d.ts +12 -0
- package/dist/cli/commands/extension/doctor.js +97 -2
- package/dist/cli/commands/extension/doctor.js.map +1 -1
- package/dist/cli/commands/extension/install-sources.d.ts +2 -0
- package/dist/cli/commands/extension/install-sources.js +11 -4
- package/dist/cli/commands/extension/install-sources.js.map +1 -1
- package/dist/cli/commands/extension/scaffold.js +49 -48
- package/dist/cli/commands/extension/scaffold.js.map +1 -1
- package/dist/cli/commands/extension.js +51 -23
- package/dist/cli/commands/extension.js.map +1 -1
- package/dist/cli/commands/get.js +7 -7
- package/dist/cli/commands/get.js.map +1 -1
- package/dist/cli/commands/health.js +38 -3
- package/dist/cli/commands/health.js.map +1 -1
- package/dist/cli/commands/index.d.ts +2 -1
- package/dist/cli/commands/index.js +4 -3
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/init.d.ts +10 -0
- package/dist/cli/commands/init.js +107 -4
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/list.d.ts +5 -0
- package/dist/cli/commands/list.js +58 -26
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/reindex.js +164 -48
- package/dist/cli/commands/reindex.js.map +1 -1
- package/dist/cli/commands/repeatable-metadata-parsers.d.ts +15 -0
- package/dist/cli/commands/repeatable-metadata-parsers.js +120 -0
- package/dist/cli/commands/repeatable-metadata-parsers.js.map +1 -0
- package/dist/cli/commands/restore.js +25 -4
- package/dist/cli/commands/restore.js.map +1 -1
- package/dist/cli/commands/schema.d.ts +122 -1
- package/dist/cli/commands/schema.js +536 -6
- package/dist/cli/commands/schema.js.map +1 -1
- package/dist/cli/commands/search.d.ts +18 -0
- package/dist/cli/commands/search.js +56 -12
- package/dist/cli/commands/search.js.map +1 -1
- package/dist/cli/commands/test.js +4 -3
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/commands/update-many.js +69 -140
- package/dist/cli/commands/update-many.js.map +1 -1
- package/dist/cli/commands/update.d.ts +2 -0
- package/dist/cli/commands/update.js +138 -119
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/commands/validate.d.ts +1 -0
- package/dist/cli/commands/validate.js +63 -33
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/error-guidance.js +26 -3
- package/dist/cli/error-guidance.js.map +1 -1
- package/dist/cli/help-content.js +82 -3
- package/dist/cli/help-content.js.map +1 -1
- package/dist/cli/main.js +377 -23
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/register-list-query.js +16 -12
- package/dist/cli/register-list-query.js.map +1 -1
- package/dist/cli/register-mutation.js +217 -47
- package/dist/cli/register-mutation.js.map +1 -1
- package/dist/cli/register-operations.js +34 -25
- package/dist/cli/register-operations.js.map +1 -1
- package/dist/cli/register-setup.js +8 -8
- package/dist/cli/register-setup.js.map +1 -1
- package/dist/cli/registration-helpers.js +35 -5
- package/dist/cli/registration-helpers.js.map +1 -1
- package/dist/cli/search-refresh.d.ts +2 -0
- package/dist/cli/search-refresh.js +13 -0
- package/dist/cli/search-refresh.js.map +1 -0
- package/dist/cli-bundle/chunks/activity-3RWRRNOW.js +20 -0
- package/dist/cli-bundle/chunks/activity-3RWRRNOW.js.map +1 -0
- package/dist/cli-bundle/chunks/activity-P5BUMWP3.js +16 -0
- package/dist/cli-bundle/chunks/activity-P5BUMWP3.js.map +7 -0
- package/dist/cli-bundle/chunks/aggregate-J35K7WZB.js +206 -0
- package/dist/cli-bundle/chunks/aggregate-J35K7WZB.js.map +1 -0
- package/dist/cli-bundle/chunks/aggregate-OOAGKWRG.js +209 -0
- package/dist/cli-bundle/chunks/aggregate-OOAGKWRG.js.map +7 -0
- package/dist/cli-bundle/chunks/append-5JE3YGXU.js +72 -0
- package/dist/cli-bundle/chunks/append-5JE3YGXU.js.map +7 -0
- package/dist/cli-bundle/chunks/append-PNN6UIBZ.js +69 -0
- package/dist/cli-bundle/chunks/append-PNN6UIBZ.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-26KTVXJW.js +218 -0
- package/dist/cli-bundle/chunks/chunk-26KTVXJW.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-3HUE7XOF.js +27 -0
- package/dist/cli-bundle/chunks/chunk-3HUE7XOF.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-3OH4DAEB.js +761 -0
- package/dist/cli-bundle/chunks/chunk-3OH4DAEB.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-4LTBNUYT.js +5553 -0
- package/dist/cli-bundle/chunks/chunk-4LTBNUYT.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-4PJQSECJ.js +634 -0
- package/dist/cli-bundle/chunks/chunk-4PJQSECJ.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-4QCR4QW3.js +1832 -0
- package/dist/cli-bundle/chunks/chunk-4QCR4QW3.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-5IRA6IYD.js +1891 -0
- package/dist/cli-bundle/chunks/chunk-5IRA6IYD.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-5KB4X7YY.js +412 -0
- package/dist/cli-bundle/chunks/chunk-5KB4X7YY.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-5PAOPUZX.js +182 -0
- package/dist/cli-bundle/chunks/chunk-5PAOPUZX.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-7K24QB23.js +698 -0
- package/dist/cli-bundle/chunks/chunk-7K24QB23.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-A6PEXMYN.js +380 -0
- package/dist/cli-bundle/chunks/chunk-A6PEXMYN.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-ASQM3IF5.js +230 -0
- package/dist/cli-bundle/chunks/chunk-ASQM3IF5.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-ATBVS6WW.js +185 -0
- package/dist/cli-bundle/chunks/chunk-ATBVS6WW.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-AXXKLVTW.js +332 -0
- package/dist/cli-bundle/chunks/chunk-AXXKLVTW.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-B3N4TKNL.js +1681 -0
- package/dist/cli-bundle/chunks/chunk-B3N4TKNL.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-PB2YU2E3.js → chunk-BNL6S7QH.js} +28 -70
- package/dist/cli-bundle/chunks/chunk-BNL6S7QH.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-CCUFLH4J.js +154 -0
- package/dist/cli-bundle/chunks/chunk-CCUFLH4J.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-CJDQB2ED.js +341 -0
- package/dist/cli-bundle/chunks/chunk-CJDQB2ED.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-CWT53EYT.js +1340 -0
- package/dist/cli-bundle/chunks/chunk-CWT53EYT.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-D3WUNETC.js +349 -0
- package/dist/cli-bundle/chunks/chunk-D3WUNETC.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-D5X7N6FI.js +1714 -0
- package/dist/cli-bundle/chunks/chunk-D5X7N6FI.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-DFIZGAI5.js +550 -0
- package/dist/cli-bundle/chunks/chunk-DFIZGAI5.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-DFUSXJDE.js +1704 -0
- package/dist/cli-bundle/chunks/chunk-DFUSXJDE.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-EAOG77HM.js +56 -0
- package/dist/cli-bundle/chunks/chunk-EAOG77HM.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-EHXPIKKP.js +2988 -0
- package/dist/cli-bundle/chunks/chunk-EHXPIKKP.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-FVXM3GKS.js +128 -0
- package/dist/cli-bundle/chunks/chunk-FVXM3GKS.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-G5BACLYH.js +454 -0
- package/dist/cli-bundle/chunks/chunk-G5BACLYH.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-GCAVRLGE.js +383 -0
- package/dist/cli-bundle/chunks/chunk-GCAVRLGE.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-GFWHHMVV.js +57 -0
- package/dist/cli-bundle/chunks/chunk-GFWHHMVV.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-GNHVV4SY.js +3860 -0
- package/dist/cli-bundle/chunks/chunk-GNHVV4SY.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-GPGAYASV.js +346 -0
- package/dist/cli-bundle/chunks/chunk-GPGAYASV.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-HPH6X4ZZ.js +1356 -0
- package/dist/cli-bundle/chunks/chunk-HPH6X4ZZ.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-HZOS2UG5.js +342 -0
- package/dist/cli-bundle/chunks/chunk-HZOS2UG5.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-IUV734HF.js +17 -0
- package/dist/cli-bundle/chunks/chunk-IUV734HF.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-J27KIHTG.js +15 -0
- package/dist/cli-bundle/chunks/chunk-J27KIHTG.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-JB4RGL4V.js +185 -0
- package/dist/cli-bundle/chunks/chunk-JB4RGL4V.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-JQI2HE55.js +130 -0
- package/dist/cli-bundle/chunks/chunk-JQI2HE55.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-K47WAYQV.js +60 -0
- package/dist/cli-bundle/chunks/chunk-K47WAYQV.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-KA24HME7.js +79 -0
- package/dist/cli-bundle/chunks/chunk-KA24HME7.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-KBG47ZOY.js +1325 -0
- package/dist/cli-bundle/chunks/chunk-KBG47ZOY.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-KCMIYKTA.js +242 -0
- package/dist/cli-bundle/chunks/chunk-KCMIYKTA.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-KK6YPGH3.js +221 -0
- package/dist/cli-bundle/chunks/chunk-KK6YPGH3.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-LDJK7SHN.js +157 -0
- package/dist/cli-bundle/chunks/chunk-LDJK7SHN.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-LXYVKYMQ.js +24 -0
- package/dist/cli-bundle/chunks/chunk-LXYVKYMQ.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-MISYRLEP.js +80 -0
- package/dist/cli-bundle/chunks/chunk-MISYRLEP.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-N5YF3VFN.js +457 -0
- package/dist/cli-bundle/chunks/chunk-N5YF3VFN.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-NQP3ECKF.js +173 -0
- package/dist/cli-bundle/chunks/chunk-NQP3ECKF.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-O5IBJE6S.js +338 -0
- package/dist/cli-bundle/chunks/chunk-O5IBJE6S.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-O7IWB35H.js +18 -0
- package/dist/cli-bundle/chunks/chunk-O7IWB35H.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-OIQIXTNB.js +3040 -0
- package/dist/cli-bundle/chunks/chunk-OIQIXTNB.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-ORTLYVA4.js +751 -0
- package/dist/cli-bundle/chunks/chunk-ORTLYVA4.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-OUF3ARDX.js +1861 -0
- package/dist/cli-bundle/chunks/chunk-OUF3ARDX.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-QAJBIGRA.js +20 -0
- package/dist/cli-bundle/chunks/chunk-QAJBIGRA.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-RANZIID5.js +176 -0
- package/dist/cli-bundle/chunks/chunk-RANZIID5.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-RQAWLSUU.js +140 -0
- package/dist/cli-bundle/chunks/chunk-RQAWLSUU.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-S3CV7JGJ.js +233 -0
- package/dist/cli-bundle/chunks/chunk-S3CV7JGJ.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-SRVKTWPR.js +5705 -0
- package/dist/cli-bundle/chunks/chunk-SRVKTWPR.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-SSFMJCPF.js +76 -0
- package/dist/cli-bundle/chunks/chunk-SSFMJCPF.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-SZQCER6S.js +631 -0
- package/dist/cli-bundle/chunks/chunk-SZQCER6S.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-T2ORWB6D.js +540 -0
- package/dist/cli-bundle/chunks/chunk-T2ORWB6D.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-TBQVUNVH.js +422 -0
- package/dist/cli-bundle/chunks/chunk-TBQVUNVH.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-RJONRNXN.js → chunk-TK633IVD.js} +51 -32
- package/dist/cli-bundle/chunks/chunk-TK633IVD.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-TQ3ZK6VD.js +131 -0
- package/dist/cli-bundle/chunks/chunk-TQ3ZK6VD.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-UFCG3SWR.js +119 -0
- package/dist/cli-bundle/chunks/chunk-UFCG3SWR.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-UOVLWB47.js +1664 -0
- package/dist/cli-bundle/chunks/chunk-UOVLWB47.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-V3JQ4IPL.js +186 -0
- package/dist/cli-bundle/chunks/chunk-V3JQ4IPL.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-VGO2T3TY.js +182 -0
- package/dist/cli-bundle/chunks/chunk-VGO2T3TY.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-WIKR7KFL.js +189 -0
- package/dist/cli-bundle/chunks/chunk-WIKR7KFL.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-XG7RJYHV.js +1385 -0
- package/dist/cli-bundle/chunks/chunk-XG7RJYHV.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-XSLQSXAH.js +53 -0
- package/dist/cli-bundle/chunks/chunk-XSLQSXAH.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-XX5LRINW.js +90 -0
- package/dist/cli-bundle/chunks/chunk-XX5LRINW.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-Y2AKE2HS.js +252 -0
- package/dist/cli-bundle/chunks/chunk-Y2AKE2HS.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-ZQ4F6EC4.js +3898 -0
- package/dist/cli-bundle/chunks/chunk-ZQ4F6EC4.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-ZRVSMOMR.js +1809 -0
- package/dist/cli-bundle/chunks/chunk-ZRVSMOMR.js.map +1 -0
- package/dist/cli-bundle/chunks/claim-AZLP7YFO.js +132 -0
- package/dist/cli-bundle/chunks/claim-AZLP7YFO.js.map +7 -0
- package/dist/cli-bundle/chunks/claim-ZFA7HKU4.js +129 -0
- package/dist/cli-bundle/chunks/claim-ZFA7HKU4.js.map +1 -0
- package/dist/cli-bundle/chunks/close-65DFYAVS.js +17 -0
- package/dist/cli-bundle/chunks/close-65DFYAVS.js.map +1 -0
- package/dist/cli-bundle/chunks/close-RMHQ3KWH.js +13 -0
- package/dist/cli-bundle/chunks/close-RMHQ3KWH.js.map +7 -0
- package/dist/cli-bundle/chunks/close-many-AKPZNSGI.js +311 -0
- package/dist/cli-bundle/chunks/close-many-AKPZNSGI.js.map +1 -0
- package/dist/cli-bundle/chunks/close-many-UKZSQGM7.js +314 -0
- package/dist/cli-bundle/chunks/close-many-UKZSQGM7.js.map +7 -0
- package/dist/cli-bundle/chunks/comments-AGBNSJJH.js +103 -0
- package/dist/cli-bundle/chunks/comments-AGBNSJJH.js.map +7 -0
- package/dist/cli-bundle/chunks/comments-CJWXQI7X.js +100 -0
- package/dist/cli-bundle/chunks/comments-CJWXQI7X.js.map +1 -0
- package/dist/cli-bundle/chunks/config-5ON3ADRH.js +1688 -0
- package/dist/cli-bundle/chunks/config-5ON3ADRH.js.map +7 -0
- package/dist/cli-bundle/chunks/config-DDPYIA6J.js +1671 -0
- package/dist/cli-bundle/chunks/config-DDPYIA6J.js.map +1 -0
- package/dist/cli-bundle/chunks/context-E6U3DWVM.js +1471 -0
- package/dist/cli-bundle/chunks/context-E6U3DWVM.js.map +7 -0
- package/dist/cli-bundle/chunks/context-ZOJEN5VT.js +1461 -0
- package/dist/cli-bundle/chunks/context-ZOJEN5VT.js.map +1 -0
- package/dist/cli-bundle/chunks/contracts-CXSFM45B.js +1277 -0
- package/dist/cli-bundle/chunks/contracts-CXSFM45B.js.map +7 -0
- package/dist/cli-bundle/chunks/contracts-LCSX5R53.js +1274 -0
- package/dist/cli-bundle/chunks/contracts-LCSX5R53.js.map +1 -0
- package/dist/cli-bundle/chunks/create-ATONSAZW.js +27 -0
- package/dist/cli-bundle/chunks/create-ATONSAZW.js.map +7 -0
- package/dist/cli-bundle/chunks/create-WYFKN2U4.js +31 -0
- package/dist/cli-bundle/chunks/create-WYFKN2U4.js.map +1 -0
- package/dist/cli-bundle/chunks/delete-RONNH4F4.js +58 -0
- package/dist/cli-bundle/chunks/delete-RONNH4F4.js.map +7 -0
- package/dist/cli-bundle/chunks/delete-ZXWC56WO.js +55 -0
- package/dist/cli-bundle/chunks/delete-ZXWC56WO.js.map +1 -0
- package/dist/cli-bundle/chunks/deps-EHXIFOZR.js +225 -0
- package/dist/cli-bundle/chunks/deps-EHXIFOZR.js.map +1 -0
- package/dist/cli-bundle/chunks/deps-WII3O4HB.js +228 -0
- package/dist/cli-bundle/chunks/deps-WII3O4HB.js.map +7 -0
- package/dist/cli-bundle/chunks/docs-JMVCFNHH.js +34 -0
- package/dist/cli-bundle/chunks/docs-JMVCFNHH.js.map +7 -0
- package/dist/cli-bundle/chunks/docs-PDREIMLS.js +31 -0
- package/dist/cli-bundle/chunks/docs-PDREIMLS.js.map +1 -0
- package/dist/cli-bundle/chunks/extension-B4ROVWJD.js +28 -0
- package/dist/cli-bundle/chunks/extension-B4ROVWJD.js.map +1 -0
- package/dist/cli-bundle/chunks/extension-G6UXSM5S.js +24 -0
- package/dist/cli-bundle/chunks/extension-G6UXSM5S.js.map +7 -0
- package/dist/cli-bundle/chunks/files-2PN7UM2D.js +282 -0
- package/dist/cli-bundle/chunks/files-2PN7UM2D.js.map +1 -0
- package/dist/cli-bundle/chunks/files-MXYS5W4M.js +285 -0
- package/dist/cli-bundle/chunks/files-MXYS5W4M.js.map +7 -0
- package/dist/cli-bundle/chunks/gc-GT552UJH.js +178 -0
- package/dist/cli-bundle/chunks/gc-GT552UJH.js.map +1 -0
- package/dist/cli-bundle/chunks/gc-QNBRJG6H.js +181 -0
- package/dist/cli-bundle/chunks/gc-QNBRJG6H.js.map +7 -0
- package/dist/cli-bundle/chunks/get-CINFEUIY.js +197 -0
- package/dist/cli-bundle/chunks/get-CINFEUIY.js.map +7 -0
- package/dist/cli-bundle/chunks/get-WXMLRG7M.js +194 -0
- package/dist/cli-bundle/chunks/get-WXMLRG7M.js.map +1 -0
- package/dist/cli-bundle/chunks/health-5VPOJQ53.js +1258 -0
- package/dist/cli-bundle/chunks/health-5VPOJQ53.js.map +1 -0
- package/dist/cli-bundle/chunks/health-IT5DBPRJ.js +1261 -0
- package/dist/cli-bundle/chunks/health-IT5DBPRJ.js.map +7 -0
- package/dist/cli-bundle/chunks/history-6FC4H6HI.js +20 -0
- package/dist/cli-bundle/chunks/history-6FC4H6HI.js.map +7 -0
- package/dist/cli-bundle/chunks/history-FLZIP7PM.js +24 -0
- package/dist/cli-bundle/chunks/history-FLZIP7PM.js.map +1 -0
- package/dist/cli-bundle/chunks/history-redact-SSZBAD76.js +23 -0
- package/dist/cli-bundle/chunks/history-redact-SSZBAD76.js.map +1 -0
- package/dist/cli-bundle/chunks/history-redact-XKYEZDBL.js +19 -0
- package/dist/cli-bundle/chunks/history-redact-XKYEZDBL.js.map +7 -0
- package/dist/cli-bundle/chunks/history-repair-KC5ZOJRZ.js +196 -0
- package/dist/cli-bundle/chunks/history-repair-KC5ZOJRZ.js.map +7 -0
- package/dist/cli-bundle/chunks/history-repair-X7CO5JJZ.js +193 -0
- package/dist/cli-bundle/chunks/history-repair-X7CO5JJZ.js.map +1 -0
- package/dist/cli-bundle/chunks/init-6MRFVOLH.js +20 -0
- package/dist/cli-bundle/chunks/init-6MRFVOLH.js.map +1 -0
- package/dist/cli-bundle/chunks/init-KHX3FEEM.js +16 -0
- package/dist/cli-bundle/chunks/init-KHX3FEEM.js.map +7 -0
- package/dist/cli-bundle/chunks/learnings-A3CLB5CO.js +47 -0
- package/dist/cli-bundle/chunks/learnings-A3CLB5CO.js.map +7 -0
- package/dist/cli-bundle/chunks/learnings-DCX55BNX.js +44 -0
- package/dist/cli-bundle/chunks/learnings-DCX55BNX.js.map +1 -0
- package/dist/cli-bundle/chunks/list-53LZ2AEO.js +20 -0
- package/dist/cli-bundle/chunks/list-53LZ2AEO.js.map +7 -0
- package/dist/cli-bundle/chunks/list-DBRECOG4.js +24 -0
- package/dist/cli-bundle/chunks/list-DBRECOG4.js.map +1 -0
- package/dist/cli-bundle/chunks/notes-42LIC3UE.js +47 -0
- package/dist/cli-bundle/chunks/notes-42LIC3UE.js.map +7 -0
- package/dist/cli-bundle/chunks/notes-P5O3VMQ3.js +44 -0
- package/dist/cli-bundle/chunks/notes-P5O3VMQ3.js.map +1 -0
- package/dist/cli-bundle/chunks/plan-HDQXEUKD.js +1174 -0
- package/dist/cli-bundle/chunks/plan-HDQXEUKD.js.map +7 -0
- package/dist/cli-bundle/chunks/plan-IGTE3WOJ.js +1171 -0
- package/dist/cli-bundle/chunks/plan-IGTE3WOJ.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-list-query-EIVQ5FMR.js → register-list-query-AG3XKXWL.js} +25 -18
- package/dist/cli-bundle/chunks/register-list-query-AG3XKXWL.js.map +7 -0
- package/dist/cli-bundle/chunks/register-list-query-EMNSIUO4.js +227 -0
- package/dist/cli-bundle/chunks/register-list-query-EMNSIUO4.js.map +1 -0
- package/dist/cli-bundle/chunks/register-mutation-M3YS6XDO.js +813 -0
- package/dist/cli-bundle/chunks/register-mutation-M3YS6XDO.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-mutation-RSZNPSGI.js → register-mutation-RSMT6DPK.js} +160 -39
- package/dist/cli-bundle/chunks/register-mutation-RSMT6DPK.js.map +7 -0
- package/dist/cli-bundle/chunks/register-operations-KYUOOOOD.js +370 -0
- package/dist/cli-bundle/chunks/register-operations-KYUOOOOD.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-operations-APUSYDMR.js → register-operations-Q54JQZUN.js} +50 -32
- package/dist/cli-bundle/chunks/register-operations-Q54JQZUN.js.map +7 -0
- package/dist/cli-bundle/chunks/register-setup-DI6P7X75.js +242 -0
- package/dist/cli-bundle/chunks/register-setup-DI6P7X75.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-setup-OZOKSMPJ.js → register-setup-YJKIQRKA.js} +21 -13
- package/dist/cli-bundle/chunks/register-setup-YJKIQRKA.js.map +7 -0
- package/dist/cli-bundle/chunks/restore-2XVTBLKQ.js +21 -0
- package/dist/cli-bundle/chunks/restore-2XVTBLKQ.js.map +1 -0
- package/dist/cli-bundle/chunks/restore-JL5QIH7H.js +17 -0
- package/dist/cli-bundle/chunks/restore-JL5QIH7H.js.map +7 -0
- package/dist/cli-bundle/chunks/schema-LVXZWFGY.js +770 -0
- package/dist/cli-bundle/chunks/schema-LVXZWFGY.js.map +1 -0
- package/dist/cli-bundle/chunks/schema-V6BX65Q2.js +780 -0
- package/dist/cli-bundle/chunks/schema-V6BX65Q2.js.map +7 -0
- package/dist/cli-bundle/chunks/search-5A3BMFA7.js +1144 -0
- package/dist/cli-bundle/chunks/search-5A3BMFA7.js.map +7 -0
- package/dist/cli-bundle/chunks/search-C7NPB7G7.js +1127 -0
- package/dist/cli-bundle/chunks/search-C7NPB7G7.js.map +1 -0
- package/dist/cli-bundle/chunks/stats-FNLYVXTB.js +120 -0
- package/dist/cli-bundle/chunks/stats-FNLYVXTB.js.map +1 -0
- package/dist/cli-bundle/chunks/stats-Y2CBTZSL.js +123 -0
- package/dist/cli-bundle/chunks/stats-Y2CBTZSL.js.map +7 -0
- package/dist/cli-bundle/chunks/test-OFYONO3C.js +35 -0
- package/dist/cli-bundle/chunks/test-OFYONO3C.js.map +1 -0
- package/dist/cli-bundle/chunks/test-RJ4ZF35X.js +31 -0
- package/dist/cli-bundle/chunks/test-RJ4ZF35X.js.map +7 -0
- package/dist/cli-bundle/chunks/test-all-EEMKNTGU.js +331 -0
- package/dist/cli-bundle/chunks/test-all-EEMKNTGU.js.map +7 -0
- package/dist/cli-bundle/chunks/test-all-OJE6CIO7.js +328 -0
- package/dist/cli-bundle/chunks/test-all-OJE6CIO7.js.map +1 -0
- package/dist/cli-bundle/chunks/test-runs-IPOPFOAF.js +929 -0
- package/dist/cli-bundle/chunks/test-runs-IPOPFOAF.js.map +1 -0
- package/dist/cli-bundle/chunks/test-runs-L2M7WKH7.js +939 -0
- package/dist/cli-bundle/chunks/test-runs-L2M7WKH7.js.map +7 -0
- package/dist/cli-bundle/chunks/update-6YEHPVXH.js +25 -0
- package/dist/cli-bundle/chunks/update-6YEHPVXH.js.map +1 -0
- package/dist/cli-bundle/chunks/update-PYLVHMRD.js +21 -0
- package/dist/cli-bundle/chunks/update-PYLVHMRD.js.map +7 -0
- package/dist/cli-bundle/chunks/update-many-322CCH2L.js +608 -0
- package/dist/cli-bundle/chunks/update-many-322CCH2L.js.map +7 -0
- package/dist/cli-bundle/chunks/update-many-DYWGW57M.js +605 -0
- package/dist/cli-bundle/chunks/update-many-DYWGW57M.js.map +1 -0
- package/dist/cli-bundle/chunks/upgrade-2U727SAM.js +269 -0
- package/dist/cli-bundle/chunks/upgrade-2U727SAM.js.map +7 -0
- package/dist/cli-bundle/chunks/upgrade-3W3RVSNM.js +266 -0
- package/dist/cli-bundle/chunks/upgrade-3W3RVSNM.js.map +1 -0
- package/dist/cli-bundle/chunks/validate-GZ24NYHO.js +1120 -0
- package/dist/cli-bundle/chunks/validate-GZ24NYHO.js.map +1 -0
- package/dist/cli-bundle/chunks/validate-ZFVWPEEN.js +1123 -0
- package/dist/cli-bundle/chunks/validate-ZFVWPEEN.js.map +7 -0
- package/dist/cli-bundle/main.js +615 -121
- package/dist/cli-bundle/main.js.map +4 -4
- package/dist/core/checkpoint/mutation-checkpoint.d.ts +44 -0
- package/dist/core/checkpoint/mutation-checkpoint.js +119 -0
- package/dist/core/checkpoint/mutation-checkpoint.js.map +1 -0
- package/dist/core/config/positional-value.js +4 -2
- package/dist/core/config/positional-value.js.map +1 -1
- package/dist/core/diagnostics/remediation.d.ts +73 -0
- package/dist/core/diagnostics/remediation.js +328 -0
- package/dist/core/diagnostics/remediation.js.map +1 -0
- package/dist/core/extensions/extension-hook-runtime.js +9 -2
- package/dist/core/extensions/extension-hook-runtime.js.map +1 -1
- package/dist/core/extensions/extension-types.d.ts +60 -4
- package/dist/core/extensions/extension-types.js +2 -2
- package/dist/core/extensions/extension-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +5 -1
- package/dist/core/extensions/index.js +61 -2
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/item-fields.d.ts +5 -1
- package/dist/core/extensions/item-fields.js +126 -4
- package/dist/core/extensions/item-fields.js.map +1 -1
- package/dist/core/extensions/loader.js +283 -8
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/item/item-format.d.ts +3 -2
- package/dist/core/item/item-format.js +15 -10
- package/dist/core/item/item-format.js.map +1 -1
- package/dist/core/item/item-type-definition.js +6 -2
- package/dist/core/item/item-type-definition.js.map +1 -1
- package/dist/core/item/status-filter.d.ts +29 -0
- package/dist/core/item/status-filter.js +97 -0
- package/dist/core/item/status-filter.js.map +1 -0
- package/dist/core/item/type-registry.d.ts +4 -0
- package/dist/core/item/type-registry.js +12 -2
- package/dist/core/item/type-registry.js.map +1 -1
- package/dist/core/output/output.js +17 -5
- package/dist/core/output/output.js.map +1 -1
- package/dist/core/schema/item-types-file.d.ts +15 -0
- package/dist/core/schema/item-types-file.js +27 -2
- package/dist/core/schema/item-types-file.js.map +1 -1
- package/dist/core/schema/runtime-field-filters.js +4 -3
- package/dist/core/schema/runtime-field-filters.js.map +1 -1
- package/dist/core/schema/runtime-field-values.d.ts +1 -1
- package/dist/core/schema/runtime-field-values.js +10 -4
- package/dist/core/schema/runtime-field-values.js.map +1 -1
- package/dist/core/schema/runtime-schema.js +75 -2
- package/dist/core/schema/runtime-schema.js.map +1 -1
- package/dist/core/schema/status-defs-file.d.ts +113 -0
- package/dist/core/schema/status-defs-file.js +260 -0
- package/dist/core/schema/status-defs-file.js.map +1 -0
- package/dist/core/schema/type-workflows.d.ts +64 -0
- package/dist/core/schema/type-workflows.js +98 -0
- package/dist/core/schema/type-workflows.js.map +1 -0
- package/dist/core/search/background-refresh.d.ts +53 -0
- package/dist/core/search/background-refresh.js +286 -0
- package/dist/core/search/background-refresh.js.map +1 -0
- package/dist/core/search/cache.d.ts +23 -2
- package/dist/core/search/cache.js +135 -30
- package/dist/core/search/cache.js.map +1 -1
- package/dist/core/search/http-client.d.ts +2 -2
- package/dist/core/search/http-client.js +2 -2
- package/dist/core/search/http-client.js.map +1 -1
- package/dist/core/search/vector-stores.d.ts +1 -0
- package/dist/core/search/vector-stores.js +69 -15
- package/dist/core/search/vector-stores.js.map +1 -1
- package/dist/core/search/vectorization-metadata.d.ts +13 -0
- package/dist/core/search/vectorization-metadata.js +65 -0
- package/dist/core/search/vectorization-metadata.js.map +1 -0
- package/dist/core/shared/constants.d.ts +2 -2
- package/dist/core/shared/constants.js +2 -3
- package/dist/core/shared/constants.js.map +1 -1
- package/dist/core/shared/serialization.d.ts +1 -0
- package/dist/core/shared/serialization.js +86 -2
- package/dist/core/shared/serialization.js.map +1 -1
- package/dist/core/store/front-matter-cache.js +14 -5
- package/dist/core/store/front-matter-cache.js.map +1 -1
- package/dist/core/store/item-format-migration.js +25 -15
- package/dist/core/store/item-format-migration.js.map +1 -1
- package/dist/core/store/item-store.d.ts +2 -0
- package/dist/core/store/item-store.js +61 -6
- package/dist/core/store/item-store.js.map +1 -1
- package/dist/core/store/settings-validator.js +22 -2
- package/dist/core/store/settings-validator.js.map +1 -1
- package/dist/core/store/settings.js +40 -5
- package/dist/core/store/settings.js.map +1 -1
- package/dist/core/telemetry/consent.js +3 -3
- package/dist/core/telemetry/consent.js.map +1 -1
- package/dist/core/telemetry/observability.js +4 -3
- package/dist/core/telemetry/observability.js.map +1 -1
- package/dist/core/telemetry/runtime.d.ts +10 -0
- package/dist/core/telemetry/runtime.js +86 -2
- package/dist/core/telemetry/runtime.js.map +1 -1
- package/dist/mcp/server.js +221 -12
- package/dist/mcp/server.js.map +1 -1
- package/dist/sdk/cli-contracts/commander-mutation-options.js +16 -2
- package/dist/sdk/cli-contracts/commander-mutation-options.js.map +1 -1
- package/dist/sdk/cli-contracts/commander-types.js +7 -2
- package/dist/sdk/cli-contracts/commander-types.js.map +1 -1
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +2 -2
- package/dist/sdk/cli-contracts/enum-contracts.js +4 -2
- package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +1 -0
- package/dist/sdk/cli-contracts/tool-option-contracts.js +53 -3
- package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +37 -8
- package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
- package/dist/sdk/cli-contracts.d.ts +19 -1
- package/dist/sdk/cli-contracts.js +211 -18
- package/dist/sdk/cli-contracts.js.map +1 -1
- package/dist/sdk/errors.d.ts +22 -0
- package/dist/sdk/errors.js +46 -0
- package/dist/sdk/errors.js.map +1 -0
- package/dist/sdk/index.d.ts +2 -1
- package/dist/sdk/index.js +3 -2
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/package-import-adapters.js +14 -3
- package/dist/sdk/package-import-adapters.js.map +1 -1
- package/dist/sdk/runtime.d.ts +1 -0
- package/dist/sdk/runtime.js +3 -2
- package/dist/sdk/runtime.js.map +1 -1
- package/dist/sdk/testing.d.ts +77 -0
- package/dist/sdk/testing.js +239 -0
- package/dist/sdk/testing.js.map +1 -0
- package/dist/types.d.ts +26 -1
- package/dist/types.js +3 -2
- package/dist/types.js.map +1 -1
- package/docs/AGENT_GUIDE.md +21 -2
- package/docs/COMMANDS.md +85 -5
- package/docs/CONFIGURATION.md +49 -2
- package/docs/EXTENSIONS.md +118 -6
- package/docs/QUICKSTART.md +2 -0
- package/docs/RELEASING.md +3 -3
- package/docs/SDK.md +273 -1
- package/docs/TESTING.md +17 -0
- package/docs/examples/policy-restricted-extension/manifest.json +1 -0
- package/docs/examples/starter-extension/index.js +9 -1
- package/docs/examples/starter-extension/manifest.json +1 -0
- package/package.json +12 -7
- package/packages/pm-beads/extensions/beads/index.js +2 -4
- package/packages/pm-beads/extensions/beads/index.ts +43 -33
- package/packages/pm-beads/extensions/beads/manifest.json +12 -1
- package/packages/pm-calendar/README.md +6 -0
- package/packages/pm-calendar/extensions/calendar/index.js +6 -1
- package/packages/pm-calendar/extensions/calendar/index.ts +6 -1
- package/packages/pm-calendar/extensions/calendar/manifest.json +6 -1
- package/packages/pm-governance-audit/extensions/governance-audit/manifest.json +6 -1
- package/packages/pm-guide-shell/README.md +4 -0
- package/packages/pm-guide-shell/extensions/guide-shell/index.js +22 -0
- package/packages/pm-guide-shell/extensions/guide-shell/index.ts +22 -0
- package/packages/pm-guide-shell/extensions/guide-shell/manifest.json +6 -1
- package/packages/pm-guide-shell/extensions/guide-shell/runtime.js +74 -3
- package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +84 -4
- package/packages/pm-lifecycle-hooks/README.md +29 -0
- package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.js +18 -0
- package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.ts +20 -0
- package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/manifest.json +9 -0
- package/packages/pm-lifecycle-hooks/package.json +52 -0
- package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/manifest.json +13 -1
- package/packages/pm-search-advanced/extensions/search-advanced/index.js +69 -1
- package/packages/pm-search-advanced/extensions/search-advanced/index.ts +91 -2
- package/packages/pm-search-advanced/extensions/search-advanced/manifest.json +13 -1
- package/packages/pm-templates/extensions/templates/manifest.json +6 -1
- package/packages/pm-todos/extensions/todos/index.js +3 -7
- package/packages/pm-todos/extensions/todos/index.ts +55 -42
- package/packages/pm-todos/extensions/todos/manifest.json +13 -1
- package/scripts/bundle-cli.mjs +121 -17
- package/dist/cli-bundle/chunks/chunk-PB2YU2E3.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-RJONRNXN.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-SW5BMMCU.js +0 -13864
- package/dist/cli-bundle/chunks/chunk-SW5BMMCU.js.map +0 -7
- package/dist/cli-bundle/chunks/commands-XJ4TJ5UN.js +0 -24225
- package/dist/cli-bundle/chunks/commands-XJ4TJ5UN.js.map +0 -7
- package/dist/cli-bundle/chunks/register-list-query-EIVQ5FMR.js.map +0 -7
- package/dist/cli-bundle/chunks/register-mutation-RSZNPSGI.js.map +0 -7
- package/dist/cli-bundle/chunks/register-operations-APUSYDMR.js.map +0 -7
- package/dist/cli-bundle/chunks/register-setup-OZOKSMPJ.js.map +0 -7
|
@@ -0,0 +1,1385 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeItemId,
|
|
3
|
+
normalizeRawItemId
|
|
4
|
+
} from "./chunk-KA24HME7.js";
|
|
5
|
+
import {
|
|
6
|
+
canonicalDocument,
|
|
7
|
+
parseItemDocument,
|
|
8
|
+
serializeItemDocument
|
|
9
|
+
} from "./chunk-HPH6X4ZZ.js";
|
|
10
|
+
import {
|
|
11
|
+
resolveItemTypeRegistry
|
|
12
|
+
} from "./chunk-4PJQSECJ.js";
|
|
13
|
+
import {
|
|
14
|
+
nowIso
|
|
15
|
+
} from "./chunk-RANZIID5.js";
|
|
16
|
+
import {
|
|
17
|
+
EMPTY_CANONICAL_DOCUMENT,
|
|
18
|
+
EXIT_CODE,
|
|
19
|
+
FRONT_MATTER_KEY_ORDER,
|
|
20
|
+
ITEM_FILE_EXTENSIONS,
|
|
21
|
+
PmCliError,
|
|
22
|
+
TYPE_TO_FOLDER,
|
|
23
|
+
appendLineAtomic,
|
|
24
|
+
ensureDir,
|
|
25
|
+
getActiveExtensionRegistrations,
|
|
26
|
+
getHistoryPath,
|
|
27
|
+
getItemFormatFromPath,
|
|
28
|
+
getItemPath,
|
|
29
|
+
getLockPath,
|
|
30
|
+
hasActiveOnReadHooks,
|
|
31
|
+
orderObject,
|
|
32
|
+
pathExists,
|
|
33
|
+
projectAfterCommandItemSnapshot,
|
|
34
|
+
recordAfterCommandAffectedItem,
|
|
35
|
+
resolveGovernanceKnobs,
|
|
36
|
+
runActiveOnReadHooks,
|
|
37
|
+
runActiveOnWriteHooks,
|
|
38
|
+
runActiveServiceOverride,
|
|
39
|
+
sha256Hex,
|
|
40
|
+
stableStringify,
|
|
41
|
+
toErrorMessage,
|
|
42
|
+
writeFileAtomic
|
|
43
|
+
} from "./chunk-SRVKTWPR.js";
|
|
44
|
+
|
|
45
|
+
// dist/core/extensions/item-fields.js
|
|
46
|
+
!(function() {
|
|
47
|
+
try {
|
|
48
|
+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
49
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "60ed024d-4341-5166-bd9e-abed9b240b11");
|
|
50
|
+
} catch (e2) {
|
|
51
|
+
}
|
|
52
|
+
})();
|
|
53
|
+
var RESERVED_ITEM_FIELD_NAMES = new Set(FRONT_MATTER_KEY_ORDER);
|
|
54
|
+
function normalizeFieldName(value) {
|
|
55
|
+
if (typeof value !== "string") {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const normalized = value.trim();
|
|
59
|
+
return normalized.length > 0 ? normalized : null;
|
|
60
|
+
}
|
|
61
|
+
function normalizeFieldType(value) {
|
|
62
|
+
if (typeof value !== "string") {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const normalized = value.trim().toLowerCase();
|
|
66
|
+
if (normalized === "string" || normalized === "number" || normalized === "boolean" || normalized === "array" || normalized === "object") {
|
|
67
|
+
return normalized;
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
function cloneFieldValue(value) {
|
|
72
|
+
try {
|
|
73
|
+
return structuredClone(value);
|
|
74
|
+
} catch {
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function parseFieldAssignment(raw) {
|
|
79
|
+
const trimmed = raw.trim();
|
|
80
|
+
const separatorIndex = trimmed.indexOf("=");
|
|
81
|
+
if (separatorIndex <= 0) {
|
|
82
|
+
throw new PmCliError(`--field entries must use name=value syntax, received: ${raw}`, EXIT_CODE.USAGE);
|
|
83
|
+
}
|
|
84
|
+
const key = trimmed.slice(0, separatorIndex).trim();
|
|
85
|
+
const value = trimmed.slice(separatorIndex + 1);
|
|
86
|
+
if (key.length === 0) {
|
|
87
|
+
throw new PmCliError("--field entries require a non-empty field name", EXIT_CODE.USAGE);
|
|
88
|
+
}
|
|
89
|
+
return { key, value };
|
|
90
|
+
}
|
|
91
|
+
function parseJsonFieldValue(raw, fieldName, expectedType) {
|
|
92
|
+
try {
|
|
93
|
+
const parsed = JSON.parse(raw);
|
|
94
|
+
if (expectedType === "array" && Array.isArray(parsed)) {
|
|
95
|
+
return parsed;
|
|
96
|
+
}
|
|
97
|
+
if (expectedType === "object" && typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
98
|
+
return parsed;
|
|
99
|
+
}
|
|
100
|
+
} catch {
|
|
101
|
+
}
|
|
102
|
+
throw new PmCliError(`--field ${fieldName}=... must be valid JSON ${expectedType}`, EXIT_CODE.USAGE);
|
|
103
|
+
}
|
|
104
|
+
function coerceRegisteredFieldValue(fieldName, fieldType, raw) {
|
|
105
|
+
if (fieldType === "string") {
|
|
106
|
+
return raw;
|
|
107
|
+
}
|
|
108
|
+
if (fieldType === "number") {
|
|
109
|
+
const trimmed = raw.trim();
|
|
110
|
+
if (trimmed.length === 0) {
|
|
111
|
+
throw new PmCliError(`--field ${fieldName}=... must be a number`, EXIT_CODE.USAGE);
|
|
112
|
+
}
|
|
113
|
+
const parsed = Number(trimmed);
|
|
114
|
+
if (!Number.isFinite(parsed)) {
|
|
115
|
+
throw new PmCliError(`--field ${fieldName}=... must be a number`, EXIT_CODE.USAGE);
|
|
116
|
+
}
|
|
117
|
+
return parsed;
|
|
118
|
+
}
|
|
119
|
+
if (fieldType === "boolean") {
|
|
120
|
+
const normalized = raw.trim().toLowerCase();
|
|
121
|
+
if (normalized === "true" || normalized === "1" || normalized === "yes") {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
if (normalized === "false" || normalized === "0" || normalized === "no") {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
throw new PmCliError(`--field ${fieldName}=... must be one of true|false|1|0|yes|no`, EXIT_CODE.USAGE);
|
|
128
|
+
}
|
|
129
|
+
return parseJsonFieldValue(raw, fieldName, fieldType);
|
|
130
|
+
}
|
|
131
|
+
function collectRegisteredFieldDefinitions(registrations) {
|
|
132
|
+
const definitions = /* @__PURE__ */ new Map();
|
|
133
|
+
if (!registrations) {
|
|
134
|
+
return definitions;
|
|
135
|
+
}
|
|
136
|
+
for (const registration of registrations.item_fields) {
|
|
137
|
+
for (const definition of registration.fields) {
|
|
138
|
+
const fieldName = normalizeFieldName(definition.name);
|
|
139
|
+
const fieldType = normalizeFieldType(definition.type);
|
|
140
|
+
if (!fieldName || !fieldType) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const existing = definitions.get(fieldName);
|
|
144
|
+
if (existing && existing.type !== fieldType) {
|
|
145
|
+
throw new PmCliError(`Extension item field "${fieldName}" is declared with conflicting types: ${existing.type}, ${fieldType}`, EXIT_CODE.USAGE, {
|
|
146
|
+
code: "extension_item_field_type_conflict",
|
|
147
|
+
nextSteps: ["Make every active extension declaration for this field use the same type."]
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
definitions.set(fieldName, { name: fieldName, type: fieldType });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return definitions;
|
|
154
|
+
}
|
|
155
|
+
function assertNotReservedItemFieldName(fieldName) {
|
|
156
|
+
if (!RESERVED_ITEM_FIELD_NAMES.has(fieldName)) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
throw new PmCliError(`Extension item field "${fieldName}" collides with reserved item metadata`, EXIT_CODE.USAGE, {
|
|
160
|
+
code: "extension_item_field_reserved",
|
|
161
|
+
nextSteps: ["Rename the extension item field, preferably with an extension-specific prefix."]
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function collectRegisteredItemFieldNames(registrations) {
|
|
165
|
+
return [...collectRegisteredFieldDefinitions(registrations).keys()].sort((left, right) => left.localeCompare(right));
|
|
166
|
+
}
|
|
167
|
+
function parseRegisteredItemFieldAssignments(rawFields, registrations) {
|
|
168
|
+
if (!rawFields || rawFields.length === 0) {
|
|
169
|
+
return {};
|
|
170
|
+
}
|
|
171
|
+
const definitions = collectRegisteredFieldDefinitions(registrations);
|
|
172
|
+
const values = {};
|
|
173
|
+
for (const raw of rawFields) {
|
|
174
|
+
const { key, value } = parseFieldAssignment(raw);
|
|
175
|
+
const definition = definitions.get(key);
|
|
176
|
+
if (!definition) {
|
|
177
|
+
const known = [...definitions.keys()].sort((left, right) => left.localeCompare(right));
|
|
178
|
+
throw new PmCliError(`--field ${key} is not declared by an active extension item-field registration`, EXIT_CODE.USAGE, {
|
|
179
|
+
code: "extension_item_field_unknown",
|
|
180
|
+
recovery: { provided_fields: known },
|
|
181
|
+
nextSteps: known.length > 0 ? [`Use one of the declared fields: ${known.join(", ")}`] : ["Activate an extension that calls registerItemFields before setting extension fields."]
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
assertNotReservedItemFieldName(definition.name);
|
|
185
|
+
values[definition.name] = coerceRegisteredFieldValue(definition.name, definition.type, value);
|
|
186
|
+
}
|
|
187
|
+
return values;
|
|
188
|
+
}
|
|
189
|
+
function isValidFieldType(value, expectedType) {
|
|
190
|
+
if (expectedType === "string") {
|
|
191
|
+
return typeof value === "string";
|
|
192
|
+
}
|
|
193
|
+
if (expectedType === "number") {
|
|
194
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
195
|
+
}
|
|
196
|
+
if (expectedType === "boolean") {
|
|
197
|
+
return typeof value === "boolean";
|
|
198
|
+
}
|
|
199
|
+
if (expectedType === "array") {
|
|
200
|
+
return Array.isArray(value);
|
|
201
|
+
}
|
|
202
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
203
|
+
}
|
|
204
|
+
function isAllowedFieldValue(value, allowed) {
|
|
205
|
+
if (!allowed || allowed.length === 0) {
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
return allowed.some((candidate) => Object.is(candidate, value));
|
|
209
|
+
}
|
|
210
|
+
function applyRegisteredItemFieldDefaultsAndValidation(frontMatter, registrations, options = {}) {
|
|
211
|
+
if (!registrations) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
collectRegisteredFieldDefinitions(registrations);
|
|
215
|
+
for (const registration of registrations.item_fields) {
|
|
216
|
+
for (const definition of registration.fields) {
|
|
217
|
+
const fieldName = normalizeFieldName(definition.name);
|
|
218
|
+
if (!fieldName) {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
assertNotReservedItemFieldName(fieldName);
|
|
222
|
+
if (!(fieldName in frontMatter) && !options.skipDefaultFields?.has(fieldName) && Object.prototype.hasOwnProperty.call(definition, "default")) {
|
|
223
|
+
frontMatter[fieldName] = cloneFieldValue(definition.default);
|
|
224
|
+
}
|
|
225
|
+
const currentValue = frontMatter[fieldName];
|
|
226
|
+
if (currentValue === void 0) {
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
const expectedType = normalizeFieldType(definition.type);
|
|
230
|
+
if (expectedType && !isValidFieldType(currentValue, expectedType)) {
|
|
231
|
+
throw new TypeError(`Item field "${fieldName}" must be of type ${expectedType}`);
|
|
232
|
+
}
|
|
233
|
+
const allowedValues = Array.isArray(definition.values) ? definition.values : void 0;
|
|
234
|
+
if (!isAllowedFieldValue(currentValue, allowedValues)) {
|
|
235
|
+
throw new TypeError(`Item field "${fieldName}" must match one of the configured allowed values`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// dist/core/item/item-record.js
|
|
242
|
+
!(function() {
|
|
243
|
+
try {
|
|
244
|
+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
245
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "104fe68e-6cf6-52c7-86ab-063e6535ac0e");
|
|
246
|
+
} catch (e2) {
|
|
247
|
+
}
|
|
248
|
+
})();
|
|
249
|
+
function toItemRecord(item) {
|
|
250
|
+
return item;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// dist/core/history/history.js
|
|
254
|
+
import jsonPatch from "fast-json-patch";
|
|
255
|
+
!(function() {
|
|
256
|
+
try {
|
|
257
|
+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
258
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "9a356560-3dec-5529-a2b5-1b4224116c14");
|
|
259
|
+
} catch (e2) {
|
|
260
|
+
}
|
|
261
|
+
})();
|
|
262
|
+
var EMPTY_LEGACY_HASH_DOCUMENT = {
|
|
263
|
+
front_matter: {},
|
|
264
|
+
body: ""
|
|
265
|
+
};
|
|
266
|
+
function decodeJsonPointer(path5) {
|
|
267
|
+
if (!path5 || path5 === "/") {
|
|
268
|
+
return [];
|
|
269
|
+
}
|
|
270
|
+
if (!path5.startsWith("/")) {
|
|
271
|
+
return [];
|
|
272
|
+
}
|
|
273
|
+
return path5.slice(1).split("/").map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~"));
|
|
274
|
+
}
|
|
275
|
+
function isDefinedPointerPath(document, path5) {
|
|
276
|
+
const segments = decodeJsonPointer(path5);
|
|
277
|
+
if (segments.length === 0) {
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
let cursor = document;
|
|
281
|
+
for (const segment of segments) {
|
|
282
|
+
if (Array.isArray(cursor)) {
|
|
283
|
+
if (segment === "-" || !/^(0|[1-9]\d*)$/.test(segment)) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
const index = Number(segment);
|
|
287
|
+
if (!Number.isInteger(index) || index < 0 || index >= cursor.length) {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
const next2 = cursor[index];
|
|
291
|
+
if (next2 === void 0) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
cursor = next2;
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
if (typeof cursor !== "object" || cursor === null) {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
if (!Object.prototype.hasOwnProperty.call(cursor, segment)) {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
const next = cursor[segment];
|
|
304
|
+
if (next === void 0) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
cursor = next;
|
|
308
|
+
}
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
function normalizeHistoryPatchOps(beforeDocument, patch) {
|
|
312
|
+
const normalized = [];
|
|
313
|
+
let replayCursor = structuredClone(beforeDocument);
|
|
314
|
+
for (const operation of patch) {
|
|
315
|
+
const normalizedOperation = operation.op === "replace" && !isDefinedPointerPath(replayCursor, operation.path) ? { ...operation, op: "add" } : operation;
|
|
316
|
+
normalized.push(normalizedOperation);
|
|
317
|
+
replayCursor = jsonPatch.applyPatch(replayCursor, [normalizedOperation], true, true).newDocument;
|
|
318
|
+
}
|
|
319
|
+
return normalized;
|
|
320
|
+
}
|
|
321
|
+
function canonicalHashDocument(document) {
|
|
322
|
+
const hasMetadata = document.metadata && Object.keys(document.metadata).length > 0;
|
|
323
|
+
if (!hasMetadata) {
|
|
324
|
+
return {
|
|
325
|
+
front_matter: {},
|
|
326
|
+
body: document.body ?? ""
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
const canonical = canonicalDocument(document);
|
|
330
|
+
const orderedFrontMatter = orderObject(toItemRecord(canonical.metadata), FRONT_MATTER_KEY_ORDER);
|
|
331
|
+
return {
|
|
332
|
+
front_matter: orderedFrontMatter,
|
|
333
|
+
body: canonical.body
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function canonicalPatchDocument(document) {
|
|
337
|
+
const hasMetadata = document.metadata && Object.keys(document.metadata).length > 0;
|
|
338
|
+
if (!hasMetadata) {
|
|
339
|
+
return {
|
|
340
|
+
metadata: {},
|
|
341
|
+
body: document.body ?? ""
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
const canonical = canonicalDocument(document);
|
|
345
|
+
const orderedMetadata = orderObject(toItemRecord(canonical.metadata), FRONT_MATTER_KEY_ORDER);
|
|
346
|
+
return {
|
|
347
|
+
metadata: orderedMetadata,
|
|
348
|
+
body: canonical.body
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
function hashDocument(document) {
|
|
352
|
+
return sha256Hex(stableStringify(canonicalHashDocument(document)));
|
|
353
|
+
}
|
|
354
|
+
function hashEmptyDocument() {
|
|
355
|
+
return sha256Hex(stableStringify(EMPTY_LEGACY_HASH_DOCUMENT));
|
|
356
|
+
}
|
|
357
|
+
function createHistoryEntry(params) {
|
|
358
|
+
const beforeHashCanonical = canonicalHashDocument(params.before);
|
|
359
|
+
const afterHashCanonical = canonicalHashDocument(params.after);
|
|
360
|
+
const beforePatchCanonical = canonicalPatchDocument(params.before);
|
|
361
|
+
const afterPatchCanonical = canonicalPatchDocument(params.after);
|
|
362
|
+
const rawPatch = jsonPatch.compare(beforePatchCanonical, afterPatchCanonical);
|
|
363
|
+
const patch = normalizeHistoryPatchOps(beforePatchCanonical, rawPatch);
|
|
364
|
+
return {
|
|
365
|
+
ts: params.nowIso,
|
|
366
|
+
author: params.author,
|
|
367
|
+
op: params.op,
|
|
368
|
+
patch,
|
|
369
|
+
before_hash: sha256Hex(stableStringify(beforeHashCanonical)),
|
|
370
|
+
after_hash: sha256Hex(stableStringify(afterHashCanonical)),
|
|
371
|
+
message: params.message === void 0 ? void 0 : params.message
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
async function appendHistoryEntry(historyPath, entry) {
|
|
375
|
+
const override = await runActiveServiceOverride("history_append", {
|
|
376
|
+
history_path: historyPath,
|
|
377
|
+
entry
|
|
378
|
+
});
|
|
379
|
+
if (override.handled) {
|
|
380
|
+
if (override.result === false) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (typeof override.result === "string") {
|
|
384
|
+
await appendLineAtomic(historyPath, override.result);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
if (typeof override.result === "object" && override.result !== null) {
|
|
388
|
+
const record = override.result;
|
|
389
|
+
if (record.skip === true) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
const nextHistoryPath = typeof record.history_path === "string" ? record.history_path : historyPath;
|
|
393
|
+
if (typeof record.line === "string") {
|
|
394
|
+
await appendLineAtomic(nextHistoryPath, record.line);
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
const nextEntry = record.entry ?? entry;
|
|
398
|
+
await appendLineAtomic(nextHistoryPath, JSON.stringify(nextEntry));
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
await appendLineAtomic(historyPath, JSON.stringify(entry));
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// dist/core/history/history-stream-policy.js
|
|
406
|
+
import fs from "node:fs/promises";
|
|
407
|
+
import path from "node:path";
|
|
408
|
+
!(function() {
|
|
409
|
+
try {
|
|
410
|
+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
411
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "6aa88fb8-fe40-5d0f-bee8-b348eda9309e");
|
|
412
|
+
} catch (e2) {
|
|
413
|
+
}
|
|
414
|
+
})();
|
|
415
|
+
function toSortedUniqueItemIds(itemIds) {
|
|
416
|
+
return [...new Set(itemIds.filter((value) => value.trim().length > 0))].sort((left, right) => left.localeCompare(right));
|
|
417
|
+
}
|
|
418
|
+
function strictMissingStreamError(itemId, commandLabel) {
|
|
419
|
+
return new PmCliError(`Missing history stream for ${itemId}. ${commandLabel} requires history streams when settings.history.missing_stream is strict_error.`, EXIT_CODE.NOT_FOUND);
|
|
420
|
+
}
|
|
421
|
+
async function createStream(historyPath, commandLabel) {
|
|
422
|
+
await ensureDir(path.dirname(historyPath));
|
|
423
|
+
const handle = await fs.open(historyPath, "a");
|
|
424
|
+
await handle.close();
|
|
425
|
+
return runActiveOnWriteHooks({
|
|
426
|
+
path: historyPath,
|
|
427
|
+
scope: "project",
|
|
428
|
+
op: `${commandLabel}:history:auto_create`
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
async function enforceHistoryStreamPolicyForItem(params) {
|
|
432
|
+
return enforceHistoryStreamPolicyForItems({
|
|
433
|
+
pmRoot: params.pmRoot,
|
|
434
|
+
settings: params.settings,
|
|
435
|
+
itemIds: [params.itemId],
|
|
436
|
+
commandLabel: params.commandLabel
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
async function enforceHistoryStreamPolicyForItems(params) {
|
|
440
|
+
const ids = toSortedUniqueItemIds(params.itemIds);
|
|
441
|
+
const autoCreated = [];
|
|
442
|
+
const warnings = [];
|
|
443
|
+
for (const itemId of ids) {
|
|
444
|
+
const historyPath = getHistoryPath(params.pmRoot, itemId);
|
|
445
|
+
if (await pathExists(historyPath)) {
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
if (params.settings.history.missing_stream === "strict_error") {
|
|
449
|
+
throw strictMissingStreamError(itemId, params.commandLabel);
|
|
450
|
+
}
|
|
451
|
+
warnings.push(...await createStream(historyPath, params.commandLabel));
|
|
452
|
+
warnings.push(`history_stream_auto_created:${itemId}`);
|
|
453
|
+
autoCreated.push(itemId);
|
|
454
|
+
}
|
|
455
|
+
return {
|
|
456
|
+
auto_created_ids: autoCreated,
|
|
457
|
+
warnings
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// dist/core/lock/lock.js
|
|
462
|
+
import fs2 from "node:fs/promises";
|
|
463
|
+
import path2 from "node:path";
|
|
464
|
+
!(function() {
|
|
465
|
+
try {
|
|
466
|
+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
467
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "5747034b-5b93-59ff-8764-7594ff8c0617");
|
|
468
|
+
} catch (e2) {
|
|
469
|
+
}
|
|
470
|
+
})();
|
|
471
|
+
function parseLockInfo(raw) {
|
|
472
|
+
let parsed;
|
|
473
|
+
try {
|
|
474
|
+
parsed = JSON.parse(raw);
|
|
475
|
+
} catch {
|
|
476
|
+
return {
|
|
477
|
+
info: null,
|
|
478
|
+
warnings: ["lock_info_invalid_json"]
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
482
|
+
return {
|
|
483
|
+
info: null,
|
|
484
|
+
warnings: ["lock_info_invalid_shape"]
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
const candidate = parsed;
|
|
488
|
+
const id = candidate.id;
|
|
489
|
+
const pid = candidate.pid;
|
|
490
|
+
const owner = candidate.owner;
|
|
491
|
+
const createdAt = candidate.created_at;
|
|
492
|
+
const ttlSeconds = candidate.ttl_seconds;
|
|
493
|
+
if (typeof id !== "string" || typeof pid !== "number" || !Number.isFinite(pid) || typeof owner !== "string" || typeof createdAt !== "string" || typeof ttlSeconds !== "number" || !Number.isFinite(ttlSeconds)) {
|
|
494
|
+
return {
|
|
495
|
+
info: null,
|
|
496
|
+
warnings: ["lock_info_invalid_shape"]
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
return {
|
|
500
|
+
info: {
|
|
501
|
+
id,
|
|
502
|
+
pid,
|
|
503
|
+
owner,
|
|
504
|
+
created_at: createdAt,
|
|
505
|
+
ttl_seconds: ttlSeconds
|
|
506
|
+
},
|
|
507
|
+
warnings: []
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
async function readLockInfo(lockPath) {
|
|
511
|
+
try {
|
|
512
|
+
const raw = await fs2.readFile(lockPath, "utf8");
|
|
513
|
+
await runActiveOnReadHooks({
|
|
514
|
+
path: lockPath,
|
|
515
|
+
scope: "project"
|
|
516
|
+
});
|
|
517
|
+
return parseLockInfo(raw);
|
|
518
|
+
} catch (error) {
|
|
519
|
+
if (isErrno(error, "ENOENT")) {
|
|
520
|
+
return {
|
|
521
|
+
info: null,
|
|
522
|
+
warnings: []
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
return {
|
|
526
|
+
info: null,
|
|
527
|
+
warnings: ["lock_info_read_failed"]
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
function isErrno(error, code) {
|
|
532
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
533
|
+
}
|
|
534
|
+
async function emitLockWriteHook(lockPath, op) {
|
|
535
|
+
await runActiveOnWriteHooks({
|
|
536
|
+
path: lockPath,
|
|
537
|
+
scope: "project",
|
|
538
|
+
op
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
function buildLockPayload(id, owner, ttlSeconds) {
|
|
542
|
+
return {
|
|
543
|
+
id,
|
|
544
|
+
pid: process.pid,
|
|
545
|
+
owner,
|
|
546
|
+
created_at: nowIso(),
|
|
547
|
+
ttl_seconds: ttlSeconds
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
async function createLockFile(lockPath, id, owner, ttlSeconds) {
|
|
551
|
+
await fs2.mkdir(path2.dirname(lockPath), { recursive: true });
|
|
552
|
+
const handle = await fs2.open(lockPath, "wx");
|
|
553
|
+
try {
|
|
554
|
+
await handle.writeFile(`${JSON.stringify(buildLockPayload(id, owner, ttlSeconds), null, 2)}
|
|
555
|
+
`, "utf8");
|
|
556
|
+
} finally {
|
|
557
|
+
await handle.close();
|
|
558
|
+
}
|
|
559
|
+
await emitLockWriteHook(lockPath, "lock:create");
|
|
560
|
+
}
|
|
561
|
+
async function unlinkLockWithHook(lockPath, op) {
|
|
562
|
+
try {
|
|
563
|
+
await fs2.unlink(lockPath);
|
|
564
|
+
await emitLockWriteHook(lockPath, op);
|
|
565
|
+
} catch {
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
function isStaleLock(info, ttlSeconds) {
|
|
569
|
+
const createdAtMs = info?.created_at ? Date.parse(info.created_at) : Number.NaN;
|
|
570
|
+
const ageMs = Number.isFinite(createdAtMs) ? Date.now() - createdAtMs : Number.POSITIVE_INFINITY;
|
|
571
|
+
return ageMs > ttlSeconds * 1e3;
|
|
572
|
+
}
|
|
573
|
+
function lockOwnerSuffix(info) {
|
|
574
|
+
return info?.owner ? ` (owner ${info.owner})` : "";
|
|
575
|
+
}
|
|
576
|
+
async function handleExistingLock(lockPath, id, ttlSeconds, force, forceRequiredForStaleLock) {
|
|
577
|
+
const lockInfo = await readLockInfo(lockPath);
|
|
578
|
+
if (!isStaleLock(lockInfo.info, ttlSeconds)) {
|
|
579
|
+
throw new PmCliError(`Item ${id} is locked${lockOwnerSuffix(lockInfo.info)}`, EXIT_CODE.CONFLICT);
|
|
580
|
+
}
|
|
581
|
+
if (!force && forceRequiredForStaleLock) {
|
|
582
|
+
const warningSuffix = lockInfo.warnings.length > 0 ? ` (${lockInfo.warnings.join(",")})` : "";
|
|
583
|
+
throw new PmCliError(`Item ${id} lock is stale${warningSuffix}; rerun with --force when supported for this command`, EXIT_CODE.CONFLICT);
|
|
584
|
+
}
|
|
585
|
+
await unlinkLockWithHook(lockPath, "lock:stale_remove");
|
|
586
|
+
}
|
|
587
|
+
async function acquireLock(pmRoot, id, ttlSeconds, owner, force = false, forceRequiredForStaleLock = true) {
|
|
588
|
+
const lockOverride = await runActiveServiceOverride("lock_acquire", {
|
|
589
|
+
pm_root: pmRoot,
|
|
590
|
+
id,
|
|
591
|
+
ttl_seconds: ttlSeconds,
|
|
592
|
+
owner,
|
|
593
|
+
force,
|
|
594
|
+
force_required_for_stale_lock: forceRequiredForStaleLock
|
|
595
|
+
});
|
|
596
|
+
if (lockOverride.handled) {
|
|
597
|
+
const releaseFromFunction = typeof lockOverride.result === "function" ? lockOverride.result : null;
|
|
598
|
+
const releaseFromObject = typeof lockOverride.result === "object" && lockOverride.result !== null && "release" in lockOverride.result && typeof lockOverride.result.release === "function" ? lockOverride.result.release : null;
|
|
599
|
+
const release = releaseFromFunction ?? releaseFromObject;
|
|
600
|
+
if (release) {
|
|
601
|
+
return async () => {
|
|
602
|
+
await Promise.resolve(release());
|
|
603
|
+
await runActiveServiceOverride("lock_release", {
|
|
604
|
+
pm_root: pmRoot,
|
|
605
|
+
id,
|
|
606
|
+
owner
|
|
607
|
+
});
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
const lockPath = getLockPath(pmRoot, id);
|
|
612
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
613
|
+
try {
|
|
614
|
+
await createLockFile(lockPath, id, owner, ttlSeconds);
|
|
615
|
+
return async () => {
|
|
616
|
+
await unlinkLockWithHook(lockPath, "lock:release");
|
|
617
|
+
await runActiveServiceOverride("lock_release", {
|
|
618
|
+
pm_root: pmRoot,
|
|
619
|
+
id,
|
|
620
|
+
owner
|
|
621
|
+
});
|
|
622
|
+
};
|
|
623
|
+
} catch (error) {
|
|
624
|
+
if (!isErrno(error, "EEXIST")) {
|
|
625
|
+
throw new PmCliError(`Failed to acquire lock for ${id}: ${toErrorMessage(error)}`, EXIT_CODE.GENERIC_FAILURE);
|
|
626
|
+
}
|
|
627
|
+
await handleExistingLock(lockPath, id, ttlSeconds, force, forceRequiredForStaleLock);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
throw new PmCliError(`Failed to acquire lock for ${id}`, EXIT_CODE.CONFLICT);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// dist/core/store/front-matter-cache.js
|
|
634
|
+
import fs3 from "node:fs/promises";
|
|
635
|
+
import path3 from "node:path";
|
|
636
|
+
import { createHash } from "node:crypto";
|
|
637
|
+
!(function() {
|
|
638
|
+
try {
|
|
639
|
+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
640
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "0b313ee5-78cb-5aa7-a288-d41e3ad6ecf8");
|
|
641
|
+
} catch (e2) {
|
|
642
|
+
}
|
|
643
|
+
})();
|
|
644
|
+
var CACHE_VERSION = 6;
|
|
645
|
+
var CACHE_FILENAME = "metadata-cache.json";
|
|
646
|
+
var BODY_CACHE_FILENAME = "metadata-cache-bodies.json";
|
|
647
|
+
var COLLECTIONS_CACHE_FILENAME = "metadata-cache-collections.json";
|
|
648
|
+
var HEAVY_METADATA_KEYS = [
|
|
649
|
+
"comments",
|
|
650
|
+
"notes",
|
|
651
|
+
"learnings",
|
|
652
|
+
"files",
|
|
653
|
+
"tests",
|
|
654
|
+
"test_runs",
|
|
655
|
+
"docs"
|
|
656
|
+
];
|
|
657
|
+
function resolveActiveExtensionFieldNames() {
|
|
658
|
+
return collectRegisteredItemFieldNames(getActiveExtensionRegistrations());
|
|
659
|
+
}
|
|
660
|
+
function splitHeavyMetadata(metadata) {
|
|
661
|
+
const light = { ...metadata };
|
|
662
|
+
const heavy = {};
|
|
663
|
+
for (const key of HEAVY_METADATA_KEYS) {
|
|
664
|
+
if (key in light) {
|
|
665
|
+
heavy[key] = light[key];
|
|
666
|
+
delete light[key];
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
return { light, heavy };
|
|
670
|
+
}
|
|
671
|
+
function mergeHeavyMetadata(light, heavy) {
|
|
672
|
+
if (!heavy || Object.keys(heavy).length === 0) {
|
|
673
|
+
return light;
|
|
674
|
+
}
|
|
675
|
+
return { ...light, ...heavy };
|
|
676
|
+
}
|
|
677
|
+
function computeContextFingerprint(preferredFormat, typeToFolder, schema, extensionFieldNames) {
|
|
678
|
+
const hash = createHash("sha256");
|
|
679
|
+
hash.update(`format:${preferredFormat ?? "default"}`);
|
|
680
|
+
const sortedTypes = Object.entries(typeToFolder).sort(([a], [b]) => a.localeCompare(b)).map(([type, folder]) => `${type}=${folder}`).join(",");
|
|
681
|
+
hash.update(`|types:${sortedTypes}`);
|
|
682
|
+
if (schema) {
|
|
683
|
+
hash.update(`|schema:${JSON.stringify(schema)}`);
|
|
684
|
+
}
|
|
685
|
+
if (extensionFieldNames.length > 0) {
|
|
686
|
+
hash.update(`|extension_fields:${extensionFieldNames.join(",")}`);
|
|
687
|
+
}
|
|
688
|
+
return hash.digest("hex").slice(0, 16);
|
|
689
|
+
}
|
|
690
|
+
function getCachePath(pmRoot) {
|
|
691
|
+
return path3.join(pmRoot, "runtime", CACHE_FILENAME);
|
|
692
|
+
}
|
|
693
|
+
function getBodyCachePath(pmRoot) {
|
|
694
|
+
return path3.join(pmRoot, "runtime", BODY_CACHE_FILENAME);
|
|
695
|
+
}
|
|
696
|
+
function getCollectionsCachePath(pmRoot) {
|
|
697
|
+
return path3.join(pmRoot, "runtime", COLLECTIONS_CACHE_FILENAME);
|
|
698
|
+
}
|
|
699
|
+
async function loadCache(pmRoot) {
|
|
700
|
+
try {
|
|
701
|
+
const raw = await fs3.readFile(getCachePath(pmRoot), "utf8");
|
|
702
|
+
const parsed = JSON.parse(raw);
|
|
703
|
+
if (parsed.version !== CACHE_VERSION || typeof parsed.entries !== "object" || parsed.entries === null) {
|
|
704
|
+
return null;
|
|
705
|
+
}
|
|
706
|
+
return parsed;
|
|
707
|
+
} catch {
|
|
708
|
+
return null;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
async function loadBodyCache(pmRoot) {
|
|
712
|
+
try {
|
|
713
|
+
const raw = await fs3.readFile(getBodyCachePath(pmRoot), "utf8");
|
|
714
|
+
const parsed = JSON.parse(raw);
|
|
715
|
+
if (parsed.version !== CACHE_VERSION || typeof parsed.bodies !== "object" || parsed.bodies === null) {
|
|
716
|
+
return null;
|
|
717
|
+
}
|
|
718
|
+
return parsed;
|
|
719
|
+
} catch {
|
|
720
|
+
return null;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
async function loadCollectionsCache(pmRoot) {
|
|
724
|
+
try {
|
|
725
|
+
const raw = await fs3.readFile(getCollectionsCachePath(pmRoot), "utf8");
|
|
726
|
+
const parsed = JSON.parse(raw);
|
|
727
|
+
if (parsed.version !== CACHE_VERSION || typeof parsed.collections !== "object" || parsed.collections === null) {
|
|
728
|
+
return null;
|
|
729
|
+
}
|
|
730
|
+
return parsed;
|
|
731
|
+
} catch {
|
|
732
|
+
return null;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
async function persistCache(cachePath, envelope) {
|
|
736
|
+
await fs3.mkdir(path3.dirname(cachePath), { recursive: true });
|
|
737
|
+
await writeFileAtomic(cachePath, JSON.stringify(envelope));
|
|
738
|
+
}
|
|
739
|
+
function appendWarning(warnings, warning) {
|
|
740
|
+
if (warnings && !warnings.includes(warning)) {
|
|
741
|
+
warnings.push(warning);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
function statMatches(signature, mtimeMs, ctimeMs, size) {
|
|
745
|
+
return signature.mtime_ms === mtimeMs && signature.ctime_ms === ctimeMs && signature.size === size;
|
|
746
|
+
}
|
|
747
|
+
async function listAllDocumentCandidatesCached(pmRoot, preferredFormat, typeToFolder, warnings, schema, options = {}) {
|
|
748
|
+
const includeBody = options.includeBody !== false;
|
|
749
|
+
const includeCollections = options.includeCollections !== false;
|
|
750
|
+
const extensionFieldNames = resolveActiveExtensionFieldNames();
|
|
751
|
+
const contextFingerprint = computeContextFingerprint(preferredFormat, typeToFolder, schema, extensionFieldNames);
|
|
752
|
+
const existingCache = await loadCache(pmRoot);
|
|
753
|
+
const previousEntries = existingCache && existingCache.context_fingerprint === contextFingerprint ? existingCache.entries : {};
|
|
754
|
+
const existingBodyCache = includeBody ? await loadBodyCache(pmRoot) : null;
|
|
755
|
+
const previousBodies = existingBodyCache && existingBodyCache.context_fingerprint === contextFingerprint ? existingBodyCache.bodies : {};
|
|
756
|
+
const existingCollectionsCache = includeCollections ? await loadCollectionsCache(pmRoot) : null;
|
|
757
|
+
const previousCollections = existingCollectionsCache && existingCollectionsCache.context_fingerprint === contextFingerprint ? existingCollectionsCache.collections : {};
|
|
758
|
+
const entries = Object.entries(typeToFolder);
|
|
759
|
+
const dirResults = await Promise.all(entries.map(async ([, folder]) => {
|
|
760
|
+
const dirPath = path3.join(pmRoot, folder);
|
|
761
|
+
try {
|
|
762
|
+
const files = await fs3.readdir(dirPath);
|
|
763
|
+
return { folder, dirPath, files };
|
|
764
|
+
} catch (error) {
|
|
765
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code !== "ENOENT") {
|
|
766
|
+
appendWarning(warnings, `item_list_directory_read_failed:${folder}`);
|
|
767
|
+
}
|
|
768
|
+
return { folder, dirPath, files: [] };
|
|
769
|
+
}
|
|
770
|
+
}));
|
|
771
|
+
const dispatchReadHooks = hasActiveOnReadHooks();
|
|
772
|
+
const newEntries = {};
|
|
773
|
+
const newBodies = {};
|
|
774
|
+
const newCollections = {};
|
|
775
|
+
const documentsById = /* @__PURE__ */ new Map();
|
|
776
|
+
let metadataMiss = false;
|
|
777
|
+
let bodyMiss = false;
|
|
778
|
+
let collectionsMiss = false;
|
|
779
|
+
const parseTasks = [];
|
|
780
|
+
for (const { folder, dirPath, files } of dirResults) {
|
|
781
|
+
for (const file of files) {
|
|
782
|
+
if (!ITEM_FILE_EXTENSIONS.some((ext) => file.toLowerCase().endsWith(ext))) {
|
|
783
|
+
continue;
|
|
784
|
+
}
|
|
785
|
+
const filePath = path3.join(dirPath, file);
|
|
786
|
+
const relativePath = path3.relative(pmRoot, filePath);
|
|
787
|
+
parseTasks.push((async () => {
|
|
788
|
+
try {
|
|
789
|
+
const stat = await fs3.stat(filePath);
|
|
790
|
+
const mtimeMs = stat.mtimeMs;
|
|
791
|
+
const ctimeMs = stat.ctimeMs;
|
|
792
|
+
const { size } = stat;
|
|
793
|
+
const itemFormat = getItemFormatFromPath(filePath);
|
|
794
|
+
if (dispatchReadHooks) {
|
|
795
|
+
for (const warning of await runActiveOnReadHooks({ path: filePath, scope: "project" })) {
|
|
796
|
+
appendWarning(warnings, warning);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
const cachedEntry = previousEntries[relativePath];
|
|
800
|
+
const metadataCached = cachedEntry !== void 0 && statMatches(cachedEntry, mtimeMs, ctimeMs, size);
|
|
801
|
+
const cachedBody = previousBodies[relativePath];
|
|
802
|
+
const bodyCached = cachedBody !== void 0 && statMatches(cachedBody, mtimeMs, ctimeMs, size);
|
|
803
|
+
const cachedCollections = previousCollections[relativePath];
|
|
804
|
+
const collectionsCached = cachedCollections !== void 0 && statMatches(cachedCollections, mtimeMs, ctimeMs, size);
|
|
805
|
+
const needRead = !metadataCached || includeBody && !bodyCached || includeCollections && !collectionsCached;
|
|
806
|
+
let lightMetadata;
|
|
807
|
+
let heavyMetadata;
|
|
808
|
+
let bodyLength;
|
|
809
|
+
let body;
|
|
810
|
+
if (needRead) {
|
|
811
|
+
const raw = await fs3.readFile(filePath, "utf8");
|
|
812
|
+
const parsed = parseItemDocument(raw, {
|
|
813
|
+
format: itemFormat,
|
|
814
|
+
schema,
|
|
815
|
+
extensionFieldNames,
|
|
816
|
+
onWarning: (w) => appendWarning(warnings, w)
|
|
817
|
+
});
|
|
818
|
+
const split = splitHeavyMetadata(parsed.metadata);
|
|
819
|
+
lightMetadata = metadataCached ? cachedEntry.metadata : split.light;
|
|
820
|
+
bodyLength = metadataCached ? cachedEntry.body_length : parsed.body.length;
|
|
821
|
+
body = includeBody ? parsed.body : void 0;
|
|
822
|
+
if (includeCollections) {
|
|
823
|
+
heavyMetadata = collectionsCached ? cachedCollections.collections : split.heavy;
|
|
824
|
+
}
|
|
825
|
+
if (!metadataCached) {
|
|
826
|
+
metadataMiss = true;
|
|
827
|
+
}
|
|
828
|
+
if (includeBody && !bodyCached) {
|
|
829
|
+
bodyMiss = true;
|
|
830
|
+
}
|
|
831
|
+
if (includeCollections && !collectionsCached) {
|
|
832
|
+
collectionsMiss = true;
|
|
833
|
+
}
|
|
834
|
+
} else {
|
|
835
|
+
lightMetadata = cachedEntry.metadata;
|
|
836
|
+
bodyLength = cachedEntry.body_length;
|
|
837
|
+
body = includeBody ? cachedBody.body : void 0;
|
|
838
|
+
heavyMetadata = includeCollections && cachedCollections ? cachedCollections.collections : void 0;
|
|
839
|
+
}
|
|
840
|
+
newEntries[relativePath] = {
|
|
841
|
+
mtime_ms: mtimeMs,
|
|
842
|
+
ctime_ms: ctimeMs,
|
|
843
|
+
size,
|
|
844
|
+
metadata: lightMetadata,
|
|
845
|
+
body_length: bodyLength
|
|
846
|
+
};
|
|
847
|
+
if (includeBody && body !== void 0) {
|
|
848
|
+
newBodies[relativePath] = { mtime_ms: mtimeMs, ctime_ms: ctimeMs, size, body };
|
|
849
|
+
}
|
|
850
|
+
if (includeCollections && heavyMetadata !== void 0) {
|
|
851
|
+
newCollections[relativePath] = { mtime_ms: mtimeMs, ctime_ms: ctimeMs, size, collections: heavyMetadata };
|
|
852
|
+
}
|
|
853
|
+
const metadata = includeCollections ? mergeHeavyMetadata(lightMetadata, heavyMetadata) : lightMetadata;
|
|
854
|
+
const existing = documentsById.get(metadata.id);
|
|
855
|
+
const candidate = {
|
|
856
|
+
metadata,
|
|
857
|
+
body,
|
|
858
|
+
item_format: itemFormat,
|
|
859
|
+
item_path: filePath
|
|
860
|
+
};
|
|
861
|
+
if (!existing) {
|
|
862
|
+
documentsById.set(metadata.id, { candidate, itemFormat });
|
|
863
|
+
} else {
|
|
864
|
+
const shouldReplace = preferredFormat ? itemFormat === preferredFormat && existing.itemFormat !== preferredFormat : itemFormat === "toon" && existing.itemFormat !== "toon";
|
|
865
|
+
if (shouldReplace) {
|
|
866
|
+
documentsById.set(metadata.id, { candidate, itemFormat });
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
} catch {
|
|
870
|
+
appendWarning(warnings, `item_list_item_read_failed:${folder}/${file}`);
|
|
871
|
+
}
|
|
872
|
+
})());
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
await Promise.all(parseTasks);
|
|
876
|
+
const metadataDirty = metadataMiss || Object.keys(previousEntries).length !== Object.keys(newEntries).length;
|
|
877
|
+
if (metadataDirty || existingCache === null || existingCache.context_fingerprint !== contextFingerprint) {
|
|
878
|
+
await persistCache(getCachePath(pmRoot), {
|
|
879
|
+
version: CACHE_VERSION,
|
|
880
|
+
context_fingerprint: contextFingerprint,
|
|
881
|
+
entries: newEntries
|
|
882
|
+
}).catch(() => {
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
if (includeBody) {
|
|
886
|
+
const bodyDirty = bodyMiss || Object.keys(previousBodies).length !== Object.keys(newBodies).length;
|
|
887
|
+
if (bodyDirty || existingBodyCache === null || existingBodyCache.context_fingerprint !== contextFingerprint) {
|
|
888
|
+
await persistCache(getBodyCachePath(pmRoot), {
|
|
889
|
+
version: CACHE_VERSION,
|
|
890
|
+
context_fingerprint: contextFingerprint,
|
|
891
|
+
bodies: newBodies
|
|
892
|
+
}).catch(() => {
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
if (includeCollections) {
|
|
897
|
+
const collectionsDirty = collectionsMiss || Object.keys(previousCollections).length !== Object.keys(newCollections).length;
|
|
898
|
+
if (collectionsDirty || existingCollectionsCache === null || existingCollectionsCache.context_fingerprint !== contextFingerprint) {
|
|
899
|
+
await persistCache(getCollectionsCachePath(pmRoot), {
|
|
900
|
+
version: CACHE_VERSION,
|
|
901
|
+
context_fingerprint: contextFingerprint,
|
|
902
|
+
collections: newCollections
|
|
903
|
+
}).catch(() => {
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
return [...documentsById.values()].sort((left, right) => left.candidate.metadata.id.localeCompare(right.candidate.metadata.id)).map((entry) => entry.candidate);
|
|
908
|
+
}
|
|
909
|
+
async function listAllDocumentsCached(pmRoot, preferredFormat, typeToFolder, warnings, schema) {
|
|
910
|
+
const candidates = await listAllDocumentCandidatesCached(pmRoot, preferredFormat, typeToFolder, warnings, schema, {
|
|
911
|
+
includeBody: false
|
|
912
|
+
});
|
|
913
|
+
return candidates.map((candidate) => ({
|
|
914
|
+
metadata: candidate.metadata,
|
|
915
|
+
body: candidate.body ?? ""
|
|
916
|
+
}));
|
|
917
|
+
}
|
|
918
|
+
async function listAllDocumentsCachedLight(pmRoot, preferredFormat, typeToFolder, warnings, schema) {
|
|
919
|
+
const candidates = await listAllDocumentCandidatesCached(pmRoot, preferredFormat, typeToFolder, warnings, schema, {
|
|
920
|
+
includeBody: false,
|
|
921
|
+
includeCollections: false
|
|
922
|
+
});
|
|
923
|
+
return candidates.map((candidate) => ({
|
|
924
|
+
metadata: candidate.metadata,
|
|
925
|
+
body: candidate.body ?? ""
|
|
926
|
+
}));
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
// dist/core/store/item-store.js
|
|
930
|
+
import fs4 from "node:fs/promises";
|
|
931
|
+
import path4 from "node:path";
|
|
932
|
+
!(function() {
|
|
933
|
+
try {
|
|
934
|
+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
935
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "88895950-2871-5fe9-9c4e-04db3aada937");
|
|
936
|
+
} catch (e2) {
|
|
937
|
+
}
|
|
938
|
+
})();
|
|
939
|
+
async function fileExists(targetPath) {
|
|
940
|
+
try {
|
|
941
|
+
await fs4.access(targetPath);
|
|
942
|
+
return true;
|
|
943
|
+
} catch {
|
|
944
|
+
return false;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
function appendWarning2(warnings, warning) {
|
|
948
|
+
if (!warnings) {
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
if (!warnings.includes(warning)) {
|
|
952
|
+
warnings.push(warning);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
function resolveActiveExtensionFieldNames2(explicit) {
|
|
956
|
+
return explicit ?? collectRegisteredItemFieldNames(getActiveExtensionRegistrations());
|
|
957
|
+
}
|
|
958
|
+
function resolveItemFormatSearchOrder(preferredFormat) {
|
|
959
|
+
if (preferredFormat === "toon") {
|
|
960
|
+
return ["toon", "json_markdown"];
|
|
961
|
+
}
|
|
962
|
+
if (preferredFormat === "json_markdown") {
|
|
963
|
+
return ["json_markdown", "toon"];
|
|
964
|
+
}
|
|
965
|
+
return ["toon", "json_markdown"];
|
|
966
|
+
}
|
|
967
|
+
async function locateItem(pmRoot, rawId, idPrefix, preferredFormat, typeToFolder = TYPE_TO_FOLDER) {
|
|
968
|
+
const normalizedId = normalizeItemId(rawId, idPrefix);
|
|
969
|
+
const rawNormalizedId = normalizeRawItemId(rawId);
|
|
970
|
+
const candidateIds = normalizedId === rawNormalizedId ? [normalizedId] : [normalizedId, rawNormalizedId];
|
|
971
|
+
const entries = Object.entries(typeToFolder);
|
|
972
|
+
const searchOrder = resolveItemFormatSearchOrder(preferredFormat);
|
|
973
|
+
for (const candidateId of candidateIds) {
|
|
974
|
+
for (const [type] of entries) {
|
|
975
|
+
for (const itemFormat of searchOrder) {
|
|
976
|
+
const itemPath = getItemPath(pmRoot, type, candidateId, itemFormat, typeToFolder);
|
|
977
|
+
if (await fileExists(itemPath)) {
|
|
978
|
+
return {
|
|
979
|
+
id: candidateId,
|
|
980
|
+
type,
|
|
981
|
+
itemPath,
|
|
982
|
+
item_format: itemFormat
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
return null;
|
|
989
|
+
}
|
|
990
|
+
async function readLocatedItem(item, options = {}) {
|
|
991
|
+
const raw = await fs4.readFile(item.itemPath, "utf8");
|
|
992
|
+
await runActiveOnReadHooks({
|
|
993
|
+
path: item.itemPath,
|
|
994
|
+
scope: "project"
|
|
995
|
+
});
|
|
996
|
+
const document = parseItemDocument(raw, {
|
|
997
|
+
format: item.item_format,
|
|
998
|
+
schema: options.schema,
|
|
999
|
+
extensionFieldNames: resolveActiveExtensionFieldNames2(options.extensionFieldNames),
|
|
1000
|
+
onWarning: (warning) => appendWarning2(options.warnings, warning)
|
|
1001
|
+
});
|
|
1002
|
+
return { raw, document };
|
|
1003
|
+
}
|
|
1004
|
+
async function listAllFrontMatter(pmRoot, preferredFormat, typeToFolder = TYPE_TO_FOLDER, warnings, schema) {
|
|
1005
|
+
const documents = await listAllDocumentsCached(pmRoot, preferredFormat, typeToFolder, warnings, schema);
|
|
1006
|
+
return documents.map((document) => document.metadata);
|
|
1007
|
+
}
|
|
1008
|
+
async function listAllFrontMatterLight(pmRoot, preferredFormat, typeToFolder = TYPE_TO_FOLDER, warnings, schema) {
|
|
1009
|
+
const documents = await listAllDocumentsCachedLight(pmRoot, preferredFormat, typeToFolder, warnings, schema);
|
|
1010
|
+
return documents.map((document) => document.metadata);
|
|
1011
|
+
}
|
|
1012
|
+
async function listAllFrontMatterWithBody(pmRoot, preferredFormat, typeToFolder = TYPE_TO_FOLDER, warnings, schema) {
|
|
1013
|
+
const candidates = await listAllDocumentCandidatesCached(pmRoot, preferredFormat, typeToFolder, warnings, schema, { includeBody: true });
|
|
1014
|
+
return candidates.map((candidate) => ({
|
|
1015
|
+
...candidate.metadata,
|
|
1016
|
+
body: candidate.body ?? ""
|
|
1017
|
+
}));
|
|
1018
|
+
}
|
|
1019
|
+
async function listKnownItemIds(pmRoot, typeToFolder) {
|
|
1020
|
+
const folders = new Set(Object.values(typeToFolder));
|
|
1021
|
+
const allIds = [];
|
|
1022
|
+
await Promise.all([...folders].map(async (folder) => {
|
|
1023
|
+
try {
|
|
1024
|
+
const entries = await fs4.readdir(path4.join(pmRoot, folder));
|
|
1025
|
+
for (const entry of entries) {
|
|
1026
|
+
for (const ext of ITEM_FILE_EXTENSIONS) {
|
|
1027
|
+
if (entry.toLowerCase().endsWith(ext)) {
|
|
1028
|
+
allIds.push(entry.slice(0, -ext.length));
|
|
1029
|
+
break;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
} catch {
|
|
1034
|
+
}
|
|
1035
|
+
}));
|
|
1036
|
+
return allIds;
|
|
1037
|
+
}
|
|
1038
|
+
function levenshtein(a, b) {
|
|
1039
|
+
if (a === b)
|
|
1040
|
+
return 0;
|
|
1041
|
+
if (a.length === 0)
|
|
1042
|
+
return b.length;
|
|
1043
|
+
if (b.length === 0)
|
|
1044
|
+
return a.length;
|
|
1045
|
+
let prev = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
1046
|
+
for (let i = 1; i <= a.length; i++) {
|
|
1047
|
+
const curr = [i];
|
|
1048
|
+
for (let j = 1; j <= b.length; j++) {
|
|
1049
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
1050
|
+
curr.push(Math.min(curr[j - 1] + 1, prev[j] + 1, prev[j - 1] + cost));
|
|
1051
|
+
}
|
|
1052
|
+
prev = curr;
|
|
1053
|
+
}
|
|
1054
|
+
return prev[b.length];
|
|
1055
|
+
}
|
|
1056
|
+
async function buildDidYouMeanSuggestions(pmRoot, badId, idPrefix, typeToFolder) {
|
|
1057
|
+
const normalized = normalizeItemId(badId, idPrefix);
|
|
1058
|
+
const ids = await listKnownItemIds(pmRoot, typeToFolder);
|
|
1059
|
+
if (ids.length === 0)
|
|
1060
|
+
return [];
|
|
1061
|
+
const scored = ids.map((id) => ({ id, distance: levenshtein(id, normalized) })).filter((entry) => entry.distance <= Math.max(3, Math.floor(normalized.length / 2))).sort((left, right) => left.distance - right.distance).slice(0, 3).map((entry) => entry.id);
|
|
1062
|
+
return scored;
|
|
1063
|
+
}
|
|
1064
|
+
async function buildItemNotFoundError(pmRoot, badId, idPrefix, typeToFolder) {
|
|
1065
|
+
const suggestions = await buildDidYouMeanSuggestions(pmRoot, badId, idPrefix, typeToFolder);
|
|
1066
|
+
const nextSteps = ["Confirm the active --path/PM_PATH scope, then retry with a valid id."];
|
|
1067
|
+
if (suggestions.length > 0) {
|
|
1068
|
+
nextSteps.unshift(`Did you mean one of: ${suggestions.join(", ")}?`);
|
|
1069
|
+
}
|
|
1070
|
+
return new PmCliError(`Item ${badId} not found`, EXIT_CODE.NOT_FOUND, { nextSteps });
|
|
1071
|
+
}
|
|
1072
|
+
function bypassesAssigneeConflict(op, bypassAssigneeConflict) {
|
|
1073
|
+
return op === "claim" || bypassAssigneeConflict === true && (op === "comment_add" || op === "note_add" || op === "learning_add" || op === "release" || op === "update" || op === "update_audit");
|
|
1074
|
+
}
|
|
1075
|
+
async function prepareLockedItem(params) {
|
|
1076
|
+
const typeToFolder = params.typeToFolder ?? resolveItemTypeRegistry(params.settings, getActiveExtensionRegistrations()).type_to_folder;
|
|
1077
|
+
const located = await locateItem(params.pmRoot, params.id, params.settings.id_prefix, params.settings.item_format, typeToFolder);
|
|
1078
|
+
if (!located) {
|
|
1079
|
+
throw await buildItemNotFoundError(params.pmRoot, params.id, params.settings.id_prefix, typeToFolder);
|
|
1080
|
+
}
|
|
1081
|
+
const releaseLock = await acquireLock(params.pmRoot, located.id, params.settings.locks.ttl_seconds, params.author, Boolean(params.force), params.settings.governance.force_required_for_stale_lock);
|
|
1082
|
+
try {
|
|
1083
|
+
const warnings = [];
|
|
1084
|
+
const { raw: originalRaw, document } = await readLocatedItem(located, {
|
|
1085
|
+
schema: params.settings.schema,
|
|
1086
|
+
extensionFieldNames: params.extensionFieldNames,
|
|
1087
|
+
warnings
|
|
1088
|
+
});
|
|
1089
|
+
const assigned = document.metadata.assignee?.trim();
|
|
1090
|
+
const governance = resolveGovernanceKnobs(params.settings);
|
|
1091
|
+
const hasOwnershipConflict = assigned && assigned !== params.author && !params.force && !bypassesAssigneeConflict(params.op, params.bypassAssigneeConflict);
|
|
1092
|
+
if (hasOwnershipConflict) {
|
|
1093
|
+
if (governance.ownership_enforcement === "strict") {
|
|
1094
|
+
throw new PmCliError(`Item ${located.id} is assigned to ${assigned}. Use --force to override.`, EXIT_CODE.CONFLICT);
|
|
1095
|
+
}
|
|
1096
|
+
if (governance.ownership_enforcement === "warn") {
|
|
1097
|
+
warnings.push(`ownership_warning:assignee_conflict:${located.id}:${assigned}`);
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
return {
|
|
1101
|
+
typeToFolder,
|
|
1102
|
+
located,
|
|
1103
|
+
originalRaw,
|
|
1104
|
+
document,
|
|
1105
|
+
warnings,
|
|
1106
|
+
releaseLock
|
|
1107
|
+
};
|
|
1108
|
+
} catch (error) {
|
|
1109
|
+
await releaseLock();
|
|
1110
|
+
throw error;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
async function mutateItem(params) {
|
|
1114
|
+
const prepared = await prepareLockedItem({
|
|
1115
|
+
pmRoot: params.pmRoot,
|
|
1116
|
+
settings: params.settings,
|
|
1117
|
+
id: params.id,
|
|
1118
|
+
op: params.op,
|
|
1119
|
+
author: params.author,
|
|
1120
|
+
force: params.force,
|
|
1121
|
+
bypassAssigneeConflict: params.bypassAssigneeConflict,
|
|
1122
|
+
extensionFieldNames: params.extensionFieldNames,
|
|
1123
|
+
typeToFolder: params.typeToFolder
|
|
1124
|
+
});
|
|
1125
|
+
const { typeToFolder, located, originalRaw, document, warnings: parseWarnings, releaseLock } = prepared;
|
|
1126
|
+
try {
|
|
1127
|
+
const historyPolicy = await enforceHistoryStreamPolicyForItem({
|
|
1128
|
+
pmRoot: params.pmRoot,
|
|
1129
|
+
settings: params.settings,
|
|
1130
|
+
itemId: located.id,
|
|
1131
|
+
commandLabel: params.op
|
|
1132
|
+
});
|
|
1133
|
+
const beforeDocument = canonicalDocument(document, {
|
|
1134
|
+
schema: params.settings.schema,
|
|
1135
|
+
extensionFieldNames: params.extensionFieldNames
|
|
1136
|
+
});
|
|
1137
|
+
const mutableDocument = canonicalDocument(structuredClone(document), {
|
|
1138
|
+
schema: params.settings.schema,
|
|
1139
|
+
extensionFieldNames: params.extensionFieldNames
|
|
1140
|
+
});
|
|
1141
|
+
const mutation = params.mutate(mutableDocument);
|
|
1142
|
+
mutableDocument.metadata.updated_at = nowIso();
|
|
1143
|
+
const afterDocument = canonicalDocument(mutableDocument, {
|
|
1144
|
+
schema: params.settings.schema,
|
|
1145
|
+
extensionFieldNames: params.extensionFieldNames
|
|
1146
|
+
});
|
|
1147
|
+
const targetItemFormat = "toon";
|
|
1148
|
+
const serializedAfter = serializeItemDocument(afterDocument, {
|
|
1149
|
+
format: targetItemFormat,
|
|
1150
|
+
schema: params.settings.schema,
|
|
1151
|
+
extensionFieldNames: params.extensionFieldNames
|
|
1152
|
+
});
|
|
1153
|
+
const targetItemPath = getItemPath(params.pmRoot, afterDocument.metadata.type, located.id, targetItemFormat, typeToFolder);
|
|
1154
|
+
const historyPath = getHistoryPath(params.pmRoot, located.id);
|
|
1155
|
+
const serviceWriteOverride = await runActiveServiceOverride("item_store_write", {
|
|
1156
|
+
op: params.op,
|
|
1157
|
+
pm_root: params.pmRoot,
|
|
1158
|
+
item_id: located.id,
|
|
1159
|
+
source_item_path: located.itemPath,
|
|
1160
|
+
target_item_path: targetItemPath,
|
|
1161
|
+
history_path: historyPath,
|
|
1162
|
+
item_format: targetItemFormat,
|
|
1163
|
+
before: beforeDocument,
|
|
1164
|
+
after: afterDocument,
|
|
1165
|
+
contents: serializedAfter
|
|
1166
|
+
});
|
|
1167
|
+
let effectiveTargetItemPath = targetItemPath;
|
|
1168
|
+
let effectiveSerializedAfter = serializedAfter;
|
|
1169
|
+
let skipItemWrite = false;
|
|
1170
|
+
if (serviceWriteOverride.handled && typeof serviceWriteOverride.result === "object" && serviceWriteOverride.result !== null) {
|
|
1171
|
+
const overrideRecord = serviceWriteOverride.result;
|
|
1172
|
+
if (typeof overrideRecord.target_item_path === "string" && overrideRecord.target_item_path.trim().length > 0) {
|
|
1173
|
+
effectiveTargetItemPath = overrideRecord.target_item_path;
|
|
1174
|
+
}
|
|
1175
|
+
if (typeof overrideRecord.contents === "string") {
|
|
1176
|
+
effectiveSerializedAfter = overrideRecord.contents;
|
|
1177
|
+
}
|
|
1178
|
+
if (overrideRecord.skip_write === true) {
|
|
1179
|
+
skipItemWrite = true;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
if (!skipItemWrite) {
|
|
1183
|
+
await writeFileAtomic(effectiveTargetItemPath, effectiveSerializedAfter);
|
|
1184
|
+
}
|
|
1185
|
+
if (!skipItemWrite && effectiveTargetItemPath !== located.itemPath) {
|
|
1186
|
+
await fs4.rm(located.itemPath);
|
|
1187
|
+
}
|
|
1188
|
+
const entry = createHistoryEntry({
|
|
1189
|
+
nowIso: afterDocument.metadata.updated_at,
|
|
1190
|
+
author: params.author,
|
|
1191
|
+
op: params.op,
|
|
1192
|
+
before: beforeDocument,
|
|
1193
|
+
after: afterDocument,
|
|
1194
|
+
message: params.message
|
|
1195
|
+
});
|
|
1196
|
+
try {
|
|
1197
|
+
await appendHistoryEntry(historyPath, entry);
|
|
1198
|
+
} catch (error) {
|
|
1199
|
+
if (!skipItemWrite && effectiveTargetItemPath !== located.itemPath) {
|
|
1200
|
+
await writeFileAtomic(located.itemPath, originalRaw);
|
|
1201
|
+
await fs4.rm(effectiveTargetItemPath, { force: true });
|
|
1202
|
+
} else if (!skipItemWrite) {
|
|
1203
|
+
await writeFileAtomic(located.itemPath, originalRaw);
|
|
1204
|
+
}
|
|
1205
|
+
throw error;
|
|
1206
|
+
}
|
|
1207
|
+
const hookWarnings = [
|
|
1208
|
+
...await runActiveOnWriteHooks({
|
|
1209
|
+
path: effectiveTargetItemPath,
|
|
1210
|
+
scope: "project",
|
|
1211
|
+
op: params.op,
|
|
1212
|
+
item_id: afterDocument.metadata.id,
|
|
1213
|
+
item_type: afterDocument.metadata.type,
|
|
1214
|
+
before: beforeDocument,
|
|
1215
|
+
after: afterDocument,
|
|
1216
|
+
changed_fields: mutation.changedFields
|
|
1217
|
+
}),
|
|
1218
|
+
...await runActiveOnWriteHooks({
|
|
1219
|
+
path: historyPath,
|
|
1220
|
+
scope: "project",
|
|
1221
|
+
op: `${params.op}:history`,
|
|
1222
|
+
item_id: afterDocument.metadata.id,
|
|
1223
|
+
item_type: afterDocument.metadata.type,
|
|
1224
|
+
before: beforeDocument,
|
|
1225
|
+
after: afterDocument,
|
|
1226
|
+
changed_fields: mutation.changedFields
|
|
1227
|
+
})
|
|
1228
|
+
];
|
|
1229
|
+
recordAfterCommandAffectedItem({
|
|
1230
|
+
id: afterDocument.metadata.id,
|
|
1231
|
+
op: params.op,
|
|
1232
|
+
item_type: afterDocument.metadata.type,
|
|
1233
|
+
previous_status: beforeDocument.metadata.status,
|
|
1234
|
+
status: afterDocument.metadata.status,
|
|
1235
|
+
previous: projectAfterCommandItemSnapshot(beforeDocument.metadata, mutation.changedFields),
|
|
1236
|
+
current: projectAfterCommandItemSnapshot(afterDocument.metadata, mutation.changedFields),
|
|
1237
|
+
changed_fields: mutation.changedFields
|
|
1238
|
+
});
|
|
1239
|
+
return {
|
|
1240
|
+
item: afterDocument.metadata,
|
|
1241
|
+
body: afterDocument.body,
|
|
1242
|
+
changedFields: mutation.changedFields,
|
|
1243
|
+
warnings: [
|
|
1244
|
+
...parseWarnings,
|
|
1245
|
+
...mutation.warnings ?? [],
|
|
1246
|
+
...historyPolicy.warnings,
|
|
1247
|
+
...serviceWriteOverride.warnings,
|
|
1248
|
+
...hookWarnings
|
|
1249
|
+
]
|
|
1250
|
+
};
|
|
1251
|
+
} finally {
|
|
1252
|
+
await releaseLock();
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
async function deleteItem(params) {
|
|
1256
|
+
const prepared = await prepareLockedItem({
|
|
1257
|
+
pmRoot: params.pmRoot,
|
|
1258
|
+
settings: params.settings,
|
|
1259
|
+
id: params.id,
|
|
1260
|
+
op: "delete",
|
|
1261
|
+
author: params.author,
|
|
1262
|
+
force: params.force
|
|
1263
|
+
});
|
|
1264
|
+
const { located, originalRaw, document, warnings: parseWarnings, releaseLock } = prepared;
|
|
1265
|
+
try {
|
|
1266
|
+
const historyPolicy = await enforceHistoryStreamPolicyForItem({
|
|
1267
|
+
pmRoot: params.pmRoot,
|
|
1268
|
+
settings: params.settings,
|
|
1269
|
+
itemId: located.id,
|
|
1270
|
+
commandLabel: "delete"
|
|
1271
|
+
});
|
|
1272
|
+
const beforeDocument = canonicalDocument(document, { schema: params.settings.schema });
|
|
1273
|
+
const deletionTimestamp = nowIso();
|
|
1274
|
+
const tombstoneDocument = EMPTY_CANONICAL_DOCUMENT;
|
|
1275
|
+
const historyEntry = createHistoryEntry({
|
|
1276
|
+
nowIso: deletionTimestamp,
|
|
1277
|
+
author: params.author,
|
|
1278
|
+
op: "delete",
|
|
1279
|
+
before: beforeDocument,
|
|
1280
|
+
after: tombstoneDocument,
|
|
1281
|
+
message: params.message
|
|
1282
|
+
});
|
|
1283
|
+
const historyPath = getHistoryPath(params.pmRoot, located.id);
|
|
1284
|
+
const serviceDeleteOverride = await runActiveServiceOverride("item_store_delete", {
|
|
1285
|
+
op: "delete",
|
|
1286
|
+
pm_root: params.pmRoot,
|
|
1287
|
+
item_id: located.id,
|
|
1288
|
+
item_path: located.itemPath,
|
|
1289
|
+
history_path: historyPath,
|
|
1290
|
+
before: beforeDocument
|
|
1291
|
+
});
|
|
1292
|
+
let effectiveItemPath = located.itemPath;
|
|
1293
|
+
let skipDelete = false;
|
|
1294
|
+
if (serviceDeleteOverride.handled && typeof serviceDeleteOverride.result === "object" && serviceDeleteOverride.result !== null) {
|
|
1295
|
+
const overrideRecord = serviceDeleteOverride.result;
|
|
1296
|
+
if (typeof overrideRecord.item_path === "string" && overrideRecord.item_path.trim().length > 0) {
|
|
1297
|
+
effectiveItemPath = overrideRecord.item_path;
|
|
1298
|
+
}
|
|
1299
|
+
if (overrideRecord.skip_delete === true) {
|
|
1300
|
+
skipDelete = true;
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
if (params.dryRun === true) {
|
|
1304
|
+
return {
|
|
1305
|
+
item: beforeDocument.metadata,
|
|
1306
|
+
changedFields: ["deleted"],
|
|
1307
|
+
targetPath: effectiveItemPath,
|
|
1308
|
+
warnings: [...parseWarnings, ...historyPolicy.warnings, ...serviceDeleteOverride.warnings]
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1311
|
+
if (!skipDelete) {
|
|
1312
|
+
await fs4.rm(effectiveItemPath);
|
|
1313
|
+
}
|
|
1314
|
+
try {
|
|
1315
|
+
await appendHistoryEntry(historyPath, historyEntry);
|
|
1316
|
+
} catch (error) {
|
|
1317
|
+
if (!skipDelete) {
|
|
1318
|
+
await writeFileAtomic(effectiveItemPath, originalRaw);
|
|
1319
|
+
}
|
|
1320
|
+
throw error;
|
|
1321
|
+
}
|
|
1322
|
+
const hookWarnings = [
|
|
1323
|
+
...await runActiveOnWriteHooks({
|
|
1324
|
+
path: effectiveItemPath,
|
|
1325
|
+
scope: "project",
|
|
1326
|
+
op: "delete",
|
|
1327
|
+
item_id: beforeDocument.metadata.id,
|
|
1328
|
+
item_type: beforeDocument.metadata.type,
|
|
1329
|
+
before: beforeDocument,
|
|
1330
|
+
after: tombstoneDocument,
|
|
1331
|
+
changed_fields: ["deleted"]
|
|
1332
|
+
}),
|
|
1333
|
+
...await runActiveOnWriteHooks({
|
|
1334
|
+
path: historyPath,
|
|
1335
|
+
scope: "project",
|
|
1336
|
+
op: "delete:history",
|
|
1337
|
+
item_id: beforeDocument.metadata.id,
|
|
1338
|
+
item_type: beforeDocument.metadata.type,
|
|
1339
|
+
before: beforeDocument,
|
|
1340
|
+
after: tombstoneDocument,
|
|
1341
|
+
changed_fields: ["deleted"]
|
|
1342
|
+
})
|
|
1343
|
+
];
|
|
1344
|
+
recordAfterCommandAffectedItem({
|
|
1345
|
+
id: beforeDocument.metadata.id,
|
|
1346
|
+
op: "delete",
|
|
1347
|
+
item_type: beforeDocument.metadata.type,
|
|
1348
|
+
previous_status: beforeDocument.metadata.status,
|
|
1349
|
+
previous: projectAfterCommandItemSnapshot(beforeDocument.metadata, Object.keys(beforeDocument.metadata)),
|
|
1350
|
+
changed_fields: ["deleted"]
|
|
1351
|
+
});
|
|
1352
|
+
return {
|
|
1353
|
+
item: beforeDocument.metadata,
|
|
1354
|
+
changedFields: ["deleted"],
|
|
1355
|
+
warnings: [...parseWarnings, ...historyPolicy.warnings, ...serviceDeleteOverride.warnings, ...hookWarnings]
|
|
1356
|
+
};
|
|
1357
|
+
} finally {
|
|
1358
|
+
await releaseLock();
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
export {
|
|
1363
|
+
collectRegisteredItemFieldNames,
|
|
1364
|
+
parseRegisteredItemFieldAssignments,
|
|
1365
|
+
applyRegisteredItemFieldDefaultsAndValidation,
|
|
1366
|
+
toItemRecord,
|
|
1367
|
+
hashDocument,
|
|
1368
|
+
hashEmptyDocument,
|
|
1369
|
+
createHistoryEntry,
|
|
1370
|
+
appendHistoryEntry,
|
|
1371
|
+
enforceHistoryStreamPolicyForItem,
|
|
1372
|
+
enforceHistoryStreamPolicyForItems,
|
|
1373
|
+
acquireLock,
|
|
1374
|
+
HEAVY_METADATA_KEYS,
|
|
1375
|
+
listAllDocumentCandidatesCached,
|
|
1376
|
+
locateItem,
|
|
1377
|
+
readLocatedItem,
|
|
1378
|
+
listAllFrontMatter,
|
|
1379
|
+
listAllFrontMatterLight,
|
|
1380
|
+
listAllFrontMatterWithBody,
|
|
1381
|
+
buildItemNotFoundError,
|
|
1382
|
+
mutateItem,
|
|
1383
|
+
deleteItem
|
|
1384
|
+
};
|
|
1385
|
+
//# sourceMappingURL=chunk-XG7RJYHV.js.map
|