oneie 1.3.3 → 1.4.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 (180) hide show
  1. package/.claude/agents/engineering-architect.md +39 -56
  2. package/.claude/agents/engineering-developer.md +37 -57
  3. package/.claude/agents/engineering-director.md +37 -144
  4. package/.claude/agents/engineering-ingestor.md +229 -0
  5. package/.claude/agents/engineering-quality-assurance.md +40 -206
  6. package/.claude/agents/engineering-user-experience.md +36 -207
  7. package/.claude/agents/improver.md +454 -0
  8. package/.claude/agents/marketing-brand-identity.md +37 -48
  9. package/.claude/agents/marketing-director.md +9 -0
  10. package/.claude/agents/one-orchestrator.md +50 -136
  11. package/.claude/agents/story-teller.md +10 -0
  12. package/.claude/agents/task-master.md +10 -0
  13. package/.claude/agents/turbo-repo-builder.md +51 -0
  14. package/.claude/claude-code-hooks.json +20 -233
  15. package/.claude/commands/agent-balance +111 -0
  16. package/.claude/commands/agent.md +24 -7
  17. package/.claude/commands/cascade-status.md +128 -0
  18. package/.claude/commands/ingest.md +290 -0
  19. package/.claude/commands/ingestor.md +136 -0
  20. package/.claude/commands/mission.md +26 -8
  21. package/.claude/commands/one.md +351 -14
  22. package/.claude/commands/quality-check.md +204 -0
  23. package/.claude/commands/smart-route.md +220 -0
  24. package/.claude/commands/start.md +9 -8
  25. package/.claude/commands/story.md +18 -3
  26. package/.claude/commands/task.md +22 -1
  27. package/.claude/settings.local.json +18 -3
  28. package/.obsidian/core-plugins.json +3 -1
  29. package/.one/checklists/agent-quality-checklist.md +24 -15
  30. package/.one/checklists/story-quality-checklist.md +24 -15
  31. package/.one/checklists/task-quality-checklist.md +24 -15
  32. package/.one/templates/bun-workspace-guide-template.md +188 -0
  33. package/.one/templates/bunfig-template.toml +95 -0
  34. package/.one/templates/root-package-template.json +37 -21
  35. package/.one/templates/turbo-config-template.json +18 -3
  36. package/.one/tools/bump-core-version.js +0 -0
  37. package/.one/tools/bump-expansion-version.js +0 -0
  38. package/.one/tools/code-generators.js +0 -0
  39. package/.one/tools/compression-engine.js +638 -0
  40. package/.one/tools/content-deduplicator.js +336 -0
  41. package/.one/tools/convert-wav-to-mp3.js +0 -0
  42. package/.one/tools/foundation-wizard.js +0 -0
  43. package/.one/tools/generate-toc.js +0 -0
  44. package/.one/tools/ingestor/cascade-integration.js +523 -0
  45. package/.one/tools/ingestor/cli.ts +234 -0
  46. package/.one/tools/ingestor/context-mapper.ts +604 -0
  47. package/.one/tools/ingestor/error-handling-monitor.js +742 -0
  48. package/.one/tools/ingestor/file-discovery.ts +484 -0
  49. package/.one/tools/ingestor/file-transformer.ts +524 -0
  50. package/.one/tools/ingestor/ingestor-orchestrator.ts +416 -0
  51. package/.one/tools/ingestor/package.json +47 -0
  52. package/.one/tools/ingestor/usage-examples.md +458 -0
  53. package/.one/tools/lazy-loader.js +489 -0
  54. package/.one/tools/minimal-generators.js +0 -0
  55. package/.one/tools/performance-benchmark.js +300 -0
  56. package/.one/tools/premium-manager.js +0 -0
  57. package/.one/tools/semantic-release-sync-installer.js +0 -0
  58. package/.one/tools/size-memory-optimizer.js +475 -0
  59. package/.one/tools/sync-installer-version.js +0 -0
  60. package/.one/tools/text-to-speech.js +0 -0
  61. package/.one/tools/transformative-ai-engine.js +0 -0
  62. package/.one/workflows/safe-improvement-deployment.yaml +420 -0
  63. package/CLAUDE.md +30 -0
  64. package/README.md +41 -10
  65. package/bin/oneie/index.js +733 -64
  66. package/one/cache/benchmark-results.json +43 -0
  67. package/one/cache/file-index.json +12480 -0
  68. package/one/config/agent-routing.yaml +124 -0
  69. package/one/config/agent-skills.yaml +451 -0
  70. package/one/config/cache-config.yaml +304 -0
  71. package/one/config/feedback-templates.yaml +152 -0
  72. package/one/config/performance-config.yaml +281 -0
  73. package/one/config/quality-automation.yaml +405 -0
  74. package/one/config/routing-logic.yaml +292 -0
  75. package/one/data/task-registry.yaml +224 -0
  76. package/one/stories/story-1.10-parallel-task-execution-orchestration.md +119 -0
  77. package/one/stories/story-3.1-external-repository-foundation.md +374 -0
  78. package/one/stories/story-3.2-3-levels-architecture-integration.md +449 -0
  79. package/one/stories/story-3.3-multi-platform-application-development.md +677 -0
  80. package/one/stories/story-3.4-shared-package-system-ui-components.md +854 -0
  81. package/one/stories/story-3.5-backend-integration-production-deployment.md +1034 -0
  82. package/one/tasks/task-1.10.1-design-parallel-execution-architecture.md +108 -0
  83. package/one/tasks/task-1.10.2-create-task-dependency-mapping-system.md +82 -0
  84. package/one/tasks/task-1.10.3-build-agent-spawning-orchestration-engine.md +120 -0
  85. package/one/tasks/task-1.10.4-implement-task-queue-dependency-resolution.md +125 -0
  86. package/one/tasks/task-1.10.5-create-task-numbering-convention-system.md +542 -0
  87. package/one/tasks/task-3.1.1-external-repository-creation.md +303 -0
  88. package/one/tasks/task-3.1.2-turborepo-configuration-optimization.md +402 -0
  89. package/one/tasks/task-3.1.3-shared-configuration-packages.md +571 -0
  90. package/one/tasks/task-3.1.4-bun-package-management-optimization.md +627 -0
  91. package/one/tools/task-numbering-validator.js +429 -0
  92. package/package.json +1 -1
  93. package/quality-gate-optimization-analysis.md +260 -0
  94. package/turbo-benchmark.js +268 -0
  95. package/turbo-optimization-guide.md +163 -0
  96. package/turbo-workspace-template.json +83 -0
  97. package/turbo.json +178 -0
  98. package/.claude/commands/analyst.md +0 -70
  99. package/.claude/commands/architect.md +0 -67
  100. package/.claude/commands/commander.md +0 -78
  101. package/.claude/commands/deploy.md +0 -68
  102. package/.claude/commands/dev.md +0 -60
  103. package/.claude/commands/playbook.md +0 -81
  104. package/.claude/commands/pm.md +0 -64
  105. package/.claude/commands/po.md +0 -68
  106. package/.claude/commands/qa.md +0 -59
  107. package/.claude/commands/taskmaster.md +0 -85
  108. package/.claude/commands/ux-expert.md +0 -58
  109. package/.one/stories/bullstamp-attract-module-complete.md +0 -255
  110. package/.one/stories/bullstamp-deployment-master-plan.md +0 -518
  111. package/.one/stories/bullstamp-executive-implementation-summary.md +0 -254
  112. package/.one/stories/bullstamp-project-status-complete.md +0 -257
  113. package/.one/stories/obsidian-pandoc-config.md +0 -159
  114. package/.one/stories/story-1.1-perfect-filesystem-organization.md +0 -270
  115. package/.one/stories/story-1.1.1.md +0 -136
  116. package/.one/stories/story-1.1.md +0 -131
  117. package/.one/stories/story-1.2.md +0 -420
  118. package/.one/stories/story-1.3.md +0 -177
  119. package/.one/stories/story-1.4.md +0 -356
  120. package/.one/stories/story-1.5.md +0 -572
  121. package/.one/stories/story-1.6.md +0 -481
  122. package/.one/stories/story-1.7.md +0 -923
  123. package/.one/stories/story-1.8.md +0 -404
  124. package/.one/stories/story-2.0.md +0 -132
  125. package/.one/stories/story-2.1.md +0 -110
  126. package/.one/stories/story-2.2.md +0 -110
  127. package/.one/stories/story-2.3.md +0 -112
  128. package/.one/stories/story-2.4.md +0 -116
  129. package/.one/stories/story-2.5.md +0 -114
  130. package/.one/stories/story-3.1.md +0 -298
  131. package/.one/stories/story-3.10.md +0 -302
  132. package/.one/stories/story-3.11.md +0 -167
  133. package/.one/stories/story-3.12.md +0 -235
  134. package/.one/stories/story-3.13.md +0 -235
  135. package/.one/stories/story-3.14.md +0 -225
  136. package/.one/stories/story-3.15.md +0 -238
  137. package/.one/stories/story-3.16.md +0 -244
  138. package/.one/stories/story-3.17.md +0 -245
  139. package/.one/stories/story-3.18.md +0 -248
  140. package/.one/stories/story-3.2.md +0 -226
  141. package/.one/stories/story-3.3.md +0 -226
  142. package/.one/stories/story-3.4.md +0 -226
  143. package/.one/stories/story-3.5.md +0 -167
  144. package/.one/stories/story-3.6.md +0 -167
  145. package/.one/stories/story-3.7.md +0 -181
  146. package/.one/stories/story-3.8.md +0 -198
  147. package/.one/stories/story-3.9.md +0 -169
  148. package/.one/stories/story-4.1.md +0 -245
  149. package/.one/stories/story-4.2.md +0 -314
  150. package/.one/stories/story-4.3.md +0 -610
  151. package/.one/stories/story-4.4.md +0 -931
  152. package/.one/stories/story-4.5.md +0 -727
  153. package/.one/stories/story-4.6-consistency.md +0 -175
  154. package/.one/stories/story-5.1.md +0 -508
  155. package/.one/stories/story-5.2.md +0 -451
  156. package/.one/stories/story-5.3.md +0 -405
  157. package/.one/stories/story-5.4.md +0 -447
  158. package/.one/stories/story-5.5.md +0 -349
  159. package/.one/stories/story-5.6.md +0 -445
  160. package/.one/stories/story-6.1-text-content-engine.md +0 -144
  161. package/.one/stories/story-6.2-audio-content-engine.md +0 -145
  162. package/.one/stories/story-6.3-video-content-engine.md +0 -145
  163. package/.one/stories/story-6.4-visual-content-engine.md +0 -177
  164. package/.one/stories/story-6.5-cross-platform-distribution.md +0 -188
  165. package/.one/stories/story-6.6.ai-content-generation-pipeline.md +0 -196
  166. package/.one/stories/story-6.7-character-consistency-quality-control.md +0 -216
  167. package/.one/stories/story-6.8-claude-code-content-integration.md +0 -181
  168. package/.one/stories/story-6.8-content-production-workflows.md +0 -247
  169. package/.one/stories/story-7.1-implementation.md +0 -128
  170. package/.one/stories/story-7.1.md +0 -203
  171. package/.one/stories/story-7.2-implementation.md +0 -147
  172. package/.one/stories/story-7.2.md +0 -415
  173. package/.one/stories/story-7.3-implementation.md +0 -159
  174. package/.one/stories/story-7.3.md +0 -463
  175. package/.one/stories/story-7.4-implementation.md +0 -154
  176. package/.one/stories/story-7.4.md +0 -500
  177. package/.one/stories/story-validation-report.md +0 -169
  178. package/one/archive-index.json +0 -91
  179. /package/one/stories/{story-3.1-npx-oneie-turbo-enhancement.md → story-2.1.1-npx-oneie-turbo-enhancement.md} +0 -0
  180. /package/one/stories/{story-3.2-npx-connection-implementation.md → story-2.21-npx-connection-implementation.md} +0 -0
@@ -0,0 +1,524 @@
1
+ import { readFile, writeFile, mkdir } from 'fs/promises';
2
+ import { join, dirname, relative, extname, basename } from 'path';
3
+ import { existsSync } from 'fs';
4
+ import type { DiscoveredFile, FrameworkType, FileClassification } from './file-discovery';
5
+
6
+ export interface TransformationRule {
7
+ pattern: RegExp;
8
+ replacement: string | ((match: string, ...groups: string[]) => string);
9
+ description: string;
10
+ }
11
+
12
+ export interface TransformationContext {
13
+ sourceFramework: FrameworkType;
14
+ targetFramework: FrameworkType;
15
+ sourcePath: string;
16
+ targetPath: string;
17
+ projectStructure: {
18
+ componentsDir: string;
19
+ utilsDir: string;
20
+ hooksDir: string;
21
+ stylesDir: string;
22
+ pagesDir: string;
23
+ apiDir?: string;
24
+ };
25
+ }
26
+
27
+ export class FileTransformer {
28
+ private transformationRules: Map<string, TransformationRule[]> = new Map();
29
+ private frameworkAdapters: Map<string, FrameworkAdapter> = new Map();
30
+
31
+ constructor() {
32
+ this.initializeTransformationRules();
33
+ this.initializeFrameworkAdapters();
34
+ }
35
+
36
+ async transformFile(
37
+ file: DiscoveredFile,
38
+ targetPath: string,
39
+ context: TransformationContext
40
+ ): Promise<{ success: boolean; outputPath: string; warnings: string[] }> {
41
+ const warnings: string[] = [];
42
+
43
+ try {
44
+ // Ensure target directory exists
45
+ await mkdir(dirname(targetPath), { recursive: true });
46
+
47
+ switch (file.classification) {
48
+ case 'direct-copy':
49
+ return await this.directCopy(file.path, targetPath);
50
+
51
+ case 'smart-modify':
52
+ return await this.smartModify(file, targetPath, context, warnings);
53
+
54
+ case 'config-adapt':
55
+ return await this.configAdapt(file, targetPath, context, warnings);
56
+
57
+ case 'manual-review':
58
+ warnings.push(`File requires manual review: ${file.relativePath}`);
59
+ return { success: false, outputPath: targetPath, warnings };
60
+ }
61
+ } catch (error) {
62
+ warnings.push(`Error transforming file: ${error}`);
63
+ return { success: false, outputPath: targetPath, warnings };
64
+ }
65
+ }
66
+
67
+ private async directCopy(sourcePath: string, targetPath: string): Promise<{ success: boolean; outputPath: string; warnings: string[] }> {
68
+ try {
69
+ const content = await readFile(sourcePath);
70
+ await writeFile(targetPath, content);
71
+ return { success: true, outputPath: targetPath, warnings: [] };
72
+ } catch (error) {
73
+ return { success: false, outputPath: targetPath, warnings: [`Copy failed: ${error}`] };
74
+ }
75
+ }
76
+
77
+ private async smartModify(
78
+ file: DiscoveredFile,
79
+ targetPath: string,
80
+ context: TransformationContext,
81
+ warnings: string[]
82
+ ): Promise<{ success: boolean; outputPath: string; warnings: string[] }> {
83
+ try {
84
+ let content = await readFile(file.path, 'utf-8');
85
+
86
+ // Apply framework-specific transformations
87
+ const adapter = this.frameworkAdapters.get(`${context.sourceFramework}->${context.targetFramework}`);
88
+ if (adapter) {
89
+ content = await adapter.transform(content, file, context);
90
+ }
91
+
92
+ // Apply general transformations
93
+ content = this.applyTransformations(content, file, context, warnings);
94
+
95
+ await writeFile(targetPath, content, 'utf-8');
96
+ return { success: true, outputPath: targetPath, warnings };
97
+ } catch (error) {
98
+ warnings.push(`Smart modification failed: ${error}`);
99
+ return { success: false, outputPath: targetPath, warnings };
100
+ }
101
+ }
102
+
103
+ private async configAdapt(
104
+ file: DiscoveredFile,
105
+ targetPath: string,
106
+ context: TransformationContext,
107
+ warnings: string[]
108
+ ): Promise<{ success: boolean; outputPath: string; warnings: string[] }> {
109
+ const fileName = basename(file.path);
110
+
111
+ try {
112
+ if (fileName === 'package.json') {
113
+ return await this.adaptPackageJson(file.path, targetPath, context, warnings);
114
+ }
115
+
116
+ if (fileName === 'tsconfig.json') {
117
+ return await this.adaptTsConfig(file.path, targetPath, context, warnings);
118
+ }
119
+
120
+ if (fileName.startsWith('tailwind.config')) {
121
+ return await this.adaptTailwindConfig(file.path, targetPath, context, warnings);
122
+ }
123
+
124
+ if (fileName.startsWith('next.config') || fileName.startsWith('astro.config') || fileName.startsWith('vite.config')) {
125
+ return await this.adaptFrameworkConfig(file.path, targetPath, context, warnings);
126
+ }
127
+
128
+ // Default: treat as smart modify
129
+ return await this.smartModify(file, targetPath, context, warnings);
130
+ } catch (error) {
131
+ warnings.push(`Config adaptation failed: ${error}`);
132
+ return { success: false, outputPath: targetPath, warnings };
133
+ }
134
+ }
135
+
136
+ private applyTransformations(
137
+ content: string,
138
+ file: DiscoveredFile,
139
+ context: TransformationContext,
140
+ warnings: string[]
141
+ ): string {
142
+ let transformedContent = content;
143
+
144
+ // Get transformation rules for file type
145
+ const fileExt = extname(file.path);
146
+ const rules = this.transformationRules.get(fileExt) || [];
147
+
148
+ for (const rule of rules) {
149
+ try {
150
+ if (typeof rule.replacement === 'string') {
151
+ transformedContent = transformedContent.replace(rule.pattern, rule.replacement);
152
+ } else {
153
+ transformedContent = transformedContent.replace(rule.pattern, rule.replacement);
154
+ }
155
+ } catch (error) {
156
+ warnings.push(`Transformation rule failed: ${rule.description} - ${error}`);
157
+ }
158
+ }
159
+
160
+ // Apply context-specific transformations
161
+ transformedContent = this.applyContextTransformations(transformedContent, context, warnings);
162
+
163
+ return transformedContent;
164
+ }
165
+
166
+ private applyContextTransformations(
167
+ content: string,
168
+ context: TransformationContext,
169
+ warnings: string[]
170
+ ): string {
171
+ let transformed = content;
172
+
173
+ // Update import paths for project structure
174
+ const importTransformations = [
175
+ // Component imports
176
+ {
177
+ from: /from ['"](?:\.\.\/)*components\/(.+?)['"]/g,
178
+ to: `from '${context.projectStructure.componentsDir}/$1'`
179
+ },
180
+ // Utility imports
181
+ {
182
+ from: /from ['"](?:\.\.\/)*utils\/(.+?)['"]/g,
183
+ to: `from '${context.projectStructure.utilsDir}/$1'`
184
+ },
185
+ // Hook imports
186
+ {
187
+ from: /from ['"](?:\.\.\/)*hooks\/(.+?)['"]/g,
188
+ to: `from '${context.projectStructure.hooksDir}/$1'`
189
+ },
190
+ // Style imports
191
+ {
192
+ from: /from ['"](?:\.\.\/)*styles\/(.+?)['"]/g,
193
+ to: `from '${context.projectStructure.stylesDir}/$1'`
194
+ }
195
+ ];
196
+
197
+ for (const transformation of importTransformations) {
198
+ transformed = transformed.replace(transformation.from, transformation.to);
199
+ }
200
+
201
+ // Framework-specific import transformations
202
+ if (context.sourceFramework !== context.targetFramework) {
203
+ transformed = this.adaptFrameworkImports(transformed, context, warnings);
204
+ }
205
+
206
+ return transformed;
207
+ }
208
+
209
+ private adaptFrameworkImports(
210
+ content: string,
211
+ context: TransformationContext,
212
+ warnings: string[]
213
+ ): string {
214
+ let adapted = content;
215
+
216
+ // Next.js to other frameworks
217
+ if (context.sourceFramework === 'nextjs') {
218
+ // Next.js specific imports
219
+ const nextImportMappings = {
220
+ "import Image from 'next/image'": "// TODO: Replace with appropriate image component",
221
+ "import Link from 'next/link'": "// TODO: Replace with appropriate link component",
222
+ "import { useRouter } from 'next/router'": "// TODO: Replace with appropriate router hook",
223
+ "import { useRouter } from 'next/navigation'": "// TODO: Replace with appropriate router hook"
224
+ };
225
+
226
+ for (const [from, to] of Object.entries(nextImportMappings)) {
227
+ if (adapted.includes(from)) {
228
+ adapted = adapted.replace(from, to);
229
+ warnings.push(`Replaced Next.js import: ${from}`);
230
+ }
231
+ }
232
+ }
233
+
234
+ // Astro to other frameworks
235
+ if (context.sourceFramework === 'astro') {
236
+ // Remove Astro frontmatter
237
+ adapted = adapted.replace(/^---[\s\S]*?---\n/m, '');
238
+
239
+ // Convert Astro components to JSX
240
+ if (context.targetFramework !== 'astro') {
241
+ // This is a complex transformation - add warning
242
+ warnings.push('Astro component detected - manual conversion to JSX may be required');
243
+ }
244
+ }
245
+
246
+ return adapted;
247
+ }
248
+
249
+ private async adaptPackageJson(
250
+ sourcePath: string,
251
+ targetPath: string,
252
+ context: TransformationContext,
253
+ warnings: string[]
254
+ ): Promise<{ success: boolean; outputPath: string; warnings: string[] }> {
255
+ try {
256
+ const sourcePackage = JSON.parse(await readFile(sourcePath, 'utf-8'));
257
+ let targetPackage = {};
258
+
259
+ // If target package.json exists, merge with it
260
+ if (existsSync(targetPath)) {
261
+ targetPackage = JSON.parse(await readFile(targetPath, 'utf-8'));
262
+ }
263
+
264
+ // Merge dependencies intelligently
265
+ const mergedPackage = {
266
+ ...targetPackage,
267
+ dependencies: {
268
+ ...(targetPackage as any).dependencies,
269
+ ...this.filterDependencies(sourcePackage.dependencies, context.targetFramework, warnings)
270
+ },
271
+ devDependencies: {
272
+ ...(targetPackage as any).devDependencies,
273
+ ...this.filterDependencies(sourcePackage.devDependencies, context.targetFramework, warnings)
274
+ }
275
+ };
276
+
277
+ await writeFile(targetPath, JSON.stringify(mergedPackage, null, 2), 'utf-8');
278
+ return { success: true, outputPath: targetPath, warnings };
279
+ } catch (error) {
280
+ warnings.push(`Package.json adaptation failed: ${error}`);
281
+ return { success: false, outputPath: targetPath, warnings };
282
+ }
283
+ }
284
+
285
+ private filterDependencies(
286
+ dependencies: Record<string, string> = {},
287
+ targetFramework: FrameworkType,
288
+ warnings: string[]
289
+ ): Record<string, string> {
290
+ const filtered: Record<string, string> = {};
291
+
292
+ // Framework-specific dependency filtering
293
+ const incompatibleDeps: Record<FrameworkType, string[]> = {
294
+ 'nextjs': [],
295
+ 'astro': ['next'],
296
+ 'vite': ['next'],
297
+ 'tanstack-start': ['next'],
298
+ 'unknown': []
299
+ };
300
+
301
+ const incompatible = incompatibleDeps[targetFramework] || [];
302
+
303
+ for (const [dep, version] of Object.entries(dependencies)) {
304
+ if (incompatible.some(inc => dep.includes(inc))) {
305
+ warnings.push(`Skipped incompatible dependency: ${dep}`);
306
+ continue;
307
+ }
308
+ filtered[dep] = version;
309
+ }
310
+
311
+ return filtered;
312
+ }
313
+
314
+ private async adaptTsConfig(
315
+ sourcePath: string,
316
+ targetPath: string,
317
+ context: TransformationContext,
318
+ warnings: string[]
319
+ ): Promise<{ success: boolean; outputPath: string; warnings: string[] }> {
320
+ try {
321
+ const sourceConfig = JSON.parse(await readFile(sourcePath, 'utf-8'));
322
+ let targetConfig = {
323
+ compilerOptions: {
324
+ target: "ES2020",
325
+ lib: ["dom", "dom.iterable", "es6"],
326
+ allowJs: true,
327
+ skipLibCheck: true,
328
+ strict: true,
329
+ forceConsistentCasingInFileNames: true,
330
+ noEmit: true,
331
+ esModuleInterop: true,
332
+ module: "esnext",
333
+ moduleResolution: "bundler",
334
+ resolveJsonModule: true,
335
+ isolatedModules: true,
336
+ jsx: "preserve",
337
+ incremental: true,
338
+ plugins: [
339
+ {
340
+ name: "next"
341
+ }
342
+ ],
343
+ baseUrl: ".",
344
+ paths: {
345
+ "@/*": ["./src/*"],
346
+ "@/components/*": ["./src/components/*"],
347
+ "@/utils/*": ["./src/utils/*"],
348
+ "@/hooks/*": ["./src/hooks/*"]
349
+ }
350
+ },
351
+ include: ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
352
+ exclude: ["node_modules"]
353
+ };
354
+
355
+ // If target config exists, merge intelligently
356
+ if (existsSync(targetPath)) {
357
+ const existing = JSON.parse(await readFile(targetPath, 'utf-8'));
358
+ targetConfig = {
359
+ ...existing,
360
+ compilerOptions: {
361
+ ...existing.compilerOptions,
362
+ ...sourceConfig.compilerOptions,
363
+ paths: {
364
+ ...existing.compilerOptions?.paths,
365
+ ...sourceConfig.compilerOptions?.paths
366
+ }
367
+ }
368
+ };
369
+ }
370
+
371
+ await writeFile(targetPath, JSON.stringify(targetConfig, null, 2), 'utf-8');
372
+ return { success: true, outputPath: targetPath, warnings };
373
+ } catch (error) {
374
+ warnings.push(`tsconfig.json adaptation failed: ${error}`);
375
+ return { success: false, outputPath: targetPath, warnings };
376
+ }
377
+ }
378
+
379
+ private async adaptTailwindConfig(
380
+ sourcePath: string,
381
+ targetPath: string,
382
+ context: TransformationContext,
383
+ warnings: string[]
384
+ ): Promise<{ success: boolean; outputPath: string; warnings: string[] }> {
385
+ try {
386
+ let content = await readFile(sourcePath, 'utf-8');
387
+
388
+ // Update content paths for target project structure
389
+ content = content.replace(
390
+ /content:\s*\[([^\]]+)\]/,
391
+ `content: [
392
+ "./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
393
+ "./src/components/**/*.{js,ts,jsx,tsx,mdx}",
394
+ "./src/app/**/*.{js,ts,jsx,tsx,mdx}",
395
+ ]`
396
+ );
397
+
398
+ await writeFile(targetPath, content, 'utf-8');
399
+ return { success: true, outputPath: targetPath, warnings };
400
+ } catch (error) {
401
+ warnings.push(`Tailwind config adaptation failed: ${error}`);
402
+ return { success: false, outputPath: targetPath, warnings };
403
+ }
404
+ }
405
+
406
+ private async adaptFrameworkConfig(
407
+ sourcePath: string,
408
+ targetPath: string,
409
+ context: TransformationContext,
410
+ warnings: string[]
411
+ ): Promise<{ success: boolean; outputPath: string; warnings: string[] }> {
412
+ // Framework configs often need manual review
413
+ warnings.push(`Framework config copied but may need manual adaptation: ${basename(sourcePath)}`);
414
+ return await this.directCopy(sourcePath, targetPath);
415
+ }
416
+
417
+ private initializeTransformationRules(): void {
418
+ // TypeScript/JavaScript transformation rules
419
+ const tsRules: TransformationRule[] = [
420
+ {
421
+ pattern: /import\s+(\{[^}]+\}|\w+)\s+from\s+['"]\.\.?\/(?:\.\.\/)*([^'"]+)['"]/g,
422
+ replacement: (match, imports, path) => {
423
+ // Convert relative imports to absolute imports
424
+ return `import ${imports} from '@/${path.replace(/^\.\.?\//, '')}'`;
425
+ },
426
+ description: 'Convert relative imports to absolute imports'
427
+ },
428
+ {
429
+ pattern: /className=['"]([^'"]*)\s+cn\(([^)]+)\)['"]/g,
430
+ replacement: "className={cn('$1', $2)}",
431
+ description: 'Fix className with cn() utility'
432
+ }
433
+ ];
434
+
435
+ // CSS transformation rules
436
+ const cssRules: TransformationRule[] = [
437
+ {
438
+ pattern: /@import\s+['"]\.\.?\/(?:\.\.\/)*([^'"]+)['"]/g,
439
+ replacement: "@import '@/$1'",
440
+ description: 'Convert relative CSS imports to absolute'
441
+ }
442
+ ];
443
+
444
+ this.transformationRules.set('.ts', tsRules);
445
+ this.transformationRules.set('.tsx', tsRules);
446
+ this.transformationRules.set('.js', tsRules);
447
+ this.transformationRules.set('.jsx', tsRules);
448
+ this.transformationRules.set('.css', cssRules);
449
+ this.transformationRules.set('.scss', cssRules);
450
+ }
451
+
452
+ private initializeFrameworkAdapters(): void {
453
+ // Next.js to Astro adapter
454
+ this.frameworkAdapters.set('nextjs->astro', new NextToAstroAdapter());
455
+
456
+ // Next.js to Vite adapter
457
+ this.frameworkAdapters.set('nextjs->vite', new NextToViteAdapter());
458
+
459
+ // Add more adapters as needed
460
+ }
461
+ }
462
+
463
+ // Framework adapter interface
464
+ abstract class FrameworkAdapter {
465
+ abstract transform(
466
+ content: string,
467
+ file: DiscoveredFile,
468
+ context: TransformationContext
469
+ ): Promise<string>;
470
+ }
471
+
472
+ class NextToAstroAdapter extends FrameworkAdapter {
473
+ async transform(
474
+ content: string,
475
+ file: DiscoveredFile,
476
+ context: TransformationContext
477
+ ): Promise<string> {
478
+ let transformed = content;
479
+
480
+ // Convert Next.js Image to Astro Image
481
+ transformed = transformed.replace(
482
+ /import Image from 'next\/image'/g,
483
+ "import { Image } from 'astro:assets'"
484
+ );
485
+
486
+ // Convert Next.js Link to Astro Link
487
+ transformed = transformed.replace(
488
+ /import Link from 'next\/link'/g,
489
+ "// Use Astro's built-in <a> tags or create custom Link component"
490
+ );
491
+
492
+ // Remove useRouter - Astro doesn't have client-side routing hooks
493
+ transformed = transformed.replace(
494
+ /import\s*\{\s*useRouter\s*\}\s*from\s*['"]next\/router['"]/g,
495
+ "// Router hooks not available in Astro - use Astro.url for current route"
496
+ );
497
+
498
+ return transformed;
499
+ }
500
+ }
501
+
502
+ class NextToViteAdapter extends FrameworkAdapter {
503
+ async transform(
504
+ content: string,
505
+ file: DiscoveredFile,
506
+ context: TransformationContext
507
+ ): Promise<string> {
508
+ let transformed = content;
509
+
510
+ // Convert Next.js Image to regular img or create custom component
511
+ transformed = transformed.replace(
512
+ /import Image from 'next\/image'/g,
513
+ "// TODO: Replace with img tag or custom Image component"
514
+ );
515
+
516
+ // Convert Next.js Link to React Router Link if available
517
+ transformed = transformed.replace(
518
+ /import Link from 'next\/link'/g,
519
+ "import { Link } from 'react-router-dom' // or create custom Link component"
520
+ );
521
+
522
+ return transformed;
523
+ }
524
+ }