@ferris1225/pi-subagents 6.0.2 → 6.0.4
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 +23 -0
- package/README.md +71 -191
- package/index.ts +2 -12
- package/package.json +7 -7
- package/src/configuration/config.ts +2 -6
- package/src/configuration/role-migration.ts +3 -14
- package/src/configuration/schema.ts +10 -0
- package/src/configuration/setup.ts +75 -36
- package/src/configuration/ui.ts +355 -53
- package/src/delegation/agents.ts +0 -1
- package/src/delegation/builtin-agents.ts +6 -27
- package/src/delegation/dispatch.ts +29 -120
- package/src/delegation/prompt.ts +16 -48
- package/src/execution/spawn.ts +2 -2
- package/src/lifecycle/cancellation.ts +4 -8
- package/src/lifecycle/durable.ts +0 -18
- package/src/lifecycle/runtime.ts +7 -56
- package/src/lifecycle/thread-lifecycle.ts +5 -33
- package/src/lifecycle/thread-restore.ts +0 -3
- package/src/lifecycle/thread-shared.ts +1 -11
- package/src/lifecycle/tools.ts +12 -97
- package/src/presentation/monitor.ts +727 -758
- package/src/presentation/widget.ts +36 -134
- package/src/delegation/ownership.ts +0 -98
- package/src/delegation/phase-scope.ts +0 -186
- package/src/workflow/acceptance.ts +0 -67
- package/src/workflow/durable.ts +0 -228
- package/src/workflow/engine.ts +0 -816
- package/src/workflow/plan.ts +0 -409
- package/src/workflow/state.ts +0 -55
- package/src/workflow/templates.ts +0 -156
- package/src/workflow/tool.ts +0 -254
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
resolveThinkingLevel,
|
|
25
25
|
supportedThinkingLevels,
|
|
26
26
|
} from "./models.ts";
|
|
27
|
-
import { promptMenu, promptSelectOne, type SetupItem } from "./ui.ts";
|
|
27
|
+
import { promptMenu, promptRoleGrid, promptSelectOne, type RoleGridFocus, type RoleGridRow, type SetupItem } from "./ui.ts";
|
|
28
28
|
|
|
29
29
|
const ROLE_DEFAULT = "__role_default__";
|
|
30
30
|
const THINKING_LEVEL_HINTS: Record<ThinkingLevel, string> = {
|
|
@@ -37,6 +37,12 @@ const THINKING_LEVEL_HINTS: Record<ThinkingLevel, string> = {
|
|
|
37
37
|
max: "strongest reasoning",
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
const ROLE_PURPOSE: Record<string, string> = {
|
|
41
|
+
scout: "Research with citations",
|
|
42
|
+
artisan: "Implement and verify",
|
|
43
|
+
sentinel: "Review and challenge claims",
|
|
44
|
+
};
|
|
45
|
+
|
|
40
46
|
async function configExists(configPath: string): Promise<boolean> {
|
|
41
47
|
try {
|
|
42
48
|
await stat(configPath);
|
|
@@ -50,14 +56,7 @@ function roleModel(ctx: ExtensionContext, config: SubagentsConfig, name: string)
|
|
|
50
56
|
return findModelByRef(availableModelsInScope(ctx), config.agentModels[name]) ?? ctx.model;
|
|
51
57
|
}
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
scout: "Research with citations",
|
|
55
|
-
artisan: "Implement and verify",
|
|
56
|
-
sentinel: "Review implementation",
|
|
57
|
-
skeptic: "Challenge a named claim",
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
function roleSettings(ctx: ExtensionContext, config: SubagentsConfig, name: string): SetupItem[] {
|
|
59
|
+
export function roleSettings(ctx: ExtensionContext, config: SubagentsConfig, name: string): SetupItem[] {
|
|
61
60
|
const selected = config.agentModels[name];
|
|
62
61
|
const model = findModelByRef(availableModelsInScope(ctx), selected);
|
|
63
62
|
const modelLabel = selected
|
|
@@ -77,13 +76,44 @@ function roleSettings(ctx: ExtensionContext, config: SubagentsConfig, name: stri
|
|
|
77
76
|
];
|
|
78
77
|
}
|
|
79
78
|
|
|
80
|
-
function roleItems(ctx: ExtensionContext, config: SubagentsConfig): SetupItem[] {
|
|
79
|
+
export function roleItems(ctx: ExtensionContext, config: SubagentsConfig): SetupItem[] {
|
|
81
80
|
return BUILTIN_AGENT_NAMES.map((name) => {
|
|
82
81
|
const settings = roleSettings(ctx, config, name);
|
|
83
|
-
return { value: name, label: name + " · " + ROLE_PURPOSE[name],
|
|
82
|
+
return { value: name, label: name + " · " + (ROLE_PURPOSE[name] ?? name),
|
|
84
83
|
description: settings[0]!.label + "\n" + settings[1]!.label + "\n" + agentProfile(name)!.remark };
|
|
85
84
|
});
|
|
86
85
|
}
|
|
86
|
+
|
|
87
|
+
/** One row per role: every model and thinking choice stays visible together in the standalone modal panel. */
|
|
88
|
+
function roleRows(ctx: ExtensionContext, config: SubagentsConfig): RoleGridRow[] {
|
|
89
|
+
const mainRef = currentModelRef(ctx) ?? "Pi default";
|
|
90
|
+
const models = availableModelsInScope(ctx);
|
|
91
|
+
return BUILTIN_AGENT_NAMES.map((name) => {
|
|
92
|
+
const profile = agentProfile(name)!;
|
|
93
|
+
const selected = config.agentModels[name];
|
|
94
|
+
const model = findModelByRef(models, selected);
|
|
95
|
+
const available = !selected || Boolean(model);
|
|
96
|
+
const modelLabel = selected
|
|
97
|
+
? (model ? model.name + " · " + model.provider + (model.name !== selected ? " (" + selected + ")" : "") : selected + " (unavailable)")
|
|
98
|
+
: "Follow main (dynamic)";
|
|
99
|
+
const preferred = config.agentThinkingLevels[name] ?? roleThinkingLevel(name);
|
|
100
|
+
const effective = resolveThinkingLevel(model ?? ctx.model, preferred);
|
|
101
|
+
const clamped = effective !== preferred ? " (" + preferred + " requested)" : "";
|
|
102
|
+
const overridden = Boolean(config.agentThinkingLevels[name]);
|
|
103
|
+
return {
|
|
104
|
+
role: name,
|
|
105
|
+
purpose: ROLE_PURPOSE[name],
|
|
106
|
+
thinkingOverridden: overridden,
|
|
107
|
+
model: modelLabel,
|
|
108
|
+
thinking: effective + clamped,
|
|
109
|
+
description: profile.remark + " Model: " + (selected
|
|
110
|
+
? "pinned reference " + selected + (available ? "; falls back to main if it fails." : "; unavailable, using main.")
|
|
111
|
+
: "follows main (" + mainRef + ") dynamically.")
|
|
112
|
+
+ " Thinking: role default " + roleThinkingLevel(name) + ", clamped to the model-supported levels. Reset restores " + name + " to Follow main and that default. * marks an override.",
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
87
117
|
async function editSetting(
|
|
88
118
|
ctx: ExtensionContext,
|
|
89
119
|
config: SubagentsConfig,
|
|
@@ -99,7 +129,7 @@ async function editSetting(
|
|
|
99
129
|
delete next.agentThinkingLevels[name];
|
|
100
130
|
} else if (field === "model") {
|
|
101
131
|
const choice = await promptSelectOne(ctx, name + " · Model",
|
|
102
|
-
"Follow main = dynamic · Others = pinned",
|
|
132
|
+
"Follow main = dynamic · Others = pinned · Esc back without changes",
|
|
103
133
|
buildModelPickerItems({ models: availableModelsInScope(ctx), configuredRef: config.agentModels[name], mainRef: currentModelRef(ctx) }),
|
|
104
134
|
config.agentModels[name] ?? CURRENT_MAIN_MODEL);
|
|
105
135
|
if (choice === undefined) return undefined;
|
|
@@ -113,17 +143,31 @@ async function editSetting(
|
|
|
113
143
|
ctx.ui.notify("Choose a model before changing thinking; its supported levels are not available yet.", "info");
|
|
114
144
|
return undefined;
|
|
115
145
|
}
|
|
116
|
-
const options = [
|
|
117
|
-
{ value: ROLE_DEFAULT, label: "Role default", description: preferredDefault + (effectiveDefault !== preferredDefault ? " → " + effectiveDefault + " on this model" : "") },
|
|
118
|
-
...supported.map((level) => ({ value: level, label: level, description: THINKING_LEVEL_HINTS[level] })),
|
|
119
|
-
];
|
|
120
146
|
const current = config.agentThinkingLevels[name];
|
|
147
|
+
const options: SetupItem[] = [
|
|
148
|
+
{
|
|
149
|
+
value: ROLE_DEFAULT,
|
|
150
|
+
label: "Role default",
|
|
151
|
+
description: preferredDefault + (effectiveDefault !== preferredDefault ? " → " + effectiveDefault + " on this model" : ""),
|
|
152
|
+
saved: !current,
|
|
153
|
+
},
|
|
154
|
+
...supported.map((level) => ({
|
|
155
|
+
value: level,
|
|
156
|
+
label: level,
|
|
157
|
+
description: THINKING_LEVEL_HINTS[level],
|
|
158
|
+
saved: current === level,
|
|
159
|
+
})),
|
|
160
|
+
];
|
|
121
161
|
if (current && !supported.includes(current)) {
|
|
122
|
-
options.push({
|
|
123
|
-
|
|
162
|
+
options.push({
|
|
163
|
+
value: current,
|
|
164
|
+
label: current + " (runs as " + resolveThinkingLevel(model, current) + ")",
|
|
165
|
+
description: "Saved preference; this model clamps it. Keep it for other models, or choose a supported level.",
|
|
166
|
+
saved: true,
|
|
167
|
+
});
|
|
124
168
|
}
|
|
125
169
|
const choice = await promptSelectOne(ctx, name + " · Thinking",
|
|
126
|
-
"Reasoning effort · saved preferences survive model changes",
|
|
170
|
+
"Reasoning effort · saved preferences survive model changes · Esc back",
|
|
127
171
|
options, current ?? ROLE_DEFAULT);
|
|
128
172
|
if (choice === undefined) return undefined;
|
|
129
173
|
if (choice === ROLE_DEFAULT) delete next.agentThinkingLevels[name];
|
|
@@ -134,8 +178,7 @@ async function editSetting(
|
|
|
134
178
|
return next;
|
|
135
179
|
}
|
|
136
180
|
|
|
137
|
-
|
|
138
|
-
/** The same role overview serves first install and later edits. */
|
|
181
|
+
/** Standalone modal panel for first install and later edits. */
|
|
139
182
|
export async function runSetup(ctx: ExtensionContext, configPath: string = getConfigPath()): Promise<void> {
|
|
140
183
|
if (ctx.mode !== "tui") {
|
|
141
184
|
ctx.ui.notify("/subagents-setup requires Pi's interactive TUI.", "error");
|
|
@@ -143,29 +186,25 @@ export async function runSetup(ctx: ExtensionContext, configPath: string = getCo
|
|
|
143
186
|
}
|
|
144
187
|
try {
|
|
145
188
|
let config = await loadConfig(configPath);
|
|
146
|
-
let
|
|
147
|
-
const settingFocus: Record<string, string> = {};
|
|
189
|
+
let focus: RoleGridFocus = {};
|
|
148
190
|
let status = "Changes save immediately";
|
|
149
191
|
while (true) {
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (!next) continue;
|
|
159
|
-
await saveConfig(next, configPath);
|
|
160
|
-
config = next;
|
|
161
|
-
status = "Saved " + name + (field === "reset" ? " defaults" : " " + field);
|
|
162
|
-
}
|
|
192
|
+
const choice = await promptRoleGrid(ctx, roleRows(ctx, config), focus, status);
|
|
193
|
+
if (choice === undefined) return;
|
|
194
|
+
focus = { row: choice.row, column: choice.column };
|
|
195
|
+
const next = await editSetting(ctx, config, choice.role, choice.field);
|
|
196
|
+
if (!next) continue;
|
|
197
|
+
await saveConfig(next, configPath);
|
|
198
|
+
config = next;
|
|
199
|
+
status = "Saved " + choice.role + (choice.field === "reset" ? " defaults" : " " + choice.field);
|
|
163
200
|
}
|
|
164
201
|
} catch (error) {
|
|
165
202
|
ctx.ui.notify("pi-subagents setup failed: " + errorMessage(error), "error");
|
|
166
203
|
}
|
|
167
204
|
}
|
|
168
205
|
|
|
206
|
+
export { promptMenu };
|
|
207
|
+
|
|
169
208
|
/** Write shipped defaults once so every role works immediately. */
|
|
170
209
|
export async function ensureDefaultConfig(
|
|
171
210
|
ctx: ExtensionContext,
|