@auto-engineer/information-architect 0.4.4 → 0.5.1
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/.turbo/turbo-build.log +5 -6
- package/.turbo/turbo-format.log +9 -7
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +12 -14
- package/.turbo/turbo-type-check.log +4 -5
- package/CHANGELOG.md +20 -0
- package/README.md +408 -0
- package/dist/cli-manifest.d.ts +3 -0
- package/dist/cli-manifest.d.ts.map +1 -0
- package/dist/cli-manifest.js +16 -0
- package/dist/cli-manifest.js.map +1 -0
- package/dist/commands/generate-ia.d.ts +6 -1
- package/dist/commands/generate-ia.d.ts.map +1 -1
- package/dist/commands/generate-ia.js +109 -37
- package/dist/commands/generate-ia.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/cli-manifest.ts +17 -0
- package/src/commands/generate-ia.ts +125 -42
- package/src/index.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3,6 +3,7 @@ import * as path from 'path';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { processFlowsWithAI } from '../index.js';
|
|
5
5
|
import createDebug from 'debug';
|
|
6
|
+
import fg from 'fast-glob';
|
|
6
7
|
const debug = createDebug('ia:generate-command');
|
|
7
8
|
const debugSchema = createDebug('ia:generate-command:schema');
|
|
8
9
|
const debugFiles = createDebug('ia:generate-command:files');
|
|
@@ -38,47 +39,25 @@ async function getAtomsFromMarkdown(designSystemDir) {
|
|
|
38
39
|
return components;
|
|
39
40
|
}
|
|
40
41
|
async function getUniqueSchemaPath(outputDir) {
|
|
41
|
-
debugFiles('Finding
|
|
42
|
-
let suffix = 0;
|
|
42
|
+
debugFiles('Finding schema path in: %s', outputDir);
|
|
43
43
|
let existingSchema;
|
|
44
|
-
//
|
|
45
|
-
const
|
|
46
|
-
debugFiles('
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
const highestNumber = Math.max(...numbers);
|
|
58
|
-
debugFiles('Highest numbered file: %d', highestNumber);
|
|
59
|
-
// Read the highest numbered file as the existing schema
|
|
60
|
-
const existingFile = highestNumber === 0 ? 'auto-ia-scheme.json' : `auto-ia-scheme-${highestNumber}.json`;
|
|
61
|
-
const existingPath = path.join(outputDir, existingFile);
|
|
62
|
-
debugFiles('Reading existing schema from: %s', existingPath);
|
|
63
|
-
try {
|
|
64
|
-
const content = await fs.readFile(existingPath, 'utf-8');
|
|
65
|
-
existingSchema = JSON.parse(content);
|
|
66
|
-
debugFiles('Existing schema loaded successfully');
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
debugFiles('Could not read/parse existing schema: %O', error);
|
|
70
|
-
// If we can't read/parse it, treat as no existing schema
|
|
71
|
-
}
|
|
72
|
-
// New file will be one number higher
|
|
73
|
-
suffix = highestNumber + 1;
|
|
74
|
-
debugFiles('New file will use suffix: %d', suffix);
|
|
44
|
+
// Always use the same filename - overwrite if it exists
|
|
45
|
+
const filePath = path.join(outputDir, 'auto-ia-scheme.json');
|
|
46
|
+
debugFiles('Schema will be written to: %s', filePath);
|
|
47
|
+
// Try to read existing schema if it exists
|
|
48
|
+
try {
|
|
49
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
50
|
+
existingSchema = JSON.parse(content);
|
|
51
|
+
debugFiles('Existing schema loaded successfully from: %s', filePath);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
debugFiles('No existing schema found at: %s', filePath);
|
|
55
|
+
// If we can't read/parse it, treat as no existing schema
|
|
75
56
|
}
|
|
76
|
-
const filePath = suffix === 0 ? path.join(outputDir, 'auto-ia-scheme.json') : path.join(outputDir, `auto-ia-scheme-${suffix}.json`);
|
|
77
|
-
debugFiles('New schema will be written to: %s', filePath);
|
|
78
57
|
debugFiles('Existing schema found: %s', existingSchema ? 'yes' : 'no');
|
|
79
58
|
return { filePath, existingSchema };
|
|
80
59
|
}
|
|
81
|
-
|
|
60
|
+
async function handleGenerateIACommandInternal(command) {
|
|
82
61
|
const { outputDir, flowFiles } = command.data;
|
|
83
62
|
debug('Handling GenerateIA command');
|
|
84
63
|
debug(' Output directory: %s', outputDir);
|
|
@@ -160,7 +139,7 @@ export async function handleGenerateIACommand(command) {
|
|
|
160
139
|
export const generateIACommandHandler = {
|
|
161
140
|
name: 'GenerateIA',
|
|
162
141
|
handle: async (command) => {
|
|
163
|
-
const result = await
|
|
142
|
+
const result = await handleGenerateIACommandInternal(command);
|
|
164
143
|
if (result.type === 'IAGenerated') {
|
|
165
144
|
console.log('IA schema generated successfully');
|
|
166
145
|
}
|
|
@@ -169,4 +148,97 @@ export const generateIACommandHandler = {
|
|
|
169
148
|
}
|
|
170
149
|
},
|
|
171
150
|
};
|
|
151
|
+
// Helper function to expand glob patterns
|
|
152
|
+
async function expandGlobPatterns(patterns) {
|
|
153
|
+
const expandedFiles = [];
|
|
154
|
+
for (const pattern of patterns) {
|
|
155
|
+
if (pattern.includes('*')) {
|
|
156
|
+
// This is a glob pattern, expand it
|
|
157
|
+
const matches = await fg(pattern);
|
|
158
|
+
expandedFiles.push(...matches);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
expandedFiles.push(pattern);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return expandedFiles;
|
|
165
|
+
}
|
|
166
|
+
// Helper function to parse from message bus format
|
|
167
|
+
async function parseFromMessageBus(data) {
|
|
168
|
+
const outputDir = data.outputDir ?? '.context';
|
|
169
|
+
const flowFiles = data.flowFiles ?? [];
|
|
170
|
+
// If no flow files provided, use default pattern
|
|
171
|
+
const resolvedFlowFiles = flowFiles.length > 0 ? flowFiles : ['flows/*.flow.ts'];
|
|
172
|
+
// Expand glob patterns if necessary
|
|
173
|
+
const expandedFlowFiles = await expandGlobPatterns(resolvedFlowFiles);
|
|
174
|
+
return {
|
|
175
|
+
type: 'GenerateIA',
|
|
176
|
+
data: {
|
|
177
|
+
outputDir,
|
|
178
|
+
flowFiles: expandedFlowFiles,
|
|
179
|
+
},
|
|
180
|
+
timestamp: new Date(),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
// Helper function to parse CLI arguments
|
|
184
|
+
async function parseCliArgs(cliArgs) {
|
|
185
|
+
// Handle case where command comes from message bus with data already structured
|
|
186
|
+
if ('data' in cliArgs && typeof cliArgs.data === 'object' && cliArgs.data !== null) {
|
|
187
|
+
return parseFromMessageBus(cliArgs.data);
|
|
188
|
+
}
|
|
189
|
+
// Handle traditional CLI arguments with _ array
|
|
190
|
+
const outputDir = cliArgs._?.[0] ?? '.context';
|
|
191
|
+
// All remaining arguments are flow files
|
|
192
|
+
const flowFiles = cliArgs._ !== undefined ? cliArgs._.slice(1) : [];
|
|
193
|
+
// If no flow files provided, use default pattern
|
|
194
|
+
const resolvedFlowFiles = flowFiles.length > 0 ? flowFiles : ['flows/*.flow.ts'];
|
|
195
|
+
// Expand glob patterns if necessary
|
|
196
|
+
const expandedFlowFiles = await expandGlobPatterns(resolvedFlowFiles);
|
|
197
|
+
return {
|
|
198
|
+
type: 'GenerateIA',
|
|
199
|
+
data: {
|
|
200
|
+
outputDir,
|
|
201
|
+
flowFiles: expandedFlowFiles,
|
|
202
|
+
},
|
|
203
|
+
timestamp: new Date(),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
// Type guard to check if it's a GenerateIACommand
|
|
207
|
+
function isGenerateIACommand(obj) {
|
|
208
|
+
return (typeof obj === 'object' &&
|
|
209
|
+
obj !== null &&
|
|
210
|
+
'type' in obj &&
|
|
211
|
+
'data' in obj &&
|
|
212
|
+
(obj.type === 'GenerateIA' || obj.type === 'generate:ia'));
|
|
213
|
+
}
|
|
214
|
+
// Default export for CLI usage
|
|
215
|
+
export default async (commandOrArgs) => {
|
|
216
|
+
let command;
|
|
217
|
+
if (isGenerateIACommand(commandOrArgs)) {
|
|
218
|
+
// Normalize the type if it comes from message bus
|
|
219
|
+
if (commandOrArgs.type === 'generate:ia') {
|
|
220
|
+
command = {
|
|
221
|
+
...commandOrArgs,
|
|
222
|
+
type: 'GenerateIA',
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
command = commandOrArgs;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else if ('outputDir' in commandOrArgs && 'flowFiles' in commandOrArgs) {
|
|
230
|
+
// Handle message bus format with outputDir and flowFiles
|
|
231
|
+
command = await parseFromMessageBus(commandOrArgs);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
command = await parseCliArgs(commandOrArgs);
|
|
235
|
+
}
|
|
236
|
+
const result = await handleGenerateIACommandInternal(command);
|
|
237
|
+
if (result.type === 'IAGenerated') {
|
|
238
|
+
console.log('IA schema generated successfully');
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
console.error(`Failed: ${result.data.error}`);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
172
244
|
//# sourceMappingURL=generate-ia.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-ia.js","sourceRoot":"","sources":["../../src/commands/generate-ia.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,WAAW,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-ia.js","sourceRoot":"","sources":["../../src/commands/generate-ia.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,IAAI,EAA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AI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAAE,EAAE,GAClE,OAAO,CAAC,aAAa,CAAC;IAkBzB,OAAO,CAAC,eAAe;CA+FxB;AAED,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EAAE,EACf,QAAQ,EAAE,QAAQ,EAClB,cAAc,CAAC,EAAE,MAAM,EACvB,KAAK,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,EAAE,GAClE,OAAO,CAAC,aAAa,CAAC,CAGxB;AAED,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -129,4 +129,5 @@ export async function processFlowsWithAI(flows, uxSchema, existingSchema, atoms)
|
|
|
129
129
|
return agent.generateUXComponents(flows, uxSchema, existingSchema, atoms);
|
|
130
130
|
}
|
|
131
131
|
export * from './commands/generate-ia.js';
|
|
132
|
+
export { CLI_MANIFEST } from './cli-manifest.js';
|
|
132
133
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG3E,SAAS,uBAAuB,CAAC,IAAY;IAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,iCAAiC,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AACtE,CAAC;AAED,SAAS,YAAY,CAAC,GAAW;IAC/B,IAAI,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,C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AI,EAAE,CAAC,CAAC;;EAEjC,cAAc,CAAC,CAAC,CAAC,kNAAkN,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0EpR,CAAC;IACA,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAe,EACf,QAAkB,EAClB,cAAuB,EACvB,KAAmE;IAEnE,MAAM,KAAK,GAAG,IAAI,yBAAyB,EAAE,CAAC;IAC9C,OAAO,KAAK,CAAC,oBAAoB,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;AAC5E,CAAC;AAED,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auto-engineer/information-architect",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -8,18 +8,18 @@
|
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"import": "./dist/index.js"
|
|
11
|
-
},
|
|
12
|
-
"./commands/generate-ia": {
|
|
13
|
-
"types": "./dist/commands/generate-ia.d.ts",
|
|
14
|
-
"import": "./dist/commands/generate-ia.js"
|
|
15
11
|
}
|
|
16
12
|
},
|
|
17
13
|
"publishConfig": {
|
|
18
14
|
"access": "public"
|
|
19
15
|
},
|
|
20
16
|
"dependencies": {
|
|
21
|
-
"@auto-engineer/ai-gateway": "^0.
|
|
22
|
-
"@auto-engineer/message-bus": "^0.
|
|
17
|
+
"@auto-engineer/ai-gateway": "^0.5.1",
|
|
18
|
+
"@auto-engineer/message-bus": "^0.4.0",
|
|
19
|
+
"fast-glob": "^3.3.2"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@auto-engineer/cli": "^0.6.0"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsc && tsx ../../scripts/fix-esm-imports.ts && cp src/auto-ux-schema.json dist/",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CliManifest } from '@auto-engineer/cli/manifest-types';
|
|
2
|
+
|
|
3
|
+
export const CLI_MANIFEST: CliManifest = {
|
|
4
|
+
category: '@auto-engineer/information-architect',
|
|
5
|
+
commands: {
|
|
6
|
+
'generate:ia': {
|
|
7
|
+
handler: () => import('./commands/generate-ia'),
|
|
8
|
+
description: 'Generate Information Architecture',
|
|
9
|
+
usage: 'generate:ia <context> <flows...>',
|
|
10
|
+
examples: ['$ auto generate:ia ./.context ./flows/*.flow.ts'],
|
|
11
|
+
args: [
|
|
12
|
+
{ name: 'context', description: 'Context directory', required: true },
|
|
13
|
+
{ name: 'flows...', description: 'Flow files to analyze', required: true },
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -5,6 +5,7 @@ import { fileURLToPath } from 'url';
|
|
|
5
5
|
import { processFlowsWithAI } from '../index';
|
|
6
6
|
import { type UXSchema } from '../types';
|
|
7
7
|
import createDebug from 'debug';
|
|
8
|
+
import fg from 'fast-glob';
|
|
8
9
|
|
|
9
10
|
const debug = createDebug('ia:generate-command');
|
|
10
11
|
const debugSchema = createDebug('ia:generate-command:schema');
|
|
@@ -74,57 +75,29 @@ async function getAtomsFromMarkdown(designSystemDir: string): Promise<string[]>
|
|
|
74
75
|
async function getUniqueSchemaPath(
|
|
75
76
|
outputDir: string,
|
|
76
77
|
): Promise<{ filePath: string; existingSchema: object | undefined }> {
|
|
77
|
-
debugFiles('Finding
|
|
78
|
-
let suffix = 0;
|
|
78
|
+
debugFiles('Finding schema path in: %s', outputDir);
|
|
79
79
|
let existingSchema: object | undefined;
|
|
80
80
|
|
|
81
|
-
//
|
|
82
|
-
const
|
|
83
|
-
debugFiles('
|
|
84
|
-
|
|
85
|
-
const iaSchemeFiles = existingFiles.filter((file) => file.match(/^auto-ia-scheme(-\d+)?\.json$/));
|
|
86
|
-
debugFiles('Found %d existing IA scheme files', iaSchemeFiles.length);
|
|
87
|
-
|
|
88
|
-
if (iaSchemeFiles.length > 0) {
|
|
89
|
-
// Find the highest numbered file
|
|
90
|
-
const numbers = iaSchemeFiles.map((file) => {
|
|
91
|
-
const match = file.match(/auto-ia-scheme(?:-(\d+))?\.json$/);
|
|
92
|
-
const num = match && match[1] ? parseInt(match[1], 10) : 0;
|
|
93
|
-
debugFiles(' File %s -> number %d', file, num);
|
|
94
|
-
return num;
|
|
95
|
-
});
|
|
96
|
-
const highestNumber = Math.max(...numbers);
|
|
97
|
-
debugFiles('Highest numbered file: %d', highestNumber);
|
|
98
|
-
|
|
99
|
-
// Read the highest numbered file as the existing schema
|
|
100
|
-
const existingFile = highestNumber === 0 ? 'auto-ia-scheme.json' : `auto-ia-scheme-${highestNumber}.json`;
|
|
101
|
-
const existingPath = path.join(outputDir, existingFile);
|
|
102
|
-
debugFiles('Reading existing schema from: %s', existingPath);
|
|
103
|
-
|
|
104
|
-
try {
|
|
105
|
-
const content = await fs.readFile(existingPath, 'utf-8');
|
|
106
|
-
existingSchema = JSON.parse(content) as object;
|
|
107
|
-
debugFiles('Existing schema loaded successfully');
|
|
108
|
-
} catch (error) {
|
|
109
|
-
debugFiles('Could not read/parse existing schema: %O', error);
|
|
110
|
-
// If we can't read/parse it, treat as no existing schema
|
|
111
|
-
}
|
|
81
|
+
// Always use the same filename - overwrite if it exists
|
|
82
|
+
const filePath = path.join(outputDir, 'auto-ia-scheme.json');
|
|
83
|
+
debugFiles('Schema will be written to: %s', filePath);
|
|
112
84
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
85
|
+
// Try to read existing schema if it exists
|
|
86
|
+
try {
|
|
87
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
88
|
+
existingSchema = JSON.parse(content) as object;
|
|
89
|
+
debugFiles('Existing schema loaded successfully from: %s', filePath);
|
|
90
|
+
} catch {
|
|
91
|
+
debugFiles('No existing schema found at: %s', filePath);
|
|
92
|
+
// If we can't read/parse it, treat as no existing schema
|
|
116
93
|
}
|
|
117
94
|
|
|
118
|
-
const filePath =
|
|
119
|
-
suffix === 0 ? path.join(outputDir, 'auto-ia-scheme.json') : path.join(outputDir, `auto-ia-scheme-${suffix}.json`);
|
|
120
|
-
|
|
121
|
-
debugFiles('New schema will be written to: %s', filePath);
|
|
122
95
|
debugFiles('Existing schema found: %s', existingSchema ? 'yes' : 'no');
|
|
123
96
|
|
|
124
97
|
return { filePath, existingSchema };
|
|
125
98
|
}
|
|
126
99
|
|
|
127
|
-
|
|
100
|
+
async function handleGenerateIACommandInternal(
|
|
128
101
|
command: GenerateIACommand,
|
|
129
102
|
): Promise<IAGeneratedEvent | IAGenerationFailedEvent> {
|
|
130
103
|
const { outputDir, flowFiles } = command.data;
|
|
@@ -224,7 +197,7 @@ export async function handleGenerateIACommand(
|
|
|
224
197
|
export const generateIACommandHandler: CommandHandler<GenerateIACommand> = {
|
|
225
198
|
name: 'GenerateIA',
|
|
226
199
|
handle: async (command: GenerateIACommand): Promise<void> => {
|
|
227
|
-
const result = await
|
|
200
|
+
const result = await handleGenerateIACommandInternal(command);
|
|
228
201
|
if (result.type === 'IAGenerated') {
|
|
229
202
|
console.log('IA schema generated successfully');
|
|
230
203
|
} else {
|
|
@@ -232,3 +205,113 @@ export const generateIACommandHandler: CommandHandler<GenerateIACommand> = {
|
|
|
232
205
|
}
|
|
233
206
|
},
|
|
234
207
|
};
|
|
208
|
+
|
|
209
|
+
// CLI arguments interface
|
|
210
|
+
interface CliArgs {
|
|
211
|
+
_: string[];
|
|
212
|
+
[key: string]: unknown;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Helper function to expand glob patterns
|
|
216
|
+
async function expandGlobPatterns(patterns: string[]): Promise<string[]> {
|
|
217
|
+
const expandedFiles: string[] = [];
|
|
218
|
+
for (const pattern of patterns) {
|
|
219
|
+
if (pattern.includes('*')) {
|
|
220
|
+
// This is a glob pattern, expand it
|
|
221
|
+
const matches = await fg(pattern);
|
|
222
|
+
expandedFiles.push(...matches);
|
|
223
|
+
} else {
|
|
224
|
+
expandedFiles.push(pattern);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return expandedFiles;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Helper function to parse from message bus format
|
|
231
|
+
async function parseFromMessageBus(data: { outputDir?: string; flowFiles?: string[] }): Promise<GenerateIACommand> {
|
|
232
|
+
const outputDir = data.outputDir ?? '.context';
|
|
233
|
+
const flowFiles = data.flowFiles ?? [];
|
|
234
|
+
|
|
235
|
+
// If no flow files provided, use default pattern
|
|
236
|
+
const resolvedFlowFiles = flowFiles.length > 0 ? flowFiles : ['flows/*.flow.ts'];
|
|
237
|
+
|
|
238
|
+
// Expand glob patterns if necessary
|
|
239
|
+
const expandedFlowFiles = await expandGlobPatterns(resolvedFlowFiles);
|
|
240
|
+
|
|
241
|
+
return {
|
|
242
|
+
type: 'GenerateIA',
|
|
243
|
+
data: {
|
|
244
|
+
outputDir,
|
|
245
|
+
flowFiles: expandedFlowFiles,
|
|
246
|
+
},
|
|
247
|
+
timestamp: new Date(),
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Helper function to parse CLI arguments
|
|
252
|
+
async function parseCliArgs(cliArgs: CliArgs): Promise<GenerateIACommand> {
|
|
253
|
+
// Handle case where command comes from message bus with data already structured
|
|
254
|
+
if ('data' in cliArgs && typeof cliArgs.data === 'object' && cliArgs.data !== null) {
|
|
255
|
+
return parseFromMessageBus(cliArgs.data as { outputDir?: string; flowFiles?: string[] });
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Handle traditional CLI arguments with _ array
|
|
259
|
+
const outputDir = cliArgs._?.[0] ?? '.context';
|
|
260
|
+
// All remaining arguments are flow files
|
|
261
|
+
const flowFiles = cliArgs._ !== undefined ? cliArgs._.slice(1) : [];
|
|
262
|
+
|
|
263
|
+
// If no flow files provided, use default pattern
|
|
264
|
+
const resolvedFlowFiles = flowFiles.length > 0 ? flowFiles : ['flows/*.flow.ts'];
|
|
265
|
+
|
|
266
|
+
// Expand glob patterns if necessary
|
|
267
|
+
const expandedFlowFiles = await expandGlobPatterns(resolvedFlowFiles);
|
|
268
|
+
|
|
269
|
+
return {
|
|
270
|
+
type: 'GenerateIA',
|
|
271
|
+
data: {
|
|
272
|
+
outputDir,
|
|
273
|
+
flowFiles: expandedFlowFiles,
|
|
274
|
+
},
|
|
275
|
+
timestamp: new Date(),
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Type guard to check if it's a GenerateIACommand
|
|
280
|
+
function isGenerateIACommand(obj: unknown): obj is GenerateIACommand {
|
|
281
|
+
return (
|
|
282
|
+
typeof obj === 'object' &&
|
|
283
|
+
obj !== null &&
|
|
284
|
+
'type' in obj &&
|
|
285
|
+
'data' in obj &&
|
|
286
|
+
((obj as { type: unknown }).type === 'GenerateIA' || (obj as { type: unknown }).type === 'generate:ia')
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Default export for CLI usage
|
|
291
|
+
export default async (commandOrArgs: GenerateIACommand | CliArgs) => {
|
|
292
|
+
let command: GenerateIACommand;
|
|
293
|
+
|
|
294
|
+
if (isGenerateIACommand(commandOrArgs)) {
|
|
295
|
+
// Normalize the type if it comes from message bus
|
|
296
|
+
if ((commandOrArgs as { type: string }).type === 'generate:ia') {
|
|
297
|
+
command = {
|
|
298
|
+
...commandOrArgs,
|
|
299
|
+
type: 'GenerateIA' as const,
|
|
300
|
+
};
|
|
301
|
+
} else {
|
|
302
|
+
command = commandOrArgs;
|
|
303
|
+
}
|
|
304
|
+
} else if ('outputDir' in commandOrArgs && 'flowFiles' in commandOrArgs) {
|
|
305
|
+
// Handle message bus format with outputDir and flowFiles
|
|
306
|
+
command = await parseFromMessageBus(commandOrArgs as { outputDir?: string; flowFiles?: string[] });
|
|
307
|
+
} else {
|
|
308
|
+
command = await parseCliArgs(commandOrArgs);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const result = await handleGenerateIACommandInternal(command);
|
|
312
|
+
if (result.type === 'IAGenerated') {
|
|
313
|
+
console.log('IA schema generated successfully');
|
|
314
|
+
} else {
|
|
315
|
+
console.error(`Failed: ${result.data.error}`);
|
|
316
|
+
}
|
|
317
|
+
};
|
package/src/index.ts
CHANGED