Skip to content

refactor(sources): unify root-fallback decision and short-circuit github root fetch#2198

Merged
dyoshikawa merged 1 commit into
mainfrom
resolve-issue-2119-root-fallback-dry
Jul 9, 2026
Merged

refactor(sources): unify root-fallback decision and short-circuit github root fetch#2198
dyoshikawa merged 1 commit into
mainfrom
resolve-issue-2119-root-fallback-dry

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Summary

Addresses the three non-blocking (low) follow-ups from the PR #2118 review.

Finding 1 — DRY: shared root-fallback decision

The "install the repo root as the single requested skill" decision was implemented twice with asymmetric gates:

  • git path (groupRemoteFilesBySkillRoot) — explicit hasRootSkillFile && !grouped.has(name) check.
  • github path (discoverGithubSkillDirs) — only gated on !hasRequestedSkillDir, delegating the SKILL.md check downstream.

Extracted a shared shouldUseRootFallback({ skillFilter, isWildcard, hasRootSkillFile, hasRequestedSkillDir }) used by both paths so they cannot drift.

Finding 2 — perf + behavior lock

#2118 widened the github fallback trigger to fire whenever the requested dir is absent, so fetchRootLevelFallbackSkill performed a full root-file fetch even when the root had no SKILL.md and nothing would be installed. Now the root SKILL.md is detected from the directory listing already in hand and gated via the shared helper, short-circuiting the fetch when there is nothing to install.

Added two tests to lock the intended behavior:

  • Root SKILL.md is installed under the requested name when it coexists with real skill dirs and the requested skill is absent (locks the widened-trigger edge case flagged in the review).
  • No root files are fetched (getFileContent not called) when the requested skill is absent and there is no root SKILL.md.

Finding 3 — .gitignore .tokensave/

.tokensave/ is a third-party byproduct that no tool emits, so per the gitignore guidelines (HAND_MAINTAINED_GITIGNORE_ENTRIES is for tool-external paths) the hand-written section is the correct owner. Left as-is intentionally; no code change.

Verification

  • New + existing sources.test.ts: 41 pass.
  • pnpm cicheck green (6920 unit tests).

Closes #2119

🤖 Generated with Claude Code

…hub 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>
@dyoshikawa dyoshikawa merged commit 8d8ac56 into main Jul 9, 2026
9 checks passed
@dyoshikawa

Copy link
Copy Markdown
Owner Author

@dyoshikawa Thank you!

@dyoshikawa dyoshikawa deleted the resolve-issue-2119-root-fallback-dry branch July 9, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow-ups from PR #2118 review: root-fallback DRY, widened github fallback trigger, and .gitignore drive-by

2 participants