mirror of
https://github.com/proffesor-for-testing/agentic-qe.git
synced 2026-09-19 08:45:47 +08:00
9fd18ed00a
Consolidate C4 diagram generation onto a single engine and expose it to users via CLI and MCP, with a deterministic confidence gate and real Knowledge-Graph-derived relationships. - Consolidation (C1/C6): C4ModelService is the single render/analyze/store engine; the bridge delegates and FAILS LOUD on a render error instead of silently degrading. Duplicate inline generators removed. - C2: real component relationships from the Knowledge Graph (AST import/call edges) replace the naming heuristic; project-scoped via a new KG basePath so repos outside cwd don't trip the path-traversal guard. - C3: deterministic confidence gate (high/medium/low + reasons) on every diagram — surfaces the detector's known limits instead of hiding them. - C4/C5: `aqe code c4` CLI + `qe/code/c4` MCP tool (generate/search), verified at MCP-CLI parity and through the protocol-server bridge. - Search: generate persists embeddings (opt-in `enableC4Embeddings`, on for MCP) so `qe/code/c4 search` returns hits in the standard flow. - Fixed pre-existing lint in touched files (require->import, unused catches). Docs: ADR-112 + docs/guides/c4-architecture-diagrams.md. tsc + lint clean; C4 surface fully green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
55 lines
2.5 KiB
TypeScript
55 lines
2.5 KiB
TypeScript
/**
|
|
* ADR-112 — qe/code/c4 is actually SERVED through the protocol-server bridge.
|
|
*
|
|
* The protocol server registers QE_TOOLS via registerMissingQETools(). This
|
|
* proves the new tool reaches that path with a definition + working handler
|
|
* (CLAUDE.md: MCP fixes must be verified through the server path, not just the
|
|
* in-process tool class).
|
|
*/
|
|
|
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
import * as fs from 'fs';
|
|
import * as os from 'os';
|
|
import * as path from 'path';
|
|
import { registerMissingQETools } from '../../../src/mcp/qe-tool-bridge';
|
|
|
|
interface CapturedEntry {
|
|
definition: { name: string; description?: string; parameters?: unknown[] };
|
|
handler: (params: Record<string, unknown>) => Promise<unknown>;
|
|
}
|
|
|
|
let tmp: string;
|
|
beforeEach(() => {
|
|
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'c4-bridge-'));
|
|
fs.writeFileSync(path.join(tmp, 'package.json'), JSON.stringify({ name: 'svc', dependencies: { pg: '^8.0.0' } }));
|
|
fs.mkdirSync(path.join(tmp, 'src', 'services'), { recursive: true });
|
|
fs.writeFileSync(path.join(tmp, 'src', 'services', 'a.ts'), 'export class A {}\n');
|
|
});
|
|
afterEach(() => fs.rmSync(tmp, { recursive: true, force: true }));
|
|
|
|
describe('qe/code/c4 served via the QE tool bridge', () => {
|
|
it('should_register_qe_code_c4_with_a_definition_and_handler', async () => {
|
|
const entries: CapturedEntry[] = [];
|
|
registerMissingQETools((e) => entries.push(e as unknown as CapturedEntry));
|
|
|
|
const c4 = entries.find((e) => e.definition.name === 'qe/code/c4');
|
|
expect(c4, 'qe/code/c4 must be bridged into the server').toBeDefined();
|
|
expect(typeof c4!.handler).toBe('function');
|
|
expect(c4!.definition.parameters?.length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it('should_execute_generate_through_the_bridged_handler', async () => {
|
|
const entries: CapturedEntry[] = [];
|
|
registerMissingQETools((e) => entries.push(e as unknown as CapturedEntry));
|
|
const c4 = entries.find((e) => e.definition.name === 'qe/code/c4')!;
|
|
|
|
const out = (await c4.handler({ action: 'generate', projectPath: tmp, level: 'context' })) as {
|
|
success?: boolean; data?: { generateResult?: { diagrams?: { context?: string } } };
|
|
generateResult?: { diagrams?: { context?: string } };
|
|
};
|
|
// The bridge may unwrap ToolResult; accept either shape.
|
|
const ctxDiagram = out?.data?.generateResult?.diagrams?.context ?? out?.generateResult?.diagrams?.context;
|
|
expect(ctxDiagram, JSON.stringify(out).slice(0, 300)).toContain('C4Context');
|
|
});
|
|
});
|