@specverse/engines 5.0.2 → 5.2.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.
Files changed (116) hide show
  1. package/assets/prompts/core/standard/default/analyse.prompt.yaml +5 -5
  2. package/assets/prompts/core/standard/default/app-demo.prompt.yaml +21 -1
  3. package/assets/prompts/core/standard/default/behavior.prompt.yaml +150 -0
  4. package/assets/prompts/core/standard/default/create.prompt.yaml +3 -3
  5. package/assets/prompts/core/standard/default/materialise.prompt.yaml +804 -774
  6. package/assets/prompts/core/standard/default/realize.prompt.yaml +581 -544
  7. package/assets/prompts/core/standard/v9/analyse.prompt.yaml +5 -5
  8. package/assets/prompts/core/standard/v9/app-demo.prompt.yaml +233 -0
  9. package/assets/prompts/core/standard/v9/behavior.prompt.yaml +33 -9
  10. package/assets/prompts/core/standard/v9/create.prompt.yaml +3 -3
  11. package/assets/prompts/core/standard/v9/materialise.prompt.yaml +804 -774
  12. package/assets/prompts/core/standard/v9/realize.prompt.yaml +581 -544
  13. package/dist/ai/commands/fill.d.ts.map +1 -1
  14. package/dist/ai/commands/fill.js +16 -7
  15. package/dist/ai/commands/fill.js.map +1 -1
  16. package/dist/ai/commands/template.d.ts.map +1 -1
  17. package/dist/ai/commands/template.js +17 -8
  18. package/dist/ai/commands/template.js.map +1 -1
  19. package/dist/bundles/deriveCatalog.d.ts +18 -0
  20. package/dist/bundles/deriveCatalog.d.ts.map +1 -0
  21. package/dist/bundles/deriveCatalog.js +263 -0
  22. package/dist/bundles/deriveCatalog.js.map +1 -0
  23. package/dist/bundles/index.d.ts +15 -0
  24. package/dist/bundles/index.d.ts.map +1 -0
  25. package/dist/bundles/index.js +15 -0
  26. package/dist/bundles/index.js.map +1 -0
  27. package/dist/bundles/types.d.ts +53 -0
  28. package/dist/bundles/types.d.ts.map +1 -0
  29. package/dist/bundles/types.js +22 -0
  30. package/dist/bundles/types.js.map +1 -0
  31. package/dist/bundles/validate.d.ts +55 -0
  32. package/dist/bundles/validate.d.ts.map +1 -0
  33. package/dist/bundles/validate.js +471 -0
  34. package/dist/bundles/validate.js.map +1 -0
  35. package/dist/inference/quint-transpiler.js +2 -2
  36. package/dist/inference/quint-transpiler.js.map +1 -1
  37. package/dist/libs/instance-factories/applications/templates/react/runtime-package-json-generator.js +1 -1
  38. package/dist/libs/instance-factories/cli/templates/commander/command-generator.js +227 -0
  39. package/dist/libs/instance-factories/tools/templates/mcp/mcp-server-generator.js +295 -14
  40. package/libs/instance-factories/applications/templates/react/runtime-package-json-generator.ts +1 -1
  41. package/libs/instance-factories/cli/templates/commander/command-generator.ts +227 -0
  42. package/libs/instance-factories/tools/templates/mcp/mcp-server-generator.ts +328 -15
  43. package/package.json +9 -5
  44. package/assets/examples/09-api/ai-spec.yaml +0 -194
  45. package/assets/examples/09-api/converted.yaml +0 -95
  46. package/assets/examples/09-api/diagram-architecture.mmd +0 -10
  47. package/assets/examples/09-api/diagram-er.mmd +0 -10
  48. package/assets/examples/09-api/documentation.html +0 -104
  49. package/assets/examples/09-api/documentation.md +0 -95
  50. package/assets/examples/09-api/inferred-spec.yaml +0 -420
  51. package/assets/examples/09-api/openapi.json +0 -61
  52. package/assets/examples/10-api/README.md +0 -216
  53. package/assets/examples/10-api/ai-spec.yaml +0 -194
  54. package/assets/examples/10-api/converted.yaml +0 -96
  55. package/assets/examples/10-api/diagram-architecture.mmd +0 -10
  56. package/assets/examples/10-api/diagram-er.mmd +0 -10
  57. package/assets/examples/10-api/documentation.html +0 -104
  58. package/assets/examples/10-api/documentation.md +0 -95
  59. package/assets/examples/10-api/inferred-spec.yaml +0 -7
  60. package/assets/examples/10-api/metadata.yaml +0 -89
  61. package/assets/examples/10-api/openapi.json +0 -61
  62. package/assets/examples/10-api/package-integration-test.js +0 -177
  63. package/assets/examples/10-api/usage-example.js +0 -323
  64. package/assets/examples/10-api/usage-example.ts +0 -363
  65. package/assets/examples/10-api/workflow-test.js +0 -113
  66. package/assets/examples/validate-examples-with-expected-failures.cjs +0 -328
  67. package/assets/examples/validate-examples.cjs +0 -225
  68. package/assets/prompts/MOVED.md +0 -35
  69. package/assets/prompts/SUMMARY-v8-PROMOTION.md +0 -445
  70. package/assets/prompts/core/CHANGELOG.md +0 -158
  71. package/assets/prompts/core/MIGRATION-v6-to-v7.md +0 -379
  72. package/assets/prompts/core/base-terminal-prompt.md +0 -201
  73. package/assets/prompts/core/examples/example-usage.ts +0 -140
  74. package/assets/prompts/core/schemas/prompt.schema.json +0 -309
  75. package/assets/prompts/core/schemas/prompt.schema.yaml +0 -229
  76. package/assets/prompts/core/standard/archive/v1/analyse.prompt.yaml +0 -259
  77. package/assets/prompts/core/standard/archive/v1/create.prompt.yaml +0 -302
  78. package/assets/prompts/core/standard/archive/v1/materialise.prompt.yaml +0 -328
  79. package/assets/prompts/core/standard/archive/v1/realize.prompt.yaml +0 -606
  80. package/assets/prompts/core/standard/archive/v2/README.md +0 -110
  81. package/assets/prompts/core/standard/archive/v2/analyse.prompt.yaml +0 -151
  82. package/assets/prompts/core/standard/archive/v2/create.prompt.yaml +0 -151
  83. package/assets/prompts/core/standard/archive/v2/materialise.prompt.yaml +0 -132
  84. package/assets/prompts/core/standard/archive/v2/realize.prompt.yaml +0 -147
  85. package/assets/prompts/core/standard/archive/v3/README.md +0 -279
  86. package/assets/prompts/core/standard/archive/v3/analyse.prompt.yaml +0 -309
  87. package/assets/prompts/core/standard/archive/v3/create.prompt.yaml +0 -351
  88. package/assets/prompts/core/standard/archive/v3/materialise.prompt.yaml +0 -247
  89. package/assets/prompts/core/standard/archive/v3/realize.prompt.yaml +0 -344
  90. package/assets/prompts/core/standard/archive/v4/README.md +0 -79
  91. package/assets/prompts/core/standard/archive/v4/analyse.prompt.yaml +0 -204
  92. package/assets/prompts/core/standard/archive/v4/create.prompt.yaml +0 -185
  93. package/assets/prompts/core/standard/archive/v5/README.md +0 -224
  94. package/assets/prompts/core/standard/archive/v5/analyse.prompt.yaml +0 -209
  95. package/assets/prompts/core/standard/archive/v5/create.prompt.yaml +0 -225
  96. package/assets/prompts/core/standard/archive/v5/materialise.prompt.yaml +0 -242
  97. package/assets/prompts/core/standard/archive/v5/realize.prompt.yaml +0 -336
  98. package/assets/prompts/core/standard/archive/v6/README.md +0 -187
  99. package/assets/prompts/core/standard/archive/v6/analyse.prompt.yaml +0 -219
  100. package/assets/prompts/core/standard/archive/v6/create.prompt.yaml +0 -180
  101. package/assets/prompts/core/standard/archive/v6/materialise.prompt.yaml +0 -203
  102. package/assets/prompts/core/standard/archive/v6/realize.prompt.yaml +0 -215
  103. package/assets/prompts/core/standard/archive/v7/analyse.prompt.nick.yaml +0 -144
  104. package/assets/prompts/core/standard/archive/v7/analyse.prompt.old.yaml +0 -146
  105. package/assets/prompts/core/standard/archive/v7/analyse.prompt.yaml +0 -129
  106. package/assets/prompts/core/standard/archive/v7/create.prompt.yaml +0 -146
  107. package/assets/prompts/core/standard/archive/v7/materialise.prompt.yaml +0 -297
  108. package/assets/prompts/core/standard/archive/v7/realize.prompt.yaml +0 -294
  109. package/assets/prompts/core/standard/archive/v8/README.md +0 -400
  110. package/assets/prompts/core/standard/archive/v8/analyse.prompt.yaml +0 -185
  111. package/assets/prompts/core/standard/archive/v8/create.prompt.yaml +0 -203
  112. package/assets/prompts/core/standard/archive/v8/materialise.prompt.yaml +0 -297
  113. package/assets/prompts/core/standard/archive/v8/realize.prompt.yaml +0 -294
  114. package/assets/prompts/templates/api-orchestrator-template.yaml +0 -188
  115. package/assets/prompts/templates/claude-integration-template.md +0 -121
  116. package/assets/prompts/templates/terminal-prompt-template.md +0 -97
@@ -1,177 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * SpecVerse npm Package Integration Test
4
- *
5
- * Tests the actual npm package installation and API usage
6
- * This validates that the built package works when installed externally
7
- */
8
-
9
- import { execSync } from 'child_process';
10
- import { mkdtempSync, rmSync, writeFileSync, readFileSync } from 'fs';
11
- import { tmpdir } from 'os';
12
- import { join } from 'path';
13
-
14
- async function testPackageIntegration() {
15
- console.log('🧪 Testing npm package integration...');
16
-
17
- let testDir;
18
- let packagePath;
19
-
20
- try {
21
- // 1. Create package from current source
22
- console.log('1️⃣ Creating package...');
23
- const packOutput = execSync('npm pack --silent', { encoding: 'utf8' }).trim();
24
- // Extract just the .tgz filename from the output (last line that ends with .tgz)
25
- const tgzFilename = packOutput.split('\n').filter(line => line.endsWith('.tgz')).pop() || packOutput;
26
- packagePath = join(process.cwd(), tgzFilename);
27
- console.log(`✅ Package created: ${tgzFilename}`);
28
-
29
- // 2. Create temporary test directory
30
- console.log('2️⃣ Setting up test environment...');
31
- testDir = mkdtempSync(join(tmpdir(), 'specverse-test-'));
32
- console.log(`✅ Test directory: ${testDir}`);
33
-
34
- // 3. Install package in test directory
35
- console.log('3️⃣ Installing package...');
36
- execSync(`cd "${testDir}" && npm init -y --silent`, { stdio: 'ignore' });
37
- // Set type to module for ES module support
38
- const packageJsonPath = join(testDir, 'package.json');
39
- const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
40
- packageJson.type = 'module';
41
- writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
42
- execSync(`cd "${testDir}" && npm install "${packagePath}" --silent`, { stdio: 'ignore' });
43
- console.log('✅ Package installed successfully');
44
-
45
- // 4. Create test script (ES module)
46
- console.log('4️⃣ Creating test script...');
47
- const testScript = `
48
- import { SpecVerseParser, LogicalInferenceEngine } from '@specverse/lang';
49
- import { readFileSync } from 'fs';
50
- import { join, dirname } from 'path';
51
- import { fileURLToPath } from 'url';
52
-
53
- const __filename = fileURLToPath(import.meta.url);
54
- const __dirname = dirname(__filename);
55
-
56
- async function runTest() {
57
- console.log('🔍 Testing installed package...');
58
-
59
- // Simple test specification
60
- const testSpec = \`components:
61
- TestComponent:
62
- version: "3.2.0"
63
- description: "Test component for package integration"
64
-
65
- models:
66
- Product:
67
- description: "Test product model"
68
- attributes:
69
- id: UUID required unique
70
- name: String required
71
- price: Number required
72
- lifecycles:
73
- status:
74
- flow: draft -> active -> archived
75
-
76
- deployments: {}
77
- \`;
78
-
79
- try {
80
- // Test 1: Parse specification
81
- const schemaPath = join(__dirname, 'node_modules/@specverse/lang/schema/SPECVERSE-SCHEMA.json');
82
- const schema = JSON.parse(readFileSync(schemaPath, 'utf8'));
83
- const parser = new SpecVerseParser(schema);
84
-
85
- const parseResult = parser.parseContent(testSpec, 'test.specly');
86
- if (parseResult.errors.length > 0) {
87
- throw new Error('Parsing failed: ' + parseResult.errors.map(e => e.message).join(', '));
88
- }
89
- console.log('✅ Parsing successful');
90
-
91
- // Test 2: Run inference
92
- const config = {
93
- logical: {
94
- generateControllers: true,
95
- generateServices: true,
96
- generateEvents: true,
97
- generateViews: true
98
- },
99
- rules: {
100
- logicalRulesPath: join(__dirname, 'node_modules/@specverse/lang/dist/inference-engine/rules/logical')
101
- }
102
- };
103
-
104
- const engine = new LogicalInferenceEngine(config);
105
- await engine.loadRules();
106
-
107
- // Get the first (and only) component since parser uses array-style indexing
108
- const componentName = Object.keys(parseResult.ast.components)[0];
109
- const component = parseResult.ast.components[componentName];
110
- const models = component.models;
111
- const inference = await engine.inferLogicalSpecification(models, 'TestComponent');
112
-
113
- console.log(\`✅ Inference successful:\`);
114
- console.log(\` Controllers: \${Object.keys(inference.controllers || {}).length}\`);
115
- console.log(\` Services: \${Object.keys(inference.services || {}).length}\`);
116
- console.log(\` Events: \${Object.keys(inference.events || {}).length}\`);
117
- console.log(\` Views: \${Object.keys(inference.views || {}).length}\`);
118
-
119
- console.log('🎉 PACKAGE INTEGRATION TEST SUCCESS!');
120
- process.exit(0);
121
-
122
- } catch (error) {
123
- console.error('❌ Test failed:', error.message);
124
- process.exit(1);
125
- }
126
- }
127
-
128
- runTest();
129
- `;
130
-
131
- writeFileSync(join(testDir, 'test.js'), testScript);
132
- console.log('✅ Test script created');
133
-
134
- // 5. Run the test
135
- console.log('5️⃣ Running package integration test...');
136
- execSync(`cd "${testDir}" && node test.js`, {
137
- stdio: 'inherit',
138
- timeout: 30000
139
- });
140
-
141
- console.log('🎉 npm Package Integration Test PASSED!');
142
-
143
- } catch (error) {
144
- console.error('❌ Package integration test failed:', error.message);
145
- throw error;
146
-
147
- } finally {
148
- // Cleanup
149
- if (testDir) {
150
- try {
151
- rmSync(testDir, { recursive: true, force: true });
152
- console.log('🧹 Cleaned up test directory');
153
- } catch (cleanupError) {
154
- console.warn('⚠️ Could not clean up test directory:', cleanupError.message);
155
- }
156
- }
157
-
158
- if (packagePath) {
159
- try {
160
- rmSync(packagePath, { force: true });
161
- console.log('🧹 Cleaned up package file');
162
- } catch (cleanupError) {
163
- console.warn('⚠️ Could not clean up package file:', cleanupError.message);
164
- }
165
- }
166
- }
167
- }
168
-
169
- // Run if called directly
170
- if (import.meta.url === `file://${process.argv[1]}`) {
171
- testPackageIntegration().catch((error) => {
172
- console.error('Package integration test failed:', error.message);
173
- process.exit(1);
174
- });
175
- }
176
-
177
- export { testPackageIntegration };
@@ -1,323 +0,0 @@
1
- /**
2
- * SpecVerse JavaScript API Usage Examples
3
- *
4
- * Simple examples showing how to use SpecVerse from JavaScript
5
- */
6
-
7
- import { SpecVerseParser } from '../../dist/index.js';
8
- import { readFileSync, writeFileSync } from 'fs';
9
- import * as yaml from 'js-yaml';
10
-
11
- // ============================================
12
- // BASIC USAGE EXAMPLE
13
- // ============================================
14
-
15
- // 1. Parse a SpecVerse file
16
- function parseSpec(filePath) {
17
- // Load the schema (in real usage, this would be from node_modules/@specverse/lang/schema/)
18
- const schema = JSON.parse(readFileSync('../../schema/SPECVERSE-SCHEMA.json', 'utf8'));
19
-
20
- // Create parser
21
- const parser = new SpecVerseParser(schema);
22
-
23
- // Parse the file
24
- const content = readFileSync(filePath, 'utf8');
25
- const result = parser.parseContent(content, filePath);
26
-
27
- if (result.errors.length > 0) {
28
- console.error('Errors:', result.errors);
29
- return null;
30
- }
31
-
32
- console.log('✅ Parsed successfully');
33
- return result.ast;
34
- }
35
-
36
- // 2. Validate a specification
37
- function validateSpec(filePath) {
38
- const schema = JSON.parse(readFileSync('../../schema/SPECVERSE-SCHEMA.json', 'utf8'));
39
- const parser = new SpecVerseParser(schema);
40
-
41
- const content = readFileSync(filePath, 'utf8');
42
- const result = parser.parseContent(content, filePath);
43
-
44
- return result.errors.length === 0;
45
- }
46
-
47
- // 3. Convert .specly to .yaml
48
- function speclyToYaml(inputPath, outputPath) {
49
- const schema = JSON.parse(readFileSync('../../schema/SPECVERSE-SCHEMA.json', 'utf8'));
50
- const parser = new SpecVerseParser(schema);
51
-
52
- const content = readFileSync(inputPath, 'utf8');
53
- const result = parser.processToYaml(content);
54
-
55
- if (result.errors.length === 0) {
56
- writeFileSync(outputPath, result.yaml);
57
- console.log('✅ Converted to YAML');
58
- return true;
59
- }
60
-
61
- console.error('❌ Conversion failed:', result.errors);
62
- return false;
63
- }
64
-
65
- // 4. Extract information from AST
66
- function analyzeSpec(ast) {
67
- if (!ast) return null;
68
-
69
- // Count different elements
70
- const stats = {
71
- components: ast.components.length,
72
- models: 0,
73
- controllers: 0,
74
- services: 0,
75
- events: 0,
76
- views: 0
77
- };
78
-
79
- // Iterate through components
80
- ast.components.forEach(component => {
81
- stats.models += component.models?.length || 0;
82
- stats.controllers += component.controllers?.length || 0;
83
- stats.services += component.services?.length || 0;
84
- stats.events += component.events?.length || 0;
85
- stats.views += component.views?.length || 0;
86
- });
87
-
88
- return stats;
89
- }
90
-
91
- // 5. Example: Generate a simple report
92
- function generateReport(filePath) {
93
- const ast = parseSpec(filePath);
94
- if (!ast) return;
95
-
96
- const stats = analyzeSpec(ast);
97
-
98
- const report = {
99
- file: filePath,
100
- timestamp: new Date().toISOString(),
101
- statistics: stats,
102
- components: ast.components.map(c => ({
103
- name: c.name,
104
- version: c.version,
105
- modelCount: c.models?.length || 0,
106
- exports: c.exports
107
- }))
108
- };
109
-
110
- console.log('\n📊 Specification Report:');
111
- console.log(JSON.stringify(report, null, 2));
112
-
113
- return report;
114
- }
115
-
116
- // ============================================
117
- // USING THE INFERENCE ENGINE
118
- // ============================================
119
-
120
- import { LogicalInferenceEngine } from '../../dist/index.js';
121
-
122
- async function runInference(filePath) {
123
- // Parse the file first
124
- const ast = parseSpec(filePath);
125
- if (!ast) return;
126
-
127
- // Configure inference
128
- const config = {
129
- logical: {
130
- generateControllers: true,
131
- generateServices: true,
132
- generateEvents: true,
133
- generateViews: true,
134
- generateTypes: true
135
- },
136
- rules: {
137
- logicalRulesPath: '../../dist/inference-engine/rules/logical',
138
- deploymentRulesPath: '../../dist/inference-engine/rules/deployment'
139
- }
140
- };
141
-
142
- // Create and run inference engine
143
- const engine = new LogicalInferenceEngine(config);
144
-
145
- // Extract models from AST
146
- const models = ast.components.flatMap(c => c.models);
147
-
148
- // Load rules first
149
- console.log('📋 Loading inference rules...');
150
- const rulesValidation = await engine.loadRules();
151
-
152
- if (!rulesValidation.valid) {
153
- console.error('❌ Failed to load inference rules:', rulesValidation.errors.map(e => e.message));
154
- return null;
155
- }
156
-
157
- // Run inference
158
- const componentName = 'GeneratedComponent';
159
- const result = await engine.inferLogicalSpecification(models, componentName);
160
-
161
- console.log('✅ Inference complete:');
162
- console.log(' Validation:', result.validation.valid ? '✅' : '❌');
163
- console.log(' Controllers:', result.statistics.controllersGenerated);
164
- console.log(' Services:', result.statistics.servicesGenerated);
165
- console.log(' Events:', result.statistics.eventsGenerated);
166
- console.log(' Views:', result.statistics.viewsGenerated);
167
-
168
- if (!result.validation.valid) {
169
- console.error(' Errors:', result.validation.errors.map(e => e.message));
170
- }
171
-
172
- // Save the inferred specification
173
- const output = yaml.dump(result.specification, {
174
- indent: 2,
175
- lineWidth: 120
176
- });
177
-
178
- writeFileSync('inferred-spec.yaml', output);
179
- console.log('💾 Saved to inferred-spec.yaml');
180
-
181
- return result;
182
- }
183
-
184
- // ============================================
185
- // USING GENERATORS
186
- // ============================================
187
-
188
- import {
189
- AIViewGenerator,
190
- UMLGenerator,
191
- DocumentationGenerator
192
- } from '../../dist/index.js';
193
-
194
- function generateAIView(ast) {
195
- try {
196
- const generator = new AIViewGenerator();
197
- const aiSpec = generator.generate(ast);
198
-
199
- // Save as YAML
200
- const output = yaml.dump(aiSpec, { indent: 2 });
201
- writeFileSync('ai-spec.yaml', output);
202
-
203
- console.log('✅ AI specification generated');
204
- return aiSpec;
205
- } catch (error) {
206
- console.warn('⚠️ AI view generation failed:', error.message);
207
- }
208
- }
209
-
210
- function generateDiagrams(ast) {
211
- try {
212
- const generator = new UMLGenerator();
213
-
214
- // Generate ER diagram
215
- const erDiagram = generator.generate(ast, {
216
- type: 'er',
217
- includeAttributes: true,
218
- includeRelationships: true
219
- });
220
- if (erDiagram) {
221
- writeFileSync('diagram-er.mmd', erDiagram);
222
- console.log('✅ ER diagram generated');
223
- }
224
-
225
- // Generate architecture diagram
226
- const archDiagram = generator.generate(ast, {
227
- type: 'architecture',
228
- includeControllers: true,
229
- includeServices: true,
230
- includeEvents: true
231
- });
232
- if (archDiagram) {
233
- writeFileSync('diagram-architecture.mmd', archDiagram);
234
- console.log('✅ Architecture diagram generated');
235
- }
236
- } catch (error) {
237
- console.warn('⚠️ Diagram generation failed:', error.message);
238
- }
239
- }
240
-
241
- function generateDocs(ast) {
242
- try {
243
- const generator = new DocumentationGenerator();
244
-
245
- // Generate markdown
246
- const markdown = generator.generate(ast, {
247
- format: 'markdown',
248
- includeTableOfContents: true,
249
- includeExamples: true,
250
- includeDiagrams: false
251
- });
252
- writeFileSync('documentation.md', markdown);
253
-
254
- // Generate HTML
255
- const html = generator.generate(ast, {
256
- format: 'html',
257
- includeTableOfContents: true,
258
- includeExamples: true
259
- });
260
- writeFileSync('documentation.html', html);
261
-
262
- // Generate OpenAPI
263
- const openapi = generator.generate(ast, {
264
- format: 'openapi',
265
- baseUrl: 'https://api.example.com'
266
- });
267
- writeFileSync('openapi.json', openapi);
268
-
269
- console.log('✅ Documentation generated (Markdown, HTML, OpenAPI)');
270
- return markdown;
271
- } catch (error) {
272
- console.warn('⚠️ Documentation generation failed:', error.message);
273
- }
274
- }
275
-
276
- // ============================================
277
- // MAIN EXAMPLE
278
- // ============================================
279
-
280
- async function main() {
281
- const specFile = '../01-fundamentals/01-01-basic-model.specly';
282
-
283
- // Basic operations
284
- console.log('1️⃣ Parsing...');
285
- const ast = parseSpec(specFile);
286
-
287
- if (ast) {
288
- console.log('2️⃣ Analyzing...');
289
- const stats = analyzeSpec(ast);
290
- console.log(' Stats:', stats);
291
-
292
- console.log('3️⃣ Running inference...');
293
- await runInference(specFile);
294
-
295
- console.log('4️⃣ Generating outputs...');
296
- generateAIView(ast);
297
- generateDiagrams(ast);
298
- generateDocs(ast);
299
-
300
- console.log('5️⃣ Converting to YAML...');
301
- speclyToYaml(specFile, 'converted.yaml');
302
- }
303
-
304
- console.log('\n✨ Done!');
305
- }
306
-
307
- // Run if executed directly
308
- if (import.meta.url === `file://${process.argv[1]}`) {
309
- main().catch(console.error);
310
- }
311
-
312
- // Export functions for use in other modules
313
- export {
314
- parseSpec,
315
- validateSpec,
316
- speclyToYaml,
317
- analyzeSpec,
318
- generateReport,
319
- runInference,
320
- generateAIView,
321
- generateDiagrams,
322
- generateDocs
323
- };