fix(solve-issue): prepare supports local repo path from trigger prompt
If the trigger prompt specifies a local repo path (--repo /path or absolute path),
prepare validates it instead of cloning to ~/Code/. Enables running solve-issue
on repos outside the default ~/Code directory.
小橘 🍊(NEKO Team)
This commit is contained in:
parent
95df8bc3c2
commit
aef9943746
@ -1,23 +1,37 @@
|
|||||||
export function preparePrompt({ threadId }: { threadId: string }): string {
|
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}\`
|
Read prior messages / thread for issue markers: \`nerve thread show ${threadId}\`
|
||||||
|
|
||||||
## Goal
|
## 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/<owner>/<repo>\` (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
|
## Steps
|
||||||
|
|
||||||
1. \`mkdir -p "$HOME/Code/<owner>"\`
|
### If a local path is provided in the trigger prompt:
|
||||||
2. If \`REPOPATH/.git\` is missing: \`git clone https://<host>/<owner>/<repo>.git "$REPOPATH"\` (use host from markers; adjust scheme if needed).
|
1. Verify \`<path>/.git\` exists — if not, fail with \`ready: false\`
|
||||||
|
2. \`cd "<path>" && 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 <default> && git pull --ff-only\`
|
||||||
|
5. Use this path as REPOPATH
|
||||||
|
|
||||||
|
### If no local path is provided:
|
||||||
|
1. Let \`REPOPATH=$HOME/Code/<owner>/<repo>\` (expand \`$HOME\`)
|
||||||
|
2. \`mkdir -p "$HOME/Code/<owner>"\`
|
||||||
|
3. If \`REPOPATH/.git\` is missing: \`git clone https://<host>/<owner>/<repo>.git "$REPOPATH"\`
|
||||||
Else: \`cd "$REPOPATH" && git fetch --all && git pull --ff-only\`
|
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. 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 <default>\`
|
5. Detect default branch and \`git checkout <default>\`
|
||||||
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.
|
### 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
|
## Required marker block
|
||||||
|
|
||||||
@ -34,7 +48,7 @@ End with:
|
|||||||
\`\`\`json
|
\`\`\`json
|
||||||
{ "ready": true }
|
{ "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).`;
|
**ready=true** only when the repo exists at \`path\`, is clean, dependencies installed, and baseline build succeeded (or no build script).`;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user