feat(skiff): align CLI with Vercel skills and fix entry symlink
Replace install/uninstall with add/remove, add publish for git ops in ~/.skills, and resolve bin/skiff symlinks so commands work from any cwd. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from skiff.paths import SKILLS_DIR, TEMPLATE_DIR, ensure_skills_home
|
||||
@@ -53,6 +54,45 @@ def resolve_skill_source(name: str, *, source: str | None = None) -> tuple[Path,
|
||||
raise SystemExit(f"找不到 skill: {name}")
|
||||
|
||||
|
||||
def read_skill_meta(skill_dir: Path) -> dict[str, str]:
|
||||
skill_md = skill_dir / "SKILL.md"
|
||||
if not skill_md.is_file():
|
||||
return {}
|
||||
text = skill_md.read_text(encoding="utf-8")
|
||||
if not text.startswith("---"):
|
||||
return {}
|
||||
end = text.find("\n---", 3)
|
||||
if end == -1:
|
||||
return {}
|
||||
frontmatter = text[3:end]
|
||||
meta: dict[str, str] = {}
|
||||
|
||||
name_match = re.search(r"^name:\s*(.+)$", frontmatter, re.MULTILINE)
|
||||
if name_match:
|
||||
meta["name"] = name_match.group(1).strip().strip("\"'")
|
||||
|
||||
desc_match = re.search(
|
||||
r"^description:\s*(?:>-|>\||>|-)?\s*\n((?:[ \t].+\n?)+)",
|
||||
frontmatter,
|
||||
re.MULTILINE,
|
||||
)
|
||||
if desc_match:
|
||||
lines = [line.strip() for line in desc_match.group(1).splitlines() if line.strip()]
|
||||
meta["description"] = " ".join(lines)
|
||||
else:
|
||||
inline = re.search(r"^description:\s*(.+)$", frontmatter, re.MULTILINE)
|
||||
if inline:
|
||||
meta["description"] = inline.group(1).strip().strip("\"'")
|
||||
|
||||
return meta
|
||||
|
||||
|
||||
def skill_description(name: str) -> str | None:
|
||||
meta = read_skill_meta(SKILLS_DIR / name)
|
||||
desc = meta.get("description")
|
||||
return desc.strip() if desc else None
|
||||
|
||||
|
||||
def validate_skill_name(name: str) -> None:
|
||||
import re
|
||||
|
||||
|
||||
Reference in New Issue
Block a user