diff --git a/DEVLOG.md b/DEVLOG.md index fafab02..949c42f 100644 --- a/DEVLOG.md +++ b/DEVLOG.md @@ -1,7 +1,41 @@ # OpenClaw Manager — 开发日志 -> 最后更新:2026-02-24 -> 当前版本:v0.5.0 +> 最后更新:2026-02-25 +> 当前版本:v0.5.1 + +--- + +## v0.5.1 更新日志(2026-02-25) + +### 修复 + +**Action 菜单英文模式残留中文** +- 修复 Action 菜单下多处弹窗在 EN 模式仍显示中文的问题(日志、回滚、目录切换、命令输出) +- 统一接入 i18n:标题、按钮、说明文案、加载态、空态、确认框、toast 文案 +- 菜单项触发后的交互文案现在与语言切换保持一致 + +### 工程改进 + +**1) 嵌入脚本转义/语法防护** +- 新增启动时预检:对前端嵌入脚本执行 `node --check` 语法校验 +- 若语法异常(常见为 `MAIN_HTML` 内 `\n` 转义写错),启动阶段直接报错并给出修复提示,避免浏览器白屏后才发现问题 + +**2) 单文件结构化重构(保持零依赖)** +- 将主页面模板从单一超长 `MAIN_HTML` 拆分为三段常量: + - `MAIN_HTML_CSS` + - `MAIN_HTML_BODY` + - `MAIN_HTML_SCRIPT` +- 最终由 `MAIN_HTML` 组合输出,保持“单文件 + 零依赖”不变,同时降低维护复杂度 +- 修复拆分过程中的脚本模板转义问题:`MAIN_HTML_SCRIPT` 使用普通模板字符串(非 `String.raw`),确保前端脚本内的反引号模板语法可被正确还原 + +### 其他 + +- 程序头部版本与启动日志版本更新为 `v0.5.1` +- `start.sh` / `start.bat` 启动横幅版本号同步更新为 `v0.5.1` +- `README` 补充 Git 安装/更新流程(`git clone` / `git pull --ff-only`),并精简中英文功能介绍 +- `README` 首屏改版:增加「1 分钟上手」命令区(安装/更新/运行同屏),并将开场介绍改为精简版 +- `README` 去重:移除中部重复的安装/更新/运行段落,统一引用首屏快速上手 +- `README` 截图区改为首屏精简展示(3 张)+ 折叠更多截图(`
`) --- diff --git a/README.md b/README.md index de0aea4..29a94e7 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,28 @@ --- -## What is this? +## Quick Start (1 min) -OCM is a lightweight local dashboard for OpenClaw that helps you: +```bash +# Install +git clone https://github.com/dtzp555-max/ocm.git +cd ocm -- **Manage sub-agents fast** (create with a wizard, switch models inline) -- **Run OpenClaw commands inside the app** via a built-in CLI terminal -- **Stop hunting for CLI flags / docs** with curated command presets + favorites +# Update (existing clone) +git pull --ff-only -Everything ships as **a single `.js` file** with zero npm dependencies — just Node.js 18+. +# Run (no npm install needed) +bash start.sh # macOS / Linux +start.bat # Windows +``` + +Open [http://localhost:3333](http://localhost:3333). + +## Why OCM + +- **Single-file + zero dependency**: one `openclaw-manager.js`, no build step +- **Fast daily operations**: agent/model/auth/cron/backup in one local UI +- **Built-in terminal**: run `openclaw` commands with streaming output and presets ## Screenshots @@ -28,6 +41,14 @@ View all agents (main + sub-agents) at a glance. Each card shows model, group bi ![Agents](screenshots/agents.png) +### Built-in CLI Terminal +Run any openclaw command with real-time streaming output. The terminal panel sits at the bottom of the page and expands on demand. + +![CLI Overview](screenshots/cli1.png) + +
+More screenshots + ### New Subagent Wizard 4-step guided wizard to create a sub-agent: basic info → model → personality & memory → confirm. Fully bilingual. @@ -48,11 +69,6 @@ View, add, enable/disable, and manually trigger openclaw-related cron tasks. Int ![Cron](screenshots/cron.png) -### Built-in CLI Terminal -Run any openclaw command with real-time streaming output. The terminal panel sits at the bottom of the page and expands on demand. - -![CLI Overview](screenshots/cli1.png) - Preset command menu with built-in commands and your personal favorites — one click to run. ![CLI Presets](screenshots/cli3.png) @@ -60,42 +76,23 @@ Preset command menu with built-in commands and your personal favorites — one c Command output streams in real-time. Star frequently used commands for quick access, or use the Manage button to organize favorites. ![CLI Detail](screenshots/cli2.png) +
## Features -- **Agent Management** — Create sub-agents (with wizard), switch models inline, browse & edit workspace files, delete with auto-backup -- **Model Selection** — Change global primary model, edit fallback chain -- **Auth Guide** — Step-by-step instructions for configuring each provider (Anthropic, OpenAI, DeepSeek, Google, GitHub Copilot, etc.) -- **Token Usage Stats** — Parse `gateway.log` for token usage, view cost breakdown by model and day -- **Cron Job Management** — View, add, enable/disable, and trigger openclaw-related cron tasks -- **Workspace File Browser** — Browse all agent workspace files, read-only by default, editable on demand -- **Backup & Rollback** — Auto-backup before every write, one-click restore from any snapshot -- **NAS Backup** — SFTP/rsync backup to NAS with legacy SSH cipher compatibility -- **Built-in CLI Terminal** — Run openclaw commands with real-time streaming output, presets, tab completion -- **Health Badge** — Auto-run `openclaw doctor` and show warnings in the header -- **Bilingual UI** — English / 中文, switchable at runtime -- **Cross-platform** — macOS / Linux / Windows +- **Agents & Workspace** — Create sub-agents, switch models inline, and browse/edit workspace files +- **Models & Auth** — Manage primary/fallback models and follow provider auth guides +- **Ops Panel** — Restart gateway, view logs, run health checks, and switch OpenClaw directory +- **Stats & Cron** — Token/cost stats from `gateway.log` plus cron task management +- **Backups** — Local backup/rollback and NAS backup (SFTP/rsync) +- **Built-in CLI** — Real-time command terminal with presets, favorites, and tab completion ## Requirements - Node.js >= 18 ([download](https://nodejs.org/)) - A working [OpenClaw](https://github.com/anthropics/openclaw) installation -## Quick Start - -```bash -git clone https://github.com/dtzp555-max/ocm.git -cd ocm -# No npm install needed - -# macOS / Linux -bash start.sh - -# Windows -start.bat -``` - -Then open http://localhost:3333 in your browser. +Install/update/run commands are in **Quick Start (1 min)** above. ### First Run @@ -176,13 +173,40 @@ MIT OpenClaw Manager 是一个零依赖的本地 Web 管理界面,用于可视化管理 [OpenClaw](https://github.com/anthropics/openclaw) AI 智能体。所有代码合并在一个 `.js` 文件中,只需要 Node.js 18+,不需要 `npm install`。 +### 1 分钟上手 + +```bash +# 首次安装 +git clone https://github.com/dtzp555-max/ocm.git +cd ocm + +# 已安装后更新 +git pull --ff-only + +# 运行(无需 npm install) +bash start.sh # macOS / Linux +start.bat # Windows +``` + +访问 [http://localhost:3333](http://localhost:3333)。 + ### 界面预览 #### 模式选择 ![Landing](screenshots/landing.png) -#### Agent 管理 & 新建向导 +#### Agent 管理 ![Agents](screenshots/agents.png) + +#### 内置 CLI 终端 +底部终端面板,支持实时流式输出、预设命令、收藏夹、Tab 补全。 + +![CLI](screenshots/cli1.png) + +
+更多截图 + +#### 新建向导 ![New Subagent](screenshots/subagents.png) #### 模型选择 & 操作菜单 @@ -194,42 +218,20 @@ OpenClaw Manager 是一个零依赖的本地 Web 管理界面,用于可视化 #### Cron 定时任务 ![Cron](screenshots/cron.png) -#### 内置 CLI 终端 -底部终端面板,支持实时流式输出、预设命令、收藏夹、Tab 补全。 - -![CLI](screenshots/cli1.png) ![CLI Presets](screenshots/cli3.png) ![CLI Detail](screenshots/cli2.png) +
### 功能一览 -- **Agent 管理** — 新建子智能体(含向导)、内联切换模型、查看/编辑工作区文件、删除(自动备份) -- **模型选择** — 修改全局主模型、编辑 Fallback 链 -- **认证引导** — 各 Provider 分步操作指引 + 一键复制 CLI 命令 -- **Token 用量统计** — 解析网关日志,按模型/天汇总 Token 和费用 -- **Cron 任务管理** — 查看、添加、启用/禁用、手动触发 openclaw 相关定时任务 -- **Workspace 文件浏览器** — 查看所有工作区文件,默认只读,可切换编辑 -- **备份 & 回滚** — 每次写入前自动备份,一键回滚 -- **NAS 备份** — SFTP/rsync 远程备份,兼容老设备 SSH 加密 -- **内置 CLI 终端** — 实时流式输出、预设命令、Tab 补全 -- **健康检查** — 自动运行 `openclaw doctor`,Header 显示状态徽章 -- **中英双语** — 运行时随时切换 -- **跨平台** — macOS / Linux / Windows +- **Agent 与 Workspace** — 新建子智能体、内联切换模型、浏览/编辑工作区文件 +- **模型与认证** — 管理主模型/Fallback 链,按引导完成各 Provider 认证 +- **运维操作面板** — 重启网关、查看日志、健康检查、切换 OpenClaw 目录 +- **统计与计划任务** — 从 `gateway.log` 汇总 Token/费用,并管理 Cron 任务 +- **备份能力** — 本地备份回滚 + NAS 远程备份(SFTP/rsync) +- **内置 CLI 终端** — 实时输出、预设命令、收藏、Tab 补全 -### 快速开始 - -```bash -git clone https://github.com/dtzp555-max/ocm.git -cd ocm - -# macOS / Linux -bash start.sh - -# Windows -start.bat -``` - -访问 http://localhost:3333 +安装/更新/运行命令见上方 **1 分钟上手**。 ### 首次运行 diff --git a/openclaw-manager.js b/openclaw-manager.js index cdf0efd..4232fa7 100644 --- a/openclaw-manager.js +++ b/openclaw-manager.js @@ -1,6 +1,6 @@ #!/usr/bin/env node // ================================================================ -// OpenClaw Manager v0.5.0 +// OpenClaw Manager v0.5.1 // 跨平台本地管理工具 (Windows / macOS / Linux) // // 用法: @@ -22,6 +22,7 @@ const { exec, execSync, spawn, spawnSync } = require('child_process'); const SCRIPT_DIR = __dirname; const MANAGER_CONFIG = path.join(SCRIPT_DIR, 'manager-config.json'); let PORT = 3333; +const APP_VERSION = '0.5.1'; // --port 参数 const portIdx = process.argv.indexOf('--port'); if (portIdx !== -1 && process.argv[portIdx + 1]) PORT = parseInt(process.argv[portIdx + 1]) || 3333; @@ -1180,14 +1181,7 @@ document.getElementById('dir').addEventListener('keydown',e=>{if(e.key==='Enter' `; // ── 主 HTML 前端 ────────────────────────────────────────────── -const MAIN_HTML = ` - - - - -OpenClaw Manager - - - +.fav-manage-cmd { font-size:11px; color:var(--muted); font-family:monospace; max-width:220px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }`; +const MAIN_HTML_BODY = String.raw` @@ -1791,29 +1783,29 @@ code { font-size:12px; background:rgba(0,0,0,.3); padding:2px 6px; border-radius
@@ -1898,27 +1890,27 @@ code { font-size:12px; background:rgba(0,0,0,.3); padding:2px 6px; border-radius
@@ -1926,14 +1918,13 @@ code { font-size:12px; background:rgba(0,0,0,.3); padding:2px 6px; border-radius -
+
`; - `; +function assertBrowserScriptSyntax(name, scriptText) { + const tmpFile = path.join(os.tmpdir(), `ocm-${name}-${process.pid}.js`); + fs.writeFileSync(tmpFile, scriptText, 'utf8'); + const r = spawnSync(process.execPath, ['--check', tmpFile], { encoding: 'utf8', timeout: 5000 }); + try { fs.unlinkSync(tmpFile); } catch (_) {} + if (r.status !== 0) { + const detail = (r.stderr || r.stdout || 'unknown syntax error').trim(); + throw new Error( + `${name} syntax check failed.\n${detail}\nHint: in MAIN_HTML_SCRIPT strings, write "\\\\n" instead of "\\n".` + ); + } +} +assertBrowserScriptSyntax('main-html-script', MAIN_HTML_SCRIPT); + // ── HTTP 服务器 ─────────────────────────────────────────────── const server = http.createServer(async (req, res) => { res.setHeader('Access-Control-Allow-Origin', '*'); @@ -3418,7 +3468,7 @@ const server = http.createServer(async (req, res) => { server.listen(PORT, '127.0.0.1', () => { const url = `http://localhost:${PORT}`; console.log(''); - console.log('🦀 OpenClaw Manager v0.3'); + console.log(`🦀 OpenClaw Manager v${APP_VERSION}`); console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'); console.log('📂 目录:' + OPENCLAW_DIR); console.log('🌐 地址:' + url); diff --git a/start.bat b/start.bat index 693a160..0098720 100644 --- a/start.bat +++ b/start.bat @@ -1,6 +1,6 @@ @echo off :: ================================================================ -:: OpenClaw Manager v0.5 — Windows 启动脚本 +:: OpenClaw Manager v0.5.1 — Windows 启动脚本 :: :: 特性: :: * 自动检测 Node.js,未安装时给出安装指引(winget/scoop/官网) @@ -19,7 +19,7 @@ set "MIN_NODE_MAJOR=18" echo. echo =================================== -echo OpenClaw Manager v0.5 +echo OpenClaw Manager v0.5.1 echo ----------------------------------- echo. diff --git a/start.sh b/start.sh index 6ab721f..5f1fd3e 100755 --- a/start.sh +++ b/start.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # ================================================================ -# OpenClaw Manager v0.5 — 跨平台启动脚本 (macOS / Linux) +# OpenClaw Manager v0.5.1 — 跨平台启动脚本 (macOS / Linux) # # 特性: # • 自动检测 Node.js,未安装时给出安装指引 @@ -22,7 +22,7 @@ CYAN='\033[0;36m'; BOLD='\033[1m'; DIM='\033[2m'; RESET='\033[0m' banner() { echo "" - echo -e "${CYAN}${BOLD} 🦀 OpenClaw Manager v0.5${RESET}" + echo -e "${CYAN}${BOLD} 🦀 OpenClaw Manager v0.5.1${RESET}" echo -e "${DIM} ─────────────────────────────${RESET}" echo "" }