fix(cli): align ensureCheckout with PM-unified store layout#82
Merged
Conversation
`ensureCheckout` returned `<askHome>/github/checkouts/<owner>__<repo>/<ref>/` while `GithubSource.fetch` writes to `<askHome>/github/<host>/<owner>/<repo>/<tag>/`. The path mismatch caused `ask docs github:<owner>/<repo>` and `ask src …` to exit 0 with no output after a successful fetch — callers walked a directory that never exists. Switches `ensureCheckout` to `githubStorePath(askHome, 'github.com', owner, repo, ref)` so the lazy resolution path matches the eager fetcher exactly. Adds `ensure-checkout.integration.test.ts` which mocks the real fetch by writing to the PM-unified layout and asserts that both `ensureCheckout` and `runDocs` land on the same path — pinning the contract so the two pipelines cannot silently diverge again. Updates existing unit tests in `ensure-checkout.test.ts`, `cache-sharing.test.ts`, and `src.test.ts` to use the PM-unified layout in their pre-populated fixtures and structural assertions.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Deploying ask-registry with
|
| Latest commit: |
9f25e8f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6acdc6fc.ask-registry.pages.dev |
| Branch Preview URL: | https://amondnet-github-agent-skills.ask-registry.pages.dev |
Contributor
There was a problem hiding this comment.
No issues found across 5 files
Auto-approved: Aligns checkout paths with the unified store layout to fix a bug causing silent failures. Low-risk logic change with comprehensive integration and unit test coverage.
Architecture diagram
sequenceDiagram
participant User
participant CLI as CLI (docs/src command)
participant EC as ensureCheckout
participant GS as GithubSource
participant FS as Local Store (~/.ask/github/)
participant GH as GitHub API
User->>CLI: run "ask docs github:owner/repo"
CLI->>EC: ensureCheckout(spec)
Note over EC,FS: PATH RESOLUTION
EC->>EC: CHANGED: Compute checkoutDir using githubStorePath<br/>(github.com/owner/repo/ref)
EC->>FS: Check if directory exists
alt Cache Hit (Path Exists)
FS-->>EC: Directory found
else Cache Miss (Path Missing)
EC->>GS: fetch(repo, ref)
GS->>GH: Download repository source
GH-->>GS: Source Data
GS->>FS: CHANGED: Write to PM-unified layout<br/>(github.com/owner/repo/ref)
FS-->>GS: Success
GS-->>EC: Return storePath
end
EC-->>CLI: Return checkoutDir (Absolute Path)
Note over CLI,FS: CONTENT DISCOVERY
CLI->>CLI: findDocLikePaths(checkoutDir)
CLI->>FS: Read directory content at checkoutDir
alt Path Alignment Success (NEW)
FS-->>CLI: File list (README, /docs, etc.)
CLI->>User: Print documentation paths
else Path Mismatch (Legacy Bug)
Note over CLI,FS: Legacy path (checkouts/owner__repo) != Unified path
FS-->>CLI: Error / Directory Not Found
CLI->>User: Exit 0 (Silent - No Output)
end
Close the second silent-failure vector on the ref-candidate axis. `GithubSource.fetch` writes the store dir under the WINNING candidate — which may differ from the primary ref when a `fallbackRef` (monorepo tags like `ai@6.0.158`) wins, or when `cloneAtTag` rescues a non-`v` ref via `v<ref>`. Previously `ensureCheckout` discarded the fetch result and returned a `checkoutDir` computed solely from the primary `ref`, reproducing the same empty-output bug on a different axis. Now threads `FetchResult.storePath` through and uses it as the authoritative path, falling back to the pre-computed path only when the fetcher does not populate it (keeps cache-hit short-circuit and legacy test mocks working). Adds an integration test simulating a `fallbackRefs`-driven resolver and asserts `ensureCheckout` surfaces the fallback's on-disk path.
Merged
amondnet
added a commit
that referenced
this pull request
Apr 14, 2026
Strengthen the existing `.claude/agent-memory/` Gotcha to explicitly require that any agent-authored memory files be committed alongside the code change that produced them. Prevents accidental loss of cross-session agent learnings when PRs are squashed or when authors stage selectively. Also flushes the two silent-failure-hunter memory files that the agent updated after PR #82 merged — keeps `main` in sync with the current agent-memory state.
2 tasks
amondnet
added a commit
that referenced
this pull request
Apr 14, 2026
) Strengthen the existing `.claude/agent-memory/` Gotcha to explicitly require that any agent-authored memory files be committed alongside the code change that produced them. Prevents accidental loss of cross-session agent learnings when PRs are squashed or when authors stage selectively. Also flushes the two silent-failure-hunter memory files that the agent updated after PR #82 merged — keeps `main` in sync with the current agent-memory state.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ensureCheckoutreturned the legacygithub/checkouts/<owner>__<repo>/<ref>/path whileGithubSource.fetchwrites to the PM-unifiedgithub/github.com/<owner>/<repo>/<tag>/layout.ask docs github:<owner>/<repo>andask src …exit 0 with no output after a successful fetch — callers walked a non-existent directory andfindDocLikePathsreturned[].ensureCheckouttogithubStorePath(askHome, 'github.com', owner, repo, ref)so the lazy and eager pipelines agree on the exact same path.Changes
packages/cli/src/commands/ensure-checkout.ts— usegithubStorePathinstead of legacycheckouts/pathpackages/cli/test/commands/ensure-checkout.integration.test.ts— new integration test that mocks the real fetch by writing to the PM-unified layout and assertsensureCheckout+runDocsboth land on the same existing pathpackages/cli/test/commands/ensure-checkout.test.ts,cache-sharing.test.ts,src.test.ts— updated to use the PM-unified layout in fixtures and structural assertionsTest Plan
bun run --cwd packages/cli test test/commands/→ 57/57 passask docs github:agentskills/agentskillsnow prints the checkout root and/docssubdir instead of emitting nothingSummary by cubic
Aligns the CLI checkout path with the PM‑unified GitHub store layout and returns the fetcher’s actual store path when a fallback ref wins, so
ask docs/ask srcread the real directory and no longer emit empty output.ensureCheckoutnow resolves to~/.ask/github/github.com/<owner>/<repo>/<ref>/or the fetcher-reportedstorePath.githubStorePath(askHome, 'github.com', owner, repo, ref)and preferFetchResult.storePathwhen present to fix both naming and ref-candidate divergence.ensureCheckout↔GithubSource.fetch↔runDocspath agreement (including fallback-ref winner); updated unit tests and fixtures to the PM‑unified layout.Written for commit 9f25e8f. Summary will update on new commits.