@learncard/cli 3.6.7 → 4.0.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.
- package/CHANGELOG.md +79 -0
- package/README.md +36 -12
- package/dist/index.js +6673 -2038
- package/package.json +27 -15
- package/project.json +0 -42
- package/rollup.config.js +0 -34
- package/scripts/embed-snippets.ts +0 -47
- package/src/auth-grant.test.ts +0 -54
- package/src/auth-grant.ts +0 -34
- package/src/clr/validate.test.ts +0 -65
- package/src/clr/validate.ts +0 -242
- package/src/clr.ts +0 -119
- package/src/consent-contract.ts +0 -116
- package/src/demo-inbox-refresh.test.ts +0 -737
- package/src/demo-inbox-refresh.ts +0 -804
- package/src/demo-refresh-command.test.ts +0 -57
- package/src/demo-refresh-command.ts +0 -22
- package/src/demo-refresh-ui.test.ts +0 -66
- package/src/demo-refresh-ui.ts +0 -65
- package/src/demo-refresh.test.ts +0 -140
- package/src/demo-refresh.ts +0 -309
- package/src/doctor/checks.test.ts +0 -448
- package/src/doctor/checks.ts +0 -497
- package/src/doctor.test.ts +0 -67
- package/src/doctor.ts +0 -118
- package/src/embed.ts +0 -102
- package/src/inbox.test.ts +0 -257
- package/src/inbox.ts +0 -221
- package/src/index.tsx +0 -876
- package/src/init.ts +0 -26
- package/src/open.test.ts +0 -40
- package/src/open.ts +0 -186
- package/src/org/apply.test.ts +0 -1108
- package/src/org/apply.ts +0 -924
- package/src/org/branding.test.ts +0 -60
- package/src/org/diff.ts +0 -14
- package/src/org/load.ts +0 -50
- package/src/org/schema.test.ts +0 -256
- package/src/org/schema.ts +0 -216
- package/src/org.ts +0 -124
- package/src/out.test.ts +0 -40
- package/src/out.ts +0 -16
- package/src/phase-two.test.ts +0 -154
- package/src/project.test.ts +0 -232
- package/src/project.ts +0 -489
- package/src/promote.test.ts +0 -142
- package/src/promote.ts +0 -202
- package/src/random.ts +0 -3
- package/src/refresh.test.ts +0 -86
- package/src/refresh.ts +0 -93
- package/src/replHelpers.test.ts +0 -80
- package/src/replHelpers.ts +0 -45
- package/src/revoke.test.ts +0 -29
- package/src/revoke.ts +0 -65
- package/src/send-template.test.ts +0 -20
- package/src/send.test.ts +0 -321
- package/src/send.ts +0 -373
- package/src/setup-signing.test.ts +0 -62
- package/src/setup-signing.ts +0 -185
- package/src/snippet-files.ts +0 -16
- package/src/status.test.ts +0 -33
- package/src/status.ts +0 -94
- package/src/token.test.ts +0 -28
- package/src/token.ts +0 -139
- package/src/types.d.ts +0 -17
- package/src/verify.test.ts +0 -35
- package/src/verify.ts +0 -66
- package/src/webhook.ts +0 -247
- package/src/whoami.test.ts +0 -67
- package/src/whoami.ts +0 -129
- package/tsconfig.json +0 -39
- package/vitest.config.ts +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,84 @@
|
|
|
1
1
|
# @learncard/cli
|
|
2
2
|
|
|
3
|
+
## 4.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#1908](https://github.com/learningeconomy/LearnCard/pull/1908) [`e580fe754ca4697a52c4642faac056c31b0280b9`](https://github.com/learningeconomy/LearnCard/commit/e580fe754ca4697a52c4642faac056c31b0280b9) Thanks [@Custard7](https://github.com/Custard7)! - Make the CLI safer and more predictable for scripts and AI agents.
|
|
8
|
+
|
|
9
|
+
**Upgrading from 3.x.** This release is a major version because scripts that parse CLI output or rely on the old behaviour may break:
|
|
10
|
+
|
|
11
|
+
- `verify --json` prints one line, `{ ok, command: "verify", verified, result }`. Read `verified` and `result` instead of the raw result.
|
|
12
|
+
- `token --json` no longer includes `token`. Read `API_TOKEN` from the `.env` named in `tokenSavedTo`, or pass `--show-secret`.
|
|
13
|
+
- `open --json --url-fragment` returns the URL without `#seed=`. Pass `--show-secret` for the old URL.
|
|
14
|
+
- Read-only commands (`whoami`, `status`, `inbox list`, `refresh history`, `doctor`, `revoke`, `token --list`/`--revoke`, `open`) fail with `NO_IDENTITY` in a folder with no identity instead of creating one. Run `init` (or `org apply`) first.
|
|
15
|
+
- Invalid flag values that used to be accepted are now rejected, as described below.
|
|
16
|
+
- Node 20 or later is required (`engines.node >= 20`).
|
|
17
|
+
|
|
18
|
+
**All changes:**
|
|
19
|
+
|
|
20
|
+
- `revoke`, `token --list` and `token --revoke` no longer create a seed, `.env` or profile in an empty folder. All commands that only read or act on an existing identity (`whoami`, `status`, `inbox list`, `refresh history`, `doctor`, `revoke`, `token --list`, `token --revoke`, `open`, `clr validate --dry-run-sign`) now fail in such a folder with `code: "NO_IDENTITY"` and the same hint to run `init`, and no longer write `NETWORK_URL` to `.env`. When `init`, `send`, `org apply` or another setup command creates a new identity, it says so on stderr and adds `identityCreated: { profileId, did, network }` to the `--json` result.
|
|
21
|
+
- `--profile-id`, `send --guardian-email` and `send --webhook-url` are checked before an identity is created, so a malformed value no longer leaves a broken `.env` behind.
|
|
22
|
+
- Flags and arguments are checked before anything is written or sent: an invalid recipient, `--network`, `--expires`, `--scope`, `status --limit`/`--event`, `inbox list --status`/`--limit`, or `setup-signing --endpoint`/`--did`.
|
|
23
|
+
- `--network` accepts `production`, `prod`, `staging`, `local` or a tRPC URL on every command (`--network production` used to fail with "Invalid URL" everywhere except `promote`).
|
|
24
|
+
- Every command except `repl` accepts `-y`, `--json` and `--network`. Commands that don't use a flag accept and ignore it.
|
|
25
|
+
- `--json` errors are now `{ ok: false, command, error, code, hint?, detail? }`. `detail` holds the full message when it spans several lines. With `--json`, usage errors (unknown command or option, missing argument, `--json` placed before the command) also print one JSON line with `code: "USAGE"`.
|
|
26
|
+
- `--json` errors are `code: "USAGE"` when a required value is missing in a non-interactive run or a flag value is invalid. If a command created a new identity before it failed, the error envelope also carries `identityCreated`. `--json` never prompts, so stdout holds only the JSON line even at a terminal without `-y`.
|
|
27
|
+
- **Breaking for scripts:** `verify --json` now prints one line, `{ ok: true, command: "verify", verified, result }`, instead of the raw result spread over several lines. It still exits 1 when the credential does not verify.
|
|
28
|
+
- **Breaking for scripts:** `token --json` no longer includes the raw `token` unless you pass `--show-secret`. It adds `tokenSavedTo`, the `.env` path where the token is saved as `API_TOKEN`.
|
|
29
|
+
- **Breaking for scripts:** `open --json --url-fragment` returns the URL without the `#seed=` fragment, plus `seedInFragment: true`, unless you pass `--show-secret`. `open` only copies the seed to the clipboard when stdout is a terminal; piped or `--json` runs (e.g. `$(cli open | tail -1)`) no longer copy it and no longer wait 60 seconds to clear the clipboard.
|
|
30
|
+
- Human-mode `webhook` now stops after `--timeout` (default 60 seconds) when stdin is not a terminal, as `--json` already did.
|
|
31
|
+
- Stricter flag validation rejects values that used to be accepted: `webhook --timeout`, `token --expires` (a positive number of days) and `status --limit` (a whole number from 1 to 100).
|
|
32
|
+
- The package installs a `learncard` binary as well as the existing `cli`. It now declares `engines.node >= 20` and publishes only `dist`, `examples` and the docs.
|
|
33
|
+
|
|
34
|
+
### Minor Changes
|
|
35
|
+
|
|
36
|
+
- [#1911](https://github.com/learningeconomy/LearnCard/pull/1911) [`076f2548d018060a4a744305167e387ed8380ec1`](https://github.com/learningeconomy/LearnCard/commit/076f2548d018060a4a744305167e387ed8380ec1) Thanks [@Custard7](https://github.com/Custard7)! - Help coding agents discover and use the whole LearnCard surface from the CLI.
|
|
37
|
+
|
|
38
|
+
- `commands [name...] [--json]` prints a manifest of every command, built from the CLI's own command tree: arguments, options, effect (`read`, `write`, `local` or `varies`), whether it can create an identity or connect, output fields and examples, plus global flags, environment variables, error codes and docs links. Each command's `--help` now ends with examples.
|
|
39
|
+
- `capabilities [id] [--json]` maps what LearnCard can do to the CLI command, SDK method, Network REST route and docs page for each.
|
|
40
|
+
- `call <method>` calls any `learnCard.invoke` SDK method as the folder's identity (`--args <json|@file|->`, `--as`, `--list`, `--describe`, `--dry-run`). `--describe` shows a method's TypeScript signature, parameters, the flags a call needs and an example, offline; `--args` also takes a bare non-JSON value such as an `lc:` URI as one string. Methods that can change data need `--write`, and methods that return secrets need `--show-secret`. On-chain methods (`transferTokens`) also need `--chain <name>`, and the wallet's chain is checked before anything is submitted; mainnet is used only when named. It never creates an identity, read calls don't register DIDs with LearnCloud, and results are converted to plain JSON.
|
|
41
|
+
- `api <METHOD> <path>` calls the LearnCard Network REST API with `LEARNCARD_API_KEY` or the folder's `API_TOKEN` (`--data`, `--query`, `--timeout`, `--dry-run`, `--spec [--fetch]`). Methods other than `GET`/`HEAD` need `--write`, as do the `GET` routes that change state (`/challenges`, `/inbox/guardian-approval/{token}`) however the path is spelled. The token is never printed, and non-2xx responses fail with code `HTTP_<status>`.
|
|
42
|
+
- `skill install` writes the LearnCard skill for coding agents to `.claude/skills/`, `.cursor/rules/` or `.agents/skills/` (`--target`, `--dir`, `--force`, `--print`). It works offline, never touches the folder's identity, and refuses to write through symlinks (`UNSAFE_PATH`).
|
|
43
|
+
|
|
44
|
+
Smaller fixes found by running the CLI as an agent on staging and production:
|
|
45
|
+
|
|
46
|
+
- `doctor` checks the production signing service (`api.learncard.app`) when no `LCA_API_URL` is set, instead of reporting hosted signing as unavailable while `setup-signing` used it.
|
|
47
|
+
- `send --suppress-delivery` no longer says the recipient will get a claim email.
|
|
48
|
+
- `call` and `api` no longer repeat the result on stderr in `--json` mode.
|
|
49
|
+
- Using `--network` that differs from the folder's network fails with `NETWORK_MISMATCH` and a hint; an unknown `status` activity ID fails with `NOT_FOUND`. Unknown commands get a "Did you mean …?" `hint`.
|
|
50
|
+
- `--json`, `-y` and `--network` may come before the command (`learncard --json whoami`).
|
|
51
|
+
- `identityCreated.did` is now the new profile's DID (the same as the result's `did`); the seed's `did:key` moves to `identityCreated.keyDid`.
|
|
52
|
+
- `--help` lists `LEARNCARD_AS`, `LEARNCARD_API_KEY` and `CLOUD_URL` with the other environment variables.
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- Updated dependencies [[`c20460f6fef685272227f506f536b6811f90b8a0`](https://github.com/learningeconomy/LearnCard/commit/c20460f6fef685272227f506f536b6811f90b8a0)]:
|
|
57
|
+
- @learncard/types@5.24.1
|
|
58
|
+
- @learncard/holder-continuity@0.2.27
|
|
59
|
+
- @learncard/core@9.4.42
|
|
60
|
+
- @learncard/init@2.5.8
|
|
61
|
+
- @learncard/network-brain-client@2.6.2
|
|
62
|
+
- @learncard/didkit-plugin@1.10.8
|
|
63
|
+
- @learncard/lca-api-plugin@2.0.14
|
|
64
|
+
- @learncard/learn-cloud-plugin@2.3.50
|
|
65
|
+
- @learncard/ler-rs-plugin@0.1.33
|
|
66
|
+
- @learncard/linked-claims-plugin@0.2.42
|
|
67
|
+
- @learncard/open-badge-v2-plugin@1.1.43
|
|
68
|
+
- @learncard/render-method-plugin@12.0.1
|
|
69
|
+
|
|
70
|
+
## 3.6.8
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- Updated dependencies [[`4ec92c41442b56341c1205e6ddd6ae784aecc990`](https://github.com/learningeconomy/LearnCard/commit/4ec92c41442b56341c1205e6ddd6ae784aecc990)]:
|
|
75
|
+
- @learncard/didkit-plugin@1.10.7
|
|
76
|
+
- @learncard/network-brain-client@2.6.1
|
|
77
|
+
- @learncard/holder-continuity@0.2.26
|
|
78
|
+
- @learncard/init@2.5.7
|
|
79
|
+
- @learncard/lca-api-plugin@2.0.13
|
|
80
|
+
- @learncard/learn-cloud-plugin@2.3.49
|
|
81
|
+
|
|
3
82
|
## 3.6.7
|
|
4
83
|
|
|
5
84
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -6,8 +6,14 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/@learncard/cli)
|
|
7
7
|
[](https://www.npmjs.com/package/@learncard/cli)
|
|
8
8
|
|
|
9
|
-
**LearnCard CLI**
|
|
10
|
-
|
|
9
|
+
**LearnCard CLI** sets up and operates a credential issuer from the terminal: send credentials,
|
|
10
|
+
track claims, manage signing, tokens and organizations, and verify what you receive. It also
|
|
11
|
+
includes an interactive REPL with a LearnCard wallet preloaded for exploring the SDK.
|
|
12
|
+
|
|
13
|
+
Run it with `npx @learncard/cli <command>` (Node.js 20 or later). A global install
|
|
14
|
+
(`npm i -g @learncard/cli`) exposes the same commands as `learncard <command>`.
|
|
15
|
+
Command reference: https://docs.learncard.com/reference/learncard-cli. Using it from an AI agent or
|
|
16
|
+
script: https://docs.learncard.com/start-here/for-ai-agents.
|
|
11
17
|
|
|
12
18
|

|
|
13
19
|
|
|
@@ -31,7 +37,7 @@ Prompts for a recipient if omitted (or pass it: `send you@yourdomain.com`), gene
|
|
|
31
37
|
Run a guided, real-network demonstration without writing code:
|
|
32
38
|
|
|
33
39
|
```bash
|
|
34
|
-
learncard demo refresh
|
|
40
|
+
npx @learncard/cli demo refresh
|
|
35
41
|
```
|
|
36
42
|
|
|
37
43
|
Press Enter between each step: send a **Provisional Course Certificate**, publish a
|
|
@@ -40,11 +46,11 @@ before and after and verifies that the credential keeps its identity. It uses th
|
|
|
40
46
|
existing `sendBoost` flow with `enableRefresh: true` and publishes using the receipt
|
|
41
47
|
returned by that send. No second badge is sent.
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
`demo refresh` requires `@learncard/cli` 3.6.0 or later. The default network is
|
|
50
|
+
`http://localhost:4000/trpc`, so a developer must first start the local services with
|
|
51
|
+
managed refresh enabled. To present against a staging network that has managed refresh
|
|
52
|
+
enabled, use `npx @learncard/cli demo refresh --network staging`. To run the current
|
|
53
|
+
source instead of the published package, run this from the repository root:
|
|
48
54
|
|
|
49
55
|
```bash
|
|
50
56
|
bun --cwd packages/learn-card-cli start demo refresh
|
|
@@ -104,7 +110,7 @@ the locally configured delivery service to email a **provisional** claim link, y
|
|
|
104
110
|
in the app, then the school publishes a single visible **final** update.
|
|
105
111
|
|
|
106
112
|
```bash
|
|
107
|
-
bun --cwd packages/learn-card-cli start demo refresh --inbox --ui --email you@
|
|
113
|
+
bun --cwd packages/learn-card-cli start demo refresh --inbox --ui --email you@yourdomain.com
|
|
108
114
|
```
|
|
109
115
|
|
|
110
116
|
`--email` without a value prompts for the address. It requires `--inbox`, `--ui`, and an
|
|
@@ -206,12 +212,18 @@ authority, publication, claim binding, and refresh are all real. The direct
|
|
|
206
212
|
### Interactive REPL
|
|
207
213
|
|
|
208
214
|
```bash
|
|
209
|
-
npx @learncard/cli
|
|
215
|
+
npx @learncard/cli repl
|
|
210
216
|
|
|
211
|
-
# Optionally specify a seed
|
|
212
|
-
npx @learncard/cli
|
|
217
|
+
# Optionally specify a deterministic seed (hex)
|
|
218
|
+
LEARNCARD_CLI_SEED=1b498556081a298261313657c32d5d0a9ce8285dc4d659e6787392207e4a7ac2 npx @learncard/cli repl
|
|
213
219
|
```
|
|
214
220
|
|
|
221
|
+
Running `npx @learncard/cli` with no command in an interactive terminal also opens the REPL; without a
|
|
222
|
+
TTY it prints help instead. `repl <seed>` takes the seed as an argument, but `LEARNCARD_CLI_SEED` (or
|
|
223
|
+
`SEED`) takes precedence over it and keeps the seed out of your shell history. The REPL does not read
|
|
224
|
+
the folder's `.env` identity: it starts a separate wallet from that seed (random if none is given),
|
|
225
|
+
always on the production network, and prints the seed on startup.
|
|
226
|
+
|
|
215
227
|
## Holder continuity export
|
|
216
228
|
|
|
217
229
|
The CLI exposes REPL helpers from `@learncard/holder-continuity` for holder-controlled export, restore, and self-import:
|
|
@@ -300,6 +312,18 @@ npx @learncard/cli promote --from staging --to production --org ./org.yaml
|
|
|
300
312
|
|
|
301
313
|
Re-applies your org spec in its own `.learncard/production` folder (each network needs its own `.env`), writes fresh service-account tokens to `<target>/secrets.env` (or `--secrets-out`), and runs `doctor` — then prints the per-network checklist (profile, tokens, signing authority, templates, ConsentFlow contracts, credentials) that doesn't carry over; only your seed's `did:key` does. Add `--dry-run` to preview or `--skip-doctor` to skip the preflight.
|
|
302
314
|
|
|
315
|
+
## Coding agents and scripts
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
npx @learncard/cli skill install # LearnCard skill for Claude Code, Cursor or .agents/
|
|
319
|
+
npx @learncard/cli commands --json # every command: effect, options, output fields, examples
|
|
320
|
+
npx @learncard/cli capabilities --json # task -> CLI command, SDK method, REST route, docs
|
|
321
|
+
npx @learncard/cli call getProfile --network staging --json # any learnCard.invoke method
|
|
322
|
+
npx @learncard/cli api GET /profile --network staging --json # any Network REST route
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
`call` and `api` run reads as-is and refuse anything that can change data unless you pass `--write` (`--dry-run` shows what would run). Neither creates an identity, and without `--show-secret` neither prints the seed or an API token (`call --show-secret` can print private keys equivalent to the seed, and API tokens). Guide: https://docs.learncard.com/start-here/for-ai-agents/use-learncard-with-coding-agents
|
|
326
|
+
|
|
303
327
|
## Contributing
|
|
304
328
|
|
|
305
329
|
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|