nlm-memory 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/plugins/marketplace.json +20 -0
- package/.github/workflows/ci.yml +30 -0
- package/LICENSE +151 -0
- package/README.md +119 -0
- package/dist/cli/classify-parity.d.ts +48 -0
- package/dist/cli/classify-parity.js +182 -0
- package/dist/cli/classify-parity.js.map +1 -0
- package/dist/cli/launchctl-helpers.d.ts +26 -0
- package/dist/cli/launchctl-helpers.js +42 -0
- package/dist/cli/launchctl-helpers.js.map +1 -0
- package/dist/cli/nlm.d.ts +25 -0
- package/dist/cli/nlm.js +832 -0
- package/dist/cli/nlm.js.map +1 -0
- package/dist/core/actions/actions-log.d.ts +40 -0
- package/dist/core/actions/actions-log.js +72 -0
- package/dist/core/actions/actions-log.js.map +1 -0
- package/dist/core/actions/overlay.d.ts +30 -0
- package/dist/core/actions/overlay.js +101 -0
- package/dist/core/actions/overlay.js.map +1 -0
- package/dist/core/adapters/aider.d.ts +33 -0
- package/dist/core/adapters/aider.js +167 -0
- package/dist/core/adapters/aider.js.map +1 -0
- package/dist/core/adapters/claude-code.d.ts +32 -0
- package/dist/core/adapters/claude-code.js +270 -0
- package/dist/core/adapters/claude-code.js.map +1 -0
- package/dist/core/adapters/common.d.ts +20 -0
- package/dist/core/adapters/common.js +60 -0
- package/dist/core/adapters/common.js.map +1 -0
- package/dist/core/adapters/from-source.d.ts +11 -0
- package/dist/core/adapters/from-source.js +55 -0
- package/dist/core/adapters/from-source.js.map +1 -0
- package/dist/core/adapters/hermes-agent.d.ts +34 -0
- package/dist/core/adapters/hermes-agent.js +192 -0
- package/dist/core/adapters/hermes-agent.js.map +1 -0
- package/dist/core/adapters/hermes.d.ts +31 -0
- package/dist/core/adapters/hermes.js +247 -0
- package/dist/core/adapters/hermes.js.map +1 -0
- package/dist/core/adapters/jsonl-generic.d.ts +56 -0
- package/dist/core/adapters/jsonl-generic.js +185 -0
- package/dist/core/adapters/jsonl-generic.js.map +1 -0
- package/dist/core/adapters/opencode.d.ts +36 -0
- package/dist/core/adapters/opencode.js +213 -0
- package/dist/core/adapters/opencode.js.map +1 -0
- package/dist/core/adapters/pi.d.ts +32 -0
- package/dist/core/adapters/pi.js +233 -0
- package/dist/core/adapters/pi.js.map +1 -0
- package/dist/core/classifier/prompt.d.ts +60 -0
- package/dist/core/classifier/prompt.js +178 -0
- package/dist/core/classifier/prompt.js.map +1 -0
- package/dist/core/dataset/build-dataset.d.ts +87 -0
- package/dist/core/dataset/build-dataset.js +335 -0
- package/dist/core/dataset/build-dataset.js.map +1 -0
- package/dist/core/embedding/chunk-body.d.ts +30 -0
- package/dist/core/embedding/chunk-body.js +60 -0
- package/dist/core/embedding/chunk-body.js.map +1 -0
- package/dist/core/embedding/embed-backfill.d.ts +36 -0
- package/dist/core/embedding/embed-backfill.js +168 -0
- package/dist/core/embedding/embed-backfill.js.map +1 -0
- package/dist/core/embedding/embed-normalize.d.ts +28 -0
- package/dist/core/embedding/embed-normalize.js +98 -0
- package/dist/core/embedding/embed-normalize.js.map +1 -0
- package/dist/core/facts/backfill-facts.d.ts +58 -0
- package/dist/core/facts/backfill-facts.js +169 -0
- package/dist/core/facts/backfill-facts.js.map +1 -0
- package/dist/core/facts/extract-facts.d.ts +20 -0
- package/dist/core/facts/extract-facts.js +37 -0
- package/dist/core/facts/extract-facts.js.map +1 -0
- package/dist/core/hook/citation-detect.d.ts +32 -0
- package/dist/core/hook/citation-detect.js +105 -0
- package/dist/core/hook/citation-detect.js.map +1 -0
- package/dist/core/hook/cite-memo.d.ts +20 -0
- package/dist/core/hook/cite-memo.js +68 -0
- package/dist/core/hook/cite-memo.js.map +1 -0
- package/dist/core/hook/claude-settings.d.ts +34 -0
- package/dist/core/hook/claude-settings.js +117 -0
- package/dist/core/hook/claude-settings.js.map +1 -0
- package/dist/core/hook/gate.d.ts +11 -0
- package/dist/core/hook/gate.js +19 -0
- package/dist/core/hook/gate.js.map +1 -0
- package/dist/core/hook/hook-log.d.ts +25 -0
- package/dist/core/hook/hook-log.js +28 -0
- package/dist/core/hook/hook-log.js.map +1 -0
- package/dist/core/hook/memo-sweep.d.ts +55 -0
- package/dist/core/hook/memo-sweep.js +134 -0
- package/dist/core/hook/memo-sweep.js.map +1 -0
- package/dist/core/hook/memo.d.ts +20 -0
- package/dist/core/hook/memo.js +66 -0
- package/dist/core/hook/memo.js.map +1 -0
- package/dist/core/hook/pointer-block.d.ts +14 -0
- package/dist/core/hook/pointer-block.js +19 -0
- package/dist/core/hook/pointer-block.js.map +1 -0
- package/dist/core/hook/select.d.ts +21 -0
- package/dist/core/hook/select.js +15 -0
- package/dist/core/hook/select.js.map +1 -0
- package/dist/core/hook/transcript.d.ts +31 -0
- package/dist/core/hook/transcript.js +103 -0
- package/dist/core/hook/transcript.js.map +1 -0
- package/dist/core/ingest/ingest-session.d.ts +40 -0
- package/dist/core/ingest/ingest-session.js +71 -0
- package/dist/core/ingest/ingest-session.js.map +1 -0
- package/dist/core/providers/provider-models.d.ts +24 -0
- package/dist/core/providers/provider-models.js +72 -0
- package/dist/core/providers/provider-models.js.map +1 -0
- package/dist/core/providers/provider-registry.d.ts +62 -0
- package/dist/core/providers/provider-registry.js +143 -0
- package/dist/core/providers/provider-registry.js.map +1 -0
- package/dist/core/recall/citation-log.d.ts +28 -0
- package/dist/core/recall/citation-log.js +90 -0
- package/dist/core/recall/citation-log.js.map +1 -0
- package/dist/core/recall/filter.d.ts +11 -0
- package/dist/core/recall/filter.js +20 -0
- package/dist/core/recall/filter.js.map +1 -0
- package/dist/core/recall/index.d.ts +6 -0
- package/dist/core/recall/index.js +5 -0
- package/dist/core/recall/index.js.map +1 -0
- package/dist/core/recall/match-fields.d.ts +10 -0
- package/dist/core/recall/match-fields.js +37 -0
- package/dist/core/recall/match-fields.js.map +1 -0
- package/dist/core/recall/query-log.d.ts +36 -0
- package/dist/core/recall/query-log.js +112 -0
- package/dist/core/recall/query-log.js.map +1 -0
- package/dist/core/recall/query-shape.d.ts +22 -0
- package/dist/core/recall/query-shape.js +64 -0
- package/dist/core/recall/query-shape.js.map +1 -0
- package/dist/core/recall/recall-service.d.ts +19 -0
- package/dist/core/recall/recall-service.js +252 -0
- package/dist/core/recall/recall-service.js.map +1 -0
- package/dist/core/recall/recent-log.d.ts +16 -0
- package/dist/core/recall/recent-log.js +46 -0
- package/dist/core/recall/recent-log.js.map +1 -0
- package/dist/core/recall/tokenize.d.ts +7 -0
- package/dist/core/recall/tokenize.js +18 -0
- package/dist/core/recall/tokenize.js.map +1 -0
- package/dist/core/recall/useful-scan.d.ts +52 -0
- package/dist/core/recall/useful-scan.js +300 -0
- package/dist/core/recall/useful-scan.js.map +1 -0
- package/dist/core/recall-facts/fact-query-log.d.ts +42 -0
- package/dist/core/recall-facts/fact-query-log.js +115 -0
- package/dist/core/recall-facts/fact-query-log.js.map +1 -0
- package/dist/core/recall-facts/fact-recall-service.d.ts +34 -0
- package/dist/core/recall-facts/fact-recall-service.js +246 -0
- package/dist/core/recall-facts/fact-recall-service.js.map +1 -0
- package/dist/core/scheduler/scan-once.d.ts +32 -0
- package/dist/core/scheduler/scan-once.js +100 -0
- package/dist/core/scheduler/scan-once.js.map +1 -0
- package/dist/core/scheduler/scheduler.d.ts +59 -0
- package/dist/core/scheduler/scheduler.js +158 -0
- package/dist/core/scheduler/scheduler.js.map +1 -0
- package/dist/core/sources/source-registry.d.ts +68 -0
- package/dist/core/sources/source-registry.js +208 -0
- package/dist/core/sources/source-registry.js.map +1 -0
- package/dist/core/storage/db-restore.d.ts +53 -0
- package/dist/core/storage/db-restore.js +113 -0
- package/dist/core/storage/db-restore.js.map +1 -0
- package/dist/core/storage/live-status.d.ts +15 -0
- package/dist/core/storage/live-status.js +43 -0
- package/dist/core/storage/live-status.js.map +1 -0
- package/dist/core/storage/migrate.d.ts +14 -0
- package/dist/core/storage/migrate.js +52 -0
- package/dist/core/storage/migrate.js.map +1 -0
- package/dist/core/storage/sqlite-fact-store.d.ts +50 -0
- package/dist/core/storage/sqlite-fact-store.js +256 -0
- package/dist/core/storage/sqlite-fact-store.js.map +1 -0
- package/dist/core/storage/sqlite-session-store.d.ts +152 -0
- package/dist/core/storage/sqlite-session-store.js +587 -0
- package/dist/core/storage/sqlite-session-store.js.map +1 -0
- package/dist/hook/pre-compact-hook.d.ts +26 -0
- package/dist/hook/pre-compact-hook.js +94 -0
- package/dist/hook/pre-compact-hook.js.map +1 -0
- package/dist/hook/prompt-recall-hook.d.ts +23 -0
- package/dist/hook/prompt-recall-hook.js +141 -0
- package/dist/hook/prompt-recall-hook.js.map +1 -0
- package/dist/hook/session-end-hook.d.ts +18 -0
- package/dist/hook/session-end-hook.js +67 -0
- package/dist/hook/session-end-hook.js.map +1 -0
- package/dist/hook/session-start-hook.d.ts +25 -0
- package/dist/hook/session-start-hook.js +129 -0
- package/dist/hook/session-start-hook.js.map +1 -0
- package/dist/hook/stop-hook.d.ts +38 -0
- package/dist/hook/stop-hook.js +171 -0
- package/dist/hook/stop-hook.js.map +1 -0
- package/dist/hook/subagent-start-hook.d.ts +30 -0
- package/dist/hook/subagent-start-hook.js +108 -0
- package/dist/hook/subagent-start-hook.js.map +1 -0
- package/dist/http/app.d.ts +65 -0
- package/dist/http/app.js +1009 -0
- package/dist/http/app.js.map +1 -0
- package/dist/install/claude-code.d.ts +57 -0
- package/dist/install/claude-code.js +76 -0
- package/dist/install/claude-code.js.map +1 -0
- package/dist/install/codex.d.ts +82 -0
- package/dist/install/codex.js +277 -0
- package/dist/install/codex.js.map +1 -0
- package/dist/install/hermes-agent.d.ts +35 -0
- package/dist/install/hermes-agent.js +48 -0
- package/dist/install/hermes-agent.js.map +1 -0
- package/dist/install/hermes.d.ts +29 -0
- package/dist/install/hermes.js +52 -0
- package/dist/install/hermes.js.map +1 -0
- package/dist/install/ollama.d.ts +54 -0
- package/dist/install/ollama.js +178 -0
- package/dist/install/ollama.js.map +1 -0
- package/dist/install/setup.d.ts +37 -0
- package/dist/install/setup.js +339 -0
- package/dist/install/setup.js.map +1 -0
- package/dist/llm/classifier-box.d.ts +29 -0
- package/dist/llm/classifier-box.js +43 -0
- package/dist/llm/classifier-box.js.map +1 -0
- package/dist/llm/deepseek-client.d.ts +40 -0
- package/dist/llm/deepseek-client.js +114 -0
- package/dist/llm/deepseek-client.js.map +1 -0
- package/dist/llm/env-autoload.d.ts +8 -0
- package/dist/llm/env-autoload.js +54 -0
- package/dist/llm/env-autoload.js.map +1 -0
- package/dist/llm/ollama-client.d.ts +47 -0
- package/dist/llm/ollama-client.js +156 -0
- package/dist/llm/ollama-client.js.map +1 -0
- package/dist/mcp/server.d.ts +64 -0
- package/dist/mcp/server.js +430 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/ports/fact-store.d.ts +82 -0
- package/dist/ports/fact-store.js +16 -0
- package/dist/ports/fact-store.js.map +1 -0
- package/dist/ports/llm-client.d.ts +42 -0
- package/dist/ports/llm-client.js +14 -0
- package/dist/ports/llm-client.js.map +1 -0
- package/dist/ports/logger.d.ts +13 -0
- package/dist/ports/logger.js +8 -0
- package/dist/ports/logger.js.map +1 -0
- package/dist/ports/session-store.d.ts +29 -0
- package/dist/ports/session-store.js +9 -0
- package/dist/ports/session-store.js.map +1 -0
- package/dist/ports/transcript-adapter.d.ts +48 -0
- package/dist/ports/transcript-adapter.js +15 -0
- package/dist/ports/transcript-adapter.js.map +1 -0
- package/dist/shared/types.d.ts +129 -0
- package/dist/shared/types.js +6 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/ui/assets/index-BA6IpU8g.css +1 -0
- package/dist/ui/assets/index-B_qIVV0k.js +69 -0
- package/dist/ui/index.html +13 -0
- package/docs/methodology/re-derivation-rate.md +112 -0
- package/docs/methodology/useful-hit-rate.md +79 -0
- package/docs/plans/2026-05-20-fts5-lexical-recall.md +1088 -0
- package/docs/plans/2026-05-20-recall-daemon-wedge-fix.md +662 -0
- package/docs/plans/2026-05-20-recall-hook-design.md +131 -0
- package/docs/plans/2026-05-20-recall-hook-implementation.md +1222 -0
- package/docs/plans/desktop-product.md +69 -0
- package/docs/plans/factstore-design.md +236 -0
- package/logs/CHANGELOG/CHANGELOG-2026.md +1389 -0
- package/logs/CHANGELOG/CHANGELOG.md +320 -0
- package/migrations/000_initial_schema.sql +174 -0
- package/migrations/001_entity_type_rename.sql +17 -0
- package/migrations/002_adapter_state_extend.sql +12 -0
- package/migrations/003_session_embeddings.sql +11 -0
- package/migrations/004_facts.sql +46 -0
- package/migrations/005_sources.sql +31 -0
- package/migrations/006_providers.sql +33 -0
- package/migrations/007_source_tokens.sql +17 -0
- package/migrations/008_fts_rebuild.sql +9 -0
- package/migrations/009_session_embedding_chunks.sql +46 -0
- package/migrations/010_sources_opencode.sql +30 -0
- package/migrations/011_sources_hermes_agent.sql +30 -0
- package/migrations/012_sources_aider.sql +30 -0
- package/migrations/013_adapter_state_failure_count.sql +12 -0
- package/package.json +56 -0
- package/plugin/.codex-plugin/plugin.json +22 -0
- package/plugin/.mcp.json +8 -0
- package/plugin/README.md +51 -0
- package/plugin/hooks/hooks.json +25 -0
- package/plugin/scripts/prompt-recall-hook.mjs +202 -0
- package/plugin/scripts/stop-hook.mjs +306 -0
- package/plugin-hermes-agent/README.md +49 -0
- package/plugin-hermes-agent/__init__.py +75 -0
- package/plugin-hermes-agent/plugin.yaml +15 -0
- package/scripts/backfill-citations.mjs +0 -0
- package/scripts/build-codex-plugin.mjs +61 -0
- package/scripts/deepseek-probe.mjs +67 -0
- package/scripts/extract-triples.mjs +207 -0
- package/scripts/longmemeval/embedding-cache.ts +77 -0
- package/scripts/longmemeval/fetch-dataset.sh +25 -0
- package/scripts/longmemeval/run-harness.ts +315 -0
- package/scripts/longmemeval/scorer.ts +99 -0
- package/scripts/longmemeval/tsconfig.json +9 -0
- package/scripts/longmemeval/types.ts +35 -0
- package/scripts/nlm-daily-digest.py +239 -0
- package/scripts/nlm-daily-digest.sh +28 -0
- package/src/cli/classify-parity.ts +257 -0
- package/src/cli/launchctl-helpers.ts +49 -0
- package/src/cli/nlm.ts +885 -0
- package/src/core/actions/actions-log.ts +118 -0
- package/src/core/actions/overlay.ts +117 -0
- package/src/core/adapters/aider.ts +205 -0
- package/src/core/adapters/claude-code.ts +293 -0
- package/src/core/adapters/common.ts +54 -0
- package/src/core/adapters/from-source.ts +57 -0
- package/src/core/adapters/hermes-agent.ts +240 -0
- package/src/core/adapters/hermes.ts +277 -0
- package/src/core/adapters/jsonl-generic.ts +208 -0
- package/src/core/adapters/opencode.ts +281 -0
- package/src/core/adapters/pi.ts +264 -0
- package/src/core/classifier/prompt.ts +200 -0
- package/src/core/dataset/build-dataset.ts +463 -0
- package/src/core/embedding/chunk-body.ts +76 -0
- package/src/core/embedding/embed-backfill.ts +210 -0
- package/src/core/embedding/embed-normalize.ts +135 -0
- package/src/core/facts/backfill-facts.ts +254 -0
- package/src/core/facts/extract-facts.ts +50 -0
- package/src/core/hook/citation-detect.ts +124 -0
- package/src/core/hook/cite-memo.ts +68 -0
- package/src/core/hook/claude-settings.ts +166 -0
- package/src/core/hook/gate.ts +25 -0
- package/src/core/hook/hook-log.ts +41 -0
- package/src/core/hook/memo-sweep.ts +164 -0
- package/src/core/hook/memo.ts +67 -0
- package/src/core/hook/pointer-block.ts +26 -0
- package/src/core/hook/select.ts +32 -0
- package/src/core/hook/transcript.ts +121 -0
- package/src/core/ingest/ingest-session.ts +111 -0
- package/src/core/providers/provider-models.ts +100 -0
- package/src/core/providers/provider-registry.ts +196 -0
- package/src/core/recall/citation-log.ts +108 -0
- package/src/core/recall/filter.ts +27 -0
- package/src/core/recall/index.ts +6 -0
- package/src/core/recall/match-fields.ts +40 -0
- package/src/core/recall/query-log.ts +149 -0
- package/src/core/recall/query-shape.ts +66 -0
- package/src/core/recall/recall-service.ts +320 -0
- package/src/core/recall/recent-log.ts +59 -0
- package/src/core/recall/tokenize.ts +18 -0
- package/src/core/recall/useful-scan.ts +336 -0
- package/src/core/recall-facts/fact-query-log.ts +150 -0
- package/src/core/recall-facts/fact-recall-service.ts +327 -0
- package/src/core/scheduler/scan-once.ts +142 -0
- package/src/core/scheduler/scheduler.ts +225 -0
- package/src/core/sources/source-registry.ts +260 -0
- package/src/core/storage/db-restore.ts +133 -0
- package/src/core/storage/live-status.ts +45 -0
- package/src/core/storage/migrate.ts +72 -0
- package/src/core/storage/sqlite-fact-store.ts +304 -0
- package/src/core/storage/sqlite-session-store.ts +765 -0
- package/src/hook/prompt-recall-hook.ts +174 -0
- package/src/hook/session-end-hook.ts +81 -0
- package/src/hook/session-start-hook.ts +165 -0
- package/src/hook/stop-hook.ts +236 -0
- package/src/http/app.ts +1114 -0
- package/src/install/claude-code.ts +128 -0
- package/src/install/codex.ts +367 -0
- package/src/install/hermes-agent.ts +76 -0
- package/src/install/hermes.ts +78 -0
- package/src/install/ollama.ts +208 -0
- package/src/install/setup.ts +368 -0
- package/src/llm/classifier-box.ts +64 -0
- package/src/llm/deepseek-client.ts +150 -0
- package/src/llm/env-autoload.ts +55 -0
- package/src/llm/ollama-client.ts +189 -0
- package/src/mcp/server.ts +534 -0
- package/src/ports/fact-store.ts +102 -0
- package/src/ports/llm-client.ts +52 -0
- package/src/ports/logger.ts +16 -0
- package/src/ports/session-store.ts +45 -0
- package/src/ports/transcript-adapter.ts +55 -0
- package/src/shared/types.ts +145 -0
- package/src/ui/App.tsx +58 -0
- package/src/ui/components/PromoteOpenButton.tsx +65 -0
- package/src/ui/components/SessionDrawer.tsx +136 -0
- package/src/ui/components/SideNav.tsx +162 -0
- package/src/ui/components/Skeleton.tsx +107 -0
- package/src/ui/index.html +13 -0
- package/src/ui/lib/actions.ts +30 -0
- package/src/ui/lib/api.ts +92 -0
- package/src/ui/lib/dataset.ts +141 -0
- package/src/ui/lib/registries.ts +155 -0
- package/src/ui/lib/view-settings.ts +41 -0
- package/src/ui/main.tsx +15 -0
- package/src/ui/pages/Live.tsx +229 -0
- package/src/ui/pages/Pulse.tsx +415 -0
- package/src/ui/pages/Recall.tsx +190 -0
- package/src/ui/pages/River.tsx +308 -0
- package/src/ui/pages/Search.tsx +93 -0
- package/src/ui/pages/Stub.tsx +9 -0
- package/src/ui/pages/Thread.tsx +262 -0
- package/src/ui/pages/settings/Classifier.tsx +227 -0
- package/src/ui/pages/settings/Data.tsx +190 -0
- package/src/ui/pages/settings/Index.tsx +65 -0
- package/src/ui/pages/settings/Labels.tsx +224 -0
- package/src/ui/pages/settings/Providers.tsx +305 -0
- package/src/ui/pages/settings/SettingsSubnav.tsx +28 -0
- package/src/ui/pages/settings/Sources.tsx +326 -0
- package/src/ui/pages/settings/Views.tsx +96 -0
- package/src/ui/styles.css +1766 -0
- package/src/ui/tsconfig.json +21 -0
- package/src/ui/vite.config.ts +19 -0
- package/tests/fixtures/claude_code/short_session.jsonl +2 -0
- package/tests/fixtures/claude_code/standard_iso.jsonl +4 -0
- package/tests/fixtures/claude_code/tool_heavy.jsonl +8 -0
- package/tests/fixtures/claude_code/with_subagent.jsonl +7 -0
- package/tests/fixtures/facts.ts +17 -0
- package/tests/fixtures/golden-corpus.ts +85 -0
- package/tests/fixtures/hermes/paired_request_dump.json +24 -0
- package/tests/fixtures/hermes/paired_session.json +23 -0
- package/tests/fixtures/hermes/request_dump.json +28 -0
- package/tests/fixtures/hermes/session_iso.json +38 -0
- package/tests/fixtures/hermes/session_unix.json +38 -0
- package/tests/fixtures/hermes/system_only.json +18 -0
- package/tests/fixtures/pi/error-connection-abort.jsonl +8 -0
- package/tests/fixtures/pi/short-successful.jsonl +5 -0
- package/tests/fixtures/pi/with-custom-message.jsonl +6 -0
- package/tests/fixtures/sessions.ts +22 -0
- package/tests/integration/backfill-facts.test.ts +362 -0
- package/tests/integration/citation-explicit.test.ts +111 -0
- package/tests/integration/cite-event.test.ts +169 -0
- package/tests/integration/cite-memo.test.ts +87 -0
- package/tests/integration/db-restore.test.ts +153 -0
- package/tests/integration/embed-backfill.test.ts +176 -0
- package/tests/integration/fact-supersedence.test.ts +313 -0
- package/tests/integration/fts-index.test.ts +60 -0
- package/tests/integration/getbyids-sqlite.test.ts +60 -0
- package/tests/integration/hermes-agent-hooks.test.ts +248 -0
- package/tests/integration/hook-claude-settings.test.ts +205 -0
- package/tests/integration/hook-log.test.ts +54 -0
- package/tests/integration/hook-memo.test.ts +68 -0
- package/tests/integration/hook-pre-compact.test.ts +105 -0
- package/tests/integration/hook-subagent-start.test.ts +102 -0
- package/tests/integration/http.test.ts +401 -0
- package/tests/integration/keyword-search-fts.test.ts +66 -0
- package/tests/integration/mcp-recall-logging.test.ts +88 -0
- package/tests/integration/mcp.test.ts +248 -0
- package/tests/integration/memo-sweep.test.ts +91 -0
- package/tests/integration/prompt-recall-hook.test.ts +88 -0
- package/tests/integration/provider-registry.test.ts +107 -0
- package/tests/integration/recall-golden.test.ts +59 -0
- package/tests/integration/recall-sqlite.test.ts +169 -0
- package/tests/integration/scheduler.test.ts +391 -0
- package/tests/integration/session-end-hook.test.ts +48 -0
- package/tests/integration/session-start-hook.test.ts +126 -0
- package/tests/integration/source-registry.test.ts +120 -0
- package/tests/integration/sqlite-fact-store.test.ts +346 -0
- package/tests/integration/stop-hook.test.ts +560 -0
- package/tests/integration/wal-checkpoint.test.ts +49 -0
- package/tests/unit/cli/launchctl-helpers.test.ts +60 -0
- package/tests/unit/core/adapters/aider.test.ts +230 -0
- package/tests/unit/core/adapters/claude-code.test.ts +118 -0
- package/tests/unit/core/adapters/hermes-agent.test.ts +329 -0
- package/tests/unit/core/adapters/hermes.test.ts +81 -0
- package/tests/unit/core/adapters/jsonl-generic.test.ts +142 -0
- package/tests/unit/core/adapters/opencode.test.ts +354 -0
- package/tests/unit/core/adapters/pi.test.ts +110 -0
- package/tests/unit/core/classifier/prompt.test.ts +126 -0
- package/tests/unit/core/embedding/chunk-body.test.ts +100 -0
- package/tests/unit/core/facts/extract-facts.test.ts +117 -0
- package/tests/unit/core/filter.test.ts +40 -0
- package/tests/unit/core/hook/citation-detect-cite-session.test.ts +96 -0
- package/tests/unit/core/hook/citation-detect.test.ts +124 -0
- package/tests/unit/core/hook/gate.test.ts +29 -0
- package/tests/unit/core/hook/pointer-block.test.ts +22 -0
- package/tests/unit/core/hook/select.test.ts +66 -0
- package/tests/unit/core/match-fields.test.ts +39 -0
- package/tests/unit/core/mcp-cite-session.test.ts +51 -0
- package/tests/unit/core/providers/provider-models.test.ts +101 -0
- package/tests/unit/core/query-shape.test.ts +92 -0
- package/tests/unit/core/recall-facts/fact-recall-service.test.ts +258 -0
- package/tests/unit/core/recall-service.test.ts +200 -0
- package/tests/unit/core/storage/live-status.test.ts +54 -0
- package/tests/unit/core/tokenize.test.ts +32 -0
- package/tests/unit/core/useful-scan.test.ts +537 -0
- package/tests/unit/llm/embed.test.ts +93 -0
- package/tests/unit/llm/ollama-client.test.ts +124 -0
- package/tests/unit/scripts/longmemeval-scorer.test.ts +114 -0
- package/tsconfig.json +31 -0
- package/tsconfig.test.json +11 -0
- package/vitest.config.ts +22 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recall — adoption + coverage telemetry for the memory system.
|
|
3
|
+
*
|
|
4
|
+
* Two surfaces, two audiences:
|
|
5
|
+
* - Session recall → what the orchestrator pulls answering questions
|
|
6
|
+
* about past work (the human-operator surface).
|
|
7
|
+
* - Fact recall → structured facts agents pull mid-task.
|
|
8
|
+
*
|
|
9
|
+
* Hit rate answers "did recall return something," not "did the agent use
|
|
10
|
+
* it." By-source answers "is anything calling this at all." Read together
|
|
11
|
+
* they distinguish an adoption problem from a corpus-coverage problem.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { useState } from "react";
|
|
15
|
+
import { usePolledEndpoint } from "../lib/api.js";
|
|
16
|
+
|
|
17
|
+
interface BaseStats {
|
|
18
|
+
days: number;
|
|
19
|
+
total: number;
|
|
20
|
+
with_results: number;
|
|
21
|
+
hit_rate: number;
|
|
22
|
+
by_source: Record<string, number>;
|
|
23
|
+
log_present: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface SessionStats extends BaseStats {
|
|
27
|
+
top_queries: { query: string; count: number }[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface FactStats extends BaseStats {
|
|
31
|
+
top_subjects: { subject: string; count: number }[];
|
|
32
|
+
top_predicates: { predicate: string; count: number }[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const EMPTY_SESSION: SessionStats = {
|
|
36
|
+
days: 7, total: 0, with_results: 0, hit_rate: 0, by_source: {}, top_queries: [], log_present: false,
|
|
37
|
+
};
|
|
38
|
+
const EMPTY_FACT: FactStats = {
|
|
39
|
+
days: 7, total: 0, with_results: 0, hit_rate: 0, by_source: {}, top_subjects: [], top_predicates: [], log_present: false,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const WINDOWS = [7, 30, 90] as const;
|
|
43
|
+
|
|
44
|
+
interface BarRow {
|
|
45
|
+
label: string;
|
|
46
|
+
count: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function RecallPage() {
|
|
50
|
+
const [days, setDays] = useState<number>(7);
|
|
51
|
+
const session = usePolledEndpoint<SessionStats>(`/api/recall/stats?days=${days}`, 30_000, EMPTY_SESSION);
|
|
52
|
+
const facts = usePolledEndpoint<FactStats>(`/api/recall/facts/stats?days=${days}`, 30_000, EMPTY_FACT);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div className="page-pad">
|
|
56
|
+
<div className="recall-head">
|
|
57
|
+
<p className="muted small recall-note">
|
|
58
|
+
Hit rate measures whether recall returned something — not whether the agent used it.
|
|
59
|
+
Watch <strong>by source</strong> for adoption and <strong>hit rate</strong> for
|
|
60
|
+
whether the corpus covers what's being asked.
|
|
61
|
+
</p>
|
|
62
|
+
<div className="filter-group" role="group" aria-label="Time window">
|
|
63
|
+
{WINDOWS.map((w) => (
|
|
64
|
+
<button
|
|
65
|
+
key={w}
|
|
66
|
+
type="button"
|
|
67
|
+
className={`chip${days === w ? " active" : ""}`}
|
|
68
|
+
onClick={() => setDays(w)}
|
|
69
|
+
>{w}d</button>
|
|
70
|
+
))}
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<StatsBlock
|
|
75
|
+
title="Session recall"
|
|
76
|
+
subtitle="What the orchestrator pulls when answering questions about past work — the human-operator surface."
|
|
77
|
+
stats={session.data}
|
|
78
|
+
error={session.error}
|
|
79
|
+
topLabel="Top queries"
|
|
80
|
+
topRows={session.data.top_queries.map((q) => ({ label: q.query, count: q.count }))}
|
|
81
|
+
/>
|
|
82
|
+
|
|
83
|
+
<StatsBlock
|
|
84
|
+
title="Fact recall"
|
|
85
|
+
subtitle="Structured facts agents pull mid-task — the orchestrator surface."
|
|
86
|
+
stats={facts.data}
|
|
87
|
+
error={facts.error}
|
|
88
|
+
topLabel="Top subjects"
|
|
89
|
+
topRows={facts.data.top_subjects.map((s) => ({ label: s.subject, count: s.count }))}
|
|
90
|
+
extraLabel="Top predicates"
|
|
91
|
+
extraRows={facts.data.top_predicates.map((p) => ({ label: p.predicate, count: p.count }))}
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
interface StatsBlockProps {
|
|
98
|
+
title: string;
|
|
99
|
+
subtitle: string;
|
|
100
|
+
stats: BaseStats;
|
|
101
|
+
error: string | null;
|
|
102
|
+
topLabel: string;
|
|
103
|
+
topRows: BarRow[];
|
|
104
|
+
extraLabel?: string;
|
|
105
|
+
extraRows?: BarRow[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function StatsBlock({ title, subtitle, stats, error, topLabel, topRows, extraLabel, extraRows }: StatsBlockProps) {
|
|
109
|
+
const zeroResult = stats.total - stats.with_results;
|
|
110
|
+
const sourceRows: BarRow[] = Object.entries(stats.by_source)
|
|
111
|
+
.map(([label, count]) => ({ label, count }))
|
|
112
|
+
.sort((a, b) => b.count - a.count);
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<section className="recall-block">
|
|
116
|
+
<header className="recall-block-head">
|
|
117
|
+
<h2 className="page-title">{title}</h2>
|
|
118
|
+
<p className="muted small">{subtitle}</p>
|
|
119
|
+
</header>
|
|
120
|
+
|
|
121
|
+
{error && <div className="muted error small">{error}</div>}
|
|
122
|
+
|
|
123
|
+
{!stats.log_present ? (
|
|
124
|
+
<div className="card recall-empty muted">
|
|
125
|
+
No query log on disk yet — nothing has called this recall surface.
|
|
126
|
+
</div>
|
|
127
|
+
) : stats.total === 0 ? (
|
|
128
|
+
<div className="card recall-empty muted">
|
|
129
|
+
No queries in the last {stats.days} days. The log exists but this window is empty.
|
|
130
|
+
</div>
|
|
131
|
+
) : (
|
|
132
|
+
<>
|
|
133
|
+
<div className="kpi-row">
|
|
134
|
+
<Kpi label="Queries" value={stats.total} hint={`last ${stats.days}d`} />
|
|
135
|
+
<Kpi
|
|
136
|
+
label="Hit rate"
|
|
137
|
+
value={`${Math.round(stats.hit_rate * 100)}%`}
|
|
138
|
+
hint={`${stats.with_results.toLocaleString()} returned ≥1`}
|
|
139
|
+
/>
|
|
140
|
+
<Kpi
|
|
141
|
+
label="Zero-result"
|
|
142
|
+
value={zeroResult}
|
|
143
|
+
hint={zeroResult > 0 ? "corpus gaps" : "full coverage"}
|
|
144
|
+
/>
|
|
145
|
+
<Kpi label="Sources" value={sourceRows.length} hint="distinct callers" />
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<div className="recall-cards">
|
|
149
|
+
<BarCard title="By source" rows={sourceRows} emptyText="No sources recorded." />
|
|
150
|
+
<BarCard title={topLabel} rows={topRows} emptyText="None recorded." />
|
|
151
|
+
{extraLabel && extraRows && (
|
|
152
|
+
<BarCard title={extraLabel} rows={extraRows} emptyText="None recorded." />
|
|
153
|
+
)}
|
|
154
|
+
</div>
|
|
155
|
+
</>
|
|
156
|
+
)}
|
|
157
|
+
</section>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function Kpi({ label, value, hint }: { label: string; value: number | string; hint?: string }) {
|
|
162
|
+
return (
|
|
163
|
+
<div className="kpi">
|
|
164
|
+
<span className="kpi-label">{label}</span>
|
|
165
|
+
<span className="kpi-value">{typeof value === "number" ? value.toLocaleString() : value}</span>
|
|
166
|
+
{hint && <span className="kpi-hint">{hint}</span>}
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function BarCard({ title, rows, emptyText }: { title: string; rows: BarRow[]; emptyText: string }) {
|
|
172
|
+
const max = Math.max(1, ...rows.map((r) => r.count));
|
|
173
|
+
return (
|
|
174
|
+
<section className="card">
|
|
175
|
+
<header className="card-head"><h3>{title}</h3></header>
|
|
176
|
+
<div className="bar-stack recall-bars">
|
|
177
|
+
{rows.length === 0 && <div className="muted small recall-bars-empty">{emptyText}</div>}
|
|
178
|
+
{rows.map((r) => (
|
|
179
|
+
<div key={r.label} className="bar-item">
|
|
180
|
+
<span className="bar-label recall-bar-label" title={r.label}>{r.label}</span>
|
|
181
|
+
<div className="bar-track">
|
|
182
|
+
<div className="bar-fill tone-active" style={{ width: `${(r.count / max) * 100}%` }} />
|
|
183
|
+
</div>
|
|
184
|
+
<span className="bar-value mono">{r.count.toLocaleString()}</span>
|
|
185
|
+
</div>
|
|
186
|
+
))}
|
|
187
|
+
</div>
|
|
188
|
+
</section>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { useNavigate } from "react-router-dom";
|
|
3
|
+
import { useDataset, relativeAge } from "../lib/dataset.js";
|
|
4
|
+
import type { DatasetSession } from "../lib/dataset.js";
|
|
5
|
+
import { SessionDrawer } from "../components/SessionDrawer.js";
|
|
6
|
+
import { readViewSettings } from "../lib/view-settings.js";
|
|
7
|
+
|
|
8
|
+
type Span = "7d" | "30d" | "90d" | "all";
|
|
9
|
+
const SPAN_DAYS: Record<Span, number | null> = { "7d": 7, "30d": 30, "90d": 90, all: null };
|
|
10
|
+
|
|
11
|
+
interface HoverState {
|
|
12
|
+
entity: string;
|
|
13
|
+
date: string;
|
|
14
|
+
count: number;
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface DragState {
|
|
20
|
+
startX: number;
|
|
21
|
+
rect: DOMRect;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface CellDrawerState {
|
|
25
|
+
entity: string;
|
|
26
|
+
date: string;
|
|
27
|
+
sessions: DatasetSession[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function RiverPage() {
|
|
31
|
+
const { data, loading, error } = useDataset();
|
|
32
|
+
const [span, setSpan] = useState<Span>("30d");
|
|
33
|
+
const [hover, setHover] = useState<HoverState | null>(null);
|
|
34
|
+
const [cellDrawer, setCellDrawer] = useState<CellDrawerState | null>(null);
|
|
35
|
+
const [sessionId, setSessionId] = useState<string | null>(null);
|
|
36
|
+
const navigate = useNavigate();
|
|
37
|
+
const [density] = useState(() => readViewSettings().riverDensity);
|
|
38
|
+
const gridRef = useRef<HTMLDivElement | null>(null);
|
|
39
|
+
const dragRef = useRef<DragState | null>(null);
|
|
40
|
+
const [dragRange, setDragRange] = useState<{ from: number; to: number } | null>(null);
|
|
41
|
+
|
|
42
|
+
const view = useMemo(() => {
|
|
43
|
+
if (!data) return null;
|
|
44
|
+
const days = SPAN_DAYS[span];
|
|
45
|
+
const sessions = data.sessions.filter((s) => s.started_at !== null);
|
|
46
|
+
const now = Date.now();
|
|
47
|
+
const filtered = days
|
|
48
|
+
? sessions.filter((s) => (now - Date.parse(s.started_at!)) / 86_400_000 <= days)
|
|
49
|
+
: sessions;
|
|
50
|
+
const lanes = new Map<string, Map<string, number>>();
|
|
51
|
+
const dateSet = new Set<string>();
|
|
52
|
+
for (const s of filtered) {
|
|
53
|
+
const d = (s.started_at ?? "").slice(0, 10);
|
|
54
|
+
if (!d) continue;
|
|
55
|
+
dateSet.add(d);
|
|
56
|
+
for (const e of s.entities) {
|
|
57
|
+
const inner = lanes.get(e) ?? new Map<string, number>();
|
|
58
|
+
inner.set(d, (inner.get(d) ?? 0) + 1);
|
|
59
|
+
lanes.set(e, inner);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const dates = [...dateSet].sort();
|
|
63
|
+
const laneRows = [...lanes.entries()]
|
|
64
|
+
.map(([entity, perDate]) => ({
|
|
65
|
+
entity,
|
|
66
|
+
total: [...perDate.values()].reduce((a, b) => a + b, 0),
|
|
67
|
+
perDate,
|
|
68
|
+
}))
|
|
69
|
+
.sort((a, b) => b.total - a.total)
|
|
70
|
+
.slice(0, 24);
|
|
71
|
+
return { dates, laneRows, total: filtered.length };
|
|
72
|
+
}, [data, span]);
|
|
73
|
+
|
|
74
|
+
const onCellClick = (entity: string, date: string) => {
|
|
75
|
+
if (!data) return;
|
|
76
|
+
const matches = data.sessions
|
|
77
|
+
.filter((s) => (s.started_at ?? "").slice(0, 10) === date && s.entities.includes(entity))
|
|
78
|
+
.sort((a, b) => (b.started_at ?? "").localeCompare(a.started_at ?? ""));
|
|
79
|
+
if (matches.length === 0) return;
|
|
80
|
+
if (matches.length === 1) {
|
|
81
|
+
setSessionId(matches[0]!.id);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
setCellDrawer({ entity, date, sessions: matches });
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const onMouseDown = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
88
|
+
if (!gridRef.current) return;
|
|
89
|
+
const rect = gridRef.current.getBoundingClientRect();
|
|
90
|
+
dragRef.current = { startX: e.clientX, rect };
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const onMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
94
|
+
if (!dragRef.current) return;
|
|
95
|
+
const { startX, rect } = dragRef.current;
|
|
96
|
+
const from = Math.min(startX, e.clientX) - rect.left;
|
|
97
|
+
const to = Math.max(startX, e.clientX) - rect.left;
|
|
98
|
+
if (to - from < 6) {
|
|
99
|
+
setDragRange(null);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
setDragRange({ from, to });
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const onMouseUp = () => {
|
|
106
|
+
if (!dragRef.current || !dragRange || !view) {
|
|
107
|
+
dragRef.current = null;
|
|
108
|
+
setDragRange(null);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
// Cells live in a CSS grid with repeat(N, 1fr); compute the cell-area
|
|
112
|
+
// width by measuring the rendered grid minus the fixed label column.
|
|
113
|
+
const grid = gridRef.current;
|
|
114
|
+
const labelEl = grid?.querySelector(".river-lane-label") as HTMLElement | null;
|
|
115
|
+
const labelWidth = labelEl?.offsetWidth ?? 0;
|
|
116
|
+
const gridWidth = grid?.offsetWidth ?? 0;
|
|
117
|
+
const cellArea = Math.max(1, gridWidth - labelWidth);
|
|
118
|
+
const cellSize = cellArea / view.dates.length;
|
|
119
|
+
const labelOffset = labelWidth + 12; // grid padding + gap
|
|
120
|
+
|
|
121
|
+
const startIdx = Math.max(0, Math.floor((dragRange.from - labelOffset) / cellSize));
|
|
122
|
+
const endIdx = Math.min(view.dates.length - 1, Math.floor((dragRange.to - labelOffset) / cellSize));
|
|
123
|
+
if (endIdx <= startIdx) {
|
|
124
|
+
dragRef.current = null;
|
|
125
|
+
setDragRange(null);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const startDate = view.dates[startIdx];
|
|
129
|
+
const endDate = view.dates[endIdx];
|
|
130
|
+
if (startDate && endDate) {
|
|
131
|
+
const days = Math.max(1, Math.ceil((Date.parse(endDate) - Date.parse(startDate)) / 86_400_000));
|
|
132
|
+
setSpan(days <= 7 ? "7d" : days <= 30 ? "30d" : days <= 90 ? "90d" : "all");
|
|
133
|
+
}
|
|
134
|
+
dragRef.current = null;
|
|
135
|
+
setDragRange(null);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
if (loading && !data) return <div className="page-pad"><div className="muted">Loading dataset…</div></div>;
|
|
139
|
+
if (error && !data) return <div className="page-pad"><div className="muted error">{error}</div></div>;
|
|
140
|
+
if (!data || !view) return null;
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<div className="page-pad">
|
|
144
|
+
<div className="river-toolbar">
|
|
145
|
+
<span className="page-title">River</span>
|
|
146
|
+
<span className="muted small">{view.total} sessions · {view.laneRows.length} lanes · {view.dates.length} days</span>
|
|
147
|
+
<span className="header-spacer" />
|
|
148
|
+
{(Object.keys(SPAN_DAYS) as Span[]).map((s) => (
|
|
149
|
+
<button
|
|
150
|
+
key={s}
|
|
151
|
+
type="button"
|
|
152
|
+
className={`ctrl-btn${s === span ? " active" : ""}`}
|
|
153
|
+
onClick={() => setSpan(s)}
|
|
154
|
+
>{s}</button>
|
|
155
|
+
))}
|
|
156
|
+
</div>
|
|
157
|
+
|
|
158
|
+
<div
|
|
159
|
+
className={`river-grid card river-density-${density}`}
|
|
160
|
+
ref={gridRef}
|
|
161
|
+
onMouseDown={onMouseDown}
|
|
162
|
+
onMouseMove={onMouseMove}
|
|
163
|
+
onMouseUp={onMouseUp}
|
|
164
|
+
onMouseLeave={() => { dragRef.current = null; setDragRange(null); setHover(null); }}
|
|
165
|
+
style={{ ["--cells" as string]: view.dates.length }}
|
|
166
|
+
>
|
|
167
|
+
{dragRange && (
|
|
168
|
+
<div
|
|
169
|
+
className="river-drag-rect"
|
|
170
|
+
style={{ left: `${dragRange.from}px`, width: `${dragRange.to - dragRange.from}px` }}
|
|
171
|
+
/>
|
|
172
|
+
)}
|
|
173
|
+
<div className="river-row river-row-dates">
|
|
174
|
+
<div className="river-lane-label river-lane-label--header" aria-hidden="true" />
|
|
175
|
+
<div className="river-cells">
|
|
176
|
+
{view.dates.map((d) => (
|
|
177
|
+
<div key={d} className="river-date-cell" title={d}>{d.slice(5)}</div>
|
|
178
|
+
))}
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
{view.laneRows.map(({ entity, perDate, total }) => (
|
|
182
|
+
<div key={entity} className="river-row">
|
|
183
|
+
<button
|
|
184
|
+
type="button"
|
|
185
|
+
className="river-lane-label"
|
|
186
|
+
onClick={() => navigate(`/thread?entity=${encodeURIComponent(entity)}`)}
|
|
187
|
+
>
|
|
188
|
+
<span className="dot" style={{ background: data.entity_colors[entity] ?? "#666" }} />
|
|
189
|
+
<span className="river-lane-name">{entity}</span>
|
|
190
|
+
<span className="muted small">{total}</span>
|
|
191
|
+
</button>
|
|
192
|
+
<div className="river-cells">
|
|
193
|
+
{view.dates.map((d) => {
|
|
194
|
+
const v = perDate.get(d) ?? 0;
|
|
195
|
+
return (
|
|
196
|
+
<div
|
|
197
|
+
key={d}
|
|
198
|
+
className={`river-cell tier-${tier(v)}`}
|
|
199
|
+
onMouseEnter={(e) => setHover({ entity, date: d, count: v, x: e.clientX, y: e.clientY })}
|
|
200
|
+
onMouseMove={(e) => setHover({ entity, date: d, count: v, x: e.clientX, y: e.clientY })}
|
|
201
|
+
onMouseLeave={() => setHover(null)}
|
|
202
|
+
onClick={() => v > 0 && onCellClick(entity, d)}
|
|
203
|
+
style={v > 0 ? { cursor: "pointer" } : {}}
|
|
204
|
+
/>
|
|
205
|
+
);
|
|
206
|
+
})}
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
))}
|
|
210
|
+
</div>
|
|
211
|
+
|
|
212
|
+
{view.laneRows.length === 0 && <div className="muted">No entities in this window.</div>}
|
|
213
|
+
|
|
214
|
+
{hover && hover.count > 0 && (
|
|
215
|
+
<div className="river-hover" style={{ left: hover.x + 12, top: hover.y + 12 }}>
|
|
216
|
+
<span className="dot" style={{ background: data.entity_colors[hover.entity] ?? "#666" }} />
|
|
217
|
+
<span className="river-hover-name">{hover.entity}</span>
|
|
218
|
+
<span className="muted small">{hover.date} · {hover.count} session{hover.count === 1 ? "" : "s"}</span>
|
|
219
|
+
</div>
|
|
220
|
+
)}
|
|
221
|
+
|
|
222
|
+
{cellDrawer && (
|
|
223
|
+
<CellPicker
|
|
224
|
+
state={cellDrawer}
|
|
225
|
+
entityColor={data.entity_colors[cellDrawer.entity] ?? "#666"}
|
|
226
|
+
onClose={() => setCellDrawer(null)}
|
|
227
|
+
onPick={(sid) => { setCellDrawer(null); setSessionId(sid); }}
|
|
228
|
+
onOpenThread={() => navigate(`/thread?entity=${encodeURIComponent(cellDrawer.entity)}`)}
|
|
229
|
+
/>
|
|
230
|
+
)}
|
|
231
|
+
|
|
232
|
+
{sessionId && (
|
|
233
|
+
<SessionDrawer
|
|
234
|
+
sessionId={sessionId}
|
|
235
|
+
onClose={() => setSessionId(null)}
|
|
236
|
+
entityColor={(() => {
|
|
237
|
+
const s = data.sessions.find((x) => x.id === sessionId);
|
|
238
|
+
const e = s?.entities[0];
|
|
239
|
+
return e ? data.entity_colors[e] : undefined;
|
|
240
|
+
})()}
|
|
241
|
+
/>
|
|
242
|
+
)}
|
|
243
|
+
</div>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
interface CellPickerProps {
|
|
248
|
+
state: CellDrawerState;
|
|
249
|
+
entityColor: string;
|
|
250
|
+
onClose: () => void;
|
|
251
|
+
onPick: (sessionId: string) => void;
|
|
252
|
+
onOpenThread: () => void;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function CellPicker({ state, entityColor, onClose, onPick, onOpenThread }: CellPickerProps) {
|
|
256
|
+
useEffect(() => {
|
|
257
|
+
const onEsc = (e: KeyboardEvent) => { if (e.key === "Escape") onClose(); };
|
|
258
|
+
window.addEventListener("keydown", onEsc);
|
|
259
|
+
return () => window.removeEventListener("keydown", onEsc);
|
|
260
|
+
}, [onClose]);
|
|
261
|
+
|
|
262
|
+
return (
|
|
263
|
+
<>
|
|
264
|
+
<div className="drawer-backdrop" onClick={onClose} />
|
|
265
|
+
<aside className="session-drawer" role="dialog" aria-modal="true" aria-label={`Sessions on ${state.date}`}>
|
|
266
|
+
<header className="drawer-head">
|
|
267
|
+
<span className="dot lg" style={{ background: entityColor }} />
|
|
268
|
+
<h3 className="drawer-title">{state.entity}</h3>
|
|
269
|
+
<span className="muted small">{state.date}</span>
|
|
270
|
+
<button type="button" className="drawer-close" onClick={onClose} aria-label="Close">×</button>
|
|
271
|
+
</header>
|
|
272
|
+
<div className="drawer-body">
|
|
273
|
+
<p className="muted small">{state.sessions.length} sessions on this day. Pick one to inspect.</p>
|
|
274
|
+
<div className="drawer-actions">
|
|
275
|
+
<button type="button" className="btn btn-accent" onClick={onOpenThread}>Open thread</button>
|
|
276
|
+
</div>
|
|
277
|
+
<ul className="session-list">
|
|
278
|
+
{state.sessions.map((s) => (
|
|
279
|
+
<li
|
|
280
|
+
key={s.id}
|
|
281
|
+
className="session-row session-row-detail clickable"
|
|
282
|
+
onClick={() => onPick(s.id)}
|
|
283
|
+
role="button"
|
|
284
|
+
tabIndex={0}
|
|
285
|
+
onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); onPick(s.id); } }}
|
|
286
|
+
>
|
|
287
|
+
<span className={`chip-inline status-${s.status}`}>{s.status}</span>
|
|
288
|
+
<div className="session-row-main">
|
|
289
|
+
<span className="session-label">{s.label}</span>
|
|
290
|
+
<span className="session-meta">{s.summary}</span>
|
|
291
|
+
</div>
|
|
292
|
+
<span className="muted small mono">{relativeAge(s.started_at)}</span>
|
|
293
|
+
</li>
|
|
294
|
+
))}
|
|
295
|
+
</ul>
|
|
296
|
+
</div>
|
|
297
|
+
</aside>
|
|
298
|
+
</>
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function tier(v: number): 0 | 1 | 2 | 3 | 4 {
|
|
303
|
+
if (v === 0) return 0;
|
|
304
|
+
if (v === 1) return 1;
|
|
305
|
+
if (v <= 3) return 2;
|
|
306
|
+
if (v <= 6) return 3;
|
|
307
|
+
return 4;
|
|
308
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useMemo, useState } from "react";
|
|
2
|
+
import { Link, useSearchParams } from "react-router-dom";
|
|
3
|
+
import { useDataset, relativeAge } from "../lib/dataset.js";
|
|
4
|
+
|
|
5
|
+
export function SearchPage() {
|
|
6
|
+
const { data, loading, error } = useDataset();
|
|
7
|
+
const [params, setParams] = useSearchParams();
|
|
8
|
+
const q = params.get("q") ?? "";
|
|
9
|
+
const entity = params.get("entity") ?? "";
|
|
10
|
+
|
|
11
|
+
const [input, setInput] = useState(q);
|
|
12
|
+
|
|
13
|
+
const tokens = useMemo(() => {
|
|
14
|
+
const norm = q.toLowerCase().split(/\s+/).filter(Boolean);
|
|
15
|
+
return norm;
|
|
16
|
+
}, [q]);
|
|
17
|
+
|
|
18
|
+
const results = useMemo(() => {
|
|
19
|
+
if (!data) return [];
|
|
20
|
+
const sessions = entity
|
|
21
|
+
? data.sessions.filter((s) => s.entities.includes(entity))
|
|
22
|
+
: data.sessions;
|
|
23
|
+
if (tokens.length === 0) return sessions.slice(-50).reverse();
|
|
24
|
+
const scored = sessions
|
|
25
|
+
.map((s) => ({ session: s, score: score(s, tokens) }))
|
|
26
|
+
.filter((x) => x.score > 0)
|
|
27
|
+
.sort((a, b) => b.score - a.score)
|
|
28
|
+
.slice(0, 100);
|
|
29
|
+
return scored.map((x) => x.session);
|
|
30
|
+
}, [data, tokens, entity]);
|
|
31
|
+
|
|
32
|
+
const onSubmit = (e: React.FormEvent) => {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
const next = new URLSearchParams(params);
|
|
35
|
+
if (input) next.set("q", input);
|
|
36
|
+
else next.delete("q");
|
|
37
|
+
setParams(next);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className="page-pad">
|
|
42
|
+
<form onSubmit={onSubmit} className="search-bar">
|
|
43
|
+
<input
|
|
44
|
+
className="search-input search-big"
|
|
45
|
+
placeholder="search sessions, decisions, open questions…"
|
|
46
|
+
value={input}
|
|
47
|
+
onChange={(e) => setInput(e.target.value)}
|
|
48
|
+
autoFocus
|
|
49
|
+
/>
|
|
50
|
+
{entity && (
|
|
51
|
+
<span className="chip-inline">
|
|
52
|
+
entity: {entity}
|
|
53
|
+
<button type="button" className="chip-x" onClick={() => { const n = new URLSearchParams(params); n.delete("entity"); setParams(n); }}>×</button>
|
|
54
|
+
</span>
|
|
55
|
+
)}
|
|
56
|
+
</form>
|
|
57
|
+
|
|
58
|
+
{loading && !data && <div className="muted">Loading…</div>}
|
|
59
|
+
{error && <div className="muted error">{error}</div>}
|
|
60
|
+
|
|
61
|
+
<div className="muted small search-meta">
|
|
62
|
+
{results.length} result{results.length === 1 ? "" : "s"}
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
<ul className="session-list compact">
|
|
66
|
+
{results.map((s) => (
|
|
67
|
+
<li key={s.id} className="session-row">
|
|
68
|
+
<span className={`chip-inline status-${s.status}`}>{s.status}</span>
|
|
69
|
+
<Link to={`/thread?entity=${encodeURIComponent(s.entities[0] ?? "")}`} className="session-label">
|
|
70
|
+
{s.label}
|
|
71
|
+
</Link>
|
|
72
|
+
<span className="session-meta">{relativeAge(s.started_at)} · {s.entities.slice(0, 4).join(", ")}</span>
|
|
73
|
+
</li>
|
|
74
|
+
))}
|
|
75
|
+
</ul>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function score(s: { label: string; summary: string; decisions: string[]; open: string[]; entities: string[] }, tokens: string[]): number {
|
|
81
|
+
let total = 0;
|
|
82
|
+
const label = s.label.toLowerCase();
|
|
83
|
+
const summary = s.summary.toLowerCase();
|
|
84
|
+
const decisions = s.decisions.join(" ").toLowerCase();
|
|
85
|
+
const open = s.open.join(" ").toLowerCase();
|
|
86
|
+
for (const t of tokens) {
|
|
87
|
+
if (label.includes(t)) total += 3;
|
|
88
|
+
if (decisions.includes(t)) total += 2;
|
|
89
|
+
if (open.includes(t)) total += 2;
|
|
90
|
+
if (summary.includes(t)) total += 1;
|
|
91
|
+
}
|
|
92
|
+
return total;
|
|
93
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function StubPage({ page }: { page: string }) {
|
|
2
|
+
return (
|
|
3
|
+
<div className="stub-shell">
|
|
4
|
+
<span className="stub-name">/{page}</span>
|
|
5
|
+
<p>not yet ported from the Astro UI.</p>
|
|
6
|
+
<p className="stub-hint">Tracked in NocoDB #95 (Vite + React SPA port).</p>
|
|
7
|
+
</div>
|
|
8
|
+
);
|
|
9
|
+
}
|