Move src/ → apps/server/ and packages/web/ → apps/web/ to adopt standard monorepo conventions (apps/ for runnable apps, packages/ for reusable libraries). Update all config files, shared package imports, test fixtures, and documentation to reflect new paths. Key fixes: - Update workspace config to ["apps/*", "packages/*"] - Update tsconfig.json rootDir/include for apps/server/ - Add apps/web/** to vitest exclude list - Update drizzle.config.ts schema path - Fix ensure-schema.ts migration path detection (3 levels up in dev, 2 levels up in dist) - Fix tests/integration/cli-server.test.ts import paths - Update packages/shared imports to apps/server/ paths - Update all docs/ files with new paths
125 lines
5.0 KiB
TypeScript
125 lines
5.0 KiB
TypeScript
/**
|
|
* Shared prompt instructions reused across agent types.
|
|
* Each constant is wrapped in a descriptive XML tag for unambiguous
|
|
* first-order / second-order delimiter separation per Anthropic best practices.
|
|
*/
|
|
|
|
export const SIGNAL_FORMAT = `
|
|
<signal_format>
|
|
As your final action, write \`.cw/output/signal.json\`:
|
|
- Done: \`{ "status": "done" }\`
|
|
- Need clarification: \`{ "status": "questions", "questions": [{ "id": "q1", "question": "..." }] }\`
|
|
- Unrecoverable error: \`{ "status": "error", "error": "..." }\`
|
|
</signal_format>`;
|
|
|
|
export const INPUT_FILES = `
|
|
<input_files>
|
|
Read \`.cw/input/manifest.json\` first, then read listed files from \`.cw/input/\`.
|
|
|
|
**Assignment Files**
|
|
- \`initiative.md\` — frontmatter: id, name, status
|
|
- \`phase.md\` — frontmatter: id, name, status; body: description
|
|
- \`task.md\` — frontmatter: id, name, category, type, priority, status; body: description
|
|
- \`pages/\` — one per page; frontmatter: title, parentPageId, sortOrder; body: markdown
|
|
|
|
**Context Files (read-only)**
|
|
Present when \`contextFiles\` exists in manifest:
|
|
- \`context/phases/\` — frontmatter: id, name, status, dependsOn; body: description
|
|
- \`context/tasks/\` — frontmatter: id, name, phaseId, parentTaskId, category, type, priority, status; body: description
|
|
|
|
Do not duplicate or contradict context file content in your output.
|
|
</input_files>`;
|
|
|
|
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\`).
|
|
</id_generation>`;
|
|
|
|
export const DEVIATION_RULES = `
|
|
<deviation_rules>
|
|
1. **Typo in assigned files** → Fix silently
|
|
2. **Bug in files you're modifying** → Fix if < 10 lines, otherwise note and move on
|
|
3. **Missing dependency** → Check context files for another agent's work; \`cw ask\` if yes, create if within scope
|
|
4. **Architectural mismatch** → STOP. Signal "questions" with what you found vs. what the task assumes
|
|
5. **Ambiguous requirement** → STOP. Signal "questions" with the ambiguity and 2-3 concrete options
|
|
6. **Task wrong or impossible** → STOP. Signal "error" explaining why
|
|
|
|
Never silently reinterpret a task.
|
|
</deviation_rules>`;
|
|
|
|
export const GIT_WORKFLOW = `
|
|
<git_workflow>
|
|
You are in an isolated git worktree. Other agents work in parallel on separate branches.
|
|
|
|
- Stage specific files with \`git add <file>\`, not \`git add .\`
|
|
- Never force-push
|
|
- Run \`git status\` before committing
|
|
</git_workflow>`;
|
|
|
|
export const CONTEXT_MANAGEMENT = `
|
|
<context_management>
|
|
When reading multiple files or running independent commands, execute them in parallel rather than sequentially. After each commit, update your progress file (see Progress Tracking).
|
|
</context_management>`;
|
|
|
|
export const TEST_INTEGRITY = `
|
|
<test_integrity>
|
|
1. **Never mirror implementation logic in assertions.** Hardcode expected values from requirements, don't recalculate them.
|
|
2. **Never modify existing test assertions to make them pass.** If a test expects X and your code produces Y, fix your code. Exception: your task explicitly changes expected behavior.
|
|
3. **Never skip or disable tests.** No \`it.skip()\`, \`.todo()\`, or commenting out. If unfixable, signal error.
|
|
4. **Each test must be independent.** No shared mutable state, no order dependence.
|
|
5. **Run the full relevant test suite**, not just your new tests.
|
|
</test_integrity>`;
|
|
|
|
export const SESSION_STARTUP = `
|
|
<session_startup>
|
|
1. \`pwd\` — confirm working directory
|
|
2. \`git status\` — check for unexpected state
|
|
3. Run test suite — establish green baseline. If already failing, signal "error". Don't build on a broken foundation.
|
|
4. Read \`.cw/input/manifest.json\` and all listed input files
|
|
</session_startup>`;
|
|
|
|
export const PROGRESS_TRACKING = `
|
|
<progress_tracking>
|
|
Update \`.cw/output/progress.md\` after each commit:
|
|
|
|
\`\`\`markdown
|
|
## Current Status
|
|
[What you just completed]
|
|
|
|
## Next Steps
|
|
[What you're working on next]
|
|
|
|
## Blockers
|
|
[Any issues or questions — empty if none]
|
|
\`\`\`
|
|
|
|
Survives context compaction — read this first if your context is refreshed.
|
|
</progress_tracking>`;
|
|
|
|
export function buildInterAgentCommunication(agentId: string): string {
|
|
return `
|
|
<inter_agent_communication>
|
|
Your agent ID: **${agentId}**
|
|
|
|
**CLI Commands**
|
|
|
|
- \`cw listen --agent-id ${agentId}\` — Waits for incoming question. Prints JSON (\`{ conversationId, fromAgentId, question, phaseId, taskId }\`) and exits.
|
|
- \`cw ask "<question>" --from ${agentId} --agent-id <TARGET>\` — Blocks until answered. Target with one of: \`--agent-id <id>\`, \`--task-id <id>\`, \`--phase-id <id>\`.
|
|
- \`cw answer "<answer>" --conversation-id <ID>\` — Answer a pending question.
|
|
|
|
**Usage Pattern**
|
|
|
|
Run \`cw listen > "$file" &\` at session start. Check periodically. On question: answer, restart listener. Before signal.json: kill listener, clean up.
|
|
|
|
**When to Communicate**
|
|
- Need interface/schema/API contract info from another agent
|
|
- About to modify a shared resource
|
|
- Have a dependency on another agent's work
|
|
- Don't ask questions you can answer by reading the codebase
|
|
</inter_agent_communication>`;
|
|
}
|