Skip to content

Commit 6056d83

Browse files
committed
uv环境管理,hatchling构建
2 parents 0ee2d25 + 2d00cd8 commit 6056d83

6 files changed

Lines changed: 78 additions & 7 deletions

File tree

astrbot-sdk/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ repository.
66
- `src/astrbot_sdk/` keeps the runtime SDK package plus the minimal testing
77
helpers that AstrBot and SDK-generated templates still treat as part of the
88
vendored contract
9-
- developer templates and embedded markdown reference files are excluded
9+
- agent skill templates and embedded markdown reference files are excluded
10+
- root project-note templates for `astr init` stay vendored because the CLI
11+
still generates `AGENTS.md` / `CLAUDE.md` by default
1012
- `pyproject.toml` keeps the src-layout package discovery but drops dev/test-only metadata
1113
- `VENDORED.md` describes the vendoring contract
1214
- tests, docs, CI files, and other source-repo-only content stay outside this directory

astrbot-sdk/VENDORED.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ via `git subtree`.
88
- Vendored snapshots keep the runtime SDK plus the minimal testing helpers
99
(`testing.py`, `_testing_support.py`, `_internal/testing_support.py`) because
1010
AstrBot and SDK-generated test templates still depend on them.
11-
- Vendored snapshots exclude developer skill templates and markdown reference
12-
assets that are not needed by the subtree consumer.
11+
- Vendored snapshots exclude agent skill templates and markdown reference
12+
assets that are not needed by the subtree consumer, but retain the default
13+
`AGENTS.md` / `CLAUDE.md` project-note templates used by `astr init`.
1314
- `vendor/pyproject.toml` keeps src-layout package discovery, but strips
1415
test/dev-only sections so the subtree stays runtime-focused.
1516
- Do not edit vendored files directly inside the AstrBot main repository.

astrbot-sdk/pyproject.toml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
[build-system]
2-
requires = ["setuptools>=80", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "astrbot-sdk"
77
version = "0.1.0"
88
description = "AstrBot SDK with v4 runtime, worker protocol, and plugin tooling"
99
readme = "README.md"
1010
requires-python = ">=3.12"
11+
classifiers = [
12+
"Operating System :: OS Independent",
13+
"Programming Language :: Python :: 3",
14+
"Programming Language :: Python :: 3 :: Only",
15+
"Programming Language :: Python :: 3.12",
16+
"Programming Language :: Python :: 3.13",
17+
"Programming Language :: Python :: 3.14",
18+
]
1119
dependencies = [
1220
"aiohttp>=3.13.2",
1321
"anthropic>=0.72.1",
@@ -26,5 +34,17 @@ dependencies = [
2634
[project.scripts]
2735
astr = "astrbot_sdk.cli:cli"
2836

29-
[tool.setuptools.packages.find]
30-
where = ["src"]
37+
[tool.hatch.build.targets.wheel]
38+
packages = ["src/astrbot_sdk"]
39+
exclude = ["/src/astrbot_sdk/AGENTS.md"]
40+
41+
[tool.hatch.build.targets.sdist]
42+
include = [
43+
"/src",
44+
"/README.md",
45+
"/LICENSE",
46+
]
47+
48+
# ============================================================
49+
# Optional Dependencies
50+
# ============================================================

astrbot-sdk/src/astrbot_sdk/cli.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
"dist",
5757
}
5858
BUILD_EXCLUDED_FILES = {
59+
"AGENTS.md",
60+
"CLAUDE.md",
5961
".astrbot-worker-state.json",
6062
}
6163
WATCH_POLL_INTERVAL_SECONDS = 0.5
@@ -72,6 +74,8 @@
7274
"opencode": "OpenCode",
7375
}
7476
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")
7579

7680

7781
class _CliPluginValidationError(RuntimeError):
@@ -866,6 +870,27 @@ def _render_init_agent_templates(
866870
)
867871

868872

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+
869894
def _ensure_plugin_dir_exists(plugin_dir: Path) -> Path:
870895
resolved = plugin_dir.resolve()
871896
if not resolved.exists() or not resolved.is_dir():
@@ -987,6 +1012,7 @@ def _init_plugin(name: str | None, agents: tuple[str, ...] = ()) -> None:
9871012
_render_init_test_py(plugin_name=plugin_name),
9881013
encoding="utf-8",
9891014
)
1015+
_render_init_project_notes(target_dir=target_dir)
9901016
_render_init_agent_templates(
9911017
target_dir=target_dir,
9921018
plugin_name=plugin_name,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# AGENTS.md
2+
3+
## AstrBot Plugin Notes
4+
5+
- Prefer raising `AstrBotError` from `astrbot_sdk.errors` for expected failures.
6+
- Reuse stable `ErrorCodes` and factory helpers instead of inventing ad-hoc `{"error": ...}` payloads.
7+
- Validate the generated plugin with `astrbot-sdk validate --plugin-dir .` before packaging or sharing it.
8+
- Run `python -m pytest tests/test_plugin.py -v` after changing plugin behavior so the sample harness contract stays honest.
9+
- `astrbot-sdk build --plugin-dir .` should create the release zip without development-only files such as `AGENTS.md`, `CLAUDE.md`, `.claude/`, `.agents/`, or `.opencode/`.
10+
11+
- 除非有充分理由,插件的直接依赖应声明已验证的最低兼容版本。若已知存在不兼容的大版本或问题版本,应同时补充上界或排除约束
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# AGENTS.md
2+
3+
## AstrBot Plugin Notes
4+
5+
- Prefer raising `AstrBotError` from `astrbot_sdk.errors` for expected failures.
6+
- Reuse stable `ErrorCodes` and factory helpers instead of inventing ad-hoc `{"error": ...}` payloads.
7+
- Validate the generated plugin with `astrbot-sdk validate --plugin-dir .` before packaging or sharing it.
8+
- Run `python -m pytest tests/test_plugin.py -v` after changing plugin behavior so the sample harness contract stays honest.
9+
- `astrbot-sdk build --plugin-dir .` should create the release zip without development-only files such as `AGENTS.md`, `CLAUDE.md`, `.claude/`, `.agents/`, or `.opencode/`.
10+
11+
- 除非有充分理由,插件的直接依赖应声明已验证的最低兼容版本。若已知存在不兼容的大版本或问题版本,应同时补充上界或排除约束

0 commit comments

Comments
 (0)