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,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nlm connect hermes-agent` / `nlm disconnect hermes-agent` — installs the
|
|
3
|
+
* nlm-memory plugin into NousResearch Hermes Agent's plugin directory and
|
|
4
|
+
* optionally enables it via the `hermes` binary.
|
|
5
|
+
*
|
|
6
|
+
* The plugin lives in plugin-hermes-agent/ at the repo root. `connect`
|
|
7
|
+
* copies it to ~/.hermes/plugins/nlm-memory/ (flat layout, one category
|
|
8
|
+
* level max per Hermes plugin discovery rules). `disconnect` removes that
|
|
9
|
+
* directory.
|
|
10
|
+
*
|
|
11
|
+
* MCP server wiring (the [mcp_servers.nlm-memory] block in
|
|
12
|
+
* ~/.hermes/config.yaml) is handled separately by `nlm connect hermes`.
|
|
13
|
+
*/
|
|
14
|
+
export interface ConnectHermesAgentOptions {
|
|
15
|
+
readonly pluginSrcDir: string;
|
|
16
|
+
readonly dryRun?: boolean;
|
|
17
|
+
readonly enableViaCliIfAvailable?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface ConnectHermesAgentReport {
|
|
20
|
+
readonly destDir: string;
|
|
21
|
+
readonly copied: boolean;
|
|
22
|
+
readonly alreadyPresent: boolean;
|
|
23
|
+
readonly enabledViaCli: boolean;
|
|
24
|
+
readonly dryRun: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface DisconnectHermesAgentReport {
|
|
27
|
+
readonly destDir: string;
|
|
28
|
+
readonly removed: boolean;
|
|
29
|
+
readonly dryRun: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function hermesAgentPluginDir(): string;
|
|
32
|
+
export declare function connectHermesAgent(opts: ConnectHermesAgentOptions): ConnectHermesAgentReport;
|
|
33
|
+
export declare function disconnectHermesAgent(opts?: {
|
|
34
|
+
dryRun?: boolean;
|
|
35
|
+
}): DisconnectHermesAgentReport;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nlm connect hermes-agent` / `nlm disconnect hermes-agent` — installs the
|
|
3
|
+
* nlm-memory plugin into NousResearch Hermes Agent's plugin directory and
|
|
4
|
+
* optionally enables it via the `hermes` binary.
|
|
5
|
+
*
|
|
6
|
+
* The plugin lives in plugin-hermes-agent/ at the repo root. `connect`
|
|
7
|
+
* copies it to ~/.hermes/plugins/nlm-memory/ (flat layout, one category
|
|
8
|
+
* level max per Hermes plugin discovery rules). `disconnect` removes that
|
|
9
|
+
* directory.
|
|
10
|
+
*
|
|
11
|
+
* MCP server wiring (the [mcp_servers.nlm-memory] block in
|
|
12
|
+
* ~/.hermes/config.yaml) is handled separately by `nlm connect hermes`.
|
|
13
|
+
*/
|
|
14
|
+
import { cpSync, existsSync, mkdirSync, rmSync } from "node:fs";
|
|
15
|
+
import { homedir } from "node:os";
|
|
16
|
+
import { dirname, join } from "node:path";
|
|
17
|
+
import { spawnSync } from "node:child_process";
|
|
18
|
+
export function hermesAgentPluginDir() {
|
|
19
|
+
return process.env["NLM_HERMES_PLUGIN_DIR"] ?? join(homedir(), ".hermes", "plugins", "nlm-memory");
|
|
20
|
+
}
|
|
21
|
+
export function connectHermesAgent(opts) {
|
|
22
|
+
const destDir = hermesAgentPluginDir();
|
|
23
|
+
const alreadyPresent = existsSync(destDir);
|
|
24
|
+
if (!opts.dryRun) {
|
|
25
|
+
mkdirSync(dirname(destDir), { recursive: true });
|
|
26
|
+
cpSync(opts.pluginSrcDir, destDir, { recursive: true });
|
|
27
|
+
let enabledViaCli = false;
|
|
28
|
+
if (opts.enableViaCliIfAvailable !== false) {
|
|
29
|
+
const result = spawnSync("hermes", ["plugins", "enable", "nlm-memory"], {
|
|
30
|
+
encoding: "utf8",
|
|
31
|
+
timeout: 10_000,
|
|
32
|
+
});
|
|
33
|
+
enabledViaCli = result.status === 0;
|
|
34
|
+
}
|
|
35
|
+
return { destDir, copied: true, alreadyPresent, enabledViaCli, dryRun: false };
|
|
36
|
+
}
|
|
37
|
+
return { destDir, copied: false, alreadyPresent, enabledViaCli: false, dryRun: true };
|
|
38
|
+
}
|
|
39
|
+
export function disconnectHermesAgent(opts) {
|
|
40
|
+
const destDir = hermesAgentPluginDir();
|
|
41
|
+
const present = existsSync(destDir);
|
|
42
|
+
if (!opts?.dryRun && present) {
|
|
43
|
+
rmSync(destDir, { recursive: true, force: true });
|
|
44
|
+
return { destDir, removed: true, dryRun: false };
|
|
45
|
+
}
|
|
46
|
+
return { destDir, removed: false, dryRun: opts?.dryRun ?? false };
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=hermes-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hermes-agent.js","sourceRoot":"","sources":["../../src/install/hermes-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EA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vC,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAEpC,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACnD,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nlm connect hermes` / `nlm disconnect hermes` — writes the nlm-memory
|
|
3
|
+
* MCP server entry into ~/.hermes/config.yaml.
|
|
4
|
+
*
|
|
5
|
+
* Uses yaml's Document API (parseDocument / doc.setIn / doc.toString) to
|
|
6
|
+
* preserve any comments the user has written in their config file. Round-
|
|
7
|
+
* tripping through parse+stringify would silently destroy comments.
|
|
8
|
+
*/
|
|
9
|
+
export interface ConnectHermesOptions {
|
|
10
|
+
readonly nlmBinPath: string;
|
|
11
|
+
readonly nodeExecPath: string;
|
|
12
|
+
readonly dryRun?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface ConnectHermesReport {
|
|
15
|
+
readonly configPath: string;
|
|
16
|
+
readonly alreadyPresent: boolean;
|
|
17
|
+
readonly written: boolean;
|
|
18
|
+
readonly dryRun: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface DisconnectHermesReport {
|
|
21
|
+
readonly configPath: string;
|
|
22
|
+
readonly removed: boolean;
|
|
23
|
+
readonly dryRun: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function hermesConfigPath(): string;
|
|
26
|
+
export declare function connectHermes(opts: ConnectHermesOptions): ConnectHermesReport;
|
|
27
|
+
export declare function disconnectHermes(opts?: {
|
|
28
|
+
dryRun?: boolean;
|
|
29
|
+
}): DisconnectHermesReport;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nlm connect hermes` / `nlm disconnect hermes` — writes the nlm-memory
|
|
3
|
+
* MCP server entry into ~/.hermes/config.yaml.
|
|
4
|
+
*
|
|
5
|
+
* Uses yaml's Document API (parseDocument / doc.setIn / doc.toString) to
|
|
6
|
+
* preserve any comments the user has written in their config file. Round-
|
|
7
|
+
* tripping through parse+stringify would silently destroy comments.
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { homedir } from "node:os";
|
|
11
|
+
import { dirname, join } from "node:path";
|
|
12
|
+
import { Document as YamlDocument, parseDocument as parseYamlDocument } from "yaml";
|
|
13
|
+
export function hermesConfigPath() {
|
|
14
|
+
return process.env["NLM_HERMES_CONFIG"] ?? join(homedir(), ".hermes", "config.yaml");
|
|
15
|
+
}
|
|
16
|
+
function readDocument(path) {
|
|
17
|
+
if (!existsSync(path))
|
|
18
|
+
return new YamlDocument();
|
|
19
|
+
try {
|
|
20
|
+
return parseYamlDocument(readFileSync(path, "utf8"));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
throw new Error(`${path} is not valid YAML. Fix or remove it, then re-run \`nlm connect hermes\`.`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function connectHermes(opts) {
|
|
27
|
+
const configPath = hermesConfigPath();
|
|
28
|
+
const doc = readDocument(configPath);
|
|
29
|
+
const alreadyPresent = doc.getIn(["mcp_servers", "nlm-memory"]) !== undefined;
|
|
30
|
+
if (!opts.dryRun) {
|
|
31
|
+
doc.setIn(["mcp_servers", "nlm-memory"], {
|
|
32
|
+
command: opts.nodeExecPath,
|
|
33
|
+
args: [opts.nlmBinPath, "mcp"],
|
|
34
|
+
});
|
|
35
|
+
mkdirSync(dirname(configPath), { recursive: true });
|
|
36
|
+
writeFileSync(configPath, doc.toString(), "utf8");
|
|
37
|
+
}
|
|
38
|
+
return { configPath, alreadyPresent, written: !opts.dryRun, dryRun: opts.dryRun ?? false };
|
|
39
|
+
}
|
|
40
|
+
export function disconnectHermes(opts) {
|
|
41
|
+
const configPath = hermesConfigPath();
|
|
42
|
+
const doc = readDocument(configPath);
|
|
43
|
+
if (doc.getIn(["mcp_servers", "nlm-memory"]) === undefined) {
|
|
44
|
+
return { configPath, removed: false, dryRun: opts?.dryRun ?? false };
|
|
45
|
+
}
|
|
46
|
+
if (!opts?.dryRun) {
|
|
47
|
+
doc.deleteIn(["mcp_servers", "nlm-memory"]);
|
|
48
|
+
writeFileSync(configPath, doc.toString(), "utf8");
|
|
49
|
+
}
|
|
50
|
+
return { configPath, removed: true, dryRun: opts?.dryRun ?? false };
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=hermes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hermes.js","sourceRoot":"","sources":["../../src/install/hermes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAqBpF,MAAM,UAAU,gBAAgB;IAC9B,OAAO,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;AACvF,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,YAAY,EAAE,CAAC;IAC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CAAC;QAC3D,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC;IACvE,CAAC;IAED,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAClB,GAAG,CAAC,QAAQ,CAAC,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;QAC5C,aAAa,CAAC,UAAU,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ollama preflight helpers for `nlm setup`.
|
|
3
|
+
*
|
|
4
|
+
* Three cases handled:
|
|
5
|
+
* 1. Ollama not installed → install it
|
|
6
|
+
* 2. Ollama installed, server not responding → start the server
|
|
7
|
+
* 3. Embedding model missing → pull it
|
|
8
|
+
*
|
|
9
|
+
* Platform support:
|
|
10
|
+
* macOS — brew install / Ollama.app / brew services / open -a
|
|
11
|
+
* Linux — official install.sh / systemctl / detached spawn
|
|
12
|
+
* Windows — winget install / detached spawn
|
|
13
|
+
*/
|
|
14
|
+
export declare const EMBEDDING_MODEL = "nomic-embed-text";
|
|
15
|
+
export interface OllamaResult {
|
|
16
|
+
readonly ok: boolean;
|
|
17
|
+
readonly output: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function ollamaBinaryAvailable(): boolean;
|
|
20
|
+
/** Returns true if the Ollama server is accepting API requests. */
|
|
21
|
+
export declare function ollamaServerRunning(): boolean;
|
|
22
|
+
/** Returns true if nomic-embed-text is present in `ollama list`. */
|
|
23
|
+
export declare function embeddingModelPresent(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Install Ollama using the best available method for the current platform.
|
|
26
|
+
* Returns { ok: false } if no automated path exists — caller shows manual instructions.
|
|
27
|
+
*/
|
|
28
|
+
export declare function installOllama(): OllamaResult;
|
|
29
|
+
/**
|
|
30
|
+
* Start the Ollama server in the background.
|
|
31
|
+
*
|
|
32
|
+
* Platform preference:
|
|
33
|
+
* macOS + brew → brew services start ollama
|
|
34
|
+
* macOS + app → open -a Ollama
|
|
35
|
+
* Linux + systemd → systemctl start ollama (needs sudo; falls back to spawn)
|
|
36
|
+
* All others → detached spawn of `ollama serve`
|
|
37
|
+
*/
|
|
38
|
+
export declare function startOllamaServer(): OllamaResult;
|
|
39
|
+
/**
|
|
40
|
+
* Poll until the Ollama server is accepting requests or maxAttempts is reached.
|
|
41
|
+
* Returns true if the server came up, false on timeout.
|
|
42
|
+
*/
|
|
43
|
+
export declare function waitForOllamaServer(maxAttempts?: number, intervalMs?: number): Promise<boolean>;
|
|
44
|
+
/**
|
|
45
|
+
* Pull the embedding model. Blocks until complete (~1–3 min on first run, a
|
|
46
|
+
* few seconds on subsequent runs). The caller shows a spinner during this call.
|
|
47
|
+
*/
|
|
48
|
+
export declare function pullEmbeddingModel(): OllamaResult;
|
|
49
|
+
export type ClassifierChoice = "deepseek" | "ollama-offline";
|
|
50
|
+
/**
|
|
51
|
+
* Write classifier config to ~/.nlm/.env. Merges into the existing file —
|
|
52
|
+
* only the lines we manage are updated; anything the user added by hand stays.
|
|
53
|
+
*/
|
|
54
|
+
export declare function writeClassifierConfig(choice: ClassifierChoice, apiKey?: string): void;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ollama preflight helpers for `nlm setup`.
|
|
3
|
+
*
|
|
4
|
+
* Three cases handled:
|
|
5
|
+
* 1. Ollama not installed → install it
|
|
6
|
+
* 2. Ollama installed, server not responding → start the server
|
|
7
|
+
* 3. Embedding model missing → pull it
|
|
8
|
+
*
|
|
9
|
+
* Platform support:
|
|
10
|
+
* macOS — brew install / Ollama.app / brew services / open -a
|
|
11
|
+
* Linux — official install.sh / systemctl / detached spawn
|
|
12
|
+
* Windows — winget install / detached spawn
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
15
|
+
import { homedir, platform } from "node:os";
|
|
16
|
+
import { join } from "node:path";
|
|
17
|
+
import { spawnSync, spawn } from "node:child_process";
|
|
18
|
+
export const EMBEDDING_MODEL = "nomic-embed-text";
|
|
19
|
+
const OS = platform();
|
|
20
|
+
// ── Detection ─────────────────────────────────────────────────────────────
|
|
21
|
+
export function ollamaBinaryAvailable() {
|
|
22
|
+
const r = spawnSync("ollama", ["--version"], { encoding: "utf8" });
|
|
23
|
+
return r.status === 0;
|
|
24
|
+
}
|
|
25
|
+
/** Returns true if the Ollama server is accepting API requests. */
|
|
26
|
+
export function ollamaServerRunning() {
|
|
27
|
+
const r = spawnSync("ollama", ["list"], { encoding: "utf8" });
|
|
28
|
+
return r.status === 0;
|
|
29
|
+
}
|
|
30
|
+
/** Returns true if nomic-embed-text is present in `ollama list`. */
|
|
31
|
+
export function embeddingModelPresent() {
|
|
32
|
+
const r = spawnSync("ollama", ["list"], { encoding: "utf8" });
|
|
33
|
+
if (r.status !== 0)
|
|
34
|
+
return false;
|
|
35
|
+
return r.stdout.includes(EMBEDDING_MODEL);
|
|
36
|
+
}
|
|
37
|
+
function brewAvailable() {
|
|
38
|
+
return spawnSync("brew", ["--version"], { encoding: "utf8" }).status === 0;
|
|
39
|
+
}
|
|
40
|
+
function ollamaAppInstalled() {
|
|
41
|
+
return existsSync("/Applications/Ollama.app");
|
|
42
|
+
}
|
|
43
|
+
function wingetAvailable() {
|
|
44
|
+
return spawnSync("winget", ["--version"], { encoding: "utf8", shell: true }).status === 0;
|
|
45
|
+
}
|
|
46
|
+
function systemctlAvailable() {
|
|
47
|
+
return spawnSync("systemctl", ["--version"], { encoding: "utf8" }).status === 0;
|
|
48
|
+
}
|
|
49
|
+
// ── Install ───────────────────────────────────────────────────────────────
|
|
50
|
+
/**
|
|
51
|
+
* Install Ollama using the best available method for the current platform.
|
|
52
|
+
* Returns { ok: false } if no automated path exists — caller shows manual instructions.
|
|
53
|
+
*/
|
|
54
|
+
export function installOllama() {
|
|
55
|
+
if (OS === "darwin") {
|
|
56
|
+
if (brewAvailable()) {
|
|
57
|
+
const r = spawnSync("brew", ["install", "ollama"], { encoding: "utf8" });
|
|
58
|
+
return { ok: r.status === 0, output: (r.stdout + r.stderr).trim() };
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
ok: false,
|
|
62
|
+
output: "Homebrew not found. Download Ollama from https://ollama.com/download and re-run setup.",
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (OS === "linux") {
|
|
66
|
+
// Runs: curl -fsSL https://ollama.com/install.sh | sh
|
|
67
|
+
// The official Ollama installer — sets up the binary and a systemd service.
|
|
68
|
+
// Requires sudo internally and may modify /etc/systemd/. The caller is
|
|
69
|
+
// responsible for confirming this with the user before calling.
|
|
70
|
+
const r = spawnSync("sh", ["-c", "curl -fsSL --proto '=https' https://ollama.com/install.sh | sh"], {
|
|
71
|
+
encoding: "utf8",
|
|
72
|
+
timeout: 120_000,
|
|
73
|
+
});
|
|
74
|
+
return { ok: r.status === 0, output: (r.stdout + r.stderr).trim() };
|
|
75
|
+
}
|
|
76
|
+
if (OS === "win32") {
|
|
77
|
+
if (wingetAvailable()) {
|
|
78
|
+
const r = spawnSync("winget", ["install", "Ollama.Ollama"], { encoding: "utf8", shell: true });
|
|
79
|
+
return { ok: r.status === 0, output: (r.stdout + r.stderr).trim() };
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
ok: false,
|
|
83
|
+
output: "Download Ollama from https://ollama.com/download and re-run setup.",
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return { ok: false, output: `Unsupported platform: ${OS}. Install from https://ollama.com/download.` };
|
|
87
|
+
}
|
|
88
|
+
// ── Server start ──────────────────────────────────────────────────────────
|
|
89
|
+
/**
|
|
90
|
+
* Start the Ollama server in the background.
|
|
91
|
+
*
|
|
92
|
+
* Platform preference:
|
|
93
|
+
* macOS + brew → brew services start ollama
|
|
94
|
+
* macOS + app → open -a Ollama
|
|
95
|
+
* Linux + systemd → systemctl start ollama (needs sudo; falls back to spawn)
|
|
96
|
+
* All others → detached spawn of `ollama serve`
|
|
97
|
+
*/
|
|
98
|
+
export function startOllamaServer() {
|
|
99
|
+
if (OS === "darwin") {
|
|
100
|
+
if (brewAvailable()) {
|
|
101
|
+
const r = spawnSync("brew", ["services", "start", "ollama"], { encoding: "utf8" });
|
|
102
|
+
if (r.status === 0)
|
|
103
|
+
return { ok: true, output: "Started via brew services" };
|
|
104
|
+
}
|
|
105
|
+
if (ollamaAppInstalled()) {
|
|
106
|
+
const r = spawnSync("open", ["-a", "Ollama"], { encoding: "utf8" });
|
|
107
|
+
if (r.status === 0)
|
|
108
|
+
return { ok: true, output: "Started via Ollama.app" };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (OS === "linux" && systemctlAvailable()) {
|
|
112
|
+
// systemctl requires root — try without sudo first (works in user sessions
|
|
113
|
+
// where the service is installed under the current user), fall through on failure.
|
|
114
|
+
const r = spawnSync("systemctl", ["start", "ollama"], { encoding: "utf8" });
|
|
115
|
+
if (r.status === 0)
|
|
116
|
+
return { ok: true, output: "Started via systemctl" };
|
|
117
|
+
}
|
|
118
|
+
// Universal fallback: detach `ollama serve`.
|
|
119
|
+
try {
|
|
120
|
+
mkdirSync(join(homedir(), ".nlm", "logs"), { recursive: true });
|
|
121
|
+
const child = spawn("ollama", ["serve"], {
|
|
122
|
+
detached: true,
|
|
123
|
+
stdio: "ignore",
|
|
124
|
+
});
|
|
125
|
+
child.unref();
|
|
126
|
+
return { ok: true, output: `ollama serve started (pid ${child.pid})` };
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
return { ok: false, output: e instanceof Error ? e.message : String(e) };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Poll until the Ollama server is accepting requests or maxAttempts is reached.
|
|
134
|
+
* Returns true if the server came up, false on timeout.
|
|
135
|
+
*/
|
|
136
|
+
export async function waitForOllamaServer(maxAttempts = 15, intervalMs = 1000) {
|
|
137
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
138
|
+
if (ollamaServerRunning())
|
|
139
|
+
return true;
|
|
140
|
+
await new Promise((res) => setTimeout(res, intervalMs));
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
// ── Model pull ────────────────────────────────────────────────────────────
|
|
145
|
+
/**
|
|
146
|
+
* Pull the embedding model. Blocks until complete (~1–3 min on first run, a
|
|
147
|
+
* few seconds on subsequent runs). The caller shows a spinner during this call.
|
|
148
|
+
*/
|
|
149
|
+
export function pullEmbeddingModel() {
|
|
150
|
+
// Give the server a moment to accept connections if it was just started.
|
|
151
|
+
const r = spawnSync("ollama", ["pull", EMBEDDING_MODEL], { encoding: "utf8" });
|
|
152
|
+
return { ok: r.status === 0, output: (r.stdout + r.stderr).trim() };
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Write classifier config to ~/.nlm/.env. Merges into the existing file —
|
|
156
|
+
* only the lines we manage are updated; anything the user added by hand stays.
|
|
157
|
+
*/
|
|
158
|
+
export function writeClassifierConfig(choice, apiKey) {
|
|
159
|
+
const envPath = join(homedir(), ".nlm", ".env");
|
|
160
|
+
mkdirSync(join(homedir(), ".nlm"), { recursive: true });
|
|
161
|
+
const existing = existsSync(envPath) ? readFileSync(envPath, "utf8") : "";
|
|
162
|
+
const kept = existing
|
|
163
|
+
.split("\n")
|
|
164
|
+
.filter((l) => !l.startsWith("DEEPSEEK_API_KEY=") && !l.startsWith("NLM_CLASSIFIER="))
|
|
165
|
+
.join("\n")
|
|
166
|
+
.replace(/\n{3,}/g, "\n\n")
|
|
167
|
+
.trim();
|
|
168
|
+
const additions = [];
|
|
169
|
+
if (choice === "deepseek" && apiKey) {
|
|
170
|
+
// Strip newlines that clipboard paste can introduce.
|
|
171
|
+
const sanitized = apiKey.replace(/[\r\n]/g, "").trim();
|
|
172
|
+
additions.push(`DEEPSEEK_API_KEY=${sanitized}`);
|
|
173
|
+
}
|
|
174
|
+
if (choice === "ollama-offline")
|
|
175
|
+
additions.push("NLM_CLASSIFIER=ollama");
|
|
176
|
+
writeFileSync(envPath, [kept, ...additions].filter(Boolean).join("\n") + "\n", "utf8");
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=ollama.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ollama.js","sourceRoot":"","sources":["../../src/install/ollama.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAClD,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAC;AAOtB,6EAA6E;AAE7E,MAAM,UAAU,qBAAqB;IACnC,MAAM,CAAC,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IACnE,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACxB,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,mBAAmB;IACjC,MAAM,CAAC,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9D,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACx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 -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `nlm setup` — interactive first-run wizard.
|
|
3
|
+
*
|
|
4
|
+
* Step order:
|
|
5
|
+
* 1. Select runtimes
|
|
6
|
+
* 2. Ollama preflight (install → start server → pull embedding model)
|
|
7
|
+
* 3. Classifier API key
|
|
8
|
+
* 4. DB migrations
|
|
9
|
+
* 5. Daemon (LaunchAgent on macOS / systemd hint on Linux / Task Scheduler hint on Windows)
|
|
10
|
+
* 6. Per-runtime MCP + hook wiring
|
|
11
|
+
*/
|
|
12
|
+
import type { ClaudeHookEvent } from "../core/hook/claude-settings.js";
|
|
13
|
+
export interface SetupOptions {
|
|
14
|
+
readonly nlmBinPath: string;
|
|
15
|
+
readonly nodeExecPath: string;
|
|
16
|
+
readonly migrationsDir: string;
|
|
17
|
+
readonly repoRoot: string;
|
|
18
|
+
readonly dbPath: string;
|
|
19
|
+
readonly launchAgentLabel: string;
|
|
20
|
+
readonly launchAgentPlist: string;
|
|
21
|
+
readonly buildPlist: (nodeExec: string, binPath: string) => string;
|
|
22
|
+
readonly claudeSettingsPath: string;
|
|
23
|
+
readonly allHooks: ReadonlyArray<{
|
|
24
|
+
event: ClaudeHookEvent;
|
|
25
|
+
script: string;
|
|
26
|
+
label: string;
|
|
27
|
+
}>;
|
|
28
|
+
readonly addHook: (path: string, command: string, event?: ClaudeHookEvent) => void;
|
|
29
|
+
readonly removeHook: (path: string, event?: ClaudeHookEvent | "*") => void;
|
|
30
|
+
readonly buildHookCommand: (nodeExec: string, script: string, mode: "shadow" | "live") => string;
|
|
31
|
+
readonly smokeTestHookCommand: (command: string, logPath: string) => {
|
|
32
|
+
ok: boolean;
|
|
33
|
+
reason?: string;
|
|
34
|
+
stderr?: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export declare function runSetup(opts: SetupOptions): Promise<void>;
|