Visitar URL original
Install Codex from Its Windows Installer and Consolidate opencode 2 into One Managed Copy by ptr727 · Pull Request #4162 · ptr727/ProjectTemplate · GitHub
Skip to content

Install Codex from Its Windows Installer and Consolidate opencode 2 into One Managed Copy - #4162

Merged
ptr727 merged 22 commits into
developfrom
codex-windows-install
Nov 13, 2026
Merged

ptr727 merged 22 commits into
developfrom
codex-windows-install

Conversation

@ptr727

@ptr727 ptr727 commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • codex on Windows. The install runs the documented installer, https://chatgpt.com/codex/install.ps1, rather than refusing. Linux already ran the documented install.sh.
  • opencode 2. The Linux installer moves to https://opencode.ai/v2/install, and the npm package to @opencode/cli. opencode 1's opencode-ai is still recognized.
  • One managed copy, opencode only. Linux keeps ~/.opencode/bin/opencode, installed and upgraded by the v2 installer. Windows keeps the npm package @opencode/cli, since the installer is bash only.
  • Another copy is reported, never removed. A copy PATH reaches ahead of the managed one is a stray. The report, --upgrade, and --install name the command that removes it, then --install opencode. While a stray is first on PATH, nothing runs for opencode and the run still exits 0. The maintainer chose this over automatic removal, since the fix is a one-off and automation belongs on the managed path.
  • Shared reads. The upgrade plan and a stray's removal command share the npm and bun resolver and the Homebrew, scoop, and choco reads.
  • Tests. Tests that used opencode as a generic npm, bun, scoop, Homebrew, mise, winget, or choco example now use codex. New tests cover the managed copy and the stray report on both platforms.
  • Follow-up. Consolidate claude and codex Into One Managed Copy in install-agents #4158 tracks declaring a managed copy for claude and codex.

Verification

  • tests/test_install_agents.py, run in Linux Docker with pwsh: 106 of 110 pass. The 4 failures are the mise tests, which fail the same way on unchanged develop in that container and pass in CI.
  • shellcheck, shfmt, PSScriptAnalyzer, markdownlint, cspell, and the prose gate pass. The change adds why-comments, so it carries the comments label.
  • install-agents.ps1 was run natively on Windows with -Report and -Upgrade -DryRun. It reported the host's opencode 1 npm copy with npm uninstall -g opencode-ai, then install-agents.ps1 -Install opencode, and changed nothing.

Local-review findings, introduced

An automatic consolidation was built first, and twelve local passes reviewed it and its replacement. Their findings were fixed, or retired with the removal design itself. One was declined: the managed path ~/.opencode/bin/opencode is fixed, since the v2 installer hard-codes INSTALL_DIR=$HOME/.opencode/bin and reads no override.

Later passes' findings were fixed in 0f79a18, 5a5f128, c6188be, and 4e91618. A second was declined: Test-ManagedTool's ContainsKey guard is required, since under Set-StrictMode -Version Latest reading a missing hashtable key throws "The property 'Managed' cannot be found on this object", checked with pwsh -NoProfile -c 'Set-StrictMode -Version Latest; $h=@{}; $h.Managed'.

The sixteenth pass's findings were fixed in b22de45 and cf2f952. A third was declined: a scheduled Linux run judges strays on its own PATH, where ~/.opencode/bin is appended. A copy genuinely ahead of it there is reported with its removal, and nothing fails silently or destructively, so GOVERNANCE.md "Trust Boundaries and Hardening Effort" gives it no further code.

Later passes' findings were fixed through 84b50e3, and the twenty-first pass over the final head raised none. No local-review finding is open.

🤖 Generated with Claude Code

ptr727 and others added 4 commits November 13, 2026 09:24
…nto One Managed Copy

codex documents a Windows installer at https://chatgpt.com/codex/install.ps1, so the Windows install
runs it rather than refusing. Linux already ran the documented install.sh.

opencode 2 moved its installer to https://opencode.ai/v2/install and its npm package to
@opencode/cli. Its installer is bash only, so the managed copy is ~/.opencode/bin/opencode on
Linux and the npm package @opencode/cli on Windows. Any other opencode copy PATH reaches first,
opencode 1's npm opencode-ai among them, is consolidated the way install-tools consolidates a
shadowing copy: the report names it, and --upgrade removes it through npm, bun, Homebrew, or
scoop after a prompt and installs the managed copy. A copy only an elevated shell or its owner
can remove is reported with its command. The record is per tool, and only opencode declares one.

Tests that used opencode as a generic npm, bun, scoop, Homebrew, mise, winget, or choco example
now use codex, and new tests cover the consolidation on both platforms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Copy That Stays

Consolidation now reads whether the managed copy can install before it removes anything, so a host is never left without opencode. A copy this script cannot remove, or whose removal is declined, stays and is upgraded where it is, as before, rather than failing every run. The report and messages name what owns a copy that stays. The scoop, choco, Homebrew, and npm-install reads are shared between the upgrade and the consolidation. Windows tests now run a real removal and the unreachable managed package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Managed Install Landed

One npm and bun resolver now serves the upgrade and the consolidation on Linux, and one owning-package lookup serves both on Windows. A stray opencode-ai copy that stays is therefore upgraded as opencode-ai rather than refused as not @opencode/cli. A removal is listed among the changes, an installer that finishes without the managed copy in place fails the tool, and the install-tools cross-references name only the Linux script, which is the one that behaves that way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ptr727 ptr727 added script A defect in hub tooling comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses labels Nov 13, 2026
Copilot AI lite review requested due to automatic review settings November 13, 2026 17:54
@ptr727 ptr727 added script A defect in hub tooling comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses labels Nov 13, 2026
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 702a605 and 84b50e3.

Files selected for processing: 6

  • docs/host-setup.md
  • host-setup/linux/README.md
  • host-setup/linux/install-agents.sh
  • host-setup/windows/README.md
  • host-setup/windows/install-agents.ps1
  • tests/test_install_agents.py
  • 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

@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

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

…Prefix Before an npm Removal

A consolidation can remove one stray and then meet one it cannot remove, so the caller now reads the path again rather than acting on the removed copy. On Windows an npm removal is planned only for files under the prefix of the npm on PATH, as the upgrade plan already required. The Windows consolidation comment no longer claims install-tools.ps1 behavior it lacks. Tests cover --install replacing a stray with no managed copy, two stacked strays, and a shim outside the npm prefix.

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

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.

🟡 Changes recommended

Approval is blocked by an unsafe npm ownership check, a misleading implementation reference, and missing test coverage for consolidation when no managed copy exists.

3 open issues
What changed in this PR

Adds Windows installation support for Codex and consolidates opencode installations into one managed copy per platform.

Changes:

  • Installs Codex on Windows through its documented PowerShell installer.
  • Uses opencode 2 sources and managed-copy paths on Linux and Windows.
  • Adds consolidation, ownership checks, reporting, documentation, and platform-specific test coverage.
File Description
tests/​test_install_agents.py Updates installer and package-manager fixtures and adds Linux and Windows coverage for opencode consolidation and Codex installation.
host-setup/​windows/​README.md Documents Windows Codex installation and managed opencode behavior.
host-setup/​windows/​install-agents.ps1 Adds the Codex installer, managed npm opencode support, consolidation logic, and shared manager resolution.
host-setup/​linux/​README.md Documents Linux opencode managed-copy installation and consolidation behavior.
host-setup/​linux/​install-agents.sh Adds managed opencode detection, consolidation, installation, upgrades, and shared package-manager resolution.
docs/​host-setup.md Updates the cross-platform host setup contract for managed agent copies and consolidation.

Review effort: Lite

Comment thread host-setup/windows/install-agents.ps1 Resolved
Comment thread tests/test_install_agents.py Resolved
Comment thread host-setup/windows/install-agents.ps1 Resolved
ptr727 and others added 2 commits November 13, 2026 10:04
…rt's Install Claim

Where the managed npm package cannot be installed, the Windows message now names the stray's removal too, since an npm copy in the same prefix holds the shim the managed package needs. The report says the managed copy is installed only unless another copy PATH reaches stays. The docs drop a comparison with install-tools.sh that described a different mechanism. A Linux test now runs the managed installer for real and checks the copy landed, and another checks that an installer leaving none fails the tool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… It Blocks, and Fit Tests to Any Host

Windows now has one npm and bun step for the upgrade and the consolidation, as Linux's package_step. A refused managed install names the stray's removal only for an npm copy, the one whose shim blocks it. The docs say which owners consolidation removes through and that --yes answers its prompt. The tests that need curl or npm absent are skipped where /usr/bin or /bin provides one, and a function-level test covers the curl refusal on every host.

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

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

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

…e npm Prefix, and Test That a Refusal Removes Nothing

Where npm or bun cannot say which package owns a stray, its command names the package the path or the shim shows, so an opencode-ai copy is never told to remove @opencode/cli. A refused managed install names a stray's removal only for one in the prefix of the npm on PATH. A function-level test now proves a refused install removes nothing on any host, the unwritable-prefix Windows test skips under root, the docs pair --yes with -Yes, and the script headers say what opencode is an exception to.

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

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.69%. Comparing base (b38e084) to head (84b50e3).
⚠️ Report is 201 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4162      +/-   ##
===========================================
- Coverage    81.60%   76.69%   -4.92%     
===========================================
  Files           26       41      +15     
  Lines         9070    14300    +5230     
===========================================
+ Hits          7402    10967    +3565     
- Misses        1668     3333    +1665     
Flag Coverage Δ
python-3.13 76.69% <ø> (-4.92%) ⬇️

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.

…Copy and Confirm PATH Reaches the Installed Package

A stray that stays is upgraded through its owner where that runs and reported where it does not, Nix and choco among the second, so the help, headers, READMEs, and docs now say it is handled as a tool without a managed copy is. On Windows, a managed package installed where PATH does not reach it now fails the tool, as the upgrade and install paths already did.

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

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

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

ptr727 and others added 4 commits November 13, 2026 10:42
…e the Fix for an Unreached Managed Package

Consolidation now reads every copy PATH holds ahead of the managed one before its first removal, and removes nothing where any of them is one it cannot remove. A removal therefore never leaves an older copy this script cannot touch answering instead. On Windows, one reason for a managed package PATH does not reach tells an npm prefix missing from PATH apart from a missing shim, and both checks give it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Per the maintainer's direction, the scripts no longer remove another opencode copy. A copy PATH reaches ahead of the managed one is reported with the command that removes it and the follow-up install, and the fix is left to a person since it is a one-off. --upgrade still upgrades the managed copy where one is installed, and --install installs it only once no other copy is in the way. The removal ordering, blocker, refusal, and reach checks that consolidation needed are gone with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Upgrade Beside It

While another opencode copy is first on PATH, --upgrade and --install now only report the fix, removal then --install, and touch nothing. That drops the managed upgrade beside a stray, with its version misreport, its Windows npm refusal helper, and its managed-presence check, and restores opencode's original Upgrade entry on Windows. One builder now makes the node_modules search string, and a by-hand delete is worded as an instruction rather than a command that would not run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pm Cannot Say, and Drop opencode's Dead Upgrade

On Windows the managed copy is now the recorded package's shim inside the prefix of the npm on PATH, so a stale shim elsewhere naming it is reported as a stray. Where npm cannot say where it installs, no copy is called a stray, so the managed shim is never reported as one of itself. The Managed record names only the manager and reads the package from Get-NpmPackage, and the opencode Upgrade entry nothing could reach is gone. The docs say how each managed copy is upgraded.

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

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

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

ptr727 and others added 2 commits November 13, 2026 11:25
…e by the Recorded Package Name

On Windows the exemption for an npm that cannot report its prefix now covers only an npm copy, so a self, bun, or scoop copy is still a stray. That keeps a self-installed copy from reaching the dropped Upgrade entry and ending the run. An upgrade names the recorded package on both platforms, and only a removal falls back to the name the path shows, so no instruction reinstalls opencode 1. The Windows help, README, and docs name the exemption.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Shim Apart Without npm

An upgrade now matches only the recorded npm package on both platforms, and only a removal also matches a name the tool shipped under earlier, as the comments now say. On Windows, where npm cannot report its prefix, a shim whose text names opencode-ai is still a stray with its removal named, so the printed fix can be followed. The managed-shim test skips where a host npm in /usr/bin or /bin would answer.

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

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

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

…thing Reads

Where npm is on PATH but reports no prefix or root, a stray's removal now says so and names the package the path shows, rather than claiming the files sit outside a prefix npm never gave. An upgrade keeps its existing message. The Windows Managed record is a marker read through Test-ManagedTool, since every reader treats the managed copy as the recorded npm package. Unused locals and a case nothing reaches are gone, one test regains coverage it had lost to a misplaced skip, and a stale test comment is corrected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he No-Root Removal

The Windows managed opencode is the npm package, so nothing writes ~/.opencode/bin there, and appending it let a leftover copy from a Git Bash install read as a stray ahead of the managed shim in a scheduled run. The Linux test for a removal npm cannot resolve now stubs an npm that reports no root, covering the branch that names the package from the path, and needs no host skip. A test helper's comment now says what PATH order actually does.

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

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

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

ptr727 and others added 2 commits November 13, 2026 12:01
The Linux upgrade plan and a stray's removal now share one mise step, as they already share the Homebrew and scoop steps. A copy inside mise's Node is therefore told to be removed where it was installed, never to run mise unuse -g core:node, which would remove the user's Node runtime. Two Windows no-prefix tests use a stub npm rather than skipping on a host npm, and a Windows helper comment says it returns any of the tool's names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Splitting the comment left its second line at column 0 inside the function body.

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

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

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

ptr727 and others added 2 commits November 13, 2026 12:14
… Package in One Place

The docs and the Linux help now say the managed opencode on Linux is upgraded by running its installer again, the second exception to driving each tool's own updater. The docs' no-prefix sentence says npm copy, as the Windows help and README do. The Windows opencode Source and Install read the package from Get-NpmPackage, the name every stray check already uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Not Run

The opencode sentence placed between cswap's exception and its reason made that reason read as opencode's, and the paragraph already states the Linux upgrade route later. A Windows bun test now checks that codex update, the updater codex actually has, was not run.

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

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 35f678147deff282519833b918adbc311641d40b, the content this pull request carries at that commit against develop, and it recorded 1 finding.

The Homebrew and mise steps that used it moved into brew_step and mise_step.

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

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

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

@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

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 a25ac13 into develop Nov 13, 2026
13 checks passed
@ptr727
ptr727 deleted the codex-windows-install branch November 13, 2026 20:51
ptr727 added a commit that referenced this pull request Nov 13, 2026
… Rules (#4189)

## Summary

Promotes the backlog-burndown rounds and changes from other hub sessions
from `develop` to `main`.

- Hooks and the prose gate: #4132, #4134, #4136, #4145, #4152, #4184.
The Husky hook reads its path list once and diffs a merge against
`MERGE_HEAD`. Interrupts re-raise their signal, a Markdown code span
reads as quoted data, and the gate picks a commit's diff base and
recognizes a conflicted promotion's branch cut from `main`.
- Procedures and carried rules: #4133, #4139, #4141, #4149, #4166,
#4177, #4179, #4183, #4185. Resync, audit and check-this-repo procedure
gaps, code style and shell interrupt rules, review-loop gaps across four
skills, the context and delegation section of `AGENTS.md`, question
rules in governance, the promotion line in pull request bodies,
closing-keyword behavior on promotion, and the history-rewrite premise.
- Review and cleanup tooling: #4138, #4148, #4154, #4156, #4157, #4163,
#4164, #4168, #4174, #4180. Cleanliness reads, parked handoffs, the
backlog report's JSON output, exact inline script pins, trusted inputs,
env-file includes, the bounded review wait, side-reviewer matching, and
a Copilot billing-failure notice read as a refusal.
- Workflow and runbook contract: #4153, #4155, #4169, #4171, #4178,
#4182. The runtime-secrets check, a registry entry and spec references,
the Copilot runbook pointers, credential-free checkout steps, and the
deploy-key and runner wording.
- From other hub sessions: #4159 (a repository's own .NET line under a
fleet default), #4161 (the 1Password CLI as an optional host tool),
#4162 (Codex's Windows installer and one managed opencode copy). These
carry no promotion line.

#4182 carries no promotion line by design, and #4175 holds the split-out
part of #4057's scope. Both #1448 and #4175 stay open.

Fixes #1071
Fixes #1154
Fixes #1391
Fixes #1471
Fixes #1594
Fixes #1620
Fixes #1627
Fixes #1650
Fixes #1801
Fixes #2853
Fixes #3620
Fixes #3668
Fixes #3697
Fixes #3766
Fixes #3787
Fixes #3837
Fixes #3840
Fixes #3842
Fixes #3844
Fixes #3865
Fixes #3882
Fixes #3890
Fixes #3894
Fixes #3912
Fixes #3916
Fixes #3954
Fixes #4014
Fixes #4015
Fixes #4016
Fixes #4043
Fixes #4050
Fixes #4057
Fixes #4058
Fixes #4062
Fixes #4084
Fixes #4097
Fixes #4098
Fixes #4099
Fixes #4104
Fixes #4108
Fixes #4114
Fixes #4115
Fixes #4117
Fixes #4118
Fixes #4119
Fixes #4121
Fixes #4122
Fixes #4123
Fixes #4131
Fixes #4135
Fixes #4140
Fixes #4142
Fixes #4143
Fixes #4144
Fixes #4151

🤖 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 script A defect in hub tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants