Commit 3fea8cf
authored
fix(skill): resolve references/ wikilinks whose stem contains a dot (#120)
* fix(skill): resolve references/ wikilinks whose stem contains a dot
`validate_skill` appended the implicit `.md` to a `[[references/...]]` link
only when `Path(link).suffix` was empty. `Path.suffix` returns everything
after the last dot, so a reference whose stem contains a dot — e.g.
`[[references/api.v2]]` or `[[references/v1.2-guide]]` — has a truthy suffix
(`.v2` / `.2-guide`). The `.md` was therefore never appended and the
validator looked for an extension-less `references/api.v2`, emitting a false
"doesn't exist" error even though `references/api.v2.md` is present and
correctly linked. (`WIKILINK_RE` allows `.` in the target, so such links are
legal and reach this branch.)
Append `.md` based on a literal `.md` check instead of `Path.suffix`, so a
dotted stem is suffixed correctly while an explicit `...md` link is left
alone. Genuinely missing references still error.
Adds a regression test for the dotted-stem case (the existing
`test_wikilink_without_md_suffix_resolves` only covered a dot-free stem).
* skill: reject references/ wikilinks that escape the references directory
Review feedback: WIKILINK_RE allows '.' and '/', so '[[references/../SKILL]]'
resolved outside references/ and was accepted whenever the resolved file
existed (and would crash the not-found message's relative_to(skill_dir)).
Reject any link whose resolved target is not under references/.1 parent 840f2b7 commit 3fea8cf
2 files changed
Lines changed: 40 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
214 | 224 | | |
215 | 225 | | |
216 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
262 | 288 | | |
263 | 289 | | |
264 | 290 | | |
| |||
0 commit comments