@autocodeflow/cli 1.9.0 → 1.9.1
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 +46 -3
- package/dist/commands/apps.js +130 -30
- package/dist/commands/audit.js +4 -3
- package/dist/commands/deploy.d.ts +8 -0
- package/dist/commands/deploy.js +88 -3
- package/dist/commands/exec.js +24 -2
- package/dist/commands/executors.js +8 -1
- package/dist/commands/login.d.ts +41 -0
- package/dist/commands/login.js +139 -5
- package/dist/commands/tasks.d.ts +10 -0
- package/dist/commands/tasks.js +142 -33
- package/dist/config.d.ts +10 -1
- package/dist/config.js +22 -5
- package/dist/help.js +35 -7
- package/dist/index.js +43 -4
- package/dist/ui.d.ts +25 -0
- package/dist/ui.js +48 -0
- package/package.json +1 -1
package/dist/help.js
CHANGED
|
@@ -4,6 +4,13 @@ export const EXAMPLES = {
|
|
|
4
4
|
'acf task trigger <taskId> --wait',
|
|
5
5
|
'acf exec tail <execId>',
|
|
6
6
|
],
|
|
7
|
+
whoami: [
|
|
8
|
+
'acf whoami # preflight: role + API URL behind the current credential',
|
|
9
|
+
'acf whoami --json',
|
|
10
|
+
],
|
|
11
|
+
logout: [
|
|
12
|
+
'acf logout # revoke server-side + clear the local credential file',
|
|
13
|
+
],
|
|
7
14
|
login: [
|
|
8
15
|
'acf login',
|
|
9
16
|
'acf login --url https://acf.example.com --user admin',
|
|
@@ -13,10 +20,12 @@ export const EXAMPLES = {
|
|
|
13
20
|
'task list': [
|
|
14
21
|
'acf task list --status active --page 1',
|
|
15
22
|
'acf task list --json',
|
|
23
|
+
'acf task list --search nightly # matches name OR description (q param)',
|
|
16
24
|
],
|
|
17
25
|
'task get': ['acf task get <taskId>', 'acf task get <taskId> --json'],
|
|
18
26
|
'task trigger': [
|
|
19
27
|
'acf task trigger <taskId> --wait --wait-timeout 900',
|
|
28
|
+
'acf task trigger <taskId> --params \'{"KEY":"value"}\' # per-run param overrides (replaces task defaults)',
|
|
20
29
|
],
|
|
21
30
|
'task executions': [
|
|
22
31
|
'acf task executions <taskId> -n 5',
|
|
@@ -35,8 +44,9 @@ export const EXAMPLES = {
|
|
|
35
44
|
],
|
|
36
45
|
'task compare': ['acf task compare <taskId> <versionId1> <versionId2>'],
|
|
37
46
|
'task create': [
|
|
38
|
-
'acf task create --file task.json # required: name,
|
|
39
|
-
"acf task create --
|
|
47
|
+
'acf task create --file task.json # required: name, triggerType (runtime is optional server-side)',
|
|
48
|
+
"acf task create --body '{\"name\":\"nightly\",\"runtime\":\"node\",\"triggerType\":\"cron\",\"cronExpression\":\"0 2 * * *\"}' # note: there is NO `version` field on the task body — use `currentVersion` if you need one",
|
|
49
|
+
"acf task create --body '{\"name\":\"sync\",\"runtime\":\"python\",\"triggerType\":\"cron\",\"cronExpression\":\"0 8 * * *\",\"params\":{\"REPLACE_EXISTING\":true,\"retries\":3,\"target\":\"nightly\"}}' # params inject as AUTOFLOW_<KEY> env vars, JSON-stringified: booleans/numbers bare ('true','3'), strings quoted ('\"nightly\"')",
|
|
40
50
|
],
|
|
41
51
|
'task update': ['acf task update <taskId> --file patch.json'],
|
|
42
52
|
'task delete': ['acf task delete <taskId> -y'],
|
|
@@ -72,15 +82,21 @@ export const EXAMPLES = {
|
|
|
72
82
|
'app list': ['acf app list', 'acf app list --json'],
|
|
73
83
|
'app get': ['acf app get <appId> --json'],
|
|
74
84
|
'app create': [
|
|
75
|
-
'acf app create --
|
|
85
|
+
'acf app create --body \'{"name":"my-app","version":"1.0.0","runtime":"python"}\' # required: name, version, runtime',
|
|
76
86
|
],
|
|
77
87
|
'app update': [
|
|
78
|
-
'acf app update <appId> --
|
|
88
|
+
'acf app update <appId> --body \'{"version":"2.0.0"}\' # renaming is not supported by the backend',
|
|
79
89
|
],
|
|
80
90
|
'app delete': ['acf app delete <appId> -y'],
|
|
81
91
|
'app analyze': ['acf app analyze <appId>'],
|
|
92
|
+
'app releases': [
|
|
93
|
+
'acf app releases <appId> # DEP-01 unified view: version × latest deployment (modern; `app versions` is the legacy alias)',
|
|
94
|
+
'acf app releases <appId> -n 200 --json',
|
|
95
|
+
],
|
|
82
96
|
'app deploy': [
|
|
83
|
-
"acf app deploy <appId> -
|
|
97
|
+
"acf app deploy <appId> -m scheduled # deploy-only — middleware/cron triggers it later (default; entry script does NOT start at deploy)",
|
|
98
|
+
"acf app deploy <appId> -m daemon --env '{\"KEY\":\"value\"}' # resident process — entry script STARTS at deploy, auto-restarts on crash (CLI warns)",
|
|
99
|
+
"acf app deploy <appId> -m deploy-only # alias of scheduled — self-documenting 'deploy, don't run'",
|
|
84
100
|
],
|
|
85
101
|
'app deployments': ['acf app deployments <appId> -n 50 --json'],
|
|
86
102
|
'app versions': ['acf app versions <appId> --json'],
|
|
@@ -100,6 +116,13 @@ export const EXAMPLES = {
|
|
|
100
116
|
'executor offline': ['acf executor offline executor-node'],
|
|
101
117
|
'deploy upgrade': ['acf deploy upgrade <deploymentId>'],
|
|
102
118
|
'deploy stop': ['acf deploy stop <deploymentId>'],
|
|
119
|
+
'deploy list': [
|
|
120
|
+
'acf deploy list # same data as: acf app deployments (deployments live under app in the command tree)',
|
|
121
|
+
'acf deploy list <appId> -n 50 --json',
|
|
122
|
+
],
|
|
123
|
+
'deploy remove': [
|
|
124
|
+
'acf deploy remove <deploymentId> -y # delete a FINISHED record (failed/stopped only); running/in-flight rows are refused with 409',
|
|
125
|
+
],
|
|
103
126
|
'audit list': [
|
|
104
127
|
'acf audit list --action task.trigger --start-time 2026-01-01T00:00:00Z',
|
|
105
128
|
'acf audit list --json',
|
|
@@ -128,9 +151,14 @@ export const EXAMPLES = {
|
|
|
128
151
|
],
|
|
129
152
|
'approval reject': ['acf approval reject <deploymentId> --note "wrong version"'],
|
|
130
153
|
'approval cancel': ['acf approval cancel <deploymentId> # withdraw your own pending request'],
|
|
131
|
-
'config show': ['acf config show'],
|
|
154
|
+
'config show': ['acf config show', 'acf config show --json'],
|
|
132
155
|
'config set-url': ['acf config set-url http://localhost:3105'],
|
|
133
|
-
|
|
156
|
+
// 刻意**不**演示 `set-token <明文>`:命令行 token 会进 shell history 与进程列表。
|
|
157
|
+
// 帮助里的示例是 agent 最常照抄的东西,所以这里只给安全通路。
|
|
158
|
+
'config set-token': [
|
|
159
|
+
'ACF_TOKEN=<jwt> acf task list # preferred: env var, never touches argv/history',
|
|
160
|
+
'acf login # or: interactive hidden prompt, stored 0600',
|
|
161
|
+
],
|
|
134
162
|
};
|
|
135
163
|
/**
|
|
136
164
|
* Walk the whole command tree and attach the matching Examples block to every
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
import { Command, CommanderError } from 'commander';
|
|
36
36
|
import { pathToFileURL } from 'node:url';
|
|
37
37
|
import chalk from 'chalk';
|
|
38
|
-
import { loginCommand } from './commands/login.js';
|
|
38
|
+
import { loginCommand, whoamiCommand, logoutCommand } from './commands/login.js';
|
|
39
39
|
import { tasksCommand } from './commands/tasks.js';
|
|
40
40
|
import { appsCommand } from './commands/apps.js';
|
|
41
41
|
import { executorsCommand } from './commands/executors.js';
|
|
@@ -60,14 +60,46 @@ import { EXIT_CODES, interruptExit } from './ui.js';
|
|
|
60
60
|
// `resolveJsonModule` 已在 tsconfig 打开;tsc 的 rootDir=src 会把 package.json
|
|
61
61
|
// 视为 src 之外的输入,故走运行时解析(发布物里 package.json 与 dist/ 同级,
|
|
62
62
|
// 路径稳定)。本包为 ESM(type: module),JSON 导入须带 import attribute。
|
|
63
|
+
// 2026-10 起不再经 Commander .version() 注册(详见下方 VERSION-HIJACK 注释),
|
|
64
|
+
// 但 pkg.version 仍是版本输出的唯一事实源——行为层守卫跑真实构建产物钉死。
|
|
63
65
|
import pkg from '../package.json' with { type: 'json' };
|
|
64
66
|
// 导出命令树供测试复用(结构守卫:每个叶子命令都必须有 Examples)。配合底部
|
|
65
67
|
// 的 main-guard,import 本文件不会触发 parseAsync。
|
|
66
68
|
export const program = new Command();
|
|
67
69
|
program
|
|
68
70
|
.name('acf')
|
|
69
|
-
.description('AutoCodeFlow CLI — manage tasks, executions, applications and projects')
|
|
70
|
-
|
|
71
|
+
.description('AutoCodeFlow CLI — manage tasks, executions, applications and projects');
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// 版本号处理(VERSION-HIJACK,P1 修复)
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
// 根命令**不**注册 --version 选项:commander 的根层 parseOptions 会在派发子
|
|
76
|
+
// 命令之前扫描**全部**参数,一旦经 .version() 注册,`acf app upload --version
|
|
77
|
+
// 1.2.0` / `acf app upgrade-all --version 1.9.0` / `acf task rollback --version
|
|
78
|
+
// v9` 里的 --version 会在根层被匹配并 exit 0 打印 CLI 版本——上传/升级/回滚
|
|
79
|
+
// 根本没发生却不报错(2026-10 开发人员实测,三个子命令全部中招)。
|
|
80
|
+
//
|
|
81
|
+
// 修法:版本输出改由根命令的 unknownOption 覆盖接管——只有到达根层仍未被
|
|
82
|
+
// 任何子命令消费的 --version / -V(即 `acf --version` / `acf -V` 这类根级
|
|
83
|
+
// 请求)才打印 pkg.version 并以 0 退出;子命令自己的 --version 选项由各自的
|
|
84
|
+
// parseOptions 消费,互不干扰。pkg.version 仍是唯一事实源(行为层守卫
|
|
85
|
+
// release-metadata.test.ts 跑真实构建产物钉死,改回硬编码会转红)。
|
|
86
|
+
// 'before' 只挂在根命令的帮助上(子命令 help 不显示版本横幅——原 .version()
|
|
87
|
+
// 的版本 banner 同样是根级专属;'beforeAll' 会传播到所有子命令,太吵)。
|
|
88
|
+
program.addHelpText('before', `acf v${pkg.version}\n`);
|
|
89
|
+
// 根级 unknownOption 覆盖:`acf --version` / `acf -V` 会在根 _parseCommand 的
|
|
90
|
+
// checkForUnknownOptions 里走到这里(无子命令可派发),此时按 CLI 版本处理;
|
|
91
|
+
// 其余未知选项(含"某子命令树里没有 --version 选项"的情形)走 commander
|
|
92
|
+
// 原逻辑(报错 + 完整 help + 退出码 2)。
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
+
const programAny = program;
|
|
95
|
+
const rootUnknownOption = programAny.unknownOption.bind(program);
|
|
96
|
+
programAny.unknownOption = (flag) => {
|
|
97
|
+
if (flag === '--version' || flag === '-V') {
|
|
98
|
+
console.log(pkg.version);
|
|
99
|
+
process.exit(0);
|
|
100
|
+
}
|
|
101
|
+
return rootUnknownOption(flag);
|
|
102
|
+
};
|
|
71
103
|
// ---------------------------------------------------------------------------
|
|
72
104
|
// 解析期行为统一(全树,见下方 applyParseErrorBehavior 的说明)
|
|
73
105
|
// ---------------------------------------------------------------------------
|
|
@@ -84,6 +116,8 @@ program.hook('preAction', (thisCommand) => {
|
|
|
84
116
|
});
|
|
85
117
|
// ---- sub-commands ----
|
|
86
118
|
program.addCommand(loginCommand());
|
|
119
|
+
program.addCommand(whoamiCommand());
|
|
120
|
+
program.addCommand(logoutCommand());
|
|
87
121
|
program.addCommand(tasksCommand());
|
|
88
122
|
program.addCommand(appsCommand());
|
|
89
123
|
program.addCommand(executorsCommand());
|
|
@@ -97,7 +131,12 @@ program.addCommand(apikeysCommand());
|
|
|
97
131
|
program.addCommand(approvalCommand());
|
|
98
132
|
// acf config show / set
|
|
99
133
|
const configCmd = new Command('config').description('View or update CLI configuration');
|
|
100
|
-
configCmd
|
|
134
|
+
configCmd
|
|
135
|
+
.command('show')
|
|
136
|
+
.description('Show current config (token is always masked — [set] / [not set])')
|
|
137
|
+
// P2(CLI-AGENT-UX-AUDIT):--json 让 agent 能解析当前配置(不改 [set]/[not set] 口径)
|
|
138
|
+
.option('--json', 'Emit raw JSON (CI-consumable)')
|
|
139
|
+
.action((opts) => showConfig({ json: opts.json }));
|
|
101
140
|
configCmd.command('set-url <url>').description('Set API base URL').action((url) => {
|
|
102
141
|
setApiUrl(url);
|
|
103
142
|
console.log(chalk.green(`✔ API URL set to ${url}`));
|
package/dist/ui.d.ts
CHANGED
|
@@ -52,4 +52,29 @@ export declare function emitUsageError(message: string): never;
|
|
|
52
52
|
* `rl.on('SIGINT')` 共用这一个出口。
|
|
53
53
|
*/
|
|
54
54
|
export declare function interruptExit(): never;
|
|
55
|
+
/**
|
|
56
|
+
* 破坏性操作的交互确认 —— 三处 delete 此前各自内联 readline.question,
|
|
57
|
+
* 在 stdin 非交互(agent / CI / `< NUL`)时会**静默假绿**:
|
|
58
|
+
*
|
|
59
|
+
* $ acf app delete <id> < NUL
|
|
60
|
+
* Delete application <id>? [y/N] <- 提示打出后立刻 EOF
|
|
61
|
+
* $ echo $? -> 0,且既无 "Aborted." 也无错误行
|
|
62
|
+
*
|
|
63
|
+
* 后果是自动化面最危险的一类失败:agent 把「什么都没删」读成「删除成功」,
|
|
64
|
+
* 继续跑下游步骤。根因是 readline 在 EOF 时以空串 resolve(不是 reject),
|
|
65
|
+
* 调用方的 `/^y(es)?$/` 判否后走 "Aborted." 分支——而该分支在 Windows 上
|
|
66
|
+
* 连输出都会丢,进程以 0 收场。
|
|
67
|
+
*
|
|
68
|
+
* 语义(与 login 的 TOTP 非交互分支同一思路,收敛到一处):
|
|
69
|
+
* - `--yes` 给定 → 直接放行,不碰 stdin(脚本显式表态的唯一通路);
|
|
70
|
+
* - stdin 非 TTY → **拒绝**并给可操作错误(UsageError → 退出码 2)。既不
|
|
71
|
+
* 静默通过(会误删)也不静默取消(会假绿);
|
|
72
|
+
* - stdin 是 TTY → 交互提问;除 y/yes 外一律视为主动放弃,返回 false,
|
|
73
|
+
* 由调用方原样 return(退出码 0 —— README 已把「主动放弃确认」归入成功)。
|
|
74
|
+
*
|
|
75
|
+
* @returns true = 继续执行;false = 用户主动放弃(调用方应直接 return)。
|
|
76
|
+
*/
|
|
77
|
+
export declare function confirmDestructive(question: string, opts?: {
|
|
78
|
+
yes?: boolean;
|
|
79
|
+
}): Promise<boolean>;
|
|
55
80
|
export {};
|
package/dist/ui.js
CHANGED
|
@@ -85,3 +85,51 @@ export function interruptExit() {
|
|
|
85
85
|
process.stderr.write('\n');
|
|
86
86
|
process.exit(EXIT_CODES.INTERRUPTED);
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* 破坏性操作的交互确认 —— 三处 delete 此前各自内联 readline.question,
|
|
90
|
+
* 在 stdin 非交互(agent / CI / `< NUL`)时会**静默假绿**:
|
|
91
|
+
*
|
|
92
|
+
* $ acf app delete <id> < NUL
|
|
93
|
+
* Delete application <id>? [y/N] <- 提示打出后立刻 EOF
|
|
94
|
+
* $ echo $? -> 0,且既无 "Aborted." 也无错误行
|
|
95
|
+
*
|
|
96
|
+
* 后果是自动化面最危险的一类失败:agent 把「什么都没删」读成「删除成功」,
|
|
97
|
+
* 继续跑下游步骤。根因是 readline 在 EOF 时以空串 resolve(不是 reject),
|
|
98
|
+
* 调用方的 `/^y(es)?$/` 判否后走 "Aborted." 分支——而该分支在 Windows 上
|
|
99
|
+
* 连输出都会丢,进程以 0 收场。
|
|
100
|
+
*
|
|
101
|
+
* 语义(与 login 的 TOTP 非交互分支同一思路,收敛到一处):
|
|
102
|
+
* - `--yes` 给定 → 直接放行,不碰 stdin(脚本显式表态的唯一通路);
|
|
103
|
+
* - stdin 非 TTY → **拒绝**并给可操作错误(UsageError → 退出码 2)。既不
|
|
104
|
+
* 静默通过(会误删)也不静默取消(会假绿);
|
|
105
|
+
* - stdin 是 TTY → 交互提问;除 y/yes 外一律视为主动放弃,返回 false,
|
|
106
|
+
* 由调用方原样 return(退出码 0 —— README 已把「主动放弃确认」归入成功)。
|
|
107
|
+
*
|
|
108
|
+
* @returns true = 继续执行;false = 用户主动放弃(调用方应直接 return)。
|
|
109
|
+
*/
|
|
110
|
+
export async function confirmDestructive(question, opts = {}) {
|
|
111
|
+
if (opts.yes)
|
|
112
|
+
return true;
|
|
113
|
+
if (process.stdin.isTTY !== true) {
|
|
114
|
+
emitUsageError('Confirmation cannot be read: stdin is not interactive. ' +
|
|
115
|
+
'Re-run with --yes (-y) to confirm this destructive operation in non-interactive use ' +
|
|
116
|
+
'(CI / agent / piped stdin).');
|
|
117
|
+
}
|
|
118
|
+
const readline = await import('readline/promises');
|
|
119
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
120
|
+
// raw 模式下 Ctrl+C 触发 rl 'SIGINT' 而非进程信号;无监听只会 pause,
|
|
121
|
+
// 确认提示处会假死。接住并走统一中断出口(130)。
|
|
122
|
+
rl.on('SIGINT', () => interruptExit());
|
|
123
|
+
let answer;
|
|
124
|
+
try {
|
|
125
|
+
answer = await rl.question(`${question} [y/N] `);
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
rl.close();
|
|
129
|
+
}
|
|
130
|
+
if (!/^y(es)?$/i.test(answer)) {
|
|
131
|
+
console.log(chalk.yellow('Aborted.'));
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
}
|