@astrale-os/cli 1.0.0-beta.6 → 1.0.0-beta.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/dist/astrale.js +46 -43
- package/dist/types/lib/failure-debug.d.ts +1 -0
- package/dist/types/lib/log.d.ts +3 -1
- package/package.json +1 -1
- package/src/connection/failure/index.ts +1 -1
- package/src/lib/__tests__/log-errors.test.ts +11 -0
- package/src/lib/log.ts +6 -4
- /package/src/{connection/failure/debug.ts → lib/failure-debug.ts} +0 -0
package/dist/astrale.js
CHANGED
|
@@ -9738,7 +9738,7 @@ var package_default;
|
|
|
9738
9738
|
var init_package = __esm(() => {
|
|
9739
9739
|
package_default = {
|
|
9740
9740
|
name: "@astrale-os/cli",
|
|
9741
|
-
version: "1.0.0-beta.
|
|
9741
|
+
version: "1.0.0-beta.8",
|
|
9742
9742
|
description: "Astrale CLI — connect to existing Astrale kernels",
|
|
9743
9743
|
keywords: [
|
|
9744
9744
|
"astrale",
|
|
@@ -41394,6 +41394,43 @@ var init_ora = __esm(() => {
|
|
|
41394
41394
|
validColors = new Set(["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "gray"]);
|
|
41395
41395
|
});
|
|
41396
41396
|
|
|
41397
|
+
// src/lib/failure-debug.ts
|
|
41398
|
+
function printFailureDebug(error52, url2) {
|
|
41399
|
+
process.stderr.write(`
|
|
41400
|
+
${source_default.dim("── debug ─────────────────")}
|
|
41401
|
+
`);
|
|
41402
|
+
if (url2)
|
|
41403
|
+
process.stderr.write(`${source_default.dim(`url: ${url2}`)}
|
|
41404
|
+
`);
|
|
41405
|
+
const seen = new Set;
|
|
41406
|
+
const pending = [{ value: error52, relation: "error" }];
|
|
41407
|
+
while (pending.length > 0 && seen.size < MAXIMUM_DEBUG_FAILURES) {
|
|
41408
|
+
const { value, relation } = pending.shift();
|
|
41409
|
+
if (seen.has(value))
|
|
41410
|
+
continue;
|
|
41411
|
+
seen.add(value);
|
|
41412
|
+
if (!(value instanceof Error)) {
|
|
41413
|
+
process.stderr.write(`${source_default.dim(`${relation}: ${String(value)}`)}
|
|
41414
|
+
`);
|
|
41415
|
+
continue;
|
|
41416
|
+
}
|
|
41417
|
+
process.stderr.write(`${source_default.dim(`${relation}: ${value.constructor.name}: ${value.message}`)}
|
|
41418
|
+
`);
|
|
41419
|
+
if (value.stack)
|
|
41420
|
+
process.stderr.write(`${source_default.dim(value.stack)}
|
|
41421
|
+
`);
|
|
41422
|
+
if (value.cause !== undefined)
|
|
41423
|
+
pending.push({ value: value.cause, relation: "caused by" });
|
|
41424
|
+
if (value instanceof AggregateError)
|
|
41425
|
+
for (const child3 of value.errors)
|
|
41426
|
+
pending.push({ value: child3, relation: "aggregate" });
|
|
41427
|
+
}
|
|
41428
|
+
}
|
|
41429
|
+
var MAXIMUM_DEBUG_FAILURES = 32;
|
|
41430
|
+
var init_failure_debug = __esm(() => {
|
|
41431
|
+
init_source();
|
|
41432
|
+
});
|
|
41433
|
+
|
|
41397
41434
|
// src/lib/format.ts
|
|
41398
41435
|
function formatElapsed(ms) {
|
|
41399
41436
|
if (ms < 1000)
|
|
@@ -41413,11 +41450,13 @@ function fatal(e, opts) {
|
|
|
41413
41450
|
payload.hint = e.hint;
|
|
41414
41451
|
process.stderr.write(JSON.stringify(payload) + `
|
|
41415
41452
|
`);
|
|
41416
|
-
|
|
41453
|
+
} else {
|
|
41454
|
+
log.error(`${code}: ${msg}`);
|
|
41455
|
+
if (e instanceof AstraleError && e.hint)
|
|
41456
|
+
log.dim(` hint: ${e.hint}`);
|
|
41417
41457
|
}
|
|
41418
|
-
|
|
41419
|
-
|
|
41420
|
-
log.dim(` hint: ${e.hint}`);
|
|
41458
|
+
if (opts?.debug)
|
|
41459
|
+
printFailureDebug(e, "");
|
|
41421
41460
|
process.exit(1);
|
|
41422
41461
|
}
|
|
41423
41462
|
function failInput(error52, opts) {
|
|
@@ -41490,6 +41529,7 @@ var init_log = __esm(() => {
|
|
|
41490
41529
|
init_source();
|
|
41491
41530
|
init_ora();
|
|
41492
41531
|
init_errors2();
|
|
41532
|
+
init_failure_debug();
|
|
41493
41533
|
init_output();
|
|
41494
41534
|
log = {
|
|
41495
41535
|
info: (msg) => console.log(source_default.blue("ℹ"), msg),
|
|
@@ -82212,43 +82252,6 @@ var init_classify = __esm(() => {
|
|
|
82212
82252
|
init_errors2();
|
|
82213
82253
|
});
|
|
82214
82254
|
|
|
82215
|
-
// src/connection/failure/debug.ts
|
|
82216
|
-
function printFailureDebug(error52, url3) {
|
|
82217
|
-
process.stderr.write(`
|
|
82218
|
-
${source_default.dim("── debug ─────────────────")}
|
|
82219
|
-
`);
|
|
82220
|
-
if (url3)
|
|
82221
|
-
process.stderr.write(`${source_default.dim(`url: ${url3}`)}
|
|
82222
|
-
`);
|
|
82223
|
-
const seen = new Set;
|
|
82224
|
-
const pending = [{ value: error52, relation: "error" }];
|
|
82225
|
-
while (pending.length > 0 && seen.size < MAXIMUM_DEBUG_FAILURES) {
|
|
82226
|
-
const { value: value3, relation } = pending.shift();
|
|
82227
|
-
if (seen.has(value3))
|
|
82228
|
-
continue;
|
|
82229
|
-
seen.add(value3);
|
|
82230
|
-
if (!(value3 instanceof Error)) {
|
|
82231
|
-
process.stderr.write(`${source_default.dim(`${relation}: ${String(value3)}`)}
|
|
82232
|
-
`);
|
|
82233
|
-
continue;
|
|
82234
|
-
}
|
|
82235
|
-
process.stderr.write(`${source_default.dim(`${relation}: ${value3.constructor.name}: ${value3.message}`)}
|
|
82236
|
-
`);
|
|
82237
|
-
if (value3.stack)
|
|
82238
|
-
process.stderr.write(`${source_default.dim(value3.stack)}
|
|
82239
|
-
`);
|
|
82240
|
-
if (value3.cause !== undefined)
|
|
82241
|
-
pending.push({ value: value3.cause, relation: "caused by" });
|
|
82242
|
-
if (value3 instanceof AggregateError)
|
|
82243
|
-
for (const child3 of value3.errors)
|
|
82244
|
-
pending.push({ value: child3, relation: "aggregate" });
|
|
82245
|
-
}
|
|
82246
|
-
}
|
|
82247
|
-
var MAXIMUM_DEBUG_FAILURES = 32;
|
|
82248
|
-
var init_debug = __esm(() => {
|
|
82249
|
-
init_source();
|
|
82250
|
-
});
|
|
82251
|
-
|
|
82252
82255
|
// src/connection/reasons.ts
|
|
82253
82256
|
function reasonCode(reason) {
|
|
82254
82257
|
if (!record9(reason) || typeof reason.code !== "string")
|
|
@@ -82462,8 +82465,8 @@ async function formatKernelError(error52, machine, urlArg = "", debug = false, o
|
|
|
82462
82465
|
printFailureDebug(error52, urlArg);
|
|
82463
82466
|
}
|
|
82464
82467
|
var init_failure2 = __esm(() => {
|
|
82468
|
+
init_failure_debug();
|
|
82465
82469
|
init_classify();
|
|
82466
|
-
init_debug();
|
|
82467
82470
|
init_render2();
|
|
82468
82471
|
init_reasons();
|
|
82469
82472
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function printFailureDebug(error: unknown, url: string): void;
|
package/dist/types/lib/log.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ export declare const log: {
|
|
|
10
10
|
};
|
|
11
11
|
/** Report an error with hint (when present) and exit. `--json` / `--ci` / a
|
|
12
12
|
* non-TTY stdout always get one structured JSON line on stderr. */
|
|
13
|
-
export declare function fatal(e: unknown, opts?: MachineOpts
|
|
13
|
+
export declare function fatal(e: unknown, opts?: MachineOpts & {
|
|
14
|
+
readonly debug?: boolean;
|
|
15
|
+
}): never;
|
|
14
16
|
/** Project only a caller-authored admission failure into the CLI input family. */
|
|
15
17
|
export declare function failInput(error: unknown, opts?: MachineOpts): never;
|
|
16
18
|
/** Shortcut for stub commands that aren't wired in v1 (§15). */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { OperationRecovery } from '../command'
|
|
2
2
|
|
|
3
|
+
import { printFailureDebug } from '../../lib/failure-debug'
|
|
3
4
|
import { classifyFailure } from './classify'
|
|
4
|
-
import { printFailureDebug } from './debug'
|
|
5
5
|
import { renderFailure } from './render'
|
|
6
6
|
|
|
7
7
|
export { functionInputIssues, schemaUpgradeHint } from '../reasons'
|
|
@@ -36,6 +36,17 @@ describe('terminal error safety', () => {
|
|
|
36
36
|
})
|
|
37
37
|
})
|
|
38
38
|
|
|
39
|
+
test('retains unknown failure evidence only under explicit debug output', () => {
|
|
40
|
+
const failure = new AggregateError([new Error('provider rejected organization scope')], '')
|
|
41
|
+
|
|
42
|
+
expect(() => fatal(failure, { json: true, debug: true })).toThrow(ExitError)
|
|
43
|
+
|
|
44
|
+
expect(stderr).toContain(
|
|
45
|
+
'{"error":"UNEXPECTED_ERROR","message":"The CLI encountered an unexpected internal failure."}',
|
|
46
|
+
)
|
|
47
|
+
expect(stderr).toContain('aggregate: Error: provider rejected organization scope')
|
|
48
|
+
})
|
|
49
|
+
|
|
39
50
|
test('rejects blank admitted CLI diagnostics', () => {
|
|
40
51
|
expect(() => new AstraleError('INVALID_INPUT', ' ')).toThrow(TypeError)
|
|
41
52
|
})
|
package/src/lib/log.ts
CHANGED
|
@@ -2,6 +2,7 @@ import chalk from 'chalk'
|
|
|
2
2
|
import ora, { type Ora } from 'ora'
|
|
3
3
|
|
|
4
4
|
import { AstraleError, NotImplementedError } from '../errors'
|
|
5
|
+
import { printFailureDebug } from './failure-debug'
|
|
5
6
|
import { formatElapsed } from './format'
|
|
6
7
|
import { isMachine, type MachineOpts } from './output'
|
|
7
8
|
|
|
@@ -18,7 +19,7 @@ export const log = {
|
|
|
18
19
|
|
|
19
20
|
/** Report an error with hint (when present) and exit. `--json` / `--ci` / a
|
|
20
21
|
* non-TTY stdout always get one structured JSON line on stderr. */
|
|
21
|
-
export function fatal(e: unknown, opts?: MachineOpts): never {
|
|
22
|
+
export function fatal(e: unknown, opts?: MachineOpts & { readonly debug?: boolean }): never {
|
|
22
23
|
// Ctrl-C at an interactive (@inquirer/prompts) prompt — exit quietly with the
|
|
23
24
|
// SIGINT convention, not a red error line.
|
|
24
25
|
if (e instanceof Error && e.name === 'ExitPromptError') process.exit(130)
|
|
@@ -29,10 +30,11 @@ export function fatal(e: unknown, opts?: MachineOpts): never {
|
|
|
29
30
|
const payload: Record<string, unknown> = { error: code, message: msg }
|
|
30
31
|
if (e instanceof AstraleError && e.hint) payload.hint = e.hint
|
|
31
32
|
process.stderr.write(JSON.stringify(payload) + '\n')
|
|
32
|
-
|
|
33
|
+
} else {
|
|
34
|
+
log.error(`${code}: ${msg}`)
|
|
35
|
+
if (e instanceof AstraleError && e.hint) log.dim(` hint: ${e.hint}`)
|
|
33
36
|
}
|
|
34
|
-
|
|
35
|
-
if (e instanceof AstraleError && e.hint) log.dim(` hint: ${e.hint}`)
|
|
37
|
+
if (opts?.debug) printFailureDebug(e, '')
|
|
36
38
|
process.exit(1)
|
|
37
39
|
}
|
|
38
40
|
|
|
File without changes
|