@stablekernel/pi-background-run 0.1.0 → 0.2.1
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 +38 -3
- package/extension/index.test.ts +573 -59
- package/extension/index.ts +452 -101
- package/package.json +3 -2
- package/skill/run-bg/SKILL.md +15 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stablekernel/pi-background-run",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Run long shell commands detached in the background for pi; get woken on completion. Output lands in a file; context stays clean.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,13 +30,14 @@
|
|
|
30
30
|
],
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
|
-
"url": "https://github.com/stablekernel/pi-background-run.git"
|
|
33
|
+
"url": "git+https://github.com/stablekernel/pi-background-run.git"
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/stablekernel/pi-background-run#readme",
|
|
36
36
|
"bugs": {
|
|
37
37
|
"url": "https://github.com/stablekernel/pi-background-run/issues"
|
|
38
38
|
},
|
|
39
39
|
"keywords": [
|
|
40
|
+
"pi-package",
|
|
40
41
|
"pi",
|
|
41
42
|
"pi-coding-agent",
|
|
42
43
|
"background",
|
package/skill/run-bg/SKILL.md
CHANGED
|
@@ -13,11 +13,13 @@ never blocks. The extension wakes this session automatically when the job finish
|
|
|
13
13
|
no polling.
|
|
14
14
|
|
|
15
15
|
## When to use
|
|
16
|
+
|
|
16
17
|
- Any command expected to run > ~30s OR emit > ~100 lines.
|
|
17
18
|
- Typical: `make test`, `go test ./...`, `make lint`, `make build`.
|
|
18
19
|
- Integration / infra suites (long-running, always background).
|
|
19
20
|
|
|
20
21
|
## When NOT to use
|
|
22
|
+
|
|
21
23
|
- Commands that complete in < ~5s — the overhead isn't worth it.
|
|
22
24
|
- Short, quiet commands whose full output you actually need (`git status`).
|
|
23
25
|
- Interactive commands (prompts, REPL, SSH) — bgrun detaches from the terminal.
|
|
@@ -27,9 +29,9 @@ no polling.
|
|
|
27
29
|
| Action | Tool |
|
|
28
30
|
|---|---|
|
|
29
31
|
| Start | `bgrun(command: "make test-short", name: "unit-tests")` → `started: <job-id>` (name is an optional short label; use it so jobs are recognizable in `bgstatus`, the status widget, and wake messages) |
|
|
30
|
-
| Status | `bgstatus(<job-id>)` or `bgstatus()` for
|
|
32
|
+
| Status | `bgstatus(<job-id>)` for one job, or `bgstatus()` for this session's running jobs — finished jobs are hidden by default; pass `includeDone: true` to list them |
|
|
31
33
|
| Tail | `bgtail(<job-id>, 40)` |
|
|
32
|
-
| Clean | `bgclean(
|
|
34
|
+
| Clean | `bgclean()` (default 7-day retention) |
|
|
33
35
|
|
|
34
36
|
## Workflow
|
|
35
37
|
|
|
@@ -51,6 +53,7 @@ no polling.
|
|
|
51
53
|
|
|
52
54
|
- **Quick peek (≤40 lines):** call `bgtail` with the job id and `lines: 40` — strips the `__BGRUN_EXIT__` marker.
|
|
53
55
|
- **Whole-log failure analysis:** `ctx_execute_file` on the log path:
|
|
56
|
+
|
|
54
57
|
```
|
|
55
58
|
ctx_execute_file(
|
|
56
59
|
path: "~/.pi-bgrun/jobs/<JOB>.log",
|
|
@@ -61,6 +64,7 @@ no polling.
|
|
|
61
64
|
console.log(fails.slice(0,40).join('\\n'));"
|
|
62
65
|
)
|
|
63
66
|
```
|
|
67
|
+
|
|
64
68
|
A 10 000-line `make test` log collapses to a ~30-line summary in context.
|
|
65
69
|
|
|
66
70
|
**Never `cat`, `Read`, or `bash cat` a full bgrun log.** Always `bgtail` or
|
|
@@ -70,16 +74,20 @@ no polling.
|
|
|
70
74
|
|
|
71
75
|
- The live wake does not survive a pi restart or a `/resume` to a different session
|
|
72
76
|
(the extension loses the child process handle). The log still completes on disk.
|
|
73
|
-
- After a restart/switch, `bgstatus`
|
|
74
|
-
|
|
75
|
-
`bgstatus
|
|
77
|
+
- After a restart/switch, run `bgstatus(<job-id>)` — the id still resolves via the
|
|
78
|
+
log's `__BGRUN_EXIT__=N` marker. To browse everything on disk, use
|
|
79
|
+
`bgstatus(includeDone: true)`.
|
|
80
|
+
- Each session only tracks its own jobs by default. Jobs from other sessions
|
|
81
|
+
appear only when `adoptForeignJobs` is enabled in `~/.pi/agent/pi-bgrun.json`
|
|
82
|
+
(or `PI_BGRUN_FOREIGN_JOBS=1`).
|
|
76
83
|
|
|
77
84
|
## Rules
|
|
78
85
|
|
|
79
86
|
- Call the tools; never hand-roll `nohup … &` inline.
|
|
80
87
|
- One job = one id. Multiple concurrent jobs are fine — each has its own log.
|
|
81
88
|
- Logs live in `~/.pi-bgrun/jobs` (override with `PI_BGRUN_DIR`).
|
|
82
|
-
-
|
|
83
|
-
(
|
|
89
|
+
- Cleanup: `bgclean` manually; auto-sweeps run at session start/shutdown, at
|
|
90
|
+
most once per `cleanupDays` (default 7, configurable in
|
|
91
|
+
`~/.pi/agent/pi-bgrun.json` or `PI_BGRUN_CLEANUP_DAYS`).
|
|
84
92
|
- To stop a running job, use `bash` with `kill <pid>` (the pid is in the `bgstatus`
|
|
85
93
|
output). There is no `bgkill` tool.
|