pi-herdr-agents 0.1.3 → 0.1.4
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 +2 -0
- package/docs/worktree-subagents.md +21 -1
- package/package.json +1 -1
- package/pi-extension/subagents/index.ts +42 -1
package/README.md
CHANGED
|
@@ -370,6 +370,8 @@ subagent({
|
|
|
370
370
|
|
|
371
371
|
Use one worktree per independent writing task; keep read-only agents in ordinary panes. `cwd` selects the source Git repository, `branch` must be unique, and `base` is resolved to an exact commit before creation. If `base` is omitted, the source checkout's committed `HEAD` is used. Parent-checkout changes that have not been committed are not copied.
|
|
372
372
|
|
|
373
|
+
A launch with `worktree` and an effective bundled `scout`, `reviewer`, or `adversarial-reviewer` returns a non-blocking warning. Scouts and reviewers normally need an ordinary pane; the adversarial reviewer is a coordinator that normally uses an ordinary pane for its review artifacts and child reviewers. To inspect or review an existing worker result, start an ordinary child in that retained worktree path. Project or global role overrides do not receive these bundled-role warnings.
|
|
374
|
+
|
|
373
375
|
The child starts at the returned worktree root. Tell writing agents to test and commit when you want a commit-based handoff, and tell them not to push, merge, switch branches, or remove the worktree. The parent owns review and integration.
|
|
374
376
|
|
|
375
377
|
Successful, failed, and help-requesting runs retain their workspace. Completion includes the worktree path, Herdr workspace, branch, base/head SHAs, commits ahead, changed and untracked files, and clean/dirty/conflicted state. Here, `clean` means no uncommitted files; the branch may still contain commits. If Git inspection fails, state is reported as unknown rather than guessed.
|
|
@@ -121,7 +121,27 @@ The parent receives the normal child summary plus:
|
|
|
121
121
|
|
|
122
122
|
`clean` means there are no staged, unstaged, or untracked files. It does **not** mean the branch has no commits or diff relative to its base.
|
|
123
123
|
|
|
124
|
-
If Git inspection fails, SHA/count/state/file fields are reported as unknown rather than guessed, and the warning is included in the handoff. Inspect the retained workspace directly before integrating or deleting it.
|
|
124
|
+
If Git inspection fails, SHA/count/state/file fields are reported as unknown rather than guessed, and the warning is included in the handoff. Inspect the retained workspace directly before integrating or deleting it. Every retained handoff also includes the exact `herdr worktree remove --workspace <workspace-id>` command, but run it only after useful state is preserved.
|
|
125
|
+
|
|
126
|
+
## Parallel pull-request review without new worktrees
|
|
127
|
+
|
|
128
|
+
For parallel read-only review, prepare one stable existing checkout of the pull request or retained worker result. Do not create one managed worktree per reviewer.
|
|
129
|
+
|
|
130
|
+
1. The parent records the exact base and head SHAs and makes sure no writer changes the checkout while review runs.
|
|
131
|
+
2. Start each read-only child in an ordinary pane with `cwd` set to that checkout. Omit `worktree`.
|
|
132
|
+
3. Give every reviewer the same exact base and head SHAs. Require it to report `git rev-parse HEAD` before its review result.
|
|
133
|
+
4. Before the parent reports or publishes the review, recheck the checkout SHA. If it changed, treat the prior reviews as stale and review the new commit again.
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
subagent({
|
|
137
|
+
name: "PR reviewer",
|
|
138
|
+
agent: "reviewer",
|
|
139
|
+
cwd: "/path/to/pr-checkout",
|
|
140
|
+
task: "Review base <base-sha> through head <head-sha>. First report git rev-parse HEAD. Do not modify files.",
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
A retained worker worktree can be this checkout. The parent owns any final report, PR action, integration, and cleanup.
|
|
125
145
|
|
|
126
146
|
## Review and integration
|
|
127
147
|
|
package/package.json
CHANGED
|
@@ -791,7 +791,7 @@ function resolveEffectiveInteractive(
|
|
|
791
791
|
function loadAgentDefaults(
|
|
792
792
|
agentName: string,
|
|
793
793
|
pi?: Pick<ExtensionAPI, "events">,
|
|
794
|
-
):
|
|
794
|
+
): ListedAgentDefinition | null {
|
|
795
795
|
return (
|
|
796
796
|
discoverAgentCatalog(pi).agents.find((agent) => agent.name === agentName) ??
|
|
797
797
|
null
|
|
@@ -956,6 +956,32 @@ function shouldRetainSubagentSurface(
|
|
|
956
956
|
return !!running.worktree;
|
|
957
957
|
}
|
|
958
958
|
|
|
959
|
+
const BUNDLED_WORKTREE_WARNINGS: Readonly<Record<string, string>> = {
|
|
960
|
+
scout:
|
|
961
|
+
"The bundled scout role is read-only and normally does not need a new worktree. " +
|
|
962
|
+
"Use an ordinary pane instead; to inspect an existing worker result, start it in the retained worktree path. " +
|
|
963
|
+
"Herdr worktree workspaces persist until explicitly removed.",
|
|
964
|
+
reviewer:
|
|
965
|
+
"The bundled reviewer role is read-only and normally does not need a new worktree. " +
|
|
966
|
+
"Use an ordinary pane instead; to review an existing worker result, start it in the retained worktree path. " +
|
|
967
|
+
"Herdr worktree workspaces persist until explicitly removed.",
|
|
968
|
+
"adversarial-reviewer":
|
|
969
|
+
"The bundled adversarial-reviewer coordinates read-only reviewers and writes review artifacts. " +
|
|
970
|
+
"It normally uses an ordinary pane, not a new worktree. " +
|
|
971
|
+
"Herdr worktree workspaces persist until explicitly removed.",
|
|
972
|
+
};
|
|
973
|
+
|
|
974
|
+
function resolveWorktreeLaunchWarning(
|
|
975
|
+
params: Pick<Static<typeof SubagentParams>, "agent" | "worktree">,
|
|
976
|
+
pi?: Pick<ExtensionAPI, "events">,
|
|
977
|
+
): string | undefined {
|
|
978
|
+
if (!params.worktree || !params.agent) return undefined;
|
|
979
|
+
const warning = BUNDLED_WORKTREE_WARNINGS[params.agent];
|
|
980
|
+
return warning && loadAgentDefaults(params.agent, pi)?.source === "package"
|
|
981
|
+
? warning
|
|
982
|
+
: undefined;
|
|
983
|
+
}
|
|
984
|
+
|
|
959
985
|
function runSubagentScript(
|
|
960
986
|
surface: string,
|
|
961
987
|
command: string,
|
|
@@ -1126,6 +1152,10 @@ function formatWorktreeHandoff(worktree: WorktreeHandoff): string {
|
|
|
1126
1152
|
lines.push(`Untracked: ${worktree.untrackedFiles.join(", ")}`);
|
|
1127
1153
|
if (worktree.gitError)
|
|
1128
1154
|
lines.push(`Git inspection warning: ${worktree.gitError}`);
|
|
1155
|
+
lines.push(
|
|
1156
|
+
"After review and preservation, remove the workspace with:",
|
|
1157
|
+
` herdr worktree remove --workspace ${worktree.workspaceId}`,
|
|
1158
|
+
);
|
|
1129
1159
|
return lines.join("\n");
|
|
1130
1160
|
}
|
|
1131
1161
|
|
|
@@ -1994,6 +2024,7 @@ export const __test__ = {
|
|
|
1994
2024
|
sendSubagentResult,
|
|
1995
2025
|
resolveResumeLaunchBehavior,
|
|
1996
2026
|
shouldRetainSubagentSurface,
|
|
2027
|
+
resolveWorktreeLaunchWarning,
|
|
1997
2028
|
captureWorktreeHandoff,
|
|
1998
2029
|
runSubagentScript,
|
|
1999
2030
|
writeWorktreeManifest,
|
|
@@ -3743,6 +3774,10 @@ export default function subagentsExtension(pi: ExtensionAPI) {
|
|
|
3743
3774
|
ctx,
|
|
3744
3775
|
parentThinking,
|
|
3745
3776
|
);
|
|
3777
|
+
const worktreeLaunchWarning = resolveWorktreeLaunchWarning(
|
|
3778
|
+
params,
|
|
3779
|
+
runtime.pi,
|
|
3780
|
+
);
|
|
3746
3781
|
const { running, index: initialPlanIndex } = await launchSubagentWithFallbacks(
|
|
3747
3782
|
params,
|
|
3748
3783
|
ctx,
|
|
@@ -3870,6 +3905,9 @@ export default function subagentsExtension(pi: ExtensionAPI) {
|
|
|
3870
3905
|
(running.worktree
|
|
3871
3906
|
? ` in worktree ${running.worktree.path} on branch ${running.worktree.branch}. `
|
|
3872
3907
|
: ". ") +
|
|
3908
|
+
(worktreeLaunchWarning
|
|
3909
|
+
? `Warning: ${worktreeLaunchWarning} `
|
|
3910
|
+
: "") +
|
|
3873
3911
|
`Do NOT generate or assume any results — you have no idea what the sub-agent will do or produce. ` +
|
|
3874
3912
|
`The results will be delivered to you automatically as a steer message when the sub-agent finishes. ` +
|
|
3875
3913
|
`Until then, move on to other work or tell the user you're waiting.`,
|
|
@@ -3886,6 +3924,9 @@ export default function subagentsExtension(pi: ExtensionAPI) {
|
|
|
3886
3924
|
thinking: running.runtimePlan?.thinking,
|
|
3887
3925
|
runtimePlan: running.runtimePlan,
|
|
3888
3926
|
...(running.worktree ? { worktree: running.worktree } : {}),
|
|
3927
|
+
...(worktreeLaunchWarning
|
|
3928
|
+
? { warning: worktreeLaunchWarning }
|
|
3929
|
+
: {}),
|
|
3889
3930
|
status: "started",
|
|
3890
3931
|
},
|
|
3891
3932
|
};
|