Skip to content

feat(ingestion): add Solidity language support#2443

Open
JaCoderX wants to merge 3 commits into
abhigyanpatwari:mainfrom
JaCoderX:solidity
Open

feat(ingestion): add Solidity language support#2443
JaCoderX wants to merge 3 commits into
abhigyanpatwari:mainfrom
JaCoderX:solidity

Conversation

@JaCoderX

Copy link
Copy Markdown

Summary

Adds first-class Solidity (.sol) support via a vendored tree-sitter-solidity@1.1.0 grammar (ABI 13 / optional, same pattern as Dart/Kotlin/Swift), with LanguageProvider wiring, extractors, scope resolution for Foundry-style projects, fixtures/tests, web WASM registration, and docs/CHANGELOG.

Motivation / context

Closes #531. Smart-contract repos were previously unindexed (no DEFINES/CALLS from .sol), so MCP query / context / impact could not answer from contracts. This lands Phase 1–3-quality Solidity ingestion so Foundry/Hardhat-style trees produce a usable graph.

Areas touched

  • gitnexus/ (CLI / core / MCP server)
  • gitnexus-web/ (Vite / React UI)
  • .github/ (workflows, actions)
  • eval/ or other tooling
  • Docs / agent config only (AGENTS.md, CLAUDE.md, .cursor/, llms.txt, etc.)

Also: gitnexus-shared/ (language enum / detection / classification), root README.md + CHANGELOG.md, gitnexus/CHANGELOG.md.

Scope & constraints

In scope

  • Vendored tree-sitter-solidity@1.1.0 under gitnexus/vendor/ (pinned for tree-sitter@0.21.1 ABI; optional via GITNEXUS_SKIP_OPTIONAL_GRAMMARS=1)
  • CLI LanguageProvider + extractors: contracts / interfaces / libraries, functions, constructors, modifiers (definitions + invocations), events, inheritance
  • Import resolution: relative paths, named imports, Foundry remappings (remappings.txt / foundry.toml)
  • using for, emit/revert edges, this / super receiver binding, Foundry noise filter (vm / msg / abi)
  • Unit + integration fixtures under test/fixtures/lang-resolution/solidity-*
  • Web: WASM grammar map + Vite copy of tree-sitter-solidity.wasm (indexing remains server-side via gitnexus serve)
  • Linux Docker FTS smoke script: gitnexus/scripts/docker-fts-validate.sh (GITNEXUS_FTS_QUERY, default contract)
  • README supported-languages matrix + Unreleased CHANGELOG entries

Explicitly out of scope / not done here

  • Solidity CFG / PDG / --pdg taint
  • Yul, delegatecall, and full dynamic-dispatch fidelity
  • Full in-browser client-side re-index (WASM binary published for future use only)
  • Hardhat-specific config parsers beyond remapping-compatible paths
  • Perfect resolution of every edge on large protocol corpora (validated on a large Foundry monorepo; evidence anonymized below)

Implementation notes

  • Grammar vendoring mirrors Dart/Kotlin/Swift: build from vendor/, do not bump to tree-sitter-solidity 1.2.x (ABI 15) without a runtime upgrade.
  • Modifier invocations create CALLS edges; inherited modifiers use MRO-aware pickImplicitThisOverload when free-call fallback is ambiguous.
  • Windows host Ladybug FTS may fail to load (DLL); hybrid BM25 validation should use Linux Docker. Graph tools are unaffected on Windows.
  • Indexing Solidity in the web UI goes through gitnexus serve (native grammars), not browser WASM parse.

Testing & verification

  • cd gitnexus && npm test (Solidity unit + integration fixtures during development)
  • cd gitnexus && npm run test:integration (if distinct from npm test in this repo — run before merge if CI doesn’t)
  • cd gitnexus && npx tsc --noEmit (during development)
  • cd gitnexus-web && npm test (WASM / upload-filter / solidity-syntax tests added)
  • cd gitnexus-web && npx tsc -b --noEmit
  • Manual / Playwright E2E (not required for this PR)

Additional verification

  • Analyzed a large Foundry Solidity monorepo (OpenZeppelin mirrored under lib/ for imports): ~13.6k nodes / ~35k edges; modifier → OZ nonReentrant, library CALLS, remapping IMPORTS, METHOD_OVERRIDES present; hybrid FTS OK under Linux Docker.
  • FTS smoke (Linux): mount repo + corpus, run gitnexus/scripts/docker-fts-validate.sh (override GITNEXUS_FTS_QUERY as needed).

Risk & rollout

  • Non-breaking for existing languages; Solidity is an additive optional grammar.
  • Install hosts without a C++ toolchain can set GITNEXUS_SKIP_OPTIONAL_GRAMMARS=1 (Solidity skipped with other optional grammars).
  • After upgrade: re-run npx gitnexus analyze (or --force) on Solidity repos to populate the new graph.
  • Release notes: cover under Unreleased → Added (CHANGELOG already drafted).

Checklist

  • PR body meets repo minimum length (workflow may label short descriptions)
  • If AGENTS.md / overlays changed: headers, scope block, and changelog updated per project conventions (N/A — not changed)
  • No secrets, tokens, or machine-specific paths committed

JaCoderX and others added 2 commits July 12, 2026 19:14
Vendor tree-sitter-solidity and wire CLI/shared detection, extractors, and
scope resolution for contracts, modifiers, using-for, Foundry remappings,
emit/revert, and this/super binding. Include fixtures/tests, web WASM
grammar registration, and a Linux Docker FTS smoke script with an
overrideable corpus-agnostic query.

Closes abhigyanpatwari#531

Co-authored-by: Cursor <cursoragent@cursor.com>
Add Unreleased changelog entries and a Solidity row in the README
supported-languages table for abhigyanpatwari#531.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown

@JaCoderX is attempting to deploy a commit to the NexusCore Team on Vercel.

A member of the Team first needs to authorize it.

@koriyoshi2041

Copy link
Copy Markdown
Contributor

Did a focused local pass on this because the hosted checks have not run beyond labeler/Vercel yet.

Environment: macOS arm64, Node v25.6.1, npm 11.9.0.

Results:

  • npm install in gitnexus/: Solidity native binding built from source successfully. The first install hit the existing monorepo setup caveat where scripts/build.js expects ../gitnexus-shared/node_modules/.bin/tsc; after npm install in gitnexus-shared/, build proceeded.
  • npx vitest run test/integration/resolvers/solidity.test.ts: 24/24 passed.
  • npx vitest run test/unit/solidity-structure.test.ts test/unit/solidity-import-resolver.test.ts test/unit/solidity-named-imports.test.ts test/unit/solidity-heritage-captures.test.ts test/unit/scope-resolution/solidity-receiver-binding.test.ts test/unit/parser-loader.test.ts test/unit/parser-loader-skip-optional.test.ts: 49/49 passed.
  • npx tsc --noEmit: passed.

One small coverage suggestion: the PR body and implementation mention foundry.toml remappings, but the new integration fixture appears to cover remappings.txt only (solidity-remappings/remappings.txt). A tiny foundry.toml fixture would lock that advertised path too, especially since the parser is intentionally regex/minimal rather than a TOML dependency.

- Introduced new Solidity files for handling foundry.toml remappings, including `App.sol` and `Helper.sol`.
- Implemented tests to validate the resolution of imports and function calls through foundry.toml remappings in `solidity.test.ts`.
- Added unit tests for loading remappings from foundry.toml and ensuring correct behavior with remappings.txt in `solidity-remappings-loader.test.ts`.

This update enhances the integration of Solidity remapping features, improving the overall functionality and testing coverage.
@JaCoderX

Copy link
Copy Markdown
Author

Thanks @koriyoshi2041 for reviewing and the feedback.

Agreed on the gap: foundry.toml remappings were implemented (regex/minimal parser; foundry.toml then remappings.txt override) but only remappings.txt was fixture-covered.

Pushed a follow-up that locks the advertised path:

  • unit tests for multiline + single-line foundry.toml, and remappings.txt override
  • integration fixture solidity-foundry-toml-remappings/ with foundry.toml only (no remappings.txt)

The gitnexus-shared → gitnexus install order you hit is the existing monorepo setup caveat; unrelated to this change.

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.

feat: Add Solidity language support

2 participants