notusci 0.1.0 → 0.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notusci",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
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
@@ -7,7 +7,7 @@ import { homedir, hostname } from "node:os";
7
7
  import { delimiter, dirname, join } from "node:path";
8
8
  import { setTimeout as sleep } from "node:timers/promises";
9
9
  import {
10
- CliError, NPX, boundedWaitSeconds, buildSource, encodeSource, parseCommand, pickWorkflow, renderError,
10
+ CliError, HELP, NPX, boundedWaitSeconds, buildSource, encodeSource, parseCommand, pickWorkflow, renderError,
11
11
  repositoryFromRemote, runPath, setCodexServer, setCursorServer, shouldWaitAgain,
12
12
  } from "./core.mjs";
13
13
 
@@ -38,7 +38,9 @@ function session() {
38
38
  if (url.protocol !== "https:" && !(url.protocol === "http:" && LOCAL_HOSTS.includes(url.hostname))) {
39
39
  throw new CliError({ code: "usage", error: "NOTUSCI_URL must use https (http only for localhost)", next: "Fix NOTUSCI_URL and retry." });
40
40
  }
41
- return { url: url.href.replace(/\/$/, ""), token: process.env.NOTUSCI_TOKEN ?? state.token, state };
41
+ const base = url.href.replace(/\/$/, "");
42
+ // A saved token goes only to the server that issued it.
43
+ return { url: base, token: process.env.NOTUSCI_TOKEN ?? ((state.url ?? DEFAULT_URL) === base ? state.token : undefined), state };
42
44
  }
43
45
 
44
46
  /** Save the token and pending login; a URL from NOTUSCI_URL is not persisted. @param {Session} s @param {{token?: string, pending?: any}} state */
@@ -299,7 +301,7 @@ async function main(s, input) {
299
301
  let config;
300
302
  try { config = JSON.parse(readFileSync(input.file, "utf8")); }
301
303
  catch { throw new CliError({ code: "usage", error: `${input.file} must be a readable JSON file`, next: "Fix --file and retry." }); }
302
- await api(s, `/api/repos/${repo}/target`, { method: "PUT", body: { config, digitaloceanToken: process.env.DIGITALOCEAN_TOKEN } });
304
+ await api(s, `/api/repos/${repo}/target`, { method: "PUT", body: { config, digitaloceanToken: process.env.DIGITALOCEAN_TOKEN, autoPromote: input.autoPromote } });
303
305
  return print({ status: "saved", repo });
304
306
  }
305
307
  case "verify": {
@@ -324,7 +326,11 @@ async function main(s, input) {
324
326
  }
325
327
  }
326
328
 
327
- try { await main(session(), parseCommand(process.argv.slice(2))); }
329
+ try {
330
+ const input = parseCommand(process.argv.slice(2));
331
+ if (input.command === "help") print(HELP);
332
+ else await main(session(), input);
333
+ }
328
334
  catch (error) {
329
335
  const body = error instanceof CliError ? error.body : { code: "error", error: error instanceof Error ? error.message : String(error) };
330
336
  process.stderr.write(`${JSON.stringify(renderError(body))}\n`);
package/src/core.mjs CHANGED
@@ -11,7 +11,7 @@ const MAX_PATHS = 20_000;
11
11
  const MAX_PATH_BYTES = 1_024;
12
12
  export const NPX = "npx -y notusci@latest";
13
13
  const SCOPES = ["read", "verify", "ship:staging", "ship:prod"];
14
- const DEFAULT_SCOPES = "read,verify,ship:staging";
14
+ const DEFAULT_SCOPES = SCOPES.join(",");
15
15
 
16
16
  /** An error printed as `{ error, code, next, ... }` on stderr. */
17
17
  export class CliError extends Error {
@@ -29,15 +29,27 @@ const OPTIONS = {
29
29
  init: { scope: { type: "string" }, "no-mcp": { type: "boolean" } },
30
30
  login: { scope: { type: "string" } },
31
31
  doctor: {}, logout: {}, token: {},
32
- target: { repo: { type: "string" }, file: { type: "string" } },
32
+ target: { repo: { type: "string" }, file: { type: "string" }, "auto-promote": { type: "string" } },
33
33
  verify: { workflow: { type: "string" }, timeout: { type: "string" } },
34
34
  wait: { repo: { type: "string" }, timeout: { type: "string" } },
35
35
  failures: { repo: { type: "string" } },
36
36
  ship: { repo: { type: "string" } },
37
37
  };
38
38
 
39
+ export const HELP = {
40
+ commands: [
41
+ "init [--scope SCOPES] [--no-mcp]", "doctor", "login [--scope SCOPES]", "logout", "token list", "token revoke ID",
42
+ "target set --repo OWNER/REPO --file TARGET.json [--auto-promote on|off]", "verify [--workflow PATH] [--timeout SECONDS]",
43
+ "wait ID [--repo OWNER/REPO] [--timeout SECONDS]", "failures ID [--repo OWNER/REPO]", "ship ID [--repo OWNER/REPO]",
44
+ ],
45
+ scopes: SCOPES,
46
+ docs: "https://ci.notusworks.com/docs/agents.md",
47
+ setup: "https://ci.notusworks.com/llms.txt",
48
+ };
49
+
39
50
  /** @param {string[]} args @returns {any} */
40
51
  export function parseCommand(args) {
52
+ if (!args.length || args[0] === "help" || args.includes("--help") || args.includes("-h")) return { command: "help" };
41
53
  const [command = "", ...rest] = args;
42
54
  if (!Object.hasOwn(OPTIONS, command)) throw usage(`unknown command: ${command || "(none)"}`);
43
55
  /** @type {{values: Record<string, any>, positionals: string[]}} */
@@ -73,7 +85,9 @@ export function parseCommand(args) {
73
85
  if (command === "target") {
74
86
  expect("set");
75
87
  if (!values.file) throw usage("--file is required");
76
- return { command: "target set", repo: values.repo, file: values.file };
88
+ const auto = values["auto-promote"];
89
+ if (auto !== undefined && auto !== "on" && auto !== "off") throw usage("--auto-promote must be on or off");
90
+ return { command: "target set", repo: values.repo, file: values.file, autoPromote: auto === undefined ? undefined : auto === "on" };
77
91
  }
78
92
  if (command === "verify") {
79
93
  expect();