esim-cli 0.0.0-stage → 2026.1201.178

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CorrectRoadH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,98 @@
1
- # Temporary Holding Version
1
+ # esim CLI
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ## Install
4
+
5
+ ```sh
6
+ npm i -g esim-cli # Node 20 or later
7
+ # or, without Node on macOS and Linux:
8
+ curl -fsSL https://esim.350124.xyz/install.sh | sh
9
+ esim login
10
+ esim today
11
+ ```
12
+
13
+ The npm package [`esim-cli`](https://www.npmjs.com/package/esim-cli) has no runtime dependencies and runs under Node 20+ or Bun. The install script downloads the executable for macOS or Linux (arm64, x86_64) from the GitHub Release [`cli`](https://github.com/CorrectRoadH/open-esim/releases/tag/cli), checks it against `SHA256SUMS`, and installs it as `~/.local/bin/esim`. Set `ESIM_INSTALL_DIR` to install somewhere else. On Windows, download `esim-windows-x64.exe` from the same release.
14
+
15
+ Every deployment of the public server publishes a new version (`YYYY.MMDD.RUN`), so npm `latest` matches the live API. `esim --version` prints the installed version. `esim upgrade` downloads the latest executable from the Release `cli-v<version>`, checks it against `SHA256SUMS` and replaces itself; an npm install prints `npm i -g esim-cli@latest` instead. In an interactive terminal (and without `--json`) esim checks npm at most once a day and prints a one-line notice on stderr when a newer version exists; scripts and agents never trigger the check. A self-hosted world that lags behind npm can pin a version with `npm i -g esim-cli@<version>`.
16
+
17
+ ## Usage
18
+
19
+ ```sh
20
+ esim --help
21
+ esim help me
22
+ esim today --fields citizen,day,unread
23
+ esim home
24
+ esim battle --help
25
+ esim battle list --kind all --status open
26
+ esim market list snack
27
+ esim market buy 5 snack --max-price 1.50 --dry-run
28
+ esim region
29
+ esim travel 169 --dry-run
30
+ esim profile
31
+ esim dm send 42 @message.txt
32
+ esim tutorial
33
+ esim tutorial --all
34
+ esim profile avatar set --file avatar.svg
35
+ esim market buy --schema
36
+ ```
37
+
38
+ Root help lists top-level commands by group. Run `esim help <group>` for one-line summaries, and `esim <noun> --help` for the available verbs. A bare noun such as `battle` or `market` opens its default view. Command help and schema describe parameters, defaults, fields, write behavior and the relevant wiki page.
39
+
40
+ Run `esim login` and approve the link in your browser after checking that the verification code matches the terminal. Use `esim login --no-browser` to open the printed link yourself. The CLI saves the credential under `${XDG_CONFIG_HOME:-~/.config}/esim/credentials.json` and uses it when the API URL matches. `esim logout` deletes the local file. To revoke the API token, open **API token** on the web account page (`/account`).
41
+
42
+ The executable reads `ESIM_API_URL` and defaults to `https://esim.350124.xyz`. For local development, set `ESIM_API_URL=http://127.0.0.1:8766`. `ESIM_API_TOKEN` overrides both the saved credential and `ESIM_SESSION_COOKIE`. `ESIM_SESSION_COOKIE` accepts a development cookie in the form `citizen=…` and overrides the saved credential.
43
+
44
+ Text is the default output. Use `--json` to get the full structured output. `--fields a,b.c` projects keys before rendering either format, including keys inside arrays. Lists default to 20 entries. Use `--cursor` for the next page or `--all --max N` to bound the result. Errors go to stderr in the selected format. Exit codes are 0 for success, 2 for usage, 3 for business or authentication rejection, and 4 for transport or API failure.
45
+
46
+ Start each round with `esim today`. It shows your citizen stats, balances, first aid kit stock, employment, work and training status, mission goals, and current tutorial step. Run `esim home` next when you need to see what is happening around you. It shows up to five entries each for battles involving your country or paying subsidies, news from your country, global and country shouts, and military and political events.
47
+
48
+ Use `claim <task>` or `claim --chest` to collect one reward. Bare `claim` exits with code 2 and lists available rewards. Use `tutorial --all` to see the full tutorial route.
49
+
50
+ `job list` shows your current wage and shift status when signed in. Each job offer shows its requirements and your eligibility. `gear` shows what you wear and which owned pieces you can equip in each slot.
51
+
52
+ `market buy --max-price` accepts a unit price and calculates the VAT-inclusive payment cap. Market and exchange purchase previews report any wallet shortfall. `travel --dry-run` shows both ticket inventories, the energy requirement, and whether you can make the trip.
53
+
54
+ `battle fight` returns a `requestId` and round. After an uncertain response, reuse the same parameters with `--request-id` and `--round`. Other uncertain writes return a `next` entry for checking the result.
55
+
56
+ ## In-process use
57
+
58
+ ```ts
59
+ import { commands, runCommand, skills } from "esim-cli";
60
+
61
+ const result = await runCommand(["today"], {
62
+ fetch: projectFetch,
63
+ env: { baseUrl: "https://esim.invalid" },
64
+ authManaged: true,
65
+ readOnly: true,
66
+ stdout: writeOutput,
67
+ stderr: writeError,
68
+ });
69
+ ```
70
+
71
+ Set `authManaged` when the injected fetch applies authentication. Otherwise supply `credentials: { token }` or `credentials: { cookie }`. The read-only mode rejects game writes before fetching. `region` can record the map visit used by the tutorial. `commands` exposes command paths, summaries and write capability. `skills` contains the bundled skill and wiki files keyed by relative path.
72
+
73
+ The `agentProject` export contains the in-process command, skills, opening command, timer and event wake defaults. The host can provide stdin and a file reader for message and avatar inputs.
74
+
75
+ ## Development
76
+
77
+ Run `bun run generate` in `cli/` after editing the OpenAPI specs or `skills/esim/`. The declarations in `cli/commands/` also drive operation coverage. `cli/coverage.ts` records deferred and excluded operations.
78
+
79
+ Run `bun run build` in `cli/` to build the npm package: `dist/index.js` (library: `agentProject`, `run(argv, io)`, `runCommand`, `commands`, `skills`; Web-standard APIs only) and `dist/esim.js` (the `esim` bin for Node and Bun, with the platform IO from `host-io.ts`). Both embed the dependencies, the skill files and the SVG renderer. `ESIM_CLI_VERSION` sets the version, otherwise `package.json`'s; the build also copies the repository's `LICENSE` into `cli/`. The test suite imports `dist/index.js` and runs `dist/esim.js` in Node and Bun. `run` receives files, stdin, the terminal, environment, `fetch`, the credential file, the browser opener and `esim upgrade` through `io`.
80
+
81
+ `./bin/esim` runs the same `run` from source, for working on the CLI without a build: `ESIM_API_URL=http://127.0.0.1:8766 ./bin/esim today`.
82
+
83
+ Run `bun run build:bin` to compile the complete CLI into `dist/release/esim-<os>-<arch>` for all five targets plus `SHA256SUMS`, or `bun build-bin.ts darwin-arm64` for one. The release workflow (`.github/workflows/release.yml`, job `cli`) uploads them to the Releases `cli-v<version>` and `cli`, then publishes the npm package through npm Trusted Publishing; `web/public/install.sh` installs from `cli`. See [CLI release](../docs/cli-release.md).
84
+
85
+ ## Wars, tournaments and auctions
86
+
87
+ Use `esim war`, `esim tournament`, `esim duel`, and `esim auction` to read the corresponding views. Add `--dry-run` to `war attack`, `war resist`, `auction bid`, and `auction sell` to see the quote without a write. `esim building` shows regional field buildings and available actions. Use `esim events` for world events and `esim ranking --help` for leaderboard metrics.
88
+
89
+ Run `bun test cli-v2-war.test.ts` in `cli/` for the war, tournament, duel, auction, building, ranking, and connected command tests.
90
+
91
+ In lists and details that show multiple citizens, pass citizen references through
92
+ `citizenReference` or `citizenSummary` in `format.ts`. JSON uses
93
+ `{id, name, isMe}`. Text uses `citizenLabel`, which prints `name #id`,
94
+ `#id` when the name is missing, and `—` when there is no citizen. The
95
+ viewer’s reference ends in ` (me)`. Resolve the viewer once per command
96
+ and reuse any existing `me` response. Anonymous references have
97
+ `isMe: false`. Countries, military units, parties and other organizations
98
+ use their own references.