Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

### 🚀 优化与重构 (Refactor)

- **SDK 升级**: 升级 `zentao-api` 至 0.6.6,获得更多模块定义、multipart 附件上传、文档内容转换以及请求超时和中止处理修复。
- **统一数据处理语义**: 列表过滤与搜索统一为组内 AND、组间 OR;规范写法采用 `field=value` 与 `field:desc`,并兼容旧有冒号相等和下划线排序语法。
- **复用 SDK 处理链**: 模块执行器直接使用 `zentao-api request()` 的转换、过滤、搜索、排序、限制与摘取能力,移除 CLI 内重复的数据工具实现。
- **原始输出**: `--format=raw` 直接返回服务端响应原文,不再执行归一化或本地数据处理。
Expand Down
4 changes: 2 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"commander": "^13.0.0",
"configstore": "^7.0.0",
"turndown": "^7.2.0",
"zentao-api": "^0.5.4",
"zentao-api": "^0.6.6",
"zod": "^4.3.6"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions skills/zentao-cli/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ zentao login -s https://zentao.example.com -u admin -p 123456
zentao story --product=1 # 产品 #1 的需求
zentao bug --product=1 # 产品 #1 的 Bug
zentao task --executionID=1 # 执行 #1 的任务
zentao execution --status=all --filter='project=5' # 项目 #5 的执行(当前页客户端过滤)
zentao execution --browseType=all --filter='project=5' # 项目 #5 的执行(当前页客户端过滤)
zentao build --project=5 # 项目 #5 的版本
zentao testtask --product=1 # 产品 #1 的测试单
zentao release --productID=1 # 产品 #1 的发布
Expand Down Expand Up @@ -199,7 +199,7 @@ CLI 不会自动翻页。仅当该列表操作的 `--help` 显示 `--page` / `--

```bash
zentao project --browseType=doing --pick=id,name,status
zentao execution --status=all --filter='project=5' --pick=id,name,status
zentao execution --browseType=all --filter='project=5' --pick=id,name,status
```

### 创建需求并关联计划
Expand Down
8 changes: 4 additions & 4 deletions skills/zentao-tour/roles/executive.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ zentao project --browseType=doing --pick=id,name,begin,end,progress
让他扫一眼,问:"有没有哪条看着不对劲?进度慢的、日期要到的?"——挑出一个深入看:

```bash
zentao execution --status=all --filter='project=<id>' --pick=id,name,status --page=<页码> --recPerPage=100
zentao task --executionID=<执行ID> --status=all --pick=id,status --page=<页码> --recPerPage=100 --format=json
zentao execution --browseType=all --filter='project=<id>' --pick=id,name,status --page=<页码> --recPerPage=100
zentao task --executionID=<执行ID> --browseType=all --pick=id,status --page=<页码> --recPerPage=100 --format=json
```

执行列表没有项目作用域,所以用 `--filter` 在当前页本地筛选;必须扫完全局执行列表的每一页,才能收集某项目的全部执行 ID。再对每个执行按任务 pager 逐页读取,本地聚合"wait/doing/done 各多少",用一句话汇报给用户。
Expand Down Expand Up @@ -85,8 +85,8 @@ zentao ticket --productID=<id> --browseType=all --pick=id,title,status,pri
| 关注点 | 命令 |
|--------|------|
| 进行中的项目 | `zentao project --browseType=doing --pick=id,name,progress,begin,end` |
| 项目下的执行 | `zentao execution --status=all --filter='project=<id>' --pick=id,name,status --page=<页码> --recPerPage=100`|
| 任务状态聚合 | `zentao task --executionID=<id> --status=all --pick=status --page=<页码> --recPerPage=100 --format=json` |
| 项目下的执行 | `zentao execution --browseType=all --filter='project=<id>' --pick=id,name,status --page=<页码> --recPerPage=100`|
| 任务状态聚合 | `zentao task --executionID=<id> --browseType=all --pick=status --page=<页码> --recPerPage=100 --format=json` |
| 产品下需求概览 | `zentao story --product=<id> --browseType=allstory --pick=id,pri,stage,plan --page=<页码> --recPerPage=100 --format=json` |
| 产品下 Bug 概览 | `zentao bug --product=<id> --browseType=all --pick=id,severity,pri,status --page=<页码> --recPerPage=100 --format=json` |
| 即将 / 最近发布 | `zentao release --productID=<id> --pick=id,name,date,status` |
Expand Down
17 changes: 10 additions & 7 deletions src/modules/executor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { request } from 'zentao-api';
import type { ResponseData } from 'zentao-api';
import type { ZentaoClient } from '../api/index.js';
import { mapSdkError } from '../errors.js';
import type {
Expand Down Expand Up @@ -105,23 +106,25 @@ export async function executeModuleCommand(
};
}

const pager: ListPagerInfo | undefined = response.pager
const normalized = response as ResponseData<unknown>;

const pager: ListPagerInfo | undefined = normalized.pager
? {
pageID: response.pager.page,
recPerPage: response.pager.recPerPage,
recTotal: response.pager.total,
pageID: normalized.pager.page,
recPerPage: normalized.pager.recPerPage,
recTotal: normalized.pager.total,
}
: undefined;

if (action.type === 'list') {
const data = (Array.isArray(response.data) ? response.data : []) as Record<string, unknown>[];
const data = (Array.isArray(normalized.data) ? normalized.data : []) as Record<string, unknown>[];
return { action, data, rawResponse: response, pager, fields, isList: true };
}

if (action.type === 'get') {
const data = (response.data ?? {}) as Record<string, unknown>;
const data = (normalized.data ?? {}) as Record<string, unknown>;
return { action, data, rawResponse: response, fields, isList: false };
}

return { action, data: response.data, rawResponse: response, fields, isList: false };
return { action, data: normalized.data, rawResponse: response, fields, isList: false };
}
2 changes: 1 addition & 1 deletion tests/modules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('module registry (zentao-api)', () => {
expect(names).toContain('task');
expect(names).toContain('story');
expect(names).toContain('user');
expect(names.length).toBe(19);
expect(names.length).toBeGreaterThanOrEqual(19);
});

test('getAllModules returns every registered module', () => {
Expand Down
8 changes: 4 additions & 4 deletions tests/skill-contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ describe('bundled Skill command contracts', () => {
expect(result.stdout).not.toContain('--all');
expect(result.stdout).toContain('zentao bug <操作> --help');

const unpaged = await runCliWithoutAuth(['release', '--help']);
expect(unpaged.exitCode).toBe(0);
expect(unpaged.stdout).not.toContain('--page <number>');
expect(unpaged.stdout).not.toContain('--recPerPage <number>');
const release = await runCliWithoutAuth(['release', '--help']);
expect(release.exitCode).toBe(0);
expect(release.stdout).toContain('--page <number>');
expect(release.stdout).toContain('--recPerPage <number>');

const fixedScope = await runCliWithoutAuth(['task', 'list', '--help']);
expect(fixedScope.exitCode).toBe(0);
Expand Down