feat: Add new merge strategy option#589
Conversation
|
@TadejPolajnar is attempting to deploy a commit to the Matt Pocock's projects Team on Vercel. A member of the Team first needs to authorize it. |
Phase 1 of the pull-request merge-strategy rollout. Adds the registry, CLI flag/selector, and copyTemplateFiles variant-suffix support without shipping any template variants yet. Existing template output is unchanged on this commit. - Add MergeStrategyEntry registry (merge-to-head, pull-request) - Add --merge-strategy CLI flag and interactive clack selector (skipped for the blank template, which has no merge phase) - copyTemplateFiles now accepts a mergeStrategy and selects between filename-suffixed variants (foo.merge-to-head / foo.pull-request) - Add CLOSES_LINE to BacklogManagerEntry.templateArgs for use by Phase 2 PR-mode templates (Closes #N gated to github-issues) - Defensive guard against malformed variant filenames - 9 new InitService tests + 2 new cli.test.ts tests Spec: ideas/merge-strategy-pull-request.md
Phase 2 of the merge-strategy rollout. Adds the four merging templates'
pull-request variants and the supporting host-side flow.
Per template (simple-loop, sequential-reviewer, parallel-planner,
parallel-planner-with-review):
- Rename existing main.mts -> main.mts.merge-to-head
- Add main.mts.pull-request: host pre-flight (origin, gh >= 2.4, gh
auth, attached HEAD, default-branch resolution), per-issue push, PR
state pre-check via gh pr list, structured-output PR-author agent,
gh pr create on host with shellEscape, no force-push.
- Add pr-prompt.md.pull-request: agent emits <pr-title> + <pr-body>
only; never runs gh or git push.
Templates that resolve issues on the host (simple-loop and
sequential-reviewer):
- Variant-ize prompt.md / implement-prompt.md so the pull-request
variant locks the agent to the host-resolved {{TASK_ID}}, while the
merge-to-head variant retains its agent-picks-the-issue behavior.
- Lock-until-merged loop control: each iteration first lists open
Sandcastle PRs and continues working on the lowest-numbered one
rather than picking a new backlog item.
- Backlog-manager runtime guard: clear error if {{LIST_TASKS_COMMAND}}
returns a non-github-issues shape.
Parallel-planner family:
- main.mts.pull-request overrides planner-emitted branch names with
deterministic 'sandcastle/issue-<id>-<slug>' (slug from issue title).
Supporting changes:
- TEXT_FILE_EXTENSIONS now includes .mts and .ts so PR-mode main.mts
variants pick up the backlog-manager-specific {{LIST_TASKS_COMMAND}}
and {{CLOSES_LINE}} at scaffold time.
Tests (198 passing, +20 from Phase 1):
- Variant selection per template (merge-to-head/pull-request vs
pull-request main.mts content markers).
- pr-prompt.md presence + CLOSES_LINE substitution per backlog manager.
- Variant file pairing invariant catches missing .merge-to-head /
.pull-request partners.
- Dockerfile and .env.example are byte-identical between merge
strategies (proves §4.7 of the spec).
- 16-combo placeholder-leak invariant: caught the .mts substitution
bug above before merge.
Spec: ideas/merge-strategy-pull-request.md
7adb308 to
b5aa654
Compare
|
@TadejPolajnar This is exactly what I was looking for, so I really appreciate that someone is working on it. Can I mention 2 things? It might be worth keeping the timestamp in the log file name, this in case something goes wrong, and you need to retry (API limit or whatever other reason). More importantly, I feel like this removes a rather good feature from the existing Edit: Is it correct that once there is an open PR the loop just kinda stops? Because right now it keeps selecting the same issue over and over and each iteration just says |
Summary
Adds a merge strategy selection to
sandcastle init— a new step in the CLI wizard (between backlog manager and template) that controls what happens to completed branches:originand opens a PR viagh pr createon the hostThe PR-mode flow: host runs pre-flight checks (origin remote,
gh>= 2.4 + auth, attached HEAD), resolves the repo's default branch, then for each completed branch: pushes, invokes a short-lived PR-author agent that emits title/body via structured tags, and runsgh pr createwith shell-escaped args. Re-runs are idempotent (open PRs get updated, closed/merged ones are skipped, force-push is never attempted).What changed
sandcastle initwizard gains a "Select a merge strategy" step (skipped forblanktemplate)--merge-strategyCLI flag for non-interactive use.merge-to-headand.pull-requestvariant filesTest plan
sandcastle init→ simple-loop → Pull Request → github-issues scaffolds correct files with PR-mode markers and no force-push patterns