@paircode/tool-office 1.0.2 → 1.0.4
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/index.js +335 -335
- package/package.json +1 -1
- package/bin/tool-office.exe +0 -0
package/index.js
CHANGED
|
@@ -1,335 +1,335 @@
|
|
|
1
|
-
// ═══════════════════════════════════════════════════════════════
|
|
2
|
-
// tool-office — 办公文档(csv_read/csv_write/json_to_table/table_stats/text_report/word_read)
|
|
3
|
-
//
|
|
4
|
-
// 生成来源(2026-08-16):内置 Go 工具组 → 磁盘外置插件(tool_plugin_gen.go
|
|
5
|
-
// 自动生成,schema 完整外置拷贝)。api 声明在插件,execute 调 ctx.binary 复用本插件目录 bin/ 下的独立二进制(源码 plugins-src/plugins/<name>/,改实现重编译即更换)。
|
|
6
|
-
// 工具清单:csv_read、csv_write、json_to_table、table_stats、text_report、word_read、word_write、read_xlsx、write_xlsx、read_pdf、markdown_to_html
|
|
7
|
-
// ═══════════════════════════════════════════════════════════════
|
|
8
|
-
const tools = [
|
|
9
|
-
{
|
|
10
|
-
"name": "csv_read",
|
|
11
|
-
"description": "读取 CSV/TSV 文件并以 Markdown 表格形式返回内容。参数 delimiter 可选 \"comma\"(逗号, 默认)或 \"tab\"(制表符)。columns 按列索引过滤(从 0 开始,逗号分隔,如 \"0,2,3\")。limit 限制返回行数(默认 100,-1=全部),offset 跳过前 N 行。",
|
|
12
|
-
"usageGuide": "读取 CSV/TSV 文件并以 Markdown 表格形式返回。比直接
|
|
13
|
-
"parameters": {
|
|
14
|
-
"properties": {
|
|
15
|
-
"columns": {
|
|
16
|
-
"description": "可选:要显示的列索引(从 0 开始,逗号分隔),省略显示全部",
|
|
17
|
-
"type": "string"
|
|
18
|
-
},
|
|
19
|
-
"delimiter": {
|
|
20
|
-
"description": "可选:分隔符,\"comma\"(逗号)或 \"tab\"(制表符),默认 \"comma\"",
|
|
21
|
-
"type": "string"
|
|
22
|
-
},
|
|
23
|
-
"limit": {
|
|
24
|
-
"description": "可选:最大返回行数(默认 100,-1 表示全部)",
|
|
25
|
-
"type": "integer"
|
|
26
|
-
},
|
|
27
|
-
"offset": {
|
|
28
|
-
"description": "可选:跳过前 N 行(默认 0)",
|
|
29
|
-
"type": "integer"
|
|
30
|
-
},
|
|
31
|
-
"path": {
|
|
32
|
-
"description": "
|
|
33
|
-
"type": "string"
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"required": [
|
|
37
|
-
"path"
|
|
38
|
-
],
|
|
39
|
-
"type": "object"
|
|
40
|
-
},
|
|
41
|
-
"readOnly": true
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"name": "csv_write",
|
|
45
|
-
"description": "将表格数据写入 CSV/TSV 文件。data 为 JSON 二维数组(如 [[\"列1\",\"列2\"],[\"值1\",\"值2\"]])或 Markdown 表格文本。delimiter 可选 \"comma\"(逗号, 默认)或 \"tab\"(制表符)。header 为可选的表头行 JSON 数组,省略则从 data 首行自动提取。",
|
|
46
|
-
"usageGuide": "将表格数据写入 CSV/TSV 文件。data 参数支持 JSON 二维数组或 Markdown 表格文本。比手动拼接 CSV 更高效(自动处理转义+分隔符)。需审核批准。",
|
|
47
|
-
"parameters": {
|
|
48
|
-
"properties": {
|
|
49
|
-
"data": {
|
|
50
|
-
"description": "表格数据:JSON 二维数组字符串,或 Markdown 表格文本",
|
|
51
|
-
"type": "string"
|
|
52
|
-
},
|
|
53
|
-
"delimiter": {
|
|
54
|
-
"description": "可选:分隔符 \"comma\" 或 \"tab\",默认 \"comma\"",
|
|
55
|
-
"type": "string"
|
|
56
|
-
},
|
|
57
|
-
"header": {
|
|
58
|
-
"description": "可选:表头行 JSON 数组,如 \"[\"姓名\",\"年龄\"]\"",
|
|
59
|
-
"type": "string"
|
|
60
|
-
},
|
|
61
|
-
"path": {
|
|
62
|
-
"description": "
|
|
63
|
-
"type": "string"
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
"required": [
|
|
67
|
-
"path",
|
|
68
|
-
"data"
|
|
69
|
-
],
|
|
70
|
-
"type": "object"
|
|
71
|
-
},
|
|
72
|
-
"requiresApproval": true
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"name": "json_to_table",
|
|
76
|
-
"description": "将 JSON 数组字符串转为 Markdown 表格。columns 指定列名和顺序(逗号分隔,如 \"name,age\"),省略则使用全部键并按字母序排列。limit 限制行数(默认 100,-1=全部),title 可选表格标题。",
|
|
77
|
-
"usageGuide": "将 JSON 数组字符串转为 Markdown 表格。columns 参数指定列名和顺序。比手动格式化更高效(自动生成表头+对齐)。",
|
|
78
|
-
"parameters": {
|
|
79
|
-
"properties": {
|
|
80
|
-
"columns": {
|
|
81
|
-
"description": "可选:显示的键名(逗号分隔),省略则用全部键",
|
|
82
|
-
"type": "string"
|
|
83
|
-
},
|
|
84
|
-
"json": {
|
|
85
|
-
"description": "JSON 数组字符串(必填,如 [{\"name\":\"张三\",\"age\":30}])",
|
|
86
|
-
"type": "string"
|
|
87
|
-
},
|
|
88
|
-
"limit": {
|
|
89
|
-
"description": "可选:最大行数(默认 100,-1=全部)",
|
|
90
|
-
"type": "integer"
|
|
91
|
-
},
|
|
92
|
-
"title": {
|
|
93
|
-
"description": "可选:表格标题",
|
|
94
|
-
"type": "string"
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
"required": [
|
|
98
|
-
"json"
|
|
99
|
-
],
|
|
100
|
-
"type": "object"
|
|
101
|
-
},
|
|
102
|
-
"readOnly": true
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
"name": "table_stats",
|
|
106
|
-
"description": "对表格数据的数值列做基本统计(求和、均值、最大值、最小值、计数)。data 为 CSV 文本、JSON 数组或文件路径。format 指定数据格式:\"csv\"(CSV 文本)\"json\"(JSON 数组)\"file\"(文件路径)。group_by 按指定列分组统计(可选)。",
|
|
107
|
-
"usageGuide": "对表格数据的数值列做基本统计(求和/均值/最大/最小/计数)。group_by 可按某列分组统计。比手动计算更快(自动识别数值列+分组聚合)。",
|
|
108
|
-
"parameters": {
|
|
109
|
-
"properties": {
|
|
110
|
-
"data": {
|
|
111
|
-
"description": "数据:CSV 文本、JSON 数组字符串、或文件路径(根据 format)",
|
|
112
|
-
"type": "string"
|
|
113
|
-
},
|
|
114
|
-
"format": {
|
|
115
|
-
"description": "数据格式:\"csv\"(默认)/ \"json\" / \"file\"",
|
|
116
|
-
"type": "string"
|
|
117
|
-
},
|
|
118
|
-
"group_by": {
|
|
119
|
-
"description": "可选:按此列名分组统计",
|
|
120
|
-
"type": "string"
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
"required": [
|
|
124
|
-
"data"
|
|
125
|
-
],
|
|
126
|
-
"type": "object"
|
|
127
|
-
},
|
|
128
|
-
"readOnly": true
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
"name": "text_report",
|
|
132
|
-
"description": "扫描工作区目录树,按文件扩展名分组统计行数。支持统计总行数、代码行(非空非纯注释)、注释行、空行。path
|
|
133
|
-
"usageGuide": "
|
|
134
|
-
"parameters": {
|
|
135
|
-
"properties": {
|
|
136
|
-
"extensions": {
|
|
137
|
-
"description": "可选:限定文件扩展名,逗号分隔(如 \".go,.ts,.vue\")",
|
|
138
|
-
"type": "string"
|
|
139
|
-
},
|
|
140
|
-
"group_by": {
|
|
141
|
-
"description": "可选:分组方式 \"ext\"(按扩展名,默认)或 \"dir\"(按目录)",
|
|
142
|
-
"type": "string"
|
|
143
|
-
},
|
|
144
|
-
"max_files": {
|
|
145
|
-
"description": "可选:最大扫描文件数(默认 5000)",
|
|
146
|
-
"type": "integer"
|
|
147
|
-
},
|
|
148
|
-
"path": {
|
|
149
|
-
"description": "
|
|
150
|
-
"type": "string"
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
"type": "object"
|
|
154
|
-
},
|
|
155
|
-
"readOnly": true
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
"name": "word_read",
|
|
159
|
-
"description": "读取 Microsoft Word (.docx) 文件的内容,以纯文本或 Markdown 格式返回。支持段落文本、表格、列表等基本结构提取。format 可选 \"text\"(纯文本,默认)或 \"markdown\"(Markdown 格式)。limit 限制返回字符数(默认 10000,防止内容过长)。",
|
|
160
|
-
"usageGuide": "读取 Microsoft Word (.docx) 文件内容,以纯文本或 Markdown 格式返回。比手动打开 Word 更高效(直接提取文本到上下文)。",
|
|
161
|
-
"parameters": {
|
|
162
|
-
"properties": {
|
|
163
|
-
"format": {
|
|
164
|
-
"description": "可选:输出格式 \"text\"(纯文本,默认)或 \"markdown\"",
|
|
165
|
-
"type": "string"
|
|
166
|
-
},
|
|
167
|
-
"limit": {
|
|
168
|
-
"description": "可选:最大返回字符数(默认 10000,-1=全部)",
|
|
169
|
-
"type": "integer"
|
|
170
|
-
},
|
|
171
|
-
"path": {
|
|
172
|
-
"description": "Word 文件路径(工作区内,.docx
|
|
173
|
-
"type": "string"
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
"required": [
|
|
177
|
-
"path"
|
|
178
|
-
],
|
|
179
|
-
"type": "object"
|
|
180
|
-
},
|
|
181
|
-
"readOnly": true
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
"name": "word_write",
|
|
185
|
-
"description": "生成 Microsoft Word (.docx) 文档。content 为 Markdown 格式文本(支持 # 标题、普通段落、- 列表项、| 表格),系统自动将其转换为 OOXML 格式写入 .docx 文件。title 为可选的文档标题(默认无)。",
|
|
186
|
-
"usageGuide": "生成 Microsoft Word (.docx) 文档。content 为 Markdown 格式文本。用于输出报告/文档。比手动排版更高效(Markdown 转 Word 格式)。需审核批准。",
|
|
187
|
-
"parameters": {
|
|
188
|
-
"properties": {
|
|
189
|
-
"content": {
|
|
190
|
-
"description": "文档内容(Markdown 格式:标题用 #、列表用 -、表格用 |)",
|
|
191
|
-
"type": "string"
|
|
192
|
-
},
|
|
193
|
-
"path": {
|
|
194
|
-
"description": "输出文件路径(工作区内,.docx
|
|
195
|
-
"type": "string"
|
|
196
|
-
},
|
|
197
|
-
"title": {
|
|
198
|
-
"description": "可选:文档标题",
|
|
199
|
-
"type": "string"
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
"required": [
|
|
203
|
-
"path",
|
|
204
|
-
"content"
|
|
205
|
-
],
|
|
206
|
-
"type": "object"
|
|
207
|
-
},
|
|
208
|
-
"requiresApproval": true
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
"name": "read_xlsx",
|
|
212
|
-
"description": "读取 Microsoft Excel (.xlsx) 文件的内容,以 Markdown 表格形式返回各工作表。sheet 指定工作表名称(默认第一个);limit 限制行数(默认 200,-1=全部)。纯 Go 标准库实现(解析 ZIP + XML),零外部依赖。",
|
|
213
|
-
"usageGuide": "读取 Excel (.xlsx) 文件内容,以 Markdown 表格形式返回。sheet 参数指定工作表名。比直接
|
|
214
|
-
"parameters": {
|
|
215
|
-
"properties": {
|
|
216
|
-
"limit": {
|
|
217
|
-
"description": "可选:最大行数(默认 200,-1=全部)",
|
|
218
|
-
"type": "integer"
|
|
219
|
-
},
|
|
220
|
-
"path": {
|
|
221
|
-
"description": "Excel 文件路径(工作区内,.xlsx
|
|
222
|
-
"type": "string"
|
|
223
|
-
},
|
|
224
|
-
"sheet": {
|
|
225
|
-
"description": "可选:工作表名称(默认第一个工作表)",
|
|
226
|
-
"type": "string"
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
"required": [
|
|
230
|
-
"path"
|
|
231
|
-
],
|
|
232
|
-
"type": "object"
|
|
233
|
-
},
|
|
234
|
-
"readOnly": true
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
"name": "write_xlsx",
|
|
238
|
-
"description": "创建 Microsoft Excel (.xlsx) 文件。data 为 JSON 二维数组(如 [[\"列1\",\"列2\"],[\"值1\",\"值2\"]])或 Markdown 表格文本。sheet 为工作表名称(默认 \"Sheet1\")。纯 Go 标准库实现(生成 ZIP + XML),零外部依赖。",
|
|
239
|
-
"usageGuide": "创建 Excel (.xlsx) 文件。data 为 JSON 二维数组或 Markdown 表格文本。比手动拼接 CSV 更专业(支持多 sheet+格式)。需审核批准。",
|
|
240
|
-
"parameters": {
|
|
241
|
-
"properties": {
|
|
242
|
-
"data": {
|
|
243
|
-
"description": "表格数据:JSON 二维数组字符串 或 Markdown 表格文本",
|
|
244
|
-
"type": "string"
|
|
245
|
-
},
|
|
246
|
-
"path": {
|
|
247
|
-
"description": "输出文件路径(工作区内,.xlsx
|
|
248
|
-
"type": "string"
|
|
249
|
-
},
|
|
250
|
-
"sheet": {
|
|
251
|
-
"description": "可选:工作表名称(默认 \"Sheet1\")",
|
|
252
|
-
"type": "string"
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
"required": [
|
|
256
|
-
"path",
|
|
257
|
-
"data"
|
|
258
|
-
],
|
|
259
|
-
"type": "object"
|
|
260
|
-
},
|
|
261
|
-
"requiresApproval": true
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
"name": "read_pdf",
|
|
265
|
-
"description": "提取 PDF 文件的文本内容。先尝试纯文本提取(解析 PDF 流对象);如提取结果为空或内容极少(\u003c50 字符),自动调用 pdftoppm/mutool 将页面渲染为图片 + Tesseract OCR 识别文字。page 指定页码(从 1 开始,默认全部);limit 限制返回字符数(默认 10000)。",
|
|
266
|
-
"usageGuide": "提取 PDF 文本内容。先尝试纯文本提取,失败则回退 OCR。比手动打开 PDF 复制更高效(直接提取到上下文)。",
|
|
267
|
-
"parameters": {
|
|
268
|
-
"properties": {
|
|
269
|
-
"limit": {
|
|
270
|
-
"description": "可选:最大返回字符数(默认 10000,-1=全部)",
|
|
271
|
-
"type": "integer"
|
|
272
|
-
},
|
|
273
|
-
"page": {
|
|
274
|
-
"description": "可选:页码(从 1 开始),省略则提取全部页面",
|
|
275
|
-
"type": "integer"
|
|
276
|
-
},
|
|
277
|
-
"path": {
|
|
278
|
-
"description": "PDF
|
|
279
|
-
"type": "string"
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
"required": [
|
|
283
|
-
"path"
|
|
284
|
-
],
|
|
285
|
-
"type": "object"
|
|
286
|
-
},
|
|
287
|
-
"readOnly": true
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
"name": "markdown_to_html",
|
|
291
|
-
"description": "将 Markdown 文本转换为 HTML 片段。支持 # 标题、**粗体**、*斜体*、`行内代码`、```代码块```、- 无序列表、1. 有序列表、| 表格、\u003e 引用、[链接](url)、。full_html 为 true 时输出完整 HTML 文档(含 DOCTYPE + head + body),否则只输出 body 内的 HTML 片段。",
|
|
292
|
-
"usageGuide": "将 Markdown 文本转为 HTML。支持 full_html 参数输出完整 HTML 文档(含 title)。比手动转换更快(内置渲染器+代码高亮)。",
|
|
293
|
-
"parameters": {
|
|
294
|
-
"properties": {
|
|
295
|
-
"full_html": {
|
|
296
|
-
"description": "可选:是否输出完整 HTML 文档(默认 false,只输出片段)",
|
|
297
|
-
"type": "boolean"
|
|
298
|
-
},
|
|
299
|
-
"markdown": {
|
|
300
|
-
"description": "Markdown 文本(必填)",
|
|
301
|
-
"type": "string"
|
|
302
|
-
},
|
|
303
|
-
"title": {
|
|
304
|
-
"description": "可选:完整 HTML 时的页面标题",
|
|
305
|
-
"type": "string"
|
|
306
|
-
}
|
|
307
|
-
},
|
|
308
|
-
"required": [
|
|
309
|
-
"markdown"
|
|
310
|
-
],
|
|
311
|
-
"type": "object"
|
|
312
|
-
},
|
|
313
|
-
"readOnly": true
|
|
314
|
-
}
|
|
315
|
-
];
|
|
316
|
-
|
|
317
|
-
return {
|
|
318
|
-
name: 'tool-office',
|
|
319
|
-
purpose: '办公文档(csv_read/csv_write/json_to_table/table_stats/text_report/word_read)(自动生成,迁移自内置 Go 工具组)',
|
|
320
|
-
apply(ctx) {
|
|
321
|
-
for (const t of tools) {
|
|
322
|
-
ctx.tools.register({
|
|
323
|
-
name: t.name,
|
|
324
|
-
description: t.description,
|
|
325
|
-
usageGuide: t.usageGuide,
|
|
326
|
-
category: t.category,
|
|
327
|
-
readOnly: t.readOnly,
|
|
328
|
-
requiresApproval: t.requiresApproval,
|
|
329
|
-
systemTool: t.systemTool,
|
|
330
|
-
parameters: t.parameters,
|
|
331
|
-
execute: (args) => ctx.binary.exec(t.name, args || {}),
|
|
332
|
-
})
|
|
333
|
-
}
|
|
334
|
-
},
|
|
335
|
-
}
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════
|
|
2
|
+
// tool-office — 办公文档(csv_read/csv_write/json_to_table/table_stats/text_report/word_read)
|
|
3
|
+
//
|
|
4
|
+
// 生成来源(2026-08-16):内置 Go 工具组 → 磁盘外置插件(tool_plugin_gen.go
|
|
5
|
+
// 自动生成,schema 完整外置拷贝)。api 声明在插件,execute 调 ctx.binary 复用本插件目录 bin/ 下的独立二进制(源码 plugins-src/plugins/<name>/,改实现重编译即更换)。
|
|
6
|
+
// 工具清单:csv_read、csv_write、json_to_table、table_stats、text_report、word_read、word_write、read_xlsx、write_xlsx、read_pdf、markdown_to_html
|
|
7
|
+
// ═══════════════════════════════════════════════════════════════
|
|
8
|
+
const tools = [
|
|
9
|
+
{
|
|
10
|
+
"name": "csv_read",
|
|
11
|
+
"description": "读取 CSV/TSV 文件并以 Markdown 表格形式返回内容。参数 delimiter 可选 \"comma\"(逗号, 默认)或 \"tab\"(制表符)。columns 按列索引过滤(从 0 开始,逗号分隔,如 \"0,2,3\")。limit 限制返回行数(默认 100,-1=全部),offset 跳过前 N 行。",
|
|
12
|
+
"usageGuide": "读取 CSV/TSV 文件并以 Markdown 表格形式返回。比直接 read 读 CSV 更友好(自动解析分隔符+格式化表格)。delimiter 可指定 comma/tab。",
|
|
13
|
+
"parameters": {
|
|
14
|
+
"properties": {
|
|
15
|
+
"columns": {
|
|
16
|
+
"description": "可选:要显示的列索引(从 0 开始,逗号分隔),省略显示全部",
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
"delimiter": {
|
|
20
|
+
"description": "可选:分隔符,\"comma\"(逗号)或 \"tab\"(制表符),默认 \"comma\"",
|
|
21
|
+
"type": "string"
|
|
22
|
+
},
|
|
23
|
+
"limit": {
|
|
24
|
+
"description": "可选:最大返回行数(默认 100,-1 表示全部)",
|
|
25
|
+
"type": "integer"
|
|
26
|
+
},
|
|
27
|
+
"offset": {
|
|
28
|
+
"description": "可选:跳过前 N 行(默认 0)",
|
|
29
|
+
"type": "integer"
|
|
30
|
+
},
|
|
31
|
+
"path": {
|
|
32
|
+
"description": "文件路径(工作区内);相对主项目根解析,跨项目请传绝对路径",
|
|
33
|
+
"type": "string"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"required": [
|
|
37
|
+
"path"
|
|
38
|
+
],
|
|
39
|
+
"type": "object"
|
|
40
|
+
},
|
|
41
|
+
"readOnly": true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "csv_write",
|
|
45
|
+
"description": "将表格数据写入 CSV/TSV 文件。data 为 JSON 二维数组(如 [[\"列1\",\"列2\"],[\"值1\",\"值2\"]])或 Markdown 表格文本。delimiter 可选 \"comma\"(逗号, 默认)或 \"tab\"(制表符)。header 为可选的表头行 JSON 数组,省略则从 data 首行自动提取。",
|
|
46
|
+
"usageGuide": "将表格数据写入 CSV/TSV 文件。data 参数支持 JSON 二维数组或 Markdown 表格文本。比手动拼接 CSV 更高效(自动处理转义+分隔符)。需审核批准。",
|
|
47
|
+
"parameters": {
|
|
48
|
+
"properties": {
|
|
49
|
+
"data": {
|
|
50
|
+
"description": "表格数据:JSON 二维数组字符串,或 Markdown 表格文本",
|
|
51
|
+
"type": "string"
|
|
52
|
+
},
|
|
53
|
+
"delimiter": {
|
|
54
|
+
"description": "可选:分隔符 \"comma\" 或 \"tab\",默认 \"comma\"",
|
|
55
|
+
"type": "string"
|
|
56
|
+
},
|
|
57
|
+
"header": {
|
|
58
|
+
"description": "可选:表头行 JSON 数组,如 \"[\"姓名\",\"年龄\"]\"",
|
|
59
|
+
"type": "string"
|
|
60
|
+
},
|
|
61
|
+
"path": {
|
|
62
|
+
"description": "文件路径(工作区内);相对主项目根解析,跨项目请传绝对路径",
|
|
63
|
+
"type": "string"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"required": [
|
|
67
|
+
"path",
|
|
68
|
+
"data"
|
|
69
|
+
],
|
|
70
|
+
"type": "object"
|
|
71
|
+
},
|
|
72
|
+
"requiresApproval": true
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "json_to_table",
|
|
76
|
+
"description": "将 JSON 数组字符串转为 Markdown 表格。columns 指定列名和顺序(逗号分隔,如 \"name,age\"),省略则使用全部键并按字母序排列。limit 限制行数(默认 100,-1=全部),title 可选表格标题。",
|
|
77
|
+
"usageGuide": "将 JSON 数组字符串转为 Markdown 表格。columns 参数指定列名和顺序。比手动格式化更高效(自动生成表头+对齐)。",
|
|
78
|
+
"parameters": {
|
|
79
|
+
"properties": {
|
|
80
|
+
"columns": {
|
|
81
|
+
"description": "可选:显示的键名(逗号分隔),省略则用全部键",
|
|
82
|
+
"type": "string"
|
|
83
|
+
},
|
|
84
|
+
"json": {
|
|
85
|
+
"description": "JSON 数组字符串(必填,如 [{\"name\":\"张三\",\"age\":30}])",
|
|
86
|
+
"type": "string"
|
|
87
|
+
},
|
|
88
|
+
"limit": {
|
|
89
|
+
"description": "可选:最大行数(默认 100,-1=全部)",
|
|
90
|
+
"type": "integer"
|
|
91
|
+
},
|
|
92
|
+
"title": {
|
|
93
|
+
"description": "可选:表格标题",
|
|
94
|
+
"type": "string"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"required": [
|
|
98
|
+
"json"
|
|
99
|
+
],
|
|
100
|
+
"type": "object"
|
|
101
|
+
},
|
|
102
|
+
"readOnly": true
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "table_stats",
|
|
106
|
+
"description": "对表格数据的数值列做基本统计(求和、均值、最大值、最小值、计数)。data 为 CSV 文本、JSON 数组或文件路径。format 指定数据格式:\"csv\"(CSV 文本)\"json\"(JSON 数组)\"file\"(文件路径)。group_by 按指定列分组统计(可选)。",
|
|
107
|
+
"usageGuide": "对表格数据的数值列做基本统计(求和/均值/最大/最小/计数)。group_by 可按某列分组统计。比手动计算更快(自动识别数值列+分组聚合)。",
|
|
108
|
+
"parameters": {
|
|
109
|
+
"properties": {
|
|
110
|
+
"data": {
|
|
111
|
+
"description": "数据:CSV 文本、JSON 数组字符串、或文件路径(根据 format)",
|
|
112
|
+
"type": "string"
|
|
113
|
+
},
|
|
114
|
+
"format": {
|
|
115
|
+
"description": "数据格式:\"csv\"(默认)/ \"json\" / \"file\"",
|
|
116
|
+
"type": "string"
|
|
117
|
+
},
|
|
118
|
+
"group_by": {
|
|
119
|
+
"description": "可选:按此列名分组统计",
|
|
120
|
+
"type": "string"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"required": [
|
|
124
|
+
"data"
|
|
125
|
+
],
|
|
126
|
+
"type": "object"
|
|
127
|
+
},
|
|
128
|
+
"readOnly": true
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "text_report",
|
|
132
|
+
"description": "扫描工作区目录树,按文件扩展名分组统计行数。支持统计总行数、代码行(非空非纯注释)、注释行、空行。path 限定扫描子目录(默认主项目根;相对主项目根解析,跨项目请传绝对路径);extensions 限定文件扩展名(逗号分隔,如 \".go,.ts,.vue\");group_by 分组方式:\"ext\"(按扩展名,默认)或 \"dir\"(按目录)。自动跳过依赖库(node_modules/vendor/.venv…)、构建产物、VCS 与项目根下的 IDE 运行数据目录。",
|
|
133
|
+
"usageGuide": "扫描目录树,按文件扩展名或目录分组统计代码行数。快速了解项目规模和技术栈分布。path 相对主项目根解析(跨项目传绝对路径)。比 bash wc -l 更智能(自动跳过依赖库/构建产物/VCS/IDE 运行数据目录+按类型分组)。",
|
|
134
|
+
"parameters": {
|
|
135
|
+
"properties": {
|
|
136
|
+
"extensions": {
|
|
137
|
+
"description": "可选:限定文件扩展名,逗号分隔(如 \".go,.ts,.vue\")",
|
|
138
|
+
"type": "string"
|
|
139
|
+
},
|
|
140
|
+
"group_by": {
|
|
141
|
+
"description": "可选:分组方式 \"ext\"(按扩展名,默认)或 \"dir\"(按目录)",
|
|
142
|
+
"type": "string"
|
|
143
|
+
},
|
|
144
|
+
"max_files": {
|
|
145
|
+
"description": "可选:最大扫描文件数(默认 5000)",
|
|
146
|
+
"type": "integer"
|
|
147
|
+
},
|
|
148
|
+
"path": {
|
|
149
|
+
"description": "可选:要扫描的目录路径(默认工作区根);相对主项目根解析,跨项目请传绝对路径",
|
|
150
|
+
"type": "string"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"type": "object"
|
|
154
|
+
},
|
|
155
|
+
"readOnly": true
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"name": "word_read",
|
|
159
|
+
"description": "读取 Microsoft Word (.docx) 文件的内容,以纯文本或 Markdown 格式返回。支持段落文本、表格、列表等基本结构提取。format 可选 \"text\"(纯文本,默认)或 \"markdown\"(Markdown 格式)。limit 限制返回字符数(默认 10000,防止内容过长)。",
|
|
160
|
+
"usageGuide": "读取 Microsoft Word (.docx) 文件内容,以纯文本或 Markdown 格式返回。比手动打开 Word 更高效(直接提取文本到上下文)。",
|
|
161
|
+
"parameters": {
|
|
162
|
+
"properties": {
|
|
163
|
+
"format": {
|
|
164
|
+
"description": "可选:输出格式 \"text\"(纯文本,默认)或 \"markdown\"",
|
|
165
|
+
"type": "string"
|
|
166
|
+
},
|
|
167
|
+
"limit": {
|
|
168
|
+
"description": "可选:最大返回字符数(默认 10000,-1=全部)",
|
|
169
|
+
"type": "integer"
|
|
170
|
+
},
|
|
171
|
+
"path": {
|
|
172
|
+
"description": "Word 文件路径(工作区内,.docx 格式);相对主项目根解析,跨项目请传绝对路径",
|
|
173
|
+
"type": "string"
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"required": [
|
|
177
|
+
"path"
|
|
178
|
+
],
|
|
179
|
+
"type": "object"
|
|
180
|
+
},
|
|
181
|
+
"readOnly": true
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"name": "word_write",
|
|
185
|
+
"description": "生成 Microsoft Word (.docx) 文档。content 为 Markdown 格式文本(支持 # 标题、普通段落、- 列表项、| 表格),系统自动将其转换为 OOXML 格式写入 .docx 文件。title 为可选的文档标题(默认无)。",
|
|
186
|
+
"usageGuide": "生成 Microsoft Word (.docx) 文档。content 为 Markdown 格式文本。用于输出报告/文档。比手动排版更高效(Markdown 转 Word 格式)。需审核批准。",
|
|
187
|
+
"parameters": {
|
|
188
|
+
"properties": {
|
|
189
|
+
"content": {
|
|
190
|
+
"description": "文档内容(Markdown 格式:标题用 #、列表用 -、表格用 |)",
|
|
191
|
+
"type": "string"
|
|
192
|
+
},
|
|
193
|
+
"path": {
|
|
194
|
+
"description": "输出文件路径(工作区内,.docx 扩展名);相对主项目根解析,跨项目请传绝对路径",
|
|
195
|
+
"type": "string"
|
|
196
|
+
},
|
|
197
|
+
"title": {
|
|
198
|
+
"description": "可选:文档标题",
|
|
199
|
+
"type": "string"
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
"required": [
|
|
203
|
+
"path",
|
|
204
|
+
"content"
|
|
205
|
+
],
|
|
206
|
+
"type": "object"
|
|
207
|
+
},
|
|
208
|
+
"requiresApproval": true
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"name": "read_xlsx",
|
|
212
|
+
"description": "读取 Microsoft Excel (.xlsx) 文件的内容,以 Markdown 表格形式返回各工作表。sheet 指定工作表名称(默认第一个);limit 限制行数(默认 200,-1=全部)。纯 Go 标准库实现(解析 ZIP + XML),零外部依赖。",
|
|
213
|
+
"usageGuide": "读取 Excel (.xlsx) 文件内容,以 Markdown 表格形式返回。sheet 参数指定工作表名。比直接 read 更友好(自动解析+多 sheet 支持)。",
|
|
214
|
+
"parameters": {
|
|
215
|
+
"properties": {
|
|
216
|
+
"limit": {
|
|
217
|
+
"description": "可选:最大行数(默认 200,-1=全部)",
|
|
218
|
+
"type": "integer"
|
|
219
|
+
},
|
|
220
|
+
"path": {
|
|
221
|
+
"description": "Excel 文件路径(工作区内,.xlsx 格式);相对主项目根解析,跨项目请传绝对路径",
|
|
222
|
+
"type": "string"
|
|
223
|
+
},
|
|
224
|
+
"sheet": {
|
|
225
|
+
"description": "可选:工作表名称(默认第一个工作表)",
|
|
226
|
+
"type": "string"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
"required": [
|
|
230
|
+
"path"
|
|
231
|
+
],
|
|
232
|
+
"type": "object"
|
|
233
|
+
},
|
|
234
|
+
"readOnly": true
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"name": "write_xlsx",
|
|
238
|
+
"description": "创建 Microsoft Excel (.xlsx) 文件。data 为 JSON 二维数组(如 [[\"列1\",\"列2\"],[\"值1\",\"值2\"]])或 Markdown 表格文本。sheet 为工作表名称(默认 \"Sheet1\")。纯 Go 标准库实现(生成 ZIP + XML),零外部依赖。",
|
|
239
|
+
"usageGuide": "创建 Excel (.xlsx) 文件。data 为 JSON 二维数组或 Markdown 表格文本。比手动拼接 CSV 更专业(支持多 sheet+格式)。需审核批准。",
|
|
240
|
+
"parameters": {
|
|
241
|
+
"properties": {
|
|
242
|
+
"data": {
|
|
243
|
+
"description": "表格数据:JSON 二维数组字符串 或 Markdown 表格文本",
|
|
244
|
+
"type": "string"
|
|
245
|
+
},
|
|
246
|
+
"path": {
|
|
247
|
+
"description": "输出文件路径(工作区内,.xlsx 扩展名);相对主项目根解析,跨项目请传绝对路径",
|
|
248
|
+
"type": "string"
|
|
249
|
+
},
|
|
250
|
+
"sheet": {
|
|
251
|
+
"description": "可选:工作表名称(默认 \"Sheet1\")",
|
|
252
|
+
"type": "string"
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
"required": [
|
|
256
|
+
"path",
|
|
257
|
+
"data"
|
|
258
|
+
],
|
|
259
|
+
"type": "object"
|
|
260
|
+
},
|
|
261
|
+
"requiresApproval": true
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"name": "read_pdf",
|
|
265
|
+
"description": "提取 PDF 文件的文本内容。先尝试纯文本提取(解析 PDF 流对象);如提取结果为空或内容极少(\u003c50 字符),自动调用 pdftoppm/mutool 将页面渲染为图片 + Tesseract OCR 识别文字。page 指定页码(从 1 开始,默认全部);limit 限制返回字符数(默认 10000)。",
|
|
266
|
+
"usageGuide": "提取 PDF 文本内容。先尝试纯文本提取,失败则回退 OCR。比手动打开 PDF 复制更高效(直接提取到上下文)。",
|
|
267
|
+
"parameters": {
|
|
268
|
+
"properties": {
|
|
269
|
+
"limit": {
|
|
270
|
+
"description": "可选:最大返回字符数(默认 10000,-1=全部)",
|
|
271
|
+
"type": "integer"
|
|
272
|
+
},
|
|
273
|
+
"page": {
|
|
274
|
+
"description": "可选:页码(从 1 开始),省略则提取全部页面",
|
|
275
|
+
"type": "integer"
|
|
276
|
+
},
|
|
277
|
+
"path": {
|
|
278
|
+
"description": "PDF 文件路径(工作区内);相对主项目根解析,跨项目请传绝对路径",
|
|
279
|
+
"type": "string"
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
"required": [
|
|
283
|
+
"path"
|
|
284
|
+
],
|
|
285
|
+
"type": "object"
|
|
286
|
+
},
|
|
287
|
+
"readOnly": true
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"name": "markdown_to_html",
|
|
291
|
+
"description": "将 Markdown 文本转换为 HTML 片段。支持 # 标题、**粗体**、*斜体*、`行内代码`、```代码块```、- 无序列表、1. 有序列表、| 表格、\u003e 引用、[链接](url)、。full_html 为 true 时输出完整 HTML 文档(含 DOCTYPE + head + body),否则只输出 body 内的 HTML 片段。",
|
|
292
|
+
"usageGuide": "将 Markdown 文本转为 HTML。支持 full_html 参数输出完整 HTML 文档(含 title)。比手动转换更快(内置渲染器+代码高亮)。",
|
|
293
|
+
"parameters": {
|
|
294
|
+
"properties": {
|
|
295
|
+
"full_html": {
|
|
296
|
+
"description": "可选:是否输出完整 HTML 文档(默认 false,只输出片段)",
|
|
297
|
+
"type": "boolean"
|
|
298
|
+
},
|
|
299
|
+
"markdown": {
|
|
300
|
+
"description": "Markdown 文本(必填)",
|
|
301
|
+
"type": "string"
|
|
302
|
+
},
|
|
303
|
+
"title": {
|
|
304
|
+
"description": "可选:完整 HTML 时的页面标题",
|
|
305
|
+
"type": "string"
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
"required": [
|
|
309
|
+
"markdown"
|
|
310
|
+
],
|
|
311
|
+
"type": "object"
|
|
312
|
+
},
|
|
313
|
+
"readOnly": true
|
|
314
|
+
}
|
|
315
|
+
];
|
|
316
|
+
|
|
317
|
+
return {
|
|
318
|
+
name: 'tool-office',
|
|
319
|
+
purpose: '办公文档(csv_read/csv_write/json_to_table/table_stats/text_report/word_read)(自动生成,迁移自内置 Go 工具组)',
|
|
320
|
+
apply(ctx) {
|
|
321
|
+
for (const t of tools) {
|
|
322
|
+
ctx.tools.register({
|
|
323
|
+
name: t.name,
|
|
324
|
+
description: t.description,
|
|
325
|
+
usageGuide: t.usageGuide,
|
|
326
|
+
category: t.category,
|
|
327
|
+
readOnly: t.readOnly,
|
|
328
|
+
requiresApproval: t.requiresApproval,
|
|
329
|
+
systemTool: t.systemTool,
|
|
330
|
+
parameters: t.parameters,
|
|
331
|
+
execute: (args) => ctx.binary.exec(t.name, args || {}),
|
|
332
|
+
})
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
}
|
package/package.json
CHANGED
package/bin/tool-office.exe
DELETED
|
Binary file
|