@ferris1225/pi-subagents 5.0.1 → 5.0.3
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/CHANGELOG.md +26 -0
- package/README.md +28 -14
- package/package.json +1 -1
- package/skills/workflow/SKILL.md +10 -8
- package/src/configuration/config.ts +1 -1
- package/src/configuration/ui.ts +22 -50
- package/src/delegation/agents.ts +1 -1
- package/src/delegation/builtin-agents.ts +3 -3
- package/src/delegation/dispatch.ts +9 -45
- package/src/delegation/prompt.ts +5 -5
- package/src/execution/background.ts +23 -227
- package/src/isolation/cleanup.ts +158 -0
- package/src/isolation/worktree.ts +1 -1
- package/src/lifecycle/cancellation.ts +11 -8
- package/src/lifecycle/completion.ts +2 -12
- package/src/lifecycle/dispatch-core.ts +5 -1
- package/src/lifecycle/runtime.ts +16 -2
- package/src/lifecycle/thread-lifecycle.ts +5 -35
- package/src/lifecycle/thread-shared.ts +3 -39
- package/src/presentation/monitor.ts +7 -28
- package/src/presentation/widget.ts +1 -1
- package/src/workflow/engine.ts +1 -1
- package/src/workflow/tool.ts +4 -6
|
@@ -54,28 +54,11 @@ async function canonicalManagedRepositoryRoot(cwd: string): Promise<string> {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
/**
|
|
58
|
-
*
|
|
59
|
-
* Shared write-capable generations use the abortable overload for their whole
|
|
60
|
-
* run. Isolated generations use the non-abortable overload only for their
|
|
61
|
-
* final worktree apply, so model work remains parallel while the original
|
|
62
|
-
* checkout mutation cannot race a shared writer.
|
|
63
|
-
*/
|
|
57
|
+
/** Serialize only worktree integration into the original checkout. */
|
|
64
58
|
export async function runInManagedRepositoryLane<T>(
|
|
65
59
|
cwd: string,
|
|
66
60
|
task: () => Promise<T>,
|
|
67
|
-
): Promise<T
|
|
68
|
-
export async function runInManagedRepositoryLane<T>(
|
|
69
|
-
cwd: string,
|
|
70
|
-
task: () => Promise<T>,
|
|
71
|
-
signal: AbortSignal,
|
|
72
|
-
): Promise<T | undefined>;
|
|
73
|
-
export async function runInManagedRepositoryLane<T>(
|
|
74
|
-
cwd: string,
|
|
75
|
-
task: () => Promise<T>,
|
|
76
|
-
signal?: AbortSignal,
|
|
77
|
-
): Promise<T | undefined> {
|
|
78
|
-
if (signal?.aborted) return undefined;
|
|
61
|
+
): Promise<T> {
|
|
79
62
|
const root = await canonicalManagedRepositoryRoot(cwd);
|
|
80
63
|
const key = process.platform === "win32" ? root.toLowerCase() : root;
|
|
81
64
|
const previous = managedRepositoryRootTails.get(key) ?? Promise.resolve();
|
|
@@ -85,30 +68,11 @@ export async function runInManagedRepositoryLane<T>(
|
|
|
85
68
|
});
|
|
86
69
|
const tail = previous.catch(() => undefined).then(() => gate);
|
|
87
70
|
managedRepositoryRootTails.set(key, tail);
|
|
88
|
-
let onAbort: (() => void) | undefined;
|
|
89
71
|
try {
|
|
90
|
-
|
|
91
|
-
await Promise.race([
|
|
92
|
-
previous.catch(() => undefined),
|
|
93
|
-
new Promise<void>((resolveAborted) => {
|
|
94
|
-
if (signal.aborted) resolveAborted();
|
|
95
|
-
else {
|
|
96
|
-
onAbort = resolveAborted;
|
|
97
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
98
|
-
}
|
|
99
|
-
}),
|
|
100
|
-
]);
|
|
101
|
-
} else {
|
|
102
|
-
await previous.catch(() => undefined);
|
|
103
|
-
}
|
|
104
|
-
if (signal?.aborted) return undefined;
|
|
72
|
+
await previous.catch(() => undefined);
|
|
105
73
|
return await task();
|
|
106
74
|
} finally {
|
|
107
|
-
if (signal && onAbort) signal.removeEventListener("abort", onAbort);
|
|
108
75
|
release();
|
|
109
|
-
// An aborted waiter may finish before the prior owner. Keep its chained
|
|
110
|
-
// tail installed until that owner also settles, otherwise a newcomer could
|
|
111
|
-
// observe an empty map and race the still-running workflow.
|
|
112
76
|
void tail.then(() => {
|
|
113
77
|
if (managedRepositoryRootTails.get(key) === tail) managedRepositoryRootTails.delete(key);
|
|
114
78
|
});
|
|
@@ -22,15 +22,8 @@ import type { IsolationMode, WorktreeFinalizationStatus } from "../isolation/wor
|
|
|
22
22
|
|
|
23
23
|
export type RunStatus = "queued" | "running" | "interrupting" | "parked" | "done" | "failed";
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
* slot (real pool pacing), serialized behind the shared-checkout repository
|
|
28
|
-
* write lane (a slot is free — the wait is write serialization), and already
|
|
29
|
-
* starting its child process (a slot is held; output is seconds away).
|
|
30
|
-
* Conflating them taught the parent model that the pool was exhausted when it
|
|
31
|
-
* was not, so it stopped dispatching. Meaningful only while status is
|
|
32
|
-
* "queued"; cleared on every transition out of it. */
|
|
33
|
-
export type RunWaitReason = "process-slot" | "repository-lane" | "starting";
|
|
25
|
+
/** A queued run is preparing its child process; execution has no capacity wait. */
|
|
26
|
+
export type RunWaitReason = "starting";
|
|
34
27
|
|
|
35
28
|
export function isRunActiveStatus(status: RunStatus): boolean {
|
|
36
29
|
return status === "queued" || status === "running" || status === "interrupting";
|
|
@@ -91,9 +84,7 @@ export interface RunChainMeta {
|
|
|
91
84
|
worktreeId?: string;
|
|
92
85
|
/** Set for nodes the workflow runner dispatches. */
|
|
93
86
|
workflow?: RunWorkflowTag;
|
|
94
|
-
/** Initial
|
|
95
|
-
* the process queue). Children spawned outside the queue pass "starting"
|
|
96
|
-
* because they never wait for a slot. */
|
|
87
|
+
/** Initial startup state before the child emits activity. */
|
|
97
88
|
waitReason?: RunWaitReason;
|
|
98
89
|
}
|
|
99
90
|
|
|
@@ -527,7 +518,7 @@ export class MonitorStore {
|
|
|
527
518
|
model,
|
|
528
519
|
thinking,
|
|
529
520
|
status: "queued",
|
|
530
|
-
waitReason: meta?.waitReason ?? "
|
|
521
|
+
waitReason: meta?.waitReason ?? "starting",
|
|
531
522
|
usage: emptyUsage(),
|
|
532
523
|
elapsedMs: 0,
|
|
533
524
|
...(meta?.isolation ? { isolation: meta.isolation, integrationStatus: meta.isolation === "worktree" ? "pending" : undefined, ...(meta.worktreeId ? { worktreeId: meta.worktreeId } : {}) } : {}),
|
|
@@ -741,9 +732,7 @@ export function statusIcon(status: RunStatus, theme: Theme): string {
|
|
|
741
732
|
}
|
|
742
733
|
}
|
|
743
734
|
|
|
744
|
-
/** User-facing
|
|
745
|
-
* so: anything vaguer ("ready") reads like an unexplained cap and made models
|
|
746
|
-
* stop dispatching while slots were merely pacing. */
|
|
735
|
+
/** User-facing lifecycle label used by tool/status rendering. */
|
|
747
736
|
export function statusLabel(status: RunStatus): string {
|
|
748
737
|
switch (status) {
|
|
749
738
|
case "queued":
|
|
@@ -761,17 +750,7 @@ export function statusLabel(status: RunStatus): string {
|
|
|
761
750
|
}
|
|
762
751
|
}
|
|
763
752
|
|
|
764
|
-
/**
|
|
765
|
-
* repository-lane wait or a starting child is never mistaken for an exhausted
|
|
766
|
-
* process pool. Undefined for runs that are not queued. */
|
|
753
|
+
/** Startup label for runs that have not emitted activity yet. */
|
|
767
754
|
export function runWaitLabel(run: Pick<RunView, "status" | "waitReason">): string | undefined {
|
|
768
|
-
|
|
769
|
-
switch (run.waitReason) {
|
|
770
|
-
case "repository-lane":
|
|
771
|
-
return "waiting for the repository write lane";
|
|
772
|
-
case "starting":
|
|
773
|
-
return "starting";
|
|
774
|
-
default:
|
|
775
|
-
return "queued for a free process slot";
|
|
776
|
-
}
|
|
755
|
+
return run.status === "queued" ? "starting" : undefined;
|
|
777
756
|
}
|
|
@@ -13,7 +13,7 @@ const MAX_WIDGET_LINES = 10;
|
|
|
13
13
|
const SEPARATOR = " · ";
|
|
14
14
|
|
|
15
15
|
function waitWord(run: Pick<RunView, "waitReason">): string {
|
|
16
|
-
return run.waitReason === "
|
|
16
|
+
return run.waitReason === "starting" ? "starting" : "queued";
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
function worktreeBadge(run: RunView): string | undefined {
|
package/src/workflow/engine.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The rule this module exists for is "dispatch the next node the moment its
|
|
5
5
|
* prerequisites settle, without waking the parent model". Each node is started
|
|
6
|
-
* through the same dispatcher a `subagent` call uses — same
|
|
6
|
+
* through the same dispatcher a `subagent` call uses — same lifecycle ownership, same
|
|
7
7
|
* admission, same isolation, same durable checkpoint — and is `quiet`, meaning
|
|
8
8
|
* it reports into this graph instead of sending its own completion message.
|
|
9
9
|
* The parent is woken exactly once, with the graph's summary.
|
package/src/workflow/tool.ts
CHANGED
|
@@ -13,7 +13,6 @@ import { Type } from "typebox";
|
|
|
13
13
|
import { isWriteCapableAgent, loadBuiltinAgents } from "../delegation/agents.ts";
|
|
14
14
|
import { defaultIsolationMode, IsolationSchema, PhaseIdSchema, ScopeSchema } from "../delegation/dispatch.ts";
|
|
15
15
|
import { loadConfig } from "../configuration/config.ts";
|
|
16
|
-
import { resolveSubagentConcurrency } from "../execution/background.ts";
|
|
17
16
|
import type { SubagentRuntime } from "../lifecycle/runtime.ts";
|
|
18
17
|
import type { DispatchCore } from "../lifecycle/dispatch-core.ts";
|
|
19
18
|
import { projectResultsRoot } from "../lifecycle/thread-shared.ts";
|
|
@@ -96,7 +95,7 @@ function launchReceipt(status: WorkflowStatusView): string {
|
|
|
96
95
|
return parts.join(" · ");
|
|
97
96
|
}),
|
|
98
97
|
"",
|
|
99
|
-
"The graph dispatches each dependent the moment its prerequisites settle, with no further dispatch from you. One summary arrives when the whole graph settles; continue disjoint work or end your turn, and do not poll.
|
|
98
|
+
"The graph dispatches each dependent the moment its prerequisites settle, with no further dispatch from you. One summary arrives when the whole graph settles; continue disjoint work or end your turn, and do not poll. Ready independent nodes start together without a process-count limit.",
|
|
100
99
|
];
|
|
101
100
|
return lines.join("\n");
|
|
102
101
|
}
|
|
@@ -136,9 +135,9 @@ export function registerWorkflowTool(pi: ExtensionAPI, runtime: SubagentRuntime,
|
|
|
136
135
|
name: "subagent_workflow",
|
|
137
136
|
label: "Subagent Workflow",
|
|
138
137
|
description:
|
|
139
|
-
"Run a dependency graph of sub-agent phases: declare nodes with dependsOn, and the runtime dispatches each dependent as soon as its prerequisites settle
|
|
138
|
+
"Run a dependency graph of sub-agent phases: declare nodes with dependsOn, and the runtime dispatches each dependent as soon as its prerequisites settle. Choose this proactively for two or more substantial phases with known dependencies and writer scopes, when scheduling saves coordination. Use subagent tasks for independent work with no dependency edges; keep small or tightly coupled work in main. If a result must decide the next task or its scope, dispatch that phase alone, decide in main, then reassess whether a graph fits. Never add research, review, or gate nodes by habit. A graph saves dispatch turns; it does not plan or judge success beyond process results. One summary arrives when the graph settles. Nodes are ordinary one-shot runs; main still owns integration, the final gate, and release.",
|
|
140
139
|
exposure: "model-only",
|
|
141
|
-
executionMode: "
|
|
140
|
+
executionMode: "parallel",
|
|
142
141
|
annotations: {
|
|
143
142
|
readOnlyHint: false,
|
|
144
143
|
destructiveHint: true,
|
|
@@ -151,8 +150,7 @@ export function registerWorkflowTool(pi: ExtensionAPI, runtime: SubagentRuntime,
|
|
|
151
150
|
await runtime.durableRestore;
|
|
152
151
|
monitor.beginTurn();
|
|
153
152
|
const config = await loadConfig(runtime.configPath);
|
|
154
|
-
|
|
155
|
-
// Both built-in roles are always available; the live tool metadata decides
|
|
153
|
+
// All built-in roles are always available; the live tool metadata decides
|
|
156
154
|
// which of them is write-capable in this session.
|
|
157
155
|
const agents = loadBuiltinAgents();
|
|
158
156
|
const toolInfos = runtime.getToolInfos();
|