neurastream 0.3.21 → 0.3.22
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 +1 -0
- package/package.json +1 -1
- package/src/adapters/omp/doctor.ts +6 -0
- package/src/cli/dispatch.ts +7 -0
- package/src/cli/reuse.ts +109 -0
- package/src/cli/setup.ts +25 -1
- package/src/core/config.ts +29 -0
- package/src/core/guards/plan-edit.ts +200 -8
- package/src/core/guards/spawn.ts +13 -3
- package/src/core/queue/lib.ts +58 -4
- package/src/core/reuse-map.ts +742 -0
- package/src/core/setup-detect.ts +8 -3
- package/src/core/uninstall.ts +14 -0
- package/templates/config.yml +7 -0
package/src/core/queue/lib.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { Config } from "../config.ts";
|
|
|
9
9
|
import type { ClaimStore } from "../claims.ts";
|
|
10
10
|
import { strftime } from "../clock.ts";
|
|
11
11
|
import { withFileLock, writeAtomicSync } from "../file-lock.ts";
|
|
12
|
+
import { MAX_TERMS, NONE_TERMS_MIN, citedQuotes, hasBareChecked, isMapOrNoneLine, normRel, parseMapLine, parseNoneLine, type ParsedMapLine, type ParsedNoneLine } from "../reuse-map.ts";
|
|
12
13
|
|
|
13
14
|
// --- landing detection (plan 20261031_0911 P4/P5): lives here, not queue-close.ts, because
|
|
14
15
|
// queueProblems' landed lock needs it and lib must not import the closer that imports lib ---
|
|
@@ -403,18 +404,64 @@ export function headerField(text: string, name: string): string | null {
|
|
|
403
404
|
* P1 (plan 20261028_1600): every new thing a plan adds carries a reuse line with a checked
|
|
404
405
|
* `path:line` citation that exists relative to the plan's repo. Applies to every plan (P5
|
|
405
406
|
* removed the cutover); an empty `review.agents` list turns the gate off (P5c).
|
|
407
|
+
*
|
|
408
|
+
* P2 (plan 20261122_1828_reuse_map): text only. When a map or none line is present the section
|
|
409
|
+
* follows the map rule instead: those lines skip the plain `checked:` rule, every `new:` citation
|
|
410
|
+
* carries a quoted line, the map's matched files are cited on >= N distinct lines, a none line
|
|
411
|
+
* searches >= 3 and at most MAX_TERMS distinct terms. Quote equality and the graphify re-run live
|
|
412
|
+
* in plan-edit's reuseMapWriteProblems — this function stays on the hot path, so it never reads
|
|
413
|
+
* a graph or runs graphify.
|
|
406
414
|
*/
|
|
407
415
|
function reuseProblems(repo: string, file: string, secs: Map<string, string>, reviewAgents: string[]): string[] {
|
|
408
416
|
if (!reviewAgents.length) return [];
|
|
409
417
|
const lines = items(secs.get("reuse") ?? "");
|
|
410
418
|
if (!lines.length)
|
|
411
419
|
return [`missing or empty "## Reuse" section (one line per new thing: - new: <thing> — checked: <path>:<line> — reuse: <how, or why not>; "- new: none — ..." when nothing is new)`];
|
|
420
|
+
const map = lines.map(parseMapLine).find((m) => m !== null) ?? null;
|
|
421
|
+
const none = lines.map(parseNoneLine).find((n) => n !== null) ?? null;
|
|
422
|
+
if (!map && !none) {
|
|
423
|
+
const probs: string[] = [];
|
|
424
|
+
for (const line of lines) {
|
|
425
|
+
const m = /checked:\s*`?([^`\s—]+):(\d+)(?:-\d+)?`?/.exec(line);
|
|
426
|
+
if (!m) probs.push(`reuse line without "checked: <path>:<line>": ${line.slice(0, 80)}`);
|
|
427
|
+
else if (!existsSync(path.resolve(repo, m[1]!))) probs.push(`reuse citation does not exist: ${m[1]}`);
|
|
428
|
+
}
|
|
429
|
+
return probs;
|
|
430
|
+
}
|
|
431
|
+
return mapGateProblems(repo, lines, map, none);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/** Text half of the map gate (plan 20261122_1828_reuse_map P2a): shapes only, never a graphify run. */
|
|
435
|
+
function mapGateProblems(repo: string, lines: string[], map: ParsedMapLine | null, none: ParsedNoneLine | null): string[] {
|
|
412
436
|
const probs: string[] = [];
|
|
437
|
+
if (map && none) probs.push("either a - map: line or a none-to-reuse line under ## Reuse, not both");
|
|
413
438
|
for (const line of lines) {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
439
|
+
if (isMapOrNoneLine(line) || !/map:|none to reuse/.test(line)) continue;
|
|
440
|
+
probs.push(`a "- map:" or "none to reuse" line that does not parse — rerun \`neurastream reuse map\`: ${line.slice(0, 80)}`);
|
|
441
|
+
}
|
|
442
|
+
if (map && map.terms.length > MAX_TERMS)
|
|
443
|
+
probs.push(`${map.terms.length} terms on the map line (at most ${MAX_TERMS} — each term is one graphify query)`);
|
|
444
|
+
if (none) {
|
|
445
|
+
if (none.terms.length < NONE_TERMS_MIN)
|
|
446
|
+
probs.push(`the none line searches ${none.terms.length} terms (search at least ${NONE_TERMS_MIN} distinct terms: - new: none to reuse — searched: "t1", "t2", "t3")`);
|
|
447
|
+
if (none.terms.length > MAX_TERMS)
|
|
448
|
+
probs.push(`${none.terms.length} terms on the none line (at most ${MAX_TERMS} — each term is one graphify query)`);
|
|
417
449
|
}
|
|
450
|
+
const matched = map ? new Set(map.files.map(normRel)) : null;
|
|
451
|
+
const cited = new Set<string>();
|
|
452
|
+
for (const line of lines) {
|
|
453
|
+
if (isMapOrNoneLine(line) || !line.includes("new:")) continue;
|
|
454
|
+
if (hasBareChecked(line)) {
|
|
455
|
+
probs.push(`reuse citation without a quoted line ("checked: <path>:<n> \\"the file's text at that line\\""): ${line.slice(0, 80)}`);
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
for (const c of citedQuotes(line)) {
|
|
459
|
+
if (!existsSync(path.resolve(repo, c.file))) probs.push(`reuse citation does not exist: ${c.file}`);
|
|
460
|
+
if (matched) cited.add(normRel(c.file));
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
if (matched && cited.size < map!.cite)
|
|
464
|
+
probs.push(`${cited.size} of the map's ${map!.cite} matched files cited — cite ${map!.cite} of ${[...matched].join(", ")} as "checked: <path>:<n> \\"the file's text at that line\\""`);
|
|
418
465
|
return probs;
|
|
419
466
|
}
|
|
420
467
|
|
|
@@ -939,9 +986,16 @@ export function chatUnlock(text: string, cfg: Config, source: string, word: "cha
|
|
|
939
986
|
return { applied: true, command: "unlock", minutes: n, until: Math.floor(past + minutes * 60) };
|
|
940
987
|
}
|
|
941
988
|
|
|
989
|
+
// P2b (plan 20261122_1828_reuse_map): the reuse map's own directory and the worktree registry are
|
|
990
|
+
// protected in any repo, the directory itself included (`rm -rf graphify-out`, `ln -s … graphify-out`).
|
|
991
|
+
const PROTECTED_SEGMENTS = [/(^|\/)graphify-out(\/|$)/, /(^|\/)\.git\/worktrees(\/|$)/];
|
|
992
|
+
|
|
942
993
|
export function protectedHit(targetPaths: string[], paths: QueuePaths): string | null {
|
|
943
994
|
const guarded = protectedPaths(paths);
|
|
944
|
-
for (const p of targetPaths)
|
|
995
|
+
for (const p of targetPaths) {
|
|
996
|
+
if (PROTECTED_SEGMENTS.some((re) => re.test(p))) return p;
|
|
997
|
+
for (const g of guarded) if (g.endsWith("/") ? p.startsWith(g) || `${p}/` === g : p === g) return p;
|
|
998
|
+
}
|
|
945
999
|
return null;
|
|
946
1000
|
}
|
|
947
1001
|
|