@giladbarnea/pi-simple-team 1.0.3 → 1.0.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/child-tools.ts CHANGED
@@ -63,15 +63,15 @@ export function registerChildTools(pi: ExtensionAPI, config: ChildRuntimeConfig)
63
63
  defineTool({
64
64
  name: "teamsend",
65
65
  label: "Team Send",
66
- description: "Send a message to teammates. To message the main agent, use teammain. Returns once the runtime accepts the send request, not after recipients reply.",
66
+ 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.",
67
67
  promptSnippet: "Send a message to teammate(s)",
68
68
  promptGuidelines: [
69
- "Use teamsend to talk to teammates. It is fire-and-forget: do not wait for a reply unless a teammate later sends one.",
69
+ "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.",
70
70
  ],
71
71
  parameters: Type.Object({
72
72
  to: Type.Array(Type.String(), { description: "Recipient teammate names" }),
73
73
  message: Type.String({ description: "Message to send" }),
74
- interrupt: Type.Optional(Type.Boolean({ description: "Abort busy recipients before delivering this message" })),
74
+ interrupt: Type.Optional(Type.Boolean({ description: "Abort busy recipients before delivering this message." })),
75
75
  }),
76
76
  async execute(_toolCallId, params, signal) {
77
77
  return toolResult(await callParent(config, "teamsend", params, signal));
@@ -79,13 +79,14 @@ export function registerChildTools(pi: ExtensionAPI, config: ChildRuntimeConfig)
79
79
  }),
80
80
  );
81
81
 
82
+ // TODO: should be renamed `sendmain` across the project.
82
83
  pi.registerTool(
83
84
  defineTool({
84
85
  name: "teammain",
85
86
  label: "Team Main",
86
- description: "Send a message to the main agent/team lead. The main agent is never interrupted.",
87
- promptSnippet: "Send a message to the main agent/team lead",
88
- promptGuidelines: ["Use teammain to update or ask the main agent. The main agent may receive it later if busy."],
87
+ description: "Send a message to the main agent.",
88
+ promptSnippet: "Send a message to the main agent.",
89
+ 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."],
89
90
  parameters: Type.Object({
90
91
  message: Type.String({ description: "Message to send to the main agent" }),
91
92
  }),
@@ -101,9 +102,10 @@ export function registerChildTools(pi: ExtensionAPI, config: ChildRuntimeConfig)
101
102
  label: "Team Status",
102
103
  description: "Set your public status and read everyone's public status.",
103
104
  promptSnippet: "Set/read the public team status map",
105
+ // TODO: If this typing system supports it, I want gerund and phrase optionality to be a XOR
104
106
  parameters: Type.Object({
105
- word: Type.Optional(Type.String({ description: "One-word status" })),
106
- phrase: Type.Optional(Type.String({ description: "Short status phrase" })),
107
+ gerund: Type.Optional(Type.String({ description: "One-word gerund status." })),
108
+ phrase: Type.Optional(Type.String({ description: "Short status phrase. Verb-oriented." })),
107
109
  }),
108
110
  async execute(_toolCallId, params, signal) {
109
111
  return toolResult(await callParent(config, "teamstatus", params, signal));
package/index.ts CHANGED
@@ -357,6 +357,7 @@ function logStatusDeclaration(team: TeamState, participant: string, word?: strin
357
357
  });
358
358
  }
359
359
 
360
+ // TODO: participants is unused. Smell.
360
361
  function startTeammate(team: TeamState, teammateSpec: TeammateSpec, participants: string[]): TeammateState {
361
362
  const teammateName = compactName(teammateSpec.name);
362
363
  const thinking = teammateSpec.thinking ?? defaultThinkingLevel;
@@ -529,10 +530,10 @@ async function handleCallbackRequest(request: http.IncomingMessage, response: ht
529
530
  }
530
531
 
531
532
  if (tool === "teamstatus") {
532
- const word = args.word as string | undefined;
533
+ const gerund = args.gerund as string | undefined;
533
534
  const phrase = args.phrase as string | undefined;
534
- updateStatus(team, from, word, phrase);
535
- logStatusDeclaration(team, from, word, phrase);
535
+ updateStatus(team, from, gerund, phrase);
536
+ logStatusDeclaration(team, from, gerund, phrase);
536
537
  writeJson(response, 200, { team: team.name, status: formatStatus(team) });
537
538
  return;
538
539
  }
@@ -567,12 +568,13 @@ export default function (pi: ExtensionAPI) {
567
568
  closeCallbackServerIfUnused();
568
569
  });
569
570
 
571
+ // TODO: Should also "start" the entire team automatically, making `teammate_start` redundant. Solves the respective smell.
570
572
  pi.registerTool(
571
573
  defineTool({
572
574
  name: "team_spawn",
573
575
  label: "Team Spawn",
574
- description: "Spawn a persistent team of RPC Pi teammates with fresh context windows. The main agent is included automatically; do not specify it as a teammate.",
575
- promptSnippet: "Spawn persistent RPC Pi teammate processes",
576
+ description: "Spawn a persistent team of RPC Pi teammates with fresh context windows. The main agent (you) is included automatically; do not specify it as a teammate.",
577
+ promptSnippet: "Spawn persistent RPC Pi teammate processes. Currently, manually ‘starting’ the teammates is required after spawn. 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 a message updating important milestones or request 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.",
576
578
  renderShell: "self",
577
579
  renderCall: (args, theme, context) => renderTeamToolCall("team_spawn", args, theme, context),
578
580
  renderResult: (result, options, theme, context) => renderTeamToolResult("team_spawn", result, options, theme, context),
@@ -633,7 +635,7 @@ export default function (pi: ExtensionAPI) {
633
635
  defineTool({
634
636
  name: "teamsend",
635
637
  label: "Team Send",
636
- description: "Send a message from main to teammate(s). Fire-and-forget; does not wait for replies.",
638
+ description: "Send a message from main to teammate(s). Fire-and-forget; does not wait for replies. Teammates will send you messages as they deem appropriate by way of push.",
637
639
  promptSnippet: "Send a message from main to teammate(s)",
638
640
  renderShell: "self",
639
641
  renderCall: (args, theme, context) => renderTeamToolCall("teamsend", args, theme, context),
@@ -665,21 +667,23 @@ export default function (pi: ExtensionAPI) {
665
667
  renderResult: (result, options, theme, context) => renderTeamToolResult("teamstatus", result, options, theme, context),
666
668
  parameters: Type.Object({
667
669
  team: Type.Optional(Type.String({ description: "Team name; optional for listing all statuses or when exactly one team exists" })),
668
- word: Type.Optional(Type.String({ description: "One-word main status" })),
669
- phrase: Type.Optional(Type.String({ description: "Short main status phrase" })),
670
+ // TODO: make gerund and phrase optionality a XOR.
671
+ gerund: Type.Optional(Type.String({ description: "Set one-word gerund main status" })),
672
+ phrase: Type.Optional(Type.String({ description: "Short main status verb-oriented phrase." })),
670
673
  }),
671
674
  async execute(_toolCallId, params) {
672
- if (!params.team && params.word === undefined && params.phrase === undefined) {
675
+ if (!params.team && params.gerund === undefined && params.phrase === undefined) {
673
676
  return toolResult({ teams: allStatuses(owner) });
674
677
  }
675
678
  const team = resolveTeam(owner, params.team);
676
- updateStatus(team, "main", params.word, params.phrase);
677
- logStatusDeclaration(team, "main", params.word, params.phrase);
679
+ updateStatus(team, "main", params.gerund, params.phrase);
680
+ logStatusDeclaration(team, "main", params.gerund, params.phrase);
678
681
  return toolResult({ team: team.name, status: formatStatus(team) });
679
682
  },
680
683
  }),
681
684
  );
682
685
 
686
+ // TODO: main could use more automatic meta/discoverability information in the return payload. To help orient around what has been read already, what hasn't been read, inside and outside the filtered space, how long is the log, etc.
683
687
  pi.registerTool(
684
688
  defineTool({
685
689
  name: "teamlog",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giladbarnea/pi-simple-team",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "A flat, live team of Pi agents.",
5
5
  "keywords": [
6
6
  "pi-package",
package/render.ts CHANGED
@@ -64,6 +64,10 @@ function wrapTeamLine(line: TeamLine, width: number): string[] {
64
64
  return parts.map((part) => `${line.prefix}${part}`.trimEnd());
65
65
  }
66
66
 
67
+ function clipToWidth(line: string, width: number): string {
68
+ return truncateToWidth(line, Math.max(1, width), glyphs().ellipsis);
69
+ }
70
+
67
71
  /** Clips each logical line to the render width (collapsed) or wraps it (expanded). */
68
72
  export class TeamLines {
69
73
  private cachedWidth?: number;
@@ -84,7 +88,7 @@ export class TeamLines {
84
88
  const targetWidth = Math.max(1, stableRenderWidth(width));
85
89
  this.cachedLines =
86
90
  this.mode === "clip"
87
- ? this.lines.map((line) => truncateToWidth(teamLineText(line), targetWidth, glyphs().ellipsis))
91
+ ? this.lines.map((line) => clipToWidth(teamLineText(line), targetWidth))
88
92
  : this.lines.flatMap((line) => wrapTeamLine(line, targetWidth));
89
93
  this.cachedWidth = width;
90
94
  return this.cachedLines;
@@ -545,17 +549,18 @@ class TeamSendView {
545
549
  }
546
550
 
547
551
  render(width: number): string[] {
552
+ const header = clipToWidth(this.headerStr, width);
548
553
  const bodyWidth = Math.max(10, width - this.barWidth);
549
554
  const bodyLines = this.md.render(bodyWidth);
550
555
  const barred = bodyLines.map((line) => `${this.barStr}${line}`);
551
- if (this.expanded) return [this.headerStr, ...barred];
556
+ if (this.expanded) return [header, ...barred];
552
557
  const shown = barred.slice(0, SEND_PREVIEW_LINES);
553
558
  const hidden = barred.length - SEND_PREVIEW_LINES;
554
559
  if (hidden > 0) {
555
560
  const g = glyphs();
556
561
  shown.push(`${this.barStr}${this.theme.fg("dim", `${g.ellipsis} ${hidden} more line${hidden === 1 ? "" : "s"}${g.dot}ctrl+o to expand`)}`);
557
562
  }
558
- return [this.headerStr, ...shown];
563
+ return [header, ...shown];
559
564
  }
560
565
  }
561
566
 
@@ -579,7 +584,7 @@ class TeamMessageView {
579
584
  render(width: number): string[] {
580
585
  const bodyWidth = Math.max(10, width - this.barWidth);
581
586
  const bodyLines = this.md.render(bodyWidth);
582
- return [this.headerLine, ...bodyLines.map((line) => `${this.barStr}${line}`)];
587
+ return [clipToWidth(this.headerLine, width), ...bodyLines.map((line) => `${this.barStr}${line}`)];
583
588
  }
584
589
  }
585
590