@yasserkhanorg/e2e-agents 1.8.4 → 1.9.5
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/README.md +95 -8
- package/dist/adapters/cypress.d.ts +10 -0
- package/dist/adapters/cypress.d.ts.map +1 -0
- package/dist/adapters/cypress.js +86 -0
- package/dist/adapters/framework_adapter.d.ts +41 -0
- package/dist/adapters/framework_adapter.d.ts.map +1 -0
- package/dist/adapters/framework_adapter.js +152 -0
- package/dist/adapters/playwright.d.ts +10 -0
- package/dist/adapters/playwright.d.ts.map +1 -0
- package/dist/adapters/playwright.js +86 -0
- package/dist/adapters/pytest.d.ts +10 -0
- package/dist/adapters/pytest.d.ts.map +1 -0
- package/dist/adapters/pytest.js +96 -0
- package/dist/adapters/supertest.d.ts +12 -0
- package/dist/adapters/supertest.d.ts.map +1 -0
- package/dist/adapters/supertest.js +85 -0
- package/dist/agent/config.d.ts +1 -1
- package/dist/agent/config.d.ts.map +1 -1
- package/dist/agent/git.d.ts +1 -0
- package/dist/agent/git.d.ts.map +1 -1
- package/dist/agent/git.js +3 -0
- package/dist/agentic/fix_loop.d.ts.map +1 -1
- package/dist/agentic/fix_loop.js +5 -4
- package/dist/agentic/runner.d.ts +2 -0
- package/dist/agentic/runner.d.ts.map +1 -1
- package/dist/agentic/runner.js +15 -12
- package/dist/agents/cross-impact.d.ts.map +1 -1
- package/dist/agents/cross-impact.js +6 -1
- package/dist/agents/executor.d.ts.map +1 -1
- package/dist/agents/executor.js +6 -1
- package/dist/agents/strategist.d.ts.map +1 -1
- package/dist/agents/strategist.js +6 -1
- package/dist/agents/test-designer.d.ts.map +1 -1
- package/dist/agents/test-designer.js +6 -1
- package/dist/anthropic_provider.d.ts.map +1 -1
- package/dist/anthropic_provider.js +1 -0
- package/dist/base_provider.d.ts +56 -0
- package/dist/base_provider.d.ts.map +1 -1
- package/dist/base_provider.js +123 -1
- package/dist/budget_ledger.d.ts +28 -0
- package/dist/budget_ledger.d.ts.map +1 -0
- package/dist/budget_ledger.js +62 -0
- package/dist/cache/cached_provider.d.ts +45 -0
- package/dist/cache/cached_provider.d.ts.map +1 -0
- package/dist/cache/cached_provider.js +88 -0
- package/dist/cache/response_cache.d.ts +79 -0
- package/dist/cache/response_cache.d.ts.map +1 -0
- package/dist/cache/response_cache.js +177 -0
- package/dist/cli/commands/bootstrap.d.ts +3 -0
- package/dist/cli/commands/bootstrap.d.ts.map +1 -0
- package/dist/cli/commands/bootstrap.js +109 -0
- package/dist/cli/commands/cost_report.d.ts +3 -0
- package/dist/cli/commands/cost_report.d.ts.map +1 -0
- package/dist/cli/commands/cost_report.js +115 -0
- package/dist/cli/commands/crew.d.ts.map +1 -1
- package/dist/cli/commands/crew.js +118 -1
- package/dist/cli/commands/gate.d.ts +3 -0
- package/dist/cli/commands/gate.d.ts.map +1 -0
- package/dist/cli/commands/gate.js +86 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +7 -62
- package/dist/cli/commands/plan_crew.d.ts.map +1 -1
- package/dist/cli/commands/plan_crew.js +33 -21
- package/dist/cli/commands/train.d.ts.map +1 -1
- package/dist/cli/commands/train.js +16 -21
- package/dist/cli/defaults.d.ts +35 -0
- package/dist/cli/defaults.d.ts.map +1 -0
- package/dist/cli/defaults.js +125 -0
- package/dist/cli/errors.d.ts +27 -0
- package/dist/cli/errors.d.ts.map +1 -0
- package/dist/cli/errors.js +57 -0
- package/dist/cli/parse_args.d.ts.map +1 -1
- package/dist/cli/parse_args.js +24 -2
- package/dist/cli/types.d.ts +7 -1
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli.js +47 -2
- package/dist/crew/context.d.ts +15 -0
- package/dist/crew/context.d.ts.map +1 -1
- package/dist/crew/orchestrator.d.ts +14 -0
- package/dist/crew/orchestrator.d.ts.map +1 -1
- package/dist/crew/orchestrator.js +162 -4
- package/dist/crew/protocol.d.ts +13 -0
- package/dist/crew/protocol.d.ts.map +1 -1
- package/dist/crew/provider.d.ts +15 -1
- package/dist/crew/provider.d.ts.map +1 -1
- package/dist/crew/provider.js +24 -4
- package/dist/custom_provider.d.ts.map +1 -1
- package/dist/custom_provider.js +1 -0
- package/dist/engine/diff_loader.d.ts.map +1 -1
- package/dist/engine/diff_loader.js +3 -14
- package/dist/engine/impact_engine.d.ts.map +1 -1
- package/dist/engine/impact_engine.js +9 -23
- package/dist/esm/adapters/cypress.js +49 -0
- package/dist/esm/adapters/framework_adapter.js +114 -0
- package/dist/esm/adapters/playwright.js +49 -0
- package/dist/esm/adapters/pytest.js +59 -0
- package/dist/esm/adapters/supertest.js +48 -0
- package/dist/esm/agent/git.js +3 -1
- package/dist/esm/agentic/fix_loop.js +5 -4
- package/dist/esm/agentic/runner.js +15 -12
- package/dist/esm/agents/cross-impact.js +6 -1
- package/dist/esm/agents/executor.js +6 -1
- package/dist/esm/agents/strategist.js +6 -1
- package/dist/esm/agents/test-designer.js +6 -1
- package/dist/esm/anthropic_provider.js +1 -0
- package/dist/esm/base_provider.js +121 -0
- package/dist/esm/budget_ledger.js +58 -0
- package/dist/esm/cache/cached_provider.js +82 -0
- package/dist/esm/cache/response_cache.js +140 -0
- package/dist/esm/cli/commands/bootstrap.js +106 -0
- package/dist/esm/cli/commands/cost_report.js +112 -0
- package/dist/esm/cli/commands/crew.js +118 -1
- package/dist/esm/cli/commands/gate.js +83 -0
- package/dist/esm/cli/commands/init.js +3 -58
- package/dist/esm/cli/commands/plan_crew.js +33 -21
- package/dist/esm/cli/commands/train.js +16 -21
- package/dist/esm/cli/defaults.js +118 -0
- package/dist/esm/cli/errors.js +52 -0
- package/dist/esm/cli/parse_args.js +24 -2
- package/dist/esm/cli.js +47 -2
- package/dist/esm/crew/orchestrator.js +162 -4
- package/dist/esm/crew/provider.js +24 -4
- package/dist/esm/custom_provider.js +1 -0
- package/dist/esm/engine/diff_loader.js +1 -12
- package/dist/esm/engine/impact_engine.js +9 -23
- package/dist/esm/index.js +21 -0
- package/dist/esm/knowledge/cluster_utils.js +60 -0
- package/dist/esm/knowledge/kg_bridge.js +381 -0
- package/dist/esm/knowledge/kg_types.js +3 -0
- package/dist/esm/knowledge/route_families.js +89 -0
- package/dist/esm/mcp-server.js +2 -4
- package/dist/esm/metrics/prometheus.js +149 -0
- package/dist/esm/model_router.js +59 -0
- package/dist/esm/ollama_provider.js +1 -0
- package/dist/esm/openai_provider.js +1 -0
- package/dist/esm/pipeline/orchestrator.js +6 -12
- package/dist/esm/pipeline/stage0_preprocess.js +12 -19
- package/dist/esm/pipeline/stage2_coverage.js +1 -0
- package/dist/esm/pipeline/stage3_generation.js +1 -0
- package/dist/esm/progress.js +112 -0
- package/dist/esm/prompts/coverage.js +7 -24
- package/dist/esm/prompts/cross-impact.js +3 -21
- package/dist/esm/prompts/generation.js +158 -36
- package/dist/esm/prompts/generation_profile.js +147 -0
- package/dist/esm/prompts/heal.js +33 -15
- package/dist/esm/prompts/impact.js +3 -22
- package/dist/esm/prompts/json_extract.js +36 -0
- package/dist/esm/prompts/strategist.js +2 -20
- package/dist/esm/prompts/test-designer.js +6 -21
- package/dist/esm/provider_factory.js +6 -4
- package/dist/esm/reporters/junit.js +86 -0
- package/dist/esm/reporters/reporter.js +3 -0
- package/dist/esm/reporters/sarif.js +131 -0
- package/dist/esm/resilience/circuit_breaker.js +78 -0
- package/dist/esm/resilience/retry.js +56 -0
- package/dist/esm/sanitize.js +66 -0
- package/dist/esm/training/kg_scanner.js +115 -0
- package/dist/esm/training/scanner.js +27 -34
- package/dist/esm/version.js +33 -0
- package/dist/index.d.ts +21 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -1
- package/dist/knowledge/cluster_utils.d.ts +28 -0
- package/dist/knowledge/cluster_utils.d.ts.map +1 -0
- package/dist/knowledge/cluster_utils.js +67 -0
- package/dist/knowledge/kg_bridge.d.ts +31 -0
- package/dist/knowledge/kg_bridge.d.ts.map +1 -0
- package/dist/knowledge/kg_bridge.js +388 -0
- package/dist/knowledge/kg_types.d.ts +75 -0
- package/dist/knowledge/kg_types.d.ts.map +1 -0
- package/dist/knowledge/kg_types.js +4 -0
- package/dist/knowledge/route_families.d.ts +18 -0
- package/dist/knowledge/route_families.d.ts.map +1 -1
- package/dist/knowledge/route_families.js +91 -0
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +2 -4
- package/dist/metrics/prometheus.d.ts +37 -0
- package/dist/metrics/prometheus.d.ts.map +1 -0
- package/dist/metrics/prometheus.js +153 -0
- package/dist/model_router.d.ts +28 -0
- package/dist/model_router.d.ts.map +1 -0
- package/dist/model_router.js +63 -0
- package/dist/ollama_provider.d.ts.map +1 -1
- package/dist/ollama_provider.js +1 -0
- package/dist/openai_provider.d.ts.map +1 -1
- package/dist/openai_provider.js +1 -0
- package/dist/pipeline/orchestrator.d.ts +2 -0
- package/dist/pipeline/orchestrator.d.ts.map +1 -1
- package/dist/pipeline/orchestrator.js +6 -12
- package/dist/pipeline/stage0_preprocess.d.ts.map +1 -1
- package/dist/pipeline/stage0_preprocess.js +11 -18
- package/dist/pipeline/stage2_coverage.d.ts +2 -0
- package/dist/pipeline/stage2_coverage.d.ts.map +1 -1
- package/dist/pipeline/stage2_coverage.js +1 -0
- package/dist/pipeline/stage3_generation.d.ts +2 -0
- package/dist/pipeline/stage3_generation.d.ts.map +1 -1
- package/dist/pipeline/stage3_generation.js +1 -0
- package/dist/pipeline/stage4_heal.d.ts +2 -0
- package/dist/pipeline/stage4_heal.d.ts.map +1 -1
- package/dist/progress.d.ts +22 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +116 -0
- package/dist/prompts/coverage.d.ts +2 -0
- package/dist/prompts/coverage.d.ts.map +1 -1
- package/dist/prompts/coverage.js +7 -24
- package/dist/prompts/cross-impact.d.ts +1 -0
- package/dist/prompts/cross-impact.d.ts.map +1 -1
- package/dist/prompts/cross-impact.js +3 -21
- package/dist/prompts/generation.d.ts +3 -1
- package/dist/prompts/generation.d.ts.map +1 -1
- package/dist/prompts/generation.js +158 -36
- package/dist/prompts/generation_profile.d.ts +29 -0
- package/dist/prompts/generation_profile.d.ts.map +1 -0
- package/dist/prompts/generation_profile.js +151 -0
- package/dist/prompts/heal.d.ts +3 -1
- package/dist/prompts/heal.d.ts.map +1 -1
- package/dist/prompts/heal.js +33 -15
- package/dist/prompts/impact.d.ts +1 -0
- package/dist/prompts/impact.d.ts.map +1 -1
- package/dist/prompts/impact.js +3 -22
- package/dist/prompts/json_extract.d.ts +14 -0
- package/dist/prompts/json_extract.d.ts.map +1 -0
- package/dist/prompts/json_extract.js +39 -0
- package/dist/prompts/strategist.d.ts.map +1 -1
- package/dist/prompts/strategist.js +2 -20
- package/dist/prompts/test-designer.d.ts +2 -0
- package/dist/prompts/test-designer.d.ts.map +1 -1
- package/dist/prompts/test-designer.js +6 -21
- package/dist/provider_factory.d.ts.map +1 -1
- package/dist/provider_factory.js +6 -4
- package/dist/reporters/junit.d.ts +6 -0
- package/dist/reporters/junit.d.ts.map +1 -0
- package/dist/reporters/junit.js +89 -0
- package/dist/reporters/reporter.d.ts +42 -0
- package/dist/reporters/reporter.d.ts.map +1 -0
- package/dist/reporters/reporter.js +4 -0
- package/dist/reporters/sarif.d.ts +7 -0
- package/dist/reporters/sarif.d.ts.map +1 -0
- package/dist/reporters/sarif.js +134 -0
- package/dist/resilience/circuit_breaker.d.ts +36 -0
- package/dist/resilience/circuit_breaker.d.ts.map +1 -0
- package/dist/resilience/circuit_breaker.js +82 -0
- package/dist/resilience/retry.d.ts +11 -0
- package/dist/resilience/retry.d.ts.map +1 -0
- package/dist/resilience/retry.js +59 -0
- package/dist/sanitize.d.ts +15 -0
- package/dist/sanitize.d.ts.map +1 -0
- package/dist/sanitize.js +71 -0
- package/dist/training/kg_scanner.d.ts +13 -0
- package/dist/training/kg_scanner.d.ts.map +1 -0
- package/dist/training/kg_scanner.js +118 -0
- package/dist/training/scanner.d.ts +7 -2
- package/dist/training/scanner.d.ts.map +1 -1
- package/dist/training/scanner.js +27 -34
- package/dist/version.d.ts +6 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +36 -0
- package/package.json +7 -2
- package/schemas/route-families.schema.json +31 -1
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
3
|
+
// See LICENSE.txt for license information.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.loadKnowledgeGraph = loadKnowledgeGraph;
|
|
6
|
+
exports.classifyProjectType = classifyProjectType;
|
|
7
|
+
exports.transformKGToFamilies = transformKGToFamilies;
|
|
8
|
+
exports.loadDiffOverlay = loadDiffOverlay;
|
|
9
|
+
exports.diffOverlayToChangedFiles = diffOverlayToChangedFiles;
|
|
10
|
+
/**
|
|
11
|
+
* Bridge between Understand-Anything's knowledge graph and e2e-agents' route families.
|
|
12
|
+
* Transforms KG nodes/edges into RouteFamilyManifest so existing pipeline works unchanged.
|
|
13
|
+
*/
|
|
14
|
+
const fs_1 = require("fs");
|
|
15
|
+
const path_1 = require("path");
|
|
16
|
+
const logger_js_1 = require("../logger.js");
|
|
17
|
+
const cluster_utils_js_1 = require("./cluster_utils.js");
|
|
18
|
+
const UA_DIR = '.understand-anything';
|
|
19
|
+
const KG_FILE = 'knowledge-graph.json';
|
|
20
|
+
const DIFF_FILE = 'diff-overlay.json';
|
|
21
|
+
const FRONTEND_FRAMEWORKS = new Set([
|
|
22
|
+
'react', 'vue', 'angular', 'svelte', 'next', 'nextjs', 'next.js',
|
|
23
|
+
'nuxt', 'nuxtjs', 'gatsby', 'remix', 'astro', 'solid', 'solidjs',
|
|
24
|
+
'preact', 'lit', 'stencil', 'qwik',
|
|
25
|
+
]);
|
|
26
|
+
const BACKEND_FRAMEWORKS = new Set([
|
|
27
|
+
'express', 'fastify', 'koa', 'hapi', 'nest', 'nestjs',
|
|
28
|
+
'django', 'flask', 'fastapi', 'rails', 'spring', 'gin', 'echo', 'fiber',
|
|
29
|
+
'actix', 'axum', 'rocket', 'phoenix', 'laravel',
|
|
30
|
+
]);
|
|
31
|
+
/**
|
|
32
|
+
* Loads the knowledge graph from .understand-anything/knowledge-graph.json
|
|
33
|
+
* or from a custom path when provided.
|
|
34
|
+
*/
|
|
35
|
+
function loadKnowledgeGraph(projectRoot, customPath) {
|
|
36
|
+
const kgPath = customPath || (0, path_1.join)(projectRoot, UA_DIR, KG_FILE);
|
|
37
|
+
if (!(0, fs_1.existsSync)(kgPath)) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const raw = JSON.parse((0, fs_1.readFileSync)(kgPath, 'utf-8'));
|
|
42
|
+
if (!raw.nodes || !Array.isArray(raw.nodes) || !raw.edges || !Array.isArray(raw.edges)) {
|
|
43
|
+
logger_js_1.logger.warn('Knowledge graph missing required nodes/edges arrays');
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
if (!raw.project) {
|
|
47
|
+
logger_js_1.logger.warn('Knowledge graph missing project metadata');
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
// Field-level validation: filter out invalid nodes rather than rejecting the whole graph
|
|
51
|
+
const MAX_STRING_LEN = 1000;
|
|
52
|
+
const validNodes = raw.nodes.filter((node) => {
|
|
53
|
+
if (typeof node.id !== 'string' || typeof node.name !== 'string') {
|
|
54
|
+
logger_js_1.logger.warn(`Dropping KG node with missing/invalid id or name: ${JSON.stringify(node).slice(0, 200)}`);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
if (node.filePath !== undefined) {
|
|
58
|
+
if (typeof node.filePath !== 'string') {
|
|
59
|
+
logger_js_1.logger.warn(`Dropping KG node "${node.id}": filePath is not a string`);
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
if (node.filePath.startsWith('/')) {
|
|
63
|
+
logger_js_1.logger.warn(`Dropping KG node "${node.id}": absolute filePath rejected`);
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (node.filePath.includes('..')) {
|
|
67
|
+
logger_js_1.logger.warn(`Dropping KG node "${node.id}": path traversal in filePath rejected`);
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (node.filePath.includes('\0')) {
|
|
71
|
+
logger_js_1.logger.warn(`Dropping KG node "${node.id}": null byte in filePath rejected`);
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
});
|
|
77
|
+
// Truncate excessively long strings
|
|
78
|
+
for (const node of validNodes) {
|
|
79
|
+
if (node.name.length > MAX_STRING_LEN) {
|
|
80
|
+
node.name = node.name.slice(0, MAX_STRING_LEN);
|
|
81
|
+
}
|
|
82
|
+
if (node.description && node.description.length > MAX_STRING_LEN) {
|
|
83
|
+
node.description = node.description.slice(0, MAX_STRING_LEN);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
raw.nodes = validNodes;
|
|
87
|
+
return raw;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
logger_js_1.logger.warn(`Failed to load knowledge graph: ${error instanceof Error ? error.message : String(error)}`);
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Classifies project type based on KG framework metadata.
|
|
96
|
+
*/
|
|
97
|
+
function classifyProjectType(kg) {
|
|
98
|
+
const frameworks = kg.project.frameworks.map((f) => f.toLowerCase());
|
|
99
|
+
const hasFrontend = frameworks.some((f) => FRONTEND_FRAMEWORKS.has(f));
|
|
100
|
+
const hasBackend = frameworks.some((f) => BACKEND_FRAMEWORKS.has(f));
|
|
101
|
+
if (hasFrontend && hasBackend)
|
|
102
|
+
return 'fullstack';
|
|
103
|
+
if (hasBackend)
|
|
104
|
+
return 'backend';
|
|
105
|
+
return 'frontend';
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Core bridge: transforms KG into a RouteFamilyManifest.
|
|
109
|
+
*
|
|
110
|
+
* Strategy:
|
|
111
|
+
* - Frontend: cluster UI-layer nodes into families by module/component groups
|
|
112
|
+
* - Backend: cluster API-layer nodes, follow calls edges into Service→Data layers
|
|
113
|
+
* - Priority: P0 = high fan-in nodes, P1 = moderate, P2 = leaf/utility
|
|
114
|
+
* - userFlows: derived from KG tour steps referencing family nodes
|
|
115
|
+
*/
|
|
116
|
+
function transformKGToFamilies(kg) {
|
|
117
|
+
const projectType = classifyProjectType(kg);
|
|
118
|
+
const nodeMap = new Map(kg.nodes.map((n) => [n.id, n]));
|
|
119
|
+
const edgesByTarget = groupEdges(kg.edges, 'target');
|
|
120
|
+
// Build clusters based on project type
|
|
121
|
+
const clusters = buildClusters(kg, projectType, nodeMap);
|
|
122
|
+
// Transform clusters into route families
|
|
123
|
+
const families = [];
|
|
124
|
+
for (const [clusterId, nodeIds] of clusters) {
|
|
125
|
+
const nodes = nodeIds.map((id) => nodeMap.get(id)).filter((n) => n !== undefined);
|
|
126
|
+
if (nodes.length === 0)
|
|
127
|
+
continue;
|
|
128
|
+
const family = buildFamilyFromCluster(clusterId, nodes, projectType, nodeMap, edgesByTarget);
|
|
129
|
+
if (family) {
|
|
130
|
+
families.push(family);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Derive userFlows from KG tour steps
|
|
134
|
+
if (kg.tour && kg.tour.length > 0) {
|
|
135
|
+
assignTourFlows(families, kg.tour, nodeMap);
|
|
136
|
+
}
|
|
137
|
+
// Sort by priority (P0 first) then alphabetically
|
|
138
|
+
families.sort((a, b) => {
|
|
139
|
+
const pOrder = { P0: 0, P1: 1, P2: 2 };
|
|
140
|
+
const pa = pOrder[a.priority || 'P2'];
|
|
141
|
+
const pb = pOrder[b.priority || 'P2'];
|
|
142
|
+
if (pa !== pb)
|
|
143
|
+
return pa - pb;
|
|
144
|
+
return a.id.localeCompare(b.id);
|
|
145
|
+
});
|
|
146
|
+
return {
|
|
147
|
+
families,
|
|
148
|
+
source: 'knowledge-graph',
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Loads the diff overlay from .understand-anything/diff-overlay.json
|
|
153
|
+
*/
|
|
154
|
+
function loadDiffOverlay(projectRoot) {
|
|
155
|
+
const overlayPath = (0, path_1.join)(projectRoot, UA_DIR, DIFF_FILE);
|
|
156
|
+
if (!(0, fs_1.existsSync)(overlayPath)) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
const raw = JSON.parse((0, fs_1.readFileSync)(overlayPath, 'utf-8'));
|
|
161
|
+
if (!raw.changes || !Array.isArray(raw.changes)) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
return raw;
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Maps diff overlay changes to file paths using KG node resolution.
|
|
172
|
+
*/
|
|
173
|
+
function diffOverlayToChangedFiles(overlay, kg) {
|
|
174
|
+
const nodeMap = new Map(kg.nodes.map((n) => [n.id, n]));
|
|
175
|
+
const files = new Set();
|
|
176
|
+
for (const change of overlay.changes) {
|
|
177
|
+
// Use filePath from change if available
|
|
178
|
+
if (change.filePath) {
|
|
179
|
+
files.add(change.filePath);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
// Fall back to KG node's filePath
|
|
183
|
+
const node = nodeMap.get(change.nodeId);
|
|
184
|
+
if (node?.filePath) {
|
|
185
|
+
files.add(node.filePath);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return [...files];
|
|
189
|
+
}
|
|
190
|
+
// ---------------------------------------------------------------------------
|
|
191
|
+
// Internal helpers
|
|
192
|
+
// ---------------------------------------------------------------------------
|
|
193
|
+
function groupEdges(edges, key) {
|
|
194
|
+
const map = new Map();
|
|
195
|
+
for (const edge of edges) {
|
|
196
|
+
const val = edge[key];
|
|
197
|
+
if (!map.has(val))
|
|
198
|
+
map.set(val, []);
|
|
199
|
+
map.get(val).push(edge);
|
|
200
|
+
}
|
|
201
|
+
return map;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Build clusters of related nodes to become families.
|
|
205
|
+
* Frontend: group by route/page/component modules
|
|
206
|
+
* Backend: group by API endpoint handlers + their service dependencies
|
|
207
|
+
*/
|
|
208
|
+
function buildClusters(kg, projectType, nodeMap) {
|
|
209
|
+
const clusters = new Map();
|
|
210
|
+
// Strategy 1: Use KG layers to find anchor nodes
|
|
211
|
+
const layerMap = new Map();
|
|
212
|
+
if (kg.layers) {
|
|
213
|
+
for (const layer of kg.layers) {
|
|
214
|
+
layerMap.set(layer.name, new Set(layer.nodeIds));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// Strategy 2: Group by module/component/route nodes
|
|
218
|
+
const anchorKinds = projectType === 'backend'
|
|
219
|
+
? new Set(['module', 'route', 'class', 'function'])
|
|
220
|
+
: new Set(['component', 'route', 'module', 'class']);
|
|
221
|
+
const anchorLayers = projectType === 'backend'
|
|
222
|
+
? new Set(['api', 'service'])
|
|
223
|
+
: new Set(['ui']);
|
|
224
|
+
for (const node of kg.nodes) {
|
|
225
|
+
// Skip test/infra nodes as cluster anchors
|
|
226
|
+
if (node.layer === 'test' || node.layer === 'infra')
|
|
227
|
+
continue;
|
|
228
|
+
const isAnchorKind = anchorKinds.has(node.kind);
|
|
229
|
+
const isAnchorLayer = !node.layer || anchorLayers.has(node.layer);
|
|
230
|
+
if (!isAnchorKind || !isAnchorLayer)
|
|
231
|
+
continue;
|
|
232
|
+
// Derive cluster ID from node path or name
|
|
233
|
+
const clusterId = (0, cluster_utils_js_1.deriveClusterId)(node);
|
|
234
|
+
if (!clusterId)
|
|
235
|
+
continue;
|
|
236
|
+
if (!clusters.has(clusterId)) {
|
|
237
|
+
clusters.set(clusterId, []);
|
|
238
|
+
}
|
|
239
|
+
clusters.get(clusterId).push(node.id);
|
|
240
|
+
}
|
|
241
|
+
// If no clusters found, fall back to file-based grouping
|
|
242
|
+
if (clusters.size === 0) {
|
|
243
|
+
for (const node of kg.nodes) {
|
|
244
|
+
if (!node.filePath || node.layer === 'test' || node.layer === 'infra')
|
|
245
|
+
continue;
|
|
246
|
+
const clusterId = (0, cluster_utils_js_1.deriveClusterIdFromPath)(node.filePath);
|
|
247
|
+
if (!clusterId)
|
|
248
|
+
continue;
|
|
249
|
+
if (!clusters.has(clusterId)) {
|
|
250
|
+
clusters.set(clusterId, []);
|
|
251
|
+
}
|
|
252
|
+
clusters.get(clusterId).push(node.id);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return clusters;
|
|
256
|
+
}
|
|
257
|
+
// deriveClusterId and deriveClusterIdFromPath imported from cluster_utils.ts
|
|
258
|
+
function computePriority(nodes) {
|
|
259
|
+
const maxFanIn = Math.max(...nodes.map((n) => n.fanIn || 0));
|
|
260
|
+
if (maxFanIn >= 10)
|
|
261
|
+
return 'P0';
|
|
262
|
+
if (maxFanIn >= 4)
|
|
263
|
+
return 'P1';
|
|
264
|
+
return 'P2';
|
|
265
|
+
}
|
|
266
|
+
function buildFamilyFromCluster(clusterId, nodes, projectType, nodeMap, edgesByTarget) {
|
|
267
|
+
const webappPaths = new Set();
|
|
268
|
+
const serverPaths = new Set();
|
|
269
|
+
const routes = [];
|
|
270
|
+
const apiEndpoints = [];
|
|
271
|
+
for (const node of nodes) {
|
|
272
|
+
if (!node.filePath)
|
|
273
|
+
continue;
|
|
274
|
+
const layer = node.layer;
|
|
275
|
+
if (layer === 'api' || layer === 'service' || layer === 'data') {
|
|
276
|
+
serverPaths.add(`${node.filePath}*`);
|
|
277
|
+
}
|
|
278
|
+
else if (layer === 'ui') {
|
|
279
|
+
webappPaths.add(`${node.filePath}*`);
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
// Auto-assign based on project type
|
|
283
|
+
if (projectType === 'backend') {
|
|
284
|
+
serverPaths.add(`${node.filePath}*`);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
webappPaths.add(`${node.filePath}*`);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// Extract routes from route nodes
|
|
291
|
+
if (node.kind === 'route') {
|
|
292
|
+
const routePath = node.metadata?.path;
|
|
293
|
+
if (routePath) {
|
|
294
|
+
routes.push(routePath);
|
|
295
|
+
// Extract API endpoint info
|
|
296
|
+
const method = node.metadata?.method || 'GET';
|
|
297
|
+
apiEndpoints.push({ method: method.toUpperCase(), path: routePath, description: node.description });
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
routes.push(`/${clusterId}`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// If no routes extracted, generate a default
|
|
305
|
+
if (routes.length === 0) {
|
|
306
|
+
routes.push(`/${clusterId}`);
|
|
307
|
+
}
|
|
308
|
+
// Collect related test file paths by following 'tests' edges
|
|
309
|
+
const specDirs = new Set();
|
|
310
|
+
for (const node of nodes) {
|
|
311
|
+
const testEdges = (edgesByTarget.get(node.id) || []).filter((e) => e.type === 'tests');
|
|
312
|
+
for (const edge of testEdges) {
|
|
313
|
+
const testNode = nodeMap.get(edge.source);
|
|
314
|
+
if (testNode?.filePath) {
|
|
315
|
+
// Use directory of test file
|
|
316
|
+
const dir = testNode.filePath.replace(/\\/g, '/').split('/').slice(0, -1).join('/');
|
|
317
|
+
if (dir)
|
|
318
|
+
specDirs.add(`${dir}/*`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
const priority = computePriority(nodes);
|
|
323
|
+
// Determine test type based on content
|
|
324
|
+
let testType;
|
|
325
|
+
if (webappPaths.size > 0 && serverPaths.size > 0) {
|
|
326
|
+
testType = 'both';
|
|
327
|
+
}
|
|
328
|
+
else if (serverPaths.size > 0 && apiEndpoints.length > 0) {
|
|
329
|
+
testType = 'api';
|
|
330
|
+
}
|
|
331
|
+
else if (webappPaths.size > 0) {
|
|
332
|
+
testType = 'ui';
|
|
333
|
+
}
|
|
334
|
+
const family = {
|
|
335
|
+
id: clusterId,
|
|
336
|
+
routes: [...new Set(routes)],
|
|
337
|
+
priority,
|
|
338
|
+
};
|
|
339
|
+
if (webappPaths.size > 0)
|
|
340
|
+
family.webappPaths = [...webappPaths];
|
|
341
|
+
if (serverPaths.size > 0)
|
|
342
|
+
family.serverPaths = [...serverPaths];
|
|
343
|
+
if (specDirs.size > 0)
|
|
344
|
+
family.specDirs = [...specDirs];
|
|
345
|
+
if (apiEndpoints.length > 0)
|
|
346
|
+
family.apiEndpoints = apiEndpoints;
|
|
347
|
+
if (testType)
|
|
348
|
+
family.testType = testType;
|
|
349
|
+
return family;
|
|
350
|
+
}
|
|
351
|
+
function assignTourFlows(families, tour, nodeMap) {
|
|
352
|
+
if (!tour)
|
|
353
|
+
return;
|
|
354
|
+
// Build a map of nodeId → family for quick lookup
|
|
355
|
+
const nodeToFamily = new Map();
|
|
356
|
+
for (const family of families) {
|
|
357
|
+
// Resolve family nodes from paths
|
|
358
|
+
for (const [nodeId, node] of nodeMap) {
|
|
359
|
+
if (!node.filePath)
|
|
360
|
+
continue;
|
|
361
|
+
const matchesPaths = [
|
|
362
|
+
...(family.webappPaths || []),
|
|
363
|
+
...(family.serverPaths || []),
|
|
364
|
+
];
|
|
365
|
+
for (const pattern of matchesPaths) {
|
|
366
|
+
const prefix = pattern.replace(/\*$/, '');
|
|
367
|
+
if (node.filePath.startsWith(prefix)) {
|
|
368
|
+
nodeToFamily.set(nodeId, family);
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
// Assign tour steps as user flows
|
|
375
|
+
for (const step of tour.sort((a, b) => a.order - b.order)) {
|
|
376
|
+
for (const nodeId of step.nodeIds) {
|
|
377
|
+
const family = nodeToFamily.get(nodeId);
|
|
378
|
+
if (family) {
|
|
379
|
+
if (!family.userFlows)
|
|
380
|
+
family.userFlows = [];
|
|
381
|
+
const flowDesc = `${step.title}: ${step.description}`;
|
|
382
|
+
if (!family.userFlows.includes(flowDesc)) {
|
|
383
|
+
family.userFlows.push(flowDesc);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript interfaces matching Understand-Anything's knowledge-graph.json schema.
|
|
3
|
+
* These types enable the bridge between UA's knowledge graph and e2e-agents' route families.
|
|
4
|
+
*/
|
|
5
|
+
export type KGNodeKind = 'file' | 'function' | 'class' | 'module' | 'concept' | 'component' | 'route' | 'hook' | 'type' | 'variable';
|
|
6
|
+
export type KGEdgeType = 'imports' | 'exports' | 'calls' | 'implements' | 'extends' | 'uses' | 'renders' | 'routes_to' | 'provides' | 'consumes' | 'tests' | 'configures' | 'depends_on' | 'contains' | 'composed_of' | 'handles' | 'emits' | 'listens_to';
|
|
7
|
+
export type KGLayerName = 'ui' | 'api' | 'service' | 'data' | 'config' | 'test' | 'infra' | 'shared';
|
|
8
|
+
export interface KGNode {
|
|
9
|
+
id: string;
|
|
10
|
+
kind: KGNodeKind;
|
|
11
|
+
name: string;
|
|
12
|
+
filePath?: string;
|
|
13
|
+
layer?: KGLayerName;
|
|
14
|
+
description?: string;
|
|
15
|
+
tags?: string[];
|
|
16
|
+
/** Fan-in: number of other nodes referencing this one */
|
|
17
|
+
fanIn?: number;
|
|
18
|
+
/** Fan-out: number of nodes this one references */
|
|
19
|
+
fanOut?: number;
|
|
20
|
+
metadata?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
export interface KGEdge {
|
|
23
|
+
source: string;
|
|
24
|
+
target: string;
|
|
25
|
+
type: KGEdgeType;
|
|
26
|
+
weight?: number;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
export interface KGLayer {
|
|
30
|
+
name: KGLayerName;
|
|
31
|
+
nodeIds: string[];
|
|
32
|
+
description?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface KGTourStep {
|
|
35
|
+
id: string;
|
|
36
|
+
title: string;
|
|
37
|
+
description: string;
|
|
38
|
+
nodeIds: string[];
|
|
39
|
+
order: number;
|
|
40
|
+
}
|
|
41
|
+
export interface KGProject {
|
|
42
|
+
name: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
frameworks: string[];
|
|
45
|
+
languages: string[];
|
|
46
|
+
entryPoints?: string[];
|
|
47
|
+
rootDir?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface KnowledgeGraph {
|
|
50
|
+
version: string;
|
|
51
|
+
project: KGProject;
|
|
52
|
+
nodes: KGNode[];
|
|
53
|
+
edges: KGEdge[];
|
|
54
|
+
layers?: KGLayer[];
|
|
55
|
+
tour?: KGTourStep[];
|
|
56
|
+
}
|
|
57
|
+
export interface DiffOverlayChange {
|
|
58
|
+
nodeId: string;
|
|
59
|
+
changeType: 'added' | 'modified' | 'removed';
|
|
60
|
+
filePath?: string;
|
|
61
|
+
description?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface DiffOverlay {
|
|
64
|
+
version: string;
|
|
65
|
+
baseSha?: string;
|
|
66
|
+
headSha?: string;
|
|
67
|
+
changes: DiffOverlayChange[];
|
|
68
|
+
affectedEdges?: Array<{
|
|
69
|
+
source: string;
|
|
70
|
+
target: string;
|
|
71
|
+
type: KGEdgeType;
|
|
72
|
+
impact: 'added' | 'modified' | 'removed';
|
|
73
|
+
}>;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=kg_types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kg_types.d.ts","sourceRoot":"","sources":["../../src/knowledge/kg_types.ts"],"names":[],"mappings":"AAGA;;;GAGG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC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lows?: string[];
|
|
12
12
|
}
|
|
13
|
+
export interface ApiEndpoint {
|
|
14
|
+
method: string;
|
|
15
|
+
path: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
}
|
|
18
|
+
export type TestType = 'ui' | 'api' | 'both';
|
|
13
19
|
export interface RouteFamily {
|
|
14
20
|
id: string;
|
|
15
21
|
routes: string[];
|
|
@@ -23,6 +29,8 @@ export interface RouteFamily {
|
|
|
23
29
|
priority?: FeaturePriority;
|
|
24
30
|
userFlows?: string[];
|
|
25
31
|
features?: RouteFeature[];
|
|
32
|
+
apiEndpoints?: ApiEndpoint[];
|
|
33
|
+
testType?: TestType;
|
|
26
34
|
}
|
|
27
35
|
export interface RouteFamilyManifest {
|
|
28
36
|
families: RouteFamily[];
|
|
@@ -66,4 +74,14 @@ export declare function getRoutesForBinding(manifest: RouteFamilyManifest, bindi
|
|
|
66
74
|
feature?: string;
|
|
67
75
|
}): string[];
|
|
68
76
|
export declare function clearManifestCache(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Build heuristic route families from changed files when no manifest exists.
|
|
79
|
+
* Groups files by their top-level directory to create rough family groupings.
|
|
80
|
+
* Results are lower confidence but allow analysis to proceed without training.
|
|
81
|
+
*/
|
|
82
|
+
export declare function buildHeuristicFamilies(changedFiles: string[], testsRoot: string): RouteFamilyManifest;
|
|
83
|
+
/**
|
|
84
|
+
* Serialize a RouteFamilyManifest to clean JSON, stripping empty optional fields.
|
|
85
|
+
*/
|
|
86
|
+
export declare function serializeManifest(manifest: RouteFamilyManifest): string;
|
|
69
87
|
//# sourceMappingURL=route_families.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route_families.d.ts","sourceRoot":"","sources":["../../src/knowledge/route_families.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjD,MAAM,WAAW,YAAY;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CA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AAmB,EAC7B,OAAO,EAAE;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAC,GAC5C,MAAM,EAAE,CAYV;AAED,wBAAgB,mBAAmB,CAC/B,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAC,GAC5C,MAAM,EAAE,CAYV;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,mBAAmB,CAsCrG;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,CAmBvE"}
|
|
@@ -14,6 +14,8 @@ exports.getPriorityForBinding = getPriorityForBinding;
|
|
|
14
14
|
exports.getUserFlowsForBinding = getUserFlowsForBinding;
|
|
15
15
|
exports.getRoutesForBinding = getRoutesForBinding;
|
|
16
16
|
exports.clearManifestCache = clearManifestCache;
|
|
17
|
+
exports.buildHeuristicFamilies = buildHeuristicFamilies;
|
|
18
|
+
exports.serializeManifest = serializeManifest;
|
|
17
19
|
const fs_1 = require("fs");
|
|
18
20
|
const path_1 = require("path");
|
|
19
21
|
const logger_js_1 = require("../logger.js");
|
|
@@ -44,6 +46,17 @@ function matchesGlob(filePath, pattern) {
|
|
|
44
46
|
function matchesAnyPattern(filePath, patterns) {
|
|
45
47
|
return patterns.some((pattern) => matchesGlob(filePath, pattern));
|
|
46
48
|
}
|
|
49
|
+
function validateApiEndpoint(ep) {
|
|
50
|
+
if (!ep || typeof ep !== 'object')
|
|
51
|
+
return null;
|
|
52
|
+
const obj = ep;
|
|
53
|
+
if (typeof obj.method !== 'string' || typeof obj.path !== 'string')
|
|
54
|
+
return null;
|
|
55
|
+
const result = { method: obj.method, path: obj.path };
|
|
56
|
+
if (typeof obj.description === 'string')
|
|
57
|
+
result.description = obj.description;
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
47
60
|
function validateFamily(family) {
|
|
48
61
|
if (!family || typeof family !== 'object') {
|
|
49
62
|
return null;
|
|
@@ -52,6 +65,10 @@ function validateFamily(family) {
|
|
|
52
65
|
if (typeof obj.id !== 'string' || !obj.id.trim()) {
|
|
53
66
|
return null;
|
|
54
67
|
}
|
|
68
|
+
// When testType is 'api', routes may contain API paths like "GET /api/users"
|
|
69
|
+
const testType = (obj.testType === 'ui' || obj.testType === 'api' || obj.testType === 'both')
|
|
70
|
+
? obj.testType
|
|
71
|
+
: undefined;
|
|
55
72
|
if (!Array.isArray(obj.routes) || obj.routes.length === 0) {
|
|
56
73
|
return null;
|
|
57
74
|
}
|
|
@@ -95,6 +112,16 @@ function validateFamily(family) {
|
|
|
95
112
|
.map((f) => validateFeature(f))
|
|
96
113
|
.filter((f) => f !== null);
|
|
97
114
|
}
|
|
115
|
+
if (Array.isArray(obj.apiEndpoints)) {
|
|
116
|
+
const endpoints = obj.apiEndpoints
|
|
117
|
+
.map((ep) => validateApiEndpoint(ep))
|
|
118
|
+
.filter((ep) => ep !== null);
|
|
119
|
+
if (endpoints.length > 0)
|
|
120
|
+
result.apiEndpoints = endpoints;
|
|
121
|
+
}
|
|
122
|
+
if (testType) {
|
|
123
|
+
result.testType = testType;
|
|
124
|
+
}
|
|
98
125
|
return result;
|
|
99
126
|
}
|
|
100
127
|
function validateFeature(feature) {
|
|
@@ -286,3 +313,67 @@ function getRoutesForBinding(manifest, binding) {
|
|
|
286
313
|
function clearManifestCache() {
|
|
287
314
|
manifestCache.clear();
|
|
288
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Build heuristic route families from changed files when no manifest exists.
|
|
318
|
+
* Groups files by their top-level directory to create rough family groupings.
|
|
319
|
+
* Results are lower confidence but allow analysis to proceed without training.
|
|
320
|
+
*/
|
|
321
|
+
function buildHeuristicFamilies(changedFiles, testsRoot) {
|
|
322
|
+
const dirGroups = new Map();
|
|
323
|
+
for (const file of changedFiles) {
|
|
324
|
+
const normalized = file.replace(/\\/g, '/');
|
|
325
|
+
const parts = normalized.split('/');
|
|
326
|
+
// Use the first meaningful directory segment as the family ID
|
|
327
|
+
// Skip common prefixes like 'src/', 'app/', 'lib/'
|
|
328
|
+
const skipDirs = new Set(['src', 'app', 'lib', 'packages', 'components']);
|
|
329
|
+
let familyDir = parts[0] || 'root';
|
|
330
|
+
if (skipDirs.has(familyDir) && parts.length > 1) {
|
|
331
|
+
familyDir = parts[1];
|
|
332
|
+
}
|
|
333
|
+
// Normalize to a clean family name
|
|
334
|
+
familyDir = familyDir.replace(/\.[^.]+$/, ''); // strip file extensions for single files
|
|
335
|
+
if (!dirGroups.has(familyDir)) {
|
|
336
|
+
dirGroups.set(familyDir, []);
|
|
337
|
+
}
|
|
338
|
+
dirGroups.get(familyDir).push(normalized);
|
|
339
|
+
}
|
|
340
|
+
const families = [];
|
|
341
|
+
for (const [dir, files] of dirGroups) {
|
|
342
|
+
families.push({
|
|
343
|
+
id: dir,
|
|
344
|
+
routes: [`/${dir}`],
|
|
345
|
+
webappPaths: files.map((f) => `${f}*`),
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
logger_js_1.logger.info(`Built ${families.length} heuristic families from ${changedFiles.length} changed files (no route-families.json found)`);
|
|
349
|
+
logger_js_1.logger.info('Tip: Run `e2e-ai-agents train` to generate a proper route-families manifest for better accuracy.');
|
|
350
|
+
return {
|
|
351
|
+
families,
|
|
352
|
+
source: 'heuristic',
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Serialize a RouteFamilyManifest to clean JSON, stripping empty optional fields.
|
|
357
|
+
*/
|
|
358
|
+
function serializeManifest(manifest) {
|
|
359
|
+
const output = {
|
|
360
|
+
families: manifest.families.map((f) => {
|
|
361
|
+
const cleaned = { ...f };
|
|
362
|
+
const optionalArrays = [
|
|
363
|
+
'pageObjects', 'components', 'webappPaths', 'serverPaths',
|
|
364
|
+
'specDirs', 'cypressSpecDirs', 'tags', 'userFlows', 'features', 'apiEndpoints',
|
|
365
|
+
];
|
|
366
|
+
for (const key of optionalArrays) {
|
|
367
|
+
if (!cleaned[key] || (Array.isArray(cleaned[key]) && cleaned[key].length === 0)) {
|
|
368
|
+
delete cleaned[key];
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (!cleaned.priority)
|
|
372
|
+
delete cleaned.priority;
|
|
373
|
+
if (!cleaned.testType)
|
|
374
|
+
delete cleaned.testType;
|
|
375
|
+
return cleaned;
|
|
376
|
+
}),
|
|
377
|
+
};
|
|
378
|
+
return JSON.stringify(output, null, 2) + '\n';
|
|
379
|
+
}
|
package/dist/mcp-server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";AAeA,UAAU,IAAI;IACV,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AA4GD;;;GAGG;AACH,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,WAAW,CAAc;gBAErB,QAAQ,GAAE,MAAsB;IAM5C,OAAO,CAAC,WAAW;IAmGnB;;;OAGG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAwB5E,OAAO,CAAC,aAAa;IA6BrB,OAAO,CAAC,QAAQ;IAmBhB,OAAO,CAAC,SAAS;IAwCjB,OAAO,CAAC,QAAQ;IAyDhB,OAAO,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRo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,CACtC,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE;IAAC,EAAE,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAC,GAC3E,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAmEzC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,GAAE,MAAsB,GAAG,IAAI,CAmCvE;AAMD,eAAe,kBAAkB,CAAC"}
|
package/dist/mcp-server.js
CHANGED
|
@@ -377,8 +377,7 @@ class E2EAgentsMCPServer {
|
|
|
377
377
|
if (!validateGitRef(since)) {
|
|
378
378
|
return JSON.stringify({ error: 'Invalid git reference format' });
|
|
379
379
|
}
|
|
380
|
-
|
|
381
|
-
const result = (0, child_process_1.spawnSync)('git', ['diff', '--name-only', '--', `${since}..HEAD`], {
|
|
380
|
+
const result = (0, child_process_1.spawnSync)('git', ['diff', '--name-only', `${since}..HEAD`], {
|
|
382
381
|
cwd: this.repoRoot,
|
|
383
382
|
encoding: 'utf-8',
|
|
384
383
|
timeout: 30000,
|
|
@@ -446,8 +445,7 @@ class E2EAgentsMCPServer {
|
|
|
446
445
|
if (!validateGitRef(since)) {
|
|
447
446
|
return [];
|
|
448
447
|
}
|
|
449
|
-
|
|
450
|
-
const result = (0, child_process_1.spawnSync)('git', ['diff', '--name-only', '--', `${since}..HEAD`], {
|
|
448
|
+
const result = (0, child_process_1.spawnSync)('git', ['diff', '--name-only', `${since}..HEAD`], {
|
|
451
449
|
cwd: this.repoRoot,
|
|
452
450
|
encoding: 'utf-8',
|
|
453
451
|
timeout: 30000,
|