faf-cli 3.0.0 ā 3.0.2
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 +134 -78
- package/dist/commands/auto.d.ts.map +1 -1
- package/dist/commands/auto.js +102 -0
- package/dist/commands/auto.js.map +1 -1
- package/dist/compiler/faf-compiler.d.ts.map +1 -1
- package/dist/compiler/faf-compiler.js +76 -4
- package/dist/compiler/faf-compiler.js.map +1 -1
- package/dist/core/platform-adapters.d.ts +76 -0
- package/dist/core/platform-adapters.d.ts.map +1 -0
- package/dist/core/platform-adapters.js +407 -0
- package/dist/core/platform-adapters.js.map +1 -0
- package/dist/core/universal-intelligence-generator.d.ts +156 -0
- package/dist/core/universal-intelligence-generator.d.ts.map +1 -0
- package/dist/core/universal-intelligence-generator.js +352 -0
- package/dist/core/universal-intelligence-generator.js.map +1 -0
- package/dist/tests/manual-validation.d.ts +8 -0
- package/dist/tests/manual-validation.d.ts.map +1 -0
- package/dist/tests/manual-validation.js +114 -0
- package/dist/tests/manual-validation.js.map +1 -0
- package/dist/utils/file-utils.d.ts +38 -0
- package/dist/utils/file-utils.d.ts.map +1 -1
- package/dist/utils/file-utils.js +148 -0
- package/dist/utils/file-utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* š UNIVERSAL INTELLIGENCE GENERATOR
|
|
3
|
+
*
|
|
4
|
+
* THE foundational pattern that applies to EVERYTHING:
|
|
5
|
+
* - Code projects (package.json, tsconfig, etc.)
|
|
6
|
+
* - Automation workflows (n8n, Make, Opal, OpenAI)
|
|
7
|
+
* - Documentation centers (markdown, wikis)
|
|
8
|
+
* - API specifications (OpenAPI, GraphQL)
|
|
9
|
+
* - ANY project that needs AI context
|
|
10
|
+
*
|
|
11
|
+
* Pattern: interrogation ā extraction ā filtering ā generation
|
|
12
|
+
* Output: ALWAYS .faf (universal container for structured intelligence)
|
|
13
|
+
*
|
|
14
|
+
* FOUNDATIONAL FIRST, UNIVERSAL BY DEFAULT
|
|
15
|
+
*/
|
|
16
|
+
export interface IntelligenceSource {
|
|
17
|
+
type: SourceType;
|
|
18
|
+
filePath: string;
|
|
19
|
+
metadata?: Record<string, any>;
|
|
20
|
+
}
|
|
21
|
+
export type SourceType = 'code-project' | 'n8n-workflow' | 'make-scenario' | 'opal-miniapp' | 'openai-assistant' | 'documentation' | 'api-spec' | 'custom';
|
|
22
|
+
export interface RawIntelligence {
|
|
23
|
+
data: any;
|
|
24
|
+
confidence: number;
|
|
25
|
+
metadata: {
|
|
26
|
+
source_type: SourceType;
|
|
27
|
+
source_file: string;
|
|
28
|
+
extracted_at: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface StructuredIntelligence {
|
|
32
|
+
project: {
|
|
33
|
+
name: string;
|
|
34
|
+
type: string;
|
|
35
|
+
goal: string;
|
|
36
|
+
main_language?: string;
|
|
37
|
+
};
|
|
38
|
+
architecture?: {
|
|
39
|
+
pattern: string;
|
|
40
|
+
components: string[];
|
|
41
|
+
};
|
|
42
|
+
tech_stack?: Record<string, string>;
|
|
43
|
+
human_context: {
|
|
44
|
+
who: string;
|
|
45
|
+
what: string;
|
|
46
|
+
why: string;
|
|
47
|
+
where: string;
|
|
48
|
+
when: string;
|
|
49
|
+
how: string;
|
|
50
|
+
};
|
|
51
|
+
source_data?: any;
|
|
52
|
+
scores: {
|
|
53
|
+
faf_score: number;
|
|
54
|
+
ai_compatibility_score: number;
|
|
55
|
+
completeness_score: number;
|
|
56
|
+
};
|
|
57
|
+
generated: string;
|
|
58
|
+
faf_version: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Base class implementing the universal pattern
|
|
62
|
+
*
|
|
63
|
+
* All input adapters (n8n, Make, Opal, etc.) extend this
|
|
64
|
+
*/
|
|
65
|
+
export declare abstract class UniversalIntelligenceGenerator {
|
|
66
|
+
/**
|
|
67
|
+
* PHASE 1: INTERROGATION
|
|
68
|
+
*
|
|
69
|
+
* "What is this? What type of intelligence source?"
|
|
70
|
+
*
|
|
71
|
+
* Detects the input type and determines if we can process it
|
|
72
|
+
*/
|
|
73
|
+
abstract detect(filePath: string): Promise<boolean>;
|
|
74
|
+
/**
|
|
75
|
+
* PHASE 2: EXTRACTION
|
|
76
|
+
*
|
|
77
|
+
* "Pull the raw intelligence from the source"
|
|
78
|
+
*
|
|
79
|
+
* Platform-specific parsing happens here
|
|
80
|
+
* Output is raw, unstructured data
|
|
81
|
+
*/
|
|
82
|
+
abstract extract(filePath: string): Promise<RawIntelligence>;
|
|
83
|
+
/**
|
|
84
|
+
* PHASE 3: FILTERING
|
|
85
|
+
*
|
|
86
|
+
* "Transform raw data ā structured intelligence"
|
|
87
|
+
* "Validate, score, enrich"
|
|
88
|
+
*
|
|
89
|
+
* This is where POOR ā RICH transformation happens:
|
|
90
|
+
* - Auto-correct typos
|
|
91
|
+
* - Fill missing context (6 W's)
|
|
92
|
+
* - Ask clarifying questions (minimal friction)
|
|
93
|
+
* - Calculate quality scores
|
|
94
|
+
*/
|
|
95
|
+
abstract filter(raw: RawIntelligence): Promise<StructuredIntelligence>;
|
|
96
|
+
/**
|
|
97
|
+
* PHASE 4: GENERATION
|
|
98
|
+
*
|
|
99
|
+
* "Output championship .faf"
|
|
100
|
+
*
|
|
101
|
+
* Converts structured intelligence ā YAML .faf file
|
|
102
|
+
* Target: 85%+ score (š„ Bronze or better)
|
|
103
|
+
*/
|
|
104
|
+
generate(intelligence: StructuredIntelligence): string;
|
|
105
|
+
/**
|
|
106
|
+
* THE COMPLETE FLOW
|
|
107
|
+
*
|
|
108
|
+
* Orchestrates all 4 phases
|
|
109
|
+
*/
|
|
110
|
+
process(filePath: string): Promise<string>;
|
|
111
|
+
/**
|
|
112
|
+
* Helper: Convert structured intelligence ā YAML
|
|
113
|
+
*/
|
|
114
|
+
protected toYAML(intelligence: StructuredIntelligence): string;
|
|
115
|
+
/**
|
|
116
|
+
* Helper: Calculate quality scores
|
|
117
|
+
*
|
|
118
|
+
* Used in FILTERING phase
|
|
119
|
+
*/
|
|
120
|
+
protected calculateScores(data: Partial<StructuredIntelligence>): {
|
|
121
|
+
faf_score: number;
|
|
122
|
+
ai_compatibility_score: number;
|
|
123
|
+
completeness_score: number;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Example: n8n Workflow Intelligence Generator
|
|
128
|
+
*
|
|
129
|
+
* Extends the universal pattern for n8n-specific processing
|
|
130
|
+
*/
|
|
131
|
+
export declare class N8nIntelligenceGenerator extends UniversalIntelligenceGenerator {
|
|
132
|
+
detect(filePath: string): Promise<boolean>;
|
|
133
|
+
extract(filePath: string): Promise<RawIntelligence>;
|
|
134
|
+
filter(raw: RawIntelligence): Promise<StructuredIntelligence>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Example: OpenAI Assistant Intelligence Generator
|
|
138
|
+
*
|
|
139
|
+
* Same universal pattern, different input adapter
|
|
140
|
+
*/
|
|
141
|
+
export declare class OpenAIAssistantGenerator extends UniversalIntelligenceGenerator {
|
|
142
|
+
detect(filePath: string): Promise<boolean>;
|
|
143
|
+
extract(filePath: string): Promise<RawIntelligence>;
|
|
144
|
+
filter(raw: RawIntelligence): Promise<StructuredIntelligence>;
|
|
145
|
+
private extractActions;
|
|
146
|
+
private extractTools;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Factory: Auto-detect and return appropriate generator
|
|
150
|
+
*/
|
|
151
|
+
export declare function createGenerator(filePath: string): Promise<UniversalIntelligenceGenerator | null>;
|
|
152
|
+
/**
|
|
153
|
+
* Main entry point: Process any file ā .faf
|
|
154
|
+
*/
|
|
155
|
+
export declare function generateFafFromAny(filePath: string): Promise<string>;
|
|
156
|
+
//# sourceMappingURL=universal-intelligence-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"universal-intelligence-generator.d.ts","sourceRoot":"","sources":["../../src/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,OAAO,CAAC,OAAO,CAAC;IAY1C,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAqBnD,MAAM,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAiDnE,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,YAAY;CAIrB;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC,CA4BtG;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ1E"}
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* š UNIVERSAL INTELLIGENCE GENERATOR
|
|
4
|
+
*
|
|
5
|
+
* THE foundational pattern that applies to EVERYTHING:
|
|
6
|
+
* - Code projects (package.json, tsconfig, etc.)
|
|
7
|
+
* - Automation workflows (n8n, Make, Opal, OpenAI)
|
|
8
|
+
* - Documentation centers (markdown, wikis)
|
|
9
|
+
* - API specifications (OpenAPI, GraphQL)
|
|
10
|
+
* - ANY project that needs AI context
|
|
11
|
+
*
|
|
12
|
+
* Pattern: interrogation ā extraction ā filtering ā generation
|
|
13
|
+
* Output: ALWAYS .faf (universal container for structured intelligence)
|
|
14
|
+
*
|
|
15
|
+
* FOUNDATIONAL FIRST, UNIVERSAL BY DEFAULT
|
|
16
|
+
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
+
var ownKeys = function(o) {
|
|
35
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
+
var ar = [];
|
|
37
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
return ownKeys(o);
|
|
41
|
+
};
|
|
42
|
+
return function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.OpenAIAssistantGenerator = exports.N8nIntelligenceGenerator = exports.UniversalIntelligenceGenerator = void 0;
|
|
52
|
+
exports.createGenerator = createGenerator;
|
|
53
|
+
exports.generateFafFromAny = generateFafFromAny;
|
|
54
|
+
/**
|
|
55
|
+
* Base class implementing the universal pattern
|
|
56
|
+
*
|
|
57
|
+
* All input adapters (n8n, Make, Opal, etc.) extend this
|
|
58
|
+
*/
|
|
59
|
+
class UniversalIntelligenceGenerator {
|
|
60
|
+
/**
|
|
61
|
+
* PHASE 4: GENERATION
|
|
62
|
+
*
|
|
63
|
+
* "Output championship .faf"
|
|
64
|
+
*
|
|
65
|
+
* Converts structured intelligence ā YAML .faf file
|
|
66
|
+
* Target: 85%+ score (š„ Bronze or better)
|
|
67
|
+
*/
|
|
68
|
+
generate(intelligence) {
|
|
69
|
+
// Universal YAML generation
|
|
70
|
+
return this.toYAML(intelligence);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* THE COMPLETE FLOW
|
|
74
|
+
*
|
|
75
|
+
* Orchestrates all 4 phases
|
|
76
|
+
*/
|
|
77
|
+
async process(filePath) {
|
|
78
|
+
// 1. INTERROGATION
|
|
79
|
+
const canProcess = await this.detect(filePath);
|
|
80
|
+
if (!canProcess) {
|
|
81
|
+
throw new Error(`Cannot process file: ${filePath}`);
|
|
82
|
+
}
|
|
83
|
+
// 2. EXTRACTION
|
|
84
|
+
const raw = await this.extract(filePath);
|
|
85
|
+
// 3. FILTERING
|
|
86
|
+
const structured = await this.filter(raw);
|
|
87
|
+
// 4. GENERATION
|
|
88
|
+
const fafContent = this.generate(structured);
|
|
89
|
+
return fafContent;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Helper: Convert structured intelligence ā YAML
|
|
93
|
+
*/
|
|
94
|
+
toYAML(intelligence) {
|
|
95
|
+
const yaml = require('yaml');
|
|
96
|
+
return yaml.stringify(intelligence);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Helper: Calculate quality scores
|
|
100
|
+
*
|
|
101
|
+
* Used in FILTERING phase
|
|
102
|
+
*/
|
|
103
|
+
calculateScores(data) {
|
|
104
|
+
// Count filled fields
|
|
105
|
+
let totalSlots = 0;
|
|
106
|
+
let filledSlots = 0;
|
|
107
|
+
// Project slots (required)
|
|
108
|
+
totalSlots += 3; // name, type, goal
|
|
109
|
+
if (data.project?.name)
|
|
110
|
+
filledSlots++;
|
|
111
|
+
if (data.project?.type)
|
|
112
|
+
filledSlots++;
|
|
113
|
+
if (data.project?.goal)
|
|
114
|
+
filledSlots++;
|
|
115
|
+
// Human context slots (6 W's - critical)
|
|
116
|
+
totalSlots += 6;
|
|
117
|
+
if (data.human_context?.who)
|
|
118
|
+
filledSlots++;
|
|
119
|
+
if (data.human_context?.what)
|
|
120
|
+
filledSlots++;
|
|
121
|
+
if (data.human_context?.why)
|
|
122
|
+
filledSlots++;
|
|
123
|
+
if (data.human_context?.where)
|
|
124
|
+
filledSlots++;
|
|
125
|
+
if (data.human_context?.when)
|
|
126
|
+
filledSlots++;
|
|
127
|
+
if (data.human_context?.how)
|
|
128
|
+
filledSlots++;
|
|
129
|
+
// Architecture slots (if applicable)
|
|
130
|
+
if (data.architecture) {
|
|
131
|
+
totalSlots += 2;
|
|
132
|
+
if (data.architecture.pattern)
|
|
133
|
+
filledSlots++;
|
|
134
|
+
if (data.architecture.components?.length)
|
|
135
|
+
filledSlots++;
|
|
136
|
+
}
|
|
137
|
+
// Tech stack slots (if applicable)
|
|
138
|
+
if (data.tech_stack && Object.keys(data.tech_stack).length > 0) {
|
|
139
|
+
totalSlots += Object.keys(data.tech_stack).length;
|
|
140
|
+
filledSlots += Object.values(data.tech_stack).filter(v => v).length;
|
|
141
|
+
}
|
|
142
|
+
const faf_score = Math.round((filledSlots / totalSlots) * 100);
|
|
143
|
+
return {
|
|
144
|
+
faf_score,
|
|
145
|
+
ai_compatibility_score: faf_score, // Aligned for now
|
|
146
|
+
completeness_score: faf_score, // Aligned for now
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.UniversalIntelligenceGenerator = UniversalIntelligenceGenerator;
|
|
151
|
+
/**
|
|
152
|
+
* Example: n8n Workflow Intelligence Generator
|
|
153
|
+
*
|
|
154
|
+
* Extends the universal pattern for n8n-specific processing
|
|
155
|
+
*/
|
|
156
|
+
class N8nIntelligenceGenerator extends UniversalIntelligenceGenerator {
|
|
157
|
+
async detect(filePath) {
|
|
158
|
+
// Check if file is n8n workflow JSON
|
|
159
|
+
const fs = await Promise.resolve().then(() => __importStar(require('fs/promises')));
|
|
160
|
+
try {
|
|
161
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
162
|
+
const json = JSON.parse(content);
|
|
163
|
+
return !!(json.nodes && json.connections);
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
async extract(filePath) {
|
|
170
|
+
// Use existing n8n analyzer (compiled in dist)
|
|
171
|
+
const { N8nWorkflowAnalyzer } = await Promise.resolve().then(() => __importStar(require('../../dist/enrichment/n8n-analyzer')));
|
|
172
|
+
const workflow = await N8nWorkflowAnalyzer.parse(filePath);
|
|
173
|
+
const pattern = N8nWorkflowAnalyzer.detectPattern(workflow);
|
|
174
|
+
return {
|
|
175
|
+
data: {
|
|
176
|
+
workflow,
|
|
177
|
+
pattern,
|
|
178
|
+
aiModels: N8nWorkflowAnalyzer.extractAIModels(workflow),
|
|
179
|
+
infrastructure: N8nWorkflowAnalyzer.extractInfrastructure(workflow),
|
|
180
|
+
triggers: N8nWorkflowAnalyzer.extractTriggers(workflow),
|
|
181
|
+
nodes: N8nWorkflowAnalyzer.groupNodes(workflow),
|
|
182
|
+
tools: N8nWorkflowAnalyzer.extractToolCapabilities(workflow),
|
|
183
|
+
decisionPoints: N8nWorkflowAnalyzer.extractDecisionPoints(workflow),
|
|
184
|
+
memory: N8nWorkflowAnalyzer.extractMemoryRequirements(workflow),
|
|
185
|
+
},
|
|
186
|
+
confidence: 95,
|
|
187
|
+
metadata: {
|
|
188
|
+
source_type: 'n8n-workflow',
|
|
189
|
+
source_file: filePath,
|
|
190
|
+
extracted_at: new Date().toISOString(),
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
async filter(raw) {
|
|
195
|
+
const { workflow, pattern, aiModels, infrastructure } = raw.data;
|
|
196
|
+
// Use existing n8n-faf-generator for RICH transformation
|
|
197
|
+
// This already does: questions ā auto-correct ā 6 W's filling
|
|
198
|
+
const { N8nFafGenerator } = await Promise.resolve().then(() => __importStar(require('../../dist/enrichment/n8n-faf-generator')));
|
|
199
|
+
const generator = new N8nFafGenerator();
|
|
200
|
+
// Generate full .faf (includes human context enrichment)
|
|
201
|
+
// NOTE: N8nFafGenerator.generate() returns FILE PATH, not content
|
|
202
|
+
const outputPath = await generator.generate({
|
|
203
|
+
workflowFile: raw.metadata.source_file,
|
|
204
|
+
quiet: true, // Quiet mode for tests
|
|
205
|
+
});
|
|
206
|
+
// Read the generated file
|
|
207
|
+
const fs = await Promise.resolve().then(() => __importStar(require('fs/promises')));
|
|
208
|
+
const fafYAML = await fs.readFile(outputPath, 'utf-8');
|
|
209
|
+
// Parse back to structured format
|
|
210
|
+
const yaml = require('yaml');
|
|
211
|
+
const structured = yaml.parse(fafYAML);
|
|
212
|
+
return structured;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
exports.N8nIntelligenceGenerator = N8nIntelligenceGenerator;
|
|
216
|
+
/**
|
|
217
|
+
* Example: OpenAI Assistant Intelligence Generator
|
|
218
|
+
*
|
|
219
|
+
* Same universal pattern, different input adapter
|
|
220
|
+
*/
|
|
221
|
+
class OpenAIAssistantGenerator extends UniversalIntelligenceGenerator {
|
|
222
|
+
async detect(filePath) {
|
|
223
|
+
// Detect OpenAI Assistant config (OpenAPI 3.1.0 schema)
|
|
224
|
+
const fs = await Promise.resolve().then(() => __importStar(require('fs/promises')));
|
|
225
|
+
try {
|
|
226
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
227
|
+
const json = JSON.parse(content);
|
|
228
|
+
return !!(json.openapi && json.paths);
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
async extract(filePath) {
|
|
235
|
+
// Parse OpenAPI schema
|
|
236
|
+
const fs = await Promise.resolve().then(() => __importStar(require('fs/promises')));
|
|
237
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
238
|
+
const schema = JSON.parse(content);
|
|
239
|
+
return {
|
|
240
|
+
data: {
|
|
241
|
+
schema,
|
|
242
|
+
actions: this.extractActions(schema),
|
|
243
|
+
tools: this.extractTools(schema),
|
|
244
|
+
},
|
|
245
|
+
confidence: 90,
|
|
246
|
+
metadata: {
|
|
247
|
+
source_type: 'openai-assistant',
|
|
248
|
+
source_file: filePath,
|
|
249
|
+
extracted_at: new Date().toISOString(),
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
async filter(raw) {
|
|
254
|
+
const { schema, actions, tools } = raw.data;
|
|
255
|
+
// Transform to universal .faf structure
|
|
256
|
+
const structured = {
|
|
257
|
+
project: {
|
|
258
|
+
name: schema.info?.title || 'OpenAI Assistant',
|
|
259
|
+
type: 'openai-assistant',
|
|
260
|
+
goal: schema.info?.description || 'AI assistant with custom actions',
|
|
261
|
+
},
|
|
262
|
+
architecture: {
|
|
263
|
+
pattern: 'AI Assistant',
|
|
264
|
+
components: actions.map((a) => a.name),
|
|
265
|
+
},
|
|
266
|
+
tech_stack: {
|
|
267
|
+
platform: 'OpenAI Assistants API',
|
|
268
|
+
schema_version: schema.openapi,
|
|
269
|
+
},
|
|
270
|
+
human_context: {
|
|
271
|
+
who: 'AI Assistant Developer',
|
|
272
|
+
what: schema.info?.title || 'OpenAI Assistant',
|
|
273
|
+
why: schema.info?.description || 'Custom AI assistant functionality',
|
|
274
|
+
where: 'OpenAI Platform',
|
|
275
|
+
when: 'Production',
|
|
276
|
+
how: `OpenAPI schema with ${actions.length} custom actions`,
|
|
277
|
+
},
|
|
278
|
+
source_data: raw.data,
|
|
279
|
+
scores: this.calculateScores({
|
|
280
|
+
project: {
|
|
281
|
+
name: schema.info?.title,
|
|
282
|
+
type: 'openai-assistant',
|
|
283
|
+
goal: schema.info?.description,
|
|
284
|
+
},
|
|
285
|
+
human_context: {
|
|
286
|
+
who: 'AI Assistant Developer',
|
|
287
|
+
what: schema.info?.title,
|
|
288
|
+
why: schema.info?.description,
|
|
289
|
+
where: 'OpenAI Platform',
|
|
290
|
+
when: 'Production',
|
|
291
|
+
how: `OpenAPI schema with ${actions.length} custom actions`,
|
|
292
|
+
},
|
|
293
|
+
}),
|
|
294
|
+
generated: new Date().toISOString(),
|
|
295
|
+
faf_version: '3.0.1',
|
|
296
|
+
};
|
|
297
|
+
return structured;
|
|
298
|
+
}
|
|
299
|
+
extractActions(schema) {
|
|
300
|
+
const actions = [];
|
|
301
|
+
for (const [path, methods] of Object.entries(schema.paths || {})) {
|
|
302
|
+
for (const [method, details] of Object.entries(methods)) {
|
|
303
|
+
actions.push({
|
|
304
|
+
name: details.operationId || `${method.toUpperCase()} ${path}`,
|
|
305
|
+
path,
|
|
306
|
+
method,
|
|
307
|
+
description: details.description,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return actions;
|
|
312
|
+
}
|
|
313
|
+
extractTools(schema) {
|
|
314
|
+
// Extract tool names from action IDs
|
|
315
|
+
return this.extractActions(schema).map(a => a.name);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
exports.OpenAIAssistantGenerator = OpenAIAssistantGenerator;
|
|
319
|
+
/**
|
|
320
|
+
* Factory: Auto-detect and return appropriate generator
|
|
321
|
+
*/
|
|
322
|
+
async function createGenerator(filePath) {
|
|
323
|
+
// Import all platform adapters
|
|
324
|
+
const { OpalMiniAppGenerator, MakeScenarioGenerator, CodeProjectGenerator, } = await Promise.resolve().then(() => __importStar(require('./platform-adapters')));
|
|
325
|
+
const generators = [
|
|
326
|
+
// Automation platforms
|
|
327
|
+
new N8nIntelligenceGenerator(),
|
|
328
|
+
new OpalMiniAppGenerator(),
|
|
329
|
+
new MakeScenarioGenerator(),
|
|
330
|
+
// AI assistants
|
|
331
|
+
new OpenAIAssistantGenerator(),
|
|
332
|
+
// Code projects (fallback)
|
|
333
|
+
new CodeProjectGenerator(),
|
|
334
|
+
];
|
|
335
|
+
for (const generator of generators) {
|
|
336
|
+
if (await generator.detect(filePath)) {
|
|
337
|
+
return generator;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Main entry point: Process any file ā .faf
|
|
344
|
+
*/
|
|
345
|
+
async function generateFafFromAny(filePath) {
|
|
346
|
+
const generator = await createGenerator(filePath);
|
|
347
|
+
if (!generator) {
|
|
348
|
+
throw new Error(`No generator found for file: ${filePath}`);
|
|
349
|
+
}
|
|
350
|
+
return generator.process(filePath);
|
|
351
|
+
}
|
|
352
|
+
//# sourceMappingURL=universal-intelligence-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"universal-intelligence-generator.js","sourceRoot":"","sources":["../../src/core/universal-intelligence-generator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsYH,0CA4BC;AAKD,gDAQC;AA5WD;;;;GAIG;AACH,MAAsB,8BAA8B;IAmClD;;;;;;;OAOG;IACH,QAAQ,CAAC,YAAoC;QAC3C,4BAA4B;QAC5B,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,QAAgB;QAC5B,mBAAmB;QACnB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,EAAE,CAAC,CAAC;QACtD,CAAC;QAED,gBAAgB;QAChB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEzC,eAAe;QACf,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAE1C,gBAAgB;QAChB,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAE7C,OAAO,UAAU,CA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AC;CACF;AAvGD,4DAuGC;AAED;;GAEG;AACI,KAAK,UAAU,eAAe,CAAC,QAAgB;IACpD,+BAA+B;IAC/B,MAAM,EACJ,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,GACrB,GAAG,wDAAa,qBAAqB,GAAC,CAAC;IAExC,MAAM,UAAU,GAAqC;QACnD,uBAAuB;QACvB,IAAI,wBAAwB,EAAE;QAC9B,IAAI,oBAAoB,EAAE;QAC1B,IAAI,qBAAqB,EAAE;QAE3B,gBAAgB;QAChB,IAAI,wBAAwB,EAAE;QAE9B,2BAA2B;QAC3B,IAAI,oBAAoB,EAAE;KAC3B,CAAC;IAEF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,MAAM,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrC,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,kBAAkB,CAAC,QAAgB;IACvD,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,CAAC;IAElD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,gCAAgC,QAAQ,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manual-validation.d.ts","sourceRoot":"","sources":["../../src/tests/manual-validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* š MANUAL VALIDATION SCRIPT
|
|
4
|
+
*
|
|
5
|
+
* Quick test to validate the universal pattern works with real data
|
|
6
|
+
* Run this to see the pattern in action!
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
const universal_intelligence_generator_1 = require("../core/universal-intelligence-generator");
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const fs = __importStar(require("fs/promises"));
|
|
45
|
+
async function main() {
|
|
46
|
+
console.log('šļø FAF Universal Intelligence Pattern - Manual Validation\n');
|
|
47
|
+
console.log('FOUNDATIONAL FIRST, UNIVERSAL BY DEFAULT\n');
|
|
48
|
+
console.log('ā'.repeat(60));
|
|
49
|
+
const testDataDir = path.join(__dirname, 'test-data');
|
|
50
|
+
// Test 1: n8n RAG Workflow
|
|
51
|
+
console.log('\nš Test 1: n8n RAG Support Bot Workflow');
|
|
52
|
+
console.log('ā'.repeat(60));
|
|
53
|
+
try {
|
|
54
|
+
const n8nFile = path.join(testDataDir, 'sample-n8n-rag-workflow.json');
|
|
55
|
+
const start1 = Date.now();
|
|
56
|
+
const faf1 = await (0, universal_intelligence_generator_1.generateFafFromAny)(n8nFile);
|
|
57
|
+
const duration1 = Date.now() - start1;
|
|
58
|
+
console.log('ā
SUCCESS');
|
|
59
|
+
console.log(`ā” Generated in ${duration1}ms`);
|
|
60
|
+
console.log('\n.faf Output (first 500 chars):');
|
|
61
|
+
console.log(faf1.substring(0, 500) + '...\n');
|
|
62
|
+
// Save output
|
|
63
|
+
await fs.writeFile(path.join(testDataDir, 'output-n8n.faf'), faf1);
|
|
64
|
+
console.log('š Saved to: output-n8n.faf');
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.log('ā FAILED:', error.message);
|
|
68
|
+
}
|
|
69
|
+
// Test 2: OpenAI Assistant
|
|
70
|
+
console.log('\nš Test 2: OpenAI Customer Support Assistant');
|
|
71
|
+
console.log('ā'.repeat(60));
|
|
72
|
+
try {
|
|
73
|
+
const openaiFile = path.join(testDataDir, 'sample-openai-assistant.json');
|
|
74
|
+
const start2 = Date.now();
|
|
75
|
+
const faf2 = await (0, universal_intelligence_generator_1.generateFafFromAny)(openaiFile);
|
|
76
|
+
const duration2 = Date.now() - start2;
|
|
77
|
+
console.log('ā
SUCCESS');
|
|
78
|
+
console.log(`ā” Generated in ${duration2}ms`);
|
|
79
|
+
console.log('\n.faf Output (first 500 chars):');
|
|
80
|
+
console.log(faf2.substring(0, 500) + '...\n');
|
|
81
|
+
// Save output
|
|
82
|
+
await fs.writeFile(path.join(testDataDir, 'output-openai.faf'), faf2);
|
|
83
|
+
console.log('š Saved to: output-openai.faf');
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
console.log('ā FAILED:', error.message);
|
|
87
|
+
}
|
|
88
|
+
// Test 3: Unknown format (should fail gracefully)
|
|
89
|
+
console.log('\nš Test 3: Unknown Format (Expected Failure)');
|
|
90
|
+
console.log('ā'.repeat(60));
|
|
91
|
+
try {
|
|
92
|
+
const unknownFile = path.join(testDataDir, 'unknown-format.json');
|
|
93
|
+
// Create unknown format file
|
|
94
|
+
await fs.writeFile(unknownFile, JSON.stringify({
|
|
95
|
+
unknown: 'format',
|
|
96
|
+
random: 'data'
|
|
97
|
+
}));
|
|
98
|
+
await (0, universal_intelligence_generator_1.generateFafFromAny)(unknownFile);
|
|
99
|
+
console.log('ā UNEXPECTED: Should have thrown error');
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
console.log('ā
CORRECTLY REJECTED');
|
|
103
|
+
console.log(` Error: ${error.message}`);
|
|
104
|
+
}
|
|
105
|
+
console.log('\n' + 'ā'.repeat(60));
|
|
106
|
+
console.log('š Manual Validation Complete\n');
|
|
107
|
+
console.log('Next steps:');
|
|
108
|
+
console.log(' 1. Check output-n8n.faf and output-openai.faf files');
|
|
109
|
+
console.log(' 2. Verify .faf structure is consistent');
|
|
110
|
+
console.log(' 3. Validate scores are 70%+');
|
|
111
|
+
console.log(' 4. Confirm championship quality\n');
|
|
112
|
+
}
|
|
113
|
+
main().catch(console.error);
|
|
114
|
+
//# sourceMappingURL=manual-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manual-validation.js","sourceRoot":"","sources":["../../src/tests/manual-validation.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+FAA8E;AAC9E,2CAA6B;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