@todoforai/cli 0.1.37 → 0.1.39

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.
@@ -42837,6 +42837,9 @@ class ApiClient {
42837
42837
  getTodo(todoId) {
42838
42838
  return this.request("GET", `/api/v1/todos/${todoId}`);
42839
42839
  }
42840
+ linkBlockSubTodo(todoId, messageId, blockId, subTodoId) {
42841
+ return this.request("POST", `/api/v1/todos/${todoId}/blocks/${blockId}/subtodo`, { messageId, subTodoId });
42842
+ }
42840
42843
  updateTodoStatus(todoId, status) {
42841
42844
  return this.request("PATCH", `/api/v1/todos/${todoId}/status`, { status });
42842
42845
  }
@@ -42932,41 +42935,6 @@ class ApiClient {
42932
42935
  throw new Error(`API GET /resources/show failed: ${res.status} ${await res.text()}`);
42933
42936
  return res.json();
42934
42937
  }
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
42938
  async patchSite(siteId, body) {
42971
42939
  const res = await fetch(`${this.apiUrl}${restBasePath(this.apiKey)}/resources/sites/${siteId}`, {
42972
42940
  method: "PATCH",
@@ -44358,7 +44326,7 @@ import { parseArgs } from "util";
44358
44326
  // package.json
44359
44327
  var package_default = {
44360
44328
  name: "@todoforai/cli",
44361
- version: "0.1.37",
44329
+ version: "0.1.39",
44362
44330
  type: "module",
44363
44331
  bin: {
44364
44332
  "todoforai-cli": "bin/todoforai-cli.js",
@@ -44418,12 +44386,10 @@ Usage:
44418
44386
  tfa-cli show <file|-> [todo-id] # Show a file in the chat (rendered by mimetype; - reads stdin)
44419
44387
  # [--title T] [--alias A] [--mime M] [--card <name>] [--link] [--json]
44420
44388
  # --link = compact chip (name+size+download) instead of inline render
44421
- # The bytes get a stable, versioned site id (printed). --site <id>
44422
- # pushes a new version of an existing one (from any todo);
44423
- # --public serves the latest at sites.todofor.ai/<id>
44424
- tfa-cli show public <site-id> [--off] # Publish / unpublish a shown file
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
44389
+ # The file gets a stable public url: sites.todofor.ai/<site-id>
44390
+ # (latest; /<site-id>/<attachment-id> = frozen version). --site <id>
44391
+ # pushes a new version to an existing url (from any todo).
44392
+ tfa-cli show rm <site-id> # Take a shown file down (all versions)
44427
44393
  tfa-cli show list [todo-id] # List show blocks (ref, title, mime/url, card)
44428
44394
  # [--project <id>] [--card <name>] [--json]
44429
44395
  # no todo-id + --project (or $TODOFORAI_PROJECT_ID) = every todo
@@ -44518,9 +44484,6 @@ function parseCliArgs() {
44518
44484
  card: { type: "string" },
44519
44485
  link: { type: "boolean", default: false },
44520
44486
  site: { type: "string" },
44521
- public: { type: "boolean", default: false },
44522
- rev: { type: "string" },
44523
- off: { type: "boolean", default: false },
44524
44487
  direction: { type: "string" },
44525
44488
  "business-context": { type: "string" },
44526
44489
  seed: { type: "string" },
@@ -47705,38 +47668,23 @@ Cancelled by user (Ctrl+C)
47705
47668
  }
47706
47669
  return;
47707
47670
  }
47708
- if (positionals[0] === "show" && ["public", "get", "rm"].includes(positionals[1] ?? "")) {
47709
- const sub = positionals[1];
47671
+ if (positionals[0] === "show" && positionals[1] === "rm") {
47710
47672
  const id = positionals[2];
47711
47673
  if (!id) {
47712
- process.stderr.write(`${RED}Usage: tfa-cli show public <site-id> [--off] | get <site-id> [out] [--rev <att>] | rm <site-id>${RESET}
47674
+ process.stderr.write(`${RED}Usage: tfa-cli show rm <site-id>${RESET}
47713
47675
  `);
47714
47676
  process.exit(2);
47715
47677
  }
47716
- if (sub === "public") {
47717
- const site = await api.patchSite(id, { isPublic: !args.off });
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}
47722
- `);
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}
47678
+ await api.deleteSite(id);
47679
+ process.stderr.write(`${GREEN}\u2705 deleted ${id}${RESET}
47729
47680
  `);
47730
- } else
47731
- process.stdout.write(new Uint8Array(bytes));
47732
- }
47733
47681
  return;
47734
47682
  }
47735
47683
  if (positionals[0] === "show") {
47736
47684
  const [, filePath, todoArg] = positionals;
47737
47685
  const todoId = todoArg || getEnv("TODO_ID") || cfgScope.data.last_todo_id;
47738
47686
  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>] [--public]${RESET}
47687
+ process.stderr.write(`${RED}Usage: tfa-cli show <file|-> [todo-id] [--title T] [--alias A] [--mime M] [--card <name>] [--link] [--site <id>]${RESET}
47740
47688
  `);
47741
47689
  process.exit(2);
47742
47690
  }
@@ -47765,13 +47713,12 @@ Cancelled by user (Ctrl+C)
47765
47713
  mime: args.mime,
47766
47714
  card: args.card,
47767
47715
  display: args.link ? "link" : undefined,
47768
- site: args.site,
47769
- public: args.public ? true : undefined
47716
+ site: args.site
47770
47717
  });
47771
47718
  if (args.json)
47772
47719
  console.log(JSON.stringify(res, null, 2));
47773
47720
  else
47774
- console.log(res.siteUrl ? `${res.ref} site=${res.siteId} ${res.siteUrl}` : `${res.ref} site=${res.siteId}`);
47721
+ console.log(res.url ? `${res.ref} site=${res.siteId} ${res.url}` : res.ref);
47775
47722
  return;
47776
47723
  }
47777
47724
  if (positionals[0] === "open") {
@@ -48210,6 +48157,11 @@ Resumed: ${CYAN}${getFrontendUrl(apiUrl, todoId)}${RESET}
48210
48157
  }
48211
48158
  const actualTodoId = todo.id || crypto.randomUUID();
48212
48159
  cfgScope.setLastTodoId(actualTodoId);
48160
+ const { TODOFORAI_TODO_ID: pTodo, TODOFORAI_MESSAGE_ID: pMsg, TODOFORAI_BLOCK_ID: pBlock } = process.env;
48161
+ if (pTodo && pMsg && pBlock && pTodo !== actualTodoId) {
48162
+ await api.linkBlockSubTodo(pTodo, pMsg, pBlock, actualTodoId).catch((e) => process.stderr.write(`${DIM}subtodo link failed: ${e?.message ?? e}${RESET}
48163
+ `));
48164
+ }
48213
48165
  const frontendUrl = getFrontendUrl(apiUrl, actualTodoId);
48214
48166
  if (args.json) {
48215
48167
  console.log(JSON.stringify({ ...todo, frontend_url: frontendUrl }, null, 2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@todoforai/cli",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "todoforai-cli": "bin/todoforai-cli.js",