codeep 1.0.17 → 1.0.19

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.
@@ -504,16 +504,45 @@ export async function runAgent(prompt, projectContext, options = {}) {
504
504
  // Remove <think>...</think> tags from response (some models include thinking)
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
- // Agent should create files, not just respond with text
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', 'website', 'app', 'feature'];
509
+ const promptLowerCase = prompt.toLowerCase();
510
+ const isCreationTask = taskKeywords.some(kw => promptLowerCase.includes(kw));
508
511
  const hasCreatedFiles = actions.some(a => a.type === 'write' || a.type === 'mkdir');
509
- const isVeryEarlyIteration = iteration <= 2 && actions.length < 3;
510
- if (isVeryEarlyIteration && !hasCreatedFiles) {
511
- console.error(`[DEBUG] Agent trying to stop too early (iteration ${iteration}, ${actions.length} actions, no files created)`);
512
- // Push agent to actually do the work
512
+ const writeFileCount = actions.filter(a => a.type === 'write').length;
513
+ const isVeryEarlyIteration = iteration <= 5; // Extended to 5 iterations
514
+ console.error(`[DEBUG] Task check: isCreationTask=${isCreationTask}, hasCreatedFiles=${hasCreatedFiles}, writeFileCount=${writeFileCount}, iteration=${iteration}`);
515
+ // STRICT RULE: If it's a creation task, agent MUST create files
516
+ // Don't accept early stopping even if it has "done some actions"
517
+ if (isCreationTask && !hasCreatedFiles && iteration <= 10) {
518
+ console.error(`[DEBUG] BLOCKING early stop - creation task detected but NO files created yet (iteration ${iteration}, ${actions.length} actions)`);
519
+ // Force agent to create files
513
520
  messages.push({ role: 'assistant', content: finalResponse });
514
521
  messages.push({
515
522
  role: 'user',
516
- 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 - execute! Use create_directory, write_file, and other tools NOW.`
523
+ 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.`
524
+ });
525
+ finalResponse = ''; // Reset
526
+ continue;
527
+ }
528
+ // If creation task but not enough files created, keep pushing
529
+ if (isCreationTask && writeFileCount < 2 && iteration <= 10) {
530
+ console.error(`[DEBUG] BLOCKING early stop - only ${writeFileCount} files created, need more (iteration ${iteration})`);
531
+ messages.push({ role: 'assistant', content: finalResponse });
532
+ messages.push({
533
+ role: 'user',
534
+ content: `You've only created ${writeFileCount} file(s). The task requires creating multiple files. Continue creating the remaining files now.`
535
+ });
536
+ finalResponse = ''; // Reset
537
+ continue;
538
+ }
539
+ // General safety: very few actions in early iterations
540
+ if (isVeryEarlyIteration && actions.length < 2) {
541
+ console.error(`[DEBUG] BLOCKING early stop - very few actions (iteration ${iteration}, only ${actions.length} actions)`);
542
+ messages.push({ role: 'assistant', content: finalResponse });
543
+ messages.push({
544
+ role: 'user',
545
+ content: `Continue working on the task. Use the available tools to complete what I asked for.`
517
546
  });
518
547
  finalResponse = ''; // Reset
519
548
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeep",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
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",