@leejungkiin/awkit 1.4.2 → 1.5.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.
Files changed (64) hide show
  1. package/README.md +32 -9
  2. package/bin/awk.js +464 -87
  3. package/bin/claude-generators.js +3 -1
  4. package/bin/cline-generators.js +3 -1
  5. package/bin/codex-generators.js +7 -2
  6. package/core/orchestrator.md +17 -3
  7. package/core/skill-runtime-manifest.json +37 -0
  8. package/package.json +2 -2
  9. package/skill-packs/creator-studio/README.md +19 -0
  10. package/skill-packs/creator-studio/pack.json +10 -0
  11. package/skill-packs/marketing/README.md +64 -0
  12. package/skill-packs/marketing/pack.json +37 -0
  13. package/skill-packs/mobile-android/README.md +16 -0
  14. package/skill-packs/mobile-android/pack.json +10 -0
  15. package/skill-packs/mobile-ios/README.md +22 -0
  16. package/skill-packs/mobile-ios/pack.json +16 -0
  17. package/skill-packs/neural-memory/pack.json +8 -2
  18. package/skill-packs/superpowers/pack.json +1 -0
  19. package/skill-packs/superpowers/skills/single-flow-task-execution/SKILL.md +59 -358
  20. package/skill-packs/superpowers/skills/writing-skills/SKILL.md +60 -654
  21. package/skill-packs/superpowers/skills/writing-skills/examples/anti-rationalization.md +75 -0
  22. package/skill-packs/superpowers/skills/writing-skills/examples/cso-optimization.md +67 -0
  23. package/skill-packs/superpowers/skills/writing-skills/examples/tdd-for-skills.md +63 -0
  24. package/skills/CATALOG.md +49 -44
  25. package/skills/brainstorm-agent/SKILL.md +55 -315
  26. package/skills/brainstorm-agent/templates/brief-template.md +76 -0
  27. package/skills/codex-conductor/SKILL.md +55 -259
  28. package/skills/codex-conductor/examples/prompt-templates.md +72 -0
  29. package/skills/module-spec-writer/SKILL.md +38 -365
  30. package/skills/module-spec-writer/examples/port-migration-mode.md +40 -0
  31. package/skills/module-spec-writer/templates/module-spec-template.md +118 -0
  32. package/skills/orchestrator/SKILL.md +17 -8
  33. package/skills/single-flow-task-execution/SKILL.md +56 -363
  34. package/skills/single-flow-task-execution/examples/workflow-example.md +91 -0
  35. package/skills/smali-to-kotlin/SKILL.md +23 -416
  36. package/skills/smali-to-kotlin/examples/getting-started/tech-stack.md +58 -0
  37. package/skills/smali-to-kotlin/examples/pipeline/data-ui-parity.md +118 -0
  38. package/skills/smali-to-kotlin/examples/pipeline/scanner-and-bootstrap.md +106 -0
  39. package/skills/smali-to-swift/SKILL.md +18 -621
  40. package/skills/smali-to-swift/examples/getting-started/tech-stack.md +72 -0
  41. package/skills/smali-to-swift/examples/getting-started/toolchain.md +32 -0
  42. package/skills/smali-to-swift/examples/pipeline/core-logic.md +45 -0
  43. package/skills/smali-to-swift/examples/pipeline/data-layer.md +76 -0
  44. package/skills/smali-to-swift/examples/pipeline/framework-scanner.md +73 -0
  45. package/skills/smali-to-swift/examples/pipeline/project-bootstrap.md +76 -0
  46. package/skills/smali-to-swift/examples/pipeline/sdk-integration.md +66 -0
  47. package/skills/smali-to-swift/examples/pipeline/ui-viewmodel.md +96 -0
  48. package/skills/smali-to-swift/references/objc-to-swift-mapping.md +57 -0
  49. package/skills/spec-gate/SKILL.md +51 -265
  50. package/skills/spec-gate/templates/design-templates.md +93 -0
  51. package/skills/symphony-enforcer/SKILL.md +24 -555
  52. package/skills/symphony-enforcer/examples/startup-protocol.md +92 -0
  53. package/skills/symphony-enforcer/examples/task-completion.md +100 -0
  54. package/skills/symphony-enforcer/examples/three-phase.md +107 -0
  55. package/skills/symphony-enforcer/examples/trigger-points.md +99 -0
  56. package/skills/symphony-orchestrator/SKILL.md +1 -1
  57. package/skills/writing-skills/SKILL.md +82 -70
  58. package/skills/writing-skills/examples/anti-rationalization.md +53 -0
  59. package/skills/writing-skills/examples/cso-optimization.md +52 -0
  60. package/skills/writing-skills/examples/tdd-for-skills.md +48 -0
  61. package/templates/help.html +447 -0
  62. package/skills/memory-sync/SKILL.md +0 -424
  63. package/skills/memory-sync/memory-router.md +0 -185
  64. package/skills/memory-sync/memory-templates.md +0 -201
@@ -1,424 +0,0 @@
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.2.0
9
- trigger: always
10
- priority: 3
11
- formerly: ambient-brain
12
- invocation-type: auto
13
- ---
14
-
15
- # 💾 Memory Sync Skill
16
-
17
- > **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.
18
- > **Renamed from:** `ambient-brain` → `memory-sync` (v2.0.0) để tránh nhầm lẫn với `/brainstorm` workflow.
19
- > **v2.2:** Self-Evolution Pattern — tự ghi learnings sau mỗi session.
20
-
21
- ---
22
-
23
- ## ⚠️ SCOPE CLARITY (Đọc trước)
24
-
25
- Skill này CHỈ xử lý **memory storage sync** (đọc/ghi brain files).
26
-
27
- | Skill này LÀM | Skill này KHÔNG làm |
28
- |---------------|---------------------|
29
- | Đọc/ghi `brain/decisions/` | Chạy brainstorm workflow |
30
- | Đọc/ghi `brain/solutions/` | Tư vấn ý tưởng sản phẩm |
31
- | Load session context | Research thị trường |
32
- | Track decisions & bug fixes | Brainstorm tính năng với user |
33
-
34
- → Để brainstorm ý tưởng: dùng `/brainstorm` workflow hoặc `brainstorm-agent` skill.
35
-
36
- ---
37
-
38
- ## Core Principle: "Ambient Memory"
39
-
40
- ```
41
- Traditional: User làm việc → nhớ → gõ /save-brain → AI lưu (FAIL khi quên)
42
- Memory Sync: User làm việc → AI tự nhận ra ký ức quan trọng → Tự lưu & tự đọc
43
- ```
44
-
45
- ---
46
-
47
- ## 📖 MEMORY READ TRIGGERS (Khi nào tự động ĐỌC)
48
-
49
- ### R1: Session Start (LUÔN LUÔN)
50
- **Điều kiện:** Đầu mỗi conversation mới
51
- ```
52
- Action:
53
- 1. Đọc brain/session.json → Working context
54
- 2. Đọc brain/active_plans.json → Active plan
55
- 3. Đọc brain/decisions/ → 3 decisions gần nhất
56
- 4. Output: Hiển thị "🧠 Memory loaded: [summary]"
57
- ```
58
-
59
- ### R2: New Task / Feature Work
60
- **Điều kiện:** User mention file/feature/task cụ thể, hoặc dùng /code, /debug, /plan
61
- ```
62
- Patterns:
63
- - "làm feature X", "sửa file Y", "implement Z"
64
- - /code, /codeExpert, /debug, /debugExpert, /plan, /planExpert
65
-
66
- Action:
67
- 1. Query brain/decisions/ với keywords từ task
68
- 2. Query brain/solutions/ với filename/feature name
69
- 3. Nếu tìm thấy liên quan: "💡 Nhớ ra: [relevant context]"
70
- 4. Inject vào working context
71
- ```
72
-
73
- ### R3: Error / Bug Encounter
74
- **Điều kiện:** Error message xuất hiện trong conversation
75
- ```
76
- Patterns (detect any of):
77
- - "error:", "Error:", "ERROR", "failed:", "exception"
78
- - "không chạy", "lỗi", "crash", "bug"
79
- - Terminal output có stack trace
80
-
81
- Action:
82
- 1. Extract error type/keywords
83
- 2. Query brain/solutions/ với error pattern
84
- 3. Nếu tìm thấy: "🔍 Đã gặp lỗi này trước: [solution summary]"
85
- 4. Trình bày solution từ memory trước khi debug mới
86
- ```
87
-
88
- ### R4: Architectural Decision Needed
89
- **Điều kiện:** User hỏi về design, approach, architecture
90
- ```
91
- Patterns:
92
- - "nên dùng gì", "best approach", "how to design"
93
- - "chọn giữa X và Y", "architecture", "pattern"
94
-
95
- Action:
96
- 1. Query brain/decisions/ với topic
97
- 2. Nếu tìm thấy: "📋 Quyết định cũ: [relevant decision]"
98
- 3. Hỏi: "Vẫn dùng approach này hay muốn thay đổi?"
99
- ```
100
-
101
- ### R5: Recurring Similar Problem
102
- **Điều kiện:** Task/error giống với memory entries (keyword overlap > 2)
103
- ```
104
- Action:
105
- 1. Tự động load solution từ memory
106
- 2. Hiển thị: "🔁 Pattern quen: Đã giải quyết tương tự lúc [date]"
107
- 3. Gợi ý dùng lại solution
108
- ```
109
-
110
- ---
111
-
112
- ## 💾 MEMORY WRITE TRIGGERS (Khi nào tự động GHI)
113
-
114
- ### W1: Decision Made (SILENT AUTO-SAVE)
115
- **Điều kiện:** AI hoặc user đưa ra quyết định kỹ thuật
116
- ```
117
- Patterns detect decision:
118
- - "quyết định dùng...", "ta sẽ dùng...", "chọn approach..."
119
- - "best way is...", "we'll use...", "decided to..."
120
- - User confirm sau khi AI suggest: "ok", "được", "đồng ý", "làm vậy đi"
121
- (nhưng chỉ sau khi AI vừa đề xuất architecture/approach)
122
-
123
- Action (SILENT - không hỏi user):
124
- 1. Extract: what, why, alternatives_considered
125
- 2. Save to: brain/decisions/YYYY-MM-DD-[slug].md
126
- 3. Update: brain/session.json với decision reference
127
- 4. Log internally (không notify user trừ khi được hỏi)
128
-
129
- Template:
130
- ---
131
- date: [ISO date]
132
- topic: [decision topic]
133
- decision: [what was decided]
134
- rationale: [why this approach]
135
- alternatives: [other options considered]
136
- context: [feature/task this belongs to]
137
- tags: [relevant tags]
138
- ---
139
- ```
140
-
141
- ### W2: Bug Fixed / Solution Found
142
- **Điều kiện:** Sau khi fix xong bug được confirm
143
- ```
144
- Patterns detect resolution:
145
- - "works now", "fixed", "chạy rồi", "ok rồi", "xong"
146
- - User sau khi test: "ổn rồi", "pass", "ngon"
147
- - "solved by", "the fix was"
148
-
149
- Action (SILENT):
150
- 1. Capture: error_pattern, root_cause, solution_steps, files_changed
151
- 2. Save to: brain/solutions/[error-slug]-[date].md
152
- 3. Tag với: filename, error_type, feature
153
-
154
- Template:
155
- ---
156
- date: [ISO date]
157
- error_pattern: [what the error looked like]
158
- root_cause: [why it happened]
159
- solution: [how it was fixed]
160
- files: [which files were changed]
161
- prevent: [how to avoid in future]
162
- tags: [file, error_type, feature]
163
- ---
164
- ```
165
-
166
- ### W3: Architecture / Pattern Defined
167
- **Điều kiện:** Sau workflow /plan, /planExpert hoàn thành; HOẶC file spec/BRIEF.md được tạo
168
- ```
169
- ⚠️ KHÔNG trigger khi đang chạy /brainstorm (chỉ trigger KHI HOÀN THÀNH)
170
- Detection: file docs/BRIEF.md tồn tại mới → W3 trigger
171
-
172
- Action (SILENT):
173
- 1. Capture: feature_name, tech_choices, structure, reasoning
174
- 2. Save to: brain/decisions/arch-[feature]-[date].md
175
- 3. Link to Bead task ID nếu có
176
- ```
177
-
178
- ### W4: Task Milestone Completed
179
- **Điều kiện:** `bd update --status done` hoặc user tuyên bố xong 1 giai đoạn lớn
180
- ```
181
- Patterns:
182
- - "bd update ... --status done"
183
- - "xong phase", "hoàn thành feature", "done với X"
184
-
185
- Action (SILENT):
186
- 1. Capture: task_name, what_was_built, key_learnings
187
- 2. Append to: brain/session.json → completed_milestones
188
- 3. Nếu có learnings quan trọng → Save to brain/solutions/
189
- ```
190
-
191
- ### W5: Explicit Save Request
192
- **Điều kiện:** User gõ /save-brain "title" (vẫn support manual)
193
- ```
194
- Action (FULL SAVE - có confirm):
195
- 1. Synthesize toàn bộ conversation context
196
- 2. User confirm nội dung trước khi lưu
197
- 3. Save với rich metadata
198
- 4. Notify: "💾 Đã lưu vào memory: [title]"
199
- ```
200
-
201
- ### W6: File Edit Tracking (MỚI)
202
- **Điều kiện:** AI tạo/sửa file trong session
203
- ```
204
- Patterns detect:
205
- - AI creates new file
206
- - AI edits existing file (multi_replace_file_content / write_to_file)
207
- - File không có trong CODEBASE.md
208
-
209
- Action (SILENT):
210
- 1. Ghi lại: filename, layer (nếu biết), feature_area, timestamp
211
- 2. Append to: brain/session.json → files_touched_this_session: []
212
- 3. Nếu file mới (chưa có trong CODEBASE.md):
213
- → Flag: needs_codebase_sync = true
214
- → Cuối session/task: gợi ý user chạy /codebase-sync
215
-
216
- Template saved to session:
217
- {
218
- "file": "path/to/file",
219
- "action": "created|modified",
220
- "layer": "Presentation|Core|Features",
221
- "feature_area": "Authentication|Dashboard",
222
- "timestamp": "ISO date",
223
- "in_codebase_md": true|false
224
- }
225
- ```
226
-
227
- ### W7: Brainstorm / Analysis Artifact Persist (MỚI)
228
- **Điều kiện:** Brainstorm-agent hoặc AI tạo brainstorm/analysis artifact
229
- ```
230
- Patterns detect:
231
- - BRIEF.md tạo xong (qua brainstorm-agent)
232
- - Analysis document tạo (pricing, market, competitor...)
233
- - Brainstorm document tạo (feature ideas, architecture exploration...)
234
-
235
- Action (SILENT):
236
- 1. POST metadata vào Symphony Notes API (type: brainstorm hoặc analysis)
237
- 2. content = summary ngắn 2-3 dòng ONLY
238
- 3. filePath = absolute path đến file artifact
239
- 4. conversationId = conversation ID hiện tại
240
- 5. projectId = project đang active
241
-
242
- curl -X POST http://localhost:3100/api/notes -H 'Content-Type: application/json' -d '{
243
- "projectId": "<project-id>",
244
- "type": "brainstorm",
245
- "title": "<artifact-title>",
246
- "content": "<summary-2-3-lines>",
247
- "filePath": "<path-to-file>",
248
- "conversationId": "<conversation-id>",
249
- "metadata": { "tags": [...], "created_by": "memory-sync" }
250
- }'
251
-
252
- ⚠️ Nếu Symphony server offline → skip silently, không block workflow
253
- ```
254
-
255
- ---
256
-
257
- ## 🔄 MEMORY SYNC PROTOCOL
258
-
259
- ### Sync Frequency
260
- ```
261
- IMMEDIATE (real-time):
262
- - W1 Decision made → save trong 1 turn
263
- - W2 Bug fixed → save ngay khi detect resolution
264
-
265
- DEFERRED (end of workflow):
266
- - W3 Architecture → save khi workflow hoàn thành (file BRIEF.md tạo xong)
267
- - W4 Task completion → save khi task đóng
268
-
269
- PERIODIC:
270
- - Mỗi 10 turns → Check if anything worth saving missed
271
- - End of session → Final consolidation save
272
- ```
273
-
274
- ### Memory File Structure
275
- ```
276
- brain/
277
- ├── session.json # Current working state (auto-updated)
278
- ├── active_plans.json # Plans đang active (auto-updated)
279
- ├── decisions/
280
- │ ├── 2026-02-22-use-sqlite.md
281
- │ ├── 2026-02-22-arch-neural-brain.md
282
- │ └── ...
283
- └── solutions/
284
- ├── 2026-02-22-fts5-error-fix.md
285
- ├── 2026-02-22-activation-algorithm.md
286
- └── ...
287
- ```
288
-
289
- ---
290
-
291
- ## 🧭 SALIENCE SCORING (Độ quan trọng)
292
-
293
- AI tự đánh giá trước khi lưu — chỉ lưu những gì có salience ≥ 0.5:
294
-
295
- ```
296
- salience_map:
297
- architectural_decision: 0.95 # Always save
298
- bug_fix_solution: 0.85 # Always save
299
- tech_choice: 0.80 # Always save
300
- pattern_discovered: 0.75 # Save if novel
301
- task_completion: 0.60 # Save key learnings
302
- code_snippet: 0.50 # Save if reusable
303
- conversation_detail: 0.20 # Skip
304
- casual_chat: 0.05 # Never save
305
- ```
306
-
307
- **Novelty Check:** Nếu memory đã có entry tương tự → Reinforce (tăng salience) thay vì tạo mới.
308
-
309
- ---
310
-
311
- ## 🔔 NOTIFICATION BEHAVIOR
312
-
313
- ```
314
- QUIET MODE (default):
315
- - Silent save: Không notify
316
- - Chỉ show indicator nhỏ: "💾" ở cuối message khi có relevant memory read
317
-
318
- VERBOSE MODE (khi user hỏi):
319
- - Explain what was saved/loaded
320
- - Show memory entry preview
321
-
322
- NEVER:
323
- - Hỏi "Bạn có muốn lưu không?" → Chỉ lưu im lặng
324
- - Interrupt flow để confirm save
325
- - Spam thông báo lưu
326
- ```
327
-
328
- ---
329
-
330
- ## 🧩 INTEGRATION WITH OTHER SKILLS
331
-
332
- ```
333
- Runs BEFORE: awf-session-restore (cung cấp data)
334
- Runs AFTER: awf-auto-save (fallback nếu memory-sync bỏ sót)
335
- Works WITH: symphony-orchestrator (link memory entries với Symphony task IDs)
336
- Works WITH: orchestrator (nhận resolved_target → query focused hơn)
337
- Enhances: awf-error-translator (thêm historical context)
338
- SEPARATE FROM: brainstorm-agent (hoàn toàn độc lập — brainstorm-agent xử lý ý tưởng)
339
-
340
- # Khi orchestrator đã resolve target:
341
- # memory-sync R2 chỉ query brain/ với resolved_target keywords
342
- # thay vì query toàn bộ → nhanh hơn và chính xác hơn
343
- ```
344
-
345
- ---
346
-
347
- ## 📝 MEMORY QUERY ALGORITHM
348
-
349
- Khi đọc memory, AI tự tìm kiếm theo priority:
350
-
351
- ```
352
- 1. Exact tag match (filename, feature_name, error_type)
353
- 2. Keyword overlap trong content (>= 2 keywords)
354
- 3. Same time period (cùng feature đang làm)
355
- 4. Recent entries (< 7 ngày)
356
-
357
- Return: Top 3 most relevant entries
358
- Format: Inline mention, không dump toàn bộ content
359
- ```
360
-
361
- ---
362
-
363
- ## ⚡ ACTIVATION EXAMPLES
364
-
365
- ### Example 1: Auto-Read on Error
366
- ```
367
- User: "Ứng dụng bị crash với lỗi 'TypeError: Cannot read property of undefined'"
368
- AI internal: [MEMORY READ TRIGGER R3 detected]
369
- AI scans: brain/solutions/ với "TypeError undefined"
370
- AI finds: "2026-02-15-undefined-null-fix.md"
371
- AI responds: "🔍 Nhớ ra: Lỗi này gặp lần trước do null check thiếu
372
- trong UserService. Fix: optional chaining + default value.
373
- Áp dụng vào đây..."
374
- ```
375
-
376
- ### Example 2: Auto-Write on Decision
377
- ```
378
- User: "Ok, ta dùng better-sqlite3 cho neural brain"
379
- AI internal: [MEMORY WRITE TRIGGER W1 detected]
380
- AI saves silently: brain/decisions/2026-02-22-use-better-sqlite3.md
381
- AI responds normally (không mention save)
382
- ```
383
-
384
- ### Example 3: Auto-Read on New Task
385
- ```
386
- User: "Giờ làm phần activation.js"
387
- AI internal: [MEMORY READ TRIGGER R2 detected - filename mention]
388
- AI scans: brain/* với "activation"
389
- AI finds: "arch-neural-brain-2026-02-22.md"
390
- AI responds: "💡 Từ plan trước: activation.js dùng heap-based BFS với
391
- sigmoid decay. Bắt đầu với SpreadingActivation class..."
392
- ```
393
-
394
- ### Example 4: /brainstorm workflow — KHÔNG trigger W3 prematurely
395
- ```
396
- User: "/brainstorm"
397
- AI internal: [memory-sync SKIP — /brainstorm workflow đang chạy, chưa có BRIEF.md]
398
- AI: [Chạy brainstorm workflow bình thường, hỏi ý tưởng user]
399
- ...
400
- [Sau khi BRIEF.md được tạo]
401
- AI internal: [MEMORY WRITE TRIGGER W3 detected — BRIEF.md exists]
402
- AI saves silently: brain/decisions/arch-[feature]-[date].md
403
- ```
404
-
405
- ---
406
-
407
- ## Self-Evolution Protocol
408
-
409
- After each session, if a memory trigger pattern was missed or a new write/read pattern was discovered:
410
- 1. Append finding to the Learnings section below
411
- 2. Update trigger patterns or salience scores if needed
412
- 3. Never remove existing learnings — only add or refine
413
-
414
- ## Learnings
415
-
416
- _Findings from past sessions. Add new entries as bullet points._
417
-
418
- - `invocation-type: auto` field added to frontmatter for CATALOG.md skill classification.
419
- - W6 (File Edit Tracking) helps detect when CODEBASE.md needs sync — proactive rather than reactive.
420
-
421
- ---
422
-
423
- *memory-sync v2.2.0 — Auto Memory Sync for AWF (Project-Aware, Self-Evolving)*
424
- *Created by Kien AI*
@@ -1,185 +0,0 @@
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*