miadi-orchestration-kit

miadi-session-observability

Session capture for Miadi hosts, as a Claude Code plugin. Install it once on a host and every Claude Code session there is captured. Nobody edits settings.json by hand. jgwill/miadi-orchestration-kit#56.

A person’s correction, while the agent works

Since 0.1.34 every session has a steering inbox (jgwill/Miadi#930). A person’s correction, sent through the Miadi connector, waits in <factory>/steering/<session_id>/pending/. At the next tool end the hook gives it to the model as additionalContext, in the same turn. If the turn ends with no further tool, Stop continues it with the correction. If it lands while the turn is ending, a background watcher (asyncRewake, 30 seconds after each turn) wakes the model with it. It goes to the main thread only, once, and is checked again for its session, hash, expiry and revocation when it is consumed. With nothing pending the hook costs one bash glob and starts no node. Hooks load at session start, so a session started before 0.1.34 answers unsupported. MIADI_STEERING_DIR moves the folder, and a host without the factory folder has no inbox and notices nothing.

Install

claude plugin marketplace add jgwill/miadi-orchestration-kit      # or the path of a checkout
claude plugin install miadi-session-observability@miadi-orchestration-kit

Then remove the hooks block from ~/.claude/settings.json on that host, in the same step. If both are wired, every event fires twice and every capture line is written twice.

The plugin’s hooks load when a session starts. Removing the hooks block takes effect at once, so a running session captures nothing from that edit until it is restarted. Restart it right after the edit (seen on gaia, 2026-09-30).

To try the plugin without installing it: claude --plugin-dir <path to this folder>.

Where captures go

<root> is CLAUDE_SESSIONDATA_ROOT, else MIADI_SESSION_DIR, MIADI_SESSIONDATA_ROOT, SESSION_DATA_ROOT, else /src/_sessiondata when it exists, else _sessiondata beside this folder (hooks/claude_hooks/lib.sh).

Files written

Every file a tool call creates, changes or moves is copied to <root>/<session_id>/written/<its absolute path>, sanitized, and listed in _claude_files_written.jsonl with the call that touched it. Since 0.1.11, jgwill/miadi-orchestration-kit#82.

What Claude memorized

Claude Code keeps a project’s memory in <config>/projects/<key>/memory/ (~/.claude unless CLAUDE_CONFIG_DIR says otherwise), one file per memory and MEMORY.md as its index. Only the user that ran the session can read that folder, and other agents never look there. Each memory file a call writes is copied like any other file, and also listed in _claude_memory.jsonl with project (the key), file, index (true for MEMORY.md), name, description, type and origin_session_id read from the copy’s frontmatter, plus kind, tool_use_id, prompt_id, sha256 and copy. A memory file that is removed is not listed. Since 0.1.25, jgwill/miadi-orchestration-kit#111.

Subagents, forks and what a person said to them

A person can open a running subagent in the agent view and talk to it, or fork a /btw side question with f. Those words reach the subagent or fork, never the main session. At every SubagentStop the hook archives the agent’s transcript to <root>/<session_id>/agents/<agent_id>.transcript.jsonl, beside .meta.json, .launch.json (when the main session launched it) and .output.md (its last reply only). scripts/agent-talk.mjs reads them back for any agent that can run node:

node scripts/agent-talk.mjs list   <session>            # each subagent and fork, person messages, replies
node scripts/agent-talk.mjs show   <session> <agent>    # directive, each person message, each reply
node scripts/agent-talk.mjs person <session>            # only what the person said, across all of them

<session> is an id, a prefix, a tmux name or a session name. A fork with no launch manifest is listed as btw-fork: the person made it. An image pasted into a subagent arrives as the text [Image #N] only, and show says so. Since 0.1.15, after three messages from Guillaume to the witness-editor sat unread on 2026-10-15.

/btw side questions and their forks

No hook fires for /btw. Claude Code keeps the question in ~/.claude/history.jsonl only (its pasted text in paste-cache/), and the answer in its panel only. Pressing f forks it, and the fork’s transcript keeps the question, the answer and everything after. Each archive pass (Stop, SubagentStop, SessionEnd, the SessionStart sweep) writes the events of the session’s /btw questions to <root>/<session_id>/_claude_btw.jsonl, each once, in time order. Since 0.1.17, jgwill/miadi-orchestration-kit#95.

kind the line holds
asked every /btw question, forked or not: btw_id (btw-<history ms>), at, question, pasted, cwd
forked agent_id, name, question, directive, and parent_last_uuid, the main transcript message it branched after
answered the panel’s answer, as the fork keeps it
person each message the person sent the fork, with its prompt_id
reply each reply, with tools_before, the tools called since the previous reply
notified each time the main session was told the fork completed or was resumed
delivered the result reaching the main session: via: "prompt" with its prompt_id, or via: "attachment" inside a running turn

Every line of a fork carries the btw_id of its question, so asked without forked is a side question that was closed. Its answer is not kept anywhere: only a fork keeps the answer. A fork the Agent tool launched has no question and writes no line. SubagentStop names a /btw fork by its question in agents/<id>.output.md and trace.log, from Claude Code’s meta.json. tests/btw.sh holds the rules.

Uncommitted, not written

Not wired since 0.1.24. A Stop hook that stops a turn makes the agent write a second reply, and that reply is what tan then annotates. A hook cannot change the reply itself, so the check is off. The script and its test stay here; the rest of this section says what it did.

At each Stop, hooks/claude_hooks/uncommitted_not_written.sh reads git status in the repository the session runs in and in every repository it wrote a file into, and lists the uncommitted files that neither the session nor its subagents wrote (_claude_files_written.jsonl) in <root>/<session_id>/_claude_uncommitted_not_written.json. The session’s own capture folder is left out, an untracked folder is the session’s when it wrote inside it, and a repository reached through a link is named by its real path. When the reply that ends the turn counts one of those files as work done (a sentence that names it, by path or by a file name with an extension only one of them carries, says wrote, updated, committed and does not say not, another, someone), the hook stops the turn once, names them, and asks for those sentences corrected with nothing else. A reply that only mentions them is never stopped, so the agent never answers the check. MIADI_UNCOMMITTED_IGNORE (shell patterns separated by :, matched against the absolute path, set in the shell or in settings.json env) leaves files out of the list and the check, for example */.claude/skills/*:*/.mino/session-inventory/*. It never stops a turn twice in a row. R6 of the requirements of 2026-10-19, lane K6e. tests/uncommitted-not-written.sh holds the rules. On gaia’s largest trees a Stop takes 1 to 3 s, most of it git status in /home/mia/workspace.

Publications

What a session put where other people can see it is one line in <root>/<session_id>/_claude_publications.jsonl, with the tool call and the prompt (prompt_id) that produced it. Since 0.1.12, jgwill/miadi-orchestration-kit#82.

kind from the line holds
artifact, artifact-asset an Artifact publish url, path (the source file), title, artifact_id, updated
issue, issue-comment, pr, pr-comment, release, gist gh issue, gh pr, gh release, gh gist that write, and gh api that writes url, repo, number, action (issue create, pr comment, api)
issue inquiry-weave open, issue and inquire, which call gh themselves (0.1.18): each owner/repo#N [created] line url, repo, number, action (inquiry-weave inquiry, inquiry-weave actions, inquiry-weave issue)
pr Claude Code’s gitOperation.pr url, number, action
commit gitOperation.commit, or git’s output ([branch sha] subject, a git log --oneline -1 after a quiet commit) the full sha, repo, dir, subject, url, verified
push gitOperation.push, or git’s To <remote> and a..b src -> dst lines repo, branch, from, to, and a compare url
npm npm, pnpm or yarn publish package, version, url

Each commit is checked in the tree the command worked in (git -C, a cd, then the cwd). A commit read from output must be in such a tree and committed during the call, and one read from git log or git show after a quiet commit must be that tree’s HEAD. A gh URL counts only when it ends its line (alone, or after a label in a batch) and the command ran the gh write that makes that kind of URL. A command that only reads (gh issue view, git log --grep, gh api -X GET) records nothing, and neither does a push or publish whose every invocation in the command is a --dry-run. A chain that publishes, then fails, is read from PostToolUseFailure. PostToolUse matches the raw input first, so a call that cannot have published costs nothing, and a call that may have costs one jq call before the parse runs detached.

Artifact comments

The threads people open on a published Artifact page are lines of <root>/<session_id>/_claude_artifact_comments.jsonl, keyed by artifact_url and thread_id, with the tool call or prompt that brought them in. Since 0.1.16, jgwill/miadi-orchestration-kit#56.

kind from the line holds
sent a prompt headed [Artifact comment sent to Claude] sent_at, the comment text without its > quote marks, the anchor context
auto-reply an artifact-auto-react task notification the posted comment_id, artifact_title
thread ArtifactComments read, or resolve anchor_label, anchor_path, span_quote, resolved, claude_activated, comments (count)
comment ArtifactComments read, or reply comment_id, author (the viewer’s name, or Claude), role, sent_to_claude, created_at, text

A read hands the hook every thread with its full text, even when the model is shown a capped list. Each comment is written once. A thread line is written when the thread is first seen and again when it is resolved or activated for Claude. A comment that nobody reads in the session and nobody sends to Claude never reaches it: read the artifact’s comments (ArtifactComments, action read) to bring every thread in. One thread in order:

jq -c 'select(.thread_id == "<thread id>")' _claude_artifact_comments.jsonl

Teams

The binding line’s team is {"id": "T1", "source": "session"}. It is resolved in this order:

  1. a declared team: MIADI_TEAM in the agent’s environment, or the tmux session option (tmux set-option -t <session> @miadi-team T1)
  2. the session names in teams/teams.json, matched against the tmux session name and the agent session’s name
  3. its folders, where the agent’s folder or one below it matches and the longest prefix wins
  4. its name patterns
  5. otherwise unassigned

The list is MIADI_TEAMS_FILE, else $MIADI_ORCHESTRATION_KIT_ROOT/teams/teams.json. An installed plugin is a copy of this folder, so it cannot reach the kit by a relative path. teams/README.md is the text people read, and the two are kept in step.

Which copy is canonical

Host integrations it uses when present

Check

bash tests/team-resolution.sh
bash tests/episode-resolution.sh
bash tests/transcript-archive.sh
bash tests/files-written.sh
bash tests/publications.sh
bash tests/artifact-comments.sh
bash tests/binding-agent.sh
bash tests/binding-mission.sh
bash tests/workspace-clone-guard.sh
bash tests/uncommitted-not-written.sh
bash tests/session-end-inventory.sh
CLAUDE_SESSIONDATA_ROOT=$(mktemp -d) claude --restricted --plugin-dir . --model haiku

--restricted ignores the user’s settings files, so only this plugin’s hooks run. One prompt that starts a subagent, a /rename and an exit write the same files as today’s capture, with each event written once.