@nodii/dev 0.6.90 → 0.6.91

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/cli.js CHANGED
@@ -384,7 +384,7 @@ Usage: nodii-dev <command> [options] [--json]
384
384
  lane freeze drop <key> --section SECTION --item ID --reason TEXT
385
385
  lane freeze swap <key> --section SECTION [--item ID] --file VALUE.json --reason TEXT
386
386
  lane freeze show|history <key> # durable compact-safe contract and all versions
387
- lane stop <key> [<key> ...] --reason TEXT [--sweeper LANE] [--no-closeout]
387
+ lane stop <key> [<key> ...] --reason TEXT [--sweeper LANE] [--no-closeout] [--no-closeout-push]
388
388
  # hub-268: several keys stop one after another in one process, so the
389
389
  # operator's one TOTP code covers them all; a lane that fails is reported
390
390
  # and the rest still stop (LANE_STOP_INCOMPLETE names each failure)
package/dist/closeout.js CHANGED
@@ -114,7 +114,7 @@ async function closeStoppedPr({ lane, repository, reason, issueKeys, gh }) {
114
114
  * Close out one repository of a stopped lane. Returns what happened at each
115
115
  * step; never throws for a step's failure.
116
116
  */
117
- export async function closeoutRepository(lane, repository, { reason, issueKeys = [], exec = defaultExec, cwd = process.cwd() } = {}) {
117
+ export async function closeoutRepository(lane, repository, { reason, issueKeys = [], exec = defaultExec, cwd = process.cwd(), push = true, progress = () => {} } = {}) {
118
118
  const { worktree, branch } = repository;
119
119
  const out = { repo: repository.repo, branch, worktree, pushed: null, pr: null, stacks: [], worktreeRemoved: false, notes: [] };
120
120
  if (!worktree || !existsSync(worktree)) {
@@ -124,6 +124,7 @@ export async function closeoutRepository(lane, repository, { reason, issueKeys =
124
124
  const git = (...args) => exec("git", ["-C", worktree, ...args]);
125
125
  const gh = (...args) => exec("gh", args, { cwd: worktree });
126
126
  const base = repository.baseRef ?? "origin/main";
127
+ const say = (text) => progress(`${lane.key} ${repository.repo ?? worktree}: ${text}`);
127
128
  let pushedOk = false;
128
129
  // A read-only repository (hub-257) holds no work of the lane's:
129
130
  // nothing to push and no PR to record.
@@ -140,23 +141,37 @@ export async function closeoutRepository(lane, repository, { reason, issueKeys =
140
141
  if (landed) {
141
142
  out.pushed = { ahead, head, needed: false };
142
143
  pushedOk = true;
144
+ } else if (!push) {
145
+ out.pushed = { ahead, head, needed: true, skipped: true };
146
+ say(`${ahead} leftover commit(s) stay on local branch ${branch} in ${worktree}`);
147
+ out.notes.push(`--no-closeout-push: ${ahead} commit(s) stay on local branch ${branch} in ${worktree}; nodii-dev lane closeout ${lane.key} --reason TEXT pushes them`);
143
148
  } else {
149
+ // The repository's own pre-push hook runs here, and on a large repository it takes minutes.
150
+ say(`pushing ${ahead} leftover commit(s) to ${branch}, through the repository's pre-push hook; this can take minutes`);
144
151
  await git("push", "--quiet", "-u", "origin", `HEAD:refs/heads/${branch}`);
145
152
  const remote = (await git("ls-remote", "origin", `refs/heads/${branch}`)).trim().split(/\s+/)[0] ?? "";
146
153
  pushedOk = remote === head;
147
154
  out.pushed = { ahead, head, remote, needed: true, readBack: pushedOk };
155
+ say(pushedOk ? "push confirmed" : "push not confirmed");
148
156
  if (!pushedOk) out.notes.push(`push read-back failed: remote ${branch} is ${remote || "missing"}, HEAD is ${head}`);
149
157
  }
150
158
  } catch (error) {
151
159
  out.notes.push(`push failed: ${String(error?.stderr || error?.message || error).trim().slice(0, 300)}`);
160
+ say("push failed");
152
161
  }
162
+ const skipped = Boolean(out.pushed?.skipped);
153
163
  // An open PR is closed as Stopped even when nothing new needed a push.
154
- if (pushedOk && !repository.readOnly) {
164
+ if ((pushedOk || skipped) && !repository.readOnly) {
155
165
  try {
156
- if (out.pushed.needed) out.pr = await closeStoppedPr({ lane, repository, reason, issueKeys, gh });
157
- else {
166
+ if (out.pushed.needed && !skipped) {
167
+ say("closing the PR");
168
+ out.pr = await closeStoppedPr({ lane, repository, reason, issueKeys, gh });
169
+ } else {
158
170
  const open = JSON.parse((await gh("pr", "list", "--head", branch, "--state", "open", "--json", "number,url")) || "[]");
159
- if (open.length) out.pr = await closeStoppedPr({ lane, repository, reason, issueKeys, gh });
171
+ if (open.length) {
172
+ say("closing the PR");
173
+ out.pr = await closeStoppedPr({ lane, repository, reason, issueKeys, gh });
174
+ }
160
175
  }
161
176
  } catch (error) {
162
177
  out.notes.push(`PR close-out failed: ${String(error?.stderr || error?.message || error).trim().slice(0, 300)}`);
@@ -172,6 +187,10 @@ export async function closeoutRepository(lane, repository, { reason, issueKeys =
172
187
  out.stacks.push({ project, down: false, error: String(error?.stderr || error?.message || error).trim().slice(0, 200) });
173
188
  }
174
189
  }
190
+ if (skipped) {
191
+ out.notes.push("worktree kept: it holds the unpushed commits");
192
+ return out;
193
+ }
175
194
  if (!pushedOk) {
176
195
  out.notes.push("worktree kept: the push did not succeed");
177
196
  return out;
@@ -202,7 +221,8 @@ export function describeCloseout(lane, repositories) {
202
221
  const lines = [`Lane ${lane.key} close-out on this machine:`];
203
222
  for (const r of repositories) {
204
223
  const parts = [];
205
- if (r.pushed?.needed) parts.push(r.pushed.readBack ? `pushed ${r.pushed.ahead} commit(s) to ${r.branch}` : "push not confirmed");
224
+ if (r.pushed?.skipped) parts.push(`${r.pushed.ahead} commit(s) left unpushed on ${r.branch}`);
225
+ else if (r.pushed?.needed) parts.push(r.pushed.readBack ? `pushed ${r.pushed.ahead} commit(s) to ${r.branch}` : "push not confirmed");
206
226
  else if (r.pushed) parts.push("nothing unlanded to push");
207
227
  if (r.pr) parts.push(`PR ${r.pr.url} ${r.pr.opened ? "opened and " : ""}closed${r.pr.labelled ? ` with the ${STOPPED_LABEL} label` : ` (the ${STOPPED_LABEL} label did not stick)`}`);
208
228
  for (const s of r.stacks) parts.push(s.down ? `test stack ${s.project} taken down` : `test stack ${s.project} NOT taken down (${s.error})`);
@@ -218,11 +238,11 @@ export function describeCloseout(lane, repositories) {
218
238
  * Orphan): Dev's refusal of the stop comes first, so nothing local runs for a
219
239
  * stop Dev did not allow.
220
240
  */
221
- export async function closeoutLane(lane, { reason, request, onBehalfOf, exec = defaultExec, cwd = process.cwd() } = {}) {
241
+ export async function closeoutLane(lane, { reason, request, onBehalfOf, exec = defaultExec, cwd = process.cwd(), push = true, progress = () => {} } = {}) {
222
242
  const issueKeys = (lane?.issues ?? []).map((issue) => issue.key).filter(Boolean);
223
243
  const repositories = [];
224
244
  for (const repository of laneRepositories(lane))
225
- repositories.push(await closeoutRepository(lane, repository, { reason, issueKeys, exec, cwd }));
245
+ repositories.push(await closeoutRepository(lane, repository, { reason, issueKeys, exec, cwd, push, progress }));
226
246
  const text = describeCloseout(lane, repositories);
227
247
  const recorded = [];
228
248
  if (request && repositories.length)
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.90";
7
+ export const VERSION = "0.6.91";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
package/dist/flags.js CHANGED
@@ -41,7 +41,7 @@ export const COMMAND_FLAGS = {
41
41
  "lane waits": ["machine"],
42
42
  "lane resume": ["override", "reason", "host-lost", "min-free-gb", "stagger-seconds", "profile", "class"],
43
43
  "lane transfer": ["reason", "to-agent"],
44
- "lane stop": ["reason", "sweeper", "no-closeout"],
44
+ "lane stop": ["reason", "sweeper", "no-closeout", "no-closeout-push"],
45
45
  "lane closeout": ["reason"],
46
46
  "lane repo": ["repo", "branch", "worktree", "read-only", "reason"],
47
47
  // hub-232: the honest close-out and the governor.
package/dist/lanes.js CHANGED
@@ -1090,7 +1090,10 @@ export async function laneCommand(action, args, flags, deps = {}) {
1090
1090
  const reason = requireFlag(flags, "reason");
1091
1091
  // Dev first: a stop it refuses changes nothing on this machine (hub-244).
1092
1092
  const payload = await request("POST", `/api/v1/lanes/${encode(id)}/stop`, { reason, ...(flags.sweeper ? { sweeper: String(flags.sweeper) } : {}), ...via });
1093
- const closeout = flags["no-closeout"] ? null : await laneCloseout(ref, reason, { request, config, closeout: deps.closeout });
1093
+ const closing = !flags["no-closeout"];
1094
+ // Printed before the close-out starts: the stop is recorded, and what follows only tidies this machine.
1095
+ if (closing) stopProgress(deps)(`${ref}: stopped. Closing out on this machine; the stop stands whatever happens next.`);
1096
+ const closeout = closing ? await laneCloseout(ref, reason, { request, config, closeout: deps.closeout, ...closeoutOptions(flags, deps) }) : null;
1094
1097
  return {
1095
1098
  payload: { ...payload, ...(closeout ? { closeout: closeout.repositories } : {}) },
1096
1099
  human: [`${ref}: stopped.`, holdsLine(payload?.holdsReleased), closeout?.text].filter(Boolean).join("\n"),
@@ -1202,11 +1205,11 @@ export function holdsLine(released) {
1202
1205
  * The machine half of a lane's end (closeout.js): push, Stopped PR, test
1203
1206
  * stacks, worktree. Runs only after Dev accepted the end.
1204
1207
  */
1205
- export async function laneCloseout(ref, reason, { request = devRequest, config = readConfig, closeout = closeoutLane, lane } = {}) {
1208
+ export async function laneCloseout(ref, reason, { request = devRequest, config = readConfig, closeout = closeoutLane, lane, push = true, progress } = {}) {
1206
1209
  const record = lane ?? (await request("GET", `/api/v1/lanes/${encode(ref)}`)).data;
1207
1210
  let onBehalfOf;
1208
1211
  try { onBehalfOf = (await config())?.person; } catch { onBehalfOf = undefined; }
1209
- return closeout(record, { reason, request, onBehalfOf });
1212
+ return closeout(record, { reason, request, onBehalfOf, push, ...(progress ? { progress } : {}) });
1210
1213
  }
1211
1214
 
1212
1215
  /**
@@ -1383,6 +1386,9 @@ const STOP_RUN_ENDING = /^(OPERATOR_STEP_UP_|OPERATOR_REQUIRED$|STAFF_OPERATOR_R
1383
1386
  // "not stopped".
1384
1387
  const STOP_UNCONFIRMED = /^(DEV_TIMEOUT|DEV_UNREACHABLE|HTTP_5\d\d)$/;
1385
1388
 
1389
+ const stopProgress = (deps) => deps.progress ?? ((line) => process.stderr.write(`${line}\n`));
1390
+ const closeoutOptions = (flags, deps) => ({ push: !flags["no-closeout-push"], progress: stopProgress(deps) });
1391
+
1386
1392
  async function stopLanes(keys, flags, deps) {
1387
1393
  const { request = devRequest, config = readConfig } = deps;
1388
1394
  const stopped = [];
@@ -1414,8 +1420,9 @@ async function stopLanes(keys, flags, deps) {
1414
1420
  const entry = { key, payload: result.payload, human: result.human };
1415
1421
  stopped.push(entry);
1416
1422
  if (flags["no-closeout"]) continue;
1423
+ stopProgress(deps)(`${key}: stopped. Closing out on this machine; the stop stands whatever happens next.`);
1417
1424
  try {
1418
- const closeout = await laneCloseout(key, flags.reason, { request, config, closeout: deps.closeout });
1425
+ const closeout = await laneCloseout(key, flags.reason, { request, config, closeout: deps.closeout, ...closeoutOptions(flags, deps) });
1419
1426
  entry.payload = { ...entry.payload, closeout: closeout.repositories };
1420
1427
  entry.human = [entry.human, closeout.text].filter(Boolean).join("\n");
1421
1428
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.90",
3
+ "version": "0.6.91",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {