Repository navigation
Conversation
# Conflicts: # package-lock.json # package.json # src/web/components/ScrapeFormContent.tsx # src/web/routes/jobs/new.tsx # src/web/routes/libraries/detail.tsx
Re-applies PR #458's Web UI wiring on top of the admin UI redesign, which removed the HTMX ScrapeFormContent/jobs/new/libraries-detail routes the original PR targeted. The checkbox lives in the Add/Edit documentation drawer's Advanced options and renders only for file:// sources, since the option has no effect on web crawls. Its *value* is submitted unconditionally, like every other option in the form: the CLI and MCP tool accept the flag for any URL, so gating the payload on the scheme would silently drop a stored setting whenever such a version was edited. For the same reason Library Detail's read-only row shows whenever the source is local or a value is stored. The local-URL test lives in the shared client format helpers as an exact, case-sensitive prefix match, so it agrees with ScraperRegistry's routing rather than promising the option for URLs the server sends elsewhere. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Addresses review findings on the original .gitignore work. Symlinks now follow git's semantics. The previous code tested both the file and the directory form and skipped on either, so a symlink pointing at a file whose name matched a directory-only rule was skipped where git keeps it. The link is now tested as a path first — still skipping a gitignored link without resolving its target — and the target is resolved only to decide whether a directory-only rule applies. An entry that cannot be stat'ed no longer fails its whole directory. A directory that is listable but not searchable makes lstat on its entries fail even though readdir succeeded, and with filtering enabled that error propagated out of the directory item; it is now skipped like a vanished entry, matching the pre-existing behaviour when filtering is off. .git is never indexed. Git excludes it from traversal unconditionally and no pattern can re-include it, but with hidden files enabled the crawler walked it. A crawl rooted below a repository root now logs a warning naming that root, since its rules are outside the evaluated scope — the case where results diverge most visibly from git. The probe is an existence check only and never reads outside the indexed folder. Also folds the repeated skip-result construction into one helper, drops the MCP schema's .default(false) so the field matches its neighbours, states the scope boundary in the CLI and MCP descriptions, and moves the e2e temp directories out of the repository working tree. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Follow-up to the previous commit, which only half-fixed the symlink semantics. Git records a symlink as a blob and never as a directory, so a directory-only rule does not match one *however it resolves* — confirmed against git 2.55: with `linkdir/` in .gitignore, a `linkdir` symlink pointing at a real directory is reported as not ignored. Resolving the target to decide was therefore both wrong and an unnecessary touch of a path outside the crawl. Symlinks are now tested as paths only, which is simpler, matches git, and restores the property that a gitignored link is skipped without its target being resolved at all. The contents of a followed symlink to a directory are still pruned by a directory-only rule naming the link, since the enclosing directory is matched as a directory when its rule context is built. Git lists the link and never descends; the crawler descends and indexes nothing inside. Both halves are now pinned by tests, the second by asserting the link is actually read — neither variant emits a page, so the event list alone cannot tell "kept, then pruned from within" from "skipped as ignored". Commits the differential test against real git that had been described in the design notes but only ever run by hand: it builds throwaway repositories, walks them with the crawler's prune-ignored-directories rule, and compares the visible file set against `git ls-files --others --exclude-standard` over curated pattern forms and a generated corpus. Its scope is the pattern rewriting and the cascade — it operates on regular files, so it would not have caught the symlink bug above, and the notes now say so. It lives in gitignore.test.ts per the single-file policy, pins core.excludesFile so a developer's global ignore file cannot fail it, and skips only outside CI. Also matches .git case-insensitively, mirroring git's protection of that spelling on case-insensitive volumes; keeps the repository-root probe walking past ancestors it cannot read; and adds the missing coverage for the repository-root warning. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The merge that brought PR #458 onto the redesigned admin UI resolved the package-lock conflict in favour of main, which dropped the entry for the `ignore` package that package.json declares. npm ci would have failed on a clean checkout. Regenerating the entry also syncs the lockfile's own version field, which had drifted behind package.json on main. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds an opt-in respectGitignore option to local file:// directory crawls so the scraper can skip paths matched by .gitignore rules (and prune ignored directories), with end-to-end plumbing through CLI, MCP, persisted scraper options, refresh behavior, and the React admin UI.
Changes:
- Implement
.gitignorerule evaluation and repository-root warning logic for local crawls. - Integrate ignore filtering into
LocalFileStrategytraversal + refresh deletions (including archives and symlink semantics). - Expose and persist the new option across CLI, MCP, pipeline/store, web UI, and tests/docs.
Reviewed changes
Copilot reviewed 26 out of 27 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/local-file-gitignore-e2e.test.ts | E2E coverage for .gitignore behavior, refresh deletions, symlinks, .git exclusion, and archive-member handling. |
| src/web/client/utils/format.ts | Adds isLocalFileUrl() helper used to gate local-only UI controls. |
| src/web/client/pages/library-detail/ScrapeConfigPanel.tsx | Displays stored respectGitignore (local-only unless a value is stored for non-local sources). |
| src/web/client/pages/library-detail/format.ts | Re-exports isLocalFileUrl for the Library Detail page formatting utilities. |
| src/web/client/components/AddEditDocumentationDrawer.tsx | Adds Advanced-option checkbox to set respectGitignore for file:// URLs and submits the option. |
| src/tools/ScrapeTool.ts | Plumbs respectGitignore into enqueue options. |
| src/tools/ScrapeTool.test.ts | Tests that respectGitignore is forwarded to the pipeline manager. |
| src/store/types.ts | Persists respectGitignore in VersionScraperOptions. |
| src/store/DocumentStore.test.ts | Verifies scraper options round-trip includes respectGitignore. |
| src/scraper/utils/gitignore.ts | Implements GitignoreFilter and findRepositoryRootAbove for scoped .gitignore evaluation. |
| src/scraper/utils/gitignore.test.ts | Unit + differential tests against real git for ignore semantics and repository-root probing. |
| src/scraper/types.ts | Adds respectGitignore to ScraperOptions. |
| src/scraper/strategies/LocalFileStrategy.ts | Builds and uses the filter during directory enumeration and item processing; warns on nested repo; handles refresh deletions and archives. |
| src/scraper/strategies/LocalFileStrategy.test.ts | Strategy-level tests for default behavior, pruning, nested rules, unreadable entries, and refresh deletions. |
| src/pipeline/PipelineManager.test.ts | Ensures refresh jobs reuse stored respectGitignore. |
| src/mcp/mcpServer.ts | Adds MCP scrape_docs schema + propagation for respectGitignore. |
| src/mcp/mcpServer.test.ts | Tests MCP schema and handler forwarding of respectGitignore. |
| src/cli/commands/scrape.ts | Adds --respect-gitignore flag and forwards it into scraper options. |
| src/cli/commands/scrape.test.ts | Tests CLI flag propagation into ScrapeTool. |
| package.json | Adds the ignore dependency. |
| package-lock.json | Updates lockfile for ignore dependency and version metadata. |
| openspec/changes/respect-gitignore-for-local-crawls/tasks.md | Tracks implementation tasks for the change. |
| openspec/changes/respect-gitignore-for-local-crawls/specs/local-file-ignore-rules/spec.md | Specifies requirements and scenarios for .gitignore filtering semantics. |
| openspec/changes/respect-gitignore-for-local-crawls/proposal.md | Proposal describing the option and scope/impact. |
| openspec/changes/respect-gitignore-for-local-crawls/design.md | Design rationale and behavior details (scope boundary, precedence, symlinks, refresh semantics). |
| openspec/changes/respect-gitignore-for-local-crawls/.openspec.yaml | OpenSpec metadata for the change. |
| docs/guides/basic-usage.md | Documents the new option, scope boundary, .git handling, and refresh behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thank you for picking this up, and for the careful work matching Git's behaviour. The opt-in flag and the scope boundary suit my use, which is indexing a folder of git repositories. I'm happy to test it once it lands. |
…gnore-v2 # Conflicts: # docs/guides/basic-usage.md # package-lock.json # package.json # src/mcp/mcpServer.ts # src/pipeline/PipelineManager.test.ts # src/scraper/strategies/LocalFileStrategy.test.ts # src/scraper/strategies/LocalFileStrategy.ts # src/store/DocumentStore.test.ts # src/tools/ScrapeTool.ts
…rong ignore 7.0.17 matches trailing foo/**/ patterns the way git does. Rewriting them to foo/*/**/ now drops direct subdirectories, so remove the rewrite and require ignore ^7.0.17.
…e package ignore 7.0.17 handles trailing whitespace, a leading BOM and the root /** pattern the way git does, so drop our rewrites of them. Pin the exact version, because patch releases of ignore have changed how patterns match. The comparison with git in gitignore.test.ts checks any bump.
Merge the per-directory context into a nullable matcher, read each .gitignore in one try block and share isMissingPathError. Move the pattern shapes the unit tests asserted by hand into the comparison with git, run the 200 generated cases in one repository instead of 200, and drop strategy and E2E tests that duplicated it. Shorten the openspec design to what the code does not say.
Scrape, change .gitignore and refresh through the real pipeline and store, and assert on the stored pages, instead of driving LocalFileStrategy with a faked refresh queue. The refresh tests now also cover that the stored option survives, so the separate PipelineManager test is dropped.
There was a problem hiding this comment.
🟡 Changes recommended
Virtual archive members are filtered using paths such as archive.zip/guide.md instead of the physical archive path, so .gitignore rules can incorrectly skip or delete individual members; nested .gitignore files with a UTF-8 BOM can also have their first rule silently fail after scoping rewrites.
2 open issues
2 resolved since last review
Review effort: Lite
…hive An entry that cannot be stat'ed is now matched by its path as a file instead of counting as ignored, so a refresh no longer deletes it. An archive member is judged by its archive file alone. An unreadable .gitignore is skipped with a warning, as git does, instead of failing the crawl. The entry cache keeps two flags per path instead of a full Stats object.
…gnore-v2 # Conflicts: # src/scraper/strategies/LocalFileStrategy.ts
There was a problem hiding this comment.
🟡 Changes recommended
Refresh-seeded paths or Markdown links beneath symlinks can cause .gitignore files outside allowedRoots to be read before access-policy validation, even with followSymlinks disabled; those external rules can also mark stored pages for deletion. Separately, with Git installed on Windows, tests use filenames that Windows forbids or normalizes, causing fixture-creation failures or comparisons of different paths rather than valid ignore-behavior checks.
2 open issues
2 resolved since last review
Review effort: Balanced
|
|
||
| // Git skips a BOM only at the start of the file. The `ignore` package | ||
| // would too, but nested rules get a base prefix first, which hides it. | ||
| const content = (await fs.readFile(ignorePath, "utf8")).replace(/^\uFEFF/, ""); |
| it.skipIf(!gitAvailable).each(SCENARIOS)("$name", async (scenario) => { | ||
| expect(await divergences(scenario, workspace)).toEqual([]); | ||
| }); |



Problem
Local directory crawls index every non-hidden file, including build output, dependency trees, and generated artifacts the project already declares uninteresting in
.gitignore. Users have to restate those rules as exclude patterns — duplicating a list that already exists, drifting from it, and leaving deliberately ignored content searchable.Closes #438.
What this is
This continues @Jonesxq's work in #458, which could no longer merge: the admin UI redesign (#452) deleted the HTMX components that PR wired the option into. Their commits are preserved via merge, with the UI reapplied on the new React/tRPC surface and the review findings addressed.
Changes
An opt-in
respectGitignoreoption forfile://directory crawls, off by default.Rule evaluation.
.gitignorefiles from the indexed folder downward, with Git's precedence: nested files override their parents, negations re-include, a rule excluding a directory excludes everything beneath it, and a re-include cannot resurrect a file under an excluded directory. Ignored directories are pruned rather than descended into..gitis never indexed.Entry points.
--respect-gitignoreon the CLI,respectGitignoreon the MCPscrape_docstool, and a checkbox in the Add/Edit documentation drawer's Advanced options — rendered only forfile://sources, since it has no effect on web crawls. The stored value is shown read-only on Library Detail's scrape configuration panel. The option persists with the version's scraper options, so refreshes reuse it; no schema change (it rides the existingscraper_optionsJSON).Refresh. Pages that have since become ignored are deleted, so a refresh converges on the same result as a fresh crawl. Archive members follow their physical archive.
Scope boundary
Only
.gitignorefiles at or below the indexed folder are read — not ancestors,.git/info/exclude, or global excludes.file://crawls are constrained to configured allowed roots, and reading rule files from ancestor directories would read outside the folder the user pointed at.The cost is that indexing a subdirectory of a repository indexes files that repository's
.gitignoreexcludes. That's the most surprising case, so the crawl probes upward for a.gitentry and warns, naming the repository root. The probe is an existence check only and never reads outside the indexed folder.On top of #458
linkdir/in.gitignore, alinkdirsymlink to a real directory is reported as not ignored. Links are tested as paths only, which also means a gitignored link is skipped without its target being resolved at all.lstaton its entries fail even thoughreaddirsucceeded; with filtering on, that error propagated out of the directory item, or out of the job at depth 0..gitis excluded. Git never walks it and no pattern can re-include it, but with hidden files enabled the crawler did. Matched case-insensitively, mirroring Git's own protection of that spelling.git. Builds throwaway repositories, walks them the way the crawler does, and compares the visible file set againstgit ls-files --others --exclude-standard— 13 curated pattern forms plus 200 seeded random combinations. This is what caught the symlink divergence. It lives ingitignore.test.tsper the single-file policy and skips when nogitbinary is present.openspec/changes/respect-gitignore-for-local-crawls/.--helpand MCP tool descriptions; MCP schema.default(false)dropped to match its neighbours; e2e temp directories moved out of the working tree.git ls-files --others --exclude-standardis the oracle rather thangit check-ignore, which answers a different question: for adir/**pattern it reports the trailing-slash directory form as ignored, which would over-prune directories whose direct children Git still lists.Testing
npm test— 134 files, 1980 testsnpm run typecheck,npx biome check .npm cifrom a clean checkout (the merge had droppedignorefrom the lockfile; restored in its own commit, which also syncs the lockfile's version field withpackage.json— that had already drifted on main)file://URLs and is absent forhttps://