feat(service-git): add readFile, tags, and path-scoped log for read-only history browsing - #269
Merged
Merged
Conversation
…nly history browsing
✅ Deploy Preview for devfra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
antfu
approved these changes
Aug 20, 2026
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.
Closes #268.
Intent
Extend the built-in
@devframes/service-gitwire service with the three read-only patterns a downstream history/file browser (e.g.tsnapi's API-snapshot inspector) needs, so consumers can drive git browsing over RPC instead of shelling out. All additions are backward-compatible — existing ops' behavior and types are untouched.What's added
readFile({ path, ref? })→GitFile— raw contents of a single file at a commit-ish (defaultHEAD), the core primitive for browsing versioned files. Absence at the ref is a clearfound: false/content: nullsignal rather than a throw; binary blobs return withcontentomitted; oversized blobs are clipped withtruncated: true. Exact bytes are preserved (including trailing newline), and the client-supplied ref is guarded against option injection.tags()→GitTags— tags newest-first with target SHA, creation date, message subject, and anannotatedflag. Dates come fromcreatordate, so annotated tags populate their date (a naivecommitterdatewould be empty for them).log—LogArgsgains an optionalpaths?: string[](git log -- <paths>) to list only commits that touched given file(s)/director(ies), preserving the existingGitLog/Commitshape.Each read op is registered as a
type: 'query'RPC (agent-flagged read-only), mirrored in the two declaration merges that keep the surface typed for consumers, with the tsnapi API snapshot and the services guide updated accordingly.Tests
New cases cover file present vs. absent at a ref (plus the dashed-ref injection guard), annotated + lightweight tags with dates and ordering, and path-scoped log filtering. The out-of-repo degradation test now also exercises
tags/readFile.This PR was created with the help of an agent.