From e9e7c7ff07ba6c2ca86584065b28f17a522be16c Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Mon, 23 Mar 2026 21:44:14 +0800 Subject: [PATCH] feat: add builtin tools module for _internal package --- astrbot/_internal/tools/builtin.py | 49 +++++++++++++++++++++++++++ openspec/config.yaml | 53 ++++++++++++++++++++---------- 2 files changed, 85 insertions(+), 17 deletions(-) create mode 100644 astrbot/_internal/tools/builtin.py diff --git a/astrbot/_internal/tools/builtin.py b/astrbot/_internal/tools/builtin.py new file mode 100644 index 000000000..335ebc991 --- /dev/null +++ b/astrbot/_internal/tools/builtin.py @@ -0,0 +1,49 @@ +""" +Builtin tools for AstrBot - re-exports from core.tools for backward compatibility. + +This module re-exports the builtin tools (cron, send_message, kb_query) from +the deprecated core.tools module for backward compatibility. + +TODO: These tools should be fully migrated to _internal and core.tools +should be removed once all consumers update their imports. +""" + +from __future__ import annotations + +# Re-export cron tools +from astrbot.core.tools.cron_tools import ( + CREATE_CRON_JOB_TOOL, + DELETE_CRON_JOB_TOOL, + LIST_CRON_JOBS_TOOL, + CreateActiveCronTool, + DeleteCronJobTool, + ListCronJobsTool, +) + +# Re-export send_message tool +from astrbot.core.tools.send_message import ( + SEND_MESSAGE_TO_USER_TOOL, + SendMessageToUserTool, +) + +# Re-export knowledge_base_query tool +from astrbot.core.tools.kb_query import ( + KNOWLEDGE_BASE_QUERY_TOOL, + KnowledgeBaseQueryTool, +) + +__all__ = [ + # Cron tools + "CREATE_CRON_JOB_TOOL", + "DELETE_CRON_JOB_TOOL", + "LIST_CRON_JOBS_TOOL", + "CreateActiveCronTool", + "DeleteCronJobTool", + "ListCronJobsTool", + # Send message tool + "SEND_MESSAGE_TO_USER_TOOL", + "SendMessageToUserTool", + # Knowledge base tool + "KNOWLEDGE_BASE_QUERY_TOOL", + "KnowledgeBaseQueryTool", +] diff --git a/openspec/config.yaml b/openspec/config.yaml index 392946c67..7a7784f8f 100644 --- a/openspec/config.yaml +++ b/openspec/config.yaml @@ -1,20 +1,39 @@ schema: spec-driven -# Project context (optional) -# This is shown to AI when creating artifacts. -# Add your tech stack, conventions, style guides, domain knowledge, etc. -# Example: -# context: | -# Tech stack: TypeScript, React, Node.js -# We use conventional commits -# Domain: e-commerce platform +# Project context +context: | + Tech stack: Python 3.12, anyio (async), FastAPI, pytest, ruff, uv + Domain: Multi-platform LLM chatbot framework (QQ, Telegram, Discord, etc.) + Architecture: Protocol-based system (LSP, MCP, ACP, ABP) -# Per-artifact rules (optional) -# Add custom rules for specific artifacts. -# Example: -# rules: -# proposal: -# - Keep proposals under 500 words -# - Always include a "Non-goals" section -# tasks: -# - Break tasks into chunks of max 2 hours +# Per-artifact rules +rules: + tasks: + - Break tasks into chunks of max 2 hours + - Always write tests for new functionality + - Run ruff and pytest before committing + code: + - Use absolute imports via `astrbot.` prefix + - Type hints required (no Any when possible) + - Comments in English + commits: + - Use conventional commits (feat:, fix:, docs:, refactor:, test:, chore:) + +# Project directives (最高旨意) +directives: + architecture: | + New architecture goes in _internal package to avoid branch conflicts. + Protocol system: LSP (client), MCP (client+server), ACP (client+server), ABP (client+server). + Runtime coordinates protocols, Gateway provides FastAPI backend. + Stars are plugins - Galaxy is the collection of stars. + async_library: | + Use anyio as the async library (not asyncio). + coverage: | + Coverage testing must be improved. + type_checking: | + Code must pass `uvx ty check` (astral's pyright). + Avoid using Any and cast. + code_style: | + Code must pass `ruff check .` and `ruff format .`. + execution: | + Always use `uv run` for running Python scripts, not bare `python`.