@wwkit/harness 1.0.42 → 1.0.44

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.
Files changed (65) hide show
  1. package/README.md +39 -9
  2. package/bin/index.js +266 -1
  3. package/package.json +1 -1
  4. package/plugin.js +62 -11
  5. package/skills/better-class/SKILL.md +1 -1
  6. package/skills/better-class/references/subagent-prompt.md +1 -1
  7. package/skills/better-class/scripts/init.js +1 -1
  8. package/skills/better-class/scripts/resolve_run_vars.js +11 -8
  9. package/skills/better-skill/SKILL.md +1 -1
  10. package/skills/better-skill/references/planning_spec.md +37 -13
  11. package/skills/blame-skill/SKILL.md +1 -1
  12. package/skills/blame-tool/SKILL.md +1 -1
  13. package/skills/blame-tool/scripts/init.js +1 -1
  14. package/skills/blame-tool/scripts/resolve_run_vars.js +10 -7
  15. package/skills/convert-files/SKILL.md +1 -1
  16. package/skills/convert-files/scripts/init.js +1 -1
  17. package/skills/convert-files/scripts/resolve_run_vars.js +13 -14
  18. package/skills/create-ppt/SKILL.md +1 -1
  19. package/skills/create-ppt/scripts/init.js +1 -1
  20. package/skills/create-ppt/scripts/resolve_run_vars.js +10 -7
  21. package/skills/pea/SKILL.md +211 -0
  22. package/skills/pea/references/tpl-prd/epic.md +31 -0
  23. package/skills/pea/references/tpl-prd/release.md +45 -0
  24. package/skills/pea/references/tpl-prd/us.md +40 -0
  25. package/skills/pea/references/tpl-sprint/batch-loop.md +108 -0
  26. package/skills/pea/references/tpl-sprint/evaluate-optimize.md +111 -0
  27. package/skills/pea/references/tpl-sprint/loop.md +85 -0
  28. package/skills/pea/references/tpl-sprint/sequential.md +51 -0
  29. package/skills/revise/SKILL.md +24 -149
  30. package/skills/revise/references/article.md +2 -2
  31. package/skills/revise/references/gallery.md +2 -2
  32. package/skills/revise/references/question.md +2 -2
  33. package/skills/revise/references/sprint_for_revise.md +46 -0
  34. package/skills/revise/references/status.md +2 -2
  35. package/skills/revise/scripts/check_input_vars.js +127 -0
  36. package/skills/revise/scripts/init.js +84 -0
  37. package/skills/revise/scripts/resolve_run_vars.js +71 -0
  38. package/skills/revise/scripts/validate-schema.js +82 -28
  39. package/skills/shared/references/rules/blame-skill-rules.md +4 -5
  40. package/skills/shared/references/run/run_sprint_eo.md +11 -10
  41. package/skills/shared/references/template/prompt/subagent.md +1 -1
  42. package/skills/shared/references/template/sprint-pe/skill.md +8 -1
  43. package/skills/shared/references/template/sprint-peo/skill.md +8 -1
  44. package/skills/shared/references/template/sprint-peo/spec.md +5 -5
  45. package/skills/shared/references/template/sprint-seq/skill.md +9 -1
  46. package/skills/shared/references/template/sprint-workflow-menu.md +4 -4
  47. package/skills/shared/scripts/resolve_system_vars.js +3 -1
  48. package/skills/shared/scripts/utils.js +24 -1
  49. package/skills/translate-file/SKILL.md +1 -1
  50. package/skills/translate-file/scripts/init.js +1 -1
  51. package/skills/translate-file/scripts/merge_results.js +1 -8
  52. package/skills/translate-file/scripts/resolve_run_vars.js +10 -7
  53. package/skills/translate-format/SKILL.md +21 -282
  54. package/skills/translate-format/references/format-prompt.md +80 -0
  55. package/skills/translate-format/references/format-rules.md +39 -0
  56. package/skills/translate-format/references/sprint_for_format.md +208 -0
  57. package/skills/translate-format/scripts/check-paragraphs.js +81 -0
  58. package/skills/translate-format/scripts/check_input_vars.js +51 -0
  59. package/skills/translate-format/scripts/chunk-bilingual.js +135 -0
  60. package/skills/translate-format/scripts/count-words.js +38 -0
  61. package/skills/translate-format/scripts/diagnose-failure.js +54 -0
  62. package/skills/translate-format/scripts/init.js +71 -0
  63. package/skills/translate-format/scripts/md-to-docx.js +398 -0
  64. package/skills/translate-format/scripts/merge-format.js +118 -0
  65. package/skills/translate-format/scripts/resolve_run_vars.js +78 -0
@@ -0,0 +1,108 @@
1
+ 使用场景:分块 → 批量 subagent → 合并
2
+
3
+ ---
4
+
5
+ # Sprint Backlog for <name>
6
+
7
+ ## Sprint Goal
8
+
9
+ <one-sentence goal, typically: chunk the source, process chunks by batch via subagents, then merge the results>
10
+
11
+ ## Sprint Increment
12
+ <list of Increment>
13
+
14
+ ## Sprint Backlog Items
15
+
16
+ ### Item1: Define variables
17
+
18
+ #### Implement
19
+ Define the following variables and reference them as `{{var}}` in later items:
20
+
21
+ | Variable | Value | Description |
22
+ |---|---|---|
23
+ | `us_work_dir` | `US Work Dir` | US work directory, from the US document |
24
+ | `results_dir` | `{{us_work_dir}}/results` | Iteration results directory |
25
+ | `chunks_dir` | `{{us_work_dir}}/chunks` | Chunk files directory |
26
+ | `max_parallel` | `5` | Max chunks dispatched in parallel per batch (default: 5) |
27
+ | `source_dir` | `Source Dir` | Source material / resource document directory, from the US document |
28
+ | `chunk_id` | `chunk_001`, `chunk_002`, ... | Per-chunk identifier, in chunk order |
29
+ | `status` | `pending` / `completed` / `failed` | Per-chunk status, stored in `progress.csv` |
30
+ | `retry` | `0` | Retry count per row; a failed row is retried while `retry < 3` |
31
+
32
+ #### DoD check
33
+ All eight variables defined and resolvable
34
+
35
+ ### Item2: Create chunks
36
+
37
+ #### Implement
38
+ 1. Split the source `{{source_dir}}/<source>` into chunks according to <chunking rule>.
39
+ 2. Save each chunk as `{{chunks_dir}}/{{chunk_id}}.<ext>`, where `{{chunk_id}}` runs `chunk_001`, `chunk_002`, ... in chunk order.
40
+
41
+ #### DoD check
42
+ Chunk files are saved to `{{chunks_dir}}`
43
+
44
+ ### Item3: Prepare loop resources
45
+
46
+ #### Implement
47
+ 1. Create `{{us_work_dir}}/progress.csv` with one row per chunk file created in Item2, all starting as `pending` with `retry = 0`:
48
+ ```
49
+ chunk_id,status,retry
50
+ chunk_001,pending,0
51
+ chunk_002,pending,0
52
+ ...
53
+ ```
54
+ 2. Prepare the subagent dispatch parameters:
55
+
56
+ | Parameter | Value |
57
+ |---|---|
58
+ | `subagent_type` | `general` |
59
+ | `description` | `<action> {{chunk_id}}` |
60
+ | `prompt` | self-contained task prompt (input: chunk file `{{chunks_dir}}/{{chunk_id}}.<ext>`, output: result file `{{results_dir}}/{{chunk_id}}.<ext>`) |
61
+
62
+ #### DoD check
63
+ `{{us_work_dir}}/progress.csv` created with all chunks pending; subagent dispatch parameters ready
64
+
65
+ ### Item4: Batch process loop
66
+
67
+ #### Implement
68
+ ```
69
+ # resources prepared in Item3
70
+ while true:
71
+ # take the first batch of chunks not completed and retry < 3
72
+ batch = first {{max_parallel}} rows from {{us_work_dir}}/progress.csv where status != completed and retry < 3
73
+
74
+ # exit when no chunk is left to process
75
+ if batch is empty:
76
+ break
77
+
78
+ # adjust prompt for failed chunks
79
+ for chunk in batch:
80
+ if chunk.status == failed:
81
+ adjust prompt based on the failure reason
82
+
83
+ # dispatch one subagent per chunk in the batch, all in a single message (parallel, not serial), using the parameters prepared in Item3 (prompt adjusted as above for retried chunks)
84
+ parallel dispatch_subagent(for each chunk in batch)
85
+
86
+ # update status; any failure (including an error) counts as one retry
87
+ for chunk in batch:
88
+ if {{results_dir}}/{{chunk_id}}.<ext> exists and valid:
89
+ update {{us_work_dir}}/progress.csv → completed
90
+ else:
91
+ update {{us_work_dir}}/progress.csv → failed, retry+1
92
+
93
+ print batch N status: [{{chunk_id}}:{{status}}, ...]
94
+ ```
95
+
96
+ #### DoD check
97
+ - All chunks in `{{us_work_dir}}/progress.csv` are either `completed` or `failed` with `retry >= 3`
98
+ - Every completed chunk has a corresponding `{{results_dir}}/{{chunk_id}}.<ext>`
99
+
100
+ ### Item5: Merge output
101
+
102
+ #### Implement
103
+ 1. Merge the results of all `completed` chunks in `{{results_dir}}/`, ordered by their row order in `{{us_work_dir}}/progress.csv`, into `{{us_work_dir}}/result.<ext>`
104
+ 2. Report the chunks that ended `failed` (retry >= 3); they are excluded from the merged result
105
+
106
+ #### DoD check
107
+ - `{{us_work_dir}}/result.<ext>` generated from all completed results
108
+ - Excluded failed chunks are reported
@@ -0,0 +1,111 @@
1
+ 使用场景:初始优化 → [评估 → 判停 → 优化]循环 → 终审优化 → 报告
2
+
3
+ ---
4
+
5
+ # Sprint Backlog for <name>
6
+
7
+ ## Sprint Goal
8
+
9
+ <one-sentence goal, typically: optimize the target in place until the score passes or max rounds reached, then report>
10
+
11
+ ## Sprint Increment
12
+ <list of Increment>
13
+
14
+ ## Sprint Backlog Items
15
+
16
+ ### Item1: Define variables
17
+
18
+ #### Implement
19
+ Define the following variables and reference them as `{{var}}` in later items:
20
+
21
+ | Variable | Value | Description |
22
+ |---|---|---|
23
+ | `us_work_dir` | `US Work Dir` | US work directory, from the US document |
24
+ | `max_rounds` | `3` | Max evaluate-optimize rounds (default: 3) |
25
+ | `target_score` | `<score the target must reach>` | Pass threshold of the evaluation score |
26
+ | `round` | `1`, `2`, ... | Per-round number, in round order |
27
+ | `score` | `<number>` | Evaluation score of the target in this round |
28
+ | `status` | `pending` / `completed` / `max_reached` / `failed` | Per-round status, stored in `progress.csv` |
29
+
30
+ #### DoD check
31
+ All six variables defined and resolvable
32
+
33
+ ### Item2: Initial optimize
34
+
35
+ #### Implement
36
+ Optimize the target in place (first pass)
37
+
38
+ #### DoD check
39
+ Target optimized in place
40
+
41
+ ### Item3: Prepare loop resources
42
+
43
+ #### Implement
44
+ 1. Create `{{us_work_dir}}/progress.csv` with one row per round `1` to `{{max_rounds}}`, all starting as `pending` with an empty score:
45
+ ```
46
+ round,status,score
47
+ 1,pending,
48
+ 2,pending,
49
+ ...
50
+ ```
51
+ 2. Define the explicit scoring rules (required), described in text: how the score is computed — the scored dimensions, their weights, and the deduction rules for unmet points — together with the evaluation tool to use and the pass threshold `{{target_score}}`
52
+
53
+ #### DoD check
54
+ `{{us_work_dir}}/progress.csv` created with all rounds pending; explicit scoring rules described in text
55
+
56
+ ### Item4: Evaluate-optimize loop
57
+
58
+ #### Implement
59
+ ```
60
+ # resources prepared in Item3
61
+ while true:
62
+ # take the first pending round
63
+ round = first row from {{us_work_dir}}/progress.csv where status == pending
64
+
65
+ # exit when no round is left to process
66
+ if round is empty:
67
+ break
68
+
69
+ # score the target
70
+ score = run the evaluation tool on the target
71
+
72
+ # decide this round's status
73
+ if score meets {{target_score}}:
74
+ status = completed
75
+ elif round >= {{max_rounds}}:
76
+ status = max_reached
77
+ else:
78
+ <optimize the target in place based on the items that did not pass>
79
+ status = completed if the target was modified else failed
80
+
81
+ update {{us_work_dir}}/progress.csv where round == {{round}} → score = {{score}}, status = {{status}}
82
+
83
+ print round {{round}} score: {{score}} status: {{status}}
84
+
85
+ # stop once the target passes or the last round is reached
86
+ if score meets {{target_score}} or status == max_reached:
87
+ break
88
+ ```
89
+
90
+ #### DoD check
91
+ - Every round is `completed`, `max_reached`, or `failed`; rounds left `pending` only when the loop stopped on a pass
92
+ - Every round with a non-`pending` status has a recorded score
93
+
94
+ ### Item5: Final optimize
95
+
96
+ #### Implement
97
+ Short-circuit: skip this item when the last round score already passes.
98
+
99
+ Final optimization pass on the target in place
100
+
101
+ #### DoD check
102
+ Target optimized in place at the final state
103
+
104
+ ### Item6: Report
105
+
106
+ #### Implement
107
+ Generate `{{us_work_dir}}/report.md` with the score history per round (read from `progress.csv`) and the final status
108
+
109
+ #### DoD check
110
+ - `report.md` generated with the score history table
111
+ - Final status recorded: `completed` when the last score met `{{target_score}}`, otherwise `NOT_REACHED`
@@ -0,0 +1,85 @@
1
+ 使用场景:条目 → 逐条循环处理 → 汇总
2
+
3
+ ---
4
+
5
+ # Sprint Backlog for <name>
6
+
7
+ ## Sprint Goal
8
+
9
+ <one-sentence goal, typically: process items one by one in a loop and produce final output>
10
+
11
+ ## Sprint Increment
12
+ <list of Increment>
13
+
14
+ ## Sprint Backlog Items
15
+
16
+ ### Item1: Define variables
17
+
18
+ #### Implement
19
+ Define the following variables and reference them as `{{var}}` in later items:
20
+
21
+ | Variable | Value | Description |
22
+ |---|---|---|
23
+ | `us_work_dir` | `US Work Dir` | US work directory, from the US document |
24
+ | `results_dir` | `{{us_work_dir}}/results` | Iteration results directory |
25
+ | `item_id` | `item_001`, `item_002`, ... | Per-item identifier, in item order |
26
+ | `status` | `pending` / `completed` / `failed` | Per-item status, stored in `progress.csv` |
27
+ | `retry` | `0` | Retry count per row; a failed row is retried while `retry < 3` |
28
+
29
+ Note: if the requirement produces no file output, `results_dir` need not be created; in that case, Item3 judges each item by its own result instead of a file, and Item4 is skipped.
30
+
31
+ #### DoD check
32
+ All five variables defined and resolvable
33
+
34
+ ### Item2: Prepare loop resources
35
+
36
+ #### Implement
37
+ 1. Create `{{us_work_dir}}/progress.csv`:
38
+ ```
39
+ item_id,status,retry
40
+ item_001,pending,0
41
+ item_002,pending,0
42
+ ...
43
+ ```
44
+ 2. <prepare other resources needed by the loop>
45
+
46
+ #### DoD check
47
+ `{{us_work_dir}}/progress.csv` created with all items pending; loop resources ready
48
+
49
+ ### Item3: Process loop
50
+
51
+ #### Implement
52
+ ```
53
+ # resources prepared in Item2
54
+ while true:
55
+ # take the first row not completed and retry < 3
56
+ item = first row from {{us_work_dir}}/progress.csv where status != completed and retry < 3
57
+
58
+ # exit when no item is left to process
59
+ if item is empty:
60
+ break
61
+
62
+ # process the single item, overwrite its process file
63
+ <process item, write output to {{results_dir}}/item_{{item_id}}.<ext>>
64
+
65
+ # update status; any failure (including an error) counts as one retry
66
+ if {{results_dir}}/item_{{item_id}}.<ext> exists and valid:
67
+ update {{us_work_dir}}/progress.csv → completed
68
+ else:
69
+ update {{us_work_dir}}/progress.csv → failed, retry+1
70
+
71
+ print item {{item_id}} status: {{status}}
72
+ ```
73
+
74
+ #### DoD check
75
+ - All items in `{{us_work_dir}}/progress.csv` are either `completed` or `failed` with `retry >= 3`
76
+ - Every completed item has a corresponding `{{results_dir}}/item_{{item_id}}.<ext>`
77
+
78
+ ### Item4: Merge output
79
+
80
+ #### Implement
81
+ Short-circuit: skip this item when the requirement produces no file output.
82
+ 1. Merge/aggregate the process files of all `completed` items in `{{results_dir}}/`, ordered by their row order in `{{us_work_dir}}/progress.csv`, into `{{us_work_dir}}/result.<ext>`
83
+
84
+ #### DoD check
85
+ - `{{us_work_dir}}/result.<ext>` generated from all completed results
@@ -0,0 +1,51 @@
1
+ 使用场景:步骤 → 顺序执行 → 完成
2
+
3
+ ---
4
+
5
+ # Sprint Backlog for <name>
6
+
7
+ ## Sprint Goal
8
+ <one-sentence goal>
9
+
10
+ ## Sprint Increment
11
+ <list of Increment>
12
+
13
+ ## Sprint Backlog Items
14
+
15
+ ### Item1: Define variables
16
+
17
+ #### Implement
18
+ Define the following variables and reference them as `{{var}}` in later items:
19
+
20
+ | Variable | Value | Description |
21
+ |---|---|---|
22
+ | `us_work_dir` | `US Work Dir` | US work directory, from the US document |
23
+
24
+ #### DoD check
25
+ The variable is defined and resolvable
26
+
27
+ ### Item2: <title>
28
+
29
+ #### Implement
30
+ <action>
31
+
32
+ #### DoD check
33
+ <verifiable criteria>
34
+
35
+ ### Item3: <title>
36
+
37
+ #### Implement
38
+ <action>
39
+
40
+ #### DoD check
41
+ <verifiable criteria>
42
+
43
+ ### Item4: <title>
44
+
45
+ #### Implement
46
+ Short-circuit: skip when <condition>
47
+
48
+ <action>
49
+
50
+ #### DoD check
51
+ <verifiable criteria>
@@ -2,68 +2,40 @@
2
2
  name: revise
3
3
  description: |
4
4
  Use when creating social media content (questions, status posts, galleries, articles) from source material into schema-validated JSON arrays. Triggers on: revise, 内容创作, 创作, question, status, gallery, article, 问题, 动态, 图集, 文章.
5
- format=question/status/gallery/article(支持中文别名),count 控制条目数(默认1),language 控制输出语言(默认中文)。调用方直接传原始任务消息;禁止 WebFetch/网络请求。
5
+ format=question/status/gallery/article(支持中文别名),count 控制条目数(默认1),language 控制输出语言(默认中文)。
6
6
  license: MIT
7
7
  metadata:
8
8
  workflow: sequential
9
9
  ---
10
10
 
11
- # revise 技能(固定 Sprint 冲刺)
11
+ 作为 Scrum 开发者,我想要把原始素材按指定格式创作成通过 schema 校验的 JSON 数组,以便交付可直接消费的结构化社交媒体内容。using the **fixed-sequence Sprint workflow** (seq)。
12
12
 
13
- ## 执行范式
14
-
15
- 每次调用 = 一个固定 Sprint,三个事件:
16
-
17
- 1. **Sprint Planning**:解析入参 → 定义 Sprint Goal → todowrite 落固定 3 项 Sprint Backlog(每项带 DoD)
18
- 2. **Sprint Execution**:逐项执行,每项 = 标记 `in_progress` → 执行 → 验证 DoD → 立即 `completed`(不攒批)
19
- 3. **Sprint Review**:对照 Sprint Goal 验证 Increment(JSON 数组)及输出语义
20
-
21
- **Sprint Goal** = `产出 {{count}} 条符合 {{format}} 格式、{{language}} 语言的 JSON 数组,并通过 schema 校验`。
22
-
23
- > **固定的含义**:3 项 Backlog 不随输入变化——步骤种类与顺序固定,`{{count}}`/`{{format}}`/`{{language}}` 只实例化参数值。
24
-
25
- **Increment** = 通过 schema 校验的裸 JSON 数组(写入 `output` 文件或 stdout)。
26
-
27
- ## Overview
28
-
29
- 将原始素材按指定格式(question/status/gallery/article)创作内容,产出通过 schema 校验的 JSON 数组。调用方直接传原始任务消息,skill 自解析字段,全程禁止网络请求。
30
-
31
- ## When to Use
32
-
33
- - 从文本/JSON/文件素材创作社交媒体内容(问题、动态、图集、文章)
34
- - 需要结构化 JSON 数组输出并通过 schema 校验
35
- - 批量生成指定数量的内容条目
36
-
37
- ## When NOT to Use
13
+ # When not to use
38
14
 
39
15
  - 需要网络抓取内容 → 用 `extract` skill
40
16
  - 只需生成自由文本(无 schema 约束)→ 用 `query` skill
41
17
  - 需要翻译文档 → 用 `translate` skill
42
18
 
43
- ## Quick Reference
19
+ # Product Goal
44
20
 
45
- | Item | 做什么 | 关键动作 |
46
- |---|---|---|
47
- | 1 | 解析入参 + 准备素材 + 加载 references | 提取六字段;`read` source 文件;`read` `references/{{format}}.md` + `references/{{format}}.schema.json5` |
48
- | 2 | 内容生成 + Schema 校验 | LLM 生成裸 JSON 数组;`write` 临时输入文件;`node 'scripts/validate-schema.js' < <临时文件>` |
49
- | 3 | 输出 | `write` 到 `output` 路径(stdout 输出路径)/ 直接 stdout 输出数组 |
21
+ 按 `format` 从素材创作 `count` 条通过 schema 校验的 JSON 数组,按输出语义(文件或 stdout)交付。
50
22
 
51
- ## 输入参数
23
+ # Extract Variables
52
24
 
53
- 入参为调用方传入的**原始任务消息**,可为 JSON 对象、key=value 或自然语言等任意形态,agent 依据字段语义自主提取。字段清单(字段/类型/必填/默认值):
25
+ 从上下文提取输入变量(入参为调用方传入的**原始任务消息**,可为 JSON、key=value 或自然语言形态):
54
26
 
55
- | 字段 | 类型 | 必填 | 说明 |
27
+ | 变量 | 类型 | 必填 | 说明 |
56
28
  |---|---|---|---|
57
- | `format` | string | ✅ | 创作格式,标准值 `question`/`status`/`gallery`/`article`,可用自然语言别名指定(见别名对照) |
29
+ | `format` | string | ✅ | 创作格式,标准值 `question`/`status`/`gallery`/`article`,可用别名指定(见别名对照) |
58
30
  | `source` | string | ✅ | 原始素材:文本 / JSON 字符串 / 文件路径 |
59
31
  | `count` | integer | ❌ | 生成 item 数量,默认 1(非整数或 <1 按 1) |
60
32
  | `language` | string | ❌ | 输出语言,默认 中文(空白按中文) |
61
- | `style` | string | ❌ | 创作风格描述(自由文本),缺省用 format 默认风格(`{{format}}.md` 的 Style 模块) |
33
+ | `style` | string | ❌ | 创作风格描述(自由文本),缺省用 format 默认风格(`references/{{format}}.md` 的 Style 模块) |
62
34
  | `output` | string | ❌ | 输出文件路径(提供则写文件,否则 stdout) |
63
35
 
64
- 本技能仅使用上表六个字段,忽略所有其他字段(如 `url`)。
36
+ 仅使用上表六个字段,忽略所有其他字段(如 `url`)。
65
37
 
66
- **format 别名对照**:
38
+ **format 别名对照**(本表为别名的唯一定义处):
67
39
 
68
40
  | format 标准值 | 别名 terms |
69
41
  |---|---|
@@ -72,120 +44,23 @@ metadata:
72
44
  | `gallery` | 图集 / 相册 / 多图 / 图片合集 / gallery |
73
45
  | `article` | 文章 / 图文 / 长文 / 推文 / article |
74
46
 
75
- ## 固定 Sprint Backlog(todowrite 落单,覆盖历史 todos)
76
-
77
- 1. 解析入参 + 准备素材 + 加载 references | DoD: 六字段已提取、素材已就绪(文件已读)、prompt 与 schema 已读且 schema 绝对路径已记录(或 stderr 报错结束)
78
- 2. 内容生成 + Schema 校验(失败修复重试 ≤3 次) | DoD: 产出含 `{{count}}` 个 item、`{{language}}` 语言的裸 JSON 数组且 `node scripts/validate-schema.js` 校验通过(或重试耗尽 stderr 报错)
79
- 3. 输出 | DoD: 按输出语义交付 JSON 数组(文件路径或 stdout)
80
-
81
- > **短路规则**:`source` 为空或 `format` 无法解析 → stderr 报错并结束,不继续执行。
82
-
83
- ## Sprint Execution
84
-
85
- 按固定 3 项逐项执行。每项:进入前 `todowrite` 标记 `in_progress` → 执行 → 验证 DoD → 立即标记 `completed`(不攒批)。短路或重试耗尽时标记终态(`completed` 或 `cancelled`),不残留 `in_progress`。
86
-
87
- ### Item 1:解析入参 + 准备素材 + 加载 references
88
-
89
- 从原始任务消息中自主提取 `format`/`source`/`count`/`language`/`style`/`output` 六个字段;自然语言格式按「format 别名对照」翻译。`source` 为文件路径时用 `read` 读取其内容作为素材。
90
-
91
- **短路规则(命中即结束,禁止继续执行):**
92
-
93
- 1. `source` 为空、null 或仅含空白 → 将错误信息输出到 stderr 并结束
94
- 2. `format` 未提供或经别名对照翻译后仍为空 → 将错误信息输出到 stderr 并结束
95
-
96
- 未短路时**并行读取** `references/{{format}}.md`(LLM 创作指令)与 `references/{{format}}.schema.json5`(输出校验规则),记录 schema 绝对路径(Item 2 校验用);references 文件不存在 → 将错误信息输出到 stderr 并结束。
97
-
98
- **DoD 验证**:六字段已提取、素材已就绪、prompt 与 schema 已读且 schema 绝对路径已记录。
99
-
100
- ### Item 2:内容生成 + Schema 校验
101
-
102
- 将素材结合 Prompt 文件内容调用 LLM 生成:**必须生成 `{{count}}` 个 item,整体输出为 JSON 数组(即使 count=1)**,内容语言使用 `{{language}}`(缺省按参数表默认值)。生成时向 LLM 传入:原始素材、Prompt 文件内容、`{{count}}`、`{{language}}`、输出格式说明和示例。
47
+ # Environment Initialization
103
48
 
104
- **style 覆盖**:若提供 `style`,以 `{{style}}` 取代 `{{format}}.md` 的 **Style 模块**(默认创作风格);**Format 模块(输出契约)不可变**——结构、schema 字段、长度、图片数量上限、真实性约束均以 Format 模块与 schema 为准。
49
+ 1. 运行 `node scripts/init.js '{{原始任务消息}}'`(消息整体加引号传入):校验入参并解析字段(JSON/key=value 形态输出「已解析字段」表,自然语言形态交由 Sprint Item1 提取),解析 run 变量(`run_dir`:临时文件与回顾报告目录)并检查依赖(`ajv`/`json5`,已声明于 harness `package.json`)。脚本输出约定(status 行与退出码)见 `scripts/` 各脚本顶部注释;失败短路的处理规则见 Sprint Backlog Item1。
50
+ 2. Read **Sprint Standards** `{{shared_dir}}/references/sprint_standards.md`。
105
51
 
106
- **裸 JSON 硬约束**:输出必须为裸 JSON 数组——不使用 markdown 代码围栏(```json)、不输出任何解释、思考过程或额外文本、无尾注,直接以 `[` 开始、`]` 结束。
52
+ # Product Increment
107
53
 
108
- 用 `write` 将 `{"data": <JSON 数组>, "schema_path": "<schema 绝对路径>"}` 写入**单个**临时 JSON 输入文件(数组内嵌于 `data`,无需单独写待校验数组文件),stdin 重定向交给 Node.js 校验:
109
-
110
- ```bash
111
- node '<技能目录>/scripts/validate-schema.js' < <临时 JSON 输入文件>
112
- ```
113
-
114
- - 通过 → 进入 Item 3
115
- - 失败 → 将 Schema 校验错误反馈给 LLM(原始素材 + Prompt 文件内容 + 上一轮不合格内容 + 错误详情)重新生成后再次校验,**最多重试 3 次**;耗尽 → 将最后一次错误及「重试 3 次后 schema 校验仍然失败」输出到 stderr 并结束
116
-
117
- **DoD 验证**:产出含 `{{count}}` 个 item、`{{language}}` 语言的裸 JSON 数组且 `node scripts/validate-schema.js` 校验通过(或重试耗尽 stderr 报错)。
118
-
119
- ### Item 3:输出
120
-
121
- 本项执行时校验必已通过:
122
-
123
- - 提供 `output` → 用 `write` 将最终 JSON 数组写入该文件(**禁止创建其他文件**),stdout 输出文件路径
124
- - 未提供 `output` → 将最终 JSON 数组直接输出到 stdout,**不写任何文件**
125
-
126
- **DoD 验证**:按输出语义交付 JSON 数组(文件路径或 stdout)。
127
-
128
- ## 禁止事项与借口表
129
-
130
- | 借口 | 现实 |
131
- |---|---|
132
- | "source 为空但可以从 URL 获取" | 禁止 WebFetch/网络请求;source 为空即短路结束 |
133
- | "format 不在标准值里但可以猜" | format 必须能通过别名对照翻译为标准值,否则短路结束 |
134
- | "schema 校验失败但内容看起来没问题" | schema 校验是硬线,不通过即重试,耗尽即结束 |
135
- | "多生成几个 item 反正不亏" | `count` 是精确值,不多不少 |
136
- | "输出加点解释说明更友好" | 裸 JSON 硬约束——不输出任何解释、思考过程或额外文本 |
137
-
138
- ## Red Flags(交付前逐条过)
139
-
140
- 1. 输出包含 markdown 代码围栏或解释文本 → 回 Item 2 重新生成
141
- 2. `count=3` 但只产出 2 个 item → 回 Item 2 重新生成
142
- 3. schema 校验未通过就进 Item 3 → 回 Item 2 重试
143
- 4. `output` 未提供却写了文件 → 违反输出语义
144
- 5. 使用了 WebFetch 或网络请求 → 违反禁令
54
+ | Product | Type | Description | DoD |
55
+ |---|---|---|---|
56
+ | JSON 数组 | file / stdout | `{{count}}` 条 `{{format}}` 格式、`{{language}}` 语言的内容条目 | `node scripts/validate-schema.js` 输出 `VALID` 且退出码 0;提供 `output` 时文件已落盘且 stdout 输出路径,否则 stdout 输出裸数组 |
145
57
 
146
- ## Common Mistakes
58
+ # Sprint Backlogs
147
59
 
148
- | 错误 | 后果 | 修复 |
60
+ | Sprint Name | Backlog File | Description |
149
61
  |---|---|---|
150
- | count=1 时输出单个 JSON 对象而非数组 | schema 校验失败(期望数组) | 即使 count=1 也输出 `[ {...} ]` |
151
- | 临时文件未清理 | 污染工作目录 | 中间产物完成后删除,禁止写入 output 以外的持久文件 |
152
- | style 覆盖了 Format 模块 | 输出结构不符合 schema | style 只覆盖 Style 模块,Format 模块不可变 |
153
- | schema 路径写错 | validate-schema.js 报路径错误 | Item 1 记录 schema 绝对路径,Item 2 使用该路径 |
154
-
155
- ## Sprint Review
156
-
157
- 本 skill 每次调用 = 无状态独立 Sprint,无跨轮次状态,故不进行 Retrospective。所有 Backlog Items 完成后:
158
-
159
- - **对照 Sprint Goal 验证**:产出的是否为 `{{count}}` 条符合 `{{format}}` 格式、`{{language}}` 语言的 JSON 数组且通过 schema 校验?输出语义是否正确(写文件输出路径 / stdout 输出数组)?
160
- - **验证 Increment**:Increment = 通过 schema 校验的裸 JSON 数组(写入 `output` 文件或 stdout);验证文件已落盘或数组已输出。
161
-
162
- ## 约束
163
-
164
- - 只处理已声明字段,忽略所有其他传入参数(字段清单见「输入参数」,含 `style`)。
165
- - **禁止使用 WebFetch 或任何网络请求、禁止访问外部网络**;`source`/`format` 缺失等短路情况的处理见 Item 1 短路规则。
166
- - 中间数据写入临时文件,以 stdin 重定向传给 `node`;中间产物完成后清理,禁止写入 `output` 以外的任何持久文件。
167
- - 禁止使用未授权的 `cp`/`rm`/`mv` 等命令;需要复制、移动或删除临时文件时用 `node -e` 的 fs 模块完成。
168
-
169
- ## 运行环境
170
-
171
- - Node.js(执行 `scripts/validate-schema.js`)
172
- - 脚本依赖:`ajv`(JSON Schema 校验)、`json5`(JSON5 解析)——已声明在 `packages/harness/package.json` 的 `dependencies` 中,无需单独安装
173
-
174
- ## references/ 目录结构
175
-
176
- 每个 format 需要两个文件,schema 定义为**数组**(`minItems: 1`),`items` 描述单个 item 的结构:
62
+ | Sprint for content | `{{skill_dir}}/references/sprint_for_revise.md` | 固定 4 项:解析入参加载 references → 生成+schema 校验 → 输出 → 回顾 |
177
63
 
178
- ```
179
- references/
180
- ├── question.md # 社交媒体问题 prompt
181
- ├── question.schema.json5 # 输出 JSON Schema
182
- ├── status.md # 社交媒体动态 prompt
183
- ├── status.schema.json5
184
- ├── gallery.md # 社交媒体图集 prompt
185
- ├── gallery.schema.json5
186
- ├── article.md # 社交媒体图文文章 prompt
187
- └── article.schema.json5
64
+ # Sprint Now!
188
65
 
189
- scripts/
190
- └── validate-schema.js # schema 校验脚本(stdin 输入,ESM)
191
- ```
66
+ Read all **Sprint Backlogs**, follow **Sprint Workflow** `{{shared_dir}}/references/run/run_sprint_one.md`, then *sprint*.
@@ -17,9 +17,9 @@
17
17
  - **图文混排**:文本块与图片块交替出现,建议文本为主、图片辅助
18
18
  - **图片**:从素材中提取图片地址作为 `{"type": "image"}` 块,最多 5 个图片块;素材无图片时全部用 `{"type": "text"}` 块
19
19
  - **真实性**:从素材中提炼核心信息,重组为流畅文章,不能凭空编造
20
- - **输出形式**:整体为 JSON 数组,含 `{{count}}` 个 item;仅输出数组,不包含任何解释、思考过程或额外文本,禁止输出单个对象
20
+ - **输出形式**:整体为 JSON 数组,含 `{{count}}` 个 item;裸 JSON 输出约束遵循 `sprint_for_revise.md` Item2「裸 JSON 契约」
21
21
 
22
- > 字数计算采用 **cn_length** 规则:中文字符算 1,非中文字符(英文/数字/符号)算 0.5,结果向上取整。
22
+ > 字数计算采用 **cn_length** 规则(唯一定义见 `sprint_for_revise.md`「执行约束」)。
23
23
 
24
24
  示例:
25
25
 
@@ -16,9 +16,9 @@
16
16
  - **配说明**:每张图必须带 `title` 简要说明图片内容——schema 必填,不可省略
17
17
  - **图片来源**:从原始素材中提取图片地址,素材中图片不足时可适当精选
18
18
  - **真实性**:从素材中提炼主题,不能凭空编造
19
- - **输出形式**:整体为 JSON 数组,含 `{{count}}` 个 item;仅输出数组,不包含任何解释、思考过程或额外文本,禁止输出单个对象
19
+ - **输出形式**:整体为 JSON 数组,含 `{{count}}` 个 item;裸 JSON 输出约束遵循 `sprint_for_revise.md` Item2「裸 JSON 契约」
20
20
 
21
- > 字数计算采用 **cn_length** 规则:中文字符算 1,非中文字符(英文/数字/符号)算 0.5,结果向上取整。
21
+ > 字数计算采用 **cn_length** 规则(唯一定义见 `sprint_for_revise.md`「执行约束」)。
22
22
 
23
23
  示例:
24
24
 
@@ -16,9 +16,9 @@
16
16
  - **结构**:每 item = `title`(10-30 cn_length)+ `content`(20-500 cn_length)+ `images`(string[],≤5 张)
17
17
  - **图片**:从素材提取图片地址,最多 5 张;素材无图片时为空数组
18
18
  - **真实性**:从素材中提取核心矛盾点,不能凭空编造
19
- - **输出形式**:整体为 JSON 数组,含 `{{count}}` 个 item;仅输出数组,不包含任何解释、思考过程或额外文本,禁止输出单个对象
19
+ - **输出形式**:整体为 JSON 数组,含 `{{count}}` 个 item;裸 JSON 输出约束遵循 `sprint_for_revise.md` Item2「裸 JSON 契约」
20
20
 
21
- > 字数计算采用 **cn_length** 规则:中文字符算 1,非中文字符(英文/数字/符号)算 0.5,结果向上取整。
21
+ > 字数计算采用 **cn_length** 规则(唯一定义见 `sprint_for_revise.md`「执行约束」)。
22
22
 
23
23
  示例:
24
24
 
@@ -0,0 +1,46 @@
1
+ # Sprint Backlog for content
2
+
3
+ ## Sprint Goal
4
+
5
+ 产出 `{{count}}` 条符合 `{{format}}` 格式、`{{language}}` 语言并通过 schema 校验的 JSON 数组,按输出语义交付。
6
+
7
+ ## Sprint Backlog Items
8
+
9
+ ### Item1: 解析入参 + 准备素材 + 加载 references
10
+
11
+ - Short-circuit: `source` 为空/仅空白,或 `format` 经别名对照(SKILL.md「Extract Variables」)翻译后仍无法得到标准值,或 init.js 已输出 `INVALID:` → 将错误信息输出到 stderr 并结束,不继续执行。
12
+ - Implement: init.js 已输出「已解析字段」表时直接采用其字段值;未输出(自然语言形态)时按 SKILL.md「Extract Variables」从原始任务消息自主提取六字段,`format` 按别名对照翻译为标准值。`source` 为文件路径时用 `read` 读取其内容作为素材。随后**并行读取** `references/{{format}}.md`(LLM 创作指令)与 `references/{{format}}.schema.json5`(输出校验规则),记录 schema 绝对路径;references 文件不存在 → stderr 报错并结束。
13
+ - DoD check: 六字段已提取、素材已就绪(文件已读)、prompt 与 schema 已读且 schema 绝对路径已记录。
14
+
15
+ ### Item2: 内容生成 + Schema 校验(失败重试 ≤3)
16
+
17
+ - Implement: 结合素材与 prompt 文件内容生成内容:必须产出 `{{count}}` 个 item(即使 `count=1` 也输出 JSON 数组),内容语言为 `{{language}}`。生成时向 LLM 传入:原始素材、prompt 文件内容、`{{count}}`、`{{language}}`、输出格式说明和示例。
18
+ - **style 覆盖**:提供 `style` 时,以 `{{style}}` 取代 `{{format}}.md` 的 Style 模块;Format 模块(输出契约)与 schema 不可变。
19
+ - **裸 JSON 契约**(唯一定义处,其余位置均引用本条):输出必须为裸 JSON 数组——直接以 `[` 开始、`]` 结束,不使用 markdown 代码围栏、不输出任何解释/思考过程/尾注等额外文本、禁止输出单个对象。
20
+ - 用 `write` 将 `{"data": <JSON 数组>, "schema_path": "<schema 绝对路径>"}` 写入 `{{run_dir}}` 下的**单个**临时输入文件,stdin 重定向校验:
21
+ ```bash
22
+ node '<skill_dir>/scripts/validate-schema.js' < <临时输入文件>
23
+ ```
24
+ 输出 `VALID` 且退出码 0 → 进入 Item3;`INVALID:`/`ERROR:` 或非零退出码 → 将错误详情连同(原始素材 + prompt 文件内容 + 上一轮不合格内容)反馈给 LLM 重新生成后再次校验,**最多重试 3 次**;耗尽 → 将最后一次错误与「重试 3 次后 schema 校验仍然失败」输出到 stderr 并结束。
25
+ - DoD check: 校验输出 `VALID` 且退出码 0,数组含 `{{count}}` 个 item、语言为 `{{language}}`。
26
+
27
+ ### Item3: 输出
28
+
29
+ - Implement: 本项执行时校验必已通过。
30
+ - 提供 `output` → 用 `write` 将最终 JSON 数组写入该文件(**禁止创建其他文件**),stdout 输出文件路径。
31
+ - 未提供 `output` → 将最终 JSON 数组直接输出到 stdout,**不写任何文件**。
32
+ - 清理 `{{run_dir}}` 临时输入文件(用 `node -e` 的 fs 模块完成,禁止 `cp`/`rm`/`mv` 命令)。
33
+ - DoD check: 按输出语义交付(文件路径或裸数组),临时文件已清理。
34
+
35
+ ### Item4: Review 与 Retrospective
36
+
37
+ - Implement: 对照 Sprint Goal 验证——产出是否为 `{{count}}` 条 `{{format}}` 格式、`{{language}}` 语言的 JSON 数组且通过 schema 校验;输出语义是否正确(写文件输出路径 / stdout 输出数组)。将 3 行回顾(做得好的 / 问题 / 改进)写入 `{{run_dir}}/retro.md`;回顾内容禁止写入 stdout(保护裸 JSON 契约)。
38
+ - Short-circuit: Item1 短路或 Item2 重试耗尽而结束时,本项标记 cancelled,不写 retro。
39
+ - DoD check: `{{run_dir}}/retro.md` 存在且含三部分,或本项已标记 cancelled。
40
+
41
+ ## 执行约束
42
+
43
+ - **禁止 WebFetch 或任何网络请求**;素材只来自 `source`。
44
+ - **cn_length 字数规则**(唯一定义处,各 format prompt 文件引用本条):中文字符算 1,非中文字符(英文/数字/符号)算 0.5,结果向上取整。
45
+ - 中间文件只写入 `{{run_dir}}`;除 `output` 指定文件外禁止在工作目录写入任何持久文件。
46
+ - 所有重试上限 3 次;短路命中即结束,禁止继续执行或"降级放行"(schema 校验不通过不得交付;`count` 是精确值,不多不少)。