This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

127 lines
3.1 KiB
TypeScript

/**
* Test helper: In-memory knowledge graph builder
*
* Provides a convenient API for constructing test graphs
* without touching the filesystem or LadybugDB.
*/
import { createKnowledgeGraph } from '../../src/core/graph/graph.js';
import type { KnowledgeGraph, NodeLabel, RelationshipType } from '../../src/core/graph/types.js';
export interface TestNodeInput {
id: string;
label: NodeLabel;
name: string;
filePath: string;
startLine?: number;
endLine?: number;
isExported?: boolean;
extra?: Record<string, any>;
}
export interface TestRelInput {
sourceId: string;
targetId: string;
type: RelationshipType;
confidence?: number;
reason?: string;
step?: number;
}
/**
* Build a test graph from simple input arrays.
*/
export function buildTestGraph(
nodes: TestNodeInput[],
relationships: TestRelInput[] = [],
): KnowledgeGraph {
const graph = createKnowledgeGraph();
for (const n of nodes) {
graph.addNode({
id: n.id,
label: n.label,
properties: {
name: n.name,
filePath: n.filePath,
startLine: n.startLine,
endLine: n.endLine,
isExported: n.isExported,
...n.extra,
},
});
}
for (const r of relationships) {
graph.addRelationship({
id: `${r.sourceId}-${r.type}-${r.targetId}`,
sourceId: r.sourceId,
targetId: r.targetId,
type: r.type,
confidence: r.confidence ?? 1.0,
reason: r.reason ?? '',
step: r.step,
});
}
return graph;
}
/**
* Create a minimal graph with a few files, functions, and relationships.
* Useful as a baseline for integration tests.
*/
export function createMinimalTestGraph(): KnowledgeGraph {
return buildTestGraph(
[
{ id: 'File:src/index.ts', label: 'File', name: 'index.ts', filePath: 'src/index.ts' },
{ id: 'File:src/utils.ts', label: 'File', name: 'utils.ts', filePath: 'src/utils.ts' },
{
id: 'Function:src/index.ts:main:1',
label: 'Function',
name: 'main',
filePath: 'src/index.ts',
startLine: 1,
endLine: 10,
isExported: true,
},
{
id: 'Function:src/utils.ts:helper:1',
label: 'Function',
name: 'helper',
filePath: 'src/utils.ts',
startLine: 1,
endLine: 5,
isExported: true,
},
{
id: 'Class:src/index.ts:App:12',
label: 'Class',
name: 'App',
filePath: 'src/index.ts',
startLine: 12,
endLine: 30,
isExported: true,
},
{ id: 'Folder:src', label: 'Folder', name: 'src', filePath: 'src' },
],
[
{
sourceId: 'Function:src/index.ts:main:1',
targetId: 'Function:src/utils.ts:helper:1',
type: 'CALLS',
},
{
sourceId: 'Function:src/index.ts:main:1',
targetId: 'Class:src/index.ts:App:12',
type: 'CALLS',
},
{ sourceId: 'File:src/index.ts', targetId: 'Function:src/index.ts:main:1', type: 'CONTAINS' },
{
sourceId: 'File:src/utils.ts',
targetId: 'Function:src/utils.ts:helper:1',
type: 'CONTAINS',
},
],
);
}