Skip to content

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 ​

  1. 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.
  2. 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.
  3. LSP (lsp) — real language-server intelligence (definition, references, call hierarchy, hover, project-wide rename) and a fail-closed check verification gate across ~45 languages, including multi-backend C/C++/CUDA compile databases.

Change Tracking & Verification ​

  1. 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.
  2. 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.
  3. Automatic Test Milestones (test_milestone / /test-milestones) — deterministic harness capture of real test runs stamped with Git HEAD and 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:

  • lsp can address targets by symbol instead of manual line/column coordinates by resolving the symbol through the local code index.
  • file_context reads the committed local code index (in a non-blocking SQLite WAL transaction) and joins it with the projected .kompile/graph.kgraph, durable file_note records, and open project incidents.
  • BackgroundIndexService listens directly to Kompile's edit and write tools (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_patch pass, with atomic per-file application and edit_coordinator file locks when multiple agents share a repository.
    • Every edit is recorded immediately in the session's tool-call journal (visible via /diffs) and indexed into diff_index with its oldString, 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.git instead of ad-hoc temp copies.
    • Drafts support show (unified diff), rebase (3-way merge against moved live files), atomic apply (refuses drift or foreign locks), and clean revert — and every create, revise, rebase, apply, and revert writes an attributed entry (source=kompile-draft) into diff_index.
  • Verification tied to changes (lsp action=check & test_milestone):
    • Touched files (or staged draft overlays) pass fail-closed lsp action=check before full builds.
    • When tests run via build, process, or bash, Kompile automatically captures real pass/fail counts alongside the Git HEAD revision (source=harness), inspectable via /test-milestones.

When to use which tool ​

NeedBest ToolWhy
Locate a class, function, or concept across a repolocal_code_index (ranked_search, blended_search, spath)Multi-signal ranking + graph boost, offline SQLite FTS5
Understand a file's public surface before opening itfile_context or local_code_index action=signaturesBounded summary (70–95% fewer tokens than reading raw files)
Trace a bug from symptom to blast radius in one calllocal_code_index action=debug_traceCombines search + callers + trace + impact in one step
Check uncommitted changes and what they affectlocal_code_index action=changed_contextGit-aware entity + impact analysis
Jump to exact resolved definition or all typed referenceslsp (definition, references, call_hierarchy)Compiler/type-checker precision (resolves overloads & imports)
Rename a symbol safely across a codebaselsp action=rename (dry_run=true first)Semantic WorkspaceEdit with diff preview before writing
Verify edits compile/type-check before running full buildslsp action=checkFail-closed multi-file gate (incl. multi-DB clangd & overlay)
Leave a durable warning/rationale pinned to a filefile_note action=addSurvives code reindexing & KGraph replacement; surfaced by file_context
Search literal strings, config keys, or non-code filesgrep / grep_batchFast exact/regex text search where AST/LSP doesn't apply
Coordinate edits across parallel subagentsfile_activity + edit_coordinatorTracks reads/writes, change notifications, and file locks
Stage changes for review or during a build windowdraft / draft_batchVersion-controlled JGit drafts (.kompile/drafts.git), 3-way rebase, atomic drift/lock-checked apply & revert
Search historical coding-agent edits, unified diffs & draft historydiff_index / /diffsSearchable, filterable, sortable old/new/unified diffs across sessions, agents & kompile-draft commits (even for untracked files)
Track verified test passes & regressions across commitstest_milestone / /test-milestonesAutomatic harness capture (source=harness) across 20+ test runners, anti-spoofing guards, and commit attribution

Dive into each tool ​

Released under the Apache-2.0 License.