ideacode 1.0.3 → 1.0.4

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/dist/repl.js CHANGED
@@ -30,8 +30,15 @@ function wordEndForward(value, cursor) {
30
30
  return i;
31
31
  }
32
32
  const CONTEXT_WINDOW_K = 128;
33
+ const MAX_TOOL_RESULT_CHARS = 3500;
33
34
  const MAX_AT_SUGGESTIONS = 12;
34
35
  const INITIAL_BANNER_LINES = 12;
36
+ const TRUNCATE_NOTE = "\n\n(Output truncated to save context. Use read with offset/limit, grep with a specific pattern, or tail with fewer lines to get more.)";
37
+ function truncateToolResult(content) {
38
+ if (content.length <= MAX_TOOL_RESULT_CHARS)
39
+ return content;
40
+ return content.slice(0, MAX_TOOL_RESULT_CHARS) + TRUNCATE_NOTE;
41
+ }
35
42
  const isMac = process.platform === "darwin";
36
43
  const pasteShortcut = isMac ? "Cmd+V" : "Ctrl+V";
37
44
  function listFilesWithFilter(cwd, filter) {
@@ -298,7 +305,7 @@ export function Repl({ apiKey, cwd, onQuit }) {
298
305
  lastUserMessageRef.current = userInput;
299
306
  setLastUserPrompt(userInput);
300
307
  let state = [...messages, { role: "user", content: userInput }];
301
- const systemPrompt = `Concise coding assistant. cwd: ${cwd}. Use focused greps (specific patterns, narrow paths) and read in chunks when files are large; avoid one huge grep or read that floods context. When exploring a dependency, set path to that package (e.g. node_modules/<pkg>) and list/read only what you need.`;
308
+ const systemPrompt = `Concise coding assistant. cwd: ${cwd}. Use focused greps (specific patterns, narrow paths) and read in chunks when files are large; avoid one huge grep or read that floods context. When exploring a dependency, set path to that package (e.g. node_modules/<pkg>) and list/read only what you need. Prefer grep or keyword search for the most recent or specific occurrence; avoid tail/read of thousands of lines. If a tool result says it was truncated, call the tool again with offset, limit, or a narrower pattern to get what you need.`;
302
309
  const modelContext = modelList.find((m) => m.id === currentModel)?.context_length;
303
310
  const maxContextTokens = Math.floor((modelContext ?? CONTEXT_WINDOW_K * 1024) * 0.85);
304
311
  const stateBeforeCompress = state;
@@ -337,7 +344,8 @@ export function Repl({ apiKey, cwd, onQuit }) {
337
344
  preview += "...";
338
345
  appendLog(toolResultLine(preview, ok));
339
346
  if (block.id) {
340
- toolResults.push({ type: "tool_result", tool_use_id: block.id, content: result });
347
+ const contentForApi = truncateToolResult(result);
348
+ toolResults.push({ type: "tool_result", tool_use_id: block.id, content: contentForApi });
341
349
  }
342
350
  }
343
351
  }
@@ -5,7 +5,7 @@ import { runBash } from "./bash.js";
5
5
  import { webFetch, webSearch } from "./web.js";
6
6
  export const TOOLS = {
7
7
  read: [
8
- "Read file with line numbers (file path, not directory). Use limit to read a portion; avoid reading huge files in one go.",
8
+ "Read file with line numbers (file path, not directory). Use limit and offset to read a portion; avoid reading huge files in one go. Long output is truncated; use offset/limit to get more.",
9
9
  { path: "string", offset: "number?", limit: "number?" },
10
10
  readFile,
11
11
  ],
@@ -21,11 +21,15 @@ export const TOOLS = {
21
21
  globFiles,
22
22
  ],
23
23
  grep: [
24
- "Search files for regex. With path '.' (default), .gitignore entries are excluded; use path node_modules/<pkg> to search one package. Prefer specific patterns and narrow path. Returns at most limit matches (default 50, max 100).",
24
+ "Search files for regex. Prefer specific patterns and narrow path; search for the most recent or relevant occurrence by keyword. With path '.' (default), .gitignore entries are excluded; use path node_modules/<pkg> to search one package. Returns at most limit matches (default 50, max 100). Long output is truncated.",
25
25
  { pat: "string", path: "string?", limit: "number?" },
26
26
  grepFiles,
27
27
  ],
28
- bash: ["Run shell command", { cmd: "string" }, runBash],
28
+ bash: [
29
+ "Run shell command. Prefer targeted commands (e.g. grep, head, tail with small line count); avoid tail -1000 or dumping huge output.",
30
+ { cmd: "string" },
31
+ runBash,
32
+ ],
29
33
  web_fetch: [
30
34
  "Fetch a URL and return the main text content (handles JS-rendered pages). Use for docs, raw GitHub, any web page.",
31
35
  { url: "string" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ideacode",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "CLI TUI for AI agents via OpenRouter — agentic loop, tools, markdown",
5
5
  "type": "module",
6
6
  "repository": {