@amdahl/cli 0.1.0

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.
Files changed (3) hide show
  1. package/README.md +126 -0
  2. package/dist/amdahl.js +17905 -0
  3. package/package.json +48 -0
package/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # @amdahl/cli
2
+
3
+ The `amdahl` command line. It signs you in with your console account, checks
4
+ that a workspace can optimize, rewrites messages, manages API keys (each one
5
+ approved in the console), and points MCP clients at Amdahl.
6
+
7
+ ## Install
8
+
9
+ Needs Node.js 20 or later.
10
+
11
+ ```sh
12
+ # Run once, with no install
13
+ npx @amdahl/cli login
14
+
15
+ # Or install the `amdahl` command
16
+ npm i -g @amdahl/cli
17
+ amdahl login
18
+ ```
19
+
20
+ ## Quick start
21
+
22
+ ```sh
23
+ amdahl login # sign in through the browser with your console account
24
+ amdahl whoami # the account, workspace and role you are signed in as
25
+ amdahl status # can this workspace optimize, and what blocks it
26
+ amdahl optimize draft.md # rewrite one message (or pipe it in with -)
27
+ amdahl install claude-code # point an MCP client at Amdahl (also codex, cursor)
28
+ ```
29
+
30
+ No workspace yet? `amdahl login` prints the console link where you can
31
+ create one or join the beta. The CLI never creates or joins a workspace.
32
+
33
+ On a server or in CI, skip `login` and set an API key in `AMDAHL_KEY`.
34
+
35
+ ## Commands
36
+
37
+ ```
38
+ amdahl login [--workspace <slug>] [--no-browser] [--port <n>] (alias: auth login)
39
+ amdahl logout [--all] (alias: auth logout)
40
+ amdahl whoami [--show-token] (alias: auth status)
41
+ amdahl auth token
42
+ amdahl status
43
+ amdahl optimize [<file>... | -] [--channel email|linkedin] [--evidence off|workspace]
44
+ [--on-unsupported flag|remove] [--tries] [--context <file.json>]
45
+ amdahl keys create --name <name> [--preset read-only|agent|internal|admin] [--expires 30d|90d|365d] [--no-browser]
46
+ amdahl keys list
47
+ amdahl keys revoke <id|prefix> [--yes] [--no-browser]
48
+ amdahl workspace list | amdahl workspace use <profile>
49
+ amdahl install claude-code|codex|cursor [--print]
50
+ ```
51
+
52
+ Global flags: `--profile`, `--api-url`, `--api-key`, `--json`, `--no-color`,
53
+ `-h`, `-v`. With `--json`, data goes to stdout and messages to stderr.
54
+
55
+ ## Targeting staging
56
+
57
+ ```sh
58
+ AMDAHL_API_URL=https://staging.amdahl.ai amdahl login
59
+ # or: amdahl login --api-url https://staging.amdahl.ai
60
+ ```
61
+
62
+ A profile remembers its API host, so later commands need no flag. A profile's
63
+ token is only ever sent to that host. Messages that link to the console use
64
+ `AMDAHL_CONSOLE_URL` when set, otherwise the console for the known API host
65
+ (`staging.amdahl.ai` -> `https://stagingui.amdahl.ai`, otherwise
66
+ `https://console.amdahl.ai`).
67
+
68
+ ## Credentials
69
+
70
+ Highest first: `--api-key`, `AMDAHL_KEY`, `AMDAHL_API_KEY`,
71
+ `AMDAHL_ACCESS_TOKEN`, then the stored sign-in (`--profile`, `AMDAHL_PROFILE`,
72
+ the default profile). `whoami` names the source that won. `keys create`,
73
+ `keys revoke` and `auth token` need the stored sign-in and exit 4 otherwise.
74
+
75
+ - Config: `${XDG_CONFIG_HOME:-~/.config}/amdahl/config.json` (mode 0600). No
76
+ tokens.
77
+ - Tokens: the OS keychain (service `amdahl-cli`; macOS `security`, Linux
78
+ `secret-tool`), passed on stdin, never on argv. Without a keychain:
79
+ `credentials.json` (mode 0600) with a one-time warning.
80
+ `AMDAHL_CREDENTIAL_STORE=keychain|file` forces either.
81
+
82
+ ## Keys
83
+
84
+ `keys create` generates the key on your machine and sends only its sha256 hash
85
+ and 14-character prefix. You approve the request in the console by typing the
86
+ code shown in the terminal; then the key is printed once and stored nowhere.
87
+
88
+ ## Exit codes
89
+
90
+ | code | meaning |
91
+ |---|---|
92
+ | 0 | ok |
93
+ | 1 | general (`login_timeout`, `state_mismatch`, optimize `ok: false`) |
94
+ | 2 | usage |
95
+ | 3 | not signed in (401, `invalid_grant`, no credential) |
96
+ | 4 | forbidden (403, `oauth_required`, `cli_client_required`, `not_admin`) |
97
+ | 5 | no workspace |
98
+ | 6 | rate limited or quota (429) |
99
+ | 7 | approval denied, expired or locked out |
100
+ | 8 | network or 5xx |
101
+
102
+ ## Development (in the amdahl-frontend repo)
103
+
104
+ ```sh
105
+ pnpm --filter @amdahl/cli build # dist/amdahl.js, one file, no runtime deps
106
+ pnpm --filter @amdahl/cli test # vitest, against a mock server
107
+ pnpm --filter @amdahl/cli type-check
108
+ pnpm --filter @amdahl/cli smoke:pack # pack, install offline, run --version
109
+ ```
110
+
111
+ ## Releases
112
+
113
+ `.github/workflows/publish-cli.yml` publishes to npm. Push a tag
114
+ `cli-v<version>`, or run the workflow by hand (a manual run is a dry run unless
115
+ you clear `dry_run`). Bump `package.json` and `src/version.ts` together in a PR
116
+ first; the workflow refuses a tag that does not match both. It type-checks,
117
+ tests, packs, runs the tarball's `--help` and `--version` from an empty
118
+ directory, and publishes that same tarball.
119
+
120
+ It publishes without npm provenance. npm signs provenance only for packages
121
+ built from a public source repository, and this repository is private. To turn
122
+ provenance back on, first make the source repository public (or move the
123
+ package to a public repository). Then set `"provenance": true` in
124
+ `publishConfig` in `package.json`, add `--provenance` to the `npm publish`
125
+ arguments in the workflow, and give the workflow the `id-token: write`
126
+ permission.