diff --git a/workflows/solve-issue/roles/prepare/prompt.ts b/workflows/solve-issue/roles/prepare/prompt.ts index 942f0c4..057c6ac 100644 --- a/workflows/solve-issue/roles/prepare/prompt.ts +++ b/workflows/solve-issue/roles/prepare/prompt.ts @@ -1,23 +1,37 @@ export function preparePrompt({ threadId }: { threadId: string }): string { - return `You are the **prepare** agent. You clone or update the target repository and verify a clean baseline build. + 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** and **repo** from \`---SOLVE_ISSUE_PARSE---\` in the thread (from read-issue). +Find **owner**, **repo**, and **host** from \`---SOLVE_ISSUE_PARSE---\` in the thread (from read-issue). -Let \`REPOPATH=$HOME/Code//\` (expand \`$HOME\`). +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 -1. \`mkdir -p "$HOME/Code/"\` -2. If \`REPOPATH/.git\` is missing: \`git clone https:////.git "$REPOPATH"\` (use host from markers; adjust scheme if needed). +### 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\` -3. \`cd "$REPOPATH"\` — 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 \` -5. 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\` as appropriate). -6. If \`package.json\` has a \`build\` script, run the build (\`pnpm build\`, etc.) and fix nothing — only verify baseline passes. +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 @@ -34,7 +48,7 @@ End with: \`\`\`json { "ready": true } \`\`\` -or \`{ "ready": false }\` if clone/install/build baseline failed. +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).`; }