023 box heads: one head band per box under its top border; in widget mode its controls join the widget title band. 024 Match card content: merge cards show their diff (the runner previews a review's tree against its worktree HEAD), every card carries legal and architecture scores, the null under command cards is gone. 025 Radio speak card: no hint text, a rounder flowing card, a MAYDAY toggle beside push to talk. 026 widget zoom: zoom a widget's content by keyboard and the context menu. 027 slash skill suggestions: every field that messages agents suggests skills after a slash, from a skills index the tree timer writes. 028 Resources accounts: an Accounts panel (provider, renewal, resets, usage and remaining, host-local, emails never in git) and panel checkboxes. 029 Controls layout: Rules and Groups pages laid out. 030 Yes/No answers as buttons, and nothing hides: rows the runner cannot run stay greyed with the reason. 031 mic in fields. Line comments (operator 2026-11-24): wherever code waits for a grant (Waits on Operator, the stream, the review overlay) selected lines or a right-clicked row take a comment that marks its lines and collects on the card; Deny opens with them as the reason and Call preselected, Grant sends them after the signed grant as one post. Requirement 003 decision 4 and its contract follow. Tests are written for every requirement and run once on this head. 🎯 Fix: 80 % 💥 Break: 20 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: ~95 % 🏆 Score: 61 🚦 Gate: ⛔ fix 80 % < 90, break 20 % > 5; security ~95 % < 100: ask the operator before the commit Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
144 lines
5.2 KiB
Python
Executable File
144 lines
5.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Args:
|
|
--home: the home whose ~/.claude/skills and ~/.agents/skills are read.
|
|
--tree: the branch-tree.json pkgmgr branch tree writes; each of its
|
|
repositories' .claude/skills and .agents/skills are read.
|
|
--output: the index the Agent Orchestrator serves at /api/skills, e.g.
|
|
~/.local/state/pkgmgr/tree/skills-index.json.
|
|
|
|
Returns:
|
|
Runs on the host, because the hub's container sees no repository:
|
|
replaces --output with {"written": <epoch>, "skills": [{"name",
|
|
"description", "source"}]}, one entry per skill folder holding a
|
|
SKILL.md, sorted by name and source; source is ~/.claude/skills,
|
|
~/.agents/skills or the repository's path. The exit code is 0.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import os
|
|
import re
|
|
import stat
|
|
import tempfile
|
|
import time
|
|
from pathlib import Path
|
|
|
|
HOME_SOURCES = (".claude/skills", ".agents/skills")
|
|
SKILL_FILE = "SKILL.md"
|
|
HEAD_BYTES = 16384
|
|
TREE_BYTES = 8 << 20
|
|
NAME = re.compile(r"[A-Za-z0-9:_.-]{1,100}")
|
|
DESCRIPTION_CHARS = 300
|
|
FIELD = re.compile(r"^(name|description):[ \t]*(.*)$")
|
|
BLOCKS = (">", "|", ">-", "|-", ">+", "|+")
|
|
|
|
|
|
def read_head(path: Path, limit: int) -> str:
|
|
"""Returns:
|
|
The first limit bytes of path as text, read without following a
|
|
symlink and only from a regular file.
|
|
|
|
Raises:
|
|
OSError: path is missing, a symlink or no regular file.
|
|
"""
|
|
handle = os.open(path, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK)
|
|
with os.fdopen(handle, "rb") as stream:
|
|
if not stat.S_ISREG(os.fstat(stream.fileno()).st_mode):
|
|
raise OSError(f"{path}: no regular file")
|
|
return stream.read(limit).decode("utf-8", "replace")
|
|
|
|
|
|
def front_matter(text: str) -> dict[str, str]:
|
|
"""Returns:
|
|
name and description from the YAML front matter that opens text,
|
|
each one line with its quotes stripped, a folded or literal block
|
|
joined into it; none without a closed front matter.
|
|
"""
|
|
lines = text.splitlines()
|
|
if not lines or lines[0].strip() != "---":
|
|
return {}
|
|
found, folding = {}, None
|
|
for line in lines[1:]:
|
|
if line.strip() == "---":
|
|
return {key: " ".join(value.split()) for key, value in found.items()}
|
|
match = FIELD.match(line)
|
|
if match:
|
|
value = match.group(2).strip()
|
|
folding = match.group(1) if value in BLOCKS else None
|
|
found[match.group(1)] = "" if folding else value.strip("\"'")
|
|
elif folding and line[:1] in (" ", "\t"):
|
|
found[folding] += f" {line.strip()}"
|
|
else:
|
|
folding = None
|
|
return {}
|
|
|
|
|
|
def skill_of(folder: Path, source: str) -> dict | None:
|
|
"""Returns:
|
|
{name, description, source} of a skill folder: the front matter's
|
|
name, else the folder's; None without a readable SKILL.md or with a
|
|
name outside NAME.
|
|
"""
|
|
try:
|
|
fields = front_matter(read_head(folder / SKILL_FILE, HEAD_BYTES))
|
|
except OSError:
|
|
return None
|
|
name = fields.get("name") or folder.name
|
|
if not NAME.fullmatch(name):
|
|
return None
|
|
return {"name": name, "description": fields.get("description", "")[:DESCRIPTION_CHARS], "source": source}
|
|
|
|
|
|
def skills_in(root: Path, source: str) -> list[dict]:
|
|
try:
|
|
folders = sorted(path for path in root.iterdir() if path.is_dir())
|
|
except OSError:
|
|
return []
|
|
return [found for folder in folders if (found := skill_of(folder, source)) is not None]
|
|
|
|
|
|
def repositories(tree: Path) -> list[str]:
|
|
"""Returns:
|
|
The absolute repository paths of the branch tree; none when it is
|
|
unreadable.
|
|
"""
|
|
try:
|
|
scan = json.loads(read_head(tree, TREE_BYTES))
|
|
except (OSError, ValueError, RecursionError):
|
|
return []
|
|
repos = scan.get("repos") if isinstance(scan, dict) else None
|
|
return sorted({repo["path"] for repo in repos if isinstance(repo, dict) and isinstance(repo.get("path"), str) and repo["path"].startswith("/")}) if isinstance(repos, list) else []
|
|
|
|
|
|
def index(home: Path, tree: Path) -> list[dict]:
|
|
found = [skill for part in HOME_SOURCES for skill in skills_in(home / part, f"~/{part}")]
|
|
found += [skill for repo in repositories(tree) for part in HOME_SOURCES for skill in skills_in(Path(repo) / part, repo)]
|
|
unique = {(skill["name"], skill["source"]): skill for skill in found}
|
|
return [unique[key] for key in sorted(unique)]
|
|
|
|
|
|
def write(output: Path, data: dict) -> None:
|
|
with tempfile.NamedTemporaryFile("w", encoding="utf-8", dir=output.parent, prefix=f".{output.name}.", delete=False) as handle:
|
|
try:
|
|
json.dump(data, handle)
|
|
except BaseException:
|
|
os.unlink(handle.name)
|
|
raise
|
|
os.replace(handle.name, output)
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description="Index the skills an agent message may name for the Agent Orchestrator.")
|
|
parser.add_argument("--home", type=Path, required=True)
|
|
parser.add_argument("--tree", type=Path, required=True)
|
|
parser.add_argument("--output", type=Path, required=True)
|
|
args = parser.parse_args()
|
|
write(args.output, {"written": time.time(), "skills": index(args.home, args.tree)})
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|