diff --git a/.github/workflows/agent-binaries.yml b/.github/workflows/agent-binaries.yml index e2dca273..ed52efbe 100644 --- a/.github/workflows/agent-binaries.yml +++ b/.github/workflows/agent-binaries.yml @@ -192,13 +192,17 @@ jobs: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} TAG: ${{ needs.plan.outputs.tag }} + VERSION: ${{ needs.plan.outputs.version }} steps: + - uses: actions/checkout@v7 + with: + ref: ${{ needs.plan.outputs.ref }} - uses: actions/download-artifact@v7 with: pattern: agent-* path: archives merge-multiple: true - - name: Create the release if it is not there, then upload + - name: Create the release if it is not there, attach the agent archives, build and attach the bundles run: | ls -l archives if ! gh release view "$TAG" >/dev/null 2>&1; then @@ -206,5 +210,56 @@ jobs: gh release create "$TAG" --title "$TAG" --notes "Agent binaries for $TAG." --verify-tag \ || gh release view "$TAG" >/dev/null fi - gh release upload "$TAG" archives/* --clobber + + # The agent archives go first: the VS Code extension and the ACP registry entry use them, + # and a bundle that fails below must not hold them back. + gh release upload "$TAG" archives/zycode-agent-* --clobber + + # A bundle is the zypi file of the release and the agent archive of the same platform. + # The build.py of a tag from before the bundles has no --bundle-from-archive. That tag + # gets no bundle, because this step is also the way to repair the release of an old tag. + help_text="$(python3 packaging/agent/build.py --help)" + case "$help_text" in + *--bundle-from-archive*) bundles=yes ;; + *) + bundles=no + echo "::notice::build.py of $TAG has no --bundle-from-archive, so this tag gets no bundles." + ;; + esac + + if [ "$bundles" = yes ]; then + mkdir -p tui-downloads + made=() + # Each of the three must work. A missing input or a failed download stops the step. + # Without a bundle, the download links in the README and on the web site give a 404, + # and the run would still be green. + for pair in "zypi-linux-x86_64:linux-x86_64" "zypi-linux-aarch64:linux-aarch64" "zypi-macos-arm64:darwin-aarch64"; do + asset="${pair%%:*}" + target="${pair##*:}" + tui_bin="tui-downloads/$asset" + agent_archive="archives/zycode-agent-$target-$VERSION.tar.gz" + bundle="archives/zycode-$target-$VERSION.tar.gz" + gh release download "$TAG" -p "$asset" -D tui-downloads + [ -f "$tui_bin" ] || { echo "::error::The release $TAG has no file $asset."; exit 1; } + [ -f "$agent_archive" ] || { echo "::error::There is no agent archive $agent_archive."; exit 1; } + chmod +x "$tui_bin" + python3 packaging/agent/build.py \ + --bundle-from-archive "$agent_archive" \ + --tui-binary "$tui_bin" \ + --target "$target" \ + --version "$VERSION" \ + --out archives + [ -f "$bundle" ] || { echo "::error::build.py did not make $bundle."; exit 1; } + made+=("$bundle") + done + gh release upload "$TAG" "${made[@]}" --clobber + + # The release must now hold all three bundles. + assets="$(gh release view "$TAG" --json assets --jq '.assets[].name')" + for target in linux-x86_64 linux-aarch64 darwin-aarch64; do + printf '%s\n' "$assets" | grep -Fxq "zycode-$target-$VERSION.tar.gz" \ + || { echo "::error::The release $TAG has no bundle for $target."; exit 1; } + done + fi + gh release view "$TAG" --json assets --jq '.assets[] | "\(.name) \(.size) \(.digest)"' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7ec8501..75553f82 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -112,6 +112,46 @@ jobs: name: tui-binary path: zypi-linux-x86_64 + build-tui-linux-arm: + name: Build TUI binary (Linux aarch64) + needs: test + runs-on: ubuntu-24.04-arm + steps: + - uses: actions/checkout@v7 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Cache Cargo registry and build + uses: actions/cache@v5 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + tui/target + key: tui-release-${{ runner.os }}-arm64-${{ hashFiles('tui/Cargo.lock') }} + restore-keys: tui-release-${{ runner.os }}-arm64- + + - name: Install protoc + uses: arduino/setup-protoc@v3 + with: + version: "28.x" + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build zypi (release-dist) + working-directory: tui + run: cargo build --profile release-dist -p pi-pager-bin + + - name: Prepare binary artifact + run: | + cp tui/target/release-dist/zypi zypi-linux-aarch64 + chmod +x zypi-linux-aarch64 + + - uses: actions/upload-artifact@v6 + with: + name: tui-binary-linux-aarch64 + path: zypi-linux-aarch64 + build-tui-macos-arm: name: Build TUI binary (macOS arm64) needs: test @@ -173,7 +213,7 @@ jobs: github-release: name: GitHub Release - needs: [build, build-tui, build-tui-macos-arm] + needs: [build, build-tui, build-tui-linux-arm, build-tui-macos-arm] # Same rule as publish-pypi. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest @@ -192,6 +232,11 @@ jobs: name: tui-binary path: tui-bin/ + - uses: actions/download-artifact@v7 + with: + name: tui-binary-linux-aarch64 + path: tui-bin/ + - uses: actions/download-artifact@v7 with: name: tui-binary-macos-arm64 diff --git a/CHANGELOG.md b/CHANGELOG.md index a84a37e8..a5dbe573 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,44 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.0.0] - 2026-11-16 + +This is 1.0.0, the first stable release of zycode. All seven Python packages and the TUI go to 1.0.0. + +One change can break a set-up that works today: `zypi` no longer starts `python -m pi_agent_cli` when you set nothing. It starts `zycode-agent`. **Changed** has the details and the one-line fix. **Added** has the standalone bundle (`zypi` and `zycode-agent` in one archive), `zypi --setup`, a `zypi` binary for Linux aarch64, and four changes in the agent: `usage_update`, the `max` thinking level, `auto_compact` and the stop reason `max_turn_requests`. **Known issues** says what nobody tried yet. + +### Added + +- **The agent tells an ACP client how full the context window is: `usage_update` (`pi-agent-cli`)**: a model in `agent.toml` (`[model]` or an entry of `[[models]]`) can have `context_window`, a whole number of tokens. A window belongs to one model, so it is never inherited. A value that cannot be used is dropped, and a note says so at the start of the session. When the model has a window, the agent sends `usage_update` (`used` and `size`) after a turn, after a compaction, after `session/load` and `session/resume` (only when the count is still true), and after a change of model. It never sends `cost`, because the agent has no price table. `used` is the count that the provider gave, plus an estimate for the tool results. After a compaction it is an estimate for the messages that remain. A model with no `context_window` gets no update: the 128,000 tokens of the core are a placeholder, not a window. Compaction now uses the declared window, with limits that fit small windows (before, it used the placeholder). The VS Code extension already reads the update and shows a Context row. `zypi` ignores it (see **Known issues**). Tests: `packages/pi-agent-cli/tests/test_context_usage.py`. Design: `docs/specs/2026-11-13-agent-context-usage.md` (#131). +- **The `max` thinking level (`pi-agent-core`, `pi-agent-cli`)**: `thinking_level = "max"` is a seventh level, above `xhigh`. DeepSeek V4, OpenAI GPT-5.6 and later, Anthropic adaptive models, Kimi K3 and GLM 5.x have it as their highest effort. The OpenAI format (gateways too) sends `reasoning_effort = "max"`, and `xhigh` still sends `"high"`. DeepSeek's own API gets `reasoning_effort = "max"`, as it does for `xhigh`. Anthropic gets the budget of `xhigh` (`budget_tokens = 40000`), because a budget has no step above it. `max` is open for every model. A model that does not take it answers with an error, and the agent lowers nothing. A test checks that each of the three tables names every level, because a level that a table lacks sends no parameter, and the model then silently does not think. Record: `docs/specs/2026-11-16-thinking-max-and-turn-limit.md` (#131). +- **`auto_compact` and the stop reason `max_turn_requests` (`pi-agent-core`, `pi-agent-cli`)**: `auto_compact = true | false` is a new optional key at the top of `agent.toml`. The key wins. When it is not set, compaction is on for a model that has a declared `context_window` and for `max_turns` of 30 or more, and off in the other cases (before, only `max_turns` of 30 or more turned it on). After a change of model, the rule decides again. `auto_compact = true` for a model with no window assumes 128,000 tokens. When the loop reaches `max_turns`, the stop reason is now `max_turn_requests` (before: `end_turn`). Any other error is still `end_turn`. The text of the error has one source: `MAX_TURNS_MESSAGE` in `pi_agent_core/types.py`. The VS Code extension shows "The turn ended: max_turn_requests." and `zypi` says "done" (#131). +- **The VS Code extension can offer `max` (`vscode/`)**: the Thinking menu lists `max`, but only for an agent of version 1.0.0 or later (`MAX_LEVEL_SINCE` in `src/core/thinking.ts`), because an older agent reads `max` as `off` and says nothing. The extension reads the version from the `initialize` answer of the agent. This release is not an extension release. The extension bundles the agent that `vscode/agent-assets.json` pins (0.9.1 today), so the menu changes only when an extension release moves the pin (#131). +- **Terminal setup command `zypi --setup`**: Added `--setup` flag to `zypi` to directly launch the agent's interactive setup dialog in the terminal to configure the provider, model, and API key before running interactive sessions. +- **Combined standalone bundles (`zycode--.tar.gz`)**: `packaging/agent/build.py` has a new option `--bundle-from-archive`, and the `Agent binaries` workflow uses it after the `Release` workflow. It packs `zypi` (the `zypi-*` file of the Release) and `zycode-agent` (the agent archive of the same platform) at the root of one archive (mode `0755`). A bundle exists for `linux-x86_64`, `linux-aarch64` and `darwin-aarch64`, and the step fails when it cannot make one of the three. The user needs no Python. +- **Linux aarch64 TUI binary in release workflow**: Added `build-tui-linux-arm` job to `.github/workflows/release.yml` on `ubuntu-24.04-arm` to build and publish `zypi-linux-aarch64`. +- **A design record for the Omarchy Linux Agent menu (docs)**: `docs/specs/2026-11-15-omarchy-agent-pr.md` has the patch that adds zycode (`zypi`) to the Agent menu of Omarchy Linux, with the mise declaration and the test notes. The patch is a draft: see **Known issues**. + +### Changed + +- **Behaviour change: `zypi` starts `zycode-agent`, and no longer falls back to `python -m pi_agent_cli` (TUI)**: `zypi` looks for `zycode-agent` (`zycode-agent.exe` on Windows) next to its own executable (a symlink is followed), and then on `PATH`. The order is: `PI_AGENT_COMMAND`, then `[agent].command` (in `agent.toml` or `config.toml`), then `PI_PYTHON` (only when it is set and not empty; it runs `python -m pi_agent_cli`), then `zycode-agent`. Before, `zypi` ran `python -m pi_agent_cli` when you set nothing. If you installed the agent with `pip install pi-agent-cli-lc` and you run a standalone `zypi`, set `PI_PYTHON` to the Python that has `pi-agent-cli-lc`, or set `PI_AGENT_COMMAND`, or use the bundle (see **Added**), which has both programs. +- **Version 1.0.0 for every package**: all seven Python packages (`pi-agent-core-lc`, `pi-agent-harness-lc`, `pi-agent-cli-lc`, `pi-web-access-py`, `pi-goal-x-py`, `pi-dynamic-workflows-py`, `pi-mcp-py`) and the TUI crates (`pi-pager-bin`, `pi-version`) go to `1.0.0`. The first three change their classifier from `Development Status :: 4 - Beta` to `Development Status :: 5 - Production/Stable`. The four extension packages never had a `Development Status` classifier, and they still have none. The README, the docs and the site name 1.0.0 as the current release. +- **A `thinking_level` that is not a level is still `off`, and a note says so (`pi-agent-cli`)**: it was `off` with no word, so a typo looked like `off`. The note comes at the start of the session (#131). +- **`agent.example.toml` has new example values (`pi-agent-cli`)**: `max_turns = 200` (it was 50) and `context_window = 1000000` (it was 128000). The default of `max_turns` in the code is still `None` (no limit) (#131). +- Refusal message for `zypi --oauth` updated to direct users to `zypi --setup`. +- Updated spawn error messages to guide placing `zycode-agent` next to `zypi` or setting `PI_AGENT_COMMAND` / `PI_PYTHON`. + +### Known issues + +The known issues of 0.9.0 still hold, except where an item below says otherwise. + +- **`zypi` ignores `usage_update` (TUI)**: the agent sends it now, but `zypi` has no code that reads it. The `context` item of `[ui.status_line]` (a known issue of 0.9.0) stays empty, and so does `cost`. `zypi` does not fail on the update only because `tui/Cargo.toml` turns on the feature `unstable` of `agent-client-protocol`, and the pager has a catch-all arm for the updates that it does not use. Do not remove that feature without a new check (#131). +- **The count in `usage_update` is partly an estimate (`pi-agent-cli`)**: the tool results of a turn, and the whole count after a compaction, are estimates (4 characters for 1 token, which is too low for CJK text). The next model call gives an exact number. A window that is too small can show more than 100 %. A change to a model with no window leaves the old numbers on the client, because ACP cannot clear them (#131). +- **`max` was not sent to a real provider (`pi-agent-core`)**: the tests use scripted models and a fake OpenAI-format server. Nobody sent `reasoning_effort = "max"` to a real gateway or to api.openai.com, and nobody tried the Anthropic path (`langchain_anthropic` is not in the dev environment). The documentation of Anthropic says that Claude 4.7 and later refuse the budget form that the agent sends. This is not verified. Adaptive thinking with `effort` is not built (#131). +- **A client may show `max_turn_requests` as a failure**: the VS Code extension shows a line of notice, and `zypi` says "done". Nobody checked another client (#131). +- **The `max` item of the VS Code menu was not tried in a real VS Code window with a real agent of 1.0.0 (`vscode/`)**: the tests use a fake agent that reports a version. A released extension has six levels. For a user who writes `max` in `agent.toml`, its menu shows `off`, and a note says that the agent does not know `max`. For the 1.0.0 agent that note is wrong. Nothing breaks (#131). +- **Nobody ran `zypi` for Linux aarch64 or macOS arm64 by hand**: CI builds them. The macOS binary is not signed and not notarized. The Linux `zypi` needs glibc 2.39 or newer. +- **The Omarchy patch is a draft with two defects that are not fixed**: `docs/specs/2026-11-15-omarchy-agent-pr.md` has a patch for the Agent menu of Omarchy Linux, and a draft PR in the Omarchy fork has the same patch. A review found two defects. The mise declaration resolves `latest` to the oldest release, and the agent id `zycode` is not the name of a command (the command is `zypi`). Do not send the patch to Omarchy before both are fixed. + ## [0.9.1] - 2026-11-12 This is a patch release. It has one fix: `provider = "openai"` now shows the thinking that a gateway streams as `reasoning_content`. **Fixed** has the details. The VS Code extension needs a new agent binary to get the fix, so it needs a new Release and a new VSIX. **Changed** has the new version numbers. **Known issues** says that the 0.9.0 list still holds. diff --git a/README.md b/README.md index c2d2de41..603736e6 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ This repository is a monorepo containing: - `pi-dynamic-workflows-py` / `pi_dynamic_workflows`: workflow orchestration extension. - `pi-mcp-py` / `pi_mcp`: optional extension that connects the MCP servers an ACP client (an editor) passes (see [`packages/pi-mcp`](packages/pi-mcp/README.md)). -**Rust TUI** (beta — prebuilt binary in [GitHub Releases](https://github.com/zy1233/pi-python/releases)): +**Rust TUI** (prebuilt binaries in [GitHub Releases](https://github.com/zy1233/pi-python/releases)): - `zypi`: full-screen terminal UI for interactive coding-agent sessions. Vendored fork of [grok-build](https://github.com/xai-org/grok-build) (Apache-2.0), with all `x.ai/*` vendor extensions removed. It offers three permission modes (Shift+Tab): Normal (`ask`, the start mode), Auto and Always-Approve. See [TUI & Code-Agent Guide](docs/TUI-AND-CODE-AGENT.md) for details. @@ -35,13 +35,13 @@ This repository is a monorepo containing: |-----------|--------|--------------| | `pi-agent-core-lc` | **Stable** | [PyPI](https://pypi.org/project/pi-agent-core-lc/) | | `pi-agent-harness-lc` | **Stable** | [PyPI](https://pypi.org/project/pi-agent-harness-lc/) | -| `pi-agent-cli-lc` | **Beta** | [PyPI](https://pypi.org/project/pi-agent-cli-lc/) | -| `pi-web-access-py` | **Beta** | [PyPI](https://pypi.org/project/pi-web-access-py/) | -| `pi-goal-x-py` | **Beta** | [PyPI](https://pypi.org/project/pi-goal-x-py/) | -| `pi-dynamic-workflows-py` | **Beta** | [PyPI](https://pypi.org/project/pi-dynamic-workflows-py/) | -| `pi-mcp-py` | **Alpha** | [PyPI](https://pypi.org/project/pi-mcp-py/) (from 0.6.0) | -| `zypi` (Rust TUI) | **Beta** | [GitHub Releases](https://github.com/zy1233/pi-python/releases) (Linux x86_64) | -| `zycode.zycode` (VS Code extension) | **Beta** | [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=zycode.zycode) and [Open VSX](https://open-vsx.org/extension/zycode/zycode) (five platforms; the project owner tested the install of 1.0.0 and the update from 0.1.0 to 1.0.0 on Windows on 2026-11-12; the rest of the Windows flow, macOS and Linux in a real VS Code are not verified) | +| `pi-agent-cli-lc` | **Stable** | [PyPI](https://pypi.org/project/pi-agent-cli-lc/) | +| `pi-web-access-py` | **Stable** | [PyPI](https://pypi.org/project/pi-web-access-py/) | +| `pi-goal-x-py` | **Stable** | [PyPI](https://pypi.org/project/pi-goal-x-py/) | +| `pi-dynamic-workflows-py` | **Stable** | [PyPI](https://pypi.org/project/pi-dynamic-workflows-py/) | +| `pi-mcp-py` | **Stable** | [PyPI](https://pypi.org/project/pi-mcp-py/) (from 0.6.0) | +| `zypi` (Rust TUI) | **Stable** | [GitHub Releases](https://github.com/zy1233/pi-python/releases) (Linux x86_64 and aarch64, macOS arm64) | +| `zycode.zycode` (VS Code extension) | **Stable** | [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=zycode.zycode) and [Open VSX](https://open-vsx.org/extension/zycode/zycode) (five platforms; the project owner tested the install of 1.0.0 and the update from 0.1.0 to 1.0.0 on Windows on 2026-11-12; the rest of the Windows flow, macOS and Linux in a real VS Code are not verified) | ## Features @@ -72,7 +72,7 @@ This repository is a monorepo containing: - LangChain `BaseTool` → `AgentTool` adapter (`from_langchain_tool`) — MCP tools via `langchain-mcp-adapters` work out of the box - The CLI itself has no MCP client. The optional `pi-mcp-py` extension connects the MCP servers that an ACP client passes in `session/new` (stdio, Streamable HTTP, SSE) and shows their tools as `mcp____`; without it, the agent says that their tools are not available in the session -**Coding Agent CLI** (Phase 4 — beta) +**Coding Agent CLI** (Phase 4) - `pi_agent_cli`: standard ACP coding agent over `AgentHarness` — no `x.ai/*` vendor extensions - Headless mode: `python -m pi_agent_cli -p "prompt"` for scripting and CI @@ -83,12 +83,12 @@ This repository is a monorepo containing: - Extensions that fail to load (import error, bad entry point, `activate()` raising, invalid tool name) are skipped, and the agent says so at session start (ACP agent message; headless stderr) instead of just not having them. `PI_HOME` moves the whole home: config, `extensions/`, saved workflows and workflow journals - Git workspace context (``) is a session-start snapshot in the system prompt (kept stable for the provider prompt cache; the block tells the model to run `git status` for live state); `--no-git-context` or `[git] enabled = false` turns it off. The snapshot is taken only for a trusted project (see project trust below): `git status` runs the program that a repository's own `.git/config` names in `core.fsmonitor`, so an untrusted project, which includes the default case of a project that ships no extensions or prompt files, gets no `` block (to get it back: `[extensions]` `trusted_projects = ["~/work"]` in `~/.pi-python/agent.toml`, or `default_project_trust = "always"`). The block (branch name and the paths of changed and untracked files) goes to the model provider with the rest of the system prompt, so turn it off if such names are sensitive -**TUI — `zypi`** (Phase 4 — beta) +**TUI — `zypi`** (Phase 4) - Full-screen Rust terminal UI for interactive coding-agent sessions -- Spawns the Python ACP agent (`python -m pi_agent_cli`) as the backend +- Spawns `zycode-agent` next to it or on `PATH` by default, or the Python ACP agent when configured (`PI_AGENT_COMMAND`, `[agent].command`, or `PI_PYTHON`) - Session management, markdown rendering, Mermaid diagrams, MCP support -- Prebuilt Linux x86_64 binary in [GitHub Releases](https://github.com/zy1233/pi-python/releases); build from source for other platforms +- Prebuilt binaries for Linux (x86_64, aarch64) and macOS (arm64) in [GitHub Releases](https://github.com/zy1233/pi-python/releases); standalone tarballs (`zycode--.tar.gz`) bundle `zypi` and `zycode-agent` together with zero Python dependencies required - See [TUI & Code-Agent Guide](docs/TUI-AND-CODE-AGENT.md) for setup and usage **FrontierHarness Evaluation** (30-task benchmark) @@ -131,20 +131,34 @@ pip install -e "./packages/pi-mcp" # optional: MCP servers that the editor pas -### TUI binary (`zypi`) — beta +### TUI binary (`zypi`) -Download the prebuilt binary for Linux x86_64 or macOS arm64 from [GitHub Releases](https://github.com/zy1233/pi-python/releases): +Download the complete standalone archive (it has `zypi` and `zycode-agent`) or the prebuilt `zypi` binary for Linux (x86_64 or aarch64) or macOS arm64 from [GitHub Releases](https://github.com/zy1233/pi-python/releases): ```bash -# Download and install (Linux x86_64) +# Option 1: Standalone bundle (contains both zypi and zycode-agent; no Python required) +# Linux x86_64 shown. The other files are zycode-linux-aarch64-1.0.0.tar.gz and zycode-darwin-aarch64-1.0.0.tar.gz. +curl -L -o zycode.tar.gz https://github.com/zy1233/pi-python/releases/download/v1.0.0/zycode-linux-x86_64-1.0.0.tar.gz +tar -xzf zycode.tar.gz +sudo mv zypi zycode-agent /usr/local/bin/ + +# Option 2: zypi alone. It has no agent: it starts zycode-agent (next to it, or on PATH), +# or the agent that PI_AGENT_COMMAND or PI_PYTHON names. curl -L -o zypi https://github.com/zy1233/pi-python/releases/latest/download/zypi-linux-x86_64 chmod +x zypi sudo mv zypi /usr/local/bin/ +# The pip package pi-agent-cli-lc has no zycode-agent command. With it, set PI_PYTHON +# (zypi starts `python -m pi_agent_cli` only when PI_PYTHON is set): +export PI_PYTHON=python3 -# macOS arm64 (Apple silicon): the same steps with the file zypi-macos-arm64 -# (built in CI, not yet run by a person; see the TUI guide) +# Set up model and API key directly in terminal: +zypi --setup +``` + +The bundle file name holds the version, so the URL names the tag (`v1.0.0`), not `latest`. -# Or build from source (requires Rust toolchain) +Or build from source (requires Rust toolchain): +```bash cd tui && cargo build --profile release-dist -p pi-pager-bin # binary at target/release-dist/zypi ``` @@ -571,7 +585,7 @@ Use `.venv-test-real` for pytest real-LLM tests; the smoke script can run from t - **Phase 2.5 (core hardening)** — done: retries, runaway protection, observability, granular events, guardrail hooks, `ContextBudget`, structured output, tool-result images - **Phase 3 (AgentHarness)** — done: H1 session tree, H2 runtime, H3 compaction/tree navigation, H4 skills/templates/system prompt/LocalExecutionEnv ([design doc](docs/specs/2026-07-03-phase3-agent-harness-design.md)) - **Phase 3.5 (tool ecosystem)** — done: all 7 built-in tools (read/bash/edit/write/grep/find/ls), group factories, and the LangChain `BaseTool` adapter ([design doc](docs/specs/2026-07-03-phase3.5-tool-ecosystem-design.md)) -- **Phase 4 (Coding Agent CLI — beta)** — done: `tui/` vendored grok-build fork (Apache-2.0); `pi_agent_cli` standard ACP agent; TUI binary `zypi`; `x.ai/*` vendor RPCs removed; session management (`/new` `/resume` `/quit`); headless `-p`; `config.toml` + Windows notes ([design doc](docs/specs/2026-08-25-phase4-coding-agent-cli-design.md), [Windows](docs/WINDOWS.md), [TUI guide](docs/TUI-AND-CODE-AGENT.md)) +- **Phase 4 (Coding Agent CLI)** — done: `tui/` vendored grok-build fork (Apache-2.0); `pi_agent_cli` standard ACP agent; TUI binary `zypi`; `x.ai/*` vendor RPCs removed; session management (`/new` `/resume` `/quit`); headless `-p`; `config.toml` + Windows notes ([design doc](docs/specs/2026-08-25-phase4-coding-agent-cli-design.md), [Windows](docs/WINDOWS.md), [TUI guide](docs/TUI-AND-CODE-AGENT.md)) - **Phase 5 (Coding Agent prompt engine)** — done: pi-aligned `build_system_prompt` + tool contributions + context files + `` ([design doc](docs/specs/2026-09-02-phase5-prompt-engine-design.md)) - **Phase 6 (extended integrations)** — done: git workspace context in the system prompt; opt-in multi-provider live matrix. MCP stays a caller-side `BaseTool` import ([design doc](docs/specs/2026-09-24-phase6-extended-integrations-design.md)); the optional `pi-mcp-py` extension (2026-10) connects the servers an editor passes, and the core, harness and CLI still hold no MCP client ([design doc](docs/specs/2026-10-23-mcp-extension-design.md)) - **Phase 7 (extension packages)** — done: `pi-web-access-py`, `pi-goal-x-py`, `pi-dynamic-workflows-py` ([design doc](docs/specs/2026-09-22-phase7-extension-api-design.md)) diff --git a/docs/DESIGN.md b/docs/DESIGN.md index ff760d1c..770c0b44 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -303,7 +303,7 @@ pi (Rust TUI) --stdio 标准 ACP--> python -m pi_agent_cli --> AgentHarness ### 8.3 TUI 改造要点 -spawn 默认为 `python -m pi_agent_cli`(`PI_AGENT_COMMAND` / `PI_PYTHON` 可覆盖)。`acp_send` 丢弃 `x.ai/*` 扩展 RPC;空 `auth_methods` 跳过 xAI 登录;auto-update 关闭;交互路径不装 otel。家目录 `PI_HOME` / `~/.pi-python`。斜杠菜单只有 `/new` `/resume` `/model` `/exit`(别名 `/quit`)与本地命令(`/help` `/theme` `/settings` `/multiline` `/home`);`/resume` 走标准 `session/list` + `session/load`,`/model` 走 ACP Session Config Options(`session/set_config_option`)。`pi -p` 转发到 `python -m pi_agent_cli -p`,不复用 grok headless。 +spawn 默认为 `zycode-agent`(先找 `zypi` 旁边,再找 `PATH`;`PI_AGENT_COMMAND`、`[agent].command` 与 `PI_PYTHON` 可覆盖。只有设了 `PI_PYTHON`,才会运行 `python -m pi_agent_cli`;没有 Python 回退)。`acp_send` 丢弃 `x.ai/*` 扩展 RPC;空 `auth_methods` 跳过 xAI 登录;auto-update 关闭;交互路径不装 otel。家目录 `PI_HOME` / `~/.pi-python`。斜杠菜单只有 `/new` `/resume` `/model` `/exit`(别名 `/quit`)与本地命令(`/help` `/theme` `/settings` `/multiline` `/home`);`/resume` 走标准 `session/list` + `session/load`,`/model` 走 ACP Session Config Options(`session/set_config_option`)。`pi -p` 转发到同一个 agent 命令的 `-p`,不复用 grok headless。 ### 8.4 权限与配置 diff --git a/docs/TUI-AND-CODE-AGENT.md b/docs/TUI-AND-CODE-AGENT.md index b3351535..8c617aa8 100644 --- a/docs/TUI-AND-CODE-AGENT.md +++ b/docs/TUI-AND-CODE-AGENT.md @@ -1,6 +1,6 @@ # TUI & Code-Agent Guide -> **Status: Beta** — The TUI (`zypi`) and coding agent (`pi_agent_cli`) are functional but under active development. APIs, configuration, and binary distribution may change between releases. +> **Status: Stable (1.0.0)** — The TUI (`zypi`) and coding agent (`pi_agent_cli` / `zycode-agent`) are production ready. This document covers how to install, configure, and use the pi-python coding agent — both the headless Python CLI and the full-screen Rust TUI. @@ -17,7 +17,7 @@ This document covers how to install, configure, and use the pi-python coding age │ ACP (Agent Client Protocol) over stdio ▼ ┌─────────────────────────────────────┐ -│ pi_agent_cli (Python ACP) │ Standard ACP agent +│ zycode-agent / pi_agent_cli (ACP) │ Standard ACP agent │ System prompt engine, tool │ MIT license │ contributions, context files │ └────────────┬────────────────────────┘ @@ -37,7 +37,7 @@ This document covers how to install, configure, and use the pi-python coding age └─────────────────────────────────────┘ ``` -The TUI (`zypi`) is the interactive frontend. It communicates with the Python coding agent (`pi_agent_cli`) over the [Agent Client Protocol (ACP)](https://agentclientprotocol.com) via stdio. The Python agent handles all LLM calls, tool execution, and session management through the core engine. `zypi` has no model client, no tool runner and no MCP client. A process-level audit of a real turn (`docs/PLAN/archive/PLAN-RUST-AGENT-RUNTIME-REMOVAL-EXECUTION-LOG.md`, section 10.14) found no connection from `zypi` to any address outside the machine. +The TUI (`zypi`) is the interactive frontend. It communicates with the ACP coding agent (`zycode-agent` binary or `pi_agent_cli` Python module) over the [Agent Client Protocol (ACP)](https://agentclientprotocol.com) via stdio. The agent handles all LLM calls, tool execution, and session management through the core engine. `zypi` has no model client, no tool runner and no MCP client. A process-level audit of a real turn (`docs/PLAN/archive/PLAN-RUST-AGENT-RUNTIME-REMOVAL-EXECUTION-LOG.md`, section 10.14) found no connection from `zypi` to any address outside the machine. You can use the coding agent in two ways: @@ -48,7 +48,23 @@ You can use the coding agent in two ways: ## Installation -### 1. Python packages (required) +### 1. Standalone bundle (recommended — no Python required) + +Download the complete bundle `zycode--.tar.gz` from [GitHub Releases](https://github.com/zy1233/pi-python/releases). The file name holds the version, so use the URL of that release (`releases/download/v/...`). Do not use `releases/latest/download/...`: after the next release, "latest" points to a release that has no file of that name. + +```bash +# Linux x86_64 +curl -L -o zycode.tar.gz https://github.com/zy1233/pi-python/releases/download/v1.0.0/zycode-linux-x86_64-1.0.0.tar.gz +tar -xzf zycode.tar.gz +sudo mv zypi zycode-agent /usr/local/bin/ + +# Initial setup in terminal +zypi --setup +``` + +The targets are `linux-x86_64`, `linux-aarch64` and `darwin-aarch64` (macOS with Apple silicon). The bundle holds two files: `zypi` and `zycode-agent`. `zypi` starts the agent that is next to it. The `Release` workflow builds `zypi`, and then the `Agent binaries` workflow packs the bundles. The bundles appear on the release page when the `Agent binaries` workflow has finished, which is after the release itself. + +### 2. Python packages (optional / dev) ```bash # Using pip @@ -58,11 +74,19 @@ pip install pi-agent-cli-lc pip install -e ".[dev]" -e "./packages/pi-agent-harness" -e "./packages/pi-agent-cli" ``` -### 2. TUI binary (`zypi`) +### 3. TUI binary (`zypi`) alone -#### Option A: Download prebuilt binary (Linux x86_64, macOS arm64) +`zypi` alone has no agent. It looks for `zycode-agent` next to its own file (a symlink is followed), and then on `PATH`. The Python package (`pip install pi-agent-cli-lc`) has no `zycode-agent` command. If you use the Python package, tell `zypi` which Python has it: -Prebuilt binaries are attached to [GitHub Releases](https://github.com/zy1233/pi-python/releases). The Linux x86_64 binary has been there since v0.3.0. The macOS arm64 binary (Apple silicon) starts with v0.5.0. +```bash +export PI_PYTHON=python3 # a Python that has pi-agent-cli-lc installed +``` + +`zypi` starts `python -m pi_agent_cli` only when `PI_PYTHON` is set and not empty. Before 1.0.0, it did this when you set nothing. You can also set `PI_AGENT_COMMAND`, or `[agent].command` (see [Configuration](#configuration)). + +#### Option A: Download prebuilt binary (Linux x86_64, Linux aarch64, macOS arm64) + +Prebuilt binaries are attached to [GitHub Releases](https://github.com/zy1233/pi-python/releases). ```bash # Linux x86_64 @@ -70,6 +94,11 @@ curl -L -o zypi https://github.com/zy1233/pi-python/releases/latest/download/zyp chmod +x zypi sudo mv zypi /usr/local/bin/ +# Linux aarch64 +curl -L -o zypi https://github.com/zy1233/pi-python/releases/latest/download/zypi-linux-aarch64 +chmod +x zypi +sudo mv zypi /usr/local/bin/ + # macOS arm64 curl -L -o zypi https://github.com/zy1233/pi-python/releases/latest/download/zypi-macos-arm64 chmod +x zypi @@ -124,8 +153,10 @@ context_window = 128000 # tokens; the agent then tell paths = ["~/.pi-python/skills", ".pi/skills"] [agent] -# Override how the TUI spawns the Python agent (optional) -command = "python -m pi_agent_cli" +# Override how the TUI spawns the ACP agent (optional). +# By default, zypi searches for `zycode-agent` next to itself (or following symlinks) +# or on PATH. Set this or PI_AGENT_COMMAND or PI_PYTHON to override. +command = "zycode-agent" [extensions] # Projects that may use their own /.pi-python/extensions (arbitrary Python), diff --git a/docs/WINDOWS.md b/docs/WINDOWS.md index a46628a4..adf7b9ff 100644 --- a/docs/WINDOWS.md +++ b/docs/WINDOWS.md @@ -59,8 +59,8 @@ Priority: 1. `PI_AGENT_COMMAND` — full command string, e.g. `D:\work\pi-python\.venv\Scripts\python.exe -m pi_agent_cli` 2. `[agent].command` in `agent.toml` -3. `PI_PYTHON` + default args `-m pi_agent_cli` -4. `python` on Windows / `python3` elsewhere +3. `PI_PYTHON` (only when it is set and not empty) + default args `-m pi_agent_cli` +4. `zycode-agent` (`zycode-agent.exe` on Windows): next to the `zypi` file, then on `PATH`. There is no fall-back to `python`. On Windows, **prefer pointing at your venv** — the Store `python` stub is unreliable. diff --git a/docs/specs/2026-11-15-omarchy-agent-pr.md b/docs/specs/2026-11-15-omarchy-agent-pr.md new file mode 100644 index 00000000..cd469085 --- /dev/null +++ b/docs/specs/2026-11-15-omarchy-agent-pr.md @@ -0,0 +1,323 @@ +# Omarchy Linux: Add zycode (`zypi`) Coding Agent to Agent Menu + +> Date: 2026-11-15 +> Status: **Draft. Do not submit yet.** Two defects are known and not fixed. (1) The mise declaration in section 3 makes `latest` resolve to the oldest release: the GitHub list of releases starts with the newest one, and mise takes the last item. (2) The agent id `zycode` is not the name of a command: the command is `zypi`. A review found both in the draft PR `zy1233/omarchy#1`. +> Upstream target: `omacom/omarchy` (`quattro` branch) +> Component: Omarchy desktop coding agent menu & launcher + +--- + +## 1. Background & Rationale + +Omarchy Linux provides a curated set of coding agents selectable via the Super+A / Super+Space desktop Agent menu (`omarchy-default-agent`) and launchable via the unified terminal wrapper `omarchy-agent`. Supported agents range from cloud harness CLIs to open-source terminal agents (such as Pi, Qwen Code, Kiro, Devin, Amp, Command Code, etc.). + +`zycode` is an open-source, full-featured agentic coding environment: +- **TUI binary (`zypi`)**: High-performance Rust terminal user interface built on an ACP client architecture with rich split-pane diff review, streaming markdown, syntax-highlighted tool inspections, and three permission modes (`ask`, `auto`, `always-approve`). +- **Core runtime (`zycode-agent`)**: Standalone binary executing the agent loop, coding tools (`read`, `bash`, `edit`, `write`, `grep`, `find`, `ls`), sandboxed workflows, and MCP server integrations. +- **Self-contained distribution**: Starting with `v1.0.0` (Production/Stable), standalone combined tarballs `zycode-linux-x86_64-1.0.0.tar.gz` and `zycode-linux-aarch64-1.0.0.tar.gz` are published on GitHub Releases. Each archive extracts both `zypi` and `zycode-agent` to the installation prefix root. +- **Zero-runtime dependency**: When installed via mise's `http:` backend, `zypi` automatically discovers the sibling `zycode-agent` binary directly beside it, requiring no global Python runtime or system pip dependencies. +- **First-run setup**: `zypi --setup` provides an interactive terminal configuration wizard to choose a model provider and configure API keys. + +Adding `zycode` to Omarchy gives users immediate, native access to zycode from Omarchy's Agent menu with automatic mise package installation, headless bypass (`--always-approve`), and shared AGENTS instructions. + +--- + +## 2. Upstream PR Proposal + +### PR Title +`feat(agent): add zycode (zypi) coding agent to Agent menu` + +### PR Description +```markdown +### Overview +Adds `zycode` (`zypi`) to Omarchy's default coding agent menu and launcher. + +`zycode` is a fast terminal coding agent featuring an ACP-driven Rust TUI (`zypi`) and standalone agent runtime (`zycode-agent`). Starting with `v1.0.0`, zycode publishes self-contained binary release archives containing both binaries for Linux x86_64 and aarch64. + +### Changes +- **`etc/mise/conf.d/omarchy-tools.toml`**: Declares `http:zycode` with `lazy = true`, `auto_update = "4h"`, `lazy_bins = ["zypi"]`, GitHub release URLs for x86_64 and aarch64 (`zycode-linux--{{version}}.tar.gz`), and version resolution via GitHub Releases API (`.[].tag_name`). +- **`bin/omarchy-default-agent`**: Registers `zycode` / `zypi` with the `http:zycode` declaration; updates usage text and arg metadata. +- **`bin/omarchy-agent`**: Adds launcher entry running `zypi --always-approve [-- "$prompt"]`. +- **`bin/omarchy-agent-instructions`**: Links agent instructions to `${PI_HOME:-$HOME/.pi-python}/agent/AGENTS.md`. +- **`default/omarchy/omarchy-menu.jsonc`**: Adds `agent.harness.zycode` entry with agent icon `󰚩`. +- **`default/i18n/en/menu.json`**: Adds English i18n label for `agent.harness.zycode`. +- **`test/shell.d/default-agent-test.sh`**: Updates expected tool declarations, lazy counts (31 -> 32), self-updating CLI counts (21 -> 22), install expectations, prompt launch, and permission bypass assertions. + +### Verification +- `bash test/shell.d/default-agent-test.sh`: 47 tests passed (0 failures). +- `bash test/shell.d/i18n-test.sh`: 123 tests passed (0 failures). +``` + +--- + +## 3. Mise Backend Configuration (`http:zycode`) + +Mise manages standalone binary packages via HTTP tarballs. The archive layout for `zycode` is flat: +```text +zycode-linux-x86_64-1.0.0.tar.gz +├── zypi (0755) +└── zycode-agent (0755) +``` + +In `etc/mise/conf.d/omarchy-tools.toml`: +```toml +"http:zycode" = { version = "latest", lazy = true, auto_update = "4h", lazy_bins = ["zypi"], minimum_release_age = "0s", platforms_linux_x64_url = "https://github.com/zy1233/pi-python/releases/download/v{{version}}/zycode-linux-x86_64-{{version}}.tar.gz", platforms_linux_arm64_url = "https://github.com/zy1233/pi-python/releases/download/v{{version}}/zycode-linux-aarch64-{{version}}.tar.gz", version_list_url = "https://api.github.com/repos/zy1233/pi-python/releases", version_json_path = ".[].tag_name" } +``` + +Key configuration points: +- `lazy = true`: Generates a lazy shim wrapper under `~/.local/share/omarchy/bin/zypi` so invoking `zypi` or launching from the menu triggers installation on first run. +- `lazy_bins = ["zypi"]`: Only `zypi` is exposed on `PATH`. `zycode-agent` remains adjacent in the mise install directory and is invoked as a child process by `zypi` via sibling binary resolution. +- `auto_update = "4h"`: Updates check every 4 hours alongside other self-updating agent CLIs. +- `version_list_url` and `version_json_path`: Queries `https://api.github.com/repos/zy1233/pi-python/releases` extracting `.tag_name`. Mise automatically strips `v` prefixes to match semver versions. + +--- + +## 4. Full Git Diff Patch against `omacom/omarchy` (`quattro`) + +```patch +diff --git a/bin/omarchy-agent b/bin/omarchy-agent +index a249529..85cfa8e 100755 +--- a/bin/omarchy-agent ++++ b/bin/omarchy-agent +@@ -277,6 +277,10 @@ commandcode) + command=(commandcode --yolo) + [[ -n ${prompt:-} ]] && command+=(-- "$prompt") + ;; ++zycode) ++ command=(zypi --always-approve) ++ [[ -n ${prompt:-} ]] && command+=(-- "$prompt") ++ ;; + *) + echo "Unsupported default agent: $agent" >&2 + exit 1 +diff --git a/bin/omarchy-agent-instructions b/bin/omarchy-agent-instructions +index 21f769d..1935306 100755 +--- a/bin/omarchy-agent-instructions ++++ b/bin/omarchy-agent-instructions +@@ -51,6 +51,7 @@ declare -A links=( + [kilo]="$config/kilo/AGENTS.md" + [commandcode]="$HOME/.commandcode/AGENTS.md" + [freebuff]="$HOME/.AGENTS.md" ++ [zycode]="${PI_HOME:-$HOME/.pi-python}/agent/AGENTS.md" + ) + + backups=() +diff --git a/bin/omarchy-default-agent b/bin/omarchy-default-agent +index cee3810..ffadd59 100755 +--- a/bin/omarchy-default-agent ++++ b/bin/omarchy-default-agent +@@ -1,7 +1,7 @@ + #!/bin/bash + + # omarchy:summary=Set and launch the default coding agent +-# omarchy:args=[pi|omp|opencode|ori|claude|codex|grok|openclaw|agy|hermes|copilot|crush|cursor-agent|muse|kimi|qwen|dsh|mcode|kiro-cli|freebuff|kilo|devin|amp|commandcode] ++# omarchy:args=[pi|omp|opencode|ori|claude|codex|grok|openclaw|agy|hermes|copilot|crush|cursor-agent|muse|kimi|qwen|dsh|mcode|kiro-cli|freebuff|kilo|devin|amp|commandcode|zycode] + # omarchy:examples=omarchy default agent | omarchy default agent codex | omarchy default agent claude + + installing=false +@@ -64,8 +64,14 @@ devin | devin-cli) + ;; + amp | ampcode) agent="amp"; name="Amp" ;; + commandcode | command-code | cmdc) agent="commandcode"; name="Command Code"; agent_package="npm:command-code" ;; ++zycode | zypi) ++ agent="zycode"; name="zycode" ++ # zycode publishes per-platform archives containing zypi and zycode-agent. ++ agent_tool="http:zycode" ++ agent_package="$agent_tool[platforms_linux_x64_url=https://github.com/zy1233/pi-python/releases/download/v{{version}}/zycode-linux-x86_64-{{version}}.tar.gz,platforms_linux_arm64_url=https://github.com/zy1233/pi-python/releases/download/v{{version}}/zycode-linux-aarch64-{{version}}.tar.gz,version_list_url=https://api.github.com/repos/zy1233/pi-python/releases,version_json_path=.[].tag_name]" ++ ;; + *) +- echo "Usage: omarchy-default-agent " ++ echo "Usage: omarchy-default-agent " + exit 1 + ;; + esac +diff --git a/default/i18n/en/menu.json b/default/i18n/en/menu.json +index 1221efa..522b296 100644 +--- a/default/i18n/en/menu.json ++++ b/default/i18n/en/menu.json +@@ -575,6 +575,9 @@ + "agent.harness.qwen": { + "label": "Qwen Code" + }, ++ "agent.harness.zycode": { ++ "label": "zycode" ++ }, + "setup.default.browser": { + "label": "Browser", + "title": "Default Browser" +diff --git a/default/omarchy/omarchy-menu.jsonc b/default/omarchy/omarchy-menu.jsonc +index cbf2662..49a4be0 100644 +--- a/default/omarchy/omarchy-menu.jsonc ++++ b/default/omarchy/omarchy-menu.jsonc +@@ -63,6 +63,7 @@ + "agent.harness.ori": {"icon":"","iconFont":"omarchy","label":"Ori","checked":"[[ \"$(omarchy-default-agent)\" == \"ori\" ]]","action":"omarchy-default-agent ori"}, + "agent.harness.pi": {"icon":"","iconFont":"omarchy","label":"Pi","checked":"[[ \"$(omarchy-default-agent)\" == \"pi\" ]]","action":"omarchy-default-agent pi"}, + "agent.harness.qwen": {"icon":"","iconFont":"omarchy","label":"Qwen Code","checked":"[[ \"$(omarchy-default-agent)\" == \"qwen\" ]]","action":"omarchy-default-agent qwen"}, ++ "agent.harness.zycode": {"icon":"󰚩","label":"zycode","checked":"[[ \"$(omarchy-default-agent)\" == \"zycode\" ]]","action":"omarchy-default-agent zycode"}, + "agent.instructions": {"icon":"󰈙","label":"Instructions","action":"omarchy-agent-instructions --edit"}, + + // System +diff --git a/etc/mise/conf.d/omarchy-tools.toml b/etc/mise/conf.d/omarchy-tools.toml +index b784d71..06ebd5b 100644 +--- a/etc/mise/conf.d/omarchy-tools.toml ++++ b/etc/mise/conf.d/omarchy-tools.toml +@@ -23,6 +23,7 @@ grok = { version = "latest", lazy = true, auto_update = "4h", minimum_release_ag + hey-cli = { version = "latest", lazy = true, minimum_release_age = "0s" } + "http:devin" = { version = "latest", lazy = true, auto_update = "4h", lazy_bins = ["devin"], minimum_release_age = "0s", platforms_linux_x64_url = "https://static.devin.ai/cli/{{ version }}/devin-{{ version }}-x86_64-unknown-linux.tar.gz", platforms_linux_arm64_url = "https://static.devin.ai/cli/{{ version }}/devin-{{ version }}-aarch64-unknown-linux.tar.gz", bin_path = "bin", version_list_url = "https://static.devin.ai/cli/current/manifest.json", version_json_path = ".version" } + "http:kiro-cli" = { version = "latest", lazy = true, auto_update = "4h", lazy_bins = ["kiro-cli"], minimum_release_age = "0s", platforms_linux_x64_url = "https://prod.download.cli.kiro.dev/stable/{{version}}/kirocli-x86_64-linux.tar.gz", platforms_linux_arm64_url = "https://prod.download.cli.kiro.dev/stable/{{version}}/kirocli-aarch64-linux.tar.gz", version_list_url = "https://prod.download.cli.kiro.dev/stable/latest/manifest.json", version_json_path = ".version" } ++"http:zycode" = { version = "latest", lazy = true, auto_update = "4h", lazy_bins = ["zypi"], minimum_release_age = "0s", platforms_linux_x64_url = "https://github.com/zy1233/pi-python/releases/download/v{{version}}/zycode-linux-x86_64-{{version}}.tar.gz", platforms_linux_arm64_url = "https://github.com/zy1233/pi-python/releases/download/v{{version}}/zycode-linux-aarch64-{{version}}.tar.gz", version_list_url = "https://api.github.com/repos/zy1233/pi-python/releases", version_json_path = ".[].tag_name" } + hunk = { version = "latest", lazy = true, minimum_release_age = "0s" } + muse = { version = "latest", lazy = true, auto_update = "4h", minimum_release_age = "0s" } + node = { version = "latest", lazy = true, minimum_release_age = "0s" } +diff --git a/test/shell.d/default-agent-test.sh b/test/shell.d/default-agent-test.sh +index 57b877f..c94efc3 100644 +--- a/test/shell.d/default-agent-test.sh ++++ b/test/shell.d/default-agent-test.sh +@@ -168,6 +168,8 @@ amp_package="amp" + commandcode_package="npm:command-code" + cursor_agent_package="cursor-agent" + muse_package="muse" ++zycode_tool="http:zycode" ++zycode_package="$zycode_tool[platforms_linux_x64_url=https://github.com/zy1233/pi-python/releases/download/v{{version}}/zycode-linux-x86_64-{{version}}.tar.gz,platforms_linux_arm64_url=https://github.com/zy1233/pi-python/releases/download/v{{version}}/zycode-linux-aarch64-{{version}}.tar.gz,version_list_url=https://api.github.com/repos/zy1233/pi-python/releases,version_json_path=.[].tag_name]" + + assert_lazy_stub() { + local package=$1 +@@ -229,6 +231,7 @@ declare -A declared_option_bins=( + [mcode]='"mcode"' + [kiro_cli]='"kiro-cli"' + [devin]='"devin"' ++ [zycode]='"zypi"' + ) + for agent in "${!declared_option_bins[@]}"; do + tool_var="${agent}_tool" +@@ -242,12 +245,12 @@ for agent in "${!declared_option_bins[@]}"; do + fail "user setup declares ${!tool_var} with ${option%%=*} inside its table" + done + done +-[[ $(grep -c 'auto_update = "4h"' "$lazy_config") == 21 ]] || fail "only the agent CLIs update themselves" ++[[ $(grep -c 'auto_update = "4h"' "$lazy_config") == 22 ]] || fail "only the agent CLIs update themselves" + for tool in node uv; do + grep -Eq "^$tool = \\{ version = \"latest\", lazy = true, minimum_release_age = \"0s\" \\}$" "$lazy_config" || + fail "user setup declares $tool as a native lazy tool" + done +-[[ $(grep -c 'lazy = true' "$lazy_config") == 31 ]] || fail "user setup declares every default mise tool as lazy" ++[[ $(grep -c 'lazy = true' "$lazy_config") == 32 ]] || fail "user setup declares every default mise tool as lazy" + grep -Fx "reshim --system" "$mise_history" >/dev/null || fail "user setup builds the system lazy bootstrap shims" + pass "user setup configures system lazy tools from registry shorthands" + : >"$stub_log" +@@ -424,6 +427,8 @@ declare -A expected_agents=( + [muse]="muse" + [muse-code]="muse" + [musecode]="muse" ++ [zycode]="zycode" ++ [zypi]="zycode" + ) + + declare -A expected_packages=( +@@ -449,6 +454,7 @@ declare -A expected_packages=( + [commandcode]="$commandcode_package" + [cursor-agent]="$cursor_agent_package" + [muse]="$muse_package" ++ [zycode]="$zycode_package" + ) + + for selection in "${!expected_agents[@]}"; do +@@ -707,7 +713,7 @@ mapfile -d '' -t agent_open_args <"$agent_open_log" + pass "Muse installs visibly through mise and opens directly" + + saved_agent=$(<"$agent_file") +-for agent in qwen dsh mcode kiro-cli freebuff kilo devin amp commandcode; do ++for agent in qwen dsh mcode kiro-cli freebuff kilo devin amp commandcode zycode; do + tool_var="${agent//-/_}_tool" + package_var="${agent//-/_}_package" + declared_tool=${!tool_var:-${!package_var}} +@@ -715,7 +721,7 @@ for agent in qwen dsh mcode kiro-cli freebuff kilo devin amp commandcode; do + omarchy-default-agent --install "$agent" >/dev/null + # npm-backed agents bring node along, which a fresh machine doesn't have yet. + case "$agent" in +- kiro-cli | devin) expected_install="install $declared_tool" ;; ++ kiro-cli | devin | zycode) expected_install="install $declared_tool" ;; + *) expected_install="install node $declared_tool" ;; + esac + grep -Fx "$expected_install" "$mise_history" >/dev/null || fail "visible $agent installation installs Omarchy's declaration (expected: $expected_install)" +@@ -842,6 +848,7 @@ assert_launch kilo kilo --auto "--prompt=Review this project" + assert_launch devin devin --permission-mode dangerous --respect-workspace-trust false -- "Review this project" + assert_launch amp bash -c 'printf "%s\n" "$1" | exec "$0" --dangerously-allow-all' amp "Review this project" + assert_launch commandcode commandcode --yolo -- "Review this project" ++assert_launch zycode zypi --always-approve -- "Review this project" + [[ $(<"$clipboard_log") == "Review this project" ]] || fail "Freebuff launcher puts the prompt on the clipboard" + mapfile -d '' -t notification_args <"$notification_history" + [[ ${notification_args[*]} == *"Freebuff takes no starting prompt"* ]] || fail "Freebuff launcher says where the prompt went" +@@ -885,6 +892,7 @@ assert_bypass kilo kilo --auto + assert_bypass devin devin --permission-mode dangerous --respect-workspace-trust false + assert_bypass amp amp --dangerously-allow-all + assert_bypass commandcode commandcode --yolo ++assert_bypass zycode zypi --always-approve + [[ ! -s $clipboard_log && ! -s $notification_history ]] || fail "Freebuff launcher leaves the clipboard alone without a prompt" + pass "agent launcher skips permission prompts for every supported agent" +``` + +--- + +## 5. Test Evidence + +### A. Omarchy Agent Test (`test/shell.d/default-agent-test.sh`) +```bash +$ bash test/shell.d/default-agent-test.sh +ok - custom agent lazy stubs preserve their mise packages +ok - user setup configures system lazy tools from registry shorthands +ok - user setup leaves ordinary lazy wrappers to mise +ok - Remove Preinstalls deletes every optional agent lazy stub +ok - Remove Preinstalls keeps an official Cursor CLI install +ok - Remove Preinstalls keeps a user-managed Muse install +ok - default agent is unset until one is chosen +ok - agent launcher refuses to launch without a default +ok - agent launcher opens a local model without a default +ok - agent launcher opens Qwen Code on a local model, keeping its key off the command line +ok - --pick opens the agent defaults menu when none is set +ok - terminal alias launches the default agent inline +ok - agent launcher has a keyboard shortcut +ok - default agent selects and opens every supported provider and alias +ok - default agent stores its selection in Omarchy user config +ok - extension installation failure silently continues selecting and launching Claude +ok - missing agents install visibly and open in the same terminal +ok - an agent installed from the Quake console opens tiled in the console +ok - an install from a terminal sharing one process across windows finds its own window +ok - installed agents select and open without notifications +ok - selecting an official Cursor CLI install skips mise +ok - a dead file at the wrapper's path does not pass for an install +ok - default agent rejects unsupported providers without changing the selection +ok - default agent opens only after mise installs the provider +ok - default agent reports mise failures without notifications +ok - failed Muse mise installation preserves the selection and skips login +ok - Muse installs visibly through mise and opens directly +ok - the added agents install through Omarchy's mise declarations +ok - installed Muse selects and opens directly +ok - default agent reports Muse mise failures without changing the selection +ok - selecting a user-installed Muse preserves its launcher +ok - agent launcher adapts initial prompts for every supported agent +ok - Muse receives option-like prompts as one literal argument +ok - Hermes receives prompted launches as one literal query argument +ok - agent launcher skips permission prompts for every supported agent +ok - agent launcher starts the selected agent without an initial prompt +ok - inline agent launcher runs in the current terminal +ok - --pick launches once an agent is chosen +ok - --prefer-local opens the running local model, and the usual agent otherwise +ok - omarchy agent keeps prompts on the prompt route +ok - agent launcher reports a missing default command +ok - choosing OpenClaw uses its runtime and launches its terminal UI +ok - a missing OpenClaw routes through the install terminal +ok - installing OpenClaw as default agent sets up its runtime +ok - OpenClaw receives prompts through --message +ok - OpenClaw's agent hands a missing command to its launcher only when the package is there +ok - agent launcher runs user-installed agents ahead of native lazy shims +# 47/47 tests passed (0 failures) +``` + +### B. Omarchy Menu & i18n Test (`test/shell.d/i18n-test.sh`) +```bash +$ bash test/shell.d/i18n-test.sh +# 123/123 tests passed (0 failures) +``` +- Validated that `agent.harness.zycode` in `default/omarchy/omarchy-menu.jsonc` matches the catalog entry in `default/i18n/en/menu.json`. +- Validated that no duplicate or orphan keys exist in menu configurations. diff --git a/packages/pi-agent-cli/AGENTS.md b/packages/pi-agent-cli/AGENTS.md index fb120235..7b9c4b08 100644 --- a/packages/pi-agent-cli/AGENTS.md +++ b/packages/pi-agent-cli/AGENTS.md @@ -124,11 +124,18 @@ The question to the user holds the reason as one fixed sentence (`auto_reasons.s ## TUI spawn -The Rust TUI (`zypi`) spawns the Python agent via (priority order): +The Rust TUI (`zypi`) spawns the ACP agent via (priority order): 1. `PI_AGENT_COMMAND` env var 2. `[agent].command` in `agent.toml`, then in `config.toml` -3. `PI_PYTHON` env var (appends `-m pi_agent_cli`) +3. `PI_PYTHON` env var: ONLY when `PI_PYTHON` is explicitly set in the environment and non-empty (appends `["-m", "pi_agent_cli"]`) +4. Default (when none of the above is set): `zycode-agent` (`zycode-agent.exe` on Windows) with empty args: + - Sibling binary next to the current `zypi` executable + - Sibling binary next to the canonicalized target (following symlinks, e.g. for `~/.local/bin/zypi` symlinks) + - Fall back to searching `PATH` for `zycode-agent` + - Notice: `zypi` does NOT fall back to bare `python` or `python3` when `PI_PYTHON` is unset. + +`zypi --setup` runs the setup command (`--setup`) directly on the resolved agent program, allowing users to configure their provider, model, and API key immediately in the terminal. **The agent's stderr.** The TUI owns the screen, and its own fd 2 is `/dev/null` (`pi_tty_utils::redirect_native_stderr`), so the agent's stderr goes to `/logs/agent.stderr.log` instead (`acp/spawn.rs`, `agent_stderr`): appended across runs, one `--- agent started