neurastream 0.2.71 → 0.2.72

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neurastream",
3
- "version": "0.2.71",
3
+ "version": "0.2.72",
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": [
6
6
  "ai-agents",
@@ -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 { gatherTags } from "../core/results.ts";
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: gatherTags(gitTop(import.meta.dir)?.repo ?? null),
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 => {
@@ -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]+(.+?)[ \t]*$/im.exec(text)?.[1] ?? "").trim();
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;
@@ -1848,6 +1862,7 @@ export function checkSpawn(e: SpawnEvent, cfg: Config, runner: CommandRunner = d
1848
1862
  const delegatedPlanner = plannerFor !== null && currentPlanner(cfg) === "delegated";
1849
1863
  if (plannerFor && !delegatedPlanner)
1850
1864
  problems.push(`${e.agent}: planner mode is main — a Planner-role spawn needs the owner's \`planner delegated\` switch.`);
1865
+ else if (delegatedPlanner && plannerPlanProblem(plannerFor)) problems.push(`${e.agent}: ${plannerPlanProblem(plannerFor)}`);
1851
1866
  else if (delegatedPlanner && !e.name) problems.push(`${e.agent}: a planner spawn needs a name (the task name keys its planner role).`);
1852
1867
  const [why, named] = delegatedPlanner ? [null, [] as string[]] : planGate(e.brief, e.agent, cfg);
1853
1868
  if (why) problems.push(why);
@@ -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;