Skip to content

feat: add draft_pr option to project config#53

Open
maxbeizer wants to merge 3 commits intomarcus:mainfrom
maxbeizer:feat/draft-pr-option
Open

feat: add draft_pr option to project config#53
maxbeizer wants to merge 3 commits intomarcus:mainfrom
maxbeizer:feat/draft-pr-option

Conversation

@maxbeizer
Copy link

Summary

Add a draft_pr boolean option to ProjectConfig so all PRs opened by Nightshift for a given project are created as GitHub draft PRs.

This keeps CODEOWNERS out of the loop until the user has reviewed the AI-generated changes and manually converts the PR to ready-for-review.

Config usage

projects:
  - path: ~/code/myproject
    draft_pr: true   # all PRs opened for this project will be drafts

Also adds a --draft flag to nightshift task run for per-run control:

nightshift task run lint-fix --provider claude --draft

Changes

  • internal/config/config.go — Added DraftPR bool field to ProjectConfig and ProjectByPath() helper
  • internal/orchestrator/orchestrator.go — Added DraftPR to RunMetadata, modified buildImplementPrompt() to instruct agents to use gh pr create --draft when enabled
  • cmd/nightshift/commands/run.go — Wire draft_pr from project config into RunMetadata
  • cmd/nightshift/commands/task.go — Add --draft CLI flag, fall back to project config
  • Tests — Added tests for config lookup, draft/non-draft prompt generation

Testing

All existing tests pass. New tests cover:

  • TestProjectByPath — config lookup by path
  • TestBuildImplementPrompt_DraftPR — draft instruction in prompt
  • TestBuildImplementPrompt_NoDraftPR — no draft instruction when disabled
  • TestBuildImplementPrompt_DraftPR_NoMetadata — graceful handling with no metadata

Closes #23

Add a `draft_pr` boolean option to ProjectConfig so all PRs opened
by Nightshift for a given project are created as GitHub draft PRs.

This keeps CODEOWNERS out of the loop until the user has reviewed the
AI-generated changes and manually converts the PR to ready-for-review.

Config usage:
  projects:
    - path: ~/code/myproject
      draft_pr: true

Also adds a --draft flag to `nightshift task run` for per-run control.

Closes marcus#23

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@maxbeizer maxbeizer marked this pull request as draft March 9, 2026 20:13
ProjectByPath now expands both the input path and configured paths,
preventing silent mismatches when one side uses ~ and the other uses
an absolute path.

Added test cases exercising tilde expansion in both directions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@maxbeizer maxbeizer force-pushed the feat/draft-pr-option branch from fb6c47d to ea1f6da Compare March 9, 2026 20:16
@maxbeizer maxbeizer marked this pull request as ready for review March 9, 2026 20:16
taskRunCmd.Flags().Bool("dry-run", false, "Show prompt without executing")
taskRunCmd.Flags().Duration("timeout", 30*time.Minute, "Execution timeout")
taskRunCmd.Flags().StringP("branch", "b", "", "Base branch for new feature branches (defaults to current branch)")
taskRunCmd.Flags().Bool("draft", false, "Open PRs as drafts")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of wonder whether draft should be the default and we invert this 🤔

When gh pr create --draft fails (e.g. repo on a free plan), the agent
now falls back to opening a regular PR with the nightshift/draft label
so the author can still identify AI-generated PRs needing review.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@maxbeizer
Copy link
Author

@marcus i think this is a really cool project 💖 . So I thought I'd fire up a PR (with copilot). Hope you like it.

As noted in #53 (comment) I actually wonder if instead of this, the default behavior should be draft and you have to explicitly enable "ready" PRs. Curious what you think

@marcus
Copy link
Owner

marcus commented Mar 9, 2026

Hey @maxbeizer! Starling here (AI assistant on the project). 👋

First — welcome, and thank you for this burst of work. Four coordinated PRs to flesh out Copilot support end-to-end is a tremendous first contribution:

Each one is cleanly scoped and ships with tests. Really appreciate the care here.

On your question about draft-as-default vs. opt-in: that's a meaningful design decision with real tradeoffs. Draft-by-default is the safer posture for AI-generated PRs (keeps CODEOWNERS quiet until the human reviews), but it's a behavior change for existing users and adds friction for solo projects where draft is just noise. No obvious right answer — surfacing to Marcus to make the call.

I'll do a review pass through the series and be back with notes. ✦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add draft_pr option to project config to always open PRs as draft

2 participants