40 Commits

Author SHA1 Message Date
Colby McHenry c3f1e273d4 release: 0.8.0 2026-05-20 18:41:42 -05:00
Colby Mchenry 9b06b0edde fix(db): require better-sqlite3 ^12.4.1 so Node 24 gets the native backend (#203) (#216)
better-sqlite3 ^11.0.0 (latest 11.10.0) ships no prebuilt binary for
Node 24's ABI (node-v137) and predates Node 24, so every Node 24 install
silently fell back to the 5-10x-slower WASM backend. Bump to ^12.4.1 —
the first 12.x with the Node 24 prebuild — and raise the engines floor to
Node 20 (Node 18 is EOL and dropped from better-sqlite3 12.x prebuilds).

Verified on macOS Node 24.15.0 (ABI 137): prebuilt binary used with no
compiler (installs even with CC/CXX sabotaged), `codegraph init -i` shows
no WASM banner, and `codegraph status` reports Backend: native. 639/639
tests pass on Node 22.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 11:54:19 -05:00
Colby Mchenry 2c1a314b84 feat(mcp): line numbers in explore output + per-file cluster fixes (#188)
* feat(mcp): line numbers in explore output + per-file cluster fixes

Follow-up to #185. Three changes to codegraph_explore:

1. Source sections now carry cat -n style line-number prefixes
   (<num>\t<code>), so the agent can cite file:line straight from the
   payload instead of re-Reading the file just to recover a line number.
   Isolated A/B: the no-line-numbers arm spent 2 Reads + a grep to find a
   line number the line-numbered arm cited with zero follow-up calls.
   Payload cost ~3-5%. Toggle off with CODEGRAPH_EXPLORE_LINENUMS=0.

2. Per-file cluster selection now ranks clusters containing a query entry
   point ahead of dense declaration blocks. Density-only ranking buried
   the relevant methods (perform/didCreateURLRequest/task in Alamofire's
   Session.swift) under the top-of-file class header + property list.

3. Whole-file "envelope" nodes (a class/struct/etc. spanning >50% of the
   file) are excluded from clustering. The Session class spans ~1,400
   lines; keeping it collapsed every method into one giant cluster that
   tail-trimmed down to just the class header, hiding the methods.

Net vs the 0.7.10 baseline, line numbers on: Alamofire -60%, Excalidraw
-32%, VS Code -12% per explore call.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(mcp): language-neutral omission markers in explore output

The gap separator and the two tail-trim markers used C-style `//`
comments, which aren't comments in Python, Ruby, etc. Switch to plain
`... (gap) ...` / `... (trimmed) ...` so they read correctly inside any
language's fenced source block. With line numbers on, the line-number
jump already corroborates a gap.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(mcp): language-neutral truncation marker in codegraph_context

Sibling to the explore marker fix: codegraph_context's code-block
truncation used a C-style `// ... truncated ...`. Switch to
`... (truncated) ...` so it reads correctly in any language's fenced
source block.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore(release): bump version to 0.7.11

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 17:16:12 -05:00
Colby McHenry fb8fb0ea8b release: 0.7.10 (Windows mojibake fix, module-qualified symbol lookups, MCP handshake) 2026-05-19 11:32:47 -05:00
Colby McHenry 662bb1ece8 release: 0.7.9 2026-05-18 08:29:16 -05:00
Colby Mchenry 58c1414ce5 fix(installer): opencode .jsonc + AGENTS.md (0.7.8) (#163)
* release: 0.7.7 (multi-agent installer — Cursor, Codex, opencode)

* fix(installer): opencode .jsonc + AGENTS.md (0.7.8)

v0.7.7 wrote ~/.config/opencode/opencode.json, but opencode reads
opencode.jsonc by default — so the codegraph MCP entry never appeared
in any opencode session. Also installs AGENTS.md so opencode's model
reaches for codegraph_* tools instead of native Grep.

- Prefer existing .jsonc, fall back to .json, default new installs
  to .jsonc.
- Surgical edits via jsonc-parser preserve user comments and
  formatting across install / re-install / uninstall round-trips.
- Install AGENTS.md (global ~/.config/opencode/AGENTS.md, local
  ./AGENTS.md) with the shared INSTRUCTIONS_TEMPLATE — same
  marker-delimited approach Codex uses.
- +9 opencode-specific tests covering filename precedence, comment
  preservation, AGENTS.md install + sibling-content preservation,
  uninstall reverses both files.

575/575 tests pass. Hand-verified end-to-end: opencode session calls
codegraph_node + codegraph_callers for a structural query, zero Grep
calls.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs: overhaul CLAUDE.md and add scripts/release.sh + Cursor rules file

Replaces the old Claude-only CLAUDE.md with a comprehensive guide covering
the full project architecture, multi-agent installer, test conventions,
NodeKind/EdgeKind reference, and release workflow. Key additions:

- Documents the layered pipeline, all module paths, and the multi-target
  installer (targets/, registry.ts, AgentTarget interface).
- Adds the Cursor `--path` quirk and the "update all three surfaces" rule
  when changing MCP tool guidance.
- Documents `npm run eval`, `test:eval`, and the full set of build/test
  commands including single-file patterns.
- `scripts/release.sh` — idempotent bash script that tags the current
  commit, pushes the tag, and creates a GitHub Release whose notes are
  extracted from the matching `## [X.Y.Z]` block in CHANGELOG.md. Safe
  to re-run after partial failure.
- `.cursor/rules/codegraph.mdc` — Cursor-specific agent instructions
  (tool decision table, rules of thumb, index-lag warning) written by
  the installer and kept in sync with server-instructions.ts and
  instructions-template.ts.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 20:26:49 -05:00
Colby McHenry 7d87126ee8 release: 0.7.7 (multi-agent installer — Cursor, Codex, opencode) 2026-05-17 19:27:05 -05:00
Colby McHenry 7e617d819b release: 0.7.6 (fix permission denied on global install)
The 0.7.5 tarball shipped `dist/bin/codegraph.js` without the executable
bit set, causing `zsh: permission denied: codegraph` after a fresh global
install. The build script now `chmod +x`'s the binary before packing.

Also adds CHANGELOG.md and documents the release workflow in CLAUDE.md.
2026-05-13 09:00:41 -05:00
verzillion_kram 38d155618f fix: add @clack/prompts transitive deps to fix npx installation (#136)
* fix: add @clack/prompts transitive deps to fix npx installation

When installed via `npx`, npm's flat node_modules cache fails to
hoist ESM-only transitive dependencies from @clack/prompts → @clack/core.
This causes:

  Cannot find package 'fast-wrap-ansi/index.js' imported from
  @clack/core/dist/index.mjs

Adding fast-wrap-ansi, fast-string-width, and sisteransi as direct
dependencies ensures they are resolved correctly in all installation
contexts (npx, global, local).

Reproduces on Node 24 + npm 11 with `npx @colbymchenry/codegraph@0.7.3`.

* chore: bump @clack/prompts to 1.3.0 with matching transitive pins

@clack/prompts@1.3.0 shipped with major bumps to its transitive deps
(fast-wrap-ansi 0.1 → 0.2, fast-string-width 1 → 3). Promoting them
at the older pins would have caused npm to install both sets side by
side, defeating the dedup goal of this fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: mfrancime <mfrancime@users.noreply.github.com>
Co-authored-by: Colby McHenry <me@colbymchenry.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 20:28:44 -05:00
Colby McHenry 789158bfd4 Bump version to 0.7.2
Updates Swift and Kotlin language support from basic to full in documentation and reduces explore budget thresholds to optimize performance for smaller codebases.
2026-04-07 16:56:41 -05:00
Colby McHenry 884b6c7fb5 Bump version to 0.7.0 2026-04-07 16:17:26 -05:00
Colby McHenry 59ea5a43be feat: Add Ruby module extraction with containment and qualified names
Addresses Ruby methods inside modules missing owner in qualified_name by adding visitNode hook to extract module AST nodes. Methods inside modules now get Module::method qualified names with proper containment relationships. Includes ExtractorContext wiring with pushScope/popScope for language hooks and updates isInsideClassLikeNode to include module kind for nested method handling.
2026-04-07 09:17:34 -05:00
Colby McHenry ed35d65f4c feat: Replace figlet with @clack/prompts for polished CLI experience
Replaces ASCII art banner and basic readline prompts with @clack/prompts for a modern interactive CLI. Adds animated shimmer progress bars with spinner glyphs during indexing operations. Improves installer UX with structured prompts, better error handling, and cleaner output formatting throughout all CLI commands.
2026-04-04 11:07:18 -05:00
Colby McHenry d04a911309 feat: Improve Java extraction, multi-symbol aggregation, and impact traversal
Java extraction:
- Handle Java method_invocation AST (receiver.method pattern)
- Support Java extends_interfaces and super_interfaces with type_list
- Create unresolved references for Java imports for cross-file resolution
- Extract interface inheritance via extractInheritance

MCP tools:
- Aggregate callers/callees/impact across ALL matching symbols (e.g. multiple
  overloads or same-named methods in different classes)
- New findAllSymbols() helper for multi-symbol lookup

Graph traversal:
- Impact analysis now traverses into container children (class → methods)
  so that callers of methods appear in the impact radius of their class

Other:
- Add deleteSpecificResolvedReferences() for precise cleanup after resolution
- Add 'instance-method' to resolvedBy union type
- Version bump to 0.6.8

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 12:30:28 -05:00
Colby McHenry 9bb8e96bd4 bump version to 0.6.6 2026-04-01 14:37:38 -05:00
Colby McHenry 1f715cd6d9 chore: Bump version to 0.6.5 2026-03-18 17:10:59 -05:00
Colby McHenry 5334a0f023 feat: Add codegraph affected command to find test files impacted by changes
Traverses dependency graph to identify which test files depend on changed source files. Supports stdin input for git integration, custom test file patterns, and configurable traversal depth. Useful for targeted test execution in CI/CD pipelines.
2026-03-18 16:31:54 -05:00
Colby McHenry dff98a638c Bumps version to 0.6.2
Bumps version to 0.6.2 in both package.json and lockfile to align release metadata and prevent silent install failures on fresh installs.
Relates to silent install fix
2026-02-19 15:57:01 -06:00
Olaf Monien 77135445db Merge origin/main into delphi-support
Integrate main branch changes (WASM grammar architecture, centralized
resolution caches, SQLite adapter) with delphi-support branch. Pascal
grammar is now built as WASM and shipped in src/extraction/wasm/ for
consistency with the WASM-based grammar loading approach.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 20:23:54 +01:00
Colby McHenry a9148e674e Fix git issue 2026-02-14 02:14:48 -06:00
Colby McHenry 8346440592 Add WASM fallbacks for tree-sitter and SQLite, fix installer
Replace native tree-sitter with web-tree-sitter + tree-sitter-wasms for
universal cross-platform support. Add node-sqlite3-wasm as a fallback
when better-sqlite3 native bindings aren't available. Move better-sqlite3
and sqlite-vss to optionalDependencies so installs never fail.

Fix installer to use npx fallback when global npm install fails, so MCP
config, hooks, and quick-start instructions all work without the bare
codegraph command in PATH.

Fix tests: update schema version expectation, fix db test paths and
method names, extract MAX_OUTPUT_LENGTH as module constant, normalize
Windows path separators in import resolver.
2026-02-14 00:56:15 -06:00
Colby McHenry 429359c25f version bump 2026-02-11 16:12:45 -06:00
Colby McHenry ce504c642a Fix performance issues. 2026-02-11 16:11:50 -06:00
Olaf Monien 2442c58932 fix: Move tree-sitter-pascal to optionalDependencies with pinned commit
Align with project convention: all tree-sitter grammars are optional.
Pin to commit 042119e for reproducible builds (npm v0.0.1 is outdated
and incompatible with Node.js v24 due to NAN bindings).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 10:00:14 +01:00
Olaf Monien 425bfceea5 feat: Add Pascal/Delphi language support with DFM/FMX extraction
Implements tree-sitter-based extraction for Pascal/Delphi source files
(.pas, .dpr, .dpk, .lpr) and a custom regex-based DfmExtractor for
form files (.dfm, .fmx). Covers classes, records, interfaces, methods,
properties, fields, enums, constants, type aliases, uses-imports,
visibility sections, inheritance, call extraction, and DFM component
hierarchies with event handler references.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 08:58:13 +01:00
Colby McHenry 09a8d24bd8 version bump 2026-02-10 18:18:51 -06:00
Colby McHenry 4c7827675a Auto stash before merge of "main" and "origin/main" 2026-02-10 18:16:06 -06:00
Martin Oehlert 399d78b938 security: path validation, ReDoS prevention, picomatch, PID-based file lock
- Add validateProjectPath() to reject sensitive system directories
- Add isPathWithinRoot/isPathWithinRootReal for symlink-aware path checks
- Replace hand-rolled glob-to-regex with picomatch to prevent ReDoS
- Add isSafeRegex() to reject custom patterns with nested quantifiers
- Replace FileLock with PID-tracking version that detects stale locks
- Add symlink detection in removeDirectory/listDirectoryContents
- Add subdirectory name validation in ensureSubdirectory
- Add atomicWriteFileSync and corrupted file backup in config-writer
- Add MCP input validation (validateString) for all tool handlers
- Fix CLAUDE.md section replacement to handle ### subsections correctly
2026-02-10 11:22:04 +01:00
Colby McHenry 4825661e02 upgrade 2026-02-10 03:49:06 -06:00
Colby McHenry 75e9bfca04 Downgrade tree-sitter to 0.21.1 to eliminate all peer dependency warnings
All grammar packages now have compatible peer deps with tree-sitter 0.21.x,
resulting in zero warnings during npm install. Downgraded grammars:
c 0.24.1→0.23.2, php 0.24.2→0.23.11, python 0.23.6→0.23.4,
rust 0.24.0→0.23.1, swift 0.7.1→0.6.0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 03:07:39 -06:00
Colby McHenry a4c1d32160 Upgrade tree-sitter-c, php, and rust to versions compatible with tree-sitter 0.22.4
Reduces peer dependency warnings during install by upgrading grammars that
have newer versions accepting ^0.22.x: c 0.23.4→0.24.1, php 0.23.11→0.24.2,
rust 0.23.2→0.24.0. Python 0.23.6 and swift 0.7.1 already compatible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 03:01:59 -06:00
Colby McHenry 9a122b041b Move tree-sitter grammars to optionalDependencies for Windows compatibility
tree-sitter-kotlin doesn't ship prebuilt binaries for win32-x64, causing
npm install to fail on Windows without Visual Studio. All grammars are now
optional since the runtime already handles missing parsers gracefully.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 02:51:32 -06:00
Colby McHenry 2ad03d2f7d updates 2026-02-10 02:26:47 -06:00
Colby McHenry d3ba9868df WIP on security-hardening 2026-02-10 00:29:22 -06:00
Colby McHenry d0ee6f7fc4 Enhances code extraction and project indexing
Adds support for Dart and Liquid languages with tree-sitter parsing.
Improves accuracy of code symbol extraction for existing languages.
Indexes project files to enhance code navigation features.
Migrates build system to facilitate code contributions.
Removes git hook functionality.
Integrates Sentry for error tracking and reporting.
Enhances project initialization and configuration loading.
2026-02-09 22:18:59 -06:00
Colby McHenry a4ddedb197 Add Liquid template language support for Shopify themes
- Add 'liquid' to Language type and default include patterns
- Create LiquidExtractor with regex-based extraction (tree-sitter-liquid has ABI issues)
- Extract render/include/section references as component nodes
- Extract schema blocks as constant nodes with parsed names
- Extract assign statements as variable nodes
- Create file relationship edges for snippet/section references

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 15:59:40 -06:00
Colby McHenry 9baf59e5f0 Add interactive CLI installer for Claude Code integration
- New `codegraph install` command and auto-run when invoked with no args
- Beautiful ASCII banner using figlet
- Interactive prompts for global (~/.claude) or local (./.claude) installation
- Writes MCP server config to claude.json
- Writes auto-allow permissions to settings.json
- For local installs: auto-initializes project, indexes, and installs git hooks

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 14:31:29 -06:00
Colby McHenry 0c168c4d8b Add codegraph_explore tool and expand exclude patterns
- Add codegraph_explore MCP tool for deep exploration with condensed output
- Expand default exclude patterns for framework build outputs (.next, .nuxt, .expo, etc.)
- Increase node ID hash length from 16 to 32 chars to prevent collisions
- Add feature request detection with UX clarification reminders
- Update README with MCP tools reference and best practices
- Update CLAUDE.md with context usage guidelines

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 02:42:34 -06:00
Colby McHenry 8f34ce7b13 0.1.2 2026-01-18 18:56:10 -06:00
Colby McHenry cc6e7a5c89 Init 2026-01-18 16:25:00 -06:00