aiknowsys 0.0.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/AGENTS.template.md +207 -0
- package/CODEBASE_CHANGELOG.template.md +145 -0
- package/CODEBASE_ESSENTIALS.template.md +382 -0
- package/LICENSE +21 -0
- package/README.md +714 -0
- package/bin/cli.js +81 -0
- package/lib/commands/init.js +227 -0
- package/lib/commands/install-agents.js +100 -0
- package/lib/commands/install-skills.js +92 -0
- package/lib/commands/migrate.js +161 -0
- package/lib/commands/scan.js +418 -0
- package/lib/utils.js +93 -0
- package/package.json +53 -0
- package/scripts/migrate-existing.sh +222 -0
- package/scripts/scan-codebase.sh +379 -0
- package/scripts/setup.sh +273 -0
- package/templates/agents/README.md +270 -0
- package/templates/agents/architect.agent.template.md +58 -0
- package/templates/agents/developer.agent.template.md +27 -0
- package/templates/agents/setup-agents.sh +65 -0
- package/templates/skills/code-refactoring/SKILL.md +662 -0
- package/templates/skills/dependency-updates/SKILL.md +561 -0
- package/templates/skills/documentation-management/SKILL.md +744 -0
- package/templates/skills/skill-creator/SKILL.md +252 -0
- package/templates/skills/skill-creator/template.md +89 -0
package/scripts/setup.sh
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# setup.sh - Initialize knowledge system for a project
|
|
3
|
+
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
echo "🎯 Knowledge System Setup"
|
|
7
|
+
echo ""
|
|
8
|
+
echo "This script will set up the knowledge system for your project."
|
|
9
|
+
echo ""
|
|
10
|
+
|
|
11
|
+
# Check if project has existing code
|
|
12
|
+
if [ -d "src" ] || [ -d "backend" ] || [ -f "package.json" ] || [ -f "pyproject.toml" ]; then
|
|
13
|
+
echo "🔍 Existing project detected!"
|
|
14
|
+
echo ""
|
|
15
|
+
echo "Choose setup mode:"
|
|
16
|
+
echo " 1) Scan existing codebase (recommended for existing projects)"
|
|
17
|
+
echo " 2) Manual setup (blank templates)"
|
|
18
|
+
read -p "Choice: " mode
|
|
19
|
+
|
|
20
|
+
if [ "$mode" = "1" ]; then
|
|
21
|
+
if [ -f "./scripts/migrate-existing.sh" ]; then
|
|
22
|
+
exec ./scripts/migrate-existing.sh
|
|
23
|
+
else
|
|
24
|
+
echo "❌ Error: migrate-existing.sh not found"
|
|
25
|
+
exit 1
|
|
26
|
+
fi
|
|
27
|
+
fi
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
echo "📝 Starting fresh project setup..."
|
|
31
|
+
echo ""
|
|
32
|
+
|
|
33
|
+
# Step 1: Detect or ask about tech stack
|
|
34
|
+
echo "=== Step 1: Technology Stack ==="
|
|
35
|
+
echo ""
|
|
36
|
+
echo "What's your primary language?"
|
|
37
|
+
echo "1) TypeScript/JavaScript"
|
|
38
|
+
echo "2) Python"
|
|
39
|
+
echo "3) Rust"
|
|
40
|
+
echo "4) Go"
|
|
41
|
+
echo "5) Other"
|
|
42
|
+
read -p "Choice: " lang_choice
|
|
43
|
+
|
|
44
|
+
case $lang_choice in
|
|
45
|
+
1)
|
|
46
|
+
LANGUAGE="TypeScript"
|
|
47
|
+
PACKAGE_MANAGER="npm"
|
|
48
|
+
;;
|
|
49
|
+
2)
|
|
50
|
+
LANGUAGE="Python"
|
|
51
|
+
PACKAGE_MANAGER="pip"
|
|
52
|
+
;;
|
|
53
|
+
3)
|
|
54
|
+
LANGUAGE="Rust"
|
|
55
|
+
PACKAGE_MANAGER="cargo"
|
|
56
|
+
;;
|
|
57
|
+
4)
|
|
58
|
+
LANGUAGE="Go"
|
|
59
|
+
PACKAGE_MANAGER="go mod"
|
|
60
|
+
;;
|
|
61
|
+
5)
|
|
62
|
+
read -p "Enter language name: " LANGUAGE
|
|
63
|
+
read -p "Enter package manager: " PACKAGE_MANAGER
|
|
64
|
+
;;
|
|
65
|
+
*)
|
|
66
|
+
echo "Invalid choice"
|
|
67
|
+
exit 1
|
|
68
|
+
;;
|
|
69
|
+
esac
|
|
70
|
+
|
|
71
|
+
# Step 2: Framework detection
|
|
72
|
+
echo ""
|
|
73
|
+
echo "=== Step 2: Framework ==="
|
|
74
|
+
echo ""
|
|
75
|
+
|
|
76
|
+
if [ "$lang_choice" = "1" ]; then
|
|
77
|
+
echo "Frontend framework?"
|
|
78
|
+
echo "1) Vue"
|
|
79
|
+
echo "2) React"
|
|
80
|
+
echo "3) Svelte"
|
|
81
|
+
echo "4) Angular"
|
|
82
|
+
echo "5) Vanilla/Other"
|
|
83
|
+
read -p "Choice: " framework_choice
|
|
84
|
+
|
|
85
|
+
case $framework_choice in
|
|
86
|
+
1) FRAMEWORK="Vue 3" ;;
|
|
87
|
+
2) FRAMEWORK="React" ;;
|
|
88
|
+
3) FRAMEWORK="Svelte" ;;
|
|
89
|
+
4) FRAMEWORK="Angular" ;;
|
|
90
|
+
5) read -p "Enter framework: " FRAMEWORK ;;
|
|
91
|
+
esac
|
|
92
|
+
elif [ "$lang_choice" = "2" ]; then
|
|
93
|
+
echo "Backend framework?"
|
|
94
|
+
echo "1) Django"
|
|
95
|
+
echo "2) FastAPI"
|
|
96
|
+
echo "3) Flask"
|
|
97
|
+
echo "4) Other"
|
|
98
|
+
read -p "Choice: " framework_choice
|
|
99
|
+
|
|
100
|
+
case $framework_choice in
|
|
101
|
+
1) FRAMEWORK="Django" ;;
|
|
102
|
+
2) FRAMEWORK="FastAPI" ;;
|
|
103
|
+
3) FRAMEWORK="Flask" ;;
|
|
104
|
+
4) read -p "Enter framework: " FRAMEWORK ;;
|
|
105
|
+
esac
|
|
106
|
+
else
|
|
107
|
+
read -p "Enter framework (or press Enter to skip): " FRAMEWORK
|
|
108
|
+
fi
|
|
109
|
+
|
|
110
|
+
# Step 3: Testing tools
|
|
111
|
+
echo ""
|
|
112
|
+
echo "=== Step 3: Testing ==="
|
|
113
|
+
echo ""
|
|
114
|
+
echo "Test framework?"
|
|
115
|
+
echo "1) Vitest"
|
|
116
|
+
echo "2) Jest"
|
|
117
|
+
echo "3) pytest"
|
|
118
|
+
echo "4) cargo test"
|
|
119
|
+
echo "5) go test"
|
|
120
|
+
echo "6) Other"
|
|
121
|
+
read -p "Choice: " test_choice
|
|
122
|
+
|
|
123
|
+
case $test_choice in
|
|
124
|
+
1)
|
|
125
|
+
TEST_FRAMEWORK="Vitest"
|
|
126
|
+
TEST_COMMAND="npm run test:run"
|
|
127
|
+
TYPE_CHECK_CMD="npm run type-check"
|
|
128
|
+
;;
|
|
129
|
+
2)
|
|
130
|
+
TEST_FRAMEWORK="Jest"
|
|
131
|
+
TEST_COMMAND="npm test"
|
|
132
|
+
TYPE_CHECK_CMD="npm run type-check"
|
|
133
|
+
;;
|
|
134
|
+
3)
|
|
135
|
+
TEST_FRAMEWORK="pytest"
|
|
136
|
+
TEST_COMMAND="pytest"
|
|
137
|
+
TYPE_CHECK_CMD="mypy ."
|
|
138
|
+
;;
|
|
139
|
+
4)
|
|
140
|
+
TEST_FRAMEWORK="cargo test"
|
|
141
|
+
TEST_COMMAND="cargo test"
|
|
142
|
+
TYPE_CHECK_CMD="cargo check"
|
|
143
|
+
;;
|
|
144
|
+
5)
|
|
145
|
+
TEST_FRAMEWORK="go test"
|
|
146
|
+
TEST_COMMAND="go test ./..."
|
|
147
|
+
TYPE_CHECK_CMD="go vet ./..."
|
|
148
|
+
;;
|
|
149
|
+
6)
|
|
150
|
+
read -p "Enter test framework: " TEST_FRAMEWORK
|
|
151
|
+
read -p "Enter test command: " TEST_COMMAND
|
|
152
|
+
read -p "Enter type check command: " TYPE_CHECK_CMD
|
|
153
|
+
;;
|
|
154
|
+
esac
|
|
155
|
+
|
|
156
|
+
# Get project name
|
|
157
|
+
PROJECT_NAME=$(basename "$PWD")
|
|
158
|
+
DATE=$(date +"%B %d, %Y")
|
|
159
|
+
|
|
160
|
+
# Step 4: Generate CODEBASE_ESSENTIALS.md
|
|
161
|
+
echo ""
|
|
162
|
+
echo "=== Step 4: Generating Files ==="
|
|
163
|
+
echo ""
|
|
164
|
+
echo "📝 Creating CODEBASE_ESSENTIALS.md..."
|
|
165
|
+
|
|
166
|
+
if [ ! -f "templates/CODEBASE_ESSENTIALS.template.md" ]; then
|
|
167
|
+
echo "❌ Error: templates/CODEBASE_ESSENTIALS.template.md not found"
|
|
168
|
+
echo " Make sure you're running this from the aiknowsys directory"
|
|
169
|
+
exit 1
|
|
170
|
+
fi
|
|
171
|
+
|
|
172
|
+
# Replace placeholders in CODEBASE_ESSENTIALS
|
|
173
|
+
sed -e "s/{{PROJECT_NAME}}/$PROJECT_NAME/g" \
|
|
174
|
+
-e "s/{{DATE}}/$DATE/g" \
|
|
175
|
+
-e "s/{{LANGUAGE}}/$LANGUAGE/g" \
|
|
176
|
+
-e "s/{{FRAMEWORK}}/$FRAMEWORK/g" \
|
|
177
|
+
-e "s/{{PACKAGE_MANAGER}}/$PACKAGE_MANAGER/g" \
|
|
178
|
+
-e "s/{{TEST_FRAMEWORK}}/$TEST_FRAMEWORK/g" \
|
|
179
|
+
-e "s|{{BACKEND_TEST_CMD}}|$TEST_COMMAND|g" \
|
|
180
|
+
-e "s|{{FRONTEND_TEST_CMD}}|$TEST_COMMAND|g" \
|
|
181
|
+
-e "s|{{TYPE_CHECK_CMD}}|$TYPE_CHECK_CMD|g" \
|
|
182
|
+
templates/CODEBASE_ESSENTIALS.template.md > CODEBASE_ESSENTIALS.md
|
|
183
|
+
|
|
184
|
+
echo "✅ CODEBASE_ESSENTIALS.md created"
|
|
185
|
+
|
|
186
|
+
# Step 5: Generate AGENTS.md
|
|
187
|
+
echo "📝 Creating AGENTS.md..."
|
|
188
|
+
|
|
189
|
+
# Create validation matrix with proper newlines
|
|
190
|
+
VALIDATION_MATRIX="| Tests | \`$TEST_COMMAND\` | ✅ MANDATORY |"
|
|
191
|
+
if [ -n "$TYPE_CHECK_CMD" ]; then
|
|
192
|
+
VALIDATION_MATRIX="$VALIDATION_MATRIX"$'\n'"| Type check | \`$TYPE_CHECK_CMD\` | ✅ MANDATORY |"
|
|
193
|
+
fi
|
|
194
|
+
|
|
195
|
+
# Replace placeholder (use a temporary approach since multi-line sed is tricky)
|
|
196
|
+
cp templates/AGENTS.template.md AGENTS.md
|
|
197
|
+
# For now, just copy template - users can customize validation matrix manually
|
|
198
|
+
|
|
199
|
+
echo "✅ AGENTS.md created (customize validation matrix as needed)"
|
|
200
|
+
|
|
201
|
+
# Step 6: Generate CODEBASE_CHANGELOG.md
|
|
202
|
+
echo "📝 Creating CODEBASE_CHANGELOG.md..."
|
|
203
|
+
|
|
204
|
+
sed -e "s/{{DATE}}/$DATE/g" \
|
|
205
|
+
-e "s/{{PROJECT_NAME}}/$PROJECT_NAME/g" \
|
|
206
|
+
templates/CODEBASE_CHANGELOG.template.md > CODEBASE_CHANGELOG.md
|
|
207
|
+
|
|
208
|
+
echo "✅ CODEBASE_CHANGELOG.md created"
|
|
209
|
+
|
|
210
|
+
# Step 7: Copy LICENSE
|
|
211
|
+
echo "📝 Creating LICENSE..."
|
|
212
|
+
cp LICENSE.template LICENSE
|
|
213
|
+
echo "✅ LICENSE created"
|
|
214
|
+
|
|
215
|
+
# Step 8: Install custom agents
|
|
216
|
+
echo ""
|
|
217
|
+
echo "=== Step 5: Installing Custom Agents ==="
|
|
218
|
+
echo ""
|
|
219
|
+
|
|
220
|
+
if [ -f "templates/agents/setup-agents.sh" ]; then
|
|
221
|
+
bash templates/agents/setup-agents.sh CODEBASE_ESSENTIALS.md
|
|
222
|
+
else
|
|
223
|
+
echo "⚠️ Custom agents setup script not found, skipping..."
|
|
224
|
+
echo " You can install agents later with: templates/agents/setup-agents.sh"
|
|
225
|
+
fi
|
|
226
|
+
|
|
227
|
+
# Step 9: Copy universal skills
|
|
228
|
+
echo ""
|
|
229
|
+
echo "=== Step 6: Installing Skills ==="
|
|
230
|
+
echo ""
|
|
231
|
+
|
|
232
|
+
mkdir -p .github/skills
|
|
233
|
+
|
|
234
|
+
# Copy skill template
|
|
235
|
+
if [ -d ".github/skills/_skill-template" ]; then
|
|
236
|
+
echo "✅ Skill template already present"
|
|
237
|
+
else
|
|
238
|
+
cp -r templates/../.github/skills/_skill-template .github/skills/ 2>/dev/null || echo "⚠️ Skill template not found"
|
|
239
|
+
fi
|
|
240
|
+
|
|
241
|
+
# Copy universal skills if they exist
|
|
242
|
+
for skill in dependency-updates documentation-management code-refactoring testing-best-practices skill-creator; do
|
|
243
|
+
if [ -d "templates/skills/$skill" ] || [ -d ".github/skills/$skill" ]; then
|
|
244
|
+
cp -r templates/skills/$skill .github/skills/ 2>/dev/null || cp -r .github/skills/$skill .github/skills/ 2>/dev/null || true
|
|
245
|
+
echo "✅ $skill skill installed"
|
|
246
|
+
fi
|
|
247
|
+
done
|
|
248
|
+
|
|
249
|
+
# Step 10: Summary
|
|
250
|
+
echo ""
|
|
251
|
+
echo "🎉 Knowledge System Installation Complete!"
|
|
252
|
+
echo ""
|
|
253
|
+
echo "📁 Files created:"
|
|
254
|
+
echo " - CODEBASE_ESSENTIALS.md (customize TODO sections)"
|
|
255
|
+
echo " - AGENTS.md (AI workflow instructions)"
|
|
256
|
+
echo " - CODEBASE_CHANGELOG.md (session history)"
|
|
257
|
+
echo " - LICENSE (MIT)"
|
|
258
|
+
echo " - .github/agents/ (Developer + Architect)"
|
|
259
|
+
echo " - .github/skills/ (Universal skills)"
|
|
260
|
+
echo ""
|
|
261
|
+
echo "📋 Next steps:"
|
|
262
|
+
echo " 1. Review CODEBASE_ESSENTIALS.md"
|
|
263
|
+
echo " 2. Fill in TODO sections (patterns, invariants, gotchas)"
|
|
264
|
+
echo " 3. Customize validation commands if needed"
|
|
265
|
+
echo " 4. Remove placeholder sections you don't need"
|
|
266
|
+
echo " 5. Start using: @Developer <your request>"
|
|
267
|
+
echo ""
|
|
268
|
+
echo "📖 Documentation:"
|
|
269
|
+
echo " - How agents work: .github/agents/README.md"
|
|
270
|
+
echo " - How to create skills: .github/skills/_skill-template/README.md"
|
|
271
|
+
echo " - Main README: README.md"
|
|
272
|
+
echo ""
|
|
273
|
+
echo "💡 Tip: Keep CODEBASE_ESSENTIALS.md updated as patterns evolve!"
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# Custom Agents - Developer & Architect Workflow
|
|
2
|
+
|
|
3
|
+
**Purpose:** Automated quality gate that enforces CODEBASE_ESSENTIALS.md patterns during development.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## How It Works
|
|
8
|
+
|
|
9
|
+
### The Agent Pair
|
|
10
|
+
|
|
11
|
+
1. **Developer Agent** (`developer.agent.md`)
|
|
12
|
+
- Primary implementer of features
|
|
13
|
+
- Writes code following documented patterns
|
|
14
|
+
- Automatically hands off to Architect for review
|
|
15
|
+
- Refactors based on feedback
|
|
16
|
+
|
|
17
|
+
2. **Architect Agent** (`architect.agent.md`)
|
|
18
|
+
- Reviews code against CODEBASE_ESSENTIALS.md
|
|
19
|
+
- Enforces KISS, DRY, SOLID, YAGNI principles
|
|
20
|
+
- Approves or requests changes
|
|
21
|
+
- Provides specific, actionable feedback
|
|
22
|
+
|
|
23
|
+
### Workflow
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
┌─────────────┐
|
|
27
|
+
│ User │
|
|
28
|
+
│ "Add X" │
|
|
29
|
+
└──────┬──────┘
|
|
30
|
+
│
|
|
31
|
+
v
|
|
32
|
+
┌─────────────────┐
|
|
33
|
+
│ @Developer │ 1. Implements feature
|
|
34
|
+
│ Implements │ 2. Writes tests
|
|
35
|
+
└────────┬────────┘ 3. Auto-handoff ──┐
|
|
36
|
+
│ │
|
|
37
|
+
│ v
|
|
38
|
+
│ ┌────────────────────┐
|
|
39
|
+
│ │ @SeniorArchitect │
|
|
40
|
+
│ │ Reads ESSENTIALS │
|
|
41
|
+
│ │ Reviews code │
|
|
42
|
+
│ └────────┬───────────┘
|
|
43
|
+
│ │
|
|
44
|
+
│ ┌──────────┴──────────┐
|
|
45
|
+
│ │ │
|
|
46
|
+
v v v
|
|
47
|
+
┌────────┐ ┌──────────┐ ┌──────────────┐
|
|
48
|
+
│ User │◄─────┤ LGTM ✅ │ │ Issues Found │
|
|
49
|
+
└────────┘ └──────────┘ └──────┬───────┘
|
|
50
|
+
│
|
|
51
|
+
v
|
|
52
|
+
┌───────────────┐
|
|
53
|
+
│ @Developer │
|
|
54
|
+
│ Refactors │
|
|
55
|
+
└───────┬───────┘
|
|
56
|
+
│
|
|
57
|
+
└──────► (Loop back to Architect)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
### In VS Code with GitHub Copilot Agent Mode
|
|
65
|
+
|
|
66
|
+
**Start with Developer:**
|
|
67
|
+
```
|
|
68
|
+
@Developer add a new feature to calculate user retention rate
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Developer will:**
|
|
72
|
+
1. Implement the code
|
|
73
|
+
2. Write tests
|
|
74
|
+
3. Automatically call: `@SeniorArchitect please review changes in [file] against CODEBASE_ESSENTIALS.md`
|
|
75
|
+
|
|
76
|
+
**You don't need to manually call Architect** - the handoff is automatic!
|
|
77
|
+
|
|
78
|
+
### Direct Review Request
|
|
79
|
+
|
|
80
|
+
If you've made changes manually and want a review:
|
|
81
|
+
```
|
|
82
|
+
@SeniorArchitect review the changes I made to src/utils/metrics.ts
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## What Architect Checks
|
|
88
|
+
|
|
89
|
+
### ✅ KISS (Keep It Simple)
|
|
90
|
+
- No overly complex nested logic
|
|
91
|
+
- Readable function/variable names
|
|
92
|
+
- Clear control flow
|
|
93
|
+
|
|
94
|
+
### ✅ DRY (Don't Repeat Yourself)
|
|
95
|
+
- No duplicated logic
|
|
96
|
+
- Proper abstraction into functions/classes
|
|
97
|
+
- Reuse existing utilities
|
|
98
|
+
|
|
99
|
+
### ✅ SOLID Principles
|
|
100
|
+
- Single Responsibility (functions do one thing)
|
|
101
|
+
- Dependency Inversion (inject dependencies)
|
|
102
|
+
- Interface segregation
|
|
103
|
+
|
|
104
|
+
### ✅ YAGNI (You Ain't Gonna Need It)
|
|
105
|
+
- No speculative "future-proofing"
|
|
106
|
+
- Features are actually needed now
|
|
107
|
+
- No premature optimization
|
|
108
|
+
|
|
109
|
+
### ✅ CODEBASE_ESSENTIALS.md Compliance
|
|
110
|
+
- Follows documented patterns
|
|
111
|
+
- Uses approved libraries/tools
|
|
112
|
+
- Respects project constraints
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Configuration
|
|
117
|
+
|
|
118
|
+
### Customizing Review Criteria
|
|
119
|
+
|
|
120
|
+
Edit `.github/agents/architect.agent.md`:
|
|
121
|
+
|
|
122
|
+
```markdown
|
|
123
|
+
### Project-Specific Rules:
|
|
124
|
+
- All API calls must use the generated OpenAPI client
|
|
125
|
+
- Components must use TypeScript strict mode
|
|
126
|
+
- Error handling must use try/catch with logger
|
|
127
|
+
- Database queries must use Django ORM (no raw SQL)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Customizing Developer Behavior
|
|
131
|
+
|
|
132
|
+
Edit `.github/agents/developer.agent.md`:
|
|
133
|
+
|
|
134
|
+
```markdown
|
|
135
|
+
### Your Coding Standards:
|
|
136
|
+
- Write tests first (TDD)
|
|
137
|
+
- Use async/await (no .then() chains)
|
|
138
|
+
- Log errors with structured logging
|
|
139
|
+
- Document complex logic with comments
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Benefits
|
|
145
|
+
|
|
146
|
+
| Traditional Workflow | With Custom Agents |
|
|
147
|
+
|---------------------|-------------------|
|
|
148
|
+
| Write code → Submit PR → Wait for human review → Fix issues → Resubmit | Write code → Instant automated review → Fix issues → Auto re-review |
|
|
149
|
+
| Inconsistent feedback across reviewers | Consistent enforcement of standards |
|
|
150
|
+
| Human reviewers check style + logic + architecture | Agents check style/patterns, humans focus on architecture |
|
|
151
|
+
| Feedback loop: hours to days | Feedback loop: seconds |
|
|
152
|
+
| Patterns drift over time | Patterns enforced on every change |
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Examples
|
|
157
|
+
|
|
158
|
+
### Example 1: Clean Code Approval
|
|
159
|
+
|
|
160
|
+
**User:** `@Developer add a function to format currency`
|
|
161
|
+
|
|
162
|
+
**Developer implements:**
|
|
163
|
+
```typescript
|
|
164
|
+
export function formatCurrency(amount: number): string {
|
|
165
|
+
return new Intl.NumberFormat('en-US', {
|
|
166
|
+
style: 'currency',
|
|
167
|
+
currency: 'USD'
|
|
168
|
+
}).format(amount);
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Developer handoff:** `@SeniorArchitect please review formatCurrency in utils/format.ts`
|
|
173
|
+
|
|
174
|
+
**Architect response:** `LGTM - Architect Approved ✅`
|
|
175
|
+
- Uses standard library (Intl.NumberFormat)
|
|
176
|
+
- Single responsibility
|
|
177
|
+
- No duplication
|
|
178
|
+
|
|
179
|
+
### Example 2: Issues Found
|
|
180
|
+
|
|
181
|
+
**User:** `@Developer add validation for email addresses`
|
|
182
|
+
|
|
183
|
+
**Developer implements:**
|
|
184
|
+
```typescript
|
|
185
|
+
function validateEmail(email: string): boolean {
|
|
186
|
+
// Complex regex copied from Stack Overflow
|
|
187
|
+
return /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(email);
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Architect response:**
|
|
192
|
+
```
|
|
193
|
+
❌ Review Failed - Issues Found:
|
|
194
|
+
|
|
195
|
+
1. **DRY Violation** in [src/utils/validation.ts](src/utils/validation.ts#L12)
|
|
196
|
+
- Email validation already exists in src/composables/useAuth.ts
|
|
197
|
+
- Refactor: Extract shared validation to src/utils/validators.ts
|
|
198
|
+
- Rationale: Duplicate regex means inconsistent validation rules
|
|
199
|
+
|
|
200
|
+
2. **Documentation** in [src/utils/validation.ts](src/utils/validation.ts#L11)
|
|
201
|
+
- Complex regex needs explanation
|
|
202
|
+
- Add comment: What email formats are accepted/rejected
|
|
203
|
+
- Rationale: Future maintainers need to understand edge cases
|
|
204
|
+
|
|
205
|
+
Please address these issues and resubmit.
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Developer refactors and re-submits → Architect approves ✅**
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Troubleshooting
|
|
213
|
+
|
|
214
|
+
### Agent doesn't auto-handoff
|
|
215
|
+
|
|
216
|
+
**Check:** Is `send: true` in the handoff configuration?
|
|
217
|
+
```yaml
|
|
218
|
+
handoffs:
|
|
219
|
+
- label: "Send to Architect"
|
|
220
|
+
agent: SeniorArchitect
|
|
221
|
+
prompt: "Please review..."
|
|
222
|
+
send: true # ← Must be true for auto-handoff
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Architect can't read CODEBASE_ESSENTIALS.md
|
|
226
|
+
|
|
227
|
+
**Check:** Does Architect have `search` tool enabled?
|
|
228
|
+
```yaml
|
|
229
|
+
tools: [search, search/changes] # ← Required
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Review is too strict / too lenient
|
|
233
|
+
|
|
234
|
+
**Customize:** Edit architect.agent.md review checklist and criteria.
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Best Practices
|
|
239
|
+
|
|
240
|
+
1. **Let the workflow happen** - Don't interrupt the auto-handoff
|
|
241
|
+
2. **Read Architect feedback carefully** - It references specific sections of ESSENTIALS
|
|
242
|
+
3. **Update ESSENTIALS when patterns change** - Architect enforces what's documented
|
|
243
|
+
4. **Use Developer for implementation** - Use direct chat for questions/exploration
|
|
244
|
+
5. **Iterate with feedback** - Refactor and resubmit until approved
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Integration with Knowledge System
|
|
249
|
+
|
|
250
|
+
The agents are part of the broader knowledge system:
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
CODEBASE_ESSENTIALS.md ←─┐
|
|
254
|
+
│
|
|
255
|
+
AGENTS.md (workflow) │
|
|
256
|
+
│ Architect reads
|
|
257
|
+
Skills (how-to guides) │ and enforces
|
|
258
|
+
│
|
|
259
|
+
Custom Agents ───────────┘
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Flow:**
|
|
263
|
+
1. Patterns documented in ESSENTIALS
|
|
264
|
+
2. Workflow enforced by AGENTS.md
|
|
265
|
+
3. Detailed steps in Skills
|
|
266
|
+
4. **Automated enforcement by Custom Agents**
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
*This creates a self-reinforcing system where good patterns are documented, taught, and automatically enforced.*
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
```chatagent
|
|
2
|
+
---
|
|
3
|
+
name: SeniorArchitect
|
|
4
|
+
description: Senior Architect focusing on KISS, DRY, SOLID, YAGNI, and Project Essentials.
|
|
5
|
+
tools: [search, search/changes]
|
|
6
|
+
handoffs:
|
|
7
|
+
- label: "Fix Issues (Developer)"
|
|
8
|
+
agent: Developer
|
|
9
|
+
prompt: "The Senior Architect has identified issues. Please refactor the code to address these specific points: "
|
|
10
|
+
send: false
|
|
11
|
+
---
|
|
12
|
+
You are a world-class Senior Software Architect. Your goal is to review code changes and ensure they meet the highest engineering standards.
|
|
13
|
+
|
|
14
|
+
### Your Core Principles:
|
|
15
|
+
- **KISS (Keep It Simple, Stupid):** Reject unnecessary complexity or "clever" code that is hard to read.
|
|
16
|
+
- **DRY (Don't Repeat Yourself):** Identify logic that should be abstracted into reusable functions/classes.
|
|
17
|
+
- **SOLID:** Ensure Single Responsibility and proper Dependency Inversion.
|
|
18
|
+
- **YAGNI (You Ain't Gonna Need It):** Flag code that implements features "just in case" for the future.
|
|
19
|
+
|
|
20
|
+
### Strict Project Guidelines:
|
|
21
|
+
You MUST verify that all changes follow the rules defined in `{{ESSENTIALS_FILE}}`.
|
|
22
|
+
1. Use your `search` tool to read `{{ESSENTIALS_FILE}}` before starting the review.
|
|
23
|
+
2. If any rule in that file is violated, the review is a **FAIL**.
|
|
24
|
+
|
|
25
|
+
### Review Checklist:
|
|
26
|
+
- [ ] Code follows documented patterns in {{ESSENTIALS_FILE}}
|
|
27
|
+
- [ ] No duplication (DRY principle)
|
|
28
|
+
- [ ] Functions have single responsibility (SOLID)
|
|
29
|
+
- [ ] No unnecessary complexity (KISS)
|
|
30
|
+
- [ ] No speculative features (YAGNI)
|
|
31
|
+
- [ ] Tests written for new functionality
|
|
32
|
+
- [ ] Type safety maintained (if applicable)
|
|
33
|
+
- [ ] Error handling follows project patterns
|
|
34
|
+
|
|
35
|
+
### Review Output Format:
|
|
36
|
+
- If perfect: Respond with "LGTM - Architect Approved ✅".
|
|
37
|
+
- If issues found: Provide a bulleted list with:
|
|
38
|
+
- Specific violation (reference ESSENTIALS section)
|
|
39
|
+
- File and line number
|
|
40
|
+
- Suggested refactoring
|
|
41
|
+
- Rationale (why it matters)
|
|
42
|
+
|
|
43
|
+
### Example Review Output:
|
|
44
|
+
```
|
|
45
|
+
❌ Review Failed - Issues Found:
|
|
46
|
+
|
|
47
|
+
1. **DRY Violation** in [src/utils/validator.ts](src/utils/validator.ts#L45-L52)
|
|
48
|
+
- Email validation logic duplicated from auth module
|
|
49
|
+
- Refactor: Extract to shared `validateEmail()` in utils
|
|
50
|
+
- Rationale: Duplicate code means double maintenance burden
|
|
51
|
+
|
|
52
|
+
2. **KISS Violation** in [src/services/api.ts](src/services/api.ts#L103)
|
|
53
|
+
- Overly complex nested ternary for status handling
|
|
54
|
+
- Refactor: Use early returns or switch statement
|
|
55
|
+
- Rationale: Nested ternaries harm readability
|
|
56
|
+
|
|
57
|
+
Please address these issues and resubmit for review.
|
|
58
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
```chatagent
|
|
2
|
+
---
|
|
3
|
+
name: Developer
|
|
4
|
+
description: Writes code and hands off to the Senior Architect.
|
|
5
|
+
handoffs:
|
|
6
|
+
- label: "Send to Architect"
|
|
7
|
+
agent: SeniorArchitect
|
|
8
|
+
prompt: "Please review the code I just wrote against {{ESSENTIALS_FILE}}."
|
|
9
|
+
send: true
|
|
10
|
+
---
|
|
11
|
+
You are the primary Developer.
|
|
12
|
+
|
|
13
|
+
### YOUR WORKFLOW:
|
|
14
|
+
1. Implement the requested feature following patterns in {{ESSENTIALS_FILE}}.
|
|
15
|
+
2. IMPORTANT: Once you have finished writing the code, you MUST automatically end your response by calling the SeniorArchitect.
|
|
16
|
+
3. Use the following syntax: "@SeniorArchitect please review the changes in [file name] against {{ESSENTIALS_FILE}}."
|
|
17
|
+
|
|
18
|
+
### Rules:
|
|
19
|
+
- Do not ask the user if they want a review. Just do it.
|
|
20
|
+
- Follow all documented patterns in {{ESSENTIALS_FILE}}
|
|
21
|
+
- Write tests alongside implementation
|
|
22
|
+
- Run validation commands before handoff (if applicable)
|
|
23
|
+
- Include what you changed and why in your handoff message
|
|
24
|
+
|
|
25
|
+
### Project-Specific Guidelines:
|
|
26
|
+
{{PROJECT_GUIDELINES}}
|
|
27
|
+
```
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# setup-agents.sh - Install custom agents (part of knowledge-system setup)
|
|
3
|
+
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
echo "🤖 Installing Custom Agents (Developer + Architect Workflow)"
|
|
7
|
+
echo ""
|
|
8
|
+
|
|
9
|
+
# Detect or use provided ESSENTIALS file name
|
|
10
|
+
ESSENTIALS_FILE="${1:-CODEBASE_ESSENTIALS.md}"
|
|
11
|
+
|
|
12
|
+
# Create agents directory
|
|
13
|
+
mkdir -p .github/agents
|
|
14
|
+
|
|
15
|
+
# Copy templates
|
|
16
|
+
if [ ! -f "templates/agents/developer.agent.template.md" ]; then
|
|
17
|
+
echo "❌ Error: templates/agents/ not found"
|
|
18
|
+
echo " Run this script from the aiknowsys directory"
|
|
19
|
+
exit 1
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
echo "📋 Copying agent templates..."
|
|
23
|
+
cp templates/agents/developer.agent.template.md .github/agents/developer.agent.md
|
|
24
|
+
cp templates/agents/architect.agent.template.md .github/agents/architect.agent.md
|
|
25
|
+
|
|
26
|
+
# Replace template variables
|
|
27
|
+
echo "🔧 Configuring agents for your project..."
|
|
28
|
+
sed -i "s|{{ESSENTIALS_FILE}}|$ESSENTIALS_FILE|g" .github/agents/developer.agent.md
|
|
29
|
+
sed -i "s|{{ESSENTIALS_FILE}}|$ESSENTIALS_FILE|g" .github/agents/architect.agent.md
|
|
30
|
+
|
|
31
|
+
# Prompt for project-specific guidelines
|
|
32
|
+
echo ""
|
|
33
|
+
echo "Do you want to add project-specific guidelines for the Developer agent?"
|
|
34
|
+
echo "(These will be added to the agent's instructions)"
|
|
35
|
+
read -p "Enter guidelines or press Enter to skip: " project_guidelines
|
|
36
|
+
|
|
37
|
+
if [ -n "$project_guidelines" ]; then
|
|
38
|
+
sed -i "s|{{PROJECT_GUIDELINES}}|$project_guidelines|g" .github/agents/developer.agent.md
|
|
39
|
+
else
|
|
40
|
+
sed -i "s|{{PROJECT_GUIDELINES}}|None specified|g" .github/agents/developer.agent.md
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
# Copy README
|
|
44
|
+
echo "📚 Installing agent documentation..."
|
|
45
|
+
cp templates/agents/README.md .github/agents/README.md
|
|
46
|
+
|
|
47
|
+
# Verify installation
|
|
48
|
+
echo ""
|
|
49
|
+
echo "✅ Custom agents installed successfully!"
|
|
50
|
+
echo ""
|
|
51
|
+
echo "📍 Location: .github/agents/"
|
|
52
|
+
echo " - developer.agent.md (Primary implementer)"
|
|
53
|
+
echo " - architect.agent.md (Code reviewer)"
|
|
54
|
+
echo " - README.md (Usage guide)"
|
|
55
|
+
echo ""
|
|
56
|
+
echo "🚀 Usage in VS Code:"
|
|
57
|
+
echo " @Developer <your request> → Implements and auto-reviews"
|
|
58
|
+
echo " @SeniorArchitect <file> → Direct review request"
|
|
59
|
+
echo ""
|
|
60
|
+
echo "📖 Next steps:"
|
|
61
|
+
echo " 1. Review .github/agents/README.md for detailed workflow"
|
|
62
|
+
echo " 2. Customize review criteria in architect.agent.md if needed"
|
|
63
|
+
echo " 3. Ensure $ESSENTIALS_FILE exists and documents your patterns"
|
|
64
|
+
echo ""
|
|
65
|
+
echo "💡 Tip: The agents will auto-handoff for review. Just use @Developer!"
|