Skip to content

Commit 8fd4a87

Browse files
committed
fix: /context warns at 80%, /doctor checks MCP, /help in command registry (v2.2.3)
1 parent 5256b26 commit 8fd4a87

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

dist/agent/commands.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ const DIRECT_COMMANDS = {
7171
ctx.onEvent({ kind: 'text_delta', text: 'Last commit undone. Changes preserved in staging.\n' });
7272
emitDone(ctx);
7373
},
74+
'/help': (ctx) => {
75+
ctx.onEvent({ kind: 'text_delta', text: `**RunCode Commands**\n\n` +
76+
` **Coding:** /commit /review /test /fix /debug /explain /search /find /refactor /scaffold\n` +
77+
` **Git:** /push /pr /undo /status /diff /log /branch /stash /unstash\n` +
78+
` **Analysis:** /security /lint /optimize /todo /deps /clean /migrate /doc\n` +
79+
` **Session:** /plan /execute /compact /retry /sessions /resume /context /tasks\n` +
80+
` **Info:** /model /wallet /cost /mcp /doctor /version /bug /help\n` +
81+
` **UI:** /clear /exit\n`
82+
});
83+
emitDone(ctx);
84+
},
7485
'/bug': (ctx) => {
7586
ctx.onEvent({ kind: 'text_delta', text: 'Report issues at: https://github.com/BlockRunAI/runcode/issues\n' });
7687
emitDone(ctx);
@@ -99,12 +110,15 @@ const DIRECT_COMMANDS = {
99110
'/context': async (ctx) => {
100111
const { estimated, apiAnchored } = getAnchoredTokenCount(ctx.history);
101112
const contextWindow = getContextWindow(ctx.config.model);
102-
const usagePct = ((estimated / contextWindow) * 100).toFixed(1);
113+
const pct = (estimated / contextWindow) * 100;
114+
const usagePct = pct.toFixed(1);
115+
const warning = pct > 80 ? ' ⚠ Near limit — consider /compact\n' : '';
103116
ctx.onEvent({ kind: 'text_delta', text: `**Session Context**\n` +
104117
` Model: ${ctx.config.model}\n` +
105118
` Mode: ${ctx.config.permissionMode || 'default'}\n` +
106119
` Messages: ${ctx.history.length}\n` +
107120
` Tokens: ~${estimated.toLocaleString()} / ${(contextWindow / 1000).toFixed(0)}k (${usagePct}%)${apiAnchored ? ' ✓' : ' ~'}\n` +
121+
warning +
108122
` Session: ${ctx.sessionId}\n` +
109123
` Directory: ${ctx.config.workingDir || process.cwd()}\n`
110124
});
@@ -128,6 +142,12 @@ const DIRECT_COMMANDS = {
128142
}
129143
checks.push(fs.existsSync(path.join(BLOCKRUN_DIR, 'wallet.json')) ? '✓ wallet configured' : '⚠ no wallet — run: runcode setup');
130144
checks.push(fs.existsSync(path.join(BLOCKRUN_DIR, 'runcode-config.json')) ? '✓ config file exists' : '⚠ no config — using defaults');
145+
// Check MCP
146+
const { listMcpServers } = await import('../mcp/client.js');
147+
const mcpServers = listMcpServers();
148+
checks.push(mcpServers.length > 0
149+
? `✓ MCP: ${mcpServers.length} server(s), ${mcpServers.reduce((a, s) => a + s.toolCount, 0)} tools`
150+
: '⚠ no MCP servers connected');
131151
checks.push(`✓ model: ${ctx.config.model}`);
132152
checks.push(`✓ history: ${ctx.history.length} messages, ~${estimateHistoryTokens(ctx.history).toLocaleString()} tokens`);
133153
checks.push(`✓ session: ${ctx.sessionId}`);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@blockrun/runcode",
3-
"version": "2.2.2",
3+
"version": "2.2.3",
44
"description": "RunCode — AI coding agent powered by 41+ models. Pay per use with USDC.",
55
"type": "module",
66
"bin": {

src/agent/commands.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ const DIRECT_COMMANDS: Record<string, (ctx: CommandContext) => Promise<void> | v
9595
if (r !== null) ctx.onEvent({ kind: 'text_delta', text: 'Last commit undone. Changes preserved in staging.\n' });
9696
emitDone(ctx);
9797
},
98+
'/help': (ctx) => {
99+
ctx.onEvent({ kind: 'text_delta', text:
100+
`**RunCode Commands**\n\n` +
101+
` **Coding:** /commit /review /test /fix /debug /explain /search /find /refactor /scaffold\n` +
102+
` **Git:** /push /pr /undo /status /diff /log /branch /stash /unstash\n` +
103+
` **Analysis:** /security /lint /optimize /todo /deps /clean /migrate /doc\n` +
104+
` **Session:** /plan /execute /compact /retry /sessions /resume /context /tasks\n` +
105+
` **Info:** /model /wallet /cost /mcp /doctor /version /bug /help\n` +
106+
` **UI:** /clear /exit\n`
107+
});
108+
emitDone(ctx);
109+
},
98110
'/bug': (ctx) => {
99111
ctx.onEvent({ kind: 'text_delta', text: 'Report issues at: https://github.com/BlockRunAI/runcode/issues\n' });
100112
emitDone(ctx);
@@ -121,13 +133,16 @@ const DIRECT_COMMANDS: Record<string, (ctx: CommandContext) => Promise<void> | v
121133
'/context': async (ctx) => {
122134
const { estimated, apiAnchored } = getAnchoredTokenCount(ctx.history);
123135
const contextWindow = getContextWindow(ctx.config.model);
124-
const usagePct = ((estimated / contextWindow) * 100).toFixed(1);
136+
const pct = (estimated / contextWindow) * 100;
137+
const usagePct = pct.toFixed(1);
138+
const warning = pct > 80 ? ' ⚠ Near limit — consider /compact\n' : '';
125139
ctx.onEvent({ kind: 'text_delta', text:
126140
`**Session Context**\n` +
127141
` Model: ${ctx.config.model}\n` +
128142
` Mode: ${ctx.config.permissionMode || 'default'}\n` +
129143
` Messages: ${ctx.history.length}\n` +
130144
` Tokens: ~${estimated.toLocaleString()} / ${(contextWindow / 1000).toFixed(0)}k (${usagePct}%)${apiAnchored ? ' ✓' : ' ~'}\n` +
145+
warning +
131146
` Session: ${ctx.sessionId}\n` +
132147
` Directory: ${ctx.config.workingDir || process.cwd()}\n`
133148
});
@@ -141,6 +156,12 @@ const DIRECT_COMMANDS: Record<string, (ctx: CommandContext) => Promise<void> | v
141156
catch { checks.push('⚠ ripgrep not found (using native grep fallback)'); }
142157
checks.push(fs.existsSync(path.join(BLOCKRUN_DIR, 'wallet.json')) ? '✓ wallet configured' : '⚠ no wallet — run: runcode setup');
143158
checks.push(fs.existsSync(path.join(BLOCKRUN_DIR, 'runcode-config.json')) ? '✓ config file exists' : '⚠ no config — using defaults');
159+
// Check MCP
160+
const { listMcpServers } = await import('../mcp/client.js');
161+
const mcpServers = listMcpServers();
162+
checks.push(mcpServers.length > 0
163+
? `✓ MCP: ${mcpServers.length} server(s), ${mcpServers.reduce((a, s) => a + s.toolCount, 0)} tools`
164+
: '⚠ no MCP servers connected');
144165
checks.push(`✓ model: ${ctx.config.model}`);
145166
checks.push(`✓ history: ${ctx.history.length} messages, ~${estimateHistoryTokens(ctx.history).toLocaleString()} tokens`);
146167
checks.push(`✓ session: ${ctx.sessionId}`);

0 commit comments

Comments
 (0)