Skip to content

fix: stabilize Windows config and install regressions#2392

Closed
dlr-1337 wants to merge 1 commit intogsd-build:mainfrom
dlr-1337:codex/stabilize-regressions
Closed

fix: stabilize Windows config and install regressions#2392
dlr-1337 wants to merge 1 commit intogsd-build:mainfrom
dlr-1337:codex/stabilize-regressions

Conversation

@dlr-1337
Copy link
Copy Markdown

@dlr-1337 dlr-1337 commented Apr 18, 2026

Summary

  • honor HOME/GSD_HOME/USERPROFILE for config and skill-manifest resolution
  • normalize Windows path handling for config-path, prompt-injection allowlists, and worktree pruning
  • harden installer hook reads/copies against transient Windows file locks and fix Windows-local install test teardown
  • normalize CRLF-sensitive tests so the suite is stable on Windows clones

Verification

  • node --test tests/config.test.cjs
  • node --test tests/skill-manifest.test.cjs
  • node --test tests/prompt-injection-scan.test.cjs
  • node --test tests/prune-orphaned-worktrees.test.cjs
  • node --test tests/few-shot-calibration.test.cjs
  • node --test tests/bug-1736-local-install-commands.test.cjs
  • node --test tests/bug-2248-local-install-statusline.test.cjs
  • node --test tests/bug-2136-sh-hook-version.test.cjs
  • npm test

Summary by CodeRabbit

  • Bug Fixes
    • Hook and template installation now automatically retries on transient filesystem read/copy errors, improving installation robustness
    • Enhanced cross-platform support with normalized path handling and consistent line ending management
    • Strengthened test suite stability through improved working directory cleanup and restoration between test runs

@dlr-1337 dlr-1337 requested a review from glittercowboy as a code owner April 18, 2026 02:54
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 18, 2026

📝 Walkthrough

Walkthrough

Introduces transient filesystem read retry logic with exponential backoff, centralizes home directory resolution across configuration modules, improves cross-platform path normalization, and ensures consistent test cleanup and working directory restoration.

Changes

Cohort / File(s) Summary
Filesystem Resilience
bin/install.js
Added transient error detection (EBUSY, EPERM, EACCES) and retry helpers with synchronous backoff sleep. Wrapped hook template installations and file copies in bounded retry loops (6 attempts default) for readFileWithRetry() and copyFileWithRetry().
Home Directory Resolution Centralization
get-shit-done/bin/lib/core.cjs, get-shit-done/bin/lib/config.cjs, get-shit-done/bin/lib/init.cjs
Introduced centralized resolveHomeDir() function checking GSD_HOME, HOME, USERPROFILE, and os.homedir() fallback. Replaced direct os.homedir() calls across config and init modules. Added parallelization normalization logic in buildNewProjectConfig() and POSIX path conversion in cmdConfigPath().
Cross-Platform Path Normalization
get-shit-done/bin/lib/core.cjs
Introduced normalizeComparablePath() for platform-agnostic path comparison with case-folding on Windows. Updated pruneOrphanedWorktrees() to use normalized paths, preventing removal logic failures from path casing/normalization differences.
Test Suite Cleanup
tests/bug-1736-local-install-commands.test.cjs, tests/bug-2248-local-install-statusline.test.cjs
Centralized working directory restoration by capturing initial SUITE_CWD and restoring it in afterEach hook, ensuring consistent cleanup across all tests.
Test Line-Ending Normalization
tests/bug-2136-sh-hook-version.test.cjs, tests/few-shot-calibration.test.cjs
Added UTF-8 readers that normalize Windows CRLF line endings to LF for platform-consistent assertions and content parsing.
Test Path Normalization
tests/prompt-injection-scan.test.cjs, tests/prune-orphaned-worktrees.test.cjs
Introduced path normalization helpers converting backslashes to forward slashes for consistent allowlist checks and file reporting across platforms.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

needs-maintainer-review, size/XL

Suggested reviewers

  • glittercowboy

Poem

🐰 A rabbit hops through code so fine,
Retries bounce when errors align,
Paths normalized, left and right,
Home directories set just right,
Tests now clean and tests run bright! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description provided is a summary of changes but does not follow the required typed template structure (fix/enhancement/feature). The template mandates using a specific template file, not a custom summary. Use the correct fix template (PULL_REQUEST_TEMPLATE/fix.md) that matches this PR type, and ensure the description follows its required structure and sections.
Docstring Coverage ⚠️ Warning Docstring coverage is 45.83% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: fixing Windows config and install regressions. It is specific, concise, and directly related to the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
bin/install.js (1)

5848-5868: ⚠️ Potential issue | 🟠 Major

Retry the destination writes as well.

The new wrapper only protects reading/copying the source file. Both the .js and .sh branches still do a single fs.writeFileSync(destFile, content), so a transient lock on an existing hook can still abort the install on Windows.

Proposed fix
+function writeFileUtf8WithRetry(filePath, content) {
+  return withFsRetry(() => fs.writeFileSync(filePath, content, 'utf8'));
+}
+
 // ...
-            fs.writeFileSync(destFile, content);
+            writeFileUtf8WithRetry(destFile, content);
             // Ensure hook files are executable (fixes `#1162` — missing +x permission)
             try { fs.chmodSync(destFile, 0o755); } catch (e) { /* Windows doesn't support chmod */ }
           } else {
             // .sh hooks carry a gsd-hook-version header so gsd-check-update.js can
             // detect staleness after updates — stamp the version just like .js hooks.
             if (entry.endsWith('.sh')) {
               let content = readFileUtf8WithRetry(srcFile);
               content = content.replace(/\{\{GSD_VERSION\}\}/g, pkg.version);
-              fs.writeFileSync(destFile, content);
+              writeFileUtf8WithRetry(destFile, content);
               try { fs.chmodSync(destFile, 0o755); } catch (e) { /* Windows doesn't support chmod */ }
             } else {
               copyFileWithRetry(srcFile, destFile);
             }
           }

Also applies to: 5973-5986

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/install.js` around lines 5848 - 5868, The writes to destination files use
a single fs.writeFileSync(destFile, content) and can fail on transient Windows
locks; add a retry wrapper (or reuse the existing copyFileWithRetry pattern) and
replace the direct fs.writeFileSync calls in both the .js branch (where content
is modified for .claude/.qwen and GSD_VERSION) and the .sh branch
(entry.endsWith('.sh')) with a writeFileWithRetry(destFile, content) that
retries on failure a few times before throwing; keep the existing chmodSync
try/catch behavior and apply the same change to the other occurrence noted
around the 5973-5986 range so all destination writes are retried.
🧹 Nitpick comments (1)
get-shit-done/bin/lib/config.cjs (1)

214-220: Consider accepting string booleans in parallelization normalization.

Line 214-220 currently treats non-boolean/non-object as invalid and falls back to defaults. Legacy/manual configs with "true"/"false" get ignored.

♻️ Suggested patch
   if (typeof config.parallelization !== 'boolean') {
     if (config.parallelization && typeof config.parallelization === 'object' && 'enabled' in config.parallelization) {
       config.parallelization = !!config.parallelization.enabled;
+    } else if (typeof config.parallelization === 'string') {
+      const v = config.parallelization.trim().toLowerCase();
+      if (v === 'true') config.parallelization = true;
+      else if (v === 'false') config.parallelization = false;
+      else config.parallelization = hardcoded.parallelization;
     } else {
       config.parallelization = hardcoded.parallelization;
     }
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@get-shit-done/bin/lib/config.cjs` around lines 214 - 220, The normalization
for config.parallelization currently only accepts booleans or objects; update
the branch that handles non-boolean values to also accept string booleans by
checking if typeof config.parallelization === 'string' and converting
"true"/"false" (case-insensitive) to the corresponding boolean before falling
back to the existing object check or hardcoded.parallelization. Keep the
existing object-path that looks for a .enabled property and ensure the new
string parsing runs before defaulting to hardcoded.parallelization so legacy
configs like "true"/"false" are honored.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@get-shit-done/bin/lib/core.cjs`:
- Line 100: The comparison parent === homedir is brittle because env-provided
home paths can differ by separators, trailing slashes or case; normalize both
sides before comparing by using path utilities: call path.resolve() and
path.normalize() on resolveHomeDir() and on the parent value, strip any trailing
path.sep, and on Windows compare using .toLowerCase() to be case-insensitive;
then replace the raw equality check in the code that references homedir with the
normalized/resolved comparison (use resolveHomeDir(), homedir variable, and the
parent variable names to locate and update the logic).

In `@get-shit-done/bin/lib/init.cjs`:
- Around line 1772-1773: The dedupe uses the raw skill `name`, so variants like
"MySkill" and " myskill " bypass it; normalize `name` before checking/adding to
`seenSkillNames` (e.g., compute a `normalized` value via trim() and
toLowerCase(), guard against null/undefined names), then use
`seenSkillNames.has(normalized)` and `seenSkillNames.add(normalized)` instead of
using the raw `name` so case/whitespace variants are treated as duplicates.

In `@tests/prompt-injection-scan.test.cjs`:
- Around line 63-65: The allowlist helper toAllowlistPath currently returns a
normalized relative path but the scan bucket logic still checks raw absolute
paths (e.g., conditions like f.includes('/agents/')), so on Windows those checks
never match; update the scan logic to use the normalized relative path returned
by toAllowlistPath for both allowlist membership and bucket selection instead of
the raw file path — locate uses of f.includes('/agents/') (and similar bucket
checks) and replace them to operate on the normalized path produced by
toAllowlistPath.

In `@tests/prune-orphaned-worktrees.test.cjs`:
- Line 152: The assertions normalize path separators but not case, causing
Windows flakes; update the normalization to also normalize case by applying a
consistent case conversion (e.g., toLowerCase()) after replacing backslashes
with slashes for the variables like normalizedWorktreeDir (and the analogous
normalized... variables used around lines where you replace /\\/g with '/'), so
that comparisons use the same lowercase path form on Windows; ensure every place
that does worktreeDir.replace(/\\/g, '/') also chains .toLowerCase() (or a
single helper normalizePath that does both) so all assertions are stable across
drive-letter/path case differences.

---

Outside diff comments:
In `@bin/install.js`:
- Around line 5848-5868: The writes to destination files use a single
fs.writeFileSync(destFile, content) and can fail on transient Windows locks; add
a retry wrapper (or reuse the existing copyFileWithRetry pattern) and replace
the direct fs.writeFileSync calls in both the .js branch (where content is
modified for .claude/.qwen and GSD_VERSION) and the .sh branch
(entry.endsWith('.sh')) with a writeFileWithRetry(destFile, content) that
retries on failure a few times before throwing; keep the existing chmodSync
try/catch behavior and apply the same change to the other occurrence noted
around the 5973-5986 range so all destination writes are retried.

---

Nitpick comments:
In `@get-shit-done/bin/lib/config.cjs`:
- Around line 214-220: The normalization for config.parallelization currently
only accepts booleans or objects; update the branch that handles non-boolean
values to also accept string booleans by checking if typeof
config.parallelization === 'string' and converting "true"/"false"
(case-insensitive) to the corresponding boolean before falling back to the
existing object check or hardcoded.parallelization. Keep the existing
object-path that looks for a .enabled property and ensure the new string parsing
runs before defaulting to hardcoded.parallelization so legacy configs like
"true"/"false" are honored.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 51c93ee8-4d67-49f6-8760-9062fad0b69b

📥 Commits

Reviewing files that changed from the base of the PR and between 28d6649 and dab8e4b.

📒 Files selected for processing (10)
  • bin/install.js
  • get-shit-done/bin/lib/config.cjs
  • get-shit-done/bin/lib/core.cjs
  • get-shit-done/bin/lib/init.cjs
  • tests/bug-1736-local-install-commands.test.cjs
  • tests/bug-2136-sh-hook-version.test.cjs
  • tests/bug-2248-local-install-statusline.test.cjs
  • tests/few-shot-calibration.test.cjs
  • tests/prompt-injection-scan.test.cjs
  • tests/prune-orphaned-worktrees.test.cjs

const resolved = path.resolve(startDir);
const root = path.parse(resolved).root;
const homedir = require('os').homedir();
const homedir = resolveHomeDir();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Normalize home path before ancestor-stop comparison.

Line 127 compares parent === homedir as raw strings. With env-provided home paths (different separators/casing/trailing slash), this can miss the home boundary check.

🔧 Suggested patch
-  const homedir = resolveHomeDir();
+  const homedir = normalizeComparablePath(resolveHomeDir());
@@
-    if (parent === homedir) break; // never go above home
+    if (normalizeComparablePath(parent) === homedir) break; // never go above home

Also applies to: 127-127

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@get-shit-done/bin/lib/core.cjs` at line 100, The comparison parent ===
homedir is brittle because env-provided home paths can differ by separators,
trailing slashes or case; normalize both sides before comparing by using path
utilities: call path.resolve() and path.normalize() on resolveHomeDir() and on
the parent value, strip any trailing path.sep, and on Windows compare using
.toLowerCase() to be case-insensitive; then replace the raw equality check in
the code that references homedir with the normalized/resolved comparison (use
resolveHomeDir(), homedir variable, and the parent variable names to locate and
update the logic).

Comment on lines +1772 to +1773
if (seenSkillNames.has(name)) continue;
seenSkillNames.add(name);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Make skill-name dedupe robust to case/whitespace variants.

Line 1772/Line 1773 dedupe on raw name, so "MySkill" and " myskill " are treated as different entries and can still duplicate in the manifest.

🔧 Suggested patch
-      const name = frontmatter.name || entry.name;
+      const name = String(frontmatter.name || entry.name).trim();
       const description = frontmatter.description || '';
-      if (seenSkillNames.has(name)) continue;
-      seenSkillNames.add(name);
+      const dedupeKey = name.toLowerCase();
+      if (seenSkillNames.has(dedupeKey)) continue;
+      seenSkillNames.add(dedupeKey);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@get-shit-done/bin/lib/init.cjs` around lines 1772 - 1773, The dedupe uses the
raw skill `name`, so variants like "MySkill" and " myskill " bypass it;
normalize `name` before checking/adding to `seenSkillNames` (e.g., compute a
`normalized` value via trim() and toLowerCase(), guard against null/undefined
names), then use `seenSkillNames.has(normalized)` and
`seenSkillNames.add(normalized)` instead of using the raw `name` so
case/whitespace variants are treated as duplicates.

Comment on lines +63 to +65
function toAllowlistPath(file) {
return path.relative(PROJECT_ROOT, file).split(path.sep).join('/');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Normalize the scan bucket paths too.

This only fixes allowlist membership. The actual scan buckets below still use raw absolute paths like f.includes('/agents/'), which never match Windows paths such as C:\repo\agents\..., so those tests pass without scanning anything. Normalize once here and use the normalized relative path for both allowlist checks and bucket selection.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/prompt-injection-scan.test.cjs` around lines 63 - 65, The allowlist
helper toAllowlistPath currently returns a normalized relative path but the scan
bucket logic still checks raw absolute paths (e.g., conditions like
f.includes('/agents/')), so on Windows those checks never match; update the scan
logic to use the normalized relative path returned by toAllowlistPath for both
allowlist membership and bucket selection instead of the raw file path — locate
uses of f.includes('/agents/') (and similar bucket checks) and replace them to
operate on the normalized path produced by toAllowlistPath.

test('runs git worktree prune to clear stale references', () => {
const repoDir = path.join(tmpBase, 'repo4');
const worktreeDir = path.join(tmpBase, 'wt-stale');
const normalizedWorktreeDir = worktreeDir.replace(/\\/g, '/');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Normalize case too, not only separators, for Windows-stable assertions.

Line 152/Line 161/Line 172 normalize \ vs /, but not casing. Git output can differ in drive-letter/path case on Windows, which can still make these assertions flaky.

🔧 Suggested patch
-    const normalizedWorktreeDir = worktreeDir.replace(/\\/g, '/');
+    const normalizeForCompare = (p) => {
+      const normalized = p.replace(/\\/g, '/');
+      return process.platform === 'win32' ? normalized.toLowerCase() : normalized;
+    };
+    const normalizedWorktreeDir = normalizeForCompare(worktreeDir);
@@
-    const beforeList = execSync('git worktree list --porcelain', { cwd: repoDir, encoding: 'utf8' }).replace(/\\/g, '/');
+    const beforeList = normalizeForCompare(
+      execSync('git worktree list --porcelain', { cwd: repoDir, encoding: 'utf8' })
+    );
@@
-    const afterList = execSync('git worktree list --porcelain', { cwd: repoDir, encoding: 'utf8' }).replace(/\\/g, '/');
+    const afterList = normalizeForCompare(
+      execSync('git worktree list --porcelain', { cwd: repoDir, encoding: 'utf8' })
+    );

Also applies to: 161-163, 172-175

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/prune-orphaned-worktrees.test.cjs` at line 152, The assertions
normalize path separators but not case, causing Windows flakes; update the
normalization to also normalize case by applying a consistent case conversion
(e.g., toLowerCase()) after replacing backslashes with slashes for the variables
like normalizedWorktreeDir (and the analogous normalized... variables used
around lines where you replace /\\/g with '/'), so that comparisons use the same
lowercase path form on Windows; ensure every place that does
worktreeDir.replace(/\\/g, '/') also chains .toLowerCase() (or a single helper
normalizePath that does both) so all assertions are stable across
drive-letter/path case differences.

@dlr-1337 dlr-1337 closed this Apr 19, 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