# awe-code-cli **Repository Path**: wx_9488171b4b/awe-code-cli ## Basic Information - **Project Name**: awe-code-cli - **Description**: ai分析cli,,,,,,,,,,,,,,,,,,,,。 - **Primary Language**: Unknown - **License**: ISC - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-15 - **Last Updated**: 2026-06-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # awe-code-cli 本地代码智能 Agent 及 AI 模型 CLI 工具 [![License](https://img.shields.io/badge/license-ISC-blue.svg)](LICENSE) [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org/) [![pnpm](https://img.shields.io/badge/pnpm-%3E%3D8.0.0-orange)](https://pnpm.io/) [![TypeScript](https://img.shields.io/badge/typescript-5.0+-blue)](https://www.typescriptlang.org/) [![AI Providers](https://img.shields.io/badge/ai-qwen%2Copenai%2Canthropic%2Cgoogle%2Collama-purple)](#ai-相关命令) [![Plugins](https://img.shields.io/badge/plugins-git%2Cdocker%2Cai-green)](#插件系统) ## 🚀 快速链接 **新手入门** - [快速开始指南](QUICK_START.md) - 5 分钟上手 - [使用指南](USAGE_GUIDE.md) - 详细使用说明 - [示例项目](examples/) - 完整代码示例 ⭐ **核心功能** - [AI 功能文档](docs/ai-features.md) - AI 对话、代码生成、代码分析 - [Git 插件文档](docs/git-plugin.md) - Git 集成和智能提交 - [Docker 插件文档](docs/docker-plugin.md) - Docker 容器化和管理 - [代码分析文档](docs/code-analysis.md) - 代码复杂度分析和优化建议 **开发资源** - [代码模板](templates/) - AI 代码生成模板库 📋 - [插件开发指南](docs/plugin-development.md) - 创建自定义插件 - [项目改进计划](PROJECT_IMPROVEMENTS.md) - 路线图和改进建议 **外部资源** - [文档中心](docs/README.md) - 完整文档导航 - [变更日志](CHANGELOG.md) - 版本更新历史 - [贡献指南](#贡献指南) - 如何参与项目开发 --- ## 简介 awe-code-cli 是一个强大的本地代码智能 Agent CLI 工具,集成了 AI 模型、代码分析、Git 管理和 Docker 容器化等功能。采用 Monorepo 架构,支持插件化扩展,适用于各种规模的开发项目。 ### ✨ 核心特性 - **🤖 AI 智能助手**: 支持 Qwen(通义千问)、OpenAI GPT、Anthropic Claude、Google Gemini、Ollama 等多种 AI 模型 - **📊 代码生成与分析**: 自动生成代码、分析代码结构、计算复杂度、提供优化建议 - **🔧 Git 集成**: 版本控制管理、AI 生成提交消息、分支操作、Conventional Commits 支持 - **🐳 Docker 支持**: 镜像构建、容器管理、Compose 编排、多服务部署 - **🔌 插件系统**: 可扩展的插件架构,轻松添加新功能 - **💻 TypeScript 支持**: 完整的类型定义和严格的类型检查 - **⚡ 高性能**: 基于 Turborepo 的增量构建和缓存机制 ### 🎯 适用场景 - **快速原型开发**: 使用 AI 生成 boilerplate 代码和项目结构 - **代码审查**: 自动分析代码复杂度和潜在问题 - **智能提交**: AI 自动生成符合 Conventional Commits 规范的提交消息 - **容器化部署**: 一键生成 Dockerfile 和 docker-compose.yml - **团队协作**: 统一的代码规范和自动化工作流 ## 项目结构 ``` awe-code-cli/ ├── packages/ │ ├── cli/ # 主 CLI 入口包 (awe-code-cli) │ │ ├── src/ │ │ │ ├── commands/ # CLI 命令实现 │ │ │ └── index.ts # 入口文件 │ │ ├── package.json │ │ └── tsconfig.json │ ├── core/ # 核心引擎 (@awe-code/core) │ │ ├── src/ │ │ │ ├── ai-model.ts # AI 模型管理器 │ │ │ ├── code-analyzer.ts # 代码分析器 │ │ │ ├── config.ts # 配置管理 │ │ │ ├── errors.ts # 错误处理 │ │ │ ├── logger.ts # 日志输出 │ │ │ ├── plugin-manager.ts # 插件管理器 │ │ │ └── index.ts │ │ ├── package.json │ │ └── tsconfig.json │ ├── plugins/ # 插件系统 │ │ ├── plugin-ai/ # AI 模型插件 (@awe-code/plugin-ai) │ │ ├── plugin-git/ # Git 集成插件 (@awe-code/plugin-git) │ │ └── plugin-docker/ # Docker 集成插件 (@awe-code/plugin-docker) │ └── shared/ # 共享库 │ ├── types/ # TypeScript 类型定义 (@awe-code/shared-types) │ └── utils/ # 通用工具函数 (@awe-code/shared-utils) ├── examples/ # 使用示例 ├── docs/ # 详细文档 ├── templates/ # 代码生成模板 ├── .changeset/ # Changesets 版本管理 ├── turbo.json # Turborepo 配置 ├── pnpm-workspace.yaml # pnpm workspace 配置 ├── package.json # 根配置 └── README.md ``` ## 快速开始 ### 环境要求 - Node.js >= 18.0.0 - pnpm >= 8.0.0 - Git(可选,用于 Git 功能) - Docker(可选,用于 Docker 功能) ### 安装依赖 ```bash pnpm install ``` ### 构建项目 ```bash pnpm build ``` ### 开发模式 ```bash pnpm dev ``` ### 运行测试 ```bash pnpm test ``` ### 清理构建产物 ```bash pnpm clean ``` ### 全局安装 CLI ```bash cd packages/cli npm link ``` 现在可以在任何地方使用 `awe-code` 命令! ## CLI 命令 ### 基础命令 ```bash # 查看版本 awe-code -v # 查看帮助 awe-code --help # 打招呼测试 awe-code greet -n "Your Name" # 开启调试模式 awe-code -d greet ``` ### AI 相关命令 ```bash # 配置 AI 模型(支持 qwen, openai, anthropic, google, ollama) awe-code ai:config -p qwen -m qwen-plus -k "your-api-key" # 与 AI 对话 awe-code ai:chat -m "如何优化这个函数?" # 生成代码(支持 typescript, javascript, python, react 等) awe-code ai:generate -p "创建一个防抖函数" -l typescript -o src/utils/debounce.ts # 分析代码文件和目录 awe-code ai:analyze -f src/main.ts # 询问代码问题 awe-code ai:ask -q "这个函数有什么潜在问题?" -f src/utils.ts ``` **支持的 AI 提供商:** | 提供商 | 模型示例 | 说明 | |--------|---------|------| | Qwen | qwen-plus, qwen-max | 阿里云通义千问,中文理解优秀 | | OpenAI | gpt-4, gpt-3.5-turbo | OpenAI GPT 系列 | | Anthropic | claude-3-opus, claude-3-sonnet | Claude 大语言模型 | | Google | gemini-pro | Google Gemini 模型 | | Ollama | llama2, mistral | 本地部署的开源模型 | 更多 AI 命令详见 [plugin-ai README](packages/plugins/plugin-ai/README.md) ### Git 相关命令 ```bash # 查看 Git 状态 awe-code git:status # 查看提交历史 awe-code git:log -n 10 # 查看差异 awe-code git:diff # 智能提交(AI 生成符合 Conventional Commits 的消息) awe-code git:commit --ai -a # 分支管理 awe-code git:branch -c feature/new-feature ``` 更多 Git 命令详见 [plugin-git README](packages/plugins/plugin-git/README.md) ### Docker 相关命令 ```bash # 构建镜像 awe-code docker:build -t my-app:latest # 运行容器 awe-code docker:run -p 3000:3000 my-app:latest # 查看日志 awe-code docker:logs -c my-app -f # Docker Compose awe-code docker:compose --up # 清理资源 awe-code docker:clean --all ``` 更多 Docker 命令详见 [plugin-docker README](packages/plugins/plugin-docker/README.md) ## 插件系统 ### 注册插件 ```typescript import { pluginManager } from '@awe-code/core'; import { gitPlugin } from '@awe-code/plugin-git'; import { dockerPlugin } from '@awe-code/plugin-docker'; import { aiPlugin } from '@awe-code/plugin-ai'; // 注册单个插件 await pluginManager.register(gitPlugin); // 注册多个插件 await Promise.all([ pluginManager.register(dockerPlugin), pluginManager.register(aiPlugin), ]); ``` ### 创建自定义插件 ```typescript import { Plugin, Command } from '@awe-code/shared-types'; import { Logger } from '@awe-code/core'; class MyPlugin implements Plugin { name = 'my-plugin'; version = '1.0.0'; description = 'My custom plugin'; commands: Command[] = []; async initialize(): Promise { Logger.debug('Initializing my plugin...'); } } export const myPlugin = new MyPlugin(); ``` 更多详情查看 [插件开发指南](docs/plugin-development.md) ## 核心模块 ### AIModelManager AI 模型管理器,支持多提供商切换: ```typescript import { aiModelManager } from '@awe-code/core'; // 配置模型 aiModelManager.setConfig({ provider: 'openai', model: 'gpt-4', apiKey: 'sk-...', }); // 聊天 const response = await aiModelManager.chat([ { role: 'user', content: 'Hello!' } ]); // 生成代码 const code = await aiModelManager.generateCode('Create a debounce function', { language: 'typescript', }); ``` ### CodeAnalyzer 代码分析器,支持多种语言: ```typescript import { codeAnalyzer } from '@awe-code/core'; // 分析文件 const result = await codeAnalyzer.analyzeFile('src/main.ts'); console.log(result.complexity); console.log(result.functions); // 分析目录 const results = await codeAnalyzer.analyzeDirectory('src/'); ``` ### Logger 日志输出工具: ```typescript import { Logger } from '@awe-code/core'; Logger.info('Information message'); Logger.success('Success message'); Logger.error('Error message'); Logger.warn('Warning message'); Logger.debug('Debug message (only in debug mode)'); // 带 spinner 的异步操作 const result = await Logger.withSpinner('Processing...', async () => { // 异步操作 }); ``` ## 配置 ### 配置文件 在项目根目录创建 `.awecoderc` 文件: ```json { "outputDir": "./dist", "verbose": false, "debug": false, "aiModel": { "provider": "openai", "model": "gpt-4", "apiKey": "sk-...", "temperature": 0.7, "maxTokens": 4096 }, "plugins": ["git", "docker", "ai"] } ``` ### 环境变量 ```bash # 调试模式 export DEBUG=true # AI API Keys export OPENAI_API_KEY="sk-..." export ANTHROPIC_API_KEY="sk-ant-..." export GOOGLE_API_KEY="AIza..." ``` ## 开发指南 ### 添加新命令 1. 在 `packages/cli/src/commands/` 创建新命令文件 2. 在 `packages/cli/src/index.ts` 中注册命令 3. 更新相关文档 ### 添加新插件 1. 在 `packages/plugins/` 创建新插件目录 2. 实现 `Plugin` 接口 3. 在 `package.json` 中添加依赖 4. 编写 README 文档 ### 发布流程 ```bash # 创建变更集 pnpm changeset # 更新版本号 pnpm version-packages # 构建并发布 pnpm release ``` ## 插件文档 - [🤖 AI 插件文档](packages/plugins/plugin-ai/README.md) - AI 模型集成、代码生成、智能对话 - [🔧 Git 插件文档](packages/plugins/plugin-git/README.md) - Git 版本控制、智能提交 - [🐳 Docker 插件文档](packages/plugins/plugin-docker/README.md) - Docker 容器化、镜像管理 - [📊 代码分析文档](docs/code-analysis.md) - 代码复杂度分析、优化建议 - [🔌 插件开发指南](docs/plugin-development.md) - 创建自定义插件 ## 示例和模板 - **[示例项目](examples/)** ⭐ - 完整的使用示例,从基础到高级 - [基础用法](examples/basic-usage/) - Hello World 和配置管理 - [AI 集成](examples/ai-integration/) - 对话、生成、分析 - [插件演示](examples/plugin-demo/) - Git 和 Docker 集成 - [完整项目](examples/full-demo/) - 完整开发工作流 - **[代码模板](templates/)** 📋 - AI 代码生成模板库 - TypeScript: function, class, interface, enum, react-component, test - JavaScript: function, class, async-function, factory-pattern, middleware - Python: function, class - Docker: Dockerfile, docker-compose.yml - SQL: migration ## 贡献指南 1. Fork 本项目 2. 创建特性分支 (`git checkout -b feature/amazing-feature`) 3. 提交变更 (`git commit -m 'feat: add amazing feature'`) 4. 推送到分支 (`git push origin feature/amazing-feature`) 5. 创建 Pull Request ### 开发流程 ```bash # 1. 克隆项目 git clone https://github.com/your-org/awe-code-cli.git cd awe-code-cli # 2. 安装依赖 pnpm install # 3. 构建项目 pnpm build # 4. 运行测试 pnpm test # 5. 创建变更集(用于版本管理) pnpm changeset # 6. 提交代码 git add . git commit -m "feat: add new feature" git push ``` 更多详情查看 [贡献指南](CONTRIBUTING.md) ## 贡献指南 1. Fork 本项目 2. 创建特性分支 (`git checkout -b feature/amazing-feature`) 3. 提交变更 (`git commit -m 'feat: add amazing feature'`) 4. 推送到分支 (`git push origin feature/amazing-feature`) 5. 创建 Pull Request ## 许可证 ISC © 2026 awe-code-cli Team ## 致谢 - [Commander](https://github.com/tj/commander.js) - CLI 框架 - [Turborepo](https://turbo.build/repo) - Monorepo 构建工具 - [pnpm](https://pnpm.io/) - 包管理器 - [Zod](https://zod.dev/) - TypeScript 优先的模式验证 - [Chalk](https://github.com/chalk/chalk) - 终端字符串样式 - [Ora](https://github.com/sindresorhus/ora) - 终端 spinner - [Axios](https://axios-http.com/) - HTTP 客户端 --- **📝 文档改进**: 发现文档问题或有改进建议?欢迎提交 [Issue](https://github.com/your-org/awe-code-cli/issues) 或 [Pull Request](https://github.com/your-org/awe-code-cli/pulls)! **💬 社区支持**: 加入我们的 [Discord](https://discord.gg/awe-code) 或 [论坛](https://forum.qoder.com/) 与其他开发者交流!