Skip to content

fix(cli): revert detect-squad-dir to zero-dependency bootstrap#756

Merged
bradygaster merged 9 commits intodevfrom
squad/fix-detect-squad-dir-zero-deps
Apr 2, 2026
Merged

fix(cli): revert detect-squad-dir to zero-dependency bootstrap#756
bradygaster merged 9 commits intodevfrom
squad/fix-detect-squad-dir-zero-deps

Conversation

@diberry
Copy link
Copy Markdown
Collaborator

@diberry diberry commented Apr 2, 2026

Bug

detect-squad-dir.ts line 5 — the requested module @bradygaster/squad-sdk does not provide an export named FSStorageProvider

Reported on the insider branch; same code exists on dev.

Root Cause

Commit 26047dc5 (feat(storage): add StorageProvider abstraction layer) swept the codebase converting raw node:fs calls to FSStorageProvider. It incorrectly converted detect-squad-dir.ts, a bootstrap utility whose JSDoc explicitly says "zero dependencies". This file runs to detect .squad/ directories before the SDK is loaded — it must only use Node built-ins.

Fix

  • Reverted detect-squad-dir.ts to use raw node:fs (fs.statSync, fs.readFileSync, fs.existsSync)
  • Removed import { FSStorageProvider } and const storage = new FSStorageProvider()
  • Preserved the "zero dependencies" JSDoc banner

Regression Guard

Added test/detect-squad-dir-zero-deps.test.ts with three assertions:

  1. Source must not import from @bradygaster/squad-sdk
  2. Source must not require @bradygaster/squad-sdk
  3. Source must import from node:fs

This prevents future sweeping refactors from accidentally converting the file again.

Verification

  • npm run build
  • vitest run test/worktree.test.ts — 9/9 pass ✅
  • vitest run test/detect-squad-dir-zero-deps.test.ts — 3/3 pass ✅

diberry and others added 6 commits April 2, 2026 12:46
The StorageProvider refactor (26047dc) incorrectly converted this
bootstrap utility from raw node:fs to FSStorageProvider. This file
detects .squad/ directories before the SDK is loaded and must not
depend on @bradygaster/squad-sdk.

Adds a regression guard test to prevent future re-conversion.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…dency creep

Prevents future sweeping refactors from converting zero-dependency
bootstrap utilities (like detect-squad-dir.ts) to use SDK imports.
These files run before the SDK is loaded and must stay Node.js-only.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Agent history changes belong on dev, not in feature PRs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds 4 verified zero-dependency bootstrap files to the protected list
(errors.ts, gh-cli.ts, output.ts, history-split.ts). Adds Sweeping
Refactor Rules section and SDK/CLI package boundary guidance.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…written)

Tasks completed:
- Task 0: PRE-CHECK: recorded decisions.md (334KB) and inbox (4 files)
- Task 1: DECISIONS ARCHIVE: triggered Tier 2 (>=50KB), archived 7 entries older than 7 days
- Task 2: DECISION INBOX: merged 4 inbox entries to decisions.md, deleted inbox files
- Task 3: ORCHESTRATION LOG: wrote 5 agent logs (EECOM, Procedures, Flight, FIDO, EECOM-changeset)
- Task 4: SESSION LOG: wrote detect-squad-dir-fix session log
- Task 5: CROSS-AGENT: appended team update to 4 agent history.md files
- Task 6: HISTORY SUMMARIZATION: checked—4 files exceed 15KB (EECOM 28.8KB, FIDO 23.3KB, Flight 23.7KB, Procedures 19.6KB). Deferred detailed archiving.
- Task 7: GIT COMMIT: staged .squad/ changes (15 files), now committing
- Task 8: HEALTH REPORT: decisions.md reduced from 334KB via Tier 2 purge; inbox count 0 (merged and cleared)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@diberry diberry marked this pull request as ready for review April 2, 2026 20:12
Copilot AI review requested due to automatic review settings April 2, 2026 20:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a CLI startup regression by restoring detect-squad-dir.ts to a true zero-dependency bootstrap utility (Node built-ins only), and adds a regression test + updated contributor guidance to prevent future refactors from reintroducing SDK dependencies.

Changes:

  • Reverted packages/squad-cli/src/cli/core/detect-squad-dir.ts to use node:fs directly instead of FSStorageProvider.
  • Added test/detect-squad-dir-zero-deps.test.ts to enforce “no SDK imports/requires” and “must use node:fs”.
  • Documented a “Protected Files — Zero External Dependencies” list in .github/copilot-instructions.md, plus added a changeset.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/squad-cli/src/cli/core/detect-squad-dir.ts Removes SDK dependency and restores raw node:fs usage for bootstrap safety.
test/detect-squad-dir-zero-deps.test.ts Adds a regression guard to prevent reintroducing external deps into the bootstrap file.
.github/copilot-instructions.md Documents protected bootstrap files and refactor rules to avoid repeating the regression.
.changeset/fix-detect-squad-dir-zero-deps.md Records a patch-level release note for the CLI fix.

Comment thread test/detect-squad-dir-zero-deps.test.ts Outdated
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
diberry and others added 3 commits April 2, 2026 13:18
…ification

- Widen test regex to catch subpath imports (@bradygaster/squad-sdk/*)
- Fix test filename reference in copilot-instructions.md
- Clarify core/ contains a mix of bootstrap and SDK-dependent modules

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Agent state (history, decisions, logs) should not be in feature PR diffs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bradygaster bradygaster merged commit cf1d068 into dev Apr 2, 2026
11 checks passed
diberry added a commit that referenced this pull request Apr 2, 2026
Captures the full Copilot PR reviewer comment pipeline learned across
PRs #756, #760, #762: reading reviews, critical evaluation, lockout-aware
routing, GraphQL thread resolution, and CI verification.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

3 participants