coder-agent 2.9.6 → 2.9.8

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/agent.js CHANGED
@@ -35,7 +35,12 @@ function normalizeFilePath(p) {
35
35
  if (process.platform === "win32" && /^\/[a-zA-Z]:/.test(normalized)) {
36
36
  normalized = normalized.slice(1);
37
37
  }
38
- return path.normalize(normalized);
38
+ try {
39
+ return path.resolve(process.cwd(), normalized);
40
+ }
41
+ catch {
42
+ return path.normalize(normalized);
43
+ }
39
44
  }
40
45
  function extractDiagnostics(text) {
41
46
  const diagnostics = [];
@@ -180,38 +185,69 @@ function formatResponseText(text) {
180
185
  return chalk.white(part);
181
186
  }).join('');
182
187
  }
183
- function normalizeContentForLoopCheck(content) {
184
- if (!content)
188
+ function normalizeCode(code) {
189
+ if (!code)
185
190
  return "";
186
- return content
191
+ return code
187
192
  .toLowerCase()
188
- .replace(/\s+/g, " ")
193
+ .replace(/\s+/g, "")
189
194
  .trim();
190
195
  }
191
- function normalizeToolCallsForLoopCheck(toolCalls) {
196
+ function getLoopCheckKey(toolCalls) {
192
197
  if (!toolCalls || toolCalls.length === 0)
193
198
  return "";
194
- return toolCalls.map(tc => {
199
+ const parts = toolCalls.map(tc => {
195
200
  const name = tc.function?.name || "";
196
- let argsStr = "";
201
+ let args = {};
197
202
  try {
198
203
  const rawArgs = tc.function?.arguments;
199
- const args = typeof rawArgs === 'string'
204
+ args = typeof rawArgs === 'string'
200
205
  ? JSON.parse(rawArgs)
201
206
  : rawArgs;
202
- if (args && typeof args === 'object') {
203
- const sortedArgs = {};
204
- for (const key of Object.keys(args).sort()) {
205
- sortedArgs[key] = args[key];
206
- }
207
- argsStr = JSON.stringify(sortedArgs);
207
+ if (args && typeof args === "object") {
208
+ if (args.filepath && !args.file_path)
209
+ args.file_path = args.filepath;
210
+ if (args.path && !args.file_path)
211
+ args.file_path = args.path;
212
+ if (args.dirpath && !args.dir_path)
213
+ args.dir_path = args.dirpath;
208
214
  }
209
215
  }
210
- catch {
211
- argsStr = tc.function?.arguments || "";
216
+ catch { }
217
+ const filePath = args.file_path || args.dir_path || "";
218
+ const normalizedPath = filePath ? normalizeFilePath(filePath).toLowerCase() : "";
219
+ switch (name) {
220
+ case "read_file":
221
+ return `read_file:${normalizedPath}`;
222
+ case "read_file_lines":
223
+ const start = args.start_line ?? "";
224
+ const end = args.end_line ?? "";
225
+ return `read_file_lines:${normalizedPath}:${start}-${end}`;
226
+ case "write_file":
227
+ return `write_file:${normalizedPath}:${normalizeCode(args.content || "")}`;
228
+ case "patch_file":
229
+ const targetCode = normalizeCode(args.target_code || "");
230
+ const replacementCode = normalizeCode(args.replacement_code || "");
231
+ return `patch_file:${normalizedPath}:${targetCode}:${replacementCode}`;
232
+ case "list_directory":
233
+ return `list_directory:${normalizedPath}`;
234
+ case "run_shell":
235
+ const cmd = (args.command || "").toLowerCase().trim().replace(/\s+/g, " ");
236
+ return `run_shell:${cmd}`;
237
+ case "web_search":
238
+ const qSearch = (args.query || "").toLowerCase().trim().replace(/\s+/g, " ");
239
+ return `web_search:${qSearch}`;
240
+ case "find_files":
241
+ const qFind = (args.query || "").toLowerCase().trim().replace(/\s+/g, " ");
242
+ return `find_files:${normalizedPath}:${qFind}`;
243
+ case "search_grep":
244
+ const qGrep = (args.query || "").toLowerCase().trim().replace(/\s+/g, " ");
245
+ return `search_grep:${qGrep}`;
246
+ default:
247
+ return `${name}:${JSON.stringify(args)}`;
212
248
  }
213
- return `${name}(${argsStr})`;
214
- }).join(";");
249
+ });
250
+ return parts.sort().join(";");
215
251
  }
216
252
  function hasRepeatingCycle(history) {
217
253
  const n = history.length;
@@ -816,7 +852,7 @@ export class Agent {
816
852
  console.log(line);
817
853
  }
818
854
  // Loop detection & intervention
819
- const currentKey = `${normalizeContentForLoopCheck(msg.content || "")}|${normalizeToolCallsForLoopCheck(toolCalls)}`;
855
+ const currentKey = getLoopCheckKey(toolCalls);
820
856
  const tempHistory = [...stateHistory, currentKey];
821
857
  if (hasRepeatingCycle(tempHistory)) {
822
858
  loopInterventions++;
package/dist/memory.js CHANGED
@@ -239,12 +239,12 @@ When writing code in your response, always use this block format:
239
239
 
240
240
  Guidelines & Controls:
241
241
  - Be extremely concise in your explanations; let code and command output speak for itself.
242
- - When you have successfully completed the user's request or achieved the goal, output an extremely brief and minimal final response (e.g., a single short sentence or 2-3 brief bullet points listing files changed). Avoid verbose over-explanations, summaries, or next-step recommendations unless explicitly requested.
242
+ - Be decisive and clear at the end of the task. If you have successfully achieved the goal or completed the user's request, state clearly and confidently that the goal has been achieved (e.g., "I have successfully achieved the goal of..."). Do not sound tentative, confused, or ask vague follow-up questions. If you genuinely need input, feedback, or clarification from the user to proceed, ask for it directly. Keep final responses minimal and brief.
243
243
  - When writing or modifying code, always use the write_file or patch_file tools to apply the changes directly to the codebase. NEVER output raw code blocks or snippets in your chat response when they can be applied using tools. Chat responses should contain only brief status confirmations or final explanations. Always run a verify script/compile tool (like run_shell) after editing to verify the code works.
244
244
  - Prefer using search_grep to locate code, read_file_lines to read relevant parts, and patch_file to make targeted edits, especially in large codebases. This prevents token/context overflow.
245
245
  - Before answering questions or checking for errors in the codebase, always inspect the workspace to identify the files and languages present. Do not guess.
246
246
  - Focus on the actual files and programming language of the codebase you are currently running in.
247
- - If a task is ambiguous or you cannot find the code the user is referring to, ask ONE clarifying question before proceeding.
247
+ - If a task is ambiguous or you cannot find the code the user is referring to, ask the user a specific clarifying question directly.
248
248
  - CRITICAL (Tool Calling): Use the native API tool calling mechanism to execute tools. Never output raw XML tags, HTML tags, or mock function call strings (like '<function=...>') in your conversational chat response.
249
249
  - CRITICAL (Response Limitation): When calling a tool, do not output any conversational explanations, thoughts, or markdown before or after the tool call in the same response. Only output conversational text when you are providing the final answer.
250
250
  - CRITICAL SECURITY GUARDRAILS:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coder-agent",
3
- "version": "2.9.6",
3
+ "version": "2.9.8",
4
4
  "description": "CLI coding agent powered by Google Gemini",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",