@auto-engineer/information-architect 0.1.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.
@@ -0,0 +1,5 @@
1
+
2
+ > @auto-engineer/information-architect@0.1.1 build /home/runner/work/auto-engineer/auto-engineer/packages/information-architect
3
+ > tsc && tsx ../../scripts/fix-esm-imports.ts && cp src/auto-ux-schema.json dist/
4
+
5
+ Fixed ESM imports in dist/
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # @auto-engineer/information-architect
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Bump versions to fix npm publish conflicts
8
+
9
+ - Updated dependencies []:
10
+ - @auto-engineer/ai-gateway@0.1.1
11
+ - @auto-engineer/message-bus@0.0.2
package/LICENSE ADDED
@@ -0,0 +1,10 @@
1
+ Elastic License 2.0
2
+
3
+ Copyright 2024 Sam Hatoum
4
+
5
+ This software and associated documentation files (the "Software") are licensed under the Elastic License 2.0 (the "License"). You may not use this file except in compliance with the License.
6
+
7
+ You may obtain a copy of the License at:
8
+ https://www.elastic.co/licensing/elastic-license
9
+
10
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
@@ -0,0 +1,269 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "React Application Scaffold Schema (Atomic Design)",
4
+ "description": "A schema defining the structure and UX of a frontend React application based on atoms, molecules, organisms, and pages.",
5
+ "type": "object",
6
+ "properties": {
7
+ "schema_description": {
8
+ "description": "A high-level description of the schema's purpose.",
9
+ "type": "string"
10
+ },
11
+ "atoms": {
12
+ "description": "Atomic UI primitives like buttons, inputs, etc., usually generated from shadcn.",
13
+ "type": "object",
14
+ "properties": {
15
+ "description": {
16
+ "type": "string"
17
+ },
18
+ "items": {
19
+ "type": "object",
20
+ "patternProperties": {
21
+ "^[A-Z][a-zA-Z0-9]*$": {
22
+ "type": "object",
23
+ "properties": {
24
+ "description": {
25
+ "type": "string"
26
+ },
27
+ "specs": {
28
+ "type": "array",
29
+ "items": {
30
+ "type": "string"
31
+ },
32
+ "description": "Optional. UX and behavioral specifications for this component/page, derived from flow specs."
33
+ }
34
+ },
35
+ "required": ["description"]
36
+ }
37
+ }
38
+ }
39
+ },
40
+ "required": ["description", "items"]
41
+ },
42
+ "molecules": {
43
+ "description": "Components composed from atoms. Stateless and reusable.",
44
+ "type": "object",
45
+ "properties": {
46
+ "description": {
47
+ "type": "string"
48
+ },
49
+ "items": {
50
+ "type": "object",
51
+ "patternProperties": {
52
+ "^[A-Z][a-zA-Z0-9]*$": {
53
+ "type": "object",
54
+ "properties": {
55
+ "description": {
56
+ "type": "string"
57
+ },
58
+ "composition": {
59
+ "type": "object",
60
+ "properties": {
61
+ "atoms": {
62
+ "type": "array",
63
+ "items": {
64
+ "type": "string"
65
+ }
66
+ }
67
+ },
68
+ "required": ["atoms"]
69
+ },
70
+ "specs": {
71
+ "type": "array",
72
+ "items": {
73
+ "type": "string"
74
+ },
75
+ "description": "Optional. UX and behavioral specifications for this component/page, derived from flow specs."
76
+ }
77
+ },
78
+ "required": ["description", "composition"]
79
+ }
80
+ }
81
+ }
82
+ },
83
+ "required": ["description", "items"]
84
+ },
85
+ "organisms": {
86
+ "description": "Smart UI components with data-fetching or logic. Composed of molecules only.",
87
+ "type": "object",
88
+ "properties": {
89
+ "description": {
90
+ "type": "string"
91
+ },
92
+ "items": {
93
+ "type": "object",
94
+ "patternProperties": {
95
+ "^[A-Z][a-zA-Z0-9]*$": {
96
+ "type": "object",
97
+ "properties": {
98
+ "description": {
99
+ "type": "string"
100
+ },
101
+ "composition": {
102
+ "type": "object",
103
+ "properties": {
104
+ "molecules": {
105
+ "type": "array",
106
+ "items": {
107
+ "type": "string"
108
+ }
109
+ }
110
+ },
111
+ "required": ["molecules"]
112
+ },
113
+ "data_requirements": {
114
+ "type": "array",
115
+ "items": {
116
+ "type": "object",
117
+ "properties": {
118
+ "type": {
119
+ "type": "string",
120
+ "enum": ["query", "mutation"]
121
+ },
122
+ "description": {
123
+ "type": "string"
124
+ },
125
+ "trigger": {
126
+ "type": "string"
127
+ },
128
+ "details": {
129
+ "type": "object",
130
+ "properties": {
131
+ "source": {
132
+ "type": "string"
133
+ },
134
+ "gql": {
135
+ "type": "string"
136
+ },
137
+ "payload_schema": {
138
+ "type": "object",
139
+ "patternProperties": {
140
+ "^[a-zA-Z0-9_]*$": {
141
+ "type": "string"
142
+ }
143
+ }
144
+ }
145
+ },
146
+ "required": ["source", "gql"]
147
+ }
148
+ },
149
+ "required": ["type", "description", "trigger", "details"]
150
+ }
151
+ },
152
+ "specs": {
153
+ "type": "array",
154
+ "items": {
155
+ "type": "string"
156
+ },
157
+ "description": "Optional. UX and behavioral specifications for this component/page, derived from flow specs."
158
+ }
159
+ },
160
+ "required": ["description", "composition"]
161
+ }
162
+ }
163
+ }
164
+ },
165
+ "required": ["description", "items"]
166
+ },
167
+ "pages": {
168
+ "description": "Top-level views composed of organisms, molecules, and atoms. Tied to routes.",
169
+ "type": "object",
170
+ "properties": {
171
+ "description": {
172
+ "type": "string"
173
+ },
174
+ "items": {
175
+ "type": "object",
176
+ "patternProperties": {
177
+ "^[A-Z][a-zA-Z0-9]*$": {
178
+ "type": "object",
179
+ "properties": {
180
+ "route": {
181
+ "type": "string"
182
+ },
183
+ "description": {
184
+ "type": "string"
185
+ },
186
+ "layout": {
187
+ "type": "object",
188
+ "properties": {
189
+ "organisms": {
190
+ "type": "array",
191
+ "items": {
192
+ "type": "string"
193
+ }
194
+ }
195
+ },
196
+ "required": ["organisms"]
197
+ },
198
+ "navigation": {
199
+ "type": "array",
200
+ "items": {
201
+ "type": "object",
202
+ "properties": {
203
+ "on": {
204
+ "type": "string"
205
+ },
206
+ "to": {
207
+ "type": "string"
208
+ }
209
+ },
210
+ "required": ["on", "to"]
211
+ }
212
+ },
213
+ "data_requirements": {
214
+ "type": "array",
215
+ "items": {
216
+ "type": "object",
217
+ "properties": {
218
+ "type": {
219
+ "type": "string",
220
+ "enum": ["query", "mutation"]
221
+ },
222
+ "description": {
223
+ "type": "string"
224
+ },
225
+ "trigger": {
226
+ "type": "string"
227
+ },
228
+ "details": {
229
+ "type": "object",
230
+ "properties": {
231
+ "source": {
232
+ "type": "string"
233
+ },
234
+ "gql": {
235
+ "type": "string"
236
+ },
237
+ "payload_schema": {
238
+ "type": "object",
239
+ "patternProperties": {
240
+ "^[a-zA-Z0-9_]*$": {
241
+ "type": "string"
242
+ }
243
+ }
244
+ }
245
+ },
246
+ "required": ["source", "gql"]
247
+ }
248
+ },
249
+ "required": ["type", "description", "trigger", "details"]
250
+ }
251
+ },
252
+ "specs": {
253
+ "type": "array",
254
+ "items": {
255
+ "type": "string"
256
+ },
257
+ "description": "Optional. UX and behavioral specifications for this component/page, derived from flow specs."
258
+ }
259
+ },
260
+ "required": ["route", "description", "layout"]
261
+ }
262
+ }
263
+ }
264
+ },
265
+ "required": ["description", "items"]
266
+ }
267
+ },
268
+ "required": ["schema_description", "atoms", "molecules", "organisms", "pages"]
269
+ }
@@ -0,0 +1,18 @@
1
+ import { type CommandHandler, type Command, type Event } from '@auto-engineer/message-bus';
2
+ export type GenerateIACommand = Command<'GenerateIA', {
3
+ outputDir: string;
4
+ flowFiles: string[];
5
+ }>;
6
+ export type IAGeneratedEvent = Event<'IAGenerated', {
7
+ outputPath: string;
8
+ outputDir: string;
9
+ flowFiles: string[];
10
+ }>;
11
+ export type IAGenerationFailedEvent = Event<'IAGenerationFailed', {
12
+ error: string;
13
+ outputDir: string;
14
+ flowFiles: string[];
15
+ }>;
16
+ export declare function handleGenerateIACommand(command: GenerateIACommand): Promise<IAGeneratedEvent | IAGenerationFailedEvent>;
17
+ export declare const generateIACommandHandler: CommandHandler<GenerateIACommand>;
18
+ //# sourceMappingURL=generate-ia.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-ia.d.ts","sourceRoot":"","sources":["../../src/commands/generate-ia.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAU3F,MAAM,MAAM,iBAAiB,GAAG,OAAO,CACrC,YAAY,EACZ;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CACF,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAClC,aAAa,EACb;IACE,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CACF,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,KAAK,CACzC,oBAAoB,EACpB;IACE,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CACF,CAAC;AA4DF,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,GAAG,uBAAuB,CAAC,CAqDrD;AAED,eAAO,MAAM,wBAAwB,EAAE,cAAc,CAAC,iBAAiB,CAUtE,CAAC"}
@@ -0,0 +1,115 @@
1
+ import { promises as fs } from 'fs';
2
+ import * as path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import { processFlowsWithAI } from '../index.js';
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+ async function getAtomsFromMarkdown(designSystemDir) {
8
+ const mdPath = path.join(designSystemDir, 'design-system.md');
9
+ let content;
10
+ try {
11
+ content = await fs.readFile(mdPath, 'utf-8');
12
+ }
13
+ catch {
14
+ return [];
15
+ }
16
+ // Find all lines that start with '### ' and extract the component name
17
+ const lines = content.split('\n');
18
+ const components = [];
19
+ for (const line of lines) {
20
+ const match = line.match(/^###\s+(.+)/);
21
+ if (match) {
22
+ components.push(match[1].trim());
23
+ }
24
+ }
25
+ return components;
26
+ }
27
+ async function getUniqueSchemaPath(outputDir) {
28
+ let suffix = 0;
29
+ let existingSchema;
30
+ // First, check if there's an existing ia-scheme file
31
+ const existingFiles = await fs.readdir(outputDir).catch(() => []);
32
+ const iaSchemeFiles = existingFiles.filter((file) => file.match(/^auto-ia-scheme(-\d+)?\.json$/));
33
+ if (iaSchemeFiles.length > 0) {
34
+ // Find the highest numbered file
35
+ const numbers = iaSchemeFiles.map((file) => {
36
+ const match = file.match(/auto-ia-scheme(?:-(\d+))?\.json$/);
37
+ return match && match[1] ? parseInt(match[1], 10) : 0;
38
+ });
39
+ const highestNumber = Math.max(...numbers);
40
+ // Read the highest numbered file as the existing schema
41
+ const existingFile = highestNumber === 0 ? 'auto-ia-scheme.json' : `auto-ia-scheme-${highestNumber}.json`;
42
+ const existingPath = path.join(outputDir, existingFile);
43
+ try {
44
+ const content = await fs.readFile(existingPath, 'utf-8');
45
+ existingSchema = JSON.parse(content);
46
+ }
47
+ catch {
48
+ // If we can't read/parse it, treat as no existing schema
49
+ }
50
+ // New file will be one number higher
51
+ suffix = highestNumber + 1;
52
+ }
53
+ const filePath = suffix === 0 ? path.join(outputDir, 'auto-ia-scheme.json') : path.join(outputDir, `auto-ia-scheme-${suffix}.json`);
54
+ return { filePath, existingSchema };
55
+ }
56
+ export async function handleGenerateIACommand(command) {
57
+ const { outputDir, flowFiles } = command.data;
58
+ try {
59
+ // Load UX schema
60
+ const uxSchemaPath = path.join(__dirname, '..', 'auto-ux-schema.json');
61
+ const uxSchemaContent = await fs.readFile(uxSchemaPath, 'utf-8');
62
+ const uxSchema = JSON.parse(uxSchemaContent);
63
+ // Read all flow files
64
+ const flows = await Promise.all(flowFiles.map((flow) => fs.readFile(flow, 'utf-8')));
65
+ // Get unique schema path and existing schema
66
+ const { filePath, existingSchema } = await getUniqueSchemaPath(outputDir);
67
+ // Get atoms from markdown
68
+ const atomNames = await getAtomsFromMarkdown(outputDir);
69
+ const atoms = atomNames.map((name) => ({ name, props: [] }));
70
+ // Generate IA schema using AI
71
+ const iaSchema = await processFlowsWithAI(flows, uxSchema, existingSchema, atoms);
72
+ // Write the schema to file
73
+ await fs.writeFile(filePath, JSON.stringify(iaSchema, null, 2));
74
+ console.log(`Generated IA schema written to ${filePath}`);
75
+ return {
76
+ type: 'IAGenerated',
77
+ data: {
78
+ outputPath: filePath,
79
+ outputDir,
80
+ flowFiles,
81
+ },
82
+ timestamp: new Date(),
83
+ requestId: command.requestId,
84
+ correlationId: command.correlationId,
85
+ };
86
+ }
87
+ catch (error) {
88
+ const errorMessage = error instanceof Error ? error.message : String(error);
89
+ console.error('Failed to generate IA schema:', error);
90
+ return {
91
+ type: 'IAGenerationFailed',
92
+ data: {
93
+ error: errorMessage,
94
+ outputDir,
95
+ flowFiles,
96
+ },
97
+ timestamp: new Date(),
98
+ requestId: command.requestId,
99
+ correlationId: command.correlationId,
100
+ };
101
+ }
102
+ }
103
+ export const generateIACommandHandler = {
104
+ name: 'GenerateIA',
105
+ handle: async (command) => {
106
+ const result = await handleGenerateIACommand(command);
107
+ if (result.type === 'IAGenerated') {
108
+ console.log('IA schema generated successfully');
109
+ }
110
+ else {
111
+ console.error(`Failed: ${result.data.error}`);
112
+ }
113
+ },
114
+ };
115
+ //# sourceMappingURL=generate-ia.js.map
@@ -0,0 +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;AAG9C,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MA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ACV;YACD,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,aAAa,EAAE,OAAO,CAAC,aAAa;SACrC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;QAEtD,OAAO;YACL,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE;gBACJ,KAAK,EAAE,YAAY;gBACnB,SAAS;gBACT,SAAS;aACV;YACD,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,aAAa,EAAE,OAAO,CAAC,aAAa;SACrC,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAsC;IACzE,IAAI,EAAE,YAAY;IAClB,MAAM,EAAE,KAAK,EAAE,OAA0B,EAAiB,EAAE;QAC1D,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAAC,OAAO,CAAC,CAAC;QACtD,IAAI,MAAM,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;YAClC,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;QAClD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,WAAW,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generate-ia-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-ia-schema.d.ts","sourceRoot":"","sources":["../src/generate-ia-schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,70 @@
1
+ import { processFlowsWithAI } from './index.js';
2
+ import uxSchema from './auto-ux-schema.json.js';
3
+ import * as fs from 'fs/promises';
4
+ import * as path from 'path';
5
+ async function getAtomsFromMarkdown(designSystemDir) {
6
+ const mdPath = path.join(designSystemDir, 'design-system.md');
7
+ let content;
8
+ try {
9
+ content = await fs.readFile(mdPath, 'utf-8');
10
+ }
11
+ catch {
12
+ return [];
13
+ }
14
+ // Find all lines that start with '### ' and extract the component name
15
+ const lines = content.split('\n');
16
+ const components = [];
17
+ for (const line of lines) {
18
+ const match = line.match(/^###\s+(.+)/);
19
+ if (match) {
20
+ components.push(match[1].trim());
21
+ }
22
+ }
23
+ return components;
24
+ }
25
+ async function getUniqueSchemaPath(outputDir) {
26
+ await fs.mkdir(outputDir, { recursive: true });
27
+ const baseFileName = 'auto-ia-scheme';
28
+ const basePath = path.join(outputDir, baseFileName);
29
+ let existingSchema = undefined;
30
+ try {
31
+ existingSchema = JSON.parse(await fs.readFile(`${basePath}.json`, 'utf-8'));
32
+ console.log('Existing IA schema found and will be taken into account.');
33
+ }
34
+ catch (err) {
35
+ if (typeof err === 'object' && err !== null && 'code' in err && err.code !== 'ENOENT') {
36
+ console.error('Error reading existing IA schema:', err);
37
+ process.exit(1);
38
+ }
39
+ // If file does not exist or is invalid, continue with existingSchema as undefined
40
+ }
41
+ let filePath = `${basePath}.json`;
42
+ let counter = 1;
43
+ while (await fs
44
+ .access(filePath)
45
+ .then(() => true)
46
+ .catch(() => false)) {
47
+ filePath = `${basePath}-${counter}.json`;
48
+ counter++;
49
+ }
50
+ return { filePath, existingSchema };
51
+ }
52
+ async function main() {
53
+ const [, , outputDir, ...flowFiles] = process.argv;
54
+ if (!outputDir) {
55
+ console.error('Usage: tsx src/generate-ia-schema.ts <output-dir> <flow-file-1> <flow-file-2> ...');
56
+ process.exit(1);
57
+ }
58
+ const flows = await Promise.all(flowFiles.map((flow) => fs.readFile(flow, 'utf-8')));
59
+ const { filePath, existingSchema } = await getUniqueSchemaPath(outputDir);
60
+ const atomNames = await getAtomsFromMarkdown(outputDir);
61
+ const atoms = atomNames.map((name) => ({ name, props: [] }));
62
+ const iaSchema = await processFlowsWithAI(flows, uxSchema, existingSchema, atoms);
63
+ await fs.writeFile(filePath, JSON.stringify(iaSchema, null, 2));
64
+ console.log(`Generated IA schema written to ${filePath}`);
65
+ }
66
+ main().catch((err) => {
67
+ console.error('Failed to generate IA schema:', err);
68
+ process.exit(1);
69
+ });
70
+ //# sourceMappingURL=generate-ia-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-ia-schema.js","sourceRoot":"","sources":["../src/generate-ia-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,KAAK,UAAU,oBAAoB,CAAC,eAAuB;IACzD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAC;IAC9D,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,uEAAuE;IACvE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACxC,IAAI,KAAK,EAAE,CAAC;YACV,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACn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C;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { AIProvider } from '@auto-engineer/ai-gateway';
2
+ import { type UXSchema, type AIAgentOutput } from './types';
3
+ export declare class InformationArchitectAgent {
4
+ private provider;
5
+ constructor(provider?: AIProvider);
6
+ generateUXComponents(flows: string[], uxSchema: UXSchema, existingSchema?: object, atoms?: {
7
+ name: string;
8
+ props: {
9
+ name: string;
10
+ type: string;
11
+ }[];
12
+ }[]): Promise<AIAgentOutput>;
13
+ private constructPrompt;
14
+ }
15
+ export declare function processFlowsWithAI(flows: string[], uxSchema: UXSchema, existingSchema?: object, atoms?: {
16
+ name: string;
17
+ props: {
18
+ name: string;
19
+ type: string;
20
+ }[];
21
+ }[]): Promise<AIAgentOutput>;
22
+ export * from './commands/generate-ia';
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAe5D,qBAAa,yBAAyB;IACpC,OAAO,CAAC,QAAQ,CAAa;gBAEjB,QAAQ,GAAE,UAAiC;IAIjD,oBAAoB,CACxB,KAAK,EAAE,MAAM,EAAE,EACf,QAAQ,EAAE,QAAQ,EAClB,cAAc,CAAC,EAAE,MAAM,EACvB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAAE,EAAE,GAClE,OAAO,CAAC,aAAa,CAAC;IAkBzB,OAAO,CAAC,eAAe;CAqFxB;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"}