@tobos/cli 0.1.0 → 0.3.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.
- package/dist/tobos.js +102 -82
- package/package.json +1 -1
package/dist/tobos.js
CHANGED
|
@@ -96,7 +96,7 @@ export declare function media(name: string): string;
|
|
|
96
96
|
var define_TOBOS_SKILL_default;
|
|
97
97
|
var init_define_TOBOS_SKILL = __esm({
|
|
98
98
|
"<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
|
|
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, 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## 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" };
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
102
|
|
|
@@ -56517,7 +56517,7 @@ function settings() {
|
|
|
56517
56517
|
|
|
56518
56518
|
// src/api.ts
|
|
56519
56519
|
init_out();
|
|
56520
|
-
var VERSION = true ? "0.
|
|
56520
|
+
var VERSION = true ? "0.3.0" : "dev";
|
|
56521
56521
|
function newer(a, b) {
|
|
56522
56522
|
const parse9 = (v) => /^\d+\.\d+\.\d+/.test(v) ? v.split(".").map((n2) => parseInt(n2)) : null;
|
|
56523
56523
|
const x = parse9(a);
|
|
@@ -56640,9 +56640,9 @@ import { dirname, join as join3, resolve as resolve2 } from "node:path";
|
|
|
56640
56640
|
// src/git.ts
|
|
56641
56641
|
init_define_TOBOS_PRESENT_TYPES();
|
|
56642
56642
|
init_define_TOBOS_SKILL();
|
|
56643
|
-
init_out();
|
|
56644
56643
|
import { spawn } from "node:child_process";
|
|
56645
56644
|
import { realpathSync } from "node:fs";
|
|
56645
|
+
init_out();
|
|
56646
56646
|
function git(args, options = {}) {
|
|
56647
56647
|
return new Promise((resolve4, reject) => {
|
|
56648
56648
|
const child = spawn("git", args, {
|
|
@@ -56684,6 +56684,16 @@ function credentialConfig(server) {
|
|
|
56684
56684
|
`credential.${server}.helper=${credentialHelper()}`
|
|
56685
56685
|
];
|
|
56686
56686
|
}
|
|
56687
|
+
function authEnv(server) {
|
|
56688
|
+
const { server: ours, token: token2 } = settings();
|
|
56689
|
+
if (!token2 || new URL(ours).origin !== new URL(server).origin) return {};
|
|
56690
|
+
const n2 = Number(process.env.GIT_CONFIG_COUNT) || 0;
|
|
56691
|
+
return {
|
|
56692
|
+
GIT_CONFIG_COUNT: String(n2 + 1),
|
|
56693
|
+
[`GIT_CONFIG_KEY_${n2}`]: `http.${server}.extraHeader`,
|
|
56694
|
+
[`GIT_CONFIG_VALUE_${n2}`]: `Authorization: Basic ${Buffer.from(`tobos:${token2}`).toString("base64")}`
|
|
56695
|
+
};
|
|
56696
|
+
}
|
|
56687
56697
|
async function configureCredentials(dir2, server) {
|
|
56688
56698
|
await gitOk(["config", "--replace-all", `credential.${server}.helper`, ""], { cwd: dir2 });
|
|
56689
56699
|
await gitOk(["config", "--add", `credential.${server}.helper`, credentialHelper()], { cwd: dir2 });
|
|
@@ -56691,7 +56701,8 @@ async function configureCredentials(dir2, server) {
|
|
|
56691
56701
|
|
|
56692
56702
|
// src/deck-dir.ts
|
|
56693
56703
|
init_out();
|
|
56694
|
-
var
|
|
56704
|
+
var ID2 = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
|
56705
|
+
var REMOTE2 = new RegExp(`^(https?://[^/]+)/git/(${ID2})\\.git$`);
|
|
56695
56706
|
async function findDeck(start = process.cwd()) {
|
|
56696
56707
|
let dir2 = resolve2(start);
|
|
56697
56708
|
while (!existsSync(join3(dir2, "deck.json"))) {
|
|
@@ -56702,20 +56713,20 @@ async function findDeck(start = process.cwd()) {
|
|
|
56702
56713
|
}
|
|
56703
56714
|
const remote = await git(["remote", "get-url", "origin"], { cwd: dir2 }).catch(() => void 0);
|
|
56704
56715
|
const match = remote && remote.code === 0 ? REMOTE2.exec(remote.stdout.trim()) : null;
|
|
56705
|
-
return match ? { root: dir2, server: match[1],
|
|
56716
|
+
return match ? { root: dir2, server: match[1], id: match[2] } : { root: dir2 };
|
|
56706
56717
|
}
|
|
56707
56718
|
async function requireRemote(start) {
|
|
56708
56719
|
const deck = await findDeck(start);
|
|
56709
|
-
if (!deck.
|
|
56720
|
+
if (!deck.id || !deck.server)
|
|
56710
56721
|
throw new CliError(
|
|
56711
56722
|
`${deck.root} isn't linked to a deck on a Tobos server (no matching git remote "origin").`
|
|
56712
56723
|
);
|
|
56713
56724
|
return deck;
|
|
56714
56725
|
}
|
|
56715
|
-
function
|
|
56716
|
-
|
|
56717
|
-
|
|
56718
|
-
return
|
|
56726
|
+
function parseId(id2) {
|
|
56727
|
+
if (!new RegExp(`^${ID2}$`).test(id2))
|
|
56728
|
+
throw new CliError(`"${id2}" is not a deck's id; \`tobos decks\` lists them.`);
|
|
56729
|
+
return id2;
|
|
56719
56730
|
}
|
|
56720
56731
|
|
|
56721
56732
|
// src/media.ts
|
|
@@ -56800,7 +56811,7 @@ async function syncMediaJson(root) {
|
|
|
56800
56811
|
if (after !== before2) writeFileSync2(file2, after);
|
|
56801
56812
|
return { media: sorted, changed: after !== before2 };
|
|
56802
56813
|
}
|
|
56803
|
-
async function uploadMedia(root, media, server,
|
|
56814
|
+
async function uploadMedia(root, media, server, deck, note) {
|
|
56804
56815
|
const hashes = [...new Set(Object.values(media).map((m) => m.hash))];
|
|
56805
56816
|
if (hashes.length === 0) return [];
|
|
56806
56817
|
const { missing } = await api("/api/media/missing", {
|
|
@@ -56816,7 +56827,7 @@ async function uploadMedia(root, media, server, account, note) {
|
|
|
56816
56827
|
`media/${name} is in media.json but not on this machine, and the server doesn't have it.`
|
|
56817
56828
|
);
|
|
56818
56829
|
note(`uploading media/${name} (${Math.round(entry.size / 1e3)} kB)`);
|
|
56819
|
-
const response = await request(`/api/media/${hash2}?
|
|
56830
|
+
const response = await request(`/api/media/${hash2}?deck=${deck}`, {
|
|
56820
56831
|
method: "PUT",
|
|
56821
56832
|
body: Readable.toWeb(createReadStream(path)),
|
|
56822
56833
|
contentType: entry.type,
|
|
@@ -56837,16 +56848,25 @@ async function uploadMedia(root, media, server, account, note) {
|
|
|
56837
56848
|
init_define_TOBOS_PRESENT_TYPES();
|
|
56838
56849
|
init_define_TOBOS_SKILL();
|
|
56839
56850
|
import { spawn as spawn2 } from "node:child_process";
|
|
56840
|
-
function openUrl(url) {
|
|
56841
|
-
|
|
56851
|
+
async function openUrl(url) {
|
|
56852
|
+
const env = process.env;
|
|
56853
|
+
if (env.CI || env.TOBOS_NO_BROWSER || env.SSH_CONNECTION) return false;
|
|
56854
|
+
if (process.platform === "linux" && !env.DISPLAY && !env.WAYLAND_DISPLAY) return false;
|
|
56842
56855
|
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "rundll32" : "xdg-open";
|
|
56843
56856
|
const args = process.platform === "win32" ? ["url.dll,FileProtocolHandler", url] : [url];
|
|
56844
56857
|
try {
|
|
56845
56858
|
const child = spawn2(command, args, { stdio: "ignore", detached: true });
|
|
56846
|
-
child.on("error", () => {
|
|
56847
|
-
});
|
|
56848
56859
|
child.unref();
|
|
56849
|
-
return
|
|
56860
|
+
return await new Promise((resolve4) => {
|
|
56861
|
+
let timer;
|
|
56862
|
+
const done = (opened) => {
|
|
56863
|
+
clearTimeout(timer);
|
|
56864
|
+
resolve4(opened);
|
|
56865
|
+
};
|
|
56866
|
+
child.once("error", () => done(false));
|
|
56867
|
+
child.once("exit", (code) => done(code === 0));
|
|
56868
|
+
child.once("spawn", () => timer = setTimeout(() => done(true), 1500));
|
|
56869
|
+
});
|
|
56850
56870
|
} catch {
|
|
56851
56871
|
return false;
|
|
56852
56872
|
}
|
|
@@ -56956,7 +56976,7 @@ function installed(dir2) {
|
|
|
56956
56976
|
}
|
|
56957
56977
|
|
|
56958
56978
|
// src/commands.ts
|
|
56959
|
-
var TERMS_NOTICE = "
|
|
56979
|
+
var TERMS_NOTICE = "If the address is new, using the code accepts https://tobos.ai/terms.";
|
|
56960
56980
|
async function login(out, args) {
|
|
56961
56981
|
const server = (args.values.server || settings().server).replace(/\/$/, "");
|
|
56962
56982
|
const client = `the tobos CLI on ${hostname()}`;
|
|
@@ -56971,11 +56991,9 @@ async function login(out, args) {
|
|
|
56971
56991
|
save({ server, pending: email });
|
|
56972
56992
|
out.result(
|
|
56973
56993
|
{ sent: email, next: "tobos login --code <code>", terms: TERMS_NOTICE },
|
|
56974
|
-
() => `Sent a 6-digit code to ${email}; it works for 10 minutes. Ask the person for it,
|
|
56975
|
-
|
|
56976
|
-
tobos login --code <code>
|
|
56994
|
+
() => `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:
|
|
56977
56995
|
|
|
56978
|
-
|
|
56996
|
+
tobos login --code <code>`
|
|
56979
56997
|
);
|
|
56980
56998
|
return;
|
|
56981
56999
|
}
|
|
@@ -56990,10 +57008,7 @@ ${TERMS_NOTICE}`
|
|
|
56990
57008
|
save({ server, token: token2, pending: void 0 });
|
|
56991
57009
|
const me = await api("/api/me", { server });
|
|
56992
57010
|
save({ email: me.email });
|
|
56993
|
-
out.result(
|
|
56994
|
-
{ email: me.email, server, accounts: me.accounts.map((a) => a.slug) },
|
|
56995
|
-
() => `Logged in as ${me.email}.`
|
|
56996
|
-
);
|
|
57011
|
+
out.result({ email: me.email, server }, () => `Logged in as ${me.email}.`);
|
|
56997
57012
|
}
|
|
56998
57013
|
async function logout(out) {
|
|
56999
57014
|
let revoked = false;
|
|
@@ -57012,37 +57027,35 @@ async function logout(out) {
|
|
|
57012
57027
|
}
|
|
57013
57028
|
async function whoami(out) {
|
|
57014
57029
|
const me = await api("/api/me");
|
|
57015
|
-
out.result(
|
|
57016
|
-
{ ...me, server: settings().server },
|
|
57017
|
-
() => `${me.email} on ${settings().server}
|
|
57018
|
-
accounts: ${me.accounts.map((a) => `${a.slug} (${a.role})`).join(", ")}`
|
|
57019
|
-
);
|
|
57030
|
+
out.result({ ...me, server: settings().server }, () => `${me.email} on ${settings().server}`);
|
|
57020
57031
|
}
|
|
57021
57032
|
async function decks(out) {
|
|
57022
57033
|
const { decks: decks2 } = await api("/api/decks");
|
|
57023
57034
|
out.result(
|
|
57024
57035
|
{ decks: decks2 },
|
|
57025
|
-
() => decks2.length === 0 ? 'No decks yet. `tobos new "Title"` starts one.' : decks2.map((d) => `${d.
|
|
57036
|
+
() => decks2.length === 0 ? 'No decks yet. `tobos new "Title"` starts one.' : decks2.map((d) => `${d.id} ${d.title}`).join("\n")
|
|
57026
57037
|
);
|
|
57027
57038
|
}
|
|
57028
57039
|
async function cloneInto(out, info, dir2) {
|
|
57029
57040
|
const { server } = settings();
|
|
57030
57041
|
if (existsSync5(dir2)) throw new CliError(`${dir2} already exists.`);
|
|
57031
|
-
out.note(`cloning ${info.
|
|
57032
|
-
await gitOk([...credentialConfig(server), "clone", "--quiet", info.git, dir2]
|
|
57042
|
+
out.note(`cloning ${info.title} into ${dir2}`);
|
|
57043
|
+
await gitOk([...credentialConfig(server), "clone", "--quiet", info.git, dir2], {
|
|
57044
|
+
env: authEnv(server)
|
|
57045
|
+
});
|
|
57033
57046
|
await configureCredentials(dir2, server);
|
|
57034
57047
|
return writeFormatGuide(dir2, server);
|
|
57035
57048
|
}
|
|
57036
57049
|
async function clone(out, args) {
|
|
57037
|
-
const
|
|
57038
|
-
if (!
|
|
57039
|
-
const
|
|
57040
|
-
const info = await api(`/api/decks/${
|
|
57041
|
-
const dir2 = resolve3(args.positionals[1] ??
|
|
57050
|
+
const given = args.positionals[0];
|
|
57051
|
+
if (!given) throw new CliError("Which deck? `tobos clone <id>` (`tobos decks` lists them).");
|
|
57052
|
+
const id2 = parseId(given);
|
|
57053
|
+
const info = await api(`/api/decks/${id2}`);
|
|
57054
|
+
const dir2 = resolve3(args.positionals[1] ?? id2);
|
|
57042
57055
|
await cloneInto(out, info, dir2);
|
|
57043
57056
|
out.result(
|
|
57044
57057
|
{ ...info, dir: dir2 },
|
|
57045
|
-
() => `Cloned ${info.
|
|
57058
|
+
() => `Cloned ${info.title} into ${relative3(process.cwd(), dir2) || "."}.
|
|
57046
57059
|
Read AGENTS.md there first. Preview: ${info.url}`
|
|
57047
57060
|
);
|
|
57048
57061
|
}
|
|
@@ -57052,20 +57065,19 @@ async function create(out, args) {
|
|
|
57052
57065
|
const info = await api("/api/decks", {
|
|
57053
57066
|
body: {
|
|
57054
57067
|
title,
|
|
57055
|
-
slug: args.values.slug,
|
|
57056
57068
|
from: args.values.from,
|
|
57057
57069
|
template: Boolean(args.values.template)
|
|
57058
57070
|
}
|
|
57059
57071
|
});
|
|
57060
57072
|
let dir2;
|
|
57061
57073
|
if (!args.values["no-clone"]) {
|
|
57062
|
-
dir2 = resolve3(args.values.dir ?? info.
|
|
57074
|
+
dir2 = resolve3(args.values.dir ?? info.id);
|
|
57063
57075
|
await cloneInto(out, info, dir2);
|
|
57064
57076
|
}
|
|
57065
57077
|
out.result(
|
|
57066
57078
|
{ ...info, dir: dir2 ?? null },
|
|
57067
57079
|
() => [
|
|
57068
|
-
`Created ${info.
|
|
57080
|
+
`Created ${info.title}: ${info.url}`,
|
|
57069
57081
|
dir2 ? `Cloned into ${relative3(process.cwd(), dir2) || "."}. Read AGENTS.md there first.` : ""
|
|
57070
57082
|
].filter(Boolean).join("\n")
|
|
57071
57083
|
);
|
|
@@ -57074,9 +57086,7 @@ async function pull(out) {
|
|
|
57074
57086
|
const deck = await requireRemote();
|
|
57075
57087
|
const result = await git(
|
|
57076
57088
|
[...credentialConfig(deck.server), "pull", "--ff-only", "--quiet", "origin", "main"],
|
|
57077
|
-
{
|
|
57078
|
-
cwd: deck.root
|
|
57079
|
-
}
|
|
57089
|
+
{ cwd: deck.root, env: authEnv(deck.server) }
|
|
57080
57090
|
);
|
|
57081
57091
|
if (result.code !== 0)
|
|
57082
57092
|
throw new CliError(
|
|
@@ -57086,7 +57096,7 @@ Commit or stash your changes, then merge with \`git pull\`.`
|
|
|
57086
57096
|
);
|
|
57087
57097
|
await writeFormatGuide(deck.root, deck.server);
|
|
57088
57098
|
const rev = (await gitOk(["rev-parse", "HEAD"], { cwd: deck.root })).trim();
|
|
57089
|
-
out.result({
|
|
57099
|
+
out.result({ id: deck.id, rev }, () => `Up to date with the server (${rev.slice(0, 7)}).`);
|
|
57090
57100
|
}
|
|
57091
57101
|
async function runCheck(dir2) {
|
|
57092
57102
|
const started = performance.now();
|
|
@@ -57134,8 +57144,7 @@ async function pushWorkingCopy(out, deck, message) {
|
|
|
57134
57144
|
`note: media/${name} is ${Math.round(entry.size / 1e6)} MB. Every viewer downloads it; size it for the stage.`,
|
|
57135
57145
|
true
|
|
57136
57146
|
);
|
|
57137
|
-
const
|
|
57138
|
-
const uploaded = await uploadMedia(root, media, server, account, (m) => out.note(m));
|
|
57147
|
+
const uploaded = await uploadMedia(root, media, server, deck.id, (m) => out.note(m));
|
|
57139
57148
|
await gitOk(["add", "-A"], { cwd: root });
|
|
57140
57149
|
const committed = (await gitOk(["diff", "--cached", "--name-only"], { cwd: root })).split("\n").filter(Boolean);
|
|
57141
57150
|
for (const file2 of committed) out.note(` ${file2}`);
|
|
@@ -57147,7 +57156,7 @@ async function pushWorkingCopy(out, deck, message) {
|
|
|
57147
57156
|
out.note("pushing\u2026");
|
|
57148
57157
|
const pushed = await git(
|
|
57149
57158
|
[...credentialConfig(server), "push", "--porcelain", "origin", "HEAD:main"],
|
|
57150
|
-
{ cwd: root, echo: !out.json }
|
|
57159
|
+
{ cwd: root, echo: !out.json, env: authEnv(server) }
|
|
57151
57160
|
);
|
|
57152
57161
|
const remote = remoteLines(pushed.stderr);
|
|
57153
57162
|
if (pushed.code !== 0) {
|
|
@@ -57176,15 +57185,15 @@ async function push(out, args) {
|
|
|
57176
57185
|
process.exitCode = EXIT.problems;
|
|
57177
57186
|
return;
|
|
57178
57187
|
}
|
|
57179
|
-
const url = `${deck.server}/${deck.
|
|
57188
|
+
const url = `${deck.server}/${deck.id}`;
|
|
57180
57189
|
out.result(
|
|
57181
57190
|
{ ...result, pushed: true, url },
|
|
57182
57191
|
() => `\u2713 Pushed ${result.rev.slice(0, 7)}${result.uploaded.length ? ` with ${plural(result.uploaded.length, "media file")}` : ""}. Live at ${url}`
|
|
57183
57192
|
);
|
|
57184
57193
|
}
|
|
57185
|
-
async function pushIfChanged(out,
|
|
57194
|
+
async function pushIfChanged(out, id2, message) {
|
|
57186
57195
|
const found2 = await findDeck().catch(() => void 0);
|
|
57187
|
-
if (!found2?.server || found2.
|
|
57196
|
+
if (!found2?.server || found2.id !== id2) return { pushed: false, uploaded: [] };
|
|
57188
57197
|
const deck = found2;
|
|
57189
57198
|
const dirty = (await gitOk(["status", "--porcelain"], { cwd: deck.root })).trim() !== "";
|
|
57190
57199
|
const head = await git(["rev-parse", "--verify", "--quiet", "HEAD"], { cwd: deck.root });
|
|
@@ -57211,24 +57220,34 @@ async function identity(root) {
|
|
|
57211
57220
|
GIT_COMMITTER_EMAIL: who ?? "tobos@localhost"
|
|
57212
57221
|
};
|
|
57213
57222
|
}
|
|
57214
|
-
async function viewUrl(
|
|
57215
|
-
|
|
57216
|
-
return api(`/api/decks/${account}/${deck}/view`, { body: { view, hours } });
|
|
57223
|
+
async function viewUrl(id2, view, hours) {
|
|
57224
|
+
return api(`/api/decks/${id2}/view`, { body: { view, hours } });
|
|
57217
57225
|
}
|
|
57218
|
-
async function
|
|
57219
|
-
if (typeof args.values.deck === "string") return args.values.deck;
|
|
57220
|
-
return (await requireRemote()).
|
|
57226
|
+
async function deckId(args) {
|
|
57227
|
+
if (typeof args.values.deck === "string") return parseId(args.values.deck);
|
|
57228
|
+
return (await requireRemote()).id;
|
|
57221
57229
|
}
|
|
57222
57230
|
async function open2(out, args) {
|
|
57223
57231
|
const position3 = args.positionals[0];
|
|
57232
|
+
if (!position3 && typeof args.values.deck !== "string" && !await findDeck().catch(() => null))
|
|
57233
|
+
return openApp(out, args);
|
|
57224
57234
|
const view = args.values.presenter ? "presenter" : void 0;
|
|
57225
|
-
const
|
|
57226
|
-
const { pushed } = await pushIfChanged(out,
|
|
57227
|
-
const { url } = await viewUrl(
|
|
57235
|
+
const id2 = await deckId(args);
|
|
57236
|
+
const { pushed } = await pushIfChanged(out, id2);
|
|
57237
|
+
const { url } = await viewUrl(id2, view, 12);
|
|
57228
57238
|
const full = position3 ? `${url}#${position3}` : url;
|
|
57229
|
-
const opened = !args.values.print && openUrl(full);
|
|
57239
|
+
const opened = !args.values.print && await openUrl(full);
|
|
57230
57240
|
out.result({ url: full, opened, pushed }, () => full);
|
|
57231
57241
|
}
|
|
57242
|
+
async function openApp(out, args) {
|
|
57243
|
+
const { url } = await api("/api/login/browser", { method: "POST" });
|
|
57244
|
+
const opened = !args.values.print && await openUrl(url);
|
|
57245
|
+
out.result(
|
|
57246
|
+
{ url, opened },
|
|
57247
|
+
() => opened ? "Opened Tobos in the browser, logged in." : `${url}
|
|
57248
|
+
This link logs a browser in once, within 10 minutes.`
|
|
57249
|
+
);
|
|
57250
|
+
}
|
|
57232
57251
|
async function exportTarget(args, file2) {
|
|
57233
57252
|
if (args.values.out) return resolve3(args.values.out);
|
|
57234
57253
|
const deck = await findDeck().catch(() => void 0);
|
|
@@ -57238,12 +57257,11 @@ async function exportTarget(args, file2) {
|
|
|
57238
57257
|
}
|
|
57239
57258
|
async function exportDeck(out, args) {
|
|
57240
57259
|
const kind = args.positionals[0];
|
|
57241
|
-
const
|
|
57242
|
-
const { account, deck } = parseName(name);
|
|
57260
|
+
const id2 = await deckId(args);
|
|
57243
57261
|
if (kind === "pdf") {
|
|
57244
57262
|
const { exportPdf: exportPdf2 } = await Promise.resolve().then(() => (init_render(), render_exports));
|
|
57245
|
-
const { url, rev } = await viewUrl(
|
|
57246
|
-
const target = await exportTarget(args, `${
|
|
57263
|
+
const { url, rev } = await viewUrl(id2, "print");
|
|
57264
|
+
const target = await exportTarget(args, `${id2}.pdf`);
|
|
57247
57265
|
const pages = await exportPdf2(
|
|
57248
57266
|
url + (args.values.handout ? "&beats=last" : ""),
|
|
57249
57267
|
target,
|
|
@@ -57259,11 +57277,11 @@ async function exportDeck(out, args) {
|
|
|
57259
57277
|
}
|
|
57260
57278
|
async function render(out, args) {
|
|
57261
57279
|
const { renderBeats: renderBeats2 } = await Promise.resolve().then(() => (init_render(), render_exports));
|
|
57262
|
-
const deck = await findDeck();
|
|
57263
|
-
const
|
|
57264
|
-
if (!
|
|
57265
|
-
const { pushed, uploaded } = await pushIfChanged(out,
|
|
57266
|
-
const view = await viewUrl(
|
|
57280
|
+
const deck = await findDeck().catch(() => void 0);
|
|
57281
|
+
const id2 = typeof args.values.deck === "string" ? parseId(args.values.deck) : deck?.id;
|
|
57282
|
+
if (!id2) throw new CliError("Run this inside a cloned deck, or pass --deck <id>.");
|
|
57283
|
+
const { pushed, uploaded } = await pushIfChanged(out, id2, args.values.message);
|
|
57284
|
+
const view = await viewUrl(id2, "render");
|
|
57267
57285
|
const { url } = view;
|
|
57268
57286
|
const rev = view.rev ?? void 0;
|
|
57269
57287
|
const targets2 = [];
|
|
@@ -57276,13 +57294,14 @@ async function render(out, args) {
|
|
|
57276
57294
|
const scene = scenes.find((s) => s.id === sceneId);
|
|
57277
57295
|
if (!scene) throw new CliError(`No scene "${sceneId}" in deck.json.`);
|
|
57278
57296
|
if (beat) {
|
|
57279
|
-
const
|
|
57280
|
-
if (!
|
|
57297
|
+
const id3 = /^\d+$/.test(beat) ? scene.beats[Number(beat)] : beat;
|
|
57298
|
+
if (!id3 || !scene.beats.includes(id3))
|
|
57281
57299
|
throw new CliError(`No beat "${beat}" in scene "${sceneId}".`);
|
|
57282
|
-
targets2.push(`${scene.id}/${
|
|
57300
|
+
targets2.push(`${scene.id}/${id3}`);
|
|
57283
57301
|
} else targets2.push(...scene.beats.map((b) => `${scene.id}/${b}`));
|
|
57284
57302
|
}
|
|
57285
|
-
const
|
|
57303
|
+
const root = deck?.id === id2 ? deck.root : ".";
|
|
57304
|
+
const dir2 = resolve3(args.values.out ?? join9(root, ".tobos", "render"));
|
|
57286
57305
|
const { files, errors } = await renderBeats2(url, targets2, {
|
|
57287
57306
|
dir: dir2,
|
|
57288
57307
|
film: Boolean(args.values.film),
|
|
@@ -57341,11 +57360,11 @@ Account
|
|
|
57341
57360
|
tobos login --code <code> finish: the code they read from the mail
|
|
57342
57361
|
tobos logout forget this machine's token
|
|
57343
57362
|
tobos whoami who you are, on which server
|
|
57344
|
-
tobos decks your decks
|
|
57363
|
+
tobos decks your decks and templates, by id
|
|
57345
57364
|
|
|
57346
57365
|
Working on a deck
|
|
57347
|
-
tobos new "Title"
|
|
57348
|
-
tobos clone
|
|
57366
|
+
tobos new "Title" create a deck and clone it here, into ./<id>
|
|
57367
|
+
tobos clone <id> [dir] clone a deck, with the agent pack
|
|
57349
57368
|
tobos pull get the latest pushes and the format guide
|
|
57350
57369
|
tobos check [--types] compile and check the deck, offline (~1 s);
|
|
57351
57370
|
--types: TypeScript too (installs a checker once)
|
|
@@ -57355,6 +57374,7 @@ Looking at it (from the working copy, render and open push what changed first)
|
|
|
57355
57374
|
tobos render scene/beat | scene | --all PNGs of beats, for you to look at
|
|
57356
57375
|
[--film] [--frames 6] [--out dir] --film: frames through the animation
|
|
57357
57376
|
tobos open [scene/beat] [--presenter] the deck in a browser (prints the URL)
|
|
57377
|
+
tobos open outside a deck: Tobos in the browser, logged in
|
|
57358
57378
|
tobos export pdf [--out file] a PDF of every beat
|
|
57359
57379
|
|
|
57360
57380
|
The skill (what your harness reads to know Tobos without this help)
|
|
@@ -57362,8 +57382,9 @@ The skill (what your harness reads to know Tobos without this help)
|
|
|
57362
57382
|
read skills; later CLIs keep it up to date
|
|
57363
57383
|
|
|
57364
57384
|
Templates (decks people start from: a new deck copies a template's master/)
|
|
57365
|
-
tobos new "Title" --from
|
|
57366
|
-
|
|
57385
|
+
tobos new "Title" --from <id> start a deck from that template (default: your own,
|
|
57386
|
+
"My template")
|
|
57387
|
+
tobos new "Our brand" --template a new template: a copy of your default (or of --from)
|
|
57367
57388
|
|
|
57368
57389
|
Every command takes --json and then prints one JSON object.
|
|
57369
57390
|
Exit codes: 0 ok, 1 error, 2 the deck has problems, 3 not logged in.
|
|
@@ -57383,7 +57404,6 @@ var TABLE = {
|
|
|
57383
57404
|
new: {
|
|
57384
57405
|
run: create,
|
|
57385
57406
|
options: {
|
|
57386
|
-
slug: { type: "string" },
|
|
57387
57407
|
dir: { type: "string" },
|
|
57388
57408
|
"no-clone": { type: "boolean" },
|
|
57389
57409
|
from: { type: "string" },
|