@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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Au Pham
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,156 @@
1
+ # @vuau/agent-memory
2
+
3
+ Structured AI memory for codebases. Works with OpenCode, GitHub Copilot, Cursor, Windsurf, and any AI coding assistant that reads markdown files.
4
+
5
+ **[Tiếng Việt →](./README.vi.md)**
6
+
7
+ ## Problem
8
+
9
+ AI coding assistants lose context between sessions. They can't remember:
10
+ - Architecture decisions you made last week
11
+ - Code patterns specific to your project
12
+ - What task you were working on yesterday
13
+
14
+ **agent-memory** solves this with a simple file-based memory system that any AI can read.
15
+
16
+ ## Research & Architecture
17
+
18
+ Want to understand the reasoning behind this approach?
19
+
20
+ - **[RESEARCH.md](./docs/RESEARCH.md)** — Problem, experiments with memsearch/MCP, comparison matrix, why file-based wins
21
+ - **[ARCHITECTURE.md](./docs/ARCHITECTURE.md)** — 4-layer design, scalability, IDE integration, migration guide
22
+
23
+ Read these if you're evaluating solutions or migrating from other systems.
24
+
25
+ ## Architecture: 4 Layers
26
+
27
+ ```
28
+ / (Project Root)
29
+ ├── AGENTS.md # Layer 1: Router — rules + pointers (~100 lines)
30
+ ├── .github/
31
+ │ └── copilot-instructions.md # Router for GitHub Copilot
32
+ ├── .agents/
33
+ │ ├── MEMORY.md # Layer 2: Long-term memory — curated decisions
34
+ │ ├── TASKS.md # Layer 3: Working memory — current plans
35
+ │ └── spec/
36
+ │ ├── architecture.md # Layer 4: Specs — detailed documentation
37
+ │ └── ...
38
+ ```
39
+
40
+ ### Layer 1: Router (AGENTS.md)
41
+ - Root file every AI IDE reads first
42
+ - Max 150 lines — rules + pointers to spec files
43
+ - **Not** a knowledge dump — a table of contents
44
+
45
+ ### Layer 2: Long-term Memory (.agents/MEMORY.md)
46
+ - Curated decisions and patterns (1-line entries)
47
+ - Category headers with pointers to spec files
48
+ - Agents write here when user approves a decision
49
+
50
+ ### Layer 3: Working Memory (.agents/TASKS.md)
51
+ - Current tasks, in-progress work, next steps
52
+ - Updated at start/end of sessions
53
+ - Enables cross-session continuity
54
+
55
+ ### Layer 4: Specs (.agents/spec/)
56
+ - Detailed documentation per domain
57
+ - Referenced by MEMORY.md pointers
58
+ - Agents read on-demand, not every session
59
+
60
+ ## Install
61
+
62
+ ### As OpenCode Plugin
63
+
64
+ ```json
65
+ // opencode.json
66
+ {
67
+ "plugin": ["@vuau/agent-memory"]
68
+ }
69
+ ```
70
+
71
+ The plugin auto-scaffolds `.agents/` on first session and provides lifecycle hooks.
72
+
73
+ ### Standalone (any project)
74
+
75
+ ```bash
76
+ npx @vuau/agent-memory init
77
+ ```
78
+
79
+ ### Options
80
+
81
+ ```bash
82
+ npx @vuau/agent-memory init --force # Overwrite existing files
83
+ npx @vuau/agent-memory init --name "My App" # Custom project name
84
+ npx @vuau/agent-memory init --no-copilot # Skip copilot-instructions.md
85
+ npx @vuau/agent-memory doctor # Validate structure
86
+ ```
87
+
88
+ ## How It Works
89
+
90
+ ### For AI Agents
91
+ 1. Agent reads `AGENTS.md` → finds documentation map
92
+ 2. Before implementing → reads `MEMORY.md` for past decisions
93
+ 3. Needs details → follows pointer to spec file
94
+ 4. User approves decision → agent appends to `MEMORY.md`
95
+ 5. End of session → agent updates `TASKS.md`
96
+
97
+ ### For Developers
98
+ - `MEMORY.md` = curated knowledge (you control what stays)
99
+ - `TASKS.md` = resume where you left off
100
+ - `spec/` = detailed docs agents update as they explore
101
+ - All markdown — readable by humans, agents, and any IDE
102
+
103
+ ## Memory Protocol
104
+
105
+ Agents follow this protocol (defined in AGENTS.md):
106
+
107
+ ```markdown
108
+ ## When to write
109
+ - User approves a decision → append to .agents/MEMORY.md
110
+ - Explore codebase/architecture → update .agents/spec/*.md
111
+ - Start/finish a large task → update .agents/TASKS.md
112
+
113
+ ## Entry format
114
+ - YYYY-MM-DD: <1-line decision or pattern>
115
+ ```
116
+
117
+ ### MEMORY.md Example
118
+
119
+ ```markdown
120
+ ## Storybook Prototypes
121
+ → Full spec: `.agents/spec/storybook.md`
122
+ - 2026-04-24: State files = 3 layers (interfaces → defaults → variants via spread)
123
+ - 2026-04-24: Dumb components: initialState prop + optional callbacks. No services.
124
+
125
+ ## Responsive Design
126
+ - 2026-04-06: Use useMediaQuery over CSS display:none for heavy components
127
+ ```
128
+
129
+ ## Cross-IDE Compatibility
130
+
131
+ | IDE | Reads | Writes |
132
+ |-----|-------|--------|
133
+ | OpenCode | AGENTS.md + .agents/* (auto via plugin) | MEMORY.md, TASKS.md, spec/* |
134
+ | GitHub Copilot | copilot-instructions.md → .agents/* | MEMORY.md (via rules) |
135
+ | Cursor | .cursorrules → .agents/* | MEMORY.md (via rules) |
136
+ | Windsurf | .windsurfrules → .agents/* | MEMORY.md (via rules) |
137
+
138
+ ## Roadmap
139
+
140
+ - [x] OpenCode plugin with lifecycle hooks
141
+ - [x] CLI scaffolding (`npx init`, `doctor`)
142
+ - [ ] VSCode extension (sidebar, Copilot Chat integration)
143
+ - [ ] Memory archiving and compression
144
+ - [ ] Multi-project memory sharing
145
+
146
+ ## Documentation
147
+
148
+ - **[RESEARCH.md](./docs/RESEARCH.md)** — Problem, experiments, comparison, solution
149
+ - **[RESEARCH.vi.md](./docs/RESEARCH.vi.md)** — Vietnamese version
150
+ - **[ARCHITECTURE.md](./docs/ARCHITECTURE.md)** — 4-layer architecture & scalability
151
+ - **[ARCHITECTURE.vi.md](./docs/ARCHITECTURE.vi.md)** — Vietnamese version
152
+ - **[README.vi.md](./README.vi.md)** — Vietnamese README
153
+
154
+ ## License
155
+
156
+ MIT
package/README.vi.md ADDED
@@ -0,0 +1,145 @@
1
+ # @vuau/agent-memory
2
+
3
+ Bộ nhớ AI có cấu trúc cho các codebase. Hoạt động với OpenCode, GitHub Copilot, Cursor, Windsurf, và bất kỳ AI coding assistant nào đọc markdown files.
4
+
5
+ ## Bài toán
6
+
7
+ AI coding assistants mất bối cảnh giữa các phiên. Họ không thể nhớ:
8
+ - Các quyết định kiến trúc bạn đã đưa ra tuần trước
9
+ - Các mẫu thiết kế cụ thể của dự án
10
+ - Task bạn đang làm hôm qua
11
+
12
+ **agent-memory** giải quyết bằng hệ thống bộ nhớ đơn giản dựa trên file mà bất kỳ AI nào cũng có thể đọc.
13
+
14
+ ## Kiến trúc: 4 Lớp
15
+
16
+ ```
17
+ / (Project Root)
18
+ ├── AGENTS.md # Lớp 1: Router — rules + pointers (~100 dòng)
19
+ ├── .github/
20
+ │ └── copilot-instructions.md # Router cho GitHub Copilot
21
+ ├── .agents/
22
+ │ ├── MEMORY.md # Lớp 2: Long-term memory — curated decisions
23
+ │ ├── TASKS.md # Lớp 3: Working memory — current plans
24
+ │ └── spec/
25
+ │ ├── architecture.md # Lớp 4: Specs — detailed documentation
26
+ │ └── ...
27
+ ```
28
+
29
+ ### Lớp 1: Router (AGENTS.md)
30
+ - Root file mọi IDE đọc đầu tiên
31
+ - Max 150 dòng — rules + pointers đến spec files
32
+ - **Không phải** knowledge dump — table of contents
33
+
34
+ ### Lớp 2: Long-term Memory (.agents/MEMORY.md)
35
+ - Curated decisions và patterns (1-line entries)
36
+ - Category headers với pointers đến spec files
37
+ - Agents ghi khi user approves decision
38
+
39
+ ### Lớp 3: Working Memory (.agents/TASKS.md)
40
+ - Current tasks, in-progress work, next steps
41
+ - Updated khi session start/end
42
+ - Enable cross-session continuity
43
+
44
+ ### Lớp 4: Specs (.agents/spec/)
45
+ - Detailed documentation per domain
46
+ - Referenced bởi MEMORY.md pointers
47
+ - Agents đọc on-demand, không every session
48
+
49
+ ## Cài đặt
50
+
51
+ ### Như OpenCode Plugin
52
+
53
+ ```json
54
+ // opencode.json
55
+ {
56
+ "plugin": ["@vuau/agent-memory"]
57
+ }
58
+ ```
59
+
60
+ Plugin auto-scaffolds `.agents/` khi session đầu tiên và cung cấp lifecycle hooks.
61
+
62
+ ### Standalone (any project)
63
+
64
+ ```bash
65
+ npx @vuau/agent-memory init
66
+ ```
67
+
68
+ ### Tùy chọn
69
+
70
+ ```bash
71
+ npx @vuau/agent-memory init --force # Overwrite existing files
72
+ npx @vuau/agent-memory init --name "My App" # Custom project name
73
+ npx @vuau/agent-memory init --no-copilot # Skip copilot-instructions.md
74
+ npx @vuau/agent-memory doctor # Validate structure
75
+ ```
76
+
77
+ ## Cách hoạt động
78
+
79
+ ### Cho AI Agents
80
+ 1. Agent đọc `AGENTS.md` → tìm documentation map
81
+ 2. Trước khi implement → đọc `MEMORY.md` cho decisions trong quá khứ
82
+ 3. Cần details → follow pointer đến spec file
83
+ 4. User approves decision → agent append vào `MEMORY.md`
84
+ 5. End of session → agent update `TASKS.md`
85
+
86
+ ### Cho Developers
87
+ - `MEMORY.md` = curated knowledge (bạn kiểm soát gì còn lại)
88
+ - `TASKS.md` = resume từ nơi dừng lại
89
+ - `spec/` = detailed docs agents update khi explore
90
+ - Tất cả markdown — readable bởi humans, agents, và any IDE
91
+
92
+ ## Memory Protocol
93
+
94
+ Agents follow protocol này (defined trong AGENTS.md):
95
+
96
+ ```markdown
97
+ ## Khi nào ghi
98
+ - User approves decision → append vào .agents/MEMORY.md
99
+ - Explore codebase/architecture → update .agents/spec/*.md
100
+ - Start/finish large task → update .agents/TASKS.md
101
+
102
+ ## Entry format
103
+ - YYYY-MM-DD: <1-line decision hoặc pattern>
104
+ ```
105
+
106
+ ### MEMORY.md Ví dụ
107
+
108
+ ```markdown
109
+ ## Storybook Prototypes
110
+ → Full spec: `.agents/spec/storybook.md`
111
+ - 2026-04-24: State files = 3 layers (interfaces → defaults → variants via spread)
112
+ - 2026-04-24: Dumb components: initialState prop + optional callbacks. No services.
113
+
114
+ ## Responsive Design
115
+ - 2026-04-06: Use useMediaQuery over CSS display:none cho heavy components
116
+ ```
117
+
118
+ ## Cross-IDE Compatibility
119
+
120
+ | IDE | Reads | Writes |
121
+ |-----|-------|--------|
122
+ | OpenCode | AGENTS.md + .agents/* (auto via plugin) | MEMORY.md, TASKS.md, spec/* |
123
+ | GitHub Copilot | copilot-instructions.md → .agents/* | MEMORY.md (via rules) |
124
+ | Cursor | .cursorrules → .agents/* | MEMORY.md (via rules) |
125
+ | Windsurf | .windsurfrules → .agents/* | MEMORY.md (via rules) |
126
+
127
+ ## Roadmap
128
+
129
+ - [x] OpenCode plugin với lifecycle hooks
130
+ - [x] CLI scaffolding (`npx init`, `doctor`)
131
+ - [ ] VSCode extension (sidebar, Copilot Chat integration)
132
+ - [ ] Memory archiving và compression
133
+ - [ ] Multi-project memory sharing
134
+
135
+ ## Tài liệu
136
+
137
+ - **[RESEARCH.md](./docs/RESEARCH.md)** — Vấn đề, thử nghiệm, so sánh, giải pháp
138
+ - **[RESEARCH.vi.md](./docs/RESEARCH.vi.md)** — Bản tiếng Việt của RESEARCH
139
+ - **[ARCHITECTURE.md](./docs/ARCHITECTURE.md)** — 4-layer architecture & scalability
140
+ - **[ARCHITECTURE.vi.md](./docs/ARCHITECTURE.vi.md)** — Bản tiếng Việt của ARCHITECTURE
141
+ - **[README.md](./README.md)** — English version
142
+
143
+ ## License
144
+
145
+ MIT
package/bin/cli.ts ADDED
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env node --experimental-strip-types --no-warnings
2
+ /**
3
+ * CLI entry point for @vuau/agent-memory
4
+ *
5
+ * Usage:
6
+ * npx @vuau/agent-memory init [--force] [--name <project-name>]
7
+ * npx @vuau/agent-memory doctor
8
+ */
9
+
10
+ import { scaffold } from "../src/core/scaffold.ts"
11
+ import { doctor } from "../src/core/doctor.ts"
12
+
13
+ const args = process.argv.slice(2)
14
+ const command = args[0]
15
+
16
+ function printUsage() {
17
+ console.log(`
18
+ @vuau/agent-memory — Structured AI memory for codebases
19
+
20
+ Usage:
21
+ agent-memory init [options] Scaffold .agents/ structure
22
+ agent-memory doctor Validate .agents/ structure
23
+ agent-memory help Show this help
24
+
25
+ Options (init):
26
+ --force Overwrite existing files
27
+ --name <name> Project name (default: from package.json)
28
+ --no-copilot Skip .github/copilot-instructions.md
29
+ `)
30
+ }
31
+
32
+ function runInit() {
33
+ const force = args.includes("--force")
34
+ const noCopilot = args.includes("--no-copilot")
35
+ const nameIdx = args.indexOf("--name")
36
+ const projectName = nameIdx !== -1 ? args[nameIdx + 1] : undefined
37
+
38
+ const cwd = process.cwd()
39
+ console.log(`Initializing agent memory in ${cwd}...`)
40
+
41
+ const result = scaffold(cwd, {
42
+ projectName,
43
+ copilotInstructions: !noCopilot,
44
+ }, force)
45
+
46
+ if (result.created.length > 0) {
47
+ console.log("\nCreated:")
48
+ for (const f of result.created) {
49
+ console.log(` ✓ ${f}`)
50
+ }
51
+ }
52
+
53
+ if (result.skipped.length > 0) {
54
+ console.log("\nSkipped (already exist):")
55
+ for (const f of result.skipped) {
56
+ console.log(` - ${f}`)
57
+ }
58
+ }
59
+
60
+ if (result.created.length === 0 && result.skipped.length > 0) {
61
+ console.log("\nAll files already exist. Use --force to overwrite.")
62
+ }
63
+
64
+ console.log("\nNext steps:")
65
+ console.log(" 1. Edit AGENTS.md — add your project-specific rules")
66
+ console.log(" 2. Add spec files to .agents/spec/ for detailed documentation")
67
+ console.log(" 3. For OpenCode: add to opencode.json → { \"plugin\": [\"@vuau/agent-memory\"] }")
68
+ console.log("")
69
+ }
70
+
71
+ function runDoctor() {
72
+ const cwd = process.cwd()
73
+ const result = doctor(cwd)
74
+
75
+ if (result.issues.length === 0) {
76
+ console.log("✓ All checks passed!")
77
+ return
78
+ }
79
+
80
+ for (const issue of result.issues) {
81
+ const icon = issue.level === "error" ? "✗" : issue.level === "warning" ? "⚠" : "ℹ"
82
+ console.log(` ${icon} [${issue.level}] ${issue.file}: ${issue.message}`)
83
+ }
84
+
85
+ console.log("")
86
+ if (result.ok) {
87
+ console.log("⚠ Passed with warnings. Run 'agent-memory init' to fix missing files.")
88
+ } else {
89
+ console.log("✗ Failed. Run 'agent-memory init' to create missing files.")
90
+ process.exit(1)
91
+ }
92
+ }
93
+
94
+ switch (command) {
95
+ case "init":
96
+ runInit()
97
+ break
98
+ case "doctor":
99
+ runDoctor()
100
+ break
101
+ case "help":
102
+ case "--help":
103
+ case "-h":
104
+ case undefined:
105
+ printUsage()
106
+ break
107
+ default:
108
+ console.error(`Unknown command: ${command}`)
109
+ printUsage()
110
+ process.exit(1)
111
+ }