diff --git a/README_zh.md b/README_zh.md index 223aeae..ad2fac8 100644 --- a/README_zh.md +++ b/README_zh.md @@ -1,4 +1,4 @@ -# Kaiwu - 本地模型 Coding Agent +# KwQode - 本地模型 Coding Agent > 中国开发者的本地 coding agent——Windows 打开就能用,数据不出网,越用越懂你的项目。 @@ -33,7 +33,7 @@ chmod +x install.sh && ./install.sh ### 手动安装 ```bash -# 1. 安装 Kaiwu +# 1. 安装 KwQode pip install kaiwu # 国内网络慢可用清华镜像 pip install kaiwu -i https://pypi.tuna.tsinghua.edu.cn/simple @@ -49,7 +49,7 @@ ollama pull gemma3:4b # 4GB 显存或 CPU # 4. 初始化项目 cd your-project -kaiwu init +kwqode init ``` ## 使用方法 @@ -58,18 +58,18 @@ kaiwu init ```bash # 交互模式(REPL) -kaiwu +kwqode # 单次任务 -kaiwu "修复登录接口的空指针异常" -kaiwu "给 UserService 加单元测试" -kaiwu "把这个函数重构成策略模式" +kwqode "修复登录接口的空指针异常" +kwqode "给 UserService 加单元测试" +kwqode "把这个函数重构成策略模式" ``` ### CLI 参数 ```bash -kaiwu [任务] [选项] +kwqode [任务] [选项] 选项: -m, --model TEXT Ollama 模型名称(默认 qwen3-8b) @@ -98,21 +98,21 @@ kaiwu [任务] [选项] ### 子命令 ```bash -kaiwu init # 初始化项目记忆 -kaiwu status # 查看模型/专家/连接状态 -kaiwu memory # 查看 KAIWU.md 内容 -kaiwu serve-mcp # 启动 MCP Server(stdio 模式) +kwqode init # 初始化项目记忆 +kwqode status # 查看模型/专家/连接状态 +kwqode memory # 查看 KAIWU.md 内容 +kwqode serve-mcp # 启动 MCP Server(stdio 模式) ``` ### 专家管理 ```bash -kaiwu expert list # 列出所有专家 -kaiwu expert info APIExpert # 查看专家详情 -kaiwu expert create my-expert # 创建自定义专家模板 -kaiwu expert export APIExpert # 导出为 .kwx 包 -kaiwu expert install ./my.kwx # 安装专家包 -kaiwu expert remove my-expert # 删除专家 +kwqode expert list # 列出所有专家 +kwqode expert info APIExpert # 查看专家详情 +kwqode expert create my-expert # 创建自定义专家模板 +kwqode expert export APIExpert # 导出为 .kwx 包 +kwqode expert install ./my.kwx # 安装专家包 +kwqode expert remove my-expert # 删除专家 ``` ## 架构 @@ -186,7 +186,7 @@ kaiwu expert remove my-expert # 删除专家 ## 配置 -Kaiwu 通过命令行参数和环境变量配置,无需配置文件。 +KwQode 通过命令行参数和环境变量配置,无需配置文件。 **环境变量:** @@ -198,10 +198,10 @@ Kaiwu 通过命令行参数和环境变量配置,无需配置文件。 **项目级配置:** -每个项目根目录的 `KAIWU.md` 文件记录项目架构、技术栈和偏好,Kaiwu 会自动读取并作为上下文传给 LLM。 +每个项目根目录的 `KAIWU.md` 文件记录项目架构、技术栈和偏好,KwQode 会自动读取并作为上下文传给 LLM。 ```bash -kaiwu init # 自动扫描项目结构,生成 KAIWU.md +kwqode init # 自动扫描项目结构,生成 KAIWU.md ``` ## 常见问题 @@ -227,13 +227,13 @@ pip install kaiwu -i https://pypi.tuna.tsinghua.edu.cn/simple **Q: 模型推理太慢?** -- 确认 GPU 被正确识别:`nvidia-smi` 或 `kaiwu status` -- 换用更小的模型:`kaiwu -m gemma3:4b "你的任务"` +- 确认 GPU 被正确识别:`nvidia-smi` 或 `kwqode status` +- 换用更小的模型:`kwqode -m gemma3:4b "你的任务"` - Reasoning 模型(如 deepseek-r1)可关闭 thinking:自动优化已内置 **Q: Windows 下中文乱码?** -Kaiwu 已内置 GBK 编码修复。如仍有问题: +KwQode 已内置 GBK 编码修复。如仍有问题: ```powershell # PowerShell 设置 UTF-8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 @@ -244,17 +244,17 @@ chcp 65001 通过 MCP 协议: ```bash -kaiwu serve-mcp -m qwen3:8b +kwqode serve-mcp -m qwen3:8b ``` -在 IDE 的 MCP 配置中添加 Kaiwu 作为 stdio server 即可。 +在 IDE 的 MCP 配置中添加 KwQode 作为 stdio server 即可。 **Q: 如何创建自定义专家?** ```bash -kaiwu expert create my-expert # 生成模板 YAML +kwqode expert create my-expert # 生成模板 YAML # 编辑 ~/.kaiwu/experts/my-expert.yaml # 配置 trigger_keywords、system_prompt、pipeline -kaiwu expert list # 确认已加载 +kwqode expert list # 确认已加载 ``` ## 系统要求 diff --git a/install.ps1 b/install.ps1 index 8dd8300..6b1391a 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1,4 +1,4 @@ -# Kaiwu 安装程序 - Windows PowerShell +# KwQode 安装程序 - Windows PowerShell # 用法: powershell -ExecutionPolicy Bypass -File install.ps1 $ErrorActionPreference = "Continue" @@ -7,7 +7,7 @@ $ErrorActionPreference = "Continue" # ── Banner ─────────────────────────────────────────────────── Write-Host "" Write-Host " ╔══════════════════════════════════════╗" -ForegroundColor Cyan -Write-Host " ║ Kaiwu 安装程序 v0.4 ║" -ForegroundColor Cyan +Write-Host " ║ KwQode 安装程序 v0.4 ║" -ForegroundColor Cyan Write-Host " ║ 本地模型 Coding Agent ║" -ForegroundColor Cyan Write-Host " ╚══════════════════════════════════════╝" -ForegroundColor Cyan Write-Host "" @@ -64,7 +64,7 @@ try { } # ── Step 3: pip install kaiwu ──────────────────────────────── -Write-Step "安装 Kaiwu..." +Write-Step "安装 KwQode..." $installed = $false @@ -87,7 +87,7 @@ if (-not $installed) { } if (-not $installed) { - Write-Err "Kaiwu 安装失败" + Write-Err "KwQode 安装失败" Write-Info "请手动执行: $pythonCmd -m pip install kaiwu" Write-Info "如果网络慢,加上: -i https://pypi.tuna.tsinghua.edu.cn/simple" exit 1 @@ -155,26 +155,26 @@ if ($ollamaOk) { } } -# ── Step 6: kaiwu init ─────────────────────────────────────── -Write-Step "初始化 Kaiwu..." +# ── Step 6: kwqode init ────────────────────────────────────── +Write-Step "初始化 KwQode..." try { - & kaiwu init 2>&1 | Out-Null + & kwqode init 2>&1 | Out-Null if ($LASTEXITCODE -eq 0) { Write-Info "KAIWU.md 已初始化" } } catch { - Write-Info "跳过初始化(可稍后在项目目录执行 kaiwu init)" + Write-Info "跳过初始化(可稍后在项目目录执行 kwqode init)" } -# ── Step 7: kaiwu status ───────────────────────────────────── +# ── Step 7: kwqode status ──────────────────────────────────── Write-Step "验证安装..." try { - & kaiwu status + & kwqode status } catch { Write-Warn "状态检查失败,但安装可能已成功" - Write-Info "请手动执行: kaiwu status" + Write-Info "请手动执行: kwqode status" } # ── 完成 ───────────────────────────────────────────────────── @@ -185,9 +185,9 @@ Write-Host " ╚═════════════════════ Write-Host "" Write-Host " 下一步:" -ForegroundColor Cyan Write-Host " 1. cd 到你的项目目录" -ForegroundColor White -Write-Host " 2. kaiwu init # 初始化项目记忆" -ForegroundColor White -Write-Host " 3. kaiwu # 进入交互模式" -ForegroundColor White -Write-Host ' 4. kaiwu "修复登录bug" # 直接执行任务' -ForegroundColor White +Write-Host " 2. kwqode init # 初始化项目记忆" -ForegroundColor White +Write-Host " 3. kwqode # 进入交互模式" -ForegroundColor White +Write-Host ' 4. kwqode "修复登录bug" # 直接执行任务' -ForegroundColor White Write-Host "" Write-Host " 文档: https://github.com/kaiwu-agent/kaiwu" -ForegroundColor Gray Write-Host "" diff --git a/install.sh b/install.sh index b98c51d..532c5ba 100644 --- a/install.sh +++ b/install.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Kaiwu 安装程序 - Mac/Linux +# KwQode 安装程序 - Mac/Linux # 用法: curl -sSL https://raw.githubusercontent.com/kaiwu-agent/kaiwu/main/install.sh | sh # 或: chmod +x install.sh && ./install.sh @@ -21,7 +21,7 @@ info() { printf " ${GRAY}%s${NC}\n" "$1"; } # ── Banner ─────────────────────────────────────────────────── printf "\n" printf " ${CYAN}╔══════════════════════════════════════╗${NC}\n" -printf " ${CYAN}║ Kaiwu 安装程序 v0.4 ║${NC}\n" +printf " ${CYAN}║ KwQode 安装程序 v0.4 ║${NC}\n" printf " ${CYAN}║ 本地模型 Coding Agent ║${NC}\n" printf " ${CYAN}╚══════════════════════════════════════╝${NC}\n" printf "\n" @@ -95,7 +95,7 @@ else fi # ── Step 3: pip install kaiwu ──────────────────────────────── -step "安装 Kaiwu..." +step "安装 KwQode..." INSTALLED=0 @@ -119,7 +119,7 @@ if [ "$INSTALLED" -eq 0 ]; then fi if [ "$INSTALLED" -eq 0 ]; then - err "Kaiwu 安装失败" + err "KwQode 安装失败" info "请手动执行: $PYTHON_CMD -m pip install kaiwu" info "如果网络慢,加上: -i https://pypi.tuna.tsinghua.edu.cn/simple" exit 1 @@ -184,21 +184,21 @@ if [ "$OLLAMA_OK" -eq 1 ]; then fi fi -# ── Step 6: kaiwu init ─────────────────────────────────────── -step "初始化 Kaiwu..." +# ── Step 6: kwqode init ────────────────────────────────────── +step "初始化 KwQode..." -if command -v kaiwu >/dev/null 2>&1; then - kaiwu init 2>/dev/null && info "KAIWU.md 已初始化" || info "跳过初始化(可稍后在项目目录执行 kaiwu init)" +if command -v kwqode >/dev/null 2>&1; then + kwqode init 2>/dev/null && info "KAIWU.md 已初始化" || info "跳过初始化(可稍后在项目目录执行 kwqode init)" else - info "kaiwu 命令未在 PATH 中,跳过初始化" + info "kwqode 命令未在 PATH 中,跳过初始化" info "尝试: $PYTHON_CMD -m kaiwu init" fi -# ── Step 7: kaiwu status ───────────────────────────────────── +# ── Step 7: kwqode status ──────────────────────────────────── step "验证安装..." -if command -v kaiwu >/dev/null 2>&1; then - kaiwu status || warn "状态检查失败,但安装可能已成功" +if command -v kwqode >/dev/null 2>&1; then + kwqode status || warn "状态检查失败,但安装可能已成功" else "$PYTHON_CMD" -m kaiwu status 2>/dev/null || warn "状态检查失败" fi @@ -211,9 +211,9 @@ printf " ${GREEN}╚═══════════════════ printf "\n" printf " ${CYAN}下一步:${NC}\n" printf " 1. cd 到你的项目目录\n" -printf " 2. kaiwu init # 初始化项目记忆\n" -printf " 3. kaiwu # 进入交互模式\n" -printf ' 4. kaiwu "修复登录bug" # 直接执行任务\n' +printf " 2. kwqode init # 初始化项目记忆\n" +printf " 3. kwqode # 进入交互模式\n" +printf ' 4. kwqode "修复登录bug" # 直接执行任务\n' printf "\n" printf " ${GRAY}文档: https://github.com/kaiwu-agent/kaiwu${NC}\n" printf "\n" diff --git a/kaiwu/cli/main.py b/kaiwu/cli/main.py index e7e8882..834dff6 100644 --- a/kaiwu/cli/main.py +++ b/kaiwu/cli/main.py @@ -1,9 +1,9 @@ """ -Kaiwu CLI entry point. -- kaiwu → 进入交互式 REPL -- kaiwu "修复bug" → 单次执行 -- kaiwu init → 初始化 KAIWU.md -- kaiwu memory → 查看项目记忆 +KwQode CLI entry point. +- kwqode → 进入交互式 REPL +- kwqode "修复bug" → 单次执行 +- kwqode init → 初始化 KAIWU.md +- kwqode memory → 查看项目记忆 """ import logging @@ -23,8 +23,8 @@ from rich.panel import Panel from rich.prompt import Prompt app = typer.Typer( - name="kaiwu", - help="Kaiwu - 本地模型 coding agent", + name="kwqode", + help="KwQode - 本地模型 coding agent", add_completion=False, no_args_is_help=False, ) @@ -203,7 +203,7 @@ def _repl(model_path, ollama_url, ollama_model, project_root, verbose): from kaiwu.memory.kaiwu_md import KaiwuMemory console.print(Panel( - f"[bold]Kaiwu v0.4[/bold] 交互模式\n" + f"[bold]KwQode v0.4[/bold] 交互模式\n" f"模型: {ollama_model} 项目: {project_root}\n" f"输入任务开始,/help 查看命令,/exit 退出", border_style="cyan", @@ -223,7 +223,7 @@ def _repl(model_path, ollama_url, ollama_model, project_root, verbose): while True: try: console.print() - user_input = Prompt.ask("[bold cyan]kaiwu[/bold cyan]").strip() + user_input = Prompt.ask("[bold cyan]kwqode[/bold cyan]").strip() except (KeyboardInterrupt, EOFError): console.print("\n [dim]bye[/dim]") break @@ -342,7 +342,7 @@ def main( do_init: bool = typer.Option(False, "--init", help="初始化KAIWU.md"), show_memory: bool = typer.Option(False, "--memory", help="查看项目记忆"), ): - """Kaiwu - 本地模型 coding agent。无参数进入交互模式。""" + """KwQode - 本地模型 coding agent。无参数进入交互模式。""" log_level = logging.DEBUG if verbose else logging.WARNING logging.basicConfig(level=log_level, format="%(name)s: %(message)s") @@ -376,7 +376,7 @@ def main( # ── Single task mode ── console.print(Panel( - f"[bold]Kaiwu v0.4[/bold] | {ollama_model} | {project_root}", + f"[bold]KwQode v0.4[/bold] | {ollama_model} | {project_root}", border_style="cyan", )) @@ -568,8 +568,8 @@ def cmd_status( f"模型: {ollama_model} Ollama: {'[green]连接正常[/green]' if ollama_ok else '[red]无法连接[/red]'} ({ollama_url})\n" f"专家: {len(builtin)} builtin + {len(custom)} custom = {len(experts)} total\n" f"项目: {project_root}\n" - f"记忆: {'[green]KAIWU.md 已初始化[/green]' if has_memory else '[yellow]未初始化 (kaiwu init)[/yellow]'}", - title="Kaiwu Status", + f"记忆: {'[green]KAIWU.md 已初始化[/green]' if has_memory else '[yellow]未初始化 (kwqode init)[/yellow]'}", + title="KwQode Status", border_style="cyan", )) diff --git a/kaiwu/mcp/router_mcp.py b/kaiwu/mcp/router_mcp.py index b1b6e0f..7cd0fd8 100644 --- a/kaiwu/mcp/router_mcp.py +++ b/kaiwu/mcp/router_mcp.py @@ -1,7 +1,7 @@ """ KaiwuMCP: Router MCP server. CORE-7: This is the ONLY external entry point. LLM does not directly see experts. -Single tool: kaiwu_execute(task_description: str) -> str +Single tool: kwqode_execute(task_description: str) -> str The `mcp` package is optional. This module is always importable, but starting the server requires `pip install mcp`. @@ -30,7 +30,7 @@ def _require_mcp(): class KaiwuMCP: - """MCP server that wraps the entire Kaiwu pipeline as a single tool.""" + """MCP server that wraps the entire KwQode pipeline as a single tool.""" def __init__(self, gate, orchestrator, memory, project_root: str): _require_mcp() @@ -38,20 +38,20 @@ class KaiwuMCP: self.orchestrator = orchestrator self.memory = memory self.project_root = project_root - self.server = Server("kaiwu") + self.server = Server("kwqode") self._setup_tools() def _setup_tools(self): - """Register the single kaiwu_execute tool.""" + """Register the single kwqode_execute tool.""" @self.server.list_tools() async def list_tools(): return [ Tool( - name="kaiwu_execute", + name="kwqode_execute", description=( - "Execute a coding task through Kaiwu's local-model expert pipeline. " - "Kaiwu automatically selects the right expert, locates relevant files, " + "Execute a coding task through KwQode's local-model expert pipeline. " + "KwQode automatically selects the right expert, locates relevant files, " "generates patches, and verifies the result." ), inputSchema={ @@ -69,7 +69,7 @@ class KaiwuMCP: @self.server.call_tool() async def call_tool(name: str, arguments: dict): - if name != "kaiwu_execute": + if name != "kwqode_execute": return [TextContent(type="text", text=f"Unknown tool: {name}")] task = arguments.get("task_description", "").strip() @@ -80,7 +80,7 @@ class KaiwuMCP: result_text = await self._execute(task) return [TextContent(type="text", text=result_text)] except Exception as e: - logger.exception("kaiwu_execute failed") + logger.exception("kwqode_execute failed") return [TextContent(type="text", text=f"Error: {e}")] async def _execute(self, task: str) -> str: diff --git a/kaiwu/memory/project_md.py b/kaiwu/memory/project_md.py index f801f88..a622bde 100644 --- a/kaiwu/memory/project_md.py +++ b/kaiwu/memory/project_md.py @@ -315,7 +315,7 @@ def show(project_root: str) -> str: """Display PROJECT.md content.""" path = _md_path(project_root) if not os.path.exists(path): - return "PROJECT.md not found. Run `kaiwu init` to create." + return "PROJECT.md not found. Run `kwqode init` to create." try: with open(path, "r", encoding="utf-8") as f: return f.read() diff --git a/pyproject.toml b/pyproject.toml index 7bcc7f9..f5982ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "kaiwu" version = "0.4.0" -description = "Local-model coding agent with MoE expert pipeline" +description = "KwQode - Local-model coding agent with MoE expert pipeline" requires-python = ">=3.10" dependencies = [ @@ -25,7 +25,7 @@ dependencies = [ ] [project.scripts] -kaiwu = "kaiwu.cli.main:app" +kwqode = "kaiwu.cli.main:app" [tool.setuptools.packages.find] where = ["."]