Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .claude/skills/agent-eval/corpus.json
Original file line number Diff line number Diff line change
Expand Up @@ -607,5 +607,14 @@
"files": "~3390",
"question": "How does programs.git.enable produce the final git config file in the user's home directory? Trace the flow from the git program module to the home-files machinery that links generated files into place."
}
],
"Tcl": [
{
"name": "tcllib",
"repo": "https://github.com/tcltk/tcllib",
"size": "Medium",
"files": "~1100",
"question": "How does a tcllib module reach the helpers another module defines? Trace one command from the package that registers it in pkgIndex.tcl down to the private procs it calls in other modules and namespaces."
}
]
}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- ArkTS now parses in the native Rust engine, so indexing HarmonyOS and OpenHarmony projects is faster.
- Solidity now parses in the native Rust engine, so indexing Solidity projects is faster.
- Erlang now parses in the native Rust engine, so indexing Erlang projects is faster.
- **Tcl is indexed** (`.tcl`, `.tm`): `proc` definitions, procs inside `namespace eval` qualified by their full namespace path (nested levels composed), `source`/`package require` imports, call edges between procs across files — including calls written with an absolute name (`::utils::log`) — and `set` assignments as variables. Tcl has no classes: a namespace's members are reported as methods, and TclOO class bodies are not read yet. Core commands (`puts`, `return`, `lsort`, …) are not reported as calls to a symbol that does not exist. Run `codegraph index` on a Tcl project to build its graph.

### Fixes

- Indexing no longer runs out of memory on a file with an extremely long chain of nested calls.
- A doc comment that begins or ends with an invisible character such as a byte-order mark is now indexed without it.



## [1.6.7] - 2026-11-30

### Highlights
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ CodeGraph's parsing engine is a **native Rust kernel**: 20 languages — TypeScr
| **Full-Text Search** | Find code by name instantly across your entire codebase, powered by FTS5 |
| **Impact Analysis** | Trace callers, callees, and the full impact radius of any symbol before making changes |
| **Always Fresh** | File watcher uses native OS events (FSEvents/inotify/ReadDirectoryChangesW) with debounced auto-sync — the graph stays current as you code, zero config |
| **20+ Languages** | TypeScript, JavaScript, ArkTS, Python, Go, Rust, Java, C#, VB.NET, PHP, Ruby, C, C++, CUDA, Objective-C, Metal, Swift, Kotlin, Scala, Dart, Lua, Luau, R, Nix, Erlang, CFML, COBOL, Solidity, Terraform/OpenTofu, Svelte, Vue, Astro, Razor/Blazor, Liquid, Pascal/Delphi |
| **20+ Languages** | TypeScript, JavaScript, ArkTS, Python, Go, Rust, Java, C#, VB.NET, PHP, Ruby, C, C++, CUDA, Objective-C, Metal, Swift, Kotlin, Scala, Dart, Lua, Luau, R, Nix, Tcl, Erlang, CFML, COBOL, Solidity, Terraform/OpenTofu, Svelte, Vue, Astro, Razor/Blazor, Liquid, Pascal/Delphi |
| **Framework-aware Routes** | Recognizes web-framework routing files and links URL patterns to their handlers across more than 20 web frameworks and routers |
| **Mixed iOS / React Native / Expo** | Closes cross-language flows that static parsing misses: Swift ↔ ObjC bridging, React Native legacy bridge + TurboModules + Fabric view components, native → JS event emitters, Expo Modules |
| **Tauri** | Follows a desktop app across its web frontend and Rust core: `invoke('save_file')`, tauri-specta's typed `commands.saveFile()`, your own wrappers around `invoke`, and events in both directions |
Expand Down Expand Up @@ -930,6 +930,7 @@ Say yes to the installer's front-load question with Codex CLI chosen, and it add
| Solidity | `.sol` | Full support (contracts, libraries, interfaces, structs, enums, modifiers, events, errors, state variables, `import`/`using` directives, `emit`/`revert` calls) |
| Terraform / OpenTofu | `.tf`, `.tfvars`, `.tofu` | Full support (resources, data sources, modules, variables, outputs, providers incl. aliases, `locals`; `var.`/`local.`/`module.`/resource references with Terraform's per-directory scoping enforced; module calls bridged across the boundary — inputs to the child module's variables, `module.M.out` to the child's output, `source` to the module's files; cloudposse/atmos `remote-state` cross-component wiring when the component is statically named; `provider = aws.east` selections resolved up the module tree; `moved`/`import`/`removed`/`check` block references; `.tfvars` assignments linked to the variables they set) |
| Nix | `.nix` | Full support (functions with simple/destructured/curried params, `let`/attrset bindings, `inherit`, `import ./path` file edges — `./dir` resolving through `default.nix` — plus NixOS module `imports = [ ./x.nix ]` lists and `callPackage ./pkg.nix` file edges; call edges; module-system option wiring — a config write like `launchd.user.agents.x = { ... }` links to the module declaring `options.launchd.user.agents`, so option flows trace across modules) |
| Tcl | `.tcl`, `.tm` | Partial support (procs as functions; procs inside `namespace eval` qualified by their full namespace path — nested levels composed, however each level is spelled — as methods, so a call written `::utils::log` reaches the proc it names across files; `set` assignments as variables; `source` and `package require` imports; core commands (`puts`, `return`, `lsort`, …) are not reported as calls. Not read yet: TclOO class bodies, `$arr(key)` array-element syntax (the upstream grammar's own limit) and a final line with no terminator) |

## Measured cross-file coverage

Expand Down
253 changes: 253 additions & 0 deletions __tests__/extraction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14609,3 +14609,256 @@ describe('C++ COM interface declarations (#1519)', () => {
expect(Buffer.byteLength(expected)).toBe(Buffer.byteLength(source));
});
});

describe('Tcl Extraction', () => {
describe('Language detection', () => {
it('should detect Tcl files', () => {
expect(detectLanguage('main.tcl')).toBe('tcl');
expect(detectLanguage('pkgIndex.tcl')).toBe('tcl');
expect(detectLanguage('module.tm')).toBe('tcl');
});

it('should report Tcl as supported', () => {
expect(isLanguageSupported('tcl')).toBe(true);
expect(getSupportedLanguages()).toContain('tcl');
});
});

describe('Function extraction', () => {
it('should extract top-level procs as functions', () => {
const code = `
proc main {argv} {
helper_process $argv
return 0
}

proc helper_process {data} {
puts "processing $data"
}
`;
const result = extractFromSource('main.tcl', code);
const funcs = result.nodes.filter((n) => n.kind === 'function').map((n) => n.name);
expect(funcs).toContain('main');
expect(funcs).toContain('helper_process');
const main = result.nodes.find((n) => n.name === 'main');
expect(main?.language).toBe('tcl');
expect(main?.signature).toBe('{argv}');
});

it('should qualify procs inside a namespace eval as methods', () => {
const code = `
namespace eval ::utils {
proc log {msg} {
puts $msg
}
proc incr_counter {} {
return 1
}
}
`;
const result = extractFromSource('main.tcl', code);
const methods = result.nodes.filter((n) => n.kind === 'method');
const log = methods.find((m) => m.name === 'log');
expect(log?.qualifiedName).toBe('::utils::log');
const incr = methods.find((m) => m.name === 'incr_counter');
expect(incr?.qualifiedName).toBe('::utils::incr_counter');
});
});

describe('Import extraction', () => {
it('should emit import nodes for source and package require', () => {
const code = `
source compat.tcl
package require Tk
`;
const result = extractFromSource('main.tcl', code);
const imports = result.nodes.filter((n) => n.kind === 'import').map((n) => n.name);
expect(imports).toContain('compat.tcl');
expect(imports).toContain('Tk');
});
});

describe('Call and builtin filtering', () => {
it('should mint call refs for user procs but claim builtins', () => {
const code = `
proc helper_process {data} {
puts "processing $data"
return 1
}

proc main {argv} {
helper_process $argv
::utils::log "go"
return 0
}
`;
const result = extractFromSource('main.tcl', code);
const callRefs = result.unresolvedReferences.filter((r) => r.referenceKind === 'calls').map((r) => r.referenceName);
expect(callRefs).toContain('helper_process');
expect(callRefs).toContain('::utils::log');
expect(callRefs).not.toContain('puts');
expect(callRefs).not.toContain('return');
});

it('should claim absolute builtin invocations (::puts, ::set)', () => {
const code = `
::set x 1
::puts "hi"
::utils::log "go"
`;
const result = extractFromSource('main.tcl', code);
const callRefs = result.unresolvedReferences.filter((r) => r.referenceKind === 'calls').map((r) => r.referenceName);
expect(callRefs).not.toContain('::set');
expect(callRefs).not.toContain('::puts');
expect(callRefs).toContain('::utils::log');
});

it('should not mint call refs for dynamic command names', () => {
const code = `
set handler ::utils::log
$handler "go"
0 1
[$obj method] arg
`;
const result = extractFromSource('main.tcl', code);
const callRefs = result.unresolvedReferences.filter((r) => r.referenceKind === 'calls').map((r) => r.referenceName);
expect(callRefs).not.toContain('$handler');
expect(callRefs).not.toContain('0');
expect(callRefs).not.toContain('$obj');
});

it('should claim TclOO class commands instead of minting call refs', () => {
// A class body is one braced word, so its `method`/`constructor` commands
// never become nodes — but each is a `command` node on the way in, and an
// unclaimed one made every project with a TclOO class look like it called
// something named `method`.
const code = `
oo::class create Foo {
method bar {} { return 1 }
constructor {} { }
}
`;
const result = extractFromSource('main.tcl', code);
const callRefs = result.unresolvedReferences.filter((r) => r.referenceKind === 'calls').map((r) => r.referenceName);
expect(callRefs).not.toContain('oo::class');
expect(callRefs).not.toContain('method');
expect(callRefs).not.toContain('constructor');
});
});

describe('Namespace qualification', () => {
it('should qualify a proc by its own absolute path', () => {
// `proc ::a::b::f` and `namespace eval ::a { namespace eval ::b { proc f
// … } }` are the same proc, so both are `f` at `::a::b::f`; before this,
// the first was a function named `::a::b::f` that no call could reach.
const code = `
proc ::abs::f {} { return 1 }
`;
const result = extractFromSource('main.tcl', code);
const f = result.nodes.find((n) => n.kind === 'method' || n.kind === 'function');
expect(f?.name).toBe('f');
expect(f?.qualifiedName).toBe('::abs::f');
});

it('should compose every enclosing namespace, however each level is spelled', () => {
// `namespace eval utils` is the root namespace `::utils` — a call writes
// the absolute path — and a nested level is cumulative, not the nearest
// name alone.
const code = `
namespace eval utils {
proc ping {} { return 1 }
}

namespace eval ::a {
namespace eval ::b {
proc x {} { return 2 }
}
}
`;
const result = extractFromSource('main.tcl', code);
const byName = (name: string) => result.nodes.find((n) => n.name === name);
expect(byName('ping')?.qualifiedName).toBe('::utils::ping');
expect(byName('x')?.qualifiedName).toBe('::a::b::x');
});

it('should not qualify a proc by a `namespace` command that evaluates nothing', () => {
// `namespace export …` is the same node type; it must not become a receiver.
const code = `
namespace export log
proc log {msg} { puts $msg }
`;
const result = extractFromSource('main.tcl', code);
const log = result.nodes.find((n) => n.name === 'log');
expect(log?.kind).toBe('function');
expect(log?.qualifiedName).toBe('log');
});
});

describe('Assignments and separators', () => {
it('should extract `set` assignments and skip a bare read', () => {
const code = `
set x 1
set y [expr {$x + 1}]
set z 3
proc read_one {} { set z }
`;
const result = extractFromSource('main.tcl', code);
const variables = result.nodes.filter((n) => n.kind === 'variable').map((n) => n.name);
// File-scope assignments only — the `set z` read inside the proc is a
// read, and a proc-local assignment is not a file symbol.
expect(variables).toEqual(['x', 'y', 'z']);
});

it('should read a `;`-separated command and a CRLF line', () => {
// The vendored grammar carries a one-line scanner patch for exactly this
// (`;` glued to a word is a terminator, not word continuation) — see
// docs/grammars/tree-sitter-tcl.md. Both separators are everyday Tcl.
const semicolons = extractFromSource('a.tcl', 'set a 1;set b 2\nproc f {} { return 1 }\n');
expect(semicolons.errors).toEqual([]);
expect(semicolons.nodes.filter((n) => n.kind === 'variable').map((n) => n.name)).toEqual(['a', 'b']);

const crlf = extractFromSource('b.tcl', 'set a 1\r\nproc f {} { return 1 }\r\n');
expect(crlf.errors).toEqual([]);
expect(crlf.nodes.filter((n) => n.kind === 'function').map((n) => n.name)).toEqual(['f']);
});

it('should keep the definitions around a command the grammar cannot read', () => {
// `$arr(key)` (array-element substitution) is still an ERROR in the
// upstream grammar, so that command yields nothing — but it must not take
// the file's procs with it. Fixed upstream, then the wasm is rebuilt; the
// gap and its measured size are in docs/grammars/tree-sitter-tcl.md.
const code = `
proc before {} {
puts $colors(-frame)
return 1
}
proc after {} { return 2 }
`;
const result = extractFromSource('main.tcl', code);
const funcs = result.nodes.filter((n) => n.kind === 'function').map((n) => n.name);
expect(funcs).toEqual(['before', 'after']);
});
});

describe('Commands inside a function body', () => {
it('should import a `source` written inside a proc body, and not call it', () => {
// `bodyWalkerUsesVisitNode`: the body walker used to dispatch `callTypes`
// straight to a call, so a `source`/builtin inside a body still minted a
// call edge the top level claimed.
const code = `
proc load_compat {} {
source compat.tcl
puts hi
}
`;
const result = extractFromSource('main.tcl', code);
const calls = result.unresolvedReferences.filter((r) => r.referenceKind === 'calls').map((r) => r.referenceName);
const imports = result.unresolvedReferences.filter((r) => r.referenceKind === 'imports').map((r) => r.referenceName);
expect(imports).toContain('compat.tcl');
expect(calls).not.toContain('source');
expect(calls).not.toContain('compat.tcl');
expect(calls).not.toContain('puts');
});
});
});

Loading