@remnic/core 9.65.8 → 9.66.1
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/dist/access-admin-ops-surface.d.ts +11 -12
- package/dist/access-admin-ops-surface.js +54 -51
- package/dist/access-authorization-probe.d.ts +11 -12
- package/dist/access-authorization-probe.js +55 -52
- package/dist/access-boundary.d.ts +11 -12
- package/dist/access-boundary.js +54 -51
- package/dist/access-citation-namespace.js +3 -3
- package/dist/access-cli.js +132 -125
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.d.ts +1 -2
- package/dist/access-coding-context-resolution.js +2 -2
- package/dist/access-extraction-force-flush.d.ts +11 -12
- package/dist/access-extraction-force-flush.js +54 -51
- package/dist/access-health-types.d.ts +1 -2
- package/dist/access-http-lcm-compaction.d.ts +11 -12
- package/dist/access-http-lifecycle-flush.d.ts +11 -12
- package/dist/access-http-offline-stream.d.ts +11 -12
- package/dist/access-http-query.d.ts +2 -3
- package/dist/access-http-query.js +56 -53
- package/dist/access-http.d.ts +12 -13
- package/dist/access-http.js +77 -74
- package/dist/access-identity-continuity-surface.d.ts +9 -10
- package/dist/access-identity-continuity-surface.js +54 -51
- package/dist/access-lcm-surface.d.ts +11 -12
- package/dist/access-lcm-surface.js +54 -51
- package/dist/access-mcp-output-schemas.js +1 -1
- package/dist/access-mcp.d.ts +11 -12
- package/dist/access-mcp.js +67 -64
- package/dist/access-memory-search-fanout.d.ts +2 -3
- package/dist/{access-namespace-preflight-CpAOrS-9.d.ts → access-namespace-preflight-50VIkPhB.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -4
- package/dist/access-namespace-preflight.js +54 -51
- package/dist/access-observe-write-surface.d.ts +11 -12
- package/dist/access-observe-write-surface.js +54 -51
- package/dist/access-offline-manifest.d.ts +9 -10
- package/dist/access-offline-manifest.js +15 -15
- package/dist/access-operations-batch.js +59 -56
- package/dist/access-operations.d.ts +12 -13
- package/dist/access-operations.js +64 -61
- package/dist/access-recall-concurrency.d.ts +11 -12
- package/dist/access-recall-concurrency.js +54 -51
- package/dist/access-recall-response.d.ts +11 -12
- package/dist/access-recall-response.js +54 -51
- package/dist/access-recall-surface.d.ts +11 -12
- package/dist/access-recall-surface.js +54 -51
- package/dist/access-schema.d.ts +12 -12
- package/dist/access-schema.js +5 -5
- package/dist/{access-service-Diu61Cfv.d.ts → access-service-C2tV2-uL.d.ts} +8 -8
- package/dist/access-service-helpers.d.ts +11 -12
- package/dist/access-service.d.ts +11 -12
- package/dist/access-service.js +54 -51
- package/dist/access-surface-catalog.d.ts +11 -12
- package/dist/access-surface-catalog.js +58 -53
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/access-wearables-meetings-surface.d.ts +3 -4
- package/dist/action-confidence.d.ts +1 -2
- package/dist/active-memory-bridge.d.ts +1 -2
- package/dist/active-memory-bridge.js +2 -2
- package/dist/active-recall.d.ts +1 -2
- package/dist/active-recall.js +11 -11
- package/dist/adapters/index.js +7 -7
- package/dist/adapters/registry.js +3 -3
- package/dist/ambient-provenance.d.ts +1 -2
- package/dist/artifact-search.d.ts +1 -2
- package/dist/{auto-sync-2YPITIWN.js → auto-sync-Q6Q2FVSC.js} +9 -9
- package/dist/behavior-learner.d.ts +1 -2
- package/dist/behavior-signals.d.ts +1 -2
- package/dist/bootstrap.d.ts +9 -10
- package/dist/briefing-window.d.ts +2 -3
- package/dist/briefing.d.ts +2 -3
- package/dist/briefing.js +28 -28
- package/dist/buffer-surprise-report.d.ts +1 -2
- package/dist/buffer-turn-helpers.d.ts +1 -2
- package/dist/buffer.d.ts +2 -3
- package/dist/buffer.js +20 -4
- package/dist/bulk-import/index.d.ts +3 -4
- package/dist/calibration.d.ts +1 -2
- package/dist/calibration.js +1 -1
- package/dist/capabilities.d.ts +1 -2
- package/dist/{capsule-merge-SGIVB3WA.js → capsule-merge-SEHERWWP.js} +4 -4
- package/dist/{catalog-9f-vEQLS.d.ts → catalog-C2jA-gLm.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -2
- package/dist/causal-consolidation.d.ts +1 -2
- package/dist/causal-consolidation.js +29 -29
- package/dist/causal-trajectory-graph.d.ts +1 -2
- package/dist/{chunk-LEPOP46W.js → chunk-227UFSEQ.js} +4 -4
- package/dist/{chunk-TFR3HG4K.js → chunk-2FA7U5XY.js} +4 -4
- package/dist/{chunk-PO7NXBG2.js → chunk-2GF27PGH.js} +5 -5
- package/dist/{chunk-W2BAGGEW.js → chunk-2ITZ74A6.js} +40 -31
- package/dist/{chunk-W2BAGGEW.js.map → chunk-2ITZ74A6.js.map} +1 -1
- package/dist/{chunk-MY2BC6UE.js → chunk-2X6BGKQL.js} +11 -11
- package/dist/{chunk-UEBDCMOO.js → chunk-3TSU662L.js} +3 -3
- package/dist/{chunk-XAB6STPO.js → chunk-46XR5FNZ.js} +53 -3
- package/dist/chunk-46XR5FNZ.js.map +1 -0
- package/dist/{chunk-FP7YTTVO.js → chunk-4OFKZAJG.js} +2 -1
- package/dist/chunk-4OFKZAJG.js.map +1 -0
- package/dist/{chunk-S5XOSTYM.js → chunk-4XLTUR6R.js} +3 -3
- package/dist/{chunk-BWGCOLEL.js → chunk-65JOGLIS.js} +2 -2
- package/dist/{chunk-HMZKGHMD.js → chunk-7UOXCCCI.js} +3 -3
- package/dist/{chunk-7WOWGRAU.js → chunk-AF5H7TKI.js} +108 -23
- package/dist/chunk-AF5H7TKI.js.map +1 -0
- package/dist/{chunk-7BDZTALN.js → chunk-AJTG3CP7.js} +12 -2
- package/dist/chunk-AJTG3CP7.js.map +1 -0
- package/dist/{chunk-2LWQSV6A.js → chunk-AL3UYZ5N.js} +3 -2
- package/dist/chunk-AL3UYZ5N.js.map +1 -0
- package/dist/{chunk-4F4AQFWL.js → chunk-B4AOWRYF.js} +10 -10
- package/dist/{chunk-ODU2CNNX.js → chunk-C5IUOBCN.js} +2 -2
- package/dist/{chunk-3A2NJP2U.js → chunk-CHGG74CY.js} +3 -3
- package/dist/{chunk-76DIF5KT.js → chunk-CX4OLNIH.js} +2 -2
- package/dist/{chunk-Z3YEGSR4.js → chunk-D3UXGE5D.js} +10 -10
- package/dist/{chunk-5HK3CJAR.js → chunk-D6Q5EPOV.js} +2 -2
- package/dist/{chunk-EGBDFJ36.js → chunk-DD5JFCWM.js} +2 -2
- package/dist/{chunk-XBGHAAKR.js → chunk-DDX6KIXF.js} +2 -2
- package/dist/{chunk-JIYDRBVZ.js → chunk-DJORULH3.js} +2 -2
- package/dist/{chunk-7KQB4EBS.js → chunk-DUAJKRR2.js} +2 -2
- package/dist/{chunk-XDL5CYZN.js → chunk-EEOUMG3J.js} +2 -1
- package/dist/{chunk-XDL5CYZN.js.map → chunk-EEOUMG3J.js.map} +1 -1
- package/dist/{chunk-Q57GOHLF.js → chunk-EGALNSZ4.js} +3 -3
- package/dist/{chunk-DPCXDG7G.js → chunk-EH65UV2Z.js} +2 -2
- package/dist/{chunk-KCT36JAW.js → chunk-ESNFSSO4.js} +2 -2
- package/dist/{chunk-XQ3HXAQH.js → chunk-ET2CNMLD.js} +4 -4
- package/dist/{chunk-TUHBYJXL.js → chunk-EWKVYCFP.js} +1 -1
- package/dist/{chunk-NPFUNWNX.js → chunk-FFUMTH27.js} +2 -2
- package/dist/{chunk-3PKAS6VL.js → chunk-GAJK3DQ5.js} +2 -2
- package/dist/{chunk-DA7ITC5Z.js → chunk-GBEOUCBB.js} +2 -2
- package/dist/{chunk-UENKPWCS.js → chunk-H2IRSXZN.js} +6 -6
- package/dist/{chunk-CFVTRUR3.js → chunk-H6RSANGQ.js} +2 -2
- package/dist/chunk-HVAEXYPL.js +98 -0
- package/dist/chunk-HVAEXYPL.js.map +1 -0
- package/dist/{chunk-EUYWQ7TS.js → chunk-IEZ6CGTW.js} +2 -2
- package/dist/{chunk-3SZD4CYO.js → chunk-IGZCAHFL.js} +3 -3
- package/dist/{chunk-UPFNQJC7.js → chunk-INUBU6I5.js} +2 -2
- package/dist/{chunk-PMVPCZJZ.js → chunk-J2R275FN.js} +3 -3
- package/dist/{chunk-UW5NPZJ2.js → chunk-JALOAKSZ.js} +59 -7
- package/dist/chunk-JALOAKSZ.js.map +1 -0
- package/dist/{chunk-2QSZNTDO.js → chunk-JBPKEARU.js} +7 -7
- package/dist/{chunk-3BCULS4U.js → chunk-JKTV3JNX.js} +145 -507
- package/dist/chunk-JKTV3JNX.js.map +1 -0
- package/dist/{chunk-5ACCD4L7.js → chunk-JRRQ747T.js} +7 -7
- package/dist/{chunk-V4IDF3EZ.js → chunk-JTWZKNUH.js} +5 -5
- package/dist/{chunk-AZMLH5UT.js → chunk-KI64TTBL.js} +2 -2
- package/dist/{chunk-DEACDKE3.js → chunk-KJXCD7VR.js} +112 -87
- package/dist/chunk-KJXCD7VR.js.map +1 -0
- package/dist/chunk-LJABGXC4.js +267 -0
- package/dist/chunk-LJABGXC4.js.map +1 -0
- package/dist/{chunk-NPIBN2VL.js → chunk-LK4TOYPU.js} +2 -2
- package/dist/{chunk-UTQUEHC7.js → chunk-LUDBXTBJ.js} +8 -8
- package/dist/{chunk-PU56CXZA.js → chunk-LYUUA6QB.js} +2 -2
- package/dist/{chunk-P36Z4JRA.js → chunk-M5ERTI4I.js} +2 -2
- package/dist/{chunk-LDKPDODJ.js → chunk-ME35HVDJ.js} +2 -2
- package/dist/{chunk-773TRRGT.js → chunk-MJUCDM3C.js} +2 -2
- package/dist/{chunk-OXRRJXPR.js → chunk-MUEGIKKY.js} +476 -1796
- package/dist/chunk-MUEGIKKY.js.map +1 -0
- package/dist/{chunk-AHPIFKNG.js → chunk-N4F7ZSSG.js} +2 -2
- package/dist/{chunk-JOZUBF4A.js → chunk-NACLNNFQ.js} +2 -2
- package/dist/{chunk-LC2BDILZ.js → chunk-NBP4EX5N.js} +2 -2
- package/dist/{chunk-T7XP6IZE.js → chunk-NFP4KPTA.js} +2 -2
- package/dist/{chunk-ZVPVTPGI.js → chunk-NNZFPYYX.js} +4 -4
- package/dist/{chunk-LPNCR4QK.js → chunk-NSTNGMSS.js} +14 -14
- package/dist/{chunk-5RWZH6PH.js → chunk-NUF7VSEX.js} +2 -2
- package/dist/{chunk-7VZFRUQU.js → chunk-O7ERGZDA.js} +5 -5
- package/dist/{chunk-HSZMX3ZJ.js → chunk-ODW5GDFE.js} +2 -2
- package/dist/{chunk-5DHKCO52.js → chunk-OJUEUQDJ.js} +2 -2
- package/dist/{chunk-LOXHYCVS.js → chunk-OMX6TKXH.js} +2 -2
- package/dist/{chunk-J2WC5LF4.js → chunk-QBC33MPY.js} +2 -1
- package/dist/{chunk-SEEJOGQX.js → chunk-QBNE55VA.js} +4 -4
- package/dist/chunk-QJCWK2A7.js +1466 -0
- package/dist/chunk-QJCWK2A7.js.map +1 -0
- package/dist/{chunk-YEUXERJ6.js → chunk-RDGKVH6T.js} +7 -3
- package/dist/{chunk-YEUXERJ6.js.map → chunk-RDGKVH6T.js.map} +1 -1
- package/dist/{chunk-JYSN42VN.js → chunk-RPIS5FQ7.js} +237 -183
- package/dist/chunk-RPIS5FQ7.js.map +1 -0
- package/dist/{chunk-F7XUD3PL.js → chunk-S4CDUXQY.js} +2 -2
- package/dist/{chunk-WNXYT4MK.js → chunk-S4Z2OBTX.js} +4 -4
- package/dist/{chunk-UL4MKZHI.js → chunk-SN4JXNLL.js} +2 -2
- package/dist/{chunk-CAMNRAJF.js → chunk-SZMYGDSM.js} +2 -2
- package/dist/chunk-TB2MJRI6.js +866 -0
- package/dist/chunk-TB2MJRI6.js.map +1 -0
- package/dist/{chunk-XNWXSGHS.js → chunk-TBCDF556.js} +28 -10
- package/dist/chunk-TBCDF556.js.map +1 -0
- package/dist/{chunk-LKYIOCWL.js → chunk-TCF4MU7L.js} +967 -132
- package/dist/chunk-TCF4MU7L.js.map +1 -0
- package/dist/chunk-TCQRIIIN.js +202 -0
- package/dist/chunk-TCQRIIIN.js.map +1 -0
- package/dist/{chunk-7PHI6GUI.js → chunk-TEZ2HTC7.js} +42 -2
- package/dist/chunk-TEZ2HTC7.js.map +1 -0
- package/dist/{chunk-CPA5NBHN.js → chunk-TNGH4ZYI.js} +2 -2
- package/dist/{chunk-F3NVYTTA.js → chunk-TNXNECAN.js} +6 -6
- package/dist/{chunk-BEC4YBNA.js → chunk-TVW4C7PV.js} +2 -2
- package/dist/{chunk-UFKPQBXH.js → chunk-U62OK7BB.js} +2 -2
- package/dist/{chunk-KZIF6XHX.js → chunk-U65VJSCJ.js} +32 -19
- package/dist/chunk-U65VJSCJ.js.map +1 -0
- package/dist/{chunk-4QEYREAV.js → chunk-U6NGKS32.js} +8 -8
- package/dist/{chunk-HRHO3ZNG.js → chunk-UW4RYPWC.js} +2 -2
- package/dist/{chunk-AX7UXCHJ.js → chunk-UYA36DQ7.js} +2 -1
- package/dist/chunk-UYA36DQ7.js.map +1 -0
- package/dist/{chunk-T6ILXUAH.js → chunk-VG4SSPAW.js} +2 -2
- package/dist/chunk-VOSWUO3K.js +100 -0
- package/dist/chunk-VOSWUO3K.js.map +1 -0
- package/dist/chunk-WFCWP4XU.js +17 -0
- package/dist/chunk-WFCWP4XU.js.map +1 -0
- package/dist/{chunk-H2YSH3DG.js → chunk-WKAXBXVA.js} +2 -2
- package/dist/{chunk-SXIMQLGV.js → chunk-WVGXCBOC.js} +2 -2
- package/dist/{chunk-UNUMFURP.js → chunk-X5PIDJ3L.js} +3 -3
- package/dist/{chunk-CRML27CO.js → chunk-X5YYSAZX.js} +4 -4
- package/dist/{chunk-FZEEWOI2.js → chunk-XJJYSX6F.js} +2 -2
- package/dist/{chunk-U7EW2W4W.js → chunk-XKNHFDTT.js} +26 -6
- package/dist/chunk-XKNHFDTT.js.map +1 -0
- package/dist/{chunk-OA2O2GJ4.js → chunk-XOHYGIWF.js} +3 -3
- package/dist/{chunk-UG6VXIOK.js → chunk-XSTNGNJP.js} +2 -2
- package/dist/{chunk-MINHJ55X.js → chunk-XXW32OL7.js} +1 -1
- package/dist/{chunk-MINHJ55X.js.map → chunk-XXW32OL7.js.map} +1 -1
- package/dist/{chunk-YDPAE2RD.js → chunk-YFLLGRXO.js} +2 -2
- package/dist/{chunk-MDD2RINF.js → chunk-YWPLOJ7T.js} +3 -3
- package/dist/{chunk-Q4WONDMJ.js → chunk-YYGZJPOK.js} +2 -2
- package/dist/{chunk-GTO56JY5.js → chunk-ZPS724LT.js} +2 -2
- package/dist/{chunk-SNOIKAHM.js → chunk-ZZZWEDF4.js} +3 -3
- package/dist/{cli-O3F-ht3i.d.ts → cli-CsfFMe6n.d.ts} +5 -5
- package/dist/cli.d.ts +13 -14
- package/dist/cli.js +101 -96
- package/dist/coding/export-okf-codegraph.d.ts +56 -0
- package/dist/coding/export-okf-codegraph.js +526 -0
- package/dist/coding/export-okf-codegraph.js.map +1 -0
- package/dist/coding/pre-action-gate.d.ts +1 -2
- package/dist/compounding/engine.d.ts +2 -3
- package/dist/compounding/engine.js +29 -29
- package/dist/compounding/preference-consolidator.d.ts +1 -2
- package/dist/compression-optimizer.d.ts +1 -2
- package/dist/config.d.ts +1 -2
- package/dist/config.js +11 -11
- package/dist/connectors/codex-materialize-runner.d.ts +1 -2
- package/dist/connectors/codex-materialize-runner.js +28 -28
- package/dist/connectors/codex-materialize.d.ts +1 -2
- package/dist/connectors/index.d.ts +1 -2
- package/dist/connectors/index.js +28 -28
- package/dist/consolidation-provenance-check.d.ts +2 -3
- package/dist/consolidation-provenance-check.js +4 -4
- package/dist/consolidation-undo.d.ts +2 -3
- package/dist/consolidation-undo.js +3 -3
- package/dist/contradiction/index.d.ts +3 -4
- package/dist/contradiction/index.js +9 -9
- package/dist/{contradiction-scan-AKUWPX5N.js → contradiction-scan-NOYMFG66.js} +3 -3
- package/dist/converge-config.d.ts +1 -2
- package/dist/convergence-refresh.d.ts +2 -3
- package/dist/convergence-refresh.js +30 -30
- package/dist/conversation-index/backend.d.ts +1 -2
- package/dist/conversation-index/backend.js +2 -2
- package/dist/conversation-index/chunker.d.ts +1 -2
- package/dist/conversation-index/faiss-adapter.d.ts +1 -2
- package/dist/conversation-index/indexer.d.ts +1 -2
- package/dist/conversation-index/search.d.ts +1 -2
- package/dist/corpus-watermark.d.ts +1 -2
- package/dist/corpus-watermark.js +30 -30
- package/dist/cross-lingual-recall.d.ts +1 -2
- package/dist/day-summary.d.ts +1 -2
- package/dist/delinearize.d.ts +1 -2
- package/dist/dependency-propagation-config.d.ts +1 -2
- package/dist/{dependency-propagation-delivery-CL6RWXTA.d.ts → dependency-propagation-delivery-D4WMbOwA.d.ts} +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -2
- package/dist/direct-answer.d.ts +1 -2
- package/dist/embedding-fallback.d.ts +1 -2
- package/dist/enrichment/index.d.ts +1 -2
- package/dist/entity-origin-fields.d.ts +1 -2
- package/dist/entity-retrieval.d.ts +2 -3
- package/dist/entity-retrieval.js +28 -28
- package/dist/entity-schema.d.ts +1 -2
- package/dist/episodic-context.d.ts +1 -2
- package/dist/eval-trajectory-contracts.d.ts +1 -2
- package/dist/eval-trajectory-store.d.ts +1 -2
- package/dist/eval-trajectory.d.ts +1 -2
- package/dist/explicit-capture.d.ts +9 -10
- package/dist/explicit-capture.js +11 -11
- package/dist/external-wiki-access.d.ts +11 -12
- package/dist/external-wiki-access.js +55 -52
- package/dist/external-wiki-collection-registration.d.ts +1 -2
- package/dist/external-wiki-collection.d.ts +1 -2
- package/dist/external-wiki-mcp-tools.d.ts +11 -12
- package/dist/extraction-error-classification.d.ts +1 -2
- package/dist/extraction-faithfulness.d.ts +1 -2
- package/dist/extraction-faithfulness.js +2 -2
- package/dist/extraction-judge-telemetry.d.ts +1 -2
- package/dist/extraction-judge-training.d.ts +1 -2
- package/dist/extraction-judge.d.ts +1 -2
- package/dist/extraction-judge.js +2 -2
- package/dist/extraction-liveness.d.ts +1 -2
- package/dist/extraction-normalization.d.ts +1 -2
- package/dist/extraction-prompt.d.ts +1 -2
- package/dist/extraction-source-grounding-rules.d.ts +1 -2
- package/dist/extraction-source-grounding.d.ts +1 -2
- package/dist/extraction.d.ts +1 -2
- package/dist/extraction.js +37 -34
- package/dist/fallback-llm.d.ts +7 -2
- package/dist/fallback-llm.js +1 -1
- package/dist/{first-start-migration-4NETATFF.js → first-start-migration-KHIMCBIC.js} +3 -3
- package/dist/graph-dashboard-diff.d.ts +1 -2
- package/dist/graph-dashboard-key.d.ts +1 -2
- package/dist/graph-dashboard-parser.d.ts +1 -2
- package/dist/graph-edge-reinforcement.d.ts +1 -2
- package/dist/graph-path-reconstruction.d.ts +1 -2
- package/dist/graph-path-scoring.d.ts +1 -2
- package/dist/graph-snapshot.d.ts +1 -2
- package/dist/graph.d.ts +1 -2
- package/dist/harmonic-retrieval.js +1 -1
- package/dist/importance.d.ts +1 -2
- package/dist/importers/index.d.ts +1 -2
- package/dist/in-flight-reads.d.ts +1 -2
- package/dist/{index-C7Xep6S9.d.ts → index-DuJnzwHv.d.ts} +2 -2
- package/dist/index.d.ts +364 -26
- package/dist/index.js +232 -169
- package/dist/intent.d.ts +1 -2
- package/dist/lcm/engine.d.ts +1 -2
- package/dist/lcm/engine.js +4 -4
- package/dist/lcm/index.d.ts +1 -2
- package/dist/lcm/index.js +10 -10
- package/dist/lcm/tools.d.ts +1 -2
- package/dist/lifecycle.d.ts +1 -2
- package/dist/live-connectors-runner.d.ts +1 -2
- package/dist/local-llm.d.ts +1 -2
- package/dist/local-model-endpoint.d.ts +1 -2
- package/dist/location/index.d.ts +315 -6
- package/dist/location/index.js +151 -19
- package/dist/maintenance/memory-governance.d.ts +1 -2
- package/dist/maintenance/memory-governance.js +28 -28
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -3
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +28 -28
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -3
- package/dist/maintenance/rebuild-memory-projection.js +29 -29
- package/dist/{maintenance-CJ-xqFp0.d.ts → maintenance-BBeaeYRR.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +11 -12
- package/dist/mcp-read-only-tools.js +1 -1
- package/dist/memory-action-policy.d.ts +1 -2
- package/dist/memory-cache.d.ts +1 -2
- package/dist/memory-controller.d.ts +1 -2
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -2
- package/dist/memory-projection-mutations.js +3 -3
- package/dist/memory-projection-store.d.ts +1 -2
- package/dist/memory-projection-store.js +1 -1
- package/dist/memory-provenance.d.ts +1 -2
- package/dist/memory-snapshot.d.ts +1 -2
- package/dist/memory-subject-cli.d.ts +11 -12
- package/dist/memory-subject.d.ts +11 -12
- package/dist/memory-subject.js +4 -4
- package/dist/memory-worth-outcomes.d.ts +2 -3
- package/dist/models-json.d.ts +1 -2
- package/dist/namespaces/migrate.d.ts +3 -4
- package/dist/namespaces/migrate.js +29 -29
- package/dist/namespaces/principal.d.ts +1 -2
- package/dist/namespaces/search.d.ts +1 -2
- package/dist/namespaces/search.js +8 -8
- package/dist/namespaces/storage.d.ts +3 -4
- package/dist/namespaces/storage.js +28 -28
- package/dist/native-knowledge.d.ts +1 -2
- package/dist/offline-sync-file-io.js +3 -3
- package/dist/offline-sync-impression-drain.d.ts +1 -2
- package/dist/offline-sync-impression-drain.js +9 -9
- package/dist/offline-sync.js +4 -4
- package/dist/operator-doctor-corpus.d.ts +1 -2
- package/dist/operator-doctor-corpus.js +31 -31
- package/dist/operator-doctor-replica.d.ts +1 -2
- package/dist/operator-toolkit.d.ts +3 -4
- package/dist/operator-toolkit.js +47 -47
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -3
- package/dist/orchestration/maintenance.d.ts +4 -5
- package/dist/orchestration/maintenance.js +42 -41
- package/dist/{orchestrator-BsntWxLy.d.ts → orchestrator-CaqnwNwM.d.ts} +8 -8
- package/dist/orchestrator.d.ts +9 -10
- package/dist/orchestrator.js +132 -125
- package/dist/page-versioning.js +3 -3
- package/dist/patterns-cli.d.ts +1 -2
- package/dist/{pipeline-CVoysPm2.d.ts → pipeline-CrxVjlJr.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -2
- package/dist/proactive-contention.d.ts +1 -2
- package/dist/provenance.d.ts +1 -2
- package/dist/{public-http-CuOxlTC2.d.ts → public-http-Cwvl4QZr.d.ts} +1 -1
- package/dist/{purge-GB7PZHT2.js → purge-OP6BEDFY.js} +2 -2
- package/dist/{qmd-DWMAGA5l.d.ts → qmd-BZgbJm0g.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -3
- package/dist/qmd-recall-cache.d.ts +1 -2
- package/dist/qmd.d.ts +2 -3
- package/dist/recall-concurrency-config.d.ts +1 -2
- package/dist/recall-deep.d.ts +37 -0
- package/dist/recall-deep.js +81 -0
- package/dist/recall-deep.js.map +1 -0
- package/dist/recall-disclosure-escalation.d.ts +1 -2
- package/dist/recall-explain-renderer.d.ts +1 -2
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +1 -2
- package/dist/recall-navigate.d.ts +70 -0
- package/dist/recall-navigate.js +51 -0
- package/dist/recall-navigate.js.map +1 -0
- package/dist/recall-planner-llm.d.ts +1 -2
- package/dist/recall-planner-llm.js +1 -1
- package/dist/recall-state-view-wire.d.ts +14 -0
- package/dist/recall-state-view-wire.js +11 -0
- package/dist/recall-state-view.d.ts +25 -0
- package/dist/recall-state-view.js +22 -0
- package/dist/recall-state-view.js.map +1 -0
- package/dist/recall-state.d.ts +1 -2
- package/dist/recall-tag-filter.d.ts +1 -2
- package/dist/recall-timings.d.ts +1 -2
- package/dist/recall-xray-cli.d.ts +1 -2
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -2
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +1 -2
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/cursor.d.ts +1 -2
- package/dist/reconcile/manifest.d.ts +1 -2
- package/dist/reconcile/manifest.js +4 -4
- package/dist/reconcile/plan.d.ts +1 -2
- package/dist/replay/normalizers/chatgpt.d.ts +1 -2
- package/dist/replay/normalizers/claude.d.ts +1 -2
- package/dist/replay/normalizers/openclaw.d.ts +1 -2
- package/dist/replay/normalizers/shared.d.ts +1 -2
- package/dist/replay/runner.d.ts +1 -2
- package/dist/replay/types.d.ts +1 -2
- package/dist/replica-divergence.d.ts +1 -2
- package/dist/replica-peers-config.d.ts +1 -2
- package/dist/{resolution-XWBPKYFB.js → resolution-4DLI3IOR.js} +10 -10
- package/dist/resolution-4DLI3IOR.js.map +1 -0
- package/dist/resolve-auth-token.d.ts +1 -2
- package/dist/resume-bundles.js +12 -12
- package/dist/retrieval-agents.d.ts +2 -3
- package/dist/retrieval-tiers.d.ts +1 -2
- package/dist/routing/engine.d.ts +1 -2
- package/dist/routing/store.d.ts +1 -2
- package/dist/salvage-envelope.d.ts +1 -2
- package/dist/salvage-envelope.js +6 -6
- package/dist/schemas.d.ts +570 -105
- package/dist/schemas.js +3 -1
- package/dist/{scope-profiles-CPWkW_dI.d.ts → scope-profiles-DFaojvoP.d.ts} +1 -1
- package/dist/search/document-scanner.js +1 -1
- package/dist/search/embed-helper.d.ts +1 -2
- package/dist/search/factory.d.ts +1 -2
- package/dist/search/factory.js +7 -7
- package/dist/search/index.d.ts +1 -2
- package/dist/search/index.js +13 -13
- package/dist/search/lancedb-backend.d.ts +1 -2
- package/dist/search/lancedb-backend.js +1 -1
- package/dist/search/meilisearch-backend.d.ts +1 -2
- package/dist/search/meilisearch-backend.js +1 -1
- package/dist/search/noop-backend.d.ts +1 -2
- package/dist/search/orama-backend.d.ts +1 -2
- package/dist/search/orama-backend.js +1 -1
- package/dist/search/port.d.ts +1 -2
- package/dist/search/remote-backend.d.ts +1 -2
- package/dist/secure-store/index.js +3 -3
- package/dist/{semantic-consolidation-CNFVBXFc.d.ts → semantic-consolidation-BiX68wZA.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -3
- package/dist/semantic-consolidation.js +29 -29
- package/dist/semantic-rule-promotion.js +28 -28
- package/dist/semantic-rule-verifier.d.ts +1 -2
- package/dist/semantic-rule-verifier.js +28 -28
- package/dist/{service-Bb-JIdQ0.d.ts → service-D5h2zZ0M.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +1 -2
- package/dist/session-observer-state.d.ts +1 -2
- package/dist/shared-context/manager.d.ts +1 -2
- package/dist/signal.d.ts +1 -2
- package/dist/source-agent-qualifier.d.ts +1 -2
- package/dist/source-agent-qualifier.js +35 -32
- package/dist/standup/build.d.ts +16 -0
- package/dist/standup/build.js +17 -0
- package/dist/standup/build.js.map +1 -0
- package/dist/{storage-CukrlNKk.d.ts → storage-CtsaojWD.d.ts} +1 -1
- package/dist/storage.d.ts +2 -3
- package/dist/storage.js +27 -27
- package/dist/subject-config.d.ts +1 -2
- package/dist/subject-config.js +5 -5
- package/dist/summarizer.d.ts +1 -2
- package/dist/summarizer.js +2 -2
- package/dist/summary-snapshot.d.ts +1 -2
- package/dist/support-passport/index.d.ts +16 -17
- package/dist/support-passport/index.js +57 -54
- package/dist/temporal-supersession.d.ts +2 -3
- package/dist/temporal-timeline-recall.d.ts +1 -2
- package/dist/temporal-validity.d.ts +1 -2
- package/dist/threading.d.ts +1 -2
- package/dist/tier-migration.d.ts +2 -3
- package/dist/tier-routing.d.ts +1 -2
- package/dist/tier-routing.js +2 -2
- package/dist/{tier-stats-4B5IJ3NE.js → tier-stats-2TOW3QNL.js} +3 -3
- package/dist/topics.d.ts +1 -2
- package/dist/transcript.d.ts +1 -2
- package/dist/transfer/capsule-import.js +4 -4
- package/dist/transfer/export-okf.d.ts +39 -0
- package/dist/transfer/export-okf.js +112 -0
- package/dist/transfer/export-okf.js.map +1 -0
- package/dist/trust-score-stage.d.ts +1 -2
- package/dist/trust-score.d.ts +1 -2
- package/dist/{types-djxQlxJ7.d.ts → types-CIpfYz1I.d.ts} +132 -12
- package/dist/types.d.ts +1 -2
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +1 -2
- package/dist/verified-recall.js +28 -28
- package/dist/who-knows-cli.d.ts +11 -12
- package/dist/who-knows-cli.js +29 -29
- package/dist/who-knows.d.ts +11 -12
- package/dist/who-knows.js +28 -28
- package/dist/write-envelope.d.ts +1 -2
- package/dist/write-envelope.js +5 -5
- package/package.json +34 -3
- package/src/access-admin-ops-surface.ts +6 -1
- package/src/access-boundary.ts +1 -0
- package/src/access-http.ts +3 -1
- package/src/access-mcp-output-schemas.ts +1 -0
- package/src/access-mcp.ts +3 -3
- package/src/access-operations.ts +1 -0
- package/src/access-service-offline-file-content.test.ts +63 -0
- package/src/access-surface-catalog.ts +2 -0
- package/src/activity/config.test.ts +1 -0
- package/src/activity/config.ts +66 -1
- package/src/activity/index.ts +3 -0
- package/src/activity/journal.test.ts +97 -0
- package/src/activity/journal.ts +113 -0
- package/src/activity/privacy.test.ts +53 -0
- package/src/activity/privacy.ts +80 -0
- package/src/activity/timeline/build.ts +279 -0
- package/src/activity/timeline/categories.ts +111 -0
- package/src/activity/timeline/classify.ts +110 -0
- package/src/activity/timeline/corrections.ts +145 -0
- package/src/activity/timeline/index.ts +8 -0
- package/src/activity/timeline/journal-recap.test.ts +113 -0
- package/src/activity/timeline/journal-recap.ts +130 -0
- package/src/activity/timeline/query.test.ts +198 -0
- package/src/activity/timeline/query.ts +313 -0
- package/src/activity/timeline/timeline.test.ts +277 -0
- package/src/activity/timeline/types.ts +106 -0
- package/src/activity/timeline/weekly.test.ts +215 -0
- package/src/activity/timeline/weekly.ts +234 -0
- package/src/activity/types.ts +20 -0
- package/src/activity/vault-publish.test.ts +166 -0
- package/src/activity/vault-publish.ts +101 -0
- package/src/cli/okf-commands.ts +45 -0
- package/src/cli.ts +2 -2
- package/src/coding/export-okf-codegraph.test.ts +381 -0
- package/src/coding/export-okf-codegraph.ts +565 -0
- package/src/config.test.ts +1 -0
- package/src/config.ts +2 -22
- package/src/dedup/merge-on-write.test.ts +91 -0
- package/src/dedup/merge-on-write.ts +75 -0
- package/src/dedup/novelty-gate.test.ts +143 -0
- package/src/dedup/novelty-gate.ts +163 -0
- package/src/extraction-prompt-safety.test.ts +14 -2
- package/src/extraction.ts +21 -1
- package/src/fallback-llm.test.ts +134 -0
- package/src/fallback-llm.ts +77 -5
- package/src/location/access-operations.ts +17 -8
- package/src/location/backfill.ts +137 -0
- package/src/location/config.test.ts +3 -0
- package/src/location/config.ts +46 -2
- package/src/location/http-glue.ts +1 -1
- package/src/location/index.ts +3 -0
- package/src/location/intervals.ts +1 -0
- package/src/location/matching.test.ts +65 -0
- package/src/location/matching.ts +354 -0
- package/src/location/mcp-tools.ts +2 -1
- package/src/location/recall-exclusion.test.ts +1 -0
- package/src/location/surfaces.test.ts +15 -2
- package/src/location/surfaces.ts +95 -18
- package/src/location/tagging.test.ts +119 -0
- package/src/location/tagging.ts +277 -0
- package/src/location/types.ts +23 -1
- package/src/mcp-read-only-tools.ts +1 -0
- package/src/memory-projection-store.ts +3 -1
- package/src/okf/cli.ts +18 -5
- package/src/okf/config.ts +5 -0
- package/src/okf/index-files.test.ts +60 -0
- package/src/okf/index-files.ts +114 -0
- package/src/okf/render.ts +133 -0
- package/src/okf/type-mapping.test.ts +3 -0
- package/src/okf/type-mapping.ts +2 -0
- package/src/orchestration/extraction-persist.ts +22 -23
- package/src/orchestration/extraction-run.ts +2 -1
- package/src/orchestration/generic-recall-paths.ts +15 -3
- package/src/orchestration/recall-entry.ts +8 -3
- package/src/recall-deep.test.ts +72 -0
- package/src/recall-deep.ts +113 -0
- package/src/recall-navigate.test.ts +84 -0
- package/src/recall-navigate.ts +100 -0
- package/src/recall-state-view-wire.test.ts +35 -0
- package/src/recall-state-view-wire.ts +28 -0
- package/src/recall-state-view.test.ts +131 -0
- package/src/recall-state-view.ts +138 -0
- package/src/schemas.ts +17 -1
- package/src/shared-context/governance.test.ts +53 -0
- package/src/shared-context/governance.ts +86 -0
- package/src/standup/access-operations.ts +14 -0
- package/src/standup/build.test.ts +34 -0
- package/src/standup/build.ts +115 -0
- package/src/standup/http-glue.ts +15 -0
- package/src/standup/mcp-tools.ts +16 -0
- package/src/support-passport/card-projection.ts +1 -0
- package/src/support-passport/card-service-commit-forwarding.test.ts +1 -0
- package/src/support-passport/card-service.test.ts +75 -1
- package/src/support-passport/card-service.ts +6 -3
- package/src/support-passport/card-state.ts +5 -1
- package/src/support-passport/offline-sync-guard.ts +14 -1
- package/src/transfer/export-okf.test.ts +164 -0
- package/src/transfer/export-okf.ts +286 -0
- package/src/types.ts +3 -10
- package/dist/chunk-2LWQSV6A.js.map +0 -1
- package/dist/chunk-3BCULS4U.js.map +0 -1
- package/dist/chunk-7BDZTALN.js.map +0 -1
- package/dist/chunk-7PHI6GUI.js.map +0 -1
- package/dist/chunk-7WOWGRAU.js.map +0 -1
- package/dist/chunk-AX7UXCHJ.js.map +0 -1
- package/dist/chunk-DEACDKE3.js.map +0 -1
- package/dist/chunk-FP7YTTVO.js.map +0 -1
- package/dist/chunk-JYSN42VN.js.map +0 -1
- package/dist/chunk-KZIF6XHX.js.map +0 -1
- package/dist/chunk-LKYIOCWL.js.map +0 -1
- package/dist/chunk-OXRRJXPR.js.map +0 -1
- package/dist/chunk-U7EW2W4W.js.map +0 -1
- package/dist/chunk-UW5NPZJ2.js.map +0 -1
- package/dist/chunk-XAB6STPO.js.map +0 -1
- package/dist/chunk-XNWXSGHS.js.map +0 -1
- package/dist/types-CM86alG1.d.ts +0 -89
- /package/dist/{auto-sync-2YPITIWN.js.map → auto-sync-Q6Q2FVSC.js.map} +0 -0
- /package/dist/{capsule-merge-SGIVB3WA.js.map → capsule-merge-SEHERWWP.js.map} +0 -0
- /package/dist/{chunk-LEPOP46W.js.map → chunk-227UFSEQ.js.map} +0 -0
- /package/dist/{chunk-TFR3HG4K.js.map → chunk-2FA7U5XY.js.map} +0 -0
- /package/dist/{chunk-PO7NXBG2.js.map → chunk-2GF27PGH.js.map} +0 -0
- /package/dist/{chunk-MY2BC6UE.js.map → chunk-2X6BGKQL.js.map} +0 -0
- /package/dist/{chunk-UEBDCMOO.js.map → chunk-3TSU662L.js.map} +0 -0
- /package/dist/{chunk-S5XOSTYM.js.map → chunk-4XLTUR6R.js.map} +0 -0
- /package/dist/{chunk-BWGCOLEL.js.map → chunk-65JOGLIS.js.map} +0 -0
- /package/dist/{chunk-HMZKGHMD.js.map → chunk-7UOXCCCI.js.map} +0 -0
- /package/dist/{chunk-4F4AQFWL.js.map → chunk-B4AOWRYF.js.map} +0 -0
- /package/dist/{chunk-ODU2CNNX.js.map → chunk-C5IUOBCN.js.map} +0 -0
- /package/dist/{chunk-3A2NJP2U.js.map → chunk-CHGG74CY.js.map} +0 -0
- /package/dist/{chunk-76DIF5KT.js.map → chunk-CX4OLNIH.js.map} +0 -0
- /package/dist/{chunk-Z3YEGSR4.js.map → chunk-D3UXGE5D.js.map} +0 -0
- /package/dist/{chunk-5HK3CJAR.js.map → chunk-D6Q5EPOV.js.map} +0 -0
- /package/dist/{chunk-EGBDFJ36.js.map → chunk-DD5JFCWM.js.map} +0 -0
- /package/dist/{chunk-XBGHAAKR.js.map → chunk-DDX6KIXF.js.map} +0 -0
- /package/dist/{chunk-JIYDRBVZ.js.map → chunk-DJORULH3.js.map} +0 -0
- /package/dist/{chunk-7KQB4EBS.js.map → chunk-DUAJKRR2.js.map} +0 -0
- /package/dist/{chunk-Q57GOHLF.js.map → chunk-EGALNSZ4.js.map} +0 -0
- /package/dist/{chunk-DPCXDG7G.js.map → chunk-EH65UV2Z.js.map} +0 -0
- /package/dist/{chunk-KCT36JAW.js.map → chunk-ESNFSSO4.js.map} +0 -0
- /package/dist/{chunk-XQ3HXAQH.js.map → chunk-ET2CNMLD.js.map} +0 -0
- /package/dist/{chunk-TUHBYJXL.js.map → chunk-EWKVYCFP.js.map} +0 -0
- /package/dist/{chunk-NPFUNWNX.js.map → chunk-FFUMTH27.js.map} +0 -0
- /package/dist/{chunk-3PKAS6VL.js.map → chunk-GAJK3DQ5.js.map} +0 -0
- /package/dist/{chunk-DA7ITC5Z.js.map → chunk-GBEOUCBB.js.map} +0 -0
- /package/dist/{chunk-UENKPWCS.js.map → chunk-H2IRSXZN.js.map} +0 -0
- /package/dist/{chunk-CFVTRUR3.js.map → chunk-H6RSANGQ.js.map} +0 -0
- /package/dist/{chunk-EUYWQ7TS.js.map → chunk-IEZ6CGTW.js.map} +0 -0
- /package/dist/{chunk-3SZD4CYO.js.map → chunk-IGZCAHFL.js.map} +0 -0
- /package/dist/{chunk-UPFNQJC7.js.map → chunk-INUBU6I5.js.map} +0 -0
- /package/dist/{chunk-PMVPCZJZ.js.map → chunk-J2R275FN.js.map} +0 -0
- /package/dist/{chunk-2QSZNTDO.js.map → chunk-JBPKEARU.js.map} +0 -0
- /package/dist/{chunk-5ACCD4L7.js.map → chunk-JRRQ747T.js.map} +0 -0
- /package/dist/{chunk-V4IDF3EZ.js.map → chunk-JTWZKNUH.js.map} +0 -0
- /package/dist/{chunk-AZMLH5UT.js.map → chunk-KI64TTBL.js.map} +0 -0
- /package/dist/{chunk-NPIBN2VL.js.map → chunk-LK4TOYPU.js.map} +0 -0
- /package/dist/{chunk-UTQUEHC7.js.map → chunk-LUDBXTBJ.js.map} +0 -0
- /package/dist/{chunk-PU56CXZA.js.map → chunk-LYUUA6QB.js.map} +0 -0
- /package/dist/{chunk-P36Z4JRA.js.map → chunk-M5ERTI4I.js.map} +0 -0
- /package/dist/{chunk-LDKPDODJ.js.map → chunk-ME35HVDJ.js.map} +0 -0
- /package/dist/{chunk-773TRRGT.js.map → chunk-MJUCDM3C.js.map} +0 -0
- /package/dist/{chunk-AHPIFKNG.js.map → chunk-N4F7ZSSG.js.map} +0 -0
- /package/dist/{chunk-JOZUBF4A.js.map → chunk-NACLNNFQ.js.map} +0 -0
- /package/dist/{chunk-LC2BDILZ.js.map → chunk-NBP4EX5N.js.map} +0 -0
- /package/dist/{chunk-T7XP6IZE.js.map → chunk-NFP4KPTA.js.map} +0 -0
- /package/dist/{chunk-ZVPVTPGI.js.map → chunk-NNZFPYYX.js.map} +0 -0
- /package/dist/{chunk-LPNCR4QK.js.map → chunk-NSTNGMSS.js.map} +0 -0
- /package/dist/{chunk-5RWZH6PH.js.map → chunk-NUF7VSEX.js.map} +0 -0
- /package/dist/{chunk-7VZFRUQU.js.map → chunk-O7ERGZDA.js.map} +0 -0
- /package/dist/{chunk-HSZMX3ZJ.js.map → chunk-ODW5GDFE.js.map} +0 -0
- /package/dist/{chunk-5DHKCO52.js.map → chunk-OJUEUQDJ.js.map} +0 -0
- /package/dist/{chunk-LOXHYCVS.js.map → chunk-OMX6TKXH.js.map} +0 -0
- /package/dist/{chunk-J2WC5LF4.js.map → chunk-QBC33MPY.js.map} +0 -0
- /package/dist/{chunk-SEEJOGQX.js.map → chunk-QBNE55VA.js.map} +0 -0
- /package/dist/{chunk-F7XUD3PL.js.map → chunk-S4CDUXQY.js.map} +0 -0
- /package/dist/{chunk-WNXYT4MK.js.map → chunk-S4Z2OBTX.js.map} +0 -0
- /package/dist/{chunk-UL4MKZHI.js.map → chunk-SN4JXNLL.js.map} +0 -0
- /package/dist/{chunk-CAMNRAJF.js.map → chunk-SZMYGDSM.js.map} +0 -0
- /package/dist/{chunk-CPA5NBHN.js.map → chunk-TNGH4ZYI.js.map} +0 -0
- /package/dist/{chunk-F3NVYTTA.js.map → chunk-TNXNECAN.js.map} +0 -0
- /package/dist/{chunk-BEC4YBNA.js.map → chunk-TVW4C7PV.js.map} +0 -0
- /package/dist/{chunk-UFKPQBXH.js.map → chunk-U62OK7BB.js.map} +0 -0
- /package/dist/{chunk-4QEYREAV.js.map → chunk-U6NGKS32.js.map} +0 -0
- /package/dist/{chunk-HRHO3ZNG.js.map → chunk-UW4RYPWC.js.map} +0 -0
- /package/dist/{chunk-T6ILXUAH.js.map → chunk-VG4SSPAW.js.map} +0 -0
- /package/dist/{chunk-H2YSH3DG.js.map → chunk-WKAXBXVA.js.map} +0 -0
- /package/dist/{chunk-SXIMQLGV.js.map → chunk-WVGXCBOC.js.map} +0 -0
- /package/dist/{chunk-UNUMFURP.js.map → chunk-X5PIDJ3L.js.map} +0 -0
- /package/dist/{chunk-CRML27CO.js.map → chunk-X5YYSAZX.js.map} +0 -0
- /package/dist/{chunk-FZEEWOI2.js.map → chunk-XJJYSX6F.js.map} +0 -0
- /package/dist/{chunk-OA2O2GJ4.js.map → chunk-XOHYGIWF.js.map} +0 -0
- /package/dist/{chunk-UG6VXIOK.js.map → chunk-XSTNGNJP.js.map} +0 -0
- /package/dist/{chunk-YDPAE2RD.js.map → chunk-YFLLGRXO.js.map} +0 -0
- /package/dist/{chunk-MDD2RINF.js.map → chunk-YWPLOJ7T.js.map} +0 -0
- /package/dist/{chunk-Q4WONDMJ.js.map → chunk-YYGZJPOK.js.map} +0 -0
- /package/dist/{chunk-GTO56JY5.js.map → chunk-ZPS724LT.js.map} +0 -0
- /package/dist/{chunk-SNOIKAHM.js.map → chunk-ZZZWEDF4.js.map} +0 -0
- /package/dist/{contradiction-scan-AKUWPX5N.js.map → contradiction-scan-NOYMFG66.js.map} +0 -0
- /package/dist/{first-start-migration-4NETATFF.js.map → first-start-migration-KHIMCBIC.js.map} +0 -0
- /package/dist/{purge-GB7PZHT2.js.map → purge-OP6BEDFY.js.map} +0 -0
- /package/dist/{resolution-XWBPKYFB.js.map → recall-state-view-wire.js.map} +0 -0
- /package/dist/{tier-stats-4B5IJ3NE.js.map → tier-stats-2TOW3QNL.js.map} +0 -0
|
@@ -0,0 +1,1466 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildCodingGraphInstallHint,
|
|
3
|
+
tryLoadCodingGraphModule
|
|
4
|
+
} from "./chunk-VQ7B2Q6M.js";
|
|
5
|
+
import {
|
|
6
|
+
composeMemoryEnvelope
|
|
7
|
+
} from "./chunk-WKAXBXVA.js";
|
|
8
|
+
import {
|
|
9
|
+
isCodingKnowledgeFeatureEnabled
|
|
10
|
+
} from "./chunk-FEHIOYML.js";
|
|
11
|
+
import {
|
|
12
|
+
displayErrorDetail
|
|
13
|
+
} from "./chunk-RL6NEVXT.js";
|
|
14
|
+
import {
|
|
15
|
+
stripAttributesSuffix
|
|
16
|
+
} from "./chunk-JDSVLVCG.js";
|
|
17
|
+
import {
|
|
18
|
+
expandTildePath
|
|
19
|
+
} from "./chunk-EYIEWJNI.js";
|
|
20
|
+
import {
|
|
21
|
+
log
|
|
22
|
+
} from "./chunk-3WCASNQZ.js";
|
|
23
|
+
|
|
24
|
+
// src/coding/architecture-card.ts
|
|
25
|
+
import { readFile, readdir, lstat } from "fs/promises";
|
|
26
|
+
import path from "path";
|
|
27
|
+
var ARCHITECTURE_CARD_MAX_BYTES = 4096;
|
|
28
|
+
var ARCHITECTURE_CARD_TRUNCATION_MARKER = "\u2026 card truncated to fit size cap \u2026";
|
|
29
|
+
var ARCHITECTURE_CARD_MAX_SUMMARY_BYTES = 1024;
|
|
30
|
+
var KNOWN_MANIFEST_FILES = [
|
|
31
|
+
"package.json",
|
|
32
|
+
"Cargo.toml",
|
|
33
|
+
"go.mod",
|
|
34
|
+
"pyproject.toml",
|
|
35
|
+
"setup.py",
|
|
36
|
+
"pom.xml",
|
|
37
|
+
"build.gradle",
|
|
38
|
+
"build.gradle.kts",
|
|
39
|
+
"Gemfile",
|
|
40
|
+
"composer.json",
|
|
41
|
+
"mix.exs",
|
|
42
|
+
"deno.json"
|
|
43
|
+
];
|
|
44
|
+
var SCAN_IGNORE_DIRS = /* @__PURE__ */ new Set([
|
|
45
|
+
"node_modules",
|
|
46
|
+
".git",
|
|
47
|
+
".svn",
|
|
48
|
+
".hg",
|
|
49
|
+
"vendor",
|
|
50
|
+
"__pycache__",
|
|
51
|
+
".venv",
|
|
52
|
+
"venv",
|
|
53
|
+
"env",
|
|
54
|
+
"dist",
|
|
55
|
+
"build",
|
|
56
|
+
"target",
|
|
57
|
+
"out",
|
|
58
|
+
".next",
|
|
59
|
+
".nuxt",
|
|
60
|
+
"coverage",
|
|
61
|
+
".cache",
|
|
62
|
+
".turbo",
|
|
63
|
+
".idea",
|
|
64
|
+
".vscode"
|
|
65
|
+
]);
|
|
66
|
+
var ARCHITECTURE_CARD_SUMMARY_SYSTEM_PROMPT = `You write a concise overview for a repository architecture card.
|
|
67
|
+
Given the deterministic card (languages, manifests, entry points), produce a 3-5 sentence plain-text overview naming the dominant language, the primary entry point, and the project's shape.
|
|
68
|
+
Rules:
|
|
69
|
+
- Never invent facts absent from the input.
|
|
70
|
+
- No headings, no markdown \u2014 just sentences.
|
|
71
|
+
- Keep it under 600 characters.`;
|
|
72
|
+
function createArchitectureCardSummariser(client) {
|
|
73
|
+
if (!client) return void 0;
|
|
74
|
+
return async (deterministicCard, repoRoot) => {
|
|
75
|
+
const response = await client.chatCompletion(
|
|
76
|
+
[
|
|
77
|
+
{ role: "system", content: ARCHITECTURE_CARD_SUMMARY_SYSTEM_PROMPT },
|
|
78
|
+
{ role: "user", content: `Repository: ${path.basename(repoRoot) || repoRoot}
|
|
79
|
+
|
|
80
|
+
${deterministicCard}` }
|
|
81
|
+
],
|
|
82
|
+
{
|
|
83
|
+
temperature: 0.2,
|
|
84
|
+
maxTokens: 512,
|
|
85
|
+
operation: "architecture-card-summary",
|
|
86
|
+
priority: "background"
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
return response?.content ?? null;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
async function buildArchitectureCard(repoRoot, options = {}) {
|
|
93
|
+
if (typeof repoRoot !== "string" || repoRoot.length === 0) {
|
|
94
|
+
return { ok: false, code: "invalid_root", detail: "repoRoot must be a non-empty string" };
|
|
95
|
+
}
|
|
96
|
+
const absoluteRoot = path.resolve(expandTildePath(repoRoot));
|
|
97
|
+
try {
|
|
98
|
+
const rootStat = await lstat(absoluteRoot);
|
|
99
|
+
if (!rootStat.isDirectory()) {
|
|
100
|
+
return { ok: false, code: "invalid_root", detail: `not a directory: ${absoluteRoot}` };
|
|
101
|
+
}
|
|
102
|
+
} catch (err) {
|
|
103
|
+
return {
|
|
104
|
+
ok: false,
|
|
105
|
+
code: "invalid_root",
|
|
106
|
+
detail: `repoRoot not accessible: ${err instanceof Error ? err.message : String(err)}`
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
await readdir(absoluteRoot);
|
|
111
|
+
} catch (err) {
|
|
112
|
+
return {
|
|
113
|
+
ok: false,
|
|
114
|
+
code: "scan_failed",
|
|
115
|
+
detail: `repoRoot not readable: ${err instanceof Error ? err.message : String(err)}`
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
const scan = await scanRepository(absoluteRoot);
|
|
120
|
+
const deterministic = renderCard(scan, options.now ?? /* @__PURE__ */ new Date());
|
|
121
|
+
const maxBytes = options.maxBytes ?? ARCHITECTURE_CARD_MAX_BYTES;
|
|
122
|
+
let content = deterministic;
|
|
123
|
+
if (options.llmSummary === true && options.summariser) {
|
|
124
|
+
try {
|
|
125
|
+
const summary = await options.summariser(deterministic, absoluteRoot);
|
|
126
|
+
if (typeof summary === "string" && summary.trim().length > 0) {
|
|
127
|
+
const separator = "\n\n---\n\n";
|
|
128
|
+
const detBytes = Buffer.byteLength(deterministic, "utf-8");
|
|
129
|
+
const sepBytes = Buffer.byteLength(separator, "utf-8");
|
|
130
|
+
const summaryBudget = Math.min(
|
|
131
|
+
ARCHITECTURE_CARD_MAX_SUMMARY_BYTES,
|
|
132
|
+
maxBytes - detBytes - sepBytes
|
|
133
|
+
);
|
|
134
|
+
if (summaryBudget > 0) {
|
|
135
|
+
const clampedSummary = clampSummaryToBytes(summary.trim(), summaryBudget);
|
|
136
|
+
if (clampedSummary.length > 0) {
|
|
137
|
+
content = `${clampedSummary}${separator}${deterministic}`;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} catch (err) {
|
|
142
|
+
void err;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const { text: truncatedContent, truncated } = capToBytes(content, maxBytes);
|
|
146
|
+
return {
|
|
147
|
+
ok: true,
|
|
148
|
+
card: {
|
|
149
|
+
content: truncatedContent,
|
|
150
|
+
generatedAt: (options.now ?? /* @__PURE__ */ new Date()).toISOString(),
|
|
151
|
+
byteSize: Buffer.byteLength(truncatedContent, "utf-8"),
|
|
152
|
+
truncated
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
} catch (err) {
|
|
156
|
+
return {
|
|
157
|
+
ok: false,
|
|
158
|
+
code: "scan_failed",
|
|
159
|
+
detail: err instanceof Error ? err.message : String(err)
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async function scanRepository(root) {
|
|
164
|
+
const topEntries = await readSortedDirEntries(root);
|
|
165
|
+
const topDirs = topEntries.filter((e) => e.isDirectory && !SCAN_IGNORE_DIRS.has(e.name)).map((e) => e.name);
|
|
166
|
+
const manifestFiles = topEntries.filter((e) => e.isFile && KNOWN_MANIFEST_FILES.includes(e.name)).map((e) => e.name);
|
|
167
|
+
const manifests = [];
|
|
168
|
+
for (const mf of sortStrings(manifestFiles)) {
|
|
169
|
+
const parsed = await parseManifest(path.join(root, mf));
|
|
170
|
+
manifests.push({ filename: mf, name: parsed.name, entryPoints: sortStrings(parsed.entryPoints) });
|
|
171
|
+
}
|
|
172
|
+
const languageHistogram = await computeLanguageHistogram(root, topEntries);
|
|
173
|
+
return {
|
|
174
|
+
root: path.basename(root) || root,
|
|
175
|
+
topDirs: sortStrings(topDirs),
|
|
176
|
+
manifests,
|
|
177
|
+
languageHistogram: sortLanguageHistogram(languageHistogram)
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
async function readSortedDirEntries(dir) {
|
|
181
|
+
let names;
|
|
182
|
+
try {
|
|
183
|
+
names = await readdir(dir);
|
|
184
|
+
} catch {
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
const entries = [];
|
|
188
|
+
for (const name of sortStrings(names)) {
|
|
189
|
+
try {
|
|
190
|
+
const s = await lstat(path.join(dir, name));
|
|
191
|
+
if (s.isSymbolicLink()) continue;
|
|
192
|
+
entries.push({ name, isDirectory: s.isDirectory(), isFile: s.isFile() });
|
|
193
|
+
} catch {
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return entries;
|
|
197
|
+
}
|
|
198
|
+
async function computeLanguageHistogram(root, topEntries) {
|
|
199
|
+
const counts = /* @__PURE__ */ new Map();
|
|
200
|
+
const dirsToScan = topEntries.filter((e) => e.isDirectory && !SCAN_IGNORE_DIRS.has(e.name)).map((e) => path.join(root, e.name));
|
|
201
|
+
const rootFiles = topEntries.filter((e) => e.isFile);
|
|
202
|
+
const visitDir = async (dir, depth) => {
|
|
203
|
+
if (depth > 2) return;
|
|
204
|
+
let entries;
|
|
205
|
+
try {
|
|
206
|
+
entries = await readSortedDirEntries(dir);
|
|
207
|
+
} catch {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
for (const entry of entries) {
|
|
211
|
+
if (entry.isDirectory) {
|
|
212
|
+
if (!SCAN_IGNORE_DIRS.has(entry.name)) {
|
|
213
|
+
await visitDir(path.join(dir, entry.name), depth + 1);
|
|
214
|
+
}
|
|
215
|
+
} else if (entry.isFile) {
|
|
216
|
+
const ext = path.extname(entry.name).toLowerCase();
|
|
217
|
+
if (ext.length > 0) {
|
|
218
|
+
counts.set(ext, (counts.get(ext) ?? 0) + 1);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
for (const f of rootFiles) {
|
|
224
|
+
const ext = path.extname(f.name).toLowerCase();
|
|
225
|
+
if (ext.length > 0) counts.set(ext, (counts.get(ext) ?? 0) + 1);
|
|
226
|
+
}
|
|
227
|
+
for (const dir of dirsToScan) {
|
|
228
|
+
await visitDir(dir, 0);
|
|
229
|
+
}
|
|
230
|
+
return Array.from(counts.entries()).map(([ext, count]) => ({ ext, count }));
|
|
231
|
+
}
|
|
232
|
+
async function parseManifest(filePath) {
|
|
233
|
+
const filename = path.basename(filePath);
|
|
234
|
+
try {
|
|
235
|
+
const raw = await readFile(filePath, "utf-8");
|
|
236
|
+
switch (filename) {
|
|
237
|
+
case "package.json":
|
|
238
|
+
return parsePackageJson(raw);
|
|
239
|
+
case "pyproject.toml":
|
|
240
|
+
case "setup.py":
|
|
241
|
+
return parsePythonProject(raw, filename);
|
|
242
|
+
case "go.mod":
|
|
243
|
+
return parseGoMod(raw);
|
|
244
|
+
case "Cargo.toml":
|
|
245
|
+
return parseCargoToml(raw);
|
|
246
|
+
default:
|
|
247
|
+
return { name: null, entryPoints: [] };
|
|
248
|
+
}
|
|
249
|
+
} catch {
|
|
250
|
+
return { name: null, entryPoints: [] };
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function parsePackageJson(raw) {
|
|
254
|
+
let parsed;
|
|
255
|
+
try {
|
|
256
|
+
parsed = JSON.parse(raw);
|
|
257
|
+
} catch {
|
|
258
|
+
return { name: null, entryPoints: [] };
|
|
259
|
+
}
|
|
260
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
261
|
+
return { name: null, entryPoints: [] };
|
|
262
|
+
}
|
|
263
|
+
const obj = parsed;
|
|
264
|
+
const name = typeof obj["name"] === "string" ? obj["name"] : null;
|
|
265
|
+
const entryPoints = [];
|
|
266
|
+
const bin = obj["bin"];
|
|
267
|
+
if (typeof bin === "string") {
|
|
268
|
+
entryPoints.push(bin);
|
|
269
|
+
} else if (typeof bin === "object" && bin !== null && !Array.isArray(bin)) {
|
|
270
|
+
for (const [key, value] of Object.entries(bin)) {
|
|
271
|
+
entryPoints.push(typeof value === "string" ? value : `bin/${key}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const main = typeof obj["main"] === "string" ? obj["main"] : null;
|
|
275
|
+
if (main) entryPoints.push(main);
|
|
276
|
+
const module = typeof obj["module"] === "string" ? obj["module"] : null;
|
|
277
|
+
if (module) entryPoints.push(module);
|
|
278
|
+
const scripts = obj["scripts"];
|
|
279
|
+
if (typeof scripts === "object" && scripts !== null && !Array.isArray(scripts)) {
|
|
280
|
+
const scriptKeys = Object.keys(scripts);
|
|
281
|
+
for (const key of ["start", "dev", "serve"]) {
|
|
282
|
+
if (scriptKeys.includes(key)) entryPoints.push(`scripts.${key}`);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return { name, entryPoints };
|
|
286
|
+
}
|
|
287
|
+
function parsePythonProject(raw, _filename) {
|
|
288
|
+
const entryPoints = [];
|
|
289
|
+
let name = null;
|
|
290
|
+
const nameMatch = raw.match(/^name\s*=\s*["']([^"']+)["']/m);
|
|
291
|
+
if (nameMatch) name = nameMatch[1] ?? null;
|
|
292
|
+
const scriptsMatch = raw.match(/\[project\.scripts\]([\s\S]*?)(?:\n\[|$)/);
|
|
293
|
+
if (scriptsMatch && scriptsMatch[1]) {
|
|
294
|
+
for (const line of scriptsMatch[1].split("\n")) {
|
|
295
|
+
const m = line.match(/^([a-zA-Z0-9_-]+)\s*=/);
|
|
296
|
+
if (m && m[1]) entryPoints.push(`scripts.${m[1]}`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return { name, entryPoints };
|
|
300
|
+
}
|
|
301
|
+
function parseGoMod(raw) {
|
|
302
|
+
const moduleMatch = raw.match(/^module\s+(\S+)/m);
|
|
303
|
+
const name = moduleMatch && moduleMatch[1] ? moduleMatch[1] : null;
|
|
304
|
+
return { name, entryPoints: name ? ["main.go"] : [] };
|
|
305
|
+
}
|
|
306
|
+
function parseCargoToml(raw) {
|
|
307
|
+
const nameMatch = raw.match(/^name\s*=\s*"([^"]+)"/m);
|
|
308
|
+
const name = nameMatch && nameMatch[1] ? nameMatch[1] : null;
|
|
309
|
+
const entryPoints = [];
|
|
310
|
+
if (/\[\[bin\]\]/.test(raw)) entryPoints.push("src/bin/");
|
|
311
|
+
if (name) entryPoints.push("src/main.rs");
|
|
312
|
+
return { name, entryPoints };
|
|
313
|
+
}
|
|
314
|
+
function renderCard(scan, now) {
|
|
315
|
+
const lines = [];
|
|
316
|
+
lines.push(`# Architecture Card \u2014 ${scan.root}`);
|
|
317
|
+
lines.push("");
|
|
318
|
+
lines.push(`_Generated ${now.toISOString()}_`);
|
|
319
|
+
lines.push("");
|
|
320
|
+
const namedManifest = scan.manifests.find((m) => m.name !== null);
|
|
321
|
+
if (namedManifest && namedManifest.name) {
|
|
322
|
+
lines.push(`**Project:** ${namedManifest.name}`);
|
|
323
|
+
lines.push("");
|
|
324
|
+
}
|
|
325
|
+
if (scan.manifests.length > 0) {
|
|
326
|
+
lines.push("## Manifests");
|
|
327
|
+
for (const m of scan.manifests) {
|
|
328
|
+
const label = m.name ? `${m.filename} (${m.name})` : m.filename;
|
|
329
|
+
lines.push(`- ${label}`);
|
|
330
|
+
}
|
|
331
|
+
lines.push("");
|
|
332
|
+
}
|
|
333
|
+
if (scan.topDirs.length > 0) {
|
|
334
|
+
lines.push("## Top-level directories");
|
|
335
|
+
const cols = 4;
|
|
336
|
+
for (let i = 0; i < scan.topDirs.length; i += cols) {
|
|
337
|
+
const row = scan.topDirs.slice(i, i + cols).join(" \xB7 ");
|
|
338
|
+
lines.push(`- ${row}`);
|
|
339
|
+
}
|
|
340
|
+
lines.push("");
|
|
341
|
+
}
|
|
342
|
+
if (scan.languageHistogram.length > 0) {
|
|
343
|
+
lines.push("## Languages (by file count)");
|
|
344
|
+
const top = scan.languageHistogram.slice(0, 10);
|
|
345
|
+
for (const entry of top) {
|
|
346
|
+
lines.push(`- ${entry.ext}: ${entry.count}`);
|
|
347
|
+
}
|
|
348
|
+
lines.push("");
|
|
349
|
+
}
|
|
350
|
+
const allEntryPoints = sortStrings(scan.manifests.flatMap((m) => m.entryPoints));
|
|
351
|
+
if (allEntryPoints.length > 0) {
|
|
352
|
+
lines.push("## Entry points");
|
|
353
|
+
for (const ep of allEntryPoints) {
|
|
354
|
+
lines.push(`- ${ep}`);
|
|
355
|
+
}
|
|
356
|
+
lines.push("");
|
|
357
|
+
}
|
|
358
|
+
return lines.join("\n").trimEnd() + "\n";
|
|
359
|
+
}
|
|
360
|
+
function sortStrings(values) {
|
|
361
|
+
return [...values].sort((a, b) => a.localeCompare(b));
|
|
362
|
+
}
|
|
363
|
+
function sortLanguageHistogram(entries) {
|
|
364
|
+
return [...entries].sort((a, b) => {
|
|
365
|
+
if (b.count !== a.count) return b.count - a.count;
|
|
366
|
+
return a.ext.localeCompare(b.ext);
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
function capToBytes(text, maxBytes) {
|
|
370
|
+
const byteLen = Buffer.byteLength(text, "utf-8");
|
|
371
|
+
if (byteLen <= maxBytes) {
|
|
372
|
+
return { text, truncated: false };
|
|
373
|
+
}
|
|
374
|
+
const marker = `
|
|
375
|
+
|
|
376
|
+
_${ARCHITECTURE_CARD_TRUNCATION_MARKER}_`;
|
|
377
|
+
const markerBytes = Buffer.byteLength(marker, "utf-8");
|
|
378
|
+
const budget = maxBytes - markerBytes;
|
|
379
|
+
if (budget <= 0) {
|
|
380
|
+
return { text: marker.trimStart(), truncated: true };
|
|
381
|
+
}
|
|
382
|
+
let cut = 0;
|
|
383
|
+
let running = 0;
|
|
384
|
+
const chars = [...text];
|
|
385
|
+
for (let i = 0; i < chars.length; i++) {
|
|
386
|
+
const charBytes = Buffer.byteLength(chars[i], "utf-8");
|
|
387
|
+
if (running + charBytes > budget) break;
|
|
388
|
+
running += charBytes;
|
|
389
|
+
cut = i + 1;
|
|
390
|
+
}
|
|
391
|
+
return { text: chars.slice(0, cut).join("") + marker, truncated: true };
|
|
392
|
+
}
|
|
393
|
+
function clampSummaryToBytes(text, maxBytes) {
|
|
394
|
+
if (maxBytes <= 0) return "";
|
|
395
|
+
if (Buffer.byteLength(text, "utf-8") <= maxBytes) return text;
|
|
396
|
+
const ellipsis = " \u2026";
|
|
397
|
+
const budget = maxBytes - Buffer.byteLength(ellipsis, "utf-8");
|
|
398
|
+
if (budget <= 0) return "";
|
|
399
|
+
let cut = 0;
|
|
400
|
+
let running = 0;
|
|
401
|
+
const chars = [...text];
|
|
402
|
+
for (let i = 0; i < chars.length; i++) {
|
|
403
|
+
const charBytes = Buffer.byteLength(chars[i], "utf-8");
|
|
404
|
+
if (running + charBytes > budget) break;
|
|
405
|
+
running += charBytes;
|
|
406
|
+
cut = i + 1;
|
|
407
|
+
}
|
|
408
|
+
return chars.slice(0, cut).join("") + ellipsis;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// src/coding/architecture-surfaces.ts
|
|
412
|
+
var ARCHITECTURE_CARD_TAG = "architecture-card";
|
|
413
|
+
var ARCHITECTURE_CARD_KIND = "architecture";
|
|
414
|
+
async function handleCodingArchitecture(request, ctx) {
|
|
415
|
+
const codingContext = request.sessionKey ? ctx.getCodingContext(request.sessionKey) : null;
|
|
416
|
+
if (codingContext === null || !isCodingKnowledgeFeatureEnabled(ctx.codingKnowledge, "architectureCard", codingContext)) {
|
|
417
|
+
ctx.throwInputError(
|
|
418
|
+
"coding_architecture requires codingKnowledge.enabled, codingKnowledge.architectureCard, and an attached coding context"
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
switch (request.subcommand) {
|
|
422
|
+
case "get":
|
|
423
|
+
return architectureGet(request, ctx);
|
|
424
|
+
case "refresh":
|
|
425
|
+
return architectureRefresh(request, ctx, codingContext);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
async function architectureGet(request, ctx) {
|
|
429
|
+
const storage = await ctx.resolveStorage(request);
|
|
430
|
+
const existing = await findArchitectureCardMemory(storage);
|
|
431
|
+
if (!existing) {
|
|
432
|
+
return { subcommand: "get", found: false };
|
|
433
|
+
}
|
|
434
|
+
const content = stripAttributesSuffix(existing.content);
|
|
435
|
+
return {
|
|
436
|
+
subcommand: "get",
|
|
437
|
+
found: true,
|
|
438
|
+
card: {
|
|
439
|
+
content,
|
|
440
|
+
generatedAt: existing.frontmatter.updated ?? existing.frontmatter.created,
|
|
441
|
+
byteSize: Buffer.byteLength(content, "utf-8"),
|
|
442
|
+
// Derive truncation from the CONTENT marker, not a frontmatter tag —
|
|
443
|
+
// the refresh update path changes content without rewriting tags, so
|
|
444
|
+
// a tag-based check goes stale (cursor review: stale truncated tag).
|
|
445
|
+
truncated: content.includes(ARCHITECTURE_CARD_TRUNCATION_MARKER)
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
async function architectureRefresh(request, ctx, codingContext) {
|
|
450
|
+
const repoRoot = codingContext.rootPath ?? codingContext.projectId;
|
|
451
|
+
const storage = await ctx.resolveStorage(request);
|
|
452
|
+
const buildResult = await ctx.buildCard(repoRoot);
|
|
453
|
+
if (!buildResult.ok) {
|
|
454
|
+
log.warn(
|
|
455
|
+
`coding_architecture/refresh: card build failed (code=${buildResult.code}): ${buildResult.detail}`
|
|
456
|
+
);
|
|
457
|
+
ctx.throwInputError(
|
|
458
|
+
`coding_architecture refresh failed: card build returned ${buildResult.code}`
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
const cardContent = buildResult.card.content;
|
|
462
|
+
const tags = [ARCHITECTURE_CARD_TAG];
|
|
463
|
+
if (buildResult.card.truncated) tags.push("truncated");
|
|
464
|
+
const existing = await findArchitectureCardMemory(storage);
|
|
465
|
+
if (existing) {
|
|
466
|
+
await ctx.versioning.snapshotIfExists(existing);
|
|
467
|
+
const updated = await storage.updateMemory(existing.frontmatter.id, cardContent, {
|
|
468
|
+
actor: "coding-architecture-refresh",
|
|
469
|
+
...ctx.sourceConnector ? { sourceConnector: ctx.sourceConnector } : {}
|
|
470
|
+
});
|
|
471
|
+
if (!updated) {
|
|
472
|
+
log.warn(
|
|
473
|
+
`coding_architecture/refresh: updateMemory returned false for id=${existing.frontmatter.id} \u2014 falling back to writeMemory`
|
|
474
|
+
);
|
|
475
|
+
const fallbackWrite = await storage.writeSealedMemory(
|
|
476
|
+
composeMemoryEnvelope(
|
|
477
|
+
{
|
|
478
|
+
content: cardContent,
|
|
479
|
+
category: "fact",
|
|
480
|
+
confidence: 1,
|
|
481
|
+
tags,
|
|
482
|
+
structuredAttributes: { cardKind: ARCHITECTURE_CARD_KIND },
|
|
483
|
+
...ctx.sourceConnector ? { sourceConnector: ctx.sourceConnector } : {}
|
|
484
|
+
},
|
|
485
|
+
{ source: "coding-architecture" }
|
|
486
|
+
),
|
|
487
|
+
{}
|
|
488
|
+
);
|
|
489
|
+
log.info(
|
|
490
|
+
`access-write op=coding_architecture/refresh memoryId=${fallbackWrite.id} (fallback write) byteSize=${buildResult.card.byteSize}`
|
|
491
|
+
);
|
|
492
|
+
return refreshResponse(fallbackWrite, buildResult.card);
|
|
493
|
+
}
|
|
494
|
+
log.info(
|
|
495
|
+
`access-write op=coding_architecture/refresh memoryId=${existing.frontmatter.id} (updated) byteSize=${buildResult.card.byteSize}`
|
|
496
|
+
);
|
|
497
|
+
return {
|
|
498
|
+
subcommand: "refresh",
|
|
499
|
+
refreshed: true,
|
|
500
|
+
memoryId: existing.frontmatter.id,
|
|
501
|
+
byteSize: buildResult.card.byteSize,
|
|
502
|
+
truncated: buildResult.card.truncated
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
const newWrite = await storage.writeSealedMemory(
|
|
506
|
+
composeMemoryEnvelope(
|
|
507
|
+
{
|
|
508
|
+
content: cardContent,
|
|
509
|
+
category: "fact",
|
|
510
|
+
confidence: 1,
|
|
511
|
+
tags,
|
|
512
|
+
structuredAttributes: { cardKind: ARCHITECTURE_CARD_KIND },
|
|
513
|
+
...ctx.sourceConnector ? { sourceConnector: ctx.sourceConnector } : {}
|
|
514
|
+
},
|
|
515
|
+
{ source: "coding-architecture" }
|
|
516
|
+
),
|
|
517
|
+
{}
|
|
518
|
+
);
|
|
519
|
+
log.info(
|
|
520
|
+
`access-write op=coding_architecture/refresh memoryId=${newWrite.id} (new) byteSize=${buildResult.card.byteSize}`
|
|
521
|
+
);
|
|
522
|
+
return refreshResponse(newWrite, buildResult.card);
|
|
523
|
+
}
|
|
524
|
+
function refreshResponse(writeResult, card) {
|
|
525
|
+
if (writeResult.tombstoneBlocked) {
|
|
526
|
+
return {
|
|
527
|
+
subcommand: "refresh",
|
|
528
|
+
refreshed: false,
|
|
529
|
+
memoryId: writeResult.id,
|
|
530
|
+
byteSize: card.byteSize,
|
|
531
|
+
truncated: card.truncated,
|
|
532
|
+
blockedReason: "tombstone-blocked",
|
|
533
|
+
...writeResult.blockedBy !== void 0 ? { blockedBy: writeResult.blockedBy } : {}
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
return {
|
|
537
|
+
subcommand: "refresh",
|
|
538
|
+
refreshed: true,
|
|
539
|
+
memoryId: writeResult.id,
|
|
540
|
+
byteSize: card.byteSize,
|
|
541
|
+
truncated: card.truncated
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
async function findArchitectureCardMemory(storage) {
|
|
545
|
+
const memories = await storage.readAllMemories();
|
|
546
|
+
const cards = memories.filter((m) => {
|
|
547
|
+
if (m.frontmatter.category !== "fact") return false;
|
|
548
|
+
const tags = m.frontmatter.tags ?? [];
|
|
549
|
+
if (!tags.includes(ARCHITECTURE_CARD_TAG)) return false;
|
|
550
|
+
if (m.frontmatter.structuredAttributes?.cardKind !== ARCHITECTURE_CARD_KIND) return false;
|
|
551
|
+
const outer = m.frontmatter.status;
|
|
552
|
+
if (outer !== void 0 && outer !== "active") return false;
|
|
553
|
+
if (m.frontmatter.archivedAt !== void 0 && m.frontmatter.archivedAt !== null) return false;
|
|
554
|
+
return true;
|
|
555
|
+
});
|
|
556
|
+
if (cards.length === 0) return null;
|
|
557
|
+
cards.sort((a, b) => {
|
|
558
|
+
const aUpdated = a.frontmatter.updated ?? a.frontmatter.created;
|
|
559
|
+
const bUpdated = b.frontmatter.updated ?? b.frontmatter.created;
|
|
560
|
+
if (aUpdated !== bUpdated) return bUpdated.localeCompare(aUpdated);
|
|
561
|
+
return b.frontmatter.id.localeCompare(a.frontmatter.id);
|
|
562
|
+
});
|
|
563
|
+
return cards[0] ?? null;
|
|
564
|
+
}
|
|
565
|
+
function createArchitectureVersioningHook(enabled, maxVersionsPerPage, sidecarDir, memoryDir, readFile3, writeVersion) {
|
|
566
|
+
return {
|
|
567
|
+
async snapshotIfExists(memory) {
|
|
568
|
+
if (!enabled) return;
|
|
569
|
+
try {
|
|
570
|
+
const fullContent = await readFile3(memory.path);
|
|
571
|
+
await writeVersion(
|
|
572
|
+
memory.path,
|
|
573
|
+
fullContent,
|
|
574
|
+
"manual",
|
|
575
|
+
{ enabled: true, maxVersionsPerPage, sidecarDir },
|
|
576
|
+
void 0,
|
|
577
|
+
"architecture-card-refresh",
|
|
578
|
+
memoryDir
|
|
579
|
+
);
|
|
580
|
+
} catch {
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
// src/coding/codegraph-runtime.ts
|
|
587
|
+
import path2 from "path";
|
|
588
|
+
import { readFile as readFile2, realpath } from "fs/promises";
|
|
589
|
+
import { readFileSync, realpathSync } from "fs";
|
|
590
|
+
import { pathToFileURL } from "url";
|
|
591
|
+
import { createHash } from "crypto";
|
|
592
|
+
function codegraphSurfaceVisible(config) {
|
|
593
|
+
const ck = config.codingKnowledge;
|
|
594
|
+
if (ck === void 0 || ck === null) return false;
|
|
595
|
+
return ck.enabled === true && ck.codegraphTools === true;
|
|
596
|
+
}
|
|
597
|
+
function resolveCodegraphRoot(config, memoryDir) {
|
|
598
|
+
const rawDir = config.codingKnowledge.codegraphDbDir.trim();
|
|
599
|
+
const root = rawDir.length > 0 ? expandTildePath(rawDir) : path2.join(memoryDir, "codegraph");
|
|
600
|
+
if (!path2.isAbsolute(root)) {
|
|
601
|
+
throw new CodegraphRuntimeError(
|
|
602
|
+
"store_error",
|
|
603
|
+
"codegraph DB root must be an absolute path; set codingKnowledge.codegraphDbDir (or memoryDir) to an absolute path"
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
return root;
|
|
607
|
+
}
|
|
608
|
+
function resolveCodegraphDbPath(params) {
|
|
609
|
+
const { config, memoryDir, principal, projectId } = params;
|
|
610
|
+
const root = resolveCodegraphRoot(config, memoryDir);
|
|
611
|
+
const principalSafe = sanitizePathSegment(principal);
|
|
612
|
+
const projectSafe = sanitizePathSegment(projectId);
|
|
613
|
+
return path2.join(root, principalSafe, `${projectSafe}.sqlite`);
|
|
614
|
+
}
|
|
615
|
+
function sanitizePathSegment(input) {
|
|
616
|
+
const trimmed = (input ?? "").trim();
|
|
617
|
+
if (trimmed.length === 0) return "_";
|
|
618
|
+
const sanitized = trimmed.replace(/[^A-Za-z0-9._:-]+/g, "_");
|
|
619
|
+
return sanitized.replace(/^\.+/, "").replace(/[/\\]+/g, "_") || "_";
|
|
620
|
+
}
|
|
621
|
+
var storeCache = /* @__PURE__ */ new Map();
|
|
622
|
+
function storeCacheKey(principalSafe, projectSafe, dbPath) {
|
|
623
|
+
return `${principalSafe}::${projectSafe}::${dbPath}`;
|
|
624
|
+
}
|
|
625
|
+
function isCodegraphModule(value) {
|
|
626
|
+
if (!value || typeof value !== "object") return false;
|
|
627
|
+
const candidate = value;
|
|
628
|
+
const graphStore = candidate.GraphStore;
|
|
629
|
+
return graphStore !== void 0 && typeof graphStore.open === "function";
|
|
630
|
+
}
|
|
631
|
+
async function resolveCodegraphModule() {
|
|
632
|
+
const mod = await tryLoadCodingGraphModule();
|
|
633
|
+
if (mod === null || !isCodegraphModule(mod)) return null;
|
|
634
|
+
return mod;
|
|
635
|
+
}
|
|
636
|
+
async function getCodegraphStore(params) {
|
|
637
|
+
const { config, memoryDir, principal, projectId, repoRoot } = params;
|
|
638
|
+
if (!codegraphSurfaceVisible(config)) {
|
|
639
|
+
throw new CodegraphRuntimeError(
|
|
640
|
+
"disabled",
|
|
641
|
+
"codegraph tools are disabled (codingKnowledge.enabled or codingKnowledge.codegraphTools is false)"
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
const mod = await resolveCodegraphModule();
|
|
645
|
+
if (mod === null) {
|
|
646
|
+
throw new CodegraphRuntimeError("package_missing", buildCodingGraphInstallHint());
|
|
647
|
+
}
|
|
648
|
+
const principalSafe = sanitizePathSegment(principal);
|
|
649
|
+
const projectSafe = sanitizePathSegment(projectId);
|
|
650
|
+
const dbPath = resolveCodegraphDbPath({ config, memoryDir, principal, projectId });
|
|
651
|
+
const key = storeCacheKey(principalSafe, projectSafe, dbPath);
|
|
652
|
+
const cached = storeCache.get(key);
|
|
653
|
+
if (cached !== void 0) {
|
|
654
|
+
if (repoRoot !== void 0 && cached.repoRoot === void 0) {
|
|
655
|
+
storeCache.delete(key);
|
|
656
|
+
try {
|
|
657
|
+
await cached.store.close();
|
|
658
|
+
} catch {
|
|
659
|
+
}
|
|
660
|
+
const store2 = await mod.GraphStore.open({ dbPath, repoRoot });
|
|
661
|
+
storeCache.set(key, { store: store2, repoRoot, openedAt: Date.now() });
|
|
662
|
+
return store2;
|
|
663
|
+
}
|
|
664
|
+
if (repoRoot !== void 0 && cached.repoRoot !== void 0 && cached.repoRoot !== repoRoot) {
|
|
665
|
+
throw new CodegraphRuntimeError(
|
|
666
|
+
"repo_root_conflict",
|
|
667
|
+
`codegraph store for project ${projectId} is already bound to repo root ${cached.repoRoot}; refusing to rebind to ${repoRoot}`
|
|
668
|
+
);
|
|
669
|
+
}
|
|
670
|
+
return cached.store;
|
|
671
|
+
}
|
|
672
|
+
const store = await mod.GraphStore.open({ dbPath, repoRoot });
|
|
673
|
+
storeCache.set(key, { store, repoRoot, openedAt: Date.now() });
|
|
674
|
+
return store;
|
|
675
|
+
}
|
|
676
|
+
function listCodegraphProjects(params) {
|
|
677
|
+
const { config, memoryDir, principal, listDir } = params;
|
|
678
|
+
if (!codegraphSurfaceVisible(config)) return [];
|
|
679
|
+
let root;
|
|
680
|
+
try {
|
|
681
|
+
root = resolveCodegraphRoot(config, memoryDir);
|
|
682
|
+
} catch {
|
|
683
|
+
return [];
|
|
684
|
+
}
|
|
685
|
+
const principalSafe = sanitizePathSegment(principal);
|
|
686
|
+
const principalDir = path2.join(root, principalSafe);
|
|
687
|
+
let entries;
|
|
688
|
+
try {
|
|
689
|
+
entries = listDir(principalDir);
|
|
690
|
+
} catch {
|
|
691
|
+
return [];
|
|
692
|
+
}
|
|
693
|
+
const projects = [];
|
|
694
|
+
for (const entry of entries) {
|
|
695
|
+
if (entry.endsWith(".sqlite")) {
|
|
696
|
+
projects.push(entry.slice(0, -".sqlite".length));
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
return projects;
|
|
700
|
+
}
|
|
701
|
+
async function deleteCodegraphProject(params) {
|
|
702
|
+
const { config, memoryDir, principal, projectId, confirm, removeFile } = params;
|
|
703
|
+
if (!confirm) {
|
|
704
|
+
throw new CodegraphRuntimeError(
|
|
705
|
+
"confirm_required",
|
|
706
|
+
"codegraph_delete_project requires confirm: true; destructive operations are never defaulted to proceed (rule 48)"
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
if (!codegraphSurfaceVisible(config)) {
|
|
710
|
+
throw new CodegraphRuntimeError("disabled", "codegraph tools are disabled");
|
|
711
|
+
}
|
|
712
|
+
const principalSafe = sanitizePathSegment(principal);
|
|
713
|
+
const projectSafe = sanitizePathSegment(projectId);
|
|
714
|
+
const dbPath = resolveCodegraphDbPath({ config, memoryDir, principal, projectId });
|
|
715
|
+
const key = storeCacheKey(principalSafe, projectSafe, dbPath);
|
|
716
|
+
const cached = storeCache.get(key);
|
|
717
|
+
if (cached !== void 0) {
|
|
718
|
+
storeCache.delete(key);
|
|
719
|
+
try {
|
|
720
|
+
await cached.store.close();
|
|
721
|
+
} catch {
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
let deleted = false;
|
|
725
|
+
try {
|
|
726
|
+
removeFile(dbPath);
|
|
727
|
+
deleted = true;
|
|
728
|
+
} catch (err) {
|
|
729
|
+
const code = err?.code;
|
|
730
|
+
if (code === "ENOENT") {
|
|
731
|
+
deleted = true;
|
|
732
|
+
} else {
|
|
733
|
+
deleted = false;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
return { deleted, projectId };
|
|
737
|
+
}
|
|
738
|
+
function makeCodegraphRuntimeDelegates() {
|
|
739
|
+
return {
|
|
740
|
+
runReindex: (store, repoRoot, mode) => runCodegraphReindex({ store, repoRoot, mode }),
|
|
741
|
+
reportIndexStatus: (store, repoRoot) => reportCodegraphIndexStatus({ store, repoRoot }),
|
|
742
|
+
detectChanges: (store, repoRoot, head) => detectCodegraphChanges({ store, repoRoot, head }),
|
|
743
|
+
ingestTraces: (store, traces) => ingestCodegraphTraces({ store, traces }),
|
|
744
|
+
runLspResolution: (store, repoRoot, lspConfig) => runCodegraphLspResolution({ store, repoRoot, lspConfig })
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
async function runCodegraphReindex(params) {
|
|
748
|
+
const mod = await resolveCodegraphModule();
|
|
749
|
+
if (mod === null) {
|
|
750
|
+
return { ok: false, code: "package_missing", message: "The @remnic/coding-graph package is not installed." };
|
|
751
|
+
}
|
|
752
|
+
if (typeof mod.executeReindex !== "function" || typeof mod.defaultCodingGitInvoker !== "function") {
|
|
753
|
+
return { ok: false, code: "runtime_unavailable", message: "executeReindex is not available in the installed @remnic/coding-graph." };
|
|
754
|
+
}
|
|
755
|
+
const git = mod.defaultCodingGitInvoker();
|
|
756
|
+
let engine;
|
|
757
|
+
try {
|
|
758
|
+
if (typeof mod.createCodingGraphEngine !== "function") {
|
|
759
|
+
return { ok: false, code: "engine_unavailable", message: "createCodingGraphEngine is not exported by @remnic/coding-graph." };
|
|
760
|
+
}
|
|
761
|
+
engine = mod.createCodingGraphEngine();
|
|
762
|
+
} catch (err) {
|
|
763
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
764
|
+
return { ok: false, code: "engine_unavailable", message: `The coding-graph engine is not ready: ${msg}` };
|
|
765
|
+
}
|
|
766
|
+
let candidatePaths = [];
|
|
767
|
+
try {
|
|
768
|
+
const tracked = git.listTrackedFiles(params.repoRoot);
|
|
769
|
+
if (tracked.ok) {
|
|
770
|
+
candidatePaths = tracked.paths;
|
|
771
|
+
}
|
|
772
|
+
} catch {
|
|
773
|
+
}
|
|
774
|
+
try {
|
|
775
|
+
const result = await mod.executeReindex({
|
|
776
|
+
store: params.store,
|
|
777
|
+
git,
|
|
778
|
+
repoRoot: params.repoRoot,
|
|
779
|
+
parseFile: (input) => engine.parseFile(input),
|
|
780
|
+
candidatePaths
|
|
781
|
+
});
|
|
782
|
+
if (result && result.ok === true) {
|
|
783
|
+
return { ok: true, mode: result.mode ?? "auto", filesIngested: result.filesIngested ?? 0, head: result.head ?? null };
|
|
784
|
+
}
|
|
785
|
+
return {
|
|
786
|
+
ok: false,
|
|
787
|
+
code: result?.code ?? "store_error",
|
|
788
|
+
message: result?.message ?? "executeReindex reported a failure."
|
|
789
|
+
};
|
|
790
|
+
} catch (err) {
|
|
791
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
792
|
+
return { ok: false, code: "store_error", message: msg };
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
async function lspPathEscapesRoot(repoRoot, absPath) {
|
|
796
|
+
try {
|
|
797
|
+
const [realRoot, realAbs] = await Promise.all([realpath(repoRoot), realpath(absPath)]);
|
|
798
|
+
const rel = path2.relative(realRoot, realAbs);
|
|
799
|
+
return rel === ".." || rel.startsWith(".." + path2.sep) || path2.isAbsolute(rel);
|
|
800
|
+
} catch {
|
|
801
|
+
return false;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
function lspPathEscapesRootSync(repoRoot, absPath) {
|
|
805
|
+
try {
|
|
806
|
+
const realRoot = realpathSync(repoRoot);
|
|
807
|
+
const realAbs = realpathSync(absPath);
|
|
808
|
+
const rel = path2.relative(realRoot, realAbs);
|
|
809
|
+
return rel === ".." || rel.startsWith(".." + path2.sep) || path2.isAbsolute(rel);
|
|
810
|
+
} catch {
|
|
811
|
+
return false;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
var DEFAULT_LSP_SERVERS = {
|
|
815
|
+
typescript: { command: "typescript-language-server", args: ["--stdio"] },
|
|
816
|
+
tsx: { command: "typescript-language-server", args: ["--stdio"] },
|
|
817
|
+
javascript: { command: "typescript-language-server", args: ["--stdio"] },
|
|
818
|
+
python: { command: "pyright-langserver", args: ["--stdio"] },
|
|
819
|
+
go: { command: "gopls", args: [] },
|
|
820
|
+
rust: { command: "rust-analyzer", args: [] }
|
|
821
|
+
};
|
|
822
|
+
async function runCodegraphLspResolution(params) {
|
|
823
|
+
const mod = await resolveCodegraphModule();
|
|
824
|
+
if (mod === null) {
|
|
825
|
+
return { ok: false, code: "package_missing", message: "@remnic/coding-graph is not installed." };
|
|
826
|
+
}
|
|
827
|
+
if (typeof mod.executeLspResolution !== "function" || typeof mod.planLspUpgrades !== "function" || typeof mod.LspClient?.connect !== "function") {
|
|
828
|
+
return { ok: false, code: "runtime_unavailable", message: "LSP resolution is not available in the installed @remnic/coding-graph." };
|
|
829
|
+
}
|
|
830
|
+
const engine = mod.createCodingGraphEngine?.() ?? null;
|
|
831
|
+
if (engine === null) {
|
|
832
|
+
return { ok: false, code: "engine_unavailable", message: "createCodingGraphEngine is not available." };
|
|
833
|
+
}
|
|
834
|
+
const repoRoot = path2.resolve(params.repoRoot);
|
|
835
|
+
const gitFactory = mod.defaultCodingGitInvoker;
|
|
836
|
+
if (typeof gitFactory !== "function") {
|
|
837
|
+
return { ok: true, upgraded: 0, unresolved: 0, budgetExhausted: 0 };
|
|
838
|
+
}
|
|
839
|
+
const tracked = gitFactory().listTrackedFiles(repoRoot);
|
|
840
|
+
if (!("paths" in tracked)) {
|
|
841
|
+
return { ok: true, upgraded: 0, unresolved: 0, budgetExhausted: 0 };
|
|
842
|
+
}
|
|
843
|
+
const resolvedCalleesBySrc = /* @__PURE__ */ new Map();
|
|
844
|
+
const alreadyResolved = (filePath, srcQualifiedName, calleeName) => {
|
|
845
|
+
const key = `${filePath}\0${srcQualifiedName}`;
|
|
846
|
+
let names = resolvedCalleesBySrc.get(key);
|
|
847
|
+
if (names === void 0) {
|
|
848
|
+
names = /* @__PURE__ */ new Set();
|
|
849
|
+
if (typeof params.store.resolvedCalleeNames === "function") {
|
|
850
|
+
for (const name of params.store.resolvedCalleeNames(srcQualifiedName, "heuristic", filePath)) {
|
|
851
|
+
names.add(name);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
resolvedCalleesBySrc.set(key, names);
|
|
855
|
+
}
|
|
856
|
+
return names.has(calleeName);
|
|
857
|
+
};
|
|
858
|
+
const sites = [];
|
|
859
|
+
const gatheredCountByFile = /* @__PURE__ */ new Map();
|
|
860
|
+
const filteredCountByFile = /* @__PURE__ */ new Map();
|
|
861
|
+
const filteredSrcByFile = /* @__PURE__ */ new Map();
|
|
862
|
+
const parsedFiles = /* @__PURE__ */ new Set();
|
|
863
|
+
for (const rel of tracked.paths) {
|
|
864
|
+
const absPath = path2.join(repoRoot, rel);
|
|
865
|
+
if (await lspPathEscapesRoot(repoRoot, absPath)) continue;
|
|
866
|
+
let content;
|
|
867
|
+
try {
|
|
868
|
+
content = await readFile2(absPath, "utf-8");
|
|
869
|
+
} catch {
|
|
870
|
+
continue;
|
|
871
|
+
}
|
|
872
|
+
let parsed;
|
|
873
|
+
try {
|
|
874
|
+
parsed = await engine.parseFile({ path: rel, content });
|
|
875
|
+
} catch {
|
|
876
|
+
continue;
|
|
877
|
+
}
|
|
878
|
+
if (!parsed || typeof parsed !== "object" || !("ok" in parsed) || parsed.ok !== true || !("ir" in parsed)) continue;
|
|
879
|
+
const ir = parsed.ir;
|
|
880
|
+
if (!ir || typeof ir !== "object" || !("callSites" in ir) || !Array.isArray(ir.callSites)) continue;
|
|
881
|
+
parsedFiles.add(rel);
|
|
882
|
+
const language = "language" in ir && typeof ir.language === "string" ? ir.language : "";
|
|
883
|
+
const symbols = "symbols" in ir && Array.isArray(ir.symbols) ? ir.symbols : [];
|
|
884
|
+
const contentBytes = Buffer.from(content, "utf-8");
|
|
885
|
+
for (const site of ir.callSites) {
|
|
886
|
+
if (!site || typeof site !== "object" || !("span" in site)) continue;
|
|
887
|
+
const span = site.span;
|
|
888
|
+
if (!span || typeof span !== "object" || !("startByte" in span) || typeof span.startByte !== "number") continue;
|
|
889
|
+
const calleeName = "calleeNameCandidates" in site && Array.isArray(site.calleeNameCandidates) && typeof site.calleeNameCandidates[0] === "string" ? site.calleeNameCandidates[0] : "";
|
|
890
|
+
if (calleeName.length === 0) continue;
|
|
891
|
+
let srcQualifiedName = "";
|
|
892
|
+
let bestSpanSize = Number.POSITIVE_INFINITY;
|
|
893
|
+
for (const sym of symbols) {
|
|
894
|
+
if (!sym || typeof sym !== "object" || !("span" in sym) || !("qualifiedName" in sym)) continue;
|
|
895
|
+
const ss = sym.span;
|
|
896
|
+
if (!ss || typeof ss !== "object" || !("startByte" in ss) || !("endByte" in ss)) continue;
|
|
897
|
+
if (typeof ss.startByte !== "number" || typeof ss.endByte !== "number") continue;
|
|
898
|
+
if (ss.startByte <= span.startByte && span.startByte < ss.endByte) {
|
|
899
|
+
const size = ss.endByte - ss.startByte;
|
|
900
|
+
if (size < bestSpanSize) {
|
|
901
|
+
bestSpanSize = size;
|
|
902
|
+
srcQualifiedName = typeof sym.qualifiedName === "string" ? sym.qualifiedName : "";
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
if (srcQualifiedName.length === 0) continue;
|
|
907
|
+
const memberAccess = "memberAccess" in site && site.memberAccess === true;
|
|
908
|
+
if (!memberAccess && alreadyResolved(rel, srcQualifiedName, calleeName)) {
|
|
909
|
+
filteredCountByFile.set(rel, (filteredCountByFile.get(rel) ?? 0) + 1);
|
|
910
|
+
let srcs = filteredSrcByFile.get(rel);
|
|
911
|
+
if (srcs === void 0) {
|
|
912
|
+
srcs = /* @__PURE__ */ new Map();
|
|
913
|
+
filteredSrcByFile.set(rel, srcs);
|
|
914
|
+
}
|
|
915
|
+
const callees = srcs.get(srcQualifiedName);
|
|
916
|
+
if (callees === void 0) srcs.set(srcQualifiedName, /* @__PURE__ */ new Set([calleeName]));
|
|
917
|
+
else callees.add(calleeName);
|
|
918
|
+
continue;
|
|
919
|
+
}
|
|
920
|
+
const nameIdx = contentBytes.indexOf(Buffer.from(calleeName, "utf-8"), span.startByte);
|
|
921
|
+
const endByte = "endByte" in span && typeof span.endByte === "number" ? span.endByte : span.startByte + calleeName.length;
|
|
922
|
+
const calleeByteOffset = nameIdx >= 0 && nameIdx < endByte ? nameIdx : span.startByte;
|
|
923
|
+
sites.push({ filePath: rel, language, content, calleeByteOffset, calleeName, srcQualifiedName });
|
|
924
|
+
gatheredCountByFile.set(rel, (gatheredCountByFile.get(rel) ?? 0) + 1);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
const canPreserve = typeof params.store.callEdgesForCaller === "function";
|
|
928
|
+
const preservedEdgesForFile = (rel) => {
|
|
929
|
+
const srcs = filteredSrcByFile.get(rel);
|
|
930
|
+
if (srcs === void 0 || !canPreserve) return [];
|
|
931
|
+
const preserved = [];
|
|
932
|
+
for (const [src] of srcs) {
|
|
933
|
+
const heuristicDsts = new Set(
|
|
934
|
+
params.store.callEdgesForCaller(src, rel, "heuristic").map((e) => e.dstQualifiedName)
|
|
935
|
+
);
|
|
936
|
+
for (const edge of params.store.callEdgesForCaller(src, rel, "lsp")) {
|
|
937
|
+
if (!heuristicDsts.has(edge.dstQualifiedName)) continue;
|
|
938
|
+
preserved.push({
|
|
939
|
+
srcQualifiedName: edge.srcQualifiedName,
|
|
940
|
+
dstQualifiedName: edge.dstQualifiedName,
|
|
941
|
+
type: edge.type
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
return preserved;
|
|
946
|
+
};
|
|
947
|
+
if (typeof params.store.reconcileLspEdges === "function") {
|
|
948
|
+
for (const rel of parsedFiles) {
|
|
949
|
+
if ((gatheredCountByFile.get(rel) ?? 0) !== 0) continue;
|
|
950
|
+
const filteredCount = filteredCountByFile.get(rel) ?? 0;
|
|
951
|
+
if (filteredCount > 0 && !canPreserve) continue;
|
|
952
|
+
params.store.reconcileLspEdges(rel, preservedEdgesForFile(rel));
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
if (sites.length === 0) {
|
|
956
|
+
return { ok: true, upgraded: 0, unresolved: 0, budgetExhausted: 0 };
|
|
957
|
+
}
|
|
958
|
+
const byLanguage = /* @__PURE__ */ new Map();
|
|
959
|
+
const srcToFiles = /* @__PURE__ */ new Map();
|
|
960
|
+
for (const site of sites) {
|
|
961
|
+
const group = byLanguage.get(site.language);
|
|
962
|
+
if (group === void 0) byLanguage.set(site.language, [site]);
|
|
963
|
+
else group.push(site);
|
|
964
|
+
const files = srcToFiles.get(site.srcQualifiedName);
|
|
965
|
+
if (files === void 0) srcToFiles.set(site.srcQualifiedName, /* @__PURE__ */ new Set([site.filePath]));
|
|
966
|
+
else files.add(site.filePath);
|
|
967
|
+
}
|
|
968
|
+
const configServers = params.lspConfig.servers ?? {};
|
|
969
|
+
const timeoutMs = params.lspConfig.timeoutMs ?? 3e3;
|
|
970
|
+
let remainingBudget = Math.max(1, Math.floor(params.lspConfig.maxRequestsPerRun ?? 500));
|
|
971
|
+
const rootUri = pathToFileURL(repoRoot).href;
|
|
972
|
+
const resolveContent = (filePath) => {
|
|
973
|
+
const absPath = path2.join(repoRoot, filePath);
|
|
974
|
+
if (lspPathEscapesRootSync(repoRoot, absPath)) return null;
|
|
975
|
+
try {
|
|
976
|
+
return readFileSync(absPath, "utf-8");
|
|
977
|
+
} catch {
|
|
978
|
+
return null;
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
let upgraded = 0;
|
|
982
|
+
let unresolved = 0;
|
|
983
|
+
let budgetExhausted = 0;
|
|
984
|
+
const degradations = [];
|
|
985
|
+
for (const [language, group] of byLanguage) {
|
|
986
|
+
if (remainingBudget <= 0) {
|
|
987
|
+
budgetExhausted += group.length;
|
|
988
|
+
continue;
|
|
989
|
+
}
|
|
990
|
+
const rawSpec = configServers[language] ?? DEFAULT_LSP_SERVERS[language];
|
|
991
|
+
if (rawSpec === void 0) {
|
|
992
|
+
degradations.push({
|
|
993
|
+
language,
|
|
994
|
+
code: "no_launch_spec",
|
|
995
|
+
message: `No LSP server configured for ${language} (${group.length} candidate call site(s)); set codingKnowledge.lsp.servers.${language}.`
|
|
996
|
+
});
|
|
997
|
+
unresolved += group.length;
|
|
998
|
+
continue;
|
|
999
|
+
}
|
|
1000
|
+
const launchSpec = { command: rawSpec.command, args: rawSpec.args ?? [] };
|
|
1001
|
+
const plan = mod.planLspUpgrades(group, { maxRequests: remainingBudget });
|
|
1002
|
+
budgetExhausted += plan.budgetExhausted;
|
|
1003
|
+
remainingBudget -= plan.requests.length;
|
|
1004
|
+
if (plan.requests.length === 0) continue;
|
|
1005
|
+
const plannedCountByFile = /* @__PURE__ */ new Map();
|
|
1006
|
+
for (const req of plan.requests) {
|
|
1007
|
+
if (req && typeof req === "object" && "filePath" in req && typeof req.filePath === "string") {
|
|
1008
|
+
plannedCountByFile.set(req.filePath, (plannedCountByFile.get(req.filePath) ?? 0) + 1);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
const connected = await mod.LspClient.connect({ launchSpec, rootUri, timeoutMs });
|
|
1012
|
+
if (!connected.ok) {
|
|
1013
|
+
const deg = connected.degradation;
|
|
1014
|
+
const code = deg && typeof deg === "object" && "code" in deg && typeof deg.code === "string" ? deg.code : "connect_failed";
|
|
1015
|
+
const message = deg && typeof deg === "object" && "detail" in deg && typeof deg.detail === "string" ? deg.detail : `LSP server for ${language} failed to connect.`;
|
|
1016
|
+
degradations.push({ language, code, message });
|
|
1017
|
+
unresolved += plan.requests.length;
|
|
1018
|
+
remainingBudget += plan.requests.length;
|
|
1019
|
+
continue;
|
|
1020
|
+
}
|
|
1021
|
+
const client = connected.client;
|
|
1022
|
+
let skippedEdgesTotal = 0;
|
|
1023
|
+
const skippedFiles = /* @__PURE__ */ new Set();
|
|
1024
|
+
try {
|
|
1025
|
+
const result = await mod.executeLspResolution(plan.requests, {
|
|
1026
|
+
client,
|
|
1027
|
+
workspaceRoot: repoRoot,
|
|
1028
|
+
resolveContent,
|
|
1029
|
+
nodeLocator: (filePath, byteOffset) => typeof params.store.findNodeBySpan === "function" ? params.store.findNodeBySpan(filePath, byteOffset) : null,
|
|
1030
|
+
applyUpgrades: async (upgrades) => {
|
|
1031
|
+
if (typeof params.store.upsertEdges !== "function") {
|
|
1032
|
+
throw new Error("store.upsertEdges is not available");
|
|
1033
|
+
}
|
|
1034
|
+
const result2 = await params.store.upsertEdges(upgrades);
|
|
1035
|
+
if (!result2.ok) {
|
|
1036
|
+
degradations.push({
|
|
1037
|
+
language,
|
|
1038
|
+
code: "edge_write_failed",
|
|
1039
|
+
message: `upsertEdges failed for ${language}: ${result2.code}.`
|
|
1040
|
+
});
|
|
1041
|
+
throw new Error(`upsertEdges failed: ${result2.code}`);
|
|
1042
|
+
}
|
|
1043
|
+
if (result2.skipped > 0) {
|
|
1044
|
+
skippedEdgesTotal += result2.skipped;
|
|
1045
|
+
for (const upgrade of upgrades) {
|
|
1046
|
+
for (const file of srcToFiles.get(upgrade.srcQualifiedName) ?? []) {
|
|
1047
|
+
skippedFiles.add(file);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
degradations.push({
|
|
1051
|
+
language,
|
|
1052
|
+
code: "edges_skipped",
|
|
1053
|
+
message: `upsertEdges persisted ${result2.persisted} and skipped ${result2.skipped} edge(s) for ${language} (unresolvable endpoints).`
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
},
|
|
1057
|
+
reconcileLspEdges: (filePath, assertedEdges) => {
|
|
1058
|
+
if (typeof params.store.reconcileLspEdges !== "function") return;
|
|
1059
|
+
if (plannedCountByFile.get(filePath) !== gatheredCountByFile.get(filePath)) return;
|
|
1060
|
+
if (skippedFiles.has(filePath)) return;
|
|
1061
|
+
if ((filteredCountByFile.get(filePath) ?? 0) > 0 && !canPreserve) return;
|
|
1062
|
+
params.store.reconcileLspEdges(filePath, [...assertedEdges, ...preservedEdgesForFile(filePath)]);
|
|
1063
|
+
}
|
|
1064
|
+
});
|
|
1065
|
+
if (result && typeof result === "object" && "upgraded" in result && typeof result.upgraded === "number") {
|
|
1066
|
+
upgraded += Math.max(0, result.upgraded - skippedEdgesTotal);
|
|
1067
|
+
unresolved += "unresolved" in result && typeof result.unresolved === "number" ? result.unresolved : 0;
|
|
1068
|
+
budgetExhausted += "budgetExhausted" in result && typeof result.budgetExhausted === "number" ? result.budgetExhausted : 0;
|
|
1069
|
+
if ("degradation" in result && result.degradation && typeof result.degradation === "object") {
|
|
1070
|
+
const rd = result.degradation;
|
|
1071
|
+
degradations.push({
|
|
1072
|
+
language,
|
|
1073
|
+
code: "code" in rd && typeof rd.code === "string" ? rd.code : "lsp_degraded",
|
|
1074
|
+
message: "detail" in rd && typeof rd.detail === "string" ? rd.detail : `LSP pass for ${language} degraded mid-run.`
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
} else {
|
|
1078
|
+
unresolved += plan.requests.length;
|
|
1079
|
+
}
|
|
1080
|
+
} catch (err) {
|
|
1081
|
+
const detail = displayErrorDetail(err);
|
|
1082
|
+
return {
|
|
1083
|
+
ok: false,
|
|
1084
|
+
code: "lsp_resolution_error",
|
|
1085
|
+
message: detail.length > 0 ? `LSP resolution failed: ${detail}.` : "LSP resolution failed."
|
|
1086
|
+
};
|
|
1087
|
+
} finally {
|
|
1088
|
+
const disposable = client;
|
|
1089
|
+
if (typeof disposable.dispose === "function") {
|
|
1090
|
+
try {
|
|
1091
|
+
await disposable.dispose();
|
|
1092
|
+
} catch {
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
return {
|
|
1098
|
+
ok: true,
|
|
1099
|
+
upgraded,
|
|
1100
|
+
unresolved,
|
|
1101
|
+
budgetExhausted,
|
|
1102
|
+
...degradations.length > 0 ? { degradations } : {}
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
async function reportCodegraphIndexStatus(params) {
|
|
1106
|
+
const mod = await resolveCodegraphModule();
|
|
1107
|
+
if (mod === null) {
|
|
1108
|
+
return { ok: false, code: "package_missing", message: "The @remnic/coding-graph package is not installed." };
|
|
1109
|
+
}
|
|
1110
|
+
if (typeof mod.getIndexStatus !== "function" || typeof mod.defaultCodingGitInvoker !== "function") {
|
|
1111
|
+
return { ok: false, code: "runtime_unavailable", message: "getIndexStatus is not available in the installed @remnic/coding-graph." };
|
|
1112
|
+
}
|
|
1113
|
+
const git = mod.defaultCodingGitInvoker();
|
|
1114
|
+
try {
|
|
1115
|
+
const status = mod.getIndexStatus(params.store, git, params.repoRoot);
|
|
1116
|
+
return { ok: true, status };
|
|
1117
|
+
} catch (err) {
|
|
1118
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1119
|
+
return { ok: false, code: "store_error", message: msg };
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
async function detectCodegraphChanges(params) {
|
|
1123
|
+
const mod = await resolveCodegraphModule();
|
|
1124
|
+
if (mod === null) {
|
|
1125
|
+
return { ok: false, code: "package_missing", message: "The @remnic/coding-graph package is not installed." };
|
|
1126
|
+
}
|
|
1127
|
+
if (typeof mod.computeBlastRadius !== "function") {
|
|
1128
|
+
return { ok: false, code: "runtime_unavailable", message: "computeBlastRadius is not available in the installed @remnic/coding-graph." };
|
|
1129
|
+
}
|
|
1130
|
+
let engine;
|
|
1131
|
+
try {
|
|
1132
|
+
if (typeof mod.createCodingGraphEngine !== "function") {
|
|
1133
|
+
return { ok: false, code: "engine_unavailable", message: "createCodingGraphEngine is not exported by @remnic/coding-graph." };
|
|
1134
|
+
}
|
|
1135
|
+
engine = mod.createCodingGraphEngine();
|
|
1136
|
+
} catch (err) {
|
|
1137
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1138
|
+
return { ok: false, code: "engine_unavailable", message: `The coding-graph engine is not ready: ${msg}` };
|
|
1139
|
+
}
|
|
1140
|
+
void engine;
|
|
1141
|
+
void params;
|
|
1142
|
+
try {
|
|
1143
|
+
const result = mod.computeBlastRadius(params.store, /* @__PURE__ */ new Set());
|
|
1144
|
+
if (result && result.ok === true) {
|
|
1145
|
+
return { ok: true, affected: result.affected ?? [] };
|
|
1146
|
+
}
|
|
1147
|
+
return { ok: false, code: result?.code ?? "store_error", message: "computeBlastRadius reported a failure." };
|
|
1148
|
+
} catch (err) {
|
|
1149
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1150
|
+
return { ok: false, code: "store_error", message: msg };
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
async function ingestCodegraphTraces(params) {
|
|
1154
|
+
if (typeof params.store.upsertEdges !== "function") {
|
|
1155
|
+
return {
|
|
1156
|
+
ok: false,
|
|
1157
|
+
code: "runtime_unavailable",
|
|
1158
|
+
message: "The installed @remnic/coding-graph does not expose upsertEdges; traces cannot be persisted."
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
const edges = [];
|
|
1162
|
+
let accepted = 0;
|
|
1163
|
+
for (const trace of params.traces) {
|
|
1164
|
+
const t = trace;
|
|
1165
|
+
if (typeof t?.caller !== "string" || typeof t?.callee !== "string") {
|
|
1166
|
+
continue;
|
|
1167
|
+
}
|
|
1168
|
+
accepted += 1;
|
|
1169
|
+
edges.push({
|
|
1170
|
+
srcQualifiedName: t.caller,
|
|
1171
|
+
dstQualifiedName: t.callee,
|
|
1172
|
+
type: "HTTP_CALLS",
|
|
1173
|
+
confidence: typeof t.confidence === "number" && t.confidence >= 0 && t.confidence <= 1 ? t.confidence : 0.5,
|
|
1174
|
+
provenance: "trace"
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
try {
|
|
1178
|
+
const result = await params.store.upsertEdges(edges);
|
|
1179
|
+
if (result.ok === true) {
|
|
1180
|
+
return { ok: true, accepted, persisted: result.persisted, skipped: result.skipped };
|
|
1181
|
+
}
|
|
1182
|
+
return { ok: false, code: result.code, message: "store.upsertEdges reported a failure." };
|
|
1183
|
+
} catch (err) {
|
|
1184
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1185
|
+
return { ok: false, code: "store_error", message: msg };
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
function deriveCodegraphProjectId(repoRoot) {
|
|
1189
|
+
return `root:${createHash("sha256").update(repoRoot).digest("hex").slice(0, 16)}`;
|
|
1190
|
+
}
|
|
1191
|
+
function resolveCodegraphProjectId(params) {
|
|
1192
|
+
const { request, getCodingContext } = params;
|
|
1193
|
+
const explicit = typeof request.project === "string" ? request.project.trim() : "";
|
|
1194
|
+
if (explicit.length > 0) return explicit;
|
|
1195
|
+
const sessionKey = typeof request.sessionKey === "string" ? request.sessionKey.trim() : "";
|
|
1196
|
+
if (sessionKey.length > 0) {
|
|
1197
|
+
const cc = getCodingContext(sessionKey);
|
|
1198
|
+
if (cc !== null) return cc.projectId;
|
|
1199
|
+
}
|
|
1200
|
+
const repoRoot = typeof request.repoRoot === "string" ? request.repoRoot.trim() : "";
|
|
1201
|
+
if (repoRoot.length > 0) return deriveCodegraphProjectId(repoRoot);
|
|
1202
|
+
throw new CodegraphRuntimeError(
|
|
1203
|
+
"project_required",
|
|
1204
|
+
"codegraph: project must be supplied explicitly, via a session coding context, or alongside a repoRoot"
|
|
1205
|
+
);
|
|
1206
|
+
}
|
|
1207
|
+
var CodegraphRuntimeError = class extends Error {
|
|
1208
|
+
code;
|
|
1209
|
+
constructor(code, message) {
|
|
1210
|
+
super(message);
|
|
1211
|
+
this.name = "CodegraphRuntimeError";
|
|
1212
|
+
this.code = code;
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
|
|
1216
|
+
// src/coding/decision-records.ts
|
|
1217
|
+
var DECISION_STATUSES = [
|
|
1218
|
+
"proposed",
|
|
1219
|
+
"accepted",
|
|
1220
|
+
"superseded",
|
|
1221
|
+
"rejected"
|
|
1222
|
+
];
|
|
1223
|
+
var ACTIVE_DECISION_STATUSES = /* @__PURE__ */ new Set([
|
|
1224
|
+
"proposed",
|
|
1225
|
+
"accepted"
|
|
1226
|
+
]);
|
|
1227
|
+
var DEFAULT_DECISION_STATUS = "proposed";
|
|
1228
|
+
var DECISION_STATUS_BY_VALUE = Object.freeze({
|
|
1229
|
+
proposed: "proposed",
|
|
1230
|
+
accepted: "accepted",
|
|
1231
|
+
superseded: "superseded",
|
|
1232
|
+
rejected: "rejected"
|
|
1233
|
+
});
|
|
1234
|
+
function isDecisionStatus(value) {
|
|
1235
|
+
return typeof value === "string" && Object.prototype.hasOwnProperty.call(DECISION_STATUS_BY_VALUE, value);
|
|
1236
|
+
}
|
|
1237
|
+
var FRONTMATTER_KEYS = Object.freeze([
|
|
1238
|
+
"id",
|
|
1239
|
+
"title",
|
|
1240
|
+
"status",
|
|
1241
|
+
"context",
|
|
1242
|
+
"decision",
|
|
1243
|
+
"consequences",
|
|
1244
|
+
"entityRefs",
|
|
1245
|
+
"supersedes"
|
|
1246
|
+
]);
|
|
1247
|
+
function serializeDecisionRecord(record) {
|
|
1248
|
+
const lines = ["---"];
|
|
1249
|
+
for (const key of FRONTMATTER_KEYS) {
|
|
1250
|
+
const present = key === "supersedes" ? record.supersedes !== void 0 : key === "consequences" ? record.consequences !== void 0 : true;
|
|
1251
|
+
if (!present) continue;
|
|
1252
|
+
lines.push(`${key}: ${encodeFrontmatterValue(key, record)}`);
|
|
1253
|
+
}
|
|
1254
|
+
lines.push("---", "");
|
|
1255
|
+
if (record.context) lines.push(record.context);
|
|
1256
|
+
lines.push("");
|
|
1257
|
+
lines.push("# Decision");
|
|
1258
|
+
lines.push("");
|
|
1259
|
+
if (record.decision) lines.push(record.decision);
|
|
1260
|
+
if (record.consequences !== void 0 && record.consequences.length > 0) {
|
|
1261
|
+
lines.push("");
|
|
1262
|
+
lines.push("# Consequences");
|
|
1263
|
+
lines.push("");
|
|
1264
|
+
lines.push(record.consequences);
|
|
1265
|
+
}
|
|
1266
|
+
if (record.entityRefs.length > 0) {
|
|
1267
|
+
lines.push("");
|
|
1268
|
+
lines.push("# Entity references");
|
|
1269
|
+
for (const ref of record.entityRefs) lines.push(`- ${ref}`);
|
|
1270
|
+
}
|
|
1271
|
+
lines.push("");
|
|
1272
|
+
return lines.join("\n");
|
|
1273
|
+
}
|
|
1274
|
+
function encodeFrontmatterValue(key, record) {
|
|
1275
|
+
if (key === "entityRefs") {
|
|
1276
|
+
const refs = record.entityRefs;
|
|
1277
|
+
if (refs.length === 0) return "[]";
|
|
1278
|
+
const inner = refs.map((ref) => `"${escapeYamlString(ref)}"`).join(", ");
|
|
1279
|
+
return `[${inner}]`;
|
|
1280
|
+
}
|
|
1281
|
+
if (key === "status") return `"${record.status}"`;
|
|
1282
|
+
if (key === "supersedes") return `"${record.supersedes ?? ""}"`;
|
|
1283
|
+
if (key === "consequences") return `"${escapeYamlString(record.consequences ?? "")}"`;
|
|
1284
|
+
const value = record[key];
|
|
1285
|
+
return `"${escapeYamlString(typeof value === "string" ? value : String(value))}"`;
|
|
1286
|
+
}
|
|
1287
|
+
function escapeYamlString(value) {
|
|
1288
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n");
|
|
1289
|
+
}
|
|
1290
|
+
function parseDecisionRecord(raw) {
|
|
1291
|
+
const { fields, body } = extractFrontmatter(raw);
|
|
1292
|
+
for (const fieldKey of Object.keys(fields)) {
|
|
1293
|
+
if (!FRONTMATTER_KEYS.includes(fieldKey)) {
|
|
1294
|
+
throw new Error(
|
|
1295
|
+
`decision record frontmatter contains unknown key '${fieldKey}'; valid keys are ${FRONTMATTER_KEYS.join(", ")}.`
|
|
1296
|
+
);
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
const id = requireString(fields.id, "id");
|
|
1300
|
+
const title = requireString(fields.title, "title");
|
|
1301
|
+
const context = requireString(fields.context, "context");
|
|
1302
|
+
const decision = requireString(fields.decision, "decision");
|
|
1303
|
+
const consequences = fields.consequences === void 0 ? void 0 : requireString(fields.consequences, "consequences");
|
|
1304
|
+
let status = DEFAULT_DECISION_STATUS;
|
|
1305
|
+
if (fields.status !== void 0 && fields.status !== null) {
|
|
1306
|
+
if (!isDecisionStatus(fields.status)) {
|
|
1307
|
+
throw new Error(
|
|
1308
|
+
`decision '${id}' has invalid status '${JSON.stringify(fields.status)}'; valid statuses are ${DECISION_STATUSES.join(", ")}.`
|
|
1309
|
+
);
|
|
1310
|
+
}
|
|
1311
|
+
status = fields.status;
|
|
1312
|
+
}
|
|
1313
|
+
const entityRefs = parseEntityRefs(fields.entityRefs);
|
|
1314
|
+
const supersedes = fields.supersedes === void 0 ? void 0 : requireString(fields.supersedes, "supersedes");
|
|
1315
|
+
const record = {
|
|
1316
|
+
id,
|
|
1317
|
+
title,
|
|
1318
|
+
status,
|
|
1319
|
+
context,
|
|
1320
|
+
decision,
|
|
1321
|
+
consequences,
|
|
1322
|
+
entityRefs,
|
|
1323
|
+
...supersedes !== void 0 ? { supersedes } : {}
|
|
1324
|
+
};
|
|
1325
|
+
void body;
|
|
1326
|
+
return record;
|
|
1327
|
+
}
|
|
1328
|
+
function requireString(field, key) {
|
|
1329
|
+
if (field === void 0 || field === null) {
|
|
1330
|
+
throw new Error(`decision record frontmatter is missing required field '${key}'.`);
|
|
1331
|
+
}
|
|
1332
|
+
if (typeof field !== "string") {
|
|
1333
|
+
throw new Error(
|
|
1334
|
+
`decision record frontmatter field '${key}' must be a string; got ${JSON.stringify(field)}.`
|
|
1335
|
+
);
|
|
1336
|
+
}
|
|
1337
|
+
return field;
|
|
1338
|
+
}
|
|
1339
|
+
function parseEntityRefs(field) {
|
|
1340
|
+
if (field === void 0) return [];
|
|
1341
|
+
if (!Array.isArray(field)) {
|
|
1342
|
+
throw new Error(
|
|
1343
|
+
`decision record frontmatter field 'entityRefs' must be an array of strings; got ${JSON.stringify(field)}.`
|
|
1344
|
+
);
|
|
1345
|
+
}
|
|
1346
|
+
for (const entry of field) {
|
|
1347
|
+
if (typeof entry !== "string") {
|
|
1348
|
+
throw new Error(
|
|
1349
|
+
`decision record frontmatter 'entityRefs' entries must be strings; got ${JSON.stringify(entry)}.`
|
|
1350
|
+
);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
return [...field];
|
|
1354
|
+
}
|
|
1355
|
+
function extractFrontmatter(raw) {
|
|
1356
|
+
const text = raw.charCodeAt(0) === 65279 ? raw.slice(1) : raw;
|
|
1357
|
+
if (!text.startsWith("---\n")) {
|
|
1358
|
+
throw new Error(
|
|
1359
|
+
"decision record must start with a YAML frontmatter fence (`---\\n`); got a document with no leading fence."
|
|
1360
|
+
);
|
|
1361
|
+
}
|
|
1362
|
+
const closeAt = text.indexOf("\n---", 4);
|
|
1363
|
+
if (closeAt === -1) {
|
|
1364
|
+
throw new Error(
|
|
1365
|
+
"decision record frontmatter is missing its closing fence (`\\n---`); the document is truncated."
|
|
1366
|
+
);
|
|
1367
|
+
}
|
|
1368
|
+
const yamlBody = text.slice(4, closeAt);
|
|
1369
|
+
const after = text.slice(closeAt + 4);
|
|
1370
|
+
const body = after.startsWith("\n") ? after.slice(1) : after;
|
|
1371
|
+
return { fields: parseYamlMapping(yamlBody), body };
|
|
1372
|
+
}
|
|
1373
|
+
function parseYamlMapping(input) {
|
|
1374
|
+
const fields = {};
|
|
1375
|
+
for (const rawLine of input.split("\n")) {
|
|
1376
|
+
const line = rawLine.trimEnd();
|
|
1377
|
+
if (line.length === 0 || line.startsWith("#")) continue;
|
|
1378
|
+
const colonAt = line.indexOf(":");
|
|
1379
|
+
if (colonAt === -1) {
|
|
1380
|
+
throw new Error(`decision record frontmatter line is not a key:value pair: "${line}".`);
|
|
1381
|
+
}
|
|
1382
|
+
const key = line.slice(0, colonAt).trim();
|
|
1383
|
+
const valueText = line.slice(colonAt + 1).trim();
|
|
1384
|
+
if (key.length === 0) {
|
|
1385
|
+
throw new Error(`decision record frontmatter has an empty key in line: "${line}".`);
|
|
1386
|
+
}
|
|
1387
|
+
fields[key] = decodeScalar(valueText);
|
|
1388
|
+
}
|
|
1389
|
+
return fields;
|
|
1390
|
+
}
|
|
1391
|
+
function decodeScalar(valueText) {
|
|
1392
|
+
if (valueText.length === 0) return "";
|
|
1393
|
+
const lower = valueText.toLowerCase();
|
|
1394
|
+
if (lower === "true") return true;
|
|
1395
|
+
if (lower === "false") return false;
|
|
1396
|
+
if (lower === "null" || lower === "~") return null;
|
|
1397
|
+
if (/^-?\d+$/.test(valueText)) return Number(valueText);
|
|
1398
|
+
if (/^".*"$/.test(valueText)) {
|
|
1399
|
+
return valueText.slice(1, -1).replace(/\\\\/g, "\0").replace(/\\n/g, "\n").replace(/\\"/g, '"').replace(/\u0000/g, "\\");
|
|
1400
|
+
}
|
|
1401
|
+
if (/^\[.*\]$/.test(valueText)) return parseFlowList(valueText);
|
|
1402
|
+
return valueText;
|
|
1403
|
+
}
|
|
1404
|
+
function parseFlowList(valueText) {
|
|
1405
|
+
const inner = valueText.slice(1, -1).trim();
|
|
1406
|
+
if (inner.length === 0) return [];
|
|
1407
|
+
const out = [];
|
|
1408
|
+
let buf = "";
|
|
1409
|
+
let inQuotes = false;
|
|
1410
|
+
let escaped = false;
|
|
1411
|
+
for (let i = 0; i < inner.length; i += 1) {
|
|
1412
|
+
const c = inner[i];
|
|
1413
|
+
if (escaped) {
|
|
1414
|
+
buf += c;
|
|
1415
|
+
escaped = false;
|
|
1416
|
+
continue;
|
|
1417
|
+
}
|
|
1418
|
+
if (c === "\\") {
|
|
1419
|
+
buf += c;
|
|
1420
|
+
escaped = true;
|
|
1421
|
+
continue;
|
|
1422
|
+
}
|
|
1423
|
+
if (c === '"') {
|
|
1424
|
+
inQuotes = !inQuotes;
|
|
1425
|
+
buf += c;
|
|
1426
|
+
continue;
|
|
1427
|
+
}
|
|
1428
|
+
if (c === "," && !inQuotes) {
|
|
1429
|
+
out.push(stripFlowStringQuotes(buf.trim()));
|
|
1430
|
+
buf = "";
|
|
1431
|
+
continue;
|
|
1432
|
+
}
|
|
1433
|
+
buf += c;
|
|
1434
|
+
}
|
|
1435
|
+
if (buf.length > 0) out.push(stripFlowStringQuotes(buf.trim()));
|
|
1436
|
+
return out;
|
|
1437
|
+
}
|
|
1438
|
+
function stripFlowStringQuotes(value) {
|
|
1439
|
+
if (value.length >= 2 && value.startsWith('"') && value.endsWith('"')) {
|
|
1440
|
+
return value.slice(1, -1).replace(/\\\\/g, "\0").replace(/\\n/g, "\n").replace(/\\"/g, '"').replace(/\u0000/g, "\\");
|
|
1441
|
+
}
|
|
1442
|
+
return value;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
export {
|
|
1446
|
+
createArchitectureCardSummariser,
|
|
1447
|
+
buildArchitectureCard,
|
|
1448
|
+
handleCodingArchitecture,
|
|
1449
|
+
findArchitectureCardMemory,
|
|
1450
|
+
createArchitectureVersioningHook,
|
|
1451
|
+
codegraphSurfaceVisible,
|
|
1452
|
+
resolveCodegraphDbPath,
|
|
1453
|
+
getCodegraphStore,
|
|
1454
|
+
listCodegraphProjects,
|
|
1455
|
+
deleteCodegraphProject,
|
|
1456
|
+
makeCodegraphRuntimeDelegates,
|
|
1457
|
+
resolveCodegraphProjectId,
|
|
1458
|
+
CodegraphRuntimeError,
|
|
1459
|
+
DECISION_STATUSES,
|
|
1460
|
+
ACTIVE_DECISION_STATUSES,
|
|
1461
|
+
DEFAULT_DECISION_STATUS,
|
|
1462
|
+
isDecisionStatus,
|
|
1463
|
+
serializeDecisionRecord,
|
|
1464
|
+
parseDecisionRecord
|
|
1465
|
+
};
|
|
1466
|
+
//# sourceMappingURL=chunk-QJCWK2A7.js.map
|