Visitar URL original
Lead Every autoMode List With $defaults and Fix Misleading Windows Output by ptr727 · Pull Request #4094 · ptr727/ProjectTemplate · GitHub
Skip to content

Lead Every autoMode List With $defaults and Fix Misleading Windows Output - #4094

Merged
ptr727 merged 3 commits into
developfrom
feature/automode-defaults-first
Nov 12, 2026
Merged

ptr727 merged 3 commits into
developfrom
feature/automode-defaults-first

Conversation

@ptr727

@ptr727 ptr727 commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes what a native Windows 11 test of the one-step agent setup (released as 2.0.1414) showed to be wrong or misleading.

  • "$defaults" first in every autoMode list.
    • The problem: Claude Code's offer to learn rules had written a 24-entry autoMode.environment with no $defaults, silently replacing Claude Code's built-in rules. The kit treated such a list as the machine's choice and left it alone.
    • Install: for each of environment, allow, soft_deny and hard_deny that exists, the kit adds $defaults at index 0 if absent, moves it there if misplaced, and collapses duplicates. Every other entry keeps its value and order, and a missing list stays absent. The deny lists matter most, since one without $defaults drops Claude Code's built-in deny rules. The decision is the maintainer's.
    • --report: a list without $defaults first, exactly once, makes the machine not current. Each case is worded for what it is: only an absent $defaults replaces the built-ins.
    • No opt-out: a machine can no longer keep a list that replaces the built-ins, since every install puts $defaults back. The README says so.
  • Archive note. The kit report said "no checkout to compare against" even when the archive stamp recorded the commit and the report had compared it. It now names the commit, and says "no commit" only when the stamp holds none.
  • Codex presence. The rules step counts Codex as present when ~/.codex exists, which is right, since the Codex IDE extension reads that file too. The agent-tools table says "not installed" when no codex CLI is on PATH. The rules lines now say "(config directory present, no codex CLI on PATH)" in that case, on both platforms.
  • merge-and-release step 7. After a hub release, step 7 now also refreshes the Codex and opencode global rules, but only where the kit in that same step reads current. That keeps it from rolling the rules back while the kit declines to.

The logic lives in the shared Python installers, so the .sh and .ps1 wrappers behave the same. The install-global-rules pair's help text changed identically on both.

Refs #2553

Verification

The kit's test_install.py (215), tests/test_global_rules.py (54), tests/test_bootstrap.py (186, with the PowerShell cases under pwsh), tests/test_cli_usage.py and tests/test_build_dist.py pass. build_dist.py --check is current. ruff, mypy and the prose gate are clean. docker_lint.py passes shellcheck, shfmt, PSScriptAnalyzer and markdownlint.

Two recorded local passes ran. The first raised two findings, the per-case wording and step 7's missing rollback guard, both fixed in 7859290. The second found nothing open.

🤖 Generated with Claude Code

ptr727 and others added 2 commits November 12, 2026 06:26
…tput

A Windows host's autoMode.environment list was created by Claude Code's "learn rules" offer without $defaults, which silently replaced Claude Code's built-in rules. The kit now makes "$defaults" the first entry, exactly once, of every autoMode list that exists, including soft_deny and hard_deny. Other entries keep their text and relative order, a missing list stays absent, and the install names each list it changed. The report names a list that does not lead with it and counts the machine as not current. That check reads settings.json live and stays out of the payload digest.

The kit report no longer says an archive stamp "has no checkout to compare against" when the stamp recorded a commit. It names the commit instead, and keeps a note only for a commit-less archive. The rules writer says when an agent counted as present only through its config directory, with no CLI on PATH.

merge-and-release step 7 now also refreshes the Codex and opencode global rules after the kit, reporting a SHADOWED or EDITED result and never retrying a failure.

Refs #2553

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…st Rollback

Claude Code splices its built-in rules in wherever "$defaults" sits, so only a list with none replaces them. The report, the registration problem and the install messages now word each case for what it is. An absent splice replaces the built-ins, and the install says it added it first alongside the host's entries. A misplaced or repeated splice keeps the built-ins and breaks only this kit's rule that it lead exactly once, so those messages make no claim that rules were missing.

merge-and-release step 7 refreshes the Codex and opencode rules only where the kit read CURRENT in that step or was installed and then read CURRENT. Where the kit declined, because its commit is not an ancestor of main or carries -dirty, the rules are left alone and both are reported together, so the rules cannot be rolled back while the kit declines the same rollback.

Refs #2553

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Nov 12, 2026
Copilot AI lite review requested due to automatic review settings November 12, 2026 14:32
@ptr727

ptr727 commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 7859290a248c3d5e35fb68af8721fe9067098d2a, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Approval is deferred because Step 7 modifies release-time host writes and relies on native Windows PowerShell behavior that cannot be executed in this review environment.

No open issues 🎉

What changed in this PR

This PR hardens host setup by preserving Claude Code's built-in autoMode rules, clarifying agent presence and archive provenance, and synchronizing post-release global rule refreshes.

Changes:

  • Normalize existing autoMode lists so $defaults appears first exactly once.
  • Improve Codex, opencode, archive, installer, wrapper, test, and documentation output.
  • Extend merge-and-release step 7 to refresh Codex and opencode rules after the safety kit is current.
File Description
tests/​test_global_rules.py Adds coverage for configuration-directory presence explanations across setup, reporting, dry-run, and PowerShell paths.
host-setup/​windows/​install-global-rules.ps1 Updates help text to document configuration-directory presence as an installation signal.
host-setup/​linux/​install-global-rules.sh Mirrors the updated configuration-directory presence help text.
host-setup/​agent-safety/​global_rules.py Adds presence-specific output for agents without a CLI on PATH.
host-setup/​agent-safety/​claude/​test_install.py Tests archive provenance and $defaults normalization and reporting behavior.
host-setup/​agent-safety/​claude/​README.md Documents the enforced $defaults placement and validation behavior.
host-setup/​agent-safety/​claude/​install.py Normalizes $defaults entries and clarifies list-state and archive provenance reporting.
docs/​host-setup.md Documents configuration-directory-based agent detection and explanatory output.
.github/​skills/​merge-and-release/​SKILL.md Adds guarded Codex and opencode global rules refresh instructions after releases.
.claude-plugin/​fleet-skills/​skills/​merge-and-release/​SKILL.md Carries the updated merge-and-release rule refresh instructions.
.claude-plugin/​fleet-skills/​.source-digests/​merge-and-release Updates the generated source digest for the merge-and-release skill.
.agents/​skills/​merge-and-release/​SKILL.md Updates the canonical merge-and-release instructions with post-release rule refreshes.

Review effort: Lite

@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 9.75610% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.58%. Comparing base (8e19057) to head (dad0bf5).

Files with missing lines Patch % Lines
host-setup/agent-safety/claude/install.py 9.37% 29 Missing ⚠️
host-setup/agent-safety/global_rules.py 11.11% 8 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4094      +/-   ##
===========================================
- Coverage    76.73%   76.58%   -0.15%     
===========================================
  Files           40       40              
  Lines        14104    14136      +32     
===========================================
+ Hits         10822    10826       +4     
- Misses        3282     3310      +28     
Flag Coverage Δ
python-3.13 76.58% <9.75%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Windows CI failed test_a_cli_on_path_prints_no_suffix, because a command on PATH is found
only through a PATHEXT extension, so the extension-less stand-in left codex absent there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ptr727

ptr727 commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

Answering the round on 7859290, whose verdict is needs a closer look with (0) counted findings. Headline: "Approval is deferred because Step 7 modifies release-time host writes and relies on native Windows PowerShell behavior that cannot be executed in this review environment." No change needed, with this evidence:

  • Step 7 cannot roll anything back. Its new release-time write runs only where the kit in the same step read CURRENT, or was installed there from origin/main and then read CURRENT. Where the kit's stamp names a commit that is not an ancestor of main, or is dirty, step 7 leaves both the kit and the rules alone and reports them to the maintainer.
  • The Windows behavior was run. Native Windows CI (Windows unit test job) runs this suite on windows-latest. Its one failure on this PR was a test stand-in missing its PATHEXT extension, fixed in dad0bf5. The PowerShell paths this PR's behavior goes through were run by hand on a Windows 11 host on 2026-11-12: menu.ps1 options 11 (-AgentSetup) and 10 (-AgentStatus). That host's autoMode.environment output is what prompted this change. The kit and rules logic changed here lives in the shared Python installers, which that run exercised.

@ptr727

ptr727 commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head dad0bf599e82397829d062600b909f104bb7d7eb, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@ptr727

ptr727 commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Action not completed

Pull request is closed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ptr727
ptr727 merged commit 90fd2d6 into develop Nov 12, 2026
12 of 13 checks passed
@ptr727
ptr727 deleted the feature/automode-defaults-first branch November 12, 2026 15:05
ptr727 added a commit that referenced this pull request Nov 12, 2026
… Upgrades (#4096)

## Summary

Promotes the agent-setup follow-ups and their review fixes, plus one
change from another hub session, from `develop` to `main`. Both follow a
native Windows 11 test of the one-step agent setup released as 2.0.1414.

- #4094:
- The Claude safety kit puts `"$defaults"` first in each `autoMode` list
that exists (`environment`, `allow`, `soft_deny`, `hard_deny`). Claude
Code's "learn rules" offer had written a list without it, which silently
replaced Claude Code's built-in rules. `--report` flags such a list as
not current.
  - The kit report's archive note names the commit.
- The Codex and opencode rules lines say when only an agent's config
directory makes it count as installed.
- `merge-and-release` step 7 also refreshes the Codex and opencode
rules, only where the kit reads current.
- #4095: an agent tool installed through npm, bun, scoop, Homebrew or
mise is upgraded through that manager, one package only. The manager is
asked whether it owns the tool, with every link resolved, before any
path shape is read, and the recorded package must own the file. A Node
runtime is never upgraded on an agent's behalf. Nothing elevates: choco,
a global scoop app, an unwritable npm prefix and Nix are reported with
their command. winget and apt stay with `upgrade-host`.

- #4102: answers this promotion's Copilot review. On Linux, npm is asked
before a `.bun` path, as on Windows, and a Nix agent under
`/nix/store/.../node_modules` is read as Nix before the generic npm
shape.

- #4105: answers this promotion's second Copilot round. On Windows,
`Test-ProtectedPath` and `Hide-Home` match only at a path component, so
`C:\Program FilesPortable` is no longer read as protected and a sibling
profile is no longer shortened. The pure path-helper tests now also run
on the native Windows CI runner.

- #4111: answers CodeRabbit's review of this promotion. bun's
`BUN_INSTALL` and `BUN_INSTALL_GLOBAL_DIR` are honored, including bun's
copied Windows shim. A mise shim is followed through `mise which`, and
mise's own listing is asked before any path shape. One herdr post step
runs after every successful upgrade. Scoop's configured roots are read
from its `config.json`.

- #4112: answers this promotion's attested local review. herdr's report
notes now match its post step for a manager-owned herdr.
`install-tools.ps1`'s `Hide-Home` gets #4105's component boundary. One
`Test-PathUnder` helper replaces seven hand-written containment checks.
A dead depth bound is removed.

- #4109, from another hub session: `dotnet-codestyle` now requires a
`global.json` pinning SDK `10.0.100` with `latestFeature` and
`allowPrerelease: false`. It leaves `LangVersion` unset (netstandard
generator projects excepted) and forbids `EnablePreviewFeatures`. The
audit gains the `csharp.sdk.globaljson` check, with a
`catalog/snippets/configs/global.json` snippet and its `spec/files.json`
C# baseline entry. `CODESTYLE.md`'s .NET summary line is updated.
Follow-ups #4106 and #4107 are filed and not in this promotion.

## Pre-existing Findings, Filed

- `host-setup/windows/install-tools.ps1:616` (`pre-existing`,
correctness): `Write-InstallFailure`'s profile replacement in log lines
does not stop at a path component. Filed as #4113.

## Not Verified

- Real package managers. #4095's tests use stub managers on PATH. The
Windows npm, scoop and bun layouts are modeled from their documented
formats and have not been run against real installs. The maintainer's
Windows 11 retest after this release covers the npm-installed opencode
case.

Closes #4103

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants