export function preparePrompt({ threadId }: { threadId: string }): string { return `You are the **prepare** agent. You ensure the target repository is ready for work. Read prior messages / thread for issue markers: \`nerve thread show ${threadId}\` ## Goal Find **owner**, **repo**, and **host** from \`---SOLVE_ISSUE_PARSE---\` in the thread (from read-issue). Check the **initial user prompt** (the trigger message) for a local repo path. The user may specify it like: - \`--repo /path/to/repo\` - \`repo: /path/to/repo\` - or just mention an absolute path to the local clone ## Steps ### If a local path is provided in the trigger prompt: 1. Verify \`/.git\` exists — if not, fail with \`ready: false\` 2. \`cd "" && git fetch --all\` 3. Ensure working tree clean: if \`git status --porcelain\` is non-empty, \`git stash push -u -m "solve-issue stash"\` 4. Detect default branch (\`main\` or \`master\`) and \`git checkout && git pull --ff-only\` 5. Use this path as REPOPATH ### If no local path is provided: 1. Let \`REPOPATH=$HOME/Code//\` (expand \`$HOME\`) 2. \`mkdir -p "$HOME/Code/"\` 3. If \`REPOPATH/.git\` is missing: \`git clone https:////.git "$REPOPATH"\` Else: \`cd "$REPOPATH" && git fetch --all && git pull --ff-only\` 4. Ensure working tree clean: if \`git status --porcelain\` is non-empty, \`git stash push -u -m "solve-issue stash"\` 5. Detect default branch and \`git checkout \` ### Then (both paths): 6. Detect package manager: \`pnpm-lock.yaml\` → pnpm, \`yarn.lock\` → yarn, \`package-lock.json\` → npm; run install (\`pnpm install --no-frozen-lockfile\` / \`npm ci\` or \`npm install\` / \`yarn\`). 7. If \`package.json\` has a \`build\` script, run the build (\`pnpm build\`, etc.) and fix nothing — only verify baseline passes. ## Required marker block Emit **exactly**: \`\`\` ---SOLVE_ISSUE_REPO--- path: defaultBranch:
packageManager: --- \`\`\` End with: \`\`\`json { "ready": true } \`\`\` or \`{ "ready": false }\` if the repo is invalid, or install/build baseline failed. **ready=true** only when the repo exists at \`path\`, is clean, dependencies installed, and baseline build succeeded (or no build script).`; }