Repository navigation
zcode-cli 3.8.1-23
Enable workspace-hook trust system in the TUI session factory
-
TUI session factory now enables the workspace-hook trust system: bootstrap passes
workspaceHookTrustEnabled: true(TODO T1 completed) (scripts/sync-runtime.ts,scripts/check-runtime.ts,vendor/zcode.cjs,test/sync-runtime.test.ts,TODO.md, newTODO-archive.md).- Why: the runtime already ships a complete project-level trust system for workspace hooks (
pending_trust -> trusted_persistentstate machine, declarationsha256+ bundle digest binding, persistent trust store at~/.zcode/security/workspace-hook-trust-v1.json, and thezcode hooks trust status/grant/revokecommand family); the headless protocol path (--prompt) already setsworkspaceHookTrustEnabled:!0; only zcode-cli's TUI session factory never passed it, so the runtime side was permanentlyfalseand project-level hooks were disabled as a whole (a CLI grant had no effect, and every session loggedworkspace_hook.feature_disabled). The consequence was that DayTradingAgent had to fall back to two security hooks under the user-level~/.zcode/cli/config.json, and on 2026-09-04 that path was measured to be overwritten wholesale by a stale snapshot when the client saves settings -- the project-level single source is the stable state. - What changed: (1)
sync-runtime.tsgainspatchRuntimeWorkspaceHookTrust(runtime)-- it anchors on the unique anchor of the TUI session factory (...,onWorkflowEvent:b.onWorkflowEvent})) and injects,workspaceHookTrustEnabled:!0; idempotent (returns the input unchanged when already patched) and throws withincompatiblewhen the anchor is missing; wired into theinstallTuiBridgepatch chain (betweenpatchRuntimeHttpNoContentandpatchRuntimeAgentAutoBackground). (2) The idempotent check chain incheck-runtime.tsgained the matching line. (3) The patch was actually written intovendor/zcode.cjs(net +29 bytes, at offset ~12365683) andnode --checkpasses. (4) New cases intest/sync-runtime.test.ts(injection assertion, idempotence,incompatiblethrow; the fixture cannot be executed withnew Function, so these are pure string assertions). - End-to-end verification (
tmp/smoke-hook-trust.ts, reproducible, gitignored): temporary HOME plus a project-levelSessionStarthook through the whole flow -- before granting, a new session log contains noworkspace_hook.feature_disabled(patch effective), config load logsconfig.project_hooks.pending_trust, and the hook is blocked by the trust gate (no marker file); afterzcode hooks trust grant(CLI path, status becomesworkspace_hooks_trusted_persistent) the hook actually runs in a new session (marker file appears) and the log still contains nofeature_disabled. Two findings worth keeping:SessionStarthooks run on the first turn (the first user input triggersrunSessionStartHooks("startup")), not at TUI startup, so a self-test must send a message; on macOS the/tmp -> /private/tmpsymlink makes theworkspaceIdentityrecorded by the CLI differ from the one the TUI session resolves from cwd (the grant never reaches the session), so smoke sandboxes must live on a symlink-free path (under the project'stmp/). Real workspace paths are stable and unaffected. - Verification:
bun test test/sync-runtime.test.ts26 pass; fullbun test617 pass / 0 fail across 77 files;bun run checkpasses (zcode-cli 3.8.1-23 / zcode-runtime 0.16.3). Follow-up on the DayTradingAgent side (its TODO T140 2 and 3): rerun the credential probe in a new ZCode session (should still be blocked, now by the project-level hook), then withdraw the two user-level hooks and switch back to the project-level single source. - Follow-up closure: T1 is archived into the newly created
TODO-archive.md; the same-origin risk (the client saving settings rewritesconfig.jsonwholesale from an in-memory stale snapshot, wiping external edits to thehookssection) is filed as TODO T2 (orange urgency).
- Why: the runtime already ships a complete project-level trust system for workspace hooks (
-
Added the project-root
TODO.mdand registered T1 (session bootstrap should passworkspaceHookTrustEnabled: true) (newTODO.md).- Why: verification on the DayTradingAgent side (2026-09-03~04) found that zcode-cli never passes this parameter when constructing a session, so the project-level workspace hooks trust system already built into the runtime was disabled by the host capability switch (the CLI grant was in place and the trust store persisted -- only this switch was missing). Per the cross-project split, this work item was transferred from DayTradingAgent TODO T140 (1) and registered here.
- What changed: created
TODO.md(a four-level urgency section framework plus a numbered timestamp convention) and registered T1 (orange) -- task description, threevendor/zcode.cjsoffset references (construction site ~11703354, bootstrap consumer ~11762913,!0sample ~11922028), post-completion verification criteria (rerun the credential probe in a new DayTradingAgent session, nofeature_disabledin the log, then withdraw the user-level fallback and switch to the project-level single source), and a note on the same-origin risk (measured on 2026-09-04: the client saving settings rewritesconfig.jsonwholesale from a stale snapshot, wiping external edits to thehookssection -- whether to file it separately was left undecided). This project had noTODO-archive.mdyet (first item, nothing to archive); it was created along with the first archive.
Install
npm install -g https://github.com/xhqing/zcode-cli/releases/download/v3.8.1-23/zcode-cli-3.8.1-23.tgz