@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.
- package/.claude/agents/architecture-reviewer.md +88 -0
- package/.claude/agents/guideline-checker.md +73 -0
- package/.claude/agents/security-auditor.md +108 -0
- package/.claude/guidelines/api-design.md +645 -0
- package/.claude/guidelines/architecture.md +2503 -0
- package/.claude/guidelines/best-practices.md +618 -0
- package/.claude/guidelines/code-style.md +304 -0
- package/.claude/guidelines/design-patterns.md +573 -0
- package/.claude/guidelines/devops.md +226 -0
- package/.claude/guidelines/error-handling.md +413 -0
- package/.claude/guidelines/language.md +782 -0
- package/.claude/guidelines/performance.md +706 -0
- package/.claude/guidelines/security.md +583 -0
- package/.claude/guidelines/testing.md +568 -0
- package/.claude/settings.json +98 -0
- package/.claude/settings.local.json +8 -0
- package/.env.example +23 -0
- package/.eslintrc.json +28 -0
- package/.github/workflows/release.yml +180 -0
- package/.github/workflows/test.yml +81 -0
- package/.gitmodules +3 -0
- package/.vs/ProjectSettings.json +3 -0
- package/.vs/VSWorkspaceState.json +16 -0
- package/.vs/aicgen.slnx/FileContentIndex/5f0ce2a3-fd68-4863-9e23-e428cf1794e3.vsidx +0 -0
- package/.vs/aicgen.slnx/v18/.wsuo +0 -0
- package/.vs/aicgen.slnx/v18/DocumentLayout.json +54 -0
- package/.vs/slnx.sqlite +0 -0
- package/AGENTS.md +121 -0
- package/CLAUDE.md +36 -0
- package/CONTRIBUTING.md +821 -0
- package/LICENSE +21 -0
- package/README.md +199 -0
- package/assets/icon.svg +34 -0
- package/assets/logo.svg +41 -0
- package/bun.lock +848 -0
- package/data/LICENSE +21 -0
- package/data/README.md +203 -0
- package/data/api/basics.md +292 -0
- package/data/api/index.md +8 -0
- package/data/api/pagination.md +142 -0
- package/data/api/rest.md +137 -0
- package/data/api/versioning.md +60 -0
- package/data/architecture/clean-architecture/index.md +7 -0
- package/data/architecture/clean-architecture/layers.md +111 -0
- package/data/architecture/ddd/index.md +8 -0
- package/data/architecture/ddd/strategic.md +89 -0
- package/data/architecture/ddd/tactical.md +132 -0
- package/data/architecture/event-driven/index.md +7 -0
- package/data/architecture/event-driven/messaging.md +242 -0
- package/data/architecture/event-driven/patterns.md +129 -0
- package/data/architecture/feature-toggles/index.md +7 -0
- package/data/architecture/feature-toggles/patterns.md +73 -0
- package/data/architecture/gui/index.md +7 -0
- package/data/architecture/gui/patterns.md +132 -0
- package/data/architecture/hexagonal/ports-adapters.md +132 -0
- package/data/architecture/index.md +12 -0
- package/data/architecture/layered/index.md +7 -0
- package/data/architecture/layered/layers.md +100 -0
- package/data/architecture/microservices/api-gateway.md +56 -0
- package/data/architecture/microservices/boundaries.md +80 -0
- package/data/architecture/microservices/communication.md +97 -0
- package/data/architecture/microservices/data.md +92 -0
- package/data/architecture/microservices/index.md +11 -0
- package/data/architecture/microservices/resilience.md +111 -0
- package/data/architecture/modular-monolith/boundaries.md +133 -0
- package/data/architecture/modular-monolith/structure.md +131 -0
- package/data/architecture/serverless/best-practices.md +322 -0
- package/data/architecture/serverless/index.md +7 -0
- package/data/architecture/serverless/patterns.md +80 -0
- package/data/architecture/solid/index.md +7 -0
- package/data/architecture/solid/principles.md +187 -0
- package/data/database/basics.md +365 -0
- package/data/database/design-patterns.md +68 -0
- package/data/database/index.md +8 -0
- package/data/database/indexing.md +136 -0
- package/data/database/nosql.md +223 -0
- package/data/database/schema.md +137 -0
- package/data/devops/ci-cd.md +66 -0
- package/data/devops/index.md +8 -0
- package/data/devops/observability.md +73 -0
- package/data/devops/practices.md +77 -0
- package/data/error-handling/basics.md +222 -0
- package/data/error-handling/index.md +7 -0
- package/data/error-handling/strategy.md +185 -0
- package/data/guideline-mappings.yml +1077 -0
- package/data/index.md +3 -0
- package/data/language/csharp/basics.md +210 -0
- package/data/language/csharp/testing.md +252 -0
- package/data/language/go/basics.md +158 -0
- package/data/language/go/testing.md +192 -0
- package/data/language/index.md +14 -0
- package/data/language/java/basics.md +184 -0
- package/data/language/java/testing.md +273 -0
- package/data/language/javascript/basics.md +217 -0
- package/data/language/javascript/testing.md +269 -0
- package/data/language/python/async.md +100 -0
- package/data/language/python/basics.md +100 -0
- package/data/language/python/index.md +10 -0
- package/data/language/python/testing.md +125 -0
- package/data/language/python/types.md +99 -0
- package/data/language/ruby/basics.md +227 -0
- package/data/language/ruby/testing.md +267 -0
- package/data/language/rust/basics.md +175 -0
- package/data/language/rust/testing.md +219 -0
- package/data/language/typescript/async.md +103 -0
- package/data/language/typescript/basics.md +87 -0
- package/data/language/typescript/config.md +95 -0
- package/data/language/typescript/error-handling.md +98 -0
- package/data/language/typescript/generics.md +85 -0
- package/data/language/typescript/index.md +14 -0
- package/data/language/typescript/interfaces-types.md +83 -0
- package/data/language/typescript/performance.md +103 -0
- package/data/language/typescript/testing.md +98 -0
- package/data/patterns/base-patterns.md +105 -0
- package/data/patterns/concurrency.md +87 -0
- package/data/patterns/data-access.md +83 -0
- package/data/patterns/distribution.md +86 -0
- package/data/patterns/domain-logic.md +81 -0
- package/data/patterns/gof.md +109 -0
- package/data/patterns/index.md +12 -0
- package/data/performance/async.md +148 -0
- package/data/performance/basics.md +324 -0
- package/data/performance/caching-strategies.md +68 -0
- package/data/performance/caching.md +152 -0
- package/data/performance/index.md +8 -0
- package/data/practices/code-review.md +52 -0
- package/data/practices/documentation.md +260 -0
- package/data/practices/index.md +11 -0
- package/data/practices/planning.md +142 -0
- package/data/practices/refactoring.md +91 -0
- package/data/practices/version-control.md +55 -0
- package/data/security/auth-jwt.md +159 -0
- package/data/security/headers.md +143 -0
- package/data/security/index.md +10 -0
- package/data/security/injection.md +119 -0
- package/data/security/secrets.md +148 -0
- package/data/style/index.md +8 -0
- package/data/style/naming.md +136 -0
- package/data/style/organization.md +162 -0
- package/data/templates/agents/architecture-reviewer.md +88 -0
- package/data/templates/agents/guideline-checker.md +73 -0
- package/data/templates/agents/security-auditor.md +108 -0
- package/data/templates/antigravity/rules/architecture.md.hbs +5 -0
- package/data/templates/antigravity/rules/code-style.md.hbs +5 -0
- package/data/templates/antigravity/rules/language.md.hbs +5 -0
- package/data/templates/antigravity/rules/performance.md.hbs +5 -0
- package/data/templates/antigravity/rules/security.md.hbs +5 -0
- package/data/templates/antigravity/rules/testing.md.hbs +5 -0
- package/data/templates/antigravity/workflows/add-documentation.md.hbs +23 -0
- package/data/templates/antigravity/workflows/generate-integration-tests.md.hbs +17 -0
- package/data/templates/antigravity/workflows/generate-unit-tests.md.hbs +20 -0
- package/data/templates/antigravity/workflows/performance-audit.md.hbs +24 -0
- package/data/templates/antigravity/workflows/refactor-extract-module.md.hbs +17 -0
- package/data/templates/antigravity/workflows/security-audit.md.hbs +20 -0
- package/data/templates/hooks/formatting.json +26 -0
- package/data/templates/hooks/security.json +35 -0
- package/data/templates/hooks/testing.json +17 -0
- package/data/testing/basics.md +151 -0
- package/data/testing/index.md +9 -0
- package/data/testing/integration.md +159 -0
- package/data/testing/unit-fundamentals.md +128 -0
- package/data/testing/unit-mocking.md +116 -0
- package/data/version.json +49 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +46 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/config/profiles.d.ts +4 -0
- package/dist/config/profiles.d.ts.map +1 -0
- package/dist/config/profiles.js +30 -0
- package/dist/config/profiles.js.map +1 -0
- package/dist/config/settings.d.ts +7 -0
- package/dist/config/settings.d.ts.map +1 -0
- package/dist/config/settings.js +7 -0
- package/dist/config/settings.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58489 -0
- package/dist/index.js.map +1 -0
- package/dist/models/guideline.d.ts +15 -0
- package/dist/models/guideline.d.ts.map +1 -0
- package/dist/models/guideline.js +2 -0
- package/dist/models/guideline.js.map +1 -0
- package/dist/models/preference.d.ts +9 -0
- package/dist/models/preference.d.ts.map +1 -0
- package/dist/models/preference.js +2 -0
- package/dist/models/preference.js.map +1 -0
- package/dist/models/profile.d.ts +9 -0
- package/dist/models/profile.d.ts.map +1 -0
- package/dist/models/profile.js +2 -0
- package/dist/models/profile.js.map +1 -0
- package/dist/models/project.d.ts +13 -0
- package/dist/models/project.d.ts.map +1 -0
- package/dist/models/project.js +2 -0
- package/dist/models/project.js.map +1 -0
- package/dist/services/ai/anthropic.d.ts +7 -0
- package/dist/services/ai/anthropic.d.ts.map +1 -0
- package/dist/services/ai/anthropic.js +39 -0
- package/dist/services/ai/anthropic.js.map +1 -0
- package/dist/services/generator.d.ts +2 -0
- package/dist/services/generator.d.ts.map +1 -0
- package/dist/services/generator.js +4 -0
- package/dist/services/generator.js.map +1 -0
- package/dist/services/learner.d.ts +2 -0
- package/dist/services/learner.d.ts.map +1 -0
- package/dist/services/learner.js +4 -0
- package/dist/services/learner.js.map +1 -0
- package/dist/services/scanner.d.ts +3 -0
- package/dist/services/scanner.d.ts.map +1 -0
- package/dist/services/scanner.js +54 -0
- package/dist/services/scanner.js.map +1 -0
- package/dist/utils/errors.d.ts +15 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +27 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/file.d.ts +7 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +32 -0
- package/dist/utils/file.js.map +1 -0
- package/dist/utils/logger.d.ts +6 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +17 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/path.d.ts +6 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +14 -0
- package/dist/utils/path.js.map +1 -0
- package/docs/planning/memory-lane.md +83 -0
- package/package.json +64 -0
- package/packaging/linux/aicgen.spec +23 -0
- package/packaging/linux/control +9 -0
- package/packaging/macos/scripts/postinstall +12 -0
- package/packaging/windows/setup.nsi +92 -0
- package/planning/BRANDING-SUMMARY.md +194 -0
- package/planning/BRANDING.md +174 -0
- package/planning/BUILD.md +186 -0
- package/planning/CHUNK-IMPLEMENTATION-PLAN.md +87 -0
- package/planning/CHUNK-TAXONOMY.md +375 -0
- package/planning/CHUNKS-COMPLETE.md +382 -0
- package/planning/DESIGN.md +313 -0
- package/planning/DYNAMIC-GUIDELINES-DESIGN.md +265 -0
- package/planning/ENTERPRISE-UX-COMPLETE.md +281 -0
- package/planning/IMPLEMENTATION-PLAN.md +20 -0
- package/planning/PHASE1-COMPLETE.md +211 -0
- package/planning/PHASE2-COMPLETE.md +350 -0
- package/planning/PHASE3-COMPLETE.md +399 -0
- package/planning/PHASE4-COMPLETE.md +361 -0
- package/planning/PHASE4.5-CHUNKS.md +462 -0
- package/planning/STRUCTURE.md +170 -0
- package/scripts/add-categories.ts +87 -0
- package/scripts/build-binary.ts +46 -0
- package/scripts/embed-data.ts +105 -0
- package/scripts/generate-version.ts +150 -0
- package/scripts/test-decompress.ts +27 -0
- package/scripts/test-extract.ts +31 -0
- package/src/__tests__/services/assistant-file-writer.test.ts +400 -0
- package/src/__tests__/services/guideline-loader.test.ts +281 -0
- package/src/__tests__/services/tarball-extraction.test.ts +125 -0
- package/src/commands/add-guideline.ts +296 -0
- package/src/commands/clear.ts +61 -0
- package/src/commands/guideline-selector.ts +123 -0
- package/src/commands/init.ts +645 -0
- package/src/commands/quick-add.ts +586 -0
- package/src/commands/remove-guideline.ts +152 -0
- package/src/commands/stats.ts +49 -0
- package/src/commands/update.ts +240 -0
- package/src/config.ts +82 -0
- package/src/embedded-data.ts +1492 -0
- package/src/index.ts +67 -0
- package/src/models/profile.ts +24 -0
- package/src/models/project.ts +43 -0
- package/src/services/assistant-file-writer.ts +612 -0
- package/src/services/config-generator.ts +150 -0
- package/src/services/config-manager.ts +70 -0
- package/src/services/data-source.ts +248 -0
- package/src/services/first-run-init.ts +148 -0
- package/src/services/guideline-loader.ts +311 -0
- package/src/services/hook-generator.ts +178 -0
- package/src/services/subagent-generator.ts +310 -0
- package/src/utils/banner.ts +66 -0
- package/src/utils/errors.ts +27 -0
- package/src/utils/file.ts +67 -0
- package/src/utils/formatting.ts +172 -0
- package/src/utils/logger.ts +89 -0
- package/src/utils/path.ts +17 -0
- package/src/utils/wizard-state.ts +132 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Phase 1: Foundation & Schema - COMPLETE ✅
|
|
2
|
+
|
|
3
|
+
## What We Built
|
|
4
|
+
|
|
5
|
+
Phase 1 establishes the core data structures and detection system for aicgen's profile-based configuration generation.
|
|
6
|
+
|
|
7
|
+
### 1. Domain Models (`src/domain/`)
|
|
8
|
+
|
|
9
|
+
#### `project-fingerprint.ts`
|
|
10
|
+
Complete project detection schema with:
|
|
11
|
+
- **Language detection** with confidence scoring
|
|
12
|
+
- **Framework detection** (Next.js, NestJS, Django, etc.)
|
|
13
|
+
- **Database detection** (PostgreSQL, MySQL, MongoDB, etc.)
|
|
14
|
+
- **Package manager** detection
|
|
15
|
+
- **Project structure** analysis (tests, CI, Docker, monorepo)
|
|
16
|
+
- **Existing configs** detection (AI assistants, linters, formatters)
|
|
17
|
+
- **Project size** estimation (team size, complexity, file count)
|
|
18
|
+
|
|
19
|
+
#### `profile.ts`
|
|
20
|
+
Profile schema supporting:
|
|
21
|
+
- **Instruction levels**: basic, standard, expert, full, custom
|
|
22
|
+
- **Architecture types**: microservices, modular-monolith, refactor, etc.
|
|
23
|
+
- **Guideline includes** with section extraction
|
|
24
|
+
- **Output configs** for generated files
|
|
25
|
+
- **Defaults** for testing, linting, formatting, CI/CD
|
|
26
|
+
|
|
27
|
+
### 2. Core Logic (`src/core/`)
|
|
28
|
+
|
|
29
|
+
#### `project-scanner.ts`
|
|
30
|
+
Comprehensive project scanner that:
|
|
31
|
+
- Detects language with confidence scoring
|
|
32
|
+
- Identifies frameworks and databases
|
|
33
|
+
- Analyzes project structure
|
|
34
|
+
- Estimates team size from codebase
|
|
35
|
+
- Finds existing AI assistant configs
|
|
36
|
+
- Counts code files intelligently
|
|
37
|
+
|
|
38
|
+
#### `recommender.ts`
|
|
39
|
+
Intelligent recommendation engine that:
|
|
40
|
+
- Recommends instruction level based on project size/maturity
|
|
41
|
+
- Recommends architecture based on team size/structure
|
|
42
|
+
- Provides reasoning for each recommendation
|
|
43
|
+
- Includes detailed descriptions for user display
|
|
44
|
+
|
|
45
|
+
#### `profile-loader.ts`
|
|
46
|
+
Profile file loader with:
|
|
47
|
+
- YAML profile parsing
|
|
48
|
+
- Profile caching for performance
|
|
49
|
+
- Profile validation
|
|
50
|
+
- Fallback profile loading
|
|
51
|
+
- Profile listing/discovery
|
|
52
|
+
|
|
53
|
+
### 3. Example Usage (`src/examples/`)
|
|
54
|
+
|
|
55
|
+
#### `phase1-demo.ts`
|
|
56
|
+
Demonstrates the complete Phase 1 flow:
|
|
57
|
+
1. Scan project → get fingerprint
|
|
58
|
+
2. Get recommendations → instruction level + architecture
|
|
59
|
+
3. Create profile selection
|
|
60
|
+
4. Load profile (will work in Phase 2)
|
|
61
|
+
|
|
62
|
+
## How to Test
|
|
63
|
+
|
|
64
|
+
Run the demo:
|
|
65
|
+
```bash
|
|
66
|
+
bun run src/examples/phase1-demo.ts
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
You should see:
|
|
70
|
+
- Project fingerprint details
|
|
71
|
+
- Recommended instruction level with reasoning
|
|
72
|
+
- Recommended architecture with reasoning
|
|
73
|
+
- Profile selection
|
|
74
|
+
- Error loading profile (expected - profiles created in Phase 2)
|
|
75
|
+
|
|
76
|
+
## Profile Selection Matrix
|
|
77
|
+
|
|
78
|
+
The system supports a matrix of profiles:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
Assistant × Language × Instruction Level × Architecture = Profile
|
|
82
|
+
|
|
83
|
+
Examples:
|
|
84
|
+
- claude-code × typescript × standard × modular-monolith
|
|
85
|
+
- copilot × python × expert × microservices
|
|
86
|
+
- antigravity × javascript × basic × refactor
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Instruction Levels
|
|
90
|
+
|
|
91
|
+
| Level | Lines | Team Size | Use Case |
|
|
92
|
+
|-------|-------|-----------|----------|
|
|
93
|
+
| **Basic** | ~200 | 1 | Scripts, POCs, learning |
|
|
94
|
+
| **Standard** | ~500 | 1-5 | MVP, small production apps |
|
|
95
|
+
| **Expert** | ~1000 | 5-20 | Scaling products, large teams |
|
|
96
|
+
| **Full** | ~2000+ | 20+ | Enterprise, complex systems |
|
|
97
|
+
| **Custom** | Variable | Any | Specific needs |
|
|
98
|
+
|
|
99
|
+
## Architecture Recommendations
|
|
100
|
+
|
|
101
|
+
| Architecture | Complexity | Best For |
|
|
102
|
+
|--------------|------------|----------|
|
|
103
|
+
| **Modular Monolith** | Medium | Most projects (default) |
|
|
104
|
+
| **Microservices** | High | Large teams, clear boundaries |
|
|
105
|
+
| **Refactor** | Medium | Legacy codebases |
|
|
106
|
+
| **Custom** | Variable | Specific patterns |
|
|
107
|
+
|
|
108
|
+
## Recommendation Logic
|
|
109
|
+
|
|
110
|
+
### Instruction Level
|
|
111
|
+
- `fileCount < 10` + `teamSize = 1` → **Basic**
|
|
112
|
+
- `fileCount > 50` OR `teamSize >= 5` → **Standard**
|
|
113
|
+
- `fileCount > 200` OR `teamSize >= 15` → **Expert**
|
|
114
|
+
- Has tests + CI → **Standard** minimum
|
|
115
|
+
- Empty project → **Basic**
|
|
116
|
+
|
|
117
|
+
### Architecture
|
|
118
|
+
- Monorepo + large team (10+) → **Microservices**
|
|
119
|
+
- Multiple modules → **Modular Monolith**
|
|
120
|
+
- Large codebase without tests → **Refactor**
|
|
121
|
+
- Backend + large team → **Microservices**
|
|
122
|
+
- Default → **Modular Monolith**
|
|
123
|
+
|
|
124
|
+
## What's Next: Phase 2
|
|
125
|
+
|
|
126
|
+
Phase 2 will create:
|
|
127
|
+
|
|
128
|
+
1. **Profile YAML files** (`profiles/`)
|
|
129
|
+
- `claude-code/typescript-standard-modular-monolith.yml`
|
|
130
|
+
- `copilot/python-expert-microservices.yml`
|
|
131
|
+
- etc.
|
|
132
|
+
|
|
133
|
+
2. **Template system** (`templates/`)
|
|
134
|
+
- Handlebars templates for instructions.md
|
|
135
|
+
- Templates for each AI assistant
|
|
136
|
+
- CI/CD templates
|
|
137
|
+
- Docker templates
|
|
138
|
+
|
|
139
|
+
3. **Template renderer**
|
|
140
|
+
- Parse templates with project context
|
|
141
|
+
- Generate final config files
|
|
142
|
+
- Atomic file writes
|
|
143
|
+
|
|
144
|
+
4. **First working profile**
|
|
145
|
+
- Claude Code + TypeScript + Standard + Modular Monolith
|
|
146
|
+
- Test end-to-end generation
|
|
147
|
+
|
|
148
|
+
## Files Created
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
src/
|
|
152
|
+
├── domain/
|
|
153
|
+
│ ├── project-fingerprint.ts ✅ Complete type definitions
|
|
154
|
+
│ ├── profile.ts ✅ Complete profile schema
|
|
155
|
+
│ └── index.ts ✅ Barrel export
|
|
156
|
+
├── core/
|
|
157
|
+
│ ├── project-scanner.ts ✅ Comprehensive scanner
|
|
158
|
+
│ ├── recommender.ts ✅ Smart recommendations
|
|
159
|
+
│ ├── profile-loader.ts ✅ YAML profile loader
|
|
160
|
+
│ └── index.ts ✅ Barrel export
|
|
161
|
+
└── examples/
|
|
162
|
+
└── phase1-demo.ts ✅ Usage demonstration
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Success Criteria ✅
|
|
166
|
+
|
|
167
|
+
- [x] ProjectFingerprint schema with all detection fields
|
|
168
|
+
- [x] Profile schema with instruction levels & architecture
|
|
169
|
+
- [x] Project scanner detects language, framework, database
|
|
170
|
+
- [x] Recommender suggests appropriate level & architecture
|
|
171
|
+
- [x] Profile loader can parse YAML files
|
|
172
|
+
- [x] All components use strict TypeScript
|
|
173
|
+
- [x] No `any` types, proper error handling
|
|
174
|
+
- [x] Example demonstrates full flow
|
|
175
|
+
|
|
176
|
+
## Architecture Decisions
|
|
177
|
+
|
|
178
|
+
1. **Separate domain models from implementation**
|
|
179
|
+
- `domain/` contains pure TypeScript interfaces
|
|
180
|
+
- `core/` contains business logic
|
|
181
|
+
- Clean separation enables testing
|
|
182
|
+
|
|
183
|
+
2. **Confidence-based language detection**
|
|
184
|
+
- Multiple signals (tsconfig.json, package.json, etc.)
|
|
185
|
+
- Scored detection, not binary
|
|
186
|
+
- Supports polyglot projects
|
|
187
|
+
|
|
188
|
+
3. **Smart recommendations with reasoning**
|
|
189
|
+
- Not just "pick one"
|
|
190
|
+
- Explain WHY each choice makes sense
|
|
191
|
+
- Users can override with context
|
|
192
|
+
|
|
193
|
+
4. **Profile caching**
|
|
194
|
+
- YAML parsing is expensive
|
|
195
|
+
- Cache loaded profiles
|
|
196
|
+
- Clear cache method for testing
|
|
197
|
+
|
|
198
|
+
5. **Extensible architecture detection**
|
|
199
|
+
- Easy to add new architecture types
|
|
200
|
+
- Each type has clear description
|
|
201
|
+
- Complexity rating helps users decide
|
|
202
|
+
|
|
203
|
+
## Ready for Phase 2!
|
|
204
|
+
|
|
205
|
+
Phase 1 provides the foundation. Phase 2 will bring it to life with actual profile files and templates.
|
|
206
|
+
|
|
207
|
+
**Next command:**
|
|
208
|
+
```bash
|
|
209
|
+
# After Phase 2, you'll be able to run:
|
|
210
|
+
aicgen init --assistant claude-code --language typescript
|
|
211
|
+
```
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
# Phase 2: Template System - COMPLETE ✅
|
|
2
|
+
|
|
3
|
+
## What We Built
|
|
4
|
+
|
|
5
|
+
Phase 2 creates the template rendering engine and first complete profile with templates.
|
|
6
|
+
|
|
7
|
+
### 1. Template System (`src/services/template-renderer.ts`)
|
|
8
|
+
|
|
9
|
+
Complete Handlebars-based template engine with:
|
|
10
|
+
- Template loading from files
|
|
11
|
+
- Template rendering with context
|
|
12
|
+
- Custom helpers (uppercase, lowercase, capitalize, formatDate, join, eq, ne, gt, etc.)
|
|
13
|
+
- Boolean logic helpers (and, or, not)
|
|
14
|
+
|
|
15
|
+
### 2. File Writer Enhanced (`src/utils/file.ts`)
|
|
16
|
+
|
|
17
|
+
Added batch atomic writes:
|
|
18
|
+
- `writeFiles()` function for multiple files
|
|
19
|
+
- Atomic writes (temp file + rename pattern)
|
|
20
|
+
- Rollback on failure (cleans up temp files)
|
|
21
|
+
- Directory creation
|
|
22
|
+
|
|
23
|
+
### 3. Config Generator (`src/services/config-generator.ts`)
|
|
24
|
+
|
|
25
|
+
Orchestration service that:
|
|
26
|
+
- Scans project → gets fingerprint
|
|
27
|
+
- Loads profile
|
|
28
|
+
- Renders all templates
|
|
29
|
+
- Writes files atomically
|
|
30
|
+
- Supports dry-run mode
|
|
31
|
+
- Evaluates conditions (!structure.hasCI, !structure.hasDocker)
|
|
32
|
+
|
|
33
|
+
### 4. First Complete Profile
|
|
34
|
+
|
|
35
|
+
**`profiles/claude-code/typescript-standard-modular-monolith.yml`**
|
|
36
|
+
|
|
37
|
+
Complete profile with:
|
|
38
|
+
- Meta information (name, version, description)
|
|
39
|
+
- Detection rules (when to suggest this profile)
|
|
40
|
+
- Instruction level config (guidelines to include, rules)
|
|
41
|
+
- Architecture config (structure, rules, focus areas)
|
|
42
|
+
- Output configs (which templates to render)
|
|
43
|
+
- Defaults (testing, linting, formatting, database, CI/CD)
|
|
44
|
+
|
|
45
|
+
### 5. Handlebars Templates
|
|
46
|
+
|
|
47
|
+
**Claude Code templates:**
|
|
48
|
+
|
|
49
|
+
1. **`instructions.md.hbs`** (~200 lines)
|
|
50
|
+
- Project overview
|
|
51
|
+
- Architecture description & structure
|
|
52
|
+
- Code guidelines & principles
|
|
53
|
+
- TypeScript specifics
|
|
54
|
+
- Error handling patterns
|
|
55
|
+
- Testing strategy
|
|
56
|
+
- Development workflow
|
|
57
|
+
- Environment configuration
|
|
58
|
+
- Logging patterns
|
|
59
|
+
- Deployment guidelines
|
|
60
|
+
|
|
61
|
+
2. **`config.yml.hbs`**
|
|
62
|
+
- Project metadata
|
|
63
|
+
- Profile info
|
|
64
|
+
- Defaults configuration
|
|
65
|
+
|
|
66
|
+
3. **`decisions.md.hbs`**
|
|
67
|
+
- Architecture Decision Records (ADRs)
|
|
68
|
+
- Initial decisions documented
|
|
69
|
+
- Template for adding new ADRs
|
|
70
|
+
|
|
71
|
+
## File Structure Created
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
profiles/
|
|
75
|
+
└── claude-code/
|
|
76
|
+
└── typescript-standard-modular-monolith.yml
|
|
77
|
+
|
|
78
|
+
templates/
|
|
79
|
+
└── claude-code/
|
|
80
|
+
├── instructions.md.hbs
|
|
81
|
+
├── config.yml.hbs
|
|
82
|
+
└── decisions.md.hbs
|
|
83
|
+
|
|
84
|
+
src/
|
|
85
|
+
├── models/
|
|
86
|
+
│ ├── project.ts (enhanced)
|
|
87
|
+
│ └── profile.ts (enhanced)
|
|
88
|
+
├── services/
|
|
89
|
+
│ ├── project-scanner.ts (new)
|
|
90
|
+
│ ├── recommender.ts (new)
|
|
91
|
+
│ ├── profile-loader.ts (new)
|
|
92
|
+
│ ├── template-renderer.ts (new)
|
|
93
|
+
│ └── config-generator.ts (new)
|
|
94
|
+
└── utils/
|
|
95
|
+
└── file.ts (enhanced with writeFiles)
|
|
96
|
+
|
|
97
|
+
examples/
|
|
98
|
+
├── phase1-demo.ts
|
|
99
|
+
└── phase2-demo.ts (new)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## How It Works
|
|
103
|
+
|
|
104
|
+
### Generation Flow
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
1. Scan Project
|
|
108
|
+
↓
|
|
109
|
+
2. Get Fingerprint (language, framework, size, etc.)
|
|
110
|
+
↓
|
|
111
|
+
3. Get Recommendations (instruction level, architecture)
|
|
112
|
+
↓
|
|
113
|
+
4. Load Profile (YAML file)
|
|
114
|
+
↓
|
|
115
|
+
5. Render Templates (Handlebars with context)
|
|
116
|
+
↓
|
|
117
|
+
6. Write Files Atomically
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Template Context
|
|
121
|
+
|
|
122
|
+
Every template receives:
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
{
|
|
126
|
+
project: ProjectFingerprint, // Detected project info
|
|
127
|
+
profile: ProfileConfig, // Selected profile
|
|
128
|
+
timestamp: Date // Generation time
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Handlebars Helpers
|
|
133
|
+
|
|
134
|
+
Available in all templates:
|
|
135
|
+
|
|
136
|
+
```handlebars
|
|
137
|
+
{{uppercase "hello"}} → HELLO
|
|
138
|
+
{{lowercase "WORLD"}} → world
|
|
139
|
+
{{capitalize "typescript"}} → Typescript
|
|
140
|
+
{{formatDate timestamp}} → 2025-12-06
|
|
141
|
+
|
|
142
|
+
{{#if (eq project.language.primary "typescript")}}
|
|
143
|
+
TypeScript detected!
|
|
144
|
+
{{/if}}
|
|
145
|
+
|
|
146
|
+
{{#if (gt project.projectSize.fileCount 100)}}
|
|
147
|
+
Large codebase
|
|
148
|
+
{{/if}}
|
|
149
|
+
|
|
150
|
+
{{#if (and project.structure.hasTests project.structure.hasCI)}}
|
|
151
|
+
Well-configured project
|
|
152
|
+
{{/if}}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Testing Phase 2
|
|
156
|
+
|
|
157
|
+
Run the demo:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
bun run examples/phase2-demo.ts
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Expected output:
|
|
164
|
+
```
|
|
165
|
+
=== Phase 2: Template System & Generation Demo ===
|
|
166
|
+
|
|
167
|
+
Step 1: Getting recommendations...
|
|
168
|
+
|
|
169
|
+
Project Analysis:
|
|
170
|
+
Name: aicgen
|
|
171
|
+
Language: typescript
|
|
172
|
+
Framework: None
|
|
173
|
+
Team Size: ~3 developers
|
|
174
|
+
File Count: 42
|
|
175
|
+
|
|
176
|
+
Recommended Configuration:
|
|
177
|
+
Instruction Level: standard
|
|
178
|
+
- Code style, testing, CI/CD, basic architecture
|
|
179
|
+
- Best for: Startup MVPs, small production apps, 1-5 developers
|
|
180
|
+
Architecture: modular-monolith
|
|
181
|
+
- Single deployment with clear module boundaries
|
|
182
|
+
- Complexity: Medium
|
|
183
|
+
|
|
184
|
+
Step 2: Generating configuration files...
|
|
185
|
+
|
|
186
|
+
Selected Profile:
|
|
187
|
+
claude-code + typescript + standard + modular-monolith
|
|
188
|
+
|
|
189
|
+
Generating (dry run)...
|
|
190
|
+
|
|
191
|
+
✅ Dry run successful!
|
|
192
|
+
|
|
193
|
+
Files that would be generated:
|
|
194
|
+
✓ .claude/instructions.md
|
|
195
|
+
✓ .claude/config.yml
|
|
196
|
+
✓ .claude/decisions.md
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Generated Files Preview
|
|
200
|
+
|
|
201
|
+
### .claude/instructions.md
|
|
202
|
+
|
|
203
|
+
Complete development guide including:
|
|
204
|
+
- Project overview with detected tech stack
|
|
205
|
+
- Modular monolith architecture description
|
|
206
|
+
- Code guidelines (TypeScript specific)
|
|
207
|
+
- Testing strategy
|
|
208
|
+
- Development workflow
|
|
209
|
+
- Environment & deployment
|
|
210
|
+
- Warnings if no tests/CI/Docker detected
|
|
211
|
+
|
|
212
|
+
### .claude/config.yml
|
|
213
|
+
|
|
214
|
+
Project configuration:
|
|
215
|
+
```yaml
|
|
216
|
+
project:
|
|
217
|
+
name: "your-project"
|
|
218
|
+
language: "typescript"
|
|
219
|
+
framework: "Next.js"
|
|
220
|
+
|
|
221
|
+
profile:
|
|
222
|
+
level: "standard"
|
|
223
|
+
architecture: "modular-monolith"
|
|
224
|
+
|
|
225
|
+
defaults:
|
|
226
|
+
runtime: "node:20-alpine"
|
|
227
|
+
testing:
|
|
228
|
+
framework: "vitest"
|
|
229
|
+
coverage: 80
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### .claude/decisions.md
|
|
233
|
+
|
|
234
|
+
Architecture Decision Records:
|
|
235
|
+
- ADR-001: Architecture choice
|
|
236
|
+
- ADR-002: Testing strategy
|
|
237
|
+
- ADR-003: Code quality tools
|
|
238
|
+
- Template for adding new ADRs
|
|
239
|
+
|
|
240
|
+
## Key Features
|
|
241
|
+
|
|
242
|
+
✅ **Conditional Generation**
|
|
243
|
+
- Only generate CI if not exists: `condition: "!structure.hasCI"`
|
|
244
|
+
- Only generate Docker if not exists: `condition: "!structure.hasDocker"`
|
|
245
|
+
- Optional files: `optional: true`
|
|
246
|
+
|
|
247
|
+
✅ **Context-Aware Templates**
|
|
248
|
+
```handlebars
|
|
249
|
+
{{#if project.database}}
|
|
250
|
+
- **Database:** {{project.database.type}}
|
|
251
|
+
{{/if}}
|
|
252
|
+
|
|
253
|
+
{{#if (not project.structure.hasTests)}}
|
|
254
|
+
⚠️ **No tests detected** - Priority!
|
|
255
|
+
{{/if}}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
✅ **Atomic Writes**
|
|
259
|
+
- All files written atomically
|
|
260
|
+
- Rollback on failure
|
|
261
|
+
- No partial state
|
|
262
|
+
|
|
263
|
+
✅ **Dry Run Support**
|
|
264
|
+
- See what would be generated
|
|
265
|
+
- No files written
|
|
266
|
+
- Validate templates
|
|
267
|
+
|
|
268
|
+
## Architecture Decisions
|
|
269
|
+
|
|
270
|
+
1. **Handlebars over other engines**
|
|
271
|
+
- Simple, powerful, widely used
|
|
272
|
+
- Good TypeScript support
|
|
273
|
+
- Extensible with helpers
|
|
274
|
+
- No code execution (safe)
|
|
275
|
+
|
|
276
|
+
2. **Atomic batch writes**
|
|
277
|
+
- Write all to .tmp first
|
|
278
|
+
- Rename all at once
|
|
279
|
+
- Rollback on any failure
|
|
280
|
+
- Prevents partial state
|
|
281
|
+
|
|
282
|
+
3. **Template context structure**
|
|
283
|
+
- `project` - what was detected
|
|
284
|
+
- `profile` - what was selected
|
|
285
|
+
- `timestamp` - when generated
|
|
286
|
+
- Simple, predictable
|
|
287
|
+
|
|
288
|
+
4. **Condition evaluation**
|
|
289
|
+
- Simple string conditions
|
|
290
|
+
- Evaluated in generator
|
|
291
|
+
- Can extend easily
|
|
292
|
+
- Type-safe
|
|
293
|
+
|
|
294
|
+
5. **Profile as single source of truth**
|
|
295
|
+
- YAML defines everything
|
|
296
|
+
- Templates referenced, not embedded
|
|
297
|
+
- Easy to add new profiles
|
|
298
|
+
- Versioned separately
|
|
299
|
+
|
|
300
|
+
## What's Next: Phase 3
|
|
301
|
+
|
|
302
|
+
Phase 3 will add the interactive CLI wizard:
|
|
303
|
+
|
|
304
|
+
1. **Interactive prompts** (Inquirer.js)
|
|
305
|
+
- Select AI assistant
|
|
306
|
+
- Choose instruction level
|
|
307
|
+
- Choose architecture
|
|
308
|
+
- Configure options
|
|
309
|
+
|
|
310
|
+
2. **Pretty terminal output** (Chalk + Ora)
|
|
311
|
+
- Colored output
|
|
312
|
+
- Progress spinners
|
|
313
|
+
- Success/error indicators
|
|
314
|
+
|
|
315
|
+
3. **CLI commands**
|
|
316
|
+
- `aicgen init` - Interactive wizard
|
|
317
|
+
- `aicgen init --profile claude-code` - Skip assistant selection
|
|
318
|
+
- `aicgen init --level expert` - Skip level selection
|
|
319
|
+
|
|
320
|
+
4. **Validation & confirmation**
|
|
321
|
+
- Show what will be generated
|
|
322
|
+
- Confirm before writing
|
|
323
|
+
- Handle existing files
|
|
324
|
+
|
|
325
|
+
## Success Criteria ✅
|
|
326
|
+
|
|
327
|
+
- [x] Template renderer with Handlebars
|
|
328
|
+
- [x] Custom helpers for common operations
|
|
329
|
+
- [x] Batch atomic file writes
|
|
330
|
+
- [x] Config generator orchestration
|
|
331
|
+
- [x] First complete profile (Claude Code + TypeScript)
|
|
332
|
+
- [x] Three templates (instructions, config, decisions)
|
|
333
|
+
- [x] Dry-run support
|
|
334
|
+
- [x] Conditional generation
|
|
335
|
+
- [x] Context-aware templates
|
|
336
|
+
- [x] Demo showing end-to-end flow
|
|
337
|
+
|
|
338
|
+
## Ready for Phase 3!
|
|
339
|
+
|
|
340
|
+
**Next command:**
|
|
341
|
+
```bash
|
|
342
|
+
# After Phase 3, you'll be able to run:
|
|
343
|
+
aicgen init
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
And get an interactive wizard that:
|
|
347
|
+
1. Scans your project
|
|
348
|
+
2. Recommends instruction level & architecture
|
|
349
|
+
3. Lets you customize
|
|
350
|
+
4. Generates all config files
|