onadit 0.0.1 → 0.1.0-beta.45
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.dev.md +124 -0
- package/README.md +194 -2
- package/dist/src/auth/keychain.d.ts +42 -0
- package/dist/src/auth/keychain.d.ts.map +1 -0
- package/dist/src/auth/keychain.js +177 -0
- package/dist/src/auth/keychain.js.map +1 -0
- package/dist/src/auth/middleware.d.ts +21 -0
- package/dist/src/auth/middleware.d.ts.map +1 -0
- package/dist/src/auth/middleware.js +93 -0
- package/dist/src/auth/middleware.js.map +1 -0
- package/dist/src/auth/rate-limit.d.ts +16 -0
- package/dist/src/auth/rate-limit.d.ts.map +1 -0
- package/dist/src/auth/rate-limit.js +38 -0
- package/dist/src/auth/rate-limit.js.map +1 -0
- package/dist/src/auth/rotation.d.ts +67 -0
- package/dist/src/auth/rotation.d.ts.map +1 -0
- package/dist/src/auth/rotation.js +190 -0
- package/dist/src/auth/rotation.js.map +1 -0
- package/dist/src/backfill/project-context-batch-constructor.d.ts +127 -0
- package/dist/src/backfill/project-context-batch-constructor.d.ts.map +1 -0
- package/dist/src/backfill/project-context-batch-constructor.js +210 -0
- package/dist/src/backfill/project-context-batch-constructor.js.map +1 -0
- package/dist/src/capture/assistant-text-lookup.d.ts +31 -0
- package/dist/src/capture/assistant-text-lookup.d.ts.map +1 -0
- package/dist/src/capture/assistant-text-lookup.js +222 -0
- package/dist/src/capture/assistant-text-lookup.js.map +1 -0
- package/dist/src/capture/auto-capture.d.ts +322 -0
- package/dist/src/capture/auto-capture.d.ts.map +1 -0
- package/dist/src/capture/auto-capture.js +1167 -0
- package/dist/src/capture/auto-capture.js.map +1 -0
- package/dist/src/capture/auto-repair.d.ts +125 -0
- package/dist/src/capture/auto-repair.d.ts.map +1 -0
- package/dist/src/capture/auto-repair.js +280 -0
- package/dist/src/capture/auto-repair.js.map +1 -0
- package/dist/src/capture/batch-budget.d.ts +90 -0
- package/dist/src/capture/batch-budget.d.ts.map +1 -0
- package/dist/src/capture/batch-budget.js +148 -0
- package/dist/src/capture/batch-budget.js.map +1 -0
- package/dist/src/capture/claude-cli-triage-provider.d.ts +28 -0
- package/dist/src/capture/claude-cli-triage-provider.d.ts.map +1 -0
- package/dist/src/capture/claude-cli-triage-provider.js +101 -0
- package/dist/src/capture/claude-cli-triage-provider.js.map +1 -0
- package/dist/src/capture/codex-cli-triage-provider.d.ts +17 -0
- package/dist/src/capture/codex-cli-triage-provider.d.ts.map +1 -0
- package/dist/src/capture/codex-cli-triage-provider.js +91 -0
- package/dist/src/capture/codex-cli-triage-provider.js.map +1 -0
- package/dist/src/capture/cursor-capture.d.ts +89 -0
- package/dist/src/capture/cursor-capture.d.ts.map +1 -0
- package/dist/src/capture/cursor-capture.js +121 -0
- package/dist/src/capture/cursor-capture.js.map +1 -0
- package/dist/src/capture/observability.d.ts +131 -0
- package/dist/src/capture/observability.d.ts.map +1 -0
- package/dist/src/capture/observability.js +181 -0
- package/dist/src/capture/observability.js.map +1 -0
- package/dist/src/capture/openai-triage-provider.d.ts +92 -0
- package/dist/src/capture/openai-triage-provider.d.ts.map +1 -0
- package/dist/src/capture/openai-triage-provider.js +267 -0
- package/dist/src/capture/openai-triage-provider.js.map +1 -0
- package/dist/src/capture/recover-quarantine.d.ts +273 -0
- package/dist/src/capture/recover-quarantine.d.ts.map +1 -0
- package/dist/src/capture/recover-quarantine.js +581 -0
- package/dist/src/capture/recover-quarantine.js.map +1 -0
- package/dist/src/capture/review-queue-index.d.ts +51 -0
- package/dist/src/capture/review-queue-index.d.ts.map +1 -0
- package/dist/src/capture/review-queue-index.js +204 -0
- package/dist/src/capture/review-queue-index.js.map +1 -0
- package/dist/src/capture/review-queue.d.ts +47 -0
- package/dist/src/capture/review-queue.d.ts.map +1 -0
- package/dist/src/capture/review-queue.js +116 -0
- package/dist/src/capture/review-queue.js.map +1 -0
- package/dist/src/capture/sources.d.ts +53 -0
- package/dist/src/capture/sources.d.ts.map +1 -0
- package/dist/src/capture/sources.js +55 -0
- package/dist/src/capture/sources.js.map +1 -0
- package/dist/src/capture/stored-statements.d.ts +9 -0
- package/dist/src/capture/stored-statements.d.ts.map +1 -0
- package/dist/src/capture/stored-statements.js +63 -0
- package/dist/src/capture/stored-statements.js.map +1 -0
- package/dist/src/capture/triage-classification.d.ts +92 -0
- package/dist/src/capture/triage-classification.d.ts.map +1 -0
- package/dist/src/capture/triage-classification.js +94 -0
- package/dist/src/capture/triage-classification.js.map +1 -0
- package/dist/src/capture/triage-lane.d.ts +39 -0
- package/dist/src/capture/triage-lane.d.ts.map +1 -0
- package/dist/src/capture/triage-lane.js +217 -0
- package/dist/src/capture/triage-lane.js.map +1 -0
- package/dist/src/capture/triage-provider-factory.d.ts +36 -0
- package/dist/src/capture/triage-provider-factory.d.ts.map +1 -0
- package/dist/src/capture/triage-provider-factory.js +55 -0
- package/dist/src/capture/triage-provider-factory.js.map +1 -0
- package/dist/src/capture/triage-provider.d.ts +82 -0
- package/dist/src/capture/triage-provider.d.ts.map +1 -0
- package/dist/src/capture/triage-provider.js +126 -0
- package/dist/src/capture/triage-provider.js.map +1 -0
- package/dist/src/capture/triage.d.ts +30 -0
- package/dist/src/capture/triage.d.ts.map +1 -0
- package/dist/src/capture/triage.js +50 -0
- package/dist/src/capture/triage.js.map +1 -0
- package/dist/src/capture/user-statements-recheck.d.ts +22 -0
- package/dist/src/capture/user-statements-recheck.d.ts.map +1 -0
- package/dist/src/capture/user-statements-recheck.js +181 -0
- package/dist/src/capture/user-statements-recheck.js.map +1 -0
- package/dist/src/capture/user-statements.d.ts +84 -0
- package/dist/src/capture/user-statements.d.ts.map +1 -0
- package/dist/src/capture/user-statements.js +617 -0
- package/dist/src/capture/user-statements.js.map +1 -0
- package/dist/src/cli/agent-homes.d.ts +15 -0
- package/dist/src/cli/agent-homes.d.ts.map +1 -0
- package/dist/src/cli/agent-homes.js +45 -0
- package/dist/src/cli/agent-homes.js.map +1 -0
- package/dist/src/cli/commands/backfill.d.ts +3 -0
- package/dist/src/cli/commands/backfill.d.ts.map +1 -0
- package/dist/src/cli/commands/backfill.js +1379 -0
- package/dist/src/cli/commands/backfill.js.map +1 -0
- package/dist/src/cli/commands/brief.d.ts +12 -0
- package/dist/src/cli/commands/brief.d.ts.map +1 -0
- package/dist/src/cli/commands/brief.js +131 -0
- package/dist/src/cli/commands/brief.js.map +1 -0
- package/dist/src/cli/commands/bulk-ingest.d.ts +3 -0
- package/dist/src/cli/commands/bulk-ingest.d.ts.map +1 -0
- package/dist/src/cli/commands/bulk-ingest.js +126 -0
- package/dist/src/cli/commands/bulk-ingest.js.map +1 -0
- package/dist/src/cli/commands/capture-recover.d.ts +40 -0
- package/dist/src/cli/commands/capture-recover.d.ts.map +1 -0
- package/dist/src/cli/commands/capture-recover.js +194 -0
- package/dist/src/cli/commands/capture-recover.js.map +1 -0
- package/dist/src/cli/commands/capture.d.ts +12 -0
- package/dist/src/cli/commands/capture.d.ts.map +1 -0
- package/dist/src/cli/commands/capture.js +304 -0
- package/dist/src/cli/commands/capture.js.map +1 -0
- package/dist/src/cli/commands/chunk-backfill.d.ts +13 -0
- package/dist/src/cli/commands/chunk-backfill.d.ts.map +1 -0
- package/dist/src/cli/commands/chunk-backfill.js +157 -0
- package/dist/src/cli/commands/chunk-backfill.js.map +1 -0
- package/dist/src/cli/commands/compact.d.ts +3 -0
- package/dist/src/cli/commands/compact.d.ts.map +1 -0
- package/dist/src/cli/commands/compact.js +70 -0
- package/dist/src/cli/commands/compact.js.map +1 -0
- package/dist/src/cli/commands/cursor-probe.d.ts +20 -0
- package/dist/src/cli/commands/cursor-probe.d.ts.map +1 -0
- package/dist/src/cli/commands/cursor-probe.js +162 -0
- package/dist/src/cli/commands/cursor-probe.js.map +1 -0
- package/dist/src/cli/commands/doctor.d.ts +6 -0
- package/dist/src/cli/commands/doctor.d.ts.map +1 -0
- package/dist/src/cli/commands/doctor.js +259 -0
- package/dist/src/cli/commands/doctor.js.map +1 -0
- package/dist/src/cli/commands/feedback.d.ts +34 -0
- package/dist/src/cli/commands/feedback.d.ts.map +1 -0
- package/dist/src/cli/commands/feedback.js +214 -0
- package/dist/src/cli/commands/feedback.js.map +1 -0
- package/dist/src/cli/commands/hooks-install.d.ts +66 -0
- package/dist/src/cli/commands/hooks-install.d.ts.map +1 -0
- package/dist/src/cli/commands/hooks-install.js +228 -0
- package/dist/src/cli/commands/hooks-install.js.map +1 -0
- package/dist/src/cli/commands/import.d.ts +19 -0
- package/dist/src/cli/commands/import.d.ts.map +1 -0
- package/dist/src/cli/commands/import.js +258 -0
- package/dist/src/cli/commands/import.js.map +1 -0
- package/dist/src/cli/commands/ingest.d.ts +3 -0
- package/dist/src/cli/commands/ingest.d.ts.map +1 -0
- package/dist/src/cli/commands/ingest.js +80 -0
- package/dist/src/cli/commands/ingest.js.map +1 -0
- package/dist/src/cli/commands/mcp-install.d.ts +65 -0
- package/dist/src/cli/commands/mcp-install.d.ts.map +1 -0
- package/dist/src/cli/commands/mcp-install.js +306 -0
- package/dist/src/cli/commands/mcp-install.js.map +1 -0
- package/dist/src/cli/commands/menubar.d.ts +127 -0
- package/dist/src/cli/commands/menubar.d.ts.map +1 -0
- package/dist/src/cli/commands/menubar.js +585 -0
- package/dist/src/cli/commands/menubar.js.map +1 -0
- package/dist/src/cli/commands/onboard-first-run.d.ts +5 -0
- package/dist/src/cli/commands/onboard-first-run.d.ts.map +1 -0
- package/dist/src/cli/commands/onboard-first-run.js +156 -0
- package/dist/src/cli/commands/onboard-first-run.js.map +1 -0
- package/dist/src/cli/commands/onboard.d.ts +336 -0
- package/dist/src/cli/commands/onboard.d.ts.map +1 -0
- package/dist/src/cli/commands/onboard.js +1873 -0
- package/dist/src/cli/commands/onboard.js.map +1 -0
- package/dist/src/cli/commands/rebuild.d.ts +12 -0
- package/dist/src/cli/commands/rebuild.d.ts.map +1 -0
- package/dist/src/cli/commands/rebuild.js +167 -0
- package/dist/src/cli/commands/rebuild.js.map +1 -0
- package/dist/src/cli/commands/reconcile.d.ts +3 -0
- package/dist/src/cli/commands/reconcile.d.ts.map +1 -0
- package/dist/src/cli/commands/reconcile.js +68 -0
- package/dist/src/cli/commands/reconcile.js.map +1 -0
- package/dist/src/cli/commands/reindex.d.ts +3 -0
- package/dist/src/cli/commands/reindex.d.ts.map +1 -0
- package/dist/src/cli/commands/reindex.js +66 -0
- package/dist/src/cli/commands/reindex.js.map +1 -0
- package/dist/src/cli/commands/review.d.ts +13 -0
- package/dist/src/cli/commands/review.d.ts.map +1 -0
- package/dist/src/cli/commands/review.js +401 -0
- package/dist/src/cli/commands/review.js.map +1 -0
- package/dist/src/cli/commands/save.d.ts +3 -0
- package/dist/src/cli/commands/save.d.ts.map +1 -0
- package/dist/src/cli/commands/save.js +111 -0
- package/dist/src/cli/commands/save.js.map +1 -0
- package/dist/src/cli/commands/search.d.ts +37 -0
- package/dist/src/cli/commands/search.d.ts.map +1 -0
- package/dist/src/cli/commands/search.js +118 -0
- package/dist/src/cli/commands/search.js.map +1 -0
- package/dist/src/cli/commands/setup.d.ts +30 -0
- package/dist/src/cli/commands/setup.d.ts.map +1 -0
- package/dist/src/cli/commands/setup.js +122 -0
- package/dist/src/cli/commands/setup.js.map +1 -0
- package/dist/src/cli/commands/stats.d.ts +3 -0
- package/dist/src/cli/commands/stats.d.ts.map +1 -0
- package/dist/src/cli/commands/stats.js +42 -0
- package/dist/src/cli/commands/stats.js.map +1 -0
- package/dist/src/cli/commands/status.d.ts +17 -0
- package/dist/src/cli/commands/status.d.ts.map +1 -0
- package/dist/src/cli/commands/status.js +206 -0
- package/dist/src/cli/commands/status.js.map +1 -0
- package/dist/src/cli/commands/token-issue.d.ts +3 -0
- package/dist/src/cli/commands/token-issue.d.ts.map +1 -0
- package/dist/src/cli/commands/token-issue.js +33 -0
- package/dist/src/cli/commands/token-issue.js.map +1 -0
- package/dist/src/cli/commands/triage.d.ts +3 -0
- package/dist/src/cli/commands/triage.d.ts.map +1 -0
- package/dist/src/cli/commands/triage.js +127 -0
- package/dist/src/cli/commands/triage.js.map +1 -0
- package/dist/src/cli/commands/uninstall.d.ts +85 -0
- package/dist/src/cli/commands/uninstall.d.ts.map +1 -0
- package/dist/src/cli/commands/uninstall.js +512 -0
- package/dist/src/cli/commands/uninstall.js.map +1 -0
- package/dist/src/cli/commands/update.d.ts +105 -0
- package/dist/src/cli/commands/update.d.ts.map +1 -0
- package/dist/src/cli/commands/update.js +556 -0
- package/dist/src/cli/commands/update.js.map +1 -0
- package/dist/src/cli/default-config-path.d.ts +15 -0
- package/dist/src/cli/default-config-path.d.ts.map +1 -0
- package/dist/src/cli/default-config-path.js +28 -0
- package/dist/src/cli/default-config-path.js.map +1 -0
- package/dist/src/cli/feedback/feedback-config.d.ts +67 -0
- package/dist/src/cli/feedback/feedback-config.d.ts.map +1 -0
- package/dist/src/cli/feedback/feedback-config.js +169 -0
- package/dist/src/cli/feedback/feedback-config.js.map +1 -0
- package/dist/src/cli/feedback/feedback-history.d.ts +11 -0
- package/dist/src/cli/feedback/feedback-history.d.ts.map +1 -0
- package/dist/src/cli/feedback/feedback-history.js +145 -0
- package/dist/src/cli/feedback/feedback-history.js.map +1 -0
- package/dist/src/cli/feedback/feedback-payload.d.ts +74 -0
- package/dist/src/cli/feedback/feedback-payload.d.ts.map +1 -0
- package/dist/src/cli/feedback/feedback-payload.js +10 -0
- package/dist/src/cli/feedback/feedback-payload.js.map +1 -0
- package/dist/src/cli/feedback/feedback-relay.d.ts +15 -0
- package/dist/src/cli/feedback/feedback-relay.d.ts.map +1 -0
- package/dist/src/cli/feedback/feedback-relay.js +47 -0
- package/dist/src/cli/feedback/feedback-relay.js.map +1 -0
- package/dist/src/cli/feedback/feedback-status.d.ts +11 -0
- package/dist/src/cli/feedback/feedback-status.d.ts.map +1 -0
- package/dist/src/cli/feedback/feedback-status.js +122 -0
- package/dist/src/cli/feedback/feedback-status.js.map +1 -0
- package/dist/src/cli/feedback/invite.d.ts +17 -0
- package/dist/src/cli/feedback/invite.d.ts.map +1 -0
- package/dist/src/cli/feedback/invite.js +73 -0
- package/dist/src/cli/feedback/invite.js.map +1 -0
- package/dist/src/cli/feedback/relay-secret-store.d.ts +32 -0
- package/dist/src/cli/feedback/relay-secret-store.d.ts.map +1 -0
- package/dist/src/cli/feedback/relay-secret-store.js +137 -0
- package/dist/src/cli/feedback/relay-secret-store.js.map +1 -0
- package/dist/src/cli/hooks-writers/claude-code-policy-script.d.ts +35 -0
- package/dist/src/cli/hooks-writers/claude-code-policy-script.d.ts.map +1 -0
- package/dist/src/cli/hooks-writers/claude-code-policy-script.js +122 -0
- package/dist/src/cli/hooks-writers/claude-code-policy-script.js.map +1 -0
- package/dist/src/cli/hooks-writers/claude-code.d.ts +63 -0
- package/dist/src/cli/hooks-writers/claude-code.d.ts.map +1 -0
- package/dist/src/cli/hooks-writers/claude-code.js +289 -0
- package/dist/src/cli/hooks-writers/claude-code.js.map +1 -0
- package/dist/src/cli/hooks-writers/codex.d.ts +16 -0
- package/dist/src/cli/hooks-writers/codex.d.ts.map +1 -0
- package/dist/src/cli/hooks-writers/codex.js +17 -0
- package/dist/src/cli/hooks-writers/codex.js.map +1 -0
- package/dist/src/cli/hooks-writers/errors.d.ts +16 -0
- package/dist/src/cli/hooks-writers/errors.d.ts.map +1 -0
- package/dist/src/cli/hooks-writers/errors.js +24 -0
- package/dist/src/cli/hooks-writers/errors.js.map +1 -0
- package/dist/src/cli/hooks-writers/index.d.ts +23 -0
- package/dist/src/cli/hooks-writers/index.d.ts.map +1 -0
- package/dist/src/cli/hooks-writers/index.js +34 -0
- package/dist/src/cli/hooks-writers/index.js.map +1 -0
- package/dist/src/cli/hooks-writers/state.d.ts +43 -0
- package/dist/src/cli/hooks-writers/state.d.ts.map +1 -0
- package/dist/src/cli/hooks-writers/state.js +225 -0
- package/dist/src/cli/hooks-writers/state.js.map +1 -0
- package/dist/src/cli/hooks-writers/types.d.ts +28 -0
- package/dist/src/cli/hooks-writers/types.d.ts.map +1 -0
- package/dist/src/cli/hooks-writers/types.js +8 -0
- package/dist/src/cli/hooks-writers/types.js.map +1 -0
- package/dist/src/cli/http-client.d.ts +128 -0
- package/dist/src/cli/http-client.d.ts.map +1 -0
- package/dist/src/cli/http-client.js +401 -0
- package/dist/src/cli/http-client.js.map +1 -0
- package/dist/src/cli/index.d.ts +4 -0
- package/dist/src/cli/index.d.ts.map +1 -0
- package/dist/src/cli/index.js +99 -0
- package/dist/src/cli/index.js.map +1 -0
- package/dist/src/cli/job-poller.d.ts +13 -0
- package/dist/src/cli/job-poller.d.ts.map +1 -0
- package/dist/src/cli/job-poller.js +29 -0
- package/dist/src/cli/job-poller.js.map +1 -0
- package/dist/src/cli/mcp-config-writers/codex-toml.d.ts +20 -0
- package/dist/src/cli/mcp-config-writers/codex-toml.d.ts.map +1 -0
- package/dist/src/cli/mcp-config-writers/codex-toml.js +918 -0
- package/dist/src/cli/mcp-config-writers/codex-toml.js.map +1 -0
- package/dist/src/cli/mcp-config-writers/earlier-name-restrictions.d.ts +11 -0
- package/dist/src/cli/mcp-config-writers/earlier-name-restrictions.d.ts.map +1 -0
- package/dist/src/cli/mcp-config-writers/earlier-name-restrictions.js +152 -0
- package/dist/src/cli/mcp-config-writers/earlier-name-restrictions.js.map +1 -0
- package/dist/src/cli/mcp-config-writers/errors.d.ts +17 -0
- package/dist/src/cli/mcp-config-writers/errors.d.ts.map +1 -0
- package/dist/src/cli/mcp-config-writers/errors.js +13 -0
- package/dist/src/cli/mcp-config-writers/errors.js.map +1 -0
- package/dist/src/cli/mcp-config-writers/index.d.ts +28 -0
- package/dist/src/cli/mcp-config-writers/index.d.ts.map +1 -0
- package/dist/src/cli/mcp-config-writers/index.js +70 -0
- package/dist/src/cli/mcp-config-writers/index.js.map +1 -0
- package/dist/src/cli/mcp-config-writers/json-config.d.ts +20 -0
- package/dist/src/cli/mcp-config-writers/json-config.d.ts.map +1 -0
- package/dist/src/cli/mcp-config-writers/json-config.js +301 -0
- package/dist/src/cli/mcp-config-writers/json-config.js.map +1 -0
- package/dist/src/cli/mcp-config-writers/left-in-folder.d.ts +18 -0
- package/dist/src/cli/mcp-config-writers/left-in-folder.d.ts.map +1 -0
- package/dist/src/cli/mcp-config-writers/left-in-folder.js +140 -0
- package/dist/src/cli/mcp-config-writers/left-in-folder.js.map +1 -0
- package/dist/src/cli/mcp-config-writers/redact.d.ts +28 -0
- package/dist/src/cli/mcp-config-writers/redact.d.ts.map +1 -0
- package/dist/src/cli/mcp-config-writers/redact.js +48 -0
- package/dist/src/cli/mcp-config-writers/redact.js.map +1 -0
- package/dist/src/cli/mcp-config-writers/types.d.ts +46 -0
- package/dist/src/cli/mcp-config-writers/types.d.ts.map +1 -0
- package/dist/src/cli/mcp-config-writers/types.js +5 -0
- package/dist/src/cli/mcp-config-writers/types.js.map +1 -0
- package/dist/src/cli/output.d.ts +8 -0
- package/dist/src/cli/output.d.ts.map +1 -0
- package/dist/src/cli/output.js +34 -0
- package/dist/src/cli/output.js.map +1 -0
- package/dist/src/cli/postinstall-menubar.d.ts +38 -0
- package/dist/src/cli/postinstall-menubar.d.ts.map +1 -0
- package/dist/src/cli/postinstall-menubar.js +139 -0
- package/dist/src/cli/postinstall-menubar.js.map +1 -0
- package/dist/src/cli/status/friend-header.d.ts +61 -0
- package/dist/src/cli/status/friend-header.d.ts.map +1 -0
- package/dist/src/cli/status/friend-header.js +708 -0
- package/dist/src/cli/status/friend-header.js.map +1 -0
- package/dist/src/cli/status/local-signals.d.ts +89 -0
- package/dist/src/cli/status/local-signals.d.ts.map +1 -0
- package/dist/src/cli/status/local-signals.js +194 -0
- package/dist/src/cli/status/local-signals.js.map +1 -0
- package/dist/src/cli/token.d.ts +37 -0
- package/dist/src/cli/token.d.ts.map +1 -0
- package/dist/src/cli/token.js +105 -0
- package/dist/src/cli/token.js.map +1 -0
- package/dist/src/cli/ui.d.ts +47 -0
- package/dist/src/cli/ui.d.ts.map +1 -0
- package/dist/src/cli/ui.js +166 -0
- package/dist/src/cli/ui.js.map +1 -0
- package/dist/src/cli/uninstall/mcp-uninstall.d.ts +33 -0
- package/dist/src/cli/uninstall/mcp-uninstall.d.ts.map +1 -0
- package/dist/src/cli/uninstall/mcp-uninstall.js +116 -0
- package/dist/src/cli/uninstall/mcp-uninstall.js.map +1 -0
- package/dist/src/config/loader.d.ts +9 -0
- package/dist/src/config/loader.d.ts.map +1 -0
- package/dist/src/config/loader.js +73 -0
- package/dist/src/config/loader.js.map +1 -0
- package/dist/src/config/schema.d.ts +956 -0
- package/dist/src/config/schema.d.ts.map +1 -0
- package/dist/src/config/schema.js +339 -0
- package/dist/src/config/schema.js.map +1 -0
- package/dist/src/diagnostics/claude-preflight.d.ts +35 -0
- package/dist/src/diagnostics/claude-preflight.d.ts.map +1 -0
- package/dist/src/diagnostics/claude-preflight.js +90 -0
- package/dist/src/diagnostics/claude-preflight.js.map +1 -0
- package/dist/src/diagnostics/codex-preflight.d.ts +33 -0
- package/dist/src/diagnostics/codex-preflight.d.ts.map +1 -0
- package/dist/src/diagnostics/codex-preflight.js +99 -0
- package/dist/src/diagnostics/codex-preflight.js.map +1 -0
- package/dist/src/diagnostics/doctor.d.ts +125 -0
- package/dist/src/diagnostics/doctor.d.ts.map +1 -0
- package/dist/src/diagnostics/doctor.js +450 -0
- package/dist/src/diagnostics/doctor.js.map +1 -0
- package/dist/src/diagnostics/install-layout.d.ts +40 -0
- package/dist/src/diagnostics/install-layout.d.ts.map +1 -0
- package/dist/src/diagnostics/install-layout.js +55 -0
- package/dist/src/diagnostics/install-layout.js.map +1 -0
- package/dist/src/diagnostics/memory-coverage.d.ts +54 -0
- package/dist/src/diagnostics/memory-coverage.d.ts.map +1 -0
- package/dist/src/diagnostics/memory-coverage.js +272 -0
- package/dist/src/diagnostics/memory-coverage.js.map +1 -0
- package/dist/src/diagnostics/notify.d.ts +107 -0
- package/dist/src/diagnostics/notify.d.ts.map +1 -0
- package/dist/src/diagnostics/notify.js +217 -0
- package/dist/src/diagnostics/notify.js.map +1 -0
- package/dist/src/diagnostics/repair-prompt.d.ts +49 -0
- package/dist/src/diagnostics/repair-prompt.d.ts.map +1 -0
- package/dist/src/diagnostics/repair-prompt.js +223 -0
- package/dist/src/diagnostics/repair-prompt.js.map +1 -0
- package/dist/src/ingestion/bulk-ingest.d.ts +11 -0
- package/dist/src/ingestion/bulk-ingest.d.ts.map +1 -0
- package/dist/src/ingestion/bulk-ingest.js +11 -0
- package/dist/src/ingestion/bulk-ingest.js.map +1 -0
- package/dist/src/ingestion/chunk-meta.d.ts +85 -0
- package/dist/src/ingestion/chunk-meta.d.ts.map +1 -0
- package/dist/src/ingestion/chunk-meta.js +167 -0
- package/dist/src/ingestion/chunk-meta.js.map +1 -0
- package/dist/src/ingestion/chunk-text.d.ts +39 -0
- package/dist/src/ingestion/chunk-text.d.ts.map +1 -0
- package/dist/src/ingestion/chunk-text.js +114 -0
- package/dist/src/ingestion/chunk-text.js.map +1 -0
- package/dist/src/ingestion/cursor/cursor-store.d.ts +177 -0
- package/dist/src/ingestion/cursor/cursor-store.d.ts.map +1 -0
- package/dist/src/ingestion/cursor/cursor-store.js +242 -0
- package/dist/src/ingestion/cursor/cursor-store.js.map +1 -0
- package/dist/src/ingestion/cursor/enrich-roots.d.ts +16 -0
- package/dist/src/ingestion/cursor/enrich-roots.d.ts.map +1 -0
- package/dist/src/ingestion/cursor/enrich-roots.js +22 -0
- package/dist/src/ingestion/cursor/enrich-roots.js.map +1 -0
- package/dist/src/ingestion/cursor/vscdb-reader.d.ts +32 -0
- package/dist/src/ingestion/cursor/vscdb-reader.d.ts.map +1 -0
- package/dist/src/ingestion/cursor/vscdb-reader.js +113 -0
- package/dist/src/ingestion/cursor/vscdb-reader.js.map +1 -0
- package/dist/src/ingestion/cursor/workspace-root.d.ts +96 -0
- package/dist/src/ingestion/cursor/workspace-root.d.ts.map +1 -0
- package/dist/src/ingestion/cursor/workspace-root.js +187 -0
- package/dist/src/ingestion/cursor/workspace-root.js.map +1 -0
- package/dist/src/ingestion/extractor.d.ts +16 -0
- package/dist/src/ingestion/extractor.d.ts.map +1 -0
- package/dist/src/ingestion/extractor.js +85 -0
- package/dist/src/ingestion/extractor.js.map +1 -0
- package/dist/src/ingestion/extractors/docx.d.ts +3 -0
- package/dist/src/ingestion/extractors/docx.d.ts.map +1 -0
- package/dist/src/ingestion/extractors/docx.js +20 -0
- package/dist/src/ingestion/extractors/docx.js.map +1 -0
- package/dist/src/ingestion/extractors/pdf.d.ts +3 -0
- package/dist/src/ingestion/extractors/pdf.d.ts.map +1 -0
- package/dist/src/ingestion/extractors/pdf.js +32 -0
- package/dist/src/ingestion/extractors/pdf.js.map +1 -0
- package/dist/src/ingestion/historical-campaign.d.ts +340 -0
- package/dist/src/ingestion/historical-campaign.d.ts.map +1 -0
- package/dist/src/ingestion/historical-campaign.js +1010 -0
- package/dist/src/ingestion/historical-campaign.js.map +1 -0
- package/dist/src/ingestion/ignored-paths.d.ts +20 -0
- package/dist/src/ingestion/ignored-paths.d.ts.map +1 -0
- package/dist/src/ingestion/ignored-paths.js +45 -0
- package/dist/src/ingestion/ignored-paths.js.map +1 -0
- package/dist/src/ingestion/inbox-core/conversation-fingerprint.d.ts +2 -0
- package/dist/src/ingestion/inbox-core/conversation-fingerprint.d.ts.map +1 -0
- package/dist/src/ingestion/inbox-core/conversation-fingerprint.js +27 -0
- package/dist/src/ingestion/inbox-core/conversation-fingerprint.js.map +1 -0
- package/dist/src/ingestion/inbox-core/conversation-key.d.ts +2 -0
- package/dist/src/ingestion/inbox-core/conversation-key.d.ts.map +1 -0
- package/dist/src/ingestion/inbox-core/conversation-key.js +31 -0
- package/dist/src/ingestion/inbox-core/conversation-key.js.map +1 -0
- package/dist/src/ingestion/inbox-core/extensions.d.ts +3 -0
- package/dist/src/ingestion/inbox-core/extensions.d.ts.map +1 -0
- package/dist/src/ingestion/inbox-core/extensions.js +16 -0
- package/dist/src/ingestion/inbox-core/extensions.js.map +1 -0
- package/dist/src/ingestion/inbox-core/idempotency.d.ts +2 -0
- package/dist/src/ingestion/inbox-core/idempotency.d.ts.map +1 -0
- package/dist/src/ingestion/inbox-core/idempotency.js +22 -0
- package/dist/src/ingestion/inbox-core/idempotency.js.map +1 -0
- package/dist/src/ingestion/inbox-core/index.d.ts +20 -0
- package/dist/src/ingestion/inbox-core/index.d.ts.map +1 -0
- package/dist/src/ingestion/inbox-core/index.js +20 -0
- package/dist/src/ingestion/inbox-core/index.js.map +1 -0
- package/dist/src/ingestion/inbox-core/source-detection.d.ts +2 -0
- package/dist/src/ingestion/inbox-core/source-detection.d.ts.map +1 -0
- package/dist/src/ingestion/inbox-core/source-detection.js +23 -0
- package/dist/src/ingestion/inbox-core/source-detection.js.map +1 -0
- package/dist/src/ingestion/inbox-core/source-sniffer.d.ts +11 -0
- package/dist/src/ingestion/inbox-core/source-sniffer.d.ts.map +1 -0
- package/dist/src/ingestion/inbox-core/source-sniffer.js +69 -0
- package/dist/src/ingestion/inbox-core/source-sniffer.js.map +1 -0
- package/dist/src/ingestion/inbox-core/zip-sniffer.d.ts +70 -0
- package/dist/src/ingestion/inbox-core/zip-sniffer.d.ts.map +1 -0
- package/dist/src/ingestion/inbox-core/zip-sniffer.js +161 -0
- package/dist/src/ingestion/inbox-core/zip-sniffer.js.map +1 -0
- package/dist/src/ingestion/inbox-watcher.d.ts +12 -0
- package/dist/src/ingestion/inbox-watcher.d.ts.map +1 -0
- package/dist/src/ingestion/inbox-watcher.js +83 -0
- package/dist/src/ingestion/inbox-watcher.js.map +1 -0
- package/dist/src/ingestion/indexer.d.ts +39 -0
- package/dist/src/ingestion/indexer.d.ts.map +1 -0
- package/dist/src/ingestion/indexer.js +111 -0
- package/dist/src/ingestion/indexer.js.map +1 -0
- package/dist/src/ingestion/metadata-extraction.d.ts +56 -0
- package/dist/src/ingestion/metadata-extraction.d.ts.map +1 -0
- package/dist/src/ingestion/metadata-extraction.js +151 -0
- package/dist/src/ingestion/metadata-extraction.js.map +1 -0
- package/dist/src/ingestion/parsers/chatgpt-web.d.ts +29 -0
- package/dist/src/ingestion/parsers/chatgpt-web.d.ts.map +1 -0
- package/dist/src/ingestion/parsers/chatgpt-web.js +100 -0
- package/dist/src/ingestion/parsers/chatgpt-web.js.map +1 -0
- package/dist/src/ingestion/parsers/claude-code-jsonl.d.ts +26 -0
- package/dist/src/ingestion/parsers/claude-code-jsonl.d.ts.map +1 -0
- package/dist/src/ingestion/parsers/claude-code-jsonl.js +125 -0
- package/dist/src/ingestion/parsers/claude-code-jsonl.js.map +1 -0
- package/dist/src/ingestion/parsers/claude-desktop-sessions.d.ts +17 -0
- package/dist/src/ingestion/parsers/claude-desktop-sessions.d.ts.map +1 -0
- package/dist/src/ingestion/parsers/claude-desktop-sessions.js +112 -0
- package/dist/src/ingestion/parsers/claude-desktop-sessions.js.map +1 -0
- package/dist/src/ingestion/parsers/claude-web.d.ts +24 -0
- package/dist/src/ingestion/parsers/claude-web.d.ts.map +1 -0
- package/dist/src/ingestion/parsers/claude-web.js +75 -0
- package/dist/src/ingestion/parsers/claude-web.js.map +1 -0
- package/dist/src/ingestion/parsers/codex-jsonl.d.ts +18 -0
- package/dist/src/ingestion/parsers/codex-jsonl.d.ts.map +1 -0
- package/dist/src/ingestion/parsers/codex-jsonl.js +150 -0
- package/dist/src/ingestion/parsers/codex-jsonl.js.map +1 -0
- package/dist/src/ingestion/parsers/gemini-web.d.ts +16 -0
- package/dist/src/ingestion/parsers/gemini-web.d.ts.map +1 -0
- package/dist/src/ingestion/parsers/gemini-web.js +170 -0
- package/dist/src/ingestion/parsers/gemini-web.js.map +1 -0
- package/dist/src/ingestion/parsers/grok-cli.d.ts +19 -0
- package/dist/src/ingestion/parsers/grok-cli.d.ts.map +1 -0
- package/dist/src/ingestion/parsers/grok-cli.js +126 -0
- package/dist/src/ingestion/parsers/grok-cli.js.map +1 -0
- package/dist/src/ingestion/parsers/grok-web.d.ts +40 -0
- package/dist/src/ingestion/parsers/grok-web.d.ts.map +1 -0
- package/dist/src/ingestion/parsers/grok-web.js +67 -0
- package/dist/src/ingestion/parsers/grok-web.js.map +1 -0
- package/dist/src/ingestion/parsers/turns.d.ts +36 -0
- package/dist/src/ingestion/parsers/turns.d.ts.map +1 -0
- package/dist/src/ingestion/parsers/turns.js +25 -0
- package/dist/src/ingestion/parsers/turns.js.map +1 -0
- package/dist/src/ingestion/parsers/types.d.ts +47 -0
- package/dist/src/ingestion/parsers/types.d.ts.map +1 -0
- package/dist/src/ingestion/parsers/types.js +26 -0
- package/dist/src/ingestion/parsers/types.js.map +1 -0
- package/dist/src/ingestion/report-cards.d.ts +75 -0
- package/dist/src/ingestion/report-cards.d.ts.map +1 -0
- package/dist/src/ingestion/report-cards.js +224 -0
- package/dist/src/ingestion/report-cards.js.map +1 -0
- package/dist/src/ingestion/scanner.d.ts +48 -0
- package/dist/src/ingestion/scanner.d.ts.map +1 -0
- package/dist/src/ingestion/scanner.js +131 -0
- package/dist/src/ingestion/scanner.js.map +1 -0
- package/dist/src/ingestion/skip-quarantine.d.ts +10 -0
- package/dist/src/ingestion/skip-quarantine.d.ts.map +1 -0
- package/dist/src/ingestion/skip-quarantine.js +35 -0
- package/dist/src/ingestion/skip-quarantine.js.map +1 -0
- package/dist/src/ingestion/staging.d.ts +109 -0
- package/dist/src/ingestion/staging.d.ts.map +1 -0
- package/dist/src/ingestion/staging.js +411 -0
- package/dist/src/ingestion/staging.js.map +1 -0
- package/dist/src/ingestion/watcher.d.ts +65 -0
- package/dist/src/ingestion/watcher.d.ts.map +1 -0
- package/dist/src/ingestion/watcher.js +182 -0
- package/dist/src/ingestion/watcher.js.map +1 -0
- package/dist/src/jobs/codex-override-handler.d.ts +3 -0
- package/dist/src/jobs/codex-override-handler.d.ts.map +1 -0
- package/dist/src/jobs/codex-override-handler.js +16 -0
- package/dist/src/jobs/codex-override-handler.js.map +1 -0
- package/dist/src/jobs/handlers/compact.d.ts +30 -0
- package/dist/src/jobs/handlers/compact.d.ts.map +1 -0
- package/dist/src/jobs/handlers/compact.js +360 -0
- package/dist/src/jobs/handlers/compact.js.map +1 -0
- package/dist/src/jobs/handlers/dedupe-conversations.d.ts +134 -0
- package/dist/src/jobs/handlers/dedupe-conversations.d.ts.map +1 -0
- package/dist/src/jobs/handlers/dedupe-conversations.js +371 -0
- package/dist/src/jobs/handlers/dedupe-conversations.js.map +1 -0
- package/dist/src/jobs/handlers/ingest.d.ts +13 -0
- package/dist/src/jobs/handlers/ingest.d.ts.map +1 -0
- package/dist/src/jobs/handlers/ingest.js +557 -0
- package/dist/src/jobs/handlers/ingest.js.map +1 -0
- package/dist/src/jobs/handlers/optimize.d.ts +11 -0
- package/dist/src/jobs/handlers/optimize.d.ts.map +1 -0
- package/dist/src/jobs/handlers/optimize.js +12 -0
- package/dist/src/jobs/handlers/optimize.js.map +1 -0
- package/dist/src/jobs/handlers/reconcile.d.ts +57 -0
- package/dist/src/jobs/handlers/reconcile.d.ts.map +1 -0
- package/dist/src/jobs/handlers/reconcile.js +685 -0
- package/dist/src/jobs/handlers/reconcile.js.map +1 -0
- package/dist/src/jobs/handlers/reindex.d.ts +38 -0
- package/dist/src/jobs/handlers/reindex.d.ts.map +1 -0
- package/dist/src/jobs/handlers/reindex.js +63 -0
- package/dist/src/jobs/handlers/reindex.js.map +1 -0
- package/dist/src/jobs/handlers/save.d.ts +10 -0
- package/dist/src/jobs/handlers/save.d.ts.map +1 -0
- package/dist/src/jobs/handlers/save.js +316 -0
- package/dist/src/jobs/handlers/save.js.map +1 -0
- package/dist/src/jobs/handlers/triage.d.ts +47 -0
- package/dist/src/jobs/handlers/triage.d.ts.map +1 -0
- package/dist/src/jobs/handlers/triage.js +95 -0
- package/dist/src/jobs/handlers/triage.js.map +1 -0
- package/dist/src/jobs/maintenance-scheduler.d.ts +30 -0
- package/dist/src/jobs/maintenance-scheduler.d.ts.map +1 -0
- package/dist/src/jobs/maintenance-scheduler.js +41 -0
- package/dist/src/jobs/maintenance-scheduler.js.map +1 -0
- package/dist/src/jobs/queue.d.ts +157 -0
- package/dist/src/jobs/queue.d.ts.map +1 -0
- package/dist/src/jobs/queue.js +759 -0
- package/dist/src/jobs/queue.js.map +1 -0
- package/dist/src/jobs/types.d.ts +53 -0
- package/dist/src/jobs/types.d.ts.map +1 -0
- package/dist/src/jobs/types.js +33 -0
- package/dist/src/jobs/types.js.map +1 -0
- package/dist/src/jobs/worker-entry.d.ts +10 -0
- package/dist/src/jobs/worker-entry.d.ts.map +1 -0
- package/dist/src/jobs/worker-entry.js +252 -0
- package/dist/src/jobs/worker-entry.js.map +1 -0
- package/dist/src/jobs/worker-process.d.ts +67 -0
- package/dist/src/jobs/worker-process.d.ts.map +1 -0
- package/dist/src/jobs/worker-process.js +227 -0
- package/dist/src/jobs/worker-process.js.map +1 -0
- package/dist/src/jobs/worker.d.ts +11 -0
- package/dist/src/jobs/worker.d.ts.map +1 -0
- package/dist/src/jobs/worker.js +14 -0
- package/dist/src/jobs/worker.js.map +1 -0
- package/dist/src/main.d.ts +2 -0
- package/dist/src/main.d.ts.map +1 -0
- package/dist/src/main.js +683 -0
- package/dist/src/main.js.map +1 -0
- package/dist/src/mcp/capture-diagnostics.d.ts +51 -0
- package/dist/src/mcp/capture-diagnostics.d.ts.map +1 -0
- package/dist/src/mcp/capture-diagnostics.js +127 -0
- package/dist/src/mcp/capture-diagnostics.js.map +1 -0
- package/dist/src/mcp/errors.d.ts +8 -0
- package/dist/src/mcp/errors.d.ts.map +1 -0
- package/dist/src/mcp/errors.js +69 -0
- package/dist/src/mcp/errors.js.map +1 -0
- package/dist/src/mcp/memory-diagnostics.d.ts +6 -0
- package/dist/src/mcp/memory-diagnostics.d.ts.map +1 -0
- package/dist/src/mcp/memory-diagnostics.js +51 -0
- package/dist/src/mcp/memory-diagnostics.js.map +1 -0
- package/dist/src/mcp/names.d.ts +48 -0
- package/dist/src/mcp/names.d.ts.map +1 -0
- package/dist/src/mcp/names.js +77 -0
- package/dist/src/mcp/names.js.map +1 -0
- package/dist/src/mcp/server.d.ts +19 -0
- package/dist/src/mcp/server.d.ts.map +1 -0
- package/dist/src/mcp/server.js +184 -0
- package/dist/src/mcp/server.js.map +1 -0
- package/dist/src/mcp/stdio.d.ts +2 -0
- package/dist/src/mcp/stdio.d.ts.map +1 -0
- package/dist/src/mcp/stdio.js +8 -0
- package/dist/src/mcp/stdio.js.map +1 -0
- package/dist/src/mcp/tools/context-pack.d.ts +35 -0
- package/dist/src/mcp/tools/context-pack.d.ts.map +1 -0
- package/dist/src/mcp/tools/context-pack.js +279 -0
- package/dist/src/mcp/tools/context-pack.js.map +1 -0
- package/dist/src/mcp/tools/conversations-search.d.ts +38 -0
- package/dist/src/mcp/tools/conversations-search.d.ts.map +1 -0
- package/dist/src/mcp/tools/conversations-search.js +79 -0
- package/dist/src/mcp/tools/conversations-search.js.map +1 -0
- package/dist/src/mcp/tools/evidence-feedback.d.ts +60 -0
- package/dist/src/mcp/tools/evidence-feedback.d.ts.map +1 -0
- package/dist/src/mcp/tools/evidence-feedback.js +62 -0
- package/dist/src/mcp/tools/evidence-feedback.js.map +1 -0
- package/dist/src/mcp/tools/log-outcome.d.ts +72 -0
- package/dist/src/mcp/tools/log-outcome.d.ts.map +1 -0
- package/dist/src/mcp/tools/log-outcome.js +59 -0
- package/dist/src/mcp/tools/log-outcome.js.map +1 -0
- package/dist/src/mcp/tools/open-evidence.d.ts +37 -0
- package/dist/src/mcp/tools/open-evidence.d.ts.map +1 -0
- package/dist/src/mcp/tools/open-evidence.js +72 -0
- package/dist/src/mcp/tools/open-evidence.js.map +1 -0
- package/dist/src/mcp/tools/save.d.ts +37 -0
- package/dist/src/mcp/tools/save.d.ts.map +1 -0
- package/dist/src/mcp/tools/save.js +65 -0
- package/dist/src/mcp/tools/save.js.map +1 -0
- package/dist/src/mcp/tools/search.d.ts +37 -0
- package/dist/src/mcp/tools/search.d.ts.map +1 -0
- package/dist/src/mcp/tools/search.js +95 -0
- package/dist/src/mcp/tools/search.js.map +1 -0
- package/dist/src/mcp/tools/status.d.ts +31 -0
- package/dist/src/mcp/tools/status.d.ts.map +1 -0
- package/dist/src/mcp/tools/status.js +63 -0
- package/dist/src/mcp/tools/status.js.map +1 -0
- package/dist/src/observability/coverage.d.ts +100 -0
- package/dist/src/observability/coverage.d.ts.map +1 -0
- package/dist/src/observability/coverage.js +178 -0
- package/dist/src/observability/coverage.js.map +1 -0
- package/dist/src/observability/embedding-events.d.ts +52 -0
- package/dist/src/observability/embedding-events.d.ts.map +1 -0
- package/dist/src/observability/embedding-events.js +149 -0
- package/dist/src/observability/embedding-events.js.map +1 -0
- package/dist/src/observability/index-events.d.ts +70 -0
- package/dist/src/observability/index-events.d.ts.map +1 -0
- package/dist/src/observability/index-events.js +148 -0
- package/dist/src/observability/index-events.js.map +1 -0
- package/dist/src/observability/onboarding-metric.d.ts +131 -0
- package/dist/src/observability/onboarding-metric.d.ts.map +1 -0
- package/dist/src/observability/onboarding-metric.js +352 -0
- package/dist/src/observability/onboarding-metric.js.map +1 -0
- package/dist/src/observability/retrieval-feedback.d.ts +82 -0
- package/dist/src/observability/retrieval-feedback.d.ts.map +1 -0
- package/dist/src/observability/retrieval-feedback.js +231 -0
- package/dist/src/observability/retrieval-feedback.js.map +1 -0
- package/dist/src/observability/rift-context.d.ts +53 -0
- package/dist/src/observability/rift-context.d.ts.map +1 -0
- package/dist/src/observability/rift-context.js +141 -0
- package/dist/src/observability/rift-context.js.map +1 -0
- package/dist/src/observability/staleness.d.ts +43 -0
- package/dist/src/observability/staleness.d.ts.map +1 -0
- package/dist/src/observability/staleness.js +74 -0
- package/dist/src/observability/staleness.js.map +1 -0
- package/dist/src/observability/tool-usage-stats.d.ts +139 -0
- package/dist/src/observability/tool-usage-stats.d.ts.map +1 -0
- package/dist/src/observability/tool-usage-stats.js +245 -0
- package/dist/src/observability/tool-usage-stats.js.map +1 -0
- package/dist/src/observability/tool-usage.d.ts +231 -0
- package/dist/src/observability/tool-usage.d.ts.map +1 -0
- package/dist/src/observability/tool-usage.js +489 -0
- package/dist/src/observability/tool-usage.js.map +1 -0
- package/dist/src/observability/version-check.d.ts +71 -0
- package/dist/src/observability/version-check.d.ts.map +1 -0
- package/dist/src/observability/version-check.js +198 -0
- package/dist/src/observability/version-check.js.map +1 -0
- package/dist/src/onboarding/capture-switch.d.ts +20 -0
- package/dist/src/onboarding/capture-switch.d.ts.map +1 -0
- package/dist/src/onboarding/capture-switch.js +52 -0
- package/dist/src/onboarding/capture-switch.js.map +1 -0
- package/dist/src/onboarding/daemon-control.d.ts +33 -0
- package/dist/src/onboarding/daemon-control.d.ts.map +1 -0
- package/dist/src/onboarding/daemon-control.js +92 -0
- package/dist/src/onboarding/daemon-control.js.map +1 -0
- package/dist/src/onboarding/env-file.d.ts +18 -0
- package/dist/src/onboarding/env-file.d.ts.map +1 -0
- package/dist/src/onboarding/env-file.js +89 -0
- package/dist/src/onboarding/env-file.js.map +1 -0
- package/dist/src/onboarding/search-by-meaning.d.ts +35 -0
- package/dist/src/onboarding/search-by-meaning.d.ts.map +1 -0
- package/dist/src/onboarding/search-by-meaning.js +163 -0
- package/dist/src/onboarding/search-by-meaning.js.map +1 -0
- package/dist/src/onboarding/setup-page.d.ts +7 -0
- package/dist/src/onboarding/setup-page.d.ts.map +1 -0
- package/dist/src/onboarding/setup-page.js +823 -0
- package/dist/src/onboarding/setup-page.js.map +1 -0
- package/dist/src/onboarding/setup-session.d.ts +22 -0
- package/dist/src/onboarding/setup-session.d.ts.map +1 -0
- package/dist/src/onboarding/setup-session.js +80 -0
- package/dist/src/onboarding/setup-session.js.map +1 -0
- package/dist/src/onboarding/setup-state.d.ts +117 -0
- package/dist/src/onboarding/setup-state.d.ts.map +1 -0
- package/dist/src/onboarding/setup-state.js +267 -0
- package/dist/src/onboarding/setup-state.js.map +1 -0
- package/dist/src/onboarding/voyage-validate.d.ts +22 -0
- package/dist/src/onboarding/voyage-validate.d.ts.map +1 -0
- package/dist/src/onboarding/voyage-validate.js +96 -0
- package/dist/src/onboarding/voyage-validate.js.map +1 -0
- package/dist/src/providers/anthropic-digest.d.ts +23 -0
- package/dist/src/providers/anthropic-digest.d.ts.map +1 -0
- package/dist/src/providers/anthropic-digest.js +91 -0
- package/dist/src/providers/anthropic-digest.js.map +1 -0
- package/dist/src/providers/basic-metadata-extraction.d.ts +60 -0
- package/dist/src/providers/basic-metadata-extraction.d.ts.map +1 -0
- package/dist/src/providers/basic-metadata-extraction.js +114 -0
- package/dist/src/providers/basic-metadata-extraction.js.map +1 -0
- package/dist/src/providers/claude-cli-metadata-extraction.d.ts +47 -0
- package/dist/src/providers/claude-cli-metadata-extraction.d.ts.map +1 -0
- package/dist/src/providers/claude-cli-metadata-extraction.js +130 -0
- package/dist/src/providers/claude-cli-metadata-extraction.js.map +1 -0
- package/dist/src/providers/claude-cli-runner.d.ts +92 -0
- package/dist/src/providers/claude-cli-runner.d.ts.map +1 -0
- package/dist/src/providers/claude-cli-runner.js +598 -0
- package/dist/src/providers/claude-cli-runner.js.map +1 -0
- package/dist/src/providers/claude-input-limit.d.ts +32 -0
- package/dist/src/providers/claude-input-limit.d.ts.map +1 -0
- package/dist/src/providers/claude-input-limit.js +32 -0
- package/dist/src/providers/claude-input-limit.js.map +1 -0
- package/dist/src/providers/codex-cli-digest.d.ts +12 -0
- package/dist/src/providers/codex-cli-digest.d.ts.map +1 -0
- package/dist/src/providers/codex-cli-digest.js +70 -0
- package/dist/src/providers/codex-cli-digest.js.map +1 -0
- package/dist/src/providers/codex-cli-metadata-extraction.d.ts +15 -0
- package/dist/src/providers/codex-cli-metadata-extraction.d.ts.map +1 -0
- package/dist/src/providers/codex-cli-metadata-extraction.js +78 -0
- package/dist/src/providers/codex-cli-metadata-extraction.js.map +1 -0
- package/dist/src/providers/codex-cli-model.d.ts +61 -0
- package/dist/src/providers/codex-cli-model.d.ts.map +1 -0
- package/dist/src/providers/codex-cli-model.js +194 -0
- package/dist/src/providers/codex-cli-model.js.map +1 -0
- package/dist/src/providers/codex-cli-runner.d.ts +60 -0
- package/dist/src/providers/codex-cli-runner.d.ts.map +1 -0
- package/dist/src/providers/codex-cli-runner.js +584 -0
- package/dist/src/providers/codex-cli-runner.js.map +1 -0
- package/dist/src/providers/codex-input-limit.d.ts +43 -0
- package/dist/src/providers/codex-input-limit.d.ts.map +1 -0
- package/dist/src/providers/codex-input-limit.js +70 -0
- package/dist/src/providers/codex-input-limit.js.map +1 -0
- package/dist/src/providers/conversation-generation.d.ts +21 -0
- package/dist/src/providers/conversation-generation.d.ts.map +1 -0
- package/dist/src/providers/conversation-generation.js +132 -0
- package/dist/src/providers/conversation-generation.js.map +1 -0
- package/dist/src/providers/ollama-embed.d.ts +23 -0
- package/dist/src/providers/ollama-embed.d.ts.map +1 -0
- package/dist/src/providers/ollama-embed.js +137 -0
- package/dist/src/providers/ollama-embed.js.map +1 -0
- package/dist/src/providers/ollama.d.ts +42 -0
- package/dist/src/providers/ollama.d.ts.map +1 -0
- package/dist/src/providers/ollama.js +169 -0
- package/dist/src/providers/ollama.js.map +1 -0
- package/dist/src/providers/openai-metadata-extraction.d.ts +120 -0
- package/dist/src/providers/openai-metadata-extraction.d.ts.map +1 -0
- package/dist/src/providers/openai-metadata-extraction.js +225 -0
- package/dist/src/providers/openai-metadata-extraction.js.map +1 -0
- package/dist/src/providers/operator-overrides.d.ts +24 -0
- package/dist/src/providers/operator-overrides.d.ts.map +1 -0
- package/dist/src/providers/operator-overrides.js +84 -0
- package/dist/src/providers/operator-overrides.js.map +1 -0
- package/dist/src/providers/placeholder-embed.d.ts +56 -0
- package/dist/src/providers/placeholder-embed.d.ts.map +1 -0
- package/dist/src/providers/placeholder-embed.js +64 -0
- package/dist/src/providers/placeholder-embed.js.map +1 -0
- package/dist/src/providers/shared-request.d.ts +22 -0
- package/dist/src/providers/shared-request.d.ts.map +1 -0
- package/dist/src/providers/shared-request.js +63 -0
- package/dist/src/providers/shared-request.js.map +1 -0
- package/dist/src/providers/stub.d.ts +19 -0
- package/dist/src/providers/stub.d.ts.map +1 -0
- package/dist/src/providers/stub.js +74 -0
- package/dist/src/providers/stub.js.map +1 -0
- package/dist/src/providers/types.d.ts +100 -0
- package/dist/src/providers/types.d.ts.map +1 -0
- package/dist/src/providers/types.js +63 -0
- package/dist/src/providers/types.js.map +1 -0
- package/dist/src/providers/voyage.d.ts +55 -0
- package/dist/src/providers/voyage.d.ts.map +1 -0
- package/dist/src/providers/voyage.js +179 -0
- package/dist/src/providers/voyage.js.map +1 -0
- package/dist/src/retrieval/brief.d.ts +26 -0
- package/dist/src/retrieval/brief.d.ts.map +1 -0
- package/dist/src/retrieval/brief.js +268 -0
- package/dist/src/retrieval/brief.js.map +1 -0
- package/dist/src/retrieval/canonical-files.d.ts +79 -0
- package/dist/src/retrieval/canonical-files.d.ts.map +1 -0
- package/dist/src/retrieval/canonical-files.js +432 -0
- package/dist/src/retrieval/canonical-files.js.map +1 -0
- package/dist/src/retrieval/compact.d.ts +306 -0
- package/dist/src/retrieval/compact.d.ts.map +1 -0
- package/dist/src/retrieval/compact.js +810 -0
- package/dist/src/retrieval/compact.js.map +1 -0
- package/dist/src/retrieval/context-pack.d.ts +344 -0
- package/dist/src/retrieval/context-pack.d.ts.map +1 -0
- package/dist/src/retrieval/context-pack.js +1473 -0
- package/dist/src/retrieval/context-pack.js.map +1 -0
- package/dist/src/retrieval/conversation-dedup.d.ts +54 -0
- package/dist/src/retrieval/conversation-dedup.d.ts.map +1 -0
- package/dist/src/retrieval/conversation-dedup.js +162 -0
- package/dist/src/retrieval/conversation-dedup.js.map +1 -0
- package/dist/src/retrieval/current-truth.d.ts +360 -0
- package/dist/src/retrieval/current-truth.d.ts.map +1 -0
- package/dist/src/retrieval/current-truth.js +766 -0
- package/dist/src/retrieval/current-truth.js.map +1 -0
- package/dist/src/retrieval/cwd.d.ts +25 -0
- package/dist/src/retrieval/cwd.d.ts.map +1 -0
- package/dist/src/retrieval/cwd.js +48 -0
- package/dist/src/retrieval/cwd.js.map +1 -0
- package/dist/src/retrieval/degraded.d.ts +20 -0
- package/dist/src/retrieval/degraded.d.ts.map +1 -0
- package/dist/src/retrieval/degraded.js +43 -0
- package/dist/src/retrieval/degraded.js.map +1 -0
- package/dist/src/retrieval/evidence-key.d.ts +48 -0
- package/dist/src/retrieval/evidence-key.d.ts.map +1 -0
- package/dist/src/retrieval/evidence-key.js +131 -0
- package/dist/src/retrieval/evidence-key.js.map +1 -0
- package/dist/src/retrieval/feedback-ranking.d.ts +49 -0
- package/dist/src/retrieval/feedback-ranking.d.ts.map +1 -0
- package/dist/src/retrieval/feedback-ranking.js +138 -0
- package/dist/src/retrieval/feedback-ranking.js.map +1 -0
- package/dist/src/retrieval/git-state.d.ts +62 -0
- package/dist/src/retrieval/git-state.d.ts.map +1 -0
- package/dist/src/retrieval/git-state.js +192 -0
- package/dist/src/retrieval/git-state.js.map +1 -0
- package/dist/src/retrieval/group-by-parent.d.ts +38 -0
- package/dist/src/retrieval/group-by-parent.d.ts.map +1 -0
- package/dist/src/retrieval/group-by-parent.js +40 -0
- package/dist/src/retrieval/group-by-parent.js.map +1 -0
- package/dist/src/retrieval/hybrid.d.ts +75 -0
- package/dist/src/retrieval/hybrid.d.ts.map +1 -0
- package/dist/src/retrieval/hybrid.js +151 -0
- package/dist/src/retrieval/hybrid.js.map +1 -0
- package/dist/src/retrieval/lexical.d.ts +33 -0
- package/dist/src/retrieval/lexical.d.ts.map +1 -0
- package/dist/src/retrieval/lexical.js +379 -0
- package/dist/src/retrieval/lexical.js.map +1 -0
- package/dist/src/retrieval/locator-boost.d.ts +37 -0
- package/dist/src/retrieval/locator-boost.d.ts.map +1 -0
- package/dist/src/retrieval/locator-boost.js +129 -0
- package/dist/src/retrieval/locator-boost.js.map +1 -0
- package/dist/src/retrieval/passages.d.ts +24 -0
- package/dist/src/retrieval/passages.d.ts.map +1 -0
- package/dist/src/retrieval/passages.js +160 -0
- package/dist/src/retrieval/passages.js.map +1 -0
- package/dist/src/retrieval/post-filter.d.ts +32 -0
- package/dist/src/retrieval/post-filter.d.ts.map +1 -0
- package/dist/src/retrieval/post-filter.js +57 -0
- package/dist/src/retrieval/post-filter.js.map +1 -0
- package/dist/src/retrieval/project-index.d.ts +71 -0
- package/dist/src/retrieval/project-index.d.ts.map +1 -0
- package/dist/src/retrieval/project-index.js +348 -0
- package/dist/src/retrieval/project-index.js.map +1 -0
- package/dist/src/retrieval/recall-hint.d.ts +22 -0
- package/dist/src/retrieval/recall-hint.d.ts.map +1 -0
- package/dist/src/retrieval/recall-hint.js +33 -0
- package/dist/src/retrieval/recall-hint.js.map +1 -0
- package/dist/src/retrieval/receipt.d.ts +57 -0
- package/dist/src/retrieval/receipt.d.ts.map +1 -0
- package/dist/src/retrieval/receipt.js +122 -0
- package/dist/src/retrieval/receipt.js.map +1 -0
- package/dist/src/retrieval/report-demotion.d.ts +46 -0
- package/dist/src/retrieval/report-demotion.d.ts.map +1 -0
- package/dist/src/retrieval/report-demotion.js +169 -0
- package/dist/src/retrieval/report-demotion.js.map +1 -0
- package/dist/src/retrieval/reranker.d.ts +119 -0
- package/dist/src/retrieval/reranker.d.ts.map +1 -0
- package/dist/src/retrieval/reranker.js +220 -0
- package/dist/src/retrieval/reranker.js.map +1 -0
- package/dist/src/retrieval/stitch-chunks.d.ts +76 -0
- package/dist/src/retrieval/stitch-chunks.d.ts.map +1 -0
- package/dist/src/retrieval/stitch-chunks.js +113 -0
- package/dist/src/retrieval/stitch-chunks.js.map +1 -0
- package/dist/src/retrieval/vector.d.ts +71 -0
- package/dist/src/retrieval/vector.d.ts.map +1 -0
- package/dist/src/retrieval/vector.js +147 -0
- package/dist/src/retrieval/vector.js.map +1 -0
- package/dist/src/runtime/legacy-migration.d.ts +27 -0
- package/dist/src/runtime/legacy-migration.d.ts.map +1 -0
- package/dist/src/runtime/legacy-migration.js +140 -0
- package/dist/src/runtime/legacy-migration.js.map +1 -0
- package/dist/src/runtime/legacy-name-guard.d.ts +35 -0
- package/dist/src/runtime/legacy-name-guard.d.ts.map +1 -0
- package/dist/src/runtime/legacy-name-guard.js +58 -0
- package/dist/src/runtime/legacy-name-guard.js.map +1 -0
- package/dist/src/runtime/rift-env.d.ts +14 -0
- package/dist/src/runtime/rift-env.d.ts.map +1 -0
- package/dist/src/runtime/rift-env.js +79 -0
- package/dist/src/runtime/rift-env.js.map +1 -0
- package/dist/src/runtime/voyage-key-source.d.ts +46 -0
- package/dist/src/runtime/voyage-key-source.d.ts.map +1 -0
- package/dist/src/runtime/voyage-key-source.js +97 -0
- package/dist/src/runtime/voyage-key-source.js.map +1 -0
- package/dist/src/runtime/watcher-startup.d.ts +2 -0
- package/dist/src/runtime/watcher-startup.d.ts.map +1 -0
- package/dist/src/runtime/watcher-startup.js +4 -0
- package/dist/src/runtime/watcher-startup.js.map +1 -0
- package/dist/src/security/archive.d.ts +23 -0
- package/dist/src/security/archive.d.ts.map +1 -0
- package/dist/src/security/archive.js +163 -0
- package/dist/src/security/archive.js.map +1 -0
- package/dist/src/security/paths.d.ts +21 -0
- package/dist/src/security/paths.d.ts.map +1 -0
- package/dist/src/security/paths.js +67 -0
- package/dist/src/security/paths.js.map +1 -0
- package/dist/src/server/app.d.ts +29 -0
- package/dist/src/server/app.d.ts.map +1 -0
- package/dist/src/server/app.js +356 -0
- package/dist/src/server/app.js.map +1 -0
- package/dist/src/server/build-info.d.ts +8 -0
- package/dist/src/server/build-info.d.ts.map +1 -0
- package/dist/src/server/build-info.js +61 -0
- package/dist/src/server/build-info.js.map +1 -0
- package/dist/src/server/lifecycle.d.ts +30 -0
- package/dist/src/server/lifecycle.d.ts.map +1 -0
- package/dist/src/server/lifecycle.js +59 -0
- package/dist/src/server/lifecycle.js.map +1 -0
- package/dist/src/server/middleware/multipart.d.ts +51 -0
- package/dist/src/server/middleware/multipart.d.ts.map +1 -0
- package/dist/src/server/middleware/multipart.js +86 -0
- package/dist/src/server/middleware/multipart.js.map +1 -0
- package/dist/src/server/routes/compact.d.ts +37 -0
- package/dist/src/server/routes/compact.d.ts.map +1 -0
- package/dist/src/server/routes/compact.js +80 -0
- package/dist/src/server/routes/compact.js.map +1 -0
- package/dist/src/server/routes/context.d.ts +12 -0
- package/dist/src/server/routes/context.d.ts.map +1 -0
- package/dist/src/server/routes/context.js +73 -0
- package/dist/src/server/routes/context.js.map +1 -0
- package/dist/src/server/routes/conversations-search.d.ts +4 -0
- package/dist/src/server/routes/conversations-search.d.ts.map +1 -0
- package/dist/src/server/routes/conversations-search.js +287 -0
- package/dist/src/server/routes/conversations-search.js.map +1 -0
- package/dist/src/server/routes/enqueue.d.ts +11 -0
- package/dist/src/server/routes/enqueue.d.ts.map +1 -0
- package/dist/src/server/routes/enqueue.js +17 -0
- package/dist/src/server/routes/enqueue.js.map +1 -0
- package/dist/src/server/routes/friend-status.d.ts +474 -0
- package/dist/src/server/routes/friend-status.d.ts.map +1 -0
- package/dist/src/server/routes/friend-status.js +671 -0
- package/dist/src/server/routes/friend-status.js.map +1 -0
- package/dist/src/server/routes/ingest.d.ts +15 -0
- package/dist/src/server/routes/ingest.d.ts.map +1 -0
- package/dist/src/server/routes/ingest.js +142 -0
- package/dist/src/server/routes/ingest.js.map +1 -0
- package/dist/src/server/routes/jobs.d.ts +10 -0
- package/dist/src/server/routes/jobs.d.ts.map +1 -0
- package/dist/src/server/routes/jobs.js +29 -0
- package/dist/src/server/routes/jobs.js.map +1 -0
- package/dist/src/server/routes/mcp-usage.d.ts +17 -0
- package/dist/src/server/routes/mcp-usage.d.ts.map +1 -0
- package/dist/src/server/routes/mcp-usage.js +17 -0
- package/dist/src/server/routes/mcp-usage.js.map +1 -0
- package/dist/src/server/routes/reconcile.d.ts +4 -0
- package/dist/src/server/routes/reconcile.d.ts.map +1 -0
- package/dist/src/server/routes/reconcile.js +62 -0
- package/dist/src/server/routes/reconcile.js.map +1 -0
- package/dist/src/server/routes/reindex.d.ts +4 -0
- package/dist/src/server/routes/reindex.d.ts.map +1 -0
- package/dist/src/server/routes/reindex.js +77 -0
- package/dist/src/server/routes/reindex.js.map +1 -0
- package/dist/src/server/routes/retrieval-feedback.d.ts +3 -0
- package/dist/src/server/routes/retrieval-feedback.d.ts.map +1 -0
- package/dist/src/server/routes/retrieval-feedback.js +290 -0
- package/dist/src/server/routes/retrieval-feedback.js.map +1 -0
- package/dist/src/server/routes/save.d.ts +52 -0
- package/dist/src/server/routes/save.d.ts.map +1 -0
- package/dist/src/server/routes/save.js +127 -0
- package/dist/src/server/routes/save.js.map +1 -0
- package/dist/src/server/routes/search.d.ts +5 -0
- package/dist/src/server/routes/search.d.ts.map +1 -0
- package/dist/src/server/routes/search.js +689 -0
- package/dist/src/server/routes/search.js.map +1 -0
- package/dist/src/server/routes/setup.d.ts +46 -0
- package/dist/src/server/routes/setup.d.ts.map +1 -0
- package/dist/src/server/routes/setup.js +322 -0
- package/dist/src/server/routes/setup.js.map +1 -0
- package/dist/src/server/routes/stats.d.ts +10 -0
- package/dist/src/server/routes/stats.d.ts.map +1 -0
- package/dist/src/server/routes/stats.js +15 -0
- package/dist/src/server/routes/stats.js.map +1 -0
- package/dist/src/server/routes/status.d.ts +20 -0
- package/dist/src/server/routes/status.d.ts.map +1 -0
- package/dist/src/server/routes/status.js +31 -0
- package/dist/src/server/routes/status.js.map +1 -0
- package/dist/src/server/routes/triage.d.ts +4 -0
- package/dist/src/server/routes/triage.d.ts.map +1 -0
- package/dist/src/server/routes/triage.js +97 -0
- package/dist/src/server/routes/triage.js.map +1 -0
- package/dist/src/server/save-quality.d.ts +21 -0
- package/dist/src/server/save-quality.d.ts.map +1 -0
- package/dist/src/server/save-quality.js +51 -0
- package/dist/src/server/save-quality.js.map +1 -0
- package/dist/src/server/serving-marker.d.ts +85 -0
- package/dist/src/server/serving-marker.d.ts.map +1 -0
- package/dist/src/server/serving-marker.js +226 -0
- package/dist/src/server/serving-marker.js.map +1 -0
- package/dist/src/storage/atomic.d.ts +8 -0
- package/dist/src/storage/atomic.d.ts.map +1 -0
- package/dist/src/storage/atomic.js +22 -0
- package/dist/src/storage/atomic.js.map +1 -0
- package/dist/src/storage/chunk-backfill.d.ts +39 -0
- package/dist/src/storage/chunk-backfill.d.ts.map +1 -0
- package/dist/src/storage/chunk-backfill.js +295 -0
- package/dist/src/storage/chunk-backfill.js.map +1 -0
- package/dist/src/storage/db.d.ts +15 -0
- package/dist/src/storage/db.d.ts.map +1 -0
- package/dist/src/storage/db.js +47 -0
- package/dist/src/storage/db.js.map +1 -0
- package/dist/src/storage/filter.d.ts +42 -0
- package/dist/src/storage/filter.d.ts.map +1 -0
- package/dist/src/storage/filter.js +70 -0
- package/dist/src/storage/filter.js.map +1 -0
- package/dist/src/storage/fts.d.ts +47 -0
- package/dist/src/storage/fts.d.ts.map +1 -0
- package/dist/src/storage/fts.js +86 -0
- package/dist/src/storage/fts.js.map +1 -0
- package/dist/src/storage/integrity.d.ts +11 -0
- package/dist/src/storage/integrity.d.ts.map +1 -0
- package/dist/src/storage/integrity.js +66 -0
- package/dist/src/storage/integrity.js.map +1 -0
- package/dist/src/storage/maintenance.d.ts +27 -0
- package/dist/src/storage/maintenance.d.ts.map +1 -0
- package/dist/src/storage/maintenance.js +66 -0
- package/dist/src/storage/maintenance.js.map +1 -0
- package/dist/src/storage/rebuild.d.ts +71 -0
- package/dist/src/storage/rebuild.d.ts.map +1 -0
- package/dist/src/storage/rebuild.js +605 -0
- package/dist/src/storage/rebuild.js.map +1 -0
- package/dist/src/storage/report-card-backfill.d.ts +20 -0
- package/dist/src/storage/report-card-backfill.d.ts.map +1 -0
- package/dist/src/storage/report-card-backfill.js +114 -0
- package/dist/src/storage/report-card-backfill.js.map +1 -0
- package/dist/src/storage/shadow-swap.d.ts +20 -0
- package/dist/src/storage/shadow-swap.d.ts.map +1 -0
- package/dist/src/storage/shadow-swap.js +163 -0
- package/dist/src/storage/shadow-swap.js.map +1 -0
- package/dist/src/storage/tables.d.ts +147 -0
- package/dist/src/storage/tables.d.ts.map +1 -0
- package/dist/src/storage/tables.js +290 -0
- package/dist/src/storage/tables.js.map +1 -0
- package/operator/swiftbar/render-menu.py +475 -0
- package/operator/swiftbar/rift.10s.sh +201 -0
- package/package.json +57 -3
|
@@ -0,0 +1,1473 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slice 3: ContextPack retrieval primitive.
|
|
3
|
+
*
|
|
4
|
+
* Builds a compact, bucketed view of prior context for an active task.
|
|
5
|
+
* Reuses hybrid search; never returns raw transcripts.
|
|
6
|
+
*
|
|
7
|
+
* Buckets:
|
|
8
|
+
* - decisions: strings pulled from matching conversations' `decisions` JSON
|
|
9
|
+
* - constraints: MUST/NEVER/DO-NOT style lines pulled from matching docs
|
|
10
|
+
* - examples: compact pointers to prior conversations (title+summary+expand)
|
|
11
|
+
* - rules: compact pointers to project docs (title+snippet+expand)
|
|
12
|
+
*
|
|
13
|
+
* Hard caps (locked contract):
|
|
14
|
+
* - each text item <= 200 chars
|
|
15
|
+
* - each snippet <= 200 chars
|
|
16
|
+
* - max_per_bucket default 3, ceiling 10
|
|
17
|
+
* - max_bytes default 6144, ceiling 16384
|
|
18
|
+
*
|
|
19
|
+
* Nothing here embeds or writes — pure assembly on top of hybridSearch
|
|
20
|
+
* plus direct row lookups for the decisions/constraints extraction.
|
|
21
|
+
*/
|
|
22
|
+
import fs from "node:fs";
|
|
23
|
+
import path from "node:path";
|
|
24
|
+
import { EMBED_WAIT_MS, hybridSearch, sharedEmbedding } from "./hybrid.js";
|
|
25
|
+
import { rerank } from "./reranker.js";
|
|
26
|
+
import { getTable } from "../storage/tables.js";
|
|
27
|
+
import { resolveCwdRoot } from "./cwd.js";
|
|
28
|
+
import { getProjectIndex, resolveProjectRoot } from "./project-index.js";
|
|
29
|
+
import { computeContentSize } from "./compact.js";
|
|
30
|
+
import { extractPassages } from "./passages.js";
|
|
31
|
+
import { decodeUserStatement, MAX_QUOTE_CHARS, } from "../capture/user-statements.js";
|
|
32
|
+
import { groupByParent, rankedKey } from "./group-by-parent.js";
|
|
33
|
+
import { collapseConversationDuplicates, convDedupEnabled, poolHasChunkMarkers, } from "./conversation-dedup.js";
|
|
34
|
+
import { parentKeyForRow } from "../ingestion/chunk-meta.js";
|
|
35
|
+
import { inFilter } from "../storage/filter.js";
|
|
36
|
+
import { classifyClaimType, classifyEvidenceIntent, partitionEvidence, } from "./current-truth.js";
|
|
37
|
+
import { probeGitStates, resolveRepoRoot, } from "./git-state.js";
|
|
38
|
+
import { canonicalEvidenceInputs, canonicalFilesEnabled, cleanItemText, holdsQuestionSubject, selectCanonicalSections, } from "./canonical-files.js";
|
|
39
|
+
// --- Locked caps ---
|
|
40
|
+
export const ITEM_TEXT_MAX = 200;
|
|
41
|
+
export const SNIPPET_MAX = 200;
|
|
42
|
+
/** Task-matching passage per example card. */
|
|
43
|
+
export const PASSAGE_MAX = 360;
|
|
44
|
+
export const DEFAULT_MAX_PER_BUCKET = 3;
|
|
45
|
+
export const MAX_PER_BUCKET_CEILING = 10;
|
|
46
|
+
/**
|
|
47
|
+
* Default envelope. 6 KB since passages were added (2026-09-24): at 4 KB the
|
|
48
|
+
* passages pushed the third example card out of every frozen-task pack; at
|
|
49
|
+
* 6 KB none were trimmed (packs measured 4.0–5.3 KB).
|
|
50
|
+
*/
|
|
51
|
+
export const DEFAULT_MAX_BYTES = 6144;
|
|
52
|
+
export const MAX_BYTES_CEILING = 16384;
|
|
53
|
+
/** Request `task` is echoed in the response, so it counts against `max_bytes`. Capped to keep the envelope small. */
|
|
54
|
+
export const TASK_MAX = 1024;
|
|
55
|
+
/**
|
|
56
|
+
* Minimum `S_sim` for a ranked candidate to feed the `decisions` /
|
|
57
|
+
* `examples` buckets. Below this floor we prefer an empty bucket over
|
|
58
|
+
* confidently-worded unrelated content — Slice 5 validation showed
|
|
59
|
+
* that when the task has no real match in the corpus, decisions from
|
|
60
|
+
* the top-ranked-but-unrelated row still come back, and an agent has
|
|
61
|
+
* no way to tell they're noise.
|
|
62
|
+
*
|
|
63
|
+
* `S_sim` is cosine similarity in [0,1] for vector / hybrid results
|
|
64
|
+
* and max-normalized BM25 for lexical-only. The floor is deliberately
|
|
65
|
+
* low (0.3): genuine weak matches still pass, but rows that are
|
|
66
|
+
* essentially keyword-free or cosine-orthogonal drop out. Constraints
|
|
67
|
+
* and rules are already heavily filtered (marker matching + engine-
|
|
68
|
+
* owned-path exclusion), so we only apply the floor to the two
|
|
69
|
+
* "free-text content" buckets where noise is most costly.
|
|
70
|
+
*/
|
|
71
|
+
export const DECISIONS_RELEVANCE_FLOOR = 0.3;
|
|
72
|
+
export const EXAMPLES_RELEVANCE_FLOOR = 0.3;
|
|
73
|
+
/**
|
|
74
|
+
* Equal-relevance band for {@link sortByRelevanceFirst}. Two candidates
|
|
75
|
+
* whose relevance signals (`max(S_sim, bm25_normalized)`) sit within
|
|
76
|
+
* this absolute delta are treated as effectively tied and fall through
|
|
77
|
+
* to the composite-score tie-breaker. Small enough to keep genuinely
|
|
78
|
+
* better relevance on top, wide enough that floating-point noise and
|
|
79
|
+
* trivial ranking jitter don't cause ping-pong between near-equal rows.
|
|
80
|
+
*/
|
|
81
|
+
export const RELEVANCE_TIE_EPSILON = 0.02;
|
|
82
|
+
/**
|
|
83
|
+
* A sentence the user said is on the task's subject when it shares two of its
|
|
84
|
+
* subject words, or when it is this close to the task in meaning. Short rules
|
|
85
|
+
* rarely repeat two words of a task ("Inter, or any good looking sans font."
|
|
86
|
+
* for a task about the website's font), so the word test alone drops them.
|
|
87
|
+
*
|
|
88
|
+
* The bar is cosine similarity, and each model has its own scale, so each
|
|
89
|
+
* measured model has its own bar. Both were set against the owner's stored
|
|
90
|
+
* statements and past task strings (4,615 pairs) to let through the same
|
|
91
|
+
* small share of pairs, about 0.6%: on voyage-3-lite the 99th percentile is
|
|
92
|
+
* 0.44 and on voyage-4-lite at 512 dimensions 0.48. At these bars both font
|
|
93
|
+
* rules pass on a short question and on a long task description, the lowest
|
|
94
|
+
* at 0.497 on voyage-3-lite. A model that was not measured keeps the word
|
|
95
|
+
* test alone.
|
|
96
|
+
*/
|
|
97
|
+
export const STATEMENT_CLOSENESS_MIN = {
|
|
98
|
+
"voyage-3-lite": 0.47,
|
|
99
|
+
"voyage-4-lite": 0.5,
|
|
100
|
+
};
|
|
101
|
+
const STATEMENT_CLOSENESS_PROVIDER = "voyage";
|
|
102
|
+
/**
|
|
103
|
+
* The most sentences one pack sends to be compared. A session keeps every
|
|
104
|
+
* statement the user made, so a long one can hold hundreds; the rest are
|
|
105
|
+
* compared by the next packs, and the pack says it is partial until then.
|
|
106
|
+
*/
|
|
107
|
+
export const STATEMENT_COMPARE_MAX = 200;
|
|
108
|
+
/** Statement vectors kept for the life of the process: a stored sentence never changes. */
|
|
109
|
+
const STATEMENT_VECTOR_CACHE_MAX = 5_000;
|
|
110
|
+
const statementVectors = new Map();
|
|
111
|
+
/** Test hook: forget the kept statement vectors. */
|
|
112
|
+
export function resetStatementVectorCache() {
|
|
113
|
+
statementVectors.clear();
|
|
114
|
+
}
|
|
115
|
+
// Fetch more candidates than we keep so we have headroom to extract
|
|
116
|
+
// decisions/constraints from multiple sources and dedupe downstream.
|
|
117
|
+
const CANDIDATE_FETCH_MULTIPLIER = 4;
|
|
118
|
+
/** Tables that feed the rules / constraints buckets. */
|
|
119
|
+
const DOC_TABLES = ["structured_docs", "structured_docs_local"];
|
|
120
|
+
/** Tracker sections read per pack; each bucket then takes its own cap from them. */
|
|
121
|
+
const TRACKER_SECTION_POOL = 24;
|
|
122
|
+
/** Same floor as examples: below it an other-project document is noise. */
|
|
123
|
+
export const OTHER_PROJECTS_RELEVANCE_FLOOR = 0.3;
|
|
124
|
+
/**
|
|
125
|
+
* The task names work outside this project ("from another project", "pour un
|
|
126
|
+
* autre client"). Other-project documents then get their budget first;
|
|
127
|
+
* otherwise they only use what the project's own evidence leaves free.
|
|
128
|
+
*/
|
|
129
|
+
const ASKS_OTHER_PROJECTS = /\b(?:an)?other\s+(?:projects?|clients?|repos?|repositor(?:y|ies))\b|\bcross[- ]project\b|\belsewhere\b|\bautres?\s+(?:projets?|clients?)\b|\bailleurs\b/i;
|
|
130
|
+
// --- Project-first retrieval ---
|
|
131
|
+
/**
|
|
132
|
+
* Project rows lead only when they are nearly as relevant as the best
|
|
133
|
+
* candidate overall; otherwise a question about another project asked from
|
|
134
|
+
* this repo would surface weak local matches first.
|
|
135
|
+
*/
|
|
136
|
+
export const PROJECT_FIRST_RELEVANCE_RATIO = 0.8;
|
|
137
|
+
async function resolvePackProjects(cwd) {
|
|
138
|
+
const index = getProjectIndex();
|
|
139
|
+
const root = cwd ? resolveProjectRoot(cwd) : null;
|
|
140
|
+
if (!index || !root)
|
|
141
|
+
return { current: null, otherProjectOf: () => undefined };
|
|
142
|
+
const { byRoot, projectById } = await index.rowsByProject();
|
|
143
|
+
const rowIds = byRoot.get(root) ?? [];
|
|
144
|
+
return {
|
|
145
|
+
current: rowIds.length ? { root, rowIds, idSet: new Set(rowIds) } : null,
|
|
146
|
+
otherProjectOf: (rowId) => {
|
|
147
|
+
const home = projectById.get(rowId);
|
|
148
|
+
return home && home !== root ? path.basename(home) : undefined;
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function mergeCandidates(a, b) {
|
|
153
|
+
const byId = new Map();
|
|
154
|
+
for (const c of [...a, ...b]) {
|
|
155
|
+
const prev = byId.get(c.id);
|
|
156
|
+
if (!prev)
|
|
157
|
+
byId.set(c.id, c);
|
|
158
|
+
else
|
|
159
|
+
byId.set(c.id, { ...prev, raw_sim: Math.max(prev.raw_sim, c.raw_sim), raw_bm25: Math.max(prev.raw_bm25, c.raw_bm25) });
|
|
160
|
+
}
|
|
161
|
+
return [...byId.values()];
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* For a task that asks for work from other projects: sessions that ran in
|
|
165
|
+
* another project lead, when close to the best of them. The reverse of
|
|
166
|
+
* {@link projectFirst}, which would bury exactly what was asked for.
|
|
167
|
+
*/
|
|
168
|
+
export function otherProjectsFirst(ranked, isOtherProject) {
|
|
169
|
+
const rel = (r) => Math.max(r.factors.S_sim, r.bm25_normalized);
|
|
170
|
+
const others = ranked.filter((r) => isOtherProject(r.id));
|
|
171
|
+
const best = others.reduce((m, r) => Math.max(m, rel(r)), 0);
|
|
172
|
+
const leadSet = new Set(others.filter((r) => rel(r) >= best * PROJECT_FIRST_RELEVANCE_RATIO));
|
|
173
|
+
return [...leadSet, ...ranked.filter((r) => !leadSet.has(r))];
|
|
174
|
+
}
|
|
175
|
+
/** Stable-partition: close-to-best project rows first, everything else after. */
|
|
176
|
+
export function projectFirst(ranked, idSet) {
|
|
177
|
+
const rel = (r) => Math.max(r.factors.S_sim, r.bm25_normalized);
|
|
178
|
+
const best = ranked.reduce((m, r) => Math.max(m, rel(r)), 0);
|
|
179
|
+
const lead = ranked.filter((r) => idSet.has(r.id) && rel(r) >= best * PROJECT_FIRST_RELEVANCE_RATIO);
|
|
180
|
+
const leadSet = new Set(lead);
|
|
181
|
+
return [...lead, ...ranked.filter((r) => !leadSet.has(r))];
|
|
182
|
+
}
|
|
183
|
+
// --- Public entry ---
|
|
184
|
+
export async function buildContextPack(opts) {
|
|
185
|
+
const maxPerBucket = clamp(opts.maxPerBucket ?? DEFAULT_MAX_PER_BUCKET, 1, MAX_PER_BUCKET_CEILING);
|
|
186
|
+
const maxBytes = clamp(opts.maxBytes ?? DEFAULT_MAX_BYTES, 512, MAX_BYTES_CEILING);
|
|
187
|
+
const cwdMatch = opts.cwd && opts.sources ? resolveCwdRoot(opts.cwd, opts.sources) : null;
|
|
188
|
+
const sourcePathPrefix = cwdMatch?.rootPath;
|
|
189
|
+
// Fetch candidates in two lanes in parallel: conversations and documents.
|
|
190
|
+
// These feed different buckets, so running them separately lets each bucket
|
|
191
|
+
// draw on its own candidate pool without one starving the other.
|
|
192
|
+
//
|
|
193
|
+
// The docs lane uses scope="all" restricted to the structured_docs table,
|
|
194
|
+
// because scope="documents" would also require `source_scope='document'`
|
|
195
|
+
// — excluding project-scoped files like CLAUDE.md / AGENTS.md / PRD.md
|
|
196
|
+
// that are the whole point of the `rules` bucket. Restricting the table
|
|
197
|
+
// (instead of filtering afterwards) keeps the docs lane from re-running the
|
|
198
|
+
// conversation search, and one shared embedding serves both lanes.
|
|
199
|
+
const fetchK = maxPerBucket * CANDIDATE_FETCH_MULTIPLIER;
|
|
200
|
+
const embedding = opts.embedding ? sharedEmbedding(opts.embedding) : undefined;
|
|
201
|
+
const { current: project, otherProjectOf } = await resolvePackProjects(opts.cwd);
|
|
202
|
+
const asksOtherProjects = ASKS_OTHER_PROJECTS.test(opts.task);
|
|
203
|
+
const [convRes, docRes, projRes, otherRes] = await Promise.all([
|
|
204
|
+
hybridSearch(opts.task, embedding, {
|
|
205
|
+
scope: "conversations",
|
|
206
|
+
top_k: fetchK,
|
|
207
|
+
...(opts.since ? { since: opts.since } : {}),
|
|
208
|
+
}),
|
|
209
|
+
hybridSearch(opts.task, embedding, {
|
|
210
|
+
scope: "all",
|
|
211
|
+
tables: DOC_TABLES,
|
|
212
|
+
top_k: fetchK,
|
|
213
|
+
...(opts.since ? { since: opts.since } : {}),
|
|
214
|
+
...(sourcePathPrefix ? { sourcePathPrefix } : {}),
|
|
215
|
+
}),
|
|
216
|
+
// Project-first lane: the same search restricted to conversations captured
|
|
217
|
+
// in this project, so project history is not crowded out by the archive.
|
|
218
|
+
// When the task asks for other projects it is the reverse: everything
|
|
219
|
+
// but this project's sessions, so they cannot crowd out the others.
|
|
220
|
+
project
|
|
221
|
+
? hybridSearch(opts.task, embedding, {
|
|
222
|
+
scope: "conversations",
|
|
223
|
+
tables: ["conversations_hot"],
|
|
224
|
+
...(asksOtherProjects
|
|
225
|
+
? { excludeConversationIds: project.rowIds }
|
|
226
|
+
: { conversationIds: project.rowIds }),
|
|
227
|
+
top_k: fetchK,
|
|
228
|
+
...(opts.since ? { since: opts.since } : {}),
|
|
229
|
+
})
|
|
230
|
+
: Promise.resolve(null),
|
|
231
|
+
// Other-projects lane: the docs lane above is locked to this project, so
|
|
232
|
+
// a document in another configured project is never a candidate there.
|
|
233
|
+
// The same search with this project left out finds it. Left out in the
|
|
234
|
+
// query: filtered afterwards, a project with many matching documents
|
|
235
|
+
// would fill top_k and leave no room for anyone else's.
|
|
236
|
+
sourcePathPrefix
|
|
237
|
+
? hybridSearch(opts.task, embedding, {
|
|
238
|
+
scope: "all",
|
|
239
|
+
tables: DOC_TABLES,
|
|
240
|
+
top_k: fetchK,
|
|
241
|
+
excludeSourcePathPrefix: `${sourcePathPrefix.replace(/\/+$/, "")}/`,
|
|
242
|
+
...(opts.since ? { since: opts.since } : {}),
|
|
243
|
+
})
|
|
244
|
+
: Promise.resolve(null),
|
|
245
|
+
]);
|
|
246
|
+
let degraded = convRes.degraded || docRes.degraded;
|
|
247
|
+
let degradedReason = convRes.degraded_reason ?? docRes.degraded_reason;
|
|
248
|
+
// Rerank the project lane together with the global lane: BM25 is normalized
|
|
249
|
+
// over the pool, so a separately reranked project pool would inflate weak
|
|
250
|
+
// project matches.
|
|
251
|
+
let convRanked = rerank(toRerankInput(mergeCandidates(convRes.candidates, projRes?.candidates ?? [])));
|
|
252
|
+
if (project) {
|
|
253
|
+
// Half the pool is held for the lane's side: this project's sessions, or
|
|
254
|
+
// everyone else's when the task asks for other projects.
|
|
255
|
+
const held = convRanked.filter((r) => project.idSet.has(r.id) !== asksOtherProjects);
|
|
256
|
+
const rest = convRanked.filter((r) => project.idSet.has(r.id) === asksOtherProjects);
|
|
257
|
+
convRanked = [...held.slice(0, Math.ceil(fetchK / 2)), ...rest];
|
|
258
|
+
}
|
|
259
|
+
convRanked = convRanked.slice(0, fetchK);
|
|
260
|
+
let docRanked = rerank(toRerankInput(docRes.candidates.filter((c) => c.source_table === "structured_docs" ||
|
|
261
|
+
c.source_table === "structured_docs_local"))).slice(0, fetchK);
|
|
262
|
+
const otherRanked = otherRes
|
|
263
|
+
? rerank(toRerankInput(otherRes.candidates)).slice(0, fetchK)
|
|
264
|
+
: [];
|
|
265
|
+
// Fetch raw rows for the top ranked results so we can pull `decisions`,
|
|
266
|
+
// `content`, `metadata.title`, `source_path`, etc.
|
|
267
|
+
const [convRows, docRows, otherRows] = await Promise.all([
|
|
268
|
+
fetchRowsById(convRanked),
|
|
269
|
+
fetchRowsById(docRanked),
|
|
270
|
+
fetchRowsById(otherRanked),
|
|
271
|
+
]);
|
|
272
|
+
// Collapse chunk siblings so one long conversation/document contributes a
|
|
273
|
+
// single card downstream (decisions / examples / rules / evidence) instead of
|
|
274
|
+
// one per chunk. No-op for unchunked/legacy rows (parentKeyForRow → null).
|
|
275
|
+
const parentKeyOf = (rows) => (r) => {
|
|
276
|
+
const row = rows.get(rankedKey(r));
|
|
277
|
+
return row ? parentKeyForRow(r.source_table, row) : null;
|
|
278
|
+
};
|
|
279
|
+
const convGrouped = groupByParent(convRanked, parentKeyOf(convRows));
|
|
280
|
+
convRanked = convGrouped.ranked;
|
|
281
|
+
docRanked = groupByParent(docRanked, parentKeyOf(docRows)).ranked;
|
|
282
|
+
// Collapse near-duplicate conversation captures (same task re-captured across
|
|
283
|
+
// sessions = distinct rows groupByParent can't merge) so one card per topic
|
|
284
|
+
// reaches decisions/examples/evidence instead of N redundant copies.
|
|
285
|
+
// Conversation rows only; docs pass through. Flag-gated (RIFT_CONV_DEDUP),
|
|
286
|
+
// provable no-op when off. Skipped when the conversation pool has chunk markers
|
|
287
|
+
// (best-chunk text would false-merge distinct conversations — see conversation-dedup).
|
|
288
|
+
if (convDedupEnabled() && !poolHasChunkMarkers(convGrouped)) {
|
|
289
|
+
convRanked = collapseConversationDuplicates(convRanked).ranked;
|
|
290
|
+
}
|
|
291
|
+
// Drop any doc candidates whose source_path points into engine-internal or
|
|
292
|
+
// build-artifact directories. These rows are not project rules — they are
|
|
293
|
+
// raw conversation snapshots, embedding cache files, quarantine drops,
|
|
294
|
+
// compiled JS/TS, node_modules, worktree copies, etc. — and they crowd
|
|
295
|
+
// real project-rule files (CLAUDE.md / AGENTS.md / PROJECT_STATE.md /
|
|
296
|
+
// TODO.md) out of the `rules` and `constraints` buckets. Conversation
|
|
297
|
+
// content is still reachable via `convRanked`.
|
|
298
|
+
const docRankedClean = docRanked.filter((r) => !shouldExcludeDocFromRules(docRows.get(rankedKey(r))?.["source_path"]));
|
|
299
|
+
// Constraints layer an extra filter on top via the contract helper:
|
|
300
|
+
// one-shot agent prompts (`*-prompt.md`) routinely carry "Hard
|
|
301
|
+
// Constraints" sections that match `extractConstraintLines`'s marker
|
|
302
|
+
// gate but are scaffolding, not durable project law. They stay
|
|
303
|
+
// eligible for `rules` (legitimate doc-level evidence) but must not
|
|
304
|
+
// lead `constraints` as project law. Calling
|
|
305
|
+
// `shouldExcludeDocFromConstraints` here — rather than composing the
|
|
306
|
+
// two helpers inline — keeps the constraint-exclusion contract in one
|
|
307
|
+
// place, so any future per-bucket exclusion is picked up automatically.
|
|
308
|
+
const docRankedForConstraints = docRanked.filter((r) => !shouldExcludeDocFromConstraints(docRows.get(rankedKey(r))?.["source_path"]));
|
|
309
|
+
// Re-sort the conversation candidates by query relevance before
|
|
310
|
+
// extracting `decisions` and `examples`. The global rerank() composite
|
|
311
|
+
// weights S_sim at only 55% — quality/tier/freshness can pull a
|
|
312
|
+
// high-confidence but tangential row above a more relevant one, which
|
|
313
|
+
// is the exact REX failure the relevance-first slice closes
|
|
314
|
+
// (docs/feedback/2026-05-14-fact-checking-rex.md, P1 #5). The re-sort
|
|
315
|
+
// is local to the context-pack path; onadit_search and the global
|
|
316
|
+
// reranker are intentionally unchanged.
|
|
317
|
+
const convSorted = sortByRelevanceFirst(convRanked);
|
|
318
|
+
const convByRelevance = asksOtherProjects
|
|
319
|
+
? otherProjectsFirst(convSorted, (id) => otherProjectOf(id) !== undefined)
|
|
320
|
+
: project
|
|
321
|
+
? projectFirst(convSorted, project.idSet)
|
|
322
|
+
: convSorted;
|
|
323
|
+
// Tracker sections read live (canonical-file lane). Trackers aren't indexed,
|
|
324
|
+
// and auto-captured sessions carry no extracted decisions, so without this
|
|
325
|
+
// the decisions and constraints a project wrote down never reach the pack.
|
|
326
|
+
// opts.cwd is the agent's working dir, often a SUBDIR (src/, tests/). The
|
|
327
|
+
// canonical files live at the repo root, so resolve the git top-level first
|
|
328
|
+
// (same resolution probeGitStates does) — otherwise we'd look in the subdir,
|
|
329
|
+
// find nothing, and silently no-op. Falls back to cwd outside a git repo.
|
|
330
|
+
const trackerMatches = canonicalFilesEnabled() && opts.cwd
|
|
331
|
+
? selectCanonicalSections({
|
|
332
|
+
projectRoot: resolveRepoRoot(opts.cwd),
|
|
333
|
+
query: opts.task,
|
|
334
|
+
maxSections: TRACKER_SECTION_POOL,
|
|
335
|
+
})
|
|
336
|
+
: [];
|
|
337
|
+
// Tracker cards fill the slots the search-ranked cards leave free; they
|
|
338
|
+
// never take one. The lane matches on words, and a tracker note that only
|
|
339
|
+
// mentions the subject must not replace a decision that is about it. A
|
|
340
|
+
// tracker section that loses its slot here still reaches the agent as a
|
|
341
|
+
// current-truth card. Each bucket reads the whole pool, so a rule further
|
|
342
|
+
// down is not lost to the cap.
|
|
343
|
+
const convForDecisions = filterByRelevance(convByRelevance, DECISIONS_RELEVANCE_FLOOR);
|
|
344
|
+
// Not after a degraded search: the task's vector did not arrive in time
|
|
345
|
+
// there, and asking for it again would hold the pack a second time. That
|
|
346
|
+
// pack is already marked partial.
|
|
347
|
+
const closeness = embedding && !convRes.degraded
|
|
348
|
+
? await statementCloseness(convForDecisions, convRows, opts.task, embedding, opts.statementWaitMs ?? EMBED_WAIT_MS)
|
|
349
|
+
: NO_CLOSENESS;
|
|
350
|
+
// Sentences were waiting and were not compared: the pack may lack a rule
|
|
351
|
+
// the next one will hold, so it says so rather than look complete.
|
|
352
|
+
if (closeness.missed) {
|
|
353
|
+
degraded = true;
|
|
354
|
+
degradedReason ??= closeness.missed;
|
|
355
|
+
}
|
|
356
|
+
const decisions = [
|
|
357
|
+
...extractDecisions(convForDecisions, convRows, maxPerBucket, otherProjectOf, opts.task, closeness),
|
|
358
|
+
...trackerDecisions(trackerMatches),
|
|
359
|
+
].slice(0, maxPerBucket);
|
|
360
|
+
const examples = buildExamples(filterByRelevance(convByRelevance, EXAMPLES_RELEVANCE_FLOOR), convRows, maxPerBucket, opts.task, otherProjectOf);
|
|
361
|
+
const rules = buildRules(docRankedClean, docRows, maxPerBucket);
|
|
362
|
+
const otherProjects = cwdMatch && opts.sources
|
|
363
|
+
? buildOtherProjects(groupByParent(otherRanked, parentKeyOf(otherRows)).ranked, otherRows, cwdMatch.rootPath, opts.sources, maxPerBucket)
|
|
364
|
+
: [];
|
|
365
|
+
// Rules the user stated in a session come last: they are past discussion,
|
|
366
|
+
// and a rule written in a document or a live tracker outranks it.
|
|
367
|
+
const constraints = [
|
|
368
|
+
...extractConstraints(docRankedForConstraints, docRows, maxPerBucket),
|
|
369
|
+
...trackerConstraints(trackerMatches),
|
|
370
|
+
...userConstraints(convForDecisions, convRows, maxPerBucket, otherProjectOf, opts.task, closeness),
|
|
371
|
+
].slice(0, maxPerBucket);
|
|
372
|
+
// Current Truth Mode v0/v1 — intent-aware evidence partition. Reuses
|
|
373
|
+
// the already-retrieved conv + doc hits; does not change ranking or
|
|
374
|
+
// fetch anything new. v1 adds the git-state probe below so file-backed
|
|
375
|
+
// evidence carries a tracked/untracked/modified/deleted/newer_on_disk
|
|
376
|
+
// signal into the partitioner. See src/retrieval/current-truth.ts +
|
|
377
|
+
// src/retrieval/git-state.ts.
|
|
378
|
+
const intent = classifyEvidenceIntent(opts.task);
|
|
379
|
+
const claimType = classifyClaimType(opts.task);
|
|
380
|
+
// v1: probe git state once per buildContextPack call. We only probe
|
|
381
|
+
// when a project root is available (opts.cwd) — without one, every
|
|
382
|
+
// path returns "unknown" anyway, and we'd be paying for a no-op git
|
|
383
|
+
// invocation. Conversations don't carry source_paths suitable for
|
|
384
|
+
// git probing, so the input set is just the document hits.
|
|
385
|
+
const gitStateInputs = [];
|
|
386
|
+
if (opts.cwd) {
|
|
387
|
+
for (const r of docRankedClean) {
|
|
388
|
+
const row = docRows.get(rankedKey(r));
|
|
389
|
+
const sourcePath = row?.["source_path"] || undefined;
|
|
390
|
+
if (!sourcePath)
|
|
391
|
+
continue;
|
|
392
|
+
const indexedAt = row?.["indexed_at"] || undefined;
|
|
393
|
+
gitStateInputs.push({ sourcePath, indexedAt });
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
const gitStateBySourcePath = opts.cwd
|
|
397
|
+
? probeGitStates(gitStateInputs, { projectRoot: opts.cwd })
|
|
398
|
+
: new Map();
|
|
399
|
+
const evidenceInputs = [
|
|
400
|
+
...convByRelevance.map((r) => ({
|
|
401
|
+
ranked: r,
|
|
402
|
+
row: convRows.get(rankedKey(r)),
|
|
403
|
+
kind: "conversation",
|
|
404
|
+
})),
|
|
405
|
+
...docRankedClean.map((r) => {
|
|
406
|
+
const row = docRows.get(rankedKey(r));
|
|
407
|
+
const sourcePath = row?.["source_path"] || undefined;
|
|
408
|
+
const gs = sourcePath ? gitStateBySourcePath.get(sourcePath) : undefined;
|
|
409
|
+
const input = {
|
|
410
|
+
ranked: r,
|
|
411
|
+
row,
|
|
412
|
+
kind: "document",
|
|
413
|
+
};
|
|
414
|
+
if (gs)
|
|
415
|
+
input.gitState = gs;
|
|
416
|
+
return input;
|
|
417
|
+
}),
|
|
418
|
+
];
|
|
419
|
+
// Tracker sections lead the evidence as tracker-tier inputs. The partitioner
|
|
420
|
+
// below is UNCHANGED and decides placement BY INTENT: tracker docs lead
|
|
421
|
+
// `current_truth` for current_truth/blended, and stay `current_truth`
|
|
422
|
+
// background under reasoning_archive ("what did we decide …" classifies as
|
|
423
|
+
// reasoning_archive, the exact case this lane must cover). No matches, no
|
|
424
|
+
// inputs.
|
|
425
|
+
evidenceInputs.unshift(...canonicalEvidenceInputs(trackerMatches.slice(0, maxPerBucket * 3)));
|
|
426
|
+
const partition = partitionEvidence(evidenceInputs, {
|
|
427
|
+
intent,
|
|
428
|
+
claimType,
|
|
429
|
+
maxPerSection: maxPerBucket,
|
|
430
|
+
...(opts.cwd ? { projectRoot: opts.cwd } : {}),
|
|
431
|
+
...(opts.selfReportsRoot ? { selfReportsRoot: opts.selfReportsRoot } : {}),
|
|
432
|
+
});
|
|
433
|
+
// The fallback list names files a project often keeps. Someone who keeps
|
|
434
|
+
// none of them must not be told to go and read them.
|
|
435
|
+
if (opts.cwd) {
|
|
436
|
+
const roots = [opts.cwd, resolveRepoRoot(opts.cwd) ?? opts.cwd];
|
|
437
|
+
partition.recommended_live_files = partition.recommended_live_files.filter((f) => path.isAbsolute(f.path) || roots.some((root) => fs.existsSync(path.join(root, f.path))));
|
|
438
|
+
}
|
|
439
|
+
const assembled = enforceBudget({ decisions, constraints, examples, rules }, {
|
|
440
|
+
maxBytes,
|
|
441
|
+
task: opts.task,
|
|
442
|
+
intent,
|
|
443
|
+
partition,
|
|
444
|
+
otherProjects,
|
|
445
|
+
otherProjectsFirst: asksOtherProjects,
|
|
446
|
+
degraded,
|
|
447
|
+
...(degradedReason ? { degradedReason } : {}),
|
|
448
|
+
...(embedding ? {} : { lexical: true }),
|
|
449
|
+
...(project ? { projectScope: { root: project.root, conversations: project.rowIds.length } } : {}),
|
|
450
|
+
});
|
|
451
|
+
const pack = {
|
|
452
|
+
task: opts.task,
|
|
453
|
+
intent,
|
|
454
|
+
decisions: assembled.decisions,
|
|
455
|
+
constraints: assembled.constraints,
|
|
456
|
+
examples: assembled.examples,
|
|
457
|
+
rules: assembled.rules,
|
|
458
|
+
total_bytes: assembled.totalBytes,
|
|
459
|
+
truncated: assembled.truncated,
|
|
460
|
+
degraded,
|
|
461
|
+
};
|
|
462
|
+
if (assembled.partition.current_truth.length > 0)
|
|
463
|
+
pack.current_truth = assembled.partition.current_truth;
|
|
464
|
+
if (assembled.partition.past_reasoning.length > 0)
|
|
465
|
+
pack.past_reasoning = assembled.partition.past_reasoning;
|
|
466
|
+
if (assembled.partition.older_memory.length > 0)
|
|
467
|
+
pack.older_memory = assembled.partition.older_memory;
|
|
468
|
+
if (assembled.partition.discounted.length > 0)
|
|
469
|
+
pack.discounted = assembled.partition.discounted;
|
|
470
|
+
if (assembled.partition.recommended_live_files.length > 0)
|
|
471
|
+
pack.recommended_live_files = assembled.partition.recommended_live_files;
|
|
472
|
+
if (assembled.partition.conflicts.length > 0)
|
|
473
|
+
pack.conflicts = assembled.partition.conflicts;
|
|
474
|
+
if (assembled.partition.current_truth_caveat)
|
|
475
|
+
pack.current_truth_caveat = assembled.partition.current_truth_caveat;
|
|
476
|
+
if (assembled.otherProjects.length > 0)
|
|
477
|
+
pack.other_projects = assembled.otherProjects;
|
|
478
|
+
if (degradedReason)
|
|
479
|
+
pack.degraded_reason = degradedReason;
|
|
480
|
+
if (!embedding)
|
|
481
|
+
pack.mode = "lexical";
|
|
482
|
+
if (project)
|
|
483
|
+
pack.project_scope = { root: project.root, conversations: project.rowIds.length };
|
|
484
|
+
return pack;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Drop candidates whose best available relevance signal falls below
|
|
488
|
+
* `floor`. Combines semantic similarity (`S_sim`) and normalized BM25
|
|
489
|
+
* via `max()` so a strong keyword match keeps a row that happens to
|
|
490
|
+
* score weakly on the embedding axis, and a strong semantic match
|
|
491
|
+
* keeps a row that happens to share no tokens. Both signals live in
|
|
492
|
+
* `[0,1]`. Exported so tests can exercise the floor directly with
|
|
493
|
+
* synthetic `RankedResult`s.
|
|
494
|
+
*/
|
|
495
|
+
export function filterByRelevance(ranked, floor) {
|
|
496
|
+
return ranked.filter((r) => Math.max(r.factors.S_sim, r.bm25_normalized) >= floor);
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Re-sort ranked candidates so that query relevance dominates ordering,
|
|
500
|
+
* with the composite rerank score acting only as a tie-breaker.
|
|
501
|
+
*
|
|
502
|
+
* Primary key: `max(S_sim, bm25_normalized)`, descending — the same
|
|
503
|
+
* dual-channel signal `filterByRelevance` already uses, so semantic
|
|
504
|
+
* and keyword evidence are treated symmetrically. Two candidates whose
|
|
505
|
+
* primary keys are within `epsilon` ({@link RELEVANCE_TIE_EPSILON})
|
|
506
|
+
* fall through to the composite `score`, descending — preserving the
|
|
507
|
+
* freshness / quality / tier ordering that the PRD-6.2 reranker
|
|
508
|
+
* encodes when relevance is effectively equal. ID is a final
|
|
509
|
+
* tie-breaker for determinism.
|
|
510
|
+
*
|
|
511
|
+
* Slice motivation: the global reranker weights `S_sim` at only 55%
|
|
512
|
+
* of the composite score, so a confidently-captured but tangential row
|
|
513
|
+
* could outrank a clearly more relevant lower-confidence row in the
|
|
514
|
+
* `decisions` and `examples` buckets. This helper is applied only to
|
|
515
|
+
* the conversation pipeline that feeds those two buckets; `onadit_search`
|
|
516
|
+
* and the global reranker are intentionally untouched. See
|
|
517
|
+
* docs/feedback/2026-05-14-fact-checking-rex.md (P1 #5) for the REX
|
|
518
|
+
* trace that motivated the change.
|
|
519
|
+
*
|
|
520
|
+
* Pure / non-mutating: returns a new array.
|
|
521
|
+
*/
|
|
522
|
+
export function sortByRelevanceFirst(ranked, epsilon = RELEVANCE_TIE_EPSILON) {
|
|
523
|
+
const withKey = ranked.map((r) => ({
|
|
524
|
+
r,
|
|
525
|
+
rel: Math.max(r.factors.S_sim, r.bm25_normalized),
|
|
526
|
+
}));
|
|
527
|
+
withKey.sort((a, b) => {
|
|
528
|
+
if (Math.abs(a.rel - b.rel) > epsilon)
|
|
529
|
+
return b.rel - a.rel;
|
|
530
|
+
if (a.r.score !== b.r.score)
|
|
531
|
+
return b.r.score - a.r.score;
|
|
532
|
+
return a.r.id < b.r.id ? -1 : a.r.id > b.r.id ? 1 : 0;
|
|
533
|
+
});
|
|
534
|
+
return withKey.map((x) => x.r);
|
|
535
|
+
}
|
|
536
|
+
// --- Bucket builders ---
|
|
537
|
+
function extractDecisions(ranked, rows, cap, otherProjectOf, task, closeness) {
|
|
538
|
+
const out = [];
|
|
539
|
+
const seen = new Set();
|
|
540
|
+
for (const r of ranked) {
|
|
541
|
+
if (out.length >= cap)
|
|
542
|
+
break;
|
|
543
|
+
const row = rows.get(rankedKey(r));
|
|
544
|
+
if (!row)
|
|
545
|
+
continue;
|
|
546
|
+
const raw = row["decisions"];
|
|
547
|
+
const list = parseJsonStringArray(raw);
|
|
548
|
+
if (list.length === 0)
|
|
549
|
+
continue;
|
|
550
|
+
const timestamp = row["indexed_at"] || undefined;
|
|
551
|
+
const source = row["source"] || "conversation";
|
|
552
|
+
for (const d of list) {
|
|
553
|
+
if (out.length >= cap)
|
|
554
|
+
break;
|
|
555
|
+
const quote = userQuote(d, "decision", r, row, task, closeness);
|
|
556
|
+
if (quote === "skip")
|
|
557
|
+
continue;
|
|
558
|
+
const text = quote?.text ?? truncate(collapseWhitespace(d), ITEM_TEXT_MAX);
|
|
559
|
+
if (!text)
|
|
560
|
+
continue;
|
|
561
|
+
const key = text.toLowerCase();
|
|
562
|
+
if (seen.has(key))
|
|
563
|
+
continue;
|
|
564
|
+
seen.add(key);
|
|
565
|
+
const card = { text, source_id: r.id, source, ...quote?.ref };
|
|
566
|
+
if (timestamp)
|
|
567
|
+
card.timestamp = timestamp;
|
|
568
|
+
const otherProject = otherProjectOf(r.id);
|
|
569
|
+
if (otherProject)
|
|
570
|
+
card.project = otherProject;
|
|
571
|
+
out.push(card);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
return out;
|
|
575
|
+
}
|
|
576
|
+
/** What a session is about, short enough to sit on every card that cites it. */
|
|
577
|
+
const SESSION_LABEL_MAX = 80;
|
|
578
|
+
const NO_CLOSENESS = { close: new Set() };
|
|
579
|
+
/**
|
|
580
|
+
* Compare the task with the user's sentences that the word test would drop,
|
|
581
|
+
* in the candidate sessions only. Nothing new leaves the machine: the task is
|
|
582
|
+
* already embedded for the search and each sentence is part of a transcript
|
|
583
|
+
* embedded at capture. A failed or slow request leaves the word test in
|
|
584
|
+
* charge and is reported as `missed`; its late answer still fills the cache,
|
|
585
|
+
* so the next pack for the same sessions has it.
|
|
586
|
+
*/
|
|
587
|
+
async function statementCloseness(ranked, rows, task, embedding, waitMs) {
|
|
588
|
+
const bar = embedding.name === STATEMENT_CLOSENESS_PROVIDER ? STATEMENT_CLOSENESS_MIN[embedding.model] : undefined;
|
|
589
|
+
if (bar === undefined)
|
|
590
|
+
return NO_CLOSENESS;
|
|
591
|
+
const quotes = new Set();
|
|
592
|
+
for (const r of ranked) {
|
|
593
|
+
for (const entry of parseJsonStringArray(rows.get(rankedKey(r))?.["decisions"])) {
|
|
594
|
+
const quote = decodeUserStatement(entry)?.quote;
|
|
595
|
+
if (quote && quote.length <= MAX_QUOTE_CHARS && !holdsQuestionSubject(quote, task))
|
|
596
|
+
quotes.add(quote);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
if (quotes.size === 0)
|
|
600
|
+
return NO_CLOSENESS;
|
|
601
|
+
const key = (quote) => `${embedding.model}\u0000${quote}`;
|
|
602
|
+
const uncompared = [...quotes].filter((q) => !statementVectors.has(key(q)));
|
|
603
|
+
const missing = uncompared.slice(0, STATEMENT_COMPARE_MAX);
|
|
604
|
+
const waiting = uncompared.length - missing.length;
|
|
605
|
+
const fetched = (async () => {
|
|
606
|
+
if (missing.length === 0)
|
|
607
|
+
return;
|
|
608
|
+
const vectors = await embedding.embedBatch(missing);
|
|
609
|
+
for (const [i, quote] of missing.entries()) {
|
|
610
|
+
const vector = vectors[i];
|
|
611
|
+
if (!vector)
|
|
612
|
+
continue;
|
|
613
|
+
if (statementVectors.size >= STATEMENT_VECTOR_CACHE_MAX) {
|
|
614
|
+
statementVectors.delete(statementVectors.keys().next().value);
|
|
615
|
+
}
|
|
616
|
+
statementVectors.set(key(quote), vector);
|
|
617
|
+
}
|
|
618
|
+
})();
|
|
619
|
+
let timer;
|
|
620
|
+
const deadline = new Promise((_, reject) => {
|
|
621
|
+
timer = setTimeout(() => reject(new Error(`no answer within ${waitMs} ms`)), waitMs);
|
|
622
|
+
});
|
|
623
|
+
try {
|
|
624
|
+
const [taskVector] = await Promise.race([Promise.all([embedding.embed(task), fetched]), deadline]);
|
|
625
|
+
const close = new Set();
|
|
626
|
+
for (const quote of quotes) {
|
|
627
|
+
const vector = statementVectors.get(key(quote));
|
|
628
|
+
if (vector && cosine(taskVector, vector) >= bar)
|
|
629
|
+
close.add(quote);
|
|
630
|
+
}
|
|
631
|
+
if (waiting === 0)
|
|
632
|
+
return { close };
|
|
633
|
+
return {
|
|
634
|
+
close,
|
|
635
|
+
missed: `partial pack: ${waiting} of your own statements are still to be compared with the task; a rule you stated may be missing`,
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
catch (err) {
|
|
639
|
+
fetched.catch(() => undefined);
|
|
640
|
+
const cause = err instanceof Error ? err.message : String(err);
|
|
641
|
+
return {
|
|
642
|
+
close: NO_CLOSENESS.close,
|
|
643
|
+
missed: `partial pack: your own statements were not compared with the task (${cause}); a rule you stated may be missing`,
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
finally {
|
|
647
|
+
clearTimeout(timer);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
function cosine(a, b) {
|
|
651
|
+
if (a.length !== b.length)
|
|
652
|
+
return 0;
|
|
653
|
+
let dot = 0;
|
|
654
|
+
let normA = 0;
|
|
655
|
+
let normB = 0;
|
|
656
|
+
for (let i = 0; i < a.length; i++) {
|
|
657
|
+
dot += a[i] * b[i];
|
|
658
|
+
normA += a[i] * a[i];
|
|
659
|
+
normB += b[i] * b[i];
|
|
660
|
+
}
|
|
661
|
+
return normA && normB ? dot / Math.sqrt(normA * normB) : 0;
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Read one entry of a row's `decisions` column as a sentence the user typed.
|
|
665
|
+
* Null for an entry capture did not mark (a manual save or an import), which
|
|
666
|
+
* keeps its existing treatment. "skip" for a marked entry of the other kind, or
|
|
667
|
+
* one that does not hold the question's subject: a session can match the task
|
|
668
|
+
* while most of what the user ruled in it is about something else.
|
|
669
|
+
*/
|
|
670
|
+
function userQuote(entry, kind, r, row, task, closeness) {
|
|
671
|
+
const statement = decodeUserStatement(entry);
|
|
672
|
+
if (!statement)
|
|
673
|
+
return null;
|
|
674
|
+
if (statement.kind !== kind)
|
|
675
|
+
return "skip";
|
|
676
|
+
if (!holdsQuestionSubject(statement.quote, task) && !closeness.close.has(statement.quote))
|
|
677
|
+
return "skip";
|
|
678
|
+
// Whole or not at all. Cut short, a rule can lose the clause that limits
|
|
679
|
+
// it and still read as something the user said.
|
|
680
|
+
const text = collapseWhitespace(statement.quote);
|
|
681
|
+
if (text.length > MAX_QUOTE_CHARS)
|
|
682
|
+
return "skip";
|
|
683
|
+
const ref = {
|
|
684
|
+
said_by: "user",
|
|
685
|
+
session: truncate(collapseWhitespace(row["summary"] || ""), SESSION_LABEL_MAX),
|
|
686
|
+
source_table: r.source_table,
|
|
687
|
+
};
|
|
688
|
+
const offset = (row["content"] || "").indexOf(statement.quote);
|
|
689
|
+
if (offset >= 0)
|
|
690
|
+
ref.offset = offset;
|
|
691
|
+
return { text, ref };
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Rules the user stated in a captured session of this project. A rule set in
|
|
695
|
+
* another project's session is not this project's rule, so it is left out.
|
|
696
|
+
*/
|
|
697
|
+
function userConstraints(ranked, rows, cap, otherProjectOf, task, closeness) {
|
|
698
|
+
const out = [];
|
|
699
|
+
const seen = new Set();
|
|
700
|
+
for (const r of ranked) {
|
|
701
|
+
if (out.length >= cap)
|
|
702
|
+
break;
|
|
703
|
+
const row = rows.get(rankedKey(r));
|
|
704
|
+
if (!row || otherProjectOf(r.id))
|
|
705
|
+
continue;
|
|
706
|
+
for (const entry of parseJsonStringArray(row["decisions"])) {
|
|
707
|
+
if (out.length >= cap)
|
|
708
|
+
break;
|
|
709
|
+
const quote = userQuote(entry, "constraint", r, row, task, closeness);
|
|
710
|
+
if (!quote || quote === "skip")
|
|
711
|
+
continue;
|
|
712
|
+
const key = quote.text.toLowerCase();
|
|
713
|
+
if (seen.has(key))
|
|
714
|
+
continue;
|
|
715
|
+
seen.add(key);
|
|
716
|
+
const card = {
|
|
717
|
+
text: quote.text,
|
|
718
|
+
source_id: r.id,
|
|
719
|
+
source: row["source"] || "conversation",
|
|
720
|
+
...quote.ref,
|
|
721
|
+
};
|
|
722
|
+
const timestamp = row["indexed_at"] || undefined;
|
|
723
|
+
if (timestamp)
|
|
724
|
+
card.timestamp = timestamp;
|
|
725
|
+
out.push(card);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
return out;
|
|
729
|
+
}
|
|
730
|
+
/** Matched items under a tracker's decisions heading, as decision cards. */
|
|
731
|
+
function trackerDecisions(matches) {
|
|
732
|
+
const out = [];
|
|
733
|
+
for (const m of matches) {
|
|
734
|
+
if (m.group !== "decision")
|
|
735
|
+
continue;
|
|
736
|
+
const text = truncate(collapseWhitespace(cleanItemText(m.section.text)), ITEM_TEXT_MAX);
|
|
737
|
+
if (!text)
|
|
738
|
+
continue;
|
|
739
|
+
const sourcePath = `${m.fileName}:${m.section.line}`;
|
|
740
|
+
const card = {
|
|
741
|
+
text,
|
|
742
|
+
source_id: `canonical:${sourcePath}`,
|
|
743
|
+
source: "tracker",
|
|
744
|
+
source_path: sourcePath,
|
|
745
|
+
};
|
|
746
|
+
const date = /^\d{4}-\d{2}-\d{2}/.exec(text)?.[0];
|
|
747
|
+
if (date)
|
|
748
|
+
card.timestamp = date;
|
|
749
|
+
out.push(card);
|
|
750
|
+
}
|
|
751
|
+
return out;
|
|
752
|
+
}
|
|
753
|
+
/** A tracker heading whose items are standing rules as written. */
|
|
754
|
+
const GUARDRAIL_HEADING = /\b(guardrails?|constraints?)\b/i;
|
|
755
|
+
/** Trackers are often written in French; the doc-lane markers are English only. */
|
|
756
|
+
const FRENCH_MARKER_AT_START = /^(?:ne\s+(?:pas|rien|jamais|plus)|jamais|toujours|interdit)\b/i;
|
|
757
|
+
/**
|
|
758
|
+
* Constraint clauses from matched tracker items. A tracker states its rules
|
|
759
|
+
* mid-sentence ("Keep email parked; do not add another source during the
|
|
760
|
+
* pilot"), so each item is split into clauses before the marker test.
|
|
761
|
+
*/
|
|
762
|
+
function trackerConstraints(matches) {
|
|
763
|
+
const out = [];
|
|
764
|
+
const seen = new Set();
|
|
765
|
+
for (const m of matches) {
|
|
766
|
+
const item = cleanItemText(m.section.text);
|
|
767
|
+
const clauses = item.split(/(?<=[.;:])\s+|\s+—\s+|\n/);
|
|
768
|
+
const lines = GUARDRAIL_HEADING.test(m.section.parent)
|
|
769
|
+
? [collapseWhitespace(item)]
|
|
770
|
+
: [
|
|
771
|
+
...extractConstraintLines(clauses.join("\n")),
|
|
772
|
+
...clauses
|
|
773
|
+
.map((clause) => collapseWhitespace(clause.replace(/[.;]+\s*$/, "")))
|
|
774
|
+
.filter((clause) => FRENCH_MARKER_AT_START.test(clause)),
|
|
775
|
+
];
|
|
776
|
+
const sourcePath = `${m.fileName}:${m.section.line}`;
|
|
777
|
+
for (const line of lines) {
|
|
778
|
+
const text = truncate(line, ITEM_TEXT_MAX);
|
|
779
|
+
const key = text.toLowerCase();
|
|
780
|
+
if (!text || seen.has(key))
|
|
781
|
+
continue;
|
|
782
|
+
seen.add(key);
|
|
783
|
+
out.push({ text, source_id: `canonical:${sourcePath}`, source_path: sourcePath });
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
return out;
|
|
787
|
+
}
|
|
788
|
+
function buildExamples(ranked, rows, cap, task, otherProjectOf) {
|
|
789
|
+
const out = [];
|
|
790
|
+
for (const r of ranked) {
|
|
791
|
+
if (out.length >= cap)
|
|
792
|
+
break;
|
|
793
|
+
const row = rows.get(rankedKey(r));
|
|
794
|
+
const fullContent = row?.["content"] || r.content || "";
|
|
795
|
+
const summary = truncate(collapseWhitespace(row?.["summary"] || fullContent), SNIPPET_MAX);
|
|
796
|
+
if (!summary)
|
|
797
|
+
continue;
|
|
798
|
+
const title = deriveExampleTitle(row, summary);
|
|
799
|
+
const source = row?.["source"] || "conversation";
|
|
800
|
+
const timestamp = row?.["indexed_at"] || undefined;
|
|
801
|
+
const { content_bytes, content_tokens_estimate } = computeContentSize(fullContent);
|
|
802
|
+
const card = {
|
|
803
|
+
id: r.id,
|
|
804
|
+
title,
|
|
805
|
+
source,
|
|
806
|
+
summary,
|
|
807
|
+
content_bytes,
|
|
808
|
+
content_tokens_estimate,
|
|
809
|
+
expand: {
|
|
810
|
+
route: "/search",
|
|
811
|
+
// Size fields are mirrored into `expand.params` so an agent that
|
|
812
|
+
// copy-pastes the pointer sees the warning at the exact moment it
|
|
813
|
+
// decides whether to spend context on `detail="full"`.
|
|
814
|
+
params: {
|
|
815
|
+
id: r.id,
|
|
816
|
+
tier: r.source_table === "conversations_cold" ? "cold" : "hot",
|
|
817
|
+
source_table: r.source_table,
|
|
818
|
+
detail: "full",
|
|
819
|
+
content_bytes,
|
|
820
|
+
content_tokens_estimate,
|
|
821
|
+
},
|
|
822
|
+
},
|
|
823
|
+
};
|
|
824
|
+
if (timestamp)
|
|
825
|
+
card.timestamp = timestamp;
|
|
826
|
+
const otherProject = otherProjectOf(r.id);
|
|
827
|
+
if (otherProject)
|
|
828
|
+
card.project = otherProject;
|
|
829
|
+
const [passage] = extractPassages(fullContent, task, { max: 1, windowChars: PASSAGE_MAX });
|
|
830
|
+
if (passage) {
|
|
831
|
+
card.passage = {
|
|
832
|
+
text: passage.text,
|
|
833
|
+
offset: passage.start,
|
|
834
|
+
matched: `${passage.terms_matched}/${passage.terms_total}`,
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
out.push(card);
|
|
838
|
+
}
|
|
839
|
+
return out;
|
|
840
|
+
}
|
|
841
|
+
function buildRules(ranked, rows, cap) {
|
|
842
|
+
const out = [];
|
|
843
|
+
for (const r of ranked) {
|
|
844
|
+
if (out.length >= cap)
|
|
845
|
+
break;
|
|
846
|
+
const row = rows.get(rankedKey(r));
|
|
847
|
+
const content = row?.["content"] || r.content || "";
|
|
848
|
+
const snippet = truncate(collapseWhitespace(content), SNIPPET_MAX);
|
|
849
|
+
if (!snippet)
|
|
850
|
+
continue;
|
|
851
|
+
const sourcePath = row?.["source_path"] || "";
|
|
852
|
+
const title = deriveRuleTitle(row, sourcePath, snippet);
|
|
853
|
+
const { content_bytes, content_tokens_estimate } = computeContentSize(content);
|
|
854
|
+
const card = {
|
|
855
|
+
id: r.id,
|
|
856
|
+
title,
|
|
857
|
+
snippet,
|
|
858
|
+
content_bytes,
|
|
859
|
+
content_tokens_estimate,
|
|
860
|
+
expand: {
|
|
861
|
+
route: "/search",
|
|
862
|
+
params: {
|
|
863
|
+
id: r.id,
|
|
864
|
+
tier: "structured_doc",
|
|
865
|
+
source_table: r.source_table,
|
|
866
|
+
detail: "full",
|
|
867
|
+
content_bytes,
|
|
868
|
+
content_tokens_estimate,
|
|
869
|
+
},
|
|
870
|
+
},
|
|
871
|
+
};
|
|
872
|
+
if (sourcePath)
|
|
873
|
+
card.source_path = sourcePath;
|
|
874
|
+
out.push(card);
|
|
875
|
+
}
|
|
876
|
+
return out;
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Documents that match the task and sit in a configured project other than
|
|
880
|
+
* the current one. They become reference cards labelled with their project,
|
|
881
|
+
* and stay out of rules, constraints and current truth: another project's
|
|
882
|
+
* "NEVER" is not this project's law.
|
|
883
|
+
*/
|
|
884
|
+
function buildOtherProjects(ranked, rows, currentRoot, sources, cap) {
|
|
885
|
+
const out = [];
|
|
886
|
+
for (const r of filterByRelevance(ranked, OTHER_PROJECTS_RELEVANCE_FLOOR)) {
|
|
887
|
+
if (out.length >= cap)
|
|
888
|
+
break;
|
|
889
|
+
const row = rows.get(rankedKey(r));
|
|
890
|
+
const sourcePath = row?.["source_path"] || "";
|
|
891
|
+
if (!sourcePath || shouldExcludeDocFromRules(sourcePath))
|
|
892
|
+
continue;
|
|
893
|
+
const home = resolveCwdRoot(sourcePath, sources);
|
|
894
|
+
if (!home || home.rootPath === currentRoot)
|
|
895
|
+
continue;
|
|
896
|
+
const content = row?.["content"] || r.content || "";
|
|
897
|
+
const snippet = truncate(collapseWhitespace(content), SNIPPET_MAX);
|
|
898
|
+
if (!snippet)
|
|
899
|
+
continue;
|
|
900
|
+
const { content_bytes, content_tokens_estimate } = computeContentSize(content);
|
|
901
|
+
out.push({
|
|
902
|
+
id: r.id,
|
|
903
|
+
title: deriveRuleTitle(row, sourcePath, snippet),
|
|
904
|
+
project: home.projectName,
|
|
905
|
+
snippet,
|
|
906
|
+
source_path: sourcePath,
|
|
907
|
+
content_bytes,
|
|
908
|
+
content_tokens_estimate,
|
|
909
|
+
expand: {
|
|
910
|
+
route: "/search",
|
|
911
|
+
params: {
|
|
912
|
+
id: r.id,
|
|
913
|
+
tier: "structured_doc",
|
|
914
|
+
source_table: r.source_table,
|
|
915
|
+
detail: "full",
|
|
916
|
+
content_bytes,
|
|
917
|
+
content_tokens_estimate,
|
|
918
|
+
},
|
|
919
|
+
},
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
return out;
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Pull constraint-shaped lines out of the matching rule documents. Looks
|
|
926
|
+
* for classic imperative markers (MUST/MUST NOT/NEVER/DO NOT/ALWAYS/AVOID)
|
|
927
|
+
* which are the idiom for CLAUDE.md / AGENTS.md / PRD-style project rules.
|
|
928
|
+
* Falls back silently if none found — constraints is the bucket most
|
|
929
|
+
* likely to be empty, by design.
|
|
930
|
+
*/
|
|
931
|
+
function extractConstraints(ranked, rows, cap) {
|
|
932
|
+
const out = [];
|
|
933
|
+
const seen = new Set();
|
|
934
|
+
for (const r of ranked) {
|
|
935
|
+
if (out.length >= cap)
|
|
936
|
+
break;
|
|
937
|
+
const row = rows.get(rankedKey(r));
|
|
938
|
+
const content = row?.["content"] || r.content;
|
|
939
|
+
if (!content)
|
|
940
|
+
continue;
|
|
941
|
+
const lines = extractConstraintLines(content);
|
|
942
|
+
if (lines.length === 0)
|
|
943
|
+
continue;
|
|
944
|
+
const sourcePath = row?.["source_path"] || undefined;
|
|
945
|
+
for (const line of lines) {
|
|
946
|
+
if (out.length >= cap)
|
|
947
|
+
break;
|
|
948
|
+
const text = truncate(line, ITEM_TEXT_MAX);
|
|
949
|
+
const key = text.toLowerCase();
|
|
950
|
+
if (seen.has(key))
|
|
951
|
+
continue;
|
|
952
|
+
seen.add(key);
|
|
953
|
+
const card = { text, source_id: r.id };
|
|
954
|
+
if (sourcePath)
|
|
955
|
+
card.source_path = sourcePath;
|
|
956
|
+
out.push(card);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
return out;
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* The idiom we are matching is project-law: "MUST run pnpm check",
|
|
963
|
+
* "NEVER commit secrets", "Do not modify files outside this repo".
|
|
964
|
+
* Real constraints put the imperative word at the start of the line.
|
|
965
|
+
* Mid-line occurrences are almost always narrative prose, JSON values,
|
|
966
|
+
* or quoted excerpts — we'd rather drop those than admit them.
|
|
967
|
+
*/
|
|
968
|
+
const MARKER_AT_START = /^(?:MUST(?:\s+NOT)?|NEVER|DO\s+NOT|DON'T|ALWAYS|AVOID|REQUIRED|FORBIDDEN)\b/i;
|
|
969
|
+
/** Bullet or numbered list prefix, stripped before checking for the marker. */
|
|
970
|
+
const LIST_PREFIX = /^\s*(?:[-*+]|\d+[.)]|\(\d+\))\s+/;
|
|
971
|
+
/** Leading markdown emphasis (`**`, `__`), stripped before checking. */
|
|
972
|
+
const EMPHASIS_PREFIX = /^(?:\*+|_+)\s*/;
|
|
973
|
+
/**
|
|
974
|
+
* Reject lines that look like a JSON/YAML fragment, a quoted transcript
|
|
975
|
+
* snippet, or other structured-data debris. These are the classic
|
|
976
|
+
* false-positive shapes from Slice 5 validation: raw conversation JSON
|
|
977
|
+
* and excerpt blobs that happen to contain marker words inside quoted
|
|
978
|
+
* values get pulled into the `constraints` bucket as if they were
|
|
979
|
+
* project law.
|
|
980
|
+
*/
|
|
981
|
+
function looksLikeStructuredFragment(line) {
|
|
982
|
+
// JSON key-value: `"content": "..."`, `"excerpt": "..."`, etc.
|
|
983
|
+
if (/^"[^"]+"\s*:/.test(line))
|
|
984
|
+
return true;
|
|
985
|
+
// JSON structural punctuation anywhere — a real constraint line would
|
|
986
|
+
// not contain `{` or `}`.
|
|
987
|
+
if (/[{}]/.test(line))
|
|
988
|
+
return true;
|
|
989
|
+
// Line opens with a quote or backtick → quoted transcript/code snippet.
|
|
990
|
+
if (/^["'`]/.test(line))
|
|
991
|
+
return true;
|
|
992
|
+
return false;
|
|
993
|
+
}
|
|
994
|
+
export function extractConstraintLines(content) {
|
|
995
|
+
const out = [];
|
|
996
|
+
for (const raw of content.split(/\r?\n/)) {
|
|
997
|
+
const trimmed = raw.trim();
|
|
998
|
+
if (!trimmed)
|
|
999
|
+
continue;
|
|
1000
|
+
if (looksLikeStructuredFragment(trimmed))
|
|
1001
|
+
continue;
|
|
1002
|
+
const body = trimmed.replace(LIST_PREFIX, "").replace(EMPHASIS_PREFIX, "");
|
|
1003
|
+
if (!MARKER_AT_START.test(body))
|
|
1004
|
+
continue;
|
|
1005
|
+
const cleaned = collapseWhitespace(body.replace(/[.?!]+\s*$/, ""));
|
|
1006
|
+
out.push(cleaned);
|
|
1007
|
+
}
|
|
1008
|
+
return out;
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Greedy round-robin fill: start with empty buckets, pull one item at a
|
|
1012
|
+
* time from each input bucket in a fixed order, add only if it fits in
|
|
1013
|
+
* the remaining budget. Guarantees each bucket gets a fair shot even
|
|
1014
|
+
* when one bucket's items would otherwise crowd the budget.
|
|
1015
|
+
*
|
|
1016
|
+
* `totalBytes` is seeded from the serialized response envelope (task +
|
|
1017
|
+
* degraded flags + empty-bucket overhead) so the returned value reflects
|
|
1018
|
+
* the whole payload, not just bucket contents — `max_bytes` is a contract
|
|
1019
|
+
* on response size.
|
|
1020
|
+
*/
|
|
1021
|
+
function enforceBudget(input, ctx) {
|
|
1022
|
+
const { maxBytes } = ctx;
|
|
1023
|
+
const order = [
|
|
1024
|
+
"decisions",
|
|
1025
|
+
"constraints",
|
|
1026
|
+
"rules",
|
|
1027
|
+
"examples",
|
|
1028
|
+
];
|
|
1029
|
+
const queues = {
|
|
1030
|
+
decisions: [...input.decisions],
|
|
1031
|
+
constraints: [...input.constraints],
|
|
1032
|
+
examples: [...input.examples],
|
|
1033
|
+
rules: [...input.rules],
|
|
1034
|
+
};
|
|
1035
|
+
const output = {
|
|
1036
|
+
decisions: [],
|
|
1037
|
+
constraints: [],
|
|
1038
|
+
examples: [],
|
|
1039
|
+
rules: [],
|
|
1040
|
+
};
|
|
1041
|
+
// Current-truth-mode partition shares the same byte budget. We seed
|
|
1042
|
+
// outputs with copies and copy-back any items that fit. Recommended
|
|
1043
|
+
// live files are small and high-value — fill first.
|
|
1044
|
+
const partitionOut = {
|
|
1045
|
+
current_truth: [],
|
|
1046
|
+
past_reasoning: [],
|
|
1047
|
+
older_memory: [],
|
|
1048
|
+
discounted: [],
|
|
1049
|
+
recommended_live_files: [],
|
|
1050
|
+
conflicts: [],
|
|
1051
|
+
...(ctx.partition.current_truth_caveat
|
|
1052
|
+
? { current_truth_caveat: ctx.partition.current_truth_caveat }
|
|
1053
|
+
: {}),
|
|
1054
|
+
};
|
|
1055
|
+
const partitionQueues = {
|
|
1056
|
+
current_truth: [...ctx.partition.current_truth],
|
|
1057
|
+
past_reasoning: [...ctx.partition.past_reasoning],
|
|
1058
|
+
older_memory: [...ctx.partition.older_memory],
|
|
1059
|
+
discounted: [...ctx.partition.discounted],
|
|
1060
|
+
recommended_live_files: [...ctx.partition.recommended_live_files],
|
|
1061
|
+
conflicts: [...ctx.partition.conflicts],
|
|
1062
|
+
};
|
|
1063
|
+
let totalBytes = envelopeBytes(output, ctx);
|
|
1064
|
+
let truncated = false;
|
|
1065
|
+
// Pass 1: conflicts + recommended_live_files — small, high-value entries
|
|
1066
|
+
// the asker needs first (a surfaced conflict is the whole point of the
|
|
1067
|
+
// mode). Fill conflicts before live files; both before the bulk buckets.
|
|
1068
|
+
while (partitionQueues.conflicts.length > 0) {
|
|
1069
|
+
const item = partitionQueues.conflicts[0];
|
|
1070
|
+
const added = itemBytes(item);
|
|
1071
|
+
if (totalBytes + added > maxBytes) {
|
|
1072
|
+
truncated = true;
|
|
1073
|
+
break;
|
|
1074
|
+
}
|
|
1075
|
+
partitionQueues.conflicts.shift();
|
|
1076
|
+
partitionOut.conflicts.push(item);
|
|
1077
|
+
totalBytes += added;
|
|
1078
|
+
}
|
|
1079
|
+
while (partitionQueues.recommended_live_files.length > 0) {
|
|
1080
|
+
const item = partitionQueues.recommended_live_files[0];
|
|
1081
|
+
const added = itemBytes(item);
|
|
1082
|
+
if (totalBytes + added > maxBytes) {
|
|
1083
|
+
truncated = true;
|
|
1084
|
+
break;
|
|
1085
|
+
}
|
|
1086
|
+
partitionQueues.recommended_live_files.shift();
|
|
1087
|
+
partitionOut.recommended_live_files.push(item);
|
|
1088
|
+
totalBytes += added;
|
|
1089
|
+
}
|
|
1090
|
+
// Pass 1b: the best tracker section read live is placed before the
|
|
1091
|
+
// round-robin, so the project's own current answer is never lost to the
|
|
1092
|
+
// budget. The other tracker sections take their turn below like any card.
|
|
1093
|
+
if (partitionQueues.current_truth[0]?.id.startsWith("canonical:")) {
|
|
1094
|
+
const item = partitionQueues.current_truth[0];
|
|
1095
|
+
const added = itemBytes(item);
|
|
1096
|
+
if (totalBytes + added > maxBytes) {
|
|
1097
|
+
truncated = true;
|
|
1098
|
+
}
|
|
1099
|
+
else {
|
|
1100
|
+
partitionQueues.current_truth.shift();
|
|
1101
|
+
partitionOut.current_truth.push(item);
|
|
1102
|
+
totalBytes += added;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
// Other-project documents: before the round-robin when the task asks for
|
|
1106
|
+
// them, after it otherwise, so by default they never take a byte from the
|
|
1107
|
+
// project's own evidence.
|
|
1108
|
+
const otherQueue = [...ctx.otherProjects];
|
|
1109
|
+
const otherOut = [];
|
|
1110
|
+
const fillOtherProjects = () => {
|
|
1111
|
+
while (otherQueue.length > 0) {
|
|
1112
|
+
const item = otherQueue[0];
|
|
1113
|
+
// The section key itself (`,"other_projects":[]`) ships with the first card.
|
|
1114
|
+
const added = itemBytes(item) + (otherOut.length === 0 ? OTHER_PROJECTS_KEY_BYTES : 0);
|
|
1115
|
+
if (totalBytes + added > maxBytes) {
|
|
1116
|
+
truncated = true;
|
|
1117
|
+
break;
|
|
1118
|
+
}
|
|
1119
|
+
otherQueue.shift();
|
|
1120
|
+
otherOut.push(item);
|
|
1121
|
+
totalBytes += added;
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
if (ctx.otherProjectsFirst)
|
|
1125
|
+
fillOtherProjects();
|
|
1126
|
+
// Pass 2: round-robin across legacy buckets and partition sections so
|
|
1127
|
+
// every section gets a fair shot even when one would otherwise crowd
|
|
1128
|
+
// the budget.
|
|
1129
|
+
const partitionOrder = [
|
|
1130
|
+
"current_truth",
|
|
1131
|
+
"past_reasoning",
|
|
1132
|
+
"older_memory",
|
|
1133
|
+
"discounted",
|
|
1134
|
+
];
|
|
1135
|
+
let progressed = true;
|
|
1136
|
+
while (progressed) {
|
|
1137
|
+
progressed = false;
|
|
1138
|
+
for (const key of order) {
|
|
1139
|
+
const q = queues[key];
|
|
1140
|
+
if (q.length === 0)
|
|
1141
|
+
continue;
|
|
1142
|
+
const item = q[0];
|
|
1143
|
+
const addedBytes = itemBytes(item);
|
|
1144
|
+
if (totalBytes + addedBytes > maxBytes) {
|
|
1145
|
+
truncated = true;
|
|
1146
|
+
continue;
|
|
1147
|
+
}
|
|
1148
|
+
q.shift();
|
|
1149
|
+
output[key].push(item);
|
|
1150
|
+
totalBytes += addedBytes;
|
|
1151
|
+
progressed = true;
|
|
1152
|
+
}
|
|
1153
|
+
for (const key of partitionOrder) {
|
|
1154
|
+
const q = partitionQueues[key];
|
|
1155
|
+
if (q.length === 0)
|
|
1156
|
+
continue;
|
|
1157
|
+
const item = q[0];
|
|
1158
|
+
const added = itemBytes(item);
|
|
1159
|
+
if (totalBytes + added > maxBytes) {
|
|
1160
|
+
truncated = true;
|
|
1161
|
+
continue;
|
|
1162
|
+
}
|
|
1163
|
+
q.shift();
|
|
1164
|
+
partitionOut[key].push(item);
|
|
1165
|
+
totalBytes += added;
|
|
1166
|
+
progressed = true;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
// Pass 3: a rule the user stated about this task that the rotation left out
|
|
1170
|
+
// takes the place of other past discussion, which is what it is itself: the
|
|
1171
|
+
// last cards of the discounted, older-memory and past-reasoning sections,
|
|
1172
|
+
// in that order. Nothing else gives way to it: not a document's or a
|
|
1173
|
+
// tracker's rule, a decision, current truth or a conflict. And it is not
|
|
1174
|
+
// shown while a rule that outranks it in the bucket is still waiting.
|
|
1175
|
+
while (queues.constraints[0]?.said_by === "user") {
|
|
1176
|
+
const item = queues.constraints[0];
|
|
1177
|
+
const needed = totalBytes + itemBytes(item) - maxBytes;
|
|
1178
|
+
const givesWay = [];
|
|
1179
|
+
let freed = 0;
|
|
1180
|
+
for (const key of USER_RULE_REPLACES) {
|
|
1181
|
+
for (let i = partitionOut[key].length - 1; i >= 0 && freed < needed; i--) {
|
|
1182
|
+
freed += itemBytes(partitionOut[key][i]);
|
|
1183
|
+
givesWay.push(key);
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
if (freed < needed)
|
|
1187
|
+
break;
|
|
1188
|
+
for (const key of givesWay) {
|
|
1189
|
+
// Back on its queue, so the pack still says something was left out.
|
|
1190
|
+
const card = partitionOut[key].pop();
|
|
1191
|
+
partitionQueues[key].unshift(card);
|
|
1192
|
+
totalBytes -= itemBytes(card);
|
|
1193
|
+
}
|
|
1194
|
+
queues.constraints.shift();
|
|
1195
|
+
output.constraints.push(item);
|
|
1196
|
+
totalBytes += itemBytes(item);
|
|
1197
|
+
}
|
|
1198
|
+
if (!ctx.otherProjectsFirst)
|
|
1199
|
+
fillOtherProjects();
|
|
1200
|
+
// Any items still sitting in the queues were dropped for budget.
|
|
1201
|
+
for (const key of order) {
|
|
1202
|
+
if (queues[key].length > 0) {
|
|
1203
|
+
truncated = true;
|
|
1204
|
+
break;
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
if (!truncated) {
|
|
1208
|
+
for (const key of partitionOrder) {
|
|
1209
|
+
if (partitionQueues[key].length > 0) {
|
|
1210
|
+
truncated = true;
|
|
1211
|
+
break;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
if (partitionQueues.recommended_live_files.length > 0)
|
|
1215
|
+
truncated = true;
|
|
1216
|
+
if (partitionQueues.conflicts.length > 0)
|
|
1217
|
+
truncated = true;
|
|
1218
|
+
}
|
|
1219
|
+
return {
|
|
1220
|
+
decisions: output.decisions,
|
|
1221
|
+
constraints: output.constraints,
|
|
1222
|
+
examples: output.examples,
|
|
1223
|
+
rules: output.rules,
|
|
1224
|
+
partition: partitionOut,
|
|
1225
|
+
otherProjects: otherOut,
|
|
1226
|
+
totalBytes,
|
|
1227
|
+
truncated,
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
/** The sections a user's own rule may take room from, first to give way first. */
|
|
1231
|
+
const USER_RULE_REPLACES = ["discounted", "older_memory", "past_reasoning"];
|
|
1232
|
+
const OTHER_PROJECTS_KEY_BYTES = Buffer.byteLength(',"other_projects":[]', "utf-8");
|
|
1233
|
+
function envelopeBytes(buckets, ctx) {
|
|
1234
|
+
// Full serialized response envelope, including echoed `task`, `degraded`
|
|
1235
|
+
// flags, and a worst-case integer placeholder for `total_bytes`. Used as
|
|
1236
|
+
// the starting-point byte count so `max_bytes` bounds the whole payload,
|
|
1237
|
+
// not just the bucket contents. The intent field is small but
|
|
1238
|
+
// included so the budget reflects its real serialized cost.
|
|
1239
|
+
const envelope = {
|
|
1240
|
+
task: ctx.task,
|
|
1241
|
+
intent: ctx.intent,
|
|
1242
|
+
decisions: buckets.decisions,
|
|
1243
|
+
constraints: buckets.constraints,
|
|
1244
|
+
examples: buckets.examples,
|
|
1245
|
+
rules: buckets.rules,
|
|
1246
|
+
total_bytes: ctx.maxBytes,
|
|
1247
|
+
truncated: true,
|
|
1248
|
+
degraded: ctx.degraded,
|
|
1249
|
+
};
|
|
1250
|
+
// v2: the caveat is a fixed-size string that always ships when set;
|
|
1251
|
+
// count it up front so a thin budget doesn't push the envelope over.
|
|
1252
|
+
// Conflicts and live files are filled item-by-item in the passes above,
|
|
1253
|
+
// so they're not pre-counted here.
|
|
1254
|
+
if (ctx.partition.current_truth_caveat)
|
|
1255
|
+
envelope["current_truth_caveat"] = ctx.partition.current_truth_caveat;
|
|
1256
|
+
if (ctx.degradedReason)
|
|
1257
|
+
envelope["degraded_reason"] = ctx.degradedReason;
|
|
1258
|
+
if (ctx.lexical)
|
|
1259
|
+
envelope["mode"] = "lexical";
|
|
1260
|
+
if (ctx.projectScope)
|
|
1261
|
+
envelope["project_scope"] = ctx.projectScope;
|
|
1262
|
+
return Buffer.byteLength(JSON.stringify(envelope), "utf-8");
|
|
1263
|
+
}
|
|
1264
|
+
function itemBytes(item) {
|
|
1265
|
+
return Buffer.byteLength(JSON.stringify(item), "utf-8") + 1; // +1 for comma
|
|
1266
|
+
}
|
|
1267
|
+
// --- Utilities ---
|
|
1268
|
+
function toRerankInput(cands) {
|
|
1269
|
+
return cands.map((c) => {
|
|
1270
|
+
const entry = {
|
|
1271
|
+
id: c.id,
|
|
1272
|
+
content: c.content,
|
|
1273
|
+
raw_sim: c.raw_sim,
|
|
1274
|
+
raw_bm25: c.raw_bm25,
|
|
1275
|
+
source_table: c.source_table,
|
|
1276
|
+
retrieval_method: c.retrieval_method,
|
|
1277
|
+
};
|
|
1278
|
+
if (c.indexed_at)
|
|
1279
|
+
entry.indexed_at = c.indexed_at;
|
|
1280
|
+
if (c.quality)
|
|
1281
|
+
entry.quality = c.quality;
|
|
1282
|
+
return entry;
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1285
|
+
async function fetchRowsById(ranked) {
|
|
1286
|
+
const byTable = new Map();
|
|
1287
|
+
for (const r of ranked) {
|
|
1288
|
+
const arr = byTable.get(r.source_table) ?? [];
|
|
1289
|
+
arr.push(r.id);
|
|
1290
|
+
byTable.set(r.source_table, arr);
|
|
1291
|
+
}
|
|
1292
|
+
// Keyed by rankedKey — (source_table, id), not bare id — so a doc id present
|
|
1293
|
+
// in both the cloud and local tables can't have one row overwrite the other
|
|
1294
|
+
// and misattribute evidence. Look up via get(rankedKey(r)).
|
|
1295
|
+
const out = new Map();
|
|
1296
|
+
await Promise.all([...byTable].map(async ([tableName, ids]) => {
|
|
1297
|
+
if (ids.length === 0)
|
|
1298
|
+
return;
|
|
1299
|
+
const table = getTable(tableName);
|
|
1300
|
+
// Everything but the stored vector, which nothing downstream reads.
|
|
1301
|
+
const columns = (await table.schema()).fields
|
|
1302
|
+
.map((f) => f.name)
|
|
1303
|
+
.filter((name) => name !== "embedding");
|
|
1304
|
+
const rows = (await table
|
|
1305
|
+
.query()
|
|
1306
|
+
.select(columns)
|
|
1307
|
+
.where(inFilter("id", ids, { validateAsRowId: true }))
|
|
1308
|
+
.limit(ids.length)
|
|
1309
|
+
.toArray());
|
|
1310
|
+
for (const row of rows) {
|
|
1311
|
+
out.set(rankedKey({ source_table: tableName, id: row["id"] }), row);
|
|
1312
|
+
}
|
|
1313
|
+
}));
|
|
1314
|
+
return out;
|
|
1315
|
+
}
|
|
1316
|
+
function parseJsonStringArray(raw) {
|
|
1317
|
+
if (typeof raw !== "string" || !raw)
|
|
1318
|
+
return [];
|
|
1319
|
+
try {
|
|
1320
|
+
const parsed = JSON.parse(raw);
|
|
1321
|
+
if (!Array.isArray(parsed))
|
|
1322
|
+
return [];
|
|
1323
|
+
return parsed.filter((x) => typeof x === "string" && !!x.trim());
|
|
1324
|
+
}
|
|
1325
|
+
catch {
|
|
1326
|
+
return [];
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
function deriveExampleTitle(row, summary) {
|
|
1330
|
+
const topics = parseJsonStringArray(row?.["topics"]);
|
|
1331
|
+
if (topics.length > 0)
|
|
1332
|
+
return truncate(topics.slice(0, 3).join(", "), 120);
|
|
1333
|
+
return truncate(firstLine(summary) || "(conversation)", 120);
|
|
1334
|
+
}
|
|
1335
|
+
function deriveRuleTitle(row, sourcePath, snippet) {
|
|
1336
|
+
const metaTitle = readMetadataTitle(row);
|
|
1337
|
+
if (metaTitle)
|
|
1338
|
+
return truncate(metaTitle, 120);
|
|
1339
|
+
if (sourcePath) {
|
|
1340
|
+
const base = sourcePath.split("/").filter(Boolean).pop();
|
|
1341
|
+
if (base)
|
|
1342
|
+
return truncate(base, 120);
|
|
1343
|
+
}
|
|
1344
|
+
return truncate(firstLine(snippet) || "(document)", 120);
|
|
1345
|
+
}
|
|
1346
|
+
function readMetadataTitle(row) {
|
|
1347
|
+
const meta = row?.["metadata"];
|
|
1348
|
+
if (typeof meta !== "string" || !meta)
|
|
1349
|
+
return null;
|
|
1350
|
+
try {
|
|
1351
|
+
const parsed = JSON.parse(meta);
|
|
1352
|
+
const t = parsed["title"];
|
|
1353
|
+
if (typeof t === "string" && t.trim())
|
|
1354
|
+
return t.trim();
|
|
1355
|
+
}
|
|
1356
|
+
catch {
|
|
1357
|
+
// ignore
|
|
1358
|
+
}
|
|
1359
|
+
return null;
|
|
1360
|
+
}
|
|
1361
|
+
function firstLine(text) {
|
|
1362
|
+
for (const line of text.split(/\r?\n/)) {
|
|
1363
|
+
const t = line.trim();
|
|
1364
|
+
if (t)
|
|
1365
|
+
return t.replace(/^#+\s*/, "").replace(/^[-*]\s+/, "");
|
|
1366
|
+
}
|
|
1367
|
+
return "";
|
|
1368
|
+
}
|
|
1369
|
+
function truncate(text, max) {
|
|
1370
|
+
if (text.length <= max)
|
|
1371
|
+
return text;
|
|
1372
|
+
return text.slice(0, max);
|
|
1373
|
+
}
|
|
1374
|
+
function collapseWhitespace(text) {
|
|
1375
|
+
return text.replace(/\s+/g, " ").trim();
|
|
1376
|
+
}
|
|
1377
|
+
function clamp(n, lo, hi) {
|
|
1378
|
+
if (n < lo)
|
|
1379
|
+
return lo;
|
|
1380
|
+
if (n > hi)
|
|
1381
|
+
return hi;
|
|
1382
|
+
return n;
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* True when `source_path` points into a `data/raw/conversations/**` directory.
|
|
1386
|
+
* Those are raw conversation JSON snapshots that sometimes get indexed as
|
|
1387
|
+
* `structured_docs` because they live under a watched source path; they are
|
|
1388
|
+
* not project rule documents and must not populate `rules` / `constraints`.
|
|
1389
|
+
*/
|
|
1390
|
+
export function isRawConversationPath(p) {
|
|
1391
|
+
return typeof p === "string" && /\/data\/raw\/conversations\//.test(p);
|
|
1392
|
+
}
|
|
1393
|
+
/**
|
|
1394
|
+
* Baseline engine-owned / build-artifact path exclusion for both the
|
|
1395
|
+
* `rules` and `constraints` buckets. The `constraints` bucket layers an
|
|
1396
|
+
* additional filter on top — see {@link shouldExcludeDocFromConstraints}
|
|
1397
|
+
* — to keep one-shot agent prompts out of the project-law surface while
|
|
1398
|
+
* still allowing them to be cited as `rules` doc evidence.
|
|
1399
|
+
*
|
|
1400
|
+
* Explicitly enumerates engine-owned subdirectories under `data/` rather
|
|
1401
|
+
* than matching `data/` wholesale, so user-facing locations the daemon
|
|
1402
|
+
* legitimately watches (notably `data/imports/`) remain eligible:
|
|
1403
|
+
* - `/data/raw/` — raw conversation snapshots
|
|
1404
|
+
* - `/data/embeddings/` — cloud embedding cache
|
|
1405
|
+
* - `/data/embeddings-local/` — local embedding cache
|
|
1406
|
+
* - `/data/quarantine/` — failed ingest drops
|
|
1407
|
+
* - `/data/review-queue/` — review-pipeline state
|
|
1408
|
+
* - `/data/inbox/` — pre-ingest staging
|
|
1409
|
+
* - `/data/observability/` — metrics / logs
|
|
1410
|
+
* - `/data/triage-results/` — batch triage output
|
|
1411
|
+
* - `/data/lancedb/` — the vector store itself
|
|
1412
|
+
* - `/dist/` — compiled JS/TS build artifacts
|
|
1413
|
+
* - `/node_modules/` — third-party dependencies
|
|
1414
|
+
* - `/.git/` — git internals
|
|
1415
|
+
* - `/.codex-worktrees/` — ephemeral worktrees created by codex runs
|
|
1416
|
+
* Rule-bearing human-authored files under `src/`, `docs/`, `reports/`,
|
|
1417
|
+
* `data/imports/`, or at the project root (CLAUDE.md, AGENTS.md,
|
|
1418
|
+
* PROJECT_STATE.md, TODO.md, …) are untouched.
|
|
1419
|
+
*/
|
|
1420
|
+
const EXCLUDED_RULE_PATH_PATTERNS = [
|
|
1421
|
+
/\/data\/raw\//,
|
|
1422
|
+
/\/data\/embeddings\//,
|
|
1423
|
+
/\/data\/embeddings-local\//,
|
|
1424
|
+
/\/data\/quarantine\//,
|
|
1425
|
+
/\/data\/review-queue\//,
|
|
1426
|
+
/\/data\/inbox\//,
|
|
1427
|
+
/\/data\/observability\//,
|
|
1428
|
+
/\/data\/triage-results\//,
|
|
1429
|
+
/\/data\/lancedb\//,
|
|
1430
|
+
/\/dist\//,
|
|
1431
|
+
/\/node_modules\//,
|
|
1432
|
+
/\/\.git\//,
|
|
1433
|
+
/\/\.codex-worktrees\//,
|
|
1434
|
+
];
|
|
1435
|
+
export function shouldExcludeDocFromRules(p) {
|
|
1436
|
+
if (typeof p !== "string")
|
|
1437
|
+
return false;
|
|
1438
|
+
return EXCLUDED_RULE_PATH_PATTERNS.some((rx) => rx.test(p));
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* True when `source_path`'s basename ends with `-prompt.md` — the naming
|
|
1442
|
+
* convention this project uses for one-shot agent prompts (e.g.
|
|
1443
|
+
* `reports/insights/2026-05-03-opus-rift-intelligence-snapshot-prompt.md`,
|
|
1444
|
+
* `docs/05-claude-code-challenge-prompt.md`). These files routinely
|
|
1445
|
+
* include `Hard Constraints` sections such as "Do not modify, create,
|
|
1446
|
+
* delete, move, or rewrite any repository file." which match the
|
|
1447
|
+
* imperative-marker gate in {@link extractConstraintLines} but are
|
|
1448
|
+
* one-shot scaffolding, not durable project law — surfacing them in the
|
|
1449
|
+
* `constraints` bucket erodes trust in the bucket as a whole
|
|
1450
|
+
* (`docs/feedback/2026-05-14-fact-checking-rex.md`, P1 #6).
|
|
1451
|
+
*
|
|
1452
|
+
* Intentionally narrow: only files whose basename ends in literal
|
|
1453
|
+
* `-prompt.md` match. A spec doc like `docs/02-agent-access-without-prompting.md`
|
|
1454
|
+
* (ends in `-prompting.md`), a playbook like `prompts-overview.md`, or a
|
|
1455
|
+
* mid-name occurrence like `prompt-engineering-notes.md` are untouched.
|
|
1456
|
+
* Over-filtering a real project rule is worse than letting some prompt
|
|
1457
|
+
* noise through.
|
|
1458
|
+
*/
|
|
1459
|
+
export function isPromptArtifactPath(p) {
|
|
1460
|
+
return typeof p === "string" && /-prompt\.md$/i.test(p);
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Per-bucket exclusion for the `constraints` surface. Combines the
|
|
1464
|
+
* baseline engine/build filter with the one-shot prompt-artifact filter
|
|
1465
|
+
* so an agent prompt can still appear in `rules` (as legitimate doc
|
|
1466
|
+
* evidence — "this is what we instructed Opus") without contributing
|
|
1467
|
+
* its imperative-marker lines to `constraints` (as if they were project
|
|
1468
|
+
* law).
|
|
1469
|
+
*/
|
|
1470
|
+
export function shouldExcludeDocFromConstraints(p) {
|
|
1471
|
+
return shouldExcludeDocFromRules(p) || isPromptArtifactPath(p);
|
|
1472
|
+
}
|
|
1473
|
+
//# sourceMappingURL=context-pack.js.map
|