@wwkit/harness 1.0.44 → 1.0.46

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 (105) hide show
  1. package/package.json +1 -1
  2. package/skills/blame-cleancode/plan.md +1408 -0
  3. package/skills/convert-files/scripts/convert.js +1 -1
  4. package/skills/pea/SKILL.md +15 -9
  5. package/skills/pea/references/tpl-prd/epic.md +10 -0
  6. package/skills/pea/references/tpl-prd/us.md +4 -4
  7. package/skills/peago/SKILL.md +113 -0
  8. package/skills/peago/references/extract/baseline.md +17 -0
  9. package/skills/peago/references/extract/spec.md +117 -0
  10. package/skills/peago/references/res2kb/spec.md +113 -0
  11. package/skills/peago/references/spec-format.md +123 -0
  12. package/skills/peago/references/translate/baseline.md +26 -0
  13. package/skills/peago/references/translate/spec.md +132 -0
  14. package/skills/shared/references/template/pea/spec-agile.md +123 -0
  15. package/skills/shared/references/template/pea/spec-common.md +93 -0
  16. package/skills/shared/scripts/format.md +1 -1
  17. package/skills/extract/SKILL.md +0 -251
  18. package/skills/extract/references/detail_schema.json5 +0 -49
  19. package/skills/extract/references/detail_workflow.md +0 -55
  20. package/skills/extract/references/list_rule_gen.md +0 -109
  21. package/skills/extract/references/list_schema.json5 +0 -34
  22. package/skills/extract/references/list_workflow.md +0 -135
  23. package/skills/extract/references/navi_schema.json5 +0 -23
  24. package/skills/extract/references/navi_workflow.md +0 -45
  25. package/skills/extract/references/planning_template.md +0 -206
  26. package/skills/extract/references/text_schema.json5 +0 -22
  27. package/skills/extract/references/text_workflow.md +0 -41
  28. package/skills/extract/scripts/build_xpath.js +0 -31
  29. package/skills/extract/scripts/clean_html.js +0 -91
  30. package/skills/extract/scripts/extract_detail.js +0 -72
  31. package/skills/extract/scripts/extract_regex.js +0 -82
  32. package/skills/extract/scripts/extract_sample.js +0 -49
  33. package/skills/extract/scripts/to_text.js +0 -21
  34. package/skills/extract/scripts/validate_schema.js +0 -40
  35. package/skills/revise/SKILL.md +0 -66
  36. package/skills/revise/references/article.md +0 -37
  37. package/skills/revise/references/article.schema.json5 +0 -40
  38. package/skills/revise/references/gallery.md +0 -35
  39. package/skills/revise/references/gallery.schema.json5 +0 -40
  40. package/skills/revise/references/question.md +0 -33
  41. package/skills/revise/references/question.schema.json5 +0 -31
  42. package/skills/revise/references/sprint_for_revise.md +0 -46
  43. package/skills/revise/references/status.md +0 -32
  44. package/skills/revise/references/status.schema.json5 +0 -27
  45. package/skills/revise/scripts/check_input_vars.js +0 -127
  46. package/skills/revise/scripts/init.js +0 -84
  47. package/skills/revise/scripts/resolve_run_vars.js +0 -71
  48. package/skills/revise/scripts/validate-schema.js +0 -94
  49. package/skills/translate/SKILL.md +0 -398
  50. package/skills/translate/app.json5 +0 -70
  51. package/skills/translate/package.json +0 -11
  52. package/skills/translate/references/failure-diagnosis.md +0 -43
  53. package/skills/translate/references/format-prompt.md +0 -62
  54. package/skills/translate/references/format-rules.md +0 -39
  55. package/skills/translate/references/global-review-rules.md +0 -23
  56. package/skills/translate/references/glossary-prompt.md +0 -86
  57. package/skills/translate/references/glossary-rules.md +0 -44
  58. package/skills/translate/references/prepare-prompt.md +0 -110
  59. package/skills/translate/references/prepare-rules.md +0 -20
  60. package/skills/translate/references/resume-detection.md +0 -51
  61. package/skills/translate/references/rulings.md +0 -15
  62. package/skills/translate/references/translation-prompt.md +0 -73
  63. package/skills/translate/references/translation-rules.md +0 -51
  64. package/skills/translate/scripts/check-boundaries.js +0 -169
  65. package/skills/translate/scripts/check-paragraphs.js +0 -71
  66. package/skills/translate/scripts/chunk-bilingual.js +0 -123
  67. package/skills/translate/scripts/chunk-text.js +0 -145
  68. package/skills/translate/scripts/clean-text.js +0 -121
  69. package/skills/translate/scripts/count-terms.js +0 -54
  70. package/skills/translate/scripts/extract-pdf.js +0 -94
  71. package/skills/translate/scripts/generate-review.js +0 -179
  72. package/skills/translate/scripts/init-progress.js +0 -144
  73. package/skills/translate/scripts/md-to-docx.js +0 -381
  74. package/skills/translate/scripts/merge-format.js +0 -110
  75. package/skills/translate/scripts/merge-result.js +0 -113
  76. package/skills/translate/scripts/verify-chunk.js +0 -185
  77. package/skills/translate/todos.md +0 -38
  78. package/skills/translate-file/SKILL.md +0 -45
  79. package/skills/translate-file/package.json +0 -10
  80. package/skills/translate-file/references/sprint_for_preprocess.md +0 -14
  81. package/skills/translate-file/references/sprint_for_teardown.md +0 -15
  82. package/skills/translate-file/references/sprint_for_translate.md +0 -74
  83. package/skills/translate-file/references/translation_prompt.md +0 -43
  84. package/skills/translate-file/scripts/check_input_vars.js +0 -53
  85. package/skills/translate-file/scripts/chunk_text.js +0 -167
  86. package/skills/translate-file/scripts/clean_text.js +0 -121
  87. package/skills/translate-file/scripts/extract.js +0 -98
  88. package/skills/translate-file/scripts/generate_review.js +0 -155
  89. package/skills/translate-file/scripts/init.js +0 -86
  90. package/skills/translate-file/scripts/merge_results.js +0 -112
  91. package/skills/translate-file/scripts/resolve_run_vars.js +0 -123
  92. package/skills/translate-file/scripts/verify_chunk.js +0 -144
  93. package/skills/translate-format/SKILL.md +0 -45
  94. package/skills/translate-format/references/format-prompt.md +0 -80
  95. package/skills/translate-format/references/format-rules.md +0 -39
  96. package/skills/translate-format/references/sprint_for_format.md +0 -208
  97. package/skills/translate-format/scripts/check-paragraphs.js +0 -81
  98. package/skills/translate-format/scripts/check_input_vars.js +0 -51
  99. package/skills/translate-format/scripts/chunk-bilingual.js +0 -135
  100. package/skills/translate-format/scripts/count-words.js +0 -38
  101. package/skills/translate-format/scripts/diagnose-failure.js +0 -54
  102. package/skills/translate-format/scripts/init.js +0 -71
  103. package/skills/translate-format/scripts/md-to-docx.js +0 -398
  104. package/skills/translate-format/scripts/merge-format.js +0 -118
  105. package/skills/translate-format/scripts/resolve_run_vars.js +0 -78
@@ -1,135 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * chunk-bilingual.js — 双语文档分块 + 格式重建进度初始化(ESM,纯 JS,无依赖)
4
- *
5
- * 用法:node chunk-bilingual.js <work_dir> <chunk_words> [<input_file>]
6
- * <input_file> 显式传入 = 从指定文件分块
7
- *
8
- * 功能:
9
- * 1. 创建 <work_dir>/fmt/ 目录
10
- * 2. 按段落边界将输入文档分块,写入 fmt/p001.md...
11
- * 3. 创建 fmt/progress.md(身份行 + chunk 状态表)
12
- * 4. stdout 打印 status 行 + data 块
13
- *
14
- * 短路:fmt/progress.md 已存在 → 跳过分块和初始化,仅打印已有块数
15
- */
16
-
17
- import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync } from 'fs'
18
- import { join, basename } from 'path'
19
-
20
- const OK_CHUNKED = 'OK: 分块完成'
21
- const OK_SKIPPED = 'OK: 已跳过(progress.md 已存在)'
22
- const INVALID_USAGE = 'INVALID: 用法 node chunk-bilingual.js <work_dir> <chunk_words> [<input_file>]'
23
- const INVALID_CHUNK_WORDS = 'INVALID: chunk_words 必须为 >= 100 的数字'
24
- const INVALID_INPUT_NOT_FOUND = 'INVALID: 输入文件不存在'
25
- const INVALID_INPUT_EMPTY = 'INVALID: 输入为空或无段落'
26
-
27
- /**
28
- * 将文本按段落边界分块。
29
- * @param {string} content — 文本内容
30
- * @param {number} chunkWords — 每块最大词数
31
- * @returns {string[]} 分块数组
32
- */
33
- export function chunkBilingual(content, chunkWords) {
34
- if (!content || !content.trim()) return []
35
-
36
- const paragraphs = content.split(/\n\n+/)
37
-
38
- const chunks = []
39
- let currentChunk = []
40
- let currentWords = 0
41
-
42
- for (const para of paragraphs) {
43
- const trimmed = para.trim()
44
- if (!trimmed) continue
45
-
46
- const words = trimmed.split(/\s+/).filter(Boolean).length
47
-
48
- if (currentWords + words > chunkWords && currentChunk.length > 0) {
49
- chunks.push(currentChunk.join('\n\n'))
50
- currentChunk = [trimmed]
51
- currentWords = words
52
- } else {
53
- currentChunk.push(trimmed)
54
- currentWords += words
55
- }
56
- }
57
-
58
- if (currentChunk.length > 0) {
59
- chunks.push(currentChunk.join('\n\n'))
60
- }
61
-
62
- return chunks
63
- }
64
-
65
- // --- CLI ---
66
-
67
- const isMain = import.meta.url === `file://${process.argv[1]}`
68
-
69
- if (isMain) {
70
- const args = process.argv.slice(2)
71
-
72
- if (args.length < 2) {
73
- console.error(INVALID_USAGE)
74
- process.exit(2)
75
- }
76
-
77
- const [workDir, chunkWordsStr, inputFile] = args
78
- const chunkWords = parseInt(chunkWordsStr, 10)
79
- const fmtDir = join(workDir, 'fmt')
80
- const progressPath = join(fmtDir, 'progress.md')
81
-
82
- if (isNaN(chunkWords) || chunkWords < 100) {
83
- console.error(INVALID_CHUNK_WORDS)
84
- process.exit(2)
85
- }
86
-
87
- // 短路:progress.md 已存在 → 仅打印已有块数
88
- if (existsSync(progressPath)) {
89
- const existing = readdirSync(fmtDir).filter(f => f.match(/^p\d+\.md$/)).length
90
- console.log(OK_SKIPPED)
91
- console.log()
92
- console.log('| chunks |')
93
- console.log(`| ${existing} |`)
94
- process.exit(0)
95
- }
96
-
97
- // 输入源:显式 input_file
98
- const inputPath = inputFile
99
- if (!inputPath || !existsSync(inputPath)) {
100
- console.error(INVALID_INPUT_NOT_FOUND + (inputPath ? `: ${inputPath}` : ''))
101
- process.exit(2)
102
- }
103
-
104
- const content = readFileSync(inputPath, 'utf-8')
105
- const chunks = chunkBilingual(content, chunkWords)
106
-
107
- if (chunks.length === 0) {
108
- console.error(`${INVALID_INPUT_EMPTY}: ${inputPath}`)
109
- process.exit(2)
110
- }
111
-
112
- // 1. 创建 fmt/ 目录
113
- mkdirSync(fmtDir, { recursive: true })
114
-
115
- // 2. 写分块文件
116
- chunks.forEach((chunk, i) => {
117
- const num = String(i + 1).padStart(3, '0')
118
- writeFileSync(join(fmtDir, `p${num}.md`), chunk + '\n', 'utf-8')
119
- })
120
-
121
- // 3. 创建 progress.md
122
- const inputDirBasename = basename(join(workDir, '..', '..'))
123
- const fileBasename = basename(workDir)
124
- const lines = [`# tsl format progress — book: ${inputDirBasename}, file: ${fileBasename}`, '', '| Chunk | 状态 | 重试 |', '|-------|------|------|']
125
- for (let i = 0; i < chunks.length; i++) {
126
- const num = String(i + 1).padStart(3, '0')
127
- lines.push(`| p${num} | pending | 0 |`)
128
- }
129
- writeFileSync(progressPath, lines.join('\n') + '\n', 'utf-8')
130
-
131
- console.log(OK_CHUNKED)
132
- console.log()
133
- console.log('| chunks |')
134
- console.log(`| ${chunks.length} |`)
135
- }
@@ -1,38 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * count-words.js — 词数统计(ESM,纯 JS,无依赖)
4
- *
5
- * 用法:node count-words.js <input_file>
6
- * stdout: status 行 + data 块
7
- * 退出码:0 成功 / 2 参数错误
8
- */
9
-
10
- import { readFileSync, existsSync } from 'fs'
11
-
12
- const OK_COUNTED = 'OK: 词数统计完成'
13
- const INVALID_USAGE = 'INVALID: 用法 node count-words.js <input_file>'
14
- const INVALID_NOT_FOUND = 'INVALID: 输入文件不存在'
15
-
16
- const isMain = import.meta.url === `file://${process.argv[1]}`
17
-
18
- if (isMain) {
19
- const inputPath = process.argv[2]
20
-
21
- if (!inputPath) {
22
- console.error(INVALID_USAGE)
23
- process.exit(2)
24
- }
25
-
26
- if (!existsSync(inputPath)) {
27
- console.error(`${INVALID_NOT_FOUND}: ${inputPath}`)
28
- process.exit(2)
29
- }
30
-
31
- const content = readFileSync(inputPath, 'utf-8')
32
- const words = content.split(/\s+/).filter(Boolean).length
33
-
34
- console.log(OK_COUNTED)
35
- console.log()
36
- console.log('| words |')
37
- console.log(`| ${words} |`)
38
- }
@@ -1,54 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * diagnose-failure.js — 查询 subagent session 失败原因(ESM,纯 JS)
4
- *
5
- * 用法:node diagnose-failure.js <session_id>
6
- * stdout: status 行 + data 块
7
- * 退出码:0 成功 / 2 参数错误 / 4 执行失败
8
- */
9
-
10
- import { execSync } from 'child_process'
11
- import { existsSync } from 'fs'
12
- import { join } from 'path'
13
- import { homedir } from 'os'
14
-
15
- const OK_FOUND = 'OK: 失败原因已诊断'
16
- const INVALID_USAGE = 'INVALID: 用法 node diagnose-failure.js <session_id>'
17
- const INVALID_NO_DB = 'INVALID: opencode.db 不存在'
18
- const ERROR_QUERY = 'ERROR: 查询失败'
19
-
20
- const DB_PATH = join(homedir(), '.local/share/opencode/opencode.db')
21
-
22
- const isMain = import.meta.url === `file://${process.argv[1]}`
23
- if (isMain) {
24
- const sessionId = process.argv[2]
25
-
26
- if (!sessionId) {
27
- console.error(INVALID_USAGE)
28
- process.exit(2)
29
- }
30
-
31
- if (!existsSync(DB_PATH)) {
32
- console.error(INVALID_NO_DB)
33
- process.exit(2)
34
- }
35
-
36
- const sql = `SELECT json_extract(p.data, '$.reason') as reason, json_extract(p.data, '$.tokens.output') as output_tokens FROM part p JOIN message m ON p.message_id = m.id WHERE m.session_id = '${sessionId}' AND p.data LIKE '%step-finish%' ORDER BY p.time_created DESC LIMIT 1;`
37
-
38
- try {
39
- const result = execSync(`sqlite3 '${DB_PATH}' "${sql}"`, {
40
- encoding: 'utf-8',
41
- timeout: 10000,
42
- }).trim()
43
-
44
- const [reason, outputTokens] = result.split('|')
45
-
46
- console.log(OK_FOUND)
47
- console.log()
48
- console.log('| reason | output_tokens |')
49
- console.log(`| ${reason || 'unknown'} | ${outputTokens || 'N/A'} |`)
50
- } catch (e) {
51
- console.error(`${ERROR_QUERY}: ${e.message}`)
52
- process.exit(4)
53
- }
54
- }
@@ -1,71 +0,0 @@
1
- /**
2
- * init.js — Initialization script: runs a 5-step init flow sequentially.
3
- *
4
- * Flow:
5
- * 1. check_input_vars — validate input variable (input .txt file)
6
- * 2. resolve_system_vars — resolve system variables
7
- * 3. resolve_run_vars — compute run variables (input_dir / file_name / tmp / chunk_words)
8
- * 4. force_clear — when force=true, clear run_dir
9
- * 5. resolve_dependencies — check npm dependencies
10
- *
11
- * Usage: node scripts/init.js <input> [force]
12
- */
13
-
14
- import { dirname, join } from 'path'
15
- import { fileURLToPath } from 'url'
16
- import { rmSync, mkdirSync } from 'fs'
17
- import { render } from '../../shared/scripts/utils.js'
18
- import { checkInputVars, OK_INPUT_VALID } from './check_input_vars.js'
19
- import { resolveSystemVars, formatSystemVars } from '../../shared/scripts/resolve_system_vars.js'
20
- import { resolveRunVars, formatRunVars } from './resolve_run_vars.js'
21
- import { resolveDependencies, formatDependencies } from '../../shared/scripts/resolve_dependencies.js'
22
-
23
- const INVALID_OUTPUT_TEMPLATE = 'INVALID: ${error}'
24
- const OK_FORCE_CLEARED = 'OK: 历史进度已清除'
25
-
26
- const isMain = import.meta.url === `file://${process.argv[1]}`
27
- if (isMain) {
28
- const inputPath = process.argv[2]
29
- const force = process.argv[3] === 'true'
30
- const scriptDir = dirname(fileURLToPath(import.meta.url))
31
- const skillDir = dirname(scriptDir)
32
-
33
- // Step 1: Input validation
34
- const checkResult = checkInputVars(inputPath)
35
- if (checkResult.error) {
36
- console.log(render(INVALID_OUTPUT_TEMPLATE, { error: checkResult.error }))
37
- process.exit(0)
38
- }
39
- console.log(OK_INPUT_VALID)
40
- console.log()
41
-
42
- // Step 2: Resolve system variables
43
- const sysVars = resolveSystemVars(skillDir)
44
- console.log(formatSystemVars(sysVars))
45
- console.log()
46
-
47
- // Step 3: Create Run variables
48
- const runResult = resolveRunVars(sysVars.skill_data_dir, inputPath)
49
- if (runResult.error) {
50
- console.log(render(INVALID_OUTPUT_TEMPLATE, { error: runResult.error }))
51
- process.exit(0)
52
- }
53
- console.log(formatRunVars(runResult))
54
- console.log()
55
-
56
- // Step 4: Force clear run_dir
57
- if (force) {
58
- const runDir = join(sysVars.skill_data_dir, runResult.file_name)
59
- rmSync(runDir, { recursive: true, force: true })
60
- mkdirSync(runDir, { recursive: true })
61
- console.log(OK_FORCE_CLEARED)
62
- console.log()
63
- }
64
-
65
- // Step 5: Check dependencies
66
- const depResult = resolveDependencies(skillDir)
67
- console.log('OK: 依赖检查完成')
68
- console.log()
69
- console.log('## Dependencies')
70
- console.log(formatDependencies(depResult))
71
- }