Skip to main content

extract_documented_invocation

Function extract_documented_invocation 

Source
pub fn extract_documented_invocation(skill_md: &str) -> Option<String>
Expand description

Pull the text of the SKILL.md that documents the CLI invocation, so flag- drift extraction reads only the documented invocation area (not the templated prose/footguns/metadata). Returns None when the skill is a pure library.

Two signals, in order:

  1. A ## Invocation heading — the section the skillpack CLI template emits. skillpack libraries use ## Usage (never ## Invocation), so this cleanly separates the two for generated packs.
  2. A fenced code block containing a --flag token — the fallback for hand-written skills (e.g. the broken-cli fixture) that document a CLI without the ## Invocation heading. A pure-library import block (import { parse } from 'x') has no --flag, so it correctly stays a library (Bug 2 + Improvement F, without the prose false-positives that scoping to the whole body would reintroduce).