Coding Tools
Kompile organizes its coding tools into two complementary layers — Code Understanding & Navigation and Change Tracking & Verification — so agents explore without dumping entire files into context, make edits safely, and leave a complete, auditable trail of every change and test run:
Code Understanding & Navigation
- Local Code Index (
local_code_index/kompile code-index) — an offline SQLite + FTS5 structural index with background watchers, call graphs, blast-radius analysis, git co-change history, and portable KGraph projection. - File Context & Notes (
file_context,read(include_context=true),file_note,file_activity) — a fast, bounded, read-only dossier for any file combining indexed declarations, structural/KGraph edges, durable per-file notes, and relevant open incidents. - LSP (
lsp) — real language-server intelligence (definition, references, call hierarchy, hover, project-wide rename) and a fail-closedcheckverification gate across ~45 languages, including multi-backend C/C++/CUDA compile databases.
Change Tracking & Verification
- Draft Workflow (
draft/draft_batch) — a JGit-backed staging repo (.kompile/drafts.git) for preparing reviewable or off-tree changes during builds or multi-agent work, with 3-way rebase, atomic drift/lock-checked apply, and clean revert. - Diff Index (
diff_index//diffs) — a searchable, filterable, sortable index of every coding-agent edit and draft revision/apply/revert (including untracked files), attributed to exact session, agent, and model. - Automatic Test Milestones (
test_milestone//test-milestones) — deterministic harness capture of real test runs stamped with GitHEADand session/subagent origin, with built-in anti-spoofing safeguards.
How the layers work together
text
1. Orient (cheap, broad)
local_code_index ──► find symbols, callers, implementors, impact, debug_trace
│
▼
2. Inspect one file (bounded, zero file-dump)
file_context / read(include_context=true) ──► notes + declarations + KGraph edges + incidents
│
▼
3. Make or stage changes safely (Change Tracking)
• Direct edits: edit / edit_batch / edit_patch (read-before-edit + edit_coordinator locks)
• Staged edits: draft / draft_batch (.kompile/drafts.git ──► show ──► rebase ──► atomic apply/revert)
│
▼
4. Verify before declaring done (fail-closed)
lsp action=check file_paths=[...] + build / test run (auto-recorded by test_milestone)
│
▼
5. Audit & trace history anytime (Change Tracking)
diff_index / /diffs (every edit & draft commit) + /test-milestones (verified pass/fail trail)Every layer feeds the next:
lspcan address targets bysymbolinstead of manual line/column coordinates by resolving the symbol through the local code index.file_contextreads the committed local code index (in a non-blocking SQLite WAL transaction) and joins it with the projected.kompile/graph.kgraph, durablefile_noterecords, and open project incidents.BackgroundIndexServicelistens directly to Kompile'seditandwritetools (noteFileWritten), so incremental index refreshes kick off immediately after an edit and subsequent reads join cleanly without stalling on directory walks.
Change tracking: how changes are made, staged, and audited
Kompile never treats edits as opaque shell side effects. Every code modification flows through one of two tracked paths — and both feed the same audit trail:
- Direct working-tree edits (
edit,edit_batch,edit_patch,write):- Guarded by the Enforcer's read-before-edit rule so replacements match exact current text rather than guessing.
- Multi-file changes batch in one
read_batch→edit_batch/edit_patchpass, with atomic per-file application andedit_coordinatorfile locks when multiple agents share a repository. - Every edit is recorded immediately in the session's tool-call journal (visible via
/diffs) and indexed intodiff_indexwith itsoldString,newString, unified diff, session, agent, and model.
- Staged off-tree drafts (
draft&draft_batch):- When a build is active, a file is locked by another session, or you want to review a diff before touching your working tree, agents stage edits in
<project>/.kompile/drafts.gitinstead of ad-hoc temp copies. - Drafts support
show(unified diff),rebase(3-way merge against moved live files), atomicapply(refuses drift or foreign locks), and cleanrevert— and everycreate,revise,rebase,apply, andrevertwrites an attributed entry (source=kompile-draft) intodiff_index.
- When a build is active, a file is locked by another session, or you want to review a diff before touching your working tree, agents stage edits in
- Verification tied to changes (
lsp action=check&test_milestone):- Touched files (or staged draft overlays) pass fail-closed
lsp action=checkbefore full builds. - When tests run via
build,process, orbash, Kompile automatically captures real pass/fail counts alongside the GitHEADrevision (source=harness), inspectable via/test-milestones.
- Touched files (or staged draft overlays) pass fail-closed
When to use which tool
| Need | Best Tool | Why |
|---|---|---|
| Locate a class, function, or concept across a repo | local_code_index (ranked_search, blended_search, spath) | Multi-signal ranking + graph boost, offline SQLite FTS5 |
| Understand a file's public surface before opening it | file_context or local_code_index action=signatures | Bounded summary (70–95% fewer tokens than reading raw files) |
| Trace a bug from symptom to blast radius in one call | local_code_index action=debug_trace | Combines search + callers + trace + impact in one step |
| Check uncommitted changes and what they affect | local_code_index action=changed_context | Git-aware entity + impact analysis |
| Jump to exact resolved definition or all typed references | lsp (definition, references, call_hierarchy) | Compiler/type-checker precision (resolves overloads & imports) |
| Rename a symbol safely across a codebase | lsp action=rename (dry_run=true first) | Semantic WorkspaceEdit with diff preview before writing |
| Verify edits compile/type-check before running full builds | lsp action=check | Fail-closed multi-file gate (incl. multi-DB clangd & overlay) |
| Leave a durable warning/rationale pinned to a file | file_note action=add | Survives code reindexing & KGraph replacement; surfaced by file_context |
| Search literal strings, config keys, or non-code files | grep / grep_batch | Fast exact/regex text search where AST/LSP doesn't apply |
| Coordinate edits across parallel subagents | file_activity + edit_coordinator | Tracks reads/writes, change notifications, and file locks |
| Stage changes for review or during a build window | draft / draft_batch | Version-controlled JGit drafts (.kompile/drafts.git), 3-way rebase, atomic drift/lock-checked apply & revert |
| Search historical coding-agent edits, unified diffs & draft history | diff_index / /diffs | Searchable, filterable, sortable old/new/unified diffs across sessions, agents & kompile-draft commits (even for untracked files) |
| Track verified test passes & regressions across commits | test_milestone / /test-milestones | Automatic harness capture (source=harness) across 20+ test runners, anti-spoofing guards, and commit attribution |
Dive into each tool
- Languages & Required Tools — what works out of the box vs which language servers need to be installed, root markers, build files (
compile_commands.json,pom.xml,pyproject.toml,tsconfig.json), and install commands for all 45+ languages. - LSP: Language-Server Intelligence & Edit Gate — all 10 actions,
checkverdicts, C/C++/CUDA compile databases,overlaychecking, and custom server config. - Local Code Index & Code Graph — SQLite FTS5 + incremental fingerprinting, background watchers, KGraph projection, all MCP actions, and
kompile code-indexCLI. - File Context, Notes & Multi-Agent Activity — how
FileContextServiceassembles bounded context, durablefile_notestorage,read(include_context=true), andfile_activity. - Draft Workflow (
draft&draft_batch) — JGit-backed.kompile/drafts.gitrevisions, 3-way rebase, atomic lock-checked applies, clean reverts, andDraftEnforcerPolicy. - Diff Index (
diff_index) — Searchable, filterable, sortable edit history mined from coding-agent transcripts andkompile-draftcommits, plus/diffsand/api/diff-index. - Automatic Test Milestone Recording — zero-config automatic test capture across JVM, JS/TS, Python, Rust, Go, C/C++, and custom runners, anti-spoofing safeguards,
/test-milestones, andtest_milestone.