codeep 1.0.18 → 1.0.20

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.
Files changed (2) hide show
  1. package/dist/utils/agent.js +27 -11
  2. package/package.json +1 -1
@@ -505,27 +505,43 @@ export async function runAgent(prompt, projectContext, options = {}) {
505
505
  finalResponse = content.replace(/<think>[\s\S]*?<\/think>/gi, '').trim();
506
506
  // CRITICAL: Don't stop prematurely if we haven't done much work yet
507
507
  // Check if prompt contains "create", "build", "make", "implement", "add" etc.
508
- const taskKeywords = ['create', 'build', 'make', 'implement', 'add', 'generate', 'write', 'setup', 'develop', 'kreiraj', 'napravi', 'dodaj'];
508
+ const taskKeywords = ['create', 'build', 'make', 'implement', 'add', 'generate', 'write', 'setup', 'develop', 'kreiraj', 'napravi', 'dodaj', 'website', 'app', 'feature'];
509
509
  const promptLowerCase = prompt.toLowerCase();
510
510
  const isCreationTask = taskKeywords.some(kw => promptLowerCase.includes(kw));
511
- const hasCreatedFiles = actions.some(a => a.type === 'write' || a.type === 'mkdir');
512
- const hasEnoughActions = actions.length >= 3;
513
- const isVeryEarlyIteration = iteration <= 3;
514
- // If it's a creation task and agent hasn't created files yet, push it to continue
515
- if (isCreationTask && isVeryEarlyIteration && !hasCreatedFiles) {
516
- console.error(`[DEBUG] Agent trying to stop too early (iteration ${iteration}, ${actions.length} actions, no files created for creation task)`);
517
- // Push agent to actually do the work
511
+ // Only count actual FILE writes, not directories
512
+ const hasCreatedFiles = actions.some(a => a.type === 'write');
513
+ const writeFileCount = actions.filter(a => a.type === 'write').length;
514
+ const hasMkdir = actions.some(a => a.type === 'mkdir');
515
+ const isVeryEarlyIteration = iteration <= 5; // Extended to 5 iterations
516
+ console.error(`[DEBUG] Task check: isCreationTask=${isCreationTask}, hasCreatedFiles=${hasCreatedFiles}, writeFileCount=${writeFileCount}, hasMkdir=${hasMkdir}, iteration=${iteration}`);
517
+ console.error(`[DEBUG] Actions breakdown:`, actions.map(a => `${a.type}:${a.target}`).join(', '));
518
+ // STRICT RULE: If it's a creation task, agent MUST create FILES (not just directories)
519
+ // Creating a directory is not enough - we need actual file content
520
+ if (isCreationTask && !hasCreatedFiles && iteration <= 10) {
521
+ console.error(`[DEBUG] BLOCKING early stop - creation task detected but NO files created yet (iteration ${iteration}, ${actions.length} actions)`);
522
+ // Force agent to create files
518
523
  messages.push({ role: 'assistant', content: finalResponse });
519
524
  messages.push({
520
525
  role: 'user',
521
- content: `You haven't completed the task yet. You need to use the tools to actually CREATE the files and folders I asked for. Don't just plan or explain - EXECUTE! Use create_directory and write_file tools NOW to create the actual files.`
526
+ 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.`
522
527
  });
523
528
  finalResponse = ''; // Reset
524
529
  continue;
525
530
  }
526
- // Even if not clearly a creation task, if very few actions in early iterations, push to continue
531
+ // If creation task but not enough files created, keep pushing
532
+ if (isCreationTask && writeFileCount < 2 && iteration <= 10) {
533
+ console.error(`[DEBUG] BLOCKING early stop - only ${writeFileCount} files created, need more (iteration ${iteration})`);
534
+ messages.push({ role: 'assistant', content: finalResponse });
535
+ messages.push({
536
+ role: 'user',
537
+ content: `You've only created ${writeFileCount} file(s). The task requires creating multiple files. Continue creating the remaining files now.`
538
+ });
539
+ finalResponse = ''; // Reset
540
+ continue;
541
+ }
542
+ // General safety: very few actions in early iterations
527
543
  if (isVeryEarlyIteration && actions.length < 2) {
528
- console.error(`[DEBUG] Agent stopping with very few actions (iteration ${iteration}, only ${actions.length} actions)`);
544
+ console.error(`[DEBUG] BLOCKING early stop - very few actions (iteration ${iteration}, only ${actions.length} actions)`);
529
545
  messages.push({ role: 'assistant', content: finalResponse });
530
546
  messages.push({
531
547
  role: 'user',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeep",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
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",