@nodii/dev 0.6.173 → 0.6.174

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.173";
7
+ export const VERSION = "0.6.174";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
package/dist/safety.js CHANGED
@@ -623,7 +623,7 @@ export function commandViolations(raw, context) {
623
623
  // cannot have its review checked, so it is refused, not judged as the hook's own (P-8).
624
624
  if (lane && gitCommands.some((x) => x.verb === "push") && pushTargets(command, context.cwd ?? context.root).includes(null))
625
625
  block("SAFETY_PUSH_TARGET_UNKNOWN", "Push blocked: the hook cannot tell which repository this push runs in. Push with a literal path: git -C <worktree> push, or cd <worktree> && git push.");
626
- if (lane && context.reviewFlowKnown && gitCommands.some((x) => x.verb === "push")) {
626
+ if (lane && context.reviewFlowKnown && context.reviewReceiptRequired !== false && gitCommands.some((x) => x.verb === "push")) {
627
627
  // Each push is judged against the repository it pushes (hub-266):
628
628
  // its own head, origin/main and review receipt, in its own worktree.
629
629
  const repos = context.pushRepos?.length ? context.pushRepos : [{ root: context.root, head: context.head, base: context.base, receipt: context.reviewReceipt }];
@@ -826,6 +826,14 @@ export async function safetyContext(cwd = process.cwd(), { request = devRequest,
826
826
  cwd: await realpath(cwd).catch(() => payloadCwd(cwd)), root, branch, head, base, role, lane, provenLane: Boolean(lane), reviewFlowKnown,
827
827
  // True when `lane` was read from Dev by key during this call (the Stop gate then reads nothing more).
828
828
  laneDetail,
829
+ // Resolve only for a push. Only an explicit disabled policy relaxes the receipt gate.
830
+ loadReviewReceiptRequired: async () => {
831
+ try {
832
+ const response = await request("GET", "/api/v1/rules/review/settings");
833
+ const settings = response?.data ?? response;
834
+ return settings?.gatesReceiptRequiredSince !== null;
835
+ } catch { return true; }
836
+ },
829
837
  ownedPaths: ownership.paths,
830
838
  ownershipKnown: role === "coordinator" || ownership.known,
831
839
  generatedPaths: [...await harnessGenerated(root), ...(state.generatedPaths ?? [])],
@@ -859,6 +867,8 @@ export async function safetyPreHook(payload, contextOrResolver = safetyContext,
859
867
  context.cwd = await realpath(cwd).catch(() => resolve(cwd));
860
868
  if (SHELL_TOOLS.has(tool)) {
861
869
  const command = String(payload.tool_input?.command ?? "");
870
+ if (provenLane(context) && pushTargets(command, context.cwd).length && typeof context.loadReviewReceiptRequired === "function")
871
+ context.reviewReceiptRequired = await context.loadReviewReceiptRequired();
862
872
  await expandLaneScope(command, context);
863
873
  // Read here, for this call, so it can only come from Dev. A failed read leaves null, which refuses.
864
874
  context.devBoundaries = provenLane(context) && createsAnyBranch(command) ? await devBoundaries(context.lane?.key, request) : null;
package/dist/surface.js CHANGED
@@ -3474,6 +3474,23 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
3474
3474
  const notYetRows = f.all && !f.fetch ? selected.filter((row) => !generated(row)) : [];
3475
3475
  const notYet = notYetRows.map((row) => row.id);
3476
3476
 
3477
+ // Preflight every target before fetching/saving trees or writing any page. Even an
3478
+ // invalid mark can contain a user's patch, so it must not be silently erased.
3479
+ if (f.write) {
3480
+ const protectedFiles = [];
3481
+ for (const row of targets) {
3482
+ const path = generatedPath(root, row);
3483
+ if (!existsSync(path)) continue;
3484
+ const marks = readFileSync(path, "utf8").split(/\r?\n/).flatMap((line, index) => {
3485
+ if (!/\/\*\s*@handrolled\b/.test(line)) return [];
3486
+ const key = /@handrolled\s+([A-Z][A-Z0-9]*(?:-[A-Z0-9]+)*-\d+)\s*:/.exec(line)?.[1];
3487
+ return [`${key ?? "missing issue key"} at line ${index + 1}`];
3488
+ });
3489
+ if (marks.length) protectedFiles.push(`${relative(root, path)}: ${marks.join(", ")}`);
3490
+ }
3491
+ if (protectedFiles.length) throw new CliError("SURFACE_HANDROLLED", `Refusing to overwrite handrolled Surfaces:\n${protectedFiles.join("\n")}\nGenerate without --write to inspect the replacement and resolve the marked patches explicitly.`, 1);
3492
+ }
3493
+
3477
3494
  let figmaGet = injected;
3478
3495
  const indexes = new Map();
3479
3496
  const trees = new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.173",
3
+ "version": "0.6.174",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {