@herbertgao/pi-extensions 2026.11.10 → 2026.11.11
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 +11 -0
- package/README.md +6 -6
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +13 -8
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +58 -15
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/tool-io.ts +0 -5
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/ansi-text.ts +18 -4
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
- package/node_modules/@herbertgao/pi-impeccable/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-impeccable/README.md +2 -2
- package/node_modules/@herbertgao/pi-impeccable/package.json +4 -4
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/SKILL.md +3 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/adapt.md +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/audit.md +12 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/audit.native.md +4 -0
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/critique.md +5 -5
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/degraded/documenter.md +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/degraded/finish-reviewer.md +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/distill.md +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/document.md +3 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/foundations.md +44 -0
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/live-setup.md +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/live.md +26 -12
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/new-work.md +10 -9
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/onboard.md +7 -6
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/overdrive.md +2 -2
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/quieter.md +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/visualize.md +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/VERSION +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/engine-checksums.txt +5 -5
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/impeccable +69 -16
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/impeccable.cmd +55 -7
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/live-browser.js +34 -4
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-subagents/README.md +27 -9
- package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +11 -11
- package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +13 -0
- package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +51 -32
- package/node_modules/@herbertgao/pi-subagents/src/default-agents.ts +7 -0
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +334 -893
- package/node_modules/@herbertgao/pi-subagents/src/nested-tools.ts +4 -1
- package/node_modules/@herbertgao/pi-subagents/src/prompts.ts +13 -0
- package/node_modules/@herbertgao/pi-subagents/src/schedule-store.ts +18 -13
- package/node_modules/@herbertgao/pi-subagents/src/schedule.ts +25 -5
- package/node_modules/@herbertgao/pi-subagents/src/settings.ts +215 -69
- package/node_modules/@herbertgao/pi-subagents/src/types.ts +17 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +9 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/agents-menu.ts +705 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/settings-menu.ts +361 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/viewer-keys.ts +1 -1
- package/node_modules/pi-commandcode-provider/CHANGELOG.md +11 -1
- package/node_modules/pi-commandcode-provider/index.ts +2 -1
- package/node_modules/pi-commandcode-provider/package.json +5 -4
- package/node_modules/pi-commandcode-provider/src/pricing.ts +8 -1
- package/node_modules/pi-commandcode-provider/src/responses-compat.ts +137 -0
- package/package.json +5 -5
|
@@ -10,13 +10,8 @@
|
|
|
10
10
|
* /agents — Interactive agent management menu
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
mkdirSync,
|
|
16
|
-
readFileSync,
|
|
17
|
-
unlinkSync,
|
|
18
|
-
writeFileSync,
|
|
19
|
-
} from "node:fs"
|
|
13
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs"
|
|
14
|
+
import { homedir } from "node:os"
|
|
20
15
|
import { isAbsolute, join } from "node:path"
|
|
21
16
|
import {
|
|
22
17
|
type AgentSession,
|
|
@@ -25,32 +20,18 @@ import {
|
|
|
25
20
|
type ExtensionCommandContext,
|
|
26
21
|
type ExtensionContext,
|
|
27
22
|
getAgentDir,
|
|
28
|
-
getSettingsListTheme,
|
|
29
23
|
} from "@earendil-works/pi-coding-agent"
|
|
30
24
|
import {
|
|
31
25
|
Container,
|
|
32
26
|
isKeyRelease,
|
|
33
|
-
Key,
|
|
34
27
|
matchesKey,
|
|
35
28
|
type ScrollViewScrollbar,
|
|
36
29
|
type SettingItem,
|
|
37
|
-
SettingsList,
|
|
38
|
-
Spacer,
|
|
39
30
|
Text,
|
|
40
31
|
} from "@earendil-works/pi-tui"
|
|
41
32
|
import { Type } from "typebox"
|
|
42
33
|
import { abortable } from "./abortable.js"
|
|
43
34
|
import { hasAgentBadge, renderAgentName } from "./agent-color.js"
|
|
44
|
-
import {
|
|
45
|
-
buildNewAgentFile,
|
|
46
|
-
disableInContent,
|
|
47
|
-
enableInContent,
|
|
48
|
-
isEmptyStub,
|
|
49
|
-
locateAgentFile,
|
|
50
|
-
personalAgentsDir,
|
|
51
|
-
projectAgentsDir,
|
|
52
|
-
serializeAgentFile,
|
|
53
|
-
} from "./agent-file-toggle.js"
|
|
54
35
|
import { AgentManager, isTopLevelAgent } from "./agent-manager.js"
|
|
55
36
|
import {
|
|
56
37
|
AGENT_RECORD_ENTRY_TYPE,
|
|
@@ -72,15 +53,9 @@ import {
|
|
|
72
53
|
setRememberAgents,
|
|
73
54
|
steerAgent,
|
|
74
55
|
} from "./agent-runner.js"
|
|
75
|
-
import {
|
|
76
|
-
rowDescription,
|
|
77
|
-
sourceIndicator,
|
|
78
|
-
sourceLegend,
|
|
79
|
-
} from "./agent-source-badge.js"
|
|
80
56
|
import {
|
|
81
57
|
BUILTIN_TOOL_NAMES,
|
|
82
58
|
getAgentConfig,
|
|
83
|
-
getAllTypes,
|
|
84
59
|
getAvailableTypes,
|
|
85
60
|
getConfig,
|
|
86
61
|
getFallbackSubagent,
|
|
@@ -135,7 +110,6 @@ import {
|
|
|
135
110
|
getPackageAgentsGate,
|
|
136
111
|
getPackageWorkflowsGate,
|
|
137
112
|
invalidatePackageCache,
|
|
138
|
-
packageNameForPath,
|
|
139
113
|
seedProjectTrust,
|
|
140
114
|
setPackageAgentsGate,
|
|
141
115
|
setPackageWorkflowsGate,
|
|
@@ -145,9 +119,18 @@ import { SubagentScheduler } from "./schedule.js"
|
|
|
145
119
|
import { resolveStorePath, ScheduleStore } from "./schedule-store.js"
|
|
146
120
|
import {
|
|
147
121
|
applyAndEmitLoaded,
|
|
122
|
+
applySettings,
|
|
123
|
+
defaultSettingsScope,
|
|
124
|
+
isNumericSettingKey,
|
|
148
125
|
loadSettings,
|
|
126
|
+
SETTING_DEFAULTS,
|
|
127
|
+
type SettingsAppliers,
|
|
128
|
+
type SettingsScope,
|
|
149
129
|
type SubagentsSettings,
|
|
150
130
|
saveAndEmitChanged,
|
|
131
|
+
saveSettings,
|
|
132
|
+
settingSources,
|
|
133
|
+
settingsFilePath,
|
|
151
134
|
type ToolDescriptionMode,
|
|
152
135
|
} from "./settings.js"
|
|
153
136
|
import {
|
|
@@ -163,6 +146,7 @@ import {
|
|
|
163
146
|
type JoinMode,
|
|
164
147
|
type NotificationDetails,
|
|
165
148
|
type SubagentType,
|
|
149
|
+
THINKING_LEVELS,
|
|
166
150
|
type ViewerMarkdownMode,
|
|
167
151
|
type WidgetMode,
|
|
168
152
|
} from "./types.js"
|
|
@@ -171,7 +155,6 @@ import {
|
|
|
171
155
|
mentionRoster,
|
|
172
156
|
type TypeInfo,
|
|
173
157
|
} from "./ui/agent-mention.js"
|
|
174
|
-
import { agentTree } from "./ui/agent-tree.js"
|
|
175
158
|
import {
|
|
176
159
|
type AgentActivity,
|
|
177
160
|
type AgentDetails,
|
|
@@ -179,6 +162,7 @@ import {
|
|
|
179
162
|
buildInvocationTags,
|
|
180
163
|
describeActivity,
|
|
181
164
|
fgPreservingNestedStyles,
|
|
165
|
+
formatAge,
|
|
182
166
|
formatCost,
|
|
183
167
|
formatDuration,
|
|
184
168
|
formatMs,
|
|
@@ -190,6 +174,7 @@ import {
|
|
|
190
174
|
type Theme,
|
|
191
175
|
type UICtx,
|
|
192
176
|
} from "./ui/agent-widget.js"
|
|
177
|
+
import { createAgentsMenu } from "./ui/agents-menu.js"
|
|
193
178
|
import {
|
|
194
179
|
ConversationViewer,
|
|
195
180
|
getConversationOverlayOptions,
|
|
@@ -200,15 +185,16 @@ import {
|
|
|
200
185
|
type FleetUICtx,
|
|
201
186
|
type FleetWorkflow,
|
|
202
187
|
} from "./ui/fleet-list.js"
|
|
203
|
-
import {
|
|
204
|
-
|
|
188
|
+
import {
|
|
189
|
+
createSettingsPage,
|
|
190
|
+
type SettingsPageDeps,
|
|
191
|
+
} from "./ui/settings-menu.js"
|
|
205
192
|
import {
|
|
206
193
|
renderWorkflowCard,
|
|
207
194
|
renderWorkflowEntryCard,
|
|
208
195
|
} from "./ui/workflow-card.js"
|
|
209
196
|
import {
|
|
210
197
|
openWorkflowFromFleet,
|
|
211
|
-
showWorkflowsMenu,
|
|
212
198
|
type WorkflowMenuDeps,
|
|
213
199
|
} from "./ui/workflow-menu.js"
|
|
214
200
|
import {
|
|
@@ -350,23 +336,6 @@ function createActivityTracker(maxTurns?: number, onStreamUpdate?: () => void) {
|
|
|
350
336
|
return { state, callbacks }
|
|
351
337
|
}
|
|
352
338
|
|
|
353
|
-
/**
|
|
354
|
-
* Advertised thinking levels, ordered to mirror pi-ai's EXTENDED_THINKING_LEVELS
|
|
355
|
-
* (`off` + every `ThinkingLevel`). Single source for the Agent tool description,
|
|
356
|
-
* the generated-agent template, and the `/agents` wizard so these lists can't
|
|
357
|
-
* drift behind pi again (#147). Availability of any level still depends on the
|
|
358
|
-
* host pi version and the selected model — pi clamps unsupported levels down.
|
|
359
|
-
*/
|
|
360
|
-
const THINKING_LEVELS = [
|
|
361
|
-
"off",
|
|
362
|
-
"minimal",
|
|
363
|
-
"low",
|
|
364
|
-
"medium",
|
|
365
|
-
"high",
|
|
366
|
-
"xhigh",
|
|
367
|
-
"max",
|
|
368
|
-
] as const
|
|
369
|
-
|
|
370
339
|
/** Human-readable status label for agent completion. */
|
|
371
340
|
function getStatusLabel(status: string, error?: string): string {
|
|
372
341
|
switch (status) {
|
|
@@ -1132,10 +1101,17 @@ export default function (pi: ExtensionAPI) {
|
|
|
1132
1101
|
return resolved?.kind === "live" ? resolved.record : undefined
|
|
1133
1102
|
}
|
|
1134
1103
|
|
|
1135
|
-
/**
|
|
1104
|
+
/**
|
|
1105
|
+
* get_subagent_result's answer from a persisted record, once the live record
|
|
1106
|
+
* is gone. The record lasts as long as the session file, so it states when
|
|
1107
|
+
* the run finished: a days-old result must not read as current (#436).
|
|
1108
|
+
*/
|
|
1136
1109
|
const formatSavedAgentRecord = (saved: AgentRecordEntryData): string =>
|
|
1137
1110
|
`Agent: ${saved.id}\n` +
|
|
1138
1111
|
`Type: ${getDisplayName(saved.type)} | Status: ${saved.status}${getStatusNote(saved.status)} | Duration: ${formatDuration(saved.startedAt, saved.completedAt)}\n` +
|
|
1112
|
+
(saved.completedAt
|
|
1113
|
+
? `Finished: ${new Date(saved.completedAt).toISOString().slice(0, 16)}Z (${formatAge(saved.completedAt)} ago)\n`
|
|
1114
|
+
: "") +
|
|
1139
1115
|
`Description: ${saved.description}\n` +
|
|
1140
1116
|
`(From the session's saved record: the live record has been cleaned up, so its stats and conversation are gone.)\n\n` +
|
|
1141
1117
|
(saved.status === "error"
|
|
@@ -2078,39 +2054,40 @@ export default function (pi: ExtensionAPI) {
|
|
|
2078
2054
|
// Apply persisted settings on startup and emit `subagents:settings_loaded`.
|
|
2079
2055
|
// Global + project merged; missing → defaults; corrupt file emits a warning
|
|
2080
2056
|
// to stderr and falls back to defaults.
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
},
|
|
2095
|
-
setDisableDefaultAgents: setDisableDefaultAgents,
|
|
2096
|
-
setToolDescriptionMode: setToolDescriptionMode,
|
|
2097
|
-
setFleetView: setFleetViewEnabled,
|
|
2098
|
-
setAgentMentions: setAgentMentionMode,
|
|
2099
|
-
setRememberAgents,
|
|
2100
|
-
setWidgetMode: setWidgetMode,
|
|
2101
|
-
setOutputTranscript: setOutputTranscriptDefault,
|
|
2102
|
-
setWorktreeIsolation: setWorktreeIsolationEnabled,
|
|
2103
|
-
setWorkflowsEnabled: setWorkflowsEnabled,
|
|
2104
|
-
setMaxSubagentDepth: setMaxSubagentDepth,
|
|
2105
|
-
setFallbackSubagent: setFallbackSubagent,
|
|
2106
|
-
setReportUsage,
|
|
2107
|
-
setShowCost,
|
|
2108
|
-
setShowModel,
|
|
2109
|
-
setViewerMarkdown,
|
|
2110
|
-
setPackageAgents: setPackageAgentsGate,
|
|
2111
|
-
setPackageWorkflows: setPackageWorkflowsGate,
|
|
2057
|
+
// Also how Del on the Settings page applies the value a row falls back to.
|
|
2058
|
+
const settingsAppliers: SettingsAppliers = {
|
|
2059
|
+
setMaxConcurrent: (n) => manager.setMaxConcurrent(n),
|
|
2060
|
+
setMaxConcurrentForeground: (n) => manager.setMaxConcurrentForeground(n),
|
|
2061
|
+
setMaxConcurrentNested: (n) => manager.setMaxConcurrentNested(n),
|
|
2062
|
+
setDefaultMaxTurns,
|
|
2063
|
+
setGraceTurns,
|
|
2064
|
+
setDefaultJoinMode,
|
|
2065
|
+
setBackgroundByDefault,
|
|
2066
|
+
setSchedulingEnabled,
|
|
2067
|
+
setScopeModels: setScopeModelsEnabled,
|
|
2068
|
+
setStrictAgentFiles: (b) => {
|
|
2069
|
+
strictAgentFiles = b
|
|
2112
2070
|
},
|
|
2113
|
-
|
|
2071
|
+
setDisableDefaultAgents: setDisableDefaultAgents,
|
|
2072
|
+
setToolDescriptionMode: setToolDescriptionMode,
|
|
2073
|
+
setFleetView: setFleetViewEnabled,
|
|
2074
|
+
setAgentMentions: setAgentMentionMode,
|
|
2075
|
+
setRememberAgents,
|
|
2076
|
+
setWidgetMode: setWidgetMode,
|
|
2077
|
+
setOutputTranscript: setOutputTranscriptDefault,
|
|
2078
|
+
setWorktreeIsolation: setWorktreeIsolationEnabled,
|
|
2079
|
+
setWorkflowsEnabled: setWorkflowsEnabled,
|
|
2080
|
+
setMaxSubagentDepth: setMaxSubagentDepth,
|
|
2081
|
+
setFallbackSubagent: setFallbackSubagent,
|
|
2082
|
+
setReportUsage,
|
|
2083
|
+
setShowCost,
|
|
2084
|
+
setShowModel,
|
|
2085
|
+
setViewerMarkdown,
|
|
2086
|
+
setPackageAgents: setPackageAgentsGate,
|
|
2087
|
+
setPackageWorkflows: setPackageWorkflowsGate,
|
|
2088
|
+
}
|
|
2089
|
+
applyAndEmitLoaded(settingsAppliers, (event, payload) =>
|
|
2090
|
+
pi.events.emit(event, payload),
|
|
2114
2091
|
)
|
|
2115
2092
|
|
|
2116
2093
|
// ---- Agent tool ----
|
|
@@ -4022,191 +3999,6 @@ Terse command-style prompts produce shallow, generic work.
|
|
|
4022
3999
|
return `${label} (→ ${resolvedFull.replace(/-\d{8}$/, "")})`
|
|
4023
4000
|
}
|
|
4024
4001
|
|
|
4025
|
-
async function showAgentsMenu(ctx: ExtensionCommandContext) {
|
|
4026
|
-
reloadCustomAgents()
|
|
4027
|
-
const allNames = getAllTypes()
|
|
4028
|
-
|
|
4029
|
-
// Build select options
|
|
4030
|
-
const options: string[] = []
|
|
4031
|
-
|
|
4032
|
-
// Running agents entry (only if there are active agents)
|
|
4033
|
-
const agents = runningAgentsRoster().map((row) => row.record)
|
|
4034
|
-
if (agents.length > 0) {
|
|
4035
|
-
const running = agents.filter(
|
|
4036
|
-
(a) => a.status === "running" || a.status === "queued",
|
|
4037
|
-
).length
|
|
4038
|
-
const done = agents.filter(
|
|
4039
|
-
(a) => a.status === "completed" || a.status === "steered",
|
|
4040
|
-
).length
|
|
4041
|
-
options.push(
|
|
4042
|
-
`Running agents (${agents.length}) — ${running} running, ${done} done`,
|
|
4043
|
-
)
|
|
4044
|
-
}
|
|
4045
|
-
|
|
4046
|
-
// Agent types list
|
|
4047
|
-
if (allNames.length > 0) {
|
|
4048
|
-
options.push(`Agent types (${allNames.length})`)
|
|
4049
|
-
}
|
|
4050
|
-
|
|
4051
|
-
// Scheduled jobs entry (always present when scheduler is active)
|
|
4052
|
-
if (scheduler.isActive()) {
|
|
4053
|
-
const jobCount = scheduler.list().length
|
|
4054
|
-
options.push(`Scheduled jobs (${jobCount})`)
|
|
4055
|
-
}
|
|
4056
|
-
|
|
4057
|
-
// Workflow runs, on the same terms as scheduled jobs: shown only when the
|
|
4058
|
-
// feature is on, so the menu never advertises something switched off.
|
|
4059
|
-
if (isWorkflowsEnabled()) {
|
|
4060
|
-
options.push(`Workflows (${workflowTasks.size})`)
|
|
4061
|
-
}
|
|
4062
|
-
|
|
4063
|
-
// Actions
|
|
4064
|
-
options.push("Create new agent")
|
|
4065
|
-
options.push("Settings")
|
|
4066
|
-
|
|
4067
|
-
const noAgentsMsg =
|
|
4068
|
-
allNames.length === 0 && agents.length === 0
|
|
4069
|
-
? "No agents found. Create specialized subagents that can be delegated to.\n\n" +
|
|
4070
|
-
"Each subagent has its own context window, custom system prompt, and specific tools.\n\n" +
|
|
4071
|
-
"Try creating: Code Reviewer, Security Auditor, Test Writer, or Documentation Writer.\n\n"
|
|
4072
|
-
: ""
|
|
4073
|
-
|
|
4074
|
-
if (noAgentsMsg) {
|
|
4075
|
-
ctx.ui.notify(noAgentsMsg, "info")
|
|
4076
|
-
}
|
|
4077
|
-
|
|
4078
|
-
const choice = await ctx.ui.select("Agents", options)
|
|
4079
|
-
if (!choice) return
|
|
4080
|
-
|
|
4081
|
-
if (choice.startsWith("Running agents (")) {
|
|
4082
|
-
await showRunningAgents(ctx)
|
|
4083
|
-
await showAgentsMenu(ctx)
|
|
4084
|
-
} else if (choice.startsWith("Agent types (")) {
|
|
4085
|
-
await showAllAgentsList(ctx)
|
|
4086
|
-
await showAgentsMenu(ctx)
|
|
4087
|
-
} else if (choice.startsWith("Scheduled jobs (")) {
|
|
4088
|
-
await showSchedulesMenu(ctx, scheduler)
|
|
4089
|
-
await showAgentsMenu(ctx)
|
|
4090
|
-
} else if (choice.startsWith("Workflows (")) {
|
|
4091
|
-
await showWorkflowsMenu(ctx, workflowMenuDeps)
|
|
4092
|
-
await showAgentsMenu(ctx)
|
|
4093
|
-
} else if (choice === "Create new agent") {
|
|
4094
|
-
await showCreateWizard(ctx)
|
|
4095
|
-
} else if (choice === "Settings") {
|
|
4096
|
-
await showSettings(ctx)
|
|
4097
|
-
await showAgentsMenu(ctx)
|
|
4098
|
-
}
|
|
4099
|
-
}
|
|
4100
|
-
|
|
4101
|
-
/**
|
|
4102
|
-
* The package that provided an agent, for display only. Undefined for every
|
|
4103
|
-
* other source, and for a package path no currently-admitted package owns —
|
|
4104
|
-
* which is what a stale `sourcePath` looks like after the gate narrows.
|
|
4105
|
-
*/
|
|
4106
|
-
function packageNameOf(cfg: AgentConfig | undefined): string | undefined {
|
|
4107
|
-
if (cfg?.source !== "package" || !cfg.sourcePath) return undefined
|
|
4108
|
-
return packageNameForPath(cfg.sourcePath, process.cwd())
|
|
4109
|
-
}
|
|
4110
|
-
|
|
4111
|
-
async function showAllAgentsList(ctx: ExtensionCommandContext) {
|
|
4112
|
-
const allNames = getAllTypes()
|
|
4113
|
-
if (allNames.length === 0) {
|
|
4114
|
-
ctx.ui.notify("No agents.", "info")
|
|
4115
|
-
return
|
|
4116
|
-
}
|
|
4117
|
-
|
|
4118
|
-
const configs = allNames.map((name) => getAgentConfig(name))
|
|
4119
|
-
|
|
4120
|
-
// One row per agent (name in the left column, model on the right); the
|
|
4121
|
-
// full description renders below the highlighted row via SettingsList,
|
|
4122
|
-
// exactly like the Settings menu — so long descriptions never wrap the list.
|
|
4123
|
-
// A package agent's description is prefixed with the package that provided
|
|
4124
|
-
// it: the `▪` badge says a package won, not which one.
|
|
4125
|
-
const items: SettingItem[] = allNames.map((name, i) => {
|
|
4126
|
-
const cfg = configs[i]
|
|
4127
|
-
const model = getModelLabel(name, ctx.modelRegistry)
|
|
4128
|
-
return {
|
|
4129
|
-
id: name,
|
|
4130
|
-
label: `${sourceIndicator(cfg)}${name}`,
|
|
4131
|
-
currentValue: model,
|
|
4132
|
-
description: rowDescription(name, cfg, packageNameOf(cfg)),
|
|
4133
|
-
// Single-value list so Enter "activates" the row (fires onChange with the
|
|
4134
|
-
// agent's id) without offering anything to actually cycle.
|
|
4135
|
-
values: [model],
|
|
4136
|
-
}
|
|
4137
|
-
})
|
|
4138
|
-
|
|
4139
|
-
const legend = sourceLegend(configs)
|
|
4140
|
-
|
|
4141
|
-
const selected = await ctx.ui.custom<string | undefined>(
|
|
4142
|
-
(_tui, _theme, _kb, done) => {
|
|
4143
|
-
const slTheme = getSettingsListTheme()
|
|
4144
|
-
const list = new SettingsList(
|
|
4145
|
-
items,
|
|
4146
|
-
Math.min(items.length, 12),
|
|
4147
|
-
slTheme,
|
|
4148
|
-
(id) => done(id), // Enter/Space on a row → return that agent's name
|
|
4149
|
-
() => done(undefined), // Esc → cancel
|
|
4150
|
-
)
|
|
4151
|
-
const container = new Container()
|
|
4152
|
-
container.addChild(new Text("Agent types", 0, 0))
|
|
4153
|
-
if (legend) container.addChild(new Text(slTheme.hint(legend), 0, 0))
|
|
4154
|
-
container.addChild(new Spacer(1))
|
|
4155
|
-
container.addChild(list)
|
|
4156
|
-
return {
|
|
4157
|
-
render: (w: number) => container.render(w),
|
|
4158
|
-
invalidate: () => container.invalidate(),
|
|
4159
|
-
handleInput: (data: string) => list.handleInput?.(data),
|
|
4160
|
-
}
|
|
4161
|
-
},
|
|
4162
|
-
)
|
|
4163
|
-
|
|
4164
|
-
if (selected && getAgentConfig(selected)) {
|
|
4165
|
-
await showAgentDetail(ctx, selected)
|
|
4166
|
-
await showAllAgentsList(ctx)
|
|
4167
|
-
}
|
|
4168
|
-
}
|
|
4169
|
-
|
|
4170
|
-
/**
|
|
4171
|
-
* The session's agents plus their nested children, as a tree (newest
|
|
4172
|
-
* top-level first). Nested children are listed here as in FleetView: this
|
|
4173
|
-
* list keeps finished agents until eviction, so it is where a finished child
|
|
4174
|
-
* stays reachable. Workflow agents stay in the workflow inspector.
|
|
4175
|
-
*/
|
|
4176
|
-
function runningAgentsRoster() {
|
|
4177
|
-
return agentTree(
|
|
4178
|
-
manager.listAgents().filter((a) => a.workflowId === undefined),
|
|
4179
|
-
)
|
|
4180
|
-
}
|
|
4181
|
-
|
|
4182
|
-
async function showRunningAgents(ctx: ExtensionCommandContext) {
|
|
4183
|
-
const rows = runningAgentsRoster()
|
|
4184
|
-
if (rows.length === 0) {
|
|
4185
|
-
ctx.ui.notify("No agents.", "info")
|
|
4186
|
-
return
|
|
4187
|
-
}
|
|
4188
|
-
|
|
4189
|
-
// Numbered + item-paired. Two same-type agents spawned together with the
|
|
4190
|
-
// same description render identically here, and resolving the choice by
|
|
4191
|
-
// string match would open whichever came first.
|
|
4192
|
-
const row = await selectItem(
|
|
4193
|
-
ctx.ui,
|
|
4194
|
-
"Running agents",
|
|
4195
|
-
rows,
|
|
4196
|
-
({ record: a, prefix }) => {
|
|
4197
|
-
const dn = getDisplayName(a.type)
|
|
4198
|
-
const dur = formatDuration(a.startedAt, a.completedAt)
|
|
4199
|
-
return `${prefix}${dn} (${a.description}) · ${a.toolUses} tools · ${a.status} · ${dur}`
|
|
4200
|
-
},
|
|
4201
|
-
)
|
|
4202
|
-
if (!row) return
|
|
4203
|
-
const record = row.record
|
|
4204
|
-
|
|
4205
|
-
await viewAgentConversation(ctx, record)
|
|
4206
|
-
// Back-navigation: re-show the list
|
|
4207
|
-
await showRunningAgents(ctx)
|
|
4208
|
-
}
|
|
4209
|
-
|
|
4210
4002
|
async function viewAgentConversation(
|
|
4211
4003
|
ctx: ExtensionCommandContext,
|
|
4212
4004
|
record: AgentRecord,
|
|
@@ -4256,430 +4048,6 @@ Terse command-style prompts produce shallow, generic work.
|
|
|
4256
4048
|
)
|
|
4257
4049
|
}
|
|
4258
4050
|
|
|
4259
|
-
async function showAgentDetail(ctx: ExtensionCommandContext, name: string) {
|
|
4260
|
-
const cfg = getAgentConfig(name)
|
|
4261
|
-
if (!cfg) {
|
|
4262
|
-
ctx.ui.notify(`Agent config not found for "${name}".`, "warning")
|
|
4263
|
-
return
|
|
4264
|
-
}
|
|
4265
|
-
|
|
4266
|
-
const isPackage = cfg.source === "package"
|
|
4267
|
-
const file = locateAgentFile(name, cfg.sourcePath, undefined, cfg.source)
|
|
4268
|
-
const isDefault = cfg.isDefault === true
|
|
4269
|
-
const disabled = cfg.enabled === false
|
|
4270
|
-
|
|
4271
|
-
let menuOptions: string[]
|
|
4272
|
-
if (isPackage) {
|
|
4273
|
-
// Read-only: nothing here may write inside pi's install root. `Disable`
|
|
4274
|
-
// still appears because it writes a *local* stub that shadows the package
|
|
4275
|
-
// agent, and `Enable` never does — a package agent that reads as disabled
|
|
4276
|
-
// was disabled by its own author's `enabled: false`, which only the
|
|
4277
|
-
// package can take back. Eject is the way out of that: the copy it writes
|
|
4278
|
-
// carries no `enabled:` line, so the ejected agent is on.
|
|
4279
|
-
menuOptions = disabled
|
|
4280
|
-
? ["Eject (export as .md)", "Back"]
|
|
4281
|
-
: ["Eject (export as .md)", "Disable", "Back"]
|
|
4282
|
-
} else if (disabled && file) {
|
|
4283
|
-
// Disabled agent with a file — offer Enable
|
|
4284
|
-
menuOptions = isDefault
|
|
4285
|
-
? ["Enable", "Edit", "Reset to default", "Delete", "Back"]
|
|
4286
|
-
: ["Enable", "Edit", "Delete", "Back"]
|
|
4287
|
-
} else if (isDefault && !file) {
|
|
4288
|
-
// Default agent with no .md override
|
|
4289
|
-
menuOptions = ["Eject (export as .md)", "Disable", "Back"]
|
|
4290
|
-
} else if (isDefault && file) {
|
|
4291
|
-
// Default agent with .md override (ejected)
|
|
4292
|
-
menuOptions = ["Edit", "Disable", "Reset to default", "Delete", "Back"]
|
|
4293
|
-
} else {
|
|
4294
|
-
// User-defined agent
|
|
4295
|
-
menuOptions = ["Edit", "Disable", "Delete", "Back"]
|
|
4296
|
-
}
|
|
4297
|
-
|
|
4298
|
-
// Name the package in the title: this menu's options are the read-only set,
|
|
4299
|
-
// and "which package do I have to uninstall or allowlist away" is the
|
|
4300
|
-
// question they raise.
|
|
4301
|
-
const pkgName = packageNameOf(cfg)
|
|
4302
|
-
const choice = await ctx.ui.select(
|
|
4303
|
-
pkgName ? `${name} — ${pkgName}` : name,
|
|
4304
|
-
menuOptions,
|
|
4305
|
-
)
|
|
4306
|
-
if (!choice || choice === "Back") return
|
|
4307
|
-
|
|
4308
|
-
if (choice === "Edit" && file) {
|
|
4309
|
-
const content = readFileSync(file.path, "utf-8")
|
|
4310
|
-
const edited = await ctx.ui.editor(`Edit ${name}`, content)
|
|
4311
|
-
if (edited !== undefined && edited !== content) {
|
|
4312
|
-
const { writeFileSync } = await import("node:fs")
|
|
4313
|
-
writeFileSync(file.path, edited, "utf-8")
|
|
4314
|
-
reloadCustomAgents()
|
|
4315
|
-
ctx.ui.notify(`Updated ${file.path}`, "info")
|
|
4316
|
-
}
|
|
4317
|
-
} else if (choice === "Delete") {
|
|
4318
|
-
if (file) {
|
|
4319
|
-
const confirmed = await ctx.ui.confirm(
|
|
4320
|
-
"Delete agent",
|
|
4321
|
-
`Delete ${name} from ${file.location} (${file.path})?`,
|
|
4322
|
-
)
|
|
4323
|
-
if (confirmed) {
|
|
4324
|
-
unlinkSync(file.path)
|
|
4325
|
-
reloadCustomAgents()
|
|
4326
|
-
ctx.ui.notify(`Deleted ${file.path}`, "info")
|
|
4327
|
-
}
|
|
4328
|
-
}
|
|
4329
|
-
} else if (choice === "Reset to default" && file) {
|
|
4330
|
-
const confirmed = await ctx.ui.confirm(
|
|
4331
|
-
"Reset to default",
|
|
4332
|
-
`Delete override ${file.path} and restore embedded default?`,
|
|
4333
|
-
)
|
|
4334
|
-
if (confirmed) {
|
|
4335
|
-
unlinkSync(file.path)
|
|
4336
|
-
reloadCustomAgents()
|
|
4337
|
-
ctx.ui.notify(`Restored default ${name}`, "info")
|
|
4338
|
-
}
|
|
4339
|
-
} else if (choice.startsWith("Eject")) {
|
|
4340
|
-
await ejectAgent(ctx, name, cfg)
|
|
4341
|
-
} else if (choice === "Disable") {
|
|
4342
|
-
await disableAgent(ctx, name)
|
|
4343
|
-
} else if (choice === "Enable") {
|
|
4344
|
-
await enableAgent(ctx, name)
|
|
4345
|
-
}
|
|
4346
|
-
}
|
|
4347
|
-
|
|
4348
|
-
/** Eject a default agent: write its embedded config as a .md file. */
|
|
4349
|
-
async function ejectAgent(
|
|
4350
|
-
ctx: ExtensionCommandContext,
|
|
4351
|
-
name: string,
|
|
4352
|
-
cfg: AgentConfig,
|
|
4353
|
-
) {
|
|
4354
|
-
const location = await ctx.ui.select("Choose location", [
|
|
4355
|
-
"Project (.pi/agents/)",
|
|
4356
|
-
`Personal (${personalAgentsDir()})`,
|
|
4357
|
-
])
|
|
4358
|
-
if (!location) return
|
|
4359
|
-
|
|
4360
|
-
const targetDir = location.startsWith("Project")
|
|
4361
|
-
? projectAgentsDir()
|
|
4362
|
-
: personalAgentsDir()
|
|
4363
|
-
mkdirSync(targetDir, { recursive: true })
|
|
4364
|
-
|
|
4365
|
-
const targetPath = join(targetDir, `${name}.md`)
|
|
4366
|
-
if (existsSync(targetPath)) {
|
|
4367
|
-
const overwrite = await ctx.ui.confirm(
|
|
4368
|
-
"Overwrite",
|
|
4369
|
-
`${targetPath} already exists. Overwrite?`,
|
|
4370
|
-
)
|
|
4371
|
-
if (!overwrite) return
|
|
4372
|
-
}
|
|
4373
|
-
|
|
4374
|
-
const content = serializeAgentFile(cfg)
|
|
4375
|
-
|
|
4376
|
-
const { writeFileSync } = await import("node:fs")
|
|
4377
|
-
writeFileSync(targetPath, content, "utf-8")
|
|
4378
|
-
reloadCustomAgents()
|
|
4379
|
-
ctx.ui.notify(`Ejected ${name} to ${targetPath}`, "info")
|
|
4380
|
-
}
|
|
4381
|
-
|
|
4382
|
-
/** Disable an agent: set enabled: false in its .md file, or create a stub for built-in defaults. */
|
|
4383
|
-
async function disableAgent(ctx: ExtensionCommandContext, name: string) {
|
|
4384
|
-
const cfg = getAgentConfig(name)
|
|
4385
|
-
// `locateAgentFile` refuses a package agent's own path, so this is either the
|
|
4386
|
-
// local stub already shadowing it or nothing — never a file inside pi's
|
|
4387
|
-
// install root. An unshadowed package agent therefore falls to the stub
|
|
4388
|
-
// branch below, which writes `enabled: false` at project or personal scope.
|
|
4389
|
-
const file = locateAgentFile(name, cfg?.sourcePath, undefined, cfg?.source)
|
|
4390
|
-
if (file) {
|
|
4391
|
-
// Existing file — set enabled: false in frontmatter (idempotent)
|
|
4392
|
-
const content = readFileSync(file.path, "utf-8")
|
|
4393
|
-
const { content: updated, outcome } = disableInContent(content)
|
|
4394
|
-
if (outcome === "already-disabled") {
|
|
4395
|
-
ctx.ui.notify(`${name} is already disabled.`, "info")
|
|
4396
|
-
return
|
|
4397
|
-
}
|
|
4398
|
-
if (outcome === "no-frontmatter") {
|
|
4399
|
-
// Nothing to edit — say so rather than rewriting the file unchanged and
|
|
4400
|
-
// reporting success for a change that never happened.
|
|
4401
|
-
ctx.ui.notify(
|
|
4402
|
-
`Cannot disable ${name}: ${file.path} has no frontmatter block.`,
|
|
4403
|
-
"error",
|
|
4404
|
-
)
|
|
4405
|
-
return
|
|
4406
|
-
}
|
|
4407
|
-
const { writeFileSync } = await import("node:fs")
|
|
4408
|
-
writeFileSync(file.path, updated, "utf-8")
|
|
4409
|
-
reloadCustomAgents()
|
|
4410
|
-
ctx.ui.notify(`Disabled ${name} (${file.path})`, "info")
|
|
4411
|
-
return
|
|
4412
|
-
}
|
|
4413
|
-
|
|
4414
|
-
// No editable file (a built-in default, or a package-provided agent) —
|
|
4415
|
-
// create a stub that shadows it.
|
|
4416
|
-
const location = await ctx.ui.select("Choose location", [
|
|
4417
|
-
"Project (.pi/agents/)",
|
|
4418
|
-
`Personal (${personalAgentsDir()})`,
|
|
4419
|
-
])
|
|
4420
|
-
if (!location) return
|
|
4421
|
-
|
|
4422
|
-
const targetDir = location.startsWith("Project")
|
|
4423
|
-
? projectAgentsDir()
|
|
4424
|
-
: personalAgentsDir()
|
|
4425
|
-
mkdirSync(targetDir, { recursive: true })
|
|
4426
|
-
|
|
4427
|
-
const targetPath = join(targetDir, `${name}.md`)
|
|
4428
|
-
const { writeFileSync } = await import("node:fs")
|
|
4429
|
-
writeFileSync(targetPath, "---\nenabled: false\n---\n", "utf-8")
|
|
4430
|
-
reloadCustomAgents()
|
|
4431
|
-
ctx.ui.notify(`Disabled ${name} (${targetPath})`, "info")
|
|
4432
|
-
}
|
|
4433
|
-
|
|
4434
|
-
/** Enable a disabled agent by removing enabled: false from its frontmatter. */
|
|
4435
|
-
async function enableAgent(ctx: ExtensionCommandContext, name: string) {
|
|
4436
|
-
const cfg = getAgentConfig(name)
|
|
4437
|
-
const file = locateAgentFile(name, cfg?.sourcePath, undefined, cfg?.source)
|
|
4438
|
-
if (!file) return
|
|
4439
|
-
|
|
4440
|
-
const content = readFileSync(file.path, "utf-8")
|
|
4441
|
-
const { content: updated, changed } = enableInContent(content)
|
|
4442
|
-
if (!changed && !isEmptyStub(updated)) {
|
|
4443
|
-
// The file carries no `enabled: false` to remove, so it was never disabled
|
|
4444
|
-
// by us — reporting success here would hide a no-op.
|
|
4445
|
-
ctx.ui.notify(`${name} is not disabled in ${file.path}.`, "info")
|
|
4446
|
-
return
|
|
4447
|
-
}
|
|
4448
|
-
const { writeFileSync } = await import("node:fs")
|
|
4449
|
-
|
|
4450
|
-
// If the file was just a stub ("---\n---\n"), delete it to restore the built-in default
|
|
4451
|
-
if (isEmptyStub(updated)) {
|
|
4452
|
-
unlinkSync(file.path)
|
|
4453
|
-
reloadCustomAgents()
|
|
4454
|
-
ctx.ui.notify(`Enabled ${name} (removed ${file.path})`, "info")
|
|
4455
|
-
} else {
|
|
4456
|
-
writeFileSync(file.path, updated, "utf-8")
|
|
4457
|
-
reloadCustomAgents()
|
|
4458
|
-
ctx.ui.notify(`Enabled ${name} (${file.path})`, "info")
|
|
4459
|
-
}
|
|
4460
|
-
}
|
|
4461
|
-
|
|
4462
|
-
async function showCreateWizard(ctx: ExtensionCommandContext) {
|
|
4463
|
-
const location = await ctx.ui.select("Choose location", [
|
|
4464
|
-
"Project (.pi/agents/)",
|
|
4465
|
-
`Personal (${personalAgentsDir()})`,
|
|
4466
|
-
])
|
|
4467
|
-
if (!location) return
|
|
4468
|
-
|
|
4469
|
-
const targetDir = location.startsWith("Project")
|
|
4470
|
-
? projectAgentsDir()
|
|
4471
|
-
: personalAgentsDir()
|
|
4472
|
-
|
|
4473
|
-
const method = await ctx.ui.select("Creation method", [
|
|
4474
|
-
"Generate with Claude (recommended)",
|
|
4475
|
-
"Manual configuration",
|
|
4476
|
-
])
|
|
4477
|
-
if (!method) return
|
|
4478
|
-
|
|
4479
|
-
if (method.startsWith("Generate")) {
|
|
4480
|
-
await showGenerateWizard(ctx, targetDir)
|
|
4481
|
-
} else {
|
|
4482
|
-
await showManualWizard(ctx, targetDir)
|
|
4483
|
-
}
|
|
4484
|
-
}
|
|
4485
|
-
|
|
4486
|
-
async function showGenerateWizard(
|
|
4487
|
-
ctx: ExtensionCommandContext,
|
|
4488
|
-
targetDir: string,
|
|
4489
|
-
) {
|
|
4490
|
-
const description = await ctx.ui.input("Describe what this agent should do")
|
|
4491
|
-
if (!description) return
|
|
4492
|
-
|
|
4493
|
-
const name = await ctx.ui.input("Agent name (filename, no spaces)")
|
|
4494
|
-
if (!name) return
|
|
4495
|
-
|
|
4496
|
-
mkdirSync(targetDir, { recursive: true })
|
|
4497
|
-
|
|
4498
|
-
const targetPath = join(targetDir, `${name}.md`)
|
|
4499
|
-
if (existsSync(targetPath)) {
|
|
4500
|
-
const overwrite = await ctx.ui.confirm(
|
|
4501
|
-
"Overwrite",
|
|
4502
|
-
`${targetPath} already exists. Overwrite?`,
|
|
4503
|
-
)
|
|
4504
|
-
if (!overwrite) return
|
|
4505
|
-
}
|
|
4506
|
-
|
|
4507
|
-
ctx.ui.notify("Generating agent definition...", "info")
|
|
4508
|
-
|
|
4509
|
-
const generatePrompt = `Create a custom pi sub-agent definition file based on this description: "${description}"
|
|
4510
|
-
|
|
4511
|
-
Write a markdown file to: ${targetPath}
|
|
4512
|
-
|
|
4513
|
-
The file format is a markdown file with YAML frontmatter and a system prompt body:
|
|
4514
|
-
|
|
4515
|
-
\`\`\`markdown
|
|
4516
|
-
---
|
|
4517
|
-
description: <one-line description shown in UI>
|
|
4518
|
-
color: <optional agent name badge color: red, blue, green, yellow, purple, orange, pink, cyan, an Agency Agents alias, or quoted "#RRGGBB">
|
|
4519
|
-
tools: <comma-separated built-in tools: read, bash, edit, write, grep, find, ls. Use "none" for no tools. Omit for all tools>
|
|
4520
|
-
model: <optional model as "provider/modelId", e.g. "anthropic/claude-haiku-4-5". Omit to inherit parent model>
|
|
4521
|
-
thinking: <optional thinking level: ${THINKING_LEVELS.join(", ")}. Omit to inherit>
|
|
4522
|
-
max_turns: <optional max agentic turns. 0 or omit for unlimited (default)>
|
|
4523
|
-
prompt_mode: <"replace" (body IS the full system prompt) or "append" (body is appended to default prompt). Default: replace>
|
|
4524
|
-
extensions: <true (inherit all MCP/extension tools), false (none), or comma-separated names. Default: true>
|
|
4525
|
-
skills: <true (inherit all), false (none), or comma-separated skill names to preload into prompt. Default: true>
|
|
4526
|
-
disallowed_tools: <comma-separated tool names to block, even if otherwise available. Omit for none>
|
|
4527
|
-
inherit_context: <true to fork parent conversation into agent so it sees chat history. Default: false>
|
|
4528
|
-
run_in_background: <pin this agent to background (true) or foreground (false). Omit to follow the backgroundByDefault setting, which is background>
|
|
4529
|
-
output_transcript: <false to write no transcript file or path for this agent. Independent of persist_session. Default: true>
|
|
4530
|
-
isolated: <true for no extension/MCP tools, only built-in tools. Default: false>
|
|
4531
|
-
memory: <"user" (global), "project" (per-project), or "local" (gitignored per-project) for persistent memory. Omit for none>${
|
|
4532
|
-
// Offering the field on a project that turned worktrees off would bake a
|
|
4533
|
-
// request that is refused at spawn time into a file that outlives the
|
|
4534
|
-
// session — the #231 pathology (models fill the fields they are shown)
|
|
4535
|
-
// one layer up. Built per invocation, so this read is live.
|
|
4536
|
-
isWorktreeIsolationEnabled()
|
|
4537
|
-
? `\nisolation: <"worktree" to run in isolated git worktree; "off" to refuse one even when the caller asks. Omit for normal>`
|
|
4538
|
-
: ""
|
|
4539
|
-
}
|
|
4540
|
-
---
|
|
4541
|
-
|
|
4542
|
-
<system prompt body — instructions for the agent>
|
|
4543
|
-
\`\`\`
|
|
4544
|
-
|
|
4545
|
-
Guidelines for choosing settings:
|
|
4546
|
-
- For read-only tasks (review, analysis): tools: read, bash, grep, find, ls
|
|
4547
|
-
- For code modification tasks: include edit, write
|
|
4548
|
-
- Use prompt_mode: append if the agent should keep the default system prompt and add specialization on top
|
|
4549
|
-
- Use prompt_mode: replace for fully custom agents with their own personality/instructions
|
|
4550
|
-
- Set inherit_context: true if the agent needs to know what was discussed in the parent conversation
|
|
4551
|
-
- Set isolated: true if the agent should NOT have access to MCP servers or other extensions
|
|
4552
|
-
- Set output_transcript: false to skip writing this agent's transcript; this alone doesn't keep the run off disk (persist_session, isolation: worktree commits, and memory still write) — set those too if that's the goal
|
|
4553
|
-
- Only include frontmatter fields that differ from defaults — omit fields where the default is fine
|
|
4554
|
-
|
|
4555
|
-
Write the file using the write tool. Only write the file, nothing else.`
|
|
4556
|
-
|
|
4557
|
-
const { record } = await manager.spawnAndWait(
|
|
4558
|
-
pi,
|
|
4559
|
-
ctx,
|
|
4560
|
-
"general-purpose",
|
|
4561
|
-
generatePrompt,
|
|
4562
|
-
{
|
|
4563
|
-
description: `Generate ${name} agent`,
|
|
4564
|
-
maxTurns: 5,
|
|
4565
|
-
// Exempt from maxConcurrentForeground. This runs from a modal wizard, not
|
|
4566
|
-
// a tool call: it passes no signal, and Esc in `ctx.ui` never reaches the
|
|
4567
|
-
// manager — so a user waiting behind a full pool would have no way to
|
|
4568
|
-
// cancel at all. It is also one human action that cannot fan out, which
|
|
4569
|
-
// is what the limit exists to bound. It still counts once started.
|
|
4570
|
-
bypassQueue: true,
|
|
4571
|
-
},
|
|
4572
|
-
)
|
|
4573
|
-
|
|
4574
|
-
if (record.status === "error") {
|
|
4575
|
-
ctx.ui.notify(`Generation failed: ${record.error}`, "warning")
|
|
4576
|
-
return
|
|
4577
|
-
}
|
|
4578
|
-
|
|
4579
|
-
reloadCustomAgents()
|
|
4580
|
-
|
|
4581
|
-
if (existsSync(targetPath)) {
|
|
4582
|
-
ctx.ui.notify(`Created ${targetPath}`, "info")
|
|
4583
|
-
} else {
|
|
4584
|
-
ctx.ui.notify(
|
|
4585
|
-
"Agent generation completed but file was not created. Check the agent output.",
|
|
4586
|
-
"warning",
|
|
4587
|
-
)
|
|
4588
|
-
}
|
|
4589
|
-
}
|
|
4590
|
-
|
|
4591
|
-
async function showManualWizard(
|
|
4592
|
-
ctx: ExtensionCommandContext,
|
|
4593
|
-
targetDir: string,
|
|
4594
|
-
) {
|
|
4595
|
-
// 1. Name
|
|
4596
|
-
const name = await ctx.ui.input("Agent name (filename, no spaces)")
|
|
4597
|
-
if (!name) return
|
|
4598
|
-
|
|
4599
|
-
// 2. Description
|
|
4600
|
-
const description = await ctx.ui.input("Description (one line)")
|
|
4601
|
-
if (!description) return
|
|
4602
|
-
|
|
4603
|
-
// 3. Tools
|
|
4604
|
-
const toolChoice = await ctx.ui.select("Tools", [
|
|
4605
|
-
"all",
|
|
4606
|
-
"none",
|
|
4607
|
-
"read-only (read, bash, grep, find, ls)",
|
|
4608
|
-
"custom...",
|
|
4609
|
-
])
|
|
4610
|
-
if (!toolChoice) return
|
|
4611
|
-
|
|
4612
|
-
let tools: string
|
|
4613
|
-
if (toolChoice === "all") {
|
|
4614
|
-
tools = BUILTIN_TOOL_NAMES.join(", ")
|
|
4615
|
-
} else if (toolChoice === "none") {
|
|
4616
|
-
tools = "none"
|
|
4617
|
-
} else if (toolChoice.startsWith("read-only")) {
|
|
4618
|
-
tools = "read, bash, grep, find, ls"
|
|
4619
|
-
} else {
|
|
4620
|
-
const customTools = await ctx.ui.input(
|
|
4621
|
-
"Tools (comma-separated)",
|
|
4622
|
-
BUILTIN_TOOL_NAMES.join(", "),
|
|
4623
|
-
)
|
|
4624
|
-
if (!customTools) return
|
|
4625
|
-
tools = customTools
|
|
4626
|
-
}
|
|
4627
|
-
|
|
4628
|
-
// 4. Model
|
|
4629
|
-
const modelChoice = await ctx.ui.select("Model", [
|
|
4630
|
-
"inherit (parent model)",
|
|
4631
|
-
"haiku",
|
|
4632
|
-
"sonnet",
|
|
4633
|
-
"opus",
|
|
4634
|
-
"custom...",
|
|
4635
|
-
])
|
|
4636
|
-
if (!modelChoice) return
|
|
4637
|
-
|
|
4638
|
-
let model: string | undefined
|
|
4639
|
-
if (modelChoice === "haiku") model = "anthropic/claude-haiku-4-5"
|
|
4640
|
-
else if (modelChoice === "sonnet") model = "anthropic/claude-sonnet-4-6"
|
|
4641
|
-
else if (modelChoice === "opus") model = "anthropic/claude-opus-4-6"
|
|
4642
|
-
else if (modelChoice === "custom...") {
|
|
4643
|
-
model = (await ctx.ui.input("Model (provider/modelId)")) || undefined
|
|
4644
|
-
}
|
|
4645
|
-
|
|
4646
|
-
// 5. Thinking
|
|
4647
|
-
// "inherit" is a UI-only pseudo-choice (omit the field); the rest mirror pi.
|
|
4648
|
-
const thinkingChoice = await ctx.ui.select("Thinking level", [
|
|
4649
|
-
"inherit",
|
|
4650
|
-
...THINKING_LEVELS,
|
|
4651
|
-
])
|
|
4652
|
-
if (!thinkingChoice) return
|
|
4653
|
-
|
|
4654
|
-
// 6. System prompt
|
|
4655
|
-
const systemPrompt = await ctx.ui.editor("System prompt", "")
|
|
4656
|
-
if (systemPrompt === undefined) return
|
|
4657
|
-
|
|
4658
|
-
const content = buildNewAgentFile({
|
|
4659
|
-
description,
|
|
4660
|
-
tools,
|
|
4661
|
-
model,
|
|
4662
|
-
thinking: thinkingChoice === "inherit" ? undefined : thinkingChoice,
|
|
4663
|
-
systemPrompt,
|
|
4664
|
-
})
|
|
4665
|
-
|
|
4666
|
-
mkdirSync(targetDir, { recursive: true })
|
|
4667
|
-
const targetPath = join(targetDir, `${name}.md`)
|
|
4668
|
-
|
|
4669
|
-
if (existsSync(targetPath)) {
|
|
4670
|
-
const overwrite = await ctx.ui.confirm(
|
|
4671
|
-
"Overwrite",
|
|
4672
|
-
`${targetPath} already exists. Overwrite?`,
|
|
4673
|
-
)
|
|
4674
|
-
if (!overwrite) return
|
|
4675
|
-
}
|
|
4676
|
-
|
|
4677
|
-
const { writeFileSync } = await import("node:fs")
|
|
4678
|
-
writeFileSync(targetPath, content, "utf-8")
|
|
4679
|
-
reloadCustomAgents()
|
|
4680
|
-
ctx.ui.notify(`Created ${targetPath}`, "info")
|
|
4681
|
-
}
|
|
4682
|
-
|
|
4683
4051
|
/**
|
|
4684
4052
|
* Every settings mutation writes this WHOLE object back to disk, so a field
|
|
4685
4053
|
* missing here is erased from the user's subagents.json the next time they
|
|
@@ -4749,6 +4117,35 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4749
4117
|
const _settingsSnapshotIsComplete: _NoMissingSettingsKeys = true
|
|
4750
4118
|
void _settingsSnapshotIsComplete
|
|
4751
4119
|
|
|
4120
|
+
// The settings as last persisted (or as loaded at startup). A save writes
|
|
4121
|
+
// only the keys that differ from it, so a change here cannot revert what
|
|
4122
|
+
// another pi session saved to the shared global file, and untouched
|
|
4123
|
+
// defaults are never frozen into a file.
|
|
4124
|
+
let savedSnapshot: SubagentsSettings = snapshotSettings()
|
|
4125
|
+
|
|
4126
|
+
/** Where a Settings-page change goes: the chosen file, and the setting it set. */
|
|
4127
|
+
type SettingsTarget = { scope: SettingsScope; key?: keyof SubagentsSettings }
|
|
4128
|
+
|
|
4129
|
+
/** Persist + broadcast what changed since the last save; the toast to show. */
|
|
4130
|
+
function saveSnapshot(
|
|
4131
|
+
successMsg: string,
|
|
4132
|
+
target?: SettingsTarget,
|
|
4133
|
+
): { message: string; level: "info" | "warning" } {
|
|
4134
|
+
const snapshot = snapshotSettings()
|
|
4135
|
+
const { persisted, ...toast } = saveAndEmitChanged(
|
|
4136
|
+
snapshot,
|
|
4137
|
+
savedSnapshot,
|
|
4138
|
+
successMsg,
|
|
4139
|
+
(event, payload) => pi.events.emit(event, payload),
|
|
4140
|
+
process.cwd(),
|
|
4141
|
+
target?.scope,
|
|
4142
|
+
target?.key ? { [target.key]: snapshot[target.key] } : {},
|
|
4143
|
+
)
|
|
4144
|
+
// A failed write keeps the old baseline, so the next save retries this change.
|
|
4145
|
+
if (persisted) savedSnapshot = snapshot
|
|
4146
|
+
return toast
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4752
4149
|
/**
|
|
4753
4150
|
* Whether a package gate lets anything through. `undefined` is the unset
|
|
4754
4151
|
* default and reads as `true`; an empty allowlist matches nothing, like
|
|
@@ -4778,16 +4175,38 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4778
4175
|
: `${base} Currently limited to an empty list, so nothing loads.`
|
|
4779
4176
|
}
|
|
4780
4177
|
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
"
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4178
|
+
// The setting a row shows: its id, except Join mode's.
|
|
4179
|
+
const settingKeyOf = (id: string) =>
|
|
4180
|
+
(id === "joinMode" ? "defaultJoinMode" : id) as keyof SubagentsSettings
|
|
4181
|
+
|
|
4182
|
+
/**
|
|
4183
|
+
* Put one setting back to `value`, the value loading gives once Del has
|
|
4184
|
+
* removed it from a file; `undefined` unsets it. Carries the side effects
|
|
4185
|
+
* the Settings rows carry when they change the same setting.
|
|
4186
|
+
*/
|
|
4187
|
+
function resetSetting(key: keyof SubagentsSettings, value: unknown) {
|
|
4188
|
+
if (value !== undefined)
|
|
4189
|
+
applySettings({ [key]: value } as SubagentsSettings, settingsAppliers)
|
|
4190
|
+
else if (key === "fallbackSubagent") setFallbackSubagent(undefined)
|
|
4191
|
+
else if (key === "packageAgents") setPackageAgentsGate(undefined)
|
|
4192
|
+
else if (key === "packageWorkflows") setPackageWorkflowsGate(undefined)
|
|
4193
|
+
else if (key === "workflowsEnabled") {
|
|
4194
|
+
// On, and no longer the user's answer: the next session may yield it to
|
|
4195
|
+
// another extension's workflow tool again.
|
|
4196
|
+
workflowsEnabled = true
|
|
4197
|
+
workflowsPinned = false
|
|
4198
|
+
}
|
|
4199
|
+
if (key === "packageAgents" || key === "packageWorkflows")
|
|
4200
|
+
reloadCustomAgents()
|
|
4201
|
+
if (key === "schedulingEnabled" && !isSchedulingEnabled()) scheduler.stop()
|
|
4202
|
+
}
|
|
4789
4203
|
|
|
4204
|
+
/**
|
|
4205
|
+
* `scope` is the file changes are written to. It starts at the default rule
|
|
4206
|
+
* and Tab switches it; the list always shows the effective (merged) values.
|
|
4207
|
+
*/
|
|
4790
4208
|
async function showSettings(ctx: ExtensionCommandContext) {
|
|
4209
|
+
let scope: SettingsScope = defaultSettingsScope(process.cwd())
|
|
4791
4210
|
function buildItems(): SettingItem[] {
|
|
4792
4211
|
const mc = manager.getMaxConcurrent()
|
|
4793
4212
|
const mcf = manager.getMaxConcurrentForeground()
|
|
@@ -4803,6 +4222,8 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4803
4222
|
const fallbackValue = getFallbackSubagent() ?? "general-purpose"
|
|
4804
4223
|
const fallbackValues = [...new Set([...getAvailableTypes(), NO_FALLBACK])]
|
|
4805
4224
|
|
|
4225
|
+
// Ordered by category, with no header rows (every row stays a setting the
|
|
4226
|
+
// filter can match): limits, dispatch, features, agent files, display.
|
|
4806
4227
|
return [
|
|
4807
4228
|
{
|
|
4808
4229
|
id: "maxConcurrent",
|
|
@@ -4832,7 +4253,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4832
4253
|
id: "maxSubagentDepth",
|
|
4833
4254
|
label: "Nested depth",
|
|
4834
4255
|
description:
|
|
4835
|
-
"Hard cap on nested delegation — main is 0, its subagents 1 (0/1 = nesting off, Enter to type)",
|
|
4256
|
+
"Hard cap on nested delegation — main is 0, its subagents 1 (0/1 = nesting off, even with allowed_subagents; Enter to type)",
|
|
4836
4257
|
currentValue: String(msd),
|
|
4837
4258
|
values: [String(msd)],
|
|
4838
4259
|
},
|
|
@@ -4868,6 +4289,37 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4868
4289
|
currentValue: getBackgroundByDefault() ? "on" : "off",
|
|
4869
4290
|
values: ["on", "off"],
|
|
4870
4291
|
},
|
|
4292
|
+
{
|
|
4293
|
+
id: "fallbackSubagent",
|
|
4294
|
+
label: "Fallback agent",
|
|
4295
|
+
description: `Agent used when subagent_type is unknown, disabled, or ambiguous; "${NO_FALLBACK}" rejects the call instead (strict dispatch)`,
|
|
4296
|
+
currentValue: fallbackValue,
|
|
4297
|
+
values: fallbackValues,
|
|
4298
|
+
},
|
|
4299
|
+
{
|
|
4300
|
+
id: "disableDefaultAgents",
|
|
4301
|
+
label: "Disable defaults",
|
|
4302
|
+
description:
|
|
4303
|
+
"Hide built-in agents (general-purpose, Explore, Plan) — custom agents are unaffected",
|
|
4304
|
+
currentValue: isDefaultsDisabled() ? "on" : "off",
|
|
4305
|
+
values: ["on", "off"],
|
|
4306
|
+
},
|
|
4307
|
+
{
|
|
4308
|
+
id: "scopeModels",
|
|
4309
|
+
label: "Scope models",
|
|
4310
|
+
description:
|
|
4311
|
+
"Validate subagent models against scoped models (/scoped-models)",
|
|
4312
|
+
currentValue: isScopeModelsEnabled() ? "on" : "off",
|
|
4313
|
+
values: ["on", "off"],
|
|
4314
|
+
},
|
|
4315
|
+
{
|
|
4316
|
+
id: "toolDescriptionMode",
|
|
4317
|
+
label: "Tool description",
|
|
4318
|
+
description:
|
|
4319
|
+
"Agent tool description sent to the LLM: full (rich, default), compact (~75% fewer tokens, for small/local models), or custom (.pi/agent-tool-description.md with {{placeholders}})",
|
|
4320
|
+
currentValue: getToolDescriptionMode(),
|
|
4321
|
+
values: ["full", "compact", "custom"],
|
|
4322
|
+
},
|
|
4871
4323
|
{
|
|
4872
4324
|
id: "schedulingEnabled",
|
|
4873
4325
|
label: "Scheduling",
|
|
@@ -4885,6 +4337,30 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4885
4337
|
currentValue: isWorkflowsEnabled() ? "on" : "off",
|
|
4886
4338
|
values: ["on", "off"],
|
|
4887
4339
|
},
|
|
4340
|
+
{
|
|
4341
|
+
id: "worktreeIsolation",
|
|
4342
|
+
label: "Worktree isolation",
|
|
4343
|
+
description:
|
|
4344
|
+
"Allow isolation: worktree to copy the repo. Off refuses worktrees on every path immediately — for repos where a copy costs too much time or disk — and drops the `isolation` param from the Agent tool spec on next pi session.",
|
|
4345
|
+
currentValue: isWorktreeIsolationEnabled() ? "on" : "off",
|
|
4346
|
+
values: ["on", "off"],
|
|
4347
|
+
},
|
|
4348
|
+
{
|
|
4349
|
+
id: "agentMentions",
|
|
4350
|
+
label: "Agent mentions",
|
|
4351
|
+
description:
|
|
4352
|
+
"Route `@handle message` at the prompt to that agent. model = an off-screen clone of this conversation calls the Agent tool, so the agent gets a context-written prompt, a transcript and per-tool detail, and the chat stays clean; direct = started here from your text, no model call. Messaging and resuming are direct either way.",
|
|
4353
|
+
currentValue: getAgentMentionMode(),
|
|
4354
|
+
values: ["model", "direct", "off"],
|
|
4355
|
+
},
|
|
4356
|
+
{
|
|
4357
|
+
id: "rememberAgents",
|
|
4358
|
+
label: "Remember agents",
|
|
4359
|
+
description:
|
|
4360
|
+
"Persist subagent sessions so `@handle` can resume one long after it finished (they also appear in /resume)",
|
|
4361
|
+
currentValue: getRememberAgents() ? "on" : "off",
|
|
4362
|
+
values: ["on", "off"],
|
|
4363
|
+
},
|
|
4888
4364
|
{
|
|
4889
4365
|
id: "packageAgents",
|
|
4890
4366
|
label: "Package agents",
|
|
@@ -4911,14 +4387,6 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4911
4387
|
: "off",
|
|
4912
4388
|
values: ["on", "off"],
|
|
4913
4389
|
},
|
|
4914
|
-
{
|
|
4915
|
-
id: "scopeModels",
|
|
4916
|
-
label: "Scope models",
|
|
4917
|
-
description:
|
|
4918
|
-
"Validate subagent models against scoped models (/scoped-models)",
|
|
4919
|
-
currentValue: isScopeModelsEnabled() ? "on" : "off",
|
|
4920
|
-
values: ["on", "off"],
|
|
4921
|
-
},
|
|
4922
4390
|
{
|
|
4923
4391
|
id: "strictAgentFiles",
|
|
4924
4392
|
label: "Strict agent files",
|
|
@@ -4927,21 +4395,6 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4927
4395
|
currentValue: strictAgentFiles ? "on" : "off",
|
|
4928
4396
|
values: ["on", "off"],
|
|
4929
4397
|
},
|
|
4930
|
-
{
|
|
4931
|
-
id: "disableDefaultAgents",
|
|
4932
|
-
label: "Disable defaults",
|
|
4933
|
-
description:
|
|
4934
|
-
"Hide built-in agents (general-purpose, Explore, Plan) — custom agents are unaffected",
|
|
4935
|
-
currentValue: isDefaultsDisabled() ? "on" : "off",
|
|
4936
|
-
values: ["on", "off"],
|
|
4937
|
-
},
|
|
4938
|
-
{
|
|
4939
|
-
id: "fallbackSubagent",
|
|
4940
|
-
label: "Fallback agent",
|
|
4941
|
-
description: `Agent used when subagent_type is unknown, disabled, or ambiguous; "${NO_FALLBACK}" rejects the call instead (strict dispatch)`,
|
|
4942
|
-
currentValue: fallbackValue,
|
|
4943
|
-
values: fallbackValues,
|
|
4944
|
-
},
|
|
4945
4398
|
{
|
|
4946
4399
|
id: "outputTranscript",
|
|
4947
4400
|
label: "Output transcript",
|
|
@@ -4951,19 +4404,27 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4951
4404
|
values: ["on", "off"],
|
|
4952
4405
|
},
|
|
4953
4406
|
{
|
|
4954
|
-
id: "
|
|
4955
|
-
label: "
|
|
4407
|
+
id: "widgetMode",
|
|
4408
|
+
label: "Widget",
|
|
4956
4409
|
description:
|
|
4957
|
-
"
|
|
4958
|
-
currentValue:
|
|
4410
|
+
"Above-editor agent widget: all = every agent; background = hide foreground (they already render inline); off = hide the widget.",
|
|
4411
|
+
currentValue: getWidgetMode(),
|
|
4412
|
+
values: ["all", "background", "off"],
|
|
4413
|
+
},
|
|
4414
|
+
{
|
|
4415
|
+
id: "fleetView",
|
|
4416
|
+
label: "Fleet view",
|
|
4417
|
+
description:
|
|
4418
|
+
"Claude Code-style main+subagents list below the editor (↓/← to navigate, Enter to view)",
|
|
4419
|
+
currentValue: isFleetViewEnabled() ? "on" : "off",
|
|
4959
4420
|
values: ["on", "off"],
|
|
4960
4421
|
},
|
|
4961
4422
|
{
|
|
4962
|
-
id: "
|
|
4963
|
-
label: "
|
|
4423
|
+
id: "showModel",
|
|
4424
|
+
label: "Show model",
|
|
4964
4425
|
description:
|
|
4965
|
-
"
|
|
4966
|
-
currentValue:
|
|
4426
|
+
"Name the model driving each agent, and the thinking level it is running at, on the widget's running rows and the fleet view rows. The Agent tool result and the conversation viewer show the pair either way — this adds it where the rows are already dense.",
|
|
4427
|
+
currentValue: isShowModelEnabled() ? "on" : "off",
|
|
4967
4428
|
values: ["on", "off"],
|
|
4968
4429
|
},
|
|
4969
4430
|
{
|
|
@@ -4974,14 +4435,6 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4974
4435
|
currentValue: isShowCostEnabled() ? "on" : "off",
|
|
4975
4436
|
values: ["on", "off"],
|
|
4976
4437
|
},
|
|
4977
|
-
{
|
|
4978
|
-
id: "showModel",
|
|
4979
|
-
label: "Show model",
|
|
4980
|
-
description:
|
|
4981
|
-
"Name the model driving each agent, and the thinking level it is running at, on the widget's running rows and the fleet view rows. The Agent tool result and the conversation viewer show the pair either way — this adds it where the rows are already dense.",
|
|
4982
|
-
currentValue: isShowModelEnabled() ? "on" : "off",
|
|
4983
|
-
values: ["on", "off"],
|
|
4984
|
-
},
|
|
4985
4438
|
{
|
|
4986
4439
|
id: "viewerMarkdown",
|
|
4987
4440
|
label: "Viewer markdown",
|
|
@@ -4991,54 +4444,29 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4991
4444
|
values: ["off", "assistant", "all"],
|
|
4992
4445
|
},
|
|
4993
4446
|
{
|
|
4994
|
-
id: "
|
|
4995
|
-
label: "
|
|
4996
|
-
description:
|
|
4997
|
-
"Claude Code-style main+subagents list below the editor (↓/← to navigate, Enter to view)",
|
|
4998
|
-
currentValue: isFleetViewEnabled() ? "on" : "off",
|
|
4999
|
-
values: ["on", "off"],
|
|
5000
|
-
},
|
|
5001
|
-
{
|
|
5002
|
-
id: "agentMentions",
|
|
5003
|
-
label: "Agent mentions",
|
|
5004
|
-
description:
|
|
5005
|
-
"Route `@handle message` at the prompt to that agent. model = an off-screen clone of this conversation calls the Agent tool, so the agent gets a context-written prompt, a transcript and per-tool detail, and the chat stays clean; direct = started here from your text, no model call. Messaging and resuming are direct either way.",
|
|
5006
|
-
currentValue: getAgentMentionMode(),
|
|
5007
|
-
values: ["model", "direct", "off"],
|
|
5008
|
-
},
|
|
5009
|
-
{
|
|
5010
|
-
id: "rememberAgents",
|
|
5011
|
-
label: "Remember agents",
|
|
4447
|
+
id: "reportUsage",
|
|
4448
|
+
label: "Report usage to session",
|
|
5012
4449
|
description:
|
|
5013
|
-
"
|
|
5014
|
-
currentValue:
|
|
4450
|
+
"Add subagent tokens and cost to this session's own totals, so pi's footer and /cost stop reading a delegating session as nearly free. Reported on the next tool result (agents that finish in the background are counted on the one after). Context-window % is unaffected.",
|
|
4451
|
+
currentValue: isReportUsageEnabled() ? "on" : "off",
|
|
5015
4452
|
values: ["on", "off"],
|
|
5016
4453
|
},
|
|
5017
|
-
{
|
|
5018
|
-
id: "widgetMode",
|
|
5019
|
-
label: "Widget",
|
|
5020
|
-
description:
|
|
5021
|
-
"Above-editor agent widget: all = every agent; background = hide foreground (they already render inline); off = hide the widget.",
|
|
5022
|
-
currentValue: getWidgetMode(),
|
|
5023
|
-
values: ["all", "background", "off"],
|
|
5024
|
-
},
|
|
5025
|
-
{
|
|
5026
|
-
id: "toolDescriptionMode",
|
|
5027
|
-
label: "Tool description",
|
|
5028
|
-
description:
|
|
5029
|
-
"Agent tool description sent to the LLM: full (rich, default), compact (~75% fewer tokens, for small/local models), or custom (.pi/agent-tool-description.md with {{placeholders}})",
|
|
5030
|
-
currentValue: getToolDescriptionMode(),
|
|
5031
|
-
values: ["full", "compact", "custom"],
|
|
5032
|
-
},
|
|
5033
4454
|
]
|
|
5034
4455
|
}
|
|
5035
4456
|
|
|
5036
4457
|
function applyValue(id: string, value: string) {
|
|
4458
|
+
// The file the page is switched to. A typed row also names its setting:
|
|
4459
|
+
// retyping the value in effect must still reach a file that stores a
|
|
4460
|
+
// different one. Toggle and cycling rows always change their value.
|
|
4461
|
+
const target: SettingsTarget = {
|
|
4462
|
+
scope,
|
|
4463
|
+
key: isNumericSettingKey(id) ? id : undefined,
|
|
4464
|
+
}
|
|
5037
4465
|
if (id === "maxConcurrent") {
|
|
5038
4466
|
const n = parseInt(value, 10)
|
|
5039
4467
|
if (n >= 1) {
|
|
5040
4468
|
manager.setMaxConcurrent(n)
|
|
5041
|
-
notifyApplied(ctx, `Max background concurrency set to ${n}`)
|
|
4469
|
+
notifyApplied(ctx, target, `Max background concurrency set to ${n}`)
|
|
5042
4470
|
}
|
|
5043
4471
|
} else if (id === "maxConcurrentForeground") {
|
|
5044
4472
|
// 0 is meaningful here, unlike maxConcurrent above: it means unlimited.
|
|
@@ -5047,6 +4475,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5047
4475
|
manager.setMaxConcurrentForeground(n)
|
|
5048
4476
|
notifyApplied(
|
|
5049
4477
|
ctx,
|
|
4478
|
+
target,
|
|
5050
4479
|
n === 0
|
|
5051
4480
|
? "Max foreground concurrency set to unlimited"
|
|
5052
4481
|
: `Max foreground concurrency set to ${n}`,
|
|
@@ -5058,6 +4487,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5058
4487
|
manager.setMaxConcurrentNested(n)
|
|
5059
4488
|
notifyApplied(
|
|
5060
4489
|
ctx,
|
|
4490
|
+
target,
|
|
5061
4491
|
n === 0
|
|
5062
4492
|
? "Max nested concurrency set to unlimited"
|
|
5063
4493
|
: `Max nested concurrency set to ${n}`,
|
|
@@ -5067,16 +4497,16 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5067
4497
|
const n = parseInt(value, 10)
|
|
5068
4498
|
if (n === 0) {
|
|
5069
4499
|
setDefaultMaxTurns(undefined)
|
|
5070
|
-
notifyApplied(ctx, "Default max turns set to unlimited")
|
|
4500
|
+
notifyApplied(ctx, target, "Default max turns set to unlimited")
|
|
5071
4501
|
} else if (n >= 1) {
|
|
5072
4502
|
setDefaultMaxTurns(n)
|
|
5073
|
-
notifyApplied(ctx, `Default max turns set to ${n}`)
|
|
4503
|
+
notifyApplied(ctx, target, `Default max turns set to ${n}`)
|
|
5074
4504
|
}
|
|
5075
4505
|
} else if (id === "graceTurns") {
|
|
5076
4506
|
const n = parseInt(value, 10)
|
|
5077
4507
|
if (n >= 1) {
|
|
5078
4508
|
setGraceTurns(n)
|
|
5079
|
-
notifyApplied(ctx, `Grace turns set to ${n}`)
|
|
4509
|
+
notifyApplied(ctx, target, `Grace turns set to ${n}`)
|
|
5080
4510
|
}
|
|
5081
4511
|
} else if (id === "maxSubagentDepth") {
|
|
5082
4512
|
const n = parseInt(value, 10)
|
|
@@ -5084,19 +4514,21 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5084
4514
|
setMaxSubagentDepth(n)
|
|
5085
4515
|
notifyApplied(
|
|
5086
4516
|
ctx,
|
|
4517
|
+
target,
|
|
5087
4518
|
n <= 1
|
|
5088
|
-
? "Nested delegation disabled"
|
|
4519
|
+
? "Nested delegation disabled for every agent, including those with allowed_subagents"
|
|
5089
4520
|
: `Nested depth set to ${n}. Applies to agents started from now on.`,
|
|
5090
4521
|
)
|
|
5091
4522
|
}
|
|
5092
4523
|
} else if (id === "joinMode") {
|
|
5093
4524
|
setDefaultJoinMode(value as JoinMode)
|
|
5094
|
-
notifyApplied(ctx, `Default join mode set to ${value}`)
|
|
4525
|
+
notifyApplied(ctx, target, `Default join mode set to ${value}`)
|
|
5095
4526
|
} else if (id === "backgroundByDefault") {
|
|
5096
4527
|
const enabled = value === "on"
|
|
5097
4528
|
setBackgroundByDefault(enabled)
|
|
5098
4529
|
notifyApplied(
|
|
5099
4530
|
ctx,
|
|
4531
|
+
target,
|
|
5100
4532
|
enabled
|
|
5101
4533
|
? "Agent calls run in the background unless they pass run_in_background: false"
|
|
5102
4534
|
: "Agent calls block and return inline unless they pass run_in_background: true",
|
|
@@ -5113,6 +4545,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5113
4545
|
if (!enabled) scheduler.stop() // immediate kill — outstanding fires stop ticking
|
|
5114
4546
|
notifyApplied(
|
|
5115
4547
|
ctx,
|
|
4548
|
+
target,
|
|
5116
4549
|
`Scheduling ${enabled ? "enabled" : "disabled"}. Tool spec change takes effect on next pi session.`,
|
|
5117
4550
|
)
|
|
5118
4551
|
}
|
|
@@ -5130,18 +4563,24 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5130
4563
|
// lose work the user never asked to discard.
|
|
5131
4564
|
notifyApplied(
|
|
5132
4565
|
ctx,
|
|
4566
|
+
target,
|
|
5133
4567
|
`Workflows ${enabled ? "enabled" : "disabled"}. Tool spec change takes effect on next pi session.`,
|
|
5134
4568
|
)
|
|
5135
4569
|
}
|
|
5136
4570
|
} else if (id === "scopeModels") {
|
|
5137
4571
|
const enabled = value === "on"
|
|
5138
4572
|
setScopeModelsEnabled(enabled)
|
|
5139
|
-
notifyApplied(
|
|
4573
|
+
notifyApplied(
|
|
4574
|
+
ctx,
|
|
4575
|
+
target,
|
|
4576
|
+
`Scope models ${enabled ? "enabled" : "disabled"}`,
|
|
4577
|
+
)
|
|
5140
4578
|
} else if (id === "strictAgentFiles") {
|
|
5141
4579
|
const enabled = value === "on"
|
|
5142
4580
|
strictAgentFiles = enabled
|
|
5143
4581
|
notifyApplied(
|
|
5144
4582
|
ctx,
|
|
4583
|
+
target,
|
|
5145
4584
|
`Strict agent files ${enabled ? "enabled" : "disabled"}. Takes effect on next pi session.`,
|
|
5146
4585
|
)
|
|
5147
4586
|
} else if (id === "disableDefaultAgents") {
|
|
@@ -5149,12 +4588,14 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5149
4588
|
setDisableDefaultAgents(enabled)
|
|
5150
4589
|
notifyApplied(
|
|
5151
4590
|
ctx,
|
|
4591
|
+
target,
|
|
5152
4592
|
`Default agents ${enabled ? "disabled" : "enabled"}. Tool spec change takes effect on next pi session.`,
|
|
5153
4593
|
)
|
|
5154
4594
|
} else if (id === "fallbackSubagent") {
|
|
5155
4595
|
setFallbackSubagent(value)
|
|
5156
4596
|
notifyApplied(
|
|
5157
4597
|
ctx,
|
|
4598
|
+
target,
|
|
5158
4599
|
value === NO_FALLBACK
|
|
5159
4600
|
? "Unknown or disabled agent types will now be rejected"
|
|
5160
4601
|
: `Unknown agent types will fall back to ${value}`,
|
|
@@ -5164,6 +4605,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5164
4605
|
setOutputTranscriptDefault(enabled)
|
|
5165
4606
|
notifyApplied(
|
|
5166
4607
|
ctx,
|
|
4608
|
+
target,
|
|
5167
4609
|
`Output transcript ${enabled ? "enabled" : "disabled"} by default`,
|
|
5168
4610
|
)
|
|
5169
4611
|
} else if (id === "worktreeIsolation") {
|
|
@@ -5173,6 +4615,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5173
4615
|
// the isolation parameter only appears/disappears next session.
|
|
5174
4616
|
notifyApplied(
|
|
5175
4617
|
ctx,
|
|
4618
|
+
target,
|
|
5176
4619
|
`Worktree isolation ${enabled ? "enabled" : "disabled"}. Tool parameter updates on next pi session.`,
|
|
5177
4620
|
)
|
|
5178
4621
|
} else if (id === "packageAgents" || id === "packageWorkflows") {
|
|
@@ -5198,12 +4641,14 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5198
4641
|
: ""
|
|
5199
4642
|
notifyApplied(
|
|
5200
4643
|
ctx,
|
|
4644
|
+
target,
|
|
5201
4645
|
`${label} ${enabled ? "enabled" : "disabled"}.${replaced}${specNote}`,
|
|
5202
4646
|
)
|
|
5203
4647
|
} else if (id === "toolDescriptionMode") {
|
|
5204
4648
|
setToolDescriptionMode(value as ToolDescriptionMode)
|
|
5205
4649
|
notifyApplied(
|
|
5206
4650
|
ctx,
|
|
4651
|
+
target,
|
|
5207
4652
|
`Tool description set to ${value}. Takes effect on next pi session.`,
|
|
5208
4653
|
)
|
|
5209
4654
|
} else if (id === "reportUsage") {
|
|
@@ -5211,6 +4656,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5211
4656
|
setReportUsage(enabled)
|
|
5212
4657
|
notifyApplied(
|
|
5213
4658
|
ctx,
|
|
4659
|
+
target,
|
|
5214
4660
|
enabled
|
|
5215
4661
|
? "Subagent usage now counted in this session's totals"
|
|
5216
4662
|
: "Subagent usage no longer counted in this session's totals",
|
|
@@ -5218,23 +4664,36 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5218
4664
|
} else if (id === "showCost") {
|
|
5219
4665
|
const enabled = value === "on"
|
|
5220
4666
|
setShowCost(enabled)
|
|
5221
|
-
notifyApplied(
|
|
4667
|
+
notifyApplied(
|
|
4668
|
+
ctx,
|
|
4669
|
+
target,
|
|
4670
|
+
`Cost display ${enabled ? "enabled" : "disabled"}`,
|
|
4671
|
+
)
|
|
5222
4672
|
} else if (id === "showModel") {
|
|
5223
4673
|
const enabled = value === "on"
|
|
5224
4674
|
setShowModel(enabled)
|
|
5225
|
-
notifyApplied(
|
|
4675
|
+
notifyApplied(
|
|
4676
|
+
ctx,
|
|
4677
|
+
target,
|
|
4678
|
+
`Model display ${enabled ? "enabled" : "disabled"}`,
|
|
4679
|
+
)
|
|
5226
4680
|
} else if (id === "viewerMarkdown") {
|
|
5227
4681
|
setViewerMarkdown(value as ViewerMarkdownMode)
|
|
5228
|
-
notifyApplied(ctx, `Viewer markdown set to ${value}`)
|
|
4682
|
+
notifyApplied(ctx, target, `Viewer markdown set to ${value}`)
|
|
5229
4683
|
} else if (id === "fleetView") {
|
|
5230
4684
|
const enabled = value === "on"
|
|
5231
4685
|
setFleetViewEnabled(enabled)
|
|
5232
|
-
notifyApplied(
|
|
4686
|
+
notifyApplied(
|
|
4687
|
+
ctx,
|
|
4688
|
+
target,
|
|
4689
|
+
`Fleet view ${enabled ? "enabled" : "disabled"}`,
|
|
4690
|
+
)
|
|
5233
4691
|
} else if (id === "agentMentions") {
|
|
5234
4692
|
const mode = value as AgentMentionMode
|
|
5235
4693
|
setAgentMentionMode(mode)
|
|
5236
4694
|
notifyApplied(
|
|
5237
4695
|
ctx,
|
|
4696
|
+
target,
|
|
5238
4697
|
mode === "off"
|
|
5239
4698
|
? "Agent mentions disabled"
|
|
5240
4699
|
: mode === "model"
|
|
@@ -5246,106 +4705,81 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5246
4705
|
setRememberAgents(enabled)
|
|
5247
4706
|
notifyApplied(
|
|
5248
4707
|
ctx,
|
|
4708
|
+
target,
|
|
5249
4709
|
`Remember agents ${enabled ? "enabled" : "disabled"}`,
|
|
5250
4710
|
)
|
|
5251
4711
|
} else if (id === "widgetMode") {
|
|
5252
4712
|
setWidgetMode(value as WidgetMode)
|
|
5253
|
-
notifyApplied(ctx, `Widget set to ${value}`)
|
|
4713
|
+
notifyApplied(ctx, target, `Widget set to ${value}`)
|
|
5254
4714
|
}
|
|
5255
4715
|
}
|
|
5256
4716
|
|
|
5257
|
-
|
|
5258
|
-
//
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
4717
|
+
// Remove the row's setting from the file its tag names. The row then
|
|
4718
|
+
// shows what a restart would load: the other file's value, or the default.
|
|
4719
|
+
const resetRow = (id: string) => {
|
|
4720
|
+
const key = settingKeyOf(id)
|
|
4721
|
+
const row = () => buildItems().find((item) => item.id === id)
|
|
4722
|
+
const label = row()?.label ?? id
|
|
4723
|
+
const cwd = process.cwd()
|
|
4724
|
+
const source = settingSources(cwd)[key]
|
|
4725
|
+
if (!source) {
|
|
4726
|
+
ctx.ui.notify(`${label} is already at its default`, "info")
|
|
4727
|
+
return
|
|
4728
|
+
}
|
|
4729
|
+
if (
|
|
4730
|
+
!saveSettings({ [key]: undefined } as SubagentsSettings, cwd, source)
|
|
4731
|
+
) {
|
|
4732
|
+
ctx.ui.notify(
|
|
4733
|
+
`${label}: failed to remove it from ${source} settings`,
|
|
4734
|
+
"warning",
|
|
5274
4735
|
)
|
|
4736
|
+
return
|
|
4737
|
+
}
|
|
4738
|
+
resetSetting(key, loadSettings(cwd)[key] ?? SETTING_DEFAULTS[key])
|
|
4739
|
+
// The file now agrees with memory for this key; a later save must not write it back.
|
|
4740
|
+
const snapshot = snapshotSettings()
|
|
4741
|
+
savedSnapshot = { ...savedSnapshot, [key]: snapshot[key] }
|
|
4742
|
+
pi.events.emit("subagents:settings_changed", {
|
|
4743
|
+
settings: snapshot,
|
|
4744
|
+
persisted: true,
|
|
4745
|
+
})
|
|
4746
|
+
const still = settingSources(cwd)[key]
|
|
4747
|
+
const value = row()?.currentValue
|
|
4748
|
+
ctx.ui.notify(
|
|
4749
|
+
still
|
|
4750
|
+
? `${label} is now ${value} from ${still} settings (removed from ${source} settings)`
|
|
4751
|
+
: `${label} reset to the default, ${value} (removed from ${source} settings)`,
|
|
4752
|
+
"info",
|
|
4753
|
+
)
|
|
4754
|
+
}
|
|
5275
4755
|
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
return
|
|
5299
|
-
}
|
|
5300
|
-
list.handleInput?.(data)
|
|
5301
|
-
},
|
|
5302
|
-
}
|
|
4756
|
+
const deps: SettingsPageDeps = {
|
|
4757
|
+
buildItems,
|
|
4758
|
+
fileTags: () => {
|
|
4759
|
+
const sources = settingSources(process.cwd())
|
|
4760
|
+
return (id) => sources[settingKeyOf(id)]
|
|
4761
|
+
},
|
|
4762
|
+
apply: applyValue,
|
|
4763
|
+
reset: resetRow,
|
|
4764
|
+
header: () => {
|
|
4765
|
+
const path = settingsFilePath(scope, process.cwd())
|
|
4766
|
+
const shown =
|
|
4767
|
+
scope === "project"
|
|
4768
|
+
? ".pi/subagents.json"
|
|
4769
|
+
: path.replace(homedir(), "~")
|
|
4770
|
+
const created =
|
|
4771
|
+
scope === "project" && !existsSync(path)
|
|
4772
|
+
? " · created on first change"
|
|
4773
|
+
: ""
|
|
4774
|
+
return { scope, file: `${shown}${created}` }
|
|
4775
|
+
},
|
|
4776
|
+
toggleScope: () => {
|
|
4777
|
+
scope = scope === "global" ? "project" : "global"
|
|
5303
4778
|
},
|
|
5304
|
-
)
|
|
5305
|
-
|
|
5306
|
-
// If a numeric field ID was returned, prompt for typed input
|
|
5307
|
-
if (result && NUMERIC_IDS.has(result)) {
|
|
5308
|
-
const current =
|
|
5309
|
-
result === "maxConcurrent"
|
|
5310
|
-
? String(manager.getMaxConcurrent())
|
|
5311
|
-
: result === "maxConcurrentForeground"
|
|
5312
|
-
? String(manager.getMaxConcurrentForeground())
|
|
5313
|
-
: result === "maxConcurrentNested"
|
|
5314
|
-
? String(manager.getMaxConcurrentNested())
|
|
5315
|
-
: result === "defaultMaxTurns"
|
|
5316
|
-
? String(getDefaultMaxTurns() ?? 0)
|
|
5317
|
-
: result === "maxSubagentDepth"
|
|
5318
|
-
? String(getMaxSubagentDepth())
|
|
5319
|
-
: String(getGraceTurns())
|
|
5320
|
-
|
|
5321
|
-
const label =
|
|
5322
|
-
result === "maxConcurrent"
|
|
5323
|
-
? "Max background concurrency (1+)"
|
|
5324
|
-
: result === "maxConcurrentForeground"
|
|
5325
|
-
? "Max foreground concurrency (0 = unlimited)"
|
|
5326
|
-
: result === "maxConcurrentNested"
|
|
5327
|
-
? "Max nested concurrency (0 = unlimited)"
|
|
5328
|
-
: result === "defaultMaxTurns"
|
|
5329
|
-
? "Default max turns (0 = unlimited)"
|
|
5330
|
-
: result === "maxSubagentDepth"
|
|
5331
|
-
? "Nested depth (0/1 = nesting off)"
|
|
5332
|
-
: "Grace turns (1+)"
|
|
5333
|
-
|
|
5334
|
-
// Loop until user enters a valid integer or cancels (Esc / null).
|
|
5335
|
-
// Silently trims whitespace; rejects non-numeric input by re-prompting.
|
|
5336
|
-
let input: string | undefined = await ctx.ui.input(label, current)
|
|
5337
|
-
while (input != null) {
|
|
5338
|
-
const trimmed = input.trim()
|
|
5339
|
-
const n = Number(trimmed)
|
|
5340
|
-
if (trimmed !== "" && Number.isInteger(n)) {
|
|
5341
|
-
applyValue(result, String(n))
|
|
5342
|
-
await showSettings(ctx)
|
|
5343
|
-
return
|
|
5344
|
-
}
|
|
5345
|
-
// Invalid — re-prompt with the user's last entry so they can edit it
|
|
5346
|
-
input = await ctx.ui.input(label, trimmed)
|
|
5347
|
-
}
|
|
5348
4779
|
}
|
|
4780
|
+
await ctx.ui.custom<undefined>((tui, theme, kb, done) =>
|
|
4781
|
+
createSettingsPage(deps, tui, theme, kb, () => done(undefined)),
|
|
4782
|
+
)
|
|
5349
4783
|
}
|
|
5350
4784
|
|
|
5351
4785
|
// Persist the current snapshot, emit `subagents:settings_changed`, and surface
|
|
@@ -5365,33 +4799,22 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5365
4799
|
ctx: ExtensionCommandContext | undefined,
|
|
5366
4800
|
changeMsg: string,
|
|
5367
4801
|
): void {
|
|
5368
|
-
const { message, level } =
|
|
5369
|
-
snapshotSettings(),
|
|
5370
|
-
changeMsg,
|
|
5371
|
-
(event, payload) => pi.events.emit(event, payload),
|
|
5372
|
-
)
|
|
4802
|
+
const { message, level } = saveSnapshot(changeMsg)
|
|
5373
4803
|
// `ctx` is absent only on the fleet path between sessions, where
|
|
5374
4804
|
// `currentCtx` has been cleared and there is no UI to carry the warning to.
|
|
5375
4805
|
// The write still happens.
|
|
5376
4806
|
if (level === "warning") ctx?.ui.notify(message, level)
|
|
5377
4807
|
}
|
|
5378
4808
|
|
|
5379
|
-
function notifyApplied(
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
)
|
|
4809
|
+
function notifyApplied(
|
|
4810
|
+
ctx: ExtensionCommandContext,
|
|
4811
|
+
target: SettingsTarget,
|
|
4812
|
+
successMsg: string,
|
|
4813
|
+
) {
|
|
4814
|
+
const { message, level } = saveSnapshot(successMsg, target)
|
|
5385
4815
|
ctx.ui.notify(message, level)
|
|
5386
4816
|
}
|
|
5387
4817
|
|
|
5388
|
-
pi.registerCommand("agents", {
|
|
5389
|
-
description: "Manage agents",
|
|
5390
|
-
handler: async (_args, ctx) => {
|
|
5391
|
-
await showAgentsMenu(ctx)
|
|
5392
|
-
},
|
|
5393
|
-
})
|
|
5394
|
-
|
|
5395
4818
|
/**
|
|
5396
4819
|
* What `/agents → Workflows` and the fleet list's `workflow` rows need from
|
|
5397
4820
|
* here. One object, built once: both entry points open the same inspector,
|
|
@@ -5411,4 +4834,22 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5411
4834
|
fleet.setWorkflowSource(fleetWorkflows, (id) =>
|
|
5412
4835
|
openWorkflowFromFleet(id, workflowMenuDeps),
|
|
5413
4836
|
)
|
|
4837
|
+
|
|
4838
|
+
const { showAgentsMenu } = createAgentsMenu({
|
|
4839
|
+
pi,
|
|
4840
|
+
manager,
|
|
4841
|
+
scheduler,
|
|
4842
|
+
workflowMenuDeps,
|
|
4843
|
+
isWorkflowsEnabled,
|
|
4844
|
+
reloadCustomAgents,
|
|
4845
|
+
getModelLabel,
|
|
4846
|
+
viewAgentConversation,
|
|
4847
|
+
showSettings,
|
|
4848
|
+
})
|
|
4849
|
+
pi.registerCommand("agents", {
|
|
4850
|
+
description: "Manage agents",
|
|
4851
|
+
handler: async (_args, ctx) => {
|
|
4852
|
+
await showAgentsMenu(ctx)
|
|
4853
|
+
},
|
|
4854
|
+
})
|
|
5414
4855
|
}
|