@blockrun/runcode 2.3.2 → 2.5.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.
@@ -108,13 +108,16 @@ const DIRECT_COMMANDS = {
108
108
  emitDone(ctx);
109
109
  },
110
110
  '/help': (ctx) => {
111
+ const ultrathinkOn = ctx.config.ultrathink;
111
112
  ctx.onEvent({ kind: 'text_delta', text: `**RunCode Commands**\n\n` +
112
113
  ` **Coding:** /commit /review /test /fix /debug /explain /search /find /refactor /scaffold\n` +
113
114
  ` **Git:** /push /pr /undo /status /diff /log /branch /stash /unstash\n` +
114
115
  ` **Analysis:** /security /lint /optimize /todo /deps /clean /migrate /doc\n` +
115
- ` **Session:** /plan /execute /compact /retry /sessions /resume /context /tasks\n` +
116
- ` **Info:** /model /wallet /cost /mcp /doctor /version /bug /help\n` +
117
- ` **UI:** /clear /exit\n`
116
+ ` **Session:** /plan /ultraplan /execute /compact /retry /sessions /resume /context /tasks\n` +
117
+ ` **Power:** /ultrathink [query] /ultraplan /dump\n` +
118
+ ` **Info:** /model /wallet /cost /tokens /mcp /doctor /version /bug /help\n` +
119
+ ` **UI:** /clear /exit\n` +
120
+ (ultrathinkOn ? `\n Ultrathink: ON\n` : '')
118
121
  });
119
122
  emitDone(ctx);
120
123
  },
@@ -201,6 +204,27 @@ const DIRECT_COMMANDS = {
201
204
  }
202
205
  emitDone(ctx);
203
206
  },
207
+ '/ultrathink': (ctx) => {
208
+ const cfg = ctx.config;
209
+ cfg.ultrathink = !cfg.ultrathink;
210
+ if (cfg.ultrathink) {
211
+ ctx.onEvent({ kind: 'text_delta', text: '**Ultrathink mode ON.** Extended reasoning active — the model will think deeply before responding.\n' +
212
+ 'Use `/ultrathink` again to disable, or `/ultrathink <query>` to send a one-shot deep analysis.\n'
213
+ });
214
+ }
215
+ else {
216
+ ctx.onEvent({ kind: 'text_delta', text: '**Ultrathink mode OFF.** Normal response mode restored.\n' });
217
+ }
218
+ emitDone(ctx);
219
+ },
220
+ '/dump': (ctx) => {
221
+ const instructions = ctx.config.systemInstructions;
222
+ const joined = instructions.join('\n\n---\n\n');
223
+ ctx.onEvent({ kind: 'text_delta', text: `**System Prompt** (${instructions.length} section${instructions.length !== 1 ? 's' : ''}):\n\n` +
224
+ `\`\`\`\n${joined.slice(0, 4000)}${joined.length > 4000 ? `\n... (${joined.length - 4000} chars truncated)` : ''}\n\`\`\`\n`
225
+ });
226
+ emitDone(ctx);
227
+ },
204
228
  '/execute': (ctx) => {
205
229
  if (ctx.config.permissionMode !== 'plan') {
206
230
  ctx.onEvent({ kind: 'text_delta', text: 'Not in plan mode. Use /plan to enter.\n' });
@@ -264,9 +288,19 @@ const REWRITE_COMMANDS = {
264
288
  '/migrate': 'Check for pending database migrations, outdated dependencies, or breaking changes that need addressing. List required migration steps.',
265
289
  '/clean': 'Find and remove dead code: unused imports, unreachable code, commented-out blocks, unused variables and functions. Show what would be removed before making changes.',
266
290
  '/tasks': 'List all current tasks using the Task tool.',
291
+ '/ultraplan': 'Enter ultraplan mode: create a detailed, step-by-step implementation plan before writing any code. ' +
292
+ 'First, thoroughly read ALL relevant files. Map out every dependency and potential side effect. ' +
293
+ 'Identify edge cases, security considerations, and performance implications. ' +
294
+ 'Then produce a numbered implementation plan with specific file paths, function names, and code changes. ' +
295
+ 'Do NOT write any code yet — only the plan.',
267
296
  };
268
297
  // Commands with arguments (prefix match → rewrite)
269
298
  const ARG_COMMANDS = [
299
+ { prefix: '/ultrathink ', rewrite: (a) => `Think deeply, carefully, and thoroughly before responding. ` +
300
+ `Consider multiple approaches, check edge cases, reason through implications step by step, ` +
301
+ `and challenge your initial assumptions. Take your time — quality of reasoning matters more than speed. ` +
302
+ `Now respond to: ${a}`
303
+ },
270
304
  { prefix: '/explain ', rewrite: (a) => `Read and explain the code in ${a}. Cover: what it does, key functions/classes, how it connects to the rest of the codebase.` },
271
305
  { prefix: '/search ', rewrite: (a) => `Search the codebase for "${a}" using Grep. Show the matching files and relevant code context.` },
272
306
  { prefix: '/find ', rewrite: (a) => `Find files matching the pattern "${a}" using Glob. Show the results.` },
@@ -50,8 +50,9 @@ You have access to tools for reading, writing, editing files, running shell comm
50
50
  # Slash Commands Available
51
51
  The user can type these shortcuts: /commit, /review, /test, /fix, /debug, /explain <file>,
52
52
  /search <query>, /find <pattern>, /refactor <desc>, /init, /todo, /deps, /diff, /status,
53
- /log, /branch, /stash, /plan, /execute, /compact, /retry, /sessions, /resume, /tasks,
54
- /context, /doctor, /model, /cost, /clear, /help, /exit.`;
53
+ /log, /branch, /stash, /plan, /ultraplan, /execute, /compact, /retry, /sessions, /resume,
54
+ /tasks, /context, /doctor, /tokens, /model, /cost, /dump, /ultrathink [query], /clear,
55
+ /help, /exit.`;
55
56
  /**
56
57
  * Build the full system instructions array for a session.
57
58
  */
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { ModelClient } from './llm.js';
7
7
  import { autoCompactIfNeeded, microCompact } from './compact.js';
8
- import { estimateHistoryTokens, updateActualTokens, resetTokenAnchor } from './tokens.js';
8
+ import { estimateHistoryTokens, updateActualTokens, resetTokenAnchor, getAnchoredTokenCount, getContextWindow } from './tokens.js';
9
9
  import { handleSlashCommand } from './commands.js';
10
10
  import { reduceTokens } from './reduce.js';
11
11
  import { PermissionManager } from './permissions.js';
@@ -214,6 +214,7 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
214
214
  // Session persistence
215
215
  const sessionId = createSessionId();
216
216
  let turnCount = 0;
217
+ let tokenBudgetWarned = false; // Emit token budget warning at most once per session
217
218
  pruneOldSessions(sessionId); // Cleanup old sessions on start, protect current
218
219
  while (true) {
219
220
  let input = await getUserInput();
@@ -290,7 +291,18 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
290
291
  }
291
292
  }
292
293
  }
293
- const systemPrompt = config.systemInstructions.join('\n\n');
294
+ // Inject ultrathink instruction when mode is active
295
+ const systemParts = [...config.systemInstructions];
296
+ if (config.ultrathink) {
297
+ systemParts.push('# Ultrathink Mode\n' +
298
+ 'You are in deep reasoning mode. Before responding to any request:\n' +
299
+ '1. Thoroughly analyze the problem from multiple angles\n' +
300
+ '2. Consider edge cases, failure modes, and second-order effects\n' +
301
+ '3. Challenge your initial assumptions before committing to an approach\n' +
302
+ '4. Think step by step — show your reasoning explicitly when it adds value\n' +
303
+ 'Prioritize correctness and thoroughness over speed.');
304
+ }
305
+ const systemPrompt = systemParts.join('\n\n');
294
306
  const modelMaxOut = getMaxOutputTokens(config.model);
295
307
  let maxTokens = Math.min(maxTokensOverride ?? CAPPED_MAX_TOKENS, modelMaxOut);
296
308
  let responseParts = [];
@@ -433,6 +445,19 @@ export async function interactiveSession(config, getUserInput, onEvent, onAbortR
433
445
  turnCount,
434
446
  messageCount: history.length,
435
447
  });
448
+ // Token budget warning — emit once per session when crossing 70%
449
+ if (!tokenBudgetWarned) {
450
+ const { estimated } = getAnchoredTokenCount(history);
451
+ const contextWindow = getContextWindow(config.model);
452
+ const pct = (estimated / contextWindow) * 100;
453
+ if (pct >= 70) {
454
+ tokenBudgetWarned = true;
455
+ onEvent({
456
+ kind: 'text_delta',
457
+ text: `\n\n> **Token budget: ${pct.toFixed(0)}% used** (~${estimated.toLocaleString()} / ${(contextWindow / 1000).toFixed(0)}k tokens). Run \`/compact\` to free up space.\n`,
458
+ });
459
+ }
460
+ }
436
461
  onEvent({ kind: 'turn_done', reason: 'completed' });
437
462
  break;
438
463
  }
@@ -101,4 +101,6 @@ export interface AgentConfig {
101
101
  permissionMode?: 'default' | 'trust' | 'deny-all' | 'plan';
102
102
  onEvent?: (event: StreamEvent) => void;
103
103
  debug?: boolean;
104
+ /** Ultrathink mode: inject deep-reasoning instruction into every prompt */
105
+ ultrathink?: boolean;
104
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/runcode",
3
- "version": "2.3.2",
3
+ "version": "2.5.0",
4
4
  "description": "RunCode — AI coding agent powered by 41+ models. Pay per use with USDC.",
5
5
  "type": "module",
6
6
  "bin": {