@tobos/cli 0.4.30 → 0.4.32

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.
@@ -5,7 +5,7 @@ import {
5
5
  init_define_TOBOS_PRESENT_TYPES,
6
6
  init_define_TOBOS_SKILL,
7
7
  init_define_TOBOS_TOOLCHAIN
8
- } from "./chunk-QZRWMMBR.js";
8
+ } from "./chunk-XG2KKGXE.js";
9
9
 
10
10
  // ../deck/src/deck-json.ts
11
11
  init_define_TOBOS_PRESENT_TYPES();
@@ -116,7 +116,7 @@ export declare const JoinCode: Component<JoinCodeProps>;
116
116
  var define_TOBOS_SKILL_default;
117
117
  var init_define_TOBOS_SKILL = __esm({
118
118
  "<define:TOBOS_SKILL>"() {
119
- define_TOBOS_SKILL_default = { "SKILL.md": "---\nname: tobos-present\ndescription: Build presentations as code with Tobos Present. Use when the user wants a talk, lecture, pitch or slide deck made, changed, rendered, presented or exported as a PDF, or mentions Tobos or `tobos`.\n---\n\n<!-- Installed by the `tobos` CLI and overwritten when it updates, so changes made here don't last. -->\n\n# Tobos Present\n\nTobos hosts presentations written as code: a deck is a folder of files, one Svelte 5 file per scene, advancing one beat per click. You build it with the `tobos` command, which needs no git; Tobos checks every push, keeps every version, hosts the deck and puts it on stage. `tobos --help` lists every command, and each takes `--json`.\n\n## Get to the deck\n\n- `tobos ls` lists the decks and templates the person can work on, by id. `tobos pull <id>` gets one; `tobos new \"Title\"` starts one and pulls it.\n- A new deck starts from Tobos simple. The person's own templates, their house styles, are in `tobos ls`: start from one with `--from <id>`, and ask which when there are several.\n- Then read the deck's `AGENTS.md`: it points to the loop, the format and the deck's slide master.\n- The person's decks are in folders, which `tobos --help` lists the commands for.\n\nExit code 3 means no one is logged in. Ask the person for their e-mail address and run `tobos login <email>`. Then ask, in one line, for the 6-digit code it mailed them (it may be in spam, and using it accepts https://tobos.ai/terms), and run `tobos login --code <code>`. In CI or a sandbox with no one to ask, `TOBOS_TOKEN` and `TOBOS_SERVER` stand in for the login.\n\n## Follow the person\n\nThey decide what to make and how much of it you build: one scene at a time, or the whole deck at once. Build what they ask, at the size they ask, from what they have told you about the talk. When they ask how Tobos works or where to start, give them the tour, https://tobos.ai/tour, and nothing of your own: no explanation, no deck to try.\n\n## Folders\n\n- Look at the person's folders before you make or move a deck, and file it under a folder name they have already, as they wrote it, rather than a new one that means the same.\n- File every deck you make: once it is made, move it into the folder it belongs in.\n- Before you move more than a handful of decks, show the person the tree you propose, and make it once they say yes.\n- A reorganisation is taken back by moving the decks back where they were: note where they were before you move them.\n- A folder goes when it empties, by a move or a deck's deletion: there is no removing one. A folder with only archived decks in it isn't empty.\n\n## What stays the person's\n\n- **Exit code 5** is a plan's limit or an archived deck. Show the person the message as it is, which says what they can do, and wait for their answer. The deck stays in Tobos: a deck built elsewhere to upload later, media shrunk or hosted elsewhere to fit, or someone else's account would decide for them what is theirs to decide.\n- **Archiving, opening again and deleting** a deck, and deleting a session's answers, are done by the person on the deck's page, also in a browser `tobos open` logged in.\n- **Who is on a deck, and its link,** are the person's, on the deck's page: they put people on it, change what each may do, take them off, and turn the link on or off there. You neither see nor change any of it: `tobos ls` tells you only what you may do on each deck and whose it is. Can edit builds it with their own agent, can present presents it with its notes and polls, and can view sees the slides; on a template, can edit and can use.\n- **The URL `tobos open` prints** is the deck's page, where the person watches it, presents it and shares it; `--presenter` gives a presenter's link instead, which opens once, for whoever opens it first.\n\n## The story\n\nA deck's story is the talk as the speaker tells it, in paragraphs. What follows a mention of a scene, `[Title](scene:<id>)` or one of its beats, `[Title](scene:<id>/<beat>)`, up to the next mention, is that scene's: the presenter sees it as speaker notes. The server holds the story, not git: the person types in it on the deck's page, and you change it with `tobos story`.\n\n- Read it again right before each change: the person may be typing.\n- Change what the person asked, and keep the rest of their words as they are.\n- An edit is anchored on exact text that occurs once in its paragraph. Exit code 4 means the paragraph changed meanwhile: anchor on it as the reply gives it, and try again.\n- Set `TOBOS_AGENT` to your name (`claude`, `codex`), so the page shows what you wrote.\n" };
119
+ define_TOBOS_SKILL_default = { "SKILL.md": "---\nname: tobos-present\ndescription: Build presentations as code with Tobos Present. Use when the user wants a talk, lecture, pitch or slide deck made, changed, rendered, presented or exported as a PDF, or mentions Tobos or `tobos`.\n---\n\n<!-- Installed by the `tobos` CLI and overwritten when it updates, so changes made here don't last. -->\n\n# Tobos Present\n\nTobos hosts presentations written as code: a deck is a folder of files, one Svelte 5 file per scene, advancing one beat per click. You build it with the `tobos` command, which needs no git; Tobos checks every push, keeps every version, hosts the deck and puts it on stage. `tobos --help` lists every command, and each takes `--json`.\n\n## Get to the deck\n\n- `tobos ls` lists the decks and templates the person can work on, by id. `tobos pull <id>` gets one; `tobos new \"Title\"` starts one and pulls it.\n- A new deck starts from Tobos simple. The person's own templates, their house styles, are in `tobos ls`: start from one with `--from <id>`, and ask which when there are several.\n- Then read the deck's `AGENTS.md`: it points to the loop, the format and the deck's slide master.\n- The person's decks are in folders, which `tobos --help` lists the commands for.\n\nExit code 3 means this machine isn't connected to the person's account. Run `tobos login`: it prints an address, which the person opens on any device, logs in at (a first login signs them up, and accepts https://tobos.ai/terms) and approves this machine. Give it to them in one line, then, once they did, run `tobos login` again. In CI or a sandbox with no one to ask, `TOBOS_TOKEN` and `TOBOS_SERVER` stand in for the login.\n\n## Follow the person\n\nThey decide what to make and how much of it you build: one scene at a time, or the whole deck at once. Build what they ask, at the size they ask, from what they have told you about the talk. When they ask how Tobos works or where to start, give them the tour, https://tobos.ai/tour, and nothing of your own: no explanation, no deck to try.\n\n## Folders\n\n- Look at the person's folders before you make or move a deck, and file it under a folder name they have already, as they wrote it, rather than a new one that means the same.\n- File every deck you make: once it is made, move it into the folder it belongs in.\n- Before you move more than a handful of decks, show the person the tree you propose, and make it once they say yes.\n- A reorganisation is taken back by moving the decks back where they were: note where they were before you move them.\n- A folder goes when it empties, by a move or a deck's deletion: there is no removing one. A folder with only archived decks in it isn't empty.\n\n## What stays the person's\n\n- **Exit code 5** is a plan's limit or an archived deck. Show the person the message as it is, which says what they can do, and wait for their answer. The deck stays in Tobos: a deck built elsewhere to upload later, media shrunk or hosted elsewhere to fit, or someone else's account would decide for them what is theirs to decide.\n- **Archiving, opening again and deleting** a deck, and deleting a session's answers, are done by the person on the deck's page, in their own browser.\n- **Who is on a deck, and its link,** are the person's, on the deck's page: they put people on it, change what each may do, take them off, and turn the link on or off there. You neither see nor change any of it: `tobos ls` tells you only what you may do on each deck and whose it is. Can edit builds it with their own agent, can present presents it with its notes and polls, and can view sees the slides; on a template, can edit and can use.\n- **The URL `tobos open` prints** is the deck's page, where the person watches it, presents it and shares it; `--presenter` gives a presenter's link instead, which opens once, for whoever opens it first.\n\n## The story\n\nA deck's story is the talk as the speaker tells it, in paragraphs. What follows a mention of a scene, `[Title](scene:<id>)` or one of its beats, `[Title](scene:<id>/<beat>)`, up to the next mention, is that scene's: the presenter sees it as speaker notes. The server holds the story, not git: the person types in it on the deck's page, and you change it with `tobos story`.\n\n- Read it again right before each change: the person may be typing.\n- Change what the person asked, and keep the rest of their words as they are.\n- An edit is anchored on exact text that occurs once in its paragraph. Exit code 4 means the paragraph changed meanwhile: anchor on it as the reply gives it, and try again.\n- Set `TOBOS_AGENT` to your name (`claude`, `codex`), so the page shows what you wrote.\n" };
120
120
  }
121
121
  });
122
122
 
package/dist/cli.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  mergeText,
8
8
  parseMediaJson,
9
9
  unpackTar
10
- } from "./chunk-67QAOIEN.js";
10
+ } from "./chunk-T2JISWY5.js";
11
11
  import {
12
12
  ASK_THE_PERSON,
13
13
  CliError,
@@ -19,7 +19,7 @@ import {
19
19
  init_define_TOBOS_TOOLCHAIN,
20
20
  offerUpdate,
21
21
  update
22
- } from "./chunk-QZRWMMBR.js";
22
+ } from "./chunk-XG2KKGXE.js";
23
23
 
24
24
  // src/main.ts
25
25
  init_define_TOBOS_PRESENT_TYPES();
@@ -27,6 +27,166 @@ init_define_TOBOS_SKILL();
27
27
  init_define_TOBOS_TOOLCHAIN();
28
28
  import { parseArgs } from "node:util";
29
29
 
30
+ // ../deck/src/verbs.ts
31
+ init_define_TOBOS_PRESENT_TYPES();
32
+ init_define_TOBOS_SKILL();
33
+ init_define_TOBOS_TOOLCHAIN();
34
+ var FOLDER_PATH = "A folder\u2019s path from the root, such as `/Courses/AI 101`; `/` is the root.";
35
+ var REV = { type: "string", description: "A version of the deck; its latest if left out." };
36
+ var CHANGESET_SCHEMA = {
37
+ type: "object",
38
+ properties: {
39
+ base: {
40
+ type: ["string", "null"],
41
+ description: "The version the files were read at: the `rev` that a read, `new` or the last write gave. If the deck changed since, Tobos merges: only lines both changed differently are a conflict."
42
+ },
43
+ message: {
44
+ type: "string",
45
+ description: "What the change does, as a commit message says: needed unless `dry`."
46
+ },
47
+ dry: {
48
+ type: "boolean",
49
+ description: "Check it, and land no version: what the check says of the deck as it would be. A file from the web for media/ is still fetched and stored, so the check sees it. Its answer is no version to write on."
50
+ },
51
+ files: {
52
+ type: "object",
53
+ description: 'Each path to change: its new text in full; `{"patch": [{"find", "replace"}]}` to change part of it, each `find` once in the file as it is now; for a file in media/, `{"url"}`, the address of a file on the web, which Tobos fetches, or `{"base64"}` or `{"hash"}` of an upload; or null to delete it. Only Tobos writes media.json, from what goes into media/.',
54
+ additionalProperties: {
55
+ anyOf: [
56
+ { type: "string" },
57
+ {
58
+ type: "object",
59
+ properties: {
60
+ patch: {
61
+ type: "array",
62
+ items: {
63
+ type: "object",
64
+ properties: { find: { type: "string" }, replace: { type: "string" } },
65
+ required: ["find", "replace"],
66
+ additionalProperties: false
67
+ }
68
+ }
69
+ },
70
+ required: ["patch"],
71
+ additionalProperties: false
72
+ },
73
+ ...["url", "base64", "hash"].map((key) => ({
74
+ type: "object",
75
+ properties: { [key]: { type: "string" } },
76
+ required: [key],
77
+ additionalProperties: false
78
+ })),
79
+ { type: "null" }
80
+ ]
81
+ }
82
+ }
83
+ },
84
+ required: ["base", "files"]
85
+ };
86
+ var VERBS = {
87
+ list: {
88
+ does: "The decks and templates the person works on, by id: their own, and those shared with them that they may present or change. Each with its title, your level on it and whose it is, whether it is archived (read-only), when it last changed, its address in Tobos, and, for the person\u2019s own, its folder. With a path, what that folder holds: its folders, then its decks.",
89
+ input: { properties: { path: { type: "string", description: FOLDER_PATH } }, required: [] },
90
+ cli: [
91
+ {
92
+ usage: "tobos ls [/path]",
93
+ does: "your decks and templates, by id, with your level on each, whose it is and its folder; with a path, what that folder holds"
94
+ }
95
+ ]
96
+ },
97
+ read: {
98
+ does: "A deck\u2019s files at a version, its latest unless another is named, with that version, `rev`, to write on.",
99
+ input: {
100
+ properties: {
101
+ paths: {
102
+ type: "array",
103
+ items: { type: "string" },
104
+ description: "The files to read, such as `deck.json` and `scenes/intro.svelte`, or `master/`."
105
+ },
106
+ rev: REV,
107
+ since: {
108
+ type: "string",
109
+ description: "Reading media/: a version you read, for only the files added since then."
110
+ }
111
+ },
112
+ required: []
113
+ },
114
+ cli: [
115
+ { usage: "tobos pull <id> [dir]", does: "a working copy of a deck, into ./<id> or dir" },
116
+ {
117
+ usage: "tobos pull",
118
+ does: "the latest version into the copy, merged with your changes; a conflict is left between <<<<<<< and >>>>>>> to resolve"
119
+ }
120
+ ],
121
+ chat: 'Without `paths`, lists its files with their sizes; with them, gives each file\u2019s text, many in one call (a path ending in `/` reads every file under it). Reading media/ (`paths: ["media/"]`) shows its pictures, video and sound instead: each file\u2019s name, type and size, when it was added and by whom, and contact sheets to see what they show, with the address of the deck\u2019s page where the person drops files. With `since`, only the files added since that version. Paths of files in media/ show just those, one alone as large as the sheet. A picture the person gave you in the chat reaches you, not Tobos: give them the address of the deck\u2019s page that reading media/ gives, where they drop it.'
122
+ },
123
+ write: {
124
+ does: "Changes a deck\u2019s files as one version, live at once, made on the version they were read at: Tobos merges what changed since, checks the deck as it would be, and saves nothing, saying why, if the check refuses it or someone changed the same lines. Dry, it only checks.",
125
+ input: {
126
+ properties: { ...CHANGESET_SCHEMA.properties },
127
+ required: CHANGESET_SCHEMA.required
128
+ },
129
+ cli: [
130
+ {
131
+ usage: 'tobos push [-m "what changed"]',
132
+ does: "the copy\u2019s changes as one version, media uploaded"
133
+ },
134
+ {
135
+ usage: "tobos check [--types]",
136
+ does: "the same, dry: the server\u2019s check, nothing saved; --types adds TypeScript\u2019s view, here"
137
+ }
138
+ ],
139
+ chat: "Each file\u2019s text in full, a patch of part of it, a file on the web for media/, or null to delete it. All or nothing, so put everything a step needs into one call."
140
+ },
141
+ new: {
142
+ does: "Makes a deck in the person\u2019s account from a template, Tobos simple unless another is named, such as the person\u2019s own house style (ask which when they have several), with its first version, `rev`; or, as a template, a new template: a copy of all of the one it starts from.",
143
+ input: {
144
+ properties: {
145
+ title: { type: "string", description: "The title of the talk." },
146
+ from: { type: "string", description: "The id of the template to start from." },
147
+ template: { type: "boolean", description: "Make a template rather than a deck." }
148
+ },
149
+ required: ["title"]
150
+ },
151
+ chat: "Gives the deck\u2019s id, its first version, `rev`, its files, and its address in Tobos; `list` gives templates\u2019 ids.",
152
+ cli: [
153
+ {
154
+ usage: 'tobos new "Title" [--from <id>] [--template] [--dir dir]',
155
+ does: "a deck from a template (Tobos simple unless --from), or a template; pulled into ./<id> or dir (--no-pull: only made)"
156
+ }
157
+ ]
158
+ },
159
+ move: {
160
+ does: "Moves the person\u2019s decks and templates, a deck by its id or title, and folders, by path, with all that is in them, into a folder, made with the folders on its path if there are none. A folder a move empties goes. Refused, with nothing moved, if one isn\u2019t there, if a title is two decks\u2019 (name that one by its id), if the folder has one of a moved folder\u2019s name, or if a folder would go into itself.",
161
+ input: {
162
+ properties: {
163
+ decks: {
164
+ type: "array",
165
+ items: { type: "string" },
166
+ description: "Decks and templates to move, each by its id or title."
167
+ },
168
+ folders: {
169
+ type: "array",
170
+ items: { type: "string" },
171
+ description: "Folders to move, each by its path, with all that is in them."
172
+ },
173
+ to: { type: "string", description: `Where they go. ${FOLDER_PATH}` }
174
+ },
175
+ required: ["to"]
176
+ },
177
+ cli: [
178
+ {
179
+ usage: "tobos mv <deck or /folder>\u2026 </path>",
180
+ does: "move decks and folders into that folder, made if there is none; a folder a move empties goes"
181
+ }
182
+ ]
183
+ }
184
+ };
185
+ function verbsAppendix(door) {
186
+ const verbs = Object.entries(VERBS);
187
+ return door === "chat" ? verbs.map(([name, verb]) => `- \`${name}\`: ${verb.does}`).join("\n") : verbs.flatMap(([, verb]) => verb.cli.map((c) => `- \`${c.usage}\`: ${c.does}`)).join("\n");
188
+ }
189
+
30
190
  // src/api.ts
31
191
  init_define_TOBOS_PRESENT_TYPES();
32
192
  init_define_TOBOS_SKILL();
@@ -68,7 +228,10 @@ function write(stored) {
68
228
  renameSync(next, file);
69
229
  }
70
230
  function save(update2) {
71
- write({ ...read(), ...update2 });
231
+ const stored = read();
232
+ const elsewhere = update2.server !== void 0 && update2.server !== stored.server;
233
+ const kept = elsewhere ? { server: stored.server } : stored;
234
+ write({ ...kept, ...update2 });
72
235
  }
73
236
  function forget() {
74
237
  write({ server: read().server });
@@ -80,16 +243,18 @@ function settings() {
80
243
  } catch (error) {
81
244
  if (!process.env.TOBOS_SERVER || !process.env.TOBOS_TOKEN) throw error;
82
245
  }
246
+ const server = (process.env.TOBOS_SERVER || stored.server || DEFAULT_SERVER).replace(/\/$/, "");
247
+ const own = (stored.server || DEFAULT_SERVER).replace(/\/$/, "") === server;
83
248
  return {
84
- server: (process.env.TOBOS_SERVER || stored.server || DEFAULT_SERVER).replace(/\/$/, ""),
85
- token: process.env.TOBOS_TOKEN || stored.token,
86
- email: stored.email,
87
- pending: stored.pending
249
+ server,
250
+ token: process.env.TOBOS_TOKEN || (own ? stored.token : void 0),
251
+ email: own ? stored.email : void 0,
252
+ device: stored.device
88
253
  };
89
254
  }
90
255
 
91
256
  // src/api.ts
92
- var VERSION = true ? "0.4.30" : "dev";
257
+ var VERSION = true ? "0.4.32" : "dev";
93
258
  function newer(a, b) {
94
259
  const parse = (v) => /^\d+\.\d+\.\d+/.test(v) ? v.split(".").map((n) => parseInt(n)) : null;
95
260
  const x = parse(a);
@@ -132,12 +297,12 @@ async function request(path, options = {}) {
132
297
  if (!options.anonymous) {
133
298
  if (!token)
134
299
  throw new CliError(
135
- "Not logged in. Ask the person you work for for their e-mail address, then run `tobos login <email>`.",
300
+ "Not logged in: run `tobos login`, and give the person the address it prints.",
136
301
  EXIT.auth
137
302
  );
138
303
  if (new URL(target).origin !== new URL(server).origin)
139
304
  throw new CliError(
140
- `This deck is on ${target}, but you are logged in to ${server}, and the token goes only there. Log in to the deck's server with \`tobos login <email> --server ${target}\`.`,
305
+ `This deck is on ${target}, but you are logged in to ${server}, and the token goes only there. Log in to the deck's server with \`tobos login --server ${target}\`.`,
141
306
  EXIT.auth
142
307
  );
143
308
  headers.authorization = `Bearer ${token}`;
@@ -530,13 +695,34 @@ init_define_TOBOS_SKILL();
530
695
  init_define_TOBOS_TOOLCHAIN();
531
696
  import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "node:fs";
532
697
  import { join as join3 } from "node:path";
698
+ var WORKING = `# Working on a deck
699
+
700
+ You work in a copy of the deck, from \`tobos pull <id>\` or \`tobos new\`, with no git: the server keeps
701
+ the versions. Every push is live: every open preview follows within a second, so the person
702
+ watches the deck take shape.
703
+
704
+ 1. Change \`deck.json\`, the scenes and whatever else the step needs.
705
+ 2. \`tobos check\`: fix every error it reports.
706
+ 3. \`tobos render <scene>/<beat>\` pushes what changed and writes a PNG of that beat; \`--film\`
707
+ writes frames through its animation. Look at each one.
708
+ 4. \`tobos push -m "what changed"\`. \`render\` and \`open\` push the same way when the copy has
709
+ changed, and \`-m\` names that push too.
710
+
711
+ A step is done when every beat it changed has been rendered and looked at.
712
+
713
+ \`.tobos/\` holds this file and the version the copy is of: leave it be. A push leaves out what
714
+ is in \`.tobos/\`, \`.git/\`, \`sources/\` and \`node_modules/\` at the copy's top.
715
+
716
+ ${verbsAppendix("cli")}
717
+
718
+ `;
533
719
  async function writeFormatGuide(root, server) {
534
720
  const dir2 = join3(root, ".tobos");
535
721
  mkdirSync3(dir2, { recursive: true });
536
722
  const format = await request("/api/format", { anonymous: true, server });
537
723
  if (!format.ok)
538
724
  throw new CliError(`Couldn't fetch the format guide from ${server} (${format.status}).`);
539
- writeFileSync3(join3(dir2, "FORMAT.md"), await format.text());
725
+ writeFileSync3(join3(dir2, "FORMAT.md"), WORKING + await format.text());
540
726
  }
541
727
 
542
728
  // src/skill.ts
@@ -626,40 +812,94 @@ function installed(dir2) {
626
812
  }
627
813
 
628
814
  // src/commands.ts
629
- var TERMS_NOTICE = "If the address is new, using the code accepts https://tobos.ai/terms.";
815
+ var LOGIN_WAIT_MS = 9e4;
630
816
  async function login(out, args) {
631
817
  const server = (args.values.server || settings().server).replace(/\/$/, "");
632
- const client = `the tobos CLI on ${hostname()}`;
633
- const email = args.positionals[0]?.trim().toLowerCase();
634
- const code = args.values.code;
635
- if (!code) {
636
- if (!email)
637
- throw new CliError(
638
- "Log in with the e-mail address of the person you work for: `tobos login <email>`."
818
+ const kept = settings().device;
819
+ let device = kept && kept.server === server && Date.parse(kept.expires) > Date.now() ? kept : void 0;
820
+ let opened = false;
821
+ if (!device) {
822
+ const started = await api("/oauth/device", {
823
+ anonymous: true,
824
+ server,
825
+ body: { label: `the tobos CLI on ${hostname()}` }
826
+ });
827
+ device = {
828
+ server,
829
+ deviceCode: started.device_code,
830
+ userCode: started.user_code,
831
+ url: started.verification_uri_complete,
832
+ interval: started.interval,
833
+ expires: new Date(Date.now() + started.expires_in * 1e3).toISOString()
834
+ };
835
+ save({ server, device });
836
+ opened = await openUrl(device.url);
837
+ if (!opened) {
838
+ out.result(
839
+ { waiting: true, url: device.url, code: device.userCode, next: "tobos login" },
840
+ () => `Give the person this address, to open where they like, a phone too: they log in there and approve this machine (a first login signs them up, and accepts https://tobos.ai/terms).
841
+
842
+ ${device.url}
843
+
844
+ The page shows the code ${device.userCode}. Once they approved it, run \`tobos login\` again.`
639
845
  );
640
- await api("/api/login", { anonymous: true, server, body: { email, client } });
641
- save({ server, pending: email });
846
+ process.exitCode = EXIT.auth;
847
+ return;
848
+ }
849
+ out.note(`Opened ${device.url} in the browser: approve the code ${device.userCode} there.`);
850
+ }
851
+ const token = await waitForApproval(device, (m) => out.note(m));
852
+ if (!token) {
642
853
  out.result(
643
- { sent: email, next: "tobos login --code <code>", terms: TERMS_NOTICE },
644
- () => `Sent a 6-digit code to ${email}; it works for 10 minutes. Ask the person for it in one line: check the inbox, or spam, and paste the code here. ${TERMS_NOTICE} Then run:
854
+ { waiting: true, url: device.url, code: device.userCode, next: "tobos login" },
855
+ () => [
856
+ `Not approved yet. The person approves this machine at
645
857
 
646
- tobos login --code <code>`
858
+ ${device.url}`,
859
+ `where the page shows the code ${device.userCode}. Then run \`tobos login\` again.`
860
+ ].join("\n\n")
647
861
  );
862
+ process.exitCode = EXIT.auth;
648
863
  return;
649
864
  }
650
- const address = email ?? settings().pending;
651
- if (!address)
652
- throw new CliError("Which address got the code? `tobos login <email> --code <code>`.");
653
- const { token } = await api("/api/login/verify", {
654
- anonymous: true,
655
- server,
656
- body: { email: address, code, client }
657
- });
658
- save({ server, token, pending: void 0 });
865
+ save({ server, token, device: void 0 });
659
866
  const me = await api("/api/me", { server });
660
867
  save({ email: me.email });
661
868
  out.result({ email: me.email, server }, () => `Logged in as ${me.email}.`);
662
869
  }
870
+ async function waitForApproval(device, note) {
871
+ const until = Date.now() + LOGIN_WAIT_MS;
872
+ let interval = device.interval * 1e3;
873
+ note(`waiting for the person to approve ${device.userCode}\u2026`);
874
+ while (Date.now() < until) {
875
+ const response = await request("/oauth/token", {
876
+ anonymous: true,
877
+ server: device.server,
878
+ body: {
879
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
880
+ device_code: device.deviceCode
881
+ }
882
+ });
883
+ const answer = await response.json().catch(() => ({}));
884
+ if (answer.access_token) return answer.access_token;
885
+ if (answer.error === "slow_down") interval += 5e3;
886
+ else if (answer.error === "access_denied") {
887
+ save({ device: void 0 });
888
+ throw new CliError("The person chose not to connect this machine.", EXIT.auth);
889
+ } else if (answer.error === "expired_token" || answer.error === "invalid_grant") {
890
+ save({ device: void 0 });
891
+ throw new CliError(
892
+ "The code expired before the person approved it. Run `tobos login` again for a new one.",
893
+ EXIT.auth
894
+ );
895
+ } else if (answer.error !== "authorization_pending")
896
+ throw new CliError(
897
+ `${device.server} answered ${response.status} rather than whether the person approved. Run \`tobos login\` again: it waits on the same code.`
898
+ );
899
+ await new Promise((done) => setTimeout(done, interval));
900
+ }
901
+ return void 0;
902
+ }
663
903
  async function logout(out) {
664
904
  let revoked = false;
665
905
  if (settings().token)
@@ -815,7 +1055,7 @@ async function check(out, args) {
815
1055
  );
816
1056
  const problems = [...written.problems];
817
1057
  if (args.values.types) {
818
- const { checkTypes } = await import("./types-YY3IZCJO.js");
1058
+ const { checkTypes } = await import("./types-XT3SUHKX.js");
819
1059
  problems.push(...await checkTypes(copy.root, (m) => out.note(m)));
820
1060
  }
821
1061
  const { errors, warnings } = problemSummary(problems);
@@ -895,16 +1135,9 @@ async function open(out, args) {
895
1135
  out.result({ url: full, opened, pushed }, () => full);
896
1136
  }
897
1137
  async function openApp(out) {
898
- const { url, code } = await api("/api/login/browser", {
899
- method: "POST"
900
- });
901
- const page = `${new URL(url).origin}/login`;
902
- out.result(
903
- { url, code, page },
904
- () => code ? `Open this link, or enter ${code} at ${page}. It works once, within 10 minutes.
905
- ${url}` : `Open this link. It works once, within 10 minutes.
906
- ${url}`
907
- );
1138
+ const url = `${settings().server}/`;
1139
+ const opened = await openUrl(url);
1140
+ out.result({ url, opened }, () => url);
908
1141
  }
909
1142
  async function storyTx(id, ops) {
910
1143
  try {
@@ -967,7 +1200,7 @@ async function story(out, args) {
967
1200
  throw new CliError(`No \`tobos story ${action}\`: edit, add or delete.`);
968
1201
  }
969
1202
  async function render(out, args) {
970
- const { renderBeats } = await import("./render-WZUAK4TK.js");
1203
+ const { renderBeats } = await import("./render-RISSGSJN.js");
971
1204
  const copy = findCopy();
972
1205
  const deck = copy?.base ? { id: copy.base.deck, root: copy.root } : void 0;
973
1206
  const id = typeof args.values.deck === "string" ? parseId(args.values.deck) : deck?.id;
@@ -1033,33 +1266,29 @@ async function skill(out, args) {
1033
1266
  }
1034
1267
 
1035
1268
  // src/main.ts
1269
+ function row(usage, does) {
1270
+ const lines = [];
1271
+ for (const word of does.split(" ")) {
1272
+ const last = lines.at(-1);
1273
+ if (last !== void 0 && last.length + word.length < 50) lines[lines.length - 1] += ` ${word}`;
1274
+ else lines.push(word);
1275
+ }
1276
+ const first = ` ${usage}`;
1277
+ const pad = " ".repeat(46);
1278
+ return [first.length < 45 ? first.padEnd(46) + lines[0] : `${first}
1279
+ ${pad}${lines[0]}`].concat(lines.slice(1).map((line) => pad + line)).join("\n");
1280
+ }
1281
+ var VERB_ROWS = Object.values(VERBS).flatMap((verb) => verb.cli.map((c) => row(c.usage, c.does))).join("\n");
1036
1282
  var HELP = `tobos ${VERSION}: the command line of Tobos, the office suite your coding agent works in.
1037
1283
 
1038
1284
  Account
1039
- tobos login <email> [--server URL] e-mail a login code to the person (signs them up if new)
1040
- tobos login --code <code> finish: the code they read from the mail
1041
- tobos logout forget this machine's token
1042
- tobos whoami who you are, on which server
1043
- tobos ls [/path] your decks and templates, by id, each in its folder,
1044
- and those shared with you; an archived one is
1045
- read-only. With a path: what that folder holds,
1046
- its folders, then its decks
1047
-
1048
- Folders (your decks and templates in a tree; a deck by its id or title, a folder by its path)
1049
- tobos mv <deck or /folder>\u2026 </path> move them into that folder, made if there is none;
1050
- a folder a move empties goes
1285
+ ${row("tobos login [--server URL]", "connect this machine: prints an address for the person to open and approve (logging in, or signing up, there); run it again once they did")}
1286
+ ${row("tobos logout", "forget this machine's token")}
1287
+ ${row("tobos whoami", "who you are, on which server")}
1051
1288
 
1052
- Working on a deck (a working copy: no git; the server keeps the versions)
1053
- tobos new "Title" [--dir dir] [--no-pull] create a deck and pull it here, into ./<id>
1054
- (or into dir; --no-pull: only create it)
1055
- tobos pull <id> [dir] a working copy of a deck, with the agent pack
1056
- tobos pull the latest version into the copy, merged with your
1057
- changes; a conflict is left between <<<<<<< and
1058
- >>>>>>> to resolve; and the format guide
1059
- tobos check [--types] the server's check of your changes; nothing lands;
1060
- --types: TypeScript too, here (installs a checker once)
1061
- tobos push [-m "what changed"] your changes as one version, media uploaded; the
1062
- server checks it, and it goes live
1289
+ The five verbs (a deck by its id, or its title to mv it; a folder by its path; in a working copy,
1290
+ with no git: the server keeps the versions)
1291
+ ${VERB_ROWS}
1063
1292
 
1064
1293
  Looking at it (from the working copy, render and open push what changed first; with --deck <id>,
1065
1294
  from anywhere)
@@ -1069,8 +1298,7 @@ from anywhere)
1069
1298
  tobos open [scene/beat] [--presenter] the deck's page in a browser (--presenter: a
1070
1299
  [--print] presenter's link, which opens once); --print: print
1071
1300
  the URL only, open nothing
1072
- tobos open outside a deck: a link, or its code for /login,
1073
- that logs a browser in once; show the person both
1301
+ tobos open outside a deck: the person's decks, in Tobos
1074
1302
 
1075
1303
  The story (what the speaker says, held by the server; a scene mentioned: [Title](scene:<id>),
1076
1304
  a beat: [Title](scene:<id>/<beat>))
@@ -1085,16 +1313,11 @@ The skill (what your harness reads to know Tobos without this help)
1085
1313
  tobos skill install put it where Claude Code, Codex, OpenCode and others
1086
1314
  read skills; later CLIs keep it up to date
1087
1315
 
1088
- Templates (decks people start from: a new deck copies a template's master/)
1089
- tobos new "Title" --from <id> start a deck from that template (default: Tobos
1090
- simple; \`tobos ls\` lists the person's own)
1091
- tobos new "Our brand" --template a new template: a copy of Tobos simple (or of --from)
1092
-
1093
1316
  Every command takes --json and then prints one JSON object.
1094
- Exit codes: 0 ok, 1 error, 2 the deck has problems, 3 not logged in, 4 a conflict: someone
1095
- changed the same lines (pull, resolve, push again; for the story, the reply has the paragraph as
1096
- it is now), 5 a plan's limit or an archived deck: the person decides what to do, so show them the
1097
- message and wait.
1317
+ Exit codes: 0 ok, 1 error, 2 the deck has problems, 3 not logged in (or not yet approved),
1318
+ 4 a conflict: someone changed the same lines (pull, resolve, push again; for the story, the reply
1319
+ has the paragraph as it is now), 5 a plan's limit or an archived deck: the person decides what to
1320
+ do, so show them the message and wait.
1098
1321
  `;
1099
1322
  var COMMON = {
1100
1323
  json: { type: "boolean" },
@@ -1103,7 +1326,7 @@ var COMMON = {
1103
1326
  var TABLE = {
1104
1327
  login: {
1105
1328
  run: login,
1106
- options: { server: { type: "string" }, code: { type: "string" } }
1329
+ options: { server: { type: "string" } }
1107
1330
  },
1108
1331
  logout: { run: logout },
1109
1332
  whoami: { run: whoami },
@@ -6,7 +6,7 @@ import {
6
6
  init_define_TOBOS_PRESENT_TYPES,
7
7
  init_define_TOBOS_SKILL,
8
8
  init_define_TOBOS_TOOLCHAIN
9
- } from "./chunk-QZRWMMBR.js";
9
+ } from "./chunk-XG2KKGXE.js";
10
10
 
11
11
  // src/render.ts
12
12
  init_define_TOBOS_PRESENT_TYPES();
@@ -3,7 +3,7 @@ import { createRequire as __tobosRequire } from 'node:module';
3
3
  const require = __tobosRequire(import.meta.url);
4
4
  import {
5
5
  parseDeckJson
6
- } from "./chunk-67QAOIEN.js";
6
+ } from "./chunk-T2JISWY5.js";
7
7
  import {
8
8
  CliError,
9
9
  __commonJS,
@@ -14,7 +14,7 @@ import {
14
14
  init_define_TOBOS_PRESENT_TYPES,
15
15
  init_define_TOBOS_SKILL,
16
16
  init_define_TOBOS_TOOLCHAIN
17
- } from "./chunk-QZRWMMBR.js";
17
+ } from "./chunk-XG2KKGXE.js";
18
18
 
19
19
  // ../node_modules/.pnpm/aria-query@5.3.1/node_modules/aria-query/lib/util/iteratorProxy.js
20
20
  var require_iteratorProxy = __commonJS({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tobos/cli",
3
- "version": "0.4.30",
3
+ "version": "0.4.32",
4
4
  "description": "The command line of Tobos: https://tobos.ai",
5
5
  "type": "module",
6
6
  "license": "FSL-1.1-ALv2",