diff --git a/CHANGELOG.md b/CHANGELOG.md index cbd8036..189f64e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased] +- **Windows ZCode 3.16.x (#43):** keep the official agent-server entrypoint for `supportsStorageStartup` builds, patch `resources/glm/zcode.cjs` with a reversible original backup, and add an install/uninstall regression covering the Windows path. Release as CLI `0.3.4` so the desktop sidecar can carry the fix. + - **Desktop 0.1.0-beta.1(候选,尚未打 tag):** 第一份 unsigned 桌面包,sidecar 绑 master 上的 CLI **0.3.2**,不是 Latest tag `v0.3.1` zip。GUI 版本保持 `0.1.0-beta.1`(源码从未公开发包)。 - GUI 超时:leader 退出后管道仍被子孙持有时,对启动时保存的 pid 进程组 SIGKILL;保留 500 ms `finish_read_task`。回归 `timeout_covers_pipes_after_leader_exit`。 - Dashboard 失败对齐 `StatusFailure`:timeout / exit / stdout / stderr,不只一句 `error.message`。 diff --git a/README.en.md b/README.en.md index 17a9b23..7c6e958 100644 --- a/README.en.md +++ b/README.en.md @@ -84,18 +84,18 @@ On the same model and the same 10 prompts, complete artifacts rose from 1 to 4. ## Get started -ZCode must already be installed. The commands below download the currently published 0.3.3 zip, which supports ZCode 3.12 and 3.14. On macOS a LaunchAgent re-applies the same runtime patch after an official auto-update; if the anchors moved, it skips and tells you to upgrade Keysmith. If that watcher leaves the current GUI session, a second LaunchAgent that does not watch the app bundle bootstraps it again. Project MEMORY.md no longer overrides Pier; `verify` in runtime-patch mode no longer fails on leftover wrapper smoke. `v0.3.0` stops on the startup screen. `v0.3.1` cannot patch 3.14. +ZCode must already be installed. The commands below download the currently published 0.3.4 zip, which supports ZCode 3.12, 3.14, and 3.16.x. On macOS a LaunchAgent re-applies the same runtime patch after an official auto-update; if the anchors moved, it skips and tells you to upgrade Keysmith. If that watcher leaves the current GUI session, a second LaunchAgent that does not watch the app bundle bootstraps it again. Project MEMORY.md no longer overrides Pier; `verify` in runtime-patch mode no longer fails on leftover wrapper smoke. `v0.3.0` stops on the startup screen. `v0.3.1` cannot patch 3.14. Source zip is the published entry. The tree also has a first unsigned desktop candidate (GUI `0.1.0-beta.1`); do not treat it as a shipped installer. **macOS:** ```bash -curl -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.3/zcode-keysmith-v0.3.3.zip -curl -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.3/SHA256SUMS +curl -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.4/zcode-keysmith-v0.3.4.zip +curl -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.4/SHA256SUMS shasum -a 256 -c SHA256SUMS -unzip zcode-keysmith-v0.3.3.zip -cd zcode-keysmith-v0.3.3 +unzip zcode-keysmith-v0.3.4.zip +cd zcode-keysmith-v0.3.4 python3 zcode-keysmith.py install --dry-run python3 zcode-keysmith.py install --yes ``` @@ -107,11 +107,11 @@ Fully quit and reopen ZCode, then start a new conversation. Fully quit ZCode first, then: ```powershell -curl.exe -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.3/zcode-keysmith-v0.3.3.zip -curl.exe -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.3/SHA256SUMS -Get-FileHash .\zcode-keysmith-v0.3.3.zip -Algorithm SHA256 -Expand-Archive .\zcode-keysmith-v0.3.3.zip -DestinationPath . -cd zcode-keysmith-v0.3.3 +curl.exe -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.4/zcode-keysmith-v0.3.4.zip +curl.exe -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.4/SHA256SUMS +Get-FileHash .\zcode-keysmith-v0.3.4.zip -Algorithm SHA256 +Expand-Archive .\zcode-keysmith-v0.3.4.zip -DestinationPath . +cd zcode-keysmith-v0.3.4 py zcode-keysmith.py install --dry-run py zcode-keysmith.py install --yes ``` diff --git a/README.md b/README.md index 2183a37..e84145b 100644 --- a/README.md +++ b/README.md @@ -84,18 +84,18 @@ Keysmith 给本机的 AI 编程工具装指令:先预览,再写入,能验 ## 开始使用 -本机需要已经装好 ZCode。下方命令下载目前公开的 0.3.3 zip,支持 ZCode 3.12 与 3.14。macOS 上官方自动更新换包后,LaunchAgent 会重打同一套补丁;锚点变了则跳过并提示升级 Keysmith。若监视进程掉出当前登录会话,另一个不监视 App 包的 LaunchAgent 会把它重新挂回去。项目内 MEMORY.md 不再盖过 Pier;`verify` 在 runtime-patch 下不再因 leftover wrapper smoke 失败。`v0.3.0` 会停在启动页,`v0.3.1` 打不上 3.14。 +本机需要已经装好 ZCode。下方命令下载目前公开的 0.3.4 zip,支持 ZCode 3.12、3.14 与 3.16.x。macOS 上官方自动更新换包后,LaunchAgent 会重打同一套补丁;锚点变了则跳过并提示升级 Keysmith。若监视进程掉出当前登录会话,另一个不监视 App 包的 LaunchAgent 会把它重新挂回去。项目内 MEMORY.md 不再盖过 Pier;`verify` 在 runtime-patch 下不再因 leftover wrapper smoke 失败。`v0.3.0` 会停在启动页,`v0.3.1` 打不上 3.14。 源码 zip 是当前公开入口。仓库里有第一份 unsigned 桌面候选(GUI `0.1.0-beta.1`);不要把它当成已发布安装包。 **macOS:** ```bash -curl -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.3/zcode-keysmith-v0.3.3.zip -curl -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.3/SHA256SUMS +curl -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.4/zcode-keysmith-v0.3.4.zip +curl -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.4/SHA256SUMS shasum -a 256 -c SHA256SUMS -unzip zcode-keysmith-v0.3.3.zip -cd zcode-keysmith-v0.3.3 +unzip zcode-keysmith-v0.3.4.zip +cd zcode-keysmith-v0.3.4 python3 zcode-keysmith.py install --dry-run python3 zcode-keysmith.py install --yes ``` @@ -107,11 +107,11 @@ python3 zcode-keysmith.py install --yes 先完全退出 ZCode,再运行: ```powershell -curl.exe -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.3/zcode-keysmith-v0.3.3.zip -curl.exe -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.3/SHA256SUMS -Get-FileHash .\zcode-keysmith-v0.3.3.zip -Algorithm SHA256 -Expand-Archive .\zcode-keysmith-v0.3.3.zip -DestinationPath . -cd zcode-keysmith-v0.3.3 +curl.exe -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.4/zcode-keysmith-v0.3.4.zip +curl.exe -LO https://github.com/Jia-Ethan/zcode-keysmith/releases/download/v0.3.4/SHA256SUMS +Get-FileHash .\zcode-keysmith-v0.3.4.zip -Algorithm SHA256 +Expand-Archive .\zcode-keysmith-v0.3.4.zip -DestinationPath . +cd zcode-keysmith-v0.3.4 py zcode-keysmith.py install --dry-run py zcode-keysmith.py install --yes ``` diff --git a/VERSION b/VERSION index 1c09c74..42045ac 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.3 +0.3.4 diff --git a/docs/agent-install.md b/docs/agent-install.md index 7157f49..812f56a 100644 --- a/docs/agent-install.md +++ b/docs/agent-install.md @@ -5,11 +5,11 @@ ## 简体中文 ```text -请从公开仓库 https://github.com/Jia-Ethan/zcode-keysmith 安装 zcode-keysmith。先检查 GitHub Release:当前稳定版是 v0.3.3(zcode-keysmith-v0.3.3.zip 与同级 SHA256SUMS),支持 ZCode 3.12 与 3.14。不要从浮动 master 安装。下载后先校验 SHA-256,再解压并确认 python3 zcode-keysmith.py --version(Windows 用 py)为 0.3.3,同时校验 examples/system-role.md 的 SHA-256 为 30e7de01b1a453d38cb1fa38bc8f4bb26eeaf8eccafada1aa178df1a1cf1c9e1。识别当前平台:Windows 使用 py,macOS 使用 python3。运行 --version、install --dry-run 和 doctor,报告目标 ~/.zcode-keysmith 目录、内置提示词来源与 SHA-256、将写入的 system-role.md / config.json / wrapper / env 脚本路径、macOS LaunchAgent 或 Windows HKCU\Environment 的 ZCODE_* 计划、ZCode runtime 与 node command 路径、injection_mode、auto_repatch_watch(macOS 3.12+ 应为 true)、auto_repatch_rearm(macOS 3.12+ 应为 true),以及真实的 app_bundle_modified(3.12+ runtime-patch 为 true)。默认只预览;等我明确确认后才添加 --yes。写入后运行 doctor 与 verify。提醒我完全退出并重新打开 ZCode,新建任务后首行应是 [P]。不要删除任何备份;3.12+ 允许按安装器备份并补丁 glm/zcode.cjs,卸载必须能还原。macOS 上 0.3.3 会在官方更新后自动重打同一套补丁,不要关掉 autoDownloadAndInstallUpdates 来留住补丁。不要改网络、运行中进程、API key、token、cookie、MCP 或 provider 配置。 +请从公开仓库 https://github.com/Jia-Ethan/zcode-keysmith 安装 zcode-keysmith。先检查 GitHub Release:当前稳定版是 v0.3.4(zcode-keysmith-v0.3.4.zip 与同级 SHA256SUMS),支持 ZCode 3.12、3.14 与 3.16.x。不要从浮动 master 安装。下载后先校验 SHA-256,再解压并确认 python3 zcode-keysmith.py --version(Windows 用 py)为 0.3.4,同时校验 examples/system-role.md 的 SHA-256 为 30e7de01b1a453d38cb1fa38bc8f4bb26eeaf8eccafada1aa178df1a1cf1c9e1。识别当前平台:Windows 使用 py,macOS 使用 python3。运行 --version、install --dry-run 和 doctor,报告目标 ~/.zcode-keysmith 目录、内置提示词来源与 SHA-256、将写入的 system-role.md / config.json / wrapper / env 脚本路径、macOS LaunchAgent 或 Windows HKCU\Environment 的 ZCODE_* 计划、ZCode runtime 与 node command 路径、injection_mode、auto_repatch_watch(macOS 3.12+ 应为 true)、auto_repatch_rearm(macOS 3.12+ 应为 true),以及真实的 app_bundle_modified(3.12+ runtime-patch 为 true)。默认只预览;等我明确确认后才添加 --yes。写入后运行 doctor 与 verify。提醒我完全退出并重新打开 ZCode,新建任务后首行应是 [P]。不要删除任何备份;3.12+ 允许按安装器备份并补丁 glm/zcode.cjs,卸载必须能还原。macOS 上 0.3.4 会在官方更新后自动重打同一套补丁,不要关掉 autoDownloadAndInstallUpdates 来留住补丁。不要改网络、运行中进程、API key、token、cookie、MCP 或 provider 配置。 ``` ## English ```text -Install zcode-keysmith from https://github.com/Jia-Ethan/zcode-keysmith. Check GitHub Releases first: the current stable release is v0.3.3 (zcode-keysmith-v0.3.3.zip and SHA256SUMS) and supports ZCode 3.12 and 3.14. Never install from floating master. Verify the zip checksum, unpack it, confirm python3 zcode-keysmith.py --version (py on Windows) is 0.3.3, and that examples/system-role.md SHA-256 is 30e7de01b1a453d38cb1fa38bc8f4bb26eeaf8eccafada1aa178df1a1cf1c9e1. Detect the platform; use py on Windows and python3 on macOS. Run --version, install --dry-run, and doctor. Report ~/.zcode-keysmith, the bundled prompt hash, planned system-role.md / config.json / wrapper / env-script paths, macOS LaunchAgent or Windows HKCU\Environment ZCODE_* plan, ZCode runtime and node-command paths, injection_mode, auto_repatch_watch (true for macOS 3.12+), auto_repatch_rearm (true for macOS 3.12+), and the real app_bundle_modified flag (true for 3.12+ runtime-patch). Preview only by default; wait for explicit confirmation before --yes. After writing, run doctor and verify. Tell me to quit and reopen ZCode; a fresh task should start with [P]. Do not delete backups. On 3.12+ the installer may back up and patch glm/zcode.cjs; uninstall must restore it. On macOS, 0.3.3 re-applies the same patch after an official update; do not turn off autoDownloadAndInstallUpdates just to keep the patch. Do not change network, running processes, API keys, tokens, cookies, MCP, or provider config. +Install zcode-keysmith from https://github.com/Jia-Ethan/zcode-keysmith. Check GitHub Releases first: the current stable release is v0.3.4 (zcode-keysmith-v0.3.4.zip and SHA256SUMS) and supports ZCode 3.12, 3.14, and 3.16.x. Never install from floating master. Verify the zip checksum, unpack it, confirm python3 zcode-keysmith.py --version (py on Windows) is 0.3.4, and that examples/system-role.md SHA-256 is 30e7de01b1a453d38cb1fa38bc8f4bb26eeaf8eccafada1aa178df1a1cf1c9e1. Detect the platform; use py on Windows and python3 on macOS. Run --version, install --dry-run, and doctor. Report ~/.zcode-keysmith, the bundled prompt hash, planned system-role.md / config.json / wrapper / env-script paths, macOS LaunchAgent or Windows HKCU\Environment ZCODE_* plan, ZCode runtime and node-command paths, injection_mode, auto_repatch_watch (true for macOS 3.12+), auto_repatch_rearm (true for macOS 3.12+), and the real app_bundle_modified flag (true for 3.12+ runtime-patch). Preview only by default; wait for explicit confirmation before --yes. After writing, run doctor and verify. Tell me to quit and reopen ZCode; a fresh task should start with [P]. Do not delete backups. On 3.12+ the installer may back up and patch glm/zcode.cjs; uninstall must restore it. On macOS, 0.3.4 re-applies the same patch after an official update; do not turn off autoDownloadAndInstallUpdates just to keep the patch. Do not change network, running processes, API keys, tokens, cookies, MCP, or provider config. ``` diff --git a/docs/reference.md b/docs/reference.md index d24045a..f96e0ed 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -14,7 +14,7 @@ ### 安装面 -- 目前可下载的是 GitHub Release `v0.3.3` 的 `zcode-keysmith-v0.3.3.zip` 与同级 `SHA256SUMS`,支持 ZCode 3.12 与 3.14。安装器把指令写到 `~/.zcode-keysmith/system-role.md`,进入 ZCode agent-server 的 system message 路径。ZCode 3.12+ 不劫持 agent-server command,改为备份并补丁 `glm/zcode.cjs`(`app_bundle_modified: true`,卸载还原);更早版本仍走 wrapper,不改原包。`v0.3.1` 无法识别 ZCode 3.14 的 runtime 锚点;`v0.3.0` 的 wrapper 路径对 3.12 不可用。 +- 目前可下载的是 GitHub Release `v0.3.4` 的 `zcode-keysmith-v0.3.4.zip` 与同级 `SHA256SUMS`,支持 ZCode 3.12、3.14 与 3.16.x。安装器把指令写到 `~/.zcode-keysmith/system-role.md`,进入 ZCode agent-server 的 system message 路径。ZCode 3.12+ 不劫持 agent-server command,改为备份并补丁 `glm/zcode.cjs`(`app_bundle_modified: true`,卸载还原);更早版本仍走 wrapper,不改原包。`v0.3.1` 无法识别 ZCode 3.14 的 runtime 锚点;`v0.3.0` 的 wrapper 路径对 3.12 不可用。 - 目前公开的稳定入口仍是源码压缩包:没有独立二进制、没有 `pip` / npm。仓库里有第一份 unsigned 桌面候选(GUI `0.1.0-beta.1`);`desktop-v0.1.0-beta.1` tag 尚未打,不要把它当成已发布安装包。 - 内置提示词来源为 [`examples/system-role.md`](../examples/system-role.md),SHA-256 `30e7de01b1a453d38cb1fa38bc8f4bb26eeaf8eccafada1aa178df1a1cf1c9e1`。 @@ -36,7 +36,7 @@ macOS 把 command 指向 `~/.zcode-keysmith/bin/zcode-agent-wrapper.py`。Window ZCode runtime 会把 `customSystemPrompt` 放进 `injectionTarget: "system"` 的上下文段,因此这份文件走的是 system message 路径,不是项目说明文件。若源文件来自 GLM ChatML 导出,外层 `<|im_start|>system:` / `<|im_end|>` 会在写入前被清理。 -当前源码版本 `0.3.3`,公开 zip 安装面是 `zcode-keysmith-v0.3.3.zip` + `SHA256SUMS`。没有独立 CLI 二进制、没有 `pip` / npm。桌面客户端源码在 `gui/`,本轮目标是 unsigned `desktop-v0.1.0-beta.1`,tag 尚未存在。目标平台是 macOS + 本机 `ZCode.app`,或 Windows 10/11 + 本机 `ZCode.exe`。macOS 通过 `launchctl` 激活;Windows 写入 `HKCU\Environment` 并广播环境变更,不需要管理员权限。Linux 没有文档化支持。 +当前源码版本 `0.3.4`,公开 zip 安装面是 `zcode-keysmith-v0.3.4.zip` + `SHA256SUMS`。没有独立 CLI 二进制、没有 `pip` / npm。桌面客户端源码在 `gui/`,本轮目标是 unsigned `desktop-v0.1.0-beta.1`,tag 尚未存在。目标平台是 macOS + 本机 `ZCode.app`,或 Windows 10/11 + 本机 `ZCode.exe`。macOS 通过 `launchctl` 激活;Windows 写入 `HKCU\Environment` 并广播环境变更,不需要管理员权限。Linux 没有文档化支持。 `install --dry-run` 仍会读取源提示词并检查本机 runtime 是否可打补丁。本机找不到可识别的 ZCode 安装时,预览会失败。可用 `--zcode-app` 或 `ZCODE_APP_PATH` 指定路径。 @@ -147,7 +147,7 @@ python3 scripts/build_release.py --output-dir dist ### Install surface -- The published GitHub Release is `v0.3.3` (`zcode-keysmith-v0.3.3.zip` and `SHA256SUMS`), which supports ZCode 3.12 and 3.14. The installer writes `~/.zcode-keysmith/system-role.md` into ZCode agent-server's system-message path. ZCode 3.12+ does not hijack the agent-server command; it backs up and patches `glm/zcode.cjs` (`app_bundle_modified: true`, restored on uninstall). Older builds still use the wrapper and leave the vendor runtime untouched. `v0.3.1` does not recognize the ZCode 3.14 runtime anchors; the `v0.3.0` wrapper path is incompatible with 3.12. +- The published GitHub Release is `v0.3.4` (`zcode-keysmith-v0.3.4.zip` and `SHA256SUMS`), which supports ZCode 3.12, 3.14, and 3.16.x. The installer writes `~/.zcode-keysmith/system-role.md` into ZCode agent-server's system-message path. ZCode 3.12+ does not hijack the agent-server command; it backs up and patches `glm/zcode.cjs` (`app_bundle_modified: true`, restored on uninstall). Older builds still use the wrapper and leave the vendor runtime untouched. `v0.3.1` does not recognize the ZCode 3.14 runtime anchors; the `v0.3.0` wrapper path is incompatible with 3.12. - The published entry is still a source zip: no standalone CLI binary, no pip/npm package. The tree also carries a first unsigned desktop candidate (GUI `0.1.0-beta.1`); the `desktop-v0.1.0-beta.1` tag does not exist yet. - Bundled prompt: [`examples/system-role.md`](../examples/system-role.md), SHA-256 `30e7de01b1a453d38cb1fa38bc8f4bb26eeaf8eccafada1aa178df1a1cf1c9e1`. @@ -169,7 +169,7 @@ On macOS the command is `~/.zcode-keysmith/bin/zcode-agent-wrapper.py`. On Windo The runtime places `customSystemPrompt` into a context segment with `injectionTarget: "system"`, so the file enters the system-message path rather than a project instruction file. GLM ChatML wrappers (`<|im_start|>system:` / `<|im_end|>`) are stripped before write. -The current source version is `0.3.3`. The published zip is `zcode-keysmith-v0.3.3.zip` plus `SHA256SUMS`. There is no standalone CLI binary or pip/npm package. Desktop source lives in `gui/`; this round targets unsigned `desktop-v0.1.0-beta.1`, but that tag is not cut yet. Documented platforms are macOS with a local `ZCode.app`, and Windows 10/11 with a local `ZCode.exe`. Windows activation uses current-user environment values under `HKCU\Environment` and requires no administrator access. Linux is not documented. +The current source version is `0.3.4`. The published zip is `zcode-keysmith-v0.3.4.zip` plus `SHA256SUMS`. There is no standalone CLI binary or pip/npm package. Desktop source lives in `gui/`; this round targets unsigned `desktop-v0.1.0-beta.1`, but that tag is not cut yet. Documented platforms are macOS with a local `ZCode.app`, and Windows 10/11 with a local `ZCode.exe`. Windows activation uses current-user environment values under `HKCU\Environment` and requires no administrator access. Linux is not documented. `install --dry-run` still reads the source prompt and checks that the local runtime is patchable. Preview fails if no recognizable ZCode installation is present. Pass `--zcode-app` or `ZCODE_APP_PATH` for a non-default location. diff --git a/docs/releases/v0.3.4.md b/docs/releases/v0.3.4.md new file mode 100644 index 0000000..9957a30 --- /dev/null +++ b/docs/releases/v0.3.4.md @@ -0,0 +1,7 @@ +项目里的 MEMORY.md 会盖过 Pier。这一版跳过那段 auto-memory 挂载,并去掉 agentsMd 里的 adhere 句。system-role 不再写死 M3 Air 和家目录路径。Persona、`[P]`、One Line 不变。 + +runtime-patch 下 `verify` 不再因为 leftover wrapper 的 `--help` smoke 失败(#32)。ShipIt 换包或 LaunchAgent 掉出会话后可用 `recover --yes` 重打补丁并 bootstrap 监视进程。3.12 与 3.14 都用这一版。 + +Windows ZCode 3.16.x 通过 `supportsStorageStartup` 走同一条 runtime-patch 路径;安装保留官方 agent-server,备份并修改 `resources/glm/zcode.cjs`,卸载时还原。 + +装完请完全退出并重新打开 ZCode,再开一轮新对话。本次不发布桌面安装包。 diff --git a/tests/test_zcode_keysmith.py b/tests/test_zcode_keysmith.py index 91381ad..af683c3 100644 --- a/tests/test_zcode_keysmith.py +++ b/tests/test_zcode_keysmith.py @@ -67,7 +67,7 @@ def test_cli_reports_release_version(): ) assert completed.returncode == 0 - assert completed.stdout.strip() == "zcode-keysmith.py 0.3.3" + assert completed.stdout.strip() == "zcode-keysmith.py 0.3.4" assert completed.stderr == "" assert mod.VERSION == (MODULE_PATH.parent / "VERSION").read_text(encoding="ascii").strip() @@ -936,6 +936,56 @@ def test_injection_mode_follows_storage_startup_marker(tmp_path): assert mod.injection_mode_for_app(win_app) == "runtime-patch" +def test_windows_storage_startup_install_patches_vendor_runtime_and_restores_it(tmp_path, monkeypatch): + monkeypatch.setattr(mod.platform, "system", lambda: "Windows") + monkeypatch.setattr(mod, "get_windows_user_env_entry", lambda key: None) + monkeypatch.setattr(mod, "set_windows_user_env_entry", lambda key, entry: None) + monkeypatch.setattr(mod, "windows_string_env_entry", lambda value: {"value": value, "registry_type": 1}) + monkeypatch.setattr(mod, "broadcast_windows_environment_change", lambda: None) + monkeypatch.setattr(mod, "is_zcode_running", lambda: False) + + app = tmp_path / "ZCode" + asar = app / "resources" / "app.asar" + asar.parent.mkdir(parents=True) + asar.write_bytes(b"ZCODE_AGENT_SERVER_COMMAND\nsupportsStorageStartup\n") + runtime = app / "resources" / "glm" / "zcode.cjs" + runtime.parent.mkdir(parents=True) + make_runtime(runtime, RUNTIME_V314) + original = runtime.read_text(encoding="utf-8") + node_command = app / "ZCode.exe" + node_command.write_bytes(b"MZ") + source = tmp_path / "source.md" + source.write_text("# Windows managed system\n", encoding="utf-8") + managed = tmp_path / "managed" + + code = mod.main([ + "install", + "--system-file", str(source), + "--managed-dir", str(managed), + "--zcode-app", str(app), + "--yes", + ]) + + assert code == 0 + config = json.loads((managed / "config.json").read_text(encoding="utf-8")) + assert config["injection_mode"] == "runtime-patch" + assert config["app_bundle_modified"] is True + assert "ZCODE_AGENT_SERVER_COMMAND" not in config["environment"] + backup = Path(config["runtime_original_backup"]) + assert backup.read_text(encoding="utf-8") == original + assert "ZCODE_KEYSMITH_SYSTEM_FILE" in runtime.read_text(encoding="utf-8") + + code = mod.main([ + "uninstall", + "--managed-dir", str(managed), + "--zcode-app", str(app), + "--yes", + ]) + + assert code == 0 + assert runtime.read_text(encoding="utf-8") == original + + def test_windows_activation_lines_are_preserved_in_json_report(tmp_path, capsys, monkeypatch): monkeypatch.setattr(mod.platform, "system", lambda: "Windows") monkeypatch.setattr(mod, "get_windows_user_env_entry", lambda key: None) diff --git a/zcode-keysmith.py b/zcode-keysmith.py index 214966f..bf7f760 100755 --- a/zcode-keysmith.py +++ b/zcode-keysmith.py @@ -42,7 +42,7 @@ if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS") else Path(__file__).resolve().parent ) -__version__ = "0.3.3" +__version__ = "0.3.4" VERSION = __version__ JSON_SCHEMA = "zcode-keysmith/v1" _LAST_USAGE_ERROR: list[str | None] = [None]