Skip to content

feat(wpm): point git at niugit, and find a shim payload wherever its mapping puts it - #1252

Merged
caomengxuan666 merged 2 commits into
mainfrom
feat/wpm-package-alias
Oct 19, 2026
Merged

caomengxuan666 merged 2 commits into
mainfrom
feat/wpm-package-alias

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Implementing the git → niugit forwarding part of #1218, plus the payload lookup that the codex package will need. This is the wpm half; the index half follows in unixwin/wpm-source after a release carries this, because an alias_of entry seen by an older wpm reads as "metadata-only (no current-arch artifact)" — an entry with no artifact is only meaningful to a wpm that understands why.

Why a package alias and not just deleting git

The index has two entries claiming commands: ["git"]:

entry version source layout
git 2.55.0.5 upstream MinGit (git-for-windows) shim
niugit 2.56.0.1 our flat niu-git build flat

So which git a user gets today depends on which name they typed. Deleting the git entry removes the wrong one but also removes the name people type; an alias keeps the name and pins it to niu-git. The same shape exists for awk/gawk in the index (a awk package still points at the pre-prune mirror build) — not touched here, reported instead.

What alias_of does

  • Resolution happens before anything looks at artifacts, so an alias entry needs no artifacts, files or sha256.
  • Guards: depth bound (kMaxPackageAliasDepth), cycle detection whose message shows the loop (wpm: 'loop-a' is part of an alias cycle: loop-a -> loop-b -> loop-a), a missing target that names both ends, and one index refresh so a target added since the cache was written is still found.
  • Presentation: wpm install git prints wpm: 'git' is provided by 'niugit'; wpm info git shows Alias of: niugit (alias_of in --json); wpm list labels it alias rather than index-only; install --json reports the requested name with alias_of.

Second commit: the shim payload is found wherever its mapping puts it

create_package_shims wrote the forwarder's map from the opt/<pkg>/<command>.exe convention alone. A shim package whose payload must keep its own directory layout — codex ships bin/codex.exe beside codex-resources/, which the executable resolves relative to itself — would have got a map entry pointing at a file that does not exist, and the forwarder would refuse to start it.

The artifact's files mapping is consulted when the convention misses, which is what the entry links for flat layouts have always done. Convention first, mapping second, so nothing that works today changes.

Verification

  • wpm_install_follows_a_package_alias: a fixture where git → target installs the target, prints the forwarding, and info git shows the alias.
  • wpm_install_rejects_alias_cycles_and_missing_targets: loop-a/loop-b fails with the loop spelled out; a dangling alias fails naming the missing package.
  • wpm_shim_map_points_at_a_non_conventional_payload: a package mapping its payload to bin/tool.exe gets a map entry pointing there.
  • wpm.* 72/72.

Sequence

  1. this PR → a WinuxCmd release carries it;
  2. then unixwin/wpm-source: drop the MinGit artifact and keep git as {"alias_of": "niugit"}, so wpm install git keeps working and installs niu-git;
  3. the codex wpm package (in progress) relies on both.

The index carries one name per tool in most cases, but `git` and `niugit` both
declared `commands: ["git"]`, so which git a user got depended on which entry
they happened to pick - and the `git` entry is the upstream MinGit this stack
does not want. An entry that only forwards removes the choice without removing
the name: `wpm install git` installs niu-git and says so
(#1218).

- `alias_of` on a package makes wpm resolve it before anything looks at
  artifacts (an alias has none on purpose), with a depth bound, a cycle
  detector whose message shows the loop (`loop-a -> loop-b -> loop-a`), a
  missing-target error that names both packages, and one index refresh in
  between so a stale cache cannot hide a target that was just added.
- `wpm info` shows `Alias of: <target>` (and `alias_of` in `--json`), and
  `wpm list` labels such an entry `alias` instead of `index-only`.
- `wpm install git --json` reports the requested name plus `alias_of`.

Tests: `wpm_install_follows_a_package_alias` (installs the target, reports the
forwarding, `info` shows it) and
`wpm_install_rejects_alias_cycles_and_missing_targets`. `wpm.*` 71/71.

The index side (dropping the upstream MinGit artifact and pointing `git` at
`niugit`) follows in unixwin/wpm-source once a release carries this.
The forwarder's map was written from the `opt\<pkg>\<command>.exe` convention
alone, so a shim package whose payload has to keep its own layout - codex ships
`bin/codex.exe` beside `codex-resources/`, which the executable resolves
relative to itself - would get a map entry pointing at a file that does not
exist, and the forwarder would refuse to start it.

Look in the artifact's `files` mapping when the convention misses, which is what
the entry links for flat layouts have always done. Convention first, mapping
second, so nothing that works today changes.

Test: `wpm_shim_map_points_at_a_non_conventional_payload` installs a shim
package mapping its payload to `bin/tool.exe` and asserts the map points there.
@caomengxuan666 caomengxuan666 changed the title feat(wpm): a package can be an alias for another one (git -> niugit) feat(wpm): point git at niugit, and find a shim payload wherever its mapping puts it Oct 19, 2026
@caomengxuan666
caomengxuan666 merged commit 8c19d14 into main Oct 19, 2026
8 checks passed
@caomengxuan666
caomengxuan666 deleted the feat/wpm-package-alias branch October 19, 2026 08:07
caomengxuan666 added a commit to unixwin/wpm-source that referenced this pull request Oct 19, 2026
`wpm install codex` installs the canonical package zip of the niu build of
OpenAI Codex: `bin/codex.exe` keeps `codex-resources/` and `codex-path/` beside
itself, so the sandbox helpers resolve exactly as they do in the npm platform
package. `layout: shim` keeps the payload (and the ~300 MB executable) out of a
directory on %PATH%.

The asset is the canonical zip npm published as `@cmx666/[email protected]`, attached
to unixwin/codex's `codex-v0.1.0` release (sha256 e44c2cac…, 128,074,227 bytes).
Releases update this entry automatically from now on
(scripts/niu/update-wpm-index.ps1 in unixwin/codex, which refuses to map a file
the archive does not carry).

Note for the command to resolve on an existing installation: wpm needs the
payload-from-mapping lookup that landed in unixwin/WinuxCmd#1252 (shim payloads
are not always at opt/<pkg>/<cmd>.exe), so this needs a WinuxCmd release that
carries it.

Co-authored-by: caomengxuan666 <[email protected]>
caomengxuan666 added a commit to unixwin/codex that referenced this pull request Oct 19, 2026
)

* feat(release): publish @unixwin/codex, ship the wpm package, keep the index current

Three things the org needs from this repository, in one place.

**The npm scope moves to the org.** `@cmx666/codex` becomes `@unixwin/codex`
(40 references across the workflow, both package scripts, `codex.js`'s platform
map / install hints / self-detection path, `RELEASE.md` and the verifier). The
`unixwin` npm org exists, so the next publish goes there; the old package stays
published and gets deprecated pointing at the new name.

**The canonical zip becomes a release asset.** `wpm` needs a versioned URL, not
a workflow artifact (those need auth and expire), so the zip this job already
builds is attached to a `codex-v<version>` pre-release. The index points at it,
so the move and the rename have to land before the next publish.

**The WPM index updates itself.** `scripts/niu/update-wpm-index.ps1` creates or
rewrites the `codex` entry in unixwin/wpm-source - `layout: shim`,
`commands: ["codex"]`, and a mapping that keeps `bin/codex.exe` beside
`codex-resources/` and `codex-path/` so the executable resolves its helpers
exactly as in the npm platform package. It refuses to write an index that maps a
file the archive does not carry, which is the failure that let a package ship
without its payload once already (unixwin/WinuxCmd#1225). The workflow step
clones wpm-source, runs it, opens the PR and merges it; without
`WPM_SOURCE_TOKEN` it warns and skips instead of failing a good npm release.

Verified on the `unixwin` side too: wpm now resolves a shim payload from the
artifact's `files` mapping when it is not at the `opt/<pkg>/<cmd>.exe`
convention (unixwin/WinuxCmd#1252), which is what makes `bin/codex.exe` work.

Fixtures: the script creates the entry on first run (real size and digest, urls
on unixwin/codex), is idempotent, and refuses an archive missing a mapped
directory. Workflow YAML parses; `codex.js`, `build_npm_package.py` and the
verifier pass their syntax checks.

* docs(npm): ship our README in the published package, keep the official one in the repo

The npm package staged `README.md` from the repository root, so npmjs showed
upstream's README - correct for the repository, misleading as the front page of
an unofficial build. The stager now prefers `README-niu.md` when it exists, and
that file says what this build is, how to install it (`@unixwin/codex`, or
`wpm install codex` inside the niu stack), what differs, and that the official
README still applies. Nothing in the repository's own README changes, so upstream
merges stay clean.

Verified by staging the meta package: `stage/README.md` is this file.
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