@reminix/cli 1.0.0-rc.5 → 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 +36 -0
- package/README.md +4 -1
- package/dist/reminix.mjs +195 -148
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,42 @@
|
|
|
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
|
+
|
|
29
|
+
## 1.0.0-rc.6 (2026-10-19)
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- `login` in the browser no longer shows Safari's "This is a non-secure
|
|
34
|
+
form" warning after **Allow**. The page now hands the new token back to
|
|
35
|
+
the waiting CLI encrypted to a key only that CLI holds, by a redirect
|
|
36
|
+
instead of a form. A CLI from before this change is asked to update.
|
|
37
|
+
- `reminix run <slug> --number <n>` test-runs version n (a draft).
|
|
38
|
+
`--version <n>` printed the CLI's own version instead of running, so it
|
|
39
|
+
is gone. A run whose output is text prints it as it is, without quotes.
|
|
40
|
+
|
|
5
41
|
## 1.0.0-rc.5 (2026-10-16)
|
|
6
42
|
|
|
7
43
|
No user-facing changes.
|
package/README.md
CHANGED
|
@@ -54,9 +54,12 @@ agents.
|
|
|
54
54
|
- [Discord](https://reminix.com/discord)
|
|
55
55
|
- [Report a security issue](https://reminix.com/security/)
|
|
56
56
|
|
|
57
|
-
##
|
|
57
|
+
## Contributing
|
|
58
58
|
|
|
59
59
|
This repository is generated from Reminix's source on each
|
|
60
60
|
release, so pull requests are ported there and credited (see
|
|
61
61
|
[CONTRIBUTING.md](https://github.com/reminixhq/reminix-cli/blob/main/CONTRIBUTING.md)).
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
62
65
|
Licensed under the Apache License 2.0.
|
package/dist/reminix.mjs
CHANGED
|
@@ -13,11 +13,10 @@ var brand_default = {
|
|
|
13
13
|
legalName: "Omsome L.L.C-FZ",
|
|
14
14
|
releaseMirrors: true,
|
|
15
15
|
mirrorProfile: {
|
|
16
|
-
tagline: "run your team's scripts from a form, an API or an agent tool, with every run on record",
|
|
17
16
|
topics: ["scripts", "automation", "ai-agents", "mcp", "api-client", "sdk"]
|
|
18
17
|
},
|
|
19
18
|
domain: "reminix.com",
|
|
20
|
-
discordInvite: "https://discord.gg/
|
|
19
|
+
discordInvite: "https://discord.gg/UU9NbEcNQj",
|
|
21
20
|
summary: "Reminix lets your whole team, your software and your agents run your team's scripts, and the ones AI writes: one publish gives a form, an API and an agent tool, with keys kept out of the code and every run on record.",
|
|
22
21
|
expectedAssets: [
|
|
23
22
|
"logo.svg",
|
|
@@ -689,7 +688,7 @@ async function uploadFile(client, file, options = {}) {
|
|
|
689
688
|
var RunError = class extends Error {
|
|
690
689
|
run;
|
|
691
690
|
constructor(run3) {
|
|
692
|
-
super(run3.status === "cancelled" ? `Run ${run3.id} was cancelled:
|
|
691
|
+
super(run3.status === "cancelled" ? `Run ${run3.id} was cancelled: ${run3.error ?? "no reason given"}` : `Run ${run3.id} failed: ${run3.error ?? "no error message"}`);
|
|
693
692
|
this.name = "RunError";
|
|
694
693
|
this.run = run3;
|
|
695
694
|
}
|
|
@@ -4650,12 +4649,35 @@ function useColor() {
|
|
|
4650
4649
|
var program = new Command();
|
|
4651
4650
|
|
|
4652
4651
|
// src/browser-login.ts
|
|
4653
|
-
import {
|
|
4652
|
+
import {
|
|
4653
|
+
constants,
|
|
4654
|
+
generateKeyPairSync,
|
|
4655
|
+
privateDecrypt,
|
|
4656
|
+
randomBytes
|
|
4657
|
+
} from "node:crypto";
|
|
4654
4658
|
import { createServer } from "node:http";
|
|
4655
4659
|
var PAGE = (title, body) => `<!doctype html><html><head><meta charset="utf-8"><title>${title}</title><meta name="viewport" content="width=device-width, initial-scale=1"></head><body style="font-family:system-ui,sans-serif;max-width:32rem;margin:4rem auto;padding:0 1rem"><h1 style="font-size:1.25rem">${title}</h1><p>${body}</p></body></html>`;
|
|
4656
|
-
var
|
|
4660
|
+
var MAX_URL = 16 * 1024;
|
|
4657
4661
|
function browserLogin(options) {
|
|
4658
4662
|
const state = randomBytes(24).toString("base64url");
|
|
4663
|
+
const { publicKey, privateKey } = generateKeyPairSync("rsa", {
|
|
4664
|
+
modulusLength: 2048
|
|
4665
|
+
});
|
|
4666
|
+
const key = publicKey.export({ type: "spki", format: "der" }).toString("base64url");
|
|
4667
|
+
const decrypt = (sealed) => {
|
|
4668
|
+
try {
|
|
4669
|
+
return privateDecrypt(
|
|
4670
|
+
{
|
|
4671
|
+
key: privateKey,
|
|
4672
|
+
padding: constants.RSA_PKCS1_OAEP_PADDING,
|
|
4673
|
+
oaepHash: "sha256"
|
|
4674
|
+
},
|
|
4675
|
+
Buffer.from(sealed, "base64url")
|
|
4676
|
+
).toString("utf8");
|
|
4677
|
+
} catch {
|
|
4678
|
+
return null;
|
|
4679
|
+
}
|
|
4680
|
+
};
|
|
4659
4681
|
return new Promise((resolve4, reject) => {
|
|
4660
4682
|
let settled = false;
|
|
4661
4683
|
const finish = (outcome) => {
|
|
@@ -4666,44 +4688,41 @@ function browserLogin(options) {
|
|
|
4666
4688
|
outcome();
|
|
4667
4689
|
};
|
|
4668
4690
|
const server = createServer((req, res) => {
|
|
4669
|
-
|
|
4691
|
+
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
4692
|
+
if (req.method !== "GET" || url.pathname !== "/callback" || (req.url ?? "").length > MAX_URL) {
|
|
4670
4693
|
res.writeHead(404).end();
|
|
4671
4694
|
return;
|
|
4672
4695
|
}
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
});
|
|
4679
|
-
|
|
4680
|
-
const fields = new URLSearchParams(body);
|
|
4681
|
-
const send = (status, title, text) => res.writeHead(status, { "content-type": "text/html; charset=utf-8" }).end(PAGE(title, text));
|
|
4682
|
-
if (fields.get("state") !== state) {
|
|
4683
|
-
send(
|
|
4684
|
-
400,
|
|
4685
|
-
"Not this login",
|
|
4686
|
-
"This sign-in did not come from the terminal that is waiting. Run login again."
|
|
4687
|
-
);
|
|
4688
|
-
return;
|
|
4689
|
-
}
|
|
4690
|
-
if (fields.get("error")) {
|
|
4691
|
-
send(200, "Sign-in cancelled", "You can close this tab.");
|
|
4692
|
-
finish(() => reject(new Error("sign-in was denied in the browser")));
|
|
4693
|
-
return;
|
|
4694
|
-
}
|
|
4695
|
-
const token = fields.get("token");
|
|
4696
|
-
if (!token) {
|
|
4697
|
-
send(400, "Something went wrong", "Run login again.");
|
|
4698
|
-
return;
|
|
4699
|
-
}
|
|
4696
|
+
const fields = url.searchParams;
|
|
4697
|
+
const send = (status, title, text) => res.writeHead(status, {
|
|
4698
|
+
"content-type": "text/html; charset=utf-8",
|
|
4699
|
+
"cache-control": "no-store",
|
|
4700
|
+
"referrer-policy": "no-referrer"
|
|
4701
|
+
}).end(PAGE(title, text));
|
|
4702
|
+
if (fields.get("state") !== state) {
|
|
4700
4703
|
send(
|
|
4701
|
-
|
|
4702
|
-
"
|
|
4703
|
-
"
|
|
4704
|
+
400,
|
|
4705
|
+
"Not this login",
|
|
4706
|
+
"This sign-in did not come from the terminal that is waiting. Run login again."
|
|
4704
4707
|
);
|
|
4705
|
-
|
|
4706
|
-
}
|
|
4708
|
+
return;
|
|
4709
|
+
}
|
|
4710
|
+
if (fields.get("error")) {
|
|
4711
|
+
send(200, "Sign-in cancelled", "You can close this tab.");
|
|
4712
|
+
finish(() => reject(new Error("sign-in was denied in the browser")));
|
|
4713
|
+
return;
|
|
4714
|
+
}
|
|
4715
|
+
const token = decrypt(fields.get("token") ?? "");
|
|
4716
|
+
if (!token) {
|
|
4717
|
+
send(400, "Something went wrong", "Run login again.");
|
|
4718
|
+
return;
|
|
4719
|
+
}
|
|
4720
|
+
send(
|
|
4721
|
+
200,
|
|
4722
|
+
"You are signed in",
|
|
4723
|
+
"Return to your terminal \u2014 you can close this tab."
|
|
4724
|
+
);
|
|
4725
|
+
finish(() => resolve4(token));
|
|
4707
4726
|
});
|
|
4708
4727
|
const timer = setTimeout(
|
|
4709
4728
|
() => finish(
|
|
@@ -4720,6 +4739,7 @@ function browserLogin(options) {
|
|
|
4720
4739
|
const url = `${options.webOrigin}/cli/authorize?${new URLSearchParams({
|
|
4721
4740
|
port: String(port),
|
|
4722
4741
|
state,
|
|
4742
|
+
key,
|
|
4723
4743
|
name: options.computer
|
|
4724
4744
|
})}`;
|
|
4725
4745
|
options.onUrl(url);
|
|
@@ -6614,7 +6634,7 @@ var OPERATIONS = [
|
|
|
6614
6634
|
"idempotentHint": false
|
|
6615
6635
|
}
|
|
6616
6636
|
},
|
|
6617
|
-
"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.",
|
|
6618
6638
|
"fields": [
|
|
6619
6639
|
{
|
|
6620
6640
|
"name": "slug",
|
|
@@ -6825,6 +6845,54 @@ var OPERATIONS = [
|
|
|
6825
6845
|
],
|
|
6826
6846
|
"description": "How it was uploaded (for the history). Default: api."
|
|
6827
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
|
+
}
|
|
6828
6896
|
}
|
|
6829
6897
|
],
|
|
6830
6898
|
"hasBody": true,
|
|
@@ -8526,24 +8594,6 @@ function print(ctx, data, asJson) {
|
|
|
8526
8594
|
// src/product/files.ts
|
|
8527
8595
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
|
|
8528
8596
|
import { basename, dirname, join as join2, resolve, sep } from "node:path";
|
|
8529
|
-
var TYPES = {
|
|
8530
|
-
csv: "text/csv",
|
|
8531
|
-
tsv: "text/tab-separated-values",
|
|
8532
|
-
txt: "text/plain",
|
|
8533
|
-
md: "text/markdown",
|
|
8534
|
-
json: "application/json",
|
|
8535
|
-
xml: "application/xml",
|
|
8536
|
-
pdf: "application/pdf",
|
|
8537
|
-
zip: "application/zip",
|
|
8538
|
-
gz: "application/gzip",
|
|
8539
|
-
ofx: "application/x-ofx",
|
|
8540
|
-
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
8541
|
-
xls: "application/vnd.ms-excel",
|
|
8542
|
-
png: "image/png",
|
|
8543
|
-
jpg: "image/jpeg",
|
|
8544
|
-
jpeg: "image/jpeg"
|
|
8545
|
-
};
|
|
8546
|
-
var typeOf = (path2) => TYPES[path2.split(".").pop()?.toLowerCase() ?? ""] ?? "application/octet-stream";
|
|
8547
8597
|
async function uploadPath(ctx, path2, workspace2) {
|
|
8548
8598
|
let data;
|
|
8549
8599
|
try {
|
|
@@ -8554,8 +8604,8 @@ async function uploadPath(ctx, path2, workspace2) {
|
|
|
8554
8604
|
});
|
|
8555
8605
|
}
|
|
8556
8606
|
return uploadFile(ctx.client({ workspace: workspace2 }), {
|
|
8607
|
+
// No type: the API takes it from the name (one table for every client).
|
|
8557
8608
|
name: basename(path2),
|
|
8558
|
-
type: typeOf(path2),
|
|
8559
8609
|
data: new Uint8Array(data)
|
|
8560
8610
|
});
|
|
8561
8611
|
}
|
|
@@ -9597,6 +9647,25 @@ function withName(result, folder) {
|
|
|
9597
9647
|
}
|
|
9598
9648
|
};
|
|
9599
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
|
+
}
|
|
9600
9669
|
|
|
9601
9670
|
// src/product/scripts.ts
|
|
9602
9671
|
var MAX_ARCHIVE_BYTES = 1e7;
|
|
@@ -9666,7 +9735,11 @@ function loadScriptDir(dir, flags = {}) {
|
|
|
9666
9735
|
files,
|
|
9667
9736
|
archive: pack(dir, files),
|
|
9668
9737
|
readme: readReadme(dir),
|
|
9669
|
-
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
|
+
}
|
|
9670
9743
|
};
|
|
9671
9744
|
}
|
|
9672
9745
|
var SKIPPED = /* @__PURE__ */ new Set([
|
|
@@ -9724,6 +9797,7 @@ function pack(dir, files) {
|
|
|
9724
9797
|
return tar.stdout;
|
|
9725
9798
|
}
|
|
9726
9799
|
var POLL_MS2 = 2e3;
|
|
9800
|
+
var ENDED2 = /* @__PURE__ */ new Set(["succeeded", "failed", "cancelled"]);
|
|
9727
9801
|
function isScript(dir) {
|
|
9728
9802
|
return existsSync3(join3(dir, "reminix.json")) || detectScript(localFolder(dir, scriptFiles(dir))).ok;
|
|
9729
9803
|
}
|
|
@@ -9765,7 +9839,7 @@ function describeDetected(manifest, detected) {
|
|
|
9765
9839
|
return lines.join("\n");
|
|
9766
9840
|
}
|
|
9767
9841
|
async function publishFolder(ctx, dir, options) {
|
|
9768
|
-
const { manifest, archive,
|
|
9842
|
+
const { manifest, archive, explicit, detected } = loadScriptDir(dir, options);
|
|
9769
9843
|
if (options.plan) {
|
|
9770
9844
|
return {
|
|
9771
9845
|
slug: manifest.slug,
|
|
@@ -9799,16 +9873,6 @@ Nothing was uploaded (--plan).`
|
|
|
9799
9873
|
line: approveUrl2 ? `Publishing ${manifest.slug} version ${number} waits for a person's approval: ${approveUrl2}` : `Published ${manifest.slug} version ${number}.`
|
|
9800
9874
|
};
|
|
9801
9875
|
}
|
|
9802
|
-
try {
|
|
9803
|
-
await call3("GET", `/v1/scripts/${slug}`);
|
|
9804
|
-
} catch (error) {
|
|
9805
|
-
if (error.status !== 404) throw error;
|
|
9806
|
-
await call3("POST", "/v1/scripts", {
|
|
9807
|
-
slug: manifest.slug,
|
|
9808
|
-
name: manifest.name,
|
|
9809
|
-
description: manifest.description
|
|
9810
|
-
});
|
|
9811
|
-
}
|
|
9812
9876
|
const version = await call3("POST", `/v1/scripts/${slug}/versions`, {
|
|
9813
9877
|
command: manifest.command,
|
|
9814
9878
|
build: manifest.build ?? null,
|
|
@@ -9819,19 +9883,14 @@ Nothing was uploaded (--plan).`
|
|
|
9819
9883
|
env: manifest.env,
|
|
9820
9884
|
tags: manifest.tags,
|
|
9821
9885
|
timeout: manifest.timeout,
|
|
9822
|
-
readme,
|
|
9823
9886
|
archive: archive.toString("base64"),
|
|
9824
|
-
via: "cli"
|
|
9887
|
+
via: "cli",
|
|
9888
|
+
create: true,
|
|
9889
|
+
...explicit,
|
|
9890
|
+
publish: !options.draft
|
|
9825
9891
|
});
|
|
9826
|
-
|
|
9827
|
-
|
|
9828
|
-
if (!options.draft) {
|
|
9829
|
-
script = await call3(
|
|
9830
|
-
"POST",
|
|
9831
|
-
`/v1/scripts/${slug}/versions/${version.number}/publish`
|
|
9832
|
-
);
|
|
9833
|
-
approveUrl = script.approval?.approveUrl ?? null;
|
|
9834
|
-
}
|
|
9892
|
+
const script = null;
|
|
9893
|
+
const approveUrl = version.approval?.approveUrl ?? null;
|
|
9835
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}.`;
|
|
9836
9895
|
const found = detected ? `${describeDetected(manifest, detected)}
|
|
9837
9896
|
` : "";
|
|
@@ -9917,9 +9976,12 @@ var defineRun = (command, ctx) => covers(command, "runs.create", "scriptVersions
|
|
|
9917
9976
|
"--out <dir>",
|
|
9918
9977
|
"save the files the run writes here (else their links are printed)"
|
|
9919
9978
|
).option(
|
|
9920
|
-
"--
|
|
9921
|
-
"test-run
|
|
9922
|
-
).option("--log", "also print what the run logged (to stderr)").option(
|
|
9979
|
+
"--number <n>",
|
|
9980
|
+
"test-run version n (a draft) instead of the published one"
|
|
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(
|
|
9923
9985
|
async (slug, options) => {
|
|
9924
9986
|
let inputs;
|
|
9925
9987
|
try {
|
|
@@ -9953,36 +10015,37 @@ var defineRun = (command, ctx) => covers(command, "runs.create", "scriptVersions
|
|
|
9953
10015
|
spec.slice(at + 1)
|
|
9954
10016
|
]);
|
|
9955
10017
|
}
|
|
9956
|
-
const script = await call3(
|
|
9957
|
-
"GET",
|
|
9958
|
-
`/v1/scripts/${encodeURIComponent(slug)}`
|
|
9959
|
-
);
|
|
9960
|
-
const properties = script.inputSchema?.properties ?? {};
|
|
9961
10018
|
for (const [name, paths] of byInput) {
|
|
9962
10019
|
const ids = [];
|
|
9963
10020
|
for (const path2 of paths) {
|
|
9964
10021
|
ids.push((await uploadPath(ctx, path2, options.workspace)).id);
|
|
9965
10022
|
}
|
|
9966
|
-
inputs[name] =
|
|
10023
|
+
inputs[name] = ids.length > 1 ? ids : ids[0];
|
|
9967
10024
|
}
|
|
9968
10025
|
}
|
|
9969
|
-
if (options.
|
|
9970
|
-
throw new Error("--
|
|
10026
|
+
if (options.number !== void 0 && !/^[1-9]\d*$/.test(options.number)) {
|
|
10027
|
+
throw new Error("--number: a version number, like --number 2");
|
|
9971
10028
|
}
|
|
9972
10029
|
let run3 = await call3(
|
|
9973
10030
|
"POST",
|
|
9974
|
-
options.
|
|
10031
|
+
options.number === void 0 ? `/v1/scripts/${encodeURIComponent(slug)}/runs` : `/v1/scripts/${encodeURIComponent(slug)}/versions/${options.number}/runs`,
|
|
9975
10032
|
{ inputs, via: "cli" }
|
|
9976
10033
|
);
|
|
9977
|
-
if (run3.status
|
|
10034
|
+
if (!options.wait && !ENDED2.has(run3.status)) {
|
|
9978
10035
|
ctx.io.stdout(
|
|
9979
|
-
options.json ? json(run3) : `
|
|
10036
|
+
options.json ? json(run3) : `Run ${run3.id} is ${run3.status}.`
|
|
9980
10037
|
);
|
|
9981
10038
|
return;
|
|
9982
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
|
+
}
|
|
9983
10046
|
let printed = 0;
|
|
9984
10047
|
const printLog = async () => {
|
|
9985
|
-
if (!options.log) return;
|
|
10048
|
+
if (!options.log || run3.status === "awaiting_approval") return;
|
|
9986
10049
|
const { lines } = await call3(
|
|
9987
10050
|
"GET",
|
|
9988
10051
|
`/v1/runs/${encodeURIComponent(run3.id)}/logs`
|
|
@@ -9990,7 +10053,7 @@ var defineRun = (command, ctx) => covers(command, "runs.create", "scriptVersions
|
|
|
9990
10053
|
for (const line of lines.slice(printed)) ctx.io.stderr(line);
|
|
9991
10054
|
printed = Math.max(printed, lines.length);
|
|
9992
10055
|
};
|
|
9993
|
-
while (run3.status
|
|
10056
|
+
while (!ENDED2.has(run3.status)) {
|
|
9994
10057
|
await printLog();
|
|
9995
10058
|
await new Promise((resolve4) => setTimeout(resolve4, POLL_MS2));
|
|
9996
10059
|
run3 = await call3(
|
|
@@ -10015,10 +10078,19 @@ var defineRun = (command, ctx) => covers(command, "runs.create", "scriptVersions
|
|
|
10015
10078
|
if (options.json) {
|
|
10016
10079
|
ctx.io.stdout(json(run3));
|
|
10017
10080
|
} else if (run3.status === "succeeded") {
|
|
10018
|
-
ctx.io.stdout(
|
|
10081
|
+
ctx.io.stdout(
|
|
10082
|
+
typeof run3.output === "string" ? run3.output : json(run3.output)
|
|
10083
|
+
);
|
|
10084
|
+
}
|
|
10085
|
+
if (run3.status === "cancelled") {
|
|
10086
|
+
throw new Error(
|
|
10087
|
+
`The run was cancelled (${run3.id}): ${run3.error ?? "no reason given"}`
|
|
10088
|
+
);
|
|
10019
10089
|
}
|
|
10020
10090
|
if (run3.status !== "succeeded") {
|
|
10021
|
-
throw new Error(
|
|
10091
|
+
throw new Error(
|
|
10092
|
+
`The run failed (${run3.id}): ${run3.error ?? "no error message"}`
|
|
10093
|
+
);
|
|
10022
10094
|
}
|
|
10023
10095
|
}
|
|
10024
10096
|
);
|
|
@@ -10031,64 +10103,38 @@ var scriptCommands = (program3, ctx) => {
|
|
|
10031
10103
|
`Short for ${brand.name} scripts publish: upload a folder's script and publish it (--draft to test first)`
|
|
10032
10104
|
);
|
|
10033
10105
|
defineRun(group.command("run <slug>"), ctx).description(
|
|
10034
|
-
`Run a script and print its output (--
|
|
10106
|
+
`Run a script and print its output (--number to test a draft; shortcut: ${brand.name} run)`
|
|
10035
10107
|
);
|
|
10036
10108
|
defineRun(program3.command("run <slug>"), ctx).description(
|
|
10037
|
-
`Short for ${brand.name} scripts run: run a script and print its output (--
|
|
10109
|
+
`Short for ${brand.name} scripts run: run a script and print its output (--number to test a draft)`
|
|
10038
10110
|
);
|
|
10039
10111
|
};
|
|
10040
10112
|
|
|
10041
10113
|
// src/product/init.ts
|
|
10042
|
-
import { existsSync as existsSync4,
|
|
10043
|
-
import { basename as basename3,
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
|
|
10048
|
-
|
|
10049
|
-
|
|
10050
|
-
|
|
10051
|
-
if (ext === ".py") return "python";
|
|
10052
|
-
if ([".js", ".mjs", ".cjs", ".ts", ".mts"].includes(ext)) return "node";
|
|
10053
|
-
if (ext === ".sh") return "sh";
|
|
10054
|
-
if (ext === "") return `./${file}`;
|
|
10055
|
-
throw new Error(
|
|
10056
|
-
`${file}: say how to run it, like: ${brand.name} init "python ${file} --month {month}"`
|
|
10057
|
-
);
|
|
10058
|
-
}
|
|
10059
|
-
var SCRIPT_FILE = /\.(py|sh|js|mjs|cjs|ts|mts)$/i;
|
|
10060
|
-
var NOT_A_SCRIPT2 = /(\.config\.|^setup\.py$|^conftest\.py$|\.d\.ts$)/i;
|
|
10061
|
-
function onlyScript(dir) {
|
|
10062
|
-
const files = readdirSync2(dir).filter(
|
|
10063
|
-
(f) => SCRIPT_FILE.test(f) && !NOT_A_SCRIPT2.test(f)
|
|
10064
|
-
);
|
|
10065
|
-
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) {
|
|
10066
10123
|
throw new Error(
|
|
10067
|
-
`${
|
|
10124
|
+
`${detection.error.replace(/ Pass --command .*$/, "")} ${INIT_HELP}`
|
|
10068
10125
|
);
|
|
10069
10126
|
}
|
|
10070
|
-
return
|
|
10071
|
-
}
|
|
10072
|
-
function commandFor(dir, given) {
|
|
10073
|
-
const line = given?.trim() || onlyScript(dir);
|
|
10074
|
-
return /\s|\{/.test(line) ? line : `${programFor(line)} ${line}`;
|
|
10127
|
+
return detection.value.command;
|
|
10075
10128
|
}
|
|
10076
10129
|
function inputSchemaFor(command) {
|
|
10077
|
-
const
|
|
10078
|
-
[...command.matchAll(/\[[^\]]*\]/g)].flatMap(
|
|
10079
|
-
(group) => [...group[0].matchAll(/\{([A-Za-z_][\w-]*)\}/g)].map((m) => m[1])
|
|
10080
|
-
)
|
|
10081
|
-
);
|
|
10082
|
-
const names = [
|
|
10083
|
-
...new Set(
|
|
10084
|
-
[...command.matchAll(/\{([A-Za-z_][\w-]*)\}/g)].map((m) => m[1])
|
|
10085
|
-
)
|
|
10086
|
-
];
|
|
10130
|
+
const schema = inputSchemaForCommand(command);
|
|
10087
10131
|
return {
|
|
10088
|
-
|
|
10089
|
-
required: names.filter((name) => !optional2.has(name)),
|
|
10132
|
+
...schema,
|
|
10090
10133
|
properties: Object.fromEntries(
|
|
10091
|
-
|
|
10134
|
+
Object.entries(schema.properties).map(([name, property]) => [
|
|
10135
|
+
name,
|
|
10136
|
+
{ ...property, description: "" }
|
|
10137
|
+
])
|
|
10092
10138
|
)
|
|
10093
10139
|
};
|
|
10094
10140
|
}
|
|
@@ -10098,14 +10144,15 @@ function scaffold(dir, given) {
|
|
|
10098
10144
|
throw new Error(`${manifest} already exists`);
|
|
10099
10145
|
}
|
|
10100
10146
|
const command = commandFor(dir, given);
|
|
10101
|
-
const
|
|
10147
|
+
const detected = detectScript(localFolder(dir, scriptFiles(dir)));
|
|
10148
|
+
const slug = (detected.ok ? detected.value.slug : void 0) ?? slugOf(basename3(resolve3(dir))) ?? "my-script";
|
|
10102
10149
|
const created = [];
|
|
10103
10150
|
writeFileSync5(
|
|
10104
10151
|
manifest,
|
|
10105
10152
|
`${JSON.stringify(
|
|
10106
10153
|
{
|
|
10107
10154
|
slug,
|
|
10108
|
-
name:
|
|
10155
|
+
name: titleOf(slug),
|
|
10109
10156
|
description: "",
|
|
10110
10157
|
command,
|
|
10111
10158
|
tags: [],
|
|
@@ -10121,7 +10168,7 @@ function scaffold(dir, given) {
|
|
|
10121
10168
|
if (!existsSync4(join4(dir, "README.md"))) {
|
|
10122
10169
|
writeFileSync5(
|
|
10123
10170
|
join4(dir, "README.md"),
|
|
10124
|
-
`# ${
|
|
10171
|
+
`# ${titleOf(slug)}
|
|
10125
10172
|
|
|
10126
10173
|
What it does, when to use it, and what its inputs mean.
|
|
10127
10174
|
`
|
|
@@ -10193,7 +10240,7 @@ function tokenEnvVar() {
|
|
|
10193
10240
|
function build(io) {
|
|
10194
10241
|
let actedIn = null;
|
|
10195
10242
|
let sending;
|
|
10196
|
-
const program3 = new Command().name(brand.name).description(`${brand.productName} command line`).version("1.0.0-rc.
|
|
10243
|
+
const program3 = new Command().name(brand.name).description(`${brand.productName} command line`).version("1.0.0-rc.7").addHelpText(
|
|
10197
10244
|
"after",
|
|
10198
10245
|
`
|
|
10199
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.
|
|
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.
|
|
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",
|