Skip to content

ux: upgrade --migrate-directory should warn about git rename history loss and unstaged changes #126

Closed

Description

@bradygaster

Problem

upgrade --migrate-directory uses fs.renameSync() to rename .ai-team/ → .squad/, which causes three silent git issues:

  1. History loss: Git sees the rename as a delete + add, not a move. git log --follow stops working for all files in the directory.
  2. Unstaged changes: The rename is not staged. Users may not realize they have uncommitted changes in the new location.
  3. Guard CI will block: The squad-main-guard workflow explicitly blocks .squad/** from main/preview branches. Users who commit .squad/ to a PR targeting main will hit a CI failure with no explanation.

Suggested Fix

After the migration completes, print clear guidance:

✓ Renamed .ai-team/ → .squad/

⚠️  Git note: this rename appears as delete+add in git history.
   To preserve file history, use: git mv .ai-team .squad (before running this command next time)

Next steps:
  git add -A
  git commit -m "chore: migrate .ai-team/ → .squad/"

Note: .squad/ should NOT be committed to main/preview — keep it on feature branches.

Additionally, consider using git mv via child_process instead of fs.renameSync when inside a git repo, which preserves rename tracking.

Found by: Kobayashi during 0.5.0 diagnostic investigation on SqncR.

Activity

  1. bradygaster commented on Feb 20, 2026

    @bradygaster
    CollaboratorAuthor

    Partially addressed in v0.5.2: the migrations and .gitattributes\ rules now use the detected squad directory (e.g. .squad/) rather than hardcoding .ai-team/, so the core correctness issue is fixed. The remaining items in this issue — explicit post-migration warning messages and considering \git mv\ over \ s.renameSync\ — are UX enhancements. Keeping this open to track those improvements.

  2. github-actions commented on Mar 7, 2026

    @github-actions
    Contributor

    🏷️ Release target updated → release:v0.8.22

  3. 9 remaining items

  4. github-actions commented on Mar 9, 2026

    @github-actions
    Contributor

    📋 Assigned to EECOM (Core Dev)

    Issue: #126 — ux: upgrade --migrate-directory should warn about git rename history loss and unstaged changes

    EECOM will pick this up in the next Copilot session.

    For Copilot coding agent: If enabled, this issue will be worked automatically.
    Otherwise, start a Copilot session and say:
    EECOM, work on issue #126

  5. bradygaster commented on Mar 13, 2026

    @bradygaster
    CollaboratorAuthor

    📌 Brady requested this issue be assigned to @diberry (docs/UX triage). Pending collaborator invite to complete assignment.

  6. diberry commented on Mar 14, 2026

    @diberry
    Contributor

    📋 Implementation Proposal: Solution D — Hybrid Smart Rename + Warnings

    Analyzed by: @diberry (PAO triage)

    Remaining work (per Brady's v0.5.2 comment — core bug fixed, UX enhancements remain):

    Approach: Try git mv .ai-team .squad when inside a git repo (preserves git log --follow). Fall back gracefully to fs.renameSync() when git is unavailable or fails. Always print enhanced warnings.

    Changes to migrate-directory.ts:

    1. Git repo detection — reuse execFileSync('git', ['rev-parse', ...]) pattern from init.ts
    2. Pre-flight dirty check — warn (not block) if .ai-team/ has uncommitted changes
    3. Smart rename — git mv first, fs.renameSync fallback on failure
    4. Enhanced post-migration output — history loss warning when git mv wasn't used, CI guard warning about main/preview branches

    No new CLI flags. No new dependencies (child_process already used in init.ts, gh-cli.ts). Graceful degradation — migration always completes.

    Test plan: 5 new tests covering git mv path, fallback path, dirty check warning, CI guard warning, and git mv failure recovery.

    Target file: packages/squad-cli/src/cli/core/migrate-directory.ts + test/cli/upgrade.test.ts

    Full PRD available on request. Ready for Core Dev pickup (Fenster/EECOM per existing triage).

  7. diberry commented on Mar 14, 2026

    @diberry
    Contributor

    cc @bradygaster — implementation proposal above for the remaining UX enhancements. Ready for Core Dev assignment when you're ready.

  8. diberry commented on Mar 14, 2026

    @diberry
    Contributor

    Coordination note: #197 overlap check

    Reviewed #197 (Improve migration experience — PR #199 by @williamhallatt). These are complementary, not overlapping:

    Dependency note for implementer: Before starting #126 work, check if PR #199 has merged. If so, verify migrate-directory.ts still exists as the active code path — the new squad migrate may eventually supersede it.

    Updated the PRD with this coordination section.

  9. diberry commented on Mar 14, 2026

    @diberry
    Contributor

    PRD updated: Consolidated with #197 non-doc items

    The PRD for this issue now also covers the non-doc implementation work from #197:

    This gives a single implementation target for Core Dev. The PRD has two parts:

    Docs-only work (migration guide covering all install methods) stays in #197 for PAO.

    cc @bradygaster

  10. github-actions commented on Mar 15, 2026

    @github-actions
    Contributor

    📋 Assigned to EECOM (Core Dev)

    Issue: #126 — ux: upgrade --migrate-directory should warn about git rename history loss and unstaged changes

    EECOM will pick this up in the next Copilot session.

    For Copilot coding agent: If enabled, this issue will be worked automatically.
    Otherwise, start a Copilot session and say:
    EECOM, work on issue #126

  11. bradygaster commented on Mar 15, 2026

    @bradygaster
    CollaboratorAuthor

    Fixed! EECOM investigated and confirmed this was still a valid concern — the upgrade --migrate-directory command was still using fs.renameSync() without safety checks.

    The fix adds:

    • Git repository detection before migration
    • Unstaged changes detection (fatal abort if found in .ai-team/ or .ai-team-templates/)
    • Clear warning about git history implications — explains the delete+add vs rename trade-off
    • Recommendation to use git mv for history preservation

    Merged in commits c6f1ec9 and cda717e on dev with 2 new tests covering the warning and abort behaviors. Thanks for the original report, @bradygaster! 🔧

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

    go:needs-researchNeeds investigationpriority:p2Next sprintsquadSquad triage inbox — Lead will assign to a membertype:featureNew capability

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions