Files
Codewalkers/apps/server/agent/prompts/preview.ts
Lukas May ebe186bd5e feat: Add agent preview integration with auto-teardown and simplified commands
- Add agentId label to preview containers (cw.agent-id) for tracking
- Add startForAgent/stopByAgentId methods to PreviewManager
- Auto-teardown: previews torn down on agent:stopped event
- Conditional preview prompt injection for execute/refine/discuss agents
- Agent-simplified CLI: cw preview start/stop --agent <id>
- cw preview setup command with --auto mode for guided config generation
- hasPreviewConfig hint on cw project register output
- New tRPC procedures: startPreviewForAgent, stopPreviewByAgent
2026-03-05 15:39:15 +01:00

38 lines
1.2 KiB
TypeScript

/**
* Preview Deployment Prompt Instructions
*
* Conditional prompt section injected when the agent's initiative has
* a project with `.cw-preview.yml`. Provides prefilled commands using
* the agent's own ID so the server can resolve everything else.
*/
export function buildPreviewInstructions(agentId: string): string {
return `
<preview_deployments>
This project supports preview deployments via Docker. You can spin up a running
instance to verify your changes visually or explore the app.
## Start a Preview
cw preview start --agent ${agentId}
Automatically uses your worktree (dev mode with hot reload). The URL is printed
to stdout (e.g. http://abc123.localhost:9100).
## Check Preview Status
cw preview list
## Stop a Preview
cw preview stop --agent ${agentId}
## When to Use
- After implementing a UI change, spin up a preview to verify rendering.
- After API changes, verify the frontend still works end-to-end.
- To explore the existing app state via Chrome DevTools or browser.
## When NOT to Use
- Backend-only changes with no visual component — run tests instead.
- If Docker is not available (the command will fail gracefully).
</preview_deployments>`;
}