passcontrol 1.2.0 → 1.2.1

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.
@@ -72,14 +72,16 @@ import {
72
72
  supportsWrite,
73
73
  } from "../cli/presets.mjs";
74
74
  import { importCompletionMessage, noAgentCreateMessage } from "../cli/workspace-import-report.mjs";
75
- import { checkForUpdate, fetchLatest, REGISTRY_URL } from "../cli/update-check.mjs";
75
+ import { announcesAfter, checkForUpdate, fetchLatest, REGISTRY_URL } from "../cli/update-check.mjs";
76
76
  import {
77
77
  clearMarker,
78
78
  detectInstall,
79
79
  dirtyBlockers,
80
80
  expectedProjectId,
81
+ finishLines,
81
82
  formatPlan,
82
83
  isPublicRepoUrl,
84
+ migrationBase,
83
85
  planUpdate,
84
86
  readMarker,
85
87
  stackFromConfig,
@@ -331,6 +333,9 @@ async function gatewayStatus(noNetwork = false, gateway = config.gateway) {
331
333
  return probeGatewayVersion(origin);
332
334
  }
333
335
 
336
+ // Wide enough for "System health:", the longest label status prints.
337
+ const STATUS_LABEL_WIDTH = 15;
338
+
334
339
  async function printCockpit({ noNetwork = false, json = false } = {}) {
335
340
  const gateway = await gatewayStatus(noNetwork);
336
341
  const local = managedDashboardTarget();
@@ -369,17 +374,17 @@ async function printCockpit({ noNetwork = false, json = false } = {}) {
369
374
  }
370
375
 
371
376
  console.log(`${heading("PassControl")}\n`);
372
- console.log(formatLabel("Gateway", `${gateway.label} ${config.gateway}`));
373
- console.log(formatLabel("Dashboard", `${dashboard} ${local.url}`));
374
- console.log(formatLabel("App", app));
375
- console.log(formatLabel("Config", configFile));
376
- console.log(formatLabel("Provider", config.provider));
377
- console.log(formatLabel("Model", config.model));
378
- console.log(formatLabel("Passport", passportConfigured ? redact(config.passportId) : "missing"));
379
- console.log(formatLabel("Key storage", passportStorage.message));
380
- console.log(formatLabel("Admin key", adminConfigured ? redact(config.apiKey, 6) : "missing"));
381
- console.log(formatLabel("System health", systemHealthLabel(systemHealth)));
382
- console.log(`${formatLabel("Sidecar", `foreground command (\`${cliCommand("sidecar")}\`)`)}\n`);
377
+ console.log(formatLabel("Gateway", `${gateway.label} ${config.gateway}`, STATUS_LABEL_WIDTH));
378
+ console.log(formatLabel("Dashboard", `${dashboard} ${local.url}`, STATUS_LABEL_WIDTH));
379
+ console.log(formatLabel("App", app, STATUS_LABEL_WIDTH));
380
+ console.log(formatLabel("Config", configFile, STATUS_LABEL_WIDTH));
381
+ console.log(formatLabel("Provider", config.provider, STATUS_LABEL_WIDTH));
382
+ console.log(formatLabel("Model", config.model, STATUS_LABEL_WIDTH));
383
+ console.log(formatLabel("Passport", passportConfigured ? redact(config.passportId) : "missing", STATUS_LABEL_WIDTH));
384
+ console.log(formatLabel("Key storage", passportStorage.message, STATUS_LABEL_WIDTH));
385
+ console.log(formatLabel("Admin key", adminConfigured ? redact(config.apiKey, 6) : "missing", STATUS_LABEL_WIDTH));
386
+ console.log(formatLabel("System health", systemHealthLabel(systemHealth), STATUS_LABEL_WIDTH));
387
+ console.log(`${formatLabel("Sidecar", `foreground command (\`${cliCommand("sidecar")}\`)`, STATUS_LABEL_WIDTH)}\n`);
383
388
  const next = [];
384
389
  if (config.sources.length === 0) {
385
390
  next.push(["init", "configure this project"]);
@@ -1719,7 +1724,19 @@ function analyzeAppForUpdate({ fetchRemote = true } = {}) {
1719
1724
  const behind = Number(gitIn(root, ["rev-list", "--count", "HEAD..origin/main"]));
1720
1725
  const base = { root, offset: stack.offset, head, target, resume, lockfileDirty: gitIn(root, ["status", "--porcelain", "--untracked-files=no", "--", "package-lock.json"]) !== "" };
1721
1726
  if (behind === 0) return { status: "current", ...base };
1722
- const migrations = gitIn(root, ["diff", "--name-only", "--diff-filter=A", head, target, "--", "db/migrations"]).split("\n").filter(Boolean);
1727
+ const since = migrationBase({
1728
+ head,
1729
+ resumeFrom: resume?.from,
1730
+ isAncestor: (rev) => {
1731
+ try {
1732
+ gitIn(root, ["merge-base", "--is-ancestor", rev, head]);
1733
+ return true;
1734
+ } catch {
1735
+ return false;
1736
+ }
1737
+ },
1738
+ });
1739
+ const migrations = gitIn(root, ["diff", "--name-only", "--diff-filter=A", since, target, "--", "db/migrations"]).split("\n").filter(Boolean);
1723
1740
  return { status: "behind", behind, from: head.slice(0, 7), to: target.slice(0, 7), migrations, ...base };
1724
1741
  }
1725
1742
 
@@ -1760,15 +1777,26 @@ async function applyAppUpdate(app) {
1760
1777
  // npm's own rewrite of the lockfile (see dirtyBlockers); \`npm ci\` below
1761
1778
  // installs exactly what the new lockfile says.
1762
1779
  if (app.lockfileDirty) gitIn(app.root, ["checkout", "--", "package-lock.json"]);
1763
- step(`Fast-forwarding ${app.from} → ${app.to}…`);
1764
- await runCommand("git", ["merge", "--ff-only", "origin/main"], { cwd: app.root });
1780
+ // One summary line, not git's per-file list (277 lines for 1.2.0).
1781
+ const changed = gitIn(app.root, ["diff", "--shortstat", "HEAD", "origin/main"]);
1782
+ step(`Fast-forwarding ${app.from} → ${app.to}${changed ? ` (${changed})` : ""}…`);
1783
+ await runCommand("git", ["merge", "--ff-only", "--quiet", "origin/main"], { cwd: app.root });
1765
1784
  }
1766
1785
  step("Installing dependencies (npm ci)…");
1767
- await runCommand(npm, ["ci"], { cwd: app.root });
1786
+ // Errors still print; deprecation warnings, funding and audit chatter do not.
1787
+ await runCommand(npm, ["ci", "--no-audit", "--no-fund", "--loglevel=error"], { cwd: app.root });
1768
1788
  step("Applying migrations and refreshing the local stack…");
1769
- await runCommand(npm, ["run", "dev:stack"], {
1789
+ await runCommand(npm, ["run", "--silent", "dev:stack"], {
1770
1790
  cwd: app.root,
1771
- env: { ...process.env, PASSCONTROL_PORT_OFFSET: String(app.offset), PASSCONTROL_SKIP_SEED: "1", PASSCONTROL_VIA_CLI: "1" },
1791
+ env: {
1792
+ ...process.env,
1793
+ PASSCONTROL_PORT_OFFSET: String(app.offset),
1794
+ PASSCONTROL_SKIP_SEED: "1",
1795
+ PASSCONTROL_VIA_CLI: "1",
1796
+ // dev-stack.sh keeps Supabase's banner (with its local keys) to a log it
1797
+ // prints only on failure, and lists only migrations it applies.
1798
+ PASSCONTROL_QUIET: "1",
1799
+ },
1772
1800
  });
1773
1801
  if (restart) await startDashboard({ dashboardOnly: true });
1774
1802
  } catch (error) {
@@ -1779,8 +1807,16 @@ async function applyAppUpdate(app) {
1779
1807
  );
1780
1808
  }
1781
1809
  clearMarker();
1782
- ok(`App updated to ${String(app.target).slice(0, 7)}.`);
1783
- step(`To roll back the code: git -C ${app.root} checkout ${from}. Database migrations only go forward.`);
1810
+ const closing = finishLines({
1811
+ target: app.target,
1812
+ root: app.root,
1813
+ restarted: restart,
1814
+ // The commit THIS run moved from. The marker's `from` can predate an
1815
+ // earlier, interrupted update; rolling back there skips a release.
1816
+ rollbackTo: app.status === "behind" ? app.head : null,
1817
+ startCommand: cliCommand("start"),
1818
+ });
1819
+ for (const [kind, text] of closing) (kind === "ok" ? ok : step)(text);
1784
1820
  }
1785
1821
 
1786
1822
  async function updateCommand(opts = {}) {
@@ -3795,7 +3831,7 @@ async function main(argv = process.argv.slice(2), runtime = {}) {
3795
3831
  // it can never turn a registry outage into a slow `passcontrol call`.
3796
3832
  // .catch() rather than try/catch: an unhandled rejection from a background
3797
3833
  // nicety must not take down a command that already did its job.
3798
- const updateNotice = runtime.skipUpdate ? Promise.resolve(null) : checkForUpdate({
3834
+ const updateNotice = runtime.skipUpdate || !announcesAfter(command) ? Promise.resolve(null) : checkForUpdate({
3799
3835
  current: CLI_VERSION,
3800
3836
  json: Boolean(opts.json),
3801
3837
  }).catch(() => null);
package/cli/config.mjs CHANGED
@@ -404,7 +404,8 @@ export const amber = (value) => paint(ANSI.yellow, value);
404
404
  export const alarm = (value) => paint(ANSI.red, value);
405
405
 
406
406
  export function formatLabel(label, value, width = 11) {
407
- return `${paint(ANSI.cyan, `${label}:`.padEnd(width))}${value}`;
407
+ // A label longer than the column still gets one space before its value.
408
+ return `${paint(ANSI.cyan, `${label}:`.padEnd(Math.max(width, label.length + 2)))}${value}`;
408
409
  }
409
410
 
410
411
  export function step(message = "") {
@@ -71,6 +71,14 @@ export function mayAnnounce({ isTty, json = false, env = process.env } = {}) {
71
71
  return true;
72
72
  }
73
73
 
74
+ /**
75
+ * Whether a command ends with the notice. Not `update`: it reports versions
76
+ * itself, and its notice was looked up before the update ran.
77
+ */
78
+ export function announcesAfter(command) {
79
+ return command !== "update";
80
+ }
81
+
74
82
  /** May we ask the registry again, or is the cached answer still fresh? */
75
83
  export function shouldFetch({ now = Date.now(), cache = null, ttlMs = CACHE_TTL_MS } = {}) {
76
84
  if (cache && typeof cache.checkedAt === "number" && now - cache.checkedAt < ttlMs) return false;
package/cli/update.mjs CHANGED
@@ -164,10 +164,13 @@ export function formatPlan(plan) {
164
164
  break;
165
165
  case "behind": {
166
166
  lines.push(`App: ${app.behind} new commit(s), ${app.from} → ${app.to}`);
167
+ if (app.resume?.from) {
168
+ lines.push(` an earlier update (from ${String(app.resume.from).slice(0, 7)}) did not finish; this one completes it`);
169
+ }
167
170
  const migrations = app.migrations ?? [];
168
171
  lines.push(
169
172
  migrations.length
170
- ? ` new database migrations (they only go forward): ${migrations.map((m) => path.basename(m)).join(", ")}`
173
+ ? ` database migrations to apply (they only go forward): ${migrations.map((m) => path.basename(m)).join(", ")}`
171
174
  : " no new database migrations"
172
175
  );
173
176
  lines.push(" steps: stop the dashboard, fast-forward, npm ci, apply migrations, start the dashboard again if it was running");
@@ -179,6 +182,32 @@ export function formatPlan(plan) {
179
182
  return lines;
180
183
  }
181
184
 
185
+ /**
186
+ * Where to count new migrations from. After an interrupted update the checkout
187
+ * is already at (or past) that update's target while its migrations never ran,
188
+ * so counting from HEAD names too few (found 2026-10-06: three named, eight
189
+ * applied). Count from where the interrupted update started, if this checkout
190
+ * still contains that commit.
191
+ */
192
+ export function migrationBase({ head, resumeFrom, isAncestor }) {
193
+ if (resumeFrom && isAncestor(resumeFrom)) return resumeFrom;
194
+ return head;
195
+ }
196
+
197
+ /**
198
+ * The closing lines of a finished app update, as [kind, text] pairs ("ok" or
199
+ * "step"). `rollbackTo` is the commit this run fast-forwarded from, or null when
200
+ * it only finished an earlier update and did not move the code.
201
+ */
202
+ export function finishLines({ target, root, restarted, rollbackTo, startCommand }) {
203
+ const lines = [["ok", `App updated to ${String(target).slice(0, 7)}.`]];
204
+ if (!restarted) lines.push(["step", `The dashboard is not running. Start it with \`${startCommand}\`.`]);
205
+ if (rollbackTo) {
206
+ lines.push(["step", `To roll back the code: git -C ${root} checkout ${rollbackTo}. Database migrations only go forward.`]);
207
+ }
208
+ return lines;
209
+ }
210
+
182
211
  // ── Resume marker ─────────────────────────────────────────────────────────────
183
212
  //
184
213
  // Written before the first change to the checkout and cleared on success. After
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "passcontrol",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Identity, scope and budget controls for AI agents while provider keys stay server-side.",
5
5
  "license": "BUSL-1.1",
6
6
  "homepage": "https://passcontrol.vertias.eu",