bareagent-cli 0.1.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.
- bareagent_cli-0.1.0/.gitignore +36 -0
- bareagent_cli-0.1.0/LICENSE +21 -0
- bareagent_cli-0.1.0/PKG-INFO +331 -0
- bareagent_cli-0.1.0/README.md +284 -0
- bareagent_cli-0.1.0/pyproject.toml +100 -0
- bareagent_cli-0.1.0/src/bareagent/__init__.py +10 -0
- bareagent_cli-0.1.0/src/bareagent/concurrency/__init__.py +6 -0
- bareagent_cli-0.1.0/src/bareagent/concurrency/background.py +97 -0
- bareagent_cli-0.1.0/src/bareagent/concurrency/notification.py +61 -0
- bareagent_cli-0.1.0/src/bareagent/concurrency/scheduler.py +136 -0
- bareagent_cli-0.1.0/src/bareagent/config.toml +299 -0
- bareagent_cli-0.1.0/src/bareagent/core/__init__.py +1 -0
- bareagent_cli-0.1.0/src/bareagent/core/config_paths.py +49 -0
- bareagent_cli-0.1.0/src/bareagent/core/context.py +127 -0
- bareagent_cli-0.1.0/src/bareagent/core/fileutil.py +103 -0
- bareagent_cli-0.1.0/src/bareagent/core/goal.py +214 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/__init__.py +1 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/bash.py +79 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/file_edit.py +47 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/file_read.py +270 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/file_write.py +34 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/glob_search.py +30 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/goal.py +60 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/grep_search.py +52 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/memory.py +71 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/plan.py +106 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/search_utils.py +77 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/skill.py +87 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/subagent_send.py +70 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/web_fetch.py +126 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/web_search.py +165 -0
- bareagent_cli-0.1.0/src/bareagent/core/handlers/workflow.py +190 -0
- bareagent_cli-0.1.0/src/bareagent/core/loop.py +535 -0
- bareagent_cli-0.1.0/src/bareagent/core/retry.py +131 -0
- bareagent_cli-0.1.0/src/bareagent/core/sandbox.py +27 -0
- bareagent_cli-0.1.0/src/bareagent/core/schema.py +21 -0
- bareagent_cli-0.1.0/src/bareagent/core/tools.py +779 -0
- bareagent_cli-0.1.0/src/bareagent/core/workflow.py +517 -0
- bareagent_cli-0.1.0/src/bareagent/core/workflow_registry.py +219 -0
- bareagent_cli-0.1.0/src/bareagent/debug/__init__.py +0 -0
- bareagent_cli-0.1.0/src/bareagent/debug/interaction_log.py +263 -0
- bareagent_cli-0.1.0/src/bareagent/debug/viewer.html +1750 -0
- bareagent_cli-0.1.0/src/bareagent/debug/web_viewer.py +157 -0
- bareagent_cli-0.1.0/src/bareagent/hooks/__init__.py +32 -0
- bareagent_cli-0.1.0/src/bareagent/hooks/config.py +118 -0
- bareagent_cli-0.1.0/src/bareagent/hooks/engine.py +197 -0
- bareagent_cli-0.1.0/src/bareagent/hooks/errors.py +14 -0
- bareagent_cli-0.1.0/src/bareagent/hooks/events.py +22 -0
- bareagent_cli-0.1.0/src/bareagent/lsp/__init__.py +63 -0
- bareagent_cli-0.1.0/src/bareagent/lsp/config.py +134 -0
- bareagent_cli-0.1.0/src/bareagent/lsp/coord.py +118 -0
- bareagent_cli-0.1.0/src/bareagent/lsp/diagnostics.py +240 -0
- bareagent_cli-0.1.0/src/bareagent/lsp/errors.py +24 -0
- bareagent_cli-0.1.0/src/bareagent/lsp/manager.py +866 -0
- bareagent_cli-0.1.0/src/bareagent/lsp/tools.py +629 -0
- bareagent_cli-0.1.0/src/bareagent/lsp/workspace_edit.py +305 -0
- bareagent_cli-0.1.0/src/bareagent/main.py +4205 -0
- bareagent_cli-0.1.0/src/bareagent/mcp/__init__.py +69 -0
- bareagent_cli-0.1.0/src/bareagent/mcp/_sse.py +69 -0
- bareagent_cli-0.1.0/src/bareagent/mcp/client.py +341 -0
- bareagent_cli-0.1.0/src/bareagent/mcp/config.py +169 -0
- bareagent_cli-0.1.0/src/bareagent/mcp/errors.py +32 -0
- bareagent_cli-0.1.0/src/bareagent/mcp/manager.py +318 -0
- bareagent_cli-0.1.0/src/bareagent/mcp/protocol.py +187 -0
- bareagent_cli-0.1.0/src/bareagent/mcp/registry.py +557 -0
- bareagent_cli-0.1.0/src/bareagent/mcp/transport/__init__.py +15 -0
- bareagent_cli-0.1.0/src/bareagent/mcp/transport/base.py +149 -0
- bareagent_cli-0.1.0/src/bareagent/mcp/transport/http_legacy.py +192 -0
- bareagent_cli-0.1.0/src/bareagent/mcp/transport/http_streamable.py +217 -0
- bareagent_cli-0.1.0/src/bareagent/mcp/transport/stdio.py +202 -0
- bareagent_cli-0.1.0/src/bareagent/memory/__init__.py +1 -0
- bareagent_cli-0.1.0/src/bareagent/memory/compact.py +203 -0
- bareagent_cli-0.1.0/src/bareagent/memory/conversation_io.py +226 -0
- bareagent_cli-0.1.0/src/bareagent/memory/embedding.py +194 -0
- bareagent_cli-0.1.0/src/bareagent/memory/persistent.py +515 -0
- bareagent_cli-0.1.0/src/bareagent/memory/token_counter.py +67 -0
- bareagent_cli-0.1.0/src/bareagent/memory/token_tracker.py +262 -0
- bareagent_cli-0.1.0/src/bareagent/memory/transcript.py +100 -0
- bareagent_cli-0.1.0/src/bareagent/permission/__init__.py +1 -0
- bareagent_cli-0.1.0/src/bareagent/permission/guard.py +329 -0
- bareagent_cli-0.1.0/src/bareagent/permission/rules.py +19 -0
- bareagent_cli-0.1.0/src/bareagent/planning/__init__.py +19 -0
- bareagent_cli-0.1.0/src/bareagent/planning/agent_types.py +169 -0
- bareagent_cli-0.1.0/src/bareagent/planning/skill_gen.py +141 -0
- bareagent_cli-0.1.0/src/bareagent/planning/skill_store.py +173 -0
- bareagent_cli-0.1.0/src/bareagent/planning/skills.py +146 -0
- bareagent_cli-0.1.0/src/bareagent/planning/subagent.py +355 -0
- bareagent_cli-0.1.0/src/bareagent/planning/subagent_registry.py +77 -0
- bareagent_cli-0.1.0/src/bareagent/planning/tasks.py +348 -0
- bareagent_cli-0.1.0/src/bareagent/planning/todo.py +153 -0
- bareagent_cli-0.1.0/src/bareagent/planning/worktree.py +122 -0
- bareagent_cli-0.1.0/src/bareagent/provider/__init__.py +1 -0
- bareagent_cli-0.1.0/src/bareagent/provider/anthropic.py +348 -0
- bareagent_cli-0.1.0/src/bareagent/provider/base.py +136 -0
- bareagent_cli-0.1.0/src/bareagent/provider/factory.py +130 -0
- bareagent_cli-0.1.0/src/bareagent/provider/openai.py +881 -0
- bareagent_cli-0.1.0/src/bareagent/provider/presets.py +72 -0
- bareagent_cli-0.1.0/src/bareagent/provider/setup.py +356 -0
- bareagent_cli-0.1.0/src/bareagent/skills/.gitkeep +1 -0
- bareagent_cli-0.1.0/src/bareagent/skills/code-review/SKILL.md +68 -0
- bareagent_cli-0.1.0/src/bareagent/skills/git/SKILL.md +68 -0
- bareagent_cli-0.1.0/src/bareagent/skills/test/SKILL.md +70 -0
- bareagent_cli-0.1.0/src/bareagent/team/__init__.py +17 -0
- bareagent_cli-0.1.0/src/bareagent/team/autonomous.py +193 -0
- bareagent_cli-0.1.0/src/bareagent/team/mailbox.py +239 -0
- bareagent_cli-0.1.0/src/bareagent/team/manager.py +155 -0
- bareagent_cli-0.1.0/src/bareagent/team/protocols.py +129 -0
- bareagent_cli-0.1.0/src/bareagent/tracing/__init__.py +12 -0
- bareagent_cli-0.1.0/src/bareagent/tracing/_api.py +92 -0
- bareagent_cli-0.1.0/src/bareagent/tracing/_proxy.py +60 -0
- bareagent_cli-0.1.0/src/bareagent/tracing/composite.py +115 -0
- bareagent_cli-0.1.0/src/bareagent/tracing/json_file.py +115 -0
- bareagent_cli-0.1.0/src/bareagent/tracing/langfuse.py +139 -0
- bareagent_cli-0.1.0/src/bareagent/tracing/otel.py +107 -0
- bareagent_cli-0.1.0/src/bareagent/tracing/setup.py +85 -0
- bareagent_cli-0.1.0/src/bareagent/ui/__init__.py +24 -0
- bareagent_cli-0.1.0/src/bareagent/ui/console.py +167 -0
- bareagent_cli-0.1.0/src/bareagent/ui/prompt.py +78 -0
- bareagent_cli-0.1.0/src/bareagent/ui/protocol.py +24 -0
- bareagent_cli-0.1.0/src/bareagent/ui/stream.py +66 -0
- bareagent_cli-0.1.0/src/bareagent/ui/theme.py +240 -0
- bareagent_cli-0.1.0/tests/.gitkeep +1 -0
- bareagent_cli-0.1.0/tests/conftest.py +70 -0
- bareagent_cli-0.1.0/tests/test_agent_types.py +129 -0
- bareagent_cli-0.1.0/tests/test_compact.py +359 -0
- bareagent_cli-0.1.0/tests/test_compact_manual.py +61 -0
- bareagent_cli-0.1.0/tests/test_config_manual.py +34 -0
- bareagent_cli-0.1.0/tests/test_config_merge.py +22 -0
- bareagent_cli-0.1.0/tests/test_config_read.py +36 -0
- bareagent_cli-0.1.0/tests/test_config_reload.py +306 -0
- bareagent_cli-0.1.0/tests/test_context.py +43 -0
- bareagent_cli-0.1.0/tests/test_conversation_io.py +184 -0
- bareagent_cli-0.1.0/tests/test_cost_config.py +60 -0
- bareagent_cli-0.1.0/tests/test_dangerous_patterns.py +45 -0
- bareagent_cli-0.1.0/tests/test_embedding.py +95 -0
- bareagent_cli-0.1.0/tests/test_experiential_skill_gen.py +374 -0
- bareagent_cli-0.1.0/tests/test_file_read_multimodal.py +278 -0
- bareagent_cli-0.1.0/tests/test_file_tools.py +57 -0
- bareagent_cli-0.1.0/tests/test_goal.py +351 -0
- bareagent_cli-0.1.0/tests/test_hooks_config.py +139 -0
- bareagent_cli-0.1.0/tests/test_hooks_engine.py +242 -0
- bareagent_cli-0.1.0/tests/test_interaction_log.py +580 -0
- bareagent_cli-0.1.0/tests/test_loop.py +916 -0
- bareagent_cli-0.1.0/tests/test_lsp_agent_types.py +110 -0
- bareagent_cli-0.1.0/tests/test_lsp_auto_diagnostics_hook.py +196 -0
- bareagent_cli-0.1.0/tests/test_lsp_config.py +100 -0
- bareagent_cli-0.1.0/tests/test_lsp_coord.py +61 -0
- bareagent_cli-0.1.0/tests/test_lsp_diagnostics.py +281 -0
- bareagent_cli-0.1.0/tests/test_lsp_e2e_manual.py +196 -0
- bareagent_cli-0.1.0/tests/test_lsp_manager.py +252 -0
- bareagent_cli-0.1.0/tests/test_lsp_manager_disconnect.py +305 -0
- bareagent_cli-0.1.0/tests/test_lsp_registry.py +53 -0
- bareagent_cli-0.1.0/tests/test_lsp_repl.py +203 -0
- bareagent_cli-0.1.0/tests/test_lsp_tools.py +480 -0
- bareagent_cli-0.1.0/tests/test_lsp_workspace_edit.py +305 -0
- bareagent_cli-0.1.0/tests/test_mailbox_manual.py +71 -0
- bareagent_cli-0.1.0/tests/test_main.py +1317 -0
- bareagent_cli-0.1.0/tests/test_mcp_client.py +483 -0
- bareagent_cli-0.1.0/tests/test_mcp_config.py +130 -0
- bareagent_cli-0.1.0/tests/test_mcp_e2e_manual.py +77 -0
- bareagent_cli-0.1.0/tests/test_mcp_manager.py +338 -0
- bareagent_cli-0.1.0/tests/test_mcp_multimodal.py +712 -0
- bareagent_cli-0.1.0/tests/test_mcp_permission.py +120 -0
- bareagent_cli-0.1.0/tests/test_mcp_prompts.py +307 -0
- bareagent_cli-0.1.0/tests/test_mcp_protocol.py +121 -0
- bareagent_cli-0.1.0/tests/test_mcp_registry.py +539 -0
- bareagent_cli-0.1.0/tests/test_mcp_repl.py +189 -0
- bareagent_cli-0.1.0/tests/test_mcp_sse.py +90 -0
- bareagent_cli-0.1.0/tests/test_mcp_transport_http_legacy.py +144 -0
- bareagent_cli-0.1.0/tests/test_mcp_transport_http_streamable.py +174 -0
- bareagent_cli-0.1.0/tests/test_mcp_transport_stdio.py +194 -0
- bareagent_cli-0.1.0/tests/test_memory_recall.py +384 -0
- bareagent_cli-0.1.0/tests/test_memory_tool.py +162 -0
- bareagent_cli-0.1.0/tests/test_mode_command.py +38 -0
- bareagent_cli-0.1.0/tests/test_permission_manual.py +33 -0
- bareagent_cli-0.1.0/tests/test_permission_rules.py +42 -0
- bareagent_cli-0.1.0/tests/test_permission_semantic_rename.py +37 -0
- bareagent_cli-0.1.0/tests/test_persistent.py +299 -0
- bareagent_cli-0.1.0/tests/test_plan_mode.py +325 -0
- bareagent_cli-0.1.0/tests/test_prompt_caching.py +494 -0
- bareagent_cli-0.1.0/tests/test_provider.py +768 -0
- bareagent_cli-0.1.0/tests/test_provider_factory.py +167 -0
- bareagent_cli-0.1.0/tests/test_provider_manual.py +48 -0
- bareagent_cli-0.1.0/tests/test_provider_setup.py +451 -0
- bareagent_cli-0.1.0/tests/test_retry.py +343 -0
- bareagent_cli-0.1.0/tests/test_scheduler.py +304 -0
- bareagent_cli-0.1.0/tests/test_search_tools.py +40 -0
- bareagent_cli-0.1.0/tests/test_skill_self_evolution.py +163 -0
- bareagent_cli-0.1.0/tests/test_skills_manual.py +38 -0
- bareagent_cli-0.1.0/tests/test_smoke.py +141 -0
- bareagent_cli-0.1.0/tests/test_subagent_manual.py +205 -0
- bareagent_cli-0.1.0/tests/test_subagent_send.py +233 -0
- bareagent_cli-0.1.0/tests/test_tasks.py +154 -0
- bareagent_cli-0.1.0/tests/test_tasks_manual.py +71 -0
- bareagent_cli-0.1.0/tests/test_team.py +989 -0
- bareagent_cli-0.1.0/tests/test_theme.py +91 -0
- bareagent_cli-0.1.0/tests/test_todo.py +177 -0
- bareagent_cli-0.1.0/tests/test_todo_manual.py +38 -0
- bareagent_cli-0.1.0/tests/test_token_tracker.py +171 -0
- bareagent_cli-0.1.0/tests/test_tools.py +355 -0
- bareagent_cli-0.1.0/tests/test_tools_registry.py +44 -0
- bareagent_cli-0.1.0/tests/test_tracing_api.py +180 -0
- bareagent_cli-0.1.0/tests/test_tracing_composite.py +184 -0
- bareagent_cli-0.1.0/tests/test_tracing_json_file.py +135 -0
- bareagent_cli-0.1.0/tests/test_ui.py +275 -0
- bareagent_cli-0.1.0/tests/test_web_fetch.py +62 -0
- bareagent_cli-0.1.0/tests/test_web_search.py +159 -0
- bareagent_cli-0.1.0/tests/test_web_viewer.py +150 -0
- bareagent_cli-0.1.0/tests/test_workflow.py +946 -0
- bareagent_cli-0.1.0/tests/test_workflow_registry.py +133 -0
- bareagent_cli-0.1.0/tests/test_worktree.py +308 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.venv/
|
|
2
|
+
__pycache__/
|
|
3
|
+
specs/
|
|
4
|
+
.claude/
|
|
5
|
+
config/
|
|
6
|
+
.mailbox/
|
|
7
|
+
.transcripts/
|
|
8
|
+
.bareagent_history
|
|
9
|
+
.logs/
|
|
10
|
+
steps/
|
|
11
|
+
code-agent-design.md
|
|
12
|
+
简历.md
|
|
13
|
+
code-review-report.md
|
|
14
|
+
terminal-ui-design-reference.md
|
|
15
|
+
|
|
16
|
+
*.py[cod]
|
|
17
|
+
|
|
18
|
+
.pytest_cache/
|
|
19
|
+
.ruff_cache/
|
|
20
|
+
.coverage
|
|
21
|
+
htmlcov/
|
|
22
|
+
|
|
23
|
+
build/
|
|
24
|
+
dist/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
tmp-dist/
|
|
27
|
+
tmp-review/
|
|
28
|
+
tmp_review_build_uv/
|
|
29
|
+
config.local.toml
|
|
30
|
+
docs/subagent-refactor-plan.md
|
|
31
|
+
docs/outline.md
|
|
32
|
+
|
|
33
|
+
# VitePress
|
|
34
|
+
docs/.vitepress/dist/
|
|
35
|
+
docs/.vitepress/cache/
|
|
36
|
+
docs/node_modules/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ducat
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bareagent-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A pure Python terminal code agent — pluggable LLM providers, fine-grained permissions, multi-agent coordination, and an extensible skill system.
|
|
5
|
+
Project-URL: Homepage, https://github.com/525300887039/BareAgent
|
|
6
|
+
Project-URL: Repository, https://github.com/525300887039/BareAgent
|
|
7
|
+
Project-URL: Issues, https://github.com/525300887039/BareAgent/issues
|
|
8
|
+
Author-email: ducat <no.525350@gmail.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agent,anthropic,cli,coding-agent,llm,openai,terminal
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Software Development
|
|
19
|
+
Classifier: Topic :: Utilities
|
|
20
|
+
Requires-Python: >=3.12
|
|
21
|
+
Requires-Dist: anthropic>=0.52
|
|
22
|
+
Requires-Dist: httpx>=0.27
|
|
23
|
+
Requires-Dist: openai>=1.70
|
|
24
|
+
Requires-Dist: prompt-toolkit>=3.0
|
|
25
|
+
Requires-Dist: rich>=14.0
|
|
26
|
+
Provides-Extra: all-tracing
|
|
27
|
+
Requires-Dist: langfuse>=2.0; extra == 'all-tracing'
|
|
28
|
+
Requires-Dist: opentelemetry-api>=1.20; extra == 'all-tracing'
|
|
29
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.20; extra == 'all-tracing'
|
|
30
|
+
Requires-Dist: opentelemetry-sdk>=1.20; extra == 'all-tracing'
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: ruff>=0.11; extra == 'dev'
|
|
34
|
+
Provides-Extra: embeddings
|
|
35
|
+
Requires-Dist: fastembed>=0.8; extra == 'embeddings'
|
|
36
|
+
Provides-Extra: langfuse
|
|
37
|
+
Requires-Dist: langfuse>=2.0; extra == 'langfuse'
|
|
38
|
+
Provides-Extra: lsp
|
|
39
|
+
Requires-Dist: multilspy>=0.0.15; extra == 'lsp'
|
|
40
|
+
Provides-Extra: otel
|
|
41
|
+
Requires-Dist: opentelemetry-api>=1.20; extra == 'otel'
|
|
42
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.20; extra == 'otel'
|
|
43
|
+
Requires-Dist: opentelemetry-sdk>=1.20; extra == 'otel'
|
|
44
|
+
Provides-Extra: pdf
|
|
45
|
+
Requires-Dist: pypdf>=4.0; extra == 'pdf'
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
|
|
48
|
+
# BareAgent
|
|
49
|
+
|
|
50
|
+
> 纯 Python 终端代码智能体 — 可插拔 LLM、细粒度权限、多智能体协调、可扩展技能系统
|
|
51
|
+
|
|
52
|
+
<!-- badges placeholder -->
|
|
53
|
+

|
|
54
|
+

|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## ✨ 核心特性
|
|
59
|
+
|
|
60
|
+
<p align="center">
|
|
61
|
+
<img src="https://raw.githubusercontent.com/525300887039/BareAgent/main/docs/public/readme-features-overview.png" alt="BareAgent 核心特性概览" width="720" />
|
|
62
|
+
</p>
|
|
63
|
+
|
|
64
|
+
| 特性 | 说明 |
|
|
65
|
+
|------|------|
|
|
66
|
+
| **多提供商支持** | Anthropic / OpenAI / DeepSeek,统一接口,流式与非流式输出自由切换 |
|
|
67
|
+
| **内置工具** | bash、文件读写编辑、glob、grep 等开箱即用,延迟加载按需注册 |
|
|
68
|
+
| **权限守卫** | 四种模式(DEFAULT / AUTO / PLAN / BYPASS),危险命令自动拦截 |
|
|
69
|
+
| **多智能体协调** | 基于 JSONL 邮箱的消息总线,守护进程式自治智能体,请求-响应协议 |
|
|
70
|
+
| **子智能体委派** | 隔离上下文、递归深度限制、类型化智能体(explore/plan/code-review)、后台异步执行 |
|
|
71
|
+
| **技能系统** | 从 `skills/*/SKILL.md` 自动发现,按需加载(code-review、git、test) |
|
|
72
|
+
| **任务管理** | 持久化任务 + 会话级 TODO,支持依赖追踪和优先级 |
|
|
73
|
+
| **消息压缩** | 微压缩 + LLM 摘要,基于 token 阈值(50k)触发,支撑超长对话 |
|
|
74
|
+
| **会话管理** | 会话转录持久化,支持列出历史会话和恢复上下文 |
|
|
75
|
+
| **运行时切换** | 斜杠命令或 `Shift+Tab` 快捷键实时切换权限模式,无需重启 |
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 🏗️ 架构概览
|
|
80
|
+
|
|
81
|
+
<p align="center">
|
|
82
|
+
<img src="https://raw.githubusercontent.com/525300887039/BareAgent/main/docs/guide/images/ch01-architecture.png" alt="BareAgent 架构图" width="720" />
|
|
83
|
+
</p>
|
|
84
|
+
|
|
85
|
+
核心循环 `agent_loop()` 是中央调度器:**调用 LLM → 解析工具调用 → 权限检查 → 执行处理器 → 收集结果**,最多迭代 200 次。支持流式输出和长对话消息自动压缩。
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 🚀 快速开始
|
|
90
|
+
|
|
91
|
+
### 环境要求
|
|
92
|
+
|
|
93
|
+
- Python 3.12+
|
|
94
|
+
- [uv](https://github.com/astral-sh/uv)(推荐)
|
|
95
|
+
|
|
96
|
+
### 安装
|
|
97
|
+
|
|
98
|
+
**作为命令行工具使用**(推荐,隔离安装,安装后全局可用 `bareagent`):
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
uv tool install bareagent-cli # 或: pipx install bareagent-cli
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**从源码开发**(可编辑安装):
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
uv pip install -e ".[dev]"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
> 发布到 PyPI / 自动发布流程见 [`docs/releasing.md`](docs/releasing.md)。
|
|
111
|
+
|
|
112
|
+
### 配置
|
|
113
|
+
|
|
114
|
+
#### API Key 设置
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Linux / macOS
|
|
118
|
+
export OPENAI_API_KEY="your-key-here"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
```powershell
|
|
122
|
+
# Windows PowerShell(当前会话)
|
|
123
|
+
$env:OPENAI_API_KEY="your-key-here"
|
|
124
|
+
|
|
125
|
+
# Windows PowerShell(永久生效)
|
|
126
|
+
[Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "your-key-here", "User")
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### 配置文件
|
|
130
|
+
|
|
131
|
+
默认配置随包内置(只读),本地覆盖写入**当前工作目录**的 `config.local.toml`(已 git-ignore;
|
|
132
|
+
`bareagent init` 会帮你生成)。也可用 `--config <path>` / `BAREAGENT_CONFIG` 指定其他配置文件:
|
|
133
|
+
|
|
134
|
+
```toml
|
|
135
|
+
[provider]
|
|
136
|
+
name = "openai"
|
|
137
|
+
model = "gpt-4.1"
|
|
138
|
+
api_key_env = "OPENAI_API_KEY"
|
|
139
|
+
|
|
140
|
+
[permission]
|
|
141
|
+
mode = "default"
|
|
142
|
+
|
|
143
|
+
[ui]
|
|
144
|
+
stream = true
|
|
145
|
+
theme = "dark"
|
|
146
|
+
|
|
147
|
+
[thinking]
|
|
148
|
+
mode = "adaptive"
|
|
149
|
+
budget_tokens = 10000
|
|
150
|
+
|
|
151
|
+
[subagent]
|
|
152
|
+
max_depth = 3
|
|
153
|
+
default_type = "general-purpose"
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### 环境变量
|
|
157
|
+
|
|
158
|
+
<p align="center">
|
|
159
|
+
<img src="https://raw.githubusercontent.com/525300887039/BareAgent/main/docs/public/readme-config-flow.png" alt="配置流程图" width="640" />
|
|
160
|
+
</p>
|
|
161
|
+
|
|
162
|
+
配置优先级:`config.toml` → `config.local.toml` → 环境变量 / CLI 参数(优先级递增)。
|
|
163
|
+
|
|
164
|
+
| 环境变量 | 说明 | 默认值 |
|
|
165
|
+
|---------|------|--------|
|
|
166
|
+
| `BAREAGENT_PROVIDER` | 提供商名称 | `openai` |
|
|
167
|
+
| `BAREAGENT_MODEL` | 模型名称 | `gpt-4.1` |
|
|
168
|
+
| `BAREAGENT_API_KEY` | 明文 API 密钥(优先于 `api_key_env`) | — |
|
|
169
|
+
| `BAREAGENT_API_KEY_ENV` | API 密钥环境变量名 | 按提供商自动设置 |
|
|
170
|
+
| `BAREAGENT_BASE_URL` | 自定义 API 基础 URL | — |
|
|
171
|
+
| `BAREAGENT_PERMISSION_MODE` | 权限模式 | `default` |
|
|
172
|
+
| `BAREAGENT_UI_STREAM` | 是否流式输出 | `true` |
|
|
173
|
+
| `BAREAGENT_UI_THEME` | UI 主题 | `dark` |
|
|
174
|
+
| `BAREAGENT_THINKING_MODE` | 思考模式(adaptive/enabled/disabled) | `adaptive` |
|
|
175
|
+
| `BAREAGENT_THINKING_BUDGET_TOKENS` | 思考 token 预算 | `10000` |
|
|
176
|
+
| `BAREAGENT_SKILLS_DIR` | 技能目录路径 | 自动发现 |
|
|
177
|
+
| `BAREAGENT_SUBAGENT_MAX_DEPTH` | 子智能体最大递归深度 | `3` |
|
|
178
|
+
| `BAREAGENT_SUBAGENT_DEFAULT_TYPE` | 子智能体默认类型 | `general-purpose` |
|
|
179
|
+
|
|
180
|
+
### 运行
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
bareagent
|
|
184
|
+
# 或
|
|
185
|
+
python -m bareagent.main
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
#### CLI 参数
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
bareagent --provider anthropic --model claude-sonnet-4-20250514
|
|
192
|
+
bareagent --provider openai --model gpt-4.1
|
|
193
|
+
bareagent --config ~/my_config.toml
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
| 参数 | 说明 |
|
|
197
|
+
|------|------|
|
|
198
|
+
| `--provider` | 覆盖配置文件中的 LLM 提供商(anthropic / openai / deepseek) |
|
|
199
|
+
| `--model` | 覆盖配置文件中的模型名称 |
|
|
200
|
+
| `--config` | 指定 TOML 配置文件路径(默认 `config.toml`,支持 `~` 扩展) |
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## 💻 REPL 命令速查
|
|
205
|
+
|
|
206
|
+
| 命令 | 说明 |
|
|
207
|
+
|------|------|
|
|
208
|
+
| `/help` | 显示帮助信息,列出所有可用命令 |
|
|
209
|
+
| `/exit` | 退出 BareAgent,广播关闭信号给所有团队成员 |
|
|
210
|
+
| `/clear` | 清屏并启动新对话(重置消息历史和会话 ID) |
|
|
211
|
+
| `/new` | 启动新对话(仅重置消息,不清屏) |
|
|
212
|
+
| `/compact` | 压缩对话上下文,生成 LLM 摘要释放 token |
|
|
213
|
+
| `/default` | 切换到 DEFAULT 权限模式 |
|
|
214
|
+
| `/auto` | 切换到 AUTO 权限模式 |
|
|
215
|
+
| `/plan` | 切换到 PLAN 权限模式(只读) |
|
|
216
|
+
| `/bypass` | 切换到 BYPASS 权限模式(无确认) |
|
|
217
|
+
| `/mode` | 交互式权限模式选择菜单 |
|
|
218
|
+
| `/sessions` | 列出已保存的历史会话 |
|
|
219
|
+
| `/resume [id]` | 恢复上一个会话(可选指定会话 ID) |
|
|
220
|
+
| `/team` | 管理团队智能体(子命令:`list`、`spawn <name>`、`send <name> <msg>`) |
|
|
221
|
+
|
|
222
|
+
**快捷键:**
|
|
223
|
+
|
|
224
|
+
| 按键 | 功能 |
|
|
225
|
+
|------|------|
|
|
226
|
+
| `Shift+Tab` | 循环切换权限模式(DEFAULT → AUTO → PLAN → BYPASS) |
|
|
227
|
+
| `Ctrl+C` | 中断当前操作(按两次退出) |
|
|
228
|
+
| `Ctrl+Z` | 立即退出 REPL |
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## 🔐 权限模式
|
|
233
|
+
|
|
234
|
+
| 模式 | 行为 | 适用场景 |
|
|
235
|
+
|------|------|---------|
|
|
236
|
+
| **DEFAULT** | 写操作需用户确认,安全工具自动批准 | 日常使用(默认) |
|
|
237
|
+
| **AUTO** | 安全命令(ls、cat、git status、pytest 等)自动通过,仅拦截危险命令 | 信任环境下的高效开发 |
|
|
238
|
+
| **PLAN** | 只允许只读工具,所有写操作被阻止 | 代码审查、方案设计 |
|
|
239
|
+
| **BYPASS** | 所有操作自动批准,无任何确认 | 完全信任的自动化场景 |
|
|
240
|
+
|
|
241
|
+
切换方式:`/default`、`/auto`、`/plan`、`/bypass`、`/mode` 或 `Shift+Tab`。
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## 📁 项目结构
|
|
246
|
+
|
|
247
|
+
<p align="center">
|
|
248
|
+
<img src="https://raw.githubusercontent.com/525300887039/BareAgent/main/docs/public/readme-project-layers.png" alt="项目分层架构图" width="640" />
|
|
249
|
+
</p>
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
src/
|
|
253
|
+
├── main.py # 入口与 REPL 循环
|
|
254
|
+
├── core/ # 智能体循环、工具注册、Schema、沙箱
|
|
255
|
+
│ ├── loop.py # 核心 agent_loop()
|
|
256
|
+
│ ├── tools.py # 工具注册与分发
|
|
257
|
+
│ ├── schema.py # 工具 Schema 定义
|
|
258
|
+
│ ├── context.py # 系统提示组装
|
|
259
|
+
│ ├── sandbox.py # 路径安全检查
|
|
260
|
+
│ ├── fileutil.py # 文件工具函数
|
|
261
|
+
│ └── handlers/ # 各工具处理器实现
|
|
262
|
+
├── provider/ # LLM 提供商抽象
|
|
263
|
+
│ ├── base.py # BaseLLMProvider
|
|
264
|
+
│ ├── anthropic.py # Anthropic 实现
|
|
265
|
+
│ ├── openai.py # OpenAI 实现
|
|
266
|
+
│ └── factory.py # 工厂
|
|
267
|
+
├── permission/ # 权限守卫
|
|
268
|
+
│ ├── guard.py # PermissionGuard(4 种模式)
|
|
269
|
+
│ └── rules.py # 权限规则解析
|
|
270
|
+
├── memory/ # 消息压缩与会话管理
|
|
271
|
+
│ ├── compact.py # Compactor(微压缩 + LLM 摘要)
|
|
272
|
+
│ ├── token_counter.py # Token 估算
|
|
273
|
+
│ └── transcript.py # 会话转录管理
|
|
274
|
+
├── planning/ # 任务、TODO、技能、子智能体
|
|
275
|
+
│ ├── agent_types.py # 智能体类型系统
|
|
276
|
+
│ ├── subagent.py # 子智能体委派
|
|
277
|
+
│ ├── tasks.py # 持久化任务管理
|
|
278
|
+
│ ├── todo.py # 会话级 TODO
|
|
279
|
+
│ └── skills.py # 技能发现与加载
|
|
280
|
+
├── team/ # 多智能体协调
|
|
281
|
+
│ ├── mailbox.py # JSONL 消息总线
|
|
282
|
+
│ ├── autonomous.py # 自治智能体守护进程
|
|
283
|
+
│ ├── manager.py # TeammateManager
|
|
284
|
+
│ └── protocols.py # 请求-响应协议
|
|
285
|
+
├── concurrency/ # 后台执行与通知
|
|
286
|
+
│ ├── background.py # BackgroundManager
|
|
287
|
+
│ └── notification.py # 后台通知
|
|
288
|
+
└── ui/ # 终端 UI(rich + 流式)
|
|
289
|
+
├── console.py # AgentConsole
|
|
290
|
+
└── stream.py # StreamPrinter
|
|
291
|
+
skills/ # 可扩展技能模块
|
|
292
|
+
tests/ # pytest 测试
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## 🔗 完整文档
|
|
298
|
+
|
|
299
|
+
项目提供基于 [VitePress](https://vitepress.dev/) 的完整文档,涵盖架构设计、模块详解、开发指南等 15 个章节:
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
cd docs
|
|
303
|
+
npm install
|
|
304
|
+
npm run docs:dev
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
文档源码位于 [`docs/`](docs/) 目录。
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## 🛠️ 开发
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
# 测试
|
|
315
|
+
pytest # 全部测试
|
|
316
|
+
pytest tests/test_loop.py # 单个文件
|
|
317
|
+
pytest tests/test_loop.py -k "test_name" # 单个测试
|
|
318
|
+
|
|
319
|
+
# 代码检查与格式化
|
|
320
|
+
ruff check src tests # 检查
|
|
321
|
+
ruff check --fix src tests # 自动修复
|
|
322
|
+
ruff format src tests # 格式化
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
提交信息遵循 Conventional Commits:`Fix:`、`Feat:`、`Refactor:`、`Test:`、`Docs:`
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## 📄 许可证
|
|
330
|
+
|
|
331
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# BareAgent
|
|
2
|
+
|
|
3
|
+
> 纯 Python 终端代码智能体 — 可插拔 LLM、细粒度权限、多智能体协调、可扩展技能系统
|
|
4
|
+
|
|
5
|
+
<!-- badges placeholder -->
|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## ✨ 核心特性
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<img src="https://raw.githubusercontent.com/525300887039/BareAgent/main/docs/public/readme-features-overview.png" alt="BareAgent 核心特性概览" width="720" />
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
| 特性 | 说明 |
|
|
18
|
+
|------|------|
|
|
19
|
+
| **多提供商支持** | Anthropic / OpenAI / DeepSeek,统一接口,流式与非流式输出自由切换 |
|
|
20
|
+
| **内置工具** | bash、文件读写编辑、glob、grep 等开箱即用,延迟加载按需注册 |
|
|
21
|
+
| **权限守卫** | 四种模式(DEFAULT / AUTO / PLAN / BYPASS),危险命令自动拦截 |
|
|
22
|
+
| **多智能体协调** | 基于 JSONL 邮箱的消息总线,守护进程式自治智能体,请求-响应协议 |
|
|
23
|
+
| **子智能体委派** | 隔离上下文、递归深度限制、类型化智能体(explore/plan/code-review)、后台异步执行 |
|
|
24
|
+
| **技能系统** | 从 `skills/*/SKILL.md` 自动发现,按需加载(code-review、git、test) |
|
|
25
|
+
| **任务管理** | 持久化任务 + 会话级 TODO,支持依赖追踪和优先级 |
|
|
26
|
+
| **消息压缩** | 微压缩 + LLM 摘要,基于 token 阈值(50k)触发,支撑超长对话 |
|
|
27
|
+
| **会话管理** | 会话转录持久化,支持列出历史会话和恢复上下文 |
|
|
28
|
+
| **运行时切换** | 斜杠命令或 `Shift+Tab` 快捷键实时切换权限模式,无需重启 |
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 🏗️ 架构概览
|
|
33
|
+
|
|
34
|
+
<p align="center">
|
|
35
|
+
<img src="https://raw.githubusercontent.com/525300887039/BareAgent/main/docs/guide/images/ch01-architecture.png" alt="BareAgent 架构图" width="720" />
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
核心循环 `agent_loop()` 是中央调度器:**调用 LLM → 解析工具调用 → 权限检查 → 执行处理器 → 收集结果**,最多迭代 200 次。支持流式输出和长对话消息自动压缩。
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 🚀 快速开始
|
|
43
|
+
|
|
44
|
+
### 环境要求
|
|
45
|
+
|
|
46
|
+
- Python 3.12+
|
|
47
|
+
- [uv](https://github.com/astral-sh/uv)(推荐)
|
|
48
|
+
|
|
49
|
+
### 安装
|
|
50
|
+
|
|
51
|
+
**作为命令行工具使用**(推荐,隔离安装,安装后全局可用 `bareagent`):
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
uv tool install bareagent-cli # 或: pipx install bareagent-cli
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**从源码开发**(可编辑安装):
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
uv pip install -e ".[dev]"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
> 发布到 PyPI / 自动发布流程见 [`docs/releasing.md`](docs/releasing.md)。
|
|
64
|
+
|
|
65
|
+
### 配置
|
|
66
|
+
|
|
67
|
+
#### API Key 设置
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Linux / macOS
|
|
71
|
+
export OPENAI_API_KEY="your-key-here"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```powershell
|
|
75
|
+
# Windows PowerShell(当前会话)
|
|
76
|
+
$env:OPENAI_API_KEY="your-key-here"
|
|
77
|
+
|
|
78
|
+
# Windows PowerShell(永久生效)
|
|
79
|
+
[Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "your-key-here", "User")
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### 配置文件
|
|
83
|
+
|
|
84
|
+
默认配置随包内置(只读),本地覆盖写入**当前工作目录**的 `config.local.toml`(已 git-ignore;
|
|
85
|
+
`bareagent init` 会帮你生成)。也可用 `--config <path>` / `BAREAGENT_CONFIG` 指定其他配置文件:
|
|
86
|
+
|
|
87
|
+
```toml
|
|
88
|
+
[provider]
|
|
89
|
+
name = "openai"
|
|
90
|
+
model = "gpt-4.1"
|
|
91
|
+
api_key_env = "OPENAI_API_KEY"
|
|
92
|
+
|
|
93
|
+
[permission]
|
|
94
|
+
mode = "default"
|
|
95
|
+
|
|
96
|
+
[ui]
|
|
97
|
+
stream = true
|
|
98
|
+
theme = "dark"
|
|
99
|
+
|
|
100
|
+
[thinking]
|
|
101
|
+
mode = "adaptive"
|
|
102
|
+
budget_tokens = 10000
|
|
103
|
+
|
|
104
|
+
[subagent]
|
|
105
|
+
max_depth = 3
|
|
106
|
+
default_type = "general-purpose"
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### 环境变量
|
|
110
|
+
|
|
111
|
+
<p align="center">
|
|
112
|
+
<img src="https://raw.githubusercontent.com/525300887039/BareAgent/main/docs/public/readme-config-flow.png" alt="配置流程图" width="640" />
|
|
113
|
+
</p>
|
|
114
|
+
|
|
115
|
+
配置优先级:`config.toml` → `config.local.toml` → 环境变量 / CLI 参数(优先级递增)。
|
|
116
|
+
|
|
117
|
+
| 环境变量 | 说明 | 默认值 |
|
|
118
|
+
|---------|------|--------|
|
|
119
|
+
| `BAREAGENT_PROVIDER` | 提供商名称 | `openai` |
|
|
120
|
+
| `BAREAGENT_MODEL` | 模型名称 | `gpt-4.1` |
|
|
121
|
+
| `BAREAGENT_API_KEY` | 明文 API 密钥(优先于 `api_key_env`) | — |
|
|
122
|
+
| `BAREAGENT_API_KEY_ENV` | API 密钥环境变量名 | 按提供商自动设置 |
|
|
123
|
+
| `BAREAGENT_BASE_URL` | 自定义 API 基础 URL | — |
|
|
124
|
+
| `BAREAGENT_PERMISSION_MODE` | 权限模式 | `default` |
|
|
125
|
+
| `BAREAGENT_UI_STREAM` | 是否流式输出 | `true` |
|
|
126
|
+
| `BAREAGENT_UI_THEME` | UI 主题 | `dark` |
|
|
127
|
+
| `BAREAGENT_THINKING_MODE` | 思考模式(adaptive/enabled/disabled) | `adaptive` |
|
|
128
|
+
| `BAREAGENT_THINKING_BUDGET_TOKENS` | 思考 token 预算 | `10000` |
|
|
129
|
+
| `BAREAGENT_SKILLS_DIR` | 技能目录路径 | 自动发现 |
|
|
130
|
+
| `BAREAGENT_SUBAGENT_MAX_DEPTH` | 子智能体最大递归深度 | `3` |
|
|
131
|
+
| `BAREAGENT_SUBAGENT_DEFAULT_TYPE` | 子智能体默认类型 | `general-purpose` |
|
|
132
|
+
|
|
133
|
+
### 运行
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
bareagent
|
|
137
|
+
# 或
|
|
138
|
+
python -m bareagent.main
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
#### CLI 参数
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
bareagent --provider anthropic --model claude-sonnet-4-20250514
|
|
145
|
+
bareagent --provider openai --model gpt-4.1
|
|
146
|
+
bareagent --config ~/my_config.toml
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
| 参数 | 说明 |
|
|
150
|
+
|------|------|
|
|
151
|
+
| `--provider` | 覆盖配置文件中的 LLM 提供商(anthropic / openai / deepseek) |
|
|
152
|
+
| `--model` | 覆盖配置文件中的模型名称 |
|
|
153
|
+
| `--config` | 指定 TOML 配置文件路径(默认 `config.toml`,支持 `~` 扩展) |
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 💻 REPL 命令速查
|
|
158
|
+
|
|
159
|
+
| 命令 | 说明 |
|
|
160
|
+
|------|------|
|
|
161
|
+
| `/help` | 显示帮助信息,列出所有可用命令 |
|
|
162
|
+
| `/exit` | 退出 BareAgent,广播关闭信号给所有团队成员 |
|
|
163
|
+
| `/clear` | 清屏并启动新对话(重置消息历史和会话 ID) |
|
|
164
|
+
| `/new` | 启动新对话(仅重置消息,不清屏) |
|
|
165
|
+
| `/compact` | 压缩对话上下文,生成 LLM 摘要释放 token |
|
|
166
|
+
| `/default` | 切换到 DEFAULT 权限模式 |
|
|
167
|
+
| `/auto` | 切换到 AUTO 权限模式 |
|
|
168
|
+
| `/plan` | 切换到 PLAN 权限模式(只读) |
|
|
169
|
+
| `/bypass` | 切换到 BYPASS 权限模式(无确认) |
|
|
170
|
+
| `/mode` | 交互式权限模式选择菜单 |
|
|
171
|
+
| `/sessions` | 列出已保存的历史会话 |
|
|
172
|
+
| `/resume [id]` | 恢复上一个会话(可选指定会话 ID) |
|
|
173
|
+
| `/team` | 管理团队智能体(子命令:`list`、`spawn <name>`、`send <name> <msg>`) |
|
|
174
|
+
|
|
175
|
+
**快捷键:**
|
|
176
|
+
|
|
177
|
+
| 按键 | 功能 |
|
|
178
|
+
|------|------|
|
|
179
|
+
| `Shift+Tab` | 循环切换权限模式(DEFAULT → AUTO → PLAN → BYPASS) |
|
|
180
|
+
| `Ctrl+C` | 中断当前操作(按两次退出) |
|
|
181
|
+
| `Ctrl+Z` | 立即退出 REPL |
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 🔐 权限模式
|
|
186
|
+
|
|
187
|
+
| 模式 | 行为 | 适用场景 |
|
|
188
|
+
|------|------|---------|
|
|
189
|
+
| **DEFAULT** | 写操作需用户确认,安全工具自动批准 | 日常使用(默认) |
|
|
190
|
+
| **AUTO** | 安全命令(ls、cat、git status、pytest 等)自动通过,仅拦截危险命令 | 信任环境下的高效开发 |
|
|
191
|
+
| **PLAN** | 只允许只读工具,所有写操作被阻止 | 代码审查、方案设计 |
|
|
192
|
+
| **BYPASS** | 所有操作自动批准,无任何确认 | 完全信任的自动化场景 |
|
|
193
|
+
|
|
194
|
+
切换方式:`/default`、`/auto`、`/plan`、`/bypass`、`/mode` 或 `Shift+Tab`。
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## 📁 项目结构
|
|
199
|
+
|
|
200
|
+
<p align="center">
|
|
201
|
+
<img src="https://raw.githubusercontent.com/525300887039/BareAgent/main/docs/public/readme-project-layers.png" alt="项目分层架构图" width="640" />
|
|
202
|
+
</p>
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
src/
|
|
206
|
+
├── main.py # 入口与 REPL 循环
|
|
207
|
+
├── core/ # 智能体循环、工具注册、Schema、沙箱
|
|
208
|
+
│ ├── loop.py # 核心 agent_loop()
|
|
209
|
+
│ ├── tools.py # 工具注册与分发
|
|
210
|
+
│ ├── schema.py # 工具 Schema 定义
|
|
211
|
+
│ ├── context.py # 系统提示组装
|
|
212
|
+
│ ├── sandbox.py # 路径安全检查
|
|
213
|
+
│ ├── fileutil.py # 文件工具函数
|
|
214
|
+
│ └── handlers/ # 各工具处理器实现
|
|
215
|
+
├── provider/ # LLM 提供商抽象
|
|
216
|
+
│ ├── base.py # BaseLLMProvider
|
|
217
|
+
│ ├── anthropic.py # Anthropic 实现
|
|
218
|
+
│ ├── openai.py # OpenAI 实现
|
|
219
|
+
│ └── factory.py # 工厂
|
|
220
|
+
├── permission/ # 权限守卫
|
|
221
|
+
│ ├── guard.py # PermissionGuard(4 种模式)
|
|
222
|
+
│ └── rules.py # 权限规则解析
|
|
223
|
+
├── memory/ # 消息压缩与会话管理
|
|
224
|
+
│ ├── compact.py # Compactor(微压缩 + LLM 摘要)
|
|
225
|
+
│ ├── token_counter.py # Token 估算
|
|
226
|
+
│ └── transcript.py # 会话转录管理
|
|
227
|
+
├── planning/ # 任务、TODO、技能、子智能体
|
|
228
|
+
│ ├── agent_types.py # 智能体类型系统
|
|
229
|
+
│ ├── subagent.py # 子智能体委派
|
|
230
|
+
│ ├── tasks.py # 持久化任务管理
|
|
231
|
+
│ ├── todo.py # 会话级 TODO
|
|
232
|
+
│ └── skills.py # 技能发现与加载
|
|
233
|
+
├── team/ # 多智能体协调
|
|
234
|
+
│ ├── mailbox.py # JSONL 消息总线
|
|
235
|
+
│ ├── autonomous.py # 自治智能体守护进程
|
|
236
|
+
│ ├── manager.py # TeammateManager
|
|
237
|
+
│ └── protocols.py # 请求-响应协议
|
|
238
|
+
├── concurrency/ # 后台执行与通知
|
|
239
|
+
│ ├── background.py # BackgroundManager
|
|
240
|
+
│ └── notification.py # 后台通知
|
|
241
|
+
└── ui/ # 终端 UI(rich + 流式)
|
|
242
|
+
├── console.py # AgentConsole
|
|
243
|
+
└── stream.py # StreamPrinter
|
|
244
|
+
skills/ # 可扩展技能模块
|
|
245
|
+
tests/ # pytest 测试
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## 🔗 完整文档
|
|
251
|
+
|
|
252
|
+
项目提供基于 [VitePress](https://vitepress.dev/) 的完整文档,涵盖架构设计、模块详解、开发指南等 15 个章节:
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
cd docs
|
|
256
|
+
npm install
|
|
257
|
+
npm run docs:dev
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
文档源码位于 [`docs/`](docs/) 目录。
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## 🛠️ 开发
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
# 测试
|
|
268
|
+
pytest # 全部测试
|
|
269
|
+
pytest tests/test_loop.py # 单个文件
|
|
270
|
+
pytest tests/test_loop.py -k "test_name" # 单个测试
|
|
271
|
+
|
|
272
|
+
# 代码检查与格式化
|
|
273
|
+
ruff check src tests # 检查
|
|
274
|
+
ruff check --fix src tests # 自动修复
|
|
275
|
+
ruff format src tests # 格式化
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
提交信息遵循 Conventional Commits:`Fix:`、`Feat:`、`Refactor:`、`Test:`、`Docs:`
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 📄 许可证
|
|
283
|
+
|
|
284
|
+
[MIT](LICENSE)
|