@reminix/cli 1.0.0-rc.6 → 1.0.0-rc.7

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/CHANGELOG.md CHANGED
@@ -2,6 +2,30 @@
2
2
 
3
3
  What changed in the Reminix CLI (`@reminix/cli`). Generated from the source on each release; newest first.
4
4
 
5
+ ## 1.0.0-rc.7 (2026-10-19)
6
+
7
+ ### Changed
8
+
9
+ - - `reminix run` waits through a person's approval, as the SDKs' `run`
10
+ does: it prints where to approve the run, then follows it to the end.
11
+ `--no-wait` answers at once instead.
12
+ - A cancelled run says why, in every client: "Run run_… was cancelled:
13
+ The approval was denied" (the run's `error`). The CLI no longer prints
14
+ "failed: null".
15
+ - Files are uploaded without a guessed type; the API takes it from the
16
+ file's name, the same way for every client. `reminix run --file` no
17
+ longer reads the script first: one file is sent as one id, and the API
18
+ takes it for an input that is a list of files.
19
+ - Publishing is one call. `scriptVersions.create` (Upload a version)
20
+ takes `create`, `name`, `description` and `publish`: it can make a new
21
+ script, rename one, and publish the upload, answering with an
22
+ `approval` link when a person must approve. Without `readme`, the
23
+ folder's `README.md` is used. `reminix publish` uses it, so a name or
24
+ description changed in `reminix.json` now reaches the script.
25
+ - `reminix init` works out the command the same way `publish` does, so
26
+ the two agree on every folder (an entry like `main.py` beside other
27
+ scripts, `pyproject.toml`, `package.json`).
28
+
5
29
  ## 1.0.0-rc.6 (2026-10-19)
6
30
 
7
31
  ### Fixed
package/dist/reminix.mjs CHANGED
@@ -688,7 +688,7 @@ async function uploadFile(client, file, options = {}) {
688
688
  var RunError = class extends Error {
689
689
  run;
690
690
  constructor(run3) {
691
- super(run3.status === "cancelled" ? `Run ${run3.id} was cancelled: its approval was denied or expired` : `Run ${run3.id} failed: ${run3.error ?? "no error message"}`);
691
+ super(run3.status === "cancelled" ? `Run ${run3.id} was cancelled: ${run3.error ?? "no reason given"}` : `Run ${run3.id} failed: ${run3.error ?? "no error message"}`);
692
692
  this.name = "RunError";
693
693
  this.run = run3;
694
694
  }
@@ -6634,7 +6634,7 @@ var OPERATIONS = [
6634
6634
  "idempotentHint": false
6635
6635
  }
6636
6636
  },
6637
- "description": "Uploads a new DRAFT version: the script's folder (a .tar.gz, base64 \u2014 the CLI makes it), the command that runs it and the JSON Schema of its inputs. Leave the command out and it is worked out from the folder: pyproject.toml's one script, package.json's bin, start or main, or the folder's one .py, .js, .ts or .sh file; leave the schema out and each `{name}` in the command is a text input. Its dependencies (requirements.txt, pyproject.toml, package.json) are installed now, once; a failed install answers 400 with what it printed. Runs keep using the published version until this one is published.",
6637
+ "description": "Uploads a new DRAFT version: the script's folder (a .tar.gz, base64 \u2014 the CLI makes it), the command that runs it and the JSON Schema of its inputs. Leave the command out and it is worked out from the folder: pyproject.toml's one script, package.json's bin, start or main, or the folder's one .py, .js, .ts or .sh file; leave the schema out and each `{name}` in the command is a text input. Its dependencies (requirements.txt, pyproject.toml, package.json) are installed now, once; a failed install answers 400 with what it printed. Leave the readme out and the folder's README.md is used. Runs keep using the published version until this one is published \u2014 or pass `publish: true` (and `create: true` for a new script) to publish in one call.",
6638
6638
  "fields": [
6639
6639
  {
6640
6640
  "name": "slug",
@@ -6845,6 +6845,54 @@ var OPERATIONS = [
6845
6845
  ],
6846
6846
  "description": "How it was uploaded (for the history). Default: api."
6847
6847
  }
6848
+ },
6849
+ {
6850
+ "name": "create",
6851
+ "in": "body",
6852
+ "type": "boolean",
6853
+ "required": false,
6854
+ "description": "Create the script when there is none with this slug \u2014 named `name`, else from the folder (pyproject.toml, package.json), else its slug. Default: false (an unknown slug is a 404, so a typo never makes a new script).",
6855
+ "schema": {
6856
+ "type": "boolean",
6857
+ "description": "Create the script when there is none with this slug \u2014 named `name`, else from the folder (pyproject.toml, package.json), else its slug. Default: false (an unknown slug is a 404, so a typo never makes a new script)."
6858
+ }
6859
+ },
6860
+ {
6861
+ "name": "name",
6862
+ "in": "body",
6863
+ "type": "string",
6864
+ "required": false,
6865
+ "description": "When given, becomes the script's name (on creation, and on every later upload that sends it).",
6866
+ "example": "Unlock account",
6867
+ "schema": {
6868
+ "type": "string",
6869
+ "minLength": 1,
6870
+ "maxLength": 100,
6871
+ "description": "When given, becomes the script's name (on creation, and on every later upload that sends it)."
6872
+ }
6873
+ },
6874
+ {
6875
+ "name": "description",
6876
+ "in": "body",
6877
+ "type": "string",
6878
+ "required": false,
6879
+ "description": "When given, becomes the script's description, as `name`.",
6880
+ "schema": {
6881
+ "type": "string",
6882
+ "maxLength": 500,
6883
+ "description": "When given, becomes the script's description, as `name`."
6884
+ }
6885
+ },
6886
+ {
6887
+ "name": "publish",
6888
+ "in": "body",
6889
+ "type": "boolean",
6890
+ "required": false,
6891
+ "description": 'Publish this version too, in the same call \u2014 exactly as "Publish a version": when the workspace needs a person\'s approval, the answer carries `approval` and it is published once approved.',
6892
+ "schema": {
6893
+ "type": "boolean",
6894
+ "description": 'Publish this version too, in the same call \u2014 exactly as "Publish a version": when the workspace needs a person\'s approval, the answer carries `approval` and it is published once approved.'
6895
+ }
6848
6896
  }
6849
6897
  ],
6850
6898
  "hasBody": true,
@@ -8546,24 +8594,6 @@ function print(ctx, data, asJson) {
8546
8594
  // src/product/files.ts
8547
8595
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
8548
8596
  import { basename, dirname, join as join2, resolve, sep } from "node:path";
8549
- var TYPES = {
8550
- csv: "text/csv",
8551
- tsv: "text/tab-separated-values",
8552
- txt: "text/plain",
8553
- md: "text/markdown",
8554
- json: "application/json",
8555
- xml: "application/xml",
8556
- pdf: "application/pdf",
8557
- zip: "application/zip",
8558
- gz: "application/gzip",
8559
- ofx: "application/x-ofx",
8560
- xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
8561
- xls: "application/vnd.ms-excel",
8562
- png: "image/png",
8563
- jpg: "image/jpeg",
8564
- jpeg: "image/jpeg"
8565
- };
8566
- var typeOf = (path2) => TYPES[path2.split(".").pop()?.toLowerCase() ?? ""] ?? "application/octet-stream";
8567
8597
  async function uploadPath(ctx, path2, workspace2) {
8568
8598
  let data;
8569
8599
  try {
@@ -8574,8 +8604,8 @@ async function uploadPath(ctx, path2, workspace2) {
8574
8604
  });
8575
8605
  }
8576
8606
  return uploadFile(ctx.client({ workspace: workspace2 }), {
8607
+ // No type: the API takes it from the name (one table for every client).
8577
8608
  name: basename(path2),
8578
- type: typeOf(path2),
8579
8609
  data: new Uint8Array(data)
8580
8610
  });
8581
8611
  }
@@ -9617,6 +9647,25 @@ function withName(result, folder) {
9617
9647
  }
9618
9648
  };
9619
9649
  }
9650
+ function inputSchemaForCommand(command) {
9651
+ const optional2 = new Set(
9652
+ [...command.matchAll(/\[[^\]]*\]/g)].flatMap(
9653
+ (group) => [...group[0].matchAll(/\{([A-Za-z_][\w-]*)\}/g)].map((m) => m[1])
9654
+ )
9655
+ );
9656
+ const names = [
9657
+ ...new Set(
9658
+ [...command.matchAll(/\{([A-Za-z_][\w-]*)\}/g)].map((m) => m[1])
9659
+ )
9660
+ ];
9661
+ return {
9662
+ type: "object",
9663
+ required: names.filter((name) => !optional2.has(name)),
9664
+ properties: Object.fromEntries(
9665
+ names.map((name) => [name, { type: "string" }])
9666
+ )
9667
+ };
9668
+ }
9620
9669
 
9621
9670
  // src/product/scripts.ts
9622
9671
  var MAX_ARCHIVE_BYTES = 1e7;
@@ -9686,7 +9735,11 @@ function loadScriptDir(dir, flags = {}) {
9686
9735
  files,
9687
9736
  archive: pack(dir, files),
9688
9737
  readme: readReadme(dir),
9689
- detected: command ? null : detected
9738
+ detected: command ? null : detected,
9739
+ explicit: {
9740
+ ...(given.name ?? flags.name) !== void 0 ? { name: given.name ?? flags.name } : {},
9741
+ ...given.description !== void 0 ? { description: given.description } : {}
9742
+ }
9690
9743
  };
9691
9744
  }
9692
9745
  var SKIPPED = /* @__PURE__ */ new Set([
@@ -9744,6 +9797,7 @@ function pack(dir, files) {
9744
9797
  return tar.stdout;
9745
9798
  }
9746
9799
  var POLL_MS2 = 2e3;
9800
+ var ENDED2 = /* @__PURE__ */ new Set(["succeeded", "failed", "cancelled"]);
9747
9801
  function isScript(dir) {
9748
9802
  return existsSync3(join3(dir, "reminix.json")) || detectScript(localFolder(dir, scriptFiles(dir))).ok;
9749
9803
  }
@@ -9785,7 +9839,7 @@ function describeDetected(manifest, detected) {
9785
9839
  return lines.join("\n");
9786
9840
  }
9787
9841
  async function publishFolder(ctx, dir, options) {
9788
- const { manifest, archive, readme, detected } = loadScriptDir(dir, options);
9842
+ const { manifest, archive, explicit, detected } = loadScriptDir(dir, options);
9789
9843
  if (options.plan) {
9790
9844
  return {
9791
9845
  slug: manifest.slug,
@@ -9819,16 +9873,6 @@ Nothing was uploaded (--plan).`
9819
9873
  line: approveUrl2 ? `Publishing ${manifest.slug} version ${number} waits for a person's approval: ${approveUrl2}` : `Published ${manifest.slug} version ${number}.`
9820
9874
  };
9821
9875
  }
9822
- try {
9823
- await call3("GET", `/v1/scripts/${slug}`);
9824
- } catch (error) {
9825
- if (error.status !== 404) throw error;
9826
- await call3("POST", "/v1/scripts", {
9827
- slug: manifest.slug,
9828
- name: manifest.name,
9829
- description: manifest.description
9830
- });
9831
- }
9832
9876
  const version = await call3("POST", `/v1/scripts/${slug}/versions`, {
9833
9877
  command: manifest.command,
9834
9878
  build: manifest.build ?? null,
@@ -9839,19 +9883,14 @@ Nothing was uploaded (--plan).`
9839
9883
  env: manifest.env,
9840
9884
  tags: manifest.tags,
9841
9885
  timeout: manifest.timeout,
9842
- readme,
9843
9886
  archive: archive.toString("base64"),
9844
- via: "cli"
9887
+ via: "cli",
9888
+ create: true,
9889
+ ...explicit,
9890
+ publish: !options.draft
9845
9891
  });
9846
- let script = null;
9847
- let approveUrl = null;
9848
- if (!options.draft) {
9849
- script = await call3(
9850
- "POST",
9851
- `/v1/scripts/${slug}/versions/${version.number}/publish`
9852
- );
9853
- approveUrl = script.approval?.approveUrl ?? null;
9854
- }
9892
+ const script = null;
9893
+ const approveUrl = version.approval?.approveUrl ?? null;
9855
9894
  const line = approveUrl ? `Uploaded ${manifest.slug} version ${version.number}; publishing waits for a person's approval: ${approveUrl}` : options.draft ? `Uploaded ${manifest.slug} version ${version.number} as a draft. Publish it in the app, or run \`${brand.name} publish\` again without --draft.` : `Published ${manifest.slug} version ${version.number}.`;
9856
9895
  const found = detected ? `${describeDetected(manifest, detected)}
9857
9896
  ` : "";
@@ -9939,7 +9978,10 @@ var defineRun = (command, ctx) => covers(command, "runs.create", "scriptVersions
9939
9978
  ).option(
9940
9979
  "--number <n>",
9941
9980
  "test-run version n (a draft) instead of the published one"
9942
- ).option("--log", "also print what the run logged (to stderr)").option("--workspace <slug>", "act in this workspace for one call").option("--json", "print the whole run, not just its output").action(
9981
+ ).option("--log", "also print what the run logged (to stderr)").option(
9982
+ "--no-wait",
9983
+ "answer at once with a run held for approval or still running, instead of following it"
9984
+ ).option("--workspace <slug>", "act in this workspace for one call").option("--json", "print the whole run, not just its output").action(
9943
9985
  async (slug, options) => {
9944
9986
  let inputs;
9945
9987
  try {
@@ -9973,17 +10015,12 @@ var defineRun = (command, ctx) => covers(command, "runs.create", "scriptVersions
9973
10015
  spec.slice(at + 1)
9974
10016
  ]);
9975
10017
  }
9976
- const script = await call3(
9977
- "GET",
9978
- `/v1/scripts/${encodeURIComponent(slug)}`
9979
- );
9980
- const properties = script.inputSchema?.properties ?? {};
9981
10018
  for (const [name, paths] of byInput) {
9982
10019
  const ids = [];
9983
10020
  for (const path2 of paths) {
9984
10021
  ids.push((await uploadPath(ctx, path2, options.workspace)).id);
9985
10022
  }
9986
- inputs[name] = properties[name]?.type === "array" || ids.length > 1 ? ids : ids[0];
10023
+ inputs[name] = ids.length > 1 ? ids : ids[0];
9987
10024
  }
9988
10025
  }
9989
10026
  if (options.number !== void 0 && !/^[1-9]\d*$/.test(options.number)) {
@@ -9994,15 +10031,21 @@ var defineRun = (command, ctx) => covers(command, "runs.create", "scriptVersions
9994
10031
  options.number === void 0 ? `/v1/scripts/${encodeURIComponent(slug)}/runs` : `/v1/scripts/${encodeURIComponent(slug)}/versions/${options.number}/runs`,
9995
10032
  { inputs, via: "cli" }
9996
10033
  );
9997
- if (run3.status === "awaiting_approval") {
10034
+ if (!options.wait && !ENDED2.has(run3.status)) {
9998
10035
  ctx.io.stdout(
9999
- options.json ? json(run3) : `Waiting for a person's approval (run ${run3.id}): ${run3.approval?.approveUrl ?? "see Approvals in the app"}`
10036
+ options.json ? json(run3) : `Run ${run3.id} is ${run3.status}.`
10000
10037
  );
10001
10038
  return;
10002
10039
  }
10040
+ const approveUrl = run3.approval?.approveUrl;
10041
+ if (run3.status === "awaiting_approval") {
10042
+ ctx.io.stderr(
10043
+ `Waiting for a person's approval (run ${run3.id}): ${approveUrl ?? "see Approvals in the app"}`
10044
+ );
10045
+ }
10003
10046
  let printed = 0;
10004
10047
  const printLog = async () => {
10005
- if (!options.log) return;
10048
+ if (!options.log || run3.status === "awaiting_approval") return;
10006
10049
  const { lines } = await call3(
10007
10050
  "GET",
10008
10051
  `/v1/runs/${encodeURIComponent(run3.id)}/logs`
@@ -10010,7 +10053,7 @@ var defineRun = (command, ctx) => covers(command, "runs.create", "scriptVersions
10010
10053
  for (const line of lines.slice(printed)) ctx.io.stderr(line);
10011
10054
  printed = Math.max(printed, lines.length);
10012
10055
  };
10013
- while (run3.status === "running") {
10056
+ while (!ENDED2.has(run3.status)) {
10014
10057
  await printLog();
10015
10058
  await new Promise((resolve4) => setTimeout(resolve4, POLL_MS2));
10016
10059
  run3 = await call3(
@@ -10039,8 +10082,15 @@ var defineRun = (command, ctx) => covers(command, "runs.create", "scriptVersions
10039
10082
  typeof run3.output === "string" ? run3.output : json(run3.output)
10040
10083
  );
10041
10084
  }
10085
+ if (run3.status === "cancelled") {
10086
+ throw new Error(
10087
+ `The run was cancelled (${run3.id}): ${run3.error ?? "no reason given"}`
10088
+ );
10089
+ }
10042
10090
  if (run3.status !== "succeeded") {
10043
- throw new Error(`The run failed (${run3.id}): ${run3.error}`);
10091
+ throw new Error(
10092
+ `The run failed (${run3.id}): ${run3.error ?? "no error message"}`
10093
+ );
10044
10094
  }
10045
10095
  }
10046
10096
  );
@@ -10061,56 +10111,30 @@ var scriptCommands = (program3, ctx) => {
10061
10111
  };
10062
10112
 
10063
10113
  // src/product/init.ts
10064
- import { existsSync as existsSync4, readdirSync as readdirSync2, writeFileSync as writeFileSync5 } from "node:fs";
10065
- import { basename as basename3, extname, join as join4, resolve as resolve3 } from "node:path";
10066
- function slugFrom(name) {
10067
- const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^[^a-z]+/, "").replace(/-+$/, "").slice(0, 64).replace(/-+$/, "");
10068
- return slug.length >= 2 ? slug : "my-script";
10069
- }
10070
- var titleFrom = (slug) => slug.split("-").filter(Boolean).map((w, i) => i === 0 ? w[0].toUpperCase() + w.slice(1) : w).join(" ");
10071
- function programFor(file) {
10072
- const ext = extname(file).toLowerCase();
10073
- if (ext === ".py") return "python";
10074
- if ([".js", ".mjs", ".cjs", ".ts", ".mts"].includes(ext)) return "node";
10075
- if (ext === ".sh") return "sh";
10076
- if (ext === "") return `./${file}`;
10077
- throw new Error(
10078
- `${file}: say how to run it, like: ${brand.name} init "python ${file} --month {month}"`
10079
- );
10080
- }
10081
- var SCRIPT_FILE = /\.(py|sh|js|mjs|cjs|ts|mts)$/i;
10082
- var NOT_A_SCRIPT2 = /(\.config\.|^setup\.py$|^conftest\.py$|\.d\.ts$)/i;
10083
- function onlyScript(dir) {
10084
- const files = readdirSync2(dir).filter(
10085
- (f) => SCRIPT_FILE.test(f) && !NOT_A_SCRIPT2.test(f)
10086
- );
10087
- if (files.length !== 1) {
10114
+ import { existsSync as existsSync4, writeFileSync as writeFileSync5 } from "node:fs";
10115
+ import { basename as basename3, join as join4, resolve as resolve3 } from "node:path";
10116
+ var INIT_HELP = `Say which file and how it runs, like: ${brand.name} init "python report.py --month {month}"`;
10117
+ function commandFor(dir, given) {
10118
+ const line = given?.trim();
10119
+ if (line && /\s|\{/.test(line)) return line;
10120
+ const folder = localFolder(dir, line ? [line] : scriptFiles(dir));
10121
+ const detection = detectScript(folder);
10122
+ if (!detection.ok) {
10088
10123
  throw new Error(
10089
- `${files.length === 0 ? "No script file here" : `Several script files here (${files.join(", ")})`} \u2014 say which and how it runs, like: ${brand.name} init "python report.py --month {month}"`
10124
+ `${detection.error.replace(/ Pass --command .*$/, "")} ${INIT_HELP}`
10090
10125
  );
10091
10126
  }
10092
- return files[0];
10093
- }
10094
- function commandFor(dir, given) {
10095
- const line = given?.trim() || onlyScript(dir);
10096
- return /\s|\{/.test(line) ? line : `${programFor(line)} ${line}`;
10127
+ return detection.value.command;
10097
10128
  }
10098
10129
  function inputSchemaFor(command) {
10099
- const optional2 = new Set(
10100
- [...command.matchAll(/\[[^\]]*\]/g)].flatMap(
10101
- (group) => [...group[0].matchAll(/\{([A-Za-z_][\w-]*)\}/g)].map((m) => m[1])
10102
- )
10103
- );
10104
- const names = [
10105
- ...new Set(
10106
- [...command.matchAll(/\{([A-Za-z_][\w-]*)\}/g)].map((m) => m[1])
10107
- )
10108
- ];
10130
+ const schema = inputSchemaForCommand(command);
10109
10131
  return {
10110
- type: "object",
10111
- required: names.filter((name) => !optional2.has(name)),
10132
+ ...schema,
10112
10133
  properties: Object.fromEntries(
10113
- names.map((name) => [name, { type: "string", description: "" }])
10134
+ Object.entries(schema.properties).map(([name, property]) => [
10135
+ name,
10136
+ { ...property, description: "" }
10137
+ ])
10114
10138
  )
10115
10139
  };
10116
10140
  }
@@ -10120,14 +10144,15 @@ function scaffold(dir, given) {
10120
10144
  throw new Error(`${manifest} already exists`);
10121
10145
  }
10122
10146
  const command = commandFor(dir, given);
10123
- const slug = slugFrom(basename3(resolve3(dir)));
10147
+ const detected = detectScript(localFolder(dir, scriptFiles(dir)));
10148
+ const slug = (detected.ok ? detected.value.slug : void 0) ?? slugOf(basename3(resolve3(dir))) ?? "my-script";
10124
10149
  const created = [];
10125
10150
  writeFileSync5(
10126
10151
  manifest,
10127
10152
  `${JSON.stringify(
10128
10153
  {
10129
10154
  slug,
10130
- name: titleFrom(slug),
10155
+ name: titleOf(slug),
10131
10156
  description: "",
10132
10157
  command,
10133
10158
  tags: [],
@@ -10143,7 +10168,7 @@ function scaffold(dir, given) {
10143
10168
  if (!existsSync4(join4(dir, "README.md"))) {
10144
10169
  writeFileSync5(
10145
10170
  join4(dir, "README.md"),
10146
- `# ${titleFrom(slug)}
10171
+ `# ${titleOf(slug)}
10147
10172
 
10148
10173
  What it does, when to use it, and what its inputs mean.
10149
10174
  `
@@ -10215,7 +10240,7 @@ function tokenEnvVar() {
10215
10240
  function build(io) {
10216
10241
  let actedIn = null;
10217
10242
  let sending;
10218
- const program3 = new Command().name(brand.name).description(`${brand.productName} command line`).version("1.0.0-rc.6").addHelpText(
10243
+ const program3 = new Command().name(brand.name).description(`${brand.productName} command line`).version("1.0.0-rc.7").addHelpText(
10219
10244
  "after",
10220
10245
  `
10221
10246
  Token: \`${brand.name} login\` stores it in ~/.config/${brand.name}/; ${tokenEnvVar()} overrides.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reminix/cli",
3
- "version": "1.0.0-rc.6",
3
+ "version": "1.0.0-rc.7",
4
4
  "description": "Reminix command line",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,7 +17,7 @@
17
17
  "typecheck": "tsc --noEmit"
18
18
  },
19
19
  "devDependencies": {
20
- "@reminix/sdk": "1.0.0-rc.5",
20
+ "@reminix/sdk": "1.0.0-rc.6",
21
21
  "@types/node": "26.6.5",
22
22
  "commander": "15.0.0",
23
23
  "smol-toml": "1.9.1",