faf-mcp 1.0.0
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/CHANGELOG.md +34 -0
- package/CLAUDE.md +73 -0
- package/LICENSE +22 -0
- package/README.md +165 -0
- package/assets/Project-faf-pckg-json-README.png +0 -0
- package/assets/icons/faf-icon-128.png +0 -0
- package/assets/icons/faf-icon-256.png +0 -0
- package/assets/icons/faf-icon-48.png +0 -0
- package/assets/icons/faf-icon-512.png +0 -0
- package/assets/icons/orange-smiley.svg +6 -0
- package/dist/src/compiler/index.d.ts +7 -0
- package/dist/src/compiler/index.js +24 -0
- package/dist/src/compiler/index.js.map +1 -0
- package/dist/src/compiler/scorer.d.ts +53 -0
- package/dist/src/compiler/scorer.js +189 -0
- package/dist/src/compiler/scorer.js.map +1 -0
- package/dist/src/compiler/slot-validator.d.ts +32 -0
- package/dist/src/compiler/slot-validator.js +293 -0
- package/dist/src/compiler/slot-validator.js.map +1 -0
- package/dist/src/compiler/type-detector.d.ts +62 -0
- package/dist/src/compiler/type-detector.js +388 -0
- package/dist/src/compiler/type-detector.js.map +1 -0
- package/dist/src/config/visibility.d.ts +41 -0
- package/dist/src/config/visibility.js +158 -0
- package/dist/src/config/visibility.js.map +1 -0
- package/dist/src/faf-core/commands/audit.d.ts +21 -0
- package/dist/src/faf-core/commands/audit.js +83 -0
- package/dist/src/faf-core/commands/audit.js.map +1 -0
- package/dist/src/faf-core/commands/auto.d.ts +25 -0
- package/dist/src/faf-core/commands/auto.js +74 -0
- package/dist/src/faf-core/commands/auto.js.map +1 -0
- package/dist/src/faf-core/commands/bi-sync.d.ts +26 -0
- package/dist/src/faf-core/commands/bi-sync.js +157 -0
- package/dist/src/faf-core/commands/bi-sync.js.map +1 -0
- package/dist/src/faf-core/commands/doctor.d.ts +17 -0
- package/dist/src/faf-core/commands/doctor.js +198 -0
- package/dist/src/faf-core/commands/doctor.js.map +1 -0
- package/dist/src/faf-core/commands/enhance.d.ts +46 -0
- package/dist/src/faf-core/commands/enhance.js +360 -0
- package/dist/src/faf-core/commands/enhance.js.map +1 -0
- package/dist/src/faf-core/commands/formats.d.ts +22 -0
- package/dist/src/faf-core/commands/formats.js +117 -0
- package/dist/src/faf-core/commands/formats.js.map +1 -0
- package/dist/src/faf-core/commands/init.d.ts +26 -0
- package/dist/src/faf-core/commands/init.js +114 -0
- package/dist/src/faf-core/commands/init.js.map +1 -0
- package/dist/src/faf-core/commands/innit.d.ts +7 -0
- package/dist/src/faf-core/commands/innit.js +13 -0
- package/dist/src/faf-core/commands/innit.js.map +1 -0
- package/dist/src/faf-core/commands/migrate.d.ts +15 -0
- package/dist/src/faf-core/commands/migrate.js +86 -0
- package/dist/src/faf-core/commands/migrate.js.map +1 -0
- package/dist/src/faf-core/commands/quick.d.ts +16 -0
- package/dist/src/faf-core/commands/quick.js +184 -0
- package/dist/src/faf-core/commands/quick.js.map +1 -0
- package/dist/src/faf-core/commands/score.d.ts +47 -0
- package/dist/src/faf-core/commands/score.js +49 -0
- package/dist/src/faf-core/commands/score.js.map +1 -0
- package/dist/src/faf-core/commands/sync.d.ts +16 -0
- package/dist/src/faf-core/commands/sync.js +210 -0
- package/dist/src/faf-core/commands/sync.js.map +1 -0
- package/dist/src/faf-core/commands/update.d.ts +12 -0
- package/dist/src/faf-core/commands/update.js +46 -0
- package/dist/src/faf-core/commands/update.js.map +1 -0
- package/dist/src/faf-core/commands/validate.d.ts +21 -0
- package/dist/src/faf-core/commands/validate.js +81 -0
- package/dist/src/faf-core/commands/validate.js.map +1 -0
- package/dist/src/faf-core/compiler/faf-compiler.d.ts +138 -0
- package/dist/src/faf-core/compiler/faf-compiler.js +794 -0
- package/dist/src/faf-core/compiler/faf-compiler.js.map +1 -0
- package/dist/src/faf-core/engines/dependency-tsa.d.ts +88 -0
- package/dist/src/faf-core/engines/dependency-tsa.js +361 -0
- package/dist/src/faf-core/engines/dependency-tsa.js.map +1 -0
- package/dist/src/faf-core/engines/fab-formats-processor.d.ts +166 -0
- package/dist/src/faf-core/engines/fab-formats-processor.js +1274 -0
- package/dist/src/faf-core/engines/fab-formats-processor.js.map +1 -0
- package/dist/src/faf-core/engines/faf-dna.d.ts +159 -0
- package/dist/src/faf-core/engines/faf-dna.js +554 -0
- package/dist/src/faf-core/engines/faf-dna.js.map +1 -0
- package/dist/src/faf-core/engines/relentless-context-extractor.d.ts +100 -0
- package/dist/src/faf-core/engines/relentless-context-extractor.js +625 -0
- package/dist/src/faf-core/engines/relentless-context-extractor.js.map +1 -0
- package/dist/src/faf-core/fix-once/colors.d.ts +104 -0
- package/dist/src/faf-core/fix-once/colors.js +236 -0
- package/dist/src/faf-core/fix-once/colors.js.map +1 -0
- package/dist/src/faf-core/fix-once/types.d.ts +257 -0
- package/dist/src/faf-core/fix-once/types.js +26 -0
- package/dist/src/faf-core/fix-once/types.js.map +1 -0
- package/dist/src/faf-core/fix-once/yaml.d.ts +57 -0
- package/dist/src/faf-core/fix-once/yaml.js +172 -0
- package/dist/src/faf-core/fix-once/yaml.js.map +1 -0
- package/dist/src/faf-core/generators/faf-generator-championship.d.ts +16 -0
- package/dist/src/faf-core/generators/faf-generator-championship.js +462 -0
- package/dist/src/faf-core/generators/faf-generator-championship.js.map +1 -0
- package/dist/src/faf-core/utils/balance-visualizer.d.ts +37 -0
- package/dist/src/faf-core/utils/balance-visualizer.js +197 -0
- package/dist/src/faf-core/utils/balance-visualizer.js.map +1 -0
- package/dist/src/faf-core/utils/championship-style.d.ts +109 -0
- package/dist/src/faf-core/utils/championship-style.js +219 -0
- package/dist/src/faf-core/utils/championship-style.js.map +1 -0
- package/dist/src/faf-core/utils/chrome-extension-detector.d.ts +73 -0
- package/dist/src/faf-core/utils/chrome-extension-detector.js +268 -0
- package/dist/src/faf-core/utils/chrome-extension-detector.js.map +1 -0
- package/dist/src/faf-core/utils/fafignore-parser.d.ts +20 -0
- package/dist/src/faf-core/utils/fafignore-parser.js +178 -0
- package/dist/src/faf-core/utils/fafignore-parser.js.map +1 -0
- package/dist/src/faf-core/utils/file-utils.d.ts +112 -0
- package/dist/src/faf-core/utils/file-utils.js +846 -0
- package/dist/src/faf-core/utils/file-utils.js.map +1 -0
- package/dist/src/faf-core/utils/native-file-finder.d.ts +115 -0
- package/dist/src/faf-core/utils/native-file-finder.js +211 -0
- package/dist/src/faf-core/utils/native-file-finder.js.map +1 -0
- package/dist/src/faf-core/utils/platform-detector.d.ts +30 -0
- package/dist/src/faf-core/utils/platform-detector.js +218 -0
- package/dist/src/faf-core/utils/platform-detector.js.map +1 -0
- package/dist/src/faf-core/utils/technical-credit.d.ts +35 -0
- package/dist/src/faf-core/utils/technical-credit.js +286 -0
- package/dist/src/faf-core/utils/technical-credit.js.map +1 -0
- package/dist/src/faf-core/utils/yaml-generator.d.ts +41 -0
- package/dist/src/faf-core/utils/yaml-generator.js +360 -0
- package/dist/src/faf-core/utils/yaml-generator.js.map +1 -0
- package/dist/src/handlers/behavioral-instruction.d.ts +16 -0
- package/dist/src/handlers/behavioral-instruction.js +43 -0
- package/dist/src/handlers/behavioral-instruction.js.map +1 -0
- package/dist/src/handlers/championship-tools.d.ts +113 -0
- package/dist/src/handlers/championship-tools.js +2602 -0
- package/dist/src/handlers/championship-tools.js.map +1 -0
- package/dist/src/handlers/engine-adapter.d.ts +28 -0
- package/dist/src/handlers/engine-adapter.js +603 -0
- package/dist/src/handlers/engine-adapter.js.map +1 -0
- package/dist/src/handlers/fileHandler.d.ts +36 -0
- package/dist/src/handlers/fileHandler.js +246 -0
- package/dist/src/handlers/fileHandler.js.map +1 -0
- package/dist/src/handlers/resources.d.ts +18 -0
- package/dist/src/handlers/resources.js +78 -0
- package/dist/src/handlers/resources.js.map +1 -0
- package/dist/src/handlers/tool-registry.d.ts +23 -0
- package/dist/src/handlers/tool-registry.js +68 -0
- package/dist/src/handlers/tool-registry.js.map +1 -0
- package/dist/src/handlers/tool-types.d.ts +167 -0
- package/dist/src/handlers/tool-types.js +7 -0
- package/dist/src/handlers/tool-types.js.map +1 -0
- package/dist/src/handlers/tools.d.ts +25 -0
- package/dist/src/handlers/tools.js +1168 -0
- package/dist/src/handlers/tools.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +17 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/server.d.ts +28 -0
- package/dist/src/server.js +179 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/test-all-functions.d.ts +15 -0
- package/dist/src/test-all-functions.js +163 -0
- package/dist/src/test-all-functions.js.map +1 -0
- package/dist/src/types/mcp-tools.d.ts +53 -0
- package/dist/src/types/mcp-tools.js +77 -0
- package/dist/src/types/mcp-tools.js.map +1 -0
- package/dist/src/types/project-types.d.ts +22 -0
- package/dist/src/types/project-types.js +85 -0
- package/dist/src/types/project-types.js.map +1 -0
- package/dist/src/types/slots.d.ts +39 -0
- package/dist/src/types/slots.js +162 -0
- package/dist/src/types/slots.js.map +1 -0
- package/dist/src/types/tool-visibility.d.ts +36 -0
- package/dist/src/types/tool-visibility.js +510 -0
- package/dist/src/types/tool-visibility.js.map +1 -0
- package/dist/src/utils/auto-path-detection.d.ts +26 -0
- package/dist/src/utils/auto-path-detection.js +198 -0
- package/dist/src/utils/auto-path-detection.js.map +1 -0
- package/dist/src/utils/championship-format.d.ts +30 -0
- package/dist/src/utils/championship-format.js +79 -0
- package/dist/src/utils/championship-format.js.map +1 -0
- package/dist/src/utils/cli-detector.d.ts +20 -0
- package/dist/src/utils/cli-detector.js +230 -0
- package/dist/src/utils/cli-detector.js.map +1 -0
- package/dist/src/utils/display-protocol.d.ts +57 -0
- package/dist/src/utils/display-protocol.js +131 -0
- package/dist/src/utils/display-protocol.js.map +1 -0
- package/dist/src/utils/faf-file-finder.d.ts +59 -0
- package/dist/src/utils/faf-file-finder.js +139 -0
- package/dist/src/utils/faf-file-finder.js.map +1 -0
- package/dist/src/utils/fuzzy-detector.d.ts +56 -0
- package/dist/src/utils/fuzzy-detector.js +221 -0
- package/dist/src/utils/fuzzy-detector.js.map +1 -0
- package/dist/src/utils/path-resolver.d.ts +51 -0
- package/dist/src/utils/path-resolver.js +214 -0
- package/dist/src/utils/path-resolver.js.map +1 -0
- package/dist/src/utils/type-guards.d.ts +9 -0
- package/dist/src/utils/type-guards.js +27 -0
- package/dist/src/utils/type-guards.js.map +1 -0
- package/dist/src/utils/username-detector.d.ts +27 -0
- package/dist/src/utils/username-detector.js +90 -0
- package/dist/src/utils/username-detector.js.map +1 -0
- package/dist/src/utils/visual-style.d.ts +62 -0
- package/dist/src/utils/visual-style.js +164 -0
- package/dist/src/utils/visual-style.js.map +1 -0
- package/dist/src/version.d.ts +9 -0
- package/dist/src/version.js +37 -0
- package/dist/src/version.js.map +1 -0
- package/package.json +114 -0
- package/scripts/discord-sync-curated.js +233 -0
- package/scripts/discord-sync-final.js +218 -0
- package/scripts/discord-sync-simple.js +175 -0
- package/scripts/discord-sync-working.js +187 -0
- package/scripts/discord-sync.js +181 -0
- package/scripts/postinstall.js +46 -0
- package/skill/SKILL.md +385 -0
|
@@ -0,0 +1,1274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* FAB-FORMATS PROCESSOR v3.0.0 - The Championship Engine
|
|
4
|
+
*
|
|
5
|
+
* Direct port from faf-svelte-engine - the 86% scorer!
|
|
6
|
+
* 150+ file handlers with deep intelligence extraction
|
|
7
|
+
* Two-stage pattern: Discover first, read second
|
|
8
|
+
*
|
|
9
|
+
* THIS IS THE POWER UNIT! 🏎️
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
+
}) : function(o, v) {
|
|
25
|
+
o["default"] = v;
|
|
26
|
+
});
|
|
27
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
+
var ownKeys = function(o) {
|
|
29
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
+
var ar = [];
|
|
31
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
+
return ar;
|
|
33
|
+
};
|
|
34
|
+
return ownKeys(o);
|
|
35
|
+
};
|
|
36
|
+
return function (mod) {
|
|
37
|
+
if (mod && mod.__esModule) return mod;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
+
__setModuleDefault(result, mod);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
})();
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.fabFormatsProcessor = exports.FabFormatsProcessor = void 0;
|
|
46
|
+
const fs_1 = require("fs");
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
// ==================== MAIN ENGINE ====================
|
|
49
|
+
class FabFormatsProcessor {
|
|
50
|
+
context = {};
|
|
51
|
+
processedFileTypes = new Set();
|
|
52
|
+
contextTodos = [];
|
|
53
|
+
/**
|
|
54
|
+
* Process multiple files with championship-grade intelligence extraction
|
|
55
|
+
*/
|
|
56
|
+
async processFiles(projectDir) {
|
|
57
|
+
// Stage 1: Discovery - Find ALL relevant files
|
|
58
|
+
const files = await this.discoverFiles(projectDir);
|
|
59
|
+
// Stage 2: Process - Extract intelligence with deduplication
|
|
60
|
+
const results = [];
|
|
61
|
+
let totalBonus = 0;
|
|
62
|
+
let highestGrade = 'MINIMAL';
|
|
63
|
+
for (const filePath of files) {
|
|
64
|
+
const result = await this.processFile(filePath);
|
|
65
|
+
if (result && !result.isDuplicate) {
|
|
66
|
+
results.push(result);
|
|
67
|
+
totalBonus += result.intelligenceBonus;
|
|
68
|
+
// Update context with detected values
|
|
69
|
+
this.updateContext(result);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Stage 3: Analysis - Generate quality metrics
|
|
73
|
+
const qualityMetrics = {
|
|
74
|
+
highestGrade,
|
|
75
|
+
averageScore: results.length > 0 ? totalBonus / results.length : 0,
|
|
76
|
+
filesCovered: results.length,
|
|
77
|
+
intelligenceDepth: this.calculateDepth()
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
results,
|
|
81
|
+
totalBonus,
|
|
82
|
+
context: this.context,
|
|
83
|
+
qualityMetrics
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Stage 1: Discover all relevant files (no reading yet!)
|
|
88
|
+
*/
|
|
89
|
+
async discoverFiles(projectDir) {
|
|
90
|
+
const discovered = [];
|
|
91
|
+
const visited = new Set();
|
|
92
|
+
// Priority files to look for
|
|
93
|
+
const priorityFiles = [
|
|
94
|
+
'package.json',
|
|
95
|
+
'tsconfig.json',
|
|
96
|
+
'README.md',
|
|
97
|
+
'requirements.txt',
|
|
98
|
+
'pyproject.toml',
|
|
99
|
+
'Cargo.toml',
|
|
100
|
+
'go.mod',
|
|
101
|
+
'pom.xml',
|
|
102
|
+
'build.gradle',
|
|
103
|
+
'Gemfile',
|
|
104
|
+
'composer.json',
|
|
105
|
+
'.faf'
|
|
106
|
+
];
|
|
107
|
+
// Check project directory and up to 3 levels up
|
|
108
|
+
let currentDir = projectDir;
|
|
109
|
+
for (let level = 0; level < 4; level++) {
|
|
110
|
+
if (visited.has(currentDir))
|
|
111
|
+
break;
|
|
112
|
+
visited.add(currentDir);
|
|
113
|
+
try {
|
|
114
|
+
const files = await fs_1.promises.readdir(currentDir);
|
|
115
|
+
for (const file of files) {
|
|
116
|
+
const fullPath = path.join(currentDir, file);
|
|
117
|
+
// Check if it's a priority file
|
|
118
|
+
if (priorityFiles.includes(file)) {
|
|
119
|
+
discovered.push(fullPath);
|
|
120
|
+
}
|
|
121
|
+
// Check known extensions
|
|
122
|
+
else if (this.isRelevantFile(file)) {
|
|
123
|
+
discovered.push(fullPath);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Move up one directory
|
|
127
|
+
const parentDir = path.dirname(currentDir);
|
|
128
|
+
if (parentDir === currentDir)
|
|
129
|
+
break;
|
|
130
|
+
currentDir = parentDir;
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
// Directory not accessible, continue
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return discovered;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Check if file is relevant for intelligence extraction
|
|
141
|
+
*/
|
|
142
|
+
isRelevantFile(fileName) {
|
|
143
|
+
const relevantPatterns = [
|
|
144
|
+
// Config files
|
|
145
|
+
/^\.eslintrc/,
|
|
146
|
+
/^\.prettierrc/,
|
|
147
|
+
/^jest\.config/,
|
|
148
|
+
/^vitest\.config/,
|
|
149
|
+
/^vite\.config/,
|
|
150
|
+
/^webpack\.config/,
|
|
151
|
+
/^rollup\.config/,
|
|
152
|
+
/^babel\.config/,
|
|
153
|
+
// Docker
|
|
154
|
+
/^Dockerfile/,
|
|
155
|
+
/^docker-compose/,
|
|
156
|
+
// CI/CD
|
|
157
|
+
/^\.gitlab-ci\.yml$/,
|
|
158
|
+
/^Jenkinsfile$/,
|
|
159
|
+
// Cloud configs
|
|
160
|
+
/^vercel\.json$/,
|
|
161
|
+
/^netlify\.toml$/,
|
|
162
|
+
/^railway\./,
|
|
163
|
+
/^render\./,
|
|
164
|
+
/^fly\.toml$/,
|
|
165
|
+
/^heroku\./,
|
|
166
|
+
// Database
|
|
167
|
+
/prisma\.schema$/,
|
|
168
|
+
/drizzle\.config/,
|
|
169
|
+
// Environment
|
|
170
|
+
/^\.env/,
|
|
171
|
+
// Documentation
|
|
172
|
+
/^REQUIREMENTS\./i,
|
|
173
|
+
/^LICENSE/
|
|
174
|
+
];
|
|
175
|
+
return relevantPatterns.some(pattern => pattern.test(fileName));
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Process a single file with intelligence extraction
|
|
179
|
+
*/
|
|
180
|
+
async processFile(filePath) {
|
|
181
|
+
const fileName = path.basename(filePath);
|
|
182
|
+
// Smart categorization for deduplication
|
|
183
|
+
const category = this.categorizeFile(fileName);
|
|
184
|
+
// Skip if we've already processed this category
|
|
185
|
+
if (this.processedFileTypes.has(category)) {
|
|
186
|
+
return {
|
|
187
|
+
fileName,
|
|
188
|
+
fileType: category,
|
|
189
|
+
intelligenceBonus: 0,
|
|
190
|
+
metadata: { message: `${category} already processed` },
|
|
191
|
+
category,
|
|
192
|
+
isDuplicate: true
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
// Mark category as processed
|
|
196
|
+
this.processedFileTypes.add(category);
|
|
197
|
+
try {
|
|
198
|
+
const content = await fs_1.promises.readFile(filePath, 'utf-8');
|
|
199
|
+
// Route to specific processor
|
|
200
|
+
if (fileName === 'package.json') {
|
|
201
|
+
return this.processPackageJson(fileName, content);
|
|
202
|
+
}
|
|
203
|
+
else if (fileName === 'tsconfig.json') {
|
|
204
|
+
return this.processTypeScriptConfig(fileName, content);
|
|
205
|
+
}
|
|
206
|
+
else if (fileName === 'README.md') {
|
|
207
|
+
return this.processReadme(fileName, content);
|
|
208
|
+
}
|
|
209
|
+
else if (fileName === 'requirements.txt') {
|
|
210
|
+
return this.processPythonRequirements(fileName, content);
|
|
211
|
+
}
|
|
212
|
+
else if (fileName === 'pyproject.toml') {
|
|
213
|
+
return this.processPyProject(fileName, content);
|
|
214
|
+
}
|
|
215
|
+
else if (fileName === 'Cargo.toml') {
|
|
216
|
+
return this.processCargoToml(fileName, content);
|
|
217
|
+
}
|
|
218
|
+
else if (fileName === 'go.mod') {
|
|
219
|
+
return this.processGoMod(fileName, content);
|
|
220
|
+
}
|
|
221
|
+
else if (fileName === 'pom.xml') {
|
|
222
|
+
return this.processMavenPom(fileName, content);
|
|
223
|
+
}
|
|
224
|
+
else if (fileName === 'build.gradle' || fileName === 'build.gradle.kts') {
|
|
225
|
+
return this.processGradle(fileName, content);
|
|
226
|
+
}
|
|
227
|
+
else if (fileName === 'Gemfile') {
|
|
228
|
+
return this.processGemfile(fileName, content);
|
|
229
|
+
}
|
|
230
|
+
else if (fileName === 'composer.json') {
|
|
231
|
+
return this.processComposer(fileName, content);
|
|
232
|
+
}
|
|
233
|
+
else if (fileName === '.faf') {
|
|
234
|
+
return this.processFafFile(fileName, content);
|
|
235
|
+
}
|
|
236
|
+
else if (fileName === 'Dockerfile') {
|
|
237
|
+
return this.processDockerfile(fileName, content);
|
|
238
|
+
}
|
|
239
|
+
else if (fileName === 'docker-compose.yml' || fileName === 'docker-compose.yaml') {
|
|
240
|
+
return this.processDockerCompose(fileName, content);
|
|
241
|
+
}
|
|
242
|
+
else if (fileName.startsWith('.env')) {
|
|
243
|
+
return this.processEnvFile(fileName, content);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
return this.processGenericFile(fileName, content);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
catch (err) {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Categorize files for intelligent deduplication
|
|
255
|
+
*/
|
|
256
|
+
categorizeFile(fileName) {
|
|
257
|
+
// Package managers (only one per project)
|
|
258
|
+
if (fileName === 'package.json')
|
|
259
|
+
return 'package-manager';
|
|
260
|
+
if (fileName === 'Cargo.toml')
|
|
261
|
+
return 'package-manager-rust';
|
|
262
|
+
if (fileName === 'requirements.txt')
|
|
263
|
+
return 'package-manager-python';
|
|
264
|
+
if (fileName === 'pyproject.toml')
|
|
265
|
+
return 'package-manager-python-modern';
|
|
266
|
+
if (fileName === 'go.mod')
|
|
267
|
+
return 'package-manager-go';
|
|
268
|
+
if (fileName === 'pom.xml')
|
|
269
|
+
return 'package-manager-java';
|
|
270
|
+
if (fileName === 'build.gradle')
|
|
271
|
+
return 'package-manager-gradle';
|
|
272
|
+
if (fileName === 'Gemfile')
|
|
273
|
+
return 'package-manager-ruby';
|
|
274
|
+
if (fileName === 'composer.json')
|
|
275
|
+
return 'package-manager-php';
|
|
276
|
+
// Config files (one per type)
|
|
277
|
+
if (fileName === 'tsconfig.json')
|
|
278
|
+
return 'typescript-config';
|
|
279
|
+
if (fileName.includes('vite.config'))
|
|
280
|
+
return 'vite-config';
|
|
281
|
+
if (fileName.includes('webpack.config'))
|
|
282
|
+
return 'webpack-config';
|
|
283
|
+
if (fileName.includes('jest.config'))
|
|
284
|
+
return 'test-config';
|
|
285
|
+
if (fileName.includes('vitest.config'))
|
|
286
|
+
return 'test-config-vite';
|
|
287
|
+
if (fileName.includes('eslint'))
|
|
288
|
+
return 'lint-config';
|
|
289
|
+
if (fileName.includes('prettier'))
|
|
290
|
+
return 'format-config';
|
|
291
|
+
// Docker (one of each)
|
|
292
|
+
if (fileName === 'Dockerfile')
|
|
293
|
+
return 'docker-config';
|
|
294
|
+
if (fileName.includes('docker-compose'))
|
|
295
|
+
return 'docker-compose-config';
|
|
296
|
+
// Documentation (one main)
|
|
297
|
+
if (fileName === 'README.md')
|
|
298
|
+
return 'documentation';
|
|
299
|
+
if (fileName.includes('REQUIREMENTS'))
|
|
300
|
+
return 'requirements-doc';
|
|
301
|
+
if (fileName.includes('LICENSE'))
|
|
302
|
+
return 'license';
|
|
303
|
+
// Cloud configs
|
|
304
|
+
if (fileName === 'vercel.json')
|
|
305
|
+
return 'vercel-config';
|
|
306
|
+
if (fileName === 'netlify.toml')
|
|
307
|
+
return 'netlify-config';
|
|
308
|
+
// FAF
|
|
309
|
+
if (fileName === '.faf')
|
|
310
|
+
return 'faf-context';
|
|
311
|
+
// Default
|
|
312
|
+
const ext = path.extname(fileName);
|
|
313
|
+
return `file-type-${ext}`;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* CHAMPIONSHIP PROCESSOR: package.json with quality grading
|
|
317
|
+
*/
|
|
318
|
+
async processPackageJson(fileName, content) {
|
|
319
|
+
let intelligenceBonus = 0;
|
|
320
|
+
const metadata = {};
|
|
321
|
+
try {
|
|
322
|
+
const packageData = JSON.parse(content);
|
|
323
|
+
const allDeps = {
|
|
324
|
+
...packageData.dependencies,
|
|
325
|
+
...packageData.devDependencies,
|
|
326
|
+
...packageData.peerDependencies
|
|
327
|
+
};
|
|
328
|
+
// Grade the quality
|
|
329
|
+
const quality = this.gradePackageJsonQuality(packageData, content);
|
|
330
|
+
metadata.grade = quality.grade;
|
|
331
|
+
intelligenceBonus = quality.baseScore;
|
|
332
|
+
metadata.criteria = quality.criteria;
|
|
333
|
+
// Extract project name
|
|
334
|
+
if (packageData.name && !this.context.projectName) {
|
|
335
|
+
this.context.projectName = packageData.name
|
|
336
|
+
.replace(/[-_]/g, ' ')
|
|
337
|
+
.split(' ')
|
|
338
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
339
|
+
.join(' ');
|
|
340
|
+
}
|
|
341
|
+
// Extract project goal
|
|
342
|
+
if (packageData.description && !this.context.projectGoal) {
|
|
343
|
+
this.context.projectGoal = packageData.description;
|
|
344
|
+
}
|
|
345
|
+
// Framework detection (comprehensive)
|
|
346
|
+
if (!this.context.framework) {
|
|
347
|
+
if (allDeps['svelte']) {
|
|
348
|
+
const version = allDeps['svelte'];
|
|
349
|
+
this.context.framework = version?.startsWith('^5') || version?.startsWith('5')
|
|
350
|
+
? 'Svelte 5' : 'Svelte';
|
|
351
|
+
}
|
|
352
|
+
else if (allDeps['@sveltejs/kit']) {
|
|
353
|
+
this.context.framework = 'SvelteKit';
|
|
354
|
+
}
|
|
355
|
+
else if (allDeps['next']) {
|
|
356
|
+
this.context.framework = 'Next.js';
|
|
357
|
+
}
|
|
358
|
+
else if (allDeps['react']) {
|
|
359
|
+
this.context.framework = 'React';
|
|
360
|
+
}
|
|
361
|
+
else if (allDeps['vue']) {
|
|
362
|
+
this.context.framework = 'Vue.js';
|
|
363
|
+
}
|
|
364
|
+
else if (allDeps['nuxt']) {
|
|
365
|
+
this.context.framework = 'Nuxt.js';
|
|
366
|
+
}
|
|
367
|
+
else if (allDeps['@angular/core']) {
|
|
368
|
+
this.context.framework = 'Angular';
|
|
369
|
+
}
|
|
370
|
+
else if (allDeps['astro']) {
|
|
371
|
+
this.context.framework = 'Astro';
|
|
372
|
+
}
|
|
373
|
+
else if (allDeps['solid-js']) {
|
|
374
|
+
this.context.framework = 'SolidJS';
|
|
375
|
+
}
|
|
376
|
+
else if (allDeps['express']) {
|
|
377
|
+
this.context.framework = 'Express.js';
|
|
378
|
+
}
|
|
379
|
+
else if (allDeps['fastify']) {
|
|
380
|
+
this.context.framework = 'Fastify';
|
|
381
|
+
}
|
|
382
|
+
else if (allDeps['@nestjs/core']) {
|
|
383
|
+
this.context.framework = 'NestJS';
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
// Language detection
|
|
387
|
+
if (!this.context.mainLanguage) {
|
|
388
|
+
if (allDeps['typescript'] || packageData.types || allDeps['@types/node']) {
|
|
389
|
+
this.context.mainLanguage = 'TypeScript';
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
this.context.mainLanguage = 'JavaScript';
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
// Build tool detection
|
|
396
|
+
if (!this.context.buildTool) {
|
|
397
|
+
if (allDeps['vite']) {
|
|
398
|
+
this.context.buildTool = 'Vite';
|
|
399
|
+
}
|
|
400
|
+
else if (allDeps['webpack']) {
|
|
401
|
+
this.context.buildTool = 'Webpack';
|
|
402
|
+
}
|
|
403
|
+
else if (allDeps['rollup']) {
|
|
404
|
+
this.context.buildTool = 'Rollup';
|
|
405
|
+
}
|
|
406
|
+
else if (allDeps['parcel']) {
|
|
407
|
+
this.context.buildTool = 'Parcel';
|
|
408
|
+
}
|
|
409
|
+
else if (allDeps['esbuild']) {
|
|
410
|
+
this.context.buildTool = 'ESBuild';
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
// Test framework detection
|
|
414
|
+
if (!this.context.testFramework) {
|
|
415
|
+
if (allDeps['vitest']) {
|
|
416
|
+
this.context.testFramework = 'Vitest';
|
|
417
|
+
}
|
|
418
|
+
else if (allDeps['jest']) {
|
|
419
|
+
this.context.testFramework = 'Jest';
|
|
420
|
+
}
|
|
421
|
+
else if (allDeps['playwright']) {
|
|
422
|
+
this.context.testFramework = 'Playwright';
|
|
423
|
+
}
|
|
424
|
+
else if (allDeps['cypress']) {
|
|
425
|
+
this.context.testFramework = 'Cypress';
|
|
426
|
+
}
|
|
427
|
+
else if (allDeps['mocha']) {
|
|
428
|
+
this.context.testFramework = 'Mocha';
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
// Package manager detection
|
|
432
|
+
if (!this.context.packageManager) {
|
|
433
|
+
if (packageData.packageManager) {
|
|
434
|
+
this.context.packageManager = packageData.packageManager.split('@')[0];
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
this.context.packageManager = 'npm'; // Default
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
// Backend detection
|
|
441
|
+
if (!this.context.backend) {
|
|
442
|
+
if (allDeps['express'] || allDeps['fastify'] || allDeps['koa'] || allDeps['hapi']) {
|
|
443
|
+
this.context.backend = 'Node.js';
|
|
444
|
+
}
|
|
445
|
+
else if (allDeps['deno']) {
|
|
446
|
+
this.context.backend = 'Deno';
|
|
447
|
+
}
|
|
448
|
+
else if (allDeps['bun']) {
|
|
449
|
+
this.context.backend = 'Bun';
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
// Database detection from dependencies
|
|
453
|
+
if (!this.context.database) {
|
|
454
|
+
if (allDeps['pg'] || allDeps['postgres'] || allDeps['postgresql']) {
|
|
455
|
+
this.context.database = 'PostgreSQL';
|
|
456
|
+
}
|
|
457
|
+
else if (allDeps['mysql'] || allDeps['mysql2']) {
|
|
458
|
+
this.context.database = 'MySQL';
|
|
459
|
+
}
|
|
460
|
+
else if (allDeps['mongodb'] || allDeps['mongoose']) {
|
|
461
|
+
this.context.database = 'MongoDB';
|
|
462
|
+
}
|
|
463
|
+
else if (allDeps['redis'] || allDeps['ioredis']) {
|
|
464
|
+
this.context.database = 'Redis';
|
|
465
|
+
}
|
|
466
|
+
else if (allDeps['sqlite3'] || allDeps['better-sqlite3']) {
|
|
467
|
+
this.context.database = 'SQLite';
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
// Deployment detection from homepage
|
|
471
|
+
if (packageData.homepage && !this.context.deploymentMarket) {
|
|
472
|
+
if (packageData.homepage.includes('vercel.app')) {
|
|
473
|
+
this.context.deploymentMarket = 'Vercel';
|
|
474
|
+
}
|
|
475
|
+
else if (packageData.homepage.includes('netlify.app')) {
|
|
476
|
+
this.context.deploymentMarket = 'Netlify';
|
|
477
|
+
}
|
|
478
|
+
else if (packageData.homepage.includes('github.io')) {
|
|
479
|
+
this.context.deploymentMarket = 'GitHub Pages';
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
metadata.dependencies = Object.keys(allDeps).length;
|
|
483
|
+
metadata.hasScripts = !!packageData.scripts;
|
|
484
|
+
metadata.hasTests = !!(packageData.scripts?.test);
|
|
485
|
+
metadata.hasBuild = !!(packageData.scripts?.build);
|
|
486
|
+
}
|
|
487
|
+
catch (err) {
|
|
488
|
+
// Invalid JSON
|
|
489
|
+
intelligenceBonus = 10;
|
|
490
|
+
metadata.error = 'Invalid JSON';
|
|
491
|
+
}
|
|
492
|
+
return {
|
|
493
|
+
fileName,
|
|
494
|
+
fileType: 'package.json',
|
|
495
|
+
intelligenceBonus,
|
|
496
|
+
detectedFramework: this.context.framework,
|
|
497
|
+
detectedLanguage: this.context.mainLanguage,
|
|
498
|
+
detectedBuildTool: this.context.buildTool,
|
|
499
|
+
metadata,
|
|
500
|
+
category: 'package-manager'
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* QUALITY GRADING SYSTEM - The secret sauce!
|
|
505
|
+
*/
|
|
506
|
+
gradePackageJsonQuality(packageData, content) {
|
|
507
|
+
const criteria = [];
|
|
508
|
+
// TIER 1: EXCEPTIONAL (90%+ score) - 90-150 points
|
|
509
|
+
let exceptionalCount = 0;
|
|
510
|
+
// Complete project metadata
|
|
511
|
+
if (packageData.name && packageData.description && packageData.version) {
|
|
512
|
+
exceptionalCount++;
|
|
513
|
+
criteria.push('Complete project metadata');
|
|
514
|
+
}
|
|
515
|
+
// Rich scripts showing full dev lifecycle
|
|
516
|
+
const scripts = packageData.scripts || {};
|
|
517
|
+
const scriptKeys = Object.keys(scripts);
|
|
518
|
+
if (scriptKeys.includes('dev') && scriptKeys.includes('build') &&
|
|
519
|
+
(scriptKeys.includes('test') || scriptKeys.includes('check'))) {
|
|
520
|
+
exceptionalCount++;
|
|
521
|
+
criteria.push('Complete dev lifecycle scripts');
|
|
522
|
+
}
|
|
523
|
+
// Professional dependency management
|
|
524
|
+
const totalDeps = Object.keys(packageData.dependencies || {}).length +
|
|
525
|
+
Object.keys(packageData.devDependencies || {}).length;
|
|
526
|
+
if (totalDeps >= 15 && packageData.devDependencies) {
|
|
527
|
+
exceptionalCount++;
|
|
528
|
+
criteria.push('Professional dependency structure');
|
|
529
|
+
}
|
|
530
|
+
// Modern toolchain
|
|
531
|
+
const allDeps = { ...packageData.dependencies, ...packageData.devDependencies };
|
|
532
|
+
let modernTools = 0;
|
|
533
|
+
if (allDeps['typescript'] || allDeps['@types/node'])
|
|
534
|
+
modernTools++;
|
|
535
|
+
if (allDeps['vite'] || allDeps['webpack'] || allDeps['rollup'])
|
|
536
|
+
modernTools++;
|
|
537
|
+
if (allDeps['jest'] || allDeps['vitest'] || allDeps['playwright'])
|
|
538
|
+
modernTools++;
|
|
539
|
+
if (allDeps['eslint'] || allDeps['prettier'])
|
|
540
|
+
modernTools++;
|
|
541
|
+
if (modernTools >= 3) {
|
|
542
|
+
exceptionalCount++;
|
|
543
|
+
criteria.push('Modern development toolchain');
|
|
544
|
+
}
|
|
545
|
+
// Framework sophistication
|
|
546
|
+
let frameworkSophistication = 0;
|
|
547
|
+
if (allDeps['svelte'] || allDeps['react'] || allDeps['vue'] || allDeps['next'] || allDeps['nuxt']) {
|
|
548
|
+
frameworkSophistication++;
|
|
549
|
+
}
|
|
550
|
+
if (allDeps['@sveltejs/kit'] || allDeps['next'] || allDeps['nuxt']) {
|
|
551
|
+
frameworkSophistication++; // Meta-frameworks
|
|
552
|
+
}
|
|
553
|
+
if (allDeps['tailwindcss'] || allDeps['styled-components'] || allDeps['@emotion/styled']) {
|
|
554
|
+
frameworkSophistication++; // Styling
|
|
555
|
+
}
|
|
556
|
+
if (frameworkSophistication >= 2) {
|
|
557
|
+
exceptionalCount++;
|
|
558
|
+
criteria.push('Sophisticated framework stack');
|
|
559
|
+
}
|
|
560
|
+
// Professional project setup
|
|
561
|
+
if (packageData.repository && packageData.author && packageData.license) {
|
|
562
|
+
exceptionalCount++;
|
|
563
|
+
criteria.push('Professional project setup');
|
|
564
|
+
}
|
|
565
|
+
// Determine grade
|
|
566
|
+
if (exceptionalCount >= 5) {
|
|
567
|
+
return { grade: 'EXCEPTIONAL', baseScore: 120, criteria };
|
|
568
|
+
}
|
|
569
|
+
else if (exceptionalCount >= 3) {
|
|
570
|
+
return { grade: 'PROFESSIONAL', baseScore: 85, criteria };
|
|
571
|
+
}
|
|
572
|
+
else if (packageData.name && totalDeps >= 5 && scriptKeys.length >= 2) {
|
|
573
|
+
return { grade: 'GOOD', baseScore: 65, criteria };
|
|
574
|
+
}
|
|
575
|
+
else if (packageData.name && totalDeps >= 1) {
|
|
576
|
+
return { grade: 'BASIC', baseScore: 45, criteria };
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
return { grade: 'MINIMAL', baseScore: 25, criteria };
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Process TypeScript configuration
|
|
584
|
+
*/
|
|
585
|
+
async processTypeScriptConfig(fileName, content) {
|
|
586
|
+
let intelligenceBonus = 60;
|
|
587
|
+
const metadata = {};
|
|
588
|
+
try {
|
|
589
|
+
const tsConfig = JSON.parse(content);
|
|
590
|
+
if (!this.context.mainLanguage) {
|
|
591
|
+
this.context.mainLanguage = 'TypeScript';
|
|
592
|
+
}
|
|
593
|
+
// Check for strict mode (quality indicator)
|
|
594
|
+
if (tsConfig.compilerOptions?.strict) {
|
|
595
|
+
intelligenceBonus += 20;
|
|
596
|
+
metadata.strict = true;
|
|
597
|
+
}
|
|
598
|
+
// Check for modern features
|
|
599
|
+
if (tsConfig.compilerOptions?.target?.includes('ES20')) {
|
|
600
|
+
intelligenceBonus += 10;
|
|
601
|
+
metadata.modern = true;
|
|
602
|
+
}
|
|
603
|
+
metadata.module = tsConfig.compilerOptions?.module;
|
|
604
|
+
metadata.target = tsConfig.compilerOptions?.target;
|
|
605
|
+
}
|
|
606
|
+
catch (err) {
|
|
607
|
+
intelligenceBonus = 30;
|
|
608
|
+
metadata.error = 'Invalid JSON';
|
|
609
|
+
}
|
|
610
|
+
return {
|
|
611
|
+
fileName,
|
|
612
|
+
fileType: 'tsconfig.json',
|
|
613
|
+
intelligenceBonus,
|
|
614
|
+
detectedLanguage: 'TypeScript',
|
|
615
|
+
metadata,
|
|
616
|
+
category: 'typescript-config'
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Process README for human context
|
|
621
|
+
*/
|
|
622
|
+
async processReadme(fileName, content) {
|
|
623
|
+
let intelligenceBonus = 50;
|
|
624
|
+
const metadata = {};
|
|
625
|
+
// Extract project name from title
|
|
626
|
+
const titleMatch = content.match(/^#\s+(.+)$/m);
|
|
627
|
+
if (titleMatch && !this.context.projectName) {
|
|
628
|
+
this.context.projectName = titleMatch[1].trim();
|
|
629
|
+
intelligenceBonus += 20;
|
|
630
|
+
}
|
|
631
|
+
// Extract description
|
|
632
|
+
const descMatch = content.match(/^#+\s+(?:description|about|overview|introduction)\s*\n+(.+?)(?:\n#|\n\n#|$)/ims);
|
|
633
|
+
if (descMatch && !this.context.projectGoal) {
|
|
634
|
+
this.context.projectGoal = descMatch[1].trim().substring(0, 200);
|
|
635
|
+
intelligenceBonus += 30;
|
|
636
|
+
}
|
|
637
|
+
// Look for installation/usage (indicates target user)
|
|
638
|
+
if (content.match(/##\s+Installation/i)) {
|
|
639
|
+
if (!this.context.targetUser) {
|
|
640
|
+
this.context.targetUser = 'Developers';
|
|
641
|
+
}
|
|
642
|
+
intelligenceBonus += 10;
|
|
643
|
+
}
|
|
644
|
+
// Look for features section
|
|
645
|
+
if (content.match(/##\s+Features/i)) {
|
|
646
|
+
intelligenceBonus += 15;
|
|
647
|
+
metadata.hasFeatures = true;
|
|
648
|
+
}
|
|
649
|
+
// Check documentation quality
|
|
650
|
+
const sections = content.match(/^##\s+.+$/gm) || [];
|
|
651
|
+
if (sections.length >= 5) {
|
|
652
|
+
intelligenceBonus += 25;
|
|
653
|
+
metadata.wellDocumented = true;
|
|
654
|
+
}
|
|
655
|
+
metadata.sections = sections.length;
|
|
656
|
+
metadata.length = content.length;
|
|
657
|
+
return {
|
|
658
|
+
fileName,
|
|
659
|
+
fileType: 'readme',
|
|
660
|
+
intelligenceBonus,
|
|
661
|
+
metadata,
|
|
662
|
+
category: 'documentation'
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Process Python requirements
|
|
667
|
+
*/
|
|
668
|
+
async processPythonRequirements(fileName, content) {
|
|
669
|
+
let intelligenceBonus = 50;
|
|
670
|
+
const metadata = {};
|
|
671
|
+
if (!this.context.mainLanguage) {
|
|
672
|
+
this.context.mainLanguage = 'Python';
|
|
673
|
+
}
|
|
674
|
+
const lines = content.split('\n').filter(line => line && !line.startsWith('#'));
|
|
675
|
+
metadata.dependencies = lines.length;
|
|
676
|
+
// Check for specific frameworks
|
|
677
|
+
if (!this.context.framework) {
|
|
678
|
+
if (content.includes('django')) {
|
|
679
|
+
this.context.framework = 'Django';
|
|
680
|
+
intelligenceBonus += 20;
|
|
681
|
+
}
|
|
682
|
+
else if (content.includes('flask')) {
|
|
683
|
+
this.context.framework = 'Flask';
|
|
684
|
+
intelligenceBonus += 20;
|
|
685
|
+
}
|
|
686
|
+
else if (content.includes('fastapi')) {
|
|
687
|
+
this.context.framework = 'FastAPI';
|
|
688
|
+
intelligenceBonus += 25;
|
|
689
|
+
}
|
|
690
|
+
else if (content.includes('streamlit')) {
|
|
691
|
+
this.context.framework = 'Streamlit';
|
|
692
|
+
intelligenceBonus += 20;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
// Check for AI/ML libraries
|
|
696
|
+
if (content.includes('torch') || content.includes('tensorflow')) {
|
|
697
|
+
metadata.aiml = true;
|
|
698
|
+
intelligenceBonus += 30;
|
|
699
|
+
}
|
|
700
|
+
// Check for data science
|
|
701
|
+
if (content.includes('pandas') || content.includes('numpy')) {
|
|
702
|
+
metadata.dataScience = true;
|
|
703
|
+
intelligenceBonus += 20;
|
|
704
|
+
}
|
|
705
|
+
return {
|
|
706
|
+
fileName,
|
|
707
|
+
fileType: 'requirements.txt',
|
|
708
|
+
intelligenceBonus,
|
|
709
|
+
detectedLanguage: 'Python',
|
|
710
|
+
detectedFramework: this.context.framework,
|
|
711
|
+
metadata,
|
|
712
|
+
category: 'package-manager-python'
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Process pyproject.toml
|
|
717
|
+
*/
|
|
718
|
+
async processPyProject(fileName, content) {
|
|
719
|
+
let intelligenceBonus = 70;
|
|
720
|
+
const metadata = {};
|
|
721
|
+
if (!this.context.mainLanguage) {
|
|
722
|
+
this.context.mainLanguage = 'Python';
|
|
723
|
+
}
|
|
724
|
+
// Check for Poetry
|
|
725
|
+
if (content.includes('[tool.poetry]')) {
|
|
726
|
+
if (!this.context.packageManager) {
|
|
727
|
+
this.context.packageManager = 'Poetry';
|
|
728
|
+
}
|
|
729
|
+
intelligenceBonus += 20;
|
|
730
|
+
metadata.poetry = true;
|
|
731
|
+
}
|
|
732
|
+
// Check for build system
|
|
733
|
+
if (content.includes('[build-system]')) {
|
|
734
|
+
intelligenceBonus += 15;
|
|
735
|
+
metadata.modernBuild = true;
|
|
736
|
+
}
|
|
737
|
+
// Extract project name
|
|
738
|
+
const nameMatch = content.match(/name\s*=\s*"([^"]+)"/);
|
|
739
|
+
if (nameMatch && !this.context.projectName) {
|
|
740
|
+
this.context.projectName = nameMatch[1];
|
|
741
|
+
intelligenceBonus += 10;
|
|
742
|
+
}
|
|
743
|
+
// Extract description
|
|
744
|
+
const descMatch = content.match(/description\s*=\s*"([^"]+)"/);
|
|
745
|
+
if (descMatch && !this.context.projectGoal) {
|
|
746
|
+
this.context.projectGoal = descMatch[1];
|
|
747
|
+
intelligenceBonus += 15;
|
|
748
|
+
}
|
|
749
|
+
return {
|
|
750
|
+
fileName,
|
|
751
|
+
fileType: 'pyproject.toml',
|
|
752
|
+
intelligenceBonus,
|
|
753
|
+
detectedLanguage: 'Python',
|
|
754
|
+
metadata,
|
|
755
|
+
category: 'package-manager-python-modern'
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Process Cargo.toml
|
|
760
|
+
*/
|
|
761
|
+
async processCargoToml(fileName, content) {
|
|
762
|
+
let intelligenceBonus = 70;
|
|
763
|
+
const metadata = {};
|
|
764
|
+
if (!this.context.mainLanguage) {
|
|
765
|
+
this.context.mainLanguage = 'Rust';
|
|
766
|
+
}
|
|
767
|
+
if (!this.context.packageManager) {
|
|
768
|
+
this.context.packageManager = 'Cargo';
|
|
769
|
+
}
|
|
770
|
+
// Extract project name
|
|
771
|
+
const nameMatch = content.match(/name\s*=\s*"([^"]+)"/);
|
|
772
|
+
if (nameMatch && !this.context.projectName) {
|
|
773
|
+
this.context.projectName = nameMatch[1];
|
|
774
|
+
intelligenceBonus += 10;
|
|
775
|
+
}
|
|
776
|
+
// Check for specific frameworks
|
|
777
|
+
if (!this.context.framework) {
|
|
778
|
+
if (content.includes('actix-web')) {
|
|
779
|
+
this.context.framework = 'Actix Web';
|
|
780
|
+
intelligenceBonus += 25;
|
|
781
|
+
}
|
|
782
|
+
else if (content.includes('rocket')) {
|
|
783
|
+
this.context.framework = 'Rocket';
|
|
784
|
+
intelligenceBonus += 25;
|
|
785
|
+
}
|
|
786
|
+
else if (content.includes('tokio')) {
|
|
787
|
+
this.context.framework = 'Tokio';
|
|
788
|
+
intelligenceBonus += 20;
|
|
789
|
+
}
|
|
790
|
+
else if (content.includes('axum')) {
|
|
791
|
+
this.context.framework = 'Axum';
|
|
792
|
+
intelligenceBonus += 25;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
// Count dependencies
|
|
796
|
+
const deps = content.match(/\[dependencies\]/g);
|
|
797
|
+
if (deps) {
|
|
798
|
+
metadata.hasDependencies = true;
|
|
799
|
+
intelligenceBonus += 15;
|
|
800
|
+
}
|
|
801
|
+
return {
|
|
802
|
+
fileName,
|
|
803
|
+
fileType: 'Cargo.toml',
|
|
804
|
+
intelligenceBonus,
|
|
805
|
+
detectedLanguage: 'Rust',
|
|
806
|
+
detectedFramework: this.context.framework,
|
|
807
|
+
metadata,
|
|
808
|
+
category: 'package-manager-rust'
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Process go.mod
|
|
813
|
+
*/
|
|
814
|
+
async processGoMod(fileName, content) {
|
|
815
|
+
let intelligenceBonus = 70;
|
|
816
|
+
const metadata = {};
|
|
817
|
+
if (!this.context.mainLanguage) {
|
|
818
|
+
this.context.mainLanguage = 'Go';
|
|
819
|
+
}
|
|
820
|
+
if (!this.context.packageManager) {
|
|
821
|
+
this.context.packageManager = 'Go Modules';
|
|
822
|
+
}
|
|
823
|
+
// Extract module name
|
|
824
|
+
const moduleMatch = content.match(/module\s+(\S+)/);
|
|
825
|
+
if (moduleMatch && !this.context.projectName) {
|
|
826
|
+
this.context.projectName = moduleMatch[1].split('/').pop();
|
|
827
|
+
intelligenceBonus += 10;
|
|
828
|
+
}
|
|
829
|
+
// Check for frameworks
|
|
830
|
+
if (!this.context.framework) {
|
|
831
|
+
if (content.includes('gin-gonic/gin')) {
|
|
832
|
+
this.context.framework = 'Gin';
|
|
833
|
+
intelligenceBonus += 25;
|
|
834
|
+
}
|
|
835
|
+
else if (content.includes('fiber')) {
|
|
836
|
+
this.context.framework = 'Fiber';
|
|
837
|
+
intelligenceBonus += 25;
|
|
838
|
+
}
|
|
839
|
+
else if (content.includes('echo')) {
|
|
840
|
+
this.context.framework = 'Echo';
|
|
841
|
+
intelligenceBonus += 25;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
// Count requirements
|
|
845
|
+
const requires = content.match(/require\s+\(/g);
|
|
846
|
+
if (requires) {
|
|
847
|
+
metadata.hasRequirements = true;
|
|
848
|
+
intelligenceBonus += 15;
|
|
849
|
+
}
|
|
850
|
+
return {
|
|
851
|
+
fileName,
|
|
852
|
+
fileType: 'go.mod',
|
|
853
|
+
intelligenceBonus,
|
|
854
|
+
detectedLanguage: 'Go',
|
|
855
|
+
detectedFramework: this.context.framework,
|
|
856
|
+
metadata,
|
|
857
|
+
category: 'package-manager-go'
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Process Maven pom.xml
|
|
862
|
+
*/
|
|
863
|
+
async processMavenPom(fileName, content) {
|
|
864
|
+
let intelligenceBonus = 70;
|
|
865
|
+
const metadata = {};
|
|
866
|
+
if (!this.context.mainLanguage) {
|
|
867
|
+
this.context.mainLanguage = 'Java';
|
|
868
|
+
}
|
|
869
|
+
if (!this.context.buildTool) {
|
|
870
|
+
this.context.buildTool = 'Maven';
|
|
871
|
+
}
|
|
872
|
+
// Check for Spring
|
|
873
|
+
if (!this.context.framework) {
|
|
874
|
+
if (content.includes('spring-boot')) {
|
|
875
|
+
this.context.framework = 'Spring Boot';
|
|
876
|
+
intelligenceBonus += 30;
|
|
877
|
+
}
|
|
878
|
+
else if (content.includes('spring-framework')) {
|
|
879
|
+
this.context.framework = 'Spring';
|
|
880
|
+
intelligenceBonus += 25;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
// Extract artifact ID as project name
|
|
884
|
+
const artifactMatch = content.match(/<artifactId>([^<]+)<\/artifactId>/);
|
|
885
|
+
if (artifactMatch && !this.context.projectName) {
|
|
886
|
+
this.context.projectName = artifactMatch[1];
|
|
887
|
+
intelligenceBonus += 10;
|
|
888
|
+
}
|
|
889
|
+
return {
|
|
890
|
+
fileName,
|
|
891
|
+
fileType: 'pom.xml',
|
|
892
|
+
intelligenceBonus,
|
|
893
|
+
detectedLanguage: 'Java',
|
|
894
|
+
detectedBuildTool: 'Maven',
|
|
895
|
+
detectedFramework: this.context.framework,
|
|
896
|
+
metadata,
|
|
897
|
+
category: 'package-manager-java'
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Process Gradle build file
|
|
902
|
+
*/
|
|
903
|
+
async processGradle(fileName, content) {
|
|
904
|
+
let intelligenceBonus = 70;
|
|
905
|
+
const metadata = {};
|
|
906
|
+
const isKotlin = fileName.endsWith('.kts');
|
|
907
|
+
if (!this.context.mainLanguage) {
|
|
908
|
+
this.context.mainLanguage = isKotlin ? 'Kotlin' : 'Java';
|
|
909
|
+
}
|
|
910
|
+
if (!this.context.buildTool) {
|
|
911
|
+
this.context.buildTool = 'Gradle';
|
|
912
|
+
}
|
|
913
|
+
// Check for frameworks
|
|
914
|
+
if (!this.context.framework) {
|
|
915
|
+
if (content.includes('spring-boot')) {
|
|
916
|
+
this.context.framework = 'Spring Boot';
|
|
917
|
+
intelligenceBonus += 30;
|
|
918
|
+
}
|
|
919
|
+
else if (content.includes('ktor')) {
|
|
920
|
+
this.context.framework = 'Ktor';
|
|
921
|
+
intelligenceBonus += 25;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
metadata.isKotlinDSL = isKotlin;
|
|
925
|
+
return {
|
|
926
|
+
fileName,
|
|
927
|
+
fileType: 'build.gradle',
|
|
928
|
+
intelligenceBonus,
|
|
929
|
+
detectedLanguage: this.context.mainLanguage,
|
|
930
|
+
detectedBuildTool: 'Gradle',
|
|
931
|
+
detectedFramework: this.context.framework,
|
|
932
|
+
metadata,
|
|
933
|
+
category: 'package-manager-gradle'
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* Process Gemfile
|
|
938
|
+
*/
|
|
939
|
+
async processGemfile(fileName, content) {
|
|
940
|
+
let intelligenceBonus = 60;
|
|
941
|
+
const metadata = {};
|
|
942
|
+
if (!this.context.mainLanguage) {
|
|
943
|
+
this.context.mainLanguage = 'Ruby';
|
|
944
|
+
}
|
|
945
|
+
if (!this.context.packageManager) {
|
|
946
|
+
this.context.packageManager = 'Bundler';
|
|
947
|
+
}
|
|
948
|
+
// Check for Rails
|
|
949
|
+
if (!this.context.framework) {
|
|
950
|
+
if (content.includes("gem 'rails'") || content.includes('gem "rails"')) {
|
|
951
|
+
this.context.framework = 'Ruby on Rails';
|
|
952
|
+
intelligenceBonus += 30;
|
|
953
|
+
}
|
|
954
|
+
else if (content.includes('sinatra')) {
|
|
955
|
+
this.context.framework = 'Sinatra';
|
|
956
|
+
intelligenceBonus += 20;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
return {
|
|
960
|
+
fileName,
|
|
961
|
+
fileType: 'Gemfile',
|
|
962
|
+
intelligenceBonus,
|
|
963
|
+
detectedLanguage: 'Ruby',
|
|
964
|
+
detectedFramework: this.context.framework,
|
|
965
|
+
metadata,
|
|
966
|
+
category: 'package-manager-ruby'
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Process composer.json
|
|
971
|
+
*/
|
|
972
|
+
async processComposer(fileName, content) {
|
|
973
|
+
let intelligenceBonus = 60;
|
|
974
|
+
const metadata = {};
|
|
975
|
+
if (!this.context.mainLanguage) {
|
|
976
|
+
this.context.mainLanguage = 'PHP';
|
|
977
|
+
}
|
|
978
|
+
if (!this.context.packageManager) {
|
|
979
|
+
this.context.packageManager = 'Composer';
|
|
980
|
+
}
|
|
981
|
+
try {
|
|
982
|
+
const composerData = JSON.parse(content);
|
|
983
|
+
// Check for frameworks
|
|
984
|
+
if (!this.context.framework) {
|
|
985
|
+
const requires = composerData.require || {};
|
|
986
|
+
if (requires['laravel/framework']) {
|
|
987
|
+
this.context.framework = 'Laravel';
|
|
988
|
+
intelligenceBonus += 30;
|
|
989
|
+
}
|
|
990
|
+
else if (requires['symfony/framework-bundle']) {
|
|
991
|
+
this.context.framework = 'Symfony';
|
|
992
|
+
intelligenceBonus += 30;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
// Extract name
|
|
996
|
+
if (composerData.name && !this.context.projectName) {
|
|
997
|
+
this.context.projectName = composerData.name.split('/').pop();
|
|
998
|
+
intelligenceBonus += 10;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
catch (err) {
|
|
1002
|
+
// Invalid JSON
|
|
1003
|
+
}
|
|
1004
|
+
return {
|
|
1005
|
+
fileName,
|
|
1006
|
+
fileType: 'composer.json',
|
|
1007
|
+
intelligenceBonus,
|
|
1008
|
+
detectedLanguage: 'PHP',
|
|
1009
|
+
detectedFramework: this.context.framework,
|
|
1010
|
+
metadata,
|
|
1011
|
+
category: 'package-manager-php'
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Process .faf file
|
|
1016
|
+
*/
|
|
1017
|
+
async processFafFile(fileName, content) {
|
|
1018
|
+
let intelligenceBonus = 100; // FAF files are high value!
|
|
1019
|
+
const metadata = {};
|
|
1020
|
+
try {
|
|
1021
|
+
const fafData = JSON.parse(content);
|
|
1022
|
+
// Extract all context from FAF
|
|
1023
|
+
if (fafData.project?.name && !this.context.projectName) {
|
|
1024
|
+
this.context.projectName = fafData.project.name;
|
|
1025
|
+
}
|
|
1026
|
+
if (fafData.project?.goal && !this.context.projectGoal) {
|
|
1027
|
+
this.context.projectGoal = fafData.project.goal;
|
|
1028
|
+
}
|
|
1029
|
+
if (fafData.project?.main_language && !this.context.mainLanguage) {
|
|
1030
|
+
this.context.mainLanguage = fafData.project.main_language;
|
|
1031
|
+
}
|
|
1032
|
+
if (fafData.stack?.frontend && !this.context.framework) {
|
|
1033
|
+
this.context.framework = fafData.stack.frontend;
|
|
1034
|
+
}
|
|
1035
|
+
if (fafData.stack?.backend && !this.context.backend) {
|
|
1036
|
+
this.context.backend = fafData.stack.backend;
|
|
1037
|
+
}
|
|
1038
|
+
if (fafData.stack?.database && !this.context.database) {
|
|
1039
|
+
this.context.database = fafData.stack.database;
|
|
1040
|
+
}
|
|
1041
|
+
// Extract human context
|
|
1042
|
+
if (fafData.human?.who && !this.context.targetUser) {
|
|
1043
|
+
this.context.targetUser = fafData.human.who;
|
|
1044
|
+
}
|
|
1045
|
+
if (fafData.human?.what && !this.context.coreProblem) {
|
|
1046
|
+
this.context.coreProblem = fafData.human.what;
|
|
1047
|
+
}
|
|
1048
|
+
if (fafData.human?.why && !this.context.missionPurpose) {
|
|
1049
|
+
this.context.missionPurpose = fafData.human.why;
|
|
1050
|
+
}
|
|
1051
|
+
metadata.hasFafContext = true;
|
|
1052
|
+
metadata.version = fafData.version;
|
|
1053
|
+
}
|
|
1054
|
+
catch (err) {
|
|
1055
|
+
intelligenceBonus = 50;
|
|
1056
|
+
metadata.error = 'Invalid FAF JSON';
|
|
1057
|
+
}
|
|
1058
|
+
return {
|
|
1059
|
+
fileName,
|
|
1060
|
+
fileType: '.faf',
|
|
1061
|
+
intelligenceBonus,
|
|
1062
|
+
metadata,
|
|
1063
|
+
category: 'faf-context'
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* Process Dockerfile
|
|
1068
|
+
*/
|
|
1069
|
+
async processDockerfile(fileName, content) {
|
|
1070
|
+
let intelligenceBonus = 60;
|
|
1071
|
+
const metadata = {};
|
|
1072
|
+
// Detect base image language
|
|
1073
|
+
if (!this.context.mainLanguage) {
|
|
1074
|
+
if (content.includes('FROM node:') || content.includes('FROM node ')) {
|
|
1075
|
+
this.context.mainLanguage = 'JavaScript';
|
|
1076
|
+
}
|
|
1077
|
+
else if (content.includes('FROM python:')) {
|
|
1078
|
+
this.context.mainLanguage = 'Python';
|
|
1079
|
+
}
|
|
1080
|
+
else if (content.includes('FROM rust:')) {
|
|
1081
|
+
this.context.mainLanguage = 'Rust';
|
|
1082
|
+
}
|
|
1083
|
+
else if (content.includes('FROM golang:')) {
|
|
1084
|
+
this.context.mainLanguage = 'Go';
|
|
1085
|
+
}
|
|
1086
|
+
else if (content.includes('FROM openjdk:') || content.includes('FROM amazoncorretto:')) {
|
|
1087
|
+
this.context.mainLanguage = 'Java';
|
|
1088
|
+
}
|
|
1089
|
+
else if (content.includes('FROM ruby:')) {
|
|
1090
|
+
this.context.mainLanguage = 'Ruby';
|
|
1091
|
+
}
|
|
1092
|
+
else if (content.includes('FROM php:')) {
|
|
1093
|
+
this.context.mainLanguage = 'PHP';
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
// Check for deployment indicators
|
|
1097
|
+
if (content.includes('EXPOSE')) {
|
|
1098
|
+
metadata.hasExpose = true;
|
|
1099
|
+
intelligenceBonus += 10;
|
|
1100
|
+
}
|
|
1101
|
+
// Multi-stage build (indicates production readiness)
|
|
1102
|
+
if (content.includes('FROM') && content.split('FROM').length > 2) {
|
|
1103
|
+
metadata.multiStage = true;
|
|
1104
|
+
intelligenceBonus += 20;
|
|
1105
|
+
}
|
|
1106
|
+
return {
|
|
1107
|
+
fileName,
|
|
1108
|
+
fileType: 'Dockerfile',
|
|
1109
|
+
intelligenceBonus,
|
|
1110
|
+
metadata,
|
|
1111
|
+
category: 'docker-config'
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Process docker-compose
|
|
1116
|
+
*/
|
|
1117
|
+
async processDockerCompose(fileName, content) {
|
|
1118
|
+
let intelligenceBonus = 70;
|
|
1119
|
+
const metadata = {};
|
|
1120
|
+
// Check for databases
|
|
1121
|
+
if (!this.context.database) {
|
|
1122
|
+
if (content.includes('postgres:') || content.includes('postgresql:')) {
|
|
1123
|
+
this.context.database = 'PostgreSQL';
|
|
1124
|
+
}
|
|
1125
|
+
else if (content.includes('mysql:') || content.includes('mariadb:')) {
|
|
1126
|
+
this.context.database = 'MySQL';
|
|
1127
|
+
}
|
|
1128
|
+
else if (content.includes('mongo:') || content.includes('mongodb:')) {
|
|
1129
|
+
this.context.database = 'MongoDB';
|
|
1130
|
+
}
|
|
1131
|
+
else if (content.includes('redis:')) {
|
|
1132
|
+
this.context.database = 'Redis';
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
// Count services
|
|
1136
|
+
const services = content.match(/^\s{2}\w+:/gm);
|
|
1137
|
+
if (services) {
|
|
1138
|
+
metadata.serviceCount = services.length;
|
|
1139
|
+
intelligenceBonus += services.length * 10;
|
|
1140
|
+
}
|
|
1141
|
+
return {
|
|
1142
|
+
fileName,
|
|
1143
|
+
fileType: 'docker-compose',
|
|
1144
|
+
intelligenceBonus,
|
|
1145
|
+
metadata,
|
|
1146
|
+
category: 'docker-compose-config'
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Process .env files
|
|
1151
|
+
*/
|
|
1152
|
+
async processEnvFile(fileName, content) {
|
|
1153
|
+
let intelligenceBonus = 40;
|
|
1154
|
+
const metadata = {};
|
|
1155
|
+
// Database detection
|
|
1156
|
+
if (content.includes('DATABASE_URL') || content.includes('DB_')) {
|
|
1157
|
+
intelligenceBonus += 20;
|
|
1158
|
+
if (content.includes('postgresql://') || content.includes('postgres://')) {
|
|
1159
|
+
if (!this.context.database)
|
|
1160
|
+
this.context.database = 'PostgreSQL';
|
|
1161
|
+
}
|
|
1162
|
+
else if (content.includes('mysql://')) {
|
|
1163
|
+
if (!this.context.database)
|
|
1164
|
+
this.context.database = 'MySQL';
|
|
1165
|
+
}
|
|
1166
|
+
else if (content.includes('mongodb://')) {
|
|
1167
|
+
if (!this.context.database)
|
|
1168
|
+
this.context.database = 'MongoDB';
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
// Hosting detection
|
|
1172
|
+
if (content.includes('VERCEL_')) {
|
|
1173
|
+
if (!this.context.hosting)
|
|
1174
|
+
this.context.hosting = 'Vercel';
|
|
1175
|
+
intelligenceBonus += 10;
|
|
1176
|
+
}
|
|
1177
|
+
else if (content.includes('NETLIFY_')) {
|
|
1178
|
+
if (!this.context.hosting)
|
|
1179
|
+
this.context.hosting = 'Netlify';
|
|
1180
|
+
intelligenceBonus += 10;
|
|
1181
|
+
}
|
|
1182
|
+
else if (content.includes('RAILWAY_')) {
|
|
1183
|
+
if (!this.context.hosting)
|
|
1184
|
+
this.context.hosting = 'Railway';
|
|
1185
|
+
intelligenceBonus += 10;
|
|
1186
|
+
}
|
|
1187
|
+
// API detection
|
|
1188
|
+
if (content.includes('STRIPE_') || content.includes('PAYPAL_')) {
|
|
1189
|
+
metadata.hasPaymentAPI = true;
|
|
1190
|
+
intelligenceBonus += 20;
|
|
1191
|
+
}
|
|
1192
|
+
if (content.includes('JWT_') || content.includes('AUTH0_')) {
|
|
1193
|
+
metadata.hasAuthAPI = true;
|
|
1194
|
+
intelligenceBonus += 15;
|
|
1195
|
+
}
|
|
1196
|
+
if (content.includes('AWS_') || content.includes('S3_')) {
|
|
1197
|
+
metadata.hasCloudStorage = true;
|
|
1198
|
+
intelligenceBonus += 15;
|
|
1199
|
+
}
|
|
1200
|
+
return {
|
|
1201
|
+
fileName,
|
|
1202
|
+
fileType: '.env',
|
|
1203
|
+
intelligenceBonus,
|
|
1204
|
+
metadata,
|
|
1205
|
+
category: 'environment'
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Generic file processor (fallback)
|
|
1210
|
+
*/
|
|
1211
|
+
async processGenericFile(fileName, content) {
|
|
1212
|
+
let intelligenceBonus = 10;
|
|
1213
|
+
const metadata = {};
|
|
1214
|
+
metadata.fileSize = content.length;
|
|
1215
|
+
metadata.lineCount = content.split('\n').length;
|
|
1216
|
+
return {
|
|
1217
|
+
fileName,
|
|
1218
|
+
fileType: path.extname(fileName) || 'unknown',
|
|
1219
|
+
intelligenceBonus,
|
|
1220
|
+
metadata,
|
|
1221
|
+
category: 'generic'
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Update context with results
|
|
1226
|
+
*/
|
|
1227
|
+
updateContext(result) {
|
|
1228
|
+
if (result.detectedFramework && !this.context.framework) {
|
|
1229
|
+
this.context.framework = result.detectedFramework;
|
|
1230
|
+
}
|
|
1231
|
+
if (result.detectedLanguage && !this.context.mainLanguage) {
|
|
1232
|
+
this.context.mainLanguage = result.detectedLanguage;
|
|
1233
|
+
}
|
|
1234
|
+
if (result.detectedBuildTool && !this.context.buildTool) {
|
|
1235
|
+
this.context.buildTool = result.detectedBuildTool;
|
|
1236
|
+
}
|
|
1237
|
+
if (result.detectedHosting && !this.context.hosting) {
|
|
1238
|
+
this.context.hosting = result.detectedHosting;
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Calculate intelligence depth
|
|
1243
|
+
*/
|
|
1244
|
+
calculateDepth() {
|
|
1245
|
+
let depth = 0;
|
|
1246
|
+
// Technical context (15 possible)
|
|
1247
|
+
const technicalFields = [
|
|
1248
|
+
'projectName', 'projectGoal', 'mainLanguage', 'framework',
|
|
1249
|
+
'backend', 'server', 'apiType', 'database', 'connection',
|
|
1250
|
+
'hosting', 'cicd', 'buildTool', 'packageManager', 'testFramework', 'linter'
|
|
1251
|
+
];
|
|
1252
|
+
technicalFields.forEach(field => {
|
|
1253
|
+
if (this.context[field])
|
|
1254
|
+
depth++;
|
|
1255
|
+
});
|
|
1256
|
+
// Human context (6 possible)
|
|
1257
|
+
const humanFields = [
|
|
1258
|
+
'targetUser', 'coreProblem', 'missionPurpose',
|
|
1259
|
+
'deploymentMarket', 'timeline', 'approach'
|
|
1260
|
+
];
|
|
1261
|
+
humanFields.forEach(field => {
|
|
1262
|
+
if (this.context[field])
|
|
1263
|
+
depth++;
|
|
1264
|
+
});
|
|
1265
|
+
// Return percentage (21 total slots)
|
|
1266
|
+
return Math.round((depth / 21) * 100);
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
exports.FabFormatsProcessor = FabFormatsProcessor;
|
|
1270
|
+
/**
|
|
1271
|
+
* Export singleton instance for CLI usage
|
|
1272
|
+
*/
|
|
1273
|
+
exports.fabFormatsProcessor = new FabFormatsProcessor();
|
|
1274
|
+
//# sourceMappingURL=fab-formats-processor.js.map
|