codeep 1.0.22 → 1.0.23
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/utils/agent.js +5 -75
- package/dist/utils/tools.js +6 -2
- package/package.json +1 -1
package/dist/utils/agent.js
CHANGED
|
@@ -62,7 +62,7 @@ import { getProviderBaseUrl, getProviderAuthHeader, supportsNativeTools } from '
|
|
|
62
62
|
import { startSession, endSession, undoLastAction, undoAllActions, getCurrentSession, getRecentSessions, formatSession } from './history.js';
|
|
63
63
|
import { runAllVerifications, formatErrorsForAgent, hasVerificationErrors, getVerificationSummary } from './verify.js';
|
|
64
64
|
import { gatherSmartContext, formatSmartContext, extractTargetFile } from './smartContext.js';
|
|
65
|
-
import { planTasks,
|
|
65
|
+
import { planTasks, formatTaskPlan } from './taskPlanner.js';
|
|
66
66
|
const DEFAULT_OPTIONS = {
|
|
67
67
|
maxIterations: 100, // Increased for large tasks
|
|
68
68
|
maxDuration: 20 * 60 * 1000, // 20 minutes
|
|
@@ -636,83 +636,13 @@ export async function runAgent(prompt, projectContext, options = {}) {
|
|
|
636
636
|
toolCalls = textToolCalls;
|
|
637
637
|
}
|
|
638
638
|
}
|
|
639
|
-
// If no tool calls,
|
|
639
|
+
// If no tool calls, agent is done - simple and clean like Claude Code/Aider
|
|
640
640
|
if (toolCalls.length === 0) {
|
|
641
|
-
console.error(`[DEBUG] No tool calls at iteration ${iteration},
|
|
642
|
-
console.error(`[DEBUG] Response preview:`, content.substring(0, 200));
|
|
641
|
+
console.error(`[DEBUG] No tool calls at iteration ${iteration}, agent finished`);
|
|
643
642
|
// Remove <think>...</think> tags from response (some models include thinking)
|
|
644
643
|
finalResponse = content.replace(/<think>[\s\S]*?<\/think>/gi, '').trim();
|
|
645
|
-
//
|
|
646
|
-
//
|
|
647
|
-
const taskKeywords = ['create', 'build', 'make', 'implement', 'add', 'generate', 'write', 'setup', 'develop', 'kreiraj', 'napravi', 'dodaj', 'website', 'app', 'feature'];
|
|
648
|
-
const promptLowerCase = prompt.toLowerCase();
|
|
649
|
-
const isCreationTask = taskKeywords.some(kw => promptLowerCase.includes(kw));
|
|
650
|
-
// Only count actual FILE writes, not directories
|
|
651
|
-
const hasCreatedFiles = actions.some(a => a.type === 'write');
|
|
652
|
-
const writeFileCount = actions.filter(a => a.type === 'write').length;
|
|
653
|
-
const hasMkdir = actions.some(a => a.type === 'mkdir');
|
|
654
|
-
const isVeryEarlyIteration = iteration <= 5; // Extended to 5 iterations
|
|
655
|
-
console.error(`[DEBUG] Task check: isCreationTask=${isCreationTask}, hasCreatedFiles=${hasCreatedFiles}, writeFileCount=${writeFileCount}, hasMkdir=${hasMkdir}, iteration=${iteration}`);
|
|
656
|
-
console.error(`[DEBUG] Actions breakdown:`, actions.map(a => `${a.type}:${a.target}`).join(', '));
|
|
657
|
-
// STRICT RULE: If it's a creation task, agent MUST create FILES (not just directories)
|
|
658
|
-
// Creating a directory is not enough - we need actual file content
|
|
659
|
-
if (isCreationTask && !hasCreatedFiles && iteration <= 10) {
|
|
660
|
-
console.error(`[DEBUG] BLOCKING early stop - creation task detected but NO files created yet (iteration ${iteration}, ${actions.length} actions)`);
|
|
661
|
-
// Force agent to create files
|
|
662
|
-
messages.push({ role: 'assistant', content: finalResponse });
|
|
663
|
-
messages.push({
|
|
664
|
-
role: 'user',
|
|
665
|
-
content: `❌ STOP. You have NOT created any files yet!\n\nYou MUST use write_file and create_directory tools to create the actual files I asked for.\n\nDo NOT respond with explanations. Execute the tools NOW:\n1. Use create_directory if needed\n2. Use write_file to create EACH file\n3. Only after creating ALL files, respond with a summary.`
|
|
666
|
-
});
|
|
667
|
-
finalResponse = ''; // Reset
|
|
668
|
-
continue;
|
|
669
|
-
}
|
|
670
|
-
// If creation task but not enough files created, keep pushing
|
|
671
|
-
if (isCreationTask && writeFileCount < 2 && iteration <= 10) {
|
|
672
|
-
console.error(`[DEBUG] BLOCKING early stop - only ${writeFileCount} files created, need more (iteration ${iteration})`);
|
|
673
|
-
messages.push({ role: 'assistant', content: finalResponse });
|
|
674
|
-
messages.push({
|
|
675
|
-
role: 'user',
|
|
676
|
-
content: `You've only created ${writeFileCount} file(s). The task requires creating multiple files. Continue creating the remaining files now.`
|
|
677
|
-
});
|
|
678
|
-
finalResponse = ''; // Reset
|
|
679
|
-
continue;
|
|
680
|
-
}
|
|
681
|
-
// General safety: very few actions in early iterations
|
|
682
|
-
if (isVeryEarlyIteration && actions.length < 2) {
|
|
683
|
-
console.error(`[DEBUG] BLOCKING early stop - very few actions (iteration ${iteration}, only ${actions.length} actions)`);
|
|
684
|
-
messages.push({ role: 'assistant', content: finalResponse });
|
|
685
|
-
messages.push({
|
|
686
|
-
role: 'user',
|
|
687
|
-
content: `Continue working on the task. Use the available tools to complete what I asked for.`
|
|
688
|
-
});
|
|
689
|
-
finalResponse = ''; // Reset
|
|
690
|
-
continue;
|
|
691
|
-
}
|
|
692
|
-
// Check if we're using task planning and there are more tasks
|
|
693
|
-
if (taskPlan && taskPlan.tasks.some(t => t.status === 'pending')) {
|
|
694
|
-
const nextTask = getNextTask(taskPlan.tasks);
|
|
695
|
-
if (nextTask) {
|
|
696
|
-
// Mark previous task as completed
|
|
697
|
-
const prevTask = taskPlan.tasks.find(t => t.status === 'in_progress' && t.id !== nextTask.id);
|
|
698
|
-
if (prevTask) {
|
|
699
|
-
prevTask.status = 'completed';
|
|
700
|
-
}
|
|
701
|
-
// Move to next task
|
|
702
|
-
nextTask.status = 'in_progress';
|
|
703
|
-
opts.onTaskUpdate?.(nextTask);
|
|
704
|
-
// Build progress summary
|
|
705
|
-
const completedTasks = taskPlan.tasks.filter(t => t.status === 'completed');
|
|
706
|
-
const progressSummary = completedTasks.map(t => `✓ ${t.id}. ${t.description}`).join('\n');
|
|
707
|
-
messages.push({ role: 'assistant', content: finalResponse });
|
|
708
|
-
messages.push({
|
|
709
|
-
role: 'user',
|
|
710
|
-
content: `Good! Task ${prevTask?.id} done.\n\nCompleted:\n${progressSummary}\n\nNEXT TASK (do it now):\n${nextTask.id}. ${nextTask.description}\n\nUse your tools immediately to complete this task. Do NOT ask for permission or confirmation.`
|
|
711
|
-
});
|
|
712
|
-
finalResponse = ''; // Reset for next task
|
|
713
|
-
continue;
|
|
714
|
-
}
|
|
715
|
-
}
|
|
644
|
+
// Trust the model - if it says it's done, it's done
|
|
645
|
+
// No forcing, no blocking, no artificial requirements
|
|
716
646
|
break;
|
|
717
647
|
}
|
|
718
648
|
// Add assistant response to history
|
package/dist/utils/tools.js
CHANGED
|
@@ -459,7 +459,9 @@ function validatePath(path, projectRoot) {
|
|
|
459
459
|
* Execute a tool call
|
|
460
460
|
*/
|
|
461
461
|
export function executeTool(toolCall, projectRoot) {
|
|
462
|
-
|
|
462
|
+
// Normalize tool name to handle case variations (WRITE_FILE -> write_file)
|
|
463
|
+
const tool = normalizeToolName(toolCall.tool);
|
|
464
|
+
const parameters = toolCall.parameters;
|
|
463
465
|
try {
|
|
464
466
|
switch (tool) {
|
|
465
467
|
case 'read_file': {
|
|
@@ -732,6 +734,8 @@ function listDirectory(dir, projectRoot, recursive, prefix = '') {
|
|
|
732
734
|
* Create action log from tool result
|
|
733
735
|
*/
|
|
734
736
|
export function createActionLog(toolCall, result) {
|
|
737
|
+
// Normalize tool name to handle case variations
|
|
738
|
+
const normalizedTool = normalizeToolName(toolCall.tool);
|
|
735
739
|
const typeMap = {
|
|
736
740
|
read_file: 'read',
|
|
737
741
|
write_file: 'write',
|
|
@@ -749,7 +753,7 @@ export function createActionLog(toolCall, result) {
|
|
|
749
753
|
toolCall.parameters.url ||
|
|
750
754
|
'unknown';
|
|
751
755
|
return {
|
|
752
|
-
type: typeMap[
|
|
756
|
+
type: typeMap[normalizedTool] || 'command',
|
|
753
757
|
target,
|
|
754
758
|
result: result.success ? 'success' : 'error',
|
|
755
759
|
details: result.success ? result.output.slice(0, 200) : result.error,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeep",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "AI-powered coding assistant built for the terminal. Multiple LLM providers, project-aware context, and a seamless development workflow.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|