✨ feat(skills): add tsl syntax reference skill
This commit is contained in:
@@ -7,10 +7,6 @@ from pathlib import Path
|
||||
|
||||
|
||||
DEFAULT_OUTPUT = Path("tmp") / "tsl-playbook"
|
||||
API_REFERENCE_BULLET = (
|
||||
"- 查 API / 函数的名字、参数、返回值和示例时,使用 "
|
||||
"`tsl-api-reference` skill;已知名走 `--name`,未知名走 `--kw`。"
|
||||
)
|
||||
|
||||
|
||||
def copy_tree(src: Path, dst: Path) -> None:
|
||||
@@ -20,24 +16,19 @@ def copy_tree(src: Path, dst: Path) -> None:
|
||||
def build_agents_text(ruleset_path: Path) -> str:
|
||||
text = ruleset_path.read_text(encoding="utf-8")
|
||||
text = text.replace("# TSL 智能体规则", "# TSL Agent Instructions", 1)
|
||||
if API_REFERENCE_BULLET not in text:
|
||||
marker = (
|
||||
"- 需要任何 TSL 语法、文件模型、函数、模块或金融数据事实时,"
|
||||
"第一跳统一进 `docs/tsl/index.md`,由它路由到具体页;"
|
||||
"不在本文件内猜文件路径,也不全目录搜索。"
|
||||
)
|
||||
text = text.replace(marker, f"{marker}\n{API_REFERENCE_BULLET}", 1)
|
||||
return text.rstrip("\n") + "\n"
|
||||
|
||||
|
||||
def ensure_sources(repo_root: Path) -> tuple[Path, Path, Path]:
|
||||
def ensure_sources(repo_root: Path) -> tuple[Path, Path, Path, Path]:
|
||||
docs_tsl = repo_root / "docs" / "tsl"
|
||||
skill = repo_root / "skills" / "tsl-api-reference"
|
||||
syntax_skill = repo_root / "skills" / "tsl-syntax-reference"
|
||||
api_skill = repo_root / "skills" / "tsl-api-reference"
|
||||
ruleset = repo_root / "rulesets" / "tsl" / "index.md"
|
||||
missing = [str(path) for path in (docs_tsl, skill, ruleset) if not path.exists()]
|
||||
sources = (docs_tsl, syntax_skill, api_skill, ruleset)
|
||||
missing = [str(path) for path in sources if not path.exists()]
|
||||
if missing:
|
||||
raise FileNotFoundError("missing source path(s): " + ", ".join(missing))
|
||||
return docs_tsl, skill, ruleset
|
||||
return sources
|
||||
|
||||
|
||||
def clean_output(output: Path, repo_root: Path) -> None:
|
||||
@@ -56,14 +47,15 @@ def clean_output(output: Path, repo_root: Path) -> None:
|
||||
|
||||
|
||||
def build(output: Path, repo_root: Path) -> None:
|
||||
docs_tsl, skill, ruleset = ensure_sources(repo_root)
|
||||
docs_tsl, syntax_skill, api_skill, ruleset = ensure_sources(repo_root)
|
||||
clean_output(output, repo_root)
|
||||
|
||||
(output / "AGENTS.md").write_text(
|
||||
build_agents_text(ruleset), encoding="utf-8", newline="\n"
|
||||
)
|
||||
copy_tree(docs_tsl, output / "docs" / "tsl")
|
||||
copy_tree(skill, output / "skills" / "tsl-api-reference")
|
||||
copy_tree(syntax_skill, output / "skills" / "tsl-syntax-reference")
|
||||
copy_tree(api_skill, output / "skills" / "tsl-api-reference")
|
||||
|
||||
|
||||
def main(argv=None) -> int:
|
||||
|
||||
Reference in New Issue
Block a user