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
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# AI Agent Instructions
|
|
2
|
+
|
|
3
|
+
## 🚨 MANDATORY SESSION START PROTOCOL
|
|
4
|
+
|
|
5
|
+
**This rule applies to EVERY session, EVERY request - no exceptions.**
|
|
6
|
+
|
|
7
|
+
### Before Making ANY Code Changes:
|
|
8
|
+
|
|
9
|
+
**Step 1: Acknowledge & Read Context**
|
|
10
|
+
```
|
|
11
|
+
"Reading required context files..."
|
|
12
|
+
[Actually call read_file on @CODEBASE_ESSENTIALS.md]
|
|
13
|
+
"Context review complete. Ready to proceed."
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**Step 2: Create Work Plan** (even for "quick fixes")
|
|
17
|
+
```
|
|
18
|
+
[Call manage_todo_list with steps including validation]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Step 3: Proceed with Implementation**
|
|
22
|
+
|
|
23
|
+
### Why This Protocol Exists:
|
|
24
|
+
- Prevents pattern violations
|
|
25
|
+
- Ensures validation happens before claiming work is complete
|
|
26
|
+
- Creates accountability trail for complex changes
|
|
27
|
+
- Catches architectural issues before they become bugs
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## ⚡ QUICK REFERENCE CHECKLIST
|
|
32
|
+
|
|
33
|
+
**Before ANY change (even small fixes):**
|
|
34
|
+
- [ ] Read @CODEBASE_ESSENTIALS.md (patterns, conventions)
|
|
35
|
+
- [ ] Read relevant skill if applicable
|
|
36
|
+
- [ ] Make changes + write/update tests
|
|
37
|
+
- [ ] **VALIDATE** (see validation matrix below)
|
|
38
|
+
- [ ] Update docs if patterns changed
|
|
39
|
+
|
|
40
|
+
**Validation Matrix (ALWAYS run after changes):**
|
|
41
|
+
|
|
42
|
+
| Changed | Commands | Required |
|
|
43
|
+
|---------|----------|----------|
|
|
44
|
+
{{VALIDATION_MATRIX}}
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 📋 SESSION WORKFLOW (Follow This Order!)
|
|
49
|
+
|
|
50
|
+
### 1️⃣ START: Read Context (REQUIRED)
|
|
51
|
+
|
|
52
|
+
**ALWAYS read these files at the start of every conversation:**
|
|
53
|
+
1. **@CODEBASE_ESSENTIALS.md** - Current architecture, patterns, and guardrails (MANDATORY)
|
|
54
|
+
2. **@AGENTS.md** - This file for workflow reminders
|
|
55
|
+
|
|
56
|
+
**When you need history:**
|
|
57
|
+
- **@CODEBASE_CHANGELOG.md** - Session-by-session changes and validation notes
|
|
58
|
+
|
|
59
|
+
### 2️⃣ PLAN: Check Skills Before Coding
|
|
60
|
+
|
|
61
|
+
**Read the relevant skill FIRST based on trigger words:**
|
|
62
|
+
|
|
63
|
+
| Trigger Words | Skill to Read | Why |
|
|
64
|
+
|---------------|---------------|-----|
|
|
65
|
+
{{SKILL_MAPPING}}
|
|
66
|
+
|
|
67
|
+
**⚠️ DON'T start coding until you've read the relevant skill!**
|
|
68
|
+
|
|
69
|
+
**For breaking changes or new features, consider using OpenSpec:**
|
|
70
|
+
- See "Change Management (OpenSpec)" section in CODEBASE_ESSENTIALS.md
|
|
71
|
+
- Create proposal: `openspec create add-feature-name`
|
|
72
|
+
- Get approval before implementing
|
|
73
|
+
|
|
74
|
+
### 3️⃣ IMPLEMENT: Write Code + Tests
|
|
75
|
+
|
|
76
|
+
Follow patterns from CODEBASE_ESSENTIALS.md and the skill you read.
|
|
77
|
+
|
|
78
|
+
### 4️⃣ VALIDATE: Run Tests & Checks (MANDATORY - DO NOT SKIP!)
|
|
79
|
+
|
|
80
|
+
**⚠️ CRITICAL: Run validation EVERY TIME you make a change (even small fixes!)**
|
|
81
|
+
|
|
82
|
+
**Use the Validation Matrix from Quick Reference above.**
|
|
83
|
+
|
|
84
|
+
**🚨 RULE: Never claim work is complete without running validation!**
|
|
85
|
+
**✅ Only say "done" after all relevant tests pass!**
|
|
86
|
+
|
|
87
|
+
### 5️⃣ DOCUMENT: Update Changelog (MANDATORY for significant changes)
|
|
88
|
+
|
|
89
|
+
**When to update** (automatic, don't ask):
|
|
90
|
+
- After architectural changes, new features, performance fixes
|
|
91
|
+
- After bug fixes that reveal design issues
|
|
92
|
+
- When you discover missing/outdated patterns
|
|
93
|
+
|
|
94
|
+
**What to update**:
|
|
95
|
+
```bash
|
|
96
|
+
# Add session entry to CODEBASE_CHANGELOG.md at the TOP
|
|
97
|
+
# Update CODEBASE_ESSENTIALS.md if patterns/invariants changed
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Session entry template**:
|
|
101
|
+
```markdown
|
|
102
|
+
## Session: [Brief Title] (MMM D, YYYY)
|
|
103
|
+
|
|
104
|
+
**Goal**: [One sentence]
|
|
105
|
+
|
|
106
|
+
**Changes**:
|
|
107
|
+
- [file/path](file/path#L123): Description with line numbers
|
|
108
|
+
- [another/file](another/file): What changed
|
|
109
|
+
|
|
110
|
+
**Validation**:
|
|
111
|
+
- ✅ Tests: X passed
|
|
112
|
+
- ✅ Type check: No errors
|
|
113
|
+
|
|
114
|
+
**Key Learning**: [Optional: pattern or gotcha for future reference]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 6️⃣ END: Confirm Completion
|
|
118
|
+
|
|
119
|
+
Only end your turn after completing steps 1-5. Tell the user:
|
|
120
|
+
- What you fixed/built
|
|
121
|
+
- What tests passed
|
|
122
|
+
- That changelog is updated (if applicable)
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## 🚫 When NOT to Update Changelog
|
|
127
|
+
|
|
128
|
+
- Trivial changes (typos, formatting)
|
|
129
|
+
- Work in progress (wait until complete)
|
|
130
|
+
- Exploratory research without implementation
|
|
131
|
+
- Simple bug fixes that don't reveal new patterns
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 📚 Skills Workflow
|
|
136
|
+
|
|
137
|
+
**Skills are located in `.github/skills/` and provide step-by-step workflows.**
|
|
138
|
+
|
|
139
|
+
**Universal skills included:**
|
|
140
|
+
- `dependency-updates` - Safe upgrade procedures
|
|
141
|
+
- `documentation-management` - Changelog archiving
|
|
142
|
+
- `code-refactoring` - Test-driven refactoring
|
|
143
|
+
- `testing-best-practices` - Framework-agnostic testing
|
|
144
|
+
- `skill-creator` - How to create new skills
|
|
145
|
+
|
|
146
|
+
**To use a skill:**
|
|
147
|
+
1. AI detects trigger words
|
|
148
|
+
2. Reads relevant skill file
|
|
149
|
+
3. Follows step-by-step workflow
|
|
150
|
+
4. Applies to current task
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 🎯 General Best Practices
|
|
155
|
+
|
|
156
|
+
1. **Read first, code second** - Always check CODEBASE_ESSENTIALS.md for existing patterns
|
|
157
|
+
2. **Update proactively** - Don't wait for user to ask
|
|
158
|
+
3. **Be concise** - Keep summaries short and factual
|
|
159
|
+
4. **Link files** - Include line numbers when referencing code
|
|
160
|
+
5. **Maintain structure** - Follow existing organization
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## 🔧 Custom Agents Integration
|
|
165
|
+
|
|
166
|
+
**If custom agents are installed:**
|
|
167
|
+
|
|
168
|
+
This project uses Developer + Architect agents for automated code review.
|
|
169
|
+
|
|
170
|
+
**Workflow:**
|
|
171
|
+
1. User requests feature
|
|
172
|
+
2. Developer implements
|
|
173
|
+
3. Developer auto-hands off to Architect
|
|
174
|
+
4. Architect reviews against CODEBASE_ESSENTIALS.md
|
|
175
|
+
5. Architect approves or requests changes
|
|
176
|
+
|
|
177
|
+
**See:** `.github/agents/README.md` for details
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## 📝 Customization Instructions
|
|
182
|
+
|
|
183
|
+
**This is a template file. To customize:**
|
|
184
|
+
|
|
185
|
+
1. **{{VALIDATION_MATRIX}}** - Replace with your actual validation commands
|
|
186
|
+
```markdown
|
|
187
|
+
| Backend | pytest | ✅ MANDATORY |
|
|
188
|
+
| Frontend | npm run type-check | ✅ MANDATORY |
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
2. **{{SKILL_MAPPING}}** - Add your project's skill trigger words
|
|
192
|
+
```markdown
|
|
193
|
+
| "refactor", "clean up" | code-refactoring | Test-driven refactoring |
|
|
194
|
+
| "update deps" | dependency-updates | Safe dependency updates |
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
3. **Add project-specific sections** as needed
|
|
198
|
+
|
|
199
|
+
4. **Remove placeholder text** and instructions
|
|
200
|
+
|
|
201
|
+
5. **Rename to `AGENTS.md`** when complete
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
*This file helps AI agents follow a consistent workflow: Read → Plan → Implement → Validate → Document → Confirm*
|
|
206
|
+
|
|
207
|
+
*Part of the Knowledge System Template. See [README](README.md) for full documentation.*
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Codebase Changelog
|
|
2
|
+
|
|
3
|
+
**Purpose:** Session-by-session record of changes, validations, and learnings.
|
|
4
|
+
|
|
5
|
+
**Usage:** Read recent sessions to understand project evolution. Add new session after completing work.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Session: Initial Knowledge System Setup ({{DATE}})
|
|
10
|
+
|
|
11
|
+
**Goal**: Install knowledge system for {{PROJECT_NAME}}
|
|
12
|
+
|
|
13
|
+
**Changes**:
|
|
14
|
+
- Created CODEBASE_ESSENTIALS.md with project patterns
|
|
15
|
+
- Installed custom agents (Developer + Architect)
|
|
16
|
+
- Added universal skills
|
|
17
|
+
- Initialized this changelog
|
|
18
|
+
|
|
19
|
+
**Validation**:
|
|
20
|
+
- ✅ All template files created
|
|
21
|
+
- ✅ Agent workflow configured
|
|
22
|
+
|
|
23
|
+
**Next Steps**:
|
|
24
|
+
- Complete TODO sections in CODEBASE_ESSENTIALS.md
|
|
25
|
+
- Start using @Developer workflow
|
|
26
|
+
- Document patterns as discovered
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Session Entry Template
|
|
31
|
+
|
|
32
|
+
**Copy this template for new sessions:**
|
|
33
|
+
|
|
34
|
+
```markdown
|
|
35
|
+
## Session: [Brief Title] (MMM D, YYYY)
|
|
36
|
+
|
|
37
|
+
**Goal**: [One sentence describing what you're trying to accomplish]
|
|
38
|
+
|
|
39
|
+
**Changes**:
|
|
40
|
+
- [file/path.ext](file/path.ext#L123): Description with line numbers
|
|
41
|
+
- [another/file.ext](another/file.ext#L45-L67): What changed and why
|
|
42
|
+
|
|
43
|
+
**Validation**:
|
|
44
|
+
- ✅ [Test type]: X passed, Y skipped
|
|
45
|
+
- ✅ [Type check]: No errors
|
|
46
|
+
- ⚠️ [Known issue]: Description and plan
|
|
47
|
+
|
|
48
|
+
**Key Learning**: [Optional: pattern or gotcha for future reference]
|
|
49
|
+
|
|
50
|
+
**Notes**: [Optional: additional context, decisions made, alternatives considered]
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Changelog Guidelines
|
|
56
|
+
|
|
57
|
+
**When to add an entry:**
|
|
58
|
+
- ✅ After completing a feature
|
|
59
|
+
- ✅ After fixing a bug that reveals design issue
|
|
60
|
+
- ✅ After refactoring
|
|
61
|
+
- ✅ After updating patterns in CODEBASE_ESSENTIALS
|
|
62
|
+
- ❌ NOT for trivial typo fixes
|
|
63
|
+
- ❌ NOT for work-in-progress
|
|
64
|
+
|
|
65
|
+
**What to include:**
|
|
66
|
+
- Brief goal statement
|
|
67
|
+
- Files changed with line numbers
|
|
68
|
+
- Validation results (which tests ran, did they pass)
|
|
69
|
+
- Key learnings (patterns discovered, gotchas encountered)
|
|
70
|
+
|
|
71
|
+
**Formatting:**
|
|
72
|
+
- Use markdown links with line numbers: `[file.ts](file.ts#L123)`
|
|
73
|
+
- List validation results with checkmarks: `✅` or warnings: `⚠️`
|
|
74
|
+
- Keep entries concise but informative
|
|
75
|
+
- Add entries at the TOP (most recent first)
|
|
76
|
+
|
|
77
|
+
**Archiving:**
|
|
78
|
+
When this file exceeds 1500 lines, archive old entries:
|
|
79
|
+
```bash
|
|
80
|
+
# Use documentation-management skill
|
|
81
|
+
# Or manually:
|
|
82
|
+
mkdir -p docs/changelog
|
|
83
|
+
mv CODEBASE_CHANGELOG.md docs/changelog/CHANGELOG_YYYY-MM.md
|
|
84
|
+
cp templates/CODEBASE_CHANGELOG.template.md CODEBASE_CHANGELOG.md
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Example Session Entries
|
|
90
|
+
|
|
91
|
+
### Session: Add User Authentication (Jan 18, 2026)
|
|
92
|
+
|
|
93
|
+
**Goal**: Implement JWT authentication with refresh tokens
|
|
94
|
+
|
|
95
|
+
**Changes**:
|
|
96
|
+
- [src/auth/jwt.ts](src/auth/jwt.ts#L1-L45): Created JWT utilities
|
|
97
|
+
- [src/middleware/auth.ts](src/middleware/auth.ts#L12-L34): Added auth middleware
|
|
98
|
+
- [tests/auth.test.ts](tests/auth.test.ts): Added 12 authentication tests
|
|
99
|
+
|
|
100
|
+
**Validation**:
|
|
101
|
+
- ✅ Backend tests: 124 passed
|
|
102
|
+
- ✅ TypeScript: No errors
|
|
103
|
+
- ✅ Integration tests: Auth flow verified
|
|
104
|
+
|
|
105
|
+
**Key Learning**: HttpOnly cookies prevent XSS attacks on tokens. Document this pattern in CODEBASE_ESSENTIALS.md
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
### Session: Refactor API Client (Jan 19, 2026)
|
|
110
|
+
|
|
111
|
+
**Goal**: Eliminate duplicate error handling across API calls
|
|
112
|
+
|
|
113
|
+
**Changes**:
|
|
114
|
+
- [src/api/client.ts](src/api/client.ts#L23-L56): Extracted error handler
|
|
115
|
+
- [src/api/endpoints/](src/api/endpoints/): Removed 15 duplicate try/catch blocks
|
|
116
|
+
- [tests/api.test.ts](tests/api.test.ts#L78-L92): Added error handling tests
|
|
117
|
+
|
|
118
|
+
**Validation**:
|
|
119
|
+
- ✅ All tests: 456 passed
|
|
120
|
+
- ✅ Type check: No errors
|
|
121
|
+
- ✅ Manual testing: Error messages display correctly
|
|
122
|
+
|
|
123
|
+
**Key Learning**: Centralized error handling ensures consistent UX. Pattern added to CODEBASE_ESSENTIALS.md
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
### Session: Fix Image Upload Bug (Jan 20, 2026)
|
|
128
|
+
|
|
129
|
+
**Goal**: Resolve image URL generation inconsistency
|
|
130
|
+
|
|
131
|
+
**Changes**:
|
|
132
|
+
- [src/models/media.ts](src/models/media.ts#L34): Unified URL generation
|
|
133
|
+
- [src/serializers/media.ts](src/serializers/media.ts#L12): Removed duplicate logic
|
|
134
|
+
|
|
135
|
+
**Validation**:
|
|
136
|
+
- ✅ Backend tests: All passed
|
|
137
|
+
- ✅ Manual verification: URLs correct in dev and production
|
|
138
|
+
|
|
139
|
+
**Key Learning**: "Quick fix" would have created third URL pattern. Following process revealed existing inconsistency and led to proper solution.
|
|
140
|
+
|
|
141
|
+
**Notes**: This demonstrates why "never rush" rule matters. Took extra 10 minutes to check patterns, saved hours of debugging later.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
*This template is part of the Knowledge System Template. See [README](README.md) for full documentation.*
|