Skip to content
MindOfqcPublic

About

Java 21 terminal AI coding agent with tools, MCP, permissions, context management, and multi-agent workflows.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

CodePaw

用 Java 21 实现的终端 AI 编程代理,适合学习 Agent 从模型对话到工具调用、权限控制和多 Agent 协作的完整工程链路。

English · 简体中文

Java 21 Gradle

CodePaw 终端界面

CodePaw 是一个可在终端中运行的 AI Coding Agent 项目。它围绕真实的 Agent 工作循环组织代码:接收请求、调用模型、执行工具、检查结果,并在需要时请求用户确认。

命令演示

主图来自本机实际运行的 CodePaw:在输入区键入 / 后,终端会显示可选命令。演示使用本地占位模型,没有发送模型 API 请求。

执行 /help 可查看命令说明。下图为同一演示中的真实终端输出:

CodePaw help command

功能

  • 模型对话:支持 Anthropic、OpenAI 和 OpenAI 兼容协议,提供终端流式交互。
  • 本地工具:通过文件读取、编辑、写入、搜索和 Shell 工具完成代码任务。
  • 权限控制:支持默认确认、接受编辑、计划模式和显式绕过模式。
  • 扩展能力:可接入 MCP Server、Skills 与 Hooks。
  • 上下文管理:包含会话历史、上下文压缩、记忆和会话恢复。
  • 协作执行:提供 SubAgent、Worktree 与 Agent Teams 相关实现。

快速开始

环境要求

  • Java 21 或更高版本
  • 项目自带 Gradle Wrapper;无需单独安装 Gradle
  • 支持 ANSI 256 色的终端可获得完整颜色效果;设置 NO_COLOR 时会按约定禁用颜色

1. 配置模型

在项目根目录创建 .codepaw/config.yaml,填入你自己的服务配置:

providers:
  - name: compatible
    protocol: openai-compat
    base_url: https://api.example.com/v1
    api_key: replace-with-your-api-key
    model: your-model-name

协议可使用 anthropic、openai 或 openai-compat。请把真实 API Key 留在本地配置中,不要提交到 Git。

2. 构建并运行

./gradlew shadowJar
java -jar build/libs/codepaw.jar

Windows PowerShell 可运行:

./gradlew.bat shadowJar
java -jar build/libs/codepaw.jar

3. 查看命令与测试

启动后输入 /help 查看命令。运行测试:

./gradlew test

项目结构

包 职责
com.codepaw.tui 终端界面、输入处理、消息与状态渲染
com.codepaw.agent、conversation、prompt Agent 执行循环、对话状态与提示词组装
com.codepaw.llm、tool、mcp、skill 模型协议、本地工具和扩展接入
com.codepaw.permission、plan、hook 工具审批、计划模式和生命周期钩子
com.codepaw.compact、memory、session、history 上下文整理与会话数据管理
com.codepaw.subagent、task、worktree、teams 子代理、任务分配和隔离协作

更多模块关系见 架构说明。

开发

构建可执行 JAR:

./gradlew shadowJar

运行全部测试:

./gradlew test

说明

CodePaw 是一个用于学习和研究 Agent 工程实现的项目。模型服务、MCP Server 与本地工具的可用性取决于你的配置和运行环境。

About

Java 21 terminal AI coding agent with tools, MCP, permissions, context management, and multi-agent workflows.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages