notusci 0.1.3 → 0.1.5

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": "notusci",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "CI for coding agents: verify uncommitted changes with your GitHub Actions workflow and get typed JSON",
5
5
  "license": "MIT",
6
6
  "homepage": "https://ci.notusworks.com",
package/src/cli.mjs CHANGED
@@ -365,11 +365,15 @@ async function main(s, input) {
365
365
  return print({ status: "revoked", id: input.id });
366
366
  case "target set": {
367
367
  const repo = repoOrOrigin(input.repo);
368
- let config;
369
- try { config = JSON.parse(readFileSync(input.file, "utf8")); }
370
- catch { throw new CliError({ code: "usage", error: `${input.file} must be a readable JSON file`, next: "Fix --file and retry." }); }
371
- await api(s, `/api/repos/${repo}/target`, { method: "PUT", body: { config, digitaloceanToken: process.env.DIGITALOCEAN_TOKEN, autoPromote: input.autoPromote } });
372
- return print({ status: "saved", repo });
368
+ const { autoPromote, autoRelease } = input;
369
+ /** @type {Record<string, unknown>} */
370
+ let body = { autoPromote, autoRelease };
371
+ if (input.file) {
372
+ try { body = { ...body, config: JSON.parse(readFileSync(input.file, "utf8")), digitaloceanToken: process.env.DIGITALOCEAN_TOKEN }; }
373
+ catch { throw new CliError({ code: "usage", error: `${input.file} must be a readable JSON file`, next: "Fix --file and retry." }); }
374
+ }
375
+ const saved = await api(s, `/api/repos/${repo}/target`, { method: "PUT", body });
376
+ return print({ status: "saved", ...saved, ...(saved.autoRelease ? { note: "Every successful push to the default branch now ships itself; with autoPromote on, anyone who can push there deploys to production. Protect the branch." } : {}) });
373
377
  }
374
378
  case "verify": {
375
379
  const { root, repo } = gitRepo();
@@ -381,6 +385,16 @@ async function main(s, input) {
381
385
  const { shipId } = await api(s, "/api/ships", { method: "POST", body: { repo, pushRunId: input.runId } });
382
386
  return report(await waitUntilReady(s, `/api/ships/${shipId}/wait`, repo));
383
387
  }
388
+ case "repo set": {
389
+ const repo = repoOrOrigin(input.repo);
390
+ return print(await api(s, `/api/repos/${repo}/settings`, { method: "PUT", body: { pushWorkflow: input.pushWorkflow } }));
391
+ }
392
+ case "migrations list": return print(await api(s, `/api/repos/${repoOrOrigin(input.repo)}/migrations`));
393
+ case "migrations approve": {
394
+ const { manifestDigest, pushRunId, reason, forceDestructive } = input;
395
+ return print(await api(s, `/api/repos/${repoOrOrigin(input.repo)}/migrations/approvals`, { method: "POST",
396
+ body: { manifestDigest, pushRunId, reason, ...(forceDestructive ? { forceDestructive } : {}) } }));
397
+ }
384
398
  case "approve": {
385
399
  const repo = repoOrOrigin(input.repo);
386
400
  return print(await api(s, `/api/pull-requests/${input.runId}/approve`, { method: "POST", query: { repo } }));
package/src/core.mjs CHANGED
@@ -33,7 +33,7 @@ const OPTIONS = {
33
33
  init: { scope: { type: "string" }, "no-mcp": { type: "boolean" }, billing: { type: "boolean" } },
34
34
  login: { scope: { type: "string" } },
35
35
  doctor: {}, logout: {}, token: {}, whoami: {}, repos: {}, version: {}, "--version": {},
36
- target: { repo: { type: "string" }, file: { type: "string" }, "auto-promote": { type: "string" } },
36
+ target: { repo: { type: "string" }, file: { type: "string" }, "auto-promote": { type: "string" }, "auto-release": { type: "string" } },
37
37
  verify: { workflow: { type: "string" }, timeout: { type: "string" } },
38
38
  wait: { repo: { type: "string" }, timeout: { type: "string" } },
39
39
  failures: { repo: { type: "string" } },
@@ -41,6 +41,8 @@ const OPTIONS = {
41
41
  "rerun-failed": { timeout: { type: "string" } },
42
42
  ship: { repo: { type: "string" } },
43
43
  approve: { repo: { type: "string" } },
44
+ repo: { repo: { type: "string" }, "push-workflow": { type: "string" }, off: { type: "boolean" } },
45
+ migrations: { repo: { type: "string" }, push: { type: "string" }, reason: { type: "string" }, "force-destructive": { type: "boolean" } },
44
46
  billing: { repo: { type: "string" }, timeout: { type: "string" } },
45
47
  };
46
48
 
@@ -48,9 +50,10 @@ export const HELP = {
48
50
  commands: [
49
51
  "init [--scope SCOPES] [--no-mcp] [--billing]", "billing [--repo OWNER/REPO] [--timeout SECONDS]", "doctor",
50
52
  "login [--scope SCOPES]", "logout", "whoami", "repos", "token list", "token revoke ID",
51
- "target set [--repo OWNER/REPO] --file TARGET.json [--auto-promote on|off]", "verify [--workflow PATH] [--timeout SECONDS]",
53
+ "target set [--repo OWNER/REPO] [--file TARGET.json] [--auto-promote on|off] [--auto-release on|off]", "verify [--workflow PATH] [--timeout SECONDS]",
52
54
  "wait ID [--repo OWNER/REPO] [--timeout SECONDS]", "failures ID [--repo OWNER/REPO]", "ship ID [--repo OWNER/REPO]",
53
- "approve ID [--repo OWNER/REPO]",
55
+ "approve ID [--repo OWNER/REPO]", "repo set [--repo OWNER/REPO] --push-workflow PATH|--off",
56
+ "migrations list [--repo OWNER/REPO]", "migrations approve MANIFEST_DIGEST --push ID --reason TEXT [--repo OWNER/REPO] [--force-destructive]",
54
57
  "search-logs ID --query LITERAL [--limit COUNT] [--repo OWNER/REPO]",
55
58
  "rerun-failed ID [--timeout SECONDS]", "--version",
56
59
  ],
@@ -97,10 +100,29 @@ export function parseCommand(args) {
97
100
  }
98
101
  if (command === "target") {
99
102
  expect("set");
100
- if (!values.file) throw usage("--file is required");
101
- const auto = values["auto-promote"];
102
- if (auto !== undefined && auto !== "on" && auto !== "off") throw usage("--auto-promote must be on or off");
103
- return { command: "target set", repo: values.repo, file: values.file, autoPromote: auto === undefined ? undefined : auto === "on" };
103
+ /** @param {string} name */
104
+ const flag = name => {
105
+ const value = values[name];
106
+ if (value !== undefined && value !== "on" && value !== "off") throw usage(`--${name} must be on or off`);
107
+ return value === undefined ? undefined : value === "on";
108
+ };
109
+ const autoPromote = flag("auto-promote"); const autoRelease = flag("auto-release");
110
+ if (!values.file && autoPromote === undefined && autoRelease === undefined) throw usage("target set needs --file, --auto-promote or --auto-release");
111
+ return { command: "target set", repo: values.repo, file: values.file, autoPromote, autoRelease };
112
+ }
113
+ if (command === "repo") {
114
+ expect("set");
115
+ if ((values["push-workflow"] === undefined) === (values.off !== true)) throw usage("repo set needs exactly one of --push-workflow PATH or --off");
116
+ return { command: "repo set", repo: values.repo, pushWorkflow: values.off ? null : values["push-workflow"] };
117
+ }
118
+ if (command === "migrations") {
119
+ if (positionals[0] === "list") { expect("list"); return { command: "migrations list", repo: values.repo }; }
120
+ expect("approve", "*");
121
+ if (!/^[0-9a-f]{64}$/.test(positionals[1]) || !isPushRunId(values.push?.toLowerCase() ?? "") || !values.reason?.trim()) {
122
+ throw usage("migrations approve needs a 64-hex manifest digest, --push PUSH_UUID and --reason TEXT");
123
+ }
124
+ return { command: "migrations approve", repo: values.repo, manifestDigest: positionals[1], pushRunId: values.push.toLowerCase(),
125
+ reason: values.reason, forceDestructive: values["force-destructive"] === true };
104
126
  }
105
127
  if (command === "verify") {
106
128
  expect();