opentology 0.3.5 → 0.3.6
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/dist/mcp/server.js +26 -2
- package/package.json +1 -1
package/dist/mcp/server.js
CHANGED
|
@@ -379,22 +379,46 @@ async function handleContextScan(args) {
|
|
|
379
379
|
}
|
|
380
380
|
// Auto-push triples server-side
|
|
381
381
|
let pushStats = null;
|
|
382
|
+
let moduleStats = null;
|
|
382
383
|
try {
|
|
383
384
|
const config = loadConfig();
|
|
384
385
|
const contextUri = `${config.graphUri}/context`;
|
|
385
386
|
const adapter = await createReadyAdapter(config);
|
|
387
|
+
// Push symbol triples
|
|
386
388
|
pushStats = await pushSymbolTriples(adapter, contextUri, scanResult);
|
|
389
|
+
// Also push module dependency graph (fixes #64)
|
|
390
|
+
const snapshot = await scanCodebase(process.cwd());
|
|
391
|
+
if (snapshot.dependencyGraph && snapshot.dependencyGraph.modules.length > 0) {
|
|
392
|
+
const dg = snapshot.dependencyGraph;
|
|
393
|
+
// Clear stale Module/dependsOn triples
|
|
394
|
+
await adapter.sparqlUpdate(`DELETE { GRAPH <${contextUri}> { ?s ?p ?o } } WHERE { GRAPH <${contextUri}> { ?s ?p ?o . { ?s a <https://opentology.dev/vocab#Module> } UNION { ?s <https://opentology.dev/vocab#dependsOn> ?o } } }`);
|
|
395
|
+
const sparqlTriples = [];
|
|
396
|
+
for (const mod of dg.modules) {
|
|
397
|
+
sparqlTriples.push(`<urn:module:${mod}> a <https://opentology.dev/vocab#Module> ; <https://opentology.dev/vocab#title> "${mod}" .`);
|
|
398
|
+
}
|
|
399
|
+
for (const edge of dg.edges) {
|
|
400
|
+
sparqlTriples.push(`<urn:module:${edge.from}> <https://opentology.dev/vocab#dependsOn> <urn:module:${edge.to}> .`);
|
|
401
|
+
}
|
|
402
|
+
await adapter.sparqlUpdate(`INSERT DATA { GRAPH <${contextUri}> {\n${sparqlTriples.join('\n')}\n} }`);
|
|
403
|
+
moduleStats = { modules: dg.modules.length, edges: dg.edges.length };
|
|
404
|
+
}
|
|
387
405
|
await persistGraph(adapter, config, contextUri);
|
|
388
406
|
}
|
|
389
407
|
catch {
|
|
390
408
|
// Non-fatal: push is best-effort
|
|
391
409
|
}
|
|
410
|
+
const hints = [];
|
|
411
|
+
if (pushStats)
|
|
412
|
+
hints.push(`Symbol triples: ${pushStats.triplesInserted} in ${pushStats.batchCount} batches`);
|
|
413
|
+
if (moduleStats)
|
|
414
|
+
hints.push(`Module triples: ${moduleStats.modules} modules, ${moduleStats.edges} edges`);
|
|
392
415
|
return {
|
|
393
416
|
...scanResult,
|
|
394
417
|
pushStats,
|
|
418
|
+
moduleStats,
|
|
395
419
|
_experimental: true,
|
|
396
|
-
_hint:
|
|
397
|
-
?
|
|
420
|
+
_hint: hints.length
|
|
421
|
+
? `${hints.join('. ')}. Query examples:\n- Classes: SELECT ?c ?name WHERE { ?c a otx:Class ; otx:title ?name }\n- Dependents: SELECT ?dep WHERE { ?dep otx:dependsOn <urn:module:src/lib/store-adapter> }\n- Call graph: SELECT ?caller ?callee WHERE { ?s a otx:MethodCall ; otx:callerSymbol ?caller ; otx:calleeSymbol ?callee }`
|
|
398
422
|
: 'Deep scan completed but triple push failed. Use push manually with the generated triples.',
|
|
399
423
|
};
|
|
400
424
|
}
|