8000 GitHub - dangom/vigil: agentic traceability within emacs · GitHub
[go: up one dir, main page]

Skip to content
dangomPublic

About

agentic traceability within emacs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

39 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vigil

vigil keeps a record, on your machine, of what a coding agent did and shows it in Emacs: every command it ran, every file it read or changed, every prompt and reply. Each is one key away from the line of the conversation where it happened.

There are two parts:

  • bin/vigil, a hook for Claude Code. Claude Code reports each prompt, tool call, subagent and reply to its hooks, and vigil hook writes each report to a file as it was given. It does nothing else.
  • emacs/vigil.el and the files beside it, which read those reports and show them next to the agent's terminal.

pi is watched the same way, through an extension instead of hooks; see pi below for what works with it so far.

Requirements

  • Optionally cooked, the Emacs terminal, from the dangom/cooked fork, main branch: for what is shown in the agent's own conversation and as a command runs. Everything else works without it: see Without cooked. vigil uses parts of cooked that are not yet in upstream cooked: hosted sessions (cooked-host), annotations on the cooked buffer (cooked-annotate), the pop-up frame (cooked-popup) and the runs that save a command's output as it prints (cooked-run). The tests expect the fork checked out next to this repository, at ../cooked.
  • Claude Code, whose hooks are what gets recorded, or pi 1.5 or later.
  • bash and Python 3 for the hook. jq and bats are needed only for the tests, and Node.js 24 or later for the tests of pi's extension (they are skipped without it).
  • git and perl for snapshots (see below); without perl none are taken.
  • Optionally, shfmt, ruff, prettier and perltidy, to lay out the commands an agent ran (see below). Without them, commands are shown as given.

vigil does not need to know what started the agent. A claude you typed into a hosted shell is watched the same way as one started by a session manager. The two halves find each other by the session's name: cooked tells the program its session's name in COOKED_HOST_SESSION, and a buffer attached to that session has the same name in cooked-host-name.

Without cooked

vigil loads, and vigil-setup runs, in an Emacs that has nothing of cooked's. An agent in any terminal is watched once it is told its session's name: start it with VIGIL_SESSION set, to a name of letters, digits, ., _ and -.

VIGIL_SESSION=myproject.1 claude

M-x vigil then shows that session as it shows any: its prompts, answers, commands, programs, subagents, changes, build and context, what each command changed, the review and the archive. A call opens from any list with what it was given and gave back; with no pop-up frame to show it in, it is shown in a window, where q closes it, l goes back and v visits its file. The session's reports are read into a buffer that is no agent's (*vigil agent: NAME*) for that.

An agent in another terminal inside Emacs (vterm, eat) can have its buffer be its agent's: set vigil-session there to the session's name and turn on vigil-mode.

What needs cooked is what is done in the conversation itself or to the agent: the marks on the lines where calls happened, moving between prompts, focus, the turn's list beside the conversation, a command's output as it runs, and pasting an earlier prompt. Those say that the session is not open in this Emacs.

Where your data goes

vigil keeps whatever the agent saw: file contents, command output, web pages and your prompts, including any secrets the agent read.

  • It is written under ~/.local/share/vigil ($VIGIL_DATA_DIR), outside this or any repository, and only your user can read it.
  • To compare two versions of a file it edited, Emacs writes one of them to a temporary file only you can read, runs diff on it and deletes it straight away. While Emacs runs, it keeps every version of each file the agent edited, one per edit.
  • vigil never opens a network connection, so none of it leaves the machine. A test checks that the code names no program that talks to another machine.
  • Reports are parsed as JSON and displayed. They are never evaluated or sourced.
Where What Kept
records/<session>/ One JSON file per hook event, as Claude Code wrote it (or pi's extension). The newest 2,000 per session. Cleared when a new conversation starts under the same session name, and after 14 days without a report. Put back from the archive when a conversation is resumed, in place of what another conversation left there; vigil restore SESSION [ID] puts them back by hand, and removes nothing.
prompts.jsonl Every prompt given to an agent. The newest 5,000.
archive/ Every event again, verbatim, per conversation. Indefinitely. VIGIL_ARCHIVE=0 turns it off.
files/ The files commands named outside the directory they ran in, as they were: see The files a command named, as they were. 180 days after a command last named them. VIGIL_FILES_MAX=0 keeps none.

An event over its size limit (4 MB in the records, 1 MB in the archive) keeps its shape, but its biggest values are replaced by {"vigil_truncated": true, "bytes": N, "head": "…"}.

Install

ln -s "$PWD/bin/vigil" ~/.local/bin/vigil
vigil setup --dry-run   # show what would change
vigil setup             # the record hook, snapshots, and pi's extension if pi is here
vigil doctor            # what is in place, and the command for each thing that is not
vigil grammars          # optional: build the grammars Rust, TypeScript, Go… are highlighted by

Then, in Emacs, with cooked and this repository's emacs/ on the load-path:

(require 'vigil)
(vigil-setup)

Restart any agent that was already running: it keeps the hooks it started with.

vigil setup does what the commands below do one by one, and can be run again after updating vigil; it changes nothing that is already in place. vigil setup --shell also follows commands as they run, which changes how Claude Code starts every command (see below). vigil doctor only reads. Run it when something is not showing up: it says off, partly (set up by an older vigil) or old beside what needs doing.

What runs, and when

Three things can run when an agent does something. Only the snapshot is waited for.

What When Waited for Takes Turned on by
vigil hook writes the report every prompt, call, subagent and reply no nothing the agent notices vigil install-hooks
vigil snapshot keeps the files as they are a prompt given, the agent stopping yes about 0.07 s vigil snapshots on
the same, around a command before and after each Bash command yes about 0.04 s each when nothing has changed, 0.08 s when something has vigil snapshots on
vigil-shell saves a command's output as it prints each Bash command it is the command a few milliseconds vigil install-shell

The snapshot before a command has to be waited for: taken while the command ran, it could already hold what the command changed. The one after is waited for so that the agent's next call does not change files while they are being read, which would put that call's changes on this command.

Almost all of a snapshot's time is starting programs, not reading files: git is started about a dozen times, and each start costs a few milliseconds. So around a command vigil first asks git one question, whether any file differs from the last snapshot, and stops there when none does, which is most of the time. On macOS, /usr/bin/git is a program that finds git and then runs it, three times slower to start than git; vigil runs the git it would find directly.

One by one

vigil install-hooks --dry-run   # show what would change in ~/.claude/settings.json
vigil install-hooks             # merge vigil's hook in, keeping all others
vigil uninstall-hooks           # take it out again, keeping all others

install-hooks and uninstall-hooks first back up the settings file to settings.json.vigil-backup-<time>, and a backup never overwrites an existing file. The hook runs asynchronously on every event, so the agent never waits for it. Agents that are already running keep the hooks they started with, so restart them to have them watched.

pi

vigil install-hooks --agent pi --dry-run   # show what would be copied, or changed
vigil install-hooks --agent pi             # copy pi/vigil.ts to ~/.pi/agent/extensions/
vigil uninstall-hooks --agent pi           # remove it again

pi has no hooks in a settings file. It loads extensions, and pi/vigil.ts is one that hands each of pi's events to the same vigil hook, one after another and without pi waiting. Only a vigil.ts that is vigil's is ever replaced or removed. Run install-hooks --agent pi again after updating vigil, and restart any pi that is running. The extension needs vigil on pi's PATH (or its path in VIGIL_BIN). Outside a hosted session it hands over no report; with snapshots on it still keeps those, since a snapshot belongs to the repository.

A report from pi keeps pi's own tool inputs and results, under the names the hook already files by, and is marked "agent": "pi". The extension adds two things pi does not report: how much context the model had read at each call, and the file an edit or write is about to change, as it was before (files up to 1 MB).

What works with pi: the call frame (commands, diffs, files read), vigil-context, a turn's list and its diff, the marks in your files, prompts, the archive and its export. What does not yet:

  • The marks in the conversation, prompt navigation and focus need the conversation as text that stays put. pi's default full-screen mode gives the terminal no such text, so start it with pi --tui-mode regular (or set "tuiMode": "regular" in ~/.pi/agent/settings.json). Even then these are untested with pi.
  • Following commands while they run (below) is for Claude Code only.
  • pi has no subagents of its own, so there are none to show.
  • Two edit calls to one file in the same reply are each given the file as it was before either ran, so the second one's lines may be credited wrongly.

Following commands while they run (optional)

vigil install-shell --dry-run
vigil install-shell     # sets "env": {"CLAUDE_CODE_SHELL_PREFIX": ".../bin/vigil-shell"}
vigil check-shell       # ask the installed Claude Code to run one command through it
vigil uninstall-shell

After this, Claude Code runs every shell command through bin/vigil-shell. When the command comes from the Bash tool in a hosted session, the wrapper hands it to cooked's cooked-host run. That runs the command exactly as it would have run, and also saves its output as it arrives under ~/.local/state/cooked/runs (readable only by you; the newest 200 per session). Anything else Claude Code runs through the prefix, such as its hooks and status line, runs as if the prefix weren't there. So does every command outside a hosted session or on a machine without cooked. The wrapper adds a few milliseconds per command and prints nothing of its own.

The sandbox

With Claude Code's sandbox on, the wrapper runs inside it. install-shell therefore also adds cooked's runs directory to sandbox.filesystem.allowWrite, so a sandboxed command can write to that one directory, where only command output is kept, and nowhere else new. The entry has no effect while the sandbox is off, and uninstall-shell removes it.

If Claude Code changes

The wrapper recognizes the Bash tool's commands by their shape, which Claude Code does not document. If a future version changes that shape, commands still run, but their output is no longer saved as it arrives. There are two ways to notice:

  • vigil check-shell asks the installed Claude Code to really run one command through the wrapper, and reports whether the wrapper recognized it. It starts claude once, on its smallest model, in a scratch directory. Run it after updating Claude Code.
  • In Emacs, vigil compares the runs with the hooks' reports, which are documented. If several commands in a row (vigil-unfollowed-limit, 3) were reported but none of them was saved, it warns you once and says what to check.

Emacs

vigil binds no global keys. M-x vigil is the one command to bind: everything else is a key away from the buffer it opens.

Features

One place to begin: M-x vigil

M-x vigil, or C-c C-s in an agent's buffer, opens one buffer for that session, as magit-status does for a repository. Elsewhere, or with C-u, it asks which session, the one last heard of first. A session that is not open in this Emacs is shown as well, from its reports.

The session, its repository and its branch are in the header line. The views are in the tab line above it, each with its key, the one showing marked:

Key View What it shows
s Status When it began, how many prompts and calls, how long its commands took, what is running, what it is working on, what it built; then the files changing now, its last prompts, and the commits made since it began.
P Prompts Each prompt on one line, the last first: when, how long, its turn as a timeline, and in a wide window how many calls, files and lines. The prompt at point is shown in full: its text, every call it led to (when, counted from the prompt; how long; what kind; what), and the reply. So a prompt is read with what came before and after it.
a Answers The replies alone, each under the prompt it answers.
c Commands Every command the session ran: under which prompt, when, how long it took, what it did (ran, or wrote: changed files), and whether it failed. Those that only looked are counted and left out; L lists them. D lists the longest first.
m Programs What the commands ran: each program, in how many commands and for how long, the most used first: see What the commands used.
e Rework What the session did more than once: commands run again, files read again, files written again: see What was done again.
u Subagents Each subagent on one line, the last first: under which prompt it was launched, when, how long it was at work, what kind it is, how many calls it made, how many files it wrote, and what it was asked. The one at point is shown in full: see A subagent's thread. i goes into it: see A subagent alone.
l Changes The files changing now, and what is changing in each: see below.
b Build The prompts and the repository's commits by when they happened, the last first. A prompt says how many files changed after it; a commit says its branches and tags, and which versions it added to CHANGELOG.md (vigil-status-changelog).
x Context What the agent's context is made of now, what each prompt added to it, and the biggest things in it: see What the context is made of.

Keys

What is at point:

Key Does
RET Opens it: a call in vigil's frame, a commit, a file's diff, a line of a diff in its file; on a prompt, goes to what is beside the list.
o Visits the file at point, or goes to the line of the conversation where the call at point shows.
w Copies the prompt, the reply or the command at point, whole and as it was written.
d Shows what changed after the prompt at point, or the commit at point. A prompt's changes are in Magit's diff, one prompt of the session's: ] and [ there go to the next and the one before.
i Goes into the subagent at point: this buffer, of that one agent. On its line in Subagents, on the call that launched it, or on a call it made.
^ From a subagent, goes back up to its session, at its line in Subagents.
n, p The next and the previous line; M-n and M-p, the next and previous prompt or file.
TAB, S-TAB Fold and unfold what is under a line, one or all, where it is under the line (v).

How a view is looked at:

Key Does
v What is at point beside the list, or under its line.
F In Changes: follow the last change, or stay put.
T In Changes: count from the last prompt, or from the session's beginning.
L In Commands: list the commands that only looked, or leave them out.
D In Commands: the longest first, or the last first. In Programs: the one that led for longest first, or the most used.
g Read the session again.
q Leave, closing the window beside.

? (or h) shows a menu of the views and of the rest of vigil, and the same keys work without it:

Key Goes to
U Its agents at work together
r What the session built
B Its prompts and what changed after each, as a log
X Its context, entry by entry
t A turn, call by call
G Its turns as a graph
f Focus in its conversation
y Paste an earlier prompt at its input
R Running commands
C Where the repository is changing
A The archive
S Another session
O Every agent, and what each is doing
K Fork the session at the prompt at point
Q Ask a question aside, after the reply at point

What is at point, beside the list

The buffer is lists: a line a prompt, a command, a file, a commit. What the line at point led to is shown in full in a second window, which follows as you move:

At point Beside it
a prompt its timeline, the prompt in full, each call it led to, the reply, and the files that changed after it
a prompt, in Answers the reply alone
a sector, in Context the files it read or wrote, each with when and under which prompts, and each thing of it, the biggest first
a prompt, in Context what it added to the context: of which sectors, and each thing, the biggest first
a command, in Commands the command, which prompt it was for, when in the turn, how long
a subagent, in Subagents its timeline, what it was asked in full, each call it made, the files it wrote, and what it reported
a file its diff
a commit what it says, which versions it added to the changelog, the files it changed

The window is to the right where there is room for two side by side (150 columns), and below otherwise. RET goes to it; there, RET opens a call or a line of a diff, w copies, and q leaves. v tur 10BC8 ns it off for the buffer: what a line led to is then under the line, folded, and TAB opens it. vigil-status-detail set to nil makes that the way every session's buffer begins.

The buffer reads the session again by itself, a moment after its agent reports anything (vigil-status-refresh-delay), while it is on screen. It stays where you left it: the same line, the same things folded.

A turn as a timeline

Beside each prompt is its turn drawn as a strip, as long as the turn was among the session's turns (vigil-status-timeline-width, 24 characters for the longest):

   #  When     Took  Timeline                  Prompt
   3  10:02  11m33s  █──────────████           Add a parser for the config file, an…
   5  10:21   3m34s  █████                     Run the tests again and fix what fai…
   8  10:40  18m38s  ────────███─█─█───██████  Now document it, and add an example …

  █ failed   █ command   ▓ edit or write   ▞ test or check   ░ read or look   ▚ subagent   ▒ other   ─ between calls

Each character is an equal share of the turn, drawn as the kind of call that took most of it, or as ─ where calls took under a third of it: the agent was thinking, or writing. A share in which a call failed is drawn as failed. Each kind has a character of its own as well as a face (vigil-ui-kind-command, -edit, -read, -subagent, -other, and vigil-ui-bad), since a theme may give two of them one colour. Beside the list, the turn at point has the same strip as wide as its window, from 0 to how long it took.

In a timeline an edit takes no time worth a character, so it is drawn where it was made if nothing else took that share of the turn. A subagent's own calls are not drawn, only the call that launched it, for as long as the subagent was at work: one that is not waited for is launched in an instant and works on beside its agent.

What the commands used

m lists the programs the session's commands ran, the most used first: what the work leaned on, and so what would be worth making faster.

Programs  34, in 157 commands that took 13m56s in all
Order     most used first   D changes it

  Uses    Led  Share   Took   Mean  Longest  Failed  Program  Where
   105  2m55s    21%  8m41s   5.0s    1m26s          grep     /usr/bin/grep
    95                5m31s   3.6s    1m26s          head     /usr/bin/head
    76  9m48s    70%  9m48s   7.7s    2m01s          emacs    /opt/homebrew/bin/emacs
    46  3m14s    23%  3m14s   4.2s      55s          python3  /usr/bin/python3
     7  5m21s    38%  5m21s    46s    1m26s          bats     /opt/homebrew/bin/bats

A program is counted once for each command it was in, however many times the command ran it. Named too are the program a wrapper runs (timeout 60 emacs, uv run pytest: both), the module python -m runs, and the script an interpreter is given (python3 tools/gen.py: both); a program named by a path of the project's is named that way (bin/vigil). The shell's own words are left out, and what is quoted or in a heredoc is not looked into.

Nothing says which program of a command its time went to. Took is the time of every command a program was in. Led is the time of those it led: where it was not only given another's output, as grep and tail are in emacs … | grep x | tail. So a filter at the end of slow commands has a long Took and little Led, and what leads for long is what the time went to, as far as the words tell. Share is Led as a part of all the commands' time; commands of several programs are counted for each, so the shares come to more than the whole. D puts the one that led for longest first. A command still running counts for as long as it has run.

Where is where the program is now: on the path, or a file of the repository. The commands that used it are beside the list as point comes to its line, or under it (RET, TAB), the longest first, with what else those commands used; RET on one opens it and c goes to it in the list of commands. Under the programs are the agent's own tools, every call counted the same way.

M-x vigil-running counts under a command the processes it started and let go of ((server &), nohup): one that began no earlier than the command and runs a file the command names, or is of the command's own process group. What such a process is doing is said as detached: …, and what it uses is counted with the command's.

What was done again

e lists what the session did more than once, which is where effort went that a clearer prompt or a faster check would have saved.

  • Commands run again: the same command, with how many runs there were, how many failed, how long they took in all and under which prompts. RET opens the last run.
  • Files read again: how many times, what the reads came to in tokens, and what all but the first did. A file read again after a summary threw it away is counted here.
  • Files written again: how many edits, how many lines they wrote in all, and how many lines the file has gained since the session began, where snapshots are kept. Little standing of much written is a file that was rewritten.

Each line says under which prompts it happened.

What the context is made of

x shows the agent's context: how big it is, of what, and how it got there.

Context  366k tokens now
Summarized  at 18:27, from 622k to 32k

  ═════▞▞▐▐▐┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓▓▓▓▓▓▓▓▓▓████████████████▒▒▒▒▒▚▄▄▄▄

     Sector        Tokens  Share  What
  ░  Read            118k    32%  files read and searched, and commands that only looked
  █  Commands         92k    25%  every other command, and what it printed
  ┄  Thinking         48k    13%  what the agent thought
  ▓  Written          35k    10%  edits and files written
  ▒  From outside     18k     5%  the web, other services, documents
  ═  System           17k     5%  the system prompt, the tools, CLAUDE.md and memory
  ▄  Harness          15k     4%  reminders, skills, hooks: what Claude Code put in
  ▐  Replies          11k     3%  what the agent said
  ▞  Summary           6k     2%  what summarizing the conversation left of it
  ▚  Subagents         5k     1%  what subagents were asked, and what they reported
  ▌  Prompts          603    <1%  what you said

By prompt  what each added, the last first
   #  When   Context  Added  Of what                   Prompt
  45  21:40     366k    +2k  ▐█                        cool. Yes, we need to deal with pi later…
  44  21:02     363k   +55k  ┄┄░░░▓▓████               yes that makes sense. Now, we should wor…
  30  18:31     155k  +101k  ┄┄░░░░░░░░░░░░░░█████████ yes absolutely.
  28  18:29      41k   +16k  ▞▞░█▚                     how we doing sub-agent wise? Maybe we sh…
      summarized at 18:27, from 622k to 32k
  27  18:20     622k    +5k  ┄█                        if would be nice if that were to close t…

The biggest in it now  20 of 302
  Tokens  Carried     Sector         #  When   What
     19k     2.1M  ░  Read          30  18:33  Read vigil-status-views.el
     17k     9.4M  ═  System                   What every request begins with
     15k     780k  ▒  From outside  37  19:50  WebFetch https://code.claude.com/docs/en/headless.md
     13k     390k  ▓  Written       41  20:31  Write vigil-fork.el

The bar is the context now, each sector as much of it as it is of the whole, and under it a line a sector, the biggest first. A call is one thing, what it was given together with what it gave back, and is of the sector its tool is of: a command that only looked (cat, grep, git log: vigil-purpose-looking-programs) is a read, as it is in a timeline; a file read whose name is a document's (vigil-tokens-documents: a PDF, say) is from outside, as are the web and every tool of another service. Thinking is in the context too: what the agent thought stays, and is read again by every request after.

Under that is each prompt, the last first: the context its last request read, how much came in under it, and that as a bar, as long as it was big among the prompts. Where the conversation was summarized is a line between two prompts. What it held before is out of the context then, and what the summary left in is a sector of its own. Beside the list, the prompt at point is what it added: its sectors, and each thing, the biggest first, with what has since been summarized away said to be.

Last come the biggest things in the context now (vigil-status-context-biggest, 20).

Beside how big a thing is, is what it has carried: its size, once for every request made while it was in the context. A request reads the whole context again, so a file of 10k tokens read fifty requests ago has been 500k tokens of reading, and the same file read just now 10k: what a read costs is how big it is, times how long it stays. The top of the view says what every request read, all together; a file's line, what its reads carried between them; and a call beside the list, how many requests have read it since. Like the sizes, it is reckoned: by the size a thing has now.

The top of the view also says what the session's requests cost, and how they used the cache. A request is billed in four parts: what it read from the cache, the cheapest; what it read that was not cached; what it wrote to the cache for the next request to read, which costs more than reading; and what the agent wrote, the dearest. Each prompt's line says what its requests came to. The prices are vigil-tokens-prices: Anthropic's list prices for its own API as of November 2026, by model. They change, other platforms have their own, and a subscription is not billed by the token, so read it as what the tokens would cost at those prices.

A conversation going well reads nearly everything from the cache. Under Cache rebuilt is each request that wrote most of its context anew where it would have read it (vigil-tokens-rebuilt, half, of a context of at least vigil-tokens-rebuilt-least tokens), with what was written, what that request cost, and why: it came after longer than the cache is kept (idle 1h46m), the conversation had just been summarized, or neither, which means something early in what every request begins with had changed.

A sector opens into what is of it: beside the list as point comes to its line, or under the line with TAB. Where its calls name files, as what was read and written does, the files come first, each on a line: what it came to in all, how many times it was read, under which prompts, and when.

 ░ Read   115k tokens   41% of the context   31 things

By file: 35 files, the one that came to most first
  Tokens  Times  Prompts  When                        File
     13k      6  1, 2, 3  17:05, 11:32, 11:34, and 3 more  emacs/vigil.el
     11k      4  3, 4     11:36, 11:36, 11:40, and 1 more  emacs/vigil-status-views.el
      9k      1  3        11:36                            emacs/vigil-ui.el
Each: 31 things, the biggest first
  Tokens     Sector  #  When   What
     12k  ░  Read    3  11:36  Bash Read the status buffer's commentary and outline its modules
      9k  ░  Read    3  11:36  Bash Read the shared UI module

A file is one however it was named: by the tool that read it, whole, or among the words of a command that only looked (sed -n 1,60p emacs/vigil.el). A command that names several files is counted equally among them, since which of them it printed most of is not known; a pattern (emacs/*.el) is a name of its own. Then comes each thing of the sector, the biggest first, with the prompt it came in under and when.

From a line there:

Key Goes to
RET the call, in vigil's frame; on a file's line, the file
o the file a call read or wrote, where it names one; else the call's line in the conversation
c the call in the list of commands, where it is a command: one that only looked is listed for it
P the prompt it came in under, and what that led to
x back, at that prompt's line

What is counted, and what is reckoned. Claude Code's transcript says, with each thing the model said, how many tokens its request read and how many it wrote, thinking apart: those are counts. What came in between two requests (what calls gave back, a prompt, what the harness put in) is in all what the context grew by, less what the model wrote; that is shared out among the things that came in by their length. So the sizes together are the count, and each one's share of a step is reckoned. What the first request read, less the prompt it was given, is the system's: the system prompt, the tools, CLAUDE.md and memory, which no line of the transcript holds.

It needs the conversation's file, which the report of each prompt names, and reads it once: later, only what was written since. A subagent's context is its own, and only what it was asked and what it reported are in its agent's. pi's reports name no such file, so nothing is said of a session of pi's.

A subagent's thread

u lists the session's subagents. Beside the list, or under the line with TAB, the one at point is its own thread, apart from its agent's:

  • a timeline of its own calls, from when it began to when it was done;
  • what it was asked, whole;
  • each call it made: when, counted from its beginning, how long, of what kind, and how it went. RET on one opens it, as anywhere;
  • the files it wrote: those it edited, and those that differed after a command of its;
  • what it reported back, whole. w copies it.

In Commands, a command a subagent ran says which kind of subagent ran it, under "By".

What to know:

  • What a subagent that is not waited for hands back comes to its agent as a prompt does. It is nobody's prompt: the turn the subagent was launched in goes on, through to the reply after it, and is one turn in every view.
  • An agent and its subagents work at once in one repository, and a snapshot says that the files differed after a command, not who wrote them. A file another call edited while a command ran is that call's; and a command that by its words only looks, run while another agent was at work, is a look. Two commands that write at once cannot be told apart: each is given what differed.
  • The agent's own summary of a conversation grown long is reported as a subagent's end is. It is not listed.

A subagent alone

i on a subagent goes into it: M-x vigil, of that one agent and nothing else. It is shown as a session of one turn is. What it was asked is its prompt, the calls it made are its calls, and what it reported is its reply; so every view is of it:

  • Status says what kind it is, which prompt of its session it was launched under, how it stands (at work, done, failed, left off), how long it took, and its calls;
  • Prompts and Answers are what it was asked and what it reported, whole;
  • Commands, Programs and Rework are of its commands alone;
  • Subagents lists the ones it launched itself, if it launched any;
  • Changes and Build count from the last snapshot kept before it began to the last kept before it was done, or to now while it is at work;
  • Context is read from its own conversation, which Claude Code keeps in a file beside its session's: how big its context is, of what, and what its requests cost.

The header line names the session, then the subagent and what it was asked. ^ goes back up to the session, at the subagent's line. The buffer is read again as the subagent reports, as a session's is.

What to know:

  • The files that differ while a subagent works are counted, not the files it wrote: another agent at work in the repository then wrote into the same snapshots.
  • A subagent has no conversation to fork or to ask aside of: K and Q say so.
  • X, t, f and y act on the agent's buffer, which is its session's.

A command, to be read

Agents write shell the way nobody reads it. Where a command is shown whole, beside the list in Commands, it is laid out as the call's frame lays it out: parsed and printed again by shfmt, a long chain broken before its &&, highlighted as shell, and the programs inside it (the argument of python3 -c, a heredoc) taken out to blocks of their own, each formatted and highlighted in its language:

cd src \
  && grep -rn TODO . | sort | uniq -c | sort -rn | head -20 \
  && python3 -c ‹1›

‹1› python3 -c
import sys

print(sys.version)

Above it is why, in the agent's words, where it said. In a list, a command its agent described is that description; one it did not is the command itself on one line, highlighted. w copies the command as it was given. vigil-status-tidy set to nil shows commands as given; so does not having shfmt.

Under the command is what shellcheck says of it, if it is installed and says anything: where, how serious, what, and its code. Only warnings and errors (vigil-status-shellcheck-level); the lines and columns are of the command as it was given. vigil-status-shellcheck set to nil checks nothing. The command is given to both programs as text: nothing in it is run.

What a command was for

An agent's command is seldom one thing: it changes three files, runs the tests and commits. Commands says what each was for, in a word each, and the timeline draws a run of tests apart:

   #  When    Took  For             Command
  12  10:41   3.6s  tests test git  Fix the sample command, rerun the suite, then commit
  12  10:40    25s  test            Run every suite
  12  10:38   2.0s  code check      Use the tags in the list, and compile
It says When
code, tests, docs files of that kind differed after it, by their names (vigil-purpose-test-files, vigil-purpose-doc-files)
write it wrote a file, and which is not known: by its words (a redirection to a file, sed -i, one of vigil-purpose-writing-programs), or by a snapshot that says the files differed
test it ran tests: pytest, bats, cargo test, make test, Emacs's ert-run-tests…
check it ran a linter, a formatter or a compiler
git it changed the repository's history or branches; or gh
setup it installed something
look none of the above, and its words only look: every program it runs is one of vigil-purpose-looking-programs (sed without -i, find without -delete or -exec, git with one of vigil-purpose-looking-git), and it writes no file
run none of these: it ran something no rule knows

Every command is at least one of these. From them a command is counted and drawn as one of three kinds, since an agent reads with cat and grep and writes files with scripts as much as with its editing tools:

Kind When In a timeline
a write it is code, tests, docs or write ▓, as an edit is
a look it is look ░, as a read is
a command anything else █, or ▞ if it is test or check

So the counts read "139 calls: 56 commands, 34 writes, 35 looks, 5 edits": an edit is a call to an editing tool, a write is a command that changed files. Commands leaves the looks out until L lists them.

Above the list is how many commands were for each, and beside a prompt, how many of its turn's were. The rules are vigil-purpose-rules: a program has to be where a program is, so grep pytest runs no tests, and what is quoted or in a heredoc is not the command's own words, so a commit whose message speaks of tests runs none.

Beside a command is why it was said to be each, and what it goes by:

What it was for
  tests  tests/vigil-status-tests.el
  test   ert-run-tests-batch-and-exit: Ran 14 tests, 14 results as expected
  git    git add, git commit, git tag

Programs, where each is now
  python3  /usr/bin/python3
  emacs    /opt/homebrew/bin/emacs
  git      /usr/bin/git

Python: python3, from its standard input
  imports  requests; json, re, of Python's own
  writes   tests/vigil-status-tests.el
  reads    tests/vigil-status-tests.el
  runs     bats tests
  asserts  2
  • How tests went is the end of what the command printed.
  • A program is where it is now, which is not always where it was when the command ran.
  • A Python program inside the command is read by Python's own parser (ast), started apart from its surroundings (python3 -I): what it imports, the files it writes, makes or removes and those it reads, the commands it runs, how many assertions it makes. It is parsed and none of it is run. A name given a string is that string; one that is worked out is said to be. What it runs is the command's too: Python that runs pytest is a test, and Python that only asserts is one. Where no snapshot says which files differed, the files it says it writes are gone by.
  • In a list the Python is not looked into, since that starts Python once a command: what only the Python shows is said beside the command, not in its line.

What it does not know, and where it errs:

  • It errs towards run. A program no rule knows runs something, so python3 script.py and git stash list are run though they may only read.
  • Which files a command wrote is known from the snapshot kept after it, which sees the repository's files that git does not ignore. Its words see files outside the repository too, but not what a script writes. In the session this was written in, of 43 writes the snapshots found 35 and the words 17.
  • A command that ran the tests and wrote a file is both, and is drawn as a write.
  • What a script on disk does (python3 gen.py), a program other than Python inside a command, and which packages a program loaded as it ran: that last could be kept by the coverage hooks, and is not yet.

What is changing now

l, or M-x vigil-live, or C-c C-w in an agent's buffer: the files that differ from when the last prompt was given, the one written last first, with how many lines went in and out and how long ago. Under the list is each file's diff, the last written one showing and the others folded.

  • It is read again as the agent works, and while it follows (F turns that off and on) it goes to the line that is new: the first line of the last written file's diff that was not there the time before.
  • T counts from the session's beginning in place of the last prompt.
  • RET on a line of a diff visits its file at that line; on a file, in the list or in Status, it shows that file's diff.
  • The first 12 files have their diff laid out (vigil-status-live-files).

This needs snapshots (vigil snapshots on, which vigil setup does). What is shown is the repository as it is now against the snapshot kept at the prompt, so it is everything that changed since, whoever changed it. Asking how things are now keeps no snapshot when nothing has changed since the last one.

How it is laid out

Tables are as wide as what is in them and never wider than the window: one column, the prompt or the command, is cut to the room there is. A prompt and a reply are each a block with a rule down its left side, filled to 88 columns (vigil-ui-text-width) or to the window where that is narrower, a list item hanging under its own words. Every list is the last first: the prompt, reply, command or commit that is newest is at the top, and is where a view opens. Change the window's width and the buffer is laid out again (vigil-ui-max-width is the widest it goes, 140 columns). Replies are written in Markdown: headings, bold, code and bullets are shown as such, with the marks hidden.

Every face inherits a standard one (bold, shadow, success, error, warning, help-key-binding, the tab line's), so a theme styles vigil without knowing of it; they are listed under Settings.

What to know

  • The views are read from the session's reports, which are kept for 14 days and start afresh when the agent is started anew under the same name.
  • A call, the context, a turn's list and focus act on the agent's buffer: for a session that is not open in this Emacs they say so.
  • Only the reply that ended each turn is reported, not what the agent said between calls: that is all Answers has.
  • A call that fails is reported as failed, with when (0.3.1; run vigil setup again after updating, and restart the agents). One that failed before that reported no end: once its agent has gone on, it is listed as "no end", with no duration, and is not counted as running.
  • The files and lines beside a prompt are what changed between the snapshot kept when it was given and the one kept at the next prompt. A message sent while the agent is at work is a prompt of its own, with its own snapshot: what changed after it is beside it, not beside the prompt that began the turn. It is by time, not by cause: work the agent was already doing for the earlier prompt, finished after the message arrived, is beside the message.

Another conversation, from a point of this one

K on a prompt in M-x vigil forks the session there: a new conversation that knows what this one knew at that point and nothing after. This session is left as it is. It asks two things.

Where:

Where The fork knows For
before the prompt everything up to the reply before it asking something else in its place. The prompt is put in the kill ring, to yank and change.
after its reply everything up to and with that reply going on another way from there. In Answers, this is what K does.

And how much of the conversation it carries, having said how big it is there:

Carry The fork begins with Costs
the whole of it every message up to the point, as it was said the whole conversation, every turn from then on
a summary the agent's own summary of it, made as the fork is made the whole conversation once, to summarize; little from then on
a digest each prompt and the reply that ended its turn, from vigil's records, as the first prompt of a new conversation little: no call and no result is in it

A fork has two halves.

  • The code is vigil's to make, whatever the agent: a git worktree of its own, .worktrees/<branch> in the repository, on a new branch fork-p<prompt>-<when>, with the files as the snapshot vigil kept at that point has them. The branch begins where the repository stood then, and what was not committed then is not committed there either. With C-u K the fork has no worktree: it works where this session does, on the files as they are now.
  • The conversation is the agent's program's to make. The fork's first prompt is vigil's, saying that it is a fork and where its files are.

The run that makes the fork reports to vigil under a name of the fork's own, <session>.<branch>, so what it does and the snapshots kept of it are the fork's and nobody else's. M-x vigil-agents lists a fork with what it is a fork of, and its own M-x vigil says so in its header line.

Who opens the agent

Vigil starts no agent. When the fork is made it is handed to vigil-fork-launch-function, which here only puts the command that takes it up in the kill ring:

cd <worktree> && VIGIL_SESSION=<session>.<branch> claude --resume <id>

Whatever starts your agents adds its own way with add-function, and vigil's is what is left when it declines. Coterie does this by itself when both are loaded: it adds an agent to the fork's project, in the fork's worktree (ct add --worktree <branch> --resume <id>). Neither needs the other.

Which programs, and how

Each program whose conversations can be forked is in vigil-fork-harnesses, with the ways it has of making a fork, the best first. They are tried in turn until one makes it: a way a program no longer has costs that way, and not the fork. If the fork then carries less than was asked for, that is said.

Program Ways, in order
Claude Code 1. Resumed up to the message to stop after, and forked (--resume <id> --resume-session-at <message> --fork-session). 2. Where the conversation has been summarized since, so that its earlier messages are in its file and no longer in it, or where the first way is refused: a copy of the file up to the point, resumed and forked. 3. A digest, to a new conversation.
pi A digest, to a new session (pi -p --session-id <id>), taken up with pi --session <id>.

A summary is asked of Claude Code by making the fork's first prompt /compact, with what the fork is to be told as what the summary must keep. Another program is another entry: what it is run as, a function giving its ways, and one giving the words that take a conversation up.

A question aside

Q on a prompt asks one question of the session as it stood after that prompt's reply. A fork answers, which may read the repository's files (vigil-fork-ask-tools), and the answer is shown in a buffer of its own. The session is not asked, and knows nothing of it. The fork that answered is a conversation like any other, listed among the agents, and the buffer says how to take it up.

What to know:

  • A fork is made by a run of the program that prints and ends, on your own login. Claude Code's first two ways rest on an option claude --help does not list and on resuming a file by its path. Both were tried against Claude Code 2.1.322, and pi's against pi 1.6.0. If either goes, the next way is taken.
  • Carrying the whole, or a summary, sends the whole conversation up to the point once. K says how many tokens that is before asking.
  • A digest has what vigil has: the prompts and the replies that ended turns. What the agent read, ran and was told in between is not in it. It is cut to vigil-fork-digest-limit characters from its end: the last turns whole, and of those before, what was asked.
  • The worktree has what the snapshot has: what git does not ignore. Files it ignores and the work needs are copied in if named in vigil-fork-copy-files; what is installed there (dependencies, builds) is not.
  • A point with no snapshot (snapshots were off, or have been pruned) can only be forked on the files as they are, with C-u K.
  • Before the first prompt nothing was said: there is no conversation to fork, only the code, and the worktree alone is made.
  • Nothing removes a fork's worktree or branch: git worktree remove and git branch -d do.

Every agent: M-x vigil-agents

M-x vigil-agents, or O in a session's buffer, lists every session that has reported in the last day, one a line, those at work first, and under each its subagents that worked lately. All of them are drawn on one line of time, the last hour up to now:

 Agents   ▶ 1 at work   ◌ 1 quiet   ● 1 done   21:52:34
     Session                 For  Last 1h                 Changed     Prompt                Now, or answered
  ▶  api.1                 5m05s                  ░░█▓▞▞  4 +126 −12  Add paging to /items  Run the tests
  ▶    ↳ general-purpose   2m10s                     ░░█              Check the callers     Bash Search for callers
  ◌  tools.2             42m ago        ░─                            Bump the linter
  ●  docs.1              14m ago          ░▓▓─▓                       Shorten the intro     It is two paragraphs now.

This example is drawn by hand. The mark before a session says how it stands, and the header says what each mark is:

Mark Meaning
▶ At work: it was prompted, or went on after a subagent handed back, and has not replied. "For" is how long.
◌ Quiet: at work, with no call going and nothing heard for 10 minutes (vigil-agents-quiet). It is waiting to be allowed something, or is gone.
● Done: it replied, and it is your turn. "For" is how long ago.
○ New: it began and was given no prompt.

A subagent's mark is ▶ at work, ● done, ✗ failed or ◌ left off, as in M-x vigil-team.

A session's line of time shows when its own agent worked and at what, a turn after another, in the characters a turn's timeline is drawn in; it is blank where the agent waited for you. A subagent's shows its own calls. Reading down a column says who worked while whom, across sessions. z draws the last 15 minutes, hour, 6 hours or day (vigil-agents-spans), and a subagent is listed while it is at work or was heard of in the time drawn.

"Changed" is the files and lines that differ since the session's last prompt, as of the last snapshot kept. The last column is the call going now, or the last one made; and for one that is done, the first line of what it answered.

The list is laid out to its window, all of its width, and no line wraps:

  • A session's name is cut to a fifth of the width.
  • The room the other columns leave is shared between the prompt and what is going now.
  • The line of time is a fifth of the width, and at least vigil-agents-lane-width.
  • A column "In" names the repository only where some session's name does not contain it.
  • A window under 110 columns leaves out what changed and draws a shorter line of time.

Under the list is the agent at point, a session's own in its last prompt or a subagent: what it was asked, the calls it has going, its last calls, what it wrote and what it said. It follows point and is read again as the agent reports. The list's window is as high as the list, between a third and two thirds of the frame, and the agent has the rest. v shows it or not, TAB goes to it, and vigil-agents-detail set to right puts it to the right of the list.

A fork says after its name what it is a fork of, and at which prompt. Where two sessions are one conversation (the run that made a fork, and the agent then opened on it under another name), the one last heard of is listed.

Key Does
RET, i Go into the agent at point: the session (M-x vigil), or on a subagent's line that subagent alone, from which ^ goes up to its session.
TAB Go to the window under the list, where the agent at point is shown.
v Show the agent at point under the list, or do not.
z Draw more time, or less: the last 15 minutes, hour, 6 hours or day.
l Open it at what it is changing now, followed as it is made.
u Open it at its subagents.
t Show its agents at work together: M-x vigil-team.
o Go to its agent's buffer, where it is open in this Emacs.
a List the sessions not heard of for a day as well, or the recent alone.
g Read every session again.

The list reads itself again every 3 seconds while it is on screen (vigil-agents-refresh); a session is read again only when it has reported since.

What to know:

  • It is read from each session's reports and from the snapshots kept of its repository. No agent need be open in Emacs, nothing is asked of one, and no snapshot is taken to draw it.
  • An agent that asks to be allowed something reports nothing while it waits: it is at work, and after 10 minutes quiet. So is one whose terminal was closed in the middle of a turn.
  • Reports are kept for 14 days: a session not heard of for longer is not there to list.

A session's agents together: M-x vigil-team

M-x vigil-team, U in a session's buffer or t in the list of every agent, shows a session whose agent has subagents out: the several that work at once, a line each. M-x vigil shows one agent; this is where to begin when there is more than one.

 Team   api.1   3 at work   3 subagents, 1 done   21:52:34
Prompt 12  21:40, 12m31s  Review the paging change three ways, and fix what they find
             Agent                 For  Calls  When, and at what                 Asked                  Now, or reported
  ▶ at work  the agent          12m31s      9  ─▚▚▚▚▚▚▚▚▚▚▚▚▚▚▚▚▚▚▚▚▚▚▚▓▓─█▚▚▚▚  Bash Run the tests
  ● done     ↳ Explore           3m02s     41   ░░░░░░█░░                        Where paging is used   Three callers, one of them untested.
  ▶ at work  ↳ general-purpose  11m58s     87   ─█▓██▒█──▓─█▓─▓▓█─▓██▞▞─▓▞▞▞█▞▞  Check the edge cases   Bash Run the paging tests
  ▶ at work  ↳ general-purpose   2m10s     12                             ─░░▓█  Fix the off-by-one     Edit items.py

Under each prompt that launched subagents, and under the last prompt whether it did or not, the last first: the session's own agent, then each subagent launched there, in the order they were launched.

Shown Meaning
▶ at work It has not reported, and its agent has not gone on without it. For the session's own agent: it has not replied, or has made a call since.
● done It reported.
✗ failed The call that launched it failed.
◌ left off It was waited for, never said it was done, and its agent has gone on.

"For" is how long it has been at work, or was. "When, and at what" is every agent under the prompt on one line of time, from the prompt to the last thing heard of any of them, and to now while one is at work: blank before an agent began and after it was done, and between, what it was doing when, in the characters of a turn's timeline. So who worked while whom, and who is still at it, is read down the column. The last column is the call an agent has going, or the last it made; and for one that is done, the first line of what it reported that is not a heading. A window 8 under 11 10BC8 0 columns leaves out what it was asked.

Beside the list is the agent at point, and where it is:

  • its own timeline, from when it began;
  • what it was asked, its first 8 lines (vigil-team-asked-lines);
  • the calls it has going now;
  • its last 14 calls, the last first (vigil-team-calls): when, counted from its beginning, how long, of what kind, and how it went. RET on one opens it;
  • the files it wrote;
  • what it reported: first, once it is done, and last while it is at work.

It follows point, and is read again as the agents report, leaving whoever reads it where they are.

Key Does
RET, i Go into the agent at point. A subagent: M-x vigil of it alone, from which ^ comes back up. The session's own agent: the session, at that prompt.
TAB Go to what is beside the list.
v Show the agent at point beside the list, or not.
s Open the session: M-x vigil.
u Open it at its subagents, on the one at point.
l Open it at what it is changing now.
o Go to its agent's buffer, where it is open in this Emacs.
w Copy what the agent at point reported.
M-n, M-p The next and the previous prompt.
O Every agent.
g Read the session again.
q Leave, closing the window beside.

The buffer reads itself again every 2 seconds while it is on screen (vigil-team-refresh): the reports only when there are new ones.

What to know:

  • It is read from the session's reports, as M-x vigil is. No agent need be open in Emacs, and nothing is asked of one.
  • A subagent that is waited for is tied to the call that launched it only once it is done: until then what it was asked is that of the oldest unanswered launch of its kind.
  • The session's own agent is drawn as at a subagent for as long as one it launched was at work, where it did nothing else: as in a turn's timeline.

Calls in the conversation

A wedge in the fringe marks each line where a command ran, a file was changed or a subagent was launched. The agent says "Bash" for every command; the wedge is coloured for what the call was, as it is drawn in a timeline (vigil-mark-kinds): a read or a search, and a command that only looked; an edit, and a command that wrote a file; any other command; a subagent; what came from outside; any other call. Several calls marked on one line have the colour of what most of them were. In the right fringe of a marked line is a gauge of how full the context was when the call was made (vigil-mark-context): a box filled from its bottom, in eight levels, full at vigil-context-window tokens (1M), and in another colour when it was nearly full. It takes no room of the line's; the mark's tooltip says the number. The faces are vigil-mark-read, -edit, -command, -subagent, -outside, -other, vigil-mark-context-size and vigil-mark-context-full. When the agent shows calls only as a summary ("Read 2 files"), they are marked together on that line. Click a wedge, or press RET on the line, and a small frame opens over the agent. It shows a command highlighted as shell with its output, an edit as a diff, a file that was read with its contents (an image as the image), or a subagent's task and result.

A file that was read is highlighted in the mode Emacs has for its name, or else for the #! line it begins with. So is what a command printed, where all it did was print one file or lines of it (cat, head, tail, sed -n '10,40p') and coloured nothing itself. Some languages Emacs highlights only by a tree-sitter grammar, and comes with none: Rust, TypeScript, Go, YAML, Dockerfiles, CMake, and Markdown where no other mode for it is installed. vigil grammars, or M-x vigil-grammars-install, builds those of vigil-grammars that are missing, once, into ~/.local/share/vigil/grammars: each from the source and the revision Emacs itself names for it (Emacs 31 does), cloned with git and compiled, which needs a C compiler and the network that one time. Only vigil looks there, while it highlights; your own Emacs is told nothing of them. Without them such a file is shown plain, and nothing ever asks to install one while something is shown.

A subagent is said to be running, done, failed or interrupted: failed when the call that launched it came back an error, interrupted when the agent was waiting for it and has since replied or been prompted without the subagent saying it was done. While it runs, the frame, the context list and the turn's list also say how many calls it has made and what the last one is ("7 calls · Bash pytest -x").

In the frame, ] and [ step through the calls, o goes to the call's line, v visits an edited file and q closes. The header line shows:

  • what the call is and when it ran;
  • the turn it was in (turn 3/5 means after your third prompt of five);
  • its position in that turn and among all the agent's calls (call 4/12 (41/87));
  • how much context the request that made it had read (55k context: its input, cached or not, from Claude Code's transcript; for a subagent's call, the subagent's own context);
  • the directory it ran in.

The keys are listed in the frame's bottom line.

As each call is shown, the conversation behind the frame scrolls its line into the part the frame leaves uncovered and briefly lights it up. For a subagent's call, that is the line of the Agent call that launched it. q puts the conversation back where it was, or at its end if you were following it. Set vigil-follow-calls to nil to turn this off.

Commands laid out to be read

In the frame, shfmt parses each command and prints it again, putting each link of a long &&, || or | chain on its own line. Programs embedded in the command are moved into blocks of their own, highlighted in their language and marked ‹1› where they were. That covers the Python of python3 -c "…", a heredoc fed to python3 -, node -e, osascript -e (JavaScript with -l JavaScript), the Perl of perl -e and of a cluster such as perl -0777 -i -pe, the Emacs Lisp of emacs --eval and emacsclient -e, bash -c, and a heredoc written to a file. Each block is laid out by its formatter (ruff format for Python, prettier for JavaScript, perltidy for Perl, Emacs's own pp-emacs-lisp-code for Emacs Lisp without comments or character literals; see vigil-command-formatters), whether the command runs it or writes it to a file. Perl is highlighted by cperl-mode, which shows what is inside a regular expression: its groups, classes and repeats, where perl-mode makes one string of the whole.

An agent often edits a file with a Perl program that is nothing but substitutions, each a line of prose replaced by another. One too long for a line is laid out as what is replaced and what replaces it, between the delimiters, each broken where it has a \n, so that it reads as it does in the file:

‹1› perl -e
s/
`M-m n r` still files it and the phone.s\n
  notes; Home counts what waits there only while something does\.
/
`M-m n r` still refiles it and the phone\x27s\n
  notes; Home says so in those words (`r` "refile the inbox", "3 in the inbox"), and\n
  counts only while something is there.
/

The breaks are for reading and are not in the program; t shows it as given. A Perl program with anything else in it is laid out by perltidy (vigil-command-perltidy). Lines still too long for the frame, such as a long string ruff leaves whole, wrap under their own indentation.

e explains each program and each option it was given, from the manuals on this machine (bash's help for a builtin, man for everything else). It stays on for later commands until you press it again. t shows commands exactly as given, and files exactly as they were written. Nothing in a command is ever run; the formatters only read it.

The scripts a command names

A command such as tools/heavy.sh /tmp/e2e/run.sh after 2>&1 | tail -20 says little: what it does is in the two files. Inspecting it shows them under its output, each under its name, highlighted, its first 60 lines (vigil-command-script-lines); the name is a link to the whole file, and s turns the scripts off and on. A script is a file the command's words name that exists, is text, and begins with #! or has a script's extension (vigil-command-script-extensions). Arguments count as well as programs, so the script handed to a wrapper is found, and a name after a cd is read from there. Words the shell would have to expand ($DIR/run.sh) are not followed.

The files are shown as they are now. One changed since the command ran is shown as it was changed, and the heading says so. Nothing is run: the command is parsed by shfmt and the files are read.

The files a command named, as they were

An agent writes a script to /tmp, runs it with what it prints sent to another file there, and waits. The command says only the names, and by the time you ask what took four minutes the script has been changed or removed. So the hook keeps such files: those a command names outside the directory it runs in, as they are when it begins and again when it ends. Inspecting the command, from anywhere a call opens, shows them under its output, under Files:

  • a file as the command found it, highlighted, its first 40 lines (vigil-kept-lines);
  • what the command changed in it, as a diff; or all of it, where it was not there before: what it wrote;
  • while the command is still running, the last 15 lines (vigil-kept-now-lines) of a file that has changed since it began, and how long ago: what it has written so far. c in M-x vigil-running shows this for the command at point.

RET on a file's name shows all of it as it was kept. A script shown this way is not shown again as it is now. Under a file's name is the call that last wrote it before this one, where one of the same agent did (the Write that made the script, the command that sent its output there); RET on that opens it.

What is kept is what the command's words write out as a path, beginning with /, ~/ or ../: outside the directory the command runs in, whose files the snapshots keep, and outside the system's own directories; text, and no bigger than 256 KB (VIGIL_FILES_MAX); at most 16 for a command (VIGIL_FILES_MOST). A path the shell would have to work out ($out, a glob) is not followed, but where it is set is (out=/tmp/page.out). A file is kept once however many commands name it, by what is in it, and for 180 days after one last did (VIGIL_FILES_DAYS). One that is too big or not text is named with its size, and one that is not there yet is named, since it may be what the command is about to write. Only an agent that reports through vigil hook after this was added has them: older commands show none.

Commands as they run

With vigil install-shell (see above), a command that is still running opens as a buffer that grows as it prints, colours included. So does a command left running in the background, whose report says nothing about its output. Opening the buffer only reads what was saved, though k there interrupts the command after asking. For a command that has finished, r shows the same buffer, with all of the output in the order it came, and r again goes back to the call's report.

That buffer works like *compilation*. Errors and warnings in it are found the way compile finds them and are underlined where the program printed them without colour. M-g M-n and M-g M-p go to them, as after a build of your own, and RET on one opens its file at that line (in the frame, when the buffer is in the frame). The run you looked at last is the one next-error walks. Compile's single-letter keys are left out, so g, k and q keep their meaning here.

Nothing opens unasked. If you'd rather have a long command open by itself, the way compile shows a build, set vigil-show-runs-after to a number of seconds: a command still running that long after the agent started it opens in a side window at the bottom of the agent's frame (vigil-run-display-action), without taking the cursor. The next one replaces it. This happens only while the agent's buffer is on screen, and never for a command left running in the background. The agent's terminal gets shorter to make room, so the agent redraws.

A turn, call by call

C-c C-t in an agent's buffer (or T on a call in the frame, or in the context buffer) lists what the agent did in one turn, from one of your prompts to the next. A background task reporting back stays inside its turn. The calls are listed in order, each with when it began (counted from your prompt), how long it took, the context it was made in, and what it did: "created src/x.py", "edited README.md", or the agent's own description of a command followed by the command.

The list opens on the turn of the call marked nearest point, with that call selected. Moving through the list scrolls the conversation behind it to each call and lights it up. RET or a click opens the call in the same frame (l comes back to the list), o goes to its line, and ] and [ go to the next and previous turn.

M-x vigil-running

This lists every command the agents started that is still going: when it started, how long it has run, how much CPU and memory it is using, why it was run, and what it is doing now. CPU and memory are summed over the command and every process under it, as ps reports them: CPU in percent of one core, so it can pass 100, and memory as resident size, which counts pages shared between processes once for each. Both columns sort, largest first. "Why" is the description the agent gave with the command, for an agent open in this Emacs, and otherwise what the last script the command names says of itself in the comment it begins with; moving to a line also says, in the echo area, the prompt the agent was last given before it started the command. "Now" means the processes at the bottom of the process tree under it, such as the sleep 60 of a loop waiting for a file, or the Python under pixi run. Each command fits on one line, laid out as above and highlighted (python3 -c ‹1›, cat > x.py << ‹1›), and c shows it in full with its programs laid out. The list refreshes itself while it is visible. The command on the cursor's line is shown as it prints, in a window beside the list, and is the one next-error walks: move to another line to see that one instead (vigil-running-show-output turns this off). RET follows a command in the frame, the same as opening its call. f shows the files the command reads and writes, as far as they have been seen: each time the list refreshes, one lsof lists what the command and every process under it have open, and those are kept, written files apart from read ones, with the program that had each open and whether it is open now. This is what the command does, whatever it is written in, and not what its text says. A file opened and closed between two refreshes is missed, nothing is seen while the list is not on show, and the system's own files are left out (vigil-running-files-ignore). q closes the list and the window beside it; in that window, q closes just the window. The list only watches and never signals a process.

Edits in your files

A file an agent edited has a bar in the fringe beside each line one of its calls wrote. The bar is bright for the turn under way (vigil-edit-latest) and dim for earlier turns (vigil-edit). Hover over a line to see which call wrote it and when. Click the bar to open that call, usually its diff, in the frame. M-x vigil-blame does the same for the line at point, and with C-u goes to the call's line in the conversation instead. The marks are on the left, drawn over diff-hl's: of the lines diff-hl marks as uncommitted, those with vigil's bar were the agent's. Set vigil-edits-fringe to right-fringe to keep them apart. The marks are off unless vigil-mark-edits is set: M-x vigil-blame works either way.

Who wrote a line is worked out from the hooks' reports alone. Each edit's report has the file as it was before the edit and the patch the edit made, and lines are followed from one edit to the next. A command the agent ran that changed the file (a sed -i, a script) is followed the same way where snapshots are kept around commands (see What a command changed); without them it belongs to no call. Anything else that changed the file in between (you, a formatter, a git checkout) belongs to no call. The same goes for anything in the buffer that differs from what the last edit left, saved or not. So a line the agent wrote and you then rewrote is yours. The marks are redrawn when the agent edits the file again, and when you save or revert the buffer. Only diff is run, on text already in Emacs.

A turn's changes as one diff

d in a turn's list, on a call in the frame, or in the context buffer (M-x vigil-turn-diff anywhere) shows what that turn changed as one diff. Each file runs from before the turn's first edit of it to after its last, so a change the agent made and then took back doesn't appear. With C-u, it covers the whole conversation. The diff opens in an ordinary window, in diff-mode, so C-u C-c C-a undoes one hunk in the file and leaves the rest of the turn alone. Changes you made to a file between two of the agent's edits in that turn are included.

M-x vigil-context

This shows everything that has entered the agent's context, oldest first, one heading each: prompts, every call with its full result, subagents with their calls folded under them, session starts, and the reply that ended each turn. TAB unfolds a heading, S-TAB folds all of them, and RET opens one in the frame. The top of the buffer lists what Claude Code's hooks don't report, and so what is missing: the system prompt, CLAUDE.md and memory files, compaction summaries, and the agent's own words between tool calls.

Where Claude Code's transcript can be read, each call's heading ends with how many tokens of the context it came to, what it was given and what it gave back together, and the top of the buffer says how big the context is now and of what. That is the transcript's count, shared out as the context view of M-x vigil does, which is where to see it whole; from there, X opens this buffer.

Files

A file name in the conversation opens the file read-only in the same frame, highlighted in its mode and at its line. Click it once it has scrolled up, or press C-c RET at point. File names in the frame and in the context buffer work the same way. There, v opens the file in a window, l goes back to the call it was opened from, ] and [ step on from that call, and q closes. HTML files open in the browser.

Focus

C-c C-f in an agent's buffer shows only your prompts and the agent's replies. Each turn's work (reads, diffs, command output, subagents) is folded into one line that says how many tool calls it took. C-c C-f again shows everything. Only the buffer's display changes; the terminal is untouched. Isearch opens a folded turn to show a match inside it. M-x vigil-focus toggles focus for the current agent from anywhere.

Prompts

C-c C-p and C-c C-n in an agent's buffer move between your prompts in the conversation. M-x vigil-prompts picks one of the prompts given to this agent (with C-u, to any agent on this machine), newest first, and pastes it at the agent's input without sending it.

M-x vigil-graph

This draws an agent's last turn as a graph on a canvas (canvacs): the prompt, each call and the reply as cards joined in the order they happened, with a subagent's calls branching off the call that launched it. A run of reads and searches that all went well shares one card. Each turn is a row of its own, one under another, and every row begins at the left with its prompt. A number as prefix argument shows that many turns, and C-u alone shows every turn there is a record of. The canvas belongs to no file and is made anew each time, so nothing of it is saved.

Each kind of step has one colour: prompts are cyan, replies purple, commands orange, edits green, subagent launches yellow, and any call that failed is red. Reads, searches and other tools are left plain. vigil-graph-colours changes them. vigil-graph-data returns the same graph as data, without a canvas, and vigil-graph-rows a turn at a time.

Objectives and subagents, for a list of agents

vigil-survey.el answers three questions about a session by its name, with no agent buffer attached, for whatever lists the agents that run:

  • vigil-survey-objective gives what the agent is working on now, if it keeps a list of things to do (TodoWrite, or TaskCreate and TaskUpdate): the item in progress, and how many of the list are done. An agent that keeps no list has no objective.
  • vigil-survey-subagents gives its subagents: what each was asked, whether it is running, done, failed or interrupted, how many calls it has made, what the last one is about, and what it reported.
  • vigil-survey-turns gives its turns step by step, which is what the graph is drawn from.

Each report is read once and what it said is kept, so asking again reads only the reports that are new. These functions never signal an error: a report that cannot be read is passed over, and a session without reports has no objectives and no subagents.

Two things are worked out, since the reports do not say them:

  • A subagent the agent waits for is tied to the call that launched it only when it is done. Until then it is given the oldest unanswered launch of its type, which is where its "what it was asked" comes from.
  • A subagent that was waited for and never reported that it was done, while the agent has since been prompted or has replied, is shown as interrupted.

The shapes of TaskCreate and TaskUpdate (a subject, a taskId, a status) are assumed: the tests use them, and no real report of either has been seen yet.

Embark

With Embark, a call is one target wherever it shows, with one set of actions. Load it after vigil:

(require 'vigil-embark)

embark-act then offers the same actions on a call's line in the conversation, on its heading in the context, on its row of a turn, in the frame inspecting it, on a line it wrote in a file, and on its row of the running commands. The keys each of those places already has stay as they are. Nothing is loaded from Embark until Embark itself is, and vigil works the same without it.

Key On a call
RET inspect it
o go to its line in the conversation
t its turn, call by call
d what its turn changed, as one diff
v visit the file it edited
w copy its command as given, or its input as JSON
W copy its result
e explain its command
y paste its command at the agent's prompt, not submitted

w takes the place of Embark's own copy, which would copy the call's name. The call comes first among the targets on its line, so a file named there is reached by cycling. A group of calls is acted on as its first call, and a subagent as the call that launched it, once that is known.

A row of vigil-archive is a second kind of target, a session: RET opens it, c shows its context (the live agent's, if it has one), g draws its graph and e exports it.

For anything else that wants to offer the same actions: a call's target has the type vigil-call and is the string SESSION/CALL-ID; a session's has the type vigil-session and is the session's name. Only calls of sessions with a live agent buffer can be acted on, so not those of an archived session opened from the archive.

M-x vigil-codebase

When agents write the code, you do not read it as it is written. vigil-codebase is for keeping a feel for it anyway. It lists the files of a repository that changed in the last 30 days (vigil-codebase-days; d changes it), the most changed first:

Column What it says
Kind new, growing, churning (changed three times or more, with at least 0.35 lines out for each one in), new, reworked, changed or gone
Changes, In, Out, Last how many commits touched it, lines added and removed, and when it last changed; what is not committed counts as one more change
Prompts how many prompts its changes go back to
Runs, Last run how many commands exercised it, when the last one ran and whether it failed, and whether the file has changed since

The header line sums the repository up: how much of what was added went into new files, and how many lines came out for each one put in. That answers whether the work is making new things or reworking the same ones.

RET on a file shows it alone: the functions that changed most often (as git names a hunk's function, with patterns for Emacs Lisp and JavaScript that git lacks), its commits, the prompts behind its changes, and the commands that exercised it with how often each ran. RET on a prompt or a command shows it whole, and on a commit shows the commit. v visits the file.

Where each part comes from:

  • Kind, changes and lines come from git's log alone.
  • Prompts and runs come from the archive (see below), read for the sessions that worked in the repository.
  • A prompt is behind a file when an edit that followed it changed the file. An agent that changes files with a script and not its editing tools leaves no edit, so a command that redirects to the file, or is handed a program or a text naming it, counts too, and is listed as "a command that wrote it".
  • A command exercised a file when it names the file (unless the program it gives the name to only reads files, like cat, grep or git), when what it printed names the file with a line number, as a traceback does, or when coverage says it ran code of it.
  • A command that failed is known by having begun and never been answered. Its output is not in the archive, so a traceback in it is not seen.

It is fast because nothing is read twice. Git is asked for line counts only, and only for commits it has not been asked about; what it said and what was read of each archived session are kept under ~/.cache/vigil (vigil-codebase-cache-directory, vigil-history-cache-directory), which can be deleted at any time. The first look at a large repository takes under a second, and later ones a tenth of that.

vigil-codebase.el and vigil-history.el need only Emacs and git: not the rest of vigil, not cooked.

In Magit

(require 'vigil-magit)
(vigil-magit-mode 1)

With vigil-magit-mode on, Magit's buffers say more, from the same two sources:

  • A commit's buffer has a section, "Prompts behind this commit", between the message and the diff. It lists the prompts whose edits wrote lines the commit adds (matched by the text of the lines, so it survives a rebase), those whose commands seem to have written its files, and, apart, those only asked while the commit was being made.
  • Each file named in a diff, a commit or the status has its change in a few words beside it: churning · 7 changes · 3 prompts · ran 2h ago ok, changed since.
  • M-x vigil-magit-why on a hunk, a file or a commit shows the prompts behind it.
  • M-x vigil-magit-inspect-call on a hunk shows the call that wrote it: ; in a prompt's diff.
  • With Embark and vigil-embark, a hunk is the call that wrote it, where that call's session is live, so every action on a call applies to the hunk.

Nothing loads Magit, and with the mode off Magit's buffers are as they were.

Which code a command ran

Naming a file is weak evidence that a command exercised it. For Python and Node programs, vigil can know which functions ran:

vigil coverage on       # and `off`, `status`

This needs vigil install-shell, since it is vigil-shell that tells the programs. It is off until turned on, because it changes the environment of the agent's commands: coverage/python goes in front of PYTHONPATH, and --require coverage/node/vigil-coverage.cjs in front of NODE_OPTIONS. Each program then notes which functions of the repository it was started in were called, and writes them when it exits to ~/.local/share/vigil/coverage/<session>/<when>/. vigil coverage on also adds that one directory to the sandbox's allowWrite in Claude Code's settings, as install-shell does for the runs; off takes it out again.

  • Python needs 3.12 or later (sys.monitoring); on an older one nothing is done. A function is watched only until its first call, so the program is not slowed. A sitecustomize of the project's own still runs.
  • Node is asked, as the program exits, which functions V8 knows to have run. Nothing is counted while it runs, so a test runner's own coverage is left as it is; a function V8 has already discarded can be missed.
  • Only files of the repository are kept, not site-packages or node_modules.
  • A command that runs no Python and no Node leaves nothing behind.
  • Neither hook prints anything, and neither can make a program fail: whatever goes wrong, the program runs as if it were not there.
  • Not seen: a program killed before it could exit, and one started with Python's -S or -I.

vigil-codebase then lists such a command as having ran the file, with the functions.

What a command changed

An agent changes most files with commands, not with its editing tools: a sed -i, a script handed to python3. A command's report says what it printed and nothing of what it changed. With snapshots on (below), one is also asked for before and after each command, and the two are what the command changed:

  • Inspecting the command shows, under its output, the files it changed with the lines put in and taken out, and their diff (its first 200 lines, vigil-effects-diff-lines).
  • A turn's list names the files beside each command that changed any.
  • The lines the command wrote are marked as its own in your files, vigil-blame on one opens the command, and a turn's diff has what its commands changed.

A command that fails is covered too. Most commands change nothing, so a snapshot around one is kept only where the files differ from the last one kept: such a command costs the time of looking (about 0.04 s before it and after it, which the agent waits for; see What runs, and when) and leaves nothing behind. What changed while no command was running (you, a formatter, another agent) is kept before the next command and is not that command's.

What this cannot tell:

  • Two commands run at once, or a command and anything else at work in the repository while it ran: what changed in that time goes to the command that ended last.
  • A command left running in the background is reported done before it has changed anything. What it changes later is nobody's.
  • Files outside the repository the command ran in, files git ignores, and files too big for a snapshot are not seen. A file that is not text, or is over 1 MB (vigil-effects-max-file-size), is named but its lines are not followed.
  • Only agents open in this Emacs are read, a little at a time, shortly after each report.

VIGIL_SNAPSHOT_CALLS=0 keeps the snapshots at prompts and stops only. If snapshots were already on, run vigil snapshots on again to add the hooks around commands, and restart the agents. pi's extension asks for the same around its bash tool.

What changed after a prompt

Git remembers what was committed, not what the files were when a prompt was given. With snapshots on, vigil keeps that, in the repository's own .git:

vigil snapshots on      # and `off`, `status`; `forget` in a repository removes its snapshots

This puts a second hook, vigil snapshot, on a prompt being given, on the agent stopping, and before and after each Bash command, failed or not. Unlike vigil hook it is waited for, so that the files are kept as they were before the agent changes them; it takes under a tenth of a second and prints nothing.

A snapshot is a commit that nothing else points to: the files git tracks as they are in the working tree, and those it neither tracks nor ignores, up to 1 MB each (VIGIL_SNAPSHOT_MAX). This is worked out again for each snapshot, so a file that has since been ignored is no longer kept. Unchanged files cost nothing, since git already has them.

  • Your index, HEAD, branches, stash and files are not touched. A snapshot is made with an index of vigil's own, .git/vigil-index, which is never a split index, so that it shares no file with yours.
  • A snapshot is whole or not there: the commit is written, then one ref is moved to it.
  • The ref is refs/worktree/vigil/snapshots, one per working tree, never pushed or fetched. Older snapshots are held by its reflog, as stashes are, and git's own collection drops them after a month (gc.reflogExpireUnreachable).
  • git config vigil.snapshots false in a repository turns them off for it.
  • Whatever goes wrong, the hook says nothing and the prompt goes ahead.

In Emacs (vigil-snapshot.el):

  • d on a prompt, wherever one is listed (a session's buffer, vigil-review, vigil-codebase's file view, *vigil why*, the prompts behind a commit in Magit), shows what changed after it.
  • M-x vigil-snapshot-latest shows what changed after the last prompt given in this repository, and M-x vigil-snapshot-changes-after lets you choose the prompt.
  • M-x vigil-snapshot-log lists the repository's prompts with what changed after each.

The diff runs from the snapshot kept when the prompt was given to the last one kept when its agent stopped. An agent that was interrupted never says it stopped: the diff then runs to its next prompt, or to now, and says which. A message sent while the agent worked, and what a subagent hands back, are kept under the prompt's own id and do not end it. It is Magit's diff where Magit is loaded, and git's in a plain buffer otherwise.

From prompt to prompt

The diff is one prompt of several: those given to the same session, or those of the list it was opened from. The header line says which, 3/12, and what is shown. These keys work in the buffer, Magit's or the plain one, and none of them is Magit's:

Key Does
], [ The next prompt's changes, and those of the one before, in the same buffer. A prompt after which nothing changed is passed over, and said to be.
/ Narrows the files: to code, tests or documentation, by their names (vigil-purpose-test-files, vigil-purpose-doc-files); to what this prompt's edits and commands are known to have written; or to the rest.
= Orders the files: by name, as git does; code, then tests, then documentation; or the most changed first. vigil-snapshot-order is the order a diff begins in.
. Goes to the prompt, in its session's buffer (M-x vigil).
, Lists the session's prompts as a log, at this one.
; In Magit, on a hunk: the call that wrote it (vigil-magit-inspect-call).

What is narrowed and how it is ordered stay as you step: narrowed to tests, ] goes to the next prompt that changed a test. Magit's own keys are as they were, so RET visits the file and g reads again. Once the buffer shows another diff, the keys are gone.

  • From a session's buffer and from vigil-review, a prompt's changes run to its next prompt, not to its agent's stop: what you changed between the two is in it.
  • The order is given to git as a file, vigil-order in the repository's .git, written over each time.

The prompts as a log: M-x vigil-snapshot-log

M-x vigil-snapshot-log in a repository, B in a session's buffer, or , in a prompt's diff: the prompts a snapshot was kept for, the newest first, as magit-log lists commits.

 When        Session          Files     In    Out Prompt
 11-29 23:48 vigil.1              4   +309   -163 the list of agents wraps around: make it cleaner
 11-29 22:50 vigil.1              6   +405    -47 can one see the work across all sessions?
 11-29 19:19 vigil.1              ·      ·      · commit
  • RET (or d) shows what changed after the prompt at point, and ] and [ there step among the prompts listed. SPC shows it and stays in the list.
  • / lists one session's prompts, or every session's. . goes to the prompt in its session's buffer.
  • A column's heading sorts by it (S): the prompts that changed the most files or the most lines first.
  • · is a prompt after which nothing changed. … is one whose agent has not stopped: listing takes no snapshot, so what it has changed so far is not counted.
  • The newest 200 are listed (vigil-snapshot-log-most).

A snapshot is of the repository, not of an agent, so the diff is everything that changed in that time. Beside each file vigil says what the archive knows: edits of this prompt, a command of this prompt that wrote it, edits by another agent meanwhile, or nothing known. Other agents at work in the repository in that time are named in the header.

A prompt given before snapshots were on has none. For it, d shows the lines the agent's edits added, from the archive, and says that this is less than a diff.

Each snapshot says which agent it was for, claude or pi, and the diff's header names it. pi has no settings to put a hook in: its extension (vigil install-hooks --agent pi) takes the snapshots itself while they are on, and waits for the one at a prompt before the agent begins. It also gives each of pi's prompts an id, which pi has none of, so that its edits and commands go back to their prompt. Codex is not watched by vigil yet.

Only the repository the agent was started in is kept.

What a session built: M-x vigil-review

Coming back to a session, the question is what it built, against what was there when it began. M-x vigil-review in the agent's buffer answers it from the same snapshots, in two buffers. Elsewhere in a repository it takes the session last at work there, and C-u M-x vigil-review lets you choose.

The overview is the session in short:

From     10:02
To       11:39, which is now
Prompts  3
Showing  its end
Changed  2 new   +1374 −0

Prompts
  #  When   Prompt                                              Files  Lines
  1  10:02  What does the parser do with a missing file?
  2  10:04  Show me where the config is read
  3  10:30  Add a way to review what a session built, with tests      2  +1374

Files
  emacs/
    + vigil-review.el        +1088
  tests/
    + vigil-review-tests.el  +286
  • RET on a file lays the files out to be read, at that one; r does so from the top.
  • . and , step through the session a snapshot at a time, and SPC plays it (vigil-review-play-seconds). The tree is then the files as they were at that moment, with what had just changed marked ●, and the prompt it belongs to marked ▸. RET on a prompt goes to what that prompt left; e goes back to the end.
  • d shows a diff: of the file at point, of what changed after the prompt at point, or of everything.
  • s reviews from another beginning, o visits the file, g reads again.

The reading buffer is the files one after another, as the session left them: the new ones first, then those that changed, then the names of those gone. Each is in its own mode's colours. The lines the session put in are highlighted, and where it only took lines out a line says how many.

What it did not touch is folded. In a changed file, each definition with no change in it is folded to its first line, which says how many lines are under it; in a new file every definition is, so that you first see what the file is made of. A file with no definitions (notes, JSON) keeps three lines around each change and folds the rest (vigil-review-context). Definitions are the major mode's own, so this works wherever beginning-of-defun does.

  • TAB folds and unfolds what the line begins: a definition, or under its name a whole file. S-TAB unfolds every definition, or folds them all. Searching opens what it finds.
  • n and p go by file, ] and [ by change.
  • F lays the buffer over as many windows side by side as fit, each 90 columns or more (vigil-review-follow-width), scrolling as one (follow-mode); F again puts the windows back.
  • RET visits the file itself at that line, and d shows its diff.

What to know:

  • A session is a hosted session by its name, from its latest beginning: an agent started again under the same name, or after /clear, begins anew. s chooses an earlier one, and the review then runs from there through every beginning after it.
  • It ends where the agent last stopped. If it has not stopped, it ends now.
  • Snapshots are of the repository: what another agent or you changed in that time is shown too.
  • Between two snapshots is as fine as the steps get: one is kept at each prompt, at each stop, and around each command that changed files. An agent's edits with its editing tools show at the next of those.
  • A file that is not text, or is over 400 kB (vigil-review-max-file-size), is named but not laid out.

Where the code is

vigil.el is the half that needs no terminal: the records, the views of a call, the context and the prompts. vigil-pi.el puts a report of pi's into the words the rest reads, as it is read. vigil-tokens.el reads Claude Code's transcript for how big the context was at each request and what it is made of; it is the one place that does, and needs neither vigil.el nor cooked. vigil-transcript.el is the half that reads the agent's cooked buffer: the marks, prompt navigation and focus. vigil-command.el lays commands out and explains them, and says which mode a file's text is highlighted in; vigil-grammars.el keeps the tree-sitter grammars some of those modes need, and needs only Emacs; vigil-running.el lists what is running, vigil-turn.el lists a turn's calls, vigil-edits.el marks the lines the agent wrote and shows a turn's diff, vigil-effects.el reads what each command changed from the snapshots kept around it, and vigil-compile.el makes run buffers work like compilations. vigil-setup loads vigil-transcript.el, vigil-turn.el, vigil-edits.el, vigil-effects.el and vigil-compile.el; vigil-running loads its file when first called. vigil-survey.el reads a session's reports by its name and needs neither vigil.el nor cooked; vigil-graph.el draws from it, and needs canvacs only when a graph is asked for. vigil-embark.el gives calls and sessions to Embark, and needs it only once it is loaded. vigil-history.el reads the archive for one repository and vigil-codebase.el lists the repository's changes; they need neither vigil.el nor cooked. vigil-magit.el shows what they know in Magit, and needs it only once it is loaded. vigil-snapshot.el shows what changed after a prompt, from the snapshots bin/vigil keeps, and vigil-review.el what a whole session built, from the same. M-x vigil is four files: vigil-status-session.el is what it reads of a session, with every option it has, and nothing of how that is shown; vigil-status-views.el draws the views; vigil-status-detail.el is the window beside; and vigil-status.el is the buffer itself, its commands, its keys and the menu. vigil-agents.el lists every session, from the same, vigil-team.el shows one session's agents at work together, and vigil-fork.el makes another conversation from a point of one. They read through vigil-survey.el and need vigil.el only for what acts on an agent's buffer. vigil-ui.el is how its buffers and the review's are laid out: sheets, tables, blocks of text, folds and tabs. vigil-purpose.el says what a command was for and what it goes by, from the command as text. Under all of them, vigil-base.el is what every reader of vigil's files shares (JSON, when a report happened, where things are kept), and vigil-git.el is how the last five ask git; both need only Emacs. coverage/ holds the few lines Python and Node load when coverage is on.

The archive

The hook also keeps every event verbatim and indefinitely, so you can study sessions later and turn prompts into evals.

archive/YYYY/MM/<session_id>.jsonl   one line per event, in the order they came:
    {"t": <epoch seconds>, "host": <session name, or null>, "hosted": <bool>,
     "event": <the hook's JSON, verbatim>}
archive/index.jsonl                  one line per conversation, at its first event:
    {"session_id", "started", "host", "hosted", "file", "cwd",
     "git_branch", "git_commit", "model", "first_event"}

A conversation's file stays in the month it began. Lines are appended under a short lock, so concurrent hooks never interleave. The git branch and commit are read from the repository as it is on disk, and nothing is fetched.

An agent outside a hosted session (a claude in any other terminal) also runs the hook, but it is archived only with VIGIL_ARCHIVE_ALL=1, flagged "hosted": false. This is off by default because it carries a risk: Claude Code deletes its own transcripts after a while (cleanupPeriodDays), but the archive keeps them indefinitely.

In Emacs ((require 'vigil-archive)):

  • M-x vigil-archive lists the conversations (date, project, session, branch, prompts, tool calls). RET opens one read-only, in the same view as vigil-context, and e exports it.
  • M-x vigil-archive-export writes an eval dataset from every conversation, with one JSON line per prompt you gave. Prompts the agent gives itself, such as a background task reporting back, stay inside the turn they arrived in.
{"schema": "vigil.prompt.v1",
 "session_id", "host", "hosted", "cwd", "git_branch", "git_commit", "model",
 "turn": 1,                       # its place in the conversation
 "prompt": "…", "prompt_time": <epoch>,
 "reply": "…" | null,             # the Stop hook's last_assistant_message
 "reply_time": <epoch> | null,
 "seconds": <reply_time (or last event) - prompt_time>,
 "tool_calls": [{"tool", "summary", "agent_id" (subagent, or null),
                 "status": "done" | "interrupted" | "unfinished", "duration_s"}],
 "subagents": [{"agent_id", "agent_type", "result"}],
 "label": {"outcome": null, "score": null, "notes": null}}   # for you to fill in

Settings

bin/vigil reads these environment variables:

Variable Default
VIGIL_DATA_DIR ~/.local/share/vigil Where everything is kept.
VIGIL_SESSION $COOKED_HOST_SESSION The session to file records under.
VIGIL_RECORDS_MAX 2000 Records kept per session.
VIGIL_KEEP_DAYS 14 Days without a report before a session's records are deleted.
VIGIL_PROMPT_HISTORY_MAX 5000 Prompts kept.
VIGIL_ARCHIVE 1 0 turns the archive off.
VIGIL_ARCHIVE_ALL 0 1 also archives agents outside hosted sessions.
VIGIL_SETTINGS ~/.claude/settings.json The file install-hooks edits.
VIGIL_RECORDS_DIR $VIGIL_DATA_DIR/records Where each session's records are kept.
VIGIL_RECORD_MAX 4194304 Bytes of one record; over it, its biggest parts are cut.
VIGIL_PROMPT_HISTORY $VIGIL_DATA_DIR/prompts.jsonl The prompt history.
VIGIL_ARCHIVE_DIR $VIGIL_DATA_DIR/archive The archive.
VIGIL_ARCHIVE_RECORD_MAX 1048576 Bytes of one archived event, cut the same way.
VIGIL_COVERAGE unset 1 turns coverage on for one command, 0 off, whatever vigil coverage says.
VIGIL_COVERAGE_DIR $VIGIL_DATA_DIR/coverage Where coverage is written.
VIGIL_SNAPSHOTS 1 0 keeps no snapshot, whatever vigil snapshots says.
VIGIL_SNAPSHOT_MAX 1048576 Bytes of the biggest untracked file a snapshot keeps.
VIGIL_FILES_MAX 262144 Bytes of the biggest file kept of those a command names elsewhere; 0 keeps none.
VIGIL_FILES_MOST 16 How many such files are kept for one command.
VIGIL_FILES_DAYS 180 Days after a command last named it that a kept file is deleted.
VIGIL_SNAPSHOT_CALLS 1 0 keeps no snapshot around commands, only at prompts and stops.
VIGIL_SNAPSHOT_REF refs/worktree/vigil/snapshots The ref snapshots are kept under.
VIGIL_PI_EXTENSIONS ~/.pi/agent/extensions Where pi's extension is installed.
VIGIL_BIN vigil The vigil that pi's extension runs.

If you move these places, set vigil-directory, vigil-prompt-history and vigil-archive-directory in Emacs to match.

In Emacs

Every option is under one group: M-x customize-group RET vigil. Those of M-x vigil and M-x vigil-review:

Option Default
vigil-status-detail t Whether what is at point is shown beside the list; nil puts it under its line, folded.
vigil-status-recent 3 How many of the last prompts Status names.
vigil-status-timeline-width 24 Characters the longest turn's timeline is, in a list.
vigil-status-context-biggest 20 How many of the biggest things in a context its view lists.
vigil-tokens-documents PDF, Word, … Which files, by their names, are counted as from outside when read.
vigil-transcript-limit 256 MB The biggest transcript read for what the context is made of.
vigil-grammars Rust, TypeScript, Go, … The languages whose tree-sitter grammars vigil wants.
vigil-grammars-directory ~/.local/share/vigil/grammars Where they are kept, once built.
vigil-command-file-modes Markdown The modes for files Emacs has none for, by their names.
vigil-status-live-files 12 How many of the files changing now have their diff laid out.
vigil-status-refresh-delay 0.7 Seconds after a report that the session is read again.
vigil-status-changelog CHANGELOG.md The file a commit's versions are looked for in.
vigil-status-tidy t Whether a command shown whole is laid out by shfmt; nil shows it as given.
vigil-status-shellcheck shellcheck The program a command shown whole is checked with; nil checks nothing.
vigil-status-shellcheck-level warning The least serious thing it is to say.
vigil-agents-recent 24 Hours after it was last heard of that a session is listed by M-x vigil-agents.
vigil-agents-quiet 600 Seconds of nothing heard, with no call going, after which an agent at work is said to be quiet.
vigil-agents-refresh 3 Seconds between two readings of the list of agents, while it is on screen.
vigil-agents-span 60 Minutes, up to now, that the line of time in the list of agents covers.
vigil-agents-spans 15, 60, 360, 1440 The spans z goes through there.
vigil-agents-lane-width 28 Characters the line of time is wide there, at least: a fifth of the window where that is more, and two thirds of this in a window under 110 columns.
vigil-agents-detail on Whether the agent at point is shown under the list of agents; right shows it to the right.
vigil-team-detail t Whether M-x vigil-team shows the agent at point beside the list.
vigil-team-refresh 2 Seconds between two readings of a session's agents, while they are on screen.
vigil-team-lane-width 32 Characters the line of time each agent is drawn on is; two thirds of it in a narrow window.
vigil-team-calls 14 How many of an agent's last calls are listed beside the list.
vigil-team-asked-lines 8 How many lines of what an agent was asked are shown beside the list.
vigil-fork-harnesses Claude Code, pi The programs whose conversations are forked, and the ways each has.
vigil-fork-launch-function vigil-fork-launch What opens an agent on a fork; what starts agents adds its way to it.
vigil-fork-worktrees .worktrees The directory of a repository a fork's worktree is made in.
vigil-fork-copy-files none Ignored files to copy into a fork's worktree: .env, say.
vigil-fork-note What a fork is told when it is made.
vigil-fork-digest-limit 60000 The most characters of a conversation a digest has.
vigil-fork-ask-tools Read,Grep,Glob The tools a question asked aside of Claude Code may be answered with.
vigil-purpose-rules What makes a command test, check, git or setup.
vigil-purpose-test-files, -doc-files What the name of a file of tests, and of documentation, looks like.
vigil-purpose-looking-programs, -looking-git The programs, and what git is asked, that only look.
vigil-purpose-writing-programs The programs that write, move or remove files.
vigil-purpose-python python3 The Python that parses a Python program inside a command.
vigil-ui-max-width 140 The widest a buffer is laid out, however wide its window.
vigil-ui-text-width 88 The widest a prompt or a reply is filled.
vigil-review-fold-lines 3 The fewest lines a definition has to be folded.
vigil-review-context 3 Lines left showing around a change, in a file with no definitions.
vigil-review-max-file-size 400000 Bytes of the biggest file laid out to be read.
vigil-review-follow-width 90 Columns a window has, at least, when the reading buffer is laid over several.
vigil-review-play-seconds 1.0 Seconds each moment shows when a review is played.

The faces are vigil-ui-heading, -dim, -strong, -key, -good, -bad, -busy, -code, -prompt, -tab, -tab-current, and for the kinds of call in a timeline vigil-ui-kind-command, -edit, -test, -read, -subagent and -other. Each inherits a standard face and sets nothing of its own.

Three options and two functions were renamed in 0.8.0, and go by their old names too: vigil-status-strip-width is vigil-status-timeline-width, and vigil-status-looking-programs, -looking-git, -writing-programs, -looks-p and -writes-p are vigil-purpose-'s.

Tests

bats tests
emacs -Q --batch -L ../cooked/lisp -L emacs -l tests/vigil-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L ../cooked/lisp -L emacs -l tests/vigil-archive-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L ../cooked/lisp -L emacs -l tests/vigil-command-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L ../cooked/lisp -L emacs -l tests/vigil-running-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L ../cooked/lisp -L emacs -l tests/vigil-pi-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L ../cooked/lisp -L emacs -l tests/vigil-embark-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L ../cooked/lisp -L emacs -l tests/vigil-effects-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L emacs -l tests/vigil-codebase-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L emacs -l tests/vigil-magit-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L emacs -l tests/vigil-snapshot-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L emacs -l tests/vigil-review-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L emacs -l tests/vigil-status-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L emacs -l tests/vigil-purpose-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L emacs -l tests/vigil-fork-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L emacs -l tests/vigil-tokens-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L emacs -l tests/vigil-grammars-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L emacs -l tests/vigil-without-cooked-tests.el \
      -f ert-run-tests-batch-and-exit
emacs -Q --batch -L emacs -l tests/vigil-kept-tests.el \
      -f ert-run-tests-batch-and-exit

The last is run without cooked on the load path, as are those above it that name only -L emacs: it loads every file, and shows a session whose agent is in no buffer.

Every one is a fresh Emacs, told nothing. The grammars' tests highlight by the grammars themselves: the first run builds any that are missing, as vigil grammars does, and every run after finds them there. Where they cannot be built those tests are skipped.

Each test writes made-up events to its own temporary directory.

About

agentic traceability within emacs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0