@todoforai/cli 0.1.37 → 0.1.38
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/dist/todoforai-cli.js +12 -68
- package/package.json +1 -1
package/dist/todoforai-cli.js
CHANGED
|
@@ -42932,41 +42932,6 @@ class ApiClient {
|
|
|
42932
42932
|
throw new Error(`API GET /resources/show failed: ${res.status} ${await res.text()}`);
|
|
42933
42933
|
return res.json();
|
|
42934
42934
|
}
|
|
42935
|
-
async pushSite(file, filename, opts = {}) {
|
|
42936
|
-
const form = new FormData;
|
|
42937
|
-
form.append("file", file, filename);
|
|
42938
|
-
for (const [k, v] of Object.entries(opts))
|
|
42939
|
-
if (v !== undefined && v !== "")
|
|
42940
|
-
form.append(k, String(v));
|
|
42941
|
-
const res = await fetch(`${this.apiUrl}${restBasePath(this.apiKey)}/resources/sites`, {
|
|
42942
|
-
method: "POST",
|
|
42943
|
-
headers: { "x-api-key": this.apiKey },
|
|
42944
|
-
body: form,
|
|
42945
|
-
signal: AbortSignal.timeout(120000)
|
|
42946
|
-
});
|
|
42947
|
-
if (!res.ok)
|
|
42948
|
-
throw new Error(`API POST /resources/sites failed: ${res.status} ${await res.text()}`);
|
|
42949
|
-
return res.json();
|
|
42950
|
-
}
|
|
42951
|
-
async listSites() {
|
|
42952
|
-
const res = await fetch(`${this.apiUrl}${restBasePath(this.apiKey)}/resources/sites`, {
|
|
42953
|
-
headers: { "x-api-key": this.apiKey },
|
|
42954
|
-
signal: AbortSignal.timeout(30000)
|
|
42955
|
-
});
|
|
42956
|
-
if (!res.ok)
|
|
42957
|
-
throw new Error(`API GET /resources/sites failed: ${res.status} ${await res.text()}`);
|
|
42958
|
-
return res.json();
|
|
42959
|
-
}
|
|
42960
|
-
async getSiteBytes(siteId, version) {
|
|
42961
|
-
const qs = version ? `?version=${encodeURIComponent(version)}` : "";
|
|
42962
|
-
const res = await fetch(`${this.apiUrl}${restBasePath(this.apiKey)}/resources/sites/${siteId}/bytes${qs}`, {
|
|
42963
|
-
headers: { "x-api-key": this.apiKey },
|
|
42964
|
-
signal: AbortSignal.timeout(120000)
|
|
42965
|
-
});
|
|
42966
|
-
if (!res.ok)
|
|
42967
|
-
throw new Error(`API GET site bytes failed: ${res.status} ${await res.text()}`);
|
|
42968
|
-
return res.arrayBuffer();
|
|
42969
|
-
}
|
|
42970
42935
|
async patchSite(siteId, body) {
|
|
42971
42936
|
const res = await fetch(`${this.apiUrl}${restBasePath(this.apiKey)}/resources/sites/${siteId}`, {
|
|
42972
42937
|
method: "PATCH",
|
|
@@ -44358,7 +44323,7 @@ import { parseArgs } from "util";
|
|
|
44358
44323
|
// package.json
|
|
44359
44324
|
var package_default = {
|
|
44360
44325
|
name: "@todoforai/cli",
|
|
44361
|
-
version: "0.1.
|
|
44326
|
+
version: "0.1.38",
|
|
44362
44327
|
type: "module",
|
|
44363
44328
|
bin: {
|
|
44364
44329
|
"todoforai-cli": "bin/todoforai-cli.js",
|
|
@@ -44418,12 +44383,10 @@ Usage:
|
|
|
44418
44383
|
tfa-cli show <file|-> [todo-id] # Show a file in the chat (rendered by mimetype; - reads stdin)
|
|
44419
44384
|
# [--title T] [--alias A] [--mime M] [--card <name>] [--link] [--json]
|
|
44420
44385
|
# --link = compact chip (name+size+download) instead of inline render
|
|
44421
|
-
# The
|
|
44422
|
-
#
|
|
44423
|
-
#
|
|
44424
|
-
tfa-cli show
|
|
44425
|
-
tfa-cli show get <site-id> [out] [--rev <att>] # Fetch its bytes (latest, or a given version)
|
|
44426
|
-
tfa-cli show rm <site-id> # Delete it and all its versions
|
|
44386
|
+
# The file gets a stable public url: sites.todofor.ai/<site-id>
|
|
44387
|
+
# (latest; /<site-id>/<attachment-id> = frozen version). --site <id>
|
|
44388
|
+
# pushes a new version to an existing url (from any todo).
|
|
44389
|
+
tfa-cli show rm <site-id> # Take a shown file down (all versions)
|
|
44427
44390
|
tfa-cli show list [todo-id] # List show blocks (ref, title, mime/url, card)
|
|
44428
44391
|
# [--project <id>] [--card <name>] [--json]
|
|
44429
44392
|
# no todo-id + --project (or $TODOFORAI_PROJECT_ID) = every todo
|
|
@@ -44518,9 +44481,6 @@ function parseCliArgs() {
|
|
|
44518
44481
|
card: { type: "string" },
|
|
44519
44482
|
link: { type: "boolean", default: false },
|
|
44520
44483
|
site: { type: "string" },
|
|
44521
|
-
public: { type: "boolean", default: false },
|
|
44522
|
-
rev: { type: "string" },
|
|
44523
|
-
off: { type: "boolean", default: false },
|
|
44524
44484
|
direction: { type: "string" },
|
|
44525
44485
|
"business-context": { type: "string" },
|
|
44526
44486
|
seed: { type: "string" },
|
|
@@ -47705,38 +47665,23 @@ Cancelled by user (Ctrl+C)
|
|
|
47705
47665
|
}
|
|
47706
47666
|
return;
|
|
47707
47667
|
}
|
|
47708
|
-
if (positionals[0] === "show" &&
|
|
47709
|
-
const sub = positionals[1];
|
|
47668
|
+
if (positionals[0] === "show" && positionals[1] === "rm") {
|
|
47710
47669
|
const id = positionals[2];
|
|
47711
47670
|
if (!id) {
|
|
47712
|
-
process.stderr.write(`${RED}Usage: tfa-cli show
|
|
47671
|
+
process.stderr.write(`${RED}Usage: tfa-cli show rm <site-id>${RESET}
|
|
47713
47672
|
`);
|
|
47714
47673
|
process.exit(2);
|
|
47715
47674
|
}
|
|
47716
|
-
|
|
47717
|
-
|
|
47718
|
-
console.log(site.url ?? `${site.id} (private)`);
|
|
47719
|
-
} else if (sub === "rm") {
|
|
47720
|
-
await api.deleteSite(id);
|
|
47721
|
-
process.stderr.write(`${GREEN}\u2705 deleted ${id}${RESET}
|
|
47675
|
+
await api.deleteSite(id);
|
|
47676
|
+
process.stderr.write(`${GREEN}\u2705 deleted ${id}${RESET}
|
|
47722
47677
|
`);
|
|
47723
|
-
} else {
|
|
47724
|
-
const bytes = await api.getSiteBytes(id, args.rev);
|
|
47725
|
-
const out = positionals[3];
|
|
47726
|
-
if (out && out !== "-") {
|
|
47727
|
-
await Bun.write(resolve3(out), bytes);
|
|
47728
|
-
process.stderr.write(`${GREEN}\u2705 ${out}${RESET}
|
|
47729
|
-
`);
|
|
47730
|
-
} else
|
|
47731
|
-
process.stdout.write(new Uint8Array(bytes));
|
|
47732
|
-
}
|
|
47733
47678
|
return;
|
|
47734
47679
|
}
|
|
47735
47680
|
if (positionals[0] === "show") {
|
|
47736
47681
|
const [, filePath, todoArg] = positionals;
|
|
47737
47682
|
const todoId = todoArg || getEnv("TODO_ID") || cfgScope.data.last_todo_id;
|
|
47738
47683
|
if (!filePath || !todoId) {
|
|
47739
|
-
process.stderr.write(`${RED}Usage: tfa-cli show <file|-> [todo-id] [--title T] [--alias A] [--mime M] [--card <name>] [--link] [--site <id>]
|
|
47684
|
+
process.stderr.write(`${RED}Usage: tfa-cli show <file|-> [todo-id] [--title T] [--alias A] [--mime M] [--card <name>] [--link] [--site <id>]${RESET}
|
|
47740
47685
|
`);
|
|
47741
47686
|
process.exit(2);
|
|
47742
47687
|
}
|
|
@@ -47765,13 +47710,12 @@ Cancelled by user (Ctrl+C)
|
|
|
47765
47710
|
mime: args.mime,
|
|
47766
47711
|
card: args.card,
|
|
47767
47712
|
display: args.link ? "link" : undefined,
|
|
47768
|
-
site: args.site
|
|
47769
|
-
public: args.public ? true : undefined
|
|
47713
|
+
site: args.site
|
|
47770
47714
|
});
|
|
47771
47715
|
if (args.json)
|
|
47772
47716
|
console.log(JSON.stringify(res, null, 2));
|
|
47773
47717
|
else
|
|
47774
|
-
console.log(res.
|
|
47718
|
+
console.log(res.url ? `${res.ref} site=${res.siteId} ${res.url}` : res.ref);
|
|
47775
47719
|
return;
|
|
47776
47720
|
}
|
|
47777
47721
|
if (positionals[0] === "open") {
|