@remnic/core 9.65.3 → 9.65.4
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 -11
- package/dist/access-admin-ops-surface.js +20 -18
- package/dist/access-authorization-probe.d.ts +11 -11
- package/dist/access-authorization-probe.js +21 -19
- package/dist/access-boundary.d.ts +11 -11
- package/dist/access-boundary.js +20 -18
- package/dist/access-cli.js +55 -53
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.d.ts +1 -1
- package/dist/access-extraction-force-flush.d.ts +11 -11
- package/dist/access-extraction-force-flush.js +20 -18
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +11 -11
- package/dist/access-http-lifecycle-flush.d.ts +11 -11
- package/dist/access-http-offline-stream.d.ts +11 -11
- package/dist/access-http-query.d.ts +2 -2
- package/dist/access-http-query.js +22 -20
- package/dist/access-http.d.ts +12 -12
- package/dist/access-http.js +31 -29
- package/dist/access-identity-continuity-surface.d.ts +9 -9
- package/dist/access-identity-continuity-surface.js +20 -18
- package/dist/access-lcm-surface.d.ts +11 -11
- package/dist/access-lcm-surface.js +20 -18
- package/dist/access-mcp.d.ts +11 -11
- package/dist/access-mcp.js +25 -23
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-B7Usyz-K.d.ts → access-namespace-preflight-D_6mo8ms.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +20 -18
- package/dist/access-observe-write-surface.d.ts +11 -11
- package/dist/access-observe-write-surface.js +20 -18
- package/dist/access-offline-manifest.d.ts +9 -9
- package/dist/access-offline-manifest.js +3 -3
- package/dist/access-operations-batch.js +21 -19
- package/dist/access-operations.d.ts +11 -11
- package/dist/access-operations.js +24 -22
- package/dist/access-recall-concurrency.d.ts +11 -11
- package/dist/access-recall-concurrency.js +20 -18
- package/dist/access-recall-response.d.ts +11 -11
- package/dist/access-recall-response.js +20 -18
- package/dist/access-recall-surface.d.ts +11 -11
- package/dist/access-recall-surface.js +20 -18
- package/dist/{access-service-DkaIG3n8.d.ts → access-service-DqPa3hy4.d.ts} +7 -7
- package/dist/access-service-helpers.d.ts +11 -11
- package/dist/access-service.d.ts +11 -11
- package/dist/access-service.js +20 -18
- package/dist/access-surface-catalog.d.ts +11 -11
- package/dist/access-surface-catalog.js +22 -20
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/access-wearables-meetings-surface.d.ts +3 -3
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +5 -1
- package/dist/active-recall.js.map +1 -1
- package/dist/ambient-provenance.d.ts +1 -1
- package/dist/artifact-search.d.ts +1 -1
- package/dist/{auto-sync-H64ZCNIR.js → auto-sync-XVMLL2RH.js} +5 -5
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +9 -9
- package/dist/briefing-window.d.ts +2 -2
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +4 -4
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer-turn-helpers.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{catalog-CX2BZEJh.d.ts → catalog-DO_7zfkv.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +9 -6
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/chunk-236PXYG7.js +232 -0
- package/dist/chunk-236PXYG7.js.map +1 -0
- package/dist/{chunk-IQSC3V2E.js → chunk-2IXQSGCU.js} +2 -2
- package/dist/{chunk-GUXS322H.js → chunk-2MVTAIL3.js} +2 -2
- package/dist/{chunk-7QOO4LGC.js → chunk-3JZBPTLD.js} +331 -73
- package/dist/chunk-3JZBPTLD.js.map +1 -0
- package/dist/{chunk-TDKSCV62.js → chunk-3NH3VP3U.js} +2 -2
- package/dist/{chunk-URHCUXKI.js → chunk-AXGFOFNY.js} +2 -2
- package/dist/{chunk-WN5FSGLE.js → chunk-AZLLH6YA.js} +19 -19
- package/dist/{chunk-D27J626P.js → chunk-BK5G2MHO.js} +2 -2
- package/dist/{chunk-DHTQP334.js → chunk-CQBIN77D.js} +2 -2
- package/dist/{chunk-6VALIZKG.js → chunk-DORFF5N5.js} +2 -2
- package/dist/{chunk-76PL4XLG.js → chunk-DPNXADEI.js} +7 -2
- package/dist/chunk-DPNXADEI.js.map +1 -0
- package/dist/{chunk-MRTUN665.js → chunk-DUEDOYZD.js} +2 -2
- package/dist/{chunk-QFMO32TO.js → chunk-DUZARALI.js} +3 -3
- package/dist/{chunk-7KFIMGMP.js → chunk-ECLJ4LA2.js} +2 -2
- package/dist/{chunk-PDVQ5JU3.js → chunk-GHD2LLG4.js} +2 -2
- package/dist/{chunk-RK4WXUI2.js → chunk-HF5BUTI6.js} +2 -2
- package/dist/{chunk-3DVBKTSO.js → chunk-HSZMX3ZJ.js} +4 -4
- package/dist/{chunk-EV3YFLCB.js → chunk-I23ZHYSL.js} +2 -2
- package/dist/{chunk-ODZG724P.js → chunk-I2HTKOOP.js} +2 -2
- package/dist/{chunk-AYYGRVRP.js → chunk-IURMJBGP.js} +2 -2
- package/dist/{chunk-TYUS5TLG.js → chunk-IWKGOCL6.js} +3 -3
- package/dist/{chunk-4XDGYCZI.js → chunk-J3ATBB7M.js} +2 -2
- package/dist/{chunk-E4MVQQVX.js → chunk-JPAKBNTM.js} +2 -2
- package/dist/{chunk-NZWEEALH.js → chunk-KFIOPZ25.js} +2 -2
- package/dist/{chunk-EIVIB73I.js → chunk-KOO37E4Y.js} +2 -2
- package/dist/{chunk-57HVIG5U.js → chunk-KPB2QHJZ.js} +2 -2
- package/dist/{chunk-NXKJHSDN.js → chunk-LBFFNDFM.js} +1 -1
- package/dist/chunk-LBFFNDFM.js.map +1 -0
- package/dist/{chunk-Z4RPXHJH.js → chunk-LYBIHM4N.js} +4 -4
- package/dist/{chunk-G57LQRP6.js → chunk-MFOSZUIT.js} +2 -2
- package/dist/{chunk-AUO2LJ3K.js → chunk-NLEH4RTB.js} +2 -2
- package/dist/{chunk-AYDDB3XI.js → chunk-OCCHUEZB.js} +2 -2
- package/dist/{chunk-6TAX66IA.js → chunk-OU34IQXV.js} +2 -2
- package/dist/{chunk-OJD4WS2E.js → chunk-OZDFB22S.js} +2 -2
- package/dist/{chunk-GN55KU2P.js → chunk-PTZQYCJ4.js} +2 -2
- package/dist/{chunk-BQUEAVNW.js → chunk-QJW4MZSW.js} +2 -2
- package/dist/{chunk-2VXWFYJE.js → chunk-R2MZCYA6.js} +3 -3
- package/dist/{chunk-VA5KMSAE.js → chunk-SR5LNI6Q.js} +3 -3
- package/dist/{chunk-LBWQ65SX.js → chunk-T42L3S6A.js} +4 -4
- package/dist/{chunk-PAYGC3BD.js → chunk-THVI4Y7X.js} +7 -7
- package/dist/{chunk-S7Q5CM7E.js → chunk-TJFI3K2O.js} +15 -3
- package/dist/chunk-TJFI3K2O.js.map +1 -0
- package/dist/{chunk-R47WINCY.js → chunk-UCKG36HO.js} +2 -2
- package/dist/{chunk-QXIQPCCN.js → chunk-UFR6HX7A.js} +1 -1
- package/dist/{chunk-CDUUDBWJ.js → chunk-VFYRYFLL.js} +2 -2
- package/dist/{chunk-P4DHENRE.js → chunk-WDXD6ITO.js} +2 -2
- package/dist/{chunk-BKYPJUQL.js → chunk-XGM3VQWG.js} +10 -10
- package/dist/{chunk-MBDJJTAT.js → chunk-YDKF4MSJ.js} +3 -3
- package/dist/{chunk-YF6UHWOV.js → chunk-YHGCT462.js} +3 -3
- package/dist/{chunk-AZAA5DNP.js → chunk-YOXVZJFM.js} +2 -2
- package/dist/{chunk-OLWTCWQ2.js → chunk-YZJM6CLF.js} +8 -8
- package/dist/chunk-ZCUTSMR2.js +61 -0
- package/dist/chunk-ZCUTSMR2.js.map +1 -0
- package/dist/{chunk-LUNJ3WFO.js → chunk-ZK4BFABK.js} +4 -4
- package/dist/{chunk-H5FW4S5Q.js → chunk-ZPOHEB5Z.js} +31 -31
- package/dist/{chunk-RDFF2NAU.js → chunk-ZXBTTMGZ.js} +184 -88
- package/dist/chunk-ZXBTTMGZ.js.map +1 -0
- package/dist/{cli-ChKeYMZv.d.ts → cli-DO3i14pM.d.ts} +5 -5
- package/dist/cli.d.ts +13 -13
- package/dist/cli.js +44 -42
- package/dist/coding/pre-action-gate.d.ts +1 -1
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +4 -4
- package/dist/compounding/preference-consolidator.d.ts +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +5 -1
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +8 -5
- package/dist/connectors/codex-materialize.d.ts +14 -1
- package/dist/connectors/codex-materialize.js +10 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +8 -5
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/contradiction/index.d.ts +3 -3
- package/dist/contradiction/index.js +1 -1
- package/dist/converge-config.d.ts +1 -1
- package/dist/convergence-refresh.d.ts +2 -2
- package/dist/convergence-refresh.js +6 -6
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/corpus-watermark.d.ts +1 -1
- package/dist/corpus-watermark.js +6 -6
- package/dist/cross-lingual-recall.d.ts +1 -1
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/dependency-propagation-config.d.ts +1 -1
- package/dist/{dependency-propagation-delivery-B8ZMBBCY.d.ts → dependency-propagation-delivery-D23_x-s5.d.ts} +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/entity-origin-fields.d.ts +1 -1
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +4 -4
- package/dist/entity-schema.d.ts +1 -1
- package/dist/episodic-context.d.ts +1 -1
- package/dist/explicit-capture.d.ts +9 -9
- package/dist/explicit-capture.js +1 -1
- package/dist/external-wiki-access.d.ts +11 -11
- package/dist/external-wiki-access.js +21 -19
- package/dist/external-wiki-collection-registration.d.ts +1 -1
- package/dist/external-wiki-collection.d.ts +1 -1
- package/dist/external-wiki-mcp-tools.d.ts +11 -11
- package/dist/extraction-error-classification.d.ts +1 -1
- package/dist/extraction-faithfulness.d.ts +1 -1
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction-judge.js +2 -2
- package/dist/extraction-liveness.d.ts +1 -1
- package/dist/extraction-normalization.d.ts +1 -1
- package/dist/extraction-prompt.d.ts +1 -1
- package/dist/extraction-source-grounding-rules.d.ts +1 -1
- package/dist/extraction-source-grounding.d.ts +1 -1
- package/dist/extraction.d.ts +1 -1
- package/dist/extraction.js +9 -7
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/graph-dashboard-diff.d.ts +1 -1
- package/dist/graph-dashboard-key.d.ts +1 -1
- package/dist/graph-dashboard-parser.d.ts +1 -1
- package/dist/graph-edge-reinforcement.d.ts +1 -1
- package/dist/graph-path-reconstruction.d.ts +1 -1
- package/dist/graph-path-scoring.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph.d.ts +1 -1
- package/dist/harmonic-retrieval.js +1 -1
- package/dist/importance.d.ts +1 -1
- package/dist/importers/index.d.ts +1 -1
- package/dist/in-flight-reads.d.ts +1 -1
- package/dist/{index-CexDrJzC.d.ts → index--QhGIXF2.d.ts} +2 -2
- package/dist/index.d.ts +87 -40
- package/dist/index.js +79 -58
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/tools.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +1 -1
- package/dist/local-model-endpoint.d.ts +1 -1
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +4 -4
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +4 -4
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +5 -5
- package/dist/{maintenance-nkdtSrVr.d.ts → maintenance-PFvY1Pw_.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +11 -11
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
- package/dist/memory-projection-store.d.ts +1 -1
- package/dist/memory-provenance.d.ts +1 -1
- package/dist/memory-snapshot.d.ts +1 -1
- package/dist/memory-subject-cli.d.ts +11 -11
- package/dist/memory-subject.d.ts +11 -11
- package/dist/memory-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +3 -3
- package/dist/namespaces/migrate.js +5 -5
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +4 -4
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/operator-doctor-corpus.d.ts +1 -1
- package/dist/operator-doctor-corpus.js +7 -7
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +16 -13
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +4 -4
- package/dist/orchestration/maintenance.js +10 -10
- package/dist/{orchestrator-Bvq1-RQs.d.ts → orchestrator-4wzJrPVm.d.ts} +8 -8
- package/dist/orchestrator.d.ts +9 -9
- package/dist/orchestrator.js +55 -53
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-C8vfIiTX.d.ts → pipeline-CgXgdIrF.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/proactive-contention.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/{public-http-Cy0aYbys.d.ts → public-http-DhIXYBYI.d.ts} +1 -1
- package/dist/{qmd-B9p1SZTZ.d.ts → qmd-BppGGxsi.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +2 -2
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +1 -1
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +1 -1
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/cursor.d.ts +1 -1
- package/dist/reconcile/manifest.d.ts +1 -1
- package/dist/reconcile/manifest.js +2 -2
- package/dist/reconcile/plan.d.ts +1 -1
- package/dist/replay/normalizers/chatgpt.d.ts +1 -1
- package/dist/replay/normalizers/claude.d.ts +1 -1
- package/dist/replay/normalizers/openclaw.d.ts +1 -1
- package/dist/replay/normalizers/shared.d.ts +1 -1
- package/dist/replay/runner.d.ts +1 -1
- package/dist/replay/types.d.ts +1 -1
- package/dist/replica-divergence.d.ts +1 -1
- package/dist/replica-peers-config.d.ts +1 -1
- package/dist/resolution-4552BNRV.js +1 -1
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +6 -2
- package/dist/retrieval-agents.d.ts +2 -2
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/routing/engine.d.ts +1 -1
- package/dist/routing/store.d.ts +1 -1
- package/dist/salvage-envelope.d.ts +1 -1
- package/dist/salvage-envelope.js +1 -1
- package/dist/schemas.d.ts +12 -12
- package/dist/{scope-profiles-DLrRxFWR.d.ts → scope-profiles-ChZUtxDU.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/index.d.ts +1 -1
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-DlN6xe20.d.ts → semantic-consolidation-mSPwQSmF.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +9 -6
- package/dist/semantic-rule-promotion.js +4 -4
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +4 -4
- package/dist/{service-GkYyVfm9.d.ts → service-BICWLwSP.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +1 -1
- package/dist/signal.d.ts +1 -1
- package/dist/skills-registry.js +4 -56
- package/dist/skills-registry.js.map +1 -1
- package/dist/source-agent-qualifier.d.ts +1 -1
- package/dist/source-agent-qualifier.js +8 -5
- package/dist/{storage-BIDzuKIn.d.ts → storage-B7urx1K3.d.ts} +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +6 -6
- package/dist/subject-config.d.ts +1 -1
- package/dist/summarizer.d.ts +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/support-passport/index.d.ts +14 -14
- package/dist/support-passport/index.js +23 -21
- package/dist/temporal-supersession.d.ts +2 -2
- package/dist/temporal-timeline-recall.d.ts +1 -1
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +2 -2
- package/dist/tier-routing.d.ts +1 -1
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-BxAcOl5Q.d.ts → types-ETU5N6nB.d.ts} +111 -4
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +4 -4
- package/dist/who-knows-cli.d.ts +11 -11
- package/dist/who-knows-cli.js +5 -5
- package/dist/who-knows.d.ts +11 -11
- package/dist/who-knows.js +4 -4
- package/dist/write-envelope.d.ts +1 -1
- package/dist/write-envelope.js +1 -1
- package/package.json +2 -2
- package/src/cli/skills-commands.ts +150 -0
- package/src/cli.ts +4 -2
- package/src/config.ts +4 -2
- package/src/connectors/codex-materialize-runner.ts +16 -0
- package/src/connectors/codex-materialize-skills.test.ts +141 -0
- package/src/connectors/codex-materialize.ts +58 -40
- package/src/connectors/materialize-paths.ts +50 -0
- package/src/connectors/materialize-skills.ts +127 -0
- package/src/index.ts +5 -10
- package/src/procedural/skill-io.test.ts +190 -0
- package/src/procedural/skill-io.ts +220 -0
- package/src/procedural/skill-projection.test.ts +214 -0
- package/src/procedural/skill-projection.ts +356 -0
- package/src/types.ts +2 -3
- package/dist/chunk-76PL4XLG.js.map +0 -1
- package/dist/chunk-7QOO4LGC.js.map +0 -1
- package/dist/chunk-NXKJHSDN.js.map +0 -1
- package/dist/chunk-RDFF2NAU.js.map +0 -1
- package/dist/chunk-S7Q5CM7E.js.map +0 -1
- /package/dist/{auto-sync-H64ZCNIR.js.map → auto-sync-XVMLL2RH.js.map} +0 -0
- /package/dist/{chunk-IQSC3V2E.js.map → chunk-2IXQSGCU.js.map} +0 -0
- /package/dist/{chunk-GUXS322H.js.map → chunk-2MVTAIL3.js.map} +0 -0
- /package/dist/{chunk-TDKSCV62.js.map → chunk-3NH3VP3U.js.map} +0 -0
- /package/dist/{chunk-URHCUXKI.js.map → chunk-AXGFOFNY.js.map} +0 -0
- /package/dist/{chunk-WN5FSGLE.js.map → chunk-AZLLH6YA.js.map} +0 -0
- /package/dist/{chunk-D27J626P.js.map → chunk-BK5G2MHO.js.map} +0 -0
- /package/dist/{chunk-DHTQP334.js.map → chunk-CQBIN77D.js.map} +0 -0
- /package/dist/{chunk-6VALIZKG.js.map → chunk-DORFF5N5.js.map} +0 -0
- /package/dist/{chunk-MRTUN665.js.map → chunk-DUEDOYZD.js.map} +0 -0
- /package/dist/{chunk-QFMO32TO.js.map → chunk-DUZARALI.js.map} +0 -0
- /package/dist/{chunk-7KFIMGMP.js.map → chunk-ECLJ4LA2.js.map} +0 -0
- /package/dist/{chunk-PDVQ5JU3.js.map → chunk-GHD2LLG4.js.map} +0 -0
- /package/dist/{chunk-RK4WXUI2.js.map → chunk-HF5BUTI6.js.map} +0 -0
- /package/dist/{chunk-3DVBKTSO.js.map → chunk-HSZMX3ZJ.js.map} +0 -0
- /package/dist/{chunk-EV3YFLCB.js.map → chunk-I23ZHYSL.js.map} +0 -0
- /package/dist/{chunk-ODZG724P.js.map → chunk-I2HTKOOP.js.map} +0 -0
- /package/dist/{chunk-AYYGRVRP.js.map → chunk-IURMJBGP.js.map} +0 -0
- /package/dist/{chunk-TYUS5TLG.js.map → chunk-IWKGOCL6.js.map} +0 -0
- /package/dist/{chunk-4XDGYCZI.js.map → chunk-J3ATBB7M.js.map} +0 -0
- /package/dist/{chunk-E4MVQQVX.js.map → chunk-JPAKBNTM.js.map} +0 -0
- /package/dist/{chunk-NZWEEALH.js.map → chunk-KFIOPZ25.js.map} +0 -0
- /package/dist/{chunk-EIVIB73I.js.map → chunk-KOO37E4Y.js.map} +0 -0
- /package/dist/{chunk-57HVIG5U.js.map → chunk-KPB2QHJZ.js.map} +0 -0
- /package/dist/{chunk-Z4RPXHJH.js.map → chunk-LYBIHM4N.js.map} +0 -0
- /package/dist/{chunk-G57LQRP6.js.map → chunk-MFOSZUIT.js.map} +0 -0
- /package/dist/{chunk-AUO2LJ3K.js.map → chunk-NLEH4RTB.js.map} +0 -0
- /package/dist/{chunk-AYDDB3XI.js.map → chunk-OCCHUEZB.js.map} +0 -0
- /package/dist/{chunk-6TAX66IA.js.map → chunk-OU34IQXV.js.map} +0 -0
- /package/dist/{chunk-OJD4WS2E.js.map → chunk-OZDFB22S.js.map} +0 -0
- /package/dist/{chunk-GN55KU2P.js.map → chunk-PTZQYCJ4.js.map} +0 -0
- /package/dist/{chunk-BQUEAVNW.js.map → chunk-QJW4MZSW.js.map} +0 -0
- /package/dist/{chunk-2VXWFYJE.js.map → chunk-R2MZCYA6.js.map} +0 -0
- /package/dist/{chunk-VA5KMSAE.js.map → chunk-SR5LNI6Q.js.map} +0 -0
- /package/dist/{chunk-LBWQ65SX.js.map → chunk-T42L3S6A.js.map} +0 -0
- /package/dist/{chunk-PAYGC3BD.js.map → chunk-THVI4Y7X.js.map} +0 -0
- /package/dist/{chunk-R47WINCY.js.map → chunk-UCKG36HO.js.map} +0 -0
- /package/dist/{chunk-QXIQPCCN.js.map → chunk-UFR6HX7A.js.map} +0 -0
- /package/dist/{chunk-CDUUDBWJ.js.map → chunk-VFYRYFLL.js.map} +0 -0
- /package/dist/{chunk-P4DHENRE.js.map → chunk-WDXD6ITO.js.map} +0 -0
- /package/dist/{chunk-BKYPJUQL.js.map → chunk-XGM3VQWG.js.map} +0 -0
- /package/dist/{chunk-MBDJJTAT.js.map → chunk-YDKF4MSJ.js.map} +0 -0
- /package/dist/{chunk-YF6UHWOV.js.map → chunk-YHGCT462.js.map} +0 -0
- /package/dist/{chunk-AZAA5DNP.js.map → chunk-YOXVZJFM.js.map} +0 -0
- /package/dist/{chunk-OLWTCWQ2.js.map → chunk-YZJM6CLF.js.map} +0 -0
- /package/dist/{chunk-LUNJ3WFO.js.map → chunk-ZK4BFABK.js.map} +0 -0
- /package/dist/{chunk-H5FW4S5Q.js.map → chunk-ZPOHEB5Z.js.map} +0 -0
|
@@ -2,7 +2,7 @@ import { CausalChainIndex } from './causal-chain.js';
|
|
|
2
2
|
import { ConsolidatedPreference } from './compounding/preference-consolidator.js';
|
|
3
3
|
import './causal-trajectory.js';
|
|
4
4
|
import './objective-state.js';
|
|
5
|
-
import './types-
|
|
5
|
+
import './types-ETU5N6nB.js';
|
|
6
6
|
import './message-parts/index.js';
|
|
7
7
|
import './bounded-jsonl-state.js';
|
|
8
8
|
import './types-CM86alG1.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as GatewayConfig, A as AgentPersonaModelConfig, P as PluginConfig, M as MemoryFile } from './types-
|
|
1
|
+
import { G as GatewayConfig, A as AgentPersonaModelConfig, P as PluginConfig, M as MemoryFile } from './types-ETU5N6nB.js';
|
|
2
2
|
import { RolloutSummaryInput, MaterializeResult } from './connectors/codex-materialize.js';
|
|
3
3
|
import './message-parts/index.js';
|
|
4
4
|
import './bounded-jsonl-state.js';
|
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
} from "./chunk-NZPFCP5A.js";
|
|
5
5
|
import {
|
|
6
6
|
buildExtensionsBlockForConsolidation
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-HF5BUTI6.js";
|
|
8
8
|
import "./chunk-5JMAGU26.js";
|
|
9
9
|
import "./chunk-B7RWBZXW.js";
|
|
10
10
|
import {
|
|
11
11
|
runPostConsolidationMaterialize
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-TJFI3K2O.js";
|
|
13
|
+
import "./chunk-ZXBTTMGZ.js";
|
|
14
|
+
import "./chunk-THVI4Y7X.js";
|
|
15
15
|
import "./chunk-UHVXE24Y.js";
|
|
16
16
|
import "./chunk-46WM6JX2.js";
|
|
17
17
|
import "./chunk-SXIMQLGV.js";
|
|
@@ -30,7 +30,7 @@ import "./chunk-ET356KSB.js";
|
|
|
30
30
|
import "./chunk-72A4L5JJ.js";
|
|
31
31
|
import "./chunk-A7Q43EUZ.js";
|
|
32
32
|
import "./chunk-S2V7RUCL.js";
|
|
33
|
-
import "./chunk-
|
|
33
|
+
import "./chunk-LBFFNDFM.js";
|
|
34
34
|
import "./chunk-SCU65EZI.js";
|
|
35
35
|
import "./chunk-PO7NXBG2.js";
|
|
36
36
|
import "./chunk-S2HLHAZ4.js";
|
|
@@ -68,6 +68,9 @@ import "./chunk-45GF7Y3V.js";
|
|
|
68
68
|
import "./chunk-RGMVMVMF.js";
|
|
69
69
|
import "./chunk-N7RWREIQ.js";
|
|
70
70
|
import "./chunk-TOTT6S2V.js";
|
|
71
|
+
import "./chunk-236PXYG7.js";
|
|
72
|
+
import "./chunk-ZCUTSMR2.js";
|
|
73
|
+
import "./chunk-QDW3E4RD.js";
|
|
71
74
|
import {
|
|
72
75
|
resolveCausalTrajectoryStoreDir
|
|
73
76
|
} from "./chunk-PP7R754B.js";
|
|
@@ -92,10 +95,10 @@ import "./chunk-7RJUVTVF.js";
|
|
|
92
95
|
import "./chunk-2LWQSV6A.js";
|
|
93
96
|
import "./chunk-RL6NEVXT.js";
|
|
94
97
|
import "./chunk-XDL5CYZN.js";
|
|
95
|
-
import "./chunk-JDSVLVCG.js";
|
|
96
98
|
import "./chunk-JOEJG4SD.js";
|
|
97
99
|
import "./chunk-5FVVY2EB.js";
|
|
98
100
|
import "./chunk-FFAZ2XFU.js";
|
|
101
|
+
import "./chunk-JDSVLVCG.js";
|
|
99
102
|
import "./chunk-5GKPFL3S.js";
|
|
100
103
|
import "./chunk-JAKIDQB2.js";
|
|
101
104
|
import "./chunk-P7FMDTKL.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/causal-consolidation.ts"],"sourcesContent":["/**\n * causal-consolidation.ts — CMC Phase 2: LLM-Assisted Causal Consolidation\n *\n * Uses an LLM to analyze causal trajectory patterns across sessions.\n * The LLM receives the causal chain graph as context — connected trajectories\n * from different sessions — and identifies recurring behavioral patterns,\n * preference signals, and actionable rules.\n *\n * This is the core CMC innovation: the LLM gets cross-session causal context\n * that no other memory system provides. It can see that a user investigated\n * a bug in session 1, attempted a fix in session 2, and succeeded in session 3 —\n * and synthesize a rule or preference from that chain.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { resolveCausalTrajectoryStoreDir, type CausalTrajectoryRecord } from \"./causal-trajectory.js\";\nimport { readChainIndex, resolveChainsDir, type CausalChainIndex, type CausalEdge } from \"./causal-chain.js\";\nimport { listJsonFiles, readJsonFile } from \"./json-store.js\";\nimport { isRecord } from \"./store-contract.js\";\nimport { FallbackLlmClient, fallbackLlmRuntimeContextFromConfig } from \"./fallback-llm.js\";\nimport type { AgentPersonaModelConfig, GatewayConfig, MemoryFile, PluginConfig } from \"./types.js\";\nimport path from \"node:path\";\nimport { log } from \"./logger.js\";\nimport { runPostConsolidationMaterialize } from \"./connectors/codex-materialize-runner.js\";\nimport type { MaterializeResult, RolloutSummaryInput } from \"./connectors/codex-materialize.js\";\nimport { buildExtensionsBlockForConsolidation } from \"./semantic-consolidation.js\";\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\nexport interface CausalPatternCandidate {\n id: string;\n sourceType: \"causal-pattern\";\n subject: string;\n category: \"principle\" | \"rule\" | \"preference\";\n content: string;\n score: number;\n rationale: string;\n outcome: null;\n provenance: string[];\n agent: string | null;\n workflow: string | null;\n}\n\nexport interface ConsolidationConfig {\n minRecurrence: number;\n minSessions: number;\n successThreshold: number;\n}\n\nexport interface LlmConsolidationResult {\n rules: Array<{\n content: string;\n category: \"rule\" | \"principle\" | \"preference\";\n confidence: number;\n evidence: string[];\n }>;\n preferences: Array<{\n statement: string;\n confidence: number;\n evidence: string[];\n }>;\n}\n\nconst CAUSAL_RULE_CATEGORIES = new Set([\"rule\", \"principle\", \"preference\"]);\n\ninterface ConsolidationLlmClient {\n isAvailable(options?: { agentId?: string; modelChain?: AgentPersonaModelConfig }): boolean;\n chatCompletion(\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options?: { temperature?: number; maxTokens?: number; agentId?: string; modelChain?: AgentPersonaModelConfig },\n ): Promise<{ content: string } | null>;\n}\n\n// ─── Trajectory Reading ──────────────────────────────────────────────────────\n\nasync function readAllTrajectories(\n memoryDir: string,\n causalTrajectoryStoreDir?: string,\n): Promise<CausalTrajectoryRecord[]> {\n const root = resolveCausalTrajectoryStoreDir(memoryDir, causalTrajectoryStoreDir);\n const trajectoriesDir = path.join(root, \"trajectories\");\n\n const files = await listJsonFiles(trajectoriesDir).catch(() => [] as string[]);\n const results: CausalTrajectoryRecord[] = [];\n\n for (const filePath of files) {\n try {\n const raw = await readJsonFile(filePath);\n if (isRecord(raw) && typeof raw.trajectoryId === \"string\") {\n results.push(raw as unknown as CausalTrajectoryRecord);\n }\n } catch {\n // skip invalid\n }\n }\n\n return results;\n}\n\n// ─── Context Formatting ──────────────────────────────────────────────────────\n\n/**\n * Format trajectories and their causal connections as a readable context\n * for the LLM. Groups by session and shows chain connections.\n */\nfunction formatCausalContext(\n trajectories: CausalTrajectoryRecord[],\n chainIndex: CausalChainIndex,\n maxChars: number = 8000,\n): string {\n // Group trajectories by session\n const bySession = new Map<string, CausalTrajectoryRecord[]>();\n for (const t of trajectories) {\n const list = bySession.get(t.sessionKey) ?? [];\n list.push(t);\n bySession.set(t.sessionKey, list);\n }\n\n const lines: string[] = [];\n lines.push(`## Causal Trajectories (${trajectories.length} across ${bySession.size} sessions)`);\n lines.push(\"\");\n\n // Format each session's trajectories\n for (const [sessionKey, sessionTrajs] of bySession) {\n lines.push(`### Session: ${sessionKey}`);\n for (const t of sessionTrajs.slice(0, 5)) {\n const outcome = t.outcomeKind === \"success\" ? \"+\" : t.outcomeKind === \"failure\" ? \"-\" : \"~\";\n lines.push(`[${outcome}] Goal: ${t.goal}`);\n lines.push(` Action: ${t.actionSummary}`);\n lines.push(` Outcome: ${t.outcomeSummary}`);\n if (t.followUpSummary) lines.push(` Follow-up: ${t.followUpSummary}`);\n if (t.entityRefs?.length) lines.push(` Entities: ${t.entityRefs.join(\", \")}`);\n }\n lines.push(\"\");\n }\n\n // Format causal chain connections\n const edgeCount = Object.keys(chainIndex.edges).length;\n if (edgeCount > 0) {\n lines.push(`## Cross-Session Causal Chains (${edgeCount} connections)`);\n lines.push(\"\");\n\n const trajectoryMap = new Map(trajectories.map((t) => [t.trajectoryId, t]));\n const shown = new Set<string>();\n\n for (const [edgeId, edge] of Object.entries(chainIndex.edges)) {\n if (shown.size >= 10) break; // limit output size\n const from = trajectoryMap.get(edge.fromTrajectoryId);\n const to = trajectoryMap.get(edge.toTrajectoryId);\n if (!from || !to) continue;\n\n lines.push(`${edge.edgeType}: \"${from.goal}\" (${from.sessionKey}) → \"${to.goal}\" (${to.sessionKey})`);\n shown.add(edgeId);\n }\n lines.push(\"\");\n }\n\n const result = lines.join(\"\\n\");\n return result.length > maxChars ? result.slice(0, maxChars) + \"\\n[truncated]\" : result;\n}\n\n// ─── LLM Consolidation ──────────────────────────────────────────────────────\n\nconst CONSOLIDATION_PROMPT = `You are analyzing a user's causal trajectory history across multiple sessions. Trajectories record what the user tried to do (goal), what they did (action), and what happened (outcome).\n\nYour job is to identify:\n1. BEHAVIORAL RULES: Recurring patterns where the same approach consistently succeeds or fails. These should be actionable guidance for future sessions.\n2. PREFERENCES: What the user cares about, prefers, or consistently chooses — even if never explicitly stated. Infer preferences from what they repeatedly do, retry until successful, or always include in their workflow.\n\nIMPORTANT:\n- Look for CROSS-SESSION patterns — things that repeat across different sessions are more significant than within-session patterns.\n- A user who retries the same goal across sessions has a strong implicit preference for that outcome.\n- Consistent action choices reveal preferences even when the user never says \"I prefer X.\"\n- Frame preferences as \"The user would prefer responses that...\" when applicable.\n\nOutput valid JSON only:\n{\n \"rules\": [\n {\"content\": \"actionable rule text\", \"category\": \"rule|principle\", \"confidence\": 0.0-1.0, \"evidence\": [\"trajectory IDs\"]}\n ],\n \"preferences\": [\n {\"statement\": \"The user would prefer...\", \"confidence\": 0.0-1.0, \"evidence\": [\"trajectory IDs\"]}\n ]\n}\n\nIf no clear patterns exist, return {\"rules\": [], \"preferences\": []}.`;\n\nasync function consolidateWithLlm(\n context: string,\n llm: ConsolidationLlmClient,\n options: { agentId?: string; modelChain?: AgentPersonaModelConfig } = {},\n): Promise<LlmConsolidationResult> {\n const response = await llm.chatCompletion(\n [\n { role: \"system\", content: CONSOLIDATION_PROMPT },\n { role: \"user\", content: context },\n ],\n { temperature: 0.2, maxTokens: 2000, agentId: options.agentId, modelChain: options.modelChain },\n );\n\n if (!response?.content) {\n return { rules: [], preferences: [] };\n }\n\n try {\n // Extract JSON from response (may have markdown code fences)\n let jsonStr = response.content.trim();\n const fenceMatch = jsonStr.match(/```(?:json)?\\s*\\n?([\\s\\S]*?)\\n?\\s*```/);\n if (fenceMatch) jsonStr = fenceMatch[1];\n\n const parsed = JSON.parse(jsonStr);\n const rawRules: unknown[] = Array.isArray(parsed.rules) ? parsed.rules : [];\n const rawPreferences: unknown[] = Array.isArray(parsed.preferences) ? parsed.preferences : [];\n return {\n rules: rawRules\n .map(parseLlmRule)\n .filter((rule): rule is LlmConsolidationResult[\"rules\"][number] => !!rule),\n preferences: rawPreferences\n .map(parseLlmPreference)\n .filter((pref): pref is LlmConsolidationResult[\"preferences\"][number] => !!pref),\n };\n } catch {\n log.warn(\"[cmc] failed to parse LLM consolidation response\");\n return { rules: [], preferences: [] };\n }\n}\n\n// ─── Candidate Generation ────────────────────────────────────────────────────\n\nfunction stablePatternId(content: string): string {\n const digest = createHash(\"sha256\")\n .update(`causal-pattern\\0${content}`)\n .digest(\"hex\")\n .slice(0, 16);\n return `causal-pattern:${digest}`;\n}\n\nfunction parseConfidence(value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined;\n return Math.max(0, Math.min(1, value));\n}\n\nfunction parseEvidence(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value.filter((item): item is string => typeof item === \"string\" && item.trim().length > 0);\n}\n\nfunction parseLlmRule(raw: unknown): LlmConsolidationResult[\"rules\"][number] | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const r = raw as Record<string, unknown>;\n const content = typeof r.content === \"string\" ? r.content.trim() : \"\";\n const category = typeof r.category === \"string\" ? r.category : \"\";\n const confidence = parseConfidence(r.confidence);\n if (content.length <= 5 || !CAUSAL_RULE_CATEGORIES.has(category) || confidence === undefined) {\n return undefined;\n }\n return {\n content,\n category: category as \"rule\" | \"principle\" | \"preference\",\n confidence,\n evidence: parseEvidence(r.evidence),\n };\n}\n\nfunction parseLlmPreference(raw: unknown): LlmConsolidationResult[\"preferences\"][number] | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const p = raw as Record<string, unknown>;\n const statement = typeof p.statement === \"string\" ? p.statement.trim() : \"\";\n const confidence = parseConfidence(p.confidence);\n if (statement.length <= 5 || confidence === undefined) return undefined;\n return {\n statement,\n confidence,\n evidence: parseEvidence(p.evidence),\n };\n}\n\nfunction llmResultToCandidates(result: LlmConsolidationResult): CausalPatternCandidate[] {\n const candidates: CausalPatternCandidate[] = [];\n\n for (const rule of result.rules) {\n const category =\n rule.category === \"principle\" || rule.category === \"preference\"\n ? rule.category\n : \"rule\";\n candidates.push({\n id: stablePatternId(rule.content),\n sourceType: \"causal-pattern\",\n subject: rule.content.slice(0, 80),\n category,\n content: rule.content,\n score: Math.min(1, rule.confidence ?? 0.7),\n rationale: \"LLM-identified causal pattern from cross-session trajectory analysis\",\n outcome: null,\n provenance: (rule.evidence ?? []).slice(0, 5),\n agent: null,\n workflow: null,\n });\n }\n\n for (const preference of result.preferences) {\n candidates.push({\n id: stablePatternId(preference.statement),\n sourceType: \"causal-pattern\",\n subject: preference.statement.slice(0, 80),\n category: \"preference\",\n content: preference.statement,\n score: Math.min(1, preference.confidence ?? 0.7),\n rationale: \"LLM-identified preference from cross-session trajectory analysis\",\n outcome: null,\n provenance: (preference.evidence ?? []).slice(0, 5),\n agent: null,\n workflow: null,\n });\n }\n\n return candidates;\n}\n\nfunction normalizePositiveInteger(value: number, fallback: number): number {\n return Number.isFinite(value) && value > 0 ? Math.floor(value) : fallback;\n}\n\nfunction normalizeSuccessThreshold(value: number): number {\n if (!Number.isFinite(value) || value <= 0) return 0;\n return Math.min(1, value);\n}\n\nfunction trajectorySuccessScore(trajectory: CausalTrajectoryRecord): number {\n if (trajectory.outcomeKind === \"success\") return 1;\n if (trajectory.outcomeKind === \"partial\") return 0.5;\n return 0;\n}\n\nfunction averageSuccessScore(trajectories: CausalTrajectoryRecord[]): number {\n if (trajectories.length === 0) return 0;\n const total = trajectories.reduce((sum, trajectory) => sum + trajectorySuccessScore(trajectory), 0);\n return total / trajectories.length;\n}\n\nfunction passesConsolidationGates(\n trajectories: CausalTrajectoryRecord[],\n config: ConsolidationConfig,\n): boolean {\n const minRecurrence = normalizePositiveInteger(config.minRecurrence, 1);\n if (trajectories.length < minRecurrence) return false;\n\n const minSessions = normalizePositiveInteger(config.minSessions, 1);\n const sessionCount = new Set(trajectories.map((trajectory) => trajectory.sessionKey)).size;\n if (sessionCount < minSessions) return false;\n\n const successThreshold = normalizeSuccessThreshold(config.successThreshold);\n if (successThreshold > 0 && averageSuccessScore(trajectories) < successThreshold) {\n return false;\n }\n\n return true;\n}\n\n// ─── Public API ──────────────────────────────────────────────────────────────\n\n/**\n * Run LLM-assisted consolidation: read trajectories, format causal context,\n * ask LLM to identify patterns and preferences.\n */\nexport async function deriveCausalPromotionCandidates(options: {\n memoryDir: string;\n causalTrajectoryStoreDir?: string;\n config: ConsolidationConfig;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig?: PluginConfig;\n llmClient?: ConsolidationLlmClient;\n}): Promise<CausalPatternCandidate[]> {\n try {\n const trajectories = await readAllTrajectories(options.memoryDir, options.causalTrajectoryStoreDir);\n if (!passesConsolidationGates(trajectories, options.config)) return [];\n\n const chainsDir = resolveChainsDir(options.memoryDir, options.causalTrajectoryStoreDir);\n const chainIndex = await readChainIndex(chainsDir);\n\n // Format the causal context for the LLM\n let context = formatCausalContext(trajectories, chainIndex);\n\n // Append memory extensions block if available (#382)\n if (options.pluginConfig) {\n const extBlock = await buildExtensionsBlockForConsolidation(options.pluginConfig);\n if (extBlock.length > 0) {\n context += \"\\n\\n\" + extBlock;\n }\n }\n\n // If no LLM available, fall back to empty (no deterministic fallback)\n const llm = options.llmClient ?? new FallbackLlmClient(\n options.gatewayConfig,\n options.pluginConfig\n ? fallbackLlmRuntimeContextFromConfig(options.pluginConfig, {\n workspaceDir: options.workspaceDir ?? options.pluginConfig.workspaceDir,\n })\n : { workspaceDir: options.workspaceDir },\n );\n const llmOptions = { agentId: options.gatewayAgentId, modelChain: options.modelChain };\n if (!llm.isAvailable(llmOptions)) {\n log.debug(\"[cmc] no LLM available for consolidation — skipping\");\n return [];\n }\n\n // Call LLM for pattern analysis\n const result = await consolidateWithLlm(context, llm, llmOptions);\n const candidates = llmResultToCandidates(result);\n\n log.debug(`[cmc] LLM consolidation produced ${candidates.length} rule(s) and ${result.preferences.length} preference(s)`);\n return candidates;\n } catch (error) {\n log.warn(`[cmc] consolidation failed (non-fatal): ${error instanceof Error ? error.message : String(error)}`);\n return [];\n }\n}\n\n/**\n * Get LLM-synthesized preferences from causal trajectory analysis.\n * Returns formatted preference statements for recall injection.\n */\nexport async function synthesizeCausalPreferencesViaLlm(options: {\n memoryDir: string;\n causalTrajectoryStoreDir?: string;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n minTrajectories?: number;\n}): Promise<string | null> {\n try {\n const trajectories = await readAllTrajectories(options.memoryDir, options.causalTrajectoryStoreDir);\n if (trajectories.length < (options.minTrajectories ?? 2)) return null;\n\n const chainsDir = resolveChainsDir(options.memoryDir, options.causalTrajectoryStoreDir);\n const chainIndex = await readChainIndex(chainsDir);\n const context = formatCausalContext(trajectories, chainIndex);\n\n const llm = new FallbackLlmClient(options.gatewayConfig, {\n workspaceDir: options.workspaceDir,\n });\n const llmOptions = { agentId: options.gatewayAgentId, modelChain: options.modelChain };\n if (!llm.isAvailable(llmOptions)) return null;\n\n const result = await consolidateWithLlm(context, llm, llmOptions);\n if (result.preferences.length === 0 && result.rules.length === 0) return null;\n\n const lines: string[] = [\"## Behavioral Insights (from Causal Chain Analysis)\", \"\"];\n\n for (const pref of result.preferences) {\n lines.push(`- ${pref.statement}`);\n }\n\n for (const rule of result.rules) {\n lines.push(`- ${rule.content}`);\n }\n\n lines.push(\"\");\n return lines.join(\"\\n\");\n } catch (error) {\n log.warn(`[cmc] preference synthesis failed (non-fatal): ${error instanceof Error ? error.message : String(error)}`);\n return null;\n }\n}\n\n/**\n * Optional post-consolidation hook — materializes Codex-native memory artifacts\n * after a causal consolidation run. Guarded by `codexMaterializeMemories` and\n * `codexMaterializeOnConsolidation`. Returns `null` when disabled or when the\n * sentinel is missing (honors user hand-edits).\n *\n * Split from the orchestrator-owned flow so #378 avoids touching\n * orchestrator.ts while Wave 1 edits are in flight.\n */\nexport async function materializeAfterCausalConsolidation(options: {\n config: PluginConfig;\n namespace?: string;\n memories?: MemoryFile[];\n memoryDir?: string;\n codexHome?: string;\n rolloutSummaries?: RolloutSummaryInput[];\n now?: Date;\n}): Promise<MaterializeResult | null> {\n // Delegates to the shared post-consolidation helper — see\n // runPostConsolidationMaterialize in codex-materialize-runner.ts.\n return runPostConsolidationMaterialize(\"[cmc]\", options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,kBAAkB;AAO3B,OAAO,UAAU;AA0CjB,IAAM,yBAAyB,oBAAI,IAAI,CAAC,QAAQ,aAAa,YAAY,CAAC;AAY1E,eAAe,oBACb,WACA,0BACmC;AACnC,QAAM,OAAO,gCAAgC,WAAW,wBAAwB;AAChF,QAAM,kBAAkB,KAAK,KAAK,MAAM,cAAc;AAEtD,QAAM,QAAQ,MAAM,cAAc,eAAe,EAAE,MAAM,MAAM,CAAC,CAAa;AAC7E,QAAM,UAAoC,CAAC;AAE3C,aAAW,YAAY,OAAO;AAC5B,QAAI;AACF,YAAM,MAAM,MAAM,aAAa,QAAQ;AACvC,UAAI,SAAS,GAAG,KAAK,OAAO,IAAI,iBAAiB,UAAU;AACzD,gBAAQ,KAAK,GAAwC;AAAA,MACvD;AAAA,IACF,QAAQ;AAAA,IAER;AAAA,EACF;AAEA,SAAO;AACT;AAQA,SAAS,oBACP,cACA,YACA,WAAmB,KACX;AAER,QAAM,YAAY,oBAAI,IAAsC;AAC5D,aAAW,KAAK,cAAc;AAC5B,UAAM,OAAO,UAAU,IAAI,EAAE,UAAU,KAAK,CAAC;AAC7C,SAAK,KAAK,CAAC;AACX,cAAU,IAAI,EAAE,YAAY,IAAI;AAAA,EAClC;AAEA,QAAM,QAAkB,CAAC;AACzB,QAAM,KAAK,2BAA2B,aAAa,MAAM,WAAW,UAAU,I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AChE,QAAI,OAAO,YAAY,WAAW,KAAK,OAAO,MAAM,WAAW,EAAG,QAAO;AAEzE,UAAM,QAAkB,CAAC,uDAAuD,EAAE;AAElF,eAAW,QAAQ,OAAO,aAAa;AACrC,YAAM,KAAK,KAAK,KAAK,SAAS,EAAE;AAAA,IAClC;AAEA,eAAW,QAAQ,OAAO,OAAO;AAC/B,YAAM,KAAK,KAAK,KAAK,OAAO,EAAE;AAAA,IAChC;AAEA,UAAM,KAAK,EAAE;AACb,WAAO,MAAM,KAAK,IAAI;AAAA,EACxB,SAAS,OAAO;AACd,QAAI,KAAK,kDAAkD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AACnH,WAAO;AAAA,EACT;AACF;AAWA,eAAsB,oCAAoC,SAQpB;AAGpC,SAAO,gCAAgC,SAAS,OAAO;AACzD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/causal-consolidation.ts"],"sourcesContent":["/**\n * causal-consolidation.ts — CMC Phase 2: LLM-Assisted Causal Consolidation\n *\n * Uses an LLM to analyze causal trajectory patterns across sessions.\n * The LLM receives the causal chain graph as context — connected trajectories\n * from different sessions — and identifies recurring behavioral patterns,\n * preference signals, and actionable rules.\n *\n * This is the core CMC innovation: the LLM gets cross-session causal context\n * that no other memory system provides. It can see that a user investigated\n * a bug in session 1, attempted a fix in session 2, and succeeded in session 3 —\n * and synthesize a rule or preference from that chain.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { resolveCausalTrajectoryStoreDir, type CausalTrajectoryRecord } from \"./causal-trajectory.js\";\nimport { readChainIndex, resolveChainsDir, type CausalChainIndex, type CausalEdge } from \"./causal-chain.js\";\nimport { listJsonFiles, readJsonFile } from \"./json-store.js\";\nimport { isRecord } from \"./store-contract.js\";\nimport { FallbackLlmClient, fallbackLlmRuntimeContextFromConfig } from \"./fallback-llm.js\";\nimport type { AgentPersonaModelConfig, GatewayConfig, MemoryFile, PluginConfig } from \"./types.js\";\nimport path from \"node:path\";\nimport { log } from \"./logger.js\";\nimport { runPostConsolidationMaterialize } from \"./connectors/codex-materialize-runner.js\";\nimport type { MaterializeResult, RolloutSummaryInput } from \"./connectors/codex-materialize.js\";\nimport { buildExtensionsBlockForConsolidation } from \"./semantic-consolidation.js\";\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\nexport interface CausalPatternCandidate {\n id: string;\n sourceType: \"causal-pattern\";\n subject: string;\n category: \"principle\" | \"rule\" | \"preference\";\n content: string;\n score: number;\n rationale: string;\n outcome: null;\n provenance: string[];\n agent: string | null;\n workflow: string | null;\n}\n\nexport interface ConsolidationConfig {\n minRecurrence: number;\n minSessions: number;\n successThreshold: number;\n}\n\nexport interface LlmConsolidationResult {\n rules: Array<{\n content: string;\n category: \"rule\" | \"principle\" | \"preference\";\n confidence: number;\n evidence: string[];\n }>;\n preferences: Array<{\n statement: string;\n confidence: number;\n evidence: string[];\n }>;\n}\n\nconst CAUSAL_RULE_CATEGORIES = new Set([\"rule\", \"principle\", \"preference\"]);\n\ninterface ConsolidationLlmClient {\n isAvailable(options?: { agentId?: string; modelChain?: AgentPersonaModelConfig }): boolean;\n chatCompletion(\n messages: Array<{ role: \"system\" | \"user\" | \"assistant\"; content: string }>,\n options?: { temperature?: number; maxTokens?: number; agentId?: string; modelChain?: AgentPersonaModelConfig },\n ): Promise<{ content: string } | null>;\n}\n\n// ─── Trajectory Reading ──────────────────────────────────────────────────────\n\nasync function readAllTrajectories(\n memoryDir: string,\n causalTrajectoryStoreDir?: string,\n): Promise<CausalTrajectoryRecord[]> {\n const root = resolveCausalTrajectoryStoreDir(memoryDir, causalTrajectoryStoreDir);\n const trajectoriesDir = path.join(root, \"trajectories\");\n\n const files = await listJsonFiles(trajectoriesDir).catch(() => [] as string[]);\n const results: CausalTrajectoryRecord[] = [];\n\n for (const filePath of files) {\n try {\n const raw = await readJsonFile(filePath);\n if (isRecord(raw) && typeof raw.trajectoryId === \"string\") {\n results.push(raw as unknown as CausalTrajectoryRecord);\n }\n } catch {\n // skip invalid\n }\n }\n\n return results;\n}\n\n// ─── Context Formatting ──────────────────────────────────────────────────────\n\n/**\n * Format trajectories and their causal connections as a readable context\n * for the LLM. Groups by session and shows chain connections.\n */\nfunction formatCausalContext(\n trajectories: CausalTrajectoryRecord[],\n chainIndex: CausalChainIndex,\n maxChars: number = 8000,\n): string {\n // Group trajectories by session\n const bySession = new Map<string, CausalTrajectoryRecord[]>();\n for (const t of trajectories) {\n const list = bySession.get(t.sessionKey) ?? [];\n list.push(t);\n bySession.set(t.sessionKey, list);\n }\n\n const lines: string[] = [];\n lines.push(`## Causal Trajectories (${trajectories.length} across ${bySession.size} sessions)`);\n lines.push(\"\");\n\n // Format each session's trajectories\n for (const [sessionKey, sessionTrajs] of bySession) {\n lines.push(`### Session: ${sessionKey}`);\n for (const t of sessionTrajs.slice(0, 5)) {\n const outcome = t.outcomeKind === \"success\" ? \"+\" : t.outcomeKind === \"failure\" ? \"-\" : \"~\";\n lines.push(`[${outcome}] Goal: ${t.goal}`);\n lines.push(` Action: ${t.actionSummary}`);\n lines.push(` Outcome: ${t.outcomeSummary}`);\n if (t.followUpSummary) lines.push(` Follow-up: ${t.followUpSummary}`);\n if (t.entityRefs?.length) lines.push(` Entities: ${t.entityRefs.join(\", \")}`);\n }\n lines.push(\"\");\n }\n\n // Format causal chain connections\n const edgeCount = Object.keys(chainIndex.edges).length;\n if (edgeCount > 0) {\n lines.push(`## Cross-Session Causal Chains (${edgeCount} connections)`);\n lines.push(\"\");\n\n const trajectoryMap = new Map(trajectories.map((t) => [t.trajectoryId, t]));\n const shown = new Set<string>();\n\n for (const [edgeId, edge] of Object.entries(chainIndex.edges)) {\n if (shown.size >= 10) break; // limit output size\n const from = trajectoryMap.get(edge.fromTrajectoryId);\n const to = trajectoryMap.get(edge.toTrajectoryId);\n if (!from || !to) continue;\n\n lines.push(`${edge.edgeType}: \"${from.goal}\" (${from.sessionKey}) → \"${to.goal}\" (${to.sessionKey})`);\n shown.add(edgeId);\n }\n lines.push(\"\");\n }\n\n const result = lines.join(\"\\n\");\n return result.length > maxChars ? result.slice(0, maxChars) + \"\\n[truncated]\" : result;\n}\n\n// ─── LLM Consolidation ──────────────────────────────────────────────────────\n\nconst CONSOLIDATION_PROMPT = `You are analyzing a user's causal trajectory history across multiple sessions. Trajectories record what the user tried to do (goal), what they did (action), and what happened (outcome).\n\nYour job is to identify:\n1. BEHAVIORAL RULES: Recurring patterns where the same approach consistently succeeds or fails. These should be actionable guidance for future sessions.\n2. PREFERENCES: What the user cares about, prefers, or consistently chooses — even if never explicitly stated. Infer preferences from what they repeatedly do, retry until successful, or always include in their workflow.\n\nIMPORTANT:\n- Look for CROSS-SESSION patterns — things that repeat across different sessions are more significant than within-session patterns.\n- A user who retries the same goal across sessions has a strong implicit preference for that outcome.\n- Consistent action choices reveal preferences even when the user never says \"I prefer X.\"\n- Frame preferences as \"The user would prefer responses that...\" when applicable.\n\nOutput valid JSON only:\n{\n \"rules\": [\n {\"content\": \"actionable rule text\", \"category\": \"rule|principle\", \"confidence\": 0.0-1.0, \"evidence\": [\"trajectory IDs\"]}\n ],\n \"preferences\": [\n {\"statement\": \"The user would prefer...\", \"confidence\": 0.0-1.0, \"evidence\": [\"trajectory IDs\"]}\n ]\n}\n\nIf no clear patterns exist, return {\"rules\": [], \"preferences\": []}.`;\n\nasync function consolidateWithLlm(\n context: string,\n llm: ConsolidationLlmClient,\n options: { agentId?: string; modelChain?: AgentPersonaModelConfig } = {},\n): Promise<LlmConsolidationResult> {\n const response = await llm.chatCompletion(\n [\n { role: \"system\", content: CONSOLIDATION_PROMPT },\n { role: \"user\", content: context },\n ],\n { temperature: 0.2, maxTokens: 2000, agentId: options.agentId, modelChain: options.modelChain },\n );\n\n if (!response?.content) {\n return { rules: [], preferences: [] };\n }\n\n try {\n // Extract JSON from response (may have markdown code fences)\n let jsonStr = response.content.trim();\n const fenceMatch = jsonStr.match(/```(?:json)?\\s*\\n?([\\s\\S]*?)\\n?\\s*```/);\n if (fenceMatch) jsonStr = fenceMatch[1];\n\n const parsed = JSON.parse(jsonStr);\n const rawRules: unknown[] = Array.isArray(parsed.rules) ? parsed.rules : [];\n const rawPreferences: unknown[] = Array.isArray(parsed.preferences) ? parsed.preferences : [];\n return {\n rules: rawRules\n .map(parseLlmRule)\n .filter((rule): rule is LlmConsolidationResult[\"rules\"][number] => !!rule),\n preferences: rawPreferences\n .map(parseLlmPreference)\n .filter((pref): pref is LlmConsolidationResult[\"preferences\"][number] => !!pref),\n };\n } catch {\n log.warn(\"[cmc] failed to parse LLM consolidation response\");\n return { rules: [], preferences: [] };\n }\n}\n\n// ─── Candidate Generation ────────────────────────────────────────────────────\n\nfunction stablePatternId(content: string): string {\n const digest = createHash(\"sha256\")\n .update(`causal-pattern\\0${content}`)\n .digest(\"hex\")\n .slice(0, 16);\n return `causal-pattern:${digest}`;\n}\n\nfunction parseConfidence(value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined;\n return Math.max(0, Math.min(1, value));\n}\n\nfunction parseEvidence(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value.filter((item): item is string => typeof item === \"string\" && item.trim().length > 0);\n}\n\nfunction parseLlmRule(raw: unknown): LlmConsolidationResult[\"rules\"][number] | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const r = raw as Record<string, unknown>;\n const content = typeof r.content === \"string\" ? r.content.trim() : \"\";\n const category = typeof r.category === \"string\" ? r.category : \"\";\n const confidence = parseConfidence(r.confidence);\n if (content.length <= 5 || !CAUSAL_RULE_CATEGORIES.has(category) || confidence === undefined) {\n return undefined;\n }\n return {\n content,\n category: category as \"rule\" | \"principle\" | \"preference\",\n confidence,\n evidence: parseEvidence(r.evidence),\n };\n}\n\nfunction parseLlmPreference(raw: unknown): LlmConsolidationResult[\"preferences\"][number] | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return undefined;\n const p = raw as Record<string, unknown>;\n const statement = typeof p.statement === \"string\" ? p.statement.trim() : \"\";\n const confidence = parseConfidence(p.confidence);\n if (statement.length <= 5 || confidence === undefined) return undefined;\n return {\n statement,\n confidence,\n evidence: parseEvidence(p.evidence),\n };\n}\n\nfunction llmResultToCandidates(result: LlmConsolidationResult): CausalPatternCandidate[] {\n const candidates: CausalPatternCandidate[] = [];\n\n for (const rule of result.rules) {\n const category =\n rule.category === \"principle\" || rule.category === \"preference\"\n ? rule.category\n : \"rule\";\n candidates.push({\n id: stablePatternId(rule.content),\n sourceType: \"causal-pattern\",\n subject: rule.content.slice(0, 80),\n category,\n content: rule.content,\n score: Math.min(1, rule.confidence ?? 0.7),\n rationale: \"LLM-identified causal pattern from cross-session trajectory analysis\",\n outcome: null,\n provenance: (rule.evidence ?? []).slice(0, 5),\n agent: null,\n workflow: null,\n });\n }\n\n for (const preference of result.preferences) {\n candidates.push({\n id: stablePatternId(preference.statement),\n sourceType: \"causal-pattern\",\n subject: preference.statement.slice(0, 80),\n category: \"preference\",\n content: preference.statement,\n score: Math.min(1, preference.confidence ?? 0.7),\n rationale: \"LLM-identified preference from cross-session trajectory analysis\",\n outcome: null,\n provenance: (preference.evidence ?? []).slice(0, 5),\n agent: null,\n workflow: null,\n });\n }\n\n return candidates;\n}\n\nfunction normalizePositiveInteger(value: number, fallback: number): number {\n return Number.isFinite(value) && value > 0 ? Math.floor(value) : fallback;\n}\n\nfunction normalizeSuccessThreshold(value: number): number {\n if (!Number.isFinite(value) || value <= 0) return 0;\n return Math.min(1, value);\n}\n\nfunction trajectorySuccessScore(trajectory: CausalTrajectoryRecord): number {\n if (trajectory.outcomeKind === \"success\") return 1;\n if (trajectory.outcomeKind === \"partial\") return 0.5;\n return 0;\n}\n\nfunction averageSuccessScore(trajectories: CausalTrajectoryRecord[]): number {\n if (trajectories.length === 0) return 0;\n const total = trajectories.reduce((sum, trajectory) => sum + trajectorySuccessScore(trajectory), 0);\n return total / trajectories.length;\n}\n\nfunction passesConsolidationGates(\n trajectories: CausalTrajectoryRecord[],\n config: ConsolidationConfig,\n): boolean {\n const minRecurrence = normalizePositiveInteger(config.minRecurrence, 1);\n if (trajectories.length < minRecurrence) return false;\n\n const minSessions = normalizePositiveInteger(config.minSessions, 1);\n const sessionCount = new Set(trajectories.map((trajectory) => trajectory.sessionKey)).size;\n if (sessionCount < minSessions) return false;\n\n const successThreshold = normalizeSuccessThreshold(config.successThreshold);\n if (successThreshold > 0 && averageSuccessScore(trajectories) < successThreshold) {\n return false;\n }\n\n return true;\n}\n\n// ─── Public API ──────────────────────────────────────────────────────────────\n\n/**\n * Run LLM-assisted consolidation: read trajectories, format causal context,\n * ask LLM to identify patterns and preferences.\n */\nexport async function deriveCausalPromotionCandidates(options: {\n memoryDir: string;\n causalTrajectoryStoreDir?: string;\n config: ConsolidationConfig;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n pluginConfig?: PluginConfig;\n llmClient?: ConsolidationLlmClient;\n}): Promise<CausalPatternCandidate[]> {\n try {\n const trajectories = await readAllTrajectories(options.memoryDir, options.causalTrajectoryStoreDir);\n if (!passesConsolidationGates(trajectories, options.config)) return [];\n\n const chainsDir = resolveChainsDir(options.memoryDir, options.causalTrajectoryStoreDir);\n const chainIndex = await readChainIndex(chainsDir);\n\n // Format the causal context for the LLM\n let context = formatCausalContext(trajectories, chainIndex);\n\n // Append memory extensions block if available (#382)\n if (options.pluginConfig) {\n const extBlock = await buildExtensionsBlockForConsolidation(options.pluginConfig);\n if (extBlock.length > 0) {\n context += \"\\n\\n\" + extBlock;\n }\n }\n\n // If no LLM available, fall back to empty (no deterministic fallback)\n const llm = options.llmClient ?? new FallbackLlmClient(\n options.gatewayConfig,\n options.pluginConfig\n ? fallbackLlmRuntimeContextFromConfig(options.pluginConfig, {\n workspaceDir: options.workspaceDir ?? options.pluginConfig.workspaceDir,\n })\n : { workspaceDir: options.workspaceDir },\n );\n const llmOptions = { agentId: options.gatewayAgentId, modelChain: options.modelChain };\n if (!llm.isAvailable(llmOptions)) {\n log.debug(\"[cmc] no LLM available for consolidation — skipping\");\n return [];\n }\n\n // Call LLM for pattern analysis\n const result = await consolidateWithLlm(context, llm, llmOptions);\n const candidates = llmResultToCandidates(result);\n\n log.debug(`[cmc] LLM consolidation produced ${candidates.length} rule(s) and ${result.preferences.length} preference(s)`);\n return candidates;\n } catch (error) {\n log.warn(`[cmc] consolidation failed (non-fatal): ${error instanceof Error ? error.message : String(error)}`);\n return [];\n }\n}\n\n/**\n * Get LLM-synthesized preferences from causal trajectory analysis.\n * Returns formatted preference statements for recall injection.\n */\nexport async function synthesizeCausalPreferencesViaLlm(options: {\n memoryDir: string;\n causalTrajectoryStoreDir?: string;\n gatewayConfig?: GatewayConfig;\n gatewayAgentId?: string;\n modelChain?: AgentPersonaModelConfig;\n workspaceDir?: string;\n minTrajectories?: number;\n}): Promise<string | null> {\n try {\n const trajectories = await readAllTrajectories(options.memoryDir, options.causalTrajectoryStoreDir);\n if (trajectories.length < (options.minTrajectories ?? 2)) return null;\n\n const chainsDir = resolveChainsDir(options.memoryDir, options.causalTrajectoryStoreDir);\n const chainIndex = await readChainIndex(chainsDir);\n const context = formatCausalContext(trajectories, chainIndex);\n\n const llm = new FallbackLlmClient(options.gatewayConfig, {\n workspaceDir: options.workspaceDir,\n });\n const llmOptions = { agentId: options.gatewayAgentId, modelChain: options.modelChain };\n if (!llm.isAvailable(llmOptions)) return null;\n\n const result = await consolidateWithLlm(context, llm, llmOptions);\n if (result.preferences.length === 0 && result.rules.length === 0) return null;\n\n const lines: string[] = [\"## Behavioral Insights (from Causal Chain Analysis)\", \"\"];\n\n for (const pref of result.preferences) {\n lines.push(`- ${pref.statement}`);\n }\n\n for (const rule of result.rules) {\n lines.push(`- ${rule.content}`);\n }\n\n lines.push(\"\");\n return lines.join(\"\\n\");\n } catch (error) {\n log.warn(`[cmc] preference synthesis failed (non-fatal): ${error instanceof Error ? error.message : String(error)}`);\n return null;\n }\n}\n\n/**\n * Optional post-consolidation hook — materializes Codex-native memory artifacts\n * after a causal consolidation run. Guarded by `codexMaterializeMemories` and\n * `codexMaterializeOnConsolidation`. Returns `null` when disabled or when the\n * sentinel is missing (honors user hand-edits).\n *\n * Split from the orchestrator-owned flow so #378 avoids touching\n * orchestrator.ts while Wave 1 edits are in flight.\n */\nexport async function materializeAfterCausalConsolidation(options: {\n config: PluginConfig;\n namespace?: string;\n memories?: MemoryFile[];\n memoryDir?: string;\n codexHome?: string;\n rolloutSummaries?: RolloutSummaryInput[];\n now?: Date;\n}): Promise<MaterializeResult | null> {\n // Delegates to the shared post-consolidation helper — see\n // runPostConsolidationMaterialize in codex-materialize-runner.ts.\n return runPostConsolidationMaterialize(\"[cmc]\", options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,kBAAkB;AAO3B,OAAO,UAAU;AA0CjB,IAAM,yBAAyB,oBAAI,IAAI,CAAC,QAAQ,aAAa,YAAY,CAAC;AAY1E,eAAe,oBACb,WACA,0BACmC;AACnC,QAAM,OAAO,gCAAgC,WAAW,wBAAwB;AAChF,QAAM,kBAAkB,KAAK,KAAK,MAAM,cAAc;AAEtD,QAAM,QAAQ,MAAM,cAAc,eAAe,EAAE,MAAM,MAAM,CAAC,CAAa;AAC7E,QAAM,UAAoC,CAAC;AAE3C,aAAW,YAAY,OAAO;AAC5B,QAAI;AACF,YAAM,MAAM,MAAM,aAAa,QAAQ;AACvC,UAAI,SAAS,GAAG,KAAK,OAAO,IAAI,iBAAiB,UAAU;AACzD,gBAAQ,KAAK,GAAwC;AAAA,MACvD;AAAA,IACF,QAAQ;AAAA,IAER;AAAA,EACF;AAEA,SAAO;AACT;AAQA,SAAS,oBACP,cACA,YACA,WAAmB,KACX;AAER,QAAM,YAAY,oBAAI,IAAs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I,kBAAkB,QAAQ,eAAe;AAAA,MACvD,cAAc,QAAQ;AAAA,IACxB,CAAC;AACD,UAAM,aAAa,EAAE,SAAS,QAAQ,gBAAgB,YAAY,QAAQ,WAAW;AACrF,QAAI,CAAC,IAAI,YAAY,UAAU,EAAG,QAAO;AAEzC,UAAM,SAAS,MAAM,mBAAmB,SAAS,KAAK,UAAU;AAChE,QAAI,OAAO,YAAY,WAAW,KAAK,OAAO,MAAM,WAAW,EAAG,QAAO;AAEzE,UAAM,QAAkB,CAAC,uDAAuD,EAAE;AAElF,eAAW,QAAQ,OAAO,aAAa;AACrC,YAAM,KAAK,KAAK,KAAK,SAAS,EAAE;AAAA,IAClC;AAEA,eAAW,QAAQ,OAAO,OAAO;AAC/B,YAAM,KAAK,KAAK,KAAK,OAAO,EAAE;AAAA,IAChC;AAEA,UAAM,KAAK,EAAE;AACb,WAAO,MAAM,KAAK,IAAI;AAAA,EACxB,SAAS,OAAO;AACd,QAAI,KAAK,kDAAkD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AACnH,WAAO;AAAA,EACT;AACF;AAWA,eAAsB,oCAAoC,SAQpB;AAGpC,SAAO,gCAAgC,SAAS,OAAO;AACzD;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as GraphEdge } from './graph-444E-DrF.js';
|
|
2
2
|
import { CausalTrajectoryRecord } from './causal-trajectory.js';
|
|
3
3
|
import './capabilities.js';
|
|
4
|
-
import './types-
|
|
4
|
+
import './types-ETU5N6nB.js';
|
|
5
5
|
import './message-parts/index.js';
|
|
6
6
|
import './bounded-jsonl-state.js';
|
|
7
7
|
import './types-CM86alG1.js';
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isValidSkillSlug
|
|
3
|
+
} from "./chunk-ZCUTSMR2.js";
|
|
4
|
+
import {
|
|
5
|
+
parseProcedureStepsFromBody
|
|
6
|
+
} from "./chunk-QDW3E4RD.js";
|
|
7
|
+
import {
|
|
8
|
+
coerceBool,
|
|
9
|
+
coerceNumber
|
|
10
|
+
} from "./chunk-PQVCH2AE.js";
|
|
11
|
+
import {
|
|
12
|
+
stripAttributesSuffix
|
|
13
|
+
} from "./chunk-JDSVLVCG.js";
|
|
14
|
+
|
|
15
|
+
// src/procedural/skill-projection.ts
|
|
16
|
+
var SKILL_MEMORY_ID_KEY = "x-remnic-memory-id";
|
|
17
|
+
var SKILL_UPDATED_KEY = "x-remnic-updated";
|
|
18
|
+
var SKILL_SOURCE_KEY = "x-remnic-source";
|
|
19
|
+
var SKILL_FILE_NAME = "SKILL.md";
|
|
20
|
+
var SKILL_IMPORT_SOURCE = "skill-import";
|
|
21
|
+
var PROJECTABLE_STATUSES = { active: true };
|
|
22
|
+
var DEFAULT_SKILL_PROJECTION_MAX_SKILLS = 20;
|
|
23
|
+
var MAX_SKILL_PROJECTION_MAX_SKILLS = 500;
|
|
24
|
+
var MAX_SLUG_LENGTH = 64;
|
|
25
|
+
var MAX_DESCRIPTION_LENGTH = 300;
|
|
26
|
+
function parseSkillProjectionConfig(raw) {
|
|
27
|
+
if (raw !== void 0 && (raw === null || typeof raw !== "object" || Array.isArray(raw))) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`procedural.skillProjection must be an object (got ${JSON.stringify(raw)}). Omit the key to keep skill projection disabled (issue #2369).`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
const block = raw && typeof raw === "object" ? raw : {};
|
|
33
|
+
let enabled = false;
|
|
34
|
+
if (block.enabled !== void 0) {
|
|
35
|
+
const coerced = coerceBool(block.enabled);
|
|
36
|
+
if (coerced === void 0) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`procedural.skillProjection.enabled must be a boolean or one of "true"/"false"/"1"/"0"/"yes"/"no"/"on"/"off" (got ${JSON.stringify(block.enabled)}).`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
enabled = coerced;
|
|
42
|
+
}
|
|
43
|
+
let maxSkills = DEFAULT_SKILL_PROJECTION_MAX_SKILLS;
|
|
44
|
+
if (block.maxSkills !== void 0) {
|
|
45
|
+
const coerced = coerceNumber(block.maxSkills);
|
|
46
|
+
if (coerced === void 0 || !Number.isFinite(coerced)) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`procedural.skillProjection.maxSkills must be a finite number (got ${JSON.stringify(block.maxSkills)}).`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
if (!Number.isInteger(coerced)) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`procedural.skillProjection.maxSkills must be an integer (got ${JSON.stringify(block.maxSkills)}).`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (coerced < 0 || coerced > MAX_SKILL_PROJECTION_MAX_SKILLS) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`procedural.skillProjection.maxSkills must be between 0 and ${MAX_SKILL_PROJECTION_MAX_SKILLS} (got ${JSON.stringify(block.maxSkills)}). 0 disables projection.`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
maxSkills = coerced;
|
|
62
|
+
}
|
|
63
|
+
return { enabled, maxSkills };
|
|
64
|
+
}
|
|
65
|
+
function sanitizeSkillSlug(input) {
|
|
66
|
+
const base = input.toLowerCase().replace(/[^a-z0-9]+/g, "-").slice(0, MAX_SLUG_LENGTH);
|
|
67
|
+
const trimmed = trimDashes(base);
|
|
68
|
+
return trimmed.length > 0 && isValidSkillSlug(trimmed) ? trimmed : "procedure";
|
|
69
|
+
}
|
|
70
|
+
function trimDashes(value) {
|
|
71
|
+
let start = 0;
|
|
72
|
+
let end = value.length;
|
|
73
|
+
while (start < end && value[start] === "-") start += 1;
|
|
74
|
+
while (end > start && value[end - 1] === "-") end -= 1;
|
|
75
|
+
return value.slice(start, end);
|
|
76
|
+
}
|
|
77
|
+
function withSuffix(base, suffix) {
|
|
78
|
+
const room = MAX_SLUG_LENGTH - suffix.length;
|
|
79
|
+
const head = trimDashes(base.slice(0, Math.max(1, room)));
|
|
80
|
+
const candidate = `${head.length > 0 ? head : "procedure"}${suffix}`;
|
|
81
|
+
return isValidSkillSlug(candidate) ? candidate : `procedure${suffix}`;
|
|
82
|
+
}
|
|
83
|
+
function allocateSlug(base, used, reserved) {
|
|
84
|
+
let candidate = reserved.has(base) ? withSuffix(`user-${base}`, "") : base;
|
|
85
|
+
if (!isValidSkillSlug(candidate)) candidate = "procedure";
|
|
86
|
+
if (!used.has(candidate) && !reserved.has(candidate)) {
|
|
87
|
+
used.add(candidate);
|
|
88
|
+
return candidate;
|
|
89
|
+
}
|
|
90
|
+
for (let n = 2; n < 1e4; n++) {
|
|
91
|
+
const next = withSuffix(candidate, `-${n}`);
|
|
92
|
+
if (!used.has(next) && !reserved.has(next)) {
|
|
93
|
+
used.add(next);
|
|
94
|
+
return next;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
throw new Error(`skill-projection: could not allocate a unique slug for ${base}`);
|
|
98
|
+
}
|
|
99
|
+
function procedureTitleFromBody(body) {
|
|
100
|
+
for (const line of body.replace(/\r\n/g, "\n").split("\n")) {
|
|
101
|
+
const trimmed = line.trim();
|
|
102
|
+
if (trimmed.length === 0) continue;
|
|
103
|
+
if (/^##\s+Step\s+\d+/i.test(trimmed)) break;
|
|
104
|
+
return trimmed.replace(/^#{1,6}\s*/, "").trim();
|
|
105
|
+
}
|
|
106
|
+
return "";
|
|
107
|
+
}
|
|
108
|
+
function compareProcedures(a, b) {
|
|
109
|
+
const aTs = Date.parse(a.frontmatter.updated ?? "");
|
|
110
|
+
const bTs = Date.parse(b.frontmatter.updated ?? "");
|
|
111
|
+
const aVal = Number.isFinite(aTs) ? aTs : 0;
|
|
112
|
+
const bVal = Number.isFinite(bTs) ? bTs : 0;
|
|
113
|
+
if (aVal !== bVal) return bVal - aVal;
|
|
114
|
+
const aId = a.frontmatter.id ?? "";
|
|
115
|
+
const bId = b.frontmatter.id ?? "";
|
|
116
|
+
if (aId < bId) return -1;
|
|
117
|
+
if (aId > bId) return 1;
|
|
118
|
+
return 0;
|
|
119
|
+
}
|
|
120
|
+
function projectProceduresToSkills(memories, options = {}) {
|
|
121
|
+
const maxSkills = typeof options.maxSkills === "number" && Number.isInteger(options.maxSkills) && options.maxSkills >= 0 ? Math.min(MAX_SKILL_PROJECTION_MAX_SKILLS, options.maxSkills) : DEFAULT_SKILL_PROJECTION_MAX_SKILLS;
|
|
122
|
+
if (maxSkills === 0) return [];
|
|
123
|
+
const reserved = new Set((options.reservedSlugs ?? []).map((s) => s.trim().toLowerCase()));
|
|
124
|
+
const candidates = memories.filter(
|
|
125
|
+
(m) => m.frontmatter.category === "procedure" && PROJECTABLE_STATUSES[m.frontmatter.status ?? "active"] === true && typeof m.content === "string" && m.content.trim().length > 0
|
|
126
|
+
).sort(compareProcedures).slice(0, maxSkills);
|
|
127
|
+
const used = /* @__PURE__ */ new Set();
|
|
128
|
+
const bundles = [];
|
|
129
|
+
for (const memory of candidates) {
|
|
130
|
+
const body = stripAttributesSuffix(memory.content.replace(/\r\n/g, "\n")).trim();
|
|
131
|
+
const title = procedureTitleFromBody(body) || memory.frontmatter.id;
|
|
132
|
+
const slug = allocateSlug(sanitizeSkillSlug(title), used, reserved);
|
|
133
|
+
bundles.push({
|
|
134
|
+
slug,
|
|
135
|
+
frontmatter: {
|
|
136
|
+
name: slug,
|
|
137
|
+
description: title.slice(0, MAX_DESCRIPTION_LENGTH)
|
|
138
|
+
},
|
|
139
|
+
body: `${body}
|
|
140
|
+
`,
|
|
141
|
+
provenance: {
|
|
142
|
+
memoryId: memory.frontmatter.id,
|
|
143
|
+
updated: memory.frontmatter.updated,
|
|
144
|
+
...memory.frontmatter.source ? { source: memory.frontmatter.source } : {}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return bundles;
|
|
149
|
+
}
|
|
150
|
+
function renderSkillBundle(bundle) {
|
|
151
|
+
const lines = [
|
|
152
|
+
"---",
|
|
153
|
+
`name: ${yamlScalar(bundle.frontmatter.name)}`,
|
|
154
|
+
`description: ${yamlScalar(bundle.frontmatter.description)}`,
|
|
155
|
+
`${SKILL_MEMORY_ID_KEY}: ${yamlScalar(bundle.provenance.memoryId)}`,
|
|
156
|
+
`${SKILL_UPDATED_KEY}: ${yamlScalar(bundle.provenance.updated)}`
|
|
157
|
+
];
|
|
158
|
+
if (bundle.provenance.source) {
|
|
159
|
+
lines.push(`${SKILL_SOURCE_KEY}: ${yamlScalar(bundle.provenance.source)}`);
|
|
160
|
+
}
|
|
161
|
+
lines.push("---", "");
|
|
162
|
+
return `${lines.join("\n")}
|
|
163
|
+
${bundle.body.trimEnd()}
|
|
164
|
+
`;
|
|
165
|
+
}
|
|
166
|
+
function yamlScalar(value) {
|
|
167
|
+
return JSON.stringify(value.replace(/\r?\n/g, " ").trim());
|
|
168
|
+
}
|
|
169
|
+
function parseSkillBundle(text, slug) {
|
|
170
|
+
const lines = text.replace(/\r\n/g, "\n").split("\n");
|
|
171
|
+
let frontmatter = {};
|
|
172
|
+
let bodyLines = lines;
|
|
173
|
+
if (lines[0]?.trim() === "---") {
|
|
174
|
+
const close = lines.findIndex((line, idx) => idx > 0 && line.trim() === "---");
|
|
175
|
+
if (close !== -1) {
|
|
176
|
+
frontmatter = parseFlatFrontmatter(lines.slice(1, close).join("\n"));
|
|
177
|
+
bodyLines = lines.slice(close + 1);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const body = bodyLines.join("\n").trim();
|
|
181
|
+
if (body.length === 0) return null;
|
|
182
|
+
return {
|
|
183
|
+
slug,
|
|
184
|
+
name: frontmatter.name,
|
|
185
|
+
description: frontmatter.description,
|
|
186
|
+
body,
|
|
187
|
+
steps: parseProcedureStepsFromBody(body),
|
|
188
|
+
provenance: {
|
|
189
|
+
memoryId: frontmatter[SKILL_MEMORY_ID_KEY],
|
|
190
|
+
updated: frontmatter[SKILL_UPDATED_KEY],
|
|
191
|
+
source: frontmatter[SKILL_SOURCE_KEY]
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function parseFlatFrontmatter(block) {
|
|
196
|
+
const out = {};
|
|
197
|
+
for (const line of block.split("\n")) {
|
|
198
|
+
if (/^\s/.test(line) || line.trim().startsWith("#")) continue;
|
|
199
|
+
const colon = line.indexOf(":");
|
|
200
|
+
if (colon <= 0) continue;
|
|
201
|
+
const key = line.slice(0, colon).trim();
|
|
202
|
+
const raw = line.slice(colon + 1).trim();
|
|
203
|
+
if (key.length === 0 || raw.length === 0) continue;
|
|
204
|
+
out[key] = unquoteScalar(raw);
|
|
205
|
+
}
|
|
206
|
+
return out;
|
|
207
|
+
}
|
|
208
|
+
function unquoteScalar(raw) {
|
|
209
|
+
if (raw.startsWith('"') && raw.endsWith('"') && raw.length >= 2) {
|
|
210
|
+
try {
|
|
211
|
+
const parsed = JSON.parse(raw);
|
|
212
|
+
if (typeof parsed === "string") return parsed;
|
|
213
|
+
} catch {
|
|
214
|
+
}
|
|
215
|
+
return raw.slice(1, -1);
|
|
216
|
+
}
|
|
217
|
+
if (raw.startsWith("'") && raw.endsWith("'") && raw.length >= 2) {
|
|
218
|
+
return raw.slice(1, -1);
|
|
219
|
+
}
|
|
220
|
+
return raw;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export {
|
|
224
|
+
SKILL_FILE_NAME,
|
|
225
|
+
SKILL_IMPORT_SOURCE,
|
|
226
|
+
parseSkillProjectionConfig,
|
|
227
|
+
sanitizeSkillSlug,
|
|
228
|
+
projectProceduresToSkills,
|
|
229
|
+
renderSkillBundle,
|
|
230
|
+
parseSkillBundle
|
|
231
|
+
};
|
|
232
|
+
//# sourceMappingURL=chunk-236PXYG7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/procedural/skill-projection.ts"],"sourcesContent":["/**\n * skill-projection.ts — project active `procedure` memories into portable\n * `skills/<slug>/SKILL.md` bundles, and parse hand-authored bundles back into\n * procedure candidates (issue #2369).\n *\n * Pure module: no filesystem, no host coupling. The Codex materializer, the\n * `remnic export skills` CLI, and `remnic import skills` all consume these\n * functions so one slug + format contract serves every surface.\n *\n * Import is INERT by construction: this module only ever returns text and\n * parsed steps. It never resolves, loads, or executes a bundle resource.\n */\n\nimport { coerceBool, coerceNumber } from \"../connectors/coerce.js\";\nimport { isValidSkillSlug } from \"../skills-registry.js\";\nimport { stripAttributesSuffix } from \"../structured-attributes.js\";\nimport type { MemoryFile, MemoryStatus } from \"../types.js\";\nimport { parseProcedureStepsFromBody, type ProcedureStep } from \"./procedure-types.js\";\n\n/** Provenance frontmatter keys. Namespaced so hosts treat them as opaque. */\nexport const SKILL_MEMORY_ID_KEY = \"x-remnic-memory-id\";\nexport const SKILL_UPDATED_KEY = \"x-remnic-updated\";\nexport const SKILL_SOURCE_KEY = \"x-remnic-source\";\n\n/** File name every bundle directory must contain. */\nexport const SKILL_FILE_NAME = \"SKILL.md\";\n\n/** Source tag written on imported procedure memories. */\nexport const SKILL_IMPORT_SOURCE = \"skill-import\";\n\n/**\n * The ONLY statuses that may be projected (Review Prevention Checklist §41 —\n * define the active set, never an exclusion list). `pending_review`,\n * `rejected`, `quarantined`, `superseded`, `archived`, and `forgotten` are\n * withheld because a projected skill is loaded by a host with no further gate.\n */\nconst PROJECTABLE_STATUSES: Partial<Record<MemoryStatus, true>> = { active: true };\n\n/** Default projection cap. `0` disables projection entirely. */\nexport const DEFAULT_SKILL_PROJECTION_MAX_SKILLS = 20;\n\n/** Hard ceiling so a misconfigured cap cannot flood a host skills directory. */\nconst MAX_SKILL_PROJECTION_MAX_SKILLS = 500;\n\nconst MAX_SLUG_LENGTH = 64;\nconst MAX_DESCRIPTION_LENGTH = 300;\n\nexport interface SkillBundleProvenance {\n /** Remnic memory id this bundle was projected from. */\n memoryId: string;\n /** `frontmatter.updated` of the source memory. */\n updated: string;\n /** `frontmatter.source` of the source memory, when present. */\n source?: string;\n}\n\nexport interface SkillBundle {\n slug: string;\n frontmatter: { name: string; description: string };\n /** Markdown body: the stored procedure body (title line + `## Step N`). */\n body: string;\n provenance: SkillBundleProvenance;\n}\n\nexport interface ProjectProceduresOptions {\n /** Cap on projected bundles. `0` projects nothing. Default 20. */\n maxSkills?: number;\n /** Slugs a projected bundle must not take (e.g. `BUILTIN_SKILLS` slugs). */\n reservedSlugs?: readonly string[];\n}\n\nexport interface SkillProjectionConfig {\n enabled: boolean;\n maxSkills: number;\n}\n\n/**\n * Parse the `procedural.skillProjection` config block. Mirrors\n * `parseProceduralMaintenanceConfig`: string forms (`\"false\"`, `\"0\"`) coerce,\n * unrecognized values throw rather than silently defaulting.\n */\nexport function parseSkillProjectionConfig(raw: unknown): SkillProjectionConfig {\n if (raw !== undefined && (raw === null || typeof raw !== \"object\" || Array.isArray(raw))) {\n throw new Error(\n `procedural.skillProjection must be an object (got ${JSON.stringify(raw)}). Omit the key to keep skill projection disabled (issue #2369).`,\n );\n }\n const block = raw && typeof raw === \"object\" ? (raw as Record<string, unknown>) : {};\n\n let enabled = false;\n if (block.enabled !== undefined) {\n const coerced = coerceBool(block.enabled);\n if (coerced === undefined) {\n throw new Error(\n `procedural.skillProjection.enabled must be a boolean or one of \"true\"/\"false\"/\"1\"/\"0\"/\"yes\"/\"no\"/\"on\"/\"off\" (got ${JSON.stringify(block.enabled)}).`,\n );\n }\n enabled = coerced;\n }\n\n let maxSkills = DEFAULT_SKILL_PROJECTION_MAX_SKILLS;\n if (block.maxSkills !== undefined) {\n const coerced = coerceNumber(block.maxSkills);\n if (coerced === undefined || !Number.isFinite(coerced)) {\n throw new Error(\n `procedural.skillProjection.maxSkills must be a finite number (got ${JSON.stringify(block.maxSkills)}).`,\n );\n }\n if (!Number.isInteger(coerced)) {\n throw new Error(\n `procedural.skillProjection.maxSkills must be an integer (got ${JSON.stringify(block.maxSkills)}).`,\n );\n }\n if (coerced < 0 || coerced > MAX_SKILL_PROJECTION_MAX_SKILLS) {\n throw new Error(\n `procedural.skillProjection.maxSkills must be between 0 and ${MAX_SKILL_PROJECTION_MAX_SKILLS} (got ${JSON.stringify(block.maxSkills)}). 0 disables projection.`,\n );\n }\n // `0` is a documented disable value (§33) — never clamp it up.\n maxSkills = coerced;\n }\n\n return { enabled, maxSkills };\n}\n\n/**\n * Sanitize arbitrary text into a slug `isValidSkillSlug` accepts.\n * Deterministic: the same title always yields the same slug.\n */\nexport function sanitizeSkillSlug(input: string): string {\n const base = input\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .slice(0, MAX_SLUG_LENGTH);\n const trimmed = trimDashes(base);\n return trimmed.length > 0 && isValidSkillSlug(trimmed) ? trimmed : \"procedure\";\n}\n\nfunction trimDashes(value: string): string {\n let start = 0;\n let end = value.length;\n while (start < end && value[start] === \"-\") start += 1;\n while (end > start && value[end - 1] === \"-\") end -= 1;\n return value.slice(start, end);\n}\n\n/** Append a suffix while keeping the slug valid and within the length cap. */\nfunction withSuffix(base: string, suffix: string): string {\n const room = MAX_SLUG_LENGTH - suffix.length;\n const head = trimDashes(base.slice(0, Math.max(1, room)));\n const candidate = `${head.length > 0 ? head : \"procedure\"}${suffix}`;\n return isValidSkillSlug(candidate) ? candidate : `procedure${suffix}`;\n}\n\n/**\n * Reserve a slug: prefix reserved (built-in) collisions with `user-`, then\n * disambiguate duplicates with a stable `-2`, `-3`, … tiebreak so a batch with\n * repeated titles never writes two bundles to one directory (§37).\n */\nfunction allocateSlug(base: string, used: Set<string>, reserved: ReadonlySet<string>): string {\n let candidate = reserved.has(base) ? withSuffix(`user-${base}`, \"\") : base;\n if (!isValidSkillSlug(candidate)) candidate = \"procedure\";\n if (!used.has(candidate) && !reserved.has(candidate)) {\n used.add(candidate);\n return candidate;\n }\n for (let n = 2; n < 10_000; n++) {\n const next = withSuffix(candidate, `-${n}`);\n if (!used.has(next) && !reserved.has(next)) {\n used.add(next);\n return next;\n }\n }\n // Unreachable in practice (10k distinct suffixes per base slug).\n throw new Error(`skill-projection: could not allocate a unique slug for ${base}`);\n}\n\n/** First non-empty line of the body, with a leading markdown heading stripped. */\nexport function procedureTitleFromBody(body: string): string {\n for (const line of body.replace(/\\r\\n/g, \"\\n\").split(\"\\n\")) {\n const trimmed = line.trim();\n if (trimmed.length === 0) continue;\n if (/^##\\s+Step\\s+\\d+/i.test(trimmed)) break;\n return trimmed.replace(/^#{1,6}\\s*/, \"\").trim();\n }\n return \"\";\n}\n\n/** Total comparator: newest first, `id` as the stable tiebreak (§12). */\nfunction compareProcedures(a: MemoryFile, b: MemoryFile): number {\n const aTs = Date.parse(a.frontmatter.updated ?? \"\");\n const bTs = Date.parse(b.frontmatter.updated ?? \"\");\n const aVal = Number.isFinite(aTs) ? aTs : 0;\n const bVal = Number.isFinite(bTs) ? bTs : 0;\n if (aVal !== bVal) return bVal - aVal;\n const aId = a.frontmatter.id ?? \"\";\n const bId = b.frontmatter.id ?? \"\";\n if (aId < bId) return -1;\n if (aId > bId) return 1;\n return 0;\n}\n\n/**\n * Project procedure memories into skill bundles. Filters to `active`\n * procedures, orders deterministically, caps at `maxSkills`, and assigns\n * collision-free slugs.\n */\nexport function projectProceduresToSkills(\n memories: readonly MemoryFile[],\n options: ProjectProceduresOptions = {},\n): SkillBundle[] {\n const maxSkills =\n typeof options.maxSkills === \"number\" && Number.isInteger(options.maxSkills) && options.maxSkills >= 0\n ? Math.min(MAX_SKILL_PROJECTION_MAX_SKILLS, options.maxSkills)\n : DEFAULT_SKILL_PROJECTION_MAX_SKILLS;\n if (maxSkills === 0) return [];\n\n const reserved = new Set((options.reservedSlugs ?? []).map((s) => s.trim().toLowerCase()));\n const candidates = memories\n .filter(\n (m) =>\n m.frontmatter.category === \"procedure\" &&\n PROJECTABLE_STATUSES[(m.frontmatter.status ?? \"active\") as MemoryStatus] === true &&\n typeof m.content === \"string\" &&\n m.content.trim().length > 0,\n )\n .sort(compareProcedures)\n .slice(0, maxSkills);\n\n const used = new Set<string>();\n const bundles: SkillBundle[] = [];\n for (const memory of candidates) {\n // Drop the machine \"[Attributes: ...]\" footer writeMemory appends: a human\n // skill body must not carry it, and leaving it in would let the footer be\n // absorbed into the final step's intent on re-parse.\n const body = stripAttributesSuffix(memory.content.replace(/\\r\\n/g, \"\\n\")).trim();\n const title = procedureTitleFromBody(body) || memory.frontmatter.id;\n const slug = allocateSlug(sanitizeSkillSlug(title), used, reserved);\n bundles.push({\n slug,\n frontmatter: {\n name: slug,\n description: title.slice(0, MAX_DESCRIPTION_LENGTH),\n },\n body: `${body}\\n`,\n provenance: {\n memoryId: memory.frontmatter.id,\n updated: memory.frontmatter.updated,\n ...(memory.frontmatter.source ? { source: memory.frontmatter.source } : {}),\n },\n });\n }\n return bundles;\n}\n\n/**\n * Render one bundle as SKILL.md text. Scalars are emitted as YAML\n * double-quoted strings so a title containing `:` or `#` cannot corrupt the\n * frontmatter block.\n */\nexport function renderSkillBundle(bundle: SkillBundle): string {\n const lines = [\n \"---\",\n `name: ${yamlScalar(bundle.frontmatter.name)}`,\n `description: ${yamlScalar(bundle.frontmatter.description)}`,\n `${SKILL_MEMORY_ID_KEY}: ${yamlScalar(bundle.provenance.memoryId)}`,\n `${SKILL_UPDATED_KEY}: ${yamlScalar(bundle.provenance.updated)}`,\n ];\n if (bundle.provenance.source) {\n lines.push(`${SKILL_SOURCE_KEY}: ${yamlScalar(bundle.provenance.source)}`);\n }\n lines.push(\"---\", \"\");\n return `${lines.join(\"\\n\")}\\n${bundle.body.trimEnd()}\\n`;\n}\n\nfunction yamlScalar(value: string): string {\n return JSON.stringify(value.replace(/\\r?\\n/g, \" \").trim());\n}\n\nexport interface ParsedSkillBundle {\n /** Directory name the bundle was read from (already sanitized by the caller). */\n slug: string;\n name?: string;\n description?: string;\n /** Markdown body with the frontmatter block removed. */\n body: string;\n /** Parsed `## Step N` sections, or `null` for a step-less body. */\n steps: ProcedureStep[] | null;\n provenance: { memoryId?: string; updated?: string; source?: string };\n}\n\n/**\n * Parse SKILL.md text. Frontmatter is optional; unknown keys are ignored.\n * Returns `null` when there is no body to import.\n */\nexport function parseSkillBundle(text: string, slug: string): ParsedSkillBundle | null {\n const lines = text.replace(/\\r\\n/g, \"\\n\").split(\"\\n\");\n // Line scan rather than a lazy `[\\s\\S]*?` fence regex (issue #2439).\n let frontmatter: Record<string, string> = {};\n let bodyLines = lines;\n if (lines[0]?.trim() === \"---\") {\n const close = lines.findIndex((line, idx) => idx > 0 && line.trim() === \"---\");\n if (close !== -1) {\n frontmatter = parseFlatFrontmatter(lines.slice(1, close).join(\"\\n\"));\n bodyLines = lines.slice(close + 1);\n }\n }\n const body = bodyLines.join(\"\\n\").trim();\n if (body.length === 0) return null;\n return {\n slug,\n name: frontmatter.name,\n description: frontmatter.description,\n body,\n steps: parseProcedureStepsFromBody(body),\n provenance: {\n memoryId: frontmatter[SKILL_MEMORY_ID_KEY],\n updated: frontmatter[SKILL_UPDATED_KEY],\n source: frontmatter[SKILL_SOURCE_KEY],\n },\n };\n}\n\n/**\n * Minimal flat `key: value` frontmatter reader. Nested blocks and sequences\n * (e.g. `allowed-tools:`) are skipped — the import path only consumes scalars.\n */\nfunction parseFlatFrontmatter(block: string): Record<string, string> {\n const out: Record<string, string> = {};\n for (const line of block.split(\"\\n\")) {\n if (/^\\s/.test(line) || line.trim().startsWith(\"#\")) continue;\n const colon = line.indexOf(\":\");\n if (colon <= 0) continue;\n const key = line.slice(0, colon).trim();\n const raw = line.slice(colon + 1).trim();\n if (key.length === 0 || raw.length === 0) continue;\n out[key] = unquoteScalar(raw);\n }\n return out;\n}\n\nfunction unquoteScalar(raw: string): string {\n if (raw.startsWith('\"') && raw.endsWith('\"') && raw.length >= 2) {\n try {\n const parsed = JSON.parse(raw) as unknown;\n if (typeof parsed === \"string\") return parsed;\n } catch {\n // fall through to the literal slice below\n }\n return raw.slice(1, -1);\n }\n if (raw.startsWith(\"'\") && raw.endsWith(\"'\") && raw.length >= 2) {\n return raw.slice(1, -1);\n }\n return raw;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoBO,IAAM,sBAAsB;AAC5B,IAAM,oBAAoB;AAC1B,IAAM,mB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AAI,WAAW,EAAG;AAC1C,QAAI,GAAG,IAAI,cAAc,GAAG;AAAA,EAC9B;AACA,SAAO;AACT;AAEA,SAAS,cAAc,KAAqB;AAC1C,MAAI,IAAI,WAAW,GAAG,KAAK,IAAI,SAAS,GAAG,KAAK,IAAI,UAAU,GAAG;AAC/D,QAAI;AACF,YAAM,SAAS,KAAK,MAAM,GAAG;AAC7B,UAAI,OAAO,WAAW,SAAU,QAAO;AAAA,IACzC,QAAQ;AAAA,IAER;AACA,WAAO,IAAI,MAAM,GAAG,EAAE;AAAA,EACxB;AACA,MAAI,IAAI,WAAW,GAAG,KAAK,IAAI,SAAS,GAAG,KAAK,IAAI,UAAU,GAAG;AAC/D,WAAO,IAAI,MAAM,GAAG,EAAE;AAAA,EACxB;AACA,SAAO;AACT;","names":[]}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
WHO_KNOWS_DEFAULT_LIMIT,
|
|
3
3
|
WHO_KNOWS_MAX_LIMIT,
|
|
4
4
|
validateWhoKnowsInput
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-KFIOPZ25.js";
|
|
6
6
|
|
|
7
7
|
// src/who-knows-cli.ts
|
|
8
8
|
function extractWhoKnowsRawArgs(rest) {
|
|
@@ -74,4 +74,4 @@ export {
|
|
|
74
74
|
renderWhoKnowsText,
|
|
75
75
|
renderWhoKnows
|
|
76
76
|
};
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
77
|
+
//# sourceMappingURL=chunk-2IXQSGCU.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveCorpusNamespaceRoots
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WDXD6ITO.js";
|
|
4
4
|
import {
|
|
5
5
|
capabilityAllowsNamespace
|
|
6
6
|
} from "./chunk-MZWSOLMT.js";
|
|
@@ -200,4 +200,4 @@ async function readAggregateExtractionWatermark(options) {
|
|
|
200
200
|
export {
|
|
201
201
|
readAggregateExtractionWatermark
|
|
202
202
|
};
|
|
203
|
-
//# sourceMappingURL=chunk-
|
|
203
|
+
//# sourceMappingURL=chunk-2MVTAIL3.js.map
|