@everywheredev/cli 0.0.1-5.1
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/README.md +135 -0
- package/bin/pocketdev.js +19 -0
- package/dist/index.js +388 -0
- package/package.json +68 -0
- package/scripts/build.mjs +68 -0
- package/scripts/ensure-node-pty.mjs +52 -0
- package/scripts/smoke.mjs +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# @everywheredev/cli
|
|
2
|
+
|
|
3
|
+
A **Claude-Code-style TypeScript terminal client** for the PocketDev host. It is a *thin client to the
|
|
4
|
+
Go host* — it never owns the filesystem, git, PTY, or AI agent. It browses/edits the project, streams
|
|
5
|
+
the terminal and activity feed, drives the HTTP proxy, and runs AI prompts, working **identically**
|
|
6
|
+
against a **LOCAL** host (loopback + Personal Access Token over Tailscale) or a **FULL-REMOTE** host
|
|
7
|
+
(cloud + Ory Hydra OAuth2), selected by a per-host **connection profile**.
|
|
8
|
+
|
|
9
|
+
> Full design: [`docs/architecture/cli.md`](../docs/architecture/cli.md).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm i -g @everywheredev/cli # provides the `pocketdev` binary
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Standalone single-file builds (Bun / Node SEA / pkg) for macOS/Linux are planned so it runs without a
|
|
18
|
+
Node toolchain, including over SSH.
|
|
19
|
+
|
|
20
|
+
### Local development install
|
|
21
|
+
|
|
22
|
+
To put the `pocketdev` command on your PATH from this working copy (no registry, no publish) — needs
|
|
23
|
+
**Node ≥ 20**:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
make cli-link # from repo root: npm install + npm link (auto-builds via `prepare`)
|
|
27
|
+
# or, from cli/: npm link
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`npm link` symlinks this package globally, so `pocketdev` points at your source. After editing,
|
|
31
|
+
rebuild and the linked command picks it up — keep a watcher running for a tight loop:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npm run build:watch # rebuild dist/ on every save (run in a spare terminal)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Validate the **published** shape (the eventual `npm i -g @everywheredev/cli` experience) without touching
|
|
38
|
+
the registry — `npm pack` builds the exact tarball `files` would ship (`bin/`, `dist/`, `README.md`):
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npm pack # → everywheredev-cli-0.1.0.tgz
|
|
42
|
+
npm i -g ./everywheredev-cli-0.1.0.tgz # install it like a real user would
|
|
43
|
+
npm rm -g @everywheredev/cli # ...then remove and re-link for dev
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Remove the dev link with `make cli-unlink` (or `npm unlink -g @everywheredev/cli`).
|
|
47
|
+
|
|
48
|
+
## Quick start
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
# LOCAL-ONLY (free): point at the host on 127.0.0.1:4317 with a Personal Access Token.
|
|
52
|
+
export POCKETDEV_MODE=local
|
|
53
|
+
export POCKETDEV_TOKEN=<pat>
|
|
54
|
+
pocketdev tree
|
|
55
|
+
pocketdev open src/index.ts
|
|
56
|
+
pocketdev agent "refactor the parser and run tests"
|
|
57
|
+
|
|
58
|
+
# FULL-REMOTE (premium): device-grant login against Ory Hydra, then the same commands.
|
|
59
|
+
pocketdev --profile cloud login
|
|
60
|
+
pocketdev --profile cloud agents
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Architecture (foundation)
|
|
64
|
+
|
|
65
|
+
The pipeline mirrors Claude Code: **entry binary → DI composition root → command/router →
|
|
66
|
+
agent + tool loop (approval gate) → transport → renderer**, with a session/transcript model and
|
|
67
|
+
layered settings underneath.
|
|
68
|
+
|
|
69
|
+
Every external dependency is an injected **interface (port)**; concretes are wired **once** at the DI
|
|
70
|
+
composition root (`src/di/container.ts`, [tsyringe](https://github.com/microsoft/tsyringe)). That root
|
|
71
|
+
is the *only* place that branches on `POCKETDEV_MODE` (`local` | `remote`) — nothing downstream
|
|
72
|
+
branches on mode, so the command/tool/agent layer is byte-identical across both.
|
|
73
|
+
|
|
74
|
+
| Seam (port) | LOCAL concrete | REMOTE concrete |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `AuthProvider` | `SharedTokenAuthProvider` (PAT / `POCKETDEV_TOKEN`) | `HydraOAuthAuthProvider` (device grant + PKCE) |
|
|
77
|
+
| `HttpPort` | `HttpTransport` → `http://127.0.0.1:4317` | `HttpTransport` → `https://…` |
|
|
78
|
+
| `StreamPort` | `WsStreamTransport` → `ws://…/ws` | `WsStreamTransport` → `wss://…/ws` |
|
|
79
|
+
| `TerminalPort` | `TerminalTransport` over the stream | same |
|
|
80
|
+
| `SessionStore` | `FileSessionStore` (JSONL + `/api/sessions`) | same |
|
|
81
|
+
|
|
82
|
+
### Layout
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
cli/
|
|
86
|
+
├─ bin/pocketdev.js # shebang shim → dist/index.js
|
|
87
|
+
└─ src/
|
|
88
|
+
├─ index.ts # bootstrap: reflect-metadata, buildContainer, route
|
|
89
|
+
├─ di/{container,tokens}.ts # composition root (ONLY local/remote wiring) + injection tokens
|
|
90
|
+
├─ core/{app,command-router,errors}.ts
|
|
91
|
+
├─ config/{ports,config-store,profile,defaults}.ts # precedence flags>env>project>user>defaults
|
|
92
|
+
├─ transport/{ports,http-transport,ws-stream-transport,terminal-transport,composite-transport,reconnect}.ts
|
|
93
|
+
├─ auth/{ports,shared-token-auth-provider,hydra-oauth-auth-provider,device-flow,pkce,keychain}.ts
|
|
94
|
+
├─ session/{ports,file-session-store}.ts
|
|
95
|
+
└─ contract/index.ts # thin re-export of @pocketdev/contract types (no drift)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Configuration & precedence
|
|
99
|
+
|
|
100
|
+
Highest wins:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
1. CLI flags --host, --mode, --profile, --token, --print/-p, --json, --no-tty
|
|
104
|
+
2. Environment POCKETDEV_MODE, POCKETDEV_HOST, POCKETDEV_PORT (4317), POCKETDEV_TOKEN,
|
|
105
|
+
POCKETDEV_PROJECT_ROOT, POCKETDEV_MAX_FILE_BYTES,
|
|
106
|
+
KRATOS_PUBLIC_URL, HYDRA_PUBLIC_URL, OIDC_ISSUER
|
|
107
|
+
3. Project config ./.pocketdev/config.json
|
|
108
|
+
4. User config ~/.pocketdev/config.json
|
|
109
|
+
5. Built-in defaults
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Server-only variables (`DATABASE_URL`, `REDIS_URL`, `CASBIN_WATCHER_CHANNEL`, `STRIPE_*`,
|
|
113
|
+
`*_ADMIN_URL`) are **not** consumed by the CLI — they belong to the host.
|
|
114
|
+
|
|
115
|
+
## Authentication
|
|
116
|
+
|
|
117
|
+
- **LOCAL** — `Authorization: Bearer $POCKETDEV_TOKEN`; the host validates with a constant-time
|
|
118
|
+
compare. `pocketdev login` is a verify round-trip. No keychain, no browser.
|
|
119
|
+
- **REMOTE** — OAuth2 **Device Authorization Grant + PKCE** (RFC 8628 + 7636) against Ory Hydra;
|
|
120
|
+
access JWT used as the same Bearer header for REST and the WS handshake; tokens stored in the OS
|
|
121
|
+
keychain with a chmod-0600 file fallback for headless/CI.
|
|
122
|
+
|
|
123
|
+
## Scripts
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
npm run build # tsc --noEmit (typecheck) → esbuild bundle+minify to a single dist/index.js
|
|
127
|
+
npm run build:watch # tsc --watch → rebuild dist/ on save (pairs with `npm link`)
|
|
128
|
+
npm run dev # run from source via tsx
|
|
129
|
+
npm test # vitest
|
|
130
|
+
npm run typecheck # tsc --noEmit
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
Proprietary — internal PocketDev component.
|
package/bin/pocketdev.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// PocketDev CLI entry shim.
|
|
3
|
+
//
|
|
4
|
+
// This is the published `pocketdev` binary (see package.json "bin"). It is a thin loader whose
|
|
5
|
+
// only job is to hand control to the compiled bootstrap in dist/index.js. Keeping the shim tiny
|
|
6
|
+
// means the real wiring (DI composition root, mode selection, routing) lives in TypeScript and is
|
|
7
|
+
// fully testable — the shim itself has nothing to test.
|
|
8
|
+
//
|
|
9
|
+
// `reflect-metadata` is imported first (before any decorated class loads) because tsyringe relies
|
|
10
|
+
// on emitted design-time type metadata for constructor injection.
|
|
11
|
+
import "reflect-metadata";
|
|
12
|
+
import { main } from "../dist/index.js";
|
|
13
|
+
|
|
14
|
+
main(process.argv.slice(2)).catch((err) => {
|
|
15
|
+
// Last-resort guard: the bootstrap maps known failures to CliError with friendly hints; anything
|
|
16
|
+
// reaching here is unexpected. Print and exit non-zero so CI/pipes observe the failure.
|
|
17
|
+
process.stderr.write(`${err?.stack ?? err}\n`);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
});
|