@giladbarnea/pi-simple-team 1.0.18 → 1.0.20
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 +1 -1
- package/child-tools.ts +0 -8
- package/index.ts +27 -4
- package/package.json +1 -1
- package/system-prompt.ts +3 -0
package/README.md
CHANGED
|
@@ -137,7 +137,7 @@ Teammates publish a one-liner:
|
|
|
137
137
|
|
|
138
138
|
> <span style="color:grey">implementer </span> Done, 89 tests green, awaiting review.
|
|
139
139
|
|
|
140
|
-
> <span style="color:grey">reviewer </span> Reading implementation, will finalize review in a few minutes
|
|
140
|
+
> <span style="color:grey">reviewer </span> Reading implementation, will finalize review in a few minutes.
|
|
141
141
|
|
|
142
142
|
Your main agent calls `teamstatus` and understands exactly what's going on. Main doesn't ask and clutter the teammates' context.
|
|
143
143
|
|
package/child-tools.ts
CHANGED
|
@@ -255,7 +255,6 @@ export function registerChildTools(pi: ExtensionAPI, config: ChildRuntimeConfig)
|
|
|
255
255
|
name: "report_context_window",
|
|
256
256
|
label: "Report Context Window",
|
|
257
257
|
description: "Report your current context-window use.",
|
|
258
|
-
promptSnippet: "Report your current context-window use",
|
|
259
258
|
parameters: Type.Object({}),
|
|
260
259
|
async execute(_toolCallId, _params, _signal, _onUpdate, context) {
|
|
261
260
|
const text = formatContextWindowReport("You have", requireKnownContextUsage(context.getContextUsage()));
|
|
@@ -269,10 +268,6 @@ export function registerChildTools(pi: ExtensionAPI, config: ChildRuntimeConfig)
|
|
|
269
268
|
name: "teamsend",
|
|
270
269
|
label: "Team Send",
|
|
271
270
|
description: "Send a message to teammate(s) (not main). To message the main agent, use teammain. Returns once the runtime accepts the send request, not after recipients reply.",
|
|
272
|
-
promptSnippet: "Send a message to teammate(s)",
|
|
273
|
-
promptGuidelines: [
|
|
274
|
-
"Use teamsend to talk to teammates. From your POV (sender), it is fire-and-forget. From the recipient’s POV, it’s pushed to context as soon as possible.",
|
|
275
|
-
],
|
|
276
271
|
parameters: Type.Object({
|
|
277
272
|
to: Type.Array(Type.String(), { description: "Recipient teammate names" }),
|
|
278
273
|
message: Type.String({ description: "Message to send" }),
|
|
@@ -290,8 +285,6 @@ export function registerChildTools(pi: ExtensionAPI, config: ChildRuntimeConfig)
|
|
|
290
285
|
name: "teammain",
|
|
291
286
|
label: "Team Main",
|
|
292
287
|
description: "Send a message to the main agent.",
|
|
293
|
-
promptSnippet: "Send a message to the main agent.",
|
|
294
|
-
promptGuidelines: ["Use teammain to update or ask the main agent. Main agent sees the big picture and has been aware of the team’s actions and status updates since the team was created."],
|
|
295
288
|
parameters: Type.Object({
|
|
296
289
|
message: Type.String({ description: "Message to send to the main agent" }),
|
|
297
290
|
}),
|
|
@@ -306,7 +299,6 @@ export function registerChildTools(pi: ExtensionAPI, config: ChildRuntimeConfig)
|
|
|
306
299
|
name: "teamstatus",
|
|
307
300
|
label: "Team Status",
|
|
308
301
|
description: "Set your public status and read everyone's public status.",
|
|
309
|
-
promptSnippet: "Set/read the public team status map",
|
|
310
302
|
// TODO: If this typing system supports it, I want gerund and phrase optionality to be a XOR
|
|
311
303
|
parameters: Type.Object({
|
|
312
304
|
gerund: Type.Optional(Type.String({ description: "One-word gerund status." })),
|
package/index.ts
CHANGED
|
@@ -45,6 +45,7 @@ interface TeammateSpec {
|
|
|
45
45
|
prompt: string;
|
|
46
46
|
model: string;
|
|
47
47
|
thinking?: ThinkingLevel;
|
|
48
|
+
inheritContext?: boolean;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
type TeammateTransport = "rpc" | "herdr";
|
|
@@ -54,6 +55,7 @@ interface TeammateState {
|
|
|
54
55
|
prompt: string;
|
|
55
56
|
model: string;
|
|
56
57
|
thinking: ThinkingLevel;
|
|
58
|
+
inheritContext: boolean;
|
|
57
59
|
transport: TeammateTransport;
|
|
58
60
|
process?: ChildProcess;
|
|
59
61
|
paneId?: string;
|
|
@@ -75,6 +77,7 @@ interface TeamState {
|
|
|
75
77
|
name: string;
|
|
76
78
|
showOnHerdrPanes: boolean;
|
|
77
79
|
teamPrompt: string;
|
|
80
|
+
mainSessionFile?: string;
|
|
78
81
|
members: Map<string, TeammateState>;
|
|
79
82
|
statuses: Map<string, TeamStatus>;
|
|
80
83
|
created: string;
|
|
@@ -488,6 +491,7 @@ function createTeammateState(team: TeamState, teammateSpec: TeammateSpec): Teamm
|
|
|
488
491
|
prompt: teammateSpec.prompt,
|
|
489
492
|
model: teammateSpec.model,
|
|
490
493
|
thinking,
|
|
494
|
+
inheritContext: Boolean(teammateSpec.inheritContext),
|
|
491
495
|
transport: team.showOnHerdrPanes ? "herdr" : "rpc",
|
|
492
496
|
visibleReady,
|
|
493
497
|
resolveVisibleReady,
|
|
@@ -519,15 +523,17 @@ function appendSpawnLog(team: TeamState, teammate: TeammateState): void {
|
|
|
519
523
|
teammate: teammate.name,
|
|
520
524
|
direction: "runtime",
|
|
521
525
|
kind: "spawn",
|
|
522
|
-
summary: `spawned ${teammate.name} (model=${teammate.model}, thinking=${teammate.thinking})`,
|
|
523
|
-
details: { model: teammate.model, thinking: teammate.thinking, transport: teammate.transport, paneId: teammate.paneId },
|
|
526
|
+
summary: `spawned ${teammate.name} (model=${teammate.model}, thinking=${teammate.thinking}, context=${teammate.inheritContext ? "inherited" : "fresh"})`,
|
|
527
|
+
details: { model: teammate.model, thinking: teammate.thinking, inheritContext: teammate.inheritContext, transport: teammate.transport, paneId: teammate.paneId },
|
|
524
528
|
});
|
|
525
529
|
}
|
|
526
530
|
|
|
527
531
|
function attachRpcTeammate(team: TeamState, teammate: TeammateState, participants: string[]): void {
|
|
532
|
+
const sessionArgs = teammate.inheritContext ? ["--fork", team.mainSessionFile!] : [];
|
|
528
533
|
const args = [
|
|
529
534
|
"--mode",
|
|
530
535
|
"rpc",
|
|
536
|
+
...sessionArgs,
|
|
531
537
|
"-e",
|
|
532
538
|
teamLiteExtensionPath,
|
|
533
539
|
"--no-prompt-templates",
|
|
@@ -583,7 +589,19 @@ async function attachVisibleTeammate(team: TeamState, teammate: TeammateState, p
|
|
|
583
589
|
for (const [name, value] of Object.entries(environment)) {
|
|
584
590
|
if (value !== undefined) args.push("--env", `${name}=${value}`);
|
|
585
591
|
}
|
|
586
|
-
args.push(
|
|
592
|
+
args.push(
|
|
593
|
+
"--",
|
|
594
|
+
"pi",
|
|
595
|
+
...(teammate.inheritContext ? ["--fork", team.mainSessionFile!] : []),
|
|
596
|
+
"-e",
|
|
597
|
+
teamLiteExtensionPath,
|
|
598
|
+
"--model",
|
|
599
|
+
teammate.model,
|
|
600
|
+
"--thinking",
|
|
601
|
+
teammate.thinking,
|
|
602
|
+
"--system-prompt",
|
|
603
|
+
systemPrompt,
|
|
604
|
+
);
|
|
587
605
|
const result = await runCommand("herdr", args);
|
|
588
606
|
teammate.paneId = parseHerdrPaneId(result.stdout, teammate.name);
|
|
589
607
|
appendSpawnLog(team, teammate);
|
|
@@ -804,6 +822,7 @@ function teammateSchema(modelGuidance: string) {
|
|
|
804
822
|
prompt: Type.String({ description: "Individual teammate system prompt" }),
|
|
805
823
|
model: Type.String({ description: `Canonical provider/model id for this teammate. ${modelGuidance}` }),
|
|
806
824
|
thinking: Type.Optional(StringEnum(thinkingLevels, { description: "Thinking level for this teammate. Defaults to xhigh.", default: defaultThinkingLevel })),
|
|
825
|
+
inheritContext: Type.Optional(Type.Boolean({ description: "Start from a fork of main's persisted session. The fork is taken during asynchronous child startup. Defaults to false.", default: false })),
|
|
807
826
|
});
|
|
808
827
|
}
|
|
809
828
|
|
|
@@ -832,7 +851,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
832
851
|
defineTool({
|
|
833
852
|
name: "team_spawn",
|
|
834
853
|
label: "Team Spawn",
|
|
835
|
-
description: `Spawn a persistent team of Pi teammates with fresh context windows. If the user is interested, set \`showOnHerdrPanes\` to run each teammate in a visible Herdr pane. The main agent (you) is included automatically; do not specify it as a teammate. ${modelGuidance}`,
|
|
854
|
+
description: `Spawn a persistent team of Pi teammates. Teammates start with fresh context windows unless \`inheritContext\` is true. If the user is interested, set \`showOnHerdrPanes\` to run each teammate in a visible Herdr pane. The main agent (you) is included automatically; do not specify it as a teammate. ${modelGuidance}`,
|
|
836
855
|
promptSnippet: `Spawn persistent Pi teammates. ${modelGuidance} Unless required, don’t fill up your time by repeatedly busy-polling team information. Don’t bash sleep to wait for progress; instead, set your status to advertise that you are counting on teammates to send you important milestones or requests for help, and that otherwise you are staying idle. Send this actively to the team. Then end your turn by sending a simple message to the user, and finally stay put.`,
|
|
837
856
|
renderShell: "self",
|
|
838
857
|
renderCall: (args, theme, context) => renderTeamToolCall("team_spawn", args, theme, context, sessionTeammateRoster),
|
|
@@ -856,6 +875,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
856
875
|
if (teammateNames.includes("main")) throw new Error('"main" is reserved');
|
|
857
876
|
|
|
858
877
|
validateTeammateModels(teammateSpecs, context.modelRegistry.getAvailable());
|
|
878
|
+
const inheritsMainContext = teammateSpecs.some((teammate) => Boolean(teammate.inheritContext));
|
|
879
|
+
const mainSessionFile = inheritsMainContext ? context.sessionManager.getSessionFile() : undefined;
|
|
880
|
+
if (inheritsMainContext && !mainSessionFile) throw new Error("inheritContext requires a persistent main session");
|
|
859
881
|
sessionTeammateRoster.push(...teammateNames.filter((teammateName) => !sessionTeammateRoster.includes(teammateName)));
|
|
860
882
|
await ensureCallbackServer();
|
|
861
883
|
|
|
@@ -865,6 +887,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
865
887
|
name: teamName,
|
|
866
888
|
showOnHerdrPanes,
|
|
867
889
|
teamPrompt: params.teamPrompt,
|
|
890
|
+
mainSessionFile,
|
|
868
891
|
members: new Map(),
|
|
869
892
|
statuses: new Map([["main", status("available", "Main agent")]]),
|
|
870
893
|
created: nowText(),
|
package/package.json
CHANGED
package/system-prompt.ts
CHANGED
|
@@ -8,9 +8,12 @@ export function composeSystemPrompt(teamName: string, teamPrompt: string, teamma
|
|
|
8
8
|
`You are ${teammateName}, a teammate on team ${teamName}.`,
|
|
9
9
|
`Participants: main, ${participants.join(", ")}.`,
|
|
10
10
|
"Use teamsend to talk to teammates, teammain to talk to the main agent, and teamstatus to set/read public statuses.",
|
|
11
|
+
"From the sender’s point of view, teamsend is fire-and-forget. From the recipient’s point of view, the message is pushed to context as soon as possible.",
|
|
12
|
+
"Main agent sees the big picture and has been aware of the team’s actions and status updates since the team was created.",
|
|
11
13
|
"As soon as you wake up, call teamstatus to acknowledge that you received your instructions before doing substantive work.",
|
|
12
14
|
"Whenever you receive a message from main or a teammate, call teamstatus first to acknowledge that specific message, then proceed.",
|
|
13
15
|
"Never set a waiting status until after you have sent the teammate you are waiting for a teamsend describing exactly what you need from them.",
|
|
16
|
+
"If you are waiting, message the person you are waiting for. Ask them to wake you when the condition is met. Set your status to “waiting for X to wake me when Y is done”, then stay put.",
|
|
14
17
|
"There is no inbox to poll and no done button. Coordinate naturally. If the team is done, one teammate should tell main via teammain.",
|
|
15
18
|
]
|
|
16
19
|
.filter(Boolean)
|