/**
 * Shared prompt instructions reused across agent types.
 */

export const SIGNAL_FORMAT = `
## Signal Output

When done, write \`.cw/output/signal.json\` with:
{ "status": "done" }

If you need clarification, write:
{ "status": "questions", "questions": [{ "id": "q1", "question": "Your question" }] }

If you hit an unrecoverable error, write:
{ "status": "error", "error": "Description of what went wrong" }

IMPORTANT: Always write this file as your final action before terminating.`;

export const INPUT_FILES = `
## Input Files

Read \`.cw/input/manifest.json\` first — it lists exactly which input files exist.
Then read the files from \`.cw/input/\`.

### Assignment Files (your work target)
- \`initiative.md\` — Initiative details (frontmatter: id, name, status)
- \`phase.md\` — Phase details (frontmatter: id, name, status; body: description)
- \`task.md\` — Task details (frontmatter: id, name, category, type, priority, status; body: description)
- \`pages/\` — Initiative pages (one file per page; frontmatter: title, parentPageId, sortOrder; body: markdown content)

### Context Files (read-only background)
If \`contextFiles\` is present in the manifest, these provide read-only context about what already exists:
- \`context/phases/\` — Existing phases (frontmatter: id, name, status, dependsOn; body: description)
- \`context/tasks/\` — Existing tasks (frontmatter: id, name, phaseId, parentTaskId, category, type, priority, status; body: description)

Context files are for reference only — do not duplicate or contradict their content in your output.`;

export const ID_GENERATION = `
## ID Generation

When creating new entities (phases, tasks, decisions), generate a unique ID by running:
\`\`\`
cw id
\`\`\`
Use the output as the filename (e.g., \`{id}.md\`).`;

export const INTER_AGENT_COMMUNICATION = `
## Inter-Agent Communication

You are working in a multi-agent parallel environment. Other agents may be working on related tasks simultaneously.

### Your Identity
Read \`.cw/input/manifest.json\` — it contains \`agentId\` and \`agentName\` fields identifying you.

### Listening for Questions
At the START of your session, start a background listener:
\`\`\`bash
cw listen --agent-id <YOUR_AGENT_ID> &
LISTEN_PID=$!
\`\`\`

When the listener prints JSON to stdout, another agent is asking you a question:
\`\`\`json
{ "conversationId": "...", "fromAgentId": "...", "question": "..." }
\`\`\`

Answer it:
\`\`\`bash
cw answer "<your answer>" --conversation-id <conversationId>
\`\`\`

Then restart the listener:
\`\`\`bash
cw listen --agent-id <YOUR_AGENT_ID> &
LISTEN_PID=$!
\`\`\`

### Asking Questions
To ask another agent a question (blocks until answered):
\`\`\`bash
cw ask "What interface does the user service expose?" --from <YOUR_AGENT_ID> --agent-id <TARGET_AGENT_ID>
\`\`\`

You can also target by task or phase:
\`\`\`bash
cw ask "What port does the API run on?" --from <YOUR_AGENT_ID> --task-id <TASK_ID>
cw ask "What schema are you using?" --from <YOUR_AGENT_ID> --phase-id <PHASE_ID>
\`\`\`

### When to Communicate
- You need interface/schema/contract info from another agent's work
- You're about to modify a shared resource and want to coordinate
- You have a dependency on work another agent is doing

### Cleanup
Before writing \`.cw/output/signal.json\`, kill your listener:
\`\`\`bash
kill $LISTEN_PID 2>/dev/null
\`\`\``;
