neurastream 0.2.71 → 0.2.73
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/cli/dispatch.ts +2 -2
- package/src/core/guards.ts +25 -6
- package/src/core/results.ts +25 -0
package/package.json
CHANGED
package/src/cli/dispatch.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { beat, withHeartbeat } from "../core/heartbeat.ts";
|
|
|
6
6
|
import { helpDoc } from "../core/help.ts";
|
|
7
7
|
import { watchOnce, systemUnitLister, watchDoctorLine, watchHealth, timerStaffedPlans } from "../core/watch.ts";
|
|
8
8
|
import { defaultGather } from "../core/main-start.ts";
|
|
9
|
-
import {
|
|
9
|
+
import { gatherReleaseTags } from "../core/results.ts";
|
|
10
10
|
import { nowSec } from "../core/clock.ts";
|
|
11
11
|
import { postReply } from "../core/notify.ts";
|
|
12
12
|
import { log } from "../core/guards.ts";
|
|
@@ -213,7 +213,7 @@ export async function run(cmd: string, args: string[]): Promise<number> {
|
|
|
213
213
|
gather: defaultGather(cfg, getAdapter(cfg)),
|
|
214
214
|
// P11: the self repo's tags and the session source feed the release verdict; no tags — no verdicts.
|
|
215
215
|
source: getAdapter(cfg).runSource(cfg),
|
|
216
|
-
tags:
|
|
216
|
+
tags: gatherReleaseTags(gitTop(import.meta.dir)?.repo ?? null).filter(t => t.ts > nowSec() - 7 * 86400),
|
|
217
217
|
notify: text => {
|
|
218
218
|
sends.push(
|
|
219
219
|
postReply(text, cfg).then(rs => {
|
package/src/core/guards.ts
CHANGED
|
@@ -364,12 +364,21 @@ function matchReviewSpawn(spawns: Record<string, ReviewSpawn>, agentId: string):
|
|
|
364
364
|
|
|
365
365
|
// --- planner mode (plan 20261102_1515 P2): the named planner spawns ---
|
|
366
366
|
|
|
367
|
-
/** The plan path a brief's `Planner role for <plan path>` line names, or null. */
|
|
368
|
-
function plannerRolePlan(text: string): string | null {
|
|
369
|
-
const p = (/^[ \t]*Planner role for[ \t]+(
|
|
367
|
+
/** The plan path a brief's `Planner role for <plan path>` line names (its first word, trailing `.,;:` dropped, so text after the path never joins it), or null. */
|
|
368
|
+
export function plannerRolePlan(text: string): string | null {
|
|
369
|
+
const p = (/^[ \t]*Planner role for[ \t]+(\S+)/im.exec(text)?.[1] ?? "").replace(/[.,;:]+$/, "");
|
|
370
370
|
return p || null;
|
|
371
371
|
}
|
|
372
372
|
|
|
373
|
+
/** Spawn-time check of a bound planner plan path: absolute, `.md`, under a `docs/plans` dir that exists (the planner may create a subfolder). Returns the refusal text, or null when fine. */
|
|
374
|
+
export function plannerPlanProblem(plan: string): string | null {
|
|
375
|
+
const cut = plan.indexOf("/docs/plans/");
|
|
376
|
+
const ok = path.isAbsolute(plan) && plan.endsWith(".md") && cut >= 0 && existsSync(plan.slice(0, cut + "/docs/plans".length));
|
|
377
|
+
return ok
|
|
378
|
+
? null
|
|
379
|
+
: `the \`Planner role for\` path "${plan}" must be an absolute .md path in an existing docs/plans dir, alone as the first word after "for" (e.g. \`Planner role for /path/to/repo/docs/plans/20261103_1015_x.md\`).`;
|
|
380
|
+
}
|
|
381
|
+
|
|
373
382
|
/** P2(b): the named planner spawns, spawn name → the one plan path its brief may create and edit (planner-spawns.json in the state dir). Recorded only on an approved spawn: in main mode the spawn gate refused the brief, so a binding exists only for a delegated planner. */
|
|
374
383
|
function plannerSpawnsFile(): string {
|
|
375
384
|
return path.join(q.STATE_DIR, "planner-spawns.json");
|
|
@@ -1038,6 +1047,11 @@ export function spawnProblem(
|
|
|
1038
1047
|
problems.push(`${label}: planner mode is main — a Planner-role spawn needs the owner's \`planner delegated\` switch.`);
|
|
1039
1048
|
continue;
|
|
1040
1049
|
}
|
|
1050
|
+
const plannerBad = plannerFor ? plannerPlanProblem(plannerFor) : null;
|
|
1051
|
+
if (plannerBad) {
|
|
1052
|
+
problems.push(`${label}: ${plannerBad}`);
|
|
1053
|
+
continue;
|
|
1054
|
+
}
|
|
1041
1055
|
if (plannerFor && !t?.name) {
|
|
1042
1056
|
problems.push(`${label}: a planner spawn needs a name (the task name keys its planner role).`);
|
|
1043
1057
|
continue;
|
|
@@ -1341,12 +1355,16 @@ function subRules(e: ToolEvent, input: Record<string, unknown>, paths: string[],
|
|
|
1341
1355
|
for (const plan of plans) {
|
|
1342
1356
|
const hit = paths.filter(p => !q.isOrchestrationPath(p, plans) && q.planCovers(plan, p, plans));
|
|
1343
1357
|
if (!hit.length) continue;
|
|
1344
|
-
|
|
1358
|
+
// An invalid plan stops code writes, not reads and not the repair of plan files: refusing those
|
|
1359
|
+
// too left a planner unable to fix the very errors the guard named (writes are checked before
|
|
1360
|
+
// the file is valid, so no valid text could ever land).
|
|
1361
|
+
const readOnly = cfg.guards.read_tools.includes(e.tool) || (cfg.guards.shell_tools.includes(e.tool) && !writes.length && !writesShellText(input, cfg));
|
|
1362
|
+
const planRepair = writes.length > 0 && writes.every(w => q.planAt(w, plans));
|
|
1363
|
+
if (plan.errors.length && !readOnly && !planRepair) return `plan ${plan.file} is invalid (${plan.errors.join("; ")}). Stop and report to Main.`;
|
|
1345
1364
|
// P5c (plan 20261031_1207): reads and read-only shell calls skip the phase-0 blockers — a
|
|
1346
1365
|
// failing blocker used to deny every read of a covered path and send the worker back blind.
|
|
1347
1366
|
// The shell filter is the review lock's (writesShellText), so landing text keeps its blocker.
|
|
1348
|
-
|
|
1349
|
-
if (!readOnly) {
|
|
1367
|
+
if (!readOnly && !planRepair) {
|
|
1350
1368
|
const why = runBlockers(plan, hit, e, cfg);
|
|
1351
1369
|
if (why) return why;
|
|
1352
1370
|
}
|
|
@@ -1848,6 +1866,7 @@ export function checkSpawn(e: SpawnEvent, cfg: Config, runner: CommandRunner = d
|
|
|
1848
1866
|
const delegatedPlanner = plannerFor !== null && currentPlanner(cfg) === "delegated";
|
|
1849
1867
|
if (plannerFor && !delegatedPlanner)
|
|
1850
1868
|
problems.push(`${e.agent}: planner mode is main — a Planner-role spawn needs the owner's \`planner delegated\` switch.`);
|
|
1869
|
+
else if (delegatedPlanner && plannerPlanProblem(plannerFor)) problems.push(`${e.agent}: ${plannerPlanProblem(plannerFor)}`);
|
|
1851
1870
|
else if (delegatedPlanner && !e.name) problems.push(`${e.agent}: a planner spawn needs a name (the task name keys its planner role).`);
|
|
1852
1871
|
const [why, named] = delegatedPlanner ? [null, [] as string[]] : planGate(e.brief, e.agent, cfg);
|
|
1853
1872
|
if (why) problems.push(why);
|
package/src/core/results.ts
CHANGED
|
@@ -298,6 +298,31 @@ export function gatherTags(repo: string | null): ReleaseTag[] {
|
|
|
298
298
|
return out;
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
+
/** The v* release dates out of an npm registry document's `time` map ("0.2.71": ISO date); the created/modified keys and bad dates are skipped. */
|
|
302
|
+
export function registryTags(doc: unknown): ReleaseTag[] {
|
|
303
|
+
const time = (doc as { time?: Record<string, unknown> } | null)?.time;
|
|
304
|
+
if (!time || typeof time !== "object") return [];
|
|
305
|
+
const out: ReleaseTag[] = [];
|
|
306
|
+
for (const [version, at] of Object.entries(time)) {
|
|
307
|
+
const ms = typeof at === "string" ? Date.parse(at) : Number.NaN;
|
|
308
|
+
if (/^\d+\.\d+\.\d+$/.test(version) && Number.isFinite(ms)) out.push({ name: `v${version}`, ts: Math.floor(ms / 1000) });
|
|
309
|
+
}
|
|
310
|
+
return out;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** The release dates this install is judged by: the git tags of the self repo when the code runs from a checkout, else the package's publish dates from the npm registry (an installed copy has no .git, so the release verdict never had a date to judge from). A network or parse failure lists none. */
|
|
314
|
+
export function gatherReleaseTags(repo: string | null): ReleaseTag[] {
|
|
315
|
+
if (repo) return gatherTags(repo);
|
|
316
|
+
try {
|
|
317
|
+
const pkg = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8")) as { name?: string };
|
|
318
|
+
if (!pkg.name) return [];
|
|
319
|
+
const proc = Bun.spawnSync(["curl", "-fsS", "--max-time", "10", `https://registry.npmjs.org/${pkg.name}`], { stdout: "pipe", stderr: "pipe" });
|
|
320
|
+
return proc.exitCode === 0 ? registryTags(JSON.parse(proc.stdout.toString())) : [];
|
|
321
|
+
} catch {
|
|
322
|
+
return [];
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
301
326
|
export interface ProductValue {
|
|
302
327
|
repo: string;
|
|
303
328
|
name: string;
|