@tokenoftrust/cli 1.4.0-rc.6 → 1.4.0-rc.8
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/README.md +6 -6
- package/bin/tot.mjs +18 -7
- package/package.json +2 -2
- package/src/commands/{checkout.mjs → clone.mjs} +43 -25
- package/src/commands/dev.mjs +4 -4
- package/src/commands/doctor.mjs +3 -3
- package/src/commands/grants.mjs +1 -1
- package/src/commands/link.mjs +14 -6
- package/src/commands/login.mjs +4 -4
- package/src/commands/start.mjs +2 -2
- package/src/commands/validate.mjs +2 -2
- package/src/commands/whoami.mjs +1 -1
- package/src/context.mjs +2 -2
- package/src/obstacle-beacon.cjs +1 -1
package/README.md
CHANGED
|
@@ -5,8 +5,8 @@ One command to go from a Token of Trust invite to a running store.
|
|
|
5
5
|
```sh
|
|
6
6
|
npm i -g @tokenoftrust/cli
|
|
7
7
|
|
|
8
|
-
tot
|
|
9
|
-
tot
|
|
8
|
+
tot clone # list the stores you can build on
|
|
9
|
+
tot clone <tenant> my-store # mirrors `git clone`; dir defaults to <tenant>
|
|
10
10
|
cd my-store
|
|
11
11
|
tot dev # run it locally with save→reload — no Docker needed
|
|
12
12
|
tot submit # (coming) submit it for preview
|
|
@@ -22,7 +22,7 @@ be fetched.)
|
|
|
22
22
|
|
|
23
23
|
| Command | Status | What it does |
|
|
24
24
|
| --- | --- | --- |
|
|
25
|
-
| `tot
|
|
25
|
+
| `tot clone [<tenant>] [<dir>]` | **built** | Clone a store you're entitled to build on (mirrors `git clone`), with an authenticated remote configured. Dir defaults to `<tenant>`. No arg → list your stores. |
|
|
26
26
|
| `tot validate` | next | Lint your store before you submit. |
|
|
27
27
|
| `tot dev` | **built** | Run your store locally with save→reload — NATIVELY (no Docker; falls back to it with `--docker` or automatically if the native artifact isn't available). |
|
|
28
28
|
| `tot submit` | next | Submit your store for preview (pushes the preview ref, reports the reconcile/compliance verdict + preview URL). |
|
|
@@ -34,7 +34,7 @@ The same `tot` does the right thing wherever you run it (walks up like `git`):
|
|
|
34
34
|
|
|
35
35
|
- **storefront monorepo** — a full platform checkout;
|
|
36
36
|
- **tenant checkout** — a standalone `content/ public/ theme.json .tot/config.json` clone (tenant read from `.tot/config.json`);
|
|
37
|
-
- **loose** — anywhere else; `tot
|
|
37
|
+
- **loose** — anywhere else; `tot clone <tenant>` gets you a checkout.
|
|
38
38
|
|
|
39
39
|
`tot doctor` prints the detected context.
|
|
40
40
|
|
|
@@ -42,8 +42,8 @@ The same `tot` does the right thing wherever you run it (walks up like `git`):
|
|
|
42
42
|
|
|
43
43
|
`tot` talks to the Token of Trust MCP (default `https://mcp.tokenoftrust.com`, override with `--mcp` or `MCP_BASE_URL`). It is **single-plane**: the only identity is **you**, signed in against the MCP over OAuth.
|
|
44
44
|
|
|
45
|
-
- Run `tot login` once — it opens your browser (or falls back to a device code on a headless box), you sign in as yourself, and the session is cached at `~/.tot/credentials.json` and refreshed silently. Every later command (`tot
|
|
46
|
-
- Not signed in? On a terminal, `tot start` / `tot
|
|
45
|
+
- Run `tot login` once — it opens your browser (or falls back to a device code on a headless box), you sign in as yourself, and the session is cached at `~/.tot/credentials.json` and refreshed silently. Every later command (`tot clone`, `tot start`, `tot submit`, …) runs as you, with no re-auth. Entitlement is derived server-side from your ToT memberships.
|
|
46
|
+
- Not signed in? On a terminal, `tot start` / `tot clone` **offer to sign you in right there** and continue in-flow — no "run `tot login`, then re-run".
|
|
47
47
|
- The old operator env-triple (`TOT_API_KEY` / `TOT_SECRET_KEY` / `TOT_APP_DOMAIN`) **no longer signs the CLI in** — tot-mcp went OAuth-first on 2026-07-23. If those vars are set, `tot` prints a one-line advisory and uses your `tot login` session anyway; it never reads them for auth.
|
|
48
48
|
|
|
49
49
|
### Optional: multiple identities at once (`TOT_PROFILE`)
|
package/bin/tot.mjs
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* tot whoami who you're signed in as ← built
|
|
11
11
|
* tot link link your identity to the ToT broker (resolve store scope) ← built
|
|
12
12
|
* tot grants capability/tier/expiry per store you can act on ← built (introspection diagnostics)
|
|
13
|
-
* tot
|
|
13
|
+
* tot clone [<tenant>] clone a store you can build on ← built
|
|
14
14
|
* tot validate lint your store before you submit ← built
|
|
15
15
|
* tot dev run your store locally with save→reload ← built (monorepo: host astro; standalone: runs the published runner image)
|
|
16
16
|
* tot submit submit your store for preview ← built (validate + push preview ref; MCP preview_status read-back)
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* from anywhere else. Every command receives the detected context.
|
|
26
26
|
*
|
|
27
27
|
* This package is `@tokenoftrust/cli` (bin `tot`). Its heaviest command, `tot dev`,
|
|
28
|
-
* fetches the published storefront runner; `tot
|
|
28
|
+
* fetches the published storefront runner; `tot clone/validate/submit` are
|
|
29
29
|
* pure Node. Dependency-free by design so `npm i -g @tokenoftrust/cli` stays light.
|
|
30
30
|
*/
|
|
31
31
|
import "../src/ensure-node.mjs"; // hard Node-version gate — must stay first (see the module doc)
|
|
@@ -35,7 +35,7 @@ import { printError } from "../src/errors.mjs";
|
|
|
35
35
|
import { recordActivity, redactArgs } from "../src/activity-log.mjs";
|
|
36
36
|
import { maybeNotifyUpdate } from "../src/update-check.mjs";
|
|
37
37
|
|
|
38
|
-
const BUILD_ORDER = ["
|
|
38
|
+
const BUILD_ORDER = ["clone", "validate", "dev", "submit"];
|
|
39
39
|
|
|
40
40
|
// CLI version (stamped into the activity log). Read from our own package.json; best-effort.
|
|
41
41
|
const VERSION = (() => {
|
|
@@ -56,7 +56,7 @@ tot — Token of Trust developer CLI
|
|
|
56
56
|
tot whoami show who you're signed in as
|
|
57
57
|
tot link link your identity so your stores resolve
|
|
58
58
|
tot grants capability/tier/expiry per store you can act on
|
|
59
|
-
tot
|
|
59
|
+
tot clone [<tenant>] clone a store you can build on
|
|
60
60
|
tot validate lint your store before you submit
|
|
61
61
|
tot dev run your store locally with save→reload
|
|
62
62
|
tot submit submit your store for preview
|
|
@@ -131,8 +131,8 @@ async function dispatch(cmd, rest, ctx) {
|
|
|
131
131
|
return run(rest, ctx);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
if (cmd === "
|
|
135
|
-
const { run } = await import("../src/commands/
|
|
134
|
+
if (cmd === "clone") {
|
|
135
|
+
const { run } = await import("../src/commands/clone.mjs");
|
|
136
136
|
return run(rest, ctx);
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -156,10 +156,21 @@ async function dispatch(cmd, rest, ctx) {
|
|
|
156
156
|
return run(rest, ctx);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
// `checkout` was deliberately freed up: it's no longer a tot verb precisely so it
|
|
160
|
+
// can mean what it means in git. Point both ways rather than a bare "unknown".
|
|
161
|
+
if (cmd === "checkout") {
|
|
162
|
+
console.error(
|
|
163
|
+
"`tot checkout` isn't a tot command — `checkout` now means what it does in git.\n\n" +
|
|
164
|
+
" • switch branches / restore files in your store: git checkout <ref>\n" +
|
|
165
|
+
" • clone a store you can build on: tot clone <tenant>\n",
|
|
166
|
+
);
|
|
167
|
+
return 2;
|
|
168
|
+
}
|
|
169
|
+
|
|
159
170
|
if (BUILD_ORDER.includes(cmd)) {
|
|
160
171
|
console.error(
|
|
161
172
|
`\`tot ${cmd}\` isn't built yet.\n\n` +
|
|
162
|
-
`Build order: ${BUILD_ORDER.map((c) => (c === "
|
|
173
|
+
`Build order: ${BUILD_ORDER.map((c) => (c === "clone" ? `${c}✓` : c)).join(" → ")}.\n` +
|
|
163
174
|
`Inside a storefront checkout you can use the in-repo scripts today ` +
|
|
164
175
|
`(e.g. \`pnpm tot ${cmd}\`).`,
|
|
165
176
|
);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/cli",
|
|
3
|
-
"version": "1.4.0-rc.
|
|
4
|
-
"description": "Token of Trust developer CLI —
|
|
3
|
+
"version": "1.4.0-rc.8",
|
|
4
|
+
"description": "Token of Trust developer CLI — clone a tenant store, run it locally with save→reload, and submit it for preview. Installs the `tot` command.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Token of Trust",
|
|
7
7
|
"homepage": "https://www.tokenoftrust.com",
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `tot
|
|
3
|
-
* authenticated remote already configured, ready for the local loop.
|
|
2
|
+
* `tot clone` — clone the tenant store you're entitled to build on, with an
|
|
3
|
+
* authenticated remote already configured, ready for the local loop. Mirrors
|
|
4
|
+
* `git clone <repo> [dir]`: the tenant is the repo, the dir defaults to the
|
|
5
|
+
* tenant name. (Named `clone`, not `checkout`, so it means what `git clone`
|
|
6
|
+
* means — materialize a local working copy — and never collides with the
|
|
7
|
+
* unrelated `git checkout` = switch-refs verb.)
|
|
4
8
|
*
|
|
5
|
-
* tot
|
|
6
|
-
* tot
|
|
7
|
-
* tot
|
|
9
|
+
* tot clone list the stores you can build on
|
|
10
|
+
* tot clone <tenant> clone into ./<tenant> (authenticated remote configured)
|
|
11
|
+
* tot clone <tenant> <dir> clone into <dir>
|
|
12
|
+
* tot clone <tenant> --remote-only just mint + print the remote, don't materialize
|
|
8
13
|
*
|
|
9
14
|
* This is the SAME MCP code path a developer gets when they switch to a tenant:
|
|
10
15
|
* sign-in → client_switch(tenant) → tenant_checkout, where the MCP derives your
|
|
11
16
|
* per-tenant Git user and mints a FRESH, single-active, repo-scoped push
|
|
12
|
-
* credential (a later
|
|
13
|
-
* privileged forge work itself — the MCP owns that.
|
|
17
|
+
* credential (a later clone for the same tenant rotates it). `tot` performs NO
|
|
18
|
+
* privileged forge work itself — the MCP owns that. ("checkout" survives only as
|
|
19
|
+
* the domain/lease term: the `tenant_checkout` MCP tool + the on-disk noun for a
|
|
20
|
+
* materialized store dir — never as a developer-facing verb.)
|
|
14
21
|
*
|
|
15
22
|
* Auth is the developer's own ToT identity (the cached `tot login` session,
|
|
16
23
|
* resolved via src/auth.mjs). When there's no session yet and we're on a TTY, we
|
|
@@ -34,8 +41,9 @@ const DEFAULT_MCP_URL = "https://mcp.tokenoftrust.com";
|
|
|
34
41
|
function parseArgs(argv) {
|
|
35
42
|
const a = {
|
|
36
43
|
tenant: null,
|
|
44
|
+
dir: null,
|
|
37
45
|
tag: "main",
|
|
38
|
-
|
|
46
|
+
remoteOnly: false,
|
|
39
47
|
mcp: null,
|
|
40
48
|
printRemote: false,
|
|
41
49
|
help: false,
|
|
@@ -43,27 +51,32 @@ function parseArgs(argv) {
|
|
|
43
51
|
for (let i = 0; i < argv.length; i++) {
|
|
44
52
|
const t = argv[i];
|
|
45
53
|
if (t === "--tag") a.tag = argv[++i];
|
|
46
|
-
else if (t === "--
|
|
54
|
+
else if (t === "--remote-only") a.remoteOnly = true;
|
|
47
55
|
else if (t === "--mcp") a.mcp = argv[++i];
|
|
48
56
|
else if (t === "--print-remote") a.printRemote = true;
|
|
49
57
|
else if (t === "--help" || t === "-h") a.help = true;
|
|
50
|
-
|
|
58
|
+
// Positional, git-clone style: `tot clone <tenant> [<dir>]`.
|
|
59
|
+
else if (!t.startsWith("--")) {
|
|
60
|
+
if (!a.tenant) a.tenant = t;
|
|
61
|
+
else if (!a.dir) a.dir = t;
|
|
62
|
+
}
|
|
51
63
|
}
|
|
52
64
|
return a;
|
|
53
65
|
}
|
|
54
66
|
|
|
55
|
-
const USAGE = `tot
|
|
67
|
+
const USAGE = `tot clone — clone a tenant store you can build on (mirrors \`git clone\`)
|
|
56
68
|
|
|
57
|
-
tot
|
|
58
|
-
tot
|
|
59
|
-
tot
|
|
69
|
+
tot clone list the stores you can build on
|
|
70
|
+
tot clone <tenant> clone into ./<tenant> (authenticated remote configured)
|
|
71
|
+
tot clone <tenant> <dir> clone into <dir>
|
|
60
72
|
|
|
61
73
|
Options:
|
|
62
74
|
--tag <tag> which repo (repo = "<tenant>-<tag>"). Default: main.
|
|
63
|
-
--
|
|
75
|
+
--remote-only don't clone; just mint + print the clone URL for <tenant>.
|
|
64
76
|
--mcp <url> MCP base URL. Default: env MCP_BASE_URL / TOT_MCP_URL, else
|
|
65
77
|
${DEFAULT_MCP_URL}.
|
|
66
|
-
--print-remote also print the authenticated remote
|
|
78
|
+
--print-remote with --remote-only, also print the authenticated remote
|
|
79
|
+
(contains a live token!).`;
|
|
67
80
|
|
|
68
81
|
/** Redact known secrets from any string before it hits the terminal. */
|
|
69
82
|
function makeRedactor(env) {
|
|
@@ -92,6 +105,11 @@ export async function run(argv, ctx) {
|
|
|
92
105
|
args.tenant = ctx.tenant;
|
|
93
106
|
}
|
|
94
107
|
|
|
108
|
+
// git-clone semantics: unless you explicitly asked for --remote-only, cloning
|
|
109
|
+
// is the default, and the target dir defaults to the tenant name (like
|
|
110
|
+
// `git clone <url>` deriving the dir from the repo basename).
|
|
111
|
+
const cloneDir = args.remoteOnly ? null : args.dir || args.tenant;
|
|
112
|
+
|
|
95
113
|
const baseUrl = args.mcp || env.MCP_BASE_URL || env.TOT_MCP_URL || DEFAULT_MCP_URL;
|
|
96
114
|
const redact = makeRedactor(env);
|
|
97
115
|
const client = createMcpClient(baseUrl);
|
|
@@ -128,21 +146,21 @@ export async function run(argv, ctx) {
|
|
|
128
146
|
const res = await checkoutTenant(client, {
|
|
129
147
|
tenant: args.tenant,
|
|
130
148
|
tag: args.tag,
|
|
131
|
-
cloneDir
|
|
149
|
+
cloneDir,
|
|
132
150
|
redact,
|
|
133
151
|
});
|
|
134
|
-
console.log(`\n+
|
|
152
|
+
console.log(`\n+ ready. repo: ${res.cloneUrl || res.publicUrl}`);
|
|
135
153
|
|
|
136
154
|
if (res.cloned) {
|
|
137
155
|
console.log(`+ cloned. HEAD: ${res.head}`);
|
|
138
156
|
console.log(`\nYour local working clone is at ${res.dir} with an authenticated remote.`);
|
|
139
157
|
console.log(` cd ${res.dir} && tot dev # run it locally with save→reload`);
|
|
140
|
-
console.log(` (the minted token lives in .git/config; a later
|
|
158
|
+
console.log(` (the minted token lives in .git/config; a later clone rotates it)`);
|
|
141
159
|
return 0;
|
|
142
160
|
}
|
|
143
161
|
|
|
144
162
|
console.log(`\nPublic clone URL (no credential): ${res.publicUrl}`);
|
|
145
|
-
console.log(`
|
|
163
|
+
console.log(`Drop --remote-only to clone with the authenticated remote configured.`);
|
|
146
164
|
if (args.printRemote) {
|
|
147
165
|
console.log(
|
|
148
166
|
`\nAUTHENTICATED remote (contains a live token — handle carefully):\n${res.gitRemote}`,
|
|
@@ -164,7 +182,7 @@ export async function run(argv, ctx) {
|
|
|
164
182
|
}
|
|
165
183
|
|
|
166
184
|
/**
|
|
167
|
-
* The privileged checkout core, composable in-process (used by `tot
|
|
185
|
+
* The privileged checkout core, composable in-process (used by `tot clone`
|
|
168
186
|
* and by `tot start`): client_switch → tenant_checkout → optionally clone. The
|
|
169
187
|
* MCP mints a fresh, repo-scoped push credential each time. Assumes `client` is
|
|
170
188
|
* already initialized + has a validated session.
|
|
@@ -211,7 +229,7 @@ async function cloneRepo(gitRemote, dir, redact) {
|
|
|
211
229
|
await git(["clone", gitRemote, dir]);
|
|
212
230
|
} catch (e) {
|
|
213
231
|
// Beacon the cockpit before we surface the error — covers this path for both
|
|
214
|
-
// `tot
|
|
232
|
+
// `tot clone` and `tot start` (which clones through here). Awaited so the
|
|
215
233
|
// packet lands before the process prints + exits; swallowed either way.
|
|
216
234
|
await emitObstacle("clone-failed");
|
|
217
235
|
throw new CliError(`clone failed: ${redact(String(e.stderr || e.message || e))}`, {
|
|
@@ -255,13 +273,13 @@ export function checkoutError(checkout) {
|
|
|
255
273
|
}
|
|
256
274
|
return {
|
|
257
275
|
message: msg || "the store checkout couldn't be completed",
|
|
258
|
-
next: "confirm you're entitled to this store — `tot
|
|
276
|
+
next: "confirm you're entitled to this store — `tot clone` (lists your stores)",
|
|
259
277
|
};
|
|
260
278
|
}
|
|
261
279
|
|
|
262
280
|
/**
|
|
263
281
|
* Normalize the (shape-varying) `client_list` response into a plain, sorted
|
|
264
|
-
* list of the stores this identity can build on. Shared by `tot
|
|
282
|
+
* list of the stores this identity can build on. Shared by `tot clone`'s
|
|
265
283
|
* listing and `tot start`'s auto-pick so both read the same fields.
|
|
266
284
|
* @param {unknown} list
|
|
267
285
|
* @returns {Array<{ id: string, name: string, raw: any }>}
|
|
@@ -409,5 +427,5 @@ function printClientList(list) {
|
|
|
409
427
|
for (const s of stores) {
|
|
410
428
|
console.log(` ${s.id}${s.name ? ` — ${s.name}` : ""}`);
|
|
411
429
|
}
|
|
412
|
-
console.log(`\nNext: tot
|
|
430
|
+
console.log(`\nNext: tot clone <tenant>`);
|
|
413
431
|
}
|
package/src/commands/dev.mjs
CHANGED
|
@@ -138,7 +138,7 @@ export async function run(argv, ctx) {
|
|
|
138
138
|
console.error(
|
|
139
139
|
fail(
|
|
140
140
|
"nothing to run — you're not inside a tenant checkout",
|
|
141
|
-
"tot
|
|
141
|
+
"tot clone <tenant> (then `cd` in and re-run), pass --workspace <dir>, or try `tot dev --sample`",
|
|
142
142
|
),
|
|
143
143
|
);
|
|
144
144
|
return 2;
|
|
@@ -194,7 +194,7 @@ async function runNativePublic(workspace, args, ctx) {
|
|
|
194
194
|
const cfg = readWorkspaceConfig(workspace);
|
|
195
195
|
if (!cfg) {
|
|
196
196
|
throw new CliError(`${workspace} isn't a tenant checkout (no readable .tot/config.json)`, {
|
|
197
|
-
next: "tot
|
|
197
|
+
next: "tot clone <tenant> (produces a runnable checkout)",
|
|
198
198
|
exitCode: 2,
|
|
199
199
|
});
|
|
200
200
|
}
|
|
@@ -280,7 +280,7 @@ async function runNative(workspace, args, ctx) {
|
|
|
280
280
|
const cfg = readWorkspaceConfig(workspace);
|
|
281
281
|
if (!cfg) {
|
|
282
282
|
throw new CliError(`${workspace} isn't a tenant checkout (no readable .tot/config.json)`, {
|
|
283
|
-
next: "tot
|
|
283
|
+
next: "tot clone <tenant> (produces a runnable checkout)",
|
|
284
284
|
exitCode: 2,
|
|
285
285
|
});
|
|
286
286
|
}
|
|
@@ -1240,7 +1240,7 @@ export function buildContainerPlan(workspace, args, _ctx) {
|
|
|
1240
1240
|
const cfg = readWorkspaceConfig(workspace);
|
|
1241
1241
|
if (!cfg) {
|
|
1242
1242
|
throw new CliError(`${workspace} isn't a tenant checkout (no readable .tot/config.json)`, {
|
|
1243
|
-
next: "tot
|
|
1243
|
+
next: "tot clone <tenant> (produces a runnable checkout)",
|
|
1244
1244
|
exitCode: 2,
|
|
1245
1245
|
});
|
|
1246
1246
|
}
|
package/src/commands/doctor.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `tot doctor` — is this machine ready to run the loop?
|
|
3
3
|
*
|
|
4
|
-
* Standalone (unlike the in-monorepo doctor): checks the things `tot
|
|
4
|
+
* Standalone (unlike the in-monorepo doctor): checks the things `tot clone`
|
|
5
5
|
* and `tot dev`/`tot start` actually need — Node, git, an MCP URL, whether an
|
|
6
6
|
* auth identity is available, and Docker — plus reports the detected context
|
|
7
7
|
* so a developer knows which mode `tot` will use here.
|
|
@@ -187,7 +187,7 @@ export async function run(argv, ctx) {
|
|
|
187
187
|
}
|
|
188
188
|
console.log(
|
|
189
189
|
failed === 0
|
|
190
|
-
? "\n✔ Ready. Try: tot start (checks out your store and runs it), or tot
|
|
190
|
+
? "\n✔ Ready. Try: tot start (checks out your store and runs it), or tot clone\n"
|
|
191
191
|
: args.fix
|
|
192
192
|
? `\n✖ ${failed} check(s) still failing — see the exact next command(s) above, then re-run \`tot doctor\`.\n`
|
|
193
193
|
: `\n✖ ${failed} check(s) failed — try \`tot doctor --fix\`, or fix the above, then re-run \`tot doctor\`.\n`,
|
|
@@ -199,5 +199,5 @@ function describeContext(ctx) {
|
|
|
199
199
|
if (ctx.mode === "monorepo") return `storefront monorepo (${ctx.repoRoot})`;
|
|
200
200
|
if (ctx.mode === "checkout")
|
|
201
201
|
return `tenant checkout${ctx.tenant ? ` for "${ctx.tenant}"` : ""} (${ctx.workspacePath})`;
|
|
202
|
-
return "loose (not inside a checkout — `tot
|
|
202
|
+
return "loose (not inside a checkout — `tot clone <tenant>` to get one)";
|
|
203
203
|
}
|
package/src/commands/grants.mjs
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
import { defaultCredentialsPath, readCredentials } from "../token-store.mjs";
|
|
27
27
|
import { establishSession, AuthUnavailableError } from "../auth.mjs";
|
|
28
28
|
import { createMcpClient } from "../mcp.mjs";
|
|
29
|
-
import { storeListError, noStoresGuidance } from "./
|
|
29
|
+
import { storeListError, noStoresGuidance } from "./clone.mjs";
|
|
30
30
|
import { offerSignIn } from "./login.mjs";
|
|
31
31
|
import { recordServerPolicy } from "../update-check.mjs";
|
|
32
32
|
|
package/src/commands/link.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Some developers sign in fine (a valid ToT OAuth session) but their identity
|
|
6
6
|
* isn't yet linked to the broker that maps a person → the tenants they can build
|
|
7
|
-
* on — so `tot start` / `tot
|
|
7
|
+
* on — so `tot start` / `tot clone` / `tot whoami` resolve ZERO stores. That's
|
|
8
8
|
* NOT a "you weren't invited" problem and NOT "the invite is still propagating";
|
|
9
9
|
* it's a one-time link step. This command drives it end-to-end from the terminal:
|
|
10
10
|
*
|
|
@@ -24,7 +24,7 @@ import { establishSession, AuthUnavailableError } from "../auth.mjs";
|
|
|
24
24
|
import { offerSignIn } from "./login.mjs";
|
|
25
25
|
import { openBrowser } from "../open.mjs";
|
|
26
26
|
import { CliError, fail, formatError } from "../errors.mjs";
|
|
27
|
-
import { normalizeStores } from "./
|
|
27
|
+
import { normalizeStores } from "./clone.mjs";
|
|
28
28
|
|
|
29
29
|
const DEFAULT_MCP_URL = "https://mcp.tokenoftrust.com";
|
|
30
30
|
|
|
@@ -83,9 +83,17 @@ export function linkPollStatus(res) {
|
|
|
83
83
|
(typeof c.status === "string" && c.status) || (typeof c.state === "string" && c.state) || "";
|
|
84
84
|
const s = raw.toLowerCase();
|
|
85
85
|
if (!s) return "pending";
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
// The broker namespaces its poll status with a `link_` prefix (e.g. `link_pending`,
|
|
87
|
+
// `link_approved`, `link_denied`) — strip it before matching so a normal "still
|
|
88
|
+
// waiting" state isn't misread as an unknown/error status and doesn't abort the poll.
|
|
89
|
+
// (Regression: `link_pending` fell through to the error branch and killed `tot link`
|
|
90
|
+
// the instant the developer hadn't yet finished the browser step.)
|
|
91
|
+
const bare = s.replace(/^link[_-]/, "");
|
|
92
|
+
if (/^(linked|link|complete|completed|done|ok|success|succeeded|active|approved|granted)$/.test(bare))
|
|
93
|
+
return "linked";
|
|
94
|
+
if (/^(pending|waiting|in_?progress|processing|started|created|authorizing|polling)$/.test(bare))
|
|
95
|
+
return "pending";
|
|
96
|
+
return s; // a terminal error status (link_denied, link_expired, …) — surfaced to the caller
|
|
89
97
|
}
|
|
90
98
|
|
|
91
99
|
/** @param {string[]} argv @param {any} _ctx */
|
|
@@ -160,7 +168,7 @@ export async function run(argv, _ctx) {
|
|
|
160
168
|
const stores = normalizeStores(list);
|
|
161
169
|
if (stores.length) {
|
|
162
170
|
console.log(` stores you can build on: ${stores.map((s) => s.id).join(", ")}`);
|
|
163
|
-
console.log(" Next: `tot start` (or `tot
|
|
171
|
+
console.log(" Next: `tot start` (or `tot clone <tenant>`).");
|
|
164
172
|
} else {
|
|
165
173
|
console.log(" Next: `tot start` — if it still shows no stores, ask your ToT contact for a store invite.");
|
|
166
174
|
}
|
package/src/commands/login.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Runs the MCP OAuth 2.1 PKCE loopback (the same ceremony `claude mcp add` runs):
|
|
5
5
|
* opens the browser to the MCP's authorize page, the developer signs in with their
|
|
6
6
|
* ToT identity + approves, and the loopback catches the code and exchanges it for a
|
|
7
|
-
* token cached at ~/.tot/credentials.json. Every later command (`tot
|
|
7
|
+
* token cached at ~/.tot/credentials.json. Every later command (`tot clone`,
|
|
8
8
|
* `tot submit`, …) then runs as that developer with NO re-auth.
|
|
9
9
|
*
|
|
10
10
|
* The MCP defaults to the same target `tot submit` talks to (env MCP_BASE_URL /
|
|
@@ -109,7 +109,7 @@ const USAGE = `tot login — sign in to Token of Trust
|
|
|
109
109
|
link a later \`tot feedback\` report to your invite + session) — not meant to be
|
|
110
110
|
typed by hand.
|
|
111
111
|
|
|
112
|
-
After signing in, run \`tot whoami\` to confirm, then \`tot
|
|
112
|
+
After signing in, run \`tot whoami\` to confirm, then \`tot clone\` / \`tot submit\`.`;
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* The core of `tot login`: run the OAuth ceremony (browser loopback, or the
|
|
@@ -270,7 +270,7 @@ export async function run(argv, _ctx) {
|
|
|
270
270
|
cacheTraceId(env, args.traceId);
|
|
271
271
|
cacheEmailHint(env, args.emailHint);
|
|
272
272
|
console.log(`\n+ signed in. Session cached to ${defaultCredentialsPath(env)}.`);
|
|
273
|
-
console.log(" Next: `tot whoami` to confirm, or `tot
|
|
273
|
+
console.log(" Next: `tot whoami` to confirm, or `tot clone` / `tot submit` to build.");
|
|
274
274
|
return 0;
|
|
275
275
|
} catch (e) {
|
|
276
276
|
console.error(
|
|
@@ -288,7 +288,7 @@ export async function run(argv, _ctx) {
|
|
|
288
288
|
await loginAndCache(mcpUrl, env, { log: (m) => console.error(m), device: args.device });
|
|
289
289
|
cacheTraceId(env, args.traceId);
|
|
290
290
|
console.log(`\n+ signed in. Session cached to ${defaultCredentialsPath(env)}.`);
|
|
291
|
-
console.log(" Next: `tot whoami` to confirm, or `tot
|
|
291
|
+
console.log(" Next: `tot whoami` to confirm, or `tot clone` / `tot submit` to build.");
|
|
292
292
|
return 0;
|
|
293
293
|
} catch (e) {
|
|
294
294
|
console.error(
|
package/src/commands/start.mjs
CHANGED
|
@@ -59,7 +59,7 @@ import { startProgress } from "../progress.mjs";
|
|
|
59
59
|
import { defaultLastTenantPath, readLastTenant, writeLastTenant } from "../last-tenant.mjs";
|
|
60
60
|
import { readCredentials, defaultCredentialsPath } from "../token-store.mjs";
|
|
61
61
|
import { collectChecks } from "./doctor.mjs";
|
|
62
|
-
import { normalizeStores, storeListError, checkoutTenant, noStoresGuidance } from "./
|
|
62
|
+
import { normalizeStores, storeListError, checkoutTenant, noStoresGuidance } from "./clone.mjs";
|
|
63
63
|
import {
|
|
64
64
|
buildContainerPlan, spawnDevContainer, dockerAvailable, tryStartDocker,
|
|
65
65
|
resolveDevImage, isPrivateRegistryImage, ensureRegistryLogin,
|
|
@@ -633,7 +633,7 @@ async function ensureCheckout(client, tenant, dir, env) {
|
|
|
633
633
|
console.log(` ✓ reusing existing checkout ./${tenant}`);
|
|
634
634
|
return;
|
|
635
635
|
}
|
|
636
|
-
throw new CliError(`./${tenant} already exists and isn't a
|
|
636
|
+
throw new CliError(`./${tenant} already exists and isn't a store checkout`, {
|
|
637
637
|
next: `remove it (or run \`tot start\` from an empty directory)`,
|
|
638
638
|
exitCode: 2,
|
|
639
639
|
});
|
|
@@ -68,11 +68,11 @@ export function run(argv, ctx) {
|
|
|
68
68
|
|
|
69
69
|
const target = resolveTarget(args, ctx);
|
|
70
70
|
if (target.error) {
|
|
71
|
-
console.error(fail(target.error, "tot
|
|
71
|
+
console.error(fail(target.error, "tot clone <tenant>, or pass --workspace <dir>"));
|
|
72
72
|
return 2;
|
|
73
73
|
}
|
|
74
74
|
if (!existsSync(target.dir)) {
|
|
75
|
-
console.error(fail(`no tenant directory at ${target.dir}`, "confirm the path, or `tot
|
|
75
|
+
console.error(fail(`no tenant directory at ${target.dir}`, "confirm the path, or `tot clone <tenant>`"));
|
|
76
76
|
return 2;
|
|
77
77
|
}
|
|
78
78
|
|
package/src/commands/whoami.mjs
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { defaultCredentialsPath, readCredentials, isExpired, activeProfile } from "../token-store.mjs";
|
|
12
12
|
import { establishSession } from "../auth.mjs";
|
|
13
13
|
import { createMcpClient } from "../mcp.mjs";
|
|
14
|
-
import { normalizeStores, storeListError, noStoresGuidance } from "./
|
|
14
|
+
import { normalizeStores, storeListError, noStoresGuidance } from "./clone.mjs";
|
|
15
15
|
import { recordServerPolicy } from "../update-check.mjs";
|
|
16
16
|
|
|
17
17
|
/**
|
package/src/context.mjs
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
* monorepo — inside a full storefront checkout (pnpm-workspace.yaml +
|
|
8
8
|
* apps/storefront + tenants/). This is us / a platform dev.
|
|
9
|
-
* `tot dev` here runs the in-tree astro dev; `tot
|
|
9
|
+
* `tot dev` here runs the in-tree astro dev; `tot clone`
|
|
10
10
|
* can suggest cloning a sibling dir.
|
|
11
11
|
* checkout — inside a STANDALONE tenant checkout: the flat, content-only
|
|
12
12
|
* shape `content/ public/ theme.json .tot/config.json` a
|
|
13
13
|
* developer clones. The tenant is read from .tot/config.json.
|
|
14
14
|
* `tot dev` here boots the bundled runner against this dir.
|
|
15
|
-
* loose — anywhere else. `tot
|
|
15
|
+
* loose — anywhere else. `tot clone <tenant>` still works (it's how
|
|
16
16
|
* you GET a checkout); commands that need a workspace say so.
|
|
17
17
|
*
|
|
18
18
|
* Detection walks UP from the cwd so `tot` works from any subdirectory of a
|
package/src/obstacle-beacon.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The obstacle beacon — a fire-and-forget POST that tells the hosted cockpit a
|
|
3
|
-
* `tot start` / `tot
|
|
3
|
+
* `tot start` / `tot clone` failed, so it can show the exact fix in the bridge
|
|
4
4
|
* strip (obstacle lane, server side already shipped). Best-effort telemetry that
|
|
5
5
|
* rides ALONGSIDE the house-style `✗ … → next:` error; it must NEVER change,
|
|
6
6
|
* delay past its timeout, or fail that error path.
|