@wwkit/harness 1.0.33 → 1.0.35
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/LICENSE +21 -21
- package/README.md +128 -128
- package/agents/scrum.md +206 -186
- package/agents/sprint.md +130 -121
- package/bin/index.js +291 -226
- package/commands/fix.md +87 -87
- package/commands/git-sync.md +217 -217
- package/commands/net-port.md +364 -364
- package/commands/pytest.md +10 -10
- package/commands/resume.md +104 -104
- package/commands/tl.md +11 -11
- package/commands/tsl.md +12 -0
- package/package.json +5 -4
- package/plugin.js +19 -19
- package/readme/development.md +39 -39
- package/readme/publish.md +41 -41
- package/readme/testing.md +44 -44
- package/scripts/postinstall.js +58 -58
- package/skills/better-agents/SKILL.md +300 -0
- package/skills/better-agents/references/evidence-map.md +102 -0
- package/skills/better-agents/references/format-spec.md +91 -0
- package/skills/better-agents/references/section-template.md +116 -0
- package/skills/better-skill/SKILL.md +319 -124
- package/skills/better-skill/references/new-mode.md +126 -0
- package/skills/blame-agents/SKILL.md +270 -0
- package/skills/blame-agents/references/check-agents.js +364 -0
- package/skills/blame-agents/references/scoring-rules.md +259 -0
- package/skills/blame-skill/SKILL.md +163 -201
- package/skills/blame-skill/references/scoring-rules.md +190 -0
- package/skills/blame-sprint-agent/SKILL.md +172 -0
- package/skills/blame-sprint-agent/references/scoring-rules.md +113 -0
- package/skills/blame-sprint-skill/SKILL.md +165 -0
- package/skills/blame-sprint-skill/references/scoring-rules.md +101 -0
- package/skills/extract/SKILL.md +119 -119
- package/skills/extract/references/build-xpath.js +30 -30
- package/skills/extract/references/clean-html.js +90 -90
- package/skills/extract/references/detail.md +54 -54
- package/skills/extract/references/detail.schema.json5 +48 -48
- package/skills/extract/references/extract-detail.js +71 -71
- package/skills/extract/references/extract-regex.js +81 -81
- package/skills/extract/references/extract-sample.js +48 -48
- package/skills/extract/references/list-rule-gen.md +109 -109
- package/skills/extract/references/list.md +134 -134
- package/skills/extract/references/list.schema.json5 +33 -33
- package/skills/extract/references/navi.md +44 -44
- package/skills/extract/references/navi.schema.json5 +23 -23
- package/skills/extract/references/text.md +40 -40
- package/skills/extract/references/text.schema.json5 +21 -21
- package/skills/extract/references/to-text.js +20 -20
- package/skills/extract/references/validate-schema.js +39 -39
- package/skills/jstest/SKILL.md +561 -561
- package/skills/jstest/references/case-create.md +327 -327
- package/skills/jstest/references/case-fix.md +273 -273
- package/skills/jstest/references/config.md +148 -148
- package/skills/jstest/references/coverage-analyze.md +247 -247
- package/skills/jstest/references/env-ensure.md +210 -210
- package/skills/jstest/references/execute.md +168 -168
- package/skills/jstest/references/sample.md +166 -166
- package/skills/jstest/references/scoring-rules.md +75 -75
- package/skills/jstest/references/src/jstest-sample/Calculator.js +80 -80
- package/skills/jstest/references/src/jstest-sample/ConfigManager.js +72 -72
- package/skills/jstest/references/src/jstest-sample/FileProcessor.js +57 -57
- package/skills/jstest/references/src/jstest-sample/OrderService.js +98 -98
- package/skills/jstest/references/src/jstest-sample/TokenGenerator.js +60 -60
- package/skills/jstest/references/src/jstest-sample/UserService.js +56 -56
- package/skills/jstest/references/src/jstest-sample/index.js +6 -6
- package/skills/jstest/references/suitability-check.md +232 -232
- package/skills/jstest/references/test-standards.md +288 -288
- package/skills/lint/SKILL.md +440 -440
- package/skills/lint/references/ai-fix.md +137 -137
- package/skills/lint/references/config-setup.md +102 -102
- package/skills/lint/references/config.md +65 -65
- package/skills/lint/references/detect-language.js +65 -65
- package/skills/lint/references/env-ensure.md +88 -88
- package/skills/lint/references/language-detect.md +75 -75
- package/skills/lint/references/languages/js.md +110 -110
- package/skills/lint/references/languages/py.md +89 -89
- package/skills/lint/references/rules-analyze.md +125 -125
- package/skills/lint/references/suitability-check.md +81 -81
- package/skills/lint/references/tool-fix.md +90 -90
- package/skills/pytest/SKILL.md +555 -555
- package/skills/pytest/references/case-create.md +324 -324
- package/skills/pytest/references/case-fix.md +271 -271
- package/skills/pytest/references/config.md +145 -145
- package/skills/pytest/references/coverage-analyze.md +223 -223
- package/skills/pytest/references/env-ensure.md +195 -195
- package/skills/pytest/references/execute.md +152 -152
- package/skills/pytest/references/sample.md +159 -159
- package/skills/pytest/references/scoring-rules.md +57 -57
- package/skills/pytest/references/src/pytest-sample/Calculator.py +67 -67
- package/skills/pytest/references/src/pytest-sample/ConfigManager.py +68 -68
- package/skills/pytest/references/src/pytest-sample/FileProcessor.py +53 -53
- package/skills/pytest/references/src/pytest-sample/OrderService.py +82 -82
- package/skills/pytest/references/src/pytest-sample/TokenGenerator.py +50 -50
- package/skills/pytest/references/src/pytest-sample/UserService.py +45 -45
- package/skills/pytest/references/suitability-check.md +220 -220
- package/skills/pytest/references/test-standards.md +244 -244
- package/skills/query/SKILL.md +71 -71
- package/skills/read-docs/SKILL.md +134 -134
- package/skills/read-docs/references/opencode/agents/cases.md +206 -206
- package/skills/read-docs/references/opencode/agents/design-pattern.md +47 -47
- package/skills/read-docs/references/opencode/agents/detail.md +191 -191
- package/skills/read-docs/references/opencode/agents/examples.md +100 -100
- package/skills/read-docs/references/opencode/agents/index.md +309 -309
- package/skills/read-docs/references/opencode/agents/parallel-dispatch.md +149 -149
- package/skills/read-docs/references/opencode/agents/subagent-internals.md +217 -217
- package/skills/read-docs/references/opencode/agents/workflow.md +161 -161
- package/skills/read-docs/references/opencode/cli/commands/acp.md +31 -31
- package/skills/read-docs/references/opencode/cli/commands/agent.md +16 -16
- package/skills/read-docs/references/opencode/cli/commands/attach.md +20 -20
- package/skills/read-docs/references/opencode/cli/commands/mcp.md +37 -37
- package/skills/read-docs/references/opencode/cli/commands/others.md +48 -48
- package/skills/read-docs/references/opencode/cli/commands/plugin.md +12 -12
- package/skills/read-docs/references/opencode/cli/commands/provider.md +43 -43
- package/skills/read-docs/references/opencode/cli/commands/run.md +81 -81
- package/skills/read-docs/references/opencode/cli/commands/serve.md +84 -84
- package/skills/read-docs/references/opencode/cli/commands/session.md +37 -37
- package/skills/read-docs/references/opencode/cli/commands/web.md +14 -14
- package/skills/read-docs/references/opencode/cli/env.md +38 -38
- package/skills/read-docs/references/opencode/cli/index.md +18 -18
- package/skills/read-docs/references/opencode/cli/tui.md +35 -35
- package/skills/read-docs/references/opencode/commands/examples.md +42 -42
- package/skills/read-docs/references/opencode/commands/index.md +185 -185
- package/skills/read-docs/references/opencode/config/provider.md +151 -151
- package/skills/read-docs/references/opencode/formatter/index.md +70 -70
- package/skills/read-docs/references/opencode/guide/config.md +419 -419
- package/skills/read-docs/references/opencode/guide/formatters.md +70 -70
- package/skills/read-docs/references/opencode/guide/index.md +37 -37
- package/skills/read-docs/references/opencode/guide/providers.md +31 -31
- package/skills/read-docs/references/opencode/guide/rules.md +63 -63
- package/skills/read-docs/references/opencode/plugins/examples.md +75 -75
- package/skills/read-docs/references/opencode/plugins/index.md +188 -188
- package/skills/read-docs/references/opencode/reference/index.md +118 -118
- package/skills/read-docs/references/opencode/rule/index.md +77 -77
- package/skills/read-docs/references/opencode/skills/detail.md +113 -113
- package/skills/read-docs/references/opencode/skills/examples.md +141 -141
- package/skills/read-docs/references/opencode/skills/index.md +126 -126
- package/skills/read-docs/references/opencode/skills/workflow.md +146 -146
- package/skills/read-docs/references/opencode/tests/agent.md +9 -9
- package/skills/read-docs/references/opencode/tests/config.md +59 -59
- package/skills/read-docs/references/opencode/tests/file.md +11 -11
- package/skills/read-docs/references/opencode/tests/serve.md +17 -17
- package/skills/read-docs/references/opencode/tests/session.md +30 -30
- package/skills/read-docs/references/opencode/tests/web.md +16 -16
- package/skills/read-docs/references/opencode/tools/arguments.md +305 -305
- package/skills/read-docs/references/opencode/tools/context.md +17 -17
- package/skills/read-docs/references/opencode/tools/custom.md +110 -110
- package/skills/read-docs/references/opencode/tools/detail.md +104 -104
- package/skills/read-docs/references/opencode/tools/examples.md +71 -71
- package/skills/read-docs/references/opencode/tools/index.md +56 -56
- package/skills/read-docs/references/opencode/tools/lsp.md +25 -25
- package/skills/read-docs/references/opencode/tools/mcp.md +132 -132
- package/skills/read-docs/references/opencode/train/README.md +134 -134
- package/skills/read-docs/references/opencode/train/agent-basic.md +771 -771
- package/skills/read-docs/references/opencode/train/command-basic.md +667 -667
- package/skills/read-docs/references/opencode/train/config-basic.md +508 -508
- package/skills/read-docs/references/opencode/train/index.md +163 -163
- package/skills/read-docs/references/opencode/train/practice.md +872 -872
- package/skills/read-docs/references/opencode/train/skill-basic.md +607 -607
- package/skills/read-docs/references/opencode/tui/commands/config.md +31 -31
- package/skills/read-docs/references/opencode/tui/commands/editor.md +46 -46
- package/skills/read-docs/references/opencode/tui/commands/index.md +124 -124
- package/skills/read-docs/references/opencode/tui/commands/init.md +4 -4
- package/skills/read-docs/references/opencode/tui/index.md +26 -26
- package/skills/read-docs/references/superpowers/bootstrap.md +107 -107
- package/skills/read-docs/references/superpowers/comparison.md +77 -77
- package/skills/read-docs/references/superpowers/context.md +71 -71
- package/skills/read-docs/references/superpowers/index.md +58 -58
- package/skills/read-docs/references/superpowers/parallel.md +49 -49
- package/skills/read-docs/references/superpowers/sdd.md +183 -183
- package/skills/read-docs/references/superpowers/skills.md +68 -68
- package/skills/read-docs/references/superpowers/workflow.md +83 -83
- package/skills/revise/SKILL.md +121 -121
- package/skills/revise/references/article.md +36 -36
- package/skills/revise/references/article.schema.json5 +40 -40
- package/skills/revise/references/gallery.md +34 -34
- package/skills/revise/references/gallery.schema.json5 +40 -40
- package/skills/revise/references/question.md +32 -32
- package/skills/revise/references/question.schema.json5 +31 -31
- package/skills/revise/references/status.md +31 -31
- package/skills/revise/references/status.schema.json5 +27 -27
- package/skills/revise/references/validate-schema.js +39 -39
- package/skills/step-extract/SKILL.md +205 -0
- package/skills/tsl/SKILL.md +393 -0
- package/skills/tsl/package.json +10 -0
- package/skills/tsl/references/global-review-rules.md +25 -0
- package/skills/tsl/references/prepare-prompt.md +150 -0
- package/skills/tsl/references/terminology-rules.md +93 -0
- package/skills/tsl/references/translation-guide.md +23 -0
- package/skills/tsl/references/translation-prompt.md +115 -0
- package/skills/tsl/references/translation-rules.md +48 -0
- package/skills/tsl/references/verification-rules.md +58 -0
- package/skills/tsl/scripts/check-boundaries.js +140 -0
- package/skills/tsl/scripts/chunk-text.js +144 -0
- package/skills/tsl/scripts/clean-text.js +121 -0
- package/skills/tsl/scripts/cleanup-glossary.js +160 -0
- package/skills/tsl/scripts/extract-pdf.js +94 -0
- package/skills/tsl/scripts/generate-review.js +179 -0
- package/skills/tsl/scripts/merge-result.js +164 -0
- package/skills/tsl/scripts/verify-chunk.js +170 -0
- package/skills/tsl-format/SKILL.md +298 -0
- package/skills/tsl-format/references/format-prompt.md +103 -0
- package/skills/tsl-format/references/format-rules.md +58 -0
- package/skills/tsl-format/scripts/chunk-bilingual.js +96 -0
- package/skills/tsl-format/scripts/merge-format.js +105 -0
- package/src/config.js +29 -29
- package/src/config.json5 +19 -19
- package/skills/new-skill/SKILL.md +0 -227
- package/skills/new-skill/references/template.md +0 -53
- package/skills/new-skill/references/workflow-patterns.md +0 -104
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# 格式化 subagent dispatch prompt 模板
|
|
2
|
+
|
|
3
|
+
主 Agent 使用此模板派发格式化 subagent。**每个 subagent 只处理 1 个 chunk,并发最多 5 个 subagent。**
|
|
4
|
+
|
|
5
|
+
**只替换 `{{变量}}`,不修改其他内容。**
|
|
6
|
+
|
|
7
|
+
## 变量
|
|
8
|
+
|
|
9
|
+
| 变量 | 说明 | 示例 |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| `{{work_dir}}` | 临时工作目录 | `<input_dir>/.tsl-format-tmp/` |
|
|
12
|
+
| `{{chunk_file}}` | chunk 文件路径 | `<work_dir>/p001.md` |
|
|
13
|
+
| `{{chunk_id}}` | chunk 编号 | `p001` |
|
|
14
|
+
| `{{format_rules_path}}` | 格式规则路径 | `<技能目录>/references/format-rules.md` |
|
|
15
|
+
|
|
16
|
+
## dispatch prompt 正文
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
你是格式化 subagent。只处理 1 个 chunk,处理完即结束。
|
|
20
|
+
按固定 Sprint 范式执行,不执行步骤以外的操作。
|
|
21
|
+
|
|
22
|
+
## Sprint Goal
|
|
23
|
+
|
|
24
|
+
将 1 个 chunk 的双语对照内容按格式规则添加 Markdown 标记,写入 result 文件供主 Agent 合并。
|
|
25
|
+
|
|
26
|
+
## Increment
|
|
27
|
+
|
|
28
|
+
subagent 产出 `{{work_dir}}/result-{{chunk_id}}.md`。主 Agent 不直接读取内容,通过 `merge-format.js` 合并(自动提取格式化内容、更新 progress.md)。
|
|
29
|
+
|
|
30
|
+
| 格式化结果 | result 文件内容 |
|
|
31
|
+
|---|---|
|
|
32
|
+
| VALID | 格式化内容 + `## status\n\nVALID` |
|
|
33
|
+
| FAILED | 仅 `## status\n\nFAILED`(无内容) |
|
|
34
|
+
|
|
35
|
+
## 固定 Sprint Backlog(3 项,todowrite 落单,覆盖历史 todos)
|
|
36
|
+
|
|
37
|
+
1. 读取参考文件 | DoD: 格式规则已读取
|
|
38
|
+
2. 格式重建 | DoD: chunk 已按格式规则添加 Markdown 标记
|
|
39
|
+
3. 写入 result 文件 | DoD: result-{{chunk_id}}.md 已写入,格式正确
|
|
40
|
+
|
|
41
|
+
## Sprint Execution
|
|
42
|
+
|
|
43
|
+
按 Backlog 逐项执行。进入 Item 前标记 in_progress → 执行 → 验证 DoD → 标记 completed。
|
|
44
|
+
|
|
45
|
+
### Item 1:读取参考文件
|
|
46
|
+
|
|
47
|
+
用 `read` 工具读取以下文件:
|
|
48
|
+
1. {{format_rules_path}}
|
|
49
|
+
|
|
50
|
+
### Item 2:格式重建
|
|
51
|
+
|
|
52
|
+
1. `read` {{chunk_file}}
|
|
53
|
+
2. 按格式规则添加 Markdown 标记(标题 `#`、关键术语 `**`、作品名/外来语 `*`)
|
|
54
|
+
3. 保留原有标记、双语结构、脚注 `[^N]`、`[CONT]` 标记、段落分隔
|
|
55
|
+
|
|
56
|
+
**裁决规则**(遇到不确定是否为标题的行):
|
|
57
|
+
- 短行(< 10 词)+ 独占段落 + 前后有空行 + 非完整句子 → 标题
|
|
58
|
+
- 有主谓宾结构 → 段落,非标题
|
|
59
|
+
- 无法判断 → 不标记(宁可不标记,不误标记)
|
|
60
|
+
|
|
61
|
+
**禁止事项**:
|
|
62
|
+
- 不修改译文内容(不改字词、不调语序)
|
|
63
|
+
- 不合并或拆分段落
|
|
64
|
+
- 不添加解释、注释或总结
|
|
65
|
+
- 不删除任何内容
|
|
66
|
+
- 不创造原文内容中没有的结构
|
|
67
|
+
|
|
68
|
+
### Item 3:写入 result 文件
|
|
69
|
+
|
|
70
|
+
用 `write` 工具写入 `{{work_dir}}/result-{{chunk_id}}.md`。
|
|
71
|
+
|
|
72
|
+
**VALID** 时格式:
|
|
73
|
+
```
|
|
74
|
+
(格式化后的双语对照内容)
|
|
75
|
+
|
|
76
|
+
## status
|
|
77
|
+
|
|
78
|
+
VALID
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**FAILED** 时格式(无内容):
|
|
82
|
+
```
|
|
83
|
+
## status
|
|
84
|
+
|
|
85
|
+
FAILED
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Sprint Review
|
|
89
|
+
|
|
90
|
+
验证 Increment(`result-{{chunk_id}}.md`)已写入且格式正确:
|
|
91
|
+
- VALID:含格式化内容 + `## status\n\nVALID`
|
|
92
|
+
- FAILED:仅含 `## status\n\nFAILED`
|
|
93
|
+
|
|
94
|
+
**格式化失败时不重试。** 主 Agent 会在下一批重新分派。
|
|
95
|
+
|
|
96
|
+
## 禁止事项
|
|
97
|
+
|
|
98
|
+
- 不直接写 `{{work_dir}}/formatted.md`
|
|
99
|
+
- 不直接写 `{{work_dir}}/progress.md`
|
|
100
|
+
- 不写 `/tmp/` 下任何文件
|
|
101
|
+
- 不处理 {{chunk_file}} 以外的 chunk
|
|
102
|
+
- 不执行格式重建以外的操作(不翻译、不清洗、不输出到 dist/)
|
|
103
|
+
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# 格式重建规则(Format Rules)
|
|
2
|
+
|
|
3
|
+
## 目标
|
|
4
|
+
|
|
5
|
+
对已翻译的双语对照文档补充 Markdown 格式标记,不改变内容。
|
|
6
|
+
|
|
7
|
+
## 格式规则
|
|
8
|
+
|
|
9
|
+
### 1. 标题
|
|
10
|
+
|
|
11
|
+
根据文档结构识别标题层级,用 `#`~`######` 标记:
|
|
12
|
+
|
|
13
|
+
| 标题类型 | 层级 | 判断依据 |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| 文档总标题 | `#` | 文件第一个独占段落,通常含书名 |
|
|
16
|
+
| 章节/部分标题 | `##` | 独占段落、短行(< 10 词)、非完整句子、前后有空行 |
|
|
17
|
+
| 小节标题 | `###` | 同上,但层级在章节之下 |
|
|
18
|
+
| 子小节标题 | `####` | 同上,但层级在小节之下 |
|
|
19
|
+
|
|
20
|
+
**裁决规则**(遇到不确定的行):
|
|
21
|
+
- 短行 + 独占段落 + 前后有空行 + 非完整句子(无主谓宾)→ 标题
|
|
22
|
+
- 有主谓宾结构 → 段落,非标题
|
|
23
|
+
- 无法判断 → 不标记(宁可不标记,不误标记)
|
|
24
|
+
|
|
25
|
+
### 2. 粗体
|
|
26
|
+
|
|
27
|
+
关键术语**首次出现**用 `**` 标记:
|
|
28
|
+
|
|
29
|
+
- 哲学/科学核心概念(如 **认识论**、**生机论**)
|
|
30
|
+
- 人名首次出现(如 **康吉莱姆**)
|
|
31
|
+
- 不重复标记已出现过的术语
|
|
32
|
+
|
|
33
|
+
### 3. 斜体
|
|
34
|
+
|
|
35
|
+
用 `*` 标记:
|
|
36
|
+
|
|
37
|
+
- 作品名(书名、文章名、期刊名)——如 *Études d'histoire et de philosophie des sciences*
|
|
38
|
+
- 外来语(非目标语言的词)——如 *a priori*
|
|
39
|
+
- 强调
|
|
40
|
+
|
|
41
|
+
### 4. 保留
|
|
42
|
+
|
|
43
|
+
以下内容**保留原样**,不修改:
|
|
44
|
+
|
|
45
|
+
- 已有的 Markdown 标记 → 保留
|
|
46
|
+
- 双语对照结构(原文段 → 译文段)→ 不变
|
|
47
|
+
- 脚注 `[^N]` → 保留
|
|
48
|
+
- `[CONT]` 标记 → 保留
|
|
49
|
+
- 段落分隔(空行)→ 保留
|
|
50
|
+
- 脚注内容格式 `原文 | 译文:译文。` → 保留
|
|
51
|
+
|
|
52
|
+
### 5. 禁止
|
|
53
|
+
|
|
54
|
+
- **不创造**原文内容中没有的结构
|
|
55
|
+
- **不合并或拆分**段落
|
|
56
|
+
- **不修改**译文内容(不改字词、不调语序)
|
|
57
|
+
- **不添加**解释、注释或总结
|
|
58
|
+
- **不删除**任何内容
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* chunk-bilingual.js — 双语文档分块脚本(ESM,纯 JS,无依赖)
|
|
4
|
+
*
|
|
5
|
+
* 按段落边界(空行分隔)将双语对照 .md 文件分块,每块 ≤ chunk_words 词数。
|
|
6
|
+
* 不拆分段落——一个段落整体属于一个块。
|
|
7
|
+
*
|
|
8
|
+
* 用法:node chunk-bilingual.js <input.md> <chunk_words> <output_dir>
|
|
9
|
+
* stdout 打印总块数
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';
|
|
13
|
+
import { join } from 'path';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 将文本按段落边界分块。
|
|
17
|
+
* @param {string} content — 文本内容
|
|
18
|
+
* @param {number} chunkWords — 每块最大词数
|
|
19
|
+
* @returns {string[]} 分块数组
|
|
20
|
+
*/
|
|
21
|
+
export function chunkBilingual(content, chunkWords) {
|
|
22
|
+
if (!content || !content.trim()) return [];
|
|
23
|
+
|
|
24
|
+
// Split by double newline (paragraph boundaries)
|
|
25
|
+
const paragraphs = content.split(/\n\n+/);
|
|
26
|
+
|
|
27
|
+
const chunks = [];
|
|
28
|
+
let currentChunk = [];
|
|
29
|
+
let currentWords = 0;
|
|
30
|
+
|
|
31
|
+
for (const para of paragraphs) {
|
|
32
|
+
const trimmed = para.trim();
|
|
33
|
+
if (!trimmed) continue;
|
|
34
|
+
|
|
35
|
+
const words = trimmed.split(/\s+/).filter(Boolean).length;
|
|
36
|
+
|
|
37
|
+
// If adding this paragraph exceeds limit and we have content, start new chunk
|
|
38
|
+
if (currentWords + words > chunkWords && currentChunk.length > 0) {
|
|
39
|
+
chunks.push(currentChunk.join('\n\n'));
|
|
40
|
+
currentChunk = [trimmed];
|
|
41
|
+
currentWords = words;
|
|
42
|
+
} else {
|
|
43
|
+
currentChunk.push(trimmed);
|
|
44
|
+
currentWords += words;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (currentChunk.length > 0) {
|
|
49
|
+
chunks.push(currentChunk.join('\n\n'));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return chunks;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// --- CLI ---
|
|
56
|
+
|
|
57
|
+
const isMain = import.meta.url === `file://${process.argv[1]}`;
|
|
58
|
+
|
|
59
|
+
if (isMain) {
|
|
60
|
+
const args = process.argv.slice(2);
|
|
61
|
+
|
|
62
|
+
if (args.length < 3) {
|
|
63
|
+
console.error('Usage: node chunk-bilingual.js <input.md> <chunk_words> <output_dir>');
|
|
64
|
+
process.exit(2);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const [inputPath, chunkWordsStr, outputDir] = args;
|
|
68
|
+
const chunkWords = parseInt(chunkWordsStr, 10);
|
|
69
|
+
|
|
70
|
+
if (!existsSync(inputPath)) {
|
|
71
|
+
console.error(`ERROR: input file not found: ${inputPath}`);
|
|
72
|
+
process.exit(2);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (isNaN(chunkWords) || chunkWords < 100) {
|
|
76
|
+
console.error('ERROR: chunk_words must be a number >= 100');
|
|
77
|
+
process.exit(2);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const content = readFileSync(inputPath, 'utf-8');
|
|
81
|
+
const chunks = chunkBilingual(content, chunkWords);
|
|
82
|
+
|
|
83
|
+
if (chunks.length === 0) {
|
|
84
|
+
console.error('ERROR: input file is empty or contains no paragraphs');
|
|
85
|
+
process.exit(2);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
mkdirSync(outputDir, { recursive: true });
|
|
89
|
+
|
|
90
|
+
chunks.forEach((chunk, i) => {
|
|
91
|
+
const num = String(i + 1).padStart(3, '0');
|
|
92
|
+
writeFileSync(join(outputDir, `p${num}.md`), chunk + '\n', 'utf-8');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
console.log(`chunks: ${chunks.length}`);
|
|
96
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* merge-format.js — 合并 subagent 格式化结果到主产物(ESM)
|
|
4
|
+
*
|
|
5
|
+
* 用法:node merge-format.js <result-file> <work-dir> <chunk-id>
|
|
6
|
+
* <chunk-id> = chunk 编号,如 p001(与 result 文件名和 progress.md 行匹配)
|
|
7
|
+
*
|
|
8
|
+
* 功能(全部在脚本内完成,主 Agent 上下文只获得一行输出):
|
|
9
|
+
* 1. 解析 result-pNNN.md:格式化内容 / status
|
|
10
|
+
* 2. VALID → 追加格式化内容到 <work-dir>/formatted.md
|
|
11
|
+
* 3. 更新 <work-dir>/progress.md(VALID→done,FAILED→failed+retry+1)
|
|
12
|
+
* 4. 删除 result 文件
|
|
13
|
+
* 5. stdout:`pNNN VALID` 或 `pNNN FAILED`
|
|
14
|
+
*
|
|
15
|
+
* 主 Agent 上下文只获得一行 status 输出,完整格式化内容不进入上下文。
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { readFileSync, writeFileSync, unlinkSync, existsSync } from 'fs';
|
|
19
|
+
import { join } from 'path';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 合并单个 result 文件到主产物。
|
|
23
|
+
* @param {string} resultFile - result-pNNN.md 路径
|
|
24
|
+
* @param {string} workDir - 工作目录(含 formatted.md 和 progress.md)
|
|
25
|
+
* @param {string} chunkId - chunk 编号(如 p001)
|
|
26
|
+
* @returns {{ chunkId: string, status: string }} 合并结果
|
|
27
|
+
* @throws {Error} 参数缺失 / 文件不存在 / 格式错误
|
|
28
|
+
*/
|
|
29
|
+
export function mergeFormat(resultFile, workDir, chunkId) {
|
|
30
|
+
if (!resultFile || !workDir || !chunkId) {
|
|
31
|
+
throw new Error('Usage: node merge-format.js <result-file> <work-dir> <chunk-id>');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!existsSync(resultFile)) {
|
|
35
|
+
throw new Error(`Result file not found: ${resultFile}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const content = readFileSync(resultFile, 'utf-8');
|
|
39
|
+
|
|
40
|
+
// --- Parse result file ---
|
|
41
|
+
|
|
42
|
+
// Status: first VALID or FAILED after ## status
|
|
43
|
+
const statusMatch = content.match(/^## status\s*\n\s*(VALID|FAILED)/m);
|
|
44
|
+
if (!statusMatch) {
|
|
45
|
+
throw new Error(`No ## status found in ${resultFile}`);
|
|
46
|
+
}
|
|
47
|
+
const status = statusMatch[1];
|
|
48
|
+
const statusPos = content.indexOf('## status');
|
|
49
|
+
|
|
50
|
+
// Formatted content = everything before ## status
|
|
51
|
+
const formattedContent = content.substring(0, statusPos).trim();
|
|
52
|
+
|
|
53
|
+
// --- 1. Append formatted content (VALID only) ---
|
|
54
|
+
|
|
55
|
+
if (status === 'VALID' && formattedContent) {
|
|
56
|
+
const formattedPath = join(workDir, 'formatted.md');
|
|
57
|
+
if (existsSync(formattedPath)) {
|
|
58
|
+
const existing = readFileSync(formattedPath, 'utf-8');
|
|
59
|
+
const sep = existing.endsWith('\n') ? '' : '\n';
|
|
60
|
+
writeFileSync(formattedPath, existing + sep + formattedContent + '\n');
|
|
61
|
+
} else {
|
|
62
|
+
writeFileSync(formattedPath, formattedContent + '\n');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// --- 2. Update progress.md ---
|
|
67
|
+
|
|
68
|
+
const progressPath = join(workDir, 'progress.md');
|
|
69
|
+
const progress = readFileSync(progressPath, 'utf-8');
|
|
70
|
+
const lines = progress.split('\n');
|
|
71
|
+
const updatedLines = lines.map(line => {
|
|
72
|
+
const match = line.match(/^\| (p\d+) \| (\w+) \| (\d+) \|$/);
|
|
73
|
+
if (match && match[1] === chunkId) {
|
|
74
|
+
if (status === 'VALID') {
|
|
75
|
+
return `| ${chunkId} | done | ${match[3]} |`;
|
|
76
|
+
} else {
|
|
77
|
+
return `| ${chunkId} | failed | ${parseInt(match[3], 10) + 1} |`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return line;
|
|
81
|
+
});
|
|
82
|
+
writeFileSync(progressPath, updatedLines.join('\n'));
|
|
83
|
+
|
|
84
|
+
// --- 3. Delete result file ---
|
|
85
|
+
|
|
86
|
+
unlinkSync(resultFile);
|
|
87
|
+
|
|
88
|
+
// --- 4. Return result ---
|
|
89
|
+
|
|
90
|
+
return { chunkId, status };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// --- CLI entry point (only when run directly, not when imported) ---
|
|
94
|
+
|
|
95
|
+
const isMain = import.meta.url === `file://${process.argv[1]}`;
|
|
96
|
+
if (isMain) {
|
|
97
|
+
const [,, resultFile, workDir, chunkId] = process.argv;
|
|
98
|
+
try {
|
|
99
|
+
const result = mergeFormat(resultFile, workDir, chunkId);
|
|
100
|
+
console.log(`${result.chunkId} ${result.status}`);
|
|
101
|
+
} catch (e) {
|
|
102
|
+
console.error(e.message);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
}
|
package/src/config.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
// src/config.js — harness 配置加载(只读参考 + 初始化检测)
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import { fileURLToPath } from 'node:url'
|
|
4
|
-
import { createConfigLoader, getXdgConfigDir } from '@wwkit/shared'
|
|
5
|
-
|
|
6
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
7
|
-
|
|
8
|
-
const _loader = createConfigLoader({
|
|
9
|
-
builtinConfigPath: path.join(__dirname, 'config.json5'),
|
|
10
|
-
userConfigDir: getXdgConfigDir('harness'),
|
|
11
|
-
envContentVar: 'HARNESS_CONFIG_CONTENT',
|
|
12
|
-
envDirVar: 'HARNESS_CONFIG_DIR',
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 获取用户配置文件路径
|
|
17
|
-
* @returns {string}
|
|
18
|
-
*/
|
|
19
|
-
export function getConfigPath() {
|
|
20
|
-
return _loader.userConfigPath
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 合并内置配置到用户配置文件(追加缺失 key,不覆盖已有值)
|
|
25
|
-
* @returns {boolean} 是否写入了文件
|
|
26
|
-
*/
|
|
27
|
-
export function mergeBuiltinConfig() {
|
|
28
|
-
return _loader.mergeBuiltinConfig()
|
|
29
|
-
}
|
|
1
|
+
// src/config.js — harness 配置加载(只读参考 + 初始化检测)
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
import { createConfigLoader, getXdgConfigDir } from '@wwkit/shared'
|
|
5
|
+
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
7
|
+
|
|
8
|
+
const _loader = createConfigLoader({
|
|
9
|
+
builtinConfigPath: path.join(__dirname, 'config.json5'),
|
|
10
|
+
userConfigDir: getXdgConfigDir('harness'),
|
|
11
|
+
envContentVar: 'HARNESS_CONFIG_CONTENT',
|
|
12
|
+
envDirVar: 'HARNESS_CONFIG_DIR',
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 获取用户配置文件路径
|
|
17
|
+
* @returns {string}
|
|
18
|
+
*/
|
|
19
|
+
export function getConfigPath() {
|
|
20
|
+
return _loader.userConfigPath
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 合并内置配置到用户配置文件(追加缺失 key,不覆盖已有值)
|
|
25
|
+
* @returns {boolean} 是否写入了文件
|
|
26
|
+
*/
|
|
27
|
+
export function mergeBuiltinConfig() {
|
|
28
|
+
return _loader.mergeBuiltinConfig()
|
|
29
|
+
}
|
package/src/config.json5
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
// config.json5 — harness 内置配置(只读参考)
|
|
2
|
-
//
|
|
3
|
-
// 此文件为只读配置,由 postinstall 或首次运行时复制到
|
|
4
|
-
// ~/.config/harness/config.json5(或 $XDG_CONFIG_HOME/harness/config.json5)。
|
|
5
|
-
// 实际运行配置通过环境变量生效,此文件主要用于:
|
|
6
|
-
// 1. 配置初始化检测(existsSync 判断是否需要复制)
|
|
7
|
-
// 2. 文档参考(记录 harness 依赖的环境变量)
|
|
8
|
-
//
|
|
9
|
-
// 修改此文件不会影响运行时行为,请通过 shell profile 直接管理环境变量。
|
|
10
|
-
|
|
11
|
-
{
|
|
12
|
-
// 环境变量声明(只读 — 由 postinstall 通过 Shell.setEnvVar 自动设置)
|
|
13
|
-
env: {
|
|
14
|
-
// harness 包安装目录(agents/skills/commands 所在路径)
|
|
15
|
-
OPENCODE_CONFIG_DIR: "",
|
|
16
|
-
// 启用 opencode 实验性 LSP 工具
|
|
17
|
-
OPENCODE_EXPERIMENTAL_LSP_TOOL: "true",
|
|
18
|
-
},
|
|
19
|
-
}
|
|
1
|
+
// config.json5 — harness 内置配置(只读参考)
|
|
2
|
+
//
|
|
3
|
+
// 此文件为只读配置,由 postinstall 或首次运行时复制到
|
|
4
|
+
// ~/.config/harness/config.json5(或 $XDG_CONFIG_HOME/harness/config.json5)。
|
|
5
|
+
// 实际运行配置通过环境变量生效,此文件主要用于:
|
|
6
|
+
// 1. 配置初始化检测(existsSync 判断是否需要复制)
|
|
7
|
+
// 2. 文档参考(记录 harness 依赖的环境变量)
|
|
8
|
+
//
|
|
9
|
+
// 修改此文件不会影响运行时行为,请通过 shell profile 直接管理环境变量。
|
|
10
|
+
|
|
11
|
+
{
|
|
12
|
+
// 环境变量声明(只读 — 由 postinstall 通过 Shell.setEnvVar 自动设置)
|
|
13
|
+
env: {
|
|
14
|
+
// harness 包安装目录(agents/skills/commands 所在路径)
|
|
15
|
+
OPENCODE_CONFIG_DIR: "",
|
|
16
|
+
// 启用 opencode 实验性 LSP 工具
|
|
17
|
+
OPENCODE_EXPERIMENTAL_LSP_TOOL: "true",
|
|
18
|
+
},
|
|
19
|
+
}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: new-skill
|
|
3
|
-
description: |
|
|
4
|
-
交互式引导创建符合最佳实践的 OpenCode Skill 定义文件,基于 blame-skill 评分规则逐项收集信息并生成高质量 SKILL.md。
|
|
5
|
-
提供:交互式引导流程、工作流模式参考、SKILL.md 模板、自动评分验证。
|
|
6
|
-
适用:新建 Skill 定义、Skill 脚手架生成、从零创建规范技能。
|
|
7
|
-
不适用:修改已有 Skill(使用 better-skill)、审查 Skill 质量(使用 blame-skill)、非 SKILL.md 文件创建。
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Skill 创建向导
|
|
11
|
-
|
|
12
|
-
## 工作流模式
|
|
13
|
-
|
|
14
|
-
本 Skill 采用 **上下文感知** 工作流:
|
|
15
|
-
|
|
16
|
-
1. **收集**:通过交互式问答逐项收集 Skill 定义所需信息
|
|
17
|
-
2. **决策**:根据收集的信息选择工作流模式和步骤设计
|
|
18
|
-
3. **生成**:基于模板和收集的信息生成 SKILL.md 及 references/ 文件
|
|
19
|
-
4. **验证**:调用 blame-skill 评分,确保达到 B 级(75分)以上
|
|
20
|
-
|
|
21
|
-
## 输入
|
|
22
|
-
|
|
23
|
-
| 参数 | 必填 | 类型 | 说明 |
|
|
24
|
-
|------|------|------|------|
|
|
25
|
-
| name | 是 | 字符串 | Skill 名称,须符合 `^[a-z0-9]+(-[a-z0-9]+)*$` 格式 |
|
|
26
|
-
| 其他信息 | 否 | 交互收集 | 通过阶段一的问答逐步收集,用户也可一次性提供 |
|
|
27
|
-
|
|
28
|
-
## 输出
|
|
29
|
-
|
|
30
|
-
- `packages/agent/src/skills/<name>/SKILL.md` — Skill 定义文件
|
|
31
|
-
- `packages/agent/src/skills/<name>/references/` — 参考文档目录(如需要)
|
|
32
|
-
- 创建报告(含 blame-skill 评分结果)
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
## 阶段一:收集
|
|
37
|
-
|
|
38
|
-
**输入**:用户提供的 name 参数(或全部信息)
|
|
39
|
-
|
|
40
|
-
**操作**:通过交互式问答,逐项收集 Skill 定义的 6 类信息。如果用户在调用时已提供完整信息,则跳过对应问答。
|
|
41
|
-
|
|
42
|
-
### 1.1 基本信息(对应 Frontmatter 规范 15 分)
|
|
43
|
-
|
|
44
|
-
向用户收集:
|
|
45
|
-
|
|
46
|
-
| # | 问题 | 对应字段 | 约束 |
|
|
47
|
-
|---|------|---------|------|
|
|
48
|
-
| 1 | Skill 名称? | name | 必须符合 `^[a-z0-9]+(-[a-z0-9]+)*$`,与目录名一致 |
|
|
49
|
-
| 2 | 一句话描述核心能力? | description.具体能力 | 如"根据X规则对Y执行Z操作" |
|
|
50
|
-
| 3 | 适用场景? | description.适用 | 如"首次执行、定期扫描、问题修复" |
|
|
51
|
-
| 4 | 不适用场景? | description.不适用 | 如"功能逻辑Bug修复、性能优化" |
|
|
52
|
-
| 5 | 提供的资源? | description.提供 | 如"规则库、修复策略、迭代验证" |
|
|
53
|
-
|
|
54
|
-
**description 拼接规则**:将 2-5 的回答拼接为完整 description,控制在 50-300 字符:
|
|
55
|
-
```
|
|
56
|
-
{{核心能力}}。提供:{{提供资源}}。适用:{{适用场景}}。不适用:{{不适用场景}}。
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### 1.2 工作流模式(对应工作流匹配 20 分)
|
|
60
|
-
|
|
61
|
-
向用户收集:
|
|
62
|
-
|
|
63
|
-
| # | 问题 | 说明 |
|
|
64
|
-
|---|------|------|
|
|
65
|
-
| 6 | Skill 的核心执行逻辑是哪种? | 展示 5 种工作流模式供选择 |
|
|
66
|
-
|
|
67
|
-
**展示选项**(读取 `references/workflow-patterns.md` 中的摘要):
|
|
68
|
-
|
|
69
|
-
| 模式 | 特征 | 典型场景 |
|
|
70
|
-
|------|------|---------|
|
|
71
|
-
| 顺序工作流 | 步骤按固定顺序执行,无循环 | 提交流程、部署、迁移 |
|
|
72
|
-
| 迭代优化 | 执行→检查→改进→再检查,循环直到达标 | 质量修复、评分达标 |
|
|
73
|
-
| 多 MCP 协调 | 协调多个外部技能/工具 | 跨系统操作、多技能编排 |
|
|
74
|
-
| 上下文感知 | 根据运行时条件动态选择路径 | 条件分支、多模式切换 |
|
|
75
|
-
| 领域智能 | 基于知识库推理匹配 | 规则匹配、智能推荐 |
|
|
76
|
-
|
|
77
|
-
用户选择后,告知该模式的必要定义项(如迭代优化需定义目标条件和最大迭代次数)。
|
|
78
|
-
|
|
79
|
-
### 1.3 步骤设计(对应工作流完整性 5 分 + 指令可执行 3 分)
|
|
80
|
-
|
|
81
|
-
向用户收集:
|
|
82
|
-
|
|
83
|
-
| # | 问题 | 说明 |
|
|
84
|
-
|---|------|------|
|
|
85
|
-
| 7 | 列出 Skill 的主要执行步骤 | 每个步骤用一句话描述做什么 |
|
|
86
|
-
| 8 | 每个步骤的输入和输出分别是什么? | 如"输入:规则列表;输出:违规项清单" |
|
|
87
|
-
| 9 | 哪些步骤之间有循环? | 仅迭代优化模式需要,定义循环条件和终止策略 |
|
|
88
|
-
|
|
89
|
-
**步骤设计原则**:
|
|
90
|
-
- 每个步骤必须有明确的输入和输出
|
|
91
|
-
- 步骤粒度适中:太粗("处理文件")→ 拆分;太细("读取第1行")→ 合并
|
|
92
|
-
- 迭代类步骤必须定义:目标条件、最大迭代次数、终止策略
|
|
93
|
-
- 协调类步骤必须定义:调用的技能/工具、数据传递方式
|
|
94
|
-
|
|
95
|
-
### 1.4 输入输出规范(对应输入输出规范 5 分)
|
|
96
|
-
|
|
97
|
-
向用户收集:
|
|
98
|
-
|
|
99
|
-
| # | 问题 | 说明 |
|
|
100
|
-
|---|------|------|
|
|
101
|
-
| 10 | Skill 接受哪些参数? | 参数名、是否必填、类型、说明 |
|
|
102
|
-
| 11 | Skill 产生哪些输出? | 输出文件、报告格式、副作用 |
|
|
103
|
-
|
|
104
|
-
### 1.5 失败处理(对应失败处理 4 分)
|
|
105
|
-
|
|
106
|
-
向用户收集:
|
|
107
|
-
|
|
108
|
-
| # | 问题 | 说明 |
|
|
109
|
-
|---|------|------|
|
|
110
|
-
| 12 | 可能遇到哪些失败场景? | 文件不存在、语法错误、外部调用失败等 |
|
|
111
|
-
| 13 | 每种失败如何处理? | 回滚、重试、降级、跳过、人工介入 |
|
|
112
|
-
|
|
113
|
-
### 1.6 边界与资源(对应边界说明 5 分 + 渐进式加载 5 分)
|
|
114
|
-
|
|
115
|
-
向用户收集:
|
|
116
|
-
|
|
117
|
-
| # | 问题 | 说明 |
|
|
118
|
-
|---|------|------|
|
|
119
|
-
| 14 | 一定要做的事情? | 列出 3-8 条核心约束 |
|
|
120
|
-
| 15 | 一定不要做的事情? | 列出 3-8 条禁止项 |
|
|
121
|
-
| 16 | 是否有大量参考数据? | 如规则库、模板、配置等,有则放入 references/ |
|
|
122
|
-
|
|
123
|
-
**输出**:完整的 Skill 定义信息清单
|
|
124
|
-
|
|
125
|
-
---
|
|
126
|
-
|
|
127
|
-
## 阶段二:生成
|
|
128
|
-
|
|
129
|
-
**输入**:阶段一收集的完整信息清单
|
|
130
|
-
|
|
131
|
-
**操作**:基于 `references/template.md` 模板和收集的信息,生成 SKILL.md 文件
|
|
132
|
-
|
|
133
|
-
**生成规则**:
|
|
134
|
-
|
|
135
|
-
1. **Frontmatter**:按模板格式拼接 name 和 description
|
|
136
|
-
2. **工作流声明**:在正文开头(一级标题后)添加工作流模式声明,列出步骤编号和名称
|
|
137
|
-
3. **输入输出表**:生成参数表和输出说明
|
|
138
|
-
4. **步骤正文**:每个步骤包含 `输入`/`操作`/`输出`/`失败`(如适用)四要素
|
|
139
|
-
5. **失败处理表**:汇总所有失败场景和处理方式
|
|
140
|
-
6. **一定要做/一定不要做**:列表格式
|
|
141
|
-
7. **references/ 目录**:如果用户提供了大量参考数据(规则库、模板等),创建对应文件
|
|
142
|
-
8. **行数控制**:主文件(SKILL.md)控制在 200 行以内,超出部分拆分到 references/
|
|
143
|
-
|
|
144
|
-
**输出**:
|
|
145
|
-
- `packages/agent/src/skills/<name>/SKILL.md`
|
|
146
|
-
- `packages/agent/src/skills/<name>/references/` 目录及文件(如需要)
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
## 阶段三:验证
|
|
151
|
-
|
|
152
|
-
**输入**:生成的 SKILL.md 文件路径
|
|
153
|
-
|
|
154
|
-
**操作**:调用 blame-skill 对生成的 Skill 进行审计评分
|
|
155
|
-
|
|
156
|
-
**输出**:评分结果
|
|
157
|
-
|
|
158
|
-
**决策**:
|
|
159
|
-
|
|
160
|
-
| 条件 | 动作 |
|
|
161
|
-
|------|------|
|
|
162
|
-
| 得分 >= 75(B 级) | 输出创建报告,流程结束 |
|
|
163
|
-
| 得分 < 75 且迭代次数 < 3 | 调用 better-skill 自动优化,回到验证 |
|
|
164
|
-
| 得分 < 75 且迭代次数 >= 3 | 输出创建报告(含未达标说明和改进建议),流程结束 |
|
|
165
|
-
|
|
166
|
-
---
|
|
167
|
-
|
|
168
|
-
## 阶段四:输出
|
|
169
|
-
|
|
170
|
-
**输入**:生成的文件 + 评分结果
|
|
171
|
-
|
|
172
|
-
**操作**:生成创建报告
|
|
173
|
-
|
|
174
|
-
**输出**:
|
|
175
|
-
|
|
176
|
-
```markdown
|
|
177
|
-
## Skill 创建报告:[name]
|
|
178
|
-
|
|
179
|
-
### 生成文件
|
|
180
|
-
- SKILL.md:[行数] 行
|
|
181
|
-
- references/:[文件列表]
|
|
182
|
-
|
|
183
|
-
### 评分结果
|
|
184
|
-
- 得分:XX / 100(等级:X)
|
|
185
|
-
- 各项得分:[来自 blame-skill 的分项得分]
|
|
186
|
-
|
|
187
|
-
### 后续建议
|
|
188
|
-
- [如有未达标项,列出改进建议]
|
|
189
|
-
- 可使用 better-skill 进一步优化至 A 级
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
---
|
|
193
|
-
|
|
194
|
-
## 失败处理
|
|
195
|
-
|
|
196
|
-
| 场景 | 处理方式 |
|
|
197
|
-
|------|---------|
|
|
198
|
-
| name 不符合命名规范 | 提示格式要求,要求用户重新输入 |
|
|
199
|
-
| 同名 Skill 已存在 | 提示用户确认是否覆盖,确认后继续 |
|
|
200
|
-
| 用户信息不完整 | 根据已有信息推断缺失项,用默认值填充并提示用户确认 |
|
|
201
|
-
| blame-skill 评分失败 | 跳过验证阶段,直接输出文件和手动验证建议 |
|
|
202
|
-
| better-skill 优化失败 | 输出当前文件和改进建议,由用户手动修改 |
|
|
203
|
-
|
|
204
|
-
## 一定要做
|
|
205
|
-
|
|
206
|
-
1. 按阶段一的问题顺序逐项收集信息,确保 6 类信息完整
|
|
207
|
-
2. 用户已提供的信息不重复询问
|
|
208
|
-
3. description 拼接后控制在 50-300 字符,包含具体能力、适用场景、不适用场景、提供资源
|
|
209
|
-
4. 工作流模式必须从 5 种标准模式中选择
|
|
210
|
-
5. 每个步骤必须定义输入和输出
|
|
211
|
-
6. 生成的 SKILL.md 必须包含工作流声明、输入输出表、失败处理、一定要做/一定不要做
|
|
212
|
-
7. 主文件控制在 200 行以内,超出部分拆分到 references/
|
|
213
|
-
8. 生成后必须调用 blame-skill 验证评分
|
|
214
|
-
|
|
215
|
-
## 一定不要做
|
|
216
|
-
|
|
217
|
-
1. 不要跳过交互收集直接生成(除非用户提供了完整信息)
|
|
218
|
-
2. 不要使用 5 种标准工作流以外的自定义模式
|
|
219
|
-
3. 不要生成没有输入输出定义的步骤
|
|
220
|
-
4. 不要在 description 中省略适用场景或不适用场景
|
|
221
|
-
5. 不要生成超过 200 行且无 references/ 拆分的 SKILL.md
|
|
222
|
-
6. 不要修改 blame-skill 的评分规则或 better-skill 的优化逻辑
|
|
223
|
-
|
|
224
|
-
## 参考资源
|
|
225
|
-
|
|
226
|
-
- `references/template.md`:SKILL.md 生成模板
|
|
227
|
-
- `references/workflow-patterns.md`:5 种工作流模式详细参考
|