refactor: Overhaul shared prompt constants — remove CODEBASE_VERIFICATION, trim GIT_WORKFLOW/CONTEXT_MANAGEMENT, add TEST_INTEGRITY/SESSION_STARTUP/PROGRESS_TRACKING
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* input files, ID generation) are in shared.ts.
|
||||
*/
|
||||
|
||||
export { SIGNAL_FORMAT, INPUT_FILES, ID_GENERATION, CODEBASE_VERIFICATION, CONTEXT_MANAGEMENT, DEVIATION_RULES, GIT_WORKFLOW, buildInterAgentCommunication } from './shared.js';
|
||||
export { SIGNAL_FORMAT, INPUT_FILES, ID_GENERATION, CONTEXT_MANAGEMENT, DEVIATION_RULES, GIT_WORKFLOW, TEST_INTEGRITY, SESSION_STARTUP, PROGRESS_TRACKING, buildInterAgentCommunication } from './shared.js';
|
||||
export { buildExecutePrompt } from './execute.js';
|
||||
export { buildDiscussPrompt } from './discuss.js';
|
||||
export { buildPlanPrompt } from './plan.js';
|
||||
|
||||
@@ -44,17 +44,6 @@ cw id
|
||||
\`\`\`
|
||||
Use the output as the filename (e.g., \`{id}.md\`).`;
|
||||
|
||||
export const CODEBASE_VERIFICATION = `
|
||||
## Codebase Verification
|
||||
|
||||
Treat your training knowledge as hypothesis, not fact. The codebase is the source of truth.
|
||||
|
||||
1. **Read before writing**: Before modifying any file, read it first. Before importing a module, verify it exists and exports what you expect.
|
||||
2. **Follow existing patterns**: Check how similar things are done in the codebase. Match naming conventions, error handling, file organization.
|
||||
3. **Verify imports**: Don't assume a package or module export exists. Check package.json, check the actual export.
|
||||
4. **Check recent changes**: Run \`git log --oneline -10\` and \`git diff HEAD~3 --stat\` to see what's been changing. Don't undo recent work.
|
||||
5. **Test your assumptions**: If you think a function works a certain way, read it. If you think a type has a field, check the definition.`;
|
||||
|
||||
export const DEVIATION_RULES = `
|
||||
## Deviation Decision Tree
|
||||
|
||||
@@ -74,18 +63,53 @@ export const GIT_WORKFLOW = `
|
||||
|
||||
You are working in an isolated git worktree. Other agents may be working in parallel on separate branches.
|
||||
|
||||
- **Commit frequently**: After each logical unit of work (new function, passing test, config change), commit. Each commit is a recovery checkpoint — if context is compacted or something breaks, you can return to the last good state.
|
||||
- **Descriptive messages**: "Add user validation to signup endpoint" not "update code" — other agents and humans read these to understand what changed.
|
||||
- **Stage specific files**: Use \`git add <file>\` not \`git add .\` because \`git add .\` can accidentally include files owned by other agents in shared worktrees.
|
||||
- **Stage specific files**: Use \`git add <file>\` not \`git add .\` — shared worktrees mean \`git add .\` can include files owned by other agents.
|
||||
- **Never force-push**: Other agents may have already inspected or built on top of your branch.
|
||||
- **Check status first**: Run \`git status\` before committing to see what you're about to include.`;
|
||||
|
||||
export const CONTEXT_MANAGEMENT = `
|
||||
## Context Management
|
||||
|
||||
Your context window will be automatically compacted as it approaches its limit, allowing you to continue working from where you left off. Do not stop tasks early due to token budget concerns — commit your progress and keep going. Each commit serves as a recovery checkpoint if context is refreshed.
|
||||
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).`;
|
||||
|
||||
When reading multiple files or running independent commands, execute them in parallel rather than sequentially.`;
|
||||
export const TEST_INTEGRITY = `
|
||||
## Test Integrity Rules
|
||||
|
||||
These rules are non-negotiable. Violating them produces code that appears to work but silently ships bugs.
|
||||
|
||||
1. **Never duplicate implementation logic in test assertions.** If your code uses \`items.reduce((sum, i) => sum + i.price, 0)\`, your test MUST NOT use the same reduce — hardcode the expected value from the requirement instead. Tests that mirror implementation logic prove nothing.
|
||||
2. **Never modify existing test assertions to make them pass.** If a pre-existing test expects X and your code produces Y, the bug is in your code — fix the code. The ONLY exception is when your task explicitly changes the expected behavior.
|
||||
3. **Never skip or disable tests.** No \`it.skip()\`, no \`.todo()\` on existing tests, no commenting out test blocks. If a test is failing and you can't fix it, signal an error.
|
||||
4. **Each test must be independent.** No shared mutable state between test cases. No tests that depend on execution order. Every \`it()\` block must pass when run in isolation.
|
||||
5. **Run the full relevant test suite, not just your new tests.** Your changes may break something elsewhere. Catch regressions before committing.`;
|
||||
|
||||
export const SESSION_STARTUP = `
|
||||
## Session Startup
|
||||
|
||||
Before doing any work, verify your environment:
|
||||
|
||||
1. Run \`pwd\` to confirm you're in the expected working directory
|
||||
2. Run \`git status\` to check for unexpected state (uncommitted changes, wrong branch)
|
||||
3. Run the project's test suite to establish a green baseline — if tests are already failing, signal with status "error" describing what's broken. Do not build on a broken foundation.
|
||||
4. Read \`.cw/input/manifest.json\` and all listed input files to understand your assignment`;
|
||||
|
||||
export const PROGRESS_TRACKING = `
|
||||
## Progress Tracking
|
||||
|
||||
Maintain \`.cw/output/progress.md\` as a running log of your work. Update it 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]
|
||||
\`\`\`
|
||||
|
||||
This file survives context compaction. If your context is refreshed, read this file first to resume where you left off.`;
|
||||
|
||||
export function buildInterAgentCommunication(agentId: string): string {
|
||||
return `
|
||||
|
||||
Reference in New Issue
Block a user