-
-
Notifications
You must be signed in to change notification settings - Fork 41
feat: switch to sydney preset and remove code sandbox #575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…iltering - Add fsIgnores config option with default ignore patterns for common folders (node_modules, .git, dist, build, etc.) - Implement ignore pattern matching using micromatch in FileStore - Skip ignored files during search and list operations - Update config schema to include fsIgnores with default patterns - Add localization for new fsIgnores config option This improves fs tool performance by skipping irrelevant folders and prevents unnecessary file operations on build artifacts and dependencies.
…d batch updates - Add batch_set action for updating multiple todos at once - Implement sequential task validation (tasks must be completed in order) - Inject task progress tracking into chat context via before-chat hook - Improve status display with checkbox format ([ ] / [x]) - Add minimum task requirement (at least 3 subtasks) - Simplify user-facing messages and improve progress feedback - Auto-cleanup completed task lists This ensures better task tracking discipline and provides clearer progress visibility to users during multi-step operations.
…m compatibility - Replace locale-specific date format with ISO 8601 format - Use consistent YYYY-MM-DD-HH-mm-ss format for log filenames - Remove locale-dependent characters that cause issues on different systems - Ensure valid filenames across all operating systems This fixes log file naming issues on systems with different locale settings.
…nd comprehensive task management
This commit introduces a complete rewrite of the cron task system:
- Replace command-based scheduling with database-backed task persistence
- Add database model `chatluna_cron_task` with comprehensive field support
- Implement CRUD operations: create, get (list), and cancel tasks
- Support two task types: notification (reminders) and command (bot commands)
- Add flexible time parsing: delays (Xs/Xm/Xh/Xd), specific times (HH:MM), and repeating tasks (time/interval)
- Implement permission system with `cronScopeSelector` for command-type tasks
- Add task restoration on bot restart via ctx.on('ready') and bot-status-updated events
- Extract Config interface and Schema to separate config.ts file for better modularity
- Update locale files with new cronScopeSelector configuration descriptions
- Remove dependency on legacy command validation and element utilities
The new implementation provides better reliability, persistence across restarts, and more intuitive task management for end users.
… management - Change default chat mode from 'chat' to 'agent' - Change default preset from 'chatgpt' to 'sydney' - Remove chatgpt preset in favor of sydney - Add group whitelist feature for fine-grained access control - Remove code_sandbox plugin - Add sydney.yml preset configuration
…ales - Remove code sandbox API key and selector configuration sections - Update cron description to remove dependency mentions - Fix typo in zh-CN command description (用户 -> 用途)
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Walkthrough调整 core 默认配置与预设匹配,规范日志时间戳;在 extension-tools 中拆分配置导出并移除 code_sandbox;新增/扩展 cron 持久化调度、文件就地替换(updateFile)、群组白名单与 todos 批量更新等工具与接口。 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant User as 用户
participant Bot as Bot/Plugin
participant Cron as CronTool
participant DB as chatluna_cron_task
participant Scheduler as 调度器(内存)
User->>Bot: 创建定时任务请求
Bot->>Cron: create(action, payload)
Cron->>Cron: 解析时间/间隔与类型
Cron->>DB: 插入任务记录
DB-->>Cron: 任务ID/记录
Cron->>Scheduler: 计算下次触发并注册回调
Scheduler-->>Cron: 返回注销句柄
Cron-->>User: 返回创建结果与任务信息
Note over Scheduler,Cron: 到期触发
Scheduler->>Cron: 执行任务回调
Cron->>Bot: 根据类型发送通知/执行命令
Cron->>DB: 更新 lastCall/重复任务下一次时间
sequenceDiagram
autonumber
participant User as 用户
participant Bot as Bot/Plugin
participant FS as UpdateFileTool
participant Store as FileStore
User->>Bot: 请求更新文件(路径、查找、替换、次数)
Bot->>FS: call(update params)
FS->>Store: updateFile(scope, path, find, replace, count)
Store->>Store: 读取/过滤忽略/替换并写回
Store-->>FS: 成功标志、替换数、上下文片段
FS-->>User: 文本结果(含上下文)
sequenceDiagram
autonumber
participant User as 用户
participant Bot as Bot/Plugin
participant Todos as TodosTool
participant Store as TodoState
User->>Bot: action=batch_set, updates=[{id,status}...]
Bot->>Todos: _call(payload)
Todos->>Todos: 校验顺序与状态合法性
alt 有非法顺序/状态
Todos-->>User: 返回可读错误信息
else 全部合法
Todos->>Store: 依序应用更新
Todos-->>User: 返回进度清单与完成提示(若全部完成)
end
Estimated code review effort🎯 4 (复杂) | ⏱️ ~60 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @dingyi222666, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a major shift in the core AI experience by migrating from the ChatGPT preset to a more advanced Sydney preset, while simultaneously streamlining the system by removing the external dependency of the code sandbox feature. Beyond these core changes, significant enhancements have been made to task management, file system interactions, and group access controls, aiming to provide a more robust, intelligent, and configurable platform. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request successfully switches the default preset to "Sydney" and removes the code sandbox feature. It also introduces significant improvements to the cron and todos tools, making them more robust and feature-rich. The refactoring of the extension tools configuration into its own file is a good move for maintainability. I've found a few issues, including a bug where the default preset was not updated in the configuration, some inconsistencies in error handling, and potential improvements in a few implementation details. Overall, this is a great set of changes that enhances the agent's capabilities.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…or handling - Remove codeSandbox boolean from config schema (already removed from plugin) - Change todos tool error throwing to return error messages for better tool chain stability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Nitpick comments (2)
packages/core/src/utils/logger.ts (1)
38-43: 改进跨平台兼容性的有效实现。时间戳格式的更改解决了跨平台文件名兼容性问题(特别是 Windows 不允许文件名中包含冒号)。使用 UTC 时间戳确保了不同时区环境下的一致性。
可选的改进建议:可以添加注释说明生成的时间戳格式(
YYYY-MM-DD-HH-mm-ss)以提高代码可读性。如果需要,可以应用以下差异添加说明性注释:
+ // 生成文件名安全的 UTC 时间戳,格式:YYYY-MM-DD-HH-mm-ss const currentTime = new Date() .toISOString() .replace(/\..+/, '') .replaceAll(':', '-') .split('T') .join('-')packages/extension-tools/src/config.ts (1)
65-70: 移除已废弃的 codeSandbox 配置项
Line 68 仍保留codeSandbox开关,但该功能在本次改动中已经移除,继续暴露此项会让用户误以为功能仍然可用,也与 PR 目标不符。建议从 Schema 中删除这一字段,以免产生无效配置项。修改示例:- fs: Schema.boolean().default(false), - command: Schema.boolean().default(false), - codeSandbox: Schema.boolean().default(false), - cron: Schema.boolean().default(true) + fs: Schema.boolean().default(false), + command: Schema.boolean().default(false), + cron: Schema.boolean().default(true)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
packages/core/resources/presets/chatgpt.ymlis excluded by!**/*.ymlpackages/core/resources/presets/sydney.ymlis excluded by!**/*.ymlpackages/extension-tools/src/locales/en-US.schema.ymlis excluded by!**/*.ymlpackages/extension-tools/src/locales/zh-CN.schema.ymlis excluded by!**/*.yml
📒 Files selected for processing (11)
packages/core/src/config.ts(1 hunks)packages/core/src/preset.ts(1 hunks)packages/core/src/utils/logger.ts(1 hunks)packages/extension-tools/src/config.ts(1 hunks)packages/extension-tools/src/index.ts(2 hunks)packages/extension-tools/src/plugin.ts(0 hunks)packages/extension-tools/src/plugins/code_sandbox.ts(0 hunks)packages/extension-tools/src/plugins/cron.ts(3 hunks)packages/extension-tools/src/plugins/fs.ts(10 hunks)packages/extension-tools/src/plugins/group.ts(1 hunks)packages/extension-tools/src/plugins/todos.ts(11 hunks)
💤 Files with no reviewable changes (2)
- packages/extension-tools/src/plugins/code_sandbox.ts
- packages/extension-tools/src/plugin.ts
🧰 Additional context used
🧬 Code graph analysis (5)
packages/core/src/preset.ts (2)
packages/core/src/llm-core/chat/app.ts (1)
preset(344-346)packages/core/src/services/chat.ts (1)
preset(323-325)
packages/extension-tools/src/config.ts (1)
packages/core/src/services/chat.ts (1)
ChatLunaPlugin(594-781)
packages/extension-tools/src/plugins/fs.ts (1)
packages/extension-tools/src/plugin.ts (1)
plugin(17-47)
packages/extension-tools/src/plugins/cron.ts (2)
packages/extension-tools/src/config.ts (2)
Config(4-48)Config(50-248)packages/core/src/llm-core/platform/types.ts (1)
ChatLunaToolRunnable(107-115)
packages/extension-tools/src/plugins/group.ts (1)
packages/core/src/llm-core/platform/client.ts (1)
config(91-93)
🪛 GitHub Check: CodeFactor
packages/extension-tools/src/config.ts
[notice] 178-178: packages/extension-tools/src/config.ts#L178
This line has a length of 410. Maximum allowed is 160. (max-len)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build
- GitHub Check: lint
🔇 Additional comments (2)
packages/core/src/preset.ts (1)
215-215: 变更符合PR目标!将默认预设从 'chatgpt' 切换到 'sydney' 的更改正确实现了PR的目标。逻辑清晰,保持了原有的回退机制。
packages/core/src/config.ts (1)
125-125: 变更符合PR目标!将默认聊天模式从 'chat' 改为 'agent' 正确实现了PR的目标。
…isplay - Format logger timestamp code for better readability - Fix todos tool to show correct status markers based on actual todo status - [ ] for pending - [→] for in_progress - [-] for cancelled - [x] for completed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
♻️ Duplicate comments (1)
packages/extension-tools/src/plugins/todos.ts (1)
283-283: 状态标记仍然不准确(与先前审查重复)283 行始终发送
- [x] ${todo.title},无论实际状态如何。这与先前审查中标记的问题相同,会在状态为 pending、in_progress 或 cancelled 时误导用户。建议根据实际状态选择标记:
[ ]用于 pending[→]用于 in_progress[-]用于 cancelled[x]仅用于 completed应用此差异修复:
- await session.send(`- [x] ${todo.title}`) + const statusMark = + todo.status === 'completed' + ? '[x]' + : todo.status === 'in_progress' + ? '[→]' + : todo.status === 'cancelled' + ? '[-]' + : '[ ]' + await session.send(`- ${statusMark} ${todo.title}`)
🧹 Nitpick comments (1)
packages/extension-tools/src/config.ts (1)
174-178: 考虑提取超长的默认提示词。第 178 行包含一个长度为 410 字符的
drawPrompt默认值,超过了代码风格的 160 字符限制。虽然这是一个合理的默认值,但考虑提取到单独的常量以提高可读性:const DEFAULT_DRAW_PROMPT = `1girl, solo, female only, full body, masterpiece, highly detailed, game CG, spring, cherry blossoms, floating sakura, beautiful sky, park, extremely delicate and beautiful girl, high school girl, black blazer jacket, plaid skirt short_hair, blunt_bangs, white_hair/pink_eyes, two-tone hair, gradient hair, by Masaaki Sasamoto, best quality, masterpiece, highres, red-eyeshadow, lipstick.`然后在 Schema 中引用:
- drawPrompt: Schema.string() - .role('textarea') - .default( - `1girl, solo, female only, full body, masterpiece, highly detailed, game CG, spring, cherry blossoms, floating sakura, beautiful sky, park, extremely delicate and beautiful girl, high school girl, black blazer jacket, plaid skirt\nshort_hair, blunt_bangs, white_hair/pink_eyes, two-tone hair, gradient hair, by Masaaki Sasamoto, best quality, masterpiece, highres, red-eyeshadow, lipstick.` - ), + drawPrompt: Schema.string() + .role('textarea') + .default(DEFAULT_DRAW_PROMPT),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
packages/core/src/config.ts(1 hunks)packages/core/src/utils/logger.ts(1 hunks)packages/extension-tools/src/config.ts(1 hunks)packages/extension-tools/src/plugins/fs.ts(10 hunks)packages/extension-tools/src/plugins/todos.ts(10 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/extension-tools/src/plugins/fs.ts
- packages/core/src/config.ts
🧰 Additional context used
🧬 Code graph analysis (1)
packages/extension-tools/src/config.ts (1)
packages/core/src/services/chat.ts (1)
ChatLunaPlugin(594-781)
🪛 GitHub Check: CodeFactor
packages/extension-tools/src/config.ts
[notice] 178-178: packages/extension-tools/src/config.ts#L178
This line has a length of 410. Maximum allowed is 160. (max-len)
packages/core/src/utils/logger.ts
[warning] 38-38: packages/core/src/utils/logger.ts#L38
Replace .toISOString().slice(0,·19).replace('T',·'-') with ⏎········.toISOString()⏎········.slice(0,·19)⏎········.replace('T',·'-')⏎········ (prettier/prettier)
🪛 GitHub Check: lint
packages/core/src/utils/logger.ts
[failure] 38-38:
Replace .toISOString().slice(0,·19).replace('T',·'-') with ⏎········.toISOString()⏎········.slice(0,·19)⏎········.replace('T',·'-')⏎········
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (12)
packages/extension-tools/src/plugins/todos.ts (6)
51-99: 任务进度注入实现良好聊天前注入任务进度的实现很好:
- 将活跃任务状态清晰地嵌入提示上下文
- 使用直观的状态标记([✓]、[→]、[ ])
- 为 LLM 提供了明确的更新指令
- 正确使用 Document API 进行上下文增强
107-107: 批量更新功能架构合理batch_set 操作的 schema 扩展设计良好:
- action 枚举正确添加了 'batch_set'
- updates 字段定义清晰,类型安全
- 与现有代码集成流畅
Also applies to: 135-150, 164-164, 179-184
198-199: 错误处理改进正确将错误从抛出异常改为返回描述性字符串是正确的做法:
- 允许语言模型接收详细的错误信息
- 使 LLM 能够理解问题并重试
- 避免工具执行崩溃并返回通用错误
这解决了先前审查中对 310-312 行的关切。
Also applies to: 202-203, 247-247, 252-252, 257-258, 402-402, 407-407
263-273: 顺序验证逻辑实现正确强制顺序更新的验证逻辑设计良好:
- 正确验证前序任务必须完成或取消
- 适用于 'in_progress' 和 'completed' 状态变更
- 错误消息清晰,有助于 LLM 理解约束
319-359: 批量更新验证逻辑严谨批量更新的验证实现非常完善:
- 预先验证所有更新,避免部分应用
- 按索引排序确保顺序处理
- 正确应用顺序约束验证
- 返回清晰的错误消息
这确保了批量操作的原子性和一致性。
285-293: 任务完成检查和清理实现良好单个和批量更新中的完成检查逻辑一致且正确:
- 准确识别所有子任务完成或取消的情况
- 向用户发送完成通知
- 从存储中清理已完成任务数据
这确保了资源的正确管理和良好的用户体验。
Also applies to: 380-388
packages/extension-tools/src/config.ts (6)
1-3: 导入声明正确。导入的类型和模块都已正确使用。
4-48: 接口定义完整且类型正确。Config 接口正确扩展了 ChatLunaPlugin.Config,并包含了所有必要的功能特性配置。groupWhitelist 的添加符合 PR 目标。
50-75: Schema 基础结构合理。使用 Schema.intersect 组合多个配置对象,结构清晰,默认值设置合理。
244-247: i18n 配置正确。正确配置了中英文本地化支持,从 YAML 文件加载翻译是良好实践。
249-254: 依赖注入和插件元数据配置正确。
inject对象正确声明了必需和可选的依赖项,name导出符合 Koishi 插件命名规范。
4-243: 确认 code sandbox 配置已正确移除。针对之前审查中提到的
codeSandbox属性问题,我确认该配置已从此文件中完全移除,符合 PR 目标。配置接口和 Schema 中均未包含任何 code sandbox 相关的属性。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (3)
packages/core/src/utils/logger.ts (1)
38-42: 逻辑正确,但需要修复格式问题。使用
toISOString()替代本地化格式化确实提高了跨平台兼容性,符合 PR 目标。时间戳格式YYYY-MM-DD-HH-mm-ss生成逻辑正确。然而,之前的审查评论已经指出格式问题——链式调用应拆分为多行以符合 prettier 规范。请应用之前建议的修复。
packages/extension-tools/src/plugins/todos.ts (2)
381-382: 批量更新中的状态标记不完整批量更新的复选框逻辑仅区分 completed 和非 completed 状态,未反映 in_progress 和 cancelled:
const checkbox = updateInfo.status === 'completed' ? '[x]' : '[ ]'这与第 283-291 行使用的全面状态标记映射不一致。
应用此差异以保持一致:
- const checkbox = updateInfo.status === 'completed' ? '[x]' : '[ ]' + const checkbox = + updateInfo.status === 'completed' + ? '[x]' + : updateInfo.status === 'in_progress' + ? '[→]' + : updateInfo.status === 'cancelled' + ? '[-]' + : '[ ]' results.push(`- ${checkbox} ${todo.title}`)
419-423: get 操作中的状态标记不完整get 操作的复选框逻辑与其他地方存在相同问题,仅区分 completed 和非 completed:
const checkbox = todo.status === 'completed' ? '[x]' : '[ ]'为保持一致性并提供准确的状态信息,应使用与第 283-291 行相同的标记映射。
应用此差异:
.map((todo) => { - const checkbox = todo.status === 'completed' ? '[x]' : '[ ]' + const checkbox = + todo.status === 'completed' + ? '[x]' + : todo.status === 'in_progress' + ? '[→]' + : todo.status === 'cancelled' + ? '[-]' + : '[ ]' return `- ${checkbox} ${todo.title}${todo.description ? ` - ${todo.description}` : ''}` })
🧹 Nitpick comments (1)
packages/extension-tools/src/plugins/todos.ts (1)
75-80: 标记符号轻微不一致此处使用
[✓]表示已完成状态,而在其他位置(如第 283-290 行)使用[x]表示相同状态。建议统一使用相同的标记符号以保持一致性。应用此差异以统一标记符号:
const status = todo.status === 'completed' - ? '[✓]' + ? '[x]' : todo.status === 'in_progress' ? '[→]' : '[ ]'
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/core/src/utils/logger.ts(1 hunks)packages/extension-tools/src/plugins/todos.ts(10 hunks)
🔇 Additional comments (10)
packages/extension-tools/src/plugins/todos.ts (10)
107-107: LGTM!
batch_set操作的 schema 扩展正确,updates字段结构清晰且文档完善。Also applies to: 135-150
197-203: LGTM - 错误处理已改进将错误处理从抛出异常改为返回描述性字符串,这为 LLM 提供了更好的反馈。最少 3 个子任务的验证是合理的约束。
如果将来需要,可以考虑将此阈值设为可配置项。
263-273: LGTM - 顺序验证逻辑正确顺序验证确保任务按序更新,逻辑实现正确且错误消息清晰。
283-291: LGTM - 状态标记已修正状态标记映射现已全面实现,正确区分了所有四种状态(completed、in_progress、cancelled、pending)。这解决了之前审查中标记的问题。
293-301: LGTM!任务完成检查和存储清理逻辑正确,为用户提供了清晰的完成通知。
318-320: LGTM - 错误处理已改进现在返回描述性错误字符串而不是抛出异常,这解决了之前的审查意见,为 LLM 提供了更有用的反馈。
327-347: LGTM!批量更新验证逻辑正确,先验证所有更新,然后统一报告错误。这避免了部分更新的不一致状态。
354-367: LGTM!批量更新中的顺序验证逻辑正确,在排序后验证确保任务按序更新。
389-396: LGTM!批量更新的完成检查逻辑与单个更新一致,正确实现。
410-416: LGTM!错误处理已改进为返回描述性字符串,与其他方法保持一致。
This PR switches the default preset from ChatGPT to Sydney and removes the code sandbox feature that required external API dependencies.
New Features
groupWhitelistconfiguration optionRemovals
code_sandbox.tsplugin filecodeSandboxAPIKey,codeSandboxSelector)Other Changes
chattoagentfor better tool utilizationchatgpttosydney