coder-agent 2.9.8 → 2.9.9
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 +67 -0
- package/dist/memory.js +1 -1
- package/package.json +1 -1
package/dist/agent.js
CHANGED
|
@@ -83,6 +83,30 @@ function extractDiagnostics(text) {
|
|
|
83
83
|
}
|
|
84
84
|
return diagnostics;
|
|
85
85
|
}
|
|
86
|
+
function extractFilePaths(text) {
|
|
87
|
+
const pathRegex = /(?:\.\/|\.\.\\|[a-zA-Z]:\\)?(?:[a-zA-Z0-9_\-\.]+[\\\/])+[a-zA-Z0-9_\-\.]+\.[a-zA-Z0-9]+/g;
|
|
88
|
+
const fileRegex = /\b[a-zA-Z0-9_\-\.]+\.[a-zA-Z0-9]+\b/g;
|
|
89
|
+
const matches = new Set();
|
|
90
|
+
let match;
|
|
91
|
+
while ((match = pathRegex.exec(text)) !== null) {
|
|
92
|
+
matches.add(match[0]);
|
|
93
|
+
}
|
|
94
|
+
while ((match = fileRegex.exec(text)) !== null) {
|
|
95
|
+
matches.add(match[0]);
|
|
96
|
+
}
|
|
97
|
+
const paths = [];
|
|
98
|
+
for (const m of matches) {
|
|
99
|
+
const trimmed = m.trim();
|
|
100
|
+
if (!trimmed)
|
|
101
|
+
continue;
|
|
102
|
+
if (/^\d/.test(trimmed))
|
|
103
|
+
continue;
|
|
104
|
+
if (trimmed.includes("://") || trimmed.startsWith("http"))
|
|
105
|
+
continue;
|
|
106
|
+
paths.push(trimmed);
|
|
107
|
+
}
|
|
108
|
+
return paths;
|
|
109
|
+
}
|
|
86
110
|
function getToolBadge(name) {
|
|
87
111
|
const blue = chalk.hex('#0a84ff');
|
|
88
112
|
const amber = chalk.hex('#ff9f0a');
|
|
@@ -680,6 +704,49 @@ export class Agent {
|
|
|
680
704
|
}
|
|
681
705
|
enrichedPrompt += "\n\n=== Enriched Code Context (Auto-Parsed) ===\n" + contexts.join("\n\n") + "\n===========================================";
|
|
682
706
|
}
|
|
707
|
+
// Auto-resolve any file paths explicitly mentioned in the user message
|
|
708
|
+
try {
|
|
709
|
+
const potentialPaths = extractFilePaths(userMessage);
|
|
710
|
+
const autoResolvedContexts = [];
|
|
711
|
+
for (const rawPath of potentialPaths) {
|
|
712
|
+
// Skip if already in diagnostics to avoid duplication
|
|
713
|
+
if (diagnostics.some(d => d.resource.toLowerCase().includes(rawPath.toLowerCase()))) {
|
|
714
|
+
continue;
|
|
715
|
+
}
|
|
716
|
+
const filePath = normalizeFilePath(rawPath);
|
|
717
|
+
try {
|
|
718
|
+
const stats = await fs.stat(filePath);
|
|
719
|
+
if (stats.isFile()) {
|
|
720
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
721
|
+
const lines = content.split(/\r?\n/);
|
|
722
|
+
const fileContentText = lines.length > 800
|
|
723
|
+
? lines.slice(0, 800).join("\n") + "\n... [Content truncated: first 800 lines shown] ..."
|
|
724
|
+
: content;
|
|
725
|
+
autoResolvedContexts.push(`File: ${rawPath}\n\`\`\`\n${fileContentText}\n\`\`\``);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
catch {
|
|
729
|
+
try {
|
|
730
|
+
// Try resolving relative path if absolute resolution failed
|
|
731
|
+
const relativePath = path.relative("/", filePath).replace(/^[a-zA-Z]:/, "").replace(/^\\+|^[//]+/, "");
|
|
732
|
+
const stats = await fs.stat(relativePath);
|
|
733
|
+
if (stats.isFile()) {
|
|
734
|
+
const content = await fs.readFile(relativePath, "utf-8");
|
|
735
|
+
const lines = content.split(/\r?\n/);
|
|
736
|
+
const fileContentText = lines.length > 800
|
|
737
|
+
? lines.slice(0, 800).join("\n") + "\n... [Content truncated: first 800 lines shown] ..."
|
|
738
|
+
: content;
|
|
739
|
+
autoResolvedContexts.push(`File: ${rawPath}\n\`\`\`\n${fileContentText}\n\`\`\``);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
catch { }
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
if (autoResolvedContexts.length > 0) {
|
|
746
|
+
enrichedPrompt += "\n\n=== Auto-Resolved File Context ===\n" + autoResolvedContexts.join("\n\n") + "\n===================================";
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
catch { }
|
|
683
750
|
this.memory.add({ role: "user", content: enrichedPrompt });
|
|
684
751
|
let iterations = 0;
|
|
685
752
|
const MAX_ITERATIONS = 12;
|
package/dist/memory.js
CHANGED
|
@@ -15,7 +15,7 @@ CORE OPERATING PRINCIPLES
|
|
|
15
15
|
- What is the correct file/folder structure?
|
|
16
16
|
- What dependencies are required and at what versions?
|
|
17
17
|
- What edge cases exist in this domain?
|
|
18
|
-
If the target file
|
|
18
|
+
If the target file is clear, or if its contents are already provided in the prompt context (e.g. under "Auto-Resolved File Context"), skip writing a plan, reasoning preamble, or explanation. Proceed directly to executing the edit tools (like patch_file or write_file) in the very first turn to achieve the goal as fast as possible. Minimize conversational turns and thinking overhead.
|
|
19
19
|
|
|
20
20
|
2. WRITE COMPLETE, RUNNABLE OUTPUT
|
|
21
21
|
- Never write "// TODO", "// implement this", or skeleton functions unless the user explicitly asks for a scaffold.
|