@unbrained/pm-cli 2026.7.4 → 2026.7.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 +26 -0
- package/README.md +1 -5
- package/dist/cli/commands/calendar.d.ts +3 -2
- package/dist/cli/commands/calendar.js +4 -4
- package/dist/cli/commands/calendar.js.map +1 -1
- package/dist/cli/commands/claim.js +17 -3
- package/dist/cli/commands/claim.js.map +1 -1
- package/dist/cli/commands/close.js +34 -16
- package/dist/cli/commands/close.js.map +1 -1
- package/dist/cli/commands/copy.js +3 -3
- package/dist/cli/commands/copy.js.map +1 -1
- package/dist/cli/commands/create.d.ts +7 -0
- package/dist/cli/commands/create.js +156 -110
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/commands/extension/bundled-catalog.d.ts +6 -0
- package/dist/cli/commands/extension/bundled-catalog.js +15 -2
- package/dist/cli/commands/extension/bundled-catalog.js.map +1 -1
- package/dist/cli/commands/extension/describe.d.ts +6 -3
- package/dist/cli/commands/extension/describe.js +21 -9
- package/dist/cli/commands/extension/describe.js.map +1 -1
- package/dist/cli/commands/extension/doctor.d.ts +0 -4
- package/dist/cli/commands/extension/doctor.js +3 -3
- package/dist/cli/commands/extension/doctor.js.map +1 -1
- package/dist/cli/commands/extension/scaffold.js +7 -2
- package/dist/cli/commands/extension/scaffold.js.map +1 -1
- package/dist/cli/commands/extension/shared.d.ts +2 -7
- package/dist/cli/commands/extension/shared.js +4 -10
- package/dist/cli/commands/extension/shared.js.map +1 -1
- package/dist/cli/commands/extension.js +33 -8
- package/dist/cli/commands/extension.js.map +1 -1
- package/dist/cli/commands/profile.js +3 -3
- package/dist/cli/commands/profile.js.map +1 -1
- package/dist/cli/commands/reindex.js +3 -3
- package/dist/cli/commands/reindex.js.map +1 -1
- package/dist/cli/commands/restore.js +3 -3
- package/dist/cli/commands/restore.js.map +1 -1
- package/dist/cli/commands/schema.js +10 -10
- package/dist/cli/commands/schema.js.map +1 -1
- package/dist/cli/commands/update.js +5 -3
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/error-guidance.js +107 -7
- package/dist/cli/error-guidance.js.map +1 -1
- package/dist/cli/main.d.ts +6 -2
- package/dist/cli/main.js +33 -12
- package/dist/cli/main.js.map +1 -1
- package/dist/cli-bundle/chunks/activity-4XQIDNM5.js +18 -0
- package/dist/cli-bundle/chunks/{activity-OENQCYZD.js → activity-YKAKZTZ4.js} +11 -9
- package/dist/cli-bundle/chunks/{aggregate-EC4LWS3U.js → aggregate-EQX2RGB7.js} +16 -13
- package/dist/cli-bundle/chunks/{aggregate-EC4LWS3U.js.map → aggregate-EQX2RGB7.js.map} +1 -1
- package/dist/cli-bundle/chunks/{aggregate-RCB3QJJE.js → aggregate-PEGZGJXD.js} +18 -15
- package/dist/cli-bundle/chunks/{aggregate-RCB3QJJE.js.map → aggregate-PEGZGJXD.js.map} +1 -1
- package/dist/cli-bundle/chunks/{append-XLEKVVWB.js → append-CZGUZ45Q.js} +11 -8
- package/dist/cli-bundle/chunks/{append-XLEKVVWB.js.map → append-CZGUZ45Q.js.map} +1 -1
- package/dist/cli-bundle/chunks/{append-ADBOI3A6.js → append-NSQBCXZJ.js} +13 -10
- package/dist/cli-bundle/chunks/{append-ADBOI3A6.js.map → append-NSQBCXZJ.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-3JZNEQBA.js +1413 -0
- package/dist/cli-bundle/chunks/chunk-3JZNEQBA.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-2LRMWMZ6.js → chunk-3PL6LEKP.js} +16 -14
- package/dist/cli-bundle/chunks/{chunk-2LRMWMZ6.js.map → chunk-3PL6LEKP.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-CN4OAA2G.js → chunk-3U3VEWK6.js} +277 -119
- package/dist/cli-bundle/chunks/chunk-3U3VEWK6.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-EB4BBEZD.js → chunk-3Y4OESPP.js} +14 -12
- package/dist/cli-bundle/chunks/{chunk-EB4BBEZD.js.map → chunk-3Y4OESPP.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-NHDR3UCW.js → chunk-4LRVSBO6.js} +14 -12
- package/dist/cli-bundle/chunks/{chunk-NHDR3UCW.js.map → chunk-4LRVSBO6.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-6YB7HG2J.js → chunk-4OFLJHX6.js} +7 -5
- package/dist/cli-bundle/chunks/{chunk-6YB7HG2J.js.map → chunk-4OFLJHX6.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-SBNT6SLO.js → chunk-4QQ6PM7M.js} +45 -557
- package/dist/cli-bundle/chunks/chunk-4QQ6PM7M.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-M34MVAOP.js → chunk-53BTLLAF.js} +16 -200
- package/dist/cli-bundle/chunks/chunk-53BTLLAF.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-UYLA5ROU.js → chunk-57C2RLW5.js} +277 -112
- package/dist/cli-bundle/chunks/chunk-57C2RLW5.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-R7EMP4JG.js → chunk-5B3X4Y22.js} +52 -63
- package/dist/cli-bundle/chunks/{chunk-R7EMP4JG.js.map → chunk-5B3X4Y22.js.map} +3 -3
- package/dist/cli-bundle/chunks/{chunk-XBIYI23P.js → chunk-5J2XPTAD.js} +10 -8
- package/dist/cli-bundle/chunks/{chunk-XBIYI23P.js.map → chunk-5J2XPTAD.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-4SHME4VR.js → chunk-5JE6SMYS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4KPQQ42D.js → chunk-5JZ7APJU.js} +18 -16
- package/dist/cli-bundle/chunks/{chunk-4KPQQ42D.js.map → chunk-5JZ7APJU.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-BDDYM4LH.js → chunk-5VVUKE3U.js} +424 -2228
- package/dist/cli-bundle/chunks/chunk-5VVUKE3U.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-QFXFKYNQ.js → chunk-75U6M5ZD.js} +16 -14
- package/dist/cli-bundle/chunks/{chunk-QFXFKYNQ.js.map → chunk-75U6M5ZD.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-7C2O74AE.js +23 -0
- package/dist/cli-bundle/chunks/chunk-7C2O74AE.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-A222YWOQ.js → chunk-7EQNAZX2.js} +14 -12
- package/dist/cli-bundle/chunks/{chunk-A222YWOQ.js.map → chunk-7EQNAZX2.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-Z4DGFQDH.js → chunk-7LQKVMPA.js} +14 -4
- package/dist/cli-bundle/chunks/chunk-7LQKVMPA.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-EH23N5FX.js → chunk-7MDXZAZS.js} +29 -7
- package/dist/cli-bundle/chunks/chunk-7MDXZAZS.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-XQCWTSLO.js → chunk-7QH7DHUB.js} +74 -8
- package/dist/cli-bundle/chunks/chunk-7QH7DHUB.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-3C5T3ZEO.js → chunk-7WYXBPYQ.js} +7 -5
- package/dist/cli-bundle/chunks/{chunk-3C5T3ZEO.js.map → chunk-7WYXBPYQ.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-AAEQMOC6.js +150 -0
- package/dist/cli-bundle/chunks/chunk-AAEQMOC6.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-CQISNF3Z.js → chunk-ABRA3BHY.js} +18 -16
- package/dist/cli-bundle/chunks/{chunk-CQISNF3Z.js.map → chunk-ABRA3BHY.js.map} +2 -2
- package/dist/cli-bundle/chunks/chunk-B5KXLBSJ.js +47 -0
- package/dist/cli-bundle/chunks/chunk-B5KXLBSJ.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-Y2VSCQ77.js → chunk-BFVHCAOO.js} +9 -7
- package/dist/cli-bundle/chunks/{chunk-Y2VSCQ77.js.map → chunk-BFVHCAOO.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-7ITQSEBL.js → chunk-BVEUCSH2.js} +6 -4
- package/dist/cli-bundle/chunks/{chunk-7ITQSEBL.js.map → chunk-BVEUCSH2.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-C3PMDWGX.js +160 -0
- package/dist/cli-bundle/chunks/chunk-C3PMDWGX.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-HL742IBM.js → chunk-D3UCE7RW.js} +7 -5
- package/dist/cli-bundle/chunks/{chunk-HL742IBM.js.map → chunk-D3UCE7RW.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-DC3QJQWI.js +275 -0
- package/dist/cli-bundle/chunks/chunk-DC3QJQWI.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-DLQ4ZTCU.js +634 -0
- package/dist/cli-bundle/chunks/chunk-DLQ4ZTCU.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-MZG6I2Q2.js → chunk-DRBV5UC2.js} +8 -23
- package/dist/cli-bundle/chunks/chunk-DRBV5UC2.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-DEIDJQZK.js → chunk-E2FUG6GD.js} +15 -220
- package/dist/cli-bundle/chunks/{chunk-DEIDJQZK.js.map → chunk-E2FUG6GD.js.map} +3 -3
- package/dist/cli-bundle/chunks/{chunk-3MLQZI3H.js → chunk-EEY54JMF.js} +5 -3
- package/dist/cli-bundle/chunks/{chunk-3MLQZI3H.js.map → chunk-EEY54JMF.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-CQFZRLXQ.js → chunk-EZFKWSC7.js} +94 -16
- package/dist/cli-bundle/chunks/{chunk-CQFZRLXQ.js.map → chunk-EZFKWSC7.js.map} +4 -4
- package/dist/cli-bundle/chunks/{chunk-4PJYRA3V.js → chunk-FDBARR33.js} +17 -15
- package/dist/cli-bundle/chunks/{chunk-4PJYRA3V.js.map → chunk-FDBARR33.js.map} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NGDK3KEZ.js → chunk-FGQKEDE4.js} +36 -12
- package/dist/cli-bundle/chunks/chunk-FGQKEDE4.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-FMWQRMHS.js → chunk-FJRKQREY.js} +10 -18
- package/dist/cli-bundle/chunks/chunk-FJRKQREY.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-6QY2NA2M.js → chunk-FUM6UMY4.js} +10 -11
- package/dist/cli-bundle/chunks/{chunk-6QY2NA2M.js.map → chunk-FUM6UMY4.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-UGDONITK.js → chunk-GIWXVMZ3.js} +140 -334
- package/dist/cli-bundle/chunks/chunk-GIWXVMZ3.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-OTSP6UEX.js → chunk-HBYZDSK5.js} +19 -17
- package/dist/cli-bundle/chunks/{chunk-OTSP6UEX.js.map → chunk-HBYZDSK5.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-D2LDM35X.js → chunk-HJE4JTKQ.js} +6 -4
- package/dist/cli-bundle/chunks/{chunk-D2LDM35X.js.map → chunk-HJE4JTKQ.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-AOP2EMK3.js → chunk-HK72NWAD.js} +89 -18
- package/dist/cli-bundle/chunks/chunk-HK72NWAD.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-2ONH3WG6.js → chunk-IJ6CO3JV.js} +18 -16
- package/dist/cli-bundle/chunks/{chunk-2ONH3WG6.js.map → chunk-IJ6CO3JV.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-J4KNRDI3.js → chunk-JFCVQXZX.js} +139 -326
- package/dist/cli-bundle/chunks/chunk-JFCVQXZX.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-V655JQ5J.js → chunk-JLA7EVYV.js} +12 -10
- package/dist/cli-bundle/chunks/{chunk-V655JQ5J.js.map → chunk-JLA7EVYV.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-K32L7HZO.js +76 -0
- package/dist/cli-bundle/chunks/chunk-K32L7HZO.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-WBWRQS32.js → chunk-K3AGVXSF.js} +37 -13
- package/dist/cli-bundle/chunks/chunk-K3AGVXSF.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-KDZ6K25I.js +79 -0
- package/dist/cli-bundle/chunks/chunk-KDZ6K25I.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-KGHH652T.js +44 -0
- package/dist/cli-bundle/chunks/chunk-KGHH652T.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-KL22PY6L.js +915 -0
- package/dist/cli-bundle/chunks/chunk-KL22PY6L.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-JZJJEJBR.js → chunk-KLG4ZULO.js} +12 -10
- package/dist/cli-bundle/chunks/{chunk-JZJJEJBR.js.map → chunk-KLG4ZULO.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-KKHIQOTN.js → chunk-LEKT4K7I.js} +74 -8
- package/dist/cli-bundle/chunks/chunk-LEKT4K7I.js.map +7 -0
- package/dist/cli-bundle/chunks/{contracts-CVBINC7C.js → chunk-MNZ7DRNC.js} +13 -10
- package/dist/cli-bundle/chunks/{contracts-CVBINC7C.js.map → chunk-MNZ7DRNC.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-2VK677OA.js → chunk-MTTXDAK4.js} +176 -125
- package/dist/cli-bundle/chunks/chunk-MTTXDAK4.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-Q2266G4S.js → chunk-MZ7VNEVY.js} +8 -6
- package/dist/cli-bundle/chunks/{chunk-Q2266G4S.js.map → chunk-MZ7VNEVY.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-4EVY7CQN.js → chunk-N6DNM2FA.js} +2 -2
- package/dist/cli-bundle/chunks/{test-runs-5SLLV3XU.js → chunk-N7X4WP6L.js} +11 -8
- package/dist/cli-bundle/chunks/{test-runs-5SLLV3XU.js.map → chunk-N7X4WP6L.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-AZMPKLIA.js → chunk-NBFCNJ7Q.js} +177 -126
- package/dist/cli-bundle/chunks/chunk-NBFCNJ7Q.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-YZR7UMZ6.js → chunk-NER3KUUS.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js +20 -0
- package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-OBA2WH65.js +918 -0
- package/dist/cli-bundle/chunks/chunk-OBA2WH65.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-DJ5S2LDY.js → chunk-OESSOFJ4.js} +14 -12
- package/dist/cli-bundle/chunks/{chunk-DJ5S2LDY.js.map → chunk-OESSOFJ4.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-OK5NXCZB.js +238 -0
- package/dist/cli-bundle/chunks/chunk-OK5NXCZB.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-TUV7SIWZ.js → chunk-OWTIRHX4.js} +28 -6
- package/dist/cli-bundle/chunks/chunk-OWTIRHX4.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-PV5JS7MP.js → chunk-P3VRG72Q.js} +10 -8
- package/dist/cli-bundle/chunks/{chunk-PV5JS7MP.js.map → chunk-P3VRG72Q.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-P5TFTLWW.js +1423 -0
- package/dist/cli-bundle/chunks/chunk-P5TFTLWW.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-P5YORJRH.js +1977 -0
- package/dist/cli-bundle/chunks/chunk-P5YORJRH.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-WTXDLBSZ.js → chunk-PDXT6Q55.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YZWXMDNH.js → chunk-PJ3A56YF.js} +46 -537
- package/dist/cli-bundle/chunks/chunk-PJ3A56YF.js.map +1 -0
- package/dist/cli-bundle/chunks/{test-runs-L3WKLO67.js → chunk-PPAJG4GB.js} +13 -10
- package/dist/cli-bundle/chunks/{test-runs-L3WKLO67.js.map → chunk-PPAJG4GB.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-LLQLLAKU.js → chunk-PPE4YUQM.js} +1670 -1573
- package/dist/cli-bundle/chunks/chunk-PPE4YUQM.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-TO4KCIOT.js → chunk-QHZO65XW.js} +8 -6
- package/dist/cli-bundle/chunks/{chunk-TO4KCIOT.js.map → chunk-QHZO65XW.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-4OXNQHKQ.js → chunk-R3ZBLGTC.js} +9 -10
- package/dist/cli-bundle/chunks/{chunk-4OXNQHKQ.js.map → chunk-R3ZBLGTC.js.map} +2 -2
- package/dist/cli-bundle/chunks/chunk-RCT3YJOK.js +624 -0
- package/dist/cli-bundle/chunks/chunk-RCT3YJOK.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-724VLYDJ.js → chunk-RX3HQSYG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PUVPC5DL.js → chunk-S4APD35C.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-T5RTYLZJ.js → chunk-S5AYOUT5.js} +8 -6
- package/dist/cli-bundle/chunks/{chunk-T5RTYLZJ.js.map → chunk-S5AYOUT5.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-75VMARGO.js → chunk-STPSZ2XY.js} +19 -744
- package/dist/cli-bundle/chunks/chunk-STPSZ2XY.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-A2W3XKAD.js → chunk-T35XLYZF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-N2LOJUBB.js → chunk-T3ABIMGW.js} +5 -3
- package/dist/cli-bundle/chunks/{chunk-N2LOJUBB.js.map → chunk-T3ABIMGW.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-FDNJMYZB.js → chunk-T3F4DF23.js} +16 -14
- package/dist/cli-bundle/chunks/{chunk-FDNJMYZB.js.map → chunk-T3F4DF23.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-T4MX77AK.js +272 -0
- package/dist/cli-bundle/chunks/chunk-T4MX77AK.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-T5Y3QSNF.js +5354 -0
- package/dist/cli-bundle/chunks/chunk-T5Y3QSNF.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-XFO2NJY6.js → chunk-TSPKZRRW.js} +33 -28
- package/dist/cli-bundle/chunks/chunk-TSPKZRRW.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-ZZWMJVW2.js → chunk-TT42JUMF.js} +4 -4
- package/dist/cli-bundle/chunks/chunk-UHKX7I75.js +165 -0
- package/dist/cli-bundle/chunks/chunk-UHKX7I75.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-7745CXNI.js → chunk-UI5BJ6DO.js} +1231 -1134
- package/dist/cli-bundle/chunks/chunk-UI5BJ6DO.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-US3T3W5J.js +1932 -0
- package/dist/cli-bundle/chunks/chunk-US3T3W5J.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-UZRDBL6W.js +175 -0
- package/dist/cli-bundle/chunks/chunk-UZRDBL6W.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-B4O5S7I3.js → chunk-VUHVWI4C.js} +13 -3
- package/dist/cli-bundle/chunks/chunk-VUHVWI4C.js.map +7 -0
- package/dist/cli-bundle/chunks/{contracts-NLCDIZAT.js → chunk-VZIYHZDX.js} +11 -8
- package/dist/cli-bundle/chunks/{contracts-NLCDIZAT.js.map → chunk-VZIYHZDX.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-TGYDJEJH.js → chunk-WISPVC2E.js} +9 -7
- package/dist/cli-bundle/chunks/{chunk-TGYDJEJH.js.map → chunk-WISPVC2E.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-WVSGSZ6J.js +5434 -0
- package/dist/cli-bundle/chunks/chunk-WVSGSZ6J.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-MTB4PRA3.js → chunk-XQCG2JGW.js} +17 -749
- package/dist/cli-bundle/chunks/chunk-XQCG2JGW.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-Y76TWC45.js +550 -0
- package/dist/cli-bundle/chunks/chunk-Y76TWC45.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-SL2ANJSV.js → chunk-YD5FML7K.js} +418 -2173
- package/dist/cli-bundle/chunks/chunk-YD5FML7K.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-NHKXOMZ5.js → chunk-YFIE7YK6.js} +7 -5
- package/dist/cli-bundle/chunks/{chunk-NHKXOMZ5.js.map → chunk-YFIE7YK6.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-5FYY76HR.js → chunk-YMABYTNG.js} +32 -27
- package/dist/cli-bundle/chunks/chunk-YMABYTNG.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-W5X3AHJN.js → chunk-YOF5VPKM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-M6PR5BC6.js → chunk-YPPVU5GX.js} +11 -9
- package/dist/cli-bundle/chunks/{chunk-M6PR5BC6.js.map → chunk-YPPVU5GX.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-ZIEGTQCY.js → chunk-YQMMMONE.js} +6 -4
- package/dist/cli-bundle/chunks/{chunk-ZIEGTQCY.js.map → chunk-YQMMMONE.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-4IW7STMB.js → chunk-YSAH5FY5.js} +16 -14
- package/dist/cli-bundle/chunks/{chunk-4IW7STMB.js.map → chunk-YSAH5FY5.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-JYLFF7GJ.js → chunk-YZIR4R3U.js} +16 -14
- package/dist/cli-bundle/chunks/{chunk-JYLFF7GJ.js.map → chunk-YZIR4R3U.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-7G5SUU6F.js → chunk-Z2CRRZYF.js} +14 -12
- package/dist/cli-bundle/chunks/{chunk-7G5SUU6F.js.map → chunk-Z2CRRZYF.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-ZAHXPXVY.js +533 -0
- package/dist/cli-bundle/chunks/chunk-ZAHXPXVY.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-WOOB7PV7.js → chunk-ZCJAA3JK.js} +8 -6
- package/dist/cli-bundle/chunks/{chunk-WOOB7PV7.js.map → chunk-ZCJAA3JK.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-WSDIALO4.js → chunk-ZD34OFFQ.js} +5 -3
- package/dist/cli-bundle/chunks/{chunk-WSDIALO4.js.map → chunk-ZD34OFFQ.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-Q3XVLRCJ.js → chunk-ZJB3UV5U.js} +54 -58
- package/dist/cli-bundle/chunks/chunk-ZJB3UV5U.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-MZ4NH46V.js → chunk-ZMD35NYG.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-ZVDL32GJ.js +241 -0
- package/dist/cli-bundle/chunks/chunk-ZVDL32GJ.js.map +7 -0
- package/dist/cli-bundle/chunks/{claim-D6L33A5Y.js → claim-4DROPSIS.js} +30 -13
- package/dist/cli-bundle/chunks/claim-4DROPSIS.js.map +1 -0
- package/dist/cli-bundle/chunks/{claim-YAFUTPVK.js → claim-VX54TV5U.js} +29 -12
- package/dist/cli-bundle/chunks/claim-VX54TV5U.js.map +7 -0
- package/dist/cli-bundle/chunks/{close-TGYXG7TV.js → close-3YRR3XY6.js} +9 -7
- package/dist/cli-bundle/chunks/close-OB2Y4QP5.js +16 -0
- package/dist/cli-bundle/chunks/{close-many-SNA6LNZH.js → close-many-AP4MWU36.js} +21 -18
- package/dist/cli-bundle/chunks/{close-many-SNA6LNZH.js.map → close-many-AP4MWU36.js.map} +1 -1
- package/dist/cli-bundle/chunks/{close-many-4QSWKCRU.js → close-many-OMZIGZB4.js} +19 -16
- package/dist/cli-bundle/chunks/{close-many-4QSWKCRU.js.map → close-many-OMZIGZB4.js.map} +1 -1
- package/dist/cli-bundle/chunks/{comments-QC6ARR5X.js → comments-MIW5MZOX.js} +12 -9
- package/dist/cli-bundle/chunks/{comments-QC6ARR5X.js.map → comments-MIW5MZOX.js.map} +1 -1
- package/dist/cli-bundle/chunks/{comments-ZHVYGUVC.js → comments-SAG5LSKL.js} +14 -11
- package/dist/cli-bundle/chunks/{comments-ZHVYGUVC.js.map → comments-SAG5LSKL.js.map} +1 -1
- package/dist/cli-bundle/chunks/{config-O6W2EU2G.js → config-DJJKZB5R.js} +20 -17
- package/dist/cli-bundle/chunks/{config-O6W2EU2G.js.map → config-DJJKZB5R.js.map} +1 -1
- package/dist/cli-bundle/chunks/{config-XQRFJXJP.js → config-V57QD47V.js} +22 -19
- package/dist/cli-bundle/chunks/{config-XQRFJXJP.js.map → config-V57QD47V.js.map} +1 -1
- package/dist/cli-bundle/chunks/{context-IHE3IXN5.js → context-4OQGIPSO.js} +15 -12
- package/dist/cli-bundle/chunks/{context-WSYWBEUL.js → context-WLA6IAWE.js} +15 -12
- package/dist/cli-bundle/chunks/contracts-HXJLKCRI.js +12 -0
- package/dist/cli-bundle/chunks/contracts-OJEXMKVW.js +16 -0
- package/dist/cli-bundle/chunks/{copy-7MUQC44A.js → copy-LEE6P6EM.js} +17 -14
- package/dist/cli-bundle/chunks/{copy-7MUQC44A.js.map → copy-LEE6P6EM.js.map} +2 -2
- package/dist/cli-bundle/chunks/{copy-ANWXDJVC.js → copy-OTJOWFL6.js} +18 -15
- package/dist/cli-bundle/chunks/{copy-ANWXDJVC.js.map → copy-OTJOWFL6.js.map} +1 -1
- package/dist/cli-bundle/chunks/create-WKOZKPQR.js +30 -0
- package/dist/cli-bundle/chunks/{create-JIA2IFCO.js → create-XWWQFQ6S.js} +14 -12
- package/dist/cli-bundle/chunks/{delete-5OLYWQIC.js → delete-62JQTYT4.js} +10 -7
- package/dist/cli-bundle/chunks/{delete-5OLYWQIC.js.map → delete-62JQTYT4.js.map} +1 -1
- package/dist/cli-bundle/chunks/{delete-INHKCIRN.js → delete-HQKGRNRZ.js} +12 -9
- package/dist/cli-bundle/chunks/{delete-INHKCIRN.js.map → delete-HQKGRNRZ.js.map} +1 -1
- package/dist/cli-bundle/chunks/{deps-IYEID3QX.js → deps-55FTG6Z5.js} +12 -9
- package/dist/cli-bundle/chunks/{deps-IYEID3QX.js.map → deps-55FTG6Z5.js.map} +1 -1
- package/dist/cli-bundle/chunks/{deps-CCSWGZW7.js → deps-L2FPIAD3.js} +10 -7
- package/dist/cli-bundle/chunks/{deps-CCSWGZW7.js.map → deps-L2FPIAD3.js.map} +1 -1
- package/dist/cli-bundle/chunks/{docs-PKO7OEIM.js → docs-6CRCSVKK.js} +11 -9
- package/dist/cli-bundle/chunks/{docs-PKO7OEIM.js.map → docs-6CRCSVKK.js.map} +1 -1
- package/dist/cli-bundle/chunks/{docs-3XZK22WF.js → docs-S6UTOTO5.js} +9 -7
- package/dist/cli-bundle/chunks/{docs-3XZK22WF.js.map → docs-S6UTOTO5.js.map} +1 -1
- package/dist/cli-bundle/chunks/{eval-5XYP6NMY.js → eval-N6UHFWVO.js} +15 -11
- package/dist/cli-bundle/chunks/{eval-5XYP6NMY.js.map → eval-N6UHFWVO.js.map} +1 -1
- package/dist/cli-bundle/chunks/{eval-O4WGQYDI.js → eval-PHOTWYHI.js} +17 -13
- package/dist/cli-bundle/chunks/{eval-O4WGQYDI.js.map → eval-PHOTWYHI.js.map} +1 -1
- package/dist/cli-bundle/chunks/{extension-T7JNTAAA.js → extension-NBAH62ML.js} +17 -11
- package/dist/cli-bundle/chunks/{extension-PVGRRZZG.js → extension-ZF6ZZPOU.js} +17 -11
- package/dist/cli-bundle/chunks/{files-W7HH5EOD.js → files-6P57MRKL.js} +12 -9
- package/dist/cli-bundle/chunks/{files-W7HH5EOD.js.map → files-6P57MRKL.js.map} +1 -1
- package/dist/cli-bundle/chunks/{files-7IU56S6R.js → files-JPU3FNJ7.js} +14 -11
- package/dist/cli-bundle/chunks/{files-7IU56S6R.js.map → files-JPU3FNJ7.js.map} +1 -1
- package/dist/cli-bundle/chunks/{focus-6FA5KYRY.js → focus-LFZ6IDBR.js} +15 -11
- package/dist/cli-bundle/chunks/{focus-6FA5KYRY.js.map → focus-LFZ6IDBR.js.map} +1 -1
- package/dist/cli-bundle/chunks/{focus-CQ63JFDG.js → focus-WNMYCVYA.js} +13 -9
- package/dist/cli-bundle/chunks/{focus-CQ63JFDG.js.map → focus-WNMYCVYA.js.map} +1 -1
- package/dist/cli-bundle/chunks/{gc-3BG67KTO.js → gc-AETFKZ44.js} +10 -7
- package/dist/cli-bundle/chunks/{gc-3BG67KTO.js.map → gc-AETFKZ44.js.map} +1 -1
- package/dist/cli-bundle/chunks/{gc-PEZYGNVB.js → gc-RLBP4QVN.js} +12 -9
- package/dist/cli-bundle/chunks/{gc-PEZYGNVB.js.map → gc-RLBP4QVN.js.map} +1 -1
- package/dist/cli-bundle/chunks/{get-J6CSJ4SX.js → get-NH2MPBCI.js} +18 -15
- package/dist/cli-bundle/chunks/{get-J6CSJ4SX.js.map → get-NH2MPBCI.js.map} +1 -1
- package/dist/cli-bundle/chunks/{get-KJTKGNEQ.js → get-P4ZQXCPZ.js} +16 -13
- package/dist/cli-bundle/chunks/{get-KJTKGNEQ.js.map → get-P4ZQXCPZ.js.map} +1 -1
- package/dist/cli-bundle/chunks/{health-32UQICEL.js → health-3GVPMQBL.js} +36 -29
- package/dist/cli-bundle/chunks/{health-32UQICEL.js.map → health-3GVPMQBL.js.map} +1 -1
- package/dist/cli-bundle/chunks/{health-ZUZG5ULV.js → health-DNTM72GJ.js} +34 -27
- package/dist/cli-bundle/chunks/{health-ZUZG5ULV.js.map → health-DNTM72GJ.js.map} +1 -1
- package/dist/cli-bundle/chunks/history-RYKLC72X.js +20 -0
- package/dist/cli-bundle/chunks/{history-W6QVR6FA.js → history-SGPYRAFT.js} +10 -8
- package/dist/cli-bundle/chunks/{history-compact-JQ6ZGYSJ.js → history-compact-3F6VELO7.js} +18 -15
- package/dist/cli-bundle/chunks/{history-compact-JQ6ZGYSJ.js.map → history-compact-3F6VELO7.js.map} +1 -1
- package/dist/cli-bundle/chunks/{history-compact-F355EGL4.js → history-compact-656Y2TN4.js} +20 -17
- package/dist/cli-bundle/chunks/{history-compact-F355EGL4.js.map → history-compact-656Y2TN4.js.map} +1 -1
- package/dist/cli-bundle/chunks/history-redact-4H3FCKF3.js +21 -0
- package/dist/cli-bundle/chunks/{history-redact-TUWOUYX5.js → history-redact-54ICFKXM.js} +11 -9
- package/dist/cli-bundle/chunks/{history-repair-ZKS3LKPV.js → history-repair-4N6SDVHK.js} +17 -14
- package/dist/cli-bundle/chunks/{history-repair-ZKS3LKPV.js.map → history-repair-4N6SDVHK.js.map} +1 -1
- package/dist/cli-bundle/chunks/{history-repair-MPCAIKYE.js → history-repair-EVTO6LIH.js} +19 -16
- package/dist/cli-bundle/chunks/{history-repair-MPCAIKYE.js.map → history-repair-EVTO6LIH.js.map} +1 -1
- package/dist/cli-bundle/chunks/init-RPIPQUNV.js +32 -0
- package/dist/cli-bundle/chunks/init-SKQAESQS.js +28 -0
- package/dist/cli-bundle/chunks/{learnings-EYC3OKS2.js → learnings-2HTPZNGZ.js} +10 -8
- package/dist/cli-bundle/chunks/{learnings-EYC3OKS2.js.map → learnings-2HTPZNGZ.js.map} +1 -1
- package/dist/cli-bundle/chunks/{learnings-HKJJUVTA.js → learnings-YBIHY3D6.js} +12 -10
- package/dist/cli-bundle/chunks/{learnings-HKJJUVTA.js.map → learnings-YBIHY3D6.js.map} +1 -1
- package/dist/cli-bundle/chunks/{list-KN3TL5Y5.js → list-64LHZ3HM.js} +10 -8
- package/dist/cli-bundle/chunks/{list-HFD5737R.js → list-7LXBTEKI.js} +10 -8
- package/dist/cli-bundle/chunks/{next-DQUMFAHG.js → next-7ODPAQ4U.js} +22 -18
- package/dist/cli-bundle/chunks/{next-DQUMFAHG.js.map → next-7ODPAQ4U.js.map} +1 -1
- package/dist/cli-bundle/chunks/{next-JUEYC5HE.js → next-ODJUM4ZM.js} +24 -20
- package/dist/cli-bundle/chunks/{next-JUEYC5HE.js.map → next-ODJUM4ZM.js.map} +1 -1
- package/dist/cli-bundle/chunks/{notes-ZG6RLZXB.js → notes-72YXN5JX.js} +10 -8
- package/dist/cli-bundle/chunks/{notes-ZG6RLZXB.js.map → notes-72YXN5JX.js.map} +1 -1
- package/dist/cli-bundle/chunks/{notes-XATYT43P.js → notes-NJ7IQJX4.js} +12 -10
- package/dist/cli-bundle/chunks/{notes-XATYT43P.js.map → notes-NJ7IQJX4.js.map} +1 -1
- package/dist/cli-bundle/chunks/{plan-DVVLX7LK.js → plan-R4NDQ27E.js} +18 -15
- package/dist/cli-bundle/chunks/{plan-DVVLX7LK.js.map → plan-R4NDQ27E.js.map} +1 -1
- package/dist/cli-bundle/chunks/{plan-5NWQL2DH.js → plan-XWY5T67S.js} +20 -17
- package/dist/cli-bundle/chunks/{plan-5NWQL2DH.js.map → plan-XWY5T67S.js.map} +1 -1
- package/dist/cli-bundle/chunks/profile-XQWEQKS3.js +397 -0
- package/dist/cli-bundle/chunks/profile-XQWEQKS3.js.map +1 -0
- package/dist/cli-bundle/chunks/profile-YRDHLMRO.js +400 -0
- package/dist/cli-bundle/chunks/profile-YRDHLMRO.js.map +7 -0
- package/dist/cli-bundle/chunks/{register-list-query-WRS6ACUW.js → register-list-query-5H66WFYF.js} +22 -19
- package/dist/cli-bundle/chunks/{register-list-query-WRS6ACUW.js.map → register-list-query-5H66WFYF.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-list-query-PNRAHNIQ.js → register-list-query-FB3FNDLZ.js} +24 -21
- package/dist/cli-bundle/chunks/{register-list-query-PNRAHNIQ.js.map → register-list-query-FB3FNDLZ.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-mutation-K2MNRWGI.js → register-mutation-UJO23C7R.js} +42 -39
- package/dist/cli-bundle/chunks/{register-mutation-K2MNRWGI.js.map → register-mutation-UJO23C7R.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-mutation-ET6E4VLE.js → register-mutation-Z2ETYHKS.js} +40 -37
- package/dist/cli-bundle/chunks/{register-mutation-ET6E4VLE.js.map → register-mutation-Z2ETYHKS.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-operations-6DQRUTIX.js → register-operations-A3XAM5J7.js} +39 -36
- package/dist/cli-bundle/chunks/{register-operations-6DQRUTIX.js.map → register-operations-A3XAM5J7.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-operations-73UDWMVB.js → register-operations-SG7HBSUP.js} +37 -34
- package/dist/cli-bundle/chunks/{register-operations-73UDWMVB.js.map → register-operations-SG7HBSUP.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-setup-LYYCMQFV.js → register-setup-I45OGJUV.js} +25 -19
- package/dist/cli-bundle/chunks/{register-setup-LYYCMQFV.js.map → register-setup-I45OGJUV.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-setup-FXZJ2CEJ.js → register-setup-K6U3NVY5.js} +23 -17
- package/dist/cli-bundle/chunks/{register-setup-FXZJ2CEJ.js.map → register-setup-K6U3NVY5.js.map} +1 -1
- package/dist/cli-bundle/chunks/restore-PXOFL6AM.js +19 -0
- package/dist/cli-bundle/chunks/{restore-R6YJHQK3.js → restore-YJ2ET6AT.js} +11 -9
- package/dist/cli-bundle/chunks/{scheduling-shortcuts-OGODPUBL.js → scheduling-shortcuts-SSC4MYWQ.js} +14 -12
- package/dist/cli-bundle/chunks/{scheduling-shortcuts-OGODPUBL.js.map → scheduling-shortcuts-SSC4MYWQ.js.map} +1 -1
- package/dist/cli-bundle/chunks/{scheduling-shortcuts-LE4S7OI7.js → scheduling-shortcuts-ULRG7MNP.js} +16 -14
- package/dist/cli-bundle/chunks/{scheduling-shortcuts-LE4S7OI7.js.map → scheduling-shortcuts-ULRG7MNP.js.map} +1 -1
- package/dist/cli-bundle/chunks/{schema-ICCD3HOP.js → schema-2PUXCZ25.js} +10 -7
- package/dist/cli-bundle/chunks/{schema-RHH23PQX.js → schema-Y6DXXK2F.js} +10 -7
- package/dist/cli-bundle/chunks/{search-Z2VGP2Q5.js → search-3S72CTD6.js} +13 -10
- package/dist/cli-bundle/chunks/{search-HDDKOPFE.js → search-WNUNBQXO.js} +13 -10
- package/dist/cli-bundle/chunks/{stats-ETFP37MB.js → stats-IJYTRQGV.js} +13 -10
- package/dist/cli-bundle/chunks/{stats-ETFP37MB.js.map → stats-IJYTRQGV.js.map} +1 -1
- package/dist/cli-bundle/chunks/{stats-DHMRXHOB.js → stats-L2D5Y2O5.js} +15 -12
- package/dist/cli-bundle/chunks/{stats-DHMRXHOB.js.map → stats-L2D5Y2O5.js.map} +1 -1
- package/dist/cli-bundle/chunks/{telemetry-ZRBM22QD.js → telemetry-L2CVOKVN.js} +11 -8
- package/dist/cli-bundle/chunks/{telemetry-ZRBM22QD.js.map → telemetry-L2CVOKVN.js.map} +1 -1
- package/dist/cli-bundle/chunks/{telemetry-NUZNKDCP.js → telemetry-QBYWQA76.js} +13 -10
- package/dist/cli-bundle/chunks/{telemetry-NUZNKDCP.js.map → telemetry-QBYWQA76.js.map} +1 -1
- package/dist/cli-bundle/chunks/{test-XNKTIP4Y.js → test-DQ2QFJ7W.js} +21 -15
- package/dist/cli-bundle/chunks/test-W7QBLVJS.js +41 -0
- package/dist/cli-bundle/chunks/{test-all-APCBSXQI.js → test-all-636NTRTT.js} +26 -19
- package/dist/cli-bundle/chunks/{test-all-APCBSXQI.js.map → test-all-636NTRTT.js.map} +1 -1
- package/dist/cli-bundle/chunks/{test-all-KIK3OYBY.js → test-all-DWYK3RG6.js} +24 -17
- package/dist/cli-bundle/chunks/{test-all-KIK3OYBY.js.map → test-all-DWYK3RG6.js.map} +1 -1
- package/dist/cli-bundle/chunks/test-runs-245OINZR.js +28 -0
- package/dist/cli-bundle/chunks/test-runs-245OINZR.js.map +1 -0
- package/dist/cli-bundle/chunks/test-runs-ZRD4GCTT.js +24 -0
- package/dist/cli-bundle/chunks/test-runs-ZRD4GCTT.js.map +7 -0
- package/dist/cli-bundle/chunks/update-SFLZPJXX.js +30 -0
- package/dist/cli-bundle/chunks/update-SFLZPJXX.js.map +1 -0
- package/dist/cli-bundle/chunks/update-SJZ6S77U.js +26 -0
- package/dist/cli-bundle/chunks/update-SJZ6S77U.js.map +7 -0
- package/dist/cli-bundle/chunks/{update-many-XGTJ7QIU.js → update-many-DC7X3EWM.js} +32 -29
- package/dist/cli-bundle/chunks/{update-many-XGTJ7QIU.js.map → update-many-DC7X3EWM.js.map} +1 -1
- package/dist/cli-bundle/chunks/{update-many-GFCQG6ZQ.js → update-many-SLLAMHT7.js} +34 -31
- package/dist/cli-bundle/chunks/{update-many-GFCQG6ZQ.js.map → update-many-SLLAMHT7.js.map} +1 -1
- package/dist/cli-bundle/chunks/{upgrade-KJ3JGELR.js → upgrade-HFFXLZJA.js} +19 -12
- package/dist/cli-bundle/chunks/{upgrade-KJ3JGELR.js.map → upgrade-HFFXLZJA.js.map} +1 -1
- package/dist/cli-bundle/chunks/{upgrade-RBRQ7PQU.js → upgrade-UYQKM7RF.js} +21 -14
- package/dist/cli-bundle/chunks/{upgrade-RBRQ7PQU.js.map → upgrade-UYQKM7RF.js.map} +1 -1
- package/dist/cli-bundle/chunks/{validate-EW6TGC7R.js → validate-PA4FDTOV.js} +34 -27
- package/dist/cli-bundle/chunks/{validate-EW6TGC7R.js.map → validate-PA4FDTOV.js.map} +2 -2
- package/dist/cli-bundle/chunks/{validate-T6PR5WAL.js → validate-Z7L75YEJ.js} +35 -28
- package/dist/cli-bundle/chunks/{validate-T6PR5WAL.js.map → validate-Z7L75YEJ.js.map} +1 -1
- package/dist/cli-bundle/main.js +173 -57
- package/dist/cli-bundle/main.js.map +2 -2
- package/dist/cli-bundle/sdk-runtime.js +247 -0
- package/dist/cli-bundle/sdk-runtime.js.map +7 -0
- package/dist/cli-bundle/sdk-testing.js +101 -0
- package/dist/cli-bundle/sdk-testing.js.map +7 -0
- package/dist/cli-bundle/sdk.js +787 -0
- package/dist/cli-bundle/sdk.js.map +7 -0
- package/dist/core/config/nested-settings.d.ts +4 -3
- package/dist/core/config/nested-settings.js +17 -6
- package/dist/core/config/nested-settings.js.map +1 -1
- package/dist/core/extensions/activation-summary.d.ts +6 -0
- package/dist/core/extensions/activation-summary.js +10 -4
- package/dist/core/extensions/activation-summary.js.map +1 -1
- package/dist/core/extensions/capability-usage.d.ts +6 -0
- package/dist/core/extensions/capability-usage.js +10 -4
- package/dist/core/extensions/capability-usage.js.map +1 -1
- package/dist/core/extensions/extension-types.d.ts +5 -0
- package/dist/core/extensions/extension-types.js +2 -2
- package/dist/core/extensions/extension-types.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +3 -0
- package/dist/core/extensions/loader.js +11 -19
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/history/history-rewrite.js +3 -3
- package/dist/core/history/history-rewrite.js.map +1 -1
- package/dist/core/item/parent-reference-policy.d.ts +9 -1
- package/dist/core/item/parent-reference-policy.js +28 -4
- package/dist/core/item/parent-reference-policy.js.map +1 -1
- package/dist/core/lock/lock.d.ts +28 -1
- package/dist/core/lock/lock.js +254 -20
- package/dist/core/lock/lock.js.map +1 -1
- package/dist/core/search/background-refresh.js +7 -19
- package/dist/core/search/background-refresh.js.map +1 -1
- package/dist/core/search/http-client.d.ts +0 -1
- package/dist/core/search/http-client.js +3 -3
- package/dist/core/search/http-client.js.map +1 -1
- package/dist/core/shared/constants.js +3 -2
- package/dist/core/shared/constants.js.map +1 -1
- package/dist/core/shared/errors.d.ts +1 -0
- package/dist/core/shared/errors.js +2 -2
- package/dist/core/shared/errors.js.map +1 -1
- package/dist/core/shared/primitives.d.ts +12 -0
- package/dist/core/shared/primitives.js +29 -2
- package/dist/core/shared/primitives.js.map +1 -1
- package/dist/core/store/item-store.js +3 -3
- package/dist/core/store/item-store.js.map +1 -1
- package/dist/core/store/settings-validator.d.ts +1 -0
- package/dist/core/store/settings-validator.js +6 -3
- package/dist/core/store/settings-validator.js.map +1 -1
- package/dist/core/store/settings.js +3 -3
- package/dist/core/store/settings.js.map +1 -1
- package/dist/core/validate/fix-planning.d.ts +0 -2
- package/dist/core/validate/fix-planning.js +3 -3
- package/dist/core/validate/fix-planning.js.map +1 -1
- package/dist/sdk/cli-contracts/commander-mutation-options.js +3 -2
- package/dist/sdk/cli-contracts/commander-mutation-options.js.map +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +3 -2
- package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
- package/dist/sdk/errors.d.ts +21 -2
- package/dist/sdk/errors.js +8 -2
- package/dist/sdk/errors.js.map +1 -1
- package/dist/sdk/package-import-adapters.js +3 -3
- package/dist/sdk/package-import-adapters.js.map +1 -1
- package/dist/sdk/testing.js +41 -19
- package/dist/sdk/testing.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/docs/ARCHITECTURE.md +27 -0
- package/docs/CONFIGURATION.md +3 -0
- package/docs/README.md +1 -0
- package/docs/SDK_PRIMITIVE_INVENTORY.md +55 -0
- package/docs/TESTING.md +5 -1
- package/docs/examples/ci/github-actions-pm-extension-gate.yml +5 -5
- package/docs/examples/ci/gitlab-ci-pm-extension-gate.yml +1 -1
- package/docs/examples/ci/jenkins-pm-extension-gate.Jenkinsfile +1 -1
- package/package.json +11 -24
- package/packages/pm-beads/extensions/beads/package.json +3 -0
- package/packages/pm-beads/extensions/beads/runtime-loader.ts +24 -2
- package/packages/pm-calendar/extensions/calendar/package.json +3 -0
- package/packages/pm-command-kit/extensions/command-kit/package.json +3 -0
- package/packages/pm-governance-audit/extensions/governance-audit/package.json +3 -0
- package/packages/pm-guide-shell/extensions/guide-shell/package.json +3 -0
- package/packages/pm-kanban/extensions/kanban/package.json +3 -0
- package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/package.json +3 -0
- package/packages/pm-search-advanced/extensions/search-advanced/package.json +3 -0
- package/packages/pm-templates/extensions/templates/package.json +3 -0
- package/packages/pm-todos/extensions/todos/package.json +3 -0
- package/packages/pm-todos/extensions/todos/runtime-loader.ts +21 -3
- package/scripts/bundle-cli.mjs +12 -2
- package/dist/cli-bundle/chunks/activity-IDS5GSYG.js +0 -16
- package/dist/cli-bundle/chunks/chunk-2VK677OA.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-5FYY76HR.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-75VMARGO.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-7745CXNI.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-AOP2EMK3.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-AZMPKLIA.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-B4O5S7I3.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-BDDYM4LH.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-CN4OAA2G.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-EH23N5FX.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-FMWQRMHS.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-J4KNRDI3.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-KKHIQOTN.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-LLQLLAKU.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-M34MVAOP.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-MTB4PRA3.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-MZG6I2Q2.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-NGDK3KEZ.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-Q3XVLRCJ.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-SBNT6SLO.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-SL2ANJSV.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-TUV7SIWZ.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-UGDONITK.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-UYLA5ROU.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-WBWRQS32.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-XFO2NJY6.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-XQCWTSLO.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-YZWXMDNH.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-Z4DGFQDH.js.map +0 -1
- package/dist/cli-bundle/chunks/claim-D6L33A5Y.js.map +0 -1
- package/dist/cli-bundle/chunks/claim-YAFUTPVK.js.map +0 -7
- package/dist/cli-bundle/chunks/close-KLDLHAOP.js +0 -14
- package/dist/cli-bundle/chunks/create-AJ6HUR5W.js +0 -28
- package/dist/cli-bundle/chunks/history-IOH6FKG7.js +0 -18
- package/dist/cli-bundle/chunks/history-redact-VVDOARNO.js +0 -19
- package/dist/cli-bundle/chunks/init-CZLEEE6Q.js +0 -22
- package/dist/cli-bundle/chunks/init-MAA6UMNQ.js +0 -26
- package/dist/cli-bundle/chunks/profile-54DZ4CLB.js +0 -1205
- package/dist/cli-bundle/chunks/profile-54DZ4CLB.js.map +0 -1
- package/dist/cli-bundle/chunks/profile-PLIQVEOY.js +0 -1243
- package/dist/cli-bundle/chunks/profile-PLIQVEOY.js.map +0 -7
- package/dist/cli-bundle/chunks/restore-L27TMMCF.js +0 -17
- package/dist/cli-bundle/chunks/test-H36PM746.js +0 -35
- package/dist/cli-bundle/chunks/update-RQKI3AMW.js +0 -24
- package/dist/cli-bundle/chunks/update-ZM7NJWHY.js +0 -28
- /package/dist/cli-bundle/chunks/{activity-IDS5GSYG.js.map → activity-4XQIDNM5.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{activity-OENQCYZD.js.map → activity-YKAKZTZ4.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-4SHME4VR.js.map → chunk-5JE6SMYS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-4EVY7CQN.js.map → chunk-N6DNM2FA.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-YZR7UMZ6.js.map → chunk-NER3KUUS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-WTXDLBSZ.js.map → chunk-PDXT6Q55.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-724VLYDJ.js.map → chunk-RX3HQSYG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-PUVPC5DL.js.map → chunk-S4APD35C.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-A2W3XKAD.js.map → chunk-T35XLYZF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-ZZWMJVW2.js.map → chunk-TT42JUMF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-W5X3AHJN.js.map → chunk-YOF5VPKM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-MZ4NH46V.js.map → chunk-ZMD35NYG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-TGYXG7TV.js.map → close-3YRR3XY6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-KLDLHAOP.js.map → close-OB2Y4QP5.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{context-IHE3IXN5.js.map → context-4OQGIPSO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{context-WSYWBEUL.js.map → context-WLA6IAWE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{create-AJ6HUR5W.js.map → contracts-HXJLKCRI.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{create-JIA2IFCO.js.map → contracts-OJEXMKVW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{extension-T7JNTAAA.js.map → create-WKOZKPQR.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{extension-PVGRRZZG.js.map → create-XWWQFQ6S.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-IOH6FKG7.js.map → extension-NBAH62ML.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-W6QVR6FA.js.map → extension-ZF6ZZPOU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-redact-VVDOARNO.js.map → history-RYKLC72X.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-redact-TUWOUYX5.js.map → history-SGPYRAFT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{init-CZLEEE6Q.js.map → history-redact-4H3FCKF3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{init-MAA6UMNQ.js.map → history-redact-54ICFKXM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{list-HFD5737R.js.map → init-RPIPQUNV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{list-KN3TL5Y5.js.map → init-SKQAESQS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{restore-L27TMMCF.js.map → list-64LHZ3HM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{restore-R6YJHQK3.js.map → list-7LXBTEKI.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{schema-ICCD3HOP.js.map → restore-PXOFL6AM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{schema-RHH23PQX.js.map → restore-YJ2ET6AT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{search-HDDKOPFE.js.map → schema-2PUXCZ25.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{search-Z2VGP2Q5.js.map → schema-Y6DXXK2F.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{test-XNKTIP4Y.js.map → search-3S72CTD6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{test-H36PM746.js.map → search-WNUNBQXO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-ZM7NJWHY.js.map → test-DQ2QFJ7W.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-RQKI3AMW.js.map → test-W7QBLVJS.js.map} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../core/extensions/item-fields.ts", "../../../../../../../../core/item/item-record.ts", "../../../../../../../../core/history/history.ts", "../../../../../../../../core/history/history-stream-policy.ts", "../../../../../../../../core/lock/lock.ts", "../../../../../../../../core/store/front-matter-cache.ts", "../../../../../../../../core/store/item-store.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @module core/extensions/item-fields\n *\n * Implements extension runtime contracts and governance for Item Fields.\n */\nimport type { ExtensionRegistrationRegistry } from \"./loader.js\";\nimport { normalizeItemFieldType, type KnownItemFieldType } from \"./item-field-types.js\";\nimport { EXIT_CODE, FRONT_MATTER_KEY_ORDER } from \"../shared/constants.js\";\nimport { PmCliError } from \"../shared/errors.js\";\n\nconst RESERVED_ITEM_FIELD_NAMES = new Set(FRONT_MATTER_KEY_ORDER);\n\nfunction normalizeFieldName(value: unknown): string | null {\n if (typeof value !== \"string\") {\n return null;\n }\n const normalized = value.trim();\n return normalized.length > 0 ? normalized : null;\n}\n\nfunction normalizeFieldType(value: unknown): KnownItemFieldType | null {\n if (typeof value !== \"string\") {\n return null;\n }\n return normalizeItemFieldType(value);\n}\n\nfunction cloneFieldValue<T>(value: T): T {\n try {\n return structuredClone(value);\n } catch {\n return value;\n }\n}\n\nfunction parseFieldAssignment(raw: string): { key: string; value: string } {\n const trimmed = raw.trim();\n const separatorIndex = trimmed.indexOf(\"=\");\n if (separatorIndex <= 0) {\n throw new PmCliError(`--field entries must use name=value syntax, received: ${raw}`, EXIT_CODE.USAGE);\n }\n // `separatorIndex > 0` guarantees a non-`=` first character on the already\n // trimmed string, so the trimmed key is always non-empty here.\n const key = trimmed.slice(0, separatorIndex).trim();\n const value = trimmed.slice(separatorIndex + 1);\n return { key, value };\n}\n\nfunction parseJsonFieldValue(raw: string, fieldName: string, expectedType: \"array\" | \"object\"): unknown {\n try {\n const parsed = JSON.parse(raw);\n if (expectedType === \"array\" && Array.isArray(parsed)) {\n return parsed;\n }\n if (expectedType === \"object\" && typeof parsed === \"object\" && parsed !== null && !Array.isArray(parsed)) {\n return parsed;\n }\n } catch {\n // Fall through to the typed usage error below.\n }\n throw new PmCliError(`--field ${fieldName}=... must be valid JSON ${expectedType}`, EXIT_CODE.USAGE);\n}\n\nfunction coerceRegisteredFieldValue(fieldName: string, fieldType: \"string\" | \"number\" | \"boolean\" | \"array\" | \"object\", raw: string): unknown {\n if (fieldType === \"string\") {\n return raw;\n }\n if (fieldType === \"number\") {\n const trimmed = raw.trim();\n if (trimmed.length === 0) {\n throw new PmCliError(`--field ${fieldName}=... must be a number`, EXIT_CODE.USAGE);\n }\n const parsed = Number(trimmed);\n if (!Number.isFinite(parsed)) {\n throw new PmCliError(`--field ${fieldName}=... must be a number`, EXIT_CODE.USAGE);\n }\n return parsed;\n }\n if (fieldType === \"boolean\") {\n const normalized = raw.trim().toLowerCase();\n if (normalized === \"true\" || normalized === \"1\" || normalized === \"yes\") {\n return true;\n }\n if (normalized === \"false\" || normalized === \"0\" || normalized === \"no\") {\n return false;\n }\n throw new PmCliError(`--field ${fieldName}=... must be one of true|false|1|0|yes|no`, EXIT_CODE.USAGE);\n }\n return parseJsonFieldValue(raw, fieldName, fieldType);\n}\n\nfunction collectRegisteredFieldDefinitions(\n registrations: ExtensionRegistrationRegistry | null,\n): Map<string, { name: string; type: \"string\" | \"number\" | \"boolean\" | \"array\" | \"object\" }> {\n const definitions = new Map<string, { name: string; type: \"string\" | \"number\" | \"boolean\" | \"array\" | \"object\" }>();\n if (!registrations) {\n return definitions;\n }\n for (const registration of registrations.item_fields) {\n for (const definition of registration.fields) {\n const fieldName = normalizeFieldName(definition.name);\n const fieldType = normalizeFieldType(definition.type);\n if (!fieldName || !fieldType) {\n continue;\n }\n const existing = definitions.get(fieldName);\n if (existing && existing.type !== fieldType) {\n throw new PmCliError(\n `Extension item field \"${fieldName}\" is declared with conflicting types: ${existing.type}, ${fieldType}`,\n EXIT_CODE.USAGE,\n {\n code: \"extension_item_field_type_conflict\",\n nextSteps: [\"Make every active extension declaration for this field use the same type.\"],\n },\n );\n }\n definitions.set(fieldName, { name: fieldName, type: fieldType });\n }\n }\n return definitions;\n}\n\nfunction assertNotReservedItemFieldName(fieldName: string): void {\n if (!RESERVED_ITEM_FIELD_NAMES.has(fieldName)) {\n return;\n }\n throw new PmCliError(`Extension item field \"${fieldName}\" collides with reserved item metadata`, EXIT_CODE.USAGE, {\n code: \"extension_item_field_reserved\",\n nextSteps: [\"Rename the extension item field, preferably with an extension-specific prefix.\"],\n });\n}\n\n/**\n * Implements collect registered item field names for the public runtime surface of this module.\n */\nexport function collectRegisteredItemFieldNames(registrations: ExtensionRegistrationRegistry | null): string[] {\n return [...collectRegisteredFieldDefinitions(registrations).keys()].sort((left, right) => left.localeCompare(right));\n}\n\n/**\n * Implements parse registered item field assignments for the public runtime surface of this module.\n */\nexport function parseRegisteredItemFieldAssignments(\n rawFields: string[] | undefined,\n registrations: ExtensionRegistrationRegistry | null,\n): Record<string, unknown> {\n if (!rawFields || rawFields.length === 0) {\n return {};\n }\n const definitions = collectRegisteredFieldDefinitions(registrations);\n const values: Record<string, unknown> = {};\n for (const raw of rawFields) {\n const { key, value } = parseFieldAssignment(raw);\n const definition = definitions.get(key);\n if (!definition) {\n const known = [...definitions.keys()].sort((left, right) => left.localeCompare(right));\n throw new PmCliError(`--field ${key} is not declared by an active extension item-field registration`, EXIT_CODE.USAGE, {\n code: \"extension_item_field_unknown\",\n recovery: { provided_fields: known },\n nextSteps: known.length > 0\n ? [`Use one of the declared fields: ${known.join(\", \")}`]\n : [\"Activate an extension that calls registerItemFields before setting extension fields.\"],\n });\n }\n assertNotReservedItemFieldName(definition.name);\n values[definition.name] = coerceRegisteredFieldValue(definition.name, definition.type, value);\n }\n return values;\n}\n\nfunction isValidFieldType(value: unknown, expectedType: \"string\" | \"number\" | \"boolean\" | \"array\" | \"object\"): boolean {\n if (expectedType === \"string\") {\n return typeof value === \"string\";\n }\n if (expectedType === \"number\") {\n return typeof value === \"number\" && Number.isFinite(value);\n }\n if (expectedType === \"boolean\") {\n return typeof value === \"boolean\";\n }\n if (expectedType === \"array\") {\n return Array.isArray(value);\n }\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isAllowedFieldValue(value: unknown, allowed: unknown[] | undefined): boolean {\n if (!allowed || allowed.length === 0) {\n return true;\n }\n return allowed.some((candidate) => Object.is(candidate, value));\n}\n\n/**\n * Implements apply registered item field defaults and validation for the public runtime surface of this module.\n */\nexport function applyRegisteredItemFieldDefaultsAndValidation(\n frontMatter: Record<string, unknown>,\n registrations: ExtensionRegistrationRegistry | null,\n options: { skipDefaultFields?: ReadonlySet<string> } = {},\n): void {\n if (!registrations) {\n return;\n }\n collectRegisteredFieldDefinitions(registrations);\n for (const registration of registrations.item_fields) {\n for (const definition of registration.fields) {\n const fieldName = normalizeFieldName(definition.name);\n if (!fieldName) {\n continue;\n }\n assertNotReservedItemFieldName(fieldName);\n if (\n !(fieldName in frontMatter) &&\n !options.skipDefaultFields?.has(fieldName) &&\n Object.prototype.hasOwnProperty.call(definition, \"default\")\n ) {\n frontMatter[fieldName] = cloneFieldValue(definition.default);\n }\n\n const currentValue = frontMatter[fieldName];\n if (currentValue === undefined) {\n continue;\n }\n const expectedType = normalizeFieldType(definition.type);\n if (expectedType && !isValidFieldType(currentValue, expectedType)) {\n throw new TypeError(`Item field \"${fieldName}\" must be of type ${expectedType}`);\n }\n\n const allowedValues = Array.isArray(definition.values) ? definition.values : undefined;\n if (!isAllowedFieldValue(currentValue, allowedValues)) {\n throw new TypeError(`Item field \"${fieldName}\" must match one of the configured allowed values`);\n }\n }\n }\n}\n", "/**\n * @module core/item/item-record\n *\n * Defines item parsing, formatting, and lifecycle helpers for Item Record.\n */\nimport type { ItemMetadata } from \"../../types/index.js\";\n\n/**\n * Bridge a typed item record into the generic `Record<string, unknown>` shape\n * consumed by formatters, field projections, history canonicalization, and\n * JSON output paths.\n *\n * `ItemMetadata` carries an index signature, but the structural mismatch on its\n * concretely-typed fields means TypeScript still requires a double cast to widen\n * it. Centralizing that `as unknown as Record<string, unknown>` widening here\n * gives the type bridge a single, named, documented home instead of scattering\n * the cast across command and core modules.\n *\n * This is a compile-time-only widening: the returned value is the very same\n * object reference, with no runtime transformation. (It is intentionally\n * distinct from the runtime `asRecord*` guards in `core/shared/primitives.ts`,\n * which validate `typeof` at runtime.) `ItemFrontMatter` is an alias of\n * `ItemMetadata`, so front-matter values are accepted as-is.\n */\nexport function toItemRecord(item: ItemMetadata): Record<string, unknown> {\n return item as unknown as Record<string, unknown>;\n}\n", "/**\n * @module core/history/history\n *\n * Implements append-only history and replay behavior for History.\n */\nimport jsonPatch from \"fast-json-patch\";\nimport { FRONT_MATTER_KEY_ORDER } from \"../shared/constants.js\";\nimport { runActiveServiceOverride } from \"../extensions/index.js\";\nimport { appendLineAtomic } from \"../fs/fs-utils.js\";\nimport { canonicalDocument } from \"../item/item-format.js\";\nimport { toItemRecord } from \"../item/item-record.js\";\nimport { orderObject, sha256Hex, stableStringify } from \"../shared/serialization.js\";\nimport { nowIso } from \"../shared/time.js\";\nimport type { HistoryEntry, HistoryPatchOp, ItemDocument } from \"../../types/index.js\";\n\nconst EMPTY_LEGACY_HASH_DOCUMENT = {\n front_matter: {},\n body: \"\",\n};\n\nfunction decodeJsonPointer(path: string): string[] {\n if (!path || path === \"/\") {\n return [];\n }\n if (!path.startsWith(\"/\")) {\n return [];\n }\n return path\n .slice(1)\n .split(\"/\")\n .map((segment) => segment.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\"));\n}\n\nfunction isDefinedPointerPath(document: unknown, path: string): boolean {\n const segments = decodeJsonPointer(path);\n if (segments.length === 0) {\n return true;\n }\n let cursor: unknown = document;\n for (const segment of segments) {\n if (Array.isArray(cursor)) {\n if (segment === \"-\" || !/^(0|[1-9]\\d*)$/.test(segment)) {\n return false;\n }\n const index = Number(segment);\n if (!Number.isInteger(index) || index < 0 || index >= cursor.length) {\n return false;\n }\n const next = cursor[index];\n if (next === undefined) {\n return false;\n }\n cursor = next;\n continue;\n }\n if (typeof cursor !== \"object\" || cursor === null) {\n return false;\n }\n if (!Object.prototype.hasOwnProperty.call(cursor, segment)) {\n return false;\n }\n const next = (cursor as Record<string, unknown>)[segment];\n if (next === undefined) {\n return false;\n }\n cursor = next;\n }\n return true;\n}\n\nfunction normalizeHistoryPatchOps(\n beforeDocument: { metadata: Record<string, unknown>; body: string },\n patch: HistoryPatchOp[],\n): HistoryPatchOp[] {\n const normalized: HistoryPatchOp[] = [];\n let replayCursor: unknown = structuredClone(beforeDocument);\n for (const operation of patch) {\n const normalizedOperation =\n operation.op === \"replace\" && !isDefinedPointerPath(replayCursor, operation.path)\n ? ({ ...operation, op: \"add\" } as HistoryPatchOp)\n : operation;\n normalized.push(normalizedOperation);\n replayCursor = jsonPatch.applyPatch(\n replayCursor,\n [normalizedOperation as jsonPatch.Operation],\n true,\n true,\n ).newDocument as unknown;\n }\n return normalized;\n}\n\nfunction canonicalHashDocument(document: ItemDocument): { front_matter: Record<string, unknown>; body: string } {\n const hasMetadata = document.metadata && Object.keys(document.metadata).length > 0;\n if (!hasMetadata) {\n return {\n front_matter: {},\n body: document.body ?? \"\",\n };\n }\n const canonical = canonicalDocument(document);\n const orderedFrontMatter = orderObject(toItemRecord(canonical.metadata), FRONT_MATTER_KEY_ORDER);\n return {\n front_matter: orderedFrontMatter,\n body: canonical.body,\n };\n}\n\nfunction canonicalPatchDocument(document: ItemDocument): { metadata: Record<string, unknown>; body: string } {\n const hasMetadata = document.metadata && Object.keys(document.metadata).length > 0;\n if (!hasMetadata) {\n return {\n metadata: {},\n body: document.body ?? \"\",\n };\n }\n const canonical = canonicalDocument(document);\n const orderedMetadata = orderObject(toItemRecord(canonical.metadata), FRONT_MATTER_KEY_ORDER);\n return {\n metadata: orderedMetadata,\n body: canonical.body,\n };\n}\n\n/**\n * Implements hash document for the public runtime surface of this module.\n */\nexport function hashDocument(document: ItemDocument): string {\n return sha256Hex(stableStringify(canonicalHashDocument(document)));\n}\n\n/**\n * Implements hash empty document for the public runtime surface of this module.\n */\nexport function hashEmptyDocument(): string {\n return sha256Hex(stableStringify(EMPTY_LEGACY_HASH_DOCUMENT));\n}\n\n/**\n * Implements create history entry for the public runtime surface of this module.\n */\nexport function createHistoryEntry(params: {\n nowIso: string;\n author: string;\n op: string;\n before: ItemDocument;\n after: ItemDocument;\n message?: string;\n}): HistoryEntry {\n const beforeHashCanonical = canonicalHashDocument(params.before);\n const afterHashCanonical = canonicalHashDocument(params.after);\n const beforePatchCanonical = canonicalPatchDocument(params.before);\n const afterPatchCanonical = canonicalPatchDocument(params.after);\n const rawPatch = jsonPatch.compare(beforePatchCanonical, afterPatchCanonical) as HistoryPatchOp[];\n const patch = normalizeHistoryPatchOps(beforePatchCanonical, rawPatch);\n\n return {\n ts: params.nowIso,\n author: params.author,\n op: params.op,\n patch,\n before_hash: sha256Hex(stableStringify(beforeHashCanonical)),\n after_hash: sha256Hex(stableStringify(afterHashCanonical)),\n message: params.message === undefined ? undefined : params.message,\n };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction fallbackHistoryTimestamp(entry: Pick<HistoryEntry, \"ts\">): string {\n const ts = entry.ts.trim();\n return ts.length > 0 ? ts : nowIso();\n}\n\nfunction withHistoryTimestamp(value: Record<string, unknown>, fallbackTs: string): Record<string, unknown> {\n const ts = value.ts;\n if (typeof ts === \"string\" && ts.trim().length > 0) {\n return value;\n }\n return { ...value, ts: fallbackTs };\n}\n\nfunction serializeHistoryLine(value: unknown, fallbackEntry: Pick<HistoryEntry, \"ts\">): string {\n const fallbackTs = fallbackHistoryTimestamp(fallbackEntry);\n if (typeof value === \"string\") {\n try {\n const parsed = JSON.parse(value) as unknown;\n if (isRecord(parsed)) {\n return JSON.stringify(withHistoryTimestamp(parsed, fallbackTs));\n }\n } catch {\n // Non-JSON extension lines are preserved for compatibility.\n }\n return value;\n }\n if (isRecord(value)) {\n return JSON.stringify(withHistoryTimestamp(value, fallbackTs));\n }\n return JSON.stringify(value);\n}\n\n/**\n * Implements append history entry for the public runtime surface of this module.\n */\nexport async function appendHistoryEntry(historyPath: string, entry: HistoryEntry): Promise<void> {\n const override = await runActiveServiceOverride(\"history_append\", {\n history_path: historyPath,\n entry,\n });\n if (override.handled) {\n if (override.result === false) {\n return;\n }\n if (typeof override.result === \"string\") {\n await appendLineAtomic(historyPath, serializeHistoryLine(override.result, entry));\n return;\n }\n if (typeof override.result === \"object\" && override.result !== null) {\n const record = override.result as {\n history_path?: unknown;\n entry?: unknown;\n line?: unknown;\n skip?: unknown;\n };\n if (record.skip === true) {\n return;\n }\n const nextHistoryPath = typeof record.history_path === \"string\" ? record.history_path : historyPath;\n if (typeof record.line === \"string\") {\n await appendLineAtomic(nextHistoryPath, serializeHistoryLine(record.line, entry));\n return;\n }\n await appendLineAtomic(nextHistoryPath, serializeHistoryLine(record.entry ?? entry, entry));\n return;\n }\n }\n await appendLineAtomic(historyPath, serializeHistoryLine(entry, entry));\n}\n\nexport const _testOnly = {\n decodeJsonPointer,\n isDefinedPointerPath,\n};\n", "/**\n * @module core/history/history-stream-policy\n *\n * Implements append-only history and replay behavior for History Stream Policy.\n */\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { runActiveOnWriteHooks } from \"../extensions/index.js\";\nimport { ensureDir, pathExists } from \"../fs/fs-utils.js\";\nimport { EXIT_CODE } from \"../shared/constants.js\";\nimport { PmCliError } from \"../shared/errors.js\";\nimport { getHistoryPath } from \"../store/paths.js\";\nimport type { PmSettings } from \"../../types/index.js\";\n\ninterface HistoryStreamPolicyParams {\n pmRoot: string;\n settings: PmSettings;\n itemId: string;\n commandLabel: string;\n}\n\ninterface HistoryStreamPolicyManyParams {\n pmRoot: string;\n settings: PmSettings;\n itemIds: string[];\n commandLabel: string;\n}\n\n/**\n * Documents the history stream policy result payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryStreamPolicyResult {\n auto_created_ids: string[];\n warnings: string[];\n}\n\nfunction toSortedUniqueItemIds(itemIds: string[]): string[] {\n return [...new Set(itemIds.filter((value) => value.trim().length > 0))].sort((left, right) => left.localeCompare(right));\n}\n\nfunction strictMissingStreamError(itemId: string, commandLabel: string): PmCliError {\n return new PmCliError(\n `Missing history stream for ${itemId}. ${commandLabel} requires history streams when settings.history.missing_stream is strict_error.`,\n EXIT_CODE.NOT_FOUND,\n );\n}\n\nasync function createStream(historyPath: string, commandLabel: string): Promise<string[]> {\n await ensureDir(path.dirname(historyPath));\n const handle = await fs.open(historyPath, \"a\");\n await handle.close();\n return runActiveOnWriteHooks({\n path: historyPath,\n scope: \"project\",\n op: `${commandLabel}:history:auto_create`,\n });\n}\n\n/**\n * Implements enforce history stream policy for item for the public runtime surface of this module.\n */\nexport async function enforceHistoryStreamPolicyForItem(params: HistoryStreamPolicyParams): Promise<HistoryStreamPolicyResult> {\n return enforceHistoryStreamPolicyForItems({\n pmRoot: params.pmRoot,\n settings: params.settings,\n itemIds: [params.itemId],\n commandLabel: params.commandLabel,\n });\n}\n\n/**\n * Implements enforce history stream policy for items for the public runtime surface of this module.\n */\nexport async function enforceHistoryStreamPolicyForItems(\n params: HistoryStreamPolicyManyParams,\n): Promise<HistoryStreamPolicyResult> {\n const ids = toSortedUniqueItemIds(params.itemIds);\n const autoCreated: string[] = [];\n const warnings: string[] = [];\n\n for (const itemId of ids) {\n const historyPath = getHistoryPath(params.pmRoot, itemId);\n if (await pathExists(historyPath)) {\n continue;\n }\n if (params.settings.history.missing_stream === \"strict_error\") {\n throw strictMissingStreamError(itemId, params.commandLabel);\n }\n warnings.push(...(await createStream(historyPath, params.commandLabel)));\n warnings.push(`history_stream_auto_created:${itemId}`);\n autoCreated.push(itemId);\n }\n\n return {\n auto_created_ids: autoCreated,\n warnings,\n };\n}\n", "/**\n * @module core/lock/lock\n *\n * Coordinates tracker lock ownership and cleanup for Lock.\n */\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { randomUUID } from \"node:crypto\";\nimport { runActiveOnReadHooks, runActiveOnWriteHooks, runActiveServiceOverride } from \"../extensions/index.js\";\nimport { EXIT_CODE } from \"../shared/constants.js\";\nimport { PmCliError } from \"../shared/errors.js\";\nimport { toErrorMessage } from \"../shared/primitives.js\";\nimport { getLockPath } from \"../store/paths.js\";\nimport { nowIso } from \"../shared/time.js\";\n\ninterface LockInfo {\n id: string;\n pid: number;\n owner: string;\n created_at: string;\n ttl_seconds: number;\n}\n\ntype LockWriteOp = \"lock:create\" | \"lock:release\" | \"lock:stale_remove\";\n\ninterface LockReadResult {\n info: LockInfo | null;\n warnings: string[];\n}\n\ninterface StaleLockRemovalResult {\n lockInfo: LockReadResult;\n shouldRetryCreate: boolean;\n staleRemovalCounted: boolean;\n}\n\ninterface StaleCleanupGateOwner {\n pid: number;\n token: string;\n}\n\nfunction parseLockInfo(raw: string): LockReadResult {\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch {\n return {\n info: null,\n warnings: [\"lock_info_invalid_json\"],\n };\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n return {\n info: null,\n warnings: [\"lock_info_invalid_shape\"],\n };\n }\n const candidate = parsed as Record<string, unknown>;\n const id = candidate.id;\n const pid = candidate.pid;\n const owner = candidate.owner;\n const createdAt = candidate.created_at;\n const ttlSeconds = candidate.ttl_seconds;\n if (\n typeof id !== \"string\" ||\n typeof pid !== \"number\" ||\n !Number.isFinite(pid) ||\n typeof owner !== \"string\" ||\n typeof createdAt !== \"string\" ||\n typeof ttlSeconds !== \"number\" ||\n !Number.isFinite(ttlSeconds)\n ) {\n return {\n info: null,\n warnings: [\"lock_info_invalid_shape\"],\n };\n }\n return {\n info: {\n id,\n pid,\n owner,\n created_at: createdAt,\n ttl_seconds: ttlSeconds,\n },\n warnings: [],\n };\n}\n\nasync function readLockInfo(lockPath: string): Promise<LockReadResult> {\n try {\n const raw = await fs.readFile(lockPath, \"utf8\");\n await runActiveOnReadHooks({\n path: lockPath,\n scope: \"project\",\n });\n return parseLockInfo(raw);\n } catch (error: unknown) {\n if (isErrno(error, \"ENOENT\")) {\n return {\n info: null,\n warnings: [],\n };\n }\n return {\n info: null,\n warnings: [\"lock_info_read_failed\"],\n };\n }\n}\n\nfunction isErrno(error: unknown, code: string): boolean {\n return typeof error === \"object\" && error !== null && \"code\" in error && (error as { code?: string }).code === code;\n}\n\nasync function emitLockWriteHook(lockPath: string, op: LockWriteOp): Promise<void> {\n await runActiveOnWriteHooks({\n path: lockPath,\n scope: \"project\",\n op,\n });\n}\n\nfunction buildLockPayload(id: string, owner: string, ttlSeconds: number): LockInfo {\n return {\n id,\n pid: process.pid,\n owner,\n created_at: nowIso(),\n ttl_seconds: ttlSeconds,\n };\n}\n\nasync function createLockFile(lockPath: string, id: string, owner: string, ttlSeconds: number): Promise<void> {\n await fs.mkdir(path.dirname(lockPath), { recursive: true });\n const handle = await fs.open(lockPath, \"wx\");\n try {\n await handle.writeFile(`${JSON.stringify(buildLockPayload(id, owner, ttlSeconds), null, 2)}\\n`, \"utf8\");\n } finally {\n await handle.close();\n }\n await emitLockWriteHook(lockPath, \"lock:create\");\n}\n\nasync function unlinkLockWithHook(lockPath: string, op: \"lock:release\" | \"lock:stale_remove\"): Promise<boolean> {\n try {\n await fs.unlink(lockPath);\n await emitLockWriteHook(lockPath, op);\n return true;\n } catch {\n // Lock cleanup is best-effort.\n return false;\n }\n}\n\nfunction isStaleLock(info: LockInfo | null, ttlSeconds: number): boolean {\n const createdAtMs = info?.created_at ? Date.parse(info.created_at) : Number.NaN;\n const ageMs = Number.isFinite(createdAtMs) ? Date.now() - createdAtMs : Number.POSITIVE_INFINITY;\n return ageMs > ttlSeconds * 1000;\n}\n\nfunction lockOwnerSuffix(info: LockInfo | null): string {\n return info?.owner ? ` (owner ${info.owner})` : \"\";\n}\n\nconst LOCK_WAIT_INITIAL_DELAY_MS = 25;\nconst LOCK_WAIT_MAX_DELAY_MS = 200;\nconst LOCK_CONFLICT_RETRY_HINT_MS = 250;\nconst MAX_STALE_LOCK_REMOVALS = 3;\nconst STALE_CLEANUP_GATE_SUFFIX = \".stale-cleanup\";\nconst STALE_CLEANUP_GATE_OWNER_FILE = \"owner.json\";\nconst STALE_CLEANUP_GATE_STALE_MS = 10_000;\n// Bounds PID-reuse false positives: a live recycled PID can delay cleanup, but not indefinitely.\nconst STALE_CLEANUP_GATE_MAX_ACTIVE_MS = 5 * 60_000;\n\nfunction parseNonNegativeIntegerWaitMs(value: string | number | undefined): number | undefined {\n if (typeof value === \"string\") {\n const trimmed = value.trim();\n if (!/^\\d+$/.test(trimmed)) {\n return undefined;\n }\n const parsed = Number(trimmed);\n return Number.isSafeInteger(parsed) ? parsed : undefined;\n }\n if (typeof value === \"number\" && Number.isFinite(value) && value >= 0) {\n return Math.trunc(value);\n }\n return undefined;\n}\n\n/**\n * Resolves the effective bounded wait budget for a contended lock: the\n * PM_LOCK_WAIT_MS environment override wins when it parses as a non-negative\n * integer, then the caller-provided budget (settings `locks.wait_ms`), then 0\n * (fail-fast, the pre-wait behavior).\n */\nfunction resolveLockWaitMs(waitMs: number | undefined): number {\n const envRaw = process.env.PM_LOCK_WAIT_MS;\n const envParsed = parseNonNegativeIntegerWaitMs(envRaw);\n if (envParsed !== undefined) {\n return envParsed;\n }\n const callerParsed = parseNonNegativeIntegerWaitMs(waitMs);\n if (callerParsed !== undefined) {\n return callerParsed;\n }\n return 0;\n}\n\nfunction sleepWithJitter(baseDelayMs: number): Promise<void> {\n const jitteredMs = Math.max(1, Math.round(baseDelayMs * (0.5 + Math.random())));\n return new Promise((resolve) => setTimeout(resolve, jitteredMs));\n}\n\nfunction buildLockConflictError(id: string, info: LockInfo | null, waitedMs: number): PmCliError {\n const waitedSuffix = waitedMs > 0 ? ` after waiting ${waitedMs}ms` : \"\";\n return new PmCliError(`Item ${id} is locked${lockOwnerSuffix(info)}${waitedSuffix}`, EXIT_CODE.CONFLICT, {\n code: \"lock_conflict\",\n recovery: {\n retry_after_ms: LOCK_CONFLICT_RETRY_HINT_MS,\n },\n });\n}\n\ntype LockReleaseOverride = () => Promise<void> | void;\n\nfunction resolveLockOverrideRelease(result: unknown): LockReleaseOverride | null {\n if (typeof result === \"function\") {\n return result as LockReleaseOverride;\n }\n if (typeof result === \"object\" && result !== null && \"release\" in result) {\n const release = (result as { release?: unknown }).release;\n return typeof release === \"function\" ? (release as LockReleaseOverride) : null;\n }\n return null;\n}\n\nfunction throwIfStaleLockNeedsForce(id: string, lockInfo: LockReadResult, force: boolean, forceRequired: boolean): void {\n if (!force && forceRequired) {\n const warningSuffix = lockInfo.warnings.length > 0 ? ` (${lockInfo.warnings.join(\",\")})` : \"\";\n throw new PmCliError(\n `Item ${id} lock is stale${warningSuffix}; rerun with --force when supported for this command`,\n EXIT_CODE.CONFLICT,\n );\n }\n}\n\nfunction parseStaleCleanupGateOwner(raw: string): StaleCleanupGateOwner | null {\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch {\n return null;\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n return null;\n }\n const candidate = parsed as Record<string, unknown>;\n const pid = candidate.pid;\n const token = candidate.token;\n if (typeof pid !== \"number\" || !Number.isInteger(pid) || pid <= 0 || typeof token !== \"string\" || token.length === 0) {\n return null;\n }\n return { pid, token };\n}\n\nasync function readStaleCleanupGateOwner(gatePath: string): Promise<StaleCleanupGateOwner | null> {\n try {\n return parseStaleCleanupGateOwner(await fs.readFile(path.join(gatePath, STALE_CLEANUP_GATE_OWNER_FILE), \"utf8\"));\n } catch {\n return null;\n }\n}\n\nfunction isProcessAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error: unknown) {\n if (isErrno(error, \"ESRCH\")) {\n return false;\n }\n return true;\n }\n}\n\nasync function removeStaleCleanupGateDirectory(gatePath: string): Promise<boolean> {\n try {\n await fs.rm(gatePath, { recursive: true, force: true });\n return true;\n } catch {\n return false;\n }\n}\n\nasync function releaseStaleCleanupGate(gatePath: string, token: string): Promise<void> {\n const owner = await readStaleCleanupGateOwner(gatePath);\n if (owner === null || owner.token !== token) {\n return;\n }\n await removeStaleCleanupGateDirectory(gatePath);\n}\n\nasync function tryCreateStaleCleanupGate(gatePath: string): Promise<StaleCleanupGateOwner | null> {\n try {\n await fs.mkdir(gatePath);\n } catch (error: unknown) {\n if (isErrno(error, \"EEXIST\")) {\n return null;\n }\n return null;\n }\n const owner = { pid: process.pid, token: randomUUID() };\n try {\n await fs.writeFile(path.join(gatePath, STALE_CLEANUP_GATE_OWNER_FILE), `${JSON.stringify(owner)}\\n`, \"utf8\");\n } catch {\n await removeStaleCleanupGateDirectory(gatePath);\n return null;\n }\n return owner;\n}\n\nasync function removeExpiredStaleCleanupGate(gatePath: string): Promise<boolean> {\n let gateAgeMs: number;\n try {\n const stats = await fs.stat(gatePath);\n gateAgeMs = Date.now() - stats.mtimeMs;\n if (gateAgeMs <= STALE_CLEANUP_GATE_STALE_MS) {\n return false;\n }\n } catch (error: unknown) {\n return isErrno(error, \"ENOENT\");\n }\n const owner = await readStaleCleanupGateOwner(gatePath);\n if (owner !== null && isProcessAlive(owner.pid) && gateAgeMs <= STALE_CLEANUP_GATE_MAX_ACTIVE_MS) {\n return false;\n }\n return removeStaleCleanupGateDirectory(gatePath);\n}\n\nasync function acquireStaleCleanupGate(lockPath: string, _id: string): Promise<(() => Promise<void>) | null> {\n const gatePath = `${lockPath}${STALE_CLEANUP_GATE_SUFFIX}`;\n const owner = await tryCreateStaleCleanupGate(gatePath);\n if (owner !== null) {\n return async () => releaseStaleCleanupGate(gatePath, owner.token);\n }\n if (!(await removeExpiredStaleCleanupGate(gatePath))) {\n return null;\n }\n const recoveredOwner = await tryCreateStaleCleanupGate(gatePath);\n if (recoveredOwner === null) {\n return null;\n }\n return async () => releaseStaleCleanupGate(gatePath, recoveredOwner.token);\n}\n\nasync function removeConfirmedStaleLock(params: {\n lockPath: string;\n id: string;\n ttlSeconds: number;\n force: boolean;\n forceRequiredForStaleLock: boolean;\n staleRemovals: number;\n waitBudgetMs: number;\n startedAtMs: number;\n fallbackLockInfo: LockReadResult;\n}): Promise<StaleLockRemovalResult> {\n const releaseCleanupGate = await acquireStaleCleanupGate(params.lockPath, params.id);\n if (releaseCleanupGate === null) {\n return {\n lockInfo: params.fallbackLockInfo,\n shouldRetryCreate: false,\n staleRemovalCounted: false,\n };\n }\n try {\n const currentLockInfo = await readLockInfo(params.lockPath);\n if (currentLockInfo.info === null && currentLockInfo.warnings.length === 0) {\n return {\n lockInfo: currentLockInfo,\n shouldRetryCreate: true,\n staleRemovalCounted: false,\n };\n }\n if (!isStaleLock(currentLockInfo.info, params.ttlSeconds)) {\n return {\n lockInfo: currentLockInfo,\n shouldRetryCreate: false,\n staleRemovalCounted: false,\n };\n }\n throwIfStaleLockNeedsForce(params.id, currentLockInfo, params.force, params.forceRequiredForStaleLock);\n if (params.staleRemovals >= MAX_STALE_LOCK_REMOVALS) {\n throw buildLockConflictError(params.id, currentLockInfo.info, Date.now() - params.startedAtMs);\n }\n return {\n lockInfo: currentLockInfo,\n shouldRetryCreate: await unlinkLockWithHook(params.lockPath, \"lock:stale_remove\"),\n staleRemovalCounted: true,\n };\n } finally {\n await releaseCleanupGate();\n }\n}\n\nexport const _testOnly = {\n parseLockInfo,\n readLockInfo,\n isErrno,\n buildLockPayload,\n isStaleLock,\n lockOwnerSuffix,\n resolveLockWaitMs,\n acquireStaleCleanupGate,\n removeConfirmedStaleLock,\n};\n\n\n/**\n * Implements acquire lock for the public runtime surface of this module.\n */\nexport async function acquireLock(\n pmRoot: string,\n id: string,\n ttlSeconds: number,\n owner: string,\n force = false,\n forceRequiredForStaleLock = true,\n waitMs?: number,\n): Promise<() => Promise<void>> {\n const lockOverride = await runActiveServiceOverride(\"lock_acquire\", {\n pm_root: pmRoot,\n id,\n ttl_seconds: ttlSeconds,\n owner,\n force,\n force_required_for_stale_lock: forceRequiredForStaleLock,\n });\n if (lockOverride.handled) {\n const release = resolveLockOverrideRelease(lockOverride.result);\n if (release) {\n return async () => {\n await Promise.resolve(release());\n await runActiveServiceOverride(\"lock_release\", {\n pm_root: pmRoot,\n id,\n owner,\n });\n };\n }\n }\n\n const lockPath = getLockPath(pmRoot, id);\n const waitBudgetMs = resolveLockWaitMs(waitMs);\n const startedAtMs = Date.now();\n let staleRemovals = 0;\n let backoffMs = LOCK_WAIT_INITIAL_DELAY_MS;\n\n for (;;) {\n try {\n await createLockFile(lockPath, id, owner, ttlSeconds);\n return async () => {\n await unlinkLockWithHook(lockPath, \"lock:release\");\n await runActiveServiceOverride(\"lock_release\", {\n pm_root: pmRoot,\n id,\n owner,\n });\n };\n } catch (error: unknown) {\n if (!isErrno(error, \"EEXIST\")) {\n throw new PmCliError(`Failed to acquire lock for ${id}: ${toErrorMessage(error)}`, EXIT_CODE.GENERIC_FAILURE);\n }\n let lockInfo = await readLockInfo(lockPath);\n if (isStaleLock(lockInfo.info, ttlSeconds)) {\n const staleRemoval = await removeConfirmedStaleLock({\n lockPath,\n id,\n ttlSeconds,\n force,\n forceRequiredForStaleLock,\n staleRemovals,\n waitBudgetMs,\n startedAtMs,\n fallbackLockInfo: lockInfo,\n });\n lockInfo = staleRemoval.lockInfo;\n if (staleRemoval.staleRemovalCounted) {\n staleRemovals += 1;\n }\n if (staleRemoval.shouldRetryCreate) {\n continue;\n }\n }\n const elapsedMs = Date.now() - startedAtMs;\n if (waitBudgetMs === 0 || elapsedMs >= waitBudgetMs) {\n throw buildLockConflictError(id, lockInfo.info, waitBudgetMs === 0 ? 0 : elapsedMs);\n }\n await sleepWithJitter(Math.min(backoffMs, waitBudgetMs - elapsedMs));\n backoffMs = Math.min(backoffMs * 2, LOCK_WAIT_MAX_DELAY_MS);\n }\n }\n}\n", "/**\n * @module core/store/front-matter-cache\n *\n * Reads and writes tracker storage with format-aware helpers for Front Matter Cache.\n */\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport { getActiveExtensionRegistrations, hasActiveOnReadHooks, runActiveOnReadHooks } from \"../extensions/index.js\";\nimport { collectRegisteredItemFieldNames } from \"../extensions/item-fields.js\";\nimport { parseItemDocument } from \"../item/item-format.js\";\nimport { evictOldestMemoEntries } from \"../shared/memo.js\";\nimport { writeFileAtomic } from \"../fs/fs-utils.js\";\nimport { ITEM_FILE_EXTENSIONS, getItemFormatFromPath } from \"./paths.js\";\nimport type { ItemDocument, ItemFormat, ItemMetadata, ItemType, RuntimeSchemaSettings } from \"../../types/index.js\";\n\nconst CACHE_VERSION = 6;\nconst CACHE_FILENAME = \"metadata-cache.json\";\nconst BODY_CACHE_FILENAME = \"metadata-cache-bodies.json\";\nconst COLLECTIONS_CACHE_FILENAME = \"metadata-cache-collections.json\";\n\n/**\n * Heavy \"collection\" front-matter fields. These arrays dominate the on-disk cache\n * (e.g. a single item's comment thread can be hundreds of KB) yet the hot list path\n * (`pm list`, stats, deps, activity, calendar, close) never reads them. They are\n * stored in a separate collections cache that is parsed only when a caller opts in\n * (`includeCollections`), keeping the always-loaded light cache an order of magnitude\n * smaller and its JSON.parse correspondingly cheaper.\n */\nexport const HEAVY_METADATA_KEYS = [\n \"comments\",\n \"notes\",\n \"learnings\",\n \"files\",\n \"tests\",\n \"test_runs\",\n \"docs\",\n] as const;\n\nfunction resolveActiveExtensionFieldNames(): readonly string[] {\n return collectRegisteredItemFieldNames(getActiveExtensionRegistrations());\n}\n\ninterface StatSignature {\n mtime_ms: number;\n ctime_ms: number;\n size: number;\n}\n\ninterface CachedEntry extends StatSignature {\n metadata: ItemMetadata;\n body_length: number;\n}\n\ninterface CachedBody extends StatSignature {\n body: string;\n}\n\ninterface CachedCollections extends StatSignature {\n collections: Record<string, unknown>;\n}\n\ninterface CacheEnvelope {\n version: number;\n context_fingerprint: string;\n entries: Record<string, CachedEntry>;\n}\n\ninterface BodyCacheEnvelope {\n version: number;\n context_fingerprint: string;\n bodies: Record<string, CachedBody>;\n}\n\ninterface CollectionsCacheEnvelope {\n version: number;\n context_fingerprint: string;\n collections: Record<string, CachedCollections>;\n}\n\n/**\n * Split parsed front-matter into the light scalar/small fields (everything except the\n * heavy collection arrays) and the heavy collection fields. Only keys that are actually\n * present are moved, so an item without comments stays without comments in both tiers.\n */\nfunction splitHeavyMetadata(metadata: ItemMetadata): {\n light: ItemMetadata;\n heavy: Record<string, unknown>;\n} {\n const light = { ...metadata } as Record<string, unknown>;\n const heavy: Record<string, unknown> = {};\n for (const key of HEAVY_METADATA_KEYS) {\n if (key in light) {\n heavy[key] = light[key];\n delete light[key];\n }\n }\n return { light: light as ItemMetadata, heavy };\n}\n\n/**\n * Recombine light metadata with cached heavy collection fields. Key order differs from\n * the on-disk document, but every downstream hash/serialization canonicalizes and\n * sorts keys (`stableStringify`), so the merged record is byte-identical once hashed.\n */\nfunction mergeHeavyMetadata(light: ItemMetadata, heavy: Record<string, unknown> | undefined): ItemMetadata {\n if (!heavy || Object.keys(heavy).length === 0) {\n return light;\n }\n return { ...light, ...heavy } as ItemMetadata;\n}\n\n/**\n * Documents the cached document candidate payload exchanged by command, SDK, and package integrations.\n */\nexport interface CachedDocumentCandidate {\n metadata: ItemMetadata;\n body?: string;\n item_format: ItemFormat;\n item_path: string;\n}\n\nfunction computeContextFingerprint(\n preferredFormat: ItemFormat | undefined,\n typeToFolder: Record<string, string>,\n schema: RuntimeSchemaSettings | undefined,\n extensionFieldNames: readonly string[],\n): string {\n const hash = createHash(\"sha256\");\n hash.update(`format:${preferredFormat ?? \"default\"}`);\n const sortedTypes = Object.entries(typeToFolder)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([type, folder]) => `${type}=${folder}`)\n .join(\",\");\n hash.update(`|types:${sortedTypes}`);\n if (schema) {\n hash.update(`|schema:${JSON.stringify(schema)}`);\n }\n if (extensionFieldNames.length > 0) {\n hash.update(`|extension_fields:${extensionFieldNames.join(\",\")}`);\n }\n return hash.digest(\"hex\").slice(0, 16);\n}\n\nfunction getCachePath(pmRoot: string): string {\n return path.join(pmRoot, \"runtime\", CACHE_FILENAME);\n}\n\nfunction getBodyCachePath(pmRoot: string): string {\n return path.join(pmRoot, \"runtime\", BODY_CACHE_FILENAME);\n}\n\nfunction getCollectionsCachePath(pmRoot: string): string {\n return path.join(pmRoot, \"runtime\", COLLECTIONS_CACHE_FILENAME);\n}\n\ninterface MemoizedEnvelope {\n signature: StatSignature;\n envelope: CacheEnvelope | BodyCacheEnvelope | CollectionsCacheEnvelope | null;\n}\n\n/**\n * In-process memo of parsed cache envelopes keyed by cache file path and validated\n * against the file's stat signature on every load. Commands that scan the corpus more\n * than once per invocation (`pm next`, `pm context`) and long-lived in-process hosts\n * (the MCP server) would otherwise re-read and re-parse multi-megabyte JSON on every\n * scan. Envelopes handed out from the memo are shared, so they must be treated as\n * read-only — the write path always goes through `mutateItem` on a `structuredClone`d\n * document parsed fresh from the item file, never through listed cache metadata.\n *\n * The cap bounds memory when one long-lived process serves many project roots\n * (3 envelopes per root). Hits re-insert their entry so Map insertion order tracks\n * recency, making the half-eviction drop the least-recently-used roots.\n */\nconst ENVELOPE_MEMO_MAX_ENTRIES = 24;\nconst envelopeMemo = new Map<string, MemoizedEnvelope>();\n\nfunction memoizeEnvelope(cachePath: string, entry: MemoizedEnvelope): void {\n if (envelopeMemo.size >= ENVELOPE_MEMO_MAX_ENTRIES && !envelopeMemo.has(cachePath)) {\n evictOldestMemoEntries(envelopeMemo);\n }\n envelopeMemo.set(cachePath, entry);\n}\n\nasync function loadEnvelopeMemoized<T extends MemoizedEnvelope[\"envelope\"]>(\n cachePath: string,\n parse: (raw: string) => T,\n): Promise<T> {\n let stat;\n try {\n stat = await fs.stat(cachePath);\n } catch {\n envelopeMemo.delete(cachePath);\n return null as T;\n }\n const memoized = envelopeMemo.get(cachePath);\n if (memoized && statMatches(memoized.signature, stat.mtimeMs, stat.ctimeMs, stat.size)) {\n // Re-insert on hit so insertion order tracks recency for the LRU half-eviction.\n envelopeMemo.delete(cachePath);\n envelopeMemo.set(cachePath, memoized);\n return memoized.envelope as T;\n }\n let envelope: T;\n try {\n envelope = parse(await fs.readFile(cachePath, \"utf8\"));\n } catch {\n envelope = null as T;\n }\n memoizeEnvelope(cachePath, {\n signature: { mtime_ms: stat.mtimeMs, ctime_ms: stat.ctimeMs, size: stat.size },\n envelope,\n });\n return envelope;\n}\n\n/**\n * Drop memoized envelopes. Exposed for tests; production invalidation is stat-driven\n * plus the explicit delete in {@link persistCache} after a rewrite.\n */\nexport function clearFrontMatterEnvelopeMemo(): void {\n envelopeMemo.clear();\n}\n\nasync function loadCache(pmRoot: string): Promise<CacheEnvelope | null> {\n return await loadEnvelopeMemoized(getCachePath(pmRoot), (raw) => {\n const parsed = JSON.parse(raw) as CacheEnvelope;\n if (parsed.version !== CACHE_VERSION || typeof parsed.entries !== \"object\" || parsed.entries === null) {\n return null;\n }\n return parsed;\n });\n}\n\nasync function loadBodyCache(pmRoot: string): Promise<BodyCacheEnvelope | null> {\n return await loadEnvelopeMemoized(getBodyCachePath(pmRoot), (raw) => {\n const parsed = JSON.parse(raw) as BodyCacheEnvelope;\n if (parsed.version !== CACHE_VERSION || typeof parsed.bodies !== \"object\" || parsed.bodies === null) {\n return null;\n }\n return parsed;\n });\n}\n\nasync function loadCollectionsCache(pmRoot: string): Promise<CollectionsCacheEnvelope | null> {\n return await loadEnvelopeMemoized(getCollectionsCachePath(pmRoot), (raw) => {\n const parsed = JSON.parse(raw) as CollectionsCacheEnvelope;\n if (parsed.version !== CACHE_VERSION || typeof parsed.collections !== \"object\" || parsed.collections === null) {\n return null;\n }\n return parsed;\n });\n}\n\nasync function persistCache(\n cachePath: string,\n envelope: CacheEnvelope | BodyCacheEnvelope | CollectionsCacheEnvelope,\n): Promise<void> {\n await fs.mkdir(path.dirname(cachePath), { recursive: true });\n await writeFileAtomic(cachePath, JSON.stringify(envelope));\n // Repopulate the memo with the just-written envelope so the next read after a\n // write skips the cold re-read; fall back to plain invalidation when the fresh\n // stat signature cannot be captured.\n try {\n const stat = await fs.stat(cachePath);\n memoizeEnvelope(cachePath, {\n signature: { mtime_ms: stat.mtimeMs, ctime_ms: stat.ctimeMs, size: stat.size },\n envelope,\n });\n } catch {\n envelopeMemo.delete(cachePath);\n }\n}\n\n/**\n * Decide whether a freshly parsed document candidate should replace the one\n * already recorded for the same item id when both an explicit-format file and a\n * fallback-format file exist (e.g. `pm-x.toon` and `pm-x.md`). An explicit\n * `preferredFormat` wins; otherwise `toon` wins over any non-toon format.\n *\n * This is a pure decision so the winner is fully deterministic regardless of the\n * order in which the concurrent per-file reads resolve — the inline call site\n * populates the map as each async read completes, so without a pure rule the\n * branch taken (and thus its coverage) would race. Keep this exported and\n * unit-tested across every format combination.\n */\nexport function shouldReplaceCachedDocumentCandidate(\n existingFormat: ItemFormat,\n candidateFormat: ItemFormat,\n preferredFormat: ItemFormat | undefined,\n): boolean {\n if (preferredFormat) {\n return candidateFormat === preferredFormat && existingFormat !== preferredFormat;\n }\n return candidateFormat === \"toon\" && existingFormat !== \"toon\";\n}\n\nfunction appendWarning(warnings: string[] | undefined, warning: string): void {\n if (warnings && !warnings.includes(warning)) {\n warnings.push(warning);\n }\n}\n\nfunction statMatches(signature: StatSignature, mtimeMs: number, ctimeMs: number, size: number): boolean {\n return signature.mtime_ms === mtimeMs && signature.ctime_ms === ctimeMs && signature.size === size;\n}\n\ninterface DocumentCacheMissState {\n metadata: boolean;\n body: boolean;\n collections: boolean;\n}\n\ninterface DocumentCacheMutableState {\n newEntries: Record<string, CachedEntry>;\n newBodies: Record<string, CachedBody>;\n newCollections: Record<string, CachedCollections>;\n documentsById: Map<string, { candidate: CachedDocumentCandidate; itemFormat: ItemFormat }>;\n misses: DocumentCacheMissState;\n}\n\ninterface DocumentCacheReadContext {\n pmRoot: string;\n preferredFormat: ItemFormat | undefined;\n warnings: string[] | undefined;\n schema: RuntimeSchemaSettings | undefined;\n extensionFieldNames: readonly string[];\n includeBody: boolean;\n includeCollections: boolean;\n dispatchReadHooks: boolean;\n previousEntries: Record<string, CachedEntry>;\n previousBodies: Record<string, CachedBody>;\n previousCollections: Record<string, CachedCollections>;\n state: DocumentCacheMutableState;\n}\n\ninterface CachedDocumentReadParts {\n mtimeMs: number;\n ctimeMs: number;\n size: number;\n itemFormat: ItemFormat;\n lightMetadata: ItemMetadata;\n heavyMetadata: Record<string, unknown> | undefined;\n bodyLength: number;\n body: string | undefined;\n}\n\nasync function readItemDirectoryFiles(\n pmRoot: string,\n folder: string,\n warnings: string[] | undefined,\n): Promise<{ folder: string; dirPath: string; files: string[] }> {\n const dirPath = path.join(pmRoot, folder);\n try {\n const files = await fs.readdir(dirPath);\n return { folder, dirPath, files };\n } catch (error: unknown) {\n if (typeof error === \"object\" && error !== null && \"code\" in error && (error as { code?: string }).code !== \"ENOENT\") {\n appendWarning(warnings, `item_list_directory_read_failed:${folder}`);\n }\n return { folder, dirPath, files: [] };\n }\n}\n\nfunction isItemDocumentFile(file: string): boolean {\n return ITEM_FILE_EXTENSIONS.some((ext) => file.toLowerCase().endsWith(ext));\n}\n\nfunction markDocumentCacheMisses(\n misses: DocumentCacheMissState,\n includeBody: boolean,\n includeCollections: boolean,\n metadataCached: boolean,\n bodyCached: boolean,\n collectionsCached: boolean,\n): void {\n if (!metadataCached) {\n misses.metadata = true;\n }\n if (includeBody && !bodyCached) {\n misses.body = true;\n }\n if (includeCollections && !collectionsCached) {\n misses.collections = true;\n }\n}\n\nasync function dispatchCachedDocumentReadHooks(\n filePath: string,\n warnings: string[] | undefined,\n dispatchReadHooks: boolean,\n): Promise<void> {\n if (!dispatchReadHooks) {\n return;\n }\n for (const warning of await runActiveOnReadHooks({ path: filePath, scope: \"project\" })) {\n appendWarning(warnings, warning);\n }\n}\n\nasync function readCachedDocumentParts(\n filePath: string,\n relativePath: string,\n context: DocumentCacheReadContext,\n): Promise<CachedDocumentReadParts> {\n const stat = await fs.stat(filePath);\n const mtimeMs = stat.mtimeMs;\n const ctimeMs = stat.ctimeMs;\n const { size } = stat;\n const itemFormat = getItemFormatFromPath(filePath) as ItemFormat;\n\n await dispatchCachedDocumentReadHooks(filePath, context.warnings, context.dispatchReadHooks);\n\n const cachedEntry = context.previousEntries[relativePath];\n const metadataCached = cachedEntry !== undefined && statMatches(cachedEntry, mtimeMs, ctimeMs, size);\n const cachedBody = context.previousBodies[relativePath];\n const bodyCached = cachedBody !== undefined && statMatches(cachedBody, mtimeMs, ctimeMs, size);\n const cachedCollections = context.previousCollections[relativePath];\n const collectionsCached = cachedCollections !== undefined && statMatches(cachedCollections, mtimeMs, ctimeMs, size);\n const needRead =\n !metadataCached || (context.includeBody && !bodyCached) || (context.includeCollections && !collectionsCached);\n\n if (!needRead) {\n return {\n mtimeMs,\n ctimeMs,\n size,\n itemFormat,\n lightMetadata: cachedEntry.metadata,\n heavyMetadata: context.includeCollections && cachedCollections ? cachedCollections.collections : undefined,\n bodyLength: cachedEntry.body_length,\n body: context.includeBody ? cachedBody.body : undefined,\n };\n }\n\n const raw = await fs.readFile(filePath, \"utf8\");\n const parsed = parseItemDocument(raw, {\n format: itemFormat,\n schema: context.schema,\n extensionFieldNames: context.extensionFieldNames,\n onWarning: (warning) => appendWarning(context.warnings, warning),\n });\n const split = splitHeavyMetadata(parsed.metadata);\n markDocumentCacheMisses(\n context.state.misses,\n context.includeBody,\n context.includeCollections,\n metadataCached,\n bodyCached,\n collectionsCached,\n );\n return {\n mtimeMs,\n ctimeMs,\n size,\n itemFormat,\n lightMetadata: metadataCached ? cachedEntry.metadata : split.light,\n heavyMetadata: context.includeCollections\n ? collectionsCached\n ? cachedCollections.collections\n : split.heavy\n : undefined,\n bodyLength: metadataCached ? cachedEntry.body_length : parsed.body.length,\n body: context.includeBody ? parsed.body : undefined,\n };\n}\n\nfunction recordCachedDocumentCandidate(\n filePath: string,\n relativePath: string,\n context: DocumentCacheReadContext,\n parts: CachedDocumentReadParts,\n): void {\n context.state.newEntries[relativePath] = {\n mtime_ms: parts.mtimeMs,\n ctime_ms: parts.ctimeMs,\n size: parts.size,\n metadata: parts.lightMetadata,\n body_length: parts.bodyLength,\n };\n if (context.includeBody && parts.body !== undefined) {\n context.state.newBodies[relativePath] = {\n mtime_ms: parts.mtimeMs,\n ctime_ms: parts.ctimeMs,\n size: parts.size,\n body: parts.body,\n };\n }\n if (context.includeCollections && parts.heavyMetadata !== undefined) {\n context.state.newCollections[relativePath] = {\n mtime_ms: parts.mtimeMs,\n ctime_ms: parts.ctimeMs,\n size: parts.size,\n collections: parts.heavyMetadata,\n };\n }\n\n const metadata = context.includeCollections ? mergeHeavyMetadata(parts.lightMetadata, parts.heavyMetadata) : parts.lightMetadata;\n const existing = context.state.documentsById.get(metadata.id);\n const candidate: CachedDocumentCandidate = {\n metadata,\n body: parts.body,\n item_format: parts.itemFormat,\n item_path: filePath,\n };\n if (!existing || shouldReplaceCachedDocumentCandidate(existing.itemFormat, parts.itemFormat, context.preferredFormat)) {\n context.state.documentsById.set(metadata.id, { candidate, itemFormat: parts.itemFormat });\n }\n}\n\nasync function processCachedDocumentFile(\n folder: string,\n filePath: string,\n relativePath: string,\n context: DocumentCacheReadContext,\n): Promise<void> {\n try {\n const parts = await readCachedDocumentParts(filePath, relativePath, context);\n recordCachedDocumentCandidate(filePath, relativePath, context, parts);\n } catch {\n appendWarning(context.warnings, `item_list_item_read_failed:${folder}/${path.basename(filePath)}`);\n }\n}\n\nfunction selectPreviousMetadataEntries(\n existingCache: CacheEnvelope | null,\n contextFingerprint: string,\n): Record<string, CachedEntry> {\n return existingCache && existingCache.context_fingerprint === contextFingerprint ? existingCache.entries : {};\n}\n\nfunction selectPreviousBodyEntries(\n existingBodyCache: BodyCacheEnvelope | null,\n contextFingerprint: string,\n): Record<string, CachedBody> {\n return existingBodyCache && existingBodyCache.context_fingerprint === contextFingerprint ? existingBodyCache.bodies : {};\n}\n\nfunction selectPreviousCollectionEntries(\n existingCollectionsCache: CollectionsCacheEnvelope | null,\n contextFingerprint: string,\n): Record<string, CachedCollections> {\n return existingCollectionsCache && existingCollectionsCache.context_fingerprint === contextFingerprint\n ? existingCollectionsCache.collections\n : {};\n}\n\nfunction createDocumentCacheMutableState(): DocumentCacheMutableState {\n return {\n newEntries: {},\n newBodies: {},\n newCollections: {},\n documentsById: new Map<string, { candidate: CachedDocumentCandidate; itemFormat: ItemFormat }>(),\n misses: {\n metadata: false,\n body: false,\n collections: false,\n },\n };\n}\n\nfunction collectCachedDocumentParseTasks(\n dirResults: Array<{ folder: string; dirPath: string; files: string[] }>,\n context: DocumentCacheReadContext,\n): Array<Promise<void>> {\n const parseTasks: Array<Promise<void>> = [];\n for (const { folder, dirPath, files } of dirResults) {\n for (const file of files) {\n if (!isItemDocumentFile(file)) {\n continue;\n }\n const filePath = path.join(dirPath, file);\n const relativePath = path.relative(context.pmRoot, filePath);\n parseTasks.push(processCachedDocumentFile(folder, filePath, relativePath, context));\n }\n }\n return parseTasks;\n}\n\nasync function persistMetadataCacheIfNeeded(params: {\n pmRoot: string;\n contextFingerprint: string;\n existingCache: CacheEnvelope | null;\n previousEntries: Record<string, CachedEntry>;\n state: DocumentCacheMutableState;\n}): Promise<void> {\n const metadataDirty = params.state.misses.metadata ||\n Object.keys(params.previousEntries).length !== Object.keys(params.state.newEntries).length;\n if (!metadataDirty && params.existingCache !== null && params.existingCache.context_fingerprint === params.contextFingerprint) {\n return;\n }\n await persistCache(getCachePath(params.pmRoot), {\n version: CACHE_VERSION,\n context_fingerprint: params.contextFingerprint,\n entries: params.state.newEntries,\n }).catch(() => {});\n}\n\nasync function persistBodyCacheIfNeeded(params: {\n pmRoot: string;\n contextFingerprint: string;\n existingBodyCache: BodyCacheEnvelope | null;\n previousBodies: Record<string, CachedBody>;\n state: DocumentCacheMutableState;\n}): Promise<void> {\n const bodyDirty = params.state.misses.body ||\n Object.keys(params.previousBodies).length !== Object.keys(params.state.newBodies).length;\n if (\n !bodyDirty &&\n params.existingBodyCache !== null &&\n params.existingBodyCache.context_fingerprint === params.contextFingerprint\n ) {\n return;\n }\n await persistCache(getBodyCachePath(params.pmRoot), {\n version: CACHE_VERSION,\n context_fingerprint: params.contextFingerprint,\n bodies: params.state.newBodies,\n }).catch(() => {});\n}\n\nasync function persistCollectionsCacheIfNeeded(params: {\n pmRoot: string;\n contextFingerprint: string;\n existingCollectionsCache: CollectionsCacheEnvelope | null;\n previousCollections: Record<string, CachedCollections>;\n state: DocumentCacheMutableState;\n}): Promise<void> {\n const collectionsDirty = params.state.misses.collections ||\n Object.keys(params.previousCollections).length !== Object.keys(params.state.newCollections).length;\n if (\n !collectionsDirty &&\n params.existingCollectionsCache !== null &&\n params.existingCollectionsCache.context_fingerprint === params.contextFingerprint\n ) {\n return;\n }\n await persistCache(getCollectionsCachePath(params.pmRoot), {\n version: CACHE_VERSION,\n context_fingerprint: params.contextFingerprint,\n collections: params.state.newCollections,\n }).catch(() => {});\n}\n\nfunction sortedCachedDocumentCandidates(state: DocumentCacheMutableState): CachedDocumentCandidate[] {\n return [...state.documentsById.values()]\n .sort((left, right) => left.candidate.metadata.id.localeCompare(right.candidate.metadata.id))\n .map((entry) => entry.candidate);\n}\n\n/**\n * Documents the list cache options payload exchanged by command, SDK, and package integrations.\n */\nexport interface ListCacheOptions {\n /**\n * When false, item bodies are neither loaded from nor written to the separate\n * body cache. Metadata-only callers (`pm list`, stats, deps, activity, …) skip\n * the large body cache entirely; only body consumers (search/reindex) pay for it.\n */\n includeBody?: boolean;\n /**\n * When false, heavy collection fields (comments/notes/learnings/files/tests/\n * test_runs/docs) are neither loaded from nor written to the separate collections\n * cache, and are absent from the returned metadata. Light-only callers (`pm list`\n * compact, stats, deps, activity, calendar, close) skip the large collections cache\n * entirely. Defaults to true so any caller that does read those fields stays correct.\n */\n includeCollections?: boolean;\n}\n\n/**\n * List all item documents using a persistent on-disk metadata cache.\n *\n * Metadata and bodies are stored in two separate cache files so the hot path\n * (`pm list` and friends, which discard bodies) never loads or rewrites the much\n * larger body payload. Each file is rewritten only when its contents actually\n * change, and per-file onRead hooks are dispatched only when an extension\n * registers one. Only files whose mtime/ctime/size changed since the last run are\n * re-parsed.\n */\nexport async function listAllDocumentCandidatesCached(\n pmRoot: string,\n preferredFormat: ItemFormat | undefined,\n typeToFolder: Record<string, string>,\n warnings: string[] | undefined,\n schema: RuntimeSchemaSettings | undefined,\n options: ListCacheOptions = {},\n): Promise<CachedDocumentCandidate[]> {\n const includeBody = options.includeBody !== false;\n const includeCollections = options.includeCollections !== false;\n const extensionFieldNames = resolveActiveExtensionFieldNames();\n const contextFingerprint = computeContextFingerprint(preferredFormat, typeToFolder, schema, extensionFieldNames);\n\n const existingCache = await loadCache(pmRoot);\n const previousEntries = selectPreviousMetadataEntries(existingCache, contextFingerprint);\n\n const existingBodyCache = includeBody ? await loadBodyCache(pmRoot) : null;\n const previousBodies = selectPreviousBodyEntries(existingBodyCache, contextFingerprint);\n\n const existingCollectionsCache = includeCollections ? await loadCollectionsCache(pmRoot) : null;\n const previousCollections = selectPreviousCollectionEntries(existingCollectionsCache, contextFingerprint);\n\n const entries = Object.entries(typeToFolder) as Array<[ItemType, string]>;\n const dirResults = await Promise.all(entries.map(([, folder]) => readItemDirectoryFiles(pmRoot, folder, warnings)));\n\n const dispatchReadHooks = hasActiveOnReadHooks();\n const state = createDocumentCacheMutableState();\n const context: DocumentCacheReadContext = {\n pmRoot,\n preferredFormat,\n warnings,\n schema,\n extensionFieldNames,\n includeBody,\n includeCollections,\n dispatchReadHooks,\n previousEntries,\n previousBodies,\n previousCollections,\n state,\n };\n\n await Promise.all(collectCachedDocumentParseTasks(dirResults, context));\n\n // Rewrite a cache file only when its contents changed: any re-parsed (missing or\n // stale) entry, or a different set of keys (additions/deletions).\n await persistMetadataCacheIfNeeded({ pmRoot, contextFingerprint, existingCache, previousEntries, state });\n\n if (includeBody) {\n await persistBodyCacheIfNeeded({ pmRoot, contextFingerprint, existingBodyCache, previousBodies, state });\n }\n\n if (includeCollections) {\n await persistCollectionsCacheIfNeeded({ pmRoot, contextFingerprint, existingCollectionsCache, previousCollections, state });\n }\n\n return sortedCachedDocumentCandidates(state);\n}\n\n/**\n * Implements list all documents cached for the public runtime surface of this module.\n */\nexport async function listAllDocumentsCached(\n pmRoot: string,\n preferredFormat: ItemFormat | undefined,\n typeToFolder: Record<string, string>,\n warnings: string[] | undefined,\n schema: RuntimeSchemaSettings | undefined,\n): Promise<ItemDocument[]> {\n const candidates = await listAllDocumentCandidatesCached(pmRoot, preferredFormat, typeToFolder, warnings, schema, {\n includeBody: false,\n });\n return candidates.map((candidate) => ({\n metadata: candidate.metadata,\n body: candidate.body ?? \"\",\n }));\n}\n\n/**\n * Light variant of {@link listAllDocumentsCached}: returns metadata WITHOUT the heavy\n * collection fields (comments/notes/learnings/files/tests/test_runs/docs), skipping the\n * large collections cache entirely. Only safe for callers that read just the light\n * scalar/small fields (id/title/status/type/priority/parent/tags/dates/dependencies/…).\n */\nexport async function listAllDocumentsCachedLight(\n pmRoot: string,\n preferredFormat: ItemFormat | undefined,\n typeToFolder: Record<string, string>,\n warnings: string[] | undefined,\n schema: RuntimeSchemaSettings | undefined,\n): Promise<ItemDocument[]> {\n const candidates = await listAllDocumentCandidatesCached(pmRoot, preferredFormat, typeToFolder, warnings, schema, {\n includeBody: false,\n includeCollections: false,\n });\n return candidates.map((candidate) => ({\n metadata: candidate.metadata,\n body: candidate.body ?? \"\",\n }));\n}\n", "/**\n * @module core/store/item-store\n *\n * Reads and writes tracker storage with format-aware helpers for Item Store.\n */\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n getActiveExtensionRegistrations,\n projectAfterCommandItemSnapshot,\n recordAfterCommandAffectedItem,\n runActiveOnReadHooks,\n runActiveOnWriteHooks,\n runActiveServiceOverride,\n} from \"../extensions/index.js\";\nimport { collectRegisteredItemFieldNames } from \"../extensions/item-fields.js\";\nimport { EMPTY_CANONICAL_DOCUMENT, EXIT_CODE, TYPE_TO_FOLDER } from \"../shared/constants.js\";\nimport { PmCliError } from \"../shared/errors.js\";\nimport { levenshteinDistanceWithinLimit } from \"../shared/levenshtein.js\";\nimport { appendHistoryEntry, createHistoryEntry } from \"../history/history.js\";\nimport { enforceHistoryStreamPolicyForItem } from \"../history/history-stream-policy.js\";\nimport { canonicalDocument, parseItemDocument, serializeItemDocument } from \"../item/item-format.js\";\nimport { resolveItemTypeRegistry } from \"../item/type-registry.js\";\nimport { acquireLock } from \"../lock/lock.js\";\nimport { writeFileAtomic } from \"../fs/fs-utils.js\";\nimport { normalizeItemId, normalizeRawItemId } from \"../item/id.js\";\nimport { listAllDocumentCandidatesCached, listAllDocumentsCached, listAllDocumentsCachedLight } from \"./front-matter-cache.js\";\nimport { getHistoryPath, getItemFormatFromPath, getItemPath, ITEM_FILE_EXTENSIONS } from \"./paths.js\";\nimport { resolveGovernanceKnobs } from \"./settings.js\";\nimport { nowIso } from \"../shared/time.js\";\nimport type { ItemDocument, ItemFormat, ItemFrontMatter, ItemType, PmSettings, RuntimeSchemaSettings } from \"../../types/index.js\";\n\n/**\n * Documents the located item payload exchanged by command, SDK, and package integrations.\n */\nexport interface LocatedItem {\n id: string;\n type: ItemType;\n itemPath: string;\n item_format: ItemFormat;\n}\n\nasync function fileExists(targetPath: string): Promise<boolean> {\n try {\n await fs.access(targetPath);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction isErrno(error: unknown, code: string): boolean {\n return typeof error === \"object\" && error !== null && \"code\" in error && (error as { code?: string }).code === code;\n}\n\nfunction appendWarning(warnings: string[] | undefined, warning: string): void {\n if (!warnings) {\n return;\n }\n if (!warnings.includes(warning)) {\n warnings.push(warning);\n }\n}\n\nfunction resolveActiveExtensionFieldNames(explicit: readonly string[] | undefined): readonly string[] {\n return explicit ?? collectRegisteredItemFieldNames(getActiveExtensionRegistrations());\n}\n\nfunction resolveItemFormatSearchOrder(preferredFormat?: ItemFormat): ItemFormat[] {\n if (preferredFormat === \"toon\") {\n return [\"toon\", \"json_markdown\"];\n }\n if (preferredFormat === \"json_markdown\") {\n return [\"json_markdown\", \"toon\"];\n }\n return [\"toon\", \"json_markdown\"];\n}\n\n/**\n * Implements locate item for the public runtime surface of this module.\n */\nexport async function locateItem(\n pmRoot: string,\n rawId: string,\n idPrefix = \"pm-\",\n preferredFormat?: ItemFormat,\n typeToFolder: Record<string, string> = TYPE_TO_FOLDER,\n): Promise<LocatedItem | null> {\n const normalizedId = normalizeItemId(rawId, idPrefix);\n const rawNormalizedId = normalizeRawItemId(rawId);\n const candidateIds = normalizedId === rawNormalizedId ? [normalizedId] : [normalizedId, rawNormalizedId];\n const entries = Object.entries(typeToFolder) as Array<[ItemType, string]>;\n const searchOrder = resolveItemFormatSearchOrder(preferredFormat);\n for (const candidateId of candidateIds) {\n for (const [type] of entries) {\n for (const itemFormat of searchOrder) {\n const itemPath = getItemPath(pmRoot, type, candidateId, itemFormat, typeToFolder);\n if (await fileExists(itemPath)) {\n return {\n id: candidateId,\n type,\n itemPath,\n item_format: itemFormat,\n };\n }\n }\n }\n }\n return null;\n}\n\n/**\n * Implements read located item for the public runtime surface of this module.\n */\nexport async function readLocatedItem(\n item: LocatedItem,\n options: { schema?: RuntimeSchemaSettings; extensionFieldNames?: readonly string[]; warnings?: string[] } = {},\n): Promise<{ raw: string; document: ItemDocument }> {\n const raw = await fs.readFile(item.itemPath, \"utf8\");\n await runActiveOnReadHooks({\n path: item.itemPath,\n scope: \"project\",\n });\n const document = parseItemDocument(raw, {\n format: item.item_format,\n schema: options.schema,\n extensionFieldNames: resolveActiveExtensionFieldNames(options.extensionFieldNames),\n onWarning: (warning) => appendWarning(options.warnings, warning),\n });\n return { raw, document };\n}\n\n/**\n * Implements list all front matter for the public runtime surface of this module.\n */\nexport async function listAllFrontMatter(\n pmRoot: string,\n preferredFormat?: ItemFormat,\n typeToFolder: Record<string, string> = TYPE_TO_FOLDER,\n warnings?: string[],\n schema?: RuntimeSchemaSettings,\n): Promise<ItemFrontMatter[]> {\n const documents = await listAllDocumentsCached(pmRoot, preferredFormat, typeToFolder, warnings, schema);\n return documents.map((document) => document.metadata);\n}\n\n/**\n * Light variant of {@link listAllFrontMatter}: returns front-matter WITHOUT the heavy\n * collection fields (comments/notes/learnings/files/tests/test_runs/docs). Skips the\n * large collections cache so the hot list path stays cheap. Only use for callers that\n * read just the light scalar/small fields — see {@link listAllDocumentsCachedLight}.\n */\nexport async function listAllFrontMatterLight(\n pmRoot: string,\n preferredFormat?: ItemFormat,\n typeToFolder: Record<string, string> = TYPE_TO_FOLDER,\n warnings?: string[],\n schema?: RuntimeSchemaSettings,\n): Promise<ItemFrontMatter[]> {\n const documents = await listAllDocumentsCachedLight(pmRoot, preferredFormat, typeToFolder, warnings, schema);\n return documents.map((document) => document.metadata);\n}\n\n/**\n * Implements list all front matter with body for the public runtime surface of this module.\n */\nexport async function listAllFrontMatterWithBody(\n pmRoot: string,\n preferredFormat?: ItemFormat,\n typeToFolder: Record<string, string> = TYPE_TO_FOLDER,\n warnings?: string[],\n schema?: RuntimeSchemaSettings,\n): Promise<Array<ItemFrontMatter & { body: string }>> {\n const candidates = await listAllDocumentCandidatesCached(\n pmRoot,\n preferredFormat,\n typeToFolder,\n warnings,\n schema,\n { includeBody: true },\n );\n return candidates.map((candidate) => ({\n ...candidate.metadata,\n // includeBody:true guarantees candidate bodies are materialized.\n body: candidate.body!,\n }));\n}\n\nasync function listKnownItemIds(\n pmRoot: string,\n typeToFolder: Record<string, string>,\n): Promise<string[]> {\n const folders = new Set(Object.values(typeToFolder));\n const allIds: string[] = [];\n await Promise.all(\n [...folders].map(async (folder) => {\n try {\n const entries = await fs.readdir(path.join(pmRoot, folder));\n for (const entry of entries) {\n for (const ext of ITEM_FILE_EXTENSIONS) {\n if (entry.toLowerCase().endsWith(ext)) {\n allIds.push(entry.slice(0, -ext.length));\n break;\n }\n }\n }\n } catch {\n // ignore missing folders\n }\n }),\n );\n return allIds;\n}\n\nasync function buildDidYouMeanSuggestions(\n pmRoot: string,\n badId: string,\n idPrefix: string,\n typeToFolder: Record<string, string>,\n): Promise<string[]> {\n const normalized = normalizeItemId(badId, idPrefix);\n const ids = await listKnownItemIds(pmRoot, typeToFolder);\n if (ids.length === 0) return [];\n const limit = Math.max(3, Math.floor(normalized.length / 2));\n const scored = ids\n .map((id) => ({ id, distance: levenshteinDistanceWithinLimit(id, normalized, limit) }))\n .filter((entry): entry is { id: string; distance: number } => entry.distance !== null)\n .sort((left, right) => left.distance - right.distance)\n .slice(0, 3)\n .map((entry) => entry.id);\n return scored;\n}\n\n/**\n * Implements build item not found error for the public runtime surface of this module.\n */\nexport async function buildItemNotFoundError(\n pmRoot: string,\n badId: string,\n idPrefix: string,\n typeToFolder: Record<string, string>,\n): Promise<PmCliError> {\n const suggestions = await buildDidYouMeanSuggestions(pmRoot, badId, idPrefix, typeToFolder);\n const nextSteps: string[] = [\"Confirm the active --path/PM_PATH scope, then retry with a valid id.\"];\n if (suggestions.length > 0) {\n nextSteps.unshift(`Did you mean one of: ${suggestions.join(\", \")}?`);\n }\n return new PmCliError(`Item ${badId} not found`, EXIT_CODE.NOT_FOUND, { nextSteps });\n}\n\nfunction bypassesAssigneeConflict(\n op: string,\n bypassAssigneeConflict?: boolean,\n): boolean {\n return (\n op === \"claim\" ||\n (bypassAssigneeConflict === true &&\n (op === \"comment_add\" ||\n op === \"comment_edit\" ||\n op === \"comment_delete\" ||\n op === \"note_add\" ||\n op === \"learning_add\" ||\n op === \"release\" ||\n op === \"update\" ||\n op === \"update_audit\"))\n );\n}\n\nasync function prepareLockedItem(params: {\n pmRoot: string;\n settings: PmSettings;\n id: string;\n op: string;\n author: string;\n force?: boolean;\n bypassAssigneeConflict?: boolean;\n extensionFieldNames?: readonly string[];\n typeToFolder?: Record<string, string>;\n}): Promise<{\n typeToFolder: Record<string, string>;\n located: LocatedItem;\n originalRaw: string;\n document: ItemDocument;\n warnings: string[];\n releaseLock: () => Promise<void>;\n}> {\n const typeToFolder =\n params.typeToFolder ??\n resolveItemTypeRegistry(params.settings, getActiveExtensionRegistrations())\n .type_to_folder;\n const located = await locateItem(\n params.pmRoot,\n params.id,\n params.settings.id_prefix,\n params.settings.item_format,\n typeToFolder,\n );\n if (!located) {\n throw await buildItemNotFoundError(\n params.pmRoot,\n params.id,\n params.settings.id_prefix,\n typeToFolder,\n );\n }\n\n const releaseLock = await acquireLock(\n params.pmRoot,\n located.id,\n params.settings.locks.ttl_seconds,\n params.author,\n Boolean(params.force),\n params.settings.governance.force_required_for_stale_lock,\n params.settings.locks.wait_ms,\n );\n\n try {\n const warnings: string[] = [];\n const { raw: originalRaw, document } = await readLocatedItem(located, {\n schema: params.settings.schema,\n extensionFieldNames: params.extensionFieldNames,\n warnings,\n });\n\n const assigned = document.metadata.assignee?.trim();\n const governance = resolveGovernanceKnobs(params.settings);\n const hasOwnershipConflict =\n assigned &&\n assigned !== params.author &&\n !params.force &&\n !bypassesAssigneeConflict(params.op, params.bypassAssigneeConflict);\n if (hasOwnershipConflict) {\n if (governance.ownership_enforcement === \"strict\") {\n throw new PmCliError(\n `Item ${located.id} is assigned to ${assigned}. Use --force to override.`,\n EXIT_CODE.CONFLICT,\n );\n }\n if (governance.ownership_enforcement === \"warn\") {\n warnings.push(\n `ownership_warning:assignee_conflict:${located.id}:${assigned}`,\n );\n }\n }\n\n return {\n typeToFolder,\n located,\n originalRaw,\n document,\n warnings,\n releaseLock,\n };\n } catch (error: unknown) {\n await releaseLock();\n throw error;\n }\n}\n\nfunction resolveItemStoreWriteOverride(\n serviceWriteOverride: { handled: boolean; result?: unknown },\n targetItemPath: string,\n serializedAfter: string,\n): {\n effectiveTargetItemPath: string;\n effectiveSerializedAfter: string;\n skipItemWrite: boolean;\n} {\n if (!serviceWriteOverride.handled || typeof serviceWriteOverride.result !== \"object\" || serviceWriteOverride.result === null) {\n return { effectiveTargetItemPath: targetItemPath, effectiveSerializedAfter: serializedAfter, skipItemWrite: false };\n }\n const overrideRecord = serviceWriteOverride.result as {\n target_item_path?: unknown;\n contents?: unknown;\n skip_write?: unknown;\n };\n return {\n effectiveTargetItemPath:\n typeof overrideRecord.target_item_path === \"string\" && overrideRecord.target_item_path.trim().length > 0\n ? overrideRecord.target_item_path\n : targetItemPath,\n effectiveSerializedAfter: typeof overrideRecord.contents === \"string\" ? overrideRecord.contents : serializedAfter,\n skipItemWrite: overrideRecord.skip_write === true,\n };\n}\n\nasync function rollbackMutatedItemWrite(params: {\n skipItemWrite: boolean;\n effectiveTargetItemPath: string;\n originalItemPath: string;\n originalRaw: string;\n}): Promise<void> {\n if (params.skipItemWrite) {\n return;\n }\n if (params.effectiveTargetItemPath !== params.originalItemPath) {\n await writeFileAtomic(params.originalItemPath, params.originalRaw);\n await fs.rm(params.effectiveTargetItemPath, { force: true });\n return;\n }\n await writeFileAtomic(params.originalItemPath, params.originalRaw);\n}\n\n/**\n * Implements mutate item for the public runtime surface of this module.\n */\nexport async function mutateItem(params: {\n pmRoot: string;\n settings: PmSettings;\n id: string;\n op: string;\n author: string;\n message?: string;\n force?: boolean;\n bypassAssigneeConflict?: boolean;\n skipNoop?: boolean;\n extensionFieldNames?: readonly string[];\n typeToFolder?: Record<string, string>;\n mutate: (document: ItemDocument) => {\n changedFields: string[];\n warnings?: string[];\n };\n}): Promise<{\n item: ItemFrontMatter;\n body: string;\n changedFields: string[];\n warnings: string[];\n}> {\n const prepared = await prepareLockedItem({\n pmRoot: params.pmRoot,\n settings: params.settings,\n id: params.id,\n op: params.op,\n author: params.author,\n force: params.force,\n bypassAssigneeConflict: params.bypassAssigneeConflict,\n extensionFieldNames: params.extensionFieldNames,\n typeToFolder: params.typeToFolder,\n });\n const {\n typeToFolder,\n located,\n originalRaw,\n document,\n warnings: parseWarnings,\n releaseLock,\n } = prepared;\n\n try {\n const beforeDocument = canonicalDocument(document, {\n schema: params.settings.schema,\n extensionFieldNames: params.extensionFieldNames,\n });\n const mutableDocument = canonicalDocument(structuredClone(document), {\n schema: params.settings.schema,\n extensionFieldNames: params.extensionFieldNames,\n });\n const mutation = params.mutate(mutableDocument);\n if (params.skipNoop === true && mutation.changedFields.length === 0) {\n return {\n item: beforeDocument.metadata,\n body: beforeDocument.body,\n changedFields: [],\n warnings: [...parseWarnings, ...(mutation.warnings ?? [])],\n };\n }\n const historyPolicy = await enforceHistoryStreamPolicyForItem({\n pmRoot: params.pmRoot,\n settings: params.settings,\n itemId: located.id,\n commandLabel: params.op,\n });\n mutableDocument.metadata.updated_at = nowIso();\n const afterDocument = canonicalDocument(mutableDocument, {\n schema: params.settings.schema,\n extensionFieldNames: params.extensionFieldNames,\n });\n const targetItemFormat: ItemFormat = \"toon\";\n const serializedAfter = serializeItemDocument(afterDocument, {\n format: targetItemFormat,\n schema: params.settings.schema,\n extensionFieldNames: params.extensionFieldNames,\n });\n const targetItemPath = getItemPath(\n params.pmRoot,\n afterDocument.metadata.type,\n located.id,\n targetItemFormat,\n typeToFolder,\n );\n const historyPath = getHistoryPath(params.pmRoot, located.id);\n const serviceWriteOverride = await runActiveServiceOverride(\"item_store_write\", {\n op: params.op,\n pm_root: params.pmRoot,\n item_id: located.id,\n source_item_path: located.itemPath,\n target_item_path: targetItemPath,\n history_path: historyPath,\n item_format: targetItemFormat,\n before: beforeDocument,\n after: afterDocument,\n contents: serializedAfter,\n });\n const { effectiveTargetItemPath, effectiveSerializedAfter, skipItemWrite } = resolveItemStoreWriteOverride(\n serviceWriteOverride,\n targetItemPath,\n serializedAfter,\n );\n\n if (!skipItemWrite) {\n await writeFileAtomic(effectiveTargetItemPath, effectiveSerializedAfter);\n }\n if (!skipItemWrite && effectiveTargetItemPath !== located.itemPath) {\n await fs.rm(located.itemPath);\n }\n const entry = createHistoryEntry({\n nowIso: afterDocument.metadata.updated_at,\n author: params.author,\n op: params.op,\n before: beforeDocument,\n after: afterDocument,\n message: params.message,\n });\n\n try {\n await appendHistoryEntry(historyPath, entry);\n } catch (error: unknown) {\n await rollbackMutatedItemWrite({\n skipItemWrite,\n effectiveTargetItemPath,\n originalItemPath: located.itemPath,\n originalRaw,\n });\n throw error;\n }\n const hookWarnings = [\n ...(await runActiveOnWriteHooks({\n path: effectiveTargetItemPath,\n scope: \"project\",\n op: params.op,\n item_id: afterDocument.metadata.id,\n item_type: afterDocument.metadata.type,\n before: beforeDocument,\n after: afterDocument,\n changed_fields: mutation.changedFields,\n })),\n ...(await runActiveOnWriteHooks({\n path: historyPath,\n scope: \"project\",\n op: `${params.op}:history`,\n item_id: afterDocument.metadata.id,\n item_type: afterDocument.metadata.type,\n before: beforeDocument,\n after: afterDocument,\n changed_fields: mutation.changedFields,\n })),\n ];\n\n recordAfterCommandAffectedItem({\n id: afterDocument.metadata.id,\n op: params.op,\n item_type: afterDocument.metadata.type,\n previous_status: beforeDocument.metadata.status,\n status: afterDocument.metadata.status,\n previous: projectAfterCommandItemSnapshot(beforeDocument.metadata, mutation.changedFields),\n current: projectAfterCommandItemSnapshot(afterDocument.metadata, mutation.changedFields),\n changed_fields: mutation.changedFields,\n });\n\n return {\n item: afterDocument.metadata,\n body: afterDocument.body,\n changedFields: mutation.changedFields,\n warnings: [\n ...parseWarnings,\n ...(mutation.warnings ?? []),\n ...historyPolicy.warnings,\n ...serviceWriteOverride.warnings,\n ...hookWarnings,\n ],\n };\n } finally {\n await releaseLock();\n }\n}\n\nexport const itemStoreTestOnly = {\n appendWarning,\n bypassesAssigneeConflict,\n buildDidYouMeanSuggestions,\n isErrno,\n};\n\n/**\n * Implements delete item for the public runtime surface of this module.\n */\nexport async function deleteItem(params: {\n pmRoot: string;\n settings: PmSettings;\n id: string;\n author: string;\n message?: string;\n force?: boolean;\n dryRun?: boolean;\n}): Promise<{ item: ItemFrontMatter; changedFields: string[]; warnings: string[]; targetPath?: string }> {\n const prepared = await prepareLockedItem({\n pmRoot: params.pmRoot,\n settings: params.settings,\n id: params.id,\n op: \"delete\",\n author: params.author,\n force: params.force,\n });\n const { located, originalRaw, document, warnings: parseWarnings, releaseLock } = prepared;\n\n try {\n const historyPolicy = await enforceHistoryStreamPolicyForItem({\n pmRoot: params.pmRoot,\n settings: params.settings,\n itemId: located.id,\n commandLabel: \"delete\",\n });\n\n const beforeDocument = canonicalDocument(document, { schema: params.settings.schema });\n const deletionTimestamp = nowIso();\n const tombstoneDocument = EMPTY_CANONICAL_DOCUMENT as unknown as ItemDocument;\n const historyEntry = createHistoryEntry({\n nowIso: deletionTimestamp,\n author: params.author,\n op: \"delete\",\n before: beforeDocument,\n after: tombstoneDocument,\n message: params.message,\n });\n const historyPath = getHistoryPath(params.pmRoot, located.id);\n const serviceDeleteOverride = await runActiveServiceOverride(\"item_store_delete\", {\n op: \"delete\",\n pm_root: params.pmRoot,\n item_id: located.id,\n item_path: located.itemPath,\n history_path: historyPath,\n before: beforeDocument,\n });\n let effectiveItemPath = located.itemPath;\n let skipDelete = false;\n if (\n serviceDeleteOverride.handled &&\n typeof serviceDeleteOverride.result === \"object\" &&\n serviceDeleteOverride.result !== null\n ) {\n const overrideRecord = serviceDeleteOverride.result as {\n item_path?: unknown;\n skip_delete?: unknown;\n };\n if (typeof overrideRecord.item_path === \"string\" && overrideRecord.item_path.trim().length > 0) {\n effectiveItemPath = overrideRecord.item_path;\n }\n if (overrideRecord.skip_delete === true) {\n skipDelete = true;\n }\n }\n\n if (params.dryRun === true) {\n return {\n item: beforeDocument.metadata,\n changedFields: [\"deleted\"],\n targetPath: effectiveItemPath,\n warnings: [...parseWarnings, ...historyPolicy.warnings, ...serviceDeleteOverride.warnings],\n };\n }\n\n if (!skipDelete) {\n await fs.rm(effectiveItemPath);\n }\n try {\n await appendHistoryEntry(historyPath, historyEntry);\n } catch (error: unknown) {\n if (!skipDelete) {\n await writeFileAtomic(effectiveItemPath, originalRaw);\n }\n throw error;\n }\n\n const hookWarnings = [\n ...(await runActiveOnWriteHooks({\n path: effectiveItemPath,\n scope: \"project\",\n op: \"delete\",\n item_id: beforeDocument.metadata.id,\n item_type: beforeDocument.metadata.type,\n before: beforeDocument,\n after: tombstoneDocument,\n changed_fields: [\"deleted\"],\n })),\n ...(await runActiveOnWriteHooks({\n path: historyPath,\n scope: \"project\",\n op: \"delete:history\",\n item_id: beforeDocument.metadata.id,\n item_type: beforeDocument.metadata.type,\n before: beforeDocument,\n after: tombstoneDocument,\n changed_fields: [\"deleted\"],\n })),\n ];\n\n recordAfterCommandAffectedItem({\n id: beforeDocument.metadata.id,\n op: \"delete\",\n item_type: beforeDocument.metadata.type,\n previous_status: beforeDocument.metadata.status,\n previous: projectAfterCommandItemSnapshot(beforeDocument.metadata, Object.keys(beforeDocument.metadata)),\n changed_fields: [\"deleted\"],\n });\n\n return {\n item: beforeDocument.metadata,\n changedFields: [\"deleted\"],\n warnings: [...parseWarnings, ...historyPolicy.warnings, ...serviceDeleteOverride.warnings, ...hookWarnings],\n };\n } finally {\n await releaseLock();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAM,4BAA4B,IAAI,IAAI,sBAAsB;AAEhE,SAAS,mBAAmB,OAAc;AACxC,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;EACT;AACA,QAAM,aAAa,MAAM,KAAI;AAC7B,SAAO,WAAW,SAAS,IAAI,aAAa;AAC9C;AAEA,SAAS,mBAAmB,OAAc;AACxC,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;EACT;AACA,SAAO,uBAAuB,KAAK;AACrC;AAEA,SAAS,gBAAmB,OAAQ;AAClC,MAAI;AACF,WAAO,gBAAgB,KAAK;EAC9B,QAAQ;AACN,WAAO;EACT;AACF;AAEA,SAAS,qBAAqB,KAAW;AACvC,QAAM,UAAU,IAAI,KAAI;AACxB,QAAM,iBAAiB,QAAQ,QAAQ,GAAG;AAC1C,MAAI,kBAAkB,GAAG;AACvB,UAAM,IAAI,WAAW,yDAAyD,GAAG,IAAI,UAAU,KAAK;EACtG;AAGA,QAAM,MAAM,QAAQ,MAAM,GAAG,cAAc,EAAE,KAAI;AACjD,QAAM,QAAQ,QAAQ,MAAM,iBAAiB,CAAC;AAC9C,SA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;AACA,QAAI;AACF,YAAM,mBAAmB,aAAa,YAAY;IACpD,SAAS,OAAgB;AACvB,UAAI,CAAC,YAAY;AACf,cAAM,gBAAgB,mBAAmB,WAAW;MACtD;AACA,YAAM;IACR;AAEA,UAAM,eAAe;MACnB,GAAI,MAAM,sBAAsB;QAC9B,MAAM;QACN,OAAO;QACP,IAAI;QACJ,SAAS,eAAe,SAAS;QACjC,WAAW,eAAe,SAAS;QACnC,QAAQ;QACR,OAAO;QACP,gBAAgB,CAAC,SAAS;OAC3B;MACD,GAAI,MAAM,sBAAsB;QAC9B,MAAM;QACN,OAAO;QACP,IAAI;QACJ,SAAS,eAAe,SAAS;QACjC,WAAW,eAAe,SAAS;QACnC,QAAQ;QACR,OAAO;QACP,gBAAgB,CAAC,SAAS;OAC3B;;AAGH,mCAA+B;MAC7B,IAAI,eAAe,SAAS;MAC5B,IAAI;MACJ,WAAW,eAAe,SAAS;MACnC,iBAAiB,eAAe,SAAS;MACzC,UAAU,gCAAgC,eAAe,UAAU,OAAO,KAAK,eAAe,QAAQ,CAAC;MACvG,gBAAgB,CAAC,SAAS;KAC3B;AAED,WAAO;MACL,MAAM,eAAe;MACrB,eAAe,CAAC,SAAS;MACzB,UAAU,CAAC,GAAG,eAAe,GAAG,cAAc,UAAU,GAAG,sBAAsB,UAAU,GAAG,YAAY;;EAE9G;AACE,UAAM,YAAW;EACnB;AACF;",
|
|
6
|
+
"names": ["path", "next", "fs", "path", "fs", "path", "fs", "path", "path", "fs", "fs", "path", "fs", "path", "fs", "appendWarning", "resolveActiveExtensionFieldNames", "fs", "path", "fs"]
|
|
7
|
+
}
|
|
@@ -3,34 +3,36 @@ import {
|
|
|
3
3
|
normalizeReplayPatchOps,
|
|
4
4
|
tryApplyReplayPatch,
|
|
5
5
|
verifyHistoryChain
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-D3UCE7RW.js";
|
|
7
7
|
import {
|
|
8
8
|
parseLimit
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EEY54JMF.js";
|
|
10
10
|
import {
|
|
11
11
|
enforceHistoryStreamPolicyForItem,
|
|
12
12
|
hashDocument,
|
|
13
13
|
hashEmptyDocument,
|
|
14
14
|
locateItem,
|
|
15
|
-
normalizeItemId,
|
|
16
15
|
readLocatedItem
|
|
17
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-3U3VEWK6.js";
|
|
18
17
|
import {
|
|
19
|
-
findFirstMergeConflictMarker
|
|
20
|
-
|
|
18
|
+
findFirstMergeConflictMarker,
|
|
19
|
+
normalizeItemId
|
|
20
|
+
} from "./chunk-EZFKWSC7.js";
|
|
21
21
|
import {
|
|
22
|
-
EXIT_CODE,
|
|
23
22
|
PmCliError,
|
|
24
23
|
getActiveExtensionRegistrations,
|
|
24
|
+
readSettings,
|
|
25
|
+
runActiveOnReadHooks
|
|
26
|
+
} from "./chunk-P5YORJRH.js";
|
|
27
|
+
import {
|
|
28
|
+
EXIT_CODE,
|
|
25
29
|
getHistoryPath,
|
|
26
30
|
getSettingsPath,
|
|
27
31
|
pathExists,
|
|
28
32
|
readFileIfExists,
|
|
29
|
-
readSettings,
|
|
30
33
|
resolveItemTypeRegistry,
|
|
31
|
-
resolvePmRoot
|
|
32
|
-
|
|
33
|
-
} from "./chunk-BDDYM4LH.js";
|
|
34
|
+
resolvePmRoot
|
|
35
|
+
} from "./chunk-5VVUKE3U.js";
|
|
34
36
|
|
|
35
37
|
// dist/core/history/history-diff.js
|
|
36
38
|
!(function() {
|
|
@@ -272,4 +274,4 @@ export {
|
|
|
272
274
|
readHistoryEntries,
|
|
273
275
|
runHistory
|
|
274
276
|
};
|
|
275
|
-
//# sourceMappingURL=chunk-
|
|
277
|
+
//# sourceMappingURL=chunk-3Y4OESPP.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../core/history/history-diff.ts", "../../../../../../../../cli/commands/history.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * @module core/history/history-diff\n *\n * Implements append-only history and replay behavior for History Diff.\n */\nimport { cloneEmptyReplayDocument, tryApplyReplayPatch, type ReplayDocument } from \"./replay.js\";\nimport type { HistoryEntry } from \"../../types/index.js\";\n\n/**\n * Documents the history field change payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryFieldChange {\n field: string;\n // before and after are the raw field values captured by replaying the history chain.\n // `undefined` is intentional: it signals that the field was absent in the document at\n // that point (e.g. after a JSON-Patch `remove` op). JSON serialization will omit\n // undefined values, which correctly communicates \"field did not exist\".\n before: unknown;\n after: unknown;\n}\n\n/**\n * Documents the history diff value entry payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryDiffValueEntry {\n /** 1-based position in the FULL stream (fullEntries index + 1). */\n index: number;\n ts: string;\n op: string;\n author: string;\n /** Number of JSON-patch operations in this entry (entry.patch.length). */\n patch_ops: number;\n /** Unique field names touched by this entry, sorted by localeCompare. */\n changed_fields: string[];\n /** Per-field before/after values, sorted by field name (localeCompare). */\n changes: HistoryFieldChange[];\n}\n\n// ---------------------------------------------------------------------------\n// JSON-Pointer helpers (ported from src/cli/commands/history.ts so the\n// orchestrator can replace the private copy there with an import from here).\n// ---------------------------------------------------------------------------\n\nfunction decodeJsonPointerSegment(segment: string): string {\n return segment.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\");\n}\n\n/**\n * Map a JSON-Patch path string to a human-readable changed-field name.\n *\n * Rules (in priority order):\n * - \"/body\" or \"/body/…\" → \"body\"\n * - \"/metadata/…\" or \"/front_matter/…\"\n * with a first segment → that decoded segment (e.g. \"status\")\n * without a first segment (bare prefix) → \"metadata\"\n * - \"/\" (root pointer, empty segment after strip) → \"root\"\n * - anything else → decoded first path segment\n */\nexport function patchPathToChangedField(path: string): string {\n if (path === \"/body\" || path.startsWith(\"/body/\")) return \"body\";\n if (\n path === \"/metadata\" ||\n path.startsWith(\"/metadata/\") ||\n path === \"/front_matter\" ||\n path.startsWith(\"/front_matter/\")\n ) {\n const segment = path.replace(/^\\/(?:metadata|front_matter)\\/?/, \"\").split(\"/\")[0];\n if (!segment) return \"metadata\";\n return decodeJsonPointerSegment(segment);\n }\n const segment = path.replace(/^\\//, \"\").split(\"/\")[0];\n return segment ? decodeJsonPointerSegment(segment) : \"root\";\n}\n\n// ---------------------------------------------------------------------------\n// Field-value reader\n// ---------------------------------------------------------------------------\n\n/**\n * Extract the before/after value for a logical field from a replay document.\n *\n * - \"body\" → doc.body\n * - \"metadata\" → doc.metadata (the whole object, for a bare /metadata replace)\n * - \"root\" → the whole document (for a bare \"/\" patch op)\n * - other → doc.metadata[field] (may be undefined when the field was absent)\n */\nfunction readFieldValue(doc: ReplayDocument, field: string): unknown {\n if (field === \"body\") return doc.body;\n if (field === \"metadata\") return doc.metadata;\n if (field === \"root\") return doc;\n return doc.metadata[field];\n}\n\n// ---------------------------------------------------------------------------\n// Main export\n// ---------------------------------------------------------------------------\n\n/**\n * Replay a full history entry stream and produce enriched diff entries with\n * per-field before/after values.\n *\n * @param fullEntries The complete ordered history chain to replay.\n * @param options.windowStartIndex 0-based index into fullEntries at which the\n * DISPLAYED window begins. Entries before this index are still replayed (so\n * state is accurate) but are not emitted. Defaults to 0.\n * @param options.field When supplied, only entries that changed this field are\n * emitted, and each emitted entry's `changes` and `changed_fields` are\n * restricted to that single field.\n */\nexport function computeHistoryDiff(\n fullEntries: HistoryEntry[],\n options?: { windowStartIndex?: number; field?: string },\n): HistoryDiffValueEntry[] {\n const windowStartIndex = options?.windowStartIndex ?? 0;\n const fieldFilter = options?.field;\n\n if (fullEntries.length === 0 || windowStartIndex >= fullEntries.length) {\n return [];\n }\n\n let current = cloneEmptyReplayDocument();\n const result: HistoryDiffValueEntry[] = [];\n\n for (let p = 0; p < fullEntries.length; p += 1) {\n const entry = fullEntries[p];\n\n // Capture before state.\n const beforeDoc = current;\n\n // Attempt to apply patch.\n const applied = tryApplyReplayPatch(current, entry.patch);\n let afterDoc: ReplayDocument;\n if (applied.ok) {\n afterDoc = applied.document;\n current = afterDoc;\n } else {\n // Patch failed — use before state as after (cannot trust partial result).\n // Do NOT advance current; keep prior replay state.\n afterDoc = beforeDoc;\n }\n\n // Collect changed field names from patch paths (and from: paths for move/copy).\n const changedFieldSet = new Set<string>();\n for (const patchOp of entry.patch) {\n changedFieldSet.add(patchPathToChangedField(patchOp.path));\n if (patchOp.from !== undefined) {\n changedFieldSet.add(patchPathToChangedField(patchOp.from));\n }\n }\n const sortedFields = [...changedFieldSet].sort((a, b) => a.localeCompare(b));\n\n // Only emit entries in the display window.\n if (p >= windowStartIndex) {\n // Apply field filter: skip this entry entirely if it doesn't touch the\n // requested field; otherwise narrow down to only that field.\n if (fieldFilter !== undefined) {\n if (!changedFieldSet.has(fieldFilter)) {\n // This entry does not touch the requested field — skip it.\n continue;\n }\n // Emit only the filtered field.\n const change: HistoryFieldChange = {\n field: fieldFilter,\n before: readFieldValue(beforeDoc, fieldFilter),\n after: readFieldValue(afterDoc, fieldFilter),\n };\n result.push({\n index: p + 1,\n ts: entry.ts,\n op: entry.op,\n author: entry.author,\n patch_ops: entry.patch.length,\n changed_fields: [fieldFilter],\n changes: [change],\n });\n } else {\n // Emit all changed fields.\n const changes: HistoryFieldChange[] = sortedFields.map((field) => ({\n field,\n before: readFieldValue(beforeDoc, field),\n after: readFieldValue(afterDoc, field),\n }));\n result.push({\n index: p + 1,\n ts: entry.ts,\n op: entry.op,\n author: entry.author,\n patch_ops: entry.patch.length,\n changed_fields: sortedFields,\n changes,\n });\n }\n }\n }\n\n return result;\n}\n", "/**\n * @module cli/commands/history\n *\n * Implements the pm history command surface and its agent-facing runtime behavior.\n */\nimport { pathExists, readFileIfExists } from \"../../core/fs/fs-utils.js\";\nimport { computeHistoryDiff, patchPathToChangedField, type HistoryDiffValueEntry } from \"../../core/history/history-diff.js\";\nimport { hashDocument, hashEmptyDocument } from \"../../core/history/history.js\";\nimport { normalizeReplayPatchOps, verifyHistoryChain } from \"../../core/history/replay.js\";\nimport { enforceHistoryStreamPolicyForItem } from \"../../core/history/history-stream-policy.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport { findFirstMergeConflictMarker } from \"../../core/shared/conflict-markers.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { getActiveExtensionRegistrations, runActiveOnReadHooks } from \"../../core/extensions/index.js\";\nimport { normalizeItemId } from \"../../core/item/id.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { locateItem, readLocatedItem } from \"../../core/store/item-store.js\";\nimport { getHistoryPath, getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { parseLimit } from \"../shared-parsers.js\";\nimport type { HistoryEntry } from \"../../types/index.js\";\n\nexport { verifyHistoryChain } from \"../../core/history/replay.js\";\n\n/**\n * Documents the history command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryCommandOptions {\n limit?: string;\n diff?: boolean;\n /** Restrict --diff to a single field's before/after transitions (implies --diff). */\n field?: string;\n verify?: boolean;\n compact?: boolean;\n}\n\n/**\n * Documents the history diff entry payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryDiffEntry {\n index: number;\n ts: string;\n op: string;\n author: string;\n patch_ops: number;\n changed_fields: string[];\n}\n\n/**\n * Documents the history verification result payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryVerificationResult {\n ok: boolean;\n entries: number;\n errors: string[];\n latest_after_hash?: string;\n current_item_hash?: string;\n current_matches_latest?: boolean;\n}\n\n/**\n * Documents the history result payload exchanged by command, SDK, and package integrations.\n */\nexport interface HistoryResult {\n id: string;\n history: HistoryEntry[];\n compact_history?: HistoryDiffEntry[];\n compact: boolean;\n count: number;\n limit: number | null;\n diff?: HistoryDiffValueEntry[];\n verification?: HistoryVerificationResult;\n}\n\nfunction limitEntries<T>(values: T[], limit: number | undefined): T[] {\n if (limit === undefined) return values;\n return values.slice(Math.max(0, values.length - limit));\n}\n\nfunction buildDiffEntries(entries: HistoryEntry[], startIndex: number): HistoryDiffEntry[] {\n return entries.map((entry, index) => {\n const changedFields = new Set<string>();\n const patch = normalizeReplayPatchOps(entry.patch);\n for (const op of patch) {\n changedFields.add(patchPathToChangedField(op.path));\n if (op.from) {\n changedFields.add(patchPathToChangedField(op.from));\n }\n }\n return {\n index: startIndex + index + 1,\n ts: entry.ts,\n op: entry.op,\n author: entry.author,\n patch_ops: patch.length,\n changed_fields: [...changedFields].sort((left, right) => left.localeCompare(right)),\n };\n });\n}\n\n/**\n * Implements read history entries for the public runtime surface of this module.\n */\nexport async function readHistoryEntries(historyPath: string, itemId: string): Promise<HistoryEntry[]> {\n const raw = await readFileIfExists(historyPath);\n if (raw === null) {\n return [];\n }\n await runActiveOnReadHooks({\n path: historyPath,\n scope: \"project\",\n });\n if (raw.trim() === \"\") {\n return [];\n }\n const conflictMarker = findFirstMergeConflictMarker(raw);\n if (conflictMarker) {\n throw new PmCliError(\n `History for ${itemId} contains merge conflict markers at line ${conflictMarker.line} (${conflictMarker.marker}). Resolve <<<<<<< ======= >>>>>>> markers and retry.`,\n EXIT_CODE.GENERIC_FAILURE,\n {\n code: \"history_merge_conflict_markers_detected\",\n required: \"Repair the history stream by resolving merge-conflict markers.\",\n why: \"Conflict markers break JSONL parsing and invalidate deterministic audit history.\",\n examples: [`pm history ${itemId}`, `pm restore ${itemId} <timestamp-or-version>`],\n nextSteps: [\"Resolve or restore the history file, then rerun the command.\"],\n },\n );\n }\n\n const entries: HistoryEntry[] = [];\n const lines = raw.split(/\\r?\\n/);\n for (let index = 0; index < lines.length; index += 1) {\n const line = lines[index]?.trim();\n if (!line) continue;\n try {\n entries.push(JSON.parse(line) as HistoryEntry);\n } catch {\n throw new PmCliError(\n `History for ${itemId} contains invalid JSON at line ${index + 1}. Repair or restore the history stream and retry.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n }\n return entries;\n}\n\n/**\n * Implements run history for the public runtime surface of this module.\n */\nexport async function runHistory(id: string, options: HistoryCommandOptions, global: GlobalOptions): Promise<HistoryResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n\n const limit = parseLimit(options.limit);\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const normalizedId = normalizeItemId(id, settings.id_prefix);\n const located = await locateItem(\n pmRoot,\n normalizedId,\n settings.id_prefix,\n settings.item_format,\n typeRegistry.type_to_folder,\n );\n const resolvedId = located?.id ?? normalizedId;\n const historyPath = getHistoryPath(pmRoot, resolvedId);\n if (!located && !(await pathExists(historyPath))) {\n throw new PmCliError(`Item ${id} not found`, EXIT_CODE.NOT_FOUND);\n }\n /* c8 ignore next -- resolved ids in command tests always map to located items. */\n if (located) {\n await enforceHistoryStreamPolicyForItem({\n pmRoot,\n settings,\n itemId: located.id,\n commandLabel: \"history\",\n });\n }\n\n const fullHistory = await readHistoryEntries(historyPath, resolvedId);\n const history = limitEntries(fullHistory, limit);\n const compact = options.compact === true;\n const compactHistory = compact ? buildDiffEntries(history, Math.max(0, fullHistory.length - history.length)) : undefined;\n const result: HistoryResult = {\n id: resolvedId,\n history: compact ? [] : history,\n compact_history: compactHistory,\n compact,\n count: history.length,\n limit: limit ?? null,\n };\n\n if (options.diff || options.field !== undefined) {\n // --diff replays the full chain to surface per-field before/after values for\n // the displayed window (the latest --limit entries). --field narrows to a\n // single field's transitions (\"when did status change?\"). Unlike the compact\n // projection above, the value diff is independent of the compact/full toggle.\n result.diff = computeHistoryDiff(fullHistory, {\n windowStartIndex: Math.max(0, fullHistory.length - history.length),\n field: options.field,\n });\n }\n\n if (options.verify) {\n const verification = verifyHistoryChain(fullHistory);\n /* c8 ignore next -- verify path operates on non-empty streams in command-level coverage. */\n const latestAfterHash = fullHistory.length > 0 ? fullHistory[fullHistory.length - 1].after_hash : hashEmptyDocument();\n let currentItemHash: string | undefined;\n let currentMatchesLatest: boolean | undefined;\n const errors = [...verification.errors];\n\n /* c8 ignore next -- verify command paths currently execute with located on-disk items. */\n if (located) {\n const loaded = await readLocatedItem(located, { schema: settings.schema });\n currentItemHash = hashDocument(loaded.document);\n currentMatchesLatest = currentItemHash === latestAfterHash;\n if (!currentMatchesLatest) {\n errors.push(\"verify_failed:current_item_hash_mismatch\");\n }\n }\n\n result.verification = {\n ok: errors.length === 0,\n entries: fullHistory.length,\n errors,\n /* c8 ignore next -- empty-history verification payloads are covered by lower-level stream tests. */\n latest_after_hash: fullHistory.length > 0 ? fullHistory[fullHistory.length - 1].after_hash : undefined,\n current_item_hash: currentItemHash,\n current_matches_latest: currentMatchesLatest,\n };\n }\n\n return result;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAS,yBAAyB,SAAe;AAC/C,SAAO,QAAQ,WAAW,MAAM,GAAG,EAAE,WAAW,MAAM,GAAG;AAC3D;AAaM,SAAU,wBAAwB,MAAY;AAClD,MAAI,SAAS,WAAW,KAAK,WAAW,QAAQ;AAAG,WAAO;AAC1D,MACE,SAAS,eACT,KAAK,WAAW,YAAY,KAC5B,SAAS,mBACT,KAAK,WAAW,gBAAgB,GAChC;AACA,UAAMA,WAAU,KAAK,QAAQ,mCAAmC,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AAChF,QAAI,CAACA;AAAS,aAAO;AACrB,WAAO,yBAAyBA,QAAO;EACzC;AACA,QAAM,UAAU,KAAK,QAAQ,OAAO,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AACpD,SAAO,UAAU,yBAAyB,OAAO,IAAI;AACvD;AAcA,SAAS,eAAe,KAAqB,OAAa;AACxD,MAAI,UAAU;AAAQ,WAAO,IAAI;AACjC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global"]
|
|
7
7
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
printError,
|
|
3
|
-
writeStdout
|
|
4
|
-
} from "./chunk-WSDIALO4.js";
|
|
5
1
|
import {
|
|
6
2
|
refreshSearchArtifactsForMutation,
|
|
7
3
|
shouldRunSearchRefreshInForeground
|
|
8
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LEKT4K7I.js";
|
|
5
|
+
import {
|
|
6
|
+
printError,
|
|
7
|
+
writeStdout
|
|
8
|
+
} from "./chunk-ZD34OFFQ.js";
|
|
9
9
|
import {
|
|
10
10
|
ACTIVITY_COMMANDER_STRING_OPTION_CONTRACTS,
|
|
11
11
|
CONTEXT_COMMANDER_STRING_OPTION_CONTRACTS,
|
|
@@ -19,16 +19,18 @@ import {
|
|
|
19
19
|
readFirstStringFromCommanderOptions,
|
|
20
20
|
readFirstValueFromCommanderOptions,
|
|
21
21
|
readStringArrayFromCommanderOptions
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-UI5BJ6DO.js";
|
|
23
23
|
import {
|
|
24
|
-
EXIT_CODE,
|
|
25
24
|
PmCliError,
|
|
26
|
-
getSettingsPath,
|
|
27
|
-
pathExists,
|
|
28
25
|
readSettings,
|
|
29
|
-
resolvePmRoot,
|
|
30
26
|
setActiveCommandResult
|
|
31
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-P5YORJRH.js";
|
|
28
|
+
import {
|
|
29
|
+
EXIT_CODE,
|
|
30
|
+
getSettingsPath,
|
|
31
|
+
pathExists,
|
|
32
|
+
resolvePmRoot
|
|
33
|
+
} from "./chunk-5VVUKE3U.js";
|
|
32
34
|
|
|
33
35
|
// dist/cli/registration-helpers.js
|
|
34
36
|
!(function() {
|
|
@@ -817,4 +819,4 @@ export {
|
|
|
817
819
|
normalizeNextOptions,
|
|
818
820
|
invalidateSearchCachesForMutation
|
|
819
821
|
};
|
|
820
|
-
//# sourceMappingURL=chunk-
|
|
822
|
+
//# sourceMappingURL=chunk-4LRVSBO6.js.map
|