@giladbarnea/pi-simple-team 1.0.42 → 1.0.44

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/index.ts CHANGED
@@ -225,13 +225,22 @@ function enqueueDelivery(team: TeamState, from: string, recipient: TeammateState
225
225
  });
226
226
  }
227
227
 
228
+ /** @example resolveTeamIdentifier([{ id: "main-review", name: "review" }], "review")?.id // "main-review" */
229
+ function resolveTeamIdentifier<IdentifiedTeam extends { id?: string; name: string }>(
230
+ candidates: Iterable<IdentifiedTeam>,
231
+ teamIdentifier: string,
232
+ ): IdentifiedTeam | undefined {
233
+ const matches = [...candidates].filter((team) => team.id === teamIdentifier || team.name === teamIdentifier);
234
+ if (matches.length > 1) throw new Error(`Ambiguous team name: ${teamIdentifier}. Pass the persistent team ID.`);
235
+ return matches[0];
236
+ }
237
+
228
238
  function resolveTeam(owner: symbol, teamIdentifier?: string): TeamState {
229
239
  const ownedTeams = [...teams.values()].filter((team) => team.owner === owner);
230
240
  if (teamIdentifier) {
231
- const matches = ownedTeams.filter((team) => team.id === teamIdentifier || team.name === teamIdentifier);
232
- if (matches.length === 0) throw new Error(`Unknown team: ${teamIdentifier}`);
233
- if (matches.length > 1) throw new Error(`Ambiguous team name: ${teamIdentifier}. Pass the persistent team ID.`);
234
- return matches[0]!;
241
+ const team = resolveTeamIdentifier(ownedTeams, teamIdentifier);
242
+ if (!team) throw new Error(`Unknown team: ${teamIdentifier}`);
243
+ return team;
235
244
  }
236
245
 
237
246
  if (ownedTeams.length === 1) return ownedTeams[0];
@@ -1073,7 +1082,7 @@ export default function (pi: ExtensionAPI) {
1073
1082
  renderCall: (args, theme, context) => renderTeamToolCall("team_resume", args, theme, context, sessionTeammateRoster),
1074
1083
  renderResult: (result, options, theme, context) => renderTeamToolResult("team_resume", result, options, theme, context, undefined, sessionTeammateRoster),
1075
1084
  parameters: Type.Object({
1076
- team: Type.String({ description: "Persistent team ID" }),
1085
+ team: Type.String({ description: "Team name or persistent ID" }),
1077
1086
  teammates: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { minItems: 1, description: "Stopped teammate names. Omit to resume all stopped teammates." })),
1078
1087
  showOnHerdrPanes: Type.Optional(Type.Boolean({ default: false, description: "Resume selected teammates in visible Herdr panes. Defaults to RPC." })),
1079
1088
  }),
@@ -1082,9 +1091,10 @@ export default function (pi: ExtensionAPI) {
1082
1091
  if (!rawProjectDirectory) throw new Error("team_resume requires a project directory");
1083
1092
  const managerSessionId = childRuntimeConfig ? context.sessionManager?.getSessionId?.() : undefined;
1084
1093
  if (childRuntimeConfig && !managerSessionId) throw new Error("team_resume requires a persistent overseeing teammate session");
1085
- const manifest = listTeamManifests(rawProjectDirectory).find(
1086
- (candidate) => candidate.id === params.team && (!managerSessionId || candidate.originMainSessionId === managerSessionId),
1094
+ const availableManifests = listTeamManifests(rawProjectDirectory).filter(
1095
+ (candidate) => !managerSessionId || candidate.originMainSessionId === managerSessionId,
1087
1096
  );
1097
+ const manifest = resolveTeamIdentifier(availableManifests, params.team);
1088
1098
  if (!manifest) throw new Error(`Unknown current-project team: ${params.team}`);
1089
1099
  const requestedNames = params.teammates?.map(compactName) ?? manifest.members.map((member) => member.name);
1090
1100
  const duplicateNames = requestedNames.filter((name, index) => requestedNames.indexOf(name) !== index);
@@ -1183,11 +1193,14 @@ export default function (pi: ExtensionAPI) {
1183
1193
  renderCall: (args, theme, context) => renderTeamToolCall("team_add", args, theme, context, sessionTeammateRoster),
1184
1194
  renderResult: (result, options, theme, context) => renderTeamToolResult("team_add", result, options, theme, context, undefined, sessionTeammateRoster),
1185
1195
  parameters: Type.Object({
1186
- team: Type.String({ description: "Persistent team ID" }),
1196
+ team: Type.String({ description: "Team name or persistent ID" }),
1187
1197
  teammates: Type.Array(teammateSchema(""), { minItems: 1, description: "New teammates to add" }),
1188
1198
  }),
1189
1199
  async execute(_toolCallId, params, _signal, _onUpdate, context) {
1190
- const team = [...teams.values()].find((candidate) => candidate.id === params.team && candidate.owner === owner);
1200
+ const team = resolveTeamIdentifier(
1201
+ [...teams.values()].filter((candidate) => candidate.owner === owner),
1202
+ params.team,
1203
+ );
1191
1204
  if (!team || !team.manifest || !team.lease || team.manifest.state !== "active") {
1192
1205
  throw new Error(`team_add requires a running team owned by this main session: ${params.team}`);
1193
1206
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giladbarnea/pi-simple-team",
3
- "version": "1.0.42",
3
+ "version": "1.0.44",
4
4
  "description": "A flat, live team of Pi agents.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -91,7 +91,7 @@ Besides checking your own context window, check your delegates’ window opportu
91
91
 
92
92
  This section is a communication rulebook to all cases where an AI requests something from another AI: down, sideways and up — main to sub-agent, main to team, teammate to teammate, and delegated to delegator.
93
93
 
94
- The framework behind this section: [`theory-of-mind.md`](~/.agents/plugins/interaction/references/theory-of-mind.md). Read it once if you haven’t already.
94
+ The framework behind this section: [`theory-of-mind.md`](references/theory-of-mind.md). Read it once if you haven’t already.
95
95
 
96
96
  **1. Orient the agent to the project:**
97
97
  1.a. Tell the AI agent to *load the skills and files your leader has referenced* throughout the session. That’s the baseline common ground. Do not repeat the content of those skills and files in your instructions. This why references exist.
@@ -139,7 +139,7 @@ The framework behind this section: [`theory-of-mind.md`](~/.agents/plugins/inter
139
139
 
140
140
  ## Next required reading
141
141
 
142
- The following is a tiny state machine. If you haven’t already, yourself first with [`roles.md`](~/.agents/plugins/interaction/references/roles.md), then read only what applies.
142
+ The following is a tiny state machine. If you haven’t already, yourself first with [`roles.md`](references/roles.md), then read only what applies.
143
143
 
144
144
  If you are choosing a delegation shape, read [`references/subagents-vs-teams.md`](references/subagents-vs-teams.md).
145
145
  If you have teammates of your own, read [`references/peers.md`](references/peers.md).
@@ -5,7 +5,7 @@ description: How to communicate with your leader — whoever gave you your missi
5
5
 
6
6
  # AI → Leader
7
7
 
8
- First, classify yourself with [`roles.md`](~/.agents/plugins/interaction/references/roles.md), and read [`theory-of-mind.md`](~/.agents/plugins/interaction/references/theory-of-mind.md) once. This skill is the upward projection of that theory: re-ground the reader, carry the delta, compress to what they need.
8
+ First, classify yourself with [`roles.md`](references/roles.md), and read [`theory-of-mind.md`](references/theory-of-mind.md) once. This skill is the upward projection of that theory: re-ground the reader, carry the delta, compress to what they need.
9
9
 
10
10
  ## Every report is a cold entry
11
11