pi-better-harness 0.61.1 → 0.61.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/lib/console-icons.svg +121 -0
  3. package/lib/console-logo.png +0 -0
  4. package/lib/console-shell.mjs +41 -0
  5. package/lib/console-ui.mjs +152 -53
  6. package/lib/console.html +9 -3
  7. package/lib/prompt-ui.mjs +60 -31
  8. package/lib/prompt-web.mjs +10 -3
  9. package/lib/prompt.css +125 -10
  10. package/lib/prompt.html +19 -16
  11. package/node_modules/pi-better-background-tasks/package.json +1 -1
  12. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-arm64.gz +0 -0
  13. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-arm64.json +1 -1
  14. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-x64.gz +0 -0
  15. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-x64.json +1 -1
  16. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-arm64.gz +0 -0
  17. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-arm64.json +1 -1
  18. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-x64.gz +0 -0
  19. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-x64.json +1 -1
  20. package/node_modules/pi-better-background-tasks/runtime-client/src/runtime/client.mjs +1 -1
  21. package/node_modules/pi-better-subagents/README.md +6 -5
  22. package/node_modules/pi-better-subagents/docs/usage.md +7 -8
  23. package/node_modules/pi-better-subagents/index.ts +4 -4
  24. package/node_modules/pi-better-subagents/package.json +1 -1
  25. package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-arm64.gz +0 -0
  26. package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-arm64.json +1 -1
  27. package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-x64.gz +0 -0
  28. package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-x64.json +1 -1
  29. package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-arm64.gz +0 -0
  30. package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-arm64.json +1 -1
  31. package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-x64.gz +0 -0
  32. package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-x64.json +1 -1
  33. package/node_modules/pi-better-subagents/runtime-client/src/runtime/client.mjs +1 -1
  34. package/node_modules/pi-better-subagents/settings-page.ts +54 -44
  35. package/node_modules/pi-better-subagents/skill-picker.ts +1 -1
  36. package/package.json +5 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.61.3] - 2026-11-29
4
+
5
+ ### Fixed
6
+
7
+ - Open **Skill exposure** in Subagent settings to choose all skills, no skills, or only selected skills. Choosing selected skills opens the checkbox list.
8
+
9
+ ## [0.61.2] - 2026-11-29
10
+
11
+ ### Changed
12
+
13
+ - Align the opt-in local console with its approved screen designs. The Server overview shows runtime and upgrade status alongside hosted sessions. Prompts provides a module list, a focused editor and a composed preview.
14
+
3
15
  ## [0.61.1] - 2026-11-29
4
16
 
5
17
  ### Fixed
@@ -0,0 +1,121 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg"><desc>ISC License
2
+
3
+ Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2022.
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+ </desc>
17
+ <symbol id="server" viewBox="0 0 24 24">
18
+ <rect width="20" height="8" x="2" y="2" rx="2" ry="2" />
19
+ <rect width="20" height="8" x="2" y="14" rx="2" ry="2" />
20
+ <line x1="6" x2="6.01" y1="6" y2="6" />
21
+ <line x1="6" x2="6.01" y1="18" y2="18" />
22
+ </symbol>
23
+ <symbol id="panels-top-left" viewBox="0 0 24 24">
24
+ <rect width="18" height="18" x="3" y="3" rx="2" />
25
+ <path d="M3 9h18" />
26
+ <path d="M9 21V9" />
27
+ </symbol>
28
+ <symbol id="sliders-horizontal" viewBox="0 0 24 24">
29
+ <line x1="21" x2="14" y1="4" y2="4" />
30
+ <line x1="10" x2="3" y1="4" y2="4" />
31
+ <line x1="21" x2="12" y1="12" y2="12" />
32
+ <line x1="8" x2="3" y1="12" y2="12" />
33
+ <line x1="21" x2="16" y1="20" y2="20" />
34
+ <line x1="12" x2="3" y1="20" y2="20" />
35
+ <line x1="14" x2="14" y1="2" y2="6" />
36
+ <line x1="8" x2="8" y1="10" y2="14" />
37
+ <line x1="16" x2="16" y1="18" y2="22" />
38
+ </symbol>
39
+ <symbol id="layout-grid" viewBox="0 0 24 24">
40
+ <rect width="7" height="7" x="3" y="3" rx="1" />
41
+ <rect width="7" height="7" x="14" y="3" rx="1" />
42
+ <rect width="7" height="7" x="14" y="14" rx="1" />
43
+ <rect width="7" height="7" x="3" y="14" rx="1" />
44
+ </symbol>
45
+ <symbol id="network" viewBox="0 0 24 24">
46
+ <rect x="16" y="16" width="6" height="6" rx="1" />
47
+ <rect x="2" y="16" width="6" height="6" rx="1" />
48
+ <rect x="9" y="2" width="6" height="6" rx="1" />
49
+ <path d="M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3" />
50
+ <path d="M12 12V8" />
51
+ </symbol>
52
+ <symbol id="list" viewBox="0 0 24 24">
53
+ <path d="M3 12h.01" />
54
+ <path d="M3 18h.01" />
55
+ <path d="M3 6h.01" />
56
+ <path d="M8 12h13" />
57
+ <path d="M8 18h13" />
58
+ <path d="M8 6h13" />
59
+ </symbol>
60
+ <symbol id="square-terminal" viewBox="0 0 24 24">
61
+ <path d="m7 11 2-2-2-2" />
62
+ <path d="M11 13h4" />
63
+ <rect width="18" height="18" x="3" y="3" rx="2" ry="2" />
64
+ </symbol>
65
+ <symbol id="monitor" viewBox="0 0 24 24">
66
+ <rect width="20" height="14" x="2" y="3" rx="2" />
67
+ <line x1="8" x2="16" y1="21" y2="21" />
68
+ <line x1="12" x2="12" y1="17" y2="21" />
69
+ </symbol>
70
+ <symbol id="refresh-cw" viewBox="0 0 24 24">
71
+ <path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" />
72
+ <path d="M21 3v5h-5" />
73
+ <path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" />
74
+ <path d="M8 16H3v5" />
75
+ </symbol>
76
+ <symbol id="upload" viewBox="0 0 24 24">
77
+ <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
78
+ <polyline points="17 8 12 3 7 8" />
79
+ <line x1="12" x2="12" y1="3" y2="15" />
80
+ </symbol>
81
+ <symbol id="folder" viewBox="0 0 24 24">
82
+ <path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" />
83
+ </symbol>
84
+ <symbol id="clock" viewBox="0 0 24 24">
85
+ <circle cx="12" cy="12" r="10" />
86
+ <polyline points="12 6 12 12 16 14" />
87
+ </symbol>
88
+ <symbol id="arrow-right" viewBox="0 0 24 24">
89
+ <path d="M5 12h14" />
90
+ <path d="m12 5 7 7-7 7" />
91
+ </symbol>
92
+ <symbol id="chevron-right" viewBox="0 0 24 24">
93
+ <path d="m9 18 6-6-6-6" />
94
+ </symbol>
95
+ <symbol id="hard-drive" viewBox="0 0 24 24">
96
+ <line x1="22" x2="2" y1="12" y2="12" />
97
+ <path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" />
98
+ <line x1="6" x2="6.01" y1="16" y2="16" />
99
+ <line x1="10" x2="10.01" y1="16" y2="16" />
100
+ </symbol>
101
+ <symbol id="circle-help" viewBox="0 0 24 24">
102
+ <circle cx="12" cy="12" r="10" />
103
+ <path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" />
104
+ <path d="M12 17h.01" />
105
+ </symbol>
106
+ <symbol id="layers" viewBox="0 0 24 24">
107
+ <path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" />
108
+ <path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" />
109
+ <path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />
110
+ </symbol>
111
+ <symbol id="files" viewBox="0 0 24 24">
112
+ <path d="M20 7h-3a2 2 0 0 1-2-2V2" />
113
+ <path d="M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z" />
114
+ <path d="M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8" />
115
+ </symbol>
116
+ <symbol id="menu" viewBox="0 0 24 24">
117
+ <line x1="4" x2="20" y1="12" y2="12" />
118
+ <line x1="4" x2="20" y1="6" y2="6" />
119
+ <line x1="4" x2="20" y1="18" y2="18" />
120
+ </symbol>
121
+ </svg>
Binary file
@@ -0,0 +1,41 @@
1
+ const sections = [
2
+ ["server", "Server", "server"], ["sessions", "Sessions", "panels-top-left"],
3
+ ["prompts/edit", "Prompts", "sliders-horizontal"], ["catalog", "Agent Catalog", "layout-grid"],
4
+ ["mcp", "MCP", "network"], ["skills", "Skills", "list"], ["tools", "Tools", "square-terminal"]
5
+ ];
6
+
7
+ export function icon(name) {
8
+ const ns = "http://www.w3.org/2000/svg";
9
+ const svg = document.createElementNS(ns, "svg");
10
+ svg.setAttribute("class", "icon");
11
+ svg.setAttribute("aria-hidden", "true");
12
+ const use = document.createElementNS(ns, "use");
13
+ use.setAttribute("href", "/console-icons.svg#" + name);
14
+ svg.append(use);
15
+ return svg;
16
+ }
17
+
18
+ export function mountShell() {
19
+ const root = document.querySelector(".rail nav");
20
+ const section = location.pathname.split("/")[1] || "prompts";
21
+ for (const [path, label, glyph] of sections) {
22
+ const a = document.createElement("a");
23
+ a.href = "/" + path;
24
+ a.append(icon(glyph), label);
25
+ if (section === path.split("/")[0]) {
26
+ a.setAttribute("aria-current", "page");
27
+ document.querySelector(".crumb strong").textContent = label;
28
+ document.title = label + " · Pi Better Harness";
29
+ }
30
+ root.append(a);
31
+ }
32
+ document.querySelector(".crumb").prepend(icon("monitor"));
33
+ }
34
+
35
+ export function agentDirectory(path) {
36
+ if (!path) return;
37
+ const target = document.querySelector(".rail-foot code");
38
+ target.textContent = path;
39
+ target.title = path;
40
+ target.parentElement.hidden = false;
41
+ }
@@ -1,11 +1,21 @@
1
+ import { agentDirectory, icon, mountShell } from "/console-shell.mjs";
1
2
  const el = id => document.getElementById(id);
2
3
  const token = location.hash.slice(1) || sessionStorage.getItem("prompt-token");
3
4
  if (token) sessionStorage.setItem("prompt-token",token);
4
5
  history.replaceState(null,"",location.pathname + location.search);
5
6
  const [,page,sessionId] = location.pathname.split("/");
6
- const current = document.querySelector('header a[href="/' + page + '"]');
7
- current?.setAttribute("aria-current","page");
8
- el("title").textContent = sessionId ? "Session TUI" : current?.textContent;
7
+ mountShell();
8
+ const pages = {
9
+ server: ["Server overview", "Local daemon and hosted sessions"],
10
+ sessions: ["Sessions", "Hosted sessions by workspace"],
11
+ catalog: ["Agent Catalog", "Roles and named agents"],
12
+ mcp: ["MCP", "Configured servers and connection status"],
13
+ skills: ["Skills", "Discovered skills in the selected session"],
14
+ tools: ["Tools", "Registered tools and the active session tool set"]
15
+ };
16
+ const [title, subtitle] = sessionId ? ["Session TUI", "Read-only terminal"] : pages[page];
17
+ el("title").textContent = title;
18
+ el("subtitle").textContent = subtitle;
9
19
  function node(tag,text) {
10
20
  const n = document.createElement(tag);
11
21
  if (text !== undefined) n.textContent = text;
@@ -24,25 +34,71 @@ function link(label,url) { const a = node("a",label); a.href = url; return a; }
24
34
  function field(name,control) { const label = node("label",name); label.append(control); return label; }
25
35
  function select(items) { const s = node("select"); s.append(...items.map(([id,label])=>new Option(label,id))); return s; }
26
36
  const controls = el("controls"), content = el("content");
37
+ function box(tag, className, text) {
38
+ const element = node(tag,text);
39
+ element.className = className;
40
+ return element;
41
+ }
42
+ function clock(value) {
43
+ const time = new Date(value);
44
+ return Number.isFinite(time.getTime()) ? time.toLocaleTimeString([], {hour:"2-digit",minute:"2-digit"}) : "Unavailable";
45
+ }
27
46
  function sessions(data) {
28
- const filter = node("input"); filter.type = "checkbox";
29
- filter.checked = new URLSearchParams(location.search).has("needsInput");
30
- controls.append(field("Needs input ",filter));
31
- const draw = () => {
32
- content.replaceChildren();
33
- const rows = data.sessions.filter(row => !filter.checked || row.needsInput.length);
34
- for (const [cwd,group] of Object.entries(Object.groupBy(rows,r=>r.cwd))) {
35
- content.append(node("h2",cwd));
36
- for (const row of group) {
37
- const anchor = link(row.name || row.sessionId,"/sessions/"+encodeURIComponent(row.sessionId));
38
- anchor.id = "session-" + row.sessionId;
39
- anchor.onclick = () => sessionStorage.setItem("console-back",JSON.stringify({path:location.pathname+location.search,id:anchor.id}));
40
- const p = node("p"); p.append(anchor," · ",row.needsInput.length ? "Needs input" : row.status); content.append(p);
47
+ const panel = box("section","panel sessions-panel");
48
+ const head = box("div","panel-head");
49
+ head.append(node("h2","Hosted sessions"),box("span","count",data.sessions.length));
50
+ if (page === "server") head.append(link("View all →","/sessions"));
51
+ const filters = box("div","filters"), table = node("table"), tbody = table.createTBody();
52
+ const header = table.createTHead().insertRow();
53
+ for (const text of ["Session","Workspace","Status","Updated"]) header.append(node("th",text));
54
+ const foot = box("div","panel-foot"), updated = node("span","Last check " + clock(data.observedAt)), total = node("span");
55
+ foot.append(updated,total);
56
+ panel.append(head,filters,table,foot); content.append(panel);
57
+ const params = new URLSearchParams(location.search);
58
+ let selected = params.has("needsInput") ? "Needs input" : params.get("status") || "All";
59
+ function setFilter(value) {
60
+ selected = value;
61
+ const url = new URL(location.href);
62
+ url.searchParams.delete("needsInput"); url.searchParams.delete("status");
63
+ if (value === "Needs input") url.searchParams.set("needsInput","");
64
+ else if (value !== "All") url.searchParams.set("status",value);
65
+ history.replaceState(null,"",url); draw();
66
+ }
67
+ const states = ["All","Needs input","Running","Idle"];
68
+ const chips = states.map(label => {
69
+ if (page === "sessions" && label === "Needs input") {
70
+ const check = node("input"); check.type = "checkbox"; check.onchange = () => setFilter(check.checked ? label : "All");
71
+ const control = field(label,check); control.className = "check-filter"; filters.append(control); return control;
72
+ }
73
+ const b = button(label,() => setFilter(label)); filters.append(b); return b;
74
+ });
75
+ const statusOf = row => row.needsInput?.length ? "Needs input" : row.displayStatus || row.status || "Unknown";
76
+ function draw() {
77
+ chips.forEach((control,i) => {
78
+ if (control.tagName === "LABEL") control.querySelector("input").checked = selected === states[i];
79
+ else control.setAttribute("aria-pressed",String(selected === states[i]));
80
+ });
81
+ const rows = data.sessions.filter(row => selected === "All" || statusOf(row).toLowerCase() === selected.toLowerCase());
82
+ tbody.replaceChildren();
83
+ const groups = page === "sessions" ? Object.entries(Object.groupBy(rows,r=>r.cwd)) : [["",rows]];
84
+ for (const [cwd,items] of groups) {
85
+ if (cwd) { const group = tbody.insertRow().insertCell(); group.colSpan = 4; group.className = "group"; group.textContent = cwd; }
86
+ for (const row of items) {
87
+ const tr = tbody.insertRow(), a = link(row.name || row.sessionId,"/sessions/"+encodeURIComponent(row.sessionId));
88
+ a.id = "session-"+row.sessionId; a.prepend(icon("square-terminal"));
89
+ a.onclick = () => sessionStorage.setItem("console-back",JSON.stringify({path:location.pathname+location.search,id:a.id}));
90
+ tr.insertCell().append(a);
91
+ const folder = tr.insertCell(); folder.textContent = row.cwd?.split("/").filter(Boolean).at(-1) || row.cwd; folder.title = row.cwd;
92
+ const status = statusOf(row); tr.insertCell().append(box("span","pill "+(status==="Needs input" ? "attention" : ""),status));
93
+ tr.insertCell().textContent = clock(row.lastActivityAt || row.updatedAt || row.createdAt);
41
94
  }
42
95
  }
43
- if (!rows.length) content.append(node("p","No matching sessions."));
44
- };
45
- filter.onchange = () => { history.replaceState(null,"",location.pathname+(filter.checked ? "?needsInput" : "")); draw(); };
96
+ if (!rows.length) {
97
+ const empty = tbody.insertRow().insertCell(); empty.colSpan = 4; empty.className = "empty";
98
+ empty.append(icon("panels-top-left"),node("p",data.sessions.length ? "No matching sessions." : "No hosted sessions."));
99
+ }
100
+ total.textContent = rows.length+" of "+data.sessions.length+" sessions";
101
+ }
46
102
  draw();
47
103
  const back = JSON.parse(sessionStorage.getItem("console-back") || "null");
48
104
  if (back?.path === location.pathname+location.search) el(back.id)?.focus();
@@ -50,8 +106,9 @@ function sessions(data) {
50
106
  function detail() {
51
107
  const back = JSON.parse(sessionStorage.getItem("console-back") || "null");
52
108
  controls.append(link("Back to sessions",back?.path || "/sessions"));
53
- const screen = node("pre"), meta = node("pre"); screen.className = "terminal";
54
- content.append(screen,meta);
109
+ const screen = box("pre","terminal"), meta = box("dl","metadata"), info = box("aside","panel inspector");
110
+ const layout = box("div","terminal-grid");
111
+ info.append(node("h2","Session details"),meta); layout.append(screen,info); content.append(layout);
55
112
  let generation = 0, timer, previous;
56
113
  const read = async () => {
57
114
  const request = generation;
@@ -67,7 +124,11 @@ function detail() {
67
124
  const cursor = node("mark",line[x] ?? " ");
68
125
  screen.replaceChildren(lines.slice(0,y).map(l=>l+"\n").join("")+line.slice(0,x).join(""),cursor,line.slice(x+1).join("")+"\n"+lines.slice(y+1).join("\n"));
69
126
  } else screen.textContent = frame.screen;
70
- meta.textContent = [frame.name,frame.sessionId,frame.cwd,frame.branch,frame.leaf,...frame.questions.map(q=>JSON.stringify(q))].filter(Boolean).join("\n");
127
+ meta.replaceChildren();
128
+ for (const [name,value] of Object.entries({Name:frame.name,Workspace:frame.cwd,Branch:frame.branch,Session:frame.sessionId,Leaf:frame.leaf})) {
129
+ if (value) meta.append(node("dt",name),node("dd",value));
130
+ }
131
+ for (const q of frame.questions) meta.append(node("dt","Needs input"),node("dd",q.question || q.title || JSON.stringify(q)));
71
132
  previous = encoded;
72
133
  }
73
134
  } catch (error) {
@@ -82,7 +143,9 @@ function detail() {
82
143
  }
83
144
  async function inventory(data) {
84
145
  const catalog = page === "catalog";
85
- const choices = catalog ? (await api("state")).connections.map(r=>[r.id,r.name]) : data.sessions.filter(r=>r.live).map(r=>[r.sessionId,r.name || r.sessionId]);
146
+ const catalogState = catalog ? await api("state") : null;
147
+ if (catalogState) agentDirectory(catalogState.agentDir);
148
+ const choices = catalog ? catalogState.connections.map(r=>[r.id,r.name]) : data.sessions.filter(r=>r.live).map(r=>[r.sessionId,r.name || r.sessionId]);
86
149
  const scope = select([["","Select session"],...choices]), query = node("input");
87
150
  query.type = "search"; controls.append(field("Session",scope),field("Search",query));
88
151
  const format = select([["Tree","Tree"],["Flat","Flat"]]), status = select([["","All"],["Active","Active"],["Registered","Registered"]]);
@@ -94,19 +157,29 @@ async function inventory(data) {
94
157
  const draw = () => {
95
158
  content.replaceChildren();
96
159
  const list = rows.filter(r=>(!status.value || r.status === status.value) && [r.name,r.description,r.source].join(" ").toLowerCase().includes(query.value.toLowerCase()));
97
- const info = node("pre");
98
- const pick = row => { selected = row; info.textContent = JSON.stringify(row,null,2); };
99
- if (list.includes(selected)) pick(selected);
160
+ const layout = box("div","inventory-grid"), results = box("section","panel inventory-list"), inspector = box("aside","panel inspector");
161
+ layout.append(results,inspector); content.append(layout);
162
+ const pick = row => {
163
+ selected = row; inspector.replaceChildren(box("span","caption","Details"),node("h2",row.name),node("p",row.description || ""));
164
+ const facts = box("dl","metadata");
165
+ for (const [title,value] of Object.entries({Source:row.source,Status:row.status})) {
166
+ if (value) facts.append(node("dt",title),node("dd",value));
167
+ }
168
+ const raw = node("details"); raw.append(node("summary","Full record"),node("pre",JSON.stringify(row,null,2)));
169
+ inspector.append(facts,raw);
170
+ for (const item of results.querySelectorAll("button")) item.setAttribute("aria-pressed",String(item.dataset.name === row.name));
171
+ };
172
+ const entry = row => { const item = button(row.name,()=>pick(row)); item.dataset.name = row.name; return item; };
100
173
  if (page === "tools" && format.value === "Flat") {
101
174
  const table = node("table"), head = node("tr"); head.append(...["Tool","Source","Session status","Description"].map(s=>node("th",s))); table.append(head);
102
- for (const row of list) { const tr = node("tr"), name = node("td"); name.append(button(row.name,()=>pick(row))); tr.append(name,...[row.source,row.status,row.description].map(s=>node("td",s))); table.append(tr); }
103
- content.append(table);
175
+ for (const row of list) { const tr = node("tr"), name = node("td"); name.append(entry(row)); tr.append(name,...[row.source,row.status,row.description].map(s=>node("td",s))); table.append(tr); }
176
+ results.append(table);
104
177
  } else for (const [source,items] of Object.entries(Object.groupBy(list,r=>r.source || "Unknown source"))) {
105
178
  const group = node("details"); group.open = true; group.append(node("summary",source));
106
- for (const row of items) group.append(button(row.name,()=>pick(row))); content.append(group);
179
+ for (const row of items) group.append(entry(row)); results.append(group);
107
180
  }
108
- if (!list.length && scope.value && !el("notice").textContent) content.append(node("p","No matching entries."));
109
- content.append(info);
181
+ if (list.length) pick(list.includes(selected) ? selected : list[0]);
182
+ else { inspector.hidden = true; results.append(node("p","No matching entries.")); }
110
183
  };
111
184
  const load = async () => {
112
185
  const request = ++generation;
@@ -124,33 +197,59 @@ async function inventory(data) {
124
197
  if (choices.length) { scope.value = choices[0][0]; await load(); }
125
198
  else el("notice").textContent = catalog ? "Connect a Pi session with a catalog host." : "No live session available.";
126
199
  }
200
+ function runtimeCards(data) {
201
+ const cards = box("div","runtime-cards"), runtime = box("section","runtime"), upgrade = box("section","upgrade panel");
202
+ const caption = box("div","caption","Managed runtime"); caption.prepend(icon("server"));
203
+ const state = box("h2","runtime-state",data.status === "Running" ? "Connected" : data.status);
204
+ state.dataset.connected = String(data.status === "Running");
205
+ const glyph = icon("server"); glyph.classList.add("runtime-glyph");
206
+ runtime.append(caption,state,glyph);
207
+ const hello = data.hello;
208
+ if (hello) {
209
+ const facts = box("dl","facts");
210
+ for (const [label,value] of [["Build",hello.build?.serverVersion],["Pi SDK",hello.piVersion],["Protocol","v"+hello.protocolVersion]]) {
211
+ const cell = node("div"); cell.append(node("dt",label),node("dd",value ?? "Unavailable")); facts.append(cell);
212
+ }
213
+ runtime.append(facts);
214
+ sessionStorage.setItem("console-last-handshake",JSON.stringify({at:data.observedAt,instance:hello.instanceId}));
215
+ } else {
216
+ if (data.status === "Stopped") runtime.append(button("Start server",()=>overview("console_start")));
217
+ const last = JSON.parse(sessionStorage.getItem("console-last-handshake") || "null");
218
+ if (last) runtime.append(node("p","Last connected " + clock(last.at)));
219
+ }
220
+ const label = box("div","caption","Runtime upgrade"); label.prepend(icon("upload"));
221
+ const phase = data.upgrade?.phase;
222
+ const heading = data.upgradeError || !hello ? "Unavailable" : phase === "ready" ? "Ready" : phase === "prepared" ? "Waiting for idle" : phase ? phase[0].toUpperCase()+phase.slice(1) : "No upgrade recorded";
223
+ upgrade.append(label,node("h2",heading));
224
+ const message = data.upgradeError || data.upgrade?.reason || (phase === "ready" && data.upgrade.desiredBuild?.serverVersion ? "Activated build " + data.upgrade.desiredBuild.serverVersion : "");
225
+ if (message) upgrade.append(node("p",message));
226
+ for (const blocker of data.upgrade?.blockers ?? []) {
227
+ const item = node("p",blocker.reason || blocker.kind || JSON.stringify(blocker));
228
+ const row = data.sessions?.find(r => r.sessionId === blocker.sessionId || r.sessionId === blocker.id);
229
+ if (row) item.append(" · ",link(row.name || row.sessionId,"/sessions/"+encodeURIComponent(row.sessionId)));
230
+ upgrade.append(item);
231
+ }
232
+ upgrade.append(link("View sessions →","/sessions")); cards.append(runtime,upgrade); controls.append(cards);
233
+ const details = box("details","panel disclosure"); details.append(node("summary","Connection details"));
234
+ const list = box("dl","metadata");
235
+ for (const [k,v] of Object.entries({Status:data.status,Directory:data.dir,Socket:data.serverDir,Instance:hello?.instanceId,Build:hello?.build?.contentId,Observed:data.observedAt})) {
236
+ if (v) list.append(node("dt",k),node("dd",v));
237
+ }
238
+ details.append(list); el("connection").replaceChildren(details);
239
+ }
240
+ let observation = 0;
127
241
  async function overview(action = "console_status") {
242
+ const request = ++observation;
128
243
  controls.replaceChildren(); content.replaceChildren(); el("notice").textContent = "";
244
+ el("connection").replaceChildren();
129
245
  if (sessionId) return detail();
130
- controls.append(button("Refresh",()=>overview()));
246
+ const refresh = button("Refresh",()=>overview()); refresh.prepend(icon("refresh-cw"));
247
+ el("actions").replaceChildren(refresh);
131
248
  if (page === "catalog") return inventory();
132
249
  const data = await api(action);
133
- if (page === "server") {
134
- const hello = data.hello;
135
- controls.append(node("h2",data.status),node("p",data.dir),node("p","Observed "+data.observedAt));
136
- if (hello) sessionStorage.setItem("console-last-handshake",JSON.stringify({at:data.observedAt,instance:hello.instanceId}));
137
- else {
138
- const last = JSON.parse(sessionStorage.getItem("console-last-handshake") || "null");
139
- if (last) controls.append(node("p","Last successful handshake (stale): "+last.instance+" · "+last.at));
140
- }
141
- if (hello) controls.append(node("pre",JSON.stringify({instance:hello.instanceId,build:hello.build ?? "Unavailable",piSDK:hello.piVersion,protocol:hello.protocolVersion},null,2)),
142
- node("p",data.upgradeError ? "Upgrade status unavailable · "+data.upgradeError : data.upgrade ? "Upgrade · "+data.upgrade.phase : "No recorded upgrade"));
143
- if (data.upgrade) {
144
- if (data.upgrade.reason) controls.append(node("p",data.upgrade.reason));
145
- for (const blocker of data.upgrade.blockers ?? []) {
146
- const p = node("p",JSON.stringify(blocker));
147
- const row = data.sessions.find(r=>r.sessionId === blocker.sessionId || r.sessionId === blocker.id);
148
- if (row) p.append(" ",link(row.name || row.sessionId,"/sessions/"+encodeURIComponent(row.sessionId)));
149
- controls.append(p);
150
- }
151
- }
152
- if (data.status === "Stopped") controls.append(button("Start server",()=>overview("console_start")));
153
- }
250
+ if (request !== observation) return;
251
+ agentDirectory(data.dir);
252
+ if (page === "server") runtimeCards(data);
154
253
  if (data.status !== "Running") { el("notice").textContent = data.reason || data.status; return; }
155
254
  if (["server","sessions"].includes(page)) sessions(data); else await inventory(data);
156
255
  }
package/lib/console.html CHANGED
@@ -1,3 +1,9 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Pi Better Harness</title><link rel="stylesheet" href="/manager.css"></head>
2
- <body><header><strong>Pi Better Harness</strong><a href="/server">Server</a><a href="/sessions">Sessions</a><a href="/catalog">Agent Catalog</a><a href="/mcp">MCP</a><a href="/skills">Skills</a><a href="/tools">Tools</a><a href="/prompts/edit">Prompts</a></header>
3
- <main class="console"><article><h1 id="title"></h1><p id="notice" role="status"></p><section id="controls"></section><section id="content"></section></article></main><script type="module" src="/console.js"></script></body></html>
1
+ <!doctype html>
2
+ <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
3
+ <title>Pi Better Harness</title><link rel="stylesheet" href="/manager.css"></head>
4
+ <body><aside class="rail"><div class="brand"><img src="/console-logo.png" width="40" height="40" alt=""><div><b>Pi Better <br>Harness</b><small>Local console</small></div></div>
5
+ <nav aria-label="Main navigation"></nav><div class="rail-foot" hidden>Agent directory<code></code></div></aside>
6
+ <header class="crumb">Local <span>/</span> <strong></strong></header>
7
+ <main class="console"><div class="page-head"><div><h1 id="title"></h1><p id="subtitle"></p></div><div id="actions"></div></div>
8
+ <p id="notice" role="status"></p><div id="controls"></div><section id="content"></section><div id="connection"></div></main>
9
+ <script type="module" src="/console.js"></script></body></html>
package/lib/prompt-ui.mjs CHANGED
@@ -1,5 +1,7 @@
1
1
  import { caseOutcome, comparisonReport, replyComparison } from "./prompt-report.mjs";
2
2
  import { promptParts } from "/prompt-layout.mjs";
3
+ import { mountShell, agentDirectory } from "/console-shell.mjs";
4
+ mountShell();
3
5
  const el = id => document.getElementById(id);
4
6
  const token = location.hash.slice(1) || sessionStorage.getItem("prompt-token");
5
7
  if (token) sessionStorage.setItem("prompt-token", token);
@@ -33,40 +35,64 @@ function handle(fn) {
33
35
  finally { document.querySelector("main").inert = false; }
34
36
  };
35
37
  }
38
+ function moduleName(row) {
39
+ const name = row.id.replace(/^(?:bundled|user):/,"").replaceAll("-"," ");
40
+ return name ? name[0].toUpperCase()+name.slice(1) : "New module";
41
+ }
36
42
  function drawRows() {
37
- el("rows").replaceChildren(...rows.map((row, i) => {
38
- const section = node("div"); section.className = "module";
39
- section.addEventListener("focusin", () => { focused = row; preview(); });
40
- section.oninput = () => preview();
41
- if (i === 0 || rows[i-1].origin !== row.origin) section.append(node("h3",row.origin === "bundled" ? "Bundled" : "User"));
43
+ if (!rows.includes(focused)) focused = rows[0];
44
+ const list = el("rows");
45
+ list.replaceChildren();
46
+ let lastOrigin;
47
+ for (const row of rows) {
48
+ if (lastOrigin !== row.origin) list.append(node("h3",row.origin === "bundled" ? "Bundled" : "User"));
49
+ lastOrigin = row.origin;
50
+ const line = node("div"); line.className = "module-option";
51
+ const select = node("button",moduleName(row));
52
+ select.setAttribute("aria-pressed",String(row === focused));
53
+ select.onclick = () => { focused = row; drawRows(); el("editor").querySelector("textarea").focus({preventScroll:true}); };
54
+ line.append(select);
42
55
  if (row.origin === "bundled") {
43
56
  const toggle = node("input"); toggle.type = "checkbox"; toggle.checked = row.enabled;
57
+ toggle.setAttribute("aria-label","Enable "+row.id);
44
58
  toggle.onchange = () => { row.enabled = toggle.checked; preview(); };
45
- const label = node("label"); label.append(toggle, " " + row.id);
46
- const entry = state.attribution.bundled.find(m => m.id === row.id);
47
- const meta = node("details"); meta.append(node("summary","Shipped text and version"), node("pre",row.original),node("code",entry.version));
48
- const editor = node("textarea"); editor.value = row.override ?? row.text; editor.rows = 3;
49
- editor.setAttribute("aria-label", row.id + " Markdown");
50
- editor.oninput = () => { row.override = editor.value; reset.disabled = false; };
51
- const reset = node("button","Reset to original"); reset.disabled = !Object.hasOwn(row,"override");
52
- reset.onclick = () => { delete row.override; delete row.overrideBase; editor.value = row.text; reset.disabled = true; editor.focus(); preview(); };
53
- if (row.overrideBase && row.overrideBase !== entry.version) meta.append(node("p","Package original changed since this override."));
54
- section.append(label, editor, reset, meta); return section;
59
+ line.append(toggle);
55
60
  }
56
- const bar = node("div"); bar.className = "toolbar";
57
- const name = node("input"); name.value = row.id.slice(5); name.setAttribute("aria-label", "User module name");
58
- name.oninput = () => { row.id = "user:" + name.value; };
59
- bar.append(name);
60
- for (const [symbol, title, offset] of [["↑","Move up",-1],["↓","Move down",1],["×","Remove",0]]) {
61
- const b = node("button", symbol); b.title = title; b.setAttribute("aria-label", title + " " + row.id);
62
- b.disabled = rows[i + offset]?.origin !== "user";
63
- b.onclick = () => { rows.splice(i, 1); if (offset) rows.splice(i + offset, 0, row); drawRows(); };
64
- bar.append(b);
61
+ list.append(line);
62
+ }
63
+ const row = focused, i = rows.indexOf(row), editor = el("editor");
64
+ editor.replaceChildren();
65
+ el("module-title").textContent = moduleName(row);
66
+ el("module-origin").textContent = row.origin === "bundled" ? "Bundled module" : "User module";
67
+ el("module-id").textContent = row.id;
68
+ const body = node("textarea"); body.rows = 9; body.value = row.override ?? row.text;
69
+ body.setAttribute("aria-label",row.id+" Markdown");
70
+ const label = node("label","Markdown"); label.append(body);
71
+ if (row.origin === "bundled") {
72
+ const entry = state.attribution.bundled.find(m=>m.id === row.id);
73
+ const original = node("details"); original.append(node("summary","Package original"),node("pre",row.original),node("code",entry.version));
74
+ if (row.overrideBase && row.overrideBase !== entry.version) original.append(node("p","Package original changed since this override."));
75
+ const reset = node("button","Reset to original"); reset.disabled = !Object.hasOwn(row,"override");
76
+ reset.onclick = () => { delete row.override; delete row.overrideBase; body.value = row.text; reset.disabled = true; body.focus(); preview(); };
77
+ body.oninput = () => { row.override = body.value; reset.disabled = false; preview(); };
78
+ editor.append(label,original,reset);
79
+ } else {
80
+ const name = node("input"); name.value = row.id.slice(5); name.setAttribute("aria-label","User module name");
81
+ name.oninput = () => {
82
+ row.id = "user:"+name.value;
83
+ list.querySelector('[aria-pressed="true"]').textContent = moduleName(row);
84
+ el("module-title").textContent = moduleName(row); el("module-id").textContent = row.id;
85
+ body.setAttribute("aria-label",row.id+" Markdown"); preview();
86
+ };
87
+ const tools = node("div"); tools.className = "toolbar";
88
+ for (const [text,offset] of [["Move up",-1],["Move down",1],["Remove",0]]) {
89
+ const b = node("button",text); b.disabled = offset !== 0 && rows[i+offset]?.origin !== "user";
90
+ b.onclick = () => { rows.splice(i,1); if (offset) rows.splice(i+offset,0,row); drawRows(); };
91
+ tools.append(b);
65
92
  }
66
- const body = node("textarea"); body.rows = 3; body.value = row.text; body.setAttribute("aria-label", row.id + " Markdown");
67
- body.oninput = () => { row.text = body.value; };
68
- section.append(bar, body); return section;
69
- }));
93
+ body.oninput = () => { row.text = body.value; preview(); };
94
+ editor.append(name,label,tools);
95
+ }
70
96
  preview();
71
97
  }
72
98
  function preview() {
@@ -138,6 +164,9 @@ function showEvidence() {
138
164
  async function refresh(preferredEvidence) {
139
165
  const previous = state?.selected;
140
166
  state = await api("state"); selected = state.selected;
167
+ agentDirectory(state.agentDir);
168
+ el("active-id").textContent = state.active?.slice(0,12) || state.source;
169
+ el("active-id").title = state.active || "";
141
170
  if (previous !== selected) { rows = structuredClone(state.modules); focused = rows[0]; }
142
171
  options("revisions", state.records, selected);
143
172
  options("session", [{ id: "", label: "Standalone" }, ...state.connections.map(c => ({ id: c.id, label: c.name }))], connection);
@@ -238,15 +267,15 @@ function tab(view) {
238
267
  }
239
268
  if (state && view === "replay") (el("mode").value === "sessions" ? refreshSessions() : refreshForks()).catch(e=>{el("notice").textContent=e.message;});
240
269
  if (returning && focused) {
241
- const section = el("rows").children[rows.indexOf(focused)];
242
- section?.querySelector("textarea")?.focus({preventScroll:true});
270
+ el("editor").querySelector("textarea")?.focus({preventScroll:true});
243
271
  }
244
272
  }
245
273
  for (const b of document.querySelectorAll("[data-view]")) b.onclick = () => tab(b.dataset.view);
246
274
  el("revisions").onchange = handle(async () => { selected = el("revisions").value; await refresh(); });
247
275
  el("session").onchange = handle(async () => { connection = el("session").value; await refresh(); });
248
276
  el("refresh").onclick = handle(refresh);
249
- el("add").onclick = () => { rows.push({ id:"user:",origin:"user",text:"" }); drawRows(); el("rows").lastChild.querySelector("input").focus(); };
277
+ el("add").onclick = () => { focused = { id:"user:",origin:"user",text:"" }; rows.push(focused); drawRows(); el("editor").querySelector("input").focus(); };
278
+ el("history-link").onclick = () => { el("revision-history").open = true; el("revision-history").scrollIntoView(); return false; };
250
279
  el("compare").onclick = handle(async () => { el("target").value = selected; await refreshPair(); tab("replay"); });
251
280
  el("save").onclick = handle(async () => { selected = await api("save", { modules:rows }); await refresh(); el("notice").textContent = "Saved " + selected + " · Parent " + state.parent + (state.evidence.length ? " · Previously tested" : " · Untested"); });
252
281
  el("publish").onclick = handle(async () => { if (confirm("Publish " + state.active + " → " + selected + "?\n" + state.diff)) { await api("publish", { confirmed:true }); await refresh(); } });