Skip to content

Commit 94359fa

Browse files
committed
release(cli): ship 0.2.0 command surface
1 parent ec85f5a commit 94359fa

69 files changed

Lines changed: 4053 additions & 187 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ that runs directory-backed project and user-global commands.
1111
- Preserve command directories as the move unit.
1212
- Keep `script` valid as a command segment; only `script.{ts,mts,js,mjs}` files
1313
make a command directory runnable.
14-
- Do not add shell entrypoints, completions, trust prompts, or MCP mode in v1.
14+
- v0.2 ships completions, the overlay trust model, `--edit`/`--rm`, templates,
15+
the `cli-cwd` pragma, `--doctor`, MCP server mode, and command packs; keep
16+
their contracts aligned with `SPEC.md`.
17+
- Do not add non-JavaScript entrypoints (`.sh`, `.py`) or a hosted pack
18+
registry.
1519
- Do not move or delete `../cli (1)/SPEC.md`; it is source material outside this
1620
package.
1721

API_SURFACE.md

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,25 @@
1616

1717
```js
1818
import {
19+
addPack,
20+
complete,
21+
completionScript,
1922
copyCommand,
2023
createCommand,
2124
discoverRoots,
2225
listCommands,
26+
localOverlayTrust,
2327
moveCommand,
28+
overlayTrustState,
29+
recordOverlayTrust,
30+
removeCommand,
31+
removeOverlayTrust,
2432
resolveCommand,
25-
runCommand
33+
runCommand,
34+
runDoctor,
35+
runMcpServer,
36+
trustLocalOverlays,
37+
untrustLocalOverlays
2638
} from "@async/cli";
2739
```
2840

@@ -43,12 +55,20 @@ and shadowed scripts.
4355

4456
### `runCommand(options, args)`
4557

46-
Executes the resolved script with inherited stdio by default, caller cwd,
47-
forwarded arguments, and `CLI_*` environment values.
58+
Executes the resolved script with inherited stdio by default, forwarded
59+
arguments, and `CLI_*` environment values. The working directory follows the
60+
script's `// cli-cwd:` pragma (caller by default). Local-overlay scripts are
61+
refused with exit 3 unless the overlay is trusted.
4862

4963
### `createCommand(options, commandPath)`
5064

51-
Creates a command directory with a default `script.ts`.
65+
Creates a command directory with a default `script.ts`, or copies
66+
`_templates/<name>/` when `options.template` is set.
67+
68+
### `removeCommand(options, commandPath)`
69+
70+
Removes a whole command directory from the nearest local overlay (or the root
71+
tree) and prunes empty parents. Nested commands require `options.force`.
5272

5373
### `copyCommand(options, commandPath)`
5474

@@ -59,3 +79,32 @@ when a script imports through `../`.
5979

6080
Moves a whole command directory between local and user-global roots and warns
6181
when a script imports through `../`.
82+
83+
### `addPack(options, source)`
84+
85+
Shallow-clones a Git source and installs its `.cli/` command directories into
86+
the root or local tree, optionally under `options.prefix`, refusing conflicts
87+
unless `options.force`.
88+
89+
### Trust
90+
91+
`trustLocalOverlays`, `untrustLocalOverlays`, `localOverlayTrust`,
92+
`overlayTrustState`, `recordOverlayTrust`, `removeOverlayTrust`,
93+
`ensureOverlayTrusted`, `hashOverlayTree`, `isTrustEnforced`, and
94+
`trustStorePath` manage the content-hash trust store kept in `.trust.json`
95+
under the user-global root. `ASYNC_CLI_TRUST=off` disables enforcement.
96+
97+
### `runDoctor(options)` / `renderDoctorReport(report)`
98+
99+
Audits all command roots and returns `{ version, problems, summary }` with
100+
error, warning, and info findings.
101+
102+
### `complete(options, words)` / `completionScript(shell)`
103+
104+
Next-segment command completion and the bash, zsh, and fish completion
105+
scripts that call it.
106+
107+
### `runMcpServer(options, io)`
108+
109+
Serves the command tree as MCP tools over newline-delimited JSON-RPC stdio.
110+
Untrusted local overlays are excluded from listing and refused at call time.

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
# Changelog
22

3+
## 0.2.0 - 2026-07-06
4+
5+
- Adds a direnv-style trust model for repo-local overlays: `cli --trust`,
6+
`cli --untrust`, `cli --trust --status`, content-hash validation, exit 3 on
7+
untrusted or changed overlays, and `ASYNC_CLI_TRUST=off` for controlled
8+
environments. CLI mutations (`--new`, `--cp/--mv --to local`,
9+
`--add --to local`) record or refresh trust for the target overlay.
10+
- Adds shell completions: `cli --completions bash|zsh|fish` and the hidden
11+
`cli --complete` helper that completes command segments and built-in flags.
12+
- Adds `cli --edit <cmd...>` to open the resolved script in `$VISUAL`/`$EDITOR`
13+
and `cli --rm <cmd...> [--root] [--force]` with nested-command protection
14+
and empty-parent pruning.
15+
- Adds `--new --template <name>`, copying command templates from
16+
`_templates/` in any command root, nearest-local first.
17+
- Adds the `// cli-cwd: caller|project-root|script-dir` pragma plus a
18+
`CLI_CALLER_CWD` environment value for scripts.
19+
- Adds `cli --doctor [--json]`: audits ambiguous script directories, escaping
20+
imports, empty command directories, trust state, descriptions, shadowing,
21+
and managed context-block drift.
22+
- Adds `cli --mcp`, a zero-dependency MCP stdio server that exposes the
23+
command tree as tools (`gh pull` becomes `gh__pull`), excluding untrusted
24+
local overlays.
25+
- Adds command packs: `cli --add <git-url> [--to root|local]
26+
[--prefix <name>] [--force]` installs `.cli/` trees from any Git source.
27+
- Exports `removeCommand`, `addPack`, `runDoctor`, `complete`,
28+
`completionScript`, `runMcpServer`, and the trust helpers from the root
29+
export.
30+
331
## 0.1.2 - 2026-07-02
432

533
- Adds `cli --cp <command...> [--to root|local]` and `copyCommand()` for

README.md

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ maps to a command directory like:
1414
.cli/gh/pull/script.ts
1515
```
1616

17-
The v1 contract is defined in `SPEC.md`. The package implements local and
18-
user-global command discovery, command resolution, script execution,
19-
machine-readable listing, `--which`, `--new`, `--mv`, context-file pointers,
20-
help, command copy, and version output.
17+
The contract is defined in `SPEC.md`. The package implements local and
18+
user-global command discovery, command resolution, script execution with a
19+
trust model for local overlays, machine-readable listing, `--which`, command
20+
scaffolding with templates, command copy/move/remove, `--edit`, command packs
21+
via `--add`, shell completions, a tree doctor, an MCP server mode,
22+
context-file pointers, help, and version output.
2123

2224
## Install
2325

@@ -52,24 +54,80 @@ cli --list --json
5254
cli --which gh pull
5355
cli --new gh pr
5456
cli --new gh pr --root
57+
cli --new gh pr --template worker
58+
cli --edit gh pull
59+
cli --rm gh pull
5560
cli --cp gh pull
5661
cli --cp gh pull --to local
5762
cli --mv gh pull
5863
cli --mv gh pull --to local
64+
cli --add https://example.com/org/pack.git
65+
cli --trust
66+
cli --trust --status
67+
cli --untrust
68+
cli --doctor
69+
cli --completions bash
70+
cli --mcp
5971
cli --agents
6072
cli --agents --write
6173
cli --agents --check
6274
cli --agents --claude --write
6375
cli --version
6476
```
6577

66-
Command scripts run from the caller's original working directory. `.js` and
67-
`.mjs` scripts run directly with Node; `.ts` and `.mts` scripts use Node 24
68-
native type stripping.
78+
Command scripts run from the caller's original working directory by default;
79+
a `// cli-cwd: project-root` or `// cli-cwd: script-dir` head comment changes
80+
that per script. `.js` and `.mjs` scripts run directly with Node; `.ts` and
81+
`.mts` scripts use Node 24 native type stripping.
6982

7083
Use `--cp` to clone a command directory between local and user-global command
7184
trees without removing the source. Use `--mv` when the source should be
72-
transferred instead.
85+
transferred instead, and `--rm` to delete a command directory.
86+
87+
## Trust
88+
89+
Repo-local `.cli/` overlays are refused at execution time until you trust
90+
them, because cloned repositories can shadow your user-global commands:
91+
92+
```sh
93+
cli --trust # trust the local overlays discovered from here
94+
cli --trust --status # trusted | changed | untrusted per overlay
95+
cli --untrust # revoke
96+
```
97+
98+
Trust records a content hash of the overlay; any change requires re-trusting.
99+
Listing and `--which` never require trust. Set `ASYNC_CLI_TRUST=off` to
100+
disable enforcement in controlled environments.
101+
102+
## Completions
103+
104+
```sh
105+
eval "$(cli --completions bash)" # or zsh
106+
cli --completions fish | source # fish
107+
```
108+
109+
## Doctor
110+
111+
`cli --doctor [--json]` audits every command root: ambiguous script
112+
directories, `../` imports that break `--cp`/`--mv`, empty command
113+
directories, untrusted overlays, missing descriptions, shadowed commands, and
114+
stale `--agents` pointer blocks.
115+
116+
## MCP
117+
118+
`cli --mcp` serves the command tree as MCP tools over stdio (JSON-RPC 2.0,
119+
zero dependencies), so agent runtimes can discover and call the same commands
120+
humans use. Untrusted local overlays are excluded.
121+
122+
## Packs
123+
124+
Install commands from any Git repository that carries a `.cli/` tree:
125+
126+
```sh
127+
cli --add https://example.com/org/pack.git # into ~/.cli
128+
cli --add https://example.com/org/pack.git --prefix vendor
129+
cli --add https://example.com/org/pack.git --to local # into this repo
130+
```
73131

74132
## Development
75133

0 commit comments

Comments
 (0)