@linxiraos/pi-messenger 1.3.1 → 1.3.2
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 +4 -0
- package/crew/team/store.ts +6 -0
- package/crew/team/subagent-roles.ts +1 -0
- package/crew/team/types.ts +2 -0
- package/package.json +1 -1
- package/teamagent-command.ts +45 -9
package/CHANGELOG.md
CHANGED
package/crew/team/store.ts
CHANGED
|
@@ -216,6 +216,9 @@ function normalizeProfile(raw: unknown, filePath: string, expectedName?: string)
|
|
|
216
216
|
if (value.skills !== undefined && !Array.isArray(value.skills)) {
|
|
217
217
|
throw new Error(`Invalid Team profile JSON at ${filePath}: role ${name}.skills must be an array`);
|
|
218
218
|
}
|
|
219
|
+
if (value.tools !== undefined && !Array.isArray(value.tools)) {
|
|
220
|
+
throw new Error(`Invalid Team profile JSON at ${filePath}: role ${name}.tools must be an array`);
|
|
221
|
+
}
|
|
219
222
|
roles[roleName] = {
|
|
220
223
|
...(typeof value.description === "string" ? { description: value.description } : {}),
|
|
221
224
|
...(typeof value.model === "string" ? { model: value.model } : {}),
|
|
@@ -223,6 +226,9 @@ function normalizeProfile(raw: unknown, filePath: string, expectedName?: string)
|
|
|
223
226
|
...(Array.isArray(value.skills)
|
|
224
227
|
? { skills: value.skills.filter((skill): skill is string => typeof skill === "string") }
|
|
225
228
|
: {}),
|
|
229
|
+
...(Array.isArray(value.tools)
|
|
230
|
+
? { tools: value.tools.filter((tool): tool is string => typeof tool === "string") }
|
|
231
|
+
: {}),
|
|
226
232
|
...(typeof value.prompt === "string" ? { prompt: value.prompt } : {}),
|
|
227
233
|
...(typeof value.promptSource === "string" ? { promptSource: value.promptSource } : {}),
|
|
228
234
|
};
|
|
@@ -72,6 +72,7 @@ function readRoleFile(filePath: string, sourceLabel: string): TeamRoleDefinition
|
|
|
72
72
|
...(data.model ? { model: data.model } : {}),
|
|
73
73
|
...(data.thinking ? { thinking: data.thinking } : {}),
|
|
74
74
|
...((data.skills ?? data.autoloadSkills) ? { skills: splitList(data.skills ?? data.autoloadSkills) } : {}),
|
|
75
|
+
...(data.tools ? { tools: splitList(data.tools) } : {}),
|
|
75
76
|
...(body ? { prompt: body.slice(0, 4000) } : {}),
|
|
76
77
|
promptSource: `${sourceLabel}:${name}`,
|
|
77
78
|
};
|
package/crew/team/types.ts
CHANGED
package/package.json
CHANGED
package/teamagent-command.ts
CHANGED
|
@@ -21,12 +21,22 @@ import * as path from "node:path";
|
|
|
21
21
|
import type { ExtensionAPI, ExtensionCommandContext } from "@linxiraos/zeta";
|
|
22
22
|
import { getAgentDir } from "@linxiraos/pi-utils/dirs";
|
|
23
23
|
import * as teamStore from "./crew/team/store.ts";
|
|
24
|
+
import { isNonEditingTeamRole } from "./crew/utils/team-roles.ts";
|
|
24
25
|
import { isProjectAgentsTrusted } from "./config.ts";
|
|
25
26
|
import { getProjectConfigPath } from "./paths.ts";
|
|
26
27
|
|
|
27
28
|
/** Reserved names the agent parser rejects; mirrored so we fail early. */
|
|
28
29
|
const RESERVED_NAMES = new Set(["main", "sub"]);
|
|
29
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Minimal tool allowlist for roles that inspect without editing. Mirrors the
|
|
33
|
+
* task plan-mode allowlist (`PLAN_MODE_TOOLS` in
|
|
34
|
+
* packages/coding-agent/src/task/structured-subagent.ts); it stays local
|
|
35
|
+
* because this plugin ships standalone and must not require a newer
|
|
36
|
+
* coding-agent build. An explicit role.tools value still wins.
|
|
37
|
+
*/
|
|
38
|
+
export const NON_EDITING_ROLE_TOOLS = ["read", "grep", "glob", "web_search"] as const;
|
|
39
|
+
|
|
30
40
|
const NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
31
41
|
|
|
32
42
|
export interface TeamAgentScope {
|
|
@@ -65,12 +75,14 @@ export function renderAgentMarkdown(role: {
|
|
|
65
75
|
model?: string;
|
|
66
76
|
thinking?: string;
|
|
67
77
|
skills?: string[];
|
|
78
|
+
tools?: string[];
|
|
68
79
|
prompt?: string;
|
|
69
80
|
}): string {
|
|
70
81
|
const lines: string[] = ["---", `name: ${yamlString(role.name)}`, `description: ${yamlString(role.description)}`];
|
|
71
82
|
if (role.model) lines.push(`model: ${yamlString(role.model)}`);
|
|
72
83
|
if (role.thinking) lines.push(`thinking: ${yamlString(role.thinking)}`);
|
|
73
84
|
if (role.skills && role.skills.length > 0) lines.push(`autoloadSkills: ${yamlString(role.skills)}`);
|
|
85
|
+
if (role.tools && role.tools.length > 0) lines.push(`tools: ${yamlString(role.tools)}`);
|
|
74
86
|
lines.push("---", "");
|
|
75
87
|
lines.push(role.prompt?.trim() || `You are the ${role.name} role. ${role.description}`);
|
|
76
88
|
return `${lines.join("\n")}\n`;
|
|
@@ -84,7 +96,15 @@ export interface AddResult {
|
|
|
84
96
|
|
|
85
97
|
/** Write one role as an agent file. Refuses reserved/invalid names up front. */
|
|
86
98
|
export function addTeamAgent(
|
|
87
|
-
role: {
|
|
99
|
+
role: {
|
|
100
|
+
name: string;
|
|
101
|
+
description: string;
|
|
102
|
+
model?: string;
|
|
103
|
+
thinking?: string;
|
|
104
|
+
skills?: string[];
|
|
105
|
+
tools?: string[];
|
|
106
|
+
prompt?: string;
|
|
107
|
+
},
|
|
88
108
|
scope: "project" | "user",
|
|
89
109
|
cwd: string,
|
|
90
110
|
): AddResult {
|
|
@@ -103,8 +123,15 @@ export function addTeamAgent(
|
|
|
103
123
|
if (fs.existsSync(filePath)) {
|
|
104
124
|
return { ok: false, message: `${name} already exists at ${filePath}. Remove it first to replace it.` };
|
|
105
125
|
}
|
|
126
|
+
// Non-editing crew roles are read-only by contract; without an allowlist the
|
|
127
|
+
// spawned agent would inherit every tool. An explicit role.tools wins.
|
|
128
|
+
const tools = role.tools?.length
|
|
129
|
+
? role.tools
|
|
130
|
+
: isNonEditingTeamRole(name)
|
|
131
|
+
? [...NON_EDITING_ROLE_TOOLS]
|
|
132
|
+
: undefined;
|
|
106
133
|
fs.mkdirSync(dir, { recursive: true });
|
|
107
|
-
fs.writeFileSync(filePath, renderAgentMarkdown({ ...role, name }), "utf8");
|
|
134
|
+
fs.writeFileSync(filePath, renderAgentMarkdown({ ...role, name, tools }), "utf8");
|
|
108
135
|
return { ok: true, message: `Registered ${name} (${scope} scope)`, filePath };
|
|
109
136
|
}
|
|
110
137
|
|
|
@@ -216,17 +243,23 @@ export function registerTeamAgentCommand(pi: ExtensionAPI): void {
|
|
|
216
243
|
" /teamagent profile.list team profiles",
|
|
217
244
|
" /teamagent charter.show print the charter",
|
|
218
245
|
" /teamagent agents list registered subagents",
|
|
219
|
-
" /teamagent add <role> [--user] register a crew role as a spawnable subagent",
|
|
220
|
-
" /teamagent remove <name> [--user]",
|
|
246
|
+
" /teamagent add <role> [--project|--user] register a crew role as a spawnable subagent",
|
|
247
|
+
" /teamagent remove <name> [--project|--user]",
|
|
221
248
|
"",
|
|
222
|
-
"
|
|
223
|
-
" <cwd>/.zeta/pi-messenger.json); --
|
|
249
|
+
"Scope defaults to the project (<cwd>/.zeta/agents, requires \"trustProjectAgents\": true",
|
|
250
|
+
" in <cwd>/.zeta/pi-messenger.json); --project names that default explicitly and",
|
|
251
|
+
" --user writes ~/.zeta/agent/agents. --user and --project cannot be combined.",
|
|
224
252
|
].join("\n"),
|
|
225
253
|
);
|
|
226
254
|
return;
|
|
227
255
|
}
|
|
228
256
|
|
|
229
257
|
const userScope = rest.includes("--user");
|
|
258
|
+
const projectScope = rest.includes("--project");
|
|
259
|
+
if (userScope && projectScope) {
|
|
260
|
+
reply("Cannot combine --user and --project: choose one scope. Omitting both uses the project scope.");
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
230
263
|
const positional = rest.filter(a => a !== "--user" && a !== "--project");
|
|
231
264
|
const scope = userScope ? "user" : "project";
|
|
232
265
|
|
|
@@ -260,7 +293,7 @@ export function registerTeamAgentCommand(pi: ExtensionAPI): void {
|
|
|
260
293
|
if (verb === "add") {
|
|
261
294
|
const roleName = positional[0];
|
|
262
295
|
if (!roleName) {
|
|
263
|
-
reply("Usage: /teamagent add <role> [--user]");
|
|
296
|
+
reply("Usage: /teamagent add <role> [--project|--user]");
|
|
264
297
|
return;
|
|
265
298
|
}
|
|
266
299
|
if (scope === "project" && !isProjectAgentsTrusted(ctx.cwd)) {
|
|
@@ -289,6 +322,7 @@ export function registerTeamAgentCommand(pi: ExtensionAPI): void {
|
|
|
289
322
|
model: role.model,
|
|
290
323
|
thinking: role.thinking,
|
|
291
324
|
skills: role.skills,
|
|
325
|
+
tools: role.tools,
|
|
292
326
|
},
|
|
293
327
|
scope,
|
|
294
328
|
ctx.cwd,
|
|
@@ -307,7 +341,7 @@ export function registerTeamAgentCommand(pi: ExtensionAPI): void {
|
|
|
307
341
|
if (verb === "remove") {
|
|
308
342
|
const name = positional[0];
|
|
309
343
|
if (!name) {
|
|
310
|
-
reply("Usage: /teamagent remove <name> [--user]");
|
|
344
|
+
reply("Usage: /teamagent remove <name> [--project|--user]");
|
|
311
345
|
return;
|
|
312
346
|
}
|
|
313
347
|
const result = removeTeamAgent(name, scope, ctx.cwd);
|
|
@@ -315,7 +349,9 @@ export function registerTeamAgentCommand(pi: ExtensionAPI): void {
|
|
|
315
349
|
return;
|
|
316
350
|
}
|
|
317
351
|
|
|
318
|
-
reply(
|
|
352
|
+
reply(
|
|
353
|
+
`Unknown subcommand "${verb}". Use roles, status, profile.list, charter.show, agents, add or remove.`,
|
|
354
|
+
);
|
|
319
355
|
},
|
|
320
356
|
});
|
|
321
357
|
}
|