sigmap 8.19.0 → 8.21.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/CHANGELOG.md +26 -0
- package/README.md +10 -10
- package/gen-context.js +445 -19
- package/llms-full.txt +9 -7
- package/llms.txt +6 -6
- package/package.json +2 -1
- package/packages/cli/package.json +1 -1
- package/packages/core/package.json +1 -1
- package/src/config/defaults.js +2 -0
- package/src/extractors/go.js +31 -3
- package/src/extractors/java.js +37 -2
- package/src/extractors/javascript.js +42 -1
- package/src/extractors/rust.js +33 -5
- package/src/extractors/typescript.js +41 -1
- package/src/graph/centrality.js +61 -0
- package/src/mcp/handlers.js +6 -2
- package/src/mcp/server.js +1 -1
- package/src/retrieval/ranker.js +26 -1
- package/src/session/memory-inspect.js +86 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* memory-inspect.js — one view over SigMap's existing cross-session stores.
|
|
5
|
+
* No new storage: reads the JSON/NDJSON files the session, notes, weights,
|
|
6
|
+
* evidence, and tracking modules already own under `.context/`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
12
|
+
/** store name → { file, kind } (kind drives the entry count). */
|
|
13
|
+
const STORES = {
|
|
14
|
+
session: { file: 'session.json', kind: 'json' },
|
|
15
|
+
notes: { file: 'notes.ndjson', kind: 'ndjson' },
|
|
16
|
+
weights: { file: 'weights.json', kind: 'weights' },
|
|
17
|
+
evidence: { file: 'evidence-pack.json', kind: 'json' },
|
|
18
|
+
gain: { file: 'gain.ndjson', kind: 'ndjson' },
|
|
19
|
+
usage: { file: 'usage.ndjson', kind: 'ndjson' },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Stores `clearMemory` may delete ('gain'/'usage' have their own reset flows). */
|
|
23
|
+
const CLEARABLE = ['session', 'notes', 'weights', 'evidence'];
|
|
24
|
+
|
|
25
|
+
function storePath(cwd, name) {
|
|
26
|
+
return path.join(cwd, '.context', STORES[name].file);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function countEntries(kind, filePath) {
|
|
30
|
+
try {
|
|
31
|
+
if (kind === 'ndjson') {
|
|
32
|
+
return fs.readFileSync(filePath, 'utf8').split('\n').filter(Boolean).length;
|
|
33
|
+
}
|
|
34
|
+
if (kind === 'weights') {
|
|
35
|
+
const w = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
36
|
+
return Object.keys((w && w.files) || w || {}).length;
|
|
37
|
+
}
|
|
38
|
+
return 1; // json: a single snapshot object
|
|
39
|
+
} catch (_) {
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Describe every cross-session store.
|
|
46
|
+
* @param {string} cwd
|
|
47
|
+
* @returns {Array<{store:string, path:string, exists:boolean, entries:number, bytes:number, modified:string|null, clearable:boolean}>}
|
|
48
|
+
*/
|
|
49
|
+
function inspectMemory(cwd) {
|
|
50
|
+
return Object.entries(STORES).map(([store, { file, kind }]) => {
|
|
51
|
+
const p = storePath(cwd, store);
|
|
52
|
+
let stat = null;
|
|
53
|
+
try { stat = fs.statSync(p); } catch (_) {}
|
|
54
|
+
return {
|
|
55
|
+
store,
|
|
56
|
+
path: path.join('.context', file),
|
|
57
|
+
exists: !!stat,
|
|
58
|
+
entries: stat ? countEntries(kind, p) : 0,
|
|
59
|
+
bytes: stat ? stat.size : 0,
|
|
60
|
+
modified: stat ? new Date(stat.mtimeMs).toISOString() : null,
|
|
61
|
+
clearable: CLEARABLE.includes(store),
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Delete one clearable store (or 'all' clearable stores).
|
|
68
|
+
* @param {string} cwd
|
|
69
|
+
* @param {string} store - session|notes|weights|evidence|all
|
|
70
|
+
* @returns {string[]} names of stores actually removed
|
|
71
|
+
*/
|
|
72
|
+
function clearMemory(cwd, store) {
|
|
73
|
+
const targets = store === 'all' ? CLEARABLE : [store];
|
|
74
|
+
for (const t of targets) {
|
|
75
|
+
if (!CLEARABLE.includes(t)) {
|
|
76
|
+
throw new Error(`unknown or protected store "${t}" — clearable: ${CLEARABLE.join(', ')}, all`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const removed = [];
|
|
80
|
+
for (const t of targets) {
|
|
81
|
+
try { fs.unlinkSync(storePath(cwd, t)); removed.push(t); } catch (_) {}
|
|
82
|
+
}
|
|
83
|
+
return removed;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
module.exports = { inspectMemory, clearMemory, STORES, CLEARABLE };
|