Skip to content

feat: make native tree-sitter deps optional (silent install without build tools)#147

Merged
clay-good merged 2 commits into
clay-good:mainfrom
laurentftech:main
Jun 13, 2026
Merged

feat: make native tree-sitter deps optional (silent install without build tools)#147
clay-good merged 2 commits into
clay-good:mainfrom
laurentftech:main

Conversation

@laurentftech

@laurentftech laurentftech commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Problem

pi install npm:openlore runs npm install openlore at every Pi coding agent startup. On environments without native build tools (corporate Windows, Nexus proxy), this produces:

  • npm warn allow-scripts noise for 17+ packages
  • code: 1 failures for tree-sitter-cli and tree-sitter-kotlin
  • ~5s overhead on every agent startup

Solution

Move tree-sitter and all language grammar packages from dependencies to optionalDependencies. 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 to optionalDependencies (alongside existing @lancedb/lancedb). Pure JS/WASM alternatives (web-tree-sitter, tree-sitter-wasms) stay in dependencies.

src/core/analyzer/ast-chunker.ts and src/core/analyzer/call-graph.ts — replace static import Parser from 'tree-sitter' with lazy dynamic imports using the undefined/null sentinel pattern:

  • undefined = not yet tried
  • null = tried, unavailable (falls back gracefully)
  • All 12 parser getter functions and all extraction paths are null-safe

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 errors
  • npm run test:run — 3536 tests pass
  • Install in an environment without build tools: npm install openlore completes without code: 1 failures

🤖 Generated with Claude Code

laurentftech and others added 2 commits June 14, 2026 00:13
…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>
@clay-good

Copy link
Copy Markdown
Owner

Thank you @laurentftech ❤️

@clay-good clay-good merged commit 99a7f58 into clay-good:main Jun 13, 2026
4 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants