pi-better-harness 0.61.4 → 0.63.0

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 (45) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +23 -3
  3. package/bin/pi-remote.mjs +2 -0
  4. package/extensions/server/detach.ts +1 -0
  5. package/extensions/server/remote.ts +1 -0
  6. package/lib/cli.mjs +13 -2
  7. package/lib/console-catalog.mjs +20 -0
  8. package/lib/console-inventory.mjs +82 -0
  9. package/lib/console-resource-reader.mjs +55 -0
  10. package/lib/console-shell.mjs +4 -1
  11. package/lib/console-ui.mjs +170 -89
  12. package/lib/local-session-console.mjs +127 -0
  13. package/lib/local-session-discovery.mjs +10 -0
  14. package/lib/local-session-terminal.mjs +124 -0
  15. package/lib/local-session-ui.mjs +166 -0
  16. package/lib/local-tui.mjs +71 -0
  17. package/lib/prompt-tools.mjs +2 -0
  18. package/lib/prompt-ui.mjs +89 -30
  19. package/lib/prompt-web.mjs +29 -7
  20. package/lib/prompt.css +47 -4
  21. package/lib/prompt.html +2 -2
  22. package/lib/terminal-view.mjs +66 -0
  23. package/node_modules/pi-better-background-tasks/README.md +1 -0
  24. package/node_modules/pi-better-background-tasks/package.json +2 -1
  25. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-arm64.json +1 -1
  26. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-x64.json +1 -1
  27. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-arm64.json +1 -1
  28. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-x64.json +1 -1
  29. package/node_modules/pi-better-background-tasks/runtime-client/src/runtime/client.mjs +3 -1
  30. package/node_modules/pi-better-subagents/README.md +1 -0
  31. package/node_modules/pi-better-subagents/package.json +2 -1
  32. package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-arm64.json +1 -1
  33. package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-x64.json +1 -1
  34. package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-arm64.json +1 -1
  35. package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-x64.json +1 -1
  36. package/node_modules/pi-better-subagents/runtime-client/src/runtime/client.mjs +3 -1
  37. package/package.json +12 -5
  38. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-arm64.gz +0 -0
  39. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-x64.gz +0 -0
  40. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-arm64.gz +0 -0
  41. package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-x64.gz +0 -0
  42. package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-arm64.gz +0 -0
  43. package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-x64.gz +0 -0
  44. package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-arm64.gz +0 -0
  45. package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-x64.gz +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.63.0] - 2026-11-30
4
+
5
+ ### Changed
6
+
7
+ - Include the shared server in both Harness install modes. Set `PI_BETTER_SERVER_ENABLE_REMOTE=1` before starting Pi to enable `/remote`, `/detach` and `pi-remote`.
8
+
9
+ ## [0.62.0] - 2026-11-30
10
+
11
+ ### Added
12
+
13
+ - Open Sessions in the opt-in Web UI to interact with a local Pi terminal at its original size. Both the terminal and browser share the same Work Navigator, keyboard input and conversation. Closing the last console tab releases the connection.
14
+ - Browse host prompts, agents, skills, tools and MCP servers without selecting a session. Skills show their loading paths or packages, Tools groups start collapsed, and MCP servers that support OAuth can be authenticated from the console.
15
+ - Preview prompt modules as separate Markdown sections while editing.
16
+
3
17
  ## [0.61.4] - 2026-11-29
4
18
 
5
19
  ### Fixed
package/README.md CHANGED
@@ -11,10 +11,13 @@ Use `pi-better-harness` when you want the full working set for Pi. It manages:
11
11
  - `pi-better-sandbox` for an opt-in write sandbox around Pi's foreground tools.
12
12
  - `pi-better-subagents` for detached, sandboxed subagent runs.
13
13
  - `pi-better-background-tasks` for durable shell tasks and watchers.
14
+ - `pi-better-server` provides the shared task runtime and opt-in remote session commands.
14
15
  - `pi-better-ssh` for short remote commands over reusable SSH connections.
15
16
  - `pi-better-goal` for explicit triggers, pause/resume, and background-aware continuation.
16
17
  - Harness-owned Goal & Todo for session context and checklist progress. Saved work appears in the panel. Automatic Goal execution defaults to Off.
17
18
 
19
+ Both Harness install methods include the shared server for subagents and background tasks. Remote session commands are off by default. Set `PI_BETTER_SERVER_ENABLE_REMOTE=1` before starting Pi to enable `/remote` and `/detach`. The same variable enables the `pi-remote` CLI.
20
+
18
21
  `pi-better-read-aloud` is intentionally not included yet.
19
22
 
20
23
  <a id="outcome--todo"></a>
@@ -343,6 +346,21 @@ the current Pi agent directory (`PI_CODING_AGENT_DIR`). The CLI prints a
343
346
  private loopback URL and opens the browser. Set `BROWSER=none` to print
344
347
  the URL only. Stop the CLI to close the server.
345
348
 
349
+ **Prompts**, **Agent Catalog**, **MCP**, **Skills** and **Tools** use the host agent
350
+ directory. You can open them with no Pi sessions running. Skills are grouped by
351
+ directory or package. Tools groups registered definitions by source and cached MCP
352
+ tools by server. MCP lists configured servers. **Authenticate** opens Pi's OAuth
353
+ sign-in for an eligible HTTP server and reports the result after Pi reconnects.
354
+
355
+ Opening the session list automatically connects running interactive Pi terminals in
356
+ this agent directory. After upgrading, run `/reload`
357
+ once in already-open terminals to load the extension. Select a terminal to see
358
+ its live Pi screen at the terminal's current dimensions. Browser and terminal
359
+ input share the same editor, menus and dialogs. A daemon session with no attached
360
+ interactive Pi terminal shows its read-only output.
361
+ Closing the last console tab releases the web connections. The terminals and
362
+ their current work continue.
363
+
346
364
  Each bundled module retains its package original and position. Edit its local
347
365
  override, toggle inclusion, or use **Reset to original**. Turning a slot off
348
366
  retains its override for the next time it is enabled.
@@ -369,9 +387,9 @@ any unscored session.
369
387
 
370
388
  To compare a candidate on one response, capture it with `/prompt-capture` or load
371
389
  a reviewed suite with `/prompt-import`. The TUI can use its current session
372
- directly. For the browser, choose **Connect browser** in the TUI and select
373
- the named Pi session on the page. The connection lasts until disconnect,
374
- reload or session shutdown. Select a captured request or a suite and model
390
+ directly. For browser replay, choose **Connect browser** in the TUI that owns
391
+ the capture or suite. The connection lasts until disconnect, reload or session
392
+ shutdown. Select a captured request or a suite and model
375
393
  in **Replay** and choose the two saved revisions. Results and judgments stay in the agent directory and
376
394
  can be reopened from either interface. Promotion requires a reviewed result
377
395
  for the displayed baseline and candidate.
@@ -493,6 +511,8 @@ Use the installer when you want every core extension with standalone package ide
493
511
 
494
512
  ## Update Or Remove
495
513
 
514
+ For an installer-managed setup, run `npx pi-better-harness@latest install` to update Harness, Server and both task clients together. Add `--local` for a project install. For a direct bundle install, run `pi update npm:pi-better-harness`.
515
+
496
516
  Remove every standalone package:
497
517
 
498
518
  ```sh
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "pi-better-server/bin/pi-remote.mjs";
@@ -0,0 +1 @@
1
+ export { default } from "pi-better-server/src/detach/extension.ts";
@@ -0,0 +1 @@
1
+ export { default } from "pi-better-server/src/remote-client/extension.ts";
package/lib/cli.mjs CHANGED
@@ -8,7 +8,7 @@ import { manageInstructions } from "./instructions.mjs";
8
8
  import { webUiDisabledMessage, webUiEnabled } from "./web-ui-flag.mjs";
9
9
 
10
10
  const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
11
- const { version } = JSON.parse(readFileSync(resolve(packageRoot, "package.json"), "utf8"));
11
+ const { version, dependencies } = JSON.parse(readFileSync(resolve(packageRoot, "package.json"), "utf8"));
12
12
 
13
13
  const HARNESS_PACKAGE = "pi-better-harness";
14
14
 
@@ -19,9 +19,18 @@ export const componentPackages = [
19
19
  "pi-better-subagents",
20
20
  "pi-better-background-tasks",
21
21
  "pi-better-ssh",
22
+ "pi-better-server",
22
23
  "pi-better-goal",
23
24
  ];
24
25
 
26
+ // Pi saves the install spec. Resolve the server and its clients as a tested set.
27
+ const runtimeVersions = {
28
+ [HARNESS_PACKAGE]: version,
29
+ "pi-better-server": dependencies["pi-better-server"],
30
+ "pi-better-subagents": dependencies["pi-better-subagents"],
31
+ "pi-better-background-tasks": dependencies["pi-better-background-tasks"],
32
+ };
33
+
25
34
  function usage() {
26
35
  const web = webUiEnabled();
27
36
  return `Usage: pi-better-harness <install|uninstall> [--local]
@@ -107,7 +116,9 @@ export function run(argv, options = {}) {
107
116
  const piCommand = process.platform === "win32" ? "pi.cmd" : "pi";
108
117
  const piAction = command === "install" ? "install" : "remove";
109
118
  for (const packageName of [...componentPackages, HARNESS_PACKAGE]) {
110
- const args = [piAction, `npm:${packageName}`, ...scopeArgs(local)];
119
+ const pin = runtimeVersions[packageName];
120
+ const source = command === "install" && pin ? `npm:${packageName}@${pin}` : `npm:${packageName}`;
121
+ const args = [piAction, source, ...scopeArgs(local)];
111
122
  const result = spawn(piCommand, args, { stdio: "inherit" });
112
123
  if (result.error) {
113
124
  stderr.write(`Failed to run Pi for ${packageName}: ${result.error.message}\n`);
@@ -0,0 +1,20 @@
1
+ import { register } from "tsx/esm/api";
2
+
3
+ register();
4
+ const { createCatalogHostAdapter } = await import("pi-better-subagents/catalog-host-admission.ts");
5
+ const { openSharedCatalog } = await import("pi-better-subagents/shared-catalog.ts");
6
+ const { inspectCatalog } = await import("pi-better-subagents/catalog-resolver.ts");
7
+
8
+ export async function personalCatalog(dir) {
9
+ const host = createCatalogHostAdapter();
10
+ host.noteCatalogHostContext({cwd:dir,isProjectTrusted:()=>false},()=>({}));
11
+ let catalog;
12
+ try {
13
+ catalog = await openSharedCatalog(dir,dir,"web-console",false,undefined,host.catalogHostAuthority,true);
14
+ const snapshot = await catalog.get();
15
+ return [...snapshot.roles.values(),...snapshot.agents.values()].map(entry => ({
16
+ ...inspectCatalog(snapshot,entry.id), name:entry.id, source:entry.kind === "role" ? "Roles" : "Named Agents",
17
+ savedSettings:snapshot.savedSettings?.[entry.id], preferenceSources:snapshot.preferenceSources?.[entry.id]
18
+ }));
19
+ } finally { catalog?.close(); host.closeCatalogHost(); }
20
+ }
@@ -0,0 +1,82 @@
1
+ import { execFile, fork } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+ import { readFile } from "node:fs/promises";
4
+ import { join } from "node:path";
5
+
6
+ async function config(dir, file) {
7
+ try { return JSON.parse(await readFile(join(dir,file),"utf8")); }
8
+ catch (error) {
9
+ if (error.code === "ENOENT") return {};
10
+ throw Error("Could not read " + file + " in the agent directory.");
11
+ }
12
+ }
13
+
14
+ async function mcpServers(dir) {
15
+ const {mcpServers = {}} = await config(dir,"mcp.json");
16
+ return Object.entries(mcpServers).map(([name,server]) => {
17
+ const disabled = server?.disabled === true || server?.enabled === false;
18
+ const oauth = !disabled && typeof server?.url === "string" && !server.auth && !server.bearerTokenEnvVar &&
19
+ !Object.keys(server.headers || {}).some(key => key.toLowerCase() === "authorization");
20
+ return {name,source:"Host configuration",status:disabled ? "Disabled" : "Configured",...(oauth && {canAuthenticate:true})};
21
+ });
22
+ }
23
+
24
+ export function mcpAuthenticator(dir) {
25
+ const active = new Map();
26
+ return async name => {
27
+ const servers = await mcpServers(dir);
28
+ if (typeof name !== "string" || name.startsWith("-") || !servers.some(s => s.name === name && s.canAuthenticate))
29
+ throw Error("OAuth sign-in is unavailable for this server.");
30
+ if (!active.has(name)) {
31
+ const env = {...process.env,PI_CODING_AGENT_DIR:dir};
32
+ if (env.BROWSER === "none") delete env.BROWSER;
33
+ const login = promisify(execFile)("pi",["mcp","login",name,"--timeout","300"],{cwd:dir,env,timeout:310000})
34
+ .then(() => true, error => { throw Error(error.code === "ENOENT" ? "Pi is unavailable on this host." : "Sign-in did not complete. Retry authentication."); })
35
+ .finally(() => active.delete(name));
36
+ active.set(name,login);
37
+ }
38
+ return active.get(name);
39
+ };
40
+ }
41
+
42
+ function discover(dir, inventory) {
43
+ return new Promise((resolve,reject) => {
44
+ const worker = fork(new URL("./console-resource-reader.mjs",import.meta.url),[inventory],{
45
+ cwd:dir, env:{...process.env, PI_CODING_AGENT_DIR:dir}, execArgv:[],
46
+ stdio:["ignore","ignore","ignore","ipc"], timeout:45000, killSignal:"SIGKILL"
47
+ });
48
+ worker.once("message",message => message.error ? reject(Error(message.error)) : resolve(message.rows));
49
+ worker.once("error",reject);
50
+ worker.once("exit",() => reject(Error("Pi resource discovery stopped before returning the host inventory.")));
51
+ });
52
+ }
53
+
54
+ export function hostInventories(dir) {
55
+ const pending = new Map();
56
+ async function read(page) {
57
+ if (page === "mcp") return mcpServers(dir);
58
+ if (page === "catalog") {
59
+ const {personalCatalog} = await import("./console-catalog.mjs");
60
+ return personalCatalog(dir);
61
+ }
62
+ if (page !== "tools" && page !== "skills") throw Error("Unknown host inventory.");
63
+ const rows = await discover(dir,page);
64
+ if (page === "tools") {
65
+ const servers = await mcpServers(dir);
66
+ const cache = await config(dir,"mcp-cache.json");
67
+ const names = new Set(rows.map(row => row.name));
68
+ for (const server of servers) {
69
+ if (server.status === "Disabled") continue;
70
+ for (const tool of cache.servers?.[server.name]?.tools || []) {
71
+ const name = "mcp__" + server.name + "__" + tool.name;
72
+ if (!names.has(name)) rows.push({name,description:tool.description,source:"MCP · " + server.name,status:"Cached"});
73
+ }
74
+ }
75
+ }
76
+ return rows;
77
+ }
78
+ return page => {
79
+ if (!pending.has(page)) pending.set(page,read(page).then(rows => ({dir,rows})).finally(() => pending.delete(page)));
80
+ return pending.get(page);
81
+ };
82
+ }
@@ -0,0 +1,55 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { basename, dirname, join } from "node:path";
3
+
4
+ function skillRows(skills) {
5
+ const packages = new Map();
6
+ return skills.map(skill => {
7
+ const path = skill.filePath, info = skill.sourceInfo;
8
+ const directory = dirname(path);
9
+ let source = basename(path) === "SKILL.md" ? dirname(directory) : directory;
10
+ if (info?.origin === "package") {
11
+ source = info.source.replace(/^npm:/,"");
12
+ if (info.baseDir) {
13
+ if (!packages.has(info.baseDir)) {
14
+ let name;
15
+ try { name = JSON.parse(readFileSync(join(info.baseDir,"package.json"),"utf8")).name; }
16
+ catch (error) { if (error.code !== "ENOENT" && error.code !== "ENOTDIR") throw error; }
17
+ packages.set(info.baseDir,name);
18
+ }
19
+ source = packages.get(info.baseDir) || source;
20
+ }
21
+ }
22
+ return {name:skill.name,description:skill.description,path,source};
23
+ });
24
+ }
25
+
26
+ // Load host extensions in a short-lived process so their registration hooks are isolated from HTTP.
27
+ async function resources(page) {
28
+ const sdk = await import("@earendil-works/pi-coding-agent");
29
+ const dir = process.env.PI_CODING_AGENT_DIR;
30
+ const settingsManager = sdk.SettingsManager.create(dir,dir);
31
+ settingsManager.setProjectTrusted(false);
32
+ const loader = new sdk.DefaultResourceLoader({cwd:dir,agentDir:dir,settingsManager,
33
+ noExtensions:page === "skills",noSkills:page === "tools",noThemes:true,noPromptTemplates:true,noContextFiles:true});
34
+ await loader.reload();
35
+ if (page === "skills") return skillRows(loader.getSkills().skills);
36
+ const tools = new Map();
37
+ for (const factory of ["Read","Bash","PowerShell","Edit","Write","Grep","Find","Ls"]) {
38
+ const tool = sdk["create" + factory + "ToolDefinition"]?.(dir);
39
+ if (tool) tools.set(tool.name,{name:tool.name,description:tool.description,source:"Built-in",status:"Registered"});
40
+ }
41
+ const builtinNames = new Set(tools.keys());
42
+ const {extensions,errors} = loader.getExtensions();
43
+ if (errors.length) throw Error("Host extension failed to load: " + errors.map(error => error.path).join(", "));
44
+ for (const extension of extensions) {
45
+ for (const [name,tool] of extension.tools) {
46
+ const provider = tool.sourceInfo?.source || extension.path;
47
+ const origin = builtinNames.has(name) ? {source:"Built-in",provider} : {source:provider};
48
+ tools.set(name,{name,description:tool.definition.description,...origin,status:"Registered"});
49
+ }
50
+ }
51
+ return [...tools.values()];
52
+ }
53
+
54
+ try { process.send({rows:await resources(process.argv[2])},() => process.exit(0)); }
55
+ catch (error) { process.send({error:error.message},() => process.exit(1)); }
@@ -1,3 +1,5 @@
1
+ import { mountLocalSessions } from "/local-session-ui.mjs";
2
+
1
3
  const sections = [
2
4
  ["server", "Server", "server"], ["sessions", "Sessions", "panels-top-left"],
3
5
  ["prompts/edit", "Prompts", "sliders-horizontal"], ["catalog", "Agent Catalog", "layout-grid"],
@@ -15,7 +17,7 @@ export function icon(name) {
15
17
  return svg;
16
18
  }
17
19
 
18
- export function mountShell() {
20
+ export function mountShell(sessionList) {
19
21
  const root = document.querySelector(".rail nav");
20
22
  const section = location.pathname.split("/")[1] || "prompts";
21
23
  for (const [path, label, glyph] of sections) {
@@ -30,6 +32,7 @@ export function mountShell() {
30
32
  root.append(a);
31
33
  }
32
34
  document.querySelector(".crumb").prepend(icon("monitor"));
35
+ mountLocalSessions(sessionList);
33
36
  }
34
37
 
35
38
  export function agentDirectory(path) {