feat: make native tree-sitter deps optional (silent install without build tools)#147
Merged
Conversation
…uild tools Moves tree-sitter and all language grammars to optionalDependencies so `npm install openlore` completes cleanly on environments without native build tools (corporate Windows, Nexus proxy, Pi coding agent startup). Replaces static `import Parser from 'tree-sitter'` with lazy dynamic imports in ast-chunker.ts and call-graph.ts using the undefined/null sentinel pattern (undefined = not tried, null = unavailable). All 12 parser getter functions and all extraction paths are null-safe with graceful fallback to blank-line chunking or empty results. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
vite 7.x and tsx 4.21.x pulled in esbuild 0.17-0.28.0 (high severity CVE). Bumped vite to ^8.0.16 (non-breaking for this codebase — view command only uses createServer; @vitejs/plugin-react already requires vite ^8). npm audit fix resolves tsx -> esbuild chain to 0.28.1 (patched). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Owner
|
Thank you @laurentftech ❤️ |
clay-good
added a commit
that referenced
this pull request
Jun 14, 2026
…lent-fail routing) Merging #147 (tree-sitter/grammars → optionalDependencies, lazy null-safe loading) into the CFG-overlay branch raised the chance the overlay builder meets an unexpected or partially-loaded grammar shape. The overlay is strictly additive, so a builder throw must never break the base call graph: - buildCfgFor wrapped buildFunctionCfg without a guard. A throw propagated into the extractor and was caught only by the per-file dispatch try/catch, which skips the ENTIRE file — silently dropping its base nodes/edges (and, in watch mode, rolling back the per-file swap). Now buildCfgFor try/catches and fails soft to no overlay; the base call graph is unaffected. - The value-level opt-in consumers (analyze_impact, trace_execution_path) now wrap their overlay use in try/catch and fall back to the full function- granularity result on any error, so a corrupt overlay blob or builder surprise can never fail the tool. Regression-tested (store-error fallback). Also resolves the #147 merge: each language extractor keeps its null-safe early return (grammar absent → empty nodes/edges/cfg). Full suite 3625 pass. Decision: fda9fc24 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
pi install npm:openlorerunsnpm install openloreat every Pi coding agent startup. On environments without native build tools (corporate Windows, Nexus proxy), this produces:npm warn allow-scriptsnoise for 17+ packagescode: 1failures fortree-sitter-cliandtree-sitter-kotlinSolution
Move
tree-sitterand all language grammar packages fromdependenciestooptionalDependencies. npm tolerates optional dep failures silently — no more alarming output for users who only need the Pi extension (which has zero native imports itself).Changes
package.json— move tree-sitter + all language grammars tooptionalDependencies(alongside existing@lancedb/lancedb). Pure JS/WASM alternatives (web-tree-sitter,tree-sitter-wasms) stay independencies.src/core/analyzer/ast-chunker.tsandsrc/core/analyzer/call-graph.ts— replace staticimport Parser from 'tree-sitter'with lazy dynamic imports using theundefined/nullsentinel pattern:undefined= not yet triednull= tried, unavailable (falls back gracefully)When native tree-sitter is absent, AST chunker falls back to blank-line chunking; call-graph extraction returns empty results for affected files.
Test plan
npm run typecheck— 0 errorsnpm run test:run— 3536 tests passnpm install openlorecompletes withoutcode: 1failures🤖 Generated with Claude Code