@solidactions/cli 3.23.0 → 3.24.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/README.md +2 -1
- package/dist/command-manifest.json +1 -1
- package/dist/commands/database-export.js +14 -0
- package/dist/commands/database-push.js +5 -3
- package/dist/commands/database.js +4 -0
- package/dist/commands/dev.js +20 -0
- package/dist/commands/doc-pull.js +78 -44
- package/dist/commands/doc-push.js +4 -0
- package/dist/commands/login.js +28 -3
- package/dist/index.js +2 -0
- package/dist/utils/api.js +4 -0
- package/dist/utils/config.js +5 -0
- package/dist/utils/database-data-plane.js +22 -3
- package/dist/utils/debug-guard.js +60 -0
- package/dist/utils/host-display.js +19 -0
- package/dist/utils/mcp.js +10 -0
- package/dist/utils/source-provenance.js +12 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -281,6 +281,7 @@ Workspace: <name> — organization <org> (<workspaceId>)
|
|
|
281
281
|
- `--global` — write config to `~/.solidactions/config.json` (today's default).
|
|
282
282
|
- `--gitignore` — with `--local`, auto-add `.solidactions/` to `.gitignore` without prompting.
|
|
283
283
|
- `login` uses `SOLIDACTIONS_HOST` when it is set.
|
|
284
|
+
- A host with a username and password in it (`http://user:pass@host`) is refused: the CLI authenticates with your API key.
|
|
284
285
|
- An agent that should be credited as itself in SolidActions (for example, docs it pushes are recorded as Agent) logs the CLI in with its own agent token, not a person's key.
|
|
285
286
|
|
|
286
287
|
In interactive shells, `login` without `--local`/`--global` prompts for a location. In non-interactive contexts, one of the flags is required.
|
|
@@ -295,7 +296,7 @@ If the target config file already exists and its contents would change, `login`
|
|
|
295
296
|
|
|
296
297
|
### Debugging resolution
|
|
297
298
|
|
|
298
|
-
Set `SOLIDACTIONS_DEBUG=1` on any command to print the resolved configuration and per-field sources to stderr before the command runs. `solidactions whoami` also shows this information.
|
|
299
|
+
Set `SOLIDACTIONS_DEBUG=1` on any command to print the resolved configuration and per-field sources to stderr before the command runs. `solidactions whoami` also shows this information. Node's generic `DEBUG` variable never prints your API key: the CLI turns off the HTTP library's `follow-redirects` debug output, which would dump request headers. The CLI refuses to run when `NODE_DEBUG` turns on Node's network debug output (`http`, `https`, `http2`, `net`, `tls`), which would print them too.
|
|
299
300
|
|
|
300
301
|
### Use case: multiple AI agents in parallel
|
|
301
302
|
|
|
@@ -169,6 +169,18 @@ function teachingError(error) {
|
|
|
169
169
|
}
|
|
170
170
|
throw error;
|
|
171
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Throw the host-naming 401 for a 401 response, in either export call
|
|
174
|
+
* (cli#186). A non-string, blank or whitespace-only server code becomes
|
|
175
|
+
* 'unauthenticated', the way safeDatabaseRequestError trims it.
|
|
176
|
+
*/
|
|
177
|
+
function throwIfUnauthenticated(error, config) {
|
|
178
|
+
if (error?.response?.status !== 401) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const candidate = typeof error.response.data?.code === 'string' ? error.response.data.code.trim() : '';
|
|
182
|
+
throw new ExportCommandError(candidate.length > 0 ? candidate : 'unauthenticated', (0, api_1.authFailedLine)(config.host), 401);
|
|
183
|
+
}
|
|
172
184
|
async function operation(config, body) {
|
|
173
185
|
try {
|
|
174
186
|
const response = await axios_1.default.post(`${config.host}/api/v1/databases`, body, {
|
|
@@ -178,6 +190,7 @@ async function operation(config, body) {
|
|
|
178
190
|
return applyRetryAfter(response.data, response.headers['retry-after']);
|
|
179
191
|
}
|
|
180
192
|
catch (error) {
|
|
193
|
+
throwIfUnauthenticated(error, config);
|
|
181
194
|
const response = error?.response;
|
|
182
195
|
const code = typeof response?.data?.code === 'string' ? response.data.code : 'upstream_unavailable';
|
|
183
196
|
const message = typeof response?.data?.message === 'string' ? response.data.message : 'Database request failed.';
|
|
@@ -196,6 +209,7 @@ async function startExport(config, name, tables, replace, requestId) {
|
|
|
196
209
|
return stableMetadata(applyRetryAfter(response.data, response.headers['retry-after']));
|
|
197
210
|
}
|
|
198
211
|
catch (error) {
|
|
212
|
+
throwIfUnauthenticated(error, config);
|
|
199
213
|
const data = error?.response?.data;
|
|
200
214
|
const code = typeof data?.code === 'string' ? data.code : 'upstream_unavailable';
|
|
201
215
|
const message = typeof data?.message === 'string' ? data.message : 'Database request failed.';
|
|
@@ -325,8 +325,9 @@ async function databasePushWithConfig(name, file, options, config, dependencies
|
|
|
325
325
|
clearInterval(renewalTimer);
|
|
326
326
|
await renewing;
|
|
327
327
|
}
|
|
328
|
-
if (renewalFailure)
|
|
329
|
-
throw
|
|
328
|
+
if (renewalFailure) {
|
|
329
|
+
throw (0, database_data_plane_1.preserveAuthFailure)(renewalFailure, 'The database upload lease could not be renewed; the source database was not changed.', 'upstream_unavailable', 'The database upload lease could not be renewed; the source database was not changed.');
|
|
330
|
+
}
|
|
330
331
|
if (uploaded.status < 200 || uploaded.status > 299) {
|
|
331
332
|
if (uploaded.status === 413)
|
|
332
333
|
throw new database_data_plane_1.DatabaseOperationError('bulk_load_too_large', 'The upstream database service rejected the upload size; the source database was not changed.');
|
|
@@ -368,7 +369,8 @@ async function databasePushWithConfig(name, file, options, config, dependencies
|
|
|
368
369
|
}
|
|
369
370
|
}
|
|
370
371
|
if (operationId && promoteAccepted && !terminalObserved) {
|
|
371
|
-
|
|
372
|
+
const stateLine = `Promotion was accepted, but status could not be confirmed. Operation ${operationId} remains active; retry with idempotency key ${key}.`;
|
|
373
|
+
throw (0, database_data_plane_1.preserveAuthFailure)(error, stateLine, 'upstream_unavailable', stateLine);
|
|
372
374
|
}
|
|
373
375
|
throw error;
|
|
374
376
|
}
|
|
@@ -895,6 +895,10 @@ async function databaseCreateWithConfig(name, options, config, dependencies = {}
|
|
|
895
895
|
}
|
|
896
896
|
}
|
|
897
897
|
catch (error) {
|
|
898
|
+
if (error instanceof database_data_plane_1.DatabaseOperationError && error.status === 401) {
|
|
899
|
+
const stateLine = `Database "${data.database.name}" was created, but its SQL import failed. The database remains in place.`;
|
|
900
|
+
throw (0, database_data_plane_1.preserveAuthFailure)(error, stateLine, 'import_failed', stateLine);
|
|
901
|
+
}
|
|
898
902
|
const safeGuidance = error instanceof database_data_plane_1.DatabaseOperationError
|
|
899
903
|
&& error.code === 'import_failed'
|
|
900
904
|
&& error.message.includes('Resume with:')
|
package/dist/commands/dev.js
CHANGED
|
@@ -51,6 +51,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
51
51
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
52
52
|
const crypto_1 = require("crypto");
|
|
53
53
|
const module_1 = require("module");
|
|
54
|
+
const api_1 = require("../utils/api");
|
|
54
55
|
const config_1 = require("../utils/config");
|
|
55
56
|
/**
|
|
56
57
|
* Does this mapping declare a database in `solidactions.yaml` that the platform
|
|
@@ -94,6 +95,7 @@ const WRITE_AUTHORITY_REFUSAL_CODES = new Set([
|
|
|
94
95
|
function buildSaApiClient(config, projectSlug) {
|
|
95
96
|
const client = {
|
|
96
97
|
projectSlug,
|
|
98
|
+
host: config.host,
|
|
97
99
|
revealDenied: false,
|
|
98
100
|
async fetchVarsAndConnections(_env) {
|
|
99
101
|
const axios = (await Promise.resolve().then(() => __importStar(require('axios')))).default;
|
|
@@ -431,6 +433,16 @@ async function runDev(opts) {
|
|
|
431
433
|
function err(msg) {
|
|
432
434
|
stderrLines.push(msg);
|
|
433
435
|
}
|
|
436
|
+
const isUnauthenticated = (e) => e?.response?.status === 401 || e?.status === 401;
|
|
437
|
+
const authFailed = () => ({
|
|
438
|
+
stdout: stdoutLines.join('\n'),
|
|
439
|
+
stderr: stderrLines.join('\n'),
|
|
440
|
+
result: {
|
|
441
|
+
status: 'failed',
|
|
442
|
+
phase: 'auth',
|
|
443
|
+
error: { name: 'AuthenticationError', message: (0, api_1.authFailedLine)(apiClient?.host ?? 'the configured host') },
|
|
444
|
+
},
|
|
445
|
+
});
|
|
434
446
|
// 1. Determine the API client (only when an env was requested). With no
|
|
435
447
|
// --env, we run fully locally: NO platform fetch, ctx.vars starts empty.
|
|
436
448
|
let apiClient;
|
|
@@ -459,6 +471,8 @@ async function runDev(opts) {
|
|
|
459
471
|
platformVars = await apiClient.fetchVarsAndConnections(opts.env);
|
|
460
472
|
}
|
|
461
473
|
catch (e) {
|
|
474
|
+
if (isUnauthenticated(e))
|
|
475
|
+
return authFailed();
|
|
462
476
|
let msg = `failed to fetch platform vars: ${e?.message ?? e}`;
|
|
463
477
|
if (e?.response?.status === 404 && opts.env !== 'production') {
|
|
464
478
|
msg += `\nThe '${opts.env}' environment project doesn't exist — staging/dev environments require a paid plan. On the free plan, use --env production.`;
|
|
@@ -553,6 +567,8 @@ async function runDev(opts) {
|
|
|
553
567
|
}
|
|
554
568
|
}
|
|
555
569
|
catch (e) {
|
|
570
|
+
if (isUnauthenticated(e))
|
|
571
|
+
return authFailed();
|
|
556
572
|
err(`${pv.env_name}: failed to resolve database '${dbName}': ${e?.message ?? e}`);
|
|
557
573
|
}
|
|
558
574
|
}
|
|
@@ -894,6 +910,10 @@ async function dev(file, options) {
|
|
|
894
910
|
console.log(chalk_1.default.yellow('Workflow cancelled'));
|
|
895
911
|
process.exit(1);
|
|
896
912
|
}
|
|
913
|
+
if (r.status === 'failed' && r.phase === 'auth') {
|
|
914
|
+
console.error(chalk_1.default.red(r.error.message));
|
|
915
|
+
process.exit(1);
|
|
916
|
+
}
|
|
897
917
|
// failed
|
|
898
918
|
console.error(chalk_1.default.red(`✗ failed (${r.phase ?? 'run'}):`), r.error?.message ?? String(r.error));
|
|
899
919
|
process.exit(1);
|
|
@@ -32,6 +32,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
32
32
|
const prompts_1 = __importDefault(require("prompts"));
|
|
33
33
|
const api_1 = require("../utils/api");
|
|
34
34
|
const mcp_1 = require("../utils/mcp");
|
|
35
|
+
const source_provenance_1 = require("../utils/source-provenance");
|
|
35
36
|
const docs_manifest_1 = require("../utils/docs-manifest");
|
|
36
37
|
Object.defineProperty(exports, "DOCS_MANIFEST", { enumerable: true, get: function () { return docs_manifest_1.DOCS_MANIFEST; } });
|
|
37
38
|
Object.defineProperty(exports, "sha256Hex", { enumerable: true, get: function () { return docs_manifest_1.sha256Hex; } });
|
|
@@ -69,6 +70,21 @@ function sanitizeSegment(name) {
|
|
|
69
70
|
function sanitizeTitle(title) {
|
|
70
71
|
return sanitizeSegment(title);
|
|
71
72
|
}
|
|
73
|
+
/** Server-derived text (a title, code, message, or a path built from titles and folder names) as printed (cli#189). Display only. */
|
|
74
|
+
function shown(value) {
|
|
75
|
+
return (0, source_provenance_1.sanitizeDisplayText)(value, 1024) ?? '(untitled)';
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Command error boundary (cli#189): an escaping error — a filesystem throw
|
|
79
|
+
* embedding a server-derived path, or a server-bearing exception like
|
|
80
|
+
* `McpRpcError` — prints through shown() like every other server-derived
|
|
81
|
+
* message. Keeps the diagnostic meaning; exits 1, as the top-level handler
|
|
82
|
+
* would.
|
|
83
|
+
*/
|
|
84
|
+
function reportWriteError(error) {
|
|
85
|
+
process.stderr.write(chalk_1.default.red(`error: ${shown(error instanceof Error ? error.message : String(error))}\n`));
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
72
88
|
/**
|
|
73
89
|
* A doc is a media *candidate* when the bulk_read row carries blob metadata
|
|
74
90
|
* and an empty body. This is a cheap pre-filter, not authoritative — the
|
|
@@ -94,16 +110,20 @@ async function resolveMedia(config, doc) {
|
|
|
94
110
|
if (confirm.status === 404 && confirm.data?.code === 'media_not_found') {
|
|
95
111
|
return { isMedia: false };
|
|
96
112
|
}
|
|
113
|
+
if (confirm.status === 401) {
|
|
114
|
+
process.stderr.write(chalk_1.default.red((0, api_1.authFailedLine)(config.host)) + '\n');
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
97
117
|
if (confirm.status !== 200) {
|
|
98
118
|
const code = confirm.data?.code ?? 'unknown_error';
|
|
99
119
|
const message = confirm.data?.message ?? 'media confirm request failed';
|
|
100
|
-
process.stderr.write(chalk_1.default.red(`error: ${code}: ${message}\n`));
|
|
120
|
+
process.stderr.write(chalk_1.default.red(`error: ${shown(code)}: ${shown(message)}\n`));
|
|
101
121
|
process.exit(1);
|
|
102
122
|
}
|
|
103
123
|
const { url, mime } = confirm.data;
|
|
104
124
|
const download = await axios_1.default.get(url, { responseType: 'arraybuffer', validateStatus: () => true });
|
|
105
125
|
if (download.status !== 200) {
|
|
106
|
-
return { isMedia: true, mime, bytes: null, warning: `warn: failed to download media for doc ${doc.id} (${doc.title}): HTTP ${download.status}` };
|
|
126
|
+
return { isMedia: true, mime, bytes: null, warning: `warn: failed to download media for doc ${doc.id} (${shown(doc.title)}): HTTP ${download.status}` };
|
|
107
127
|
}
|
|
108
128
|
return { isMedia: true, mime, bytes: Buffer.from(download.data) };
|
|
109
129
|
}
|
|
@@ -202,7 +222,7 @@ async function fetchBodies(config, rows) {
|
|
|
202
222
|
if (!result.ok) {
|
|
203
223
|
const code = result.data?.code ?? 'unknown_error';
|
|
204
224
|
const message = result.data?.message ?? 'MCP returned an error with no message';
|
|
205
|
-
process.stderr.write(chalk_1.default.red(`error: ${code}: ${message}\n`));
|
|
225
|
+
process.stderr.write(chalk_1.default.red(`error: ${shown(code)}: ${shown(message)}\n`));
|
|
206
226
|
process.exit(1);
|
|
207
227
|
}
|
|
208
228
|
const resultRows = result.data?.results ?? [];
|
|
@@ -213,7 +233,7 @@ async function fetchBodies(config, rows) {
|
|
|
213
233
|
continue;
|
|
214
234
|
seenIds.add(row.id);
|
|
215
235
|
if (row.status !== BULK_READ_OK_STATUS) {
|
|
216
|
-
warnings.push(`warn: skipping doc ${row.id} (${original.title}): bulk_read returned status "${row.status ?? 'unknown'}"`);
|
|
236
|
+
warnings.push(`warn: skipping doc ${row.id} (${shown(original.title)}): bulk_read returned status "${shown(row.status ?? 'unknown')}"`);
|
|
217
237
|
continue;
|
|
218
238
|
}
|
|
219
239
|
fetched.push({
|
|
@@ -225,7 +245,7 @@ async function fetchBodies(config, rows) {
|
|
|
225
245
|
}
|
|
226
246
|
for (const requested of chunk) {
|
|
227
247
|
if (!seenIds.has(requested.id)) {
|
|
228
|
-
warnings.push(`warn: skipping doc ${requested.id} (${requested.title}): missing from bulk_read results`);
|
|
248
|
+
warnings.push(`warn: skipping doc ${requested.id} (${shown(requested.title)}): missing from bulk_read results`);
|
|
229
249
|
}
|
|
230
250
|
}
|
|
231
251
|
}
|
|
@@ -257,7 +277,7 @@ async function backfillDocTypes(config, fetched) {
|
|
|
257
277
|
// valid untyped doc, not a failure — warn only when the type could
|
|
258
278
|
// not be read at all.
|
|
259
279
|
if (!readOk) {
|
|
260
|
-
warnings.push(`warn: could not read the type of doc ${doc.id} (${doc.title}); writing it as .md`);
|
|
280
|
+
warnings.push(`warn: could not read the type of doc ${doc.id} (${shown(doc.title)}); writing it as .md`);
|
|
261
281
|
}
|
|
262
282
|
doc.docType = slug;
|
|
263
283
|
doc.docTypeKnown = true;
|
|
@@ -456,8 +476,8 @@ function refuseManifestClobber(previousManifest, resolvedFolder, argument, desti
|
|
|
456
476
|
if (previousManifest === null || previousManifest.folder_path === resolvedFolder || options.overwrite) {
|
|
457
477
|
return;
|
|
458
478
|
}
|
|
459
|
-
process.stderr.write(chalk_1.default.red(`error: "${destination}" already tracks "${previousManifest.folder_path}".\n`));
|
|
460
|
-
process.stderr.write(chalk_1.default.red(`Pulling "${argument}" here would replace its manifest, and local edits to the\n`));
|
|
479
|
+
process.stderr.write(chalk_1.default.red(`error: "${shown(destination)}" already tracks "${shown(previousManifest.folder_path)}".\n`));
|
|
480
|
+
process.stderr.write(chalk_1.default.red(`Pulling "${shown(argument)}" here would replace its manifest, and local edits to the\n`));
|
|
461
481
|
process.stderr.write(chalk_1.default.red('previously tracked files would no longer be protected from being overwritten.\n'));
|
|
462
482
|
process.stderr.write(chalk_1.default.red('Pull into a different directory, or pass --overwrite to replace the manifest.\n'));
|
|
463
483
|
process.exit(1);
|
|
@@ -480,12 +500,12 @@ async function docPullWithConfig(folderPath, dest, options, config) {
|
|
|
480
500
|
// doc still exists remotely) from an edited orphan (kept + warned, no flag needed).
|
|
481
501
|
if (fs_1.default.existsSync(destination)) {
|
|
482
502
|
if (!fs_1.default.statSync(destination).isDirectory()) {
|
|
483
|
-
process.stderr.write(chalk_1.default.red(`error: destination "${destination}" exists and is not a directory.\n`));
|
|
503
|
+
process.stderr.write(chalk_1.default.red(`error: destination "${shown(destination)}" exists and is not a directory.\n`));
|
|
484
504
|
process.exit(1);
|
|
485
505
|
}
|
|
486
506
|
const entries = fs_1.default.readdirSync(destination);
|
|
487
507
|
if (entries.length > 0 && !options.yes && !options.overwrite) {
|
|
488
|
-
console.log(chalk_1.default.yellow(`Destination "${destination}" is not empty (${entries.length} items).`));
|
|
508
|
+
console.log(chalk_1.default.yellow(`Destination "${shown(destination)}" is not empty (${entries.length} items).`));
|
|
489
509
|
console.log(chalk_1.default.yellow("Pulling overwrites tracked files; local files the folder doesn't track are refused unless --overwrite."));
|
|
490
510
|
const response = await (0, prompts_1.default)({
|
|
491
511
|
type: 'confirm',
|
|
@@ -519,8 +539,8 @@ async function docPullWithConfig(folderPath, dest, options, config) {
|
|
|
519
539
|
if (!readResult.ok) {
|
|
520
540
|
const readCode = readResult.data?.code ?? 'unknown_error';
|
|
521
541
|
const readMessage = readResult.data?.message ?? 'MCP returned an error with no message';
|
|
522
|
-
process.stderr.write(chalk_1.default.red(`error: ${listResult.code}: ${listResult.message}\n`));
|
|
523
|
-
process.stderr.write(chalk_1.default.red(`error: ${readCode}: ${readMessage}\n`));
|
|
542
|
+
process.stderr.write(chalk_1.default.red(`error: ${shown(listResult.code)}: ${shown(listResult.message)}\n`));
|
|
543
|
+
process.stderr.write(chalk_1.default.red(`error: ${shown(readCode)}: ${shown(readMessage)}\n`));
|
|
524
544
|
process.exit(1);
|
|
525
545
|
}
|
|
526
546
|
const data = readResult.data;
|
|
@@ -542,7 +562,7 @@ async function docPullWithConfig(folderPath, dest, options, config) {
|
|
|
542
562
|
return;
|
|
543
563
|
}
|
|
544
564
|
else {
|
|
545
|
-
process.stderr.write(chalk_1.default.red(`error: ${listResult.code}: ${listResult.message}\n`));
|
|
565
|
+
process.stderr.write(chalk_1.default.red(`error: ${shown(listResult.code)}: ${shown(listResult.message)}\n`));
|
|
546
566
|
process.exit(1);
|
|
547
567
|
return;
|
|
548
568
|
}
|
|
@@ -635,8 +655,8 @@ function linkOnTheWay(destination, rel) {
|
|
|
635
655
|
return null;
|
|
636
656
|
}
|
|
637
657
|
function refuseLink(rel, link, doc) {
|
|
638
|
-
const where = link === rel ? '' : ` (or sits under one: ${link})`;
|
|
639
|
-
process.stderr.write(chalk_1.default.red(`error: ${rel} is a symbolic link${where}; this pull would write doc ${doc.id} ("${doc.title}") through it.\n`));
|
|
658
|
+
const where = link === rel ? '' : ` (or sits under one: ${shown(link)})`;
|
|
659
|
+
process.stderr.write(chalk_1.default.red(`error: ${shown(rel)} is a symbolic link${where}; this pull would write doc ${doc.id} ("${shown(doc.title)}") through it.\n`));
|
|
640
660
|
process.stderr.write(chalk_1.default.red('Replace it with a regular file or folder and pull again.\n'));
|
|
641
661
|
process.exit(1);
|
|
642
662
|
}
|
|
@@ -644,7 +664,7 @@ function refuseLink(rel, link, doc) {
|
|
|
644
664
|
function explainUnresolvable(label, error) {
|
|
645
665
|
const code = error.code ?? 'ERROR';
|
|
646
666
|
const reason = code === 'ELOOP' ? 'too many symbolic links (ELOOP). Fix or remove the link and pull again.' : `${code} ${error.message}.`;
|
|
647
|
-
process.stderr.write(chalk_1.default.red(`error: cannot resolve ${label}: ${reason}\n`));
|
|
667
|
+
process.stderr.write(chalk_1.default.red(`error: cannot resolve ${shown(label)}: ${shown(reason)}\n`));
|
|
648
668
|
process.exit(1);
|
|
649
669
|
}
|
|
650
670
|
/** physicalTargetPath, but a resolution error becomes one line (spec §2.3). A planned target with a link on the way gets the symbolic-link refusal. */
|
|
@@ -701,7 +721,7 @@ function checkPlannedWrites(destination, planned, previousManifest, options, ren
|
|
|
701
721
|
const physical = resolveOrExplain(destination, p.relPath, p.doc);
|
|
702
722
|
// Belt and braces behind linkOnTheWay, which refuses every link first; kept in case the physical path ever diverges without one.
|
|
703
723
|
if (physical !== realDest && !physical.startsWith(realDest + path_1.default.sep)) {
|
|
704
|
-
process.stderr.write(chalk_1.default.red(`error: ${p.relPath} resolves outside the destination (${physical}); this pull would write doc ${p.doc.id} ("${p.doc.title}") there.\n`));
|
|
724
|
+
process.stderr.write(chalk_1.default.red(`error: ${shown(p.relPath)} resolves outside the destination (${shown(physical)}); this pull would write doc ${p.doc.id} ("${shown(p.doc.title)}") there.\n`));
|
|
705
725
|
process.exit(1);
|
|
706
726
|
}
|
|
707
727
|
}
|
|
@@ -741,7 +761,7 @@ function checkPlannedWrites(destination, planned, previousManifest, options, ren
|
|
|
741
761
|
const one = untracked.length === 1;
|
|
742
762
|
process.stderr.write(chalk_1.default.red(`${untracked.length} ${one ? 'file exists' : 'files exist'} locally but ${one ? 'is' : 'are'} not tracked:\n`));
|
|
743
763
|
for (const rel of untracked)
|
|
744
|
-
process.stderr.write(chalk_1.default.red(` ${rel}\n`));
|
|
764
|
+
process.stderr.write(chalk_1.default.red(` ${shown(rel)}\n`));
|
|
745
765
|
process.stderr.write(chalk_1.default.red('Move them aside and pull again, or pass --overwrite to replace them.\n'));
|
|
746
766
|
process.exit(1);
|
|
747
767
|
}
|
|
@@ -878,8 +898,8 @@ async function report(destination, folderPath, fetched, options, config, extraWa
|
|
|
878
898
|
if (!taker)
|
|
879
899
|
continue;
|
|
880
900
|
const oldTitle = previousManifest.docs[m.oldRel]?.title ?? `#${m.id}`;
|
|
881
|
-
process.stderr.write(chalk_1.default.red(`error: ${m.oldRel} holds unpublished edits for doc ${m.id} ("${oldTitle}", now written as ${m.newRel}), but this pull would write doc ${taker.doc.id} ("${taker.doc.title}") to ${taker.relPath}, the same file.\n`));
|
|
882
|
-
process.stderr.write(chalk_1.default.red(`Move or rename the edited ${m.oldRel} (or push it first) and pull again.\n`));
|
|
901
|
+
process.stderr.write(chalk_1.default.red(`error: ${shown(m.oldRel)} holds unpublished edits for doc ${m.id} ("${shown(oldTitle)}", now written as ${shown(m.newRel)}), but this pull would write doc ${taker.doc.id} ("${shown(taker.doc.title)}") to ${shown(taker.relPath)}, the same file.\n`));
|
|
902
|
+
process.stderr.write(chalk_1.default.red(`Move or rename the edited ${shown(m.oldRel)} (or push it first) and pull again.\n`));
|
|
883
903
|
process.exit(1);
|
|
884
904
|
}
|
|
885
905
|
// A rename whose replacement will not be written keeps its old file and
|
|
@@ -892,7 +912,7 @@ async function report(destination, folderPath, fetched, options, config, extraWa
|
|
|
892
912
|
const taker = plannedTargetForSource(m);
|
|
893
913
|
if (!taker)
|
|
894
914
|
continue;
|
|
895
|
-
process.stderr.write(chalk_1.default.red(`error: doc ${m.id} ("${m.title}") failed to download to ${m.newRel}, so ${m.oldRel} must keep its previous file and tracking, but this pull would put doc ${taker.doc.id} ("${taker.doc.title}") at ${taker.relPath}, the same file.\n`));
|
|
915
|
+
process.stderr.write(chalk_1.default.red(`error: doc ${m.id} ("${shown(m.title)}") failed to download to ${shown(m.newRel)}, so ${shown(m.oldRel)} must keep its previous file and tracking, but this pull would put doc ${taker.doc.id} ("${shown(taker.doc.title)}") at ${shown(taker.relPath)}, the same file.\n`));
|
|
896
916
|
process.stderr.write(chalk_1.default.red('Nothing was written. Pull again once the download succeeds.\n'));
|
|
897
917
|
process.exit(1);
|
|
898
918
|
}
|
|
@@ -901,15 +921,15 @@ async function report(destination, folderPath, fetched, options, config, extraWa
|
|
|
901
921
|
for (const m of renameMoves) {
|
|
902
922
|
if (m.replacementWritten || !m.modified)
|
|
903
923
|
continue;
|
|
904
|
-
process.stderr.write(chalk_1.default.red(`error: ${m.oldRel} holds unpublished edits for doc ${m.id}, which is now ${m.newRel}, but its download failed.\n`));
|
|
905
|
-
process.stderr.write(chalk_1.default.red(`Nothing was written. Push ${m.oldRel} first (or move it aside), then pull again once the download succeeds.\n`));
|
|
924
|
+
process.stderr.write(chalk_1.default.red(`error: ${shown(m.oldRel)} holds unpublished edits for doc ${m.id}, which is now ${shown(m.newRel)}, but its download failed.\n`));
|
|
925
|
+
process.stderr.write(chalk_1.default.red(`Nothing was written. Push ${shown(m.oldRel)} first (or move it aside), then pull again once the download succeeds.\n`));
|
|
906
926
|
process.exit(1);
|
|
907
927
|
}
|
|
908
928
|
const blocked = renameMoves.filter((m) => m.modified);
|
|
909
929
|
if (blocked.length > 0) {
|
|
910
930
|
for (const m of blocked) {
|
|
911
|
-
process.stderr.write(chalk_1.default.red(`error: ${m.oldRel} holds unpublished edits for doc ${m.id} ("${m.title}"), which is now written as ${m.newRel}.\n`));
|
|
912
|
-
process.stderr.write(chalk_1.default.red(`Nothing was written. Push ${m.oldRel} first (or move it aside) and pull again.\n`));
|
|
931
|
+
process.stderr.write(chalk_1.default.red(`error: ${shown(m.oldRel)} holds unpublished edits for doc ${m.id} ("${shown(m.title)}"), which is now written as ${shown(m.newRel)}.\n`));
|
|
932
|
+
process.stderr.write(chalk_1.default.red(`Nothing was written. Push ${shown(m.oldRel)} first (or move it aside) and pull again.\n`));
|
|
913
933
|
}
|
|
914
934
|
process.exit(1);
|
|
915
935
|
}
|
|
@@ -928,7 +948,7 @@ async function report(destination, folderPath, fetched, options, config, extraWa
|
|
|
928
948
|
if (!writes.some((p) => renamedIds.has(p.doc.id)) && foldedPaths.size === writes.length)
|
|
929
949
|
continue;
|
|
930
950
|
const [first, second] = writes;
|
|
931
|
-
process.stderr.write(chalk_1.default.red(`error: ${first.relPath} (doc ${first.doc.id}) and ${second.relPath} (doc ${second.doc.id}) are the same file on this filesystem; this pull would write different docs through those names.\n`));
|
|
951
|
+
process.stderr.write(chalk_1.default.red(`error: ${shown(first.relPath)} (doc ${first.doc.id}) and ${shown(second.relPath)} (doc ${second.doc.id}) are the same file on this filesystem; this pull would write different docs through those names.\n`));
|
|
932
952
|
process.stderr.write(chalk_1.default.red('Nothing was written. Move the aliased files apart and pull again.\n'));
|
|
933
953
|
process.exit(1);
|
|
934
954
|
}
|
|
@@ -947,8 +967,8 @@ async function report(destination, folderPath, fetched, options, config, extraWa
|
|
|
947
967
|
}
|
|
948
968
|
if (!isLink)
|
|
949
969
|
continue;
|
|
950
|
-
process.stderr.write(chalk_1.default.red(`error: ${m.newRel} is a symbolic link; this pull would write doc ${m.id} ("${m.title}", renamed from ${m.oldRel}) through it.\n`));
|
|
951
|
-
process.stderr.write(chalk_1.default.red(`Replace ${m.newRel} with a regular file (or remove it) and pull again.\n`));
|
|
970
|
+
process.stderr.write(chalk_1.default.red(`error: ${shown(m.newRel)} is a symbolic link; this pull would write doc ${m.id} ("${shown(m.title)}", renamed from ${shown(m.oldRel)}) through it.\n`));
|
|
971
|
+
process.stderr.write(chalk_1.default.red(`Replace ${shown(m.newRel)} with a regular file (or remove it) and pull again.\n`));
|
|
952
972
|
process.exit(1);
|
|
953
973
|
}
|
|
954
974
|
// A rename target holding an untracked local file (not in the previous
|
|
@@ -983,8 +1003,8 @@ async function report(destination, folderPath, fetched, options, config, extraWa
|
|
|
983
1003
|
if (existing !== null && (0, docs_manifest_1.sha256Hex)(existing) === plannedPaths.get(m.newRel)?.bodySha256)
|
|
984
1004
|
continue;
|
|
985
1005
|
const state = (targetEntry === undefined ? 'exists locally but is not tracked' : `holds local bytes with no recorded hash (tracked for doc ${targetEntry.id})`) + unreadable;
|
|
986
|
-
process.stderr.write(chalk_1.default.red(`error: ${m.newRel} ${state}; this pull would overwrite it with doc ${m.id} ("${m.title}", renamed from ${m.oldRel}).\n`));
|
|
987
|
-
process.stderr.write(chalk_1.default.red(`Move ${m.newRel} aside and pull again, or pass --overwrite to replace it.\n`));
|
|
1006
|
+
process.stderr.write(chalk_1.default.red(`error: ${shown(m.newRel)} ${state}; this pull would overwrite it with doc ${m.id} ("${shown(m.title)}", renamed from ${shown(m.oldRel)}).\n`));
|
|
1007
|
+
process.stderr.write(chalk_1.default.red(`Move ${shown(m.newRel)} aside and pull again, or pass --overwrite to replace it.\n`));
|
|
988
1008
|
process.exit(1);
|
|
989
1009
|
}
|
|
990
1010
|
}
|
|
@@ -1008,7 +1028,7 @@ async function report(destination, folderPath, fetched, options, config, extraWa
|
|
|
1008
1028
|
const noun = conflicts.length === 1 ? 'file has' : 'files have';
|
|
1009
1029
|
process.stderr.write(chalk_1.default.red(`${conflicts.length} ${noun} unpushed local changes:\n`));
|
|
1010
1030
|
for (const file of conflicts) {
|
|
1011
|
-
process.stderr.write(chalk_1.default.red(` ${file}\n`));
|
|
1031
|
+
process.stderr.write(chalk_1.default.red(` ${shown(file)}\n`));
|
|
1012
1032
|
}
|
|
1013
1033
|
process.stderr.write(chalk_1.default.red('push your changes first, or pass --overwrite to discard them.\n'));
|
|
1014
1034
|
process.exit(1);
|
|
@@ -1020,10 +1040,13 @@ async function report(destination, folderPath, fetched, options, config, extraWa
|
|
|
1020
1040
|
for (const p of planned) {
|
|
1021
1041
|
const targetAbs = path_1.default.join(destination, ...p.relPath.split('/'));
|
|
1022
1042
|
if (fs_1.default.existsSync(targetAbs) && !fs_1.default.statSync(targetAbs).isFile()) {
|
|
1023
|
-
process.stderr.write(chalk_1.default.red(`error: "${p.relPath}" exists and is not a regular file — cannot write doc ${p.doc.id} (${p.doc.title}).\n`));
|
|
1043
|
+
process.stderr.write(chalk_1.default.red(`error: "${shown(p.relPath)}" exists and is not a regular file — cannot write doc ${p.doc.id} (${shown(p.doc.title)}).\n`));
|
|
1024
1044
|
process.exit(1);
|
|
1025
1045
|
}
|
|
1026
1046
|
}
|
|
1047
|
+
// Every throw below can carry a server-derived path (commitDocs writes
|
|
1048
|
+
// title-named files): the command boundary in `docPull` prints it
|
|
1049
|
+
// sanitised.
|
|
1027
1050
|
fs_1.default.mkdirSync(destination, { recursive: true });
|
|
1028
1051
|
const destPrefix = path_1.default.resolve(destination) + path_1.default.sep;
|
|
1029
1052
|
const realDest = fs_1.default.realpathSync(destination);
|
|
@@ -1049,7 +1072,7 @@ async function report(destination, folderPath, fetched, options, config, extraWa
|
|
|
1049
1072
|
if (!holdsLocalFile)
|
|
1050
1073
|
continue;
|
|
1051
1074
|
delete manifestDocs[p.relPath];
|
|
1052
|
-
process.stderr.write(chalk_1.default.yellow(`! doc ${p.doc.id} ("${p.doc.title}") failed to download and ${p.relPath} holds a local file; not tracking it — pull again later\n`));
|
|
1075
|
+
process.stderr.write(chalk_1.default.yellow(`! doc ${p.doc.id} ("${shown(p.doc.title)}") failed to download and ${shown(p.relPath)} holds a local file; not tracking it — pull again later\n`));
|
|
1053
1076
|
}
|
|
1054
1077
|
// Identity of every file this pull actually wrote, keyed by dev:ino. Used by the
|
|
1055
1078
|
// deletion-propagation loop below to recognize an "orphan" that is really just the
|
|
@@ -1089,10 +1112,10 @@ async function report(destination, folderPath, fetched, options, config, extraWa
|
|
|
1089
1112
|
manifestDocs[m.oldRel] = oldEntry;
|
|
1090
1113
|
}
|
|
1091
1114
|
if (m.sourcePresent) {
|
|
1092
|
-
process.stderr.write(chalk_1.default.yellow(`! kept ${m.oldRel} — doc ${m.id} download failed; still tracked as ${m.oldRel}\n`));
|
|
1115
|
+
process.stderr.write(chalk_1.default.yellow(`! kept ${shown(m.oldRel)} — doc ${m.id} download failed; still tracked as ${shown(m.oldRel)}\n`));
|
|
1093
1116
|
}
|
|
1094
1117
|
else {
|
|
1095
|
-
process.stderr.write(chalk_1.default.yellow(`! doc ${m.id} download failed; still tracked as ${m.oldRel}, which is not present locally\n`));
|
|
1118
|
+
process.stderr.write(chalk_1.default.yellow(`! doc ${m.id} download failed; still tracked as ${shown(m.oldRel)}, which is not present locally\n`));
|
|
1096
1119
|
}
|
|
1097
1120
|
continue;
|
|
1098
1121
|
}
|
|
@@ -1115,7 +1138,7 @@ async function report(destination, folderPath, fetched, options, config, extraWa
|
|
|
1115
1138
|
}
|
|
1116
1139
|
const writtenPath = oldIdentity === null ? undefined : writtenPathByIdentity.get(oldIdentity);
|
|
1117
1140
|
if (writtenPath !== undefined) {
|
|
1118
|
-
process.stderr.write(chalk_1.default.yellow(`! kept ${m.oldRel}: it is the same file as ${writtenPath} (a link); the extra name is not tracked — remove it yourself if you don't need it\n`));
|
|
1141
|
+
process.stderr.write(chalk_1.default.yellow(`! kept ${shown(m.oldRel)}: it is the same file as ${shown(writtenPath)} (a link); the extra name is not tracked — remove it yourself if you don't need it\n`));
|
|
1119
1142
|
}
|
|
1120
1143
|
}
|
|
1121
1144
|
if (!isSafeToRemoveTrackedFile(absOld, destPrefix, realDest, writtenIdentities))
|
|
@@ -1154,7 +1177,7 @@ async function report(destination, folderPath, fetched, options, config, extraWa
|
|
|
1154
1177
|
process.stderr.write(chalk_1.default.yellow("deletions not propagated: single-doc pull cannot speak for a folder's contents\n"));
|
|
1155
1178
|
}
|
|
1156
1179
|
else if (previousManifest.folder_path !== folderPath) {
|
|
1157
|
-
process.stderr.write(chalk_1.default.yellow(`deletions not propagated: this directory tracks "${previousManifest.folder_path}", not "${folderPath}"\n`));
|
|
1180
|
+
process.stderr.write(chalk_1.default.yellow(`deletions not propagated: this directory tracks "${shown(previousManifest.folder_path)}", not "${shown(folderPath)}"\n`));
|
|
1158
1181
|
}
|
|
1159
1182
|
}
|
|
1160
1183
|
const keptModifiedMedia = new Set();
|
|
@@ -1192,18 +1215,18 @@ async function report(destination, folderPath, fetched, options, config, extraWa
|
|
|
1192
1215
|
}
|
|
1193
1216
|
}
|
|
1194
1217
|
if (options.json) {
|
|
1195
|
-
console.log(JSON.stringify({ manifest, files, removed, kept_modified: keptModified }));
|
|
1218
|
+
console.log((0, source_provenance_1.escapeJsonDisplayText)(JSON.stringify({ manifest, files, removed, kept_modified: keptModified })));
|
|
1196
1219
|
process.exit(0);
|
|
1197
1220
|
}
|
|
1198
|
-
console.log(chalk_1.default.green(`pulled ${files.length} doc${files.length === 1 ? '' : 's'} → ${destination}`));
|
|
1221
|
+
console.log(chalk_1.default.green(`pulled ${files.length} doc${files.length === 1 ? '' : 's'} → ${shown(destination)}`));
|
|
1199
1222
|
for (const file of files) {
|
|
1200
|
-
console.log(chalk_1.default.gray(` ${file.path}`));
|
|
1223
|
+
console.log(chalk_1.default.gray(` ${shown(file.path)}`));
|
|
1201
1224
|
}
|
|
1202
1225
|
for (const file of removed) {
|
|
1203
|
-
console.log(chalk_1.default.gray(`- removed (deleted remotely): ${file}`));
|
|
1226
|
+
console.log(chalk_1.default.gray(`- removed (deleted remotely): ${shown(file)}`));
|
|
1204
1227
|
}
|
|
1205
1228
|
for (const file of keptModified) {
|
|
1206
|
-
process.stderr.write(chalk_1.default.yellow(`! kept ${file} — deleted remotely but modified locally\n`));
|
|
1229
|
+
process.stderr.write(chalk_1.default.yellow(`! kept ${shown(file)} — deleted remotely but modified locally\n`));
|
|
1207
1230
|
if (keptModifiedMedia.has(file)) {
|
|
1208
1231
|
process.stderr.write(chalk_1.default.yellow(' (it is now untracked; use `solidactions doc upload` to re-create it)\n'));
|
|
1209
1232
|
}
|
|
@@ -1215,8 +1238,19 @@ async function report(destination, folderPath, fetched, options, config, extraWa
|
|
|
1215
1238
|
}
|
|
1216
1239
|
/**
|
|
1217
1240
|
* Entry point called from index.ts.
|
|
1241
|
+
*
|
|
1242
|
+
* Command-level error boundary (cli#189): any error escaping the command's
|
|
1243
|
+
* work — a server-bearing exception like `McpRpcError` as well as a
|
|
1244
|
+
* filesystem throw — prints one sanitised red `error: ` line and exits 1.
|
|
1245
|
+
* The command's own `process.exit` calls terminate the process and never
|
|
1246
|
+
* reach this catch.
|
|
1218
1247
|
*/
|
|
1219
1248
|
async function docPull(folder, dest, options) {
|
|
1220
|
-
|
|
1221
|
-
|
|
1249
|
+
try {
|
|
1250
|
+
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
1251
|
+
await docPullWithConfig(folder, dest, options, config);
|
|
1252
|
+
}
|
|
1253
|
+
catch (error) {
|
|
1254
|
+
reportWriteError(error);
|
|
1255
|
+
}
|
|
1222
1256
|
}
|
|
@@ -499,6 +499,10 @@ async function docPushWithConfig(dir, options, config) {
|
|
|
499
499
|
trackedMissing.push({ file: relPath, id: entry.id });
|
|
500
500
|
continue;
|
|
501
501
|
}
|
|
502
|
+
if (status === 401) {
|
|
503
|
+
process.stderr.write(chalk_1.default.red((0, api_1.authFailedLine)(config.host)) + '\n');
|
|
504
|
+
process.exit(1);
|
|
505
|
+
}
|
|
502
506
|
process.stderr.write(chalk_1.default.red(`error: ${relPath}: ${data?.message ?? error.message}\n`));
|
|
503
507
|
process.exit(1);
|
|
504
508
|
}
|
package/dist/commands/login.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DEVICE_LOGIN_REFUSAL_MESSAGE = exports.LoginHostInvalidError = exports.LoginHostConflictError = exports.API_KEY_PROMPT = exports.selectWorkspaceInteractively = void 0;
|
|
6
|
+
exports.DEVICE_LOGIN_REFUSAL_MESSAGE = exports.LoginHostUserinfoError = exports.LoginHostInvalidError = exports.LoginHostConflictError = exports.API_KEY_PROMPT = exports.selectWorkspaceInteractively = void 0;
|
|
7
7
|
exports.resolveLoginApiKey = resolveLoginApiKey;
|
|
8
8
|
exports.clearConfig = clearConfig;
|
|
9
9
|
exports.resolveLoginHost = resolveLoginHost;
|
|
@@ -95,6 +95,16 @@ class LoginHostInvalidError extends Error {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
exports.LoginHostInvalidError = LoginHostInvalidError;
|
|
98
|
+
class LoginHostUserinfoError extends Error {
|
|
99
|
+
label;
|
|
100
|
+
host;
|
|
101
|
+
constructor(label, host) {
|
|
102
|
+
super(`${label} "${(0, host_display_1.displayHost)(host)}" contains a username/password; remove "user:pass@" — the CLI authenticates with your API key.`);
|
|
103
|
+
this.label = label;
|
|
104
|
+
this.host = host;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.LoginHostUserinfoError = LoginHostUserinfoError;
|
|
98
108
|
function resolveLoginHost(options, env = process.env) {
|
|
99
109
|
const strip = (h) => h.trim().replace(/\/+$/, '');
|
|
100
110
|
// Ruling 9: a non-empty value that strips to nothing is INVALID, never "absent".
|
|
@@ -105,9 +115,16 @@ function resolveLoginHost(options, env = process.env) {
|
|
|
105
115
|
return value;
|
|
106
116
|
};
|
|
107
117
|
const rawEnv = env.SOLIDACTIONS_HOST;
|
|
108
|
-
const
|
|
118
|
+
const noUserinfo = (host, label) => {
|
|
119
|
+
if ((0, host_display_1.hostHasUserinfo)(host))
|
|
120
|
+
throw new LoginHostUserinfoError(label, host);
|
|
121
|
+
return host;
|
|
122
|
+
};
|
|
123
|
+
const envHost = rawEnv !== undefined && rawEnv.trim() !== ''
|
|
124
|
+
? noUserinfo(usable(rawEnv, 'SOLIDACTIONS_HOST'), 'SOLIDACTIONS_HOST')
|
|
125
|
+
: undefined;
|
|
109
126
|
const explicitHostFlag = (raw) => {
|
|
110
|
-
const host = usable(raw, '--host');
|
|
127
|
+
const host = noUserinfo(usable(raw, '--host'), '--host');
|
|
111
128
|
return { host, flag: `--host ${(0, host_display_1.displayHost)(host)}` };
|
|
112
129
|
};
|
|
113
130
|
const explicit = options.host !== undefined
|
|
@@ -142,6 +159,10 @@ function resolveLoginHostOrExit(options) {
|
|
|
142
159
|
console.error(chalk_1.default.red(`error: ${error.message}`));
|
|
143
160
|
process.exit(1);
|
|
144
161
|
}
|
|
162
|
+
if (error instanceof LoginHostUserinfoError) {
|
|
163
|
+
console.error(chalk_1.default.red(`error: ${error.message}`));
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
145
166
|
throw error;
|
|
146
167
|
}
|
|
147
168
|
}
|
|
@@ -494,6 +515,10 @@ function whoami() {
|
|
|
494
515
|
console.error(chalk_1.default.red((0, config_1.credentialConflictMessage)(resolved.credentialConflict)));
|
|
495
516
|
process.exit(1);
|
|
496
517
|
}
|
|
518
|
+
if (resolved && (0, host_display_1.hostHasUserinfo)(resolved.config.host)) {
|
|
519
|
+
console.error(chalk_1.default.red((0, config_1.userinfoHostMessage)(resolved.config.host, resolved.sources.host)));
|
|
520
|
+
process.exit(1);
|
|
521
|
+
}
|
|
497
522
|
if (!resolved || !resolved.config.apiKey) {
|
|
498
523
|
console.log(chalk_1.default.yellow('Not initialized.'));
|
|
499
524
|
console.log(chalk_1.default.gray('Run "solidactions login --global" to configure.'));
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
exports.program = void 0;
|
|
41
|
+
// Must stay first: it edits DEBUG before any dependency can load `debug`, and refuses a network NODE_DEBUG (cli#194).
|
|
42
|
+
require("./utils/debug-guard");
|
|
41
43
|
const chalk_1 = __importDefault(require("chalk"));
|
|
42
44
|
const commander_1 = require("commander");
|
|
43
45
|
const deploy_1 = require("./commands/deploy");
|
package/dist/utils/api.js
CHANGED
|
@@ -292,6 +292,10 @@ function requireResolvedConfig() {
|
|
|
292
292
|
console.error(chalk_1.default.red((0, config_1.credentialConflictMessage)(resolved.credentialConflict)));
|
|
293
293
|
process.exit(1);
|
|
294
294
|
}
|
|
295
|
+
if (resolved && (0, host_display_1.hostHasUserinfo)(resolved.config.host)) {
|
|
296
|
+
console.error(chalk_1.default.red((0, config_1.userinfoHostMessage)(resolved.config.host, resolved.sources.host)));
|
|
297
|
+
process.exit(1);
|
|
298
|
+
}
|
|
295
299
|
if (!resolved || !resolved.config.apiKey) {
|
|
296
300
|
console.error(chalk_1.default.red('Not initialized. Run `solidactions login --global` first.'));
|
|
297
301
|
process.exit(1);
|
package/dist/utils/config.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.DEFAULT_HOST = void 0;
|
|
7
7
|
exports.normalizeHost = normalizeHost;
|
|
8
|
+
exports.userinfoHostMessage = userinfoHostMessage;
|
|
8
9
|
exports.credentialConflictMessage = credentialConflictMessage;
|
|
9
10
|
exports.setCliWorkspaceOverride = setCliWorkspaceOverride;
|
|
10
11
|
exports.getGlobalConfigPath = getGlobalConfigPath;
|
|
@@ -30,6 +31,10 @@ function normalizeHost(host) {
|
|
|
30
31
|
function describeSource(source, envVar) {
|
|
31
32
|
return source === 'env' ? `$${envVar}` : String(source);
|
|
32
33
|
}
|
|
34
|
+
/** The refusal for a resolved host that carries userinfo (cli#195). Never includes the userinfo. */
|
|
35
|
+
function userinfoHostMessage(host, source) {
|
|
36
|
+
return `error: the host "${(0, host_display_1.displayHost)(host)}" (from ${describeSource(source, 'SOLIDACTIONS_HOST')}) contains a username/password; remove "user:pass@" — the CLI authenticates with your API key.`;
|
|
37
|
+
}
|
|
33
38
|
/** The refusal shown when a key would be sent to a host it was not configured with. Never includes the key. */
|
|
34
39
|
function credentialConflictMessage(conflict) {
|
|
35
40
|
if (conflict.keySource === 'env') {
|
|
@@ -8,6 +8,7 @@ exports.databaseCredentialDeadline = databaseCredentialDeadline;
|
|
|
8
8
|
exports.isDatabaseCredentialAuthFailure = isDatabaseCredentialAuthFailure;
|
|
9
9
|
exports.databaseCredentialFailureCode = databaseCredentialFailureCode;
|
|
10
10
|
exports.safeDatabaseRequestError = safeDatabaseRequestError;
|
|
11
|
+
exports.preserveAuthFailure = preserveAuthFailure;
|
|
11
12
|
exports.runDatabaseClientOperationWithDeadline = runDatabaseClientOperationWithDeadline;
|
|
12
13
|
exports.requestDatabaseOperation = requestDatabaseOperation;
|
|
13
14
|
exports.requestDatabaseDumpStream = requestDatabaseDumpStream;
|
|
@@ -80,7 +81,7 @@ class DatabaseOperationError extends Error {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
exports.DatabaseOperationError = DatabaseOperationError;
|
|
83
|
-
function safeDatabaseRequestError(error) {
|
|
84
|
+
function safeDatabaseRequestError(error, host) {
|
|
84
85
|
const augmented = (0, api_1.augmentTokenMissingAbilityMessage)(error);
|
|
85
86
|
const response = augmented?.response;
|
|
86
87
|
const status = typeof response?.status === 'number' ? response.status : undefined;
|
|
@@ -88,6 +89,10 @@ function safeDatabaseRequestError(error) {
|
|
|
88
89
|
? response.data.code.trim()
|
|
89
90
|
: '';
|
|
90
91
|
const stableCode = codeCandidate.length > 0 ? codeCandidate : null;
|
|
92
|
+
if (status === 401) {
|
|
93
|
+
// The one-line, host-naming 401 every command prints (cli#186).
|
|
94
|
+
return new DatabaseOperationError(stableCode ?? 'unauthenticated', (0, api_1.authFailedLine)(host), 401);
|
|
95
|
+
}
|
|
91
96
|
const code = stableCode ?? 'upstream_unavailable';
|
|
92
97
|
const appMessage = stableCode !== null
|
|
93
98
|
&& typeof response?.data?.message === 'string'
|
|
@@ -102,6 +107,20 @@ function safeDatabaseRequestError(error) {
|
|
|
102
107
|
: undefined;
|
|
103
108
|
return new DatabaseOperationError(code, message, status, sizeLimitBytes);
|
|
104
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* A wrapper that adds operational state disclosure must not lose a 401's
|
|
112
|
+
* host line and status (cli#186). When the underlying failure is a 401 (a
|
|
113
|
+
* DatabaseOperationError whose message is already the shared host line),
|
|
114
|
+
* the surfaced error keeps its code and status and starts with that line,
|
|
115
|
+
* followed by the disclosure on a second line. Any other failure keeps the
|
|
116
|
+
* wrapper's existing error exactly.
|
|
117
|
+
*/
|
|
118
|
+
function preserveAuthFailure(error, disclosure, fallbackCode, fallbackMessage) {
|
|
119
|
+
if (error instanceof DatabaseOperationError && error.status === 401) {
|
|
120
|
+
return new DatabaseOperationError(error.code, `${error.message}\n${disclosure}`, 401);
|
|
121
|
+
}
|
|
122
|
+
return new DatabaseOperationError(fallbackCode, fallbackMessage);
|
|
123
|
+
}
|
|
105
124
|
function positiveTimeout(value, fallback) {
|
|
106
125
|
return typeof value === 'number' && Number.isFinite(value) && value > 0
|
|
107
126
|
? value
|
|
@@ -170,7 +189,7 @@ async function requestDatabaseOperation(config, body, dependencies = {}) {
|
|
|
170
189
|
return response.data;
|
|
171
190
|
}
|
|
172
191
|
catch (error) {
|
|
173
|
-
throw safeDatabaseRequestError(error);
|
|
192
|
+
throw safeDatabaseRequestError(error, config.host);
|
|
174
193
|
}
|
|
175
194
|
}
|
|
176
195
|
/** Request the existing server-side SQL dump as a stream. */
|
|
@@ -190,7 +209,7 @@ async function requestDatabaseDumpStream(config, name, dependencies = {}) {
|
|
|
190
209
|
return response.data;
|
|
191
210
|
}
|
|
192
211
|
catch (error) {
|
|
193
|
-
throw safeDatabaseRequestError(error);
|
|
212
|
+
throw safeDatabaseRequestError(error, config.host);
|
|
194
213
|
}
|
|
195
214
|
}
|
|
196
215
|
function safeDirectClientError() {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.guardDebugNamespaces = guardDebugNamespaces;
|
|
7
|
+
exports.nodeDebugNetworkSection = nodeDebugNetworkSection;
|
|
8
|
+
exports.refuseNetworkNodeDebug = refuseNetworkNodeDebug;
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
/**
|
|
11
|
+
* cli#194: keep the API key out of every debug channel.
|
|
12
|
+
*
|
|
13
|
+
* - `DEBUG` (the `debug` package): axios sends every request through
|
|
14
|
+
* follow-redirects, whose `debug` namespace dumps the request options (the
|
|
15
|
+
* Authorization header, a URL's userinfo). `debug` reads DEBUG once, when it
|
|
16
|
+
* first loads, and a skip (`-name`) beats any match, so appending the skip
|
|
17
|
+
* here turns that namespace off while every other one keeps working.
|
|
18
|
+
* - `NODE_DEBUG` (Node's util.debuglog): the http/net/tls sections dump
|
|
19
|
+
* connection options, headers included, for the axios path and the MCP
|
|
20
|
+
* transport. Node fixes the enabled sections during bootstrap, before any
|
|
21
|
+
* user code, so they cannot be turned off here: refuse to run instead
|
|
22
|
+
* (recorded on cli#194).
|
|
23
|
+
*
|
|
24
|
+
* src/index.ts imports this module first, before anything can load `debug`
|
|
25
|
+
* or make a request.
|
|
26
|
+
*/
|
|
27
|
+
const DEBUG_SKIP = '-follow-redirects';
|
|
28
|
+
const NETWORK_SECTIONS = ['http', 'https', 'http2', 'net', 'tls'];
|
|
29
|
+
function guardDebugNamespaces(env = process.env) {
|
|
30
|
+
const value = env.DEBUG;
|
|
31
|
+
if (value === undefined || value.trim() === '') {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (value.split(/[\s,]+/).includes(DEBUG_SKIP)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
env.DEBUG = `${value},${DEBUG_SKIP}`;
|
|
38
|
+
}
|
|
39
|
+
/** The first network section NODE_DEBUG enables, matched exactly as Node's initializeDebugEnv does; null when none. */
|
|
40
|
+
function nodeDebugNetworkSection(value) {
|
|
41
|
+
if (!value) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const pattern = value
|
|
45
|
+
.replace(/[|\\{}()[\]^$+?.]/g, '\\$&')
|
|
46
|
+
.replace(/\*/g, '.*')
|
|
47
|
+
.replace(/,/g, '$|^');
|
|
48
|
+
const enabled = new RegExp(`^${pattern}$`, 'i');
|
|
49
|
+
return NETWORK_SECTIONS.find((section) => enabled.test(section)) ?? null;
|
|
50
|
+
}
|
|
51
|
+
function refuseNetworkNodeDebug(env = process.env) {
|
|
52
|
+
const section = nodeDebugNetworkSection(env.NODE_DEBUG);
|
|
53
|
+
if (section === null) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
process.stderr.write(`${chalk_1.default.red(`error: NODE_DEBUG=${JSON.stringify(env.NODE_DEBUG)} turns on Node's "${section}" debug output, which prints request headers including your API key. Remove http, https, http2, net and tls from NODE_DEBUG (or unset it) and run again.`)}\n`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
refuseNetworkNodeDebug();
|
|
60
|
+
guardDebugNamespaces();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.displayHost = displayHost;
|
|
4
|
+
exports.hostHasUserinfo = hostHasUserinfo;
|
|
4
5
|
/**
|
|
5
6
|
* Host as shown in user-facing output: a URL with any userinfo stripped
|
|
6
7
|
* (credentials must never reach the terminal), otherwise shown as
|
|
@@ -26,6 +27,24 @@ function displayHost(host) {
|
|
|
26
27
|
}
|
|
27
28
|
return shown;
|
|
28
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* True when a host carries userinfo (`user:pass@`, `user@`). axios turns URL
|
|
32
|
+
* userinfo into a Basic Authorization header that replaces the CLI's API-key header, so
|
|
33
|
+
* such a host can never authenticate; config resolution and login refuse it
|
|
34
|
+
* (cli#195, Peter's ruling on CrewOps ask task-cliahostwithuser-922c).
|
|
35
|
+
*/
|
|
36
|
+
function hostHasUserinfo(host) {
|
|
37
|
+
try {
|
|
38
|
+
const url = new URL(host);
|
|
39
|
+
if (url.host !== '') {
|
|
40
|
+
return url.username !== '' || url.password !== '';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Not a URL `new URL` accepts: look at the authority by hand below.
|
|
45
|
+
}
|
|
46
|
+
return /^([a-z][a-z0-9+.-]*:\/\/)?[^/?#]*@/i.test(host);
|
|
47
|
+
}
|
|
29
48
|
const INVALID_HOST_PLACEHOLDER = '<invalid host>';
|
|
30
49
|
/**
|
|
31
50
|
* Fallback for a value `new URL` rejects (`http://u:secret@localhost:bad-port`),
|
package/dist/utils/mcp.js
CHANGED
|
@@ -39,6 +39,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
39
39
|
return result;
|
|
40
40
|
};
|
|
41
41
|
})();
|
|
42
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
|
+
};
|
|
42
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
46
|
exports.McpRpcError = void 0;
|
|
44
47
|
exports.retryAfterSeconds = retryAfterSeconds;
|
|
@@ -47,6 +50,7 @@ exports.callCrewsTool = callCrewsTool;
|
|
|
47
50
|
exports.resolveDocsCall = resolveDocsCall;
|
|
48
51
|
exports.callDocsTool = callDocsTool;
|
|
49
52
|
exports.callCrewsToolContent = callCrewsToolContent;
|
|
53
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
50
54
|
const http = __importStar(require("http"));
|
|
51
55
|
const https = __importStar(require("https"));
|
|
52
56
|
const url_1 = require("url");
|
|
@@ -140,6 +144,12 @@ async function postMcpTool(config, endpointPath, toolName, args) {
|
|
|
140
144
|
process.stderr.write(`solidactions: rate limited by server (429); retrying in ${waitSec}s (attempt ${n + 1}/${RATE_LIMIT_MAX_ATTEMPTS})\n`);
|
|
141
145
|
await new Promise((resolve) => setTimeout(resolve, waitSec * 1000));
|
|
142
146
|
}
|
|
147
|
+
if (last.status === 401) {
|
|
148
|
+
// One transport-level 401 branch for every MCP caller (cli#184): the host
|
|
149
|
+
// line every other command prints, never the raw body.
|
|
150
|
+
process.stderr.write(chalk_1.default.red((0, api_1.authFailedLine)(config.host)) + '\n');
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
143
153
|
if (last.status === 404) {
|
|
144
154
|
throw new Error(`MCP request failed: ${parsed.host} has no ${endpointPath} endpoint — the server may be older or newer than this CLI (${CLI_VERSION}). Raw: HTTP 404 ${last.raw}`);
|
|
145
155
|
}
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.escapeJsonDisplayText = escapeJsonDisplayText;
|
|
6
7
|
exports.sanitizeDisplayText = sanitizeDisplayText;
|
|
7
8
|
exports.formatRevisionSummary = formatRevisionSummary;
|
|
8
9
|
exports.revisionSha = revisionSha;
|
|
@@ -20,7 +21,17 @@ const path_1 = __importDefault(require("path"));
|
|
|
20
21
|
const child_process_1 = require("child_process");
|
|
21
22
|
const form_data_1 = __importDefault(require("form-data"));
|
|
22
23
|
const table_1 = require("./table");
|
|
23
|
-
const DISPLAY_FORMATTING = /[\x00-\x1f\x7f\u061c\u200b-\u200f\u202a-\u202e\u2060\u2066-\u2069\ufeff]/g;
|
|
24
|
+
const DISPLAY_FORMATTING = /[\x00-\x1f\x7f-\x9f\u061c\u200b-\u200f\u202a-\u202e\u2060\u2066-\u2069\ufeff]/g;
|
|
25
|
+
/**
|
|
26
|
+
* Escape every character of the shared display-formatting class as a `\uXXXX`
|
|
27
|
+
* sequence inside an already-serialised JSON string, so terminal-unsafe
|
|
28
|
+
* characters never reach stdout raw while `JSON.parse` still recovers the
|
|
29
|
+
* exact values (cli#189). Machine-readable values are untouched, only their
|
|
30
|
+
* encoding.
|
|
31
|
+
*/
|
|
32
|
+
function escapeJsonDisplayText(serialised) {
|
|
33
|
+
return serialised.replace(DISPLAY_FORMATTING, (character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, '0')}`);
|
|
34
|
+
}
|
|
24
35
|
const SHA_PATTERN = /^[0-9a-f]{7,64}$/i;
|
|
25
36
|
const STRICT_ISO_PATTERN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/;
|
|
26
37
|
function displayValue(value, maxLength) {
|