neurastream 0.2.2 → 0.2.4
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/package.json +1 -1
- package/src/core/brief-lint.ts +26 -1
- package/src/core/guards.ts +1 -1
- package/src/core/queue/lib.ts +10 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neurastream",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Guardrails for running many AI coding agents at once: plan queue, blockers, call budgets, provider caps, scoring, merge-verified close.",
|
|
5
5
|
"keywords": ["ai-agents", "coding-agents", "orchestration", "guardrails", "omp", "bun", "cli"],
|
|
6
6
|
"homepage": "https://github.com/umiddey/neurastream#readme",
|
package/src/core/brief-lint.ts
CHANGED
|
@@ -2,8 +2,32 @@ import { existsSync, readFileSync, statSync } from "node:fs";
|
|
|
2
2
|
import { basename, dirname } from "node:path";
|
|
3
3
|
import type { Config } from "./config.ts";
|
|
4
4
|
import { exitText, helpDoc, printText } from "./help.ts";
|
|
5
|
+
import { sections } from "./queue/lib.ts";
|
|
5
6
|
|
|
6
7
|
const OUTPUT_HINT = /(report|progress|review|handoff|log|brief)[\w\-]*\.(md|log|txt|json)$|\.log$/;
|
|
8
|
+
const TICKED_PHASE = /^\s*[-*]\s+\[[xX]\]/;
|
|
9
|
+
|
|
10
|
+
// A plan's paths are live work only in the header lines, Goal, Forbidden, Blockers, unticked phase
|
|
11
|
+
// lines and Done check. Ticked phases and the history sections (Code read by Main, Progress,
|
|
12
|
+
// Background) cite worktrees removed after their work landed, so the path check skips them. A plain
|
|
13
|
+
// brief (no `## Phases`) is checked whole.
|
|
14
|
+
function liveText(text: string): string {
|
|
15
|
+
const secs = sections(text);
|
|
16
|
+
if (!secs.has("phases")) return text;
|
|
17
|
+
const header = text.slice(0, text.search(/^## /m));
|
|
18
|
+
const unticked = (secs.get("phases") ?? "")
|
|
19
|
+
.split("\n")
|
|
20
|
+
.filter(l => !TICKED_PHASE.test(l))
|
|
21
|
+
.join("\n");
|
|
22
|
+
return [
|
|
23
|
+
header,
|
|
24
|
+
secs.get("goal") ?? "",
|
|
25
|
+
secs.get("forbidden") ?? "",
|
|
26
|
+
secs.get("blockers") ?? "",
|
|
27
|
+
unticked,
|
|
28
|
+
secs.get("done check") ?? "",
|
|
29
|
+
].join("\n");
|
|
30
|
+
}
|
|
7
31
|
|
|
8
32
|
function escapeReg(s: string): string {
|
|
9
33
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -41,9 +65,10 @@ function lint(path: string, cfg: Config): { errs: string[]; warns: string[] } {
|
|
|
41
65
|
|
|
42
66
|
|
|
43
67
|
const paths = new Set<string>();
|
|
68
|
+
const scan = liveText(text);
|
|
44
69
|
for (const prefix of cfg.brief.path_prefixes) {
|
|
45
70
|
const re = new RegExp(`(${escapeReg(prefix)}[\\w./\\-]+)`, "g");
|
|
46
|
-
for (const hit of
|
|
71
|
+
for (const hit of scan.matchAll(re)) paths.add(hit[1]!);
|
|
47
72
|
}
|
|
48
73
|
for (const raw of [...paths].sort()) {
|
|
49
74
|
let p = raw.replace(/[.,)]+$/, "");
|
package/src/core/guards.ts
CHANGED
|
@@ -301,7 +301,7 @@ function subRules(e: ToolEvent, input: Record<string, unknown>, paths: string[],
|
|
|
301
301
|
return `${p} is a plan file: change its "## Progress" section only with the edit or write tool.`;
|
|
302
302
|
}
|
|
303
303
|
for (const plan of plans) {
|
|
304
|
-
const hit = paths.filter(p => !q.isOrchestrationPath(p, plans) && q.planCovers(plan, p));
|
|
304
|
+
const hit = paths.filter(p => !q.isOrchestrationPath(p, plans) && q.planCovers(plan, p, plans));
|
|
305
305
|
if (!hit.length) continue;
|
|
306
306
|
if (plan.errors.length) return `plan ${plan.file} is invalid (${plan.errors.join("; ")}). Stop and report to Main.`;
|
|
307
307
|
const why = runBlockers(plan, hit, e, cfg);
|
package/src/core/queue/lib.ts
CHANGED
|
@@ -283,9 +283,16 @@ function under(p: string, root: string): boolean {
|
|
|
283
283
|
return p === root || p.startsWith(`${root}/`);
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
export function planCovers(plan: Plan, p: string): boolean {
|
|
287
|
-
|
|
288
|
-
|
|
286
|
+
export function planCovers(plan: Plan, p: string, plans: Plan[] = []): boolean {
|
|
287
|
+
// One plan = one worktree (0.2.0 one-index): a linked worktree that another open plan names
|
|
288
|
+
// as its Worktree is that plan's ground, so this plan covers such a path only through its
|
|
289
|
+
// own Worktree or ## Applies to — the repo-level fallback below must not claim every
|
|
290
|
+
// worktree of the shared repo. Paths in the main checkout and in worktrees no open plan
|
|
291
|
+
// names stay covered as before (safe default).
|
|
292
|
+
const g = gitTop(p);
|
|
293
|
+
if (g && plans.some(o => o !== plan && o.status === "open" && o.worktree && o.worktree === g.top))
|
|
294
|
+
return plan.appliesTo.some(a => under(p, a)) || (!!plan.worktree && under(p, plan.worktree));
|
|
295
|
+
return under(p, plan.repo) || plan.appliesTo.some(a => under(p, a)) || (!!plan.worktree && under(p, plan.worktree)) || repoRoot(p) === plan.repo;
|
|
289
296
|
}
|
|
290
297
|
|
|
291
298
|
export function planAt(p: string, plans: Plan[]): Plan | null {
|