@zonease/aiworker-cli 0.10.2 → 0.10.3

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 CHANGED
@@ -7,48 +7,101 @@ Self-hosted, lightweight **Project Brain + Worker/Fleet aggregation runtime**.
7
7
  - **Worker** owns the Project Brain (filesystem is the source of truth), worker.db, and conversations. External executors (Codex / Claude Code / Hermes / OpenClaw / Cursor, etc.) are invoked through a thin adapter only.
8
8
  - **Gateway is an optional control plane**: a single worker runs without one. With multiple workers, the gateway aggregates presence, routing, and audit — it never holds brain or conversation data.
9
9
 
10
+ ## Why AIWorker exists
11
+
12
+ AIWorker is not trying to be a smarter coding assistant or a new executor
13
+ platform. If all you need is a better one-off chat or coding agent, use Codex,
14
+ Claude Code, Cursor, Hermes, OpenClaw, or another executor directly.
15
+
16
+ Use AIWorker when you already trust external executors, but need to run them as
17
+ durable, governed workers bound to a real business scope:
18
+
19
+ - **Project Brain as an owned asset**: each worker has a filesystem-first,
20
+ reviewable, portable brain for scope identity, persona, policy, memories,
21
+ rollups, and brain skills.
22
+ - **Governed self-iteration**: an executor can propose durable brain changes,
23
+ but memory and brain-skill writes must pass admission, approval,
24
+ secret-scan, provenance, and audit.
25
+ - **Bring your own executor**: AIWorker does not replace the executor's tool
26
+ loop, MCP, plugins, sandbox, native sessions, auth, or model routing. It
27
+ wraps them with scope context, persistence, observation, and governance.
28
+ - **Worker/Fleet operations**: one worker can run alone; many workers can be
29
+ aggregated by a gateway for presence, routing, logs, approvals, cron, and
30
+ audit without copying brain, conversations, or secrets into fleet.db.
31
+
32
+ In short: AIWorker turns existing AI agents into self-hosted, scope-bound,
33
+ auditable business workers. The competitive edge is not "better model output";
34
+ it is durable Project Brain plus governance and fleet operations around the
35
+ executors customers already use.
36
+
37
+ ## Who needs AIWorker
38
+
39
+ AIWorker is a good fit when you want AI agents to behave less like disposable
40
+ chat windows and more like managed workers tied to real work.
41
+
42
+ - **Teams that already use AI executors** and want durable scope memory,
43
+ policy, persona, and reviewable brain files around them.
44
+ - **Operators running agents for business scopes**, such as a code repository,
45
+ hiring pipeline, finance period, support queue, compliance folder, or
46
+ operational runbook.
47
+ - **Organizations that need governance before self-learning**, where memory or
48
+ brain-skill changes can be proposed by an agent but must be reviewed,
49
+ approved, and audited.
50
+ - **People running more than one worker**, where presence, routing, logs,
51
+ approvals, schedules, and enrollment need one control plane without moving
52
+ private brain or conversation data into that control plane.
53
+ - **Customers who need to keep their own data local**, while still using the
54
+ executor, model, auth, and tool ecosystem they already trust.
55
+
56
+ If you only need a one-off coding session, a single chat, or a better model
57
+ answer, AIWorker is probably more infrastructure than you need.
58
+
59
+ ## Topology
60
+
10
61
  ```text
11
- Operator / Admin
12
- | aiworker fleet ...
13
- | WS basicauth + token
14
- v
15
- +------------------------------------------------+
16
- | AIWorker Gateway (optional control plane) |
17
- | fleet.db : pointers + audit only |
18
- | no brain no chat data no secrets |
19
- +------+-------------+-------------+-------------+
20
- v v v WS relay
21
- Worker A Worker B ... Worker N
22
- |
23
- | a single worker also runs without a gateway
24
- v
25
- +------------------------------------------------+
26
- | Per-worker data plane |
27
- | |
28
- | worker.db identity / config / chat |
29
- | AES-256-GCM |
30
- | |
31
- | Project Brain filesystem authoritative |
32
- | AGENT / SOUL / USER |
33
- | memories / brain skills |
34
- | policy / admission state |
35
- | |
36
- | Thin Adapter health / run / stream |
37
- | cancel / resume |
38
- | | |
39
- | v invoke |
40
- | External Engine |
41
- | Codex / Claude Code / Hermes |
42
- | OpenClaw / Cursor / ACP / MCP / HTTP |
43
- | | |
44
- | v loads ambient |
45
- | user/host MCP / skills / plugins |
46
- | auth / native sessions |
47
- | (not owned by AIWorker) |
48
- +------------------------------------------------+
62
+ Operator / Admin
63
+ runs `aiworker fleet ...`
64
+ |
65
+ | WebSocket control traffic
66
+ | basicauth + device token
67
+ v
68
+ +--------------------------------------------------------------------------------+
69
+ | AIWorker Gateway (optional control plane) |
70
+ | |
71
+ | fleet.db stores: worker pointers, presence, enrollment state, audit events |
72
+ | fleet.db does not store: Project Brain, conversations, worker secrets |
73
+ +---------------------------+----------------------------+-----------------------+
74
+ | |
75
+ | WS relay / routing | WS relay / routing
76
+ v v
77
+ +----------------------+ +----------------------+
78
+ | Worker A | | Worker B ... N |
79
+ | owns its own data | | owns its own data |
80
+ +----------------------+ +----------------------+
81
+
82
+ A single worker can also run without the gateway:
83
+
84
+ +--------------------------------------------------------------------------------+
85
+ | One worker data plane |
86
+ | |
87
+ | Project Brain (filesystem) worker.db |
88
+ | - SOUL / USER / MEMORY - identity and config |
89
+ | - memories and brain skills - conversations and messages |
90
+ | - policy and capabilities - encrypted local state |
91
+ | - admission proposals |
92
+ | |
93
+ | AIWorker thin adapter |
94
+ | - adds scope context and governance |
95
+ | - observes run / stream / cancel / resume |
96
+ | - does not replace the executor tool loop |
97
+ | |
98
+ | External executor |
99
+ | - Codex / Claude Code / Hermes / OpenClaw / Cursor / ACP / MCP / HTTP |
100
+ | - keeps its own MCP, skills, plugins, auth, sandbox, and native sessions |
101
+ +--------------------------------------------------------------------------------+
49
102
  ```
50
103
 
51
- A single worker can run standalone — the gateway is needed only when you want to aggregate multiple workers. The control plane and the data plane are physically isolated: fleet.db never stores brain / conversations / secrets, and worker.db is never reverse-fetched by the gateway. Full architecture and dual-view mermaid diagrams: [`docs/architecture.md`](docs/architecture.md). Whether this build meets the Project Brain governance node target: [`docs/governance-node-status.md`](docs/governance-node-status.md).
104
+ A single worker can run standalone — the gateway is needed only when you want to aggregate multiple workers. The control plane and the data plane are physically isolated: fleet.db never stores brain / conversations / secrets, and worker.db is never reverse-fetched by the gateway. Full architecture and dual-view diagrams: [`docs/architecture.md`](docs/architecture.md). Production-readiness notes and remaining boundaries: [`docs/governance-node-status.md`](docs/governance-node-status.md).
52
105
 
53
106
  ---
54
107
 
@@ -60,22 +113,37 @@ bun install -g @zonease/aiworker-cli
60
113
  # or `npx` / `npm install -g` (Bun is still required at runtime)
61
114
  ```
62
115
 
63
- The CLI is Bun-native. The first run mints a master key and writes it to `~/.aiworker/.env` (chmod 0600). **The master key must be backed up offline at the org level** — if it is lost, worker.db / fleet.db cannot be decrypted and every worker must re-enroll.
116
+ The CLI is Bun-native. The first worker initialization mints a master key and writes it to the worker-local `.env` (project workers use `<project>/.aiworker/local/.env`; explicit/user homes use `<AIWORKER_HOME>/.env`). **The master key must be backed up offline at the org level** — if it is lost, worker.db / fleet.db cannot be decrypted and every worker must re-enroll.
64
117
 
65
118
  Full install and per-platform binaries: [`docs/deployment.md`](docs/deployment.md).
66
119
 
67
120
  ---
68
121
 
122
+ ## CLI discovery
123
+
124
+ `aiworker --help` is intentionally short and shows the first-run path. Use
125
+ `aiworker commands` for the complete command index, or scoped help for a role:
126
+
127
+ ```sh
128
+ aiworker --help
129
+ aiworker commands
130
+ aiworker worker --help
131
+ aiworker fleet --help
132
+ aiworker gateway --help
133
+ ```
134
+
135
+ ---
136
+
69
137
  ## Start a worker (single host, no gateway)
70
138
 
71
139
  The most common path: turn the current business directory into a worker scope, start a local server + admin UI, and chat through the CLI. **No fleet credentials required.**
72
140
 
73
141
  ```sh
74
142
  cd ~/code/my-project
75
- aiworker up --soul developer # one shot: init + executor select + doctor + serve
143
+ aiworker up --soul developer # one shot: init + doctor + executor readiness + serve
76
144
  ```
77
145
 
78
- `aiworker up` lays down the Project Brain layout under `<cwd>/.aiworker/` (worker.db, master key, persona, brain skills), runs the preflight checks, and starts the worker HTTP/admin server (default `:9217`). Pick a Soul from `developer` / `hr-recruiting` / `finance-ops` / `qa-reviewer` / `general-assistant` — Souls shape persona / risk preferences / default brief sections; governance kernel behavior is the same across all Souls.
146
+ `aiworker up` lays down the Project Brain layout under `<cwd>/.aiworker/` (worker.db, master key, persona, brain skills), runs the preflight checks, reports executor readiness, and starts the worker HTTP/admin server (default `:9217`). It does not choose an executor for you; use `aiworker executor select --engine <id> --apply` for that. Pick a Soul from `developer` / `hr-recruiting` / `finance-ops` / `qa-reviewer` / `general-assistant` — Souls shape persona / risk preferences / default brief sections; governance kernel behavior is the same across all Souls.
79
147
 
80
148
  Step-by-step alternative:
81
149
 
@@ -95,6 +163,11 @@ After it is running:
95
163
  - Bearer token: `<scope>/.aiworker/local/bootstrap-token.txt`. REST calls must include `Authorization: Bearer <token>`.
96
164
  - Brain and conversations stay local. The only outbound traffic is whatever the external executor itself talks to (its own LLM provider).
97
165
 
166
+ New worker-local `.env` files reserve commented gateway enrollment examples.
167
+ `aiworker doctor` also reports gateway enrollment as standalone/configured and
168
+ prints the exact `aiworker env ...` commands when enrollment is optional but not
169
+ yet configured.
170
+
98
171
  Full CLI reference: [`docs/cli.md`](docs/cli.md).
99
172
 
100
173
  ---
@@ -130,14 +203,16 @@ The most common path — the worker side carries no fleet credentials, the opera
130
203
  ```sh
131
204
  # Worker side:
132
205
  aiworker init --soul developer
133
- printf '%s\n' \
134
- "AIWORKER_GATEWAY_URL=wss://your-gateway.example/" \
135
- "AIWORKER_DISPLAY_NAME=my-laptop" \
136
- >> .aiworker/local/.env
206
+ aiworker env gateway-url wss://your-gateway.example/
207
+ aiworker env display-name my-laptop
137
208
  aiworker serve
138
209
  # stdout prints an OTP, e.g. YDCR-ZD8M
139
210
  ```
140
211
 
212
+ `aiworker init` also leaves commented `AIWORKER_GATEWAY_URL` /
213
+ `AIWORKER_DISPLAY_NAME` examples in the worker-local `.env`; keep them
214
+ commented unless you intentionally configure gateway enrollment.
215
+
141
216
  ```sh
142
217
  # Operator side:
143
218
  aiworker fleet enroll list # see pending OTPs
@@ -234,8 +309,8 @@ See [`docs/deployment.md`](docs/deployment.md).
234
309
  |---|---|
235
310
  | `AIWORKER_MASTER_KEY` | 64 hex; AES master key for worker / gateway databases; **must be backed up offline** |
236
311
  | `INTERNAL_SHARED_SECRET` | Remote-operator bearer when the gateway is exposed publicly or off loopback (≥16 chars) |
237
- | `AIWORKER_GATEWAY_URL` | Worker-side gateway URL (path + basicauth); for project workers prefer `.aiworker/local/.env` |
238
- | `AIWORKER_DISPLAY_NAME` | Worker label in the fleet list (defaults to hostname); persisted per worker in `.aiworker/local/.env` |
312
+ | `AIWORKER_GATEWAY_URL` | Optional worker-side gateway URL (path + basicauth); set with `aiworker env gateway-url <url>` |
313
+ | `AIWORKER_DISPLAY_NAME` | Optional worker label in the fleet list (defaults to hostname / worker id); set with `aiworker env display-name <name>` |
239
314
  | `AIWORKER_HOME` | Explicit worker state root; project scope auto-resolves to `<project>/.aiworker/local` |
240
315
  | `AIWORKER_ADMIN_EXTERNAL_AUTH` | Set to `1` if `/admin/*` is fronted by Caddy / Cloudflare Access / Logto / etc. |
241
316
 
@@ -245,14 +320,13 @@ Full list: `apps/api/.env.example` + `ops/compose/.env.example`, or [`docs/archi
245
320
 
246
321
  ## More
247
322
 
248
- - [`docs/architecture.md`](docs/architecture.md) — monorepo layout, data flow, security model, Brain Governance Kernel decision, full env table
249
- - [`docs/governance-node-status.md`](docs/governance-node-status.md) — source-backed assessment of whether this build meets the Project Brain governance node target
323
+ - [`docs/architecture.md`](docs/architecture.md) — system layout, data flow, security model, Brain governance boundary, full env table
324
+ - [`docs/governance-node-status.md`](docs/governance-node-status.md) — production-readiness checklist and remaining boundaries
250
325
  - [`docs/gateway.md`](docs/gateway.md) — WS protocol (METHODS / EVENTS) and the four enrollment paths
251
326
  - [`docs/deployment.md`](docs/deployment.md) — three deployment shapes runbook + troubleshooting + backup checklist
252
327
  - [`docs/deployment-public-https.md`](docs/deployment-public-https.md) — public-internet Cloudflare + Caddy overlay (including the BUG-007 fail-closed fix)
253
328
  - [`docs/executor-engines.md`](docs/executor-engines.md) — per-engine auth/install
254
329
  - [`docs/cli.md`](docs/cli.md) — full CLI reference
255
- - [`scripts/governance-kernel-harness.ts`](scripts/governance-kernel-harness.ts) — Brain Governance Kernel regression harness (compact / full × source-local / cli-release-local)
256
330
  - [`docs/changelog.md`](docs/changelog.md) — release history and end-to-end test notes
257
331
 
258
332
  ---
@@ -265,24 +339,29 @@ cd aiworker && bun install
265
339
  bun run typecheck && bun run lint && bun run test
266
340
  ```
267
341
 
268
- New features go through the `/pma` skill in three stages: investigate → proposal → implement. Backend uses `/pma-bun`, frontend uses `/pma-web`, code review uses `/pma-cr`. Docs: [`docs/plan/`](docs/plan/) / [`docs/task/`](docs/task/) / [`docs/changelog.md`](docs/changelog.md).
342
+ For local development, run focused package checks while iterating and the full
343
+ gate before publishing or merging. Planning notes, implementation history, and
344
+ release records live in [`docs/plan/`](docs/plan/), [`docs/task/`](docs/task/),
345
+ and [`docs/changelog.md`](docs/changelog.md).
269
346
 
270
347
  ---
271
348
 
272
349
  ## Status
273
350
 
274
- > Before going to production, read the conformance table and residual-boundary section in [`docs/governance-node-status.md`](docs/governance-node-status.md). Pre-1.0 the CLI / API / config does not guarantee backwards compatibility (an explicit AGENTS.md commitment).
351
+ > Before going to production, read the readiness table and remaining-boundary
352
+ > section in [`docs/governance-node-status.md`](docs/governance-node-status.md).
353
+ > Before 1.0.0, CLI / API / config shapes may still change.
275
354
 
276
- CLI npm latest: **0.10.2**.
355
+ CLI npm latest: **0.10.3**.
277
356
 
278
357
  | Module | Status |
279
358
  |---|---|
280
- | Worker / Fleet control plane / 4 enrollment paths / 6 LLM engines / 5 channel webhooks / cron / per-tool approvals / hot reload | ✅ Production |
281
- | Brain Governance Kernel (admission state machine + secret-scan defense + canonical memory boundary + truthful decision events + bypass detection) | ✅ GA |
282
- | Governance Kernel regression harness (5×2 matrix on source + cli-release-local with 800+ checks) + long-running serve multi-turn REST regression | ✅ GA |
283
- | Brain admission `memory-add` materializer | ✅ MVP (other kinds return `unsupported`; post-apply rollback not yet implemented) |
284
- | Heavy LLM-backed Brain decider | 🔜 opt-in; defaults to `evaluator=heuristic` `mode=observe_only` |
285
- | Cross-scope hard isolation (runtime-enforced) | 🔜 currently filesystem-conventional, not runtime-isolated |
359
+ | Worker and Fleet operations: control plane, enrollment, executor adapters, webhooks, schedules, per-tool approvals, hot reload | ✅ Production |
360
+ | Project Brain governance: reviewed memory changes, secret scanning, provenance events, canonical memory boundary, bypass checks | ✅ GA |
361
+ | Governance regression coverage: 800+ checks across source and packaged CLI, plus long-running worker REST regression | ✅ GA |
362
+ | Memory-write automation | ✅ MVP (`memory-add` is available; other proposal types are rejected until implemented) |
363
+ | Optional LLM-backed Brain reviewer | 🔜 opt-in; default is observe-only heuristic review |
364
+ | Cross-scope runtime isolation | 🔜 currently convention / filesystem only |
286
365
  | Web SPA pending UI / Multi-host HA | 🔜 Stage-2 |
287
366
 
288
367
  ---