Commit b3ba6b9
refactor(sources): unify root-fallback decision and short-circuit github root fetch
Follow-ups from the PR #2118 review.
Finding 1 (DRY): the "use the repo root as the requested skill" decision
was implemented twice with asymmetric gates — an explicit SKILL.md check
in the git path (`groupRemoteFilesBySkillRoot`) and a delegated check in
the github path (`discoverGithubSkillDirs`). Extract a shared
`shouldUseRootFallback({ skillFilter, isWildcard, hasRootSkillFile,
hasRequestedSkillDir })` used by both so they cannot drift.
Finding 2 (perf + behavior lock): the github fallback trigger was widened
in #2118 to fire whenever the requested dir is absent, which performed a
full root-file fetch even when the root had no SKILL.md to install. Detect
the root SKILL.md from the directory listing already in hand and gate on
it via the shared helper, so the full root fetch is short-circuited when
nothing would be installed. Add tests locking the intended behavior: the
root SKILL.md is installed under the requested name when it coexists with
real skill dirs and the requested skill is absent, and no root files are
fetched when there is no root SKILL.md.
Finding 3 (.gitignore drive-by): `.tokensave/` is a third-party byproduct
that no tool emits, so the hand-written .gitignore section is the correct
owner (per the gitignore guidelines); left as-is intentionally.
Closes #2119
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 43c3143 commit b3ba6b9
2 files changed
Lines changed: 108 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1247 | 1247 | | |
1248 | 1248 | | |
1249 | 1249 | | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
1250 | 1316 | | |
1251 | 1317 | | |
1252 | 1318 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
437 | 464 | | |
438 | 465 | | |
439 | 466 | | |
| |||
464 | 491 | | |
465 | 492 | | |
466 | 493 | | |
467 | | - | |
468 | | - | |
469 | 494 | | |
470 | | - | |
471 | | - | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
472 | 501 | | |
473 | 502 | | |
474 | 503 | | |
| |||
729 | 758 | | |
730 | 759 | | |
731 | 760 | | |
732 | | - | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
733 | 770 | | |
734 | 771 | | |
735 | 772 | | |
| |||
0 commit comments