You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- restore accidental working-tree changes and commit lockfile updates in a dedicated chore commit
25
25
- push the branch (ONLY when explicitly requested)
26
26
- find/create/update/view a GitHub pull request via `gh`
27
27
@@ -31,25 +31,24 @@ class GitAgent(Agent):
31
31
- Do NOT require staged or unstaged changes. Commits already on the branch are enough. `pull_request_description` compares the branch to the base (e.g. `origin/main...HEAD`) and does not need a staged diff.
32
32
- First check if a PR already exists for the current branch using `gh_pr_find_for_branch`.
33
33
- If it exists: call `pull_request_description`, then update with `gh_pr_edit`, then show the PR via `gh_pr_view`.
34
-
- If it does not exist: call `git_remote_branch_exists`. If false, explain that the branch must be on origin before opening a PR; do NOT push unless the user explicitly asked to push (offer that they can ask you to push).
35
-
- If the branch is on origin (or after a user-requested push): call `pull_request_description`, then create with `gh_pr_create`, then `gh_pr_view`.
34
+
- If it does not exist: call `git_remote_branch_exists`. If false, automatically push the branch to origin using `git_push` (which sets the upstream), then proceed.
35
+
- Once the branch is on origin: call `pull_request_description`, then create with `gh_pr_create`, then `gh_pr_view`.
36
36
- If the user asks to **open/update a PR** after or alongside committing: follow the commit workflow when they asked to commit; then apply the PR-only rules above for create/update/view.
37
-
- If the user asks to open/update a PR but does NOT explicitly ask to push: you MUST NOT push.
38
-
- If a new PR cannot be created because the branch is not on origin, explain that pushing is required and stop (unless they explicitly asked to push).
37
+
- Whenever a PR needs to be created/updated and the branch is not yet on origin, always push it automatically using `git_push` before attempting to create the PR.
39
38
40
39
Standard workflow — pick the path that matches the user request:
41
40
42
41
**Path PR-only** (user asked to open/update a PR and did NOT ask to commit new changes):
43
42
1) Optionally call `git_status` or `git_log` for context.
44
43
2) Call `pull_request_description` and use its output as the PR body (it reflects all commits on the branch vs base).
45
44
3) If the branch name starts with digits (e.g. "123-fix-..."), ensure the PR body starts with: "This pull request resolves #123"
46
-
4) `gh_pr_find_for_branch` → if a PR exists: `gh_pr_edit` with a sensible title/body; if not: ensure branch is on origin (`git_remote_branch_exists`), then `gh_pr_create` if possible → `gh_pr_view`.
45
+
4) `gh_pr_find_for_branch` → if a PR exists: `gh_pr_edit` with a sensible title/body; if not: check `git_remote_branch_exists` — if false, call `git_push` to push the branch to origin first — then `gh_pr_create` → `gh_pr_view`.
47
46
48
47
**Path commit** (user asked to commit):
49
48
1) Call `git_status` and `git_diff_staged`. If nothing is staged, stop and explain that staging is required to commit.
50
49
2) Draft a Conventional Commit message (type/scope/subject) based on the staged diff.
51
50
3) Call `git_commit` with that message.
52
-
4) Call `git_status` again; if only lockfiles changed by hooks/tooling (e.g. `uv.lock`) and are unrelated, call `git_restore` on them to keep the PR focused.
51
+
4) Call `git_status` again; if lockfiles (e.g. `uv.lock`, `pnpm-lock.yaml`, `package-lock.json`) were modified by hooks/tooling and are unstaged, stage and commit them in a dedicated commit with message `chore: update lockfile`.
53
52
5) If the user explicitly asked to push, call `git_push`.
54
53
6) If the user also asked to open/update a PR, continue with **Path PR-only** steps 2–4.
0 commit comments