Skip to content

Commit f6d5308

Browse files
Merge pull request #293 from modelstudioai/output-contract-review
refactor(cli): unify output contracts for agent-facing commands
2 parents e66e686 + c795c47 commit f6d5308

501 files changed

Lines changed: 33637 additions & 7656 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 102 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ concurrency:
99
group: ci-${{ github.ref }}
1010
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
1111

12+
permissions:
13+
contents: read
14+
actions: read
15+
1216
jobs:
13-
check:
14-
name: lint + typecheck + test
17+
quality:
18+
name: lint + typecheck + build
1519
runs-on: ubuntu-latest
1620
steps:
1721
- uses: actions/checkout@v6
@@ -23,7 +27,32 @@ jobs:
2327
node-version: "22"
2428
cache: pnpm
2529

26-
# Keep native-fetch and compiled Binary tests on the release Bun version.
30+
- run: pnpm install --frozen-lockfile
31+
32+
- run: pnpm run sync:skill-assets
33+
34+
- run: pnpm -r --filter "./packages/*" build
35+
36+
- run: pnpm run check
37+
38+
test:
39+
name: test shard ${{ matrix.shard }}/4
40+
runs-on: ubuntu-latest
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
shard: [1, 2, 3, 4]
45+
steps:
46+
- uses: actions/checkout@v6
47+
48+
- uses: pnpm/action-setup@v6
49+
50+
- uses: actions/setup-node@v6
51+
with:
52+
node-version: "22"
53+
cache: pnpm
54+
55+
# Every shard keeps the real Node/Bun/compiled-binary coverage.
2756
- uses: oven-sh/setup-bun@v2
2857
with:
2958
bun-version: "1.3.14"
@@ -34,6 +63,74 @@ jobs:
3463

3564
- run: pnpm -r --filter "./packages/*" build
3665

37-
- run: pnpm run check
66+
- name: Run test shard
67+
run: >-
68+
pnpm exec vp test --shard=${{ matrix.shard }}/4
69+
--reporter=default --reporter=blob --reporter=json
70+
--outputFile.blob=.ci-test-results/blob/shard-${{ matrix.shard }}.json
71+
--outputFile.json=.ci-test-results/json/shard-${{ matrix.shard }}.json
3872
39-
- run: pnpm test
73+
- name: Upload shard reports
74+
if: ${{ always() }}
75+
uses: actions/upload-artifact@v7
76+
with:
77+
name: test-shard-${{ matrix.shard }}
78+
path: .ci-test-results/
79+
include-hidden-files: true
80+
if-no-files-found: error
81+
retention-days: 3
82+
83+
# Keep the existing required-check identity. Upstream failure/skip/cancellation
84+
# must produce a failing check, rather than silently skipping the gate.
85+
check:
86+
name: lint + typecheck + test
87+
if: ${{ always() }}
88+
needs: [quality, test]
89+
runs-on: ubuntu-latest
90+
steps:
91+
- uses: actions/checkout@v6
92+
93+
- uses: pnpm/action-setup@v6
94+
95+
- uses: actions/setup-node@v6
96+
with:
97+
node-version: "22"
98+
cache: pnpm
99+
100+
- run: pnpm install --frozen-lockfile
101+
102+
- name: Download shard reports
103+
id: download
104+
uses: actions/download-artifact@v8
105+
with:
106+
pattern: test-shard-*
107+
path: .ci-test-results
108+
merge-multiple: true
109+
110+
# list --filesOnly discovers the full inventory, independently of sharding.
111+
- name: Discover complete test inventory
112+
run: pnpm exec vp test list --filesOnly --json=.ci-test-inventory.json
113+
114+
- name: Verify complete shard coverage
115+
if: ${{ always() }}
116+
env:
117+
QUALITY_RESULT: ${{ needs.quality.result }}
118+
TEST_RESULT: ${{ needs.test.result }}
119+
run: >-
120+
node tools/ci/verify-shard-reports.mjs
121+
--reports .ci-test-results --inventory .ci-test-inventory.json --shards 4
122+
123+
- name: Merge test reports
124+
if: ${{ always() && steps.download.outcome == 'success' }}
125+
run: >-
126+
pnpm exec vp test --mergeReports=.ci-test-results/blob
127+
--reporter=default --reporter=json --outputFile.json=.ci-test-summary.json
128+
129+
- name: Upload merged report
130+
if: ${{ always() }}
131+
uses: actions/upload-artifact@v7
132+
with:
133+
name: test-summary
134+
path: .ci-test-summary.json
135+
include-hidden-files: true
136+
retention-days: 3

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ tools/generated
4646

4747
# Test & scene outputs
4848
/test/
49+
/.ci-test-results/
50+
/.ci-test-inventory.json
51+
/.ci-test-summary.json
4952
packages/cli/scene/**/outputs/
5053

5154
# Environment variables (sensitive data)

‎AGENTS.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ Skill / 命令手册随 `skills/bailian-*/` 经 `bl skill init` 安装(装齐
6161
| 场景 | 何时进入 | 详见 |
6262
| ----------------- | --------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
6363
| 命令增删改 | 增加 / 删除 / 重命名 `bl xxx` 或入口命令路径 | [docs/agents/command-add-remove.md](docs/agents/command-add-remove.md) |
64-
| E2E 测试维护 | 新增/改命令或 e2e 用例、补 help/缺参/dry-run | [docs/agents/cli-e2e-tests.md](docs/agents/cli-e2e-tests.md) |
64+
| 测试维护与性能 | 新增/修改任意单测、输出契约测试或 E2E;选择 runner、fixture、计时方式 | [docs/agents/cli-e2e-tests.md](docs/agents/cli-e2e-tests.md) |
6565
| 测试隔离 | 单测/E2E 受本地 HOME、语言、系统目录干扰;统一隔离基建 | [docs/agents/test-isolation.md](docs/agents/test-isolation.md) |
66+
| 输出契约 | 新增输出、quiet/verbose、JSON 错误或流式输出 | [docs/agents/output-contract.md](docs/agents/output-contract.md) |
6667
| 批量压测 | 改/跑多能力并发压测、`test:stress`、fixtures | [docs/agents/stress-batch-tests.md](docs/agents/stress-batch-tests.md) |
6768
| 选项变更 | 给已有命令加 `--flag` 或改默认值 | [docs/agents/command-flag-change.md](docs/agents/command-flag-change.md) |
6869
| 模型上下架 | 增加新模型 / 改默认模型 / 废弃旧模型 | [docs/agents/model-add-remove.md](docs/agents/model-add-remove.md) |
@@ -136,6 +137,8 @@ CLI 只为「自己能权威解释的错误」发出语义化信号,服务端的
136137

137138
## 完成改动后的快速验证
138139

140+
新增或修改任何 `**/tests/**` 用例(含 `tests/output`)前,必须读取[测试维护规范](docs/agents/cli-e2e-tests.md)。测试通过之外,还必须检查执行成本:按测试目标选择执行层,说明必要的子进程覆盖,并对新增/扩展套件提供耗时记录;性能优化必须提供同条件前后对比,不能靠删除必要覆盖或增加跳过项提速。具体执行方式、隔离与验收清单统一在该文档维护。
141+
139142
```sh
140143
vp check # format + lint + type check
141144
vp test # unit + e2e (真实集成需 API key / console token)

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Keep the returned IDs and recovery record. Closing the CLI or a later failure do
141141

142142
### RAG audio and video
143143

144-
`bl knowledge doc import --index-id <id> --doc-id <fileId>` imports an existing file into a knowledge base; `doc list --details` shows per-file processing settings. Media support includes parser options, streaming uploads, and media references in search/chunk output. Chat JSON separates the final answer from phases, tools, docs, usage, and raw events; quiet mode emits only the final answer. See the [command guide](docs/knowledge/knowledge-cli-guide.md).
144+
`bl knowledge doc import --index-id <id> --doc-id <fileId>` imports an existing file into a knowledge base; `doc list --details` shows per-file processing settings. Media support includes parser options, streaming uploads, and media references in search/chunk output. Chat JSON separates the final answer from phases, tools, docs, usage, and raw events; quiet mode hides progress and informational messages while preserving the final result, including every JSON field. See the [command guide](docs/knowledge/knowledge-cli-guide.md).
145145

146146
## ParseX
147147

‎README.zh.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ bl knowledge init --workspace-id <workspace-id> --dry-run
140140

141141
### RAG 音视频接入
142142

143-
`bl knowledge doc import --index-id <id> --doc-id <fileId>` 将历史文件导入已有库;`doc list --details` 查看文件级处理参数。支持音视频 parser、流式上传,以及检索/切片中的媒体来源展示。问答 JSON 将最终 answer 与 phases/tools/docs/usage/events 分开保存,quiet 仅输出最终回答。参阅 [命令指南](docs/knowledge/knowledge-cli-guide.md)。
143+
`bl knowledge doc import --index-id <id> --doc-id <fileId>` 将历史文件导入已有库;`doc list --details` 查看文件级处理参数。支持音视频 parser、流式上传,以及检索/切片中的媒体来源展示。问答 JSON 将最终 answer 与 phases/tools/docs/usage/events 分开保存,quiet 只隐藏进度和过程提示,保留最终结果及完整 JSON 字段。参阅 [命令指南](docs/knowledge/knowledge-cli-guide.md)。
144144

145145
## ParseX
146146

0 commit comments

Comments
 (0)