@plumpslabs/kuma 2.2.7 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,550 +1,237 @@
1
1
  <div align="center">
2
2
 
3
- <img src="https://raw.githubusercontent.com/plumpslabs/kuma/main/public/kuma.png" alt="Kuma Logo" width="200" />
3
+ <img src="https://raw.githubusercontent.com/plumpslabs/kuma/main/public/kuma.png" alt="Kuma Logo" width="180" />
4
4
 
5
5
  # Kuma
6
6
 
7
- **Zero-setup safety & context runtime for AI coding agents v2.2.2**
7
+ **Safety-first context & orchestration engine for AI coding agents** · v2.2.8
8
8
 
9
9
  [![npm](https://img.shields.io/npm/v/@plumpslabs/kuma.svg?logo=npm&color=red)](https://www.npmjs.com/package/@plumpslabs/kuma)
10
10
  [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
11
11
  [![Node.js](https://img.shields.io/badge/node-18+-339933?logo=nodedotjs)](https://nodejs.org/)
12
12
 
13
- Works with **13 AI coding agents** — Claude Code, Cursor, Windsurf, GitHub Copilot Editor, Cline, Aider, Antigravity CLI, OpenCode, Codex CLI, Qwen Code, Kiro, OpenClaw, CodeWhale — and any MCP-compatible client.
14
-
15
- **No manual config needed.** Just run `npx @plumpslabs/kuma init`.
13
+ Works with **any MCP-compatible agent** — Claude Code, Cursor, Windsurf, Cline, Aider, OpenCode, Codex CLI, Qwen Code, Kiro, and more.
16
14
 
17
15
  </div>
18
16
 
19
17
  ---
20
18
 
21
- ## Quick Start
19
+ ## What is Kuma?
22
20
 
23
- ```bash
24
- # Generate config files for ALL supported AI agents
25
- npx @plumpslabs/kuma init --all
21
+ Kuma is an **MCP server** that sits alongside your AI coding agent and enforces a simple rule: *understand before you touch.*
26
22
 
27
- # Or generate for specific agents
28
- npx @plumpslabs/kuma init --cursor --claude --aider
23
+ When an agent wants to modify code, Kuma won't let it work blind. It runs a deterministic pipeline: load the research cache, query the knowledge graph, analyze impact across the entire codebase, look up past decisions, and check safety policies — all in one MCP call. Only then does the agent have the context it needs to edit safely.
29
24
 
30
- # See all options
31
- npx @plumpslabs/kuma init --help
32
- ```
25
+ Kuma is **not** an editor, search tool, linter, or terminal. Those are things your AI agent already does natively. Kuma is the **safety layer** that makes sure those actions are informed, tracked, and reversible.
33
26
 
34
- Or add Kuma MCP server manually to any MCP client:
35
-
36
- ```json
37
- {
38
- "mcpServers": {
39
- "kuma": {
40
- "command": "npx",
41
- "args": ["-y", "@plumpslabs/kuma"]
42
- }
43
- }
44
- }
45
- ```
27
+ **Think of it this way:** Your AI agent is the surgeon. Kuma is the pre-op checklist, the patient history, the X-ray, and the post-op report — all in one.
46
28
 
47
29
  ---
48
30
 
49
- ## Unified Tool Router (10 Groups)
50
-
51
- > **Kuma consolidates 46+ individual operations into 10 grouped tools.** AI agents scan 10 groups instead of 46 tools — simpler, faster, less context.
31
+ ## Zero Setup?
52
32
 
53
- | Group | Actions | What it does |
54
- |-------|---------|-------------|
55
- | 🔵 `kuma_init` | `init`, `conventions`, `structure` | **Call first** every session — load context, detect stack, show tree |
56
- | 🟢 `kuma_core` | `grep`, `read`, `edit`, `batch`, `lsp` | During active coding — search, read, safe edit, create files, LSP queries |
57
- | 🟡 `kuma_verify` | `test`, `review`, `lint` | After every edit — run tests, code review, static analysis |
58
- | 🔴 `kuma_safety` | `guard`, `score`, `check`, `policy`, `risk`, `dependency`, `context`, `audit`, `stats`, `override` | Safety & risk — anti-patterns, health score, pre-exec check, policy enforcement, impact analysis, dependency guard, snapshots, audit trail |
59
- | 🟣 `kuma_graph` | `query`, `navigate`, `diagram`, `investigate`, `arch`, `experience`, `intent` | Codebase understanding — query knowledge graph, navigate flows, Mermaid diagrams, auto-investigate, architecture guard, experience patterns, intent paths |
60
- | 🧠 `kuma_memory` | `get`, `search`, `write`, `decision`, `context`, `heal` | Persist/retrieve context — session memory, keyword search, persist knowledge, decisions (ADR), auto-context engine, self-heal graph |
61
- | 📊 `kuma_analytics` | `reflect`, `analytics`, `health`, `replay`, `heatmap`, `learn`, `predict`, `confidence`, `dna` | Session review — on-track detection, stats dashboard, code health, session replay, activity heat map, AI learning, predictive next, confidence score, project DNA |
62
- | ⏳ `kuma_history` | `timeline`, `log`, `diff` | Code history — symbol evolution timeline, commit log, structured diffs |
63
- | 🔒 `kuma_lock` | `acquire`, `release`, `list`, `clean` | Multi-agent coordination — file-level locks, lock listing, stale cleanup |
64
- | ⚙️ `kuma_advanced` | `failure`, `compress`, `shadow`, `collective`, `marketplace` | Maintenance — failure knowledge base, semantic compression, shadow execution simulation, collective VPS sync, marketplace templates |
33
+ **Yes to run Kuma, you need exactly zero configuration:**
65
34
 
66
35
  ```bash
67
- # Full workflow example
68
- kuma_init({ action: "init" }) # Load project context
69
- kuma_core({ action: "grep", query: "handleAuth" }) # Find code
70
- kuma_core({ action: "edit", filePath: "auth.ts", edits: [...] }) # Edit safely
71
- kuma_safety({ action: "guard", goal: "refactor auth" }) # Safety check
72
- kuma_verify({ action: "test" }) # Verify didn't break
73
- kuma_analytics({ action: "reflect" }) # Reflect on progress
36
+ npx -y @plumpslabs/kuma
74
37
  ```
75
38
 
76
- ---
77
-
78
- ## Supported Agents
79
-
80
- `kuma init` generates native config files for **13 AI coding agents** — no manual hunting for file formats:
81
-
82
- | # | Agent | Generated Files | Approach |
83
- |---|-------|----------------|----------|
84
- | 1 | **Claude Code** | `CLAUDE.md` | Fallback instructions (plugin via `/plugin install` is proper) |
85
- | 2 | **Cursor** | `.cursor/rules/kuma.mdc` | Rule file with YAML frontmatter (`alwaysApply: true`) |
86
- | 3 | **Windsurf** | `.windsurfrules` | Static rules file |
87
- | 4 | **GitHub Copilot Editor** | `AGENTS.md` + `.github/skills/kuma/SKILL.md` | AGENTS.md + Skill file |
88
- | 5 | **Cline** | `.clinerules/kuma.md` | Rule file with `paths` frontmatter |
89
- | 6 | **Aider** | `CONVENTIONS.md` + `.aider.conf.yml` | Convention file referenced via `read: CONVENTIONS.md` |
90
- | 7 | **Antigravity CLI** | `.agents/skills/kuma/SKILL.md` + `.agents/mcp_config.json` | Skill + MCP config |
91
- | 8 | **OpenCode** | `opencode.json` | Plugin config JSON |
92
- | 9 | **Codex CLI (OpenAI)** | `AGENTS.md` + `.codex/config.toml` | AGENTS.md + MCP server in TOML |
93
- | 10 | **Qwen Code** | `AGENTS.md` + `settings.json` | AGENTS.md + MCP server in JSON |
94
- | 11 | **Kiro** | `.kiro/steering/kuma.md` | Steering file with YAML frontmatter |
95
- | 12 | **OpenClaw** | `skills/kuma/SKILL.md` | Skill (loaded on demand) |
96
- | 13 | **CodeWhale** | `skills/kuma/SKILL.md` + `.codewhale/mcp.json` | Skill + MCP server config |
39
+ That's it. The MCP server starts. Your AI agent connects. Kuma auto-generates `.kuma/init.md` (behavioral rules), detects your AI agent, and creates its native skill file — automatically.
97
40
 
98
- > `AGENTS.md` is a merged file shared by Codex CLI, Qwen Code, and GitHub Copilot Editor one file, no conflicts.
41
+ The "setup" part is optional: `npx @plumpslabs/kuma init` generates config files for 13 AI agents, but that's just convenience. Kuma works with any MCP client out of the box.
99
42
 
100
43
  ---
101
44
 
102
- ## Features
103
-
104
- ### 🔍 Context & Understanding
105
-
106
- | Feature | Tool / Action | Description |
107
- |---------|--------------|-------------|
108
- | **Smart Grep** | `kuma_core({ action: "grep" })` | Regex code search with context lines, caching, and `.gitignore` respect |
109
- | **Smart File Picker** | `kuma_core({ action: "read" })` | Read files with chunking strategies: `full`, `smart` (signatures + tail), `outline` (exports only) |
110
- | **Project Structure** | `kuma_init({ action: "structure" })` | Tree view of project layout with depth control, folder-only mode, patterns |
111
- | **Project Conventions** | `kuma_init({ action: "conventions" })` | Auto-detect framework, test runner, package manager, monorepo workspaces |
112
- | **LSP Query** | `kuma_core({ action: "lsp" })` | Go-to-definition, find references, type info, rename symbols via TypeScript Language Server. **Falls back to regex when LSP unavailable.** |
113
- | **Code Time Machine** | `kuma_history({ action: "timeline" })` | Track how a function evolved over time — git blame + commit analysis + design decisions |
114
- | **Git Log** | `kuma_history({ action: "log" })` | Structured commit history with file filtering |
115
- | **Git Diff** | `kuma_history({ action: "diff" })` | Structured diff with staged/unstaged, ref ranges, context control |
45
+ ## Core Features
116
46
 
117
47
  ### 🧠 Knowledge Graph (SQLite)
118
48
 
119
- Everything in Kuma is backed by a **SQLite knowledge graph** auto-built, auto-healed, queryable:
120
-
121
- | Feature | Tool / Action | Description |
122
- |---------|--------------|-------------|
123
- | **Graph Query** | `kuma_graph({ action: "query" })` | Query nodes/edges/stats. FTS5 full-text search with graceful fallback |
124
- | **AI Navigation** | `kuma_graph({ action: "navigate" })` | Answer "How does login work?" — returns the full call chain |
125
- | **Autonomous Investigation** | `kuma_graph({ action: "investigate" })` | Given a problem, auto-discovers the relevant code path + bottleneck |
126
- | **Mermaid Diagrams** | `kuma_graph({ action: "diagram" })` | Generate architecture, sequence, impact, ownership, heatmap diagrams |
127
- | **Living Architecture** | `kuma_graph({ action: "arch" })` | Auto-detect architecture (clean/layered/hexagonal/MVC), detect violations |
128
- | **Experience Graph** | `kuma_graph({ action: "experience" })` | Learn from past sessions — suggests next tools based on success patterns |
129
- | **Intent Graph** | `kuma_graph({ action: "intent" })` | Organize by intent, not dependency — suggests optimal paths for a goal |
130
- | **Self-Healing** | `kuma_memory({ action: "heal" })` | Auto-detect stale nodes, repair via git history or content hash. Cascading edge cleanup |
131
-
132
- ### ✏️ Execution — Make Changes Safely
133
-
134
- | Feature | Tool / Action | Description |
135
- |---------|--------------|-------------|
136
- | **Precise Diff Editor** | `kuma_core({ action: "edit" })` | Search-and-replace with exact → whitespace → fuzzy fallback. **Auto-backup before every edit.** Dry-run preview, versioned rollback, batch edits (up to 10) |
137
- | **Batch File Writer** | `kuma_core({ action: "batch" })` | Create up to 15 files in one call. Path validation before writing |
138
- | **Static Analysis** | `kuma_verify({ action: "lint" })` | Run ESLint / TypeScript / Prettier / Ruff — structured output |
139
- | **Code Reviewer** | `kuma_verify({ action: "review" })` | Senior-level static analysis. Focus modes: correctness, conventions, security, performance, **over-engineering detection** |
140
-
141
- ### 🧠 Memory
142
-
143
- | Feature | Tool / Action | Description |
144
- |---------|--------------|-------------|
145
- | **Session Memory** | `kuma_memory({ action: "get" })` | Session state tracker — modified files, unresolved failures, tool history |
146
- | **Memory Search** | `kuma_memory({ action: "search" })` | Keyword search across tool calls, memory files, errors, dependency graph |
147
- | **Persist Knowledge** | `kuma_memory({ action: "write" })` | Save decisions, glossary, architecture notes to `.kuma/memories/` |
148
- | **Decision Memory** | `kuma_memory({ action: "decision" })` | ADR-style decision recording: context → options → rationale → outcome |
149
- | **Context Engine** | `kuma_memory({ action: "context" })` | Auto-inject relevant context — finds files related to a goal via graph distance + recency + failure history |
150
-
151
- ### 🛡️ Safety — Stay on Track
152
-
153
- | Feature | Tool / Action | Description |
154
- |---------|--------------|-------------|
155
- | **Safety Guard** | `kuma_safety({ action: "guard" })` | Anti-pattern detection (script patching, bash grep), tool loops, drift (edits without tests) |
156
- | **Safety Score** | `kuma_safety({ action: "score" })` | Aggregate 0-100 health score across 9 dimensions: git status, backups, LSP, tests, loops, etc. |
157
- | **Safety Policy** | `kuma_safety({ action: "policy" })` | Policy file (`.kuma/policy.yml`) — `never_touch`, `require_review`, `require_tests`, `block_commands` |
158
- | **Risk Prediction** | `kuma_safety({ action: "risk" })` | Before editing — shows references, test files, API routes affected |
159
- | **Dependency Guard** | `kuma_safety({ action: "dependency" })` | Before adding packages — checks existing deps, suggests native JS alternatives |
160
- | **Context Snapshots** | `kuma_safety({ action: "context" })` | Save/restore project state before risky operations |
161
- | **Safety Audit** | `kuma_safety({ action: "audit" })` | Every tool call recorded in SQLite. Queryable trail with override logging |
162
- | **Safety Check** | `kuma_safety({ action: "check" })` | Pre-execution safety check — validates path, policy, dangerous commands |
163
-
164
- ### 📊 Analytics & Reflection
165
-
166
- | Feature | Tool / Action | Description |
167
- |---------|--------------|-------------|
168
- | **Reflection** | `kuma_analytics({ action: "reflect" })` | On-track/off-track detection, drift warnings, next action suggestion |
169
- | **Behavior Analytics** | `kuma_analytics({ action: "analytics" })` | Session stats — tool calls, edits, test runs, rollbacks, loops prevented |
170
- | **Code Health Dashboard** | `kuma_analytics({ action: "health" })` | Project-level health — bug density, test pass rate, rollback rate, fragility scoring |
171
- | **Session Replay** | `kuma_analytics({ action: "replay" })` | Replay what AI did in a previous session as a human-readable narrative |
172
- | **Activity Heat Map** | `kuma_analytics({ action: "heatmap" })` | Show which parts of the codebase AI works on most |
173
- | **AI Learning** | `kuma_analytics({ action: "learn" })` | Auto-prioritize high-usage patterns in the knowledge graph |
174
- | **Predictive AI** | `kuma_analytics({ action: "predict" })` | Predict what file/tool AI needs next based on current context |
175
- | **Confidence Engine** | `kuma_analytics({ action: "confidence" })` | Estimate how confident AI should be — factors: files read, refs checked, graph completeness |
176
- | **Project DNA** | `kuma_analytics({ action: "dna" })` | One-page project fingerprint — architecture, coding style, coupling, risk areas, trends |
177
-
178
- ### ⏳ History & Time Machine
179
-
180
- | Feature | Tool / Action | Description |
181
- |---------|--------------|-------------|
182
- | **Symbol Timeline** | `kuma_history({ action: "timeline" })` | "Why does login work this way?" — traces a function's evolution across commits with design decisions |
183
- | **Commit Log** | `kuma_history({ action: "log" })` | Structured commit history with file filter |
184
- | **Git Diff** | `kuma_history({ action: "diff" })` | Staged/unstaged/ref-range diffs with configurable context |
185
-
186
- ### 🔒 Multi-Agent
187
-
188
- | Feature | Tool / Action | Description |
189
- |---------|--------------|-------------|
190
- | **File Locking** | `kuma_lock({ action: "acquire" })` | Prevent multiple AI agents from editing the same file simultaneously |
191
- | **Lock Management** | `kuma_lock({ action: "list" })` | See active locks, clean stale ones |
192
-
193
- ### ⚙️ Advanced
194
-
195
- | Feature | Tool / Action | Description |
196
- |---------|--------------|-------------|
197
- | **Failure Knowledge Base** | `kuma_advanced({ action: "failure" })` | Every failure saved — type, symbol, solution. Proactive warnings for repeat patterns |
198
- | **Semantic Compression** | `kuma_advanced({ action: "compress" })` | Compress large codebases into a semantic graph (type signatures + deps — no boilerplate) |
199
- | **Shadow Execution** | `kuma_advanced({ action: "shadow" })` | Simulate changes before applying — virtual typecheck, test prediction, risk assessment |
200
- | **Collective Intelligence** | `kuma_advanced({ action: "collective" })` | Sync anonymized patterns to your own VPS — learn from multiple projects |
201
- | **Knowledge Marketplace** | `kuma_advanced({ action: "marketplace" })` | Install pre-built graph templates for popular frameworks |
202
-
203
- ---
204
-
205
- ## Kuma's Promise
49
+ Every project gets its own SQLite database (pure WASM, no native build). Kuma builds a graph of **nodes** (files, functions, classes, tests, API routes) and **edges** (calls, imports, defines, tests). This graph is what powers all research, impact analysis, and flow navigation.
206
50
 
207
- **Kuma is built for one thing: making sure AI agents don't break your project.**
51
+ - FTS5 full-text search with graceful fallback
52
+ - Auto-built, auto-healed, queryable
53
+ - Per-project — your context stays with your codebase
208
54
 
209
- Every tool in Kuma has a safety net built-in — not as an afterthought, but as a core design principle:
55
+ ### 🔬 Mandatory Research Pipeline
210
56
 
211
- | # | When this happens... | Kuma does this... |
212
- |---|---|---|
213
- | 1 | LSP server is not installed | **Falls back to regex** — never hard fails |
214
- | 2 | An edit breaks something | **Rollback to any version** — versioned backups, dry-run preview, version list |
215
- | 3 | AI loops on a test failure | **Circuit breaker stops it** — prevents infinite retries after 3 identical failures |
216
- | 4 | A file path doesn't resolve | **Shows where it looked** — CWD vs project root with resolved paths |
217
- | 5 | A command is dangerous | **Blocks it** — `rm -rf`, `git push --force`, `curl \| bash`, plus shell obfuscation detection |
218
- | 6 | AI keeps repeating the same tool | **Tool-loop detection** — flags if same tool called 4+ times in last 10 calls |
219
- | 7 | You need to undo an edit | **Versioned rollback** — `action: "rollback"` with `version: N` or `version: "list"` |
220
- | 8 | A diff doesn't match | **Fuzzy fallback** — exact → whitespace-normalized → fuzzy match with configurable threshold |
221
- | 9 | AI needs to understand complex code | **Knowledge graph** — SQLite-backed, auto-built, queryable, self-healing |
222
- | 10 | AI is about to break architecture | **Architecture guard** — detects layer violations, suggests correct dependency direction |
223
- | 11 | AI has no context for a goal | **Auto-context engine** — finds relevant files via graph distance + recency + failure history |
224
- | 12 | AI needs to know confidence | **Confidence engine** — 0-100 score based on context completeness |
225
- | 13 | AI wants to know a file's history | **Code time machine** — shows why code is the way it is via git blame + commit analysis |
226
- | 14 | Multiple agents edit the same file | **File lock** — prevents conflicts, clean stale locks |
57
+ Before an agent edits unfamiliar code, Kuma enforces a 5-step research pipeline:
227
58
 
228
- Most tools make AI smarter. **Kuma makes AI not break things.**
59
+ | Step | What happens |
60
+ |------|-------------|
61
+ | **1. Load Cache** | Check `.kuma/research/<scope>.json` — fresh or stale? |
62
+ | **2. Graph Query** | Find all related nodes and edges in the knowledge graph |
63
+ | **3. Impact Analysis** | "If I change X, what breaks?" — references, files, tests, API routes |
64
+ | **4. Decision Lookup** | Check past ADR-style decisions and known issues |
65
+ | **5. Safety Check** | Policy compliance, active locks, risk level |
229
66
 
230
- ---
67
+ All in one MCP call: `kuma_context({ action: "research", scope: "auth" })`. No chaining. No guesswork.
231
68
 
232
- ## Safety
69
+ ### 🛡️ Safety Layer
233
70
 
234
71
  | Feature | What it does |
235
72
  |---------|-------------|
236
- | **Sandboxed** | All file operations locked to project directory. Path traversal blocked. System dirs protected. |
237
- | **Auto-backup** | `.kuma/backups/<timestamp>/` snapshot before every `precise_diff_editor` edit. Rollback to any version. |
238
- | **Circuit breaker** | Stops after 3 identical failures. Prevents AI loops. |
239
- | **Timeout** | All commands have configurable timeout (max 180s). Process tree kill on timeout. |
240
- | **Command whitelist** | Only `test`, `build`, `lint`, `typecheck`, and explicit custom commands. |
241
- | **Dangerous pattern blocking** | `rm -rf`, `git push --force`, `npm publish`, `curl \| bash` blocked by default. **Shell obfuscation detection** catches hidden dangerous commands. |
242
- | **LSP graceful degradation** | When TypeScript Language Server is not installed, LSP tools **fall back to regex** instead of hard failing. |
243
- | **Multi-agent lock** | File-level locks prevent multiple AI agents from editing the same file simultaneously. |
244
- | **Safety score** | Aggregate 0-100 score across 9 dimensions: git status, backups, LSP, tests, modified files, loops, failures, conventions, goal. |
245
- | **Safety policy** | `.kuma/policy.yml` — declare `never_touch` files, `require_review` paths, `block_commands`. |
246
- | **Risk prediction** | Before editing a symbol — shows 42 references in 15 files, 7 test files, 3 API routes. |
247
- | **Dependency guard** | When AI installs a new package — checks existing deps, suggests native alternatives. |
248
- | **Safety audit** | Every tool call recorded in SQLite. Queryable trail with override logging. |
73
+ | **Safety Guard** | Anti-pattern detection, drift (edits without tests), tool-loop prevention, unresolved failure checks |
74
+ | **Safety Policy** | YAML policy file (`.kuma/policy.yml`) `never_touch`, `require_review`, `block_commands` |
75
+ | **Safety Audit** | Every tool call recorded in SQLite. Queryable trail. Override logging with reasons. |
76
+ | **Multi-Agent Lock** | File-level locks prevent multiple AI agents from editing the same file simultaneously |
249
77
 
250
- ---
78
+ ### 📝 Decision Memory
251
79
 
252
- ## What Makes Kuma Unique
253
-
254
- - **Router groups** — 46+ operations consolidated into 10 grouped tools. AI scans 10 groups instead of 46 tools.
255
- - **Knowledge Graph (SQLite)** — Built-in SQLite database via `sql.js` (pure WASM, zero native build). Tracks nodes (functions, files, API routes, tests) + edges (calls, imports, defines, tests) + experience patterns + sessions. FTS5 full-text search with graceful fallback.
256
- - **Self-healing graph** — Automatically detects stale nodes, repairs via git history or content hash fingerprinting.
257
- - **Safety is default, not optional** — Rollback, circuit breaker, sandbox, timeout, dangerous pattern blocking are built into every tool.
258
- - **Graceful degradation** — When dependencies are missing (LSP, linters, FTS5), Kuma falls back instead of crashing.
259
- - **Over-engineering detection** — `code_reviewer` with `focus: "over-engineering"` catches unnecessary abstractions.
260
- - **Drift detection** — `kuma_guard` catches edits without tests, tool-call loops, unresolved failures.
261
- - **Impact prediction** — `kuma_risk` tells you how many files reference a symbol before you change it.
262
- - **Auto-context engine** — Given a goal, finds relevant files via graph distance + recency + failure history.
263
- - **Code time machine** — Shows why code is the way it is: "Because commit e4f5g6h migrated from sessions to JWT for mobile support."
264
- - **Mermaid diagrams** — Auto-generated architecture, sequence, impact, ownership, and heatmap diagrams from the knowledge graph.
265
- - **Architecture guard** — Detects layer violations (Handler → Database when it should be Handler → Service → Repository).
266
- - **Confidence engine** — 0-100 score estimating how confident AI should be about a change.
267
- - **Shadow execution** — Simulate changes before applying: virtual typecheck, test prediction, risk assessment.
268
- - **Failure knowledge base** — Every failure saved and becomes a learning. Proactive warnings.
269
- - **Dependency guard** — Before adding npm packages, checks for native JS alternatives and existing similar packages.
270
- - **Persistent memory** — Knowledge survives across sessions via `.kuma/memories/` + `.kuma/kuma.db`.
271
- - **Monorepo awareness** — Detects workspaces, scans `apps/*`, `packages/*`, `services/*`, and pnpm/yarn/npm workspaces.
272
- - **Collective intelligence** — Anonymized pattern sharing across projects via your own VPS. Zero source code leakage.
273
- - **Knowledge marketplace** — Pre-built graph templates for Laravel, Spring Boot, Django, Gin, Axum, Next.js, Express.js, and more.
274
-
275
- ### Storage Layout
80
+ When Kuma detects a significant change, it can suggest recording an **ADR-style decision**:
276
81
 
277
82
  ```
278
- .kuma/
279
- ├── kuma.db # SQLite database (knowledge graph, sessions, experiences, safety audit)
280
- ├── init.md # Behavioral rules for AI agents (auto-generated)
281
- ├── config.json # Per-project config (collective endpoint, autoSync, etc.)
282
- ├── memory.json # Session state (modified files, failures, tool history)
283
- ├── policy.yml # Safety policy (never_touch, require_review, block_commands)
284
- ├── .instance-id # Anonymous instance ID for collective sync
285
- └── memories/ # Persistent knowledge files
286
- ├── architecture.md
287
- ├── conventions.md
288
- ├── decisions.md
289
- ├── glossary.md
290
- └── known-issues.md
291
-
292
- .kuma/backups/ # Versioned backups from precise_diff_editor
293
- └── <timestamp>/ # One backup snapshot per edit
294
- └── <relative-file-path>
83
+ Context: "We need stateless tokens that expire in 15min"
84
+ Options: "JWT vs opaque tokens vs session store"
85
+ Rationale: "JWT is mobile-compatible, no server-side store needed"
86
+ Outcome: "Implemented JwtPasswordResetService"
295
87
  ```
296
88
 
297
- ---
89
+ Saved to the knowledge graph + `.kuma/memories/decisions.md`. Survives across sessions. Readable by both humans and future AI agents.
298
90
 
299
- ## 🔄 Self-Healing
91
+ ### 🔄 Self-Healing
300
92
 
301
- Kuma automatically detects and repairs issues in the knowledge graph:
93
+ The knowledge graph automatically detects stale nodes, repairs via git history (tracks renames), and reduces stale edge weights — all without manual intervention.
302
94
 
303
- ```bash
304
- # Check for stale entries
305
- kuma_memory({ action: "heal", healAction: "check" })
95
+ ### ↩️ Selective Undo
306
96
 
307
- # Auto-heal remove stale nodes/edges
308
- kuma_memory({ action: "heal" })
309
- ```
97
+ Kuma tracks **symbol-level changes** per session. Instead of file-level rollback, you can see exactly what changed and revert specific modifications without affecting unrelated work:
310
98
 
311
- | Feature | Description |
312
- |---------|-------------|
313
- | **Content Hash** | Detects files that changed since last scan (MD5 of head + tail + size) |
314
- | **All-Node Scan** | Scans all node types: `file`, `function`, `class`, `interface`, `module`, `test`, etc. |
315
- | **Git-Aware Repair** | Uses `git log --follow --diff-filter=R` to trace file renames |
316
- | **Cascading Edges** | Stale node edges get weight reduced to near-zero |
317
- | **Incremental Heal** | Batch processing — repairs only the affected subgraph, not full scan |
318
- | **Auto-Heal Hook** | Runs automatically during graph queries — no manual action needed |
99
+ ```
100
+ kuma_context({ action: "changes" }) → "Session 3 modified routes.ts:42-67 and db.ts"
101
+ ```
319
102
 
320
103
  ---
321
104
 
322
- ## 🛡️ Safety AI Layer
105
+ ## 3 Tools
323
106
 
324
- The Safety layer sits between AI agents and the filesystem. Every tool call goes through: policy check, path validation, audit logging.
107
+ Kuma consolidates everything into **3 coarse-grained tools**. Each action triggers a complete workflow internally one MCP call, not a chain of micro-tools.
325
108
 
326
- ### Features
109
+ ### 🧠 `kuma_context` — Context & Research
327
110
 
328
- | Feature | Description |
329
- |---------|-------------|
330
- | **Safety Audit** | Every tool call recorded in SQLite (`safety_audit`). Queryable. |
331
- | **Safety Proxy** | `precise_diff_editor` is auto-wrapped runs preCheck before execution. |
332
- | **Risk Assessment** | Path validation, policy checks, dangerous command detection. |
333
- | **Override Logging** | Safety bypasses are logged with reasonsaudit trail stays clean. |
334
- | **Safety Score** | 0-100 aggregate health score across 9 dimensions. |
335
-
336
- ### Usage
111
+ | Action | Pipelina | Use case |
112
+ |--------|----------|----------|
113
+ | `init` | Project brief | **Call first every session.** Load graph, detect stack, show structure. |
114
+ | `research` | 5-step pipeline | **WAJIB before editing.** Cache → staleness → graph → impact → decisions. |
115
+ | `impact` | Graph traversal | "Change validateToken → 42 refs, 15 files, 3 tests, 2 API routes." |
116
+ | `navigate` | BFS traversal | "How does login work?" full call chain from route to database. |
117
+ | `changes` | Change log query | "What changed this session?" selective undo support. |
118
+ | `health` | Aggregate scoring | Project health dashboard 0-100 across 9 dimensions. |
337
119
 
338
- ```bash
339
- # Query audit trail (20 most recent entries)
340
- kuma_safety({ action: "audit", limit: 20 })
120
+ ### 📝 `kuma_memory` — Decision & Knowledge
341
121
 
342
- # Audit statistics
343
- kuma_safety({ action: "stats" })
122
+ | Action | Use case |
123
+ |--------|----------|
124
+ | `decision` | ADR-style recording: template, suggest, or record. |
125
+ | `research_save` | Persist research to graph + `.kuma/research/<scope>.json`. |
126
+ | `session` | "What happened this session?" — files, failures, progress. |
127
+ | `heal` | Self-heal knowledge graph — stale detection, git repair. |
128
+ | `search` | Search across memories + knowledge graph. |
129
+ | `changes` | Change log for selective undo. |
344
130
 
345
- # Full safety check before execution
346
- kuma_safety({ action: "check", actionCheck: "edit", filePath: "config.ts" })
131
+ ### 🛡️ `kuma_safety` Safety & Policy
347
132
 
348
- # Safety Score
349
- kuma_safety({ action: "score" })
350
-
351
- # Bypass safety (logged with reason)
352
- kuma_safety({ action: "override", tool: "precise_diff_editor", reason: "trusted edit" })
353
- ```
133
+ | Action | Use case |
134
+ |--------|----------|
135
+ | `guard` | Anti-pattern, drift, tool-loop, and failure checks. |
136
+ | `check` | Pre-execution safety: policy, path, lock, risk level. |
137
+ | `audit` | Query audit trail + stats + override log. |
138
+ | `lock` | Multi-agent file locking. |
139
+ | `health` | Safety score 0-100 with dimension breakdown. |
140
+ | `override` | Logged safety bypass with reason. |
354
141
 
355
142
  ---
356
143
 
357
- ## 🐻 KolektifCollective Intelligence
358
-
359
- Kolektif allows Kuma instances across different projects to share anonymized patterns. Data is sent to **your own VPS server** — not to a public server.
360
-
361
- ### Architecture
362
-
363
- ```
364
- Project A (Laptop) ──────┐
365
- ├──► Your VPS (Hono + better-sqlite3)
366
- Project B (Laptop) ──────┘ Port 3001
367
- ```
144
+ ## VPS / Collective What Is It?
368
145
 
369
- **Data sent (safe):**
370
- - `errorType`: "type_error" / "build_error" — generic category
371
- - `tools`: ["smart_grep", "lsp_query"] — tool names only
372
- - `language`: "typescript" — programming language
373
- - `count`, `successRate` — anonymous numbers
146
+ Kuma has an optional feature called **Kolektif** collective intelligence. It lets multiple Kuma instances across different projects share anonymized patterns to your own VPS.
374
147
 
375
- **Data NEVER sent:**
376
- - ❌ Source code
377
- - ❌ File names / function names
378
- - ❌ Raw error messages
379
- - ❌ Git history / commit messages
380
- - ❌ User identity
148
+ **This is entirely optional.** You never need to set it up. Kuma works perfectly fine with zero infrastructure — just local SQLite.
381
149
 
382
- ### Quick Deploy (VPS)
150
+ What it does:
151
+ - Syncs **anonymized** patterns (error types, tool names, language — no source code, no file names, no git history)
152
+ - Helps Kuma learn patterns across projects ("this error pattern is common in Go projects")
153
+ - Data goes to **your own VPS**, not a public server
383
154
 
384
- Requires a VPS (1GB RAM is enough) with Node.js 18+.
385
-
386
- ```bash
387
- # 1. Clone repo
388
- ssh user@vps-ip
389
- git clone https://github.com/plumpslabs/kuma.git kolektif
390
- cd kolektif/server
155
+ When not configured, Kuma is 100% local. No data leaves your machine.
391
156
 
392
- # 2. Install + build
393
- npm install
394
- npx tsc
157
+ ---
395
158
 
396
- # 3. Start via PM2
397
- pm2 start dist/index.js --name kuma-server
398
- pm2 save
159
+ ## Context Model: Per-Project
399
160
 
400
- # 4. Open firewall
401
- sudo ufw allow 3001/tcp
402
- ```
161
+ Kuma stores context **per project** in a `.kuma/` directory at your project root:
403
162
 
404
- Or use the one-command deploy script:
405
- ```bash
406
- ssh user@vps-ip 'bash -s' < server/deploy.sh
407
163
  ```
408
-
409
- ### Client Setup
410
-
411
- Set the environment variable on your laptop:
412
- ```bash
413
- export KUMA_COLLECTIVE_URL=http://<vps-ip>:3001
414
- ```
415
-
416
- Or via `.kuma/config.json`:
417
- ```json
418
- {
419
- "collective": {
420
- "url": "http://<vps-ip>:3001",
421
- "autoSync": true,
422
- "syncIntervalMinutes": 60
423
- }
424
- }
164
+ your-project/
165
+ ├── src/
166
+ ├── tests/
167
+ └── .kuma/ ← Auto-generated by Kuma
168
+ ├── kuma.db ← Knowledge graph, research cache, audit trail, change log
169
+ ├── init.md ← Behavioral rules for the AI agent
170
+ ├── config.json ← Per-project settings
171
+ ├── policy.yml ← Safety policy
172
+ ├── research/ ← Research records (one JSON per scope)
173
+ └── memories/ ← Persistent decisions, conventions, glossary
425
174
  ```
426
175
 
427
- ### API Endpoints
428
-
429
- | Method | Endpoint | Description |
430
- |--------|----------|-------------|
431
- | `GET` | `/health` | Health check |
432
- | `POST` | `/api/v1/patterns` | Submit anonymized patterns |
433
- | `GET` | `/api/v1/patterns?lang=go` | Get global patterns by language |
434
- | `GET` | `/api/v1/stats` | Dashboard statistics |
176
+ This means **every project has its own context**. The auth flow in Project A is different from Project B. The knowledge graph, decisions, and research are all project-specific — never mixed.
435
177
 
436
- ### TriggerManual via AI
437
-
438
- Sync is **manually triggered** by the AI agent calling the Kuma tool. There is no background scheduler — the AI decides when to sync based on context.
439
-
440
- ```bash
441
- # Sync patterns to your VPS (sends + receives)
442
- kuma_advanced({ action: "collective", collectiveAction: "sync" })
443
-
444
- # Preview what data would be sent (safe preview)
445
- kuma_advanced({ action: "collective", collectiveAction: "export" })
446
-
447
- # Discover local patterns without sending
448
- kuma_advanced({ action: "collective" })
449
- ```
450
-
451
- > 💡 The `autoSync` flag in config tells the AI to remember syncing periodically — but the actual call is always made by the AI agent, not by a timer.
178
+ The VPS collective (optional) is the only cross-project feature, and it only shares anonymized patterns never code or project-specific context.
452
179
 
453
180
  ---
454
181
 
455
- ## 📦 Knowledge Marketplace
456
-
457
- Marketplace provides **pre-built knowledge graph templates** for popular frameworks. Installing a template means Kuma instantly understands the framework's structure without having to learn from scratch.
182
+ ## Workflow
458
183
 
459
- ### Usage
184
+ A typical Kuma-powered session:
460
185
 
461
- ```bash
462
- # List all templates
463
- kuma_advanced({ action: "marketplace" })
464
-
465
- # Install Laravel template — Kuma instantly understands Laravel MVC
466
- kuma_advanced({ action: "marketplace", marketplaceAction: "install", template: "graph:laravel" })
467
186
  ```
187
+ # 1. Understand the project
188
+ kuma_context({ action: "init", goal: "add password reset" })
468
189
 
469
- ### Available Templates
470
-
471
- #### 🔷 TypeScript / JavaScript
472
-
473
- | Template | Framework | Knows | Nodes | Edges |
474
- |----------|-----------|-------|-------|-------|
475
- | `graph:hono` | Hono | Middleware chain, RPC mode, typed routes, HonoX, JSX middleware | 35 | 90 |
476
- | `graph:fastify` | Fastify | Plugin system, hooks lifecycle, schema validation, encapsulation | 40 | 100 |
477
- | `graph:elysia` | Elysia (Bun) | Plugin system, Eden Treaty, schema validation, state/derive pattern | 28 | 70 |
478
- | `graph:nextjs` | Next.js App Router | App Router, Server Components, layout structure, route groups | 45 | 120 |
479
- | `graph:nextjs-pages` | Next.js Pages Router | Pages Router, getServerSideProps, API routes, ISR pattern | 38 | 95 |
480
- | `graph:remix` | Remix | Loaders, actions, forms pattern, nested routes, resource routes | 32 | 80 |
481
- | `graph:express` | Express.js | Middleware chain, route handlers, error patterns, app structure | 30 | 85 |
482
-
483
- #### ⚛️ React Ecosystem
484
-
485
- | Template | Library | Knows | Nodes | Edges |
486
- |----------|---------|-------|-------|-------|
487
- | `graph:tanstack-query` | TanStack Query | Query/mutation pattern, cache invalidation, optimistic updates, infinite queries | 36 | 88 |
488
- | `graph:tanstack-router` | TanStack Router | File-based routing, loaders, search params, route guards, devtools | 30 | 75 |
489
- | `graph:tanstack-table` | TanStack Table | Column definitions, sorting, filtering, pagination, row selection | 22 | 55 |
490
- | `graph:zustand` | Zustand | Store pattern, middleware (persist, devtools, immer), subscribe, slice pattern | 18 | 42 |
491
- | `graph:shadcn` | shadcn/ui | Component structure, Radix primitives, tailwind classes, registry pattern | 50 | 130 |
492
-
493
- #### 🗄️ Database (JS/TS)
494
-
495
- | Template | ORM | Knows | Nodes | Edges |
496
- |----------|-----|-------|-------|-------|
497
- | `graph:prisma` | Prisma | Schema models, relations, migrations, client queries, middleware hooks | 35 | 85 |
498
- | `graph:drizzle` | Drizzle | Schema definition, relations, SQL-like queries, migrations, Drizzle Kit | 30 | 72 |
190
+ # 2. Research before touching code (WAJIB)
191
+ kuma_context({ action: "research", scope: "auth" })
192
+ Returns: entry points, flow, 42 refs in 15 files, 3 tests, 2 decisions
499
193
 
500
- #### Other Languages
194
+ # 3. Agent edits using native tools (Claude Code / Cursor / etc.)
501
195
 
502
- | Template | Framework | Knows | Nodes | Edges |
503
- |----------|-----------|-------|-------|-------|
504
- | `graph:laravel` | Laravel (PHP) | Controllers, Services, Repositories, Middleware, Blade, Eloquent | 50 | 140 |
505
- | `graph:spring` | Spring Boot (Java) | Controllers, Services, JPA Repositories, Entities, Config | 55 | 150 |
506
- | `graph:django` | Django (Python) | Views, Models, Serializers, URLs, Admin | 40 | 110 |
507
- | `graph:gin` | Gin (Go) | Handlers, Services, Repositories, Middleware, Models | 25 | 65 |
508
- | `graph:axum` | Axum (Rust) | Handlers, Extractors, Services, Repositories, State | 20 | 55 |
196
+ # 4. Save what you learned
197
+ kuma_memory({ action: "research_save", scope: "auth", confidence: 0.85 })
509
198
 
510
- > ⚠️ `@kuma-templates/*` packages do not exist on npmjs yet. All built-in templates are generated from Kuma's source code directly — no npm install needed. The npm path exists for future community-published templates.
199
+ # 5. Record significant decisions
200
+ kuma_memory({
201
+ action: "decision",
202
+ decisionAction: "record",
203
+ title: "Use JWT for password reset tokens",
204
+ context: "Need stateless tokens that expire in 15min",
205
+ rationale: "No session store needed, mobile-compatible",
206
+ outcome: "Implemented JwtPasswordResetService"
207
+ })
511
208
 
512
- ---
513
-
514
- ## 🍵 Pair with Matcha
515
-
516
- **Kuma keeps AI agents safe. Matcha keeps AI agents deliberate.**
517
-
518
- [Matcha](https://github.com/plumpslabs/matcha) is an engineering philosophy
519
- ruleset that enforces deliberate thinking before, during, and after coding:
209
+ # 6. Verify nothing broke
210
+ kuma_safety({ action: "guard", guardGoal: "add password reset" })
520
211
 
521
- - **5W1H Gate** Why are we doing this? Is there a simpler path?
522
- - **Reuse Before Write** — Never write what already exists
523
- - **Clean Finish** — No temp, no debug, no unused code
524
-
525
- Where Kuma provides **runtime safety** (rollback, circuit breaker, sandbox),
526
- Matcha provides **session discipline** (planning gate, cleanup scan, intensity levels).
527
-
528
- ```bash
529
- # Try them together
530
- npx @plumpslabs/matcha init # Install matcha philosophy
531
- npx @plumpslabs/kuma init --all # Install kuma safety tools
212
+ # 7. Check changes for selective undo awareness
213
+ kuma_context({ action: "changes" })
532
214
  ```
533
215
 
534
- Both tools are designed to complement each other — Kuma handles the
535
- "can't break things" layer while Matcha handles the "think before you act" layer.
536
-
537
216
  ---
538
217
 
539
- ## Contributing
218
+ ## Why Kuma?
540
219
 
541
- See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
220
+ | Need | Problem | Kuma's Answer |
221
+ |------|---------|---------------|
222
+ | Context | AI agent forgets what happened last session | Knowledge graph + session memory survive across sessions |
223
+ | Safety | AI agent edits the wrong file | Policy enforcement + path validation + audit trail |
224
+ | Impact | "If I change this, what breaks?" | Graph-based impact analysis — references, tests, API routes |
225
+ | Coordination | Two agents editing the same file | Multi-agent file lock |
226
+ | Memory | "Why was this decision made?" | ADR-style decision recording, trigger-based |
227
+ | Reversibility | "Undo this change, but not that one" | Selective undo via change log |
228
+ | Staleness | Graph data is months old | Self-healing with content hash + git-aware repair |
542
229
 
543
230
  ---
544
231
 
545
232
  ## License
546
233
 
547
- [MIT](LICENSE)
234
+ MIT
548
235
 
549
236
  <div align="center">
550
237