Skip to content

chore: update README and CHANGELOG with new PR workflow commands#2

Merged
MusicMaster4 merged 3 commits into
testingfrom
feature/automatic-pr
Jul 10, 2026
Merged

chore: update README and CHANGELOG with new PR workflow commands#2
MusicMaster4 merged 3 commits into
testingfrom
feature/automatic-pr

Conversation

@MusicMaster4

Copy link
Copy Markdown
Owner

Summary

  • chore: update README and CHANGELOG with new PR workflow commands

@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR introduces a gg pr / gg cnp pr workflow that commits dirty work, pushes the branch, generates an AI PR title and body via two parallel plain-text model calls, and creates the pull request via gh pr create — with graceful fallback to commit-log text when no API key is set.

  • lib/pr-message.ts (new): encapsulates diff/log context building, OpenRouter and OpenAI Responses API calls, cleanTitle/cleanBody sanitizers, resolveBaseRef/detectDefaultBase helpers, and a runCapture/isGhAvailable wrapper for the gh CLI.
  • scripts/cli.ts: adds case "pr" and extends case "commit" so that cnp pr commits without runSteps (avoiding the previously reported early "done"), then delegates push + PR creation to createPullRequest, printing a single done only on full success.
  • README / CHANGELOG: documentation and changelog accurately reflect the new commands, including the "commit if dirty" step and gh auth requirement.

Confidence Score: 5/5

Safe to merge — changes are additive, the existing commit/push path is unmodified, and the new PR path is well-isolated behind a feature-flag-style argument check.

The new gg pr / cnp pr flow is fully self-contained: it adds a new case pr and guards the PR branch inside if (wantPr) in the existing commit case, leaving the normal commit/push path unchanged. Push deduplication is correct, the single-done UX issue from the previous review is fixed, AI errors fall back gracefully, and tests cover the sanitizer functions.

No files require special attention.

Important Files Changed

Filename Overview
lib/pr-message.ts New module implementing AI PR title/body generation via two parallel model calls (OpenRouter + OpenAI Responses API), with sanitizers, git diff/log context building, gh availability check, and fallbackPrContent when no API key.
scripts/cli.ts Adds case "pr" and extends case "commit" to support cnp pr / commit pr — correctly avoids double push by handling push only inside createPullRequest, and prints a single "done" after the full flow resolving the previously flagged UX bug.
test/pr-message.test.ts New unit tests for cleanTitle and cleanBody — cover quote stripping, first-line extraction, prefix removal, length cap, fence unwrapping, and <think> tag scrubbing; all assertions are correct.
README.md Adds gg cnp pr and gg pr rows to all command tables, updates the -y flag description, and adds a new "How AI pull requests work" section that accurately matches the implementation (including the "commit if dirty" step).
CHANGELOG.md Adds an Unreleased section accurately documenting the new PR workflow commands, AI generation strategy, PR reuse behavior, and the single-done UX fix.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A([gg pr / gg cnp pr]) --> B{Dirty working tree?}
    B -- Yes --> C[git add . + git commit -m AI msg]
    B -- No --> D[Log: nothing to commit]
    C --> E[createPullRequest]
    D --> E
    E --> F{gh available?}
    F -- No --> G([die: install gh + auth])
    F -- Yes --> H[detectDefaultBase]
    H --> I{baseHint provided or -y?}
    I -- Yes --> J[Use hint / defaultBase]
    I -- No --> K[Prompt user for base branch]
    J --> L[git push / push -u origin]
    K --> L
    L --> M[gh pr list --head branch]
    M --> N{Open PR exists?}
    N -- Yes --> O([Print existing PR URL + done])
    N -- No --> P[generatePrContent: 2x parallel AI calls]
    P --> Q[cleanTitle + cleanBody]
    Q --> R[gh pr create --base --head --title --body]
    R --> S([Print new PR URL + done])
    P -- API error / no key --> T[fallbackPrContent from git log]
    T --> R
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A([gg pr / gg cnp pr]) --> B{Dirty working tree?}
    B -- Yes --> C[git add . + git commit -m AI msg]
    B -- No --> D[Log: nothing to commit]
    C --> E[createPullRequest]
    D --> E
    E --> F{gh available?}
    F -- No --> G([die: install gh + auth])
    F -- Yes --> H[detectDefaultBase]
    H --> I{baseHint provided or -y?}
    I -- Yes --> J[Use hint / defaultBase]
    I -- No --> K[Prompt user for base branch]
    J --> L[git push / push -u origin]
    K --> L
    L --> M[gh pr list --head branch]
    M --> N{Open PR exists?}
    N -- Yes --> O([Print existing PR URL + done])
    N -- No --> P[generatePrContent: 2x parallel AI calls]
    P --> Q[cleanTitle + cleanBody]
    Q --> R[gh pr create --base --head --title --body]
    R --> S([Print new PR URL + done])
    P -- API error / no key --> T[fallbackPrContent from git log]
    T --> R
Loading

Reviews (2): Last reviewed commit: "fix: update PR workflow and AI to reuse ..." | Re-trigger Greptile

Comment thread scripts/cli.ts Outdated
Comment thread README.md
@MusicMaster4
MusicMaster4 merged commit e4d7453 into testing Jul 10, 2026
2 checks passed
@MusicMaster4
MusicMaster4 deleted the feature/automatic-pr branch July 10, 2026 12:40
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.

1 participant