The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Files Changed</title>
<script type="application/beacon-lens+json">
{
"id": "files-changed",
"title": "Files Changed",
"description": "Every file the agent created, edited or deleted, as a tree, with each edit's diff in order.",
"icon": "file",
"version": 1,
"api": "beacon.lens.v1",
"author": "Beacon"
}
</script>
<style>
body {
margin: 0;
color: var(--beacon-text, #111827);
font: 400 13px/1.5 var(--beacon-font-sans, ui-sans-serif, system-ui, sans-serif);
}
.muted { color: var(--beacon-muted, #6b7280); }
.mono, pre { font: 13px/1.45 var(--beacon-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); }
.add { color: var(--beacon-ok, #047857); }
.del { color: var(--beacon-danger, #b91c1c); }
#summary { margin: 0 0 10px; }
.layout { display: grid; grid-template-columns: minmax(12rem, 18rem) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 640px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.tree { min-width: 0; border-right: 1px solid var(--beacon-line, rgba(0,0,0,0.1)); padding-right: 8px; }
.row { box-sizing: border-box; display: flex; align-items: baseline; gap: 6px; width: 100%; padding: 2px 6px; border: 0; border-radius: 4px; background: none; color: inherit; font: inherit; text-align: left; }
.row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .counts { white-space: nowrap; font-variant-numeric: tabular-nums; }
button.row { cursor: pointer; }
button.row:hover { background: var(--beacon-panel-soft, #f9fafb); }
button.row[aria-current="true"] { background: var(--beacon-accent-soft, #e2f0f8); }
button.row:focus-visible { outline: 2px solid var(--beacon-accent, #036aa2); outline-offset: -2px; }
.dir { color: var(--beacon-muted, #6b7280); }
.tag { font-size: 12px; color: var(--beacon-muted, #6b7280); }
h2 { margin: 0 0 8px; font-size: 13px; font-weight: 400; overflow-wrap: anywhere; }
.edit { margin: 0 0 14px; }
.edit-head { margin: 0 0 4px; }
pre { margin: 0; padding: 6px 8px; overflow-x: auto; border: 1px solid var(--beacon-line, rgba(0,0,0,0.1)); border-radius: 4px; white-space: pre; }
pre span { display: block; }
.hunk { color: var(--beacon-muted, #6b7280); }
</style>
</head>
<body>
<p id="status" class="muted">Loading trace…</p>
<main id="root" hidden>
<p id="summary" class="muted"></p>
<div class="layout">
<nav id="tree" class="tree" aria-label="Changed files"></nav>
<section id="detail" aria-live="polite"></section>
</div>
</main>
<script>
(function () {
"use strict";
// The file.operation values and actions that change a file, as `beacon git` counts them.
var WRITE_OPS = { create: 1, modify: 1, delete: 1, write: 1, edit: 1, rename: 1, move: 1 };
var WRITE_ACTIONS = { "file.created": 1, "file.modified": 1, "file.deleted": 1, "file.edited": 1 };
var MAX_DIFF_LINES = 2000;
var fmt = new Intl.NumberFormat();
// Every node is built with textContent: paths and diffs are untrusted trace content.
function el(tag, text, className) {
var node = document.createElement(tag);
if (text !== undefined && text !== null) node.textContent = String(text);
if (className) node.className = className;
return node;
}
function isWrite(event) {
// An approval names the file a write is about to touch; the write itself is its own event.
if (event.category === "approval" || String(event.action || "").indexOf("approval.") === 0) return false;
var op = String((event.file && event.file.operation) || "").toLowerCase();
return !!(WRITE_OPS[op] || WRITE_ACTIONS[event.action]);
}
function diffText(file) {
var d = file && file.diff;
return d && d.included && typeof d.text === "string" ? d.text : null;
}
// classifyDiff labels each line of a unified diff. The ---/+++ file headers only come before a
// file's first @@ hunk; inside a hunk, "--- x" is a removed "-- x" (a SQL or Lua comment) and
// "+++ x" an added "++ x", so position, not prefix, decides which a line is.
function classifyDiff(text) {
var inHunk = false;
return text.replace(/\n$/, "").split("\n").map(function (line) {
if (line.indexOf("diff ") === 0) { inHunk = false; return { line: line, cls: "hunk" }; }
if (line.indexOf("@@") === 0) { inHunk = true; return { line: line, cls: "hunk" }; }
if (!inHunk && (line.indexOf("+++ ") === 0 || line.indexOf("--- ") === 0 || line === "+++" || line === "---")) {
return { line: line, cls: "hunk" };
}
if (line.charAt(0) === "+") return { line: line, cls: "add" };
if (line.charAt(0) === "-") return { line: line, cls: "del" };
return { line: line, cls: "" };
});
}
function countLines(text) {
var added = 0, removed = 0;
if (!text) return { added: 0, removed: 0 };
classifyDiff(text).forEach(function (l) {
if (l.cls === "add") added += 1;
else if (l.cls === "del") removed += 1;
});
return { added: added, removed: removed };
}
function relative(path, root) {
if (root && path.indexOf(root + "/") === 0) return path.slice(root.length + 1);
return path;
}
function counts(added, removed, missing) {
var span = el("span", null, "counts mono");
if (added) span.appendChild(el("span", "+" + fmt.format(added) + " ", "add"));
if (removed) span.appendChild(el("span", "−" + fmt.format(removed), "del"));
if (!added && !removed && missing) span.appendChild(el("span", "no diff", "muted"));
return span;
}
function collect(data) {
var trace = data.trace || {};
var events = Array.isArray(trace.events) ? trace.events : [];
var root = (trace.summary && trace.summary.session && trace.summary.session.working_directory) || "";
root = root.replace(/\/+$/, "");
var files = {};
var order = [];
var reads = {};
events.forEach(function (event) {
if (!event || !event.file || !event.file.path) return;
var path = relative(String(event.file.path), root);
if (!isWrite(event)) {
reads[path] = 1;
return;
}
if (!files[path]) {
files[path] = { path: path, edits: [], added: 0, removed: 0, missing: false, ops: {} };
order.push(path);
}
var f = files[path];
var text = diffText(event.file);
var c = countLines(text);
f.added += c.added;
f.removed += c.removed;
if (text === null) f.missing = true;
f.ops[String(event.file.operation || event.action)] = 1;
f.edits.push({ event: event, text: text });
});
order.sort();
// Agents read a file before editing it; only files that were read and never changed count as reads.
var readOnly = Object.keys(reads).filter(function (path) { return !files[path]; });
return { files: files, order: order, reads: readOnly.length, total: events.length, truncated: !!data.truncated };
}
function renderTree(model, select) {
var tree = document.getElementById("tree");
tree.textContent = "";
var shownDirs = {};
var buttons = {};
model.order.forEach(function (path) {
var parts = path.split("/");
// One row per directory level not shown yet, indented by depth.
for (var i = 0; i < parts.length - 1; i++) {
var dir = parts.slice(0, i + 1).join("/");
if (shownDirs[dir]) continue;
shownDirs[dir] = 1;
var dirRow = el("div", null, "row dir");
dirRow.style.paddingLeft = (6 + i * 12) + "px";
dirRow.title = dir;
dirRow.appendChild(el("span", parts[i] + "/", "name mono"));
tree.appendChild(dirRow);
}
var f = model.files[path];
var row = el("button", null, "row");
row.type = "button";
row.style.paddingLeft = (6 + (parts.length - 1) * 12) + "px";
row.title = path;
row.appendChild(el("span", parts[parts.length - 1], "name mono"));
if (f.ops.create || f.ops["file.created"]) row.appendChild(el("span", "new", "tag"));
if (f.ops["delete"] || f.ops["file.deleted"]) row.appendChild(el("span", "deleted", "tag"));
row.appendChild(counts(f.added, f.removed, f.missing));
row.addEventListener("click", function () { select(path); });
buttons[path] = row;
tree.appendChild(row);
});
return buttons;
}
function renderDiff(text) {
var pre = el("pre");
var lines = classifyDiff(text);
lines.slice(0, MAX_DIFF_LINES).forEach(function (l) {
pre.appendChild(el("span", l.line === "" ? " " : l.line, l.cls));
});
if (lines.length > MAX_DIFF_LINES) {
pre.appendChild(el("span", "… " + fmt.format(lines.length - MAX_DIFF_LINES) + " more lines", "hunk"));
}
return pre;
}
function renderDetail(f) {
var detail = document.getElementById("detail");
detail.textContent = "";
// Break the path after each slash rather than mid-name.
var heading = el("h2", null, "mono");
f.path.split("/").forEach(function (part, i, parts) {
heading.appendChild(document.createTextNode(part + (i < parts.length - 1 ? "/" : "")));
if (i < parts.length - 1) heading.appendChild(document.createElement("wbr"));
});
detail.appendChild(heading);
f.edits.forEach(function (edit) {
var e = edit.event;
var block = el("div", null, "edit");
var head = el("p", null, "edit-head muted");
var when = e.timestamp ? new Date(e.timestamp) : null;
head.textContent = "#" + e.number + " · " + (e.file.operation || e.action) +
(when && !isNaN(when) ? " · " + when.toLocaleTimeString() : "");
block.appendChild(head);
if (edit.text !== null) {
block.appendChild(renderDiff(edit.text));
if (e.file.diff.truncated) block.appendChild(el("p", "Diff truncated by Beacon's size limits.", "muted"));
} else {
var why = (e.file.diff && e.file.diff.redacted) ? "redacted" : "not retained";
var facts = [why];
if (e.file.diff_bytes) facts.push(fmt.format(e.file.diff_bytes) + " bytes");
if (e.file.diff_hash) facts.push(e.file.diff_hash);
block.appendChild(el("p", "Diff " + facts.join(" · "), "muted mono"));
}
detail.appendChild(block);
});
}
function render(data) {
var model = collect(data || {});
var summary = document.getElementById("summary");
if (model.order.length === 0) {
summary.textContent = "No files were changed in this trace" + (model.reads ? " (" + fmt.format(model.reads) + " read)." : ".");
document.querySelector(".layout").hidden = true;
} else {
var added = 0, removed = 0, edits = 0;
model.order.forEach(function (p) { added += model.files[p].added; removed += model.files[p].removed; edits += model.files[p].edits.length; });
summary.textContent = fmt.format(model.order.length) + (model.order.length === 1 ? " file" : " files") + " changed in " +
fmt.format(edits) + (edits === 1 ? " edit" : " edits") + " · +" + fmt.format(added) + " −" + fmt.format(removed) +
(model.reads ? " · " + fmt.format(model.reads) + " read" : "") +
(model.truncated ? " · trace truncated, later edits missing" : "");
var buttons;
var select = function (path) {
Object.keys(buttons).forEach(function (p) { buttons[p].setAttribute("aria-current", String(p === path)); });
renderDetail(model.files[path]);
};
buttons = renderTree(model, select);
select(model.order[0]);
}
document.getElementById("status").hidden = true;
document.getElementById("root").hidden = false;
}
window.beacon.getTrace().then(render, function (err) {
document.getElementById("status").textContent = "Could not load this trace: " + ((err && err.message) || err);
});
})();
</script>
</body>
</html>