Skip to content

fix(setup): never delete or overwrite an existing project without --overwrite - #2

Merged
Yoepan merged 1 commit into
Yoepan:mainfrom
KiloMusician:fix/setup-no-data-loss
Oct 24, 2026
Merged

Yoepan merged 1 commit into
Yoepan:mainfrom
KiloMusician:fix/setup-no-data-loss

Conversation

@KiloMusician

Copy link
Copy Markdown
Contributor

Problem

python setup_project.py <folder> runs shutil.rmtree on <folder>/assets, <folder>/dashboard and <folder>/.agents whenever they exist, and overwrites AGENTS.md, LICENSE, .gitignore and the status file, without asking. On throw-away trees I reproduced:

  • pointing it at an existing app that has an assets/ folder and its own .gitignore deleted assets/precious.png and replaced the .gitignore;
  • pointing it at the TenAgent checkout itself deleted the sources it was about to copy.

Change

  • It lists every conflicting path and exits with status 2 without touching anything, unless --overwrite is given.
  • It refuses a target that is, or lies inside, the framework checkout, or that is an existing file (exit status 2; wrong usage exits 1).
  • A fresh or empty folder behaves exactly as before.
  • bootstrap_new_project() now returns True/False and main(argv) exposes the exit codes so they can be tested.

Two files change: setup_project.py and a new tests/test_setup_project.py (8 tests, standard-library unittest, temp directories only).

Verification

python -I -m unittest discover -s tests on head 0aa8949:

Where Result
Windows 11, Python 3.13 8 tests, OK
Linux container, Python 3.11 (the version ci.yml pins), no network 8 tests, OK

The new tests fail on the previous setup_project.py (4 failures and 9 errors when run against d9e2c27).

Not verified

Only temp directories were used; nothing was run against a real project. Anyone who relied on the old silent overwrite now needs to pass --overwrite.

Prepared with AI coding assistants (OpenAI GPT and Anthropic Claude) on behalf of @KiloMusician, who submits it. Commands and counts above were run on the head named. MIT licence and notices untouched.

…hout --overwrite

setup_project.py <folder> ran shutil.rmtree on <folder>/assets, <folder>/dashboard
and <folder>/.agents whenever they existed, and copy2-overwrote AGENTS.md,
LICENSE, .gitignore and the status file, with no prompt. Reproduced on throw-away
trees: pointing it at an existing app that has an assets/ folder and its own
.gitignore deleted assets/precious.png and replaced the .gitignore. Pointing it
at the framework checkout itself deleted the sources it was about to copy.

Now it lists every conflicting path and exits 2 without touching anything unless
--overwrite is given, and refuses a target that is, or lies inside, the
framework checkout, or that is an existing file. Fresh folders behave as before.
bootstrap_new_project() returns True/False and main(argv) exposes the exit
codes (1 usage, 2 refused).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@Yoepan
Yoepan merged commit 51c772e into Yoepan:main Oct 24, 2026
@Yoepan

Yoepan commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Thanks @KiloMusician for the thorough audit, security proposals, and the extensive test harness!

We have already merged PR #2. Regarding PR #1

  1. There are currently merge conflicts with main due to recent updates in dashboard/serve.py and council.py
  2. For local developer experience, requiring HTTP Basic Auth credentials on every office.bat launch adds friction for pure 127.0.0.1 single-user desktop workflows (though an opt-in flag like auth could be useful).
  3. Since several credential-masking and host-binding protections are now active on main, could you rebase your branch against the latest main and consider splitting the PR (e.g. statefile atomic writes and integration tests in a separate, smaller PR)?

Thanks again for your contribution!"

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.

2 participants