@cstart/coldstart 2.2.14 → 2.2.15
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/dist/kb/cli.js +69 -49
- package/dist/kb/cli.js.map +1 -1
- package/dist/kb/durable-worklist.d.ts +18 -0
- package/dist/kb/durable-worklist.d.ts.map +1 -0
- package/dist/kb/durable-worklist.js +121 -0
- package/dist/kb/durable-worklist.js.map +1 -0
- package/dist/kb/store.d.ts.map +1 -1
- package/dist/kb/store.js +17 -3
- package/dist/kb/store.js.map +1 -1
- package/dist/kb/write-batch.d.ts +21 -0
- package/dist/kb/write-batch.d.ts.map +1 -0
- package/dist/kb/write-batch.js +77 -0
- package/dist/kb/write-batch.js.map +1 -0
- package/dist/kb/write-guide.d.ts.map +1 -1
- package/dist/kb/write-guide.js +17 -9
- package/dist/kb/write-guide.js.map +1 -1
- package/dist/kb/write.d.ts.map +1 -1
- package/dist/kb/write.js +10 -1
- package/dist/kb/write.js.map +1 -1
- package/dist/server/mcp.d.ts +8 -1
- package/dist/server/mcp.d.ts.map +1 -1
- package/dist/server/mcp.js +48 -35
- package/dist/server/mcp.js.map +1 -1
- package/hooks/capture-payload.mjs +56 -28
- package/package.json +1 -1
- package/dist/kb/session-worklist.d.ts +0 -10
- package/dist/kb/session-worklist.d.ts.map +0 -1
- package/dist/kb/session-worklist.js +0 -92
- package/dist/kb/session-worklist.js.map +0 -1
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Capture coverage — telling the writing agent how much of its worklist it noted.
|
|
3
|
-
*
|
|
4
|
-
* The gap this closes: the capture checklist hands the agent a worklist of every
|
|
5
|
-
* file it worked on, but `kb write` only ever sees ONE spec, so nothing could
|
|
6
|
-
* report "you wrote 8 notes for 30 worked files". The agent's own count is the
|
|
7
|
-
* one thing it cannot check — it is mid-heredoc, and under-capture is silent by
|
|
8
|
-
* construction. So the hook drops the worklist in tmpdir when it builds the
|
|
9
|
-
* capture prompt, and every `kb write --session <sid>` prints the running ratio.
|
|
10
|
-
*
|
|
11
|
-
* CONTRACT TWIN: hooks/capture-payload.mjs (worklistManifestPath) writes this
|
|
12
|
-
* file; keep the name and shape in step. Everything here is best-effort — a
|
|
13
|
-
* missing, stale or malformed manifest prints nothing and never fails a write.
|
|
14
|
-
*
|
|
15
|
-
* Local only. The manifest lives in tmpdir, never in the repo: it is scratch
|
|
16
|
-
* state for one session, not a record, and nothing about it is transmitted.
|
|
17
|
-
*/
|
|
18
|
-
import { readFileSync, writeFileSync } from 'node:fs';
|
|
19
|
-
import { tmpdir } from 'node:os';
|
|
20
|
-
import { join } from 'node:path';
|
|
21
|
-
/** Manifests older than this are a resumed/unrelated session — ignore them. */
|
|
22
|
-
const MAX_AGE_MS = 24 * 60 * 60 * 1000;
|
|
23
|
-
/** Below this share of outstanding files, name the skips. */
|
|
24
|
-
const LOW_COVERAGE = 0.5;
|
|
25
|
-
const LIST_MAX = 6;
|
|
26
|
-
function manifestPath(sid) {
|
|
27
|
-
return join(tmpdir(), `coldstart-kb-worklist-${sid}.json`);
|
|
28
|
-
}
|
|
29
|
-
function load(sid) {
|
|
30
|
-
try {
|
|
31
|
-
const m = JSON.parse(readFileSync(manifestPath(sid), 'utf8'));
|
|
32
|
-
if (!Array.isArray(m?.files) || !m.files.length)
|
|
33
|
-
return null;
|
|
34
|
-
if (typeof m.ts === 'number' && Date.now() - m.ts > MAX_AGE_MS)
|
|
35
|
-
return null;
|
|
36
|
-
m.wrote = Array.isArray(m.wrote) ? m.wrote : [];
|
|
37
|
-
return m;
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/** Paths this spec puts a note on. Flow steps do NOT count: a flow verifies
|
|
44
|
-
* files, it does not give any of them the file note rule 5 asks for. */
|
|
45
|
-
export function specPaths(spec) {
|
|
46
|
-
const s = spec;
|
|
47
|
-
if (!s || typeof s.path !== 'string')
|
|
48
|
-
return [];
|
|
49
|
-
return s.type === 'file-single' || s.type === 'file-hub' ? [s.path] : [];
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Record this write against the session worklist and return the coverage line
|
|
53
|
-
* to print, or null when there is no manifest to compare against (no --session,
|
|
54
|
-
* a manual `kb write` outside capture, a session that never armed).
|
|
55
|
-
*/
|
|
56
|
-
export function noteCoverage(sid, spec) {
|
|
57
|
-
if (!sid)
|
|
58
|
-
return null;
|
|
59
|
-
const m = load(sid);
|
|
60
|
-
if (!m)
|
|
61
|
-
return null;
|
|
62
|
-
for (const p of specPaths(spec))
|
|
63
|
-
if (!m.wrote.includes(p))
|
|
64
|
-
m.wrote.push(p);
|
|
65
|
-
try {
|
|
66
|
-
writeFileSync(manifestPath(sid), JSON.stringify(m));
|
|
67
|
-
}
|
|
68
|
-
catch { /* best-effort */ }
|
|
69
|
-
const outstanding = m.files.filter((f) => f.needsNote);
|
|
70
|
-
if (!outstanding.length)
|
|
71
|
-
return null;
|
|
72
|
-
const wrote = new Set(m.wrote);
|
|
73
|
-
const done = outstanding.filter((f) => wrote.has(f.path));
|
|
74
|
-
const left = outstanding.filter((f) => !wrote.has(f.path));
|
|
75
|
-
const already = m.files.length - outstanding.length;
|
|
76
|
-
const lines = [
|
|
77
|
-
`capture coverage: ${done.length} of ${outstanding.length} worklist files noted` +
|
|
78
|
-
(already ? ` (${already} more already had a fresh note)` : ''),
|
|
79
|
-
];
|
|
80
|
-
if (left.length) {
|
|
81
|
-
const shown = left.slice(0, LIST_MAX).map((f) => `${f.path} [${f.tier}]`).join(', ');
|
|
82
|
-
lines.push(` not noted yet: ${shown}${left.length > LIST_MAX ? `, +${left.length - LIST_MAX} more` : ''}`);
|
|
83
|
-
}
|
|
84
|
-
// The nudge fires only on the low end, and asks for a REASON rather than more
|
|
85
|
-
// notes: a deliberate skip is a fine answer, an invisible one is not. Chained
|
|
86
|
-
// writes each print this, so the last line of the block carries the real tally.
|
|
87
|
-
if (left.length && done.length / outstanding.length < LOW_COVERAGE) {
|
|
88
|
-
lines.push(' if those need no note, say which and why in your reply — an unexplained skip reads as a forgotten one.');
|
|
89
|
-
}
|
|
90
|
-
return lines.join('\n');
|
|
91
|
-
}
|
|
92
|
-
//# sourceMappingURL=session-worklist.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-worklist.js","sourceRoot":"","sources":["../../src/kb/session-worklist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAKjC,+EAA+E;AAC/E,MAAM,UAAU,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACvC,6DAA6D;AAC7D,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,QAAQ,GAAG,CAAC,CAAC;AAEnB,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE,yBAAyB,GAAG,OAAO,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,IAAI,CAAC,GAAW;IACvB,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAa,CAAC;QAC1E,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QAC7D,IAAI,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,UAAU;YAAE,OAAO,IAAI,CAAC;QAC5E,CAAC,CAAC,KAAK,GAAG,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