@aicgen/aicgen 1.0.0-beta.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{.claude/guidelines → .agent/rules}/api-design.md +5 -1
- package/{.claude/guidelines → .agent/rules}/architecture.md +5 -1
- package/{.claude/guidelines → .agent/rules}/best-practices.md +5 -1
- package/{.claude/guidelines → .agent/rules}/code-style.md +5 -1
- package/{.claude/guidelines → .agent/rules}/design-patterns.md +5 -1
- package/{.claude/guidelines → .agent/rules}/devops.md +5 -1
- package/{.claude/guidelines → .agent/rules}/error-handling.md +5 -1
- package/.agent/rules/instructions.md +28 -0
- package/{.claude/guidelines → .agent/rules}/language.md +5 -1
- package/{.claude/guidelines → .agent/rules}/performance.md +5 -1
- package/{.claude/guidelines → .agent/rules}/security.md +5 -1
- package/{.claude/guidelines → .agent/rules}/testing.md +5 -1
- package/.agent/workflows/add-documentation.md +10 -0
- package/.agent/workflows/generate-integration-tests.md +10 -0
- package/.agent/workflows/generate-unit-tests.md +11 -0
- package/.agent/workflows/performance-audit.md +11 -0
- package/.agent/workflows/refactor-extract-module.md +12 -0
- package/.agent/workflows/security-audit.md +12 -0
- package/.gemini/instructions.md +4843 -0
- package/.vs/ProjectSettings.json +2 -2
- package/.vs/VSWorkspaceState.json +15 -15
- package/.vs/aicgen.slnx/v18/DocumentLayout.json +53 -53
- package/AGENTS.md +9 -11
- package/assets/icon.svg +33 -33
- package/bun.lock +734 -26
- package/{CLAUDE.md → claude.md} +2 -2
- package/config.example.yml +129 -0
- package/config.yml +38 -0
- package/data/architecture/microservices/api-gateway.md +56 -56
- package/data/devops/observability.md +73 -73
- package/data/guideline-mappings.yml +128 -0
- package/data/language/dart/async.md +289 -0
- package/data/language/dart/basics.md +280 -0
- package/data/language/dart/error-handling.md +355 -0
- package/data/language/dart/index.md +10 -0
- package/data/language/dart/testing.md +352 -0
- package/data/language/swift/basics.md +477 -0
- package/data/language/swift/concurrency.md +654 -0
- package/data/language/swift/error-handling.md +679 -0
- package/data/language/swift/swiftui-mvvm.md +795 -0
- package/data/language/swift/testing.md +708 -0
- package/data/version.json +10 -8
- package/dist/index.js +50153 -28959
- package/jest.config.js +46 -0
- package/package.json +14 -3
- package/.claude/agents/architecture-reviewer.md +0 -88
- package/.claude/agents/guideline-checker.md +0 -73
- package/.claude/agents/security-auditor.md +0 -108
- package/.claude/settings.json +0 -98
- package/.claude/settings.local.json +0 -8
- package/.eslintrc.json +0 -28
- package/.github/workflows/release.yml +0 -180
- package/.github/workflows/test.yml +0 -81
- package/CONTRIBUTING.md +0 -821
- package/dist/commands/init.d.ts +0 -8
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -46
- package/dist/commands/init.js.map +0 -1
- package/dist/config/profiles.d.ts +0 -4
- package/dist/config/profiles.d.ts.map +0 -1
- package/dist/config/profiles.js +0 -30
- package/dist/config/profiles.js.map +0 -1
- package/dist/config/settings.d.ts +0 -7
- package/dist/config/settings.d.ts.map +0 -1
- package/dist/config/settings.js +0 -7
- package/dist/config/settings.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/models/guideline.d.ts +0 -15
- package/dist/models/guideline.d.ts.map +0 -1
- package/dist/models/guideline.js +0 -2
- package/dist/models/guideline.js.map +0 -1
- package/dist/models/preference.d.ts +0 -9
- package/dist/models/preference.d.ts.map +0 -1
- package/dist/models/preference.js +0 -2
- package/dist/models/preference.js.map +0 -1
- package/dist/models/profile.d.ts +0 -9
- package/dist/models/profile.d.ts.map +0 -1
- package/dist/models/profile.js +0 -2
- package/dist/models/profile.js.map +0 -1
- package/dist/models/project.d.ts +0 -13
- package/dist/models/project.d.ts.map +0 -1
- package/dist/models/project.js +0 -2
- package/dist/models/project.js.map +0 -1
- package/dist/services/ai/anthropic.d.ts +0 -7
- package/dist/services/ai/anthropic.d.ts.map +0 -1
- package/dist/services/ai/anthropic.js +0 -39
- package/dist/services/ai/anthropic.js.map +0 -1
- package/dist/services/generator.d.ts +0 -2
- package/dist/services/generator.d.ts.map +0 -1
- package/dist/services/generator.js +0 -4
- package/dist/services/generator.js.map +0 -1
- package/dist/services/learner.d.ts +0 -2
- package/dist/services/learner.d.ts.map +0 -1
- package/dist/services/learner.js +0 -4
- package/dist/services/learner.js.map +0 -1
- package/dist/services/scanner.d.ts +0 -3
- package/dist/services/scanner.d.ts.map +0 -1
- package/dist/services/scanner.js +0 -54
- package/dist/services/scanner.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -15
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js +0 -27
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/file.d.ts +0 -7
- package/dist/utils/file.d.ts.map +0 -1
- package/dist/utils/file.js +0 -32
- package/dist/utils/file.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -6
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -17
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/path.d.ts +0 -6
- package/dist/utils/path.d.ts.map +0 -1
- package/dist/utils/path.js +0 -14
- package/dist/utils/path.js.map +0 -1
- package/docs/planning/memory-lane.md +0 -83
- package/packaging/linux/aicgen.spec +0 -23
- package/packaging/linux/control +0 -9
- package/packaging/macos/scripts/postinstall +0 -12
- package/packaging/windows/setup.nsi +0 -92
- package/scripts/add-categories.ts +0 -87
- package/scripts/build-binary.ts +0 -46
- package/scripts/embed-data.ts +0 -105
- package/scripts/generate-version.ts +0 -150
- package/scripts/test-decompress.ts +0 -27
- package/scripts/test-extract.ts +0 -31
- package/src/__tests__/services/assistant-file-writer.test.ts +0 -400
- package/src/__tests__/services/guideline-loader.test.ts +0 -281
- package/src/__tests__/services/tarball-extraction.test.ts +0 -125
- package/src/commands/add-guideline.ts +0 -296
- package/src/commands/clear.ts +0 -61
- package/src/commands/guideline-selector.ts +0 -123
- package/src/commands/init.ts +0 -645
- package/src/commands/quick-add.ts +0 -586
- package/src/commands/remove-guideline.ts +0 -152
- package/src/commands/stats.ts +0 -49
- package/src/commands/update.ts +0 -240
- package/src/config.ts +0 -82
- package/src/embedded-data.ts +0 -1492
- package/src/index.ts +0 -67
- package/src/models/profile.ts +0 -24
- package/src/models/project.ts +0 -43
- package/src/services/assistant-file-writer.ts +0 -612
- package/src/services/config-generator.ts +0 -150
- package/src/services/config-manager.ts +0 -70
- package/src/services/data-source.ts +0 -248
- package/src/services/first-run-init.ts +0 -148
- package/src/services/guideline-loader.ts +0 -311
- package/src/services/hook-generator.ts +0 -178
- package/src/services/subagent-generator.ts +0 -310
- package/src/utils/banner.ts +0 -66
- package/src/utils/errors.ts +0 -27
- package/src/utils/file.ts +0 -67
- package/src/utils/formatting.ts +0 -172
- package/src/utils/logger.ts +0 -89
- package/src/utils/path.ts +0 -17
- package/src/utils/wizard-state.ts +0 -132
- package/tsconfig.json +0 -25
package/CONTRIBUTING.md
DELETED
|
@@ -1,821 +0,0 @@
|
|
|
1
|
-
# Contributing to aicgen
|
|
2
|
-
|
|
3
|
-
Thank you for your interest in contributing to **aicgen**! We welcome contributions of all kinds: bug reports, feature suggestions, documentation improvements, and code contributions.
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Code of Conduct](#code-of-conduct)
|
|
8
|
-
- [How Can I Contribute?](#how-can-i-contribute)
|
|
9
|
-
- [Reporting Bugs](#reporting-bugs)
|
|
10
|
-
- [Suggesting Features](#suggesting-features)
|
|
11
|
-
- [Improving Documentation](#improving-documentation)
|
|
12
|
-
- [Contributing Code](#contributing-code)
|
|
13
|
-
- [Development Setup](#development-setup)
|
|
14
|
-
- [Development Workflow](#development-workflow)
|
|
15
|
-
- [Code Standards](#code-standards)
|
|
16
|
-
- [Testing Guidelines](#testing-guidelines)
|
|
17
|
-
- [Commit Guidelines](#commit-guidelines)
|
|
18
|
-
- [Pull Request Process](#pull-request-process)
|
|
19
|
-
- [Project Structure](#project-structure)
|
|
20
|
-
- [Adding New Guidelines](#adding-new-guidelines)
|
|
21
|
-
- [Building Binaries](#building-binaries)
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## Code of Conduct
|
|
26
|
-
|
|
27
|
-
This project adheres to a code of conduct that promotes a welcoming and inclusive environment. By participating, you are expected to:
|
|
28
|
-
|
|
29
|
-
- Be respectful and considerate in all interactions
|
|
30
|
-
- Provide constructive feedback
|
|
31
|
-
- Focus on what is best for the community
|
|
32
|
-
- Show empathy towards other contributors
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
## How Can I Contribute?
|
|
37
|
-
|
|
38
|
-
### Reporting Bugs
|
|
39
|
-
|
|
40
|
-
Found a bug? Help us fix it by submitting a detailed bug report.
|
|
41
|
-
|
|
42
|
-
**Before Submitting:**
|
|
43
|
-
- Check the [existing issues](https://github.com/lpsandaruwan/aicgen/issues) to avoid duplicates
|
|
44
|
-
- Verify you're using the latest version
|
|
45
|
-
- Try to reproduce the bug with minimal steps
|
|
46
|
-
|
|
47
|
-
**Creating a Bug Report:**
|
|
48
|
-
|
|
49
|
-
Open a [new issue](https://github.com/lpsandaruwan/aicgen/issues/new) with the following information:
|
|
50
|
-
|
|
51
|
-
**Title:** Clear, concise description (e.g., "Init command fails on Windows with spaces in path")
|
|
52
|
-
|
|
53
|
-
**Template:**
|
|
54
|
-
```markdown
|
|
55
|
-
## Bug Description
|
|
56
|
-
A clear description of what the bug is.
|
|
57
|
-
|
|
58
|
-
## Steps to Reproduce
|
|
59
|
-
1. Run `aicgen init`
|
|
60
|
-
2. Select profile 'balanced'
|
|
61
|
-
3. ...
|
|
62
|
-
|
|
63
|
-
## Expected Behavior
|
|
64
|
-
What you expected to happen.
|
|
65
|
-
|
|
66
|
-
## Actual Behavior
|
|
67
|
-
What actually happened.
|
|
68
|
-
|
|
69
|
-
## Environment
|
|
70
|
-
- **OS:** Windows 11 / macOS 14.2 / Ubuntu 22.04
|
|
71
|
-
- **aicgen version:** 0.2.0
|
|
72
|
-
- **Bun version:** 1.1.0
|
|
73
|
-
- **Node version:** (if applicable)
|
|
74
|
-
|
|
75
|
-
## Additional Context
|
|
76
|
-
- Screenshots
|
|
77
|
-
- Error messages
|
|
78
|
-
- Logs (run with `--debug` flag)
|
|
79
|
-
|
|
80
|
-
## Possible Solution (Optional)
|
|
81
|
-
If you have ideas on how to fix this.
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
**Priority Labels:**
|
|
85
|
-
- `critical` - Blocks core functionality
|
|
86
|
-
- `high` - Significant impact on user experience
|
|
87
|
-
- `medium` - Affects some users
|
|
88
|
-
- `low` - Minor issue or edge case
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
### Suggesting Features
|
|
93
|
-
|
|
94
|
-
Have an idea to make aicgen better? We'd love to hear it!
|
|
95
|
-
|
|
96
|
-
**Before Suggesting:**
|
|
97
|
-
- Check [existing feature requests](https://github.com/lpsandaruwan/aicgen/issues?q=is%3Aissue+label%3Aenhancement)
|
|
98
|
-
- Review the [roadmap](README.md#-roadmap) to see if it's already planned
|
|
99
|
-
- Consider if it aligns with aicgen's core purpose
|
|
100
|
-
|
|
101
|
-
**Creating a Feature Request:**
|
|
102
|
-
|
|
103
|
-
Open a [new issue](https://github.com/lpsandaruwan/aicgen/issues/new) with the label `enhancement`:
|
|
104
|
-
|
|
105
|
-
**Template:**
|
|
106
|
-
```markdown
|
|
107
|
-
## Feature Request
|
|
108
|
-
|
|
109
|
-
### Problem Statement
|
|
110
|
-
What problem does this solve? What use case does it address?
|
|
111
|
-
|
|
112
|
-
### Proposed Solution
|
|
113
|
-
Describe your ideal implementation.
|
|
114
|
-
|
|
115
|
-
### Alternatives Considered
|
|
116
|
-
What other approaches did you consider?
|
|
117
|
-
|
|
118
|
-
### User Impact
|
|
119
|
-
Who benefits? How often will this be used?
|
|
120
|
-
|
|
121
|
-
### Example Usage
|
|
122
|
-
```bash
|
|
123
|
-
# Show how the feature would be used
|
|
124
|
-
aicgen new-command --example
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### Additional Context
|
|
128
|
-
- Related issues
|
|
129
|
-
- Similar features in other tools
|
|
130
|
-
- Mockups or diagrams
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
**Feature Categories:**
|
|
134
|
-
- `enhancement:core` - Core CLI functionality
|
|
135
|
-
- `enhancement:guidelines` - New guidelines or categories
|
|
136
|
-
- `enhancement:ai` - AI analysis improvements
|
|
137
|
-
- `enhancement:ux` - User experience improvements
|
|
138
|
-
- `enhancement:docs` - Documentation additions
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
### Improving Documentation
|
|
143
|
-
|
|
144
|
-
Documentation improvements are always welcome! This includes:
|
|
145
|
-
|
|
146
|
-
- Fixing typos or grammatical errors
|
|
147
|
-
- Clarifying confusing sections
|
|
148
|
-
- Adding examples or use cases
|
|
149
|
-
- Improving code comments
|
|
150
|
-
- Writing tutorials or guides
|
|
151
|
-
|
|
152
|
-
**How to Contribute:**
|
|
153
|
-
1. Fork the repository
|
|
154
|
-
2. Make your changes
|
|
155
|
-
3. Submit a pull request with `docs:` prefix in the title
|
|
156
|
-
|
|
157
|
-
**Documentation Files:**
|
|
158
|
-
- `README.md` - Main project documentation
|
|
159
|
-
- `CLAUDE.md` - Development guidelines and architecture
|
|
160
|
-
- `CONTRIBUTING.md` - This file
|
|
161
|
-
- Guidelines in `data/guidelines/` - Content guidelines
|
|
162
|
-
- Code comments - In-code documentation
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
### Contributing Code
|
|
167
|
-
|
|
168
|
-
Ready to write some code? Great! Follow these steps.
|
|
169
|
-
|
|
170
|
-
---
|
|
171
|
-
|
|
172
|
-
## Development Setup
|
|
173
|
-
|
|
174
|
-
### Prerequisites
|
|
175
|
-
|
|
176
|
-
- **Bun** >= 1.0.0 ([Install Bun](https://bun.sh))
|
|
177
|
-
- **Git**
|
|
178
|
-
- **TypeScript** knowledge
|
|
179
|
-
- **Node.js** (optional, for compatibility testing)
|
|
180
|
-
|
|
181
|
-
### Clone and Install
|
|
182
|
-
|
|
183
|
-
```bash
|
|
184
|
-
# Fork the repository first, then:
|
|
185
|
-
git clone https://github.com/YOUR_USERNAME/aicgen.git
|
|
186
|
-
cd aicgen
|
|
187
|
-
|
|
188
|
-
# Install dependencies
|
|
189
|
-
bun install
|
|
190
|
-
|
|
191
|
-
# Verify setup
|
|
192
|
-
bun run typecheck
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### Set Up API Keys (Optional)
|
|
196
|
-
|
|
197
|
-
For testing AI features:
|
|
198
|
-
|
|
199
|
-
```bash
|
|
200
|
-
# Claude
|
|
201
|
-
export ANTHROPIC_API_KEY=sk-ant-...
|
|
202
|
-
|
|
203
|
-
# Gemini
|
|
204
|
-
export GEMINI_API_KEY=...
|
|
205
|
-
|
|
206
|
-
# OpenAI
|
|
207
|
-
export OPENAI_API_KEY=sk-...
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
## Development Workflow
|
|
213
|
-
|
|
214
|
-
### Running in Development
|
|
215
|
-
|
|
216
|
-
```bash
|
|
217
|
-
# Watch mode (auto-reload on changes)
|
|
218
|
-
bun run dev
|
|
219
|
-
|
|
220
|
-
# Run commands directly
|
|
221
|
-
bun run start init
|
|
222
|
-
bun run start init --help
|
|
223
|
-
|
|
224
|
-
# Type checking
|
|
225
|
-
bun run typecheck
|
|
226
|
-
|
|
227
|
-
# Linting
|
|
228
|
-
bun run lint
|
|
229
|
-
|
|
230
|
-
# Format code
|
|
231
|
-
bun run format
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
### Testing Your Changes
|
|
235
|
-
|
|
236
|
-
```bash
|
|
237
|
-
# Run all tests
|
|
238
|
-
bun test
|
|
239
|
-
|
|
240
|
-
# Run specific test file
|
|
241
|
-
bun test src/services/__tests__/scanner.test.ts
|
|
242
|
-
|
|
243
|
-
# Run with coverage
|
|
244
|
-
bun test --coverage
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
### Building
|
|
248
|
-
|
|
249
|
-
```bash
|
|
250
|
-
# Standard build
|
|
251
|
-
bun run build
|
|
252
|
-
|
|
253
|
-
# Build binary for current platform
|
|
254
|
-
bun run build:binary
|
|
255
|
-
|
|
256
|
-
# Build for specific platform
|
|
257
|
-
bun run build:binary:windows
|
|
258
|
-
bun run build:binary:linux
|
|
259
|
-
bun run build:binary:macos
|
|
260
|
-
|
|
261
|
-
# Build all platforms
|
|
262
|
-
bun run build:all
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
---
|
|
266
|
-
|
|
267
|
-
## Code Standards
|
|
268
|
-
|
|
269
|
-
### TypeScript Standards
|
|
270
|
-
|
|
271
|
-
- **Strict Mode:** All checks enabled (`tsconfig.json`)
|
|
272
|
-
- **No `any` types** - Use `unknown` with type guards
|
|
273
|
-
- **Prefer interfaces** for public APIs, types for internal use
|
|
274
|
-
- **Export types** alongside implementations
|
|
275
|
-
- **Discriminated unions** for variant types
|
|
276
|
-
|
|
277
|
-
**Good:**
|
|
278
|
-
```typescript
|
|
279
|
-
interface Config {
|
|
280
|
-
profile: 'basic' | 'balanced' | 'expert';
|
|
281
|
-
guidelines: string[];
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function processConfig(config: Config): void {
|
|
285
|
-
// Implementation
|
|
286
|
-
}
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
**Bad:**
|
|
290
|
-
```typescript
|
|
291
|
-
function processConfig(config: any) {
|
|
292
|
-
// Implementation
|
|
293
|
-
}
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
### Naming Conventions
|
|
297
|
-
|
|
298
|
-
- **Classes:** `PascalCase` (e.g., `ProjectScanner`)
|
|
299
|
-
- **Functions/Variables:** `camelCase` (e.g., `detectProjectType`)
|
|
300
|
-
- **Constants:** `UPPER_SNAKE_CASE` (e.g., `DEFAULT_PROFILE`)
|
|
301
|
-
- **Interfaces:** `PascalCase`, no `I` prefix (e.g., `Config`, not `IConfig`)
|
|
302
|
-
- **Types:** `PascalCase` (e.g., `ProfileType`)
|
|
303
|
-
- **Files:** `kebab-case` (e.g., `project-scanner.ts`)
|
|
304
|
-
|
|
305
|
-
### File Organization
|
|
306
|
-
|
|
307
|
-
```typescript
|
|
308
|
-
// 1. Node built-ins
|
|
309
|
-
import { readFile } from 'fs/promises';
|
|
310
|
-
import path from 'path';
|
|
311
|
-
|
|
312
|
-
// 2. External dependencies
|
|
313
|
-
import chalk from 'chalk';
|
|
314
|
-
import { Command } from 'commander';
|
|
315
|
-
|
|
316
|
-
// 3. Internal modules (grouped by layer)
|
|
317
|
-
import { ProjectScanner } from '@/services/scanner';
|
|
318
|
-
import { Config } from '@/models/config';
|
|
319
|
-
import { AicgenError } from '@/utils/errors';
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
### Function Guidelines
|
|
323
|
-
|
|
324
|
-
- **Max 50 lines** per function
|
|
325
|
-
- **Max 3 levels** of nesting
|
|
326
|
-
- **Extract complex conditionals** into named functions
|
|
327
|
-
- **Single responsibility** - one function, one purpose
|
|
328
|
-
|
|
329
|
-
**Good:**
|
|
330
|
-
```typescript
|
|
331
|
-
async function initializeProject(path: string): Promise<void> {
|
|
332
|
-
validatePath(path);
|
|
333
|
-
const config = await loadConfig(path);
|
|
334
|
-
const scanner = new ProjectScanner(path);
|
|
335
|
-
const results = await scanner.scan();
|
|
336
|
-
await generateFiles(config, results);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function validatePath(path: string): void {
|
|
340
|
-
if (!existsSync(path)) {
|
|
341
|
-
throw new ProjectNotFoundError(path);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
**Bad:**
|
|
347
|
-
```typescript
|
|
348
|
-
async function initializeProject(path: string): Promise<void> {
|
|
349
|
-
if (!existsSync(path)) {
|
|
350
|
-
throw new Error('Not found');
|
|
351
|
-
}
|
|
352
|
-
const config = await readFile(path);
|
|
353
|
-
if (config) {
|
|
354
|
-
const scanner = new ProjectScanner(path);
|
|
355
|
-
if (scanner) {
|
|
356
|
-
const results = await scanner.scan();
|
|
357
|
-
if (results) {
|
|
358
|
-
// Deep nesting...
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
### Error Handling
|
|
366
|
-
|
|
367
|
-
Use custom error classes that extend `AicgenError`:
|
|
368
|
-
|
|
369
|
-
```typescript
|
|
370
|
-
export class AicgenError extends Error {
|
|
371
|
-
constructor(
|
|
372
|
-
message: string,
|
|
373
|
-
public code: string,
|
|
374
|
-
public details?: unknown
|
|
375
|
-
) {
|
|
376
|
-
super(message);
|
|
377
|
-
this.name = 'AicgenError';
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
export class ProjectNotFoundError extends AicgenError {
|
|
382
|
-
constructor(path: string) {
|
|
383
|
-
super(
|
|
384
|
-
`No project found at ${path}`,
|
|
385
|
-
'PROJECT_NOT_FOUND',
|
|
386
|
-
{ path }
|
|
387
|
-
);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
**Error Handling Best Practices:**
|
|
393
|
-
- Use specific error types
|
|
394
|
-
- Include actionable messages
|
|
395
|
-
- Log error details in debug mode
|
|
396
|
-
- Never expose internal errors to users
|
|
397
|
-
- Handle expected errors gracefully
|
|
398
|
-
|
|
399
|
-
### Async Operations
|
|
400
|
-
|
|
401
|
-
```typescript
|
|
402
|
-
// Good - Prefer async/await
|
|
403
|
-
async function loadMultipleFiles(paths: string[]): Promise<string[]> {
|
|
404
|
-
return Promise.all(paths.map(p => readFile(p, 'utf-8')));
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
// Good - Handle partial failures
|
|
408
|
-
async function loadWithFallback(paths: string[]): Promise<SettledResult[]> {
|
|
409
|
-
return Promise.allSettled(paths.map(p => readFile(p, 'utf-8')));
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// Bad - Mixing promises and callbacks
|
|
413
|
-
function loadFile(path: string, callback: Function) {
|
|
414
|
-
readFile(path).then(data => callback(null, data));
|
|
415
|
-
}
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
### Comments Policy
|
|
419
|
-
|
|
420
|
-
**NO REDUNDANT COMMENTS** - Code should be self-documenting.
|
|
421
|
-
|
|
422
|
-
**Only comment WHY, never WHAT:**
|
|
423
|
-
|
|
424
|
-
**Good:**
|
|
425
|
-
```typescript
|
|
426
|
-
// Normalize to forward slashes for cross-platform compatibility
|
|
427
|
-
const normalizedPath = path.replace(/\\/g, '/');
|
|
428
|
-
|
|
429
|
-
// Retry with exponential backoff to handle rate limits
|
|
430
|
-
await retryWithBackoff(() => apiCall());
|
|
431
|
-
```
|
|
432
|
-
|
|
433
|
-
**Bad:**
|
|
434
|
-
```typescript
|
|
435
|
-
// Set the path variable
|
|
436
|
-
const path = '/some/path';
|
|
437
|
-
|
|
438
|
-
// Call the function
|
|
439
|
-
doSomething();
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
**When to comment:**
|
|
443
|
-
- Complex algorithms that aren't obvious
|
|
444
|
-
- Workarounds for external library bugs
|
|
445
|
-
- Security-sensitive code
|
|
446
|
-
- Performance optimizations
|
|
447
|
-
|
|
448
|
-
---
|
|
449
|
-
|
|
450
|
-
## Testing Guidelines
|
|
451
|
-
|
|
452
|
-
### Test Structure
|
|
453
|
-
|
|
454
|
-
```typescript
|
|
455
|
-
import { describe, expect, it, beforeEach } from 'bun:test';
|
|
456
|
-
import { ProjectScanner } from '@/services/scanner';
|
|
457
|
-
|
|
458
|
-
describe('ProjectScanner', () => {
|
|
459
|
-
let scanner: ProjectScanner;
|
|
460
|
-
|
|
461
|
-
beforeEach(() => {
|
|
462
|
-
scanner = new ProjectScanner('/test/path');
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
it('should detect TypeScript projects', async () => {
|
|
466
|
-
const result = await scanner.detectLanguage();
|
|
467
|
-
expect(result).toBe('typescript');
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
it('should throw error for invalid path', async () => {
|
|
471
|
-
expect(() => new ProjectScanner('')).toThrow(ProjectNotFoundError);
|
|
472
|
-
});
|
|
473
|
-
});
|
|
474
|
-
```
|
|
475
|
-
|
|
476
|
-
### What to Test
|
|
477
|
-
|
|
478
|
-
- **Unit Tests:** Individual functions and classes
|
|
479
|
-
- **Integration Tests:** Multiple components working together
|
|
480
|
-
- **E2E Tests:** Full command execution with fixtures
|
|
481
|
-
- **Edge Cases:** Empty inputs, missing files, invalid data
|
|
482
|
-
- **Error Paths:** Ensure errors are thrown correctly
|
|
483
|
-
|
|
484
|
-
### Mocking
|
|
485
|
-
|
|
486
|
-
```typescript
|
|
487
|
-
import { mock } from 'bun:test';
|
|
488
|
-
|
|
489
|
-
// Mock file system
|
|
490
|
-
mock.module('fs/promises', () => ({
|
|
491
|
-
readFile: async () => 'mocked content',
|
|
492
|
-
writeFile: async () => {},
|
|
493
|
-
}));
|
|
494
|
-
|
|
495
|
-
// Mock API calls
|
|
496
|
-
mock.module('@anthropic-ai/sdk', () => ({
|
|
497
|
-
Anthropic: class {
|
|
498
|
-
messages = {
|
|
499
|
-
create: async () => ({ content: 'mocked response' }),
|
|
500
|
-
};
|
|
501
|
-
},
|
|
502
|
-
}));
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
---
|
|
506
|
-
|
|
507
|
-
## Commit Guidelines
|
|
508
|
-
|
|
509
|
-
### Commit Message Format
|
|
510
|
-
|
|
511
|
-
Follow [Conventional Commits](https://www.conventionalcommits.org/):
|
|
512
|
-
|
|
513
|
-
```
|
|
514
|
-
<type>(<scope>): <subject>
|
|
515
|
-
|
|
516
|
-
<body>
|
|
517
|
-
|
|
518
|
-
<footer>
|
|
519
|
-
```
|
|
520
|
-
|
|
521
|
-
**Types:**
|
|
522
|
-
- `feat` - New feature
|
|
523
|
-
- `fix` - Bug fix
|
|
524
|
-
- `docs` - Documentation only
|
|
525
|
-
- `style` - Code style (formatting, missing semicolons)
|
|
526
|
-
- `refactor` - Code change that neither fixes a bug nor adds a feature
|
|
527
|
-
- `perf` - Performance improvement
|
|
528
|
-
- `test` - Adding or updating tests
|
|
529
|
-
- `chore` - Maintenance tasks (deps, build scripts)
|
|
530
|
-
|
|
531
|
-
**Examples:**
|
|
532
|
-
```bash
|
|
533
|
-
feat(init): add support for custom profile templates
|
|
534
|
-
|
|
535
|
-
fix(scanner): resolve Windows path handling issue
|
|
536
|
-
|
|
537
|
-
docs(readme): update installation instructions
|
|
538
|
-
|
|
539
|
-
refactor(generator): extract template rendering logic
|
|
540
|
-
```
|
|
541
|
-
|
|
542
|
-
### Commit Best Practices
|
|
543
|
-
|
|
544
|
-
- **Atomic commits** - One logical change per commit
|
|
545
|
-
- **Clear messages** - Describe WHAT and WHY, not HOW
|
|
546
|
-
- **Reference issues** - Use `Fixes #123` or `Closes #456`
|
|
547
|
-
- **Test before committing** - Ensure tests pass
|
|
548
|
-
- **No merge commits** - Rebase before merging
|
|
549
|
-
|
|
550
|
-
---
|
|
551
|
-
|
|
552
|
-
## Pull Request Process
|
|
553
|
-
|
|
554
|
-
### Before Submitting
|
|
555
|
-
|
|
556
|
-
- [ ] Code follows project standards
|
|
557
|
-
- [ ] All tests pass (`bun test`)
|
|
558
|
-
- [ ] Type checking passes (`bun run typecheck`)
|
|
559
|
-
- [ ] Linting passes (`bun run lint`)
|
|
560
|
-
- [ ] Code is formatted (`bun run format`)
|
|
561
|
-
- [ ] Documentation is updated
|
|
562
|
-
- [ ] Commit messages follow conventions
|
|
563
|
-
|
|
564
|
-
### PR Template
|
|
565
|
-
|
|
566
|
-
**Title:** `feat(scope): add new feature` or `fix(scope): resolve bug`
|
|
567
|
-
|
|
568
|
-
**Description:**
|
|
569
|
-
```markdown
|
|
570
|
-
## Summary
|
|
571
|
-
Brief description of changes.
|
|
572
|
-
|
|
573
|
-
## Motivation
|
|
574
|
-
Why is this change needed? What problem does it solve?
|
|
575
|
-
|
|
576
|
-
## Changes
|
|
577
|
-
- Added X feature
|
|
578
|
-
- Updated Y component
|
|
579
|
-
- Fixed Z bug
|
|
580
|
-
|
|
581
|
-
## Testing
|
|
582
|
-
How was this tested?
|
|
583
|
-
- [ ] Unit tests added/updated
|
|
584
|
-
- [ ] Manual testing performed
|
|
585
|
-
- [ ] Edge cases considered
|
|
586
|
-
|
|
587
|
-
## Screenshots (if applicable)
|
|
588
|
-
Before/after screenshots or terminal output.
|
|
589
|
-
|
|
590
|
-
## Checklist
|
|
591
|
-
- [ ] Tests pass
|
|
592
|
-
- [ ] Documentation updated
|
|
593
|
-
- [ ] Breaking changes documented
|
|
594
|
-
- [ ] Backwards compatible (or migration guide provided)
|
|
595
|
-
|
|
596
|
-
## Related Issues
|
|
597
|
-
Fixes #123
|
|
598
|
-
Closes #456
|
|
599
|
-
```
|
|
600
|
-
|
|
601
|
-
### Review Process
|
|
602
|
-
|
|
603
|
-
1. **Automated checks** run (tests, linting, type checking)
|
|
604
|
-
2. **Maintainer review** - may request changes
|
|
605
|
-
3. **Address feedback** - make requested updates
|
|
606
|
-
4. **Approval** - maintainer approves PR
|
|
607
|
-
5. **Merge** - squash and merge to main
|
|
608
|
-
|
|
609
|
-
### PR Guidelines
|
|
610
|
-
|
|
611
|
-
- **Keep PRs focused** - One feature/fix per PR
|
|
612
|
-
- **Small is better** - Easier to review and merge
|
|
613
|
-
- **Respond promptly** - Address review feedback quickly
|
|
614
|
-
- **Be respectful** - Accept constructive criticism
|
|
615
|
-
- **Update branch** - Rebase on latest main before merging
|
|
616
|
-
|
|
617
|
-
---
|
|
618
|
-
|
|
619
|
-
## Project Structure
|
|
620
|
-
|
|
621
|
-
```
|
|
622
|
-
aicgen/
|
|
623
|
-
├── src/
|
|
624
|
-
│ ├── commands/ # CLI command handlers
|
|
625
|
-
│ │ ├── init.ts # Init command
|
|
626
|
-
│ │ ├── stats.ts # Stats command
|
|
627
|
-
│ │ └── ...
|
|
628
|
-
│ ├── config/ # Configuration
|
|
629
|
-
│ │ ├── profiles.ts # Profile definitions
|
|
630
|
-
│ │ └── settings.ts # Default settings
|
|
631
|
-
│ ├── models/ # Domain models
|
|
632
|
-
│ │ ├── config.ts # Config interfaces
|
|
633
|
-
│ │ ├── guideline.ts # Guideline models
|
|
634
|
-
│ │ └── project.ts # Project models
|
|
635
|
-
│ ├── prompts/ # Interactive prompts
|
|
636
|
-
│ │ ├── profile-selection.ts
|
|
637
|
-
│ │ └── guideline-selection.ts
|
|
638
|
-
│ ├── services/ # Business logic
|
|
639
|
-
│ │ ├── ai/ # AI providers
|
|
640
|
-
│ │ │ ├── anthropic.ts
|
|
641
|
-
│ │ │ ├── gemini.ts
|
|
642
|
-
│ │ │ └── openai.ts
|
|
643
|
-
│ │ ├── scanner.ts # Project scanner
|
|
644
|
-
│ │ ├── generator.ts # Config generator
|
|
645
|
-
│ │ └── cache.ts # Cache management
|
|
646
|
-
│ ├── utils/ # Utilities
|
|
647
|
-
│ │ ├── errors.ts # Error classes
|
|
648
|
-
│ │ ├── logger.ts # Logging
|
|
649
|
-
│ │ ├── file-ops.ts # File operations
|
|
650
|
-
│ │ └── validators.ts # Input validation
|
|
651
|
-
│ └── index.ts # CLI entry point
|
|
652
|
-
├── data/ # Guidelines (submodule)
|
|
653
|
-
│ ├── guidelines/ # Markdown guidelines
|
|
654
|
-
│ └── categories.json # Category metadata
|
|
655
|
-
├── scripts/ # Build scripts
|
|
656
|
-
│ ├── embed-data.ts # Embed guidelines in binary
|
|
657
|
-
│ └── build-binary.ts # Build executables
|
|
658
|
-
└── tests/ # Test fixtures
|
|
659
|
-
```
|
|
660
|
-
|
|
661
|
-
### Key Architecture Patterns
|
|
662
|
-
|
|
663
|
-
- **Command Pattern:** Each command is isolated
|
|
664
|
-
- **Strategy Pattern:** Profiles define different strategies
|
|
665
|
-
- **Repository Pattern:** Abstract file operations
|
|
666
|
-
- **Factory Pattern:** Generate configs based on context
|
|
667
|
-
- **Dependency Injection:** Pass dependencies explicitly
|
|
668
|
-
|
|
669
|
-
---
|
|
670
|
-
|
|
671
|
-
## Adding New Guidelines
|
|
672
|
-
|
|
673
|
-
Guidelines are markdown files in the `data/guidelines/` directory (Git submodule).
|
|
674
|
-
|
|
675
|
-
### Structure
|
|
676
|
-
|
|
677
|
-
```markdown
|
|
678
|
-
---
|
|
679
|
-
title: "Guideline Name"
|
|
680
|
-
category: "language|architecture|testing|security|devops|best-practices|..."
|
|
681
|
-
tags: ["tag1", "tag2"]
|
|
682
|
-
language: "typescript|python|go|rust|java|csharp|ruby|javascript|all"
|
|
683
|
-
difficulty: "beginner|intermediate|advanced"
|
|
684
|
-
---
|
|
685
|
-
|
|
686
|
-
# Guideline Title
|
|
687
|
-
|
|
688
|
-
## Overview
|
|
689
|
-
Brief description of what this guideline covers.
|
|
690
|
-
|
|
691
|
-
## Key Principles
|
|
692
|
-
- Principle 1
|
|
693
|
-
- Principle 2
|
|
694
|
-
|
|
695
|
-
## Best Practices
|
|
696
|
-
Detailed best practices with examples.
|
|
697
|
-
|
|
698
|
-
## Common Pitfalls
|
|
699
|
-
Things to avoid.
|
|
700
|
-
|
|
701
|
-
## Examples
|
|
702
|
-
|
|
703
|
-
### Good
|
|
704
|
-
```language
|
|
705
|
-
// Good example
|
|
706
|
-
```
|
|
707
|
-
|
|
708
|
-
### Bad
|
|
709
|
-
```language
|
|
710
|
-
// Bad example
|
|
711
|
-
```
|
|
712
|
-
|
|
713
|
-
## References
|
|
714
|
-
- [Link to documentation]
|
|
715
|
-
```
|
|
716
|
-
|
|
717
|
-
### Adding a New Guideline
|
|
718
|
-
|
|
719
|
-
1. **Navigate to data repository:**
|
|
720
|
-
```bash
|
|
721
|
-
cd data
|
|
722
|
-
```
|
|
723
|
-
|
|
724
|
-
2. **Create guideline file:**
|
|
725
|
-
```bash
|
|
726
|
-
touch guidelines/your-guideline.md
|
|
727
|
-
```
|
|
728
|
-
|
|
729
|
-
3. **Write content** following the structure above
|
|
730
|
-
|
|
731
|
-
4. **Update categories:**
|
|
732
|
-
```bash
|
|
733
|
-
bun run scripts/add-categories.ts
|
|
734
|
-
```
|
|
735
|
-
|
|
736
|
-
5. **Test integration:**
|
|
737
|
-
```bash
|
|
738
|
-
bun run embed
|
|
739
|
-
bun run start init --debug
|
|
740
|
-
```
|
|
741
|
-
|
|
742
|
-
6. **Commit to data repository:**
|
|
743
|
-
```bash
|
|
744
|
-
cd data
|
|
745
|
-
git add guidelines/your-guideline.md
|
|
746
|
-
git commit -m "feat: add [guideline name] guideline"
|
|
747
|
-
git push
|
|
748
|
-
```
|
|
749
|
-
|
|
750
|
-
7. **Update submodule in main repo:**
|
|
751
|
-
```bash
|
|
752
|
-
cd ..
|
|
753
|
-
git add data
|
|
754
|
-
git commit -m "chore: update guidelines submodule"
|
|
755
|
-
```
|
|
756
|
-
|
|
757
|
-
### Guideline Best Practices
|
|
758
|
-
|
|
759
|
-
- **Language-agnostic when possible** - Use `language: all`
|
|
760
|
-
- **Include practical examples** - Show good vs bad code
|
|
761
|
-
- **Link to authoritative sources** - Martin Fowler, official docs
|
|
762
|
-
- **Keep it concise** - 1-2 pages max
|
|
763
|
-
- **Focus on WHY** - Explain reasoning, not just rules
|
|
764
|
-
- **Use clear headers** - Easy to scan
|
|
765
|
-
|
|
766
|
-
---
|
|
767
|
-
|
|
768
|
-
## Building Binaries
|
|
769
|
-
|
|
770
|
-
### Single Platform
|
|
771
|
-
|
|
772
|
-
```bash
|
|
773
|
-
# Current platform
|
|
774
|
-
bun run build:binary
|
|
775
|
-
|
|
776
|
-
# Specific platform
|
|
777
|
-
bun run build:binary:windows # aicgen.exe
|
|
778
|
-
bun run build:binary:linux # aicgen-linux
|
|
779
|
-
bun run build:binary:macos # aicgen-macos
|
|
780
|
-
```
|
|
781
|
-
|
|
782
|
-
### All Platforms
|
|
783
|
-
|
|
784
|
-
```bash
|
|
785
|
-
bun run build:all
|
|
786
|
-
```
|
|
787
|
-
|
|
788
|
-
Binaries are created in `dist/`:
|
|
789
|
-
- `aicgen.exe` (Windows)
|
|
790
|
-
- `aicgen-linux` (Linux x64)
|
|
791
|
-
- `aicgen-macos` (macOS ARM64)
|
|
792
|
-
|
|
793
|
-
### Testing Binaries
|
|
794
|
-
|
|
795
|
-
```bash
|
|
796
|
-
# Windows
|
|
797
|
-
.\dist\aicgen.exe init
|
|
798
|
-
|
|
799
|
-
# Linux/macOS
|
|
800
|
-
./dist/aicgen-linux init
|
|
801
|
-
./dist/aicgen-macos init
|
|
802
|
-
```
|
|
803
|
-
|
|
804
|
-
---
|
|
805
|
-
|
|
806
|
-
## Questions?
|
|
807
|
-
|
|
808
|
-
- **Bug reports:** [GitHub Issues](https://github.com/lpsandaruwan/aicgen/issues)
|
|
809
|
-
- **Feature requests:** [GitHub Issues](https://github.com/lpsandaruwan/aicgen/issues)
|
|
810
|
-
- **Discussions:** [GitHub Discussions](https://github.com/lpsandaruwan/aicgen/discussions)
|
|
811
|
-
- **Email:** [maintainer email]
|
|
812
|
-
|
|
813
|
-
---
|
|
814
|
-
|
|
815
|
-
## License
|
|
816
|
-
|
|
817
|
-
By contributing to aicgen, you agree that your contributions will be licensed under the MIT License.
|
|
818
|
-
|
|
819
|
-
---
|
|
820
|
-
|
|
821
|
-
Thank you for contributing to aicgen! Your efforts help make AI-assisted development more accessible and effective for everyone.
|