aiwg
Version:
Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo
51 lines • 1.89 kB
JavaScript
/**
* Graph Backend Abstraction
*
* Swappable interface for graph storage and traversal. The default
* JsonGraphBackend wraps the existing DependencyGraph type with zero
* additional dependencies. Optional backends (graphology, SQLite) provide
* richer traversal and persistence at the cost of extra packages.
*
* @implements #727
* @source @src/artifacts/types.ts
* @tests @test/unit/artifacts/graph-backend.test.ts
*/
/**
* Create a graph backend instance.
*
* The json backend is always available. graphology and sqlite require
* their respective optional dependencies to be installed.
*
* @param type - Backend type identifier
* @returns A new GraphBackend instance
* @throws Error if the requested backend's dependencies are not installed
*/
export async function createGraphBackend(type = 'json') {
switch (type) {
case 'json': {
const { JsonGraphBackend } = await import('./backends/json-backend.js');
return new JsonGraphBackend();
}
case 'graphology': {
try {
const { GraphologyBackend } = await import('./backends/graphology-backend.js');
return GraphologyBackend.create();
}
catch {
throw new Error('graphology backend requires: npm install graphology graphology-types graphology-operators graphology-traversal');
}
}
case 'sqlite': {
try {
const { SqliteGraphBackend } = await import('./backends/sqlite-backend.js');
return new SqliteGraphBackend();
}
catch {
throw new Error('sqlite backend requires: npm install better-sqlite3 @types/better-sqlite3');
}
}
default:
throw new Error(`Unknown graph backend: ${type}`);
}
}
//# sourceMappingURL=graph-backend.js.map