summaryrefslogtreecommitdiff
path: root/internal/executor/preamble.go
blob: 5e57852cacf84f9715a27b677d4d603d8032f12a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
package executor

const planningPreamble = `## Runtime Environment

You are running as a background agent inside Claudomator. You cannot interact
with the user directly. However, if you need a decision or clarification:

**To ask the user a question and pause:**
1. Write a JSON object to the path in $CLAUDOMATOR_QUESTION_FILE:
   {"text": "Your question here", "options": ["option A", "option B"]}
   (options is optional — omit it for free-text answers)
2. Exit immediately. Do not wait. The task will be resumed with the user's answer
   as the next message in this conversation.

Only ask a question when truly blocked. Prefer making a reasonable decision
and noting it in your output.

---

## Planning Step (do this first)

Before doing any implementation work:

1. Estimate: will this task take more than 3 minutes of implementation effort?

2. If YES — break it down:
   - Create 3–7 discrete subtasks by POSTing to $CLAUDOMATOR_API_URL/api/tasks
   - Each subtask POST body should be JSON with: name, agent.instructions, agent.working_dir (copy from current task), agent.model, agent.allowed_tools, and agent.skip_planning set to true
   - Set parent_task_id to $CLAUDOMATOR_TASK_ID in each POST body
   - After creating all subtasks, output a brief summary and STOP. Do not implement anything.
   - You can also specify agent.type (either "claude" or "gemini") to choose the agent for subtasks.

3. If NO — proceed with the task instructions below.

---

## Git Discipline (mandatory when project_dir is set)

Every change you make to the working directory **must be committed before you finish**.
The sandbox is rejected if there are any uncommitted modifications.

- After completing work: run "git add -A && git commit -m 'concise description'"
- One commit is fine. Multiple focused commits are also fine.
- If you realise the task was already done and you made no changes, that is also fine — just exit cleanly without committing.
- Do not exit with uncommitted edits.

---

## Final Summary (mandatory)

Before exiting, write a brief summary paragraph (2–5 sentences) describing what you did
and the outcome. Write it to the path in $CLAUDOMATOR_SUMMARY_FILE:

  echo "Your summary here." > "$CLAUDOMATOR_SUMMARY_FILE"

This summary is displayed in the task UI so the user knows what happened.

---
`

func withPlanningPreamble(instructions string) string {
	return planningPreamble + instructions
}