Files
.pouch/skiff/agents.py
T
laily f1ed320991 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>
2026-07-04 12:11:53 +08:00

41 lines
1.1 KiB
Python

"""Agent 名称解析(兼容 Vercel skills CLI 别名)。"""
from __future__ import annotations
from skiff.paths import ALL_TARGETS
AGENT_ALIASES: dict[str, str] = {
"cursor": "cursor",
"claude": "claude",
"claude-code": "claude",
"codex": "codex",
"*": "*",
}
AGENT_CHOICES = sorted({*ALL_TARGETS, *AGENT_ALIASES.keys()})
def flatten_agent_args(groups: list[list[str]] | None) -> list[str] | None:
if not groups:
return None
flat = [item for group in groups for item in group]
return flat or None
def resolve_agent_args(agents: list[str] | None) -> list[str]:
if not agents or agents == ["*"] or "*" in agents:
return list(ALL_TARGETS)
resolved: list[str] = []
for raw in agents:
key = raw.lower()
if key == "*":
return list(ALL_TARGETS)
target = AGENT_ALIASES.get(key)
if target is None:
choices = ", ".join(AGENT_CHOICES)
raise SystemExit(f"未知 agent: {raw!r},可选: {choices}")
if target != "*" and target not in resolved:
resolved.append(target)
return resolved