neurastream 0.1.24 → 0.1.26
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 +4 -1
- package/package.json +2 -3
- package/src/adapters/omp/doctor.ts +6 -2
- package/src/adapters/omp/index.ts +3 -3
- package/src/cli/commands.ts +4 -8
- package/src/cli/dispatch.ts +50 -3
- package/src/cli/init.ts +34 -10
- package/src/core/brief-lint.ts +3 -16
- package/src/core/config.ts +24 -2
- package/src/core/file-lock.ts +89 -0
- package/src/core/guards.ts +22 -6
- package/src/core/heavy-run.ts +37 -29
- package/src/core/host.ts +19 -0
- package/src/core/incidents.ts +14 -1
- package/src/core/machine-guard.ts +5 -2
- package/src/core/main-start.ts +4 -1
- package/src/core/queue/lib.ts +21 -1
- package/src/core/queue-close.ts +5 -3
- package/src/core/quota-reset.ts +127 -0
- package/src/core/subagents.ts +83 -0
- package/src/core/tmp-snapshot.ts +26 -14
- package/templates/config.yml +6 -11
- package/templates/help/agent-score.txt +1 -1
- package/templates/help/brief-lint.txt +1 -1
- package/templates/help/wip-check.txt +1 -1
- package/templates/help/wip-snapshot.txt +1 -1
- package/templates/machine-guard.sh +57 -16
- package/templates/tmp-snapshot.sh +13 -7
- package/bin/pm-fail-facts +0 -6
- package/src/adapters/omp/herdr-agent-state.ts +0 -440
- package/src/core/glm-reset.ts +0 -32
- package/src/core/pm-fail-facts.ts +0 -116
- package/templates/help/pm-fail-facts.txt +0 -6
- /package/bin/{glm-reset → quota-reset} +0 -0
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
-
import { basename, resolve, join } from "node:path";
|
|
3
|
-
import type { Config } from "./config.ts";
|
|
4
|
-
import { exitText, helpDoc, printText } from "./help.ts";
|
|
5
|
-
|
|
6
|
-
function unescapeXml(s: string): string {
|
|
7
|
-
return s
|
|
8
|
-
.replace(/&#(\d+);/g, (_, n: string) => String.fromCharCode(Number(n)))
|
|
9
|
-
.replace(/&#x([0-9a-fA-F]+);/g, (_, n: string) => String.fromCharCode(parseInt(n, 16)))
|
|
10
|
-
.replace(/"/g, '"')
|
|
11
|
-
.replace(/'/g, "'")
|
|
12
|
-
.replace(/</g, "<")
|
|
13
|
-
.replace(/>/g, ">")
|
|
14
|
-
.replace(/&/g, "&");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function attr(blob: string, name: string): string {
|
|
18
|
-
const m = blob.match(new RegExp(`\\b${name}="([^"]*)"`)) ?? blob.match(new RegExp(`\\b${name}='([^']*)'`));
|
|
19
|
-
return m ? unescapeXml(m[1]!) : "";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function child(inner: string, tag: string): { attrs: string; text: string } | null {
|
|
23
|
-
const re = new RegExp(`<${tag}\\b([^>]*)/>|<${tag}\\b([^>]*)>([\\s\\S]*?)</${tag}>`);
|
|
24
|
-
const m = inner.match(re);
|
|
25
|
-
if (!m) return null;
|
|
26
|
-
if (m[1] !== undefined) return { attrs: m[1], text: "" };
|
|
27
|
-
return { attrs: m[2] ?? "", text: unescapeXml(m[3] ?? "") };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function opt(args: string[], name: string): string | undefined {
|
|
31
|
-
const i = args.indexOf(name);
|
|
32
|
-
if (i < 0) return undefined;
|
|
33
|
-
return args[i + 1];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function slug(s: string): string {
|
|
37
|
-
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function head(path: string, k: number): string {
|
|
41
|
-
try {
|
|
42
|
-
return readFileSync(path, "utf8").split(/\n/).slice(0, k).join("\n").replace(/\s+$/, "");
|
|
43
|
-
} catch {
|
|
44
|
-
return "";
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function pmFailFacts(args: string[], cfg: Config): number {
|
|
49
|
-
if (args.length < 1) return exitText(helpDoc("pm-fail-facts"));
|
|
50
|
-
const wt = resolve(args[0]!);
|
|
51
|
-
const nRaw = opt(args, "--lines");
|
|
52
|
-
const n = nRaw !== undefined ? Number(nRaw) : cfg.pm.fail_lines;
|
|
53
|
-
const blog = opt(args, "--backend-log") ?? cfg.pm.backend_log;
|
|
54
|
-
const junit = join(wt, "test-results", "e2e-junit.xml");
|
|
55
|
-
if (!existsSync(junit)) return exitText(`no ${junit}`);
|
|
56
|
-
|
|
57
|
-
const xml = readFileSync(junit, "utf8");
|
|
58
|
-
const cases: { cls: string; name: string; inner: string; attrs: string }[] = [];
|
|
59
|
-
const re = /<testcase\b([^>]*)\/>|<testcase\b([^>]*)>([\s\S]*?)<\/testcase>/g;
|
|
60
|
-
for (const m of xml.matchAll(re)) {
|
|
61
|
-
if (m[1] !== undefined) cases.push({ cls: attr(m[1], "classname"), name: attr(m[1], "name"), inner: "", attrs: m[1] });
|
|
62
|
-
else cases.push({ cls: attr(m[2] ?? "", "classname"), name: attr(m[2] ?? "", "name"), inner: m[3] ?? "", attrs: m[2] ?? "" });
|
|
63
|
-
}
|
|
64
|
-
const failed: { cls: string; name: string; text: string }[] = [];
|
|
65
|
-
for (const c of cases) {
|
|
66
|
-
const f = child(c.inner, "failure") ?? child(c.inner, "error");
|
|
67
|
-
if (f) failed.push({ cls: c.cls, name: c.name, text: `${attr(f.attrs, "message")}\n${f.text}` });
|
|
68
|
-
}
|
|
69
|
-
const skipped = cases.filter(c => /<skipped\b/.test(c.inner)).length;
|
|
70
|
-
printText(`== ${junit}: ${cases.length} tests, ${failed.length} failed, ${skipped} skipped`);
|
|
71
|
-
|
|
72
|
-
const artRoot = join(wt, "test-results", "playwright-output");
|
|
73
|
-
const dirs = existsSync(artRoot)
|
|
74
|
-
? readdirSync(artRoot).map(d => join(artRoot, d)).filter(d => {
|
|
75
|
-
try {
|
|
76
|
-
return statSync(d).isDirectory();
|
|
77
|
-
} catch {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
: [];
|
|
82
|
-
|
|
83
|
-
for (const { cls, name, text } of failed) {
|
|
84
|
-
const loc = text.match(/(tests\/[\w/.\-]+\.spec\.[jt]s):(\d+)/);
|
|
85
|
-
printText(`\n#### FAIL ${cls} :: ${name}`);
|
|
86
|
-
if (loc) printText(`at ${loc[1]}:${loc[2]}`);
|
|
87
|
-
const err = text.split(/\r?\n/).filter(l => l.trim()).slice(0, n);
|
|
88
|
-
printText(err.map(l => ` ${l.slice(0, 220)}`).join("\n"));
|
|
89
|
-
const words = slug(`${cls} ${name}`).split("-").filter(w => w.length > 2);
|
|
90
|
-
const scored = dirs
|
|
91
|
-
.map(d => ({ score: words.filter(w => basename(d).toLowerCase().includes(w)).length, d }))
|
|
92
|
-
.sort((a, b) => b.score - a.score || (a.d < b.d ? 1 : a.d > b.d ? -1 : 0));
|
|
93
|
-
const best = scored[0]?.score ?? 0;
|
|
94
|
-
const match = scored.filter(s => s.score >= 2 && s.score === best).slice(0, 2).map(s => s.d);
|
|
95
|
-
for (const d of match) {
|
|
96
|
-
printText(`-- artifacts ${d}`);
|
|
97
|
-
for (const fn of ["error-context.md", "failed-requests.log", "console-errors.log"]) {
|
|
98
|
-
const p = join(d, fn);
|
|
99
|
-
if (!existsSync(p)) continue;
|
|
100
|
-
printText(` [${fn}]`);
|
|
101
|
-
printText(head(p, n).split(/\r?\n/).map(l => ` ${l.slice(0, 200)}`).join("\n"));
|
|
102
|
-
}
|
|
103
|
-
const traces = existsSync(d) ? readdirSync(d).filter(f => f.startsWith("trace") && f.endsWith(".zip")) : [];
|
|
104
|
-
if (traces.length) printText(` trace: ${join(d, traces[0]!)} (npx playwright show-trace)`);
|
|
105
|
-
}
|
|
106
|
-
if (match.length === 0) printText("-- no artifact dir matched");
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (existsSync(blog)) {
|
|
110
|
-
const pat = new RegExp(cfg.pm.backend_error);
|
|
111
|
-
const hits = readFileSync(blog, "utf8").split(/\n/).map(l => l.replace(/\s+$/, "")).filter(l => pat.test(l));
|
|
112
|
-
printText(`\n== backend log ${blog}: ${hits.length} error lines (last ${n})`);
|
|
113
|
-
printText(hits.slice(-n).map(l => ` ${l.slice(0, 220)}`).join("\n"));
|
|
114
|
-
}
|
|
115
|
-
return 0;
|
|
116
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
pm-fail-facts: every fact about a Playwright run's failures in ONE call.
|
|
2
|
-
|
|
3
|
-
Replaces hand-grepping logs/artifacts turn by turn (owner 2026-10-11: deterministic work goes to scripts).
|
|
4
|
-
For each failed test in <worktree>/test-results/e2e-junit.xml: title, file:line, error head,
|
|
5
|
-
artifact dir, error-context.md head, failed-requests.log, console errors; then backend log errors.
|
|
6
|
-
Usage: pm-fail-facts <worktree> [--backend-log PATH] [--lines N]
|
|
File without changes
|