@bamptee/aia-code 0.7.0 → 0.8.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/package.json +1 -1
- package/src/commands/init.js +3 -1
- package/src/services/config.js +20 -0
- package/src/services/prompts.js +149 -0
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { createAiaStructure } from '../services/scaffold.js';
|
|
3
3
|
import { writeDefaultConfig } from '../services/config.js';
|
|
4
|
+
import { writeDefaultPrompts } from '../services/prompts.js';
|
|
4
5
|
import { AIA_DIR } from '../constants.js';
|
|
5
6
|
|
|
6
7
|
export function registerInitCommand(program) {
|
|
7
8
|
program
|
|
8
9
|
.command('init')
|
|
9
|
-
.description('Initialize .aia folder structure and
|
|
10
|
+
.description('Initialize .aia folder structure, default config, and prompt templates')
|
|
10
11
|
.action(async () => {
|
|
11
12
|
try {
|
|
12
13
|
await createAiaStructure();
|
|
13
14
|
await writeDefaultConfig();
|
|
15
|
+
await writeDefaultPrompts();
|
|
14
16
|
console.log(chalk.green(`Initialized ${AIA_DIR}/ project structure.`));
|
|
15
17
|
} catch (err) {
|
|
16
18
|
console.error(chalk.red(`Init failed: ${err.message}`));
|
package/src/services/config.js
CHANGED
|
@@ -5,6 +5,13 @@ import { AIA_DIR } from '../constants.js';
|
|
|
5
5
|
|
|
6
6
|
const DEFAULT_CONFIG = {
|
|
7
7
|
models: {
|
|
8
|
+
brief: [
|
|
9
|
+
{ model: 'claude-default', weight: 1 },
|
|
10
|
+
],
|
|
11
|
+
'ba-spec': [
|
|
12
|
+
{ model: 'claude-default', weight: 0.5 },
|
|
13
|
+
{ model: 'openai-default', weight: 0.5 },
|
|
14
|
+
],
|
|
8
15
|
questions: [
|
|
9
16
|
{ model: 'claude-default', weight: 0.5 },
|
|
10
17
|
{ model: 'openai-default', weight: 0.5 },
|
|
@@ -13,6 +20,19 @@ const DEFAULT_CONFIG = {
|
|
|
13
20
|
{ model: 'claude-default', weight: 0.5 },
|
|
14
21
|
{ model: 'openai-default', weight: 0.5 },
|
|
15
22
|
],
|
|
23
|
+
challenge: [
|
|
24
|
+
{ model: 'openai-default', weight: 1 },
|
|
25
|
+
],
|
|
26
|
+
'dev-plan': [
|
|
27
|
+
{ model: 'claude-default', weight: 0.5 },
|
|
28
|
+
{ model: 'openai-default', weight: 0.5 },
|
|
29
|
+
],
|
|
30
|
+
implement: [
|
|
31
|
+
{ model: 'claude-default', weight: 1 },
|
|
32
|
+
],
|
|
33
|
+
review: [
|
|
34
|
+
{ model: 'openai-default', weight: 1 },
|
|
35
|
+
],
|
|
16
36
|
},
|
|
17
37
|
knowledge_default: ['backend'],
|
|
18
38
|
context_files: [
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import { AIA_DIR, FEATURE_STEPS } from '../constants.js';
|
|
4
|
+
|
|
5
|
+
const DEFAULT_PROMPTS = {
|
|
6
|
+
brief: `You are a product manager. Write a product brief for this feature.
|
|
7
|
+
|
|
8
|
+
Include:
|
|
9
|
+
- Problem statement: what pain point does this solve?
|
|
10
|
+
- Target users: who benefits from this feature?
|
|
11
|
+
- User stories: 3-5 key user stories in "As a [user], I want [goal], so that [benefit]" format
|
|
12
|
+
- Success metrics: how do we measure if this feature is successful?
|
|
13
|
+
- Scope: what is in scope and out of scope for v1?
|
|
14
|
+
- Open questions: list any unknowns that need clarification
|
|
15
|
+
|
|
16
|
+
Keep it concise and actionable. Use the project context and knowledge to align with existing architecture.`,
|
|
17
|
+
|
|
18
|
+
'ba-spec': `You are a business analyst. Write a detailed business analysis specification based on the brief.
|
|
19
|
+
|
|
20
|
+
Include:
|
|
21
|
+
- Functional requirements: numbered list of what the system must do
|
|
22
|
+
- Non-functional requirements: performance, security, scalability expectations
|
|
23
|
+
- Business rules: validation rules, edge cases, constraints
|
|
24
|
+
- Data requirements: what data is needed, where it comes from, how it flows
|
|
25
|
+
- User workflows: step-by-step flows for each key user story
|
|
26
|
+
- Acceptance criteria: clear, testable criteria for each requirement
|
|
27
|
+
- Dependencies: external systems, APIs, or teams involved
|
|
28
|
+
|
|
29
|
+
Be specific and measurable. Every requirement should be testable.`,
|
|
30
|
+
|
|
31
|
+
questions: `You are a senior architect reviewing the brief and BA spec.
|
|
32
|
+
|
|
33
|
+
Generate a list of critical questions that must be answered before implementation.
|
|
34
|
+
|
|
35
|
+
Organize by category:
|
|
36
|
+
- Architecture: system design, integration points, data flow
|
|
37
|
+
- Security: authentication, authorization, data protection
|
|
38
|
+
- Performance: expected load, latency requirements, caching strategy
|
|
39
|
+
- UX: user interaction details, error handling, edge cases
|
|
40
|
+
- Data: migration, storage, backup, retention policies
|
|
41
|
+
- Infrastructure: deployment, monitoring, scaling
|
|
42
|
+
- Dependencies: third-party services, API limits, licensing
|
|
43
|
+
|
|
44
|
+
For each question, explain why it matters and suggest a default answer if possible.`,
|
|
45
|
+
|
|
46
|
+
'tech-spec': `You are a senior software architect. Write a detailed technical specification.
|
|
47
|
+
|
|
48
|
+
Include:
|
|
49
|
+
- Architecture overview: how this feature fits into the existing system
|
|
50
|
+
- Data models: schemas, relationships, indexes, migrations
|
|
51
|
+
- API design: endpoints, request/response formats, status codes, authentication
|
|
52
|
+
- Service layer: business logic, validation, error handling
|
|
53
|
+
- Integration points: external APIs, message queues, webhooks
|
|
54
|
+
- Security considerations: input validation, authorization checks, rate limiting
|
|
55
|
+
- Performance considerations: caching strategy, query optimization, pagination
|
|
56
|
+
- Error handling: failure modes, retry strategies, fallback behavior
|
|
57
|
+
- Testing strategy: unit tests, integration tests, key scenarios to cover
|
|
58
|
+
|
|
59
|
+
Use the project's existing patterns from the knowledge files. Be specific with code-level details.`,
|
|
60
|
+
|
|
61
|
+
challenge: `You are a devil's advocate reviewer. Challenge the technical specification.
|
|
62
|
+
|
|
63
|
+
Your job is to find weaknesses, gaps, and risks:
|
|
64
|
+
- Architectural risks: single points of failure, scaling bottlenecks, coupling issues
|
|
65
|
+
- Security vulnerabilities: injection risks, auth bypass, data leaks
|
|
66
|
+
- Missing edge cases: race conditions, concurrent access, data corruption
|
|
67
|
+
- Performance concerns: N+1 queries, missing indexes, memory leaks
|
|
68
|
+
- Operational risks: deployment complexity, rollback strategy, monitoring gaps
|
|
69
|
+
- Over-engineering: unnecessary complexity, premature optimization
|
|
70
|
+
- Under-engineering: missing error handling, insufficient validation
|
|
71
|
+
|
|
72
|
+
For each issue found:
|
|
73
|
+
1. Describe the problem
|
|
74
|
+
2. Explain the potential impact
|
|
75
|
+
3. Suggest a concrete fix
|
|
76
|
+
|
|
77
|
+
Be constructive but thorough. It's better to catch issues now than in production.`,
|
|
78
|
+
|
|
79
|
+
'dev-plan': `You are a tech lead. Create a step-by-step implementation plan.
|
|
80
|
+
|
|
81
|
+
Break the work into ordered tasks that can be implemented sequentially:
|
|
82
|
+
|
|
83
|
+
For each task:
|
|
84
|
+
- Title: short description
|
|
85
|
+
- Files: which files to create or modify
|
|
86
|
+
- Details: what exactly to implement
|
|
87
|
+
- Dependencies: which previous tasks must be completed first
|
|
88
|
+
- Tests: what tests to write for this task
|
|
89
|
+
|
|
90
|
+
Guidelines:
|
|
91
|
+
- Order tasks so each one builds on the previous
|
|
92
|
+
- Start with data models and migrations
|
|
93
|
+
- Then services and business logic
|
|
94
|
+
- Then API routes and controllers
|
|
95
|
+
- Then UI components if applicable
|
|
96
|
+
- End with integration tests
|
|
97
|
+
- Each task should be small enough to review in isolation
|
|
98
|
+
- Include exact file paths based on the project structure`,
|
|
99
|
+
|
|
100
|
+
implement: `You are a senior developer. Implement the feature following the dev-plan exactly.
|
|
101
|
+
|
|
102
|
+
Rules:
|
|
103
|
+
- Follow the project's existing code patterns and conventions
|
|
104
|
+
- Create all files specified in the dev-plan
|
|
105
|
+
- Write clean, production-ready code
|
|
106
|
+
- Include proper error handling and input validation
|
|
107
|
+
- Add JSDoc comments for public functions
|
|
108
|
+
- Follow the naming conventions from the knowledge files
|
|
109
|
+
- Write unit tests for business logic
|
|
110
|
+
- Write integration tests for API endpoints
|
|
111
|
+
|
|
112
|
+
Work through the dev-plan tasks in order. For each task, create or modify the specified files.
|
|
113
|
+
Do not skip any task. If a task depends on a previous one, make sure the dependency is implemented first.`,
|
|
114
|
+
|
|
115
|
+
review: `You are a senior code reviewer. Review the implementation of this feature.
|
|
116
|
+
|
|
117
|
+
Evaluate:
|
|
118
|
+
- Correctness: does the code match the tech spec and dev plan?
|
|
119
|
+
- Code quality: readability, naming, structure, DRY principle
|
|
120
|
+
- Error handling: are all failure modes covered?
|
|
121
|
+
- Security: input validation, SQL injection, XSS, auth checks
|
|
122
|
+
- Performance: N+1 queries, missing indexes, unnecessary computations
|
|
123
|
+
- Tests: coverage, edge cases, meaningful assertions
|
|
124
|
+
- Documentation: are public APIs documented?
|
|
125
|
+
|
|
126
|
+
For each issue found:
|
|
127
|
+
- File and line reference
|
|
128
|
+
- Severity: critical / warning / suggestion
|
|
129
|
+
- Description of the problem
|
|
130
|
+
- Suggested fix with code example
|
|
131
|
+
|
|
132
|
+
End with a summary: ship / ship with fixes / needs rework.`,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export async function writeDefaultPrompts(root = process.cwd()) {
|
|
136
|
+
const promptsDir = path.join(root, AIA_DIR, 'prompts');
|
|
137
|
+
await fs.ensureDir(promptsDir);
|
|
138
|
+
|
|
139
|
+
for (const step of FEATURE_STEPS) {
|
|
140
|
+
const filePath = path.join(promptsDir, `${step}.md`);
|
|
141
|
+
if (await fs.pathExists(filePath)) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const content = DEFAULT_PROMPTS[step] ?? '';
|
|
145
|
+
if (content) {
|
|
146
|
+
await fs.writeFile(filePath, content, 'utf-8');
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|