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

82 lines
2.8 KiB
TypeScript

import { describe, it, expect, beforeAll } from 'vitest';
import path from 'path';
import {
FIXTURES,
getRelationships,
getNodesByLabel,
getNodesByLabelFull,
runPipelineFromRepo,
type PipelineResult,
} from './helpers.js';
describe('Python @mcp.tool() detection', () => {
let result: PipelineResult;
beforeAll(async () => {
result = await runPipelineFromRepo(path.join(FIXTURES, 'python-mcp-tools'), () => {});
}, 60000);
it('creates Tool nodes for @mcp.tool() decorated functions', () => {
const tools = getNodesByLabel(result, 'Tool');
expect(tools).toContain('get_weather');
expect(tools).toContain('search_docs');
expect(tools).toContain('explicit_tool');
});
it('uses handler functions for HANDLES_TOOL edges', () => {
const edges = getRelationships(result, 'HANDLES_TOOL');
expect(edges.length).toBeGreaterThanOrEqual(2);
const weatherEdge = edges.find((e) => e.target === 'get_weather');
expect(weatherEdge).toBeDefined();
expect(weatherEdge!.source).toBe('get_weather');
expect(weatherEdge!.sourceLabel).toBe('Function');
const searchEdge = edges.find((e) => e.target === 'search_docs');
expect(searchEdge).toBeDefined();
expect(searchEdge!.source).toBe('search_docs');
expect(searchEdge!.sourceLabel).toBe('Function');
});
it('detects exactly 3 tools from the fixture', () => {
const tools = getNodesByLabel(result, 'Tool');
expect(tools).toHaveLength(3);
});
it('uses Python handler docstrings as tool descriptions', () => {
const tools = getNodesByLabelFull(result, 'Tool');
const descriptions = new Map(tools.map((tool) => [tool.name, tool.properties.description]));
expect(descriptions.get('get_weather')).toBe('Get weather for a city.');
expect(descriptions.get('search_docs')).toBe('Search documentation.');
expect(descriptions.get('explicit_tool')).toBe('Explicit description');
});
it('links each tool only to flows rooted at its handler', () => {
const edges = getRelationships(result, 'ENTRY_POINT_OF').filter(
(e) => e.sourceLabel === 'Tool' && e.targetLabel === 'Process',
);
const flowsByTool = new Map<string, string[]>();
for (const edge of edges) {
let flows = flowsByTool.get(edge.source);
if (flows === undefined) {
flows = [];
flowsByTool.set(edge.source, flows);
}
flows.push(edge.target);
}
const weatherFlows = flowsByTool.get('get_weather') ?? [];
const searchFlows = flowsByTool.get('search_docs') ?? [];
expect(weatherFlows).toHaveLength(1);
expect(weatherFlows[0]).toContain('Get_weather');
expect(weatherFlows[0]).toContain('_format_weather');
expect(searchFlows).toHaveLength(1);
expect(searchFlows[0]).toContain('Search_docs');
expect(searchFlows[0]).toContain('_rank_docs');
expect(weatherFlows).not.toEqual(searchFlows);
});
});