-
Notifications
You must be signed in to change notification settings - Fork 0
Fix zero value handling in CLI output and explicit file protocol configuration #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e5ad5e9
Initial plan
Copilot 0ca1734
Add tocFormat configuration with tree and compressed formats
Copilot 05a32f5
Add tests for TOC format configuration
Copilot 5d0d1e4
Address code review feedback and fix test failures
Copilot c8c4df3
Update compressed format to Vercel AGENTS.md style
Copilot 4475ded
Plan to remove frontmatter and update format
Copilot ff42056
Remove frontmatter and update TOC formats
Copilot 661f3c1
Update src/config.ts
fbosch f8b0018
Add test for toc=false backward compatibility
Copilot 7111ad1
fix(git): add force to detach checkout
fbosch ecefb9e
feat(git): add timeoutMs config for operations
fbosch beee886
feat(git): add persistent cache for repo fetches
fbosch 232fbc7
feat(git): add env config for cache dir
fbosch 93c6441
refactor: extract cache dir utilities to shared module
Copilot 880382c
docs: clarify timeoutMs is CLI-only option
Copilot 0ed8631
fix: handle zero values correctly and set explicit file protocol config
Copilot db81975
feat(toc): unify toc config into single field
fbosch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import { access, readdir, rm, stat } from "node:fs/promises"; | ||
| import { homedir } from "node:os"; | ||
| import path from "node:path"; | ||
|
|
||
| // Get platform-specific cache directory | ||
| const getCacheBaseDir = (): string => { | ||
| const home = homedir(); | ||
| switch (process.platform) { | ||
| case "darwin": | ||
| return path.join(home, "Library", "Caches"); | ||
| case "win32": | ||
| return process.env.LOCALAPPDATA || path.join(home, "AppData", "Local"); | ||
| default: | ||
| // Linux and other Unix-like systems (XDG Base Directory) | ||
| return process.env.XDG_CACHE_HOME || path.join(home, ".cache"); | ||
| } | ||
| }; | ||
|
|
||
| const resolveGitCacheDir = () => | ||
| process.env.DOCS_CACHE_GIT_DIR || | ||
| path.join(getCacheBaseDir(), "docs-cache-git"); | ||
|
fbosch marked this conversation as resolved.
Outdated
|
||
|
|
||
| const exists = async (filePath: string): Promise<boolean> => { | ||
| try { | ||
| await access(filePath); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } | ||
| }; | ||
|
|
||
| const getDirSize = async (dirPath: string): Promise<number> => { | ||
| try { | ||
| const entries = await readdir(dirPath, { withFileTypes: true }); | ||
| let totalSize = 0; | ||
|
|
||
| for (const entry of entries) { | ||
| const fullPath = path.join(dirPath, entry.name); | ||
| if (entry.isDirectory()) { | ||
| totalSize += await getDirSize(fullPath); | ||
| } else { | ||
| const stats = await stat(fullPath); | ||
| totalSize += stats.size; | ||
| } | ||
| } | ||
|
|
||
| return totalSize; | ||
| } catch { | ||
| return 0; | ||
| } | ||
| }; | ||
|
|
||
| const countCachedRepos = async (cacheDir: string): Promise<number> => { | ||
| try { | ||
| const entries = await readdir(cacheDir); | ||
| return entries.length; | ||
| } catch { | ||
| return 0; | ||
| } | ||
| }; | ||
|
|
||
| export type CleanGitCacheResult = { | ||
| removed: boolean; | ||
| cacheDir: string; | ||
| repoCount?: number; | ||
| bytesFreed?: number; | ||
| }; | ||
|
|
||
| export type CleanGitCacheOptions = { | ||
| json?: boolean; | ||
| }; | ||
|
|
||
| export const cleanGitCache = async ( | ||
| options: CleanGitCacheOptions = {}, | ||
| ): Promise<CleanGitCacheResult> => { | ||
| const cacheDir = resolveGitCacheDir(); | ||
| const cacheExists = await exists(cacheDir); | ||
|
|
||
| if (!cacheExists) { | ||
| return { | ||
| removed: false, | ||
| cacheDir, | ||
| }; | ||
| } | ||
|
|
||
| // Get stats before removal | ||
| const repoCount = await countCachedRepos(cacheDir); | ||
| const bytesFreed = await getDirSize(cacheDir); | ||
|
|
||
| // Remove the cache directory | ||
| await rm(cacheDir, { recursive: true, force: true }); | ||
|
|
||
| return { | ||
| removed: true, | ||
| cacheDir, | ||
| repoCount, | ||
| bytesFreed, | ||
| }; | ||
| }; | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ const COMMANDS = [ | |
| "sync", | ||
| "status", | ||
| "clean", | ||
| "clean-cache", | ||
| "prune", | ||
| "verify", | ||
| "init", | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.