@autocodeflow/cli 1.13.0 → 1.15.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/dist/client.js +9 -0
- package/dist/commands/apps.js +149 -9
- package/dist/error-code.js +6 -1
- package/dist/help.js +7 -0
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -128,6 +128,15 @@ export function normalizeApiBase(url) {
|
|
|
128
128
|
}
|
|
129
129
|
return out;
|
|
130
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* P2-3 端间 parity 登记注释(2026-10-26,文档-实现漂移修订):
|
|
133
|
+
* 本客户端刻意**无重试、无熔断**——CLI 是一次性交互进程,唯一的自愈面是
|
|
134
|
+
* 上方 401 单飞刷新(BUG-13)。完整的重试 + 熔断契约只存在于管理面客户端
|
|
135
|
+
* `packages/autocodeflow-http`(与 node-sdk 两端对齐,见其模块 docstring 的
|
|
136
|
+
* parity 地图);任务进程通用通道 `autoflow-sdk`(http.py)与 `mcp-server`
|
|
137
|
+
* (api.ts,仅超时 + 401 refresh 自愈)同样无重试/熔断。修订任何一端前先
|
|
138
|
+
* 互读各端注释。
|
|
139
|
+
*/
|
|
131
140
|
function getClient() {
|
|
132
141
|
if (!_client) {
|
|
133
142
|
_client = axios.create({
|
package/dist/commands/apps.js
CHANGED
|
@@ -342,9 +342,13 @@ export function appsCommand() {
|
|
|
342
342
|
// 保持;canary 传 { rollout: { strategy: 'canary', percentage? } }。
|
|
343
343
|
// 2026-10-07:UpgradeAllDto 增可选 version(版本定向灰度/渐进回滚)——
|
|
344
344
|
// --version <v> 时 body 带顶层 version;缺省不带(升级目标恒为应用当前版本)。
|
|
345
|
+
// R2(部署模型评审 §4.4,2026-10-24):覆盖面显式化——默认覆盖 = 全部
|
|
346
|
+
// RUNNING 行(scheduled「仅部署」行实证稳态即 RUNNING,同属默认覆盖);
|
|
347
|
+
// --include-stopped 把 stopped 行显式纳入(仅 all 策略);在途行由服务端
|
|
348
|
+
// 跳过并在响应 skipped 明细回显(黄字透出,不当作失败)。
|
|
345
349
|
// 批次由服务端异步推进(心跳确认 → 健康探测 → 提升),受理 ≠ 完成。
|
|
346
350
|
cmd.command('upgrade-all <appId>')
|
|
347
|
-
.description("Trigger a rolling upgrade of
|
|
351
|
+
.description("Trigger a rolling upgrade of the application's deployed devices to its current version (or --version). Default coverage = all RUNNING rows (deploy-only/scheduled rows report running on completion, so they are covered too); --include-stopped additionally dispatches STOPPED rows (all strategy only). Canary batches advance asynchronously on the server — acceptance is not completion")
|
|
348
352
|
.option('--strategy <strategy>', 'Rollout strategy: all (default) | canary (first batch → heartbeat confirm → health probe → auto-promote the rest, DEP-02)')
|
|
349
353
|
.option('--percentage <n>', 'Canary first-batch percentage, int 1-100 (default 50 — first batch = ceil(N × p%), at least 1)', (v) => {
|
|
350
354
|
const n = Number.parseInt(v, 10);
|
|
@@ -353,7 +357,8 @@ export function appsCommand() {
|
|
|
353
357
|
}
|
|
354
358
|
return n;
|
|
355
359
|
})
|
|
356
|
-
.option('--version <version>', 'Target a historical released version (version string, not uuid) — enables gradual rollback. Default: the application\'s current version. The app record is restored from that version snapshot before the rollout starts')
|
|
360
|
+
.option('--version <version>', 'Target a historical released version (version string, not uuid) — enables gradual rollback. Default: the application\'s current version. The app record is restored from that version snapshot before the rollout starts. Equivalent to the R1 set-current-version + deploy-version split endpoints; prefer those')
|
|
361
|
+
.option('--include-stopped', 'Also dispatch STOPPED deployment rows under the all strategy (default: only RUNNING rows — daemon and deploy-only alike). The canary strategy rejects this flag (health probing needs live processes)', false)
|
|
357
362
|
.option('--json', 'Emit raw JSON (CI-consumable)')
|
|
358
363
|
.option('-y, --yes', 'Skip the confirmation prompt for a FULL upgrade (all strategy)', false)
|
|
359
364
|
.action(async (appId, opts) => {
|
|
@@ -364,18 +369,30 @@ export function appsCommand() {
|
|
|
364
369
|
if (opts.percentage !== undefined && strategy !== 'canary') {
|
|
365
370
|
emitUsageError('--percentage only applies to --strategy canary (the full-upgrade path never reads it)');
|
|
366
371
|
}
|
|
372
|
+
// R2 §4.4:includeStopped 只作用于 all——canary 的健康探测需要活进程,
|
|
373
|
+
// 扩覆盖只会造出必失败的灰度首批;客户端先拒(与 --percentage 同口径)。
|
|
374
|
+
if (opts.includeStopped && strategy !== 'all') {
|
|
375
|
+
emitUsageError('--include-stopped only applies to the all strategy (canary batches probe live processes)');
|
|
376
|
+
}
|
|
367
377
|
// P1(CLI-AGENT-UX-AUDIT):全量滚动升级会重启该应用**所有 RUNNING 部署**,
|
|
368
378
|
// 此前零确认。canary 天然是低风险首步(且服务端会自动提升/回滚),不设门;
|
|
369
379
|
// all 是「一次性动全量」,需要显式表态——与三处 delete 共用同一套非交互语义。
|
|
370
380
|
if (strategy === 'all') {
|
|
371
|
-
if (!(await confirmDestructive(`Roll out the upgrade to ALL running deployments of ${appId}?`, { yes: opts.yes }))) {
|
|
381
|
+
if (!(await confirmDestructive(`Roll out the upgrade to ALL running deployments of ${appId}${opts.includeStopped ? ' (including stopped rows)' : ''}?`, { yes: opts.yes }))) {
|
|
372
382
|
return;
|
|
373
383
|
}
|
|
374
384
|
}
|
|
375
385
|
const spinner = ora('Triggering upgrade…').start();
|
|
376
386
|
try {
|
|
377
|
-
// all
|
|
378
|
-
// 白名单体,percentage
|
|
387
|
+
// all:缺省(无 version/include-stopped)不传 body —— 与既有全量升级
|
|
388
|
+
// 语义逐字节一致;canary:rollout 白名单体,percentage 仅在给出时携带
|
|
389
|
+
// (服务端缺省 50)。R2:all + --include-stopped 带 {includeStopped:true}。
|
|
390
|
+
const allExtras = opts.version !== undefined || opts.includeStopped
|
|
391
|
+
? {
|
|
392
|
+
...(opts.version !== undefined ? { version: opts.version } : {}),
|
|
393
|
+
...(opts.includeStopped ? { includeStopped: true } : {}),
|
|
394
|
+
}
|
|
395
|
+
: undefined;
|
|
379
396
|
const body = strategy === 'canary'
|
|
380
397
|
? {
|
|
381
398
|
...(opts.version !== undefined ? { version: opts.version } : {}),
|
|
@@ -384,9 +401,7 @@ export function appsCommand() {
|
|
|
384
401
|
...(opts.percentage !== undefined ? { percentage: opts.percentage } : {}),
|
|
385
402
|
},
|
|
386
403
|
}
|
|
387
|
-
:
|
|
388
|
-
? { version: opts.version }
|
|
389
|
-
: undefined;
|
|
404
|
+
: allExtras;
|
|
390
405
|
const r = await post(`/applications/${appId}/upgrade-all`, body);
|
|
391
406
|
spinner.stop();
|
|
392
407
|
if (opts.json) {
|
|
@@ -405,6 +420,16 @@ export function appsCommand() {
|
|
|
405
420
|
process.exitCode = 1;
|
|
406
421
|
return;
|
|
407
422
|
}
|
|
423
|
+
// R2 §4.4:覆盖面分组如实回显(旧输出只报 succeeded/total,用户无从知道
|
|
424
|
+
// 「仅部署」行也在覆盖内、stopped 有多少台被留下)。
|
|
425
|
+
const cov = r.coverage;
|
|
426
|
+
if (cov) {
|
|
427
|
+
console.log(chalk.gray(` coverage: running ${cov.running}, deploy-only ${cov.scheduled}, stopped ${cov.stopped}${opts.includeStopped ? ' (included)' : ''}, failed ${cov.failed}, in-flight ${cov.inFlight}`));
|
|
428
|
+
}
|
|
429
|
+
// 在途跳过明细:黄字逐行列出(不是失败——exit code 不受影响)。
|
|
430
|
+
for (const s of r.skipped ?? []) {
|
|
431
|
+
console.log(chalk.yellow(` skipped: ${s.deploymentId.slice(0, 12)} executor=${s.executorId ?? '-'} status=${s.status} reason=${s.reason}`));
|
|
432
|
+
}
|
|
408
433
|
if (strategy === 'canary') {
|
|
409
434
|
spinner.succeed(`Canary batch accepted: first batch ${r.succeeded}/${r.total} deployment(s)`);
|
|
410
435
|
console.log(chalk.gray(` batchId: ${r.rollout?.batchId ?? '-'} strategy: ${r.rollout?.strategy ?? strategy}`));
|
|
@@ -422,12 +447,104 @@ export function appsCommand() {
|
|
|
422
447
|
console.error(chalk.red(` ${r.failed} deployment(s) failed to accept the upgrade — inspect with: acf app deployments ${appId}`));
|
|
423
448
|
process.exitCode = 1;
|
|
424
449
|
}
|
|
450
|
+
// 存在 stopped 行且本次未纳入——显式指路(如实提示,不留「以为全升了」的误会)。
|
|
451
|
+
if (!opts.includeStopped && (cov?.stopped ?? 0) > 0) {
|
|
452
|
+
console.log(chalk.yellow(` ⚠ ${cov.stopped} stopped deployment(s) not covered — pass --include-stopped to include them`));
|
|
453
|
+
}
|
|
425
454
|
}
|
|
426
455
|
}
|
|
427
456
|
catch (e) {
|
|
428
457
|
emitError('Failed to trigger upgrade-all', e, { spinner });
|
|
429
458
|
}
|
|
430
459
|
});
|
|
460
|
+
// ── R1(2026-10-24 部署模型评审 §4.2):应用回滚拆出的两个显式动作 ──────
|
|
461
|
+
// 「设为当前版本」只按版本快照恢复应用当前字段(绝不触碰部署行/设备);
|
|
462
|
+
// 「下发到设备」先做同一份字段恢复,再对部署行逐台走 upgrade 链。旧 POST
|
|
463
|
+
// /applications/:id/rollback/:id 已标 deprecated alias(admin-web 已切双动作),
|
|
464
|
+
// CLI 不再暴露旧端点——此前 CLI 本就没有 app rollback 子命令,保持不补。
|
|
465
|
+
// acf app set-current-version <appId> <versionId>
|
|
466
|
+
cmd.command('set-current-version <appId> <versionId>')
|
|
467
|
+
.description("Restore the application's current fields from a released version snapshot (version/commit/packageUrl/entrypoint/env/manifest — same mapping as the deprecated rollback). NEVER touches deployment rows or devices; to dispatch use: acf app deploy-version")
|
|
468
|
+
.option('--json', 'Emit raw JSON (CI-consumable)')
|
|
469
|
+
.action(async (appId, versionId, opts) => {
|
|
470
|
+
// 安全半边(只改记录面)不设确认门——与 upgrade-all 的 canary 首步同口径。
|
|
471
|
+
const spinner = ora('Setting current version…').start();
|
|
472
|
+
try {
|
|
473
|
+
const r = await post(`/applications/${appId}/set-current-version`, { versionId });
|
|
474
|
+
spinner.stop();
|
|
475
|
+
if (opts.json) {
|
|
476
|
+
console.log(JSON.stringify(r, null, 2));
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
spinner.succeed(`Current version set to ${r.version}`);
|
|
480
|
+
console.log(chalk.gray(` versionId: ${r.versionId} dispatched: ${r.dispatched} (no devices touched)`));
|
|
481
|
+
}
|
|
482
|
+
catch (e) {
|
|
483
|
+
emitError('Failed to set current version', e, { spinner });
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
// acf app deploy-version <appId> <versionId> [--executors <id1,id2>]
|
|
487
|
+
cmd.command('deploy-version <appId> <versionId>')
|
|
488
|
+
.description('Restore the app fields from the version snapshot, then dispatch an upgrade to its deployment rows (default: ALL running rows, same as the deprecated rollback). Executors without a dispatchable row are reported as skipped, not errors')
|
|
489
|
+
.option('--executors <ids>', 'Comma-separated executor ids to dispatch to (default: all running deployment rows of the application)')
|
|
490
|
+
.option('--json', 'Emit raw JSON (CI-consumable)')
|
|
491
|
+
.option('-y, --yes', 'Skip the confirmation prompt (the dispatch restarts the selected deployments)', false)
|
|
492
|
+
.action(async (appId, versionId, opts) => {
|
|
493
|
+
let executorIds;
|
|
494
|
+
if (opts.executors !== undefined) {
|
|
495
|
+
executorIds = opts.executors.split(',').map((s) => s.trim()).filter(Boolean);
|
|
496
|
+
if (executorIds.length === 0) {
|
|
497
|
+
emitUsageError('--executors must list at least one executor id (comma-separated)');
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
// 下发半边会重启所选部署——与 upgrade-all 全量路径同款确认门。
|
|
501
|
+
const scope = executorIds
|
|
502
|
+
? `${executorIds.length} named executor(s)`
|
|
503
|
+
: 'ALL running deployments';
|
|
504
|
+
if (!(await confirmDestructive(`Deploy version to ${scope} of ${appId}? (this restarts those deployments)`, { yes: opts.yes }))) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
const spinner = ora('Dispatching version…').start();
|
|
508
|
+
try {
|
|
509
|
+
const r = await post(`/applications/${appId}/deploy-version`, {
|
|
510
|
+
versionId,
|
|
511
|
+
...(executorIds ? { executorIds } : {}),
|
|
512
|
+
});
|
|
513
|
+
spinner.stop();
|
|
514
|
+
// upgrade_rejected = 有行在 upgrade 链被拒(真失败);no_deployment /
|
|
515
|
+
// not_running 是显式点名的预期跳过——CI 只对前者红。
|
|
516
|
+
const rejected = r.skipped.filter((s) => s.reason === 'upgrade_rejected');
|
|
517
|
+
if (opts.json) {
|
|
518
|
+
console.log(JSON.stringify(r, null, 2));
|
|
519
|
+
if (r.upgraded.length === 0 || rejected.length > 0)
|
|
520
|
+
process.exitCode = 1;
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
if (r.upgraded.length === 0) {
|
|
524
|
+
spinner.fail('No deployment was dispatched (all targets skipped)');
|
|
525
|
+
for (const s of r.skipped) {
|
|
526
|
+
console.error(chalk.red(` ${s.executorId ?? s.deploymentId ?? '?'}: ${s.reason}${s.detail ? ` (${s.detail})` : ''}`));
|
|
527
|
+
}
|
|
528
|
+
process.exitCode = 1;
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
spinner.succeed(`Version ${r.version} dispatched: ${r.upgraded.length} deployment(s) upgrading`);
|
|
532
|
+
for (const u of r.upgraded) {
|
|
533
|
+
console.log(chalk.gray(` ${u.deploymentId.slice(0, 12)} executor: ${u.executorId ?? '-'} ${u.executorAddress ?? ''}`));
|
|
534
|
+
}
|
|
535
|
+
if (r.skipped.length > 0) {
|
|
536
|
+
console.error(chalk.yellow(` ⚠ ${r.skipped.length} skipped:`));
|
|
537
|
+
for (const s of r.skipped) {
|
|
538
|
+
console.error(chalk.yellow(` ${s.executorId ?? s.deploymentId ?? '?'}: ${s.reason}${s.detail ? ` (${s.detail})` : ''}`));
|
|
539
|
+
}
|
|
540
|
+
if (rejected.length > 0)
|
|
541
|
+
process.exitCode = 1;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
catch (e) {
|
|
545
|
+
emitError('Failed to deploy version', e, { spinner });
|
|
546
|
+
}
|
|
547
|
+
});
|
|
431
548
|
// acf app deployments [appId]
|
|
432
549
|
cmd.command('deployments [appId]')
|
|
433
550
|
.description('List deployments (optionally filtered by application)')
|
|
@@ -504,6 +621,9 @@ export function appsCommand() {
|
|
|
504
621
|
emitError('Failed to list versions', e, { spinner });
|
|
505
622
|
}
|
|
506
623
|
});
|
|
624
|
+
// P8-R:被截版本「仍有设备保留」清单的展示上限——超出折叠为计数,与
|
|
625
|
+
// admin-web ApplicationDetailPage 的 RETAINED_BUT_TRUNCATED_MAX_TAGS(10)同口径。
|
|
626
|
+
const RETAINED_BUT_TRUNCATED_MAX = 10;
|
|
507
627
|
cmd.command('releases <appId>')
|
|
508
628
|
.description('List unified release history (version × latest deployment) for an application — the modern DEP-01 view; `app versions` is the legacy alias')
|
|
509
629
|
.option('-p, --page <n>', 'Page number', '1')
|
|
@@ -513,10 +633,13 @@ export function appsCommand() {
|
|
|
513
633
|
.action(async (appId, opts) => {
|
|
514
634
|
const spinner = ora('Fetching releases…').start();
|
|
515
635
|
try {
|
|
516
|
-
// getReleases returns `{ data, total, page, pageSize }`
|
|
636
|
+
// getReleases returns `{ data, total, page, pageSize, truncated, retainedButTruncated }`
|
|
637
|
+
// (0a278da6:truncated=synthetic 聚合扫描到 5000 行上限被截;
|
|
638
|
+
// retainedButTruncated=被截但仍有设备保留的版本号,字母序。)
|
|
517
639
|
const data = await get(`/applications/${appId}/releases`, { page: opts.page, pageSize: opts.pageSize });
|
|
518
640
|
spinner.stop();
|
|
519
641
|
if (opts.json) {
|
|
642
|
+
// 信封原样透传(truncated / retainedButTruncated 一并直出,CI 自行判断)
|
|
520
643
|
console.log(JSON.stringify(data));
|
|
521
644
|
return;
|
|
522
645
|
}
|
|
@@ -543,6 +666,23 @@ export function appsCommand() {
|
|
|
543
666
|
}
|
|
544
667
|
console.log(table.toString());
|
|
545
668
|
console.log(chalk.gray(`Total: ${data.total ?? list.length} page ${opts.page}`));
|
|
669
|
+
// P8(对齐 admin-web Releases 截断告警条):truncated=true = synthetic
|
|
670
|
+
// 聚合扫描到 5000 行上限被截——表格用户必须看到「被截」事实,否则会把
|
|
671
|
+
// 「看到的」当「全量」。--json 形态已在上方原样透传两字段,不走这里。
|
|
672
|
+
if (data.truncated) {
|
|
673
|
+
console.log(chalk.yellow(`⚠ 版本行数超上限被截断,仅显示前 ${list.length} 条;完整动作史见事件流(acf app releases --json 可拿 truncated/retainedButTruncated 原始字段)`));
|
|
674
|
+
// P8-R:被截版本里「仍有设备保留」的版本号显式列出——徽标行不在
|
|
675
|
+
// 本页,不列出的话「设备还留着这版」的事实就从表格消失。超 10 个
|
|
676
|
+
// 折叠计数,与前端 RETAINED_BUT_TRUNCATED_MAX_TAGS 口径一致。
|
|
677
|
+
const retained = data.retainedButTruncated ?? [];
|
|
678
|
+
if (retained.length > 0) {
|
|
679
|
+
const shown = retained.slice(0, RETAINED_BUT_TRUNCATED_MAX).join(', ');
|
|
680
|
+
const more = retained.length > RETAINED_BUT_TRUNCATED_MAX
|
|
681
|
+
? `(还有 ${retained.length - RETAINED_BUT_TRUNCATED_MAX} 个版本)`
|
|
682
|
+
: '';
|
|
683
|
+
console.log(chalk.yellow(` 被截断但仍有设备保留的版本: ${shown}${more}`));
|
|
684
|
+
}
|
|
685
|
+
}
|
|
546
686
|
}
|
|
547
687
|
catch (e) {
|
|
548
688
|
emitError('Failed to list releases', e, { spinner });
|
package/dist/error-code.js
CHANGED
|
@@ -64,7 +64,12 @@ const CATEGORY_RULES = [
|
|
|
64
64
|
// (validation),而 `TASK_TRIGGER_CONCURRENT` / `_CONCURRENT_MODIFICATION`
|
|
65
65
|
// 才是并发冲突。少了这个环视,前者会被误判成冲突、给出"重新读一次"的
|
|
66
66
|
// 无效建议(实测红过一条)。
|
|
67
|
-
|
|
67
|
+
// 2026-10-23:补两条 SOP 归档语义——
|
|
68
|
+
// · `SOP_ARCHIVE_HAS_ACTIVE_ASSIGNMENTS`:还有未结束的指派(先处理再归档)
|
|
69
|
+
// · `SOP_NOT_DEPRECATED`:不是归档态(无可恢复)
|
|
70
|
+
// 两者都是**状态冲突**("重新读一次再决定"),不是入参错误。不加这两条
|
|
71
|
+
// 时它们会落到「未知」分支:用户拿到码却没有任何下一步。
|
|
72
|
+
/(EXISTS|_TAKEN|ALREADY_|CONFLICT|STILL_|IN_FLIGHT|(?<!MAX_)CONCURRENT|STALE|IMMUTABLE|_TERMINAL|_PAUSED|LAST_ADMIN|SELF_DELETE|AWAITING_|_NOT_PENDING|_HAS_ACTIVE_|_NOT_DEPRECATED)/,
|
|
68
73
|
],
|
|
69
74
|
[
|
|
70
75
|
'validation',
|
package/dist/help.js
CHANGED
|
@@ -108,6 +108,13 @@ export const EXAMPLES = {
|
|
|
108
108
|
'acf app upgrade-all <appId> # full rolling upgrade (default, no body)',
|
|
109
109
|
'acf app upgrade-all <appId> --strategy canary --percentage 20 # canary first, auto-promote after probe',
|
|
110
110
|
],
|
|
111
|
+
'app set-current-version': [
|
|
112
|
+
'acf app set-current-version <appId> <versionId> # R1 §4.2: restore app fields from a released snapshot ONLY — no devices touched (versionId from: acf app releases <appId>)',
|
|
113
|
+
],
|
|
114
|
+
'app deploy-version': [
|
|
115
|
+
'acf app deploy-version <appId> <versionId> # R1 §4.2: restore fields, then upgrade ALL running deployments (same as the deprecated rollback)',
|
|
116
|
+
'acf app deploy-version <appId> <versionId> --executors <id1,id2> -y # targeted dispatch; executors without a dispatchable row are skipped, not errors',
|
|
117
|
+
],
|
|
111
118
|
'executor list': ['acf executor list', 'acf executor list --json'],
|
|
112
119
|
'executor get': ['acf executor get <executorId> --json'],
|
|
113
120
|
'executor rotate': [
|