@maheidem/pi-delegate 0.7.1 → 0.7.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.
Files changed (3) hide show
  1. package/commands.ts +26 -2
  2. package/index.ts +19 -1
  3. package/package.json +1 -1
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
@@ -1117,6 +1117,8 @@ export default function delegateExtension(pi: ExtensionAPI) {
1117
1117
  "/delegate status stable status text",
1118
1118
  "/delegate run general <task> run a delegation with a role",
1119
1119
  "/delegate research <task> research role",
1120
+ "/delegate set <field> <value> set a user-wide config knob (e.g. set queueLimit 4)",
1121
+ "/delegate set-project <field> <value> set a knob in the project .pi/delegate/config.json overlay",
1120
1122
  "/delegate bg [role] <task> run it in the background (report arrives later)",
1121
1123
  "/delegate fg [role] <task> run it in the foreground (blocks until done)",
1122
1124
  "/delegate <task> general-role shorthand",
@@ -1136,7 +1138,10 @@ export default function delegateExtension(pi: ExtensionAPI) {
1136
1138
 
1137
1139
  const doctorText = (): string => {
1138
1140
  const report = app.doctor();
1139
- const lines = [`[delegate doctor] ${report.ok ? "OK" : "ISSUES FOUND"}`];
1141
+ const lines = [
1142
+ `[delegate doctor] ${report.ok ? "OK" : "ISSUES FOUND"}`,
1143
+ `version: v${delegateVersion()} (loaded at session start; /reload picks up newer installs)`,
1144
+ ];
1140
1145
  for (const c of report.checks) lines.push(` ${c.status === "ok" ? "✓" : c.status === "warning" ? "!" : "✗"} ${c.name}: ${c.detail}`);
1141
1146
  return lines.join("\n");
1142
1147
  };
@@ -1273,6 +1278,19 @@ export default function delegateExtension(pi: ExtensionAPI) {
1273
1278
  }
1274
1279
  return;
1275
1280
  }
1281
+ case "set": {
1282
+ // Panel≡command parity: same app method as the advanced-config
1283
+ // input rows (cfg:user:*). patchConfig owns field validation.
1284
+ const err = app.patchConfig(intent.field, intent.value);
1285
+ say(ctx, err ? `[delegate] ${err}` : `[delegate] set ${intent.field} = ${intent.value} (user config)`, err ? "warning" : "info");
1286
+ return;
1287
+ }
1288
+ case "set-project": {
1289
+ // Same method as the cfg:project:* input rows.
1290
+ const err = app.patchProjectConfig(ctx.cwd ?? process.cwd(), intent.field, intent.value);
1291
+ say(ctx, err ? `[delegate] ${err}` : `[delegate] set ${intent.field} = ${intent.value} (project config)`, err ? "warning" : "info");
1292
+ return;
1293
+ }
1276
1294
  case "invalid":
1277
1295
  say(ctx, `[delegate] unrecognized '${intent.token}'.\n${intent.usage}\n${helpText()}`, "error");
1278
1296
  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.2",
4
4
  "type": "module",
5
5
  "description": "Foreground isolated delegation and strict coordinator mode for the Pi coding agent.",
6
6
  "license": "MIT",