@lesliechan721/aw 0.1.0-beta.100 → 0.1.0-beta.101
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/src/commands/catalog-source.d.ts +1 -0
- package/dist/src/commands/catalog-source.js +1 -0
- package/dist/src/commands/catalog-source.js.map +1 -1
- package/dist/src/commands/catalog-store.d.ts +4 -0
- package/dist/src/commands/catalog-store.js +190 -137
- package/dist/src/commands/catalog-store.js.map +1 -1
- package/dist/src/commands/intent-command.d.ts +1 -0
- package/dist/src/commands/intent-command.js +2 -2
- package/dist/src/commands/intent-command.js.map +1 -1
- package/dist/src/commands/managed-commands.js +8 -4
- package/dist/src/commands/managed-commands.js.map +1 -1
- package/dist/src/commands/public-lifecycle-result.d.ts +2 -1
- package/dist/src/commands/public-lifecycle-result.js.map +1 -1
- package/dist/src/commands/public-lifecycle.d.ts +2 -1
- package/dist/src/commands/public-lifecycle.js +74 -10
- package/dist/src/commands/public-lifecycle.js.map +1 -1
- package/dist/src/commands/public-plugin-query.js +7 -3
- package/dist/src/commands/public-plugin-query.js.map +1 -1
- package/dist/src/commands/rebuild-command.js +5 -0
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/runtime.d.ts +2 -0
- package/dist/src/commands/runtime.js.map +1 -1
- package/dist/src/commands/targets-command.js +34 -6
- package/dist/src/commands/targets-command.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +170 -50
- package/dist/src/index.js.map +1 -1
- package/dist/src/output/cli-progress.d.ts +30 -0
- package/dist/src/output/cli-progress.js +424 -0
- package/dist/src/output/cli-progress.js.map +1 -0
- package/dist/src/output/model.d.ts +123 -1
- package/dist/src/output/model.js +45 -1
- package/dist/src/output/model.js.map +1 -1
- package/dist/src/output/public-command-ids.d.ts +8 -0
- package/dist/src/output/public-command-ids.js +38 -0
- package/dist/src/output/public-command-ids.js.map +1 -0
- package/dist/src/output/public-result.d.ts +6 -4
- package/dist/src/output/public-result.js +1 -364
- package/dist/src/output/public-result.js.map +1 -1
- package/dist/src/output/receipt-projection.js +7 -1
- package/dist/src/output/receipt-projection.js.map +1 -1
- package/dist/src/output/render/document.d.ts +55 -0
- package/dist/src/output/render/document.js +176 -0
- package/dist/src/output/render/document.js.map +1 -0
- package/dist/src/output/render/shared.d.ts +18 -0
- package/dist/src/output/render/shared.js +245 -0
- package/dist/src/output/render/shared.js.map +1 -0
- package/dist/src/output/render/style.d.ts +45 -0
- package/dist/src/output/render/style.js +155 -0
- package/dist/src/output/render/style.js.map +1 -0
- package/dist/src/output/render/views/commands-self.d.ts +6 -0
- package/dist/src/output/render/views/commands-self.js +210 -0
- package/dist/src/output/render/views/commands-self.js.map +1 -0
- package/dist/src/output/render/views/config.d.ts +2 -0
- package/dist/src/output/render/views/config.js +203 -0
- package/dist/src/output/render/views/config.js.map +1 -0
- package/dist/src/output/render/views/dev.d.ts +2 -0
- package/dist/src/output/render/views/dev.js +278 -0
- package/dist/src/output/render/views/dev.js.map +1 -0
- package/dist/src/output/render/views/fallback.d.ts +2 -0
- package/dist/src/output/render/views/fallback.js +6 -0
- package/dist/src/output/render/views/fallback.js.map +1 -0
- package/dist/src/output/render/views/index.d.ts +3 -0
- package/dist/src/output/render/views/index.js +79 -0
- package/dist/src/output/render/views/index.js.map +1 -0
- package/dist/src/output/render/views/lifecycle.d.ts +5 -0
- package/dist/src/output/render/views/lifecycle.js +170 -0
- package/dist/src/output/render/views/lifecycle.js.map +1 -0
- package/dist/src/output/render/views/sources-cache.d.ts +3 -0
- package/dist/src/output/render/views/sources-cache.js +322 -0
- package/dist/src/output/render/views/sources-cache.js.map +1 -0
- package/dist/src/output/render/views/targets.d.ts +2 -0
- package/dist/src/output/render/views/targets.js +82 -0
- package/dist/src/output/render/views/targets.js.map +1 -0
- package/dist/src/platforms/discovery.d.ts +1 -1
- package/dist/src/platforms/discovery.js +19 -2
- package/dist/src/platforms/discovery.js.map +1 -1
- package/dist/src/recovery/coordinator.js +5 -0
- package/dist/src/recovery/coordinator.js.map +1 -1
- package/dist/src/recovery/joint-coordinator.js +5 -0
- package/dist/src/recovery/joint-coordinator.js.map +1 -1
- package/dist/src/recovery/joint-install-execution.js +4 -0
- package/dist/src/recovery/joint-install-execution.js.map +1 -1
- package/dist/src/recovery/retirement.js +5 -0
- package/dist/src/recovery/retirement.js.map +1 -1
- package/dist/src/utils/aw-home-mutation-lock.d.ts +1 -0
- package/dist/src/utils/aw-home-mutation-lock.js +26 -5
- package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
- package/dist/src/utils/catalog-generation-service.d.ts +1 -0
- package/dist/src/utils/catalog-generation-service.js +7 -0
- package/dist/src/utils/catalog-generation-service.js.map +1 -1
- package/dist/src/utils/catalog-generation-store.d.ts +1 -0
- package/dist/src/utils/catalog-generation-store.js +1 -0
- package/dist/src/utils/catalog-generation-store.js.map +1 -1
- package/dist/src/utils/native-cli-interruption.d.ts +3 -0
- package/dist/src/utils/native-cli-interruption.js +68 -27
- package/dist/src/utils/native-cli-interruption.js.map +1 -1
- package/dist/src/utils/process-lock.d.ts +1 -0
- package/dist/src/utils/process-lock.js +8 -0
- package/dist/src/utils/process-lock.js.map +1 -1
- package/package.json +3 -3
package/dist/src/index.js
CHANGED
|
@@ -6,14 +6,17 @@ import { CLI_OUTPUT_SCHEMA_VERSION, commandResult, publicExitCode, renderPublicR
|
|
|
6
6
|
import { projectReceipt } from './output/receipt-projection.js';
|
|
7
7
|
import { observePreferences } from './intent/deployment-preferences.js';
|
|
8
8
|
import { assertConfigLayerWritable, ConfigLayerError, resolveActiveConfigPlatforms } from './utils/config-platforms.js';
|
|
9
|
-
import {
|
|
9
|
+
import { isPublicResultCommandId } from './output/public-command-ids.js';
|
|
10
|
+
import { createCliProgressController, resolveCliProgressMode } from './output/cli-progress.js';
|
|
11
|
+
import { resolveTerminalCapabilities } from './output/render/style.js';
|
|
12
|
+
import { reportCliPhase, withCliPhase } from './output/model.js';
|
|
10
13
|
import { runPublicLifecycle } from './commands/public-lifecycle.js';
|
|
11
14
|
import { runPublicPluginList, runPublicPluginShow, runPublicPluginStatus } from './commands/public-plugin-query.js';
|
|
12
15
|
import fs from 'node:fs';
|
|
13
16
|
import path from 'node:path';
|
|
14
17
|
import { defaultPluginProcessRunner } from './utils/plugin-scripts.js';
|
|
15
18
|
import { fileURLToPath } from 'node:url';
|
|
16
|
-
import { withNativeCliInterruption } from './utils/native-cli-interruption.js';
|
|
19
|
+
import { registerBeforeSignalExit, withNativeCliInterruption } from './utils/native-cli-interruption.js';
|
|
17
20
|
import { Command, CommanderError, InvalidArgumentError, Option } from 'commander';
|
|
18
21
|
import { doctorEvalProviders } from '@lesliechan721/agent-skill-eval';
|
|
19
22
|
import { compilePluginConfigDefinition, selectPluginConfigProfile, PLATFORM_TARGETS, CONFIG_SUGGESTIONS_TIMEOUT_MIN_MS, CONFIG_SUGGESTIONS_TIMEOUT_MAX_MS, } from '@lesliechan721/aw-plugin-core/manifest';
|
|
@@ -407,6 +410,10 @@ function parseBareConsoleOptions(argv) {
|
|
|
407
410
|
if (token === '--help' || token === '-h' || token === '--version' || token === '-V') {
|
|
408
411
|
return null;
|
|
409
412
|
}
|
|
413
|
+
if (token === '--no-color' || token === '--no-progress') {
|
|
414
|
+
parsed[token === '--no-color' ? 'color' : 'progress'] = false;
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
410
417
|
if (token === '-v' || token === '--verbose') {
|
|
411
418
|
parsed.verbose = true;
|
|
412
419
|
continue;
|
|
@@ -610,7 +617,7 @@ function writeConfigReadHuman(write, resolved, pluginName) {
|
|
|
610
617
|
}
|
|
611
618
|
}
|
|
612
619
|
}
|
|
613
|
-
export function buildProgram(options = {}) {
|
|
620
|
+
export function buildProgram(options = {}, legacyDiagnosticSink) {
|
|
614
621
|
const cwd = options.cwd ?? process.cwd();
|
|
615
622
|
const env = options.env ?? process.env;
|
|
616
623
|
const commandExitState = { exitCode: 0 };
|
|
@@ -618,6 +625,9 @@ export function buildProgram(options = {}) {
|
|
|
618
625
|
...createDefaultIo(),
|
|
619
626
|
...options.io,
|
|
620
627
|
};
|
|
628
|
+
// Direct buildProgram consumers keep the legacy stderr output. runCli
|
|
629
|
+
// captures these receipt diagnostics separately from ordinary verbose logs.
|
|
630
|
+
const writeLegacyDiagnostic = legacyDiagnosticSink ?? io.stderr;
|
|
621
631
|
const createActionContext = (commandName, rawOptions) => createCliExecutionContext({
|
|
622
632
|
...options,
|
|
623
633
|
cwd,
|
|
@@ -637,7 +647,7 @@ export function buildProgram(options = {}) {
|
|
|
637
647
|
.exitOverride()
|
|
638
648
|
.configureOutput({
|
|
639
649
|
writeOut: (text) => io.stdout(text),
|
|
640
|
-
writeErr: (text) =>
|
|
650
|
+
writeErr: (text) => writeLegacyDiagnostic(text),
|
|
641
651
|
outputError: (text, write) => write(text),
|
|
642
652
|
});
|
|
643
653
|
const dev = program.command('dev').description('Create, validate, build, and publish author sources');
|
|
@@ -1046,7 +1056,7 @@ export function buildProgram(options = {}) {
|
|
|
1046
1056
|
const message = error instanceof Error ? error.message : String(error);
|
|
1047
1057
|
if (rawOptions.json)
|
|
1048
1058
|
writeJsonReceipt(io.stdout, { command: 'plugin:test', ok: false, errors: [{ message }] });
|
|
1049
|
-
writeLine(
|
|
1059
|
+
writeLine(writeLegacyDiagnostic, message);
|
|
1050
1060
|
commandExitState.exitCode = 1;
|
|
1051
1061
|
}
|
|
1052
1062
|
});
|
|
@@ -1080,7 +1090,7 @@ export function buildProgram(options = {}) {
|
|
|
1080
1090
|
const message = error instanceof Error ? error.message : String(error);
|
|
1081
1091
|
if (rawOptions.json)
|
|
1082
1092
|
writeJsonReceipt(io.stdout, { command: 'plugin:build', ok: false, errors: [{ message }] });
|
|
1083
|
-
writeLine(
|
|
1093
|
+
writeLine(writeLegacyDiagnostic, message);
|
|
1084
1094
|
commandExitState.exitCode = 1;
|
|
1085
1095
|
}
|
|
1086
1096
|
});
|
|
@@ -1122,7 +1132,7 @@ export function buildProgram(options = {}) {
|
|
|
1122
1132
|
const message = error instanceof Error ? error.message : String(error);
|
|
1123
1133
|
if (rawOptions.json)
|
|
1124
1134
|
writeJsonReceipt(io.stdout, { command: 'catalog:init', ok: false, errors: [{ message }] });
|
|
1125
|
-
writeLine(
|
|
1135
|
+
writeLine(writeLegacyDiagnostic, message);
|
|
1126
1136
|
commandExitState.exitCode = 1;
|
|
1127
1137
|
}
|
|
1128
1138
|
});
|
|
@@ -1154,7 +1164,7 @@ export function buildProgram(options = {}) {
|
|
|
1154
1164
|
const message = error instanceof Error ? error.message : String(error);
|
|
1155
1165
|
if (rawOptions.json)
|
|
1156
1166
|
writeJsonReceipt(io.stdout, { command: 'catalog:version', ok: false, errors: [{ message }] });
|
|
1157
|
-
writeLine(
|
|
1167
|
+
writeLine(writeLegacyDiagnostic, message);
|
|
1158
1168
|
commandExitState.exitCode = 1;
|
|
1159
1169
|
}
|
|
1160
1170
|
});
|
|
@@ -1186,7 +1196,7 @@ export function buildProgram(options = {}) {
|
|
|
1186
1196
|
const message = error instanceof Error ? error.message : String(error);
|
|
1187
1197
|
if (rawOptions.json)
|
|
1188
1198
|
writeJsonReceipt(io.stdout, { command: 'catalog:build', ok: false, errors: [{ message }] });
|
|
1189
|
-
writeLine(
|
|
1199
|
+
writeLine(writeLegacyDiagnostic, message);
|
|
1190
1200
|
commandExitState.exitCode = 1;
|
|
1191
1201
|
}
|
|
1192
1202
|
});
|
|
@@ -1207,7 +1217,7 @@ export function buildProgram(options = {}) {
|
|
|
1207
1217
|
const message = error instanceof Error ? error.message : String(error);
|
|
1208
1218
|
if (rawOptions.json)
|
|
1209
1219
|
writeJsonReceipt(io.stdout, { command: 'catalog:validate', ok: false, errors: [{ message }] });
|
|
1210
|
-
writeLine(
|
|
1220
|
+
writeLine(writeLegacyDiagnostic, message);
|
|
1211
1221
|
commandExitState.exitCode = 1;
|
|
1212
1222
|
}
|
|
1213
1223
|
});
|
|
@@ -1276,7 +1286,7 @@ export function buildProgram(options = {}) {
|
|
|
1276
1286
|
});
|
|
1277
1287
|
if (rawOptions.json)
|
|
1278
1288
|
writeJsonReceipt(io.stdout, failure);
|
|
1279
|
-
writeLine(
|
|
1289
|
+
writeLine(writeLegacyDiagnostic, failure.message);
|
|
1280
1290
|
commandExitState.exitCode = 1;
|
|
1281
1291
|
}
|
|
1282
1292
|
});
|
|
@@ -1335,7 +1345,7 @@ export function buildProgram(options = {}) {
|
|
|
1335
1345
|
});
|
|
1336
1346
|
if (rawOptions.json)
|
|
1337
1347
|
writeJsonReceipt(io.stdout, { ...failure, ...(error instanceof CatalogPublicationApplyFailure ? { overallState: 'partial', ...error.outcome } : {}) });
|
|
1338
|
-
writeLine(
|
|
1348
|
+
writeLine(writeLegacyDiagnostic, failure.message);
|
|
1339
1349
|
commandExitState.exitCode = 1;
|
|
1340
1350
|
}
|
|
1341
1351
|
});
|
|
@@ -1440,7 +1450,7 @@ export function buildProgram(options = {}) {
|
|
|
1440
1450
|
errors: [{ code: failure.code ?? failure.name ?? 'catalogSourceMutationFailed', message }],
|
|
1441
1451
|
});
|
|
1442
1452
|
}
|
|
1443
|
-
writeLine(
|
|
1453
|
+
writeLine(writeLegacyDiagnostic, message);
|
|
1444
1454
|
commandExitState.exitCode = 1;
|
|
1445
1455
|
};
|
|
1446
1456
|
const writeCatalogGenerationFailure = (command, sourceId, json, error) => {
|
|
@@ -1458,7 +1468,7 @@ export function buildProgram(options = {}) {
|
|
|
1458
1468
|
errors: [{ code: catalogGenerationErrorCode(error), message }],
|
|
1459
1469
|
});
|
|
1460
1470
|
}
|
|
1461
|
-
writeLine(
|
|
1471
|
+
writeLine(writeLegacyDiagnostic, message);
|
|
1462
1472
|
commandExitState.exitCode = 1;
|
|
1463
1473
|
};
|
|
1464
1474
|
const configLayerRecoveryResult = (result, error, pluginId) => {
|
|
@@ -1497,7 +1507,7 @@ export function buildProgram(options = {}) {
|
|
|
1497
1507
|
const message = json
|
|
1498
1508
|
? failure.message
|
|
1499
1509
|
: redactString(sanitizeCatalogSourceErrorMessage(error instanceof Error ? error.message : String(error), env, [cwd]));
|
|
1500
|
-
writeLine(
|
|
1510
|
+
writeLine(writeLegacyDiagnostic, message);
|
|
1501
1511
|
commandExitState.exitCode = failure.code === 'invalidArguments' ? 2
|
|
1502
1512
|
: ['configSchemaUnavailable', 'schemaUnavailable', 'configUnavailable', 'requiredConfigMissing'].includes(failure.code) ? 3 : 1;
|
|
1503
1513
|
};
|
|
@@ -1506,6 +1516,7 @@ export function buildProgram(options = {}) {
|
|
|
1506
1516
|
return withAwHomeMutationLock({
|
|
1507
1517
|
env: context.env,
|
|
1508
1518
|
signal: context.signal,
|
|
1519
|
+
onContention: (status) => reportCliPhase(context.reporter, 'wait-lock', status),
|
|
1509
1520
|
action: async (awHomeMutationToken) => {
|
|
1510
1521
|
const catalogOperationContext = await resolveCatalogOperationContext({
|
|
1511
1522
|
...(parsed.sourceId ? { sourceIds: [parsed.sourceId] } : {}),
|
|
@@ -1535,7 +1546,8 @@ export function buildProgram(options = {}) {
|
|
|
1535
1546
|
if (rawOptions.check && rawOptions.replaceDamaged) {
|
|
1536
1547
|
throw new Error('catalog source sync --check cannot use --replace-damaged.');
|
|
1537
1548
|
}
|
|
1538
|
-
const
|
|
1549
|
+
const context = createActionContext('source.sync', rawOptions);
|
|
1550
|
+
const result = await withCliPhase(context.reporter, rawOptions.check ? 'check-remote-source' : 'sync-source', () => syncCatalogSourceCommand({
|
|
1539
1551
|
sourceId: id,
|
|
1540
1552
|
cliVersion: resolveCliVersion(),
|
|
1541
1553
|
cwd,
|
|
@@ -1543,7 +1555,8 @@ export function buildProgram(options = {}) {
|
|
|
1543
1555
|
impactConfirmed: rawOptions.yes === true,
|
|
1544
1556
|
replaceDamaged: rawOptions.replaceDamaged === true,
|
|
1545
1557
|
env,
|
|
1546
|
-
|
|
1558
|
+
runtime: { onContention: (status) => reportCliPhase(context.reporter, 'wait-lock', status) },
|
|
1559
|
+
}), { subject: id });
|
|
1547
1560
|
if (rawOptions.json) {
|
|
1548
1561
|
writeJsonReceipt(io.stdout, {
|
|
1549
1562
|
...result,
|
|
@@ -1632,7 +1645,9 @@ export function buildProgram(options = {}) {
|
|
|
1632
1645
|
request: { action: 'add', source }, cwd, env,
|
|
1633
1646
|
})
|
|
1634
1647
|
: undefined;
|
|
1648
|
+
const context = createActionContext('source.add', rawOptions);
|
|
1635
1649
|
const receipt = await addCatalogSourceCommand({
|
|
1650
|
+
runtime: { onContention: (status) => reportCliPhase(context.reporter, 'wait-lock', status) },
|
|
1636
1651
|
source,
|
|
1637
1652
|
cliVersion: resolveCliVersion(),
|
|
1638
1653
|
cwd,
|
|
@@ -1650,7 +1665,7 @@ export function buildProgram(options = {}) {
|
|
|
1650
1665
|
else
|
|
1651
1666
|
writeLine(io.stdout, `Catalog source ${id} added.`);
|
|
1652
1667
|
for (const diagnostic of receipt.errors)
|
|
1653
|
-
writeLine(
|
|
1668
|
+
writeLine(writeLegacyDiagnostic, `Warning: ${diagnostic.message}`);
|
|
1654
1669
|
}
|
|
1655
1670
|
catch (error) {
|
|
1656
1671
|
await writeCatalogSourceFailure('catalog:source:add', id, rawOptions.json === true, error, rawOptions.path === undefined ? [] : [rawOptions.path, path.resolve(cwd, rawOptions.path)]);
|
|
@@ -1713,7 +1728,9 @@ export function buildProgram(options = {}) {
|
|
|
1713
1728
|
const preview = await preflightCatalogSourceMutation({
|
|
1714
1729
|
request: { action: 'update', sourceId: id, update, ...(rawOptions.primary ? { primary: true } : {}) }, cwd, env,
|
|
1715
1730
|
});
|
|
1731
|
+
const context = createActionContext('source.update', rawOptions);
|
|
1716
1732
|
const receipt = await updateCatalogSourceCommand({
|
|
1733
|
+
runtime: { onContention: (status) => reportCliPhase(context.reporter, 'wait-lock', status) },
|
|
1717
1734
|
sourceId: id,
|
|
1718
1735
|
update,
|
|
1719
1736
|
...(rawOptions.primary ? { primary: true } : {}),
|
|
@@ -1733,7 +1750,7 @@ export function buildProgram(options = {}) {
|
|
|
1733
1750
|
else
|
|
1734
1751
|
writeLine(io.stdout, `Catalog source ${id} updated.`);
|
|
1735
1752
|
for (const diagnostic of receipt.errors)
|
|
1736
|
-
writeLine(
|
|
1753
|
+
writeLine(writeLegacyDiagnostic, `Warning: ${diagnostic.message}`);
|
|
1737
1754
|
}
|
|
1738
1755
|
catch (error) {
|
|
1739
1756
|
await writeCatalogSourceFailure('catalog:source:update', id, rawOptions.json === true, error, rawOptions.path === undefined ? [] : [rawOptions.path, path.resolve(cwd, rawOptions.path)]);
|
|
@@ -1747,7 +1764,9 @@ export function buildProgram(options = {}) {
|
|
|
1747
1764
|
.action(async (id, rawOptions) => {
|
|
1748
1765
|
try {
|
|
1749
1766
|
const preview = await preflightCatalogSourceMutation({ request: { action: 'remove', sourceId: id }, cwd, env });
|
|
1767
|
+
const context = createActionContext('source.remove', rawOptions);
|
|
1750
1768
|
const receipt = await removeCatalogSourceCommand({
|
|
1769
|
+
runtime: { onContention: (status) => reportCliPhase(context.reporter, 'wait-lock', status) },
|
|
1751
1770
|
sourceId: id,
|
|
1752
1771
|
cwd,
|
|
1753
1772
|
env,
|
|
@@ -1771,7 +1790,8 @@ export function buildProgram(options = {}) {
|
|
|
1771
1790
|
.option('-j, --json', 'print Catalog store status as JSON', false)
|
|
1772
1791
|
.action(async (rawOptions) => {
|
|
1773
1792
|
try {
|
|
1774
|
-
const
|
|
1793
|
+
const context = createActionContext('cache.status', rawOptions);
|
|
1794
|
+
const result = await catalogStoreStatus({ env, onProgress: (event) => reportCliPhase(context.reporter, event.phase, event.status, event) });
|
|
1775
1795
|
if (rawOptions.json) {
|
|
1776
1796
|
writeJsonReceipt(io.stdout, result);
|
|
1777
1797
|
}
|
|
@@ -1801,7 +1821,7 @@ export function buildProgram(options = {}) {
|
|
|
1801
1821
|
entries: [],
|
|
1802
1822
|
errors: [{ code: catalogStoreErrorCode(error), message }],
|
|
1803
1823
|
});
|
|
1804
|
-
writeLine(
|
|
1824
|
+
writeLine(writeLegacyDiagnostic, message);
|
|
1805
1825
|
commandExitState.exitCode = 1;
|
|
1806
1826
|
}
|
|
1807
1827
|
});
|
|
@@ -1818,7 +1838,8 @@ export function buildProgram(options = {}) {
|
|
|
1818
1838
|
code: 'invalidArguments',
|
|
1819
1839
|
});
|
|
1820
1840
|
}
|
|
1821
|
-
const
|
|
1841
|
+
const context = createActionContext('cache.prune', rawOptions);
|
|
1842
|
+
const result = await catalogStorePrune({ dryRun, env, onProgress: (event) => reportCliPhase(context.reporter, event.phase, event.status, event) });
|
|
1822
1843
|
if (rawOptions.json) {
|
|
1823
1844
|
writeJsonReceipt(io.stdout, result);
|
|
1824
1845
|
}
|
|
@@ -1853,7 +1874,7 @@ export function buildProgram(options = {}) {
|
|
|
1853
1874
|
reclaimableBytes: null,
|
|
1854
1875
|
deletedBytes: 0,
|
|
1855
1876
|
});
|
|
1856
|
-
writeLine(
|
|
1877
|
+
writeLine(writeLegacyDiagnostic, message);
|
|
1857
1878
|
commandExitState.exitCode = 1;
|
|
1858
1879
|
}
|
|
1859
1880
|
});
|
|
@@ -1919,7 +1940,7 @@ export function buildProgram(options = {}) {
|
|
|
1919
1940
|
});
|
|
1920
1941
|
contextualCommand(targets.command('list'))
|
|
1921
1942
|
.action(async (rawOptions) => runRecoveryAction('targets:list', rawOptions, (context) => targetsList({ cwd: context.cwd, env: context.env, context: recoveryContext(rawOptions),
|
|
1922
|
-
runtime: { nativeCliRunner: context.nativeCliRunner } })));
|
|
1943
|
+
runtime: { nativeCliRunner: context.nativeCliRunner, reporter: context.reporter } })));
|
|
1923
1944
|
for (const action of ['exclude', 'include']) {
|
|
1924
1945
|
contextualCommand(targets.command(action).argument('<plugin>'))
|
|
1925
1946
|
.addOption(strictValueOption('--target <target>', 'one canonical platform target', PLATFORM_TARGETS).makeOptionMandatory())
|
|
@@ -1983,7 +2004,7 @@ export function buildProgram(options = {}) {
|
|
|
1983
2004
|
throw new ConfigSuggestionArgumentError(`Use a decimal integer between ${CONFIG_SUGGESTIONS_TIMEOUT_MIN_MS} and ${CONFIG_SUGGESTIONS_TIMEOUT_MAX_MS} milliseconds.`);
|
|
1984
2005
|
}
|
|
1985
2006
|
const work = await configContext(context, rawOptions, false);
|
|
1986
|
-
const result = await runActionWithContext(context, () => withResolvedCatalogPlugin({
|
|
2007
|
+
const result = await withCliPhase(context.reporter, 'load-suggestions', () => runActionWithContext(context, () => withResolvedCatalogPlugin({
|
|
1987
2008
|
selector, cliVersion: resolveCliVersion(), env: context.env, signal: context.signal,
|
|
1988
2009
|
consume: async ({ plugin }) => {
|
|
1989
2010
|
const prepared = await preparePluginConfigSuggestions({
|
|
@@ -2007,7 +2028,7 @@ export function buildProgram(options = {}) {
|
|
|
2007
2028
|
} })),
|
|
2008
2029
|
});
|
|
2009
2030
|
},
|
|
2010
|
-
}));
|
|
2031
|
+
})), { subject: parts.join('.'), profile: platform ?? 'common', failed: (value) => value.status === 'failed' || value.status === 'blocked' });
|
|
2011
2032
|
writeJsonReceipt(io.stdout, result);
|
|
2012
2033
|
commandExitState.exitCode = publicExitCode(result);
|
|
2013
2034
|
}
|
|
@@ -2308,7 +2329,7 @@ export function buildProgram(options = {}) {
|
|
|
2308
2329
|
};
|
|
2309
2330
|
};
|
|
2310
2331
|
const resetReceipt = await runActionWithContext(context, () => withAwHomeMutationLock({
|
|
2311
|
-
env: context.env, signal: context.signal, action: async (token) => {
|
|
2332
|
+
env: context.env, signal: context.signal, onContention: (status) => reportCliPhase(context.reporter, 'wait-lock', status), action: async (token) => {
|
|
2312
2333
|
let started = false;
|
|
2313
2334
|
try {
|
|
2314
2335
|
const operationContext = await resolveCatalogOperationContext({ sourceIds: [located.sourceId],
|
|
@@ -2427,7 +2448,7 @@ export function buildProgram(options = {}) {
|
|
|
2427
2448
|
}
|
|
2428
2449
|
commandExitState.exitCode = result.ok ? 0 : 1;
|
|
2429
2450
|
});
|
|
2430
|
-
configurePublicCommands(program, options, io, commandExitState);
|
|
2451
|
+
configurePublicCommands(program, options, io, commandExitState, writeLegacyDiagnostic);
|
|
2431
2452
|
Object.assign(program, { __awCommandExitState: commandExitState });
|
|
2432
2453
|
return program;
|
|
2433
2454
|
}
|
|
@@ -2515,7 +2536,7 @@ function commandId(command) {
|
|
|
2515
2536
|
names.unshift(current.name());
|
|
2516
2537
|
return names.join('.');
|
|
2517
2538
|
}
|
|
2518
|
-
function configurePublicCommands(program, options, io, exit) {
|
|
2539
|
+
function configurePublicCommands(program, options, io, exit, writeLegacyDiagnostic) {
|
|
2519
2540
|
const find = (parent, name) => {
|
|
2520
2541
|
const result = parent.commands.find((entry) => entry.name() === name);
|
|
2521
2542
|
if (!result)
|
|
@@ -2539,9 +2560,13 @@ function configurePublicCommands(program, options, io, exit) {
|
|
|
2539
2560
|
io.result?.(result);
|
|
2540
2561
|
return;
|
|
2541
2562
|
}
|
|
2563
|
+
const action = context('source.status', raw);
|
|
2542
2564
|
const remote = await Promise.all(result.sources.map(async (source) => {
|
|
2543
2565
|
try {
|
|
2544
|
-
const probe = await
|
|
2566
|
+
const probe = await withCliPhase(action.reporter, 'check-remote-source', () => syncCatalogSourceCommand({
|
|
2567
|
+
sourceId: source.sourceId, cliVersion: resolveCliVersion(), cwd: options.cwd, check: true, env,
|
|
2568
|
+
runtime: { onContention: (status) => reportCliPhase(action.reporter, 'wait-lock', status) },
|
|
2569
|
+
}), { subject: source.sourceId });
|
|
2545
2570
|
return { sourceId: source.sourceId, checked: true, candidate: probe.resolution, outcome: probe.outcome };
|
|
2546
2571
|
}
|
|
2547
2572
|
catch (error) {
|
|
@@ -2608,7 +2633,7 @@ function configurePublicCommands(program, options, io, exit) {
|
|
|
2608
2633
|
const tokens = [...scriptRoutes[id], ...(id === 'dev.skill.create' ? [String(raw.plugin)] : selected.args)];
|
|
2609
2634
|
for (const option of selected.options) {
|
|
2610
2635
|
const value = selected.getOptionValue(option.attributeName());
|
|
2611
|
-
if (['json', 'plugin', 'verbose', 'debug', 'logFile'].includes(option.attributeName()) || value === undefined || value === false && !option.negate || value === true && option.negate)
|
|
2636
|
+
if (['json', 'plugin', 'verbose', 'debug', 'logFile', 'color', 'progress'].includes(option.attributeName()) || value === undefined || value === false && !option.negate || value === true && option.negate)
|
|
2612
2637
|
continue;
|
|
2613
2638
|
tokens.push(option.long);
|
|
2614
2639
|
if (value !== true && !option.negate)
|
|
@@ -2622,12 +2647,22 @@ function configurePublicCommands(program, options, io, exit) {
|
|
|
2622
2647
|
tokens.push('--workspace-root', workspace.workspaceRoot);
|
|
2623
2648
|
}
|
|
2624
2649
|
let protocol = '';
|
|
2625
|
-
|
|
2626
|
-
exit.exitCode = await runAuthoringCliAdapter(tokens, { ...options, interactive: false, io: {
|
|
2650
|
+
const scriptStderr = [];
|
|
2651
|
+
exit.exitCode = await runAuthoringCliAdapter(tokens, { ...options, interactive: false, io: {
|
|
2652
|
+
stdout: (text) => { if (hasProtocol)
|
|
2627
2653
|
protocol += text;
|
|
2628
2654
|
else
|
|
2629
|
-
io.stderr(text); },
|
|
2630
|
-
|
|
2655
|
+
io.stderr(text); },
|
|
2656
|
+
stderr: (text) => { scriptStderr.push(text); },
|
|
2657
|
+
} });
|
|
2658
|
+
const hasReceipt = hasProtocol && Boolean(protocol.trim());
|
|
2659
|
+
// A failed fallback receipt incorporates the script's stderr as its
|
|
2660
|
+
// diagnostic. remove-plugin also mirrors its JSON failure on stderr.
|
|
2661
|
+
const writeScriptStderr = exit.exitCode !== 0 && (!hasReceipt || id === 'dev.plugin.remove')
|
|
2662
|
+
? writeLegacyDiagnostic : io.stderr;
|
|
2663
|
+
for (const text of scriptStderr)
|
|
2664
|
+
writeScriptStderr(text);
|
|
2665
|
+
if (hasReceipt) {
|
|
2631
2666
|
let value;
|
|
2632
2667
|
try {
|
|
2633
2668
|
value = JSON.parse(protocol);
|
|
@@ -2638,7 +2673,7 @@ function configurePublicCommands(program, options, io, exit) {
|
|
|
2638
2673
|
io.result?.(value);
|
|
2639
2674
|
}
|
|
2640
2675
|
else
|
|
2641
|
-
io.result?.({ ok: exit.exitCode === 0, pluginName: raw.plugin ?? selected.args[0], workspaceRoot: raw.workspaceRoot ?? options.cwd, ...(exit.exitCode ? { errors: [{ code: 'authoringFailed', message:
|
|
2676
|
+
io.result?.({ ok: exit.exitCode === 0, pluginName: raw.plugin ?? selected.args[0], workspaceRoot: raw.workspaceRoot ?? options.cwd, ...(exit.exitCode ? { errors: [{ code: 'authoringFailed', message: scriptStderr.join('').trim() || 'The authoring tool did not complete.' }] } : {}) });
|
|
2642
2677
|
});
|
|
2643
2678
|
if (!cmd.options.some((option) => option.long === '--json'))
|
|
2644
2679
|
cmd.option('-j, --json', 'Output one JSON result');
|
|
@@ -2652,10 +2687,14 @@ function configurePublicCommands(program, options, io, exit) {
|
|
|
2652
2687
|
cmd.option('-D, --debug', 'Write diagnostic logs');
|
|
2653
2688
|
if (!cmd.options.some((option) => option.long === '--log-file'))
|
|
2654
2689
|
cmd.option('--log-file <path>', 'Diagnostic log path');
|
|
2690
|
+
if (id !== 'command.run' && id !== 'internal' && !id.startsWith('internal.')) {
|
|
2691
|
+
cmd.option('--no-color', 'Disable ANSI colors');
|
|
2692
|
+
cmd.option('--no-progress', 'Disable intermediate progress');
|
|
2693
|
+
}
|
|
2655
2694
|
attach(cmd);
|
|
2656
2695
|
}
|
|
2657
2696
|
};
|
|
2658
|
-
program.option('-j, --json', 'Output one JSON result').option('-v, --verbose', 'Show additional details').option('-D, --debug', 'Write diagnostic logs').option('--log-file <path>', 'Diagnostic log path');
|
|
2697
|
+
program.option('-j, --json', 'Output one JSON result').option('-v, --verbose', 'Show additional details').option('-D, --debug', 'Write diagnostic logs').option('--log-file <path>', 'Diagnostic log path').option('--no-color', 'Disable ANSI colors').option('--no-progress', 'Disable intermediate progress');
|
|
2659
2698
|
program.command('tui').description('Open the interactive console').action(() => undefined);
|
|
2660
2699
|
attach(program);
|
|
2661
2700
|
program.hook('preAction', (_root, action) => { action.setOptionValue('json', true); });
|
|
@@ -2686,10 +2725,13 @@ function resolveRegisteredCommand(program, argv) {
|
|
|
2686
2725
|
return { command: current, index: commandIndex };
|
|
2687
2726
|
}
|
|
2688
2727
|
function helpResult(program, selected) {
|
|
2728
|
+
const displayOption = (option) => option.attributeName() === 'color' || option.attributeName() === 'progress';
|
|
2729
|
+
const inherited = selected === program ? [] : program.options.filter((option) => !displayOption(option) || !selected.options.some((own) => own.attributeName() === option.attributeName()));
|
|
2730
|
+
const options = [...selected.options, ...inherited].filter((option) => commandId(selected) !== 'command.run' || !displayOption(option));
|
|
2689
2731
|
return commandResult('help', {
|
|
2690
2732
|
command: commandId(selected) || 'aw', description: selected.description(),
|
|
2691
2733
|
arguments: selected.registeredArguments.map((argument) => ({ name: argument.name(), required: argument.required, variadic: argument.variadic, description: argument.description })),
|
|
2692
|
-
options:
|
|
2734
|
+
options: options.map((option) => ({ flags: option.flags, description: option.description, required: option.mandatory, choices: option.argChoices ?? null, conflicts: [] })),
|
|
2693
2735
|
commands: selected.commands.map((command) => ({ command: commandId(command), description: command.description() })),
|
|
2694
2736
|
resultSchema: { schemaVersion: CLI_OUTPUT_SCHEMA_VERSION, statuses: ['success', 'partial', 'blocked', 'failed'] },
|
|
2695
2737
|
rules: commandId(selected) === 'plugin.install' ? ['--scope is required.', '--only requirements cannot use --target or --script-timeout.'] : commandId(selected) === 'plugin.remove' ? ['--scope is required.', '--only outputs requires --target.', '--force cannot use --only requirements.', '--keep-dependencies cannot use --only.', '--delete-config cannot use --only.'] : [],
|
|
@@ -2698,7 +2740,7 @@ function helpResult(program, selected) {
|
|
|
2698
2740
|
});
|
|
2699
2741
|
}
|
|
2700
2742
|
function scanPresentation(program, argv) {
|
|
2701
|
-
const result = { json: false, help: false, version: false };
|
|
2743
|
+
const result = { json: false, help: false, version: false, verbose: false, noColor: false, noProgress: false };
|
|
2702
2744
|
let command = program;
|
|
2703
2745
|
for (let index = 0; index < argv.length; index++) {
|
|
2704
2746
|
const token = argv[index];
|
|
@@ -2714,6 +2756,12 @@ function scanPresentation(program, argv) {
|
|
|
2714
2756
|
const option = available.find((entry) => entry.long === flag);
|
|
2715
2757
|
if (flag === '--json')
|
|
2716
2758
|
result.json = true;
|
|
2759
|
+
if (flag === '--verbose')
|
|
2760
|
+
result.verbose = true;
|
|
2761
|
+
if (flag === '--no-color')
|
|
2762
|
+
result.noColor = true;
|
|
2763
|
+
if (flag === '--no-progress')
|
|
2764
|
+
result.noProgress = true;
|
|
2717
2765
|
if (flag === '--help')
|
|
2718
2766
|
result.help = true;
|
|
2719
2767
|
if (flag === '--version' && !option?.required)
|
|
@@ -2727,6 +2775,8 @@ function scanPresentation(program, argv) {
|
|
|
2727
2775
|
const option = available.find((entry) => entry.short === flag);
|
|
2728
2776
|
if (flag === '-j')
|
|
2729
2777
|
result.json = true;
|
|
2778
|
+
if (flag === '-v')
|
|
2779
|
+
result.verbose = true;
|
|
2730
2780
|
if (flag === '-h')
|
|
2731
2781
|
result.help = true;
|
|
2732
2782
|
if (flag === '-V')
|
|
@@ -2753,12 +2803,16 @@ export async function runCli(argv, options = {}) {
|
|
|
2753
2803
|
const context = createCliExecutionContext({ ...options, io });
|
|
2754
2804
|
let receipt;
|
|
2755
2805
|
const stderr = [];
|
|
2756
|
-
const
|
|
2757
|
-
|
|
2806
|
+
const bufferLog = (text) => { stderr.push({ kind: 'log', text }); };
|
|
2807
|
+
const progress = createCliProgressController(io.stderr, options.reporter);
|
|
2808
|
+
const commandOptions = { ...options, interactive: false, reporter: progress.reporter, io: {
|
|
2809
|
+
stdout: bufferLog, stderr: bufferLog, result: (value) => { receipt = value; },
|
|
2758
2810
|
} };
|
|
2759
|
-
const program = buildProgram(commandOptions);
|
|
2811
|
+
const program = buildProgram(commandOptions, (text) => { stderr.push({ kind: 'legacy-diagnostic', text }); });
|
|
2760
2812
|
const presentation = scanPresentation(program, awArgs);
|
|
2761
2813
|
const json = presentation.json;
|
|
2814
|
+
const verbose = presentation.verbose || options.diagnostics?.verbose === true;
|
|
2815
|
+
const capabilities = resolveTerminalCapabilities({ options, env: options.env ?? process.env, noColor: presentation.noColor, json });
|
|
2762
2816
|
const resolvedCommand = resolveRegisteredCommand(program, awArgs);
|
|
2763
2817
|
const selected = resolvedCommand.command;
|
|
2764
2818
|
const id = selected && selected !== program ? commandId(selected) : null;
|
|
@@ -2770,12 +2824,18 @@ export async function runCli(argv, options = {}) {
|
|
|
2770
2824
|
commandOptions.signal = (id === 'plugin.config.apply' || id === 'plugin.config.suggestions') && options.signal
|
|
2771
2825
|
? AbortSignal.any([options.signal, interruption.signal]) : interruption.signal;
|
|
2772
2826
|
}
|
|
2827
|
+
if (id === 'command.run' && (presentation.noColor || presentation.noProgress)) {
|
|
2828
|
+
// This path owns child stdio and does not use the public result protocol.
|
|
2829
|
+
io.stderr(`aw: invalidArguments: Unknown option ${presentation.noColor ? '--no-color' : '--no-progress'}.\n`);
|
|
2830
|
+
return 2;
|
|
2831
|
+
}
|
|
2773
2832
|
if (id === 'command.run' && !awArgs.some((arg) => arg === '--help' || arg === '-h')) {
|
|
2774
2833
|
const prefix = argv.slice(0, resolvedCommand.index).filter((arg) => arg !== 'command');
|
|
2775
2834
|
return runManagedCommandCli(['run', ...prefix, ...argv.slice(resolvedCommand.index + 1)], { ...context, interactive: false }, { cliEntry: fileURLToPath(import.meta.url), cliVersion: resolveCliVersion() });
|
|
2776
2835
|
}
|
|
2777
2836
|
let confirmation = null;
|
|
2778
2837
|
const emit = (result, invalid = false) => {
|
|
2838
|
+
progress.finish();
|
|
2779
2839
|
if (result.diagnostics.some((diagnostic) => diagnostic.code === 'catalogWorkspaceMissing')) {
|
|
2780
2840
|
const workspaceRoot = selected?.getOptionValue('workspaceRoot');
|
|
2781
2841
|
result.nextActions = result.nextActions.filter((action) => action.kind !== 'command'
|
|
@@ -2793,13 +2853,18 @@ export async function runCli(argv, options = {}) {
|
|
|
2793
2853
|
: 'The command was interrupted. Completed changes are retained in the result.' });
|
|
2794
2854
|
}
|
|
2795
2855
|
}
|
|
2796
|
-
io.stdout(json ? `${JSON.stringify(result)}\n` : renderPublicResult(result,
|
|
2797
|
-
|
|
2798
|
-
|
|
2856
|
+
io.stdout(json ? `${JSON.stringify(result)}\n` : renderPublicResult(result, {
|
|
2857
|
+
verbose, color: capabilities.colorStdout, tty: capabilities.stdoutIsTty, width: capabilities.stdoutColumns,
|
|
2858
|
+
}));
|
|
2859
|
+
if (json)
|
|
2860
|
+
for (const diagnostic of result.diagnostics)
|
|
2799
2861
|
io.stderr(`${diagnostic.code}: ${diagnostic.message}\n`);
|
|
2800
|
-
if (options.diagnostics?.verbose || awArgs.includes('--verbose'))
|
|
2801
|
-
for (const
|
|
2802
|
-
|
|
2862
|
+
if (json ? options.diagnostics?.verbose || awArgs.includes('--verbose') : verbose) {
|
|
2863
|
+
for (const { kind, text } of stderr) {
|
|
2864
|
+
if (json || (kind === 'log' && text.trim()))
|
|
2865
|
+
io.stderr(`${safePublicMessage(text.trim())}\n`);
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2803
2868
|
return interruption.cleanupFailed ? 1 : interruption.exitCode ?? publicExitCode(result, invalid);
|
|
2804
2869
|
};
|
|
2805
2870
|
if (presentation.version)
|
|
@@ -2858,6 +2923,28 @@ export async function runCli(argv, options = {}) {
|
|
|
2858
2923
|
// Other routes retain Node's normal signal termination until their domain
|
|
2859
2924
|
// runner provides the same cleanup contract. Managed run and TUI exited above.
|
|
2860
2925
|
const stopListening = controlledInterrupt ? interruption.listen() : () => undefined;
|
|
2926
|
+
const progressMode = resolveCliProgressMode({
|
|
2927
|
+
json, verbose, noProgress: presentation.noProgress, capabilities,
|
|
2928
|
+
bypass: presentation.help || presentation.version || !isPublicResultCommandId(id),
|
|
2929
|
+
});
|
|
2930
|
+
const unregisterProgressCleanup = progressMode.kind === 'tty'
|
|
2931
|
+
? registerBeforeSignalExit(() => progress.finish()) : () => undefined;
|
|
2932
|
+
progress.activate(progressMode);
|
|
2933
|
+
let authorPhase;
|
|
2934
|
+
const authorPhases = {
|
|
2935
|
+
'dev.plugin.build': 'build-plugin', 'dev.plugin.test': 'test-plugin',
|
|
2936
|
+
'dev.catalog.build': 'build-catalog', 'dev.catalog.publish.plan': 'publish-plan',
|
|
2937
|
+
'dev.catalog.publish.apply': 'publish-apply', 'dev.review.prepare': 'prepare-review',
|
|
2938
|
+
'dev.eval.prepare': 'prepare-eval',
|
|
2939
|
+
};
|
|
2940
|
+
const completeAuthorPhase = (failed) => {
|
|
2941
|
+
if (!authorPhase)
|
|
2942
|
+
return;
|
|
2943
|
+
reportCliPhase(progress.reporter, authorPhase.phase, failed ? 'fail' : 'done', {
|
|
2944
|
+
subject: authorPhase.subject, durationMs: performance.now() - authorPhase.started,
|
|
2945
|
+
});
|
|
2946
|
+
authorPhase = undefined;
|
|
2947
|
+
};
|
|
2861
2948
|
try {
|
|
2862
2949
|
program.hook('preAction', (_root, command) => {
|
|
2863
2950
|
interruption.signal.throwIfAborted();
|
|
@@ -2902,6 +2989,14 @@ export async function runCli(argv, options = {}) {
|
|
|
2902
2989
|
if (!raw.yes)
|
|
2903
2990
|
throw Object.assign(new Error('Repeat the command with --yes to confirm the listed effects.'), { code: 'confirmationRequired' });
|
|
2904
2991
|
}
|
|
2992
|
+
const phase = isPublicResultCommandId(current) ? authorPhases[current] : undefined;
|
|
2993
|
+
if (phase) {
|
|
2994
|
+
const name = command.args[0];
|
|
2995
|
+
const subject = (phase === 'build-plugin' || phase === 'test-plugin') && typeof name === 'string'
|
|
2996
|
+
&& /^[a-z0-9][a-z0-9-]*$/u.test(name) ? name : undefined;
|
|
2997
|
+
authorPhase = { phase, subject, started: performance.now() };
|
|
2998
|
+
reportCliPhase(progress.reporter, phase, 'start', { subject });
|
|
2999
|
+
}
|
|
2905
3000
|
});
|
|
2906
3001
|
await program.parseAsync(['node', 'aw', ...argv]);
|
|
2907
3002
|
const exitCode = program.__awCommandExitState.exitCode;
|
|
@@ -2910,6 +3005,9 @@ export async function runCli(argv, options = {}) {
|
|
|
2910
3005
|
return emit(helpResult(program, selected));
|
|
2911
3006
|
throw new Error('The command did not return a result.');
|
|
2912
3007
|
}
|
|
3008
|
+
const actionReceipt = receipt && typeof receipt === 'object' ? receipt : {};
|
|
3009
|
+
completeAuthorPhase(exitCode !== 0 || actionReceipt.ok === false || actionReceipt.valid === false);
|
|
3010
|
+
progress.finish();
|
|
2913
3011
|
if (id === 'dev.plugin.test' && receipt && typeof receipt === 'object') {
|
|
2914
3012
|
const logs = receipt;
|
|
2915
3013
|
if (typeof logs.stdout === 'string')
|
|
@@ -2935,6 +3033,7 @@ export async function runCli(argv, options = {}) {
|
|
|
2935
3033
|
return emit(result, invalid);
|
|
2936
3034
|
}
|
|
2937
3035
|
catch (error) {
|
|
3036
|
+
completeAuthorPhase(true);
|
|
2938
3037
|
if (error instanceof CommanderError && error.exitCode === 0)
|
|
2939
3038
|
return emit(helpResult(program, selected ?? program));
|
|
2940
3039
|
const argumentError = error instanceof CommanderError || error instanceof WriteCommandRequestError;
|
|
@@ -2960,9 +3059,16 @@ export async function runCli(argv, options = {}) {
|
|
|
2960
3059
|
const preparedConfirmation = error?.confirmation ?? confirmation;
|
|
2961
3060
|
const unknownAuthoringChanges = error?.authoringChanges === 'unknown';
|
|
2962
3061
|
const data = { ...(preparedConfirmation ? { confirmation: preparedConfirmation } : {}), ...(unknownAuthoringChanges ? { changes: 'unknown' } : {}) };
|
|
2963
|
-
|
|
3062
|
+
const failure = commandResult(isPublicResultCommandId(id) ? id : null, data, { status: unknownAuthoringChanges ? 'partial' : blocked ? 'blocked' : 'failed', diagnostics: [{ code, severity: 'error', message: safePublicMessage(message, code), ...(code === 'invalidOptionValue' ? { subject: { field: raw.message?.match(/--([a-z][a-z-]*)/u)?.[1] ?? 'option' } } : {}) }], nextActions: code === 'confirmationRequired' ? [{ kind: 'manual', message: 'Review the effects and repeat the command with --yes.' }] : [] });
|
|
3063
|
+
// Existing schema v2 also identifies a *registered command group* when
|
|
3064
|
+
// argument parsing fails before reaching a leaf. Never echo raw argv.
|
|
3065
|
+
if (!isPublicResultCommandId(id))
|
|
3066
|
+
failure.command = id;
|
|
3067
|
+
return emit(failure, argumentError);
|
|
2964
3068
|
}
|
|
2965
3069
|
finally {
|
|
3070
|
+
progress.finish();
|
|
3071
|
+
unregisterProgressCleanup();
|
|
2966
3072
|
stopListening();
|
|
2967
3073
|
}
|
|
2968
3074
|
}
|
|
@@ -2970,7 +3076,21 @@ export async function main(argv = process.argv.slice(2), options = {}) {
|
|
|
2970
3076
|
return runCli(argv, options);
|
|
2971
3077
|
}
|
|
2972
3078
|
export function runExecutableCli() {
|
|
2973
|
-
|
|
3079
|
+
const stderr = process.stderr;
|
|
3080
|
+
let stderrClosed = false;
|
|
3081
|
+
// Standard streams can emit EPIPE asynchronously without becoming
|
|
3082
|
+
// non-writable. A disappearing diagnostic/progress reader must not
|
|
3083
|
+
// invalidate the command's stdout or domain outcome.
|
|
3084
|
+
stderr.on('error', (error) => {
|
|
3085
|
+
if (error.code !== 'EPIPE')
|
|
3086
|
+
throw error;
|
|
3087
|
+
stderrClosed = true;
|
|
3088
|
+
});
|
|
3089
|
+
void withNativeCliInterruption(() => main(undefined, {
|
|
3090
|
+
promptOutputSink: stderr,
|
|
3091
|
+
io: { stderr: (text) => { if (!stderrClosed)
|
|
3092
|
+
stderr.write(text); } },
|
|
3093
|
+
})).then((exitCode) => {
|
|
2974
3094
|
if (exitCode !== 0) {
|
|
2975
3095
|
process.exitCode = exitCode;
|
|
2976
3096
|
}
|