@farthershore/cli 0.29.0 → 0.31.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 (4) hide show
  1. package/README.md +128 -158
  2. package/dist/index.js +96 -2117
  3. package/dist/mcp.js +49 -48
  4. package/package.json +4 -5
package/README.md CHANGED
@@ -3,96 +3,117 @@
3
3
  Create and operate [FartherShore](https://farthershore.com) software businesses
4
4
  from the terminal.
5
5
 
6
- **Status: `0.25.0`.** Pre-1.0 — the command surface is stable but may still
6
+ **Status: `0.31.0`.** Pre-1.0 — the command surface is stable but may still
7
7
  change between minor versions. Pin an exact version in CI.
8
8
 
9
9
  FartherShore lets you define a software business as code, then sells, meters,
10
10
  and bills access to it at the edge. Business behavior — plans, pricing, limits,
11
- routes, meters, and origins — is authored in your GitHub repo with
11
+ routes and meters — is authored in your GitHub repo with
12
12
  [`@farthershore/business`](https://www.npmjs.com/package/@farthershore/business)
13
- and applied automatically when you push. This CLI is the tool layer around that
14
- repo: scaffold a new business, validate it locally before you push, connect
15
- billing, publish it live, and run day-to-day operations (consumers, secrets,
16
- backends, webhooks, promo codes, usage). It is designed to be safe for both
17
- humans and agents — every command takes `--format json` for non-interactive
18
- scripting, and the same surface is exposed as an MCP server.
13
+ and reconciled through repository checks and the apply timeline after you push.
14
+ This CLI is the tool layer around that repo: provision a managed business repo,
15
+ validate it locally before you push, inspect publication state, and run
16
+ day-to-day operations (consumers, secrets, backends, webhooks, promo codes,
17
+ usage). It is designed to be safe for both humans and agents — every command
18
+ takes `--format json` for non-interactive scripting, and the MCP server exposes
19
+ the explicitly agent-operable subset of the CLI surface.
19
20
 
20
21
  ## Install
21
22
 
22
23
  ```bash
23
- npm install -g @farthershore/cli
24
+ npm install -g @farthershore/cli@0.31.0
24
25
  ```
25
26
 
26
27
  Or run it directly with npx:
27
28
 
28
29
  ```bash
29
- npx @farthershore/cli --help
30
+ npx @farthershore/cli@0.31.0 --help
30
31
  ```
31
32
 
32
33
  The package also ships an MCP stdio server for agents:
33
34
 
34
35
  ```bash
35
- FARTHERSHORE_TOKEN=mk_xxx npx -p @farthershore/cli farthershore-mcp
36
+ npx -p @farthershore/cli@0.31.0 farthershore-mcp
36
37
  ```
37
38
 
38
39
  ## Authentication
39
40
 
40
- Create a maker token at
41
- [farthershore.com/settings/tokens](https://farthershore.com/settings/tokens),
42
- then store it locally:
41
+ Start the device login. The CLI prints a verification URL and user code, opens
42
+ the browser when possible, and waits for a human to review and approve access:
43
43
 
44
44
  ```bash
45
- # Interactive — prompts for the token
46
- farthershore auth login
45
+ farthershore login
46
+ farthershore auth whoami --format json
47
+ ```
48
+
49
+ On a headless machine, print the same handoff without trying to open a browser:
50
+
51
+ ```bash
52
+ farthershore login --headless
53
+ ```
47
54
 
48
- # Non-interactive — pass it directly
49
- farthershore auth login --token mk_xxx
55
+ Normal login creates a user-bound CLI session. It uses your live role in each
56
+ organization instead of copying a permission list into the credential. By
57
+ default it follows all of your current and future organization memberships and
58
+ all businesses in them. Normal login has no permission or scope choices: use an
59
+ organization-scoped MakerToken when automation needs narrower access.
50
60
 
51
- # Or skip the file entirely with an env var (CI / agents)
52
- export FARTHERSHORE_TOKEN=mk_xxx
61
+ Choose the active organization for a command with `--organization <id-or-slug>`,
62
+ or save a default context:
63
+
64
+ ```bash
65
+ farthershore auth organization list
66
+ farthershore auth organization use <id-or-slug>
53
67
  ```
54
68
 
55
- Tokens are stored in `~/.farthershore/credentials.json`. A maker token is
56
- exchanged for a short-lived CLI access token on the first authenticated request.
69
+ For a separately issued organization-scoped MakerToken, pipe it through bounded stdin:
57
70
 
58
71
  ```bash
59
- farthershore auth whoami # Show current org, role, and scopes
60
- farthershore auth logout # Clear stored credentials
72
+ printf %s "$FARTHERSHORE_MAKER_TOKEN" | farthershore login --token-stdin
61
73
  ```
62
74
 
63
- GitHub account linking and Stripe Connect/KYC are browser-hosted flows; the CLI
64
- reports their status (see `connect`) so you — or an agent — can continue once the
65
- flow is finished in the dashboard.
75
+ `FARTHERSHORE_TOKEN` accepts an organization-scoped MakerToken as an ephemeral
76
+ process override and is never persisted automatically. `farthershore logout` deletes the stored credential after
77
+ revoking the current user CLI session on the platform. Signing in again also
78
+ supersedes older user CLI sessions.
79
+ Membership and role changes take effect on the next authenticated request. A
80
+ restricted MakerToken remains available through `--token-stdin` or
81
+ `FARTHERSHORE_TOKEN`. Never write
82
+ credentials into the managed repository.
66
83
 
67
84
  ## Quickstart
68
85
 
69
- Scaffold a business, validate it, connect billing, and publish:
86
+ Create a managed business repo, author the business, validate it, and push:
70
87
 
71
88
  ```bash
72
- export FARTHERSHORE_TOKEN=mk_xxx
73
-
74
- # 1. Create the managed repo (provisions GitHub repo + starter frontend)
75
- farthershore business create --name weather-api --display-name "Weather API"
89
+ # 1. Create the managed repo. Human output is exactly its URL.
90
+ REPO_URL=$(farthershore business create weather-api)
76
91
 
77
- # 2. Edit business behavior in the repo
78
- gh repo clone acme/weather-api
92
+ # 2. Clone it and author business/ from scratch.
93
+ git clone "$REPO_URL"
79
94
  cd weather-api
80
- # ...edit business/business.ts with @farthershore/business...
95
+ # ...author business/ with @farthershore/business...
81
96
 
82
97
  # 3. Validate the same way the PR check will, before pushing
83
98
  farthershore validate --business weather-api
84
99
 
85
- # 4. Push — the GitHub bot compiles + applies your manifest
100
+ # 4. Push — the GitHub bot validates and records apply state
86
101
  git push --set-upstream origin feature/pricing
87
- farthershore change-set list weather-api # inspect checks + apply state
102
+ farthershore apply-timeline list weather-api # inspect checks + apply state
88
103
 
89
- # 5. Connect billing, then go live
90
- farthershore connect stripe weather-api
91
- farthershore business publish weather-api
104
+ # 5. Inspect accepted state, then use the CLI for platform operations.
105
+ farthershore business status weather-api --format json
106
+ farthershore operations list --format json
92
107
  ```
93
108
 
94
- Plans, prices, limits, routes, meters, and origins are **repo-controlled**:
95
- change them by editing `business/business.ts` and pushing. The CLI's
109
+ Do not infer a successful apply from a push alone. A default-branch runtime-only
110
+ change may publish after validation; an economic change is deferred to a GitHub
111
+ Release. Preview-environment branches publish only to that environment. Inspect
112
+ the repository checks and apply timeline for the actual outcome.
113
+
114
+ Plans, prices, limits, routes, and meters are **repo-controlled**: change them
115
+ by editing the program under `business/` and pushing. Presentation and origin bindings
116
+ are platform-owned operating state. The CLI's
96
117
  write commands cover **operational** state that lives outside the manifest
97
118
  (consumers, secrets, backends, webhooks, promo codes, brand presentation).
98
119
 
@@ -100,7 +121,6 @@ write commands cover **operational** state that lives outside the manifest
100
121
 
101
122
  | Flag | Description |
102
123
  | --------------------- | -------------------------------------------------------- |
103
- | `--token <token>` | Override auth token for this command |
104
124
  | `--api-url <url>` | Override platform Core API URL |
105
125
  | `--env <environment>` | Environment scope (`production`/`prod`/`main` aliases) |
106
126
  | `--format <format>` | `json` for machine-readable output (default for non-TTY) |
@@ -112,7 +132,7 @@ write commands cover **operational** state that lives outside the manifest
112
132
 
113
133
  | Variable | Description |
114
134
  | ---------------------- | --------------------------------------------------------------- |
115
- | `FARTHERSHORE_TOKEN` | API token (overrides stored credentials) |
135
+ | `FARTHERSHORE_TOKEN` | Ephemeral organization-scoped MakerToken; never persisted |
116
136
  | `FARTHERSHORE_API_URL` | Platform Core API URL (default `https://core.farthershore.com`) |
117
137
  | `FARTHERSHORE_ENV` | Default environment scope when `--env` is omitted |
118
138
 
@@ -120,40 +140,13 @@ write commands cover **operational** state that lives outside the manifest
120
140
 
121
141
  Run `farthershore <group> --help` for the full flag set of any command.
122
142
 
123
- ### `farthershore init`
124
-
125
- Scaffold a starter business repo locally from a named plan preset. Each preset
126
- fills in a functional `business/business.ts` using `fs.requests()`,
127
- `fs.route()`, `fs.plan()`, and a default `fs.business()` export, then creates the matching customer
128
- `frontend/` project, repo-local `business/package.json`, `business/tsconfig.json`,
129
- and `.gitignore`.
130
-
131
- ```bash
132
- # Interactive walkthrough (TTY only) — pick a preset and a path
133
- farthershore init
134
-
135
- # Non-interactive — pass --template explicitly (required when not a TTY)
136
- farthershore init --template free
137
- farthershore init --template starter --force
138
- farthershore init --template metered --format json
139
- farthershore init --template starter --surface frontend --surface agent
140
- ```
141
-
142
- | Template | Shape |
143
- | --------- | ------------------------------------------------------------ |
144
- | `free` | $0 plan, hard-enforced 1k requests/month limit |
145
- | `starter` | $20/mo + $20 included usage, $0.001/request overage |
146
- | `pro` | $100/mo + $200 included usage, 14-day trial, $0.0005/request |
147
- | `prepaid` | $50 one-time signup credit, then pay-as-you-go |
148
- | `metered` | Pure pay-as-you-go at $0.001/request |
149
-
150
- After `init`, add functional meter, route, group, and plan declarations to grow
151
- the business. Configure the platform-owned upstream origin separately.
152
- Pass repeatable
153
- `--surface <frontend|api|docs|widget|dashboard|webhook|worker|agent>` to seed a
154
- specific shape; omitting it keeps the default `frontend + api` starter. Run
155
- `npm install` in `business/`, then `farthershore build` from the repo root to
156
- confirm it compiles.
143
+ Database-backed list commands use Core's shared query contract: repeat
144
+ `--filter field=value` for exact AND filters, pass one
145
+ `--sort field[:asc|desc]` (ascending when omitted), and use
146
+ `--search <text>` for case-insensitive text search. Core applies all three
147
+ before pagination; the CLI does not sort or filter a partial page locally.
148
+ Each command rejects fields outside its endpoint-specific allowlist shown by
149
+ `--help`.
157
150
 
158
151
  ### `farthershore create`
159
152
 
@@ -174,7 +167,7 @@ planned.
174
167
 
175
168
  ### `farthershore build`
176
169
 
177
- Compile `business/business.ts` to a Manifest IR envelope locally (default
170
+ Compile the program under `business/` to a Manifest IR envelope locally (default
178
171
  output `business-build.json`). The CLI uses the Business SDK installed under
179
172
  `business/`, falling back to a root install. This is local compilation only;
180
173
  server-side validation and apply happen when you push `business/**` changes.
@@ -201,42 +194,29 @@ farthershore validate --local-only --format json
201
194
 
202
195
  ### `farthershore business`
203
196
 
204
- Business lifecycle. Creation provisions a managed GitHub repo (the source of
205
- truth for business behavior) under your connected GitHub account and returns the
206
- clone URL plus bootstrap instructions. A new business starts as a DRAFT with a
207
- generated `frontend/` ready to customize.
197
+ Business lifecycle. Creation provisions a managed GitHub repo as the source of
198
+ truth for business behavior and returns its URL. A new business starts as a
199
+ DRAFT with repository tooling but no predefined business program.
208
200
 
209
201
  ```bash
210
202
  farthershore business list --format json
203
+ farthershore business list --filter status=ACTIVE --sort updatedAt:desc --search weather --format json
211
204
  farthershore business show weather-api --format json
212
205
  farthershore business show weather-api --env preview --format json
213
206
 
214
- farthershore business create \
215
- --name weather-api \
207
+ farthershore business create weather-api \
216
208
  --display-name "Weather API" \
217
209
  --format json
218
210
 
219
- # Seed a meter from the same templates the dashboard offers:
220
- # requests (default) | ai-tokens | credits | spend | compute
221
- farthershore business create --name llm-api --meters ai-tokens --format json
222
-
223
- # Or a fully custom meter list (key[:display[:unit]], repeatable):
224
- farthershore business create --name image-api \
225
- --meter requests \
226
- --meter images:Images:image \
227
- --format json
228
-
229
- # Seed initial Business SDK surfaces (repeatable; defaults to frontend + api):
230
- farthershore business create \
231
- --name support-agent \
232
- --surface frontend \
233
- --surface agent \
234
- --format json
235
-
236
211
  farthershore business publish weather-api --format json
212
+ farthershore business rollback weather-api wfe_previous --reason "bad release" --format json
237
213
  farthershore business delete weather-api --yes --format json
238
214
  ```
239
215
 
216
+ The JSON result includes `data.business`, `data.repoUrl`, and recovery metadata.
217
+ Gather the product requirements, create the `business/` program, and author its
218
+ plans, prices, limits, routes, and meters from scratch.
219
+
240
220
  `business update` changes platform-owned fields such as display name,
241
221
  description, icon, and logo (icon/logo accept PNG, JPEG, or WEBP). Plans,
242
222
  prices, limits, routes, and meters are repo-controlled and must be changed
@@ -253,18 +233,19 @@ farthershore business update weather-api \
253
233
  --clear-icon --clear-logo --format json
254
234
  ```
255
235
 
256
- `business publish` enforces the same go-live gates as the dashboard: at least one
257
- plan, an origin, and a verified Stripe connection (clear remediation is printed
258
- for `STRIPE_NOT_CONNECTED` / `STRIPE_NOT_VERIFIED` / `BILLING_TAX_NOT_ENROLLED`).
236
+ `business publish` enforces the same go-live gates as the dashboard and returns
237
+ stable remediation errors when a prerequisite is missing.
238
+ `business rollback` enqueues a rollback of the specified prior publish workflow
239
+ and requires the exact `business:rollback` permission.
259
240
 
260
- ### `farthershore change-set`
241
+ ### `farthershore apply-timeline`
261
242
 
262
- Inspect repo-backed change sets — PRs, pushes, releases, checks, semantic diffs,
243
+ Inspect repo-backed applies — PRs, pushes, releases, checks, semantic diffs,
263
244
  and apply state — for a business.
264
245
 
265
246
  ```bash
266
- farthershore change-set list weather-api --format json
267
- farthershore change-set inspect weather-api 42 --format json # by id, PR #, branch, or SHA
247
+ farthershore apply-timeline list weather-api --format json
248
+ farthershore apply-timeline inspect weather-api 42 --format json # by id, PR #, branch, or SHA
268
249
  ```
269
250
 
270
251
  ### `farthershore env`
@@ -274,10 +255,21 @@ Manage preview/production environments. Production is the default scope when
274
255
 
275
256
  ```bash
276
257
  farthershore env list weather-api --format json
258
+ farthershore env list weather-api --filter branch=env/preview --sort createdAt:desc --search preview --format json
277
259
  farthershore env create weather-api --name preview --branch env/preview --format json
278
260
  farthershore env delete weather-api preview --yes --format json
279
261
  ```
280
262
 
263
+ ### `farthershore organization`
264
+
265
+ Manage organization members and the exact platform-permission roles assigned
266
+ to them. Built-in and custom roles use the same list contract.
267
+
268
+ ```bash
269
+ farthershore organization role list <organizationId> --filter builtIn=true --sort name --search security --format json
270
+ farthershore organization members <organizationId> --filter roleKey=auditor --sort email:asc --search person --format json
271
+ ```
272
+
281
273
  ### `farthershore plan`
282
274
 
283
275
  Read code-managed plans and operate live subscriber migrations. The CLI does not
@@ -420,7 +412,7 @@ export async function POST(request: Request) {
420
412
  ### `farthershore webhook`
421
413
 
422
414
  Provision outbound webhook endpoints and inspect delivery health. If the business
423
- declares webhooks in `business/business.ts`, writes return
415
+ declares webhooks under `business/`, writes return
424
416
  `409 MANAGED_BY_CODE` so the repo stays canonical.
425
417
 
426
418
  ```bash
@@ -457,46 +449,27 @@ update` requires `--kind`, `--duration-months`, and the amount flag for that kin
457
449
  whenever you change the code, amount, dates, plan scope, or redemption limits.
458
450
  Use `--all-plans` to clear plan scoping.
459
451
 
460
- ### `farthershore connect`
452
+ ### Farther Shore agent skills
461
453
 
462
- GitHub OAuth and Stripe Connect are browser-only. These commands report status so
463
- you can poll until the flow is finished in the dashboard.
454
+ Install or refresh the platform-verified skills bundle together. The platform
455
+ pins this immutable release, and CI plus a daily repository check compare it to
456
+ GitHub's latest stable release so the guidance cannot silently drift.
457
+ This command requires `@farthershore/cli` 0.31.0 or newer.
464
458
 
465
459
  ```bash
466
- farthershore connect github --format json
467
- farthershore connect stripe weather-api --format json
460
+ farthershore skills install --help
461
+ # If the command is unavailable, upgrade to the required CLI release:
462
+ npm install -g @farthershore/cli@0.31.0
463
+ farthershore skills install
468
464
  ```
469
465
 
470
- ### `farthershore token`
471
-
472
- Manage maker tokens for the current org.
473
-
474
- ```bash
475
- farthershore token list --format json
476
- farthershore token create --name "ci-bot" --scope businesses:update businesses:publish --format json
477
- farthershore token rotate <tokenId> --sync-to-github --format json
478
- farthershore token revoke <tokenId> --yes --format json
479
- ```
480
-
481
- ### `farthershore skills`
482
-
483
- Inside a business repo, recommend agent skills matching the FartherShore SDK
484
- versions the repo actually uses. The Business SDK and Frontend SDK tracks are
485
- recommended independently, so updating one does not force a skill update for the
486
- other.
487
-
488
- ```bash
489
- farthershore skills recommend --format json
490
- SKILLS_CMD=$(farthershore skills recommend --format json | jq -r '.data.recommendation.command')
491
- eval "$SKILLS_CMD"
492
- ```
466
+ The Farther Shore CLI downloads the exact installer archive and verifies this
467
+ SHA-512 before it extracts or executes any installer code.
493
468
 
494
469
  ### `farthershore operations`
495
470
 
496
471
  Print the machine-readable action boundary: which operations are repo-authored
497
- (`contract`), which are CLI/API operations (`operate`), which reconcile through
498
- either path (`dual`), and which are browser-only prerequisites (GitHub linking,
499
- Stripe Connect).
472
+ (`contract`) and which are CLI/API operations (`operate`).
500
473
 
501
474
  ```bash
502
475
  farthershore operations list --format json
@@ -509,14 +482,8 @@ stdout — `{ ok, op, data }` on success, or `{ ok: false, op, error }` on failu
509
482
  where `error` carries a stable `code`, `message`, HTTP `status`, a `retryable`
510
483
  flag, and a remediation `hint` when one is registered. Diagnostics go to stderr.
511
484
 
512
- In table mode, failures print `Error [CODE]: message` plus a `Hint:` line:
513
-
514
- ```text
515
- Error [STRIPE_NOT_CONFIGURED]: connect Stripe before running billing operations
516
- Hint: Stripe isn't connected on this business. Connect it in the dashboard before running billing operations.
517
- ```
518
-
519
- The bracketed code is stable across releases — quote it in support threads.
485
+ In table mode, failures print `Error [CODE]: message` plus a `Hint:` line. The
486
+ bracketed code is stable across releases — quote it in support threads.
520
487
 
521
488
  Exit codes are a branchable taxonomy so a script can tell failure classes apart
522
489
  without parsing text:
@@ -532,21 +499,24 @@ without parsing text:
532
499
 
533
500
  ## CI and agent usage
534
501
 
535
- The CLI is non-interactive whenever a token is available via `--token` or
536
- `FARTHERSHORE_TOKEN` — `auth login` only prompts when stdin is a TTY and no token
537
- was passed, so it is safe to script. `farthershore build` and `farthershore
538
- validate --local-only` need no network or auth and are safe to run in CI.
502
+ Authenticate before unattended work, or supply an organization-scoped
503
+ MakerToken through `FARTHERSHORE_TOKEN`. Device login waits for human approval; use
504
+ `--headless` when the CLI cannot open a browser. `farthershore build` and
505
+ `farthershore validate --local-only` need no network or auth and are safe to
506
+ run in CI.
539
507
 
540
508
  ## MCP server
541
509
 
542
510
  The MCP server (`farthershore-mcp`) projects its tools from the same operation
543
- registry that defines the CLI commands, so every MCP tool has a CLI sibling. Tool
544
- names use the `fs_*` prefix and cover the agent-operable surface: businesses,
545
- environments, plans, frontends, backends, runtime tokens, webhooks, promo codes,
546
- consumers, secrets, personas, usage, and maker tokens.
511
+ registry that defines the CLI commands. Every MCP tool has a CLI sibling, but
512
+ not every CLI command is exposed through MCP. Tool names use the `fs_*` prefix
513
+ and cover only operations explicitly marked agent-operable in that registry.
514
+ Organization, role, member, and invitation administration requires a live-user
515
+ CLI session and is not projected into MCP; audit logs, notifications, and apply
516
+ timelines are also CLI-only.
547
517
 
548
518
  ```bash
549
- FARTHERSHORE_TOKEN=mk_xxx farthershore-mcp
519
+ farthershore-mcp
550
520
  ```
551
521
 
552
522
  ## Learn more