Skip to content

fix(skills): pr-reference readers return empty or wrong results for generate.ps1 output and undercount diff lines #3149

Open
CMKIXVI/hve-core
#2

Description

Component

Skills

Bug Description

The pr-reference skill's PowerShell toolchain gives empty or wrong results. Some of these defects are shared with the Bash twin. They came up while reviewing #3140 (which fixes #3131) and are pre-existing, not introduced by that PR.

  1. generate.ps1 output can't be read by either reader. Get-PrXmlContent in generate.ps1 prefixes every diff line with two spaces ($DiffOutput | ForEach-Object { " $_" }). generate.sh writes raw git diff output. Every reader anchors on column 0 (^diff --git, ^\+[^+], ^-[^-]), so on PowerShell-generated XML:

    • read-diff.ps1 -Summary and read-diff.sh --summary print only Changed files:.
    • read-diff.ps1 -File <path> warns No diff found for file for a file that is in the diff (read-diff.sh --file is anchored the same way).
  2. list-changed-files.ps1 lists files that weren't changed. Its unanchored regex diff --git a/(.+?) b/(.+?)(?=\n) also matches the text diff --git inside diff content. On fix(skills): count per-file changes in read-diff.sh summary mode #3140's own diff it emitted 6 bogus entries such as docs/guide.md -> docs/guide.md' and ${file} -> " "${INPUT_FILE}" | grep -m 1 ....

  3. Both twins undercount added and removed lines. ^\+[^+] and ^-[^-] (in Get-DiffSummary and the awk in read-diff.sh) skip:

    • blank added or removed lines (+ or - alone),
    • added lines whose content starts with +,
    • removed lines whose content starts with -. That includes every removed Markdown - bullet, YAML list item, SQL -- comment, and --- front matter.

    Example: a hunk with 2 real additions and 2 real removals reports +1/-0. fix(skills): count per-file changes in read-diff.sh summary mode #3140's own test file reports +48 against 53 real additions.

  4. Header parsing errors in both twins.

    • When git quotes a path (non-ASCII, or containing tab, quote, or backslash), as in diff --git "a/caf\303\251.txt" "b/caf\303\251.txt", the header isn't recognized. The file is dropped, or its hunks are counted toward the previous file.
    • A path containing b/ (diff --git a/x b/y.txt b/x b/y.txt) is reported as x.
  5. Sort order isn't deterministic across hosts. Get-DiffSummary uses culture-aware Sort-Object Path, so the order depends on the host and the invariant-globalization setting. It can't match the Bash LC_ALL=C sort -f order byte for byte; _, -, and non-ASCII paths come out in different orders.

Expected Behavior

  • PowerShell-generated and Bash-generated pr-reference.xml files can be read the same way by both read-diff and list-changed-files implementations. Either generate.ps1 stops indenting the <full_diff> block (matching generate.sh), or the readers accept the indented form.
  • list-changed-files reports only real file headers.
  • Per-file counts match git diff --numstat. The counter should know about hunks: inside a file block, count every + or - line after the first @@.
  • Quoted paths and paths containing b/ resolve correctly. One way is to take the path from the +++ b/ or --- a/ line, or to pass -c core.quotePath=false from the generators.
  • Both twins use the same deterministic sort: ordinal, case-insensitive, on the path key only.
  • Parity tests cover all of the above, including a generate.ps1-format fixture.

Steps to Reproduce

  1. On Windows, from any feature branch, run .github/skills/shared/pr-reference/scripts/generate.ps1 -BaseBranch main -MergeBase.

  2. Run .github/skills/shared/pr-reference/scripts/read-diff.ps1 -Summary. The output is only Changed files:.

  3. Run read-diff.ps1 -File <a changed path>. It prints WARNING: No diff found for file: ....

  4. Run list-changed-files.ps1 -Format Plain on a branch whose diff contains the text diff --git (for example, a branch that edits read-diff.sh). Extra non-file entries appear.

  5. For the undercount, feed either reader this diff:

    diff --git a/q.sql b/q.sql
    --- a/q.sql
    +++ b/q.sql
    @@ -1,2 +1,2 @@
    --- comment
    -- sql
    +++counter
    +x
    

    Both report q.sql (+1/-0) instead of +2/-2.

Additional Context

Activity

  1. added
    bug
    needs-triage
    on Oct 6, 2026
  2. removed
    needs-triage
    on Oct 6, 2026
  3. github-actions commented on Oct 6, 2026

    @github-actions
    Contributor

    Thanks for the detailed report. It's triaged as a bug in skills and scripts, with testing for the parity tests, at priority-2 because it can silently hide the change surface from reviews on Windows.

    This is related to #3131, which is open. #3140 is its fix and shares the counting logic. The fix for item 3 may overlap with that work, so it's worth coordinating.

    I didn't mark this agent-ready. It bundles several defects and needs a design choice: stop indenting in generate.ps1, or have the readers accept indented input.

    Generated by Issue Triage for #3149 · auto · 15.4 AIC · ⌖ 3.15 AIC · ⊞ 13.7K · ◷

  4. added
    priority-2
    scripts
    skills
    testing
    on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority-2scriptsskillstesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions