Feat/agent system#149
Merged
Merged
Conversation
…thread-safe loading
- 重构优化: 调整导入顺序与缩进格式 * 修正 `src/console/commands/workspaces/agent_cmd.py` 中 `AgentManager`、`copy_to_clipboard` 及 `AgentConfig` 的导入顺序,符合项目规范。 * 优化 `src/core/agent_manager.py` 中 `_parse_frontmatter` 函数的切片语法为 `lines[end_idx + 1 :]`。 * 简化 `src/console/ui/repl.py` 中 `title_right.update` 和 `tui_console.print` 的多行字符串拼接,改为单行形式。 - 修复问题: 统一中文标点符号使用 * 在 `src/core/agent_manager.py` 的默认 Agent 配置内容中,将全角逗号 `,` 替换为英文半角点号 `.`,确保输出格式一致性。 - 重构优化: 精简工具权限判断逻辑 * 重构 `src/models/agent.py` 中 `ToolPermissions.can_use_tool` 方法,将原有的多层 `if-else` 逻辑简化为 `return not self.whitelist or tool_name in self.whitelist`,提升可读性。
- 新增功能: 优化系统提示词生成流程,支持基于 Agent 配置的动态覆盖 * 修改 `_generate_tool_definitions_section` 签名,显式接收 `AgentConfig` 参数替代内部调用 `AgentManager().get_current()` * 修改 `_generate_agent_directive_section` 签名,移除 `CommandContext` 依赖,直接处理 `agent` 对象并增加 `precedence="OVERRIDES_BASE"` 属性 * 重构 `_assemble_full_prompt` 函数,明确定义提示词组装顺序:Role → Constraints → Agent Directive → Tool Rules → Tool Definitions → Workflow → Workspace Context → Augmentation → Extensions * 引入条件逻辑,当 Agent 自身定义了 `body_role` 或 `body_workflow` 时,跳过全局的 `SYSTEM_ROLE` 和 `WORKFLOW_GUIDELINES` 注入 - 重构优化: 分离常量定义与模板内容,提升代码可维护性 * 将 `src/constants/prompts.py` 中的 `SYSTEM_IDENTITY` 拆分为 `SYSTEM_ROLE` (仅包含身份描述) 和 `SYSTEM_CONSTRAINTS` (独立约束块) * 更新 `TOOL_RULES` 中的 `<anti_hallucination>` 标签,增加 `precedence="ABSOLUTE"` 属性以强化优先级 * 调整 `WORKFLOW_GUIDELINES` 步骤,在任务分解前增加“先通过搜索和读取了解项目结构”的步骤 * 更新 `src/core/agent_manager.py` 中 `write_default` 方法,使用 f-string 动态注入 `SYSTEM_ROLE` 和 `WORKFLOW_GUIDELINES` 常量至默认 `default.md` 文件
- 新增功能: 添加 `/agent reset` 子命令用于重写 default.md * 在 `AgentCommand` 中集成 `_reset_default` 函数,调用 `AgentManager.reset_default()` * 新增 `ArgumentParser` 解析器以支持子命令参数及帮助信息展示 (`-h`, `--help`) * 将原有的私有方法 `_show_current` 和 `_list_all` 提升为模块级函数供外部调用 - 修复问题: 解决工作区路径未保存导致重置失败的问题 * 在 `AgentManager.initialize` 中新增 `_root_path` 属性存储工作区根路径 * 修改 `write_default` 方法签名,增加 `force` 布尔参数控制是否覆盖现有文件 * 实现 `reset_default` 方法,强制重写 `default.md` 并清空内部缓存 (`_loaded`, `_agents`)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.