nlm-memory 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -34
- package/dist/cli/digest.d.ts +20 -0
- package/dist/cli/digest.js +142 -0
- package/dist/cli/digest.js.map +1 -0
- package/dist/cli/nlm.d.ts +1 -0
- package/dist/cli/nlm.js +25 -1
- package/dist/cli/nlm.js.map +1 -1
- package/dist/core/digest/compose.d.ts +38 -0
- package/dist/core/digest/compose.js +93 -0
- package/dist/core/digest/compose.js.map +1 -0
- package/dist/core/digest/hook-liveness.d.ts +32 -0
- package/dist/core/digest/hook-liveness.js +54 -0
- package/dist/core/digest/hook-liveness.js.map +1 -0
- package/dist/http/app.js +2 -1
- package/dist/http/app.js.map +1 -1
- package/dist/mcp/server.js +20 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/ui/assets/{index-C8cpwbYJ.css → index-Beo8psd-.css} +1 -1
- package/dist/ui/assets/{index-CB50QnL-.js → index-CSPTTeeM.js} +8 -8
- package/dist/ui/index.html +2 -2
- package/package.json +26 -1
- package/.agents/plugins/marketplace.json +0 -20
- package/.github/workflows/ci.yml +0 -30
- package/docs/methodology/re-derivation-rate.md +0 -112
- package/docs/methodology/useful-hit-rate.md +0 -79
- package/docs/plans/2026-05-20-fts5-lexical-recall.md +0 -1088
- package/docs/plans/2026-05-20-recall-daemon-wedge-fix.md +0 -662
- package/docs/plans/2026-05-20-recall-hook-design.md +0 -131
- package/docs/plans/2026-05-20-recall-hook-implementation.md +0 -1222
- package/docs/plans/desktop-product.md +0 -69
- package/docs/plans/factstore-design.md +0 -236
- package/logs/CHANGELOG/CHANGELOG-2026.md +0 -1575
- package/logs/CHANGELOG/CHANGELOG.md +0 -209
- package/migrations/000_initial_schema.sql +0 -174
- package/migrations/001_entity_type_rename.sql +0 -17
- package/migrations/002_adapter_state_extend.sql +0 -12
- package/migrations/003_session_embeddings.sql +0 -11
- package/migrations/004_facts.sql +0 -46
- package/migrations/005_sources.sql +0 -31
- package/migrations/006_providers.sql +0 -33
- package/migrations/007_source_tokens.sql +0 -17
- package/migrations/008_fts_rebuild.sql +0 -9
- package/migrations/009_session_embedding_chunks.sql +0 -46
- package/migrations/010_sources_opencode.sql +0 -30
- package/migrations/011_sources_hermes_agent.sql +0 -30
- package/migrations/012_sources_aider.sql +0 -30
- package/migrations/013_adapter_state_failure_count.sql +0 -12
- package/migrations/014_sources_cursor.sql +0 -30
- package/migrations/015_sources_windsurf.sql +0 -30
- package/plugin-hermes-agent/README.md +0 -49
- package/plugin-hermes-agent/__init__.py +0 -75
- package/plugin-hermes-agent/plugin.yaml +0 -15
- package/scripts/backfill-citations.mjs +0 -0
- package/scripts/build-codex-plugin.mjs +0 -61
- package/scripts/deepseek-probe.mjs +0 -67
- package/scripts/extract-triples.mjs +0 -207
- package/scripts/longmemeval/embedding-cache.ts +0 -77
- package/scripts/longmemeval/fetch-dataset.sh +0 -25
- package/scripts/longmemeval/run-harness.ts +0 -315
- package/scripts/longmemeval/scorer.ts +0 -99
- package/scripts/longmemeval/tsconfig.json +0 -9
- package/scripts/longmemeval/types.ts +0 -35
- package/scripts/nlm-daily-digest.py +0 -239
- package/scripts/nlm-daily-digest.sh +0 -28
- package/src/cli/classify-parity.ts +0 -257
- package/src/cli/launchctl-helpers.ts +0 -49
- package/src/cli/nlm.ts +0 -1078
- package/src/core/actions/actions-log.ts +0 -118
- package/src/core/actions/overlay.ts +0 -117
- package/src/core/adapters/aider.ts +0 -205
- package/src/core/adapters/claude-code.ts +0 -293
- package/src/core/adapters/common.ts +0 -54
- package/src/core/adapters/cursor.ts +0 -486
- package/src/core/adapters/from-source.ts +0 -67
- package/src/core/adapters/hermes-agent.ts +0 -240
- package/src/core/adapters/hermes.ts +0 -277
- package/src/core/adapters/jsonl-generic.ts +0 -208
- package/src/core/adapters/opencode.ts +0 -281
- package/src/core/adapters/pi.ts +0 -264
- package/src/core/adapters/windsurf.ts +0 -386
- package/src/core/classifier/prompt.ts +0 -200
- package/src/core/dataset/build-dataset.ts +0 -463
- package/src/core/embedding/chunk-body.ts +0 -76
- package/src/core/embedding/embed-backfill.ts +0 -210
- package/src/core/embedding/embed-normalize.ts +0 -135
- package/src/core/facts/backfill-facts.ts +0 -254
- package/src/core/facts/extract-facts.ts +0 -50
- package/src/core/hook/citation-detect.ts +0 -124
- package/src/core/hook/cite-memo.ts +0 -68
- package/src/core/hook/claude-settings.ts +0 -187
- package/src/core/hook/gate.ts +0 -25
- package/src/core/hook/hook-log.ts +0 -41
- package/src/core/hook/memo-sweep.ts +0 -164
- package/src/core/hook/memo.ts +0 -67
- package/src/core/hook/pointer-block.ts +0 -26
- package/src/core/hook/select.ts +0 -32
- package/src/core/hook/transcript.ts +0 -121
- package/src/core/ingest/ingest-session.ts +0 -111
- package/src/core/providers/provider-models.ts +0 -100
- package/src/core/providers/provider-registry.ts +0 -196
- package/src/core/recall/citation-log.ts +0 -108
- package/src/core/recall/filter.ts +0 -27
- package/src/core/recall/index.ts +0 -6
- package/src/core/recall/match-fields.ts +0 -40
- package/src/core/recall/query-log.ts +0 -149
- package/src/core/recall/query-shape.ts +0 -66
- package/src/core/recall/recall-service.ts +0 -320
- package/src/core/recall/recent-log.ts +0 -59
- package/src/core/recall/tokenize.ts +0 -18
- package/src/core/recall/useful-scan.ts +0 -336
- package/src/core/recall-facts/fact-query-log.ts +0 -150
- package/src/core/recall-facts/fact-recall-service.ts +0 -327
- package/src/core/scheduler/scan-once.ts +0 -142
- package/src/core/scheduler/scheduler.ts +0 -225
- package/src/core/sources/source-registry.ts +0 -278
- package/src/core/storage/db-restore.ts +0 -133
- package/src/core/storage/live-status.ts +0 -45
- package/src/core/storage/migrate.ts +0 -72
- package/src/core/storage/sqlite-fact-store.ts +0 -304
- package/src/core/storage/sqlite-session-store.ts +0 -810
- package/src/hook/hook-auth.ts +0 -18
- package/src/hook/prompt-recall-hook.ts +0 -180
- package/src/hook/session-end-hook.ts +0 -81
- package/src/hook/session-start-hook.ts +0 -168
- package/src/hook/stop-hook.ts +0 -239
- package/src/http/app.ts +0 -1215
- package/src/install/claude-code.ts +0 -128
- package/src/install/codex.ts +0 -367
- package/src/install/cursor.ts +0 -68
- package/src/install/hermes-agent.ts +0 -76
- package/src/install/hermes.ts +0 -78
- package/src/install/nlm-dir-perms.ts +0 -55
- package/src/install/ollama.ts +0 -284
- package/src/install/setup.ts +0 -489
- package/src/install/windsurf.ts +0 -68
- package/src/llm/classifier-box.ts +0 -64
- package/src/llm/deepseek-client.ts +0 -150
- package/src/llm/env-autoload.ts +0 -55
- package/src/llm/ollama-client.ts +0 -189
- package/src/mcp/server.ts +0 -534
- package/src/ports/fact-store.ts +0 -102
- package/src/ports/llm-client.ts +0 -52
- package/src/ports/logger.ts +0 -16
- package/src/ports/session-store.ts +0 -45
- package/src/ports/transcript-adapter.ts +0 -55
- package/src/shared/types.ts +0 -149
- package/src/ui/App.tsx +0 -58
- package/src/ui/components/PromoteOpenButton.tsx +0 -65
- package/src/ui/components/SessionDrawer.tsx +0 -199
- package/src/ui/components/SideNav.tsx +0 -162
- package/src/ui/components/Skeleton.tsx +0 -107
- package/src/ui/index.html +0 -13
- package/src/ui/lib/actions.ts +0 -30
- package/src/ui/lib/api.ts +0 -92
- package/src/ui/lib/dataset.ts +0 -141
- package/src/ui/lib/registries.ts +0 -155
- package/src/ui/lib/view-settings.ts +0 -41
- package/src/ui/main.tsx +0 -15
- package/src/ui/pages/Live.tsx +0 -229
- package/src/ui/pages/Pulse.tsx +0 -415
- package/src/ui/pages/Recall.tsx +0 -190
- package/src/ui/pages/River.tsx +0 -354
- package/src/ui/pages/Search.tsx +0 -386
- package/src/ui/pages/Stub.tsx +0 -9
- package/src/ui/pages/Thread.tsx +0 -473
- package/src/ui/pages/settings/Classifier.tsx +0 -227
- package/src/ui/pages/settings/Data.tsx +0 -190
- package/src/ui/pages/settings/Index.tsx +0 -65
- package/src/ui/pages/settings/Labels.tsx +0 -224
- package/src/ui/pages/settings/Providers.tsx +0 -305
- package/src/ui/pages/settings/SettingsSubnav.tsx +0 -28
- package/src/ui/pages/settings/Sources.tsx +0 -326
- package/src/ui/pages/settings/Views.tsx +0 -96
- package/src/ui/styles.css +0 -1890
- package/src/ui/tsconfig.json +0 -21
- package/src/ui/vite.config.ts +0 -19
- package/tests/fixtures/claude_code/short_session.jsonl +0 -2
- package/tests/fixtures/claude_code/standard_iso.jsonl +0 -4
- package/tests/fixtures/claude_code/tool_heavy.jsonl +0 -8
- package/tests/fixtures/claude_code/with_subagent.jsonl +0 -7
- package/tests/fixtures/facts.ts +0 -17
- package/tests/fixtures/golden-corpus.ts +0 -85
- package/tests/fixtures/hermes/paired_request_dump.json +0 -24
- package/tests/fixtures/hermes/paired_session.json +0 -23
- package/tests/fixtures/hermes/request_dump.json +0 -28
- package/tests/fixtures/hermes/session_iso.json +0 -38
- package/tests/fixtures/hermes/session_unix.json +0 -38
- package/tests/fixtures/hermes/system_only.json +0 -18
- package/tests/fixtures/pi/error-connection-abort.jsonl +0 -8
- package/tests/fixtures/pi/short-successful.jsonl +0 -5
- package/tests/fixtures/pi/with-custom-message.jsonl +0 -6
- package/tests/fixtures/sessions.ts +0 -22
- package/tests/integration/backfill-facts.test.ts +0 -362
- package/tests/integration/citation-explicit.test.ts +0 -111
- package/tests/integration/cite-event.test.ts +0 -169
- package/tests/integration/cite-memo.test.ts +0 -87
- package/tests/integration/db-restore.test.ts +0 -153
- package/tests/integration/embed-backfill.test.ts +0 -176
- package/tests/integration/fact-supersedence.test.ts +0 -313
- package/tests/integration/fts-index.test.ts +0 -60
- package/tests/integration/getbyids-sqlite.test.ts +0 -100
- package/tests/integration/hermes-agent-hooks.test.ts +0 -248
- package/tests/integration/hook-claude-settings.test.ts +0 -218
- package/tests/integration/hook-log.test.ts +0 -54
- package/tests/integration/hook-memo.test.ts +0 -68
- package/tests/integration/hook-pre-compact.test.ts +0 -105
- package/tests/integration/hook-subagent-start.test.ts +0 -102
- package/tests/integration/http.test.ts +0 -401
- package/tests/integration/keyword-search-fts.test.ts +0 -66
- package/tests/integration/mcp-recall-logging.test.ts +0 -88
- package/tests/integration/mcp.test.ts +0 -260
- package/tests/integration/memo-sweep.test.ts +0 -91
- package/tests/integration/prompt-recall-hook.test.ts +0 -88
- package/tests/integration/provider-registry.test.ts +0 -107
- package/tests/integration/recall-golden.test.ts +0 -59
- package/tests/integration/recall-sqlite.test.ts +0 -169
- package/tests/integration/scheduler.test.ts +0 -391
- package/tests/integration/session-end-hook.test.ts +0 -48
- package/tests/integration/session-start-hook.test.ts +0 -126
- package/tests/integration/source-registry.test.ts +0 -122
- package/tests/integration/sqlite-fact-store.test.ts +0 -346
- package/tests/integration/stop-hook.test.ts +0 -560
- package/tests/integration/wal-checkpoint.test.ts +0 -49
- package/tests/unit/cli/launchctl-helpers.test.ts +0 -60
- package/tests/unit/core/adapters/aider.test.ts +0 -230
- package/tests/unit/core/adapters/claude-code.test.ts +0 -118
- package/tests/unit/core/adapters/cursor.test.ts +0 -485
- package/tests/unit/core/adapters/hermes-agent.test.ts +0 -329
- package/tests/unit/core/adapters/hermes.test.ts +0 -81
- package/tests/unit/core/adapters/jsonl-generic.test.ts +0 -142
- package/tests/unit/core/adapters/opencode.test.ts +0 -354
- package/tests/unit/core/adapters/pi.test.ts +0 -110
- package/tests/unit/core/adapters/windsurf.test.ts +0 -416
- package/tests/unit/core/classifier/prompt.test.ts +0 -126
- package/tests/unit/core/embedding/chunk-body.test.ts +0 -100
- package/tests/unit/core/facts/extract-facts.test.ts +0 -117
- package/tests/unit/core/filter.test.ts +0 -40
- package/tests/unit/core/hook/citation-detect-cite-session.test.ts +0 -96
- package/tests/unit/core/hook/citation-detect.test.ts +0 -124
- package/tests/unit/core/hook/gate.test.ts +0 -29
- package/tests/unit/core/hook/pointer-block.test.ts +0 -22
- package/tests/unit/core/hook/select.test.ts +0 -66
- package/tests/unit/core/match-fields.test.ts +0 -39
- package/tests/unit/core/mcp-cite-session.test.ts +0 -51
- package/tests/unit/core/providers/provider-models.test.ts +0 -101
- package/tests/unit/core/query-shape.test.ts +0 -92
- package/tests/unit/core/recall-facts/fact-recall-service.test.ts +0 -258
- package/tests/unit/core/recall-service.test.ts +0 -200
- package/tests/unit/core/storage/live-status.test.ts +0 -54
- package/tests/unit/core/tokenize.test.ts +0 -32
- package/tests/unit/core/useful-scan.test.ts +0 -537
- package/tests/unit/llm/embed.test.ts +0 -93
- package/tests/unit/llm/ollama-client.test.ts +0 -124
- package/tests/unit/scripts/longmemeval-scorer.test.ts +0 -114
- package/tsconfig.json +0 -31
- package/tsconfig.test.json +0 -11
- package/vitest.config.ts +0 -22
package/src/install/setup.ts
DELETED
|
@@ -1,489 +0,0 @@
|
|
|
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
|
-
|
|
13
|
-
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
14
|
-
import { execFileSync } from "node:child_process";
|
|
15
|
-
import { homedir, platform } from "node:os";
|
|
16
|
-
import { dirname, join } from "node:path";
|
|
17
|
-
import {
|
|
18
|
-
cancel, confirm, intro, isCancel, log, multiselect, outro, password, select, spinner,
|
|
19
|
-
} from "@clack/prompts";
|
|
20
|
-
import { connectClaudeCode } from "./claude-code.js";
|
|
21
|
-
import { connectHermes } from "./hermes.js";
|
|
22
|
-
import { codexBinaryAvailable, connectCodex, pluginScriptsDir } from "./codex.js";
|
|
23
|
-
import { defaultDbPath as openCodeDefaultDbPath } from "../core/adapters/opencode.js";
|
|
24
|
-
import type { ClaudeHookEvent } from "../core/hook/claude-settings.js";
|
|
25
|
-
import {
|
|
26
|
-
type ClassifierChoice,
|
|
27
|
-
EMBEDDING_MODEL,
|
|
28
|
-
embeddingModelPresent,
|
|
29
|
-
ensureMcpToken,
|
|
30
|
-
installOllama,
|
|
31
|
-
ollamaBinaryAvailable,
|
|
32
|
-
ollamaServerRunning,
|
|
33
|
-
pullEmbeddingModel,
|
|
34
|
-
startOllamaServer,
|
|
35
|
-
waitForOllamaServer,
|
|
36
|
-
writeClassifierConfig,
|
|
37
|
-
} from "./ollama.js";
|
|
38
|
-
import { installClaudeCodeHooks } from "./claude-code.js";
|
|
39
|
-
import { hardenNlmDirPermissions } from "./nlm-dir-perms.js";
|
|
40
|
-
|
|
41
|
-
const OS = platform();
|
|
42
|
-
|
|
43
|
-
export interface SetupOptions {
|
|
44
|
-
readonly nlmBinPath: string;
|
|
45
|
-
readonly nodeExecPath: string;
|
|
46
|
-
readonly migrationsDir: string;
|
|
47
|
-
readonly repoRoot: string;
|
|
48
|
-
readonly dbPath: string;
|
|
49
|
-
readonly launchAgentLabel: string;
|
|
50
|
-
readonly launchAgentPlist: string;
|
|
51
|
-
readonly buildPlist: (nodeExec: string, binPath: string) => string;
|
|
52
|
-
readonly linuxSystemdUnitName: string;
|
|
53
|
-
readonly linuxSystemdUnitPath: string;
|
|
54
|
-
readonly buildSystemdUnit: (nodeExec: string, binPath: string) => string;
|
|
55
|
-
readonly linuxSystemdUserAvailable: () => boolean;
|
|
56
|
-
readonly claudeSettingsPath: string;
|
|
57
|
-
readonly allHooks: ReadonlyArray<{
|
|
58
|
-
event: ClaudeHookEvent;
|
|
59
|
-
script: string;
|
|
60
|
-
label: string;
|
|
61
|
-
}>;
|
|
62
|
-
readonly addHook: (path: string, command: string, event?: ClaudeHookEvent) => void;
|
|
63
|
-
readonly removeHook: (path: string, event?: ClaudeHookEvent | "*") => void;
|
|
64
|
-
readonly buildHookCommand: (nodeExec: string, script: string, mode: "shadow" | "live") => string;
|
|
65
|
-
readonly smokeTestHookCommand: (command: string, logPath: string) => { ok: boolean; reason?: string; stderr?: string };
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Embedding-only tags shouldn't be offered as classifier models — they
|
|
69
|
-
// can't run chat completions and the call would fail at first ingest.
|
|
70
|
-
const EMBEDDING_MODEL_PREFIXES = ["nomic-embed", "mxbai-embed", "snowflake-arctic-embed", "bge-"] as const;
|
|
71
|
-
|
|
72
|
-
async function fetchOllamaChatModels(timeoutMs = 5000): Promise<string[]> {
|
|
73
|
-
const baseUrl = process.env["NLM_OLLAMA_URL"] ?? "http://localhost:11434";
|
|
74
|
-
const controller = new AbortController();
|
|
75
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
76
|
-
try {
|
|
77
|
-
const res = await fetch(`${baseUrl}/api/tags`, { signal: controller.signal });
|
|
78
|
-
if (!res.ok) return [];
|
|
79
|
-
const data = (await res.json()) as { models?: Array<{ name?: string }> };
|
|
80
|
-
return (data.models ?? [])
|
|
81
|
-
.map((m) => m.name)
|
|
82
|
-
.filter((n): n is string => typeof n === "string")
|
|
83
|
-
.filter((n) => !EMBEDDING_MODEL_PREFIXES.some((p) => n.startsWith(p)))
|
|
84
|
-
.sort();
|
|
85
|
-
} catch {
|
|
86
|
-
return [];
|
|
87
|
-
} finally {
|
|
88
|
-
clearTimeout(timer);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
type RuntimeId = "claude-code" | "codex" | "opencode" | "hermes" | "pi";
|
|
93
|
-
|
|
94
|
-
interface RuntimeOption {
|
|
95
|
-
readonly id: RuntimeId;
|
|
96
|
-
readonly label: string;
|
|
97
|
-
readonly hint: string;
|
|
98
|
-
readonly detected: boolean;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function detectRuntimes(): RuntimeOption[] {
|
|
102
|
-
const claudeProjectsPath = process.env["NLM_CLAUDE_PROJECTS_PATH"]
|
|
103
|
-
?? join(homedir(), ".claude", "projects");
|
|
104
|
-
const hermesPath = process.env["NLM_HERMES_SESSIONS_PATH"]
|
|
105
|
-
?? join(homedir(), ".hermes", "sessions");
|
|
106
|
-
const piPath = process.env["PI_SESSIONS_PATH"]
|
|
107
|
-
?? join(homedir(), ".pi", "agent", "sessions");
|
|
108
|
-
const openCodeDb = openCodeDefaultDbPath();
|
|
109
|
-
|
|
110
|
-
return [
|
|
111
|
-
{
|
|
112
|
-
id: "claude-code",
|
|
113
|
-
label: "Claude Code",
|
|
114
|
-
hint: existsSync(claudeProjectsPath) ? "detected" : "not found",
|
|
115
|
-
detected: existsSync(claudeProjectsPath),
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
id: "codex",
|
|
119
|
-
label: "Codex (OpenAI)",
|
|
120
|
-
hint: codexBinaryAvailable() ? "detected" : "not found — install: npm i -g @openai/codex",
|
|
121
|
-
detected: codexBinaryAvailable(),
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
id: "opencode",
|
|
125
|
-
label: "OpenCode (sst)",
|
|
126
|
-
hint: existsSync(openCodeDb) ? "detected" : "not found",
|
|
127
|
-
detected: existsSync(openCodeDb),
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
id: "hermes",
|
|
131
|
-
label: "Hermes",
|
|
132
|
-
hint: existsSync(hermesPath) ? "detected" : "not found",
|
|
133
|
-
detected: existsSync(hermesPath),
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
id: "pi",
|
|
137
|
-
label: "pi.dev",
|
|
138
|
-
hint: existsSync(piPath) ? "detected" : "not found",
|
|
139
|
-
detected: existsSync(piPath),
|
|
140
|
-
},
|
|
141
|
-
];
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export async function runSetup(opts: SetupOptions): Promise<void> {
|
|
145
|
-
intro("NLM Memory — first-run setup");
|
|
146
|
-
|
|
147
|
-
// ── Step 1: runtime selection ─────────────────────────────────────────
|
|
148
|
-
const runtimes = detectRuntimes();
|
|
149
|
-
const detectedIds = runtimes.filter((r) => r.detected).map((r) => r.id);
|
|
150
|
-
|
|
151
|
-
const selected = await multiselect<RuntimeId>({
|
|
152
|
-
message: "Which AI coding runtimes do you use?",
|
|
153
|
-
options: runtimes.map((r) => ({ value: r.id, label: r.label, hint: r.hint })),
|
|
154
|
-
initialValues: detectedIds,
|
|
155
|
-
required: false,
|
|
156
|
-
});
|
|
157
|
-
if (isCancel(selected)) { cancel("Setup cancelled."); process.exit(0); }
|
|
158
|
-
const chosen = selected as RuntimeId[];
|
|
159
|
-
|
|
160
|
-
// ── Step 2: Ollama preflight ──────────────────────────────────────────
|
|
161
|
-
if (!ollamaBinaryAvailable()) {
|
|
162
|
-
const installMsg = OS === "linux"
|
|
163
|
-
? "Ollama not found. Install now? (runs the official install.sh as current user — see https://ollama.com/install.sh)"
|
|
164
|
-
: "Ollama not found. Install it now? (required for memory indexing)";
|
|
165
|
-
const doInstall = await confirm({ message: installMsg });
|
|
166
|
-
if (isCancel(doInstall)) { cancel("Setup cancelled."); process.exit(0); }
|
|
167
|
-
|
|
168
|
-
if (doInstall) {
|
|
169
|
-
const is = spinner();
|
|
170
|
-
is.start("Installing Ollama");
|
|
171
|
-
const result = installOllama();
|
|
172
|
-
if (result.ok) {
|
|
173
|
-
is.stop("Ollama installed");
|
|
174
|
-
} else {
|
|
175
|
-
is.stop("Ollama install failed");
|
|
176
|
-
log.warn(result.output);
|
|
177
|
-
log.warn("Install Ollama manually from https://ollama.com/download, then re-run `nlm setup`.");
|
|
178
|
-
}
|
|
179
|
-
} else {
|
|
180
|
-
log.warn("Skipping Ollama install — memory indexing won't work until Ollama is running with nomic-embed-text.");
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Ensure server is running before attempting pull.
|
|
185
|
-
if (ollamaBinaryAvailable() && !ollamaServerRunning()) {
|
|
186
|
-
const ss = spinner();
|
|
187
|
-
ss.start("Starting Ollama server");
|
|
188
|
-
const result = startOllamaServer();
|
|
189
|
-
if (result.ok) {
|
|
190
|
-
ss.start("Waiting for Ollama server to accept connections");
|
|
191
|
-
const ready = await waitForOllamaServer(15, 1000);
|
|
192
|
-
if (ready) {
|
|
193
|
-
ss.stop("Ollama server ready");
|
|
194
|
-
} else {
|
|
195
|
-
ss.stop("Ollama server started but not responding yet");
|
|
196
|
-
log.warn("If the model pull fails, wait a moment and run `ollama pull nomic-embed-text` manually.");
|
|
197
|
-
}
|
|
198
|
-
} else {
|
|
199
|
-
ss.stop("Could not start Ollama server automatically");
|
|
200
|
-
log.warn(`Start it manually with \`ollama serve\`, then re-run \`nlm setup\`. (${result.output})`);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (ollamaBinaryAvailable() && !embeddingModelPresent()) {
|
|
205
|
-
const doPull = await confirm({ message: `Pull the ${EMBEDDING_MODEL} embedding model now? (~274 MB, required for semantic recall)` });
|
|
206
|
-
if (isCancel(doPull)) { cancel("Setup cancelled."); process.exit(0); }
|
|
207
|
-
|
|
208
|
-
if (doPull) {
|
|
209
|
-
const ps = spinner();
|
|
210
|
-
ps.start(`Pulling ${EMBEDDING_MODEL} (this may take a few minutes)`);
|
|
211
|
-
const result = pullEmbeddingModel();
|
|
212
|
-
if (result.ok) {
|
|
213
|
-
ps.stop(`${EMBEDDING_MODEL} ready`);
|
|
214
|
-
} else {
|
|
215
|
-
ps.stop("Model pull failed");
|
|
216
|
-
log.warn(`Run \`ollama pull ${EMBEDDING_MODEL}\` manually to retry.`);
|
|
217
|
-
}
|
|
218
|
-
} else {
|
|
219
|
-
log.warn(`Skipping model pull — run \`ollama pull ${EMBEDDING_MODEL}\` before using memory recall.`);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (ollamaBinaryAvailable() && embeddingModelPresent()) {
|
|
224
|
-
log.success(`Ollama ready — ${EMBEDDING_MODEL} present`);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// ── Step 3: classifier (provider + model + key) ───────────────────────
|
|
228
|
-
const wantConfigure = await confirm({
|
|
229
|
-
message: "Configure the session classifier? (controls how new sessions are tagged)",
|
|
230
|
-
});
|
|
231
|
-
if (isCancel(wantConfigure)) { cancel("Setup cancelled."); process.exit(0); }
|
|
232
|
-
|
|
233
|
-
if (wantConfigure) {
|
|
234
|
-
const classifierChoice = await select<ClassifierChoice>({
|
|
235
|
-
message: "Which classifier provider?",
|
|
236
|
-
options: [
|
|
237
|
-
{
|
|
238
|
-
value: "deepseek",
|
|
239
|
-
label: "DeepSeek (cloud)",
|
|
240
|
-
hint: "fast, cheap (~$0.002/session). Transcripts are sent to api.deepseek.com.",
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
value: "ollama-offline",
|
|
244
|
-
label: "Ollama (local)",
|
|
245
|
-
hint: "private — runs on this machine via your local Ollama. Slower; needs a chat model pulled.",
|
|
246
|
-
},
|
|
247
|
-
],
|
|
248
|
-
});
|
|
249
|
-
if (isCancel(classifierChoice)) { cancel("Setup cancelled."); process.exit(0); }
|
|
250
|
-
|
|
251
|
-
if (classifierChoice === "deepseek") {
|
|
252
|
-
log.info("Heads up: DeepSeek classification sends up to 30K chars of each session transcript to api.deepseek.com.");
|
|
253
|
-
log.info(" Anything in a transcript (pasted keys, client names, internal URLs) leaves this machine.");
|
|
254
|
-
log.info(" Pick Ollama (local) above if that's not acceptable.");
|
|
255
|
-
|
|
256
|
-
const model = await select<string>({
|
|
257
|
-
message: "Which DeepSeek model?",
|
|
258
|
-
options: [
|
|
259
|
-
{ value: "deepseek-v4-flash", label: "deepseek-v4-flash", hint: "recommended — fast + cheap, ~$0.002/session" },
|
|
260
|
-
{ value: "deepseek-v4-pro", label: "deepseek-v4-pro", hint: "higher quality, ~10× cost" },
|
|
261
|
-
{ value: "deepseek-chat", label: "deepseek-chat", hint: "legacy chat model" },
|
|
262
|
-
],
|
|
263
|
-
});
|
|
264
|
-
if (isCancel(model)) { cancel("Setup cancelled."); process.exit(0); }
|
|
265
|
-
|
|
266
|
-
const key = await password({ message: "DeepSeek API key (get one at platform.deepseek.com):" });
|
|
267
|
-
if (isCancel(key)) { cancel("Setup cancelled."); process.exit(0); }
|
|
268
|
-
const apiKey = key && (key as string).trim() ? (key as string).trim() : undefined;
|
|
269
|
-
writeClassifierConfig(apiKey !== undefined
|
|
270
|
-
? { choice: "deepseek", model: model as string, apiKey }
|
|
271
|
-
: { choice: "deepseek", model: model as string });
|
|
272
|
-
if (apiKey) {
|
|
273
|
-
log.success(`DeepSeek (${model as string}) configured — credentials saved to ~/.nlm/.env`);
|
|
274
|
-
} else {
|
|
275
|
-
log.warn(`DeepSeek (${model as string}) configured — set DEEPSEEK_API_KEY in ~/.nlm/.env before running.`);
|
|
276
|
-
}
|
|
277
|
-
} else {
|
|
278
|
-
const ollamaModels = await fetchOllamaChatModels();
|
|
279
|
-
let modelValue = "phi4-mini:latest";
|
|
280
|
-
if (ollamaModels.length > 0) {
|
|
281
|
-
const model = await select<string>({
|
|
282
|
-
message: "Which Ollama chat model?",
|
|
283
|
-
options: ollamaModels.map((m) => ({
|
|
284
|
-
value: m,
|
|
285
|
-
label: m,
|
|
286
|
-
hint: m === "phi4-mini:latest" ? "recommended default — small, fast" : undefined,
|
|
287
|
-
})) as { value: string; label: string; hint?: string }[],
|
|
288
|
-
});
|
|
289
|
-
if (isCancel(model)) { cancel("Setup cancelled."); process.exit(0); }
|
|
290
|
-
modelValue = model as string;
|
|
291
|
-
} else {
|
|
292
|
-
log.warn("No Ollama chat models detected. Defaulting to phi4-mini:latest.");
|
|
293
|
-
log.warn(" Pull a model with: ollama pull phi4-mini (or any chat model you prefer)");
|
|
294
|
-
}
|
|
295
|
-
writeClassifierConfig({ choice: "ollama-offline", model: modelValue });
|
|
296
|
-
log.success(`Ollama classifier (${modelValue}) saved to ~/.nlm/.env`);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// ── Step 3.5: HTTP API auth token ─────────────────────────────────────
|
|
301
|
-
// Generate a token if one isn't set so /api/* gets Bearer-protected for
|
|
302
|
-
// non-browser callers (curl, port-forwarded clients). The UI still works
|
|
303
|
-
// because browsers send Origin and we exempt loopback origins.
|
|
304
|
-
const token = ensureMcpToken();
|
|
305
|
-
if (token === process.env["NLM_MCP_TOKEN"] && token.length === 64) {
|
|
306
|
-
log.success("HTTP API auth token saved to ~/.nlm/.env (NLM_MCP_TOKEN)");
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// ── Step 4: migrations ────────────────────────────────────────────────
|
|
310
|
-
const ms = spinner();
|
|
311
|
-
ms.start("Running database migrations");
|
|
312
|
-
try {
|
|
313
|
-
const { SqliteSessionStore } = await import("../core/storage/sqlite-session-store.js");
|
|
314
|
-
const store = new SqliteSessionStore({ dbPath: opts.dbPath, migrationsDir: opts.migrationsDir });
|
|
315
|
-
store.close();
|
|
316
|
-
ms.stop("Database ready");
|
|
317
|
-
} catch (e) {
|
|
318
|
-
ms.stop("Migration failed");
|
|
319
|
-
log.error(`${e instanceof Error ? e.message : String(e)}`);
|
|
320
|
-
process.exit(1);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// ── Step 4.5: harden ~/.nlm permissions ────────────────────────────────
|
|
324
|
-
// Idempotent. Covers upgrade from pre-v0.4.2 installs where files were
|
|
325
|
-
// written without explicit chmod, leaving secrets world-readable.
|
|
326
|
-
const perms = hardenNlmDirPermissions();
|
|
327
|
-
if (perms.filesHardened + perms.dirsHardened > 0) {
|
|
328
|
-
log.success(`Hardened perms on ${perms.dirsHardened} dirs and ${perms.filesHardened} files in ${perms.nlmDir}`);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// ── Step 5: daemon ────────────────────────────────────────────────────
|
|
332
|
-
if (OS === "darwin") {
|
|
333
|
-
const installDaemon = await confirm({ message: "Install macOS LaunchAgent (auto-start on login)?" });
|
|
334
|
-
if (isCancel(installDaemon)) { cancel("Setup cancelled."); process.exit(0); }
|
|
335
|
-
|
|
336
|
-
if (installDaemon) {
|
|
337
|
-
const ds = spinner();
|
|
338
|
-
ds.start("Installing LaunchAgent");
|
|
339
|
-
try {
|
|
340
|
-
const uid = process.getuid?.();
|
|
341
|
-
if (uid === undefined) throw new Error("Could not determine UID");
|
|
342
|
-
mkdirSync(join(homedir(), ".nlm", "logs"), { recursive: true });
|
|
343
|
-
writeFileSync(opts.launchAgentPlist, opts.buildPlist(opts.nodeExecPath, opts.nlmBinPath), "utf8");
|
|
344
|
-
try {
|
|
345
|
-
execFileSync("launchctl", ["bootout", `gui/${uid}`, opts.launchAgentLabel], { stdio: "ignore" });
|
|
346
|
-
} catch { /* not loaded yet — expected */ }
|
|
347
|
-
execFileSync("launchctl", ["bootstrap", `gui/${uid}`, opts.launchAgentPlist]);
|
|
348
|
-
ds.stop("LaunchAgent installed — daemon running");
|
|
349
|
-
} catch (e) {
|
|
350
|
-
ds.stop("LaunchAgent install failed");
|
|
351
|
-
log.error(`${e instanceof Error ? e.message : String(e)}`);
|
|
352
|
-
log.warn("Run `nlm install` manually later.");
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
} else if (OS === "linux") {
|
|
356
|
-
if (opts.linuxSystemdUserAvailable()) {
|
|
357
|
-
const installDaemon = await confirm({ message: "Install systemd user unit (auto-start on login)?" });
|
|
358
|
-
if (isCancel(installDaemon)) { cancel("Setup cancelled."); process.exit(0); }
|
|
359
|
-
|
|
360
|
-
if (installDaemon) {
|
|
361
|
-
const ds = spinner();
|
|
362
|
-
ds.start("Installing systemd user unit");
|
|
363
|
-
try {
|
|
364
|
-
mkdirSync(dirname(opts.linuxSystemdUnitPath), { recursive: true });
|
|
365
|
-
mkdirSync(join(homedir(), ".nlm", "logs"), { recursive: true });
|
|
366
|
-
writeFileSync(opts.linuxSystemdUnitPath, opts.buildSystemdUnit(opts.nodeExecPath, opts.nlmBinPath), "utf8");
|
|
367
|
-
execFileSync("systemctl", ["--user", "daemon-reload"]);
|
|
368
|
-
execFileSync("systemctl", ["--user", "enable", "--now", opts.linuxSystemdUnitName]);
|
|
369
|
-
ds.stop("systemd user unit installed — daemon running");
|
|
370
|
-
log.info(` Status: systemctl --user status ${opts.linuxSystemdUnitName}`);
|
|
371
|
-
log.info(" Headless? Run `sudo loginctl enable-linger $USER` so the daemon survives logout.");
|
|
372
|
-
} catch (e) {
|
|
373
|
-
ds.stop("systemd install failed");
|
|
374
|
-
log.error(`${e instanceof Error ? e.message : String(e)}`);
|
|
375
|
-
log.warn("Run `nlm install` manually later, or start now with: nlm start &");
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
} else {
|
|
379
|
-
log.info("systemd user instance not available (no XDG_RUNTIME_DIR or `systemctl --user`).");
|
|
380
|
-
log.info(" Common on headless servers — start manually with: nlm start &");
|
|
381
|
-
log.info(" Or enable lingering, then re-run `nlm install`:");
|
|
382
|
-
log.info(" sudo loginctl enable-linger $USER");
|
|
383
|
-
}
|
|
384
|
-
} else if (OS === "win32") {
|
|
385
|
-
log.info("Windows daemon: run `nlm start` at login via Task Scheduler.");
|
|
386
|
-
log.info(" Or start manually: nlm start");
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// ── Step 6: per-runtime configuration ────────────────────────────────
|
|
390
|
-
for (const id of chosen) {
|
|
391
|
-
switch (id) {
|
|
392
|
-
case "claude-code": {
|
|
393
|
-
// MCP config
|
|
394
|
-
const cs = spinner();
|
|
395
|
-
cs.start("Configuring Claude Code — MCP server");
|
|
396
|
-
try {
|
|
397
|
-
const report = connectClaudeCode({ nlmBinPath: opts.nlmBinPath, nodeExecPath: opts.nodeExecPath });
|
|
398
|
-
cs.stop(`MCP server ${report.alreadyPresent ? "updated" : "written"} → ${report.mcpConfigPath}`);
|
|
399
|
-
} catch (e) {
|
|
400
|
-
cs.stop("MCP config write failed");
|
|
401
|
-
log.error(`${e instanceof Error ? e.message : String(e)}`);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
// Hooks — Claude Code hooks are process hooks (settings.json), not
|
|
405
|
-
// OS-level scripts, so they work on all platforms where Claude Code runs.
|
|
406
|
-
const hs = spinner();
|
|
407
|
-
hs.start("Configuring Claude Code — session hooks");
|
|
408
|
-
const hookLogPath = process.env["NLM_HOOK_LOG"] ?? join(homedir(), ".nlm", "hook-log.jsonl");
|
|
409
|
-
const hookResult = installClaudeCodeHooks({
|
|
410
|
-
nodeExecPath: opts.nodeExecPath,
|
|
411
|
-
hooks: opts.allHooks,
|
|
412
|
-
settingsPath: opts.claudeSettingsPath,
|
|
413
|
-
hookLogPath,
|
|
414
|
-
addHook: opts.addHook,
|
|
415
|
-
removeHook: opts.removeHook,
|
|
416
|
-
buildHookCommand: opts.buildHookCommand,
|
|
417
|
-
smokeTestHookCommand: opts.smokeTestHookCommand,
|
|
418
|
-
});
|
|
419
|
-
if (hookResult.ok) {
|
|
420
|
-
hs.stop(`${hookResult.count} hooks installed → ${opts.claudeSettingsPath}`);
|
|
421
|
-
} else {
|
|
422
|
-
hs.stop(`Hook install failed (${hookResult.failedLabel ?? "unknown"})`);
|
|
423
|
-
if (hookResult.errorMessage) log.error(hookResult.errorMessage);
|
|
424
|
-
log.warn("Run `nlm hook install` manually after checking your Node path.");
|
|
425
|
-
}
|
|
426
|
-
break;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
case "codex": {
|
|
430
|
-
if (!codexBinaryAvailable()) {
|
|
431
|
-
log.warn("Codex binary not found — install with `npm i -g @openai/codex`, then run `nlm connect codex`.");
|
|
432
|
-
break;
|
|
433
|
-
}
|
|
434
|
-
const cs = spinner();
|
|
435
|
-
cs.start("Connecting Codex");
|
|
436
|
-
try {
|
|
437
|
-
const report = connectCodex({ source: "pbmagnet4/nlm-memory-ts" }, pluginScriptsDir(opts.repoRoot));
|
|
438
|
-
if (report.marketplaceAdd?.status !== 0 || report.pluginAdd?.status !== 0) {
|
|
439
|
-
cs.stop("Codex connect had errors — run `nlm connect codex` manually to retry");
|
|
440
|
-
} else {
|
|
441
|
-
cs.stop("Codex marketplace + plugin registered");
|
|
442
|
-
}
|
|
443
|
-
} catch (e) {
|
|
444
|
-
cs.stop("Codex connect failed");
|
|
445
|
-
log.error(`${e instanceof Error ? e.message : String(e)}`);
|
|
446
|
-
}
|
|
447
|
-
break;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
case "opencode":
|
|
451
|
-
log.success("OpenCode: session scanning enabled (passive — no extra config needed)");
|
|
452
|
-
break;
|
|
453
|
-
|
|
454
|
-
case "hermes": {
|
|
455
|
-
const hs = spinner();
|
|
456
|
-
hs.start("Configuring Hermes");
|
|
457
|
-
try {
|
|
458
|
-
const report = connectHermes({ nlmBinPath: opts.nlmBinPath, nodeExecPath: opts.nodeExecPath });
|
|
459
|
-
hs.stop(`MCP server ${report.alreadyPresent ? "updated" : "written"} → ${report.configPath}`);
|
|
460
|
-
} catch (e) {
|
|
461
|
-
hs.stop("Hermes config write failed");
|
|
462
|
-
log.error(`${e instanceof Error ? e.message : String(e)}`);
|
|
463
|
-
log.warn("Run `nlm connect hermes` manually after checking ~/.hermes/config.yaml.");
|
|
464
|
-
}
|
|
465
|
-
break;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
case "pi":
|
|
469
|
-
log.success("pi.dev: session scanning enabled (passive — no extra config needed)");
|
|
470
|
-
break;
|
|
471
|
-
|
|
472
|
-
default: {
|
|
473
|
-
const _: never = id;
|
|
474
|
-
log.warn(`Unknown runtime: ${_ as string} — skipping.`);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
// ── Summary ───────────────────────────────────────────────────────────
|
|
480
|
-
const needsRestart: string[] = [];
|
|
481
|
-
if (chosen.includes("claude-code")) needsRestart.push("Claude Code");
|
|
482
|
-
if (chosen.includes("hermes")) needsRestart.push("Hermes");
|
|
483
|
-
|
|
484
|
-
outro(
|
|
485
|
-
needsRestart.length > 0
|
|
486
|
-
? `Done! Restart ${needsRestart.join(" and ")} for the MCP server to activate, then start a session — memory will follow.`
|
|
487
|
-
: "Done! Start a session in any configured runtime and NLM will begin indexing automatically.",
|
|
488
|
-
);
|
|
489
|
-
}
|
package/src/install/windsurf.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `nlm connect windsurf` / `nlm disconnect windsurf` — registers or removes the
|
|
3
|
-
* Windsurf adapter source in the NLM source registry.
|
|
4
|
-
*
|
|
5
|
-
* NLM reads Windsurf's existing workspace SQLite DBs directly from the User
|
|
6
|
-
* directory. The connect operation only registers the source row so the daemon
|
|
7
|
-
* scans it.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { existsSync } from "node:fs";
|
|
11
|
-
import { defaultUserDir } from "../core/adapters/windsurf.js";
|
|
12
|
-
import type { SourceRegistry } from "../core/sources/source-registry.js";
|
|
13
|
-
|
|
14
|
-
export interface ConnectWindsurfOptions {
|
|
15
|
-
readonly userDir?: string;
|
|
16
|
-
readonly dryRun?: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface ConnectWindsurfReport {
|
|
20
|
-
readonly userDir: string;
|
|
21
|
-
readonly dirExists: boolean;
|
|
22
|
-
readonly action: "created" | "enabled" | "already-active" | "dry-run";
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface DisconnectWindsurfReport {
|
|
26
|
-
readonly action: "disabled" | "not-found" | "dry-run";
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function connectWindsurf(
|
|
30
|
-
registry: SourceRegistry,
|
|
31
|
-
opts: ConnectWindsurfOptions = {},
|
|
32
|
-
): ConnectWindsurfReport {
|
|
33
|
-
const userDir = opts.userDir ?? defaultUserDir();
|
|
34
|
-
const dirExists = existsSync(userDir);
|
|
35
|
-
|
|
36
|
-
if (opts.dryRun) {
|
|
37
|
-
return { userDir, dirExists, action: "dry-run" };
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const existing = registry.getByName("Windsurf");
|
|
41
|
-
if (existing) {
|
|
42
|
-
if (existing.enabled && existing.pathOrUrl === userDir) {
|
|
43
|
-
return { userDir, dirExists, action: "already-active" };
|
|
44
|
-
}
|
|
45
|
-
registry.update(existing.id, { enabled: true, pathOrUrl: userDir });
|
|
46
|
-
return { userDir, dirExists, action: "enabled" };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
registry.insert({
|
|
50
|
-
kind: "windsurf",
|
|
51
|
-
name: "Windsurf",
|
|
52
|
-
pathOrUrl: userDir,
|
|
53
|
-
runtimeLabel: "windsurf/1.0",
|
|
54
|
-
enabled: dirExists,
|
|
55
|
-
});
|
|
56
|
-
return { userDir, dirExists, action: "created" };
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function disconnectWindsurf(
|
|
60
|
-
registry: SourceRegistry,
|
|
61
|
-
opts: { dryRun?: boolean } = {},
|
|
62
|
-
): DisconnectWindsurfReport {
|
|
63
|
-
if (opts.dryRun) return { action: "dry-run" };
|
|
64
|
-
const existing = registry.getByName("Windsurf");
|
|
65
|
-
if (!existing) return { action: "not-found" };
|
|
66
|
-
registry.update(existing.id, { enabled: false });
|
|
67
|
-
return { action: "disabled" };
|
|
68
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ClassifierBox — a mutable LLMClient wrapper holding the active classifier
|
|
3
|
-
* client. The scheduler reads `inner` on each tick, so a runtime swap takes
|
|
4
|
-
* effect on the next session ingest without restarting the daemon.
|
|
5
|
-
*
|
|
6
|
-
* Only `classify()` is delegated. `embed()` throws — embeddings are wired
|
|
7
|
-
* separately through the dedicated Ollama embedder; the classifier slot is
|
|
8
|
-
* for transcript classification only.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {
|
|
12
|
-
ClassifyResult,
|
|
13
|
-
EmbedResult,
|
|
14
|
-
EmbeddingKind,
|
|
15
|
-
LLMClient,
|
|
16
|
-
} from "@ports/llm-client.js";
|
|
17
|
-
import { DeepSeekClient } from "./deepseek-client.js";
|
|
18
|
-
import { OllamaClient } from "./ollama-client.js";
|
|
19
|
-
|
|
20
|
-
export type ClassifierProvider = "deepseek" | "ollama";
|
|
21
|
-
|
|
22
|
-
export interface ClassifierBoxOptions {
|
|
23
|
-
readonly provider: ClassifierProvider;
|
|
24
|
-
readonly model: string;
|
|
25
|
-
readonly ollamaUrl?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export class ClassifierBox implements LLMClient {
|
|
29
|
-
private inner: LLMClient;
|
|
30
|
-
private providerName: ClassifierProvider;
|
|
31
|
-
private modelName: string;
|
|
32
|
-
private readonly ollamaUrl: string;
|
|
33
|
-
|
|
34
|
-
constructor(opts: ClassifierBoxOptions) {
|
|
35
|
-
this.providerName = opts.provider;
|
|
36
|
-
this.modelName = opts.model;
|
|
37
|
-
this.ollamaUrl = opts.ollamaUrl ?? "http://localhost:11434";
|
|
38
|
-
this.inner = this.construct(opts.provider, opts.model);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get provider(): ClassifierProvider { return this.providerName; }
|
|
42
|
-
get model(): string { return this.modelName; }
|
|
43
|
-
|
|
44
|
-
swap(provider: ClassifierProvider, model: string): void {
|
|
45
|
-
this.inner = this.construct(provider, model);
|
|
46
|
-
this.providerName = provider;
|
|
47
|
-
this.modelName = model;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
embed(_text: string, _kind: EmbeddingKind): Promise<EmbedResult> {
|
|
51
|
-
throw new Error("ClassifierBox.embed is not supported — wire OllamaClient as the embedder.");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
classify(transcript: string): Promise<ClassifyResult> {
|
|
55
|
-
return this.inner.classify(transcript);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
private construct(provider: ClassifierProvider, model: string): LLMClient {
|
|
59
|
-
if (provider === "ollama") {
|
|
60
|
-
return new OllamaClient({ baseUrl: this.ollamaUrl, classifyModel: model });
|
|
61
|
-
}
|
|
62
|
-
return new DeepSeekClient({ classifyModel: model });
|
|
63
|
-
}
|
|
64
|
-
}
|