@aicgen/aicgen 1.0.0-beta.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.
Files changed (287) hide show
  1. package/.claude/agents/architecture-reviewer.md +88 -0
  2. package/.claude/agents/guideline-checker.md +73 -0
  3. package/.claude/agents/security-auditor.md +108 -0
  4. package/.claude/guidelines/api-design.md +645 -0
  5. package/.claude/guidelines/architecture.md +2503 -0
  6. package/.claude/guidelines/best-practices.md +618 -0
  7. package/.claude/guidelines/code-style.md +304 -0
  8. package/.claude/guidelines/design-patterns.md +573 -0
  9. package/.claude/guidelines/devops.md +226 -0
  10. package/.claude/guidelines/error-handling.md +413 -0
  11. package/.claude/guidelines/language.md +782 -0
  12. package/.claude/guidelines/performance.md +706 -0
  13. package/.claude/guidelines/security.md +583 -0
  14. package/.claude/guidelines/testing.md +568 -0
  15. package/.claude/settings.json +98 -0
  16. package/.claude/settings.local.json +8 -0
  17. package/.env.example +23 -0
  18. package/.eslintrc.json +28 -0
  19. package/.github/workflows/release.yml +180 -0
  20. package/.github/workflows/test.yml +81 -0
  21. package/.gitmodules +3 -0
  22. package/.vs/ProjectSettings.json +3 -0
  23. package/.vs/VSWorkspaceState.json +16 -0
  24. package/.vs/aicgen.slnx/FileContentIndex/5f0ce2a3-fd68-4863-9e23-e428cf1794e3.vsidx +0 -0
  25. package/.vs/aicgen.slnx/v18/.wsuo +0 -0
  26. package/.vs/aicgen.slnx/v18/DocumentLayout.json +54 -0
  27. package/.vs/slnx.sqlite +0 -0
  28. package/AGENTS.md +121 -0
  29. package/CLAUDE.md +36 -0
  30. package/CONTRIBUTING.md +821 -0
  31. package/LICENSE +21 -0
  32. package/README.md +199 -0
  33. package/assets/icon.svg +34 -0
  34. package/assets/logo.svg +41 -0
  35. package/bun.lock +848 -0
  36. package/data/LICENSE +21 -0
  37. package/data/README.md +203 -0
  38. package/data/api/basics.md +292 -0
  39. package/data/api/index.md +8 -0
  40. package/data/api/pagination.md +142 -0
  41. package/data/api/rest.md +137 -0
  42. package/data/api/versioning.md +60 -0
  43. package/data/architecture/clean-architecture/index.md +7 -0
  44. package/data/architecture/clean-architecture/layers.md +111 -0
  45. package/data/architecture/ddd/index.md +8 -0
  46. package/data/architecture/ddd/strategic.md +89 -0
  47. package/data/architecture/ddd/tactical.md +132 -0
  48. package/data/architecture/event-driven/index.md +7 -0
  49. package/data/architecture/event-driven/messaging.md +242 -0
  50. package/data/architecture/event-driven/patterns.md +129 -0
  51. package/data/architecture/feature-toggles/index.md +7 -0
  52. package/data/architecture/feature-toggles/patterns.md +73 -0
  53. package/data/architecture/gui/index.md +7 -0
  54. package/data/architecture/gui/patterns.md +132 -0
  55. package/data/architecture/hexagonal/ports-adapters.md +132 -0
  56. package/data/architecture/index.md +12 -0
  57. package/data/architecture/layered/index.md +7 -0
  58. package/data/architecture/layered/layers.md +100 -0
  59. package/data/architecture/microservices/api-gateway.md +56 -0
  60. package/data/architecture/microservices/boundaries.md +80 -0
  61. package/data/architecture/microservices/communication.md +97 -0
  62. package/data/architecture/microservices/data.md +92 -0
  63. package/data/architecture/microservices/index.md +11 -0
  64. package/data/architecture/microservices/resilience.md +111 -0
  65. package/data/architecture/modular-monolith/boundaries.md +133 -0
  66. package/data/architecture/modular-monolith/structure.md +131 -0
  67. package/data/architecture/serverless/best-practices.md +322 -0
  68. package/data/architecture/serverless/index.md +7 -0
  69. package/data/architecture/serverless/patterns.md +80 -0
  70. package/data/architecture/solid/index.md +7 -0
  71. package/data/architecture/solid/principles.md +187 -0
  72. package/data/database/basics.md +365 -0
  73. package/data/database/design-patterns.md +68 -0
  74. package/data/database/index.md +8 -0
  75. package/data/database/indexing.md +136 -0
  76. package/data/database/nosql.md +223 -0
  77. package/data/database/schema.md +137 -0
  78. package/data/devops/ci-cd.md +66 -0
  79. package/data/devops/index.md +8 -0
  80. package/data/devops/observability.md +73 -0
  81. package/data/devops/practices.md +77 -0
  82. package/data/error-handling/basics.md +222 -0
  83. package/data/error-handling/index.md +7 -0
  84. package/data/error-handling/strategy.md +185 -0
  85. package/data/guideline-mappings.yml +1077 -0
  86. package/data/index.md +3 -0
  87. package/data/language/csharp/basics.md +210 -0
  88. package/data/language/csharp/testing.md +252 -0
  89. package/data/language/go/basics.md +158 -0
  90. package/data/language/go/testing.md +192 -0
  91. package/data/language/index.md +14 -0
  92. package/data/language/java/basics.md +184 -0
  93. package/data/language/java/testing.md +273 -0
  94. package/data/language/javascript/basics.md +217 -0
  95. package/data/language/javascript/testing.md +269 -0
  96. package/data/language/python/async.md +100 -0
  97. package/data/language/python/basics.md +100 -0
  98. package/data/language/python/index.md +10 -0
  99. package/data/language/python/testing.md +125 -0
  100. package/data/language/python/types.md +99 -0
  101. package/data/language/ruby/basics.md +227 -0
  102. package/data/language/ruby/testing.md +267 -0
  103. package/data/language/rust/basics.md +175 -0
  104. package/data/language/rust/testing.md +219 -0
  105. package/data/language/typescript/async.md +103 -0
  106. package/data/language/typescript/basics.md +87 -0
  107. package/data/language/typescript/config.md +95 -0
  108. package/data/language/typescript/error-handling.md +98 -0
  109. package/data/language/typescript/generics.md +85 -0
  110. package/data/language/typescript/index.md +14 -0
  111. package/data/language/typescript/interfaces-types.md +83 -0
  112. package/data/language/typescript/performance.md +103 -0
  113. package/data/language/typescript/testing.md +98 -0
  114. package/data/patterns/base-patterns.md +105 -0
  115. package/data/patterns/concurrency.md +87 -0
  116. package/data/patterns/data-access.md +83 -0
  117. package/data/patterns/distribution.md +86 -0
  118. package/data/patterns/domain-logic.md +81 -0
  119. package/data/patterns/gof.md +109 -0
  120. package/data/patterns/index.md +12 -0
  121. package/data/performance/async.md +148 -0
  122. package/data/performance/basics.md +324 -0
  123. package/data/performance/caching-strategies.md +68 -0
  124. package/data/performance/caching.md +152 -0
  125. package/data/performance/index.md +8 -0
  126. package/data/practices/code-review.md +52 -0
  127. package/data/practices/documentation.md +260 -0
  128. package/data/practices/index.md +11 -0
  129. package/data/practices/planning.md +142 -0
  130. package/data/practices/refactoring.md +91 -0
  131. package/data/practices/version-control.md +55 -0
  132. package/data/security/auth-jwt.md +159 -0
  133. package/data/security/headers.md +143 -0
  134. package/data/security/index.md +10 -0
  135. package/data/security/injection.md +119 -0
  136. package/data/security/secrets.md +148 -0
  137. package/data/style/index.md +8 -0
  138. package/data/style/naming.md +136 -0
  139. package/data/style/organization.md +162 -0
  140. package/data/templates/agents/architecture-reviewer.md +88 -0
  141. package/data/templates/agents/guideline-checker.md +73 -0
  142. package/data/templates/agents/security-auditor.md +108 -0
  143. package/data/templates/antigravity/rules/architecture.md.hbs +5 -0
  144. package/data/templates/antigravity/rules/code-style.md.hbs +5 -0
  145. package/data/templates/antigravity/rules/language.md.hbs +5 -0
  146. package/data/templates/antigravity/rules/performance.md.hbs +5 -0
  147. package/data/templates/antigravity/rules/security.md.hbs +5 -0
  148. package/data/templates/antigravity/rules/testing.md.hbs +5 -0
  149. package/data/templates/antigravity/workflows/add-documentation.md.hbs +23 -0
  150. package/data/templates/antigravity/workflows/generate-integration-tests.md.hbs +17 -0
  151. package/data/templates/antigravity/workflows/generate-unit-tests.md.hbs +20 -0
  152. package/data/templates/antigravity/workflows/performance-audit.md.hbs +24 -0
  153. package/data/templates/antigravity/workflows/refactor-extract-module.md.hbs +17 -0
  154. package/data/templates/antigravity/workflows/security-audit.md.hbs +20 -0
  155. package/data/templates/hooks/formatting.json +26 -0
  156. package/data/templates/hooks/security.json +35 -0
  157. package/data/templates/hooks/testing.json +17 -0
  158. package/data/testing/basics.md +151 -0
  159. package/data/testing/index.md +9 -0
  160. package/data/testing/integration.md +159 -0
  161. package/data/testing/unit-fundamentals.md +128 -0
  162. package/data/testing/unit-mocking.md +116 -0
  163. package/data/version.json +49 -0
  164. package/dist/commands/init.d.ts +8 -0
  165. package/dist/commands/init.d.ts.map +1 -0
  166. package/dist/commands/init.js +46 -0
  167. package/dist/commands/init.js.map +1 -0
  168. package/dist/config/profiles.d.ts +4 -0
  169. package/dist/config/profiles.d.ts.map +1 -0
  170. package/dist/config/profiles.js +30 -0
  171. package/dist/config/profiles.js.map +1 -0
  172. package/dist/config/settings.d.ts +7 -0
  173. package/dist/config/settings.d.ts.map +1 -0
  174. package/dist/config/settings.js +7 -0
  175. package/dist/config/settings.js.map +1 -0
  176. package/dist/index.d.ts +3 -0
  177. package/dist/index.d.ts.map +1 -0
  178. package/dist/index.js +58489 -0
  179. package/dist/index.js.map +1 -0
  180. package/dist/models/guideline.d.ts +15 -0
  181. package/dist/models/guideline.d.ts.map +1 -0
  182. package/dist/models/guideline.js +2 -0
  183. package/dist/models/guideline.js.map +1 -0
  184. package/dist/models/preference.d.ts +9 -0
  185. package/dist/models/preference.d.ts.map +1 -0
  186. package/dist/models/preference.js +2 -0
  187. package/dist/models/preference.js.map +1 -0
  188. package/dist/models/profile.d.ts +9 -0
  189. package/dist/models/profile.d.ts.map +1 -0
  190. package/dist/models/profile.js +2 -0
  191. package/dist/models/profile.js.map +1 -0
  192. package/dist/models/project.d.ts +13 -0
  193. package/dist/models/project.d.ts.map +1 -0
  194. package/dist/models/project.js +2 -0
  195. package/dist/models/project.js.map +1 -0
  196. package/dist/services/ai/anthropic.d.ts +7 -0
  197. package/dist/services/ai/anthropic.d.ts.map +1 -0
  198. package/dist/services/ai/anthropic.js +39 -0
  199. package/dist/services/ai/anthropic.js.map +1 -0
  200. package/dist/services/generator.d.ts +2 -0
  201. package/dist/services/generator.d.ts.map +1 -0
  202. package/dist/services/generator.js +4 -0
  203. package/dist/services/generator.js.map +1 -0
  204. package/dist/services/learner.d.ts +2 -0
  205. package/dist/services/learner.d.ts.map +1 -0
  206. package/dist/services/learner.js +4 -0
  207. package/dist/services/learner.js.map +1 -0
  208. package/dist/services/scanner.d.ts +3 -0
  209. package/dist/services/scanner.d.ts.map +1 -0
  210. package/dist/services/scanner.js +54 -0
  211. package/dist/services/scanner.js.map +1 -0
  212. package/dist/utils/errors.d.ts +15 -0
  213. package/dist/utils/errors.d.ts.map +1 -0
  214. package/dist/utils/errors.js +27 -0
  215. package/dist/utils/errors.js.map +1 -0
  216. package/dist/utils/file.d.ts +7 -0
  217. package/dist/utils/file.d.ts.map +1 -0
  218. package/dist/utils/file.js +32 -0
  219. package/dist/utils/file.js.map +1 -0
  220. package/dist/utils/logger.d.ts +6 -0
  221. package/dist/utils/logger.d.ts.map +1 -0
  222. package/dist/utils/logger.js +17 -0
  223. package/dist/utils/logger.js.map +1 -0
  224. package/dist/utils/path.d.ts +6 -0
  225. package/dist/utils/path.d.ts.map +1 -0
  226. package/dist/utils/path.js +14 -0
  227. package/dist/utils/path.js.map +1 -0
  228. package/docs/planning/memory-lane.md +83 -0
  229. package/package.json +64 -0
  230. package/packaging/linux/aicgen.spec +23 -0
  231. package/packaging/linux/control +9 -0
  232. package/packaging/macos/scripts/postinstall +12 -0
  233. package/packaging/windows/setup.nsi +92 -0
  234. package/planning/BRANDING-SUMMARY.md +194 -0
  235. package/planning/BRANDING.md +174 -0
  236. package/planning/BUILD.md +186 -0
  237. package/planning/CHUNK-IMPLEMENTATION-PLAN.md +87 -0
  238. package/planning/CHUNK-TAXONOMY.md +375 -0
  239. package/planning/CHUNKS-COMPLETE.md +382 -0
  240. package/planning/DESIGN.md +313 -0
  241. package/planning/DYNAMIC-GUIDELINES-DESIGN.md +265 -0
  242. package/planning/ENTERPRISE-UX-COMPLETE.md +281 -0
  243. package/planning/IMPLEMENTATION-PLAN.md +20 -0
  244. package/planning/PHASE1-COMPLETE.md +211 -0
  245. package/planning/PHASE2-COMPLETE.md +350 -0
  246. package/planning/PHASE3-COMPLETE.md +399 -0
  247. package/planning/PHASE4-COMPLETE.md +361 -0
  248. package/planning/PHASE4.5-CHUNKS.md +462 -0
  249. package/planning/STRUCTURE.md +170 -0
  250. package/scripts/add-categories.ts +87 -0
  251. package/scripts/build-binary.ts +46 -0
  252. package/scripts/embed-data.ts +105 -0
  253. package/scripts/generate-version.ts +150 -0
  254. package/scripts/test-decompress.ts +27 -0
  255. package/scripts/test-extract.ts +31 -0
  256. package/src/__tests__/services/assistant-file-writer.test.ts +400 -0
  257. package/src/__tests__/services/guideline-loader.test.ts +281 -0
  258. package/src/__tests__/services/tarball-extraction.test.ts +125 -0
  259. package/src/commands/add-guideline.ts +296 -0
  260. package/src/commands/clear.ts +61 -0
  261. package/src/commands/guideline-selector.ts +123 -0
  262. package/src/commands/init.ts +645 -0
  263. package/src/commands/quick-add.ts +586 -0
  264. package/src/commands/remove-guideline.ts +152 -0
  265. package/src/commands/stats.ts +49 -0
  266. package/src/commands/update.ts +240 -0
  267. package/src/config.ts +82 -0
  268. package/src/embedded-data.ts +1492 -0
  269. package/src/index.ts +67 -0
  270. package/src/models/profile.ts +24 -0
  271. package/src/models/project.ts +43 -0
  272. package/src/services/assistant-file-writer.ts +612 -0
  273. package/src/services/config-generator.ts +150 -0
  274. package/src/services/config-manager.ts +70 -0
  275. package/src/services/data-source.ts +248 -0
  276. package/src/services/first-run-init.ts +148 -0
  277. package/src/services/guideline-loader.ts +311 -0
  278. package/src/services/hook-generator.ts +178 -0
  279. package/src/services/subagent-generator.ts +310 -0
  280. package/src/utils/banner.ts +66 -0
  281. package/src/utils/errors.ts +27 -0
  282. package/src/utils/file.ts +67 -0
  283. package/src/utils/formatting.ts +172 -0
  284. package/src/utils/logger.ts +89 -0
  285. package/src/utils/path.ts +17 -0
  286. package/src/utils/wizard-state.ts +132 -0
  287. package/tsconfig.json +25 -0
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Add category metadata to guideline-mappings.yml based on directory structure
4
+ */
5
+
6
+ import { readFile, writeFile } from 'fs/promises';
7
+ import { join } from 'path';
8
+ import YAML from 'yaml';
9
+
10
+ interface GuidelineMapping {
11
+ path: string;
12
+ category?: string;
13
+ languages?: string[];
14
+ levels?: string[];
15
+ architectures?: string[];
16
+ tags?: string[];
17
+ }
18
+
19
+ const categoryMap: Record<string, string> = {
20
+ 'language': 'Language',
21
+ 'architecture': 'Architecture',
22
+ 'testing': 'Testing',
23
+ 'security': 'Security',
24
+ 'performance': 'Performance',
25
+ 'api': 'API Design',
26
+ 'database': 'Database',
27
+ 'devops': 'DevOps',
28
+ 'error-handling': 'Error Handling',
29
+ 'patterns': 'Design Patterns',
30
+ 'practices': 'Best Practices',
31
+ 'style': 'Code Style'
32
+ };
33
+
34
+ function getCategoryFromPath(path: string): string {
35
+ const firstDir = path.split('/')[0];
36
+ return categoryMap[firstDir] || 'General';
37
+ }
38
+
39
+ async function addCategories() {
40
+ console.log('📝 Adding categories to guideline-mappings.yml...\n');
41
+
42
+ const mappingsPath = join(process.cwd(), 'data', 'guideline-mappings.yml');
43
+
44
+ const content = await readFile(mappingsPath, 'utf-8');
45
+ const mappings = YAML.parse(content) as Record<string, GuidelineMapping>;
46
+
47
+ let updated = 0;
48
+
49
+ for (const [id, mapping] of Object.entries(mappings)) {
50
+ if (!mapping.category) {
51
+ mapping.category = getCategoryFromPath(mapping.path);
52
+ updated++;
53
+ }
54
+ }
55
+
56
+ const output = YAML.stringify(mappings, {
57
+ lineWidth: 0,
58
+ defaultStringType: 'PLAIN'
59
+ });
60
+
61
+ const header = `# Guideline Mappings
62
+ # Defines which guidelines apply to which profiles
63
+ #
64
+ # Format:
65
+ # guideline-id:
66
+ # path: relative/path/to/guideline.md
67
+ # category: Guideline category for organization
68
+ # languages: [list of applicable languages] (optional, if omitted applies to all)
69
+ # levels: [list of applicable levels] (optional, if omitted applies to all)
70
+ # architectures: [list of applicable architectures] (optional, if omitted applies to all)
71
+ # tags: [list of tags for organization]
72
+
73
+ `;
74
+
75
+ await writeFile(mappingsPath, header + output, 'utf-8');
76
+
77
+ console.log(`✅ Updated ${updated} mappings with categories`);
78
+ console.log(`📂 Categories found:`);
79
+
80
+ const categories = new Set(Object.values(mappings).map(m => m.category));
81
+ categories.forEach(cat => console.log(` - ${cat}`));
82
+ }
83
+
84
+ addCategories().catch(err => {
85
+ console.error('❌ Failed:', err);
86
+ process.exit(1);
87
+ });
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env bun
2
+ import { readFileSync } from 'fs';
3
+
4
+ const packageJson = JSON.parse(readFileSync('package.json', 'utf-8'));
5
+ const version = packageJson.version;
6
+
7
+ const platform = process.argv[2] || 'current';
8
+
9
+ import { mkdirSync } from 'fs';
10
+
11
+ // Ensure dist exists
12
+ try { mkdirSync('dist'); } catch (e) { }
13
+
14
+ console.log(`Building binary for ${platform} with version ${version}...`);
15
+
16
+ const buildConfigs: Record<string, string[]> = {
17
+ current: ['build', 'src/index.ts', '--compile', '--outfile', 'dist/aicgen'],
18
+ windows: ['build', 'src/index.ts', '--compile', '--outfile', 'dist/aicgen.exe', '--target=bun-windows-x64'],
19
+ linux: ['build', 'src/index.ts', '--compile', '--outfile', 'dist/aicgen-linux', '--target=bun-linux-x64'],
20
+ macos: ['build', 'src/index.ts', '--compile', '--outfile', 'dist/aicgen-macos', '--target=bun-darwin-arm64']
21
+ };
22
+
23
+ const args = buildConfigs[platform];
24
+
25
+ if (!args) {
26
+ console.error(`Unknown platform: ${platform}`);
27
+ console.error(`Available platforms: ${Object.keys(buildConfigs).join(', ')}`);
28
+ process.exit(1);
29
+ }
30
+
31
+ // Add the version define
32
+ args.push('--define', `process.env.APP_VERSION="${version}"`);
33
+
34
+ const proc = Bun.spawn(['bun', ...args], {
35
+ stdout: 'inherit',
36
+ stderr: 'inherit',
37
+ });
38
+
39
+ const exitCode = await proc.exited;
40
+
41
+ if (exitCode === 0) {
42
+ console.log(`✓ Binary built successfully (v${version})`);
43
+ } else {
44
+ console.error('Build failed');
45
+ process.exit(exitCode);
46
+ }
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * Embed all guideline data into a TypeScript file for bundling into binary.
4
+ * Run: bun run scripts/embed-data.ts
5
+ */
6
+
7
+ import { readFile, readdir, writeFile } from 'fs/promises';
8
+ import { join } from 'path';
9
+ import YAML from 'yaml';
10
+
11
+ interface GuidelineMapping {
12
+ path: string;
13
+ languages?: string[];
14
+ levels?: string[];
15
+ architectures?: string[];
16
+ datasources?: string[];
17
+ tags?: string[];
18
+ }
19
+
20
+ interface EmbeddedData {
21
+ mappings: Record<string, GuidelineMapping>;
22
+ guidelines: Record<string, string>;
23
+ }
24
+
25
+ async function readGuidelinesRecursively(dir: string, basePath: string = ''): Promise<Record<string, string>> {
26
+ const guidelines: Record<string, string> = {};
27
+ const entries = await readdir(dir, { withFileTypes: true });
28
+
29
+ for (const entry of entries) {
30
+ const fullPath = join(dir, entry.name);
31
+ const relativePath = basePath ? `${basePath}/${entry.name}` : entry.name;
32
+
33
+ if (entry.isDirectory()) {
34
+ const subGuidelines = await readGuidelinesRecursively(fullPath, relativePath);
35
+ Object.assign(guidelines, subGuidelines);
36
+ } else if (entry.name.endsWith('.md')) {
37
+ const content = await readFile(fullPath, 'utf-8');
38
+ guidelines[relativePath] = content;
39
+ }
40
+ }
41
+
42
+ return guidelines;
43
+ }
44
+
45
+ async function embedData() {
46
+ console.log('📦 Embedding guideline data into TypeScript...\n');
47
+
48
+ const dataDir = join(process.cwd(), 'data');
49
+ const mappingsPath = join(dataDir, 'guideline-mappings.yml');
50
+
51
+ // Read mappings
52
+ const mappingsContent = await readFile(mappingsPath, 'utf-8');
53
+ const mappings = YAML.parse(mappingsContent) as Record<string, GuidelineMapping>;
54
+
55
+ console.log(` Loaded ${Object.keys(mappings).length} guideline mappings`);
56
+
57
+ // Read all guidelines from data directory
58
+ const guidelines = await readGuidelinesRecursively(dataDir);
59
+
60
+ // Remove the mappings file and top-level index from guidelines
61
+ delete guidelines['guideline-mappings.yml'];
62
+ delete guidelines['index.md'];
63
+
64
+ console.log(` Loaded ${Object.keys(guidelines).length} markdown files`);
65
+
66
+ const data: EmbeddedData = { mappings, guidelines };
67
+
68
+ // Generate TypeScript file
69
+ const output = `// AUTO-GENERATED - DO NOT EDIT
70
+ // Generated by scripts/embed-data.ts
71
+ // Contains all guideline mappings and content embedded for binary distribution
72
+
73
+ export interface GuidelineMapping {
74
+ path: string;
75
+ category?: string;
76
+ languages?: string[];
77
+ levels?: string[];
78
+ architectures?: string[];
79
+ datasources?: string[];
80
+ tags?: string[];
81
+ }
82
+
83
+ export interface EmbeddedData {
84
+ mappings: Record<string, GuidelineMapping>;
85
+ guidelines: Record<string, string>;
86
+ }
87
+
88
+ export const EMBEDDED_DATA: EmbeddedData = ${JSON.stringify(data, null, 2)};
89
+
90
+ export const GUIDELINE_COUNT = ${Object.keys(guidelines).length};
91
+ export const MAPPING_COUNT = ${Object.keys(mappings).length};
92
+ `;
93
+
94
+ const outputPath = join(process.cwd(), 'src', 'embedded-data.ts');
95
+ await writeFile(outputPath, output, 'utf-8');
96
+
97
+ const sizeKB = (output.length / 1024).toFixed(1);
98
+ console.log(`\n✅ Generated src/embedded-data.ts (${sizeKB} KB)`);
99
+ console.log(` ${Object.keys(mappings).length} mappings, ${Object.keys(guidelines).length} guidelines embedded`);
100
+ }
101
+
102
+ embedData().catch(err => {
103
+ console.error('❌ Failed to embed data:', err);
104
+ process.exit(1);
105
+ });
@@ -0,0 +1,150 @@
1
+ #!/usr/bin/env bun
2
+
3
+ /**
4
+ * Generate version.json with dynamic stats calculated from guideline-mappings.yml
5
+ */
6
+
7
+ import { readFileSync, writeFileSync } from 'fs';
8
+ import { parse as parseYAML } from 'yaml';
9
+ import { join } from 'path';
10
+
11
+ interface GuidelineMapping {
12
+ path: string;
13
+ category?: string;
14
+ languages?: string[];
15
+ levels?: string[];
16
+ architectures?: string[];
17
+ datasources?: string[];
18
+ tags?: string[];
19
+ }
20
+
21
+ interface GuidelineMappings {
22
+ [key: string]: GuidelineMapping;
23
+ }
24
+
25
+ interface VersionData {
26
+ version: string;
27
+ lastUpdated: string;
28
+ totalGuidelines: number;
29
+ categories: Record<string, number>;
30
+ languages: Record<string, number>;
31
+ architectures: Record<string, number>;
32
+ levels: Record<string, number>;
33
+ datasources: Record<string, number>;
34
+ }
35
+
36
+ const DATA_DIR = join(__dirname, '../data');
37
+ const MAPPINGS_FILE = join(DATA_DIR, 'guideline-mappings.yml');
38
+ const VERSION_FILE = join(DATA_DIR, 'version.json');
39
+
40
+ function calculateStats(mappings: GuidelineMappings): Omit<VersionData, 'version' | 'lastUpdated'> {
41
+ const categories: Record<string, number> = {};
42
+ const languages: Record<string, number> = {};
43
+ const architectures: Record<string, number> = {};
44
+ const levels: Record<string, number> = {
45
+ basic: 0,
46
+ standard: 0,
47
+ expert: 0,
48
+ full: 0
49
+ };
50
+ const datasources: Record<string, number> = {};
51
+
52
+ const guidelineIds = Object.keys(mappings);
53
+
54
+ // Count by category
55
+ for (const id of guidelineIds) {
56
+ const mapping = mappings[id];
57
+
58
+ if (mapping.category) {
59
+ categories[mapping.category] = (categories[mapping.category] || 0) + 1;
60
+ }
61
+ }
62
+
63
+ // Count by language (only language-specific guidelines)
64
+ for (const id of guidelineIds) {
65
+ const mapping = mappings[id];
66
+
67
+ if (mapping.languages && mapping.languages.length > 0) {
68
+ for (const lang of mapping.languages) {
69
+ languages[lang] = (languages[lang] || 0) + 1;
70
+ }
71
+ }
72
+ }
73
+
74
+ // Count by architecture (only architecture-specific guidelines)
75
+ for (const id of guidelineIds) {
76
+ const mapping = mappings[id];
77
+
78
+ if (mapping.architectures && mapping.architectures.length > 0) {
79
+ for (const arch of mapping.architectures) {
80
+ architectures[arch] = (architectures[arch] || 0) + 1;
81
+ }
82
+ }
83
+ }
84
+
85
+ // Count by level
86
+ for (const id of guidelineIds) {
87
+ const mapping = mappings[id];
88
+ const mappingLevels = mapping.levels || ['basic', 'standard', 'expert', 'full'];
89
+
90
+ for (const level of mappingLevels) {
91
+ if (level in levels) {
92
+ levels[level]++;
93
+ }
94
+ }
95
+ }
96
+
97
+ // Count by datasource (only datasource-specific guidelines)
98
+ for (const id of guidelineIds) {
99
+ const mapping = mappings[id];
100
+
101
+ if (mapping.datasources && mapping.datasources.length > 0) {
102
+ for (const ds of mapping.datasources) {
103
+ datasources[ds] = (datasources[ds] || 0) + 1;
104
+ }
105
+ }
106
+ }
107
+
108
+ return {
109
+ totalGuidelines: guidelineIds.length,
110
+ categories,
111
+ languages,
112
+ architectures,
113
+ levels,
114
+ datasources
115
+ };
116
+ }
117
+
118
+ function main() {
119
+ console.log('📊 Generating version.json with dynamic stats...\n');
120
+
121
+ // Read guideline mappings
122
+ const mappingsContent = readFileSync(MAPPINGS_FILE, 'utf-8');
123
+ const mappings = parseYAML(mappingsContent) as GuidelineMappings;
124
+
125
+ // Calculate stats
126
+ const stats = calculateStats(mappings);
127
+
128
+ // Get today's date
129
+ const today = new Date().toISOString().split('T')[0];
130
+
131
+ // Create version data
132
+ const versionData: VersionData = {
133
+ version: '1.0.0',
134
+ lastUpdated: today,
135
+ ...stats
136
+ };
137
+
138
+ // Write to file
139
+ writeFileSync(VERSION_FILE, JSON.stringify(versionData, null, 2) + '\n');
140
+
141
+ console.log(`✅ Generated ${VERSION_FILE}`);
142
+ console.log(` Total guidelines: ${stats.totalGuidelines}`);
143
+ console.log(` Categories: ${Object.keys(stats.categories).length}`);
144
+ console.log(` Languages: ${Object.keys(stats.languages).length}`);
145
+ console.log(` Architectures: ${Object.keys(stats.architectures).length}`);
146
+ console.log(` Levels: basic(${stats.levels.basic}), standard(${stats.levels.standard}), expert(${stats.levels.expert}), full(${stats.levels.full})`);
147
+ console.log(` Datasources: ${Object.keys(stats.datasources).length}`);
148
+ }
149
+
150
+ main();
@@ -0,0 +1,27 @@
1
+ import decompress from 'decompress';
2
+ import { writeFile, mkdir } from 'fs/promises';
3
+ import { join } from 'path';
4
+ import { homedir } from 'os';
5
+ import { execSync } from 'child_process';
6
+
7
+ const url = 'https://api.github.com/repos/lpsandaruwan/aicgen-docs/tarball/0.1.0';
8
+
9
+ console.log('Downloading tarball...');
10
+ const response = await fetch(url);
11
+ const tarballBuffer = Buffer.from(await response.arrayBuffer());
12
+
13
+ const testDir = join(homedir(), '.aicgen-test3');
14
+ await mkdir(testDir, { recursive: true });
15
+
16
+ const tarballPath = join(testDir, 'test.tar.gz');
17
+ await writeFile(tarballPath, tarballBuffer);
18
+
19
+ console.log('Extracting with decompress...');
20
+ await decompress(tarballPath, testDir);
21
+
22
+ console.log('Checking files...');
23
+ const result = execSync(`cd "${testDir}" && find . -type f | wc -l`).toString().trim();
24
+ console.log(`Total files extracted: ${result}`);
25
+
26
+ const result2 = execSync(`cd "${testDir}" && ls`).toString().trim();
27
+ console.log('Extracted contents:', result2);
@@ -0,0 +1,31 @@
1
+ import { extract } from 'tar';
2
+ import { mkdir, writeFile, readdir, cp } from 'fs/promises';
3
+ import { join } from 'path';
4
+ import { homedir } from 'os';
5
+
6
+ const url = 'https://api.github.com/repos/lpsandaruwan/aicgen-docs/tarball/0.1.0';
7
+
8
+ console.log('Downloading tarball...');
9
+ const response = await fetch(url);
10
+ const tarballBuffer = Buffer.from(await response.arrayBuffer());
11
+
12
+ const testDir = join(homedir(), '.aicgen-test');
13
+ await mkdir(testDir, { recursive: true });
14
+
15
+ const tarballPath = join(testDir, 'test.tar.gz');
16
+ await writeFile(tarballPath, tarballBuffer);
17
+
18
+ console.log('Extracting...');
19
+ await extract({ file: tarballPath, cwd: testDir });
20
+
21
+ console.log('Listing extracted contents:');
22
+ const entries = await readdir(testDir);
23
+ console.log(entries);
24
+
25
+ const rootDir = entries.find(e => e.startsWith('lpsandaruwan-aicgen-docs-'));
26
+ if (rootDir) {
27
+ const extractedPath = join(testDir, rootDir);
28
+ const extracted = await readdir(extractedPath);
29
+ console.log('\nFiles in extracted directory:');
30
+ console.log(extracted);
31
+ }