Skip to content

Omit generated diffs and slim the split-commit prompt - #38

Merged
rafaeelricco merged 4 commits into
mainfrom
rafaeelricco/generated-diffs-and-split-prompt
Sep 1, 2026
Merged

Omit generated diffs and slim the split-commit prompt#38
rafaeelricco merged 4 commits into
mainfrom
rafaeelricco/generated-diffs-and-split-prompt

Conversation

@rafaeelricco

Copy link
Copy Markdown
Owner

What's New

Staged Diff Filtering

  • getStagedDiff returns the source-file patch and a numstat line per generated path (lockfiles, dist/out, snapshots, minified assets) so those bodies never enter the LLM context.
  • Staging only generated files now resolves with that summary instead of failing as "No staged changes found".

Split Commit Prompt

  • getSplitPrompt states the active convention inline instead of slicing the single-message prompt, which had been duplicating {diff} and carrying SMALL/MEDIUM/LARGE instructions into the partition task.

Staged Diff Flow

flowchart TB
    A["getStagedDiff"] --> B["Load worktree root and staged paths"]
    B --> C{"Any staged paths?"}
    C -->|no| D["Reject: No staged changes found"]
    C -->|yes| E["Split generated vs source"]
    E --> F["diff --staged for source paths"]
    E --> G["numstat summary for generated paths"]
    F --> H["Concatenate body + omitted-path note"]
    G --> H
    H --> I["Return staged context"]
Loading

Changed Files

File Change Type Summary
src/infra/git/parsers.ts Modified Classify generated paths and format omitted-path numstat lines.
src/infra/git/repo.ts Modified Build staged context from source diffs plus generated-file summaries.
src/domain/commit/prompts.ts Modified Summarize the message convention in the split prompt instead of embedding the single-message prompt.
test/infra/git/parsers.test.ts Modified Cover generated-path matching and omitted-path formatting.
test/infra/git/repo.integration.test.ts Modified Cover mixed and generated-only staged diffs.
test/domain/commit/prompts.test.ts Modified Cover convention summary and single {diff} interpolation.

Testing & Feedback

Check getStagedDiff with a lockfile staged beside source, and with only a lockfile staged. Confirm the split prompt contains the diff once and does not mention SMALL/MEDIUM/LARGE.

If you find any bugs or have recommendations for improvements, please open an issue and assign it to me.

- Match lockfiles, `dist`/`out`, snapshots, and minified assets as generated paths.
- Return source diffs plus a numstat summary for omitted generated files from `getStagedDiff`.
- Cover matching, omitted-path formatting, and staged-diff omission with unit and integration tests.
- Stop embedding the single-message prompt in `getSplitPrompt`.
- Summarize the active convention and include the diff once, without `{diff}` interpolation from custom templates.
- Assert the split prompt drops SMALL/MEDIUM/LARGE instructions and interpolates the diff once.
@rafaeelricco rafaeelricco self-assigned this Sep 1, 2026
- Default commit generation and refine to the provider's low effort when the config sets none, keeping an explicit effort untouched via `withDefaultMinEffort`.
- Return the static rules and examples from `getPrompt` as a system instruction and send only the diff as the user prompt, so providers can cache the prefix across runs.
- Drop the second copy of the diff from the custom template prompt.
- Mark the last Anthropic system block ephemeral on both the API key and setup-token paths.
- Cover the effort default, the prompt split, and the Anthropic request shape with unit tests.
- Add `generatedOnlyMessage` to build a commit title, and a bullet body for several files, from the staged paths and the active convention.
- Short-circuit `Commit.route` to that local message when every staged path matches `isGeneratedPath`, and say so in the log.
- Thread a `Proposal` with optional request metadata through `interact` and the commit handlers so the local path renders no model lines.
- Cover the local message and the skipped model call with unit tests.
@rafaeelricco

Copy link
Copy Markdown
Owner Author

@codex review

Review this PR at HEAD (71e89a3 and later if pushed).

Majors only (P0/P1): correctness bugs, security issues, data loss, broken
contracts or installs, clear regressions. Confirm whether any remain after the
latest commits.

Ignore completely: P3, nits, style, formatting, wording, optional refactors.
P2 only if it is clearly a real correctness or safety risk — if unsure, skip it.

Since last review:

  • 33e3647 — Omit generated file bodies from staged diffs and name them with churn counts.
  • 3582e67 — Slim the split-commit prompt to a convention summary.
  • d8f6d7e — Default the single-commit path to low effort, move the static prompt into a cacheable system block, and mark the Anthropic system block ephemeral.
  • 71e89a3 — Build the commit message locally when only generated files are staged.

If you find no major issues, say so in a clear line
(e.g. "Didn't find any major issues").

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 71e89a36ce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@rafaeelricco
rafaeelricco merged commit ff0e591 into main Sep 1, 2026
4 checks passed
@rafaeelricco rafaeelricco mentioned this pull request Sep 1, 2026
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