byteplan-cli 1.0.2 → 1.2.2

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 (66) hide show
  1. package/package.json +7 -3
  2. package/skills/byteplan-analysis/SKILL.md +1078 -0
  3. package/skills/byteplan-api/API_REFERENCE.md +249 -0
  4. package/skills/byteplan-api/SKILL.md +96 -0
  5. package/skills/byteplan-api/package.json +16 -0
  6. package/skills/byteplan-api/scripts/api.js +973 -0
  7. package/skills/byteplan-excel/SKILL.md +212 -0
  8. package/skills/byteplan-excel/examples/margin-analysis.json +40 -0
  9. package/skills/byteplan-excel/package.json +12 -0
  10. package/skills/byteplan-excel/pnpm-lock.yaml +68 -0
  11. package/skills/byteplan-excel/scripts/generate_excel.js +156 -0
  12. package/skills/byteplan-html/SKILL.md +490 -0
  13. package/skills/byteplan-html/examples/example-output.html +184 -0
  14. package/skills/byteplan-html/examples/generate-ppt-style-html.js +611 -0
  15. package/skills/byteplan-html/examples/margin-contribution-analysis.json +152 -0
  16. package/skills/byteplan-html/package.json +18 -0
  17. package/skills/byteplan-html/scripts/generate_html.js +517 -0
  18. package/skills/byteplan-ppt/SKILL.md +394 -0
  19. package/skills/byteplan-ppt/examples/margin-contribution-analysis.json +152 -0
  20. package/skills/byteplan-ppt/package.json +16 -0
  21. package/skills/byteplan-ppt/pnpm-lock.yaml +138 -0
  22. package/skills/byteplan-ppt/scripts/check_ppt_overlap.js +318 -0
  23. package/skills/byteplan-ppt/scripts/generate_ppt.js +680 -0
  24. package/skills/byteplan-video/SKILL.md +606 -0
  25. package/skills/byteplan-video/examples/sample-video-data.json +82 -0
  26. package/skills/byteplan-video/remotion-project/package.json +22 -0
  27. package/skills/byteplan-video/remotion-project/pnpm-lock.yaml +1646 -0
  28. package/skills/byteplan-video/remotion-project/remotion.config.ts +6 -0
  29. package/skills/byteplan-video/remotion-project/scene_durations.json +32 -0
  30. package/skills/byteplan-video/remotion-project/scripts/generate_audio.js +279 -0
  31. package/skills/byteplan-video/remotion-project/src/DynamicReport.tsx +172 -0
  32. package/skills/byteplan-video/remotion-project/src/Root.tsx +51 -0
  33. package/skills/byteplan-video/remotion-project/src/SalesReport.tsx +107 -0
  34. package/skills/byteplan-video/remotion-project/src/index.tsx +4 -0
  35. package/skills/byteplan-video/remotion-project/src/scenes/ChartSlide.tsx +201 -0
  36. package/skills/byteplan-video/remotion-project/src/scenes/CoverSlide.tsx +61 -0
  37. package/skills/byteplan-video/remotion-project/src/scenes/EndSlide.tsx +60 -0
  38. package/skills/byteplan-video/remotion-project/src/scenes/InsightSlide.tsx +101 -0
  39. package/skills/byteplan-video/remotion-project/src/scenes/KpiSlide.tsx +84 -0
  40. package/skills/byteplan-video/remotion-project/src/scenes/RecommendationSlide.tsx +100 -0
  41. package/skills/byteplan-video/remotion-project/tsconfig.json +13 -0
  42. package/skills/byteplan-video/remotion-project/video_data.json +76 -0
  43. package/skills/byteplan-video/scripts/generate_video.js +270 -0
  44. package/skills/byteplan-video/templates/package.json +31 -0
  45. package/skills/byteplan-video/templates/pnpm-lock.yaml +2200 -0
  46. package/skills/byteplan-video/templates/remotion.config.ts +9 -0
  47. package/skills/byteplan-video/templates/scripts/generate-audio.ts +55 -0
  48. package/skills/byteplan-video/templates/src/components/BarChartScene.tsx +153 -0
  49. package/skills/byteplan-video/templates/src/components/InsightScene.tsx +135 -0
  50. package/skills/byteplan-video/templates/src/components/LineChartScene.tsx +214 -0
  51. package/skills/byteplan-video/templates/src/components/SceneFactory.tsx +34 -0
  52. package/skills/byteplan-video/templates/src/components/SummaryScene.tsx +155 -0
  53. package/skills/byteplan-video/templates/src/components/TitleScene.tsx +130 -0
  54. package/skills/byteplan-video/templates/src/compositions/AnalysisVideo.tsx +39 -0
  55. package/skills/byteplan-video/templates/src/index.tsx +28 -0
  56. package/skills/byteplan-video/templates/src/register-root.tsx +4 -0
  57. package/skills/byteplan-video/templates/src/storyboard/types.ts +46 -0
  58. package/skills/byteplan-video/templates/tsconfig.json +17 -0
  59. package/skills/byteplan-video/templates/tsconfig.scripts.json +13 -0
  60. package/skills/byteplan-word/SKILL.md +233 -0
  61. package/skills/byteplan-word/package.json +12 -0
  62. package/skills/byteplan-word/pnpm-lock.yaml +120 -0
  63. package/skills/byteplan-word/scripts/generate_word.js +548 -0
  64. package/src/api.js +78 -22
  65. package/src/cli.js +11 -0
  66. package/src/commands/skills.js +279 -0
@@ -0,0 +1,212 @@
1
+ ---
2
+ name: byteplan-excel
3
+ description: 根据已有的分析数据生成 Excel 报告。只输出结构化数据表格,不包含说明文字。需要先使用 byteplan-analysis skill 完成数据分析。
4
+ ---
5
+
6
+ # BytePlan Excel 报告 Skill
7
+
8
+ ## 概述
9
+
10
+ 此 Skill 根据已有的分析数据生成 Excel 报告,**只输出结构化数据表格**:
11
+
12
+ 1. **读取数据** - 从工作目录读取分析结果数据
13
+ 2. **转换格式** - 将数据转换为 Excel 表格格式
14
+ 3. **生成 Excel** - 使用 xlsx 库创建工作簿
15
+
16
+ **设计原则**:简洁、结构化、纯数据展示。
17
+
18
+ **前置条件**:必须先使用 [byteplan-analysis](../byteplan-analysis/SKILL.md) skill 完成数据分析。
19
+
20
+ ---
21
+
22
+ ## 输出规范
23
+
24
+ ### 1. 文件命名
25
+
26
+ ```
27
+ {分析主题}报告.xlsx
28
+ ```
29
+
30
+ ### 2. Sheet 结构
31
+
32
+ 每个分析维度生成一个独立的 Sheet:
33
+
34
+ | Sheet 名称 | 内容 | 列结构 |
35
+ |-----------|------|--------|
36
+ | TOP3贡献要素 | 贡献最大的三个要素 | 排名、维度、要素、金额、贡献占比 |
37
+ | 费用类别贡献 | 按费用类别的贡献分析 | 费用类别、金额、贡献占比 |
38
+ | 资产类别贡献 | 按资产类别的贡献分析 | 资产类别、金额、贡献占比 |
39
+ | 分摊步骤贡献 | 按分摊步骤的贡献分析 | 分摊步骤、金额、贡献占比 |
40
+ | ... | 根据实际分析维度动态生成 | ... |
41
+
42
+ ### 3. 数据格式
43
+
44
+ | 字段类型 | 格式 | 示例 |
45
+ |---------|------|------|
46
+ | 金额 | 数字,保留2位小数 | 16898.63 |
47
+ | 占比 | 数字,保留3位小数 | 0.449 |
48
+ | 排名 | 整数 | 1, 2, 3 |
49
+ | 名称 | 字符串 | 研发费用 |
50
+
51
+ ### 4. 列宽设置
52
+
53
+ ```javascript
54
+ // 根据内容自动设置列宽
55
+ ws["!cols"] = [
56
+ { wch: 40 }, // 名称列
57
+ { wch: 15 }, // 金额列
58
+ { wch: 12 } // 占比列
59
+ ];
60
+ ```
61
+
62
+ ---
63
+
64
+ ## 数据格式
65
+
66
+ ### 输入数据结构(excel_data.json)
67
+
68
+ ```json
69
+ {
70
+ "sheets": [
71
+ {
72
+ "name": "TOP3贡献要素",
73
+ "columns": ["排名", "维度", "要素", "金额", "贡献占比"],
74
+ "data": [
75
+ [1, "分摊步骤", "其他费用分摊", 33396.69, 0.887],
76
+ [2, "费用类别", "研发费用", 16898.63, 0.449],
77
+ [3, "资产类别", "固定资产-施工设备-卷扬机、升降机", 15636.13, 0.579]
78
+ ]
79
+ },
80
+ {
81
+ "name": "费用类别贡献",
82
+ "columns": ["费用类别", "金额", "贡献占比"],
83
+ "data": [
84
+ ["研发费用", 16898.63, 0.449],
85
+ ["销售费用", 13363.98, 0.355],
86
+ ["管理费用", 6418.02, 0.170],
87
+ ["生产成本", 966.12, 0.026]
88
+ ]
89
+ }
90
+ ]
91
+ }
92
+ ```
93
+
94
+ ---
95
+
96
+ ## 使用方法
97
+
98
+ ### 方式一:命令行
99
+
100
+ ```bash
101
+ # 使用默认数据文件 (excel_data.json)
102
+ cd skills/byteplan-excel
103
+ pnpm run generate -o report.xlsx
104
+
105
+ # 指定数据文件
106
+ pnpm run generate -o report.xlsx -d /path/to/data.json
107
+ ```
108
+
109
+ ### 方式二:Node.js 调用
110
+
111
+ ```javascript
112
+ import { generateExcel } from './scripts/generate_excel.js';
113
+
114
+ generateExcel('report.xlsx', 'data.json');
115
+ ```
116
+
117
+ ### 方式三:直接传入数据
118
+
119
+ ```javascript
120
+ import { generateExcelFromData } from './scripts/generate_excel.js';
121
+
122
+ const data = {
123
+ sheets: [
124
+ {
125
+ name: "费用类别贡献",
126
+ columns: ["费用类别", "金额", "贡献占比"],
127
+ data: [
128
+ ["研发费用", 16898.63, 0.449],
129
+ ["销售费用", 13363.98, 0.355]
130
+ ]
131
+ }
132
+ ]
133
+ };
134
+
135
+ generateExcelFromData('report.xlsx', data);
136
+ ```
137
+
138
+ ---
139
+
140
+ ## 完整示例
141
+
142
+ ### 1. 准备数据文件
143
+
144
+ ```bash
145
+ # 从分析结果生成数据文件
146
+ # 确保 excel_data.json 包含所有必要字段
147
+ ```
148
+
149
+ ### 2. 生成 Excel
150
+
151
+ ```bash
152
+ cd skills/byteplan-excel
153
+ pnpm run generate -o 边际分析报告.xlsx
154
+ ```
155
+
156
+ ### 3. 打开查看
157
+
158
+ ```bash
159
+ open 边际分析报告.xlsx
160
+ ```
161
+
162
+ ---
163
+
164
+ ## ⚠️ 重要规则
165
+
166
+ ### 文件输出位置
167
+
168
+ **所有生成的 Excel 文件必须放在 BytePlan 工作目录下:**
169
+
170
+ ```
171
+ ~/.byteplan/workspaces/{主题}_{时间戳}/{主题}报告.xlsx
172
+ ```
173
+
174
+ **❌ 错误位置:**
175
+ - `~/.openclaw/workspace/`
176
+ - `/tmp/`
177
+ - 当前任意目录
178
+
179
+ **✅ 正确位置:**
180
+ - `~/.byteplan/workspaces/边际分析_20260331_230800/边际分析报告.xlsx`
181
+
182
+ ### 数据来源
183
+
184
+ Excel 数据必须来自 `byteplan-analysis` 的分析结果,不能凭空编造数据。
185
+
186
+ ---
187
+
188
+ ## 与其他 Skill 的关系
189
+
190
+ ```
191
+ byteplan-analysis ← 数据分析(必须先执行)
192
+
193
+ analysis_report.md
194
+ analysisPlan.json
195
+
196
+ byteplan-excel ← 生成 Excel(读取分析结果)
197
+
198
+ xxx报告.xlsx
199
+
200
+ byteplan-ppt ← 生成 PPT(可选)
201
+ byteplan-word ← 生成 Word(可选)
202
+ ```
203
+
204
+ ---
205
+
206
+ ## 注意事项
207
+
208
+ - **只输出数据**:Excel 中只包含结构化数据表格,不包含说明文字、标题等
209
+ - **每个维度一个 Sheet**:不同分析维度分别放在独立的 Sheet
210
+ - **数据来源**:必须基于 byteplan-analysis 的分析结果
211
+ - **文件位置**:输出文件必须放在 BytePlan 工作目录
212
+ - **包管理器**:使用 pnpm 安装依赖
@@ -0,0 +1,40 @@
1
+ {
2
+ "sheets": [
3
+ {
4
+ "name": "TOP3贡献要素",
5
+ "columns": ["排名", "维度", "要素", "金额", "贡献占比"],
6
+ "data": [
7
+ [1, "分摊步骤", "其他费用分摊", 33396.69, 0.887],
8
+ [2, "费用类别", "研发费用", 16898.63, 0.449],
9
+ [3, "资产类别", "固定资产-施工设备-卷扬机、升降机", 15636.13, 0.579]
10
+ ]
11
+ },
12
+ {
13
+ "name": "费用类别贡献",
14
+ "columns": ["费用类别", "金额", "贡献占比"],
15
+ "data": [
16
+ ["研发费用", 16898.63, 0.449],
17
+ ["销售费用", 13363.98, 0.355],
18
+ ["管理费用", 6418.02, 0.170],
19
+ ["生产成本", 966.12, 0.026]
20
+ ]
21
+ },
22
+ {
23
+ "name": "资产类别贡献",
24
+ "columns": ["资产类别", "金额", "贡献占比"],
25
+ "data": [
26
+ ["固定资产-施工设备-卷扬机、升降机", 15636.13, 0.579],
27
+ ["固定资产-工业生产设备-内燃机", 11370.07, 0.421],
28
+ ["计算机", 0, 0]
29
+ ]
30
+ },
31
+ {
32
+ "name": "分摊步骤贡献",
33
+ "columns": ["分摊步骤", "金额", "贡献占比"],
34
+ "data": [
35
+ ["其他费用分摊", 33396.69, 0.887],
36
+ ["研发费用分摊", 4250.06, 0.113]
37
+ ]
38
+ }
39
+ ]
40
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "byteplan-excel",
3
+ "version": "1.0.0",
4
+ "description": "BytePlan Excel 报告生成",
5
+ "type": "module",
6
+ "scripts": {
7
+ "generate": "node scripts/generate_excel.js"
8
+ },
9
+ "dependencies": {
10
+ "xlsx": "^0.18.5"
11
+ }
12
+ }
@@ -0,0 +1,68 @@
1
+ lockfileVersion: '6.0'
2
+
3
+ dependencies:
4
+ xlsx:
5
+ specifier: ^0.18.5
6
+ version: 0.18.5
7
+
8
+ packages:
9
+
10
+ /adler-32@1.3.1:
11
+ resolution: {integrity: sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==}
12
+ engines: {node: '>=0.8'}
13
+ dev: false
14
+
15
+ /cfb@1.2.2:
16
+ resolution: {integrity: sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==}
17
+ engines: {node: '>=0.8'}
18
+ dependencies:
19
+ adler-32: 1.3.1
20
+ crc-32: 1.2.2
21
+ dev: false
22
+
23
+ /codepage@1.15.0:
24
+ resolution: {integrity: sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==}
25
+ engines: {node: '>=0.8'}
26
+ dev: false
27
+
28
+ /crc-32@1.2.2:
29
+ resolution: {integrity: sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==}
30
+ engines: {node: '>=0.8'}
31
+ hasBin: true
32
+ dev: false
33
+
34
+ /frac@1.1.2:
35
+ resolution: {integrity: sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==}
36
+ engines: {node: '>=0.8'}
37
+ dev: false
38
+
39
+ /ssf@0.11.2:
40
+ resolution: {integrity: sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==}
41
+ engines: {node: '>=0.8'}
42
+ dependencies:
43
+ frac: 1.1.2
44
+ dev: false
45
+
46
+ /wmf@1.0.2:
47
+ resolution: {integrity: sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==}
48
+ engines: {node: '>=0.8'}
49
+ dev: false
50
+
51
+ /word@0.3.0:
52
+ resolution: {integrity: sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==}
53
+ engines: {node: '>=0.8'}
54
+ dev: false
55
+
56
+ /xlsx@0.18.5:
57
+ resolution: {integrity: sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==}
58
+ engines: {node: '>=0.8'}
59
+ hasBin: true
60
+ dependencies:
61
+ adler-32: 1.3.1
62
+ cfb: 1.2.2
63
+ codepage: 1.15.0
64
+ crc-32: 1.2.2
65
+ ssf: 0.11.2
66
+ wmf: 1.0.2
67
+ word: 0.3.0
68
+ dev: false
@@ -0,0 +1,156 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * BytePlan Excel 报告生成脚本
5
+ *
6
+ * 功能:根据分析数据生成结构化的 Excel 报告
7
+ *
8
+ * 使用方式:
9
+ * node generate_excel.js -o output.xlsx [-d data.json]
10
+ *
11
+ * 参数:
12
+ * -o, --output 输出文件路径(必需)
13
+ * -d, --data 数据文件路径(默认:excel_data.json)
14
+ */
15
+
16
+ import XLSX from 'xlsx';
17
+ import { readFileSync, writeFileSync, existsSync } from 'fs';
18
+ import { resolve, dirname, basename } from 'path';
19
+ import { homedir } from 'os';
20
+ import { fileURLToPath } from 'url';
21
+
22
+ const __dirname = dirname(fileURLToPath(import.meta.url));
23
+
24
+ /**
25
+ * 解析命令行参数
26
+ */
27
+ function parseArgs() {
28
+ const args = process.argv.slice(2);
29
+ const params = {
30
+ output: null,
31
+ data: null
32
+ };
33
+
34
+ for (let i = 0; i < args.length; i++) {
35
+ if ((args[i] === '-o' || args[i] === '--output') && args[i + 1]) {
36
+ params.output = args[i + 1];
37
+ i++;
38
+ } else if ((args[i] === '-d' || args[i] === '--data') && args[i + 1]) {
39
+ params.data = args[i + 1];
40
+ i++;
41
+ }
42
+ }
43
+
44
+ return params;
45
+ }
46
+
47
+ /**
48
+ * 计算列宽
49
+ */
50
+ function calculateColWidth(data, columns) {
51
+ const widths = columns.map((col, idx) => {
52
+ // 列标题宽度
53
+ let maxWidth = String(col).length * 2 + 2;
54
+
55
+ // 数据宽度
56
+ data.forEach(row => {
57
+ const cellValue = row[idx];
58
+ const cellWidth = String(cellValue ?? '').length * 2 + 2;
59
+ if (cellWidth > maxWidth) {
60
+ maxWidth = cellWidth;
61
+ }
62
+ });
63
+
64
+ return Math.min(Math.max(maxWidth, 10), 50);
65
+ });
66
+
67
+ return widths.map(w => ({ wch: w }));
68
+ }
69
+
70
+ /**
71
+ * 从数据对象生成 Excel
72
+ */
73
+ export function generateExcelFromData(outputPath, data) {
74
+ const wb = XLSX.utils.book_new();
75
+
76
+ // 遍历每个 Sheet
77
+ for (const sheet of data.sheets) {
78
+ // 组装数据:第一行是列标题,后面是数据行
79
+ const sheetData = [sheet.columns, ...sheet.data];
80
+
81
+ // 创建 Sheet
82
+ const ws = XLSX.utils.aoa_to_sheet(sheetData);
83
+
84
+ // 设置列宽
85
+ ws['!cols'] = calculateColWidth(sheet.data, sheet.columns);
86
+
87
+ // 添加到工作簿
88
+ XLSX.utils.book_append_sheet(wb, ws, sheet.name);
89
+ }
90
+
91
+ // 写入文件
92
+ XLSX.writeFile(wb, outputPath);
93
+
94
+ return outputPath;
95
+ }
96
+
97
+ /**
98
+ * 从 JSON 文件生成 Excel
99
+ */
100
+ export function generateExcel(outputPath, dataPath) {
101
+ // 检查数据文件
102
+ if (!existsSync(dataPath)) {
103
+ console.error(`❌ 数据文件不存在: ${dataPath}`);
104
+ process.exit(1);
105
+ }
106
+
107
+ // 读取数据
108
+ const data = JSON.parse(readFileSync(dataPath, 'utf-8'));
109
+
110
+ // 生成 Excel
111
+ return generateExcelFromData(outputPath, data);
112
+ }
113
+
114
+ /**
115
+ * 主函数
116
+ */
117
+ function main() {
118
+ const params = parseArgs();
119
+
120
+ if (!params.output) {
121
+ console.log(`
122
+ BytePlan Excel 报告生成
123
+
124
+ 使用方式:
125
+ node generate_excel.js -o output.xlsx [-d data.json]
126
+
127
+ 参数:
128
+ -o, --output 输出文件路径(必需)
129
+ -d, --data 数据文件路径(默认:excel_data.json)
130
+
131
+ 示例:
132
+ node generate_excel.js -o 报告.xlsx
133
+ node generate_excel.js -o 报告.xlsx -d ../excel_data.json
134
+ `);
135
+ process.exit(0);
136
+ }
137
+
138
+ // 默认数据文件
139
+ const dataPath = params.data || resolve(__dirname, '../excel_data.json');
140
+ const outputPath = resolve(params.output);
141
+
142
+ console.log(`📊 生成 Excel 报告...`);
143
+ console.log(` 数据: ${dataPath}`);
144
+ console.log(` 输出: ${outputPath}`);
145
+
146
+ try {
147
+ generateExcel(outputPath, dataPath);
148
+ console.log(`✅ Excel 已生成: ${outputPath}`);
149
+ } catch (error) {
150
+ console.error(`❌ 生成失败: ${error.message}`);
151
+ process.exit(1);
152
+ }
153
+ }
154
+
155
+ // 执行主函数
156
+ main();