@wwkit/harness 1.0.46 → 1.0.47
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/package.json +1 -1
- package/skills/pea/SKILL.md +14 -4
- package/skills/pea/references/tpl-prd/epic.md +7 -2
- package/skills/peago/SKILL.md +10 -2
- package/skills/peago/references/cleancode/languages/py-ut.md +88 -0
- package/skills/peago/references/cleancode/languages/py.md +222 -0
- package/skills/{blame-cleancode/references → peago/references/cleancode}/report_template.md +45 -12
- package/skills/peago/references/cleancode/rules-ut.md +133 -0
- package/skills/peago/references/cleancode/rules.md +477 -0
- package/skills/peago/references/cleancode/spec.md +204 -0
- package/skills/peago/references/lint/spec.md +160 -0
- package/skills/peago/references/test/languages/js.md +74 -0
- package/skills/peago/references/test/languages/py.md +68 -0
- package/skills/peago/references/test/spec.md +201 -0
- package/skills/peago/references/translate/scripts/check-paragraphs.js +71 -0
- package/skills/peago/references/translate/scripts/check-structure.js +118 -0
- package/skills/peago/references/translate/scripts/chunk-bilingual.js +123 -0
- package/skills/peago/references/translate/scripts/chunk-text.js +150 -0
- package/skills/peago/references/translate/scripts/clean-text.js +121 -0
- package/skills/peago/references/translate/scripts/count-terms.js +54 -0
- package/skills/peago/references/translate/scripts/extract-vision.js +267 -0
- package/skills/peago/references/translate/scripts/md-to-docx.js +381 -0
- package/skills/peago/references/translate/scripts/merge-format.js +110 -0
- package/skills/peago/references/translate/scripts/merge-pages.js +202 -0
- package/skills/peago/references/translate/scripts/merge-result.js +113 -0
- package/skills/peago/references/translate/scripts/verify-chunk.js +200 -0
- package/skills/peago/references/translate/spec.md +14 -6
- package/skills/better-class/SKILL.md +0 -48
- package/skills/better-class/references/planning_spec.md +0 -91
- package/skills/better-class/references/report-template.md +0 -65
- package/skills/better-class/references/sprint_for_eo.md +0 -83
- package/skills/better-class/references/sprint_for_report.md +0 -22
- package/skills/better-class/references/subagent-prompt.md +0 -47
- package/skills/better-class/references/workflow.md +0 -75
- package/skills/better-class/scripts/check-syntax.js +0 -112
- package/skills/better-class/scripts/check_input_vars.js +0 -52
- package/skills/better-class/scripts/init.js +0 -88
- package/skills/better-class/scripts/resolve_run_vars.js +0 -96
- package/skills/better-class/scripts/run-tests.js +0 -108
- package/skills/better-cleancode/SKILL.md +0 -157
- package/skills/better-ut/SKILL.md +0 -236
- package/skills/blame-class/SKILL.md +0 -78
- package/skills/blame-class/references/report_template.md +0 -98
- package/skills/blame-class/references/rules.md +0 -40
- package/skills/blame-cleancode/SKILL.md +0 -105
- package/skills/blame-cleancode/plan.md +0 -1408
- package/skills/blame-cleancode/references/rules.md +0 -630
- package/skills/blame-ut/SKILL.md +0 -113
- package/skills/blame-ut/references/report_template.md +0 -102
- package/skills/blame-ut/references/rules.md +0 -197
- package/skills/convert-files/SKILL.md +0 -37
- package/skills/convert-files/package.json +0 -11
- package/skills/convert-files/references/sprint_for_conversion.md +0 -17
- package/skills/convert-files/scripts/check_input_vars.js +0 -54
- package/skills/convert-files/scripts/convert.js +0 -331
- package/skills/convert-files/scripts/init.js +0 -75
- package/skills/convert-files/scripts/resolve_run_vars.js +0 -124
- package/skills/create-ppt/SKILL.md +0 -47
- package/skills/create-ppt/package.json +0 -9
- package/skills/create-ppt/references/ppt-styles.md +0 -287
- package/skills/create-ppt/references/sprint_for_ppt_generation.md +0 -81
- package/skills/create-ppt/references/sprint_for_source_discovery.md +0 -18
- package/skills/create-ppt/scripts/check_input_vars.js +0 -57
- package/skills/create-ppt/scripts/find-source-files.js +0 -98
- package/skills/create-ppt/scripts/init.js +0 -96
- package/skills/create-ppt/scripts/md-to-pptx.js +0 -579
- package/skills/create-ppt/scripts/resolve_run_vars.js +0 -91
- package/skills/jstest/SKILL.md +0 -561
- package/skills/jstest/references/case-create.md +0 -327
- package/skills/jstest/references/case-fix.md +0 -273
- package/skills/jstest/references/config.md +0 -148
- package/skills/jstest/references/coverage-analyze.md +0 -247
- package/skills/jstest/references/env-ensure.md +0 -210
- package/skills/jstest/references/execute.md +0 -168
- package/skills/jstest/references/sample.md +0 -166
- package/skills/jstest/references/scoring-rules.md +0 -75
- package/skills/jstest/references/suitability-check.md +0 -232
- package/skills/jstest/references/test-standards.md +0 -288
- package/skills/lint/SKILL.md +0 -440
- package/skills/lint/references/ai-fix.md +0 -138
- package/skills/lint/references/config-setup.md +0 -103
- package/skills/lint/references/config.md +0 -65
- package/skills/lint/references/env-ensure.md +0 -89
- package/skills/lint/references/language-detect.md +0 -76
- package/skills/lint/references/rules-analyze.md +0 -126
- package/skills/lint/references/suitability-check.md +0 -82
- package/skills/lint/references/tool-fix.md +0 -91
- package/skills/peago/references/extract/baseline.md +0 -17
- package/skills/peago/references/extract/spec.md +0 -117
- package/skills/pytest/SKILL.md +0 -556
- package/skills/pytest/references/case-create.md +0 -325
- package/skills/pytest/references/case-fix.md +0 -272
- package/skills/pytest/references/config.md +0 -145
- package/skills/pytest/references/coverage-analyze.md +0 -224
- package/skills/pytest/references/env-ensure.md +0 -196
- package/skills/pytest/references/execute.md +0 -153
- package/skills/pytest/references/sample.md +0 -160
- package/skills/pytest/references/scoring-rules.md +0 -57
- package/skills/pytest/references/suitability-check.md +0 -221
- package/skills/pytest/references/test-standards.md +0 -244
- /package/skills/{lint/references → peago/references/lint}/languages/js.md +0 -0
- /package/skills/{lint/references → peago/references/lint}/languages/py.md +0 -0
- /package/skills/{lint/references → peago/references/lint/scripts}/detect-language.js +0 -0
- /package/skills/{jstest/references/src/jstest-sample → peago/references/test/sample-src/js}/Calculator.js +0 -0
- /package/skills/{jstest/references/src/jstest-sample → peago/references/test/sample-src/js}/ConfigManager.js +0 -0
- /package/skills/{jstest/references/src/jstest-sample → peago/references/test/sample-src/js}/FileProcessor.js +0 -0
- /package/skills/{jstest/references/src/jstest-sample → peago/references/test/sample-src/js}/OrderService.js +0 -0
- /package/skills/{jstest/references/src/jstest-sample → peago/references/test/sample-src/js}/TokenGenerator.js +0 -0
- /package/skills/{jstest/references/src/jstest-sample → peago/references/test/sample-src/js}/UserService.js +0 -0
- /package/skills/{jstest/references/src/jstest-sample → peago/references/test/sample-src/js}/index.js +0 -0
- /package/skills/{pytest/references/src/pytest-sample → peago/references/test/sample-src/py}/Calculator.py +0 -0
- /package/skills/{pytest/references/src/pytest-sample → peago/references/test/sample-src/py}/ConfigManager.py +0 -0
- /package/skills/{pytest/references/src/pytest-sample → peago/references/test/sample-src/py}/FileProcessor.py +0 -0
- /package/skills/{pytest/references/src/pytest-sample → peago/references/test/sample-src/py}/OrderService.py +0 -0
- /package/skills/{pytest/references/src/pytest-sample → peago/references/test/sample-src/py}/TokenGenerator.py +0 -0
- /package/skills/{pytest/references/src/pytest-sample → peago/references/test/sample-src/py}/UserService.py +0 -0
- /package/skills/{pytest/references/src/pytest-sample → peago/references/test/sample-src/py}/__init__.py +0 -0
|
@@ -44,11 +44,14 @@
|
|
|
44
44
|
|
|
45
45
|
| # | 要求 | 对应 AC |
|
|
46
46
|
|---|---|---|
|
|
47
|
-
| R1 |
|
|
47
|
+
| R1 | 单次调用完成全流程:源文本获取 → 清洗 → 分块 → 术语表 → 逐块翻译 → 聚合 → 结构扫描(R15)→ 格式重建 → docx → 全局终检,无需人工分步 | AC-1 |
|
|
48
|
+
| R1a | **源文本获取**:文本输入(`.txt`/`.md`/`.markdown`)直接读取;PDF 与图片输入用参考脚本 `references/translate/scripts/extract-vision.js` 提取为纯文本(三个独立入口按输入类型选用:`extractPdfText` PDF 文本层直接抽取 / `extractImageText` 图片视觉转录 / `extractPdfVision` 扫描 PDF 逐页渲染转录;组合入口 `extractAny` 自动路由),页间以 `\f` 分隔(R1b 的接缝合并依赖页边界) | AC-1 |
|
|
49
|
+
| R1b | **清洗**:先 `clean-text.js`(字符级噪声清理,保留 `\f` 页标记)后 `merge-pages.js`(页级接缝合并与页眉清理),必须执行 `merge-pages.js` 的接缝合并——直接把 `\f` 替换为空行而不合并接缝会留下断段(成品交错缺陷的实测根因);禁止用 LLM 阅读全文清洗 | AC-11 |
|
|
50
|
+
| R1c | **分块**:见 R3 | AC-4 |
|
|
48
51
|
| R2 | 支持 `.pdf`/`.txt`/`.md`/`.markdown`;空文件跳过;不存在或不支持的输入以明确错误终止 | AC-8 |
|
|
49
|
-
| R3 |
|
|
52
|
+
| R3 | 分块对中文与西文一致可预期,单块规模不逼近模型输出上限(分块算法参考脚本 `references/translate/scripts/chunk-text.js`);块尾段落未完时追加 `[CONT]` 拼接标记,翻译时双语各保留一个,校验其配对;跨块合并按语言分别配对——原文断段与其续段拼为完整原文段、译文断段与其续段拼为完整译文段,双语段不得交错;`[CONT]` 是过程标记,聚合交付时移除,最终产物不得残留 | AC-2 / AC-2a / AC-4 |
|
|
50
53
|
| R4 | 单块失败可隔离,根因可从运行记录定位 | AC-5 |
|
|
51
|
-
| R5 |
|
|
54
|
+
| R5 | 每块产出前经过自动校验(校验项参考脚本 `references/translate/scripts/verify-chunk.js`:段落对齐、脚注、`[CONT]`、术语),不合格即失败并进入诊断;重试上限 3,超限补处理。块内每个原文段(含脚注段)必须有对应译文段——块以未配对的原文段结尾时校验不通过,不得让"原文孤儿段"进入聚合 | AC-5 |
|
|
52
55
|
| R6 | 并发 ≤5;任务返回即合并,无批末同步等待 | AC-6 |
|
|
53
56
|
| R7 | 任一块内容被模型完整输出的次数 ≤2(翻译产出、格式加标记);校验参数以文件引用或管道传递,不得把全文再写入输出 | AC-3 |
|
|
54
57
|
| R8 | 进度状态持久化在磁盘上的人可读文件,不依赖会话内存;中断后可恢复到"待翻译/待格式化/待发布" | AC-7 |
|
|
@@ -56,8 +59,8 @@
|
|
|
56
59
|
| R10 | 术语表按逻辑文档从其全文提取、条目 ≤300;每块翻译遵循术语表,校验覆盖术语一致性 | AC-9 |
|
|
57
60
|
| R11 | 多逻辑文档按自然排序逐个处理;全局终检覆盖跨逻辑文档术语一致性与章节衔接 | AC-9 |
|
|
58
61
|
| R12 | 格式重建基于双语对照译文添加 Markdown 标记(标题/粗体/斜体/引用/列表/链接),不改动译文内容 | AC-2 |
|
|
59
|
-
| R13 | 非文本输入(无文本层 PDF):在 subagent 内调用 skill peago(基于 `references/extract` spec)完成文本提取,取得源文本后进入正常流程 | AC-1 / AC-2 |
|
|
60
62
|
| R14 | 翻译单元为逻辑文档而非源文件:准备阶段将输入文件分组为 1..N 个逻辑文档——判据为文件名连续编号模式(partN/chapterN 等)、内容页码衔接、章节连续性、标题一致性;用户显式声明优先。同组文件按序合并为单一源文本,分块、术语表、进度、续跑均以逻辑文档为单位;判定结果与依据记入工作目录 | AC-10 |
|
|
63
|
+
| R15 | 聚合产物结构扫描:格式重建与 docx 生成前,对聚合后的 `-tsl.md` 执行机械扫描(参考脚本 `references/translate/scripts/check-structure.js`)——①交错形态(原文断/译文断/原文续/译文续四段窗口);②孤儿段(连续原文段无译文间隔);③`[CONT]` 残留。检出 >0 即 FAIL,修复后复扫至 0 才放行;扫描结果记入 `-review.md` | AC-12 |
|
|
61
64
|
|
|
62
65
|
### 3.2 Out of Scope(不包含的功能 / 范围) `[可选]`
|
|
63
66
|
|
|
@@ -72,7 +75,7 @@
|
|
|
72
75
|
|
|
73
76
|
- [ ] **AC-1(产物完整)**:Given `{{input}}` 含至少 1 个支持格式的非空文件, When 翻译完成, Then `{{output_dir}}` 下每个逻辑文档都有第 2 节所列四件产物且非空(docx 允许失败清单替代),并有 `global-review.md`;全部为 UTF-8。
|
|
74
77
|
- [ ] **AC-2(译文质量)**:Given 任一逻辑文档, When 抽检 ≥3 块, Then 双语对照格式为原文段在前、译文段在后、空行分隔,逐段对应、无整段缺失;脚注 `[^N]` 保留;术语译法与术语表一致。
|
|
75
|
-
- [ ] **AC-2a(拼接正确)**:Given 存在 `[CONT]` 拼接点的逻辑文档, When 检查每个拼接点, Then 原文断句与其续文直接相连且语义连贯、译文断句与其续文直接相连且语义连贯,双语段无交错;最终产物(`-tsl.md`、`-tsl-fmt.md`、docx)中 `[CONT]` 残留数为 0
|
|
78
|
+
- [ ] **AC-2a(拼接正确)**:Given 存在 `[CONT]` 拼接点的逻辑文档, When 检查每个拼接点, Then 原文断句与其续文直接相连且语义连贯、译文断句与其续文直接相连且语义连贯,双语段无交错;最终产物(`-tsl.md`、`-tsl-fmt.md`、docx)中 `[CONT]` 残留数为 0。
|
|
76
79
|
- [ ] **AC-3(成本)**:Given 完整运行, When 统计, Then 每源词的 LLM 输出 token 当量 ≤11(双语产物形态的物理下限约 8-11,口径见 `references/translate/baseline.md` 第 1 节),且任一块内容被模型完整输出的次数 ≤2。
|
|
77
80
|
- [ ] **AC-4(分块)**:Given 20 页中文 PDF, When 分块完成, Then 块数 ≥2;Given 10 万词英文, When 分块完成, Then 块数 ≥15;块数、进度行数、续跑起点三者一致。
|
|
78
81
|
- [ ] **AC-5(门禁与降级)**:Given 某块产出不合格或格式重建失败, When 处理, Then 不合格块被判失败、按可定位根因诊断后重试(禁止同因反复重试),重试达上限(3)后补处理;仍失败的块原文段照常写入最终文档、译文段以错误信息提示文本占位,最终无缺块;格式重建重试达上限仍失败时,`-tsl-fmt.md` 由未格式化双语降级生成并在 `-review.md` 记录原因;校验与格式重建均为必经步骤。
|
|
@@ -81,6 +84,8 @@
|
|
|
81
84
|
- [ ] **AC-8(输入处理)**:Given 目录同时含支持格式、空文件与不支持扩展名, When 运行, Then 支持的格式被处理、空文件跳过、不支持的扩展名以明确错误信息终止且不产出残缺产物。
|
|
82
85
|
- [ ] **AC-9(术语与跨文档)**:Given 含多个逻辑文档的输入, When 完成, Then 每个逻辑文档术语表条目 ≤300 且全部来自其源文本;各逻辑文档译文遵循各自术语表;`global-review.md` 记录跨逻辑文档术语一致性与章节衔接检查结果。
|
|
83
86
|
- [ ] **AC-10(文档归属判定)**:Given 同一本书分拆为多个 PDF 的目录(如 part1..partN 连续编号), When 完成, Then 判定为单一逻辑文档,产出一套四件产物,内容按 part 顺序无缝衔接;Given 各自独立的多个 PDF, When 完成, Then 各自独立成套产物;判定结果与依据在工作目录可追溯。
|
|
87
|
+
- [ ] **AC-11(清洗质量)**:Given 含跨页段落与页眉页脚的源文档, When 清洗完成, Then 跨页段落合并为完整段落(含断词合并)、页眉页脚移除、无因分页产生的伪段边界;最终产物中不存在"原文前半/译文前半/原文后半/译文后半"交错形态。
|
|
88
|
+
- [ ] **AC-12(产物结构)**:Given 聚合完成的 `-tsl.md`, When 结构扫描(`check-structure.js`), Then 交错形态 0、孤儿段 0、`[CONT]` 残留 0,且在格式重建与 docx 生成之前完成;扫描结果记入 `-review.md`。
|
|
84
89
|
|
|
85
90
|
---
|
|
86
91
|
|
|
@@ -100,7 +105,9 @@
|
|
|
100
105
|
| Type | Name | Version | Usage | Fallback |
|
|
101
106
|
|---|---|---|---|---|
|
|
102
107
|
| package | `markdown-docx` | `^1.7.1` | Markdown → docx | 转换失败不影响翻译交付,输出失败清单 |
|
|
103
|
-
|
|
|
108
|
+
| tool | `extract-vision.js`(`references/translate/scripts/`) | - | PDF/图片 → 纯文本。用法:`node extract-vision.js "<源文件>" "<输出.txt>"`;文本层自动判定,无文本层走视觉转录(端点/模型可用环境变量 `EXTRACT_VL_ENDPOINT`/`EXTRACT_VL_MODEL` 覆盖) | 提取失败(失败页 >0)时该文件终止并报错,不产出残缺产物 |
|
|
109
|
+
| model | `codemate/Qwen3.6-27B-VL`(视觉转录,OpenAI 兼容 API) | - | 无文本层 PDF 的页面图像 → 文本 | 端点不可达时该文件终止并报错 |
|
|
110
|
+
| tool | `pdftoppm`/`pdftotext`/`pdfinfo`(poppler-utils,Linux) | 系统自带 | 页数读取 / 文本层判定 / 页面渲染 | 缺失时该文件终止并报错 |
|
|
104
111
|
|
|
105
112
|
---
|
|
106
113
|
|
|
@@ -109,6 +116,7 @@
|
|
|
109
116
|
| # | 类型 | 路径 / 来源 | 说明 |
|
|
110
117
|
|---|---|---|---|
|
|
111
118
|
| 1 | 度量口径 | `references/translate/baseline.md` | token 当量与输出次数的统计口径、分块阈值依据、护栏 |
|
|
119
|
+
| 2 | 参考脚本 | `references/translate/scripts/` | 各机械环节的参考实现(提取 `extract-vision.js`、清洗 `merge-pages.js`/`clean-text.js`、分块 `chunk-text.js`、块校验 `verify-chunk.js`、产物结构扫描 `check-structure.js`、合并 `merge-result.js`/`merge-format.js`、术语 `count-terms.js`、docx `md-to-docx.js`、段落检查 `check-paragraphs.js`、双语分块 `chunk-bilingual.js`);机械环节优先复用/改造这些脚本 |
|
|
112
120
|
|
|
113
121
|
---
|
|
114
122
|
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: better-class
|
|
3
|
-
description: "Use when optimizing a single Python class for both Clean Code and unit-test quality, including reference-safe renames, dependency injection, complexity reduction, and test coverage fixes. Triggers on: better-class, Python class refactor, Clean Code optimization, unit-test quality remediation, 类优化, Python 重构, 代码质量整改, 评审后优化."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
作为 Scrum 开发者,我想要优化单个 Python 类文件的 Clean Code 与单元测试质量,以便使综合评分达标或达到最大迭代次数。using the **fixed-sequence Sprint workflow** (seq)。
|
|
7
|
-
|
|
8
|
-
# Product Goal
|
|
9
|
-
|
|
10
|
-
优化单个 Python 类文件,使其 Clean Code 与单元测试质量评分均达标(综合 ≥ 80/100)或达到最大迭代次数。
|
|
11
|
-
|
|
12
|
-
# Extract Variables
|
|
13
|
-
|
|
14
|
-
Extract input variables from the context:
|
|
15
|
-
|
|
16
|
-
| Variable | Type | Required | Description |
|
|
17
|
-
|---|---|---|---|
|
|
18
|
-
| `class_path` | string | ✅ | 目标 Python 类文件路径 |
|
|
19
|
-
| `report_dir` | string | ❌ | 报告输出目录,默认与 `class_path` 同目录 |
|
|
20
|
-
| `max_iterations` | integer | ❌ | 最大迭代次数,默认且上限为 `5` |
|
|
21
|
-
| `force` | boolean | ❌ | clear `{{run_dir}}` before running, default `true` |
|
|
22
|
-
|
|
23
|
-
# Environment Initialization
|
|
24
|
-
|
|
25
|
-
1. Run `node scripts/init.js '{{class_path}}' '{{report_dir}}' {{force}}` to validate input, resolve variables, clear `{{run_dir}}` and check npm dependencies.
|
|
26
|
-
2. Read **Sprint Standards** `{{shared_dir}}/references/sprint_standards.md`.
|
|
27
|
-
|
|
28
|
-
# Product Increment
|
|
29
|
-
|
|
30
|
-
| Product | Type | Description | DoD |
|
|
31
|
-
|---|---|---|---|
|
|
32
|
-
| `{{class_path}}` | file | 优化后的 Python 类文件 | `node '{{skill_dir}}/scripts/check-syntax.js' '{{class_path}}'` 退出码 0 |
|
|
33
|
-
| `{{report_dir}}/{{run_name}}_opt_report.md` | file | 优化报告 | 文件存在且非空;含 `{{skill_dir}}/references/report-template.md` 全部 H2 章节 |
|
|
34
|
-
|
|
35
|
-
# Sprint Backlogs
|
|
36
|
-
|
|
37
|
-
| Sprint Name | Backlog File | Description |
|
|
38
|
-
|---|---|---|
|
|
39
|
-
| Sprint for planning | `{{shared_dir}}/references/sprint_for_planning.md` | dynamically plan the following Sprint Backlogs |
|
|
40
|
-
| Sprints from planning | `{{run_dir}}/release_plan.md` | generated by planning, execute in order |
|
|
41
|
-
|
|
42
|
-
# Plan Now!
|
|
43
|
-
|
|
44
|
-
Read **Sprint for planning** `{{shared_dir}}/references/sprint_for_planning.md`, follow **Sprint One Workflow** `{{shared_dir}}/references/run/run_sprint_one.md`, then *plan*.
|
|
45
|
-
|
|
46
|
-
# Sprint Now!
|
|
47
|
-
|
|
48
|
-
Read all **Sprint Backlogs** from `{{run_dir}}/release_plan.md`, follow **Sprint Workflow** `{{shared_dir}}/references/run/run_sprint_loop.md`, then *sprint*.
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# 资源与约束
|
|
2
|
-
|
|
3
|
-
## C. 分解策略
|
|
4
|
-
|
|
5
|
-
- 分解维度: 按迭代阶段。评估-优化循环作为一个 Sprint(使用 sprint-peo 模板),最终报告作为独立 Sprint(使用 sprint-seq 模板)
|
|
6
|
-
- 切分依据: 评估-优化循环可由一个 Sprint(含 loop 的 subagent Sprint)完整交付;最终报告可由主 agent 独立交付
|
|
7
|
-
- 目标结构判定: improve 模式,按 sprint-workflow-menu.md 判定特征识别当前结构,按功能特征判定目标流程类型为 peo
|
|
8
|
-
|
|
9
|
-
## D. 依赖模型
|
|
10
|
-
|
|
11
|
-
- 依赖链:
|
|
12
|
-
- Sprint for planning → 产出 `release_plan.md` → 全部下游 Sprint 依赖
|
|
13
|
-
- 评估-优化 Sprint → 产出 `release_progress.csv`(含每轮得分)→ 最终报告 Sprint 依赖
|
|
14
|
-
- 最终报告 Sprint → 产出 `{{report_dir}}/{{run_name}}_opt_report.md`(Product Increment)
|
|
15
|
-
- 可并行: 无——评估-优化循环内轮次间串行依赖(每轮依赖上一轮结果)
|
|
16
|
-
- 顺序约束: 规划 → 评估-优化循环 → 最终报告
|
|
17
|
-
|
|
18
|
-
## E. 资源清单
|
|
19
|
-
|
|
20
|
-
| 类型 | 路径 | 说明 | 加载条件 |
|
|
21
|
-
|---|---|---|---|
|
|
22
|
-
| 工具 | `blame-cleancode`(skill 工具) | Clean Code 评分器(0-80) | 每轮评估调用 |
|
|
23
|
-
| 工具 | `blame-ut`(skill 工具) | 单元测试评分器(0-20) | 每轮评估调用 |
|
|
24
|
-
| 规则 | `../blame-cleancode/references/rules.md` | Clean Code 评分规则 | 优化 subagent 读取 |
|
|
25
|
-
| 规则 | `../blame-ut/references/rules.md` | 单元测试评分规则 | 优化 subagent 读取 |
|
|
26
|
-
| 技能 | `../better-cleancode/SKILL.md` | Clean Code 优化技能 | 优化 subagent 调用 |
|
|
27
|
-
| 技能 | `../better-ut/SKILL.md` | 单元测试优化技能 | 优化 subagent 调用 |
|
|
28
|
-
| 脚本 | `{{skill_dir}}/scripts/check-syntax.js` | Python 语法检查 | 每轮优化后验证 |
|
|
29
|
-
| 脚本 | `{{skill_dir}}/scripts/run-tests.js` | pytest 测试运行 | 每轮优化后验证 |
|
|
30
|
-
| 参考 | `{{skill_dir}}/references/workflow.md` | 门禁决策表、失败处理、引用同步检查清单、Common Mistakes | 优化 subagent 读取 |
|
|
31
|
-
| 模板 | `{{skill_dir}}/references/report-template.md` | 优化报告模板 | 报告 Sprint 读取 |
|
|
32
|
-
|
|
33
|
-
## F. 约束规范
|
|
34
|
-
|
|
35
|
-
- 评分主体: 主 agent 直接调用 `blame-cleancode` 与 `blame-ut` 评分;禁止让 subagent 评分
|
|
36
|
-
- 优化依据: 优化 subagent 必须按评估扣分项逐条修改,不得自行臆断
|
|
37
|
-
- 返回摘要: 优化 subagent 完成后返回修改摘要(改了哪些文件、每个文件改了什么、与扣分项的对应关系)
|
|
38
|
-
- 通过标准: Clean Code ≥ 64/80、单元测试 ≥ 16/20、综合 ≥ 80/100
|
|
39
|
-
- 迭代约束: 最大迭代次数 5 次;单轮内测试修复尝试最多 3 次;每轮必须消除至少一个扣分项
|
|
40
|
-
- 规则引用: 以路径引用规则 / 模板,禁止内联
|
|
41
|
-
- 交付前复核: 重算基线/最终得分与报告一致
|
|
42
|
-
|
|
43
|
-
## G. 聚合规则
|
|
44
|
-
|
|
45
|
-
- 评分: `blame-cleancode`(0-80)+ `blame-ut`(0-20)= 综合总分(0-100)
|
|
46
|
-
- 轮次聚合: 基线 + 每轮得分 → 最终得分
|
|
47
|
-
- 终态: `completed`(达标:Clean Code ≥ 64、单元测试 ≥ 16、综合 ≥ 80)/ `NOT_REACHED`(`round >= max_iterations` 未达标)
|
|
48
|
-
|
|
49
|
-
## H. 输出结构
|
|
50
|
-
|
|
51
|
-
`{{report_dir}}/{{run_name}}_opt_report.md` 按 `{{skill_dir}}/references/report-template.md` 模板生成,固定包含:评分轨迹、优化项汇总、修改文件清单、引用同步记录、未解决项、最终测试结果。
|
|
52
|
-
|
|
53
|
-
## I. 自检判据
|
|
54
|
-
|
|
55
|
-
| # | 判据 | 结果 | 证据 |
|
|
56
|
-
|---|---|---|---|
|
|
57
|
-
| 1 | 每个 Sprint 的 Backlog 符合模板规范 | | |
|
|
58
|
-
| 2 | 每个 Item 可执行,有明确动作对象与可验证 DoD | | |
|
|
59
|
-
| 3 | 全部产物路径都在 `{{run_dir}}` 或目标项目内 | | |
|
|
60
|
-
| 4 | 规划约束全部被满足 | | |
|
|
61
|
-
| 5 | Sprint 数量与顺序与分解表一致 | | |
|
|
62
|
-
| 6 | Sprints 产物包含Product Increment | | |
|
|
63
|
-
| 7 | 使用 subagent 时,其 prompt 已附带变量表,且覆盖 subagent 引用文件所需变量 | | |
|
|
64
|
-
| 8 | 使用 subagent 时,含失败路径 Item | | |
|
|
65
|
-
| 9 | 基线评分已记录 | | |
|
|
66
|
-
| 10 | 每轮优化都有对应的评估扣分项 | | |
|
|
67
|
-
| 11 | 终止条件已记录(达标 / 轮次耗尽) | | |
|
|
68
|
-
| 12 | 通过标准与迭代约束已在约束规范中定义 | | |
|
|
69
|
-
|
|
70
|
-
## J. 失败与降级
|
|
71
|
-
|
|
72
|
-
### J1. Sprint 步骤失败
|
|
73
|
-
|
|
74
|
-
| 失败场景 | 判定条件 | 重试 | 降级动作 | 错误传播 |
|
|
75
|
-
|---|---|---|---|---|
|
|
76
|
-
| 评估失败 | blame-cleancode/blame-ut 返回异常或无得分 | 1 次 | 当前轮标注 `评估失败`,保留上一轮得分 | 不阻塞优化 Sprint |
|
|
77
|
-
| 目标不可读 | `{{class_path}}` 不存在 | 0 次 | 标注 `目标不存在`,短路到最终报告 | 阻塞评估-优化循环 |
|
|
78
|
-
| 数值复核不通过 | 报告得分与 release_progress.csv 不一致 | 1 次 | 修正后重试 | 不阻塞交付 |
|
|
79
|
-
|
|
80
|
-
### J2. Subagent 失败
|
|
81
|
-
|
|
82
|
-
| 判定条件 | 说明 | 重试 | 降级动作 | 错误传播 |
|
|
83
|
-
|---|---|---|---|---|
|
|
84
|
-
| BLOCKED | subagent 无法启动或被阻塞 | 2 次 | 跳过本轮优化,保留上一轮结果 | 不阻塞下一轮评估 |
|
|
85
|
-
| NEEDS_CONTEXT | 变量表不完整 | 2 次(补充变量后重新派发) | 跳过本轮优化 | 不阻塞下一轮评估 |
|
|
86
|
-
| 结果不完整 | subagent 未修改所有扣分项 | 2 次(补充指令后重新派发) | 保留已修改部分,未修改项标注 `未修复` | 不阻塞下一轮评估 |
|
|
87
|
-
|
|
88
|
-
### J3. 全局规则
|
|
89
|
-
|
|
90
|
-
- 轮次耗尽未达标 → Product Increment仍交付报告,终态标注 `NOT_REACHED`
|
|
91
|
-
- 降级产物在报告对应章节显式标注(`评估失败` / `未修复` / `数值不一致`),禁止填入虚假分数
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# better-class 优化报告模板
|
|
2
|
-
|
|
3
|
-
将本文件复制为 `{{report_dir}}/{{run_name}}_opt_report.md`,替换所有 `{{...}}` 占位符。章节不可删除;无内容时填写"无"。
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# {{ClassName}} 优化报告
|
|
8
|
-
|
|
9
|
-
> 文件路径:`{{class_path}}`
|
|
10
|
-
> 优化时间:{{时间}}
|
|
11
|
-
> 迭代次数:{{N}} 次
|
|
12
|
-
> 最终状态:达标 / 未达标(未达标时注明"已达最大迭代次数")
|
|
13
|
-
|
|
14
|
-
## 评分轨迹
|
|
15
|
-
|
|
16
|
-
| 迭代轮次 | Clean Code | 单元测试 | 总分 | 状态 |
|
|
17
|
-
|----------|-----------|---------|------|------|
|
|
18
|
-
| 初始 | {{分数}}/80 | {{分数}}/20 | {{分数}}/100 | 开始 |
|
|
19
|
-
| 第 1 轮 | {{分数}}/80 | {{分数}}/20 | {{分数}}/100 | {{✓/✗}} |
|
|
20
|
-
| ... | ... | ... | ... | ... |
|
|
21
|
-
| 最终 | {{分数}}/80 | {{分数}}/20 | {{分数}}/100 | {{✓/✗}} |
|
|
22
|
-
|
|
23
|
-
## 优化项汇总
|
|
24
|
-
|
|
25
|
-
### Clean Code 优化
|
|
26
|
-
|
|
27
|
-
| 序号 | 优化项 | 位置 | 改动前 | 改动后 |
|
|
28
|
-
|------|--------|------|--------|--------|
|
|
29
|
-
| 1 | (如:类命名) | 第 X 行 | `old_name` | `NewName` |
|
|
30
|
-
| 2 | (如:类型注解) | 第 X 行 | 无注解 | `-> str \| None` |
|
|
31
|
-
| 3 | (如:方法拆分) | 第 X 行 | 50 行 | 拆分为 3 个方法 |
|
|
32
|
-
|
|
33
|
-
### 单元测试优化
|
|
34
|
-
|
|
35
|
-
| 序号 | 优化项 | 位置 | 改动前 | 改动后 |
|
|
36
|
-
|------|--------|------|--------|--------|
|
|
37
|
-
| 1 | (如:新增测试覆盖) | Test{{ClassName}}.py | 无测试 | 新增 3 个测试方法 |
|
|
38
|
-
| 2 | (如:依赖注入) | `__init__` | 硬编码 | 构造器注入 |
|
|
39
|
-
| 3 | (如:降低圈复杂度) | 第 X 行 | 嵌套 4 层 | early return |
|
|
40
|
-
|
|
41
|
-
## 修改文件清单
|
|
42
|
-
|
|
43
|
-
| 文件 | 修改类型 | 说明 |
|
|
44
|
-
|------|----------|------|
|
|
45
|
-
| `{{class_path}}` | 源文件 | {{改动摘要}} |
|
|
46
|
-
| `Test{{ClassName}}.py` | 测试文件 | {{改动摘要}} |
|
|
47
|
-
| `__init__.py` | 导入更新 | {{改动摘要}} |
|
|
48
|
-
|
|
49
|
-
## 引用同步记录
|
|
50
|
-
|
|
51
|
-
| 旧名称 | 新名称 | 同步位置 |
|
|
52
|
-
|--------|--------|----------|
|
|
53
|
-
| `old_method` | `new_method` | tests/: 3 处, src/: 2 处 |
|
|
54
|
-
|
|
55
|
-
## 未解决项
|
|
56
|
-
|
|
57
|
-
{{连续两轮未消除的扣分项;无则写"无"}}
|
|
58
|
-
|
|
59
|
-
## 最终测试结果
|
|
60
|
-
|
|
61
|
-
````
|
|
62
|
-
{{测试命令输出}}
|
|
63
|
-
````
|
|
64
|
-
|
|
65
|
-
**结果:全部 PASS / 有失败**
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
# Sprint Backlog for eo
|
|
2
|
-
|
|
3
|
-
## Sprint Goal
|
|
4
|
-
|
|
5
|
-
评估→优化→重评循环,直到 Clean Code ≥ 64/80、单元测试 ≥ 16/20、综合 ≥ 80/100,或达到最大迭代次数。
|
|
6
|
-
|
|
7
|
-
## Sprint Backlog Items
|
|
8
|
-
|
|
9
|
-
### Item1: Initialize progress
|
|
10
|
-
|
|
11
|
-
- Implement: Create `{{run_dir}}/release_progress.csv` and write:
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
round,cleancode_score,ut_score,total_score,status
|
|
15
|
-
0,0,0,0,pending
|
|
16
|
-
1,0,0,0,pending
|
|
17
|
-
...
|
|
18
|
-
{{max_iterations}},0,0,0,pending
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
- DoD check: `release_progress.csv` is created with all rounds in `pending` status
|
|
22
|
-
|
|
23
|
-
### Item2: Baseline evaluation
|
|
24
|
-
|
|
25
|
-
- Implement: Call `blame-cleancode` skill with `class_path={{class_path}}`, record Clean Code score and deduction items. Call `blame-ut` skill with `class_path={{class_path}}`, record unit test score and deduction items. Merge deduction items by score descending into a repair list. Write baseline scores to `{{run_dir}}/release_progress.csv` row `0`.
|
|
26
|
-
- DoD check: Three scores (cleancode_score, ut_score, total_score) recorded; repair list contains "deduction item / location / score" per line, sorted by score descending
|
|
27
|
-
|
|
28
|
-
### Item3: Check target [Loop body start]
|
|
29
|
-
|
|
30
|
-
- Short-circuit: skip to **Final output** when `cleancode_score >= 64` AND `ut_score >= 16` AND `total_score >= 80`
|
|
31
|
-
- Implement: Read current round's scores from `{{run_dir}}/release_progress.csv`
|
|
32
|
-
- DoD check: Scores checked against passing criteria (see `{{skill_dir}}/references/planning_spec.md` section F)
|
|
33
|
-
|
|
34
|
-
### Item4: Prepare subagent prompt
|
|
35
|
-
|
|
36
|
-
- Implement: Read the optimization subagent prompt from `{{skill_dir}}/references/subagent-prompt.md`. Read evaluation report's deduction items as optimization targets.
|
|
37
|
-
- DoD check: Subagent prompt and optimization targets are determined
|
|
38
|
-
|
|
39
|
-
### Item5: Prepare variable table
|
|
40
|
-
|
|
41
|
-
- Implement: Create the subagent variable table:
|
|
42
|
-
|
|
43
|
-
| Variable | Value | Description |
|
|
44
|
-
|---|---|---|
|
|
45
|
-
| `class_path` | `{{class_path}}` | target Python class file |
|
|
46
|
-
| `source_dir` | `{{source_dir}}` | class file directory |
|
|
47
|
-
| `report_dir` | `{{report_dir}}` | report output directory |
|
|
48
|
-
| `skill_dir` | `{{skill_dir}}` | this skill directory |
|
|
49
|
-
| `shared_dir` | `{{shared_dir}}` | shared resources directory |
|
|
50
|
-
| `run_dir` | `{{run_dir}}` | run data directory |
|
|
51
|
-
|
|
52
|
-
- DoD check: All variable values are determined
|
|
53
|
-
|
|
54
|
-
### Item6: Dispatch optimization subagent
|
|
55
|
-
|
|
56
|
-
- Implement: Dispatch one subagent (`subagent_type: "general"`, `description: "optimize round <n>"`, `prompt: <subagent prompt> \n Variable table: <variable table>`). Subagent reads evaluation deduction items and uses `better-cleancode` and `better-ut` skills to modify target files.
|
|
57
|
-
- DoD check: Subagent completed and returned modification summary
|
|
58
|
-
|
|
59
|
-
### Item7: Re-evaluate
|
|
60
|
-
|
|
61
|
-
- Implement: Call `blame-cleancode` and `blame-ut` skills again, update scores in `{{run_dir}}/release_progress.csv` for current round
|
|
62
|
-
- DoD check: New scores recorded
|
|
63
|
-
|
|
64
|
-
### Item8: Check rounds [Loop body end]
|
|
65
|
-
|
|
66
|
-
- Short-circuit: skip to **Final output** when `round >= max_iterations`
|
|
67
|
-
- Implement: Increment round counter
|
|
68
|
-
- DoD check: Round count checked against `max_iterations`
|
|
69
|
-
|
|
70
|
-
### Item9: Loop back [Loop back]
|
|
71
|
-
|
|
72
|
-
- Implement: Jump back to [Loop body start] for the next round
|
|
73
|
-
- DoD check: Control has returned to the loop body start
|
|
74
|
-
|
|
75
|
-
### Item10: Final output
|
|
76
|
-
|
|
77
|
-
- Implement: Record terminal status in `{{run_dir}}/release_progress.csv` (`completed` if target met, `NOT_REACHED` if max rounds exhausted)
|
|
78
|
-
- DoD check: Terminal status recorded
|
|
79
|
-
|
|
80
|
-
### Item11: Failure path
|
|
81
|
-
|
|
82
|
-
- Implement: When subagent returns BLOCKED / NEEDS_CONTEXT / 结果不完整, retry up to 2 times (see `{{skill_dir}}/references/planning_spec.md` section J2). After retries exhausted, skip current round optimization, preserve previous round results.
|
|
83
|
-
- DoD check: Failure handled per spec; current round marked with failure reason
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# Sprint Backlog for report
|
|
2
|
-
|
|
3
|
-
## Sprint Goal
|
|
4
|
-
|
|
5
|
-
基于评估-优化循环的进度数据,生成优化报告。
|
|
6
|
-
|
|
7
|
-
## Sprint Backlog Items
|
|
8
|
-
|
|
9
|
-
### Item1: Read progress data
|
|
10
|
-
|
|
11
|
-
- Implement: Read `{{run_dir}}/release_progress.csv` to get baseline score, each round's scores, final score, and terminal status.
|
|
12
|
-
- DoD check: All rounds' scores and terminal status are read
|
|
13
|
-
|
|
14
|
-
### Item2: Generate report
|
|
15
|
-
|
|
16
|
-
- Implement: Read `{{skill_dir}}/references/report-template.md`. Write `{{report_dir}}/{{run_name}}_opt_report.md`, replacing all placeholders with actual data from release_progress.csv.
|
|
17
|
-
- DoD check: Report file exists and is non-empty; contains all H2 sections from template
|
|
18
|
-
|
|
19
|
-
### Item3: Verify report
|
|
20
|
-
|
|
21
|
-
- Implement: Verify report contains all template sections; verify final test results section contains actual test output; verify scores in report match release_progress.csv.
|
|
22
|
-
- DoD check: Report DoD met (see `# Product Increment` in SKILL.md)
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
作为 Scrum 开发者,我想要按评估报告修复目标 Python 类文件,以便提升 Clean Code 与单元测试质量评分。
|
|
2
|
-
|
|
3
|
-
## Business Rules
|
|
4
|
-
|
|
5
|
-
| ID | Category | Rule |
|
|
6
|
-
|---|---|---|
|
|
7
|
-
| R1 | scoring | 优化依据:必须按评估报告的扣分项逐条修改,不得自行臆断 |
|
|
8
|
-
| R2 | references | 规则以路径引用,禁止内联规则内容 |
|
|
9
|
-
| R3 | no-fetch | 禁止网络请求 |
|
|
10
|
-
| R4 | single-source | 每个信息在唯一一处定义,其余文件引用不复述 |
|
|
11
|
-
|
|
12
|
-
## Sprint Goal
|
|
13
|
-
|
|
14
|
-
按评估报告的扣分项逐条修复目标 Python 类文件,使其 Clean Code 与单元测试质量评分提升。
|
|
15
|
-
|
|
16
|
-
## Sprint Increment
|
|
17
|
-
|
|
18
|
-
| Product | Type | Description | DoD |
|
|
19
|
-
|---|---|---|---|
|
|
20
|
-
| `{{class_path}}` | file | 优化后的 Python 类文件 | `node '{{skill_dir}}/scripts/check-syntax.js' '{{class_path}}'` 退出码 0 |
|
|
21
|
-
| 测试文件 | file | 优化后的测试文件 | `node '{{skill_dir}}/scripts/run-tests.js' <测试文件路径>` 退出码 0 |
|
|
22
|
-
|
|
23
|
-
## Sprint Backlog Items
|
|
24
|
-
|
|
25
|
-
### Item1: Clean Code 修复
|
|
26
|
-
|
|
27
|
-
- Implement: 使用 `better-cleancode` 技能,传入 `class_path` 与本轮 Clean Code 扣分项。优先处理高扣分项(-5、-3)。按 `{{skill_dir}}/references/workflow.md` 的「引用同步检查清单」同步重命名:`__init__.py` 导入/`__all__`、测试文件、其他源文件调用点。同步更新 docstring、注释中的旧标识符。
|
|
28
|
-
- DoD check: 对每个已重命名的旧标识符执行 grep 搜索,返回 0 处匹配;`node '{{skill_dir}}/scripts/check-syntax.js' <修改过的 .py 文件>` 退出码为 0
|
|
29
|
-
|
|
30
|
-
### Item2: 单元测试修复
|
|
31
|
-
|
|
32
|
-
- Implement: 使用 `better-ut` 技能,传入 `class_path`、测试文件路径与引用映射。修复覆盖、可测试性、依赖注入、圈复杂度问题。若 `better-ut` 修改了源文件接口,按引用映射表更新测试与其他引用点。
|
|
33
|
-
- DoD check: 测试文件存在且非空;测试文件中已重命名旧标识符的 grep 搜索结果为空
|
|
34
|
-
|
|
35
|
-
### Item3: 验证
|
|
36
|
-
|
|
37
|
-
- Short-circuit: skip when test file does not exist (mark as "需创建")
|
|
38
|
-
- Implement: 运行 `node '{{skill_dir}}/scripts/run-tests.js' <所有测试文件路径>`。若退出码非 0,按 `{{skill_dir}}/references/workflow.md` 的「失败处理」修复后重跑;单轮最多 3 次。
|
|
39
|
-
- DoD check: 测试命令退出码为 0
|
|
40
|
-
|
|
41
|
-
# Sprint Standards
|
|
42
|
-
|
|
43
|
-
Read **Sprint Standards** `{{shared_dir}}/references/sprint_standards.md`.
|
|
44
|
-
|
|
45
|
-
# Sprint Now!
|
|
46
|
-
|
|
47
|
-
Follow **Sprint One Workflow** `{{shared_dir}}/references/run/run_sprint_one.md`, then *sprint*.
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
# better-class 迭代工作流参考
|
|
2
|
-
|
|
3
|
-
## 目录
|
|
4
|
-
|
|
5
|
-
- [循环](#循环)
|
|
6
|
-
- [门禁决策表](#门禁决策表)
|
|
7
|
-
- [失败处理](#失败处理)
|
|
8
|
-
- [引用同步检查清单](#引用同步检查清单)
|
|
9
|
-
- [Common Mistakes](#common-mistakes)
|
|
10
|
-
- [示例](#示例)
|
|
11
|
-
|
|
12
|
-
## 循环
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
评估 → 门禁 ─┬─ 达标 → 最终验证 → 报告
|
|
16
|
-
├─ 未达标且 iteration < max_iterations → 修复 → 验证 → 评估
|
|
17
|
-
└─ 未达标且 iteration = max_iterations → 报告(未达标)
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## 门禁决策表
|
|
21
|
-
|
|
22
|
-
| 条件 | 动作 |
|
|
23
|
-
|---|---|
|
|
24
|
-
| 三项均达到通过标准(见 `planning_spec.md` F) | 进入最终验证 |
|
|
25
|
-
| 未达标且 `iteration < max_iterations` | `iteration += 1`,执行引用扫描 → Clean Code 修复 → 单测修复 → 验证 |
|
|
26
|
-
| 未达标且 `iteration = max_iterations` | 停止修复,生成报告并标记未达标 |
|
|
27
|
-
| 单轮内测试修复尝试已达上限(3 次) | 停止该轮修复,生成报告并记录失败输出 |
|
|
28
|
-
| 同一扣分项连续两轮未能消除 | 写入报告的"未解决项",不再重复同一修复动作 |
|
|
29
|
-
|
|
30
|
-
## 失败处理
|
|
31
|
-
|
|
32
|
-
- 测试失败时先读 pytest 输出的首个 traceback,定位到具体文件与行号,再修改。
|
|
33
|
-
- `ImportError` / `ModuleNotFoundError` 优先按引用映射表检查 `__init__.py`、测试文件、其他源文件的导入。
|
|
34
|
-
- 断言失败时先确认预期行为是否变化:仅当接口契约确实改变时才调整测试。
|
|
35
|
-
- 修复后必须重跑测试;不把"已修改"当作"已通过"。
|
|
36
|
-
|
|
37
|
-
## 引用同步检查清单
|
|
38
|
-
|
|
39
|
-
| 修改类型 | 同步位置 |
|
|
40
|
-
|----------|----------|
|
|
41
|
-
| 类名 | `__init__.py`、所有测试文件、其他源文件 |
|
|
42
|
-
| 方法名 | 所有测试文件、其他源文件调用点 |
|
|
43
|
-
| 参数名 | 方法体内部、调用点关键字参数、测试文件 |
|
|
44
|
-
| 依赖注入 | `__init__` 调用点、测试实例化、mock 配置 |
|
|
45
|
-
|
|
46
|
-
## Common Mistakes
|
|
47
|
-
|
|
48
|
-
| 错误 | 修复 |
|
|
49
|
-
|------|------|
|
|
50
|
-
| 重命名方法后只改源文件,漏掉 `__init__.py` 或测试导入 | 按引用同步检查清单逐个同步,再用 grep 搜索确认旧名称 0 匹配 |
|
|
51
|
-
| 测试断言失败时直接改测试以匹配旧行为 | 先确认契约是否变化;契约未变则修源文件,变了才改测试 |
|
|
52
|
-
| 把 pytest 的 `no tests ran` 当成通过 | 检查测试文件命名与路径;`run-tests.js` 非 0 退出时必须修复 |
|
|
53
|
-
| 把 `run-tests.js` 的退出码 4 当成脚本故障 | 4 表示 pytest 未通过;按「失败处理」修复测试或源文件 |
|
|
54
|
-
| 旧名称仍残留在 docstring 或注释中 | 把 docstring/注释纳入 grep 搜索与同步范围 |
|
|
55
|
-
| 重命名后出现 `ImportError` 仍继续跑测试 | 先修 `__init__.py` 与全部导入点,再重跑测试 |
|
|
56
|
-
| 达到 5 轮仍继续修改 | 立即停止并生成报告,标记未达标 |
|
|
57
|
-
| 用相对路径运行测试但当前目录不是项目根目录 | 从项目根目录执行,或改用脚本可解析的绝对路径 |
|
|
58
|
-
|
|
59
|
-
## 示例
|
|
60
|
-
|
|
61
|
-
输入:`class_path: src/blues_lib/services/schema/SchemaGenerator.py`
|
|
62
|
-
|
|
63
|
-
1. 基线评估:`blame-cleancode` 58/80,`blame-ut` 14/20,总分 72/100,未达标。
|
|
64
|
-
2. 引用扫描:`SchemaGenerator`、`getSchema`、`schema_type` 在 `src/` 命中 2 处、`tests/` 命中 3 处、`__init__.py` 命中 1 处;映射表记录 `getSchema → get_schema`。
|
|
65
|
-
3. 修复后执行:
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
node '{{skill_dir}}/scripts/check-syntax.js' src/blues_lib/services/schema/SchemaGenerator.py src/blues_lib/services/schema/__init__.py
|
|
69
|
-
# OK: 语法检查通过 (2 个文件)
|
|
70
|
-
|
|
71
|
-
node '{{skill_dir}}/scripts/run-tests.js' tests/unit/services/schema/test_schema_generator.py
|
|
72
|
-
# OK: pytest 通过 (1 个路径)
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
4. 复评:66/80、17/20、83/100,达标,生成 `src/blues_lib/services/schema/SchemaGenerator_opt_report.md`。
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* check-syntax.js — 用 Python AST 解析检查 .py 文件语法,不写 __pycache__。
|
|
4
|
-
*
|
|
5
|
-
* 用法:node check-syntax.js <file.py> [<file.py> ...]
|
|
6
|
-
* - 依赖:uv(在目标项目根目录执行)
|
|
7
|
-
* - 输出:Python 语法错误详情 + 一行 status
|
|
8
|
-
* - 退出码:0 通过 / 2 参数或输入错误 / 3 依赖不可用 / 4 语法错误
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { existsSync, statSync } from 'fs'
|
|
12
|
-
import { spawnSync } from 'child_process'
|
|
13
|
-
import { pathToFileURL } from 'url'
|
|
14
|
-
|
|
15
|
-
// ── CLI 输出模板(status 行;CLI 入口只做占位符替换)──
|
|
16
|
-
const USAGE_TEMPLATE = `ERROR: usage: node check-syntax.js <file.py> [<file.py> ...]
|
|
17
|
-
file.py: 待检查的 Python 源文件路径(相对当前工作目录)`
|
|
18
|
-
const NO_INPUT_TEMPLATE = 'INVALID: 未提供 Python 文件路径'
|
|
19
|
-
const NOT_FOUND_TEMPLATE = 'INVALID: 文件不存在: ${path}'
|
|
20
|
-
const NOT_FILE_TEMPLATE = 'INVALID: 路径不是文件: ${path}'
|
|
21
|
-
const NOT_PYTHON_TEMPLATE = 'INVALID: 文件不是 .py: ${path}'
|
|
22
|
-
const UV_MISSING_TEMPLATE = 'ERROR: 未找到 uv,无法执行 Python 语法检查;请在目标项目根目录确认 uv 可用'
|
|
23
|
-
const OK_TEMPLATE = 'OK: 语法检查通过 (${count} 个文件)'
|
|
24
|
-
const FAIL_TEMPLATE = 'ERROR: 语法检查失败 (exit=${status})'
|
|
25
|
-
const SPAWN_ERROR_TEMPLATE = 'ERROR: 无法启动 Python: ${message}'
|
|
26
|
-
|
|
27
|
-
const PYTHON_CHECK_CODE =
|
|
28
|
-
"import ast, pathlib, sys; [ast.parse(pathlib.Path(p).read_text(encoding='utf-8'), filename=p) for p in sys.argv[1:]]"
|
|
29
|
-
|
|
30
|
-
const render = (template, data = {}) =>
|
|
31
|
-
template.replace(/\$\{(\w+)\}/g, (_, key) => data[key] ?? '')
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 校验传入的 Python 文件路径。
|
|
35
|
-
* @param {string[]} filePaths 文件路径列表
|
|
36
|
-
* @returns {{ ok: boolean, message?: string }}
|
|
37
|
-
*/
|
|
38
|
-
export function validatePythonPaths(filePaths) {
|
|
39
|
-
if (!Array.isArray(filePaths) || filePaths.length === 0) {
|
|
40
|
-
return { ok: false, message: render(NO_INPUT_TEMPLATE) }
|
|
41
|
-
}
|
|
42
|
-
for (const filePath of filePaths) {
|
|
43
|
-
if (!existsSync(filePath)) {
|
|
44
|
-
return { ok: false, message: render(NOT_FOUND_TEMPLATE, { path: filePath }) }
|
|
45
|
-
}
|
|
46
|
-
if (!statSync(filePath).isFile()) {
|
|
47
|
-
return { ok: false, message: render(NOT_FILE_TEMPLATE, { path: filePath }) }
|
|
48
|
-
}
|
|
49
|
-
if (!filePath.endsWith('.py')) {
|
|
50
|
-
return { ok: false, message: render(NOT_PYTHON_TEMPLATE, { path: filePath }) }
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return { ok: true }
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* 确认 uv 可用。
|
|
58
|
-
* @returns {{ ok: boolean, message?: string }}
|
|
59
|
-
*/
|
|
60
|
-
export function checkUv() {
|
|
61
|
-
const result = spawnSync('uv', ['--version'], { encoding: 'utf8' })
|
|
62
|
-
if (result.error || result.status !== 0) {
|
|
63
|
-
return { ok: false, message: render(UV_MISSING_TEMPLATE) }
|
|
64
|
-
}
|
|
65
|
-
return { ok: true }
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* 用 Python AST 检查文件语法。
|
|
70
|
-
* @param {string[]} filePaths 已校验的 Python 文件路径
|
|
71
|
-
* @returns {number} 脚本退出码
|
|
72
|
-
*/
|
|
73
|
-
export function checkSyntax(filePaths) {
|
|
74
|
-
const validation = validatePythonPaths(filePaths)
|
|
75
|
-
if (!validation.ok) {
|
|
76
|
-
console.error(validation.message)
|
|
77
|
-
return 2
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const uv = checkUv()
|
|
81
|
-
if (!uv.ok) {
|
|
82
|
-
console.error(uv.message)
|
|
83
|
-
return 3
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const result = spawnSync('uv', ['run', 'python', '-c', PYTHON_CHECK_CODE, ...filePaths], {
|
|
87
|
-
stdio: 'inherit',
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
if (result.error) {
|
|
91
|
-
console.error(render(SPAWN_ERROR_TEMPLATE, { message: result.error.message }))
|
|
92
|
-
return 4
|
|
93
|
-
}
|
|
94
|
-
if (result.status !== 0) {
|
|
95
|
-
console.error(render(FAIL_TEMPLATE, { status: result.status ?? 'signal' }))
|
|
96
|
-
return 4
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
console.log(render(OK_TEMPLATE, { count: filePaths.length }))
|
|
100
|
-
return 0
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const isMain = Boolean(process.argv[1]) && import.meta.url === pathToFileURL(process.argv[1]).href
|
|
104
|
-
|
|
105
|
-
if (isMain) {
|
|
106
|
-
const filePaths = process.argv.slice(2)
|
|
107
|
-
if (filePaths.length === 0) {
|
|
108
|
-
console.error(render(USAGE_TEMPLATE))
|
|
109
|
-
process.exit(2)
|
|
110
|
-
}
|
|
111
|
-
process.exit(checkSyntax(filePaths))
|
|
112
|
-
}
|