sanook-cli 0.5.0 → 0.5.2

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 (146) hide show
  1. package/.env.example +161 -3
  2. package/CHANGELOG.md +83 -5
  3. package/README.md +240 -23
  4. package/README.th.md +87 -6
  5. package/dist/approval.js +6 -0
  6. package/dist/bin.js +3045 -210
  7. package/dist/brain-context.js +223 -0
  8. package/dist/brain-doctor.js +318 -0
  9. package/dist/brain-eval.js +186 -0
  10. package/dist/brain-final.js +371 -0
  11. package/dist/brain-review.js +382 -0
  12. package/dist/brain.js +12 -1
  13. package/dist/brand.js +1 -1
  14. package/dist/cli-args.js +152 -0
  15. package/dist/cli-option-values.js +16 -0
  16. package/dist/commands.js +172 -13
  17. package/dist/compaction.js +96 -11
  18. package/dist/config.js +118 -28
  19. package/dist/context-compression.js +191 -0
  20. package/dist/cost.js +49 -15
  21. package/dist/first-run.js +21 -0
  22. package/dist/gateway/auth.js +37 -8
  23. package/dist/gateway/bluebubbles.js +205 -0
  24. package/dist/gateway/config.js +929 -0
  25. package/dist/gateway/deliver.js +357 -0
  26. package/dist/gateway/discord.js +124 -0
  27. package/dist/gateway/email.js +472 -0
  28. package/dist/gateway/googlechat.js +207 -0
  29. package/dist/gateway/homeassistant.js +256 -0
  30. package/dist/gateway/ledger.js +18 -0
  31. package/dist/gateway/line.js +171 -0
  32. package/dist/gateway/lock.js +3 -1
  33. package/dist/gateway/matrix.js +366 -0
  34. package/dist/gateway/mattermost.js +322 -0
  35. package/dist/gateway/ntfy.js +218 -0
  36. package/dist/gateway/schedule.js +31 -4
  37. package/dist/gateway/serve.js +267 -7
  38. package/dist/gateway/server.js +253 -19
  39. package/dist/gateway/service.js +224 -0
  40. package/dist/gateway/session.js +343 -0
  41. package/dist/gateway/signal.js +351 -0
  42. package/dist/gateway/slack.js +124 -0
  43. package/dist/gateway/sms.js +169 -0
  44. package/dist/gateway/targets.js +576 -0
  45. package/dist/gateway/teams.js +106 -0
  46. package/dist/gateway/telegram.js +38 -15
  47. package/dist/gateway/webhooks.js +220 -0
  48. package/dist/gateway/whatsapp.js +230 -0
  49. package/dist/hooks.js +13 -2
  50. package/dist/insights-args.js +35 -0
  51. package/dist/insights.js +86 -0
  52. package/dist/loop.js +123 -24
  53. package/dist/lsp/index.js +23 -5
  54. package/dist/mcp-registry.js +350 -0
  55. package/dist/mcp-server.js +1 -1
  56. package/dist/mcp.js +44 -6
  57. package/dist/memory.js +100 -33
  58. package/dist/orchestrate.js +49 -19
  59. package/dist/personality.js +58 -0
  60. package/dist/providers/codex.js +86 -38
  61. package/dist/providers/keys.js +1 -1
  62. package/dist/providers/models.js +22 -6
  63. package/dist/providers/registry.js +38 -49
  64. package/dist/search/chunk.js +7 -8
  65. package/dist/search/cli.js +75 -0
  66. package/dist/search/embed-store.js +3 -0
  67. package/dist/search/indexer.js +44 -1
  68. package/dist/search/store.js +23 -1
  69. package/dist/session.js +93 -7
  70. package/dist/skill-install.js +29 -12
  71. package/dist/support-dump.js +175 -0
  72. package/dist/tools/edit.js +45 -15
  73. package/dist/tools/git.js +10 -5
  74. package/dist/tools/homeassistant.js +106 -0
  75. package/dist/tools/index.js +5 -0
  76. package/dist/tools/list.js +19 -6
  77. package/dist/tools/permission.js +923 -9
  78. package/dist/tools/read.js +16 -4
  79. package/dist/tools/schedule.js +19 -3
  80. package/dist/tools/search.js +217 -13
  81. package/dist/tools/task.js +18 -7
  82. package/dist/tools/timeout.js +21 -3
  83. package/dist/trust.js +11 -1
  84. package/dist/ui/app.js +57 -11
  85. package/dist/ui/brain-wizard.js +2 -2
  86. package/dist/ui/history.js +37 -5
  87. package/dist/ui/mentions.js +3 -2
  88. package/dist/ui/render.js +55 -15
  89. package/dist/ui/setup.js +107 -10
  90. package/dist/update.js +24 -11
  91. package/dist/worktree.js +175 -4
  92. package/package.json +4 -4
  93. package/second-brain/AGENTS.md +6 -4
  94. package/second-brain/CLAUDE.md +7 -1
  95. package/second-brain/Evals/_Index.md +10 -2
  96. package/second-brain/Evals/quality-ledger.md +9 -1
  97. package/second-brain/Evals/second-brain-benchmarks.md +62 -0
  98. package/second-brain/GEMINI.md +5 -4
  99. package/second-brain/Home.md +1 -1
  100. package/second-brain/Projects/_Index.md +3 -1
  101. package/second-brain/Projects/sanook-cli/_Index.md +26 -0
  102. package/second-brain/Projects/sanook-cli/second-brain-feature-roadmap.md +156 -0
  103. package/second-brain/README.md +1 -1
  104. package/second-brain/Research/2026-06-17-ai-second-brain-method-experiment.md +108 -0
  105. package/second-brain/Research/2026-06-18-ai-token-reduction-frameworks.md +55 -0
  106. package/second-brain/Research/2026-06-18-hermes-cli-second-brain-expansion-research.md +160 -0
  107. package/second-brain/Research/2026-06-18-sanook-mcp-ecosystem-and-ux-roadmap.md +181 -0
  108. package/second-brain/Research/_Index.md +6 -1
  109. package/second-brain/Reviews/2026-06-18-auto-improve-maintenance.md +54 -0
  110. package/second-brain/Reviews/_Index.md +1 -1
  111. package/second-brain/Runbooks/_Index.md +6 -1
  112. package/second-brain/Runbooks/ai-second-brain-operating-sequence.md +108 -0
  113. package/second-brain/SANOOK.md +45 -0
  114. package/second-brain/Sessions/2026-06-17-ai-framework-additional-zones.md +68 -0
  115. package/second-brain/Sessions/2026-06-17-ai-second-brain-sequence-experiment.md +63 -0
  116. package/second-brain/Sessions/2026-06-18-cli-args-release-readiness.md +59 -0
  117. package/second-brain/Sessions/2026-06-18-final-gate-template-final.md +192 -0
  118. package/second-brain/Sessions/2026-06-18-final-gate-template.md +71 -0
  119. package/second-brain/Sessions/2026-06-18-framework-dogfood-permission-and-memory.md +58 -0
  120. package/second-brain/Sessions/2026-06-18-hermes-second-brain-expansion-research.md +52 -0
  121. package/second-brain/Sessions/2026-06-18-mcp-ecosystem-and-sanook-ux-scan.md +81 -0
  122. package/second-brain/Sessions/2026-06-18-sanook-brain-cli-p0-implementation.md +86 -0
  123. package/second-brain/Sessions/2026-06-18-sanook-brain-final-cli-final.md +246 -0
  124. package/second-brain/Sessions/2026-06-18-sanook-brain-final-cli.md +78 -0
  125. package/second-brain/Sessions/2026-06-18-sanook-cli-second-brain-roadmap-correction.md +54 -0
  126. package/second-brain/Sessions/2026-06-18-token-reduction-framework-integration.md +69 -0
  127. package/second-brain/Sessions/_Index.md +15 -1
  128. package/second-brain/Shared/AI-Context-Index.md +22 -0
  129. package/second-brain/Shared/Context-Packs/_Index.md +9 -1
  130. package/second-brain/Shared/Context-Packs/coding-release.md +51 -0
  131. package/second-brain/Shared/Context-Packs/research-to-framework.md +51 -0
  132. package/second-brain/Shared/Context-Packs/second-brain-maintenance.md +41 -0
  133. package/second-brain/Shared/Operating-State/current-state.md +22 -3
  134. package/second-brain/Shared/Scripts/_Index.md +3 -1
  135. package/second-brain/Shared/Scripts/ai-second-brain-method-eval.mjs +198 -0
  136. package/second-brain/Shared/Tech-Standards/_Index.md +4 -1
  137. package/second-brain/Shared/Tech-Standards/mcp-integration-roadmap.md +86 -0
  138. package/second-brain/Shared/Tech-Standards/verification-standard.md +24 -0
  139. package/second-brain/Shared/User-Memory/_Index.md +4 -1
  140. package/second-brain/Shared/User-Memory/response-examples.md +98 -0
  141. package/second-brain/Shared/User-Memory/user-preferences.md +1 -0
  142. package/second-brain/Templates/_Index.md +9 -0
  143. package/second-brain/Templates/final-lite.md +111 -0
  144. package/second-brain/Templates/final.md +231 -0
  145. package/second-brain/Vault Structure Map.md +2 -1
  146. package/skills/structured-output-llm/SKILL.md +1 -1
@@ -0,0 +1,108 @@
1
+ ---
2
+ tags: [research, second-brain, ai, experiment]
3
+ note_type: research-note
4
+ created: 2026-06-17
5
+ updated: 2026-06-17
6
+ parent: "[[Research/_Index]]"
7
+ source::
8
+ - "[[Shared/Scripts/ai-second-brain-method-eval.mjs]]"
9
+ - "https://arxiv.org/abs/2307.03172"
10
+ - "https://arxiv.org/abs/2310.11511"
11
+ - "https://arxiv.org/abs/2404.16130"
12
+ ---
13
+
14
+ # AI Second-Brain Method Experiment — 2026-06-17
15
+
16
+ > คำถามทดลอง: วิธีจัด second-brain แบบไหนทำให้ AI ใช้งาน vault ได้แม่นที่สุด โดยไม่โหลด context เกินจำเป็น?
17
+
18
+ ## Hypothesis
19
+
20
+ วิธีที่ดีที่สุดไม่ใช่การให้ AI โหลดทั้ง vault หรือจำจาก session log แต่คือ:
21
+
22
+ **Single Retrieval Path + JIT Task Rules + Explicit Write Routing + Eval/Consolidation Loop**
23
+
24
+ ชื่อที่ใช้ใน framework: **Scientific Loop Sequence**.
25
+
26
+ ## Method
27
+
28
+ รันสคริปต์:
29
+
30
+ ```bash
31
+ node second-brain/Shared/Scripts/ai-second-brain-method-eval.mjs second-brain
32
+ ```
33
+
34
+ สคริปต์เทียบ 5 วิธี:
35
+
36
+ | Method | แนวคิด |
37
+ |---|---|
38
+ | Session-log only | ใช้ session history เป็น memory หลัก |
39
+ | Folder map only | ใช้ `Vault Structure Map.md` และ index ปลายทาง |
40
+ | Single retrieval index | เริ่มจาก `Shared/AI-Context-Index.md` |
41
+ | Index + JIT context policy | single index + context assembly + โหลดเฉพาะไฟล์จำเป็น |
42
+ | Scientific loop sequence | single index + JIT + write protocol + eval + sleep consolidation + coordination |
43
+
44
+ Scenarios ที่ใช้วัด:
45
+
46
+ 1. เริ่มงานกับ AI โดยไม่หลุด source of truth
47
+ 2. สร้าง/แก้ durable note ให้ถูกที่และค้นเจอภายหลัง
48
+ 3. บันทึก preference/decision/fact โดยไม่ append ซ้ำ
49
+ 4. นำข้อมูลภายนอกเข้า vault แบบปลอด prompt injection
50
+ 5. ทำ sleep-time consolidation และปิด loop ความจำ
51
+ 6. กันหลาย agent ชนกันและส่งต่องานได้
52
+ 7. งานเทคนิคที่ต้อง verify ก่อนสรุป
53
+
54
+ Metric:
55
+
56
+ - **File coverage**: context มีไฟล์ที่ scenario ต้องใช้ไหม
57
+ - **Capability coverage**: วิธีนั้นมี retrieval/routing/eval/memory/coordination ครบไหม
58
+ - **Token economy**: context เฉลี่ยยังใกล้ budget หรือไม่
59
+
60
+ ## Results
61
+
62
+ | Rank | Method | Score | File Coverage | Capability Coverage | Avg Tokens |
63
+ |---:|---|---:|---:|---:|---:|
64
+ | 1 | Scientific loop sequence | 97.0 | 100% | 100% | ~2890 |
65
+ | 2 | Index + JIT context policy | 62.6 | 64% | 43% | ~2235 |
66
+ | 3 | Single retrieval index | 40.6 | 39% | 18% | ~1932 |
67
+ | 4 | Folder map + destination indexes | 20.8 | 13% | 18% | ~2598 |
68
+ | 5 | Session-log only | 16.4 | 6% | 10% | ~313 |
69
+
70
+ ## Interpretation
71
+
72
+ **Winner: Scientific Loop Sequence.**
73
+
74
+ เหตุผล:
75
+
76
+ - ครอบคลุมงาน AI กับ second-brain ได้ครบทุก scenario
77
+ - ลด hallucination เพราะเริ่มจาก single source of truth แล้วค่อย expand context
78
+ - ลด memory rot เพราะ write operation ต้องเลือก ADD/UPDATE/DELETE/NOOP
79
+ - ลด context rot เพราะใช้ `context-assembly-policy` ก่อนโหลด task rules
80
+ - มี feedback loop จริงผ่าน `eval-loop` และ `sleep-time-consolidation`
81
+
82
+ ข้อควรระวัง:
83
+
84
+ - Avg tokens ~2890 สูงกว่า target ~2k
85
+ - บาง scenario สูงเพราะต้องโหลดไฟล์ใหญ่ เช่น `Vault Structure Map.md` และ ingest rules
86
+ - ดังนั้น implementation ต้องใช้แบบ **JIT**: โหลด heading/index ก่อน, expand body เฉพาะเมื่อจำเป็น, และอย่า preload ทุก rule ทุกครั้ง
87
+
88
+ ## Literature Anchor
89
+
90
+ - Lost in the Middle สนับสนุนว่า context ยาวและตำแหน่งกลางทำให้ retrieval/usefulness ลดลง จึงควรวาง load-bearing context ไว้หัว/ท้าย
91
+ - Self-RAG สนับสนุน retrieve-then-critique/evaluate loop แทนการตอบจาก memory ล้วน
92
+ - GraphRAG สนับสนุนการจัดความรู้เป็น graph/index แทนการกองเอกสารแบบ flat
93
+
94
+ ## Decision
95
+
96
+ ใช้ **Scientific Loop Sequence** เป็น default AI operating sequence ของ vault:
97
+
98
+ 1. Frame objective/DoD
99
+ 2. Retrieve hot context via `Shared/AI-Context-Index.md`
100
+ 3. Select AI role for the current phase
101
+ 4. Load task-specific rules JIT
102
+ 5. Act and verify
103
+ 6. Write memory with explicit operation
104
+ 7. Eval if non-trivial
105
+ 8. Consolidate later via sleep-time loop
106
+
107
+ related:: [[Runbooks/ai-second-brain-operating-sequence]]
108
+ up:: [[Research/_Index]]
@@ -0,0 +1,55 @@
1
+ ---
2
+ tags: [research, token-reduction, ai-agent, sanook-cli]
3
+ note_type: research
4
+ created: 2026-06-18
5
+ updated: 2026-06-18
6
+ parent: "[[Research/_Index]]"
7
+ source:
8
+ - https://github.com/microsoft/LLMLingua
9
+ - https://github.com/liyucheng09/Selective_Context
10
+ - https://github.com/chopratejas/headroom
11
+ ---
12
+
13
+ # AI Token Reduction Frameworks for Sanook CLI
14
+
15
+ > Research note for choosing a token-reduction framework/pattern to integrate into Sanook CLI.
16
+
17
+ ## Candidates
18
+
19
+ - Microsoft LLMLingua: strong prompt-compression family, but Python/model-heavy for a Node CLI default.
20
+ - Selective Context: removes low-information lexical units; good fit for a zero-LLM local compressor.
21
+ - Headroom: TypeScript package with Vercel AI SDK adapter, but direct compression requires a running proxy or cloud API key.
22
+
23
+ ## Decision
24
+
25
+ Use a Sanook-native zero-dependency selective context compressor as the default, and expose Headroom as an optional framework mode.
26
+
27
+ Rationale:
28
+
29
+ - Works by default without a Python runtime, model download, proxy, or extra API key.
30
+ - Fits the current Sanook architecture because the biggest waste is stale tool output in multi-step agent loops.
31
+ - Keeps recent tool results full, preserving local correctness while reducing old transcript bloat.
32
+ - Lets users opt into the actual `headroom-ai` Vercel AI SDK adapter when they have a Headroom proxy/cloud compression layer.
33
+
34
+ ## Implementation Shape
35
+
36
+ - New `contextCompression` config: `selective` (default), `headroom`, or `off`.
37
+ - `SANOOK_CONTEXT_COMPRESSION=off` disables it.
38
+ - `SANOOK_CONTEXT_COMPRESSION=headroom` wraps the Vercel AI SDK model with `headroom-ai/vercel-ai`.
39
+ - `SANOOK_HEADROOM_BASE_URL` and `SANOOK_HEADROOM_API_KEY` can point Sanook at the user's Headroom setup.
40
+ - `selectiveCompressText()` keeps head/tail anchors and high-information lines:
41
+ - current user-query matches
42
+ - errors, warnings, failures, tracebacks
43
+ - file paths and line numbers
44
+ - diffs and code structure
45
+ - headings / JSON-like structure
46
+ - rare lexical terms
47
+ - `selectivelyCompressStaleToolResults()` applies it only to old large tool outputs before each model step.
48
+ - Older stale tool outputs get tighter budgets; the newest tail remains full.
49
+
50
+ ## Verification
51
+
52
+ - Unit tests cover preservation of query matches, errors, code/diff structure, unchanged short text, stale-tool compression, recency budgets, and recent-tail preservation.
53
+ - Full validation still needs `typecheck`, full test suite, and build after implementation.
54
+
55
+ up:: [[Research/_Index]]
@@ -0,0 +1,160 @@
1
+ ---
2
+ tags: [research, second-brain, hermes, ai-agent, context-engineering]
3
+ note_type: research-note
4
+ created: 2026-06-18
5
+ updated: 2026-06-18
6
+ parent: "[[Research/_Index]]"
7
+ source::
8
+ - https://github.com/NousResearch/hermes-agent
9
+ - https://hermes-agent.nousresearch.com/docs/user-guide/features/context-files
10
+ - https://hermes-agent.nousresearch.com/docs/user-guide/features/memory
11
+ - https://hermes-agent.nousresearch.com/docs/user-guide/features/skills
12
+ - https://hermes-agent.nousresearch.com/docs/user-guide/features/curator
13
+ - https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents
14
+ - https://docs.langchain.com/oss/python/concepts/memory
15
+ - https://arxiv.org/abs/2304.03442
16
+ - https://arxiv.org/abs/2310.08560
17
+ - https://arxiv.org/abs/2303.11366
18
+ - https://arxiv.org/abs/2210.03629
19
+ - https://fortelabs.com/blog/para/
20
+ related:: [[Runbooks/ai-second-brain-operating-sequence]]
21
+ related:: [[Shared/AI-Context-Index]]
22
+ related:: [[Evals/second-brain-benchmarks]]
23
+ ---
24
+
25
+ # Hermes CLI Second-Brain Expansion Research
26
+
27
+ > Research note for deciding what to add to this second-brain so Hermes CLI can use it better. Created after comparing the current vault structure with Hermes Agent docs, agent memory research, context-engineering guidance, eval patterns, and PARA-style knowledge management. This note becomes stale when Hermes context/memory/skills semantics change materially.
28
+
29
+ ## Bottom Line
30
+
31
+ Scope correction on 2026-06-18: this note is reference material for Hermes compatibility only. If the objective is Sanook CLI itself, use [[Projects/sanook-cli/second-brain-feature-roadmap]] instead.
32
+
33
+ อย่าเพิ่ม root-level folder เยอะตอนนี้. โครงสร้างปัจจุบันมี knowledge pipeline, memory, context packs, evals, coordination, and runbooks ครบกว่าค่าเฉลี่ยแล้ว.
34
+
35
+ สิ่งที่ควรเพิ่มถัดไปคือชั้นที่ทำให้ Hermes ใช้ของที่มีอยู่ได้แม่นขึ้น:
36
+
37
+ 1. `HERMES.md` หรือ `.hermes.md` adapter สำหรับ Hermes CLI โดยเฉพาะ.
38
+ 2. `Shared/Hermes/` หรืออย่างน้อย `Shared/Agent-Adapters/hermes.md` สำหรับ config, memory sync, toolset, and curator policy.
39
+ 3. `Evals/Benchmarks/` สำหรับ benchmark cases แยกเป็นไฟล์เล็กๆ แทนการโตในไฟล์เดียว.
40
+ 4. `Acceptance/Golden-Cases/` สำหรับ input -> expected output ของ Hermes workflows.
41
+ 5. `Reviews/Vault-Health/` สำหรับ scheduled curator-style review ของ vault/context/skills.
42
+
43
+ ## Evidence From Hermes
44
+
45
+ Hermes context files:
46
+
47
+ - Hermes supports `.hermes.md` / `HERMES.md`, `AGENTS.md`, `CLAUDE.md`, `SOUL.md`, `.cursorrules`, and Cursor rule modules.
48
+ - Priority is first-match: `.hermes.md` -> `AGENTS.md` -> `CLAUDE.md` -> `.cursorrules`; `SOUL.md` is separate global identity.
49
+ - Hermes loads one project context type per session, then progressively discovers subdirectory context files as tools touch paths.
50
+ - Context files are security scanned, truncated, and should stay concise with headers, examples, negative constraints, key paths, and stale-context hygiene.
51
+
52
+ Implication for this vault:
53
+
54
+ - Current `AGENTS.md` works as fallback, but Hermes-only usage should prefer a dedicated `HERMES.md` / `.hermes.md` so Hermes does not inherit adapter compromises meant for other agents.
55
+ - Because Hermes progressively discovers subdirectory files, scoped context files can be more useful than one giant root instruction file.
56
+
57
+ Hermes memory:
58
+
59
+ - Built-in memory is deliberately tiny: `MEMORY.md` for agent notes and `USER.md` for user profile, both loaded once as a frozen snapshot at session start.
60
+ - Hermes explicitly separates always-on memory from on-demand session search.
61
+ - Memory writes can be gated with approval, and memory entries should be compact, specific, and non-duplicative.
62
+
63
+ Implication for this vault:
64
+
65
+ - Keep Hermes memory small and use the vault as the long-term source of truth.
66
+ - Add a Hermes memory sync policy: what goes to `~/.hermes/memories/MEMORY.md`, what stays in `Shared/User-Memory`, what is retrieved on demand from vault search/session logs.
67
+
68
+ Hermes skills:
69
+
70
+ - Skills are on-demand knowledge documents with progressive disclosure.
71
+ - `SKILL.md` supports references, templates, scripts, assets, platform restrictions, required environment variables, and verification sections.
72
+ - Hermes can scan external skill directories, but writable external dirs are not a write-protection boundary.
73
+
74
+ Implication for this vault:
75
+
76
+ - Current `.agents/skills/` can become a shared skill source, but it needs an explicit policy for which skills are read-only, owner-authored, or agent-created.
77
+ - Useful repeatable vault workflows should graduate into Hermes skills only after they have examples, pitfalls, and verification.
78
+
79
+ Hermes curator:
80
+
81
+ - The curator tracks skill usage, marks stale skills, archives long-unused skills, and can optionally run an LLM consolidation pass.
82
+ - It has status, dry-run, backup, rollback, pin, and archive commands.
83
+
84
+ Implication for this vault:
85
+
86
+ - Add curator-like vault health reviews: stale context, duplicated rules, unused context packs, benchmark drift, and skills that should be archived or pinned.
87
+
88
+ ## Evidence From Agent Research
89
+
90
+ Context engineering:
91
+
92
+ - Anthropic frames context as finite and context engineering as the task of curating all tokens available to an agent across long-running loops, not just writing better prompts.
93
+ - This supports the current Scientific Loop Sequence and argues for smaller, task-specific retrieval bundles rather than a larger global instruction file.
94
+
95
+ Memory taxonomy:
96
+
97
+ - LangGraph separates short-term thread-scoped memory from long-term memory across conversations, and uses semantic, episodic, and procedural memory categories.
98
+ - Generative Agents stores experiences, synthesizes reflections, and retrieves memories dynamically for planning.
99
+ - MemGPT argues for tiered memory and movement between fast context and slower external memory.
100
+ - Reflexion stores reflective text in episodic memory after feedback to improve future trials.
101
+ - ReAct shows the value of interleaving reasoning/action with external information retrieval.
102
+
103
+ Implication for this vault:
104
+
105
+ - Current folders already map well:
106
+ - semantic memory -> `Learning/`, `Distillations/`, `Entities/`, `Shared/Core-Facts/`
107
+ - episodic memory -> `Sessions/`, `Retrospectives/`, `Traces/`
108
+ - procedural memory -> `Runbooks/`, `Playbooks/`, `Skills/`, `.agents/skills/`
109
+ - eval/reflection memory -> `Evals/`, `Acceptance/`, `Reviews/`
110
+ - The missing piece is not another generic "Resources" folder. It is sharper eval cases, Hermes adapter policy, and scheduled consolidation.
111
+
112
+ PKM / PARA:
113
+
114
+ - PARA's Projects / Areas / Resources / Archives split supports action-oriented retrieval.
115
+ - This vault already extends PARA with AI-specific layers: Evals, Acceptance, Rules, Context-Packs, Provenance, Coordination.
116
+
117
+ Implication for this vault:
118
+
119
+ - Avoid adding broad folders like `Resources/`, `Notes/`, or `AI/`; they would overlap existing canonical homes.
120
+
121
+ ## Gap Analysis
122
+
123
+ | Gap | Current coverage | Recommended addition | Priority |
124
+ |---|---|---|---|
125
+ | Hermes-specific project context | `AGENTS.md` only | `HERMES.md` or `.hermes.md` pointing to hot path and Hermes-only rules | P0 |
126
+ | Hermes memory policy | `Shared/User-Memory`, `Shared/Memory-Inbox`, `USER.md` | `Shared/Hermes/memory-sync-policy.md` or `Shared/Agent-Adapters/hermes-memory.md` | P0 |
127
+ | Hermes skill lifecycle | `.agents/skills`, `Skills/`, `Shared/Rules/skills-admission` | `Shared/Hermes/skill-lifecycle.md` plus first Hermes skill for second-brain maintenance | P1 |
128
+ | Atomic benchmarks | `Evals/second-brain-benchmarks.md` | `Evals/Benchmarks/<case-id>.md` | P1 |
129
+ | Golden fixtures | `Acceptance/golden-case-template.md` | `Acceptance/Golden-Cases/<workflow>.md` | P1 |
130
+ | Scheduled vault health | `Reviews/`, `Runbooks/sleep-time-consolidation.md` | `Reviews/Vault-Health/YYYY-MM-DD.md` | P1 |
131
+ | Prompt-injection trust boundary | `Intake/_Quarantine`, `ingest-quarantine`, Hermes scanner | `Shared/Security/trust-boundaries.md` only if rules grow beyond current files | P2 |
132
+ | Tool inventory and MCP capabilities | `Tools/`, `Shared/mcp-servers`, `Tech-Standards` | `Shared/Hermes/toolsets.md` if Hermes profiles/toolsets become important | P2 |
133
+ | Output artifacts per project | `Projects/<proj>/` role allows deliverables | Add `Projects/<proj>/Artifacts/` only inside active projects with many generated files | P2 |
134
+
135
+ ## Recommended Next Build
136
+
137
+ Best next bundle:
138
+
139
+ 1. Add `second-brain/HERMES.md`.
140
+ 2. Add `second-brain/Shared/Hermes/_Index.md`.
141
+ 3. Add `second-brain/Shared/Hermes/memory-sync-policy.md`.
142
+ 4. Add `second-brain/Shared/Hermes/skill-lifecycle.md`.
143
+ 5. Add `second-brain/Shared/Context-Packs/hermes-cli-vault-maintenance.md`.
144
+ 6. Split 3-5 high-value cases from `Evals/second-brain-benchmarks.md` into `Evals/Benchmarks/`.
145
+
146
+ Implementation caution:
147
+
148
+ - If adding new folders, update [[Vault Structure Map]] and any folder scaffold source such as `src/brain.ts`.
149
+ - If adding only files under existing folders, keep the current taxonomy stable.
150
+ - Do not mirror Hermes `~/.hermes/` wholesale into the vault; keep local runtime state in Hermes home and store only policy, reviewed snapshots, and durable decisions here.
151
+
152
+ ## Do Not Add Yet
153
+
154
+ - `Resources/` root folder: overlaps `Research/`, `Learning/`, and `Distillations/`.
155
+ - `Notes/` root folder: becomes a junk drawer and weakens routing.
156
+ - `AI/` root folder: duplicates `Shared/AI-Context-Index`, agent adapters, rules, and context packs.
157
+ - `Archive/` root folder: `Shared/Archive/` already exists.
158
+ - `Experiments/` root folder: use `Research/`, `Evals/`, or `Sessions/` depending on artifact type.
159
+
160
+ up:: [[Research/_Index]]
@@ -0,0 +1,181 @@
1
+ ---
2
+ tags: [research, mcp, sanook-cli, integration, roadmap]
3
+ note_type: research
4
+ created: 2026-06-18
5
+ updated: 2026-06-18
6
+ parent: "[[Research/_Index]]"
7
+ source:
8
+ - https://registry.modelcontextprotocol.io/openapi.json
9
+ - https://registry.modelcontextprotocol.io/v0/servers
10
+ - https://registry.modelcontextprotocol.io/v0/version
11
+ - https://modelcontextprotocol.io/specification/2025-06-18/basic/transports
12
+ - https://modelcontextprotocol.io/specification/2025-06-18/server/tools
13
+ related:
14
+ - "[[Shared/Tech-Standards/mcp-integration-roadmap]]"
15
+ ---
16
+
17
+ # 2026-06-18 - Sanook MCP Ecosystem and UX Roadmap
18
+
19
+ > Research snapshot for how Sanook CLI currently handles MCP, what the official MCP registry exposes, and which integrations would make Sanook easier to use.
20
+
21
+ ## Current Sanook MCP State
22
+
23
+ Sanook already has a strong MCP foundation:
24
+
25
+ - MCP client: `src/mcp.ts`
26
+ - Loads global `~/.sanook/mcp.json`.
27
+ - Loads project `.sanook/mcp.json` only after project trust.
28
+ - Supports stdio via `command` + `args`.
29
+ - Supports remote Streamable HTTP via `url` + `headers`.
30
+ - Sanitizes server names.
31
+ - Sends minimal safe env to child MCP servers and only passes explicit `cfg.env`.
32
+ - Caps MCP tool output.
33
+ - Merges MCP tools into the main agent as `<server>__<tool>`.
34
+ - MCP server: `src/mcp-server.ts`
35
+ - `sanook mcp serve` exposes `sanook_search`, `sanook_recall`, `sanook_remember`, `sanook_index`, and `sanook_stats`.
36
+ - Uses stdio JSON-RPC and keeps stdout protocol-clean.
37
+ - CLI management: `src/bin.ts`
38
+ - `sanook mcp add <name> <command> [args...]`
39
+ - `sanook mcp add <name> https://host/mcp`
40
+ - `sanook mcp list`
41
+ - `sanook mcp remove <name>`
42
+
43
+ Main gap: Sanook can run MCP servers, but users still need to know the exact package, args, secrets, and safe configuration shape themselves.
44
+
45
+ ## Registry Findings
46
+
47
+ The official registry API is available and healthy:
48
+
49
+ - `GET /v0/version` returned registry `1.7.9`, build time `2026-05-12T21:05:57Z`.
50
+ - `GET /v0/health` returned `status: ok`.
51
+ - OpenAPI exposes list/get/validate/publish/status endpoints under `/v0` and `/v0.1`.
52
+ - Server entries include:
53
+ - `server.name`, `description`, `version`, `repository`, `websiteUrl`
54
+ - `remotes` with `type: streamable-http` or `sse`
55
+ - `packages` with `registryType`, `identifier`, `version`, `runtimeHint`, `transport`
56
+ - `environmentVariables`, `headers`, `packageArguments`, `runtimeArguments`
57
+ - `isRequired`, `isSecret`, `format`, `placeholder`, and default values for setup UX
58
+ - metadata such as `isLatest`
59
+
60
+ This means Sanook can build a first-class MCP installer without hardcoding every server.
61
+
62
+ ## High-Value MCP Categories for Sanook
63
+
64
+ | Category | Examples seen in registry | Why it matters for Sanook |
65
+ |---|---|---|
66
+ | Code hosting | GitLab official remote, GitHub variants | PRs/issues/releases/repo operations. |
67
+ | Local/cloud files | Filesystem variants, remote GCS filesystem | Safer file access outside the workspace, cloud artifacts. |
68
+ | Databases | Postgres, SQLite | Data inspection for app/debug workflows; should default read-only. |
69
+ | Project management | Linear, Jira | Turn user tasks into issue-backed work loops. |
70
+ | Observability | Sentry | Debug production errors from real issue/event context. |
71
+ | Browser/web | Playwright, Browserbase, fetch, Brave/web search | JS-rendered pages, docs extraction, web research. |
72
+ | Team/chat | Slack, Discord | Team context and delivery/notification workflows. |
73
+ | Knowledge/workspace | Notion, Gmail, Google Drive, Obsidian | Import user knowledge into second-brain workflows. |
74
+ | Docs/versioned knowledge | Context7-like docs servers | Better library/API grounding without broad web search. |
75
+ | Infrastructure | Docker, Kubernetes variants | Ops/debug workflows, but needs strict approval gates. |
76
+
77
+ ## Recommended Sanook UX Improvements
78
+
79
+ ### P0: Discover / Install / Test
80
+
81
+ Add registry-backed commands:
82
+
83
+ ```text
84
+ sanook mcp search <query>
85
+ sanook mcp info <server-name>
86
+ sanook mcp install <server-name> [--name alias]
87
+ sanook mcp test [name]
88
+ ```
89
+
90
+ Expected behavior:
91
+
92
+ - `search` calls the official registry, filters latest versions, and shows transport/package choices.
93
+ - `info` shows description, repo, remotes/packages, required env/header secrets, and risk class.
94
+ - `install` converts registry metadata to `~/.sanook/mcp.json`.
95
+ - `test` initializes the server and lists tools without starting an agent turn.
96
+
97
+ ### P1: Setup Wizard from Registry Metadata
98
+
99
+ Use `environmentVariables` and `headers`:
100
+
101
+ - prompt for required secrets without echoing them
102
+ - support `--env KEY=value` and `--header KEY=value`
103
+ - store secrets explicitly only in `~/.sanook/mcp.json`, not inherited process env
104
+ - show a redacted preview before write
105
+
106
+ ### P1: Safer Capability Review
107
+
108
+ After install/test, print:
109
+
110
+ - transport: stdio / remote HTTP
111
+ - package runtime: `npx`, `uvx`, Docker, remote
112
+ - number of tools
113
+ - tool names
114
+ - risk class:
115
+ - read-only
116
+ - file-write
117
+ - network-write
118
+ - database-write
119
+ - infra/admin
120
+
121
+ Then let users enable dangerous servers intentionally.
122
+
123
+ ### P2: Preset Packs
124
+
125
+ Sanook can ship curated packs:
126
+
127
+ ```text
128
+ sanook mcp preset dev
129
+ sanook mcp preset research
130
+ sanook mcp preset pm
131
+ sanook mcp preset ops
132
+ ```
133
+
134
+ Suggested presets:
135
+
136
+ - `dev`: GitHub/GitLab, filesystem, Sentry, Context7/docs
137
+ - `research`: fetch, Brave/web search, docs, Obsidian/GDrive
138
+ - `pm`: Linear/Jira, Slack, Notion
139
+ - `ops`: Postgres read-only, Docker/Kubernetes, Sentry
140
+
141
+ ### P2: Tool Discovery in the REPL
142
+
143
+ Improve `/tools`:
144
+
145
+ - group MCP tools by server
146
+ - show disabled/unreachable servers
147
+ - show how to fix missing env/headers
148
+ - show source config path: global vs project
149
+
150
+ ## Implementation Notes
151
+
152
+ Good fit for Sanook's existing code:
153
+
154
+ - Add a new module `src/mcp-registry.ts`.
155
+ - Keep registry parsing pure/testable.
156
+ - Do not install from arbitrary registry package metadata without showing command/env first.
157
+ - Prefer remote Streamable HTTP when no local runtime is required.
158
+ - Prefer read-only database servers by default.
159
+ - Keep project `.sanook/mcp.json` behind trust, as today.
160
+ - Add tests with mocked fetch and fake MCP servers.
161
+
162
+ ## Suggested First Integrations
163
+
164
+ For this repo and owner's likely workflows:
165
+
166
+ 1. GitLab official remote or GitHub MCP variant: repo/issues/PRs/releases.
167
+ 2. Sentry: production debugging and release verification.
168
+ 3. Linear/Jira: task loop integration if issue tracker is used.
169
+ 4. Postgres read-only: app data inspection.
170
+ 5. Context7/docs + fetch/search: better grounded research.
171
+ 6. Slack/Discord: team/message workflows.
172
+ 7. Google Drive/Gmail/Notion/Obsidian: knowledge intake into second-brain.
173
+
174
+ ## Open Questions
175
+
176
+ - Should Sanook store MCP secrets directly in `mcp.json`, or add a redacted secret store under `~/.sanook/secrets.json`?
177
+ - Should `sanook mcp install` default to global only, with `--project` requiring trust?
178
+ - Should remote OAuth flows be supported directly, or should Sanook only accept bearer tokens/headers first?
179
+ - Should dangerous MCP tool groups be disabled until the user runs `sanook mcp enable <name> --write`?
180
+
181
+ up:: [[Research/_Index]]
@@ -25,6 +25,11 @@ parent: "[[Home]]"
25
25
 
26
26
  > รายละเอียดทุกโฟลเดอร์ + decision rules → [[Vault Structure Map]]
27
27
 
28
- _(ยังว่าง โน้ตในโฟลเดอร์นี้จะถูกลิงก์ที่นี่)_
28
+ ## Research Notes
29
+
30
+ - [[Research/2026-06-17-ai-second-brain-method-experiment]] — ทดลองเปรียบเทียบวิธีใช้ second-brain ร่วมกับ AI และเลือก Scientific Loop Sequence
31
+ - [[Research/2026-06-18-hermes-cli-second-brain-expansion-research]] — research ว่าควรเพิ่มอะไรใน second-brain เพื่อให้ Hermes CLI ใช้ vault ได้ดีขึ้น
32
+ - [[Research/2026-06-18-sanook-mcp-ecosystem-and-ux-roadmap]] — MCP ecosystem scan + Sanook CLI registry/install/test roadmap
33
+ - [[Research/2026-06-18-ai-token-reduction-frameworks]] — compare LLMLingua, Selective Context, and Headroom for Sanook token reduction
29
34
 
30
35
  up:: [[Home]]
@@ -0,0 +1,54 @@
1
+ ---
2
+ tags: [review, maintenance, auto-improve]
3
+ note_type: review
4
+ created: 2026-06-18
5
+ updated: 2026-06-18
6
+ parent: "[[Reviews/_Index]]"
7
+ ---
8
+
9
+ # Auto Improve Maintenance - 2026-06-18
10
+
11
+ > Purpose: Record the local recurring maintenance run, the small improvement chosen, and verification status for future agents.
12
+
13
+ ## Scope
14
+
15
+ Recurring local maintenance run for `sanook-cli`.
16
+
17
+ ## Current State
18
+
19
+ - Existing uncommitted changes already included a `serve --port` missing-value UX fix in `src/cli-args.ts`, search split-option hardening, matching tests, changelog text, and release-readiness notes.
20
+ - Full test baseline passed before this follow-up work.
21
+ - This run consolidated duplicated inline/split CLI option-value handling into `src/cli-option-values.ts`, shared by `parseArgs`, `parseServeArgs`, and `parseSearchArgs`.
22
+ - Parser behavior is intended to stay unchanged by the consolidation; existing focused parser tests cover the touched surfaces.
23
+ - This recurring follow-up added a spawned CLI regression test for `sanook gateway setup ntfy`, covering required split-option missing values and preserving single-dash secret values like `--token -tk_secret`.
24
+
25
+ ## Verification
26
+
27
+ - `npm test` before new edits - 94 files, 810 tests passed.
28
+ - `npm test -- src/search/cli.test.ts` - 1 file, 10 tests passed.
29
+ - `npm run typecheck` - passed.
30
+ - One chained full-suite attempt hit sandbox loopback `EPERM` while another listen probe was running; `npm test -- src/integration.test.ts` passed on rerun.
31
+ - `npm test` after new edits - 94 files, 811 tests passed.
32
+ - `npm run build` - passed.
33
+ - Follow-up baseline `npm test` - 94 files, 811 tests passed.
34
+ - `npm test -- src/cli-args.test.ts src/search/cli.test.ts` - 2 files, 30 tests passed.
35
+ - Follow-up `npm run typecheck` - passed.
36
+ - Follow-up `npm test` after consolidation - 94 files, 811 tests passed.
37
+ - Follow-up `npm run build` - passed.
38
+ - Recurring maintenance baseline `npm test` - 95 files, 814 tests passed.
39
+ - `npm test -- src/gateway-setup-cli.test.ts` - 1 file, 2 tests passed.
40
+ - `npm run typecheck` - passed.
41
+ - Follow-up `npm test` after gateway setup CLI regression coverage - 96 files, 816 tests passed.
42
+ - `npm run build` - passed.
43
+
44
+ ## Follow-up Audit
45
+
46
+ - Reviewed the remaining direct next-argument readers in `src/tools/permission.ts` and `src/bin.ts`.
47
+ - No safe behavior change was made this pass: the `permission.ts` readers intentionally model shell/git option semantics where a following token that begins with `-` can still be the consumed value, and the gateway setup helpers in `bin.ts` may receive secret/token values that begin with `-`.
48
+ - Avoid broad conversion to the shared CLI option helper unless the target command surface has tests proving flag-like values should be rejected.
49
+
50
+ ## Next Candidate
51
+
52
+ Consider extracting a small gateway setup option parser only if more setup command regressions appear; for now the spawned CLI regression coverage protects the known brittle edge without broad parser churn.
53
+
54
+ up:: [[Reviews/_Index]]
@@ -25,6 +25,6 @@ reflection รายงาน (→Retrospectives)
25
25
 
26
26
  > รายละเอียดทุกโฟลเดอร์ + decision rules → [[Vault Structure Map]]
27
27
 
28
- _(ยังว่างโน้ตในโฟลเดอร์นี้จะถูกลิงก์ที่นี่)_
28
+ - [[Reviews/2026-06-18-auto-improve-maintenance]] recurring local maintenance baseline and next candidate
29
29
 
30
30
  up:: [[Home]]
@@ -25,6 +25,11 @@ runnable unit (→Skills)
25
25
 
26
26
  > รายละเอียดทุกโฟลเดอร์ + decision rules → [[Vault Structure Map]]
27
27
 
28
- _(ยังว่าง — โน้ตในโฟลเดอร์นี้จะถูกลิงก์ที่นี่)_
28
+ ## Runbooks
29
+
30
+ - [[Runbooks/ai-second-brain-operating-sequence]] — default sequence สำหรับ AI ทำงานกับ vault จากผลทดลอง 2026-06-17
31
+ - [[Runbooks/eval-loop]] — quality loop หลังงานไม่ trivial
32
+ - [[Runbooks/ingest-quarantine]] — gate สำหรับข้อมูลภายนอก/untrusted content
33
+ - [[Runbooks/sleep-time-consolidation]] — consolidate memory เป็นรอบ
29
34
 
30
35
  up:: [[Home]]