@wwkit/harness 1.0.46 → 1.0.48

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 (119) hide show
  1. package/package.json +3 -4
  2. package/skills/pea/SKILL.md +14 -4
  3. package/skills/pea/references/tpl-prd/epic.md +7 -2
  4. package/skills/peago/SKILL.md +10 -2
  5. package/skills/peago/references/cleancode/languages/py-ut.md +88 -0
  6. package/skills/peago/references/cleancode/languages/py.md +222 -0
  7. package/skills/{blame-cleancode/references → peago/references/cleancode}/report_template.md +45 -12
  8. package/skills/peago/references/cleancode/rules-ut.md +133 -0
  9. package/skills/peago/references/cleancode/rules.md +477 -0
  10. package/skills/peago/references/cleancode/spec.md +204 -0
  11. package/skills/peago/references/lint/spec.md +160 -0
  12. package/skills/peago/references/test/languages/js.md +74 -0
  13. package/skills/peago/references/test/languages/py.md +68 -0
  14. package/skills/peago/references/test/spec.md +201 -0
  15. package/skills/peago/references/translate/scripts/check-paragraphs.js +71 -0
  16. package/skills/peago/references/translate/scripts/check-structure.js +118 -0
  17. package/skills/peago/references/translate/scripts/chunk-bilingual.js +123 -0
  18. package/skills/peago/references/translate/scripts/chunk-text.js +150 -0
  19. package/skills/peago/references/translate/scripts/clean-text.js +121 -0
  20. package/skills/peago/references/translate/scripts/count-terms.js +54 -0
  21. package/skills/peago/references/translate/scripts/extract-vision.js +267 -0
  22. package/skills/peago/references/translate/scripts/md-to-docx.js +381 -0
  23. package/skills/peago/references/translate/scripts/merge-format.js +110 -0
  24. package/skills/peago/references/translate/scripts/merge-pages.js +202 -0
  25. package/skills/peago/references/translate/scripts/merge-result.js +113 -0
  26. package/skills/peago/references/translate/scripts/verify-chunk.js +200 -0
  27. package/skills/peago/references/translate/spec.md +14 -6
  28. package/skills/better-class/SKILL.md +0 -48
  29. package/skills/better-class/references/planning_spec.md +0 -91
  30. package/skills/better-class/references/report-template.md +0 -65
  31. package/skills/better-class/references/sprint_for_eo.md +0 -83
  32. package/skills/better-class/references/sprint_for_report.md +0 -22
  33. package/skills/better-class/references/subagent-prompt.md +0 -47
  34. package/skills/better-class/references/workflow.md +0 -75
  35. package/skills/better-class/scripts/check-syntax.js +0 -112
  36. package/skills/better-class/scripts/check_input_vars.js +0 -52
  37. package/skills/better-class/scripts/init.js +0 -88
  38. package/skills/better-class/scripts/resolve_run_vars.js +0 -96
  39. package/skills/better-class/scripts/run-tests.js +0 -108
  40. package/skills/better-cleancode/SKILL.md +0 -157
  41. package/skills/better-ut/SKILL.md +0 -236
  42. package/skills/blame-class/SKILL.md +0 -78
  43. package/skills/blame-class/references/report_template.md +0 -98
  44. package/skills/blame-class/references/rules.md +0 -40
  45. package/skills/blame-cleancode/SKILL.md +0 -105
  46. package/skills/blame-cleancode/plan.md +0 -1408
  47. package/skills/blame-cleancode/references/rules.md +0 -630
  48. package/skills/blame-ut/SKILL.md +0 -113
  49. package/skills/blame-ut/references/report_template.md +0 -102
  50. package/skills/blame-ut/references/rules.md +0 -197
  51. package/skills/convert-files/SKILL.md +0 -37
  52. package/skills/convert-files/package.json +0 -11
  53. package/skills/convert-files/references/sprint_for_conversion.md +0 -17
  54. package/skills/convert-files/scripts/check_input_vars.js +0 -54
  55. package/skills/convert-files/scripts/convert.js +0 -331
  56. package/skills/convert-files/scripts/init.js +0 -75
  57. package/skills/convert-files/scripts/resolve_run_vars.js +0 -124
  58. package/skills/create-ppt/SKILL.md +0 -47
  59. package/skills/create-ppt/package.json +0 -9
  60. package/skills/create-ppt/references/ppt-styles.md +0 -287
  61. package/skills/create-ppt/references/sprint_for_ppt_generation.md +0 -81
  62. package/skills/create-ppt/references/sprint_for_source_discovery.md +0 -18
  63. package/skills/create-ppt/scripts/check_input_vars.js +0 -57
  64. package/skills/create-ppt/scripts/find-source-files.js +0 -98
  65. package/skills/create-ppt/scripts/init.js +0 -96
  66. package/skills/create-ppt/scripts/md-to-pptx.js +0 -579
  67. package/skills/create-ppt/scripts/resolve_run_vars.js +0 -91
  68. package/skills/jstest/SKILL.md +0 -561
  69. package/skills/jstest/references/case-create.md +0 -327
  70. package/skills/jstest/references/case-fix.md +0 -273
  71. package/skills/jstest/references/config.md +0 -148
  72. package/skills/jstest/references/coverage-analyze.md +0 -247
  73. package/skills/jstest/references/env-ensure.md +0 -210
  74. package/skills/jstest/references/execute.md +0 -168
  75. package/skills/jstest/references/sample.md +0 -166
  76. package/skills/jstest/references/scoring-rules.md +0 -75
  77. package/skills/jstest/references/suitability-check.md +0 -232
  78. package/skills/jstest/references/test-standards.md +0 -288
  79. package/skills/lint/SKILL.md +0 -440
  80. package/skills/lint/references/ai-fix.md +0 -138
  81. package/skills/lint/references/config-setup.md +0 -103
  82. package/skills/lint/references/config.md +0 -65
  83. package/skills/lint/references/env-ensure.md +0 -89
  84. package/skills/lint/references/language-detect.md +0 -76
  85. package/skills/lint/references/rules-analyze.md +0 -126
  86. package/skills/lint/references/suitability-check.md +0 -82
  87. package/skills/lint/references/tool-fix.md +0 -91
  88. package/skills/peago/references/extract/baseline.md +0 -17
  89. package/skills/peago/references/extract/spec.md +0 -117
  90. package/skills/pytest/SKILL.md +0 -556
  91. package/skills/pytest/references/case-create.md +0 -325
  92. package/skills/pytest/references/case-fix.md +0 -272
  93. package/skills/pytest/references/config.md +0 -145
  94. package/skills/pytest/references/coverage-analyze.md +0 -224
  95. package/skills/pytest/references/env-ensure.md +0 -196
  96. package/skills/pytest/references/execute.md +0 -153
  97. package/skills/pytest/references/sample.md +0 -160
  98. package/skills/pytest/references/scoring-rules.md +0 -57
  99. package/skills/pytest/references/suitability-check.md +0 -221
  100. package/skills/pytest/references/test-standards.md +0 -244
  101. package/skills/query/SKILL.md +0 -72
  102. package/skills/step-extract/SKILL.md +0 -205
  103. /package/skills/{lint/references → peago/references/lint}/languages/js.md +0 -0
  104. /package/skills/{lint/references → peago/references/lint}/languages/py.md +0 -0
  105. /package/skills/{lint/references → peago/references/lint/scripts}/detect-language.js +0 -0
  106. /package/skills/{jstest/references/src/jstest-sample → peago/references/test/sample-src/js}/Calculator.js +0 -0
  107. /package/skills/{jstest/references/src/jstest-sample → peago/references/test/sample-src/js}/ConfigManager.js +0 -0
  108. /package/skills/{jstest/references/src/jstest-sample → peago/references/test/sample-src/js}/FileProcessor.js +0 -0
  109. /package/skills/{jstest/references/src/jstest-sample → peago/references/test/sample-src/js}/OrderService.js +0 -0
  110. /package/skills/{jstest/references/src/jstest-sample → peago/references/test/sample-src/js}/TokenGenerator.js +0 -0
  111. /package/skills/{jstest/references/src/jstest-sample → peago/references/test/sample-src/js}/UserService.js +0 -0
  112. /package/skills/{jstest/references/src/jstest-sample → peago/references/test/sample-src/js}/index.js +0 -0
  113. /package/skills/{pytest/references/src/pytest-sample → peago/references/test/sample-src/py}/Calculator.py +0 -0
  114. /package/skills/{pytest/references/src/pytest-sample → peago/references/test/sample-src/py}/ConfigManager.py +0 -0
  115. /package/skills/{pytest/references/src/pytest-sample → peago/references/test/sample-src/py}/FileProcessor.py +0 -0
  116. /package/skills/{pytest/references/src/pytest-sample → peago/references/test/sample-src/py}/OrderService.py +0 -0
  117. /package/skills/{pytest/references/src/pytest-sample → peago/references/test/sample-src/py}/TokenGenerator.py +0 -0
  118. /package/skills/{pytest/references/src/pytest-sample → peago/references/test/sample-src/py}/UserService.py +0 -0
  119. /package/skills/{pytest/references/src/pytest-sample → peago/references/test/sample-src/py}/__init__.py +0 -0
@@ -1,331 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * convert.js — Markdown 批量转 docx 脚本(ESM,自包含,无跨 skill 依赖)
4
- *
5
- * 将 md_files 列表中的每个 Markdown 文件转换为同名 .docx,输出到 output_dir。
6
- * 转换核心逻辑自包含实现(sanitizeMarkdownUrls → normalizeFootnoteLabels →
7
- * markdown-docx → rebuildFootnotes),不依赖其他 skill。
8
- *
9
- * 三道转换前/后修正(缺一不可,都针对 Word 打开 docx 报错):
10
- * 1. sanitizeMarkdownUrls(转换前):把裸 URL + 全角标点/CJK 紧贴的畸形转成
11
- * 标准 Markdown 链接,防止 GFM autolink 把全角标点/中文吞入 href。
12
- * 2. normalizeFootnoteLabels(转换前):脚注 label 全局唯一化,防止重复引用
13
- * 和孤儿定义导致 Word 报脚注错误。
14
- * 3. rebuildFootnotes(转换后兜底):重建 footnotes.xml/endnotes.xml,保证每个
15
- * 引用有唯一定义,保留 Word 规范的 separator/continuationSeparator。
16
- *
17
- * 用法:node convert.js <md_files> <output_dir>
18
- * - md_files:逗号分隔的 .md 文件路径列表
19
- * - output_dir:docx 输出目录(不存在时自动创建)
20
- * 短路:输出 docx 已存在且非空 → 打印 skipped(避免重复转换)
21
- * stdout: OK: docx <input> -> <output> (bytes=N)
22
- * 退出码:0 成功/短路 / 2 参数错误 / 4 执行失败
23
- */
24
-
25
- import { readFileSync, writeFileSync, existsSync, statSync, mkdirSync } from 'fs'
26
- import { dirname, join, basename } from 'path'
27
- import { createRequire } from 'module'
28
- import JSZip from 'jszip'
29
-
30
- const require = createRequire(import.meta.url)
31
-
32
- // markdown-docx 默认选项:启用 GFM(脚注/表格/删除线等扩展语法依赖)
33
- const DEFAULTS = { gfm: true }
34
-
35
- // ── CLI 输出模板(status 行 + 汇总;CLI 入口只做占位符替换)──
36
- const SKIPPED_OUTPUT_TEMPLATE = 'OK: skipped ${outputPath} (bytes=${bytes})'
37
- const CONVERTED_OUTPUT_TEMPLATE = 'OK: docx ${inputPath} -> ${outputPath} (bytes=${bytes})'
38
- const SUMMARY_OUTPUT_TEMPLATE = 'OK: total=${total}, converted=${converted}, skipped=${skipped}, failed=${failed}'
39
- const SUMMARY_ERROR_TEMPLATE = 'ERROR: total=${total}, converted=${converted}, skipped=${skipped}, failed=${failed}'
40
- const ERROR_OUTPUT_TEMPLATE = 'ERROR: ${error}'
41
- const FILE_MISSING_TEMPLATE = 'ERROR: 文件不存在: ${inputPath}'
42
- const CONVERT_FAILED_TEMPLATE = 'ERROR: 转换失败 ${inputPath}: ${error}'
43
- const USAGE_OUTPUT_TEMPLATE = `ERROR: usage: node convert.js <md_files> <output_dir>
44
- md_files: 逗号分隔的 .md 文件路径列表
45
- output_dir: docx 输出目录`
46
-
47
- const render = (template, data) => template.replace(/\$\{(\w+)\}/g, (_, key) => data[key] ?? '')
48
-
49
- // ── 裸 URL 匹配与尾部回退 ──
50
- const BARE_URL_RE = /(^|[^(\]])((?:https?:\/\/|www\.)[^\s<()《》""''!?,。;:、\u4e00-\u9fff]+)/g
51
- const TRAILING_ASCII_PUNCT = /[?!.,:;*_'"~)]+$/
52
-
53
- /**
54
- * 惰性加载 markdown-docx。
55
- * @returns {{ default: Function, Packer: object }} markdown-docx 模块
56
- * @throws {Error} markdown-docx 不可用时抛出,附带安装提示
57
- */
58
- function loadMarkdownDocx() {
59
- try {
60
- const mod = require('markdown-docx')
61
- return { default: mod.default || mod, Packer: mod.Packer }
62
- } catch {
63
- throw new Error('ERROR: markdown-docx not available. Run: npm install (in skills/convert-files)')
64
- }
65
- }
66
-
67
- /**
68
- * 清洗 Markdown 中的畸形裸 URL(转换前预处理)。
69
- * 把裸 URL 转为标准 Markdown 链接 [url](url),URL 后的全角标点/中文保持在链接外。
70
- * @param {string} markdown - 原始 Markdown 文本
71
- * @returns {string} 清洗后的 Markdown 文本
72
- */
73
- function sanitizeMarkdownUrls(markdown) {
74
- return markdown.replace(BARE_URL_RE, (match, prefix, url) => {
75
- const cleaned = url.replace(TRAILING_ASCII_PUNCT, '')
76
- if (cleaned.length === 0) return match
77
- const rest = url.slice(cleaned.length)
78
- return `${prefix}[${cleaned}](${cleaned})${rest}`
79
- })
80
- }
81
-
82
- /**
83
- * 将脚注 label 归一化为全局唯一(转换前预处理)。
84
- * 按"正文引用 → 之后最近的同 label 定义"配对,把 label 重写为全局唯一 [^f1]..[^fN];
85
- * 同时给紧贴正文段落的定义行前补空行。
86
- * @param {string} markdown - 原始 Markdown 文本
87
- * @returns {string} 归一化后的 Markdown
88
- */
89
- function normalizeFootnoteLabels(markdown) {
90
- const lines = markdown.split('\n')
91
- const defs = new Map()
92
- const defLines = new Set()
93
- let inCode = false
94
- lines.forEach((l, i) => {
95
- if (/^\s*```/.test(l)) { inCode = !inCode; return }
96
- if (inCode) return
97
- const m = l.match(/^\[\^([^\]\n]+)\]:/)
98
- if (m) {
99
- const label = m[1]
100
- if (!defs.has(label)) defs.set(label, [])
101
- defs.get(label).push(i)
102
- defLines.add(i)
103
- }
104
- })
105
-
106
- const refs = new Map()
107
- inCode = false
108
- lines.forEach((l, i) => {
109
- if (/^\s*```/.test(l)) { inCode = !inCode; return }
110
- if (inCode || defLines.has(i)) return
111
- for (const m of l.matchAll(/\[\^([^\]\n]+)\]/g)) {
112
- const label = m[1]
113
- if (!refs.has(label)) refs.set(label, [])
114
- refs.get(label).push(i)
115
- }
116
- })
117
-
118
- const defOrder = []
119
- for (const [label, positions] of defs) for (const li of positions) defOrder.push({ label, li })
120
- defOrder.sort((a, b) => a.li - b.li)
121
- const idxOf = new Map()
122
- defOrder.forEach((d, i) => idxOf.set(`${d.label}#${d.li}`, i + 1))
123
-
124
- const refIdx = new Map()
125
- for (const [label, rlines] of refs) {
126
- const dlines = defs.get(label) || []
127
- for (const li of rlines) {
128
- const later = dlines.find((d) => d > li)
129
- if (later !== undefined) {
130
- refIdx.set(`${label}#${li}`, idxOf.get(`${label}#${later}`))
131
- } else {
132
- const earlier = [...dlines].reverse().find((d) => d < li)
133
- refIdx.set(`${label}#${li}`, earlier !== undefined ? idxOf.get(`${label}#${earlier}`) : -1)
134
- }
135
- }
136
- }
137
-
138
- return lines
139
- .map((l, i) => {
140
- if (defLines.has(i)) {
141
- const rewritten = l.replace(/^\[\^([^\]\n]+)\]:,/, (m, label) => `[^f${idxOf.get(`${label}#${i}`)}]:`)
142
- return (i > 0 && lines[i - 1].trim() !== '' ? '\n' : '') + rewritten
143
- }
144
- return l.replace(/\[\^([^\]\n]+)\]/g, (m, label) => {
145
- const idx = refIdx.get(`${label}#${i}`)
146
- return idx && idx > 0 ? `[^f${idx}]` : m
147
- })
148
- })
149
- .join('\n')
150
- }
151
-
152
- /**
153
- * 解析 footnotes.xml / endnotes.xml,供 rebuildFootnotes 重建时复用。
154
- * @param {string} xml - footnotes.xml 或 endnotes.xml 文本
155
- * @param {string} tag - 'footnote' | 'endnote'
156
- */
157
- function parseNotesXml(xml, tag) {
158
- const plural = `${tag}s`
159
- const decl = xml.match(/^<\?xml[^>]*\?>/)?.[0] || ''
160
- const rootOpen = xml.match(new RegExp(`<w:${plural}[^>]*>`))?.[0] || `<w:${plural}>`
161
- const sep = xml.match(new RegExp(`<w:${tag} w:type="separator"[^>]*>.*?</w:${tag}>`, 's'))?.[0] || ''
162
- const contSep = xml.match(
163
- new RegExp(`<w:${tag} w:type="continuationSeparator"[^>]*>.*?</w:${tag}>`, 's')
164
- )?.[0] || ''
165
- const defs = new Map()
166
- const re = new RegExp(`<w:${tag} w:id="(\\d+)">(.*?)</w:${tag}>`, 'gs')
167
- let m
168
- while ((m = re.exec(xml))) defs.set(parseInt(m[1], 10), m[2])
169
- return { decl, rootOpen, sep, contSep, defs, tag, plural }
170
- }
171
-
172
- /**
173
- * 重建 docx 中的脚注/尾注结构(转换后兜底)。
174
- * 保证每个引用有唯一定义且定义全部被引用,保留 Word 规范的 separator/continuationSeparator。
175
- * @param {Buffer} docxBuffer - 原始 docx buffer
176
- * @returns {Promise<Buffer>} 重建后的 docx buffer
177
- */
178
- async function rebuildFootnotes(docxBuffer) {
179
- const zip = await JSZip.loadAsync(docxBuffer)
180
- const docXml = await zip.file('word/document.xml').async('string')
181
-
182
- let fnCounter = 0
183
- let enCounter = 0
184
- const fnUses = []
185
- const enUses = []
186
- const newDocXml = docXml
187
- .replace(/w:footnoteReference w:id="(-?\d+)"/g, (m, id) => {
188
- fnCounter += 1
189
- fnUses.push({ oldId: parseInt(id, 10), newId: fnCounter })
190
- return `w:footnoteReference w:id="${fnCounter}"`
191
- })
192
- .replace(/w:endnoteReference w:id="(-?\d+)"/g, (m, id) => {
193
- enCounter += 1
194
- enUses.push({ oldId: parseInt(id, 10), newId: enCounter })
195
- return `w:endnoteReference w:id="${enCounter}"`
196
- })
197
-
198
- const buildNotes = (notes, uses) => {
199
- const { decl, rootOpen, sep, contSep, defs, tag, plural } = notes
200
- let body = ''
201
- for (const { oldId, newId } of uses) {
202
- const inner = defs.get(oldId) || '<w:p><w:r><w:t xml:space="preserve"> </w:t></w:r></w:p>'
203
- body += `<w:${tag} w:id="${newId}">${inner}</w:${tag}>`
204
- }
205
- return `${decl}${rootOpen}${sep}${contSep}${body}</w:${plural}>`
206
- }
207
-
208
- if (zip.file('word/footnotes.xml')) {
209
- const fnXml = await zip.file('word/footnotes.xml').async('string')
210
- zip.file('word/footnotes.xml', buildNotes(parseNotesXml(fnXml, 'footnote'), fnUses))
211
- }
212
- if (zip.file('word/endnotes.xml')) {
213
- const enXml = await zip.file('word/endnotes.xml').async('string')
214
- zip.file('word/endnotes.xml', buildNotes(parseNotesXml(enXml, 'endnote'), enUses))
215
- }
216
- zip.file('word/document.xml', newDocXml)
217
- return zip.generateAsync({ type: 'nodebuffer', compression: 'DEFLATE' })
218
- }
219
-
220
- /**
221
- * 将 Markdown 内容转换为 docx Buffer。
222
- * 流程:sanitizeMarkdownUrls → normalizeFootnoteLabels → markdown-docx → rebuildFootnotes。
223
- * @param {string} markdown - Markdown 文本内容
224
- * @param {object} [options] - markdown-docx 转换选项
225
- * @returns {Promise<Buffer>} docx 文件 buffer
226
- */
227
- async function mdToDocxBuffer(markdown, options = {}) {
228
- const { default: markdownDocx, Packer } = loadMarkdownDocx()
229
- const cleaned = normalizeFootnoteLabels(sanitizeMarkdownUrls(markdown))
230
- const doc = await markdownDocx(cleaned, { ...DEFAULTS, ...options })
231
- const rawBuf = await Packer.toBuffer(doc)
232
- return rebuildFootnotes(rawBuf)
233
- }
234
-
235
- /**
236
- * 将 Markdown 文件转换为 docx 文件。
237
- * @param {string} inputPath - 输入 .md 文件路径
238
- * @param {string} outputPath - 输出 .docx 文件路径(父目录不存在时自动创建)
239
- * @param {object} [options] - markdown-docx 转换选项
240
- * @returns {Promise<{ inputPath: string, outputPath: string, bytes: number }>}
241
- */
242
- async function mdToDocx(inputPath, outputPath, options = {}) {
243
- if (!inputPath || !outputPath) {
244
- throw new Error('Usage: mdToDocx(inputPath, outputPath)')
245
- }
246
- if (!existsSync(inputPath)) {
247
- throw new Error(`ERROR: input file not found: ${inputPath}`)
248
- }
249
- const markdown = readFileSync(inputPath, 'utf-8')
250
- const buf = await mdToDocxBuffer(markdown, options)
251
- mkdirSync(dirname(outputPath), { recursive: true })
252
- writeFileSync(outputPath, buf)
253
- return { inputPath, outputPath, bytes: buf.length }
254
- }
255
-
256
- /**
257
- * 将 md_files 列表中的每个 .md 文件转换为同名 .docx,输出到 output_dir。
258
- * @param {string} mdFilesStr — 逗号分隔的 .md 文件路径列表
259
- * @param {string} outputDir — docx 输出目录(不存在时自动创建)
260
- * @returns {Promise<{total: number, converted: number, skipped: number, failed: number}>}
261
- */
262
- export async function convertFiles(mdFilesStr, outputDir) {
263
- const mdFiles = mdFilesStr.split(',').map((s) => s.trim()).filter(Boolean)
264
- if (mdFiles.length === 0) {
265
- throw new Error('ERROR: md_files 为空')
266
- }
267
- if (!outputDir) {
268
- throw new Error('ERROR: output_dir 未提供')
269
- }
270
- mkdirSync(outputDir, { recursive: true })
271
-
272
- let converted = 0
273
- let skipped = 0
274
- let failed = 0
275
-
276
- for (const mdFile of mdFiles) {
277
- if (!existsSync(mdFile)) {
278
- console.error(render(FILE_MISSING_TEMPLATE, { inputPath: mdFile }))
279
- failed++
280
- continue
281
- }
282
- const docxName = basename(mdFile, '.md') + '.docx'
283
- const outputPath = join(outputDir, docxName)
284
-
285
- // 短路:输出 docx 已存在且非空 → 跳过(避免重复转换)
286
- if (existsSync(outputPath) && statSync(outputPath).size > 0) {
287
- console.log(render(SKIPPED_OUTPUT_TEMPLATE, { outputPath, bytes: statSync(outputPath).size }))
288
- skipped++
289
- continue
290
- }
291
-
292
- try {
293
- const result = await mdToDocx(mdFile, outputPath)
294
- console.log(render(CONVERTED_OUTPUT_TEMPLATE, {
295
- inputPath: result.inputPath,
296
- outputPath: result.outputPath,
297
- bytes: result.bytes,
298
- }))
299
- converted++
300
- } catch (e) {
301
- console.error(render(CONVERT_FAILED_TEMPLATE, { inputPath: mdFile, error: e.message }))
302
- failed++
303
- }
304
- }
305
-
306
- return { total: mdFiles.length, converted, skipped, failed }
307
- }
308
-
309
- // --- CLI entry point (only when run directly, not when imported) ---
310
-
311
- const isMain = import.meta.url === `file://${process.argv[1]}`
312
- if (isMain) {
313
- const mdFilesStr = process.argv[2]
314
- const outputDir = process.argv[3]
315
-
316
- if (!mdFilesStr || !outputDir) {
317
- console.error(USAGE_OUTPUT_TEMPLATE)
318
- process.exit(2)
319
- }
320
-
321
- convertFiles(mdFilesStr, outputDir)
322
- .then(({ total, converted, skipped, failed }) => {
323
- const template = failed > 0 ? SUMMARY_ERROR_TEMPLATE : SUMMARY_OUTPUT_TEMPLATE
324
- console.log(render(template, { total, converted, skipped, failed }))
325
- process.exit(failed > 0 ? 4 : 0)
326
- })
327
- .catch((e) => {
328
- console.error(render(ERROR_OUTPUT_TEMPLATE, { error: e.message }))
329
- process.exit(4)
330
- })
331
- }
@@ -1,75 +0,0 @@
1
- /**
2
- * init.js — 初始化脚本:按顺序执行 4 步初始化流程
3
- *
4
- * 流程:
5
- * 1. check_input_vars — 校验输入变量(input_path)
6
- * 2. resolve_system_vars — 解析系统变量(skill_dir / shared_dir / skill_data_dir / max_parallel)
7
- * 3. resolve_run_vars — 创建 Run 变量(md_files / run_name / run_dir / output_dir)
8
- * 4. resolve_dependencies — 检查并安装 npm 依赖
9
- *
10
- * 短路:任何一步返回 INVALID → 打印错误 + exit(0),不执行后续步骤
11
- *
12
- * 输出风格:每步以 OK: <描述> 开头,后接可选 ## <表头> + 表格/详情,步骤间空行分隔。
13
- *
14
- * 用法:node scripts/init.js <input_path>
15
- */
16
-
17
- import { dirname } from 'path'
18
- import { fileURLToPath } from 'url'
19
- import { render } from '../../shared/scripts/utils.js'
20
- import { checkInputVars, OK_INPUT_VALID } from './check_input_vars.js'
21
- import { resolveSystemVars, formatSystemVars } from '../../shared/scripts/resolve_system_vars.js'
22
- import { resolveRunVars, formatRunVars } from './resolve_run_vars.js'
23
- import { resolveDependencies, formatDependencies, DEPS_FAIL } from '../../shared/scripts/resolve_dependencies.js'
24
-
25
- // ── 本脚本常量 ──
26
- const INVALID_OUTPUT_TEMPLATE = 'INVALID: ${error}'
27
- const DEPS_OK_OUTPUT_TEMPLATE = 'OK: 依赖检查完成'
28
- const DEPS_FAIL_OUTPUT_TEMPLATE = 'ERROR: 依赖检查失败'
29
- const DEPS_HEADER_TEMPLATE = '## Dependencies'
30
-
31
- // ── CLI 入口 ──
32
- const isMain = import.meta.url === `file://${process.argv[1]}`
33
- if (isMain) {
34
- const inputPath = process.argv[2]
35
- // skill_dir = 本脚本所在目录(.../skills/<skill>/scripts)的父目录
36
- const scriptDir = dirname(fileURLToPath(import.meta.url))
37
- const skillDir = dirname(scriptDir)
38
-
39
- // Step 1: 输入校验(必须首先执行,失败则短路退出)
40
- const checkResult = checkInputVars(inputPath)
41
- if (checkResult.error) {
42
- console.log(render(INVALID_OUTPUT_TEMPLATE, { error: checkResult.error }))
43
- process.exit(0)
44
- }
45
- console.log(OK_INPUT_VALID)
46
- console.log()
47
-
48
- // Step 2: 解析系统变量
49
- const sysVars = resolveSystemVars(skillDir)
50
- console.log(formatSystemVars(sysVars))
51
- console.log()
52
-
53
- // Step 3: 创建 Run 变量
54
- const runResult = resolveRunVars(sysVars.skill_data_dir, inputPath, sysVars.skill_name)
55
- if (runResult.error) {
56
- console.log(render(INVALID_OUTPUT_TEMPLATE, { error: runResult.error }))
57
- process.exit(0)
58
- }
59
- console.log(formatRunVars(runResult))
60
- console.log()
61
-
62
- // Step 4: 检查并安装 npm 依赖
63
- const depResult = resolveDependencies(skillDir)
64
- if (depResult.status === DEPS_FAIL) {
65
- console.log(DEPS_FAIL_OUTPUT_TEMPLATE)
66
- console.log()
67
- console.log(DEPS_HEADER_TEMPLATE)
68
- console.log(formatDependencies(depResult))
69
- process.exit(3)
70
- }
71
- console.log(DEPS_OK_OUTPUT_TEMPLATE)
72
- console.log()
73
- console.log(DEPS_HEADER_TEMPLATE)
74
- console.log(formatDependencies(depResult))
75
- }
@@ -1,124 +0,0 @@
1
- /**
2
- * resolve_run_vars.js — 创建 Run 变量表(容错转换 + 计算)
3
- *
4
- * 输入:argv[2] = skill_data_dir(系统变量),argv[3] = input_path,argv[4] = skill_name(系统变量)
5
- * 容错:input_path 为文件 → md_files = [该文件];为目录 → md_files = 目录下所有 .md 文件
6
- * 校验:skill_data_dir 存在且为目录 + 文件扩展名 .md + 目录下无 .md 文件
7
- *
8
- * 输出:OK: Run 变量已解析 + ## Run 变量表(md_files / run_name / run_dir / output_dir)
9
- *
10
- * 职责边界:本脚本只创建 Run 变量;系统变量由 resolve_system_vars.js 负责,依赖检查由 resolve_dependencies.js 负责。
11
- */
12
-
13
- import { existsSync, statSync, readdirSync } from 'fs'
14
- import { dirname, basename, join, extname } from 'path'
15
- import { render, resolveOutputDir } from '../../shared/scripts/utils.js'
16
-
17
- const SUPPORTED_EXT = '.md'
18
-
19
- // ── 本脚本常量 ──
20
- const INVALID_OUTPUT_TEMPLATE = 'INVALID: ${error}'
21
- const ERR_INPUT_INVALID = '请提示用户输入不合法,任务结束'
22
- const ERR_INIT_FAILED = '请提示用户环境初始化失败,任务结束'
23
-
24
- // ── 输出模板(CLI stdout:status 行 + data 块,占位符 ${var} 运行时替换)──
25
- const RUN_VARS_OUTPUT_TEMPLATE = `OK: Run 变量已解析
26
-
27
- ## Run 变量表
28
-
29
- | 变量 | 值 | 说明 |
30
- |---|---|---|
31
- | \`md_files\` | \${md_files} | 待转换的 markdown 文件列表(逗号分隔) |
32
- | \`run_name\` | \${run_name} | 运行标识(input_path 所在目录名) |
33
- | \`run_dir\` | \${run_dir} | 本次执行数据目录 |
34
- | \`output_dir\` | \${output_dir} | 最终产物输出目录(source_dir/skill_name) |`
35
-
36
- // 业务校验不合法(短路信号,stdout + exit 0)
37
-
38
- /**
39
- * 在目录中查找所有 .md 文件(非递归,仅当前层级)
40
- * @param {string} dir — 目录路径
41
- * @returns {string[]} — 匹配的文件完整路径列表,无匹配返回空数组
42
- */
43
- function findMdFiles(dir) {
44
- const entries = readdirSync(dir)
45
- return entries
46
- .filter((entry) => {
47
- const fullPath = join(dir, entry)
48
- return statSync(fullPath).isFile() && extname(entry).toLowerCase() === SUPPORTED_EXT
49
- })
50
- .map((entry) => join(dir, entry))
51
- }
52
-
53
- /**
54
- * 容错转换 input_path → md_files,计算 run 变量(纯函数,可测试)。
55
- * @param {string} skillDataDir — skill 数据目录(由 resolve_system_vars.js 解析)
56
- * @param {string} inputPath — 源文件路径或目录路径(已由 check_input_vars.js 校验)
57
- * @param {string} skillName — skill 名称(来自系统变量 {{skill_name}})
58
- * @returns {{md_files: string[], run_name: string, run_dir: string, output_dir: string} | {error: string}}
59
- */
60
- export function resolveRunVars(skillDataDir, inputPath, skillName) {
61
- // 校验:skill_data_dir(runtime 变量创建依赖它)
62
- if (!existsSync(skillDataDir) || !statSync(skillDataDir).isDirectory()) {
63
- return { error: `系统变量 skill_data_dir 非法:${skillDataDir},${ERR_INIT_FAILED}` }
64
- }
65
- // 容错转换:文件 → md_files = [该文件];目录 → md_files = 目录下所有 .md 文件
66
- let mdFiles
67
- let runName
68
- // output_dir = source_dir / skill_name
69
- const outputDir = resolveOutputDir(inputPath, skillName)
70
- if (statSync(inputPath).isFile()) {
71
- // 校验:文件扩展名必须为 .md
72
- const ext = extname(inputPath).toLowerCase()
73
- if (ext !== SUPPORTED_EXT) {
74
- return { error: `input_path 文件扩展名不支持(仅 .md):${inputPath},${ERR_INPUT_INVALID}` }
75
- }
76
- mdFiles = [inputPath]
77
- runName = basename(dirname(inputPath))
78
- } else if (statSync(inputPath).isDirectory()) {
79
- mdFiles = findMdFiles(inputPath)
80
- if (mdFiles.length === 0) {
81
- return { error: `input_path 目录下无 .md 文件:${inputPath},${ERR_INPUT_INVALID}` }
82
- }
83
- runName = basename(inputPath)
84
- }
85
- const runDir = join(skillDataDir, runName)
86
- return {
87
- md_files: mdFiles,
88
- run_name: runName,
89
- run_dir: runDir,
90
- output_dir: outputDir,
91
- }
92
- }
93
-
94
- /**
95
- * 渲染 Run 变量表为 Markdown 字符串(供 init.js 复用模板)。
96
- * @param {{md_files: string[], run_name: string, run_dir: string, output_dir: string}} vars
97
- * @returns {string}
98
- */
99
- export function formatRunVars(vars) {
100
- const renderData = { ...vars, md_files: vars.md_files.join(',') }
101
- return render(RUN_VARS_OUTPUT_TEMPLATE, renderData)
102
- }
103
-
104
- // ── CLI 入口 ──
105
- const isMain = import.meta.url === `file://${process.argv[1]}`
106
- if (isMain) {
107
- const skillDataDir = process.argv[2]
108
- const inputPath = process.argv[3]
109
- const skillName = process.argv[4]
110
-
111
- if (!skillDataDir || !inputPath || !skillName) {
112
- console.error('Usage: node resolve_run_vars.js <skill_data_dir> <input_path> <skill_name>')
113
- process.exit(2)
114
- }
115
-
116
- const result = resolveRunVars(skillDataDir, inputPath, skillName)
117
-
118
- if (result.error) {
119
- console.log(render(INVALID_OUTPUT_TEMPLATE, { error: result.error }))
120
- process.exit(0)
121
- }
122
-
123
- console.log(formatRunVars(result))
124
- }
@@ -1,47 +0,0 @@
1
- ---
2
- name: create-ppt
3
- description: Use when converting text/markdown/PDF source files into two styles of presentation-format markdown and pptx files. Triggers on: create ppt, create presentation, 生成PPT, 制作汇报, 文档转PPT, 汇报材料.
4
- ---
5
-
6
- 作为 Scrum 开发者,我想要将源文件(txt/md/pdf)转换为两种风格的演示文稿,以便交付 .md 和 .pptx 文件。using the **fixed-sequence Sprint workflow** (seq)。
7
-
8
- # Product Goal
9
-
10
- Convert source files (txt/md/pdf) into two styles of presentation-format .md and .pptx files.
11
-
12
- # Extract Variables
13
-
14
- Extract input variables from the context:
15
-
16
- | Variable | Type | Required | Description |
17
- |---|---|---|---|
18
- | `input_path` | string | ✅ | source file or directory path |
19
- | `force` | boolean | ❌ | clear `{{run_dir}}` before Sprint runs, default `true` |
20
-
21
- # Environment Initialization
22
-
23
- 1. Run `node scripts/init.js '{{input_path}}' '{{force}}'` to validate input, resolve variables and check npm dependencies. `force` defaults to `true` (clears `{{run_dir}}` before any Sprint runs).
24
- 2. Read **Sprint Standards** `{{shared_dir}}/references/sprint_standards.md`.
25
-
26
- # Product Increment
27
-
28
- | Product | Type | Description | DoD |
29
- |---|---|---|---|
30
- | `{{output_dir}}/*.md` + `*.pptx` | file | two styles of PPT-format markdown and pptx files | 2 .md + 2 .pptx exist in `{{output_dir}}` |
31
-
32
- # Sprint Backlogs
33
-
34
- | Sprint Name | Backlog File | Description |
35
- |---|---|---|
36
- | Sprint for progress | `{{shared_dir}}/references/sprint_for_progress.md` | shared skill file — manage resume state / release_progress.csv (force clear is done by `init.js`) |
37
- | Sprint for source-discovery | `{{skill_dir}}/references/sprint_for_source_discovery.md` | discover all txt/md/pdf source files into source_files.csv |
38
- | Sprint for ppt-generation | `{{skill_dir}}/references/sprint_for_ppt_generation.md` | aggregate source content, generate 2 styles of PPT-format .md and convert to pptx |
39
-
40
- # Sprint Now!
41
-
42
- Read all **Sprint Backlogs**, follow **Sprint Workflow** `{{shared_dir}}/references/run/run_sprint_loop.md`, then *sprint*.
43
-
44
- ## Iron Laws
45
-
46
- - **Rulings, not stalls**: When content interpretation is ambiguous (e.g., a source file has no clear structure), make a ruling and continue — do not stop to ask the user. Pick the most reasonable interpretation and proceed.
47
- - **Continuous execution**: Process all source files in sequence without pausing to report between batches. The loop prints batch status but does not stop for user confirmation between batches.
@@ -1,9 +0,0 @@
1
- {
2
- "name": "create-ppt-skill",
3
- "version": "1.0.0",
4
- "private": true,
5
- "type": "module",
6
- "dependencies": {
7
- "pptxgenjs": "^3.12.0"
8
- }
9
- }