fix(devbox): auto-detect install flag from root package.json#4
Merged
Conversation
`devbox add` always emitted `install: true`, so adding a non-Node repo (an Ansible/shell toolkit like claude-devbox itself) made the projects role's `bun install` fail with "could not find a package.json file", breaking the playbook run until the entry was hand-edited. detectProject now auto-detects `install` from a root package.json and projectEntry emits the matching line + comment. Preview and --write both flow through projectEntry, so the dry-run output reflects it. Adds projectEntry true/false tests and detectProject integration tests (throwaway git repos with/without package.json); documents the behavior in docs/multi-project.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes devbox add so new project entries don’t default to install: true when the target repo isn’t a Bun project. It auto-detects whether to run bun install by checking for a root package.json, preventing playbook failures for repos like Ansible/shell toolkits.
Changes:
- Extend
detectProjectto setinstallbased on<repo-root>/package.jsonexistence. - Update
projectEntryto emitinstall: true/falsewith an explanatory inline comment. - Add/adjust tests for
projectEntryand integration-style tests fordetectProject, and update multi-project documentation accordingly.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| docs/multi-project.md | Documents that install: is auto-detected from a root package.json and explains the install: false behavior. |
| clients/devbox/src/add.ts | Adds install detection and makes YAML emission reflect the detected value with clearer comments. |
| clients/devbox/src/add.test.ts | Adds test coverage for install rendering and repo-root auto-detection behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Problem
devbox addalways emittedinstall: truefor a new project entry. When the target repo has no rootpackage.json(an Ansible/shell toolkit — claude-devbox itself, for example), theprojectsrole'sbun installstep then fails with:…which breaks the playbook run until the entry is hand-edited to
install: false.Fix
detectProjectalready resolves the repo root (git rev-parse --show-toplevel); it now also setsinstallfromexistsSync(<root>/package.json).projectEntryemits the matching line + comment:install: true # run \bun install` after clone`install: false # no package.json at repo root — nothing to installDEVBOX_DRYRUN) and--writeboth flow throughprojectEntry, so the dry-run output reflects the detected value with no extra change.No new override flag — none existed, and auto-detection covers the case.
Tests (TDD, RED→GREEN)
projectEntry: split into explicitinstall: true/install: falsecases.detectProject: two integration tests against throwaway git repos (with/withoutpackage.json).bun test→ 80/80 pass;bun run typecheck→ clean.Verify
Docs
docs/multi-project.mdupdated in thedevbox addand Projects sections.🤖 Generated with Claude Code