nlm-memory 0.20.0 → 0.21.0
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/README.md +19 -10
- package/dist/cli/digest.js +60 -1
- package/dist/cli/digest.js.map +1 -1
- package/dist/cli/init.d.ts +12 -0
- package/dist/cli/init.js +49 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/nlm.d.ts +13 -1
- package/dist/cli/nlm.js +872 -61
- package/dist/cli/nlm.js.map +1 -1
- package/dist/cli/scope-backfill.d.ts +34 -0
- package/dist/cli/scope-backfill.js +237 -0
- package/dist/cli/scope-backfill.js.map +1 -0
- package/dist/cli/scope-coverage.d.ts +44 -0
- package/dist/cli/scope-coverage.js +205 -0
- package/dist/cli/scope-coverage.js.map +1 -0
- package/dist/core/actions/overlay.d.ts +20 -6
- package/dist/core/actions/overlay.js +32 -18
- package/dist/core/actions/overlay.js.map +1 -1
- package/dist/core/adapters/claude-code.d.ts +14 -0
- package/dist/core/adapters/claude-code.js +36 -0
- package/dist/core/adapters/claude-code.js.map +1 -1
- package/dist/core/classifier/prompt.js +3 -3
- package/dist/core/dataset/build-dataset.js +1 -0
- package/dist/core/dataset/build-dataset.js.map +1 -1
- package/dist/core/digest/compose.d.ts +13 -3
- package/dist/core/digest/compose.js +23 -18
- package/dist/core/digest/compose.js.map +1 -1
- package/dist/core/digest/hook-injection.d.ts +43 -0
- package/dist/core/digest/hook-injection.js +79 -0
- package/dist/core/digest/hook-injection.js.map +1 -0
- package/dist/core/embedding/embed-backfill.d.ts +13 -2
- package/dist/core/embedding/embed-backfill.js +181 -43
- package/dist/core/embedding/embed-backfill.js.map +1 -1
- package/dist/core/embedding/embedding-config.d.ts +17 -0
- package/dist/core/embedding/embedding-config.js +12 -0
- package/dist/core/embedding/embedding-config.js.map +1 -0
- package/dist/core/embedding/pg-embed-backfill.d.ts +31 -0
- package/dist/core/embedding/pg-embed-backfill.js +264 -0
- package/dist/core/embedding/pg-embed-backfill.js.map +1 -0
- package/dist/core/entities/dedup-suggest.d.ts +25 -0
- package/dist/core/entities/dedup-suggest.js +107 -0
- package/dist/core/entities/dedup-suggest.js.map +1 -0
- package/dist/core/eval/classifier-fixture-eval.d.ts +29 -0
- package/dist/core/eval/classifier-fixture-eval.js +217 -0
- package/dist/core/eval/classifier-fixture-eval.js.map +1 -0
- package/dist/core/eval/extraction-scoring.d.ts +63 -0
- package/dist/core/eval/extraction-scoring.js +79 -0
- package/dist/core/eval/extraction-scoring.js.map +1 -0
- package/dist/core/eval/run-eval.d.ts +40 -0
- package/dist/core/eval/run-eval.js +34 -0
- package/dist/core/eval/run-eval.js.map +1 -0
- package/dist/core/exemplars/capture-from-session.d.ts +2 -0
- package/dist/core/exemplars/capture-from-session.js +7 -3
- package/dist/core/exemplars/capture-from-session.js.map +1 -1
- package/dist/core/exemplars/diff-parse.d.ts +23 -0
- package/dist/core/exemplars/diff-parse.js +73 -0
- package/dist/core/exemplars/diff-parse.js.map +1 -0
- package/dist/core/exemplars/embed-backfill.d.ts +36 -0
- package/dist/core/exemplars/embed-backfill.js +85 -0
- package/dist/core/exemplars/embed-backfill.js.map +1 -0
- package/dist/core/exemplars/embed-text.d.ts +15 -0
- package/dist/core/exemplars/embed-text.js +18 -0
- package/dist/core/exemplars/embed-text.js.map +1 -0
- package/dist/core/exemplars/extract-exemplar.d.ts +2 -0
- package/dist/core/exemplars/extract-exemplar.js +9 -66
- package/dist/core/exemplars/extract-exemplar.js.map +1 -1
- package/dist/core/exemplars/ingest-exemplar.d.ts +1 -0
- package/dist/core/exemplars/ingest-exemplar.js +1 -0
- package/dist/core/exemplars/ingest-exemplar.js.map +1 -1
- package/dist/core/exemplars/recall-code.js +4 -0
- package/dist/core/exemplars/recall-code.js.map +1 -1
- package/dist/core/exemplars/warm-embedder.d.ts +14 -0
- package/dist/core/exemplars/warm-embedder.js +18 -0
- package/dist/core/exemplars/warm-embedder.js.map +1 -0
- package/dist/core/health/corpus-state.d.ts +8 -0
- package/dist/core/health/corpus-state.js +11 -0
- package/dist/core/health/corpus-state.js.map +1 -0
- package/dist/core/health/embed-inflight.d.ts +9 -0
- package/dist/core/health/embed-inflight.js +30 -0
- package/dist/core/health/embed-inflight.js.map +1 -0
- package/dist/core/health/embedding-lane-state.d.ts +6 -0
- package/dist/core/health/embedding-lane-state.js +18 -0
- package/dist/core/health/embedding-lane-state.js.map +1 -0
- package/dist/core/health/warmup-state.d.ts +12 -0
- package/dist/core/health/warmup-state.js +12 -0
- package/dist/core/health/warmup-state.js.map +1 -0
- package/dist/core/hook/claude-settings.d.ts +1 -1
- package/dist/core/hook/claude-settings.js +0 -1
- package/dist/core/hook/claude-settings.js.map +1 -1
- package/dist/core/hook/gate.d.ts +13 -6
- package/dist/core/hook/gate.js +47 -6
- package/dist/core/hook/gate.js.map +1 -1
- package/dist/core/hook/hook-log.d.ts +5 -0
- package/dist/core/hook/hook-log.js.map +1 -1
- package/dist/core/hook/memo.d.ts +12 -0
- package/dist/core/hook/memo.js +41 -1
- package/dist/core/hook/memo.js.map +1 -1
- package/dist/core/hook/pointer-block.d.ts +1 -0
- package/dist/core/hook/pointer-block.js +23 -2
- package/dist/core/hook/pointer-block.js.map +1 -1
- package/dist/core/hook/query-extract.d.ts +2 -1
- package/dist/core/hook/query-extract.js +10 -1
- package/dist/core/hook/query-extract.js.map +1 -1
- package/dist/core/hook/resolve-conversation-by-query.d.ts +28 -0
- package/dist/core/hook/resolve-conversation-by-query.js +98 -0
- package/dist/core/hook/resolve-conversation-by-query.js.map +1 -0
- package/dist/core/hook/select.d.ts +8 -0
- package/dist/core/hook/select.js +9 -2
- package/dist/core/hook/select.js.map +1 -1
- package/dist/core/hook/transcript.js +16 -2
- package/dist/core/hook/transcript.js.map +1 -1
- package/dist/core/ingest/backfill-derivables.d.ts +92 -0
- package/dist/core/ingest/backfill-derivables.js +175 -0
- package/dist/core/ingest/backfill-derivables.js.map +1 -0
- package/dist/core/ingest/ingest-session.d.ts +5 -0
- package/dist/core/ingest/ingest-session.js +23 -0
- package/dist/core/ingest/ingest-session.js.map +1 -1
- package/dist/core/ingest/reclassify-oversized.d.ts +5 -0
- package/dist/core/ingest/reclassify-oversized.js +9 -0
- package/dist/core/ingest/reclassify-oversized.js.map +1 -1
- package/dist/core/ingest/reprocess.d.ts +96 -0
- package/dist/core/ingest/reprocess.js +280 -0
- package/dist/core/ingest/reprocess.js.map +1 -0
- package/dist/core/ingest/transcript-derivables.d.ts +27 -0
- package/dist/core/ingest/transcript-derivables.js +138 -0
- package/dist/core/ingest/transcript-derivables.js.map +1 -0
- package/dist/core/integrity/check-invariants.d.ts +6 -1
- package/dist/core/integrity/check-invariants.js +209 -3
- package/dist/core/integrity/check-invariants.js.map +1 -1
- package/dist/core/metrics/corpus-stats.d.ts +49 -0
- package/dist/core/metrics/corpus-stats.js +111 -0
- package/dist/core/metrics/corpus-stats.js.map +1 -0
- package/dist/core/metrics/re-derivation.d.ts +48 -0
- package/dist/core/metrics/re-derivation.js +87 -0
- package/dist/core/metrics/re-derivation.js.map +1 -0
- package/dist/core/outcome/coverage.d.ts +33 -0
- package/dist/core/outcome/coverage.js +46 -0
- package/dist/core/outcome/coverage.js.map +1 -0
- package/dist/core/outcome/rollup.d.ts +33 -0
- package/dist/core/outcome/rollup.js +113 -0
- package/dist/core/outcome/rollup.js.map +1 -0
- package/dist/core/recall/citation-log.d.ts +8 -0
- package/dist/core/recall/citation-log.js +17 -0
- package/dist/core/recall/citation-log.js.map +1 -1
- package/dist/core/recall/hook-recall-log.d.ts +2 -2
- package/dist/core/recall/hook-recall-log.js +2 -2
- package/dist/core/recall/query-intent.d.ts +7 -0
- package/dist/core/recall/query-intent.js +25 -0
- package/dist/core/recall/query-intent.js.map +1 -0
- package/dist/core/recall/query-log.d.ts +4 -0
- package/dist/core/recall/query-log.js +4 -0
- package/dist/core/recall/query-log.js.map +1 -1
- package/dist/core/recall/recall-service.d.ts +37 -1
- package/dist/core/recall/recall-service.js +106 -63
- package/dist/core/recall/recall-service.js.map +1 -1
- package/dist/core/recall/related-exemplars.d.ts +1 -0
- package/dist/core/recall/related-exemplars.js +4 -1
- package/dist/core/recall/related-exemplars.js.map +1 -1
- package/dist/core/recall/related-facts.js +2 -2
- package/dist/core/recall/related-facts.js.map +1 -1
- package/dist/core/recall/reranker.d.ts +2 -1
- package/dist/core/recall/reranker.js +3 -3
- package/dist/core/recall/reranker.js.map +1 -1
- package/dist/core/recall-facts/fact-query-log.d.ts +7 -0
- package/dist/core/recall-facts/fact-query-log.js +2 -0
- package/dist/core/recall-facts/fact-query-log.js.map +1 -1
- package/dist/core/recall-facts/fact-recall-service.d.ts +9 -1
- package/dist/core/recall-facts/fact-recall-service.js +22 -8
- package/dist/core/recall-facts/fact-recall-service.js.map +1 -1
- package/dist/core/scheduler/scan-once.d.ts +6 -6
- package/dist/core/scheduler/scan-once.js +15 -49
- package/dist/core/scheduler/scan-once.js.map +1 -1
- package/dist/core/scheduler/scheduler.d.ts +10 -0
- package/dist/core/scheduler/scheduler.js +109 -13
- package/dist/core/scheduler/scheduler.js.map +1 -1
- package/dist/core/scope/alias-map.d.ts +10 -0
- package/dist/core/scope/alias-map.js +41 -0
- package/dist/core/scope/alias-map.js.map +1 -0
- package/dist/core/scope/derive-scope.d.ts +8 -0
- package/dist/core/scope/derive-scope.js +54 -0
- package/dist/core/scope/derive-scope.js.map +1 -0
- package/dist/core/scope/scope-clause.d.ts +16 -0
- package/dist/core/scope/scope-clause.js +21 -0
- package/dist/core/scope/scope-clause.js.map +1 -0
- package/dist/core/scope/stamp-flag.d.ts +1 -0
- package/dist/core/scope/stamp-flag.js +4 -0
- package/dist/core/scope/stamp-flag.js.map +1 -0
- package/dist/core/signals/code-signal.d.ts +50 -0
- package/dist/core/signals/code-signal.js +54 -0
- package/dist/core/signals/code-signal.js.map +1 -0
- package/dist/core/signals/ingest-signal.d.ts +1 -1
- package/dist/core/signals/ingest-signal.js +3 -1
- package/dist/core/signals/ingest-signal.js.map +1 -1
- package/dist/core/signals/stamp-scope.d.ts +18 -0
- package/dist/core/signals/stamp-scope.js +28 -0
- package/dist/core/signals/stamp-scope.js.map +1 -0
- package/dist/core/storage/db-restore.js +3 -1
- package/dist/core/storage/db-restore.js.map +1 -1
- package/dist/core/storage/fact-batch.d.ts +9 -0
- package/dist/core/storage/fact-batch.js +14 -0
- package/dist/core/storage/fact-batch.js.map +1 -0
- package/dist/core/storage/pg-code-exemplar-store.d.ts +1 -0
- package/dist/core/storage/pg-code-exemplar-store.js +13 -2
- package/dist/core/storage/pg-code-exemplar-store.js.map +1 -1
- package/dist/core/storage/pg-embedding-config.d.ts +29 -0
- package/dist/core/storage/pg-embedding-config.js +53 -0
- package/dist/core/storage/pg-embedding-config.js.map +1 -0
- package/dist/core/storage/pg-entity-store.d.ts +12 -0
- package/dist/core/storage/pg-entity-store.js +79 -0
- package/dist/core/storage/pg-entity-store.js.map +1 -0
- package/dist/core/storage/pg-fact-ingest.d.ts +15 -0
- package/dist/core/storage/pg-fact-ingest.js +34 -0
- package/dist/core/storage/pg-fact-ingest.js.map +1 -0
- package/dist/core/storage/pg-fact-store.d.ts +3 -0
- package/dist/core/storage/pg-fact-store.js +26 -30
- package/dist/core/storage/pg-fact-store.js.map +1 -1
- package/dist/core/storage/pg-migrate.d.ts +18 -0
- package/dist/core/storage/pg-migrate.js +73 -0
- package/dist/core/storage/pg-migrate.js.map +1 -0
- package/dist/core/storage/pg-session-store.d.ts +11 -2
- package/dist/core/storage/pg-session-store.js +224 -96
- package/dist/core/storage/pg-session-store.js.map +1 -1
- package/dist/core/storage/pg-signal-store.js +4 -3
- package/dist/core/storage/pg-signal-store.js.map +1 -1
- package/dist/core/storage/pg-storage.d.ts +9 -7
- package/dist/core/storage/pg-storage.js +20 -50
- package/dist/core/storage/pg-storage.js.map +1 -1
- package/dist/core/storage/pg-workstream-store.d.ts +25 -0
- package/dist/core/storage/pg-workstream-store.js +97 -0
- package/dist/core/storage/pg-workstream-store.js.map +1 -0
- package/dist/core/storage/sqlite-code-exemplar-store.d.ts +1 -0
- package/dist/core/storage/sqlite-code-exemplar-store.js +15 -2
- package/dist/core/storage/sqlite-code-exemplar-store.js.map +1 -1
- package/dist/core/storage/sqlite-embedding-config.d.ts +10 -0
- package/dist/core/storage/sqlite-embedding-config.js +27 -0
- package/dist/core/storage/sqlite-embedding-config.js.map +1 -0
- package/dist/core/storage/sqlite-entity-store.d.ts +13 -0
- package/dist/core/storage/sqlite-entity-store.js +96 -0
- package/dist/core/storage/sqlite-entity-store.js.map +1 -0
- package/dist/core/storage/sqlite-fact-store.d.ts +15 -7
- package/dist/core/storage/sqlite-fact-store.js +81 -27
- package/dist/core/storage/sqlite-fact-store.js.map +1 -1
- package/dist/core/storage/sqlite-outcome-store.d.ts +89 -0
- package/dist/core/storage/sqlite-outcome-store.js +158 -0
- package/dist/core/storage/sqlite-outcome-store.js.map +1 -0
- package/dist/core/storage/sqlite-session-store.d.ts +42 -7
- package/dist/core/storage/sqlite-session-store.js +208 -95
- package/dist/core/storage/sqlite-session-store.js.map +1 -1
- package/dist/core/storage/sqlite-signal-store.js +4 -2
- package/dist/core/storage/sqlite-signal-store.js.map +1 -1
- package/dist/core/storage/sqlite-storage.d.ts +8 -8
- package/dist/core/storage/sqlite-storage.js +21 -32
- package/dist/core/storage/sqlite-storage.js.map +1 -1
- package/dist/core/storage/sqlite-workstream-store.d.ts +25 -0
- package/dist/core/storage/sqlite-workstream-store.js +99 -0
- package/dist/core/storage/sqlite-workstream-store.js.map +1 -0
- package/dist/core/storage/supersedence-log.js +2 -0
- package/dist/core/storage/supersedence-log.js.map +1 -1
- package/dist/core/telemetry/probe-filter.d.ts +35 -0
- package/dist/core/telemetry/probe-filter.js +56 -0
- package/dist/core/telemetry/probe-filter.js.map +1 -0
- package/dist/core/update-check/check.d.ts +6 -0
- package/dist/core/update-check/check.js +35 -0
- package/dist/core/update-check/check.js.map +1 -1
- package/dist/core/work-digest/active-spans.d.ts +8 -0
- package/dist/core/work-digest/active-spans.js +29 -0
- package/dist/core/work-digest/active-spans.js.map +1 -0
- package/dist/core/work-digest/attribute.d.ts +15 -0
- package/dist/core/work-digest/attribute.js +76 -0
- package/dist/core/work-digest/attribute.js.map +1 -0
- package/dist/core/work-digest/build-work-digest.d.ts +12 -0
- package/dist/core/work-digest/build-work-digest.js +69 -0
- package/dist/core/work-digest/build-work-digest.js.map +1 -0
- package/dist/core/work-digest/compose-work-digest.d.ts +3 -0
- package/dist/core/work-digest/compose-work-digest.js +52 -0
- package/dist/core/work-digest/compose-work-digest.js.map +1 -0
- package/dist/core/work-digest/merge-active.d.ts +10 -0
- package/dist/core/work-digest/merge-active.js +22 -0
- package/dist/core/work-digest/merge-active.js.map +1 -0
- package/dist/core/work-digest/read-transcript-timestamps.d.ts +7 -0
- package/dist/core/work-digest/read-transcript-timestamps.js +40 -0
- package/dist/core/work-digest/read-transcript-timestamps.js.map +1 -0
- package/dist/core/work-digest/topics.d.ts +18 -0
- package/dist/core/work-digest/topics.js +26 -0
- package/dist/core/work-digest/topics.js.map +1 -0
- package/dist/core/work-digest/types.d.ts +45 -0
- package/dist/core/work-digest/types.js +2 -0
- package/dist/core/work-digest/types.js.map +1 -0
- package/dist/core/workstream/bind.d.ts +26 -0
- package/dist/core/workstream/bind.js +42 -0
- package/dist/core/workstream/bind.js.map +1 -0
- package/dist/core/workstream/compose-recall.d.ts +2 -0
- package/dist/core/workstream/compose-recall.js +39 -0
- package/dist/core/workstream/compose-recall.js.map +1 -0
- package/dist/core/workstream/merge-suggest.d.ts +19 -0
- package/dist/core/workstream/merge-suggest.js +61 -0
- package/dist/core/workstream/merge-suggest.js.map +1 -0
- package/dist/core/workstream/model.d.ts +21 -0
- package/dist/core/workstream/model.js +9 -0
- package/dist/core/workstream/model.js.map +1 -0
- package/dist/core/workstream/name-match.d.ts +8 -0
- package/dist/core/workstream/name-match.js +18 -0
- package/dist/core/workstream/name-match.js.map +1 -0
- package/dist/core/workstream/resolve.d.ts +10 -0
- package/dist/core/workstream/resolve.js +21 -0
- package/dist/core/workstream/resolve.js.map +1 -0
- package/dist/core/workstream/rollup.d.ts +12 -0
- package/dist/core/workstream/rollup.js +17 -0
- package/dist/core/workstream/rollup.js.map +1 -0
- package/dist/core/workstream/work-topics.d.ts +10 -0
- package/dist/core/workstream/work-topics.js +55 -0
- package/dist/core/workstream/work-topics.js.map +1 -0
- package/dist/hook/hook-helpers.d.ts +4 -0
- package/dist/hook/hook-helpers.js +36 -0
- package/dist/hook/hook-helpers.js.map +1 -0
- package/dist/hook/pre-compact-hook.d.ts +23 -0
- package/dist/hook/pre-compact-hook.js +67 -0
- package/dist/hook/pre-compact-hook.js.map +1 -0
- package/dist/hook/prompt-recall-hook.d.ts +38 -0
- package/dist/hook/prompt-recall-hook.js +124 -20
- package/dist/hook/prompt-recall-hook.js.map +1 -1
- package/dist/hook/recall-gate.d.ts +29 -0
- package/dist/hook/recall-gate.js +50 -0
- package/dist/hook/recall-gate.js.map +1 -0
- package/dist/hook/recall-over-http.d.ts +3 -2
- package/dist/hook/recall-over-http.js +26 -13
- package/dist/hook/recall-over-http.js.map +1 -1
- package/dist/hook/recent-context.d.ts +25 -0
- package/dist/hook/recent-context.js +104 -0
- package/dist/hook/recent-context.js.map +1 -0
- package/dist/hook/score-floor.d.ts +27 -0
- package/dist/hook/score-floor.js +42 -0
- package/dist/hook/score-floor.js.map +1 -0
- package/dist/hook/session-end-hook.js +8 -29
- package/dist/hook/session-end-hook.js.map +1 -1
- package/dist/hook/session-start-hook.js +26 -60
- package/dist/hook/session-start-hook.js.map +1 -1
- package/dist/hook/stop-hook.js +24 -60
- package/dist/hook/stop-hook.js.map +1 -1
- package/dist/http/app.d.ts +6 -0
- package/dist/http/app.js +52 -44
- package/dist/http/app.js.map +1 -1
- package/dist/install/setup.js +2 -0
- package/dist/install/setup.js.map +1 -1
- package/dist/llm/build-classifier.d.ts +22 -0
- package/dist/llm/build-classifier.js +42 -0
- package/dist/llm/build-classifier.js.map +1 -0
- package/dist/llm/build-embedder.d.ts +11 -0
- package/dist/llm/build-embedder.js +42 -0
- package/dist/llm/build-embedder.js.map +1 -0
- package/dist/llm/bundled-embedder-client.d.ts +37 -0
- package/dist/llm/bundled-embedder-client.js +90 -0
- package/dist/llm/bundled-embedder-client.js.map +1 -0
- package/dist/llm/classifier-box.d.ts +13 -5
- package/dist/llm/classifier-box.js +28 -6
- package/dist/llm/classifier-box.js.map +1 -1
- package/dist/llm/classifier-egress.d.ts +18 -0
- package/dist/llm/classifier-egress.js +59 -0
- package/dist/llm/classifier-egress.js.map +1 -0
- package/dist/llm/client-shared.d.ts +4 -0
- package/dist/llm/client-shared.js +39 -0
- package/dist/llm/client-shared.js.map +1 -0
- package/dist/llm/deepseek-client.d.ts +20 -0
- package/dist/llm/deepseek-client.js +59 -45
- package/dist/llm/deepseek-client.js.map +1 -1
- package/dist/llm/embedder-info.d.ts +15 -0
- package/dist/llm/embedder-info.js +27 -0
- package/dist/llm/embedder-info.js.map +1 -0
- package/dist/llm/model-quirks.d.ts +4 -0
- package/dist/llm/model-quirks.js +7 -0
- package/dist/llm/model-quirks.js.map +1 -0
- package/dist/llm/naming.d.ts +5 -0
- package/dist/llm/naming.js +20 -0
- package/dist/llm/naming.js.map +1 -0
- package/dist/llm/ollama-client.d.ts +7 -8
- package/dist/llm/ollama-client.js +59 -51
- package/dist/llm/ollama-client.js.map +1 -1
- package/dist/llm/ollama-code-embedder.d.ts +8 -3
- package/dist/llm/ollama-code-embedder.js +14 -24
- package/dist/llm/ollama-code-embedder.js.map +1 -1
- package/dist/llm/openai-code-embedder-client.d.ts +25 -0
- package/dist/llm/openai-code-embedder-client.js +52 -0
- package/dist/llm/openai-code-embedder-client.js.map +1 -0
- package/dist/llm/openai-embedder-client.d.ts +41 -0
- package/dist/llm/openai-embedder-client.js +83 -0
- package/dist/llm/openai-embedder-client.js.map +1 -0
- package/dist/mcp/server.d.ts +69 -2
- package/dist/mcp/server.js +404 -19
- package/dist/mcp/server.js.map +1 -1
- package/dist/ports/code-embedder.d.ts +6 -1
- package/dist/ports/code-exemplar-store.d.ts +5 -0
- package/dist/ports/entity-store.d.ts +35 -0
- package/dist/ports/entity-store.js +7 -0
- package/dist/ports/entity-store.js.map +1 -0
- package/dist/ports/fact-store.d.ts +0 -0
- package/dist/ports/fact-store.js.map +1 -1
- package/dist/ports/llm-client.d.ts +9 -1
- package/dist/ports/outcome.d.ts +85 -0
- package/dist/ports/outcome.js +11 -0
- package/dist/ports/outcome.js.map +1 -0
- package/dist/ports/session-store.d.ts +12 -6
- package/dist/ports/storage.d.ts +7 -30
- package/dist/ports/storage.js +3 -7
- package/dist/ports/storage.js.map +1 -1
- package/dist/ports/transcript-adapter.d.ts +2 -0
- package/dist/ports/workstream-store.d.ts +22 -0
- package/dist/ports/workstream-store.js +2 -0
- package/dist/ports/workstream-store.js.map +1 -0
- package/dist/shared/net.d.ts +3 -0
- package/dist/shared/net.js +4 -0
- package/dist/shared/net.js.map +1 -0
- package/dist/shared/types.d.ts +56 -2
- package/dist/shared/types.js +4 -1
- package/dist/shared/types.js.map +1 -1
- package/dist/ui/assets/{index-CMpQkbQy.js → index-CSaBtgXD.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/fixtures/classifier-gold/README.md +94 -0
- package/fixtures/classifier-gold/reference.json +318 -0
- package/fixtures/classifier-gold/transcripts/01-bug-fix-null-pointer-api.txt +75 -0
- package/fixtures/classifier-gold/transcripts/02-bug-fix-race-condition-queue.txt +77 -0
- package/fixtures/classifier-gold/transcripts/03-bug-fix-jwt-clock-skew.txt +86 -0
- package/fixtures/classifier-gold/transcripts/04-feature-webhook-retry.txt +95 -0
- package/fixtures/classifier-gold/transcripts/05-feature-csv-export.txt +86 -0
- package/fixtures/classifier-gold/transcripts/06-feature-rate-limiting.txt +61 -0
- package/fixtures/classifier-gold/transcripts/07-refactor-db-abstraction.txt +72 -0
- package/fixtures/classifier-gold/transcripts/08-refactor-config-loading.txt +89 -0
- package/fixtures/classifier-gold/transcripts/09-ops-docker-staging.txt +94 -0
- package/fixtures/classifier-gold/transcripts/10-ops-nginx-ssl.txt +121 -0
- package/fixtures/classifier-gold/transcripts/11-ops-postgres-migration.txt +74 -0
- package/fixtures/classifier-gold/transcripts/12-ops-cron-debugging.txt +73 -0
- package/fixtures/classifier-gold/transcripts/13-research-vector-db-comparison.txt +59 -0
- package/fixtures/classifier-gold/transcripts/14-research-oauth-provider.txt +74 -0
- package/fixtures/classifier-gold/transcripts/15-writing-api-docs.txt +154 -0
- package/fixtures/classifier-gold/transcripts/16-meeting-sprint-planning.txt +69 -0
- package/fixtures/classifier-gold/transcripts/17-trivial-list-files.txt +14 -0
- package/fixtures/classifier-gold/transcripts/18-trivial-version-check.txt +21 -0
- package/fixtures/classifier-gold/transcripts/19-trivial-syntax-help.txt +29 -0
- package/fixtures/classifier-gold/transcripts/20-trivial-read-package-json.txt +41 -0
- package/migrations/000_initial_schema.sql +1 -1
- package/migrations/024_backfill_exemplar_repo_basename.sql +32 -0
- package/migrations/025_workstreams.sql +30 -0
- package/migrations/026_embedding_config.sql +12 -0
- package/migrations/027_drop_legacy_session_embeddings.sql +7 -0
- package/migrations/028_classifier_provenance.sql +5 -0
- package/migrations/029_project_scope.sql +21 -0
- package/migrations/032_session_derivables.sql +11 -0
- package/migrations/pg/001_initial.sql +34 -0
- package/migrations/pg/019_split_replaces.sql +16 -7
- package/migrations/pg/025_workstreams.sql +34 -0
- package/migrations/pg/026_embedding_config.sql +12 -0
- package/migrations/pg/028_classifier_provenance.sql +5 -0
- package/migrations/pg/029_entity_variants.sql +9 -0
- package/migrations/pg/030_project_scope.sql +23 -0
- package/migrations/pg/031_widen_session_edges_kind.sql +11 -0
- package/migrations/pg/032_session_derivables.sql +17 -0
- package/nlm/index.js +405 -39
- package/package.json +12 -2
- package/plugin/.codex-plugin/plugin.json +2 -2
- package/plugin/scripts/prompt-recall-hook.mjs +413 -43
- package/plugin/scripts/session-start-hook.mjs +295 -61
- package/plugin/scripts/stop-hook.mjs +89 -66
- package/plugin-hermes-agent/__init__.py +2 -1
- package/templates/agent-contract/README.md +24 -0
- package/templates/agent-contract/claude-code.md +40 -0
- package/templates/agent-contract/generic.md +38 -0
- package/dist/core/embedding/embed-normalize.d.ts +0 -28
- package/dist/core/embedding/embed-normalize.js +0 -98
- package/dist/core/embedding/embed-normalize.js.map +0 -1
- package/dist/core/storage/pg-tx-context.d.ts +0 -52
- package/dist/core/storage/pg-tx-context.js +0 -149
- package/dist/core/storage/pg-tx-context.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-eval.js","sourceRoot":"","sources":["../../../src/core/eval/run-eval.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA4BH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,IAA0B,EAC1B,OAAiC,EACjC,IAAqC;IAErC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,MAAM,GAA0F,EAAE,CAAC;IACzG,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;QACjG,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACrC,MAAM,IAAI,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY;QAChF,IAAI,IAAI,KAAK,CAAC;YAAE,IAAI,EAAE,CAAC;QACvB,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;YAAE,IAAI,EAAE,CAAC;QACnC,IAAI,IAAI,IAAI,CAAC;YAAE,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;;YAC5B,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,WAAW,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IAC1E,CAAC;IACD,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;IAC9B,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,CAAC,EAAE,OAAO,CAAC,MAAM;QACjB,IAAI,EAAE,IAAI,GAAG,CAAC;QACd,IAAI,EAAE,IAAI,GAAG,CAAC;QACd,GAAG,EAAE,KAAK,GAAG,CAAC;QACd,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -22,6 +22,8 @@ export interface SessionExemplarContext {
|
|
|
22
22
|
readonly summary: string;
|
|
23
23
|
readonly decisions: ReadonlyArray<string>;
|
|
24
24
|
readonly installScope: string;
|
|
25
|
+
readonly model?: string;
|
|
26
|
+
readonly scope: string | null;
|
|
25
27
|
}
|
|
26
28
|
export declare function composeTaskContext(summary: string, decisions: ReadonlyArray<string>): string;
|
|
27
29
|
export declare function captureExemplarsFromSession(ctx: SessionExemplarContext): CodeExemplarInput[];
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
* (the scheduler) to insert + embed. Git failures yield fewer exemplars,
|
|
12
12
|
* never wrong ones.
|
|
13
13
|
*/
|
|
14
|
+
import { basename } from "node:path";
|
|
14
15
|
import { detectCommitShas } from "./detect-commits.js";
|
|
15
16
|
import { extractFromGitSha } from "./extract-exemplar.js";
|
|
17
|
+
import { composeEmbedText } from "./embed-text.js";
|
|
16
18
|
const TASK_CONTEXT_CAP = 280;
|
|
17
19
|
export function composeTaskContext(summary, decisions) {
|
|
18
20
|
const base = summary.trim();
|
|
@@ -27,16 +29,18 @@ export function captureExemplarsFromSession(ctx) {
|
|
|
27
29
|
const out = [];
|
|
28
30
|
for (const sha of detectCommitShas(ctx.text)) {
|
|
29
31
|
const exemplar = extractFromGitSha({
|
|
30
|
-
repo: ctx.projectDir,
|
|
32
|
+
repo: basename(ctx.projectDir),
|
|
33
|
+
repoPath: ctx.projectDir,
|
|
31
34
|
sha,
|
|
32
35
|
installScope: ctx.installScope,
|
|
33
36
|
outcome: "pass",
|
|
37
|
+
...(ctx.model ? { model: ctx.model } : {}),
|
|
34
38
|
sessionId: ctx.sessionId,
|
|
35
39
|
ts: ctx.startedAt,
|
|
36
40
|
taskContext,
|
|
37
41
|
});
|
|
38
42
|
if (exemplar)
|
|
39
|
-
out.push(exemplar);
|
|
43
|
+
out.push({ ...exemplar, scope: ctx.scope });
|
|
40
44
|
}
|
|
41
45
|
return out;
|
|
42
46
|
}
|
|
@@ -54,7 +58,7 @@ export async function drainSessionExemplars(ctx, deps) {
|
|
|
54
58
|
const embedder = deps.codeEmbedder;
|
|
55
59
|
const store = deps.exemplarStore;
|
|
56
60
|
void embedder
|
|
57
|
-
.embed(input.taskContext
|
|
61
|
+
.embed(composeEmbedText(input.taskContext, input.code), "document")
|
|
58
62
|
.then((r) => store.upsertEmbedding(id, r.vector))
|
|
59
63
|
.catch(() => { });
|
|
60
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture-from-session.js","sourceRoot":"","sources":["../../../src/core/exemplars/capture-from-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"capture-from-session.js","sourceRoot":"","sources":["../../../src/core/exemplars/capture-from-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAIrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,iBAAiB,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OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC/G,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified-diff parsing helpers shared by the exemplar extractor (path a) and
|
|
3
|
+
* the code-signal producer. Pure string functions — no I/O.
|
|
4
|
+
*/
|
|
5
|
+
export interface DiffHunk {
|
|
6
|
+
readonly file: string;
|
|
7
|
+
readonly hunkHeader: string;
|
|
8
|
+
readonly body: string;
|
|
9
|
+
}
|
|
10
|
+
/** Extract a git hunk header funcname: `@@ ... @@ funcname` */
|
|
11
|
+
export declare function parseFuncname(hunkHeader: string): string | null;
|
|
12
|
+
/** Detect likely language from file extension. */
|
|
13
|
+
export declare function detectLang(filePath: string): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Parse a unified diff into individual hunks. Returns (file, hunkHeader, body) triples.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseHunks(diff: string): DiffHunk[];
|
|
18
|
+
/**
|
|
19
|
+
* Extract the added/changed lines from a hunk body (strip context and removed lines).
|
|
20
|
+
*/
|
|
21
|
+
export declare function extractAddedLines(hunkBody: string): string;
|
|
22
|
+
/** Pick the hunk with the most non-blank added lines (most representative). */
|
|
23
|
+
export declare function selectLargestHunk(hunks: readonly DiffHunk[]): DiffHunk | null;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified-diff parsing helpers shared by the exemplar extractor (path a) and
|
|
3
|
+
* the code-signal producer. Pure string functions — no I/O.
|
|
4
|
+
*/
|
|
5
|
+
/** Extract a git hunk header funcname: `@@ ... @@ funcname` */
|
|
6
|
+
export function parseFuncname(hunkHeader) {
|
|
7
|
+
const m = hunkHeader.match(/@@ [^@]+ @@ (.+)/);
|
|
8
|
+
return m?.[1]?.trim() ?? null;
|
|
9
|
+
}
|
|
10
|
+
/** Detect likely language from file extension. */
|
|
11
|
+
export function detectLang(filePath) {
|
|
12
|
+
const ext = filePath.split(".").pop()?.toLowerCase() ?? "";
|
|
13
|
+
const map = {
|
|
14
|
+
ts: "ts", tsx: "ts", js: "js", jsx: "js", mjs: "js",
|
|
15
|
+
py: "py", go: "go", rb: "rb", rs: "rs", java: "java",
|
|
16
|
+
c: "c", cpp: "cpp", cs: "cs", swift: "swift", kt: "kt",
|
|
17
|
+
sh: "sh", bash: "sh", zsh: "sh",
|
|
18
|
+
};
|
|
19
|
+
return map[ext] ?? null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parse a unified diff into individual hunks. Returns (file, hunkHeader, body) triples.
|
|
23
|
+
*/
|
|
24
|
+
export function parseHunks(diff) {
|
|
25
|
+
const result = [];
|
|
26
|
+
let currentFile = "";
|
|
27
|
+
let currentHeader = "";
|
|
28
|
+
let bodyLines = [];
|
|
29
|
+
for (const line of diff.split("\n")) {
|
|
30
|
+
if (line.startsWith("+++ b/")) {
|
|
31
|
+
currentFile = line.slice(6);
|
|
32
|
+
}
|
|
33
|
+
else if (line.startsWith("@@ ")) {
|
|
34
|
+
if (currentHeader && bodyLines.length > 0) {
|
|
35
|
+
result.push({ file: currentFile, hunkHeader: currentHeader, body: bodyLines.join("\n") });
|
|
36
|
+
}
|
|
37
|
+
currentHeader = line;
|
|
38
|
+
bodyLines = [];
|
|
39
|
+
}
|
|
40
|
+
else if (currentHeader && (line.startsWith("+") || line.startsWith("-") || line.startsWith(" "))) {
|
|
41
|
+
bodyLines.push(line);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (currentHeader && bodyLines.length > 0) {
|
|
45
|
+
result.push({ file: currentFile, hunkHeader: currentHeader, body: bodyLines.join("\n") });
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Extract the added/changed lines from a hunk body (strip context and removed lines).
|
|
51
|
+
*/
|
|
52
|
+
export function extractAddedLines(hunkBody) {
|
|
53
|
+
return hunkBody
|
|
54
|
+
.split("\n")
|
|
55
|
+
.filter((l) => l.startsWith("+"))
|
|
56
|
+
.map((l) => l.slice(1))
|
|
57
|
+
.join("\n");
|
|
58
|
+
}
|
|
59
|
+
/** Pick the hunk with the most non-blank added lines (most representative). */
|
|
60
|
+
export function selectLargestHunk(hunks) {
|
|
61
|
+
let best;
|
|
62
|
+
let bestCount = 0;
|
|
63
|
+
for (const h of hunks) {
|
|
64
|
+
const added = extractAddedLines(h.body);
|
|
65
|
+
const count = added.split("\n").filter((l) => l.trim()).length;
|
|
66
|
+
if (count > bestCount) {
|
|
67
|
+
bestCount = count;
|
|
68
|
+
best = h;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return best ?? null;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=diff-parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-parse.js","sourceRoot":"","sources":["../../../src/core/exemplars/diff-parse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,+DAA+D;AAC/D,MAAM,UAAU,aAAa,CAAC,UAAkB;IAC9C,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC;AAChC,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAC3D,MAAM,GAAG,GAA2B;QAClC,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI;QACnD,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE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IAAI,IAAI,IAAI,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* exemplar embed-backfill — (re)embed code_exemplars rows that are missing a
|
|
3
|
+
* vector. The /api/signal capture path embeds exemplars fire-and-forget; a
|
|
4
|
+
* cold CodeRankEmbed model on first capture can drop the vector, leaving the
|
|
5
|
+
* exemplar permanently unretrievable (recall_code is vector-only). This is
|
|
6
|
+
* the repair: discover rows with no entry in code_exemplars_vec, embed
|
|
7
|
+
* taskContext + code via the CodeEmbedder, and upsert the vector.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors the session embed-backfill (reembedCorpus): same embed-text shape
|
|
10
|
+
* as the live capture path (composeEmbedText, role "document"), the store's
|
|
11
|
+
* existing upsertEmbedding, and a single retry on transient
|
|
12
|
+
* embedder failures. Idempotent — rows that already have a vector are skipped
|
|
13
|
+
* (discovery is by absence in the vec table, so a second run finds nothing).
|
|
14
|
+
*
|
|
15
|
+
* Layering: depends on the CodeExemplarStore port for the upsert and on a
|
|
16
|
+
* read-only better-sqlite3 handle for discovery (the store has no
|
|
17
|
+
* "list rows missing a vector" method and adding one to the port for a
|
|
18
|
+
* one-shot operational tool isn't worth it — same direct-SQLite call the
|
|
19
|
+
* session backfill makes).
|
|
20
|
+
*/
|
|
21
|
+
import type { CodeEmbedder } from "../../ports/code-embedder.js";
|
|
22
|
+
import type { CodeExemplarStore } from "../../ports/code-exemplar-store.js";
|
|
23
|
+
export interface ExemplarBackfillOptions {
|
|
24
|
+
readonly dbPath: string;
|
|
25
|
+
readonly embedder: CodeEmbedder;
|
|
26
|
+
readonly store: CodeExemplarStore;
|
|
27
|
+
readonly limit?: number;
|
|
28
|
+
readonly onProgress?: (i: number, total: number, id: string, status: string) => void;
|
|
29
|
+
}
|
|
30
|
+
export interface ExemplarBackfillReport {
|
|
31
|
+
readonly total: number;
|
|
32
|
+
readonly succeeded: number;
|
|
33
|
+
readonly failed: number;
|
|
34
|
+
readonly dbMissing: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare function backfillExemplarEmbeddings(opts: ExemplarBackfillOptions): Promise<ExemplarBackfillReport>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* exemplar embed-backfill — (re)embed code_exemplars rows that are missing a
|
|
3
|
+
* vector. The /api/signal capture path embeds exemplars fire-and-forget; a
|
|
4
|
+
* cold CodeRankEmbed model on first capture can drop the vector, leaving the
|
|
5
|
+
* exemplar permanently unretrievable (recall_code is vector-only). This is
|
|
6
|
+
* the repair: discover rows with no entry in code_exemplars_vec, embed
|
|
7
|
+
* taskContext + code via the CodeEmbedder, and upsert the vector.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors the session embed-backfill (reembedCorpus): same embed-text shape
|
|
10
|
+
* as the live capture path (composeEmbedText, role "document"), the store's
|
|
11
|
+
* existing upsertEmbedding, and a single retry on transient
|
|
12
|
+
* embedder failures. Idempotent — rows that already have a vector are skipped
|
|
13
|
+
* (discovery is by absence in the vec table, so a second run finds nothing).
|
|
14
|
+
*
|
|
15
|
+
* Layering: depends on the CodeExemplarStore port for the upsert and on a
|
|
16
|
+
* read-only better-sqlite3 handle for discovery (the store has no
|
|
17
|
+
* "list rows missing a vector" method and adding one to the port for a
|
|
18
|
+
* one-shot operational tool isn't worth it — same direct-SQLite call the
|
|
19
|
+
* session backfill makes).
|
|
20
|
+
*/
|
|
21
|
+
import { existsSync } from "node:fs";
|
|
22
|
+
import Database from "better-sqlite3";
|
|
23
|
+
import * as sqliteVec from "sqlite-vec";
|
|
24
|
+
import { LLMUnreachableError } from "../../ports/llm-client.js";
|
|
25
|
+
import { composeEmbedText } from "./embed-text.js";
|
|
26
|
+
export async function backfillExemplarEmbeddings(opts) {
|
|
27
|
+
if (!existsSync(opts.dbPath)) {
|
|
28
|
+
return { total: 0, succeeded: 0, failed: 0, dbMissing: true };
|
|
29
|
+
}
|
|
30
|
+
const db = new Database(opts.dbPath, { readonly: true });
|
|
31
|
+
sqliteVec.load(db);
|
|
32
|
+
let rows;
|
|
33
|
+
try {
|
|
34
|
+
const sql = "SELECT e.id, e.task_context, e.code FROM code_exemplars e " +
|
|
35
|
+
"WHERE e.id NOT IN (SELECT exemplar_id FROM code_exemplars_vec) " +
|
|
36
|
+
"ORDER BY e.created_at" +
|
|
37
|
+
(opts.limit ? ` LIMIT ${Math.trunc(opts.limit)}` : "");
|
|
38
|
+
rows = db.prepare(sql).all();
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
db.close();
|
|
42
|
+
}
|
|
43
|
+
const total = rows.length;
|
|
44
|
+
let succeeded = 0;
|
|
45
|
+
let failed = 0;
|
|
46
|
+
for (let i = 0; i < rows.length; i++) {
|
|
47
|
+
const row = rows[i];
|
|
48
|
+
const idx = i + 1;
|
|
49
|
+
const text = composeEmbedText(row.task_context, row.code);
|
|
50
|
+
let vector;
|
|
51
|
+
let lastErr;
|
|
52
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
53
|
+
try {
|
|
54
|
+
const out = await opts.embedder.embed(text, "document");
|
|
55
|
+
vector = out.vector;
|
|
56
|
+
lastErr = undefined;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
lastErr = e;
|
|
61
|
+
if (!(e instanceof LLMUnreachableError))
|
|
62
|
+
throw e;
|
|
63
|
+
if (attempt === 0)
|
|
64
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (vector === undefined) {
|
|
68
|
+
failed += 1;
|
|
69
|
+
opts.onProgress?.(idx, total, row.id, `FAIL (embedder): ${lastErr?.message ?? "unknown"}`);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
await opts.store.upsertEmbedding(row.id, vector);
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
failed += 1;
|
|
77
|
+
opts.onProgress?.(idx, total, row.id, `FAIL (db): ${e.message}`);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
succeeded += 1;
|
|
81
|
+
opts.onProgress?.(idx, total, row.id, "OK");
|
|
82
|
+
}
|
|
83
|
+
return { total, succeeded, failed, dbMissing: false };
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=embed-backfill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed-backfill.js","sourceRoot":"","sources":["../../../src/core/exemplars/embed-backfill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAGxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAuBnD,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,IAA6B;IAE7B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAChE,CAAC;IAED,MAAM,EAAE,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEnB,IAAI,IAAkB,CAAC;IACvB,IAAI,CAAC;QACH,MAAM,GAAG,GACP,4DAA4D;YAC5D,iEAAiE;YACjE,uBAAuB;YACvB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,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,CAAC;YAClE,CAAC;QACH,CAAC;QAED,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,CAAC,CAAC;YACZ,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,oBAAqB,OAAiB,EAAE,OAAO,IAAI,SAAS,EAAE,CAAC,CAAC;YACtG,SAAS;QACX,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACnD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,CAAC,CAAC;YACZ,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,cAAe,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;YAC5E,SAAS;QACX,CAAC;QAED,SAAS,IAAI,CAAC,CAAC;QACf,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The embed payload for a code exemplar is `taskContext + "\n" + code`. The
|
|
3
|
+
* code embedder (CodeRankEmbed) has a ~512-token context window; a real commit
|
|
4
|
+
* diff easily exceeds it, at which point Ollama returns HTTP 500 ("the input
|
|
5
|
+
* length exceeds the context length") and the vector is silently dropped —
|
|
6
|
+
* leaving the exemplar unretrievable (recall_code is vector-only).
|
|
7
|
+
*
|
|
8
|
+
* composeEmbedText is the single place both the live capture path and the
|
|
9
|
+
* backfill build that payload, capping it so the embed always fits. 2000 chars
|
|
10
|
+
* sits comfortably under the window even for token-dense code (empirically the
|
|
11
|
+
* window tolerates ~4000 chars; 2000 leaves margin for the model's prompt
|
|
12
|
+
* prefix and tokenizer variance).
|
|
13
|
+
*/
|
|
14
|
+
export declare const EMBED_TEXT_CAP = 2000;
|
|
15
|
+
export declare function composeEmbedText(taskContext: string, code: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The embed payload for a code exemplar is `taskContext + "\n" + code`. The
|
|
3
|
+
* code embedder (CodeRankEmbed) has a ~512-token context window; a real commit
|
|
4
|
+
* diff easily exceeds it, at which point Ollama returns HTTP 500 ("the input
|
|
5
|
+
* length exceeds the context length") and the vector is silently dropped —
|
|
6
|
+
* leaving the exemplar unretrievable (recall_code is vector-only).
|
|
7
|
+
*
|
|
8
|
+
* composeEmbedText is the single place both the live capture path and the
|
|
9
|
+
* backfill build that payload, capping it so the embed always fits. 2000 chars
|
|
10
|
+
* sits comfortably under the window even for token-dense code (empirically the
|
|
11
|
+
* window tolerates ~4000 chars; 2000 leaves margin for the model's prompt
|
|
12
|
+
* prefix and tokenizer variance).
|
|
13
|
+
*/
|
|
14
|
+
export const EMBED_TEXT_CAP = 2000;
|
|
15
|
+
export function composeEmbedText(taskContext, code) {
|
|
16
|
+
return (taskContext + "\n" + code).slice(0, EMBED_TEXT_CAP);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=embed-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed-text.js","sourceRoot":"","sources":["../../../src/core/exemplars/embed-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC;AAEnC,MAAM,UAAU,gBAAgB,CAAC,WAAmB,EAAE,IAAY;IAChE,OAAO,CAAC,WAAW,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -16,6 +16,7 @@ import type { Signal } from "../../shared/types.js";
|
|
|
16
16
|
export interface ExtractOptions {
|
|
17
17
|
readonly installScope: string;
|
|
18
18
|
readonly repoPath?: string;
|
|
19
|
+
readonly scope?: string | null;
|
|
19
20
|
}
|
|
20
21
|
export interface GitShaExtractParams {
|
|
21
22
|
readonly repo: string;
|
|
@@ -28,6 +29,7 @@ export interface GitShaExtractParams {
|
|
|
28
29
|
readonly ts?: string;
|
|
29
30
|
readonly repoPath?: string;
|
|
30
31
|
readonly taskContext?: string;
|
|
32
|
+
readonly scope?: string | null;
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
35
|
* Path (a): extract exemplar from a git commit's diff.
|
|
@@ -13,60 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { execFileSync } from "node:child_process";
|
|
15
15
|
import { codeHash, normalizeExemplar } from "./ingest-exemplar.js";
|
|
16
|
-
|
|
17
|
-
function parseFuncname(hunkHeader) {
|
|
18
|
-
const m = hunkHeader.match(/@@ [^@]+ @@ (.+)/);
|
|
19
|
-
return m?.[1]?.trim() ?? null;
|
|
20
|
-
}
|
|
21
|
-
/** Detect likely language from file extension. */
|
|
22
|
-
function detectLang(filePath) {
|
|
23
|
-
const ext = filePath.split(".").pop()?.toLowerCase() ?? "";
|
|
24
|
-
const map = {
|
|
25
|
-
ts: "ts", tsx: "ts", js: "js", jsx: "js", mjs: "js",
|
|
26
|
-
py: "py", go: "go", rb: "rb", rs: "rs", java: "java",
|
|
27
|
-
c: "c", cpp: "cpp", cs: "cs", swift: "swift", kt: "kt",
|
|
28
|
-
sh: "sh", bash: "sh", zsh: "sh",
|
|
29
|
-
};
|
|
30
|
-
return map[ext] ?? null;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Parse a unified diff into individual hunks. Returns (file, hunkHeader, body) triples.
|
|
34
|
-
*/
|
|
35
|
-
function parseHunks(diff) {
|
|
36
|
-
const result = [];
|
|
37
|
-
let currentFile = "";
|
|
38
|
-
let currentHeader = "";
|
|
39
|
-
let bodyLines = [];
|
|
40
|
-
for (const line of diff.split("\n")) {
|
|
41
|
-
if (line.startsWith("+++ b/")) {
|
|
42
|
-
currentFile = line.slice(6);
|
|
43
|
-
}
|
|
44
|
-
else if (line.startsWith("@@ ")) {
|
|
45
|
-
if (currentHeader && bodyLines.length > 0) {
|
|
46
|
-
result.push({ file: currentFile, hunkHeader: currentHeader, body: bodyLines.join("\n") });
|
|
47
|
-
}
|
|
48
|
-
currentHeader = line;
|
|
49
|
-
bodyLines = [];
|
|
50
|
-
}
|
|
51
|
-
else if (currentHeader && (line.startsWith("+") || line.startsWith("-") || line.startsWith(" "))) {
|
|
52
|
-
bodyLines.push(line);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (currentHeader && bodyLines.length > 0) {
|
|
56
|
-
result.push({ file: currentFile, hunkHeader: currentHeader, body: bodyLines.join("\n") });
|
|
57
|
-
}
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Extract the added/changed lines from a hunk body (strip context and removed lines).
|
|
62
|
-
*/
|
|
63
|
-
function extractAddedLines(hunkBody) {
|
|
64
|
-
return hunkBody
|
|
65
|
-
.split("\n")
|
|
66
|
-
.filter((l) => l.startsWith("+"))
|
|
67
|
-
.map((l) => l.slice(1))
|
|
68
|
-
.join("\n");
|
|
69
|
-
}
|
|
16
|
+
import { detectLang, extractAddedLines, parseFuncname, parseHunks, selectLargestHunk } from "./diff-parse.js";
|
|
70
17
|
/**
|
|
71
18
|
* Path (a): extract exemplar from a git commit's diff.
|
|
72
19
|
* Returns null if the git command fails or no valid hunks are found.
|
|
@@ -78,22 +25,13 @@ export function extractFromGitSha(params) {
|
|
|
78
25
|
diff = execFileSync("git", ["show", "--unified=3", "--diff-filter=AM", params.sha], { cwd: repoPath, encoding: "utf8", timeout: 10_000 });
|
|
79
26
|
}
|
|
80
27
|
catch {
|
|
28
|
+
// Git show failed - exemplar extraction from this commit skipped.
|
|
81
29
|
return null;
|
|
82
30
|
}
|
|
83
31
|
const hunks = parseHunks(diff);
|
|
84
32
|
if (hunks.length === 0)
|
|
85
33
|
return null;
|
|
86
|
-
|
|
87
|
-
let best;
|
|
88
|
-
let bestCount = 0;
|
|
89
|
-
for (const h of hunks) {
|
|
90
|
-
const added = extractAddedLines(h.body);
|
|
91
|
-
const count = added.split("\n").filter((l) => l.trim()).length;
|
|
92
|
-
if (count > bestCount) {
|
|
93
|
-
bestCount = count;
|
|
94
|
-
best = h;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
34
|
+
const best = selectLargestHunk(hunks);
|
|
97
35
|
if (!best)
|
|
98
36
|
return null;
|
|
99
37
|
const code = extractAddedLines(best.body);
|
|
@@ -113,10 +51,12 @@ export function extractFromGitSha(params) {
|
|
|
113
51
|
outcome: params.outcome,
|
|
114
52
|
gitSha: params.sha,
|
|
115
53
|
survived: null,
|
|
54
|
+
scope: params.scope ?? null,
|
|
116
55
|
...(params.ts ? { ts: params.ts } : {}),
|
|
117
56
|
});
|
|
118
57
|
}
|
|
119
58
|
catch {
|
|
59
|
+
// Normalization failed - exemplar from git hunk discarded.
|
|
120
60
|
return null;
|
|
121
61
|
}
|
|
122
62
|
}
|
|
@@ -148,10 +88,12 @@ export function extractFromDetail(signal, opts) {
|
|
|
148
88
|
outcome: signal.outcome,
|
|
149
89
|
gitSha: typeof detail["git_sha"] === "string" ? detail["git_sha"] : null,
|
|
150
90
|
survived: null,
|
|
91
|
+
scope: opts.scope ?? null,
|
|
151
92
|
ts: signal.ts,
|
|
152
93
|
});
|
|
153
94
|
}
|
|
154
95
|
catch {
|
|
96
|
+
// Normalization failed - exemplar from signal detail discarded.
|
|
155
97
|
return null;
|
|
156
98
|
}
|
|
157
99
|
}
|
|
@@ -176,11 +118,12 @@ export function extractExemplar(signal, opts) {
|
|
|
176
118
|
sessionId: signal.sessionId,
|
|
177
119
|
ts: signal.ts,
|
|
178
120
|
repoPath,
|
|
121
|
+
scope: signal.scope,
|
|
179
122
|
});
|
|
180
123
|
if (fromGit)
|
|
181
124
|
return fromGit;
|
|
182
125
|
}
|
|
183
126
|
// Path (b): producer-supplied code in detail.
|
|
184
|
-
return extractFromDetail(signal, opts);
|
|
127
|
+
return extractFromDetail(signal, { ...opts, scope: signal.scope });
|
|
185
128
|
}
|
|
186
129
|
//# sourceMappingURL=extract-exemplar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-exemplar.js","sourceRoot":"","sources":["../../../src/core/exemplars/extract-exemplar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"extract-exemplar.js","sourceRoot":"","sources":["../../../src/core/exemplars/extract-exemplar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAwB9G;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA2B;IAC3D,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC;IAChD,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,YAAY,CACjB,KAAK,EACL,CAAC,MAAM,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,CAAC,GAAG,CAAC,EACvD,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CACrD,CAAC;IACJ,CAAC;IAAC,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ome: string;
|
|
26
26
|
readonly gitSha?: string | null;
|
|
27
27
|
readonly survived?: 0 | 1 | null;
|
|
28
|
+
readonly scope?: string | null;
|
|
28
29
|
readonly ts?: string;
|
|
29
30
|
}
|
|
30
31
|
export declare function normalizeExemplar(raw: RawExemplarPayload, now?: () => string): CodeExemplarInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingest-exemplar.js","sourceRoot":"","sources":["../../../src/core/exemplars/ingest-exemplar.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;AAEpF,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,MAAM,UAAU,GAAG,IAAI;SACpB,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACvB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;SACpD,IAAI,CAAC,IAAI,CAAC;SACV,IAAI,EAAE,CAAC;IACV,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC;AAED,6CAA6C;AAC7C,SAAS,mBAAmB,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;QACnC,MAAM,C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G,CAC5F,CAAC;IACJ,CAAC;IACD,IAAI,UAAU,GAAG,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CACb,4BAA4B,UAAU,8BAA8B,SAAS,6BAA6B,CAC3G,CAAC;IACJ,CAAC;IAED,OAAO;QACL,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,QAAQ,EAAE,GAAG,CAAC,QAAQ,IAAI,IAAI;QAC9B,SAAS,EAAE,GAAG,CAAC,SAAS,IAAI,IAAI;QAChC,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,SAAS;QAC7B,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,IAAI;QACtB,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;QAC5B,OAAO,EAAE,OAA8B;QACvC,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,IAAI;QAC1B,QAAQ,EAAE,GAAG,CAAC,QAAQ,IAAI,IAAI;QAC9B,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,IAAI;QACxB,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -6,11 +6,15 @@
|
|
|
6
6
|
* Negatives are returned clearly labeled — "code that failed the gate" is
|
|
7
7
|
* as useful to the caller as the positive.
|
|
8
8
|
*/
|
|
9
|
+
import { laneHealth } from "../health/embedding-lane-state.js";
|
|
9
10
|
/**
|
|
10
11
|
* Recall code exemplars. Returns positives (pass/fix) and negatives (fail/exhausted)
|
|
11
12
|
* as separate lists so the caller can surface them with distinct framing.
|
|
12
13
|
*/
|
|
13
14
|
export async function recallCode(opts, store, codeEmbedder, proseFallback) {
|
|
15
|
+
if (laneHealth("code") === "stale") {
|
|
16
|
+
return { positives: [], negatives: [] };
|
|
17
|
+
}
|
|
14
18
|
let queryVector = null;
|
|
15
19
|
if (codeEmbedder) {
|
|
16
20
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recall-code.js","sourceRoot":"","sources":["../../../src/core/exemplars/recall-code.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"recall-code.js","sourceRoot":"","sources":["../../../src/core/exemplars/recall-code.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAYlE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAAuB,EACvB,KAAwB,EACxB,YAAiC,EACjC,aAA+B;IAE/B,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,OAAO,EAAE,CAAC;QACnC,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IAC1C,CAAC;IAED,IAAI,WAAW,GAAwB,IAAI,CAAC;IAE5C,IAAI,YAAY,EAAE,CAAC;QACjB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC7D,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;QAC9B,CAAC;QAAC,MAAM,CAAC;YACP,2CAA2C;QAC7C,CAAC;IACH,CAAC;IAED,IAAI,CAAC,WAAW,IAAI,aAAa,EAAE,CAAC;QAClC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC9D,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;QAC9B,CAAC;QAAC,MAAM,CAAC;YACP,wBAAwB;QAC1B,CAAC;IACH,CAAC;IAED,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IAC1C,CAAC;IAED,MAAM,MAAM,GAA6B;QACvC,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;QACnD,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;QACnD,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QACtD,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,IAAI,IAAI;QAC/C,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;KACf,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,cAAc,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAE7D,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,MAAM,IAAI,CAAC,CAAC,OAAO,KAAK,KAAK,CAAC,CAAC;IAClF,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,MAAM,IAAI,CAAC,CAAC,OAAO,KAAK,WAAW,CAAC,CAAC;IAExF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* warm-on-start for the code embedder.
|
|
3
|
+
*
|
|
4
|
+
* recall_code is vector-only and the capture path embeds fire-and-forget, so
|
|
5
|
+
* the very first real capture against a cold CodeRankEmbed model can time out
|
|
6
|
+
* and silently drop the vector. Warming the model once at daemon boot pays
|
|
7
|
+
* that load cost up front, off the request path.
|
|
8
|
+
*
|
|
9
|
+
* Gated on NLM_CODE_EXEMPLARS_ENABLED=1 (the same flag that gates capture).
|
|
10
|
+
* Best-effort and non-blocking: the embed is a throwaway, and any failure is
|
|
11
|
+
* swallowed — a cold embedder must never block or crash daemon startup.
|
|
12
|
+
*/
|
|
13
|
+
import type { CodeEmbedder } from "../../ports/code-embedder.js";
|
|
14
|
+
export declare function warmCodeEmbedder(embedder: CodeEmbedder): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* warm-on-start for the code embedder.
|
|
3
|
+
*
|
|
4
|
+
* recall_code is vector-only and the capture path embeds fire-and-forget, so
|
|
5
|
+
* the very first real capture against a cold CodeRankEmbed model can time out
|
|
6
|
+
* and silently drop the vector. Warming the model once at daemon boot pays
|
|
7
|
+
* that load cost up front, off the request path.
|
|
8
|
+
*
|
|
9
|
+
* Gated on NLM_CODE_EXEMPLARS_ENABLED=1 (the same flag that gates capture).
|
|
10
|
+
* Best-effort and non-blocking: the embed is a throwaway, and any failure is
|
|
11
|
+
* swallowed — a cold embedder must never block or crash daemon startup.
|
|
12
|
+
*/
|
|
13
|
+
export function warmCodeEmbedder(embedder) {
|
|
14
|
+
if (process.env["NLM_CODE_EXEMPLARS_ENABLED"] !== "1")
|
|
15
|
+
return;
|
|
16
|
+
void embedder.embed("warm", "query").catch(() => { });
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=warm-embedder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warm-embedder.js","sourceRoot":"","sources":["../../../src/core/exemplars/warm-embedder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,MAAM,UAAU,gBAAgB,CAAC,QAAsB;IACrD,IAAI,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,KAAK,GAAG;QAAE,OAAO;IAC9D,KAAK,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAA0C,CAAC,CAAC,CAAC;AAC/F,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CorpusStats } from "../metrics/corpus-stats.js";
|
|
2
|
+
export interface CorpusSnapshot extends CorpusStats {
|
|
3
|
+
readonly state: "ok" | "warn" | "alert";
|
|
4
|
+
readonly lastComputedAt: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function setCorpusSnapshot(s: CorpusSnapshot): void;
|
|
7
|
+
export declare function corpusSnapshot(): CorpusSnapshot | null;
|
|
8
|
+
export declare function resetForTests(): void;
|