oira666_pi-subagent 0.5.7 → 0.5.8

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/README.md CHANGED
@@ -105,7 +105,7 @@ Collapsed results show each child's name, task, status, and most recent activity
105
105
 
106
106
  `/subagent-expand <name>` opens a saved worker transcript. With no name, it opens a searchable picker. Name completion is fuzzy. Each task or resume shows its actual provider/model and thinking level from the worker's session, not the parent's settings. Selected presets also appear as an intelligence label, kept separately for each run. Missing historical model/thinking metadata appears as `unknown`.
107
107
 
108
- [Model presets](docs/configuration.md#caller-selected-intelligence) show labels such as `Nicolas (Junior/code-writer)` in regular tool results. One enabled preset applies automatically to all launches and resumes without exposing an `intelligence` argument. Two or more expose an optional choice; zero or disabled presets keep the existing defaults and show no intelligence label.
108
+ [Model presets](docs/configuration.md#caller-selected-intelligence) show labels such as `Nicolas (Junior/code-writer)` in regular tool results. One enabled preset applies automatically to all launches and resumes without exposing an `intelligence` argument. Two or more require an explicit `intelligence` choice on every launch and resume item. Omitted or `null` choices reject the whole batch before any worker starts. Zero or disabled presets keep the existing defaults and show no intelligence label.
109
109
 
110
110
  | Key | Action |
111
111
  | --- | --- |
@@ -58,7 +58,7 @@ Missing descriptions retain their defaults. Overrides change written guidance, n
58
58
 
59
59
  ## Caller-selected intelligence
60
60
 
61
- Define named model presets in `pi-subagent.json`. With two or more enabled presets, the calling model chooses through each task's optional `intelligence` argument. With exactly one enabled preset, both tools hide the argument and automatically use that preset for every launch and resume. With no presets, the argument is absent and existing model/thinking defaults apply. No router or separate model-selection request is used.
61
+ Define named model presets in `pi-subagent.json`. With two or more enabled presets, the calling model must choose a configured `intelligence` preset for every launch and resume item. With exactly one enabled preset, both tools hide the argument and automatically use that preset for every launch and resume. With no presets, the argument is absent and existing model/thinking defaults apply. No router or separate model-selection request is used.
62
62
 
63
63
  ```json
64
64
  {
@@ -98,11 +98,11 @@ Use models available in your Pi installation. Names are arbitrary, unique, non-e
98
98
  }
99
99
  ```
100
100
 
101
- With multiple presets, `resume_subagents` also accepts `intelligence` on each resume item. A selected or automatic preset overrides the parent model and agent model/thinking settings for that run. The parent's explicit `--provider` and `--api-key` are not forwarded when a preset is selected. Worker providers use their configured Pi credentials. With multiple presets, omitting `intelligence` preserves existing defaults; it does not remember a previous preset choice.
101
+ With multiple enabled presets, `resume_subagents` requires `intelligence` on each resume item, including object and shorthand calls. A selected or automatic preset overrides the parent model and agent model/thinking settings for that run. The parent's explicit `--provider` and `--api-key` are not forwarded when a preset is selected. Worker providers use their configured Pi credentials. Each resume needs a fresh explicit choice; it does not remember a previous preset choice. Omitted or `null` choices reject the entire launch or resume batch before any worker starts or budget changes.
102
102
 
103
- Tool result rows show the selected preset, for example `Nicolas (Junior/code-writer)`. Display names capitalize only the first character; configured spelling and argument values otherwise stay unchanged. Runs without a preset show `Nicolas (code-writer)`. Durable results retain their own preset name, and the name registry retains the initial choice. `/subagent-expand` shows each task's or resume's recorded intelligence alongside its actual transcript model and thinking level. Later resumes do not relabel earlier work. Missing model or thinking metadata remains `unknown`, even when a preset name is known.
103
+ Tool result rows show the selected preset, for example `Nicolas (Junior/code-writer)`. Display names capitalize only the first character; configured spelling and argument values otherwise stay unchanged. Runs without a preset show `Nicolas (code-writer)`. Durable results retain their own preset name, and the name registry retains the initial choice. The `/subagent-expand` picker shows the initial preset beside each agent type and lets you search by preset name. Its transcript view shows each task's or resume's recorded intelligence alongside its actual transcript model and thinking level. Later resumes do not relabel earlier work. Missing model or thinking metadata remains `unknown`, even when a preset name is known.
104
104
 
105
- `PI_SUBAGENT_INTELLIGENCE=true` enables presets when they exist, which is the default. Set it to `false` or `0` to treat the configuration as having no presets: both tools hide the argument and no automatic preset applies. Unknown choices or attempts to pass a hidden argument fail before launching workers.
105
+ `PI_SUBAGENT_INTELLIGENCE=true` enables presets when they exist, which is the default. Set it to `false` or `0` to treat the configuration as having no presets: both tools hide the argument and no automatic preset applies. Unknown choices or attempts to pass a named hidden argument fail before launching workers. When the argument is hidden, omission or `null` still uses the automatic sole preset or existing defaults.
106
106
 
107
107
  Configuration follows the trust checks and file order above. A later `subagents-models` block replaces the entire earlier block. An empty list disables selection. Invalid blocks warn and disable selection rather than using a partial list. Nested workers load configuration using the same rules. Reload Pi after changing settings.
108
108
 
@@ -36,7 +36,12 @@ export function registerSubagentExpandCommand(state: ExtensionState): void {
36
36
  // one by any fragment of the name, agent type, or task.
37
37
  const pickerItems: PickerItem[] = Object.values(registry.agents ?? {})
38
38
  .sort((a, b) => (b.createdAt ?? 0) - (a.createdAt ?? 0))
39
- .map((record) => ({ name: record.name, agent: record.agent, task: record.task }));
39
+ .map((record) => ({
40
+ name: record.name,
41
+ agent: record.agent,
42
+ task: record.task,
43
+ intelligence: record.intelligence,
44
+ }));
40
45
  const items = filterPickerItems(pickerItems, prefix).map((item) => ({
41
46
  value: item.name,
42
47
  label: item.name,
@@ -70,7 +75,12 @@ export function registerSubagentExpandCommand(state: ExtensionState): void {
70
75
  const record = name ? findNameRecord(registry, name) : undefined;
71
76
  if (!record && name) {
72
77
  const suggestions = filterPickerItems(
73
- sortedRecords.map((item) => ({ name: item.name, agent: item.agent, task: item.task })),
78
+ sortedRecords.map((item) => ({
79
+ name: item.name,
80
+ agent: item.agent,
81
+ task: item.task,
82
+ intelligence: item.intelligence,
83
+ })),
74
84
  name,
75
85
  )
76
86
  .slice(0, 10)
@@ -101,7 +111,12 @@ export function registerSubagentExpandCommand(state: ExtensionState): void {
101
111
  await ctx.ui.custom(
102
112
  (tui, theme, _keybindings, done: (value: void) => void) =>
103
113
  new SubagentExpandView({
104
- items: sortedRecords.map((item) => ({ name: item.name, agent: item.agent, task: item.task })),
114
+ items: sortedRecords.map((item) => ({
115
+ name: item.name,
116
+ agent: item.agent,
117
+ task: item.task,
118
+ intelligence: item.intelligence,
119
+ })),
105
120
  detail,
106
121
  resolveDetail,
107
122
  getRows: () => tui?.terminal?.rows ?? 30,
@@ -69,20 +69,18 @@ export function createIntelligenceSchemas(presets: IntelligencePreset[] = []) {
69
69
  // Literal alternatives enforce validation; enum and descriptions advertise the caller's choices.
70
70
  // The tuple is non-empty whenever these dynamic schemas are exposed.
71
71
  const intelligence = {
72
- intelligence: Type.Optional(
73
- Type.Union(
74
- presets.map((preset) => Type.Literal(preset.name, { description: preset.description })) as [
75
- TLiteral<string>,
76
- ...TLiteral<string>[],
77
- ],
78
- {
79
- enum: presets.map((preset) => preset.name),
80
- description: [
81
- "Optional named model/provider/reasoning preset. Omit to use existing defaults.",
82
- ...presets.map((preset) => `${preset.name}${preset.description ? `: ${preset.description}` : ""}`),
83
- ].join("\n"),
84
- },
85
- ),
72
+ intelligence: Type.Union(
73
+ presets.map((preset) => Type.Literal(preset.name, { description: preset.description })) as [
74
+ TLiteral<string>,
75
+ ...TLiteral<string>[],
76
+ ],
77
+ {
78
+ enum: presets.map((preset) => preset.name),
79
+ description: [
80
+ "Required named model/provider/reasoning preset. Choose a configured preset for every launch and resume.",
81
+ ...presets.map((preset) => `${preset.name}${preset.description ? `: ${preset.description}` : ""}`),
82
+ ].join("\n"),
83
+ },
86
84
  ),
87
85
  };
88
86
  const task = Type.Object({ ...TaskItem.properties, ...intelligence }, { additionalProperties: false });
@@ -102,8 +100,8 @@ export function createIntelligenceSchemas(presets: IntelligencePreset[] = []) {
102
100
  return presets.length >= 2 && intelligenceEnabled(presets)
103
101
  ? { subagents, resumes }
104
102
  : {
105
- subagents: SubagentParams as typeof subagents,
106
- resumes: ResumeSubagentsParams as typeof resumes,
103
+ subagents: SubagentParams as unknown as typeof subagents,
104
+ resumes: ResumeSubagentsParams as unknown as typeof resumes,
107
105
  };
108
106
  }
109
107
 
@@ -136,7 +134,7 @@ export function normalizeResumes(
136
134
  return normalized;
137
135
  }
138
136
 
139
- /** Strict provider schemas can send null for omitted optional intelligence. Leave all other fields alone. */
137
+ /** Normalize provider nulls to omission. Exposed choices still fail required-field validation. */
140
138
  export function prepareIntelligenceArguments(args: unknown, key: "tasks" | "resumes"): unknown {
141
139
  if (!isRecord(args) || !Object.hasOwn(args, key)) return args;
142
140
  const omitNull = (item: unknown): unknown => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oira666_pi-subagent",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "Subagent extension for Pi coding agent. Delegate tasks to specialized agents.",
5
5
  "type": "module",
6
6
  "main": "index.ts",
package/ui/picker.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import { overlayFrame } from "./frame.js";
2
+ import { displayIntelligence } from "../intelligence.js";
2
3
  import { Key, matchesKey, fuzzyFilter } from "@earendil-works/pi-tui";
3
4
  import type { DetailTheme } from "../detail.js";
4
5
  export interface PickerItem {
5
6
  name: string;
6
7
  agent: string;
8
+ intelligence?: string;
7
9
  task?: string;
8
10
  }
9
11
 
@@ -11,7 +13,11 @@ export function filterPickerItems(items: PickerItem[], query: string): PickerIte
11
13
  const trimmed = query.trim();
12
14
  if (!trimmed) return items;
13
15
  const byName = fuzzyFilter(items, trimmed, (item) => item.name);
14
- const byEverything = fuzzyFilter(items, trimmed, (item) => `${item.name} ${item.agent} ${item.task ?? ""}`);
16
+ const byEverything = fuzzyFilter(
17
+ items,
18
+ trimmed,
19
+ (item) => `${item.name} ${item.agent} ${item.intelligence ?? ""} ${item.task ?? ""}`,
20
+ );
15
21
  const seen = new Set(byName);
16
22
  return [...byName, ...byEverything.filter((item) => !seen.has(item))];
17
23
  }
@@ -97,7 +103,8 @@ export class SubagentPicker {
97
103
  }
98
104
  const isSelected = this.scroll + index === this.selected;
99
105
  const marker = isSelected ? theme.fg("accent", ">") : " ";
100
- const label = `${item.name} (${item.agent})`;
106
+ const agent = item.intelligence ? `${displayIntelligence(item.intelligence)}/${item.agent}` : item.agent;
107
+ const label = `${item.name} (${agent})`;
101
108
  const task = item.task ? ` — ${item.task.replace(/\s+/g, " ")}` : "";
102
109
  out.push(frame.row(`${marker} ${theme.fg("accent", label)}${theme.fg("dim", task)}`));
103
110
  }