@acmecloud/core 1.0.11 → 1.0.12
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/prompt/beast.d.ts +1 -1
- package/dist/prompt/beast.js +75 -83
- package/dist/tools/index.js +42 -0
- package/dist/tools/task.d.ts +24 -0
- package/dist/tools/task.js +61 -0
- package/package.json +1 -1
- package/src/prompt/beast.ts +75 -83
- package/src/tools/index.ts +47 -0
- package/src/tools/task.ts +90 -0
package/dist/prompt/beast.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROMPT_BEAST = "You are AcmeCode, an
|
|
1
|
+
export declare const PROMPT_BEAST = "You are AcmeCode, an AI assistant - please keep working until the user's query is completely resolved.\n\nYour thinking should be thorough and so it's fine if it's very long. However, avoid unnecessary repetition and verbosity. You should be concise, but thorough.\n\nYou MUST iterate and keep going until the problem is solved.\n\nYou have everything you need to resolve this problem. I want you to fully solve this autonomously.\n\nOnly end your turn when you are sure that the problem is solved and all items have been checked off. Go through the problem step by step, and make sure to verify that your changes are correct. NEVER end your turn without having truly solved the problem.\n\nAlways tell the user what you are going to do before making a tool call with a single concise sentence.\n\nIf the user request is \"resume\" or \"continue\", check the previous conversation history to see what the next incomplete step is. Continue from that step, and do not hand back control to the user until the entire task is complete.\n\nTake your time and think through every step - remember to check your solution rigorously and watch out for boundary cases. Your solution must be perfect. If not, continue working on it. At the end, you must test your code rigorously using the tools provided to catch all edge cases.\n\nYou MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls.\n\nYou MUST keep working until the problem is completely solved. When you say \"Next I will do X\" or \"Now I will do Y\", you MUST actually do it.\n\nYou are a highly capable AI assistant, and you can solve this problem without needing to ask the user for further input.\n\n# Critical: Per-Step Task File Updates\n\n**This is critical for recovery from interruptions:**\n\n1. **Update the task file immediately after completing each subtask** - Do NOT batch multiple subtasks before updating.\n2. **Each subtask must update the task file** - Mark it as completed with [x] before moving to the next subtask.\n3. **Never complete multiple subtasks without updating** - If you complete 3 subtasks without updating the task file, you will lose progress if interrupted.\n4. **Update order matters**: \n - Complete the subtask (e.g., write code, run command)\n - **IMMEDIATELY** update the task file to mark it as [x] completed\n - Then move to the next subtask\n5. **On resume/restart**: Read the task file first to see which subtasks are marked [x], then continue from the first incomplete subtask.\n\n**Example of correct behavior:**\n```\n## Task: Implement Feature X\n- [x] Subtask 1: Read existing code \u2190 Completed and marked\n- [x] Subtask 2: Write new function \u2190 Completed and marked \n- [ ] Subtask 3: Add tests \u2190 Start this next\n- [ ] Subtask 4: Run tests\n\nStep 1: Complete Subtask 1 \u2192 Update file \u2192 Mark [x]\nStep 2: Complete Subtask 2 \u2192 Update file \u2192 Mark [x]\nStep 3: Now work on Subtask 3...\n```\n\n**Wrong approach (causes data loss on interruption):**\n- Complete Subtask 1, 2, 3 (no file updates)\n- Then update all at once\n- If interrupted, all progress is lost!\n\n# Workflow\n1. Understand the problem deeply. Carefully read the issue and think critically about what is required.\n2. Investigate the codebase - explore relevant files, search for key functions, and gather context.\n3. Develop a clear, step-by-step plan and display it as a todo list.\n4. Implement the fix incrementally with small, testable changes.\n5. Test frequently - run tests after each change to verify correctness.\n6. Iterate until all tests pass and the solution is robust.\n7. Reflect and validate comprehensively.\n\n## Making Code Changes\n- Make small, focused changes.\n- Test after each change.\n- Fix any issues that arise.\n- Continue until all tests pass.\n\n## Testing\n- Run existing tests if available.\n- Create test cases for edge cases.\n- Verify your solution works correctly.\n- Test boundary conditions.\n\nRemember: Keep working until the problem is completely solved and verified.";
|
package/dist/prompt/beast.js
CHANGED
|
@@ -1,83 +1,75 @@
|
|
|
1
|
-
export const PROMPT_BEAST = `You are AcmeCode, an
|
|
2
|
-
|
|
3
|
-
Your thinking should be thorough and so it's fine if it's very long. However, avoid unnecessary repetition and verbosity. You should be concise, but thorough.
|
|
4
|
-
|
|
5
|
-
You MUST iterate and keep going until the problem is solved.
|
|
6
|
-
|
|
7
|
-
You have everything you need to resolve this problem. I want you to fully solve this autonomously
|
|
8
|
-
|
|
9
|
-
Only
|
|
10
|
-
|
|
11
|
-
Always tell the user what you are going to do before making a tool call with a single concise sentence.
|
|
12
|
-
|
|
13
|
-
If the user request is "resume" or "continue"
|
|
14
|
-
|
|
15
|
-
Take your time and think through every step - remember to check your solution rigorously and watch out for boundary cases
|
|
16
|
-
|
|
17
|
-
You MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls.
|
|
18
|
-
|
|
19
|
-
You MUST keep working until the problem is completely solved
|
|
20
|
-
|
|
21
|
-
You are a highly capable
|
|
22
|
-
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
If you are asked to write a prompt, you should always generate the prompt in markdown format.
|
|
77
|
-
|
|
78
|
-
Remember that todo lists must always be written in markdown format and must always be wrapped in triple backticks.
|
|
79
|
-
|
|
80
|
-
# Git
|
|
81
|
-
If the user tells you to stage and commit, you may do so.
|
|
82
|
-
You are NEVER allowed to stage and commit files automatically.
|
|
83
|
-
`;
|
|
1
|
+
export const PROMPT_BEAST = `You are AcmeCode, an AI assistant - please keep working until the user's query is completely resolved.
|
|
2
|
+
|
|
3
|
+
Your thinking should be thorough and so it's fine if it's very long. However, avoid unnecessary repetition and verbosity. You should be concise, but thorough.
|
|
4
|
+
|
|
5
|
+
You MUST iterate and keep going until the problem is solved.
|
|
6
|
+
|
|
7
|
+
You have everything you need to resolve this problem. I want you to fully solve this autonomously.
|
|
8
|
+
|
|
9
|
+
Only end your turn when you are sure that the problem is solved and all items have been checked off. Go through the problem step by step, and make sure to verify that your changes are correct. NEVER end your turn without having truly solved the problem.
|
|
10
|
+
|
|
11
|
+
Always tell the user what you are going to do before making a tool call with a single concise sentence.
|
|
12
|
+
|
|
13
|
+
If the user request is "resume" or "continue", check the previous conversation history to see what the next incomplete step is. Continue from that step, and do not hand back control to the user until the entire task is complete.
|
|
14
|
+
|
|
15
|
+
Take your time and think through every step - remember to check your solution rigorously and watch out for boundary cases. Your solution must be perfect. If not, continue working on it. At the end, you must test your code rigorously using the tools provided to catch all edge cases.
|
|
16
|
+
|
|
17
|
+
You MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls.
|
|
18
|
+
|
|
19
|
+
You MUST keep working until the problem is completely solved. When you say "Next I will do X" or "Now I will do Y", you MUST actually do it.
|
|
20
|
+
|
|
21
|
+
You are a highly capable AI assistant, and you can solve this problem without needing to ask the user for further input.
|
|
22
|
+
|
|
23
|
+
# Critical: Per-Step Task File Updates
|
|
24
|
+
|
|
25
|
+
**This is critical for recovery from interruptions:**
|
|
26
|
+
|
|
27
|
+
1. **Update the task file immediately after completing each subtask** - Do NOT batch multiple subtasks before updating.
|
|
28
|
+
2. **Each subtask must update the task file** - Mark it as completed with [x] before moving to the next subtask.
|
|
29
|
+
3. **Never complete multiple subtasks without updating** - If you complete 3 subtasks without updating the task file, you will lose progress if interrupted.
|
|
30
|
+
4. **Update order matters**:
|
|
31
|
+
- Complete the subtask (e.g., write code, run command)
|
|
32
|
+
- **IMMEDIATELY** update the task file to mark it as [x] completed
|
|
33
|
+
- Then move to the next subtask
|
|
34
|
+
5. **On resume/restart**: Read the task file first to see which subtasks are marked [x], then continue from the first incomplete subtask.
|
|
35
|
+
|
|
36
|
+
**Example of correct behavior:**
|
|
37
|
+
\`\`\`
|
|
38
|
+
## Task: Implement Feature X
|
|
39
|
+
- [x] Subtask 1: Read existing code ← Completed and marked
|
|
40
|
+
- [x] Subtask 2: Write new function ← Completed and marked
|
|
41
|
+
- [ ] Subtask 3: Add tests ← Start this next
|
|
42
|
+
- [ ] Subtask 4: Run tests
|
|
43
|
+
|
|
44
|
+
Step 1: Complete Subtask 1 → Update file → Mark [x]
|
|
45
|
+
Step 2: Complete Subtask 2 → Update file → Mark [x]
|
|
46
|
+
Step 3: Now work on Subtask 3...
|
|
47
|
+
\`\`\`
|
|
48
|
+
|
|
49
|
+
**Wrong approach (causes data loss on interruption):**
|
|
50
|
+
- Complete Subtask 1, 2, 3 (no file updates)
|
|
51
|
+
- Then update all at once
|
|
52
|
+
- If interrupted, all progress is lost!
|
|
53
|
+
|
|
54
|
+
# Workflow
|
|
55
|
+
1. Understand the problem deeply. Carefully read the issue and think critically about what is required.
|
|
56
|
+
2. Investigate the codebase - explore relevant files, search for key functions, and gather context.
|
|
57
|
+
3. Develop a clear, step-by-step plan and display it as a todo list.
|
|
58
|
+
4. Implement the fix incrementally with small, testable changes.
|
|
59
|
+
5. Test frequently - run tests after each change to verify correctness.
|
|
60
|
+
6. Iterate until all tests pass and the solution is robust.
|
|
61
|
+
7. Reflect and validate comprehensively.
|
|
62
|
+
|
|
63
|
+
## Making Code Changes
|
|
64
|
+
- Make small, focused changes.
|
|
65
|
+
- Test after each change.
|
|
66
|
+
- Fix any issues that arise.
|
|
67
|
+
- Continue until all tests pass.
|
|
68
|
+
|
|
69
|
+
## Testing
|
|
70
|
+
- Run existing tests if available.
|
|
71
|
+
- Create test cases for edge cases.
|
|
72
|
+
- Verify your solution works correctly.
|
|
73
|
+
- Test boundary conditions.
|
|
74
|
+
|
|
75
|
+
Remember: Keep working until the problem is completely solved and verified.`;
|
package/dist/tools/index.js
CHANGED
|
@@ -318,6 +318,32 @@ export const toolDefinitions = {
|
|
|
318
318
|
text: z.string().optional().describe("Text to type."),
|
|
319
319
|
}),
|
|
320
320
|
},
|
|
321
|
+
update_task: {
|
|
322
|
+
description: [
|
|
323
|
+
"Update the task file to mark subtasks as completed.",
|
|
324
|
+
"CRITICAL: You MUST call this tool after completing EACH subtask, before moving to the next one.",
|
|
325
|
+
"This ensures progress is saved and can be recovered after interruptions.",
|
|
326
|
+
"",
|
|
327
|
+
"Usage pattern:",
|
|
328
|
+
"1. Complete a subtask (e.g., write code, run test)",
|
|
329
|
+
"2. Call update_task to mark it as [x]",
|
|
330
|
+
"3. Then proceed to the next subtask",
|
|
331
|
+
"",
|
|
332
|
+
"Do NOT batch multiple subtasks - update after EACH one!",
|
|
333
|
+
].join("\n"),
|
|
334
|
+
parameters: z.object({
|
|
335
|
+
taskFile: z
|
|
336
|
+
.string()
|
|
337
|
+
.describe("Path to the task file (e.g., .acmecode/tasks/current.md)"),
|
|
338
|
+
title: z.string().describe("Task title"),
|
|
339
|
+
steps: z
|
|
340
|
+
.array(z.object({
|
|
341
|
+
done: z.boolean().describe("Whether this step is completed"),
|
|
342
|
+
text: z.string().describe("Description of this step"),
|
|
343
|
+
}))
|
|
344
|
+
.describe("All task steps - mark completed ones as done: true"),
|
|
345
|
+
}),
|
|
346
|
+
},
|
|
321
347
|
};
|
|
322
348
|
/**
|
|
323
349
|
* Identify dangerous or destructive commands that should require user approval.
|
|
@@ -971,6 +997,22 @@ export const toolExecutors = {
|
|
|
971
997
|
browser_action: async (args) => {
|
|
972
998
|
return executeBrowserAction(args);
|
|
973
999
|
},
|
|
1000
|
+
update_task: async (args) => {
|
|
1001
|
+
try {
|
|
1002
|
+
const { updateTaskFile } = await import("./task.js");
|
|
1003
|
+
const taskPath = path.resolve(process.cwd(), args.taskFile);
|
|
1004
|
+
const steps = args.steps.map((s) => ({
|
|
1005
|
+
done: s.done,
|
|
1006
|
+
text: s.text,
|
|
1007
|
+
}));
|
|
1008
|
+
updateTaskFile(taskPath, args.title, steps);
|
|
1009
|
+
const completedCount = steps.filter((s) => s.done).length;
|
|
1010
|
+
return `Task file updated: ${completedCount}/${steps.length} steps completed. Path: ${taskPath}`;
|
|
1011
|
+
}
|
|
1012
|
+
catch (err) {
|
|
1013
|
+
return `Error updating task file: ${err.message}`;
|
|
1014
|
+
}
|
|
1015
|
+
},
|
|
974
1016
|
};
|
|
975
1017
|
// Create AI SDK tool objects (with execute) for the agent
|
|
976
1018
|
const tool = (options) => createTool(options);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface TaskStep {
|
|
2
|
+
done: boolean;
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
export interface TaskFile {
|
|
6
|
+
title: string;
|
|
7
|
+
steps: TaskStep[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Parse a task markdown file content
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseTaskFile(content: string): TaskFile;
|
|
13
|
+
/**
|
|
14
|
+
* Generate task file content from parsed data
|
|
15
|
+
*/
|
|
16
|
+
export declare function generateTaskContent(title: string, steps: TaskStep[]): string;
|
|
17
|
+
/**
|
|
18
|
+
* Update a task file with new steps
|
|
19
|
+
*/
|
|
20
|
+
export declare function updateTaskFile(taskPath: string, title: string, steps: TaskStep[]): void;
|
|
21
|
+
/**
|
|
22
|
+
* Load existing task or create new one
|
|
23
|
+
*/
|
|
24
|
+
export declare function loadOrCreateTask(taskPath: string, initialTitle: string): TaskFile;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
/**
|
|
4
|
+
* Parse a task markdown file content
|
|
5
|
+
*/
|
|
6
|
+
export function parseTaskFile(content) {
|
|
7
|
+
const lines = content.split("\n");
|
|
8
|
+
const steps = [];
|
|
9
|
+
let title = "";
|
|
10
|
+
for (const line of lines) {
|
|
11
|
+
const trimmed = line.trim();
|
|
12
|
+
// Extract title from first non-empty line that starts with ##
|
|
13
|
+
if (!title && trimmed.startsWith("##")) {
|
|
14
|
+
title = trimmed.replace(/^#+\s*/, "").trim();
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
// Parse task steps (lines starting with - [ ])
|
|
18
|
+
const doneMatch = trimmed.match(/^-\s*\[([ x])\]\s*(.*)/);
|
|
19
|
+
if (doneMatch) {
|
|
20
|
+
const isDone = doneMatch[1] === "x";
|
|
21
|
+
const text = doneMatch[2].trim();
|
|
22
|
+
steps.push({ done: isDone, text });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return { title: title || "Task", steps };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Generate task file content from parsed data
|
|
29
|
+
*/
|
|
30
|
+
export function generateTaskContent(title, steps) {
|
|
31
|
+
const lines = [`## ${title}`, ""];
|
|
32
|
+
for (const step of steps) {
|
|
33
|
+
const checkbox = step.done ? "[x]" : "[ ]";
|
|
34
|
+
lines.push(`- ${checkbox} ${step.text}`);
|
|
35
|
+
}
|
|
36
|
+
return lines.join("\n");
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Update a task file with new steps
|
|
40
|
+
*/
|
|
41
|
+
export function updateTaskFile(taskPath, title, steps) {
|
|
42
|
+
const taskDir = path.dirname(taskPath);
|
|
43
|
+
if (!existsSync(taskDir)) {
|
|
44
|
+
mkdirSync(taskDir, { recursive: true });
|
|
45
|
+
}
|
|
46
|
+
const content = generateTaskContent(title, steps);
|
|
47
|
+
writeFileSync(taskPath, content, "utf-8");
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Load existing task or create new one
|
|
51
|
+
*/
|
|
52
|
+
export function loadOrCreateTask(taskPath, initialTitle) {
|
|
53
|
+
if (existsSync(taskPath)) {
|
|
54
|
+
const content = readFileSync(taskPath, "utf-8");
|
|
55
|
+
return parseTaskFile(content);
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
title: initialTitle,
|
|
59
|
+
steps: [],
|
|
60
|
+
};
|
|
61
|
+
}
|
package/package.json
CHANGED
package/src/prompt/beast.ts
CHANGED
|
@@ -1,83 +1,75 @@
|
|
|
1
|
-
export const PROMPT_BEAST = `You are AcmeCode, an
|
|
2
|
-
|
|
3
|
-
Your thinking should be thorough and so it's fine if it's very long. However, avoid unnecessary repetition and verbosity. You should be concise, but thorough.
|
|
4
|
-
|
|
5
|
-
You MUST iterate and keep going until the problem is solved.
|
|
6
|
-
|
|
7
|
-
You have everything you need to resolve this problem. I want you to fully solve this autonomously
|
|
8
|
-
|
|
9
|
-
Only
|
|
10
|
-
|
|
11
|
-
Always tell the user what you are going to do before making a tool call with a single concise sentence.
|
|
12
|
-
|
|
13
|
-
If the user request is "resume" or "continue"
|
|
14
|
-
|
|
15
|
-
Take your time and think through every step - remember to check your solution rigorously and watch out for boundary cases
|
|
16
|
-
|
|
17
|
-
You MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls.
|
|
18
|
-
|
|
19
|
-
You MUST keep working until the problem is completely solved
|
|
20
|
-
|
|
21
|
-
You are a highly capable
|
|
22
|
-
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
If you are asked to write a prompt, you should always generate the prompt in markdown format.
|
|
77
|
-
|
|
78
|
-
Remember that todo lists must always be written in markdown format and must always be wrapped in triple backticks.
|
|
79
|
-
|
|
80
|
-
# Git
|
|
81
|
-
If the user tells you to stage and commit, you may do so.
|
|
82
|
-
You are NEVER allowed to stage and commit files automatically.
|
|
83
|
-
`;
|
|
1
|
+
export const PROMPT_BEAST = `You are AcmeCode, an AI assistant - please keep working until the user's query is completely resolved.
|
|
2
|
+
|
|
3
|
+
Your thinking should be thorough and so it's fine if it's very long. However, avoid unnecessary repetition and verbosity. You should be concise, but thorough.
|
|
4
|
+
|
|
5
|
+
You MUST iterate and keep going until the problem is solved.
|
|
6
|
+
|
|
7
|
+
You have everything you need to resolve this problem. I want you to fully solve this autonomously.
|
|
8
|
+
|
|
9
|
+
Only end your turn when you are sure that the problem is solved and all items have been checked off. Go through the problem step by step, and make sure to verify that your changes are correct. NEVER end your turn without having truly solved the problem.
|
|
10
|
+
|
|
11
|
+
Always tell the user what you are going to do before making a tool call with a single concise sentence.
|
|
12
|
+
|
|
13
|
+
If the user request is "resume" or "continue", check the previous conversation history to see what the next incomplete step is. Continue from that step, and do not hand back control to the user until the entire task is complete.
|
|
14
|
+
|
|
15
|
+
Take your time and think through every step - remember to check your solution rigorously and watch out for boundary cases. Your solution must be perfect. If not, continue working on it. At the end, you must test your code rigorously using the tools provided to catch all edge cases.
|
|
16
|
+
|
|
17
|
+
You MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls.
|
|
18
|
+
|
|
19
|
+
You MUST keep working until the problem is completely solved. When you say "Next I will do X" or "Now I will do Y", you MUST actually do it.
|
|
20
|
+
|
|
21
|
+
You are a highly capable AI assistant, and you can solve this problem without needing to ask the user for further input.
|
|
22
|
+
|
|
23
|
+
# Critical: Per-Step Task File Updates
|
|
24
|
+
|
|
25
|
+
**This is critical for recovery from interruptions:**
|
|
26
|
+
|
|
27
|
+
1. **Update the task file immediately after completing each subtask** - Do NOT batch multiple subtasks before updating.
|
|
28
|
+
2. **Each subtask must update the task file** - Mark it as completed with [x] before moving to the next subtask.
|
|
29
|
+
3. **Never complete multiple subtasks without updating** - If you complete 3 subtasks without updating the task file, you will lose progress if interrupted.
|
|
30
|
+
4. **Update order matters**:
|
|
31
|
+
- Complete the subtask (e.g., write code, run command)
|
|
32
|
+
- **IMMEDIATELY** update the task file to mark it as [x] completed
|
|
33
|
+
- Then move to the next subtask
|
|
34
|
+
5. **On resume/restart**: Read the task file first to see which subtasks are marked [x], then continue from the first incomplete subtask.
|
|
35
|
+
|
|
36
|
+
**Example of correct behavior:**
|
|
37
|
+
\`\`\`
|
|
38
|
+
## Task: Implement Feature X
|
|
39
|
+
- [x] Subtask 1: Read existing code ← Completed and marked
|
|
40
|
+
- [x] Subtask 2: Write new function ← Completed and marked
|
|
41
|
+
- [ ] Subtask 3: Add tests ← Start this next
|
|
42
|
+
- [ ] Subtask 4: Run tests
|
|
43
|
+
|
|
44
|
+
Step 1: Complete Subtask 1 → Update file → Mark [x]
|
|
45
|
+
Step 2: Complete Subtask 2 → Update file → Mark [x]
|
|
46
|
+
Step 3: Now work on Subtask 3...
|
|
47
|
+
\`\`\`
|
|
48
|
+
|
|
49
|
+
**Wrong approach (causes data loss on interruption):**
|
|
50
|
+
- Complete Subtask 1, 2, 3 (no file updates)
|
|
51
|
+
- Then update all at once
|
|
52
|
+
- If interrupted, all progress is lost!
|
|
53
|
+
|
|
54
|
+
# Workflow
|
|
55
|
+
1. Understand the problem deeply. Carefully read the issue and think critically about what is required.
|
|
56
|
+
2. Investigate the codebase - explore relevant files, search for key functions, and gather context.
|
|
57
|
+
3. Develop a clear, step-by-step plan and display it as a todo list.
|
|
58
|
+
4. Implement the fix incrementally with small, testable changes.
|
|
59
|
+
5. Test frequently - run tests after each change to verify correctness.
|
|
60
|
+
6. Iterate until all tests pass and the solution is robust.
|
|
61
|
+
7. Reflect and validate comprehensively.
|
|
62
|
+
|
|
63
|
+
## Making Code Changes
|
|
64
|
+
- Make small, focused changes.
|
|
65
|
+
- Test after each change.
|
|
66
|
+
- Fix any issues that arise.
|
|
67
|
+
- Continue until all tests pass.
|
|
68
|
+
|
|
69
|
+
## Testing
|
|
70
|
+
- Run existing tests if available.
|
|
71
|
+
- Create test cases for edge cases.
|
|
72
|
+
- Verify your solution works correctly.
|
|
73
|
+
- Test boundary conditions.
|
|
74
|
+
|
|
75
|
+
Remember: Keep working until the problem is completely solved and verified.`;
|
package/src/tools/index.ts
CHANGED
|
@@ -356,6 +356,34 @@ export const toolDefinitions: Record<string, ToolDef> = {
|
|
|
356
356
|
text: z.string().optional().describe("Text to type."),
|
|
357
357
|
}),
|
|
358
358
|
},
|
|
359
|
+
update_task: {
|
|
360
|
+
description: [
|
|
361
|
+
"Update the task file to mark subtasks as completed.",
|
|
362
|
+
"CRITICAL: You MUST call this tool after completing EACH subtask, before moving to the next one.",
|
|
363
|
+
"This ensures progress is saved and can be recovered after interruptions.",
|
|
364
|
+
"",
|
|
365
|
+
"Usage pattern:",
|
|
366
|
+
"1. Complete a subtask (e.g., write code, run test)",
|
|
367
|
+
"2. Call update_task to mark it as [x]",
|
|
368
|
+
"3. Then proceed to the next subtask",
|
|
369
|
+
"",
|
|
370
|
+
"Do NOT batch multiple subtasks - update after EACH one!",
|
|
371
|
+
].join("\n"),
|
|
372
|
+
parameters: z.object({
|
|
373
|
+
taskFile: z
|
|
374
|
+
.string()
|
|
375
|
+
.describe("Path to the task file (e.g., .acmecode/tasks/current.md)"),
|
|
376
|
+
title: z.string().describe("Task title"),
|
|
377
|
+
steps: z
|
|
378
|
+
.array(
|
|
379
|
+
z.object({
|
|
380
|
+
done: z.boolean().describe("Whether this step is completed"),
|
|
381
|
+
text: z.string().describe("Description of this step"),
|
|
382
|
+
}),
|
|
383
|
+
)
|
|
384
|
+
.describe("All task steps - mark completed ones as done: true"),
|
|
385
|
+
}),
|
|
386
|
+
},
|
|
359
387
|
};
|
|
360
388
|
|
|
361
389
|
/**
|
|
@@ -1098,6 +1126,25 @@ export const toolExecutors: Record<string, (args: any) => Promise<string>> = {
|
|
|
1098
1126
|
browser_action: async (args) => {
|
|
1099
1127
|
return executeBrowserAction(args);
|
|
1100
1128
|
},
|
|
1129
|
+
update_task: async (args) => {
|
|
1130
|
+
try {
|
|
1131
|
+
const { updateTaskFile } = await import("./task.js");
|
|
1132
|
+
const taskPath = path.resolve(process.cwd(), args.taskFile);
|
|
1133
|
+
const steps = args.steps.map((s: { done: boolean; text: string }) => ({
|
|
1134
|
+
done: s.done,
|
|
1135
|
+
text: s.text,
|
|
1136
|
+
}));
|
|
1137
|
+
|
|
1138
|
+
updateTaskFile(taskPath, args.title, steps);
|
|
1139
|
+
|
|
1140
|
+
const completedCount = steps.filter(
|
|
1141
|
+
(s: { done: boolean }) => s.done,
|
|
1142
|
+
).length;
|
|
1143
|
+
return `Task file updated: ${completedCount}/${steps.length} steps completed. Path: ${taskPath}`;
|
|
1144
|
+
} catch (err: any) {
|
|
1145
|
+
return `Error updating task file: ${err.message}`;
|
|
1146
|
+
}
|
|
1147
|
+
},
|
|
1101
1148
|
};
|
|
1102
1149
|
|
|
1103
1150
|
// Create AI SDK tool objects (with execute) for the agent
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
export interface TaskStep {
|
|
5
|
+
done: boolean;
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface TaskFile {
|
|
10
|
+
title: string;
|
|
11
|
+
steps: TaskStep[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Parse a task markdown file content
|
|
16
|
+
*/
|
|
17
|
+
export function parseTaskFile(content: string): TaskFile {
|
|
18
|
+
const lines = content.split("\n");
|
|
19
|
+
const steps: TaskStep[] = [];
|
|
20
|
+
let title = "";
|
|
21
|
+
|
|
22
|
+
for (const line of lines) {
|
|
23
|
+
const trimmed = line.trim();
|
|
24
|
+
|
|
25
|
+
// Extract title from first non-empty line that starts with ##
|
|
26
|
+
if (!title && trimmed.startsWith("##")) {
|
|
27
|
+
title = trimmed.replace(/^#+\s*/, "").trim();
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Parse task steps (lines starting with - [ ])
|
|
32
|
+
const doneMatch = trimmed.match(/^-\s*\[([ x])\]\s*(.*)/);
|
|
33
|
+
if (doneMatch) {
|
|
34
|
+
const isDone = doneMatch[1] === "x";
|
|
35
|
+
const text = doneMatch[2].trim();
|
|
36
|
+
steps.push({ done: isDone, text });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return { title: title || "Task", steps };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Generate task file content from parsed data
|
|
45
|
+
*/
|
|
46
|
+
export function generateTaskContent(title: string, steps: TaskStep[]): string {
|
|
47
|
+
const lines = [`## ${title}`, ""];
|
|
48
|
+
|
|
49
|
+
for (const step of steps) {
|
|
50
|
+
const checkbox = step.done ? "[x]" : "[ ]";
|
|
51
|
+
lines.push(`- ${checkbox} ${step.text}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return lines.join("\n");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Update a task file with new steps
|
|
59
|
+
*/
|
|
60
|
+
export function updateTaskFile(
|
|
61
|
+
taskPath: string,
|
|
62
|
+
title: string,
|
|
63
|
+
steps: TaskStep[],
|
|
64
|
+
): void {
|
|
65
|
+
const taskDir = path.dirname(taskPath);
|
|
66
|
+
if (!existsSync(taskDir)) {
|
|
67
|
+
mkdirSync(taskDir, { recursive: true });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const content = generateTaskContent(title, steps);
|
|
71
|
+
writeFileSync(taskPath, content, "utf-8");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Load existing task or create new one
|
|
76
|
+
*/
|
|
77
|
+
export function loadOrCreateTask(
|
|
78
|
+
taskPath: string,
|
|
79
|
+
initialTitle: string,
|
|
80
|
+
): TaskFile {
|
|
81
|
+
if (existsSync(taskPath)) {
|
|
82
|
+
const content = readFileSync(taskPath, "utf-8");
|
|
83
|
+
return parseTaskFile(content);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
title: initialTitle,
|
|
88
|
+
steps: [],
|
|
89
|
+
};
|
|
90
|
+
}
|