@blockrun/runcode 2.5.5 → 2.5.7

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.
@@ -9,10 +9,10 @@
9
9
  * 5. Pre-compact stripping — remove images/docs before summarization
10
10
  */
11
11
  // ─── Constants ─────────────────────────────────────────────────────────────
12
- /** Max chars per individual tool result before truncation */
13
- const MAX_TOOL_RESULT_CHARS = 50_000;
12
+ /** Max chars per individual tool result before truncation (history-level safety net) */
13
+ const MAX_TOOL_RESULT_CHARS = 32_000;
14
14
  /** Max aggregate tool result chars per user message */
15
- const MAX_TOOL_RESULTS_PER_MESSAGE_CHARS = 200_000;
15
+ const MAX_TOOL_RESULTS_PER_MESSAGE_CHARS = 100_000;
16
16
  /** Preview size when truncating */
17
17
  const PREVIEW_CHARS = 2_000;
18
18
  /** Default max_tokens (low to save output slot reservation) */
@@ -106,7 +106,11 @@ async function execute(input, ctx) {
106
106
  }
107
107
  });
108
108
  withMtime.sort((a, b) => b.mtime - a.mtime);
109
- const sorted = withMtime.map(f => f.path);
109
+ // Convert to relative paths to save tokens (same as Claude Code)
110
+ const sorted = withMtime.map(f => {
111
+ const rel = path.relative(ctx.workingDir, f.path);
112
+ return rel.startsWith('..') ? f.path : rel;
113
+ });
110
114
  if (sorted.length === 0) {
111
115
  // Suggest recursive pattern if user used non-recursive glob
112
116
  const hint = !pattern.includes('**') && !pattern.includes('/')
@@ -32,12 +32,18 @@ async function execute(input, ctx) {
32
32
  const mode = opts.output_mode || 'files_with_matches';
33
33
  const limit = opts.head_limit ?? 250;
34
34
  if (hasRipgrep()) {
35
- return runRipgrep(opts, searchPath, mode, limit);
35
+ return runRipgrep(opts, searchPath, mode, limit, ctx.workingDir);
36
36
  }
37
- return runNativeGrep(opts, searchPath, mode, limit);
37
+ return runNativeGrep(opts, searchPath, mode, limit, ctx.workingDir);
38
38
  }
39
- function runRipgrep(opts, searchPath, mode, limit) {
39
+ function toRelative(absPath, cwd) {
40
+ const rel = path.relative(cwd, absPath);
41
+ return rel.startsWith('..') ? absPath : rel;
42
+ }
43
+ function runRipgrep(opts, searchPath, mode, limit, cwd) {
40
44
  const args = [];
45
+ // Limit line length to prevent base64/minified content from cluttering output
46
+ args.push('--max-columns', '500');
41
47
  switch (mode) {
42
48
  case 'files_with_matches':
43
49
  args.push('-l');
@@ -64,8 +70,8 @@ function runRipgrep(opts, searchPath, mode, limit) {
64
70
  args.push('-U', '--multiline-dotall');
65
71
  if (opts.glob)
66
72
  args.push(`--glob=${opts.glob}`);
67
- // Always exclude common noise
68
- args.push('--glob=!node_modules', '--glob=!.git', '--glob=!dist');
73
+ // Always exclude common noise + lock files (huge, rarely useful)
74
+ args.push('--glob=!node_modules', '--glob=!.git', '--glob=!dist', '--glob=!*.lock', '--glob=!package-lock.json', '--glob=!pnpm-lock.yaml');
69
75
  args.push('--', opts.pattern);
70
76
  args.push(searchPath);
71
77
  try {
@@ -76,7 +82,17 @@ function runRipgrep(opts, searchPath, mode, limit) {
76
82
  });
77
83
  const lines = result.split('\n').filter(Boolean);
78
84
  const limited = limit > 0 ? lines.slice(0, limit) : lines;
79
- let output = limited.join('\n');
85
+ // Convert absolute paths to relative paths to save tokens (same as Claude Code)
86
+ const relativized = limited.map(line => {
87
+ // Lines: /abs/path or /abs/path:rest (content mode)
88
+ const colonIdx = line.indexOf(':');
89
+ if (colonIdx > 0 && line.startsWith('/')) {
90
+ const filePart = line.slice(0, colonIdx);
91
+ return toRelative(filePart, cwd) + line.slice(colonIdx);
92
+ }
93
+ return line.startsWith('/') ? toRelative(line, cwd) : line;
94
+ });
95
+ let output = relativized.join('\n');
80
96
  if (lines.length > limited.length) {
81
97
  output += `\n\n... (${lines.length - limited.length} more results, use head_limit to see more)`;
82
98
  }
@@ -97,7 +113,7 @@ function runRipgrep(opts, searchPath, mode, limit) {
97
113
  };
98
114
  }
99
115
  }
100
- function runNativeGrep(opts, searchPath, mode, limit) {
116
+ function runNativeGrep(opts, searchPath, mode, limit, cwd) {
101
117
  const args = ['-r', '-n'];
102
118
  if (opts.case_insensitive)
103
119
  args.push('-i');
@@ -118,7 +134,7 @@ function runNativeGrep(opts, searchPath, mode, limit) {
118
134
  .replace(/\*\*/, '*'); // Convert ** to * for flat matching
119
135
  args.push(`--include=${nativeGlob}`);
120
136
  }
121
- args.push('--exclude-dir=node_modules', '--exclude-dir=.git', '--exclude-dir=dist');
137
+ args.push('--exclude-dir=node_modules', '--exclude-dir=.git', '--exclude-dir=dist', '--exclude=*.lock', '--exclude=package-lock.json', '--exclude=pnpm-lock.yaml');
122
138
  args.push('-e', opts.pattern, searchPath);
123
139
  try {
124
140
  const result = execFileSync('grep', args, {
@@ -128,7 +144,14 @@ function runNativeGrep(opts, searchPath, mode, limit) {
128
144
  });
129
145
  const lines = result.split('\n').filter(Boolean);
130
146
  const limited = limit > 0 ? lines.slice(0, limit) : lines;
131
- let output = limited.join('\n');
147
+ const relativized = limited.map(line => {
148
+ const colonIdx = line.indexOf(':');
149
+ if (colonIdx > 0 && line.startsWith('/')) {
150
+ return toRelative(line.slice(0, colonIdx), cwd) + line.slice(colonIdx);
151
+ }
152
+ return line.startsWith('/') ? toRelative(line, cwd) : line;
153
+ });
154
+ let output = relativized.join('\n');
132
155
  if (lines.length > limited.length) {
133
156
  output += `\n\n... (${lines.length - limited.length} more results)`;
134
157
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/runcode",
3
- "version": "2.5.5",
3
+ "version": "2.5.7",
4
4
  "description": "RunCode — AI coding agent powered by 41+ models. Pay per use with USDC.",
5
5
  "type": "module",
6
6
  "bin": {