GitNexus/AGENTS.md
Gergő Magyar ab077b4c29
feat(ingestion): TypeScript registry-primary scope resolution (Ring 3) (#1050)
* feat(ingestion): TypeScript registry-primary scope resolution (Ring 3)

- Add TypeScript ScopeResolver stack (query/captures/interpret, import decomposition, hooks, arity, merge, receiver binding) and register in SCOPE_RESOLVERS.

- Harden shared compound receiver and receiver-bound CALLS pass for map for-of tuple bindings, dotted typeRef shapes, and callable-alias fallbacks.

- Flip TypeScript into MIGRATED_LANGUAGES; refresh AGENTS.md and type-resolution-system.md.

- Shared finalize-algorithm updates for cross-file scope parity.

- Tests: TS scope-resolution unit suite; legacy call-processor suite forces REGISTRY_PRIMARY_TYPESCRIPT=0; registry-primary flag test opts out TS in override scenario.

Made-with: Cursor

* fix(ingestion): SCC-ordered cross-file return-type propagation + multi-hop re-export resolution

Fix CI failures on PR #1050 (TypeScript registry-primary migration) by
making `propagateImportedReturnTypes` deterministic via reverse-
topological SCC ordering and updating the multi-hop re-export contract
to match `followReexportChain` behavior.

Why: the legacy pass mirrored an intermediate ref instead of the
terminal type when an importer was processed before its source module
had its own typeBindings chain-followed (4-file alias chain regression
in `ts-simple` fixture: `models.User -> service.user -> app.user`
collapsed to `getUser` instead of `User`). Reverse-topological walk of
`indexes.sccs` (leaves first) lets every importer see the source's
already-followed terminal type in a single pass.

Changes:
- `imported-return-types.ts`: rewrite to walk SCCs leaves-first, chain-
  follow the source module's typeBindings BEFORE mirroring, and chain-
  follow the importer's typeBindings AFTER mirroring. Cyclic SCCs
  reach a partial fixpoint (no convergence guarantee, ts-circular only
  asserts no-throw).
- `finalize-algorithm.ts`: docstring update on `FinalizeFile.localDefs`
  to reflect that `followReexportChain` resolves multi-hop re-exports
  through barrels even when intermediates do not surface the name -
  surfacing is now a static optimization, not a correctness requirement.
- `contract/scope-resolver.ts` Invariant I3: explicitly document the
  SCC ordering requirement.
- `pipeline/run.ts`: split PROF timer into `finalize` and `propagate`
  so the pass's cost is observable independently.
- `ARCHITECTURE.md` Performance notes: describe SCC-ordered propagation.
- `imported-return-types.ts`: expand chain-depth comment (2x effective
  depth from pre/post follow), add multi-ref break rationale, add
  `ts-simple` motivating-fixture pointer.

Tests:
- `finalize-algorithm.test.ts`: add 4 cases (3-hop chain, cyclic
  re-export visited-set guard, wildcard re-export fall-through,
  multi-source first-match-wins); fix misleading shared nodeId in the
  thick variant; rename and update the multi-hop test for the new
  contract (transitiveVia assertion on the thin variant).
- `imported-return-types.test.ts` (NEW): unit tests for the SCC pass
  pinning topological collapse, local-annotation guard, missing-source
  skip, and cyclic-SCC no-throw.
- `cross-file-binding.test.ts` + `ts-deep-alias-chain` fixture (NEW):
  5-file integration regression guard for SCC-ordered propagation
  through 4 module boundaries.

Validation: 865 scope-resolution + cross-file tests pass on Windows;
typecheck clean across both packages; only pre-existing Swift overload
failures remain (verified on PR base commit, environmental).

Made-with: Cursor

* fix(ingestion): address PR #1050 review findings — side-effect imports, resolve-cache perf, adapter signature

Three independent fixes surfaced by the production-readiness review of
the TypeScript registry-primary scope-resolution migration (RFC #909
Ring 3). All three pass under both REGISTRY_PRIMARY_TYPESCRIPT=0 and =1.

1. Side-effect imports were silently dropped (correctness regression).
   The legacy DAG emitted IMPORTS edges for `import './polyfill'` because
   its tree-sitter query matches `(import_statement source: (string))`
   regardless of clause. The new registry-primary path returned `[]`
   from `splitImportStatement()` for clause-less imports, so no
   ParsedImport / ImportEdge was ever produced — silent file-level edge
   loss. Add a generic 'side-effect' variant to `ParsedImport` and
   `ImportEdge['kind']` in `gitnexus-shared`; finalize resolves the
   target file and pre-finalizes the edge (no `targetDefId`, no
   `BindingRef`) so the SCC fixpoint loop skips it. The TypeScript
   provider now emits + interprets the new kind end-to-end. The
   variant is intentionally generic so other languages (Rust
   `use foo as _`, Python module-init) can adopt it.

2. Per-import re-derivation in `resolveImportTarget` (perf regression).
   The TS adapter built `new Set(allFilePaths)` on every call and let
   `resolveTsImportTarget` re-derive `allFileList` /
   `normalizedFileList` and discard the `resolveCache`. For a workspace
   with N files and M imports that's O(N × M) work per pass. Wrap the
   adapter in a closure that memoizes all five derived values keyed on
   the orchestrator's `ReadonlySet` identity; reset only when the set
   reference changes (start of new pass). New cost: O(N + M).

3. Misleading fake `ParsedImport` in the adapter (architecture).
   The adapter constructed `{ kind: 'named', localName: '_',
   importedName: '_', targetRaw }` to call `resolveTsImportTarget`,
   even though only `targetRaw` and the structural-typed context are
   read. Extract `resolveTsTarget(targetRaw, ctx)` so the adapter has
   an honest signature; `resolveTsImportTarget` still works for other
   callers. Also extract `narrowTsContext` for the type narrowing.

Tests: - New 4-file fixture `typescript-side-effect-imports` with two
    side-effect imports + one named import.
  - New "TypeScript side-effect imports" describe in
    `test/integration/resolvers/typescript.test.ts` (parity-gated by
    `ci-scope-parity.yml` — runs under both flag states).
  - Updated 2 unit tests to expect 1 side-effect ParsedImport and 4
    `@import.statement` matches (was 0 / 3).
  - 785 / 785 TS scope-resolution tests pass under both
    REGISTRY_PRIMARY_TYPESCRIPT=0 and =1.
Made-with: Cursor

* fix(scope): address Codex adversarial review findings on PR #1050

Four findings from the Codex adversarial review broke registry-primary
TypeScript resolution for common patterns. All four now have unit and
integration regression coverage that pass under both
`REGISTRY_PRIMARY_TYPESCRIPT=0` (legacy DAG) and the default
registry-primary path.

[high] tsconfig path aliases dropped:
Threaded `tsconfigPaths` through ScopeResolver via a new opaque
`resolutionConfig` parameter and a `loadResolutionConfig(repoPath)`
hook. The orchestrator (`scopeResolutionPhase` + `runScopeResolution`)
loads it once per workspace pass and forwards into every
`resolveImportTarget` call. TypeScript resolver now resolves
`@/services/user` style imports through the standard resolver's alias
branch.

[high] TSX parsed with the wrong grammar:
`emitTsScopeCaptures` now picks the parser/query by `filePath`
(`.tsx` -> TSX grammar) and validates cached trees against the
expected grammar via the new exported `tsCachedTreeMatchesGrammar`
helper. Stale TS-grammar trees for `.tsx` files no longer leak through
the scope query.

[medium] Literal dynamic imports never linked:
Added `kind: 'dynamic-resolved'` to `ParsedImport` and `ImportEdge`.
The decomposer emits a synthetic `@import.literal` capture for
string-literal dynamic imports; the interpreter maps that to
`dynamic-resolved`; finalize pre-finalizes it as a file-level terminal
(same shape as `side-effect`). `import('./feature')` now produces a
real IMPORTS edge under the registry-primary path. Legacy DAG keeps
its existing behavior — the new integration assertion is gated behind
the flag.

[medium] Namespace re-exports invisible from barrels:
The decomposer now emits TWO captures for `export * as ns from './m'`
— the existing `reexport-namespace` import draft AND a synthetic
`@declaration.namespace` capture (via `buildNamespaceDeclarationMatch`).
The latter creates a Namespace `SymbolDefinition` in the barrel's
`localDefs`, so downstream `import { ns } from './barrel'` resolves
through `findExportByName`.

Regression fixtures under `gitnexus/test/fixtures/lang-resolution/`:
- typescript-tsconfig-aliases (`@/` alias)
- typescript-tsx-jsx (Button.tsx + App.tsx with JSX)
- typescript-dynamic-import (`await import('./feature')`)
- typescript-reexport-namespace (`export * as Models from './base'`)

Validation:
- gitnexus-shared builds clean
- gitnexus typecheck clean
- 385/385 TS scope-resolution tests pass under both
  `REGISTRY_PRIMARY_TYPESCRIPT=0` and default

Made-with: Cursor

* perf(scope): O(1) defById lookup + bounded re-export depth (PR #1050 round 3)

Addresses the round-3 PR #1050 reviews (Claude adversarial + xkonjin):
both flagged the existing O(N²) `findDefById` linear scan in
`materializeBindings` and the unbounded recursion in
`followReexportChain` as production-readiness blockers for TypeScript
monorepos. Both fixes land alongside their regression tests under
both `REGISTRY_PRIMARY_TYPESCRIPT=0` and the default registry-primary
path.

[high] materializeBindings O(N_files × N_defs × N_edges) → O(N_defs + N_edges):
Build a `nodeId → SymbolDefinition` index map once at the top of
`materializeBindings` (one O(N_defs) pass), then replace the per-edge
`findDefById(files, edge.targetDefId)` linear scan with an O(1)
`defById.get(edge.targetDefId)` lookup. Also drop the now-unused
`findDefById` helper. At realistic TypeScript monorepo scale (~5k
files × ~50 defs/file × ~100k linked import edges) this is the
difference between ~25 s and a few ms inside finalize. Regression
test in `finalize-algorithm.test.ts` builds 200 leaf files +
1 consumer importing one symbol from each, asserts every binding
materializes correctly.

[medium] followReexportChain unbounded recursion:
The existing `visited` set caps depth at `O(N_files)` but allows
recursion proportional to barrel-chain depth, mismatching the
explicit "Iterative DFS to avoid stack overflow" policy in
`tarjanSccs`. Added a `MAX_REEXPORT_DEPTH = 100` constant and a
`depth` parameter to `followReexportChain` (defaults to 0); each
recursive call passes `depth + 1` and the function returns `null`
when the cap is exceeded. 100 is comfortably above any realistic
hand-authored barrel chain (typical depth 1-5; auto-generated
barrels rarely exceed 20) while staying well below JS engine call
stack limits. Regression test wires a 200-link reexport chain and
verifies the crawl terminates cleanly with `linkStatus: 'unresolved'`
(no terminal def reachable within the budget).

[low] synthesizeInstanceofNarrowings bare-identifier-only limitation:
xkonjin's review #4 noted that the LHS narrowing only handles bare
identifiers (`if (x instanceof Foo)`), not member expressions
(`if (user.address instanceof Address)`). Added a JSDoc note
explaining the constraint and pointing readers at field-type
resolution as the workaround for member-chain receivers.

Validation:
- gitnexus-shared builds clean
- gitnexus typecheck clean
- 413/413 tests pass under both flag states for finalize-algorithm +
  TS unit + TS integration suites
- 972/972 tests pass across full scope-resolution + Python +
  C# integration smoke (no cross-language regression)

Made-with: Cursor

* refactor(finalize): replace recursive followReexportChain with SCC-condensed iterative closure

The legacy `followReexportChain` walked re-export drafts via mutual
recursion guarded by a per-call visited set + a `MAX_REEXPORT_DEPTH`
ceiling. Recursion is fragile (call-stack ceiling, no bound on depth
that's actually meaningful), so this replaces it with a structurally
better algorithm: a precomputed per-file re-export closure built by
running Tarjan SCC over the re-export sub-graph and propagating names
in reverse-topological order with a bounded intra-SCC fixpoint.

Algorithm (`buildReexportClosures` in finalize-algorithm.ts):

  1. Sub-graph: build the directed graph of `reexport` + `wildcard`
     drafts only (regular/namespace/dynamic imports do not contribute).
  2. SCC condensation: run the same iterative `tarjanSccs` already
     used for the file-level import graph; output is in reverse-topo
     order so out-of-SCC neighbors are always already-finalized.
  3. Per-SCC propagation:
       - Acyclic singleton: one pass populates from neighbors' closures.
       - Cyclic SCC: bounded fixpoint capped at |SCC|+1 iterations.
         With first-wins precedence the closure map is monotone, so
         each name needs at most |SCC| hops to traverse the cycle.

Precedence (preserved from the recursive crawl):
  - Named re-exports take precedence over wildcards.
  - Within each kind, declaration order wins.

Lookup at finalize time becomes O(1) (`lookupReexportedName`), down
from O(chain_depth × drafts) per consult and recursive at that.

Properties vs the legacy implementation:
  - Stack-safe by construction; no `MAX_REEXPORT_DEPTH` guard needed.
  - 1000-hop barrel chains now resolve in full (legacy capped at 100
    and surfaced anything deeper as `unresolved`).
  - Cycles handled structurally via SCC, not via per-call visited set.
  - Same observable semantics: every existing test passes unchanged.

Tests:
  - Replace the obsolete `MAX_REEXPORT_DEPTH (200-hop chain stops
    cleanly without stack overflow)` test (which asserted the OLD
    bug — that deep chains failed to resolve) with a positive
    1000-hop test that asserts full resolution + accurate
    `transitiveVia`. Proves both the recursion is gone AND the
    closure correctly inherits the leaf def across all hops.
  - Update commentary on adjacent re-export tests to reference the
    closure mechanism.
  - Update `FinalizeFile.localDefs` JSDoc + import-decomposer.ts
    inline doc to point at `buildReexportClosures` instead of the
    removed function name.

Validation: - gitnexus-shared builds cleanly.
  - gitnexus typechecks cleanly.
  - 28/28 finalize-algorithm.test.ts tests pass (incl. new 1000-hop).
  - 801/801 TypeScript scope-resolution tests pass under default
    (registry-primary) AND `REGISTRY_PRIMARY_TYPESCRIPT=0` (legacy DAG).
  - 404/404 Python + C# integration tests pass — no regression in
    cross-language consumers of the shared `finalize`.
Made-with: Cursor

* fix(scope): remove non-null assertions from scope resolution

Made-with: Cursor

* fix(scope): address TypeScript review follow-ups

Made-with: Cursor

* fix(scope): address TypeScript import review follow-ups

Add regression coverage for non-binding import edges and circular TypeScript bindings so PR #1050 review concerns stay visible without changing runtime semantics.

Made-with: Cursor
2026-04-26 08:23:08 +01:00

12 KiB

Last reviewed: 2026-04-23

Project: GitNexus · Environment: dev · Maintainer: repository maintainers (see GitHub)

Scope

Boundary Rule
Reads gitnexus/, gitnexus-web/, eval/, plugin packages, .github/, .gitnexus/, docs.
Writes Only paths required for the change; keep diffs minimal. Update lockfiles when deps change.
Executes npm, npx, node under gitnexus/ and gitnexus-web/; uv run for Python under eval/; documented CI/dev workflows.
Off-limits Real .env / secrets, production credentials, unrelated repos, destructive git ops without confirmation.

Model Configuration

  • Primary: Use a named model (e.g. Claude Sonnet 4.x). Avoid Auto or unversioned latest when reproducibility matters.
  • Notes: The GitNexus CLI indexer does not call an LLM.

Execution Sequence (complex tasks)

For multi-step work, state up front:

  1. Which rules in this file and GUARDRAILS.md apply (and any relevant Signs).
  2. Current Scope boundaries.
  3. Which validation commands you will run (cd gitnexus && npm test, npx tsc --noEmit).

On long threads, "Remember: apply all AGENTS.md rules" re-weights these instructions against context dilution.

Claude Code hooks

PreToolUse hooks can block tools (e.g. git_commit) until checks pass. Adapt to this repo: cd gitnexus && npm test before commit.

Context budget

Commands and gotchas live under Repo reference below and in CONTRIBUTING.md. If always-on rules grow, split into .cursor/rules/*.mdc (globs). Cursor: project-wide rules in .cursor/index.mdc. Claude Code: load STANDARDS.md only when needed.

Reference docs

  • ARCHITECTURE.md, CONTRIBUTING.md, GUARDRAILS.md
  • Call-resolution DAG (legacy path): See ARCHITECTURE.md § Call-Resolution DAG. Typed 6-stage DAG inside the parse phase; language-specific behavior behind inferImplicitReceiver / selectDispatch hooks on LanguageProvider. Shared code in gitnexus/src/core/ingestion/ must not name languages. Types: gitnexus/src/core/ingestion/call-types.ts.
  • Scope-resolution pipeline (RFC #909 Ring 3): See ARCHITECTURE.md § Scope-Resolution Pipeline. Replaces the legacy DAG for languages in MIGRATED_LANGUAGES (see registry-primary-flag.ts). A language plugs in by implementing ScopeResolver (scope-resolution/contract/scope-resolver.ts) and registering it in SCOPE_RESOLVERS. CI parity gate runs BOTH paths per migrated language on every PR.
  • Cursor: .cursor/index.mdc (always-on); .cursor/rules/*.mdc (glob-scoped). Legacy .cursorrules deprecated.
  • GitNexus: skills in .claude/skills/gitnexus/; MCP rules in gitnexus:start block below.

Changelog

Date Version Change
2026-04-23 1.7.0 TypeScript added to MIGRATED_LANGUAGES (registry-primary call resolution by default).
2026-04-20 1.6.0 Added scope-resolution pipeline pointer (RFC #909 Ring 3); Python migrated to registry-primary.
2026-04-19 1.5.0 Cross-repo impact (#794): impact/query/context accept repo: "@<group>" + service. Removed group_query/group_contracts/group_status MCP tools; added gitnexus://group/{name}/contracts and gitnexus://group/{name}/status resources.
2026-04-16 1.4.0 Fixed: web UI description, pre-commit behavior, MCP tools (7->16), added gitnexus-shared, removed stale vite-plugin-wasm gotcha.
2026-04-13 1.3.0 Updated GitNexus index stats after DAG refactor.
2026-03-24 1.2.0 Fixed gitnexus:start block duplication.
2026-03-23 1.1.0 Updated agent instructions, references, Cursor layout.
2026-03-22 1.0.0 Initial structured header and changelog.

GitNexus — Code Intelligence

Indexed as GitNexus (4325 symbols, 10556 relationships, 300 execution flows). Use MCP tools to understand code, assess impact, and navigate safely.

If any tool warns the index is stale, run npx gitnexus analyze first.

Always Do

  • MUST run impact analysis before editing any symbol. gitnexus_impact({target: "symbolName", direction: "upstream"}) — report blast radius to the user.
  • MUST run gitnexus_detect_changes() before committing — verify only expected symbols and flows are affected.
  • MUST warn the user if impact returns HIGH or CRITICAL risk.
  • Explore unfamiliar code with gitnexus_query({query: "concept"}) (process-grouped, ranked) instead of grepping.
  • Full context on a symbol: gitnexus_context({name: "symbolName"}).

When Debugging

  1. gitnexus_query({query: "<error or symptom>"}) — find related execution flows
  2. gitnexus_context({name: "<suspect function>"}) — callers, callees, process participation
  3. READ gitnexus://repo/GitNexus/process/{processName} — trace flow step by step
  4. Regressions: gitnexus_detect_changes({scope: "compare", base_ref: "main"})

When Refactoring

  • Rename: gitnexus_rename({symbol_name: "old", new_name: "new", dry_run: true}) first. Graph edits are safe; text_search edits need manual review.
  • Extract/Split: gitnexus_context (incoming/outgoing refs) then gitnexus_impact (upstream callers) before moving code.
  • After any refactor: gitnexus_detect_changes({scope: "all"}) to verify scope.

Never Do

  • Edit a symbol without running gitnexus_impact first.
  • Ignore HIGH/CRITICAL risk warnings.
  • Rename with find-and-replace — use gitnexus_rename.
  • Commit without gitnexus_detect_changes().
  • Add language-specific behavior to shared ingestion code (gitnexus/src/core/ingestion/) — use a LanguageProvider hook. Seeing provider.mroStrategy === 'xxx' or an import from languages/xxx.ts in shared code means stop and add a hook.

Tools Quick Reference

Tool When to use Example
list_repos Discover indexed repos gitnexus_list_repos({})
query Find code by concept gitnexus_query({query: "auth validation"})
context 360-degree view of one symbol gitnexus_context({name: "validateUser"})
impact Blast radius before editing gitnexus_impact({target: "X", direction: "upstream"})
detect_changes Pre-commit scope check gitnexus_detect_changes({scope: "staged"})
rename Safe multi-file rename gitnexus_rename({symbol_name: "old", new_name: "new", dry_run: true})
cypher Custom graph queries gitnexus_cypher({query: "MATCH ..."})
api_impact Pre-change API route impact gitnexus_api_impact({route: "/api/users", method: "GET"})
route_map Route → handler → consumer map gitnexus_route_map({})
tool_map MCP/RPC tool definitions gitnexus_tool_map({})
shape_check Response shape vs consumer access gitnexus_shape_check({route: "/api/users"})
group_list List repo groups gitnexus_group_list({})
group_sync Rebuild group Contract Registry gitnexus_group_sync({name: "myGroup"})
query (group mode) Cross-repo search in a group (RRF-merged) gitnexus_query({repo: "@myGroup", query: "auth"})
context (group mode) 360° view across all member repos gitnexus_context({repo: "@myGroup", name: "validateUser"})
impact (group mode) Cross-repo blast radius via Contract Bridge gitnexus_impact({repo: "@myGroup", target: "X", direction: "upstream"})

Group mode: pass repo: "@<groupName>" to fan out across all member repos, or repo: "@<groupName>/<memberPath>" to target a single member (path keys from group.yaml). Optional service: "<monorepo/path>" filters by service root. Group-level state (contracts, staleness) lives in the resources table below — there are no group_query / group_context / group_impact / group_contracts / group_status MCP tools.

For a full walkthrough of setting up a group across multiple repos that communicate over gRPC, see docs/guides/microservices-grpc.md.

Impact Risk Levels

Depth Meaning Action
d=1 WILL BREAK — direct callers/importers MUST update
d=2 LIKELY AFFECTED — indirect deps Should test
d=3 MAY NEED TESTING — transitive Test if critical path

Resources

Resource Use for
gitnexus://repo/GitNexus/context Codebase overview, index freshness
gitnexus://repo/GitNexus/clusters All functional areas
gitnexus://repo/GitNexus/processes All execution flows
gitnexus://repo/GitNexus/process/{name} Step-by-step execution trace
gitnexus://group/{name}/contracts Group Contract Registry (provider/consumer rows + cross-links)
gitnexus://group/{name}/status Per-member index + Contract Registry staleness report

Self-Check Before Finishing

  1. gitnexus_impact was run for all modified symbols
  2. No HIGH/CRITICAL warnings were ignored
  3. gitnexus_detect_changes() confirms expected scope
  4. All d=1 dependents were updated

Keeping the Index Fresh

npx gitnexus analyze                 # basic refresh; preserves any existing embeddings
npx gitnexus analyze --embeddings    # also generate embeddings for new/changed nodes
npx gitnexus analyze --drop-embeddings  # explicit opt-in to wipe existing embeddings

Check .gitnexus/meta.json stats.embeddings (0 = none). A plain analyze no longer drops existing vectors — pass --drop-embeddings to wipe.

Claude Code: PostToolUse hook detects a stale index after git commit and git merge and prompts the agent to run analyze. The hook does not invoke analyze itself.

CLI Skills

Task Skill file
Architecture / "How does X work?" .claude/skills/gitnexus/gitnexus-exploring/SKILL.md
Blast radius / "What breaks?" .claude/skills/gitnexus/gitnexus-impact-analysis/SKILL.md
Debugging / "Why is X failing?" .claude/skills/gitnexus/gitnexus-debugging/SKILL.md
Refactoring .claude/skills/gitnexus/gitnexus-refactoring/SKILL.md
Tools/resources/schema reference .claude/skills/gitnexus/gitnexus-guide/SKILL.md
CLI commands (index, status, clean, wiki) .claude/skills/gitnexus/gitnexus-cli/SKILL.md

Repo reference

Packages

Package Path Purpose
CLI/Core gitnexus/ TypeScript CLI, indexing pipeline, MCP server. Published to npm.
Web UI gitnexus-web/ React/Vite thin client. All queries via gitnexus serve HTTP API.
Shared gitnexus-shared/ Shared TypeScript types and constants.
Claude Plugin gitnexus-claude-plugin/ Static config for Claude marketplace.
Cursor Integration gitnexus-cursor-integration/ Static config for Cursor editor.
Eval eval/ Python evaluation harness (Docker + LLM API keys).

Running services

cd gitnexus && npm run dev                 # CLI: tsx watch mode
cd gitnexus-web && npm run dev             # Web UI: Vite on port 5173
npx gitnexus serve                         # HTTP API on port 4747 (from any indexed repo)

Testing

CLI / Core (gitnexus/)

  • npm test — full vitest suite (~2000 tests)
  • npm run test:unit — unit tests only
  • npm run test:integration — integration (~1850 tests). LadybugDB file-locking tests may fail in containers (known env issue).
  • npx tsc --noEmit — typecheck

Web UI (gitnexus-web/)

  • npm test — vitest (~200 tests)
  • npm run test:e2e — Playwright (7 spec files; requires gitnexus serve + npm run dev)
  • npx tsc -b --noEmit — typecheck

Pre-commit hook (.husky/pre-commit): formatting (prettier via lint-staged) + typecheck for staged packages. Tests do not run in pre-commit — CI only.

Gotchas

  • npm install in gitnexus/ triggers prepare (builds via tsc) and postinstall (patches tree-sitter-swift, builds tree-sitter-proto). Native bindings need python3, make, g++.
  • tree-sitter-kotlin and tree-sitter-swift are optional — install warnings expected.
  • ESLint configured via eslint.config.mjs (TS, React Hooks, unused-imports). No npm run lint script; use npx eslint .. Prettier runs via lint-staged. CI checks both in ci-quality.yml.