@unbrained/pm-cli 2026.7.21 → 2026.7.22
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 +25 -0
- package/dist/cli/bundle-integrity.js +3 -3
- package/dist/cli/bundle-integrity.js.map +1 -1
- package/dist/cli/commands/contracts.d.ts +5 -0
- package/dist/cli/commands/contracts.js +8 -6
- package/dist/cli/commands/contracts.js.map +1 -1
- package/dist/cli/commands/copy.js +36 -20
- package/dist/cli/commands/copy.js.map +1 -1
- package/dist/cli/commands/create.js +48 -24
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/commands/merge.d.ts +1 -1
- package/dist/cli/commands/merge.js +3 -3
- package/dist/cli/commands/merge.js.map +1 -1
- package/dist/cli/commands/restore.js +40 -22
- package/dist/cli/commands/restore.js.map +1 -1
- package/dist/cli/commands/update.js +12 -9
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/extension-command-help.js +3 -4
- package/dist/cli/extension-command-help.js.map +1 -1
- package/dist/cli/main.d.ts +3 -2
- package/dist/cli/main.js +6 -6
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/register-list-query.js +33 -21
- package/dist/cli/register-list-query.js.map +1 -1
- package/dist/cli/register-mutation.js +63 -37
- package/dist/cli/register-mutation.js.map +1 -1
- package/dist/cli/registration-helpers.d.ts +2 -0
- package/dist/cli/registration-helpers.js +3 -2
- package/dist/cli/registration-helpers.js.map +1 -1
- package/dist/cli-bundle/bundle-manifest.json +349 -341
- package/dist/cli-bundle/chunks/{append-7OVFYR3C.js → append-CYMA7RJT.js} +5 -5
- package/dist/cli-bundle/chunks/append-H53CAPMP.js +11 -0
- package/dist/cli-bundle/chunks/{chunk-PFNHX655.js → chunk-2P7OK4WG.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-EJDGV4GR.js → chunk-3EBGHNNQ.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-DZRV2OPA.js → chunk-3EDFN3VV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZOY5K4D3.js → chunk-3PWJWLLQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VXOOB6YX.js → chunk-3SJAR3CY.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-GTLCVJOE.js → chunk-3WVKMF2A.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-LAV26CQG.js → chunk-42SYYKA4.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-NLR32VFS.js → chunk-4IXLNV7W.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BKIAH72N.js → chunk-4LTPHDKA.js} +39 -23
- package/dist/cli-bundle/chunks/chunk-4LTPHDKA.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-ABWCF646.js → chunk-4YTQVO3V.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-E5XMKOSB.js → chunk-5EBRMHI6.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-IY6VZ3IW.js → chunk-5FAG2JUC.js} +320 -62
- package/dist/cli-bundle/chunks/chunk-5FAG2JUC.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-GKX4NJ7U.js → chunk-5K5LHZZX.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-T6PPNM7V.js → chunk-5K7BOAB6.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-4QOB7L7I.js → chunk-5MUZ54G2.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-SF3DT5HJ.js → chunk-5QME4KX2.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-RMF7LMBS.js → chunk-6PDGFY3P.js} +27 -17
- package/dist/cli-bundle/chunks/{chunk-RMF7LMBS.js.map → chunk-6PDGFY3P.js.map} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TRSHFPRZ.js → chunk-6PM6CPPP.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-O4BCOJTZ.js → chunk-7AHRY3ZB.js} +21 -16
- package/dist/cli-bundle/chunks/chunk-7AHRY3ZB.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-OR42SO64.js → chunk-7B36A3VT.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-QWRVBJ4D.js → chunk-7OR2YKKD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FPBMLYPI.js → chunk-7QUV54XX.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-WWNL6WMH.js → chunk-7WXW6JHG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BXNDKOR2.js → chunk-A2VL5SVG.js} +4 -4
- package/dist/cli-bundle/chunks/chunk-AXGDUXJW.js +5 -0
- package/dist/cli-bundle/chunks/{chunk-IAQE32BI.js → chunk-B2AVNGG3.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-K36WV5J6.js → chunk-B7O44UBR.js} +71 -8
- package/dist/cli-bundle/chunks/chunk-B7O44UBR.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-HCEBZNC3.js → chunk-BRMPF2RM.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-Z7VWXXJM.js → chunk-BTNKMF2A.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-KH44WBAT.js → chunk-CD4643VW.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-OWXOPDHD.js → chunk-CJEEC5O4.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-PZC2FUOQ.js → chunk-CTPKCZCF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7W2UAXXT.js → chunk-D4OBQVL3.js} +10 -10
- package/dist/cli-bundle/chunks/{chunk-EWJWSNRU.js → chunk-DM4TYC2A.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-VJQG4BIM.js → chunk-DSFTAQ7T.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-AELMUANP.js → chunk-DVB6SQU7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KBLZ3AA5.js → chunk-E3ZWOFSO.js} +4 -4
- package/dist/cli-bundle/chunks/chunk-EP25DV6P.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-GTK4DTEW.js → chunk-F4VCB4WY.js} +10 -10
- package/dist/cli-bundle/chunks/{chunk-V22ZPOKN.js → chunk-F4XAQUQA.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-QOOTOD3W.js → chunk-FGR6IBAF.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-JSLT7WVE.js → chunk-FKBMT2Q6.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QIH77CAG.js → chunk-G5RLSSIX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-P7MTHPJQ.js → chunk-GEKRVH3G.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-2L6ZP22J.js → chunk-GSP6IZFU.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-ATBCUC7Y.js → chunk-H3MDK2VU.js} +48 -30
- package/dist/cli-bundle/chunks/chunk-H3MDK2VU.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-ZVZGXPQ5.js → chunk-HYZZM3Q2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XJTABV3X.js → chunk-IBWG3OSH.js} +22 -17
- package/dist/cli-bundle/chunks/chunk-IBWG3OSH.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-4XGJLADW.js → chunk-IHY5SX7O.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-UCBDQI5E.js → chunk-IMU7JLUI.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-Z75ONV25.js → chunk-IPAQAJWB.js} +77 -7
- package/dist/cli-bundle/chunks/chunk-IPAQAJWB.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-7RW4JCU2.js → chunk-IQCD6OO3.js} +25 -13
- package/dist/cli-bundle/chunks/chunk-IQCD6OO3.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-YQWCZ5AC.js → chunk-J3ZKFEDM.js} +38 -22
- package/dist/cli-bundle/chunks/chunk-J3ZKFEDM.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-PEQGTJ5Q.js → chunk-JCLXCGIL.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-GROYI4RB.js → chunk-JLTHOYR7.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-JHJSFOAM.js → chunk-JMPVHM44.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-MATHDCGG.js → chunk-JWYG36RV.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-ZTVA4KLN.js → chunk-KEGVMZNA.js} +28 -16
- package/dist/cli-bundle/chunks/chunk-KEGVMZNA.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-VLRGDBLY.js → chunk-KEHOPUHH.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-K55VMLSS.js → chunk-KJ4ZF35M.js} +63 -13
- package/dist/cli-bundle/chunks/chunk-KJ4ZF35M.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-CPX275C6.js → chunk-KPCZL2YK.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-POG76WWZ.js → chunk-L7DZV6EZ.js} +319 -61
- package/dist/cli-bundle/chunks/chunk-L7DZV6EZ.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-FO6OSVEN.js → chunk-LANV45W2.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-LVC72YRD.js → chunk-LC5ZUXWE.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-SY4SFZSD.js → chunk-LE522OXA.js} +55 -30
- package/dist/cli-bundle/chunks/chunk-LE522OXA.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-TVYYO5A7.js → chunk-MBHYQYCS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FJIFFBJX.js → chunk-MROP2RNT.js} +66 -74
- package/dist/cli-bundle/chunks/chunk-MROP2RNT.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-7656MAUL.js → chunk-MUAJHL2R.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-R3P6FZJW.js → chunk-N6QCY2AX.js} +43 -25
- package/dist/cli-bundle/chunks/chunk-N6QCY2AX.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-7WCE6Y64.js → chunk-NUQCSV4P.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-SZVB53Y3.js → chunk-O3GFE2PX.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-OY7DMU5P.js → chunk-O43LEUSD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-AMJPSANK.js → chunk-O7RH6BWP.js} +103 -44
- package/dist/cli-bundle/chunks/chunk-O7RH6BWP.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-NUF7ROFH.js → chunk-OODR5KYF.js} +26 -27
- package/dist/cli-bundle/chunks/chunk-OODR5KYF.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-LZYP423P.js → chunk-OZ25YD4Q.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-VZIZB6QH.js → chunk-PKYKQCTJ.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-UZLJOEAC.js → chunk-PMRED6QZ.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-ADBTSVGK.js → chunk-PPATPPI6.js} +65 -73
- package/dist/cli-bundle/chunks/chunk-PPATPPI6.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-K4CI6Y45.js → chunk-PWGJCP2V.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-UVN66B3M.js → chunk-Q3Z2Y5WJ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RNPZYNHS.js → chunk-Q6YZ3VCI.js} +104 -45
- package/dist/cli-bundle/chunks/chunk-Q6YZ3VCI.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-7DOJC3HS.js → chunk-QE5EUHKN.js} +28 -18
- package/dist/cli-bundle/chunks/chunk-QE5EUHKN.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-AS4SAZ5R.js → chunk-QKMMWESK.js} +25 -26
- package/dist/cli-bundle/chunks/chunk-QKMMWESK.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-R7QV7ICM.js → chunk-QSXN2FAN.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-5NTE36LD.js → chunk-RBECHH5K.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-JXCW2TI2.js → chunk-RPNC7M63.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-ICDAQ4TD.js → chunk-S2QQNTA6.js} +26 -14
- package/dist/cli-bundle/chunks/chunk-S2QQNTA6.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-JFD5LPMI.js → chunk-SP3BAXFF.js} +29 -17
- package/dist/cli-bundle/chunks/chunk-SP3BAXFF.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-F2LBF7XJ.js → chunk-SUSFH6F7.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-VHXHVTUU.js → chunk-TDOPC7UY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-HYW67VJ5.js → chunk-TLF52ZDP.js} +30 -25
- package/dist/cli-bundle/chunks/chunk-TLF52ZDP.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-FSE2IKJQ.js → chunk-TWHG646K.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OCUBRA6D.js → chunk-U7U7WGEC.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-PONKZPCJ.js → chunk-UFRVIIJ2.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-VNTCM3VW.js → chunk-VKX2VZZH.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-7AVEY74G.js → chunk-VTOCZ343.js} +29 -24
- package/dist/cli-bundle/chunks/chunk-VTOCZ343.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-6JUTHVQS.js → chunk-W2JDNTN3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PQSEQD6E.js → chunk-W35PHE44.js} +62 -12
- package/dist/cli-bundle/chunks/chunk-W35PHE44.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-4QSQ6XDK.js → chunk-WT4KXBUD.js} +68 -31
- package/dist/cli-bundle/chunks/chunk-WT4KXBUD.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-RPESLSO5.js → chunk-XC5RVKHH.js} +69 -32
- package/dist/cli-bundle/chunks/chunk-XC5RVKHH.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-QG4GFLQ6.js → chunk-XD6UF2NB.js} +42 -24
- package/dist/cli-bundle/chunks/chunk-XD6UF2NB.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-AF2CCM5U.js → chunk-XKRVX4B3.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-JGUKMMRS.js → chunk-XN4NQZJK.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-3P7UJQOX.js → chunk-YKFMLQNK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YCIUJJOD.js → chunk-YKWKMGL7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TOBGV45Y.js → chunk-YUKIFPWK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-72LQ4TKV.js → chunk-YYEZEP3E.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-X3W65QK3.js → chunk-ZEY3XSZQ.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-MWQ2HC2A.js → chunk-ZKOQHLJP.js} +59 -34
- package/dist/cli-bundle/chunks/chunk-ZKOQHLJP.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-QJIKE24M.js → chunk-ZQ3UMKWE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4PUUNQDV.js → chunk-ZVVEWHWK.js} +58 -33
- package/dist/cli-bundle/chunks/chunk-ZVVEWHWK.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-OG5DVFMA.js → chunk-ZXE6SNKO.js} +5 -5
- package/dist/cli-bundle/chunks/close-GAUIGOQC.js +12 -0
- package/dist/cli-bundle/chunks/{close-QEMOYZN3.js → close-SJIEKNY4.js} +5 -5
- package/dist/cli-bundle/chunks/{close-many-RZVTUGBG.js → close-many-B6AIC5OQ.js} +15 -14
- package/dist/cli-bundle/chunks/close-many-QCINT6I2.js +24 -0
- package/dist/cli-bundle/chunks/comments-4SK5EUEJ.js +13 -0
- package/dist/cli-bundle/chunks/{comments-TPU7QRBL.js → comments-DM5KV2RS.js} +7 -7
- package/dist/cli-bundle/chunks/copy-4KCCLTYQ.js +10 -0
- package/dist/cli-bundle/chunks/{copy-DKTSSCK7.js → copy-HEP5SZHB.js} +5 -4
- package/dist/cli-bundle/chunks/create-BDKQFPRE.js +30 -0
- package/dist/cli-bundle/chunks/{create-EIFBIVNQ.js → create-VCGBCYL2.js} +11 -10
- package/dist/cli-bundle/chunks/delete-JWDXPR3H.js +10 -0
- package/dist/cli-bundle/chunks/{delete-LCS3VPDH.js → delete-ZSPBTVJD.js} +4 -4
- package/dist/cli-bundle/chunks/{deps-YG7UF3VR.js → deps-BZTWWOIE.js} +6 -6
- package/dist/cli-bundle/chunks/{deps-UH5EQQUY.js → deps-OVAJOQIE.js} +6 -6
- package/dist/cli-bundle/chunks/{docs-G32TK6XS.js → docs-3GFMSWLL.js} +6 -6
- package/dist/cli-bundle/chunks/docs-SY2NPT6Y.js +14 -0
- package/dist/cli-bundle/chunks/{files-4ALMCSKB.js → files-2SEL4QIU.js} +6 -6
- package/dist/cli-bundle/chunks/{files-3H32UQ4K.js → files-FYMMJGNN.js} +6 -6
- package/dist/cli-bundle/chunks/focus-4A27YJ2Z.js +10 -0
- package/dist/cli-bundle/chunks/{focus-7SOUT5PZ.js → focus-TEUJKTAT.js} +5 -5
- package/dist/cli-bundle/chunks/history-compact-7QOKL2NB.js +16 -0
- package/dist/cli-bundle/chunks/{history-compact-77BT2LUB.js → history-compact-U7A37VR6.js} +6 -6
- package/dist/cli-bundle/chunks/{history-redact-LJPZPNFA.js → history-redact-TNKUO4ZE.js} +4 -4
- package/dist/cli-bundle/chunks/{history-redact-PWTTJ3XS.js → history-redact-ZWRUWQY3.js} +4 -4
- package/dist/cli-bundle/chunks/{history-repair-I7CBNCV3.js → history-repair-6IU5VWHN.js} +7 -7
- package/dist/cli-bundle/chunks/history-repair-GWCGJUM2.js +17 -0
- package/dist/cli-bundle/chunks/learnings-DDFAUUX3.js +13 -0
- package/dist/cli-bundle/chunks/{learnings-KTYW3AL7.js → learnings-GOEZXMKL.js} +7 -7
- package/dist/cli-bundle/chunks/{notes-ZERD3KB2.js → notes-BZWODAEK.js} +7 -7
- package/dist/cli-bundle/chunks/notes-OBJ6FL36.js +13 -0
- package/dist/cli-bundle/chunks/{plan-OFJUBIM5.js → plan-V57VQTAG.js} +12 -11
- package/dist/cli-bundle/chunks/plan-ZMOBD6FX.js +27 -0
- package/dist/cli-bundle/chunks/{profile-3THJPIQY.js → profile-BG3N4ETA.js} +9 -9
- package/dist/cli-bundle/chunks/{profile-XEZAMMBW.js → profile-XLM45FKV.js} +9 -9
- package/dist/cli-bundle/chunks/{register-list-query-BR435Q2H.js → register-list-query-EYYNTGMF.js} +48 -38
- package/dist/cli-bundle/chunks/register-list-query-EYYNTGMF.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-list-query-RWTWLOBE.js → register-list-query-WGXJPXXY.js} +47 -37
- package/dist/cli-bundle/chunks/register-list-query-WGXJPXXY.js.map +7 -0
- package/dist/cli-bundle/chunks/{register-mutation-HLWC2WNP.js → register-mutation-3YSDDVOL.js} +131 -105
- package/dist/cli-bundle/chunks/register-mutation-3YSDDVOL.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-mutation-ZJX5AZM5.js → register-mutation-VDGUMMUY.js} +131 -105
- package/dist/cli-bundle/chunks/register-mutation-VDGUMMUY.js.map +7 -0
- package/dist/cli-bundle/chunks/{register-operations-744YBJMV.js → register-operations-H4URGAHX.js} +36 -35
- package/dist/cli-bundle/chunks/{register-operations-744YBJMV.js.map → register-operations-H4URGAHX.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-operations-UEBJH6AN.js → register-operations-HSO7X77D.js} +34 -33
- package/dist/cli-bundle/chunks/{register-operations-UEBJH6AN.js.map → register-operations-HSO7X77D.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-setup-5DA4UZXI.js → register-setup-HZ2KKXK4.js} +13 -13
- package/dist/cli-bundle/chunks/{register-setup-6H25M3BH.js → register-setup-WCBKJ3H3.js} +13 -13
- package/dist/cli-bundle/chunks/{restore-6TDVSATY.js → restore-3NGRFDPX.js} +7 -6
- package/dist/cli-bundle/chunks/restore-LNVNUWHE.js +15 -0
- package/dist/cli-bundle/chunks/{schema-TPVTIJPO.js → schema-LMFZ742C.js} +6 -6
- package/dist/cli-bundle/chunks/{schema-HFXFSGPG.js → schema-O34O33UW.js} +6 -6
- package/dist/cli-bundle/chunks/update-BN6VZSYX.js +24 -0
- package/dist/cli-bundle/chunks/{update-LJZCL5SI.js → update-FDLPLKOB.js} +14 -13
- package/dist/cli-bundle/chunks/update-many-WCKOPN3K.js +35 -0
- package/dist/cli-bundle/chunks/update-many-WCKOPN3K.js.map +7 -0
- package/dist/cli-bundle/chunks/update-many-X6DVGOMM.js +39 -0
- package/dist/cli-bundle/chunks/update-many-X6DVGOMM.js.map +1 -0
- package/dist/cli-bundle/main.js +65 -64
- package/dist/cli-bundle/main.js.map +2 -2
- package/dist/cli-bundle/sdk-runtime.js +53 -52
- package/dist/cli-bundle/sdk-testing.js +6 -6
- package/dist/cli-bundle/sdk.js +362 -56
- package/dist/cli-bundle/sdk.js.map +4 -4
- package/dist/cli.js +10 -4
- package/dist/cli.js.map +1 -1
- package/dist/core/diagnostics/remediation.js +7 -2
- package/dist/core/diagnostics/remediation.js.map +1 -1
- package/dist/core/search/background-refresh.d.ts +3 -1
- package/dist/core/search/background-refresh.js +34 -6
- package/dist/core/search/background-refresh.js.map +1 -1
- package/dist/core/search/cache.js +28 -5
- package/dist/core/search/cache.js.map +1 -1
- package/dist/core/shared/constants.d.ts +2 -0
- package/dist/core/shared/constants.js +29 -24
- package/dist/core/shared/constants.js.map +1 -1
- package/dist/core/store/item-metadata-cache.d.ts +32 -1
- package/dist/core/store/item-metadata-cache.js +289 -21
- package/dist/core/store/item-metadata-cache.js.map +1 -1
- package/dist/core/store/item-store.js +71 -34
- package/dist/core/store/item-store.js.map +1 -1
- package/dist/core/store/settings.js +9 -3
- package/dist/core/store/settings.js.map +1 -1
- package/dist/sdk/cli-bootstrap.js +68 -76
- package/dist/sdk/cli-bootstrap.js.map +1 -1
- package/dist/sdk/compile-cache.d.ts +16 -0
- package/dist/sdk/compile-cache.js +73 -0
- package/dist/sdk/compile-cache.js.map +1 -0
- package/dist/sdk/context-relevance.d.ts +16 -1
- package/dist/sdk/context-relevance.js +20 -8
- package/dist/sdk/context-relevance.js.map +1 -1
- package/dist/sdk/context-signal-store.d.ts +77 -0
- package/dist/sdk/context-signal-store.js +201 -0
- package/dist/sdk/context-signal-store.js.map +1 -0
- package/dist/sdk/dependency-provenance.d.ts +12 -0
- package/dist/sdk/dependency-provenance.js +38 -0
- package/dist/sdk/dependency-provenance.js.map +1 -0
- package/dist/sdk/governance/storage-integrity.d.ts +1 -1
- package/dist/sdk/governance/storage-integrity.js +47 -6
- package/dist/sdk/governance/storage-integrity.js.map +1 -1
- package/dist/sdk/graph/assembly.d.ts +2 -0
- package/dist/sdk/graph/assembly.js +51 -4
- package/dist/sdk/graph/assembly.js.map +1 -1
- package/dist/sdk/graph/run.js +12 -13
- package/dist/sdk/graph/run.js.map +1 -1
- package/dist/sdk/index.d.ts +5 -0
- package/dist/sdk/index.js +7 -2
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/item-metadata-index.d.ts +11 -0
- package/dist/sdk/item-metadata-index.js +15 -0
- package/dist/sdk/item-metadata-index.js.map +1 -0
- package/dist/sdk/merge/index.d.ts +1 -0
- package/dist/sdk/merge/index.js +3 -2
- package/dist/sdk/merge/index.js.map +1 -1
- package/dist/sdk/merge/install.js +25 -9
- package/dist/sdk/merge/install.js.map +1 -1
- package/dist/sdk/merge/reconcile.d.ts +46 -0
- package/dist/sdk/merge/reconcile.js +46 -0
- package/dist/sdk/merge/reconcile.js.map +1 -0
- package/dist/sdk/query/list.d.ts +5 -4
- package/dist/sdk/query/list.js +22 -14
- package/dist/sdk/query/list.js.map +1 -1
- package/dist/sdk/relationship-history.d.ts +30 -0
- package/dist/sdk/relationship-history.js +75 -7
- package/dist/sdk/relationship-history.js.map +1 -1
- package/dist/sdk/relationship-migration.d.ts +42 -0
- package/dist/sdk/relationship-migration.js +78 -0
- package/dist/sdk/relationship-migration.js.map +1 -0
- package/dist/sdk/structured-mutations.js +4 -25
- package/dist/sdk/structured-mutations.js.map +1 -1
- package/docs/COMMANDS.md +26 -3
- package/docs/CONFIGURATION.md +1 -1
- package/docs/MERGE_SAFETY.md +14 -5
- package/docs/PERFORMANCE.md +28 -0
- package/docs/RELATIONSHIP_GRAPH.md +47 -1
- package/docs/SDK.md +78 -5
- package/marketplace.json +2 -2
- package/package.json +2 -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/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/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/dist/cli-bundle/chunks/append-DFETHAZL.js +0 -11
- package/dist/cli-bundle/chunks/chunk-4PUUNQDV.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-4QSQ6XDK.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-7AVEY74G.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-7DOJC3HS.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-7RW4JCU2.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-ADBTSVGK.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-AMJPSANK.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-AS4SAZ5R.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-ATBCUC7Y.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-BKIAH72N.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-FJIFFBJX.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-HYW67VJ5.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-ICDAQ4TD.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-IY6VZ3IW.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-JFD5LPMI.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-K36WV5J6.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-K55VMLSS.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-MWQ2HC2A.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-NUF7ROFH.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-O4BCOJTZ.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-POG76WWZ.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-PQSEQD6E.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-QG4GFLQ6.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-R3P6FZJW.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-RNPZYNHS.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-RPESLSO5.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-SY4SFZSD.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-XJTABV3X.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-YQWCZ5AC.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-Z75ONV25.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-ZTVA4KLN.js.map +0 -7
- package/dist/cli-bundle/chunks/close-O5QVZ6ET.js +0 -12
- package/dist/cli-bundle/chunks/close-many-5RZXVN4J.js +0 -23
- package/dist/cli-bundle/chunks/comments-Z4KV6FU3.js +0 -13
- package/dist/cli-bundle/chunks/copy-M7DDI6LS.js +0 -9
- package/dist/cli-bundle/chunks/create-RGSPN5GD.js +0 -29
- package/dist/cli-bundle/chunks/delete-MD7YXQLH.js +0 -10
- package/dist/cli-bundle/chunks/docs-JWWNRC27.js +0 -14
- package/dist/cli-bundle/chunks/focus-DRQ6FQH6.js +0 -10
- package/dist/cli-bundle/chunks/history-compact-VCKGTX64.js +0 -16
- package/dist/cli-bundle/chunks/history-repair-YTDZRK5E.js +0 -17
- package/dist/cli-bundle/chunks/learnings-CYNOICKR.js +0 -13
- package/dist/cli-bundle/chunks/notes-FGO63FXL.js +0 -13
- package/dist/cli-bundle/chunks/plan-SGCDDTYR.js +0 -26
- package/dist/cli-bundle/chunks/register-list-query-BR435Q2H.js.map +0 -1
- package/dist/cli-bundle/chunks/register-list-query-RWTWLOBE.js.map +0 -7
- package/dist/cli-bundle/chunks/register-mutation-HLWC2WNP.js.map +0 -1
- package/dist/cli-bundle/chunks/register-mutation-ZJX5AZM5.js.map +0 -7
- package/dist/cli-bundle/chunks/restore-RSL7C7LO.js +0 -14
- package/dist/cli-bundle/chunks/update-SIA7LH5Y.js +0 -23
- package/dist/cli-bundle/chunks/update-many-BDBZVGQL.js +0 -38
- package/dist/cli-bundle/chunks/update-many-MOY3A5B3.js +0 -34
- /package/dist/cli-bundle/chunks/{append-7OVFYR3C.js.map → append-CYMA7RJT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{append-DFETHAZL.js.map → append-H53CAPMP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-PFNHX655.js.map → chunk-2P7OK4WG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-EJDGV4GR.js.map → chunk-3EBGHNNQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-DZRV2OPA.js.map → chunk-3EDFN3VV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-ZOY5K4D3.js.map → chunk-3PWJWLLQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-VXOOB6YX.js.map → chunk-3SJAR3CY.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-GTLCVJOE.js.map → chunk-3WVKMF2A.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-LAV26CQG.js.map → chunk-42SYYKA4.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-NLR32VFS.js.map → chunk-4IXLNV7W.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-ABWCF646.js.map → chunk-4YTQVO3V.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-E5XMKOSB.js.map → chunk-5EBRMHI6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-GKX4NJ7U.js.map → chunk-5K5LHZZX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-T6PPNM7V.js.map → chunk-5K7BOAB6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-4QOB7L7I.js.map → chunk-5MUZ54G2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-SF3DT5HJ.js.map → chunk-5QME4KX2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-TRSHFPRZ.js.map → chunk-6PM6CPPP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-OR42SO64.js.map → chunk-7B36A3VT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QWRVBJ4D.js.map → chunk-7OR2YKKD.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-FPBMLYPI.js.map → chunk-7QUV54XX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-WWNL6WMH.js.map → chunk-7WXW6JHG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-BXNDKOR2.js.map → chunk-A2VL5SVG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-QEMOYZN3.js.map → chunk-AXGDUXJW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-IAQE32BI.js.map → chunk-B2AVNGG3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-HCEBZNC3.js.map → chunk-BRMPF2RM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-Z7VWXXJM.js.map → chunk-BTNKMF2A.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-KH44WBAT.js.map → chunk-CD4643VW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-OWXOPDHD.js.map → chunk-CJEEC5O4.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-PZC2FUOQ.js.map → chunk-CTPKCZCF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-7W2UAXXT.js.map → chunk-D4OBQVL3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-EWJWSNRU.js.map → chunk-DM4TYC2A.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-VJQG4BIM.js.map → chunk-DSFTAQ7T.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-AELMUANP.js.map → chunk-DVB6SQU7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-KBLZ3AA5.js.map → chunk-E3ZWOFSO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-O5QVZ6ET.js.map → chunk-EP25DV6P.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-GTK4DTEW.js.map → chunk-F4VCB4WY.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-V22ZPOKN.js.map → chunk-F4XAQUQA.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QOOTOD3W.js.map → chunk-FGR6IBAF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-JSLT7WVE.js.map → chunk-FKBMT2Q6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QIH77CAG.js.map → chunk-G5RLSSIX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-P7MTHPJQ.js.map → chunk-GEKRVH3G.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-2L6ZP22J.js.map → chunk-GSP6IZFU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-ZVZGXPQ5.js.map → chunk-HYZZM3Q2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-4XGJLADW.js.map → chunk-IHY5SX7O.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-UCBDQI5E.js.map → chunk-IMU7JLUI.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-PEQGTJ5Q.js.map → chunk-JCLXCGIL.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-GROYI4RB.js.map → chunk-JLTHOYR7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-JHJSFOAM.js.map → chunk-JMPVHM44.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-MATHDCGG.js.map → chunk-JWYG36RV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-VLRGDBLY.js.map → chunk-KEHOPUHH.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-CPX275C6.js.map → chunk-KPCZL2YK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-FO6OSVEN.js.map → chunk-LANV45W2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-LVC72YRD.js.map → chunk-LC5ZUXWE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-TVYYO5A7.js.map → chunk-MBHYQYCS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-7656MAUL.js.map → chunk-MUAJHL2R.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-7WCE6Y64.js.map → chunk-NUQCSV4P.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-SZVB53Y3.js.map → chunk-O3GFE2PX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-OY7DMU5P.js.map → chunk-O43LEUSD.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-LZYP423P.js.map → chunk-OZ25YD4Q.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-VZIZB6QH.js.map → chunk-PKYKQCTJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-UZLJOEAC.js.map → chunk-PMRED6QZ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-K4CI6Y45.js.map → chunk-PWGJCP2V.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-UVN66B3M.js.map → chunk-Q3Z2Y5WJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-R7QV7ICM.js.map → chunk-QSXN2FAN.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-5NTE36LD.js.map → chunk-RBECHH5K.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-JXCW2TI2.js.map → chunk-RPNC7M63.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-F2LBF7XJ.js.map → chunk-SUSFH6F7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-VHXHVTUU.js.map → chunk-TDOPC7UY.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-FSE2IKJQ.js.map → chunk-TWHG646K.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-OCUBRA6D.js.map → chunk-U7U7WGEC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-PONKZPCJ.js.map → chunk-UFRVIIJ2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-VNTCM3VW.js.map → chunk-VKX2VZZH.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-6JUTHVQS.js.map → chunk-W2JDNTN3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-AF2CCM5U.js.map → chunk-XKRVX4B3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-JGUKMMRS.js.map → chunk-XN4NQZJK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-3P7UJQOX.js.map → chunk-YKFMLQNK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-YCIUJJOD.js.map → chunk-YKWKMGL7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-TOBGV45Y.js.map → chunk-YUKIFPWK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-72LQ4TKV.js.map → chunk-YYEZEP3E.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-X3W65QK3.js.map → chunk-ZEY3XSZQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QJIKE24M.js.map → chunk-ZQ3UMKWE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-OG5DVFMA.js.map → chunk-ZXE6SNKO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-many-5RZXVN4J.js.map → close-GAUIGOQC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-many-RZVTUGBG.js.map → close-SJIEKNY4.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{comments-TPU7QRBL.js.map → close-many-B6AIC5OQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{comments-Z4KV6FU3.js.map → close-many-QCINT6I2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{copy-M7DDI6LS.js.map → comments-4SK5EUEJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{copy-DKTSSCK7.js.map → comments-DM5KV2RS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{create-RGSPN5GD.js.map → copy-4KCCLTYQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{create-EIFBIVNQ.js.map → copy-HEP5SZHB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{delete-MD7YXQLH.js.map → create-BDKQFPRE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{delete-LCS3VPDH.js.map → create-VCGBCYL2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{deps-YG7UF3VR.js.map → delete-JWDXPR3H.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{deps-UH5EQQUY.js.map → delete-ZSPBTVJD.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{docs-JWWNRC27.js.map → deps-BZTWWOIE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{docs-G32TK6XS.js.map → deps-OVAJOQIE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{files-3H32UQ4K.js.map → docs-3GFMSWLL.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{files-4ALMCSKB.js.map → docs-SY2NPT6Y.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{focus-DRQ6FQH6.js.map → files-2SEL4QIU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{focus-7SOUT5PZ.js.map → files-FYMMJGNN.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-compact-VCKGTX64.js.map → focus-4A27YJ2Z.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-compact-77BT2LUB.js.map → focus-TEUJKTAT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-redact-PWTTJ3XS.js.map → history-compact-7QOKL2NB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-redact-LJPZPNFA.js.map → history-compact-U7A37VR6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-repair-I7CBNCV3.js.map → history-redact-TNKUO4ZE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-repair-YTDZRK5E.js.map → history-redact-ZWRUWQY3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{learnings-KTYW3AL7.js.map → history-repair-6IU5VWHN.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{learnings-CYNOICKR.js.map → history-repair-GWCGJUM2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{notes-FGO63FXL.js.map → learnings-DDFAUUX3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{notes-ZERD3KB2.js.map → learnings-GOEZXMKL.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{plan-OFJUBIM5.js.map → notes-BZWODAEK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{plan-SGCDDTYR.js.map → notes-OBJ6FL36.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{profile-3THJPIQY.js.map → plan-V57VQTAG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{profile-XEZAMMBW.js.map → plan-ZMOBD6FX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{restore-6TDVSATY.js.map → profile-BG3N4ETA.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{restore-RSL7C7LO.js.map → profile-XLM45FKV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{register-setup-5DA4UZXI.js.map → register-setup-HZ2KKXK4.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{register-setup-6H25M3BH.js.map → register-setup-WCBKJ3H3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{schema-TPVTIJPO.js.map → restore-3NGRFDPX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{schema-HFXFSGPG.js.map → restore-LNVNUWHE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-LJZCL5SI.js.map → schema-LMFZ742C.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-SIA7LH5Y.js.map → schema-O34O33UW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-many-MOY3A5B3.js.map → update-BN6VZSYX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-many-BDBZVGQL.js.map → update-FDLPLKOB.js.map} +0 -0
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* Powers search, embeddings, and semantic retrieval behavior for Background Refresh.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
!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]="
|
|
7
|
+
!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]="1c1df3a7-d81f-53bb-9590-1c9c9d461569")}catch(e){}}();
|
|
8
8
|
import { spawn } from "node:child_process";
|
|
9
9
|
import { mkdirSync, rmSync, statSync } from "node:fs";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { pathExists, readFileIfExists, writeFileAtomic, } from "../fs/fs-utils.js";
|
|
12
12
|
import { acquireLock } from "../lock/lock.js";
|
|
13
13
|
import { resolvePmPackageRootFromModule } from "../packages/root.js";
|
|
14
|
-
import {
|
|
14
|
+
import { readSettingsWithMetadata, } from "../store/settings.js";
|
|
15
15
|
import { toErrorMessage } from "../shared/primitives.js";
|
|
16
16
|
import { resolveSettingsWithSemanticRuntimeDefaults } from "./semantic-defaults.js";
|
|
17
17
|
/** Shared lock id for any process that rewrites the local vector store. Reindex and the background mutation-refresh worker both acquire this so they never write concurrently and corrupt the store. Exported so `pm reindex` reuses the same id rather than duplicating the literal. */
|
|
@@ -21,6 +21,8 @@ const PENDING_QUEUE_GATE_REL_PATH = "search/pending-refresh.gate.lock";
|
|
|
21
21
|
const PENDING_QUEUE_GATE_STALE_MS = 30_000;
|
|
22
22
|
const SEARCH_REFRESH_INLINE_ENV = "PM_SEARCH_REFRESH_INLINE";
|
|
23
23
|
const SEARCH_REFRESH_CHILD_ENV = "PM_SEARCH_REFRESH_CHILD";
|
|
24
|
+
/** Delay before a settings-failed worker dispatches one replacement child, preventing a tight retry loop while preserving eventual queue recovery. */
|
|
25
|
+
export const SEARCH_REFRESH_RETRY_DELAY_MS = 30_000;
|
|
24
26
|
function parseBooleanTrueLike(value) {
|
|
25
27
|
if (typeof value !== "string") {
|
|
26
28
|
return false;
|
|
@@ -178,13 +180,16 @@ function dispatchRefreshChild(pmRoot) {
|
|
|
178
180
|
// Best effort — see doc comment above.
|
|
179
181
|
}
|
|
180
182
|
}
|
|
183
|
+
function scheduleDelayedRefreshRetry(pmRoot) {
|
|
184
|
+
setTimeout(() => dispatchRefreshChild(pmRoot), SEARCH_REFRESH_RETRY_DELAY_MS);
|
|
185
|
+
}
|
|
181
186
|
/** Enqueue mutated ids and dispatch a detached worker child to refresh semantic embeddings without blocking the mutation. The reindex lock the worker acquires serializes concurrent refreshes, so the spawn itself stays unconditional and cheap; a worker that loses the lock exits and its ids are drained by the holder. */
|
|
182
187
|
export async function scheduleBackgroundSemanticRefresh(pmRoot, itemIds) {
|
|
183
188
|
await enqueuePendingRefreshIds(pmRoot, itemIds);
|
|
184
189
|
dispatchRefreshChild(pmRoot);
|
|
185
190
|
}
|
|
186
191
|
/** Drain the pending queue and refresh semantic vectors under the reindex lock so the local vector store is never rewritten concurrently. If the lock is held by another worker we exit immediately — that holder drains our enqueued ids. After releasing we re-check the queue once and re-dispatch if a sibling enqueued ids during our final window, guaranteeing eventual processing. */
|
|
187
|
-
export async function runSemanticRefreshWorker(pmRoot, refresh) {
|
|
192
|
+
export async function runSemanticRefreshWorker(pmRoot, refresh, scheduleRetry = scheduleDelayedRefreshRetry) {
|
|
188
193
|
const warnings = [];
|
|
189
194
|
const processed = [];
|
|
190
195
|
if (!(await pathExists(pmRoot))) {
|
|
@@ -192,9 +197,22 @@ export async function runSemanticRefreshWorker(pmRoot, refresh) {
|
|
|
192
197
|
}
|
|
193
198
|
let settings;
|
|
194
199
|
try {
|
|
195
|
-
|
|
200
|
+
const settingsRead = await readSettingsWithMetadata(pmRoot);
|
|
201
|
+
const readFailure = settingsRead.warnings.find((warning) => warning.startsWith("settings_read_"));
|
|
202
|
+
if (readFailure) {
|
|
203
|
+
scheduleRetry(pmRoot);
|
|
204
|
+
return {
|
|
205
|
+
processed,
|
|
206
|
+
rounds: 0,
|
|
207
|
+
warnings: [
|
|
208
|
+
`search_background_refresh_settings_read_failed:${readFailure}`,
|
|
209
|
+
],
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
settings = resolveSettingsWithSemanticRuntimeDefaults(settingsRead.settings).settings;
|
|
196
213
|
}
|
|
197
214
|
catch (error) {
|
|
215
|
+
scheduleRetry(pmRoot);
|
|
198
216
|
return {
|
|
199
217
|
processed,
|
|
200
218
|
rounds: 0,
|
|
@@ -215,6 +233,7 @@ export async function runSemanticRefreshWorker(pmRoot, refresh) {
|
|
|
215
233
|
}
|
|
216
234
|
let rounds = 0;
|
|
217
235
|
let failed = false;
|
|
236
|
+
let retryPending = false;
|
|
218
237
|
try {
|
|
219
238
|
for (;;) {
|
|
220
239
|
const ids = await drainPendingRefreshIds(pmRoot);
|
|
@@ -224,8 +243,14 @@ export async function runSemanticRefreshWorker(pmRoot, refresh) {
|
|
|
224
243
|
rounds += 1;
|
|
225
244
|
try {
|
|
226
245
|
const result = await refresh(pmRoot, ids);
|
|
227
|
-
processed.push(...result.refreshed);
|
|
228
246
|
warnings.push(...result.warnings);
|
|
247
|
+
if (result.warnings.some((warning) => warning.startsWith("search_semantic_refresh_skipped:settings_read_failed:"))) {
|
|
248
|
+
await enqueuePendingRefreshIds(pmRoot, ids);
|
|
249
|
+
failed = true;
|
|
250
|
+
retryPending = true;
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
processed.push(...result.refreshed);
|
|
229
254
|
}
|
|
230
255
|
catch (error) {
|
|
231
256
|
warnings.push(`search_background_refresh_failed:${toErrorMessage(error)}`);
|
|
@@ -239,6 +264,9 @@ export async function runSemanticRefreshWorker(pmRoot, refresh) {
|
|
|
239
264
|
finally {
|
|
240
265
|
await release?.();
|
|
241
266
|
}
|
|
267
|
+
if (retryPending) {
|
|
268
|
+
scheduleRetry(pmRoot);
|
|
269
|
+
}
|
|
242
270
|
// Close the race where a sibling enqueued ids between our last empty drain and
|
|
243
271
|
// releasing the lock: re-dispatch so those ids are eventually processed. Skip
|
|
244
272
|
// this after a refresh failure — the failed ids were re-enqueued and an
|
|
@@ -255,4 +283,4 @@ export async function runSemanticRefreshWorker(pmRoot, refresh) {
|
|
|
255
283
|
};
|
|
256
284
|
}
|
|
257
285
|
//# sourceMappingURL=background-refresh.js.map
|
|
258
|
-
//# debugId=
|
|
286
|
+
//# debugId=1c1df3a7-d81f-53bb-9590-1c9c9d461569
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"background-refresh.js","sources":["core/search/background-refresh.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module core/search/background-refresh\n *\n * Powers search, embeddings, and semantic retrieval behavior for Background Refresh.\n */\nimport { spawn } from \"node:child_process\";\nimport { mkdirSync, rmSync, statSync } from \"node:fs\";\nimport path from \"node:path\";\n\nimport {\n pathExists,\n readFileIfExists,\n writeFileAtomic,\n} from \"../fs/fs-utils.js\";\nimport { acquireLock } from \"../lock/lock.js\";\nimport { resolvePmPackageRootFromModule } from \"../packages/root.js\";\nimport { readSettings } from \"../store/settings.js\";\nimport { toErrorMessage } from \"../shared/primitives.js\";\nimport { resolveSettingsWithSemanticRuntimeDefaults } from \"./semantic-defaults.js\";\n\n/** Shared lock id for any process that rewrites the local vector store. Reindex and the background mutation-refresh worker both acquire this so they never write concurrently and corrupt the store. Exported so `pm reindex` reuses the same id rather than duplicating the literal. */\nexport const REINDEX_LOCK_ID = \"reindex\";\n\nconst PENDING_QUEUE_REL_PATH = \"search/pending-refresh.json\";\nconst PENDING_QUEUE_GATE_REL_PATH = \"search/pending-refresh.gate.lock\";\nconst PENDING_QUEUE_GATE_STALE_MS = 30_000;\n\nconst SEARCH_REFRESH_INLINE_ENV = \"PM_SEARCH_REFRESH_INLINE\";\nconst SEARCH_REFRESH_CHILD_ENV = \"PM_SEARCH_REFRESH_CHILD\";\n\nfunction parseBooleanTrueLike(value: string | undefined): boolean {\n if (typeof value !== \"string\") {\n return false;\n }\n const normalized = value.trim().toLowerCase();\n return (\n normalized === \"1\" ||\n normalized === \"true\" ||\n normalized === \"yes\" ||\n normalized === \"on\"\n );\n}\n\n/** Mutation search refresh runs inline (blocking) under test runners, inside the background worker child itself, or when explicitly requested. Otherwise the semantic refresh is dispatched to a detached child so mutations return without waiting on embeddings. Mirrors the telemetry-flush inline gate so the full test suite stays deterministic. */\nexport function shouldRunSearchRefreshInForeground(): boolean {\n if (parseBooleanTrueLike(process.env[SEARCH_REFRESH_INLINE_ENV])) {\n return true;\n }\n if (parseBooleanTrueLike(process.env[SEARCH_REFRESH_CHILD_ENV])) {\n return true;\n }\n const nodeEnv = (process.env.NODE_ENV ?? \"\").trim().toLowerCase();\n return (\n typeof process.env.VITEST === \"string\" ||\n typeof process.env.VITEST_WORKER_ID === \"string\" ||\n nodeEnv === \"test\"\n );\n}\n\nfunction pendingQueuePath(pmRoot: string): string {\n return path.join(pmRoot, PENDING_QUEUE_REL_PATH);\n}\n\nfunction pendingQueueGatePath(pmRoot: string): string {\n return path.join(pmRoot, PENDING_QUEUE_GATE_REL_PATH);\n}\n\nfunction acquireQueueGate(pmRoot: string): boolean {\n const gatePath = pendingQueueGatePath(pmRoot);\n try {\n if (Date.now() - statSync(gatePath).mtimeMs < PENDING_QUEUE_GATE_STALE_MS) {\n return false;\n }\n rmSync(gatePath, { recursive: true, force: true });\n } catch {\n // Missing gate is the common case; fall through to create it.\n }\n try {\n mkdirSync(path.dirname(gatePath), { recursive: true });\n mkdirSync(gatePath);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction releaseQueueGate(pmRoot: string): void {\n try {\n rmSync(pendingQueueGatePath(pmRoot), { recursive: true, force: true });\n } catch {\n // Best effort; a stale gate self-heals after PENDING_QUEUE_GATE_STALE_MS.\n }\n}\n\nasync function withQueueGate<T>(\n pmRoot: string,\n fn: () => Promise<T>,\n fallback: T,\n): Promise<T> {\n // Briefly serialize read-modify-write access to the pending queue across the\n // mutation process and the worker child. Acquisition is best effort; if a\n // healthy gate is held we skip rather than risk a torn queue.\n for (let attempt = 0; attempt < 50; attempt += 1) {\n if (acquireQueueGate(pmRoot)) {\n try {\n return await fn();\n } finally {\n releaseQueueGate(pmRoot);\n }\n }\n await delay(20);\n }\n return fallback;\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, ms);\n });\n}\n\nasync function readPendingQueueIds(pmRoot: string): Promise<string[]> {\n const raw = await readFileIfExists(pendingQueuePath(pmRoot));\n if (!raw || raw.trim().length === 0) {\n return [];\n }\n try {\n const parsed = JSON.parse(raw) as { ids?: unknown };\n if (!Array.isArray(parsed.ids)) {\n return [];\n }\n return parsed.ids.filter(\n (id): id is string => typeof id === \"string\" && id.length > 0,\n );\n } catch {\n return [];\n }\n}\n\nasync function writePendingQueueIds(\n pmRoot: string,\n ids: string[],\n): Promise<void> {\n await writeFileAtomic(\n pendingQueuePath(pmRoot),\n `${JSON.stringify({ ids })}\\n`,\n );\n}\n\n/** Merge mutated item ids into the persistent pending-refresh queue. */\nexport async function enqueuePendingRefreshIds(\n pmRoot: string,\n itemIds: string[],\n): Promise<void> {\n const incoming = itemIds.filter(\n (id) => typeof id === \"string\" && id.trim().length > 0,\n );\n if (incoming.length === 0) {\n return;\n }\n const mergeIncoming = async (): Promise<void> => {\n const existing = await readPendingQueueIds(pmRoot);\n const merged = [...new Set([...existing, ...incoming])].sort(\n (left, right) => left.localeCompare(right),\n );\n await writePendingQueueIds(pmRoot, merged);\n };\n const gated = await withQueueGate(\n pmRoot,\n async () => {\n await mergeIncoming();\n return true;\n },\n false,\n );\n if (!gated) {\n // The gate stayed contended past the retry budget. Never silently drop a\n // mutation's refresh work: fall back to a best-effort unguarded merge.\n // writeFileAtomic keeps the file valid; the only risk is losing a concurrent\n // writer's delta, which its own next dispatch and the vector_index_stale\n // warning both recover.\n await mergeIncoming();\n }\n}\n\n/** Atomically read and clear the pending-refresh queue, returning drained ids. */\nexport async function drainPendingRefreshIds(\n pmRoot: string,\n): Promise<string[]> {\n return withQueueGate(pmRoot, async () => {\n const ids = await readPendingQueueIds(pmRoot);\n if (ids.length > 0) {\n await writePendingQueueIds(pmRoot, []);\n }\n return ids;\n }, []);\n}\n\nfunction searchRefreshRunnerPath(): string {\n return path.join(\n resolvePmPackageRootFromModule(import.meta.url, [\"../../..\"]),\n \"dist\",\n \"cli\",\n \"search-refresh.js\",\n );\n}\n\n/** Spawn the detached refresh worker child for this pm root. Best effort: a failed dispatch must never keep the CLI alive or fail a mutation; the next mutation re-dispatches and `vector_index_stale` warns about the catch-up window in the meantime. */\nfunction dispatchRefreshChild(pmRoot: string): void {\n try {\n const child = spawn(process.execPath, [searchRefreshRunnerPath()], {\n detached: true,\n stdio: \"ignore\",\n env: {\n ...process.env,\n PM_PATH: pmRoot,\n [SEARCH_REFRESH_CHILD_ENV]: \"1\",\n },\n });\n // A detached child can emit an async 'error' event (e.g. spawn EAGAIN/ENOENT,\n // resource limits). Swallow it so it never becomes an unhandled error that\n // crashes the parent CLI; dispatch is best effort.\n child.on(\"error\", () => {});\n child.unref();\n } catch {\n // Best effort — see doc comment above.\n }\n}\n\n/** Enqueue mutated ids and dispatch a detached worker child to refresh semantic embeddings without blocking the mutation. The reindex lock the worker acquires serializes concurrent refreshes, so the spawn itself stays unconditional and cheap; a worker that loses the lock exits and its ids are drained by the holder. */\nexport async function scheduleBackgroundSemanticRefresh(\n pmRoot: string,\n itemIds: string[],\n): Promise<void> {\n await enqueuePendingRefreshIds(pmRoot, itemIds);\n dispatchRefreshChild(pmRoot);\n}\n\n/** Documents the semantic refresh worker result payload exchanged by command, SDK, and package integrations. */\nexport interface SemanticRefreshWorkerResult {\n /** Value that configures or reports processed for this contract. */\n processed: string[];\n /** Value that configures or reports rounds for this contract. */\n rounds: number;\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n}\n\ntype SemanticRefreshFn = (\n pmRoot: string,\n itemIds: string[],\n) => Promise<{ refreshed: string[]; skipped: string[]; warnings: string[] }>;\n\n/** Drain the pending queue and refresh semantic vectors under the reindex lock so the local vector store is never rewritten concurrently. If the lock is held by another worker we exit immediately — that holder drains our enqueued ids. After releasing we re-check the queue once and re-dispatch if a sibling enqueued ids during our final window, guaranteeing eventual processing. */\nexport async function runSemanticRefreshWorker(\n pmRoot: string,\n refresh: SemanticRefreshFn,\n): Promise<SemanticRefreshWorkerResult> {\n const warnings: string[] = [];\n const processed: string[] = [];\n if (!(await pathExists(pmRoot))) {\n return { processed, rounds: 0, warnings };\n }\n\n let settings: Awaited<ReturnType<typeof readSettings>>;\n try {\n settings = resolveSettingsWithSemanticRuntimeDefaults(\n await readSettings(pmRoot),\n ).settings;\n } catch (error: unknown) {\n return {\n processed,\n rounds: 0,\n warnings: [\n `search_background_refresh_settings_read_failed:${toErrorMessage(error)}`,\n ],\n };\n }\n\n let release: (() => Promise<void>) | null = null;\n try {\n release = await acquireLock(\n pmRoot,\n REINDEX_LOCK_ID,\n settings.locks.ttl_seconds,\n process.env.PM_AUTHOR ?? \"pm-search-refresh\",\n false,\n settings.governance.force_required_for_stale_lock,\n settings.locks.wait_ms,\n );\n } catch {\n // acquireLock owns the bounded wait budget; queued ids remain for the next dispatch.\n }\n if (!release) {\n return { processed, rounds: 0, warnings };\n }\n\n let rounds = 0;\n let failed = false;\n try {\n for (;;) {\n const ids = await drainPendingRefreshIds(pmRoot);\n if (ids.length === 0) {\n break;\n }\n rounds += 1;\n try {\n const result = await refresh(pmRoot, ids);\n processed.push(...result.refreshed);\n warnings.push(...result.warnings);\n } catch (error: unknown) {\n warnings.push(\n `search_background_refresh_failed:${toErrorMessage(error)}`,\n );\n // Re-enqueue so the work is retried by a later dispatch rather than lost.\n await enqueuePendingRefreshIds(pmRoot, ids);\n failed = true;\n break;\n }\n }\n } finally {\n await release?.();\n }\n\n // Close the race where a sibling enqueued ids between our last empty drain and\n // releasing the lock: re-dispatch so those ids are eventually processed. Skip\n // this after a refresh failure — the failed ids were re-enqueued and an\n // immediate respawn would just fail again, spinning indefinitely. They wait\n // for the next mutation's dispatch instead.\n const remaining = failed ? [] : await readPendingQueueIds(pmRoot);\n if (remaining.length > 0) {\n dispatchRefreshChild(pmRoot);\n }\n\n return {\n processed: [...new Set(processed)].sort((a, b) => a.localeCompare(b)),\n rounds,\n warnings,\n };\n}\n"],"names":[],"mappings":"AAAA;;;;GAIG;;;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,0CAA0C,EAAE,MAAM,wBAAwB,CAAC;AAEpF,yRAAyR;AACzR,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAAC;AAEzC,MAAM,sBAAsB,GAAG,6BAA6B,CAAC;AAC7D,MAAM,2BAA2B,GAAG,kCAAkC,CAAC;AACvE,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAE3C,MAAM,yBAAyB,GAAG,0BAA0B,CAAC;AAC7D,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAE3D,SAAS,oBAAoB,CAAC,KAAyB;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAA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C,KAAK,CAAC,EAAE,CAC5D,CAAC;gBACF,0EAA0E;gBAC1E,MAAM,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBAC5C,MAAM,GAAG,IAAI,CAAC;gBACd,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,OAAO,EAAE,EAAE,CAAC;IACpB,CAAC;IAED,+EAA+E;IAC/E,8EAA8E;IAC9E,wEAAwE;IACxE,4EAA4E;IAC5E,4CAA4C;IAC5C,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAClE,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO;QACL,SAAS,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QACrE,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC","debugId":"29dca602-09bd-5ca8-b505-f9ea519c0c44"}
|
|
1
|
+
{"version":3,"file":"background-refresh.js","sources":["core/search/background-refresh.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module core/search/background-refresh\n *\n * Powers search, embeddings, and semantic retrieval behavior for Background Refresh.\n */\nimport { spawn } from \"node:child_process\";\nimport { mkdirSync, rmSync, statSync } from \"node:fs\";\nimport path from \"node:path\";\n\nimport {\n pathExists,\n readFileIfExists,\n writeFileAtomic,\n} from \"../fs/fs-utils.js\";\nimport { acquireLock } from \"../lock/lock.js\";\nimport { resolvePmPackageRootFromModule } from \"../packages/root.js\";\nimport {\n readSettings,\n readSettingsWithMetadata,\n} from \"../store/settings.js\";\nimport { toErrorMessage } from \"../shared/primitives.js\";\nimport { resolveSettingsWithSemanticRuntimeDefaults } from \"./semantic-defaults.js\";\n\n/** Shared lock id for any process that rewrites the local vector store. Reindex and the background mutation-refresh worker both acquire this so they never write concurrently and corrupt the store. Exported so `pm reindex` reuses the same id rather than duplicating the literal. */\nexport const REINDEX_LOCK_ID = \"reindex\";\n\nconst PENDING_QUEUE_REL_PATH = \"search/pending-refresh.json\";\nconst PENDING_QUEUE_GATE_REL_PATH = \"search/pending-refresh.gate.lock\";\nconst PENDING_QUEUE_GATE_STALE_MS = 30_000;\n\nconst SEARCH_REFRESH_INLINE_ENV = \"PM_SEARCH_REFRESH_INLINE\";\nconst SEARCH_REFRESH_CHILD_ENV = \"PM_SEARCH_REFRESH_CHILD\";\n/** Delay before a settings-failed worker dispatches one replacement child, preventing a tight retry loop while preserving eventual queue recovery. */\nexport const SEARCH_REFRESH_RETRY_DELAY_MS = 30_000;\n\nfunction parseBooleanTrueLike(value: string | undefined): boolean {\n if (typeof value !== \"string\") {\n return false;\n }\n const normalized = value.trim().toLowerCase();\n return (\n normalized === \"1\" ||\n normalized === \"true\" ||\n normalized === \"yes\" ||\n normalized === \"on\"\n );\n}\n\n/** Mutation search refresh runs inline (blocking) under test runners, inside the background worker child itself, or when explicitly requested. Otherwise the semantic refresh is dispatched to a detached child so mutations return without waiting on embeddings. Mirrors the telemetry-flush inline gate so the full test suite stays deterministic. */\nexport function shouldRunSearchRefreshInForeground(): boolean {\n if (parseBooleanTrueLike(process.env[SEARCH_REFRESH_INLINE_ENV])) {\n return true;\n }\n if (parseBooleanTrueLike(process.env[SEARCH_REFRESH_CHILD_ENV])) {\n return true;\n }\n const nodeEnv = (process.env.NODE_ENV ?? \"\").trim().toLowerCase();\n return (\n typeof process.env.VITEST === \"string\" ||\n typeof process.env.VITEST_WORKER_ID === \"string\" ||\n nodeEnv === \"test\"\n );\n}\n\nfunction pendingQueuePath(pmRoot: string): string {\n return path.join(pmRoot, PENDING_QUEUE_REL_PATH);\n}\n\nfunction pendingQueueGatePath(pmRoot: string): string {\n return path.join(pmRoot, PENDING_QUEUE_GATE_REL_PATH);\n}\n\nfunction acquireQueueGate(pmRoot: string): boolean {\n const gatePath = pendingQueueGatePath(pmRoot);\n try {\n if (Date.now() - statSync(gatePath).mtimeMs < PENDING_QUEUE_GATE_STALE_MS) {\n return false;\n }\n rmSync(gatePath, { recursive: true, force: true });\n } catch {\n // Missing gate is the common case; fall through to create it.\n }\n try {\n mkdirSync(path.dirname(gatePath), { recursive: true });\n mkdirSync(gatePath);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction releaseQueueGate(pmRoot: string): void {\n try {\n rmSync(pendingQueueGatePath(pmRoot), { recursive: true, force: true });\n } catch {\n // Best effort; a stale gate self-heals after PENDING_QUEUE_GATE_STALE_MS.\n }\n}\n\nasync function withQueueGate<T>(\n pmRoot: string,\n fn: () => Promise<T>,\n fallback: T,\n): Promise<T> {\n // Briefly serialize read-modify-write access to the pending queue across the\n // mutation process and the worker child. Acquisition is best effort; if a\n // healthy gate is held we skip rather than risk a torn queue.\n for (let attempt = 0; attempt < 50; attempt += 1) {\n if (acquireQueueGate(pmRoot)) {\n try {\n return await fn();\n } finally {\n releaseQueueGate(pmRoot);\n }\n }\n await delay(20);\n }\n return fallback;\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, ms);\n });\n}\n\nasync function readPendingQueueIds(pmRoot: string): Promise<string[]> {\n const raw = await readFileIfExists(pendingQueuePath(pmRoot));\n if (!raw || raw.trim().length === 0) {\n return [];\n }\n try {\n const parsed = JSON.parse(raw) as { ids?: unknown };\n if (!Array.isArray(parsed.ids)) {\n return [];\n }\n return parsed.ids.filter(\n (id): id is string => typeof id === \"string\" && id.length > 0,\n );\n } catch {\n return [];\n }\n}\n\nasync function writePendingQueueIds(\n pmRoot: string,\n ids: string[],\n): Promise<void> {\n await writeFileAtomic(\n pendingQueuePath(pmRoot),\n `${JSON.stringify({ ids })}\\n`,\n );\n}\n\n/** Merge mutated item ids into the persistent pending-refresh queue. */\nexport async function enqueuePendingRefreshIds(\n pmRoot: string,\n itemIds: string[],\n): Promise<void> {\n const incoming = itemIds.filter(\n (id) => typeof id === \"string\" && id.trim().length > 0,\n );\n if (incoming.length === 0) {\n return;\n }\n const mergeIncoming = async (): Promise<void> => {\n const existing = await readPendingQueueIds(pmRoot);\n const merged = [...new Set([...existing, ...incoming])].sort(\n (left, right) => left.localeCompare(right),\n );\n await writePendingQueueIds(pmRoot, merged);\n };\n const gated = await withQueueGate(\n pmRoot,\n async () => {\n await mergeIncoming();\n return true;\n },\n false,\n );\n if (!gated) {\n // The gate stayed contended past the retry budget. Never silently drop a\n // mutation's refresh work: fall back to a best-effort unguarded merge.\n // writeFileAtomic keeps the file valid; the only risk is losing a concurrent\n // writer's delta, which its own next dispatch and the vector_index_stale\n // warning both recover.\n await mergeIncoming();\n }\n}\n\n/** Atomically read and clear the pending-refresh queue, returning drained ids. */\nexport async function drainPendingRefreshIds(\n pmRoot: string,\n): Promise<string[]> {\n return withQueueGate(pmRoot, async () => {\n const ids = await readPendingQueueIds(pmRoot);\n if (ids.length > 0) {\n await writePendingQueueIds(pmRoot, []);\n }\n return ids;\n }, []);\n}\n\nfunction searchRefreshRunnerPath(): string {\n return path.join(\n resolvePmPackageRootFromModule(import.meta.url, [\"../../..\"]),\n \"dist\",\n \"cli\",\n \"search-refresh.js\",\n );\n}\n\n/** Spawn the detached refresh worker child for this pm root. Best effort: a failed dispatch must never keep the CLI alive or fail a mutation; the next mutation re-dispatches and `vector_index_stale` warns about the catch-up window in the meantime. */\nfunction dispatchRefreshChild(pmRoot: string): void {\n try {\n const child = spawn(process.execPath, [searchRefreshRunnerPath()], {\n detached: true,\n stdio: \"ignore\",\n env: {\n ...process.env,\n PM_PATH: pmRoot,\n [SEARCH_REFRESH_CHILD_ENV]: \"1\",\n },\n });\n // A detached child can emit an async 'error' event (e.g. spawn EAGAIN/ENOENT,\n // resource limits). Swallow it so it never becomes an unhandled error that\n // crashes the parent CLI; dispatch is best effort.\n child.on(\"error\", () => {});\n child.unref();\n } catch {\n // Best effort — see doc comment above.\n }\n}\n\nfunction scheduleDelayedRefreshRetry(pmRoot: string): void {\n setTimeout(() => dispatchRefreshChild(pmRoot), SEARCH_REFRESH_RETRY_DELAY_MS);\n}\n\n/** Enqueue mutated ids and dispatch a detached worker child to refresh semantic embeddings without blocking the mutation. The reindex lock the worker acquires serializes concurrent refreshes, so the spawn itself stays unconditional and cheap; a worker that loses the lock exits and its ids are drained by the holder. */\nexport async function scheduleBackgroundSemanticRefresh(\n pmRoot: string,\n itemIds: string[],\n): Promise<void> {\n await enqueuePendingRefreshIds(pmRoot, itemIds);\n dispatchRefreshChild(pmRoot);\n}\n\n/** Documents the semantic refresh worker result payload exchanged by command, SDK, and package integrations. */\nexport interface SemanticRefreshWorkerResult {\n /** Value that configures or reports processed for this contract. */\n processed: string[];\n /** Value that configures or reports rounds for this contract. */\n rounds: number;\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n}\n\ntype SemanticRefreshFn = (\n pmRoot: string,\n itemIds: string[],\n) => Promise<{ refreshed: string[]; skipped: string[]; warnings: string[] }>;\n\n/** Drain the pending queue and refresh semantic vectors under the reindex lock so the local vector store is never rewritten concurrently. If the lock is held by another worker we exit immediately — that holder drains our enqueued ids. After releasing we re-check the queue once and re-dispatch if a sibling enqueued ids during our final window, guaranteeing eventual processing. */\nexport async function runSemanticRefreshWorker(\n pmRoot: string,\n refresh: SemanticRefreshFn,\n scheduleRetry: (root: string) => void = scheduleDelayedRefreshRetry,\n): Promise<SemanticRefreshWorkerResult> {\n const warnings: string[] = [];\n const processed: string[] = [];\n if (!(await pathExists(pmRoot))) {\n return { processed, rounds: 0, warnings };\n }\n\n let settings: Awaited<ReturnType<typeof readSettings>>;\n try {\n const settingsRead = await readSettingsWithMetadata(pmRoot);\n const readFailure = settingsRead.warnings.find((warning) =>\n warning.startsWith(\"settings_read_\"),\n );\n if (readFailure) {\n scheduleRetry(pmRoot);\n return {\n processed,\n rounds: 0,\n warnings: [\n `search_background_refresh_settings_read_failed:${readFailure}`,\n ],\n };\n }\n settings = resolveSettingsWithSemanticRuntimeDefaults(\n settingsRead.settings,\n ).settings;\n } catch (error: unknown) {\n scheduleRetry(pmRoot);\n return {\n processed,\n rounds: 0,\n warnings: [\n `search_background_refresh_settings_read_failed:${toErrorMessage(error)}`,\n ],\n };\n }\n\n let release: (() => Promise<void>) | null = null;\n try {\n release = await acquireLock(\n pmRoot,\n REINDEX_LOCK_ID,\n settings.locks.ttl_seconds,\n process.env.PM_AUTHOR ?? \"pm-search-refresh\",\n false,\n settings.governance.force_required_for_stale_lock,\n settings.locks.wait_ms,\n );\n } catch {\n // acquireLock owns the bounded wait budget; queued ids remain for the next dispatch.\n }\n if (!release) {\n return { processed, rounds: 0, warnings };\n }\n\n let rounds = 0;\n let failed = false;\n let retryPending = false;\n try {\n for (;;) {\n const ids = await drainPendingRefreshIds(pmRoot);\n if (ids.length === 0) {\n break;\n }\n rounds += 1;\n try {\n const result = await refresh(pmRoot, ids);\n warnings.push(...result.warnings);\n if (\n result.warnings.some((warning) =>\n warning.startsWith(\n \"search_semantic_refresh_skipped:settings_read_failed:\",\n ),\n )\n ) {\n await enqueuePendingRefreshIds(pmRoot, ids);\n failed = true;\n retryPending = true;\n break;\n }\n processed.push(...result.refreshed);\n } catch (error: unknown) {\n warnings.push(\n `search_background_refresh_failed:${toErrorMessage(error)}`,\n );\n // Re-enqueue so the work is retried by a later dispatch rather than lost.\n await enqueuePendingRefreshIds(pmRoot, ids);\n failed = true;\n break;\n }\n }\n } finally {\n await release?.();\n }\n\n if (retryPending) {\n scheduleRetry(pmRoot);\n }\n\n // Close the race where a sibling enqueued ids between our last empty drain and\n // releasing the lock: re-dispatch so those ids are eventually processed. Skip\n // this after a refresh failure — the failed ids were re-enqueued and an\n // immediate respawn would just fail again, spinning indefinitely. They wait\n // for the next mutation's dispatch instead.\n const remaining = failed ? [] : await readPendingQueueIds(pmRoot);\n if (remaining.length > 0) {\n dispatchRefreshChild(pmRoot);\n }\n\n return {\n processed: [...new Set(processed)].sort((a, b) => a.localeCompare(b)),\n rounds,\n warnings,\n };\n}\n"],"names":[],"mappings":"AAAA;;;;GAIG;;;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAEL,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,0CAA0C,EAAE,MAAM,wBAAwB,CAAC;AAEpF,yRAAyR;AACzR,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAAC;AAEzC,MAAM,sBAAsB,GAAG,6BAA6B,CAAC;AAC7D,MAAM,2BAA2B,GAAG,kCAAkC,CAAC;AACvE,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAE3C,MAAM,yBAAyB,GAAG,0BAA0B,CAAC;AAC7D,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAC3D,sJAAsJ;AACtJ,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC;AAEpD,SAAS,oBAAoB,CAAC,KAAyB;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,OAAO,CACL,UAAU,KAAK,GAAG;QAClB,UAAU,KAAK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C,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAClE,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO;QACL,SAAS,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QACrE,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC","debugId":"1c1df3a7-d81f-53bb-9590-1c9c9d461569"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Powers search, embeddings, and semantic retrieval behavior for Cache.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
!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]="
|
|
7
|
+
!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]="64ce81f6-7bac-5243-8391-ccc808cd2dfc")}catch(e){}}();
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import { getActiveExtensionRegistrations } from "../extensions/index.js";
|
|
10
10
|
import { pathExists, readFileIfExists, removeFileIfExists, writeFileAtomic, } from "../fs/fs-utils.js";
|
|
@@ -12,7 +12,7 @@ import { resolveItemTypeRegistry } from "../item/type-registry.js";
|
|
|
12
12
|
import { toErrorMessage } from "../shared/primitives.js";
|
|
13
13
|
import { locateItem, readLocatedItem } from "../store/item-store.js";
|
|
14
14
|
import { getSettingsPath } from "../store/paths.js";
|
|
15
|
-
import {
|
|
15
|
+
import { readSettingsWithMetadata, } from "../store/settings.js";
|
|
16
16
|
import { executeEmbeddingBatchesWithRetry } from "./embedding-batches.js";
|
|
17
17
|
import { buildSemanticCorpusInput, resolveSearchCorpusFields, resolveSemanticCorpusCharacterLimit, } from "./corpus.js";
|
|
18
18
|
import { resolveEmbeddingProviders } from "./providers.js";
|
|
@@ -169,7 +169,17 @@ async function resolveSemanticRefreshRuntimeContext(pmRoot, normalizedItemIds, o
|
|
|
169
169
|
}
|
|
170
170
|
let settings;
|
|
171
171
|
try {
|
|
172
|
-
|
|
172
|
+
if (options.settings) {
|
|
173
|
+
settings = options.settings;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
const settingsRead = await readSettingsWithMetadata(pmRoot);
|
|
177
|
+
const readFailure = settingsRead.warnings.find((warning) => warning.startsWith("settings_read_"));
|
|
178
|
+
if (readFailure) {
|
|
179
|
+
return buildSkippedSemanticRefreshResult(normalizedItemIds, `search_semantic_refresh_skipped:settings_read_failed:${readFailure}`);
|
|
180
|
+
}
|
|
181
|
+
settings = settingsRead.settings;
|
|
182
|
+
}
|
|
173
183
|
}
|
|
174
184
|
catch (error) {
|
|
175
185
|
return buildSkippedSemanticRefreshResult(normalizedItemIds, `search_semantic_refresh_skipped:settings_read_failed:${toErrorMessage(error)}`);
|
|
@@ -450,7 +460,20 @@ export async function refreshSearchArtifactsForMutation(pmRoot, itemIds, options
|
|
|
450
460
|
}
|
|
451
461
|
let settings;
|
|
452
462
|
try {
|
|
453
|
-
|
|
463
|
+
const settingsRead = await readSettingsWithMetadata(pmRoot);
|
|
464
|
+
const readFailure = settingsRead.warnings.find((warning) => warning.startsWith("settings_read_"));
|
|
465
|
+
if (readFailure) {
|
|
466
|
+
return {
|
|
467
|
+
invalidated: invalidation.invalidated,
|
|
468
|
+
refreshed: [],
|
|
469
|
+
skipped: normalizedItemIds,
|
|
470
|
+
warnings: [
|
|
471
|
+
...invalidation.warnings,
|
|
472
|
+
`search_semantic_refresh_skipped:settings_read_failed:${readFailure}`,
|
|
473
|
+
],
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
settings = settingsRead.settings;
|
|
454
477
|
}
|
|
455
478
|
catch (error) {
|
|
456
479
|
return {
|
|
@@ -509,4 +532,4 @@ export const _testOnly = {
|
|
|
509
532
|
resetSemanticVectorStore,
|
|
510
533
|
};
|
|
511
534
|
//# sourceMappingURL=cache.js.map
|
|
512
|
-
//# debugId=
|
|
535
|
+
//# debugId=64ce81f6-7bac-5243-8391-ccc808cd2dfc
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sources":["core/search/cache.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module core/search/cache\n *\n * Powers search, embeddings, and semantic retrieval behavior for Cache.\n */\nimport path from \"node:path\";\nimport { getActiveExtensionRegistrations } from \"../extensions/index.js\";\nimport {\n pathExists,\n readFileIfExists,\n removeFileIfExists,\n writeFileAtomic,\n} from \"../fs/fs-utils.js\";\nimport { resolveItemTypeRegistry } from \"../item/type-registry.js\";\nimport { toErrorMessage } from \"../shared/primitives.js\";\nimport { locateItem, readLocatedItem } from \"../store/item-store.js\";\nimport { getSettingsPath } from \"../store/paths.js\";\nimport { readSettings } from \"../store/settings.js\";\nimport { executeEmbeddingBatchesWithRetry } from \"./embedding-batches.js\";\nimport {\n buildSemanticCorpusInput,\n resolveSearchCorpusFields,\n resolveSemanticCorpusCharacterLimit,\n} from \"./corpus.js\";\nimport { resolveEmbeddingProviders } from \"./providers.js\";\nimport type { EmbeddingProviderConfig } from \"./providers.js\";\nimport { resolveSettingsWithSemanticRuntimeDefaults } from \"./semantic-defaults.js\";\nimport { scheduleBackgroundSemanticRefresh } from \"./background-refresh.js\";\nimport {\n executeVectorDelete,\n executeVectorReset,\n executeVectorUpsert,\n resolveVectorStores,\n} from \"./vector-stores.js\";\nimport type { VectorStoreConfig } from \"./vector-stores.js\";\nimport {\n buildVectorizationEmbeddingIdentity,\n buildVectorizationEmbeddingMetadata,\n hasVectorizationEmbeddingIdentityChanged,\n hasVectorizationVectorDimensionChanged,\n inferConsistentVectorDimension,\n normalizeVectorizationEmbeddingMetadata,\n} from \"./vectorization-metadata.js\";\nimport type {\n VectorizationEmbeddingIdentity,\n VectorizationEmbeddingMetadata,\n} from \"./vectorization-metadata.js\";\nimport { nowIso } from \"../shared/time.js\";\nimport type { ItemDocument, ItemMetadata } from \"../../types/index.js\";\n\n/** Public contract for search cache artifact paths, shared by SDK and presentation-layer consumers. */\nexport const SEARCH_CACHE_ARTIFACT_PATHS = [\n \"index/manifest.json\",\n \"search/embeddings.jsonl\",\n] as const;\n/** Filesystem path used for vectorization status ledger resolution. */\nexport const VECTORIZATION_STATUS_LEDGER_PATH =\n \"search/vectorization-status.json\";\n\n/** Documents the search cache invalidation result payload exchanged by command, SDK, and package integrations. */\nexport interface SearchCacheInvalidationResult {\n /** Value that configures or reports invalidated for this contract. */\n invalidated: string[];\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n}\n\n/** Documents the semantic mutation refresh result payload exchanged by command, SDK, and package integrations. */\nexport interface SemanticMutationRefreshResult {\n /** Value that configures or reports refreshed for this contract. */\n refreshed: string[];\n /** Value that configures or reports skipped for this contract. */\n skipped: string[];\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n}\n\n/** Documents the search mutation artifact refresh result payload exchanged by command, SDK, and package integrations. */\nexport interface SearchMutationArtifactRefreshResult extends SearchCacheInvalidationResult {\n /** Value that configures or reports refreshed for this contract. */\n refreshed: string[];\n /** Value that configures or reports skipped for this contract. */\n skipped: string[];\n /** True when the semantic refresh was dispatched to a detached background worker. */\n scheduled?: boolean;\n}\n\n/** Documents the refresh search artifacts for mutation options payload exchanged by command, SDK, and package integrations. */\nexport interface RefreshSearchArtifactsForMutationOptions {\n /** When true and semantic search is active, the (slow) embedding refresh is dispatched to a detached background worker instead of awaited inline so the mutation returns immediately. The synchronous keyword-cache invalidation still runs first. Callers pass this only outside test runners. */\n background?: boolean;\n}\n\n/** Documents the semantic refresh options payload exchanged by command, SDK, and package integrations. */\nexport interface SemanticRefreshOptions {\n /** Value that configures or reports settings for this contract. */\n settings?: Awaited<ReturnType<typeof readSettings>>;\n /** Value that configures or reports apply runtime defaults for this contract. */\n apply_runtime_defaults?: boolean;\n}\n\n/** Documents the vectorization status ledger read result payload exchanged by command, SDK, and package integrations. */\nexport interface VectorizationStatusLedgerReadResult {\n /** Value that configures or reports entries for this contract. */\n entries: Record<string, string>;\n /** Value that configures or reports embedding for this contract. */\n embedding: VectorizationEmbeddingMetadata | null;\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n}\n\nfunction formatInvalidationWarning(\n relativePath: string,\n error: unknown,\n): string {\n return `search_cache_invalidation_failed:${relativePath}:${String(error)}`;\n}\n\nfunction toUniqueSorted(values: Iterable<string>): string[] {\n return [\n ...new Set(\n [...values]\n .map((value) => value.trim())\n .filter((value) => value.length > 0),\n ),\n ].sort((left, right) => left.localeCompare(right));\n}\n\nfunction isValidUpdatedAt(value: unknown): value is string {\n return (\n typeof value === \"string\" &&\n value.trim().length > 0 &&\n Number.isFinite(Date.parse(value))\n );\n}\n\nfunction normalizeVectorizationLedgerEntries(\n entries: Record<string, string>,\n): Record<string, string> {\n const normalized = new Map<string, string>();\n for (const [rawId, rawUpdatedAt] of Object.entries(entries)) {\n const id = rawId.trim();\n if (id.length === 0 || !isValidUpdatedAt(rawUpdatedAt)) {\n continue;\n }\n normalized.set(id, rawUpdatedAt);\n }\n return Object.fromEntries(\n [...normalized.entries()].sort((left, right) =>\n left[0].localeCompare(right[0]),\n ),\n );\n}\n\n/** Implements read vectorization status ledger for the public runtime surface of this module. */\nexport async function readVectorizationStatusLedger(\n pmRoot: string,\n): Promise<VectorizationStatusLedgerReadResult> {\n const ledgerPath = path.join(pmRoot, VECTORIZATION_STATUS_LEDGER_PATH);\n const raw = await readFileIfExists(ledgerPath);\n if (raw === null || raw.trim().length === 0) {\n return {\n entries: {},\n embedding: null,\n warnings: [],\n };\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch {\n return {\n entries: {},\n embedding: null,\n warnings: [\"search_vectorization_status_ledger_invalid\"],\n };\n }\n\n if (\n typeof parsed !== \"object\" ||\n parsed === null ||\n (parsed as { version?: unknown }).version !== 1 ||\n !Array.isArray((parsed as { items?: unknown }).items)\n ) {\n return {\n entries: {},\n embedding: null,\n warnings: [\"search_vectorization_status_ledger_invalid\"],\n };\n }\n\n const mapped = new Map<string, string>();\n for (const entry of (parsed as { items: unknown[] }).items) {\n if (typeof entry !== \"object\" || entry === null) {\n return {\n entries: {},\n embedding: null,\n warnings: [\"search_vectorization_status_ledger_invalid\"],\n };\n }\n const id = (entry as { id?: unknown }).id;\n const updatedAt = (entry as { updated_at?: unknown }).updated_at;\n if (\n typeof id !== \"string\" ||\n id.trim().length === 0 ||\n !isValidUpdatedAt(updatedAt)\n ) {\n return {\n entries: {},\n embedding: null,\n warnings: [\"search_vectorization_status_ledger_invalid\"],\n };\n }\n mapped.set(id.trim(), updatedAt);\n }\n\n let embedding: VectorizationEmbeddingMetadata | null = null;\n try {\n embedding = normalizeVectorizationEmbeddingMetadata(\n (parsed as { embedding?: unknown }).embedding,\n );\n } catch {\n return {\n entries: {},\n embedding: null,\n warnings: [\"search_vectorization_status_ledger_invalid\"],\n };\n }\n\n return {\n entries: Object.fromEntries(\n [...mapped.entries()].sort((left, right) =>\n left[0].localeCompare(right[0]),\n ),\n ),\n embedding,\n warnings: [],\n };\n}\n\n/** Implements write vectorization status ledger for the public runtime surface of this module. */\nexport async function writeVectorizationStatusLedger(\n pmRoot: string,\n entries: Record<string, string>,\n embedding?: VectorizationEmbeddingMetadata | null,\n): Promise<void> {\n const normalizedEntries = normalizeVectorizationLedgerEntries(entries);\n const ledgerPath = path.join(pmRoot, VECTORIZATION_STATUS_LEDGER_PATH);\n const serialized = `${JSON.stringify(\n {\n version: 1,\n generated_at: nowIso(),\n ...(embedding ? { embedding } : {}),\n items: Object.entries(normalizedEntries).map(([id, updated_at]) => ({\n id,\n updated_at,\n })),\n },\n null,\n 2,\n )}\\n`;\n await writeFileAtomic(ledgerPath, serialized);\n}\n\nfunction buildVectorPayload(item: ItemMetadata): Record<string, unknown> {\n return {\n id: item.id,\n type: item.type,\n status: item.status,\n priority: item.priority,\n updated_at: item.updated_at,\n };\n}\n\ninterface SemanticRefreshRuntimeContext {\n settings: Awaited<ReturnType<typeof readSettings>>;\n provider: EmbeddingProviderConfig;\n vectorStore: VectorStoreConfig;\n}\n\ninterface SemanticRefreshWorkload {\n documents: Array<{ id: string; document: ItemDocument }>;\n missingIds: string[];\n skippedIds: string[];\n warnings: string[];\n}\n\ninterface SemanticRefreshOperationResult {\n refreshed: string[];\n skipped: string[];\n warnings: string[];\n}\n\ninterface SemanticEmbeddingOperationResult {\n vectors: number[][];\n vector_dimension: number;\n warnings: string[];\n}\n\nfunction buildVectorizationIdentityForProvider(\n provider: EmbeddingProviderConfig,\n): VectorizationEmbeddingIdentity {\n const identity = buildVectorizationEmbeddingIdentity(\n provider.name,\n provider.model,\n );\n if (!identity) {\n throw new Error(\n \"Embedding provider must include a provider name and model\",\n );\n }\n return identity;\n}\n\nfunction buildSkippedSemanticRefreshResult(\n itemIds: string[],\n warning: string,\n): SemanticMutationRefreshResult {\n return {\n refreshed: [],\n skipped: itemIds,\n warnings: [warning],\n };\n}\n\nasync function resolveSemanticRefreshRuntimeContext(\n pmRoot: string,\n normalizedItemIds: string[],\n options: SemanticRefreshOptions,\n): Promise<SemanticRefreshRuntimeContext | SemanticMutationRefreshResult> {\n if (!options.settings && !(await pathExists(getSettingsPath(pmRoot)))) {\n return buildSkippedSemanticRefreshResult(\n normalizedItemIds,\n \"search_semantic_refresh_skipped:settings_not_initialized\",\n );\n }\n\n let settings: Awaited<ReturnType<typeof readSettings>>;\n try {\n settings = options.settings ?? (await readSettings(pmRoot));\n } catch (error: unknown) {\n return buildSkippedSemanticRefreshResult(\n normalizedItemIds,\n `search_semantic_refresh_skipped:settings_read_failed:${toErrorMessage(error)}`,\n );\n }\n const effectiveSettings = options.apply_runtime_defaults\n ? resolveSettingsWithSemanticRuntimeDefaults(settings).settings\n : settings;\n\n const provider = resolveEmbeddingProviders(effectiveSettings).active;\n if (!provider) {\n return buildSkippedSemanticRefreshResult(\n normalizedItemIds,\n \"search_semantic_refresh_skipped:provider_unconfigured\",\n );\n }\n const vectorStore = resolveVectorStores(effectiveSettings, pmRoot).active;\n if (!vectorStore) {\n return buildSkippedSemanticRefreshResult(\n normalizedItemIds,\n \"search_semantic_refresh_skipped:vector_store_unconfigured\",\n );\n }\n\n return {\n settings: effectiveSettings,\n provider,\n vectorStore,\n };\n}\n\nasync function collectSemanticRefreshWorkload(\n pmRoot: string,\n idPrefix: string,\n preferredFormat: \"toon\" | \"json_markdown\",\n normalizedItemIds: string[],\n typeToFolder: Record<string, string>,\n schema: Awaited<ReturnType<typeof readSettings>>[\"schema\"],\n): Promise<SemanticRefreshWorkload> {\n const warnings: string[] = [];\n const skipped = new Set<string>();\n const missing = new Set<string>();\n const documents: Array<{ id: string; document: ItemDocument }> = [];\n\n for (const itemId of normalizedItemIds) {\n const located = await locateItem(\n pmRoot,\n itemId,\n idPrefix,\n preferredFormat,\n typeToFolder,\n );\n if (!located) {\n missing.add(itemId);\n continue;\n }\n\n try {\n const loaded = await readLocatedItem(located, { schema });\n documents.push({\n id: loaded.document.metadata.id,\n document: loaded.document,\n });\n } catch (error: unknown) {\n skipped.add(located.id);\n warnings.push(\n `search_semantic_refresh_item_read_failed:${located.id}:${toErrorMessage(error)}`,\n );\n }\n }\n\n documents.sort((left, right) => left.id.localeCompare(right.id));\n return {\n documents,\n missingIds: toUniqueSorted(missing),\n skippedIds: toUniqueSorted(skipped),\n warnings,\n };\n}\n\nasync function embedLocatedSemanticVectors(\n settings: Awaited<ReturnType<typeof readSettings>>,\n provider: EmbeddingProviderConfig,\n documents: Array<{ id: string; document: ItemDocument }>,\n): Promise<SemanticEmbeddingOperationResult> {\n const corpusCharacterLimit = resolveSemanticCorpusCharacterLimit(\n provider.name,\n settings.search.embedding_corpus_max_characters,\n ).maxCharacters;\n const corpusFields = resolveSearchCorpusFields(settings);\n const corpusInputs = documents.map((entry) =>\n buildSemanticCorpusInput(entry.document, {\n providerName: provider.name,\n maxCharacters: corpusCharacterLimit,\n fields: corpusFields,\n }),\n );\n const embeddingResult = await executeEmbeddingBatchesWithRetry(\n provider,\n settings,\n corpusInputs,\n );\n return {\n vectors: embeddingResult.vectors,\n vector_dimension: inferConsistentVectorDimension(\n embeddingResult.vectors,\n \"Semantic refresh embedding\",\n ),\n warnings: embeddingResult.warnings,\n };\n}\n\nasync function upsertLocatedSemanticVectors(\n vectorStore: VectorStoreConfig,\n documents: Array<{ id: string; document: ItemDocument }>,\n vectors: number[][],\n): Promise<SemanticRefreshOperationResult> {\n await executeVectorUpsert(\n vectorStore,\n documents.map((entry, index) => ({\n id: entry.id,\n vector: vectors[index],\n payload: buildVectorPayload(entry.document.metadata),\n })),\n );\n return {\n refreshed: documents.map((entry) => entry.id),\n skipped: [],\n warnings: [],\n };\n}\n\nasync function resetSemanticVectorStore(\n vectorStore: VectorStoreConfig,\n ledgerEntries: Record<string, string>,\n): Promise<SemanticRefreshOperationResult> {\n try {\n await executeVectorReset(vectorStore, Object.keys(ledgerEntries));\n return { refreshed: [], skipped: [], warnings: [] };\n } catch (error: unknown) {\n return {\n refreshed: [],\n skipped: [],\n warnings: [\n `search_semantic_refresh_reset_failed:${toErrorMessage(error)}`,\n ],\n };\n }\n}\n\nasync function pruneMissingSemanticVectors(\n vectorStore: VectorStoreConfig,\n missingIds: string[],\n): Promise<SemanticRefreshOperationResult> {\n if (missingIds.length === 0) {\n return { refreshed: [], skipped: [], warnings: [] };\n }\n try {\n await executeVectorDelete(vectorStore, missingIds);\n return {\n refreshed: [],\n skipped: [],\n warnings: [],\n };\n } catch (error: unknown) {\n return {\n refreshed: [],\n skipped: missingIds,\n warnings: [\n `search_semantic_refresh_delete_failed:${toErrorMessage(error)}`,\n ],\n };\n }\n}\n\n/** Implements invalidate search cache artifacts for the public runtime surface of this module. */\nexport async function invalidateSearchCacheArtifacts(\n pmRoot: string,\n): Promise<SearchCacheInvalidationResult> {\n const invalidated: string[] = [];\n const warnings: string[] = [];\n\n for (const relativePath of SEARCH_CACHE_ARTIFACT_PATHS) {\n const artifactPath = path.join(pmRoot, relativePath);\n try {\n if (!(await pathExists(artifactPath))) {\n continue;\n }\n await removeFileIfExists(artifactPath);\n invalidated.push(relativePath);\n } catch (error: unknown) {\n warnings.push(formatInvalidationWarning(relativePath, error));\n }\n }\n\n return {\n invalidated,\n warnings,\n };\n}\n\n/** Implements refresh semantic embeddings for mutated items for the public runtime surface of this module. */\nexport async function refreshSemanticEmbeddingsForMutatedItems(\n pmRoot: string,\n itemIds: string[],\n options: SemanticRefreshOptions = {},\n): Promise<SemanticMutationRefreshResult> {\n const normalizedItemIds = toUniqueSorted(itemIds);\n if (normalizedItemIds.length === 0) {\n return {\n refreshed: [],\n skipped: [],\n warnings: [],\n };\n }\n\n const runtimeContext = await resolveSemanticRefreshRuntimeContext(\n pmRoot,\n normalizedItemIds,\n options,\n );\n if (!(\"settings\" in runtimeContext)) {\n return runtimeContext;\n }\n const typeRegistry = resolveItemTypeRegistry(\n runtimeContext.settings,\n getActiveExtensionRegistrations(),\n );\n const workload = await collectSemanticRefreshWorkload(\n pmRoot,\n runtimeContext.settings.id_prefix,\n runtimeContext.settings.item_format,\n normalizedItemIds,\n typeRegistry.type_to_folder,\n runtimeContext.settings.schema,\n );\n const ledgerRead =\n workload.documents.length > 0 || workload.missingIds.length > 0\n ? await readVectorizationStatusLedger(pmRoot)\n : { entries: {}, embedding: null, warnings: [] };\n const embeddingIdentity = buildVectorizationIdentityForProvider(\n runtimeContext.provider,\n );\n const nextLedgerBaseEntries = ledgerRead.entries;\n let refreshedResult: SemanticRefreshOperationResult = {\n refreshed: [],\n skipped: [],\n warnings: [],\n };\n let nextEmbeddingMetadata = ledgerRead.embedding;\n if (workload.documents.length > 0) {\n if (\n ledgerRead.embedding &&\n hasVectorizationEmbeddingIdentityChanged(\n ledgerRead.embedding,\n embeddingIdentity,\n )\n ) {\n refreshedResult = {\n refreshed: [],\n skipped: workload.documents.map((entry) => entry.id),\n warnings: [\n \"search_semantic_refresh_requires_reindex:embedding_identity_changed\",\n ],\n };\n } else {\n try {\n const embedded = await embedLocatedSemanticVectors(\n runtimeContext.settings,\n runtimeContext.provider,\n workload.documents,\n );\n if (\n hasVectorizationVectorDimensionChanged(\n ledgerRead.embedding,\n embedded.vector_dimension,\n )\n ) {\n refreshedResult = {\n refreshed: [],\n skipped: workload.documents.map((entry) => entry.id),\n warnings: [\n ...embedded.warnings,\n \"search_semantic_refresh_requires_reindex:vector_dimension_changed\",\n ],\n };\n } else {\n nextEmbeddingMetadata = buildVectorizationEmbeddingMetadata(\n embeddingIdentity,\n embedded.vector_dimension,\n );\n const upserted = await upsertLocatedSemanticVectors(\n runtimeContext.vectorStore,\n workload.documents,\n embedded.vectors,\n );\n refreshedResult = {\n refreshed: upserted.refreshed,\n skipped: upserted.skipped,\n warnings: [...embedded.warnings, ...upserted.warnings],\n };\n }\n } catch (error: unknown) {\n refreshedResult = {\n refreshed: [],\n skipped: workload.documents.map((entry) => entry.id),\n warnings: [`search_semantic_refresh_failed:${toErrorMessage(error)}`],\n };\n }\n }\n }\n const pruneResult = await pruneMissingSemanticVectors(\n runtimeContext.vectorStore,\n workload.missingIds,\n );\n const refreshedIdSet = new Set(refreshedResult.refreshed);\n const refreshedEntries = Object.fromEntries(\n workload.documents\n .filter((entry) => refreshedIdSet.has(entry.id))\n .map((entry) => [entry.id, entry.document.metadata.updated_at]),\n );\n const ledgerWarnings: string[] = [];\n if (\n Object.keys(refreshedEntries).length > 0 ||\n workload.missingIds.length > 0\n ) {\n const nextEntries = {\n ...nextLedgerBaseEntries,\n ...normalizeVectorizationLedgerEntries(refreshedEntries),\n };\n for (const missingId of workload.missingIds) {\n delete nextEntries[missingId];\n }\n try {\n await writeVectorizationStatusLedger(\n pmRoot,\n nextEntries,\n nextEmbeddingMetadata,\n );\n } catch (error: unknown) {\n ledgerWarnings.push(\n `search_vectorization_status_ledger_write_failed:${toErrorMessage(error)}`,\n );\n }\n ledgerWarnings.push(...ledgerRead.warnings);\n }\n\n return {\n refreshed: toUniqueSorted([\n ...refreshedResult.refreshed,\n ...pruneResult.refreshed,\n ]),\n skipped: toUniqueSorted([\n ...workload.skippedIds,\n ...refreshedResult.skipped,\n ...pruneResult.skipped,\n ]),\n warnings: [\n ...workload.warnings,\n ...refreshedResult.warnings,\n ...pruneResult.warnings,\n ...ledgerWarnings,\n ],\n };\n}\n\n/** Returns true when a semantic embedding refresh would do real work for these settings (an embedding provider AND a vector store both resolve). Used to decide whether a mutation's refresh is worth dispatching to a background worker — when semantic search is not configured the inline path is already a fast no-op and no child is spawned. */\nexport function isSemanticRefreshActive(\n settings: Awaited<ReturnType<typeof readSettings>>,\n applyRuntimeDefaults: boolean,\n): boolean {\n const effectiveSettings = applyRuntimeDefaults\n ? resolveSettingsWithSemanticRuntimeDefaults(settings).settings\n : settings;\n return Boolean(\n resolveEmbeddingProviders(effectiveSettings).active &&\n resolveVectorStores(effectiveSettings).active,\n );\n}\n\n/** Implements refresh search artifacts for mutation for the public runtime surface of this module. */\nexport async function refreshSearchArtifactsForMutation(\n pmRoot: string,\n itemIds: string[],\n options: RefreshSearchArtifactsForMutationOptions = {},\n): Promise<SearchMutationArtifactRefreshResult> {\n const invalidation = await invalidateSearchCacheArtifacts(pmRoot);\n const normalizedItemIds = toUniqueSorted(itemIds);\n if (normalizedItemIds.length === 0) {\n return {\n invalidated: invalidation.invalidated,\n refreshed: [],\n skipped: [],\n warnings: invalidation.warnings,\n };\n }\n\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n const semanticRefresh = await refreshSemanticEmbeddingsForMutatedItems(\n pmRoot,\n normalizedItemIds,\n );\n return {\n invalidated: invalidation.invalidated,\n refreshed: semanticRefresh.refreshed,\n skipped: semanticRefresh.skipped,\n warnings: [...invalidation.warnings, ...semanticRefresh.warnings],\n };\n }\n\n let settings: Awaited<ReturnType<typeof readSettings>>;\n try {\n settings = await readSettings(pmRoot);\n } catch (error: unknown) {\n return {\n invalidated: invalidation.invalidated,\n refreshed: [],\n skipped: normalizedItemIds,\n warnings: [\n ...invalidation.warnings,\n `search_semantic_refresh_skipped:settings_read_failed:${toErrorMessage(error)}`,\n ],\n };\n }\n\n if (settings.search.mutation_refresh_policy === \"cache_only\") {\n return {\n invalidated: invalidation.invalidated,\n refreshed: [],\n skipped: normalizedItemIds,\n warnings: invalidation.warnings,\n };\n }\n\n const applyRuntimeDefaults =\n settings.search.mutation_refresh_policy === \"semantic_auto\";\n\n // Keyword cache is already invalidated synchronously above (so keyword search\n // stays immediately correct). When requested, dispatch the slow embedding\n // refresh to a detached worker so the mutation returns instantly; the\n // vector_index_stale health/search warning covers the catch-up window.\n if (\n options.background &&\n isSemanticRefreshActive(settings, applyRuntimeDefaults)\n ) {\n await scheduleBackgroundSemanticRefresh(pmRoot, normalizedItemIds);\n return {\n invalidated: invalidation.invalidated,\n refreshed: [],\n skipped: [],\n warnings: [\n ...invalidation.warnings,\n \"search_semantic_refresh_scheduled_background\",\n ],\n scheduled: true,\n };\n }\n\n const semanticRefresh = await refreshSemanticEmbeddingsForMutatedItems(\n pmRoot,\n normalizedItemIds,\n {\n settings,\n apply_runtime_defaults: applyRuntimeDefaults,\n },\n );\n return {\n invalidated: invalidation.invalidated,\n refreshed: semanticRefresh.refreshed,\n skipped: semanticRefresh.skipped,\n warnings: [...invalidation.warnings, ...semanticRefresh.warnings],\n };\n}\n\n/** Public contract for test only, shared by SDK and presentation-layer consumers. */\nexport const _testOnly = {\n buildSkippedSemanticRefreshResult,\n buildVectorizationIdentityForProvider,\n normalizeVectorizationLedgerEntries,\n resetSemanticVectorStore,\n};\n"],"names":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C;aAC/C;YACD,SAAS,EAAE,IAAI;SAChB,CAAC;IACJ,CAAC;IAED,MAAM,eAAe,GAAG,MAAM,wCAAwC,CACpE,MAAM,EACN,iBAAiB,EACjB;QACE,QAAQ;QACR,sBAAsB,EAAE,oBAAoB;KAC7C,CACF,CAAC;IACF,OAAO;QACL,WAAW,EAAE,YAAY,CAAC,WAAW;QACrC,SAAS,EAAE,eAAe,CAAC,SAAS;QACpC,OAAO,EAAE,eAAe,CAAC,OAAO;QAChC,QAAQ,EAAE,CAAC,GAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,eAAe,CAAC,QAAQ,CAAC;KAClE,CAAC;AACJ,CAAC;AAED,qFAAqF;AACrF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,iCAAiC;IACjC,qCAAqC;IACrC,mCAAmC;IACnC,wBAAwB;CACzB,CAAC","debugId":"c65c4b7b-9860-5c4c-a7a4-de3eb53b59a3"}
|
|
1
|
+
{"version":3,"file":"cache.js","sources":["core/search/cache.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module core/search/cache\n *\n * Powers search, embeddings, and semantic retrieval behavior for Cache.\n */\nimport path from \"node:path\";\nimport { getActiveExtensionRegistrations } from \"../extensions/index.js\";\nimport {\n pathExists,\n readFileIfExists,\n removeFileIfExists,\n writeFileAtomic,\n} from \"../fs/fs-utils.js\";\nimport { resolveItemTypeRegistry } from \"../item/type-registry.js\";\nimport { toErrorMessage } from \"../shared/primitives.js\";\nimport { locateItem, readLocatedItem } from \"../store/item-store.js\";\nimport { getSettingsPath } from \"../store/paths.js\";\nimport {\n readSettings,\n readSettingsWithMetadata,\n} from \"../store/settings.js\";\nimport { executeEmbeddingBatchesWithRetry } from \"./embedding-batches.js\";\nimport {\n buildSemanticCorpusInput,\n resolveSearchCorpusFields,\n resolveSemanticCorpusCharacterLimit,\n} from \"./corpus.js\";\nimport { resolveEmbeddingProviders } from \"./providers.js\";\nimport type { EmbeddingProviderConfig } from \"./providers.js\";\nimport { resolveSettingsWithSemanticRuntimeDefaults } from \"./semantic-defaults.js\";\nimport { scheduleBackgroundSemanticRefresh } from \"./background-refresh.js\";\nimport {\n executeVectorDelete,\n executeVectorReset,\n executeVectorUpsert,\n resolveVectorStores,\n} from \"./vector-stores.js\";\nimport type { VectorStoreConfig } from \"./vector-stores.js\";\nimport {\n buildVectorizationEmbeddingIdentity,\n buildVectorizationEmbeddingMetadata,\n hasVectorizationEmbeddingIdentityChanged,\n hasVectorizationVectorDimensionChanged,\n inferConsistentVectorDimension,\n normalizeVectorizationEmbeddingMetadata,\n} from \"./vectorization-metadata.js\";\nimport type {\n VectorizationEmbeddingIdentity,\n VectorizationEmbeddingMetadata,\n} from \"./vectorization-metadata.js\";\nimport { nowIso } from \"../shared/time.js\";\nimport type { ItemDocument, ItemMetadata } from \"../../types/index.js\";\n\n/** Public contract for search cache artifact paths, shared by SDK and presentation-layer consumers. */\nexport const SEARCH_CACHE_ARTIFACT_PATHS = [\n \"index/manifest.json\",\n \"search/embeddings.jsonl\",\n] as const;\n/** Filesystem path used for vectorization status ledger resolution. */\nexport const VECTORIZATION_STATUS_LEDGER_PATH =\n \"search/vectorization-status.json\";\n\n/** Documents the search cache invalidation result payload exchanged by command, SDK, and package integrations. */\nexport interface SearchCacheInvalidationResult {\n /** Value that configures or reports invalidated for this contract. */\n invalidated: string[];\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n}\n\n/** Documents the semantic mutation refresh result payload exchanged by command, SDK, and package integrations. */\nexport interface SemanticMutationRefreshResult {\n /** Value that configures or reports refreshed for this contract. */\n refreshed: string[];\n /** Value that configures or reports skipped for this contract. */\n skipped: string[];\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n}\n\n/** Documents the search mutation artifact refresh result payload exchanged by command, SDK, and package integrations. */\nexport interface SearchMutationArtifactRefreshResult extends SearchCacheInvalidationResult {\n /** Value that configures or reports refreshed for this contract. */\n refreshed: string[];\n /** Value that configures or reports skipped for this contract. */\n skipped: string[];\n /** True when the semantic refresh was dispatched to a detached background worker. */\n scheduled?: boolean;\n}\n\n/** Documents the refresh search artifacts for mutation options payload exchanged by command, SDK, and package integrations. */\nexport interface RefreshSearchArtifactsForMutationOptions {\n /** When true and semantic search is active, the (slow) embedding refresh is dispatched to a detached background worker instead of awaited inline so the mutation returns immediately. The synchronous keyword-cache invalidation still runs first. Callers pass this only outside test runners. */\n background?: boolean;\n}\n\n/** Documents the semantic refresh options payload exchanged by command, SDK, and package integrations. */\nexport interface SemanticRefreshOptions {\n /** Value that configures or reports settings for this contract. */\n settings?: Awaited<ReturnType<typeof readSettings>>;\n /** Value that configures or reports apply runtime defaults for this contract. */\n apply_runtime_defaults?: boolean;\n}\n\n/** Documents the vectorization status ledger read result payload exchanged by command, SDK, and package integrations. */\nexport interface VectorizationStatusLedgerReadResult {\n /** Value that configures or reports entries for this contract. */\n entries: Record<string, string>;\n /** Value that configures or reports embedding for this contract. */\n embedding: VectorizationEmbeddingMetadata | null;\n /** Value that configures or reports warnings for this contract. */\n warnings: string[];\n}\n\nfunction formatInvalidationWarning(\n relativePath: string,\n error: unknown,\n): string {\n return `search_cache_invalidation_failed:${relativePath}:${String(error)}`;\n}\n\nfunction toUniqueSorted(values: Iterable<string>): string[] {\n return [\n ...new Set(\n [...values]\n .map((value) => value.trim())\n .filter((value) => value.length > 0),\n ),\n ].sort((left, right) => left.localeCompare(right));\n}\n\nfunction isValidUpdatedAt(value: unknown): value is string {\n return (\n typeof value === \"string\" &&\n value.trim().length > 0 &&\n Number.isFinite(Date.parse(value))\n );\n}\n\nfunction normalizeVectorizationLedgerEntries(\n entries: Record<string, string>,\n): Record<string, string> {\n const normalized = new Map<string, string>();\n for (const [rawId, rawUpdatedAt] of Object.entries(entries)) {\n const id = rawId.trim();\n if (id.length === 0 || !isValidUpdatedAt(rawUpdatedAt)) {\n continue;\n }\n normalized.set(id, rawUpdatedAt);\n }\n return Object.fromEntries(\n [...normalized.entries()].sort((left, right) =>\n left[0].localeCompare(right[0]),\n ),\n );\n}\n\n/** Implements read vectorization status ledger for the public runtime surface of this module. */\nexport async function readVectorizationStatusLedger(\n pmRoot: string,\n): Promise<VectorizationStatusLedgerReadResult> {\n const ledgerPath = path.join(pmRoot, VECTORIZATION_STATUS_LEDGER_PATH);\n const raw = await readFileIfExists(ledgerPath);\n if (raw === null || raw.trim().length === 0) {\n return {\n entries: {},\n embedding: null,\n warnings: [],\n };\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch {\n return {\n entries: {},\n embedding: null,\n warnings: [\"search_vectorization_status_ledger_invalid\"],\n };\n }\n\n if (\n typeof parsed !== \"object\" ||\n parsed === null ||\n (parsed as { version?: unknown }).version !== 1 ||\n !Array.isArray((parsed as { items?: unknown }).items)\n ) {\n return {\n entries: {},\n embedding: null,\n warnings: [\"search_vectorization_status_ledger_invalid\"],\n };\n }\n\n const mapped = new Map<string, string>();\n for (const entry of (parsed as { items: unknown[] }).items) {\n if (typeof entry !== \"object\" || entry === null) {\n return {\n entries: {},\n embedding: null,\n warnings: [\"search_vectorization_status_ledger_invalid\"],\n };\n }\n const id = (entry as { id?: unknown }).id;\n const updatedAt = (entry as { updated_at?: unknown }).updated_at;\n if (\n typeof id !== \"string\" ||\n id.trim().length === 0 ||\n !isValidUpdatedAt(updatedAt)\n ) {\n return {\n entries: {},\n embedding: null,\n warnings: [\"search_vectorization_status_ledger_invalid\"],\n };\n }\n mapped.set(id.trim(), updatedAt);\n }\n\n let embedding: VectorizationEmbeddingMetadata | null = null;\n try {\n embedding = normalizeVectorizationEmbeddingMetadata(\n (parsed as { embedding?: unknown }).embedding,\n );\n } catch {\n return {\n entries: {},\n embedding: null,\n warnings: [\"search_vectorization_status_ledger_invalid\"],\n };\n }\n\n return {\n entries: Object.fromEntries(\n [...mapped.entries()].sort((left, right) =>\n left[0].localeCompare(right[0]),\n ),\n ),\n embedding,\n warnings: [],\n };\n}\n\n/** Implements write vectorization status ledger for the public runtime surface of this module. */\nexport async function writeVectorizationStatusLedger(\n pmRoot: string,\n entries: Record<string, string>,\n embedding?: VectorizationEmbeddingMetadata | null,\n): Promise<void> {\n const normalizedEntries = normalizeVectorizationLedgerEntries(entries);\n const ledgerPath = path.join(pmRoot, VECTORIZATION_STATUS_LEDGER_PATH);\n const serialized = `${JSON.stringify(\n {\n version: 1,\n generated_at: nowIso(),\n ...(embedding ? { embedding } : {}),\n items: Object.entries(normalizedEntries).map(([id, updated_at]) => ({\n id,\n updated_at,\n })),\n },\n null,\n 2,\n )}\\n`;\n await writeFileAtomic(ledgerPath, serialized);\n}\n\nfunction buildVectorPayload(item: ItemMetadata): Record<string, unknown> {\n return {\n id: item.id,\n type: item.type,\n status: item.status,\n priority: item.priority,\n updated_at: item.updated_at,\n };\n}\n\ninterface SemanticRefreshRuntimeContext {\n settings: Awaited<ReturnType<typeof readSettings>>;\n provider: EmbeddingProviderConfig;\n vectorStore: VectorStoreConfig;\n}\n\ninterface SemanticRefreshWorkload {\n documents: Array<{ id: string; document: ItemDocument }>;\n missingIds: string[];\n skippedIds: string[];\n warnings: string[];\n}\n\ninterface SemanticRefreshOperationResult {\n refreshed: string[];\n skipped: string[];\n warnings: string[];\n}\n\ninterface SemanticEmbeddingOperationResult {\n vectors: number[][];\n vector_dimension: number;\n warnings: string[];\n}\n\nfunction buildVectorizationIdentityForProvider(\n provider: EmbeddingProviderConfig,\n): VectorizationEmbeddingIdentity {\n const identity = buildVectorizationEmbeddingIdentity(\n provider.name,\n provider.model,\n );\n if (!identity) {\n throw new Error(\n \"Embedding provider must include a provider name and model\",\n );\n }\n return identity;\n}\n\nfunction buildSkippedSemanticRefreshResult(\n itemIds: string[],\n warning: string,\n): SemanticMutationRefreshResult {\n return {\n refreshed: [],\n skipped: itemIds,\n warnings: [warning],\n };\n}\n\nasync function resolveSemanticRefreshRuntimeContext(\n pmRoot: string,\n normalizedItemIds: string[],\n options: SemanticRefreshOptions,\n): Promise<SemanticRefreshRuntimeContext | SemanticMutationRefreshResult> {\n if (!options.settings && !(await pathExists(getSettingsPath(pmRoot)))) {\n return buildSkippedSemanticRefreshResult(\n normalizedItemIds,\n \"search_semantic_refresh_skipped:settings_not_initialized\",\n );\n }\n\n let settings: Awaited<ReturnType<typeof readSettings>>;\n try {\n if (options.settings) {\n settings = options.settings;\n } else {\n const settingsRead = await readSettingsWithMetadata(pmRoot);\n const readFailure = settingsRead.warnings.find((warning) =>\n warning.startsWith(\"settings_read_\"),\n );\n if (readFailure) {\n return buildSkippedSemanticRefreshResult(\n normalizedItemIds,\n `search_semantic_refresh_skipped:settings_read_failed:${readFailure}`,\n );\n }\n settings = settingsRead.settings;\n }\n } catch (error: unknown) {\n return buildSkippedSemanticRefreshResult(\n normalizedItemIds,\n `search_semantic_refresh_skipped:settings_read_failed:${toErrorMessage(error)}`,\n );\n }\n const effectiveSettings = options.apply_runtime_defaults\n ? resolveSettingsWithSemanticRuntimeDefaults(settings).settings\n : settings;\n\n const provider = resolveEmbeddingProviders(effectiveSettings).active;\n if (!provider) {\n return buildSkippedSemanticRefreshResult(\n normalizedItemIds,\n \"search_semantic_refresh_skipped:provider_unconfigured\",\n );\n }\n const vectorStore = resolveVectorStores(effectiveSettings, pmRoot).active;\n if (!vectorStore) {\n return buildSkippedSemanticRefreshResult(\n normalizedItemIds,\n \"search_semantic_refresh_skipped:vector_store_unconfigured\",\n );\n }\n\n return {\n settings: effectiveSettings,\n provider,\n vectorStore,\n };\n}\n\nasync function collectSemanticRefreshWorkload(\n pmRoot: string,\n idPrefix: string,\n preferredFormat: \"toon\" | \"json_markdown\",\n normalizedItemIds: string[],\n typeToFolder: Record<string, string>,\n schema: Awaited<ReturnType<typeof readSettings>>[\"schema\"],\n): Promise<SemanticRefreshWorkload> {\n const warnings: string[] = [];\n const skipped = new Set<string>();\n const missing = new Set<string>();\n const documents: Array<{ id: string; document: ItemDocument }> = [];\n\n for (const itemId of normalizedItemIds) {\n const located = await locateItem(\n pmRoot,\n itemId,\n idPrefix,\n preferredFormat,\n typeToFolder,\n );\n if (!located) {\n missing.add(itemId);\n continue;\n }\n\n try {\n const loaded = await readLocatedItem(located, { schema });\n documents.push({\n id: loaded.document.metadata.id,\n document: loaded.document,\n });\n } catch (error: unknown) {\n skipped.add(located.id);\n warnings.push(\n `search_semantic_refresh_item_read_failed:${located.id}:${toErrorMessage(error)}`,\n );\n }\n }\n\n documents.sort((left, right) => left.id.localeCompare(right.id));\n return {\n documents,\n missingIds: toUniqueSorted(missing),\n skippedIds: toUniqueSorted(skipped),\n warnings,\n };\n}\n\nasync function embedLocatedSemanticVectors(\n settings: Awaited<ReturnType<typeof readSettings>>,\n provider: EmbeddingProviderConfig,\n documents: Array<{ id: string; document: ItemDocument }>,\n): Promise<SemanticEmbeddingOperationResult> {\n const corpusCharacterLimit = resolveSemanticCorpusCharacterLimit(\n provider.name,\n settings.search.embedding_corpus_max_characters,\n ).maxCharacters;\n const corpusFields = resolveSearchCorpusFields(settings);\n const corpusInputs = documents.map((entry) =>\n buildSemanticCorpusInput(entry.document, {\n providerName: provider.name,\n maxCharacters: corpusCharacterLimit,\n fields: corpusFields,\n }),\n );\n const embeddingResult = await executeEmbeddingBatchesWithRetry(\n provider,\n settings,\n corpusInputs,\n );\n return {\n vectors: embeddingResult.vectors,\n vector_dimension: inferConsistentVectorDimension(\n embeddingResult.vectors,\n \"Semantic refresh embedding\",\n ),\n warnings: embeddingResult.warnings,\n };\n}\n\nasync function upsertLocatedSemanticVectors(\n vectorStore: VectorStoreConfig,\n documents: Array<{ id: string; document: ItemDocument }>,\n vectors: number[][],\n): Promise<SemanticRefreshOperationResult> {\n await executeVectorUpsert(\n vectorStore,\n documents.map((entry, index) => ({\n id: entry.id,\n vector: vectors[index],\n payload: buildVectorPayload(entry.document.metadata),\n })),\n );\n return {\n refreshed: documents.map((entry) => entry.id),\n skipped: [],\n warnings: [],\n };\n}\n\nasync function resetSemanticVectorStore(\n vectorStore: VectorStoreConfig,\n ledgerEntries: Record<string, string>,\n): Promise<SemanticRefreshOperationResult> {\n try {\n await executeVectorReset(vectorStore, Object.keys(ledgerEntries));\n return { refreshed: [], skipped: [], warnings: [] };\n } catch (error: unknown) {\n return {\n refreshed: [],\n skipped: [],\n warnings: [\n `search_semantic_refresh_reset_failed:${toErrorMessage(error)}`,\n ],\n };\n }\n}\n\nasync function pruneMissingSemanticVectors(\n vectorStore: VectorStoreConfig,\n missingIds: string[],\n): Promise<SemanticRefreshOperationResult> {\n if (missingIds.length === 0) {\n return { refreshed: [], skipped: [], warnings: [] };\n }\n try {\n await executeVectorDelete(vectorStore, missingIds);\n return {\n refreshed: [],\n skipped: [],\n warnings: [],\n };\n } catch (error: unknown) {\n return {\n refreshed: [],\n skipped: missingIds,\n warnings: [\n `search_semantic_refresh_delete_failed:${toErrorMessage(error)}`,\n ],\n };\n }\n}\n\n/** Implements invalidate search cache artifacts for the public runtime surface of this module. */\nexport async function invalidateSearchCacheArtifacts(\n pmRoot: string,\n): Promise<SearchCacheInvalidationResult> {\n const invalidated: string[] = [];\n const warnings: string[] = [];\n\n for (const relativePath of SEARCH_CACHE_ARTIFACT_PATHS) {\n const artifactPath = path.join(pmRoot, relativePath);\n try {\n if (!(await pathExists(artifactPath))) {\n continue;\n }\n await removeFileIfExists(artifactPath);\n invalidated.push(relativePath);\n } catch (error: unknown) {\n warnings.push(formatInvalidationWarning(relativePath, error));\n }\n }\n\n return {\n invalidated,\n warnings,\n };\n}\n\n/** Implements refresh semantic embeddings for mutated items for the public runtime surface of this module. */\nexport async function refreshSemanticEmbeddingsForMutatedItems(\n pmRoot: string,\n itemIds: string[],\n options: SemanticRefreshOptions = {},\n): Promise<SemanticMutationRefreshResult> {\n const normalizedItemIds = toUniqueSorted(itemIds);\n if (normalizedItemIds.length === 0) {\n return {\n refreshed: [],\n skipped: [],\n warnings: [],\n };\n }\n\n const runtimeContext = await resolveSemanticRefreshRuntimeContext(\n pmRoot,\n normalizedItemIds,\n options,\n );\n if (!(\"settings\" in runtimeContext)) {\n return runtimeContext;\n }\n const typeRegistry = resolveItemTypeRegistry(\n runtimeContext.settings,\n getActiveExtensionRegistrations(),\n );\n const workload = await collectSemanticRefreshWorkload(\n pmRoot,\n runtimeContext.settings.id_prefix,\n runtimeContext.settings.item_format,\n normalizedItemIds,\n typeRegistry.type_to_folder,\n runtimeContext.settings.schema,\n );\n const ledgerRead =\n workload.documents.length > 0 || workload.missingIds.length > 0\n ? await readVectorizationStatusLedger(pmRoot)\n : { entries: {}, embedding: null, warnings: [] };\n const embeddingIdentity = buildVectorizationIdentityForProvider(\n runtimeContext.provider,\n );\n const nextLedgerBaseEntries = ledgerRead.entries;\n let refreshedResult: SemanticRefreshOperationResult = {\n refreshed: [],\n skipped: [],\n warnings: [],\n };\n let nextEmbeddingMetadata = ledgerRead.embedding;\n if (workload.documents.length > 0) {\n if (\n ledgerRead.embedding &&\n hasVectorizationEmbeddingIdentityChanged(\n ledgerRead.embedding,\n embeddingIdentity,\n )\n ) {\n refreshedResult = {\n refreshed: [],\n skipped: workload.documents.map((entry) => entry.id),\n warnings: [\n \"search_semantic_refresh_requires_reindex:embedding_identity_changed\",\n ],\n };\n } else {\n try {\n const embedded = await embedLocatedSemanticVectors(\n runtimeContext.settings,\n runtimeContext.provider,\n workload.documents,\n );\n if (\n hasVectorizationVectorDimensionChanged(\n ledgerRead.embedding,\n embedded.vector_dimension,\n )\n ) {\n refreshedResult = {\n refreshed: [],\n skipped: workload.documents.map((entry) => entry.id),\n warnings: [\n ...embedded.warnings,\n \"search_semantic_refresh_requires_reindex:vector_dimension_changed\",\n ],\n };\n } else {\n nextEmbeddingMetadata = buildVectorizationEmbeddingMetadata(\n embeddingIdentity,\n embedded.vector_dimension,\n );\n const upserted = await upsertLocatedSemanticVectors(\n runtimeContext.vectorStore,\n workload.documents,\n embedded.vectors,\n );\n refreshedResult = {\n refreshed: upserted.refreshed,\n skipped: upserted.skipped,\n warnings: [...embedded.warnings, ...upserted.warnings],\n };\n }\n } catch (error: unknown) {\n refreshedResult = {\n refreshed: [],\n skipped: workload.documents.map((entry) => entry.id),\n warnings: [`search_semantic_refresh_failed:${toErrorMessage(error)}`],\n };\n }\n }\n }\n const pruneResult = await pruneMissingSemanticVectors(\n runtimeContext.vectorStore,\n workload.missingIds,\n );\n const refreshedIdSet = new Set(refreshedResult.refreshed);\n const refreshedEntries = Object.fromEntries(\n workload.documents\n .filter((entry) => refreshedIdSet.has(entry.id))\n .map((entry) => [entry.id, entry.document.metadata.updated_at]),\n );\n const ledgerWarnings: string[] = [];\n if (\n Object.keys(refreshedEntries).length > 0 ||\n workload.missingIds.length > 0\n ) {\n const nextEntries = {\n ...nextLedgerBaseEntries,\n ...normalizeVectorizationLedgerEntries(refreshedEntries),\n };\n for (const missingId of workload.missingIds) {\n delete nextEntries[missingId];\n }\n try {\n await writeVectorizationStatusLedger(\n pmRoot,\n nextEntries,\n nextEmbeddingMetadata,\n );\n } catch (error: unknown) {\n ledgerWarnings.push(\n `search_vectorization_status_ledger_write_failed:${toErrorMessage(error)}`,\n );\n }\n ledgerWarnings.push(...ledgerRead.warnings);\n }\n\n return {\n refreshed: toUniqueSorted([\n ...refreshedResult.refreshed,\n ...pruneResult.refreshed,\n ]),\n skipped: toUniqueSorted([\n ...workload.skippedIds,\n ...refreshedResult.skipped,\n ...pruneResult.skipped,\n ]),\n warnings: [\n ...workload.warnings,\n ...refreshedResult.warnings,\n ...pruneResult.warnings,\n ...ledgerWarnings,\n ],\n };\n}\n\n/** Returns true when a semantic embedding refresh would do real work for these settings (an embedding provider AND a vector store both resolve). Used to decide whether a mutation's refresh is worth dispatching to a background worker — when semantic search is not configured the inline path is already a fast no-op and no child is spawned. */\nexport function isSemanticRefreshActive(\n settings: Awaited<ReturnType<typeof readSettings>>,\n applyRuntimeDefaults: boolean,\n): boolean {\n const effectiveSettings = applyRuntimeDefaults\n ? resolveSettingsWithSemanticRuntimeDefaults(settings).settings\n : settings;\n return Boolean(\n resolveEmbeddingProviders(effectiveSettings).active &&\n resolveVectorStores(effectiveSettings).active,\n );\n}\n\n/** Implements refresh search artifacts for mutation for the public runtime surface of this module. */\nexport async function refreshSearchArtifactsForMutation(\n pmRoot: string,\n itemIds: string[],\n options: RefreshSearchArtifactsForMutationOptions = {},\n): Promise<SearchMutationArtifactRefreshResult> {\n const invalidation = await invalidateSearchCacheArtifacts(pmRoot);\n const normalizedItemIds = toUniqueSorted(itemIds);\n if (normalizedItemIds.length === 0) {\n return {\n invalidated: invalidation.invalidated,\n refreshed: [],\n skipped: [],\n warnings: invalidation.warnings,\n };\n }\n\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n const semanticRefresh = await refreshSemanticEmbeddingsForMutatedItems(\n pmRoot,\n normalizedItemIds,\n );\n return {\n invalidated: invalidation.invalidated,\n refreshed: semanticRefresh.refreshed,\n skipped: semanticRefresh.skipped,\n warnings: [...invalidation.warnings, ...semanticRefresh.warnings],\n };\n }\n\n let settings: Awaited<ReturnType<typeof readSettings>>;\n try {\n const settingsRead = await readSettingsWithMetadata(pmRoot);\n const readFailure = settingsRead.warnings.find((warning) =>\n warning.startsWith(\"settings_read_\"),\n );\n if (readFailure) {\n return {\n invalidated: invalidation.invalidated,\n refreshed: [],\n skipped: normalizedItemIds,\n warnings: [\n ...invalidation.warnings,\n `search_semantic_refresh_skipped:settings_read_failed:${readFailure}`,\n ],\n };\n }\n settings = settingsRead.settings;\n } catch (error: unknown) {\n return {\n invalidated: invalidation.invalidated,\n refreshed: [],\n skipped: normalizedItemIds,\n warnings: [\n ...invalidation.warnings,\n `search_semantic_refresh_skipped:settings_read_failed:${toErrorMessage(error)}`,\n ],\n };\n }\n\n if (settings.search.mutation_refresh_policy === \"cache_only\") {\n return {\n invalidated: invalidation.invalidated,\n refreshed: [],\n skipped: normalizedItemIds,\n warnings: invalidation.warnings,\n };\n }\n\n const applyRuntimeDefaults =\n settings.search.mutation_refresh_policy === \"semantic_auto\";\n\n // Keyword cache is already invalidated synchronously above (so keyword search\n // stays immediately correct). When requested, dispatch the slow embedding\n // refresh to a detached worker so the mutation returns instantly; the\n // vector_index_stale health/search warning covers the catch-up window.\n if (\n options.background &&\n isSemanticRefreshActive(settings, applyRuntimeDefaults)\n ) {\n await scheduleBackgroundSemanticRefresh(pmRoot, normalizedItemIds);\n return {\n invalidated: invalidation.invalidated,\n refreshed: [],\n skipped: [],\n warnings: [\n ...invalidation.warnings,\n \"search_semantic_refresh_scheduled_background\",\n ],\n scheduled: true,\n };\n }\n\n const semanticRefresh = await refreshSemanticEmbeddingsForMutatedItems(\n pmRoot,\n normalizedItemIds,\n {\n settings,\n apply_runtime_defaults: applyRuntimeDefaults,\n },\n );\n return {\n invalidated: invalidation.invalidated,\n refreshed: semanticRefresh.refreshed,\n skipped: semanticRefresh.skipped,\n warnings: [...invalidation.warnings, ...semanticRefresh.warnings],\n };\n}\n\n/** Public contract for test only, shared by SDK and presentation-layer consumers. */\nexport const _testOnly = {\n buildSkippedSemanticRefreshResult,\n buildVectorizationIdentityForProvider,\n normalizeVectorizationLedgerEntries,\n resetSemanticVectorStore,\n};\n"],"names":[],"mappings":"AAAA;;;;GAIG;;;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAEL,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,mCAAmC,GACpC,MAAM,aAAa,CAAC;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CAAC;QACD,MAAM,iCAAiC,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;QACnE,OAAO;YACL,WAAW,EAAE,YAAY,CAAC,WAAW;YACrC,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;YACX,QAAQ,EAAE;gBACR,GAAG,YAAY,CAAC,QAAQ;gBACxB,8CAA8C;aAC/C;YACD,SAAS,EAAE,IAAI;SAChB,CAAC;IACJ,CAAC;IAED,MAAM,eAAe,GAAG,MAAM,wCAAwC,CACpE,MAAM,EACN,iBAAiB,EACjB;QACE,QAAQ;QACR,sBAAsB,EAAE,oBAAoB;KAC7C,CACF,CAAC;IACF,OAAO;QACL,WAAW,EAAE,YAAY,CAAC,WAAW;QACrC,SAAS,EAAE,eAAe,CAAC,SAAS;QACpC,OAAO,EAAE,eAAe,CAAC,OAAO;QAChC,QAAQ,EAAE,CAAC,GAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,eAAe,CAAC,QAAQ,CAAC;KAClE,CAAC;AACJ,CAAC;AAED,qFAAqF;AACrF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,iCAAiC;IACjC,qCAAqC;IACrC,mCAAmC;IACnC,wBAAwB;CACzB,CAAC","debugId":"64ce81f6-7bac-5243-8391-ccc808cd2dfc"}
|
|
@@ -28,6 +28,8 @@ export declare const PM_OPTIONAL_TYPE_SUBDIRS: readonly ["decisions", "events",
|
|
|
28
28
|
export declare const PM_REQUIRED_SUBDIRS: readonly ["", "epics", "features", "tasks", "chores", "issues", "schema", "history", "search", "extensions", "locks", "decisions", "events", "reminders", "milestones", "meetings", "plans"];
|
|
29
29
|
/** Public contract for type to folder, shared by SDK and presentation-layer consumers. */
|
|
30
30
|
export declare const TYPE_TO_FOLDER: Record<BuiltinItemType, string>;
|
|
31
|
+
/** Portable project-context fields shared by storage order and structured mutation IO. */
|
|
32
|
+
export declare const ITEM_PROJECT_CONTEXT_KEYS: readonly ["goal", "objective", "value", "impact", "outcome", "why_now", "parent", "reviewer", "risk", "confidence", "sprint", "release", "blocked_by", "blocked_reason", "unblock_note", "reporter", "severity", "environment", "repro_steps", "resolution", "expected_result", "actual_result"];
|
|
31
33
|
/** Public contract for item metadata key order, shared by SDK and presentation-layer consumers. */
|
|
32
34
|
export declare const ITEM_METADATA_KEY_ORDER: ReadonlyArray<string>;
|
|
33
35
|
type BuiltinGovernancePreset = Exclude<GovernancePreset, "custom">;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!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]="
|
|
2
|
+
!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]="3f35f57d-c4cd-5508-8860-c6bcd0d56eeb")}catch(e){}}();
|
|
3
3
|
import { createDefaultExtensionGovernancePolicy } from "../extensions/extension-types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Canonical default lifecycle status model and workflow role mapping.
|
|
@@ -93,6 +93,31 @@ export const TYPE_TO_FOLDER = {
|
|
|
93
93
|
Meeting: "meetings",
|
|
94
94
|
Plan: "plans",
|
|
95
95
|
};
|
|
96
|
+
/** Portable project-context fields shared by storage order and structured mutation IO. */
|
|
97
|
+
export const ITEM_PROJECT_CONTEXT_KEYS = [
|
|
98
|
+
"goal",
|
|
99
|
+
"objective",
|
|
100
|
+
"value",
|
|
101
|
+
"impact",
|
|
102
|
+
"outcome",
|
|
103
|
+
"why_now",
|
|
104
|
+
"parent",
|
|
105
|
+
"reviewer",
|
|
106
|
+
"risk",
|
|
107
|
+
"confidence",
|
|
108
|
+
"sprint",
|
|
109
|
+
"release",
|
|
110
|
+
"blocked_by",
|
|
111
|
+
"blocked_reason",
|
|
112
|
+
"unblock_note",
|
|
113
|
+
"reporter",
|
|
114
|
+
"severity",
|
|
115
|
+
"environment",
|
|
116
|
+
"repro_steps",
|
|
117
|
+
"resolution",
|
|
118
|
+
"expected_result",
|
|
119
|
+
"actual_result",
|
|
120
|
+
];
|
|
96
121
|
/** Public contract for item metadata key order, shared by SDK and presentation-layer consumers. */
|
|
97
122
|
export const ITEM_METADATA_KEY_ORDER = [
|
|
98
123
|
"id",
|
|
@@ -120,28 +145,7 @@ export const ITEM_METADATA_KEY_ORDER = [
|
|
|
120
145
|
"external_ref",
|
|
121
146
|
"definition_of_ready",
|
|
122
147
|
"order",
|
|
123
|
-
|
|
124
|
-
"objective",
|
|
125
|
-
"value",
|
|
126
|
-
"impact",
|
|
127
|
-
"outcome",
|
|
128
|
-
"why_now",
|
|
129
|
-
"parent",
|
|
130
|
-
"reviewer",
|
|
131
|
-
"risk",
|
|
132
|
-
"confidence",
|
|
133
|
-
"sprint",
|
|
134
|
-
"release",
|
|
135
|
-
"blocked_by",
|
|
136
|
-
"blocked_reason",
|
|
137
|
-
"unblock_note",
|
|
138
|
-
"reporter",
|
|
139
|
-
"severity",
|
|
140
|
-
"environment",
|
|
141
|
-
"repro_steps",
|
|
142
|
-
"resolution",
|
|
143
|
-
"expected_result",
|
|
144
|
-
"actual_result",
|
|
148
|
+
...ITEM_PROJECT_CONTEXT_KEYS,
|
|
145
149
|
"affected_version",
|
|
146
150
|
"fixed_version",
|
|
147
151
|
"component",
|
|
@@ -414,6 +418,7 @@ export const TELEMETRY_ERROR_CATEGORY_BY_CODE = Object.freeze({
|
|
|
414
418
|
lock_conflict: "conflict",
|
|
415
419
|
terminal_state_conflict: "conflict",
|
|
416
420
|
dependency_failed: "runtime",
|
|
421
|
+
merge_git_config_unwritable: "runtime",
|
|
417
422
|
command_failed: "runtime",
|
|
418
423
|
unknown_error: "runtime",
|
|
419
424
|
});
|
|
@@ -445,4 +450,4 @@ export function resolveTelemetryErrorCategory(errorCode) {
|
|
|
445
450
|
return "unknown";
|
|
446
451
|
}
|
|
447
452
|
//# sourceMappingURL=constants.js.map
|
|
448
|
-
//# debugId=
|
|
453
|
+
//# debugId=3f35f57d-c4cd-5508-8860-c6bcd0d56eeb
|