JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix: esc and double ctrl+d to esc,add build whl pkg guide
huanggawa97f28bd5ee2d
diff --git a/docs/en/developer_guide.md b/docs/en/developer_guide.mdindex 83809d311a..c289282ed2 100644--- a/docs/en/developer_guide.md+++ b/docs/en/developer_guide.md@@ -219,3 +219,73 @@ After installation, verify the version:node --version# Expected output: v18.x.x or higher```++## 6. Building Packages++The project supports two distribution formats: **Python wheel packages** (`.whl`) and **desktop executables** (`.exe` / `.dmg`).++### 6.1 Building Wheel Packages++The project contains two independent wheel packages:++| Package | Description | Config File |+|---------|-------------|-------------|+| `jiuwenclaw` | Backend service main package (includes Web frontend build artifacts) | `pyproject.toml` |+| `jiuwenclaw-tui` | TUI terminal interface sidecar package (includes Bun-compiled native binaries) | `packages/jiuwenclaw-tui/pyproject.toml` |++#### 6.1.1 Build All (Recommended)++Run from the project root directory:++```bash+# macOS / Linux+bash scripts/build.sh+```++The script will execute the following steps in order:+1. Build the Web frontend (runs `npm run build` in `jiuwenclaw/channels/web/frontend`)+2. Build the main package `jiuwenclaw.whl`+3. If `bun` is detected, continue to build the TUI native binary and `jiuwenclaw-tui.whl`++Artifacts are output to two directories:+- `./dist/jiuwenclaw-<version>-py3-none-any.whl` (main package)+- `./packages/jiuwenclaw-tui/dist/jiuwenclaw_tui-<version>-<platform>.whl` (TUI sidecar package)++### 6.2 Desktop EXE / DMG Packaging++The desktop version uses [PyInstaller](https://pyinstaller.org/) to package the Python application into a standalone executable.++#### 6.2.1 Prerequisites++- `uv` and `Node.js` installed+- Install development dependencies via `uv sync --extra dev` (includes PyInstaller)++#### 6.2.2 Windows Packaging (EXE)++**Using batch script (recommended):**++```cmd+scripts\build-exe.bat+```++**Using PowerShell script:**++```powershell+.\scripts\build-exe.ps1+```++Output: `dist\jiuwenclaw\jiuwenclaw.exe`++#### 6.2.3 macOS Packaging (DMG)++```bash+bash scripts/build-macos.sh+```++The script will execute the following steps in order:+1. Install Python dependencies (`uv sync --extra dev`)+2. Build the Web frontend (`npm run build`)+3. Package with PyInstaller to generate `JiuwenClaw.app`+4. Create a DMG installer image using `hdiutil`++Output: `dist/JiuwenClaw-<version>.dmg`diff --git a/docs/zh/developer_guide.md b/docs/zh/developer_guide.mdindex a36e012fd3..5cea8d2939 100644--- a/docs/zh/developer_guide.md+++ b/docs/zh/developer_guide.md@@ -219,3 +219,73 @@ Windows 用户可使用 [nvm-windows](https://github.com/coreybutler/nvm-windowsnode --version# 预期输出:v18.x.x 或更高```++## 6. 编译包++项目支持两种分发形式:**Python wheel 包**(`.whl`)和**桌面可执行文件**(`.exe` / `.app`)。++### 6.1 wheel 包构建++项目包含两个独立的 wheel 包:++| 包名 | 说明 | 配置文件 |+|------|------|----------|+| `jiuwenclaw` | 后端服务主包(含 Web 前端构建产物) | `pyproject.toml` |+| `jiuwenclaw-tui` | TUI 终端界面 sidecar 包(含 Bun 编译的原生二进制) | `packages/jiuwenclaw-tui/pyproject.toml` |++#### 6.1.1 一键构建全部(推荐)++在项目根目录执行:++```bash+# macOS / Linux+bash scripts/build.sh+```++该脚本会依次执行:+1. 编译 Web 前端(`jiuwenclaw/channels/web/frontend` 目录下执行 `npm run build`)+2. 构建主包 `jiuwenclaw.whl`+3. 如果检测到 `bun` 命令,继续构建 TUI 原生二进制和 `jiuwenclaw-tui.whl`++产物输出到两个目录:+- `./dist/jiuwenclaw-<version>-py3-none-any.whl`(主包)+- `./packages/jiuwenclaw-tui/dist/jiuwenclaw_tui-<version>-<platform>.whl`(TUI sidecar 包)++### 6.2 桌面版 EXE / DMG 打包++桌面版通过 [PyInstaller](https://pyinstaller.org/) 将 Python 应用打包为独立可执行文件。++#### 6.2.1 前置条件++- 已安装 `uv`、`Node.js`+- 通过 `uv sync --extra dev` 安装开发依赖(包含 PyInstaller)++#### 6.2.2 Windows 平台打包(EXE)++**使用批处理脚本(推荐):**++```cmd+scripts\build-exe.bat+```++**使用 PowerShell 脚本:**++```powershell+.\scripts\build-exe.ps1+```++产物目录:`dist\jiuwenclaw\jiuwenclaw.exe`++#### 6.2.3 macOS 平台打包(DMG)++```bash+bash scripts/build-macos.sh+```++该脚本会依次执行:+1. 安装 Python 依赖(`uv sync --extra dev`)+2. 编译 Web 前端(`npm run build`)+3. PyInstaller 打包生成 `JiuwenClaw.app`+4. 使用 `hdiutil` 创建 DMG 安装镜像++产物:`dist/JiuwenClaw-<version>.dmg`diff --git a/jiuwenclaw/channels/tui/frontend/src/ui/app-screen.ts b/jiuwenclaw/channels/tui/frontend/src/ui/app-screen.tsindex 35105d8b4c..112f3ed5df 100644--- a/jiuwenclaw/channels/tui/frontend/src/ui/app-screen.ts+++ b/jiuwenclaw/channels/tui/frontend/src/ui/app-screen.ts@@ -2638,6 +2638,8 @@ export class AppScreen implements Component, Focusable {const reject = question.options.find((option) => option.label === "拒绝");if (reject) {this.handleQuestionSelection(reject.label);+ } else if (question.options.length > 0) {+ this.handleQuestionSelection(question.options[0].label);}};const selectedValue = this.pendingQuestionAnswers.get(this.activeQuestionIndex);diff --git a/jiuwenclaw/channels/tui/frontend/src/ui/keymap.ts b/jiuwenclaw/channels/tui/frontend/src/ui/keymap.tsindex 730bfc2951..dbdc2ae130 100644--- a/jiuwenclaw/channels/tui/frontend/src/ui/keymap.ts+++ b/jiuwenclaw/channels/tui/frontend/src/ui/keymap.ts@@ -39,6 +39,20 @@ export const APP_SCREEN_KEY_BINDINGS: readonly KeyBinding[] = [delegate.interruptTask();},},+ {+ key: "ctrl+d",+ label: "ctrl+d",+ description: "中断任务;连按两次退出",+ run: (delegate) => {+ const now = Date.now();+ if (now - lastInterruptTime < 1000) {+ delegate.exitApp();+ return;+ }+ lastInterruptTime = now;+ delegate.interruptTask();+ },+ },{key: "ctrl+l",label: "ctrl+l",diff --git a/scripts/build_python_packages.py b/scripts/build_python_packages.pyindex 18d59de4be..66fb0c3b03 100644--- a/scripts/build_python_packages.py+++ b/scripts/build_python_packages.py@@ -15,8 +15,8 @@ SIDE_CAR_DIST = SIDECAR_ROOT / "dist"TUI_ROOT = ROOT / "jiuwenclaw" / "channels" / "tui" / "frontend"TUI_TARGETS = {- #"linux-x64": "linux_x86_64",- #"linux-arm64": "linux_aarch64",+ "linux-x64": "linux_x86_64",+ "linux-arm64": "linux_aarch64",#"macos-x64": "macosx_10_15_x86_64","macos-arm64": "macosx_11_0_arm64","windows-x64": "win_amd64",