@maheidem/pi-delegate 0.7.1 → 0.7.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/ask.ts CHANGED
@@ -116,6 +116,14 @@ export function registerAskParentTool(pi: ExtensionAPI, env: AskEnv): void {
116
116
  "Ask the delegating parent agent a question (you block until it answers or the budget expires) or file a non-blocking note. " +
117
117
  "Ask only when you are genuinely blocked or a wrong guess is expensive; for cheap decisions proceed with a stated assumption instead. " +
118
118
  "Prefer notes for risks and observations — they never stall your run.",
119
+ // Pi >= 1.0 lists an extension tool in the system prompt's <tools> section
120
+ // only when it has a promptSnippet. Without one, small models read that
121
+ // list, say "I don't have an ask_parent tool" and never call it, even
122
+ // though the tool is declared to the provider.
123
+ promptSnippet: "Ask the delegating parent agent a question (blocks until it answers) or file a non-blocking note",
124
+ promptGuidelines: [
125
+ "ask_parent is a real tool in this session. When the user or task tells you to ask the parent, call ask_parent; do not say it is unavailable.",
126
+ ],
119
127
  parameters: AskParentParams,
120
128
  async execute(toolCallId: string, params): Promise<AskToolResult> {
121
129
  const validation = validateAskSubmission(params);
package/commands.ts CHANGED
@@ -25,6 +25,8 @@ export type DelegateIntent =
25
25
  | { kind: "resume"; runId?: string; task: string; timeoutMs?: number; execution?: "background" | "foreground" }
26
26
  | { kind: "peek"; runId?: string }
27
27
  | { kind: "run"; role: RoleName; task: string; explicit: boolean; timeoutMs?: number; execution?: "background" | "foreground" }
28
+ | { kind: "set"; field: string; value: string }
29
+ | { kind: "set-project"; field: string; value: string }
28
30
  | { kind: "invalid"; token: string; usage: string };
29
31
 
30
32
  export const DELEGATE_USAGE = [
@@ -39,6 +41,8 @@ export const DELEGATE_USAGE = [
39
41
  "/delegate peek [run-id] live/final feed of a run's child activity",
40
42
  "/delegate inspect [run-id] show run metadata (defaults to latest)",
41
43
  "/delegate run <general|research> <task...> run with an explicit role",
44
+ "/delegate set <field> <value> set a user-wide config knob (e.g. set queueLimit 4)",
45
+ "/delegate set-project <field> <value> set a knob in the project .pi/delegate/config.json overlay",
42
46
  "/delegate fg [general|research] <task...> run in the FOREGROUND (blocks until done)",
43
47
  "/delegate research <task...> research-role shorthand",
44
48
  "/delegate <task...> general-role shorthand",
@@ -63,6 +67,8 @@ export const RESERVED_FIRST_TOKENS = new Set([
63
67
  "peek",
64
68
  "run",
65
69
  "research",
70
+ "set",
71
+ "set-project",
66
72
  ]);
67
73
 
68
74
  export interface ParseOptions {
@@ -180,6 +186,24 @@ export function parseDelegateCommand(input: string, options: ParseOptions = {}):
180
186
  if (!task) return invalid("research");
181
187
  return { kind: "run", role: "research", task, explicit: true, timeoutMs, ...(execution ? { execution } : {}) };
182
188
  }
189
+ case "set": {
190
+ // Panel≡command parity: the advanced-config input rows dispatch
191
+ // through patchConfig — `set` is their command twin. Field validation
192
+ // is a runtime concern (the app method owns it), not grammar.
193
+ const rest = trimmed.slice("set".length).trim();
194
+ const field = rest.split(/\s+/)[0] ?? "";
195
+ const value = rest.slice(field.length).trim();
196
+ if (!field || !value) return { kind: "invalid", token: "set", usage: "/delegate set <field> <value>" };
197
+ return { kind: "set", field, value };
198
+ }
199
+ case "set-project": {
200
+ // Same shape as `set`, but targets the project overlay file.
201
+ const rest = trimmed.slice("set-project".length).trim();
202
+ const field = rest.split(/\s+/)[0] ?? "";
203
+ const value = rest.slice(field.length).trim();
204
+ if (!field || !value) return { kind: "invalid", token: "set-project", usage: "/delegate set-project <field> <value>" };
205
+ return { kind: "set-project", field, value };
206
+ }
183
207
  }
184
208
  return invalid(first);
185
209
  }
@@ -192,7 +216,7 @@ function invalid(token: string): DelegateIntent {
192
216
  export function delegateCompletions(prefix: string, recentRunIds: string[] = []): string[] {
193
217
  const words = (prefix ?? "").trimStart();
194
218
  const tokens = words.split(/\s+/);
195
- const base: string[] = ["on", "off", "status", "paths", "doctor", "help", "cancel ", "answer ", "bg ", "fg ", "inspect ", "resume ", "peek ", "run ", "research "];
219
+ const base: string[] = ["on", "off", "status", "paths", "doctor", "help", "cancel ", "answer ", "bg ", "fg ", "inspect ", "resume ", "peek ", "run ", "research ", "set ", "set-project "];
196
220
 
197
221
  const matches: string[] = [];
198
222
  if (tokens.length <= 1) {
@@ -213,7 +237,7 @@ export function delegateCompletions(prefix: string, recentRunIds: string[] = [])
213
237
  }
214
238
  }
215
239
  // De-duplicate, keep order, cap for the TUI (all primary verbs fit).
216
- return [...new Set(matches)].slice(0, 15);
240
+ return [...new Set(matches)].slice(0, 17);
217
241
  }
218
242
 
219
243
  /**
package/index.ts CHANGED
@@ -150,6 +150,13 @@ function registerChildHandoffTool(pi: ExtensionAPI): void {
150
150
  "MANDATORY final report for this delegated run. Your run does not complete until this tool " +
151
151
  "has been called with a valid submission; free-text endings are rejected and you will be re-prompted. " +
152
152
  "When terminated mid-work, call it immediately with outcome=partial.",
153
+ // Pi >= 1.0 lists an extension tool in the system prompt's <tools> section
154
+ // only when it has a promptSnippet. Without one, small models read that
155
+ // list, say "I don't have a handoff tool" and end with free text instead.
156
+ promptSnippet: "Submit the mandatory structured final report for this delegated run",
157
+ promptGuidelines: [
158
+ "handoff is a real tool in this session. End the run by calling handoff; do not end with free text or say the tool is unavailable.",
159
+ ],
153
160
  parameters: HandoffToolParams,
154
161
  async execute(_toolCallId, params): Promise<{
155
162
  content: Array<{ type: "text"; text: string }>;
@@ -1117,6 +1124,8 @@ export default function delegateExtension(pi: ExtensionAPI) {
1117
1124
  "/delegate status stable status text",
1118
1125
  "/delegate run general <task> run a delegation with a role",
1119
1126
  "/delegate research <task> research role",
1127
+ "/delegate set <field> <value> set a user-wide config knob (e.g. set queueLimit 4)",
1128
+ "/delegate set-project <field> <value> set a knob in the project .pi/delegate/config.json overlay",
1120
1129
  "/delegate bg [role] <task> run it in the background (report arrives later)",
1121
1130
  "/delegate fg [role] <task> run it in the foreground (blocks until done)",
1122
1131
  "/delegate <task> general-role shorthand",
@@ -1136,7 +1145,10 @@ export default function delegateExtension(pi: ExtensionAPI) {
1136
1145
 
1137
1146
  const doctorText = (): string => {
1138
1147
  const report = app.doctor();
1139
- const lines = [`[delegate doctor] ${report.ok ? "OK" : "ISSUES FOUND"}`];
1148
+ const lines = [
1149
+ `[delegate doctor] ${report.ok ? "OK" : "ISSUES FOUND"}`,
1150
+ `version: v${delegateVersion()} (loaded at session start; /reload picks up newer installs)`,
1151
+ ];
1140
1152
  for (const c of report.checks) lines.push(` ${c.status === "ok" ? "✓" : c.status === "warning" ? "!" : "✗"} ${c.name}: ${c.detail}`);
1141
1153
  return lines.join("\n");
1142
1154
  };
@@ -1273,6 +1285,19 @@ export default function delegateExtension(pi: ExtensionAPI) {
1273
1285
  }
1274
1286
  return;
1275
1287
  }
1288
+ case "set": {
1289
+ // Panel≡command parity: same app method as the advanced-config
1290
+ // input rows (cfg:user:*). patchConfig owns field validation.
1291
+ const err = app.patchConfig(intent.field, intent.value);
1292
+ say(ctx, err ? `[delegate] ${err}` : `[delegate] set ${intent.field} = ${intent.value} (user config)`, err ? "warning" : "info");
1293
+ return;
1294
+ }
1295
+ case "set-project": {
1296
+ // Same method as the cfg:project:* input rows.
1297
+ const err = app.patchProjectConfig(ctx.cwd ?? process.cwd(), intent.field, intent.value);
1298
+ say(ctx, err ? `[delegate] ${err}` : `[delegate] set ${intent.field} = ${intent.value} (project config)`, err ? "warning" : "info");
1299
+ return;
1300
+ }
1276
1301
  case "invalid":
1277
1302
  say(ctx, `[delegate] unrecognized '${intent.token}'.\n${intent.usage}\n${helpText()}`, "error");
1278
1303
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maheidem/pi-delegate",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "description": "Foreground isolated delegation and strict coordinator mode for the Pi coding agent.",
6
6
  "license": "MIT",
@@ -70,4 +70,4 @@
70
70
  "./index.ts"
71
71
  ]
72
72
  }
73
- }
73
+ }