fix: move pre-existing .devcontainer aside instead of refusing to init - #21
Open
ai-anant wants to merge 1 commit into
Open
fix: move pre-existing .devcontainer aside instead of refusing to init#21ai-anant wants to merge 1 commit into
ai-anant wants to merge 1 commit into
Conversation
When a repo already ships its own .devcontainer/ (or an aidc-managed .cursor/rules/00-core-logics.mdc), 'aidc init' / 'aidc claude' aborted with 'error: refusing to overwrite existing file'. The pre-existing files are now moved aside to <dir>.aidc-backup (with a numeric suffix on collision) and a restore hint is printed, then the scaffold proceeds. User content is preserved, never deleted. The backup dirs are added to the per-repo git excludes so they don't pollute git status. Fixes cyfinoid#6
This was referenced Aug 2, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #6. When a repo already ships its own
.devcontainer/(or an aidc-managed.cursor/rules/00-core-logics.mdc),aidc init/aidc claudeaborted with:This made aidc unusable on any repo that already had a devcontainer — exactly the scenario in the issue ("AIDC wont initialize if .devcontainer already exists").
Change
lib/aidc.sh—aidc::check_init_conflicts()no longer dies when a pre-existing managed path is found. Instead it:.devcontainer/,.cursor/rules/).<dir>.aidc-backup(numeric suffix.1,.2, … on collision) — user content is renamed, never deleted.mv .devcontainer.aidc-backup .devcontainer.refresh_scaffoldproceeds normally.aidc::ensure_local_git_excludes()now also excludes.devcontainer.aidc-backup*/so the backup dir doesn't pollutegit status.Behavior matrix:
.devcontainer/devcontainer.json(typical VS Code devcontainer)error: refusing to overwrite.devcontainer.aidc-backup, scaffold proceeds.cursor/rules/00-core-logics.mdcerror: refusing to overwrite.cursormoved to.cursor.aidc-backup, scaffold proceeds.cursor/rules/my-user-rule.md(no aidc-managed path)00-core-logics.mdc.ai-container/project.envpresent)Verification
bash -nunder bash 3.2.57 (the project floor) — cleanshellcheck --severity=warningonbin/aidc,lib/aidc.sh, all*.sh(mirrors shellcheck.yml) — clean.github/scripts/bash-compat-check.shunder bash 3.2 — parse + smoke OKtests/resolve-oauth-token.test.sh— 7/7 pass.github/scripts/test-bootstrap-state.sh— 9/9 passpython3 -m py_compile bin/aidc-clipboard-server— OKaidc init): repo with pre-existing.devcontainer/(devcontainer.json + scripts) +.cursor/rules/my-user-rule.md→ init succeeds, originals preserved in.devcontainer.aidc-backup, user cursor rule untouched, scaffold complete. Second scenario with a.devcontainer.aidc-backupalready present → backup correctly lands in.devcontainer.aidc-backup.1. Re-runningaidc initon an initialized repo stays a clean no-op.Fixes #6