@nodii/dev 0.6.59 → 0.6.60

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/dist/core.js CHANGED
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
4
4
  import { homedir, platform } from "node:os";
5
5
  import { dirname, join } from "node:path";
6
6
 
7
- export const VERSION = "0.6.59";
7
+ export const VERSION = "0.6.60";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
package/dist/lanes.js CHANGED
@@ -9,7 +9,7 @@ import { storeGatherFreeze } from "./freeze.js";
9
9
  import { doneCheckRecorded } from "./lane-supervisor.js";
10
10
  import { SWAP_BOUNDARIES, componentsForScope, guidelineLookup, laneFigmaScope, loadDsCatalog } from "./figma-scope.js";
11
11
  import { designCheck } from "./design.js";
12
- import { REVIEW_FILE, checkLines, checkReviewChecks, diffDigest, laneDiff, privateStore, runLaneCheck, runOutcome, worktreeCommitted } from "./review.js";
12
+ import { REVIEW_FILE, checkLines, checkReviewChecks, diffDigest, laneDiff, privateStore, repoGeneratedPaths, runLaneCheck, runOutcome, worktreeCommitted } from "./review.js";
13
13
 
14
14
  const execFileAsync = promisify(execFile);
15
15
  const via = { via: "nodii-dev" };
@@ -574,9 +574,12 @@ export async function laneCommand(action, args, flags, deps = {}) {
574
574
  throw new CliError("LANE_WORKTREE_REQUIRED", `Run lane check from one of ${ref}'s worktrees (${worktrees.join(", ") || "none recorded"}: registered, or named in its Freeze boundaries.repos); this is ${context.worktree}.`, 2);
575
575
  const current = { ...(await reviewContext()), branch: context.branch };
576
576
  const store = checkDeps.store ?? privateStore(context.worktree);
577
+ // A-037: the reviewer reads source; Dev names this repo's generated paths.
578
+ const generatedPaths = await repoGeneratedPaths(request, context.repo);
579
+ const diff = (cwd) => (checkDeps.diff ?? laneDiff)(cwd, { generatedPaths });
577
580
  const run = await runLaneCheck(ref, flags, {
578
581
  request, lane, freeze, current, cwd: context.worktree, store,
579
- diff: checkDeps.diff ?? laneDiff,
582
+ diff,
580
583
  deltaGather: checkDeps.deltaGather ?? ((key, paths) => laneCommand("gather", [key], { delta: true, paths: paths.join(",") }, deps)),
581
584
  catalog: checkDeps.catalog ?? catalog,
582
585
  designCheck: checkDeps.designCheck ?? designCheck,
@@ -598,7 +601,7 @@ export async function laneCommand(action, args, flags, deps = {}) {
598
601
  // Dev binds a run to base and head only, so the reviewed content must be that
599
602
  // commit, unchanged since the reviewers read it.
600
603
  const committed = await (checkDeps.committed ?? worktreeCommitted)(context.worktree);
601
- if (!committed || diffDigest((await (checkDeps.diff ?? laneDiff)(context.worktree)).text) !== run.digest)
604
+ if (!committed || diffDigest((await diff(context.worktree)).text) !== run.digest)
602
605
  throw new CliError("REVIEW_WORKTREE_DIRTY", `${[...lines, `run: nothing recorded. ${committed ? "The worktree changed while the reviewers ran" : "The reviewed diff has uncommitted or untracked changes"}, and Dev records a review for commit ${run.body.head} only. Commit them (or drop them) and rerun nodii-dev lane check ${ref}; this round does not count.`].join("\n")}`, 1);
603
606
  const file = await store.write(REVIEW_FILE, run.body);
604
607
  const payload = await recordReview(flags, run.body);
package/dist/review.js CHANGED
@@ -99,21 +99,53 @@ export async function gatesReceipt(commands, { cwd, current, store, diff, run =
99
99
  return changed;
100
100
  }
101
101
 
102
- /** DEV-REV-6: the worktree against its origin/main merge base, tracked and untracked. */
103
- export async function laneDiff(cwd, { exec = execFileAsync } = {}) {
102
+ /**
103
+ * A-037: the repo's generated-artifact prefixes, as Dev serves them on its
104
+ * harness definition (`generatedPaths`, NODII-DEV-CLI-23). Dev is the only
105
+ * source (DEV-OV-1), so a lane cannot widen the list from its own diff. No
106
+ * list, nothing excluded.
107
+ */
108
+ export async function repoGeneratedPaths(request, repo) {
109
+ const get = (drafts) => request("GET", `/api/v1/harness?repo=${encodeURIComponent(repo.toLowerCase())}${drafts ? "&includeDrafts=true" : ""}`);
110
+ // The same draft fallback as harness install: the list is per repo, not per methodology.
111
+ const harness = (await get(false).catch((error) => { if (error?.code === "METHODOLOGY_NOT_AVAILABLE") return get(true); throw error; })).data;
112
+ return (Array.isArray(harness?.generatedPaths) ? harness.generatedPaths : []).filter((path) => typeof path === "string" && path.trim());
113
+ }
114
+
115
+ /** One exclude pathspec per prefix, never per file, so a big regeneration cannot hit E2BIG. */
116
+ export const generatedPathspecs = (prefixes) => prefixes.map((prefix) => `:(exclude,glob)${prefix}**`);
117
+
118
+ /**
119
+ * DEV-REV-6: the worktree against its origin/main merge base, tracked and
120
+ * untracked. `text` is every change (the receipt and the digest cover it);
121
+ * `reviewText` leaves out the generated paths (A-037), which `paths` and
122
+ * `generated` still name. One set of pathspecs decides both, so the list and
123
+ * the diff the reviewer reads never disagree.
124
+ */
125
+ export async function laneDiff(cwd, { exec = execFileAsync, generatedPaths = [] } = {}) {
104
126
  const git = async (...args) => (await exec("git", ["-C", cwd, ...args], { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 })).stdout;
105
127
  const mergeBase = (await git("merge-base", "origin/main", "HEAD")).trim();
128
+ const changedNames = async (...specs) => (await git("diff", "--name-only", mergeBase, ...(specs.length ? ["--", ".", ...specs] : []))).split("\n").map((x) => x.trim()).filter(Boolean);
129
+ const untrackedNames = async (...specs) => (await git("ls-files", "--others", "--exclude-standard", "-z", ...(specs.length ? ["--", ".", ...specs] : []))).split("\0").filter(Boolean);
130
+ const specs = generatedPathspecs(generatedPaths);
106
131
  const tracked = await git("diff", "--no-color", "--no-ext-diff", mergeBase);
107
- const names = (await git("diff", "--name-only", mergeBase)).split("\n");
108
- const untracked = (await git("ls-files", "--others", "--exclude-standard", "-z")).split("\0").filter(Boolean);
132
+ const names = await changedNames();
133
+ const untracked = await untrackedNames();
134
+ const kept = new Set(specs.length ? [...await changedNames(...specs), ...await untrackedNames(...specs)] : [...names, ...untracked]);
135
+ const paths = [...new Set([...names, ...untracked])];
136
+ const generated = paths.filter((path) => !kept.has(path));
109
137
  const added = [];
138
+ const reviewAdded = [];
110
139
  for (const path of untracked) {
140
+ let chunk;
111
141
  // --no-index exits 1 when the files differ, which they always do here.
112
- try { added.push(await git("diff", "--no-color", "--no-ext-diff", "--no-index", "--", "/dev/null", path)); }
113
- catch (error) { if (error.code === 1 && typeof error.stdout === "string") added.push(error.stdout); else throw error; }
142
+ try { chunk = await git("diff", "--no-color", "--no-ext-diff", "--no-index", "--", "/dev/null", path); }
143
+ catch (error) { if (error.code === 1 && typeof error.stdout === "string") chunk = error.stdout; else throw error; }
144
+ added.push(chunk);
145
+ if (kept.has(path)) reviewAdded.push(chunk);
114
146
  }
115
- const paths = [...new Set([...names, ...untracked].map((x) => x.trim()).filter(Boolean))];
116
- return { mergeBase, text: tracked + added.join(""), paths };
147
+ const reviewTracked = names.some((path) => !kept.has(path)) ? await git("diff", "--no-color", "--no-ext-diff", mergeBase, "--", ".", ...specs) : tracked;
148
+ return { mergeBase, text: tracked + added.join(""), reviewText: reviewTracked + reviewAdded.join(""), paths, generated };
117
149
  }
118
150
 
119
151
  /** True when the worktree is its commit: no uncommitted or untracked (not ignored) change. */
@@ -147,7 +179,7 @@ const clauseText = (clauses) => clauses.map((clause) => [
147
179
  ].join("\n")).join("\n\n");
148
180
 
149
181
  /** The reviewer's whole input: instructions, the clauses, the diff. */
150
- export function reviewerPrompt(check, { diff, clauses = [] }) {
182
+ export function reviewerPrompt(check, { diff, clauses = [], generated = [] }) {
151
183
  const ask = check === "rules"
152
184
  ? [
153
185
  "You are the rules check of a lane review (DEV-REV). You have no tools: judge only the diff and the clauses below.",
@@ -169,6 +201,7 @@ export function reviewerPrompt(check, { diff, clauses = [] }) {
169
201
  "```diff",
170
202
  diff,
171
203
  "```",
204
+ ...(generated.length ? ["", `## Generated files changed, left out of the diff (A-037: built from source, not reviewed by reading) (${generated.length})`, ...generated] : []),
172
205
  ].join("\n");
173
206
  }
174
207
 
@@ -398,8 +431,12 @@ export async function runLaneCheck(ref, flags, { request, lane, freeze, current,
398
431
  if (!changed.text.trim()) throw new CliError("LANE_DIFF_EMPTY", `${ref}: this worktree has no change against origin/main, so there is nothing to review.`, 1);
399
432
  const runtime = lane.launch?.runtime === "codex" ? "codex" : "claude";
400
433
  const runner = { runtime, model: lane.launch?.model, profile: lane.launch?.profile };
401
- const tooLarge = changed.text.length > MAX_DIFF_CHARS
402
- ? new ReviewerError(UNAVAILABLE, `the diff is ${changed.text.length} characters; a reviewer takes at most ${MAX_DIFF_CHARS}. Split the lane.`)
434
+ // A-037: the reviewer reads source, not the generated artifacts built from it.
435
+ const reviewed = changed.reviewText ?? changed.text;
436
+ const generated = changed.generated ?? [];
437
+ const excluded = generated.length ? { generatedPaths: generated.length } : {};
438
+ const tooLarge = reviewed.length > MAX_DIFF_CHARS
439
+ ? new ReviewerError(UNAVAILABLE, `the diff is ${reviewed.length} characters${generated.length ? ` without its ${generated.length} generated file(s)` : ""}; a reviewer takes at most ${MAX_DIFF_CHARS}. Split the lane.`)
403
440
  : null;
404
441
  const loop = (await store.read(REVIEW_LOOP)) ?? {};
405
442
  const laneLoop = loop[ref]?.branch === current.branch ? loop[ref].checks ?? {} : {};
@@ -422,9 +459,9 @@ export async function runLaneCheck(ref, flags, { request, lane, freeze, current,
422
459
  rules = errorCheck("rules", error, firstRound("rules"), { clauseIds: [], deltaGatherId: null, clauseMapGatherId: freeze?.clauseMap?.gatherId ?? null });
423
460
  }
424
461
  if (!rules) {
425
- const inputs = { clauseIds: gathered.clauseIds, clauseMapGatherId: gathered.clauseMapGatherId, deltaGatherId: gathered.deltaGatherId, runtime, diffDigest: diffDigest(changed.text) };
462
+ const inputs = { clauseIds: gathered.clauseIds, clauseMapGatherId: gathered.clauseMapGatherId, deltaGatherId: gathered.deltaGatherId, runtime, diffDigest: diffDigest(changed.text), ...excluded };
426
463
  try {
427
- const findings = await reviewer("rules", { ...runner, prompt: reviewerPrompt("rules", { diff: changed.text, clauses: gathered.clauses }), clauseIds: gathered.clauseIds });
464
+ const findings = await reviewer("rules", { ...runner, prompt: reviewerPrompt("rules", { diff: reviewed, clauses: gathered.clauses, generated }), clauseIds: gathered.clauseIds });
428
465
  rules = round("rules", findings, inputs);
429
466
  } catch (error) {
430
467
  if (!(error instanceof ReviewerError)) throw error;
@@ -460,10 +497,10 @@ export async function runLaneCheck(ref, flags, { request, lane, freeze, current,
460
497
  let code;
461
498
  if (!critical) code = { check: "code", outcome: "NOT_REQUIRED", iterationCount: 0, reviewerErrors: [], inputs: { critical: false }, notRequired: CODE_NOT_REQUIRED, findings: [] };
462
499
  else {
463
- const inputs = { critical: true, clauseIds: gathered?.clauseIds ?? [], runtime, diffDigest: diffDigest(changed.text) };
500
+ const inputs = { critical: true, clauseIds: gathered?.clauseIds ?? [], runtime, diffDigest: diffDigest(changed.text), ...excluded };
464
501
  try {
465
502
  if (tooLarge) throw tooLarge;
466
- const findings = await reviewer("code", { ...runner, prompt: reviewerPrompt("code", { diff: changed.text, clauses: gathered?.clauses ?? [] }) });
503
+ const findings = await reviewer("code", { ...runner, prompt: reviewerPrompt("code", { diff: reviewed, clauses: gathered?.clauses ?? [], generated }) });
467
504
  code = round("code", findings, inputs);
468
505
  } catch (error) {
469
506
  if (!(error instanceof ReviewerError)) throw error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.59",
3
+ "version": "0.6.60",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {