@one2x/merouter 0.1.2-darwin-x64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,186 @@
1
+ # @one2x/merouter
2
+
3
+ Unified CLI for managing and routing across multiple AI model providers, shipped as an npm-installable wrapper around a native Rust binary.
4
+
5
+ ```bash
6
+ npm install -g @one2x/merouter
7
+ merouter --help
8
+ ```
9
+
10
+ Works on macOS (x64, arm64), Linux (x64, arm64), and Windows x64. `npm`/`pnpm`/`yarn`/`bun` all supported.
11
+
12
+ ---
13
+
14
+ ## How it works
15
+
16
+ The installed `merouter` command is a thin Node.js shim. On first invocation, it:
17
+
18
+ 1. Detects your OS + architecture.
19
+ 2. Locates the native Rust binary that npm already fetched as part of the install (via `optionalDependencies`).
20
+ 3. Spawns the binary with your argv, forwards signals, and mirrors the exit code.
21
+
22
+ There is **no post-install download step** — binaries are regular npm payloads, so `npm install --ignore-scripts`, offline installs, and air-gapped CI all work.
23
+
24
+ ### Publishing model
25
+
26
+ All artifacts ship under the single npm name `@one2x/merouter`, distinguished by a **platform-tagged version**:
27
+
28
+ | Version | Contents |
29
+ | -------------------- | ------------------------------------------------------------------------ |
30
+ | `0.1.2` | JS shim + `optionalDependencies` pointing at the platform versions below |
31
+ | `0.1.2-linux-x64` | just `vendor/x86_64-unknown-linux-gnu/merouter/merouter` |
32
+ | `0.1.2-linux-arm64` | `vendor/aarch64-unknown-linux-gnu/...` |
33
+ | `0.1.2-darwin-x64` | `vendor/x86_64-apple-darwin/...` |
34
+ | `0.1.2-darwin-arm64` | `vendor/aarch64-apple-darwin/...` |
35
+ | `0.1.2-win32-x64` | `vendor/x86_64-pc-windows-msvc/merouter/merouter.exe` |
36
+
37
+ The main package's `optionalDependencies` use npm's `npm:` alias syntax to reference each platform version while exposing a stable virtual package name:
38
+
39
+ ```jsonc
40
+ "optionalDependencies": {
41
+ "@one2x/merouter-linux-x64": "npm:@one2x/merouter@0.1.2-linux-x64",
42
+ "@one2x/merouter-linux-arm64": "npm:@one2x/merouter@0.1.2-linux-arm64",
43
+ "@one2x/merouter-darwin-x64": "npm:@one2x/merouter@0.1.2-darwin-x64",
44
+ "@one2x/merouter-darwin-arm64":"npm:@one2x/merouter@0.1.2-darwin-arm64",
45
+ "@one2x/merouter-win32-x64": "npm:@one2x/merouter@0.1.2-win32-x64"
46
+ }
47
+ ```
48
+
49
+ Each platform version sets `os` and `cpu` in its manifest, so npm skips the non-matching ones automatically (standard `optionalDependencies` behavior). The shim resolves the right one via `require.resolve('@one2x/merouter-linux-x64/package.json')`.
50
+
51
+ ### Platform tag → `dist-tag`
52
+
53
+ Each platform version is published under a matching `dist-tag` (e.g. `linux-x64`, `darwin-arm64`) so it doesn't overwrite `latest`. Only the main package gets `latest` (or `next` for pre-releases).
54
+
55
+ ---
56
+
57
+ ## Layout
58
+
59
+ ```
60
+ packages/merouter/
61
+ ├── src/
62
+ │ ├── bin.ts # runtime shim entry (TypeScript source)
63
+ │ ├── binary-resolver.ts # resolves the native binary path
64
+ │ ├── package-manager.ts # detects bun vs npm for hints / env
65
+ │ ├── spawn-child.ts # spawn + signal forwarding + exit handling
66
+ │ └── utils/
67
+ │ └── platforms.ts # single source of truth for target triples
68
+ ├── bin/ # compiled JS (generated by `pnpm build`, gitignored)
69
+ │ └── bin.js
70
+ ├── scripts/
71
+ │ └── stage/ # publish-time stager (runs via tsx)
72
+ │ ├── main.ts # entry
73
+ │ ├── args.ts # node:util parseArgs wrapper
74
+ │ ├── fs-utils.ts # ensureEmptyDir, unpackArchive
75
+ │ ├── npm-pack.ts # npm pack wrapper
76
+ │ ├── stage-platform.ts # stages one platform tarball
77
+ │ └── stage-main.ts # stages the main (shim) tarball
78
+ ├── package.json # source template (version = release version)
79
+ ├── tsconfig.json
80
+ ├── project.json # Nx config
81
+ └── README.md
82
+ ```
83
+
84
+ ---
85
+
86
+ ## Development
87
+
88
+ ### Dependencies
89
+
90
+ ```bash
91
+ pnpm install
92
+ ```
93
+
94
+ ### Typecheck + build the shim
95
+
96
+ ```bash
97
+ pnpm --filter @one2x/merouter build
98
+ # or via Nx
99
+ nx run merouter:build
100
+ ```
101
+
102
+ ### Local smoke-test of the shim
103
+
104
+ After the Rust CLI is built, place the binary where the shim's dev fallback expects it:
105
+
106
+ ```bash
107
+ # From repo root:
108
+ nx run cli:build
109
+ mkdir -p packages/merouter/vendor/x86_64-unknown-linux-gnu/merouter
110
+ cp cli/target/release/merouter-cli \
111
+ packages/merouter/vendor/x86_64-unknown-linux-gnu/merouter/merouter
112
+ chmod +x packages/merouter/vendor/x86_64-unknown-linux-gnu/merouter/merouter
113
+
114
+ # Run the shim directly:
115
+ pnpm --filter @one2x/merouter build
116
+ node packages/merouter/bin/bin.js --help
117
+ ```
118
+
119
+ (Adjust the target triple to your host OS/arch.)
120
+
121
+ ---
122
+
123
+ ## Maintainer: cutting a release
124
+
125
+ From the repo root:
126
+
127
+ ```bash
128
+ pnpm release vX.Y.Z
129
+ # or directly:
130
+ pnpm tsx scripts/publish.ts vX.Y.Z
131
+ ```
132
+
133
+ The script (`scripts/publish.ts`):
134
+
135
+ 1. **Preflight** — refuses to run unless:
136
+ - on `main` branch (override: `--skip-branch-check`)
137
+ - working tree clean (override: `--allow-dirty`)
138
+ - tag `vX.Y.Z` does not already exist
139
+ - requested version > current `cli/Cargo.toml` version
140
+ - `cli/Cargo.toml` and `packages/merouter/package.json` versions are already in sync
141
+ 2. **Bumps** the version in:
142
+ - `cli/Cargo.toml` (`[package] version`)
143
+ - `cli/Cargo.lock` (via `cargo update -p merouter-cli --precise`)
144
+ - `packages/merouter/package.json` (`version` + all 5 `npm:` aliases under `optionalDependencies`)
145
+ 3. **Commits** all three files as `chore(release): merouter vX.Y.Z`
146
+ 4. **Tags** `vX.Y.Z` (annotated)
147
+ 5. **Does NOT push** — review the commit first, then:
148
+
149
+ ```bash
150
+ git push origin main --follow-tags
151
+ ```
152
+
153
+ Pushing the tag triggers `.github/workflows/cli-release.yml`, which:
154
+
155
+ - Builds Rust binaries for all 5 targets
156
+ - Creates a GitHub Release with the tarballs
157
+ - Builds the TS shim
158
+ - Stages 6 npm tarballs via `packages/merouter/scripts/stage/main.ts`
159
+ - Publishes each to npm with OIDC + the correct `--tag` per platform
160
+
161
+ ### Dry run
162
+
163
+ To preview without touching git or files:
164
+
165
+ ```bash
166
+ pnpm tsx scripts/publish.ts vX.Y.Z --dry-run --allow-dirty
167
+ ```
168
+
169
+ ### npm trusted publishing (one-time setup)
170
+
171
+ This repo uses OIDC-based trusted publishing (no `NPM_TOKEN` secret). To configure:
172
+
173
+ 1. Sign in to [npmjs.com](https://www.npmjs.com/) as an `@one2x` org owner.
174
+ 2. For the `@one2x/merouter` package: **Settings → Trusted Publishers → Add publisher** with:
175
+ - Provider: **GitHub Actions**
176
+ - Organization: `one2x`
177
+ - Repository: `merouter`
178
+ - Workflow filename: `cli-release.yml`
179
+ - Environment: _(leave blank)_
180
+ 3. Initial publish (for any package that doesn't yet exist on npm) must be done with `npm publish --access public` from a logged-in session; OIDC can only be configured on an existing package.
181
+
182
+ ### Version bump mechanics
183
+
184
+ Steps 1-2 above are fully automated by `scripts/publish.ts`. The 5
185
+ `optionalDependencies` entries, the main `version` field, and
186
+ `Cargo.toml` + `Cargo.lock` are all kept in sync atomically in one commit.
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@one2x/merouter",
3
+ "version": "0.1.2-darwin-x64",
4
+ "license": "SEE LICENSE IN LICENSE",
5
+ "description": "merouter CLI native binary for darwin/x64.",
6
+ "os": [
7
+ "darwin"
8
+ ],
9
+ "cpu": [
10
+ "x64"
11
+ ],
12
+ "files": [
13
+ "vendor",
14
+ "README.md"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/one2x/merouter.git",
19
+ "directory": "packages/merouter"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public",
23
+ "provenance": true
24
+ }
25
+ }