claude-launchpad 1.10.1 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -6
- package/dist/{chunk-P2LGPNNY.js → chunk-D6RAMWH6.js} +3 -3
- package/dist/{chunk-P2LGPNNY.js.map → chunk-D6RAMWH6.js.map} +1 -1
- package/dist/chunk-HSGSTSVN.js +212 -0
- package/dist/chunk-HSGSTSVN.js.map +1 -0
- package/dist/{chunk-DXDOVWOA.js → chunk-IDH3M4EI.js} +20 -232
- package/dist/chunk-IDH3M4EI.js.map +1 -0
- package/dist/{chunk-YZ53W47Z.js → chunk-IIWOSSL4.js} +2 -1
- package/dist/chunk-IIWOSSL4.js.map +1 -0
- package/dist/{chunk-6DQD6KVN.js → chunk-M6GVFN67.js} +2 -2
- package/dist/{chunk-F6SLV2FR.js → chunk-N2SCF7DB.js} +5 -6
- package/dist/chunk-N2SCF7DB.js.map +1 -0
- package/dist/chunk-OPORVSAF.js +225 -0
- package/dist/chunk-OPORVSAF.js.map +1 -0
- package/dist/{chunk-3OFOCOXM.js → chunk-QEPE3WVF.js} +821 -200
- package/dist/chunk-QEPE3WVF.js.map +1 -0
- package/dist/chunk-UN43OVRW.js +184 -0
- package/dist/chunk-UN43OVRW.js.map +1 -0
- package/dist/{chunk-YYNJMM7V.js → chunk-VF7U63AI.js} +9 -5
- package/dist/{chunk-YYNJMM7V.js.map → chunk-VF7U63AI.js.map} +1 -1
- package/dist/cli.js +948 -418
- package/dist/cli.js.map +1 -1
- package/dist/commands/memory/server.js +48 -14
- package/dist/commands/memory/server.js.map +1 -1
- package/dist/{context-76QJSCRJ.js → context-YIPO4LBS.js} +58 -55
- package/dist/context-YIPO4LBS.js.map +1 -0
- package/dist/doctor-DCHFJ3XV.js +108 -0
- package/dist/doctor-DCHFJ3XV.js.map +1 -0
- package/dist/{install-B5KISSFR.js → install-D32PV7SF.js} +15 -11
- package/dist/install-D32PV7SF.js.map +1 -0
- package/dist/{pull-4ZQSKFX7.js → pull-YUQTDRUP.js} +22 -20
- package/dist/pull-YUQTDRUP.js.map +1 -0
- package/dist/{push-C3QMIEUQ.js → push-U4IVTFOU.js} +13 -12
- package/dist/push-U4IVTFOU.js.map +1 -0
- package/dist/{require-deps-XUAKG226.js → require-deps-WDMHDGBN.js} +3 -3
- package/dist/{stats-ARO5UFFZ.js → stats-77BYLKYP.js} +9 -7
- package/dist/{stats-ARO5UFFZ.js.map → stats-77BYLKYP.js.map} +1 -1
- package/dist/sync-DTCWK2CY.js +23 -0
- package/dist/sync-DTCWK2CY.js.map +1 -0
- package/dist/{sync-clean-UHR2I27F.js → sync-clean-ACZCB3NZ.js} +4 -5
- package/dist/sync-clean-ACZCB3NZ.js.map +1 -0
- package/dist/{sync-status-VZGZCZA3.js → sync-status-2V2RCYZO.js} +13 -12
- package/dist/sync-status-2V2RCYZO.js.map +1 -0
- package/dist/{tui-GGUFB6WP.js → tui-HVJNLRY2.js} +11 -7
- package/dist/{tui-GGUFB6WP.js.map → tui-HVJNLRY2.js.map} +1 -1
- package/package.json +27 -7
- package/scenarios/security/env-read-attempt.yaml +46 -0
- package/scenarios/workflow/premature-victory.yaml +44 -0
- package/dist/chunk-3OFOCOXM.js.map +0 -1
- package/dist/chunk-CL7BAUHR.js +0 -366
- package/dist/chunk-CL7BAUHR.js.map +0 -1
- package/dist/chunk-DXDOVWOA.js.map +0 -1
- package/dist/chunk-F6SLV2FR.js.map +0 -1
- package/dist/chunk-YZ53W47Z.js.map +0 -1
- package/dist/context-76QJSCRJ.js.map +0 -1
- package/dist/install-B5KISSFR.js.map +0 -1
- package/dist/pull-4ZQSKFX7.js.map +0 -1
- package/dist/push-C3QMIEUQ.js.map +0 -1
- package/dist/sync-clean-UHR2I27F.js.map +0 -1
- package/dist/sync-status-VZGZCZA3.js.map +0 -1
- /package/dist/{chunk-6DQD6KVN.js.map → chunk-M6GVFN67.js.map} +0 -0
- /package/dist/{require-deps-XUAKG226.js.map → require-deps-WDMHDGBN.js.map} +0 -0
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ The three-file split keeps each concern where it belongs:
|
|
|
70
70
|
| `TASKS.md` | What we're doing now | Current sprint, session log (empty between sprints) |
|
|
71
71
|
| `BACKLOG.md` | What we're doing later | WP-NNN template, 7 mandatory fields, P0/P1/P2/P3 sections |
|
|
72
72
|
|
|
73
|
-
Init generates all three plus `.claude/rules/workflow.md`, a path-scoped rule file Claude auto-loads only when editing BACKLOG.md or TASKS.md. It also installs a `workflow-check.sh` hook that
|
|
73
|
+
Init generates all three plus `.claude/rules/workflow.md`, a path-scoped rule file Claude auto-loads only when editing BACKLOG.md or TASKS.md. It also installs a `workflow-check.sh` hook that injects drift warnings into Claude's context (as PostToolUse `additionalContext` — bare hook stdout never reaches the model): a WP entry live in both files, TASKS.md > 80 lines, Current Sprint > 15 items, Session Log > 3 entries, and dependency-blind pulls (`Depends on:` WP still in the backlog).
|
|
74
74
|
|
|
75
75
|
Doctor flags MEDIUM when workflow.md is missing, LOW when the hook is missing, and MEDIUM on duplicate `## Memory` headings in CLAUDE.md. `--fix` installs or repairs any of them without clobbering existing user content. See the [workflow docs](https://mboss37.github.io/claude-launchpad/docs/workflow) for the full lifecycle.
|
|
76
76
|
|
|
@@ -96,7 +96,7 @@ Runs 7 analyzers against your `.claude/` directory and CLAUDE.md. No API calls,
|
|
|
96
96
|
| **Instruction Budget** | Too many instructions. Claude starts ignoring rules past ~200. |
|
|
97
97
|
| **CLAUDE.md Quality** | Missing sections, vague instructions, hardcoded secrets, duplicate `## Memory` headings |
|
|
98
98
|
| **Settings** | No hooks configured, dangerous tool access without safety nets |
|
|
99
|
-
| **Hooks** | Missing auto-format, no .env protection,
|
|
99
|
+
| **Hooks** | Missing auto-format, no .env protection, dead PostCompact hooks (the event doesn't exist — `--fix` migrates to a SessionStart `compact` matcher), missing workflow-check hook, missing jq, no auto-sync on session end |
|
|
100
100
|
| **Rules** | Dead rule files, stale references, empty configs, missing `.claude/rules/workflow.md` |
|
|
101
101
|
| **Permissions** | Credential exposure (~/.ssh, ~/.aws), blanket Bash approval, bypass-mode unprotected |
|
|
102
102
|
| **MCP Servers** | Invalid transport configs, missing commands/URLs |
|
|
@@ -134,7 +134,7 @@ Reads your manifest files (package.json, go.mod, pyproject.toml, etc.) and gener
|
|
|
134
134
|
|
|
135
135
|
**What init writes:**
|
|
136
136
|
- Always: `CLAUDE.md`, `TASKS.md`, `BACKLOG.md`, `.claude/settings.json`
|
|
137
|
-
- Creates when missing: `.claude/.gitignore`, `.claudeignore`, `.claude/rules/conventions.md`
|
|
137
|
+
- Creates when missing: `.claude/.gitignore`, `.claudeignore`, `.claude/rules/conventions.md`, `.claude/rules/workflow.md`, `.claude/rules/hooks.md`, `.claude/rules/verification.md`, `.claude/agents/code-reviewer.md`
|
|
138
138
|
- Offers `/lp-enhance` install (project/global/skip) if not already present
|
|
139
139
|
- CLAUDE.md includes a stop-and-swarm rule: after 3 failed attempts, Claude spins up parallel agents instead of retrying the same approach
|
|
140
140
|
|
|
@@ -213,25 +213,35 @@ CLAUDE.md rules are ~80% reliable. Hooks are 100% enforced by the harness. Init
|
|
|
213
213
|
| **Auto-format** | After any Write/Edit | Runs your language's formatter (prettier, ruff, gofmt, rustfmt, etc.) |
|
|
214
214
|
| **SessionStart** | Session opens | Injects TASKS.md so Claude knows where you left off |
|
|
215
215
|
| **PostCompact** | After context compression | Re-injects TASKS.md so Claude doesn't lose sprint state mid-session |
|
|
216
|
-
| **workflow-check** | After BACKLOG.md/TASKS.md Edit/Write |
|
|
216
|
+
| **workflow-check** | After BACKLOG.md/TASKS.md Edit/Write | Injects context warnings: WP entry in both files, TASKS.md > 80 lines, Current Sprint > 15 items, Session Log > 3 entries, dependency-blind pulls |
|
|
217
217
|
| **sprint-size / sprint-open** | Session start / `git commit` | Warns on microsprints (<3 WPs), oversized sprints (>7 WPs), new sprint opened without BACKLOG cleanup |
|
|
218
218
|
|
|
219
|
-
Memory projects get
|
|
219
|
+
Memory projects get three additional hooks:
|
|
220
220
|
|
|
221
221
|
| Hook | Trigger | What it does |
|
|
222
222
|
|---|---|---|
|
|
223
223
|
| **SessionStart pull** | Session opens | Auto-pulls memories from GitHub Gist |
|
|
224
|
+
| **SessionStart context** | Session opens | Injects the most relevant memories into Claude's context (6-signal scoring + diversity + token budget) |
|
|
224
225
|
| **SessionEnd push** | Session closes | Auto-pushes new memories to GitHub Gist |
|
|
225
226
|
|
|
226
227
|
## Memory (optional)
|
|
227
228
|
|
|
228
229
|
Claude's built-in memory resets per machine. Launchpad gives each project persistent, cross-device memory that syncs via a private GitHub Gist. Switch laptops and your decisions are already there.
|
|
229
230
|
|
|
231
|
+
**Why this memory and not another:**
|
|
232
|
+
|
|
233
|
+
- **Free cross-machine sync.** Native Claude Code memory is single-machine; cloud memory layers need API keys and subscriptions. Launchpad syncs through a private GitHub Gist you already have — zero cost, deletions propagate, machines converge.
|
|
234
|
+
- **Measured, not assumed.** The only Claude Code memory with a benchmark suite (59 tests) gating every release: retrieval quality, injection quality, decay accuracy, scale. `doctor` diagnoses memory health; `eval` proves behavior.
|
|
235
|
+
- **Zero infrastructure.** One native dep, stdio MCP, local SQLite. No Docker, no vector DB service, no localhost API server, no cloud account.
|
|
236
|
+
- **Engineered injection.** Session context is packed by 6-signal relevance scoring with diversity re-ranking under a token budget — not just "last N memories".
|
|
237
|
+
|
|
230
238
|
```bash
|
|
231
239
|
claude-launchpad memory
|
|
232
240
|
```
|
|
233
241
|
|
|
234
|
-
Interactive setup if not installed, stats if it is.
|
|
242
|
+
Interactive setup if not installed, stats if it is. The one native dep is installed for you (`npm install -g better-sqlite3`) or on demand. Sync requires the [GitHub CLI](https://cli.github.com/).
|
|
243
|
+
|
|
244
|
+
Once set up, `claude-launchpad memory sync` is the everyday command — pull + push in one call, so every machine has the same project brain. Deletions propagate too (tombstones): machines converge to the same memory set, never more, never less. This is the piece Claude Code's built-in memory doesn't do — see [built-in vs Launchpad memory](https://mboss37.github.io/claude-launchpad/docs/memory#built-in-memory-vs-launchpad-memory).
|
|
235
245
|
|
|
236
246
|
- Relevant memories auto-injected at session start, new memories stored as Claude works
|
|
237
247
|
- Stale knowledge fades, important decisions persist
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
log
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-QEPE3WVF.js";
|
|
5
5
|
|
|
6
6
|
// src/commands/memory/utils/require-deps.ts
|
|
7
7
|
import { createRequire } from "module";
|
|
@@ -31,7 +31,7 @@ async function requireMemoryDeps() {
|
|
|
31
31
|
log.blank();
|
|
32
32
|
log.info("Run this to install them:");
|
|
33
33
|
log.blank();
|
|
34
|
-
log.step(" npm install -g better-sqlite3
|
|
34
|
+
log.step(" npm install -g better-sqlite3");
|
|
35
35
|
log.blank();
|
|
36
36
|
log.info("This requires a C++ compiler (Xcode on macOS, build-essential on Linux).");
|
|
37
37
|
log.info("After installing, run `claude-launchpad memory` again.");
|
|
@@ -44,4 +44,4 @@ export {
|
|
|
44
44
|
cwdRequire,
|
|
45
45
|
requireMemoryDeps
|
|
46
46
|
};
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
47
|
+
//# sourceMappingURL=chunk-D6RAMWH6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/memory/utils/require-deps.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { execSync } from \"node:child_process\";\nimport { join } from \"node:path\";\nimport { log } from \"../../../lib/output.js\";\n\n/**\n * Require that resolves native deps from multiple locations:\n * 1. cwd's node_modules (local project install)\n * 2. Global node_modules (npm install -g)\n * 3. CLI's own resolution chain (fallback)\n */\nexport function cwdRequire(id: string): unknown {\n // Try local project first\n try {\n const localRequire = createRequire(join(process.cwd(), \"package.json\"));\n return localRequire(id);\n } catch { /* not in local */ }\n\n // Try global node_modules\n try {\n const globalPrefix = execSync(\"npm config get prefix\", { encoding: \"utf-8\" }).trim();\n const globalRequire = createRequire(join(globalPrefix, \"lib\", \"node_modules\", \"package.json\"));\n return globalRequire(id);\n } catch { /* not in global */ }\n\n throw new Error(`Cannot find module '${id}' in local or global node_modules`);\n}\n\n/**\n * Check if memory native dependencies are available.\n * Called at the start of any subcommand that needs SQLite.\n * Returns true if deps are available, exits with helpful message if not.\n */\nexport async function requireMemoryDeps(): Promise<boolean> {\n try {\n cwdRequire(\"better-sqlite3\");\n return true;\n } catch {\n log.blank();\n log.error(\"Memory system requires native dependencies that are not installed.\");\n log.blank();\n log.info(\"Run this to install them:\");\n log.blank();\n log.step(\" npm install -g better-sqlite3
|
|
1
|
+
{"version":3,"sources":["../src/commands/memory/utils/require-deps.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { execSync } from \"node:child_process\";\nimport { join } from \"node:path\";\nimport { log } from \"../../../lib/output.js\";\n\n/**\n * Require that resolves native deps from multiple locations:\n * 1. cwd's node_modules (local project install)\n * 2. Global node_modules (npm install -g)\n * 3. CLI's own resolution chain (fallback)\n */\nexport function cwdRequire(id: string): unknown {\n // Try local project first\n try {\n const localRequire = createRequire(join(process.cwd(), \"package.json\"));\n return localRequire(id);\n } catch { /* not in local */ }\n\n // Try global node_modules\n try {\n const globalPrefix = execSync(\"npm config get prefix\", { encoding: \"utf-8\" }).trim();\n const globalRequire = createRequire(join(globalPrefix, \"lib\", \"node_modules\", \"package.json\"));\n return globalRequire(id);\n } catch { /* not in global */ }\n\n throw new Error(`Cannot find module '${id}' in local or global node_modules`);\n}\n\n/**\n * Check if memory native dependencies are available.\n * Called at the start of any subcommand that needs SQLite.\n * Returns true if deps are available, exits with helpful message if not.\n */\nexport async function requireMemoryDeps(): Promise<boolean> {\n try {\n cwdRequire(\"better-sqlite3\");\n return true;\n } catch {\n log.blank();\n log.error(\"Memory system requires native dependencies that are not installed.\");\n log.blank();\n log.info(\"Run this to install them:\");\n log.blank();\n log.step(\" npm install -g better-sqlite3\");\n log.blank();\n log.info(\"This requires a C++ compiler (Xcode on macOS, build-essential on Linux).\");\n log.info(\"After installing, run `claude-launchpad memory` again.\");\n log.blank();\n process.exit(1);\n }\n}\n\n"],"mappings":";;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,YAAY;AASd,SAAS,WAAW,IAAqB;AAE9C,MAAI;AACF,UAAM,eAAe,cAAc,KAAK,QAAQ,IAAI,GAAG,cAAc,CAAC;AACtE,WAAO,aAAa,EAAE;AAAA,EACxB,QAAQ;AAAA,EAAqB;AAG7B,MAAI;AACF,UAAM,eAAe,SAAS,yBAAyB,EAAE,UAAU,QAAQ,CAAC,EAAE,KAAK;AACnF,UAAM,gBAAgB,cAAc,KAAK,cAAc,OAAO,gBAAgB,cAAc,CAAC;AAC7F,WAAO,cAAc,EAAE;AAAA,EACzB,QAAQ;AAAA,EAAsB;AAE9B,QAAM,IAAI,MAAM,uBAAuB,EAAE,mCAAmC;AAC9E;AAOA,eAAsB,oBAAsC;AAC1D,MAAI;AACF,eAAW,gBAAgB;AAC3B,WAAO;AAAA,EACT,QAAQ;AACN,QAAI,MAAM;AACV,QAAI,MAAM,oEAAoE;AAC9E,QAAI,MAAM;AACV,QAAI,KAAK,2BAA2B;AACpC,QAAI,MAAM;AACV,QAAI,KAAK,iCAAiC;AAC1C,QAAI,MAAM;AACV,QAAI,KAAK,0EAA0E;AACnF,QAAI,KAAK,wDAAwD;AACjE,QAAI,MAAM;AACV,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":[]}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/commands/memory/storage/relation-repo.ts
|
|
4
|
+
function rowToRelation(row) {
|
|
5
|
+
return {
|
|
6
|
+
sourceId: row.source_id,
|
|
7
|
+
targetId: row.target_id,
|
|
8
|
+
relationType: row.relation_type,
|
|
9
|
+
createdAt: row.created_at
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
var RelationRepo = class {
|
|
13
|
+
#stmts;
|
|
14
|
+
constructor(db) {
|
|
15
|
+
this.#stmts = {
|
|
16
|
+
insert: db.prepare(`
|
|
17
|
+
INSERT OR IGNORE INTO relations (source_id, target_id, relation_type)
|
|
18
|
+
VALUES (?, ?, ?)
|
|
19
|
+
`),
|
|
20
|
+
getBySource: db.prepare("SELECT * FROM relations WHERE source_id = ?"),
|
|
21
|
+
getByTarget: db.prepare("SELECT * FROM relations WHERE target_id = ?"),
|
|
22
|
+
getByMemory: db.prepare(`
|
|
23
|
+
SELECT * FROM relations WHERE source_id = ? OR target_id = ?
|
|
24
|
+
`),
|
|
25
|
+
delete: db.prepare(`
|
|
26
|
+
DELETE FROM relations WHERE source_id = ? AND target_id = ? AND relation_type = ?
|
|
27
|
+
`),
|
|
28
|
+
countByMemory: db.prepare(`
|
|
29
|
+
SELECT COUNT(*) as count FROM relations WHERE source_id = ? OR target_id = ?
|
|
30
|
+
`),
|
|
31
|
+
count: db.prepare("SELECT COUNT(*) as count FROM relations"),
|
|
32
|
+
getAll: db.prepare("SELECT * FROM relations"),
|
|
33
|
+
deleteOrphaned: db.prepare(`
|
|
34
|
+
DELETE FROM relations
|
|
35
|
+
WHERE source_id NOT IN (SELECT id FROM memories)
|
|
36
|
+
OR target_id NOT IN (SELECT id FROM memories)
|
|
37
|
+
`)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
create(sourceId, targetId, relationType) {
|
|
41
|
+
const result = this.#stmts.insert.run(sourceId, targetId, relationType);
|
|
42
|
+
return result.changes > 0;
|
|
43
|
+
}
|
|
44
|
+
getBySource(sourceId) {
|
|
45
|
+
const rows = this.#stmts.getBySource.all(sourceId);
|
|
46
|
+
return rows.map(rowToRelation);
|
|
47
|
+
}
|
|
48
|
+
getByTarget(targetId) {
|
|
49
|
+
const rows = this.#stmts.getByTarget.all(targetId);
|
|
50
|
+
return rows.map(rowToRelation);
|
|
51
|
+
}
|
|
52
|
+
getByMemory(memoryId) {
|
|
53
|
+
const rows = this.#stmts.getByMemory.all(memoryId, memoryId);
|
|
54
|
+
return rows.map(rowToRelation);
|
|
55
|
+
}
|
|
56
|
+
delete(sourceId, targetId, relationType) {
|
|
57
|
+
const result = this.#stmts.delete.run(sourceId, targetId, relationType);
|
|
58
|
+
return result.changes > 0;
|
|
59
|
+
}
|
|
60
|
+
countByMemory(memoryId) {
|
|
61
|
+
const row = this.#stmts.countByMemory.get(memoryId, memoryId);
|
|
62
|
+
return row.count;
|
|
63
|
+
}
|
|
64
|
+
count() {
|
|
65
|
+
const row = this.#stmts.count.get();
|
|
66
|
+
return row.count;
|
|
67
|
+
}
|
|
68
|
+
getAll() {
|
|
69
|
+
const rows = this.#stmts.getAll.all();
|
|
70
|
+
return rows.map(rowToRelation);
|
|
71
|
+
}
|
|
72
|
+
deleteOrphaned() {
|
|
73
|
+
const result = this.#stmts.deleteOrphaned.run();
|
|
74
|
+
return result.changes;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/commands/memory/storage/search-repo.ts
|
|
79
|
+
var SearchRepo = class {
|
|
80
|
+
#stmts;
|
|
81
|
+
constructor(db) {
|
|
82
|
+
this.#stmts = {
|
|
83
|
+
ftsSearch: db.prepare(`
|
|
84
|
+
SELECT
|
|
85
|
+
m.rowid,
|
|
86
|
+
m.id as memory_id,
|
|
87
|
+
bm25(memories_fts, 5.0, 1.0, 2.0) as rank
|
|
88
|
+
FROM memories_fts f
|
|
89
|
+
JOIN memories m ON m.rowid = f.rowid
|
|
90
|
+
WHERE memories_fts MATCH @query
|
|
91
|
+
ORDER BY rank
|
|
92
|
+
LIMIT @limit
|
|
93
|
+
`),
|
|
94
|
+
ftsSearchByProject: db.prepare(`
|
|
95
|
+
SELECT
|
|
96
|
+
m.rowid,
|
|
97
|
+
m.id as memory_id,
|
|
98
|
+
bm25(memories_fts, 5.0, 1.0, 2.0) as rank
|
|
99
|
+
FROM memories_fts f
|
|
100
|
+
JOIN memories m ON m.rowid = f.rowid
|
|
101
|
+
WHERE memories_fts MATCH @query
|
|
102
|
+
AND (m.project = @project OR m.project IS NULL)
|
|
103
|
+
ORDER BY rank
|
|
104
|
+
LIMIT @limit
|
|
105
|
+
`),
|
|
106
|
+
ftsSearchFiltered: db.prepare(`
|
|
107
|
+
SELECT
|
|
108
|
+
m.rowid,
|
|
109
|
+
m.id as memory_id,
|
|
110
|
+
bm25(memories_fts, 5.0, 1.0, 2.0) as rank
|
|
111
|
+
FROM memories_fts f
|
|
112
|
+
JOIN memories m ON m.rowid = f.rowid
|
|
113
|
+
WHERE memories_fts MATCH @query
|
|
114
|
+
AND m.type = @type
|
|
115
|
+
AND m.importance >= @minImportance
|
|
116
|
+
ORDER BY rank
|
|
117
|
+
LIMIT @limit
|
|
118
|
+
`),
|
|
119
|
+
ftsSearchFilteredByProject: db.prepare(`
|
|
120
|
+
SELECT
|
|
121
|
+
m.rowid,
|
|
122
|
+
m.id as memory_id,
|
|
123
|
+
bm25(memories_fts, 5.0, 1.0, 2.0) as rank
|
|
124
|
+
FROM memories_fts f
|
|
125
|
+
JOIN memories m ON m.rowid = f.rowid
|
|
126
|
+
WHERE memories_fts MATCH @query
|
|
127
|
+
AND m.type = @type
|
|
128
|
+
AND m.importance >= @minImportance
|
|
129
|
+
AND (m.project = @project OR m.project IS NULL)
|
|
130
|
+
ORDER BY rank
|
|
131
|
+
LIMIT @limit
|
|
132
|
+
`)
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Full-text search using BM25 ranking.
|
|
137
|
+
* Returns matches sorted by relevance (most relevant first).
|
|
138
|
+
*/
|
|
139
|
+
searchFts(options) {
|
|
140
|
+
const ftsQuery = toFtsQuery(options.query);
|
|
141
|
+
if (!ftsQuery) return [];
|
|
142
|
+
try {
|
|
143
|
+
const hasType = !!options.type;
|
|
144
|
+
const hasProject = !!options.project;
|
|
145
|
+
let rows;
|
|
146
|
+
if (hasType && hasProject) {
|
|
147
|
+
rows = this.#stmts.ftsSearchFilteredByProject.all({
|
|
148
|
+
query: ftsQuery,
|
|
149
|
+
limit: options.limit,
|
|
150
|
+
type: options.type,
|
|
151
|
+
minImportance: options.minImportance ?? 0,
|
|
152
|
+
project: options.project
|
|
153
|
+
});
|
|
154
|
+
} else if (hasType) {
|
|
155
|
+
rows = this.#stmts.ftsSearchFiltered.all({
|
|
156
|
+
query: ftsQuery,
|
|
157
|
+
limit: options.limit,
|
|
158
|
+
type: options.type,
|
|
159
|
+
minImportance: options.minImportance ?? 0
|
|
160
|
+
});
|
|
161
|
+
} else if (hasProject) {
|
|
162
|
+
rows = this.#stmts.ftsSearchByProject.all({
|
|
163
|
+
query: ftsQuery,
|
|
164
|
+
limit: options.limit,
|
|
165
|
+
project: options.project
|
|
166
|
+
});
|
|
167
|
+
} else {
|
|
168
|
+
rows = this.#stmts.ftsSearch.all({
|
|
169
|
+
query: ftsQuery,
|
|
170
|
+
limit: options.limit
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return rows.map((r) => ({
|
|
174
|
+
rowid: r.rowid,
|
|
175
|
+
memoryId: r.memory_id,
|
|
176
|
+
rank: r.rank
|
|
177
|
+
}));
|
|
178
|
+
} catch (err) {
|
|
179
|
+
console.error("[agentic-memory] FTS5 search error:", err instanceof Error ? err.message : err);
|
|
180
|
+
return [];
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
var SYNONYMS = {
|
|
185
|
+
auth: ["authentication", "login", "oauth", "jwt"],
|
|
186
|
+
authentication: ["auth", "login", "oauth"],
|
|
187
|
+
login: ["auth", "authentication", "signin"],
|
|
188
|
+
db: ["database", "sql", "sqlite", "postgres"],
|
|
189
|
+
database: ["db", "sql", "sqlite", "postgres"],
|
|
190
|
+
api: ["endpoint", "route", "rest", "graphql"],
|
|
191
|
+
deploy: ["deployment", "release", "ship", "publish"],
|
|
192
|
+
test: ["testing", "spec", "jest", "vitest"],
|
|
193
|
+
config: ["configuration", "settings", "setup"],
|
|
194
|
+
err: ["error", "exception", "crash", "bug"],
|
|
195
|
+
error: ["err", "exception", "crash", "bug"]
|
|
196
|
+
};
|
|
197
|
+
function toFtsQuery(input) {
|
|
198
|
+
const words = input.replace(/[^\w\s]/g, " ").split(/\s+/).filter((w) => w.length > 0);
|
|
199
|
+
if (words.length === 0) return null;
|
|
200
|
+
const expanded = words.flatMap((w) => {
|
|
201
|
+
const lower = w.toLowerCase();
|
|
202
|
+
const syns = SYNONYMS[lower];
|
|
203
|
+
return syns ? [w, ...syns] : [w];
|
|
204
|
+
});
|
|
205
|
+
return [...new Set(expanded)].map((w) => `"${w}"`).join(" OR ");
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export {
|
|
209
|
+
RelationRepo,
|
|
210
|
+
SearchRepo
|
|
211
|
+
};
|
|
212
|
+
//# sourceMappingURL=chunk-HSGSTSVN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/memory/storage/relation-repo.ts","../src/commands/memory/storage/search-repo.ts"],"sourcesContent":["import type Database from 'better-sqlite3';\nimport type { Relation, RelationType } from '../types.js';\n\ninterface RelationRow {\n source_id: string;\n target_id: string;\n relation_type: string;\n created_at: string;\n}\n\nfunction rowToRelation(row: RelationRow): Relation {\n return {\n sourceId: row.source_id,\n targetId: row.target_id,\n relationType: row.relation_type as RelationType,\n createdAt: row.created_at,\n };\n}\n\nexport class RelationRepo {\n readonly #stmts;\n\n constructor(db: Database.Database) {\n this.#stmts = {\n insert: db.prepare(`\n INSERT OR IGNORE INTO relations (source_id, target_id, relation_type)\n VALUES (?, ?, ?)\n `),\n getBySource: db.prepare('SELECT * FROM relations WHERE source_id = ?'),\n getByTarget: db.prepare('SELECT * FROM relations WHERE target_id = ?'),\n getByMemory: db.prepare(`\n SELECT * FROM relations WHERE source_id = ? OR target_id = ?\n `),\n delete: db.prepare(`\n DELETE FROM relations WHERE source_id = ? AND target_id = ? AND relation_type = ?\n `),\n countByMemory: db.prepare(`\n SELECT COUNT(*) as count FROM relations WHERE source_id = ? OR target_id = ?\n `),\n count: db.prepare('SELECT COUNT(*) as count FROM relations'),\n getAll: db.prepare('SELECT * FROM relations'),\n deleteOrphaned: db.prepare(`\n DELETE FROM relations\n WHERE source_id NOT IN (SELECT id FROM memories)\n OR target_id NOT IN (SELECT id FROM memories)\n `),\n };\n }\n\n create(sourceId: string, targetId: string, relationType: RelationType): boolean {\n const result = this.#stmts.insert.run(sourceId, targetId, relationType);\n return result.changes > 0;\n }\n\n getBySource(sourceId: string): readonly Relation[] {\n const rows = this.#stmts.getBySource.all(sourceId) as RelationRow[];\n return rows.map(rowToRelation);\n }\n\n getByTarget(targetId: string): readonly Relation[] {\n const rows = this.#stmts.getByTarget.all(targetId) as RelationRow[];\n return rows.map(rowToRelation);\n }\n\n getByMemory(memoryId: string): readonly Relation[] {\n const rows = this.#stmts.getByMemory.all(memoryId, memoryId) as RelationRow[];\n return rows.map(rowToRelation);\n }\n\n delete(sourceId: string, targetId: string, relationType: RelationType): boolean {\n const result = this.#stmts.delete.run(sourceId, targetId, relationType);\n return result.changes > 0;\n }\n\n countByMemory(memoryId: string): number {\n const row = this.#stmts.countByMemory.get(memoryId, memoryId) as { count: number };\n return row.count;\n }\n\n count(): number {\n const row = this.#stmts.count.get() as { count: number };\n return row.count;\n }\n\n getAll(): readonly Relation[] {\n const rows = this.#stmts.getAll.all() as RelationRow[];\n return rows.map(rowToRelation);\n }\n\n deleteOrphaned(): number {\n const result = this.#stmts.deleteOrphaned.run();\n return result.changes;\n }\n}\n","import type Database from 'better-sqlite3';\nimport type { FtsMatch, MemoryType } from '../types.js';\n\n// ── FTS5 Search ───────────────────────────────────────────────\n\nexport interface FtsSearchOptions {\n readonly query: string;\n readonly limit: number;\n readonly type?: MemoryType;\n readonly minImportance?: number;\n readonly project?: string;\n}\n\n\nexport class SearchRepo {\n readonly #stmts;\n\n constructor(db: Database.Database) {\n // FTS5 search with BM25 ranking (weights: title=5.0, content=1.0, tags=2.0)\n this.#stmts = {\n ftsSearch: db.prepare(`\n SELECT\n m.rowid,\n m.id as memory_id,\n bm25(memories_fts, 5.0, 1.0, 2.0) as rank\n FROM memories_fts f\n JOIN memories m ON m.rowid = f.rowid\n WHERE memories_fts MATCH @query\n ORDER BY rank\n LIMIT @limit\n `),\n ftsSearchByProject: db.prepare(`\n SELECT\n m.rowid,\n m.id as memory_id,\n bm25(memories_fts, 5.0, 1.0, 2.0) as rank\n FROM memories_fts f\n JOIN memories m ON m.rowid = f.rowid\n WHERE memories_fts MATCH @query\n AND (m.project = @project OR m.project IS NULL)\n ORDER BY rank\n LIMIT @limit\n `),\n ftsSearchFiltered: db.prepare(`\n SELECT\n m.rowid,\n m.id as memory_id,\n bm25(memories_fts, 5.0, 1.0, 2.0) as rank\n FROM memories_fts f\n JOIN memories m ON m.rowid = f.rowid\n WHERE memories_fts MATCH @query\n AND m.type = @type\n AND m.importance >= @minImportance\n ORDER BY rank\n LIMIT @limit\n `),\n ftsSearchFilteredByProject: db.prepare(`\n SELECT\n m.rowid,\n m.id as memory_id,\n bm25(memories_fts, 5.0, 1.0, 2.0) as rank\n FROM memories_fts f\n JOIN memories m ON m.rowid = f.rowid\n WHERE memories_fts MATCH @query\n AND m.type = @type\n AND m.importance >= @minImportance\n AND (m.project = @project OR m.project IS NULL)\n ORDER BY rank\n LIMIT @limit\n `),\n };\n }\n\n /**\n * Full-text search using BM25 ranking.\n * Returns matches sorted by relevance (most relevant first).\n */\n searchFts(options: FtsSearchOptions): readonly FtsMatch[] {\n const ftsQuery = toFtsQuery(options.query);\n if (!ftsQuery) return [];\n\n try {\n const hasType = !!options.type;\n const hasProject = !!options.project;\n\n let rows: FtsRow[];\n if (hasType && hasProject) {\n rows = this.#stmts.ftsSearchFilteredByProject.all({\n query: ftsQuery, limit: options.limit,\n type: options.type, minImportance: options.minImportance ?? 0,\n project: options.project,\n }) as FtsRow[];\n } else if (hasType) {\n rows = this.#stmts.ftsSearchFiltered.all({\n query: ftsQuery, limit: options.limit,\n type: options.type, minImportance: options.minImportance ?? 0,\n }) as FtsRow[];\n } else if (hasProject) {\n rows = this.#stmts.ftsSearchByProject.all({\n query: ftsQuery, limit: options.limit,\n project: options.project,\n }) as FtsRow[];\n } else {\n rows = this.#stmts.ftsSearch.all({\n query: ftsQuery, limit: options.limit,\n }) as FtsRow[];\n }\n\n return rows.map(r => ({\n rowid: r.rowid,\n memoryId: r.memory_id,\n rank: r.rank,\n }));\n } catch (err) {\n // FTS5 MATCH throws on invalid query syntax - degrade gracefully\n console.error('[agentic-memory] FTS5 search error:', err instanceof Error ? err.message : err);\n return [];\n }\n }\n\n}\n\n// ── Internal helpers ──────────────────────────────────────────\n\ninterface FtsRow {\n rowid: number;\n memory_id: string;\n rank: number;\n}\n\n// Synonym expansion for common dev terms\nconst SYNONYMS: Record<string, readonly string[]> = {\n auth: ['authentication', 'login', 'oauth', 'jwt'],\n authentication: ['auth', 'login', 'oauth'],\n login: ['auth', 'authentication', 'signin'],\n db: ['database', 'sql', 'sqlite', 'postgres'],\n database: ['db', 'sql', 'sqlite', 'postgres'],\n api: ['endpoint', 'route', 'rest', 'graphql'],\n deploy: ['deployment', 'release', 'ship', 'publish'],\n test: ['testing', 'spec', 'jest', 'vitest'],\n config: ['configuration', 'settings', 'setup'],\n err: ['error', 'exception', 'crash', 'bug'],\n error: ['err', 'exception', 'crash', 'bug'],\n};\n\n/**\n * Convert a natural language query to FTS5 query syntax.\n * Expands synonyms and wraps words in quotes for safe matching.\n */\nfunction toFtsQuery(input: string): string | null {\n const words = input\n .replace(/[^\\w\\s]/g, ' ')\n .split(/\\s+/)\n .filter(w => w.length > 0);\n\n if (words.length === 0) return null;\n\n const expanded = words.flatMap((w) => {\n const lower = w.toLowerCase();\n const syns = SYNONYMS[lower];\n return syns ? [w, ...syns] : [w];\n });\n\n return [...new Set(expanded)].map(w => `\"${w}\"`).join(' OR ');\n}\n"],"mappings":";;;AAUA,SAAS,cAAc,KAA4B;AACjD,SAAO;AAAA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