sanook-cli 0.5.1 → 0.5.5
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/.env.example +161 -3
- package/CHANGELOG.md +148 -10
- package/README.md +255 -26
- package/README.th.md +95 -7
- package/dist/approval.js +13 -0
- package/dist/bin.js +3552 -155
- package/dist/brain-consolidate.js +335 -0
- package/dist/brain-context.js +262 -0
- package/dist/brain-doctor.js +318 -0
- package/dist/brain-eval.js +186 -0
- package/dist/brain-final.js +377 -0
- package/dist/brain-metrics.js +277 -0
- package/dist/brain-new.js +402 -0
- package/dist/brain-pack.js +210 -0
- package/dist/brain-repair.js +280 -0
- package/dist/brain-review.js +382 -0
- package/dist/brain.js +15 -1
- package/dist/brand.js +1 -1
- package/dist/cli-args.js +190 -0
- package/dist/cli-option-values.js +16 -0
- package/dist/clipboard.js +65 -0
- package/dist/commands.js +266 -27
- package/dist/compaction.js +96 -11
- package/dist/config.js +149 -33
- package/dist/context-compression.js +191 -0
- package/dist/context-pack.js +145 -0
- package/dist/cost.js +49 -15
- package/dist/dashboard/api-helpers.js +87 -0
- package/dist/dashboard/server.js +179 -0
- package/dist/dashboard/static/app.js +277 -0
- package/dist/dashboard/static/index.html +39 -0
- package/dist/dashboard/static/styles.css +85 -0
- package/dist/diff.js +10 -2
- package/dist/first-run.js +21 -0
- package/dist/gateway/auth.js +49 -9
- package/dist/gateway/bluebubbles.js +205 -0
- package/dist/gateway/config.js +929 -0
- package/dist/gateway/deliver.js +399 -0
- package/dist/gateway/discord.js +124 -0
- package/dist/gateway/doctor.js +456 -0
- package/dist/gateway/email.js +501 -0
- package/dist/gateway/googlechat.js +207 -0
- package/dist/gateway/homeassistant.js +256 -0
- package/dist/gateway/ledger.js +38 -1
- package/dist/gateway/line.js +171 -0
- package/dist/gateway/lock.js +3 -1
- package/dist/gateway/matrix.js +366 -0
- package/dist/gateway/mattermost.js +322 -0
- package/dist/gateway/ntfy.js +218 -0
- package/dist/gateway/schedule.js +31 -4
- package/dist/gateway/serve.js +267 -7
- package/dist/gateway/server.js +253 -19
- package/dist/gateway/service.js +224 -0
- package/dist/gateway/session.js +362 -0
- package/dist/gateway/signal.js +351 -0
- package/dist/gateway/slack.js +124 -0
- package/dist/gateway/sms.js +169 -0
- package/dist/gateway/targets.js +576 -0
- package/dist/gateway/teams.js +106 -0
- package/dist/gateway/telegram.js +38 -15
- package/dist/gateway/webhooks.js +220 -0
- package/dist/gateway/whatsapp.js +230 -0
- package/dist/hooks.js +13 -2
- package/dist/hotkeys.js +21 -0
- package/dist/i18n/en.js +98 -0
- package/dist/i18n/index.js +19 -0
- package/dist/i18n/th.js +98 -0
- package/dist/i18n/types.js +1 -0
- package/dist/insights-args.js +55 -0
- package/dist/insights.js +86 -0
- package/dist/knowledge.js +55 -29
- package/dist/loop.js +157 -29
- package/dist/lsp/index.js +23 -5
- package/dist/mcp-hub.js +33 -0
- package/dist/mcp-registry.js +494 -0
- package/dist/mcp-risk.js +71 -0
- package/dist/mcp-server.js +1 -1
- package/dist/mcp.js +120 -10
- package/dist/memory-log.js +90 -0
- package/dist/memory-store.js +37 -1
- package/dist/memory.js +148 -37
- package/dist/model-picker.js +58 -0
- package/dist/orchestrate.js +51 -19
- package/dist/personality.js +58 -0
- package/dist/plan-handoff.js +17 -0
- package/dist/polyglot.js +162 -0
- package/dist/process-runner.js +96 -0
- package/dist/project-init.js +91 -0
- package/dist/project-registry.js +143 -0
- package/dist/project-scaffold.js +124 -0
- package/dist/prompt-size.js +155 -0
- package/dist/providers/codex-login.js +138 -0
- package/dist/providers/codex.js +89 -43
- package/dist/providers/keys.js +22 -1
- package/dist/providers/models.js +2 -2
- package/dist/providers/registry.js +14 -47
- package/dist/search/chunk.js +7 -8
- package/dist/search/cli.js +83 -0
- package/dist/search/embed-store.js +3 -0
- package/dist/search/embedding-config.js +22 -0
- package/dist/search/engine.js +2 -13
- package/dist/search/indexer.js +44 -1
- package/dist/search/store.js +23 -1
- package/dist/session-distill.js +84 -0
- package/dist/session.js +92 -16
- package/dist/skill-install.js +53 -13
- package/dist/skills.js +33 -0
- package/dist/slash-completion.js +155 -0
- package/dist/support-dump.js +206 -0
- package/dist/tool-catalog.js +59 -0
- package/dist/tools/edit.js +45 -15
- package/dist/tools/git.js +10 -5
- package/dist/tools/homeassistant.js +106 -0
- package/dist/tools/index.js +10 -0
- package/dist/tools/list.js +19 -6
- package/dist/tools/permission.js +992 -12
- package/dist/tools/polyglot.js +126 -0
- package/dist/tools/read.js +16 -4
- package/dist/tools/sandbox.js +38 -13
- package/dist/tools/schedule.js +19 -3
- package/dist/tools/search.js +226 -15
- package/dist/tools/task.js +40 -9
- package/dist/tools/timeout.js +23 -3
- package/dist/tools/web-fetch-tool.js +33 -0
- package/dist/trust.js +11 -1
- package/dist/turn-retrieval.js +83 -0
- package/dist/ui/app.js +878 -32
- package/dist/ui/banner.js +78 -4
- package/dist/ui/history.js +37 -5
- package/dist/ui/markdown.js +122 -0
- package/dist/ui/mentions.js +3 -2
- package/dist/ui/overlay.js +496 -0
- package/dist/ui/queue.js +23 -0
- package/dist/ui/render.js +20 -1
- package/dist/ui/session-panel.js +115 -0
- package/dist/ui/setup-providers.js +40 -0
- package/dist/ui/setup.js +172 -46
- package/dist/ui/status.js +142 -0
- package/dist/ui/thinking-panel.js +36 -0
- package/dist/ui/tool-trail.js +97 -0
- package/dist/ui/transcript.js +26 -0
- package/dist/ui/useBusyElapsed.js +19 -0
- package/dist/ui/useEditor.js +144 -5
- package/dist/ui/useGitBranch.js +57 -0
- package/dist/update.js +56 -17
- package/dist/web-fetch.js +637 -0
- package/dist/web-surface.js +190 -0
- package/dist/worktree.js +175 -4
- package/package.json +5 -5
- package/second-brain/AGENTS.md +6 -4
- package/second-brain/CLAUDE.md +7 -1
- package/second-brain/Evals/_Index.md +10 -2
- package/second-brain/Evals/quality-ledger.md +9 -1
- package/second-brain/Evals/second-brain-benchmarks.md +62 -0
- package/second-brain/GEMINI.md +5 -4
- package/second-brain/Home.md +1 -1
- package/second-brain/Projects/_Index.md +19 -4
- package/second-brain/Projects/sanook-cli/_Index.md +30 -0
- package/second-brain/Projects/sanook-cli/context.md +35 -0
- package/second-brain/Projects/sanook-cli/current-state.md +32 -0
- package/second-brain/Projects/sanook-cli/overview.md +41 -0
- package/second-brain/Projects/sanook-cli/repo.md +34 -0
- package/second-brain/Projects/sanook-cli/second-brain-feature-roadmap.md +197 -0
- package/second-brain/README.md +1 -1
- package/second-brain/Research/2026-06-17-ai-second-brain-method-experiment.md +108 -0
- package/second-brain/Research/2026-06-18-ai-token-reduction-frameworks.md +55 -0
- package/second-brain/Research/2026-06-18-hermes-cli-second-brain-expansion-research.md +160 -0
- package/second-brain/Research/2026-06-18-hermes-tui-parity-map.md +129 -0
- package/second-brain/Research/2026-06-18-sanook-mcp-ecosystem-and-ux-roadmap.md +181 -0
- package/second-brain/Research/2026-06-19-hermes-python-architecture-for-sanook.md +49 -0
- package/second-brain/Research/2026-06-19-terminal-ui-brand-research.md +52 -0
- package/second-brain/Research/_Index.md +8 -1
- package/second-brain/Reviews/2026-06-18-auto-improve-maintenance.md +54 -0
- package/second-brain/Reviews/_Index.md +1 -1
- package/second-brain/Runbooks/_Index.md +6 -1
- package/second-brain/Runbooks/ai-second-brain-operating-sequence.md +108 -0
- package/second-brain/SANOOK.md +45 -0
- package/second-brain/Sessions/2026-06-17-ai-framework-additional-zones.md +68 -0
- package/second-brain/Sessions/2026-06-17-ai-second-brain-sequence-experiment.md +63 -0
- package/second-brain/Sessions/2026-06-18-cli-args-release-readiness.md +59 -0
- package/second-brain/Sessions/2026-06-18-final-gate-template-final.md +192 -0
- package/second-brain/Sessions/2026-06-18-final-gate-template.md +71 -0
- package/second-brain/Sessions/2026-06-18-framework-dogfood-permission-and-memory.md +58 -0
- package/second-brain/Sessions/2026-06-18-hermes-second-brain-expansion-research.md +52 -0
- package/second-brain/Sessions/2026-06-18-mcp-ecosystem-and-sanook-ux-scan.md +81 -0
- package/second-brain/Sessions/2026-06-18-sanook-brain-cli-p0-implementation.md +86 -0
- package/second-brain/Sessions/2026-06-18-sanook-brain-final-cli-final.md +246 -0
- package/second-brain/Sessions/2026-06-18-sanook-brain-final-cli.md +78 -0
- package/second-brain/Sessions/2026-06-18-sanook-cli-second-brain-roadmap-correction.md +54 -0
- package/second-brain/Sessions/2026-06-18-token-reduction-framework-integration.md +69 -0
- package/second-brain/Sessions/_Index.md +15 -1
- package/second-brain/Shared/AI-Context-Index.md +22 -0
- package/second-brain/Shared/Context-Packs/_Index.md +9 -1
- package/second-brain/Shared/Context-Packs/coding-release.md +51 -0
- package/second-brain/Shared/Context-Packs/research-to-framework.md +51 -0
- package/second-brain/Shared/Context-Packs/second-brain-maintenance.md +41 -0
- package/second-brain/Shared/Operating-State/current-state.md +14 -4
- package/second-brain/Shared/Scripts/_Index.md +3 -1
- package/second-brain/Shared/Scripts/ai-second-brain-method-eval.mjs +198 -0
- package/second-brain/Shared/Tech-Standards/_Index.md +6 -1
- package/second-brain/Shared/Tech-Standards/mcp-integration-roadmap.md +86 -0
- package/second-brain/Shared/Tech-Standards/polyglot-runtime-strategy.md +46 -0
- package/second-brain/Shared/Tech-Standards/verification-standard.md +24 -0
- package/second-brain/Shared/Tech-Standards/web-search-grounding-policy.md +70 -0
- package/second-brain/Shared/User-Memory/_Index.md +4 -1
- package/second-brain/Shared/User-Memory/response-examples.md +98 -0
- package/second-brain/Shared/User-Memory/user-preferences.md +1 -0
- package/second-brain/Templates/_Index.md +9 -0
- package/second-brain/Templates/final-lite.md +111 -0
- package/second-brain/Templates/final.md +231 -0
- package/second-brain/Templates/project-workspace/_Index.md +31 -0
- package/second-brain/Templates/project-workspace/context.md +28 -0
- package/second-brain/Templates/project-workspace/current-state.md +29 -0
- package/second-brain/Templates/project-workspace/overview.md +39 -0
- package/second-brain/Templates/project-workspace/repo.md +33 -0
- package/second-brain/Vault Structure Map.md +2 -1
- package/skills/structured-output-llm/SKILL.md +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
tags: [index, moc, project, sanook-cli]
|
|
3
|
+
note_type: moc
|
|
4
|
+
created: 2026-06-18
|
|
5
|
+
updated: 2026-06-20
|
|
6
|
+
parent: "[[Projects/_Index]]"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Sanook CLI
|
|
10
|
+
|
|
11
|
+
> Project workspace for Sanook CLI product decisions, implementation plans, and current project-specific state.
|
|
12
|
+
|
|
13
|
+
## Notes
|
|
14
|
+
|
|
15
|
+
- [[Projects/sanook-cli/overview]] — goal, scope, stack, verify
|
|
16
|
+
- [[Projects/sanook-cli/current-state]] — NOW / blockers / next
|
|
17
|
+
- [[Projects/sanook-cli/context]] — architecture + conventions for AI
|
|
18
|
+
- [[Projects/sanook-cli/repo]] — repo path mapping (Sanook auto-detect)
|
|
19
|
+
- [[Projects/sanook-cli/second-brain-feature-roadmap]] — second-brain CLI roadmap
|
|
20
|
+
|
|
21
|
+
## AI Routing Contract
|
|
22
|
+
|
|
23
|
+
- ก่อนเขียน: ใช้โฟลเดอร์นี้เฉพาะงานที่เกี่ยวกับ Sanook CLI product/codebase โดยตรง
|
|
24
|
+
- ก่อนสร้างไฟล์ใหม่: ค้นหา note เดิมใน `Projects/sanook-cli/` ก่อน เพื่อ merge/update แทน append ซ้ำ
|
|
25
|
+
- เมื่อสร้างโน้ตในโฟลเดอร์นี้: ตั้ง `parent: "[[Projects/sanook-cli/_Index]]"` และท้ายไฟล์ `up:: [[Projects/sanook-cli/_Index]]`
|
|
26
|
+
- หลังเขียน: เชื่อม link ไป session/source/code path ที่เกี่ยวข้อง และอัปเดต index นี้ถ้าโน้ตควรถูกค้นเจอในอนาคต
|
|
27
|
+
|
|
28
|
+
> รายละเอียดทุกโฟลเดอร์ + decision rules → [[Vault Structure Map]]
|
|
29
|
+
|
|
30
|
+
up:: [[Projects/_Index]]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
tags: [project, context, sanook-cli]
|
|
3
|
+
note_type: project-context
|
|
4
|
+
created: 2026-06-20
|
|
5
|
+
updated: 2026-06-20
|
|
6
|
+
parent: "[[Projects/sanook-cli/_Index]]"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
> Stable AI context — architecture, conventions, and gotchas before editing Sanook CLI code.
|
|
10
|
+
|
|
11
|
+
# Context — Sanook CLI
|
|
12
|
+
|
|
13
|
+
> สิ่งที่ AI ต้องรู้ก่อนแตะโค้ด
|
|
14
|
+
|
|
15
|
+
## Architecture
|
|
16
|
+
|
|
17
|
+
- **Entry:** `src/bin.ts` → CLI routing; `src/loop.ts` → agent loop (Vercel AI SDK)
|
|
18
|
+
- **Brain:** `src/memory.ts`, `src/brain-*.ts`, `src/project-registry.ts` — vault context + project detect
|
|
19
|
+
- **Search:** `src/search/` — BM25 + optional semantic; indexes vault + memory + sessions + skills
|
|
20
|
+
- **Bundled vault:** `second-brain/` ships with npm; user `brainPath` usually points here or a copy
|
|
21
|
+
|
|
22
|
+
## Conventions
|
|
23
|
+
|
|
24
|
+
- Branch: `main`
|
|
25
|
+
- Verify: `npm run typecheck && npm test` (1210+ tests)
|
|
26
|
+
- Commit style: complete sentences, focus on why
|
|
27
|
+
- Minimize diff scope; match existing TS patterns; Thai comments OK in CLI strings
|
|
28
|
+
|
|
29
|
+
## Gotchas
|
|
30
|
+
|
|
31
|
+
- `brainPath` in `~/.sanook/config.json` — brain CLI commands need it configured
|
|
32
|
+
- Bundled vault path in repo: `second-brain/` (not only user's external vault)
|
|
33
|
+
- `loadBrainContext(cwd)` auto-injects matching `Projects/<slug>/` when cwd is inside `repo_path`
|
|
34
|
+
|
|
35
|
+
up:: [[Projects/sanook-cli/_Index]]
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
tags: [project, operating-state, sanook-cli]
|
|
3
|
+
note_type: project-state
|
|
4
|
+
status: active
|
|
5
|
+
created: 2026-06-20
|
|
6
|
+
updated: 2026-06-20
|
|
7
|
+
parent: "[[Projects/sanook-cli/_Index]]"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
> Live project status — update when NOW / blockers / next actions change.
|
|
11
|
+
|
|
12
|
+
# Current State — Sanook CLI
|
|
13
|
+
|
|
14
|
+
> สถานะ project ปัจจุบัน (อัปเดตเมื่อ priority/blocker เปลี่ยน)
|
|
15
|
+
|
|
16
|
+
## Now
|
|
17
|
+
|
|
18
|
+
- 2026-06-20: Release **0.5.3** — brain pack/new/repair/consolidate/metrics, MCP enable/risk, gateway doctor, web_fetch, sanook init, TUI session/transcript polish
|
|
19
|
+
- 2026-06-20: **Project workspace auto-detect** — cwd ↔ `Projects/<slug>/repo.md` injects hot project context into agent prompt
|
|
20
|
+
- Active focus: multi-project vault under `Projects/` as single Sanook brain for all repos
|
|
21
|
+
|
|
22
|
+
## Blockers
|
|
23
|
+
|
|
24
|
+
_(none)_
|
|
25
|
+
|
|
26
|
+
## Next
|
|
27
|
+
|
|
28
|
+
- [ ] Dogfood project auto-detect on every repo under `Projects/`
|
|
29
|
+
- [ ] Add next project workspace with `sanook brain new project --title "..." --repo /path`
|
|
30
|
+
- [ ] Scheduled `sanook brain consolidate --apply` (weekly hook)
|
|
31
|
+
|
|
32
|
+
up:: [[Projects/sanook-cli/_Index]]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
tags: [project, project-overview, sanook-cli]
|
|
3
|
+
note_type: project-overview
|
|
4
|
+
status: active
|
|
5
|
+
created: 2026-06-20
|
|
6
|
+
updated: 2026-06-20
|
|
7
|
+
parent: "[[Projects/sanook-cli/_Index]]"
|
|
8
|
+
repo_path: /Users/chawakornbuasontorn/dev/sanook-cli
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
> Project overview — goal, scope, stack, and verify commands for Sanook CLI.
|
|
12
|
+
|
|
13
|
+
# Sanook CLI
|
|
14
|
+
|
|
15
|
+
## เป้าหมาย (Goal)
|
|
16
|
+
|
|
17
|
+
Terminal AI coding agent (BYOK) with durable second-brain memory across sessions — the moat vs Claude Code / Codex / Gemini CLI.
|
|
18
|
+
|
|
19
|
+
## Scope / Non-goals
|
|
20
|
+
|
|
21
|
+
- In scope: agent loop, MCP, gateway, second-brain vault tooling, search, TUI
|
|
22
|
+
- Out of scope: hosted SaaS, OAuth/subscription key reuse, Hermes full TUI port
|
|
23
|
+
|
|
24
|
+
## Tech / Stack
|
|
25
|
+
|
|
26
|
+
- Node ≥ 22, TypeScript strict, Vercel AI SDK 6, Ink REPL
|
|
27
|
+
- Vitest CI, bundled `second-brain/` vault template ships with npm package
|
|
28
|
+
|
|
29
|
+
## Verify
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm run typecheck && npm test
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Related
|
|
36
|
+
|
|
37
|
+
- Repo map: [[Projects/sanook-cli/repo]]
|
|
38
|
+
- Live status: [[Projects/sanook-cli/current-state]]
|
|
39
|
+
- Roadmap: [[Projects/sanook-cli/second-brain-feature-roadmap]]
|
|
40
|
+
|
|
41
|
+
up:: [[Projects/sanook-cli/_Index]]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
tags: [project, repo, sanook-cli]
|
|
3
|
+
note_type: project-repo
|
|
4
|
+
created: 2026-06-20
|
|
5
|
+
updated: 2026-06-20
|
|
6
|
+
parent: "[[Projects/sanook-cli/_Index]]"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
> Machine-readable repo mapping — Sanook auto-detects this project when cwd is inside the repo.
|
|
10
|
+
|
|
11
|
+
# Repo — Sanook CLI
|
|
12
|
+
|
|
13
|
+
> Machine-readable repo mapping for Sanook project auto-detect.
|
|
14
|
+
|
|
15
|
+
repo_path: /Users/chawakornbuasontorn/dev/sanook-cli
|
|
16
|
+
default_branch: main
|
|
17
|
+
verify: npm run typecheck && npm test
|
|
18
|
+
|
|
19
|
+
## Paths
|
|
20
|
+
|
|
21
|
+
| What | Path |
|
|
22
|
+
|---|---|
|
|
23
|
+
| Repository | `/Users/chawakornbuasontorn/dev/sanook-cli` |
|
|
24
|
+
| Vault (bundled) | `second-brain/` |
|
|
25
|
+
| Project notes | `second-brain/Projects/sanook-cli/` |
|
|
26
|
+
|
|
27
|
+
## Commands
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
cd /Users/chawakornbuasontorn/dev/sanook-cli
|
|
31
|
+
npm run typecheck && npm test
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
up:: [[Projects/sanook-cli/_Index]]
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
tags: [project, sanook-cli, second-brain, roadmap]
|
|
3
|
+
note_type: project-overview
|
|
4
|
+
created: 2026-06-18
|
|
5
|
+
updated: 2026-06-20
|
|
6
|
+
parent: "[[Projects/sanook-cli/_Index]]"
|
|
7
|
+
source::
|
|
8
|
+
- src/bin.ts
|
|
9
|
+
- src/brain.ts
|
|
10
|
+
- src/memory.ts
|
|
11
|
+
- src/knowledge.ts
|
|
12
|
+
- src/mcp-server.ts
|
|
13
|
+
- src/search/indexer.ts
|
|
14
|
+
- src/brain-pack.ts
|
|
15
|
+
- src/brain-new.ts
|
|
16
|
+
- src/brain-repair.ts
|
|
17
|
+
- src/brain-consolidate.ts
|
|
18
|
+
- src/brain-metrics.ts
|
|
19
|
+
- src/context-pack.ts
|
|
20
|
+
- second-brain/SANOOK.md
|
|
21
|
+
related:: [[Research/2026-06-18-hermes-cli-second-brain-expansion-research]]
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# Sanook CLI Second-Brain Feature Roadmap
|
|
25
|
+
|
|
26
|
+
> Implementation roadmap for doing the second-brain work inside Sanook CLI itself. This supersedes Hermes-specific next actions unless the task is explicitly about Hermes compatibility.
|
|
27
|
+
|
|
28
|
+
## Current Sanook Capabilities
|
|
29
|
+
|
|
30
|
+
- `sanook brain init [path]` scaffolds the vault, writes `SANOOK.md`, and stores `brainPath`.
|
|
31
|
+
- `wireBrainMcp()` adds a filesystem MCP server for the vault under `~/.sanook/mcp.json`.
|
|
32
|
+
- `buildBrainContext()` injects `Shared/AI-Context-Index.md`, `current-state.md`, Memory-Inbox candidates, and **auto-selected context packs** into agent context.
|
|
33
|
+
- `remember` writes to Sanook memory store and routes facts into vault Memory-Inbox.
|
|
34
|
+
- Headless sessions append a daily worklog into `Sessions/`.
|
|
35
|
+
- `sanook index` incrementally indexes vault + memory + sessions + skills.
|
|
36
|
+
- `sanook search` gives BM25 plus optional semantic/hybrid search over the unified index.
|
|
37
|
+
- `sanook mcp serve` exposes `sanook_search`, `sanook_recall`, `sanook_remember`, `sanook_index`, and `sanook_stats`.
|
|
38
|
+
- `sanook brain pack list|show`, `brain new`, `brain repair`, `brain consolidate`, and `brain metrics` operate on the configured vault from the CLI.
|
|
39
|
+
|
|
40
|
+
## Correct Direction
|
|
41
|
+
|
|
42
|
+
Do not make the next step `HERMES.md`. For Sanook CLI, the better work is:
|
|
43
|
+
|
|
44
|
+
1. Make Sanook able to inspect and repair its own second-brain.
|
|
45
|
+
2. Make Sanook able to assemble task-focused context from the vault.
|
|
46
|
+
3. Make Sanook able to run lightweight evals against the vault.
|
|
47
|
+
4. Keep the scaffold taxonomy stable until a command proves a new folder is necessary.
|
|
48
|
+
|
|
49
|
+
## P0 Features
|
|
50
|
+
|
|
51
|
+
### `sanook brain doctor`
|
|
52
|
+
|
|
53
|
+
Status: implemented.
|
|
54
|
+
|
|
55
|
+
Check the vault itself, not just installation:
|
|
56
|
+
|
|
57
|
+
- `brainPath` configured and exists.
|
|
58
|
+
- Hot files exist: `SANOOK.md`, `Shared/AI-Context-Index.md`, `Vault Structure Map.md`, `Shared/Operating-State/current-state.md`.
|
|
59
|
+
- Every markdown seed has purpose blockquote, `parent`, and `up::` where expected.
|
|
60
|
+
- `Vault Structure Map.md` mentions every `FOLDERS[]` entry.
|
|
61
|
+
- Search index exists and is fresh enough compared with vault mtimes.
|
|
62
|
+
- MCP wiring points to the configured vault.
|
|
63
|
+
|
|
64
|
+
### `sanook brain context [--task "..."]`
|
|
65
|
+
|
|
66
|
+
Status: implemented.
|
|
67
|
+
|
|
68
|
+
Show the exact context Sanook would inject or retrieve:
|
|
69
|
+
|
|
70
|
+
- Hot context sources and character counts.
|
|
71
|
+
- Optional task query that runs search and prints top vault/session/skill hits.
|
|
72
|
+
- Clear warning when context is stale, too large, or missing expected files.
|
|
73
|
+
|
|
74
|
+
### `sanook brain eval`
|
|
75
|
+
|
|
76
|
+
Status: implemented.
|
|
77
|
+
|
|
78
|
+
Turn `Evals/second-brain-benchmarks.md` into a runnable sanity check:
|
|
79
|
+
|
|
80
|
+
- Static cases: required files, routing links, memory policy, index presence.
|
|
81
|
+
- Retrieval cases: search for known benchmark phrases and verify expected files appear.
|
|
82
|
+
- Output pass/partial/fail with file evidence.
|
|
83
|
+
|
|
84
|
+
## P1 Features
|
|
85
|
+
|
|
86
|
+
### `sanook brain review`
|
|
87
|
+
|
|
88
|
+
Status: implemented.
|
|
89
|
+
|
|
90
|
+
Curator-style health review for the vault:
|
|
91
|
+
|
|
92
|
+
- Stale context packs.
|
|
93
|
+
- Duplicate or contradictory memory candidates.
|
|
94
|
+
- Sessions without index entries.
|
|
95
|
+
- Evals that have not been updated after framework changes.
|
|
96
|
+
- Markdown routing hygiene: purpose blockquote, `parent`, and `up::`.
|
|
97
|
+
|
|
98
|
+
### `sanook brain pack list|show`
|
|
99
|
+
|
|
100
|
+
Status: implemented (2026-06-20).
|
|
101
|
+
|
|
102
|
+
- List available packs with descriptions and index link status.
|
|
103
|
+
- Show pack sources, load order, done criteria, and expected use cases.
|
|
104
|
+
- Agent auto-selects a pack via `buildBrainContext({ taskQuery })` and per-turn retrieval when the query matches a pack.
|
|
105
|
+
|
|
106
|
+
### `sanook brain new <type>`
|
|
107
|
+
|
|
108
|
+
Status: implemented (2026-06-20).
|
|
109
|
+
|
|
110
|
+
Template-backed note creation:
|
|
111
|
+
|
|
112
|
+
- `session`, `bug`, `handoff`, `project`, `golden-case`, `checklist`.
|
|
113
|
+
- Reads destination `_Index.md`, fills frontmatter, and prevents wrong-folder drift.
|
|
114
|
+
|
|
115
|
+
### `sanook brain consolidate`
|
|
116
|
+
|
|
117
|
+
Status: implemented (2026-06-20).
|
|
118
|
+
|
|
119
|
+
Sleep-time consolidation runner based on `Runbooks/sleep-time-consolidation.md`:
|
|
120
|
+
|
|
121
|
+
- Inbox routing/dedup, stale → archive, retrieval eval, optional auto-memory merge.
|
|
122
|
+
- Dry-run by default; `--apply` / `--apply --archive` / `--memory` for writes.
|
|
123
|
+
|
|
124
|
+
## P2 Features
|
|
125
|
+
|
|
126
|
+
- `sanook brain export --for claude|gemini|codex|hermes` for adapter files only when explicitly needed.
|
|
127
|
+
- `sanook brain metrics` — **implemented (2026-06-20)**: counts, stale notes, index freshness, retrieval coverage.
|
|
128
|
+
- `sanook brain repair` — **implemented (2026-06-20)**: safe one-line fixes after `doctor`/`review` (purpose blockquote, `parent`, `up::`, pack links, scaffold folders).
|
|
129
|
+
|
|
130
|
+
## Folder Policy
|
|
131
|
+
|
|
132
|
+
No new root folder is needed yet.
|
|
133
|
+
|
|
134
|
+
Add folders only when a Sanook command needs stable output:
|
|
135
|
+
|
|
136
|
+
- `Evals/Benchmarks/` when `sanook brain eval` wants per-case files.
|
|
137
|
+
- `Acceptance/Golden-Cases/` when golden fixtures multiply.
|
|
138
|
+
- `Reviews/Vault-Health/` when `sanook brain review` starts writing scheduled reports. The current command is read-only, so no new folder is needed yet.
|
|
139
|
+
|
|
140
|
+
Avoid broad folders:
|
|
141
|
+
|
|
142
|
+
- No `Resources/`
|
|
143
|
+
- No `Notes/`
|
|
144
|
+
- No root `AI/`
|
|
145
|
+
- No root `Experiments/`
|
|
146
|
+
|
|
147
|
+
## First Implementation Slice
|
|
148
|
+
|
|
149
|
+
Completed on 2026-06-18:
|
|
150
|
+
|
|
151
|
+
1. Added `src/brain-doctor.ts` with pure check functions and CLI wiring.
|
|
152
|
+
2. Added `src/brain-context.ts` so Sanook can inspect the exact prompt context and task retrieval hits.
|
|
153
|
+
3. Added `src/brain-eval.ts` as a runnable benchmark sanity checker over `Evals/second-brain-benchmarks.md`.
|
|
154
|
+
4. Updated shell/REPL help and changelog.
|
|
155
|
+
5. Verified with targeted second-brain tests and typecheck.
|
|
156
|
+
|
|
157
|
+
## Second Implementation Slice
|
|
158
|
+
|
|
159
|
+
Completed on 2026-06-18:
|
|
160
|
+
|
|
161
|
+
1. Added `src/brain-review.ts` for curator-style vault review.
|
|
162
|
+
2. Wired `sanook brain review [--no-hygiene]` into CLI and help.
|
|
163
|
+
3. Updated generated `Shared/Context-Packs/_Index.md` to link bundled context packs.
|
|
164
|
+
4. Verified with review/scaffold/memory tests and typecheck.
|
|
165
|
+
|
|
166
|
+
## Third Implementation Slice
|
|
167
|
+
|
|
168
|
+
Completed on 2026-06-20 (release 0.5.3):
|
|
169
|
+
|
|
170
|
+
1. Added `src/brain-pack.ts` — `sanook brain pack list|show`.
|
|
171
|
+
2. Added `src/brain-new.ts` — `sanook brain new <type>`.
|
|
172
|
+
3. Added `src/brain-repair.ts` — `sanook brain repair [--dry-run]`.
|
|
173
|
+
4. Added `src/brain-consolidate.ts` — `sanook brain consolidate [--apply]`.
|
|
174
|
+
5. Added `src/brain-metrics.ts` — `sanook brain metrics`.
|
|
175
|
+
6. Added `src/context-pack.ts` — pack catalog + auto-select in `buildBrainContext()` / `buildTurnRetrieval()`.
|
|
176
|
+
7. Verified with targeted tests, full suite (1210 tests), and typecheck.
|
|
177
|
+
|
|
178
|
+
## Next Implementation Slice
|
|
179
|
+
|
|
180
|
+
Best next code slice:
|
|
181
|
+
|
|
182
|
+
1. Scheduled `sanook brain consolidate --apply` hook/cron integration for unattended sleep-time loops.
|
|
183
|
+
2. Richer pack auto-select (user-defined packs beyond bundled three) with `brain pack` discoverability in setup wizard.
|
|
184
|
+
3. `sanook brain export --for claude|gemini|codex|hermes` when adapter portability is explicitly needed.
|
|
185
|
+
|
|
186
|
+
## Project Portfolio (2026-06-20)
|
|
187
|
+
|
|
188
|
+
Status: **implemented** — multi-project vault via `Projects/<slug>/` + cwd auto-detect.
|
|
189
|
+
|
|
190
|
+
- Standard workspace files: `overview.md`, `current-state.md`, `context.md`, `repo.md` (`repo_path`, `verify`, `default_branch`)
|
|
191
|
+
- `sanook brain new project --title "..." --repo /path`
|
|
192
|
+
- `sanook brain projects list`
|
|
193
|
+
- Agent injects `<project_workspace>` when cwd matches `repo_path`
|
|
194
|
+
- `sanook brain context --project <slug>` for forced selection
|
|
195
|
+
- `brain init` skips copying bundled `Projects/<slug>/` (add projects explicitly)
|
|
196
|
+
|
|
197
|
+
up:: [[Projects/sanook-cli/_Index]]
|
package/second-brain/README.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
1. เปิดโฟลเดอร์นี้ใน **Obsidian** (Open folder as vault)
|
|
24
24
|
2. ให้ AI agent อ่าน `Shared/AI-Context-Index.md` ก่อนทำงานเสมอ
|
|
25
25
|
3. ก่อนสร้างหรือย้ายโน้ต ให้เลือกปลายทางจาก `Vault Structure Map.md` แล้วอ่าน `_Index.md` ของโฟลเดอร์นั้นเพื่อทำตาม **AI Routing Contract**
|
|
26
|
-
4. constitution อยู่ที่ `CLAUDE.md` / `GEMINI.md` / `AGENTS.md` — กฎปฏิบัติของ AI
|
|
26
|
+
4. constitution อยู่ที่ `CLAUDE.md` / `GEMINI.md` / `AGENTS.md` / `SANOOK.md` — กฎปฏิบัติของ AI
|
|
27
27
|
|
|
28
28
|
## ปรับให้เป็นของคุณ
|
|
29
29
|
|
|
@@ -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]]
|