@vuau/agent-memory 0.1.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/LICENSE +21 -0
- package/README.md +156 -0
- package/README.vi.md +145 -0
- package/bin/cli.ts +111 -0
- package/docs/ARCHITECTURE.md +285 -0
- package/docs/ARCHITECTURE.vi.md +285 -0
- package/docs/RESEARCH.md +216 -0
- package/docs/RESEARCH.vi.md +216 -0
- package/index.ts +11 -0
- package/package.json +45 -0
- package/src/core/doctor.ts +86 -0
- package/src/core/index.ts +5 -0
- package/src/core/memory.ts +86 -0
- package/src/core/scaffold.ts +124 -0
- package/src/core/tasks.ts +77 -0
- package/src/core/types.ts +30 -0
- package/src/opencode/plugin.ts +97 -0
- package/templates/AGENTS.md +44 -0
- package/templates/MEMORY.md +17 -0
- package/templates/TASKS.md +14 -0
- package/templates/copilot-instructions.md +30 -0
- package/templates/spec/.gitkeep +0 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# Architecture: Recommended 4-Layer Structure for AI Memory
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This document proposes a generalizable architecture for AI memory across codebases of any size. It addresses the scalability, maintainability, and IDE compatibility issues discovered during research.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Layer 1: Router (Project Root AGENTS.md)
|
|
10
|
+
|
|
11
|
+
**Purpose**: Single point of truth for AI agents entering the project.
|
|
12
|
+
|
|
13
|
+
**Constraints**:
|
|
14
|
+
- Max 150 lines
|
|
15
|
+
- Purely routing/reference, not documentation
|
|
16
|
+
- No project-specific decisions (only pointers to layers below)
|
|
17
|
+
|
|
18
|
+
**Contains**:
|
|
19
|
+
- Project setup commands (`npm install`, `make dev`, etc.)
|
|
20
|
+
- Critical code style rules (type safety, lint settings)
|
|
21
|
+
- Documentation map — which file to read for which task type
|
|
22
|
+
- Memory protocol — how agents should write MEMORY.md
|
|
23
|
+
|
|
24
|
+
**Example**:
|
|
25
|
+
```markdown
|
|
26
|
+
# My Project - AGENTS
|
|
27
|
+
|
|
28
|
+
## Commands
|
|
29
|
+
- `npm dev` — start dev server
|
|
30
|
+
- `npm test` — run tests
|
|
31
|
+
|
|
32
|
+
## Key Rules
|
|
33
|
+
- TypeScript strict: true required
|
|
34
|
+
- All components must have JSDoc comments
|
|
35
|
+
|
|
36
|
+
## Documentation Map
|
|
37
|
+
| Task | Read |
|
|
38
|
+
|------|------|
|
|
39
|
+
| Architecture decisions | `.agents/MEMORY.md` |
|
|
40
|
+
| Component patterns | `.agents/spec/components.md` |
|
|
41
|
+
| Production deployment | `.agents/spec/deployment.md` |
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Why 150 lines max**:
|
|
45
|
+
- Fits in single screen → agents read entire context
|
|
46
|
+
- Encourages ruthless curation — only critical rules
|
|
47
|
+
- Prevents AGENTS.md from becoming a dumping ground
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Layer 2: Long-term Memory (.agents/MEMORY.md)
|
|
52
|
+
|
|
53
|
+
**Purpose**: Curated decisions and patterns agents should know before implementing.
|
|
54
|
+
|
|
55
|
+
**Format**:
|
|
56
|
+
```markdown
|
|
57
|
+
## Category Name
|
|
58
|
+
→ Full details: `.agents/spec/category.md`
|
|
59
|
+
|
|
60
|
+
- YYYY-MM-DD: <1-line decision or pattern>
|
|
61
|
+
- YYYY-MM-DD: <another decision>
|
|
62
|
+
|
|
63
|
+
## Another Category
|
|
64
|
+
→ Pointer to spec file
|
|
65
|
+
|
|
66
|
+
- YYYY-MM-DD: <decision>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Constraints**:
|
|
70
|
+
- 1 line per entry (decision is small enough to fit)
|
|
71
|
+
- Category headers point to spec files
|
|
72
|
+
- Max 150-200 lines for entire file
|
|
73
|
+
- Append-only — never delete old entries
|
|
74
|
+
|
|
75
|
+
**Design rationale**:
|
|
76
|
+
- Agents can scan 150 lines quickly (~200 tokens)
|
|
77
|
+
- Follow pointers only when needed (on-demand spec files)
|
|
78
|
+
- Category headers = progressive disclosure
|
|
79
|
+
- 1-line format forces curation — only truly important decisions survive
|
|
80
|
+
|
|
81
|
+
**When to add entries**:
|
|
82
|
+
- User explicitly approves a decision ("ok", "yes", "apply")
|
|
83
|
+
- Agent understands decision is reusable across sessions
|
|
84
|
+
- Not: every thought, every experiment, every debug session
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Layer 3: Working Memory (.agents/TASKS.md)
|
|
89
|
+
|
|
90
|
+
**Purpose**: Enable session continuity — agents resume where they left off.
|
|
91
|
+
|
|
92
|
+
**Format**:
|
|
93
|
+
```markdown
|
|
94
|
+
## In Progress
|
|
95
|
+
- Task 1 description — what agent is actively doing
|
|
96
|
+
- Task 2 description
|
|
97
|
+
|
|
98
|
+
## Up Next
|
|
99
|
+
- Next task to work on
|
|
100
|
+
- Task after that
|
|
101
|
+
|
|
102
|
+
## Completed
|
|
103
|
+
- What was finished in recent sessions
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Constraints**:
|
|
107
|
+
- 3 simple sections: In Progress, Up Next, Completed
|
|
108
|
+
- Free-form text per task (1-3 lines each)
|
|
109
|
+
- Updated at session start and end
|
|
110
|
+
|
|
111
|
+
**Agent behavior**:
|
|
112
|
+
- Read at session start → understand context, resume work
|
|
113
|
+
- Update before session end → what's done, what's next
|
|
114
|
+
- Plugin reminds if tasks exist but not updated
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Layer 4: Spec Files (.agents/spec/*.md)
|
|
119
|
+
|
|
120
|
+
**Purpose**: Detailed documentation agents read on-demand, referenced by MEMORY.md.
|
|
121
|
+
|
|
122
|
+
**Naming**:
|
|
123
|
+
- `architecture.md` — codebase structure, file organization
|
|
124
|
+
- `components.md` — reusable component patterns
|
|
125
|
+
- `deployment.md` — release process, environments
|
|
126
|
+
- `domain.md` — business logic, core concepts
|
|
127
|
+
- `{feature}.md` — any major feature with complex patterns
|
|
128
|
+
|
|
129
|
+
**Contents**:
|
|
130
|
+
- Code examples showing the pattern
|
|
131
|
+
- When to use / when not to use
|
|
132
|
+
- Common pitfalls
|
|
133
|
+
- Links to related files in codebase
|
|
134
|
+
|
|
135
|
+
**Design**:
|
|
136
|
+
- Agents read from MEMORY.md pointers, not all specs
|
|
137
|
+
- Specs can be large (1000+ lines) → loaded on-demand
|
|
138
|
+
- Better for screenshots, diagrams, detailed explanations
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Scalability: Handling Different Project Sizes
|
|
143
|
+
|
|
144
|
+
### Small Project (1-2 agents, 1 dev)
|
|
145
|
+
- AGENTS.md: ~50 lines
|
|
146
|
+
- MEMORY.md: ~30 lines (3-5 categories)
|
|
147
|
+
- spec/: 1-2 files
|
|
148
|
+
- Total footprint: <500 lines
|
|
149
|
+
|
|
150
|
+
### Medium Project (3-5 agents, team of 2-4)
|
|
151
|
+
- AGENTS.md: ~100 lines
|
|
152
|
+
- MEMORY.md: ~150 lines (8-10 categories)
|
|
153
|
+
- spec/: 4-6 files
|
|
154
|
+
- Total footprint: <1500 lines
|
|
155
|
+
|
|
156
|
+
### Large Project (10+ agents, team of 5+)
|
|
157
|
+
- AGENTS.md: ~150 lines (hard cap)
|
|
158
|
+
- MEMORY.md: ~200 lines, archive old entries annually
|
|
159
|
+
- spec/: 10+ files, organized by domain
|
|
160
|
+
- Total footprint: <3000 lines
|
|
161
|
+
- Archive: Move completed decisions to `spec/archive/decisions-2025-H1.md`
|
|
162
|
+
|
|
163
|
+
**Progressive Disclosure in Action**:
|
|
164
|
+
- Large projects don't bloat MEMORY.md
|
|
165
|
+
- Agents read full MEMORY.md once per session (~500 tokens)
|
|
166
|
+
- Follow pointers only to relevant specs
|
|
167
|
+
- Result: Same token cost as small project for core memory
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## IDE Integration Points
|
|
172
|
+
|
|
173
|
+
### OpenCode
|
|
174
|
+
- Reads: AGENTS.md (via plugin hook)
|
|
175
|
+
- Plugin auto-injects: `.agents/MEMORY.md` context on session start
|
|
176
|
+
- Plugin reminds: Update TASKS.md on session idle
|
|
177
|
+
- Writes: Agent appends to MEMORY.md/TASKS.md/spec/
|
|
178
|
+
|
|
179
|
+
### GitHub Copilot (VSCode)
|
|
180
|
+
- Reads: `.github/copilot-instructions.md` (GitHub convention)
|
|
181
|
+
- copilot-instructions.md = same router format as AGENTS.md
|
|
182
|
+
- Points to `.agents/MEMORY.md` + spec files
|
|
183
|
+
- Writes: User includes `@save memory: <decision>` in chat → agent appends
|
|
184
|
+
|
|
185
|
+
### Cursor / Windsurf
|
|
186
|
+
- Reads: `.cursorrules` / `.windsurfrules` (IDE convention)
|
|
187
|
+
- Same router format, points to `.agents/`
|
|
188
|
+
- Writes: Agent rules instruct direct append
|
|
189
|
+
|
|
190
|
+
### CLI / Non-IDE Workflows
|
|
191
|
+
- Humans can read/edit `.agents/` files directly
|
|
192
|
+
- No special IDE integration needed
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Migration from Other Systems
|
|
197
|
+
|
|
198
|
+
### From memsearch → File-Based
|
|
199
|
+
|
|
200
|
+
1. **Export memsearch data**:
|
|
201
|
+
```bash
|
|
202
|
+
# Read .memsearch/memory/2026-*.md files
|
|
203
|
+
# Manually extract high-quality summaries
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
2. **Create initial MEMORY.md**:
|
|
207
|
+
- Go through each date file
|
|
208
|
+
- Extract 2-3 truly important decisions per week
|
|
209
|
+
- Format as `- YYYY-MM-DD: <1-line summary>`
|
|
210
|
+
- Discard debug logs, failed experiments, noise
|
|
211
|
+
|
|
212
|
+
3. **Create spec files**:
|
|
213
|
+
- For each category with multiple entries, create `spec/category.md`
|
|
214
|
+
- Add pointer in MEMORY.md to new spec file
|
|
215
|
+
- Move detailed explanations to spec file, leave 1-line pointer in MEMORY
|
|
216
|
+
|
|
217
|
+
4. **Disable memsearch**:
|
|
218
|
+
- Remove `@zilliz/memsearch-opencode` from `opencode.json`
|
|
219
|
+
- Keep `.memsearch/memory/` as archive (1 year retention)
|
|
220
|
+
- Delete milvus.db
|
|
221
|
+
|
|
222
|
+
### From .github/copilot-instructions.md (monolithic)
|
|
223
|
+
|
|
224
|
+
1. **Extract decisions** → `.agents/MEMORY.md`
|
|
225
|
+
2. **Extract patterns** → `.agents/spec/patterns.md`
|
|
226
|
+
3. **Extract commands** → `AGENTS.md`
|
|
227
|
+
4. **Keep router** → update `.github/copilot-instructions.md` to point to `.agents/`
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Quality Standards
|
|
232
|
+
|
|
233
|
+
### AGENTS.md
|
|
234
|
+
- ✓ Every rule is actionable (not vague)
|
|
235
|
+
- ✓ Every pointer resolves to a real file
|
|
236
|
+
- ✓ Fits on one screen (150 lines)
|
|
237
|
+
- ✓ No project-specific context (generic template works with substitution)
|
|
238
|
+
|
|
239
|
+
### MEMORY.md
|
|
240
|
+
- ✓ Each entry is a complete thought (not partial)
|
|
241
|
+
- ✓ Each category has 3+ entries or should be archived
|
|
242
|
+
- ✓ Entries sorted by date (newest first within category)
|
|
243
|
+
- ✓ No duplicate ideas across entries
|
|
244
|
+
- ✓ All entries are decisions/patterns (not TODOs)
|
|
245
|
+
|
|
246
|
+
### spec/*.md
|
|
247
|
+
- ✓ At least 1 code example per concept
|
|
248
|
+
- ✓ Clear "when to use / when not to use" section
|
|
249
|
+
- ✓ Links to related files in codebase
|
|
250
|
+
- ✓ Referenced from at least 1 MEMORY.md entry
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Tooling Support
|
|
255
|
+
|
|
256
|
+
### OpenCode Plugin (Current)
|
|
257
|
+
- ✓ session.created → log memory file status
|
|
258
|
+
- ✓ tool.execute.after → track spec file edits
|
|
259
|
+
- ✓ session.idle → remind update TASKS.md
|
|
260
|
+
- Planned: ✗ Auto-inject MEMORY.md into next agent session
|
|
261
|
+
|
|
262
|
+
### CLI (Current)
|
|
263
|
+
- ✓ `npx @vuau/agent-memory init` — scaffold structure
|
|
264
|
+
- ✓ `npx @vuau/agent-memory doctor` — validate structure
|
|
265
|
+
- Planned: ✗ `report` — generate memory stats, archival suggestions
|
|
266
|
+
|
|
267
|
+
### VSCode Extension (Planned Phase 3)
|
|
268
|
+
- Sidebar showing MEMORY.md categories
|
|
269
|
+
- Copilot Chat integration → inject relevant spec file on user request
|
|
270
|
+
- Quick commands: "Add decision", "Update task"
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Summary
|
|
275
|
+
|
|
276
|
+
This 4-layer architecture provides:
|
|
277
|
+
|
|
278
|
+
1. **Scalability**: Works for 1-person projects and 50-person teams
|
|
279
|
+
2. **Portability**: Plain markdown files work with any IDE
|
|
280
|
+
3. **Simplicity**: No daemon, no database, no special infrastructure
|
|
281
|
+
4. **Quality**: Agents write only when they understand context (vs. automatic capture)
|
|
282
|
+
5. **Sustainability**: Plain text + git version control
|
|
283
|
+
6. **Token efficiency**: Curated entries + on-demand specs = consistent ~500 token/session overhead
|
|
284
|
+
|
|
285
|
+
It's a natural fit for teams migrating from heavyweight solutions (memsearch, MCP servers) to a simpler, more sustainable approach.
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# Kiến trúc: Cấu trúc 4 Lớp Được Đề xuất cho AI Memory
|
|
2
|
+
|
|
3
|
+
## Tổng quan
|
|
4
|
+
|
|
5
|
+
Tài liệu này đề xuất kiến trúc khả năng skalabiliti cho AI memory qua các codebases mọi kích cỡ. Nó giải quyết vấn đề scalability, maintainability, và IDE compatibility phát hiện trong quá trình nghiên cứu.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Lớp 1: Router (Project Root AGENTS.md)
|
|
10
|
+
|
|
11
|
+
**Mục đích**: Single point of truth cho AI agents vào project.
|
|
12
|
+
|
|
13
|
+
**Ràng buộc**:
|
|
14
|
+
- Max 150 dòng
|
|
15
|
+
- Thuần routing/reference, không documentation
|
|
16
|
+
- Không project-specific decisions (chỉ pointers đến layers dưới)
|
|
17
|
+
|
|
18
|
+
**Chứa**:
|
|
19
|
+
- Project setup commands (`npm install`, `make dev`, etc.)
|
|
20
|
+
- Quy tắc code style quan trọng (type safety, lint settings)
|
|
21
|
+
- Documentation map — file nào để đọc cho task type nào
|
|
22
|
+
- Memory protocol — agents ghi MEMORY.md thế nào
|
|
23
|
+
|
|
24
|
+
**Ví dụ**:
|
|
25
|
+
```markdown
|
|
26
|
+
# My Project - AGENTS
|
|
27
|
+
|
|
28
|
+
## Commands
|
|
29
|
+
- `npm dev` — start dev server
|
|
30
|
+
- `npm test` — run tests
|
|
31
|
+
|
|
32
|
+
## Key Rules
|
|
33
|
+
- TypeScript strict: true required
|
|
34
|
+
- All components must have JSDoc comments
|
|
35
|
+
|
|
36
|
+
## Documentation Map
|
|
37
|
+
| Task | Read |
|
|
38
|
+
|------|------|
|
|
39
|
+
| Architecture decisions | `.agents/MEMORY.md` |
|
|
40
|
+
| Component patterns | `.agents/spec/components.md` |
|
|
41
|
+
| Production deployment | `.agents/spec/deployment.md` |
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Tại sao 150 dòng max**:
|
|
45
|
+
- Vừa trên một screen → agents đọc full context
|
|
46
|
+
- Khuyến khích ruthless curation — chỉ critical rules
|
|
47
|
+
- Prevent AGENTS.md thành dumping ground
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Lớp 2: Long-term Memory (.agents/MEMORY.md)
|
|
52
|
+
|
|
53
|
+
**Mục đích**: Curated decisions và patterns agents nên biết trước khi implement.
|
|
54
|
+
|
|
55
|
+
**Format**:
|
|
56
|
+
```markdown
|
|
57
|
+
## Category Name
|
|
58
|
+
→ Full details: `.agents/spec/category.md`
|
|
59
|
+
|
|
60
|
+
- YYYY-MM-DD: <1-line decision hoặc pattern>
|
|
61
|
+
- YYYY-MM-DD: <another decision>
|
|
62
|
+
|
|
63
|
+
## Another Category
|
|
64
|
+
→ Pointer to spec file
|
|
65
|
+
|
|
66
|
+
- YYYY-MM-DD: <decision>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Ràng buộc**:
|
|
70
|
+
- 1 line per entry (decision đủ nhỏ để fit)
|
|
71
|
+
- Category headers point đến spec files
|
|
72
|
+
- Max 150-200 lines cho entire file
|
|
73
|
+
- Append-only — không bao giờ delete old entries
|
|
74
|
+
|
|
75
|
+
**Lý do thiết kế**:
|
|
76
|
+
- Agents có thể scan 150 lines nhanh (~200 token)
|
|
77
|
+
- Follow pointers chỉ khi cần (on-demand spec files)
|
|
78
|
+
- Category headers = progressive disclosure
|
|
79
|
+
- 1-line format force curation — chỉ truly important decisions sống sót
|
|
80
|
+
|
|
81
|
+
**Khi thêm entries**:
|
|
82
|
+
- User explicitly approves decision ("ok", "yes", "apply")
|
|
83
|
+
- Agent hiểu decision là reusable qua sessions
|
|
84
|
+
- Not: every thought, every experiment, every debug session
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Lớp 3: Working Memory (.agents/TASKS.md)
|
|
89
|
+
|
|
90
|
+
**Mục đích**: Enable session continuity — agents resume từ nơi dừng.
|
|
91
|
+
|
|
92
|
+
**Format**:
|
|
93
|
+
```markdown
|
|
94
|
+
## In Progress
|
|
95
|
+
- Task 1 description — agent đang làm gì
|
|
96
|
+
- Task 2 description
|
|
97
|
+
|
|
98
|
+
## Up Next
|
|
99
|
+
- Next task để work on
|
|
100
|
+
- Task after that
|
|
101
|
+
|
|
102
|
+
## Completed
|
|
103
|
+
- Gì được finish trong recent sessions
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Ràng buộc**:
|
|
107
|
+
- 3 simple sections: In Progress, Up Next, Completed
|
|
108
|
+
- Free-form text per task (1-3 lines mỗi)
|
|
109
|
+
- Updated khi session start và end
|
|
110
|
+
|
|
111
|
+
**Agent behavior**:
|
|
112
|
+
- Read khi session start → hiểu context, resume work
|
|
113
|
+
- Update trước session end → gì done, gì next
|
|
114
|
+
- Plugin reminds nếu tasks exist nhưng không update
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Lớp 4: Spec Files (.agents/spec/*.md)
|
|
119
|
+
|
|
120
|
+
**Mục đích**: Detailed documentation agents đọc on-demand, referenced bởi MEMORY.md.
|
|
121
|
+
|
|
122
|
+
**Naming**:
|
|
123
|
+
- `architecture.md` — codebase structure, file organization
|
|
124
|
+
- `components.md` — reusable component patterns
|
|
125
|
+
- `deployment.md` — release process, environments
|
|
126
|
+
- `domain.md` — business logic, core concepts
|
|
127
|
+
- `{feature}.md` — bất kỳ major feature nào với complex patterns
|
|
128
|
+
|
|
129
|
+
**Contents**:
|
|
130
|
+
- Code examples showing pattern
|
|
131
|
+
- When to use / when not to use
|
|
132
|
+
- Common pitfalls
|
|
133
|
+
- Links đến related files trong codebase
|
|
134
|
+
|
|
135
|
+
**Design**:
|
|
136
|
+
- Agents read từ MEMORY.md pointers, không all specs
|
|
137
|
+
- Specs có thể large (1000+ lines) → loaded on-demand
|
|
138
|
+
- Better cho screenshots, diagrams, detailed explanations
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Skalabiliti: Xử lý khác nhau Project Sizes
|
|
143
|
+
|
|
144
|
+
### Small Project (1-2 agents, 1 dev)
|
|
145
|
+
- AGENTS.md: ~50 dòng
|
|
146
|
+
- MEMORY.md: ~30 dòng (3-5 categories)
|
|
147
|
+
- spec/: 1-2 files
|
|
148
|
+
- Total footprint: <500 dòng
|
|
149
|
+
|
|
150
|
+
### Medium Project (3-5 agents, team 2-4)
|
|
151
|
+
- AGENTS.md: ~100 dòng
|
|
152
|
+
- MEMORY.md: ~150 dòng (8-10 categories)
|
|
153
|
+
- spec/: 4-6 files
|
|
154
|
+
- Total footprint: <1500 dòng
|
|
155
|
+
|
|
156
|
+
### Large Project (10+ agents, team 5+)
|
|
157
|
+
- AGENTS.md: ~150 dòng (hard cap)
|
|
158
|
+
- MEMORY.md: ~200 dòng, archive old entries annually
|
|
159
|
+
- spec/: 10+ files, organized by domain
|
|
160
|
+
- Total footprint: <3000 dòng
|
|
161
|
+
- Archive: Move completed decisions to `spec/archive/decisions-2025-H1.md`
|
|
162
|
+
|
|
163
|
+
**Progressive Disclosure in Action**:
|
|
164
|
+
- Large projects không bloat MEMORY.md
|
|
165
|
+
- Agents đọc full MEMORY.md once per session (~500 token)
|
|
166
|
+
- Follow pointers chỉ đến relevant specs
|
|
167
|
+
- Result: Cùng token cost như small project cho core memory
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## IDE Integration Points
|
|
172
|
+
|
|
173
|
+
### OpenCode
|
|
174
|
+
- Reads: AGENTS.md (via plugin hook)
|
|
175
|
+
- Plugin auto-injects: `.agents/MEMORY.md` context khi session start
|
|
176
|
+
- Plugin reminds: Update TASKS.md khi session idle
|
|
177
|
+
- Writes: Agent appends đến MEMORY.md/TASKS.md/spec/
|
|
178
|
+
|
|
179
|
+
### GitHub Copilot (VSCode)
|
|
180
|
+
- Reads: `.github/copilot-instructions.md` (GitHub convention)
|
|
181
|
+
- copilot-instructions.md = cùng router format với AGENTS.md
|
|
182
|
+
- Points đến `.agents/MEMORY.md` + spec files
|
|
183
|
+
- Writes: User includes `@save memory: <decision>` trong chat → agent appends
|
|
184
|
+
|
|
185
|
+
### Cursor / Windsurf
|
|
186
|
+
- Reads: `.cursorrules` / `.windsurfrules` (IDE convention)
|
|
187
|
+
- Cùng router format, points đến `.agents/`
|
|
188
|
+
- Writes: Agent rules instruct direct append
|
|
189
|
+
|
|
190
|
+
### CLI / Non-IDE Workflows
|
|
191
|
+
- Humans có thể read/edit `.agents/` files trực tiếp
|
|
192
|
+
- Không cần special IDE integration
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Migration từ Other Systems
|
|
197
|
+
|
|
198
|
+
### Từ memsearch → File-Based
|
|
199
|
+
|
|
200
|
+
1. **Export memsearch data**:
|
|
201
|
+
```bash
|
|
202
|
+
# Read .memsearch/memory/2026-*.md files
|
|
203
|
+
# Manually extract high-quality summaries
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
2. **Create initial MEMORY.md**:
|
|
207
|
+
- Go through each date file
|
|
208
|
+
- Extract 2-3 truly important decisions per week
|
|
209
|
+
- Format as `- YYYY-MM-DD: <1-line summary>`
|
|
210
|
+
- Discard debug logs, failed experiments, noise
|
|
211
|
+
|
|
212
|
+
3. **Create spec files**:
|
|
213
|
+
- Cho mỗi category có multiple entries, tạo `spec/category.md`
|
|
214
|
+
- Add pointer trong MEMORY.md đến new spec file
|
|
215
|
+
- Move detailed explanations đến spec file, để 1-line pointer trong MEMORY
|
|
216
|
+
|
|
217
|
+
4. **Disable memsearch**:
|
|
218
|
+
- Remove `@zilliz/memsearch-opencode` từ `opencode.json`
|
|
219
|
+
- Keep `.memsearch/memory/` như archive (1 year retention)
|
|
220
|
+
- Delete milvus.db
|
|
221
|
+
|
|
222
|
+
### Từ .github/copilot-instructions.md (monolithic)
|
|
223
|
+
|
|
224
|
+
1. **Extract decisions** → `.agents/MEMORY.md`
|
|
225
|
+
2. **Extract patterns** → `.agents/spec/patterns.md`
|
|
226
|
+
3. **Extract commands** → `AGENTS.md`
|
|
227
|
+
4. **Keep router** → update `.github/copilot-instructions.md` để point đến `.agents/`
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Tiêu chuẩn Chất lượng
|
|
232
|
+
|
|
233
|
+
### AGENTS.md
|
|
234
|
+
- ✓ Mỗi rule là actionable (không vague)
|
|
235
|
+
- ✓ Mỗi pointer resolves đến real file
|
|
236
|
+
- ✓ Vừa trên một screen (150 dòng)
|
|
237
|
+
- ✓ Không project-specific context (generic template work với substitution)
|
|
238
|
+
|
|
239
|
+
### MEMORY.md
|
|
240
|
+
- ✓ Mỗi entry là complete thought (không partial)
|
|
241
|
+
- ✓ Mỗi category có 3+ entries hoặc should be archived
|
|
242
|
+
- ✓ Entries sorted by date (newest first trong category)
|
|
243
|
+
- ✓ Không duplicate ideas qua entries
|
|
244
|
+
- ✓ Tất cả entries là decisions/patterns (không TODOs)
|
|
245
|
+
|
|
246
|
+
### spec/*.md
|
|
247
|
+
- ✓ Ít nhất 1 code example per concept
|
|
248
|
+
- ✓ Clear "when to use / when not to use" section
|
|
249
|
+
- ✓ Links đến related files trong codebase
|
|
250
|
+
- ✓ Referenced từ ít nhất 1 MEMORY.md entry
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Công cụ Support
|
|
255
|
+
|
|
256
|
+
### OpenCode Plugin (Hiện tại)
|
|
257
|
+
- ✓ session.created → log memory file status
|
|
258
|
+
- ✓ tool.execute.after → track spec file edits
|
|
259
|
+
- ✓ session.idle → remind update TASKS.md
|
|
260
|
+
- Planned: ✗ Auto-inject MEMORY.md vào next agent session
|
|
261
|
+
|
|
262
|
+
### CLI (Hiện tại)
|
|
263
|
+
- ✓ `npx @vuau/agent-memory init` — scaffold structure
|
|
264
|
+
- ✓ `npx @vuau/agent-memory doctor` — validate structure
|
|
265
|
+
- Planned: ✗ `report` — generate memory stats, archival suggestions
|
|
266
|
+
|
|
267
|
+
### VSCode Extension (Planned Phase 3)
|
|
268
|
+
- Sidebar showing MEMORY.md categories
|
|
269
|
+
- Copilot Chat integration → inject relevant spec file trên user request
|
|
270
|
+
- Quick commands: "Add decision", "Update task"
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Tóm lại
|
|
275
|
+
|
|
276
|
+
Kiến trúc 4-layer này cung cấp:
|
|
277
|
+
|
|
278
|
+
1. **Skalabiliti**: Làm việc cho 1-person projects và 50-person teams
|
|
279
|
+
2. **Portability**: Plain markdown files hoạt động với bất kỳ IDE nào
|
|
280
|
+
3. **Simplicity**: Không daemon, không database, không special infrastructure
|
|
281
|
+
4. **Quality**: Agents ghi chỉ khi họ hiểu context (vs. automatic capture)
|
|
282
|
+
5. **Sustainability**: Plain text + git version control
|
|
283
|
+
6. **Token efficiency**: Curated entries + on-demand specs = consistent ~500 token/session overhead
|
|
284
|
+
|
|
285
|
+
Đó là natural fit cho teams migrate từ heavyweight solutions (memsearch, MCP servers) đến simpler, sustainable approach.
|