SMT / CASE STUDY 03 / 05

VS Code developer tool

Ledger

Keep the run beside the code.

Captures terminal runs, associates them with hashed code snapshots, and compares changes in source and output.

  • TypeScript
  • VS Code API
  • SHA-256
FIG. 01Controlled execution
TERMINAL / totals.pyPYTHON

RUN 01

items = [2, 2]
print(sum(items))

STDOUT4

SHA-256 54f3b9819406…54f3b9819406f697df5ce0d2a13ffdc14eef80458a06d3a68ab79b29e31867b7

RUN 02

items = [2, 3]
print(sum(items))

STDOUT5

SHA-256 c6d9f6413af0…c6d9f6413af061d0fe7303fafee4f335c944cbdac9d96642a24791c90d671762
Both Python variants were executed for this study. The output and hashes were measured locally. The plate reconstructs the comparison in HTML.

01 / Brief

The problem

Terminal scrollback preserves output but can lose its connection to the source that produced it. After another edit, it becomes difficult to reconstruct which change altered the result.

Context and constraints

Ledger runs inside VS Code and listens for shell integration events from the integrated terminal. Its history is scoped to the workspace, and capture depends on shell integration and the command filter.

My contribution

I implemented the VS Code extension, including execution capture, source snapshots, workspace history, and comparison views. The implementation commit and source links show how those pieces connect.

02 / System

Architecture

  1. Shell integration

    VS Code start and end events delimit a run. A command filter excludes routine shell operations by default.

  2. Snapshot and history

    Ledger reads the editor buffer or file, normalizes line endings for SHA-256, and stores source and run output in workspace history.

  3. Tree and comparison views

    The activity view opens past executions. The comparison panel calculates separate diffs for source and recorded output.

Core functionality

Capture a run
Supported executions record the command, output, and exit status, with a source snapshot when the extension resolves a file.
Reopen earlier output
Workspace storage keeps past runs available after a window reload.
Compare two runs
Source and output can be compared independently. The extension also offers a native VS Code source diff.

03 / Engineering

Decisions and evidence

Store the source alongside the digest

The SHA-256 digest identifies a normalized text snapshot. Keeping the source makes a diff possible, and keeping the output makes it possible to inspect what changed between the two executions.

Observed in source or example

A one-line change with a visible result

In the controlled Python example, changing the second list item from 2 to 3 changes stdout from 4 to 5 and produces a different SHA-256 digest. The repository’s comparison tests cover the panel separately.

Revisit the evidence plate

04 / References

Read the source