ai-first-cli 1.2.1 → 1.2.3
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/ANALISIS_COMPLETO.md +424 -0
- package/ANALISIS_MEJORAS.md +327 -0
- package/README.es.md +104 -82
- package/README.md +116 -113
- package/TEST_RESULTS.md +198 -0
- package/TEST_RESULTS_COMPARATIVE.md +159 -0
- package/TEST_RESULTS_COMPLETE.md +127 -0
- package/TEST_RESULTS_COMPREHENSIVE.md +208 -0
- package/ai/dependencies.json +15 -0
- package/ai/graph/knowledge-graph.json +4 -2
- package/ai-context/ai_context.md +7 -7
- package/ai-context/ai_rules.md +2 -2
- package/ai-context/architecture.md +17 -17
- package/ai-context/dependencies.json +34 -2
- package/ai-context/entrypoints.md +1 -1
- package/ai-context/graph/knowledge-graph.json +14 -199
- package/ai-context/index-state.json +386 -22
- package/ai-context/modules.json +685 -284
- package/ai-context/project.json +1 -1
- package/ai-context/repo_map.json +5317 -2019
- package/ai-context/repo_map.md +751 -17
- package/ai-context/schema.json +1 -1
- package/ai-context/summary.md +13 -8
- package/ai-context/symbols.json +65349 -5
- package/ai-context/tech_stack.md +4 -3
- package/dist/analyzers/symbols.js +9 -9
- package/dist/analyzers/symbols.js.map +1 -1
- package/dist/commands/ai-first.js +17 -0
- package/dist/commands/ai-first.js.map +1 -1
- package/dist/core/adapters/baseAdapter.d.ts +1 -1
- package/dist/core/adapters/baseAdapter.d.ts.map +1 -1
- package/dist/core/adapters/baseAdapter.js +50 -12
- package/dist/core/adapters/baseAdapter.js.map +1 -1
- package/dist/core/semanticContexts.d.ts.map +1 -1
- package/dist/core/semanticContexts.js +22 -60
- package/dist/core/semanticContexts.js.map +1 -1
- package/homebrew/af.rb +18 -0
- package/install.sh +188 -0
- package/package.json +2 -2
- package/src/analyzers/symbols.ts +9 -9
- package/src/commands/ai-first.ts +19 -1
- package/src/core/adapters/baseAdapter.ts +61 -12
- package/src/core/semanticContexts.ts +24 -66
- package/tests/knowledgeGraph.test.ts +1 -1
- package/tests/phase2-fixes.test.ts +4 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { ensureDir, writeFile, readJsonFile } from "../utils/fileUtils.js";
|
|
4
|
+
import { DEFAULT_ADAPTER, type AnalysisAdapter } from "./adapters/baseAdapter.js";
|
|
4
5
|
|
|
5
6
|
export interface Feature {
|
|
6
7
|
name: string;
|
|
@@ -23,77 +24,31 @@ export interface SemanticContexts {
|
|
|
23
24
|
flows: Flow[];
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
// Use DEFAULT_ADAPTER which has universal patterns for ALL languages/frameworks
|
|
28
|
+
const ADAPTER = DEFAULT_ADAPTER;
|
|
29
|
+
|
|
30
|
+
const CANDIDATE_ROOTS = ADAPTER.featureRoots;
|
|
31
|
+
const IGNORED_FOLDERS = new Set(ADAPTER.ignoredFolders);
|
|
32
|
+
const ENTRYPOINT_PATTERNS = ADAPTER.entrypointPatterns;
|
|
33
|
+
const FLOW_ENTRY_PATTERNS = ADAPTER.flowEntrypointPatterns;
|
|
34
|
+
const FLOW_EXCLUDE = new Set(ADAPTER.flowExcludePatterns);
|
|
35
|
+
|
|
36
|
+
const LAYER_PATTERNS: Record<string, string[]> = {};
|
|
37
|
+
for (const layer of ADAPTER.layerRules) {
|
|
38
|
+
LAYER_PATTERNS[layer.name] = layer.patterns;
|
|
39
|
+
}
|
|
29
40
|
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// 2. Ignore folders - these are technical, not business features
|
|
38
|
-
const IGNORED_FOLDERS = new Set([
|
|
39
|
-
"utils",
|
|
40
|
-
"helpers",
|
|
41
|
-
"types",
|
|
42
|
-
"interfaces",
|
|
43
|
-
"constants",
|
|
44
|
-
"config",
|
|
45
|
-
"dto",
|
|
46
|
-
"common",
|
|
47
|
-
"shared"
|
|
48
|
-
]);
|
|
49
|
-
|
|
50
|
-
// 3. Entrypoint patterns - files that indicate a business feature
|
|
51
|
-
const ENTRYPOINT_PATTERNS = [
|
|
52
|
-
"controller",
|
|
53
|
-
"route",
|
|
54
|
-
"handler",
|
|
55
|
-
"command",
|
|
56
|
-
"service"
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
// 4. Flow-specific patterns
|
|
60
|
-
const FLOW_ENTRY_PATTERNS = [
|
|
61
|
-
"controller", "route", "handler", "command",
|
|
62
|
-
// Frontend patterns
|
|
63
|
-
"page", "screen", "view", "component"
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
// 5. Flow exclusion patterns
|
|
67
|
-
const FLOW_EXCLUDE = new Set([
|
|
68
|
-
"repository", "repo", "utils", "helper", "model", "entity",
|
|
69
|
-
"dto", "type", "interface", "constant", "config"
|
|
70
|
-
]);
|
|
71
|
-
|
|
72
|
-
// 6. Layer detection
|
|
73
|
-
const LAYER_PATTERNS: Record<string, string[]> = {
|
|
74
|
-
api: ["controller", "handler", "route", "router", "api", "endpoint"],
|
|
75
|
-
service: ["service", "services", "usecase", "interactor"],
|
|
76
|
-
data: ["repository", "repo", "dal", "dao", "data", "persistence"],
|
|
77
|
-
domain: ["model", "entity", "schema", "domain"],
|
|
78
|
-
util: ["util", "helper", "lib", "common"]
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const LAYER_PRIORITY: Record<string, number> = {
|
|
82
|
-
api: 1, controller: 1, handler: 1, route: 1, router: 1,
|
|
83
|
-
service: 2, usecase: 2, interactor: 2,
|
|
84
|
-
data: 3, repository: 3, repo: 3, dal: 3, dao: 3, persistence: 3,
|
|
85
|
-
model: 4, entity: 4, domain: 4,
|
|
86
|
-
};
|
|
41
|
+
const LAYER_PRIORITY: Record<string, number> = {};
|
|
42
|
+
for (const layer of ADAPTER.layerRules) {
|
|
43
|
+
for (const pattern of layer.patterns) {
|
|
44
|
+
LAYER_PRIORITY[pattern] = layer.priority;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
87
47
|
|
|
88
48
|
const MAX_FLOW_DEPTH = 5;
|
|
89
49
|
const MAX_FLOW_FILES = 30;
|
|
90
50
|
|
|
91
|
-
|
|
92
|
-
const SOURCE_EXTENSIONS = new Set([
|
|
93
|
-
".ts", ".tsx", ".js", ".jsx", ".py", ".java", ".kt", ".go", ".rs", ".rb", ".php", ".cs", ".vue", ".svelte",
|
|
94
|
-
// Salesforce/Apex
|
|
95
|
-
".cls", ".trigger", ".apex", ".object"
|
|
96
|
-
]);
|
|
51
|
+
const SOURCE_EXTENSIONS = new Set(ADAPTER.supportedExtensions);
|
|
97
52
|
|
|
98
53
|
// ============================================================
|
|
99
54
|
// HELPER FUNCTIONS
|
|
@@ -304,6 +259,9 @@ export function generateFeatures(
|
|
|
304
259
|
// Extract feature name from path - get the last segment
|
|
305
260
|
const featureName = mod.path.split("/").pop() || moduleName;
|
|
306
261
|
|
|
262
|
+
// Skip ignored folders (utils, helpers, types, etc.)
|
|
263
|
+
if (isIgnoredFolder(featureName)) continue;
|
|
264
|
+
|
|
307
265
|
features.push({
|
|
308
266
|
name: featureName,
|
|
309
267
|
path: mod.path,
|
|
@@ -14,7 +14,7 @@ import os from "os";
|
|
|
14
14
|
|
|
15
15
|
describe("Knowledge Graph Builder", () => {
|
|
16
16
|
const testRoot = process.cwd();
|
|
17
|
-
const testAiDir = path.join(testRoot, "ai");
|
|
17
|
+
const testAiDir = path.join(testRoot, "ai-context");
|
|
18
18
|
|
|
19
19
|
describe("createNodes", () => {
|
|
20
20
|
it("should create nodes from ai directory", () => {
|
|
@@ -34,7 +34,7 @@ module.exports = app;
|
|
|
34
34
|
const fileInfo = {
|
|
35
35
|
path: testFilePath,
|
|
36
36
|
relativePath: "test.js",
|
|
37
|
-
extension: "
|
|
37
|
+
extension: "js",
|
|
38
38
|
name: "test"
|
|
39
39
|
};
|
|
40
40
|
|
|
@@ -62,7 +62,7 @@ export const MAX_USERS = 100;
|
|
|
62
62
|
const fileInfo = {
|
|
63
63
|
path: tsFilePath,
|
|
64
64
|
relativePath: "test.ts",
|
|
65
|
-
extension: "
|
|
65
|
+
extension: "ts",
|
|
66
66
|
name: "test"
|
|
67
67
|
};
|
|
68
68
|
|
|
@@ -75,7 +75,7 @@ export const MAX_USERS = 100;
|
|
|
75
75
|
fs.unlinkSync(tsFilePath);
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
it("should
|
|
78
|
+
it("should extract symbols when extension is passed without dot", () => {
|
|
79
79
|
const fileInfo = {
|
|
80
80
|
path: testFilePath,
|
|
81
81
|
relativePath: "test.js",
|
|
@@ -85,7 +85,7 @@ export const MAX_USERS = 100;
|
|
|
85
85
|
|
|
86
86
|
const result = extractSymbols([fileInfo]);
|
|
87
87
|
|
|
88
|
-
expect(result.symbols.length).
|
|
88
|
+
expect(result.symbols.length).toBeGreaterThan(0);
|
|
89
89
|
});
|
|
90
90
|
});
|
|
91
91
|
|