ideacode 1.0.2 → 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/index.js +1 -1
- package/dist/repl.js +10 -2
- package/dist/tools/index.js +7 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import "dotenv/config";
|
|
|
4
4
|
import { render } from "ink";
|
|
5
5
|
import { getApiKey } from "./config.js";
|
|
6
6
|
import { runOnboarding } from "./onboarding.js";
|
|
7
|
-
import { Repl } from "./
|
|
7
|
+
import { Repl } from "./repl.js";
|
|
8
8
|
async function main() {
|
|
9
9
|
let apiKey = getApiKey();
|
|
10
10
|
if (!apiKey) {
|
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
|
-
|
|
347
|
+
const contentForApi = truncateToolResult(result);
|
|
348
|
+
toolResults.push({ type: "tool_result", tool_use_id: block.id, content: contentForApi });
|
|
341
349
|
}
|
|
342
350
|
}
|
|
343
351
|
}
|
package/dist/tools/index.js
CHANGED
|
@@ -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.
|
|
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: [
|
|
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" },
|