kemdicode-mcp 1.20.0 → 1.21.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 +46 -38
- package/dist/thinking/index.d.ts +20 -0
- package/dist/thinking/index.d.ts.map +1 -0
- package/dist/thinking/index.js +12 -0
- package/dist/thinking/index.js.map +1 -0
- package/dist/thinking/thinking-store.d.ts +79 -0
- package/dist/thinking/thinking-store.d.ts.map +1 -0
- package/dist/thinking/thinking-store.js +304 -0
- package/dist/thinking/thinking-store.js.map +1 -0
- package/dist/thinking/types.d.ts +91 -0
- package/dist/thinking/types.d.ts.map +1 -0
- package/dist/thinking/types.js +31 -0
- package/dist/thinking/types.js.map +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +3 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/registry.d.ts +1 -1
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/thinking/index.d.ts +11 -0
- package/dist/tools/thinking/index.d.ts.map +1 -0
- package/dist/tools/thinking/index.js +11 -0
- package/dist/tools/thinking/index.js.map +1 -0
- package/dist/tools/thinking/thinking-chain.tool.d.ts +20 -0
- package/dist/tools/thinking/thinking-chain.tool.d.ts.map +1 -0
- package/dist/tools/thinking/thinking-chain.tool.js +378 -0
- package/dist/tools/thinking/thinking-chain.tool.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
<h3 align="center">Model Context Protocol Server for AI-Powered Development</h3>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
|
|
8
|
+
120 tools • 7 LLM providers • multi-agent orchestration • kanban • project memory
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
12
|
<a href="https://www.npmjs.com/package/kemdicode-mcp"><img src="https://img.shields.io/badge/npm-kemdicode--mcp-CB3837?style=flat-square&logo=npm&logoColor=white" alt="npm" /></a>
|
|
13
|
-
<a href="https://github.com/kemdi-pl/kemdicode-mcp/releases"><img src="https://img.shields.io/badge/version-1.
|
|
13
|
+
<a href="https://github.com/kemdi-pl/kemdicode-mcp/releases"><img src="https://img.shields.io/badge/version-1.21.0-blue?style=flat-square" alt="Version" /></a>
|
|
14
14
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-GPL--3.0-green?style=flat-square" alt="License" /></a>
|
|
15
15
|
</p>
|
|
16
16
|
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
-
**kemdiCode MCP** is a [Model Context Protocol](https://modelcontextprotocol.io/) server that gives AI agents and IDE assistants access to **
|
|
26
|
+
**kemdiCode MCP** is a [Model Context Protocol](https://modelcontextprotocol.io/) server that gives AI agents and IDE assistants access to **120 specialized tools** for code analysis, generation, git operations, file management, AST-aware editing, project memory, multi-board kanban, task comments, and multi-agent coordination.
|
|
27
27
|
|
|
28
28
|
<details>
|
|
29
29
|
<summary><strong>Table of Contents</strong></summary>
|
|
30
30
|
|
|
31
|
-
- [What's New in 1.
|
|
31
|
+
- [What's New in 1.21.0](#whats-new-in-1210)
|
|
32
32
|
- [Usage Examples](#usage-examples)
|
|
33
33
|
- [Highlights](#highlights)
|
|
34
34
|
- [Compatibility](#compatibility)
|
|
@@ -50,27 +50,29 @@
|
|
|
50
50
|
|
|
51
51
|
---
|
|
52
52
|
|
|
53
|
-
## What's New in 1.
|
|
53
|
+
## What's New in 1.21.0
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
- **Memory Tools: Redis Pipeline Optimization** — `read-memory` and `delete-memory` batch operations use Redis pipelines instead of sequential queries, eliminating N+1 performance issues.
|
|
57
|
-
- **5 Critical Bug Fixes** — memory leak in `sessionHistory` Map (LRU eviction), recursion context restoration in `tool-invoker`, Pub/Sub handler leak in `agent-monitor`, Redis connection leak in kanban subscriber, race condition in `claimTask` blocker validation.
|
|
58
|
-
- **5 Performance Improvements** — session write-back throttling (dirty flag + 5min threshold), kanban `listTasks` N+1 → Redis pipeline, context `queryContext` N+1 → pipeline, rate-limit map cleanup timer, shared Redis connection pooling.
|
|
59
|
-
- **2 Security Fixes** — hardcoded salt fallback removed (now throws on missing `SECURE_STORAGE_SALT`), command injection risk in `projectContext.enhanced.ts` fixed (switched to `execFile`).
|
|
60
|
-
- **Template Injection Prevention** — `consensus-prompt` fixed reversed `replaceAll` order to prevent user prompt from injecting `{board_responses}` placeholder. CEO `maxTokens` capped at 32K.
|
|
61
|
-
- **ANSI Escape Injection Protection** — new `sanitizeTerminalOutput()` utility applied to `agent-alert` and `agent-inject` to prevent terminal escape sequence injection via user-controlled strings.
|
|
62
|
-
- **Shared Memory Module** — extracted duplicated types, constants, and helpers from 7 memory tools into `src/tools/memory/shared.ts`, eliminating 6x duplication.
|
|
63
|
-
- **Shared Format Helpers** — new `src/utils/format-helpers.ts` with `sanitizeTerminalOutput()`, `wrapText()`, `priorityIcon()`, `statusIcon()` shared across agent tools.
|
|
64
|
-
- **Input Validation Hardening** — prototype pollution prevention in `agent-register` metadata keys, octal mode regex validation in `file-write`, ref flag injection prevention in `git-log`, content size limits (1MB) in `queue-message`.
|
|
55
|
+
### Thinking Chain Tool
|
|
65
56
|
|
|
66
|
-
|
|
57
|
+
New `thinking-chain` tool for structured reasoning with forward-only constraint:
|
|
67
58
|
|
|
68
|
-
- **
|
|
69
|
-
- **
|
|
70
|
-
- **
|
|
71
|
-
- **
|
|
72
|
-
- **
|
|
73
|
-
- **
|
|
59
|
+
- **7 actions** — `start`, `think`, `branch`, `revise`, `conclude`, `get`, `list`
|
|
60
|
+
- **Forward-only** — thoughts are appended sequentially; backtracking is blocked until the latest thought reaches **≥90% confidence** or you revise the last thought
|
|
61
|
+
- **Branching** — fork a new chain from any thought to explore alternative hypotheses without modifying the original chain
|
|
62
|
+
- **Revision tracking** — revisions are appended as new thoughts with `revisedFrom` reference, preserving the full reasoning history
|
|
63
|
+
- **Confidence tracking** — every thought has a 0-100% confidence score with optional reasoning
|
|
64
|
+
- **Visual display** — `get` action renders the chain with box-drawing UI showing thought flow, branches, revisions, and conclusion
|
|
65
|
+
- **Redis-backed** — 7-day TTL, indexed by session and agent
|
|
66
|
+
|
|
67
|
+
New `thinking` tool category added to the registry.
|
|
68
|
+
|
|
69
|
+
### What was in 1.20.0
|
|
70
|
+
|
|
71
|
+
- **14 New Tools** — `git-add`, `git-commit`, `git-stash`, `task-get`, `task-delete`, `task-comment`, `board-delete`, `workspace-delete`, `file-delete`, `file-move`, `file-copy`, `file-backup-restore`, `pipeline`, `checkpoint-diff`
|
|
72
|
+
- **Task Comments System** — append-only notes for kanban tasks with `TaskNote` type, batch 1-20 comments, `task-get` returns notes
|
|
73
|
+
- **Metadata for All Tools** — every tool now has `category`, `tags`, `examples`, `relatedTools`. 4 new categories: `loci`, `mpc`, `session`, `rl`
|
|
74
|
+
- **UX Improvements** — auto-sessionId, board/workspace name lookup, shorthand mode, `format` param for git tools, configurable batch `maxResultLength`, rewritten `help` tool
|
|
75
|
+
- **Bug Fixes** — race condition in `task-comment` (Promise.all → sequential), emoji fix in priority/status fields
|
|
74
76
|
|
|
75
77
|
---
|
|
76
78
|
|
|
@@ -132,7 +134,7 @@ You: "Set up 3 agents: backend, frontend, QA. Backend works on the API, frontend
|
|
|
132
134
|
|
|
133
135
|
| Capability | Description |
|
|
134
136
|
|:-----------|:------------|
|
|
135
|
-
| **
|
|
137
|
+
| **119 MCP Tools** | Code review, refactoring, testing, git, file management, AST editing, memory, checkpoints, kanban, task comments, pipelines |
|
|
136
138
|
| **7 LLM Providers** | Native SDKs for OpenAI (GPT-5), Anthropic (Claude 4.5), Gemini (Gemini 3) + OpenAI-compatible for Groq, DeepSeek, Ollama, OpenRouter |
|
|
137
139
|
| **Multi-Agent** | Agents connect via HTTP, share context through Redis Pub/Sub, coordinate via kanban boards |
|
|
138
140
|
| **Parallel Multi-Model** | Send one prompt to N models simultaneously; CEO-and-Board consensus pattern |
|
|
@@ -351,7 +353,7 @@ ai-config --action test
|
|
|
351
353
|
|
|
352
354
|
## Tool Reference
|
|
353
355
|
|
|
354
|
-
> **
|
|
356
|
+
> **120 tools** across 21 categories.
|
|
355
357
|
|
|
356
358
|
| Category | # | Tools |
|
|
357
359
|
|:---------|:-:|:------|
|
|
@@ -361,18 +363,20 @@ ai-config --action test
|
|
|
361
363
|
| **Line Editing** | 4 | `insert-at-line` `delete-lines` `replace-lines` `replace-content` |
|
|
362
364
|
| **Symbol Editing** | 3 | `insert-before-symbol` `insert-after-symbol` `rename-symbol` |
|
|
363
365
|
| **Code Modification** | 5 | `fix-bug` `refactor` `auto-fix` `auto-fix-agent` `write-tests` |
|
|
364
|
-
| **Project Memory** |
|
|
365
|
-
| **Git** |
|
|
366
|
-
| **File Operations** |
|
|
366
|
+
| **Project Memory** | 8 | `write-memory` `read-memory` `list-memories` `edit-memory` `delete-memory` `checkpoint-save` `checkpoint-restore` `checkpoint-diff` |
|
|
367
|
+
| **Git** | 8 | `git-status` `git-diff` `git-log` `git-blame` `git-branch` `git-add` `git-commit` `git-stash` |
|
|
368
|
+
| **File Operations** | 9 | `file-read` `file-write` `file-search` `file-tree` `file-diff` `file-delete` `file-move` `file-copy` `file-backup-restore` |
|
|
367
369
|
| **Project** | 5 | `project-info` `run-script` `run-tests` `run-lint` `check-types` |
|
|
368
|
-
| **Kanban — Tasks** |
|
|
369
|
-
| **Kanban — Workspaces** |
|
|
370
|
-
| **Kanban — Boards** |
|
|
370
|
+
| **Kanban — Tasks** | 10 | `task-create` `task-get` `task-list` `task-update` `task-delete` `task-comment` `task-claim` `task-assign` `task-push-multi` `board-status` |
|
|
371
|
+
| **Kanban — Workspaces** | 5 | `workspace-create` `workspace-list` `workspace-join` `workspace-leave` `workspace-delete` |
|
|
372
|
+
| **Kanban — Boards** | 6 | `board-create` `board-list` `board-share` `board-members` `board-invite` `board-delete` |
|
|
371
373
|
| **Recursive** | 3 | `invoke-tool` `invoke-batch` `invocation-log` |
|
|
372
374
|
| **Multi-Agent** | 13 | `agent-list` `agent-register` `agent-watch` `agent-alert` `agent-inject` `agent-history` `monitor` `agent-summary` `queue-message` `shared-thoughts` `get-shared-context` `feedback` `batch` |
|
|
375
|
+
| **Orchestration** | 1 | `pipeline` |
|
|
373
376
|
| **Session** | 5 | `session-list` `session-info` `session-create` `session-switch` `session-delete` |
|
|
374
377
|
| **MPC Security** | 4 | `mpc-split` `mpc-distribute` `mpc-reconstruct` `mpc-status` |
|
|
375
378
|
| **RL Learning** | 2 | `rl-reward-stats` `rl-dopamine-log` |
|
|
379
|
+
| **Thinking Chain** | 1 | `thinking-chain` |
|
|
376
380
|
| **Knowledge Graph** | 4 | `graph-query` `graph-find-path` `loci-recall` `sequence-recommend` |
|
|
377
381
|
| **System** | 10 | `shell-exec` `process-list` `env-info` `memory-usage` `ai-config` `ai-models` `config` `ping` `help` `timeout-test` |
|
|
378
382
|
|
|
@@ -387,7 +391,7 @@ ai-config --action test
|
|
|
387
391
|
| **Clients** | Claude Code, Cursor, KiroCode, RooCode | Connect via SSE + JSON-RPC (MCP Protocol) |
|
|
388
392
|
| **HTTP Server** | `:3100` (Bun or Node.js) | Routes: `/sse`, `/message`, `/resume`, `/stream` |
|
|
389
393
|
| **Session Manager** | Per-client isolation | CWD injection, activity tracking, `/resume` for post-compaction recovery, SSE keep-alive |
|
|
390
|
-
| **Tool Registry** |
|
|
394
|
+
| **Tool Registry** | 120 tools, 21 categories | Zod schema validation, auto JSON Schema generation, runtime registration with `tools/list_changed` broadcast, full metadata (category, tags, examples, relatedTools) |
|
|
391
395
|
| **Provider Registry** | 7 LLM providers | OpenAI, Anthropic, Gemini (native SDKs) + Groq, DeepSeek, Ollama, OpenRouter (OpenAI-compatible). Lazy init, hot-reload, unified thinking tokens |
|
|
392
396
|
| **Tree-sitter AST** | 19 languages | WASM parsers, symbol navigation, rename, insert before/after, indentation detection |
|
|
393
397
|
| **Runtime Abstraction** | Bun / Node.js | Auto-detection at startup. Unified HTTP (`Bun.serve` / `node:http`), process spawning (`Bun.spawn` / `child_process`) |
|
|
@@ -436,10 +440,11 @@ ai-config --action test
|
|
|
436
440
|
| | `storage.ts` | Redis-based shared context store (DB 2) |
|
|
437
441
|
| | `feedback-loop.ts` | Learning from iteration results |
|
|
438
442
|
| | `iteration-tracker.ts` | Track fix attempts per issue |
|
|
439
|
-
| `src/kanban/` | `kanban-store.ts` | Task CRUD with Redis `hset`/`hgetall` persistence |
|
|
443
|
+
| `src/kanban/` | `kanban-store.ts` | Task CRUD with Redis `hset`/`hgetall` persistence, task notes |
|
|
440
444
|
| | `workspace-store.ts` | Workspace CRUD operations |
|
|
441
445
|
| | `board-store.ts` | Board management and membership |
|
|
442
446
|
| | `membership-store.ts` | Role-based access: owner / admin / member / viewer |
|
|
447
|
+
| | `resolvers.ts` | Auto-sessionId injection, board/workspace name-to-ID resolution |
|
|
443
448
|
| | `migration.ts` | Lazy migration to multi-board schema |
|
|
444
449
|
| `src/recursive/` | `tool-invoker.ts` | Safe recursive tool calls: max depth 2, rate-limited, parallel isolation |
|
|
445
450
|
| `src/tree-sitter/` | `parser-manager.ts` | WASM parser lifecycle for 19 languages |
|
|
@@ -447,15 +452,16 @@ ai-config --action test
|
|
|
447
452
|
| `src/session/` | `manager.ts` | Session create / destroy / cleanup lifecycle |
|
|
448
453
|
| | `cwd-resolver.ts` | Project path resolution priority chain |
|
|
449
454
|
| `src/tools/` | `registry.ts` | `UnifiedTool` interface, Zod → JSON Schema, broadcast on register |
|
|
450
|
-
| | `index.ts` | Central tool registration (
|
|
455
|
+
| | `index.ts` | Central tool registration (120 tools, 21 categories) |
|
|
456
|
+
| | `pipeline.tool.ts` | Sequential tool execution with `{{stepId.result}}` interpolation |
|
|
451
457
|
| `src/tools/agents/` | 9 tools | `agent-register`, `agent-watch`, `agent-alert`, `agent-inject`, `monitor`, `agent-summary`, `queue-message`, `agent-list`, `agent-history` |
|
|
452
458
|
| `src/tools/code/` | 8 tools | `find-definition`, `find-references`, `find-symbols`, `code-outline`, `insert-before-symbol`, `insert-after-symbol`, `rename-symbol`, `semantic-search` |
|
|
453
459
|
| `src/tools/context/` | 4 tools | `shared-thoughts`, `get-shared-context`, `feedback`, `batch` |
|
|
454
460
|
| `src/tools/edit/` | 4 tools | `insert-at-line`, `delete-lines`, `replace-lines`, `replace-content` |
|
|
455
|
-
| `src/tools/file/` |
|
|
456
|
-
| `src/tools/git/` |
|
|
457
|
-
| `src/tools/kanban/` |
|
|
458
|
-
| `src/tools/memory/` |
|
|
461
|
+
| `src/tools/file/` | 9 tools | `file-read`, `file-write`, `file-search`, `file-tree`, `file-diff`, `file-delete`, `file-move`, `file-copy`, `file-backup-restore` |
|
|
462
|
+
| `src/tools/git/` | 8 tools | `git-status`, `git-diff`, `git-log`, `git-blame`, `git-branch`, `git-add`, `git-commit`, `git-stash` |
|
|
463
|
+
| `src/tools/kanban/` | 21 tools | Tasks (10), boards (6), workspaces (5) |
|
|
464
|
+
| `src/tools/memory/` | 8 tools | `write-memory`, `read-memory`, `list-memories`, `edit-memory`, `delete-memory`, `checkpoint-save`, `checkpoint-restore`, `checkpoint-diff` |
|
|
459
465
|
| `src/tools/multi-llm/` | 2 tools | `multi-prompt`, `consensus-prompt` |
|
|
460
466
|
| `src/tools/project/` | 5 tools | `project-info`, `run-script`, `run-tests`, `run-lint`, `check-types` |
|
|
461
467
|
| `src/tools/recursive/` | 3 tools | `invoke-tool`, `invoke-batch`, `invocation-log` |
|
|
@@ -465,6 +471,8 @@ ai-config --action test
|
|
|
465
471
|
| `src/tools/loci/` | 4 tools | `graph-query`, `graph-find-path`, `loci-recall`, `sequence-recommend` |
|
|
466
472
|
| `src/tools/mpc/` | 4 tools | `mpc-split`, `mpc-distribute`, `mpc-reconstruct`, `mpc-status` |
|
|
467
473
|
| `src/tools/rl/` | 2 tools | `rl-reward-stats`, `rl-dopamine-log` |
|
|
474
|
+
| `src/tools/thinking/` | 1 tool | `thinking-chain` |
|
|
475
|
+
| `src/thinking/` | Store + types | `ThinkingChain`, `Thought` types, Redis-backed store with forward-only constraint |
|
|
468
476
|
| `src/utils/` | `commandExecutor.ts` | Process spawning with timeout, SIGTERM → SIGKILL |
|
|
469
477
|
| | `file-utils.ts` | Read/write with encoding detection (UTF-8, UTF-16, Latin1) |
|
|
470
478
|
| | `edit-utils.ts` | Line-based editing helpers |
|
|
@@ -557,7 +565,7 @@ task-create --tasks '[
|
|
|
557
565
|
task-push-multi --taskIds '["t-1","t-2"]' --agents '["agent-1"]' --mode assign
|
|
558
566
|
```
|
|
559
567
|
|
|
560
|
-
**Features:** workspaces • multiple boards • owner / admin / member / viewer roles • batch create / update (1-20 per call) • assign / clone / notify distribution modes
|
|
568
|
+
**Features:** workspaces • multiple boards • owner / admin / member / viewer roles • batch create / update / delete (1-20 per call) • assign / clone / notify distribution modes • append-only task comments • auto-sessionId • board/workspace name lookup
|
|
561
569
|
|
|
562
570
|
---
|
|
563
571
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KemdiCode MCP Server
|
|
3
|
+
* Copyright (C) 2025-2026 Kemdi Sp. z o.o.
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Thinking Chain Module
|
|
12
|
+
*
|
|
13
|
+
* Exports types and store functions for the thinking chain system.
|
|
14
|
+
*
|
|
15
|
+
* @module thinking
|
|
16
|
+
*/
|
|
17
|
+
export type { ThinkingChain, Thought, ChainStatus } from './types.js';
|
|
18
|
+
export { THINKING_KEYS, THINKING_TTL } from './types.js';
|
|
19
|
+
export { createChain, getChain, addThought, reviseThought, branchChain, concludeChain, listChains, } from './thinking-store.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/thinking/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;GAMG;AAEH,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,UAAU,EACV,aAAa,EACb,WAAW,EACX,aAAa,EACb,UAAU,GACX,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KemdiCode MCP Server
|
|
3
|
+
* Copyright (C) 2025-2026 Kemdi Sp. z o.o.
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*/
|
|
10
|
+
export { THINKING_KEYS, THINKING_TTL } from './types.js';
|
|
11
|
+
export { createChain, getChain, addThought, reviseThought, branchChain, concludeChain, listChains, } from './thinking-store.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/thinking/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAWH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,UAAU,EACV,aAAa,EACb,WAAW,EACX,aAAa,EACb,UAAU,GACX,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KemdiCode MCP Server
|
|
3
|
+
* Copyright (C) 2025-2026 Kemdi Sp. z o.o.
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import type { ThinkingChain, Thought, ChainStatus } from './types.js';
|
|
19
|
+
/**
|
|
20
|
+
* Create a new thinking chain with its first thought
|
|
21
|
+
*/
|
|
22
|
+
export declare function createChain(params: {
|
|
23
|
+
title: string;
|
|
24
|
+
agentId: string;
|
|
25
|
+
sessionId: string;
|
|
26
|
+
content: string;
|
|
27
|
+
confidence: number;
|
|
28
|
+
reasoning?: string;
|
|
29
|
+
tags?: string[];
|
|
30
|
+
}): Promise<ThinkingChain>;
|
|
31
|
+
/**
|
|
32
|
+
* Get a chain by ID
|
|
33
|
+
*/
|
|
34
|
+
export declare function getChain(chainId: string): Promise<ThinkingChain | null>;
|
|
35
|
+
/**
|
|
36
|
+
* Add a new thought to the end of a chain (forward-only)
|
|
37
|
+
*/
|
|
38
|
+
export declare function addThought(chainId: string, params: {
|
|
39
|
+
content: string;
|
|
40
|
+
confidence: number;
|
|
41
|
+
reasoning?: string;
|
|
42
|
+
}): Promise<Thought>;
|
|
43
|
+
/**
|
|
44
|
+
* Revise a thought in the chain.
|
|
45
|
+
* Only allowed if:
|
|
46
|
+
* - thoughtIndex is the last thought's index (revising latest), OR
|
|
47
|
+
* - The latest thought has confidence >= 90
|
|
48
|
+
*/
|
|
49
|
+
export declare function reviseThought(chainId: string, params: {
|
|
50
|
+
thoughtIndex: number;
|
|
51
|
+
content: string;
|
|
52
|
+
confidence: number;
|
|
53
|
+
reasoning?: string;
|
|
54
|
+
}): Promise<Thought>;
|
|
55
|
+
/**
|
|
56
|
+
* Branch a new chain from a specific thought in an existing chain
|
|
57
|
+
*/
|
|
58
|
+
export declare function branchChain(params: {
|
|
59
|
+
sourceChainId: string;
|
|
60
|
+
thoughtIndex: number;
|
|
61
|
+
title: string;
|
|
62
|
+
content: string;
|
|
63
|
+
confidence: number;
|
|
64
|
+
reasoning?: string;
|
|
65
|
+
}): Promise<ThinkingChain>;
|
|
66
|
+
/**
|
|
67
|
+
* Conclude a chain with a final conclusion
|
|
68
|
+
*/
|
|
69
|
+
export declare function concludeChain(chainId: string, conclusion: string): Promise<ThinkingChain>;
|
|
70
|
+
/**
|
|
71
|
+
* List chains with optional filters
|
|
72
|
+
*/
|
|
73
|
+
export declare function listChains(params: {
|
|
74
|
+
sessionId?: string;
|
|
75
|
+
agentId?: string;
|
|
76
|
+
status?: ChainStatus;
|
|
77
|
+
limit?: number;
|
|
78
|
+
}): Promise<ThinkingChain[]>;
|
|
79
|
+
//# sourceMappingURL=thinking-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinking-store.d.ts","sourceRoot":"","sources":["../../src/thinking/thinking-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAYH,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAsEtE;;GAEG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE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OAAO,CAAC,aAAa,EAAE,CAAC,CA0B3B"}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KemdiCode MCP Server
|
|
3
|
+
* Copyright (C) 2025-2026 Kemdi Sp. z o.o.
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Thinking Chain Store
|
|
20
|
+
*
|
|
21
|
+
* Redis-backed storage for thinking chains.
|
|
22
|
+
* Uses hash storage with JSON-serialized thoughts array.
|
|
23
|
+
*
|
|
24
|
+
* @module thinking/thinking-store
|
|
25
|
+
*/
|
|
26
|
+
import { getSharedRedis } from '../infrastructure/redis/connection.js';
|
|
27
|
+
import { THINKING_KEYS, THINKING_TTL } from './types.js';
|
|
28
|
+
import { randomBytes } from 'crypto';
|
|
29
|
+
/**
|
|
30
|
+
* Get Redis client
|
|
31
|
+
*/
|
|
32
|
+
async function getRedis() {
|
|
33
|
+
return getSharedRedis();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Generate a unique chain ID
|
|
37
|
+
*/
|
|
38
|
+
function generateChainId() {
|
|
39
|
+
return `chain_${Date.now()}_${randomBytes(4).toString('hex')}`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Safely parse JSON with fallback
|
|
43
|
+
*/
|
|
44
|
+
function safeJsonParse(value, fallback) {
|
|
45
|
+
if (!value)
|
|
46
|
+
return fallback;
|
|
47
|
+
try {
|
|
48
|
+
return JSON.parse(value) ?? fallback;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return fallback;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Serialize chain for Redis storage
|
|
56
|
+
*/
|
|
57
|
+
function serializeChain(chain) {
|
|
58
|
+
return {
|
|
59
|
+
id: chain.id,
|
|
60
|
+
title: chain.title,
|
|
61
|
+
agentId: chain.agentId,
|
|
62
|
+
sessionId: chain.sessionId,
|
|
63
|
+
parentChainId: chain.parentChainId || '',
|
|
64
|
+
parentThoughtIndex: chain.parentThoughtIndex !== undefined ? String(chain.parentThoughtIndex) : '',
|
|
65
|
+
thoughts: JSON.stringify(chain.thoughts),
|
|
66
|
+
status: chain.status,
|
|
67
|
+
conclusion: chain.conclusion || '',
|
|
68
|
+
tags: JSON.stringify(chain.tags),
|
|
69
|
+
createdAt: String(chain.createdAt),
|
|
70
|
+
updatedAt: String(chain.updatedAt),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Parse chain from Redis data
|
|
75
|
+
*/
|
|
76
|
+
function parseChain(data) {
|
|
77
|
+
return {
|
|
78
|
+
id: data.id,
|
|
79
|
+
title: data.title,
|
|
80
|
+
agentId: data.agentId,
|
|
81
|
+
sessionId: data.sessionId,
|
|
82
|
+
parentChainId: data.parentChainId || undefined,
|
|
83
|
+
parentThoughtIndex: data.parentThoughtIndex ? parseInt(data.parentThoughtIndex, 10) : undefined,
|
|
84
|
+
thoughts: safeJsonParse(data.thoughts, []),
|
|
85
|
+
status: data.status || 'active',
|
|
86
|
+
conclusion: data.conclusion || undefined,
|
|
87
|
+
tags: safeJsonParse(data.tags, []),
|
|
88
|
+
createdAt: parseInt(data.createdAt, 10) || 0,
|
|
89
|
+
updatedAt: parseInt(data.updatedAt, 10) || 0,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create a new thinking chain with its first thought
|
|
94
|
+
*/
|
|
95
|
+
export async function createChain(params) {
|
|
96
|
+
const client = await getRedis();
|
|
97
|
+
const now = Date.now();
|
|
98
|
+
const firstThought = {
|
|
99
|
+
index: 0,
|
|
100
|
+
content: params.content,
|
|
101
|
+
confidence: Math.max(0, Math.min(100, params.confidence)),
|
|
102
|
+
reasoning: params.reasoning,
|
|
103
|
+
createdAt: now,
|
|
104
|
+
};
|
|
105
|
+
const chain = {
|
|
106
|
+
id: generateChainId(),
|
|
107
|
+
title: params.title,
|
|
108
|
+
agentId: params.agentId,
|
|
109
|
+
sessionId: params.sessionId,
|
|
110
|
+
thoughts: [firstThought],
|
|
111
|
+
status: 'active',
|
|
112
|
+
tags: params.tags || [],
|
|
113
|
+
createdAt: now,
|
|
114
|
+
updatedAt: now,
|
|
115
|
+
};
|
|
116
|
+
const key = THINKING_KEYS.chain(chain.id);
|
|
117
|
+
await client.hset(key, serializeChain(chain));
|
|
118
|
+
await client.expire(key, THINKING_TTL);
|
|
119
|
+
// Add to indexes
|
|
120
|
+
await client.sadd(THINKING_KEYS.bySession(chain.sessionId), chain.id);
|
|
121
|
+
await client.sadd(THINKING_KEYS.byAgent(chain.agentId), chain.id);
|
|
122
|
+
return chain;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get a chain by ID
|
|
126
|
+
*/
|
|
127
|
+
export async function getChain(chainId) {
|
|
128
|
+
const client = await getRedis();
|
|
129
|
+
const data = await client.hgetall(THINKING_KEYS.chain(chainId));
|
|
130
|
+
if (!data || Object.keys(data).length === 0) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
return parseChain(data);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Add a new thought to the end of a chain (forward-only)
|
|
137
|
+
*/
|
|
138
|
+
export async function addThought(chainId, params) {
|
|
139
|
+
const client = await getRedis();
|
|
140
|
+
const chain = await getChain(chainId);
|
|
141
|
+
if (!chain)
|
|
142
|
+
throw new Error(`Chain not found: ${chainId}`);
|
|
143
|
+
if (chain.status !== 'active')
|
|
144
|
+
throw new Error(`Chain is ${chain.status}, cannot add thoughts`);
|
|
145
|
+
const now = Date.now();
|
|
146
|
+
const thought = {
|
|
147
|
+
index: chain.thoughts.length,
|
|
148
|
+
content: params.content,
|
|
149
|
+
confidence: Math.max(0, Math.min(100, params.confidence)),
|
|
150
|
+
reasoning: params.reasoning,
|
|
151
|
+
createdAt: now,
|
|
152
|
+
};
|
|
153
|
+
chain.thoughts.push(thought);
|
|
154
|
+
const key = THINKING_KEYS.chain(chainId);
|
|
155
|
+
await client.hset(key, {
|
|
156
|
+
thoughts: JSON.stringify(chain.thoughts),
|
|
157
|
+
updatedAt: String(now),
|
|
158
|
+
});
|
|
159
|
+
return thought;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Revise a thought in the chain.
|
|
163
|
+
* Only allowed if:
|
|
164
|
+
* - thoughtIndex is the last thought's index (revising latest), OR
|
|
165
|
+
* - The latest thought has confidence >= 90
|
|
166
|
+
*/
|
|
167
|
+
export async function reviseThought(chainId, params) {
|
|
168
|
+
const client = await getRedis();
|
|
169
|
+
const chain = await getChain(chainId);
|
|
170
|
+
if (!chain)
|
|
171
|
+
throw new Error(`Chain not found: ${chainId}`);
|
|
172
|
+
if (chain.status !== 'active')
|
|
173
|
+
throw new Error(`Chain is ${chain.status}, cannot revise thoughts`);
|
|
174
|
+
const lastThought = chain.thoughts[chain.thoughts.length - 1];
|
|
175
|
+
const isLastThought = params.thoughtIndex === lastThought.index;
|
|
176
|
+
const highConfidence = lastThought.confidence >= 90;
|
|
177
|
+
if (!isLastThought && !highConfidence) {
|
|
178
|
+
throw new Error(`Cannot revise thought #${params.thoughtIndex}: backtracking blocked. ` +
|
|
179
|
+
`Latest thought confidence is ${lastThought.confidence}% (need ≥90%) ` +
|
|
180
|
+
`or revise the latest thought (#${lastThought.index}).`);
|
|
181
|
+
}
|
|
182
|
+
if (params.thoughtIndex < 0 || params.thoughtIndex >= chain.thoughts.length) {
|
|
183
|
+
throw new Error(`Thought index ${params.thoughtIndex} out of range (0-${chain.thoughts.length - 1})`);
|
|
184
|
+
}
|
|
185
|
+
const now = Date.now();
|
|
186
|
+
// Append a new thought that marks itself as a revision
|
|
187
|
+
const revisedThought = {
|
|
188
|
+
index: chain.thoughts.length,
|
|
189
|
+
content: params.content,
|
|
190
|
+
confidence: Math.max(0, Math.min(100, params.confidence)),
|
|
191
|
+
reasoning: params.reasoning,
|
|
192
|
+
revisedFrom: params.thoughtIndex,
|
|
193
|
+
createdAt: now,
|
|
194
|
+
};
|
|
195
|
+
chain.thoughts.push(revisedThought);
|
|
196
|
+
const key = THINKING_KEYS.chain(chainId);
|
|
197
|
+
await client.hset(key, {
|
|
198
|
+
thoughts: JSON.stringify(chain.thoughts),
|
|
199
|
+
updatedAt: String(now),
|
|
200
|
+
});
|
|
201
|
+
return revisedThought;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Branch a new chain from a specific thought in an existing chain
|
|
205
|
+
*/
|
|
206
|
+
export async function branchChain(params) {
|
|
207
|
+
const client = await getRedis();
|
|
208
|
+
const sourceChain = await getChain(params.sourceChainId);
|
|
209
|
+
if (!sourceChain)
|
|
210
|
+
throw new Error(`Source chain not found: ${params.sourceChainId}`);
|
|
211
|
+
if (params.thoughtIndex < 0 || params.thoughtIndex >= sourceChain.thoughts.length) {
|
|
212
|
+
throw new Error(`Thought index ${params.thoughtIndex} out of range (0-${sourceChain.thoughts.length - 1})`);
|
|
213
|
+
}
|
|
214
|
+
const now = Date.now();
|
|
215
|
+
const firstThought = {
|
|
216
|
+
index: 0,
|
|
217
|
+
content: params.content,
|
|
218
|
+
confidence: Math.max(0, Math.min(100, params.confidence)),
|
|
219
|
+
reasoning: params.reasoning,
|
|
220
|
+
createdAt: now,
|
|
221
|
+
};
|
|
222
|
+
const newChain = {
|
|
223
|
+
id: generateChainId(),
|
|
224
|
+
title: params.title,
|
|
225
|
+
agentId: sourceChain.agentId,
|
|
226
|
+
sessionId: sourceChain.sessionId,
|
|
227
|
+
parentChainId: params.sourceChainId,
|
|
228
|
+
parentThoughtIndex: params.thoughtIndex,
|
|
229
|
+
thoughts: [firstThought],
|
|
230
|
+
status: 'active',
|
|
231
|
+
tags: [...sourceChain.tags],
|
|
232
|
+
createdAt: now,
|
|
233
|
+
updatedAt: now,
|
|
234
|
+
};
|
|
235
|
+
// Save new chain
|
|
236
|
+
const key = THINKING_KEYS.chain(newChain.id);
|
|
237
|
+
await client.hset(key, serializeChain(newChain));
|
|
238
|
+
await client.expire(key, THINKING_TTL);
|
|
239
|
+
// Add to indexes
|
|
240
|
+
await client.sadd(THINKING_KEYS.bySession(newChain.sessionId), newChain.id);
|
|
241
|
+
await client.sadd(THINKING_KEYS.byAgent(newChain.agentId), newChain.id);
|
|
242
|
+
// Record branch in source chain's thought
|
|
243
|
+
const sourceThought = sourceChain.thoughts[params.thoughtIndex];
|
|
244
|
+
if (!sourceThought.branches)
|
|
245
|
+
sourceThought.branches = [];
|
|
246
|
+
sourceThought.branches.push(newChain.id);
|
|
247
|
+
await client.hset(THINKING_KEYS.chain(params.sourceChainId), {
|
|
248
|
+
thoughts: JSON.stringify(sourceChain.thoughts),
|
|
249
|
+
updatedAt: String(now),
|
|
250
|
+
});
|
|
251
|
+
return newChain;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Conclude a chain with a final conclusion
|
|
255
|
+
*/
|
|
256
|
+
export async function concludeChain(chainId, conclusion) {
|
|
257
|
+
const client = await getRedis();
|
|
258
|
+
const chain = await getChain(chainId);
|
|
259
|
+
if (!chain)
|
|
260
|
+
throw new Error(`Chain not found: ${chainId}`);
|
|
261
|
+
if (chain.status !== 'active')
|
|
262
|
+
throw new Error(`Chain is already ${chain.status}`);
|
|
263
|
+
const now = Date.now();
|
|
264
|
+
const key = THINKING_KEYS.chain(chainId);
|
|
265
|
+
await client.hset(key, {
|
|
266
|
+
status: 'concluded',
|
|
267
|
+
conclusion,
|
|
268
|
+
updatedAt: String(now),
|
|
269
|
+
});
|
|
270
|
+
chain.status = 'concluded';
|
|
271
|
+
chain.conclusion = conclusion;
|
|
272
|
+
chain.updatedAt = now;
|
|
273
|
+
return chain;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* List chains with optional filters
|
|
277
|
+
*/
|
|
278
|
+
export async function listChains(params) {
|
|
279
|
+
const client = await getRedis();
|
|
280
|
+
let chainIds = [];
|
|
281
|
+
if (params.agentId) {
|
|
282
|
+
chainIds = await client.smembers(THINKING_KEYS.byAgent(params.agentId));
|
|
283
|
+
}
|
|
284
|
+
else if (params.sessionId) {
|
|
285
|
+
chainIds = await client.smembers(THINKING_KEYS.bySession(params.sessionId));
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
return [];
|
|
289
|
+
}
|
|
290
|
+
const chains = [];
|
|
291
|
+
for (const id of chainIds) {
|
|
292
|
+
const chain = await getChain(id);
|
|
293
|
+
if (!chain)
|
|
294
|
+
continue;
|
|
295
|
+
if (params.status && chain.status !== params.status)
|
|
296
|
+
continue;
|
|
297
|
+
chains.push(chain);
|
|
298
|
+
}
|
|
299
|
+
// Sort by updatedAt desc
|
|
300
|
+
chains.sort((a, b) => b.updatedAt - a.updatedAt);
|
|
301
|
+
const limit = params.limit || 20;
|
|
302
|
+
return chains.slice(0, limit);
|
|
303
|
+
}
|
|
304
|
+
//# sourceMappingURL=thinking-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinking-store.js","sourceRoot":"","sources":["../../src/thinking/thinking-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,C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