@unbrained/pm-cli 2026.7.13 → 2026.7.14
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/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +28 -0
- package/dist/cli/commands/aggregate.d.ts +1 -1
- package/dist/cli/commands/aggregate.js +18 -6
- package/dist/cli/commands/aggregate.js.map +1 -1
- package/dist/cli/commands/context.d.ts +16 -1
- package/dist/cli/commands/context.js +98 -16
- package/dist/cli/commands/context.js.map +1 -1
- package/dist/cli/commands/create.d.ts +1 -1
- package/dist/cli/commands/create.js +11 -7
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/commands/deps.d.ts +6 -96
- package/dist/cli/commands/deps.js +4 -214
- package/dist/cli/commands/deps.js.map +1 -1
- package/dist/cli/commands/docs.d.ts +2 -44
- package/dist/cli/commands/docs.js +8 -13
- package/dist/cli/commands/docs.js.map +1 -1
- package/dist/cli/commands/files.d.ts +6 -134
- package/dist/cli/commands/files.js +4 -294
- package/dist/cli/commands/files.js.map +1 -1
- package/dist/cli/commands/get.js +15 -2
- package/dist/cli/commands/get.js.map +1 -1
- package/dist/cli/commands/list.js +5 -6
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/next.d.ts +3 -1
- package/dist/cli/commands/next.js +77 -20
- package/dist/cli/commands/next.js.map +1 -1
- package/dist/cli/commands/update-many.js +6 -3
- package/dist/cli/commands/update-many.js.map +1 -1
- package/dist/cli/commands/update.js +14 -7
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/commands/validate.d.ts +1 -1
- package/dist/cli/commands/validate.js +32 -35
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/main.d.ts +2 -14
- package/dist/cli/main.js +27 -8
- package/dist/cli/main.js.map +1 -1
- package/dist/cli-bundle/chunks/append-DYQWQK2J.js +11 -0
- package/dist/cli-bundle/chunks/{append-2FS6MVG7.js → append-PVZJDM6J.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-J2WAWP4U.js → chunk-2FNWQXZ2.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-YFGYDZRP.js → chunk-2GA3NK35.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-XFEIASAC.js → chunk-2QIQGYPW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3WCGYH5Q.js → chunk-3CMRNVTO.js} +7 -7
- package/dist/cli-bundle/chunks/chunk-3HKUXVKV.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-VDAZPPRU.js → chunk-3I3LRT2G.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3P3RFJIQ.js → chunk-3TL7WOEF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4SHJ5JS3.js → chunk-44LNIULG.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-QFOAWBOB.js → chunk-4DY4KPQI.js} +11 -10
- package/dist/cli-bundle/chunks/{chunk-QFOAWBOB.js.map → chunk-4DY4KPQI.js.map} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BVCF4ULV.js → chunk-4RXTMU57.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-XMI2TRY5.js → chunk-4WREH7RT.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-JYUGUXFW.js → chunk-5CT5BW6E.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-NA5SBIB4.js → chunk-5URI7TPJ.js} +44 -44
- package/dist/cli-bundle/chunks/chunk-5URI7TPJ.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-QGH6WL6L.js → chunk-655STMGA.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DGKBWCMA.js → chunk-6IIVBC56.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-SRQLQUO6.js → chunk-6MHSBDGD.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-SRQLQUO6.js.map → chunk-6MHSBDGD.js.map} +2 -2
- package/dist/cli-bundle/chunks/{chunk-D4GPNYYP.js → chunk-6OTZMORS.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-JVRVXO6M.js → chunk-6PKA3SJQ.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-2PR4ZTRO.js → chunk-6TTOHMTB.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-2PR4ZTRO.js.map → chunk-6TTOHMTB.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-6X5MZ5R2.js +9 -0
- package/dist/cli-bundle/chunks/chunk-76UBY2EE.js +5 -0
- package/dist/cli-bundle/chunks/{chunk-ZS2KPCJN.js → chunk-7QDSYUMF.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-Z7TFPIJ6.js → chunk-7TQMR6LK.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-AHA4POA6.js → chunk-ABRCOSDC.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-XY3CC3EM.js → chunk-AFWZRL7M.js} +59 -53
- package/dist/cli-bundle/chunks/chunk-AFWZRL7M.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-KQJVTQVK.js → chunk-ANSJHDOZ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OMT4NO7T.js → chunk-B5DZYTT3.js} +113 -24
- package/dist/cli-bundle/chunks/chunk-B5DZYTT3.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-B7SWOIP6.js +5 -0
- package/dist/cli-bundle/chunks/{chunk-D2LXG7WX.js → chunk-BN62TO2S.js} +5 -5
- package/dist/cli-bundle/chunks/chunk-BN62TO2S.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-ZTSV7P2T.js → chunk-BPD26E3P.js} +357 -42
- package/dist/cli-bundle/chunks/chunk-BPD26E3P.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-RKGFUC4O.js → chunk-CDJYP7OQ.js} +36 -14
- package/dist/cli-bundle/chunks/chunk-CDJYP7OQ.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-VLFLRFJP.js → chunk-CIOZ376P.js} +20 -13
- package/dist/cli-bundle/chunks/chunk-CIOZ376P.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-HXTCZSAI.js → chunk-DBZVUJTK.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-2QNOWOIB.js → chunk-DO5RGJXT.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-MKONZ4UO.js → chunk-DRNJPEPQ.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-XDT2PSXA.js → chunk-DVOLZJ3C.js} +12 -11
- package/dist/cli-bundle/chunks/{chunk-XDT2PSXA.js.map → chunk-DVOLZJ3C.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-H36FXA7B.js → chunk-DYEX6NFH.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-G3IB5GTD.js → chunk-E2WC6S4P.js} +15 -11
- package/dist/cli-bundle/chunks/chunk-E2WC6S4P.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-GAJ7U7B4.js → chunk-ERL2YFJ2.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-FPEYOFEF.js → chunk-F7PSHRNO.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-UH7OLT6F.js → chunk-FDSBDNYE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DGJF32JF.js → chunk-FIGXOCEQ.js} +66 -21
- package/dist/cli-bundle/chunks/chunk-FIGXOCEQ.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-RQAY7C5T.js → chunk-FJZDA6MS.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-B4TVNGRX.js → chunk-FO7GMJKG.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-FRQ63VPB.js +5 -0
- package/dist/cli-bundle/chunks/{chunk-UTYNQ2WH.js → chunk-FS6UM5WH.js} +48 -27
- package/dist/cli-bundle/chunks/chunk-FS6UM5WH.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-U252II47.js → chunk-FTQLW4JD.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-TNGLCRKS.js → chunk-GSEADLRH.js} +1821 -1809
- package/dist/cli-bundle/chunks/chunk-GSEADLRH.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-TGG7YGMC.js → chunk-GXXC7QSK.js} +53 -47
- package/dist/cli-bundle/chunks/chunk-GXXC7QSK.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-AGD4VZXH.js → chunk-H2QBAKLQ.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-CJVQ4XIG.js → chunk-HAMLIWAF.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-56DX6QYG.js → chunk-HL7V2PHX.js} +19 -13
- package/dist/cli-bundle/chunks/chunk-HL7V2PHX.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-7QOIQTPB.js → chunk-HLHSQ5CA.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-AHC7J6XD.js → chunk-IA3YFTXT.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-5ZCVF4WF.js → chunk-IAPHYPRL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OCSQWIOW.js → chunk-IFZA4VB5.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-6O2HJENY.js → chunk-IGED7NH2.js} +61 -48
- package/dist/cli-bundle/chunks/chunk-IGED7NH2.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-RPCCQDG2.js → chunk-ILLUE5DI.js} +36 -14
- package/dist/cli-bundle/chunks/chunk-ILLUE5DI.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-4WMFM77X.js → chunk-J4NZOP3I.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-57JVERX3.js → chunk-JAF4TUQ7.js} +4 -4
- package/dist/cli-bundle/chunks/chunk-JAF4TUQ7.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-MTNKSSSO.js → chunk-JL7WZ4O2.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-AZ52LTCY.js → chunk-K7WNZ7KD.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-2OLSXXIV.js → chunk-KADLSPIU.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-RQKORMM4.js → chunk-KB726FMH.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-WKSFBBZT.js → chunk-L24HCJFC.js} +114 -25
- package/dist/cli-bundle/chunks/chunk-L24HCJFC.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-LDO24J5I.js → chunk-LWTIRS3Y.js} +365 -43
- package/dist/cli-bundle/chunks/chunk-LWTIRS3Y.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-TZTQ4TVV.js → chunk-M6ASXYCU.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-WDDOAU7Z.js → chunk-M7EWN4TF.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-327DSGW2.js → chunk-MD6ULIPJ.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-OKDBHOON.js → chunk-MKL4CP2I.js} +61 -48
- package/dist/cli-bundle/chunks/chunk-MKL4CP2I.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-M52DG2QJ.js → chunk-MQZ3PLCF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GQ2CQNGI.js → chunk-N3CMP4NI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-J7SBFUZC.js → chunk-NAQYVWSQ.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-U2GMYP3L.js → chunk-NKW36AMT.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-5WEYOVZ7.js → chunk-OBDLEQG5.js} +19 -12
- package/dist/cli-bundle/chunks/chunk-OBDLEQG5.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-VL4LYTJN.js → chunk-OI4S4KCI.js} +18 -12
- package/dist/cli-bundle/chunks/chunk-OI4S4KCI.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-FCVVMAEX.js → chunk-P6MYFH6K.js} +60 -22
- package/dist/cli-bundle/chunks/chunk-P6MYFH6K.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-FTQQAPRX.js → chunk-PHKP3AGR.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-WVUXNIYO.js → chunk-Q37E63AM.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-JVXV7ANV.js → chunk-Q7E6OYZK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WVUYATII.js → chunk-QABYZYLU.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-QRRUGIJN.js → chunk-QASRVKUQ.js} +45 -45
- package/dist/cli-bundle/chunks/chunk-QASRVKUQ.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-L4262MFB.js → chunk-QK2ZN6UL.js} +14 -5
- package/dist/cli-bundle/chunks/{chunk-L4262MFB.js.map → chunk-QK2ZN6UL.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-7TQPV7HR.js → chunk-QSPARJWF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GTKILM6F.js → chunk-QZ7LT3XE.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-L3VKY6R6.js → chunk-RA5AIAMP.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-BJS27ALI.js → chunk-RGXD5JJR.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-TSEPW2P6.js → chunk-RMF3IOYQ.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-QXYKH56X.js → chunk-T4BRCB6Z.js} +1894 -1875
- package/dist/cli-bundle/chunks/chunk-T4BRCB6Z.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-TGGTXC52.js → chunk-TH7U4KLY.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-LP4UATP6.js → chunk-TWLDBKQU.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-OTZ3C2NE.js → chunk-TZ2PSLLT.js} +49 -28
- package/dist/cli-bundle/chunks/chunk-TZ2PSLLT.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-UK222BHQ.js → chunk-TZRTLMWM.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-6E6S2X6S.js → chunk-UB2QYSTO.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-S6CXUSYC.js → chunk-UGTVWL3E.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-BNS6QHTZ.js → chunk-UJ4HJYWL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BYVOEJPQ.js → chunk-UKUIIBDW.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-SGDBVR7X.js → chunk-UVBA6F5A.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DZRZMBBF.js → chunk-VJTAEIPC.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-74PWVJON.js → chunk-W6HZ55JO.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HR2MQAO5.js → chunk-WD6MSYMP.js} +13 -4
- package/dist/cli-bundle/chunks/{chunk-HR2MQAO5.js.map → chunk-WD6MSYMP.js.map} +2 -2
- package/dist/cli-bundle/chunks/{chunk-P7IFURWH.js → chunk-WPAWZW7S.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-36LEOWSX.js → chunk-WQUEHPZB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FCKJF7G2.js → chunk-WRKB56FC.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-KR5EHAN4.js → chunk-X3GYR4P2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-J567OZJY.js → chunk-X6BVXQ52.js} +16 -12
- package/dist/cli-bundle/chunks/chunk-X6BVXQ52.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-Y72FV7RM.js +178 -0
- package/dist/cli-bundle/chunks/chunk-Y72FV7RM.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-OWW2KXOV.js → chunk-YQYG2V23.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-G2SCT7BC.js → chunk-YVKE5ZDM.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-QHIN4UTF.js → chunk-ZAYYDNB3.js} +4 -4
- package/dist/cli-bundle/chunks/chunk-ZHBI2AP7.js +9 -0
- package/dist/cli-bundle/chunks/chunk-ZNP64HOW.js +175 -0
- package/dist/cli-bundle/chunks/chunk-ZNP64HOW.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-GNVBUNJQ.js → chunk-ZTRBSABY.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-PY32KGQU.js → chunk-ZUKSZVBW.js} +5 -5
- package/dist/cli-bundle/chunks/{close-CU56F47E.js → close-LZECOMHO.js} +5 -5
- package/dist/cli-bundle/chunks/close-RI4JQQHU.js +12 -0
- package/dist/cli-bundle/chunks/close-many-LY2XJ52M.js +21 -0
- package/dist/cli-bundle/chunks/{close-many-ZQ2WP67J.js → close-many-ZHI6A5TN.js} +12 -12
- package/dist/cli-bundle/chunks/comments-35M273DN.js +13 -0
- package/dist/cli-bundle/chunks/{comments-UDUMKXL6.js → comments-AJWRTFZ5.js} +7 -7
- package/dist/cli-bundle/chunks/{copy-VFHECFBV.js → copy-GMXYKBXT.js} +4 -4
- package/dist/cli-bundle/chunks/copy-NPYM7M7U.js +9 -0
- package/dist/cli-bundle/chunks/create-F53OBTOU.js +27 -0
- package/dist/cli-bundle/chunks/{create-CE2X3SGF.js → create-HU4Q7RJX.js} +11 -9
- package/dist/cli-bundle/chunks/{delete-2JXQCHHT.js → delete-GSDZLTRC.js} +4 -4
- package/dist/cli-bundle/chunks/delete-ODRWJWAM.js +10 -0
- package/dist/cli-bundle/chunks/deps-U57I7EAK.js +16 -0
- package/dist/cli-bundle/chunks/{deps-FPXNLO6C.js → deps-WWB7P2GT.js} +7 -4
- package/dist/cli-bundle/chunks/docs-G7N4E2JO.js +14 -0
- package/dist/cli-bundle/chunks/{docs-AMAR4OHU.js → docs-MQIY2ZQS.js} +7 -7
- package/dist/cli-bundle/chunks/files-TBZD7V6H.js +18 -0
- package/dist/cli-bundle/chunks/{files-JFHN7DYM.js → files-TTY6N2AV.js} +7 -7
- package/dist/cli-bundle/chunks/focus-U5TRVCRS.js +10 -0
- package/dist/cli-bundle/chunks/{focus-QFN2RRZ7.js → focus-XT6YVFFX.js} +5 -5
- package/dist/cli-bundle/chunks/{history-compact-G34XMABV.js → history-compact-KKVUWB4V.js} +8 -8
- package/dist/cli-bundle/chunks/{history-compact-SAHT5D46.js → history-compact-M7GHYVFN.js} +8 -8
- package/dist/cli-bundle/chunks/{history-redact-IFJDNKLZ.js → history-redact-3DVZOILD.js} +6 -6
- package/dist/cli-bundle/chunks/history-redact-JIHZLHDP.js +16 -0
- package/dist/cli-bundle/chunks/{history-repair-NXLQTCVN.js → history-repair-ITDUMK4N.js} +8 -8
- package/dist/cli-bundle/chunks/history-repair-NAFCHLH7.js +18 -0
- package/dist/cli-bundle/chunks/{learnings-5CZKAMBS.js → learnings-FGO3NSFW.js} +7 -7
- package/dist/cli-bundle/chunks/learnings-SONGPSHI.js +13 -0
- package/dist/cli-bundle/chunks/notes-BSD53H2W.js +13 -0
- package/dist/cli-bundle/chunks/{notes-POMK37UI.js → notes-NQ6RXVW6.js} +7 -7
- package/dist/cli-bundle/chunks/{plan-YBNYNT3A.js → plan-2NNEO46V.js} +10 -10
- package/dist/cli-bundle/chunks/plan-AWLYGBNV.js +24 -0
- package/dist/cli-bundle/chunks/{profile-JNKSU6EQ.js → profile-AAQUU6T3.js} +9 -9
- package/dist/cli-bundle/chunks/{profile-A2WPVG6I.js → profile-U725ATWZ.js} +9 -9
- package/dist/cli-bundle/chunks/{register-list-query-UG4ZA5AU.js → register-list-query-BUWCYHBT.js} +14 -13
- package/dist/cli-bundle/chunks/{register-list-query-UG4ZA5AU.js.map → register-list-query-BUWCYHBT.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-list-query-KJULL4W3.js → register-list-query-KTZ6AGE7.js} +16 -15
- package/dist/cli-bundle/chunks/{register-list-query-KJULL4W3.js.map → register-list-query-KTZ6AGE7.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-mutation-3OXYXBKH.js → register-mutation-4FMGJJF7.js} +29 -29
- package/dist/cli-bundle/chunks/{register-mutation-WK265BM7.js → register-mutation-UELYYOR7.js} +29 -29
- package/dist/cli-bundle/chunks/{register-operations-C5SQH3FJ.js → register-operations-ISUX6LY5.js} +33 -29
- package/dist/cli-bundle/chunks/{register-operations-C5SQH3FJ.js.map → register-operations-ISUX6LY5.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-operations-FH3PBHYN.js → register-operations-JVW24J2Y.js} +35 -31
- package/dist/cli-bundle/chunks/{register-operations-FH3PBHYN.js.map → register-operations-JVW24J2Y.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-setup-CCK7CJVR.js → register-setup-5XNGKJ22.js} +15 -15
- package/dist/cli-bundle/chunks/{register-setup-CPZBGSOJ.js → register-setup-ZTNY6S7R.js} +15 -15
- package/dist/cli-bundle/chunks/restore-66GLMHIX.js +14 -0
- package/dist/cli-bundle/chunks/{restore-IVS5XGYR.js → restore-B3BAB6X2.js} +6 -6
- package/dist/cli-bundle/chunks/{schema-P2MF23JO.js → schema-LZNUYHDB.js} +6 -6
- package/dist/cli-bundle/chunks/schema-LZNUYHDB.js.map +7 -0
- package/dist/cli-bundle/chunks/{schema-R3U2REY4.js → schema-U7IM2DXV.js} +6 -6
- package/dist/cli-bundle/chunks/schema-U7IM2DXV.js.map +1 -0
- package/dist/cli-bundle/chunks/update-2XGHIVQ2.js +21 -0
- package/dist/cli-bundle/chunks/update-2XGHIVQ2.js.map +7 -0
- package/dist/cli-bundle/chunks/{update-YBIQESMH.js → update-Q3UCILNR.js} +12 -12
- package/dist/cli-bundle/chunks/update-Q3UCILNR.js.map +1 -0
- package/dist/cli-bundle/chunks/{update-many-F3CIV5SQ.js → update-many-75K57FS3.js} +19 -19
- package/dist/cli-bundle/chunks/update-many-75K57FS3.js.map +1 -0
- package/dist/cli-bundle/chunks/update-many-U42YA445.js +30 -0
- package/dist/cli-bundle/chunks/update-many-U42YA445.js.map +7 -0
- package/dist/cli-bundle/main.js +39 -16
- package/dist/cli-bundle/main.js.map +2 -2
- package/dist/cli-bundle/sdk-runtime.js +56 -53
- package/dist/cli-bundle/sdk-testing.js +6 -6
- package/dist/cli-bundle/sdk.js +115 -55
- package/dist/cli-bundle/sdk.js.map +2 -2
- package/dist/core/extensions/command-hook-context.d.ts +40 -0
- package/dist/core/extensions/command-hook-context.js +14 -0
- package/dist/core/extensions/command-hook-context.js.map +1 -0
- package/dist/core/extensions/index.d.ts +1 -0
- package/dist/core/extensions/index.js +4 -3
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/item/parse.d.ts +2 -0
- package/dist/core/item/parse.js +11 -2
- package/dist/core/item/parse.js.map +1 -1
- package/dist/core/store/paths.d.ts +2 -0
- package/dist/core/store/paths.js +10 -2
- package/dist/core/store/paths.js.map +1 -1
- package/dist/mcp/tool-definitions.js +12 -2
- package/dist/mcp/tool-definitions.js.map +1 -1
- package/dist/sdk/context-packing.d.ts +114 -0
- package/dist/sdk/context-packing.js +219 -0
- package/dist/sdk/context-packing.js.map +1 -0
- package/dist/sdk/context-relevance.d.ts +1 -1
- package/dist/sdk/context-relevance.js +4 -2
- package/dist/sdk/context-relevance.js.map +1 -1
- package/dist/sdk/context-usage.d.ts +79 -0
- package/dist/sdk/context-usage.js +193 -0
- package/dist/sdk/context-usage.js.map +1 -0
- package/dist/sdk/dependencies.d.ts +145 -0
- package/dist/sdk/dependencies.js +327 -0
- package/dist/sdk/dependencies.js.map +1 -0
- package/dist/sdk/docs.d.ts +48 -0
- package/dist/sdk/docs.js +15 -0
- package/dist/sdk/docs.js.map +1 -0
- package/dist/sdk/files.d.ts +135 -0
- package/dist/sdk/files.js +320 -0
- package/dist/sdk/files.js.map +1 -0
- package/dist/sdk/index.d.ts +6 -0
- package/dist/sdk/index.js +8 -2
- package/dist/sdk/index.js.map +1 -1
- package/dist/{cli/commands → sdk}/linked-artifacts.d.ts +11 -5
- package/dist/{cli/commands → sdk}/linked-artifacts.js +49 -25
- package/dist/sdk/linked-artifacts.js.map +1 -0
- package/dist/sdk/runtime.d.ts +4 -4
- package/dist/sdk/runtime.js +7 -4
- package/dist/sdk/runtime.js.map +1 -1
- package/dist/sdk/workspace.js +3 -2
- package/dist/sdk/workspace.js.map +1 -1
- package/docs/AGENT_GUIDE.md +1 -1
- package/docs/CONFIGURATION.md +1 -0
- package/docs/PR_REVIEW_LOOP.md +21 -11
- package/docs/SDK.md +94 -0
- package/marketplace.json +2 -2
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/dist/cli/commands/linked-artifacts.js.map +0 -1
- package/dist/cli-bundle/chunks/append-CTKFDEAX.js +0 -11
- package/dist/cli-bundle/chunks/chunk-56DX6QYG.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-57JVERX3.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-5WEYOVZ7.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-6O2HJENY.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-CCAGZCZK.js +0 -17
- package/dist/cli-bundle/chunks/chunk-CCAGZCZK.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-D2LXG7WX.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-DGJF32JF.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-FCVVMAEX.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-FUOK7JZ6.js +0 -14
- package/dist/cli-bundle/chunks/chunk-FUOK7JZ6.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-G3IB5GTD.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-J567OZJY.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-LDO24J5I.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-NA5SBIB4.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-OKDBHOON.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-OMT4NO7T.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-OTZ3C2NE.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-QRRUGIJN.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-QXYKH56X.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-RKGFUC4O.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-RPCCQDG2.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-TGG7YGMC.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-TNGLCRKS.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-UTYNQ2WH.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-VL4LYTJN.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-VLFLRFJP.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-WKSFBBZT.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-XY3CC3EM.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-ZTSV7P2T.js.map +0 -1
- package/dist/cli-bundle/chunks/close-BWM7FTF4.js +0 -12
- package/dist/cli-bundle/chunks/close-many-AUHTVFUQ.js +0 -21
- package/dist/cli-bundle/chunks/comments-7D5VPBZI.js +0 -13
- package/dist/cli-bundle/chunks/copy-QJ6ZVWZV.js +0 -9
- package/dist/cli-bundle/chunks/create-FGMTTYOI.js +0 -25
- package/dist/cli-bundle/chunks/delete-L2GMMMPR.js +0 -10
- package/dist/cli-bundle/chunks/deps-KTFI4RWD.js +0 -13
- package/dist/cli-bundle/chunks/docs-VNURA275.js +0 -14
- package/dist/cli-bundle/chunks/files-UNFPZLTG.js +0 -18
- package/dist/cli-bundle/chunks/focus-MI2UHBP4.js +0 -10
- package/dist/cli-bundle/chunks/history-redact-VAHGBUHI.js +0 -16
- package/dist/cli-bundle/chunks/history-repair-DDYQXR43.js +0 -18
- package/dist/cli-bundle/chunks/learnings-VWJEKHEO.js +0 -13
- package/dist/cli-bundle/chunks/notes-NGVJJJQO.js +0 -13
- package/dist/cli-bundle/chunks/plan-U6SQJUFI.js +0 -24
- package/dist/cli-bundle/chunks/restore-AX6ZMGHZ.js +0 -14
- package/dist/cli-bundle/chunks/update-XYHF3YZF.js +0 -21
- package/dist/cli-bundle/chunks/update-many-5HKVHFUL.js +0 -30
- /package/dist/cli-bundle/chunks/{append-CTKFDEAX.js.map → append-DYQWQK2J.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{append-2FS6MVG7.js.map → append-PVZJDM6J.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-J2WAWP4U.js.map → chunk-2FNWQXZ2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-YFGYDZRP.js.map → chunk-2GA3NK35.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-XFEIASAC.js.map → chunk-2QIQGYPW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-3WCGYH5Q.js.map → chunk-3CMRNVTO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-BWM7FTF4.js.map → chunk-3HKUXVKV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-VDAZPPRU.js.map → chunk-3I3LRT2G.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-3P3RFJIQ.js.map → chunk-3TL7WOEF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-4SHJ5JS3.js.map → chunk-44LNIULG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-BVCF4ULV.js.map → chunk-4RXTMU57.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-XMI2TRY5.js.map → chunk-4WREH7RT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-JYUGUXFW.js.map → chunk-5CT5BW6E.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QGH6WL6L.js.map → chunk-655STMGA.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-DGKBWCMA.js.map → chunk-6IIVBC56.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-D4GPNYYP.js.map → chunk-6OTZMORS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-JVRVXO6M.js.map → chunk-6PKA3SJQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-many-AUHTVFUQ.js.map → chunk-6X5MZ5R2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-CU56F47E.js.map → chunk-76UBY2EE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-ZS2KPCJN.js.map → chunk-7QDSYUMF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-Z7TFPIJ6.js.map → chunk-7TQMR6LK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-AHA4POA6.js.map → chunk-ABRCOSDC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-KQJVTQVK.js.map → chunk-ANSJHDOZ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-many-ZQ2WP67J.js.map → chunk-B7SWOIP6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-HXTCZSAI.js.map → chunk-DBZVUJTK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-2QNOWOIB.js.map → chunk-DO5RGJXT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-MKONZ4UO.js.map → chunk-DRNJPEPQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-H36FXA7B.js.map → chunk-DYEX6NFH.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-GAJ7U7B4.js.map → chunk-ERL2YFJ2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-FPEYOFEF.js.map → chunk-F7PSHRNO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-UH7OLT6F.js.map → chunk-FDSBDNYE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-RQAY7C5T.js.map → chunk-FJZDA6MS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-B4TVNGRX.js.map → chunk-FO7GMJKG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{comments-UDUMKXL6.js.map → chunk-FRQ63VPB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-U252II47.js.map → chunk-FTQLW4JD.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-AGD4VZXH.js.map → chunk-H2QBAKLQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-CJVQ4XIG.js.map → chunk-HAMLIWAF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-7QOIQTPB.js.map → chunk-HLHSQ5CA.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-AHC7J6XD.js.map → chunk-IA3YFTXT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-5ZCVF4WF.js.map → chunk-IAPHYPRL.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-OCSQWIOW.js.map → chunk-IFZA4VB5.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-4WMFM77X.js.map → chunk-J4NZOP3I.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-MTNKSSSO.js.map → chunk-JL7WZ4O2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-AZ52LTCY.js.map → chunk-K7WNZ7KD.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-2OLSXXIV.js.map → chunk-KADLSPIU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-RQKORMM4.js.map → chunk-KB726FMH.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-TZTQ4TVV.js.map → chunk-M6ASXYCU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-WDDOAU7Z.js.map → chunk-M7EWN4TF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-327DSGW2.js.map → chunk-MD6ULIPJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-M52DG2QJ.js.map → chunk-MQZ3PLCF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-GQ2CQNGI.js.map → chunk-N3CMP4NI.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-J7SBFUZC.js.map → chunk-NAQYVWSQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-U2GMYP3L.js.map → chunk-NKW36AMT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-FTQQAPRX.js.map → chunk-PHKP3AGR.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-WVUXNIYO.js.map → chunk-Q37E63AM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-JVXV7ANV.js.map → chunk-Q7E6OYZK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-WVUYATII.js.map → chunk-QABYZYLU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-7TQPV7HR.js.map → chunk-QSPARJWF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-GTKILM6F.js.map → chunk-QZ7LT3XE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-L3VKY6R6.js.map → chunk-RA5AIAMP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-BJS27ALI.js.map → chunk-RGXD5JJR.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-TSEPW2P6.js.map → chunk-RMF3IOYQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-TGGTXC52.js.map → chunk-TH7U4KLY.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-LP4UATP6.js.map → chunk-TWLDBKQU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-UK222BHQ.js.map → chunk-TZRTLMWM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-6E6S2X6S.js.map → chunk-UB2QYSTO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-S6CXUSYC.js.map → chunk-UGTVWL3E.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-BNS6QHTZ.js.map → chunk-UJ4HJYWL.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-BYVOEJPQ.js.map → chunk-UKUIIBDW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-SGDBVR7X.js.map → chunk-UVBA6F5A.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-DZRZMBBF.js.map → chunk-VJTAEIPC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-74PWVJON.js.map → chunk-W6HZ55JO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-P7IFURWH.js.map → chunk-WPAWZW7S.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-36LEOWSX.js.map → chunk-WQUEHPZB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-FCKJF7G2.js.map → chunk-WRKB56FC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-KR5EHAN4.js.map → chunk-X3GYR4P2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-OWW2KXOV.js.map → chunk-YQYG2V23.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-G2SCT7BC.js.map → chunk-YVKE5ZDM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QHIN4UTF.js.map → chunk-ZAYYDNB3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{comments-7D5VPBZI.js.map → chunk-ZHBI2AP7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-GNVBUNJQ.js.map → chunk-ZTRBSABY.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-PY32KGQU.js.map → chunk-ZUKSZVBW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{copy-VFHECFBV.js.map → close-LZECOMHO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{copy-QJ6ZVWZV.js.map → close-RI4JQQHU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{create-FGMTTYOI.js.map → close-many-LY2XJ52M.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{create-CE2X3SGF.js.map → close-many-ZHI6A5TN.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{delete-L2GMMMPR.js.map → comments-35M273DN.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{delete-2JXQCHHT.js.map → comments-AJWRTFZ5.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{deps-FPXNLO6C.js.map → copy-GMXYKBXT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{deps-KTFI4RWD.js.map → copy-NPYM7M7U.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{docs-VNURA275.js.map → create-F53OBTOU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{docs-AMAR4OHU.js.map → create-HU4Q7RJX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{files-JFHN7DYM.js.map → delete-GSDZLTRC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{files-UNFPZLTG.js.map → delete-ODRWJWAM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{focus-MI2UHBP4.js.map → deps-U57I7EAK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{focus-QFN2RRZ7.js.map → deps-WWB7P2GT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-compact-SAHT5D46.js.map → docs-G7N4E2JO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-compact-G34XMABV.js.map → docs-MQIY2ZQS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-redact-VAHGBUHI.js.map → files-TBZD7V6H.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-redact-IFJDNKLZ.js.map → files-TTY6N2AV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-repair-DDYQXR43.js.map → focus-U5TRVCRS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-repair-NXLQTCVN.js.map → focus-XT6YVFFX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{learnings-5CZKAMBS.js.map → history-compact-KKVUWB4V.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{learnings-VWJEKHEO.js.map → history-compact-M7GHYVFN.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{notes-POMK37UI.js.map → history-redact-3DVZOILD.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{notes-NGVJJJQO.js.map → history-redact-JIHZLHDP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{plan-YBNYNT3A.js.map → history-repair-ITDUMK4N.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{plan-U6SQJUFI.js.map → history-repair-NAFCHLH7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{profile-JNKSU6EQ.js.map → learnings-FGO3NSFW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{profile-A2WPVG6I.js.map → learnings-SONGPSHI.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{restore-AX6ZMGHZ.js.map → notes-BSD53H2W.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{restore-IVS5XGYR.js.map → notes-NQ6RXVW6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{schema-R3U2REY4.js.map → plan-2NNEO46V.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{schema-P2MF23JO.js.map → plan-AWLYGBNV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-YBIQESMH.js.map → profile-AAQUU6T3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-XYHF3YZF.js.map → profile-U725ATWZ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{register-mutation-3OXYXBKH.js.map → register-mutation-4FMGJJF7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{register-mutation-WK265BM7.js.map → register-mutation-UELYYOR7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{register-setup-CCK7CJVR.js.map → register-setup-5XNGKJ22.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{register-setup-CPZBGSOJ.js.map → register-setup-ZTNY6S7R.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-many-5HKVHFUL.js.map → restore-66GLMHIX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-many-F3CIV5SQ.js.map → restore-B3BAB6X2.js.map} +0 -0
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../../../../cli/commands/activity.ts", "../../../../../../../../cli/commands/calendar.ts", "../../../../../../../../sdk/context-relevance.ts", "../../../../../../../../cli/commands/context.ts", "../../../../../../../../cli/commands/next.ts", "../../../../../../../../core/search/staleness.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @module cli/commands/activity\n *\n * Implements the pm activity command surface and its agent-facing runtime behavior.\n */\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n getActiveExtensionRegistrations,\n runActiveOnReadHooks,\n} from \"../../core/extensions/index.js\";\nimport { pathExists } from \"../../core/fs/fs-utils.js\";\nimport { enforceHistoryStreamPolicyForItems } from \"../../core/history/history-stream-policy.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport {\n compareTimestampStrings,\n nowIso,\n resolveIsoOrRelative,\n} from \"../../core/shared/time.js\";\nimport { listAllItemMetadataLight } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { readHistoryEntries } from \"./history.js\";\nimport { parseLimit } from \"../shared-parsers.js\";\nimport type { HistoryEntry } from \"../../types/index.js\";\n\n/** Documents the activity command options payload exchanged by command, SDK, and package integrations. */\nexport interface ActivityCommandOptions {\n /** Stable identifier used to reference this record across commands and storage. */\n id?: string;\n /** Value that configures or reports op for this contract. */\n op?: string;\n /** Value that configures or reports author for this contract. */\n author?: string;\n /** Value that configures or reports from for this contract. */\n from?: string;\n /** Value that configures or reports to for this contract. */\n to?: string;\n /** Value that configures or reports limit for this contract. */\n limit?: string;\n /** Value that configures or reports compact for this contract. */\n compact?: boolean;\n}\n\n/** Documents the activity entry payload exchanged by command, SDK, and package integrations. */\nexport interface ActivityEntry extends HistoryEntry {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n}\n\n/** Documents the compact activity entry payload exchanged by command, SDK, and package integrations. */\nexport interface CompactActivityEntry {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports op for this contract. */\n op: string;\n /** Value that configures or reports ts for this contract. */\n ts: string;\n /** Value that configures or reports author for this contract. */\n author: string;\n /** Value that configures or reports msg for this contract. */\n msg?: string;\n}\n\n/** Documents the activity result payload exchanged by command, SDK, and package integrations. */\nexport interface ActivityResult {\n /** Value that configures or reports activity for this contract. */\n activity: ActivityEntry[];\n /** Value that configures or reports compact activity for this contract. */\n compact_activity?: CompactActivityEntry[];\n /** Value that configures or reports compact for this contract. */\n compact: boolean;\n /** Value that configures or reports count for this contract. */\n count: number;\n /** Value that configures or reports limit for this contract. */\n limit: number | null;\n}\n\ninterface ActivityFilters {\n id: string | undefined;\n op: string | undefined;\n author: string | undefined;\n from: string | undefined;\n to: string | undefined;\n limit: number | undefined;\n}\n\ninterface ActivityRuntimeContext {\n pmRoot: string;\n settings: Awaited<ReturnType<typeof readSettings>>;\n}\n\nfunction parseNonEmptyFilter(\n raw: string | undefined,\n flagLabel: string,\n): string | undefined {\n if (raw === undefined) return undefined;\n const normalized = raw.trim();\n if (normalized.length === 0) {\n throw new PmCliError(`${flagLabel} must not be empty`, EXIT_CODE.USAGE);\n }\n return normalized;\n}\n\nfunction parseRangeBound(\n raw: string | undefined,\n nowValue: string,\n fieldLabel: string,\n): string | undefined {\n if (raw === undefined) return undefined;\n const normalized = raw.trim();\n if (normalized.length === 0) {\n throw new PmCliError(\n \"Activity time bounds must not be empty\",\n EXIT_CODE.USAGE,\n );\n }\n return resolveIsoOrRelative(normalized, new Date(nowValue), fieldLabel);\n}\n\nfunction includeByTimeWindow(\n entry: ActivityEntry,\n from: string | undefined,\n to: string | undefined,\n): boolean {\n if (entry.ts.length === 0 && (from || to)) {\n return false;\n }\n if (from && compareTimestampStrings(entry.ts, from) < 0) {\n return false;\n }\n if (to && compareTimestampStrings(entry.ts, to) >= 0) {\n return false;\n }\n return true;\n}\n\nfunction limitEntries<T>(values: T[], limit: number | undefined): T[] {\n if (limit === undefined) return values;\n return values.slice(0, limit);\n}\n\nfunction readActivityString(value: unknown, fallback = \"\"): string {\n return typeof value === \"string\" ? value : fallback;\n}\n\nfunction normalizeActivityEntry(\n id: string,\n entry: HistoryEntry,\n): ActivityEntry {\n return {\n ...entry,\n id,\n ts: readActivityString(entry.ts),\n author: readActivityString(entry.author, \"unknown\"),\n op: readActivityString(entry.op, \"unknown\"),\n patch: Array.isArray(entry.patch) ? entry.patch : [],\n before_hash: readActivityString(entry.before_hash),\n after_hash: readActivityString(entry.after_hash),\n };\n}\n\nfunction sortActivity(entries: ActivityEntry[]): ActivityEntry[] {\n return [...entries].sort((a, b) => {\n const byTimestamp = b.ts.localeCompare(a.ts);\n if (byTimestamp !== 0) return byTimestamp;\n const byId = a.id.localeCompare(b.id);\n if (byId !== 0) return byId;\n return a.op.localeCompare(b.op);\n });\n}\n\nasync function listHistoryFiles(historyDir: string): Promise<string[]> {\n try {\n return (await fs.readdir(historyDir))\n .filter((entry) => entry.endsWith(\".jsonl\"))\n .sort((a, b) => a.localeCompare(b));\n } catch (error: unknown) {\n // Activity should degrade gracefully when optional history storage is absent.\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return [];\n }\n throw error;\n }\n}\n\nfunction resolveActivityFilters(\n options: ActivityCommandOptions,\n): ActivityFilters {\n const nowValue = nowIso();\n const from = parseRangeBound(options.from, nowValue, \"--from\");\n const to = parseRangeBound(options.to, nowValue, \"--to\");\n if (from && to && compareTimestampStrings(from, to) >= 0) {\n throw new PmCliError(\n \"Activity --from must be before --to\",\n EXIT_CODE.USAGE,\n );\n }\n return {\n id: parseNonEmptyFilter(options.id, \"Activity --id\"),\n op: parseNonEmptyFilter(options.op, \"Activity --op\"),\n author: parseNonEmptyFilter(options.author, \"Activity --author\"),\n from,\n to,\n limit: parseLimit(options.limit),\n };\n}\n\nasync function resolveActivityRuntimeContext(\n global: GlobalOptions,\n): Promise<ActivityRuntimeContext> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(\n `Tracker is not initialized at ${pmRoot}. Run pm init first.`,\n EXIT_CODE.NOT_FOUND,\n );\n }\n return {\n pmRoot,\n settings: await readSettings(pmRoot),\n };\n}\n\nasync function prepareActivityHistoryRead(\n context: ActivityRuntimeContext,\n): Promise<string> {\n const typeRegistry = resolveItemTypeRegistry(\n context.settings,\n getActiveExtensionRegistrations(),\n );\n const items = await listAllItemMetadataLight(\n context.pmRoot,\n context.settings.item_format,\n typeRegistry.type_to_folder,\n undefined,\n context.settings.schema,\n );\n await enforceHistoryStreamPolicyForItems({\n pmRoot: context.pmRoot,\n settings: context.settings,\n itemIds: items.map((item) => item.id),\n commandLabel: \"activity\",\n });\n const historyDir = path.join(context.pmRoot, \"history\");\n await runActiveOnReadHooks({\n path: historyDir,\n scope: \"project\",\n });\n return historyDir;\n}\n\nfunction includeActivityEntry(\n entry: HistoryEntry,\n candidate: ActivityEntry,\n filters: ActivityFilters,\n): boolean {\n // Preserve legacy filter semantics: op/author filters compare the raw\n // history row before missing metadata is normalized to \"unknown\" for display.\n if (filters.op && entry.op !== filters.op) {\n return false;\n }\n if (filters.author && entry.author !== filters.author) {\n return false;\n }\n return includeByTimeWindow(candidate, filters.from, filters.to);\n}\n\nasync function collectActivityEntries(\n historyDir: string,\n filters: ActivityFilters,\n): Promise<ActivityEntry[]> {\n const combined: ActivityEntry[] = [];\n for (const file of await listHistoryFiles(historyDir)) {\n const id = file.slice(0, -\".jsonl\".length);\n if (filters.id && id !== filters.id) {\n continue;\n }\n const entries = await readHistoryEntries(path.join(historyDir, file), id);\n for (const entry of entries) {\n const candidate = normalizeActivityEntry(id, entry);\n if (includeActivityEntry(entry, candidate, filters)) {\n combined.push(candidate);\n }\n }\n }\n return combined;\n}\n\nfunction formatCompactActivity(\n activity: ActivityEntry[],\n): CompactActivityEntry[] {\n return activity.map(\n (entry): CompactActivityEntry => ({\n id: entry.id,\n op: entry.op,\n ts: entry.ts,\n author: entry.author,\n ...(entry.message ? { msg: entry.message } : {}),\n }),\n );\n}\n\n/** Public contract for test only, shared by SDK and presentation-layer consumers. */\nexport const _testOnly = {\n parseNonEmptyFilter,\n parseRangeBound,\n includeByTimeWindow,\n limitEntries,\n readActivityString,\n normalizeActivityEntry,\n sortActivity,\n listHistoryFiles,\n};\n\n/** Implements run activity for the public runtime surface of this module. */\nexport async function runActivity(\n options: ActivityCommandOptions,\n global: GlobalOptions,\n): Promise<ActivityResult> {\n const context = await resolveActivityRuntimeContext(global);\n const filters = resolveActivityFilters(options);\n const historyDir = await prepareActivityHistoryRead(context);\n const activity = limitEntries(\n sortActivity(await collectActivityEntries(historyDir, filters)),\n filters.limit,\n );\n const compact = options.compact === true;\n const compactActivity = compact ? formatCompactActivity(activity) : undefined;\n return {\n activity: compact ? [] : activity,\n compact_activity: compactActivity,\n compact,\n count: activity.length,\n limit: filters.limit ?? null,\n };\n}\n", "/**\n * @module cli/commands/calendar\n *\n * Implements the pm calendar command surface and its agent-facing runtime behavior.\n */\nimport { encode as encodeToon } from \"@toon-format/toon\";\nimport { pathExists } from \"../../core/fs/fs-utils.js\";\nimport { getActiveExtensionRegistrations } from \"../../core/extensions/index.js\";\nimport {\n resolveItemTypeRegistry,\n type ItemTypeRegistry,\n} from \"../../core/item/type-registry.js\";\nimport {\n parseIntegerLimit,\n parsePriority,\n parseType,\n} from \"../shared-parsers.js\";\nimport { normalizeStatusInput } from \"../../core/item/status.js\";\nimport {\n collectRuntimeFilterValues,\n matchesRuntimeFilters,\n} from \"../../core/schema/runtime-field-filters.js\";\nimport {\n resolveRuntimeFieldRegistry,\n resolveRuntimeStatusRegistry,\n type RuntimeStatusRegistry,\n} from \"../../core/schema/runtime-schema.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { levenshteinDistanceWithinLimit } from \"../../core/shared/levenshtein.js\";\nimport {\n compareTimestampStrings,\n nowIso,\n resolveIsoOrRelative,\n} from \"../../core/shared/time.js\";\nimport { listAllItemMetadataLight } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport type {\n ItemMetadata,\n ItemStatus,\n ItemType,\n RecurrenceRule,\n} from \"../../types/index.js\";\nimport {\n RECURRENCE_WEEKDAY_VALUES,\n weekdayOrderIndex,\n} from \"../../types/index.js\";\n\nconst CALENDAR_VIEW_VALUES = [\"agenda\", \"day\", \"week\", \"month\"] as const;\n/** Restricts calendar view values accepted by command, SDK, and storage contracts. */\nexport type CalendarView = (typeof CALENDAR_VIEW_VALUES)[number];\n\nconst CALENDAR_OUTPUT_VALUES = [\"markdown\", \"toon\", \"json\"] as const;\n/** Restricts calendar output format values accepted by command, SDK, and storage contracts. */\nexport type CalendarOutputFormat = (typeof CALENDAR_OUTPUT_VALUES)[number];\n\n/** Documents the calendar options payload exchanged by command, SDK, and package integrations. */\nexport interface CalendarOptions {\n /** Value that configures or reports view for this contract. */\n view?: string;\n /** Value that configures or reports date for this contract. */\n date?: string;\n /** Value that configures or reports from for this contract. */\n from?: string;\n /** Value that configures or reports to for this contract. */\n to?: string;\n /** Value that configures or reports past for this contract. */\n past?: boolean;\n /** Value that configures or reports full period for this contract. */\n fullPeriod?: boolean;\n /** Value that configures or reports limit for this contract. */\n limit?: string;\n /** Schema type that determines the shape and validation rules for this value. */\n type?: string;\n /** Value that configures or reports tag for this contract. */\n tag?: string;\n /** Value that configures or reports priority for this contract. */\n priority?: string;\n /** Lifecycle state reported for status. */\n status?: string;\n /** Value that configures or reports assignee for this contract. */\n assignee?: string;\n /** Value that configures or reports assignee filter for this contract. */\n assigneeFilter?: string;\n /** Value that configures or reports sprint for this contract. */\n sprint?: string;\n /** Value that configures or reports release for this contract. */\n release?: string;\n /** Value that configures or reports include for this contract. */\n include?: string;\n /** Value that configures or reports recurrence lookahead days for this contract. */\n recurrenceLookaheadDays?: string;\n /** Value that configures or reports recurrence lookback days for this contract. */\n recurrenceLookbackDays?: string;\n /** Value that configures or reports occurrence limit for this contract. */\n occurrenceLimit?: string;\n /** Value that configures or reports format for this contract. */\n format?: string;\n [key: string]: unknown;\n}\n\n/** Documents the calendar row payload exchanged by command, SDK, and package integrations. */\nexport interface CalendarRow {\n /** Value that configures or reports at for this contract. */\n at: string;\n /** Value that configures or reports date for this contract. */\n date: string;\n /** Value that configures or reports kind for this contract. */\n kind: \"deadline\" | \"reminder\" | \"event\";\n /** Value that configures or reports reminder text for this contract. */\n reminder_text: string | null;\n /** Value that configures or reports event title for this contract. */\n event_title: string | null;\n /** Value that configures or reports event end for this contract. */\n event_end: string | null;\n /** Value that configures or reports event location for this contract. */\n event_location: string | null;\n /** Value that configures or reports event all day for this contract. */\n event_all_day: boolean | null;\n /** Value that configures or reports event timezone for this contract. */\n event_timezone: string | null;\n /** Value that configures or reports event recurring for this contract. */\n event_recurring: boolean | null;\n /** Value that configures or reports event recurrence rule for this contract. */\n event_recurrence_rule: string | null;\n /** Value that configures or reports item id for this contract. */\n item_id: string;\n /** Value that configures or reports item title for this contract. */\n item_title: string;\n /** Schema type that determines the shape and validation rules for this value. */\n item_type: ItemType;\n /** Lifecycle state reported for itemthe record. */\n item_status: ItemStatus;\n /** Value that configures or reports item priority for this contract. */\n item_priority: number;\n /** Value that configures or reports item assignee for this contract. */\n item_assignee: string | null;\n /** Value that configures or reports item deadline for this contract. */\n item_deadline: string | null;\n /** Value that configures or reports item tags for this contract. */\n item_tags: string[];\n}\n\n/** Documents the calendar day bucket payload exchanged by command, SDK, and package integrations. */\nexport interface CalendarDayBucket {\n /** Value that configures or reports date for this contract. */\n date: string;\n /** Value that configures or reports count for this contract. */\n count: number;\n /** Value that configures or reports events for this contract. */\n events: CalendarRow[];\n}\n\n/** Documents the calendar result payload exchanged by command, SDK, and package integrations. */\nexport interface CalendarResult {\n /** Value that configures or reports view for this contract. */\n view: CalendarView;\n /** Value that configures or reports output default for this contract. */\n output_default: \"markdown\";\n /** Value that configures or reports now for this contract. */\n now: string;\n /** Value that configures or reports anchor for this contract. */\n anchor: string;\n /** Value that configures or reports range for this contract. */\n range: {\n start: string | null;\n end: string | null;\n period_start: string | null;\n period_end: string | null;\n full_period: boolean;\n past: boolean;\n from: string | null;\n to: string | null;\n };\n /** Value that configures or reports filters for this contract. */\n filters: {\n type: string | null;\n tag: string | null;\n priority: string | null;\n status: string | null;\n assignee: string | null;\n assignee_filter: string | null;\n sprint: string | null;\n release: string | null;\n runtime_filters?: Record<string, unknown>;\n limit: string | null;\n include: string | null;\n full_period: string | null;\n recurrence_lookahead_days: string | null;\n recurrence_lookback_days: string | null;\n occurrence_limit: string | null;\n };\n /** Value that configures or reports summary for this contract. */\n summary: {\n events: number;\n items: number;\n deadlines: number;\n reminders: number;\n scheduled: number;\n by_kind: {\n deadline: number;\n reminder: number;\n event: number;\n };\n by_type: Record<string, number>;\n by_status: Record<string, number>;\n recurring_events: number;\n };\n /** Value that configures or reports events for this contract. */\n events: CalendarRow[];\n /** Value that configures or reports days for this contract. */\n days: CalendarDayBucket[];\n /** Value that configures or reports warnings for this contract. */\n warnings?: string[];\n}\n\nconst UTC_DAY_TO_WEEKDAY = [\n \"sun\",\n \"mon\",\n \"tue\",\n \"wed\",\n \"thu\",\n \"fri\",\n \"sat\",\n] as const;\nconst DEFAULT_RECURRENCE_LOOKAHEAD_DAYS = 365;\nconst DEFAULT_RECURRENCE_LOOKBACK_DAYS = 365;\nconst DEFAULT_EVENTS_ONLY_LOOKAHEAD_DAYS = 28;\nconst MAX_RECURRENCE_OCCURRENCES = 1000;\n\nfunction parseNonNegativeInteger(\n raw: string | undefined,\n label: string,\n): number | undefined {\n if (raw === undefined) return undefined;\n const parsed = Number(raw);\n if (!Number.isInteger(parsed) || parsed < 0) {\n throw new PmCliError(\n `${label} must be a non-negative integer`,\n EXIT_CODE.USAGE,\n );\n }\n return parsed;\n}\n\ntype CalendarIncludeKind = \"deadlines\" | \"reminders\" | \"events\";\n\nfunction parseIncludeSources(\n raw: string | undefined,\n): Set<CalendarIncludeKind> {\n if (!raw) {\n return new Set([\"deadlines\", \"reminders\", \"events\"]);\n }\n const normalized = raw.trim().toLowerCase();\n if (normalized === \"all\") {\n return new Set([\"deadlines\", \"reminders\", \"events\"]);\n }\n const values = normalized\n .split(/[|,]/)\n .map((value) => value.trim())\n .filter((value) => value.length > 0);\n if (values.length === 0) {\n throw new PmCliError(\n \"Calendar include filter must not be empty\",\n EXIT_CODE.USAGE,\n );\n }\n const include = new Set<CalendarIncludeKind>();\n for (const value of values) {\n if (value === \"deadlines\" || value === \"deadline\") {\n include.add(\"deadlines\");\n continue;\n }\n if (value === \"reminders\" || value === \"reminder\") {\n include.add(\"reminders\");\n continue;\n }\n if (value === \"events\" || value === \"event\" || value === \"scheduled\") {\n include.add(\"events\");\n continue;\n }\n throw new PmCliError(\n \"Calendar include filter must be deadlines|reminders|events|scheduled|all\",\n EXIT_CODE.USAGE,\n );\n }\n return include;\n}\n\n/** Suggest the closest valid choice for a mistyped enum value (within edit distance 2) so an agent gets an actionable \"did you mean\" hint instead of just a list of choices (never-block UX). */\nfunction suggestClosestChoice(\n value: string,\n choices: readonly string[],\n): string | undefined {\n let best: { choice: string; distance: number } | undefined;\n for (const choice of choices) {\n const distance = levenshteinDistanceWithinLimit(value, choice, 2);\n if (distance !== null && (best === undefined || distance < best.distance)) {\n best = { choice, distance };\n }\n }\n return best?.choice;\n}\n\nfunction parseView(raw: string | undefined): CalendarView {\n if (!raw) return \"agenda\";\n const normalized = raw.trim().toLowerCase();\n if (!CALENDAR_VIEW_VALUES.includes(normalized as CalendarView)) {\n const suggestion = suggestClosestChoice(normalized, CALENDAR_VIEW_VALUES);\n throw new PmCliError(\n `Calendar view must be one of ${CALENDAR_VIEW_VALUES.join(\"|\")}${suggestion ? `. Did you mean \"${suggestion}\"?` : \".\"}`,\n EXIT_CODE.USAGE,\n );\n }\n return normalized as CalendarView;\n}\n\nfunction parseOutputFormat(\n raw: string | undefined,\n): CalendarOutputFormat | undefined {\n if (!raw) return undefined;\n const normalized = raw.trim().toLowerCase();\n if (!CALENDAR_OUTPUT_VALUES.includes(normalized as CalendarOutputFormat)) {\n const suggestion = suggestClosestChoice(normalized, CALENDAR_OUTPUT_VALUES);\n throw new PmCliError(\n `Calendar format must be one of ${CALENDAR_OUTPUT_VALUES.join(\"|\")}${suggestion ? `. Did you mean \"${suggestion}\"?` : \".\"}`,\n EXIT_CODE.USAGE,\n );\n }\n return normalized as CalendarOutputFormat;\n}\n\n/** Implements resolve calendar output format for the public runtime surface of this module. */\nexport function resolveCalendarOutputFormat(\n options: CalendarOptions,\n global: GlobalOptions,\n): CalendarOutputFormat {\n const commandFormat = parseOutputFormat(options.format);\n if (global.json && commandFormat && commandFormat !== \"json\") {\n throw new PmCliError(\n \"Cannot combine --json with --format markdown|toon\",\n EXIT_CODE.USAGE,\n );\n }\n if (global.json) {\n return \"json\";\n }\n return commandFormat ?? \"markdown\";\n}\n\nfunction parseStatus(\n raw: string | undefined,\n statusRegistry: RuntimeStatusRegistry,\n): ItemStatus | undefined {\n if (raw === undefined) return undefined;\n const normalized = normalizeStatusInput(raw, statusRegistry);\n if (!normalized) {\n const allowedStatuses = statusRegistry.definitions.map(\n (definition) => definition.id,\n );\n throw new PmCliError(\n `Calendar status filter must be one of ${allowedStatuses.join(\"|\")}`,\n EXIT_CODE.USAGE,\n );\n }\n return normalized;\n}\n\nfunction parseAssigneeFilter(\n raw: string | undefined,\n): \"assigned\" | \"unassigned\" | undefined {\n if (raw === undefined) {\n return undefined;\n }\n const normalized = raw.trim().toLowerCase();\n if (!normalized) {\n throw new PmCliError(\n \"Calendar assignee filter must be one of assigned|unassigned\",\n EXIT_CODE.USAGE,\n );\n }\n if (normalized !== \"assigned\" && normalized !== \"unassigned\") {\n throw new PmCliError(\n `Invalid calendar assignee filter \"${raw}\". Allowed: assigned|unassigned`,\n EXIT_CODE.USAGE,\n );\n }\n return normalized;\n}\n\nfunction toUtcDayKey(timestamp: string): string {\n return new Date(timestamp).toISOString().slice(0, 10);\n}\n\n/** Calendar day (YYYY-MM-DD) the instant falls on in the given IANA timezone. Events carry an optional `timezone`; bucketing and clock rendering use it so a 23:30Z instant tagged Asia/Tokyo correctly lands on the next local day rather than the UTC day. Falls back to the UTC day when no/invalid timezone is given, so existing UTC behavior is unchanged. Uses Intl (no timezone dependency). */\nfunction toLocalDayKey(timestamp: string, timezone?: string | null): string {\n if (!timezone || timezone === \"UTC\") {\n return toUtcDayKey(timestamp);\n }\n try {\n const parts = new Intl.DateTimeFormat(\"en-CA\", {\n timeZone: timezone,\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n }).formatToParts(new Date(timestamp));\n const year = parts.find((part) => part.type === \"year\")?.value;\n const month = parts.find((part) => part.type === \"month\")?.value;\n const day = parts.find((part) => part.type === \"day\")?.value;\n if (year && month && day) {\n return `${year}-${month}-${day}`;\n }\n } catch {\n // Invalid IANA zone — fall back to the UTC day key below.\n }\n return toUtcDayKey(timestamp);\n}\n\nfunction startOfUtcDay(timestamp: string): string {\n const date = new Date(timestamp);\n return new Date(\n Date.UTC(\n date.getUTCFullYear(),\n date.getUTCMonth(),\n date.getUTCDate(),\n 0,\n 0,\n 0,\n 0,\n ),\n ).toISOString();\n}\n\nfunction addUtcDays(timestamp: string, days: number): string {\n const date = new Date(timestamp);\n return new Date(date.getTime() + days * 24 * 60 * 60 * 1000).toISOString();\n}\n\nfunction startOfUtcWeekMonday(timestamp: string): string {\n const base = new Date(startOfUtcDay(timestamp));\n const day = base.getUTCDay();\n const delta = day === 0 ? -6 : 1 - day;\n return addUtcDays(base.toISOString(), delta);\n}\n\nfunction startOfUtcMonth(timestamp: string): string {\n const date = new Date(timestamp);\n return new Date(\n Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), 1, 0, 0, 0, 0),\n ).toISOString();\n}\n\nfunction startOfNextUtcMonth(timestamp: string): string {\n const date = new Date(timestamp);\n return new Date(\n Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + 1, 1, 0, 0, 0, 0),\n ).toISOString();\n}\n\nfunction maxTimestamp(left: string, right: string): string {\n return compareTimestampStrings(left, right) >= 0 ? left : right;\n}\n\nfunction toSortedCountRecord(\n values: Map<string, number>,\n): Record<string, number> {\n return Object.fromEntries(\n [...values.entries()].sort(([left], [right]) => left.localeCompare(right)),\n );\n}\n\nfunction incrementCount(values: Map<string, number>, key: string): void {\n values.set(key, (values.get(key) ?? 0) + 1);\n}\n\nfunction formatRecurrenceRuleForSummary(\n rule: RecurrenceRule | undefined,\n): string | null {\n if (!rule) {\n return null;\n }\n const parts: string[] = [`freq=${rule.freq}`];\n if (rule.interval !== undefined) {\n parts.push(`interval=${rule.interval}`);\n }\n if (rule.count !== undefined) {\n parts.push(`count=${rule.count}`);\n }\n if (rule.until) {\n parts.push(`until=${rule.until}`);\n }\n if (rule.by_weekday && rule.by_weekday.length > 0) {\n const weekdays = [...rule.by_weekday].sort(\n (left, right) => weekdayOrderIndex(left) - weekdayOrderIndex(right),\n );\n parts.push(`by_weekday=${weekdays.join(\"|\")}`);\n }\n if (rule.by_month_day && rule.by_month_day.length > 0) {\n const monthDays = [...rule.by_month_day].sort(\n (left, right) => left - right,\n );\n parts.push(`by_month_day=${monthDays.join(\"|\")}`);\n }\n if (rule.exdates && rule.exdates.length > 0) {\n const exdates = [...rule.exdates].sort((left, right) =>\n left.localeCompare(right),\n );\n parts.push(`exdates=${exdates.join(\"|\")}`);\n }\n return parts.join(\",\");\n}\n\nfunction buildUtcTimestamp(\n year: number,\n month: number,\n day: number,\n timeSource: Date,\n): string | undefined {\n const candidate = new Date(\n Date.UTC(\n year,\n month,\n day,\n timeSource.getUTCHours(),\n timeSource.getUTCMinutes(),\n timeSource.getUTCSeconds(),\n timeSource.getUTCMilliseconds(),\n ),\n );\n if (\n candidate.getUTCFullYear() !== year ||\n candidate.getUTCMonth() !== month ||\n candidate.getUTCDate() !== day\n ) {\n return undefined;\n }\n return candidate.toISOString();\n}\n\nfunction weekdayToken(timestamp: string): (typeof UTC_DAY_TO_WEEKDAY)[number] {\n return UTC_DAY_TO_WEEKDAY[new Date(timestamp).getUTCDay()];\n}\n\nfunction normalizeInstantKey(timestamp: string): string | null {\n const parsed = Date.parse(timestamp);\n return Number.isFinite(parsed) ? new Date(parsed).toISOString() : null;\n}\n\nfunction buildExcludedInstantSet(\n exdates: readonly string[] | undefined,\n): Set<string> {\n const excluded = new Set<string>();\n for (const exdate of exdates ?? []) {\n const instantKey = normalizeInstantKey(exdate);\n if (instantKey) {\n excluded.add(instantKey);\n }\n }\n return excluded;\n}\n\nfunction buildRecurringEventWindow(\n start: string | undefined,\n end: string | undefined,\n nowValue: string,\n lookbackDays: number | undefined,\n lookaheadDays: number | undefined,\n): { start: string; end: string } {\n const windowStart =\n start ??\n addUtcDays(nowValue, -(lookbackDays ?? DEFAULT_RECURRENCE_LOOKBACK_DAYS));\n const windowEnd =\n end ??\n addUtcDays(\n start ?? nowValue,\n lookaheadDays ?? DEFAULT_RECURRENCE_LOOKAHEAD_DAYS,\n );\n return {\n start: windowStart,\n end:\n compareTimestampStrings(windowEnd, windowStart) > 0\n ? windowEnd\n : addUtcDays(windowStart, 1),\n };\n}\n\ninterface RecurrenceExpansionContext {\n startAt: string;\n startDate: Date;\n window: { start: string; end: string };\n maxOccurrences: number;\n interval: number;\n countLimit: number;\n until: string | undefined;\n excluded: Set<string>;\n weekdayFilter: Set<string> | undefined;\n monthDayFilter: Set<number> | undefined;\n sortedWeekdays: Array<(typeof RECURRENCE_WEEKDAY_VALUES)[number]>;\n sortedMonthDays: number[];\n occurrences: string[];\n produced: number;\n}\n\nfunction buildRecurrenceExpansionContext(\n startAt: string,\n recurrence: RecurrenceRule,\n window: { start: string; end: string },\n occurrenceLimit: number | undefined,\n): RecurrenceExpansionContext {\n // Omitted filters default to the series start; explicit empty filters intentionally match no occurrences.\n const recurrenceWeekdays =\n recurrence.by_weekday !== undefined\n ? [...recurrence.by_weekday]\n : [weekdayToken(startAt)];\n const recurrenceMonthDays =\n recurrence.by_month_day !== undefined\n ? [...recurrence.by_month_day]\n : [new Date(startAt).getUTCDate()];\n return {\n startAt,\n startDate: new Date(startAt),\n window,\n maxOccurrences: occurrenceLimit ?? MAX_RECURRENCE_OCCURRENCES,\n interval: recurrence.interval ?? 1,\n countLimit: recurrence.count ?? Number.POSITIVE_INFINITY,\n until: recurrence.until,\n excluded: buildExcludedInstantSet(recurrence.exdates),\n weekdayFilter:\n recurrence.by_weekday !== undefined\n ? new Set(recurrence.by_weekday)\n : undefined,\n monthDayFilter:\n recurrence.by_month_day !== undefined\n ? new Set(recurrence.by_month_day)\n : undefined,\n sortedWeekdays: [...new Set(recurrenceWeekdays)].sort(\n (left, right) => weekdayOrderIndex(left) - weekdayOrderIndex(right),\n ),\n sortedMonthDays: [...new Set(recurrenceMonthDays)].sort(\n (left, right) => left - right,\n ),\n occurrences: [],\n produced: 0,\n };\n}\n\nfunction consumeRecurrenceCandidate(\n context: RecurrenceExpansionContext,\n candidateAt: string,\n): \"continue\" | \"stop\" {\n if (compareTimestampStrings(candidateAt, context.startAt) < 0) {\n return \"continue\";\n }\n if (\n context.until &&\n compareTimestampStrings(candidateAt, context.until) > 0\n ) {\n return \"stop\";\n }\n if (compareTimestampStrings(candidateAt, context.window.end) >= 0) {\n return \"stop\";\n }\n if (context.excluded.has(candidateAt)) {\n return \"continue\";\n }\n context.produced += 1;\n if (compareTimestampStrings(candidateAt, context.window.start) >= 0) {\n context.occurrences.push(candidateAt);\n }\n return context.produced >= context.countLimit ||\n context.occurrences.length >= context.maxOccurrences\n ? \"stop\"\n : \"continue\";\n}\n\nfunction recurrenceDayMatchesFilters(\n context: RecurrenceExpansionContext,\n candidateAt: string,\n): boolean {\n const candidateWeekday = weekdayToken(candidateAt);\n const candidateMonthDay = new Date(candidateAt).getUTCDate();\n const weekdayMatches =\n !context.weekdayFilter || context.weekdayFilter.has(candidateWeekday);\n const monthDayMatches =\n !context.monthDayFilter || context.monthDayFilter.has(candidateMonthDay);\n return weekdayMatches && monthDayMatches;\n}\n\nfunction expandDailyOccurrences(context: RecurrenceExpansionContext): string[] {\n let candidateAt = context.startAt;\n for (let iteration = 0; iteration < context.maxOccurrences; iteration += 1) {\n if (\n recurrenceDayMatchesFilters(context, candidateAt) &&\n consumeRecurrenceCandidate(context, candidateAt) === \"stop\"\n ) {\n break;\n }\n candidateAt = addUtcDays(candidateAt, context.interval);\n }\n return context.occurrences;\n}\n\nfunction buildWeeklyCandidateAt(\n context: RecurrenceExpansionContext,\n candidateWeekStart: string,\n weekday: string,\n): string {\n const dayOffset = weekdayOrderIndex(\n weekday as (typeof RECURRENCE_WEEKDAY_VALUES)[number],\n );\n const candidateDay = addUtcDays(candidateWeekStart, dayOffset);\n const dayDate = new Date(candidateDay);\n return new Date(\n Date.UTC(\n dayDate.getUTCFullYear(),\n dayDate.getUTCMonth(),\n dayDate.getUTCDate(),\n context.startDate.getUTCHours(),\n context.startDate.getUTCMinutes(),\n context.startDate.getUTCSeconds(),\n context.startDate.getUTCMilliseconds(),\n ),\n ).toISOString();\n}\n\nfunction expandWeeklyOccurrences(\n context: RecurrenceExpansionContext,\n): string[] {\n const weekStart = startOfUtcWeekMonday(context.startAt);\n for (let step = 0; step < context.maxOccurrences; step += 1) {\n const candidateWeekStart = addUtcDays(\n weekStart,\n step * context.interval * 7,\n );\n for (const weekday of context.sortedWeekdays) {\n const candidateAt = buildWeeklyCandidateAt(\n context,\n candidateWeekStart,\n weekday,\n );\n if (!recurrenceDayMatchesFilters(context, candidateAt)) {\n continue;\n }\n if (consumeRecurrenceCandidate(context, candidateAt) === \"stop\") {\n return context.occurrences;\n }\n }\n }\n return context.occurrences;\n}\n\nfunction expandMonthlyOccurrences(\n context: RecurrenceExpansionContext,\n): string[] {\n const startYear = context.startDate.getUTCFullYear();\n const startMonth = context.startDate.getUTCMonth();\n for (let step = 0; step < context.maxOccurrences; step += 1) {\n const monthAnchor = new Date(\n Date.UTC(startYear, startMonth + step * context.interval, 1, 0, 0, 0, 0),\n );\n for (const monthDay of context.sortedMonthDays) {\n const candidateAt = buildUtcTimestamp(\n monthAnchor.getUTCFullYear(),\n monthAnchor.getUTCMonth(),\n monthDay,\n context.startDate,\n );\n if (!candidateAt || !recurrenceDayMatchesFilters(context, candidateAt)) {\n continue;\n }\n if (consumeRecurrenceCandidate(context, candidateAt) === \"stop\") {\n return context.occurrences;\n }\n }\n }\n return context.occurrences;\n}\n\nfunction expandYearlyOccurrences(\n context: RecurrenceExpansionContext,\n): string[] {\n const year = context.startDate.getUTCFullYear();\n const month = context.startDate.getUTCMonth();\n for (let step = 0; step < context.maxOccurrences; step += 1) {\n const candidateYear = year + step * context.interval;\n for (const monthDay of context.sortedMonthDays) {\n const candidateAt = buildUtcTimestamp(\n candidateYear,\n month,\n monthDay,\n context.startDate,\n );\n if (!candidateAt || !recurrenceDayMatchesFilters(context, candidateAt)) {\n continue;\n }\n if (consumeRecurrenceCandidate(context, candidateAt) === \"stop\") {\n return context.occurrences;\n }\n }\n }\n return context.occurrences;\n}\n\nfunction expandRecurringOccurrences(\n startAt: string,\n recurrence: RecurrenceRule,\n window: { start: string; end: string },\n occurrenceLimit: number | undefined,\n): string[] {\n const context = buildRecurrenceExpansionContext(\n startAt,\n recurrence,\n window,\n occurrenceLimit,\n );\n if (recurrence.freq === \"daily\") {\n return expandDailyOccurrences(context);\n }\n\n if (recurrence.freq === \"weekly\") {\n return expandWeeklyOccurrences(context);\n }\n\n if (recurrence.freq === \"monthly\") {\n return expandMonthlyOccurrences(context);\n }\n\n return expandYearlyOccurrences(context);\n}\n\nfunction sortEvents(values: CalendarRow[]): CalendarRow[] {\n return [...values].sort((a, b) => {\n const byAt = compareTimestampStrings(a.at, b.at);\n if (byAt !== 0) return byAt;\n const byPriority = a.item_priority - b.item_priority;\n if (byPriority !== 0) return byPriority;\n const byId = a.item_id.localeCompare(b.item_id);\n if (byId !== 0) return byId;\n const byKind = a.kind.localeCompare(b.kind);\n if (byKind !== 0) return byKind;\n const byEventTitle = String(a.event_title).localeCompare(\n String(b.event_title),\n );\n if (byEventTitle !== 0) return byEventTitle;\n return String(a.reminder_text).localeCompare(String(b.reminder_text));\n });\n}\n\nfunction buildItemCalendarRowBase(\n item: ItemMetadata,\n): Pick<\n CalendarRow,\n | \"item_id\"\n | \"item_title\"\n | \"item_type\"\n | \"item_status\"\n | \"item_priority\"\n | \"item_assignee\"\n | \"item_deadline\"\n | \"item_tags\"\n> {\n return {\n item_id: item.id,\n item_title: item.title,\n item_type: item.type,\n item_status: item.status,\n item_priority: item.priority,\n item_assignee: item.assignee ?? null,\n item_deadline: item.deadline ?? null,\n item_tags: item.tags,\n };\n}\n\nfunction buildDeadlineRow(item: ItemMetadata): CalendarRow | null {\n if (!item.deadline) {\n return null;\n }\n return {\n at: item.deadline,\n date: toUtcDayKey(item.deadline),\n kind: \"deadline\",\n reminder_text: null,\n event_title: null,\n event_end: null,\n event_location: null,\n event_all_day: null,\n event_timezone: null,\n event_recurring: null,\n event_recurrence_rule: null,\n ...buildItemCalendarRowBase(item),\n item_deadline: item.deadline,\n };\n}\n\nfunction buildReminderRows(item: ItemMetadata): CalendarRow[] {\n return (item.reminders ?? []).map((reminder) => ({\n at: reminder.at,\n date: toUtcDayKey(reminder.at),\n kind: \"reminder\",\n reminder_text: reminder.text,\n event_title: null,\n event_end: null,\n event_location: null,\n event_all_day: null,\n event_timezone: null,\n event_recurring: null,\n event_recurrence_rule: null,\n ...buildItemCalendarRowBase(item),\n }));\n}\n\nfunction recurringDurationMs(\n startAt: string,\n endAt: string | undefined,\n): number | null {\n if (!endAt) {\n return null;\n }\n const duration = Date.parse(endAt) - Date.parse(startAt);\n return Number.isFinite(duration) && duration > 0 ? duration : null;\n}\n\nfunction eventOccurrenceEnd(\n occurrenceAt: string,\n event: NonNullable<ItemMetadata[\"events\"]>[number],\n durationMs: number | null,\n): string | null {\n return event.recurrence && durationMs !== null\n ? new Date(new Date(occurrenceAt).getTime() + durationMs).toISOString()\n : (event.end_at ?? null);\n}\n\nfunction buildScheduledEventRows(\n item: ItemMetadata,\n event: NonNullable<ItemMetadata[\"events\"]>[number],\n recurringWindow: { start: string; end: string },\n occurrenceLimit: number | undefined,\n): CalendarRow[] {\n const recurrenceRuleSummary = formatRecurrenceRuleForSummary(\n event.recurrence,\n );\n const durationMs = recurringDurationMs(event.start_at, event.end_at);\n const occurrences = event.recurrence\n ? expandRecurringOccurrences(\n event.start_at,\n event.recurrence,\n recurringWindow,\n occurrenceLimit,\n )\n : [event.start_at];\n return occurrences.map((occurrenceAt) => ({\n at: occurrenceAt,\n // All-day events are timezone-agnostic calendar dates: bucket by the\n // literal start date. Timed events bucket by their local day in the\n // event's timezone (defaults to UTC when unset).\n date:\n event.all_day === true\n ? occurrenceAt.slice(0, 10)\n : toLocalDayKey(occurrenceAt, event.timezone),\n kind: \"event\",\n reminder_text: event.description ?? null,\n event_title: event.title ?? item.title,\n event_end: eventOccurrenceEnd(occurrenceAt, event, durationMs),\n event_location: event.location ?? null,\n event_all_day: event.all_day ?? null,\n event_timezone: event.timezone ?? null,\n event_recurring: event.recurrence ? true : false,\n event_recurrence_rule: recurrenceRuleSummary,\n ...buildItemCalendarRowBase(item),\n }));\n}\n\nfunction buildEventSeed(\n items: ItemMetadata[],\n recurringWindow: { start: string; end: string },\n includeSources: Set<CalendarIncludeKind>,\n occurrenceLimit: number | undefined,\n): CalendarRow[] {\n const events: CalendarRow[] = [];\n for (const item of items) {\n const deadlineRow = includeSources.has(\"deadlines\")\n ? buildDeadlineRow(item)\n : null;\n if (deadlineRow) {\n events.push(deadlineRow);\n }\n if (includeSources.has(\"reminders\")) {\n events.push(...buildReminderRows(item));\n }\n for (const event of includeSources.has(\"events\")\n ? (item.events ?? [])\n : []) {\n events.push(\n ...buildScheduledEventRows(\n item,\n event,\n recurringWindow,\n occurrenceLimit,\n ),\n );\n }\n }\n return sortEvents(events);\n}\n\nfunction filterItems(\n items: ItemMetadata[],\n options: CalendarOptions,\n typeRegistry: ItemTypeRegistry,\n statusRegistry: RuntimeStatusRegistry,\n runtimeFieldFilters: Record<string, unknown>,\n): ItemMetadata[] {\n const typeFilter = parseType(options.type, typeRegistry);\n const tagFilter = options.tag?.trim().toLowerCase();\n const priorityFilter = parsePriority(options.priority);\n const statusFilter = parseStatus(options.status, statusRegistry);\n const assigneeFilter = options.assignee?.trim();\n const assigneeModeFilter = parseAssigneeFilter(options.assigneeFilter);\n const sprintFilter = options.sprint?.trim();\n const releaseFilter = options.release?.trim();\n\n if (\n assigneeFilter &&\n (assigneeFilter.toLowerCase() === \"none\" ||\n assigneeFilter.toLowerCase() === \"null\")\n ) {\n throw new PmCliError(\n '--assignee no longer accepts \"none\" or \"null\". Use --assignee-filter unassigned.',\n EXIT_CODE.USAGE,\n );\n }\n if (assigneeFilter !== undefined && assigneeModeFilter === \"unassigned\") {\n throw new PmCliError(\n \"Cannot combine --assignee with --assignee-filter unassigned\",\n EXIT_CODE.USAGE,\n );\n }\n\n return items.filter((item) =>\n itemMatchesCalendarFilters(item, {\n typeFilter,\n tagFilter,\n priorityFilter,\n statusFilter,\n assigneeFilter,\n assigneeModeFilter,\n sprintFilter,\n releaseFilter,\n runtimeFieldFilters,\n }),\n );\n}\n\nfunction itemMatchesCalendarFilters(\n item: ItemMetadata,\n filters: {\n typeFilter: ItemType | undefined;\n tagFilter: string | undefined;\n priorityFilter: number | undefined;\n statusFilter: ItemStatus | undefined;\n assigneeFilter: string | undefined;\n assigneeModeFilter: \"assigned\" | \"unassigned\" | undefined;\n sprintFilter: string | undefined;\n releaseFilter: string | undefined;\n runtimeFieldFilters: Record<string, unknown>;\n },\n): boolean {\n return (\n itemMatchesCalendarIdentityFilters(item, filters) &&\n itemMatchesCalendarOwnerFilters(item, filters) &&\n matchesRuntimeFilters(\n item as Record<string, unknown>,\n filters.runtimeFieldFilters,\n )\n );\n}\n\nfunction itemMatchesCalendarIdentityFilters(\n item: ItemMetadata,\n filters: Parameters<typeof itemMatchesCalendarFilters>[1],\n): boolean {\n if (filters.typeFilter && item.type !== filters.typeFilter) return false;\n if (\n filters.tagFilter &&\n !item.tags.some((tag) => tag.trim().toLowerCase() === filters.tagFilter)\n )\n return false;\n if (\n filters.priorityFilter !== undefined &&\n item.priority !== filters.priorityFilter\n )\n return false;\n if (filters.statusFilter && item.status !== filters.statusFilter)\n return false;\n return true;\n}\n\nfunction itemMatchesCalendarOwnerFilters(\n item: ItemMetadata,\n filters: Parameters<typeof itemMatchesCalendarFilters>[1],\n): boolean {\n if (filters.assigneeModeFilter === \"assigned\" && !item.assignee) return false;\n if (filters.assigneeModeFilter === \"unassigned\" && item.assignee)\n return false;\n if (\n filters.assigneeFilter !== undefined &&\n item.assignee !== filters.assigneeFilter\n )\n return false;\n if (\n filters.sprintFilter !== undefined &&\n item.sprint !== filters.sprintFilter\n )\n return false;\n if (\n filters.releaseFilter !== undefined &&\n item.release !== filters.releaseFilter\n )\n return false;\n return true;\n}\n\nfunction includeEventInWindow(\n event: CalendarRow,\n start: string | undefined,\n end: string | undefined,\n): boolean {\n if (start && compareTimestampStrings(event.at, start) < 0) {\n return false;\n }\n if (end && compareTimestampStrings(event.at, end) >= 0) {\n return false;\n }\n return true;\n}\n\nfunction resolveCalendarBoundaryInput(\n raw: string,\n nowValue: string,\n fieldLabel: \"--date\" | \"--from\" | \"--to\",\n): string {\n if (raw.trim().toLowerCase() === \"today\") {\n return startOfUtcDay(nowValue);\n }\n return resolveIsoOrRelative(raw, new Date(nowValue), fieldLabel);\n}\n\nfunction buildRange(\n view: CalendarView,\n options: CalendarOptions,\n nowValue: string,\n): {\n anchor: string;\n start?: string;\n end?: string;\n periodStart?: string;\n periodEnd?: string;\n fullPeriod: boolean;\n} {\n const anchor = options.date\n ? resolveCalendarBoundaryInput(options.date, nowValue, \"--date\")\n : nowValue;\n const includePast = options.past === true;\n const fullPeriodRequested = options.fullPeriod === true;\n\n const from = options.from\n ? resolveCalendarBoundaryInput(options.from, nowValue, \"--from\")\n : undefined;\n const to = options.to\n ? resolveCalendarBoundaryInput(options.to, nowValue, \"--to\")\n : undefined;\n if (from && to && compareTimestampStrings(from, to) >= 0) {\n throw new PmCliError(\n \"Calendar --from must be before --to\",\n EXIT_CODE.USAGE,\n );\n }\n\n if (\n view !== \"agenda\" &&\n (options.from !== undefined || options.to !== undefined)\n ) {\n throw new PmCliError(\n \"--from and --to are only supported for --view agenda\",\n EXIT_CODE.USAGE,\n );\n }\n\n if (view === \"agenda\") {\n return buildAgendaRange(\n anchor,\n options,\n nowValue,\n includePast,\n fullPeriodRequested,\n from,\n to,\n );\n }\n\n if (view === \"day\") {\n const dayStart = startOfUtcDay(anchor);\n return buildFixedPeriodRange(\n anchor,\n nowValue,\n includePast,\n fullPeriodRequested,\n dayStart,\n addUtcDays(dayStart, 1),\n );\n }\n\n if (view === \"week\") {\n const weekStart = startOfUtcWeekMonday(anchor);\n return buildFixedPeriodRange(\n anchor,\n nowValue,\n includePast,\n fullPeriodRequested,\n weekStart,\n addUtcDays(weekStart, 7),\n );\n }\n\n const monthStart = startOfUtcMonth(anchor);\n return buildFixedPeriodRange(\n anchor,\n nowValue,\n includePast,\n fullPeriodRequested,\n monthStart,\n startOfNextUtcMonth(anchor),\n );\n}\n\nfunction buildAgendaRange(\n anchor: string,\n options: CalendarOptions,\n nowValue: string,\n includePast: boolean,\n fullPeriodRequested: boolean,\n from: string | undefined,\n to: string | undefined,\n): ReturnType<typeof buildRange> {\n if (fullPeriodRequested) {\n throw new PmCliError(\n \"--full-period is only supported for --view day|week|month. For agenda windows, use --from and --to.\",\n EXIT_CODE.USAGE,\n );\n }\n return {\n anchor,\n start: from ?? (options.date ? anchor : includePast ? undefined : nowValue),\n end: to,\n fullPeriod: false,\n };\n}\n\nfunction buildFixedPeriodRange(\n anchor: string,\n nowValue: string,\n includePast: boolean,\n fullPeriodRequested: boolean,\n periodStart: string,\n periodEnd: string,\n): ReturnType<typeof buildRange> {\n const fullPeriod = includePast || fullPeriodRequested;\n return {\n anchor,\n start: fullPeriod ? periodStart : maxTimestamp(periodStart, nowValue),\n end: periodEnd,\n periodStart,\n periodEnd,\n fullPeriod,\n };\n}\n\nfunction bucketEventsByDay(events: CalendarRow[]): CalendarDayBucket[] {\n const dayMap = new Map<string, CalendarRow[]>();\n for (const event of events) {\n const list = dayMap.get(event.date) ?? [];\n list.push(event);\n dayMap.set(event.date, list);\n }\n return [...dayMap.entries()]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([date, dayEvents]) => ({\n date,\n count: dayEvents.length,\n events: sortEvents(dayEvents),\n }));\n}\n\nfunction summarize(events: CalendarRow[]): CalendarResult[\"summary\"] {\n const itemIds = new Set<string>();\n const byType = new Map<string, number>();\n const byStatus = new Map<string, number>();\n let deadlines = 0;\n let reminders = 0;\n let scheduled = 0;\n let recurringEvents = 0;\n for (const event of events) {\n itemIds.add(event.item_id);\n incrementCount(byType, event.item_type);\n incrementCount(byStatus, event.item_status);\n if (event.kind === \"deadline\") {\n deadlines += 1;\n } else if (event.kind === \"reminder\") {\n reminders += 1;\n } else {\n scheduled += 1;\n if (event.event_recurring === true) {\n recurringEvents += 1;\n }\n }\n }\n return {\n events: events.length,\n items: itemIds.size,\n deadlines,\n reminders,\n scheduled,\n by_kind: {\n deadline: deadlines,\n reminder: reminders,\n event: scheduled,\n },\n by_type: toSortedCountRecord(byType),\n by_status: toSortedCountRecord(byStatus),\n recurring_events: recurringEvents,\n };\n}\n\nfunction formatWindow(range: CalendarResult[\"range\"]): string {\n const start = range.start ?? \"unbounded\";\n const end = range.end ?? \"unbounded\";\n return `${start} -> ${end}`;\n}\n\nfunction formatClock(timestamp: string, timezone?: string | null): string {\n if (timezone && timezone !== \"UTC\") {\n try {\n const parts = new Intl.DateTimeFormat(\"en-GB\", {\n timeZone: timezone,\n hour: \"2-digit\",\n minute: \"2-digit\",\n hourCycle: \"h23\",\n }).formatToParts(new Date(timestamp));\n const hour = parts.find((part) => part.type === \"hour\")?.value;\n const minute = parts.find((part) => part.type === \"minute\")?.value;\n if (hour && minute) {\n // Local wall-clock time; the event line already prints `timezone=<zone>`.\n return `${hour}:${minute}`;\n }\n } catch {\n // Invalid IANA zone — fall back to the UTC clock below.\n }\n }\n return `${new Date(timestamp).toISOString().slice(11, 16)}Z`;\n}\n\nfunction formatSummaryCountRecord(values: Record<string, number>): string {\n const entries = Object.entries(values);\n if (entries.length === 0) {\n return \"empty\";\n }\n return entries.map(([key, value]) => `${key}=${value}`).join(\", \");\n}\n\nfunction formatEventEnd(event: CalendarRow): string | null {\n if (!event.event_end) {\n return null;\n }\n if (event.event_all_day === true) {\n return event.event_end.slice(0, 10);\n }\n if (event.date === toLocalDayKey(event.event_end, event.event_timezone)) {\n return formatClock(event.event_end, event.event_timezone);\n }\n return event.event_end;\n}\n\nfunction formatEventLine(event: CalendarRow): string {\n const core = `${formatClock(event.at, event.event_timezone)} [${event.kind}] ${event.item_id} type=${event.item_type} p${event.item_priority} ${event.item_status} ${event.item_title}`;\n if (event.kind === \"reminder\") {\n const reminderText = event.reminder_text ?? \"\";\n return `${core} — ${reminderText} reminder=${JSON.stringify(reminderText)}`;\n }\n if (event.kind === \"event\") {\n const details: string[] = [];\n const title = event.event_title ?? event.item_title;\n const titleDiffers =\n event.event_title !== null && event.event_title !== event.item_title;\n if (titleDiffers) {\n details.push(title);\n details.push(`title=${JSON.stringify(title)}`);\n }\n if (event.event_recurring) {\n details.push(\"(recurring)\");\n details.push(\"recurring=true\");\n }\n const end = formatEventEnd(event);\n if (end) {\n details.push(`end=${end}`);\n }\n if (event.event_all_day !== null) {\n details.push(`all_day=${event.event_all_day ? \"true\" : \"false\"}`);\n }\n if (event.event_timezone) {\n details.push(`timezone=${event.event_timezone}`);\n }\n if (event.event_location) {\n details.push(`@ ${event.event_location}`);\n details.push(`location=${JSON.stringify(event.event_location)}`);\n }\n if (event.event_recurrence_rule) {\n details.push(`recurrence=${event.event_recurrence_rule}`);\n }\n if (event.reminder_text) {\n details.push(`description=${JSON.stringify(event.reminder_text)}`);\n }\n return `${core} — ${details.join(\" \")}`;\n }\n return core;\n}\n\n/** Implements render calendar markdown for the public runtime surface of this module. */\nexport function renderCalendarMarkdown(result: CalendarResult): string {\n const lines: string[] = [];\n lines.push(`# pm calendar (${result.view})`);\n lines.push(\"\");\n lines.push(`- now: ${result.now}`);\n lines.push(`- window: ${formatWindow(result.range)}`);\n if (result.range.period_start && result.range.period_end) {\n lines.push(\n `- period: ${result.range.period_start} -> ${result.range.period_end}`,\n );\n lines.push(\n `- period-mode: ${result.range.full_period ? \"full-period\" : \"active-window\"}`,\n );\n }\n lines.push(\n `- events: ${result.summary.events} (deadlines: ${result.summary.deadlines}, reminders: ${result.summary.reminders}, scheduled: ${result.summary.scheduled})`,\n );\n lines.push(`- items: ${result.summary.items}`);\n lines.push(`- by-kind: ${formatSummaryCountRecord(result.summary.by_kind)}`);\n lines.push(`- by-type: ${formatSummaryCountRecord(result.summary.by_type)}`);\n lines.push(\n `- by-status: ${formatSummaryCountRecord(result.summary.by_status)}`,\n );\n lines.push(`- recurring-events: ${result.summary.recurring_events}`);\n lines.push(\"\");\n\n if (result.events.length === 0) {\n lines.push(\"No calendar events matched the selected filters.\");\n return lines.join(\"\\n\");\n }\n\n for (const day of result.days) {\n lines.push(`## ${day.date} (${day.count})`);\n for (const event of day.events) {\n lines.push(`- ${formatEventLine(event)}`);\n }\n lines.push(\"\");\n }\n if (result.warnings && result.warnings.length > 0) {\n lines.push(\"### warnings\");\n for (const warning of result.warnings) {\n lines.push(`- ${warning}`);\n }\n lines.push(\"\");\n }\n return trimTrailingNewlines(lines.join(\"\\n\"));\n}\n\n/**\n * Serializes a CalendarResult as TOON (the project's structured output format).\n *\n * The calendar result is JSON-serializable end-to-end (only strings, numbers,\n * booleans, null, plain objects, and arrays), so the value is fed directly to\n * `@toon-format/toon`'s encoder.\n */\nexport function renderCalendarToon(result: CalendarResult): string {\n return encodeToon(result as unknown as Parameters<typeof encodeToon>[0]);\n}\n\nfunction trimTrailingNewlines(value: string): string {\n let end = value.length;\n while (end > 0 && value[end - 1] === \"\\n\") {\n end -= 1;\n }\n return value.slice(0, end);\n}\n\ninterface CalendarExecutionInputs {\n nowValue: string;\n view: CalendarView;\n rangeBounds: ReturnType<typeof buildRange>;\n limit: number | undefined;\n includeSources: Set<CalendarIncludeKind>;\n occurrenceLimit: number | undefined;\n recurrenceLookaheadDays: number | undefined;\n recurrenceLookbackWindowDays: number | undefined;\n eventsOnlyCapApplied: boolean;\n}\n\nfunction resolveCalendarExecutionInputs(\n options: CalendarOptions,\n): CalendarExecutionInputs {\n const nowValue = nowIso();\n const view = parseView(options.view);\n const rangeBounds = buildRange(view, options, nowValue);\n const limit = parseIntegerLimit(options.limit);\n const includeSources = parseIncludeSources(options.include);\n const explicitLookahead = parseNonNegativeInteger(\n options.recurrenceLookaheadDays,\n \"Calendar recurrence lookahead days\",\n );\n const recurrenceLookbackDays = parseNonNegativeInteger(\n options.recurrenceLookbackDays,\n \"Calendar recurrence lookback days\",\n );\n const occurrenceLimit = parseNonNegativeInteger(\n options.occurrenceLimit,\n \"Calendar occurrence limit\",\n );\n if (occurrenceLimit !== undefined && occurrenceLimit < 1) {\n throw new PmCliError(\n \"Calendar occurrence limit must be >= 1\",\n EXIT_CODE.USAGE,\n );\n }\n const eventsOnly =\n includeSources.has(\"events\") &&\n !includeSources.has(\"deadlines\") &&\n !includeSources.has(\"reminders\");\n const hasExplicitBounds =\n options.to !== undefined ||\n explicitLookahead !== undefined ||\n recurrenceLookbackDays !== undefined ||\n occurrenceLimit !== undefined;\n const eventsOnlyCapApplied = eventsOnly && !hasExplicitBounds;\n return {\n nowValue,\n view,\n rangeBounds,\n limit,\n includeSources,\n occurrenceLimit,\n recurrenceLookaheadDays: eventsOnlyCapApplied\n ? DEFAULT_EVENTS_ONLY_LOOKAHEAD_DAYS\n : explicitLookahead,\n recurrenceLookbackWindowDays:\n eventsOnlyCapApplied && recurrenceLookbackDays === undefined\n ? 0\n : recurrenceLookbackDays,\n eventsOnlyCapApplied,\n };\n}\n\nfunction appendCalendarCapWarning(\n warnings: string[],\n capApplied: boolean,\n): void {\n if (!capApplied) {\n return;\n }\n warnings.push(\n `recurring_events_default_cap_applied:lookback=0d,lookahead=${DEFAULT_EVENTS_ONLY_LOOKAHEAD_DAYS}d -- use --recurrence-lookback-days/--recurrence-lookahead-days or --to for wider range`,\n );\n}\n\nfunction buildCalendarFiltersResult(\n options: CalendarOptions,\n runtimeFieldFilters: Record<string, unknown>,\n): CalendarResult[\"filters\"] {\n return {\n type: options.type ?? null,\n tag: options.tag ?? null,\n priority: options.priority ?? null,\n status: options.status ?? null,\n assignee: options.assignee ?? null,\n assignee_filter: options.assigneeFilter ?? null,\n sprint: options.sprint ?? null,\n release: options.release ?? null,\n runtime_filters: runtimeFieldFilters,\n limit: options.limit ?? null,\n include: options.include ?? null,\n full_period: options.fullPeriod === true ? \"true\" : null,\n recurrence_lookahead_days: options.recurrenceLookaheadDays ?? null,\n recurrence_lookback_days: options.recurrenceLookbackDays ?? null,\n occurrence_limit: options.occurrenceLimit ?? null,\n };\n}\n\nfunction buildCalendarRangeResult(\n options: CalendarOptions,\n rangeBounds: ReturnType<typeof buildRange>,\n): CalendarResult[\"range\"] {\n return {\n start: rangeBounds.start ?? null,\n end: rangeBounds.end ?? null,\n period_start: rangeBounds.periodStart ?? null,\n period_end: rangeBounds.periodEnd ?? null,\n full_period: rangeBounds.fullPeriod,\n past: options.past === true,\n from: options.from ?? null,\n to: options.to ?? null,\n };\n}\n\n/** Implements run calendar for the public runtime surface of this module. */\nexport async function runCalendar(\n options: CalendarOptions,\n global: GlobalOptions,\n): Promise<CalendarResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(\n `Tracker is not initialized at ${pmRoot}. Run pm init first.`,\n EXIT_CODE.NOT_FOUND,\n );\n }\n\n const inputs = resolveCalendarExecutionInputs(options);\n\n const settings = await readSettings(pmRoot);\n const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);\n const runtimeFieldRegistry = resolveRuntimeFieldRegistry(settings.schema);\n const runtimeFieldFilters = collectRuntimeFilterValues(\n options as Record<string, unknown>,\n runtimeFieldRegistry,\n \"calendar\",\n );\n const typeRegistry = resolveItemTypeRegistry(\n settings,\n getActiveExtensionRegistrations(),\n );\n const listWarnings: string[] = [];\n appendCalendarCapWarning(listWarnings, inputs.eventsOnlyCapApplied);\n const items = await listAllItemMetadataLight(\n pmRoot,\n settings.item_format,\n typeRegistry.type_to_folder,\n listWarnings,\n settings.schema,\n );\n const filteredItems = filterItems(\n items,\n options,\n typeRegistry,\n statusRegistry,\n runtimeFieldFilters,\n );\n const recurringWindow = buildRecurringEventWindow(\n inputs.rangeBounds.start,\n inputs.rangeBounds.end,\n inputs.nowValue,\n inputs.recurrenceLookbackWindowDays,\n inputs.recurrenceLookaheadDays,\n );\n const seededEvents = buildEventSeed(\n filteredItems,\n recurringWindow,\n inputs.includeSources,\n inputs.occurrenceLimit,\n );\n const rangedEvents = seededEvents.filter((event) =>\n includeEventInWindow(\n event,\n inputs.rangeBounds.start,\n inputs.rangeBounds.end,\n ),\n );\n const limitedEvents =\n inputs.limit === undefined\n ? rangedEvents\n : rangedEvents.slice(0, inputs.limit);\n const days = bucketEventsByDay(limitedEvents);\n const warnings = [...new Set(listWarnings)].sort((left, right) =>\n left.localeCompare(right),\n );\n\n return {\n view: inputs.view,\n output_default: \"markdown\",\n now: inputs.nowValue,\n anchor: inputs.rangeBounds.anchor,\n range: buildCalendarRangeResult(options, inputs.rangeBounds),\n filters: buildCalendarFiltersResult(options, runtimeFieldFilters),\n summary: summarize(limitedEvents),\n events: limitedEvents,\n days,\n ...(warnings.length > 0 ? { warnings } : {}),\n };\n}\n", "/**\n * @module sdk/context-relevance\n *\n * Public, deterministic context-ranking and evaluation primitives. The scorer\n * accepts already-derived signals so package authors can reuse the same model\n * with core, extension, or project-specific feature stores.\n */\nimport { runActiveServiceOverride } from \"../core/extensions/index.js\";\n\n/** Canonical signal keys understood by the built-in relevance model. */\nexport const CONTEXT_RELEVANCE_SIGNAL_NAMES = [\n \"structural\",\n \"recency\",\n \"activity_density\",\n \"graph_proximity\",\n \"claim_focus\",\n \"priority_pressure\",\n \"risk_pressure\",\n \"deadline_pressure\",\n \"knowledge_density\",\n \"author_affinity\",\n \"semantic_similarity\",\n] as const;\n\n/** A normalized signal consumed by the built-in context relevance scorer. */\nexport type ContextRelevanceSignalName =\n (typeof CONTEXT_RELEVANCE_SIGNAL_NAMES)[number];\n\n/** Normalized candidate features; omitted signals are excluded from weighting. */\nexport type ContextRelevanceSignals = Partial<\n Record<Exclude<ContextRelevanceSignalName, \"structural\">, number>\n>;\n\n/** A project-management object and its derived relevance signals. */\nexport interface ContextRelevanceCandidate<TItem> {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports item for this contract. */\n item: TItem;\n /** Value that configures or reports signals for this contract. */\n signals?: ContextRelevanceSignals;\n}\n\n/** Per-signal weighted contributions used to explain a ranked result. */\nexport type ContextRelevanceContributions = Record<string, number>;\n\n/** One ranked candidate with deterministic score and explanation metadata. */\nexport interface RankedContextCandidate<\n TItem,\n> extends ContextRelevanceCandidate<TItem> {\n /** Value that configures or reports baseline rank for this contract. */\n baseline_rank: number;\n /** Value that configures or reports rank for this contract. */\n rank: number;\n /** Value that configures or reports score for this contract. */\n score: number;\n /** Value that configures or reports contributions for this contract. */\n contributions: ContextRelevanceContributions;\n}\n\n/** Complete output from a context relevance scorer. */\nexport interface ContextRelevanceReport<TItem> {\n /** Value that configures or reports model for this contract. */\n model: string;\n /** Value that configures or reports available signals for this contract. */\n available_signals: ContextRelevanceSignalName[];\n /** Value that configures or reports ranked for this contract. */\n ranked: RankedContextCandidate<TItem>[];\n /** Value that configures or reports warnings for this contract. */\n warnings?: string[];\n}\n\n/** Minimal custom score returned by a replacement or wrapper scorer. */\nexport interface ContextRelevanceCustomScore {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports score for this contract. */\n score: number;\n}\n\n/** Input provided to a custom scorer, including the deterministic default. */\nexport interface ContextRelevanceScorerInput<TItem> {\n /** Value that configures or reports candidates for this contract. */\n candidates: readonly ContextRelevanceCandidate<TItem>[];\n /** Fallback report used when callers do not provide an override. */\n default_report: ContextRelevanceReport<TItem>;\n}\n\n/** Replaceable package/extension scorer contract. */\nexport type ContextRelevanceScorer<TItem> = (\n input: ContextRelevanceScorerInput<TItem>,\n) =>\n | readonly ContextRelevanceCustomScore[]\n | Promise<readonly ContextRelevanceCustomScore[]>;\n\n/** Options for the built-in or replaceable context relevance scorer. */\nexport interface ScoreContextCandidatesOptions<TItem> {\n /** Value that configures or reports weights for this contract. */\n weights?: Partial<Record<ContextRelevanceSignalName, number>>;\n /** Value that configures or reports scorer for this contract. */\n scorer?: ContextRelevanceScorer<TItem>;\n}\n\n/** Governed extension service used to replace or wrap context ranking. */\nexport const CONTEXT_RELEVANCE_SERVICE = \"context_relevance\" as const;\n\n/** Command surface requesting an active extension relevance override. */\nexport type ContextRelevanceSurface = \"context\" | \"next\";\n\nconst DEFAULT_CONTEXT_RELEVANCE_WEIGHTS: Record<\n ContextRelevanceSignalName,\n number\n> = {\n structural: 0.4,\n recency: 0.35,\n activity_density: 0.25,\n graph_proximity: 0.15,\n claim_focus: 0.6,\n priority_pressure: 0.35,\n risk_pressure: 0.2,\n deadline_pressure: 0.45,\n knowledge_density: 0.25,\n author_affinity: 0.2,\n semantic_similarity: 0.5,\n};\nconst JSON_TOKEN_ENCODER = new TextEncoder();\n\nfunction assertCandidates<TItem>(\n candidates: readonly ContextRelevanceCandidate<TItem>[],\n): void {\n const ids = new Set<string>();\n for (const candidate of candidates) {\n if (\n typeof candidate.id !== \"string\" ||\n candidate.id.trim().length === 0 ||\n ids.has(candidate.id)\n ) {\n throw new TypeError(\n \"Context relevance candidates require unique non-empty ids\",\n );\n }\n ids.add(candidate.id);\n for (const [signal, value] of Object.entries(candidate.signals ?? {})) {\n if (\n signal === \"structural\" ||\n !CONTEXT_RELEVANCE_SIGNAL_NAMES.includes(\n signal as ContextRelevanceSignalName,\n )\n ) {\n throw new TypeError(`Unknown context relevance signal: ${signal}`);\n }\n if (value === undefined) continue;\n if (!Number.isFinite(value) || value < 0 || value > 1) {\n throw new TypeError(\n `Context relevance signal ${signal} must be a finite number from 0 to 1`,\n );\n }\n }\n }\n}\n\nfunction resolveWeights(\n overrides: Partial<Record<ContextRelevanceSignalName, number>> | undefined,\n): Record<ContextRelevanceSignalName, number> {\n const weights = { ...DEFAULT_CONTEXT_RELEVANCE_WEIGHTS };\n for (const [signal, weight] of Object.entries(overrides ?? {})) {\n if (\n weight !== undefined &&\n CONTEXT_RELEVANCE_SIGNAL_NAMES.includes(\n signal as ContextRelevanceSignalName,\n )\n ) {\n weights[signal as ContextRelevanceSignalName] = weight;\n }\n }\n for (const [signal, weight] of Object.entries(weights)) {\n if (!Number.isFinite(weight) || weight < 0) {\n throw new TypeError(\n `Context relevance weight ${signal} must be a finite non-negative number`,\n );\n }\n }\n return weights;\n}\n\n/** Score candidates with pm's deterministic weighted model. Candidate order is the structural baseline and remains unchanged when no advanced signals exist. */\nexport function defaultScoreContextCandidates<TItem>(\n candidates: readonly ContextRelevanceCandidate<TItem>[],\n options: Pick<ScoreContextCandidatesOptions<TItem>, \"weights\"> = {},\n): ContextRelevanceReport<TItem> {\n assertCandidates(candidates);\n const weights = resolveWeights(options.weights);\n const denominator = Math.max(candidates.length - 1, 1);\n const available = new Set<ContextRelevanceSignalName>([\"structural\"]);\n for (const candidate of candidates) {\n for (const [signal, value] of Object.entries(candidate.signals ?? {})) {\n if (value !== undefined)\n available.add(signal as ContextRelevanceSignalName);\n }\n }\n const availableSignals = CONTEXT_RELEVANCE_SIGNAL_NAMES.filter((signal) =>\n available.has(signal),\n );\n const scored = candidates.map(\n (candidate, index): RankedContextCandidate<TItem> => {\n const signalValues: Partial<Record<ContextRelevanceSignalName, number>> =\n {\n structural: candidates.length === 1 ? 1 : 1 - index / denominator,\n ...candidate.signals,\n };\n const contributions: ContextRelevanceContributions = {};\n let weightedScore = 0;\n let totalWeight = 0;\n for (const signal of availableSignals) {\n const value = signalValues[signal];\n if (value === undefined) continue;\n const contribution = value * weights[signal];\n contributions[signal] = contribution;\n weightedScore += contribution;\n totalWeight += weights[signal];\n }\n return {\n ...candidate,\n baseline_rank: index + 1,\n rank: 0,\n score: totalWeight === 0 ? 0 : weightedScore / totalWeight,\n contributions,\n };\n },\n );\n scored.sort(\n (left, right) =>\n right.score - left.score || left.baseline_rank - right.baseline_rank,\n );\n scored.forEach((entry, index) => {\n entry.rank = index + 1;\n });\n return {\n model: \"default-weighted-v1\",\n available_signals: availableSignals,\n ranked: scored,\n };\n}\n\n/** Score candidates with the default model or a validated replacement/wrapper. */\nexport async function scoreContextCandidates<TItem>(\n candidates: readonly ContextRelevanceCandidate<TItem>[],\n options: ScoreContextCandidatesOptions<TItem> = {},\n): Promise<ContextRelevanceReport<TItem>> {\n const defaultReport = defaultScoreContextCandidates(candidates, options);\n if (!options.scorer) return defaultReport;\n const customScores = await options.scorer({\n candidates,\n default_report: defaultReport,\n });\n const scoreById = new Map<string, number>();\n for (const entry of customScores) {\n if (scoreById.has(entry.id) || !Number.isFinite(entry.score)) {\n throw new TypeError(\n \"Context relevance scorer must return one finite score for every candidate\",\n );\n }\n scoreById.set(entry.id, entry.score);\n }\n if (\n scoreById.size !== candidates.length ||\n candidates.some((candidate) => !scoreById.has(candidate.id))\n ) {\n throw new TypeError(\n \"Context relevance scorer must return one finite score for every candidate\",\n );\n }\n const ranked = defaultReport.ranked.map((entry) => {\n const score = scoreById.get(entry.id) as number;\n return { ...entry, score, contributions: { custom: score } };\n });\n ranked.sort(\n (left, right) =>\n right.score - left.score || left.baseline_rank - right.baseline_rank,\n );\n ranked.forEach((entry, index) => {\n entry.rank = index + 1;\n });\n return {\n model: \"custom\",\n available_signals: defaultReport.available_signals,\n ranked,\n };\n}\n\n/** Score command candidates through the public default model and then the active governed `context_relevance` service override, when one is registered. */\nexport async function scoreContextCandidatesWithActiveExtensions<TItem>(\n surface: ContextRelevanceSurface,\n candidates: readonly ContextRelevanceCandidate<TItem>[],\n options: Pick<ScoreContextCandidatesOptions<TItem>, \"weights\"> = {},\n): Promise<ContextRelevanceReport<TItem>> {\n const defaultReport = defaultScoreContextCandidates(candidates, options);\n const override = await runActiveServiceOverride(CONTEXT_RELEVANCE_SERVICE, {\n surface,\n candidates,\n default_report: defaultReport,\n });\n if (!override.handled) {\n return override.warnings.length > 0\n ? { ...defaultReport, warnings: override.warnings }\n : defaultReport;\n }\n if (\n !Array.isArray(override.result) ||\n !override.result.every(\n (entry) =>\n typeof entry === \"object\" &&\n entry !== null &&\n typeof (entry as { id?: unknown }).id === \"string\" &&\n typeof (entry as { score?: unknown }).score === \"number\" &&\n Number.isFinite((entry as { score: number }).score),\n )\n ) {\n return {\n ...defaultReport,\n warnings: [\n ...override.warnings,\n \"extension_context_relevance_invalid_result\",\n ],\n };\n }\n try {\n const report = await scoreContextCandidates(candidates, {\n ...options,\n scorer: () => override.result as ContextRelevanceCustomScore[],\n });\n return override.warnings.length > 0\n ? { ...report, warnings: override.warnings }\n : report;\n } catch {\n return {\n ...defaultReport,\n warnings: [\n ...override.warnings,\n \"extension_context_relevance_invalid_result\",\n ],\n };\n }\n}\n\n/** Input for rank-aware context/next quality evaluation. */\nexport interface ContextRankingEvaluationInput {\n /** Value that configures or reports ranked ids for this contract. */\n ranked_ids: string[];\n /** Value that configures or reports judgments for this contract. */\n judgments: Record<string, number>;\n /** Value that configures or reports required ids for this contract. */\n required_ids?: string[];\n /** Value that configures or reports continuity ids for this contract. */\n continuity_ids?: string[];\n /** Value that configures or reports actual tokens for this contract. */\n actual_tokens: number;\n /** Value that configures or reports token budget for this contract. */\n token_budget: number;\n}\n\n/** Rank-quality, continuity, recall, and token-budget metrics for one scenario. */\nexport interface ContextRankingEvaluation {\n /** Value that configures or reports ndcg for this contract. */\n ndcg: number;\n /** Value that configures or reports reciprocal rank for this contract. */\n reciprocal_rank: number;\n /** Value that configures or reports required recall for this contract. */\n required_recall: number;\n /** Value that configures or reports continuity coverage for this contract. */\n continuity_coverage: number;\n /** Value that configures or reports token budget adherence for this contract. */\n token_budget_adherence: number;\n /** Value that configures or reports within token budget for this contract. */\n within_token_budget: boolean;\n}\n\n/** Flexible read options accepted by context evaluation scenarios. */\nexport interface ContextEvaluationReadOptions {\n /** Value that configures or reports explain ranking for this contract. */\n explainRanking?: boolean;\n [key: string]: unknown;\n}\n\n/** Minimal item identity consumed by the context evaluation runner. */\nexport interface ContextEvaluationResultItem {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n}\n\n/** Optional scorer attribution returned by an evaluated read primitive. */\nexport interface ContextEvaluationResultRanking {\n /** Value that configures or reports items for this contract. */\n items?: Array<{ id: string; contributions: ContextRelevanceContributions }>;\n}\n\n/** Structural context result consumed by the evaluation runner. */\nexport interface ContextEvaluationContextResult {\n /** Value that configures or reports high level for this contract. */\n high_level?: ContextEvaluationResultItem[];\n /** Value that configures or reports low level for this contract. */\n low_level?: ContextEvaluationResultItem[];\n /** Value that configures or reports blocked fallback for this contract. */\n blocked_fallback?: ContextEvaluationResultItem[];\n /** Value that configures or reports ranking for this contract. */\n ranking?: ContextEvaluationResultRanking;\n [key: string]: unknown;\n}\n\n/** Structural next result consumed by the evaluation runner. */\nexport interface ContextEvaluationNextResult {\n /** Value that configures or reports recommended for this contract. */\n recommended?: ContextEvaluationResultItem | null;\n /** Value that configures or reports ready for this contract. */\n ready?: ContextEvaluationResultItem[];\n /** Value that configures or reports ranking for this contract. */\n ranking?: ContextEvaluationResultRanking;\n [key: string]: unknown;\n}\n\n/** Read-only SDK surface required by the context evaluation runner. */\nexport interface ContextEvaluationReader {\n /** Value that configures or reports context for this contract. */\n context(\n options?: ContextEvaluationReadOptions,\n ): Promise<ContextEvaluationContextResult>;\n /** Value that configures or reports next for this contract. */\n next(\n options?: ContextEvaluationReadOptions,\n ): Promise<ContextEvaluationNextResult>;\n}\n\n/** One graded context or next scenario evaluated against a real SDK reader. */\nexport interface ContextEvaluationScenario {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports surface for this contract. */\n surface: ContextRelevanceSurface;\n /** Value that configures or reports options for this contract. */\n options?: ContextEvaluationReadOptions;\n /** Value that configures or reports judgments for this contract. */\n judgments: Record<string, number>;\n /** Value that configures or reports required ids for this contract. */\n required_ids?: string[];\n /** Value that configures or reports continuity ids for this contract. */\n continuity_ids?: string[];\n /** Value that configures or reports token budget for this contract. */\n token_budget: number;\n /** Value that configures or reports rationale for this contract. */\n rationale: string;\n}\n\n/** Per-item signal attribution retained by a context evaluation report. */\nexport interface ContextEvaluationAttribution {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports contributions for this contract. */\n contributions: ContextRelevanceContributions;\n}\n\n/** Result of executing and grading one context evaluation scenario. */\nexport interface ContextEvaluationScenarioReport {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports surface for this contract. */\n surface: ContextRelevanceSurface;\n /** Value that configures or reports rationale for this contract. */\n rationale: string;\n /** Value that configures or reports ranked ids for this contract. */\n ranked_ids: string[];\n /** Value that configures or reports actual tokens for this contract. */\n actual_tokens: number;\n /** Value that configures or reports metrics for this contract. */\n metrics: ContextRankingEvaluation;\n /** Value that configures or reports attribution for this contract. */\n attribution: ContextEvaluationAttribution[];\n}\n\n/** Minimum acceptable aggregate metrics for a context evaluation corpus. */\nexport interface ContextEvaluationThresholds {\n /** Value that configures or reports ndcg for this contract. */\n ndcg: number;\n /** Value that configures or reports reciprocal rank for this contract. */\n reciprocal_rank: number;\n /** Value that configures or reports required recall for this contract. */\n required_recall: number;\n /** Value that configures or reports continuity coverage for this contract. */\n continuity_coverage: number;\n /** Value that configures or reports token budget adherence for this contract. */\n token_budget_adherence: number;\n}\n\n/** Canonical aggregate metrics required by every context evaluation corpus. */\nexport const CONTEXT_EVALUATION_METRIC_NAMES = [\n \"ndcg\",\n \"reciprocal_rank\",\n \"required_recall\",\n \"continuity_coverage\",\n \"token_budget_adherence\",\n] as const satisfies readonly (keyof ContextEvaluationThresholds)[];\n\n/** Aggregate context evaluation report suitable for a CI quality gate. */\nexport interface ContextEvaluationCorpusReport {\n /** Number of scenario entries represented by this result. */\n scenario_count: number;\n /** Value that configures or reports aggregate for this contract. */\n aggregate: ContextEvaluationThresholds;\n /** Value that configures or reports scenarios for this contract. */\n scenarios: ContextEvaluationScenarioReport[];\n /** Value that configures or reports passed for this contract. */\n passed: boolean;\n /** Value that configures or reports failures for this contract. */\n failures: string[];\n}\n\nfunction ratioOfPresent(\n expected: readonly string[],\n actual: ReadonlySet<string>,\n): number {\n if (expected.length === 0) return 1;\n return expected.filter((id) => actual.has(id)).length / expected.length;\n}\n\n/** Evaluate one ranked context packet against graded human judgments. */\nexport function evaluateContextRanking(\n input: ContextRankingEvaluationInput,\n): ContextRankingEvaluation {\n if (\n !Number.isFinite(input.actual_tokens) ||\n input.actual_tokens < 0 ||\n !Number.isFinite(input.token_budget) ||\n input.token_budget <= 0\n ) {\n throw new TypeError(\n \"Context ranking token counts require actual_tokens >= 0 and token_budget > 0\",\n );\n }\n const judgments = input.judgments ?? {};\n const gains = input.ranked_ids.map((id) => Math.max(0, judgments[id] ?? 0));\n const idealGains = Object.values(judgments)\n .map((grade) => Math.max(0, grade))\n .sort((left, right) => right - left)\n .slice(0, gains.length || 1);\n const discountedGain = (values: readonly number[]) =>\n values.reduce(\n (total, grade, index) => total + (2 ** grade - 1) / Math.log2(index + 2),\n 0,\n );\n const ideal = discountedGain(idealGains);\n const firstRelevant = gains.findIndex((grade) => grade > 0);\n const actualIds = new Set(input.ranked_ids);\n const withinBudget = input.actual_tokens <= input.token_budget;\n return {\n ndcg: ideal === 0 ? 1 : discountedGain(gains) / ideal,\n reciprocal_rank: firstRelevant < 0 ? 0 : 1 / (firstRelevant + 1),\n required_recall: ratioOfPresent(input.required_ids ?? [], actualIds),\n continuity_coverage: ratioOfPresent(input.continuity_ids ?? [], actualIds),\n token_budget_adherence: withinBudget\n ? 1\n : input.token_budget / input.actual_tokens,\n within_token_budget: withinBudget,\n };\n}\n\nfunction estimateJsonTokens(value: unknown): number {\n return Math.ceil(\n JSON_TOKEN_ENCODER.encode(JSON.stringify(value)).byteLength / 4,\n );\n}\n\nfunction roundEvaluationMetric(value: number): number {\n return Math.round(value * 10_000) / 10_000;\n}\n\nfunction rankingPayloadForScenario(\n result: ContextEvaluationContextResult | ContextEvaluationNextResult,\n surface: ContextRelevanceSurface,\n): { rankedIds: string[]; attribution: ContextEvaluationAttribution[] } {\n const rankedIds =\n surface === \"context\"\n ? [\n ...((result as ContextEvaluationContextResult).high_level ?? []),\n ...((result as ContextEvaluationContextResult).low_level ?? []),\n ...((result as ContextEvaluationContextResult).blocked_fallback ??\n []),\n ].map((item) => item.id)\n : [\n ...((result as ContextEvaluationNextResult).recommended\n ? [\n (result as ContextEvaluationNextResult)\n .recommended as ContextEvaluationResultItem,\n ]\n : []),\n ...((result as ContextEvaluationNextResult).ready ?? []),\n ].map((item) => item.id);\n const servedIds = new Set(rankedIds);\n const attribution = (result.ranking?.items ?? [])\n .filter((item) => servedIds.has(item.id))\n .map((item) => ({ id: item.id, contributions: item.contributions }));\n return { rankedIds, attribution };\n}\n\n/** Execute one graded scenario through public SDK context/next read primitives. */\nexport async function runContextEvaluationScenario(\n scenario: ContextEvaluationScenario,\n reader: ContextEvaluationReader,\n): Promise<ContextEvaluationScenarioReport> {\n if (\n scenario.id.trim().length === 0 ||\n scenario.rationale.trim().length === 0\n ) {\n throw new TypeError(\n \"Context evaluation scenarios require non-empty id and rationale values\",\n );\n }\n const result =\n scenario.surface === \"context\"\n ? await reader.context({ ...scenario.options, explainRanking: true })\n : await reader.next({ ...scenario.options, explainRanking: true });\n const { rankedIds, attribution } = rankingPayloadForScenario(\n result,\n scenario.surface,\n );\n const packet = { ...result, ranking: undefined };\n const actualTokens = estimateJsonTokens(packet);\n return {\n id: scenario.id,\n surface: scenario.surface,\n rationale: scenario.rationale,\n ranked_ids: rankedIds,\n actual_tokens: actualTokens,\n metrics: evaluateContextRanking({\n ranked_ids: rankedIds,\n judgments: scenario.judgments,\n required_ids: scenario.required_ids,\n continuity_ids: scenario.continuity_ids,\n actual_tokens: actualTokens,\n token_budget: scenario.token_budget,\n }),\n attribution,\n };\n}\n\n/** Aggregate scenario reports and evaluate every metric against explicit thresholds. */\nexport function summarizeContextEvaluationReports(\n reports: readonly ContextEvaluationScenarioReport[],\n thresholds: ContextEvaluationThresholds,\n): ContextEvaluationCorpusReport {\n if (reports.length === 0) {\n throw new TypeError(\n \"Context evaluation requires at least one scenario report\",\n );\n }\n const metrics = CONTEXT_EVALUATION_METRIC_NAMES;\n for (const metric of metrics) {\n if (!Number.isFinite(thresholds[metric])) {\n throw new TypeError(\n `Context evaluation threshold ${metric} must be a finite number`,\n );\n }\n }\n const aggregate = Object.fromEntries(\n metrics.map((metric) => [\n metric,\n roundEvaluationMetric(\n reports.reduce((total, report) => total + report.metrics[metric], 0) /\n reports.length,\n ),\n ]),\n ) as unknown as ContextEvaluationThresholds;\n const failures = metrics\n .filter((metric) => aggregate[metric] < thresholds[metric])\n .map((metric) => `${metric}:${aggregate[metric]}<${thresholds[metric]}`);\n return {\n scenario_count: reports.length,\n aggregate,\n scenarios: [...reports],\n passed: failures.length === 0,\n failures,\n };\n}\n\n/** Execute a same-workspace scenario corpus through public SDK read primitives. */\nexport async function runContextEvaluationCorpus(\n scenarios: readonly ContextEvaluationScenario[],\n reader: ContextEvaluationReader,\n thresholds: ContextEvaluationThresholds,\n): Promise<ContextEvaluationCorpusReport> {\n const reports: ContextEvaluationScenarioReport[] = [];\n for (const scenario of scenarios) {\n reports.push(await runContextEvaluationScenario(scenario, reader));\n }\n return summarizeContextEvaluationReports(reports, thresholds);\n}\n", "/**\n * @module cli/commands/context\n *\n * Implements the pm context command surface and its agent-facing runtime behavior.\n */\nimport { SETTINGS_DEFAULTS, EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { compareTimestampStrings, nowIso } from \"../../core/shared/time.js\";\nimport {\n isTerminalStatus,\n normalizeStatusForRegistry,\n normalizeStatusInput,\n} from \"../../core/item/status.js\";\nimport {\n resolveRuntimeStatusRegistry,\n type RuntimeStatusRegistry,\n} from \"../../core/schema/runtime-schema.js\";\nimport { resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport type {\n ContextDepth,\n ContextSectionName,\n ContextSettings,\n ItemMetadata,\n ItemStatus,\n PmSettings,\n} from \"../../types/index.js\";\nimport {\n CONTEXT_DEPTH_VALUES,\n CONTEXT_SECTION_VALUES,\n} from \"../../types/index.js\";\nimport { parseIntegerLimit } from \"../shared-parsers.js\";\nimport {\n runCalendar,\n type CalendarOptions,\n type CalendarRow,\n} from \"./calendar.js\";\nimport { runList, type ListOptions } from \"./list.js\";\nimport { runActivity, type CompactActivityEntry } from \"./activity.js\";\nimport {\n scoreContextCandidatesWithActiveExtensions,\n type ContextRelevanceCandidate,\n type ContextRelevanceContributions,\n type ContextRelevanceReport,\n type ContextRelevanceSignalName,\n} from \"../../sdk/context-relevance.js\";\nimport {\n createQueryFingerprint,\n encodeQueryCursor,\n resolveQueryCursorStart,\n} from \"../../sdk/pagination.js\";\n\n// ---------------------------------------------------------------------------\n// Output format\n// ---------------------------------------------------------------------------\n\n/** Supported values accepted by the context output contract. */\nexport const CONTEXT_OUTPUT_VALUES = [\"markdown\", \"toon\", \"json\"] as const;\n/** Restricts context output format values accepted by command, SDK, and storage contracts. */\nexport type ContextOutputFormat = (typeof CONTEXT_OUTPUT_VALUES)[number];\n\n// ---------------------------------------------------------------------------\n// Options\n// ---------------------------------------------------------------------------\n\n/** Documents the context options payload exchanged by command, SDK, and package integrations. */\nexport interface ContextOptions {\n /** Value that configures or reports date for this contract. */\n date?: string;\n /** Value that configures or reports from for this contract. */\n from?: string;\n /** Value that configures or reports to for this contract. */\n to?: string;\n /** Value that configures or reports past for this contract. */\n past?: boolean;\n /** Schema type that determines the shape and validation rules for this value. */\n type?: string;\n /** Value that configures or reports tag for this contract. */\n tag?: string;\n /** Value that configures or reports priority for this contract. */\n priority?: string;\n /** Value that configures or reports assignee for this contract. */\n assignee?: string;\n /** Value that configures or reports assignee filter for this contract. */\n assigneeFilter?: string;\n /** Value that configures or reports sprint for this contract. */\n sprint?: string;\n /** Value that configures or reports release for this contract. */\n release?: string;\n /** Value that configures or reports limit for this contract. */\n limit?: string;\n /** Value that configures or reports max items for this contract. */\n maxItems?: string;\n /** Opaque cursor returned by a previous context focus page. */\n after?: string;\n /** Value that configures or reports format for this contract. */\n format?: string;\n /** Value that configures or reports depth for this contract. */\n depth?: string;\n /** Value that configures or reports fields for this contract. */\n fields?: string;\n /** Value that configures or reports section for this contract. */\n section?: string[];\n /** Value that configures or reports activity limit for this contract. */\n activityLimit?: string;\n /** Value that configures or reports stale threshold for this contract. */\n staleThreshold?: string;\n /** Value that configures or reports parent for this contract. */\n parent?: string;\n /** Value that configures or reports explain ranking for this contract. */\n explainRanking?: boolean;\n [key: string]: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// Focus item (unchanged from original)\n// ---------------------------------------------------------------------------\n\n/** Documents the context focus item payload exchanged by command, SDK, and package integrations. */\nexport interface ContextFocusItem {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports title for this contract. */\n title: string;\n /** Schema type that determines the shape and validation rules for this value. */\n type: string;\n /** Lifecycle state reported for status. */\n status: ItemStatus;\n /** Value that configures or reports priority for this contract. */\n priority: number;\n /** Value that configures or reports order for this contract. */\n order: number | null;\n /** Value that configures or reports deadline for this contract. */\n deadline: string | null;\n /** Value that configures or reports assignee for this contract. */\n assignee: string | null;\n /** Value that configures or reports tags for this contract. */\n tags: string[];\n /** ISO 8601 timestamp recording when updated occurred. */\n updated_at: string;\n /** Value that configures or reports parent for this contract. */\n parent: string | null;\n /** Value that configures or reports children total for this contract. */\n children_total?: number;\n /** Value that configures or reports children closed for this contract. */\n children_closed?: number;\n /** Value that configures or reports completion pct for this contract. */\n completion_pct?: number;\n}\n\n// ---------------------------------------------------------------------------\n// Section data types\n// ---------------------------------------------------------------------------\n\n/** Documents the hierarchy child payload exchanged by command, SDK, and package integrations. */\nexport interface HierarchyChild {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports title for this contract. */\n title: string;\n /** Schema type that determines the shape and validation rules for this value. */\n type: string;\n /** Lifecycle state reported for status. */\n status: ItemStatus;\n /** Value that configures or reports children total for this contract. */\n children_total: number;\n /** Value that configures or reports children closed for this contract. */\n children_closed: number;\n}\n\n/** Documents the hierarchy node payload exchanged by command, SDK, and package integrations. */\nexport interface HierarchyNode {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports title for this contract. */\n title: string;\n /** Schema type that determines the shape and validation rules for this value. */\n type: string;\n /** Lifecycle state reported for status. */\n status: ItemStatus;\n /** Value that configures or reports children total for this contract. */\n children_total: number;\n /** Value that configures or reports children closed for this contract. */\n children_closed: number;\n /** Value that configures or reports children open for this contract. */\n children_open: number;\n /** Value that configures or reports children in progress for this contract. */\n children_in_progress: number;\n /** Value that configures or reports children blocked for this contract. */\n children_blocked: number;\n /** Value that configures or reports children for this contract. */\n children: HierarchyChild[];\n}\n\n/** Documents the progress entry payload exchanged by command, SDK, and package integrations. */\nexport interface ProgressEntry {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports title for this contract. */\n title: string;\n /** Schema type that determines the shape and validation rules for this value. */\n type: string;\n /** Value that configures or reports total for this contract. */\n total: number;\n /** Value that configures or reports closed for this contract. */\n closed: number;\n /** Value that configures or reports open for this contract. */\n open: number;\n /** Value that configures or reports in progress for this contract. */\n in_progress: number;\n /** Value that configures or reports blocked for this contract. */\n blocked: number;\n /** Value that configures or reports completion pct for this contract. */\n completion_pct: number;\n}\n\n/** Documents the blocker entry payload exchanged by command, SDK, and package integrations. */\nexport interface BlockerEntry {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports title for this contract. */\n title: string;\n /** Value that configures or reports blocked by for this contract. */\n blocked_by: string | null;\n /** Value that configures or reports blocked by title for this contract. */\n blocked_by_title: string | null;\n /** Lifecycle state reported for blocked bythe record. */\n blocked_by_status: ItemStatus | null;\n /** Value that configures or reports blocked reason for this contract. */\n blocked_reason: string | null;\n /** Value that configures or reports unblock note for this contract. */\n unblock_note: string | null;\n}\n\n/** Documents the hot file payload exchanged by command, SDK, and package integrations. */\nexport interface HotFile {\n /** Filesystem path used for path resolution. */\n path: string;\n /** Value that configures or reports references for this contract. */\n references: number;\n /** Value that configures or reports items for this contract. */\n items: string[];\n}\n\n/** Documents the workload entry payload exchanged by command, SDK, and package integrations. */\nexport interface WorkloadEntry {\n /** Value that configures or reports assignee for this contract. */\n assignee: string | null;\n /** Value that configures or reports active for this contract. */\n active: number;\n /** Value that configures or reports in progress for this contract. */\n in_progress: number;\n /** Value that configures or reports items for this contract. */\n items: string[];\n}\n\n/** Documents the stale entry payload exchanged by command, SDK, and package integrations. */\nexport interface StaleEntry {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports title for this contract. */\n title: string;\n /** Lifecycle state reported for status. */\n status: ItemStatus;\n /** ISO 8601 timestamp recording when updated occurred. */\n updated_at: string;\n /** Value that configures or reports stale days for this contract. */\n stale_days: number;\n}\n\n/** Documents the recent context item payload exchanged by command, SDK, and package integrations. */\nexport interface RecentContextItem extends ContextFocusItem {\n /** ISO 8601 timestamp recording when created occurred. */\n created_at?: string;\n}\n\n/** Documents the test health summary payload exchanged by command, SDK, and package integrations. */\nexport interface TestHealthSummary {\n /** Value that configures or reports items with tests for this contract. */\n items_with_tests: number;\n /** Value that configures or reports items with recent runs for this contract. */\n items_with_recent_runs: number;\n /** Value that configures or reports recent runs for this contract. */\n recent_runs: {\n passed: number;\n failed: number;\n skipped: number;\n };\n /** Value that configures or reports items failing for this contract. */\n items_failing: string[];\n}\n\n// ---------------------------------------------------------------------------\n// Agenda / summary (unchanged)\n// ---------------------------------------------------------------------------\n\ninterface ContextAgendaSummary {\n events: number;\n items: number;\n deadlines: number;\n reminders: number;\n scheduled: number;\n}\n\ninterface ContextSummary {\n active_items: number;\n in_progress: number;\n open: number;\n blocked: number;\n blocked_fallback_used: boolean;\n high_level: number;\n low_level: number;\n agenda_events: number;\n total_items?: number;\n closed?: number;\n canceled?: number;\n}\n\n// ---------------------------------------------------------------------------\n// Result\n// ---------------------------------------------------------------------------\n\n/** Documents the context result payload exchanged by command, SDK, and package integrations. */\nexport interface ContextResult {\n /** Value that configures or reports output default for this contract. */\n output_default: \"toon\";\n /** Value that configures or reports now for this contract. */\n now: string;\n /** Value that configures or reports depth for this contract. */\n depth: ContextDepth;\n /** Value that configures or reports sections included for this contract. */\n sections_included: ContextSectionName[];\n /** Value that configures or reports window for this contract. */\n window: {\n anchor: string;\n start: string | null;\n end: string | null;\n past: boolean;\n from: string | null;\n to: string | null;\n };\n /** Value that configures or reports filters for this contract. */\n filters: {\n type: string | null;\n tag: string | null;\n priority: string | null;\n assignee: string | null;\n assignee_filter: string | null;\n sprint: string | null;\n release: string | null;\n limit: string | null;\n parent: string | null;\n runtime_filters?: Record<string, unknown>;\n };\n /** Value that configures or reports summary for this contract. */\n summary: ContextSummary;\n /** Value that configures or reports high level for this contract. */\n high_level: ContextFocusItem[];\n /** Value that configures or reports low level for this contract. */\n low_level: ContextFocusItem[];\n /** Value that configures or reports blocked fallback for this contract. */\n blocked_fallback: ContextFocusItem[];\n /** Value that configures or reports agenda for this contract. */\n agenda: {\n summary: ContextAgendaSummary;\n events: CalendarRow[];\n };\n /** Value that configures or reports hierarchy for this contract. */\n hierarchy?: HierarchyNode[];\n /** Value that configures or reports activity for this contract. */\n activity?: CompactActivityEntry[];\n /** Value that configures or reports progress for this contract. */\n progress?: ProgressEntry[];\n /** Value that configures or reports blockers for this contract. */\n blockers?: BlockerEntry[];\n /** Value that configures or reports recently created for this contract. */\n recently_created?: RecentContextItem[];\n /** Value that configures or reports unparented for this contract. */\n unparented?: ContextFocusItem[];\n /** Value that configures or reports files for this contract. */\n files?: HotFile[];\n /** Value that configures or reports workload for this contract. */\n workload?: WorkloadEntry[];\n /** Value that configures or reports staleness for this contract. */\n staleness?: StaleEntry[];\n /** Value that configures or reports tests for this contract. */\n tests?: TestHealthSummary;\n /** Value that configures or reports suggestions for this contract. */\n suggestions?: string[];\n /** Focus-row field subset requested via --fields; null/omitted means full rows. */\n focus_fields?: string[];\n /** Value that configures or reports warnings for this contract. */\n warnings?: string[];\n /** Value that configures or reports ranking for this contract. */\n ranking?: ContextRankingSummary;\n /** Whether additional ranked focus rows remain after this page. */\n has_more?: boolean;\n /** Opaque continuation cursor for the next ranked focus page. */\n next_cursor?: string;\n /** Effective ranked-focus page size. */\n applied_limit?: number;\n /** Explicit marker that focus rows were bounded. */\n truncated?: true;\n}\n\n/** Compact explainability envelope shared by context and next JSON results. */\nexport interface ContextRankingSummary {\n /** Value that configures or reports model for this contract. */\n model: string;\n /** Value that configures or reports available signals for this contract. */\n available_signals: ContextRelevanceSignalName[];\n /** Value that configures or reports items for this contract. */\n items: Array<{\n id: string;\n rank: number;\n baseline_rank: number;\n score: number;\n contributions: ContextRelevanceContributions;\n }>;\n}\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nconst HIGH_LEVEL_TYPES = new Set<string>([\"Epic\", \"Feature\"]);\nconst DEFAULT_CONTEXT_LIMIT = 10;\nconst CONTEXT_SCALE_THRESHOLD = 10_000;\n\nconst STANDARD_SECTIONS: ContextSectionName[] = [\n \"hierarchy\",\n \"activity\",\n \"progress\",\n \"recently_created\",\n \"unparented\",\n \"workload\",\n];\nconst DEEP_SECTIONS: ContextSectionName[] = [\n ...STANDARD_SECTIONS,\n \"blockers\",\n \"files\",\n \"staleness\",\n \"tests\",\n];\nconst LEADING_HYPHEN_DATE = /^(\\d{4})-(\\d{2})-(\\d{2})/;\nconst LEADING_COMPACT_DATE = /^(\\d{4})(\\d{2})(\\d{2})(?:[T ]?\\d{2}|$)/;\nconst COMPACT_DATE = /^(\\d{4})(\\d{2})(\\d{2})$/;\nconst COMPACT_DATETIME =\n /^(\\d{4})(\\d{2})(\\d{2})(?:[T\\s]?)(\\d{2})(\\d{2})(\\d{2})?(Z|[+-]\\d{2}:?\\d{2})?$/i;\n\n// ---------------------------------------------------------------------------\n// Parsers\n// ---------------------------------------------------------------------------\n\nfunction parseOutputFormat(\n raw: string | undefined,\n): ContextOutputFormat | undefined {\n if (!raw) return undefined;\n const normalized = raw.trim().toLowerCase();\n if (!CONTEXT_OUTPUT_VALUES.includes(normalized as ContextOutputFormat)) {\n throw new PmCliError(\n \"Context format must be one of markdown|toon|json\",\n EXIT_CODE.USAGE,\n );\n }\n return normalized as ContextOutputFormat;\n}\n\n// Fields selectable by `pm context --fields` for focus-row projection. Every\n// ContextFocusItem scalar plus `created_at` (carried by recently-created rows)\n// is addressable; unknown names are rejected with a usage hint.\nconst FOCUS_PROJECTION_FIELDS = new Set<string>([\n \"id\",\n \"title\",\n \"type\",\n \"status\",\n \"priority\",\n \"order\",\n \"deadline\",\n \"assignee\",\n \"tags\",\n \"updated_at\",\n \"parent\",\n \"children_total\",\n \"children_closed\",\n \"completion_pct\",\n \"created_at\",\n]);\n\n/** Parses the comma-separated `--fields` value into a validated, de-duplicated focus-row projection list. Returns undefined when no projection was requested. */\nexport function parseContextFocusFields(\n raw: string | undefined,\n): string[] | undefined {\n if (raw === undefined) return undefined;\n const fields: string[] = [];\n for (const token of raw.split(\",\")) {\n const normalized = token.trim().toLowerCase();\n if (normalized.length === 0) continue;\n if (!FOCUS_PROJECTION_FIELDS.has(normalized)) {\n throw new PmCliError(\n `Context --fields value not projectable: ${normalized} (valid: ${[...FOCUS_PROJECTION_FIELDS].join(\", \")})`,\n EXIT_CODE.USAGE,\n );\n }\n if (!fields.includes(normalized)) fields.push(normalized);\n }\n if (fields.length === 0) {\n throw new PmCliError(\n \"Context --fields requires at least one field name\",\n EXIT_CODE.USAGE,\n );\n }\n return fields;\n}\n\n/** Projects focus rows onto the requested field subset, preserving field order so the rendered/serialized output mirrors the `--fields` argument. */\nexport function projectContextFocusRows<T extends ContextFocusItem>(\n rows: T[],\n fields: string[],\n): ContextFocusItem[] {\n return rows.map((row) => {\n const projected: Record<string, unknown> = {};\n const source = row as Record<string, unknown>;\n for (const field of fields) {\n projected[field] = source[field] ?? null;\n }\n return projected as unknown as ContextFocusItem;\n });\n}\n\n/** Implements resolve context output format for the public runtime surface of this module. */\nexport function resolveContextOutputFormat(\n options: ContextOptions,\n global: GlobalOptions,\n): ContextOutputFormat {\n const commandFormat = parseOutputFormat(options.format);\n if (global.json && commandFormat && commandFormat !== \"json\") {\n throw new PmCliError(\n \"Cannot combine --json with --format markdown|toon\",\n EXIT_CODE.USAGE,\n );\n }\n if (global.json) {\n return \"json\";\n }\n return commandFormat ?? \"toon\";\n}\n\n// --depth full surfaces the entire backlog: when no explicit --limit is given,\n// every section returns all rows instead of the default top-N sample.\nfunction parseContextLimit(\n raw: string | undefined,\n depth: ContextDepth,\n): number {\n return (\n parseIntegerLimit(raw, \"--limit\") ??\n (depth === \"full\" ? Number.MAX_SAFE_INTEGER : DEFAULT_CONTEXT_LIMIT)\n );\n}\n\nfunction resolveContextLimitAtScale(limit: number, itemCount: number): number {\n return itemCount >= CONTEXT_SCALE_THRESHOLD && limit === Number.MAX_SAFE_INTEGER\n ? DEFAULT_CONTEXT_LIMIT\n : limit;\n}\n\n/** Implements parse context depth for the public runtime surface of this module. */\nexport function parseContextDepth(\n raw: string | undefined,\n settings: ContextSettings,\n): ContextDepth {\n if (!raw) return settings.default_depth;\n const normalized = raw.trim().toLowerCase();\n if (!CONTEXT_DEPTH_VALUES.includes(normalized as ContextDepth)) {\n throw new PmCliError(\n `Context --depth must be one of ${CONTEXT_DEPTH_VALUES.join(\"|\")}`,\n EXIT_CODE.USAGE,\n );\n }\n return normalized as ContextDepth;\n}\n\n/** Implements parse context sections for the public runtime surface of this module. */\nexport function parseContextSections(\n raw: string[] | undefined,\n depth: ContextDepth,\n settings: ContextSettings,\n): ContextSectionName[] {\n if (raw && raw.length > 0) {\n const sections: ContextSectionName[] = [];\n for (const value of raw) {\n const normalized = value.trim().toLowerCase();\n if (!CONTEXT_SECTION_VALUES.includes(normalized as ContextSectionName)) {\n throw new PmCliError(\n `Context --section must be one of ${CONTEXT_SECTION_VALUES.join(\"|\")}`,\n EXIT_CODE.USAGE,\n );\n }\n if (!sections.includes(normalized as ContextSectionName)) {\n sections.push(normalized as ContextSectionName);\n }\n }\n return sections;\n }\n if (depth === \"brief\") return [];\n // --depth full is the comprehensive snapshot: every known section, regardless\n // of the per-section settings toggles that brief/standard/deep respect.\n if (depth === \"full\") return [...CONTEXT_SECTION_VALUES];\n const pool = depth === \"deep\" ? DEEP_SECTIONS : STANDARD_SECTIONS;\n return pool.filter((section) => settings.sections[section]);\n}\n\nfunction parseActivityLimit(\n raw: string | undefined,\n settings: ContextSettings,\n): number {\n if (!raw) return settings.activity_limit;\n const parsed = parseIntegerLimit(raw, \"--activity-limit\");\n /* c8 ignore start -- parseIntegerLimit either throws or returns a number; fallback is defensive typing guard */\n return parsed ?? settings.activity_limit;\n /* c8 ignore stop */\n}\n\nfunction parseStaleThresholdDays(\n raw: string | undefined,\n settings: ContextSettings,\n): number {\n if (!raw) return settings.stale_threshold_days;\n const trimmed = raw.trim().toLowerCase();\n const match = /^(\\d+)d?$/.exec(trimmed);\n if (!match) {\n throw new PmCliError(\n \"--stale-threshold must be a number of days (e.g. 7 or 7d)\",\n EXIT_CODE.USAGE,\n );\n }\n const days = parseInt(match[1], 10);\n if (days <= 0) {\n throw new PmCliError(\"--stale-threshold must be positive\", EXIT_CODE.USAGE);\n }\n return days;\n}\n\n// ---------------------------------------------------------------------------\n// Status helpers\n// ---------------------------------------------------------------------------\n\nfunction statusRank(\n status: ItemStatus,\n statusRegistry: RuntimeStatusRegistry,\n): number {\n const normalizedStatus = normalizeStatusForRegistry(status, statusRegistry);\n const inProgressStatus = normalizeStatusInput(\"in_progress\", statusRegistry);\n const openStatus = normalizeStatusInput(\"open\", statusRegistry);\n const blockedStatus = normalizeStatusInput(\"blocked\", statusRegistry);\n const draftStatus = normalizeStatusInput(\"draft\", statusRegistry);\n if (inProgressStatus && normalizedStatus === inProgressStatus) return 0;\n if (openStatus && normalizedStatus === openStatus) return 1;\n if (blockedStatus && normalizedStatus === blockedStatus) return 2;\n if (draftStatus && normalizedStatus === draftStatus) return 3;\n if (statusRegistry.active_statuses.has(normalizedStatus)) return 4;\n if (statusRegistry.blocked_statuses.has(normalizedStatus)) return 5;\n if (statusRegistry.terminal_statuses.has(normalizedStatus)) return 7;\n return 6;\n}\n\nfunction isClosedStatus(\n status: ItemStatus,\n statusRegistry: RuntimeStatusRegistry,\n): boolean {\n const closeStatus = normalizeStatusInput(\"closed\", statusRegistry);\n return normalizeStatusForRegistry(status, statusRegistry) === closeStatus;\n}\n\nfunction isInProgressStatus(\n status: ItemStatus,\n statusRegistry: RuntimeStatusRegistry,\n): boolean {\n const inProgressStatus = normalizeStatusInput(\"in_progress\", statusRegistry);\n return (\n normalizeStatusForRegistry(status, statusRegistry) === inProgressStatus\n );\n}\n\nfunction isOpenStatus(\n status: ItemStatus,\n statusRegistry: RuntimeStatusRegistry,\n): boolean {\n const openStatus = normalizeStatusInput(\"open\", statusRegistry);\n return normalizeStatusForRegistry(status, statusRegistry) === openStatus;\n}\n\nfunction isBlockedStatus(\n status: ItemStatus,\n statusRegistry: RuntimeStatusRegistry,\n): boolean {\n return statusRegistry.blocked_statuses.has(\n normalizeStatusForRegistry(status, statusRegistry),\n );\n}\n\n// Projection flags belong to list/calendar/activity output shaping and must not\n// leak into runContext's downstream calls, which need full ItemMetadata rows.\n// --parent is a context-level subtree scope computed here transitively, so it\n// must not reach runList (whose --parent matches direct children only).\nconst LIST_PROJECTION_FLAGS = [\n \"compact\",\n \"brief\",\n \"fields\",\n \"includeBody\",\n \"include_body\",\n \"parent\",\n] as const;\n\nfunction stripListProjectionFlags(\n options: ContextOptions,\n): Record<string, unknown> {\n const copy: Record<string, unknown> = {\n ...(options as Record<string, unknown>),\n };\n for (const key of LIST_PROJECTION_FLAGS) {\n delete copy[key];\n }\n return copy;\n}\n\n/**\n * Resolves the transitive subtree (the anchor item plus every descendant via\n * parent links) so `--parent` can scope a snapshot to one epic/milestone. Reuses\n * the same {@link buildChildrenByParent}/{@link collectDescendants} helpers the\n * hierarchy section relies on, so subtree membership stays consistent across the\n * snapshot. Ids are normalized to lowercase for case-insensitive membership; the\n * `found` flag is false when the anchor id is absent from the corpus. Exported so\n * sibling read commands (e.g. `pm next`) can apply the same subtree scoping.\n */\nexport function collectSubtreeIds(\n corpus: ItemMetadata[],\n parentId: string,\n): { ids: Set<string>; found: boolean } {\n const target = parentId.trim().toLowerCase();\n const anchor = corpus.find((item) => item.id.trim().toLowerCase() === target);\n if (!anchor) {\n return { ids: new Set<string>(), found: false };\n }\n const childrenByParent = buildChildrenByParent(corpus);\n const descendants = collectDescendants(anchor.id, childrenByParent);\n // Store normalized ids so membership checks are case-insensitive end-to-end.\n const ids = new Set<string>(\n [anchor.id, ...descendants.map((item) => item.id)].map((id) =>\n id.trim().toLowerCase(),\n ),\n );\n return { ids, found: true };\n}\n\nfunction parseContextParent(raw: string | undefined): string | undefined {\n if (raw === undefined) return undefined;\n const trimmed = raw.trim();\n if (trimmed.length === 0) {\n throw new PmCliError(\n \"Context --parent requires an item id\",\n EXIT_CODE.USAGE,\n );\n }\n return trimmed;\n}\n\n// ---------------------------------------------------------------------------\n// Sorting / mapping helpers (unchanged from original)\n// ---------------------------------------------------------------------------\n\nfunction compareOptionalOrder(\n left: number | null | undefined,\n right: number | null | undefined,\n): number {\n const leftValue = left ?? null;\n const rightValue = right ?? null;\n if (leftValue === null && rightValue === null) return 0;\n if (leftValue === null) return 1;\n if (rightValue === null) return -1;\n return leftValue - rightValue;\n}\n\nfunction compareOptionalDeadline(\n left: string | null | undefined,\n right: string | null | undefined,\n): number {\n const leftValue = left ?? null;\n const rightValue = right ?? null;\n if (leftValue === null && rightValue === null) return 0;\n if (leftValue === null) return 1;\n if (rightValue === null) return -1;\n return compareTimestampStrings(leftValue, rightValue);\n}\n\nfunction daysInUtcMonth(year: number, monthIndex: number): number {\n return new Date(Date.UTC(year, monthIndex + 1, 0)).getUTCDate();\n}\n\nfunction hasNoInvalidDatePrefix(value: string): boolean {\n const match =\n LEADING_HYPHEN_DATE.exec(value) ?? LEADING_COMPACT_DATE.exec(value);\n if (!match) {\n return true;\n }\n const year = Number.parseInt(match[1], 10);\n const month = Number.parseInt(match[2], 10);\n const day = Number.parseInt(match[3], 10);\n return (\n month >= 1 &&\n month <= 12 &&\n day >= 1 &&\n day <= daysInUtcMonth(year, month - 1)\n );\n}\n\nfunction normalizeTimestampCandidate(value: string): string {\n const compactDate = COMPACT_DATE.exec(value);\n if (compactDate) {\n return `${compactDate[1]}-${compactDate[2]}-${compactDate[3]}`;\n }\n const compactDateTime = COMPACT_DATETIME.exec(value);\n if (compactDateTime) {\n const [, year, month, day, hour, minute, secondRaw, offsetRaw] =\n compactDateTime;\n const second = secondRaw ? `:${secondRaw}` : \"\";\n const offset =\n offsetRaw && offsetRaw.length === 5 && offsetRaw !== \"Z\"\n ? `${offsetRaw.slice(0, 3)}:${offsetRaw.slice(3)}`\n : (offsetRaw ?? \"\");\n return `${year}-${month}-${day}T${hour}:${minute}${second}${offset}`;\n }\n return value;\n}\n\nfunction parseContextTimestampMs(value: unknown): number {\n if (typeof value !== \"string\") {\n return Number.NaN;\n }\n const trimmed = value.trim();\n if (trimmed.length === 0 || !hasNoInvalidDatePrefix(trimmed)) {\n return Number.NaN;\n }\n const parsed = Date.parse(normalizeTimestampCandidate(trimmed));\n return Number.isFinite(parsed) ? parsed : Number.NaN;\n}\n\nfunction sortableTimestamp(value: unknown): string {\n const parsed = parseContextTimestampMs(value);\n return Number.isFinite(parsed) ? new Date(parsed).toISOString() : \"\";\n}\n\nfunction dateTokenForTimestamp(value: unknown): string {\n const parsed = parseContextTimestampMs(value);\n return Number.isFinite(parsed)\n ? new Date(parsed).toISOString().slice(0, 10)\n : \"unknown\";\n}\n\nfunction normalizedParentId(value: unknown): string | null {\n if (typeof value !== \"string\") {\n return null;\n }\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : null;\n}\n\n/**\n * Ranks two items by work criticality: in-progress before open before blocked\n * before draft (via {@link statusRank}), then ascending priority, explicit order,\n * earliest deadline, most-recently-updated, and finally id for a total order.\n * Exported as the canonical focus ordering so sibling read commands (e.g.\n * `pm next`) recommend work in the exact same sequence as `pm context`.\n */\nexport function compareCriticalItems(\n left: ItemMetadata,\n right: ItemMetadata,\n statusRegistry: RuntimeStatusRegistry,\n): number {\n const byStatus =\n statusRank(left.status, statusRegistry) -\n statusRank(right.status, statusRegistry);\n if (byStatus !== 0) return byStatus;\n const byPriority = left.priority - right.priority;\n if (byPriority !== 0) return byPriority;\n const byOrder = compareOptionalOrder(left.order, right.order);\n if (byOrder !== 0) return byOrder;\n const byDeadline = compareOptionalDeadline(left.deadline, right.deadline);\n if (byDeadline !== 0) return byDeadline;\n const byUpdated = compareTimestampStrings(\n sortableTimestamp(right.updated_at),\n sortableTimestamp(left.updated_at),\n );\n const byId = left.id.localeCompare(right.id);\n return byUpdated !== 0 ? byUpdated : byId;\n}\n\nfunction normalizedPressure(value: unknown, maximum: number): number {\n const parsed =\n typeof value === \"number\"\n ? value\n : typeof value === \"string\"\n ? Number.parseFloat(value)\n : Number.NaN;\n if (!Number.isFinite(parsed)) return 0;\n return 1 - Math.min(Math.max(parsed, 0), maximum) / maximum;\n}\n\nfunction resolveDeadlinePressure(deadline: unknown, nowMs: number): number {\n const deadlineMs =\n typeof deadline === \"string\"\n ? Date.parse(deadline)\n : deadline instanceof Date\n ? deadline.getTime()\n : typeof deadline === \"number\"\n ? deadline\n : Number.NaN;\n if (!Number.isFinite(deadlineMs) || !Number.isFinite(nowMs)) return 0;\n const deadlineDays = (deadlineMs - nowMs) / (24 * 60 * 60 * 1000);\n return deadlineDays <= 0 ? 1 : 1 / (1 + deadlineDays / 30);\n}\n\nfunction resolveRiskPressure(risk: ItemMetadata[\"risk\"]): number {\n const normalized =\n typeof risk === \"string\" ? risk.trim().toLowerCase() : undefined;\n if (normalized === \"critical\" || normalized === \"high\") return 1;\n if (normalized === \"medium\") return 0.5;\n return normalized === \"low\" ? 0.1 : 0;\n}\n\nfunction buildItemContextRelevanceCandidate(\n item: ItemMetadata,\n params: {\n statusRegistry: RuntimeStatusRegistry;\n nowMs: number;\n normalizedAuthor: string | undefined;\n recencyRank: ReadonlyMap<string, number>;\n recencyDenominator: number;\n itemCount: number;\n },\n): ContextRelevanceCandidate<ItemMetadata> {\n const assignedToAuthor =\n params.normalizedAuthor !== undefined &&\n typeof item.assignee === \"string\" &&\n item.assignee.trim().toLowerCase() === params.normalizedAuthor;\n const claimFocus = isInProgressStatus(item.status, params.statusRegistry)\n ? 1\n : assignedToAuthor\n ? 0.75\n : 0;\n const riskPressure = resolveRiskPressure(item.risk);\n const knowledgeEntries =\n (item.comments?.length ?? 0) +\n (item.notes?.length ?? 0) +\n (item.learnings?.length ?? 0);\n return {\n id: item.id,\n item,\n signals: {\n recency:\n params.itemCount === 1\n ? 1\n : 1 -\n (params.recencyRank.get(item.id) as number) /\n params.recencyDenominator,\n graph_proximity: item.parent ? 0.3 : 0,\n claim_focus: claimFocus,\n priority_pressure: normalizedPressure(item.priority, 4),\n risk_pressure: riskPressure,\n deadline_pressure: resolveDeadlinePressure(item.deadline, params.nowMs),\n knowledge_density: Math.min(knowledgeEntries / 5, 1),\n author_affinity: assignedToAuthor ? 1 : 0,\n },\n };\n}\n\n/** Derives the metadata signals currently available on compact item rows. More expensive history/index/semantic signals can be added by an extension scorer without changing the public candidate contract. */\nexport function buildItemContextRelevanceCandidates(\n items: readonly ItemMetadata[],\n statusRegistry: RuntimeStatusRegistry,\n now: string,\n author: string | undefined,\n): ContextRelevanceCandidate<ItemMetadata>[] {\n const recencyOrder = [...items].sort(\n (left, right) =>\n compareTimestampStrings(\n sortableTimestamp(right.updated_at),\n sortableTimestamp(left.updated_at),\n ) || left.id.localeCompare(right.id),\n );\n const recencyRank = new Map(\n recencyOrder.map((item, index) => [item.id, index]),\n );\n const recencyDenominator = Math.max(items.length - 1, 1);\n const normalizedAuthor = author?.trim().toLowerCase();\n const nowMs = Date.parse(now);\n return items.map((item) =>\n buildItemContextRelevanceCandidate(item, {\n statusRegistry,\n nowMs,\n normalizedAuthor,\n recencyRank,\n recencyDenominator,\n itemCount: items.length,\n }),\n );\n}\n\n/** Project a full scorer report onto the low-token command explanation shape. */\nexport function toContextRankingSummary<TItem>(\n report: ContextRelevanceReport<TItem>,\n): ContextRankingSummary {\n return {\n model: report.model,\n available_signals: report.available_signals,\n items: report.ranked.map((entry) => ({\n id: entry.id,\n rank: entry.rank,\n baseline_rank: entry.baseline_rank,\n score: entry.score,\n contributions: entry.contributions,\n })),\n };\n}\n\nfunction completionPct(closed: number, total: number): number {\n return total > 0 ? Math.round((closed / total) * 100) : 0;\n}\n\n/** Indexes items by their parent id, yielding a parent→direct-children map used by the hierarchy/progress rollups and by focus-row child completion. Items without a parent are skipped. Exported so sibling read commands reuse the same index. */\nexport function buildChildrenByParent(\n allItems: ItemMetadata[],\n): Map<string, ItemMetadata[]> {\n const childrenByParent = new Map<string, ItemMetadata[]>();\n for (const item of allItems) {\n const parent = normalizedParentId(item.parent);\n if (!parent) continue;\n const children = childrenByParent.get(parent) ?? [];\n children.push(item);\n childrenByParent.set(parent, children);\n }\n return childrenByParent;\n}\n\n/**\n * Projects an item onto the compact {@link ContextFocusItem} focus row. When both\n * a status registry and a parent→children index are supplied, it also folds in the\n * descendant rollup (`children_total`/`children_closed`/`completion_pct`). Exported\n * so sibling read commands (e.g. `pm next`) emit identically-shaped focus rows.\n */\nexport function toContextFocusItem(\n item: ItemMetadata,\n statusRegistry?: RuntimeStatusRegistry,\n childrenByParent?: Map<string, ItemMetadata[]>,\n): ContextFocusItem {\n const focus: ContextFocusItem = {\n id: item.id,\n title: item.title,\n type: item.type,\n status: item.status,\n priority: item.priority,\n order: item.order ?? null,\n deadline: item.deadline ?? null,\n assignee: item.assignee ?? null,\n tags: Array.isArray(item.tags) ? [...item.tags] : [],\n updated_at: item.updated_at,\n parent: normalizedParentId(item.parent),\n };\n if (statusRegistry && childrenByParent) {\n const descendants = collectDescendants(item.id, childrenByParent);\n const total = descendants.length;\n if (total > 0) {\n const closed = descendants.filter((desc) =>\n isClosedStatus(desc.status, statusRegistry),\n ).length;\n focus.children_total = total;\n focus.children_closed = closed;\n focus.completion_pct = completionPct(closed, total);\n }\n }\n return focus;\n}\n\nfunction summarizeAgenda(events: CalendarRow[]): ContextAgendaSummary {\n let deadlines = 0;\n let reminders = 0;\n let scheduled = 0;\n const itemIds = new Set<string>();\n for (const event of events) {\n itemIds.add(event.item_id);\n if (event.kind === \"deadline\") {\n deadlines += 1;\n continue;\n }\n if (event.kind === \"reminder\") {\n reminders += 1;\n continue;\n }\n scheduled += 1;\n }\n return {\n events: events.length,\n items: itemIds.size,\n deadlines,\n reminders,\n scheduled,\n };\n}\n\nfunction mergeSortedWarnings(\n ...warningGroups: Array<string[] | undefined>\n): string[] {\n return [...new Set(warningGroups.flatMap((group) => group ?? []))].sort(\n (left, right) => left.localeCompare(right),\n );\n}\n\nfunction filterTerminalCalendarEvents(\n events: CalendarRow[],\n statusRegistry: RuntimeStatusRegistry,\n): CalendarRow[] {\n return events.filter(\n (event) =>\n !statusRegistry.terminal_statuses.has(\n normalizeStatusForRegistry(event.item_status, statusRegistry),\n ),\n );\n}\n\n// ---------------------------------------------------------------------------\n// Section builders\n// ---------------------------------------------------------------------------\n\nfunction buildHierarchy(\n allItems: ItemMetadata[],\n activeItems: ItemMetadata[],\n statusRegistry: RuntimeStatusRegistry,\n limit: number,\n): HierarchyNode[] {\n const itemMap = new Map<string, ItemMetadata>();\n for (const item of allItems) {\n itemMap.set(item.id, item);\n }\n\n const childrenByParent = buildChildrenByParent(allItems);\n\n const activeHighLevelIds = new Set(\n activeItems\n .filter((item) => HIGH_LEVEL_TYPES.has(item.type))\n .map((item) => item.id),\n );\n\n const nodes: HierarchyNode[] = [];\n for (const parentId of activeHighLevelIds) {\n const parent = itemMap.get(parentId);\n if (!parent) continue;\n const allDescendants = collectDescendants(parentId, childrenByParent);\n const childItems = childrenByParent.get(parentId) ?? [];\n\n let closedCount = 0;\n let openCount = 0;\n let inProgressCount = 0;\n let blockedCount = 0;\n /* c8 ignore start -- chained status-classification branch accounting is noisy under v8 for mixed descendant sets */\n for (const desc of allDescendants) {\n if (isClosedStatus(desc.status, statusRegistry)) closedCount++;\n else if (isInProgressStatus(desc.status, statusRegistry))\n inProgressCount++;\n else if (isBlockedStatus(desc.status, statusRegistry)) blockedCount++;\n else if (isOpenStatus(desc.status, statusRegistry)) openCount++;\n }\n /* c8 ignore stop */\n\n const children: HierarchyChild[] = childItems\n .sort((a, b) => compareCriticalItems(a, b, statusRegistry))\n .slice(0, limit)\n .map((child) => {\n const grandchildren = collectDescendants(child.id, childrenByParent);\n const gcClosed = grandchildren.filter((gc) =>\n isClosedStatus(gc.status, statusRegistry),\n ).length;\n return {\n id: child.id,\n title: child.title,\n type: child.type,\n status: child.status,\n children_total: grandchildren.length,\n children_closed: gcClosed,\n };\n });\n\n nodes.push({\n id: parent.id,\n title: parent.title,\n type: parent.type,\n status: parent.status,\n children_total: allDescendants.length,\n children_closed: closedCount,\n children_open: openCount,\n children_in_progress: inProgressCount,\n children_blocked: blockedCount,\n children,\n });\n }\n\n return nodes\n .sort((a, b) => {\n const aParent = itemMap.get(a.id)!;\n const bParent = itemMap.get(b.id)!;\n return compareCriticalItems(aParent, bParent, statusRegistry);\n })\n .slice(0, limit);\n}\n\nfunction collectDescendants(\n parentId: string,\n childrenByParent: Map<string, ItemMetadata[]>,\n): ItemMetadata[] {\n const result: ItemMetadata[] = [];\n const stack = [parentId];\n const visited = new Set<string>();\n while (stack.length > 0) {\n const current = stack.pop()!;\n if (visited.has(current)) continue;\n visited.add(current);\n const children = childrenByParent.get(current) ?? [];\n for (const child of children) {\n result.push(child);\n stack.push(child.id);\n }\n }\n return result;\n}\n\n/** Public contract for test only, shared by SDK and presentation-layer consumers. */\nexport const _testOnly = {\n buildActivity,\n buildBlockers,\n buildChildrenByParent,\n buildHierarchy,\n buildHotFiles,\n buildProgress,\n buildRecentlyCreated,\n buildStaleness,\n buildTestHealth,\n buildUnparented,\n buildWorkload,\n collectDescendants,\n collectSubtreeIds,\n compareCriticalItems,\n compareOptionalDeadline,\n compareOptionalOrder,\n completionPct,\n dateTokenForTimestamp,\n filterTerminalCalendarEvents,\n isBlockedStatus,\n isClosedStatus,\n isInProgressStatus,\n isOpenStatus,\n mergeSortedWarnings,\n normalizedParentId,\n parseActivityLimit,\n parseContextLimit,\n resolveContextLimitAtScale,\n parseContextParent,\n parseContextTimestampMs,\n parseStaleThresholdDays,\n sortableTimestamp,\n statusRank,\n stripListProjectionFlags,\n summarizeAgenda,\n toContextFocusItem,\n};\n\nasync function buildActivity(\n activityLimit: number,\n global: GlobalOptions,\n): Promise<CompactActivityEntry[]> {\n const result = await runActivity(\n { compact: true, limit: String(activityLimit) },\n global,\n );\n return result.compact_activity ?? [];\n}\n\nfunction buildProgress(\n allItems: ItemMetadata[],\n activeItems: ItemMetadata[],\n statusRegistry: RuntimeStatusRegistry,\n limit: number,\n): ProgressEntry[] {\n const childrenByParent = new Map<string, ItemMetadata[]>();\n for (const item of allItems) {\n if (!item.parent) continue;\n const children = childrenByParent.get(item.parent) ?? [];\n children.push(item);\n childrenByParent.set(item.parent, children);\n }\n\n const activeHighLevel = activeItems.filter((item) =>\n HIGH_LEVEL_TYPES.has(item.type),\n );\n const entries: ProgressEntry[] = [];\n for (const parent of activeHighLevel) {\n const descendants = collectDescendants(parent.id, childrenByParent);\n const total = descendants.length;\n if (total === 0) continue;\n\n let closed = 0;\n let open = 0;\n let inProgress = 0;\n let blocked = 0;\n /* c8 ignore start -- chained status-classification branch accounting is noisy under v8 for mixed descendant sets */\n for (const desc of descendants) {\n if (isClosedStatus(desc.status, statusRegistry)) closed++;\n else if (isInProgressStatus(desc.status, statusRegistry)) inProgress++;\n else if (isBlockedStatus(desc.status, statusRegistry)) blocked++;\n else if (isOpenStatus(desc.status, statusRegistry)) open++;\n }\n /* c8 ignore stop */\n\n entries.push({\n id: parent.id,\n title: parent.title,\n type: parent.type,\n total,\n closed,\n open,\n in_progress: inProgress,\n blocked,\n completion_pct: completionPct(closed, total),\n });\n }\n\n return entries\n .sort((a, b) => a.completion_pct - b.completion_pct)\n .slice(0, limit);\n}\n\nfunction buildBlockers(\n blockedItems: ItemMetadata[],\n itemMap: Map<string, ItemMetadata>,\n limit: number,\n): BlockerEntry[] {\n return blockedItems.slice(0, limit).map((item) => {\n const blockerItem = item.blocked_by\n ? itemMap.get(item.blocked_by)\n : undefined;\n return {\n id: item.id,\n title: item.title,\n blocked_by: item.blocked_by ?? null,\n blocked_by_title: blockerItem?.title ?? null,\n blocked_by_status: blockerItem?.status ?? null,\n blocked_reason: item.blocked_reason ?? null,\n unblock_note: item.unblock_note ?? null,\n };\n });\n}\n\nfunction buildHotFiles(\n activeItems: ItemMetadata[],\n limit: number,\n): HotFile[] {\n const fileMap = new Map<string, Set<string>>();\n for (const item of activeItems) {\n for (const file of item.files ?? []) {\n const existing = fileMap.get(file.path) ?? new Set<string>();\n existing.add(item.id);\n fileMap.set(file.path, existing);\n }\n }\n\n return [...fileMap.entries()]\n .map(([filePath, itemIds]) => ({\n path: filePath,\n references: itemIds.size,\n items: [...itemIds].sort(),\n }))\n .sort((a, b) => b.references - a.references)\n .slice(0, limit);\n}\n\nfunction buildWorkload(\n activeItems: ItemMetadata[],\n statusRegistry: RuntimeStatusRegistry,\n limit: number,\n): WorkloadEntry[] {\n const groups = new Map<string | null, ItemMetadata[]>();\n for (const item of activeItems) {\n const key = item.assignee ?? null;\n const existing = groups.get(key) ?? [];\n existing.push(item);\n groups.set(key, existing);\n }\n\n return [...groups.entries()]\n .map(([assignee, items]) => ({\n assignee,\n active: items.length,\n in_progress: items.filter((item) =>\n isInProgressStatus(item.status, statusRegistry),\n ).length,\n items: items.map((item) => item.id).sort(),\n }))\n .sort((a, b) => b.active - a.active)\n .slice(0, limit);\n}\n\nfunction buildStaleness(\n allNonTerminal: ItemMetadata[],\n staleThresholdDays: number,\n now: string,\n limit: number,\n): StaleEntry[] {\n const cutoffMs =\n new Date(now).getTime() - staleThresholdDays * 24 * 60 * 60 * 1000;\n\n return allNonTerminal\n .filter((item) => new Date(item.updated_at).getTime() < cutoffMs)\n .map((item) => ({\n id: item.id,\n title: item.title,\n status: item.status,\n updated_at: item.updated_at,\n stale_days: Math.floor(\n (new Date(now).getTime() - new Date(item.updated_at).getTime()) /\n (24 * 60 * 60 * 1000),\n ),\n }))\n .sort((a, b) => b.stale_days - a.stale_days)\n .slice(0, limit);\n}\n\nfunction buildRecentlyCreated(\n allNonTerminal: ItemMetadata[],\n statusRegistry: RuntimeStatusRegistry,\n childrenByParent: Map<string, ItemMetadata[]>,\n limit: number,\n): RecentContextItem[] {\n return allNonTerminal\n .map((item) => ({ item, sortKey: sortableTimestamp(item.created_at) }))\n .sort((left, right) => {\n const byCreated = compareTimestampStrings(right.sortKey, left.sortKey);\n return byCreated !== 0\n ? byCreated\n : left.item.id.localeCompare(right.item.id);\n })\n .slice(0, limit)\n .map(({ item }) => ({\n ...toContextFocusItem(item, statusRegistry, childrenByParent),\n created_at: item.created_at,\n }));\n}\n\nfunction buildUnparented(\n allNonTerminal: ItemMetadata[],\n statusRegistry: RuntimeStatusRegistry,\n childrenByParent: Map<string, ItemMetadata[]>,\n limit: number,\n): ContextFocusItem[] {\n return allNonTerminal\n .filter(\n (item) =>\n !normalizedParentId(item.parent) && !HIGH_LEVEL_TYPES.has(item.type),\n )\n .sort((left, right) => compareCriticalItems(left, right, statusRegistry))\n .slice(0, limit)\n .map((item) => toContextFocusItem(item, statusRegistry, childrenByParent));\n}\n\nfunction buildTestHealth(activeItems: ItemMetadata[]): TestHealthSummary {\n let itemsWithTests = 0;\n let itemsWithRecentRuns = 0;\n let passed = 0;\n let failed = 0;\n let skipped = 0;\n const itemsFailing: string[] = [];\n\n for (const item of activeItems) {\n if ((item.tests ?? []).length > 0) {\n itemsWithTests++;\n }\n const runs = item.test_runs ?? [];\n if (runs.length > 0) {\n itemsWithRecentRuns++;\n let itemHasFailure = false;\n for (const run of runs) {\n passed += run.passed ?? 0;\n failed += run.failed ?? 0;\n skipped += run.skipped ?? 0;\n if ((run.failed ?? 0) > 0) {\n itemHasFailure = true;\n }\n }\n if (itemHasFailure) {\n itemsFailing.push(item.id);\n }\n }\n }\n\n return {\n items_with_tests: itemsWithTests,\n items_with_recent_runs: itemsWithRecentRuns,\n recent_runs: { passed, failed, skipped },\n items_failing: itemsFailing.sort(),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Markdown formatting\n// ---------------------------------------------------------------------------\n\nfunction formatClock(timestamp: string): string {\n return `${new Date(timestamp).toISOString().slice(11, 16)}Z`;\n}\n\nfunction formatFocusLine(item: ContextFocusItem): string {\n const orderToken = item.order === null ? \"-\" : String(item.order);\n const deadlineToken = item.deadline ?? \"-\";\n const parentToken = item.parent ? ` parent:${item.parent}` : \"\";\n const progressToken =\n item.children_total !== undefined &&\n item.children_closed !== undefined &&\n item.completion_pct !== undefined\n ? ` children:${item.children_closed}/${item.children_total} done:${item.completion_pct}%`\n : \"\";\n return `${item.id} p${item.priority} ${item.status} ${item.type} order:${orderToken} deadline:${deadlineToken}${parentToken}${progressToken} ${item.title}`;\n}\n\n// Renders a focus row projected to a `--fields` subset as space-separated\n// field:value tokens, mirroring the projection field order. Array values join\n// with commas; missing/null values render as `-`.\nfunction formatProjectedFocusLine(\n item: ContextFocusItem,\n fields: string[],\n): string {\n const source = item as unknown as Record<string, unknown>;\n return fields\n .map((field) => {\n const value = source[field];\n if (Array.isArray(value)) return `${field}:${value.join(\",\")}`;\n return `${field}:${value ?? \"-\"}`;\n })\n .join(\" \");\n}\n\nfunction formatAgendaLine(event: CalendarRow): string {\n const base = `${formatClock(event.at)} [${event.kind}] ${event.item_id} p${event.item_priority} ${event.item_status} ${event.item_title}`;\n if (event.kind === \"reminder\") {\n return `${base} — ${event.reminder_text}`;\n }\n if (event.kind === \"event\") {\n const recurringSuffix = event.event_recurring ? \" (recurring)\" : \"\";\n const title = event.event_title ?? event.item_title;\n return `${base} — ${title}${recurringSuffix}`;\n }\n return base;\n}\n\nfunction pushContextFocusSection(\n lines: string[],\n title: string,\n rows: ContextFocusItem[],\n emptyText: string,\n renderFocus: (item: ContextFocusItem) => string,\n): void {\n lines.push(`## ${title}`);\n if (rows.length === 0) {\n lines.push(emptyText);\n } else {\n for (const item of rows) {\n lines.push(`- ${renderFocus(item)}`);\n }\n }\n lines.push(\"\");\n}\n\nfunction pushBlockedFallbackSection(\n lines: string[],\n result: ContextResult,\n renderFocus: (item: ContextFocusItem) => string,\n): void {\n if (result.blocked_fallback.length === 0) {\n return;\n }\n lines.push(\"## Blocked fallback\");\n for (const item of result.blocked_fallback) {\n lines.push(`- ${renderFocus(item)}`);\n }\n lines.push(\"\");\n}\n\nfunction pushAgendaSection(lines: string[], result: ContextResult): void {\n lines.push(\"## Agenda\");\n lines.push(\n `- events: ${result.agenda.summary.events} (deadlines: ${result.agenda.summary.deadlines}, reminders: ${result.agenda.summary.reminders}, scheduled: ${result.agenda.summary.scheduled})`,\n );\n if (result.agenda.events.length === 0) {\n lines.push(\"No agenda events matched the selected filters.\");\n } else {\n for (const event of result.agenda.events) {\n lines.push(`- ${formatAgendaLine(event)}`);\n }\n }\n lines.push(\"\");\n}\n\nfunction pushHierarchySection(lines: string[], result: ContextResult): void {\n if (!result.hierarchy || result.hierarchy.length === 0) {\n return;\n }\n lines.push(\"## Hierarchy\");\n for (const node of result.hierarchy) {\n const pct =\n node.children_total > 0\n ? Math.round((node.children_closed / node.children_total) * 100)\n : 0;\n lines.push(\n `- ${node.id} ${node.type} ${node.status} \"${node.title}\" [${node.children_closed}/${node.children_total} done ${pct}%]`,\n );\n for (const child of node.children) {\n const cpct =\n child.children_total > 0\n ? Math.round((child.children_closed / child.children_total) * 100)\n : 0;\n lines.push(\n ` - ${child.id} ${child.type} ${child.status} \"${child.title}\" [${child.children_closed}/${child.children_total} done ${cpct}%]`,\n );\n }\n }\n lines.push(\"\");\n}\n\nfunction pushProgressSection(lines: string[], result: ContextResult): void {\n if (!result.progress || result.progress.length === 0) {\n return;\n }\n lines.push(\"## Progress\");\n for (const entry of result.progress) {\n lines.push(\n `- ${entry.id} \"${entry.title}\" ${entry.completion_pct}% (${entry.closed}/${entry.total} closed, ${entry.in_progress} wip, ${entry.open} open, ${entry.blocked} blocked)`,\n );\n }\n lines.push(\"\");\n}\n\nfunction pushRecentlyCreatedSection(\n lines: string[],\n result: ContextResult,\n focusFields: string[] | undefined,\n renderFocus: (item: ContextFocusItem) => string,\n): void {\n if (!result.recently_created || result.recently_created.length === 0) {\n return;\n }\n lines.push(\"## Recently created\");\n for (const item of result.recently_created) {\n lines.push(\n focusFields\n ? `- ${renderFocus(item)}`\n : `- ${dateTokenForTimestamp(item.created_at)} ${formatFocusLine(item)}`,\n );\n }\n lines.push(\"\");\n}\n\nfunction pushUnparentedSection(\n lines: string[],\n result: ContextResult,\n renderFocus: (item: ContextFocusItem) => string,\n): void {\n if (!result.unparented || result.unparented.length === 0) {\n return;\n }\n lines.push(\"## Unparented\");\n for (const item of result.unparented) {\n lines.push(`- ${renderFocus(item)}`);\n }\n lines.push(\"\");\n}\n\nfunction pushActivitySection(lines: string[], result: ContextResult): void {\n if (!result.activity || result.activity.length === 0) {\n return;\n }\n lines.push(\"## Recent activity\");\n for (const entry of result.activity) {\n const msg = entry.msg ? ` ${entry.msg}` : \"\";\n lines.push(\n `- ${entry.ts.slice(0, 16)}Z ${entry.id} ${entry.op} by:${entry.author}${msg}`,\n );\n }\n lines.push(\"\");\n}\n\nfunction pushBlockersSection(lines: string[], result: ContextResult): void {\n if (!result.blockers || result.blockers.length === 0) {\n return;\n }\n lines.push(\"## Blockers\");\n for (const entry of result.blockers) {\n const by = entry.blocked_by\n ? `blocked_by:${entry.blocked_by}(${entry.blocked_by_status ?? \"?\"})`\n : \"blocked_by:-\";\n const reason = entry.blocked_reason\n ? ` reason:\"${entry.blocked_reason}\"`\n : \"\";\n const note = entry.unblock_note ? ` unblock:\"${entry.unblock_note}\"` : \"\";\n lines.push(`- ${entry.id} \"${entry.title}\" ${by}${reason}${note}`);\n }\n lines.push(\"\");\n}\n\nfunction pushFilesSection(lines: string[], result: ContextResult): void {\n if (!result.files || result.files.length === 0) {\n return;\n }\n lines.push(\"## Hot files\");\n for (const file of result.files) {\n lines.push(\n `- ${file.path} refs:${file.references} items:[${file.items.join(\",\")}]`,\n );\n }\n lines.push(\"\");\n}\n\nfunction pushWorkloadSection(lines: string[], result: ContextResult): void {\n if (!result.workload || result.workload.length === 0) {\n return;\n }\n lines.push(\"## Workload\");\n for (const entry of result.workload) {\n const who = entry.assignee ?? \"(unassigned)\";\n lines.push(\n `- ${who} active:${entry.active} wip:${entry.in_progress} items:[${entry.items.join(\",\")}]`,\n );\n }\n lines.push(\"\");\n}\n\nfunction pushStalenessSection(lines: string[], result: ContextResult): void {\n if (!result.staleness || result.staleness.length === 0) {\n return;\n }\n lines.push(\"## Stale items\");\n for (const entry of result.staleness) {\n lines.push(\n `- ${entry.id} ${entry.status} stale:${entry.stale_days}d last:${entry.updated_at.slice(0, 10)} \"${entry.title}\"`,\n );\n }\n lines.push(\"\");\n}\n\nfunction pushTestHealthSection(lines: string[], result: ContextResult): void {\n if (!result.tests) {\n return;\n }\n lines.push(\"## Test health\");\n lines.push(`- items_with_tests: ${result.tests.items_with_tests}`);\n lines.push(\n `- items_with_recent_runs: ${result.tests.items_with_recent_runs}`,\n );\n lines.push(\n `- passed: ${result.tests.recent_runs.passed}, failed: ${result.tests.recent_runs.failed}, skipped: ${result.tests.recent_runs.skipped}`,\n );\n if (result.tests.items_failing.length > 0) {\n lines.push(`- items_failing: [${result.tests.items_failing.join(\",\")}]`);\n }\n lines.push(\"\");\n}\n\nfunction pushEmptyContextSuggestions(\n lines: string[],\n result: ContextResult,\n): void {\n const isEmpty =\n result.summary.active_items === 0 &&\n result.summary.blocked === 0 &&\n result.agenda.summary.events === 0;\n if (!isEmpty) {\n return;\n }\n lines.push(\"## Suggestions\");\n lines.push(\"No active work items or upcoming events. Consider:\");\n lines.push('- `pm create --type Task --title \"...\"` to add a new work item');\n lines.push(\n \"- `pm list --status closed --limit 5` to review recent completions\",\n );\n lines.push(\"- `pm search <keywords>` to find related past work\");\n lines.push(\"- `pm aggregate` for a full project status overview\");\n}\n\n/** Implements render context markdown for the public runtime surface of this module. */\nexport function renderContextMarkdown(result: ContextResult): string {\n const lines: string[] = [];\n const focusFields = result.focus_fields;\n const renderFocus = (item: ContextFocusItem): string =>\n focusFields\n ? formatProjectedFocusLine(item, focusFields)\n : formatFocusLine(item);\n lines.push(\"# pm context\");\n lines.push(\"\");\n lines.push(`- now: ${result.now}`);\n lines.push(`- depth: ${result.depth}`);\n if (result.filters.parent) {\n lines.push(`- scope: subtree of ${result.filters.parent}`);\n }\n lines.push(\n `- active_items: ${result.summary.active_items} (in_progress: ${result.summary.in_progress}, open: ${result.summary.open})`,\n );\n if (result.summary.total_items !== undefined) {\n lines.push(\n `- total_items: ${result.summary.total_items} (closed: ${result.summary.closed ?? 0}, canceled: ${result.summary.canceled ?? 0})`,\n );\n }\n lines.push(`- agenda_events: ${result.summary.agenda_events}`);\n lines.push(\n `- blocked_fallback_used: ${result.summary.blocked_fallback_used}`,\n );\n const renderedSections = result.sections_included.filter(\n (section) => section !== \"blockers\" || (result.blockers?.length ?? 0) > 0,\n );\n if (renderedSections.length > 0) {\n lines.push(`- sections: ${renderedSections.join(\", \")}`);\n }\n lines.push(\"\");\n\n pushContextFocusSection(\n lines,\n \"High-level focus\",\n result.high_level,\n \"No high-level active items.\",\n renderFocus,\n );\n pushContextFocusSection(\n lines,\n \"Low-level focus\",\n result.low_level,\n \"No low-level active items.\",\n renderFocus,\n );\n pushBlockedFallbackSection(lines, result, renderFocus);\n pushAgendaSection(lines, result);\n pushHierarchySection(lines, result);\n pushProgressSection(lines, result);\n pushRecentlyCreatedSection(lines, result, focusFields, renderFocus);\n pushUnparentedSection(lines, result, renderFocus);\n pushActivitySection(lines, result);\n pushBlockersSection(lines, result);\n pushFilesSection(lines, result);\n pushWorkloadSection(lines, result);\n pushStalenessSection(lines, result);\n pushTestHealthSection(lines, result);\n pushEmptyContextSuggestions(lines, result);\n\n return lines.join(\"\\n\");\n}\n\n// ---------------------------------------------------------------------------\n// Main runner\n// ---------------------------------------------------------------------------\n\ninterface ContextRuntime {\n settings: PmSettings;\n contextSettings: ContextSettings;\n statusRegistry: RuntimeStatusRegistry;\n depth: ContextDepth;\n limit: number;\n sectionsIncluded: ContextSectionName[];\n activityLimit: number;\n staleThresholdDays: number;\n parentScope: string | undefined;\n focusFields: string[] | undefined;\n baseListOptions: Record<string, unknown>;\n}\n\ninterface ContextCorpus {\n listed: Awaited<ReturnType<typeof runList>>;\n listedItemMetadata: ItemMetadata[];\n allItems: ItemMetadata[];\n fullCorpus: ItemMetadata[];\n subtreeIds: Set<string> | undefined;\n}\n\ninterface ContextFocusGroups {\n activeItems: ItemMetadata[];\n blockedItems: ItemMetadata[];\n highLevel: ContextFocusItem[];\n lowLevel: ContextFocusItem[];\n blockedFallback: ContextFocusItem[];\n blockedFallbackUsed: boolean;\n ranking: ContextRelevanceReport<ItemMetadata>;\n pageExtras: {\n has_more?: boolean;\n next_cursor?: string;\n applied_limit?: number;\n truncated?: true;\n };\n}\n\ninterface ContextOptionalSections {\n hierarchy?: HierarchyNode[];\n activity?: CompactActivityEntry[];\n progress?: ProgressEntry[];\n blockersSection?: BlockerEntry[];\n recentlyCreated?: RecentContextItem[];\n unparented?: ContextFocusItem[];\n filesSection?: HotFile[];\n workload?: WorkloadEntry[];\n staleness?: StaleEntry[];\n tests?: TestHealthSummary;\n}\n\nasync function resolveContextRuntime(\n options: ContextOptions,\n global: GlobalOptions,\n): Promise<ContextRuntime> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n const settings = await readSettings(pmRoot);\n /* c8 ignore start -- settings persistence currently always materializes context defaults */\n const contextSettings = settings.context ?? SETTINGS_DEFAULTS.context;\n /* c8 ignore stop */\n const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);\n const depth = parseContextDepth(options.depth, contextSettings);\n return {\n settings,\n contextSettings,\n statusRegistry,\n depth,\n limit: parseContextLimit(options.limit ?? options.maxItems, depth),\n sectionsIncluded: parseContextSections(\n options.section,\n depth,\n contextSettings,\n ),\n activityLimit: parseActivityLimit(options.activityLimit, contextSettings),\n staleThresholdDays: parseStaleThresholdDays(\n options.staleThreshold,\n contextSettings,\n ),\n parentScope: parseContextParent(options.parent),\n focusFields: parseContextFocusFields(options.fields),\n baseListOptions: stripListProjectionFlags(options),\n };\n}\n\nfunction contextNeedsAllItems(sectionsIncluded: ContextSectionName[]): boolean {\n return sectionsIncluded.some((section) =>\n [\n \"hierarchy\",\n \"progress\",\n \"blockers\",\n \"staleness\",\n \"recently_created\",\n \"unparented\",\n ].includes(section),\n );\n}\n\nfunction buildUnpaginatedContextListOptions(\n baseListOptions: Record<string, unknown>,\n extra: Partial<ListOptions>,\n): ListOptions {\n return {\n ...baseListOptions,\n ...extra,\n noTruncate: true,\n limit: undefined,\n offset: undefined,\n after: undefined,\n };\n}\n\nasync function loadContextCorpus(\n options: ContextOptions,\n global: GlobalOptions,\n runtime: ContextRuntime,\n): Promise<ContextCorpus> {\n const needsAllItems = contextNeedsAllItems(runtime.sectionsIncluded);\n const listOptions = buildUnpaginatedContextListOptions(\n runtime.baseListOptions,\n { excludeTerminal: true },\n );\n const listed = await runList(undefined, listOptions, global);\n let listedItemMetadata = listed.items as ItemMetadata[];\n let allItems: ItemMetadata[] = listedItemMetadata;\n if (needsAllItems || runtime.parentScope !== undefined) {\n const allListed = await runList(\n undefined,\n buildUnpaginatedContextListOptions(runtime.baseListOptions, {\n excludeTerminal: false,\n }),\n global,\n );\n allItems = allListed.items as ItemMetadata[];\n }\n const fullCorpus = allItems;\n const subtreeIds = resolveContextSubtreeIds(runtime.parentScope, fullCorpus);\n if (subtreeIds) {\n listedItemMetadata = listedItemMetadata.filter((item) =>\n subtreeIds.has(item.id.trim().toLowerCase()),\n );\n allItems = allItems.filter((item) =>\n subtreeIds.has(item.id.trim().toLowerCase()),\n );\n }\n return { listed, listedItemMetadata, allItems, fullCorpus, subtreeIds };\n}\n\nfunction resolveContextSubtreeIds(\n parentScope: string | undefined,\n fullCorpus: ItemMetadata[],\n): Set<string> | undefined {\n if (parentScope === undefined) {\n return undefined;\n }\n const subtree = collectSubtreeIds(fullCorpus, parentScope);\n if (!subtree.found) {\n throw new PmCliError(\n `Context --parent item not found: ${parentScope}`,\n EXIT_CODE.NOT_FOUND,\n );\n }\n return subtree.ids;\n}\n\nasync function resolveContextFocusGroups(\n listedItemMetadata: ItemMetadata[],\n allItems: ItemMetadata[],\n statusRegistry: RuntimeStatusRegistry,\n sectionsIncluded: ContextSectionName[],\n limit: number,\n now: string,\n author: string | undefined,\n cursor: string | undefined,\n cursorFingerprint: string,\n useBoundedPage: boolean,\n): Promise<ContextFocusGroups> {\n const structural = [...listedItemMetadata].sort((left, right) =>\n compareCriticalItems(left, right, statusRegistry),\n );\n const ranking = await scoreContextCandidatesWithActiveExtensions(\n \"context\",\n buildItemContextRelevanceCandidates(\n structural,\n statusRegistry,\n now,\n author,\n ),\n );\n const ranked = ranking.ranked.map((entry) => entry.item);\n const activeStatuses = statusRegistry.active_statuses;\n const activeItems = ranked.filter((item) =>\n activeStatuses.has(normalizeStatusForRegistry(item.status, statusRegistry)),\n );\n const pageStart = useBoundedPage\n ? resolveQueryCursorStart(\n activeItems,\n cursor,\n cursorFingerprint,\n (item) => item.id,\n )\n : 0;\n const focusPage = useBoundedPage\n ? activeItems.slice(pageStart, pageStart + limit)\n : activeItems;\n const hasMore =\n useBoundedPage &&\n focusPage.length > 0 &&\n pageStart + focusPage.length < activeItems.length;\n const nextCursor =\n hasMore && focusPage.length > 0\n ? encodeQueryCursor(\n cursorFingerprint,\n focusPage[focusPage.length - 1]!.id,\n pageStart + focusPage.length - 1,\n )\n : undefined;\n const blockedItems = ranked.filter((item) =>\n statusRegistry.blocked_statuses.has(\n normalizeStatusForRegistry(item.status, statusRegistry),\n ),\n );\n const childrenByParent = buildChildrenByParent(allItems);\n const focusChildrenByParent = contextNeedsAllItems(sectionsIncluded)\n ? childrenByParent\n : undefined;\n const highLevel = focusPage\n .filter((item) => HIGH_LEVEL_TYPES.has(item.type))\n .slice(0, useBoundedPage ? focusPage.length : limit)\n .map((item) =>\n toContextFocusItem(item, statusRegistry, focusChildrenByParent),\n );\n const lowLevel = focusPage\n .filter((item) => !HIGH_LEVEL_TYPES.has(item.type))\n .slice(0, useBoundedPage ? focusPage.length : limit)\n .map((item) =>\n toContextFocusItem(item, statusRegistry, focusChildrenByParent),\n );\n const blockedFallbackUsed = activeItems.length === 0;\n return {\n activeItems,\n blockedItems,\n highLevel,\n lowLevel,\n blockedFallback: blockedFallbackUsed\n ? blockedItems\n .slice(0, limit)\n .map((item) =>\n toContextFocusItem(item, statusRegistry, focusChildrenByParent),\n )\n : [],\n blockedFallbackUsed,\n ranking,\n pageExtras: {\n ...(useBoundedPage ? { applied_limit: limit } : {}),\n ...(hasMore ? { has_more: true, truncated: true } : {}),\n ...(nextCursor ? { next_cursor: nextCursor } : {}),\n },\n };\n}\n\nfunction buildContextCursorFingerprint(options: ContextOptions): string {\n const normalizedOptions: Record<string, unknown> = { ...options };\n delete normalizedOptions.after;\n delete normalizedOptions.limit;\n delete normalizedOptions.maxItems;\n delete normalizedOptions.format;\n delete normalizedOptions.fields;\n delete normalizedOptions.section;\n delete normalizedOptions.activityLimit;\n delete normalizedOptions.staleThreshold;\n delete normalizedOptions.explainRanking;\n return createQueryFingerprint(\"context\", normalizedOptions);\n}\n\nfunction shouldPageContextFocus(\n options: ContextOptions,\n corpusItemCount: number,\n): boolean {\n return (\n options.limit !== undefined ||\n options.maxItems !== undefined ||\n options.after !== undefined ||\n corpusItemCount >= CONTEXT_SCALE_THRESHOLD\n );\n}\n\nasync function buildContextAgenda(\n options: ContextOptions,\n global: GlobalOptions,\n runtime: ContextRuntime,\n subtreeIds: Set<string> | undefined,\n): Promise<{\n agenda: Awaited<ReturnType<typeof runCalendar>>;\n agendaEvents: CalendarRow[];\n agendaSummary: ContextAgendaSummary;\n}> {\n const calendarOptions: CalendarOptions = {\n ...runtime.baseListOptions,\n view: \"agenda\",\n include: \"all\",\n limit:\n runtime.parentScope === undefined ? String(runtime.limit) : undefined,\n };\n const agenda = await runCalendar(calendarOptions, global);\n const scopedAgenda =\n subtreeIds === undefined\n ? agenda.events\n : agenda.events.filter((event) =>\n subtreeIds.has(event.item_id.trim().toLowerCase()),\n );\n const agendaEvents = filterTerminalCalendarEvents(\n scopedAgenda,\n runtime.statusRegistry,\n ).slice(0, runtime.limit);\n return { agenda, agendaEvents, agendaSummary: summarizeAgenda(agendaEvents) };\n}\n\nfunction countContextStatus(\n items: ItemMetadata[],\n status: string | undefined,\n statusRegistry: RuntimeStatusRegistry,\n): number {\n const targetStatus = String(status);\n return items.filter(\n (item) =>\n normalizeStatusForRegistry(item.status, statusRegistry) === targetStatus,\n ).length;\n}\n\nasync function buildOptionalContextSections(params: {\n runtime: ContextRuntime;\n allItems: ItemMetadata[];\n fullCorpus: ItemMetadata[];\n focusGroups: ContextFocusGroups;\n now: string;\n global: GlobalOptions;\n}): Promise<ContextOptionalSections> {\n const { runtime, allItems, fullCorpus, focusGroups, now, global } = params;\n const childrenByParent = buildChildrenByParent(allItems);\n const itemMap = new Map(fullCorpus.map((item) => [item.id, item]));\n const allNonTerminal = allItems.filter(\n (item) => !isTerminalStatus(item.status, runtime.statusRegistry),\n );\n const has = (section: ContextSectionName) =>\n runtime.sectionsIncluded.includes(section);\n return {\n hierarchy: has(\"hierarchy\")\n ? buildHierarchy(\n allItems,\n focusGroups.activeItems,\n runtime.statusRegistry,\n runtime.limit,\n )\n : undefined,\n activity: has(\"activity\")\n ? await buildActivity(runtime.activityLimit, global)\n : undefined,\n progress: has(\"progress\")\n ? buildProgress(\n allItems,\n focusGroups.activeItems,\n runtime.statusRegistry,\n runtime.limit,\n )\n : undefined,\n blockersSection: has(\"blockers\")\n ? buildBlockers(focusGroups.blockedItems, itemMap, runtime.limit)\n : undefined,\n recentlyCreated: has(\"recently_created\")\n ? buildRecentlyCreated(\n allNonTerminal,\n runtime.statusRegistry,\n childrenByParent,\n runtime.limit,\n )\n : undefined,\n unparented: has(\"unparented\")\n ? buildUnparented(\n allNonTerminal,\n runtime.statusRegistry,\n childrenByParent,\n runtime.limit,\n )\n : undefined,\n filesSection: has(\"files\")\n ? buildHotFiles(focusGroups.activeItems, runtime.limit)\n : undefined,\n workload: has(\"workload\")\n ? buildWorkload(\n focusGroups.activeItems,\n runtime.statusRegistry,\n runtime.limit,\n )\n : undefined,\n staleness: has(\"staleness\")\n ? buildStaleness(\n allNonTerminal,\n runtime.staleThresholdDays,\n now,\n runtime.limit,\n )\n : undefined,\n tests: has(\"tests\") ? buildTestHealth(focusGroups.activeItems) : undefined,\n };\n}\n\nfunction buildContextSummaryExtras(\n needsAllItems: boolean,\n allItems: ItemMetadata[],\n statusRegistry: RuntimeStatusRegistry,\n): Pick<ContextSummary, \"total_items\" | \"closed\" | \"canceled\"> {\n if (!needsAllItems) {\n return {};\n }\n const canceledStatus = normalizeStatusInput(\"canceled\", statusRegistry);\n return {\n total_items: allItems.length,\n closed: allItems.filter((item) =>\n isClosedStatus(item.status, statusRegistry),\n ).length,\n canceled: allItems.filter(\n (item) =>\n normalizeStatusForRegistry(item.status, statusRegistry) ===\n canceledStatus,\n ).length,\n };\n}\n\nfunction attachOptionalContextSections(\n result: ContextResult,\n sections: ContextOptionalSections,\n): void {\n if (sections.hierarchy) result.hierarchy = sections.hierarchy;\n if (sections.activity) result.activity = sections.activity;\n if (sections.progress) result.progress = sections.progress;\n if (sections.blockersSection) result.blockers = sections.blockersSection;\n if (sections.recentlyCreated)\n result.recently_created = sections.recentlyCreated;\n if (sections.unparented) result.unparented = sections.unparented;\n if (sections.filesSection) result.files = sections.filesSection;\n if (sections.workload) result.workload = sections.workload;\n if (sections.staleness) result.staleness = sections.staleness;\n if (sections.tests) result.tests = sections.tests;\n}\n\nfunction applyContextFocusProjection(\n result: ContextResult,\n focusFields: string[] | undefined,\n): void {\n if (!focusFields) {\n return;\n }\n result.focus_fields = focusFields;\n result.high_level = projectContextFocusRows(result.high_level, focusFields);\n result.low_level = projectContextFocusRows(result.low_level, focusFields);\n result.blocked_fallback = projectContextFocusRows(\n result.blocked_fallback,\n focusFields,\n );\n if (result.recently_created) {\n result.recently_created = projectContextFocusRows(\n result.recently_created,\n focusFields,\n ) as RecentContextItem[];\n }\n if (result.unparented) {\n result.unparented = projectContextFocusRows(result.unparented, focusFields);\n }\n}\n\nfunction maybeAttachEmptyContextSuggestions(\n result: ContextResult,\n activeItems: ItemMetadata[],\n blockedItems: ItemMetadata[],\n): void {\n if (\n activeItems.length > 0 ||\n blockedItems.length > 0 ||\n result.agenda.events.length > 0\n ) {\n return;\n }\n result.suggestions = [\n 'pm create --type Task --title \"...\" to add a new work item',\n \"pm list --status closed --limit 5 to review recent completions\",\n \"pm search <keywords> to find related past work\",\n \"pm aggregate for a full project status overview\",\n ];\n}\n\n/** Implements run context for the public runtime surface of this module. */\nexport async function runContext(\n options: ContextOptions,\n global: GlobalOptions,\n): Promise<ContextResult> {\n const resolvedRuntime = await resolveContextRuntime(options, global);\n const corpus = await loadContextCorpus(options, global, resolvedRuntime);\n const runtime = {\n ...resolvedRuntime,\n limit: resolveContextLimitAtScale(\n resolvedRuntime.limit,\n corpus.fullCorpus.length,\n ),\n };\n const focusGroups = await resolveContextFocusGroups(\n corpus.listedItemMetadata,\n corpus.allItems,\n runtime.statusRegistry,\n runtime.sectionsIncluded,\n runtime.limit,\n nowIso(),\n process.env.PM_AUTHOR,\n options.after,\n buildContextCursorFingerprint(options),\n shouldPageContextFocus(options, corpus.fullCorpus.length),\n );\n const agendaContext = await buildContextAgenda(\n options,\n global,\n runtime,\n corpus.subtreeIds,\n );\n const warnings = mergeSortedWarnings(\n corpus.listed.warnings,\n agendaContext.agenda.warnings,\n focusGroups.ranking.warnings,\n );\n const inProgressCount = countContextStatus(\n focusGroups.activeItems,\n normalizeStatusInput(\"in_progress\", runtime.statusRegistry),\n runtime.statusRegistry,\n );\n const openCount = countContextStatus(\n focusGroups.activeItems,\n normalizeStatusInput(\"open\", runtime.statusRegistry),\n runtime.statusRegistry,\n );\n const sections = await buildOptionalContextSections({\n runtime,\n allItems: corpus.allItems,\n fullCorpus: corpus.fullCorpus,\n focusGroups,\n now: agendaContext.agenda.now,\n global,\n });\n const summaryExtras = buildContextSummaryExtras(\n contextNeedsAllItems(runtime.sectionsIncluded),\n corpus.allItems,\n runtime.statusRegistry,\n );\n\n const result: ContextResult = {\n output_default: \"toon\",\n now: agendaContext.agenda.now,\n depth: runtime.depth,\n sections_included: runtime.sectionsIncluded,\n window: {\n anchor: agendaContext.agenda.anchor,\n start: agendaContext.agenda.range.start,\n end: agendaContext.agenda.range.end,\n past: agendaContext.agenda.range.past,\n from: agendaContext.agenda.range.from,\n to: agendaContext.agenda.range.to,\n },\n filters: {\n type: options.type ?? null,\n tag: options.tag ?? null,\n priority: options.priority ?? null,\n assignee: options.assignee ?? null,\n assignee_filter: options.assigneeFilter ?? null,\n sprint: options.sprint ?? null,\n release: options.release ?? null,\n limit: options.limit ?? options.maxItems ?? null,\n parent: runtime.parentScope ?? null,\n /* c8 ignore next -- listed/calendar runtime filters are always materialized by their command handlers */\n runtime_filters: (corpus.listed.filters.runtime_filters ??\n agendaContext.agenda.filters.runtime_filters ??\n {}) as Record<string, unknown>,\n },\n summary: {\n active_items: focusGroups.activeItems.length,\n in_progress: inProgressCount,\n open: openCount,\n blocked: focusGroups.blockedItems.length,\n blocked_fallback_used: focusGroups.blockedFallbackUsed,\n high_level: focusGroups.highLevel.length,\n low_level: focusGroups.lowLevel.length,\n agenda_events: agendaContext.agendaSummary.events,\n ...summaryExtras,\n },\n high_level: focusGroups.highLevel,\n low_level: focusGroups.lowLevel,\n blocked_fallback: focusGroups.blockedFallback,\n agenda: {\n summary: agendaContext.agendaSummary,\n events: agendaContext.agendaEvents,\n },\n ...focusGroups.pageExtras,\n };\n\n attachOptionalContextSections(result, sections);\n if (options.explainRanking === true)\n result.ranking = toContextRankingSummary(focusGroups.ranking);\n applyContextFocusProjection(result, runtime.focusFields);\n if (warnings.length > 0) result.warnings = warnings;\n maybeAttachEmptyContextSuggestions(\n result,\n focusGroups.activeItems,\n focusGroups.blockedItems,\n );\n\n return result;\n}\n", "/**\n * @module cli/commands/next\n *\n * Implements the `pm next` command: the distilled \"what should I work on now?\"\n * query. It loads the active corpus, computes dependency-aware actionability\n * (ready vs blocked leaf work), and returns a single ranked recommendation with a\n * deterministic rationale plus the ranked ready/blocked queues — so an agent gets\n * the next action and the reason for it in one token-efficient read instead of\n * re-deriving readiness from a full `pm context` snapshot every turn.\n */\nimport {\n collectBlockedByIds,\n computeActionabilityReport,\n type ActionableEntry,\n} from \"../../core/item/actionability.js\";\nimport {\n resolveRuntimeStatusRegistry,\n type RuntimeStatusRegistry,\n} from \"../../core/schema/runtime-schema.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { nowIso } from \"../../core/shared/time.js\";\nimport {\n normalizeStatusInput,\n normalizeStatusForRegistry,\n} from \"../../core/item/status.js\";\nimport { resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport type { ItemMetadata, ItemStatus } from \"../../types/index.js\";\nimport { parseIntegerLimit } from \"../shared-parsers.js\";\nimport {\n buildChildrenByParent,\n buildItemContextRelevanceCandidates,\n collectSubtreeIds,\n compareCriticalItems,\n toContextRankingSummary,\n toContextFocusItem,\n type ContextFocusItem,\n type ContextRankingSummary,\n} from \"./context.js\";\nimport { runList, type ListOptions } from \"./list.js\";\nimport { scoreContextCandidatesWithActiveExtensions } from \"../../sdk/context-relevance.js\";\n\n/** Supported values accepted by the next output contract. */\nexport const NEXT_OUTPUT_VALUES = [\"markdown\", \"toon\", \"json\"] as const;\n/** Restricts `pm next` output format values accepted by command, SDK, and storage contracts. */\nexport type NextOutputFormat = (typeof NEXT_OUTPUT_VALUES)[number];\n\nconst DEFAULT_NEXT_LIMIT = 5;\nconst MS_PER_DAY = 24 * 60 * 60 * 1000;\n\n/** Documents the `pm next` options payload exchanged by command, SDK, and package integrations. */\nexport interface NextOptions {\n /** Schema type that determines the shape and validation rules for this value. */\n type?: string;\n /** Value that configures or reports tag for this contract. */\n tag?: string;\n /** Value that configures or reports priority for this contract. */\n priority?: string | number;\n /** Value that configures or reports assignee for this contract. */\n assignee?: string;\n /** Value that configures or reports assignee filter for this contract. */\n assigneeFilter?: string;\n /** Value that configures or reports sprint for this contract. */\n sprint?: string;\n /** Value that configures or reports release for this contract. */\n release?: string;\n /** Value that configures or reports parent for this contract. */\n parent?: string;\n /** Value that configures or reports limit for this contract. */\n limit?: string;\n /** Value that configures or reports blocked limit for this contract. */\n blockedLimit?: string;\n /** Value that configures or reports ready only for this contract. */\n readyOnly?: boolean;\n /** Value that configures or reports format for this contract. */\n format?: string;\n /** Value that configures or reports explain ranking for this contract. */\n explainRanking?: boolean;\n /** Include human-gated Decision items in the claimable ready queue. */\n includeDecisions?: boolean;\n /** Internal caller override used to align claim-next ranking with --author. */\n callerAuthor?: string;\n [key: string]: unknown;\n}\n\n/** A blocker reference projected onto the `pm next` output. */\nexport interface NextBlockerRef {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports title for this contract. */\n title: string | null;\n /** Lifecycle state reported for status. */\n status: ItemStatus | null;\n}\n\n/**\n * A classified actionable item on the `pm next` output: a {@link ContextFocusItem}\n * focus row augmented with its open-blocker references and the downstream items it\n * would unblock.\n */\nexport interface NextActionableItem extends ContextFocusItem {\n /** One-based position in the complete ranked actionable queue. */\n rank: number;\n /** Number of open blocker entries represented by this result. */\n open_blocker_count: number;\n /** Value that configures or reports blockers for this contract. */\n blockers: NextBlockerRef[];\n /** Value that configures or reports unblocks for this contract. */\n unblocks: string[];\n}\n\n/** The single recommended next item: an actionable row plus its rationale. */\nexport interface NextRecommendation extends NextActionableItem {\n /** Value that configures or reports reasons for this contract. */\n reasons: string[];\n}\n\ninterface NextSummary {\n recommended: boolean;\n ready: number;\n blocked: number;\n in_progress: number;\n candidates: number;\n containers: number;\n decision_needed: number;\n held_by_others: number;\n}\n\n/** Documents the `pm next` result payload exchanged by command, SDK, and package integrations. */\nexport interface NextResult {\n /** Value that configures or reports output default for this contract. */\n output_default: \"toon\";\n /** Value that configures or reports now for this contract. */\n now: string;\n /** Value that configures or reports recommended for this contract. */\n recommended: NextRecommendation | null;\n /** Value that configures or reports ready for this contract. */\n ready: NextActionableItem[];\n /** Human-gated decisions kept visible without dispatching them to agents. */\n decision_needed: NextActionableItem[];\n /** Value that configures or reports blocked for this contract. */\n blocked: NextActionableItem[];\n /** Value that configures or reports held by others for this contract. */\n held_by_others: Array<{ id: string; assignee: string }>;\n /** Value that configures or reports summary for this contract. */\n summary: NextSummary;\n /** Value that configures or reports filters for this contract. */\n filters: {\n type: string | null;\n tag: string | null;\n priority: string | number | null;\n assignee: string | null;\n assignee_filter: string | null;\n sprint: string | null;\n release: string | null;\n parent: string | null;\n limit: number;\n blocked_limit: number;\n ready_only: boolean;\n include_decisions: boolean;\n };\n /** Value that configures or reports suggestions for this contract. */\n suggestions?: string[];\n /** Value that configures or reports warnings for this contract. */\n warnings?: string[];\n /** Value that configures or reports ranking for this contract. */\n ranking?: ContextRankingSummary;\n /** Explicit marker and complete counts for queues truncated by the shared section limit. */\n truncation?: {\n decision_needed_total?: number;\n held_by_others_total?: number;\n };\n}\n\nfunction parseNextOutputFormat(\n raw: string | undefined,\n): NextOutputFormat | undefined {\n if (!raw) return undefined;\n const normalized = raw.trim().toLowerCase();\n if (!NEXT_OUTPUT_VALUES.includes(normalized as NextOutputFormat)) {\n throw new PmCliError(\n \"Next format must be one of markdown|toon|json\",\n EXIT_CODE.USAGE,\n );\n }\n return normalized as NextOutputFormat;\n}\n\n/** Resolves the effective `pm next` output format from the command `--format` flag and the global `--json` switch, rejecting the contradictory `--json --format markdown|toon` combination. Defaults to `toon`. */\nexport function resolveNextOutputFormat(\n options: NextOptions,\n global: GlobalOptions,\n): NextOutputFormat {\n const commandFormat = parseNextOutputFormat(options.format);\n if (global.json && commandFormat && commandFormat !== \"json\") {\n throw new PmCliError(\n \"Cannot combine --json with --format markdown|toon\",\n EXIT_CODE.USAGE,\n );\n }\n if (global.json) {\n return \"json\";\n }\n return commandFormat ?? \"toon\";\n}\n\n// Per-section row cap. A non-positive or absent value falls back to the default;\n// invalid (non-integer) values throw via parseIntegerLimit.\nfunction parseNextLimit(\n raw: string | undefined,\n flag: string,\n fallback: number,\n): number {\n const parsed = parseIntegerLimit(raw, flag);\n if (parsed === undefined || parsed <= 0) return fallback;\n return parsed;\n}\n\n// Projects an actionable entry onto its output row. Ready entries carry no\n// blockers; blocked entries surface their unresolved blockers for the agent.\nfunction toNextActionableItem(\n entry: ActionableEntry,\n statusRegistry: RuntimeStatusRegistry,\n childrenByParent: Map<string, ItemMetadata[]>,\n rank: number,\n): NextActionableItem {\n return {\n ...toContextFocusItem(entry.item, statusRegistry, childrenByParent),\n open_blocker_count: entry.open_blockers.length,\n blockers: entry.open_blockers.map((blocker) => ({\n id: blocker.id,\n title: blocker.title,\n status: blocker.status,\n })),\n unblocks: entry.unblocks,\n rank,\n };\n}\n\n// Builds the human+agent readable rationale for the recommended item, ordering\n// clauses from most to least decisive (status, priority, deadline, blocker\n// clearance, parent advancement, downstream unblocks).\nfunction buildRecommendationReasons(\n entry: ActionableEntry,\n statusRegistry: RuntimeStatusRegistry,\n now: string,\n completedContainer: boolean,\n): string[] {\n const item = entry.item;\n const reasons: string[] = [];\n const inProgressStatus = normalizeStatusInput(\"in_progress\", statusRegistry);\n reasons.push(\n normalizeStatusForRegistry(item.status, statusRegistry) === inProgressStatus\n ? \"in progress — resume to finish\"\n : \"open and ready to start\",\n );\n if (completedContainer) {\n reasons.push(\"completed container — governance closeout\");\n }\n reasons.push(\n `priority p${item.priority}${item.priority === 0 ? \" (highest)\" : \"\"}`,\n );\n if (typeof item.deadline === \"string\" && item.deadline.trim().length > 0) {\n reasons.push(describeDeadline(item.deadline, now));\n }\n reasons.push(\n collectBlockedByIds(item).length > 0\n ? \"all blockers resolved\"\n : \"no blockers\",\n );\n if (typeof item.parent === \"string\" && item.parent.trim().length > 0) {\n reasons.push(`advances ${item.parent.trim()}`);\n }\n if (entry.unblocks.length > 0) {\n reasons.push(\n `unblocks ${entry.unblocks.length} item(s): ${entry.unblocks.join(\", \")}`,\n );\n }\n return reasons;\n}\n\nfunction partitionCallerOwnedReady(\n ready: ActionableEntry[],\n fallbackAuthor: string,\n explicitAuthor?: string,\n): {\n available: ActionableEntry[];\n held: Array<{ id: string; assignee: string }>;\n} {\n const caller =\n (explicitAuthor ?? process.env.PM_AUTHOR ?? fallbackAuthor).trim() ||\n \"unknown\";\n const available: ActionableEntry[] = [];\n const held: Array<{ id: string; assignee: string }> = [];\n for (const entry of ready) {\n const assignee =\n typeof entry.item.assignee === \"string\" ? entry.item.assignee.trim() : \"\";\n const isForeignWork = assignee.length > 0 && assignee !== caller;\n if (isForeignWork) held.push({ id: entry.item.id, assignee });\n else available.push(entry);\n }\n return { available, held };\n}\n\n/** Test-only access to deterministic next-work partitioning edge cases. */\nexport const _testOnlyNextCommand = { partitionCallerOwnedReady };\n\n/** Separates human-gated decisions from autonomous agent work unless the caller explicitly opts into decision claims. */\nexport function partitionDecisionEntries(\n ready: ActionableEntry[],\n includeDecisions: boolean,\n): { agent: ActionableEntry[]; decisions: ActionableEntry[] } {\n const decisions = ready.filter(\n (entry) => entry.item.type.trim().toLowerCase() === \"decision\",\n );\n return {\n agent: includeDecisions\n ? ready\n : ready.filter(\n (entry) => entry.item.type.trim().toLowerCase() !== \"decision\",\n ),\n decisions: includeDecisions ? [] : decisions,\n };\n}\n\n// Renders a deadline as a date token plus a relative tag (overdue/today/in Nd).\n// The relative delta is computed on UTC calendar dates (both sides normalized to\n// midnight) so a deadline due today never reads as \"overdue 1d\" just because the\n// wall-clock time of `now` has passed midnight. Unparseable deadlines degrade to\n// the raw token (defensive — stored deadlines are always valid ISO).\nfunction describeDeadline(deadline: string, now: string): string {\n const deadlineMs = Date.parse(deadline);\n /* c8 ignore start -- defensive: a stored deadline that fails Date.parse still surfaces its raw token */\n if (!Number.isFinite(deadlineMs)) {\n return `deadline ${deadline.trim()}`;\n }\n /* c8 ignore stop */\n const dateToken = new Date(deadlineMs).toISOString().slice(0, 10);\n const nowToken = new Date(Date.parse(now)).toISOString().slice(0, 10);\n const days = Math.round(\n (Date.parse(dateToken) - Date.parse(nowToken)) / MS_PER_DAY,\n );\n if (days < 0) return `deadline ${dateToken} (overdue ${-days}d)`;\n if (days === 0) return `deadline ${dateToken} (due today)`;\n return `deadline ${dateToken} (in ${days}d)`;\n}\n\nfunction inProgressReadyCount(\n ready: NextActionableItem[],\n statusRegistry: RuntimeStatusRegistry,\n): number {\n const inProgressStatus = normalizeStatusInput(\"in_progress\", statusRegistry);\n return ready.filter(\n (item) =>\n normalizeStatusForRegistry(item.status, statusRegistry) ===\n inProgressStatus,\n ).length;\n}\n\n// Returns true when an otherwise-ready item still has terminal descendants. Such\n// rows are useful governance closeout context, but concrete leaf work should rank\n// ahead of them in the default agent loop.\nfunction hasCompletedDescendants(\n item: ItemMetadata,\n childrenByParent: Map<string, ItemMetadata[]>,\n): boolean {\n return (childrenByParent.get(item.id.trim().toLowerCase()) ?? []).length > 0;\n}\n\n// Strips projection/pagination flags so the corpus reads stay full: limits are\n// per-section display caps applied after classification, never corpus filters.\nfunction nextListOptions(\n options: NextOptions,\n extra: Partial<ListOptions>,\n): ListOptions {\n return {\n type: options.type,\n tag: options.tag,\n priority:\n typeof options.priority === \"number\"\n ? String(options.priority)\n : options.priority,\n assignee: options.assignee,\n assigneeFilter: options.assigneeFilter,\n sprint: options.sprint,\n release: options.release,\n noTruncate: true,\n ...extra,\n };\n}\n\nfunction rankNextReadyEntries(\n ready: ActionableEntry[],\n childrenByParent: Map<string, ItemMetadata[]>,\n statusRegistry: RuntimeStatusRegistry,\n): ActionableEntry[] {\n return [...ready].sort((left, right) => {\n const leftCompletedContainer = hasCompletedDescendants(\n left.item,\n childrenByParent,\n );\n const rightCompletedContainer = hasCompletedDescendants(\n right.item,\n childrenByParent,\n );\n if (leftCompletedContainer !== rightCompletedContainer) {\n return Number(leftCompletedContainer) - Number(rightCompletedContainer);\n }\n return compareCriticalItems(left.item, right.item, statusRegistry);\n });\n}\n\nfunction buildNextRecommendation(params: {\n projectedReady: ActionableEntry[];\n readyRows: NextActionableItem[];\n statusRegistry: RuntimeStatusRegistry;\n now: string;\n completedContainer: boolean;\n}): NextRecommendation | null {\n if (params.projectedReady.length === 0) {\n return null;\n }\n return {\n ...params.readyRows[0],\n reasons: buildRecommendationReasons(\n params.projectedReady[0],\n params.statusRegistry,\n params.now,\n params.completedContainer,\n ),\n };\n}\n\nfunction buildNextSuggestions(\n recommended: NextRecommendation | null,\n blockedRows: NextActionableItem[],\n): string[] | undefined {\n if (recommended !== null) {\n return undefined;\n }\n if (blockedRows.length > 0) {\n const blockedWithReferences = blockedRows.find(\n (item) => item.blockers.length > 0,\n );\n return [\n blockedWithReferences\n ? `${blockedRows.length} item(s) are blocked; unblock the top one by closing ${blockedWithReferences.blockers.map((blocker) => blocker.id).join(\", \")}`\n : `${blockedRows.length} item(s) are blocked; add blocker context or move the top item back to an active status`,\n \"pm next --ready-only after a blocker closes to re-check ready work\",\n 'pm create --type Task --title \"...\" to add new ready work',\n ];\n }\n return [\n 'pm create --type Task --title \"...\" to add a new work item',\n \"pm list --status in_progress to review work already underway\",\n \"pm context --depth deep for the full project snapshot\",\n ];\n}\n\nfunction buildNextTruncation(\n decisionCount: number,\n heldCount: number,\n limit: number,\n): NextResult[\"truncation\"] {\n const truncation: NonNullable<NextResult[\"truncation\"]> = {};\n if (decisionCount > limit) {\n truncation.decision_needed_total = decisionCount;\n }\n if (heldCount > limit) {\n truncation.held_by_others_total = heldCount;\n }\n return Object.keys(truncation).length > 0 ? truncation : undefined;\n}\n\nfunction filterCandidatesByParentScope(\n candidates: ItemMetadata[],\n corpus: ItemMetadata[],\n parentScope: string,\n): ItemMetadata[] {\n if (!parentScope) {\n return candidates;\n }\n const subtree = collectSubtreeIds(corpus, parentScope);\n if (!subtree.found) {\n throw new PmCliError(\n `Next --parent item not found: ${parentScope}`,\n EXIT_CODE.NOT_FOUND,\n );\n }\n return candidates.filter((item) =>\n subtree.ids.has(item.id.trim().toLowerCase()),\n );\n}\n\nasync function rankReadyEntriesWithRelevance(\n rankedReady: ActionableEntry[],\n childrenByParent: Map<string, ItemMetadata[]>,\n statusRegistry: RuntimeStatusRegistry,\n now: string,\n callerAuthor: string | undefined,\n): Promise<{\n projectedReady: ActionableEntry[];\n ranking: Awaited<\n ReturnType<\n typeof scoreContextCandidatesWithActiveExtensions<ItemMetadata>\n >\n >;\n completedContainer: boolean;\n}> {\n const concreteReady = rankedReady.filter(\n (entry) => !hasCompletedDescendants(entry.item, childrenByParent),\n );\n const structuralReady =\n concreteReady.length > 0 ? concreteReady : rankedReady;\n const ranking = await scoreContextCandidatesWithActiveExtensions(\n \"next\",\n buildItemContextRelevanceCandidates(\n structuralReady.map((entry) => entry.item),\n statusRegistry,\n now,\n callerAuthor ?? process.env.PM_AUTHOR,\n ),\n );\n const readyById = new Map(\n structuralReady.map((entry) => [entry.item.id, entry]),\n );\n const projectedReady = ranking.ranked\n .map((entry) => readyById.get(entry.id))\n .filter((entry): entry is ActionableEntry => entry !== undefined);\n return {\n projectedReady,\n ranking,\n completedContainer: concreteReady.length === 0,\n };\n}\n\n/** Implements `pm next`: computes the ranked ready/blocked actionable queues and a single recommended next item with rationale for the public runtime surface. */\nexport async function runNext(\n options: NextOptions,\n global: GlobalOptions,\n): Promise<NextResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n const settings = await readSettings(pmRoot);\n const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);\n const now = nowIso();\n const limit = parseNextLimit(options.limit, \"--limit\", DEFAULT_NEXT_LIMIT);\n const blockedLimit = parseNextLimit(\n options.blockedLimit,\n \"--blocked-limit\",\n limit,\n );\n const readyOnly = options.readyOnly === true;\n const parentScope =\n typeof options.parent === \"string\" ? options.parent.trim() : \"\";\n\n // Active (non-terminal) candidates honor the caller's filters; the corpus is the\n // FULL, UNFILTERED set (every status, every item) so blocker and descendant\n // resolution still sees items outside the caller's filters or --parent subtree —\n // otherwise a real blocker assigned to someone else (or a parent of a different\n // type) would be missing and the blocked item misread as ready.\n const candidatesList = await runList(\n undefined,\n nextListOptions(options, { excludeTerminal: true }),\n global,\n );\n const corpusList = await runList(\n undefined,\n { excludeTerminal: false, noTruncate: true },\n global,\n );\n const candidates = filterCandidatesByParentScope(\n candidatesList.items as ItemMetadata[],\n corpusList.items as ItemMetadata[],\n parentScope,\n );\n const corpus = corpusList.items as ItemMetadata[];\n\n const report = computeActionabilityReport(candidates, corpus, statusRegistry);\n const childrenByParent = buildChildrenByParent(corpus);\n const partitionedByDecision = partitionDecisionEntries(\n report.ready,\n options.includeDecisions === true,\n );\n const callerPartition = partitionCallerOwnedReady(\n partitionedByDecision.agent,\n settings.author_default,\n options.callerAuthor,\n );\n const rankedReady = rankNextReadyEntries(\n callerPartition.available,\n childrenByParent,\n statusRegistry,\n );\n const rankedBlocked = [...report.blocked].sort((left, right) =>\n compareCriticalItems(left.item, right.item, statusRegistry),\n );\n const {\n projectedReady,\n ranking: readyRanking,\n completedContainer,\n } = await rankReadyEntriesWithRelevance(\n rankedReady,\n childrenByParent,\n statusRegistry,\n now,\n options.callerAuthor,\n );\n\n const readyRows = projectedReady.map((entry, index) =>\n toNextActionableItem(entry, statusRegistry, childrenByParent, index + 1),\n );\n const blockedRows = rankedBlocked.map((entry, index) =>\n toNextActionableItem(entry, statusRegistry, childrenByParent, index + 1),\n );\n const decisionRows = rankNextReadyEntries(\n partitionedByDecision.decisions,\n childrenByParent,\n statusRegistry,\n ).map((entry, index) =>\n toNextActionableItem(entry, statusRegistry, childrenByParent, index + 1),\n );\n\n const recommended = buildNextRecommendation({\n projectedReady,\n readyRows,\n statusRegistry,\n now,\n completedContainer,\n });\n const truncation = buildNextTruncation(\n decisionRows.length,\n callerPartition.held.length,\n limit,\n );\n\n const result: NextResult = {\n output_default: \"toon\",\n now,\n recommended,\n ready: readyRows.slice(1, limit + 1),\n decision_needed: decisionRows.slice(0, limit),\n blocked: readyOnly ? [] : blockedRows.slice(0, blockedLimit),\n held_by_others: callerPartition.held.slice(0, limit),\n summary: {\n recommended: recommended !== null,\n ready: readyRows.length,\n blocked: blockedRows.length,\n in_progress: inProgressReadyCount(readyRows, statusRegistry),\n candidates: report.active_count,\n containers: report.container_count,\n decision_needed: decisionRows.length,\n held_by_others: callerPartition.held.length,\n },\n filters: {\n type: options.type ?? null,\n tag: options.tag ?? null,\n priority: options.priority ?? null,\n assignee: options.assignee ?? null,\n assignee_filter: options.assigneeFilter ?? null,\n sprint: options.sprint ?? null,\n release: options.release ?? null,\n parent: parentScope.length > 0 ? parentScope : null,\n limit,\n blocked_limit: blockedLimit,\n ready_only: readyOnly,\n include_decisions: options.includeDecisions === true,\n },\n truncation,\n };\n\n const warnings = [\n ...new Set([\n ...(candidatesList.warnings ?? []),\n ...(corpusList.warnings ?? []),\n ...(readyRanking.warnings ?? []),\n ]),\n ].sort((a, b) => a.localeCompare(b));\n if (warnings.length > 0) result.warnings = warnings;\n if (options.explainRanking === true)\n result.ranking = toContextRankingSummary(readyRanking);\n\n result.suggestions = buildNextSuggestions(recommended, blockedRows);\n\n return result;\n}\n\n/**\n * Renders a {@link NextResult} as compact agent-readable markdown: the\n * recommendation with its rationale, the ranked ready queue, and (unless\n * `--ready-only`) the blocked queue annotated with each item's open blockers.\n */\nexport function renderNextMarkdown(result: NextResult): string {\n const lines: string[] = [\"# pm next\", \"\", ...renderNextSummaryLines(result)];\n lines.push(...renderNextSection(\"Recommended\", renderNextRecommendedRows(result.recommended), \"No ready work.\"));\n lines.push(\n ...renderNextSection(\n \"Decision needed\",\n // `?? []` tolerates JSON payloads from pre-decision-queue builds (the\n // field is newer than the rest of the shape); pinned by a dedicated spec.\n (result.decision_needed ?? []).map((item) => `- ${formatNextLine(item)}`),\n \"No human-gated decisions.\",\n ),\n );\n lines.push(\n ...renderNextSection(\n \"Ready\",\n result.ready.map((item) => `- ${formatNextLine(item)}`),\n \"No ready items.\",\n ),\n );\n if (!result.filters.ready_only) {\n lines.push(\n ...renderNextSection(\n \"Blocked\",\n result.blocked.map((item) => `- ${formatNextBlockedLine(item)}`),\n \"No blocked items.\",\n ),\n );\n }\n if (result.suggestions && result.suggestions.length > 0) {\n lines.push(\"## Suggestions\");\n for (const suggestion of result.suggestions) {\n lines.push(`- ${suggestion}`);\n }\n }\n\n return lines.join(\"\\n\").trimEnd();\n}\n\n// Renders the top-of-report summary bullet block (timestamp, queue counts,\n// optional subtree scope) followed by its separating blank line.\nfunction renderNextSummaryLines(result: NextResult): string[] {\n const lines = [\n `- now: ${result.now}`,\n `- ready: ${result.summary.ready} (in_progress: ${result.summary.in_progress}), blocked: ${result.summary.blocked}, candidates: ${result.summary.candidates}`,\n ];\n if (result.filters.parent) {\n lines.push(`- scope: subtree of ${result.filters.parent}`);\n }\n lines.push(\"\");\n return lines;\n}\n\n// Renders the recommendation rows (item line + rationale) or nothing when no\n// candidate is ready, letting the shared section helper supply the empty state.\nfunction renderNextRecommendedRows(recommended: NextResult[\"recommended\"]): string[] {\n if (!recommended) {\n return [];\n }\n return [`- ${formatNextLine(recommended)}`, ` why: ${recommended.reasons.join(\"; \")}`];\n}\n\n// Renders one markdown queue section: the `##` header, then either the rows or\n// the section's empty-state message, closed by a separating blank line.\nfunction renderNextSection(header: string, rows: string[], emptyMessage: string): string[] {\n return [`## ${header}`, ...(rows.length === 0 ? [emptyMessage] : rows), \"\"];\n}\n\n// Formats a blocked row: the standard actionable line annotated with each open\n// blocker's id and current status.\nfunction formatNextBlockedLine(item: NextResult[\"blocked\"][number]): string {\n const by = item.blockers\n .map((blocker) => `${blocker.id}(${blocker.status ?? \"?\"})`)\n .join(\", \");\n return `${formatNextLine(item)} blocked_by:${by}`;\n}\n\n// Formats a single actionable row: id, priority, status, type, deadline, parent,\n// downstream-unblock count, and title. Mirrors the context focus-line shape.\nfunction formatNextLine(item: NextActionableItem): string {\n const deadlineToken = item.deadline ?? \"-\";\n const parentToken = item.parent ? ` parent:${item.parent}` : \"\";\n const unblocksToken =\n item.unblocks.length > 0 ? ` unblocks:${item.unblocks.length}` : \"\";\n const rankToken = Number.isInteger(item.rank) ? `#${item.rank} ` : \"\";\n return `${rankToken}${item.id} p${item.priority} ${item.status} ${item.type} deadline:${deadlineToken}${parentToken}${unblocksToken} ${item.title}`;\n}\n", "/**\n * Vectorization-ledger staleness helpers.\n *\n * The vectorization status ledger at `search/vectorization-status.json`\n * records the `updated_at` of every item that has been embedded into the\n * vector store. When an item's current `updated_at` differs from the\n * ledger's recorded value (or the item is missing from the ledger\n * entirely), the vector store is stale for that item and a `pm reindex`\n * is needed.\n *\n * This module exposes the comparison helper as a tiny pure function so it\n * can be reused by `pm health` (gates), `pm reindex`, and `pm search`\n * (query-time staleness warning) without re-importing each other.\n */\n\n/** Minimal item shape required to compare vectorization freshness. */\nexport interface ItemWithUpdatedAt {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** ISO 8601 timestamp recording when updated occurred. */\n updated_at: string;\n}\n\n/** Return the sorted list of item IDs whose current `updated_at` does not match the ledger entry. Missing ledger entries count as stale. */\nexport function collectStaleVectorizationIds<T extends ItemWithUpdatedAt>(\n items: readonly T[],\n ledgerEntries: Readonly<Record<string, string>> | null | undefined,\n): string[] {\n // Tolerate a missing / corrupted / partially-written ledger by treating\n // unknown items as stale (the same as having no entry).\n const entries = ledgerEntries ?? {};\n return items\n .filter((item) => {\n const trackedUpdatedAt = entries[item.id];\n return trackedUpdatedAt !== item.updated_at;\n })\n .map((item) => item.id)\n .sort((left, right) => left.localeCompare(right));\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAO,QAAQ;AACf,OAAO,UAAU;;;;;;;;AAyFjB,SAAS,oBACP,KACA,WAAiB;AAEjB,MAAI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