cmdzero 0.5.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/README.md +63 -0
- package/bin/cmdzero.js +13 -0
- package/overlay/overlay.js +1284 -0
- package/package.json +35 -0
- package/src/resolver.js +694 -0
- package/src/router.js +276 -0
- package/src/server.js +316 -0
- package/src/telemetry.js +97 -0
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# CmdZero
|
|
2
|
+
|
|
3
|
+
Tweak your UI live in the browser — the changes are written straight to your source files.
|
|
4
|
+
|
|
5
|
+
- **Copy**: click any text, edit in place, Enter. Written to the JSX literal. 0 tokens.
|
|
6
|
+
- **Style**: padding/margin per side, font sizes and colors from *your* design system tokens. Deterministic Tailwind class edits. 0 tokens.
|
|
7
|
+
- **Reorder**: every selected section/card gets a move toolbar — arrows (`↑↓` for columns, `←→` for rows) or drag the `⠿` grip. Cards in a `.map()` reorder the backing array; written-out siblings swap in place; a section's outer container moves the whole `<Section/>` among its siblings in the page. 0 tokens.
|
|
8
|
+
- **Anything else**: describe it — a layered router picks a model *and* an effort level sized to the request, then runs headless `claude -p` scoped to the exact file your selection maps to.
|
|
9
|
+
|
|
10
|
+
Changes show live automatically — the overlay reloads the page (preserving scroll + selection) after a write settles, so HMR gaps (module-scope consts, structural edits) never need a manual refresh. Toggle it bottom-left.
|
|
11
|
+
|
|
12
|
+
## Model routing
|
|
13
|
+
|
|
14
|
+
| Tier | What it covers | Model | Effort (by complexity) |
|
|
15
|
+
|---|---|---|---|
|
|
16
|
+
| 1 | Styles, copy, component tweaks, existing components | `claude-sonnet-5` | low / medium / high |
|
|
17
|
+
| 2 | New logic & functionality (handlers, state, forms, data) | `claude-opus-4-8` | medium / high / xhigh |
|
|
18
|
+
| 3 | Multi-feature or cross-cutting work | `claude-opus-4-8` | xhigh |
|
|
19
|
+
| 3+ | Mission-critical (auth, payments, data, security) or very high complexity | `claude-fable-5` | high |
|
|
20
|
+
|
|
21
|
+
Routing is layered (RouteLLM-style): deterministic lexicon + structure scoring first (<1ms, free); requests with no clear signal fall through to a Haiku classifier with structured output (~1–3s, ~$0.001). Inspect any routing decision without running it: `POST /api/classify {"instruction": "..."}`.
|
|
22
|
+
|
|
23
|
+
Overrides: `CMDZERO_T1_MODEL`, `CMDZERO_T2_MODEL`, `CMDZERO_T3_MODEL`, `CMDZERO_T3_CRITICAL_MODEL`, and `CMDZERO_ROUTER=heuristic|hybrid|llm` (default `hybrid`).
|
|
24
|
+
|
|
25
|
+
## Quickstart (Next.js)
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm i -D cmdzero @cmdzero/react
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
1. `jsconfig.json` / `tsconfig.json`:
|
|
32
|
+
```json
|
|
33
|
+
{ "compilerOptions": { "jsxImportSource": "@cmdzero/react" } }
|
|
34
|
+
```
|
|
35
|
+
2. Root layout:
|
|
36
|
+
```jsx
|
|
37
|
+
import { CmdZeroOverlay } from '@cmdzero/react';
|
|
38
|
+
// inside <body>: {children}<CmdZeroOverlay />
|
|
39
|
+
```
|
|
40
|
+
3. Run the daemon next to your dev server, from the project root:
|
|
41
|
+
```sh
|
|
42
|
+
npx cmdzero
|
|
43
|
+
```
|
|
44
|
+
4. Open your app, press `⌘0`, click anything.
|
|
45
|
+
|
|
46
|
+
Works with Turbopack, webpack, and Vite — stamping happens in React's dev JSX runtime, not the bundler. Server components included. Production builds are untouched (the prod runtime is a passthrough).
|
|
47
|
+
|
|
48
|
+
## Telemetry
|
|
49
|
+
|
|
50
|
+
The daemon sends anonymous usage telemetry: package version, node version, OS platform, whether Tailwind was detected, and per-lane tweak counts. **Never** code, file paths, file names, prompts, or anything identifying. A disclosure prints the first time the daemon runs.
|
|
51
|
+
|
|
52
|
+
Opt out permanently:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
export CMDZERO_TELEMETRY=0 # or DO_NOT_TRACK=1 — both respected
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Options
|
|
59
|
+
|
|
60
|
+
- `npx cmdzero --port 4101` (+ `<CmdZeroOverlay origin="http://localhost:4101" />`)
|
|
61
|
+
- `CMDZERO_FAST_MODEL` / `CMDZERO_SMART_MODEL` — model aliases for the router (default `haiku` / `sonnet`)
|
|
62
|
+
- `CMDZERO_BASELINE_COST` / `CMDZERO_BASELINE_MS` — baseline for the savings counter
|
|
63
|
+
- Natural-language tweaks require the [Claude Code CLI](https://claude.com/claude-code) (`claude`) on your PATH; copy/style lanes work without it.
|
package/bin/cmdzero.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { startServer } from '../src/server.js';
|
|
3
|
+
|
|
4
|
+
const args = process.argv.slice(2);
|
|
5
|
+
function flag(name, fallback) {
|
|
6
|
+
const i = args.indexOf(`--${name}`);
|
|
7
|
+
return i >= 0 ? args[i + 1] : fallback;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
startServer({
|
|
11
|
+
root: flag('root', process.cwd()),
|
|
12
|
+
port: Number(flag('port', 4100)),
|
|
13
|
+
});
|