@tobos/cli 0.2.0 → 0.4.0

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.
Files changed (2) hide show
  1. package/dist/tobos.js +493 -128
  2. package/package.json +1 -1
package/dist/tobos.js CHANGED
@@ -47,7 +47,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
47
47
  var define_TOBOS_PRESENT_TYPES_default;
48
48
  var init_define_TOBOS_PRESENT_TYPES = __esm({
49
49
  "<define:TOBOS_PRESENT_TYPES>"() {
50
- define_TOBOS_PRESENT_TYPES_default = { "registry.d.ts": "/** State the viewer sets up before any scene loads, and the scene API reads. */\nexport declare function setMedia(media: Record<string, {\n hash: string;\n}>): void;\nexport declare function mediaUrl(name: string): string;\n", "timeline.d.ts": "import type { Beat } from './index.ts';\n/**\n * Whether the scene timeline that holds this animation is playing a step forward, in real\n * time, as opposed to being sought (a jump, a step back, a finish, a still view or a render).\n */\nexport declare function playingForward(animation: gsap.core.Animation): boolean;\n/**\n * One scene's beats as one paused GSAP timeline, with a label after each beat's animation.\n * Stepping forward tweens the playhead to the next label; everything else seeks.\n */\nexport declare class SceneTimeline {\n readonly timeline: gsap.core.Timeline;\n private labels;\n private tween;\n constructor(root: Element, beats: readonly Beat[]);\n get playing(): boolean;\n /** Finish the beat that is playing, at once. */\n finish(): void;\n /** Before the first beat: the scene waiting for its entrance. */\n hold(): void;\n /** Show a beat: play the animation into it, or land on its end state. */\n show(beat: number, animate: boolean): void;\n /** Put the playhead part-way through the animation into a beat (0..1), for filmstrips. */\n sample(beat: number, progress: number): void;\n /** How long the animation into a beat takes, in seconds. */\n duration(beat: number): number;\n kill(): void;\n}\n", "video.d.ts": "export interface PlayVideoOptions {\n /** Where the clip starts in the video, in seconds. Default 0. */\n from?: number;\n /** Where the clip ends in the video, in seconds. Default: the end of the video. */\n to?: number;\n /** Speed: 1 is real time, 0.5 half speed. Default 1. */\n rate?: number;\n /**\n * When the clip starts within the beat: GSAP's position parameter (`'<'`, `'+=0.5'`, a\n * number). Default: after what the beat has animated so far, like any `tl.to`.\n */\n position?: gsap.Position;\n}\n/**\n * Play a video (or the clip `from`\u2013`to` of it) as part of a beat. Stepping forward plays it in\n * real time; going back, jumping or reloading shows the frame for that position at once; a\n * click while it plays lands on its last frame. Before its beat it shows the clip's first frame.\n *\n * ```ts\n * { id: 'turn', enter: (tl, q) => playVideo(tl, q('video')) }\n * ```\n *\n * The video is muted, plays inline and preloads. Several videos (`q('video')` finding more\n * than one) play side by side, each its own length.\n */\nexport declare function playVideo(tl: gsap.core.Timeline, target: Element | ArrayLike<Element> | null | undefined, options?: PlayVideoOptions): gsap.core.Timeline;\n/**\n * Wait until the videos inside `root` know their length, so `playVideo` can size their clips\n * when the scene's timeline is built. Videos that won't load (no source, `preload=\"none\"`, an\n * error) don't hold it up, nor does anything past `timeout`.\n */\nexport declare function videosKnowTheirLength(root: Element, timeout?: number): Promise<void>;\n/**\n * Wait until every video inside `root` shows the frame it was last sought to: no seek pending,\n * and a frame decoded. Videos that won't load don't hold it up.\n */\nexport declare function videoFramesReady(root: Element): Promise<void>;\n", "index.d.ts": `export { playVideo, type PlayVideoOptions } from './video.ts';
50
+ define_TOBOS_PRESENT_TYPES_default = { "registry.d.ts": "/** State the viewer sets up before any scene loads, and the scene API reads. */\nexport declare function setMedia(media: Record<string, {\n hash: string;\n}>): void;\nexport declare function mediaUrl(name: string): string;\n/** The deck's join code, and the ways to show it. */\nexport interface JoinInfo {\n /** The six digits: `482913`. */\n code: string;\n /** The link as people type it, without the scheme: `tobosusercontent.com/482913`. */\n link: string;\n /** The full URL the QR code holds: `https://tobosusercontent.com/482913`. */\n url: string;\n /** The QR code, black on white, as an image's address: `<img src={join.qr} />`. */\n qr: string;\n}\nexport declare function setJoin(info: JoinInfo | undefined): void;\nexport declare function joinInfo(): JoinInfo | undefined;\n/** Whether this is a share link's page, for people outside the deck's account. */\nexport declare function setShared(value: boolean): void;\nexport declare function isShared(): boolean;\n", "timeline.d.ts": "import type { Beat } from './index.ts';\n/**\n * Whether the scene timeline that holds this animation is playing a step forward, in real\n * time, as opposed to being sought (a jump, a step back, a finish, a still view or a render).\n */\nexport declare function playingForward(animation: gsap.core.Animation): boolean;\n/**\n * One scene's beats as one paused GSAP timeline, with a label after each beat's animation.\n * Stepping forward tweens the playhead to the next label; everything else seeks.\n */\nexport declare class SceneTimeline {\n readonly timeline: gsap.core.Timeline;\n private labels;\n private tween;\n constructor(root: Element, beats: readonly Beat[]);\n get playing(): boolean;\n /** Finish the beat that is playing, at once. */\n finish(): void;\n /** Before the first beat: the scene waiting for its entrance. */\n hold(): void;\n /** Show a beat: play the animation into it, or land on its end state. */\n show(beat: number, animate: boolean): void;\n /** Put the playhead part-way through the animation into a beat (0..1), for filmstrips. */\n sample(beat: number, progress: number): void;\n /** How long the animation into a beat takes, in seconds. */\n duration(beat: number): number;\n kill(): void;\n}\n", "video.d.ts": "export interface PlayVideoOptions {\n /** Where the clip starts in the video, in seconds. Default 0. */\n from?: number;\n /** Where the clip ends in the video, in seconds. Default: the end of the video. */\n to?: number;\n /** Speed: 1 is real time, 0.5 half speed. Default 1. */\n rate?: number;\n /**\n * When the clip starts within the beat: GSAP's position parameter (`'<'`, `'+=0.5'`, a\n * number). Default: after what the beat has animated so far, like any `tl.to`.\n */\n position?: gsap.Position;\n}\n/**\n * Play a video (or the clip `from`\u2013`to` of it) as part of a beat. Stepping forward plays it in\n * real time; going back, jumping or reloading shows the frame for that position at once; a\n * click while it plays lands on its last frame. Before its beat it shows the clip's first frame.\n *\n * ```ts\n * { id: 'turn', enter: (tl, q) => playVideo(tl, q('video')) }\n * ```\n *\n * The video is muted, plays inline and preloads. Several videos (`q('video')` finding more\n * than one) play side by side, each its own length.\n */\nexport declare function playVideo(tl: gsap.core.Timeline, target: Element | ArrayLike<Element> | null | undefined, options?: PlayVideoOptions): gsap.core.Timeline;\n/**\n * Wait until the videos inside `root` know their length, so `playVideo` can size their clips\n * when the scene's timeline is built. Videos that won't load (no source, `preload=\"none\"`, an\n * error) don't hold it up, nor does anything past `timeout`.\n */\nexport declare function videosKnowTheirLength(root: Element, timeout?: number): Promise<void>;\n/**\n * Wait until every video inside `root` shows the frame it was last sought to: no seek pending,\n * and a frame decoded. Videos that won't load don't hold it up.\n */\nexport declare function videoFramesReady(root: Element): Promise<void>;\n", "deck/types.d.ts": "export type Severity = 'error' | 'warning';\n/** One thing wrong with a deck. Lines and columns are 1-based. */\nexport interface Problem {\n file: string;\n line?: number;\n column?: number;\n rule: string;\n message: string;\n severity: Severity;\n}\nexport interface DeckScene {\n id: string;\n title: string;\n /** A line about the scene, for the people working on the deck (a template's gallery shows it). */\n note?: string;\n}\nexport interface DeckChapter {\n id: string;\n title: string;\n scenes: DeckScene[];\n}\n/** deck.json */\nexport interface DeckJson {\n title: string;\n chapters: DeckChapter[];\n dependencies?: Record<string, string>;\n}\nexport interface MediaEntry {\n hash: string;\n size: number;\n type: string;\n}\n/** media.json: path inside media/ \u2192 the file's content hash. */\nexport type MediaJson = Record<string, MediaEntry>;\n/** A poll: each phone picks one option. Its result shows on the projector from `reveals` on. */\nexport interface ChoiceActivity {\n id: string;\n kind: 'choice';\n prompt: string;\n options: string[];\n /** The beat of its scene that closes the poll and shows its result. */\n reveals?: string;\n}\nexport interface TextField {\n id: string;\n label: string;\n multiline?: boolean;\n /** The most characters it takes. 500 unless the scene says otherwise; in a manifest, always set. */\n max?: number;\n}\n/** A form: each phone fills in its fields. The answers are only stored. */\nexport interface TextActivity {\n id: string;\n kind: 'text';\n prompt?: string;\n fields: TextField[];\n}\n/**\n * Something the room responds to on their phones, declared by a scene. It is open while the\n * deck is presented on its scene, up to its `reveals` beat.\n */\nexport type Activity = ChoiceActivity | TextActivity;\nexport interface ManifestScene {\n id: string;\n title: string;\n note?: string;\n beats: string[];\n /** The scene's specifier in the import map. */\n module: string;\n activity?: Activity;\n}\nexport interface ManifestChapter {\n id: string;\n title: string;\n scenes: ManifestScene[];\n}\n/** What the viewer needs to show one revision of a deck. */\nexport interface Manifest {\n format: 1;\n title: string;\n chapters: ManifestChapter[];\n /**\n * Deck specifiers (`@deck/scenes/a.svelte`) \u2192 module paths relative to the viewer (`m/<hash>.js`).\n * The server adds the package specifiers once it has bundled them (`d3` \u2192 `p/<bundle>/d3.js`).\n */\n imports: Record<string, string>;\n media: MediaJson;\n /** deck.json's dependencies: package \u2192 exact version. */\n dependencies: Record<string, string>;\n /** The package specifiers the deck imports, by dependency: `{ three: ['three', 'three/addons/\u2026'] }`. */\n packages: Record<string, string[]>;\n /**\n * Stylesheets, relative to the viewer: the master's tokens.css (`m/<hash>.css`), then those of\n * the packages it imports (`p/<bundle>/katex/dist/katex.min.css`), which the server adds.\n */\n styles?: string[];\n}\n/** A deck's files, from a directory or from a git revision. Paths use `/` and have no leading slash. */\nexport interface DeckTree {\n files(): string[];\n read(path: string): Uint8Array | undefined;\n}\n", "activities.d.ts": "/** What the server tells about a deck's activities: phones what is open, the projector the results. */\n/** An activity as a phone needs it: no more. */\nexport type PhoneActivity = {\n id: string;\n kind: 'choice';\n prompt: string;\n options: string[];\n} | {\n id: string;\n kind: 'text';\n prompt?: string;\n fields: {\n id: string;\n label: string;\n multiline?: boolean;\n max: number;\n }[];\n};\n/** Nothing live, or the show and its open activity, if any. */\nexport type PhoneState = {\n live: false;\n} | {\n live: true;\n show: string;\n activity: PhoneActivity | null;\n};\n/** What the projector hears: the show, and every activity answered in it. */\nexport interface Results {\n show: string | null;\n joined: number;\n activities: Record<string, {\n answered: number;\n counts?: number[];\n }>;\n}\n", "responses.svelte.d.ts": "/**\n * What the room has answered, for the projector: the audience and presenter windows, and the\n * preview on the deck's page, follow it from the server. Print and render, and a link that isn't\n * a presenter's, have zeros. It is live data, which the position can't recreate.\n */\nimport type { Manifest } from '@tobos/deck/types';\nimport type { Results } from './activities.ts';\n/** One activity's responses in the current show. */\nexport interface Responses {\n /** People whose phones opened the deck's join link during this show. */\n readonly joined: number;\n /** People who have answered this activity during this show. */\n readonly answered: number;\n /** A poll's responses per option, in the order the scene declares them. A form's is empty. */\n readonly counts: number[];\n}\n/** The deck's activities, so a poll nobody answered yet has a zero per option. */\nexport declare function setActivities(manifest: Manifest): void;\n/** The current show's responses: reactive, for a scene or the presenter's view. */\nexport declare function liveResults(): Readonly<Results>;\n/**\n * The room's responses to an activity of this deck in the current show: how many joined, how\n * many answered, and a poll's counts per option. Call during component setup.\n */\nexport declare function useResponses(id: string): Responses;\n/** Follow the server's results stream (server-sent events) until the returned function is called. */\nexport declare function followResponses(url: string): () => void;\n", "index.d.ts": `import { type Component } from 'svelte';
51
+ import { type JoinInfo } from './registry.ts';
52
+ export { playVideo, type PlayVideoOptions } from './video.ts';
53
+ export { useResponses, type Responses } from './responses.svelte.ts';
54
+ export type { Activity, ChoiceActivity, TextActivity, TextField } from '@tobos/deck/types';
51
55
  /** Finds elements inside the current scene only. */
52
56
  export type Query = (selector: string) => Element[];
53
57
  /** One click's worth of a scene: an ID, and the animation into it. */
@@ -88,6 +92,22 @@ export declare const DECK_CONTEXT = "tobos:deck";
88
92
  export declare function useDeck(): DeckContext;
89
93
  /** The URL of a file in the deck's media/ folder. The name must be a string literal. */
90
94
  export declare function media(name: string): string;
95
+ export type { JoinInfo } from './registry.ts';
96
+ /**
97
+ * The deck's join code, for a scene to show its own way: the digits, the link as people type
98
+ * it, the full URL, and the QR code as an image's address. Undefined while the deck has no
99
+ * activity.
100
+ */
101
+ export declare function useJoin(): JoinInfo | undefined;
102
+ export interface JoinCodeProps {
103
+ /** The QR code's width and height, in stage pixels. */
104
+ size?: number;
105
+ }
106
+ /**
107
+ * The deck's join code: a QR code, and under it the link it holds, which phones open to answer
108
+ * the deck's activities. The scene sizes it; the link takes the scene's font.
109
+ */
110
+ export declare const JoinCode: Component<JoinCodeProps>;
91
111
  ` };
92
112
  }
93
113
  });
@@ -96,7 +116,7 @@ export declare function media(name: string): string;
96
116
  var define_TOBOS_SKILL_default;
97
117
  var init_define_TOBOS_SKILL = __esm({
98
118
  "<define:TOBOS_SKILL>"() {
99
- 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 that you write as code: one Svelte 5 file per scene, with beats (one click each) and GSAP animations. You build; Tobos checks every push, hosts the deck, and puts it on stage with a presenter view. There is no AI on Tobos's side and no MCP server: everything goes through the `tobos` command and git.\n\n## Set up (once per machine)\n\n```sh\nnpm i -g @tobos/cli # the `tobos` command; needs Node 22.18+ and git\ntobos login you@example.com # e-mails the person a 6-digit code (and signs them up if new)\ntobos login --code 123456 # the code they paste to you from the mail\n```\n\nAsk the person for their e-mail address first, then for the code in one line: it's in their e-mail, maybe in spam, and using it accepts https://tobos.ai/terms. Only they can read it; never guess or reuse one. It works for 10 minutes. In CI, set `TOBOS_TOKEN` instead.\n\n## Start or continue a deck\n\n```sh\ntobos decks # the decks you can work on\ntobos new \"Title of the talk\" # create one and clone it into ./<slug>\ntobos clone account/deck # or clone an existing one\n```\n\nThen **read the deck's `AGENTS.md`**. It, `.tobos/FORMAT.md` and `master/GUIDE.md` are the instructions for everything that follows: the loop (`check` \u2192 `render` \u2192 look \u2192 `push`), the format, the slide master's layouts and rules.\n\n## Follow the person\n\nThey decide what to make and how much you do: some build a deck one scene at a time, some want all of it at once. Do what they ask, at the size they ask. Don't ask what a talk is about, who it's for or how long it runs, and don't propose an outline they didn't ask for.\n\n## Commands\n\n| Command | Does |\n| -------------------------------------------------------- | ------------------------------------------------------ |\n| `tobos check` | compile and check the deck, offline |\n| `tobos push -m \"\u2026\"` | upload media, commit, push; the server checks it again |\n| `tobos render scene/beat` \xB7 `scene` \xB7 `--all` \xB7 `--film` | PNGs of beats; pushes what changed first |\n| `tobos open [scene/beat] [--presenter]` | the deck in a browser; pushes what changed first |\n| `tobos open` (outside a deck) | Tobos in the browser, logged in: decks and templates |\n| `tobos export pdf` | a PDF of every beat |\n\nEvery command takes `--json`. Exit codes: 0 ok, 1 error, 2 the deck has problems, 3 not logged in.\n\nWhen a command says a newer `tobos` is out, run `npm i -g @tobos/cli`; the next command updates this skill. When a plan's limit stops a command (Free hosts 3 decks), the error links to the billing page: give the person the link, since only they can buy Pro.\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 that you write as code: one Svelte 5 file per scene, with beats (one click each) and GSAP animations. You build; Tobos checks every push, hosts the deck, and puts it on stage with a presenter view. There is no AI on Tobos's side and no MCP server: everything goes through the `tobos` command and git.\n\n## Set up (once per machine)\n\n```sh\nnpm i -g @tobos/cli # the `tobos` command; needs Node 22.18+ and git\ntobos login you@example.com # e-mails the person a 6-digit code (and signs them up if new)\ntobos login --code 123456 # the code they paste to you from the mail\n```\n\nAsk the person for their e-mail address first, then for the code in one line: it's in their e-mail, maybe in spam, and using it accepts https://tobos.ai/terms. Only they can read it; never guess or reuse one. It works for 10 minutes. In CI, set `TOBOS_TOKEN` instead.\n\n## Start or continue a deck\n\n```sh\ntobos decks # the decks you can work on, by id\ntobos new \"Title of the talk\" # create one and clone it into ./<id>\ntobos clone <id> # or clone an existing one\n```\n\nThen **read the deck's `AGENTS.md`**. It, `.tobos/FORMAT.md` and `master/GUIDE.md` are the instructions for everything that follows: the loop (`check` \u2192 `render` \u2192 look \u2192 `push`), the format, the slide master's layouts and rules.\n\n## Follow the person\n\nThey decide what to make and how much you do: some build a deck one scene at a time, some want all of it at once. Do what they ask, at the size they ask. Don't ask what a talk is about, who it's for or how long it runs, and don't propose an outline they didn't ask for.\n\n## Polls and forms\n\nA scene can ask the room a poll or a short form, which people answer on their phones through the deck's join code: `<JoinCode/>` shows its QR code, and the poll's result shows on the projector at a beat you choose. See \"Activities\" in the deck's `.tobos/FORMAT.md`. The responses download from the deck's page as a CSV per show (one class or talk): a row per phone, a column per question.\n\n## The story\n\nA deck has one story: the talk as the speaker tells it, paragraph by paragraph, with scenes mentioned as Markdown links, `[Dartmouth College](scene:same-problem)`, or one of their beats, `[Dartmouth College](scene:same-problem/quote)` (the ids from deck.json; the label is the scene's title). What follows a mention, up to the next, is that scene's: the deck's page shows it under the stage, and the presenter sees it as speaker notes. The server holds it, not git, so there is no file to edit: the person types in it live on the deck's page, and you change it with `tobos story`, which reads and writes it on the server.\n\n- `tobos story` prints it with a \xB6 id per paragraph (`p4`). Read it again before each change: the person may be typing.\n- Your changes apply at once, as the person's do, and the deck's page marks what you wrote. Change what the person asked you to, and leave the rest of their words as they are.\n- An edit is anchored on the exact text it replaces, which has to occur once in the paragraph. If someone changed it meanwhile, the command exits with code 4 and the paragraph as it is now: anchor on that and try again.\n- Set `TOBOS_AGENT` to your name (`claude`, `codex`): the page shows who wrote what.\n\n## Commands\n\n| Command | Does |\n| -------------------------------------------------------- | ------------------------------------------------------ |\n| `tobos check` | compile and check the deck, offline |\n| `tobos push -m \"\u2026\"` | upload media, commit, push; the server checks it again |\n| `tobos render scene/beat` \xB7 `scene` \xB7 `--all` \xB7 `--film` | PNGs of beats; pushes what changed first |\n| `tobos open [scene/beat] [--presenter]` | the deck in a browser; pushes what changed first |\n| `tobos open` (outside a deck) | Tobos in the browser, logged in: decks and templates |\n| `tobos export pdf` | a PDF of every beat |\n| `tobos story` | the story, by \xB6 id |\n| `tobos story edit <\xB6> \"old\" \"new\"` | change it, anchored on the exact text |\n| `tobos story add [--after <\xB6>] \"\u2026\"` \xB7 `delete <\xB6>` | add a paragraph, or delete one |\n\nEvery command takes `--json`. Exit codes: 0 ok, 1 error, 2 the deck has problems, 3 not logged in, 4 the story changed meanwhile.\n\nWhen a command says a newer `tobos` is out, run `npm i -g @tobos/cli`; the next command updates this skill. When a plan's limit stops a command (Free hosts 3 decks), the error links to the billing page: give the person the link, since only they can buy Pro.\n" };
100
120
  }
101
121
  });
102
122
 
@@ -128,7 +148,7 @@ var init_out = __esm({
128
148
  "use strict";
129
149
  init_define_TOBOS_PRESENT_TYPES();
130
150
  init_define_TOBOS_SKILL();
131
- EXIT = { ok: 0, error: 1, problems: 2, auth: 3 };
151
+ EXIT = { ok: 0, error: 1, problems: 2, auth: 3, conflict: 4 };
132
152
  CliError = class extends Error {
133
153
  exit;
134
154
  extra;
@@ -3440,8 +3460,8 @@ var init_acorn = __esm({
3440
3460
  node.body.push(stmt2);
3441
3461
  }
3442
3462
  if (this.inModule) {
3443
- for (var i2 = 0, list4 = Object.keys(this.undefinedExports); i2 < list4.length; i2 += 1) {
3444
- var name = list4[i2];
3463
+ for (var i2 = 0, list5 = Object.keys(this.undefinedExports); i2 < list5.length; i2 += 1) {
3464
+ var name = list5[i2];
3445
3465
  this.raiseRecoverable(this.undefinedExports[name].start, "Export '" + name + "' is not defined");
3446
3466
  }
3447
3467
  }
@@ -3926,8 +3946,8 @@ var init_acorn = __esm({
3926
3946
  return this.finishNode(node, "EmptyStatement");
3927
3947
  };
3928
3948
  pp$8.parseLabeledStatement = function(node, maybeName, expr, context) {
3929
- for (var i$1 = 0, list4 = this.labels; i$1 < list4.length; i$1 += 1) {
3930
- var label = list4[i$1];
3949
+ for (var i$1 = 0, list5 = this.labels; i$1 < list5.length; i$1 += 1) {
3950
+ var label = list5[i$1];
3931
3951
  if (label.name === maybeName) {
3932
3952
  this.raise(expr.start, "Label '" + maybeName + "' is already declared");
3933
3953
  }
@@ -4329,8 +4349,8 @@ var init_acorn = __esm({
4329
4349
  node.attributes = this.parseWithClause();
4330
4350
  }
4331
4351
  } else {
4332
- for (var i2 = 0, list4 = node.specifiers; i2 < list4.length; i2 += 1) {
4333
- var spec = list4[i2];
4352
+ for (var i2 = 0, list5 = node.specifiers; i2 < list5.length; i2 += 1) {
4353
+ var spec = list5[i2];
4334
4354
  this.checkUnreserved(spec.local);
4335
4355
  this.checkLocalExport(spec.local);
4336
4356
  if (spec.local.type === "Literal") {
@@ -4384,8 +4404,8 @@ var init_acorn = __esm({
4384
4404
  if (type === "Identifier") {
4385
4405
  this.checkExport(exports$1, pat, pat.start);
4386
4406
  } else if (type === "ObjectPattern") {
4387
- for (var i2 = 0, list4 = pat.properties; i2 < list4.length; i2 += 1) {
4388
- var prop2 = list4[i2];
4407
+ for (var i2 = 0, list5 = pat.properties; i2 < list5.length; i2 += 1) {
4408
+ var prop2 = list5[i2];
4389
4409
  this.checkPatternExport(exports$1, prop2);
4390
4410
  }
4391
4411
  } else if (type === "ArrayPattern") {
@@ -4407,8 +4427,8 @@ var init_acorn = __esm({
4407
4427
  if (!exports$1) {
4408
4428
  return;
4409
4429
  }
4410
- for (var i2 = 0, list4 = decls; i2 < list4.length; i2 += 1) {
4411
- var decl = list4[i2];
4430
+ for (var i2 = 0, list5 = decls; i2 < list5.length; i2 += 1) {
4431
+ var decl = list5[i2];
4412
4432
  this.checkPatternExport(exports$1, decl.id);
4413
4433
  }
4414
4434
  };
@@ -4585,8 +4605,8 @@ var init_acorn = __esm({
4585
4605
  if (refDestructuringErrors) {
4586
4606
  this.checkPatternErrors(refDestructuringErrors, true);
4587
4607
  }
4588
- for (var i2 = 0, list4 = node.properties; i2 < list4.length; i2 += 1) {
4589
- var prop2 = list4[i2];
4608
+ for (var i2 = 0, list5 = node.properties; i2 < list5.length; i2 += 1) {
4609
+ var prop2 = list5[i2];
4590
4610
  this.toAssignable(prop2, isBinding);
4591
4611
  if (prop2.type === "RestElement" && (prop2.argument.type === "ArrayPattern" || prop2.argument.type === "ObjectPattern")) {
4592
4612
  this.raise(prop2.argument.start, "Unexpected token");
@@ -4773,8 +4793,8 @@ var init_acorn = __esm({
4773
4793
  if (bindingType === void 0) bindingType = BIND_NONE;
4774
4794
  switch (expr.type) {
4775
4795
  case "ObjectPattern":
4776
- for (var i2 = 0, list4 = expr.properties; i2 < list4.length; i2 += 1) {
4777
- var prop2 = list4[i2];
4796
+ for (var i2 = 0, list5 = expr.properties; i2 < list5.length; i2 += 1) {
4797
+ var prop2 = list5[i2];
4778
4798
  this.checkLValInnerPattern(prop2, bindingType, checkClashes);
4779
4799
  }
4780
4800
  break;
@@ -5873,8 +5893,8 @@ var init_acorn = __esm({
5873
5893
  this.exitScope();
5874
5894
  };
5875
5895
  pp$5.isSimpleParamList = function(params) {
5876
- for (var i2 = 0, list4 = params; i2 < list4.length; i2 += 1) {
5877
- var param = list4[i2];
5896
+ for (var i2 = 0, list5 = params; i2 < list5.length; i2 += 1) {
5897
+ var param = list5[i2];
5878
5898
  if (param.type !== "Identifier") {
5879
5899
  return false;
5880
5900
  }
@@ -5883,8 +5903,8 @@ var init_acorn = __esm({
5883
5903
  };
5884
5904
  pp$5.checkParams = function(node, allowDuplicates) {
5885
5905
  var nameHash = /* @__PURE__ */ Object.create(null);
5886
- for (var i2 = 0, list4 = node.params; i2 < list4.length; i2 += 1) {
5887
- var param = list4[i2];
5906
+ for (var i2 = 0, list5 = node.params; i2 < list5.length; i2 += 1) {
5907
+ var param = list5[i2];
5888
5908
  this.checkLValInnerPattern(param, BIND_VAR, allowDuplicates ? null : nameHash);
5889
5909
  }
5890
5910
  };
@@ -6297,8 +6317,8 @@ var init_acorn = __esm({
6297
6317
  RegExpValidationState.prototype.eatChars = function eatChars(chs, forceU) {
6298
6318
  if (forceU === void 0) forceU = false;
6299
6319
  var pos = this.pos;
6300
- for (var i2 = 0, list4 = chs; i2 < list4.length; i2 += 1) {
6301
- var ch = list4[i2];
6320
+ for (var i2 = 0, list5 = chs; i2 < list5.length; i2 += 1) {
6321
+ var ch = list5[i2];
6302
6322
  var current2 = this.at(pos, forceU);
6303
6323
  if (current2 === -1 || current2 !== ch) {
6304
6324
  return false;
@@ -6370,8 +6390,8 @@ var init_acorn = __esm({
6370
6390
  if (state.maxBackReference > state.numCapturingParens) {
6371
6391
  state.raise("Invalid escape");
6372
6392
  }
6373
- for (var i2 = 0, list4 = state.backReferenceNames; i2 < list4.length; i2 += 1) {
6374
- var name = list4[i2];
6393
+ for (var i2 = 0, list5 = state.backReferenceNames; i2 < list5.length; i2 += 1) {
6394
+ var name = list5[i2];
6375
6395
  if (!state.groupNames[name]) {
6376
6396
  state.raise("Invalid named capture referenced");
6377
6397
  }
@@ -6695,8 +6715,8 @@ var init_acorn = __esm({
6695
6715
  var known = state.groupNames[state.lastStringValue];
6696
6716
  if (known) {
6697
6717
  if (trackDisjunction) {
6698
- for (var i2 = 0, list4 = known; i2 < list4.length; i2 += 1) {
6699
- var altID = list4[i2];
6718
+ for (var i2 = 0, list5 = known; i2 < list5.length; i2 += 1) {
6719
+ var altID = list5[i2];
6700
6720
  if (!altID.separatedFrom(state.branchID)) {
6701
6721
  state.raise("Duplicate capture group name");
6702
6722
  }
@@ -14342,8 +14362,8 @@ function event_handler_invalid_component_modifier(node) {
14342
14362
  e(node, "event_handler_invalid_component_modifier", `Event modifiers other than 'once' can only be used on DOM elements
14343
14363
  https://svelte.dev/e/event_handler_invalid_component_modifier`);
14344
14364
  }
14345
- function event_handler_invalid_modifier(node, list4) {
14346
- e(node, "event_handler_invalid_modifier", `Valid event modifiers are ${list4}
14365
+ function event_handler_invalid_modifier(node, list5) {
14366
+ e(node, "event_handler_invalid_modifier", `Valid event modifiers are ${list5}
14347
14367
  https://svelte.dev/e/event_handler_invalid_modifier`);
14348
14368
  }
14349
14369
  function event_handler_invalid_modifier_combination(node, modifier1, modifier2) {
@@ -14534,8 +14554,8 @@ function svelte_meta_invalid_placement(node, name) {
14534
14554
  e(node, "svelte_meta_invalid_placement", `\`<${name}>\` tags cannot be inside elements or blocks
14535
14555
  https://svelte.dev/e/svelte_meta_invalid_placement`);
14536
14556
  }
14537
- function svelte_meta_invalid_tag(node, list4) {
14538
- e(node, "svelte_meta_invalid_tag", `Valid \`<svelte:...>\` tag names are ${list4}
14557
+ function svelte_meta_invalid_tag(node, list5) {
14558
+ e(node, "svelte_meta_invalid_tag", `Valid \`<svelte:...>\` tag names are ${list5}
14539
14559
  https://svelte.dev/e/svelte_meta_invalid_tag`);
14540
14560
  }
14541
14561
  function svelte_options_deprecated_tag(node) {
@@ -14546,8 +14566,8 @@ function svelte_options_invalid_attribute(node) {
14546
14566
  e(node, "svelte_options_invalid_attribute", `\`<svelte:options>\` can only receive static attributes
14547
14567
  https://svelte.dev/e/svelte_options_invalid_attribute`);
14548
14568
  }
14549
- function svelte_options_invalid_attribute_value(node, list4) {
14550
- e(node, "svelte_options_invalid_attribute_value", `Value must be ${list4}, if specified
14569
+ function svelte_options_invalid_attribute_value(node, list5) {
14570
+ e(node, "svelte_options_invalid_attribute_value", `Value must be ${list5}, if specified
14551
14571
  https://svelte.dev/e/svelte_options_invalid_attribute_value`);
14552
14572
  }
14553
14573
  function svelte_options_invalid_customelement(node) {
@@ -38398,8 +38418,8 @@ function validate_element(node, context) {
38398
38418
  let conflicting_passive_modifier = "";
38399
38419
  for (const modifier of attribute.modifiers) {
38400
38420
  if (!EVENT_MODIFIERS.includes(modifier)) {
38401
- const list4 = `${EVENT_MODIFIERS.slice(0, -1).join(", ")} or ${EVENT_MODIFIERS.at(-1)}`;
38402
- event_handler_invalid_modifier(attribute, list4);
38421
+ const list5 = `${EVENT_MODIFIERS.slice(0, -1).join(", ")} or ${EVENT_MODIFIERS.at(-1)}`;
38422
+ event_handler_invalid_modifier(attribute, list5);
38403
38423
  }
38404
38424
  if (modifier === "passive") {
38405
38425
  has_passive_modifier = true;
@@ -55183,6 +55203,17 @@ var init_compiler = __esm({
55183
55203
  }
55184
55204
  });
55185
55205
 
55206
+ // ../deck/src/activity.ts
55207
+ var TEXT_MAX;
55208
+ var init_activity = __esm({
55209
+ "../deck/src/activity.ts"() {
55210
+ "use strict";
55211
+ init_define_TOBOS_PRESENT_TYPES();
55212
+ init_define_TOBOS_SKILL();
55213
+ TEXT_MAX = 500;
55214
+ }
55215
+ });
55216
+
55186
55217
  // ../deck/src/tree.ts
55187
55218
  function readText(tree, path) {
55188
55219
  const bytes = tree.read(path);
@@ -55245,7 +55276,7 @@ function readBeats(file2, source2, module) {
55245
55276
  ]
55246
55277
  });
55247
55278
  if (!module) return missing();
55248
- let list4;
55279
+ let list5;
55249
55280
  for (const statement of module.content.body) {
55250
55281
  if (statement.type !== "ExportNamedDeclaration") continue;
55251
55282
  const declaration2 = statement.declaration;
@@ -55254,23 +55285,23 @@ function readBeats(file2, source2, module) {
55254
55285
  const id2 = declarator2.id;
55255
55286
  if (id2.type === "Identifier" && id2.name === "beats") {
55256
55287
  if (declaration2.kind !== "const") at2(declarator2, "`beats` must be declared with const.");
55257
- list4 = unwrap(declarator2.init);
55258
- if (!list4) at2(declarator2, "`beats` needs a value.");
55288
+ list5 = unwrap(declarator2.init);
55289
+ if (!list5) at2(declarator2, "`beats` needs a value.");
55259
55290
  }
55260
55291
  }
55261
55292
  }
55262
- if (!list4) return problems.length ? { problems } : missing();
55263
- if (list4.type !== "ArrayExpression") {
55264
- at2(list4, "`beats` must be an array literal, so Tobos can read it without running the scene.");
55293
+ if (!list5) return problems.length ? { problems } : missing();
55294
+ if (list5.type !== "ArrayExpression") {
55295
+ at2(list5, "`beats` must be an array literal, so Tobos can read it without running the scene.");
55265
55296
  return { problems };
55266
55297
  }
55267
55298
  const beats = [];
55268
55299
  const seen2 = /* @__PURE__ */ new Set();
55269
- for (const element2 of list4.elements) {
55300
+ for (const element2 of list5.elements) {
55270
55301
  const beat = unwrap(element2 ?? void 0);
55271
55302
  if (!beat || beat.type !== "ObjectExpression") {
55272
55303
  at2(
55273
- element2 ?? list4,
55304
+ element2 ?? list5,
55274
55305
  'Each beat must be an object literal: `{ id: "\u2026", enter: (tl, q) => \u2026 }`.'
55275
55306
  );
55276
55307
  continue;
@@ -55299,9 +55330,226 @@ function readBeats(file2, source2, module) {
55299
55330
  seen2.add(id2);
55300
55331
  beats.push({ id: id2, line: position2(source2, value.start).line });
55301
55332
  }
55302
- if (beats.length === 0 && problems.length === 0) at2(list4, "A scene needs at least one beat.");
55333
+ if (beats.length === 0 && problems.length === 0) at2(list5, "A scene needs at least one beat.");
55303
55334
  return { beats, problems };
55304
55335
  }
55336
+ function readLiteral(node) {
55337
+ const value = unwrap(node);
55338
+ if (value.type === "Literal" && ["string", "number", "boolean"].includes(typeof value.value))
55339
+ return { node: value, value: value.value };
55340
+ if (value.type === "TemplateLiteral" && value.expressions.length === 0)
55341
+ return {
55342
+ node: value,
55343
+ value: value.quasis[0].value.cooked ?? ""
55344
+ };
55345
+ if (value.type === "ArrayExpression") {
55346
+ const items = [];
55347
+ for (const element2 of value.elements) {
55348
+ if (!element2 || element2.type === "SpreadElement") return { bad: element2 ?? value };
55349
+ const item = readLiteral(element2);
55350
+ if ("bad" in item) return item;
55351
+ items.push(item);
55352
+ }
55353
+ return { node: value, value: items };
55354
+ }
55355
+ if (value.type === "ObjectExpression") {
55356
+ const props = /* @__PURE__ */ new Map();
55357
+ for (const prop2 of value.properties) {
55358
+ const key2 = prop2.key;
55359
+ const name = key2?.type === "Identifier" ? key2.name : key2?.type === "Literal" && typeof key2.value === "string" ? key2.value : void 0;
55360
+ if (prop2.type !== "Property" || prop2.computed || prop2.kind !== "init" || prop2.method)
55361
+ return { bad: prop2 };
55362
+ if (name === void 0) return { bad: prop2 };
55363
+ const item = readLiteral(prop2.value);
55364
+ if ("bad" in item) return item;
55365
+ props.set(name, item);
55366
+ }
55367
+ return { node: value, value: props };
55368
+ }
55369
+ return { bad: value };
55370
+ }
55371
+ function readActivity(file2, source2, module, beats) {
55372
+ const problems = [];
55373
+ const at2 = (node, message) => problems.push({
55374
+ file: file2,
55375
+ ...position2(source2, node.start),
55376
+ rule: "activity",
55377
+ message,
55378
+ severity: "error"
55379
+ });
55380
+ let init3;
55381
+ for (const statement of module?.content?.body ?? []) {
55382
+ const declaration2 = statement.declaration;
55383
+ if (statement.type !== "ExportNamedDeclaration" || declaration2?.type !== "VariableDeclaration")
55384
+ continue;
55385
+ for (const declarator2 of declaration2.declarations) {
55386
+ const id3 = declarator2.id;
55387
+ if (id3.type !== "Identifier" || id3.name !== "activity") continue;
55388
+ if (declaration2.kind !== "const") at2(declarator2, "`activity` must be declared with const.");
55389
+ init3 = unwrap(declarator2.init);
55390
+ if (!init3) at2(declarator2, "`activity` needs a value.");
55391
+ }
55392
+ }
55393
+ if (!init3 || problems.length) return { problems };
55394
+ if (init3.type !== "ObjectExpression") {
55395
+ at2(
55396
+ init3,
55397
+ "`activity` must be an object literal, so Tobos can read it without running the scene."
55398
+ );
55399
+ return { problems };
55400
+ }
55401
+ const read2 = readLiteral(init3);
55402
+ if ("bad" in read2) {
55403
+ at2(
55404
+ read2.bad,
55405
+ "`activity` may hold only string, number and boolean literals, and arrays and objects of them, so Tobos can read it without running the scene."
55406
+ );
55407
+ return { problems };
55408
+ }
55409
+ const props = read2.value;
55410
+ const text3 = (literal3) => typeof literal3?.value === "string" ? literal3.value : void 0;
55411
+ const short = (literal3, name, max) => {
55412
+ const value = text3(literal3);
55413
+ if (value === void 0) at2(literal3.node, `The \`${name}\` is a string.`);
55414
+ else if (value.length > max)
55415
+ at2(literal3.node, `The \`${name}\` is ${value.length} characters; it may have ${max}.`);
55416
+ return value;
55417
+ };
55418
+ const only = (map, allowed, what) => {
55419
+ for (const [key2, literal3] of map)
55420
+ if (!allowed.includes(key2))
55421
+ at2(literal3.node, `${what} has no \`${key2}\`: it takes ${list4(allowed)}.`);
55422
+ };
55423
+ const idLiteral = props.get("id");
55424
+ const id2 = text3(idLiteral);
55425
+ if (id2 === void 0)
55426
+ at2(idLiteral?.node ?? init3, "An activity needs an `id`: lowercase letters, digits and dashes.");
55427
+ else if (!ACTIVITY_ID.test(id2))
55428
+ at2(idLiteral.node, `Activity ID "${id2}" must be lowercase letters, digits and dashes.`);
55429
+ const kind = text3(props.get("kind"));
55430
+ const prompt = props.get("prompt");
55431
+ let activity;
55432
+ if (kind === "choice") {
55433
+ only(props, ["id", "kind", "prompt", "options", "reveals"], "A poll");
55434
+ const question = prompt ? short(prompt, "prompt", PROMPT_MAX) : void 0;
55435
+ if (!prompt) at2(init3, "A poll needs a `prompt`.");
55436
+ else if (question !== void 0 && !question.trim())
55437
+ at2(prompt.node, "A poll needs a `prompt`.");
55438
+ const optionsLiteral = props.get("options");
55439
+ const options = [];
55440
+ if (!Array.isArray(optionsLiteral?.value))
55441
+ at2(optionsLiteral?.node ?? init3, "A poll needs 2 to 8 `options`, as an array of strings.");
55442
+ else {
55443
+ const items = optionsLiteral.value;
55444
+ if (items.length < 2 || items.length > 8)
55445
+ at2(optionsLiteral.node, `A poll needs 2 to 8 \`options\`; this one has ${items.length}.`);
55446
+ for (const item of items) {
55447
+ const option = text3(item);
55448
+ if (option === void 0) at2(item.node, "Each option is a string.");
55449
+ else if (!option.trim()) at2(item.node, "An option needs some text.");
55450
+ else if (option.length > OPTION_MAX)
55451
+ at2(item.node, `An option is ${option.length} characters; it may have ${OPTION_MAX}.`);
55452
+ else if (options.includes(option)) at2(item.node, `Option "${option}" is listed twice.`);
55453
+ else options.push(option);
55454
+ }
55455
+ }
55456
+ const revealsLiteral = props.get("reveals");
55457
+ const reveals = text3(revealsLiteral);
55458
+ if (revealsLiteral) {
55459
+ const names = (beats ?? []).map((b) => b.id);
55460
+ if (reveals === void 0) at2(revealsLiteral.node, "`reveals` names a beat of this scene.");
55461
+ else if (names[0] === reveals)
55462
+ at2(
55463
+ revealsLiteral.node,
55464
+ `\`reveals\` names "${reveals}", the scene's first beat: the poll would never be open. Name a later beat.`
55465
+ );
55466
+ else if (beats && !names.includes(reveals))
55467
+ at2(
55468
+ revealsLiteral.node,
55469
+ `\`reveals\` names "${reveals}", which is not a beat of this scene (${names.join(", ")}).`
55470
+ );
55471
+ }
55472
+ if (id2 !== void 0 && question !== void 0)
55473
+ activity = {
55474
+ id: id2,
55475
+ kind,
55476
+ prompt: question,
55477
+ options,
55478
+ ...reveals !== void 0 ? { reveals } : {}
55479
+ };
55480
+ } else if (kind === "text") {
55481
+ if (props.has("reveals"))
55482
+ at2(props.get("reveals").node, "A form can't `reveal`: a form's answers are only stored.");
55483
+ only(
55484
+ new Map([...props].filter(([key2]) => key2 !== "reveals")),
55485
+ ["id", "kind", "prompt", "fields"],
55486
+ "A form"
55487
+ );
55488
+ const question = prompt ? short(prompt, "prompt", PROMPT_MAX) : void 0;
55489
+ const fieldsLiteral = props.get("fields");
55490
+ const fields = [];
55491
+ if (!Array.isArray(fieldsLiteral?.value))
55492
+ at2(fieldsLiteral?.node ?? init3, "A form needs 1 to 5 `fields`, as an array of objects.");
55493
+ else {
55494
+ const items = fieldsLiteral.value;
55495
+ if (items.length < 1 || items.length > 5)
55496
+ at2(fieldsLiteral.node, `A form needs 1 to 5 \`fields\`; this one has ${items.length}.`);
55497
+ const seen2 = /* @__PURE__ */ new Set();
55498
+ for (const item of items) {
55499
+ if (!(item.value instanceof Map)) {
55500
+ at2(item.node, 'Each field is an object: `{ id: "\u2026", label: "\u2026" }`.');
55501
+ continue;
55502
+ }
55503
+ const field = item.value;
55504
+ only(field, ["id", "label", "multiline", "max"], "A field");
55505
+ const fieldIdLiteral = field.get("id");
55506
+ const fieldId = text3(fieldIdLiteral);
55507
+ if (fieldId === void 0)
55508
+ at2(
55509
+ fieldIdLiteral?.node ?? item.node,
55510
+ "A field needs an `id`: lowercase letters, digits and dashes."
55511
+ );
55512
+ else if (!ACTIVITY_ID.test(fieldId))
55513
+ at2(
55514
+ fieldIdLiteral.node,
55515
+ `Field ID "${fieldId}" must be lowercase letters, digits and dashes.`
55516
+ );
55517
+ else if (seen2.has(fieldId))
55518
+ at2(fieldIdLiteral.node, `Field "${fieldId}" is declared twice in this form.`);
55519
+ else seen2.add(fieldId);
55520
+ const labelLiteral = field.get("label");
55521
+ const label = labelLiteral ? short(labelLiteral, "label", LABEL_MAX) : void 0;
55522
+ if (!labelLiteral) at2(item.node, "A field needs a `label`.");
55523
+ const multiline = field.get("multiline");
55524
+ if (multiline && typeof multiline.value !== "boolean")
55525
+ at2(multiline.node, "`multiline` is true or false.");
55526
+ const max = field.get("max");
55527
+ if (max && (typeof max.value !== "number" || !Number.isInteger(max.value) || max.value < 1 || max.value > FIELD_MAX))
55528
+ at2(max.node, `\`max\` is a whole number of characters from 1 to ${FIELD_MAX}.`);
55529
+ if (fieldId !== void 0 && label !== void 0)
55530
+ fields.push({
55531
+ id: fieldId,
55532
+ label,
55533
+ ...multiline?.value === true ? { multiline: true } : {},
55534
+ max: typeof max?.value === "number" ? max.value : TEXT_MAX
55535
+ });
55536
+ }
55537
+ }
55538
+ if (id2 !== void 0)
55539
+ activity = {
55540
+ id: id2,
55541
+ kind,
55542
+ ...question !== void 0 ? { prompt: question } : {},
55543
+ fields
55544
+ };
55545
+ } else
55546
+ at2(
55547
+ props.get("kind")?.node ?? init3,
55548
+ 'An activity\'s `kind` is "choice" (a poll) or "text" (a form).'
55549
+ );
55550
+ if (problems.length || !activity) return { problems };
55551
+ return { activity: { activity, line: position2(source2, idLiteral.node.start).line }, problems };
55552
+ }
55305
55553
  function readCalls(file2, source2, root, problems) {
55306
55554
  const media = [];
55307
55555
  walk(root, null, {
@@ -55501,9 +55749,13 @@ function analyzeSvelte(file2, source2, options) {
55501
55749
  const result = { media: [], problems };
55502
55750
  const rules = options.rules ?? {};
55503
55751
  if (options.scene) {
55504
- const beats = readBeats(file2, source2, ast.module);
55752
+ const module = ast.module;
55753
+ const beats = readBeats(file2, source2, module);
55505
55754
  result.beats = beats.beats;
55506
55755
  problems.push(...beats.problems);
55756
+ const activity = readActivity(file2, source2, module, beats.beats);
55757
+ result.activity = activity.activity;
55758
+ problems.push(...activity.problems);
55507
55759
  if (rules.layoutRoot) readRoot(file2, source2, ast, problems);
55508
55760
  }
55509
55761
  Object.assign(result, readCalls(file2, source2, ast, problems));
@@ -55524,7 +55776,7 @@ function analyzeScript(file2, source2, rules = {}) {
55524
55776
  readBehaviour(file2, source2, program, problems);
55525
55777
  return { ...calls, problems };
55526
55778
  }
55527
- var SIZES, TIMERS, NETWORK, NETWORK_CLASSES, REMOTE, IGNORED_ROOT;
55779
+ var ACTIVITY_ID, PROMPT_MAX, OPTION_MAX, LABEL_MAX, FIELD_MAX, list4, SIZES, TIMERS, NETWORK, NETWORK_CLASSES, REMOTE, IGNORED_ROOT;
55528
55780
  var init_analyze2 = __esm({
55529
55781
  "../deck/src/analyze.ts"() {
55530
55782
  "use strict";
@@ -55533,7 +55785,14 @@ var init_analyze2 = __esm({
55533
55785
  init_acorn();
55534
55786
  init_compiler();
55535
55787
  init_walk();
55788
+ init_activity();
55536
55789
  init_tree();
55790
+ ACTIVITY_ID = /^[a-z0-9][a-z0-9-]*$/;
55791
+ PROMPT_MAX = 200;
55792
+ OPTION_MAX = 80;
55793
+ LABEL_MAX = 200;
55794
+ FIELD_MAX = 2e3;
55795
+ list4 = (names) => names.length < 2 ? names.join("") : `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
55537
55796
  SIZES = [
55538
55797
  /font-size\s*:\s*(\d+(?:\.\d+)?)(px|rem)\b/g,
55539
55798
  /(?<![\w-])font\s*:\s*[^;{}"'`]*?\b(\d+(?:\.\d+)?)(px|rem)\b/g,
@@ -55924,13 +56183,12 @@ async function buildDeck(tree, options = {}) {
55924
56183
  });
55925
56184
  }
55926
56185
  const dependencies = deck.dependencies ?? {};
55927
- const graph = await compileGraph(
55928
- tree,
55929
- [...files].filter(
55930
- (f) => (f.startsWith("scenes/") || f.startsWith("master/") || f.startsWith("lib/")) && SOURCE.test(f) && !f.endsWith(".json")
55931
- ),
55932
- { rules, cache: options.cache, scenes: sceneFiles, dependencies }
55933
- );
56186
+ const graph = await compileGraph(tree, sourcesIn(files, ["scenes/", "master/", "lib/"]), {
56187
+ rules,
56188
+ cache: options.cache,
56189
+ scenes: sceneFiles,
56190
+ dependencies
56191
+ });
55934
56192
  problems.push(...graph.problems);
55935
56193
  for (const path of graph.compiled.keys())
55936
56194
  if (path.startsWith("scenes/") && !sceneFiles.has(path) && path.endsWith(".svelte") && !path.slice(7).includes("/"))
@@ -55953,6 +56211,21 @@ async function buildDeck(tree, options = {}) {
55953
56211
  severity: "error"
55954
56212
  });
55955
56213
  }
56214
+ const activityFiles = /* @__PURE__ */ new Map();
56215
+ for (const file2 of sceneFiles) {
56216
+ const found2 = graph.compiled.get(file2)?.analysis.activity;
56217
+ if (!found2) continue;
56218
+ const other = activityFiles.get(found2.activity.id);
56219
+ if (other)
56220
+ problems.push({
56221
+ file: file2,
56222
+ line: found2.line,
56223
+ rule: "activity",
56224
+ message: `Activity "${found2.activity.id}" is declared in ${other} too: activity IDs are unique across the deck.`,
56225
+ severity: "error"
56226
+ });
56227
+ else activityFiles.set(found2.activity.id, file2);
56228
+ }
55956
56229
  const stylesheet = masterStylesheet(tree, media, mediaProblems.length ? [] : problems);
55957
56230
  if (problems.some((p) => p.severity === "error")) return { problems, modules, deck };
55958
56231
  const emitted = emitModules(graph.compiled);
@@ -55962,12 +56235,14 @@ async function buildDeck(tree, options = {}) {
55962
56235
  title: chapter.title,
55963
56236
  scenes: chapter.scenes.map((scene) => {
55964
56237
  const file2 = `scenes/${scene.id}.svelte`;
56238
+ const analysis = graph.compiled.get(file2)?.analysis;
55965
56239
  return {
55966
56240
  id: scene.id,
55967
56241
  title: scene.title,
55968
56242
  ...scene.note ? { note: scene.note } : {},
55969
- beats: (graph.compiled.get(file2)?.analysis.beats ?? []).map((b) => b.id),
55970
- module: DECK_PREFIX + file2
56243
+ beats: (analysis?.beats ?? []).map((b) => b.id),
56244
+ module: DECK_PREFIX + file2,
56245
+ ...analysis?.activity ? { activity: analysis.activity.activity } : {}
55971
56246
  };
55972
56247
  })
55973
56248
  }));
@@ -56010,7 +56285,7 @@ function masterStylesheet(tree, media, problems) {
56010
56285
  );
56011
56286
  return { name: `m/${sha256(code).slice(0, 20)}.css`, code };
56012
56287
  }
56013
- var DECK_PREFIX, SOURCE, RUNTIME_PACKAGES, isNotAName;
56288
+ var DECK_PREFIX, SOURCE, RUNTIME_PACKAGES, isNotAName, sourcesIn;
56014
56289
  var init_build = __esm({
56015
56290
  "../deck/src/build.ts"() {
56016
56291
  "use strict";
@@ -56027,6 +56302,9 @@ var init_build = __esm({
56027
56302
  SOURCE = /\.(svelte|ts|js|mjs|json)$/;
56028
56303
  RUNTIME_PACKAGES = /* @__PURE__ */ new Set(["svelte", "gsap", "@tobos/present"]);
56029
56304
  isNotAName = (segment) => segment === "" || segment === "." || segment === "..";
56305
+ sourcesIn = (files, folders) => [...files].filter(
56306
+ (f) => folders.some((folder) => f.startsWith(folder)) && SOURCE.test(f) && !f.endsWith(".json")
56307
+ );
56030
56308
  }
56031
56309
  });
56032
56310
 
@@ -56036,11 +56314,21 @@ var init_master = __esm({
56036
56314
  "use strict";
56037
56315
  init_define_TOBOS_PRESENT_TYPES();
56038
56316
  init_define_TOBOS_SKILL();
56317
+ init_build();
56039
56318
  init_deck_json();
56040
56319
  init_tree();
56041
56320
  }
56042
56321
  });
56043
56322
 
56323
+ // ../deck/src/share.ts
56324
+ var init_share = __esm({
56325
+ "../deck/src/share.ts"() {
56326
+ "use strict";
56327
+ init_define_TOBOS_PRESENT_TYPES();
56328
+ init_define_TOBOS_SKILL();
56329
+ }
56330
+ });
56331
+
56044
56332
  // ../deck/src/format-problems.ts
56045
56333
  function formatProblems(problems) {
56046
56334
  return problems.map((p) => {
@@ -56067,6 +56355,8 @@ var init_src4 = __esm({
56067
56355
  init_master();
56068
56356
  init_tree();
56069
56357
  init_hash();
56358
+ init_activity();
56359
+ init_share();
56070
56360
  init_format_problems();
56071
56361
  }
56072
56362
  });
@@ -56175,7 +56465,8 @@ function writeConfig(root) {
56175
56465
  }
56176
56466
  const rel = (path) => relative2(dir2, path).split("\\").join("/");
56177
56467
  const paths = {
56178
- "@tobos/present": [rel(join7(dir2, "present", "index.d.ts"))]
56468
+ "@tobos/present": [rel(join7(dir2, "present", "index.d.ts"))],
56469
+ "@tobos/deck/types": [rel(join7(dir2, "present", "deck", "types.d.ts"))]
56179
56470
  };
56180
56471
  const config = join7(dir2, "tsconfig.json");
56181
56472
  writeFileSync5(
@@ -56517,7 +56808,7 @@ function settings() {
56517
56808
 
56518
56809
  // src/api.ts
56519
56810
  init_out();
56520
- var VERSION = true ? "0.2.0" : "dev";
56811
+ var VERSION = true ? "0.4.0" : "dev";
56521
56812
  function newer(a, b) {
56522
56813
  const parse9 = (v) => /^\d+\.\d+\.\d+/.test(v) ? v.split(".").map((n2) => parseInt(n2)) : null;
56523
56814
  const x = parse9(a);
@@ -56640,9 +56931,9 @@ import { dirname, join as join3, resolve as resolve2 } from "node:path";
56640
56931
  // src/git.ts
56641
56932
  init_define_TOBOS_PRESENT_TYPES();
56642
56933
  init_define_TOBOS_SKILL();
56643
- init_out();
56644
56934
  import { spawn } from "node:child_process";
56645
56935
  import { realpathSync } from "node:fs";
56936
+ init_out();
56646
56937
  function git(args, options = {}) {
56647
56938
  return new Promise((resolve4, reject) => {
56648
56939
  const child = spawn("git", args, {
@@ -56684,6 +56975,16 @@ function credentialConfig(server) {
56684
56975
  `credential.${server}.helper=${credentialHelper()}`
56685
56976
  ];
56686
56977
  }
56978
+ function authEnv(server) {
56979
+ const { server: ours, token: token2 } = settings();
56980
+ if (!token2 || new URL(ours).origin !== new URL(server).origin) return {};
56981
+ const n2 = Number(process.env.GIT_CONFIG_COUNT) || 0;
56982
+ return {
56983
+ GIT_CONFIG_COUNT: String(n2 + 1),
56984
+ [`GIT_CONFIG_KEY_${n2}`]: `http.${server}.extraHeader`,
56985
+ [`GIT_CONFIG_VALUE_${n2}`]: `Authorization: Basic ${Buffer.from(`tobos:${token2}`).toString("base64")}`
56986
+ };
56987
+ }
56687
56988
  async function configureCredentials(dir2, server) {
56688
56989
  await gitOk(["config", "--replace-all", `credential.${server}.helper`, ""], { cwd: dir2 });
56689
56990
  await gitOk(["config", "--add", `credential.${server}.helper`, credentialHelper()], { cwd: dir2 });
@@ -56691,7 +56992,8 @@ async function configureCredentials(dir2, server) {
56691
56992
 
56692
56993
  // src/deck-dir.ts
56693
56994
  init_out();
56694
- var REMOTE2 = /^(https?:\/\/[^/]+)\/git\/([a-z][a-z0-9-]*)\/([a-z][a-z0-9-]*)\.git$/;
56995
+ var ID2 = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
56996
+ var REMOTE2 = new RegExp(`^(https?://[^/]+)/git/(${ID2})\\.git$`);
56695
56997
  async function findDeck(start = process.cwd()) {
56696
56998
  let dir2 = resolve2(start);
56697
56999
  while (!existsSync(join3(dir2, "deck.json"))) {
@@ -56702,20 +57004,20 @@ async function findDeck(start = process.cwd()) {
56702
57004
  }
56703
57005
  const remote = await git(["remote", "get-url", "origin"], { cwd: dir2 }).catch(() => void 0);
56704
57006
  const match = remote && remote.code === 0 ? REMOTE2.exec(remote.stdout.trim()) : null;
56705
- return match ? { root: dir2, server: match[1], name: `${match[2]}/${match[3]}` } : { root: dir2 };
57007
+ return match ? { root: dir2, server: match[1], id: match[2] } : { root: dir2 };
56706
57008
  }
56707
57009
  async function requireRemote(start) {
56708
57010
  const deck = await findDeck(start);
56709
- if (!deck.name || !deck.server)
57011
+ if (!deck.id || !deck.server)
56710
57012
  throw new CliError(
56711
57013
  `${deck.root} isn't linked to a deck on a Tobos server (no matching git remote "origin").`
56712
57014
  );
56713
57015
  return deck;
56714
57016
  }
56715
- function parseName(name) {
56716
- const match = /^([a-z][a-z0-9-]*)\/([a-z][a-z0-9-]*)$/.exec(name);
56717
- if (!match) throw new CliError(`"${name}" is not a deck name; use account/deck.`);
56718
- return { account: match[1], deck: match[2] };
57017
+ function parseId(id2) {
57018
+ if (!new RegExp(`^${ID2}$`).test(id2))
57019
+ throw new CliError(`"${id2}" is not a deck's id; \`tobos decks\` lists them.`);
57020
+ return id2;
56719
57021
  }
56720
57022
 
56721
57023
  // src/media.ts
@@ -56800,7 +57102,7 @@ async function syncMediaJson(root) {
56800
57102
  if (after !== before2) writeFileSync2(file2, after);
56801
57103
  return { media: sorted, changed: after !== before2 };
56802
57104
  }
56803
- async function uploadMedia(root, media, server, account, note) {
57105
+ async function uploadMedia(root, media, server, deck, note) {
56804
57106
  const hashes = [...new Set(Object.values(media).map((m) => m.hash))];
56805
57107
  if (hashes.length === 0) return [];
56806
57108
  const { missing } = await api("/api/media/missing", {
@@ -56816,7 +57118,7 @@ async function uploadMedia(root, media, server, account, note) {
56816
57118
  `media/${name} is in media.json but not on this machine, and the server doesn't have it.`
56817
57119
  );
56818
57120
  note(`uploading media/${name} (${Math.round(entry.size / 1e3)} kB)`);
56819
- const response = await request(`/api/media/${hash2}?account=${account}`, {
57121
+ const response = await request(`/api/media/${hash2}?deck=${deck}`, {
56820
57122
  method: "PUT",
56821
57123
  body: Readable.toWeb(createReadStream(path)),
56822
57124
  contentType: entry.type,
@@ -56997,10 +57299,7 @@ async function login(out, args) {
56997
57299
  save({ server, token: token2, pending: void 0 });
56998
57300
  const me = await api("/api/me", { server });
56999
57301
  save({ email: me.email });
57000
- out.result(
57001
- { email: me.email, server, accounts: me.accounts.map((a) => a.slug) },
57002
- () => `Logged in as ${me.email}.`
57003
- );
57302
+ out.result({ email: me.email, server }, () => `Logged in as ${me.email}.`);
57004
57303
  }
57005
57304
  async function logout(out) {
57006
57305
  let revoked = false;
@@ -57019,37 +57318,35 @@ async function logout(out) {
57019
57318
  }
57020
57319
  async function whoami(out) {
57021
57320
  const me = await api("/api/me");
57022
- out.result(
57023
- { ...me, server: settings().server },
57024
- () => `${me.email} on ${settings().server}
57025
- accounts: ${me.accounts.map((a) => `${a.slug} (${a.role})`).join(", ")}`
57026
- );
57321
+ out.result({ ...me, server: settings().server }, () => `${me.email} on ${settings().server}`);
57027
57322
  }
57028
57323
  async function decks(out) {
57029
57324
  const { decks: decks2 } = await api("/api/decks");
57030
57325
  out.result(
57031
57326
  { decks: decks2 },
57032
- () => decks2.length === 0 ? 'No decks yet. `tobos new "Title"` starts one.' : decks2.map((d) => `${d.name.padEnd(32)} ${d.title}`).join("\n")
57327
+ () => decks2.length === 0 ? 'No decks yet. `tobos new "Title"` starts one.' : decks2.map((d) => `${d.id} ${d.title}`).join("\n")
57033
57328
  );
57034
57329
  }
57035
57330
  async function cloneInto(out, info, dir2) {
57036
57331
  const { server } = settings();
57037
57332
  if (existsSync5(dir2)) throw new CliError(`${dir2} already exists.`);
57038
- out.note(`cloning ${info.name} into ${dir2}`);
57039
- await gitOk([...credentialConfig(server), "clone", "--quiet", info.git, dir2]);
57333
+ out.note(`cloning ${info.title} into ${dir2}`);
57334
+ await gitOk([...credentialConfig(server), "clone", "--quiet", info.git, dir2], {
57335
+ env: authEnv(server)
57336
+ });
57040
57337
  await configureCredentials(dir2, server);
57041
57338
  return writeFormatGuide(dir2, server);
57042
57339
  }
57043
57340
  async function clone(out, args) {
57044
- const name = args.positionals[0];
57045
- if (!name) throw new CliError("Which deck? `tobos clone account/deck` (see `tobos decks`).");
57046
- const { account, deck } = parseName(name);
57047
- const info = await api(`/api/decks/${account}/${deck}`);
57048
- const dir2 = resolve3(args.positionals[1] ?? deck);
57341
+ const given = args.positionals[0];
57342
+ if (!given) throw new CliError("Which deck? `tobos clone <id>` (`tobos decks` lists them).");
57343
+ const id2 = parseId(given);
57344
+ const info = await api(`/api/decks/${id2}`);
57345
+ const dir2 = resolve3(args.positionals[1] ?? id2);
57049
57346
  await cloneInto(out, info, dir2);
57050
57347
  out.result(
57051
57348
  { ...info, dir: dir2 },
57052
- () => `Cloned ${info.name} into ${relative3(process.cwd(), dir2) || "."}.
57349
+ () => `Cloned ${info.title} into ${relative3(process.cwd(), dir2) || "."}.
57053
57350
  Read AGENTS.md there first. Preview: ${info.url}`
57054
57351
  );
57055
57352
  }
@@ -57059,20 +57356,19 @@ async function create(out, args) {
57059
57356
  const info = await api("/api/decks", {
57060
57357
  body: {
57061
57358
  title,
57062
- slug: args.values.slug,
57063
57359
  from: args.values.from,
57064
57360
  template: Boolean(args.values.template)
57065
57361
  }
57066
57362
  });
57067
57363
  let dir2;
57068
57364
  if (!args.values["no-clone"]) {
57069
- dir2 = resolve3(args.values.dir ?? info.slug);
57365
+ dir2 = resolve3(args.values.dir ?? info.id);
57070
57366
  await cloneInto(out, info, dir2);
57071
57367
  }
57072
57368
  out.result(
57073
57369
  { ...info, dir: dir2 ?? null },
57074
57370
  () => [
57075
- `Created ${info.name}: ${info.url}`,
57371
+ `Created ${info.title}: ${info.url}`,
57076
57372
  dir2 ? `Cloned into ${relative3(process.cwd(), dir2) || "."}. Read AGENTS.md there first.` : ""
57077
57373
  ].filter(Boolean).join("\n")
57078
57374
  );
@@ -57081,9 +57377,7 @@ async function pull(out) {
57081
57377
  const deck = await requireRemote();
57082
57378
  const result = await git(
57083
57379
  [...credentialConfig(deck.server), "pull", "--ff-only", "--quiet", "origin", "main"],
57084
- {
57085
- cwd: deck.root
57086
- }
57380
+ { cwd: deck.root, env: authEnv(deck.server) }
57087
57381
  );
57088
57382
  if (result.code !== 0)
57089
57383
  throw new CliError(
@@ -57093,7 +57387,7 @@ Commit or stash your changes, then merge with \`git pull\`.`
57093
57387
  );
57094
57388
  await writeFormatGuide(deck.root, deck.server);
57095
57389
  const rev = (await gitOk(["rev-parse", "HEAD"], { cwd: deck.root })).trim();
57096
- out.result({ name: deck.name, rev }, () => `Up to date with ${deck.name} (${rev.slice(0, 7)}).`);
57390
+ out.result({ id: deck.id, rev }, () => `Up to date with the server (${rev.slice(0, 7)}).`);
57097
57391
  }
57098
57392
  async function runCheck(dir2) {
57099
57393
  const started = performance.now();
@@ -57141,8 +57435,7 @@ async function pushWorkingCopy(out, deck, message) {
57141
57435
  `note: media/${name} is ${Math.round(entry.size / 1e6)} MB. Every viewer downloads it; size it for the stage.`,
57142
57436
  true
57143
57437
  );
57144
- const account = deck.name.split("/")[0];
57145
- const uploaded = await uploadMedia(root, media, server, account, (m) => out.note(m));
57438
+ const uploaded = await uploadMedia(root, media, server, deck.id, (m) => out.note(m));
57146
57439
  await gitOk(["add", "-A"], { cwd: root });
57147
57440
  const committed = (await gitOk(["diff", "--cached", "--name-only"], { cwd: root })).split("\n").filter(Boolean);
57148
57441
  for (const file2 of committed) out.note(` ${file2}`);
@@ -57154,7 +57447,7 @@ async function pushWorkingCopy(out, deck, message) {
57154
57447
  out.note("pushing\u2026");
57155
57448
  const pushed = await git(
57156
57449
  [...credentialConfig(server), "push", "--porcelain", "origin", "HEAD:main"],
57157
- { cwd: root, echo: !out.json }
57450
+ { cwd: root, echo: !out.json, env: authEnv(server) }
57158
57451
  );
57159
57452
  const remote = remoteLines(pushed.stderr);
57160
57453
  if (pushed.code !== 0) {
@@ -57183,15 +57476,15 @@ async function push(out, args) {
57183
57476
  process.exitCode = EXIT.problems;
57184
57477
  return;
57185
57478
  }
57186
- const url = `${deck.server}/${deck.name}`;
57479
+ const url = `${deck.server}/${deck.id}`;
57187
57480
  out.result(
57188
57481
  { ...result, pushed: true, url },
57189
57482
  () => `\u2713 Pushed ${result.rev.slice(0, 7)}${result.uploaded.length ? ` with ${plural(result.uploaded.length, "media file")}` : ""}. Live at ${url}`
57190
57483
  );
57191
57484
  }
57192
- async function pushIfChanged(out, name, message) {
57485
+ async function pushIfChanged(out, id2, message) {
57193
57486
  const found2 = await findDeck().catch(() => void 0);
57194
- if (!found2?.server || found2.name !== name) return { pushed: false, uploaded: [] };
57487
+ if (!found2?.server || found2.id !== id2) return { pushed: false, uploaded: [] };
57195
57488
  const deck = found2;
57196
57489
  const dirty = (await gitOk(["status", "--porcelain"], { cwd: deck.root })).trim() !== "";
57197
57490
  const head = await git(["rev-parse", "--verify", "--quiet", "HEAD"], { cwd: deck.root });
@@ -57218,22 +57511,21 @@ async function identity(root) {
57218
57511
  GIT_COMMITTER_EMAIL: who ?? "tobos@localhost"
57219
57512
  };
57220
57513
  }
57221
- async function viewUrl(name, view, hours) {
57222
- const { account, deck } = parseName(name);
57223
- return api(`/api/decks/${account}/${deck}/view`, { body: { view, hours } });
57514
+ async function viewUrl(id2, view, hours) {
57515
+ return api(`/api/decks/${id2}/view`, { body: { view, hours } });
57224
57516
  }
57225
- async function deckName(args) {
57226
- if (typeof args.values.deck === "string") return args.values.deck;
57227
- return (await requireRemote()).name;
57517
+ async function deckId(args) {
57518
+ if (typeof args.values.deck === "string") return parseId(args.values.deck);
57519
+ return (await requireRemote()).id;
57228
57520
  }
57229
57521
  async function open2(out, args) {
57230
57522
  const position3 = args.positionals[0];
57231
57523
  if (!position3 && typeof args.values.deck !== "string" && !await findDeck().catch(() => null))
57232
57524
  return openApp(out, args);
57233
57525
  const view = args.values.presenter ? "presenter" : void 0;
57234
- const name = await deckName(args);
57235
- const { pushed } = await pushIfChanged(out, name);
57236
- const { url } = await viewUrl(name, view, 12);
57526
+ const id2 = await deckId(args);
57527
+ const { pushed } = await pushIfChanged(out, id2);
57528
+ const { url } = await viewUrl(id2, view, 12);
57237
57529
  const full = position3 ? `${url}#${position3}` : url;
57238
57530
  const opened = !args.values.print && await openUrl(full);
57239
57531
  out.result({ url: full, opened, pushed }, () => full);
@@ -57247,6 +57539,66 @@ async function openApp(out, args) {
57247
57539
  This link logs a browser in once, within 10 minutes.`
57248
57540
  );
57249
57541
  }
57542
+ async function storyTx(id2, ops) {
57543
+ try {
57544
+ return await api(`/api/decks/${id2}/story/tx`, {
57545
+ body: { ops, agent: process.env.TOBOS_AGENT || void 0 }
57546
+ });
57547
+ } catch (error) {
57548
+ if (error instanceof CliError && error.extra.status === 409) {
57549
+ const now = error.extra.paragraph;
57550
+ throw new CliError(
57551
+ now ? `${error.message}
57552
+ It is now:
57553
+ \xB6 ${now.id} ${now.text}` : error.message,
57554
+ EXIT.conflict,
57555
+ error.extra
57556
+ );
57557
+ }
57558
+ throw error;
57559
+ }
57560
+ }
57561
+ async function story(out, args) {
57562
+ const [action, ...rest2] = args.positionals;
57563
+ const id2 = await deckId(args);
57564
+ if (!action) {
57565
+ const story2 = await api(`/api/decks/${id2}/story`);
57566
+ out.result(
57567
+ { ...story2 },
57568
+ () => story2.paragraphs.length ? story2.paragraphs.map((p) => `\xB6 ${p.id.padEnd(4)} ${p.text}`).join("\n\n") : 'No story yet. `tobos story add "\u2026"` writes its first paragraph.'
57569
+ );
57570
+ return;
57571
+ }
57572
+ if (action === "edit") {
57573
+ const [paragraph, find, replace] = rest2;
57574
+ if (!paragraph || find === void 0 || replace === void 0)
57575
+ throw new CliError(
57576
+ '`tobos story edit <\xB6 id> "the exact text" "what replaces it"` (`tobos story` shows the ids).'
57577
+ );
57578
+ const result = await storyTx(id2, [{ op: "set", id: paragraph, find, replace }]);
57579
+ out.result({ ...result, paragraph }, () => `Changed ${paragraph}.`);
57580
+ return;
57581
+ }
57582
+ if (action === "add") {
57583
+ const text3 = rest2.join(" ").trim();
57584
+ if (!text3) throw new CliError('`tobos story add [--after <\xB6 id>] "the paragraph"`.');
57585
+ const after = args.values.after ?? "end";
57586
+ const result = await storyTx(id2, [
57587
+ { op: "insert", after: after === "start" ? null : after, text: text3, key: "new:1" }
57588
+ ]);
57589
+ const paragraph = result.ids["new:1"] ?? null;
57590
+ out.result({ ...result, paragraph }, () => `Added ${paragraph}.`);
57591
+ return;
57592
+ }
57593
+ if (action === "delete") {
57594
+ const paragraph = rest2[0];
57595
+ if (!paragraph) throw new CliError("`tobos story delete <\xB6 id>`.");
57596
+ const result = await storyTx(id2, [{ op: "delete", id: paragraph }]);
57597
+ out.result({ ...result, paragraph }, () => `Deleted ${paragraph}.`);
57598
+ return;
57599
+ }
57600
+ throw new CliError(`No \`tobos story ${action}\`: edit, add or delete.`);
57601
+ }
57250
57602
  async function exportTarget(args, file2) {
57251
57603
  if (args.values.out) return resolve3(args.values.out);
57252
57604
  const deck = await findDeck().catch(() => void 0);
@@ -57256,12 +57608,11 @@ async function exportTarget(args, file2) {
57256
57608
  }
57257
57609
  async function exportDeck(out, args) {
57258
57610
  const kind = args.positionals[0];
57259
- const name = await deckName(args);
57260
- const { account, deck } = parseName(name);
57611
+ const id2 = await deckId(args);
57261
57612
  if (kind === "pdf") {
57262
57613
  const { exportPdf: exportPdf2 } = await Promise.resolve().then(() => (init_render(), render_exports));
57263
- const { url, rev } = await viewUrl(name, "print");
57264
- const target = await exportTarget(args, `${account}-${deck}.pdf`);
57614
+ const { url, rev } = await viewUrl(id2, "print");
57615
+ const target = await exportTarget(args, `${id2}.pdf`);
57265
57616
  const pages = await exportPdf2(
57266
57617
  url + (args.values.handout ? "&beats=last" : ""),
57267
57618
  target,
@@ -57277,11 +57628,11 @@ async function exportDeck(out, args) {
57277
57628
  }
57278
57629
  async function render(out, args) {
57279
57630
  const { renderBeats: renderBeats2 } = await Promise.resolve().then(() => (init_render(), render_exports));
57280
- const deck = await findDeck();
57281
- const name = args.values.deck ?? deck.name;
57282
- if (!name) throw new CliError("Run this inside a cloned deck, or pass --deck account/deck.");
57283
- const { pushed, uploaded } = await pushIfChanged(out, name, args.values.message);
57284
- const view = await viewUrl(name, "render");
57631
+ const deck = await findDeck().catch(() => void 0);
57632
+ const id2 = typeof args.values.deck === "string" ? parseId(args.values.deck) : deck?.id;
57633
+ if (!id2) throw new CliError("Run this inside a cloned deck, or pass --deck <id>.");
57634
+ const { pushed, uploaded } = await pushIfChanged(out, id2, args.values.message);
57635
+ const view = await viewUrl(id2, "render");
57285
57636
  const { url } = view;
57286
57637
  const rev = view.rev ?? void 0;
57287
57638
  const targets2 = [];
@@ -57294,13 +57645,14 @@ async function render(out, args) {
57294
57645
  const scene = scenes.find((s) => s.id === sceneId);
57295
57646
  if (!scene) throw new CliError(`No scene "${sceneId}" in deck.json.`);
57296
57647
  if (beat) {
57297
- const id2 = /^\d+$/.test(beat) ? scene.beats[Number(beat)] : beat;
57298
- if (!id2 || !scene.beats.includes(id2))
57648
+ const id3 = /^\d+$/.test(beat) ? scene.beats[Number(beat)] : beat;
57649
+ if (!id3 || !scene.beats.includes(id3))
57299
57650
  throw new CliError(`No beat "${beat}" in scene "${sceneId}".`);
57300
- targets2.push(`${scene.id}/${id2}`);
57651
+ targets2.push(`${scene.id}/${id3}`);
57301
57652
  } else targets2.push(...scene.beats.map((b) => `${scene.id}/${b}`));
57302
57653
  }
57303
- const dir2 = resolve3(args.values.out ?? join9(deck.root, ".tobos", "render"));
57654
+ const root = deck?.id === id2 ? deck.root : ".";
57655
+ const dir2 = resolve3(args.values.out ?? join9(root, ".tobos", "render"));
57304
57656
  const { files, errors } = await renderBeats2(url, targets2, {
57305
57657
  dir: dir2,
57306
57658
  film: Boolean(args.values.film),
@@ -57359,11 +57711,11 @@ Account
57359
57711
  tobos login --code <code> finish: the code they read from the mail
57360
57712
  tobos logout forget this machine's token
57361
57713
  tobos whoami who you are, on which server
57362
- tobos decks your decks
57714
+ tobos decks your decks and templates, by id
57363
57715
 
57364
57716
  Working on a deck
57365
- tobos new "Title" [--slug S] create a deck and clone it here
57366
- tobos clone account/deck [dir] clone a deck, with the agent pack
57717
+ tobos new "Title" create a deck and clone it here, into ./<id>
57718
+ tobos clone <id> [dir] clone a deck, with the agent pack
57367
57719
  tobos pull get the latest pushes and the format guide
57368
57720
  tobos check [--types] compile and check the deck, offline (~1 s);
57369
57721
  --types: TypeScript too (installs a checker once)
@@ -57376,17 +57728,27 @@ Looking at it (from the working copy, render and open push what changed first)
57376
57728
  tobos open outside a deck: Tobos in the browser, logged in
57377
57729
  tobos export pdf [--out file] a PDF of every beat
57378
57730
 
57731
+ The story (what the speaker says, held by the server; a scene mentioned: [Title](scene:<id>),
57732
+ a beat: [Title](scene:<id>/<beat>))
57733
+ tobos story the text, by \xB6 id
57734
+ tobos story edit <\xB6> "old" "new" change it, anchored on the exact text
57735
+ tobos story add [--after <\xB6>] "\u2026" a new paragraph (at the end, or after \xB6)
57736
+ tobos story delete <\xB6> a paragraph goes
57737
+ TOBOS_AGENT=<name> says which agent you are: the
57738
+ deck's page marks what you wrote
57739
+
57379
57740
  The skill (what your harness reads to know Tobos without this help)
57380
57741
  tobos skill install put it where Claude Code, Codex, OpenCode and others
57381
57742
  read skills; later CLIs keep it up to date
57382
57743
 
57383
57744
  Templates (decks people start from: a new deck copies a template's master/)
57384
- tobos new "Title" --from account/template start a deck from that template (default: your own,
57385
- account/my-template)
57745
+ tobos new "Title" --from <id> start a deck from that template (default: your own,
57746
+ "My template")
57386
57747
  tobos new "Our brand" --template a new template: a copy of your default (or of --from)
57387
57748
 
57388
57749
  Every command takes --json and then prints one JSON object.
57389
- Exit codes: 0 ok, 1 error, 2 the deck has problems, 3 not logged in.
57750
+ Exit codes: 0 ok, 1 error, 2 the deck has problems, 3 not logged in, 4 the story changed
57751
+ meanwhile (the reply has the paragraph as it is now: anchor on that and try again).
57390
57752
  `;
57391
57753
  var COMMON = {
57392
57754
  json: { type: "boolean" },
@@ -57403,7 +57765,6 @@ var TABLE = {
57403
57765
  new: {
57404
57766
  run: create,
57405
57767
  options: {
57406
- slug: { type: "string" },
57407
57768
  dir: { type: "string" },
57408
57769
  "no-clone": { type: "boolean" },
57409
57770
  from: { type: "string" },
@@ -57431,6 +57792,10 @@ var TABLE = {
57431
57792
  }
57432
57793
  },
57433
57794
  skill: { run: skill },
57795
+ story: {
57796
+ run: story,
57797
+ options: { deck: { type: "string" }, after: { type: "string" } }
57798
+ },
57434
57799
  render: {
57435
57800
  run: render,
57436
57801
  options: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tobos/cli",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "The command line of Tobos: https://tobos.ai",
5
5
  "type": "module",
6
6
  "license": "FSL-1.1-ALv2",