neurastream 0.1.25 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neurastream",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
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",
@@ -168,6 +168,18 @@ export function addIncident(cfg: Config, input: IncidentInput, now = nowSec()):
168
168
  return { incident: { ...rec, resolution: null }, deduped: false };
169
169
  }
170
170
 
171
+ /**
172
+ * The repo a plan belongs to: the nearest directory from the plan's folder upward that holds the
173
+ * repo INDEX.md. Plans live at any depth under the repo (docs/plans/immediate/…), so a fixed
174
+ * number of dirname steps lands short of the root.
175
+ */
176
+ function repoForPlan(abs: string): string | null {
177
+ for (let dir = dirname(abs); ; dir = dirname(dir)) {
178
+ if (existsSync(join(dir, q.REPO_INDEX))) return dir;
179
+ if (dirname(dir) === dir) return null;
180
+ }
181
+ }
182
+
171
183
  /**
172
184
  * Records the plan that fixes an incident: refused unless the file exists, is listed in its repo
173
185
  * INDEX.md, and contains `INCIDENT <id>` (the spawn gates look for that text). Returns the
@@ -181,7 +193,8 @@ export function planIncident(cfg: Config, id: string, planPath: string): string
181
193
  if (res) return `incident ${id} already has a ${res.type} record`;
182
194
  const abs = resolve(q.expandHome(planPath));
183
195
  if (!existsSync(abs)) return `plan file not found: ${abs}`;
184
- const repo = dirname(dirname(dirname(abs)));
196
+ const repo = repoForPlan(abs);
197
+ if (!repo) return `${abs} is not under a directory holding ${q.REPO_INDEX}`;
185
198
  if (!q.readRepoIndex(repo).includes(abs)) return `${abs} is not listed in ${join(repo, q.REPO_INDEX)}`;
186
199
  let text: string;
187
200
  try {
@@ -1,7 +1,10 @@
1
+ import { spawnSync } from "node:child_process";
1
2
  import type { Config } from "./config.ts";
2
3
 
3
4
  // Converts a provider's rate-limit reset time (wall clock in the provider's zone) into the caller's
4
- // local time. Intl does the zone math, so this needs no GNU date and behaves the same on macOS.
5
+ // local time. Intl does the zone math; date(1) supplies the local zone abbreviation, because Intl's
6
+ // short timeZoneName is a tzdata abbreviation only for US zones (Europe/Berlin prints "GMT+2" where
7
+ // date +%Z prints "CEST"). macOS's BSD date is used there, so no GNU date is needed.
5
8
 
6
9
  const USAGE =
7
10
  'usage: quota-reset "YYYY-MM-DD HH:MM[:SS]" [--tz <zone>] (reset time from your provider\'s rate-limit message)\n';
@@ -49,6 +52,19 @@ function parseWhen(text: string): { y: number; mo: number; d: number; h: number;
49
52
  return valid ? wall : null;
50
53
  }
51
54
 
55
+ // The tzdata abbreviation for this instant (CEST, CET, CST, +05) as date(1) prints it in the zone
56
+ // env this process runs in (the child inherits it, so the abbreviation always matches the wall
57
+ // clock next to it). Falls back to the Intl short name only when date fails.
58
+ function zoneAbbrev(epoch: number): string {
59
+ const probe =
60
+ process.platform === "darwin"
61
+ ? spawnSync("date", ["-r", String(epoch), "+%Z"], { encoding: "utf8" })
62
+ : spawnSync("date", ["-d", `@${epoch}`, "+%Z"], { encoding: "utf8" });
63
+ if (probe.status === 0 && probe.stdout?.trim()) return probe.stdout.trim();
64
+ const parts = new Intl.DateTimeFormat("en-US", { timeZoneName: "short" }).formatToParts(new Date(epoch * 1000));
65
+ return parts.find(p => p.type === "timeZoneName")?.value ?? "";
66
+ }
67
+
52
68
  // Local wall clock of the process, "YYYY-MM-DD HH:MM:SS ZONE".
53
69
  function localStamp(epoch: number): string {
54
70
  const parts = new Intl.DateTimeFormat("en-US", {
@@ -59,10 +75,9 @@ function localStamp(epoch: number): string {
59
75
  hour: "2-digit",
60
76
  minute: "2-digit",
61
77
  second: "2-digit",
62
- timeZoneName: "short",
63
78
  }).formatToParts(new Date(epoch * 1000));
64
- const get = (type: string): string => parts.find((p) => p.type === type)?.value ?? "";
65
- return `${get("year")}-${get("month")}-${get("day")} ${get("hour")}:${get("minute")}:${get("second")} ${get("timeZoneName")}`;
79
+ const get = (type: string): string => parts.find(p => p.type === type)?.value ?? "";
80
+ return `${get("year")}-${get("month")}-${get("day")} ${get("hour")}:${get("minute")}:${get("second")} ${zoneAbbrev(epoch)}`;
66
81
  }
67
82
 
68
83
  export function quotaReset(args: string[], cfg: Config): number {