@vheins/local-memory-mcp 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/DASHBOARD.md +129 -0
- package/HYBRID_SEARCH.md +204 -0
- package/IMPLEMENTATION.md +159 -0
- package/README.md +175 -0
- package/dist/capabilities.d.ts +22 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +23 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/dashboard/dashboard.test.d.ts +2 -0
- package/dist/dashboard/dashboard.test.d.ts.map +1 -0
- package/dist/dashboard/dashboard.test.js +362 -0
- package/dist/dashboard/dashboard.test.js.map +1 -0
- package/dist/dashboard/public/app.js +1187 -0
- package/dist/dashboard/public/chart.js +0 -0
- package/dist/dashboard/public/index.html +967 -0
- package/dist/dashboard/server.d.ts +3 -0
- package/dist/dashboard/server.d.ts.map +1 -0
- package/dist/dashboard/server.js +297 -0
- package/dist/dashboard/server.js.map +1 -0
- package/dist/mcp/client.d.ts +34 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +181 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/client.test.d.ts +2 -0
- package/dist/mcp/client.test.d.ts.map +1 -0
- package/dist/mcp/client.test.js +130 -0
- package/dist/mcp/client.test.js.map +1 -0
- package/dist/prompts/registry.d.ts +39 -0
- package/dist/prompts/registry.d.ts.map +1 -0
- package/dist/prompts/registry.js +90 -0
- package/dist/prompts/registry.js.map +1 -0
- package/dist/resources/index.d.ts +17 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +100 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/index.test.d.ts +2 -0
- package/dist/resources/index.test.d.ts.map +1 -0
- package/dist/resources/index.test.js +96 -0
- package/dist/resources/index.test.js.map +1 -0
- package/dist/router.d.ts +4 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +60 -0
- package/dist/router.js.map +1 -0
- package/dist/router.test.d.ts +2 -0
- package/dist/router.test.d.ts.map +1 -0
- package/dist/router.test.js +113 -0
- package/dist/router.test.js.map +1 -0
- package/dist/search_memory_example.d.ts +3 -0
- package/dist/search_memory_example.d.ts.map +1 -0
- package/dist/search_memory_example.js +56 -0
- package/dist/search_memory_example.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +91 -0
- package/dist/server.js.map +1 -0
- package/dist/storage/sqlite.d.ts +95 -0
- package/dist/storage/sqlite.d.ts.map +1 -0
- package/dist/storage/sqlite.js +537 -0
- package/dist/storage/sqlite.js.map +1 -0
- package/dist/storage/sqlite.test.d.ts +2 -0
- package/dist/storage/sqlite.test.d.ts.map +1 -0
- package/dist/storage/sqlite.test.js +358 -0
- package/dist/storage/sqlite.test.js.map +1 -0
- package/dist/storage/vectors.stub.d.ts +12 -0
- package/dist/storage/vectors.stub.d.ts.map +1 -0
- package/dist/storage/vectors.stub.js +88 -0
- package/dist/storage/vectors.stub.js.map +1 -0
- package/dist/store_memory_example.d.ts +3 -0
- package/dist/store_memory_example.d.ts.map +1 -0
- package/dist/store_memory_example.js +69 -0
- package/dist/store_memory_example.js.map +1 -0
- package/dist/test_quotes_client.d.ts +3 -0
- package/dist/test_quotes_client.d.ts.map +1 -0
- package/dist/test_quotes_client.js +72 -0
- package/dist/test_quotes_client.js.map +1 -0
- package/dist/tools/memory.delete.d.ts +9 -0
- package/dist/tools/memory.delete.d.ts.map +1 -0
- package/dist/tools/memory.delete.js +22 -0
- package/dist/tools/memory.delete.js.map +1 -0
- package/dist/tools/memory.recap.d.ts +4 -0
- package/dist/tools/memory.recap.d.ts.map +1 -0
- package/dist/tools/memory.recap.js +42 -0
- package/dist/tools/memory.recap.js.map +1 -0
- package/dist/tools/memory.search.d.ts +5 -0
- package/dist/tools/memory.search.d.ts.map +1 -0
- package/dist/tools/memory.search.js +192 -0
- package/dist/tools/memory.search.js.map +1 -0
- package/dist/tools/memory.search.test.d.ts +2 -0
- package/dist/tools/memory.search.test.d.ts.map +1 -0
- package/dist/tools/memory.search.test.js +181 -0
- package/dist/tools/memory.search.test.js.map +1 -0
- package/dist/tools/memory.store.d.ts +5 -0
- package/dist/tools/memory.store.d.ts.map +1 -0
- package/dist/tools/memory.store.js +41 -0
- package/dist/tools/memory.store.js.map +1 -0
- package/dist/tools/memory.summarize.d.ts +4 -0
- package/dist/tools/memory.summarize.d.ts.map +1 -0
- package/dist/tools/memory.summarize.js +13 -0
- package/dist/tools/memory.summarize.js.map +1 -0
- package/dist/tools/memory.update.d.ts +5 -0
- package/dist/tools/memory.update.d.ts.map +1 -0
- package/dist/tools/memory.update.js +31 -0
- package/dist/tools/memory.update.js.map +1 -0
- package/dist/tools/schemas.d.ts +334 -0
- package/dist/tools/schemas.d.ts.map +1 -0
- package/dist/tools/schemas.js +251 -0
- package/dist/tools/schemas.js.map +1 -0
- package/dist/types.d.ts +31 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/git-scope.d.ts +8 -0
- package/dist/utils/git-scope.d.ts.map +1 -0
- package/dist/utils/git-scope.js +38 -0
- package/dist/utils/git-scope.js.map +1 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +40 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/logger.test.d.ts +2 -0
- package/dist/utils/logger.test.d.ts.map +1 -0
- package/dist/utils/logger.test.js +84 -0
- package/dist/utils/logger.test.js.map +1 -0
- package/dist/utils/mcp-response.d.ts +44 -0
- package/dist/utils/mcp-response.d.ts.map +1 -0
- package/dist/utils/mcp-response.js +81 -0
- package/dist/utils/mcp-response.js.map +1 -0
- package/dist/utils/normalize.d.ts +4 -0
- package/dist/utils/normalize.d.ts.map +1 -0
- package/dist/utils/normalize.js +51 -0
- package/dist/utils/normalize.js.map +1 -0
- package/dist/utils/normalize.test.d.ts +2 -0
- package/dist/utils/normalize.test.d.ts.map +1 -0
- package/dist/utils/normalize.test.js +159 -0
- package/dist/utils/normalize.test.js.map +1 -0
- package/dist/utils/query-expander.d.ts +2 -0
- package/dist/utils/query-expander.d.ts.map +1 -0
- package/dist/utils/query-expander.js +50 -0
- package/dist/utils/query-expander.js.map +1 -0
- package/dist/utils/query-expander.test.d.ts +2 -0
- package/dist/utils/query-expander.test.d.ts.map +1 -0
- package/dist/utils/query-expander.test.js +35 -0
- package/dist/utils/query-expander.test.js.map +1 -0
- package/docs/PRD.md +199 -0
- package/docs/PROMPT-agent.md +139 -0
- package/docs/SPEC-git-scope.md +172 -0
- package/docs/SPEC-heuristics.md +199 -0
- package/docs/SPEC-server.md +243 -0
- package/docs/SPEC-skeleton.md +255 -0
- package/docs/SPEC-sqlite-schema.md +183 -0
- package/docs/SPEC-tool-schema.md +201 -0
- package/docs/SPEC-vector-search.md +198 -0
- package/docs/TEST-scenarios.md +179 -0
- package/package.json +43 -0
- package/scripts/update-null-titles-ai.mjs +272 -0
- package/scripts/update-titles-batch.mjs +71 -0
- package/scripts/update-titles.mjs +66 -0
- package/seed-data.mjs +151 -0
- package/src/capabilities.ts +22 -0
- package/src/dashboard/dashboard.test.ts +546 -0
- package/src/dashboard/public/app.js +1187 -0
- package/src/dashboard/public/chart.js +0 -0
- package/src/dashboard/public/index.html +967 -0
- package/src/dashboard/server.ts +347 -0
- package/src/mcp/client.test.ts +164 -0
- package/src/mcp/client.ts +212 -0
- package/src/prompts/registry.ts +89 -0
- package/src/resources/index.test.ts +132 -0
- package/src/resources/index.ts +113 -0
- package/src/router.test.ts +145 -0
- package/src/router.ts +80 -0
- package/src/server.ts +99 -0
- package/src/storage/sqlite.test.ts +504 -0
- package/src/storage/sqlite.ts +688 -0
- package/src/storage/vectors.stub.ts +101 -0
- package/src/tools/memory.delete.ts +37 -0
- package/src/tools/memory.recap.ts +61 -0
- package/src/tools/memory.search.test.ts +276 -0
- package/src/tools/memory.search.ts +244 -0
- package/src/tools/memory.store.ts +56 -0
- package/src/tools/memory.summarize.ts +23 -0
- package/src/tools/memory.update.ts +46 -0
- package/src/tools/schemas.ts +261 -0
- package/src/types.ts +36 -0
- package/src/utils/git-scope.ts +42 -0
- package/src/utils/logger.test.ts +125 -0
- package/src/utils/logger.ts +53 -0
- package/src/utils/mcp-response.ts +116 -0
- package/src/utils/normalize.test.ts +203 -0
- package/src/utils/normalize.ts +53 -0
- package/src/utils/query-expander.test.ts +40 -0
- package/src/utils/query-expander.ts +60 -0
- package/storage/.gitkeep +5 -0
- package/test.sh +48 -0
- package/tsconfig.json +21 -0
- package/vitest.config.ts +10 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Agent Prompt – Production Ready
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Dokumen ini adalah final agent prompt untuk Coding Copilot + Antigravity Agent yang terintegrasi dengan MCP Local Memory.
|
|
6
|
+
|
|
7
|
+
**Prompt ini dirancang untuk:**
|
|
8
|
+
- Konsisten jangka panjang
|
|
9
|
+
- Disiplin menggunakan memory
|
|
10
|
+
- Tidak over-recall
|
|
11
|
+
- Tahan typo & konteks berubah
|
|
12
|
+
|
|
13
|
+
*Prompt ini SIAP DIPAKAI langsung.*
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## System Prompt (Identity & Contract)
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
You are a coding copilot agent working inside an active software project.
|
|
21
|
+
|
|
22
|
+
Your primary goal is to help write correct, maintainable, and consistent code.
|
|
23
|
+
|
|
24
|
+
You are memory-aware:
|
|
25
|
+
- Stored memory represents durable project knowledge
|
|
26
|
+
- Memory is a source of truth, not a suggestion
|
|
27
|
+
- You must respect stored decisions and constraints
|
|
28
|
+
|
|
29
|
+
You are NOT a chat bot.
|
|
30
|
+
You are a long-term project collaborator.
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Core Behavioral Rules (Hard Rules)
|
|
36
|
+
|
|
37
|
+
1. **Never contradict stored decisions.**
|
|
38
|
+
2. **Never repeat known mistakes.**
|
|
39
|
+
3. **Never invent project rules.**
|
|
40
|
+
4. **Never use memory from another repository.**
|
|
41
|
+
5. **If memory conflicts with the user, ask for clarification.**
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Memory Usage Policy
|
|
46
|
+
|
|
47
|
+
**Before generating code:**
|
|
48
|
+
1. Read project summary (if available).
|
|
49
|
+
2. Search memory for relevant decisions, mistakes, or patterns.
|
|
50
|
+
3. Use memory **ONLY** if clearly relevant.
|
|
51
|
+
4. Prefer fewer, stronger memories over many weak ones.
|
|
52
|
+
|
|
53
|
+
**If no relevant memory exists:**
|
|
54
|
+
- Proceed normally without assumptions.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Memory Injection Format (Internal)
|
|
59
|
+
|
|
60
|
+
```text
|
|
61
|
+
Relevant project memory:
|
|
62
|
+
|
|
63
|
+
- [Decision] Do not use ORM; use raw SQL only.
|
|
64
|
+
- [Mistake] Avoid default exports in domain layer.
|
|
65
|
+
- [Pattern] API handlers use explicit DTO validation.
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Rules:**
|
|
69
|
+
- Do NOT mention memory IDs
|
|
70
|
+
- Do NOT mention scores or metadata
|
|
71
|
+
- Do NOT quote memory verbatim unless necessary
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Auto-Memory Creation Policy
|
|
76
|
+
|
|
77
|
+
**You MAY store memory ONLY if:**
|
|
78
|
+
- The information affects future behavior
|
|
79
|
+
- The scope (repository) is clear
|
|
80
|
+
- The knowledge is durable
|
|
81
|
+
|
|
82
|
+
**Before storing memory:**
|
|
83
|
+
- Explain briefly why it should be stored
|
|
84
|
+
- Ask for confirmation if unsure
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Confirmation Template (When Storing Memory)
|
|
89
|
+
|
|
90
|
+
```text
|
|
91
|
+
I will store this as a [decision/mistake/pattern] for this project
|
|
92
|
+
so I can stay consistent in the future. Let me know if this is incorrect.
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Conflict Resolution
|
|
98
|
+
|
|
99
|
+
**If the user requests something that violates stored memory:**
|
|
100
|
+
1. Politely point out the conflict
|
|
101
|
+
2. Explain the existing constraint
|
|
102
|
+
3. Ask whether the decision has changed
|
|
103
|
+
|
|
104
|
+
*Never silently override memory.*
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Antigravity Behavior Rules
|
|
109
|
+
|
|
110
|
+
- Prefer high-level consistency over short-term convenience
|
|
111
|
+
- Resist gradual drift from established decisions
|
|
112
|
+
- Use project summary to anchor reasoning
|
|
113
|
+
- Push back gently when necessary
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Error Handling & Uncertainty
|
|
118
|
+
|
|
119
|
+
**If unsure:**
|
|
120
|
+
- Ask a clarifying question
|
|
121
|
+
- Do not guess or invent constraints
|
|
122
|
+
- Do not store memory
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Final Instruction
|
|
127
|
+
|
|
128
|
+
> **Behave like a trusted senior engineer who remembers past decisions and protects the long-term health of the codebase.**
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Final Take
|
|
133
|
+
|
|
134
|
+
This prompt turns a stateless LLM into a long-term coding partner.
|
|
135
|
+
|
|
136
|
+
**If the agent follows this contract strictly:**
|
|
137
|
+
- Memory stays clean
|
|
138
|
+
- Behavior stays consistent
|
|
139
|
+
- Trust increases over time
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Skeleton – Git / Project Scope Resolver
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Dokumen ini mendefinisikan resolver scope project / git yang digunakan oleh MCP Local Memory Server.
|
|
6
|
+
|
|
7
|
+
**Resolver ini adalah komponen KRITIS untuk:**
|
|
8
|
+
- Mencegah memory lintas project tercampur
|
|
9
|
+
- Menjaga kualitas coding copilot
|
|
10
|
+
- Mendukung antigravity behavior
|
|
11
|
+
|
|
12
|
+
> *Jika resolver ini salah → memory system akan rusak perlahan.*
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Responsibility
|
|
17
|
+
|
|
18
|
+
**Git Scope Resolver bertugas untuk:**
|
|
19
|
+
1. Menentukan repo aktif saat agent bekerja
|
|
20
|
+
2. Menyediakan scope object yang konsisten
|
|
21
|
+
3. Menolak operasi memory tanpa scope jelas
|
|
22
|
+
|
|
23
|
+
**Resolver ini tidak:**
|
|
24
|
+
- Menyimpan memory
|
|
25
|
+
- Menentukan relevance
|
|
26
|
+
- Melakukan vector search
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Scope Resolution Strategy (Opinionated)
|
|
31
|
+
|
|
32
|
+
### Priority Order
|
|
33
|
+
1. **Explicit scope** dari client (jika ada)
|
|
34
|
+
2. **Git repository root** (via `.git`)
|
|
35
|
+
3. **Project folder name** (fallback)
|
|
36
|
+
|
|
37
|
+
**Jika SEMUA gagal → REJECT.**
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Scope Object (Canonical)
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
export type MemoryScope = {
|
|
45
|
+
repo: string // REQUIRED
|
|
46
|
+
branch?: string
|
|
47
|
+
folder?: string
|
|
48
|
+
language?: string
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Rules
|
|
53
|
+
- `repo` **wajib**
|
|
54
|
+
- `branch` **opsional** (tidak dipakai untuk search default)
|
|
55
|
+
- `folder` hanya jika decision lokal
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## File Location
|
|
60
|
+
|
|
61
|
+
`utils/git-scope.ts`
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Implementation – `git-scope.ts`
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import fs from "fs";
|
|
69
|
+
import path from "path";
|
|
70
|
+
import { execSync } from "child_process";
|
|
71
|
+
|
|
72
|
+
export function resolveGitScope(cwd = process.cwd()) {
|
|
73
|
+
// 1. Try git root
|
|
74
|
+
try {
|
|
75
|
+
const root = execSync("git rev-parse --show-toplevel", {
|
|
76
|
+
cwd,
|
|
77
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
78
|
+
})
|
|
79
|
+
.toString()
|
|
80
|
+
.trim();
|
|
81
|
+
|
|
82
|
+
const repo = path.basename(root);
|
|
83
|
+
|
|
84
|
+
let branch: string | undefined;
|
|
85
|
+
try {
|
|
86
|
+
branch = execSync("git rev-parse --abbrev-ref HEAD", {
|
|
87
|
+
cwd,
|
|
88
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
89
|
+
})
|
|
90
|
+
.toString()
|
|
91
|
+
.trim();
|
|
92
|
+
} catch {}
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
repo,
|
|
96
|
+
branch
|
|
97
|
+
};
|
|
98
|
+
} catch {}
|
|
99
|
+
|
|
100
|
+
// 2. Fallback: project folder
|
|
101
|
+
const fallback = path.basename(cwd);
|
|
102
|
+
|
|
103
|
+
if (fallback) {
|
|
104
|
+
return {
|
|
105
|
+
repo: fallback
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
throw new Error("Unable to resolve project scope (no git repo, no folder)");
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Enforcement Rules (WAJIB di Tool Layer)
|
|
116
|
+
|
|
117
|
+
### `memory.store`
|
|
118
|
+
```typescript
|
|
119
|
+
if (!scope?.repo) {
|
|
120
|
+
throw new Error("Memory must be scoped to a repo");
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### `memory.search`
|
|
125
|
+
```typescript
|
|
126
|
+
if (!repo) {
|
|
127
|
+
throw new Error("Search requires repo scope");
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Agent Behavior Contract
|
|
134
|
+
|
|
135
|
+
**Agent:**
|
|
136
|
+
- **TIDAK BOLEH** menebak repo
|
|
137
|
+
- **TIDAK BOLEH** reuse memory lintas repo
|
|
138
|
+
- **HARUS** pass scope eksplisit atau implicit
|
|
139
|
+
|
|
140
|
+
**Jika resolver gagal:**
|
|
141
|
+
- Agent **HARUS** lanjut tanpa memory
|
|
142
|
+
- **BUKAN** fallback ke global memory
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Common Failure Modes (dan Kenapa Ini Penting)
|
|
147
|
+
|
|
148
|
+
- ❌ **Global memory fallback**
|
|
149
|
+
- → Constraint project A bocor ke project B
|
|
150
|
+
- ❌ **Branch-based memory**
|
|
151
|
+
- → Memory jadi rapuh & terfragmentasi
|
|
152
|
+
- ❌ **Silent failure**
|
|
153
|
+
- → Agent pakai memory salah tanpa sadar
|
|
154
|
+
|
|
155
|
+
**Resolver ini mencegah semua itu.**
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Extension Points (Future, Not Now)
|
|
160
|
+
|
|
161
|
+
- Hash-based repo ID
|
|
162
|
+
- Multi-workspace support
|
|
163
|
+
- Manual override via env
|
|
164
|
+
|
|
165
|
+
*Semua bisa ditambah tanpa breaking contract.*
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Final Take
|
|
170
|
+
|
|
171
|
+
Git scope resolver adalah **seatbelt** untuk memory system.
|
|
172
|
+
Tidak terlihat, tapi menyelamatkan kamu dari kecelakaan serius di masa depan.
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Spec – Auto-Memory Heuristics & Scoping
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Dokumen ini mendefinisikan aturan resmi kapan agent **BOLEH** dan **TIDAK BOLEH** menyimpan memory ke MCP Local Memory Service, serta bagaimana memory di-scope ke project / git repository aktif.
|
|
6
|
+
|
|
7
|
+
**Tujuan utama:**
|
|
8
|
+
- Menjaga kualitas memory (high-signal only)
|
|
9
|
+
- Mencegah memory pollution
|
|
10
|
+
- Mendukung antigravity behavior
|
|
11
|
+
- Membuat agent konsisten lintas sesi
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Core Principle (WAJIB Dipatuhi)
|
|
16
|
+
|
|
17
|
+
1. **Memory adalah commit, bukan log**
|
|
18
|
+
2. **Lebih baik tidak menyimpan apa-apa daripada menyimpan memory buruk**
|
|
19
|
+
3. **Agent tidak menyimpan memory untuk dirinya sendiri, tapi untuk future agent**
|
|
20
|
+
4. **Memory selalu ter-scope ke konteks kerja aktif**
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Active Project / Git Scope
|
|
25
|
+
|
|
26
|
+
### Definisi
|
|
27
|
+
"Active Project" adalah project / repository tempat agent sedang bekerja saat ini.
|
|
28
|
+
|
|
29
|
+
**Scope diturunkan dari:**
|
|
30
|
+
- Git repository root (preferred)
|
|
31
|
+
- Project folder (fallback)
|
|
32
|
+
|
|
33
|
+
### Scope Object (WAJIB)
|
|
34
|
+
```json
|
|
35
|
+
scope: {
|
|
36
|
+
repo: string, // git repo name atau hash
|
|
37
|
+
branch?: string, // opsional
|
|
38
|
+
language?: string, // ts, js, go, dll
|
|
39
|
+
folder?: string // jika decision lokal
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Hard Rules
|
|
44
|
+
- ❌ Memory **TANPA** repo **DILARANG**
|
|
45
|
+
- ❌ Memory lintas repo **TIDAK BOLEH** digabung
|
|
46
|
+
- ✅ Memory hanya dipakai jika repo cocok
|
|
47
|
+
|
|
48
|
+
*Ini mencegah agent mencampur constraint antar project.*
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Memory Types & Eligibility Rules
|
|
53
|
+
|
|
54
|
+
### 1. decision
|
|
55
|
+
**Definisi:** Keputusan desain / arsitektur yang berdampak jangka panjang.
|
|
56
|
+
|
|
57
|
+
**Boleh Disimpan Jika:**
|
|
58
|
+
- User menyatakan keputusan eksplisit
|
|
59
|
+
- Ada tradeoff yang disepakati
|
|
60
|
+
- Keputusan memengaruhi future code
|
|
61
|
+
|
|
62
|
+
**Contoh Valid:**
|
|
63
|
+
- "Kita tidak pakai ORM di project ini"
|
|
64
|
+
- "Semua handler harus pure function"
|
|
65
|
+
|
|
66
|
+
**Contoh Tidak Valid:**
|
|
67
|
+
- "Aku prefer cara ini aja"
|
|
68
|
+
|
|
69
|
+
**Default Importance:** `importance = 5`
|
|
70
|
+
|
|
71
|
+
### 2. mistake
|
|
72
|
+
**Definisi:** Kesalahan yang dikoreksi dan tidak boleh diulang.
|
|
73
|
+
|
|
74
|
+
**Boleh Disimpan Jika:**
|
|
75
|
+
- User mengoreksi agent
|
|
76
|
+
- Kesalahan terjadi lebih dari sekali
|
|
77
|
+
- User bilang "jangan lakukan ini lagi"
|
|
78
|
+
|
|
79
|
+
**Contoh Valid:**
|
|
80
|
+
- "Jangan pakai default export di domain"
|
|
81
|
+
- "Ini bug karena async tidak di-await"
|
|
82
|
+
|
|
83
|
+
**Default Importance:** `importance = 4`
|
|
84
|
+
|
|
85
|
+
### 3. code_fact
|
|
86
|
+
**Definisi:** Fakta stabil tentang codebase.
|
|
87
|
+
|
|
88
|
+
**Boleh Disimpan Jika:**
|
|
89
|
+
- Fakta bersifat objektif
|
|
90
|
+
- Tidak tergantung task
|
|
91
|
+
|
|
92
|
+
**Contoh Valid:**
|
|
93
|
+
- "Project ini pakai clean architecture"
|
|
94
|
+
- "Validasi pakai zod"
|
|
95
|
+
|
|
96
|
+
**Default Importance:** `importance = 3`
|
|
97
|
+
|
|
98
|
+
### 4. pattern
|
|
99
|
+
**Definisi:** Pola implementasi berulang.
|
|
100
|
+
|
|
101
|
+
**Boleh Disimpan Jika:**
|
|
102
|
+
- Pola muncul ≥ 2 kali
|
|
103
|
+
- Pola disetujui user atau implicit standard
|
|
104
|
+
|
|
105
|
+
**Contoh Valid:**
|
|
106
|
+
- Struktur controller
|
|
107
|
+
- Cara error handling
|
|
108
|
+
|
|
109
|
+
**Default Importance:** `importance = 2`
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Auto-Memory Triggers
|
|
114
|
+
|
|
115
|
+
Agent **BOLEH** mempertimbangkan menyimpan memory jika mendeteksi salah satu sinyal berikut:
|
|
116
|
+
|
|
117
|
+
### Explicit User Signals
|
|
118
|
+
- "ingat ini"
|
|
119
|
+
- "ke depannya"
|
|
120
|
+
- "jangan ulangi"
|
|
121
|
+
- "selalu lakukan seperti ini"
|
|
122
|
+
|
|
123
|
+
### Implicit Signals
|
|
124
|
+
- Correction berulang
|
|
125
|
+
- Constraint eksplisit (must / never)
|
|
126
|
+
- Architecture-level instruction
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Auto-Memory Guardrails (HARUS ADA)
|
|
131
|
+
|
|
132
|
+
Sebelum memanggil `memory.store`, agent **WAJIB** menjawab **YA** untuk semua pertanyaan ini:
|
|
133
|
+
|
|
134
|
+
1. Apakah ini masih relevan 1 minggu ke depan?
|
|
135
|
+
2. Apakah ini berlaku untuk seluruh repo (atau folder jelas)?
|
|
136
|
+
3. Apakah ini akan mengubah perilaku agent di masa depan?
|
|
137
|
+
4. Apakah ini bebas dari konteks sementara?
|
|
138
|
+
|
|
139
|
+
**Jika salah satu jawabannya TIDAK → JANGAN simpan.**
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Confirmation Pattern (WAJIB)
|
|
144
|
+
|
|
145
|
+
Agent **HARUS** transparan saat menyimpan memory.
|
|
146
|
+
|
|
147
|
+
**Template:**
|
|
148
|
+
> "Aku akan menyimpan ini sebagai [decision/mistake/etc] untuk project [repo] supaya aku konsisten ke depannya."
|
|
149
|
+
|
|
150
|
+
User boleh membatalkan.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Memory Update vs New Memory
|
|
155
|
+
|
|
156
|
+
**Update Existing Memory Jika:**
|
|
157
|
+
- Decision lama dipertegas
|
|
158
|
+
- Pola diperjelas
|
|
159
|
+
|
|
160
|
+
**Create New Memory Jika:**
|
|
161
|
+
- Decision lama dibatalkan
|
|
162
|
+
- Constraint baru bertentangan
|
|
163
|
+
|
|
164
|
+
*Catatan: Jangan overwrite history tanpa alasan eksplisit.*
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Summary Update Rule (Antigravity)
|
|
169
|
+
|
|
170
|
+
Agent **WAJIB** memanggil `memory.summarize` jika:
|
|
171
|
+
- Menyimpan decision importance ≥ 4
|
|
172
|
+
- Ada ≥ 2 memory baru dalam repo yang sama
|
|
173
|
+
|
|
174
|
+
**Summary HARUS:**
|
|
175
|
+
- High-level
|
|
176
|
+
- Bebas detail implementasi
|
|
177
|
+
- Maksimal 3–5 bullet implisit
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Anti-Patterns (DILARANG)
|
|
182
|
+
|
|
183
|
+
- ❌ Menyimpan opini subjektif
|
|
184
|
+
- ❌ Menyimpan solusi sementara
|
|
185
|
+
- ❌ Menyimpan hasil brainstorming
|
|
186
|
+
- ❌ Menyimpan memory tanpa scope repo
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Final Take
|
|
191
|
+
|
|
192
|
+
Disiplin memory lebih penting dari kecanggihan vector DB.
|
|
193
|
+
|
|
194
|
+
**Auto-memory yang ketat:**
|
|
195
|
+
- Membuat agent terasa dewasa
|
|
196
|
+
- Meningkatkan trust
|
|
197
|
+
- Menjaga antigravity
|
|
198
|
+
|
|
199
|
+
Kalau aturan ini dipatuhi, memory system akan tetap kecil, bersih, dan bernilai tinggi.
|