@j0hanz/thinkseq-mcp 1.2.7 → 2.1.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 +160 -236
- package/dist/app.d.ts +2 -1
- package/dist/app.js +23 -4
- package/dist/appConfig/env.d.ts +3 -0
- package/dist/appConfig/env.js +9 -0
- package/dist/appConfig/runDependencies.d.ts +4 -4
- package/dist/appConfig/runDependencies.js +32 -15
- package/dist/assets/logo.svg +4029 -0
- package/dist/engine/revision.d.ts +4 -2
- package/dist/engine/revision.js +9 -16
- package/dist/engine/thoughtQueries.js +37 -22
- package/dist/engine/thoughtStore.d.ts +7 -0
- package/dist/engine/thoughtStore.js +134 -100
- package/dist/engine.d.ts +2 -0
- package/dist/engine.js +135 -58
- package/dist/index.js +1 -0
- package/dist/instructions.md +20 -19
- package/dist/lib/mcpLogging.d.ts +4 -1
- package/dist/lib/mcpLogging.js +27 -9
- package/dist/lib/types.d.ts +3 -0
- package/dist/schemas/inputs.d.ts +1 -0
- package/dist/schemas/inputs.js +6 -0
- package/dist/schemas/outputs.d.ts +5 -5
- package/dist/schemas/outputs.js +5 -5
- package/dist/tools/thinkseq.d.ts +1 -1
- package/dist/tools/thinkseq.js +78 -65
- package/package.json +23 -20
- package/dist/appConfig.d.ts +0 -4
- package/dist/appConfig.js +0 -2
- package/dist/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -1,220 +1,177 @@
|
|
|
1
1
|
# ThinkSeq MCP Server
|
|
2
2
|
|
|
3
|
-
<img src="
|
|
3
|
+
<img src="assets/logo.svg" alt="ThinkSeq MCP Server Logo" width="225" />
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/@j0hanz/thinkseq-mcp)
|
|
8
|
-
|
|
9
|
-
## One-click install
|
|
5
|
+
[](https://www.npmjs.com/package/@j0hanz/thinkseq-mcp)[](https://opensource.org/licenses/MIT)[](https://github.com/modelcontextprotocol/typescript-sdk)
|
|
10
6
|
|
|
11
7
|
[](https://insiders.vscode.dev/redirect/mcp/install?name=thinkseq&inputs=%5B%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fthinkseq-mcp%40latest%22%5D%7D) [](https://insiders.vscode.dev/redirect/mcp/install?name=thinkseq&inputs=%5B%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fthinkseq-mcp%40latest%22%5D%7D&quality=insiders)
|
|
12
8
|
|
|
13
9
|
[](https://cursor.com/install-mcp?name=thinkseq&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBqMGhhbnovdGhpbmtzZXEtbWNwQGxhdGVzdCJdfQ==)
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
ThinkSeq exposes a single MCP tool, `thinkseq`, for structured, sequential thinking. The server runs over stdio and stores an in-memory thought history so it can return progress, active-path context, and revision metadata on each call.
|
|
18
|
-
|
|
19
|
-
## Quick start
|
|
11
|
+
An MCP server for structured, sequential thinking with revision support.
|
|
20
12
|
|
|
21
|
-
|
|
22
|
-
npx -y @j0hanz/thinkseq-mcp@latest
|
|
23
|
-
```
|
|
13
|
+
## Overview
|
|
24
14
|
|
|
25
|
-
|
|
15
|
+
ThinkSeq exposes a single MCP tool, `thinkseq`, that enables Language Models to "think" in a structured, step-by-step manner. It maintains an in-memory history of thoughts, calculates progress, and critically allows for **destructive revision**—where a model can realize a mistake, "rewind" to a previous step, and branch off with a correction. This capability mirrors human reasoning patterns and improves problem-solving accuracy for complex tasks.
|
|
26
16
|
|
|
27
|
-
|
|
28
|
-
thinkseq --max-thoughts 500 --max-memory-mb 100
|
|
29
|
-
```
|
|
17
|
+
## Key Features
|
|
30
18
|
|
|
31
|
-
|
|
19
|
+
- **Sequential Thinking**: Records thoughts as discrete steps with auto-incrementing numbers.
|
|
20
|
+
- **Progress Tracking**: Automatically calculates progress (0.0 to 1.0) based on estimated total thoughts.
|
|
21
|
+
- **Revision Support**: Allows models to revise specific past thoughts, superseding the old path and starting a new reasoning branch.
|
|
22
|
+
- **Context Awareness**: Returns recent thoughts and revision context with every tool call to keep the model grounded.
|
|
23
|
+
- **Session Isolation**: Supports multiple concurrent thinking sessions via `sessionId`.
|
|
24
|
+
- **Memory Management**: Configurable limits for max thoughts and memory usage to prevent resource exhaustion.
|
|
32
25
|
|
|
33
|
-
|
|
34
|
-
- `--max-memory-mb <number>`: Max memory (MB) for stored thoughts.
|
|
35
|
-
- `--shutdown-timeout-ms <number>`: Graceful shutdown timeout.
|
|
36
|
-
- `--package-read-timeout-ms <number>`: Package.json read timeout.
|
|
37
|
-
- `-h, --help`: Show help.
|
|
26
|
+
## Tech Stack
|
|
38
27
|
|
|
39
|
-
|
|
28
|
+
- **Runtime**: Node.js >=22.0.0
|
|
29
|
+
- **Language**: TypeScript 5.9+
|
|
30
|
+
- **MCP SDK**: `@modelcontextprotocol/sdk`
|
|
31
|
+
- **Validation**: `zod`
|
|
40
32
|
|
|
41
|
-
|
|
42
|
-
- `maxMemoryBytes` default: 100 MB (derived from `--max-memory-mb`).
|
|
43
|
-
- `packageReadTimeoutMs` default: 2000 ms.
|
|
44
|
-
- `shutdownTimeoutMs` default: 5000 ms.
|
|
33
|
+
## Repository Structure
|
|
45
34
|
|
|
46
|
-
|
|
35
|
+
```text
|
|
36
|
+
c:\thinkseq-mcp
|
|
37
|
+
├── dist/ # Compiled JavaScript
|
|
38
|
+
├── src/
|
|
39
|
+
│ ├── app.ts # Application entry and MCP wiring
|
|
40
|
+
│ ├── engine.ts # Core thinking engine logic
|
|
41
|
+
│ ├── engineConfig.ts # Configuration defaults
|
|
42
|
+
│ ├── index.ts # CLI entrypoint
|
|
43
|
+
│ ├── lib/ # Utilities (CLI, logging, types)
|
|
44
|
+
│ ├── schemas/ # Zod schemas for inputs/outputs
|
|
45
|
+
│ └── tools/ # MCP tool definitions
|
|
46
|
+
├── package.json
|
|
47
|
+
└── tsconfig.json
|
|
48
|
+
```
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
## Requirements
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
{
|
|
52
|
-
"mcpServers": {
|
|
53
|
-
"thinkseq": {
|
|
54
|
-
"command": "npx",
|
|
55
|
-
"args": ["-y", "@j0hanz/thinkseq-mcp@latest"]
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
```
|
|
52
|
+
- **Node.js**: Version 22.0.0 or higher.
|
|
60
53
|
|
|
61
|
-
|
|
62
|
-
<summary><b>VS Code</b></summary>
|
|
54
|
+
## Quickstart
|
|
63
55
|
|
|
64
|
-
|
|
56
|
+
To run the server using `npx`:
|
|
65
57
|
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
"mcpServers": {
|
|
69
|
-
"thinkseq": {
|
|
70
|
-
"command": "npx",
|
|
71
|
-
"args": ["-y", "@j0hanz/thinkseq-mcp@latest"]
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
58
|
+
```bash
|
|
59
|
+
npx -y @j0hanz/thinkseq-mcp@latest
|
|
75
60
|
```
|
|
76
61
|
|
|
77
|
-
</details>
|
|
78
|
-
|
|
79
62
|
<details>
|
|
80
|
-
<summary><b>
|
|
63
|
+
<summary><b>Quick Test with MCP Inspector</b></summary>
|
|
81
64
|
|
|
82
|
-
|
|
65
|
+
You can inspect the tools using the MCP Inspector:
|
|
83
66
|
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
"mcpServers": {
|
|
87
|
-
"thinkseq": {
|
|
88
|
-
"command": "npx",
|
|
89
|
-
"args": ["-y", "@j0hanz/thinkseq-mcp@latest"]
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
67
|
+
```bash
|
|
68
|
+
npx @modelcontextprotocol/inspector npx -y @j0hanz/thinkseq-mcp@latest
|
|
93
69
|
```
|
|
94
70
|
|
|
95
71
|
</details>
|
|
96
72
|
|
|
97
|
-
|
|
98
|
-
<summary><b>Cursor</b></summary>
|
|
73
|
+
## Installation
|
|
99
74
|
|
|
100
|
-
|
|
101
|
-
2. Click **Add New MCP Server**.
|
|
102
|
-
3. Fill in the details:
|
|
103
|
-
- **Name:** `thinkseq`
|
|
104
|
-
- **Type:** `command`
|
|
105
|
-
- **Command:** `npx -y @j0hanz/thinkseq-mcp@latest`
|
|
75
|
+
### Using NPX (Recommended)
|
|
106
76
|
|
|
107
|
-
|
|
77
|
+
This server is designed to be run directly via `npx` in your MCP client configuration.
|
|
108
78
|
|
|
109
|
-
|
|
110
|
-
|
|
79
|
+
```bash
|
|
80
|
+
npx -y @j0hanz/thinkseq-mcp@latest
|
|
81
|
+
```
|
|
111
82
|
|
|
112
|
-
|
|
83
|
+
### From Source
|
|
113
84
|
|
|
114
|
-
|
|
115
|
-
{
|
|
116
|
-
"mcpServers": {
|
|
117
|
-
"thinkseq": {
|
|
118
|
-
"command": "npx",
|
|
119
|
-
"args": ["-y", "@j0hanz/thinkseq-mcp@latest"]
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
```
|
|
85
|
+
1. Clone the repository:
|
|
124
86
|
|
|
125
|
-
|
|
87
|
+
```bash
|
|
88
|
+
git clone https://github.com/j0hanz/thinkseq-mcp-server.git
|
|
89
|
+
cd thinkseq-mcp-server
|
|
90
|
+
```
|
|
126
91
|
|
|
127
|
-
|
|
92
|
+
2. Install dependencies:
|
|
128
93
|
|
|
129
|
-
|
|
94
|
+
```bash
|
|
95
|
+
npm install
|
|
96
|
+
```
|
|
130
97
|
|
|
131
|
-
|
|
98
|
+
3. Build the project:
|
|
132
99
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
| `totalThoughts` | number | no | Estimated total thoughts (1-25, default: 3). |
|
|
137
|
-
| `revisesThought` | number | no | Revise a previous thought by number. Original preserved for audit. |
|
|
100
|
+
```bash
|
|
101
|
+
npm run build
|
|
102
|
+
```
|
|
138
103
|
|
|
139
|
-
|
|
104
|
+
4. Run the server:
|
|
140
105
|
|
|
141
|
-
|
|
106
|
+
```bash
|
|
107
|
+
node dist/index.js
|
|
108
|
+
```
|
|
142
109
|
|
|
143
|
-
|
|
110
|
+
## Configuration
|
|
144
111
|
|
|
145
|
-
|
|
146
|
-
| :------- | :------ | :----------------------------------- |
|
|
147
|
-
| `ok` | boolean | `true` on success, `false` on error. |
|
|
148
|
-
| `result` | object | Present when `ok` is true. |
|
|
149
|
-
| `error` | object | Present when `ok` is false. |
|
|
112
|
+
The server is configured via CLI arguments.
|
|
150
113
|
|
|
151
|
-
|
|
114
|
+
| Argument | Description | Default |
|
|
115
|
+
| :----------------------------------- | :-------------------------------------------- | :------ |
|
|
116
|
+
| `--max-thoughts <number>` | Max thoughts to keep in memory before pruning | 500 |
|
|
117
|
+
| `--max-memory-mb <number>` | Max memory (MB) for stored thoughts | 100 |
|
|
118
|
+
| `--shutdown-timeout-ms <number>` | Graceful shutdown timeout in ms | 5000 |
|
|
119
|
+
| `--package-read-timeout-ms <number>` | Package.json read timeout in ms | 2000 |
|
|
120
|
+
| `-h, --help` | Show help message | - |
|
|
152
121
|
|
|
153
|
-
|
|
154
|
-
| :--------------------- | :------- | :--------------------------------------------------- |
|
|
155
|
-
| `thoughtNumber` | number | Auto-incremented thought number. |
|
|
156
|
-
| `totalThoughts` | number | Effective total thoughts (at least `thoughtNumber`). |
|
|
157
|
-
| `progress` | number | `thoughtNumber / totalThoughts` (0 to 1). |
|
|
158
|
-
| `isComplete` | boolean | `true` when `thoughtNumber >= totalThoughts`. |
|
|
159
|
-
| `thoughtHistoryLength` | number | Stored thought count after pruning. |
|
|
160
|
-
| `hasRevisions` | boolean | `true` if any thought has been revised. |
|
|
161
|
-
| `activePathLength` | number | Count of non-superseded thoughts. |
|
|
162
|
-
| `revisableThoughts` | number[] | Thought numbers available for revision. |
|
|
163
|
-
| `context` | object | Recent context summary (see below). |
|
|
122
|
+
## MCP Surface
|
|
164
123
|
|
|
165
|
-
|
|
124
|
+
### Tools
|
|
166
125
|
|
|
167
|
-
|
|
168
|
-
| :--------------- | :----- | :---------------------------------------------------------------------- |
|
|
169
|
-
| `recentThoughts` | array | Up to the last 5 active thoughts with `stepIndex`, `number`, `preview`. |
|
|
170
|
-
| `revisionInfo` | object | Present when revising: `revises` (number) and `supersedes` (number[]). |
|
|
126
|
+
#### `thinkseq`
|
|
171
127
|
|
|
172
|
-
|
|
128
|
+
Record a concise thinking step. Be brief: capture only the essential insight, calculation, or decision.
|
|
173
129
|
|
|
174
|
-
|
|
175
|
-
- Revisions are a destructive rewind: they supersede the target thought and any later active thoughts in the active chain.
|
|
176
|
-
- `recentThoughts[].stepIndex` is a contiguous 1-based index in the current active chain (useful when thought numbers become non-contiguous after revisions).
|
|
130
|
+
**Parameters:**
|
|
177
131
|
|
|
178
|
-
|
|
132
|
+
| Name | Type | Required | Description |
|
|
133
|
+
| :--------------- | :------ | :------: | :-------------------------------------------------------------------------------------------------------------------- |
|
|
134
|
+
| `thought` | string | Yes | Your current thinking step (1-8000 chars). |
|
|
135
|
+
| `sessionId` | string | No | Optional session identifier (max 200 chars) to isolate thought histories. |
|
|
136
|
+
| `totalThoughts` | integer | No | Estimated total thoughts (1-25, default: 3). |
|
|
137
|
+
| `revisesThought` | integer | No | Revise a previous thought by number. The original is preserved for audit, but the active chain rewinds to this point. |
|
|
179
138
|
|
|
180
|
-
|
|
181
|
-
| :----------------------------- | :---------------------------------------------- |
|
|
182
|
-
| `E_REVISION_TARGET_NOT_FOUND` | The requested thought number does not exist. |
|
|
183
|
-
| `E_REVISION_TARGET_SUPERSEDED` | The requested thought was already superseded. |
|
|
184
|
-
| `E_THINK` | Unexpected tool failure while processing input. |
|
|
139
|
+
**Returns:**
|
|
185
140
|
|
|
186
|
-
|
|
141
|
+
A JSON object containing the current state of the thinking process, including:
|
|
187
142
|
|
|
188
|
-
|
|
143
|
+
- `thoughtNumber`: The current step number.
|
|
144
|
+
- `progress`: A value between 0 and 1 indicating completion.
|
|
145
|
+
- `isComplete`: Boolean indicating if the thought process is finished.
|
|
146
|
+
- `revisableThoughts`: Array of thought numbers that can be revised.
|
|
147
|
+
- `context`: Recent thoughts and revision information.
|
|
189
148
|
|
|
190
|
-
Input
|
|
149
|
+
**Example Input:**
|
|
191
150
|
|
|
192
151
|
```json
|
|
193
152
|
{
|
|
194
|
-
"thought": "
|
|
153
|
+
"thought": "I need to calculate the fibonacci sequence up to 10.",
|
|
154
|
+
"totalThoughts": 5
|
|
195
155
|
}
|
|
196
156
|
```
|
|
197
157
|
|
|
198
|
-
Output
|
|
158
|
+
**Example Output:**
|
|
199
159
|
|
|
200
160
|
```json
|
|
201
161
|
{
|
|
202
162
|
"ok": true,
|
|
203
163
|
"result": {
|
|
204
164
|
"thoughtNumber": 1,
|
|
205
|
-
"totalThoughts":
|
|
206
|
-
"progress": 0.
|
|
165
|
+
"totalThoughts": 5,
|
|
166
|
+
"progress": 0.2,
|
|
207
167
|
"isComplete": false,
|
|
208
|
-
"thoughtHistoryLength": 1,
|
|
209
|
-
"hasRevisions": false,
|
|
210
|
-
"activePathLength": 1,
|
|
211
168
|
"revisableThoughts": [1],
|
|
212
169
|
"context": {
|
|
213
170
|
"recentThoughts": [
|
|
214
171
|
{
|
|
215
172
|
"stepIndex": 1,
|
|
216
173
|
"number": 1,
|
|
217
|
-
"preview": "
|
|
174
|
+
"preview": "I need to calculate the fibonacci sequence up to 10."
|
|
218
175
|
}
|
|
219
176
|
]
|
|
220
177
|
}
|
|
@@ -222,128 +179,95 @@ Output (success):
|
|
|
222
179
|
}
|
|
223
180
|
```
|
|
224
181
|
|
|
225
|
-
|
|
182
|
+
### Resources
|
|
183
|
+
|
|
184
|
+
_No resources are currently exposed by this server._
|
|
185
|
+
|
|
186
|
+
### Prompts
|
|
226
187
|
|
|
227
|
-
|
|
188
|
+
_No prompts are currently exposed by this server._
|
|
228
189
|
|
|
229
|
-
|
|
190
|
+
## Client Configuration Examples
|
|
191
|
+
|
|
192
|
+
<details>
|
|
193
|
+
<summary><b>VS Code (mcp.json)</b></summary>
|
|
230
194
|
|
|
231
195
|
```json
|
|
232
196
|
{
|
|
233
|
-
"
|
|
234
|
-
|
|
197
|
+
"mcpServers": {
|
|
198
|
+
"thinkseq": {
|
|
199
|
+
"command": "npx",
|
|
200
|
+
"args": ["-y", "@j0hanz/thinkseq-mcp@latest"]
|
|
201
|
+
}
|
|
202
|
+
}
|
|
235
203
|
}
|
|
236
204
|
```
|
|
237
205
|
|
|
238
|
-
|
|
206
|
+
</details>
|
|
207
|
+
|
|
208
|
+
<details>
|
|
209
|
+
<summary><b>Claude Desktop</b></summary>
|
|
210
|
+
|
|
211
|
+
Add this to your `claude_desktop_config.json`:
|
|
239
212
|
|
|
240
213
|
```json
|
|
241
214
|
{
|
|
242
|
-
"
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
"progress": 0.6666666666666666,
|
|
247
|
-
"isComplete": false,
|
|
248
|
-
"thoughtHistoryLength": 2,
|
|
249
|
-
"hasRevisions": true,
|
|
250
|
-
"activePathLength": 1,
|
|
251
|
-
"revisableThoughts": [2],
|
|
252
|
-
"context": {
|
|
253
|
-
"recentThoughts": [
|
|
254
|
-
{
|
|
255
|
-
"stepIndex": 1,
|
|
256
|
-
"number": 2,
|
|
257
|
-
"preview": "Better approach: validate first, then parse"
|
|
258
|
-
}
|
|
259
|
-
],
|
|
260
|
-
"revisionInfo": {
|
|
261
|
-
"revises": 1,
|
|
262
|
-
"supersedes": [1]
|
|
263
|
-
}
|
|
215
|
+
"mcpServers": {
|
|
216
|
+
"thinkseq": {
|
|
217
|
+
"command": "npx",
|
|
218
|
+
"args": ["-y", "@j0hanz/thinkseq-mcp@latest"]
|
|
264
219
|
}
|
|
265
220
|
}
|
|
266
221
|
}
|
|
267
222
|
```
|
|
268
223
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
- Inputs are validated with Zod and unknown keys are rejected.
|
|
272
|
-
- `thoughtNumber` is auto-incremented (1, 2, 3...).
|
|
273
|
-
- `totalThoughts` defaults to 3, must be in 1-25, and is adjusted up to at least `thoughtNumber`.
|
|
274
|
-
- The engine stores thoughts in memory and prunes when limits are exceeded:
|
|
275
|
-
- `maxThoughts` default: 500 (cap 10000). When exceeded, prunes the oldest 10% (minimum excess).
|
|
276
|
-
- `maxMemoryBytes` default: 100 MB. When exceeded and history is large, prunes roughly 20% of history.
|
|
277
|
-
- `estimatedThoughtOverheadBytes` default: 200.
|
|
278
|
-
|
|
279
|
-
## Diagnostics
|
|
280
|
-
|
|
281
|
-
This server publishes events via `node:diagnostics_channel`:
|
|
224
|
+
</details>
|
|
282
225
|
|
|
283
|
-
|
|
284
|
-
|
|
226
|
+
<details>
|
|
227
|
+
<summary><b>Cursor</b></summary>
|
|
285
228
|
|
|
286
|
-
|
|
229
|
+
1. Navigate to **Settings** > **General** > **MCP**.
|
|
230
|
+
2. Click **Add New MCP Server**.
|
|
231
|
+
3. Name: `thinkseq`
|
|
232
|
+
4. Type: `command`
|
|
233
|
+
5. Command: `npx -y @j0hanz/thinkseq-mcp@latest`
|
|
287
234
|
|
|
288
|
-
|
|
235
|
+
</details>
|
|
289
236
|
|
|
290
|
-
##
|
|
237
|
+
## Security
|
|
291
238
|
|
|
292
|
-
|
|
239
|
+
- **Stdio Transport**: This server runs over stdio. It creates a console bridge to intercept `console.log` calls and redirect them to standard error (stderr) to prevent interfering with the JSON-RPC protocol.
|
|
240
|
+
- **Memory Limits**: The server enforces maximum thought counts and memory usage limits (configurable via CLI) to prevent memory exhaustion attacks.
|
|
241
|
+
- **Input Validation**: All inputs are strictly validated using Zod schemas.
|
|
293
242
|
|
|
294
|
-
|
|
243
|
+
## Development Workflow
|
|
295
244
|
|
|
296
|
-
|
|
245
|
+
1. **Install dependencies**:
|
|
297
246
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
| `npm run dev` | Run the server in watch mode. |
|
|
302
|
-
| `npm start` | Run `dist/index.js`. |
|
|
303
|
-
| `npm run test` | Run the test suite. |
|
|
304
|
-
| `npm run test:ci` | Build, then run the test suite. |
|
|
305
|
-
| `npm run test:coverage` | Run tests with coverage output. |
|
|
306
|
-
| `npm run lint` | Lint with ESLint. |
|
|
307
|
-
| `npm run format` | Format with Prettier. |
|
|
308
|
-
| `npm run format:check` | Check formatting with Prettier. |
|
|
309
|
-
| `npm run type-check` | Type-check without emitting. |
|
|
310
|
-
| `npm run inspector` | Launch the MCP inspector. |
|
|
311
|
-
| `npm run clean` | Remove `dist/`. |
|
|
312
|
-
| `npm run prepublishOnly` | Lint, type-check, and build. |
|
|
313
|
-
| `npm run benchmark` | Run `benchmark/engine.bench.ts`. |
|
|
247
|
+
```bash
|
|
248
|
+
npm install
|
|
249
|
+
```
|
|
314
250
|
|
|
315
|
-
|
|
251
|
+
2. **Run in development mode**:
|
|
316
252
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
- `THINKSEQ_BENCH_PIN` (optional CPU affinity mask)
|
|
253
|
+
```bash
|
|
254
|
+
npm run dev # Runs tsc in watch mode
|
|
255
|
+
npm run dev:run # Runs the built app in watch mode
|
|
256
|
+
```
|
|
322
257
|
|
|
323
|
-
|
|
258
|
+
3. **Run tests**:
|
|
324
259
|
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
appConfig.ts # Dependency wiring and shutdown handling
|
|
329
|
-
engine.ts # Core thinking engine
|
|
330
|
-
engineConfig.ts # Defaults and limits
|
|
331
|
-
engine/ # Revision and query helpers
|
|
332
|
-
lib/ # CLI, diagnostics, errors, protocol, stdio utilities
|
|
333
|
-
schemas/ # Zod input/output schemas
|
|
334
|
-
tools/ # MCP tool definitions (thinkseq)
|
|
335
|
-
tests/ # Node.js tests
|
|
336
|
-
benchmark/ # Benchmark targets
|
|
337
|
-
docs/ # Assets (logo)
|
|
338
|
-
dist/ # Build output
|
|
339
|
-
scripts/ # Quality gates and metrics helpers
|
|
340
|
-
metrics/ # Generated metrics outputs
|
|
341
|
-
```
|
|
260
|
+
```bash
|
|
261
|
+
npm test
|
|
262
|
+
```
|
|
342
263
|
|
|
343
|
-
|
|
264
|
+
4. **Lint and Format**:
|
|
344
265
|
|
|
345
|
-
|
|
266
|
+
```bash
|
|
267
|
+
npm run lint
|
|
268
|
+
npm run format
|
|
269
|
+
```
|
|
346
270
|
|
|
347
|
-
## Contributing
|
|
271
|
+
## Contributing & License
|
|
348
272
|
|
|
349
|
-
|
|
273
|
+
This project is licensed under the MIT License.
|
package/dist/app.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { RunDependencies } from './appConfig/runDependencies.js';
|
|
2
|
+
import type { ProcessLike } from './appConfig/types.js';
|
|
2
3
|
interface ProcessErrorHandlerDeps {
|
|
3
4
|
processLike?: ProcessLike;
|
|
4
5
|
logError?: (message: string) => void;
|
package/dist/app.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
import { resolvePackageIdentity, resolveRunDependencies, } from './appConfig/runDependencies.js';
|
|
4
|
+
import { buildShutdownDependencies } from './appConfig/shutdown.js';
|
|
2
5
|
import { installConsoleBridge, installMcpLogging } from './lib/mcpLogging.js';
|
|
3
6
|
const toError = (value) => value instanceof Error ? value : new Error(String(value));
|
|
4
7
|
const createExit = (proc, exit) => exit ?? ((code) => proc.exit(code));
|
|
@@ -7,6 +10,19 @@ const createHandlerFor = (logError, exit) => (label) => (value) => {
|
|
|
7
10
|
logError(`thinkseq: ${label}: ${error.message}`);
|
|
8
11
|
exit(1);
|
|
9
12
|
};
|
|
13
|
+
function getLocalIconData() {
|
|
14
|
+
try {
|
|
15
|
+
const iconPath = new URL('../assets/logo.svg', import.meta.url);
|
|
16
|
+
const buffer = readFileSync(iconPath);
|
|
17
|
+
if (buffer.length > 2 * 1024 * 1024) {
|
|
18
|
+
console.warn('Warning: logo.svg is larger than 2MB');
|
|
19
|
+
}
|
|
20
|
+
return `data:image/svg+xml;base64,${buffer.toString('base64')}`;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
10
26
|
export function installProcessErrorHandlers(deps = {}) {
|
|
11
27
|
const proc = deps.processLike ?? process;
|
|
12
28
|
const logError = deps.logError ?? console.error;
|
|
@@ -19,15 +35,18 @@ export async function run(deps = {}) {
|
|
|
19
35
|
const resolved = resolveRunDependencies(deps);
|
|
20
36
|
const pkg = await resolved.readPackageJson(AbortSignal.timeout(resolved.packageReadTimeoutMs));
|
|
21
37
|
const { name, version } = resolvePackageIdentity(pkg);
|
|
22
|
-
const
|
|
38
|
+
const localIcon = getLocalIconData();
|
|
39
|
+
const server = resolved.createServer(name, version, localIcon);
|
|
23
40
|
installMcpLogging(server);
|
|
24
|
-
installConsoleBridge(server);
|
|
41
|
+
const { flush: flushConsole, restore: restoreConsole } = installConsoleBridge(server);
|
|
42
|
+
process.on('exit', restoreConsole);
|
|
25
43
|
resolved.publishLifecycleEvent({
|
|
26
44
|
type: 'lifecycle.started',
|
|
27
45
|
ts: resolved.now(),
|
|
28
46
|
});
|
|
29
47
|
const engine = resolved.engineFactory();
|
|
30
|
-
resolved.registerTool(server, engine);
|
|
48
|
+
resolved.registerTool(server, engine, localIcon);
|
|
31
49
|
const transport = await resolved.connectServer(server);
|
|
50
|
+
flushConsole();
|
|
32
51
|
resolved.installShutdownHandlers(buildShutdownDependencies(resolved, { server, engine, transport }));
|
|
33
52
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
const FALSY_ENV_VALUES = new Set(['0', 'false', 'no', 'off']);
|
|
3
|
+
function resolveIncludeTextContent() {
|
|
4
|
+
const raw = process.env.THINKSEQ_INCLUDE_TEXT_CONTENT;
|
|
5
|
+
return raw === undefined || !FALSY_ENV_VALUES.has(raw.trim().toLowerCase());
|
|
6
|
+
}
|
|
7
|
+
export const APP_ENV = {
|
|
8
|
+
INCLUDE_TEXT_CONTENT: resolveIncludeTextContent(),
|
|
9
|
+
};
|
|
@@ -8,9 +8,9 @@ export interface RunDependencies {
|
|
|
8
8
|
shutdownTimeoutMs?: number;
|
|
9
9
|
readPackageJson?: (signal?: AbortSignal) => Promise<PackageInfo>;
|
|
10
10
|
publishLifecycleEvent?: (event: LifecycleEvent) => void;
|
|
11
|
-
createServer?: (name: string, version: string) => ServerLike;
|
|
11
|
+
createServer?: (name: string, version: string, icon?: string) => ServerLike;
|
|
12
12
|
connectServer?: (server: ServerLike, createTransport?: () => TransportLike) => Promise<TransportLike>;
|
|
13
|
-
registerTool?: (server: ServerLike, engine: EngineLike) => void;
|
|
13
|
+
registerTool?: (server: ServerLike, engine: EngineLike, icon?: string) => void;
|
|
14
14
|
engineFactory?: () => EngineLike;
|
|
15
15
|
installShutdownHandlers?: (deps: ShutdownDependencies) => void;
|
|
16
16
|
now?: () => number;
|
|
@@ -21,9 +21,9 @@ export interface ResolvedRunDependencies {
|
|
|
21
21
|
shutdownTimeoutMs?: number;
|
|
22
22
|
readPackageJson: (signal?: AbortSignal) => Promise<PackageInfo>;
|
|
23
23
|
publishLifecycleEvent: (event: LifecycleEvent) => void;
|
|
24
|
-
createServer: (name: string, version: string) => ServerLike;
|
|
24
|
+
createServer: (name: string, version: string, icon?: string) => ServerLike;
|
|
25
25
|
connectServer: (server: ServerLike, createTransport?: () => TransportLike) => Promise<TransportLike>;
|
|
26
|
-
registerTool: (server: ServerLike, engine: EngineLike) => void;
|
|
26
|
+
registerTool: (server: ServerLike, engine: EngineLike, icon?: string) => void;
|
|
27
27
|
engineFactory: () => EngineLike;
|
|
28
28
|
installShutdownHandlers: (deps: ShutdownDependencies) => void;
|
|
29
29
|
now: () => number;
|