byoe 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. byoe-0.2.0/PKG-INFO +380 -0
  2. byoe-0.2.0/README.md +348 -0
  3. byoe-0.2.0/byoe/__init__.py +13 -0
  4. byoe-0.2.0/byoe/__main__.py +4 -0
  5. byoe-0.2.0/byoe/chat.py +223 -0
  6. byoe-0.2.0/byoe/cli.py +352 -0
  7. byoe-0.2.0/byoe/engine/__init__.py +12 -0
  8. byoe-0.2.0/byoe/engine/agent.py +174 -0
  9. byoe-0.2.0/byoe/engine/config.py +56 -0
  10. byoe-0.2.0/byoe/engine/context.py +202 -0
  11. byoe-0.2.0/byoe/engine/llm.py +236 -0
  12. byoe-0.2.0/byoe/engine/prompt.py +113 -0
  13. byoe-0.2.0/byoe/engine/session.py +77 -0
  14. byoe-0.2.0/byoe/engine/tools/__init__.py +40 -0
  15. byoe-0.2.0/byoe/engine/tools/agent.py +44 -0
  16. byoe-0.2.0/byoe/engine/tools/base.py +23 -0
  17. byoe-0.2.0/byoe/engine/tools/bash.py +141 -0
  18. byoe-0.2.0/byoe/engine/tools/edit.py +80 -0
  19. byoe-0.2.0/byoe/engine/tools/glob_tool.py +48 -0
  20. byoe-0.2.0/byoe/engine/tools/grep.py +63 -0
  21. byoe-0.2.0/byoe/engine/tools/read.py +44 -0
  22. byoe-0.2.0/byoe/engine/tools/write.py +38 -0
  23. byoe-0.2.0/byoe/orchestrator/__init__.py +1 -0
  24. byoe-0.2.0/byoe/orchestrator/commands/__init__.py +1 -0
  25. byoe-0.2.0/byoe/orchestrator/commands/agents.py +127 -0
  26. byoe-0.2.0/byoe/orchestrator/commands/init.py +204 -0
  27. byoe-0.2.0/byoe/orchestrator/commands/plan.py +137 -0
  28. byoe-0.2.0/byoe/orchestrator/commands/release.py +90 -0
  29. byoe-0.2.0/byoe/orchestrator/commands/run.py +224 -0
  30. byoe-0.2.0/byoe/orchestrator/commands/status.py +161 -0
  31. byoe-0.2.0/byoe/orchestrator/utils.py +65 -0
  32. byoe-0.2.0/byoe/web.py +1014 -0
  33. byoe-0.2.0/byoe.egg-info/PKG-INFO +380 -0
  34. byoe-0.2.0/byoe.egg-info/SOURCES.txt +41 -0
  35. byoe-0.2.0/byoe.egg-info/dependency_links.txt +1 -0
  36. byoe-0.2.0/byoe.egg-info/entry_points.txt +2 -0
  37. byoe-0.2.0/byoe.egg-info/requires.txt +9 -0
  38. byoe-0.2.0/byoe.egg-info/top_level.txt +1 -0
  39. byoe-0.2.0/pyproject.toml +55 -0
  40. byoe-0.2.0/setup.cfg +4 -0
  41. byoe-0.2.0/tests/test_orchestrator.py +184 -0
  42. byoe-0.2.0/tests/test_prompt.py +152 -0
  43. byoe-0.2.0/tests/test_tools.py +271 -0
byoe-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,380 @@
1
+ Metadata-Version: 2.4
2
+ Name: byoe
3
+ Version: 0.2.0
4
+ Summary: 卜一智航 — 携智而来,决策随行。AI 开发团队编排 + 内置多模型编程 Agent 一体化工具
5
+ Author-email: 卜一智元 <hi@byoe.net>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://byoe.net
8
+ Project-URL: Repository, https://github.com/byoe/byoe
9
+ Project-URL: Bug Tracker, https://github.com/byoe/byoe/issues
10
+ Project-URL: Changelog, https://github.com/byoe/byoe/blob/main/CHANGELOG.md
11
+ Keywords: ai,agent,orchestration,coding,llm,cli,dev-team,byoe
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Environment :: Console
22
+ Classifier: Operating System :: OS Independent
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ Requires-Dist: openai>=1.0
26
+ Requires-Dist: rich>=13.0
27
+ Requires-Dist: prompt_toolkit>=3.0
28
+ Requires-Dist: python-dotenv>=1.0
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=7.0; extra == "dev"
31
+ Provides-Extra: web
32
+
33
+ # 卜一智航 · BYOE
34
+
35
+ > **携智而来,决策随行** — Bring Your Own Executive AI
36
+
37
+ **卜一智航**(BYOE)是[卜一智元](https://byoe.net)出品的 AI 开发团队编排工具,秉承「自建引擎(Build Your Own Engine)」理念,让每位开发者都能拥有一支随时待命的 AI 研发团队。
38
+
39
+ BYOE 将两个工具合二为一:
40
+
41
+ - **Orchestrator**(Crew 编排层):项目工作流管理 — 初始化、变更计划、进度跟踪、归档
42
+ - **Engine**(AI Agent 执行层):内置轻量 AI 编程 Agent,支持任意 OpenAI 兼容模型
43
+
44
+ **深度集成核心**:在 BYOE 管理的项目目录下运行 `byoe chat` 时,`INSTRUCTIONS.md`、`crew.yaml`、`crew/resume.md` 会被**自动注入**到 Agent 的 system prompt,无需手动粘贴上下文。
45
+
46
+ 🌐 **官网**: [byoe.net](https://byoe.net) | 📦 `pip install byoe`
47
+
48
+ ---
49
+
50
+ ## 安装
51
+
52
+ ```bash
53
+ pip install byoe
54
+ ```
55
+
56
+ 或从源码安装(开发模式):
57
+
58
+ ```bash
59
+ cd byoe
60
+ pip install -e .
61
+ ```
62
+
63
+ **要求:** Python ≥ 3.10
64
+
65
+ ---
66
+
67
+ ## 快速开始
68
+
69
+ ### 1. 初始化项目
70
+
71
+ ```bash
72
+ cd my-project
73
+ byoe init
74
+ ```
75
+
76
+ 生成:`INSTRUCTIONS.md`、`crew.yaml`、`crew/resume.md`、`crew/specs/`
77
+
78
+ ### 2. 配置 API Key
79
+
80
+ ```bash
81
+ # OpenAI
82
+ export OPENAI_API_KEY=sk-...
83
+
84
+ # DeepSeek
85
+ export OPENAI_API_KEY=sk-...
86
+ export OPENAI_BASE_URL=https://api.deepseek.com
87
+ export BYOE_MODEL=deepseek-chat
88
+
89
+ # Qwen(通义千问)
90
+ export OPENAI_API_KEY=sk-...
91
+ export OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
92
+ export BYOE_MODEL=qwen3-max
93
+
94
+ # Ollama(本地)
95
+ export OPENAI_API_KEY=ollama
96
+ export OPENAI_BASE_URL=http://localhost:11434/v1
97
+ export BYOE_MODEL=qwen2.5-coder:32b
98
+ ```
99
+
100
+ Windows PowerShell:将 `export` 替换为 `$env:`,例如:
101
+
102
+ ```powershell
103
+ $env:OPENAI_API_KEY = "sk-..."
104
+ $env:BYOE_MODEL = "deepseek-chat"
105
+ ```
106
+
107
+ ### 3. 启动内置 Agent
108
+
109
+ ```bash
110
+ byoe chat
111
+ # 或等价命令
112
+ byoe run
113
+ ```
114
+
115
+ Agent 启动时自动检测并注入项目上下文,欢迎界面显示 `✓ Crew 项目上下文已自动注入`。
116
+
117
+ ### 4. 创建变更计划并执行
118
+
119
+ ```bash
120
+ byoe plan user-auth # 创建标准变更计划
121
+ byoe plan fix-login-bug # 自动推断为 express 模式(含 fix 关键词)
122
+ byoe chat # 启动 Agent,描述需求开始工作
123
+ ```
124
+
125
+ ### 5. 外部工具(可选)
126
+
127
+ ```bash
128
+ byoe run claude # 启动 Claude Code,自动写入 .claude/CLAUDE.md
129
+ byoe run opencode # 启动 OpenCode,自动写入 .opencode/instructions.md
130
+ byoe run aider # 启动 Aider,通过 --system-prompt 注入
131
+ byoe run cursor # 打开 Cursor,自动写入 .cursorrules
132
+ ```
133
+
134
+ ---
135
+
136
+ ## 命令参考
137
+
138
+ ### 编排命令
139
+
140
+ | 命令 | 说明 |
141
+ |------|------|
142
+ | `byoe init` | 初始化 Crew 工作区 |
143
+ | `byoe init --scan` | 初始化 + 扫描代码库建立基线(生成 `crew/codebase.md`) |
144
+ | `byoe init --prd <file>` | 导入已有需求文档 |
145
+ | `byoe plan <name>` | 创建变更计划(standard 模式) |
146
+ | `byoe plan <name> --express` | 快速模式(Bug 修复,P→E→V 流程) |
147
+ | `byoe plan <name> --prototype` | 原型模式(P→D→E,无 Verify) |
148
+ | `byoe status` | 查看所有活跃变更状态 |
149
+ | `byoe release` | 归档已完成变更 |
150
+ | `byoe agents` | 列出所有领域专家 |
151
+ | `byoe agents -c <category>` | 按分类过滤(engineering / game / design / …) |
152
+ | `byoe agents --show <id>` | 查看专家完整详情(支持部分名称匹配) |
153
+
154
+ ### Agent 命令
155
+
156
+ | 命令 | 说明 |
157
+ |------|------|
158
+ | `byoe chat` | 启动内置 Agent 交互式 REPL |
159
+ | `byoe chat -m <model>` | 指定模型(覆盖 `BYOE_MODEL`) |
160
+ | `byoe chat -p "..."` | 单次提示模式,执行后退出 |
161
+ | `byoe chat -r <session-id>` | 恢复已保存的会话 |
162
+ | `byoe run [tool]` | 同 chat,或启动外部工具 |
163
+
164
+ ### 会话管理
165
+
166
+ | 命令 | 说明 |
167
+ |------|------|
168
+ | `byoe sessions` | 列出最近保存的会话 |
169
+ | `byoe sessions list` | 同上 |
170
+ | `byoe sessions show <id>` | 查看会话详情(消息历史 + 修改文件) |
171
+ | `byoe sessions delete <id>` | 删除会话 |
172
+
173
+ ### Chat REPL 内置命令
174
+
175
+ 在 `byoe chat` 交互界面中:
176
+
177
+ | 命令 | 说明 |
178
+ |------|------|
179
+ | `/help` | 显示帮助 |
180
+ | `/reset` | 清空对话历史(重新加载项目上下文) |
181
+ | `/model <name>` | 运行时切换模型 |
182
+ | `/tokens` | 查看 Token 用量及费用估算 |
183
+ | `/compact` | 手动触发上下文压缩 |
184
+ | `/diff` | 查看本次会话修改的文件列表 |
185
+ | `/save` | 保存会话到磁盘(显示 session ID) |
186
+ | `/sessions` | 列出所有已保存会话 |
187
+ | `quit` / `Ctrl+D` | 退出 |
188
+
189
+ ---
190
+
191
+ ## 支持的模型
192
+
193
+ 所有实现 OpenAI Chat Completions API 的服务均可使用:
194
+
195
+ | 提供商 | `BYOE_MODEL` 示例 |
196
+ |--------|------------------|
197
+ | OpenAI | `gpt-4o`、`gpt-4o-mini` |
198
+ | DeepSeek | `deepseek-chat`、`deepseek-reasoner` |
199
+ | Qwen(通义千问) | `qwen3-max`、`qwen3-plus` |
200
+ | Kimi | `kimi-k2.5`、`moonshot-v1-128k` |
201
+ | Claude(via OpenRouter) | `anthropic/claude-sonnet-4-5` |
202
+ | Ollama(本地) | `qwen2.5-coder:32b`、`llama3.3` |
203
+
204
+ ---
205
+
206
+ ## 微信远程控制(byoe + wechatbot)
207
+
208
+ 通过 [wechatbot](../wechatbot/README.md) 可以从微信直接指挥 AI 开发团队:
209
+
210
+ ```
211
+ 手机微信 ──消息──▶ wechatbot ──▶ byoe_bridge ──▶ byoe Agent
212
+ ├── 编排层(plan/status/release)
213
+ └── 执行层(bash/edit/read…)
214
+ ```
215
+
216
+ ### 快速启动
217
+
218
+ ```bash
219
+ # 安装两者
220
+ pip install -e /path/to/byoe
221
+ pip install -r /path/to/wechatbot/requirements.txt
222
+
223
+ # 配置 LLM
224
+ export OPENAI_API_KEY=sk-...
225
+ export BYOE_MODEL=deepseek-chat
226
+
227
+ # 启动并激活 byoe 接管
228
+ cd /your/project
229
+ BYOE_WECHAT=1 python /path/to/wechatbot/main.py
230
+ ```
231
+
232
+ ### 工作流示例
233
+
234
+ ```
235
+ 你(微信): /cd /home/user/myproject
236
+ Bot: Working directory set to: /home/user/myproject
237
+
238
+ 你: /init
239
+ Bot: ✅ Crew 工作区已初始化
240
+ 生成文件: INSTRUCTIONS.md, crew.yaml, ...
241
+
242
+ 你: /plan user-auth
243
+ Bot: ✅ 创建变更计划: user-auth
244
+ 模式: standard
245
+
246
+ 你: 帮我实现 JWT 登录,包括注册、登录、token 刷新接口
247
+ Bot: ⚙️ [bash] find . -name "*.py" | head -20
248
+ 📖 [read_file] src/app.py
249
+ ✏️ [edit_file] src/auth.py
250
+ ...(实时工具进度)
251
+ 已完成 JWT 认证模块,修改了 3 个文件:
252
+ - src/auth.py(新建)
253
+ - src/routes.py(新增 3 个路由)
254
+ - requirements.txt(新增 PyJWT)
255
+
256
+ 你: /diff
257
+ Bot: Files changed this session:
258
+ src/auth.py
259
+ src/routes.py
260
+ requirements.txt
261
+
262
+ 你: /status
263
+ Bot: 活跃变更:
264
+ ● user-auth [standard] 进行中
265
+ ```
266
+
267
+ 详细说明见 [wechatbot/README.md](../wechatbot/README.md)。
268
+
269
+ ---
270
+
271
+ ## 上下文压缩
272
+
273
+ Agent 自动管理上下文,三级压缩策略:
274
+
275
+ | 触发阈值 | 策略 | 提示 |
276
+ |---------|------|------|
277
+ | 50% 上限 | Snip:截断工具输出 | `⚡ 工具输出已裁剪` |
278
+ | 70% 上限 | Summarize:AI 摘要压缩历史 | `⚡ 上下文已摘要压缩` |
279
+ | 90% 上限 | Collapse:硬重置,保留最近消息 | `⚡ 上下文已硬重置` |
280
+
281
+ ---
282
+
283
+ ## 会话持久化
284
+
285
+ 会话保存在 `~/.byoe/sessions/`,内容包括:
286
+ - 完整对话历史
287
+ - 使用的模型名称
288
+ - 本次会话修改的文件列表
289
+
290
+ ```bash
291
+ byoe chat # 正常使用
292
+ # 在 chat 中输入 /save → 显示 session ID
293
+
294
+ byoe chat -r <session-id> # 下次恢复
295
+ ```
296
+
297
+ ---
298
+
299
+ ## 自定义定价
300
+
301
+ `~/.byoe/pricing.json` 可覆盖内置的 token 定价(每百万 token,美元):
302
+
303
+ ```json
304
+ {
305
+ "my-private-model": [1.0, 2.0],
306
+ "gpt-4o": [2.5, 10.0]
307
+ }
308
+ ```
309
+
310
+ 格式:`"model-name": [input_price, output_price]`
311
+
312
+ ---
313
+
314
+ ## 项目结构
315
+
316
+ ```
317
+ byoe/
318
+ ├── byoe/
319
+ │ ├── cli.py 统一 CLI 入口(argparse)
320
+ │ ├── chat.py 交互式 REPL(prompt_toolkit)
321
+ │ ├── engine/ AI Agent 执行层
322
+ │ │ ├── agent.py 核心 Agent 循环(tool loop + 并行执行)
323
+ │ │ ├── llm.py OpenAI 兼容多模型层(流式 + 计费)
324
+ │ │ ├── config.py 环境变量配置
325
+ │ │ ├── prompt.py System prompt + Crew 上下文注入
326
+ │ │ ├── context.py 三层上下文压缩管理
327
+ │ │ ├── session.py 会话持久化(messages + model + changed_files)
328
+ │ │ └── tools/
329
+ │ │ ├── base.py Tool 基类
330
+ │ │ ├── bash.py Shell 命令执行(跨平台 + 危险命令检测)
331
+ │ │ ├── read.py 文件读取(带截断)
332
+ │ │ ├── edit.py 文件编辑(字符串替换)
333
+ │ │ ├── write.py 文件写入
334
+ │ │ ├── glob.py 文件路径匹配
335
+ │ │ ├── grep.py 内容搜索
336
+ │ │ └── agent.py 子 Agent 调用
337
+ │ └── orchestrator/ Crew 编排层
338
+ │ ├── utils.py 颜色输出、名称转换等工具
339
+ │ └── commands/
340
+ │ ├── init.py byoe init
341
+ │ ├── plan.py byoe plan
342
+ │ ├── status.py byoe status
343
+ │ ├── release.py byoe release
344
+ │ ├── agents.py byoe agents
345
+ │ └── run.py byoe run
346
+ ├── agents/ 领域专家 Markdown 定义(30+ 个)
347
+ ├── templates/
348
+ │ └── INSTRUCTIONS.md 项目初始化模板
349
+ └── tests/
350
+ ├── test_tools.py 工具层测试(30 项)
351
+ ├── test_orchestrator.py 编排层测试(26 项)
352
+ └── test_prompt.py Prompt 层测试(17 项)
353
+ ```
354
+
355
+ ---
356
+
357
+ ## 测试
358
+
359
+ ```bash
360
+ cd byoe
361
+ pytest tests/ -v
362
+ ```
363
+
364
+ 74 项测试,2 项在 Windows 上跳过(Unix 特定危险命令模式)。
365
+
366
+ ---
367
+
368
+ ## License
369
+
370
+ MIT
371
+
372
+ ---
373
+
374
+ <div align="center">
375
+
376
+ **卜一智航 · BYOE** — 携智而来,决策随行
377
+
378
+ [卜一智元](https://byoe.net) © 2026 | Build Your Own Engine
379
+
380
+ </div>