|
| 1 | +--- |
| 2 | +name: adk-verify-snippets |
| 3 | +description: > |
| 4 | + Extracts and verifies the runnability and code coverage of all Python code blocks inside a Markdown file. |
| 5 | + Generates a detailed compilation and execution report. |
| 6 | +metadata: |
| 7 | + author: Antigravity |
| 8 | + version: 1.4.0 |
| 9 | +--- |
| 10 | + |
| 11 | +# Verify Markdown Snippets Skill |
| 12 | + |
| 13 | +This skill extracts all ` ```python ` blocks from a Markdown file, executes each |
| 14 | +one in a process-isolated environment using the bundled `run.py` harness, and |
| 15 | +generates a structured report covering load status, run status, and line |
| 16 | +coverage. |
| 17 | + |
| 18 | +> [!CAUTION] **STRICT READ-ONLY CONSTRAINT — READ THIS BEFORE DOING ANYTHING |
| 19 | +> ELSE** |
| 20 | +> |
| 21 | +> This skill is **read-only**. The agent **MUST NOT**: - **Modify** any file in |
| 22 | +> the repository (source, test, config, docs, or skill files — including this |
| 23 | +> SKILL.md). - **Delete** any file in the repository. - **Create** any new file |
| 24 | +> in the repository. |
| 25 | +> |
| 26 | +> The **only two write operations permitted** are: 1. Writing temporary `.py` |
| 27 | +> snippet files to a **system temp directory outside the repository**. 2. |
| 28 | +> Writing the final `<filename>_REPORT.md` into the **same directory as the |
| 29 | +> source Markdown file**. |
| 30 | +> |
| 31 | +> If in doubt, do not write. Any other mutation is a violation of this skill's |
| 32 | +> contract. |
| 33 | +
|
| 34 | +-------------------------------------------------------------------------------- |
| 35 | + |
| 36 | +## 🔧 Prerequisites |
| 37 | + |
| 38 | +1. **ADK Python environment**: Run from the repository root with the `uv` |
| 39 | + virtual environment active. |
| 40 | +2. **`coverage` package** *(optional)*: Enables per-snippet coverage reporting. |
| 41 | + Without it, coverage columns show `—`. |
| 42 | + |
| 43 | + ```bash |
| 44 | + uv pip install coverage |
| 45 | + ``` |
| 46 | + |
| 47 | +3. **Gemini API key**: Required only for snippets that instantiate an `Agent`, |
| 48 | + `App`, or `Workflow` (which make live Gemini API calls). Set one of: |
| 49 | + |
| 50 | + ```bash |
| 51 | + export GEMINI_API_KEY="your-key-here" |
| 52 | + # or |
| 53 | + export GOOGLE_API_KEY="your-key-here" |
| 54 | + ``` |
| 55 | + |
| 56 | + If both are set, `GEMINI_API_KEY` takes precedence. |
| 57 | + |
| 58 | +-------------------------------------------------------------------------------- |
| 59 | + |
| 60 | +## 🛠️ Usage |
| 61 | + |
| 62 | +```bash |
| 63 | +uv run --no-sync python .agents/skills/adk-verify-snippets/scripts/verify_md.py <path_to_markdown_file.md> |
| 64 | +``` |
| 65 | + |
| 66 | +The script prints progress for each snippet, then writes a report to |
| 67 | +**`<filename>_REPORT.md`** in the same directory as the source file and prints |
| 68 | +the full path on completion. |
| 69 | + |
| 70 | +**Report contents:** :- **Executive Summary table** — one row per snippet: |
| 71 | +preceding heading, Load phase status, Run phase status, coverage %, and error |
| 72 | +detail. |
| 73 | + |
| 74 | +- **Detailed section** — for each snippet: the extracted code block, full |
| 75 | + execution logs (stdout + stderr/traceback), and the coverage report. |
| 76 | + |
| 77 | +-------------------------------------------------------------------------------- |
| 78 | + |
| 79 | +## 📝 How Snippets Are Classified |
| 80 | + |
| 81 | +Each ` ```python ` block falls into one of these categories: |
| 82 | +
|
| 83 | +### 1. Runnability Test (has a module-level ADK component) |
| 84 | +
|
| 85 | +If the snippet assigns a `Workflow`, `Agent`, or `App` to a **module-level |
| 86 | +variable**, the runner executes it against the Gemini API. |
| 87 | +
|
| 88 | +- The variable name does not matter — the runner finds it automatically via |
| 89 | + `vars(module)`. |
| 90 | +- For multi-agent snippets, the runner identifies the root agent by excluding |
| 91 | + any agent that appears in another agent's `sub_agents` list. |
| 92 | +- To use a custom test prompt instead of the default `"Test input topic"`, |
| 93 | + define a module-level `test_input` string in the snippet. |
| 94 | +
|
| 95 | +If no module-level ADK component is found, the run phase is skipped and the |
| 96 | +report shows `➖ NO ADK COMPONENT`. |
| 97 | +
|
| 98 | +### 2. Loadability-Only (no ADK component) |
| 99 | +
|
| 100 | +The runner verifies the snippet compiles and imports without error. No API call |
| 101 | +is made. |
| 102 | +
|
| 103 | +### 3. Skipped (annotated with ignore) |
| 104 | +
|
| 105 | +Place `<!-- verify-snippets: ignore -->` immediately before the opening |
| 106 | +` ```python ` fence to exclude a block entirely. Use this for pseudo-code, |
| 107 | +illustrative examples, or snippets that require external setup. |
| 108 | +
|
| 109 | +````markdown |
| 110 | +<!-- verify-snippets: ignore --> |
| 111 | +```python |
| 112 | +# pseudo-code — not runnable as-is |
| 113 | +my_agent = Agent(model="gemini-ultra-hypothetical", ...) |
| 114 | +``` |
| 115 | +```` |
| 116 | +
|
| 117 | +The report shows these as `⏭️ SKIPPED`. |
| 118 | +
|
| 119 | +-------------------------------------------------------------------------------- |
| 120 | +
|
| 121 | +## ⚠️ Known Limitations |
| 122 | +
|
| 123 | +- **No shared state between snippets**: Each snippet runs in a fresh |
| 124 | + subprocess with no imports or variables carried over from previous snippets. |
| 125 | + A snippet that depends on code from an earlier block will fail with |
| 126 | + `NameError` or `ImportError`. Make each snippet self-contained, or annotate |
| 127 | + it with `<!-- verify-snippets: ignore -->`. |
| 128 | +- **120-second timeout**: Each snippet is killed after 120 seconds. Annotate |
| 129 | + long-running or blocking snippets with `<!-- verify-snippets: ignore -->`. |
| 130 | +- **Ignore annotation placement**: The `<!-- verify-snippets: ignore -->` |
| 131 | + annotation applies to the next ` ```python ` fence encountered. Blank lines |
| 132 | + between the annotation and the fence are tolerated, but any non-blank line |
| 133 | + (prose or a heading) cancels the annotation. |
| 134 | +- **Bare ` ``` ` closes the block**: The parser closes a Python block on the |
| 135 | + first bare ` ``` ` line (no language tag). A bare ` ``` ` appearing as |
| 136 | + content inside a snippet (e.g. to demonstrate Markdown syntax) will |
| 137 | + prematurely close the block. Annotate such snippets with |
| 138 | + `<!-- verify-snippets: ignore -->`. |
| 139 | +
|
| 140 | +-------------------------------------------------------------------------------- |
| 141 | +
|
| 142 | +## ⚠️ Behavioral Constraints (For AI Agents) |
| 143 | +
|
| 144 | +- **Read-only**: See the caution block at the top. The constraint is absolute. |
| 145 | +- **Report only, do not fix**: The agent MUST NOT rewrite the source Markdown, |
| 146 | + modify code blocks, or generate patches. Present the summary table to the |
| 147 | + user and stop. |
| 148 | +- **Present the summary table verbatim**: After the script completes, read the |
| 149 | + generated `_REPORT.md` and copy the Executive Summary table to the user |
| 150 | + **exactly as written** — same six columns, same order, no renaming or |
| 151 | + dropping: `Snippet | Preceding Heading | Load Phase | Run Phase | Coverage | |
| 152 | + Details` |
0 commit comments