faf-cli 4.2.2 → 4.3.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/README.md +266 -90
- package/assets/project-faf-screenshot.png +0 -0
- package/dist/commands/git.d.ts.map +1 -1
- package/dist/commands/git.js +9 -7
- package/dist/commands/git.js.map +1 -1
- package/dist/github/current-score-calculator.d.ts +15 -0
- package/dist/github/current-score-calculator.d.ts.map +1 -0
- package/dist/github/current-score-calculator.js +125 -0
- package/dist/github/current-score-calculator.js.map +1 -0
- package/dist/github/faf-git-generator.d.ts +58 -0
- package/dist/github/faf-git-generator.d.ts.map +1 -0
- package/dist/github/faf-git-generator.js +557 -0
- package/dist/github/faf-git-generator.js.map +1 -0
- package/dist/github/github-extractor.d.ts +4 -0
- package/dist/github/github-extractor.d.ts.map +1 -1
- package/dist/github/github-extractor.js +27 -0
- package/dist/github/github-extractor.js.map +1 -1
- package/dist/github/repo-selector.d.ts +2 -2
- package/dist/github/repo-selector.d.ts.map +1 -1
- package/dist/github/repo-selector.js +30 -23
- package/dist/github/repo-selector.js.map +1 -1
- package/dist/utils/slot-counter.d.ts +56 -0
- package/dist/utils/slot-counter.d.ts.map +1 -0
- package/dist/utils/slot-counter.js +100 -0
- package/dist/utils/slot-counter.js.map +1 -0
- package/dist/utils/yaml-generator.d.ts.map +1 -1
- package/dist/utils/yaml-generator.js +3 -7
- package/dist/utils/yaml-generator.js.map +1 -1
- package/package.json +3 -1
- package/project.faf +5 -9
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 🏆 Current Score Calculator
|
|
4
|
+
*
|
|
5
|
+
* Calculates AI-readiness score for repos AS THEY ARE (before FAF enhancement)
|
|
6
|
+
*
|
|
7
|
+
* Strategy:
|
|
8
|
+
* - Check if .faf exists → score it
|
|
9
|
+
* - No .faf → calculate baseline from README + package.json
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.calculateCurrentScore = calculateCurrentScore;
|
|
13
|
+
const github_extractor_1 = require("./github-extractor");
|
|
14
|
+
/**
|
|
15
|
+
* Calculate current score (repo as-is, before FAF generation)
|
|
16
|
+
*/
|
|
17
|
+
async function calculateCurrentScore(metadata, files) {
|
|
18
|
+
// Check if repo has existing .faf file
|
|
19
|
+
const hasFaf = files.some(f => f.path === 'project.faf' ||
|
|
20
|
+
f.path === '.faf' ||
|
|
21
|
+
f.path.endsWith('.faf'));
|
|
22
|
+
if (hasFaf) {
|
|
23
|
+
// Repo has .faf - score it
|
|
24
|
+
try {
|
|
25
|
+
const fafFile = files.find(f => f.path === 'project.faf' || f.path === '.faf');
|
|
26
|
+
if (fafFile) {
|
|
27
|
+
const fafContent = await (0, github_extractor_1.fetchGitHubFileContent)(metadata.owner, metadata.repo, fafFile.path, metadata.defaultBranch || 'main');
|
|
28
|
+
if (fafContent) {
|
|
29
|
+
return scoreFafContent(fafContent);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
// Fallback to baseline if can't fetch .faf
|
|
35
|
+
console.error('Failed to fetch existing .faf:', error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// No .faf file - calculate baseline score from available data
|
|
39
|
+
return calculateBaselineScore(metadata, files);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Score existing .faf content (simplified version)
|
|
43
|
+
*/
|
|
44
|
+
function scoreFafContent(fafContent) {
|
|
45
|
+
let score = 0;
|
|
46
|
+
// Basic presence checks (10 points each, max 60)
|
|
47
|
+
const checks = [
|
|
48
|
+
{ pattern: /project:/i, points: 10 },
|
|
49
|
+
{ pattern: /stack:/i, points: 10 },
|
|
50
|
+
{ pattern: /human_context:/i, points: 10 },
|
|
51
|
+
{ pattern: /ai_instructions:/i, points: 10 },
|
|
52
|
+
{ pattern: /what:/i, points: 10 },
|
|
53
|
+
{ pattern: /why:/i, points: 10 },
|
|
54
|
+
];
|
|
55
|
+
for (const check of checks) {
|
|
56
|
+
if (check.pattern.test(fafContent)) {
|
|
57
|
+
score += check.points;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Quality indicators (5 points each, max 40)
|
|
61
|
+
const qualityChecks = [
|
|
62
|
+
{ pattern: /name:\s*\S+/, points: 5 },
|
|
63
|
+
{ pattern: /goal:\s*\S+/, points: 5 },
|
|
64
|
+
{ pattern: /main_language:\s*\S+/, points: 5 },
|
|
65
|
+
{ pattern: /type:\s*\S+/, points: 5 },
|
|
66
|
+
{ pattern: /who:\s*\S+/, points: 5 },
|
|
67
|
+
{ pattern: /where:\s*\S+/, points: 5 },
|
|
68
|
+
{ pattern: /when:\s*\S+/, points: 5 },
|
|
69
|
+
{ pattern: /how:\s*\S+/, points: 5 },
|
|
70
|
+
];
|
|
71
|
+
for (const check of qualityChecks) {
|
|
72
|
+
if (check.pattern.test(fafContent)) {
|
|
73
|
+
score += check.points;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return Math.min(score, 100);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Calculate baseline score from README + package.json (no .faf)
|
|
80
|
+
*/
|
|
81
|
+
function calculateBaselineScore(metadata, files) {
|
|
82
|
+
let score = 0;
|
|
83
|
+
// Has README (+10)
|
|
84
|
+
if (metadata.readme || files.some(f => f.path.toLowerCase().includes('readme'))) {
|
|
85
|
+
score += 10;
|
|
86
|
+
}
|
|
87
|
+
// Has package.json (+10)
|
|
88
|
+
if (metadata.hasPackageJson) {
|
|
89
|
+
score += 10;
|
|
90
|
+
}
|
|
91
|
+
// Has description (+5)
|
|
92
|
+
if (metadata.description && metadata.description.length > 20) {
|
|
93
|
+
score += 5;
|
|
94
|
+
}
|
|
95
|
+
// Has topics/tags (+5)
|
|
96
|
+
if (metadata.topics && metadata.topics.length > 0) {
|
|
97
|
+
score += 5;
|
|
98
|
+
}
|
|
99
|
+
// Popular repo (+5 for 1K+ stars)
|
|
100
|
+
const stars = parseInt(metadata.stars || '0');
|
|
101
|
+
if (stars >= 1000) {
|
|
102
|
+
score += 5;
|
|
103
|
+
}
|
|
104
|
+
// Has license (+5)
|
|
105
|
+
if (metadata.license) {
|
|
106
|
+
score += 5;
|
|
107
|
+
}
|
|
108
|
+
// Recently updated (+5 for < 90 days)
|
|
109
|
+
if (metadata.lastUpdated) {
|
|
110
|
+
const lastUpdate = new Date(metadata.lastUpdated);
|
|
111
|
+
const now = new Date();
|
|
112
|
+
const daysSinceUpdate = (now.getTime() - lastUpdate.getTime()) / (1000 * 60 * 60 * 24);
|
|
113
|
+
if (daysSinceUpdate < 90) {
|
|
114
|
+
score += 5;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Has multiple languages (+5)
|
|
118
|
+
if (metadata.languages && metadata.languages.length > 1) {
|
|
119
|
+
score += 5;
|
|
120
|
+
}
|
|
121
|
+
// Baseline repos typically score 20-50%
|
|
122
|
+
// This is intentionally low to show FAF's value
|
|
123
|
+
return Math.min(score, 50);
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=current-score-calculator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-score-calculator.js","sourceRoot":"","sources":["../../src/github/current-score-calculator.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAQH,sDAkCC;AAvCD,yDAA4D;AAE5D;;GAEG;AACI,KAAK,UAAU,qBAAqB,CACzC,QAAwB,EACxB,KAAY;IAEZ,uCAAuC;IACvC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAC5B,CAAC,CAAC,IAAI,KAAK,aAAa;QACxB,CAAC,CAAC,IAAI,KAAK,MAAM;QACjB,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CACxB,CAAC;IAEF,IAAI,MAAM,EAAE,CAAC;QACX,2BAA2B;QAC3B,IAAI,CAAC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CAAC,CAAC;IACb,CAAC;IAED,wCAAwC;IACxC,gDAAgD;IAChD,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🏆 Enhanced FAF Generation for `faf git`
|
|
3
|
+
*
|
|
4
|
+
* Generates 90%+ AI-ready .faf files from GitHub repos WITHOUT cloning
|
|
5
|
+
*
|
|
6
|
+
* Strategy:
|
|
7
|
+
* 1. Fetch README.md → Extract 6 Ws (+30%)
|
|
8
|
+
* 2. Fetch package.json → Deep stack analysis (+15%)
|
|
9
|
+
* 3. Full FAF schema → Match faf-cli init (+20%)
|
|
10
|
+
* 4. Smart defaults → AI instructions, project type (+15%)
|
|
11
|
+
* 5. Enhanced scoring → Championship grade (+10%)
|
|
12
|
+
*/
|
|
13
|
+
import type { GitHubMetadata } from './github-extractor';
|
|
14
|
+
export interface Enhanced6Ws {
|
|
15
|
+
who: string;
|
|
16
|
+
what: string;
|
|
17
|
+
why: string;
|
|
18
|
+
where: string;
|
|
19
|
+
when: string;
|
|
20
|
+
how: string;
|
|
21
|
+
confidence: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Extract 6 Ws from README content (simplified version for git command)
|
|
25
|
+
*/
|
|
26
|
+
export declare function extract6WsFromReadme(readme: string, metadata: GitHubMetadata): Enhanced6Ws;
|
|
27
|
+
/**
|
|
28
|
+
* Enhanced stack detection from package.json
|
|
29
|
+
*/
|
|
30
|
+
export interface StackAnalysis {
|
|
31
|
+
frontend?: string;
|
|
32
|
+
backend?: string;
|
|
33
|
+
database?: string;
|
|
34
|
+
testing?: string;
|
|
35
|
+
buildTool?: string;
|
|
36
|
+
runtime?: string;
|
|
37
|
+
language?: string;
|
|
38
|
+
hosting?: string;
|
|
39
|
+
frameworks: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Extract stack from GH API languages array
|
|
43
|
+
* This is the SOURCE OF TRUTH from GitHub - trust it!
|
|
44
|
+
*/
|
|
45
|
+
export declare function extractFromLanguages(metadata: GitHubMetadata): StackAnalysis;
|
|
46
|
+
export declare function analyzePackageJson(packageJson: any, metadata: GitHubMetadata): StackAnalysis;
|
|
47
|
+
/**
|
|
48
|
+
* Calculate enhanced quality score (targeting 90%+)
|
|
49
|
+
*/
|
|
50
|
+
export declare function calculateEnhancedScore(metadata: GitHubMetadata, has6Ws: boolean, hasPackageJson: boolean, hasReadme: boolean): number;
|
|
51
|
+
/**
|
|
52
|
+
* Generate full FAF structure (matching faf-cli init output)
|
|
53
|
+
*/
|
|
54
|
+
export declare function generateEnhancedFaf(metadata: GitHubMetadata, files: any[]): Promise<{
|
|
55
|
+
content: string;
|
|
56
|
+
score: number;
|
|
57
|
+
}>;
|
|
58
|
+
//# sourceMappingURL=faf-git-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"faf-git-generator.d.ts","sourceRoot":"","sources":["../../src/github/faf-git-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAKzD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,WAAW,CA+E1F;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,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