@clanker-code/pi-subagents 0.10.5
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/.plans/PLAN-next-changes.md +183 -0
- package/.plans/README.md +14 -0
- package/AGENTS.md +31 -0
- package/CHANGELOG.md +583 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +21 -0
- package/README.md +630 -0
- package/RELEASE.md +39 -0
- package/dist/abort-resend.d.ts +35 -0
- package/dist/abort-resend.js +71 -0
- package/dist/agent-details.d.ts +17 -0
- package/dist/agent-details.js +22 -0
- package/dist/agent-manager.d.ts +132 -0
- package/dist/agent-manager.js +493 -0
- package/dist/agent-runner.d.ts +165 -0
- package/dist/agent-runner.js +732 -0
- package/dist/agent-tool-description.d.ts +9 -0
- package/dist/agent-tool-description.js +147 -0
- package/dist/agent-types.d.ts +60 -0
- package/dist/agent-types.js +157 -0
- package/dist/context.d.ts +12 -0
- package/dist/context.js +56 -0
- package/dist/cross-extension-rpc.d.ts +46 -0
- package/dist/cross-extension-rpc.js +76 -0
- package/dist/custom-agents.d.ts +14 -0
- package/dist/custom-agents.js +149 -0
- package/dist/default-agents.d.ts +7 -0
- package/dist/default-agents.js +119 -0
- package/dist/enabled-models.d.ts +49 -0
- package/dist/enabled-models.js +145 -0
- package/dist/env.d.ts +6 -0
- package/dist/env.js +28 -0
- package/dist/group-join.d.ts +32 -0
- package/dist/group-join.js +116 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +1918 -0
- package/dist/invocation-config.d.ts +25 -0
- package/dist/invocation-config.js +19 -0
- package/dist/memory.d.ts +49 -0
- package/dist/memory.js +151 -0
- package/dist/model-resolver.d.ts +19 -0
- package/dist/model-resolver.js +62 -0
- package/dist/notifications.d.ts +6 -0
- package/dist/notifications.js +107 -0
- package/dist/output-file.d.ts +24 -0
- package/dist/output-file.js +86 -0
- package/dist/peek.d.ts +37 -0
- package/dist/peek.js +121 -0
- package/dist/prompts.d.ts +40 -0
- package/dist/prompts.js +95 -0
- package/dist/schedule-store.d.ts +38 -0
- package/dist/schedule-store.js +155 -0
- package/dist/schedule.d.ts +109 -0
- package/dist/schedule.js +338 -0
- package/dist/settings.d.ts +135 -0
- package/dist/settings.js +168 -0
- package/dist/skill-loader.d.ts +24 -0
- package/dist/skill-loader.js +93 -0
- package/dist/status-note.d.ts +13 -0
- package/dist/status-note.js +24 -0
- package/dist/types.d.ts +184 -0
- package/dist/types.js +7 -0
- package/dist/ui/agent-tool-rendering.d.ts +34 -0
- package/dist/ui/agent-tool-rendering.js +154 -0
- package/dist/ui/agent-widget-tree.d.ts +33 -0
- package/dist/ui/agent-widget-tree.js +130 -0
- package/dist/ui/agent-widget.d.ts +156 -0
- package/dist/ui/agent-widget.js +408 -0
- package/dist/ui/conversation-viewer.d.ts +47 -0
- package/dist/ui/conversation-viewer.js +290 -0
- package/dist/ui/menu-select.d.ts +20 -0
- package/dist/ui/menu-select.js +46 -0
- package/dist/ui/schedule-menu.d.ts +16 -0
- package/dist/ui/schedule-menu.js +99 -0
- package/dist/ui/viewer-keys.d.ts +20 -0
- package/dist/ui/viewer-keys.js +17 -0
- package/dist/usage.d.ts +50 -0
- package/dist/usage.js +49 -0
- package/dist/wait.d.ts +10 -0
- package/dist/wait.js +37 -0
- package/dist/worktree.d.ts +45 -0
- package/dist/worktree.js +160 -0
- package/docs/design/default-extension-tool-exposure.md +56 -0
- package/docs/superpowers/plans/2026-06-19-recursive-subagent-widget.md +600 -0
- package/docs/superpowers/specs/2026-06-19-recursive-subagent-widget-design.md +189 -0
- package/examples/agent-tool-description.md +45 -0
- package/package.json +56 -0
- package/reviews/proposal-structured-output-schema.md +135 -0
- package/reviews/recursive-subagent-widget-preview-rev2.png +0 -0
- package/reviews/recursive-subagent-widget-preview.html +137 -0
- package/reviews/recursive-subagent-widget-preview.png +0 -0
- package/reviews/subagent-features-comparison.md +350 -0
- package/src/abort-resend.ts +75 -0
- package/src/agent-details.ts +31 -0
- package/src/agent-manager.ts +596 -0
- package/src/agent-runner.ts +872 -0
- package/src/agent-tool-description.ts +163 -0
- package/src/agent-types.ts +189 -0
- package/src/context.ts +58 -0
- package/src/cross-extension-rpc.ts +122 -0
- package/src/custom-agents.ts +160 -0
- package/src/default-agents.ts +123 -0
- package/src/enabled-models.ts +180 -0
- package/src/env.ts +33 -0
- package/src/group-join.ts +141 -0
- package/src/index.ts +2115 -0
- package/src/invocation-config.ts +42 -0
- package/src/memory.ts +165 -0
- package/src/model-resolver.ts +81 -0
- package/src/notifications.ts +120 -0
- package/src/output-file.ts +96 -0
- package/src/peek.ts +155 -0
- package/src/prompts.ts +129 -0
- package/src/schedule-store.ts +153 -0
- package/src/schedule.ts +365 -0
- package/src/settings.ts +289 -0
- package/src/skill-loader.ts +102 -0
- package/src/status-note.ts +25 -0
- package/src/types.ts +195 -0
- package/src/ui/agent-tool-rendering.ts +175 -0
- package/src/ui/agent-widget-tree.ts +169 -0
- package/src/ui/agent-widget.ts +497 -0
- package/src/ui/conversation-viewer.ts +297 -0
- package/src/ui/menu-select.ts +68 -0
- package/src/ui/schedule-menu.ts +105 -0
- package/src/ui/viewer-keys.ts +39 -0
- package/src/usage.ts +60 -0
- package/src/wait.ts +44 -0
- package/src/worktree.ts +191 -0
- package/vitest.config.ts +25 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Plan: Next pi-subagents improvements
|
|
2
|
+
|
|
3
|
+
This plan covers four coordinated changes:
|
|
4
|
+
1. **Abort-detach + interruptible/timeout wait** for `get_subagent_result wait:true` (Escape no longer wedges the turn; default 4.5 min timeout).
|
|
5
|
+
2. Configurable `waitTimeoutSeconds` setting (default 270s) exposed in `/agents → Settings`.
|
|
6
|
+
3. `get_subagent_result` peek/tail capability with line numbers, regex filter, and `after` line offset.
|
|
7
|
+
4. Description polish for `inherit_context` and `isolation: "worktree"`.
|
|
8
|
+
|
|
9
|
+
All changes are scoped to keep diffs minimal and upstream-merge-friendly.
|
|
10
|
+
|
|
11
|
+
### Key finding (abort-detach)
|
|
12
|
+
Background spawns already do NOT pass the parent abort signal to `manager.spawn()` — only the now-dead foreground path did. So background subagents are already detached from Escape. The Escape-wedge symptom comes from `get_subagent_result wait:true`, which awaits `record.promise` and ignores the parent `signal`. Fix: race the wait against (a) the parent abort `signal` and (b) the configurable timeout, returning current status on either WITHOUT aborting the subagent.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 1. Settings foundation: configurable `waitTimeoutSeconds`
|
|
17
|
+
|
|
18
|
+
### Motivation
|
|
19
|
+
Users want to avoid typical 5-minute LLM cache expiry; 4.5 minutes is a safe default. We also want this exposed in `/agents → Settings` so it is discoverable and adjustable per project.
|
|
20
|
+
|
|
21
|
+
### Files touched
|
|
22
|
+
- `src/types.ts` — add `waitTimeoutSeconds` to `AgentRecord`? No, this is runtime/config, not per-agent. Keep it in settings only.
|
|
23
|
+
- `src/settings.ts`:
|
|
24
|
+
- Add `waitTimeoutSeconds?: number` to `SubagentsSettings`.
|
|
25
|
+
- Add `setWaitTimeoutSeconds: (seconds: number) => void` to `SettingsAppliers`.
|
|
26
|
+
- Add sanitize rule: integer, min 30, max 3600 (30s–1h). Default 270 (4.5m) when absent.
|
|
27
|
+
- Add `applySettings` wiring.
|
|
28
|
+
- `src/index.ts`:
|
|
29
|
+
- Add `let waitTimeoutSeconds = 270` and getter/setter.
|
|
30
|
+
- Add to `snapshotSettings()`.
|
|
31
|
+
- Add `/agents → Settings` item with id `waitTimeoutSeconds`.
|
|
32
|
+
- Wire `applyValue` for `waitTimeoutSeconds` (numeric prompt, 30–3600).
|
|
33
|
+
- Add to `applyAndEmitLoaded` appliers object.
|
|
34
|
+
- Pass timeout value into `get_subagent_result` execute closure.
|
|
35
|
+
|
|
36
|
+
### Return value / UI impact
|
|
37
|
+
- `get_subagent_result` `wait` description: mention current configured timeout.
|
|
38
|
+
- On timeout, return message:
|
|
39
|
+
```
|
|
40
|
+
Agent is still running after 4 minutes 30 seconds.
|
|
41
|
+
This wait timed out to avoid blocking the parent session longer than the configured limit.
|
|
42
|
+
Call get_subagent_result with wait: true again to keep waiting, or omit wait to check status.
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Tests
|
|
46
|
+
- `test/settings.test.ts` (if exists) or new assertions in `test/settings.test.ts`: sanitize boundaries.
|
|
47
|
+
- New/updated test for `get_subagent_result` timeout behavior using a mocked promise and fake timers.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 2. `get_subagent_result` peek parameter
|
|
52
|
+
|
|
53
|
+
### Motivation
|
|
54
|
+
Agents should be able to cheaply check recent output / logs without fetching the full result or conversation.
|
|
55
|
+
|
|
56
|
+
### Proposed schema
|
|
57
|
+
```ts
|
|
58
|
+
peek: Type.Optional(
|
|
59
|
+
Type.Object({
|
|
60
|
+
lines: Type.Optional(Type.Number({ minimum: 1, description: "Number of trailing lines to return. Default: 20." })),
|
|
61
|
+
regex: Type.Optional(Type.String({ description: "Optional regex filter. Only lines matching this regex are included." })),
|
|
62
|
+
after: Type.Optional(Type.Number({ minimum: 0, description: "Return all lines after this 0-based line index. Overrides lines when set." })),
|
|
63
|
+
}, {
|
|
64
|
+
description: "Return a peek (tail/filter/update) of the agent result or streaming output file. Ignored when verbose is true.",
|
|
65
|
+
}),
|
|
66
|
+
),
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Behavior
|
|
70
|
+
- `peek` is ignored when `verbose: true`.
|
|
71
|
+
- If `after` is set, return all lines with index > `after` (or >= `after+1`). Include line numbers.
|
|
72
|
+
- Else, return the last `lines` lines (default 20). Include line numbers.
|
|
73
|
+
- If `regex` is provided, filter matching lines **first**, then apply tail/after semantics. Include line numbers of the original source.
|
|
74
|
+
- Source precedence:
|
|
75
|
+
1. If agent is running and `record.outputFile` exists, read from the streaming output file. Parse JSONL and extract assistant/toolResult text (most useful live content).
|
|
76
|
+
2. Else if `record.result` exists, split it into lines.
|
|
77
|
+
3. Else return: "No output yet."
|
|
78
|
+
|
|
79
|
+
### Return format
|
|
80
|
+
```
|
|
81
|
+
Showing last 20 lines of agent output (line numbers from full output):
|
|
82
|
+
|
|
83
|
+
[42] some line
|
|
84
|
+
[43] another line
|
|
85
|
+
...
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
Use verbose: true for the full conversation, or omit peek for the complete result.
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
If `regex` is used, add: `(filtered by regex: /.../)`.
|
|
92
|
+
If `after` is used, add: `(lines after index N)`.
|
|
93
|
+
|
|
94
|
+
### Implementation notes
|
|
95
|
+
- Add helper `peekAgentOutput(record, peek)` in a new file or in `src/index.ts` near `get_subagent_result`.
|
|
96
|
+
- For output-file JSONL parsing, reuse/extract from `output-file.ts` or read the file line-by-line.
|
|
97
|
+
- Handle regex parse errors gracefully — return a clear error message.
|
|
98
|
+
- Avoid reading the whole file into memory if possible; for now `readFileSync` is acceptable because output files are bounded by session length and the tail case is common.
|
|
99
|
+
|
|
100
|
+
### Tests
|
|
101
|
+
- New test file `test/get-subagent-result-peek.test.ts` or extend existing `status-note-wiring.test.ts`:
|
|
102
|
+
- Peek tail of result.
|
|
103
|
+
- Peek with regex.
|
|
104
|
+
- Peek `after` offset.
|
|
105
|
+
- Peek ignored when verbose true.
|
|
106
|
+
- Peek on running agent with output file.
|
|
107
|
+
- Regex parse error handling.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 3. Description polish
|
|
112
|
+
|
|
113
|
+
### `inherit_context`
|
|
114
|
+
Current:
|
|
115
|
+
> "If true, fork parent conversation into the agent. Default: false (fresh context)."
|
|
116
|
+
|
|
117
|
+
New:
|
|
118
|
+
> "If true, fork the parent conversation into the agent so it sees the chat history. Recommended for questions or requests that require current context. Default: false (fresh context)."
|
|
119
|
+
|
|
120
|
+
Also update the eject template line in `src/index.ts`.
|
|
121
|
+
|
|
122
|
+
### `isolation: "worktree"`
|
|
123
|
+
Current:
|
|
124
|
+
> "Set to 'worktree' to run the agent in a temporary git worktree (isolated copy of the repo). Changes are saved to a branch on completion."
|
|
125
|
+
|
|
126
|
+
New:
|
|
127
|
+
> "Set to 'worktree' to run the agent in a temporary git worktree that is automatically created from the current repo state at HEAD and removed on completion. Changes are saved to a branch. Requires the working directory to be a git repo with at least one commit."
|
|
128
|
+
|
|
129
|
+
Also update README.md and `examples/agent-tool-description.md` to match.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 4. Coordination / cross-cutting concerns
|
|
134
|
+
|
|
135
|
+
- `get_subagent_result` description must mention the configurable timeout, e.g.:
|
|
136
|
+
> "If true, wait for the agent to complete before returning. Blocks up to the configured wait timeout (default 4.5 minutes). If the agent is still running when the timeout is reached, returns current status with instructions to call again. Default: false."
|
|
137
|
+
|
|
138
|
+
- The settings UI should present `waitTimeoutSeconds` as "Wait timeout (30–3600s, default 270 = 4m30s)".
|
|
139
|
+
|
|
140
|
+
- Tests for the timeout should use Vitest fake timers so they run fast and deterministically.
|
|
141
|
+
|
|
142
|
+
- Peek should not duplicate verbose. Keep the contract: `verbose` = full conversation, `peek` = lightweight tail/filter.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 5. Things to consider removing / avoiding
|
|
147
|
+
|
|
148
|
+
Before jumping in, review whether any existing code becomes dead weight:
|
|
149
|
+
|
|
150
|
+
- The foreground execution path in `src/index.ts` is now dead code after the background-by-default change. We currently left it in place but unreachable. Consider whether to remove it in a separate cleanup pass (it complicates future changes).
|
|
151
|
+
- `run_in_background` param is deprecated but still in the schema. Keep it for prompt compatibility; do not remove.
|
|
152
|
+
- `AgentConfig.runInBackground` frontmatter default is still consulted by `resolveAgentInvocationConfig`. Since `index.ts` now forces `runInBackground = true`, the frontmatter field is effectively ignored. Consider whether to deprecate it in docs or leave it as a no-op.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 6. Acceptance criteria
|
|
157
|
+
|
|
158
|
+
- [ ] `get_subagent_result wait:true` times out after the configured number of seconds and returns a clear message.
|
|
159
|
+
- [ ] Timeout duration is configurable via `/agents → Settings` and persists to `.pi/subagents.json`.
|
|
160
|
+
- [ ] `get_subagent_result` supports `peek` with `lines`, `regex`, and `after`.
|
|
161
|
+
- [ ] `peek` returns line numbers and respects `verbose: true` (is ignored).
|
|
162
|
+
- [ ] `inherit_context` and `isolation` descriptions are updated in tool schema, eject template, README, and example template.
|
|
163
|
+
- [ ] All existing tests pass; new tests cover timeout + peek.
|
|
164
|
+
- [ ] `npm run typecheck` and `npm run lint` clean.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 7. Implementation order
|
|
169
|
+
|
|
170
|
+
1. Add `waitTimeoutSeconds` setting (settings.ts + index.ts wiring).
|
|
171
|
+
2. Implement wait timeout in `get_subagent_result` execute.
|
|
172
|
+
3. Add `peek` parameter + helper.
|
|
173
|
+
4. Update descriptions for `inherit_context` and `isolation`.
|
|
174
|
+
5. Update README + example template.
|
|
175
|
+
6. Write tests.
|
|
176
|
+
7. Run full test/typecheck/lint.
|
|
177
|
+
|
|
178
|
+
--- SUMMARY ---
|
|
179
|
+
|
|
180
|
+
- Add a configurable `waitTimeoutSeconds` setting (default 270s) wired into `/agents → Settings` and `get_subagent_result wait:true`.
|
|
181
|
+
- Add a `peek` object param to `get_subagent_result` for tail/filter/offset access to result/output-file with line numbers, ignored when `verbose` is true.
|
|
182
|
+
- Polish `inherit_context` and `isolation: "worktree"` descriptions across schema, template, README, and example.
|
|
183
|
+
- Tests, typecheck, lint.
|
package/.plans/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# `.plans/` — local planning scratch
|
|
2
|
+
|
|
3
|
+
This directory holds ad-hoc plans, notes, and design sketches for this fork. It is gitignored so it does not pollute upstream diffs.
|
|
4
|
+
|
|
5
|
+
## Conventions
|
|
6
|
+
|
|
7
|
+
- One plan per file: `PLAN-<short-name>.md`.
|
|
8
|
+
- Plans should include: motivation, files touched, behavior changes, UI/message changes, tests, acceptance criteria, implementation order, and a summary.
|
|
9
|
+
- When a plan graduates to implementation, update the plan file with progress or archive it.
|
|
10
|
+
- Delete obsolete plans to avoid stale guidance.
|
|
11
|
+
|
|
12
|
+
## Active plans
|
|
13
|
+
|
|
14
|
+
- `PLAN-next-changes.md` — configurable `get_subagent_result` wait timeout, peek/tail/regex/after parameter, and description polish for `inherit_context` / `isolation: "worktree"`.
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# CLAUDE.md — Notes for Claude / Coding Agents
|
|
2
|
+
|
|
3
|
+
This is a fork of [`tintinweb/pi-subagents`](https://github.com/tintinweb/pi-subagents).
|
|
4
|
+
|
|
5
|
+
## Fork Relationship
|
|
6
|
+
|
|
7
|
+
- We track upstream for useful changes but do **not** auto-merge.
|
|
8
|
+
- This is a pseudo-fork: cherry-pick upstream commits when they apply cleanly and fit our direction; otherwise reimplement the same behavior in our own commits.
|
|
9
|
+
- `package.json`, `README.md`, and `CHANGELOG.md` must reflect this fork (`@clanker-code/pi-subagents`).
|
|
10
|
+
|
|
11
|
+
## Release Checklist
|
|
12
|
+
|
|
13
|
+
Every release must:
|
|
14
|
+
|
|
15
|
+
1. Bump `version` in `package.json`.
|
|
16
|
+
2. Update `CHANGELOG.md` with a dated `[x.y.z]` section under `[Unreleased]`.
|
|
17
|
+
3. **Update `README.md` to document any new or changed user-facing features.**
|
|
18
|
+
4. Run and pass: `npm run lint`, `npm run typecheck`, `npm test`, `npm run build`.
|
|
19
|
+
5. Commit and push.
|
|
20
|
+
6. User publishes with `npm publish` from a clean `master` checkout.
|
|
21
|
+
|
|
22
|
+
## Keeping Upstream In Sync
|
|
23
|
+
|
|
24
|
+
Periodically run:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
git fetch upstream
|
|
28
|
+
git log --oneline --right-only --no-merges HEAD...upstream/master
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Cherry-pick commits that are wanted and clean; reimplement anything that conflicts with fork-specific changes.
|