musubix2 0.5.8 → 0.5.9
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/.claude/.musubix-managed +1 -1
- package/dist/assets/skills-manifest.json +1 -1
- package/dist/cli.js +129 -60
- package/dist/index.js +129 -60
- package/package.json +1 -1
package/.claude/.musubix-managed
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"generator":"musubix2","version":"0.5.
|
|
1
|
+
{"generator":"musubix2","version":"0.5.9","timestamp":"2026-07-09T10:34:18.313Z"}
|
package/dist/cli.js
CHANGED
|
@@ -14180,63 +14180,101 @@ function policyTools() {
|
|
|
14180
14180
|
})
|
|
14181
14181
|
];
|
|
14182
14182
|
}
|
|
14183
|
+
async function loadTripleStore(basePath) {
|
|
14184
|
+
const { createOntologyStore: createOntologyStore2 } = await Promise.resolve().then(() => (init_dist3(), dist_exports3));
|
|
14185
|
+
const store = createOntologyStore2();
|
|
14186
|
+
const { existsSync: existsSync12, readFileSync: readFileSync7 } = await import("node:fs");
|
|
14187
|
+
const { join: join8 } = await import("node:path");
|
|
14188
|
+
const file = join8(basePath, ".musubix", "ontology.json");
|
|
14189
|
+
try {
|
|
14190
|
+
if (existsSync12(file)) {
|
|
14191
|
+
store.addTriples(JSON.parse(readFileSync7(file, "utf-8")));
|
|
14192
|
+
}
|
|
14193
|
+
} catch {
|
|
14194
|
+
}
|
|
14195
|
+
return { store, file };
|
|
14196
|
+
}
|
|
14197
|
+
async function saveTripleStore(store, file) {
|
|
14198
|
+
const { writeFileSync: writeFileSync4, mkdirSync: mkdirSync4 } = await import("node:fs");
|
|
14199
|
+
const { dirname: dirname4 } = await import("node:path");
|
|
14200
|
+
mkdirSync4(dirname4(file), { recursive: true });
|
|
14201
|
+
writeFileSync4(file, JSON.stringify(store.getAll(), null, 2), "utf-8");
|
|
14202
|
+
}
|
|
14183
14203
|
function ontologyTools() {
|
|
14184
14204
|
return [
|
|
14185
|
-
tool("ontology.triple.add", "Add a triple (subject, predicate, object) to the ontology store", "ontology", [
|
|
14186
|
-
param("subject", "string", "Subject
|
|
14187
|
-
param("predicate", "string", "Predicate
|
|
14188
|
-
param("object", "string", "Object URI or literal")
|
|
14205
|
+
tool("ontology.triple.add", "Add a triple (subject, predicate, object) to the persisted ontology store", "ontology", [
|
|
14206
|
+
param("subject", "string", "Subject"),
|
|
14207
|
+
param("predicate", "string", "Predicate"),
|
|
14208
|
+
param("object", "string", "Object (URI or literal)"),
|
|
14209
|
+
param("basePath", "string", "Project base path", false, ".")
|
|
14189
14210
|
], async (params) => {
|
|
14190
14211
|
try {
|
|
14191
|
-
const
|
|
14192
|
-
|
|
14193
|
-
|
|
14194
|
-
|
|
14212
|
+
const { store, file } = await loadTripleStore(params["basePath"] ?? ".");
|
|
14213
|
+
store.addTriple({
|
|
14214
|
+
subject: params["subject"],
|
|
14215
|
+
predicate: params["predicate"],
|
|
14216
|
+
object: params["object"]
|
|
14217
|
+
});
|
|
14218
|
+
await saveTripleStore(store, file);
|
|
14219
|
+
return ok({ added: true, total: store.size() });
|
|
14195
14220
|
} catch {
|
|
14196
|
-
return
|
|
14221
|
+
return fail("Ontology package not available");
|
|
14197
14222
|
}
|
|
14198
14223
|
}),
|
|
14199
|
-
tool("ontology.triple.query", "Query triples by pattern
|
|
14200
|
-
param("subject", "string", "Subject pattern
|
|
14201
|
-
param("predicate", "string", "Predicate pattern
|
|
14202
|
-
param("object", "string", "Object pattern
|
|
14224
|
+
tool("ontology.triple.query", "Query triples by pattern (omit a term to wildcard it)", "ontology", [
|
|
14225
|
+
param("subject", "string", "Subject pattern", false),
|
|
14226
|
+
param("predicate", "string", "Predicate pattern", false),
|
|
14227
|
+
param("object", "string", "Object pattern", false),
|
|
14228
|
+
param("basePath", "string", "Project base path", false, ".")
|
|
14203
14229
|
], async (params) => {
|
|
14204
14230
|
try {
|
|
14205
|
-
const
|
|
14206
|
-
const
|
|
14207
|
-
|
|
14208
|
-
|
|
14231
|
+
const { store } = await loadTripleStore(params["basePath"] ?? ".");
|
|
14232
|
+
const results = store.query({
|
|
14233
|
+
subject: params["subject"],
|
|
14234
|
+
predicate: params["predicate"],
|
|
14235
|
+
object: params["object"]
|
|
14236
|
+
});
|
|
14237
|
+
return ok({ results, count: results.length });
|
|
14209
14238
|
} catch {
|
|
14210
|
-
return
|
|
14239
|
+
return fail("Ontology package not available");
|
|
14211
14240
|
}
|
|
14212
14241
|
}),
|
|
14213
|
-
tool("ontology.rules.apply", "Apply rule engine to infer new triples", "ontology", [param("
|
|
14242
|
+
tool("ontology.rules.apply", "Apply the default OWL 2 RL rule engine to infer new triples", "ontology", [param("basePath", "string", "Project base path", false, ".")], async (params) => {
|
|
14214
14243
|
try {
|
|
14215
|
-
const
|
|
14216
|
-
const
|
|
14217
|
-
const result =
|
|
14218
|
-
|
|
14244
|
+
const { createRuleEngine: createRuleEngine2 } = await Promise.resolve().then(() => (init_dist3(), dist_exports3));
|
|
14245
|
+
const { store, file } = await loadTripleStore(params["basePath"] ?? ".");
|
|
14246
|
+
const result = createRuleEngine2(true).applyRules(store);
|
|
14247
|
+
await saveTripleStore(store, file);
|
|
14248
|
+
return ok(result);
|
|
14219
14249
|
} catch {
|
|
14220
|
-
return
|
|
14250
|
+
return fail("Ontology package not available");
|
|
14221
14251
|
}
|
|
14222
14252
|
}),
|
|
14223
|
-
tool("ontology.consistency.check", "Check ontology consistency", "ontology", [], async () => {
|
|
14253
|
+
tool("ontology.consistency.check", "Check ontology consistency against the persisted store", "ontology", [param("basePath", "string", "Project base path", false, ".")], async (params) => {
|
|
14224
14254
|
try {
|
|
14225
|
-
const
|
|
14226
|
-
const
|
|
14227
|
-
|
|
14228
|
-
return ok(result ?? { consistent: true, issues: [] });
|
|
14255
|
+
const { createConsistencyValidator: createConsistencyValidator2 } = await Promise.resolve().then(() => (init_dist3(), dist_exports3));
|
|
14256
|
+
const { store } = await loadTripleStore(params["basePath"] ?? ".");
|
|
14257
|
+
return ok(createConsistencyValidator2().validate(store));
|
|
14229
14258
|
} catch {
|
|
14230
|
-
return
|
|
14259
|
+
return fail("Ontology package not available");
|
|
14231
14260
|
}
|
|
14232
14261
|
}),
|
|
14233
|
-
tool("ontology.sparql.query", "
|
|
14262
|
+
tool("ontology.sparql.query", "Pattern query over the store (basic subject/predicate/object matching)", "ontology", [
|
|
14263
|
+
param("subject", "string", "Subject pattern", false),
|
|
14264
|
+
param("predicate", "string", "Predicate pattern", false),
|
|
14265
|
+
param("object", "string", "Object pattern", false),
|
|
14266
|
+
param("basePath", "string", "Project base path", false, ".")
|
|
14267
|
+
], async (params) => {
|
|
14234
14268
|
try {
|
|
14235
|
-
const
|
|
14236
|
-
const
|
|
14237
|
-
|
|
14269
|
+
const { store } = await loadTripleStore(params["basePath"] ?? ".");
|
|
14270
|
+
const bindings = store.query({
|
|
14271
|
+
subject: params["subject"],
|
|
14272
|
+
predicate: params["predicate"],
|
|
14273
|
+
object: params["object"]
|
|
14274
|
+
});
|
|
14275
|
+
return ok({ bindings, count: bindings.length });
|
|
14238
14276
|
} catch {
|
|
14239
|
-
return
|
|
14277
|
+
return fail("Ontology package not available");
|
|
14240
14278
|
}
|
|
14241
14279
|
})
|
|
14242
14280
|
];
|
|
@@ -14248,47 +14286,78 @@ function codeAnalysisTools() {
|
|
|
14248
14286
|
param("language", "string", "Source language: typescript | javascript | python", false, "typescript")
|
|
14249
14287
|
], async (params) => {
|
|
14250
14288
|
try {
|
|
14251
|
-
const
|
|
14252
|
-
const
|
|
14253
|
-
return ok(
|
|
14289
|
+
const { createASTParser: createASTParser2 } = await Promise.resolve().then(() => (init_dist4(), dist_exports4));
|
|
14290
|
+
const nodes = createASTParser2().parse(params["source"] ?? "", params["language"] ?? "typescript");
|
|
14291
|
+
return ok({ nodes, count: nodes.length });
|
|
14254
14292
|
} catch {
|
|
14255
|
-
return
|
|
14293
|
+
return fail("Codegraph package not available");
|
|
14256
14294
|
}
|
|
14257
14295
|
}),
|
|
14258
|
-
tool("code.graph.build", "Build a
|
|
14259
|
-
param("entryPoint", "string", "Entry point file path"),
|
|
14260
|
-
param("basePath", "string", "Project base path", false, ".")
|
|
14261
|
-
], async (params) => {
|
|
14296
|
+
tool("code.graph.build", "Build a code graph (nodes) from inline sources", "code-analysis", [param("sources", "array", "Sources as {code, language, filePath} objects")], async (params) => {
|
|
14262
14297
|
try {
|
|
14263
|
-
const
|
|
14264
|
-
const
|
|
14265
|
-
|
|
14298
|
+
const { createASTParser: createASTParser2, createGraphEngine: createGraphEngine2 } = await Promise.resolve().then(() => (init_dist4(), dist_exports4));
|
|
14299
|
+
const parser = createASTParser2();
|
|
14300
|
+
const engine = createGraphEngine2();
|
|
14301
|
+
const sources = params["sources"] ?? [];
|
|
14302
|
+
for (const s of sources) {
|
|
14303
|
+
const lang = s.language ?? "typescript";
|
|
14304
|
+
for (const n of parser.parse(s.code ?? "", lang)) {
|
|
14305
|
+
engine.addNode({
|
|
14306
|
+
id: `${s.filePath ?? "inline"}:${n.name}`,
|
|
14307
|
+
name: n.name,
|
|
14308
|
+
kind: n.kind,
|
|
14309
|
+
filePath: s.filePath ?? "inline",
|
|
14310
|
+
language: lang,
|
|
14311
|
+
startLine: n.startLine ?? 0,
|
|
14312
|
+
endLine: n.endLine ?? 0
|
|
14313
|
+
});
|
|
14314
|
+
}
|
|
14315
|
+
}
|
|
14316
|
+
const stats = engine.getStats();
|
|
14317
|
+
return ok({ nodeCount: stats.nodeCount, edgeCount: stats.edgeCount, languages: [...stats.languages] });
|
|
14266
14318
|
} catch {
|
|
14267
|
-
return
|
|
14319
|
+
return fail("Codegraph package not available");
|
|
14268
14320
|
}
|
|
14269
14321
|
}),
|
|
14270
|
-
tool("code.graph.search", "Search code graph using GraphRAG
|
|
14322
|
+
tool("code.graph.search", "Search a code graph built from inline sources using GraphRAG", "code-analysis", [
|
|
14271
14323
|
param("query", "string", "Search query"),
|
|
14272
|
-
param("
|
|
14324
|
+
param("sources", "array", "Sources as {code, language, filePath} objects to index")
|
|
14273
14325
|
], async (params) => {
|
|
14274
14326
|
try {
|
|
14275
|
-
const
|
|
14276
|
-
const
|
|
14277
|
-
|
|
14327
|
+
const { createASTParser: createASTParser2, createGraphEngine: createGraphEngine2, GraphRAGSearch: GraphRAGSearch2 } = await Promise.resolve().then(() => (init_dist4(), dist_exports4));
|
|
14328
|
+
const parser = createASTParser2();
|
|
14329
|
+
const engine = createGraphEngine2();
|
|
14330
|
+
const sources = params["sources"] ?? [];
|
|
14331
|
+
for (const s of sources) {
|
|
14332
|
+
const lang = s.language ?? "typescript";
|
|
14333
|
+
for (const n of parser.parse(s.code ?? "", lang)) {
|
|
14334
|
+
engine.addNode({
|
|
14335
|
+
id: `${s.filePath ?? "inline"}:${n.name}`,
|
|
14336
|
+
name: n.name,
|
|
14337
|
+
kind: n.kind,
|
|
14338
|
+
filePath: s.filePath ?? "inline",
|
|
14339
|
+
language: lang,
|
|
14340
|
+
startLine: n.startLine ?? 0,
|
|
14341
|
+
endLine: n.endLine ?? 0
|
|
14342
|
+
});
|
|
14343
|
+
}
|
|
14344
|
+
}
|
|
14345
|
+
const results = new GraphRAGSearch2(engine).globalSearch(params["query"] ?? "");
|
|
14346
|
+
return ok({ query: params["query"], results });
|
|
14278
14347
|
} catch {
|
|
14279
|
-
return
|
|
14348
|
+
return fail("Codegraph package not available");
|
|
14280
14349
|
}
|
|
14281
14350
|
}),
|
|
14282
|
-
tool("code.dfg.analyze", "
|
|
14283
|
-
param("
|
|
14284
|
-
param("
|
|
14351
|
+
tool("code.dfg.analyze", "Build a data-flow graph from structured statements and report reaching definitions", "code-analysis", [
|
|
14352
|
+
param("statements", "array", "SimpleStatement[] (type/line/variable/value/usedVariables)"),
|
|
14353
|
+
param("scope", "string", "Scope name", false, "global")
|
|
14285
14354
|
], async (params) => {
|
|
14286
14355
|
try {
|
|
14287
|
-
const
|
|
14288
|
-
const
|
|
14289
|
-
return ok(
|
|
14356
|
+
const { createDataFlowAnalyzer: createDataFlowAnalyzer2 } = await Promise.resolve().then(() => (init_dist13(), dist_exports13));
|
|
14357
|
+
const dfg = createDataFlowAnalyzer2().buildDFG(params["statements"] ?? [], params["scope"] ?? "global");
|
|
14358
|
+
return ok(dfg);
|
|
14290
14359
|
} catch {
|
|
14291
|
-
return
|
|
14360
|
+
return fail("DFG package not available");
|
|
14292
14361
|
}
|
|
14293
14362
|
})
|
|
14294
14363
|
];
|
package/dist/index.js
CHANGED
|
@@ -14180,63 +14180,101 @@ function policyTools() {
|
|
|
14180
14180
|
})
|
|
14181
14181
|
];
|
|
14182
14182
|
}
|
|
14183
|
+
async function loadTripleStore(basePath) {
|
|
14184
|
+
const { createOntologyStore: createOntologyStore2 } = await Promise.resolve().then(() => (init_dist3(), dist_exports3));
|
|
14185
|
+
const store = createOntologyStore2();
|
|
14186
|
+
const { existsSync: existsSync12, readFileSync: readFileSync7 } = await import("node:fs");
|
|
14187
|
+
const { join: join8 } = await import("node:path");
|
|
14188
|
+
const file = join8(basePath, ".musubix", "ontology.json");
|
|
14189
|
+
try {
|
|
14190
|
+
if (existsSync12(file)) {
|
|
14191
|
+
store.addTriples(JSON.parse(readFileSync7(file, "utf-8")));
|
|
14192
|
+
}
|
|
14193
|
+
} catch {
|
|
14194
|
+
}
|
|
14195
|
+
return { store, file };
|
|
14196
|
+
}
|
|
14197
|
+
async function saveTripleStore(store, file) {
|
|
14198
|
+
const { writeFileSync: writeFileSync4, mkdirSync: mkdirSync4 } = await import("node:fs");
|
|
14199
|
+
const { dirname: dirname4 } = await import("node:path");
|
|
14200
|
+
mkdirSync4(dirname4(file), { recursive: true });
|
|
14201
|
+
writeFileSync4(file, JSON.stringify(store.getAll(), null, 2), "utf-8");
|
|
14202
|
+
}
|
|
14183
14203
|
function ontologyTools() {
|
|
14184
14204
|
return [
|
|
14185
|
-
tool("ontology.triple.add", "Add a triple (subject, predicate, object) to the ontology store", "ontology", [
|
|
14186
|
-
param("subject", "string", "Subject
|
|
14187
|
-
param("predicate", "string", "Predicate
|
|
14188
|
-
param("object", "string", "Object URI or literal")
|
|
14205
|
+
tool("ontology.triple.add", "Add a triple (subject, predicate, object) to the persisted ontology store", "ontology", [
|
|
14206
|
+
param("subject", "string", "Subject"),
|
|
14207
|
+
param("predicate", "string", "Predicate"),
|
|
14208
|
+
param("object", "string", "Object (URI or literal)"),
|
|
14209
|
+
param("basePath", "string", "Project base path", false, ".")
|
|
14189
14210
|
], async (params) => {
|
|
14190
14211
|
try {
|
|
14191
|
-
const
|
|
14192
|
-
|
|
14193
|
-
|
|
14194
|
-
|
|
14212
|
+
const { store, file } = await loadTripleStore(params["basePath"] ?? ".");
|
|
14213
|
+
store.addTriple({
|
|
14214
|
+
subject: params["subject"],
|
|
14215
|
+
predicate: params["predicate"],
|
|
14216
|
+
object: params["object"]
|
|
14217
|
+
});
|
|
14218
|
+
await saveTripleStore(store, file);
|
|
14219
|
+
return ok({ added: true, total: store.size() });
|
|
14195
14220
|
} catch {
|
|
14196
|
-
return
|
|
14221
|
+
return fail("Ontology package not available");
|
|
14197
14222
|
}
|
|
14198
14223
|
}),
|
|
14199
|
-
tool("ontology.triple.query", "Query triples by pattern
|
|
14200
|
-
param("subject", "string", "Subject pattern
|
|
14201
|
-
param("predicate", "string", "Predicate pattern
|
|
14202
|
-
param("object", "string", "Object pattern
|
|
14224
|
+
tool("ontology.triple.query", "Query triples by pattern (omit a term to wildcard it)", "ontology", [
|
|
14225
|
+
param("subject", "string", "Subject pattern", false),
|
|
14226
|
+
param("predicate", "string", "Predicate pattern", false),
|
|
14227
|
+
param("object", "string", "Object pattern", false),
|
|
14228
|
+
param("basePath", "string", "Project base path", false, ".")
|
|
14203
14229
|
], async (params) => {
|
|
14204
14230
|
try {
|
|
14205
|
-
const
|
|
14206
|
-
const
|
|
14207
|
-
|
|
14208
|
-
|
|
14231
|
+
const { store } = await loadTripleStore(params["basePath"] ?? ".");
|
|
14232
|
+
const results = store.query({
|
|
14233
|
+
subject: params["subject"],
|
|
14234
|
+
predicate: params["predicate"],
|
|
14235
|
+
object: params["object"]
|
|
14236
|
+
});
|
|
14237
|
+
return ok({ results, count: results.length });
|
|
14209
14238
|
} catch {
|
|
14210
|
-
return
|
|
14239
|
+
return fail("Ontology package not available");
|
|
14211
14240
|
}
|
|
14212
14241
|
}),
|
|
14213
|
-
tool("ontology.rules.apply", "Apply rule engine to infer new triples", "ontology", [param("
|
|
14242
|
+
tool("ontology.rules.apply", "Apply the default OWL 2 RL rule engine to infer new triples", "ontology", [param("basePath", "string", "Project base path", false, ".")], async (params) => {
|
|
14214
14243
|
try {
|
|
14215
|
-
const
|
|
14216
|
-
const
|
|
14217
|
-
const result =
|
|
14218
|
-
|
|
14244
|
+
const { createRuleEngine: createRuleEngine2 } = await Promise.resolve().then(() => (init_dist3(), dist_exports3));
|
|
14245
|
+
const { store, file } = await loadTripleStore(params["basePath"] ?? ".");
|
|
14246
|
+
const result = createRuleEngine2(true).applyRules(store);
|
|
14247
|
+
await saveTripleStore(store, file);
|
|
14248
|
+
return ok(result);
|
|
14219
14249
|
} catch {
|
|
14220
|
-
return
|
|
14250
|
+
return fail("Ontology package not available");
|
|
14221
14251
|
}
|
|
14222
14252
|
}),
|
|
14223
|
-
tool("ontology.consistency.check", "Check ontology consistency", "ontology", [], async () => {
|
|
14253
|
+
tool("ontology.consistency.check", "Check ontology consistency against the persisted store", "ontology", [param("basePath", "string", "Project base path", false, ".")], async (params) => {
|
|
14224
14254
|
try {
|
|
14225
|
-
const
|
|
14226
|
-
const
|
|
14227
|
-
|
|
14228
|
-
return ok(result ?? { consistent: true, issues: [] });
|
|
14255
|
+
const { createConsistencyValidator: createConsistencyValidator2 } = await Promise.resolve().then(() => (init_dist3(), dist_exports3));
|
|
14256
|
+
const { store } = await loadTripleStore(params["basePath"] ?? ".");
|
|
14257
|
+
return ok(createConsistencyValidator2().validate(store));
|
|
14229
14258
|
} catch {
|
|
14230
|
-
return
|
|
14259
|
+
return fail("Ontology package not available");
|
|
14231
14260
|
}
|
|
14232
14261
|
}),
|
|
14233
|
-
tool("ontology.sparql.query", "
|
|
14262
|
+
tool("ontology.sparql.query", "Pattern query over the store (basic subject/predicate/object matching)", "ontology", [
|
|
14263
|
+
param("subject", "string", "Subject pattern", false),
|
|
14264
|
+
param("predicate", "string", "Predicate pattern", false),
|
|
14265
|
+
param("object", "string", "Object pattern", false),
|
|
14266
|
+
param("basePath", "string", "Project base path", false, ".")
|
|
14267
|
+
], async (params) => {
|
|
14234
14268
|
try {
|
|
14235
|
-
const
|
|
14236
|
-
const
|
|
14237
|
-
|
|
14269
|
+
const { store } = await loadTripleStore(params["basePath"] ?? ".");
|
|
14270
|
+
const bindings = store.query({
|
|
14271
|
+
subject: params["subject"],
|
|
14272
|
+
predicate: params["predicate"],
|
|
14273
|
+
object: params["object"]
|
|
14274
|
+
});
|
|
14275
|
+
return ok({ bindings, count: bindings.length });
|
|
14238
14276
|
} catch {
|
|
14239
|
-
return
|
|
14277
|
+
return fail("Ontology package not available");
|
|
14240
14278
|
}
|
|
14241
14279
|
})
|
|
14242
14280
|
];
|
|
@@ -14248,47 +14286,78 @@ function codeAnalysisTools() {
|
|
|
14248
14286
|
param("language", "string", "Source language: typescript | javascript | python", false, "typescript")
|
|
14249
14287
|
], async (params) => {
|
|
14250
14288
|
try {
|
|
14251
|
-
const
|
|
14252
|
-
const
|
|
14253
|
-
return ok(
|
|
14289
|
+
const { createASTParser: createASTParser2 } = await Promise.resolve().then(() => (init_dist4(), dist_exports4));
|
|
14290
|
+
const nodes = createASTParser2().parse(params["source"] ?? "", params["language"] ?? "typescript");
|
|
14291
|
+
return ok({ nodes, count: nodes.length });
|
|
14254
14292
|
} catch {
|
|
14255
|
-
return
|
|
14293
|
+
return fail("Codegraph package not available");
|
|
14256
14294
|
}
|
|
14257
14295
|
}),
|
|
14258
|
-
tool("code.graph.build", "Build a
|
|
14259
|
-
param("entryPoint", "string", "Entry point file path"),
|
|
14260
|
-
param("basePath", "string", "Project base path", false, ".")
|
|
14261
|
-
], async (params) => {
|
|
14296
|
+
tool("code.graph.build", "Build a code graph (nodes) from inline sources", "code-analysis", [param("sources", "array", "Sources as {code, language, filePath} objects")], async (params) => {
|
|
14262
14297
|
try {
|
|
14263
|
-
const
|
|
14264
|
-
const
|
|
14265
|
-
|
|
14298
|
+
const { createASTParser: createASTParser2, createGraphEngine: createGraphEngine2 } = await Promise.resolve().then(() => (init_dist4(), dist_exports4));
|
|
14299
|
+
const parser = createASTParser2();
|
|
14300
|
+
const engine = createGraphEngine2();
|
|
14301
|
+
const sources = params["sources"] ?? [];
|
|
14302
|
+
for (const s of sources) {
|
|
14303
|
+
const lang = s.language ?? "typescript";
|
|
14304
|
+
for (const n of parser.parse(s.code ?? "", lang)) {
|
|
14305
|
+
engine.addNode({
|
|
14306
|
+
id: `${s.filePath ?? "inline"}:${n.name}`,
|
|
14307
|
+
name: n.name,
|
|
14308
|
+
kind: n.kind,
|
|
14309
|
+
filePath: s.filePath ?? "inline",
|
|
14310
|
+
language: lang,
|
|
14311
|
+
startLine: n.startLine ?? 0,
|
|
14312
|
+
endLine: n.endLine ?? 0
|
|
14313
|
+
});
|
|
14314
|
+
}
|
|
14315
|
+
}
|
|
14316
|
+
const stats = engine.getStats();
|
|
14317
|
+
return ok({ nodeCount: stats.nodeCount, edgeCount: stats.edgeCount, languages: [...stats.languages] });
|
|
14266
14318
|
} catch {
|
|
14267
|
-
return
|
|
14319
|
+
return fail("Codegraph package not available");
|
|
14268
14320
|
}
|
|
14269
14321
|
}),
|
|
14270
|
-
tool("code.graph.search", "Search code graph using GraphRAG
|
|
14322
|
+
tool("code.graph.search", "Search a code graph built from inline sources using GraphRAG", "code-analysis", [
|
|
14271
14323
|
param("query", "string", "Search query"),
|
|
14272
|
-
param("
|
|
14324
|
+
param("sources", "array", "Sources as {code, language, filePath} objects to index")
|
|
14273
14325
|
], async (params) => {
|
|
14274
14326
|
try {
|
|
14275
|
-
const
|
|
14276
|
-
const
|
|
14277
|
-
|
|
14327
|
+
const { createASTParser: createASTParser2, createGraphEngine: createGraphEngine2, GraphRAGSearch: GraphRAGSearch2 } = await Promise.resolve().then(() => (init_dist4(), dist_exports4));
|
|
14328
|
+
const parser = createASTParser2();
|
|
14329
|
+
const engine = createGraphEngine2();
|
|
14330
|
+
const sources = params["sources"] ?? [];
|
|
14331
|
+
for (const s of sources) {
|
|
14332
|
+
const lang = s.language ?? "typescript";
|
|
14333
|
+
for (const n of parser.parse(s.code ?? "", lang)) {
|
|
14334
|
+
engine.addNode({
|
|
14335
|
+
id: `${s.filePath ?? "inline"}:${n.name}`,
|
|
14336
|
+
name: n.name,
|
|
14337
|
+
kind: n.kind,
|
|
14338
|
+
filePath: s.filePath ?? "inline",
|
|
14339
|
+
language: lang,
|
|
14340
|
+
startLine: n.startLine ?? 0,
|
|
14341
|
+
endLine: n.endLine ?? 0
|
|
14342
|
+
});
|
|
14343
|
+
}
|
|
14344
|
+
}
|
|
14345
|
+
const results = new GraphRAGSearch2(engine).globalSearch(params["query"] ?? "");
|
|
14346
|
+
return ok({ query: params["query"], results });
|
|
14278
14347
|
} catch {
|
|
14279
|
-
return
|
|
14348
|
+
return fail("Codegraph package not available");
|
|
14280
14349
|
}
|
|
14281
14350
|
}),
|
|
14282
|
-
tool("code.dfg.analyze", "
|
|
14283
|
-
param("
|
|
14284
|
-
param("
|
|
14351
|
+
tool("code.dfg.analyze", "Build a data-flow graph from structured statements and report reaching definitions", "code-analysis", [
|
|
14352
|
+
param("statements", "array", "SimpleStatement[] (type/line/variable/value/usedVariables)"),
|
|
14353
|
+
param("scope", "string", "Scope name", false, "global")
|
|
14285
14354
|
], async (params) => {
|
|
14286
14355
|
try {
|
|
14287
|
-
const
|
|
14288
|
-
const
|
|
14289
|
-
return ok(
|
|
14356
|
+
const { createDataFlowAnalyzer: createDataFlowAnalyzer2 } = await Promise.resolve().then(() => (init_dist13(), dist_exports13));
|
|
14357
|
+
const dfg = createDataFlowAnalyzer2().buildDFG(params["statements"] ?? [], params["scope"] ?? "global");
|
|
14358
|
+
return ok(dfg);
|
|
14290
14359
|
} catch {
|
|
14291
|
-
return
|
|
14360
|
+
return fail("DFG package not available");
|
|
14292
14361
|
}
|
|
14293
14362
|
})
|
|
14294
14363
|
];
|