@spike1292/claude-memory 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +412 -2
- package/hooks/distill-session.mjs +74 -0
- package/hooks/graph-staleness-check.mjs +25 -0
- package/hooks/hooks.json +94 -0
- package/hooks/insights-surface.mjs +48 -0
- package/hooks/lib/distill-session.mjs +1560 -0
- package/hooks/lib/dupe-report.mjs +61 -0
- package/hooks/lib/env-shell.mjs +92 -0
- package/hooks/lib/graph-staleness-check.mjs +394 -0
- package/hooks/lib/hook-io.mjs +715 -0
- package/hooks/lib/insights-surface.mjs +165 -0
- package/hooks/lib/memory-link-lint.mjs +499 -0
- package/hooks/lib/memory-recall.mjs +219 -0
- package/hooks/lib/omp.mjs +103 -0
- package/hooks/lib/opencode.mjs +231 -0
- package/hooks/lib/paths.mjs +452 -0
- package/hooks/lib/semantic-index-refresh.mjs +155 -0
- package/hooks/lib/validate-note.mjs +218 -0
- package/hooks/lib/vault-env.sh +110 -0
- package/hooks/memory-link-lint.mjs +65 -0
- package/hooks/memory-recall.mjs +251 -0
- package/hooks/semantic-index-refresh.mjs +23 -0
- package/hooks/session-context.mjs +9 -0
- package/hooks/validate-note.mjs +52 -0
- package/hooks/vault-memory-sync.sh +154 -0
- package/omp/index.js +1 -0
- package/opencode/index.js +1 -0
- package/package.json +51 -4
- package/scripts/claude-memory.mjs +31 -0
- package/scripts/doctor-perf.mjs +121 -0
- package/scripts/doctor.sh +558 -0
- package/scripts/env.mjs +6 -0
- package/scripts/lib/claude-memory.mjs +168 -0
- package/scripts/lib/doctor-perf.mjs +434 -0
- package/scripts/lib/hook-stats.mjs +864 -0
- package/scripts/lib/lexical.mjs +85 -0
- package/scripts/lib/memory-adopt.mjs +69 -0
- package/scripts/lib/memory-audit-checks.mjs +344 -0
- package/scripts/lib/memory-eval.mjs +381 -0
- package/scripts/lib/memory-mark.mjs +135 -0
- package/scripts/lib/memory-mcp.mjs +142 -0
- package/scripts/lib/memory-merge.mjs +316 -0
- package/scripts/lib/memory-mine.mjs +108 -0
- package/scripts/lib/memory-promote.mjs +207 -0
- package/scripts/lib/memory-prune.mjs +84 -0
- package/scripts/lib/memory-semantic.mjs +999 -0
- package/scripts/lib/memory-setup.mjs +170 -0
- package/scripts/lib/memory-synth-vault.mjs +538 -0
- package/scripts/lib/model-default.mjs +7 -0
- package/scripts/lib/models.mjs +58 -0
- package/scripts/lib/prune-logs.mjs +130 -0
- package/scripts/lib/recall-stats.mjs +354 -0
- package/scripts/lib/share-modules.mjs +70 -0
- package/scripts/lib/slim-install.mjs +162 -0
- package/scripts/lib/vault-mcp.mjs +405 -0
- package/scripts/memory-adopt.mjs +160 -0
- package/scripts/memory-audit-checks.mjs +375 -0
- package/scripts/memory-eval.mjs +753 -0
- package/scripts/memory-mark.mjs +39 -0
- package/scripts/memory-mcp.mjs +35 -0
- package/scripts/memory-merge.mjs +55 -0
- package/scripts/memory-prune.mjs +44 -0
- package/scripts/memory-semantic.mjs +1192 -0
- package/scripts/memory-setup.mjs +33 -0
- package/scripts/memory-synth-vault.mjs +251 -0
- package/scripts/prune-logs.mjs +42 -0
- package/scripts/share-modules.mjs +79 -0
- package/scripts/slim-install.mjs +55 -0
- package/scripts/vault-mcp.mjs +50 -0
- package/stubs/onnxruntime-web/index.mjs +11 -0
- package/stubs/onnxruntime-web/package.json +12 -0
- package/stubs/sharp/index.mjs +11 -0
- package/stubs/sharp/package.json +12 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Mark a vault note as manually adjudicated: never auto-merge anything into it.
|
|
3
|
+
//
|
|
4
|
+
// node scripts/memory-mark.mjs <note-name-or-path> [...]
|
|
5
|
+
// node scripts/memory-mark.mjs --unmark <note-name-or-path> [...]
|
|
6
|
+
//
|
|
7
|
+
// A script rather than instructions in /memory:prune — CLAUDE.md's Retrieval section (the
|
|
8
|
+
// `reconcile: manual` bullet) has why: the instruction version produced four unmarked keeps.
|
|
9
|
+
//
|
|
10
|
+
// Entry only: argv, stdout, exit code. The logic and its tests live in lib/memory-mark.mjs.
|
|
11
|
+
import * as paths from '../hooks/lib/paths.mjs';
|
|
12
|
+
import { markNotes } from './lib/memory-mark.mjs';
|
|
13
|
+
|
|
14
|
+
const argv = process.argv.slice(2);
|
|
15
|
+
const unmark = argv.includes('--unmark');
|
|
16
|
+
const names = argv.filter((a) => !a.startsWith('-'));
|
|
17
|
+
|
|
18
|
+
if (!names.length) {
|
|
19
|
+
console.error('usage: memory-mark.mjs [--unmark] <note-name-or-path> [...]');
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let changed = 0;
|
|
24
|
+
for (const r of markNotes(paths.vault(), names, !unmark)) {
|
|
25
|
+
if (r.status === 'missing') {
|
|
26
|
+
console.error(`not found in the vault: ${r.name}`);
|
|
27
|
+
process.exitCode = 1;
|
|
28
|
+
} else if (r.status === 'no-frontmatter') {
|
|
29
|
+
console.error(`no frontmatter, refusing to edit: ${r.file}`);
|
|
30
|
+
process.exitCode = 1;
|
|
31
|
+
} else if (r.status === 'unchanged') {
|
|
32
|
+
console.log(`already ${unmark ? 'unmarked' : 'marked'}: ${r.name}`);
|
|
33
|
+
} else {
|
|
34
|
+
changed++;
|
|
35
|
+
console.log(`${r.status}: ${r.name}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.log(`\n${changed} note(s) changed.`);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Read-only stdio MCP server: one tool, memory_search. Usage: node scripts/memory-mcp.mjs
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
6
|
+
import * as paths from '../hooks/lib/paths.mjs';
|
|
7
|
+
import { detach } from '../hooks/lib/hook-io.mjs';
|
|
8
|
+
import { CARD } from './lib/lexical.mjs';
|
|
9
|
+
import { MODEL_KEY } from './lib/memory-semantic.mjs';
|
|
10
|
+
import { serveStdio } from './lib/memory-mcp.mjs';
|
|
11
|
+
|
|
12
|
+
/** @param {string} dbFile */
|
|
13
|
+
function readCards(dbFile) {
|
|
14
|
+
const db = new DatabaseSync(dbFile, { readOnly: true });
|
|
15
|
+
try {
|
|
16
|
+
return /** @type {import('./lib/vault-mcp.mjs').Card[]} */ (
|
|
17
|
+
/** @type {unknown} */ (
|
|
18
|
+
db.prepare('SELECT note, layer, text FROM chunks WHERE heading = ?').all(CARD)
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
} finally {
|
|
22
|
+
db.close();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
serveStdio(process.stdin, process.stdout, {
|
|
27
|
+
dbDir: paths.stateDir('db'),
|
|
28
|
+
sockPath: path.join(paths.stateDir('run'), `search-${MODEL_KEY}.sock`),
|
|
29
|
+
defaultSlug: () => paths.projectKey(process.cwd()),
|
|
30
|
+
readCards,
|
|
31
|
+
spawn: () =>
|
|
32
|
+
detach(process.execPath, [path.join(paths.scriptsDir, 'memory-semantic.mjs'), '--serve']) !==
|
|
33
|
+
null,
|
|
34
|
+
version: JSON.parse(fs.readFileSync(path.join(paths.pluginRoot, 'package.json'), 'utf8')).version,
|
|
35
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Merge duplicate vault notes into one survivor — /memory:prune step 2, after the human confirms.
|
|
3
|
+
//
|
|
4
|
+
// node scripts/memory-merge.mjs [--dry-run] <survivor> <redundant> [...]
|
|
5
|
+
// node scripts/memory-merge.mjs [--dry-run] --plan <file.json> [["survivor", "redundant", ...], ...]
|
|
6
|
+
//
|
|
7
|
+
// Entry only: argv, stdout, exit code. The logic and its tests live in lib/memory-merge.mjs.
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
import * as paths from '../hooks/lib/paths.mjs';
|
|
10
|
+
import { todayStr } from '../hooks/lib/distill-session.mjs';
|
|
11
|
+
import { applyMerge, planMerge } from './lib/memory-merge.mjs';
|
|
12
|
+
|
|
13
|
+
const argv = process.argv.slice(2);
|
|
14
|
+
const dry = argv.includes('--dry-run');
|
|
15
|
+
const at = argv.indexOf('--plan');
|
|
16
|
+
const groups =
|
|
17
|
+
at >= 0
|
|
18
|
+
? JSON.parse(fs.readFileSync(argv[at + 1], 'utf8'))
|
|
19
|
+
: [argv.filter((a) => !a.startsWith('-'))];
|
|
20
|
+
|
|
21
|
+
if (!groups.length || !groups[0]?.length) {
|
|
22
|
+
console.error(
|
|
23
|
+
'usage: memory-merge.mjs [--dry-run] (<survivor> <redundant> [...] | --plan <file>)',
|
|
24
|
+
);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const vault = paths.vault();
|
|
29
|
+
/** @type {import('./lib/memory-merge.mjs').Plan} */
|
|
30
|
+
let plan;
|
|
31
|
+
try {
|
|
32
|
+
plan = planMerge(vault, groups, todayStr());
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.error(`refusing the whole plan, nothing changed:\n${/** @type {Error} */ (e).message}`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
for (const g of plan.groups)
|
|
39
|
+
console.log(`${g.survivor.name} <= ${g.redundant.map((r) => r.name).join(', ')}`);
|
|
40
|
+
console.log(`\nedit (${plan.edits.length}):`);
|
|
41
|
+
for (const f of plan.edits) console.log(` ${f}`);
|
|
42
|
+
console.log(`move to trash (${plan.moves.length}):`);
|
|
43
|
+
for (const m of plan.moves) console.log(` ${m.from}\n -> ${m.to}`);
|
|
44
|
+
|
|
45
|
+
if (dry) {
|
|
46
|
+
console.log('\n--dry-run: nothing changed.');
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const dangling = applyMerge(vault, plan);
|
|
51
|
+
console.log(`\nmerged ${plan.groups.length} group(s), moved ${plan.moves.length} note(s).`);
|
|
52
|
+
if (dangling.length) {
|
|
53
|
+
console.error(`still linking to a moved note:\n ${dangling.join('\n ')}`);
|
|
54
|
+
process.exitCode = 1;
|
|
55
|
+
} else console.log('dangling links: none.');
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Archive old logs, refresh the index, list candidate duplicates. Usage: memory-prune.mjs --help
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
import * as paths from '../hooks/lib/paths.mjs';
|
|
6
|
+
import { parseDays } from './lib/prune-logs.mjs';
|
|
7
|
+
import { USAGE, parsePruneArgs, prune } from './lib/memory-prune.mjs';
|
|
8
|
+
|
|
9
|
+
const argv = process.argv.slice(2);
|
|
10
|
+
if (argv.includes('--help') || argv.includes('-h')) {
|
|
11
|
+
console.log(`usage: ${USAGE}\n\nPRUNE_DAYS=N changes the 90-day log window.`);
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
14
|
+
const opts = parsePruneArgs(argv);
|
|
15
|
+
if ('error' in opts) {
|
|
16
|
+
console.error(`${opts.error}\nusage: ${USAGE}`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
const days = parseDays(process.env.PRUNE_DAYS ?? '');
|
|
20
|
+
if (!Number.isInteger(days)) {
|
|
21
|
+
console.error(`PRUNE_DAYS must be a whole number of days, got: ${process.env.PRUNE_DAYS}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
const semantic = path.join(paths.scriptsDir, 'memory-semantic.mjs');
|
|
25
|
+
process.exitCode = prune(
|
|
26
|
+
{ slug: opts.slug || paths.computeProjectKey(process.cwd()), dryRun: opts.dryRun },
|
|
27
|
+
{
|
|
28
|
+
vault: paths.vault(),
|
|
29
|
+
days,
|
|
30
|
+
run: (args) => {
|
|
31
|
+
const r = spawnSync(process.execPath, [semantic, ...args], {
|
|
32
|
+
encoding: 'utf8',
|
|
33
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
code: r.status ?? 1,
|
|
37
|
+
out:
|
|
38
|
+
(r.stdout ?? '') +
|
|
39
|
+
(r.status === 0 ? '' : r.stderr || r.error?.message || 'semantic scan failed'),
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
print: (l) => console.log(l),
|
|
43
|
+
},
|
|
44
|
+
);
|