codeep 1.0.8 → 1.0.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.
@@ -7,7 +7,7 @@ import { getProviderBaseUrl, getProviderAuthHeader, supportsNativeTools } from '
7
7
  import { startSession, endSession, undoLastAction, undoAllActions, getCurrentSession, getRecentSessions, formatSession } from './history.js';
8
8
  import { runAllVerifications, formatErrorsForAgent, hasVerificationErrors, getVerificationSummary } from './verify.js';
9
9
  import { gatherSmartContext, formatSmartContext, extractTargetFile } from './smartContext.js';
10
- import { planTasks, formatTaskPlan } from './taskPlanner.js';
10
+ import { planTasks, getNextTask, formatTaskPlan } from './taskPlanner.js';
11
11
  const DEFAULT_OPTIONS = {
12
12
  maxIterations: 100, // Increased for large tasks
13
13
  maxDuration: 20 * 60 * 1000, // 20 minutes
@@ -27,15 +27,12 @@ function getAgentSystemPrompt(projectContext) {
27
27
  - List directory contents
28
28
 
29
29
  ## IMPORTANT: Follow User Instructions Exactly
30
- - Do EXACTLY what the user asks - complete the ENTIRE task
31
- - If user says "create a website" -> create ALL necessary files (HTML, CSS, JS, etc.)
30
+ - Do EXACTLY what the user asks
32
31
  - If user says "create folder X" -> use create_directory tool to create folder X
33
32
  - If user says "delete file X" -> use delete_file tool to delete file X
34
- - Do NOT stop after just 1-2 tool calls unless the task is trivially simple
35
- - Complex tasks (like creating websites) require MANY tool calls to complete
36
33
  - The user may write in any language - understand their request and execute it
37
34
  - Tool names and parameters must ALWAYS be in English (e.g., "create_directory", not "kreiraj_direktorij")
38
- - KEEP WORKING until the entire task is finished - do not stop prematurely
35
+ - When you finish a subtask, provide a clear summary and I will give you the next subtask
39
36
 
40
37
  ## Rules
41
38
  1. Always read files before editing them to understand the current content
@@ -72,15 +69,12 @@ function getFallbackSystemPrompt(projectContext) {
72
69
  return `You are an AI coding agent with FULL autonomous access to this project.
73
70
 
74
71
  ## IMPORTANT: Follow User Instructions Exactly
75
- - Do EXACTLY what the user asks - complete the ENTIRE task
76
- - If user says "create a website" -> create ALL necessary files (HTML, CSS, JS, etc.)
72
+ - Do EXACTLY what the user asks
77
73
  - If user says "create folder X" -> use create_directory tool
78
74
  - If user says "delete file X" -> use delete_file tool
79
- - Do NOT stop after just 1-2 tool calls unless the task is trivially simple
80
- - Complex tasks (like creating websites) require MANY tool calls to complete
81
75
  - The user may write in any language - understand and execute
82
76
  - Tool names and parameters must ALWAYS be in English
83
- - KEEP WORKING until the entire task is finished - do not stop prematurely
77
+ - When you finish a subtask, provide a clear summary and I will give you the next subtask
84
78
 
85
79
  ## Available Tools
86
80
  ${formatToolDefinitions()}
@@ -379,9 +373,13 @@ export async function runAgent(prompt, projectContext, options = {}) {
379
373
  const messages = [];
380
374
  // Start history session for undo support
381
375
  const sessionId = startSession(prompt, projectContext.root || process.cwd());
382
- // Task planning phase (if enabled and prompt is complex enough)
376
+ // Task planning phase (if enabled)
377
+ // Use planning for complex keywords or multi-word prompts
383
378
  let taskPlan = null;
384
- if (opts.usePlanning && prompt.split(' ').length > 5) {
379
+ const complexKeywords = ['create', 'build', 'implement', 'add', 'setup', 'generate', 'make', 'develop'];
380
+ const hasComplexKeyword = complexKeywords.some(kw => prompt.toLowerCase().includes(kw));
381
+ const shouldPlan = opts.usePlanning && (prompt.split(' ').length > 3 || hasComplexKeyword);
382
+ if (shouldPlan) {
385
383
  try {
386
384
  opts.onIteration?.(0, 'Planning tasks...');
387
385
  taskPlan = await planTasks(prompt, {
@@ -391,6 +389,8 @@ export async function runAgent(prompt, projectContext, options = {}) {
391
389
  });
392
390
  if (taskPlan.tasks.length > 1) {
393
391
  opts.onTaskPlan?.(taskPlan);
392
+ // Mark first task as in_progress
393
+ taskPlan.tasks[0].status = 'in_progress';
394
394
  }
395
395
  else {
396
396
  taskPlan = null; // Single task, no need for planning
@@ -479,41 +479,32 @@ export async function runAgent(prompt, projectContext, options = {}) {
479
479
  toolCalls = textToolCalls;
480
480
  }
481
481
  }
482
- // If no tool calls, check if this is really the final response
483
- // Don't exit on first iteration without tool calls - agent might be thinking
482
+ // If no tool calls, this is the final response
484
483
  if (toolCalls.length === 0) {
485
- // Only accept as final response if:
486
- // 1. We've done at least some work (iteration > 2)
487
- // 2. Agent explicitly indicates completion
488
- const completionIndicators = [
489
- 'task is complete',
490
- 'all files have been created',
491
- 'website has been created',
492
- 'successfully completed',
493
- 'everything is ready',
494
- 'all done'
495
- ];
496
- const lowerContent = content.toLowerCase();
497
- const indicatesCompletion = completionIndicators.some(indicator => lowerContent.includes(indicator));
498
- if (iteration > 2 && indicatesCompletion) {
499
- // Remove <think>...</think> tags from response
500
- finalResponse = content.replace(/<think>[\s\S]*?<\/think>/gi, '').trim();
501
- break;
502
- }
503
- else if (iteration <= 2) {
504
- // Too early to quit - remind agent to continue
505
- messages.push({ role: 'assistant', content });
506
- messages.push({
507
- role: 'user',
508
- content: 'Continue with the task. Use the tools to complete what was requested. Do not stop until all files are created and the task is fully complete.'
509
- });
510
- continue;
511
- }
512
- else {
513
- // Later iteration without completion indicator - accept as final
514
- finalResponse = content.replace(/<think>[\s\S]*?<\/think>/gi, '').trim();
515
- break;
484
+ // Remove <think>...</think> tags from response (some models include thinking)
485
+ finalResponse = content.replace(/<think>[\s\S]*?<\/think>/gi, '').trim();
486
+ // Check if we're using task planning and there are more tasks
487
+ if (taskPlan && taskPlan.tasks.some(t => t.status === 'pending')) {
488
+ const nextTask = getNextTask(taskPlan.tasks);
489
+ if (nextTask) {
490
+ // Move to next task
491
+ nextTask.status = 'in_progress';
492
+ opts.onTaskUpdate?.(nextTask);
493
+ messages.push({ role: 'assistant', content: finalResponse });
494
+ messages.push({
495
+ role: 'user',
496
+ content: `Good progress! Next task:\n\n${nextTask.id}. ${nextTask.description}\n\nComplete this task now.`
497
+ });
498
+ // Mark previous task as completed
499
+ const prevTask = taskPlan.tasks.find(t => t.status === 'in_progress' && t.id !== nextTask.id);
500
+ if (prevTask) {
501
+ prevTask.status = 'completed';
502
+ }
503
+ finalResponse = ''; // Reset for next task
504
+ continue;
505
+ }
516
506
  }
507
+ break;
517
508
  }
518
509
  // Add assistant response to history
519
510
  messages.push({ role: 'assistant', content });
@@ -548,12 +539,9 @@ export async function runAgent(prompt, projectContext, options = {}) {
548
539
  }
549
540
  }
550
541
  // Add tool results to messages
551
- const nextStepPrompt = iteration < 5
552
- ? `Tool results:\n\n${toolResults.join('\n\n')}\n\nGood progress! Continue working on the task. Use more tools to complete what was requested. Only stop when EVERYTHING is finished and working.`
553
- : `Tool results:\n\n${toolResults.join('\n\n')}\n\nContinue with the task. If the task is fully complete, provide a final summary without any tool calls.`;
554
542
  messages.push({
555
543
  role: 'user',
556
- content: nextStepPrompt,
544
+ content: `Tool results:\n\n${toolResults.join('\n\n')}\n\nContinue with the task. If this subtask is complete, provide a summary without tool calls.`,
557
545
  });
558
546
  }
559
547
  // Check if we hit max iterations
@@ -10,19 +10,21 @@ export async function planTasks(userPrompt, projectContext) {
10
10
  const systemPrompt = `You are a task planning expert. Break down user requests into clear, sequential subtasks.
11
11
 
12
12
  RULES:
13
- 1. Create 3-15 subtasks maximum
14
- 2. Each subtask should be specific and actionable
15
- 3. Order tasks logically (dependencies first)
13
+ 1. Create 3-10 subtasks maximum (keep it focused)
14
+ 2. Each subtask should be specific and achievable in 2-5 tool calls
15
+ 3. Order tasks logically - one file/component per task
16
16
  4. Use simple, clear descriptions
17
- 5. Respond ONLY with a JSON object, no other text
17
+ 5. For websites: separate HTML, CSS, JS into different tasks
18
+ 6. Respond ONLY with a JSON object, no other text
18
19
 
19
- Example response format:
20
+ Example for "create a website":
20
21
  {
21
22
  "tasks": [
22
- {"id": 1, "description": "Create project directory structure", "dependencies": []},
23
- {"id": 2, "description": "Create index.html with basic structure", "dependencies": [1]},
24
- {"id": 3, "description": "Create styles.css with base styles", "dependencies": [1]},
25
- {"id": 4, "description": "Add navigation to all pages", "dependencies": [2, 3]}
23
+ {"id": 1, "description": "Create directory structure", "dependencies": []},
24
+ {"id": 2, "description": "Create index.html with page structure", "dependencies": [1]},
25
+ {"id": 3, "description": "Create styles.css with layout and design", "dependencies": [1]},
26
+ {"id": 4, "description": "Create script.js with interactive features", "dependencies": [1]},
27
+ {"id": 5, "description": "Add content and finalize all pages", "dependencies": [2, 3, 4]}
26
28
  ]
27
29
  }
28
30
 
@@ -32,7 +34,7 @@ Project Context:
32
34
 
33
35
  User Request: ${userPrompt}
34
36
 
35
- Break this down into subtasks. Respond with JSON only.`;
37
+ Break this down into subtasks. Each task = one file or one logical unit. Respond with JSON only.`;
36
38
  try {
37
39
  const apiKey = await getApiKey();
38
40
  if (!apiKey) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeep",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
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",