@wwkit/harness 1.0.32 → 1.0.34

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 (38) hide show
  1. package/agents/scrum.md +55 -29
  2. package/agents/sprint.md +31 -19
  3. package/bin/index.js +67 -2
  4. package/commands/tsl.md +12 -0
  5. package/package.json +4 -3
  6. package/skills/better-skill/SKILL.md +148 -80
  7. package/skills/blame-skill/SKILL.md +91 -144
  8. package/skills/blame-skill/references/scoring-rules.md +190 -0
  9. package/skills/blame-sprint-agent/SKILL.md +167 -0
  10. package/skills/blame-sprint-agent/references/scoring-rules.md +113 -0
  11. package/skills/blame-sprint-skill/SKILL.md +154 -0
  12. package/skills/blame-sprint-skill/references/scoring-rules.md +101 -0
  13. package/skills/new-skill/SKILL.md +122 -156
  14. package/skills/step-extract/SKILL.md +205 -0
  15. package/skills/tsl/SKILL.md +393 -0
  16. package/skills/tsl/package.json +10 -0
  17. package/skills/tsl/references/global-review-rules.md +25 -0
  18. package/skills/tsl/references/prepare-prompt.md +150 -0
  19. package/skills/tsl/references/terminology-rules.md +93 -0
  20. package/skills/tsl/references/translation-guide.md +23 -0
  21. package/skills/tsl/references/translation-prompt.md +115 -0
  22. package/skills/tsl/references/translation-rules.md +48 -0
  23. package/skills/tsl/references/verification-rules.md +58 -0
  24. package/skills/tsl/scripts/check-boundaries.js +140 -0
  25. package/skills/tsl/scripts/chunk-text.js +144 -0
  26. package/skills/tsl/scripts/clean-text.js +121 -0
  27. package/skills/tsl/scripts/cleanup-glossary.js +160 -0
  28. package/skills/tsl/scripts/extract-pdf.js +94 -0
  29. package/skills/tsl/scripts/generate-review.js +179 -0
  30. package/skills/tsl/scripts/merge-result.js +164 -0
  31. package/skills/tsl/scripts/verify-chunk.js +170 -0
  32. package/skills/tsl-format/SKILL.md +298 -0
  33. package/skills/tsl-format/references/format-prompt.md +103 -0
  34. package/skills/tsl-format/references/format-rules.md +58 -0
  35. package/skills/tsl-format/scripts/chunk-bilingual.js +96 -0
  36. package/skills/tsl-format/scripts/merge-format.js +105 -0
  37. package/skills/new-skill/references/template.md +0 -53
  38. 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
+ }
@@ -1,53 +0,0 @@
1
- # Skill 模板
2
-
3
- 本文件为 new-skill 技能使用的 SKILL.md 生成模板。`{{占位符}}` 由收集的信息填充。
4
-
5
- ---
6
-
7
- ```yaml
8
- ---
9
- name: {{name}}
10
- description: |
11
- {{description_capability}}。提供:{{description_resources}}。适用:{{description_applicable}}。不适用:{{description_not_applicable}}。
12
- ---
13
- ```
14
-
15
- ```markdown
16
- # {{title}}
17
-
18
- ## 工作流模式
19
-
20
- 本 Skill 采用 **{{workflow_type}}** 工作流:
21
-
22
- {{workflow_steps}}
23
-
24
- ## 输入
25
-
26
- | 参数 | 必填 | 类型 | 说明 |
27
- |------|------|------|------|
28
- {{input_rows}}
29
-
30
- ## 输出
31
-
32
- {{output_desc}}
33
-
34
- ---
35
-
36
- {{stages}}
37
-
38
- ---
39
-
40
- ## 失败处理
41
-
42
- | 场景 | 处理方式 |
43
- |------|---------|
44
- {{failure_rows}}
45
-
46
- ## 一定要做
47
-
48
- {{must_do_items}}
49
-
50
- ## 一定不要做
51
-
52
- {{must_not_do_items}}
53
- ```
@@ -1,104 +0,0 @@
1
- # 工作流模式参考
2
-
3
- 创建 Skill 时,必须从以下 5 种工作流模式中选择一种。选择依据是 Skill 的核心执行逻辑。
4
-
5
- ---
6
-
7
- ## 1. 顺序工作流
8
-
9
- **特征**:步骤按固定顺序依次执行,前一步的输出是后一步的输入,无循环。
10
-
11
- **适用场景**:提交流程、部署流程、文件迁移、一次性转换。
12
-
13
- **声明格式**:
14
- ```markdown
15
- 本 Skill 采用 **顺序工作流**:
16
- 1. **阶段A**:描述
17
- 2. **阶段B**:描述
18
- 3. **阶段C**:描述
19
- ```
20
-
21
- **示例**:git-feat(分支→暂存→提交→推送→集成)
22
-
23
- ---
24
-
25
- ## 2. 迭代优化工作流
26
-
27
- **特征**:执行→检查→改进→再检查,循环直到达标或达到最大迭代次数。
28
-
29
- **适用场景**:代码质量修复、文档优化、评分达标、搜索精炼。
30
-
31
- **声明格式**:
32
- ```markdown
33
- 本 Skill 采用 **迭代优化** 工作流:
34
- 1. **执行**:描述
35
- 2. **检查**:描述
36
- 3. **判断**:达标→输出 / 未达标→改进
37
- 4. **改进**:描述
38
- 5. **循环**:回到步骤2
39
- ```
40
-
41
- **必须定义**:目标条件、最大迭代次数、终止策略。
42
-
43
- **示例**:pipeline-check(检查→修复→验证→迭代)、better-skill(评估→改进→重评→迭代)
44
-
45
- ---
46
-
47
- ## 3. 多 MCP 协调工作流
48
-
49
- **特征**:协调多个外部工具/技能/服务,主 Skill 负责调度和汇总。
50
-
51
- **适用场景**:跨系统操作、多技能编排、API 聚合。
52
-
53
- **声明格式**:
54
- ```markdown
55
- 本 Skill 采用 **多 MCP 协调** 工作流:
56
- 1. **调度**:描述如何选择和调用外部技能/工具
57
- 2. **协调**:描述数据在多个调用间如何传递
58
- 3. **汇总**:描述如何合并多个结果
59
- ```
60
-
61
- **必须定义**:协调的技能/工具列表、数据传递方式、部分失败处理。
62
-
63
- **示例**:pipeline-fix(读取bug→提取→生成→协调pipeline-check→输出)
64
-
65
- ---
66
-
67
- ## 4. 上下文感知工作流
68
-
69
- **特征**:根据运行时环境、用户输入或文件状态动态选择执行路径。
70
-
71
- **适用场景**:条件分支处理、环境适配、多模式切换。
72
-
73
- **声明格式**:
74
- ```markdown
75
- 本 Skill 采用 **上下文感知** 工作流:
76
- 1. **感知**:描述如何检测上下文(环境变量、文件状态、用户输入)
77
- 2. **决策**:描述根据上下文选择哪条执行路径
78
- 3. **执行**:描述各条路径的处理逻辑
79
- ```
80
-
81
- **必须定义**:上下文检测方式、分支条件、每条分支的完整流程。
82
-
83
- **示例**:pipeline-check(根据是否提供rules参数选择全量/定向模式)
84
-
85
- ---
86
-
87
- ## 5. 领域智能工作流
88
-
89
- **特征**:基于领域知识库进行推理、匹配和生成,核心是知识驱动而非流程驱动。
90
-
91
- **适用场景**:规则匹配、知识问答、智能推荐、模式识别。
92
-
93
- **声明格式**:
94
- ```markdown
95
- 本 Skill 采用 **领域智能** 工作流:
96
- 1. **加载**:加载领域知识库(references/)
97
- 2. **匹配**:将输入与知识库中的模式/规则进行匹配
98
- 3. **推理**:基于匹配结果进行推理或生成
99
- 4. **输出**:描述输出格式
100
- ```
101
-
102
- **必须定义**:知识库位置和格式、匹配/推理逻辑。
103
-
104
- **示例**:blame-skill(加载评分规则→匹配Skill特征→评分推理→输出报告)