neurastream 0.1.20 → 0.1.21

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.20",
3
+ "version": "0.1.21",
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",
@@ -360,6 +360,28 @@ function packageOpTarget(code: string): string | null {
360
360
  return packageOpMatcher?.(code) ?? null;
361
361
  }
362
362
 
363
+ // Heredoc bodies are data, not commands: a `<<WORD` body (up to a line that is
364
+ // exactly WORD; leading tabs are ignored for `<<-`) is dropped from the text the
365
+ // redirect and command-word scans read. The line that opens the heredoc stays,
366
+ // so its own redirects (`cat <<EOF > out.txt`) still count. An unterminated
367
+ // heredoc is kept as command text: failing open would hide real writes.
368
+ const HEREDOC_START = /(?<!<)<<(-?)\s*\\?(["']?)([A-Za-z_][A-Za-z0-9_]*)\2/g;
369
+ function withoutHeredocBodies(code: string): string {
370
+ const lines = code.split("\n");
371
+ const keep: string[] = [];
372
+ for (let i = 0; i < lines.length; i++) {
373
+ const line = lines[i] ?? "";
374
+ keep.push(line);
375
+ for (const m of line.matchAll(HEREDOC_START)) {
376
+ const word = m[3] ?? "";
377
+ const dash = m[1] === "-";
378
+ const end = lines.findIndex((l, j) => j > i && (dash ? l.replace(/^\t+/, "") : l) === word);
379
+ if (end > i) i = end;
380
+ }
381
+ }
382
+ return keep.join("\n");
383
+ }
384
+
363
385
  export function writeTargets(toolName: string, input: Record<string, unknown>, cwd: string): string[] {
364
386
  const out = new Set<string>();
365
387
  const add = (raw: string, from: string) => {
@@ -393,14 +415,18 @@ export function writeTargets(toolName: string, input: Record<string, unknown>, c
393
415
  const pkgOp = packageOpTarget(code);
394
416
  if (!MUTATING.test(code) && !pkgOp) return [];
395
417
  let dir = typeof input?.cwd === "string" ? path.resolve(cwd, expandHome(input.cwd)) : cwd;
396
- for (const seg of code.split(/&&|\|\||;|\n|\|/)) {
418
+ for (const seg of withoutHeredocBodies(code).split(/&&|\|\||;|\n|\|/)) {
397
419
  const s = seg.trim();
398
420
  const cd = s.match(/^cd\s+(\S+)/);
399
421
  if (cd) {
400
422
  dir = path.resolve(dir, expandHome((cd[1] ?? "").replace(/^["']|["']$/g, "")));
401
423
  continue;
402
424
  }
403
- for (const m of s.matchAll(/(?:^|[^0-9&>=\-])>{1,2}\s*([^\s&|;)<>]+)/g)) add(m[1] ?? "", dir);
425
+ for (const m of s.matchAll(/(?:^|[^0-9&>=\-])>{1,2}\s*([^\s&|;)<>]+)/g)) {
426
+ // A target with no letter, digit, `.` or `/` (`>,`) is prose, not a file.
427
+ const target = m[1] ?? "";
428
+ if (/[\p{L}\p{N}./]/u.test(target)) add(target, dir);
429
+ }
404
430
  const words = s.split(/\s+/).filter(Boolean);
405
431
  const cmd = words[0]?.replace(/^.*\//, "") ?? "";
406
432
  const args = words.slice(1).filter(w => !w.startsWith("-"));