Files
Codewalkers/apps/server/agent/prompts/workspace.ts
Lukas May 28521e1c20 chore: merge main into cw/small-change-flow
Integrates main branch changes (headquarters dashboard, task retry count,
agent prompt persistence, remote sync improvements) with the initiative's
errand agent feature. Both features coexist in the merged result.

Key resolutions:
- Schema: take main's errands table (nullable projectId, no conflictFiles,
  with errandsRelations); migrate to 0035_faulty_human_fly
- Router: keep both errandProcedures and headquartersProcedures
- Errand prompt: take main's simpler version (no question-asking flow)
- Manager: take main's status check (running|idle only, no waiting_for_input)
- Tests: update to match removed conflictFiles field and undefined vs null
2026-03-06 16:48:12 +01:00

43 lines
1.4 KiB
TypeScript

/**
* Workspace layout section describing the agent's working directory.
*/
import { readdirSync } from 'node:fs';
import { join } from 'node:path';
export function buildWorkspaceLayout(agentCwd: string): string {
let entries: string[];
try {
entries = readdirSync(agentCwd, { withFileTypes: true })
.filter(d => d.isDirectory() && d.name !== '.cw')
.map(d => d.name);
} catch {
return '';
}
if (entries.length === 0) {
return `
<workspace>
Your working directory is: ${agentCwd}
This is an isolated git worktree. Other agents may be working in parallel on separate branches — do not assume you have exclusive access to the repository.
</workspace>`;
}
const lines = entries.map(
name => `- \`${name}/\`${join(agentCwd, name)}`
);
return `
<workspace>
Your working directory is: ${agentCwd}
This is an isolated git worktree. Other agents may be working in parallel on separate branches — do not assume you have exclusive access to the repository.
The following project directories contain the source code (git worktrees):
${lines.join('\n')}
**IMPORTANT**: All \`.cw/output/\` paths (signal.json, progress.md, etc.) are relative to this working directory (\`${agentCwd}\`), NOT to any project subdirectory. Always write to \`${join(agentCwd, '.cw/output/')}\` regardless of your current \`cd\` location.
</workspace>`;
}