@kinqs/brainrouter-cli 0.3.4 ā 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -142
- package/dist/agent/agent.js +2 -2
- package/dist/cli/repl.js +1 -1
- package/dist/index.js +1 -1
- package/dist/runtime/mcpClient.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,185 +1,145 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@kinqs/brainrouter-cli`
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A memory-native terminal agent. Edits files, runs shell commands,
|
|
4
|
+
spawns child agents, and talks to a BrainRouter MCP server for long-term
|
|
5
|
+
recall, skills, and capture.
|
|
6
|
+
|
|
7
|
+
Ships the `brainrouter` binary.
|
|
4
8
|
|
|
5
9
|
---
|
|
6
10
|
|
|
7
|
-
##
|
|
8
|
-
- **Dual-Tier Connection**: Connects to local MCP servers via standard I/O (stdio) or hosted multi-tenant servers over Streamable HTTP/SSE.
|
|
9
|
-
- **Double-Tier Memory Architecture**:
|
|
10
|
-
- **System 1 (Heuristic Recall)**: Automatically retrieves active focus scenes, codebase facts, and skills *before* each LLM reasoning cycle.
|
|
11
|
-
- **System 2 (Memory Consolidation)**: Autonomously extracts learning points, updates facts, and saves evidence via turn-by-turn memory capture.
|
|
12
|
-
- **Local Execution Harness**: Autonomous execution of files editing, directory listing, regex/string grep, and terminal command invocation (safely prompted for user verification).
|
|
13
|
-
- **Obsidian Dark / Midnight Ledger Aesthetics**: High-end command line styling, loader animations, and formatted terminal markdown output.
|
|
11
|
+
## Install
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g @kinqs/brainrouter-cli
|
|
15
|
+
```
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm install
|
|
23
|
-
npm run build
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
2. **Configure Provider and Server Profiles**:
|
|
27
|
-
Run the interactive configurator to set up your LLM settings (OpenAI, local endpoints like Ollama/LM Studio) and active server profile.
|
|
28
|
-
From the repository root:
|
|
29
|
-
```bash
|
|
30
|
-
npm run cli config
|
|
31
|
-
```
|
|
32
|
-
Or from the `brainrouter` package subdirectory:
|
|
33
|
-
```bash
|
|
34
|
-
node dist/index.js config
|
|
35
|
-
```
|
|
36
|
-
This generates and modifies settings stored in `~/.config/brainrouter/config.json`.
|
|
17
|
+
**The `-g` flag is critical.** Without it, npm installs into the current
|
|
18
|
+
directory's `node_modules/` and the `brainrouter` binary ends up at
|
|
19
|
+
`./node_modules/.bin/brainrouter` ā not on `$PATH`. Symptom: `brainrouter:
|
|
20
|
+
command not found`.
|
|
37
21
|
|
|
38
|
-
|
|
22
|
+
**Sudo caveat.** Whether you need `sudo` depends on your Node install:
|
|
23
|
+
|
|
24
|
+
| How Node is installed | Use `sudo`? |
|
|
25
|
+
|---|---|
|
|
26
|
+
| Homebrew (`brew install node`) | ā No ā global prefix is user-writable |
|
|
27
|
+
| nvm / asdf / fnm | ā No ā same reason |
|
|
28
|
+
| System Node on macOS / Linux | ā
Yes ā global prefix is `/usr/local/...` |
|
|
29
|
+
|
|
30
|
+
Check yours:
|
|
39
31
|
|
|
40
|
-
## CLI Usage
|
|
41
|
-
|
|
42
|
-
### Start Interactive Agent Session (REPL)
|
|
43
|
-
Starts the agent loop. It will automatically load the active server connection and prime the agent with active codebase memories.
|
|
44
|
-
From the repository root:
|
|
45
|
-
```bash
|
|
46
|
-
npm run cli
|
|
47
|
-
```
|
|
48
|
-
Or to run a specific command:
|
|
49
|
-
```bash
|
|
50
|
-
npm run cli chat
|
|
51
|
-
```
|
|
52
|
-
Or from the `brainrouter` package subdirectory:
|
|
53
|
-
```bash
|
|
54
|
-
node dist/index.js chat
|
|
55
|
-
```
|
|
56
|
-
*Tip: You can override the active LLM model via `--model <name>` or profile via `--profile <name>`.*
|
|
57
|
-
|
|
58
|
-
Workspace detection:
|
|
59
|
-
- By default, BrainRouter uses the nearest project root with `AGENT.md`, `AGENTS.md`, or `.git`.
|
|
60
|
-
- If you run from this package directory during BrainRouter development, the CLI promotes the workspace to the monorepo root so tools see the whole project, not only `brainrouter/`.
|
|
61
|
-
- Override manually with `--workspace /absolute/path/to/project` or `BRAINROUTER_WORKSPACE=/absolute/path/to/project`.
|
|
62
|
-
- In the REPL, run `/workspace` to confirm the active root and session key.
|
|
63
|
-
|
|
64
|
-
### Host Login / Setup Connection
|
|
65
|
-
Interactively log in to a hosted HTTP/SSE BrainRouter deployment and test latency/connectivity:
|
|
66
|
-
From the repository root:
|
|
67
32
|
```bash
|
|
68
|
-
npm
|
|
33
|
+
npm config get prefix
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
If the path is under `/Users/...`, `/opt/homebrew/...`, or your home dir
|
|
37
|
+
ā no sudo. If it's `/usr/local/...` ā use sudo.
|
|
38
|
+
|
|
39
|
+
Verify the install:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
which brainrouter # prints the path to the binary
|
|
43
|
+
brainrouter --version # prints 0.3.5
|
|
69
44
|
```
|
|
70
45
|
|
|
71
46
|
---
|
|
72
47
|
|
|
73
|
-
##
|
|
48
|
+
## Configure
|
|
49
|
+
|
|
50
|
+
Two configuration surfaces, both one-time:
|
|
74
51
|
|
|
75
|
-
|
|
76
|
-
- `/help` ā List all available directive commands.
|
|
77
|
-
- `/status` ā Display active server profile details, LLM model, server latency check, and database size stats.
|
|
78
|
-
- `/workspace` ā Show active workspace root, launch directory, and BrainRouter session key.
|
|
79
|
-
- `/tools` ā Show local workspace tools and MCP tools exposed to the LLM.
|
|
80
|
-
- `/doctor` ā Check active profile, MCP connectivity, plan + session store health, and orchestration tool availability.
|
|
81
|
-
- `/skills` ā Visualize all loaded BrainRouter skills and categories.
|
|
82
|
-
- `/plan` ā Show the durable CLI task plan persisted under `.brainrouter/cli/tasks.json`.
|
|
83
|
-
- `/transcript [main|sessionKey]` ā Show recent persisted transcript entries.
|
|
84
|
-
- `/roles` ā List built-in agent roles (`explorer`, `architect`, `reviewer`, `worker`, `verifier`) with default access modes.
|
|
85
|
-
- `/agents` ā List child agent sessions with status, role, label, and elapsed time.
|
|
86
|
-
- `/agent <id>` ā Show child detail, prompt, final output, and recent transcript.
|
|
87
|
-
- `/spawn <role> <prompt>` ā Spawn a child agent (parent narrates via the LLM tool call).
|
|
88
|
-
- `/wait <id> [timeoutMs]` ā Wait for a child agent to finish.
|
|
89
|
-
- `/spec <title>` ā Runs the **spec-driven-skill** and writes a full `spec.md` to `<workspace>/.brainrouter/cli/workflows/<slug>/spec.md`. Stops for approval before generating tasks.
|
|
90
|
-
- `/approve [slug]` ā Approves the current (or named) workflow and kicks off the worker + verifier implementation phase, one task at a time, appending to `walkthrough.md`.
|
|
91
|
-
- `/workflows` ā List durable workflow folders with per-artifact status (`spec.md`, `tasks.md`, `walkthrough.md`).
|
|
92
|
-
- `/feature-dev <feature>` ā Runs the catalogued **agentic-engineering-workflow** skill with explorer + architect orchestration. Writes `spec.md` and `tasks.md` to the workflow folder, then stops for user approval before worker implementation.
|
|
93
|
-
- `/review [scope]` ā Runs the catalogued **code-review-and-quality** skill with 3 parallel reviewer agents (correctness, maintainability, conventions).
|
|
94
|
-
- `/implement-plan` ā Runs the catalogued **incremental-skill** with a worker + verifier loop on the next pending plan item.
|
|
95
|
-
- `/skill <name> [input]` ā Generic invoker for any skill in your `skills/` catalogue. The CLI fetches the skill body via the MCP `get_skill` tool, falls back to filesystem (`skills/**/SKILL.md`), and hands the agent a structured prompt that embeds the skill instructions plus orchestration affordances (`spawn_agent`, `update_plan`).
|
|
52
|
+
### 1. The chat LLM and MCP server profile
|
|
96
53
|
|
|
97
|
-
|
|
54
|
+
```bash
|
|
55
|
+
brainrouter config # interactive ā set LLM provider, model, key, endpoint
|
|
56
|
+
brainrouter login # interactive ā set MCP server URL + API key
|
|
57
|
+
```
|
|
98
58
|
|
|
99
|
-
|
|
59
|
+
Both write to `~/.config/brainrouter/config.json`.
|
|
100
60
|
|
|
101
|
-
|
|
61
|
+
For local-model setups (LM Studio / Ollama), point the LLM endpoint at
|
|
62
|
+
`http://localhost:1234/v1/chat/completions` or `http://localhost:11434/v1/chat/completions`.
|
|
102
63
|
|
|
103
|
-
|
|
64
|
+
### 2. (Optional) Runtime knobs ā `~/.config/brainrouter/cli.env` or `./brainrouter-cli.env`
|
|
104
65
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
- The installed `@kinqs/brainrouter-mcp-server` package directory (resolved via `require.resolve`). This works because the MCP package bundles the canonical catalogue at publish time (see below).
|
|
110
|
-
3. Otherwise the CLI hands the agent a benign placeholder and asks it to use general judgement.
|
|
66
|
+
Only needed if you want to tune sandbox, tool-loop limits, trace logging,
|
|
67
|
+
or web-search backend. See the [`.env.example`](.env.example) bundled with
|
|
68
|
+
this package for the full list. LLM credentials do **not** go here ā they
|
|
69
|
+
live in `config.json`.
|
|
111
70
|
|
|
112
|
-
|
|
71
|
+
---
|
|
113
72
|
|
|
114
|
-
|
|
73
|
+
## Run
|
|
115
74
|
|
|
116
|
-
|
|
75
|
+
```bash
|
|
76
|
+
brainrouter # starts the interactive REPL
|
|
77
|
+
brainrouter chat # same ā `chat` is the default subcommand
|
|
78
|
+
brainrouter run "summarize the changes in src/" # one-shot non-interactive
|
|
79
|
+
brainrouter agents # list child agent sessions in this workspace
|
|
80
|
+
```
|
|
117
81
|
|
|
118
|
-
|
|
119
|
-
|
|
82
|
+
Inside the REPL, type `/help` for the full slash-command list (60+
|
|
83
|
+
commands across session / memory / workflow / orchestration / observability
|
|
84
|
+
surfaces).
|
|
120
85
|
|
|
121
|
-
|
|
86
|
+
### Offline mode
|
|
122
87
|
|
|
123
|
-
|
|
88
|
+
If the MCP server isn't reachable, the CLI still boots ā but only local
|
|
89
|
+
tools (file edits, shell, web fetch, `spawn_agent`) work. Memory recall,
|
|
90
|
+
capture, and skills are disabled until the server is back. The startup
|
|
91
|
+
banner shows `ā ļø OFFLINE MODE` when this happens. Pass `--strict-mcp` to
|
|
92
|
+
make the CLI exit instead of degrading.
|
|
124
93
|
|
|
125
|
-
|
|
94
|
+
### Stdio mode
|
|
126
95
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
tasks.md # produced by /feature-dev phase 3
|
|
132
|
-
walkthrough.md # appended by /implement-plan as items ship
|
|
133
|
-
review.md # produced by /review
|
|
134
|
-
```
|
|
96
|
+
If you'd rather have the CLI spawn the MCP server as a child process
|
|
97
|
+
instead of running it separately, use `brainrouter config` ā "Set Active
|
|
98
|
+
Server Profile" ā `default` (the bundled stdio profile). You don't need
|
|
99
|
+
to run anything else ā the CLI manages the server's lifecycle.
|
|
135
100
|
|
|
136
|
-
|
|
101
|
+
---
|
|
137
102
|
|
|
138
|
-
|
|
103
|
+
## Workspace detection
|
|
139
104
|
|
|
140
|
-
|
|
105
|
+
By default, the CLI uses the nearest project root with `AGENT.md`,
|
|
106
|
+
`AGENTS.md`, or `.git`. Override with:
|
|
141
107
|
|
|
142
|
-
|
|
108
|
+
```bash
|
|
109
|
+
brainrouter --workspace /absolute/path/to/project
|
|
110
|
+
# or
|
|
111
|
+
BRAINROUTER_WORKSPACE=/absolute/path/to/project brainrouter
|
|
112
|
+
```
|
|
143
113
|
|
|
144
|
-
|
|
145
|
-
2. **`memory_working_context`** ā current working canvas, so resumed sessions don't reset.
|
|
146
|
-
3. **`memory_task_state`** ā open tasks / handover notes for this workspace.
|
|
114
|
+
Inside the REPL, run `/workspace` to confirm the active root and session key.
|
|
147
115
|
|
|
148
|
-
|
|
116
|
+
---
|
|
149
117
|
|
|
150
|
-
|
|
118
|
+
## What you also probably want
|
|
151
119
|
|
|
152
|
-
|
|
120
|
+
A BrainRouter MCP server for the cognitive memory. The CLI works without
|
|
121
|
+
it (offline mode) but you lose recall, capture, and skills:
|
|
153
122
|
|
|
154
|
-
|
|
123
|
+
```bash
|
|
124
|
+
npm install -g @kinqs/brainrouter-mcp-server
|
|
125
|
+
brainrouter-mcp init # one-time: scaffold ~/.config/brainrouter/server.env
|
|
126
|
+
$EDITOR ~/.config/brainrouter/server.env # set BRAINROUTER_LLM_API_KEY, embeddings, etc.
|
|
127
|
+
brainrouter-mcp --http --port 3747 # in a separate terminal
|
|
128
|
+
```
|
|
155
129
|
|
|
156
|
-
|
|
157
|
-
- `/recall <query>` ā explicit `memory_recall`, no LLM turn.
|
|
158
|
-
- `/briefing` ā what was recalled before the most recent turn.
|
|
159
|
-
- `/scenes` ā list active focus scenes.
|
|
160
|
-
- `/working` ā current working-memory canvas.
|
|
161
|
-
- `/forget <recordId>` ā archive an obsolete memory.
|
|
130
|
+
Then `brainrouter login` and point at `http://localhost:3747/mcp`.
|
|
162
131
|
|
|
163
|
-
|
|
132
|
+
---
|
|
164
133
|
|
|
165
|
-
|
|
134
|
+
## Docs
|
|
166
135
|
|
|
167
|
-
|
|
168
|
-
-
|
|
169
|
-
-
|
|
170
|
-
-
|
|
171
|
-
- `/exit` ā Close connections and exit.
|
|
136
|
+
- **Repo**: <https://github.com/kinqsradiollc/BrainRouter>
|
|
137
|
+
- **Memory engine deep-dive**: [BRAINROUTER.md](https://github.com/kinqsradiollc/BrainRouter/blob/main/BRAINROUTER.md)
|
|
138
|
+
- **Maintainer runbook**: [SETUP.md](https://github.com/kinqsradiollc/BrainRouter/blob/main/SETUP.md)
|
|
139
|
+
- **Bugs / requests**: <https://github.com/kinqsradiollc/BrainRouter/issues>
|
|
172
140
|
|
|
173
141
|
---
|
|
174
142
|
|
|
175
|
-
##
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
1. **BrainRouter Memory Tools** (loaded dynamically via the MCP connection): `memory_recall`, `memory_capture_turn`, `list_skills`, etc.
|
|
179
|
-
2. **Local Workspace Tools**:
|
|
180
|
-
- `read_file` ā Reads content of a workspace file.
|
|
181
|
-
- `write_file` ā Overwrites or writes a new file.
|
|
182
|
-
- `edit_file` ā Performs safe single-match string search-and-replace.
|
|
183
|
-
- `list_dir` ā Lists directory paths.
|
|
184
|
-
- `grep_search` ā Platform-independent recursive search of code patterns.
|
|
185
|
-
- `run_command` ā Runs a shell command on your host (always requests manual confirmation first for safety).
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
MIT
|
package/dist/agent/agent.js
CHANGED
|
@@ -984,7 +984,7 @@ export class Agent {
|
|
|
984
984
|
try {
|
|
985
985
|
const res = await fetch(url, {
|
|
986
986
|
headers: {
|
|
987
|
-
'User-Agent': 'Mozilla/5.0 (compatible; BrainRouterCLI/0.3.
|
|
987
|
+
'User-Agent': 'Mozilla/5.0 (compatible; BrainRouterCLI/0.3.5)'
|
|
988
988
|
}
|
|
989
989
|
});
|
|
990
990
|
if (!res.ok) {
|
|
@@ -1424,7 +1424,7 @@ async function runWebSearch(query, maxResults) {
|
|
|
1424
1424
|
}
|
|
1425
1425
|
try {
|
|
1426
1426
|
const url = `https://api.duckduckgo.com/?q=${encodeURIComponent(query)}&format=json&no_html=1&skip_disambig=1`;
|
|
1427
|
-
const res = await fetch(url, { headers: { 'User-Agent': 'BrainRouterCLI/0.3.
|
|
1427
|
+
const res = await fetch(url, { headers: { 'User-Agent': 'BrainRouterCLI/0.3.5' } });
|
|
1428
1428
|
if (!res.ok) {
|
|
1429
1429
|
return `web_search failed: DuckDuckGo returned ${res.status} ${res.statusText}.`;
|
|
1430
1430
|
}
|
package/dist/cli/repl.js
CHANGED
|
@@ -50,7 +50,7 @@ const SLASH_COMMANDS = [
|
|
|
50
50
|
'/experimental', '/memories', '/debug-config', '/mention', '/keymap', '/ide',
|
|
51
51
|
];
|
|
52
52
|
export function startREPL(agent, mcpClient, config, workspace) {
|
|
53
|
-
console.log(chalk.bold.hex('#CC9166')('\nš§ BRAINROUTER TERMINAL AGENT CLIENT v0.3.
|
|
53
|
+
console.log(chalk.bold.hex('#CC9166')('\nš§ BRAINROUTER TERMINAL AGENT CLIENT v0.3.5'));
|
|
54
54
|
console.log(chalk.gray('Midnight Ledger / Obsidian Surface theme active.'));
|
|
55
55
|
console.log(chalk.gray(`Workspace root: ${workspace?.workspaceRoot || process.cwd()}`));
|
|
56
56
|
// Surface offline mode prominently ā easy to miss the warning that scrolled
|
package/dist/index.js
CHANGED
|
@@ -165,7 +165,7 @@ const program = new Command();
|
|
|
165
165
|
program
|
|
166
166
|
.name('brainrouter')
|
|
167
167
|
.description('BrainRouter CLI ā Premium interactive terminal-based agent client.')
|
|
168
|
-
.version('0.3.
|
|
168
|
+
.version('0.3.5');
|
|
169
169
|
// Chat Command (default)
|
|
170
170
|
program
|
|
171
171
|
.command('chat', { isDefault: true })
|
|
@@ -14,7 +14,7 @@ export class McpClientWrapper {
|
|
|
14
14
|
*/
|
|
15
15
|
connected = false;
|
|
16
16
|
constructor() {
|
|
17
|
-
this.client = new Client({ name: 'brainrouter-cli', version: '0.3.
|
|
17
|
+
this.client = new Client({ name: 'brainrouter-cli', version: '0.3.5' }, { capabilities: {} });
|
|
18
18
|
}
|
|
19
19
|
/** Whether this wrapper has an active MCP transport. */
|
|
20
20
|
isConnected() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kinqs/brainrouter-cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Memory-native terminal coding agent. Talks to the BrainRouter MCP cognitive engine for recall, skills, capture, persona, focus scenes, and contradiction tracking.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"prepack": "npm run build && find dist -name '*.test.*' -delete"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@kinqs/brainrouter-sdk": "^0.3.
|
|
25
|
-
"@kinqs/brainrouter-types": "^0.3.
|
|
24
|
+
"@kinqs/brainrouter-sdk": "^0.3.5",
|
|
25
|
+
"@kinqs/brainrouter-types": "^0.3.5",
|
|
26
26
|
"@modelcontextprotocol/sdk": "^1.11.0",
|
|
27
27
|
"chalk": "^5.3.0",
|
|
28
28
|
"commander": "^12.1.0",
|