@intijs/cli 0.0.0-stage → 0.1.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 (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -2
  3. package/bin/inti-dev.ts +40 -0
  4. package/bin/inti.js +54 -0
  5. package/dist/commands/dev.d.ts +2 -0
  6. package/dist/commands/dev.d.ts.map +1 -0
  7. package/dist/commands/dev.js +12 -0
  8. package/dist/commands/generate.d.ts +25 -0
  9. package/dist/commands/generate.d.ts.map +1 -0
  10. package/dist/commands/generate.js +149 -0
  11. package/dist/commands/sync.d.ts +2 -0
  12. package/dist/commands/sync.d.ts.map +1 -0
  13. package/dist/commands/sync.js +114 -0
  14. package/dist/generator/ai-generator.d.ts +14 -0
  15. package/dist/generator/ai-generator.d.ts.map +1 -0
  16. package/dist/generator/ai-generator.js +55 -0
  17. package/dist/generator/component-generator.d.ts +42 -0
  18. package/dist/generator/component-generator.d.ts.map +1 -0
  19. package/dist/generator/component-generator.js +228 -0
  20. package/dist/generator/index.d.ts +5 -0
  21. package/dist/generator/index.d.ts.map +1 -0
  22. package/dist/generator/index.js +3 -0
  23. package/dist/generator/sdk-generator.d.ts +7 -0
  24. package/dist/generator/sdk-generator.d.ts.map +1 -0
  25. package/dist/generator/sdk-generator.js +114 -0
  26. package/dist/generator/types-generator.d.ts +16 -0
  27. package/dist/generator/types-generator.d.ts.map +1 -0
  28. package/dist/generator/types-generator.js +155 -0
  29. package/dist/index.d.ts +8 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +7 -0
  32. package/package.json +49 -4
  33. package/src/commands/dev.ts +14 -0
  34. package/src/commands/generate.ts +194 -0
  35. package/src/commands/sync.ts +134 -0
  36. package/src/generator/ai-generator.ts +62 -0
  37. package/src/generator/component-generator.ts +314 -0
  38. package/src/generator/index.ts +4 -0
  39. package/src/generator/types-generator.ts +167 -0
  40. package/src/index.ts +10 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024–present Inti.js Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Temporary Holding Version
1
+ # @intijs/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Generates TypeScript types from your CMS schema. Part of [Inti](https://github.com/intijs/inti), currently in beta.
4
+
5
+ > **Not on npm yet.** The `@intijs` packages will be published there. Until then the `npm install` command below answers 404: install from git as described under [Installation](https://github.com/intijs/inti#-installation) in the repository README.
6
+
7
+ ```bash
8
+ npm install -D @intijs/cli
9
+ npx @intijs/cli sync
10
+ ```
11
+
12
+ `inti sync` reads `inti.config.ts`, asks the adapter for the schema, and writes to `outputDir` (`./src/lib/inti` by default):
13
+
14
+ | File | Contents |
15
+ |---|---|
16
+ | `inti.types.ts` | One interface per block type, plus `IntiTypedBlock`, a union discriminated by `type` |
17
+ | `inti-manifest.json` | The block manifest for AI tools |
18
+ | `inti-mocks.ts` | Sample data |
19
+
20
+ ```ts
21
+ // inti.config.ts
22
+ import { defineConfig } from '@intijs/core';
23
+
24
+ export default defineConfig({
25
+ adapter: 'wordpress',
26
+ adapterConfig: { endpoint: process.env.INTI_WP_ENDPOINT }
27
+ });
28
+ ```
29
+
30
+ ```ts
31
+ import type { IntiTypedBlock } from './lib/inti/inti.types';
32
+
33
+ const blocks = page.blocks as IntiTypedBlock[];
34
+ if (blocks[0].type === 'hero') blocks[0].data.headline; // string
35
+ ```
36
+
37
+ It generates types, not a fetch SDK: content is always read with the adapter. See the [guide](https://github.com/intijs/inti/blob/main/apps/docs/src/content/docs/cli/sync.mdx).
38
+
39
+ MIT
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env bun
2
+
3
+ import { syncCommand } from '../src/commands/sync.ts';
4
+ import { devCommand } from '../src/commands/dev.ts';
5
+
6
+ const args = process.argv.slice(2);
7
+ const command = args[0];
8
+
9
+ async function main() {
10
+ switch (command) {
11
+ case 'sync':
12
+ await syncCommand();
13
+ break;
14
+ case 'dev':
15
+ await devCommand(args.slice(1));
16
+ break;
17
+ case 'help':
18
+ case '--help':
19
+ case '-h':
20
+ default:
21
+ console.log(`
22
+ ╔══════════════════════════════════════════════════════════╗
23
+ ║ Inti.js CLI — visual editing layer for Astro ║
24
+ ╚══════════════════════════════════════════════════════════╝
25
+
26
+ Commands:
27
+ inti sync Generate TypeScript types from CMS schema
28
+ inti dev Run "astro dev" (its arguments are passed through)
29
+ inti help Show this help message
30
+
31
+ Examples:
32
+ bun inti sync # Sync types from configured CMS
33
+
34
+ For more information, visit: https://github.com/intijs/inti
35
+ `);
36
+ break;
37
+ }
38
+ }
39
+
40
+ main().catch(console.error);
package/bin/inti.js ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { syncCommand } from '../dist/commands/sync.js';
4
+ import { devCommand } from '../dist/commands/dev.js';
5
+
6
+ const args = process.argv.slice(2);
7
+ const command = args[0];
8
+
9
+ /**
10
+ * Value of a flag: `--config path` or `--config=path`. The help advertised
11
+ * `--config` from the start, but it was never read: `sync` always used
12
+ * ./inti.config.ts.
13
+ */
14
+ function flag(name) {
15
+ const prefix = `--${name}=`;
16
+ const inline = args.find((arg) => arg.startsWith(prefix));
17
+ if (inline) return inline.slice(prefix.length);
18
+ const index = args.indexOf(`--${name}`);
19
+ return index >= 0 ? args[index + 1] : undefined;
20
+ }
21
+
22
+ async function main() {
23
+ switch (command) {
24
+ case 'sync':
25
+ await syncCommand(flag('config'));
26
+ break;
27
+ case 'dev':
28
+ await devCommand(args.slice(1));
29
+ break;
30
+ case 'help':
31
+ case '--help':
32
+ case '-h':
33
+ default:
34
+ console.log(`
35
+ ╔══════════════════════════════════════════════════════════╗
36
+ ║ Inti.js CLI — visual editing layer for Astro ║
37
+ ╚══════════════════════════════════════════════════════════╝
38
+
39
+ Commands:
40
+ inti sync Generate TypeScript types from CMS schema
41
+ inti dev Run "astro dev" (its arguments are passed through)
42
+ inti help Show this help message
43
+
44
+ Examples:
45
+ npx @intijs/cli sync # Types from ./inti.config.ts
46
+ npx @intijs/cli sync --config ./config/inti.ts # Use another config file
47
+
48
+ For more information, visit: https://github.com/intijs/inti
49
+ `);
50
+ break;
51
+ }
52
+ }
53
+
54
+ main().catch(console.error);
@@ -0,0 +1,2 @@
1
+ export declare function devCommand(args?: string[]): Promise<void>;
2
+ //# sourceMappingURL=dev.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,wBAAsB,UAAU,CAAC,IAAI,GAAE,MAAM,EAAO,iBAanD"}
@@ -0,0 +1,12 @@
1
+ export async function devCommand(args = []) {
2
+ // Runs `astro dev` with the given arguments. It adds nothing of its own.
3
+ console.log('Running astro dev…\n');
4
+ const { spawn } = await import('child_process');
5
+ const astro = spawn('astro', ['dev', ...args], {
6
+ stdio: 'inherit',
7
+ shell: true
8
+ });
9
+ astro.on('close', (code) => {
10
+ process.exit(code || 0);
11
+ });
12
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @module commands/generate
3
+ * CLI command handler for `inti generate`.
4
+ * Introspects the CMS schema via the configured adapter and generates
5
+ * ready-to-use Astro component files in the project.
6
+ */
7
+ export interface GenerateCommandOptions {
8
+ /** Directory to write generated components into */
9
+ outputDir?: string;
10
+ /** Whether to overwrite existing component files */
11
+ overwrite?: boolean;
12
+ /** Style preset: 'minimal' (no classes) or 'styled' (Tailwind/UnoCSS) */
13
+ style?: string;
14
+ }
15
+ /**
16
+ * Execute the `inti generate` command.
17
+ *
18
+ * Loads the project config, resolves the CMS adapter, introspects the schema,
19
+ * generates `.astro` components for each collection, and writes them to disk.
20
+ *
21
+ * @param configPath - Path to the inti config file (default: `./inti.config.ts`)
22
+ * @param options - Optional overrides for output directory, overwrite, and style
23
+ */
24
+ export declare function generateCommand(configPath?: string, options?: GenerateCommandOptions): Promise<void>;
25
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,MAAM,WAAW,sBAAsB;IACnC,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAMD;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACjC,UAAU,GAAE,MAA2B,EACvC,OAAO,CAAC,EAAE,sBAAsB,GACjC,OAAO,CAAC,IAAI,CAAC,CA0Ff"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * @module commands/generate
3
+ * CLI command handler for `inti generate`.
4
+ * Introspects the CMS schema via the configured adapter and generates
5
+ * ready-to-use Astro component files in the project.
6
+ */
7
+ import { writeFileSync, existsSync, mkdirSync } from 'fs';
8
+ import { resolve } from 'path';
9
+ import { pathToFileURL } from 'url';
10
+ import { generateAstroComponents } from '../generator/index.js';
11
+ // ============================================
12
+ // Command Implementation
13
+ // ============================================
14
+ /**
15
+ * Execute the `inti generate` command.
16
+ *
17
+ * Loads the project config, resolves the CMS adapter, introspects the schema,
18
+ * generates `.astro` components for each collection, and writes them to disk.
19
+ *
20
+ * @param configPath - Path to the inti config file (default: `./inti.config.ts`)
21
+ * @param options - Optional overrides for output directory, overwrite, and style
22
+ */
23
+ export async function generateCommand(configPath = './inti.config.ts', options) {
24
+ console.log('🧩 Starting Inti Component Generation...');
25
+ try {
26
+ // Step 1: Load config
27
+ const fullConfigPath = resolve(process.cwd(), configPath);
28
+ if (!existsSync(fullConfigPath)) {
29
+ console.error(`❌ Config file not found at ${fullConfigPath}`);
30
+ process.exit(1);
31
+ }
32
+ const config = await loadConfig(fullConfigPath);
33
+ console.log(`📡 Using adapter: ${config.adapter}`);
34
+ // Step 2: Resolve and initialise adapter
35
+ const AdapterClass = await resolveAdapterClass(config.adapter);
36
+ const adapter = new AdapterClass(config.adapterConfig);
37
+ // Step 3: Introspect CMS
38
+ console.log('🔍 Introspecting CMS schema...');
39
+ const schema = await adapter.introspect();
40
+ console.log(` Found ${schema.collections.length} collections.`);
41
+ if (schema.collections.length === 0) {
42
+ console.log('⚠️ No collections found — nothing to generate.');
43
+ return;
44
+ }
45
+ // Step 4: Resolve options
46
+ const outputDir = resolve(process.cwd(), options?.outputDir || config.componentsDir || './src/components/blocks');
47
+ const overwrite = options?.overwrite ?? false;
48
+ const style = (options?.style === 'minimal' ? 'minimal' : 'styled');
49
+ // Ensure output directory exists
50
+ if (!existsSync(outputDir)) {
51
+ mkdirSync(outputDir, { recursive: true });
52
+ }
53
+ // Step 5: Generate components
54
+ console.log('\n🧱 Generating Astro components...');
55
+ const generatorOptions = {
56
+ outputDir,
57
+ overwrite,
58
+ style,
59
+ includeProps: true,
60
+ includeJsDoc: true,
61
+ };
62
+ const components = generateAstroComponents(schema, generatorOptions);
63
+ // Step 6: Write to disk
64
+ let created = 0;
65
+ let skipped = 0;
66
+ for (const component of components) {
67
+ const filePath = resolve(outputDir, component.filename);
68
+ const exists = existsSync(filePath);
69
+ if (exists && !overwrite) {
70
+ component.isNew = false;
71
+ skipped++;
72
+ console.log(` ⏭️ Skipped (exists): ${component.filename}`);
73
+ continue;
74
+ }
75
+ writeFileSync(filePath, component.content, 'utf-8');
76
+ component.isNew = !exists;
77
+ created++;
78
+ console.log(` ✅ ${exists ? 'Overwrote' : 'Created'}: ${filePath.replace(process.cwd(), '.')}`);
79
+ }
80
+ // Step 7: Summary
81
+ console.log('\n─────────────────────────────────────');
82
+ console.log(`🎉 Component generation complete!`);
83
+ console.log(` 📂 Output: ${outputDir.replace(process.cwd(), '.')}`);
84
+ console.log(` ✅ Created: ${created}`);
85
+ if (skipped > 0) {
86
+ console.log(` ⏭️ Skipped: ${skipped} (use --overwrite to replace)`);
87
+ }
88
+ console.log('─────────────────────────────────────\n');
89
+ }
90
+ catch (error) {
91
+ console.error('❌ Generation failed:');
92
+ console.error(error instanceof Error ? error.message : error);
93
+ process.exit(1);
94
+ }
95
+ }
96
+ // ============================================
97
+ // Internal Helpers (mirrored from sync.ts)
98
+ // ============================================
99
+ /**
100
+ * Load config from file
101
+ */
102
+ async function loadConfig(configPath) {
103
+ try {
104
+ const fileUrl = pathToFileURL(configPath).href;
105
+ const module = await import(fileUrl);
106
+ const config = module.default || module;
107
+ if (!config.adapter) {
108
+ throw new Error('Config must specify "adapter"');
109
+ }
110
+ return config;
111
+ }
112
+ catch (error) {
113
+ throw new Error(`Failed to load config: ${error instanceof Error ? error.message : error}`);
114
+ }
115
+ }
116
+ /**
117
+ * Resolve adapter class dynamically
118
+ */
119
+ async function resolveAdapterClass(adapterName) {
120
+ const tryPackages = [
121
+ `@intijs/adapter-${adapterName}`,
122
+ `inti-adapter-${adapterName}`,
123
+ ];
124
+ for (const pkg of tryPackages) {
125
+ try {
126
+ const module = await import(pkg);
127
+ const AdapterClass = module.default || Object.values(module).find((v) => typeof v === 'function');
128
+ if (AdapterClass) {
129
+ return AdapterClass;
130
+ }
131
+ }
132
+ catch {
133
+ continue;
134
+ }
135
+ }
136
+ // Fallback to internal core adapters if name matches
137
+ if (adapterName === 'contentful' || adapterName === 'strapi' || adapterName === 'sanity') {
138
+ try {
139
+ const pkg = `@intijs/core/adapters`;
140
+ const module = await import(pkg);
141
+ const className = `${adapterName.charAt(0).toUpperCase()}${adapterName.slice(1)}Adapter`;
142
+ if (module[className])
143
+ return module[className];
144
+ }
145
+ catch { }
146
+ }
147
+ throw new Error(`Adapter "${adapterName}" not found.\n` +
148
+ `Try installing: bun add @intijs/adapter-${adapterName}`);
149
+ }
@@ -0,0 +1,2 @@
1
+ export declare function syncCommand(configPath?: string): Promise<void>;
2
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAQA,wBAAsB,WAAW,CAAC,UAAU,GAAE,MAA2B,iBAoExE"}
@@ -0,0 +1,114 @@
1
+ import { writeFileSync, existsSync, mkdirSync } from 'fs';
2
+ import { resolve } from 'path';
3
+ import { pathToFileURL } from 'url';
4
+ // Import generators directly
5
+ import { generateTypeDefinitions, generateAIManifest, generateMockData } from '../generator/index.js';
6
+ import { registry } from '@intijs/core/registry';
7
+ export async function syncCommand(configPath = './inti.config.ts') {
8
+ console.log('🚀 Starting Inti Sync...');
9
+ try {
10
+ // Step 1: Load config
11
+ const fullConfigPath = resolve(process.cwd(), configPath);
12
+ if (!existsSync(fullConfigPath)) {
13
+ console.error(`❌ Config file not found at ${fullConfigPath}`);
14
+ process.exit(1);
15
+ }
16
+ const config = await loadConfig(fullConfigPath);
17
+ console.log(`📡 Using adapter: ${config.adapter}`);
18
+ // Step 2: Resolve and initialize adapter
19
+ const AdapterClass = await resolveAdapterClass(config.adapter);
20
+ const adapter = new AdapterClass(config.adapterConfig);
21
+ // Step 3: Introspect CMS
22
+ console.log('🔍 Introspecting CMS schema...');
23
+ const schema = await adapter.introspect();
24
+ console.log(` Found ${schema.collections.length} collections.`);
25
+ // Step 4: Generate code
26
+ const finalOutputDir = resolve(process.cwd(), config.outputDir || './src/lib/inti');
27
+ // Ensure output directory exists
28
+ if (!existsSync(finalOutputDir)) {
29
+ mkdirSync(finalOutputDir, { recursive: true });
30
+ }
31
+ // Generate types file
32
+ console.log('\n📝 Generating TypeScript types...');
33
+ const typesContent = generateTypeDefinitions(schema);
34
+ const typesPath = resolve(finalOutputDir, 'inti.types.ts');
35
+ writeFileSync(typesPath, typesContent);
36
+ console.log(` ✓ Generated: ${typesPath.replace(process.cwd(), '.')}`);
37
+ // Development versions also generated inti-sdk.ts, with functions that
38
+ // requested `${endpoint}/api/<collection>`: a route that no supported
39
+ // CMS has. Content is read with the adapter. A user's file is not
40
+ // deleted without asking; we warn instead.
41
+ const legacySdk = resolve(finalOutputDir, 'inti-sdk.ts');
42
+ if (existsSync(legacySdk)) {
43
+ console.warn(` ⚠ ${legacySdk.replace(process.cwd(), '.')} is from an earlier development version and its functions do not ` +
44
+ 'work with any supported CMS. Delete it and read content with the adapter.');
45
+ }
46
+ // Step 5: AI-Native Generation
47
+ console.log('🤖 Generating AI Discovery Manifest...');
48
+ const manifest = registry.getManifest ? registry.getManifest() : {};
49
+ const manifestPath = generateAIManifest(manifest, finalOutputDir);
50
+ console.log(` ✓ Generated: ${manifestPath.replace(process.cwd(), '.')}`);
51
+ console.log('🧪 Generating Mock Data examples...');
52
+ const mocksPath = generateMockData(manifest, finalOutputDir);
53
+ console.log(` ✓ Generated: ${mocksPath.replace(process.cwd(), '.')}`);
54
+ // Success
55
+ console.log('\n✅ Synchronization complete!');
56
+ }
57
+ catch (error) {
58
+ console.error('❌ Sync failed:');
59
+ console.error(error instanceof Error ? error.message : error);
60
+ process.exit(1);
61
+ }
62
+ }
63
+ /**
64
+ * Load config from file
65
+ */
66
+ async function loadConfig(configPath) {
67
+ try {
68
+ const fileUrl = pathToFileURL(configPath).href;
69
+ const module = await import(fileUrl);
70
+ const config = module.default || module;
71
+ if (!config.adapter) {
72
+ throw new Error('Config must specify "adapter"');
73
+ }
74
+ return config;
75
+ }
76
+ catch (error) {
77
+ throw new Error(`Failed to load config: ${error instanceof Error ? error.message : error}`);
78
+ }
79
+ }
80
+ /**
81
+ * Resolve adapter class dynamically
82
+ */
83
+ async function resolveAdapterClass(adapterName) {
84
+ const tryPackages = [
85
+ `@intijs/adapter-${adapterName}`,
86
+ `inti-adapter-${adapterName}`
87
+ ];
88
+ for (const pkg of tryPackages) {
89
+ try {
90
+ const module = await import(pkg);
91
+ // Try default export first, then look for any exported function
92
+ const AdapterClass = module.default || Object.values(module).find((v) => typeof v === 'function');
93
+ if (AdapterClass) {
94
+ return AdapterClass;
95
+ }
96
+ }
97
+ catch {
98
+ continue;
99
+ }
100
+ }
101
+ // Fallback to internal core adapters if name matches
102
+ if (adapterName === 'contentful' || adapterName === 'strapi' || adapterName === 'sanity' || adapterName === 'kitsuden') {
103
+ try {
104
+ const pkg = `@intijs/core/adapters`;
105
+ const module = await import(pkg);
106
+ const className = `${adapterName.charAt(0).toUpperCase()}${adapterName.slice(1)}Adapter`;
107
+ if (module[className])
108
+ return module[className];
109
+ }
110
+ catch { }
111
+ }
112
+ throw new Error(`Adapter "${adapterName}" not found.\n` +
113
+ `Try installing: bun add @intijs/adapter-${adapterName}`);
114
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * AI Manifest Generator
3
+ * Generates a JSON file describing all available Inti blocks.
4
+ * This file acts as a "source of truth" for AI agents to understand
5
+ * what components can be used to build pages.
6
+ */
7
+ export declare function generateAIManifest(manifest: Record<string, any>, outputDir: string): string;
8
+ /**
9
+ * Mock Data Generator
10
+ * Generates example JSON structures for the CMS based on the manifest.
11
+ * This helps AI agents create realistic test data.
12
+ */
13
+ export declare function generateMockData(manifest: Record<string, any>, outputDir: string): string;
14
+ //# sourceMappingURL=ai-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-generator.d.ts","sourceRoot":"","sources":["../../src/generator/ai-generator.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAiB3F;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CA4BzF"}
@@ -0,0 +1,55 @@
1
+ import { writeFileSync } from 'fs';
2
+ import { resolve } from 'path';
3
+ /**
4
+ * AI Manifest Generator
5
+ * Generates a JSON file describing all available Inti blocks.
6
+ * This file acts as a "source of truth" for AI agents to understand
7
+ * what components can be used to build pages.
8
+ */
9
+ export function generateAIManifest(manifest, outputDir) {
10
+ const manifestPath = resolve(outputDir, 'inti-manifest.json');
11
+ // Enrich manifest with AI instructions
12
+ const aiManifest = {
13
+ _instructions: {
14
+ goal: "Use this manifest to construct valid IntiPage and IntiBlock structures.",
15
+ blockRules: "Each block in 'blocks' object contains metadata about its component. 'type' matches the 'type' field in an IntiBlock.",
16
+ mapping: "When building a page, map CMS fields to the properties defined in these blocks.",
17
+ styles: "Components are styled with UnoCSS (Tailwind-compatible). Use utility classes for customization."
18
+ },
19
+ blocks: manifest,
20
+ projectRules: "Blocks are declared in code and composed by editors. Never invent block types that are not listed here."
21
+ };
22
+ writeFileSync(manifestPath, JSON.stringify(aiManifest, null, 2));
23
+ return manifestPath;
24
+ }
25
+ /**
26
+ * Mock Data Generator
27
+ * Generates example JSON structures for the CMS based on the manifest.
28
+ * This helps AI agents create realistic test data.
29
+ */
30
+ export function generateMockData(manifest, outputDir) {
31
+ const mocksPath = resolve(outputDir, 'inti-mocks.ts');
32
+ const mocks = {};
33
+ for (const [type, reg] of Object.entries(manifest)) {
34
+ mocks[type] = reg.mockData || {
35
+ title: `Example ${type}`,
36
+ description: `This is a high-quality placeholder for the ${type} block, designed to help AI agents understand the expected structure.`,
37
+ content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
38
+ image: {
39
+ url: "https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe",
40
+ alt: `Placeholder for ${type}`
41
+ }
42
+ };
43
+ }
44
+ const content = `/**
45
+ * Inti Mock Data
46
+ * Generated automatically. Use these examples for testing and AI prompting.
47
+ */
48
+
49
+ export const IntiMocks = ${JSON.stringify(mocks, null, 2)};
50
+
51
+ export default IntiMocks;
52
+ `;
53
+ writeFileSync(mocksPath, content);
54
+ return mocksPath;
55
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @module component-generator
3
+ * Generates Astro component files from CMS schema introspection.
4
+ * Each collection in the schema produces a ready-to-use `.astro` component
5
+ * with typed props, semantic HTML, and Visual Bridge compatibility attributes.
6
+ */
7
+ import type { SchemaDefinition } from '@intijs/core/adapters';
8
+ /** Options for the Astro component generator */
9
+ export interface ComponentGeneratorOptions {
10
+ /** Directory where generated components will be written */
11
+ outputDir: string;
12
+ /** Whether to overwrite existing component files (default: false) */
13
+ overwrite?: boolean;
14
+ /** Generate with or without Tailwind/UnoCSS utility classes (default: 'styled') */
15
+ style?: 'minimal' | 'styled';
16
+ /** Include a typed Astro Props interface in the frontmatter (default: true) */
17
+ includeProps?: boolean;
18
+ /** Include JSDoc comments in the generated component (default: true) */
19
+ includeJsDoc?: boolean;
20
+ }
21
+ /** Represents a single generated component and its metadata */
22
+ export interface GeneratedComponent {
23
+ /** PascalCase component name derived from the collection */
24
+ name: string;
25
+ /** Output filename, e.g. `BlogPost.astro` */
26
+ filename: string;
27
+ /** Full resolved path on disk */
28
+ path: string;
29
+ /** Complete file content ready to be written */
30
+ content: string;
31
+ /** Whether this component did not previously exist on disk */
32
+ isNew: boolean;
33
+ }
34
+ /**
35
+ * Generate Astro component files for every collection in the schema.
36
+ *
37
+ * @param schema - The introspected CMS schema definition
38
+ * @param options - Generation options (output dir, style, overwrite, etc.)
39
+ * @returns An array of {@link GeneratedComponent} objects ready for writing to disk
40
+ */
41
+ export declare function generateAstroComponents(schema: SchemaDefinition, options: ComponentGeneratorOptions): GeneratedComponent[];
42
+ //# sourceMappingURL=component-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-generator.d.ts","sourceRoot":"","sources":["../../src/generator/component-generator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAA4C,MAAM,uBAAuB,CAAC;AAMxG,gDAAgD;AAChD,MAAM,WAAW,yBAAyB;IACtC,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mFAAmF;IACnF,KAAK,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC7B,+EAA+E;IAC/E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,wEAAwE;IACxE,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,+DAA+D;AAC/D,MAAM,WAAW,kBAAkB;IAC/B,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,KAAK,EAAE,OAAO,CAAC;CAClB;AAgPD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACnC,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,yBAAyB,GACnC,kBAAkB,EAAE,CAwBtB"}