Skip to content

fix(install): refuse to replace non-managed files or dirs during setup - #114

Merged
danielvm-git merged 1 commit into
danielvm-git:mainfrom
56phil:fix/installer-clobber
Sep 1, 2026
Merged

danielvm-git merged 1 commit into
danielvm-git:mainfrom
56phil:fix/installer-clobber

Conversation

@56phil

@56phil 56phil commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

linkSkills/linkDir/linkFile/linkHook in scripts/lib/install-helpers.js previously did fs.rmSync(dst, { force: true, recursive: true }) before symlinking — silently destroying any pre-existing file or directory at the destination. A user's own ~/.claude/hooks/rtk-rewrite.sh (installed by RTK itself) or a user-authored skills dir with a colliding name would be deleted without prompt, backup, or any check.

Change

Add assertReplaceable(dst), called by all four link functions before removal:

  • Destination absent → safe to create.
  • Destination is a symlink pointing back into this package (REPO_ROOT) → managed by bigpowers, safe to re-link.
  • Anything else (regular file, directory, foreign symlink) → throw with a clear message: "Refusing to replace ... Back it up or remove it manually, then re-run setup."

The recursive: true rmSync is dropped in favor of plain rmSync, since the only removable case is now a single managed symlink.

Verification

  • bash scripts/test-install-helpers.sh → ALL PASS (existing suite, no regressions).
  • Direct guard checks: blocks a non-managed file, blocks a foreign symlink, re-links a managed symlink, creates a new link.

Closes #112.

linkSkills/linkDir/linkFile/linkHook previously did rmSync(dst,
{recursive:true}) before symlinking, silently destroying any pre-existing
file or directory at the destination. A user's own ~/.claude/hooks/
rtk-rewrite.sh (installed by RTK itself) or a user-authored skills dir
with a colliding name would be deleted without prompt or backup.

Add assertReplaceable(): the destination may only be replaced when it is
absent or already a symlink pointing back into this package. Anything
else throws with a clear message. The recursive rmSync is dropped in
favor of plain rmSync since the only removable case is now a single
managed symlink.

Closes danielvm-git#112
@danielvm-git
danielvm-git merged commit f866adc into danielvm-git:main Sep 1, 2026
github-actions Bot pushed a commit that referenced this pull request Sep 1, 2026
## [2.87.6](v2.87.5...v2.87.6) (2026-09-01)

### Bug Fixes

* **install:** refuse to replace non-managed files or dirs during setup ([#114](#114)) ([f866adc](f866adc)), closes [#112](#112)
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.87.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

danielvm-git added a commit that referenced this pull request Sep 1, 2026
Regression tests for BUG-2026-08-31-pi-scripts-provisioning (#116):
- initProject links package scripts/ into a consumer project and
  scaffolds specs/bugs + specs/verifications
- initProjectRemove cleans only managed artifacts
- init refuses (never clobbers) a user-owned scripts/ dir
- CLI drift guards: 'init' dispatch in bin/bigpowers.js + bin/init.js
- managed-symlink check needs a path-separator boundary (PR #114
  follow-up): prefix sibling <ROOT>-evil must be refused

All fail against current code (initProject undefined).
danielvm-git added a commit that referenced this pull request Sep 1, 2026
…rojects

BUG-2026-08-31-pi-scripts-provisioning (#116). Package installs
(pi install npm:bigpowers, npm i -g, npx) register skills but never
provision a project-local scripts/ tree — pi's package contract has
no resource type for project files and no lifecycle script runs — so
SKILL.md commands (bash scripts/*.sh) and verify gates fail in every
consumer project.

- install-helpers.js: initProject(repoRoot) links the package
  scripts/ into cwd and scaffolds specs/bugs + specs/verifications;
  initProjectRemove(repoRoot) removes only managed artifacts.
  Both reuse linkDir/assertReplaceable — a user-owned scripts/ is
  refused, never clobbered.
- assertReplaceable: managed-symlink check now requires a
  path-separator boundary — a string-prefix sibling of the package
  root (<ROOT>-evil) is no longer treated as managed (PR #114
  follow-up).
- bin/init.js + bigpowers init [--remove] dispatch + help text.
- README pi Support: document the per-project provisioning step.

RED->GREEN: test-install-helpers.js additions from the previous
commit failed (initProject undefined) and now pass; e2e verified in
a temp consumer project (gates resolve, idempotent, --remove cleans,
refusal preserves user content, no-op inside the package).
danielvm-git added a commit that referenced this pull request Sep 1, 2026
…rojects (#117)

* chore(bugs): file BUG-2026-08-31 — npm token release failure + pi scripts provisioning

Two open bug records:
- BUG-2026-08-31-npm-token-invalid-release: Release workflow fails
  EINVALIDNPMTOKEN at verifyConditions (run 33461454695, commit f866adc);
  v2.87.6 unpublished pending NPM_TOKEN rotation. Code unaffected —
  skill-health and compliance green on the same commit.
- BUG-2026-08-31-pi-scripts-provisioning (#116): package installs
  provision skills but never scripts/ — verify gates fail in every
  consumer project. Fix via bigpowers init lands in the following
  commits on this branch.

Registry regenerated (74 bugs) with OKF sidecars.

* test(install): bigpowers init provisions scripts/ + specs/ — RED

Regression tests for BUG-2026-08-31-pi-scripts-provisioning (#116):
- initProject links package scripts/ into a consumer project and
  scaffolds specs/bugs + specs/verifications
- initProjectRemove cleans only managed artifacts
- init refuses (never clobbers) a user-owned scripts/ dir
- CLI drift guards: 'init' dispatch in bin/bigpowers.js + bin/init.js
- managed-symlink check needs a path-separator boundary (PR #114
  follow-up): prefix sibling <ROOT>-evil must be refused

All fail against current code (initProject undefined).

* fix(cli): bigpowers init provisions scripts/ + specs/ into consumer projects

BUG-2026-08-31-pi-scripts-provisioning (#116). Package installs
(pi install npm:bigpowers, npm i -g, npx) register skills but never
provision a project-local scripts/ tree — pi's package contract has
no resource type for project files and no lifecycle script runs — so
SKILL.md commands (bash scripts/*.sh) and verify gates fail in every
consumer project.

- install-helpers.js: initProject(repoRoot) links the package
  scripts/ into cwd and scaffolds specs/bugs + specs/verifications;
  initProjectRemove(repoRoot) removes only managed artifacts.
  Both reuse linkDir/assertReplaceable — a user-owned scripts/ is
  refused, never clobbered.
- assertReplaceable: managed-symlink check now requires a
  path-separator boundary — a string-prefix sibling of the package
  root (<ROOT>-evil) is no longer treated as managed (PR #114
  follow-up).
- bin/init.js + bigpowers init [--remove] dispatch + help text.
- README pi Support: document the per-project provisioning step.

RED->GREEN: test-install-helpers.js additions from the previous
commit failed (initProject undefined) and now pass; e2e verified in
a temp consumer project (gates resolve, idempotent, --remove cleans,
refusal preserves user content, no-op inside the package).
github-actions Bot pushed a commit that referenced this pull request Sep 1, 2026
## [2.87.8](v2.87.7...v2.87.8) (2026-09-01)

### Bug Fixes

* **cli:** bigpowers init provisions scripts/ + specs/ into consumer projects ([#117](#117)) ([37bc0bf](37bc0bf)), closes [#116](#116) [#116](#116) [#114](#114) [#116](#116) [#114](#114)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

install: claude setup silently replaces an existing ~/.claude/hooks/rtk-rewrite.sh with a different, incompatible hook

2 participants