refactor(flags): scope yes/async/concurrent to command-owned flags

- remove nonInteractive plus yes/async/concurrent from GLOBAL_FLAGS and Settings;
  command dispatch no longer resolves command-only switches into global settings
- add shared ASYNC_FLAG / CONCURRENT_FLAG definitions for commands that actually
  support task-only return or parallel requests
- keep quota downgrade protection by moving --yes onto quota request and reading
  flags.yes for confirmed downgrade submission
- update existing async/concurrent consumers to read own flags; no new capability
  matrix entries are added
- refresh generated command reference and remove stale --non-interactive usage
  from e2e/stress invocations
This commit is contained in:
若麒
2026-07-06 20:43:29 +08:00
parent deab3b3841
commit 468b4d710e
63 changed files with 106 additions and 323 deletions
+2 -3
View File
@@ -46,7 +46,7 @@ describe.skipIf(<ready>)("e2e: <topic>(DashScope …)", () => {
1. **分组 help**:`runCli(["image"])` → `exitCode === 0`,stdout+stderr 含子命令名
2. **--help**:`runCli([..., "--help"])` → stderr 含主要 flags
3. **缺参**:`--non-interactive` 且不传 required flag → `exitCode === 2`,stderr 匹配 `--flag|Missing required argument`
3. **缺参**:带一个无害全局 flag(如 `--quiet`)且不传 required flag → `exitCode === 2`,stderr 匹配 `--flag|Missing required argument`
4. **--dry-run**:仅当实现在联网/上传/写盘**之前**返回;断言 stdout JSON/文本,不入网
5. **真实集成**:保留既有用例名称与断言;放在 skip 块**末尾**
@@ -70,7 +70,7 @@ describe.skipIf(<ready>)("e2e: <topic>(DashScope …)", () => {
```ts
test("foo bar 缺少 --prompt 时退出为用法错误 (2)", async () => {
const { stderr, exitCode } = await runCli(["foo", "bar", "--non-interactive"]);
const { stderr, exitCode } = await runCli(["foo", "bar", "--quiet"]);
expect(exitCode).toBe(2);
expect(stderr).toMatch(/--prompt|Missing required argument/i);
});
@@ -82,7 +82,6 @@ test("foo bar --dry-run 仅输出计划", async () => {
"--dry-run",
"--prompt",
"x",
"--non-interactive",
"--output",
"json",
]);
+2 -2
View File
@@ -104,10 +104,10 @@ process.exit(err.exitCode)
```sh
# 触发对应错误,看 text 输出
HOME=/tmp/empty node packages/cli/src/main.ts text chat --message "x" --non-interactive
HOME=/tmp/empty node packages/cli/src/main.ts text chat --message "x"
# 看 JSON 输出(应包含 cause 字段当 cause 存在时)
HOME=/tmp/empty node packages/cli/src/main.ts text chat --message "x" --non-interactive --output json
HOME=/tmp/empty node packages/cli/src/main.ts text chat --message "x" --output json
# 模拟网络层错误,验证 errno 透传
DASHSCOPE_BASE_URL=https://nonexistent-host.invalid \
-1
View File
@@ -121,7 +121,6 @@ pnpm run test:stress -- video-edit --reuse-fixtures -- --count 3
### 必须带的 CLI 参数(通用)
- `--non-interactive`
- 除 `speech recognize` 外,压测子进程宜带 `--output json`(语音识别以 `--out` 文件为准 stdout 可能为纯文本)
- 异步类命令带 `--timeout`、对应 `--poll-interval`
+1 -1
View File
@@ -59,7 +59,7 @@ grep -rnE "https://dashscope[a-z-]*\.aliyuncs\.com" packages/ --include="*.ts" \
```sh
# 验证错误 hint 不再泄漏旧 URL
HOME=/tmp/empty node packages/cli/src/main.ts text chat --message x --non-interactive
HOME=/tmp/empty node packages/cli/src/main.ts text chat --message x
# 看输出的 Get API Key URL 是否走新值
# 验证 banner / help