@tokenoftrust/cli 2.2.6 → 2.2.7
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/package.json +1 -1
- package/src/commands/git-credential.mjs +36 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/cli",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.7",
|
|
4
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",
|
|
@@ -22,14 +22,25 @@
|
|
|
22
22
|
* git config by `tot clone agency-kit`) mints through `repo_read_credential`,
|
|
23
23
|
* cached under a key a store's can never take.
|
|
24
24
|
*
|
|
25
|
-
* FAILS SILENT, NEVER LOUD: `get` prints NOTHING
|
|
26
|
-
* problem (not signed in, MCP unreachable, cwd isn't a
|
|
27
|
-
* checkout) — git then falls through to its next
|
|
28
|
-
* own prompt, exactly as if this helper weren't
|
|
29
|
-
* a malformed credential line
|
|
30
|
-
* operation in the checkout. It also NEVER
|
|
31
|
-
* this runs as a non-interactive subprocess
|
|
32
|
-
* fails through rather than trying to open a
|
|
25
|
+
* FAILS SILENT ON STDOUT, NEVER LOUD THERE: `get` prints NOTHING on stdout and
|
|
26
|
+
* exits non-zero on any problem (not signed in, MCP unreachable, cwd isn't a
|
|
27
|
+
* recognizable tenant checkout) — git then falls through to its next
|
|
28
|
+
* configured helper or its own prompt, exactly as if this helper weren't
|
|
29
|
+
* configured. A stack trace or a malformed credential line on STDOUT here
|
|
30
|
+
* would otherwise corrupt EVERY git operation in the checkout. It also NEVER
|
|
31
|
+
* triggers an interactive sign-in — this runs as a non-interactive subprocess
|
|
32
|
+
* of `git`, so a missing session fails through rather than trying to open a
|
|
33
|
+
* browser mid-`git fetch`.
|
|
34
|
+
*
|
|
35
|
+
* It is NOT silent on stderr for every failure, though: when the MCP itself
|
|
36
|
+
* renders an authoritative decision — a `CliError` from `tenant_checkout` or
|
|
37
|
+
* `repo_read_credential`, e.g. "this checkout names a tenant your session
|
|
38
|
+
* doesn't hold" — that diagnosis is lost forever if swallowed, and git passes
|
|
39
|
+
* a credential helper's stderr straight through to the developer's terminal.
|
|
40
|
+
* So those specific catches print the CliError's house-style message (+ its
|
|
41
|
+
* `next` step) to stderr before returning null. A bare network/auth failure
|
|
42
|
+
* (not signed in, MCP unreachable, wrong dir) has no such decision to report
|
|
43
|
+
* and stays silent exactly as before.
|
|
33
44
|
*
|
|
34
45
|
* Dependency-free (global fetch + `git`, via the same MCP client + auth
|
|
35
46
|
* module every other command uses).
|
|
@@ -41,6 +52,7 @@ import { establishSession } from "../auth.mjs";
|
|
|
41
52
|
import { checkoutTenant, mintReadOnlyAlias, resolveReadOnlyAlias } from "./clone.mjs";
|
|
42
53
|
import { detectContext } from "../context.mjs";
|
|
43
54
|
import { repoNameFromRemote, tagFromRepoName } from "./submit.mjs";
|
|
55
|
+
import { CliError, formatError } from "../errors.mjs";
|
|
44
56
|
import {
|
|
45
57
|
parseCredentialInput, formatCredentialOutput, splitAuthedRemote,
|
|
46
58
|
credentialCachePath, readCachedCredential, writeCachedCredential,
|
|
@@ -129,8 +141,13 @@ export async function mintOrCacheCredential({
|
|
|
129
141
|
const fresh = { username: cred.username, password: cred.token };
|
|
130
142
|
writeCachedCredential(cachePath, fresh);
|
|
131
143
|
return fresh;
|
|
132
|
-
} catch {
|
|
133
|
-
|
|
144
|
+
} catch (e) {
|
|
145
|
+
// A CliError is an authoritative decision (e.g. the kit credential was refused) —
|
|
146
|
+
// report it on stderr so `git fetch` doesn't dead-end the developer in silence. A
|
|
147
|
+
// bare network/auth failure (not signed in, MCP unreachable) has no decision to
|
|
148
|
+
// report and stays silent, same as every other "nothing this helper can do" path.
|
|
149
|
+
if (e instanceof CliError) console.error(formatError(e));
|
|
150
|
+
return null;
|
|
134
151
|
}
|
|
135
152
|
}
|
|
136
153
|
|
|
@@ -168,8 +185,15 @@ export async function mintOrCacheCredential({
|
|
|
168
185
|
const fresh = { username: cred.username, password: cred.token };
|
|
169
186
|
writeCachedCredential(cachePath, fresh);
|
|
170
187
|
return fresh;
|
|
171
|
-
} catch {
|
|
172
|
-
|
|
188
|
+
} catch (e) {
|
|
189
|
+
// Same distinction as the kit-checkout catch above: `checkoutTenant` renders a
|
|
190
|
+
// CliError when the MCP (or this checkout's own state) has an authoritative answer
|
|
191
|
+
// — e.g. this checkout's `.tot/config.json` names a tenant the session doesn't hold,
|
|
192
|
+
// or `tenant_checkout` echoed a different tenant than the one asked for — and that
|
|
193
|
+
// diagnosis is lost forever if swallowed silently. A bare network/auth failure has
|
|
194
|
+
// no such decision and stays silent, exit non-zero, exactly as before.
|
|
195
|
+
if (e instanceof CliError) console.error(formatError(e));
|
|
196
|
+
return null;
|
|
173
197
|
}
|
|
174
198
|
}
|
|
175
199
|
|