|
56 | 56 | "dist", |
57 | 57 | } |
58 | 58 | BUILD_EXCLUDED_FILES = { |
| 59 | + "AGENTS.md", |
| 60 | + "CLAUDE.md", |
59 | 61 | ".astrbot-worker-state.json", |
60 | 62 | } |
61 | 63 | WATCH_POLL_INTERVAL_SECONDS = 0.5 |
|
72 | 74 | "opencode": "OpenCode", |
73 | 75 | } |
74 | 76 | INIT_SKILL_TEMPLATE_NAME = "astrbot-plugin-dev" |
| 77 | +INIT_PROJECT_NOTE_TEMPLATE_DIR = ("templates", "project_notes") |
| 78 | +INIT_PROJECT_NOTE_TEMPLATE_NAMES = ("AGENTS.md", "CLAUDE.md") |
75 | 79 |
|
76 | 80 |
|
77 | 81 | class _CliPluginValidationError(RuntimeError): |
@@ -866,6 +870,27 @@ def _render_init_agent_templates( |
866 | 870 | ) |
867 | 871 |
|
868 | 872 |
|
| 873 | +def _render_init_project_notes(*, target_dir: Path) -> None: |
| 874 | + template_root = resources.files("astrbot_sdk").joinpath( |
| 875 | + *INIT_PROJECT_NOTE_TEMPLATE_DIR |
| 876 | + ) |
| 877 | + if not template_root.is_dir(): |
| 878 | + raise _CliPluginValidationError("未找到项目级说明模板:AGENTS.md / CLAUDE.md") |
| 879 | + |
| 880 | + for template_name in INIT_PROJECT_NOTE_TEMPLATE_NAMES: |
| 881 | + template_path = template_root.joinpath(template_name) |
| 882 | + if not template_path.is_file(): |
| 883 | + raise _CliPluginValidationError( |
| 884 | + f"未找到项目级说明模板文件:{template_name}" |
| 885 | + ) |
| 886 | + # Keep these notes as packaged resources so `astr init` behaves the same |
| 887 | + # from a repo checkout, an sdist, and an installed wheel. |
| 888 | + (target_dir / template_name).write_text( |
| 889 | + template_path.read_text(encoding="utf-8"), |
| 890 | + encoding="utf-8", |
| 891 | + ) |
| 892 | + |
| 893 | + |
869 | 894 | def _ensure_plugin_dir_exists(plugin_dir: Path) -> Path: |
870 | 895 | resolved = plugin_dir.resolve() |
871 | 896 | if not resolved.exists() or not resolved.is_dir(): |
@@ -987,6 +1012,7 @@ def _init_plugin(name: str | None, agents: tuple[str, ...] = ()) -> None: |
987 | 1012 | _render_init_test_py(plugin_name=plugin_name), |
988 | 1013 | encoding="utf-8", |
989 | 1014 | ) |
| 1015 | + _render_init_project_notes(target_dir=target_dir) |
990 | 1016 | _render_init_agent_templates( |
991 | 1017 | target_dir=target_dir, |
992 | 1018 | plugin_name=plugin_name, |
|
0 commit comments