@aarav-j/zephyr-mcp-server 0.1.0
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/README.md +199 -0
- package/dist/db.d.ts +72 -0
- package/dist/db.d.ts.map +1 -0
- package/dist/db.js +343 -0
- package/dist/db.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +451 -0
- package/dist/index.js.map +1 -0
- package/dist/parsers/doxygen.d.ts +14 -0
- package/dist/parsers/doxygen.d.ts.map +1 -0
- package/dist/parsers/doxygen.js +184 -0
- package/dist/parsers/doxygen.js.map +1 -0
- package/dist/parsers/dt-bindings.d.ts +10 -0
- package/dist/parsers/dt-bindings.d.ts.map +1 -0
- package/dist/parsers/dt-bindings.js +82 -0
- package/dist/parsers/dt-bindings.js.map +1 -0
- package/dist/parsers/kconfig.d.ts +11 -0
- package/dist/parsers/kconfig.d.ts.map +1 -0
- package/dist/parsers/kconfig.js +187 -0
- package/dist/parsers/kconfig.js.map +1 -0
- package/dist/test-db.d.ts +2 -0
- package/dist/test-db.d.ts.map +1 -0
- package/dist/test-db.js +119 -0
- package/dist/test-db.js.map +1 -0
- package/dist/test-doxygen.d.ts +2 -0
- package/dist/test-doxygen.d.ts.map +1 -0
- package/dist/test-doxygen.js +49 -0
- package/dist/test-doxygen.js.map +1 -0
- package/package.json +33 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { ListToolsRequestSchema, CallToolRequestSchema, ErrorCode, McpError, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
import { ZephyrDatabase, getCacheDir } from "./db.js";
|
|
6
|
+
import { existsSync, readdirSync, mkdirSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
// --- Database loading ---
|
|
9
|
+
let db = null;
|
|
10
|
+
let currentVersion = null;
|
|
11
|
+
function loadLatestIndex() {
|
|
12
|
+
const cacheDir = getCacheDir();
|
|
13
|
+
if (!existsSync(cacheDir))
|
|
14
|
+
return;
|
|
15
|
+
const entries = readdirSync(cacheDir, { withFileTypes: true });
|
|
16
|
+
const versionDirs = entries
|
|
17
|
+
.filter((e) => e.isDirectory())
|
|
18
|
+
.map((e) => e.name)
|
|
19
|
+
.sort()
|
|
20
|
+
.reverse();
|
|
21
|
+
for (const ver of versionDirs) {
|
|
22
|
+
const dbPath = join(cacheDir, ver, "zephyr-index.db");
|
|
23
|
+
if (existsSync(dbPath)) {
|
|
24
|
+
try {
|
|
25
|
+
const candidate = new ZephyrDatabase(dbPath);
|
|
26
|
+
const stored = candidate.getMeta("version");
|
|
27
|
+
if (stored) {
|
|
28
|
+
db = candidate;
|
|
29
|
+
currentVersion = stored;
|
|
30
|
+
console.error(`Loaded index: ${stored} from ${dbPath}`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
candidate.close();
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// --- Server setup ---
|
|
42
|
+
const server = new Server({ name: "@aarav-j/zephyr-mcp-server", version: "0.1.0" }, { capabilities: { tools: {} } });
|
|
43
|
+
// --- Tool definitions ---
|
|
44
|
+
const GET_FUNCTION_SIGNATURE_TOOL = {
|
|
45
|
+
name: "get_function_signature",
|
|
46
|
+
description: "Look up the exact C function or macro signature, parameters, return type, and header location from Zephyr's Doxygen API docs.",
|
|
47
|
+
inputSchema: {
|
|
48
|
+
type: "object",
|
|
49
|
+
properties: {
|
|
50
|
+
name: {
|
|
51
|
+
type: "string",
|
|
52
|
+
description: "Function or macro name (e.g. k_sem_take, GPIO_DT_SPEC_GET)",
|
|
53
|
+
},
|
|
54
|
+
version: {
|
|
55
|
+
type: "string",
|
|
56
|
+
description: "Zephyr version tag (e.g. v4.1.0). Defaults to latest cached.",
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
required: ["name"],
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
const FIND_KCONFIG_TOOL = {
|
|
63
|
+
name: "find_kconfig",
|
|
64
|
+
description: "Search Zephyr Kconfig symbols by name or description. Returns matching symbols with their type, prompt, default value, and dependency chain.",
|
|
65
|
+
inputSchema: {
|
|
66
|
+
type: "object",
|
|
67
|
+
properties: {
|
|
68
|
+
pattern: {
|
|
69
|
+
type: "string",
|
|
70
|
+
description: "Search pattern (e.g. GPIO, CONFIG_I2C, USB)",
|
|
71
|
+
},
|
|
72
|
+
limit: {
|
|
73
|
+
type: "number",
|
|
74
|
+
description: "Maximum results. Default 10, max 50.",
|
|
75
|
+
default: 10,
|
|
76
|
+
},
|
|
77
|
+
version: {
|
|
78
|
+
type: "string",
|
|
79
|
+
description: "Zephyr version tag. Defaults to latest cached.",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
required: ["pattern"],
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
const GET_DT_BINDING_TOOL = {
|
|
86
|
+
name: "get_dt_binding",
|
|
87
|
+
description: "Look up a Devicetree binding by compatible string. Returns the binding schema including required and optional properties, bus information, and child bindings.",
|
|
88
|
+
inputSchema: {
|
|
89
|
+
type: "object",
|
|
90
|
+
properties: {
|
|
91
|
+
compatible: {
|
|
92
|
+
type: "string",
|
|
93
|
+
description: "Devicetree compatible string (e.g. st,stm32-i2c, arm,cortex-m4)",
|
|
94
|
+
},
|
|
95
|
+
version: {
|
|
96
|
+
type: "string",
|
|
97
|
+
description: "Zephyr version tag. Defaults to latest cached.",
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
required: ["compatible"],
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
const SEARCH_DOCS_TOOL = {
|
|
104
|
+
name: "search_docs",
|
|
105
|
+
description: "Full-text search across Zephyr documentation, API reference, Kconfig help text, and DT binding descriptions.",
|
|
106
|
+
inputSchema: {
|
|
107
|
+
type: "object",
|
|
108
|
+
properties: {
|
|
109
|
+
query: {
|
|
110
|
+
type: "string",
|
|
111
|
+
description: "Search query (e.g. 'semaphore timeout', 'gpio interrupt', 'i2c stm32')",
|
|
112
|
+
},
|
|
113
|
+
domain: {
|
|
114
|
+
type: "string",
|
|
115
|
+
description: "Scope: 'api', 'kconfig', 'dt', or omit for all",
|
|
116
|
+
enum: ["api", "kconfig", "dt"],
|
|
117
|
+
},
|
|
118
|
+
limit: {
|
|
119
|
+
type: "number",
|
|
120
|
+
description: "Maximum results. Default 10, max 30.",
|
|
121
|
+
default: 10,
|
|
122
|
+
},
|
|
123
|
+
version: {
|
|
124
|
+
type: "string",
|
|
125
|
+
description: "Zephyr version tag. Defaults to latest cached.",
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
required: ["query"],
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
// --- Request handlers ---
|
|
132
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
133
|
+
tools: [
|
|
134
|
+
GET_FUNCTION_SIGNATURE_TOOL,
|
|
135
|
+
FIND_KCONFIG_TOOL,
|
|
136
|
+
GET_DT_BINDING_TOOL,
|
|
137
|
+
SEARCH_DOCS_TOOL,
|
|
138
|
+
],
|
|
139
|
+
}));
|
|
140
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
141
|
+
const tool = request.params.name;
|
|
142
|
+
const args = request.params.arguments ?? {};
|
|
143
|
+
if (!db) {
|
|
144
|
+
return {
|
|
145
|
+
content: [
|
|
146
|
+
{
|
|
147
|
+
type: "text",
|
|
148
|
+
text: JSON.stringify({
|
|
149
|
+
error: "No index loaded.",
|
|
150
|
+
hint: "Run `npx tsx scripts/build-index.ts --source /path/to/zephyr` to build the index first.",
|
|
151
|
+
}, null, 2),
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
switch (tool) {
|
|
157
|
+
// --- get_function_signature ---
|
|
158
|
+
case "get_function_signature": {
|
|
159
|
+
const name = String(args.name ?? "");
|
|
160
|
+
if (!name) {
|
|
161
|
+
throw new McpError(ErrorCode.InvalidParams, "Missing required argument: name");
|
|
162
|
+
}
|
|
163
|
+
const fn = db.getFunctionByName(name);
|
|
164
|
+
if (!fn) {
|
|
165
|
+
const results = db.searchFunctions(name, 5);
|
|
166
|
+
return {
|
|
167
|
+
content: [
|
|
168
|
+
{
|
|
169
|
+
type: "text",
|
|
170
|
+
text: JSON.stringify({
|
|
171
|
+
name,
|
|
172
|
+
found: false,
|
|
173
|
+
suggestions: results
|
|
174
|
+
.filter((r) => r.name.toLowerCase() !== name.toLowerCase())
|
|
175
|
+
.map((r) => ({
|
|
176
|
+
name: r.name,
|
|
177
|
+
signature: r.signature,
|
|
178
|
+
header: r.header,
|
|
179
|
+
})),
|
|
180
|
+
version: currentVersion,
|
|
181
|
+
}, null, 2),
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
content: [
|
|
188
|
+
{
|
|
189
|
+
type: "text",
|
|
190
|
+
text: JSON.stringify({
|
|
191
|
+
name: fn.name,
|
|
192
|
+
signature: fn.signature,
|
|
193
|
+
brief: fn.brief,
|
|
194
|
+
params: fn.params ? JSON.parse(fn.params) : [],
|
|
195
|
+
return_type: fn.return_type,
|
|
196
|
+
return_desc: fn.return_desc,
|
|
197
|
+
header: fn.header,
|
|
198
|
+
section: fn.section,
|
|
199
|
+
version: currentVersion,
|
|
200
|
+
}, null, 2),
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
// --- find_kconfig ---
|
|
206
|
+
case "find_kconfig": {
|
|
207
|
+
const pattern = String(args.pattern ?? "");
|
|
208
|
+
if (!pattern) {
|
|
209
|
+
throw new McpError(ErrorCode.InvalidParams, "Missing required argument: pattern");
|
|
210
|
+
}
|
|
211
|
+
const limit = Math.min(Math.max(Number(args.limit ?? 10), 1), 50);
|
|
212
|
+
const results = db.searchKconfig(pattern, limit);
|
|
213
|
+
return {
|
|
214
|
+
content: [
|
|
215
|
+
{
|
|
216
|
+
type: "text",
|
|
217
|
+
text: JSON.stringify({
|
|
218
|
+
pattern,
|
|
219
|
+
found: results.length > 0,
|
|
220
|
+
count: results.length,
|
|
221
|
+
results: results.map((r) => ({
|
|
222
|
+
name: r.name,
|
|
223
|
+
type: r.type,
|
|
224
|
+
prompt: r.prompt,
|
|
225
|
+
default: r.default_val,
|
|
226
|
+
depends_on: r.depends_on ? JSON.parse(r.depends_on) : [],
|
|
227
|
+
path: r.path,
|
|
228
|
+
})),
|
|
229
|
+
version: currentVersion,
|
|
230
|
+
}, null, 2),
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
// --- get_dt_binding ---
|
|
236
|
+
case "get_dt_binding": {
|
|
237
|
+
const compatible = String(args.compatible ?? "");
|
|
238
|
+
if (!compatible) {
|
|
239
|
+
throw new McpError(ErrorCode.InvalidParams, "Missing required argument: compatible");
|
|
240
|
+
}
|
|
241
|
+
// Try exact match first (avoids FTS5 comma syntax issues)
|
|
242
|
+
let binding = db.getBindingByCompatible(compatible);
|
|
243
|
+
if (!binding) {
|
|
244
|
+
// Fall back to FTS search
|
|
245
|
+
const results = db.searchBindings(compatible, 5);
|
|
246
|
+
binding = results.find((r) => r.compatible === compatible) ?? results[0] ?? null;
|
|
247
|
+
}
|
|
248
|
+
if (!binding) {
|
|
249
|
+
return {
|
|
250
|
+
content: [
|
|
251
|
+
{
|
|
252
|
+
type: "text",
|
|
253
|
+
text: JSON.stringify({
|
|
254
|
+
compatible,
|
|
255
|
+
found: false,
|
|
256
|
+
suggestions: [],
|
|
257
|
+
version: currentVersion,
|
|
258
|
+
}, null, 2),
|
|
259
|
+
},
|
|
260
|
+
],
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
return {
|
|
264
|
+
content: [
|
|
265
|
+
{
|
|
266
|
+
type: "text",
|
|
267
|
+
text: JSON.stringify({
|
|
268
|
+
compatible: binding.compatible,
|
|
269
|
+
description: binding.description,
|
|
270
|
+
properties: binding.properties ? JSON.parse(binding.properties) : null,
|
|
271
|
+
child_binding: binding.child_binding ? JSON.parse(binding.child_binding) : null,
|
|
272
|
+
bus: binding.bus,
|
|
273
|
+
on_bus: binding.on_bus,
|
|
274
|
+
path: binding.path,
|
|
275
|
+
version: currentVersion,
|
|
276
|
+
}, null, 2),
|
|
277
|
+
},
|
|
278
|
+
],
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
// --- search_docs ---
|
|
282
|
+
case "search_docs": {
|
|
283
|
+
const query = String(args.query ?? "");
|
|
284
|
+
if (!query) {
|
|
285
|
+
throw new McpError(ErrorCode.InvalidParams, "Missing required argument: query");
|
|
286
|
+
}
|
|
287
|
+
const domain = String(args.domain ?? "");
|
|
288
|
+
const limit = Math.min(Math.max(Number(args.limit ?? 10), 1), 30);
|
|
289
|
+
const allResults = [];
|
|
290
|
+
if (!domain || domain === "api") {
|
|
291
|
+
const fnResults = db.searchFunctions(query, limit);
|
|
292
|
+
for (const r of fnResults) {
|
|
293
|
+
allResults.push({
|
|
294
|
+
domain: "api",
|
|
295
|
+
title: r.name,
|
|
296
|
+
snippet: r.signature,
|
|
297
|
+
path: r.header ?? undefined,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (!domain || domain === "kconfig") {
|
|
302
|
+
const kcResults = db.searchKconfig(query, limit);
|
|
303
|
+
for (const r of kcResults) {
|
|
304
|
+
allResults.push({
|
|
305
|
+
domain: "kconfig",
|
|
306
|
+
title: r.name,
|
|
307
|
+
snippet: r.prompt ?? r.help_text ?? "",
|
|
308
|
+
path: r.path ?? undefined,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (!domain || domain === "dt") {
|
|
313
|
+
const dtResults = db.searchBindings(query, limit);
|
|
314
|
+
for (const r of dtResults) {
|
|
315
|
+
allResults.push({
|
|
316
|
+
domain: "dt",
|
|
317
|
+
title: r.compatible,
|
|
318
|
+
snippet: r.description ?? "",
|
|
319
|
+
path: r.path ?? undefined,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return {
|
|
324
|
+
content: [
|
|
325
|
+
{
|
|
326
|
+
type: "text",
|
|
327
|
+
text: JSON.stringify({
|
|
328
|
+
query,
|
|
329
|
+
count: allResults.length,
|
|
330
|
+
results: allResults.slice(0, limit),
|
|
331
|
+
version: currentVersion,
|
|
332
|
+
}, null, 2),
|
|
333
|
+
},
|
|
334
|
+
],
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
default:
|
|
338
|
+
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${tool}`);
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
// --- Start ---
|
|
342
|
+
// --- Version check ---
|
|
343
|
+
const GITHUB_API = "https://api.github.com/repos/zephyrproject-rtos/zephyr/releases/latest";
|
|
344
|
+
async function checkLatestVersion() {
|
|
345
|
+
try {
|
|
346
|
+
const resp = await fetch(GITHUB_API, {
|
|
347
|
+
headers: { "Accept": "application/vnd.github.v3+json" },
|
|
348
|
+
signal: AbortSignal.timeout(10_000),
|
|
349
|
+
});
|
|
350
|
+
if (!resp.ok)
|
|
351
|
+
return null;
|
|
352
|
+
const data = (await resp.json());
|
|
353
|
+
return data.tag_name;
|
|
354
|
+
}
|
|
355
|
+
catch {
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
// --- Start ---
|
|
360
|
+
async function downloadPrebuiltIndex() {
|
|
361
|
+
const REPO = "Aarav-J/zephyr-mcp-server";
|
|
362
|
+
const RELEASES_API = `https://api.github.com/repos/${REPO}/releases/latest`;
|
|
363
|
+
try {
|
|
364
|
+
console.error("[download] Checking for pre-built index...");
|
|
365
|
+
const resp = await fetch(RELEASES_API, {
|
|
366
|
+
headers: { "Accept": "application/vnd.github.v3+json" },
|
|
367
|
+
signal: AbortSignal.timeout(15_000),
|
|
368
|
+
});
|
|
369
|
+
if (!resp.ok) {
|
|
370
|
+
console.error(`[download] Failed to fetch release info: ${resp.status}`);
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
const data = (await resp.json());
|
|
374
|
+
// Find the index asset
|
|
375
|
+
const asset = data.assets.find((a) => a.name.endsWith(".db"));
|
|
376
|
+
if (!asset) {
|
|
377
|
+
console.error("[download] No index asset found in latest release");
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
console.error(`[download] Downloading ${asset.name}...`);
|
|
381
|
+
const dbResp = await fetch(asset.browser_download_url, {
|
|
382
|
+
signal: AbortSignal.timeout(60_000),
|
|
383
|
+
});
|
|
384
|
+
if (!dbResp.ok) {
|
|
385
|
+
console.error(`[download] Download failed: ${dbResp.status}`);
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
const buffer = await dbResp.arrayBuffer();
|
|
389
|
+
const cacheDir = getCacheDir();
|
|
390
|
+
const versionDir = join(cacheDir, data.tag_name);
|
|
391
|
+
mkdirSync(versionDir, { recursive: true });
|
|
392
|
+
const dbPath = join(versionDir, "zephyr-index.db");
|
|
393
|
+
writeFileSync(dbPath, Buffer.from(buffer));
|
|
394
|
+
console.error(`[download] Saved index to ${dbPath}`);
|
|
395
|
+
const loaded = new ZephyrDatabase(dbPath);
|
|
396
|
+
const stored = loaded.getMeta("version");
|
|
397
|
+
if (stored) {
|
|
398
|
+
db = loaded;
|
|
399
|
+
currentVersion = stored;
|
|
400
|
+
console.error(`[download] Loaded index: ${stored}`);
|
|
401
|
+
return loaded;
|
|
402
|
+
}
|
|
403
|
+
loaded.close();
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
catch (err) {
|
|
407
|
+
console.error(`[download] Error: ${err}`);
|
|
408
|
+
return null;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
// --- Start ---
|
|
412
|
+
async function main() {
|
|
413
|
+
// Try local cache first
|
|
414
|
+
loadLatestIndex();
|
|
415
|
+
// If no local index, download pre-built one
|
|
416
|
+
if (!db) {
|
|
417
|
+
console.error("No local index found. Attempting to download pre-built index...");
|
|
418
|
+
await downloadPrebuiltIndex();
|
|
419
|
+
}
|
|
420
|
+
// Fire-and-forget version check
|
|
421
|
+
checkLatestVersion().then((latest) => {
|
|
422
|
+
if (latest && currentVersion && latest !== currentVersion) {
|
|
423
|
+
console.error(`[update] New Zephyr release: ${latest} (cached: ${currentVersion})`);
|
|
424
|
+
console.error(`[update] Run: cd zephyr-mcp-server && npm run build-index ${latest}`);
|
|
425
|
+
}
|
|
426
|
+
else if (latest && !currentVersion) {
|
|
427
|
+
console.error(`[update] Latest Zephyr release: ${latest}`);
|
|
428
|
+
console.error(`[update] Run: cd zephyr-mcp-server && npm run build-index ${latest}`);
|
|
429
|
+
}
|
|
430
|
+
else if (latest && latest === currentVersion) {
|
|
431
|
+
console.error(`[update] Index is up-to-date (${latest})`);
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
const transport = new StdioServerTransport();
|
|
435
|
+
await server.connect(transport);
|
|
436
|
+
console.error("Zephyr MCP server started on stdio");
|
|
437
|
+
if (db) {
|
|
438
|
+
console.error(`Active index: ${currentVersion}`);
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
console.error("No index loaded.");
|
|
442
|
+
console.error(" If first run, the server should auto-download a pre-built index.");
|
|
443
|
+
console.error(" Otherwise, run: git clone https://github.com/Aarav-J/zephyr-mcp-server.git");
|
|
444
|
+
console.error(" Then: cd zephyr-mcp-server && npm install && npm run build");
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
main().catch((err) => {
|
|
448
|
+
console.error("Fatal error:", err);
|
|
449
|
+
process.exit(1);
|
|
450
|
+
});
|
|
451
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,SAAS,EACT,QAAQ,GACT,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAyC,MAAM,SAAS,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,2BAA2B;AAE3B,IAAI,EAAE,GAA0B,IAAI,CAAC;AACrC,IAAI,cAAc,GAAkB,IAAI,CAAC;AAEzC,SAAS,eAAe;IACtB,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO;IAElC,MAAM,OAAO,GAAG,WAAW,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,MAAM,WAAW,GAAG,OAAO;SACxB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;SAC9B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SAClB,IAAI,EAAE;SACN,OAAO,EAAE,CAAC;IAEb,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC;QACtD,IAAI,UA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ACpD,IAAI,EAAE,EAAE,CAAC;QACP,OAAO,CAAC,KAAK,CAAC,iBAAiB,cAAc,EAAE,CAAC,CAAC;IACnD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,oEAAoE,CAAC,CAAC;QACpF,OAAO,CAAC,KAAK,CAAC,8EAA8E,CAAC,CAAC;QAC9F,OAAO,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC;IAChF,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FunctionRow } from "../db.js";
|
|
2
|
+
export interface ParseResult {
|
|
3
|
+
functions: FunctionRow[];
|
|
4
|
+
sourcePath: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Parse a single Doxygen XML file and return extracted functions.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseDoxygenFile(filePath: string): ParseResult;
|
|
10
|
+
/**
|
|
11
|
+
* Parse all Doxygen XML files in a directory, extracting functions.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseDoxygenDirectory(dirPath: string): ParseResult;
|
|
14
|
+
//# sourceMappingURL=doxygen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doxygen.d.ts","sourceRoot":"","sources":["../../src/parsers/doxygen.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAqNvC,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CAY9D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAwBlE"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { XMLParser } from "fast-xml-parser";
|
|
2
|
+
import { readFileSync, readdirSync, existsSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
// --- XML parsing ---
|
|
5
|
+
const parser = new XMLParser({
|
|
6
|
+
ignoreAttributes: false,
|
|
7
|
+
attributeNamePrefix: "@_",
|
|
8
|
+
isArray: (name) => ["compounddef", "sectiondef", "memberdef", "param", "para", "listitem"].includes(name),
|
|
9
|
+
processEntities: true,
|
|
10
|
+
htmlEntities: true,
|
|
11
|
+
});
|
|
12
|
+
// --- Text extraction ---
|
|
13
|
+
/** Extract plain text from a Doxygen para element (may contain nested formatting). */
|
|
14
|
+
function extractParaText(para) {
|
|
15
|
+
if (para === null || para === undefined)
|
|
16
|
+
return "";
|
|
17
|
+
if (typeof para === "string")
|
|
18
|
+
return para;
|
|
19
|
+
if (typeof para === "number")
|
|
20
|
+
return String(para);
|
|
21
|
+
if (Array.isArray(para)) {
|
|
22
|
+
return para.map(extractParaText).join(" ").trim();
|
|
23
|
+
}
|
|
24
|
+
if (typeof para !== "object")
|
|
25
|
+
return "";
|
|
26
|
+
// Direct text content
|
|
27
|
+
if ("#text" in para && typeof para["#text"] === "string") {
|
|
28
|
+
return para["#text"];
|
|
29
|
+
}
|
|
30
|
+
const obj = para;
|
|
31
|
+
// Nested paragraph
|
|
32
|
+
if (obj.para)
|
|
33
|
+
return extractParaText(obj.para);
|
|
34
|
+
// ulink element
|
|
35
|
+
if (obj.ulink && typeof obj.ulink === "object") {
|
|
36
|
+
const ulink = obj.ulink;
|
|
37
|
+
const url = typeof ulink["@_url"] === "string" ? ulink["@_url"] : "";
|
|
38
|
+
const text = extractParaText(ulink.para ?? obj.ulink);
|
|
39
|
+
return text || url;
|
|
40
|
+
}
|
|
41
|
+
// Formatted inline elements
|
|
42
|
+
for (const key of ["bold", "emphasis", "computeroutput"]) {
|
|
43
|
+
if (obj[key])
|
|
44
|
+
return extractParaText(obj[key]);
|
|
45
|
+
}
|
|
46
|
+
// ref element
|
|
47
|
+
if (obj.ref && typeof obj.ref === "object") {
|
|
48
|
+
const ref = obj.ref;
|
|
49
|
+
const text = typeof ref["#text"] === "string" ? ref["#text"] : "";
|
|
50
|
+
return text || extractParaText(ref);
|
|
51
|
+
}
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
/** Extract text from a brief/detailed description block. */
|
|
55
|
+
function extractDescription(desc) {
|
|
56
|
+
if (!desc)
|
|
57
|
+
return "";
|
|
58
|
+
if (typeof desc !== "object")
|
|
59
|
+
return "";
|
|
60
|
+
const d = desc;
|
|
61
|
+
return extractParaText(d.para ?? d);
|
|
62
|
+
}
|
|
63
|
+
/** Build full function signature from type + name + args. */
|
|
64
|
+
function buildSignature(member) {
|
|
65
|
+
let returnType = "";
|
|
66
|
+
if (member.type) {
|
|
67
|
+
if (typeof member.type === "string") {
|
|
68
|
+
returnType = member.type;
|
|
69
|
+
}
|
|
70
|
+
else if ("#text" in member.type) {
|
|
71
|
+
returnType = member.type["#text"] ?? "";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const name = member.name ?? "";
|
|
75
|
+
const args = member.argsstring ?? "()";
|
|
76
|
+
if (args.startsWith("(")) {
|
|
77
|
+
return `${returnType} ${name}${args}`;
|
|
78
|
+
}
|
|
79
|
+
if (args.startsWith(returnType) || returnType === "") {
|
|
80
|
+
return args;
|
|
81
|
+
}
|
|
82
|
+
return `${returnType} ${name}${args.startsWith("(") ? args : `(${args})`}`;
|
|
83
|
+
}
|
|
84
|
+
/** Extract name from a param element. */
|
|
85
|
+
function extractParamName(param) {
|
|
86
|
+
return param.declname ?? "";
|
|
87
|
+
}
|
|
88
|
+
/** Extract type string from a Doxygen type element. */
|
|
89
|
+
function extractTypeString(typeVal) {
|
|
90
|
+
if (!typeVal)
|
|
91
|
+
return "";
|
|
92
|
+
if (typeof typeVal === "string")
|
|
93
|
+
return typeVal;
|
|
94
|
+
if (typeof typeVal === "object" && "#text" in typeVal) {
|
|
95
|
+
const v = typeVal["#text"];
|
|
96
|
+
return typeof v === "string" ? v : "";
|
|
97
|
+
}
|
|
98
|
+
return "";
|
|
99
|
+
}
|
|
100
|
+
// --- Parsing engine ---
|
|
101
|
+
/** Parse a single Doxygen compounddef and extract all functions. */
|
|
102
|
+
function parseCompounddef(compound, _sourcePath) {
|
|
103
|
+
const rows = [];
|
|
104
|
+
const groupId = compound.compoundname ?? null;
|
|
105
|
+
const section = compound.title ?? null;
|
|
106
|
+
const candidates = [];
|
|
107
|
+
if (compound.sectiondef) {
|
|
108
|
+
for (const sectiondef of compound.sectiondef) {
|
|
109
|
+
if (sectiondef["@_kind"] === "func" && sectiondef.memberdef) {
|
|
110
|
+
candidates.push(...sectiondef.memberdef);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (compound.memberdef) {
|
|
115
|
+
candidates.push(...compound.memberdef);
|
|
116
|
+
}
|
|
117
|
+
for (const member of candidates) {
|
|
118
|
+
if (member["@_kind"] !== "function")
|
|
119
|
+
continue;
|
|
120
|
+
if (!member.name)
|
|
121
|
+
continue;
|
|
122
|
+
const params = (member.param ?? []).map((p) => ({
|
|
123
|
+
name: extractParamName(p),
|
|
124
|
+
type: extractTypeString(p.type),
|
|
125
|
+
description: extractDescription(p.briefdescription),
|
|
126
|
+
}));
|
|
127
|
+
const row = {
|
|
128
|
+
name: member.name,
|
|
129
|
+
signature: buildSignature(member),
|
|
130
|
+
brief: extractDescription(member.briefdescription) || null,
|
|
131
|
+
description: extractDescription(member.detaileddescription) || null,
|
|
132
|
+
params: params.length > 0 ? JSON.stringify(params) : null,
|
|
133
|
+
return_type: extractTypeString(member.type) || null,
|
|
134
|
+
return_desc: null,
|
|
135
|
+
header: member.location?.["@_declfile"] ?? member.location?.["@_file"] ?? null,
|
|
136
|
+
section: section ?? null,
|
|
137
|
+
group_id: groupId,
|
|
138
|
+
};
|
|
139
|
+
rows.push(row);
|
|
140
|
+
}
|
|
141
|
+
return rows;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Parse a single Doxygen XML file and return extracted functions.
|
|
145
|
+
*/
|
|
146
|
+
export function parseDoxygenFile(filePath) {
|
|
147
|
+
const xml = readFileSync(filePath, "utf-8");
|
|
148
|
+
const parsed = parser.parse(xml);
|
|
149
|
+
const compounds = parsed.doxygen?.compounddef ?? [];
|
|
150
|
+
const functions = [];
|
|
151
|
+
for (const compound of compounds) {
|
|
152
|
+
const rows = parseCompounddef(compound, filePath);
|
|
153
|
+
functions.push(...rows);
|
|
154
|
+
}
|
|
155
|
+
return { functions, sourcePath: filePath };
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Parse all Doxygen XML files in a directory, extracting functions.
|
|
159
|
+
*/
|
|
160
|
+
export function parseDoxygenDirectory(dirPath) {
|
|
161
|
+
const allFunctions = [];
|
|
162
|
+
if (!existsSync(dirPath)) {
|
|
163
|
+
throw new Error(`Doxygen XML directory not found: ${dirPath}`);
|
|
164
|
+
}
|
|
165
|
+
const entries = readdirSync(dirPath, { withFileTypes: true });
|
|
166
|
+
for (const entry of entries) {
|
|
167
|
+
if (!entry.isFile())
|
|
168
|
+
continue;
|
|
169
|
+
if (!entry.name.endsWith(".xml"))
|
|
170
|
+
continue;
|
|
171
|
+
if (entry.name === "index.xml")
|
|
172
|
+
continue;
|
|
173
|
+
const filePath = join(dirPath, entry.name);
|
|
174
|
+
try {
|
|
175
|
+
const result = parseDoxygenFile(filePath);
|
|
176
|
+
allFunctions.push(...result.functions);
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return { functions: allFunctions, sourcePath: dirPath };
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=doxygen.js.map
|