wezard 3.0.3 → 3.0.5
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/CLAUDE.md +1 -1
- package/README.md +271 -193
- package/cli/wezard.sh +109 -12
- package/config.example.jsonc +26 -17
- package/dist/cli/audit.js +42 -25
- package/dist/cli/audit.js.map +1 -1
- package/dist/cli/ext.js +1 -1
- package/dist/cli/ext.js.map +1 -1
- package/dist/cli/init.js +4 -1
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/wx.js +3 -0
- package/dist/cli/wx.js.map +1 -1
- package/dist/daemon/approval.js +11 -10
- package/dist/daemon/approval.js.map +1 -1
- package/dist/daemon/audit.js +12 -0
- package/dist/daemon/audit.js.map +1 -1
- package/dist/daemon/bg-tasks.js +74 -0
- package/dist/daemon/bg-tasks.js.map +1 -0
- package/dist/daemon/channel-context.js +2 -2
- package/dist/daemon/channel-context.js.map +1 -1
- package/dist/daemon/channel-newpost.js +88 -0
- package/dist/daemon/channel-newpost.js.map +1 -0
- package/dist/daemon/channel-onboarding.js +27 -31
- package/dist/daemon/channel-onboarding.js.map +1 -1
- package/dist/daemon/channel-posts.js +51 -8
- package/dist/daemon/channel-posts.js.map +1 -1
- package/dist/daemon/channel-rebind.js +4 -5
- package/dist/daemon/channel-rebind.js.map +1 -1
- package/dist/daemon/channel.js +79 -35
- package/dist/daemon/channel.js.map +1 -1
- package/dist/daemon/danger-scrub.js +18 -1
- package/dist/daemon/danger-scrub.js.map +1 -1
- package/dist/daemon/danger-workspace.js +177 -0
- package/dist/daemon/danger-workspace.js.map +1 -0
- package/dist/daemon/danger.js +293 -23
- package/dist/daemon/danger.js.map +1 -1
- package/dist/daemon/detail.js +1 -0
- package/dist/daemon/detail.js.map +1 -1
- package/dist/daemon/handoff.js +27 -10
- package/dist/daemon/handoff.js.map +1 -1
- package/dist/daemon/http.js +15 -3
- package/dist/daemon/http.js.map +1 -1
- package/dist/daemon/inbound.js +36 -7
- package/dist/daemon/inbound.js.map +1 -1
- package/dist/daemon/index.js +584 -343
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/loop-lag.js +39 -0
- package/dist/daemon/loop-lag.js.map +1 -0
- package/dist/daemon/mcp-http.js +3 -0
- package/dist/daemon/mcp-http.js.map +1 -1
- package/dist/daemon/mirror-bridge.js +163 -48
- package/dist/daemon/mirror-bridge.js.map +1 -1
- package/dist/daemon/onboarding.js +25 -8
- package/dist/daemon/onboarding.js.map +1 -1
- package/dist/daemon/peers.js +61 -12
- package/dist/daemon/peers.js.map +1 -1
- package/dist/daemon/quota.js +1 -1
- package/dist/daemon/quota.js.map +1 -1
- package/dist/daemon/room-archive.js +189 -0
- package/dist/daemon/room-archive.js.map +1 -0
- package/dist/daemon/room-bind.js +16 -109
- package/dist/daemon/room-bind.js.map +1 -1
- package/dist/daemon/room-facts.js +2 -1
- package/dist/daemon/room-facts.js.map +1 -1
- package/dist/daemon/room-hub.js +65 -10
- package/dist/daemon/room-hub.js.map +1 -1
- package/dist/daemon/room-watchdog.js +4 -0
- package/dist/daemon/room-watchdog.js.map +1 -1
- package/dist/daemon/rooms.js +203 -11
- package/dist/daemon/rooms.js.map +1 -1
- package/dist/daemon/spawn-tmux.js +41 -21
- package/dist/daemon/spawn-tmux.js.map +1 -1
- package/dist/daemon/steward-model.js +19 -4
- package/dist/daemon/steward-model.js.map +1 -1
- package/dist/daemon/steward.js +12 -0
- package/dist/daemon/steward.js.map +1 -1
- package/dist/daemon/store-metrics.js +124 -0
- package/dist/daemon/store-metrics.js.map +1 -0
- package/dist/daemon/tool-latency.js +24 -0
- package/dist/daemon/tool-latency.js.map +1 -0
- package/dist/daemon/wezard-session.js +1 -1
- package/dist/daemon/wezard-session.js.map +1 -1
- package/dist/daemon/wizard.js +4 -4
- package/dist/daemon/wizard.js.map +1 -1
- package/dist/daemon/zombie-panes.js +216 -0
- package/dist/daemon/zombie-panes.js.map +1 -0
- package/dist/mcp/tools.js +20 -17
- package/dist/mcp/tools.js.map +1 -1
- package/dist/shared/chat-http.js +8 -4
- package/dist/shared/chat-http.js.map +1 -1
- package/dist/shared/cli-backends.js +13 -1
- package/dist/shared/cli-backends.js.map +1 -1
- package/dist/shared/config.js +45 -8
- package/dist/shared/config.js.map +1 -1
- package/dist/shared/daemon-client.js +13 -2
- package/dist/shared/daemon-client.js.map +1 -1
- package/dist/shared/external.js +0 -1
- package/dist/shared/external.js.map +1 -1
- package/dist/shared/group-members.js +2 -1
- package/dist/shared/group-members.js.map +1 -1
- package/dist/shared/log.js +76 -5
- package/dist/shared/log.js.map +1 -1
- package/dist/shared/mention-filter.js +63 -0
- package/dist/shared/mention-filter.js.map +1 -0
- package/dist/shared/room-view.js +32 -2
- package/dist/shared/room-view.js.map +1 -1
- package/dist/shared/room.js +12 -3
- package/dist/shared/room.js.map +1 -1
- package/dist/shared/session-hooks.js +1 -1
- package/dist/shared/session-hooks.js.map +1 -1
- package/dist/shared/topic-room.js +23 -0
- package/dist/shared/topic-room.js.map +1 -0
- package/dist/shared/workspace-trust.js +88 -2
- package/dist/shared/workspace-trust.js.map +1 -1
- package/dist/shared/world.js.map +1 -1
- package/dist/svr/index.js +3 -37
- package/dist/svr/index.js.map +1 -1
- package/dist/svr/room-reader.js +140 -0
- package/dist/svr/room-reader.js.map +1 -0
- package/hooks/pre-tool-use.sh +2 -0
- package/package.json +1 -1
- package/web/chat.js +314 -45
package/CLAUDE.md
CHANGED
|
@@ -80,7 +80,7 @@ Three processes, all coordinating via the daemon's unix control socket (`<stateD
|
|
|
80
80
|
- `peers.ts` is the read side of multi-agent awareness — "who else is working in this chat, and are they busy". A wizard's HOME chat is its target key's base principal (`baseOfKey`): the untagged default plus every slot `chat:xxx#slot`. Pure parsing only — bounded transcript-tail reads (`talkTurns` / `lastAssistantText` / `summarizeTail`, the last shared with `session-scan.ts`) and pane classification (`paneIsBusy`). **What a wizard reads about another comes from the transcript, never from a pane capture**: text turns only (`talkTurns`), and "where is it stuck" is `openToolUses` (a tool call left hanging on an idle session = parked on an approval card). The pane is consulted for exactly one thing, `busy`. Read-side tools (`wizard_roster` / `peek_peer` / `room_read`) answer in plain text rendered daemon-side, not json; `room_read` renders a room's ledger (`shared/room-view.ts`), not a transcript. Which channel a line belongs to and who said it is read back from the room wake header + trigger line (`shared/inject-view.ts`), or — for scheduled tasks and old transcripts — from the envelope riding on that user line (`parseEnvelope`, `shared/reminder.ts`): every wezard `<system-reminder>` carries its facts as opening-tag attributes (`wezard=` one of the `REMINDER_KINDS` — `envelope|message-event|hint|lead|mention|roster|charter`, plus `after|pending|chatlog` which are registered but have no production writer today; `kind` / `from` / `scope`, `chat-key` on the scheduled-task envelope, the injection event id as `msg`; the old human/peer envelopes' `chat` / `chat-key` / `asker-*` / `receipt` attrs are read-only legacy) and its prose only for the model; which attrs each kind may write is the `REMINDER_KINDS` registry (each attr is either read back by code or an id the model copies into `re`/`for`/`drop`), and `renderTail` lays one injection's tail out in a fixed order, envelope first — rewording the prose never breaks parsing; only the current attribute envelope is parsed, without inferring facts from older prose. The rolepage collapses each reminder into a tag named by its kind (`<envelope · .x>`, `<回执 · .x · need>`, `<roster>` …) that expands to raw on click; **the human envelope is gone** — an envelope now rides only on scheduled-task injections (and the memory steward's), and a room wake carries no `wezard=envelope` at all (who spoke = the ledger row's author, which chat = the room in the wake header; a human line is an author that is neither `.name` nor `wezard`). The reminder tails a human line used to drag into the ledger row (steward hint, mention hint, notice/roster) are no longer part of the row: a human row stores only the human's words, and `daemon/wake-tail.ts` `humanWakeTail` computes the hint + mention tail (and the turn's channel/speaker for the live seal) at wake time from the triggering human rows, handed through `room-hub` `tailOf` → `injectText({tail})` to `noticeSuffixFor` (so they are rendered only after the pane gate lets the paste through, and notice/mention dedup is recorded at that point — a paste that fails or is uncertain after the gate has used this round's hint up, same as roster increments); old rows that still carry a tail are read through `rowText` (`shared/room.ts`, strips trailing wezard blocks on `origin:"inbound"` rows) without rewriting them. After a reload, `openingOf` recovers a human turn's channel/speaker from the wake header and trigger line (`shared/inject-view.ts` `humanOpening`; bound room → channel = the chat, `dm:`/`adhoc:` → private `""`), and still reads old human envelopes from old transcripts. `room-hub.ts` `render` lays out a `【label】(roomId)` header plus one `renderMsgLine` row per message, and the rolepage reads the room back from that header (`shared/role-render.ts` `blocks` / `injRoom`, via `parseInjection`); the `peer` kind in `parseEnvelope` exists only to read old transcripts. A clone's transcript starts with its parent's forked history, so its rounds older than `bornAt` are dropped. Identity (name / responsibility / memory / lineage) lives in `wizard.ts`, not here. **Busy detection matches the TUI spinner footer** (`… (12m 31s · …)` on current versions, `esc to interrupt` on older ones) in the last 8 non-blank rows — transcript mtime is useless here, it goes quiet during long tool calls.
|
|
81
81
|
- `wizard.ts` is the identity layer over those sessions: a target key plus a **globally unique name** — the wizard's only address, written `.name` everywhere a human or model sees it (a chat's default session takes the chat's name, a slot takes its slot id; collisions get `-N` via `pickName`; `settleName` claims lazily, `settleAll` initializes unnamed current identities at boot, default sessions first). The slot id inside the key is NOT the name: a rename never rekeys a session. Plus a one-line responsibility, a long-term `memory` list, and a `parent` link for management ownership. Every collaborative spawn/clone belongs to its caller, including cross-cwd/chat creation and cloning context from another wizard; `forkOf` records a different context source. Horizontal communication does not change parent ownership. Ending an identity is limited to itself or its direct parent; active/paused plans prevent logical retirement, and children must be handled before their parent can be forgotten. Completed work retains wizard identities by default; pane resource eviction keeps identity and binding. The registry is a write-through json (`~/.wezard/wizards.json`, `wrc.mirror.wizardsFile`) bound process-wide via `bindWizardStore` so the IM side can read it too; everything else in the module is a pure renderer. **Identity travels as the first message's preamble, not the system prompt**: `renderCharter` builds the wizard's charter (who it is, its workspace, its clones, its memory, the chat's and the workspace's shared memory (`wizard-memory.ts`: `~/.wezard/memory/{chats,workspaces}/*.md`, human-editable, appended by `wizard_remember({scope})`), the tool roster, the orchestration playbook, how to talk through rooms). `spawn-tmux` only parks it at `charters/<sid>.md` (claude/codebuddy no longer get `--append-system-prompt` — it cost ~1.4s per cold start); the attachment's `charterPending` prepends it as `<system-reminder wezard="charter">` to the pane's first non-slash injection and clears it once that injection is confirmed. It is re-armed on every moment a session has not read it: `/new`, a spare-pool claim, a dead-pane `--resume` respawn (only when the transcript has no charter block since the last `compact_boundary`: `charterInContext`; already owed / unreadable transcript still arm), `/clear` and compaction (`onContextCut` → `armCharter`); a clone's opening line carries the child's charter, superseding the parent's inherited one. Read sides (`stripMeta`, `cleanUserText`, rolepage) strip/collapse the `charter` reminder, so it never becomes a chat ask or a bubble. Codex keeps it in `developer_instructions`. Every spawn path (`/new`, a dead-pane respawn, a clone) pulls it from `MirrorBridge.setCharterProvider`, installed in `index.ts`. Since a running wizard never sees a new charter, `config_set` renders every chartered wizard's charter before and after the change and tells the affected ones (and the caller) to `handoff` — generic over whatever config the charter reads. Backends with no such flag spawn without a charter rather than with a rejected flag.
|
|
82
82
|
- **Cloning is a context fork**: `MirrorBridge.cloneSession` spawns `--resume <parent sid> --fork-session`, so the child starts holding everything the parent had read while the parent is untouched — that is what makes "load the shared material once, then fan out" work. Two invariants: `--fork-session` is mandatory (without it a second pane appends to the parent's jsonl and two chats cross-wire), and the attach waits for the forked transcript (codebuddy 2.167 writes it at process start — a byte copy of the parent plus a `session-meta` row, no API call; older CLIs only on the first message); if it never appears the pane is killed rather than bound to the parent's sid.
|
|
83
|
-
- **Rooms are the only thing wizards talk through** (`shared/room.ts` pure core — row types, fold, `judge`, wake rules, ids; `daemon/rooms.ts` store; `daemon/room-hub.ts` the only append door + wake pump; contract in `docs/room/contract.md`). A WeCom group / DM
|
|
83
|
+
- **Rooms are the only thing wizards talk through** (`shared/room.ts` pure core — row types, fold, `judge`, wake rules, ids; `daemon/rooms.ts` store; `daemon/room-hub.ts` the only append door + wake pump; contract in `docs/room/contract.md`). A WeCom group / DM is a *bound* room (id = the base principal verbatim); a channel post is a *bound* room too, one per post, id `topic:<topic_id>/<post_id>` (`shared/topic-room.ts`; the channel itself has no room — it only binds a host identity, `wrc.channel.steward.<topic_id>` = class, one instance per topic room; legacy `chat:<opk>` post rooms keep working and the old `chat:<topic_id>` channel room is a read-only archive; inbound resolves bind > existing topic room > legacy post room > pairing lookup > new id; outbound in a topic room always comments the root post, and `chat_say` to `chat:<topic_id>` opens a new post); two wizards' conversation is an unbound `dm:<uidA>|<uidB>` room (stable instance uids, never names); 3+ is an `adhoc:<hex>` room opened with `room_open`. A room is one append-only, fsync-per-append jsonl under `<stateDir>/rooms/` (`roomsDirOf` is the single derivation — never `join(…, "rooms")` locally); state is a fold of the rows, a torn tail line is dropped, a corrupt middle line makes that room fail closed (503). Humans (inbound) and wizards (tools) append through the same `judge` (membership, who may write a `status`, dedup, wake targets, budget); a rejected line never becomes a row. **Completion, origin and the right to speak are explicit fields on ledger rows, never inferred from a transcript or a final line**: `chat_ask` opens a *duty* on its `to`; only that holder's `chat_reply` with status `done` / `passed` / `canceled` closes it (`need` / `progress` / `error` don't); `chat_say` / `notify` open nothing. `wakeTargets`: the named, the asker of a `re`, the host for an unaddressed human line in a bound room, and `room_watch` subscribers on human lines / closing replies; host = the earliest-joined wizard member, evaluated on read. A bound room mirrors every `msg` row to WeCom except `origin` inbound/migrate and `trigger` rows (`mirrors()`); dm/adhoc rows live only on the rolepage.
|
|
84
84
|
- **The wake pump keeps no queue** (`room-hub.ts`): who is owed what, and what to show them, is recomputed from the ledger every pass — a row with `wake∋uid` past the member's `seen` cursor is pending. The `seen` row is written only after a confirmed paste; an uncertain paste leaves the cursor and re-delivers the same batch marked "maybe already read", so a reload loses nothing. A target with no session at all (`gone`: its binding was dropped by `stop_wizard` end / `/kill`) is not woken by retrying: each duty it holds in the batch gets one `undelivered` system row to its asker (cursor untouched, so a same-name respawn still reads them); other failures log one warn per state change. A busy live pane waits for its turn to end; `interrupt:true` (direct parent / host / human only, budgeted per room) presses Esc first; a cold wizard is not "busy" — pasting respawns it. A wizard that ends a turn still owing a duty gets one reminder (in-turn via the Stop hook `hooks/stop.sh` for backends that honor `decision:block`, else at turn end), then a system row to the asker. `room-watchdog.ts` writes `canceled` for the duties of a wizard whose pane is truly gone (two confirming scans, never on a failed tmux call). `after` on a `chat_ask` defers the wake until the listed duties are `done`. **Overdue** (`shared/room-overdue.ts` pure, `daemon/room-overdue.ts` scan on the watchdog cadence): an open ask/task/human duty held by a wizard and idle (no non-daemon row touching it) for `rooms.overdue.remindMin` (60) gets a `trigger` row `sys:"overdue-remind"` that wakes the holder; at `groupMin` (120) a non-waking `sys:"overdue-group"` system row lands in the room, and — if the room is unbound — in the holder's (else asker's) home group so a human sees it. A child the holder dispatched also counts as activity: a task/ask row's `for` is its lineage (the msg id of the duty it was dispatched for — defaulted by the daemon, `hub.defaultFor`, to the single duty that woke the caller this turn when `for` is omitted; zero or several → left empty), so the child's own row, any non-daemon row answering it (its `done` closes included) and its descendants' (cross-room, depth ≤ 5) restart the parent's clock. Reminding is **leaf-first**: while a duty still has an open, still-known child duty on its `for` lineage, neither level fires for the parent — the child's holder is the one reminded; once the children close, the closing row restarts the parent's clock and the parent is reminded `remindMin` later (an orphan child whose holder left the roster does not block). And a holder that is **busy** (mid-turn, or parked on an approval card — `MirrorBridge.isBusy`) is skipped for that pass: no row is written, it is judged again once idle. Both hot, 0 = off, ledger-deduped, never auto-`canceled`.
|
|
85
85
|
- **`delegate` / `route_candidates`** (`daemon/route.ts`, the deterministic half of dispatch): candidates are filtered and ordered by evidence (files it read > responsibility > recent asks; same workspace only breaks ties), each with its cost line (cache cold / ctx size → what waking it costs vs. a white-board spawn); `decide` takes the first candidate no veto rejects (weak evidence, busy, not worth it, cold cache with big ctx — `force` crosses only the last) or spawns a white-board wizard at `tierFor`. The product of `delegate` is one `chat_ask`; the caller may override (`to`, `spawn`, `force`, `tier`, `lead`). `lead` is per job: `WizardRecord.leadOf` records the task rows that made it a lead, and the daemon clears `lead` once all of them are closed and it owns no unfinished plan (`leadSettled`, run after every closing row via the hub's `onClosed`, after plan updates, and at boot — where legacy leads without `leadOf` are cleared if no peer-opened duty is still open). In-flight work is the room ledger's open duties (`openDuties` / `dutyFacts` in `shared/room-view.ts`); the old `TurnState` / `WorldFacts.inflight` vocabulary is gone.
|
|
86
86
|
- **Steward hand-brake** (`approval.ts` / `steward-guard.ts`): triggered by role (`isStewardTarget`: the chat's bound steward, else its default session), ahead of every approval path — it may not edit files or open subagents, and caps its own look-commands per turn at `chatPolicy.<chat>.stewardBudget` (reading code — Read/Grep/Glob and read-only shell commands — passes free; the deny reason points at `delegate`). A new group's onboarding guide has no tool surface at all (`onboarding.ts` `guideRefusal`) except `chat_reply` / `chat_say` / `onboard_bind`.
|