@leejungkiin/awkit 1.0.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/CHANGELOG.md +27 -0
- package/README.md +146 -0
- package/VERSION +1 -0
- package/bin/awf.js +549 -0
- package/bin/awk.js +1759 -0
- package/core/AGENTS.md +39 -0
- package/core/GEMINI.md +202 -0
- package/core/GEMINI.md.bak +244 -0
- package/core/orchestrator.md +58 -0
- package/package.json +46 -0
- package/schemas/brain.schema.json +342 -0
- package/schemas/preferences.schema.json +95 -0
- package/schemas/session.schema.json +112 -0
- package/skill-packs/neural-memory/README.md +111 -0
- package/skill-packs/neural-memory/pack.json +35 -0
- package/skill-packs/neural-memory/schemas/brain-snapshot.json +167 -0
- package/skill-packs/neural-memory/skills/nm-memory-audit/SKILL.md +157 -0
- package/skill-packs/neural-memory/skills/nm-memory-evolution/SKILL.md +202 -0
- package/skill-packs/neural-memory/skills/nm-memory-intake/SKILL.md +135 -0
- package/skill-packs/neural-memory/skills/nm-memory-sync/SKILL.md +184 -0
- package/skill-packs/neural-memory/workflows/nm-import.md +73 -0
- package/skill-packs/neural-memory/workflows/nm-recall.md +67 -0
- package/skill-packs/neural-memory/workflows/nm-snapshot.md +69 -0
- package/skills/adaptive-language/SKILL.md +189 -0
- package/skills/ambient-brain/SKILL.md +314 -0
- package/skills/ambient-brain/brain-router.md +185 -0
- package/skills/ambient-brain/brain-templates.md +201 -0
- package/skills/auto-save/SKILL.md +223 -0
- package/skills/awf-adaptive-language/SKILL.md +189 -0
- package/skills/awf-context-help/SKILL.md +180 -0
- package/skills/awf-error-translator/SKILL.md +153 -0
- package/skills/awf-session-restore/SKILL.md +270 -0
- package/skills/awf-version-tracker/SKILL.md +32 -0
- package/skills/awf-version-tracker/scripts/snapshot.sh +22 -0
- package/skills/beads-manager/SKILL.md +323 -0
- package/skills/brainstorm-agent/SKILL.md +295 -0
- package/skills/context-help/SKILL.md +180 -0
- package/skills/error-translator/SKILL.md +153 -0
- package/skills/ios-engineer/SKILL.md +101 -0
- package/skills/memory-sync/SKILL.md +378 -0
- package/skills/memory-sync/memory-router.md +185 -0
- package/skills/memory-sync/memory-templates.md +201 -0
- package/skills/orchestrator/SKILL.md +193 -0
- package/skills/session-restore/SKILL.md +240 -0
- package/templates/CODEBASE.md +80 -0
- package/templates/brain.example.json +321 -0
- package/templates/preferences.example.json +21 -0
- package/templates/project-identity/android.json +28 -0
- package/templates/project-identity/backend-nestjs.json +24 -0
- package/templates/project-identity/expo.json +27 -0
- package/templates/project-identity/ios.json +27 -0
- package/templates/project-identity/web-nextjs.json +24 -0
- package/templates/session.example.json +53 -0
- package/templates/specs/design-template.md +166 -0
- package/templates/specs/requirements-template.md +65 -0
- package/templates/specs/tasks-template.md +132 -0
- package/templates/structures/android.txt +10 -0
- package/templates/structures/backend-nestjs.txt +6 -0
- package/templates/structures/expo.txt +9 -0
- package/templates/structures/ios.txt +9 -0
- package/templates/structures/web-nextjs.txt +6 -0
- package/templates/workflow_dual_mode_template.md +87 -0
- package/workflows/_uncategorized/README.md +339 -0
- package/workflows/_uncategorized/ads-creative.md +357 -0
- package/workflows/_uncategorized/ads-full-optimization.md +308 -0
- package/workflows/_uncategorized/ads-plan.md +247 -0
- package/workflows/_uncategorized/ads-user-analysis.md +337 -0
- package/workflows/_uncategorized/skill-health.md +35 -0
- package/workflows/_uncategorized/skill-rollback.md +35 -0
- package/workflows/ads/admob.md +62 -0
- package/workflows/ads/ads-analyst.md +201 -0
- package/workflows/ads/ads-audit.md +106 -0
- package/workflows/ads/ads-optimize.md +97 -0
- package/workflows/ads/ads-targeting.md +241 -0
- package/workflows/ads/adsExpert.md +160 -0
- package/workflows/ads/smali-ads-config.md +400 -0
- package/workflows/ads/smali-ads-flow.md +331 -0
- package/workflows/ads/smali-ads-interstitial.md +377 -0
- package/workflows/ads/smali-ads-native.md +382 -0
- package/workflows/context/auto-execution-workflow.md +291 -0
- package/workflows/context/auto-implement.md +211 -0
- package/workflows/context/codebase-sync.md +163 -0
- package/workflows/context/logic-reasoning-workflow.md +260 -0
- package/workflows/context/next.md +195 -0
- package/workflows/context/recap.md +212 -0
- package/workflows/context/save-brain.md +285 -0
- package/workflows/context/user-intent-analysis-workflow.md +206 -0
- package/workflows/expert/codeExpert.md +126 -0
- package/workflows/expert/debugExpert.md +136 -0
- package/workflows/expert/planExpert.md +112 -0
- package/workflows/git/cloudflare-tunnel.md +135 -0
- package/workflows/git/git-commit-workflow.md +75 -0
- package/workflows/git/hotfix.md +357 -0
- package/workflows/git/release-notes.md +160 -0
- package/workflows/git/rollback.md +52 -0
- package/workflows/git/smart-git-ops.md +103 -0
- package/workflows/lifecycle/brainstorm.md +377 -0
- package/workflows/lifecycle/code.md +663 -0
- package/workflows/lifecycle/debug.md +116 -0
- package/workflows/lifecycle/deploy.md +95 -0
- package/workflows/lifecycle/init.md +152 -0
- package/workflows/lifecycle/master-code-workflow.md +300 -0
- package/workflows/lifecycle/migration.md +196 -0
- package/workflows/lifecycle/plan.md +91 -0
- package/workflows/lifecycle/refactor.md +165 -0
- package/workflows/lifecycle/run.md +52 -0
- package/workflows/lifecycle/test.md +91 -0
- package/workflows/meta/customize.md +346 -0
- package/workflows/meta/file-protection-rules.md +129 -0
- package/workflows/meta/help.html +350 -0
- package/workflows/meta/project-identity-enforcement.md +180 -0
- package/workflows/mobile/app-analysis.md +64 -0
- package/workflows/mobile/maestro-qa-workflow.md +470 -0
- package/workflows/mobile/maestro-test-workflow.md +84 -0
- package/workflows/mobile/structure-clean-architect.md +271 -0
- package/workflows/mobile/turbo-mobile-build.md +190 -0
- package/workflows/quality/accessibility-audit.md +311 -0
- package/workflows/quality/audit.md +217 -0
- package/workflows/quality/bug-hunter.md +243 -0
- package/workflows/quality/code-janitor.md +209 -0
- package/workflows/quality/code-quality-rules.md +132 -0
- package/workflows/quality/performance-audit.md +343 -0
- package/workflows/quality/project-audit.md +61 -0
- package/workflows/quality/self-healing-test.md +192 -0
- package/workflows/quality/ui-review.md +130 -0
- package/workflows/quality/ux-audit.md +213 -0
- package/workflows/quality/visual-debug.md +34 -0
- package/workflows/roles/oracle.md +267 -0
- package/workflows/roles/product-manager-workflow.md +52 -0
- package/workflows/roles/qa-engineer-workflow.md +41 -0
- package/workflows/roles/tech-lead-workflow.md +45 -0
- package/workflows/roles/ui-ux-designer-workflow.md +42 -0
- package/workflows/roles/vibe-coding-master-workflow.md +52 -0
- package/workflows/ui/app-screen-analyzer.md +152 -0
- package/workflows/ui/create-feature.md +332 -0
- package/workflows/ui/create-spec-architect.md +184 -0
- package/workflows/ui/design-to-ui.md +308 -0
- package/workflows/ui/ui-first-methodology.md +279 -0
- package/workflows/ui/visualize.md +298 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memory-sync
|
|
3
|
+
description: >-
|
|
4
|
+
Memory Sync — AI tự động đọc/ghi memory storage theo context mà không cần user nhớ.
|
|
5
|
+
Write triggers: decisions, bug fixes, architecture, task completion, file edits.
|
|
6
|
+
Read triggers: session start, debug, new task, errors, similar problems.
|
|
7
|
+
NOTE: Skill này KHÔNG liên quan đến /brainstorm workflow. Chức năng: sync memory storage.
|
|
8
|
+
version: 2.1.0
|
|
9
|
+
trigger: always
|
|
10
|
+
priority: 3
|
|
11
|
+
formerly: ambient-brain
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# 💾 Memory Sync Skill
|
|
15
|
+
|
|
16
|
+
> **Philosophy:** User không nên nhớ để lưu. AI phải tự biết lúc nào cần đọc, lúc nào cần ghi vào memory storage.
|
|
17
|
+
> **Renamed from:** `ambient-brain` → `memory-sync` (v2.0.0) để tránh nhầm lẫn với `/brainstorm` workflow.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## ⚠️ SCOPE CLARITY (Đọc trước)
|
|
22
|
+
|
|
23
|
+
Skill này CHỈ xử lý **memory storage sync** (đọc/ghi brain files).
|
|
24
|
+
|
|
25
|
+
| Skill này LÀM | Skill này KHÔNG làm |
|
|
26
|
+
|---------------|---------------------|
|
|
27
|
+
| Đọc/ghi `brain/decisions/` | Chạy brainstorm workflow |
|
|
28
|
+
| Đọc/ghi `brain/solutions/` | Tư vấn ý tưởng sản phẩm |
|
|
29
|
+
| Load session context | Research thị trường |
|
|
30
|
+
| Track decisions & bug fixes | Brainstorm tính năng với user |
|
|
31
|
+
|
|
32
|
+
→ Để brainstorm ý tưởng: dùng `/brainstorm` workflow hoặc `brainstorm-agent` skill.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Core Principle: "Ambient Memory"
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
Traditional: User làm việc → nhớ → gõ /save-brain → AI lưu (FAIL khi quên)
|
|
40
|
+
Memory Sync: User làm việc → AI tự nhận ra ký ức quan trọng → Tự lưu & tự đọc
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 📖 MEMORY READ TRIGGERS (Khi nào tự động ĐỌC)
|
|
46
|
+
|
|
47
|
+
### R1: Session Start (LUÔN LUÔN)
|
|
48
|
+
**Điều kiện:** Đầu mỗi conversation mới
|
|
49
|
+
```
|
|
50
|
+
Action:
|
|
51
|
+
1. Đọc brain/session.json → Working context
|
|
52
|
+
2. Đọc brain/active_plans.json → Active plan
|
|
53
|
+
3. Đọc brain/decisions/ → 3 decisions gần nhất
|
|
54
|
+
4. Output: Hiển thị "🧠 Memory loaded: [summary]"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### R2: New Task / Feature Work
|
|
58
|
+
**Điều kiện:** User mention file/feature/task cụ thể, hoặc dùng /code, /debug, /plan
|
|
59
|
+
```
|
|
60
|
+
Patterns:
|
|
61
|
+
- "làm feature X", "sửa file Y", "implement Z"
|
|
62
|
+
- /code, /codeExpert, /debug, /debugExpert, /plan, /planExpert
|
|
63
|
+
|
|
64
|
+
Action:
|
|
65
|
+
1. Query brain/decisions/ với keywords từ task
|
|
66
|
+
2. Query brain/solutions/ với filename/feature name
|
|
67
|
+
3. Nếu tìm thấy liên quan: "💡 Nhớ ra: [relevant context]"
|
|
68
|
+
4. Inject vào working context
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### R3: Error / Bug Encounter
|
|
72
|
+
**Điều kiện:** Error message xuất hiện trong conversation
|
|
73
|
+
```
|
|
74
|
+
Patterns (detect any of):
|
|
75
|
+
- "error:", "Error:", "ERROR", "failed:", "exception"
|
|
76
|
+
- "không chạy", "lỗi", "crash", "bug"
|
|
77
|
+
- Terminal output có stack trace
|
|
78
|
+
|
|
79
|
+
Action:
|
|
80
|
+
1. Extract error type/keywords
|
|
81
|
+
2. Query brain/solutions/ với error pattern
|
|
82
|
+
3. Nếu tìm thấy: "🔍 Đã gặp lỗi này trước: [solution summary]"
|
|
83
|
+
4. Trình bày solution từ memory trước khi debug mới
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### R4: Architectural Decision Needed
|
|
87
|
+
**Điều kiện:** User hỏi về design, approach, architecture
|
|
88
|
+
```
|
|
89
|
+
Patterns:
|
|
90
|
+
- "nên dùng gì", "best approach", "how to design"
|
|
91
|
+
- "chọn giữa X và Y", "architecture", "pattern"
|
|
92
|
+
|
|
93
|
+
Action:
|
|
94
|
+
1. Query brain/decisions/ với topic
|
|
95
|
+
2. Nếu tìm thấy: "📋 Quyết định cũ: [relevant decision]"
|
|
96
|
+
3. Hỏi: "Vẫn dùng approach này hay muốn thay đổi?"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### R5: Recurring Similar Problem
|
|
100
|
+
**Điều kiện:** Task/error giống với memory entries (keyword overlap > 2)
|
|
101
|
+
```
|
|
102
|
+
Action:
|
|
103
|
+
1. Tự động load solution từ memory
|
|
104
|
+
2. Hiển thị: "🔁 Pattern quen: Đã giải quyết tương tự lúc [date]"
|
|
105
|
+
3. Gợi ý dùng lại solution
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 💾 MEMORY WRITE TRIGGERS (Khi nào tự động GHI)
|
|
111
|
+
|
|
112
|
+
### W1: Decision Made (SILENT AUTO-SAVE)
|
|
113
|
+
**Điều kiện:** AI hoặc user đưa ra quyết định kỹ thuật
|
|
114
|
+
```
|
|
115
|
+
Patterns detect decision:
|
|
116
|
+
- "quyết định dùng...", "ta sẽ dùng...", "chọn approach..."
|
|
117
|
+
- "best way is...", "we'll use...", "decided to..."
|
|
118
|
+
- User confirm sau khi AI suggest: "ok", "được", "đồng ý", "làm vậy đi"
|
|
119
|
+
(nhưng chỉ sau khi AI vừa đề xuất architecture/approach)
|
|
120
|
+
|
|
121
|
+
Action (SILENT - không hỏi user):
|
|
122
|
+
1. Extract: what, why, alternatives_considered
|
|
123
|
+
2. Save to: brain/decisions/YYYY-MM-DD-[slug].md
|
|
124
|
+
3. Update: brain/session.json với decision reference
|
|
125
|
+
4. Log internally (không notify user trừ khi được hỏi)
|
|
126
|
+
|
|
127
|
+
Template:
|
|
128
|
+
---
|
|
129
|
+
date: [ISO date]
|
|
130
|
+
topic: [decision topic]
|
|
131
|
+
decision: [what was decided]
|
|
132
|
+
rationale: [why this approach]
|
|
133
|
+
alternatives: [other options considered]
|
|
134
|
+
context: [feature/task this belongs to]
|
|
135
|
+
tags: [relevant tags]
|
|
136
|
+
---
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### W2: Bug Fixed / Solution Found
|
|
140
|
+
**Điều kiện:** Sau khi fix xong bug được confirm
|
|
141
|
+
```
|
|
142
|
+
Patterns detect resolution:
|
|
143
|
+
- "works now", "fixed", "chạy rồi", "ok rồi", "xong"
|
|
144
|
+
- User sau khi test: "ổn rồi", "pass", "ngon"
|
|
145
|
+
- "solved by", "the fix was"
|
|
146
|
+
|
|
147
|
+
Action (SILENT):
|
|
148
|
+
1. Capture: error_pattern, root_cause, solution_steps, files_changed
|
|
149
|
+
2. Save to: brain/solutions/[error-slug]-[date].md
|
|
150
|
+
3. Tag với: filename, error_type, feature
|
|
151
|
+
|
|
152
|
+
Template:
|
|
153
|
+
---
|
|
154
|
+
date: [ISO date]
|
|
155
|
+
error_pattern: [what the error looked like]
|
|
156
|
+
root_cause: [why it happened]
|
|
157
|
+
solution: [how it was fixed]
|
|
158
|
+
files: [which files were changed]
|
|
159
|
+
prevent: [how to avoid in future]
|
|
160
|
+
tags: [file, error_type, feature]
|
|
161
|
+
---
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### W3: Architecture / Pattern Defined
|
|
165
|
+
**Điều kiện:** Sau workflow /plan, /planExpert hoàn thành; HOẶC file spec/BRIEF.md được tạo
|
|
166
|
+
```
|
|
167
|
+
⚠️ KHÔNG trigger khi đang chạy /brainstorm (chỉ trigger KHI HOÀN THÀNH)
|
|
168
|
+
Detection: file docs/BRIEF.md tồn tại mới → W3 trigger
|
|
169
|
+
|
|
170
|
+
Action (SILENT):
|
|
171
|
+
1. Capture: feature_name, tech_choices, structure, reasoning
|
|
172
|
+
2. Save to: brain/decisions/arch-[feature]-[date].md
|
|
173
|
+
3. Link to Bead task ID nếu có
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### W4: Task Milestone Completed
|
|
177
|
+
**Điều kiện:** `bd update --status done` hoặc user tuyên bố xong 1 giai đoạn lớn
|
|
178
|
+
```
|
|
179
|
+
Patterns:
|
|
180
|
+
- "bd update ... --status done"
|
|
181
|
+
- "xong phase", "hoàn thành feature", "done với X"
|
|
182
|
+
|
|
183
|
+
Action (SILENT):
|
|
184
|
+
1. Capture: task_name, what_was_built, key_learnings
|
|
185
|
+
2. Append to: brain/session.json → completed_milestones
|
|
186
|
+
3. Nếu có learnings quan trọng → Save to brain/solutions/
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### W5: Explicit Save Request
|
|
190
|
+
**Điều kiện:** User gõ /save-brain "title" (vẫn support manual)
|
|
191
|
+
```
|
|
192
|
+
Action (FULL SAVE - có confirm):
|
|
193
|
+
1. Synthesize toàn bộ conversation context
|
|
194
|
+
2. User confirm nội dung trước khi lưu
|
|
195
|
+
3. Save với rich metadata
|
|
196
|
+
4. Notify: "💾 Đã lưu vào memory: [title]"
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### W6: File Edit Tracking (MỚI)
|
|
200
|
+
**Điều kiện:** AI tạo/sửa file trong session
|
|
201
|
+
```
|
|
202
|
+
Patterns detect:
|
|
203
|
+
- AI creates new file
|
|
204
|
+
- AI edits existing file (multi_replace_file_content / write_to_file)
|
|
205
|
+
- File không có trong CODEBASE.md
|
|
206
|
+
|
|
207
|
+
Action (SILENT):
|
|
208
|
+
1. Ghi lại: filename, layer (nếu biết), feature_area, timestamp
|
|
209
|
+
2. Append to: brain/session.json → files_touched_this_session: []
|
|
210
|
+
3. Nếu file mới (chưa có trong CODEBASE.md):
|
|
211
|
+
→ Flag: needs_codebase_sync = true
|
|
212
|
+
→ Cuối session/task: gợi ý user chạy /codebase-sync
|
|
213
|
+
|
|
214
|
+
Template saved to session:
|
|
215
|
+
{
|
|
216
|
+
"file": "path/to/file",
|
|
217
|
+
"action": "created|modified",
|
|
218
|
+
"layer": "Presentation|Core|Features",
|
|
219
|
+
"feature_area": "Authentication|Dashboard",
|
|
220
|
+
"timestamp": "ISO date",
|
|
221
|
+
"in_codebase_md": true|false
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## 🔄 MEMORY SYNC PROTOCOL
|
|
228
|
+
|
|
229
|
+
### Sync Frequency
|
|
230
|
+
```
|
|
231
|
+
IMMEDIATE (real-time):
|
|
232
|
+
- W1 Decision made → save trong 1 turn
|
|
233
|
+
- W2 Bug fixed → save ngay khi detect resolution
|
|
234
|
+
|
|
235
|
+
DEFERRED (end of workflow):
|
|
236
|
+
- W3 Architecture → save khi workflow hoàn thành (file BRIEF.md tạo xong)
|
|
237
|
+
- W4 Task completion → save khi task đóng
|
|
238
|
+
|
|
239
|
+
PERIODIC:
|
|
240
|
+
- Mỗi 10 turns → Check if anything worth saving missed
|
|
241
|
+
- End of session → Final consolidation save
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Memory File Structure
|
|
245
|
+
```
|
|
246
|
+
brain/
|
|
247
|
+
├── session.json # Current working state (auto-updated)
|
|
248
|
+
├── active_plans.json # Plans đang active (auto-updated)
|
|
249
|
+
├── decisions/
|
|
250
|
+
│ ├── 2026-02-22-use-sqlite.md
|
|
251
|
+
│ ├── 2026-02-22-arch-neural-brain.md
|
|
252
|
+
│ └── ...
|
|
253
|
+
└── solutions/
|
|
254
|
+
├── 2026-02-22-fts5-error-fix.md
|
|
255
|
+
├── 2026-02-22-activation-algorithm.md
|
|
256
|
+
└── ...
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## 🧭 SALIENCE SCORING (Độ quan trọng)
|
|
262
|
+
|
|
263
|
+
AI tự đánh giá trước khi lưu — chỉ lưu những gì có salience ≥ 0.5:
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
salience_map:
|
|
267
|
+
architectural_decision: 0.95 # Always save
|
|
268
|
+
bug_fix_solution: 0.85 # Always save
|
|
269
|
+
tech_choice: 0.80 # Always save
|
|
270
|
+
pattern_discovered: 0.75 # Save if novel
|
|
271
|
+
task_completion: 0.60 # Save key learnings
|
|
272
|
+
code_snippet: 0.50 # Save if reusable
|
|
273
|
+
conversation_detail: 0.20 # Skip
|
|
274
|
+
casual_chat: 0.05 # Never save
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Novelty Check:** Nếu memory đã có entry tương tự → Reinforce (tăng salience) thay vì tạo mới.
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## 🔔 NOTIFICATION BEHAVIOR
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
QUIET MODE (default):
|
|
285
|
+
- Silent save: Không notify
|
|
286
|
+
- Chỉ show indicator nhỏ: "💾" ở cuối message khi có relevant memory read
|
|
287
|
+
|
|
288
|
+
VERBOSE MODE (khi user hỏi):
|
|
289
|
+
- Explain what was saved/loaded
|
|
290
|
+
- Show memory entry preview
|
|
291
|
+
|
|
292
|
+
NEVER:
|
|
293
|
+
- Hỏi "Bạn có muốn lưu không?" → Chỉ lưu im lặng
|
|
294
|
+
- Interrupt flow để confirm save
|
|
295
|
+
- Spam thông báo lưu
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## 🧩 INTEGRATION WITH OTHER SKILLS
|
|
301
|
+
|
|
302
|
+
```
|
|
303
|
+
Runs BEFORE: awf-session-restore (cung cấp data)
|
|
304
|
+
Runs AFTER: awf-auto-save (fallback nếu memory-sync bỏ sót)
|
|
305
|
+
Works WITH: beads-manager (link memory entries với Bead IDs)
|
|
306
|
+
Works WITH: orchestrator (nhận resolved_target → query focused hơn)
|
|
307
|
+
Enhances: awf-error-translator (thêm historical context)
|
|
308
|
+
SEPARATE FROM: brainstorm-agent (hoàn toàn độc lập — brainstorm-agent xử lý ý tưởng)
|
|
309
|
+
|
|
310
|
+
# Khi orchestrator đã resolve target:
|
|
311
|
+
# memory-sync R2 chỉ query brain/ với resolved_target keywords
|
|
312
|
+
# thay vì query toàn bộ → nhanh hơn và chính xác hơn
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## 📝 MEMORY QUERY ALGORITHM
|
|
318
|
+
|
|
319
|
+
Khi đọc memory, AI tự tìm kiếm theo priority:
|
|
320
|
+
|
|
321
|
+
```
|
|
322
|
+
1. Exact tag match (filename, feature_name, error_type)
|
|
323
|
+
2. Keyword overlap trong content (>= 2 keywords)
|
|
324
|
+
3. Same time period (cùng feature đang làm)
|
|
325
|
+
4. Recent entries (< 7 ngày)
|
|
326
|
+
|
|
327
|
+
Return: Top 3 most relevant entries
|
|
328
|
+
Format: Inline mention, không dump toàn bộ content
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
## ⚡ ACTIVATION EXAMPLES
|
|
334
|
+
|
|
335
|
+
### Example 1: Auto-Read on Error
|
|
336
|
+
```
|
|
337
|
+
User: "Ứng dụng bị crash với lỗi 'TypeError: Cannot read property of undefined'"
|
|
338
|
+
AI internal: [MEMORY READ TRIGGER R3 detected]
|
|
339
|
+
AI scans: brain/solutions/ với "TypeError undefined"
|
|
340
|
+
AI finds: "2026-02-15-undefined-null-fix.md"
|
|
341
|
+
AI responds: "🔍 Nhớ ra: Lỗi này gặp lần trước do null check thiếu
|
|
342
|
+
trong UserService. Fix: optional chaining + default value.
|
|
343
|
+
Áp dụng vào đây..."
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Example 2: Auto-Write on Decision
|
|
347
|
+
```
|
|
348
|
+
User: "Ok, ta dùng better-sqlite3 cho neural brain"
|
|
349
|
+
AI internal: [MEMORY WRITE TRIGGER W1 detected]
|
|
350
|
+
AI saves silently: brain/decisions/2026-02-22-use-better-sqlite3.md
|
|
351
|
+
AI responds normally (không mention save)
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Example 3: Auto-Read on New Task
|
|
355
|
+
```
|
|
356
|
+
User: "Giờ làm phần activation.js"
|
|
357
|
+
AI internal: [MEMORY READ TRIGGER R2 detected - filename mention]
|
|
358
|
+
AI scans: brain/* với "activation"
|
|
359
|
+
AI finds: "arch-neural-brain-2026-02-22.md"
|
|
360
|
+
AI responds: "💡 Từ plan trước: activation.js dùng heap-based BFS với
|
|
361
|
+
sigmoid decay. Bắt đầu với SpreadingActivation class..."
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Example 4: /brainstorm workflow — KHÔNG trigger W3 prematurely
|
|
365
|
+
```
|
|
366
|
+
User: "/brainstorm"
|
|
367
|
+
AI internal: [memory-sync SKIP — /brainstorm workflow đang chạy, chưa có BRIEF.md]
|
|
368
|
+
AI: [Chạy brainstorm workflow bình thường, hỏi ý tưởng user]
|
|
369
|
+
...
|
|
370
|
+
[Sau khi BRIEF.md được tạo]
|
|
371
|
+
AI internal: [MEMORY WRITE TRIGGER W3 detected — BRIEF.md exists]
|
|
372
|
+
AI saves silently: brain/decisions/arch-[feature]-[date].md
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
*memory-sync v2.1.0 — Auto Memory Sync for AWF (Project-Aware, renamed from ambient-brain)*
|
|
378
|
+
*Created by Kien AI*
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Brain Router — Decision Logic
|
|
2
|
+
|
|
3
|
+
> AI sử dụng file này để quyết định: READ, WRITE, hoặc SKIP brain cho mỗi input.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Routing Decision Tree
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
USER_INPUT received
|
|
11
|
+
│
|
|
12
|
+
▼
|
|
13
|
+
[1. Session Start?] ──YES──▶ READ: session.json + active_plans + recent decisions
|
|
14
|
+
│ NO
|
|
15
|
+
▼
|
|
16
|
+
[2. Error detected?] ──YES──▶ READ: brain/solutions/ (error pattern match)
|
|
17
|
+
│ NO Then: proceed with debug, WRITE solution if fixed
|
|
18
|
+
▼
|
|
19
|
+
[3. Command: /plan, /code, /debug?] ──YES──▶ READ: feature-relevant entries
|
|
20
|
+
│ NO
|
|
21
|
+
▼
|
|
22
|
+
[4. File/Feature/Task mentioned?] ──YES──▶ READ: tag match for that file/feature
|
|
23
|
+
│ NO
|
|
24
|
+
▼
|
|
25
|
+
[5. Decision signal detected?] ──YES──▶ WRITE: brain/decisions/ (silent)
|
|
26
|
+
│ NO
|
|
27
|
+
▼
|
|
28
|
+
[6. Resolution signal detected?] ──YES──▶ WRITE: brain/solutions/ (silent)
|
|
29
|
+
│ NO
|
|
30
|
+
▼
|
|
31
|
+
[7. Workflow end?] ──YES──▶ WRITE: architecture/milestone summary (silent)
|
|
32
|
+
│ NO
|
|
33
|
+
▼
|
|
34
|
+
[8. Every 10 turns?] ──YES──▶ CONSOLIDATE: check missed saves
|
|
35
|
+
│ NO
|
|
36
|
+
▼
|
|
37
|
+
SKIP (normal processing)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Signal Detection Patterns
|
|
43
|
+
|
|
44
|
+
### 🔴 WRITE Signals
|
|
45
|
+
|
|
46
|
+
#### Decision Signals
|
|
47
|
+
```yaml
|
|
48
|
+
high_confidence:
|
|
49
|
+
- "ta sẽ dùng {X}"
|
|
50
|
+
- "quyết định dùng {X}"
|
|
51
|
+
- "chọn {X} vì {reason}"
|
|
52
|
+
- "best approach là {X}"
|
|
53
|
+
- "we'll go with {X}"
|
|
54
|
+
- "decided: {X}"
|
|
55
|
+
|
|
56
|
+
medium_confidence (chỉ save nếu AI vừa propose):
|
|
57
|
+
- "ok", "được", "đồng ý" # + context: AI vừa suggest architecture
|
|
58
|
+
- "làm vậy đi", "Kien Ok" # + context: AI vừa propose approach
|
|
59
|
+
- "alright", "sounds good" # + context: technical decision context
|
|
60
|
+
|
|
61
|
+
low_confidence (SKIP - too vague):
|
|
62
|
+
- "ok" alone in casual chat
|
|
63
|
+
- "được" in non-technical context
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Resolution Signals
|
|
67
|
+
```yaml
|
|
68
|
+
high_confidence:
|
|
69
|
+
- "works now", "fixed it", "chạy rồi"
|
|
70
|
+
- "problem solved", "issue resolved"
|
|
71
|
+
- "xong rồi", "ổn rồi", "ngon"
|
|
72
|
+
- "tests pass", "build success"
|
|
73
|
+
|
|
74
|
+
medium_confidence:
|
|
75
|
+
- "ok rồi" sau debug session
|
|
76
|
+
- "done" sau coding task
|
|
77
|
+
- emoji: ✅ sau error discussion
|
|
78
|
+
|
|
79
|
+
requires_context: True # Chỉ save nếu đang trong debug/fix context
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 🔵 READ Signals
|
|
83
|
+
|
|
84
|
+
#### Auto-Read Triggers
|
|
85
|
+
```yaml
|
|
86
|
+
session_start:
|
|
87
|
+
detect: First message of conversation
|
|
88
|
+
load: session.json, active_plans.json, decisions (last 3)
|
|
89
|
+
|
|
90
|
+
error_context:
|
|
91
|
+
detect: error pattern in message
|
|
92
|
+
patterns:
|
|
93
|
+
- "error:", "Error:", "failed", "exception"
|
|
94
|
+
- "crash", "lỗi", "không chạy", "bug"
|
|
95
|
+
- Stack trace format (indented lines with "at ")
|
|
96
|
+
query: brain/solutions/ with error keywords
|
|
97
|
+
|
|
98
|
+
task_context:
|
|
99
|
+
detect: Specific file/feature mentioned + action verb
|
|
100
|
+
patterns:
|
|
101
|
+
- "{verb} {filename}.{ext}"
|
|
102
|
+
- "feature {name}", "implement {name}"
|
|
103
|
+
- /code, /debug, /plan commands
|
|
104
|
+
query: brain/* with filename or feature name as tags
|
|
105
|
+
|
|
106
|
+
architecture_question:
|
|
107
|
+
detect: Design/approach question
|
|
108
|
+
patterns:
|
|
109
|
+
- "nên dùng gì", "best approach"
|
|
110
|
+
- "how to design", "architecture for"
|
|
111
|
+
- "which pattern", "chọn giữa"
|
|
112
|
+
query: brain/decisions/ with topic keywords
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Context Accumulator
|
|
118
|
+
|
|
119
|
+
Brain Router maintains internal context per conversation:
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"conversation_context": {
|
|
124
|
+
"turn_count": 0,
|
|
125
|
+
"current_feature": null,
|
|
126
|
+
"current_files": [],
|
|
127
|
+
"current_task_id": null,
|
|
128
|
+
"recent_errors": [],
|
|
129
|
+
"decisions_made": [],
|
|
130
|
+
"solutions_found": [],
|
|
131
|
+
"last_brain_read": null,
|
|
132
|
+
"last_brain_write": null,
|
|
133
|
+
"brain_entries_loaded": []
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Updated each turn** to maintain routing accuracy with accumulated context.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Anti-Patterns (When NOT to read/write)
|
|
143
|
+
|
|
144
|
+
```yaml
|
|
145
|
+
never_read:
|
|
146
|
+
- Casual greeting ("xin chào", "hi", "how are you")
|
|
147
|
+
- Pure question about general knowledge (not project-specific)
|
|
148
|
+
- Already read brain this turn (deduplicate)
|
|
149
|
+
|
|
150
|
+
never_write:
|
|
151
|
+
- Salience < 0.5 (see SKILL.md scoring)
|
|
152
|
+
- Already have identical/similar entry (within 24h)
|
|
153
|
+
- Casual conversation, non-technical decisions
|
|
154
|
+
- User says "never mind", "bỏ qua", "thôi"
|
|
155
|
+
|
|
156
|
+
rate_limits:
|
|
157
|
+
max_reads_per_turn: 1
|
|
158
|
+
max_writes_per_turn: 2
|
|
159
|
+
min_write_interval_seconds: 30 # Avoid duplicate rapid saves
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Output Format for Brain Reads
|
|
165
|
+
|
|
166
|
+
When brain read finds relevant content:
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
✅ Inline mention (default):
|
|
170
|
+
"💡 Nhớ ra: [1-2 sentence summary]. Áp dụng vào đây..."
|
|
171
|
+
|
|
172
|
+
✅ Decision reminder:
|
|
173
|
+
"📋 Đã quyết định [X] lúc [date]. Vẫn dùng?"
|
|
174
|
+
|
|
175
|
+
✅ Solution reference:
|
|
176
|
+
"🔍 Đã giải quyết lỗi tương tự: [root_cause + fix in 1 line]"
|
|
177
|
+
|
|
178
|
+
❌ Never dump full file content
|
|
179
|
+
❌ Never show raw markdown formatting
|
|
180
|
+
❌ Never mention "reading from brain" explicitly
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
*memory-router v2.0.0 — Routing logic for memory-sync skill*
|