@aicgen/aicgen 1.0.0-beta.1 → 1.0.0-beta.2

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 (136) hide show
  1. package/.vs/ProjectSettings.json +2 -2
  2. package/.vs/VSWorkspaceState.json +15 -15
  3. package/.vs/aicgen.slnx/v18/DocumentLayout.json +53 -53
  4. package/assets/icon.svg +33 -33
  5. package/bun.lock +0 -43
  6. package/data/architecture/microservices/api-gateway.md +56 -56
  7. package/data/devops/observability.md +73 -73
  8. package/dist/index.js +9299 -9299
  9. package/package.json +2 -2
  10. package/.claude/agents/architecture-reviewer.md +0 -88
  11. package/.claude/agents/guideline-checker.md +0 -73
  12. package/.claude/agents/security-auditor.md +0 -108
  13. package/.claude/guidelines/api-design.md +0 -645
  14. package/.claude/guidelines/architecture.md +0 -2503
  15. package/.claude/guidelines/best-practices.md +0 -618
  16. package/.claude/guidelines/code-style.md +0 -304
  17. package/.claude/guidelines/design-patterns.md +0 -573
  18. package/.claude/guidelines/devops.md +0 -226
  19. package/.claude/guidelines/error-handling.md +0 -413
  20. package/.claude/guidelines/language.md +0 -782
  21. package/.claude/guidelines/performance.md +0 -706
  22. package/.claude/guidelines/security.md +0 -583
  23. package/.claude/guidelines/testing.md +0 -568
  24. package/.claude/settings.json +0 -98
  25. package/.claude/settings.local.json +0 -8
  26. package/.eslintrc.json +0 -28
  27. package/.github/workflows/release.yml +0 -180
  28. package/.github/workflows/test.yml +0 -81
  29. package/CONTRIBUTING.md +0 -821
  30. package/dist/commands/init.d.ts +0 -8
  31. package/dist/commands/init.d.ts.map +0 -1
  32. package/dist/commands/init.js +0 -46
  33. package/dist/commands/init.js.map +0 -1
  34. package/dist/config/profiles.d.ts +0 -4
  35. package/dist/config/profiles.d.ts.map +0 -1
  36. package/dist/config/profiles.js +0 -30
  37. package/dist/config/profiles.js.map +0 -1
  38. package/dist/config/settings.d.ts +0 -7
  39. package/dist/config/settings.d.ts.map +0 -1
  40. package/dist/config/settings.js +0 -7
  41. package/dist/config/settings.js.map +0 -1
  42. package/dist/index.d.ts +0 -3
  43. package/dist/index.d.ts.map +0 -1
  44. package/dist/index.js.map +0 -1
  45. package/dist/models/guideline.d.ts +0 -15
  46. package/dist/models/guideline.d.ts.map +0 -1
  47. package/dist/models/guideline.js +0 -2
  48. package/dist/models/guideline.js.map +0 -1
  49. package/dist/models/preference.d.ts +0 -9
  50. package/dist/models/preference.d.ts.map +0 -1
  51. package/dist/models/preference.js +0 -2
  52. package/dist/models/preference.js.map +0 -1
  53. package/dist/models/profile.d.ts +0 -9
  54. package/dist/models/profile.d.ts.map +0 -1
  55. package/dist/models/profile.js +0 -2
  56. package/dist/models/profile.js.map +0 -1
  57. package/dist/models/project.d.ts +0 -13
  58. package/dist/models/project.d.ts.map +0 -1
  59. package/dist/models/project.js +0 -2
  60. package/dist/models/project.js.map +0 -1
  61. package/dist/services/ai/anthropic.d.ts +0 -7
  62. package/dist/services/ai/anthropic.d.ts.map +0 -1
  63. package/dist/services/ai/anthropic.js +0 -39
  64. package/dist/services/ai/anthropic.js.map +0 -1
  65. package/dist/services/generator.d.ts +0 -2
  66. package/dist/services/generator.d.ts.map +0 -1
  67. package/dist/services/generator.js +0 -4
  68. package/dist/services/generator.js.map +0 -1
  69. package/dist/services/learner.d.ts +0 -2
  70. package/dist/services/learner.d.ts.map +0 -1
  71. package/dist/services/learner.js +0 -4
  72. package/dist/services/learner.js.map +0 -1
  73. package/dist/services/scanner.d.ts +0 -3
  74. package/dist/services/scanner.d.ts.map +0 -1
  75. package/dist/services/scanner.js +0 -54
  76. package/dist/services/scanner.js.map +0 -1
  77. package/dist/utils/errors.d.ts +0 -15
  78. package/dist/utils/errors.d.ts.map +0 -1
  79. package/dist/utils/errors.js +0 -27
  80. package/dist/utils/errors.js.map +0 -1
  81. package/dist/utils/file.d.ts +0 -7
  82. package/dist/utils/file.d.ts.map +0 -1
  83. package/dist/utils/file.js +0 -32
  84. package/dist/utils/file.js.map +0 -1
  85. package/dist/utils/logger.d.ts +0 -6
  86. package/dist/utils/logger.d.ts.map +0 -1
  87. package/dist/utils/logger.js +0 -17
  88. package/dist/utils/logger.js.map +0 -1
  89. package/dist/utils/path.d.ts +0 -6
  90. package/dist/utils/path.d.ts.map +0 -1
  91. package/dist/utils/path.js +0 -14
  92. package/dist/utils/path.js.map +0 -1
  93. package/docs/planning/memory-lane.md +0 -83
  94. package/packaging/linux/aicgen.spec +0 -23
  95. package/packaging/linux/control +0 -9
  96. package/packaging/macos/scripts/postinstall +0 -12
  97. package/packaging/windows/setup.nsi +0 -92
  98. package/scripts/add-categories.ts +0 -87
  99. package/scripts/build-binary.ts +0 -46
  100. package/scripts/embed-data.ts +0 -105
  101. package/scripts/generate-version.ts +0 -150
  102. package/scripts/test-decompress.ts +0 -27
  103. package/scripts/test-extract.ts +0 -31
  104. package/src/__tests__/services/assistant-file-writer.test.ts +0 -400
  105. package/src/__tests__/services/guideline-loader.test.ts +0 -281
  106. package/src/__tests__/services/tarball-extraction.test.ts +0 -125
  107. package/src/commands/add-guideline.ts +0 -296
  108. package/src/commands/clear.ts +0 -61
  109. package/src/commands/guideline-selector.ts +0 -123
  110. package/src/commands/init.ts +0 -645
  111. package/src/commands/quick-add.ts +0 -586
  112. package/src/commands/remove-guideline.ts +0 -152
  113. package/src/commands/stats.ts +0 -49
  114. package/src/commands/update.ts +0 -240
  115. package/src/config.ts +0 -82
  116. package/src/embedded-data.ts +0 -1492
  117. package/src/index.ts +0 -67
  118. package/src/models/profile.ts +0 -24
  119. package/src/models/project.ts +0 -43
  120. package/src/services/assistant-file-writer.ts +0 -612
  121. package/src/services/config-generator.ts +0 -150
  122. package/src/services/config-manager.ts +0 -70
  123. package/src/services/data-source.ts +0 -248
  124. package/src/services/first-run-init.ts +0 -148
  125. package/src/services/guideline-loader.ts +0 -311
  126. package/src/services/hook-generator.ts +0 -178
  127. package/src/services/subagent-generator.ts +0 -310
  128. package/src/utils/banner.ts +0 -66
  129. package/src/utils/errors.ts +0 -27
  130. package/src/utils/file.ts +0 -67
  131. package/src/utils/formatting.ts +0 -172
  132. package/src/utils/logger.ts +0 -89
  133. package/src/utils/path.ts +0 -17
  134. package/src/utils/wizard-state.ts +0 -132
  135. package/tsconfig.json +0 -25
  136. /package/{CLAUDE.md → claude.md} +0 -0
@@ -1,83 +0,0 @@
1
- # Memory Lane - aicgen Project Context
2
-
3
- ## Last Updated
4
- 2024-12-16
5
-
6
- ## Project Overview
7
- **aicgen** - CLI tool that generates AI coding assistant configuration files (CLAUDE.md, copilot-instructions.md, etc.) with embedded guidelines.
8
-
9
- ## Current Objective
10
- Preparing v1.0 release - improving dataset coverage with basic-level guidelines.
11
-
12
- ## Recent Progress
13
-
14
- ### Completed
15
- - ✅ Fixed CLAUDE.md location (now at project root, not `.claude/`)
16
- - ✅ Fixed README guideline count claims (now accurate: 77 mappings)
17
- - ✅ Added testing guidelines for Go, Rust, Java, C#, Ruby, JavaScript
18
- - ✅ Added architecture depth for event-driven (messaging.md) and serverless (best-practices.md)
19
- - ✅ Created `data/version.json` with accurate counts
20
- - ✅ Created `data/README.md` contribution guide
21
- - ✅ Added datasource selection (SQL/NoSQL/None) to wizard
22
- - ✅ Created NoSQL database guidelines
23
- - ✅ Added datasource filtering to guideline loader
24
- - ✅ Fixed network permission gating by level (expert/full only)
25
- - ✅ Added download safeguards (timeout, size limits)
26
- - ✅ Added destructive regeneration warning in quick-add
27
- - ✅ **Added 5 new basic-level guidelines (2024-12-16)**:
28
- - `testing-basics.md` - First unit test, assertions, running tests
29
- - `error-handling-basics.md` - Try/catch, throw, logging
30
- - `api-basics.md` - HTTP methods, status codes
31
- - `database-basics.md` - CRUD operations, SQL basics
32
- - `performance-basics.md` - Data structures, N+1 queries, indexing
33
-
34
- ### In Progress
35
- - 🔄 No active work
36
-
37
- ### Pending
38
- - ⏳ Consider project type expansion (frontend vs fullstack)
39
-
40
- ## Key Decisions
41
- 1. **Datasource dimension** - Users choose SQL, NoSQL, or None; database guidelines filtered accordingly
42
- 2. **Assistant-aware filtering** - Intentionally NOT implemented; all assistants share same guidelines (no assistant-specific content)
43
- 3. **Architecture options** - Added clean-architecture, ddd, serverless, hexagonal to wizard
44
- 4. **Level permissions** - Only expert/full levels get internet access (WebFetch, WebSearch)
45
-
46
- ## Important Files
47
- - `src/commands/init.ts` - Main wizard flow
48
- - `src/services/guideline-loader.ts` - Guideline filtering logic
49
- - `src/models/profile.ts` - ProfileSelection interface with all dimensions
50
- - `data/guideline-mappings.yml` - All guideline mappings
51
- - `data/version.json` - Counts and metadata
52
-
53
- ## Technical Context
54
- - Runtime: Bun
55
- - Language: TypeScript (strict mode)
56
- - CLI framework: Commander.js + @inquirer/prompts
57
- - Embedded data pattern for binary distribution
58
- - Auto-generated `src/embedded-data.ts` from `scripts/embed-data.ts`
59
-
60
- ## Architect Findings Status
61
- | Issue | Status |
62
- |-------|--------|
63
- | guideline-loader ignores assistant | Documented as intentional |
64
- | quick-add destructive without warning | ✅ Fixed |
65
- | Download no timeout/size guards | ✅ Fixed |
66
- | Default settings enable internet for all | ✅ Fixed (expert/full only) |
67
- | Architecture wizard/data mismatch | ✅ Fixed |
68
- | Language gaps outside TS/Python | ✅ Improved (basics + testing for 6 languages) |
69
- | README claim mismatch | ✅ Fixed |
70
- | Level imbalance | ✅ Fixed (basic: 12 → 17, +42% coverage) |
71
-
72
- ## Stats
73
- - Total guidelines: 82 (up from 77)
74
- - Languages: 8 (TS, Python, Go, Rust, Java, C#, Ruby, JS)
75
- - Architectures: 8 (layered, modular-monolith, microservices, event-driven, hexagonal, clean-architecture, ddd, serverless)
76
- - Levels: basic (17), standard (62), expert (76), full (82)
77
- - Datasources: sql (3), nosql (1)
78
- - Categories: Testing (4), Error Handling (2), API Design (4), Database (5), Performance (4)
79
-
80
- ## Next Session
81
- 1. Consider project type expansion (split "web" into "frontend" and "fullstack")
82
- 2. Consider running integration tests manually to verify wizard flow
83
- 3. Version bump for release
@@ -1,23 +0,0 @@
1
- Name: aicgen
2
- Version: 1.0.0
3
- Release: 1%{?dist}
4
- Summary: AI Config Generator
5
- License: MIT
6
- URL: https://github.com/lpsandaruwan/aicgen
7
- Source0: aicgen-linux
8
-
9
- %description
10
- AI-assisted configuration generator for better coding.
11
- Automatically analyzes your project and suggests optimal configurations.
12
-
13
- %install
14
- mkdir -p %{buildroot}/usr/bin
15
- cp %{SOURCE0} %{buildroot}/usr/bin/aicgen
16
- chmod 755 %{buildroot}/usr/bin/aicgen
17
-
18
- %files
19
- /usr/bin/aicgen
20
-
21
- %changelog
22
- * Thu Dec 11 2025 Lahiru Sandaruwan <lpsandaruwan@gmail.com> - 1.0.0-1
23
- - Initial release
@@ -1,9 +0,0 @@
1
- Package: aicgen
2
- Version: 1.0.0
3
- Section: devel
4
- Priority: optional
5
- Architecture: amd64
6
- Maintainer: lpsandaruwan
7
- Description: AI Config Generator
8
- AI-assisted configuration generator for better coding.
9
- Automatically analyzes your project and suggests optimal configurations.
@@ -1,12 +0,0 @@
1
- #!/bin/bash
2
- # MacOS Post-install script
3
-
4
- # Ensure /usr/local/bin exists
5
- if [ ! -d "/usr/local/bin" ]; then
6
- mkdir -p "/usr/local/bin"
7
- fi
8
-
9
- # Link is handled by pkgbuild usually, but we can double check permission
10
- chmod +x "/usr/local/bin/aicgen"
11
-
12
- exit 0
@@ -1,92 +0,0 @@
1
- ; aicgen Installer Script
2
- !include "MUI2.nsh"
3
-
4
- ; General
5
- Name "aicgen"
6
- OutFile "..\..\dist\aicgen-setup-x64.exe"
7
- Unicode True
8
- InstallDir "$PROGRAMFILES64\aicgen"
9
- InstallDirRegKey HKCU "Software\aicgen" ""
10
- RequestExecutionLevel admin
11
-
12
- ; Version Information
13
- VIProductVersion "1.0.0.0"
14
- VIAddVersionKey "ProductName" "aicgen"
15
- VIAddVersionKey "CompanyName" "lpsandaruwan"
16
- VIAddVersionKey "LegalCopyright" "© 2025 lpsandaruwan"
17
- VIAddVersionKey "FileDescription" "AI Config Generator Installer"
18
- VIAddVersionKey "FileVersion" "1.0.0.0"
19
-
20
- ; Icons (Uncomment if .ico files are present in packaging/windows)
21
- ; !define MUI_ICON "install.ico"
22
- ; !define MUI_UNICON "uninstall.ico"
23
-
24
- ; UI Interface
25
- !define MUI_ABORTWARNING
26
- !insertmacro MUI_PAGE_WELCOME
27
- !insertmacro MUI_PAGE_LICENSE "..\..\LICENSE"
28
- !insertmacro MUI_PAGE_DIRECTORY
29
- !insertmacro MUI_PAGE_INSTFILES
30
- !insertmacro MUI_PAGE_FINISH
31
-
32
- !insertmacro MUI_UNPAGE_WELCOME
33
- !insertmacro MUI_UNPAGE_CONFIRM
34
- !insertmacro MUI_UNPAGE_INSTFILES
35
- !insertmacro MUI_UNPAGE_FINISH
36
-
37
- !insertmacro MUI_LANGUAGE "English"
38
-
39
- ; Installer
40
- Section "aicgen (required)" SecCore
41
- SectionIn RO
42
-
43
- SetOutPath "$INSTDIR"
44
-
45
- ; Files to install
46
- File "..\..\dist\aicgen.exe"
47
- File "..\..\LICENSE"
48
- File "..\..\README.md"
49
-
50
- ; Write Uninstaller
51
- WriteUninstaller "$INSTDIR\uninstall.exe"
52
-
53
- ; Start Menu Shortcuts
54
- CreateDirectory "$SMPROGRAMS\aicgen"
55
- CreateShortcut "$SMPROGRAMS\aicgen\aicgen.lnk" "$INSTDIR\aicgen.exe"
56
- CreateShortcut "$SMPROGRAMS\aicgen\Uninstall.lnk" "$INSTDIR\uninstall.exe"
57
-
58
- ; Registry keys for Add/Remove programs
59
- WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\aicgen" "DisplayName" "aicgen"
60
- WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\aicgen" "UninstallString" '"$INSTDIR\uninstall.exe"'
61
- WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\aicgen" "Publisher" "lpsandaruwan"
62
- WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\aicgen" "DisplayVersion" "1.0.0"
63
-
64
- ; Add to PATH
65
- EnVar::SetHKLM
66
- EnVar::AddValue "path" "$INSTDIR"
67
- SectionEnd
68
-
69
- ; Uninstaller
70
- Section "Uninstall"
71
- ; Remove files
72
- Delete "$INSTDIR\aicgen.exe"
73
- Delete "$INSTDIR\LICENSE"
74
- Delete "$INSTDIR\README.md"
75
- Delete "$INSTDIR\uninstall.exe"
76
-
77
- ; Remove shortcuts
78
- Delete "$SMPROGRAMS\aicgen\aicgen.lnk"
79
- Delete "$SMPROGRAMS\aicgen\Uninstall.lnk"
80
- RMDir "$SMPROGRAMS\aicgen"
81
-
82
- ; Remove install dir
83
- RMDir "$INSTDIR"
84
-
85
- ; Remove from PATH
86
- EnVar::SetHKLM
87
- EnVar::DeleteValue "path" "$INSTDIR"
88
-
89
- ; Remove registry keys
90
- DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\aicgen"
91
- DeleteRegKey HKCU "Software\aicgen"
92
- SectionEnd
@@ -1,87 +0,0 @@
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
- });
@@ -1,46 +0,0 @@
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
- }
@@ -1,105 +0,0 @@
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
- });
@@ -1,150 +0,0 @@
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();
@@ -1,27 +0,0 @@
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);
@@ -1,31 +0,0 @@
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
- }