Commit abd2923
committed
test(skills): direct unit tests for skill_runner/skills/critique-slash + doc fix
Three follow-up items from the architectural review (scores 60-70):
1. **openkb/skill/generator.py docstring** — claimed "future targets
plug in by declaring an output dir and a validator" but no plug-in
registry exists; current dispatch is a literal ``if target_type ==
"skill"`` else-branch. Reworded to be honest about scope and to
point at the deferred-followups entry for the registry refactor.
2. **tests/test_skill_runner.py** (NEW, 8 tests) — direct coverage of
the function every CLI/chat path now funnels through:
- SkillNotFoundError lists what IS available
- body lands in agent.instructions with "## User intent" section
- write_file + read_output_or_skill_file tools wired
- output_path_template substitutes {slug} and enforces post-run
existence
- od.mode=="deck" triggers validate_deck with the skill's grammar
- od.mode missing or non-deck skips validation
- MaxTurnsExceeded → RuntimeError with skill-name + step-cap info
- default max_turns matches MAX_TURNS constant
3. **tests/test_skills.py** (NEW, 16 tests) — direct coverage of the
scanner & frontmatter parser:
- empty when no roots exist
- SDK shape (name/description/path, path absolute)
- skips dirs without SKILL.md
- skips skills missing description
- falls back to dir name when frontmatter omits name (pinned as
intentional sane-default, not a bug)
- truncates description to 1024 chars
- first-hit-wins precedence across roots
- extra_roots appended after defaults (doesn't override)
- DEFAULT_SKILL_ROOTS constant pinned
- frontmatter: happy path, no-delim, unclosed, malformed YAML,
non-dict YAML, body-containing-dashes preservation
- autouse $HOME isolation so the user's real ~/.claude/skills
doesn't pollute test results
4. **tests/test_critique_slash.py** (NEW, 6 tests) — direct coverage
of /critique <path> chat slash:
- no arg → usage print, no run_skill call
- missing file → [ERROR], no run_skill call
- happy path → run_skill called with openkb-html-critic + relative
path in intent
- absolute path inside KB → converted to relative form
- SkillNotFoundError → [ERROR] (does not crash chat turn)
- RuntimeError → [ERROR] (does not propagate)
Regression: 569 tests pass (was 539; net +30 new tests in this commit).
The fifth deferred follow-up — bitmap image inline handling — is out
of scope (no concrete user need yet). The Generator if/else → registry
refactor and the chat-freeform iteration-backup gap stay deferred per
the original PR description.1 parent 916b938 commit abd2923
3 files changed
Lines changed: 667 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
0 commit comments