# All files / src/agent/prompts workspace.ts

30% Statements 3/10
0% Branches 0/4
25% Functions 1/4
30% Lines 3/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34

    8x
    8x

    8x

     /**
     * 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 `\n\n## Workspace Layout\n\nYour working directory is: ${agentCwd}\nThis 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.`;
      }

      const lines = entries.map(
        name => `- \`${name}/\` — ${join(agentCwd, name)}`
      );

      return `\n\n## Workspace Layout

    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')}`;
    }