Skip to content

bug: get-pr-context.ps1 resolves REPO_ROOT incorrectly (off by one directory level) #5

@markhazleton

Description

@markhazleton

Bug Description

get-pr-context.ps1 resolves $repoRoot by navigating two levels up from the script directory, but the script lives three levels deep under the repo root (.documentation/scripts/powershell/). This causes REPO_ROOT to resolve to .documentation/ instead of the actual workspace root.

Impact

All paths derived from $repoRoot are incorrect:

Field Expected Actual (broken)
REPO_ROOT C:\myrepo C:\myrepo\.documentation
CONSTITUTION_PATH C:\myrepo\.documentation\memory\constitution.md C:\myrepo\.documentation\.documentation\memory\constitution.md
REVIEW_DIR C:\myrepo\.documentation\specs\pr-review C:\myrepo\.documentation\.documentation\specs\pr-review
CONSTITUTION_EXISTS true false (path doesn't exist)

This causes pr-review to report the constitution as missing even when it exists, and the review output directory is wrong.

Root Cause

Line 38 of get-pr-context.ps1:

$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
$repoRoot = (Resolve-Path "$scriptPath\..\..")   # Only goes up 2 levels

The script is at .documentation/scripts/powershell/get-pr-context.ps1 — that's 3 levels below the repo root:

repo-root/                          # level 0 (target)
  .documentation/                   # level 1
    scripts/                        # level 2
      powershell/                   # level 3 ($scriptPath)
        get-pr-context.ps1

../.. from powershell/ lands at .documentation/ (level 1), not the repo root (level 0).

Fix

Change to three levels up:

$repoRoot = (Resolve-Path "$scriptPath\..\..\..")

Confirm that all scripts do not have this problem.

Steps to Reproduce

  1. Run /speckit.pr-review on any repo with the standard .documentation/ layout
  2. Observe the JSON output: REPO_ROOT points to .documentation/ and CONSTITUTION_EXISTS is false

Environment

  • PowerShell 7+
  • Windows (also affects macOS/Linux with forward-slash paths)
  • Discovered during PR review on markhazleton/sql2csv#9

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions