Strip YAML frontmatter from skill files before passing to claude -p
The leading --- in YAML frontmatter was being interpreted as a CLI option by `claude -p`, causing "unknown option" errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>clickup-runner
parent
19f6ee94c6
commit
e51570b804
|
|
@ -1,5 +1,5 @@
|
||||||
"""Claude Code subprocess runner.
|
"""Claude Code subprocess runner.
|
||||||
|
NEW WORKING CODE
|
||||||
Builds prompts from skill files + task context, runs `claude -p`,
|
Builds prompts from skill files + task context, runs `claude -p`,
|
||||||
collects output files, and returns structured results.
|
collects output files, and returns structured results.
|
||||||
"""
|
"""
|
||||||
|
|
@ -286,9 +286,22 @@ def notify(
|
||||||
log.warning("Failed to send ntfy notification: %s", e)
|
log.warning("Failed to send ntfy notification: %s", e)
|
||||||
|
|
||||||
|
|
||||||
|
def _strip_frontmatter(text: str) -> str:
|
||||||
|
"""Remove YAML frontmatter (--- ... ---) from a markdown file."""
|
||||||
|
if not text.startswith("---"):
|
||||||
|
return text
|
||||||
|
end = text.find("---", 3)
|
||||||
|
if end == -1:
|
||||||
|
return text
|
||||||
|
return text[end + 3:].lstrip("\r\n")
|
||||||
|
|
||||||
|
|
||||||
def read_skill_file(route: SkillRoute, skills_dir: Path) -> str:
|
def read_skill_file(route: SkillRoute, skills_dir: Path) -> str:
|
||||||
"""Read a skill .md file and return its content.
|
"""Read a skill .md file and return its content.
|
||||||
|
|
||||||
|
Strips YAML frontmatter (skill registry metadata) since it's not
|
||||||
|
useful as prompt content and the leading --- breaks `claude -p`.
|
||||||
|
|
||||||
Raises FileNotFoundError if the skill file doesn't exist.
|
Raises FileNotFoundError if the skill file doesn't exist.
|
||||||
"""
|
"""
|
||||||
skill_path = skills_dir / route.skill_file
|
skill_path = skills_dir / route.skill_file
|
||||||
|
|
@ -296,4 +309,5 @@ def read_skill_file(route: SkillRoute, skills_dir: Path) -> str:
|
||||||
raise FileNotFoundError(
|
raise FileNotFoundError(
|
||||||
"Skill file not found: %s" % skill_path
|
"Skill file not found: %s" % skill_path
|
||||||
)
|
)
|
||||||
return skill_path.read_text(encoding="utf-8")
|
raw = skill_path.read_text(encoding="utf-8")
|
||||||
|
return _strip_frontmatter(raw)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue