Skip to content

fix(nix): make project agent CLI an explicit opt-in - #1968

Merged
gerchowl merged 6 commits into
devfrom
bugfix/1967-devshell-no-agent-cli
Oct 29, 2026
Merged

gerchowl merged 6 commits into
devfrom
bugfix/1967-devshell-no-agent-cli

Conversation

@gerchowl

@gerchowl gerchowl commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Project shells currently shadow a machine's claude wrapper, bypassing its release channel and per-profile credentials. Leave the agent CLI to the machine by default and provide an explicit opt-in.

Type of Change

  • fix -- Bug fix

Modifiers

  • Breaking change (!)

Changes Made

  • Split the agent package into one shared list; default, scaffolded, capability, and Rust shells use the agent-free toolchain. Machine modules and the image retain the CLI.
  • Add withAgentCli = false to mkProjectShell and mkRustProject. The fixed devShells.<system>.with-agent-cli output serves consumers who select a shell output rather than call the builder.
  • Document migration and the system-wrapper shadowing effect. Keep the fast-mover overlay and package pin unchanged.
  • Add an evaluation-only flake policy check covering default, consumer and scaffolded shells, opt-in package identity, and legacy home-manager/NixOS installs. Update the existing tool-list guard.

Changelog Entry

Changed

  • Project shells leave the agent CLI to the machine (#1967)
    • Repositories relying on the dev-shell's claude must install it machine-wide (or via the home module), or set withAgentCli = true; consumers of devkit's own devShells output can select #with-agent-cli.
    • Opting in shadows any system claude wrapper. Home modules and the container image retain the CLI.

Testing

  • Current-head CI: all 18 checks passed on 39c17c51433765c0e607180a92bbabba8b750fbd, including Test Summary, Project Flake Gates, Consumer Matrix, and both home matrices. gh pr checks 1968 --watch exited 0.

  • Rust-path regression: nix eval .#checks.x86_64-linux.agentCliPolicy.drvPath exited 1 for each temporary mutant (removed withAgentCli forwarding; changed its Rust default to true). Restoring each original implementation makes the evaluation pass (exit 0). Both mutants were restored before the guard was committed.

  • The guard now evaluates mkRustProject against templates/rust with default and opted-in CLI settings. Builder documentation and the Rust scaffold show the option and warn that it shadows a system wrapper.

  • Touched tests pass locally

  • Manual evaluation performed

Manual Testing Details

  • RED: nix eval --impure --json --file tests/agent-cli-policy.nix exited 1 on the default-shell assertion before implementation; committed first as d4566beb.
  • Previous-head CI: all 18 checks passed on e4e7f56bf396872e547f6847f6c8ac48535cfeff, including Project Flake Gates, Consumer Matrix, both home matrices, and Test Summary. gh pr checks 1968 exited 0.
  • GREEN: nix eval .#checks.x86_64-linux.agentCliPolicy.drvPath exited 0. This evaluates package lists without building Claude Code.
  • uv run --with pytest-xdist pytest tests/test_flake_devshell.py::test_devshell_tools_is_superset_of_agent_toolkit -n 4 --basetemp=$HOME/.cache/devkit-pytest/1967 exited 0 (1 passed); isolated directory removed.
  • just docs and commit hooks run inside nix develop; full suites/builds are left to CI on the shared host.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code where needed
  • I have updated the documentation accordingly
  • I have updated both devkit changelog copies under Unreleased
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective
  • Touched tests pass locally
  • No dependent changes are required

Additional Notes

The opt-in devkit shell output is necessary for consumers using an exported shell directly: such consumers cannot pass a builder argument. No full builds were run locally. The container CLI remains available as before.

Refs: #1967

@gerchowl
gerchowl force-pushed the bugfix/1967-devshell-no-agent-cli branch from 35046a2 to 39c17c5 Compare October 29, 2026 19:25
@gerchowl
gerchowl merged commit 90346a3 into dev Oct 29, 2026
18 checks passed
@gerchowl
gerchowl deleted the bugfix/1967-devshell-no-agent-cli branch October 29, 2026 19:35
gerchowl added a commit that referenced this pull request Oct 30, 2026
…1972)

## Description

Carry #1967 from PR #1968 onto the main-based 1.18.1 hotfix. Default
project devShells leave `claude` to the machine; `withAgentCli = true`
and devkit's `#with-agent-cli` output opt in using the same pin.
Home/NixOS modules and the container image retain the CLI.

## Type of Change

- [x] `fix` -- Bug fix
- [x] `docs` -- Documentation only
- [x] `test` -- Adding or updating tests

### Modifiers

- [ ] Breaking change (`!`)

## Changes Made

Cherry-picked in source order with `-x` provenance retained in each
commit body (before the final `Refs` line):

- d246518 — shell policy regression
guard.
- 0161007 — opt-in implementation,
documentation and scaffold policy.
- 831688b — shell-builder option
comments, limited to existing files.
- d31b02d — corrected migration
wording.
- 39c17c5 — distinguish devkit-output
and consumer-builder opt-ins.

Dropped from the carry:

- Entire 260420a: Rust-only policy test
bindings/assertions require `templates/rust`, absent from the release
base.
- `assets/flake.d/rust.flake.nix` comment hunk from
831688b: file absent from the release
base.
- Retained `nix/mk-rust-project.nix` option/pass-through and comment
hunks: that file exists on the release base and the changes applied
cleanly.
- No unrelated development changelog entries carried. Both copies
contain only #1967 in the seeded 1.18.1 section.

## Changelog Entry

Under `## [1.18.1] - TBD` in both changelogs, per the hotfix lane:

### Changed

- **Project shells leave the agent CLI to the machine**
([#1967](#1967))
- Repositories relying on the dev-shell's `claude` must install it
machine-wide (or via the home module), or set `withAgentCli = true`;
consumers of devkit's own `devShells` output can select
`#with-agent-cli`.
- Opting in shadows any system `claude` wrapper. Home modules and the
container image retain the CLI.

## Testing

- [x] Manual testing performed
- Evaluation only: `nix eval --impure --json --expr 'import
./tests/agent-cli-policy.nix {}'` — exit 0 (`agentCliPolicy: true`).
Asserts no CLI in default devShell, `lib.mkProjectShell` or scaffolded
workspace; opt-in includes the same pinned package; home and NixOS
modules retain it.
- `nix eval --raw .#checks.x86_64-linux.agentCliPolicy.drvPath` — exit
0, check evaluates without building its closure.
- Pre-change default-shell absence assertion evaluated against the
test-only commit — exit 1, expected assertion failure because the CLI
was present.
- Repository commit hooks run inside `nix develop`; broader suites run
in PR CI.

## Checklist

- [x] Code follows project style; self-review performed
- [x] Documentation and regression guard included
- [x] Both changelogs updated in the hotfix release section
- [x] No unrelated release changes

## Additional Notes

Targets `release/1.18.1`. No release workflow dispatch or merge is part
of this PR.

Rebased onto `release/1.18.1` at 113d379 after security-register
reconciliation PR #1973. Both existing release entries (uv under Changed
and the exception reconciliation under Security) are preserved alongside
#1967. No implementation changes were made in this rebase.

Post-rebase verification: policy evaluation and `agentCliPolicy.drvPath`
evaluation both exit 0. An additional evaluation asserts that the opt-in
shell contains `claude-code` directly from the locked nixpkgs-unstable
input: exit 0, version 2.1.309, unstable revision
`674a2028661e550a97400c1cc992b9cca9a668a1`. All 18 checks are green on
rebased head `00f791f6bda5d2a73a19615f12900f1114e07823`; `gh pr checks
1972 --watch` exited 0.

Refs: #1967
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.

1 participant