@unbrained/pm-cli 2026.7.14 → 2026.7.15
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 +48 -0
- package/README.md +14 -11
- package/dist/cli/argv-utils.d.ts +1 -4
- package/dist/cli/argv-utils.js +3 -13
- package/dist/cli/argv-utils.js.map +1 -1
- package/dist/cli/bootstrap-args.d.ts +6 -4
- package/dist/cli/bootstrap-args.js +51 -16
- package/dist/cli/bootstrap-args.js.map +1 -1
- package/dist/cli/bundle-integrity.d.ts +49 -0
- package/dist/cli/bundle-integrity.js +111 -0
- package/dist/cli/bundle-integrity.js.map +1 -0
- package/dist/cli/commands/completion.js +7 -2
- package/dist/cli/commands/completion.js.map +1 -1
- package/dist/cli/commands/config.d.ts +6 -163
- package/dist/cli/commands/config.js +4 -1133
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/context.d.ts +2 -4
- package/dist/cli/commands/context.js +10 -85
- package/dist/cli/commands/context.js.map +1 -1
- package/dist/cli/commands/create.d.ts +1 -0
- package/dist/cli/commands/create.js +3 -2
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/commands/extension/describe.d.ts +2 -91
- package/dist/cli/commands/extension/describe.js +4 -142
- package/dist/cli/commands/extension/describe.js.map +1 -1
- package/dist/cli/commands/extension/scaffold.d.ts +2 -36
- package/dist/cli/commands/extension/scaffold.js +4 -2435
- package/dist/cli/commands/extension/scaffold.js.map +1 -1
- package/dist/cli/commands/extension/shared.d.ts +2 -28
- package/dist/cli/commands/extension/shared.js +4 -130
- package/dist/cli/commands/extension/shared.js.map +1 -1
- package/dist/cli/commands/extension.d.ts +3 -400
- package/dist/cli/commands/extension.js +4 -2183
- package/dist/cli/commands/extension.js.map +1 -1
- package/dist/cli/commands/gc.d.ts +6 -56
- package/dist/cli/commands/gc.js +4 -270
- package/dist/cli/commands/gc.js.map +1 -1
- package/dist/cli/commands/get.d.ts +18 -5
- package/dist/cli/commands/get.js +117 -58
- package/dist/cli/commands/get.js.map +1 -1
- package/dist/cli/commands/health.d.ts +6 -184
- package/dist/cli/commands/health.js +4 -1747
- package/dist/cli/commands/health.js.map +1 -1
- package/dist/cli/commands/history-compact.d.ts +4 -139
- package/dist/cli/commands/history-compact.js +5 -510
- package/dist/cli/commands/history-compact.js.map +1 -1
- package/dist/cli/commands/history-redact.d.ts +8 -120
- package/dist/cli/commands/history-redact.js +6 -581
- package/dist/cli/commands/history-redact.js.map +1 -1
- package/dist/cli/commands/history-repair.d.ts +7 -89
- package/dist/cli/commands/history-repair.js +5 -257
- package/dist/cli/commands/history-repair.js.map +1 -1
- package/dist/cli/commands/history.d.ts +1 -2
- package/dist/cli/commands/history.js +6 -48
- package/dist/cli/commands/history.js.map +1 -1
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.js +3 -2
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/init-agent-guidance.d.ts +6 -113
- package/dist/cli/commands/init-agent-guidance.js +4 -431
- package/dist/cli/commands/init-agent-guidance.js.map +1 -1
- package/dist/cli/commands/init.d.ts +6 -181
- package/dist/cli/commands/init.js +4 -690
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/next.js +3 -3
- package/dist/cli/commands/next.js.map +1 -1
- package/dist/cli/commands/profile.d.ts +4 -174
- package/dist/cli/commands/profile.js +4 -425
- package/dist/cli/commands/profile.js.map +1 -1
- package/dist/cli/commands/restore.d.ts +4 -19
- package/dist/cli/commands/restore.js +9 -158
- package/dist/cli/commands/restore.js.map +1 -1
- package/dist/cli/commands/schema.d.ts +7 -507
- package/dist/cli/commands/schema.js +5 -1254
- package/dist/cli/commands/schema.js.map +1 -1
- package/dist/cli/commands/test.d.ts +2 -4
- package/dist/cli/commands/test.js +7 -97
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/commands/validate.d.ts +9 -249
- package/dist/cli/commands/validate.js +9 -2150
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/extension-command-help.js +18 -4
- package/dist/cli/extension-command-help.js.map +1 -1
- package/dist/cli/extension-command-options.js +3 -3
- package/dist/cli/extension-command-options.js.map +1 -1
- package/dist/cli/help-content.js +7 -3
- package/dist/cli/help-content.js.map +1 -1
- package/dist/cli/main.js +20 -30
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/register-list-query.js +4 -2
- package/dist/cli/register-list-query.js.map +1 -1
- package/dist/cli/register-mutation.js +11 -3
- package/dist/cli/register-mutation.js.map +1 -1
- package/dist/cli/register-setup.js +4 -2
- package/dist/cli/register-setup.js.map +1 -1
- package/dist/cli/registration-helpers.js +3 -2
- package/dist/cli/registration-helpers.js.map +1 -1
- package/dist/cli-bundle/bundle-manifest.json +782 -0
- package/dist/cli-bundle/chunks/{append-PVZJDM6J.js → append-OJQFUQ4T.js} +5 -5
- package/dist/cli-bundle/chunks/append-UZVHUO74.js +11 -0
- package/dist/cli-bundle/chunks/{chunk-MQZ3PLCF.js → chunk-2IFFUZLC.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-P6MYFH6K.js → chunk-2JKGO6QX.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-X3GYR4P2.js → chunk-2NCIPMQP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q7E6OYZK.js → chunk-2VPAVL7O.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DRNJPEPQ.js → chunk-2WSE6PO2.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-FDSBDNYE.js → chunk-34L5OT3Y.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TH7U4KLY.js → chunk-3AUGG2DP.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-NKW36AMT.js → chunk-3CLU2XZO.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-N3CMP4NI.js → chunk-3S5QVM5H.js} +43 -7
- package/dist/cli-bundle/chunks/chunk-3S5QVM5H.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-3U7ZR6M4.js +64 -0
- package/dist/cli-bundle/chunks/chunk-3U7ZR6M4.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-ABRCOSDC.js → chunk-3WM75PWC.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-4223PVZT.js +121 -0
- package/dist/cli-bundle/chunks/chunk-4223PVZT.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-5URI7TPJ.js → chunk-4XQ3BDV4.js} +281 -164
- package/dist/cli-bundle/chunks/chunk-4XQ3BDV4.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-X6BVXQ52.js → chunk-5JLUII3O.js} +13 -13
- package/dist/cli-bundle/chunks/{chunk-MKL4CP2I.js → chunk-5ZSLZLDN.js} +631 -246
- package/dist/cli-bundle/chunks/chunk-5ZSLZLDN.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-Q37E63AM.js → chunk-6CFNAVTF.js} +21 -141
- package/dist/cli-bundle/chunks/chunk-6CFNAVTF.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-3TL7WOEF.js → chunk-6N2VXVTQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ERL2YFJ2.js → chunk-6S3YSUYG.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-ZUKSZVBW.js → chunk-7B67ZL4N.js} +8 -7
- package/dist/cli-bundle/chunks/chunk-7B67ZL4N.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-IA3YFTXT.js → chunk-7PIWCHTW.js} +11 -13
- package/dist/cli-bundle/chunks/chunk-7PIWCHTW.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-BPD26E3P.js → chunk-7Z4LKRS4.js} +291 -81
- package/dist/cli-bundle/chunks/chunk-7Z4LKRS4.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-IFZA4VB5.js → chunk-AHVTB5I5.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-DO5RGJXT.js → chunk-APRVSW2O.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-NAQYVWSQ.js → chunk-B7PE22W6.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-MD6ULIPJ.js → chunk-BCOFWYW4.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-KADLSPIU.js → chunk-BEP7WJA2.js} +4 -4
- package/dist/cli-bundle/chunks/chunk-BKVG6XOA.js +1114 -0
- package/dist/cli-bundle/chunks/chunk-BKVG6XOA.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-AFWZRL7M.js → chunk-BSEQUTQP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-AFWZRL7M.js.map → chunk-BSEQUTQP.js.map} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OBDLEQG5.js → chunk-CRVF2JDM.js} +10 -10
- package/dist/cli-bundle/chunks/{chunk-FJZDA6MS.js → chunk-DM4H7FP4.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-DUT67M43.js +5 -0
- package/dist/cli-bundle/chunks/{chunk-44LNIULG.js → chunk-DYH63FX7.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-LWTIRS3Y.js → chunk-E2OJMKML.js} +306 -82
- package/dist/cli-bundle/chunks/chunk-E2OJMKML.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-HAMLIWAF.js → chunk-EAB64KLB.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-CIOZ376P.js → chunk-EACOH7AU.js} +10 -10
- package/dist/cli-bundle/chunks/{chunk-HL7V2PHX.js → chunk-EH2OPHBI.js} +10 -10
- package/dist/cli-bundle/chunks/{chunk-HL7V2PHX.js.map → chunk-EH2OPHBI.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-QK2ZN6UL.js → chunk-EJEXHTY5.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WQUEHPZB.js → chunk-EYLCSJAI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-655STMGA.js → chunk-FMBNM2EN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RMF3IOYQ.js → chunk-FNSPG7MU.js} +12 -12
- package/dist/cli-bundle/chunks/{chunk-5CT5BW6E.js → chunk-GM5QHQU6.js} +46 -40
- package/dist/cli-bundle/chunks/chunk-GM5QHQU6.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-FTQLW4JD.js → chunk-GOSLKLFE.js} +418 -24
- package/dist/cli-bundle/chunks/chunk-GOSLKLFE.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-KB726FMH.js → chunk-H2Z3FYXQ.js} +4 -4
- package/dist/cli-bundle/chunks/chunk-H3EIEWGR.js +162 -0
- package/dist/cli-bundle/chunks/chunk-H3EIEWGR.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-2QIQGYPW.js → chunk-H5APFTHZ.js} +53 -10
- package/dist/cli-bundle/chunks/chunk-H5APFTHZ.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-HDH3JUGG.js +118 -0
- package/dist/cli-bundle/chunks/chunk-HDH3JUGG.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-ZAYYDNB3.js → chunk-HO4KXD6I.js} +22 -142
- package/dist/cli-bundle/chunks/chunk-HO4KXD6I.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-ILLUE5DI.js → chunk-HYB5AZ63.js} +203 -62
- package/dist/cli-bundle/chunks/{chunk-ILLUE5DI.js.map → chunk-HYB5AZ63.js.map} +3 -3
- package/dist/cli-bundle/chunks/{chunk-BN62TO2S.js → chunk-IA5FKNII.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JL7WZ4O2.js → chunk-IG3SWA4A.js} +33 -9
- package/dist/cli-bundle/chunks/chunk-IG3SWA4A.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-W6HZ55JO.js → chunk-IJIICKVW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-IGED7NH2.js → chunk-ILX33QXL.js} +668 -251
- package/dist/cli-bundle/chunks/chunk-ILX33QXL.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-UGTVWL3E.js → chunk-INU6DKT5.js} +47 -41
- package/dist/cli-bundle/chunks/chunk-INU6DKT5.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-UB2QYSTO.js → chunk-J5AOEGDC.js} +26 -18
- package/dist/cli-bundle/chunks/chunk-J5AOEGDC.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-4DY4KPQI.js → chunk-J6364LFM.js} +1330 -937
- package/dist/cli-bundle/chunks/chunk-J6364LFM.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-DVOLZJ3C.js → chunk-J6EY5V4N.js} +1295 -939
- package/dist/cli-bundle/chunks/chunk-J6EY5V4N.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-JFTKLTEF.js +1097 -0
- package/dist/cli-bundle/chunks/chunk-JFTKLTEF.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-M7EWN4TF.js → chunk-JOUQZENX.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-J4NZOP3I.js → chunk-JXQUXVMI.js} +9 -8
- package/dist/cli-bundle/chunks/chunk-JXQUXVMI.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-2FNWQXZ2.js → chunk-JYFOV7FC.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-HLHSQ5CA.js → chunk-K2X6U4UA.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-6OTZMORS.js → chunk-K3WII2ME.js} +27 -27
- package/dist/cli-bundle/chunks/chunk-K3WII2ME.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-M6ASXYCU.js → chunk-KG44YSKD.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-YVKE5ZDM.js → chunk-KPMKHGEA.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-QASRVKUQ.js → chunk-LPYWLWDS.js} +257 -163
- package/dist/cli-bundle/chunks/chunk-LPYWLWDS.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-RGXD5JJR.js → chunk-LSG2U345.js} +19 -12
- package/dist/cli-bundle/chunks/chunk-LSG2U345.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-MIQDDLB5.js +5 -0
- package/dist/cli-bundle/chunks/{chunk-UJ4HJYWL.js → chunk-NLDFBC6J.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WRKB56FC.js → chunk-NP22ERDF.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-YQYG2V23.js → chunk-NU3IMIEA.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3I3LRT2G.js → chunk-NVPZIJVR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JAF4TUQ7.js → chunk-ODALILG3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CDJYP7OQ.js → chunk-ONG5V5CI.js} +190 -63
- package/dist/cli-bundle/chunks/chunk-ONG5V5CI.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-QZ7LT3XE.js → chunk-ONREO4ST.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-OW4JWD5M.js +61 -0
- package/dist/cli-bundle/chunks/chunk-OW4JWD5M.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-3CMRNVTO.js → chunk-P74IZQ7A.js} +12 -12
- package/dist/cli-bundle/chunks/chunk-PENXZX3U.js +172 -0
- package/dist/cli-bundle/chunks/chunk-PENXZX3U.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-ZTRBSABY.js → chunk-PGY23YTC.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-H2QBAKLQ.js → chunk-PMOSXADO.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-PNTULOGU.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-GSEADLRH.js → chunk-Q7A43DS4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QSPARJWF.js → chunk-QEHQ2GVG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VJTAEIPC.js → chunk-QIPLHNP7.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-GXXC7QSK.js → chunk-QKECXBBG.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-GXXC7QSK.js.map → chunk-QKECXBBG.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-K7WNZ7KD.js → chunk-QKJGPFAF.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-F7PSHRNO.js → chunk-QKXHFPYM.js} +27 -10
- package/dist/cli-bundle/chunks/chunk-QKXHFPYM.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-ZNP64HOW.js → chunk-RLCHOOHC.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-IAPHYPRL.js → chunk-RMLWNPH2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UVBA6F5A.js → chunk-RRM5JYJC.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-6IIVBC56.js → chunk-S6MQESFR.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-QABYZYLU.js → chunk-SDQLJWBO.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-ANSJHDOZ.js → chunk-SELVXEZK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DYEX6NFH.js → chunk-TD3LVC7D.js} +438 -23
- package/dist/cli-bundle/chunks/chunk-TD3LVC7D.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-WD6MSYMP.js → chunk-TKOVBP6C.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TZ2PSLLT.js → chunk-TQSZFPIS.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-WPAWZW7S.js → chunk-TSMHDIW4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TZRTLMWM.js → chunk-UFXU44HV.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-TWLDBKQU.js → chunk-ULTHRDBP.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-OI4S4KCI.js → chunk-UMOPHQSU.js} +9 -9
- package/dist/cli-bundle/chunks/{chunk-OI4S4KCI.js.map → chunk-UMOPHQSU.js.map} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RA5AIAMP.js → chunk-UOHFKBUV.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-PHKP3AGR.js → chunk-UWQHLMEB.js} +35 -18
- package/dist/cli-bundle/chunks/chunk-UWQHLMEB.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-6TTOHMTB.js → chunk-UXONS674.js} +45 -112
- package/dist/cli-bundle/chunks/chunk-UXONS674.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-4RXTMU57.js → chunk-UY2ACEMF.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-6PKA3SJQ.js → chunk-WQPUU7XD.js} +19 -28
- package/dist/cli-bundle/chunks/chunk-WQPUU7XD.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-7TQMR6LK.js → chunk-WT3ZEOGH.js} +70 -20
- package/dist/cli-bundle/chunks/chunk-WT3ZEOGH.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-FIGXOCEQ.js → chunk-WUJQK4YV.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-T4BRCB6Z.js → chunk-XSJUSQAE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-6MHSBDGD.js → chunk-XXXF6PAQ.js} +50 -117
- package/dist/cli-bundle/chunks/chunk-XXXF6PAQ.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-UKUIIBDW.js → chunk-YAQEBNY7.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-7QDSYUMF.js → chunk-YAROI3PD.js} +44 -21
- package/dist/cli-bundle/chunks/chunk-YAROI3PD.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-E2WC6S4P.js → chunk-YBLZ2VE7.js} +13 -13
- package/dist/cli-bundle/chunks/{chunk-Y72FV7RM.js → chunk-YCQET3OT.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-YUSOJDWM.js +9 -0
- package/dist/cli-bundle/chunks/chunk-YXSHIAUJ.js +58 -0
- package/dist/cli-bundle/chunks/chunk-YXSHIAUJ.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-FS6UM5WH.js → chunk-ZI6VQWQ7.js} +4 -4
- package/dist/cli-bundle/chunks/chunk-ZKRZY773.js +68 -0
- package/dist/cli-bundle/chunks/chunk-ZKRZY773.js.map +7 -0
- package/dist/cli-bundle/chunks/{close-LZECOMHO.js → close-CWODTPKG.js} +5 -5
- package/dist/cli-bundle/chunks/close-W6LI2PKM.js +12 -0
- package/dist/cli-bundle/chunks/{close-many-ZHI6A5TN.js → close-many-CQFUY7MR.js} +15 -13
- package/dist/cli-bundle/chunks/close-many-DLDDVSH5.js +23 -0
- package/dist/cli-bundle/chunks/comments-E3TNTK24.js +13 -0
- package/dist/cli-bundle/chunks/{comments-AJWRTFZ5.js → comments-WGLHR7LB.js} +7 -7
- package/dist/cli-bundle/chunks/{copy-GMXYKBXT.js → copy-LXVDXH7B.js} +4 -4
- package/dist/cli-bundle/chunks/copy-Q5ZJPUKR.js +9 -0
- package/dist/cli-bundle/chunks/{create-F53OBTOU.js → create-J5U6ND4K.js} +9 -9
- package/dist/cli-bundle/chunks/{create-HU4Q7RJX.js → create-LBVCYMEG.js} +9 -9
- package/dist/cli-bundle/chunks/{delete-GSDZLTRC.js → delete-PMJBNY5G.js} +4 -4
- package/dist/cli-bundle/chunks/delete-WNHB3LYW.js +10 -0
- package/dist/cli-bundle/chunks/{deps-WWB7P2GT.js → deps-JZ7TMVCB.js} +7 -4
- package/dist/cli-bundle/chunks/{deps-U57I7EAK.js → deps-OA26IS25.js} +7 -4
- package/dist/cli-bundle/chunks/{docs-MQIY2ZQS.js → docs-FEWB2DQB.js} +6 -6
- package/dist/cli-bundle/chunks/docs-HA2AIDBB.js +14 -0
- package/dist/cli-bundle/chunks/{files-TBZD7V6H.js → files-6YFBJRBG.js} +6 -6
- package/dist/cli-bundle/chunks/{files-TTY6N2AV.js → files-EFIWKFTM.js} +6 -6
- package/dist/cli-bundle/chunks/{focus-XT6YVFFX.js → focus-4QJR7FOQ.js} +5 -5
- package/dist/cli-bundle/chunks/focus-POIW5LTJ.js +10 -0
- package/dist/cli-bundle/chunks/{history-compact-KKVUWB4V.js → history-compact-CKRPDTJN.js} +6 -10
- package/dist/cli-bundle/chunks/history-compact-FWG2C7FZ.js +16 -0
- package/dist/cli-bundle/chunks/history-redact-BB3TGDAE.js +15 -0
- package/dist/cli-bundle/chunks/{history-redact-3DVZOILD.js → history-redact-D225BHOZ.js} +5 -6
- package/dist/cli-bundle/chunks/history-repair-6GEAM7HE.js +16 -0
- package/dist/cli-bundle/chunks/{history-repair-ITDUMK4N.js → history-repair-RQXKQHL4.js} +6 -8
- package/dist/cli-bundle/chunks/{learnings-FGO3NSFW.js → learnings-JLNLCOL5.js} +7 -7
- package/dist/cli-bundle/chunks/learnings-RSNLSWDC.js +13 -0
- package/dist/cli-bundle/chunks/notes-2WDH6DXU.js +13 -0
- package/dist/cli-bundle/chunks/{notes-NQ6RXVW6.js → notes-GB47XXQQ.js} +7 -7
- package/dist/cli-bundle/chunks/plan-DOVI2VMW.js +24 -0
- package/dist/cli-bundle/chunks/{plan-2NNEO46V.js → plan-VDCJ2PCN.js} +10 -10
- package/dist/cli-bundle/chunks/{profile-AAQUU6T3.js → profile-FAU7NZML.js} +10 -10
- package/dist/cli-bundle/chunks/{profile-U725ATWZ.js → profile-IVXQEL3D.js} +10 -10
- package/dist/cli-bundle/chunks/{register-list-query-BUWCYHBT.js → register-list-query-DKA3EH5D.js} +22 -19
- package/dist/cli-bundle/chunks/register-list-query-DKA3EH5D.js.map +7 -0
- package/dist/cli-bundle/chunks/{register-list-query-KTZ6AGE7.js → register-list-query-UL4UKBBN.js} +23 -20
- package/dist/cli-bundle/chunks/register-list-query-UL4UKBBN.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-mutation-UELYYOR7.js → register-mutation-ARFHRW55.js} +36 -32
- package/dist/cli-bundle/chunks/{register-mutation-UELYYOR7.js.map → register-mutation-ARFHRW55.js.map} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-4FMGJJF7.js → register-mutation-RBBJ52DK.js} +37 -33
- package/dist/cli-bundle/chunks/register-mutation-RBBJ52DK.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-operations-JVW24J2Y.js → register-operations-ZIBBRSED.js} +41 -39
- package/dist/cli-bundle/chunks/{register-operations-JVW24J2Y.js.map → register-operations-ZIBBRSED.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-operations-ISUX6LY5.js → register-operations-ZUJ5JWPE.js} +39 -37
- package/dist/cli-bundle/chunks/{register-operations-ISUX6LY5.js.map → register-operations-ZUJ5JWPE.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-setup-5XNGKJ22.js → register-setup-BCVLFEYS.js} +29 -17
- package/dist/cli-bundle/chunks/{register-setup-5XNGKJ22.js.map → register-setup-BCVLFEYS.js.map} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-ZTNY6S7R.js → register-setup-TDCGWIOS.js} +19 -18
- package/dist/cli-bundle/chunks/{register-setup-ZTNY6S7R.js.map → register-setup-TDCGWIOS.js.map} +1 -1
- package/dist/cli-bundle/chunks/{restore-B3BAB6X2.js → restore-25DLT2Q2.js} +6 -6
- package/dist/cli-bundle/chunks/restore-YPMVUUEX.js +14 -0
- package/dist/cli-bundle/chunks/{schema-U7IM2DXV.js → schema-FNU3WE4O.js} +7 -6
- package/dist/cli-bundle/chunks/{schema-LZNUYHDB.js → schema-NBCM3RAD.js} +7 -6
- package/dist/cli-bundle/chunks/update-WWBYOPXO.js +21 -0
- package/dist/cli-bundle/chunks/update-WWBYOPXO.js.map +7 -0
- package/dist/cli-bundle/chunks/{update-Q3UCILNR.js → update-XHSIAIXE.js} +12 -12
- package/dist/cli-bundle/chunks/update-XHSIAIXE.js.map +1 -0
- package/dist/cli-bundle/chunks/update-many-OUGIU5SF.js +32 -0
- package/dist/cli-bundle/chunks/update-many-OUGIU5SF.js.map +7 -0
- package/dist/cli-bundle/chunks/update-many-TA7NGQBO.js +36 -0
- package/dist/cli-bundle/chunks/update-many-TA7NGQBO.js.map +1 -0
- package/dist/cli-bundle/main.js +826 -43
- package/dist/cli-bundle/main.js.map +4 -4
- package/dist/cli-bundle/sdk-runtime.js +70 -57
- package/dist/cli-bundle/sdk-testing.js +6 -6
- package/dist/cli-bundle/sdk.js +876 -74
- package/dist/cli-bundle/sdk.js.map +4 -4
- package/dist/cli.js +5 -4
- package/dist/cli.js.map +1 -1
- package/dist/core/diagnostics/remediation.js +12 -2
- package/dist/core/diagnostics/remediation.js.map +1 -1
- package/dist/core/history/projection.d.ts +39 -0
- package/dist/core/history/projection.js +164 -0
- package/dist/core/history/projection.js.map +1 -0
- package/dist/core/history/read.d.ts +3 -0
- package/dist/core/history/read.js +55 -0
- package/dist/core/history/read.js.map +1 -0
- package/dist/core/output/output-control.d.ts +18 -0
- package/dist/core/output/output-control.js +26 -0
- package/dist/core/output/output-control.js.map +1 -0
- package/dist/core/output/output.js +20 -8
- package/dist/core/output/output.js.map +1 -1
- package/dist/core/sentry/helpers.js +10 -2
- package/dist/core/sentry/helpers.js.map +1 -1
- package/dist/core/shared/command-types.d.ts +2 -0
- package/dist/core/shared/command-types.js +2 -2
- package/dist/core/shared/command-types.js.map +1 -1
- package/dist/core/shared/errors.d.ts +11 -0
- package/dist/core/shared/errors.js +2 -2
- package/dist/core/shared/errors.js.map +1 -1
- package/dist/mcp/server.d.ts +2 -2
- package/dist/mcp/tool-definitions.js +5 -5
- package/dist/mcp/tool-definitions.js.map +1 -1
- package/dist/sdk/author-attribution.d.ts +35 -0
- package/dist/sdk/author-attribution.js +118 -0
- package/dist/sdk/author-attribution.js.map +1 -0
- package/dist/sdk/cli-contracts/command-aliases.d.ts +7 -0
- package/dist/sdk/cli-contracts/command-aliases.js +17 -0
- package/dist/sdk/cli-contracts/command-aliases.js.map +1 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +5 -2
- package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-option-contracts.js +6 -2
- package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +21 -2
- package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +3 -3
- package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
- package/dist/sdk/cli-contracts.d.ts +1 -0
- package/dist/sdk/cli-contracts.js +3 -2
- package/dist/sdk/cli-contracts.js.map +1 -1
- package/dist/sdk/cli-program.d.ts +8 -0
- package/dist/sdk/cli-program.js +39 -0
- package/dist/sdk/cli-program.js.map +1 -0
- package/dist/sdk/command-line.d.ts +11 -0
- package/dist/sdk/command-line.js +40 -0
- package/dist/sdk/command-line.js.map +1 -0
- package/dist/sdk/config.d.ts +163 -0
- package/dist/sdk/config.js +1087 -0
- package/dist/sdk/config.js.map +1 -0
- package/dist/sdk/context-relevance.d.ts +21 -0
- package/dist/sdk/context-relevance.js +70 -2
- package/dist/sdk/context-relevance.js.map +1 -1
- package/dist/sdk/dependencies.d.ts +15 -2
- package/dist/sdk/dependencies.js +97 -8
- package/dist/sdk/dependencies.js.map +1 -1
- package/dist/{cli/commands → sdk}/extension/bundled-catalog.d.ts +1 -1
- package/dist/{cli/commands → sdk}/extension/bundled-catalog.js +12 -12
- package/dist/sdk/extension/bundled-catalog.js.map +1 -0
- package/dist/sdk/extension/concurrency.d.ts +7 -0
- package/dist/sdk/extension/concurrency.js +26 -0
- package/dist/sdk/extension/concurrency.js.map +1 -0
- package/dist/sdk/extension/describe.d.ts +91 -0
- package/dist/sdk/extension/describe.js +144 -0
- package/dist/sdk/extension/describe.js.map +1 -0
- package/dist/{cli/commands → sdk}/extension/doctor.d.ts +3 -3
- package/dist/{cli/commands → sdk}/extension/doctor.js +7 -7
- package/dist/sdk/extension/doctor.js.map +1 -0
- package/dist/sdk/extension/install-runtime.d.ts +26 -0
- package/dist/sdk/extension/install-runtime.js +269 -0
- package/dist/sdk/extension/install-runtime.js.map +1 -0
- package/dist/sdk/extension/install-snapshot.d.ts +23 -0
- package/dist/sdk/extension/install-snapshot.js +66 -0
- package/dist/sdk/extension/install-snapshot.js.map +1 -0
- package/dist/{cli/commands → sdk}/extension/install-sources.d.ts +3 -3
- package/dist/{cli/commands → sdk}/extension/install-sources.js +15 -12
- package/dist/sdk/extension/install-sources.js.map +1 -0
- package/dist/{cli/commands → sdk}/extension/managed-state.js +6 -6
- package/dist/sdk/extension/managed-state.js.map +1 -0
- package/dist/sdk/extension/scaffold.d.ts +36 -0
- package/dist/sdk/extension/scaffold.js +2436 -0
- package/dist/sdk/extension/scaffold.js.map +1 -0
- package/dist/sdk/extension/shared.d.ts +28 -0
- package/dist/sdk/extension/shared.js +140 -0
- package/dist/sdk/extension/shared.js.map +1 -0
- package/dist/sdk/extension/update-check.d.ts +15 -0
- package/dist/sdk/extension/update-check.js +68 -0
- package/dist/sdk/extension/update-check.js.map +1 -0
- package/dist/sdk/extension.d.ts +367 -0
- package/dist/sdk/extension.js +2174 -0
- package/dist/sdk/extension.js.map +1 -0
- package/dist/sdk/governance/gc.d.ts +56 -0
- package/dist/sdk/governance/gc.js +276 -0
- package/dist/sdk/governance/gc.js.map +1 -0
- package/dist/sdk/governance/health.d.ts +187 -0
- package/dist/sdk/governance/health.js +1796 -0
- package/dist/sdk/governance/health.js.map +1 -0
- package/dist/sdk/governance/validate.d.ts +255 -0
- package/dist/sdk/governance/validate.js +2175 -0
- package/dist/sdk/governance/validate.js.map +1 -0
- package/dist/sdk/history-compact.d.ts +142 -0
- package/dist/sdk/history-compact.js +508 -0
- package/dist/sdk/history-compact.js.map +1 -0
- package/dist/sdk/history-mcp.d.ts +17 -0
- package/dist/sdk/history-mcp.js +68 -0
- package/dist/sdk/history-mcp.js.map +1 -0
- package/dist/sdk/history-read.d.ts +31 -0
- package/dist/sdk/history-read.js +58 -0
- package/dist/sdk/history-read.js.map +1 -0
- package/dist/sdk/history-redact.d.ts +120 -0
- package/dist/sdk/history-redact.js +577 -0
- package/dist/sdk/history-redact.js.map +1 -0
- package/dist/sdk/history-repair.d.ts +89 -0
- package/dist/sdk/history-repair.js +263 -0
- package/dist/sdk/history-repair.js.map +1 -0
- package/dist/sdk/index.d.ts +25 -1
- package/dist/sdk/index.js +27 -3
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/init-agent-guidance.d.ts +113 -0
- package/dist/sdk/init-agent-guidance.js +437 -0
- package/dist/sdk/init-agent-guidance.js.map +1 -0
- package/dist/sdk/init.d.ts +186 -0
- package/dist/sdk/init.js +733 -0
- package/dist/sdk/init.js.map +1 -0
- package/dist/sdk/invocation-author.d.ts +2 -0
- package/dist/sdk/invocation-author.js +39 -0
- package/dist/sdk/invocation-author.js.map +1 -0
- package/dist/sdk/item-children.d.ts +45 -0
- package/dist/sdk/item-children.js +75 -0
- package/dist/sdk/item-children.js.map +1 -0
- package/dist/sdk/item-schedule.d.ts +26 -0
- package/dist/sdk/item-schedule.js +28 -0
- package/dist/sdk/item-schedule.js.map +1 -0
- package/dist/sdk/output.d.ts +7 -0
- package/dist/sdk/output.js +11 -0
- package/dist/sdk/output.js.map +1 -0
- package/dist/sdk/pagination.d.ts +4 -1
- package/dist/sdk/pagination.js +13 -5
- package/dist/sdk/pagination.js.map +1 -1
- package/dist/sdk/profile.d.ts +176 -0
- package/dist/sdk/profile.js +431 -0
- package/dist/sdk/profile.js.map +1 -0
- package/dist/sdk/relationship-analytics.d.ts +108 -0
- package/dist/sdk/relationship-analytics.js +292 -0
- package/dist/sdk/relationship-analytics.js.map +1 -0
- package/dist/sdk/relationship-context.d.ts +67 -0
- package/dist/sdk/relationship-context.js +207 -0
- package/dist/sdk/relationship-context.js.map +1 -0
- package/dist/sdk/relationship-history.d.ts +109 -0
- package/dist/sdk/relationship-history.js +401 -0
- package/dist/sdk/relationship-history.js.map +1 -0
- package/dist/sdk/relationships.d.ts +145 -0
- package/dist/sdk/relationships.js +551 -0
- package/dist/sdk/relationships.js.map +1 -0
- package/dist/sdk/runtime-input.d.ts +10 -0
- package/dist/sdk/runtime-input.js +60 -0
- package/dist/sdk/runtime-input.js.map +1 -0
- package/dist/sdk/runtime.d.ts +31 -8
- package/dist/sdk/runtime.js +61 -57
- package/dist/sdk/runtime.js.map +1 -1
- package/dist/sdk/schema.d.ts +507 -0
- package/dist/sdk/schema.js +1269 -0
- package/dist/sdk/schema.js.map +1 -0
- package/dist/{cli/commands → sdk}/templates.d.ts +1 -1
- package/dist/{cli/commands → sdk}/templates.js +9 -9
- package/dist/sdk/templates.js.map +1 -0
- package/dist/{cli/commands → sdk}/test/linked-command-detection.d.ts +10 -2
- package/dist/sdk/test/linked-command-detection.js +525 -0
- package/dist/sdk/test/linked-command-detection.js.map +1 -0
- package/docs/COMMANDS.md +58 -40
- package/docs/EXTENSIONS.md +10 -1
- package/docs/RELATIONSHIP_GRAPH.md +113 -0
- package/docs/RELEASING.md +2 -0
- package/docs/SDK.md +156 -9
- package/docs/SDK_CUSTOMIZATION_PRIMITIVES.md +79 -0
- package/marketplace.json +2 -2
- package/package.json +3 -2
- 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/extensions/governance-audit/runtime-utils.ts +76 -16
- package/packages/pm-governance-audit/extensions/governance-audit/sdk.ts +8 -0
- 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/scripts/bundle-cli.mjs +66 -23
- package/dist/cli/commands/extension/bundled-catalog.js.map +0 -1
- package/dist/cli/commands/extension/doctor.js.map +0 -1
- package/dist/cli/commands/extension/install-sources.js.map +0 -1
- package/dist/cli/commands/extension/managed-state.js.map +0 -1
- package/dist/cli/commands/templates.js.map +0 -1
- package/dist/cli/commands/test/linked-command-detection.js +0 -248
- package/dist/cli/commands/test/linked-command-detection.js.map +0 -1
- package/dist/cli-bundle/chunks/append-DYQWQK2J.js +0 -11
- package/dist/cli-bundle/chunks/chunk-2GA3NK35.js +0 -530
- package/dist/cli-bundle/chunks/chunk-2GA3NK35.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-2QIQGYPW.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-4DY4KPQI.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-4WREH7RT.js +0 -554
- package/dist/cli-bundle/chunks/chunk-4WREH7RT.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-5CT5BW6E.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-5URI7TPJ.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-6MHSBDGD.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-6OTZMORS.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-6PKA3SJQ.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-6TTOHMTB.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-7QDSYUMF.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-7TQMR6LK.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-B5DZYTT3.js +0 -312
- package/dist/cli-bundle/chunks/chunk-B5DZYTT3.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-BPD26E3P.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-CDJYP7OQ.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-DBZVUJTK.js +0 -858
- package/dist/cli-bundle/chunks/chunk-DBZVUJTK.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-DVOLZJ3C.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-DYEX6NFH.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-F7PSHRNO.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-FO7GMJKG.js +0 -875
- package/dist/cli-bundle/chunks/chunk-FO7GMJKG.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-FTQLW4JD.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-IA3YFTXT.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-IGED7NH2.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-J4NZOP3I.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-JL7WZ4O2.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-L24HCJFC.js +0 -309
- package/dist/cli-bundle/chunks/chunk-L24HCJFC.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-LWTIRS3Y.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-MKL4CP2I.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-N3CMP4NI.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-PHKP3AGR.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-Q37E63AM.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-QASRVKUQ.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-RGXD5JJR.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-UB2QYSTO.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-UGTVWL3E.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-ZAYYDNB3.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-ZUKSZVBW.js.map +0 -7
- package/dist/cli-bundle/chunks/close-RI4JQQHU.js +0 -12
- package/dist/cli-bundle/chunks/close-many-LY2XJ52M.js +0 -21
- package/dist/cli-bundle/chunks/comments-35M273DN.js +0 -13
- package/dist/cli-bundle/chunks/copy-NPYM7M7U.js +0 -9
- package/dist/cli-bundle/chunks/delete-ODRWJWAM.js +0 -10
- package/dist/cli-bundle/chunks/docs-G7N4E2JO.js +0 -14
- package/dist/cli-bundle/chunks/focus-U5TRVCRS.js +0 -10
- package/dist/cli-bundle/chunks/history-compact-M7GHYVFN.js +0 -20
- package/dist/cli-bundle/chunks/history-redact-JIHZLHDP.js +0 -16
- package/dist/cli-bundle/chunks/history-repair-NAFCHLH7.js +0 -18
- package/dist/cli-bundle/chunks/learnings-SONGPSHI.js +0 -13
- package/dist/cli-bundle/chunks/notes-BSD53H2W.js +0 -13
- package/dist/cli-bundle/chunks/plan-AWLYGBNV.js +0 -24
- package/dist/cli-bundle/chunks/register-list-query-BUWCYHBT.js.map +0 -7
- package/dist/cli-bundle/chunks/register-list-query-KTZ6AGE7.js.map +0 -1
- package/dist/cli-bundle/chunks/register-mutation-4FMGJJF7.js.map +0 -1
- package/dist/cli-bundle/chunks/restore-66GLMHIX.js +0 -14
- package/dist/cli-bundle/chunks/update-2XGHIVQ2.js +0 -21
- package/dist/cli-bundle/chunks/update-many-75K57FS3.js +0 -34
- package/dist/cli-bundle/chunks/update-many-U42YA445.js +0 -30
- /package/dist/cli-bundle/chunks/{append-PVZJDM6J.js.map → append-OJQFUQ4T.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{append-DYQWQK2J.js.map → append-UZVHUO74.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-MQZ3PLCF.js.map → chunk-2IFFUZLC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-P6MYFH6K.js.map → chunk-2JKGO6QX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-X3GYR4P2.js.map → chunk-2NCIPMQP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-Q7E6OYZK.js.map → chunk-2VPAVL7O.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-DRNJPEPQ.js.map → chunk-2WSE6PO2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-FDSBDNYE.js.map → chunk-34L5OT3Y.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-TH7U4KLY.js.map → chunk-3AUGG2DP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-NKW36AMT.js.map → chunk-3CLU2XZO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-ABRCOSDC.js.map → chunk-3WM75PWC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-X6BVXQ52.js.map → chunk-5JLUII3O.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-3TL7WOEF.js.map → chunk-6N2VXVTQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-ERL2YFJ2.js.map → chunk-6S3YSUYG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-IFZA4VB5.js.map → chunk-AHVTB5I5.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-DO5RGJXT.js.map → chunk-APRVSW2O.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-NAQYVWSQ.js.map → chunk-B7PE22W6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-MD6ULIPJ.js.map → chunk-BCOFWYW4.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-KADLSPIU.js.map → chunk-BEP7WJA2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-OBDLEQG5.js.map → chunk-CRVF2JDM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-FJZDA6MS.js.map → chunk-DM4H7FP4.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-LZECOMHO.js.map → chunk-DUT67M43.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-44LNIULG.js.map → chunk-DYH63FX7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-HAMLIWAF.js.map → chunk-EAB64KLB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-CIOZ376P.js.map → chunk-EACOH7AU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QK2ZN6UL.js.map → chunk-EJEXHTY5.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-WQUEHPZB.js.map → chunk-EYLCSJAI.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-655STMGA.js.map → chunk-FMBNM2EN.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-RMF3IOYQ.js.map → chunk-FNSPG7MU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-KB726FMH.js.map → chunk-H2Z3FYXQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-BN62TO2S.js.map → chunk-IA5FKNII.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-W6HZ55JO.js.map → chunk-IJIICKVW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-M7EWN4TF.js.map → chunk-JOUQZENX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-2FNWQXZ2.js.map → chunk-JYFOV7FC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-HLHSQ5CA.js.map → chunk-K2X6U4UA.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-M6ASXYCU.js.map → chunk-KG44YSKD.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-YVKE5ZDM.js.map → chunk-KPMKHGEA.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-many-ZHI6A5TN.js.map → chunk-MIQDDLB5.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-UJ4HJYWL.js.map → chunk-NLDFBC6J.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-WRKB56FC.js.map → chunk-NP22ERDF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-YQYG2V23.js.map → chunk-NU3IMIEA.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-3I3LRT2G.js.map → chunk-NVPZIJVR.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-JAF4TUQ7.js.map → chunk-ODALILG3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QZ7LT3XE.js.map → chunk-ONREO4ST.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-3CMRNVTO.js.map → chunk-P74IZQ7A.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-ZTRBSABY.js.map → chunk-PGY23YTC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-H2QBAKLQ.js.map → chunk-PMOSXADO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-RI4JQQHU.js.map → chunk-PNTULOGU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-GSEADLRH.js.map → chunk-Q7A43DS4.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QSPARJWF.js.map → chunk-QEHQ2GVG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-VJTAEIPC.js.map → chunk-QIPLHNP7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-K7WNZ7KD.js.map → chunk-QKJGPFAF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-ZNP64HOW.js.map → chunk-RLCHOOHC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-IAPHYPRL.js.map → chunk-RMLWNPH2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-UVBA6F5A.js.map → chunk-RRM5JYJC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-6IIVBC56.js.map → chunk-S6MQESFR.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QABYZYLU.js.map → chunk-SDQLJWBO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-ANSJHDOZ.js.map → chunk-SELVXEZK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-WD6MSYMP.js.map → chunk-TKOVBP6C.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-TZ2PSLLT.js.map → chunk-TQSZFPIS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-WPAWZW7S.js.map → chunk-TSMHDIW4.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-TZRTLMWM.js.map → chunk-UFXU44HV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-TWLDBKQU.js.map → chunk-ULTHRDBP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-RA5AIAMP.js.map → chunk-UOHFKBUV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-4RXTMU57.js.map → chunk-UY2ACEMF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-FIGXOCEQ.js.map → chunk-WUJQK4YV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-T4BRCB6Z.js.map → chunk-XSJUSQAE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-UKUIIBDW.js.map → chunk-YAQEBNY7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-E2WC6S4P.js.map → chunk-YBLZ2VE7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-Y72FV7RM.js.map → chunk-YCQET3OT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-many-LY2XJ52M.js.map → chunk-YUSOJDWM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-FS6UM5WH.js.map → chunk-ZI6VQWQ7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{comments-AJWRTFZ5.js.map → close-CWODTPKG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{comments-35M273DN.js.map → close-W6LI2PKM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{copy-GMXYKBXT.js.map → close-many-CQFUY7MR.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{copy-NPYM7M7U.js.map → close-many-DLDDVSH5.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{create-F53OBTOU.js.map → comments-E3TNTK24.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{create-HU4Q7RJX.js.map → comments-WGLHR7LB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{delete-GSDZLTRC.js.map → copy-LXVDXH7B.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{delete-ODRWJWAM.js.map → copy-Q5ZJPUKR.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{deps-U57I7EAK.js.map → create-J5U6ND4K.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{deps-WWB7P2GT.js.map → create-LBVCYMEG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{docs-MQIY2ZQS.js.map → delete-PMJBNY5G.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{docs-G7N4E2JO.js.map → delete-WNHB3LYW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{files-TTY6N2AV.js.map → deps-JZ7TMVCB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{files-TBZD7V6H.js.map → deps-OA26IS25.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{focus-XT6YVFFX.js.map → docs-FEWB2DQB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{focus-U5TRVCRS.js.map → docs-HA2AIDBB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-compact-M7GHYVFN.js.map → files-6YFBJRBG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-compact-KKVUWB4V.js.map → files-EFIWKFTM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-redact-3DVZOILD.js.map → focus-4QJR7FOQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-redact-JIHZLHDP.js.map → focus-POIW5LTJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-repair-ITDUMK4N.js.map → history-compact-CKRPDTJN.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-repair-NAFCHLH7.js.map → history-compact-FWG2C7FZ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{learnings-SONGPSHI.js.map → history-redact-BB3TGDAE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{learnings-FGO3NSFW.js.map → history-redact-D225BHOZ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{notes-BSD53H2W.js.map → history-repair-6GEAM7HE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{notes-NQ6RXVW6.js.map → history-repair-RQXKQHL4.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{plan-2NNEO46V.js.map → learnings-JLNLCOL5.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{plan-AWLYGBNV.js.map → learnings-RSNLSWDC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{profile-U725ATWZ.js.map → notes-2WDH6DXU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{profile-AAQUU6T3.js.map → notes-GB47XXQQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{restore-66GLMHIX.js.map → plan-DOVI2VMW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{restore-B3BAB6X2.js.map → plan-VDCJ2PCN.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{schema-U7IM2DXV.js.map → profile-FAU7NZML.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{schema-LZNUYHDB.js.map → profile-IVXQEL3D.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-Q3UCILNR.js.map → restore-25DLT2Q2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-2XGHIVQ2.js.map → restore-YPMVUUEX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-many-75K57FS3.js.map → schema-FNU3WE4O.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-many-U42YA445.js.map → schema-NBCM3RAD.js.map} +0 -0
- /package/dist/{cli/commands → sdk}/extension/managed-state.d.ts +0 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/relationship-history
|
|
3
|
+
*
|
|
4
|
+
* Provides an append-only, storage-independent relationship event ledger with
|
|
5
|
+
* optimistic concurrency, deterministic replay, snapshots, and cursor pages.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="787e8f44-80d5-554f-9232-9675cf6a8637")}catch(e){}}();
|
|
9
|
+
import { createQueryFingerprint, decodeQueryCursorState, paginateQueryRows, } from "./pagination.js";
|
|
10
|
+
import { constants } from "node:fs";
|
|
11
|
+
import { lstat, mkdir, open } from "node:fs/promises";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import { acquireLock } from "../core/lock/lock.js";
|
|
14
|
+
import { RelationshipGraph, createRelationshipKindRegistry, } from "./relationships.js";
|
|
15
|
+
function requiredText(value, field) {
|
|
16
|
+
if (typeof value !== "string" || value.trim().length === 0)
|
|
17
|
+
throw new TypeError(`Relationship event ${field} must be non-empty`);
|
|
18
|
+
return value.trim();
|
|
19
|
+
}
|
|
20
|
+
function edgeIdentity(edge, registry) {
|
|
21
|
+
const definition = registry.require(edge.kind);
|
|
22
|
+
const endpoints = definition.direction === "undirected"
|
|
23
|
+
? [edge.source, edge.target].sort().join("\u0000")
|
|
24
|
+
: `${edge.source}\u0000${edge.target}`;
|
|
25
|
+
return `${definition.kind}\u0000${endpoints}`;
|
|
26
|
+
}
|
|
27
|
+
function freezeEdge(edge) {
|
|
28
|
+
return Object.freeze({
|
|
29
|
+
...edge,
|
|
30
|
+
...(edge.payload === undefined
|
|
31
|
+
? {}
|
|
32
|
+
: { payload: Object.freeze(structuredClone(edge.payload)) }),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function assertCardinality(candidate, excludeRelationshipId, registry, indexes) {
|
|
36
|
+
const definition = registry.require(candidate.kind);
|
|
37
|
+
const outgoingOwner = indexes.outgoingOne.get(`${definition.kind}\u0000${candidate.source}`);
|
|
38
|
+
if (outgoingOwner !== undefined && outgoingOwner !== excludeRelationshipId)
|
|
39
|
+
throw new TypeError(`Relationship outgoing cardinality exceeded for ${definition.kind}`);
|
|
40
|
+
const incomingOwner = indexes.incomingOne.get(`${definition.kind}\u0000${candidate.target}`);
|
|
41
|
+
if (incomingOwner !== undefined && incomingOwner !== excludeRelationshipId)
|
|
42
|
+
throw new TypeError(`Relationship incoming cardinality exceeded for ${definition.kind}`);
|
|
43
|
+
const identity = edgeIdentity(candidate, registry);
|
|
44
|
+
const identityOwner = indexes.identities.get(identity);
|
|
45
|
+
if (identityOwner !== undefined && identityOwner !== excludeRelationshipId)
|
|
46
|
+
throw new TypeError(`Relationship edge already active: ${identity}`);
|
|
47
|
+
}
|
|
48
|
+
function replayEvents(events) {
|
|
49
|
+
const active = new Map();
|
|
50
|
+
for (const event of events) {
|
|
51
|
+
if (event.action === "remove")
|
|
52
|
+
active.delete(event.relationshipId);
|
|
53
|
+
else
|
|
54
|
+
active.set(event.relationshipId, event.edge);
|
|
55
|
+
}
|
|
56
|
+
return active;
|
|
57
|
+
}
|
|
58
|
+
function normalizeEventHeader(input, currentVersion, eventIds) {
|
|
59
|
+
if (input.expectedVersion !== undefined &&
|
|
60
|
+
input.expectedVersion !== currentVersion)
|
|
61
|
+
throw new TypeError(`Relationship event version conflict: expected ${input.expectedVersion}, current ${currentVersion}`);
|
|
62
|
+
const eventId = requiredText(input.eventId, "eventId");
|
|
63
|
+
if (eventIds.has(eventId))
|
|
64
|
+
throw new TypeError(`Relationship event already exists: ${eventId}`);
|
|
65
|
+
if (input.action !== "add" &&
|
|
66
|
+
input.action !== "remove" &&
|
|
67
|
+
input.action !== "supersede")
|
|
68
|
+
throw new TypeError(`Unknown relationship event action: ${input.action}`);
|
|
69
|
+
if (!Number.isFinite(Date.parse(input.timestamp)))
|
|
70
|
+
throw new TypeError("Relationship event timestamp must be valid");
|
|
71
|
+
return {
|
|
72
|
+
eventId,
|
|
73
|
+
relationshipId: requiredText(input.relationshipId, "relationshipId"),
|
|
74
|
+
author: requiredText(input.author, "author"),
|
|
75
|
+
timestamp: new Date(input.timestamp).toISOString(),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function resolveMutationEdge(input, relationshipId, active, nodes, registry, indexes) {
|
|
79
|
+
const isActive = active.has(relationshipId);
|
|
80
|
+
if (input.action === "add" && isActive)
|
|
81
|
+
throw new TypeError(`Relationship is already active: ${relationshipId}`);
|
|
82
|
+
if (input.action !== "add" && !isActive)
|
|
83
|
+
throw new TypeError(`Relationship is not active: ${relationshipId}`);
|
|
84
|
+
if (input.action === "remove")
|
|
85
|
+
return undefined;
|
|
86
|
+
if (!input.edge)
|
|
87
|
+
throw new TypeError(`Relationship ${input.action} event requires an edge`);
|
|
88
|
+
const source = typeof input.edge.source === "string" ? input.edge.source.trim() : "";
|
|
89
|
+
const target = typeof input.edge.target === "string" ? input.edge.target.trim() : "";
|
|
90
|
+
if (!nodes.has(source) || !nodes.has(target))
|
|
91
|
+
throw new TypeError(`Relationship endpoint not found: ${source} -> ${target}`);
|
|
92
|
+
const canonical = new RelationshipGraph([source, target], [input.edge], registry).edges()[0];
|
|
93
|
+
assertCardinality(canonical, relationshipId, registry, indexes);
|
|
94
|
+
return freezeEdge(canonical);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Append-only in-memory reference ledger. Durable adapters can persist the
|
|
98
|
+
* returned immutable events while reusing the same replay and validation model.
|
|
99
|
+
*/
|
|
100
|
+
export class RelationshipEventLog {
|
|
101
|
+
#nodes;
|
|
102
|
+
#registry;
|
|
103
|
+
#events = [];
|
|
104
|
+
#eventIds = new Set();
|
|
105
|
+
#active = new Map();
|
|
106
|
+
#cardinalityIndexes = {
|
|
107
|
+
identities: new Map(),
|
|
108
|
+
outgoingOne: new Map(),
|
|
109
|
+
incomingOne: new Map(),
|
|
110
|
+
};
|
|
111
|
+
/** Create an empty relationship ledger for a fixed node universe. */
|
|
112
|
+
constructor(nodes, options = {}) {
|
|
113
|
+
this.#nodes = new Set([...nodes]
|
|
114
|
+
.filter((node) => typeof node === "string")
|
|
115
|
+
.map((node) => node.trim())
|
|
116
|
+
.filter(Boolean));
|
|
117
|
+
this.#registry = options.registry ?? createRelationshipKindRegistry();
|
|
118
|
+
}
|
|
119
|
+
/** Current append sequence. */
|
|
120
|
+
get version() {
|
|
121
|
+
return this.#events.length;
|
|
122
|
+
}
|
|
123
|
+
/** Return an immutable copy of the full event stream. */
|
|
124
|
+
events() {
|
|
125
|
+
return Object.freeze([...this.#events]);
|
|
126
|
+
}
|
|
127
|
+
/** Add one active relationship to constant-time validation indexes. */
|
|
128
|
+
#indexActive(relationshipId, edge) {
|
|
129
|
+
const definition = this.#registry.require(edge.kind);
|
|
130
|
+
this.#cardinalityIndexes.identities.set(edgeIdentity(edge, this.#registry), relationshipId);
|
|
131
|
+
if (definition.outgoing === "one")
|
|
132
|
+
this.#cardinalityIndexes.outgoingOne.set(`${definition.kind}\u0000${edge.source}`, relationshipId);
|
|
133
|
+
if (definition.incoming === "one")
|
|
134
|
+
this.#cardinalityIndexes.incomingOne.set(`${definition.kind}\u0000${edge.target}`, relationshipId);
|
|
135
|
+
}
|
|
136
|
+
/** Remove one superseded or deleted relationship from validation indexes. */
|
|
137
|
+
#unindexActive(edge) {
|
|
138
|
+
const definition = this.#registry.require(edge.kind);
|
|
139
|
+
this.#cardinalityIndexes.identities.delete(edgeIdentity(edge, this.#registry));
|
|
140
|
+
if (definition.outgoing === "one")
|
|
141
|
+
this.#cardinalityIndexes.outgoingOne.delete(`${definition.kind}\u0000${edge.source}`);
|
|
142
|
+
if (definition.incoming === "one")
|
|
143
|
+
this.#cardinalityIndexes.incomingOne.delete(`${definition.kind}\u0000${edge.target}`);
|
|
144
|
+
}
|
|
145
|
+
/** Validate and append one attributable relationship mutation. */
|
|
146
|
+
append(input) {
|
|
147
|
+
const header = normalizeEventHeader(input, this.version, this.#eventIds);
|
|
148
|
+
const previous = this.#active.get(header.relationshipId);
|
|
149
|
+
const edge = resolveMutationEdge(input, header.relationshipId, this.#active, this.#nodes, this.#registry, this.#cardinalityIndexes);
|
|
150
|
+
const event = Object.freeze({
|
|
151
|
+
eventId: header.eventId,
|
|
152
|
+
relationshipId: header.relationshipId,
|
|
153
|
+
action: input.action,
|
|
154
|
+
...(edge === undefined ? {} : { edge }),
|
|
155
|
+
author: header.author,
|
|
156
|
+
timestamp: header.timestamp,
|
|
157
|
+
...(input.reason?.trim() ? { reason: input.reason.trim() } : {}),
|
|
158
|
+
sequence: this.version + 1,
|
|
159
|
+
});
|
|
160
|
+
this.#events.push(event);
|
|
161
|
+
this.#eventIds.add(header.eventId);
|
|
162
|
+
if (previous)
|
|
163
|
+
this.#unindexActive(previous);
|
|
164
|
+
if (input.action === "remove")
|
|
165
|
+
this.#active.delete(header.relationshipId);
|
|
166
|
+
else {
|
|
167
|
+
this.#active.set(header.relationshipId, edge);
|
|
168
|
+
this.#indexActive(header.relationshipId, edge);
|
|
169
|
+
}
|
|
170
|
+
return event;
|
|
171
|
+
}
|
|
172
|
+
/** Materialize an exact point-in-time graph without mutating the ledger. */
|
|
173
|
+
snapshot(options = {}) {
|
|
174
|
+
if (options.atVersion !== undefined && options.atTimestamp !== undefined)
|
|
175
|
+
throw new TypeError("Relationship snapshot accepts one target");
|
|
176
|
+
let included;
|
|
177
|
+
if (options.atTimestamp !== undefined) {
|
|
178
|
+
const timestamp = Date.parse(options.atTimestamp);
|
|
179
|
+
if (!Number.isFinite(timestamp))
|
|
180
|
+
throw new TypeError("Relationship snapshot timestamp must be valid");
|
|
181
|
+
let lastIndex = -1;
|
|
182
|
+
for (let index = this.#events.length - 1; index >= 0; index -= 1) {
|
|
183
|
+
if (Date.parse(this.#events[index].timestamp) > timestamp)
|
|
184
|
+
continue;
|
|
185
|
+
lastIndex = index;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
included = lastIndex === -1 ? [] : this.#events.slice(0, lastIndex + 1);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
const version = options.atVersion ?? this.version;
|
|
192
|
+
if (!Number.isInteger(version) || version < 0 || version > this.version)
|
|
193
|
+
throw new TypeError(`Relationship snapshot version out of range: ${version}`);
|
|
194
|
+
included = this.#events.slice(0, version);
|
|
195
|
+
}
|
|
196
|
+
const active = replayEvents(included);
|
|
197
|
+
const graph = new RelationshipGraph(this.#nodes, active.values(), this.#registry);
|
|
198
|
+
return Object.freeze({
|
|
199
|
+
version: included.length,
|
|
200
|
+
...(included.at(-1) ? { asOf: included.at(-1).timestamp } : {}),
|
|
201
|
+
edges: graph.edges(),
|
|
202
|
+
graph,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/** Page the immutable event stream with a cursor bound to this log version. */
|
|
206
|
+
page(options) {
|
|
207
|
+
if (!Number.isInteger(options.limit) || options.limit < 1)
|
|
208
|
+
throw new TypeError("Relationship event page limit must be positive");
|
|
209
|
+
const fingerprint = createQueryFingerprint("relationship-events", {
|
|
210
|
+
order: "append-sequence",
|
|
211
|
+
});
|
|
212
|
+
const snapshot = options.cursor === undefined
|
|
213
|
+
? this.version
|
|
214
|
+
: Number(decodeQueryCursorState(options.cursor, fingerprint).snapshot);
|
|
215
|
+
if (!Number.isSafeInteger(snapshot) ||
|
|
216
|
+
snapshot < 0 ||
|
|
217
|
+
snapshot > this.version)
|
|
218
|
+
throw new TypeError("Relationship event cursor snapshot version is invalid");
|
|
219
|
+
const page = paginateQueryRows(this.#events.slice(0, snapshot), {
|
|
220
|
+
cursor: options.cursor,
|
|
221
|
+
fingerprint,
|
|
222
|
+
limit: options.limit,
|
|
223
|
+
readId: (event) => event.eventId,
|
|
224
|
+
snapshot: String(snapshot),
|
|
225
|
+
});
|
|
226
|
+
return {
|
|
227
|
+
version: snapshot,
|
|
228
|
+
events: page.rows,
|
|
229
|
+
hasMore: page.has_more,
|
|
230
|
+
...(page.next_cursor ? { nextCursor: page.next_cursor } : {}),
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const RELATIONSHIP_STORE_LOCK_ID = "relationship-event-store";
|
|
235
|
+
const RELATIONSHIP_NOFOLLOW_FLAG = constants.O_NOFOLLOW;
|
|
236
|
+
function acquireRelationshipStoreLock(pmRoot) {
|
|
237
|
+
return acquireLock(pmRoot, RELATIONSHIP_STORE_LOCK_ID, 30, `relationship-store:${process.pid}`, false, false, 3_000);
|
|
238
|
+
}
|
|
239
|
+
async function resolveRelationshipEventStorePath(pmRoot, relativePath = "relationships/events.jsonl") {
|
|
240
|
+
const root = path.resolve(pmRoot);
|
|
241
|
+
const target = path.resolve(root, relativePath);
|
|
242
|
+
const relative = path.relative(root, target);
|
|
243
|
+
if (relative.length === 0)
|
|
244
|
+
throw new TypeError("Relationship event path must name a file within the tracker root");
|
|
245
|
+
if (relative === ".." ||
|
|
246
|
+
relative.startsWith(`..${path.sep}`) ||
|
|
247
|
+
path.isAbsolute(relative))
|
|
248
|
+
throw new TypeError("Relationship event path must stay within the tracker root");
|
|
249
|
+
await mkdir(root, { recursive: true });
|
|
250
|
+
const rootStats = await lstat(root);
|
|
251
|
+
if (rootStats.isSymbolicLink())
|
|
252
|
+
throw new TypeError("Relationship event tracker root must not be a symbolic link");
|
|
253
|
+
let current = root;
|
|
254
|
+
for (const segment of relative.split(path.sep)) {
|
|
255
|
+
current = path.join(current, segment);
|
|
256
|
+
try {
|
|
257
|
+
if ((await lstat(current)).isSymbolicLink())
|
|
258
|
+
throw new TypeError("Relationship event path must not contain symbolic links");
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
if (error.code === "ENOENT")
|
|
262
|
+
break;
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return target;
|
|
267
|
+
}
|
|
268
|
+
async function loadRelationshipEventLog(target, nodes, registry) {
|
|
269
|
+
const log = new RelationshipEventLog(nodes, { registry });
|
|
270
|
+
let raw;
|
|
271
|
+
let handle;
|
|
272
|
+
try {
|
|
273
|
+
handle = await open(target, constants.O_RDONLY | RELATIONSHIP_NOFOLLOW_FLAG);
|
|
274
|
+
raw = await handle.readFile("utf8");
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
if (error.code === "ENOENT")
|
|
278
|
+
return log;
|
|
279
|
+
throw error;
|
|
280
|
+
}
|
|
281
|
+
finally {
|
|
282
|
+
await handle?.close();
|
|
283
|
+
}
|
|
284
|
+
const lines = raw.split("\n");
|
|
285
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
286
|
+
const line = lines[index].trim();
|
|
287
|
+
if (!line)
|
|
288
|
+
continue;
|
|
289
|
+
let stored;
|
|
290
|
+
try {
|
|
291
|
+
stored = JSON.parse(line);
|
|
292
|
+
}
|
|
293
|
+
catch {
|
|
294
|
+
throw new TypeError(`Invalid relationship event JSONL at line ${index + 1}`);
|
|
295
|
+
}
|
|
296
|
+
if (stored.sequence !== log.version + 1)
|
|
297
|
+
throw new TypeError(`Invalid relationship event sequence at line ${index + 1}`);
|
|
298
|
+
log.append({
|
|
299
|
+
eventId: stored.eventId,
|
|
300
|
+
relationshipId: stored.relationshipId,
|
|
301
|
+
action: stored.action,
|
|
302
|
+
...(stored.edge === undefined ? {} : { edge: stored.edge }),
|
|
303
|
+
author: stored.author,
|
|
304
|
+
timestamp: stored.timestamp,
|
|
305
|
+
...(stored.reason === undefined ? {} : { reason: stored.reason }),
|
|
306
|
+
expectedVersion: log.version,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
return log;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Lock-serialized durable JSONL adapter for {@link RelationshipEventLog}.
|
|
313
|
+
* Every append replays the current stream while holding the workspace lock, so
|
|
314
|
+
* independent processes share optimistic versions without lost updates.
|
|
315
|
+
*/
|
|
316
|
+
export class RelationshipEventStore {
|
|
317
|
+
#pmRoot;
|
|
318
|
+
#nodes;
|
|
319
|
+
#registry;
|
|
320
|
+
#path;
|
|
321
|
+
#log;
|
|
322
|
+
constructor(options, nodes, target, log) {
|
|
323
|
+
this.#pmRoot = options.pmRoot;
|
|
324
|
+
this.#nodes = nodes;
|
|
325
|
+
this.#registry = options.registry;
|
|
326
|
+
this.#path = target;
|
|
327
|
+
this.#log = log;
|
|
328
|
+
}
|
|
329
|
+
/** Open and validate an existing stream or create an empty store view. */
|
|
330
|
+
static async open(options) {
|
|
331
|
+
const nodes = Object.freeze([...options.nodes]);
|
|
332
|
+
const target = await resolveRelationshipEventStorePath(options.pmRoot, options.relativePath);
|
|
333
|
+
const release = await acquireRelationshipStoreLock(options.pmRoot);
|
|
334
|
+
try {
|
|
335
|
+
await resolveRelationshipEventStorePath(options.pmRoot, target);
|
|
336
|
+
const log = await loadRelationshipEventLog(target, nodes, options.registry);
|
|
337
|
+
return new RelationshipEventStore(options, nodes, target, log);
|
|
338
|
+
}
|
|
339
|
+
finally {
|
|
340
|
+
await release();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
/** Absolute JSONL path, exposed for diagnostics and backup tooling. */
|
|
344
|
+
get path() {
|
|
345
|
+
return this.#path;
|
|
346
|
+
}
|
|
347
|
+
/** Refresh from durable history and return the current validated append sequence. */
|
|
348
|
+
async currentVersion() {
|
|
349
|
+
this.#log = await this.#refreshFromDurableHistory();
|
|
350
|
+
return this.#log.version;
|
|
351
|
+
}
|
|
352
|
+
/** Append one event after refreshing under the shared workspace lock. */
|
|
353
|
+
async append(input) {
|
|
354
|
+
const release = await acquireRelationshipStoreLock(this.#pmRoot);
|
|
355
|
+
try {
|
|
356
|
+
const target = await resolveRelationshipEventStorePath(this.#pmRoot, this.#path);
|
|
357
|
+
const refreshed = await loadRelationshipEventLog(target, this.#nodes, this.#registry);
|
|
358
|
+
const event = refreshed.append(input);
|
|
359
|
+
await mkdir(path.dirname(target), { recursive: true });
|
|
360
|
+
await resolveRelationshipEventStorePath(this.#pmRoot, target);
|
|
361
|
+
const handle = await open(target, constants.O_APPEND |
|
|
362
|
+
constants.O_CREAT |
|
|
363
|
+
constants.O_WRONLY |
|
|
364
|
+
RELATIONSHIP_NOFOLLOW_FLAG);
|
|
365
|
+
try {
|
|
366
|
+
await handle.appendFile(`${JSON.stringify(event)}\n`, "utf8");
|
|
367
|
+
}
|
|
368
|
+
finally {
|
|
369
|
+
await handle.close();
|
|
370
|
+
}
|
|
371
|
+
this.#log = refreshed;
|
|
372
|
+
return event;
|
|
373
|
+
}
|
|
374
|
+
finally {
|
|
375
|
+
await release();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
/** Refresh from durable history and materialize an exact validated snapshot. */
|
|
379
|
+
async snapshot(options = {}) {
|
|
380
|
+
this.#log = await this.#refreshFromDurableHistory();
|
|
381
|
+
return this.#log.snapshot(options);
|
|
382
|
+
}
|
|
383
|
+
/** Refresh from durable history and page immutable events. */
|
|
384
|
+
async page(options) {
|
|
385
|
+
this.#log = await this.#refreshFromDurableHistory();
|
|
386
|
+
return this.#log.page(options);
|
|
387
|
+
}
|
|
388
|
+
/** Serialize a durable refresh with writers so readers never observe a torn JSONL tail. */
|
|
389
|
+
async #refreshFromDurableHistory() {
|
|
390
|
+
const release = await acquireRelationshipStoreLock(this.#pmRoot);
|
|
391
|
+
try {
|
|
392
|
+
const target = await resolveRelationshipEventStorePath(this.#pmRoot, this.#path);
|
|
393
|
+
return await loadRelationshipEventLog(target, this.#nodes, this.#registry);
|
|
394
|
+
}
|
|
395
|
+
finally {
|
|
396
|
+
await release();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
//# sourceMappingURL=relationship-history.js.map
|
|
401
|
+
//# debugId=787e8f44-80d5-554f-9232-9675cf6a8637
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relationship-history.js","sources":["sdk/relationship-history.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module sdk/relationship-history\n *\n * Provides an append-only, storage-independent relationship event ledger with\n * optimistic concurrency, deterministic replay, snapshots, and cursor pages.\n */\nimport {\n createQueryFingerprint,\n decodeQueryCursorState,\n paginateQueryRows,\n} from \"./pagination.js\";\nimport { constants } from \"node:fs\";\nimport { lstat, mkdir, open, type FileHandle } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { acquireLock } from \"../core/lock/lock.js\";\nimport {\n RelationshipGraph,\n RelationshipKindRegistry,\n createRelationshipKindRegistry,\n type RelationshipEdge,\n} from \"./relationships.js\";\n\n/** Mutation kinds retained in the immutable relationship event stream. */\nexport type RelationshipEventAction = \"add\" | \"remove\" | \"supersede\";\n\n/** Caller-authored relationship mutation before its sequence is assigned. */\nexport interface RelationshipEventInput {\n /** Globally unique idempotency key for this event. */\n eventId: string;\n /** Stable logical relationship identifier across superseding events. */\n relationshipId: string;\n /** Append, remove, or replace the logical relationship. */\n action: RelationshipEventAction;\n /** Edge required for add and supersede actions. */\n edge?: RelationshipEdge;\n /** Attributable actor responsible for the mutation. */\n author: string;\n /** Valid event-time timestamp. */\n timestamp: string;\n /** Optional optimistic concurrency precondition. */\n expectedVersion?: number;\n /** Optional human-readable mutation rationale. */\n reason?: string;\n}\n\n/** One immutable sequenced relationship mutation. */\nexport interface RelationshipEvent extends Omit<\n RelationshipEventInput,\n \"expectedVersion\"\n> {\n /** One-based append sequence assigned by the ledger. */\n sequence: number;\n}\n\n/** Point-in-time materialized relationship view. */\nexport interface RelationshipSnapshot {\n /** Final event sequence included in this snapshot. */\n version: number;\n /** Timestamp of the final included event, when one exists. */\n asOf?: string;\n /** Deterministic active edge materialization. */\n edges: readonly RelationshipEdge[];\n /** Immutable graph query view over the active edges. */\n graph: RelationshipGraph;\n}\n\n/** Stable cursor page over a fixed relationship event-log version. */\nexport interface RelationshipEventPage {\n /** Log version against which this page was produced. */\n version: number;\n /** Events in append order. */\n events: RelationshipEvent[];\n /** Whether another event page exists. */\n hasMore: boolean;\n /** Opaque continuation cursor when another page exists. */\n nextCursor?: string;\n}\n\n/** Construction controls for the in-memory reference ledger. */\nexport interface RelationshipEventLogOptions {\n /** Registry defining edge semantics and cardinality. */\n registry?: RelationshipKindRegistry;\n}\n\n/** Filesystem controls for the durable relationship event store. */\nexport interface RelationshipEventStoreOptions extends RelationshipEventLogOptions {\n /** Tracker root that owns the relationship history directory. */\n pmRoot: string;\n /** Fixed node universe validated by every replay and append. */\n nodes: Iterable<string>;\n /** Optional JSONL path relative to the tracker root. */\n relativePath?: string;\n}\n\ninterface RelationshipCardinalityIndexes {\n identities: Map<string, string>;\n outgoingOne: Map<string, string>;\n incomingOne: Map<string, string>;\n}\n\nfunction requiredText(value: unknown, field: string): string {\n if (typeof value !== \"string\" || value.trim().length === 0)\n throw new TypeError(`Relationship event ${field} must be non-empty`);\n return value.trim();\n}\n\nfunction edgeIdentity(\n edge: RelationshipEdge,\n registry: RelationshipKindRegistry,\n): string {\n const definition = registry.require(edge.kind);\n const endpoints =\n definition.direction === \"undirected\"\n ? [edge.source, edge.target].sort().join(\"\\u0000\")\n : `${edge.source}\\u0000${edge.target}`;\n return `${definition.kind}\\u0000${endpoints}`;\n}\n\nfunction freezeEdge(edge: RelationshipEdge): RelationshipEdge {\n return Object.freeze({\n ...edge,\n ...(edge.payload === undefined\n ? {}\n : { payload: Object.freeze(structuredClone(edge.payload)) }),\n });\n}\n\nfunction assertCardinality(\n candidate: RelationshipEdge,\n excludeRelationshipId: string,\n registry: RelationshipKindRegistry,\n indexes: RelationshipCardinalityIndexes,\n): void {\n const definition = registry.require(candidate.kind);\n const outgoingOwner = indexes.outgoingOne.get(\n `${definition.kind}\\u0000${candidate.source}`,\n );\n if (outgoingOwner !== undefined && outgoingOwner !== excludeRelationshipId)\n throw new TypeError(\n `Relationship outgoing cardinality exceeded for ${definition.kind}`,\n );\n const incomingOwner = indexes.incomingOne.get(\n `${definition.kind}\\u0000${candidate.target}`,\n );\n if (incomingOwner !== undefined && incomingOwner !== excludeRelationshipId)\n throw new TypeError(\n `Relationship incoming cardinality exceeded for ${definition.kind}`,\n );\n const identity = edgeIdentity(candidate, registry);\n const identityOwner = indexes.identities.get(identity);\n if (identityOwner !== undefined && identityOwner !== excludeRelationshipId)\n throw new TypeError(`Relationship edge already active: ${identity}`);\n}\n\nfunction replayEvents(\n events: readonly RelationshipEvent[],\n): Map<string, RelationshipEdge> {\n const active = new Map<string, RelationshipEdge>();\n for (const event of events) {\n if (event.action === \"remove\") active.delete(event.relationshipId);\n else active.set(event.relationshipId, event.edge!);\n }\n return active;\n}\n\nfunction normalizeEventHeader(\n input: RelationshipEventInput,\n currentVersion: number,\n eventIds: ReadonlySet<string>,\n): {\n eventId: string;\n relationshipId: string;\n author: string;\n timestamp: string;\n} {\n if (\n input.expectedVersion !== undefined &&\n input.expectedVersion !== currentVersion\n )\n throw new TypeError(\n `Relationship event version conflict: expected ${input.expectedVersion}, current ${currentVersion}`,\n );\n const eventId = requiredText(input.eventId, \"eventId\");\n if (eventIds.has(eventId))\n throw new TypeError(`Relationship event already exists: ${eventId}`);\n if (\n input.action !== \"add\" &&\n input.action !== \"remove\" &&\n input.action !== \"supersede\"\n )\n throw new TypeError(`Unknown relationship event action: ${input.action}`);\n if (!Number.isFinite(Date.parse(input.timestamp)))\n throw new TypeError(\"Relationship event timestamp must be valid\");\n return {\n eventId,\n relationshipId: requiredText(input.relationshipId, \"relationshipId\"),\n author: requiredText(input.author, \"author\"),\n timestamp: new Date(input.timestamp).toISOString(),\n };\n}\n\nfunction resolveMutationEdge(\n input: RelationshipEventInput,\n relationshipId: string,\n active: ReadonlyMap<string, RelationshipEdge>,\n nodes: ReadonlySet<string>,\n registry: RelationshipKindRegistry,\n indexes: RelationshipCardinalityIndexes,\n): RelationshipEdge | undefined {\n const isActive = active.has(relationshipId);\n if (input.action === \"add\" && isActive)\n throw new TypeError(`Relationship is already active: ${relationshipId}`);\n if (input.action !== \"add\" && !isActive)\n throw new TypeError(`Relationship is not active: ${relationshipId}`);\n if (input.action === \"remove\") return undefined;\n if (!input.edge)\n throw new TypeError(`Relationship ${input.action} event requires an edge`);\n const source =\n typeof input.edge.source === \"string\" ? input.edge.source.trim() : \"\";\n const target =\n typeof input.edge.target === \"string\" ? input.edge.target.trim() : \"\";\n if (!nodes.has(source) || !nodes.has(target))\n throw new TypeError(\n `Relationship endpoint not found: ${source} -> ${target}`,\n );\n const canonical = new RelationshipGraph(\n [source, target],\n [input.edge],\n registry,\n ).edges()[0]!;\n assertCardinality(canonical, relationshipId, registry, indexes);\n return freezeEdge(canonical);\n}\n\n/**\n * Append-only in-memory reference ledger. Durable adapters can persist the\n * returned immutable events while reusing the same replay and validation model.\n */\nexport class RelationshipEventLog {\n readonly #nodes: ReadonlySet<string>;\n readonly #registry: RelationshipKindRegistry;\n readonly #events: RelationshipEvent[] = [];\n readonly #eventIds = new Set<string>();\n readonly #active = new Map<string, RelationshipEdge>();\n readonly #cardinalityIndexes: RelationshipCardinalityIndexes = {\n identities: new Map(),\n outgoingOne: new Map(),\n incomingOne: new Map(),\n };\n\n /** Create an empty relationship ledger for a fixed node universe. */\n public constructor(\n nodes: Iterable<string>,\n options: RelationshipEventLogOptions = {},\n ) {\n this.#nodes = new Set(\n [...nodes]\n .filter((node): node is string => typeof node === \"string\")\n .map((node) => node.trim())\n .filter(Boolean),\n );\n this.#registry = options.registry ?? createRelationshipKindRegistry();\n }\n\n /** Current append sequence. */\n public get version(): number {\n return this.#events.length;\n }\n\n /** Return an immutable copy of the full event stream. */\n public events(): readonly RelationshipEvent[] {\n return Object.freeze([...this.#events]);\n }\n\n /** Add one active relationship to constant-time validation indexes. */\n #indexActive(relationshipId: string, edge: RelationshipEdge): void {\n const definition = this.#registry.require(edge.kind);\n this.#cardinalityIndexes.identities.set(\n edgeIdentity(edge, this.#registry),\n relationshipId,\n );\n if (definition.outgoing === \"one\")\n this.#cardinalityIndexes.outgoingOne.set(\n `${definition.kind}\\u0000${edge.source}`,\n relationshipId,\n );\n if (definition.incoming === \"one\")\n this.#cardinalityIndexes.incomingOne.set(\n `${definition.kind}\\u0000${edge.target}`,\n relationshipId,\n );\n }\n\n /** Remove one superseded or deleted relationship from validation indexes. */\n #unindexActive(edge: RelationshipEdge): void {\n const definition = this.#registry.require(edge.kind);\n this.#cardinalityIndexes.identities.delete(\n edgeIdentity(edge, this.#registry),\n );\n if (definition.outgoing === \"one\")\n this.#cardinalityIndexes.outgoingOne.delete(\n `${definition.kind}\\u0000${edge.source}`,\n );\n if (definition.incoming === \"one\")\n this.#cardinalityIndexes.incomingOne.delete(\n `${definition.kind}\\u0000${edge.target}`,\n );\n }\n\n /** Validate and append one attributable relationship mutation. */\n public append(input: RelationshipEventInput): RelationshipEvent {\n const header = normalizeEventHeader(input, this.version, this.#eventIds);\n const previous = this.#active.get(header.relationshipId);\n const edge = resolveMutationEdge(\n input,\n header.relationshipId,\n this.#active,\n this.#nodes,\n this.#registry,\n this.#cardinalityIndexes,\n );\n\n const event = Object.freeze({\n eventId: header.eventId,\n relationshipId: header.relationshipId,\n action: input.action,\n ...(edge === undefined ? {} : { edge }),\n author: header.author,\n timestamp: header.timestamp,\n ...(input.reason?.trim() ? { reason: input.reason.trim() } : {}),\n sequence: this.version + 1,\n }) satisfies RelationshipEvent;\n this.#events.push(event);\n this.#eventIds.add(header.eventId);\n if (previous) this.#unindexActive(previous);\n if (input.action === \"remove\") this.#active.delete(header.relationshipId);\n else {\n this.#active.set(header.relationshipId, edge!);\n this.#indexActive(header.relationshipId, edge!);\n }\n return event;\n }\n\n /** Materialize an exact point-in-time graph without mutating the ledger. */\n public snapshot(\n options: {\n atVersion?: number;\n atTimestamp?: string;\n } = {},\n ): RelationshipSnapshot {\n if (options.atVersion !== undefined && options.atTimestamp !== undefined)\n throw new TypeError(\"Relationship snapshot accepts one target\");\n let included: RelationshipEvent[];\n if (options.atTimestamp !== undefined) {\n const timestamp = Date.parse(options.atTimestamp);\n if (!Number.isFinite(timestamp))\n throw new TypeError(\"Relationship snapshot timestamp must be valid\");\n let lastIndex = -1;\n for (let index = this.#events.length - 1; index >= 0; index -= 1) {\n if (Date.parse(this.#events[index]!.timestamp) > timestamp) continue;\n lastIndex = index;\n break;\n }\n included = lastIndex === -1 ? [] : this.#events.slice(0, lastIndex + 1);\n } else {\n const version = options.atVersion ?? this.version;\n if (!Number.isInteger(version) || version < 0 || version > this.version)\n throw new TypeError(\n `Relationship snapshot version out of range: ${version}`,\n );\n included = this.#events.slice(0, version);\n }\n const active = replayEvents(included);\n const graph = new RelationshipGraph(\n this.#nodes,\n active.values(),\n this.#registry,\n );\n return Object.freeze({\n version: included.length,\n ...(included.at(-1) ? { asOf: included.at(-1)!.timestamp } : {}),\n edges: graph.edges(),\n graph,\n });\n }\n\n /** Page the immutable event stream with a cursor bound to this log version. */\n public page(options: {\n limit: number;\n cursor?: string;\n }): RelationshipEventPage {\n if (!Number.isInteger(options.limit) || options.limit < 1)\n throw new TypeError(\"Relationship event page limit must be positive\");\n const fingerprint = createQueryFingerprint(\"relationship-events\", {\n order: \"append-sequence\",\n });\n const snapshot =\n options.cursor === undefined\n ? this.version\n : Number(decodeQueryCursorState(options.cursor, fingerprint).snapshot);\n if (\n !Number.isSafeInteger(snapshot) ||\n snapshot < 0 ||\n snapshot > this.version\n )\n throw new TypeError(\n \"Relationship event cursor snapshot version is invalid\",\n );\n const page = paginateQueryRows(this.#events.slice(0, snapshot), {\n cursor: options.cursor,\n fingerprint,\n limit: options.limit,\n readId: (event) => event.eventId,\n snapshot: String(snapshot),\n });\n return {\n version: snapshot,\n events: page.rows,\n hasMore: page.has_more,\n ...(page.next_cursor ? { nextCursor: page.next_cursor } : {}),\n };\n }\n}\n\nconst RELATIONSHIP_STORE_LOCK_ID = \"relationship-event-store\";\nconst RELATIONSHIP_NOFOLLOW_FLAG = constants.O_NOFOLLOW;\n\nfunction acquireRelationshipStoreLock(\n pmRoot: string,\n): Promise<() => Promise<void>> {\n return acquireLock(\n pmRoot,\n RELATIONSHIP_STORE_LOCK_ID,\n 30,\n `relationship-store:${process.pid}`,\n false,\n false,\n 3_000,\n );\n}\n\nasync function resolveRelationshipEventStorePath(\n pmRoot: string,\n relativePath = \"relationships/events.jsonl\",\n): Promise<string> {\n const root = path.resolve(pmRoot);\n const target = path.resolve(root, relativePath);\n const relative = path.relative(root, target);\n if (relative.length === 0)\n throw new TypeError(\n \"Relationship event path must name a file within the tracker root\",\n );\n if (\n relative === \"..\" ||\n relative.startsWith(`..${path.sep}`) ||\n path.isAbsolute(relative)\n )\n throw new TypeError(\n \"Relationship event path must stay within the tracker root\",\n );\n await mkdir(root, { recursive: true });\n const rootStats = await lstat(root);\n if (rootStats.isSymbolicLink())\n throw new TypeError(\n \"Relationship event tracker root must not be a symbolic link\",\n );\n let current = root;\n for (const segment of relative.split(path.sep)) {\n current = path.join(current, segment);\n try {\n if ((await lstat(current)).isSymbolicLink())\n throw new TypeError(\n \"Relationship event path must not contain symbolic links\",\n );\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") break;\n throw error;\n }\n }\n return target;\n}\n\nasync function loadRelationshipEventLog(\n target: string,\n nodes: readonly string[],\n registry: RelationshipKindRegistry | undefined,\n): Promise<RelationshipEventLog> {\n const log = new RelationshipEventLog(nodes, { registry });\n let raw: string;\n let handle: FileHandle | undefined;\n try {\n handle = await open(\n target,\n constants.O_RDONLY | RELATIONSHIP_NOFOLLOW_FLAG,\n );\n raw = await handle.readFile(\"utf8\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return log;\n throw error;\n } finally {\n await handle?.close();\n }\n const lines = raw.split(\"\\n\");\n for (let index = 0; index < lines.length; index += 1) {\n const line = lines[index]!.trim();\n if (!line) continue;\n let stored: RelationshipEvent;\n try {\n stored = JSON.parse(line) as RelationshipEvent;\n } catch {\n throw new TypeError(\n `Invalid relationship event JSONL at line ${index + 1}`,\n );\n }\n if (stored.sequence !== log.version + 1)\n throw new TypeError(\n `Invalid relationship event sequence at line ${index + 1}`,\n );\n log.append({\n eventId: stored.eventId,\n relationshipId: stored.relationshipId,\n action: stored.action,\n ...(stored.edge === undefined ? {} : { edge: stored.edge }),\n author: stored.author,\n timestamp: stored.timestamp,\n ...(stored.reason === undefined ? {} : { reason: stored.reason }),\n expectedVersion: log.version,\n });\n }\n return log;\n}\n\n/**\n * Lock-serialized durable JSONL adapter for {@link RelationshipEventLog}.\n * Every append replays the current stream while holding the workspace lock, so\n * independent processes share optimistic versions without lost updates.\n */\nexport class RelationshipEventStore {\n readonly #pmRoot: string;\n readonly #nodes: readonly string[];\n readonly #registry: RelationshipKindRegistry | undefined;\n readonly #path: string;\n #log: RelationshipEventLog;\n\n private constructor(\n options: RelationshipEventStoreOptions,\n nodes: readonly string[],\n target: string,\n log: RelationshipEventLog,\n ) {\n this.#pmRoot = options.pmRoot;\n this.#nodes = nodes;\n this.#registry = options.registry;\n this.#path = target;\n this.#log = log;\n }\n\n /** Open and validate an existing stream or create an empty store view. */\n public static async open(\n options: RelationshipEventStoreOptions,\n ): Promise<RelationshipEventStore> {\n const nodes = Object.freeze([...options.nodes]);\n const target = await resolveRelationshipEventStorePath(\n options.pmRoot,\n options.relativePath,\n );\n const release = await acquireRelationshipStoreLock(options.pmRoot);\n try {\n await resolveRelationshipEventStorePath(options.pmRoot, target);\n const log = await loadRelationshipEventLog(\n target,\n nodes,\n options.registry,\n );\n return new RelationshipEventStore(options, nodes, target, log);\n } finally {\n await release();\n }\n }\n\n /** Absolute JSONL path, exposed for diagnostics and backup tooling. */\n public get path(): string {\n return this.#path;\n }\n\n /** Refresh from durable history and return the current validated append sequence. */\n public async currentVersion(): Promise<number> {\n this.#log = await this.#refreshFromDurableHistory();\n return this.#log.version;\n }\n\n /** Append one event after refreshing under the shared workspace lock. */\n public async append(\n input: RelationshipEventInput,\n ): Promise<RelationshipEvent> {\n const release = await acquireRelationshipStoreLock(this.#pmRoot);\n try {\n const target = await resolveRelationshipEventStorePath(\n this.#pmRoot,\n this.#path,\n );\n const refreshed = await loadRelationshipEventLog(\n target,\n this.#nodes,\n this.#registry,\n );\n const event = refreshed.append(input);\n await mkdir(path.dirname(target), { recursive: true });\n await resolveRelationshipEventStorePath(this.#pmRoot, target);\n const handle = await open(\n target,\n constants.O_APPEND |\n constants.O_CREAT |\n constants.O_WRONLY |\n RELATIONSHIP_NOFOLLOW_FLAG,\n );\n try {\n await handle.appendFile(`${JSON.stringify(event)}\\n`, \"utf8\");\n } finally {\n await handle.close();\n }\n this.#log = refreshed;\n return event;\n } finally {\n await release();\n }\n }\n\n /** Refresh from durable history and materialize an exact validated snapshot. */\n public async snapshot(\n options: Parameters<RelationshipEventLog[\"snapshot\"]>[0] = {},\n ): Promise<RelationshipSnapshot> {\n this.#log = await this.#refreshFromDurableHistory();\n return this.#log.snapshot(options);\n }\n\n /** Refresh from durable history and page immutable events. */\n public async page(\n options: Parameters<RelationshipEventLog[\"page\"]>[0],\n ): Promise<RelationshipEventPage> {\n this.#log = await this.#refreshFromDurableHistory();\n return this.#log.page(options);\n }\n\n /** Serialize a durable refresh with writers so readers never observe a torn JSONL tail. */\n async #refreshFromDurableHistory(): Promise<RelationshipEventLog> {\n const release = await acquireRelationshipStoreLock(this.#pmRoot);\n try {\n const target = await resolveRelationshipEventStorePath(\n this.#pmRoot,\n this.#path,\n );\n return await loadRelationshipEventLog(\n target,\n this.#nodes,\n this.#registry,\n );\n } finally {\n await release();\n }\n }\n}\n"],"names":[],"mappings":"AAAA;;;;;GAKG;;;AACH,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAmB,MAAM,kBAAkB,CAAC;AACvE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EACL,iBAAiB,EAEjB,8BAA8B,GAE/B,MAAM,oBAAoB,CAAC;AAgF5B,SAAS,YAAY,CAAC,KAAc,EAAE,KAAa;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QACxD,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AE,CAAC;QAClB,CAAC;IACH,CAAC;IAED,gFAAgF;IACzE,KAAK,CAAC,QAAQ,CACnB,UAA2D,EAAE;QAE7D,IAAI,CAAC,IAAI,GAAG,MAAM,IAAI,CAAC,0BAA0B,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,8DAA8D;IACvD,KAAK,CAAC,IAAI,CACf,OAAoD;QAEpD,IAAI,CAAC,IAAI,GAAG,MAAM,IAAI,CAAC,0BAA0B,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,2FAA2F;IAC3F,KAAK,CAAC,0BAA0B;QAC9B,MAAM,OAAO,GAAG,MAAM,4BAA4B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjE,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,iCAAiC,CACpD,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,KAAK,CACX,CAAC;YACF,OAAO,MAAM,wBAAwB,CACnC,MAAM,EACN,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,SAAS,CACf,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,MAAM,OAAO,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;CACF","debugId":"787e8f44-80d5-554f-9232-9675cf6a8637"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/relationships
|
|
3
|
+
*
|
|
4
|
+
* Provides the dependency-free relationship ontology and bounded graph-query
|
|
5
|
+
* kernel shared by the SDK, CLI, MCP adapters, extensions, and non-PM apps.
|
|
6
|
+
*/
|
|
7
|
+
import type { Dependency, ItemMetadata } from "../types/index.js";
|
|
8
|
+
/** Direction exposed by a relationship kind. */
|
|
9
|
+
export type RelationshipDirection = "directed" | "undirected";
|
|
10
|
+
/** Cardinality constraint applied independently to outgoing and incoming edges. */
|
|
11
|
+
export type RelationshipCardinality = "one" | "many";
|
|
12
|
+
/** Lifecycle policy for a relationship kind. */
|
|
13
|
+
export type RelationshipLifecycle = "persistent" | "supersedable" | "ephemeral";
|
|
14
|
+
/** Direction in which an ordering edge contributes to execution precedence. */
|
|
15
|
+
export type RelationshipPrecedence = "source_before_target" | "target_before_source";
|
|
16
|
+
/** Endpoint that represents the structural parent for hierarchy kinds. */
|
|
17
|
+
export type RelationshipHierarchyDirection = "source_parent" | "target_parent";
|
|
18
|
+
/** Versioned semantic definition for a built-in or application-defined edge kind. */
|
|
19
|
+
export interface RelationshipKindDefinition {
|
|
20
|
+
/** Canonical, case-insensitive kind identifier. */
|
|
21
|
+
kind: string;
|
|
22
|
+
/** Whether traversing source to target has distinct meaning from the reverse. */
|
|
23
|
+
direction: RelationshipDirection;
|
|
24
|
+
/** Optional canonical kind used when traversing a directed edge in reverse. */
|
|
25
|
+
inverse?: string;
|
|
26
|
+
/** Whether the kind participates in execution-order cycle checks. */
|
|
27
|
+
ordering: boolean;
|
|
28
|
+
/** Execution direction for ordering kinds; defaults to source before target. */
|
|
29
|
+
precedence?: RelationshipPrecedence;
|
|
30
|
+
/** Whether the kind contributes to structural ancestry. */
|
|
31
|
+
hierarchy: boolean;
|
|
32
|
+
/** Endpoint that represents the parent; defaults to source for custom kinds. */
|
|
33
|
+
hierarchyDirection?: RelationshipHierarchyDirection;
|
|
34
|
+
/** Maximum logical outgoing edges of this kind from one node. */
|
|
35
|
+
outgoing: RelationshipCardinality;
|
|
36
|
+
/** Maximum logical incoming edges of this kind to one node. */
|
|
37
|
+
incoming: RelationshipCardinality;
|
|
38
|
+
/** Edge replacement and retention behavior. */
|
|
39
|
+
lifecycle: RelationshipLifecycle;
|
|
40
|
+
/** JSON Schema for optional application-owned payloads. */
|
|
41
|
+
payloadSchema?: Readonly<Record<string, unknown>>;
|
|
42
|
+
/** Legacy spellings normalized to this definition. */
|
|
43
|
+
aliases?: readonly string[];
|
|
44
|
+
/** Compatibility version of this semantic contract. */
|
|
45
|
+
compatibilityVersion: number;
|
|
46
|
+
/** Whether source and target may be the same node. */
|
|
47
|
+
allowSelf: boolean;
|
|
48
|
+
}
|
|
49
|
+
/** One normalized relationship edge indexed by the graph kernel. */
|
|
50
|
+
export interface RelationshipEdge {
|
|
51
|
+
/** Source node identifier. */
|
|
52
|
+
source: string;
|
|
53
|
+
/** Target node identifier. */
|
|
54
|
+
target: string;
|
|
55
|
+
/** Canonical relationship kind. */
|
|
56
|
+
kind: string;
|
|
57
|
+
/** Optional creation timestamp retained from storage. */
|
|
58
|
+
createdAt?: string;
|
|
59
|
+
/** Optional author retained from storage. */
|
|
60
|
+
author?: string;
|
|
61
|
+
/** Optional application-owned edge payload. */
|
|
62
|
+
payload?: Readonly<Record<string, unknown>>;
|
|
63
|
+
}
|
|
64
|
+
/** Direction used by adjacency, closure, and path traversal. */
|
|
65
|
+
export type RelationshipTraversalDirection = "outgoing" | "incoming" | "both";
|
|
66
|
+
/** Shared bounded-query controls. */
|
|
67
|
+
export interface RelationshipQueryOptions {
|
|
68
|
+
/** Edge kinds to traverse after alias normalization. */
|
|
69
|
+
kinds?: readonly string[];
|
|
70
|
+
/** Traversal direction relative to each visited node. */
|
|
71
|
+
direction?: RelationshipTraversalDirection;
|
|
72
|
+
/** Maximum number of returned nodes, excluding the starting node. */
|
|
73
|
+
limit?: number;
|
|
74
|
+
/** Maximum traversal depth. */
|
|
75
|
+
maxDepth?: number;
|
|
76
|
+
/** Abort signal checked throughout traversal. */
|
|
77
|
+
signal?: AbortSignal;
|
|
78
|
+
}
|
|
79
|
+
/** Cost and truncation metadata returned by every graph query. */
|
|
80
|
+
export interface RelationshipQueryMeta {
|
|
81
|
+
/** Number of nodes removed from the traversal frontier. */
|
|
82
|
+
visitedNodes: number;
|
|
83
|
+
/** Number of candidate edges inspected. */
|
|
84
|
+
inspectedEdges: number;
|
|
85
|
+
/** Whether a configured bound stopped traversal. */
|
|
86
|
+
truncated: boolean;
|
|
87
|
+
/** Deterministic continuation cursor for the final returned node. */
|
|
88
|
+
nextCursor?: string;
|
|
89
|
+
}
|
|
90
|
+
/** Generic bounded graph query result. */
|
|
91
|
+
export interface RelationshipQueryResult<T> {
|
|
92
|
+
/** Deterministically ordered query value. */
|
|
93
|
+
value: T;
|
|
94
|
+
/** Explicit query work and truncation metadata. */
|
|
95
|
+
meta: RelationshipQueryMeta;
|
|
96
|
+
}
|
|
97
|
+
/** Induced subgraph returned by bounded traversal. */
|
|
98
|
+
export interface RelationshipSubgraph {
|
|
99
|
+
/** Deterministically ordered node identifiers. */
|
|
100
|
+
nodes: string[];
|
|
101
|
+
/** Deterministically ordered edges whose endpoints are both present. */
|
|
102
|
+
edges: RelationshipEdge[];
|
|
103
|
+
}
|
|
104
|
+
/** Mutable registry with immutable snapshots and collision-safe extension registration. */
|
|
105
|
+
export declare class RelationshipKindRegistry {
|
|
106
|
+
#private;
|
|
107
|
+
/** Create a registry initialized with the stable built-in ontology by default. */
|
|
108
|
+
constructor(definitions?: readonly RelationshipKindDefinition[]);
|
|
109
|
+
/** Register one definition after validating its identifier, version, and aliases. */
|
|
110
|
+
register(definition: RelationshipKindDefinition): this;
|
|
111
|
+
/** Resolve a canonical kind or compatibility alias. */
|
|
112
|
+
resolve(kind: unknown): RelationshipKindDefinition | undefined;
|
|
113
|
+
/** Resolve a kind or throw a precise error suitable for command adapters. */
|
|
114
|
+
require(kind: string): RelationshipKindDefinition;
|
|
115
|
+
/** Return a deterministic immutable registry snapshot. */
|
|
116
|
+
list(): readonly RelationshipKindDefinition[];
|
|
117
|
+
}
|
|
118
|
+
/** Create a registry containing the built-in relationship ontology. */
|
|
119
|
+
export declare function createRelationshipKindRegistry(): RelationshipKindRegistry;
|
|
120
|
+
/** Report whether a kind participates in execution-order cycle detection. */
|
|
121
|
+
export declare function isOrderingRelationshipKind(kind: string, registry?: RelationshipKindRegistry): boolean;
|
|
122
|
+
/** Build an immutable, deterministic in-memory relationship index. */
|
|
123
|
+
export declare class RelationshipGraph {
|
|
124
|
+
#private;
|
|
125
|
+
/** Validate and index nodes and edges without reading tracker storage. */
|
|
126
|
+
constructor(nodes: Iterable<string>, edges: Iterable<RelationshipEdge>, registry?: RelationshipKindRegistry);
|
|
127
|
+
/** Build the graph directly from item metadata, including hierarchy and legacy blocker fields. */
|
|
128
|
+
static fromItems(items: readonly Pick<ItemMetadata, "id" | "parent" | "blocked_by" | "dependencies">[], registry?: RelationshipKindRegistry): RelationshipGraph;
|
|
129
|
+
/** Return the deterministic immutable edge snapshot. */
|
|
130
|
+
edges(): readonly RelationshipEdge[];
|
|
131
|
+
/** Return the deterministic immutable edges incident to one node. */
|
|
132
|
+
incidentEdges(id: string): readonly RelationshipEdge[];
|
|
133
|
+
/** Return the deterministic immutable node snapshot. */
|
|
134
|
+
nodes(): readonly string[];
|
|
135
|
+
/** Return one-hop adjacent node identifiers. */
|
|
136
|
+
adjacency(id: string, options?: RelationshipQueryOptions): RelationshipQueryResult<string[]>;
|
|
137
|
+
/** Return bounded transitive closure in breadth-first discovery order. */
|
|
138
|
+
closure(id: string, options?: RelationshipQueryOptions): RelationshipQueryResult<string[]>;
|
|
139
|
+
/** Return a deterministic shortest path, or an empty array when disconnected. */
|
|
140
|
+
shortestPath(source: string, target: string, options?: RelationshipQueryOptions): RelationshipQueryResult<string[]>;
|
|
141
|
+
/** Return the induced subgraph over a bounded closure including the root. */
|
|
142
|
+
subgraph(id: string, options?: RelationshipQueryOptions): RelationshipQueryResult<RelationshipSubgraph>;
|
|
143
|
+
}
|
|
144
|
+
/** Convert one stored dependency into the public relationship edge contract. */
|
|
145
|
+
export declare function dependencyToRelationship(source: string, dependency: Dependency, registry?: RelationshipKindRegistry): RelationshipEdge;
|