@yusukeshib/pi-babysit 0.7.0 → 0.8.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.
- package/README.md +9 -17
- package/index.ts +4 -6
- package/package.json +1 -5
- package/view.mjs +0 -79
package/README.md
CHANGED
|
@@ -167,7 +167,9 @@ including reusable idle agents. Summary counts use `RUNNING` / `IDLE`; rows show
|
|
|
167
167
|
and unknown-status indicators when applicable, and a colored one-line description.
|
|
168
168
|
Older sessions fall back to their command or task. Rows truncate to terminal width
|
|
169
169
|
with `…`. In fullscreen mode, click the single `⧉` icon at the right edge of a row
|
|
170
|
-
to copy that session's shell-quoted `babysit log` command
|
|
170
|
+
to copy that session's shell-quoted `babysit log` command (for a local subagent,
|
|
171
|
+
its log file path; see [Viewing a subagent transcript](#viewing-a-subagent-transcript)).
|
|
172
|
+
The command includes the local
|
|
171
173
|
`BABYSIT_DIR` or remote host/worker ID, without executing the command or changing
|
|
172
174
|
the input buffer. The icon changes in place: `…` while copying, `✓` on success,
|
|
173
175
|
or `!` on failure. The result stays visible for two seconds before returning to
|
|
@@ -232,27 +234,17 @@ RPC event stream (JSONL), recorded through the worker's PTY, so lines end in
|
|
|
232
234
|
`\r\n`. pi-babysit adds no records and removes no fields. Parked-turn
|
|
233
235
|
detection reads `agent_end.messages`.
|
|
234
236
|
|
|
235
|
-
###
|
|
237
|
+
### Viewing a subagent transcript
|
|
236
238
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
The wrapper resolves a session id, uses the worker's directory, and shows the
|
|
242
|
-
session state. The widget's copy icon on a local subagent row copies this
|
|
243
|
-
command:
|
|
239
|
+
The widget's copy icon on a local subagent row copies the subagent's log file
|
|
240
|
+
path. The log is Pi's standard RPC event stream, so any Pi event viewer can
|
|
241
|
+
read it, for example [pi-tail](https://github.com/yusukeshib/pi-tail), which
|
|
242
|
+
renders it with Pi's own components:
|
|
244
243
|
|
|
245
244
|
```sh
|
|
246
|
-
|
|
245
|
+
pi-tail -f <copied output.log path>
|
|
247
246
|
```
|
|
248
247
|
|
|
249
|
-
Keys: `q` / `Ctrl-C` quit, `Ctrl-O` expand or collapse tool output, `t`
|
|
250
|
-
toggle thinking blocks. `--print` renders the current transcript once to stdout;
|
|
251
|
-
`--cwd DIR` overrides the worker directory. Because the log is a plain Pi RPC
|
|
252
|
-
stream, `pi-tail <output.log>` works on it too. See the pi-tail README for how
|
|
253
|
-
Pi packages, settings, themes and extension renderers are loaded
|
|
254
|
-
(`PI_TAIL_PI_PACKAGE_DIR` overrides the Pi package directory).
|
|
255
|
-
|
|
256
248
|
## Execution timeouts
|
|
257
249
|
|
|
258
250
|
Commands default to an absolute **60s execution timeout**, in both foreground
|
package/index.ts
CHANGED
|
@@ -638,7 +638,7 @@ interface Meta {
|
|
|
638
638
|
// subagent
|
|
639
639
|
task?: string;
|
|
640
640
|
launchCommand?: string;
|
|
641
|
-
/** Worker working directory
|
|
641
|
+
/** Worker working directory. */
|
|
642
642
|
cwd?: string;
|
|
643
643
|
reapAfter?: string;
|
|
644
644
|
promptOffset?: number;
|
|
@@ -2694,14 +2694,12 @@ function sessionCliCommand(id: string, command: "log" | "attach"): string {
|
|
|
2694
2694
|
}
|
|
2695
2695
|
|
|
2696
2696
|
/**
|
|
2697
|
-
*
|
|
2698
|
-
*
|
|
2697
|
+
* Text copied by the widget icon: a local subagent's log file path (Pi's RPC
|
|
2698
|
+
* event stream, e.g. for `pi-tail -f`); everything else gets its log command.
|
|
2699
2699
|
*/
|
|
2700
2700
|
export function widgetCopyCommand(id: string): string {
|
|
2701
2701
|
const meta = readMeta(id);
|
|
2702
|
-
if (meta?.kind === "subagent" && !meta.host)
|
|
2703
|
-
return `${shq(process.execPath)} ${shq(path.join(EXT_DIR, "view.mjs"))} ${shq(logPath(id))}`;
|
|
2704
|
-
}
|
|
2702
|
+
if (meta?.kind === "subagent" && !meta.host) return logPath(id);
|
|
2705
2703
|
return sessionCliCommand(id, "log");
|
|
2706
2704
|
}
|
|
2707
2705
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yusukeshib/pi-babysit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Run any shell command and pi subagents under babysit, with context-safe captured output.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"agents.ts",
|
|
24
24
|
"self-reap.ts",
|
|
25
25
|
"format-stream.mjs",
|
|
26
|
-
"view.mjs",
|
|
27
26
|
"search-log.mjs",
|
|
28
27
|
"gc.mjs",
|
|
29
28
|
"gc.d.mts",
|
|
@@ -39,9 +38,6 @@
|
|
|
39
38
|
"./index.ts"
|
|
40
39
|
]
|
|
41
40
|
},
|
|
42
|
-
"dependencies": {
|
|
43
|
-
"@yusukeshib/pi-tail": "^0.1.0"
|
|
44
|
-
},
|
|
45
41
|
"peerDependencies": {
|
|
46
42
|
"@earendil-works/pi-ai": "*",
|
|
47
43
|
"@earendil-works/pi-coding-agent": ">=1.0.0",
|
package/view.mjs
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* view.mjs — live, read-only view of a pi-babysit subagent, rendered by
|
|
4
|
-
* @yusukeshib/pi-tail with Pi's own TUI components.
|
|
5
|
-
*
|
|
6
|
-
* node view.mjs <session-id | session dir | output.log> [--print] [--cwd DIR]
|
|
7
|
-
*
|
|
8
|
-
* A subagent log is Pi's `pi --mode rpc` event stream. This wrapper resolves
|
|
9
|
-
* the session, uses the worker's directory, and shows the session state.
|
|
10
|
-
*/
|
|
11
|
-
import fs from "node:fs";
|
|
12
|
-
import os from "node:os";
|
|
13
|
-
import path from "node:path";
|
|
14
|
-
import { pathToFileURL } from "node:url";
|
|
15
|
-
import { parseArgs, runCli, runViewer } from "@yusukeshib/pi-tail";
|
|
16
|
-
|
|
17
|
-
export { parseArgs };
|
|
18
|
-
|
|
19
|
-
const USAGE = "Usage: node view.mjs <session-id | session dir | output.log> [--print] [--cwd DIR]";
|
|
20
|
-
|
|
21
|
-
/** Resolve a session id, session directory, or log path to the log file. */
|
|
22
|
-
export function resolveLogPath(target, rootBase = process.env.PI_BABYSIT_DIR ?? path.join(os.homedir(), ".pi-babysit")) {
|
|
23
|
-
if (fs.existsSync(target)) {
|
|
24
|
-
const stat = fs.statSync(target);
|
|
25
|
-
return stat.isDirectory() ? path.join(target, "output.log") : target;
|
|
26
|
-
}
|
|
27
|
-
let best;
|
|
28
|
-
for (const root of fs.existsSync(rootBase) ? fs.readdirSync(rootBase) : []) {
|
|
29
|
-
const log = path.join(rootBase, root, "sessions", target, "output.log");
|
|
30
|
-
try {
|
|
31
|
-
const mtime = fs.statSync(log).mtimeMs;
|
|
32
|
-
if (!best || mtime > best.mtime) best = { log, mtime };
|
|
33
|
-
} catch {
|
|
34
|
-
/* not in this root */
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (!best) throw new Error(`No babysit session log found for ${target} under ${rootBase}`);
|
|
38
|
-
return best.log;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function readJson(file) {
|
|
42
|
-
try {
|
|
43
|
-
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
44
|
-
} catch {
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** pi-babysit's own metadata for a session log (<root>/meta/<id>.json). */
|
|
50
|
-
function sessionInfo(logPath) {
|
|
51
|
-
const sessionDir = path.dirname(logPath);
|
|
52
|
-
const id = path.basename(sessionDir);
|
|
53
|
-
const root = path.dirname(path.dirname(sessionDir));
|
|
54
|
-
return {
|
|
55
|
-
id,
|
|
56
|
-
meta: readJson(path.join(root, "meta", `${id}.json`)),
|
|
57
|
-
statusFile: path.join(sessionDir, "status.json"),
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export async function main(argv = process.argv.slice(2)) {
|
|
62
|
-
const options = parseArgs(argv);
|
|
63
|
-
if (options.help || !options.target) {
|
|
64
|
-
console.log(USAGE);
|
|
65
|
-
return options.help ? 0 : 2;
|
|
66
|
-
}
|
|
67
|
-
const file = resolveLogPath(options.target);
|
|
68
|
-
const info = sessionInfo(file);
|
|
69
|
-
const label = info.meta?.name && info.meta.name !== info.id ? `${info.id} (${info.meta.name})` : info.id;
|
|
70
|
-
return runViewer({
|
|
71
|
-
file,
|
|
72
|
-
cwd: options.cwd ?? info.meta?.cwd ?? process.cwd(),
|
|
73
|
-
print: options.print,
|
|
74
|
-
status: () => `${label} · ${readJson(info.statusFile)?.state ?? "unknown"}`,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const entry = process.argv[1] ? pathToFileURL(fs.realpathSync(process.argv[1])).href : undefined;
|
|
79
|
-
if (entry === import.meta.url) runCli(main);
|