@herbertgao/pi-extensions 2026.11.9 → 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 +21 -0
- package/README.md +6 -6
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +12 -0
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +8 -6
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +8 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +12 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +36 -13
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +4 -8
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +7 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer.ts +115 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +47 -15
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/startup-header.ts +3 -18
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +34 -10
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +6 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +30 -17
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/scroll.ts +4 -21
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +63 -7
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/names.ts +3 -13
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/tool-io.ts +0 -5
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/transcript-mode.ts +34 -7
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/ansi-text.ts +43 -4
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/keybindings.ts +75 -0
- 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 +12 -0
- package/node_modules/@herbertgao/pi-subagents/README.md +53 -26
- package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +12 -12
- package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +84 -8
- 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 +369 -879
- 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 +225 -61
- package/node_modules/@herbertgao/pi-subagents/src/types.ts +27 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/agent-tree.ts +47 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +16 -5
- package/node_modules/@herbertgao/pi-subagents/src/ui/agents-menu.ts +705 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +211 -47
- 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"
|
|
@@ -178,6 +162,7 @@ import {
|
|
|
178
162
|
buildInvocationTags,
|
|
179
163
|
describeActivity,
|
|
180
164
|
fgPreservingNestedStyles,
|
|
165
|
+
formatAge,
|
|
181
166
|
formatCost,
|
|
182
167
|
formatDuration,
|
|
183
168
|
formatMs,
|
|
@@ -189,6 +174,7 @@ import {
|
|
|
189
174
|
type Theme,
|
|
190
175
|
type UICtx,
|
|
191
176
|
} from "./ui/agent-widget.js"
|
|
177
|
+
import { createAgentsMenu } from "./ui/agents-menu.js"
|
|
192
178
|
import {
|
|
193
179
|
ConversationViewer,
|
|
194
180
|
getConversationOverlayOptions,
|
|
@@ -199,15 +185,16 @@ import {
|
|
|
199
185
|
type FleetUICtx,
|
|
200
186
|
type FleetWorkflow,
|
|
201
187
|
} from "./ui/fleet-list.js"
|
|
202
|
-
import {
|
|
203
|
-
|
|
188
|
+
import {
|
|
189
|
+
createSettingsPage,
|
|
190
|
+
type SettingsPageDeps,
|
|
191
|
+
} from "./ui/settings-menu.js"
|
|
204
192
|
import {
|
|
205
193
|
renderWorkflowCard,
|
|
206
194
|
renderWorkflowEntryCard,
|
|
207
195
|
} from "./ui/workflow-card.js"
|
|
208
196
|
import {
|
|
209
197
|
openWorkflowFromFleet,
|
|
210
|
-
showWorkflowsMenu,
|
|
211
198
|
type WorkflowMenuDeps,
|
|
212
199
|
} from "./ui/workflow-menu.js"
|
|
213
200
|
import {
|
|
@@ -349,23 +336,6 @@ function createActivityTracker(maxTurns?: number, onStreamUpdate?: () => void) {
|
|
|
349
336
|
return { state, callbacks }
|
|
350
337
|
}
|
|
351
338
|
|
|
352
|
-
/**
|
|
353
|
-
* Advertised thinking levels, ordered to mirror pi-ai's EXTENDED_THINKING_LEVELS
|
|
354
|
-
* (`off` + every `ThinkingLevel`). Single source for the Agent tool description,
|
|
355
|
-
* the generated-agent template, and the `/agents` wizard so these lists can't
|
|
356
|
-
* drift behind pi again (#147). Availability of any level still depends on the
|
|
357
|
-
* host pi version and the selected model — pi clamps unsupported levels down.
|
|
358
|
-
*/
|
|
359
|
-
const THINKING_LEVELS = [
|
|
360
|
-
"off",
|
|
361
|
-
"minimal",
|
|
362
|
-
"low",
|
|
363
|
-
"medium",
|
|
364
|
-
"high",
|
|
365
|
-
"xhigh",
|
|
366
|
-
"max",
|
|
367
|
-
] as const
|
|
368
|
-
|
|
369
339
|
/** Human-readable status label for agent completion. */
|
|
370
340
|
function getStatusLabel(status: string, error?: string): string {
|
|
371
341
|
switch (status) {
|
|
@@ -714,7 +684,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
714
684
|
widget.update()
|
|
715
685
|
fleet.update()
|
|
716
686
|
}
|
|
717
|
-
/** Name the model and thinking level on the widget's running rows. */
|
|
687
|
+
/** Name the model and thinking level on the widget's running rows and the fleet rows. */
|
|
718
688
|
let showModel = false
|
|
719
689
|
function isShowModelEnabled(): boolean {
|
|
720
690
|
return showModel
|
|
@@ -722,6 +692,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
722
692
|
function setShowModel(b: boolean): void {
|
|
723
693
|
showModel = b
|
|
724
694
|
widget.update()
|
|
695
|
+
fleet.update()
|
|
725
696
|
}
|
|
726
697
|
/**
|
|
727
698
|
* How much of the conversation viewer renders as Markdown. Read through a
|
|
@@ -1130,10 +1101,17 @@ export default function (pi: ExtensionAPI) {
|
|
|
1130
1101
|
return resolved?.kind === "live" ? resolved.record : undefined
|
|
1131
1102
|
}
|
|
1132
1103
|
|
|
1133
|
-
/**
|
|
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
|
+
*/
|
|
1134
1109
|
const formatSavedAgentRecord = (saved: AgentRecordEntryData): string =>
|
|
1135
1110
|
`Agent: ${saved.id}\n` +
|
|
1136
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
|
+
: "") +
|
|
1137
1115
|
`Description: ${saved.description}\n` +
|
|
1138
1116
|
`(From the session's saved record: the live record has been cleaned up, so its stats and conversation are gone.)\n\n` +
|
|
1139
1117
|
(saved.status === "error"
|
|
@@ -1733,6 +1711,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
1733
1711
|
),
|
|
1734
1712
|
getFullscreenScrollbar,
|
|
1735
1713
|
backgroundActionFor,
|
|
1714
|
+
isShowModelEnabled,
|
|
1736
1715
|
)
|
|
1737
1716
|
let fleetViewEnabled = true
|
|
1738
1717
|
function isFleetViewEnabled(): boolean {
|
|
@@ -2075,38 +2054,40 @@ export default function (pi: ExtensionAPI) {
|
|
|
2075
2054
|
// Apply persisted settings on startup and emit `subagents:settings_loaded`.
|
|
2076
2055
|
// Global + project merged; missing → defaults; corrupt file emits a warning
|
|
2077
2056
|
// to stderr and falls back to defaults.
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
setDisableDefaultAgents: setDisableDefaultAgents,
|
|
2092
|
-
setToolDescriptionMode: setToolDescriptionMode,
|
|
2093
|
-
setFleetView: setFleetViewEnabled,
|
|
2094
|
-
setAgentMentions: setAgentMentionMode,
|
|
2095
|
-
setRememberAgents,
|
|
2096
|
-
setWidgetMode: setWidgetMode,
|
|
2097
|
-
setOutputTranscript: setOutputTranscriptDefault,
|
|
2098
|
-
setWorktreeIsolation: setWorktreeIsolationEnabled,
|
|
2099
|
-
setWorkflowsEnabled: setWorkflowsEnabled,
|
|
2100
|
-
setMaxSubagentDepth: setMaxSubagentDepth,
|
|
2101
|
-
setFallbackSubagent: setFallbackSubagent,
|
|
2102
|
-
setReportUsage,
|
|
2103
|
-
setShowCost,
|
|
2104
|
-
setShowModel,
|
|
2105
|
-
setViewerMarkdown,
|
|
2106
|
-
setPackageAgents: setPackageAgentsGate,
|
|
2107
|
-
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
|
|
2108
2070
|
},
|
|
2109
|
-
|
|
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),
|
|
2110
2091
|
)
|
|
2111
2092
|
|
|
2112
2093
|
// ---- Agent tool ----
|
|
@@ -4018,173 +3999,6 @@ Terse command-style prompts produce shallow, generic work.
|
|
|
4018
3999
|
return `${label} (→ ${resolvedFull.replace(/-\d{8}$/, "")})`
|
|
4019
4000
|
}
|
|
4020
4001
|
|
|
4021
|
-
async function showAgentsMenu(ctx: ExtensionCommandContext) {
|
|
4022
|
-
reloadCustomAgents()
|
|
4023
|
-
const allNames = getAllTypes()
|
|
4024
|
-
|
|
4025
|
-
// Build select options
|
|
4026
|
-
const options: string[] = []
|
|
4027
|
-
|
|
4028
|
-
// Running agents entry (only if there are active agents)
|
|
4029
|
-
const agents = manager.listAgents().filter(isTopLevelAgent)
|
|
4030
|
-
if (agents.length > 0) {
|
|
4031
|
-
const running = agents.filter(
|
|
4032
|
-
(a) => a.status === "running" || a.status === "queued",
|
|
4033
|
-
).length
|
|
4034
|
-
const done = agents.filter(
|
|
4035
|
-
(a) => a.status === "completed" || a.status === "steered",
|
|
4036
|
-
).length
|
|
4037
|
-
options.push(
|
|
4038
|
-
`Running agents (${agents.length}) — ${running} running, ${done} done`,
|
|
4039
|
-
)
|
|
4040
|
-
}
|
|
4041
|
-
|
|
4042
|
-
// Agent types list
|
|
4043
|
-
if (allNames.length > 0) {
|
|
4044
|
-
options.push(`Agent types (${allNames.length})`)
|
|
4045
|
-
}
|
|
4046
|
-
|
|
4047
|
-
// Scheduled jobs entry (always present when scheduler is active)
|
|
4048
|
-
if (scheduler.isActive()) {
|
|
4049
|
-
const jobCount = scheduler.list().length
|
|
4050
|
-
options.push(`Scheduled jobs (${jobCount})`)
|
|
4051
|
-
}
|
|
4052
|
-
|
|
4053
|
-
// Workflow runs, on the same terms as scheduled jobs: shown only when the
|
|
4054
|
-
// feature is on, so the menu never advertises something switched off.
|
|
4055
|
-
if (isWorkflowsEnabled()) {
|
|
4056
|
-
options.push(`Workflows (${workflowTasks.size})`)
|
|
4057
|
-
}
|
|
4058
|
-
|
|
4059
|
-
// Actions
|
|
4060
|
-
options.push("Create new agent")
|
|
4061
|
-
options.push("Settings")
|
|
4062
|
-
|
|
4063
|
-
const noAgentsMsg =
|
|
4064
|
-
allNames.length === 0 && agents.length === 0
|
|
4065
|
-
? "No agents found. Create specialized subagents that can be delegated to.\n\n" +
|
|
4066
|
-
"Each subagent has its own context window, custom system prompt, and specific tools.\n\n" +
|
|
4067
|
-
"Try creating: Code Reviewer, Security Auditor, Test Writer, or Documentation Writer.\n\n"
|
|
4068
|
-
: ""
|
|
4069
|
-
|
|
4070
|
-
if (noAgentsMsg) {
|
|
4071
|
-
ctx.ui.notify(noAgentsMsg, "info")
|
|
4072
|
-
}
|
|
4073
|
-
|
|
4074
|
-
const choice = await ctx.ui.select("Agents", options)
|
|
4075
|
-
if (!choice) return
|
|
4076
|
-
|
|
4077
|
-
if (choice.startsWith("Running agents (")) {
|
|
4078
|
-
await showRunningAgents(ctx)
|
|
4079
|
-
await showAgentsMenu(ctx)
|
|
4080
|
-
} else if (choice.startsWith("Agent types (")) {
|
|
4081
|
-
await showAllAgentsList(ctx)
|
|
4082
|
-
await showAgentsMenu(ctx)
|
|
4083
|
-
} else if (choice.startsWith("Scheduled jobs (")) {
|
|
4084
|
-
await showSchedulesMenu(ctx, scheduler)
|
|
4085
|
-
await showAgentsMenu(ctx)
|
|
4086
|
-
} else if (choice.startsWith("Workflows (")) {
|
|
4087
|
-
await showWorkflowsMenu(ctx, workflowMenuDeps)
|
|
4088
|
-
await showAgentsMenu(ctx)
|
|
4089
|
-
} else if (choice === "Create new agent") {
|
|
4090
|
-
await showCreateWizard(ctx)
|
|
4091
|
-
} else if (choice === "Settings") {
|
|
4092
|
-
await showSettings(ctx)
|
|
4093
|
-
await showAgentsMenu(ctx)
|
|
4094
|
-
}
|
|
4095
|
-
}
|
|
4096
|
-
|
|
4097
|
-
/**
|
|
4098
|
-
* The package that provided an agent, for display only. Undefined for every
|
|
4099
|
-
* other source, and for a package path no currently-admitted package owns —
|
|
4100
|
-
* which is what a stale `sourcePath` looks like after the gate narrows.
|
|
4101
|
-
*/
|
|
4102
|
-
function packageNameOf(cfg: AgentConfig | undefined): string | undefined {
|
|
4103
|
-
if (cfg?.source !== "package" || !cfg.sourcePath) return undefined
|
|
4104
|
-
return packageNameForPath(cfg.sourcePath, process.cwd())
|
|
4105
|
-
}
|
|
4106
|
-
|
|
4107
|
-
async function showAllAgentsList(ctx: ExtensionCommandContext) {
|
|
4108
|
-
const allNames = getAllTypes()
|
|
4109
|
-
if (allNames.length === 0) {
|
|
4110
|
-
ctx.ui.notify("No agents.", "info")
|
|
4111
|
-
return
|
|
4112
|
-
}
|
|
4113
|
-
|
|
4114
|
-
const configs = allNames.map((name) => getAgentConfig(name))
|
|
4115
|
-
|
|
4116
|
-
// One row per agent (name in the left column, model on the right); the
|
|
4117
|
-
// full description renders below the highlighted row via SettingsList,
|
|
4118
|
-
// exactly like the Settings menu — so long descriptions never wrap the list.
|
|
4119
|
-
// A package agent's description is prefixed with the package that provided
|
|
4120
|
-
// it: the `▪` badge says a package won, not which one.
|
|
4121
|
-
const items: SettingItem[] = allNames.map((name, i) => {
|
|
4122
|
-
const cfg = configs[i]
|
|
4123
|
-
const model = getModelLabel(name, ctx.modelRegistry)
|
|
4124
|
-
return {
|
|
4125
|
-
id: name,
|
|
4126
|
-
label: `${sourceIndicator(cfg)}${name}`,
|
|
4127
|
-
currentValue: model,
|
|
4128
|
-
description: rowDescription(name, cfg, packageNameOf(cfg)),
|
|
4129
|
-
// Single-value list so Enter "activates" the row (fires onChange with the
|
|
4130
|
-
// agent's id) without offering anything to actually cycle.
|
|
4131
|
-
values: [model],
|
|
4132
|
-
}
|
|
4133
|
-
})
|
|
4134
|
-
|
|
4135
|
-
const legend = sourceLegend(configs)
|
|
4136
|
-
|
|
4137
|
-
const selected = await ctx.ui.custom<string | undefined>(
|
|
4138
|
-
(_tui, _theme, _kb, done) => {
|
|
4139
|
-
const slTheme = getSettingsListTheme()
|
|
4140
|
-
const list = new SettingsList(
|
|
4141
|
-
items,
|
|
4142
|
-
Math.min(items.length, 12),
|
|
4143
|
-
slTheme,
|
|
4144
|
-
(id) => done(id), // Enter/Space on a row → return that agent's name
|
|
4145
|
-
() => done(undefined), // Esc → cancel
|
|
4146
|
-
)
|
|
4147
|
-
const container = new Container()
|
|
4148
|
-
container.addChild(new Text("Agent types", 0, 0))
|
|
4149
|
-
if (legend) container.addChild(new Text(slTheme.hint(legend), 0, 0))
|
|
4150
|
-
container.addChild(new Spacer(1))
|
|
4151
|
-
container.addChild(list)
|
|
4152
|
-
return {
|
|
4153
|
-
render: (w: number) => container.render(w),
|
|
4154
|
-
invalidate: () => container.invalidate(),
|
|
4155
|
-
handleInput: (data: string) => list.handleInput?.(data),
|
|
4156
|
-
}
|
|
4157
|
-
},
|
|
4158
|
-
)
|
|
4159
|
-
|
|
4160
|
-
if (selected && getAgentConfig(selected)) {
|
|
4161
|
-
await showAgentDetail(ctx, selected)
|
|
4162
|
-
await showAllAgentsList(ctx)
|
|
4163
|
-
}
|
|
4164
|
-
}
|
|
4165
|
-
|
|
4166
|
-
async function showRunningAgents(ctx: ExtensionCommandContext) {
|
|
4167
|
-
const agents = manager.listAgents().filter(isTopLevelAgent)
|
|
4168
|
-
if (agents.length === 0) {
|
|
4169
|
-
ctx.ui.notify("No agents.", "info")
|
|
4170
|
-
return
|
|
4171
|
-
}
|
|
4172
|
-
|
|
4173
|
-
// Numbered + item-paired. Two same-type agents spawned together with the
|
|
4174
|
-
// same description render identically here, and resolving the choice by
|
|
4175
|
-
// string match would open whichever came first.
|
|
4176
|
-
const record = await selectItem(ctx.ui, "Running agents", agents, (a) => {
|
|
4177
|
-
const dn = getDisplayName(a.type)
|
|
4178
|
-
const dur = formatDuration(a.startedAt, a.completedAt)
|
|
4179
|
-
return `${dn} (${a.description}) · ${a.toolUses} tools · ${a.status} · ${dur}`
|
|
4180
|
-
})
|
|
4181
|
-
if (!record) return
|
|
4182
|
-
|
|
4183
|
-
await viewAgentConversation(ctx, record)
|
|
4184
|
-
// Back-navigation: re-show the list
|
|
4185
|
-
await showRunningAgents(ctx)
|
|
4186
|
-
}
|
|
4187
|
-
|
|
4188
4002
|
async function viewAgentConversation(
|
|
4189
4003
|
ctx: ExtensionCommandContext,
|
|
4190
4004
|
record: AgentRecord,
|
|
@@ -4234,430 +4048,6 @@ Terse command-style prompts produce shallow, generic work.
|
|
|
4234
4048
|
)
|
|
4235
4049
|
}
|
|
4236
4050
|
|
|
4237
|
-
async function showAgentDetail(ctx: ExtensionCommandContext, name: string) {
|
|
4238
|
-
const cfg = getAgentConfig(name)
|
|
4239
|
-
if (!cfg) {
|
|
4240
|
-
ctx.ui.notify(`Agent config not found for "${name}".`, "warning")
|
|
4241
|
-
return
|
|
4242
|
-
}
|
|
4243
|
-
|
|
4244
|
-
const isPackage = cfg.source === "package"
|
|
4245
|
-
const file = locateAgentFile(name, cfg.sourcePath, undefined, cfg.source)
|
|
4246
|
-
const isDefault = cfg.isDefault === true
|
|
4247
|
-
const disabled = cfg.enabled === false
|
|
4248
|
-
|
|
4249
|
-
let menuOptions: string[]
|
|
4250
|
-
if (isPackage) {
|
|
4251
|
-
// Read-only: nothing here may write inside pi's install root. `Disable`
|
|
4252
|
-
// still appears because it writes a *local* stub that shadows the package
|
|
4253
|
-
// agent, and `Enable` never does — a package agent that reads as disabled
|
|
4254
|
-
// was disabled by its own author's `enabled: false`, which only the
|
|
4255
|
-
// package can take back. Eject is the way out of that: the copy it writes
|
|
4256
|
-
// carries no `enabled:` line, so the ejected agent is on.
|
|
4257
|
-
menuOptions = disabled
|
|
4258
|
-
? ["Eject (export as .md)", "Back"]
|
|
4259
|
-
: ["Eject (export as .md)", "Disable", "Back"]
|
|
4260
|
-
} else if (disabled && file) {
|
|
4261
|
-
// Disabled agent with a file — offer Enable
|
|
4262
|
-
menuOptions = isDefault
|
|
4263
|
-
? ["Enable", "Edit", "Reset to default", "Delete", "Back"]
|
|
4264
|
-
: ["Enable", "Edit", "Delete", "Back"]
|
|
4265
|
-
} else if (isDefault && !file) {
|
|
4266
|
-
// Default agent with no .md override
|
|
4267
|
-
menuOptions = ["Eject (export as .md)", "Disable", "Back"]
|
|
4268
|
-
} else if (isDefault && file) {
|
|
4269
|
-
// Default agent with .md override (ejected)
|
|
4270
|
-
menuOptions = ["Edit", "Disable", "Reset to default", "Delete", "Back"]
|
|
4271
|
-
} else {
|
|
4272
|
-
// User-defined agent
|
|
4273
|
-
menuOptions = ["Edit", "Disable", "Delete", "Back"]
|
|
4274
|
-
}
|
|
4275
|
-
|
|
4276
|
-
// Name the package in the title: this menu's options are the read-only set,
|
|
4277
|
-
// and "which package do I have to uninstall or allowlist away" is the
|
|
4278
|
-
// question they raise.
|
|
4279
|
-
const pkgName = packageNameOf(cfg)
|
|
4280
|
-
const choice = await ctx.ui.select(
|
|
4281
|
-
pkgName ? `${name} — ${pkgName}` : name,
|
|
4282
|
-
menuOptions,
|
|
4283
|
-
)
|
|
4284
|
-
if (!choice || choice === "Back") return
|
|
4285
|
-
|
|
4286
|
-
if (choice === "Edit" && file) {
|
|
4287
|
-
const content = readFileSync(file.path, "utf-8")
|
|
4288
|
-
const edited = await ctx.ui.editor(`Edit ${name}`, content)
|
|
4289
|
-
if (edited !== undefined && edited !== content) {
|
|
4290
|
-
const { writeFileSync } = await import("node:fs")
|
|
4291
|
-
writeFileSync(file.path, edited, "utf-8")
|
|
4292
|
-
reloadCustomAgents()
|
|
4293
|
-
ctx.ui.notify(`Updated ${file.path}`, "info")
|
|
4294
|
-
}
|
|
4295
|
-
} else if (choice === "Delete") {
|
|
4296
|
-
if (file) {
|
|
4297
|
-
const confirmed = await ctx.ui.confirm(
|
|
4298
|
-
"Delete agent",
|
|
4299
|
-
`Delete ${name} from ${file.location} (${file.path})?`,
|
|
4300
|
-
)
|
|
4301
|
-
if (confirmed) {
|
|
4302
|
-
unlinkSync(file.path)
|
|
4303
|
-
reloadCustomAgents()
|
|
4304
|
-
ctx.ui.notify(`Deleted ${file.path}`, "info")
|
|
4305
|
-
}
|
|
4306
|
-
}
|
|
4307
|
-
} else if (choice === "Reset to default" && file) {
|
|
4308
|
-
const confirmed = await ctx.ui.confirm(
|
|
4309
|
-
"Reset to default",
|
|
4310
|
-
`Delete override ${file.path} and restore embedded default?`,
|
|
4311
|
-
)
|
|
4312
|
-
if (confirmed) {
|
|
4313
|
-
unlinkSync(file.path)
|
|
4314
|
-
reloadCustomAgents()
|
|
4315
|
-
ctx.ui.notify(`Restored default ${name}`, "info")
|
|
4316
|
-
}
|
|
4317
|
-
} else if (choice.startsWith("Eject")) {
|
|
4318
|
-
await ejectAgent(ctx, name, cfg)
|
|
4319
|
-
} else if (choice === "Disable") {
|
|
4320
|
-
await disableAgent(ctx, name)
|
|
4321
|
-
} else if (choice === "Enable") {
|
|
4322
|
-
await enableAgent(ctx, name)
|
|
4323
|
-
}
|
|
4324
|
-
}
|
|
4325
|
-
|
|
4326
|
-
/** Eject a default agent: write its embedded config as a .md file. */
|
|
4327
|
-
async function ejectAgent(
|
|
4328
|
-
ctx: ExtensionCommandContext,
|
|
4329
|
-
name: string,
|
|
4330
|
-
cfg: AgentConfig,
|
|
4331
|
-
) {
|
|
4332
|
-
const location = await ctx.ui.select("Choose location", [
|
|
4333
|
-
"Project (.pi/agents/)",
|
|
4334
|
-
`Personal (${personalAgentsDir()})`,
|
|
4335
|
-
])
|
|
4336
|
-
if (!location) return
|
|
4337
|
-
|
|
4338
|
-
const targetDir = location.startsWith("Project")
|
|
4339
|
-
? projectAgentsDir()
|
|
4340
|
-
: personalAgentsDir()
|
|
4341
|
-
mkdirSync(targetDir, { recursive: true })
|
|
4342
|
-
|
|
4343
|
-
const targetPath = join(targetDir, `${name}.md`)
|
|
4344
|
-
if (existsSync(targetPath)) {
|
|
4345
|
-
const overwrite = await ctx.ui.confirm(
|
|
4346
|
-
"Overwrite",
|
|
4347
|
-
`${targetPath} already exists. Overwrite?`,
|
|
4348
|
-
)
|
|
4349
|
-
if (!overwrite) return
|
|
4350
|
-
}
|
|
4351
|
-
|
|
4352
|
-
const content = serializeAgentFile(cfg)
|
|
4353
|
-
|
|
4354
|
-
const { writeFileSync } = await import("node:fs")
|
|
4355
|
-
writeFileSync(targetPath, content, "utf-8")
|
|
4356
|
-
reloadCustomAgents()
|
|
4357
|
-
ctx.ui.notify(`Ejected ${name} to ${targetPath}`, "info")
|
|
4358
|
-
}
|
|
4359
|
-
|
|
4360
|
-
/** Disable an agent: set enabled: false in its .md file, or create a stub for built-in defaults. */
|
|
4361
|
-
async function disableAgent(ctx: ExtensionCommandContext, name: string) {
|
|
4362
|
-
const cfg = getAgentConfig(name)
|
|
4363
|
-
// `locateAgentFile` refuses a package agent's own path, so this is either the
|
|
4364
|
-
// local stub already shadowing it or nothing — never a file inside pi's
|
|
4365
|
-
// install root. An unshadowed package agent therefore falls to the stub
|
|
4366
|
-
// branch below, which writes `enabled: false` at project or personal scope.
|
|
4367
|
-
const file = locateAgentFile(name, cfg?.sourcePath, undefined, cfg?.source)
|
|
4368
|
-
if (file) {
|
|
4369
|
-
// Existing file — set enabled: false in frontmatter (idempotent)
|
|
4370
|
-
const content = readFileSync(file.path, "utf-8")
|
|
4371
|
-
const { content: updated, outcome } = disableInContent(content)
|
|
4372
|
-
if (outcome === "already-disabled") {
|
|
4373
|
-
ctx.ui.notify(`${name} is already disabled.`, "info")
|
|
4374
|
-
return
|
|
4375
|
-
}
|
|
4376
|
-
if (outcome === "no-frontmatter") {
|
|
4377
|
-
// Nothing to edit — say so rather than rewriting the file unchanged and
|
|
4378
|
-
// reporting success for a change that never happened.
|
|
4379
|
-
ctx.ui.notify(
|
|
4380
|
-
`Cannot disable ${name}: ${file.path} has no frontmatter block.`,
|
|
4381
|
-
"error",
|
|
4382
|
-
)
|
|
4383
|
-
return
|
|
4384
|
-
}
|
|
4385
|
-
const { writeFileSync } = await import("node:fs")
|
|
4386
|
-
writeFileSync(file.path, updated, "utf-8")
|
|
4387
|
-
reloadCustomAgents()
|
|
4388
|
-
ctx.ui.notify(`Disabled ${name} (${file.path})`, "info")
|
|
4389
|
-
return
|
|
4390
|
-
}
|
|
4391
|
-
|
|
4392
|
-
// No editable file (a built-in default, or a package-provided agent) —
|
|
4393
|
-
// create a stub that shadows it.
|
|
4394
|
-
const location = await ctx.ui.select("Choose location", [
|
|
4395
|
-
"Project (.pi/agents/)",
|
|
4396
|
-
`Personal (${personalAgentsDir()})`,
|
|
4397
|
-
])
|
|
4398
|
-
if (!location) return
|
|
4399
|
-
|
|
4400
|
-
const targetDir = location.startsWith("Project")
|
|
4401
|
-
? projectAgentsDir()
|
|
4402
|
-
: personalAgentsDir()
|
|
4403
|
-
mkdirSync(targetDir, { recursive: true })
|
|
4404
|
-
|
|
4405
|
-
const targetPath = join(targetDir, `${name}.md`)
|
|
4406
|
-
const { writeFileSync } = await import("node:fs")
|
|
4407
|
-
writeFileSync(targetPath, "---\nenabled: false\n---\n", "utf-8")
|
|
4408
|
-
reloadCustomAgents()
|
|
4409
|
-
ctx.ui.notify(`Disabled ${name} (${targetPath})`, "info")
|
|
4410
|
-
}
|
|
4411
|
-
|
|
4412
|
-
/** Enable a disabled agent by removing enabled: false from its frontmatter. */
|
|
4413
|
-
async function enableAgent(ctx: ExtensionCommandContext, name: string) {
|
|
4414
|
-
const cfg = getAgentConfig(name)
|
|
4415
|
-
const file = locateAgentFile(name, cfg?.sourcePath, undefined, cfg?.source)
|
|
4416
|
-
if (!file) return
|
|
4417
|
-
|
|
4418
|
-
const content = readFileSync(file.path, "utf-8")
|
|
4419
|
-
const { content: updated, changed } = enableInContent(content)
|
|
4420
|
-
if (!changed && !isEmptyStub(updated)) {
|
|
4421
|
-
// The file carries no `enabled: false` to remove, so it was never disabled
|
|
4422
|
-
// by us — reporting success here would hide a no-op.
|
|
4423
|
-
ctx.ui.notify(`${name} is not disabled in ${file.path}.`, "info")
|
|
4424
|
-
return
|
|
4425
|
-
}
|
|
4426
|
-
const { writeFileSync } = await import("node:fs")
|
|
4427
|
-
|
|
4428
|
-
// If the file was just a stub ("---\n---\n"), delete it to restore the built-in default
|
|
4429
|
-
if (isEmptyStub(updated)) {
|
|
4430
|
-
unlinkSync(file.path)
|
|
4431
|
-
reloadCustomAgents()
|
|
4432
|
-
ctx.ui.notify(`Enabled ${name} (removed ${file.path})`, "info")
|
|
4433
|
-
} else {
|
|
4434
|
-
writeFileSync(file.path, updated, "utf-8")
|
|
4435
|
-
reloadCustomAgents()
|
|
4436
|
-
ctx.ui.notify(`Enabled ${name} (${file.path})`, "info")
|
|
4437
|
-
}
|
|
4438
|
-
}
|
|
4439
|
-
|
|
4440
|
-
async function showCreateWizard(ctx: ExtensionCommandContext) {
|
|
4441
|
-
const location = await ctx.ui.select("Choose location", [
|
|
4442
|
-
"Project (.pi/agents/)",
|
|
4443
|
-
`Personal (${personalAgentsDir()})`,
|
|
4444
|
-
])
|
|
4445
|
-
if (!location) return
|
|
4446
|
-
|
|
4447
|
-
const targetDir = location.startsWith("Project")
|
|
4448
|
-
? projectAgentsDir()
|
|
4449
|
-
: personalAgentsDir()
|
|
4450
|
-
|
|
4451
|
-
const method = await ctx.ui.select("Creation method", [
|
|
4452
|
-
"Generate with Claude (recommended)",
|
|
4453
|
-
"Manual configuration",
|
|
4454
|
-
])
|
|
4455
|
-
if (!method) return
|
|
4456
|
-
|
|
4457
|
-
if (method.startsWith("Generate")) {
|
|
4458
|
-
await showGenerateWizard(ctx, targetDir)
|
|
4459
|
-
} else {
|
|
4460
|
-
await showManualWizard(ctx, targetDir)
|
|
4461
|
-
}
|
|
4462
|
-
}
|
|
4463
|
-
|
|
4464
|
-
async function showGenerateWizard(
|
|
4465
|
-
ctx: ExtensionCommandContext,
|
|
4466
|
-
targetDir: string,
|
|
4467
|
-
) {
|
|
4468
|
-
const description = await ctx.ui.input("Describe what this agent should do")
|
|
4469
|
-
if (!description) return
|
|
4470
|
-
|
|
4471
|
-
const name = await ctx.ui.input("Agent name (filename, no spaces)")
|
|
4472
|
-
if (!name) return
|
|
4473
|
-
|
|
4474
|
-
mkdirSync(targetDir, { recursive: true })
|
|
4475
|
-
|
|
4476
|
-
const targetPath = join(targetDir, `${name}.md`)
|
|
4477
|
-
if (existsSync(targetPath)) {
|
|
4478
|
-
const overwrite = await ctx.ui.confirm(
|
|
4479
|
-
"Overwrite",
|
|
4480
|
-
`${targetPath} already exists. Overwrite?`,
|
|
4481
|
-
)
|
|
4482
|
-
if (!overwrite) return
|
|
4483
|
-
}
|
|
4484
|
-
|
|
4485
|
-
ctx.ui.notify("Generating agent definition...", "info")
|
|
4486
|
-
|
|
4487
|
-
const generatePrompt = `Create a custom pi sub-agent definition file based on this description: "${description}"
|
|
4488
|
-
|
|
4489
|
-
Write a markdown file to: ${targetPath}
|
|
4490
|
-
|
|
4491
|
-
The file format is a markdown file with YAML frontmatter and a system prompt body:
|
|
4492
|
-
|
|
4493
|
-
\`\`\`markdown
|
|
4494
|
-
---
|
|
4495
|
-
description: <one-line description shown in UI>
|
|
4496
|
-
color: <optional agent name badge color: red, blue, green, yellow, purple, orange, pink, cyan, an Agency Agents alias, or quoted "#RRGGBB">
|
|
4497
|
-
tools: <comma-separated built-in tools: read, bash, edit, write, grep, find, ls. Use "none" for no tools. Omit for all tools>
|
|
4498
|
-
model: <optional model as "provider/modelId", e.g. "anthropic/claude-haiku-4-5". Omit to inherit parent model>
|
|
4499
|
-
thinking: <optional thinking level: ${THINKING_LEVELS.join(", ")}. Omit to inherit>
|
|
4500
|
-
max_turns: <optional max agentic turns. 0 or omit for unlimited (default)>
|
|
4501
|
-
prompt_mode: <"replace" (body IS the full system prompt) or "append" (body is appended to default prompt). Default: replace>
|
|
4502
|
-
extensions: <true (inherit all MCP/extension tools), false (none), or comma-separated names. Default: true>
|
|
4503
|
-
skills: <true (inherit all), false (none), or comma-separated skill names to preload into prompt. Default: true>
|
|
4504
|
-
disallowed_tools: <comma-separated tool names to block, even if otherwise available. Omit for none>
|
|
4505
|
-
inherit_context: <true to fork parent conversation into agent so it sees chat history. Default: false>
|
|
4506
|
-
run_in_background: <pin this agent to background (true) or foreground (false). Omit to follow the backgroundByDefault setting, which is background>
|
|
4507
|
-
output_transcript: <false to write no transcript file or path for this agent. Independent of persist_session. Default: true>
|
|
4508
|
-
isolated: <true for no extension/MCP tools, only built-in tools. Default: false>
|
|
4509
|
-
memory: <"user" (global), "project" (per-project), or "local" (gitignored per-project) for persistent memory. Omit for none>${
|
|
4510
|
-
// Offering the field on a project that turned worktrees off would bake a
|
|
4511
|
-
// request that is refused at spawn time into a file that outlives the
|
|
4512
|
-
// session — the #231 pathology (models fill the fields they are shown)
|
|
4513
|
-
// one layer up. Built per invocation, so this read is live.
|
|
4514
|
-
isWorktreeIsolationEnabled()
|
|
4515
|
-
? `\nisolation: <"worktree" to run in isolated git worktree; "off" to refuse one even when the caller asks. Omit for normal>`
|
|
4516
|
-
: ""
|
|
4517
|
-
}
|
|
4518
|
-
---
|
|
4519
|
-
|
|
4520
|
-
<system prompt body — instructions for the agent>
|
|
4521
|
-
\`\`\`
|
|
4522
|
-
|
|
4523
|
-
Guidelines for choosing settings:
|
|
4524
|
-
- For read-only tasks (review, analysis): tools: read, bash, grep, find, ls
|
|
4525
|
-
- For code modification tasks: include edit, write
|
|
4526
|
-
- Use prompt_mode: append if the agent should keep the default system prompt and add specialization on top
|
|
4527
|
-
- Use prompt_mode: replace for fully custom agents with their own personality/instructions
|
|
4528
|
-
- Set inherit_context: true if the agent needs to know what was discussed in the parent conversation
|
|
4529
|
-
- Set isolated: true if the agent should NOT have access to MCP servers or other extensions
|
|
4530
|
-
- 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
|
|
4531
|
-
- Only include frontmatter fields that differ from defaults — omit fields where the default is fine
|
|
4532
|
-
|
|
4533
|
-
Write the file using the write tool. Only write the file, nothing else.`
|
|
4534
|
-
|
|
4535
|
-
const { record } = await manager.spawnAndWait(
|
|
4536
|
-
pi,
|
|
4537
|
-
ctx,
|
|
4538
|
-
"general-purpose",
|
|
4539
|
-
generatePrompt,
|
|
4540
|
-
{
|
|
4541
|
-
description: `Generate ${name} agent`,
|
|
4542
|
-
maxTurns: 5,
|
|
4543
|
-
// Exempt from maxConcurrentForeground. This runs from a modal wizard, not
|
|
4544
|
-
// a tool call: it passes no signal, and Esc in `ctx.ui` never reaches the
|
|
4545
|
-
// manager — so a user waiting behind a full pool would have no way to
|
|
4546
|
-
// cancel at all. It is also one human action that cannot fan out, which
|
|
4547
|
-
// is what the limit exists to bound. It still counts once started.
|
|
4548
|
-
bypassQueue: true,
|
|
4549
|
-
},
|
|
4550
|
-
)
|
|
4551
|
-
|
|
4552
|
-
if (record.status === "error") {
|
|
4553
|
-
ctx.ui.notify(`Generation failed: ${record.error}`, "warning")
|
|
4554
|
-
return
|
|
4555
|
-
}
|
|
4556
|
-
|
|
4557
|
-
reloadCustomAgents()
|
|
4558
|
-
|
|
4559
|
-
if (existsSync(targetPath)) {
|
|
4560
|
-
ctx.ui.notify(`Created ${targetPath}`, "info")
|
|
4561
|
-
} else {
|
|
4562
|
-
ctx.ui.notify(
|
|
4563
|
-
"Agent generation completed but file was not created. Check the agent output.",
|
|
4564
|
-
"warning",
|
|
4565
|
-
)
|
|
4566
|
-
}
|
|
4567
|
-
}
|
|
4568
|
-
|
|
4569
|
-
async function showManualWizard(
|
|
4570
|
-
ctx: ExtensionCommandContext,
|
|
4571
|
-
targetDir: string,
|
|
4572
|
-
) {
|
|
4573
|
-
// 1. Name
|
|
4574
|
-
const name = await ctx.ui.input("Agent name (filename, no spaces)")
|
|
4575
|
-
if (!name) return
|
|
4576
|
-
|
|
4577
|
-
// 2. Description
|
|
4578
|
-
const description = await ctx.ui.input("Description (one line)")
|
|
4579
|
-
if (!description) return
|
|
4580
|
-
|
|
4581
|
-
// 3. Tools
|
|
4582
|
-
const toolChoice = await ctx.ui.select("Tools", [
|
|
4583
|
-
"all",
|
|
4584
|
-
"none",
|
|
4585
|
-
"read-only (read, bash, grep, find, ls)",
|
|
4586
|
-
"custom...",
|
|
4587
|
-
])
|
|
4588
|
-
if (!toolChoice) return
|
|
4589
|
-
|
|
4590
|
-
let tools: string
|
|
4591
|
-
if (toolChoice === "all") {
|
|
4592
|
-
tools = BUILTIN_TOOL_NAMES.join(", ")
|
|
4593
|
-
} else if (toolChoice === "none") {
|
|
4594
|
-
tools = "none"
|
|
4595
|
-
} else if (toolChoice.startsWith("read-only")) {
|
|
4596
|
-
tools = "read, bash, grep, find, ls"
|
|
4597
|
-
} else {
|
|
4598
|
-
const customTools = await ctx.ui.input(
|
|
4599
|
-
"Tools (comma-separated)",
|
|
4600
|
-
BUILTIN_TOOL_NAMES.join(", "),
|
|
4601
|
-
)
|
|
4602
|
-
if (!customTools) return
|
|
4603
|
-
tools = customTools
|
|
4604
|
-
}
|
|
4605
|
-
|
|
4606
|
-
// 4. Model
|
|
4607
|
-
const modelChoice = await ctx.ui.select("Model", [
|
|
4608
|
-
"inherit (parent model)",
|
|
4609
|
-
"haiku",
|
|
4610
|
-
"sonnet",
|
|
4611
|
-
"opus",
|
|
4612
|
-
"custom...",
|
|
4613
|
-
])
|
|
4614
|
-
if (!modelChoice) return
|
|
4615
|
-
|
|
4616
|
-
let model: string | undefined
|
|
4617
|
-
if (modelChoice === "haiku") model = "anthropic/claude-haiku-4-5"
|
|
4618
|
-
else if (modelChoice === "sonnet") model = "anthropic/claude-sonnet-4-6"
|
|
4619
|
-
else if (modelChoice === "opus") model = "anthropic/claude-opus-4-6"
|
|
4620
|
-
else if (modelChoice === "custom...") {
|
|
4621
|
-
model = (await ctx.ui.input("Model (provider/modelId)")) || undefined
|
|
4622
|
-
}
|
|
4623
|
-
|
|
4624
|
-
// 5. Thinking
|
|
4625
|
-
// "inherit" is a UI-only pseudo-choice (omit the field); the rest mirror pi.
|
|
4626
|
-
const thinkingChoice = await ctx.ui.select("Thinking level", [
|
|
4627
|
-
"inherit",
|
|
4628
|
-
...THINKING_LEVELS,
|
|
4629
|
-
])
|
|
4630
|
-
if (!thinkingChoice) return
|
|
4631
|
-
|
|
4632
|
-
// 6. System prompt
|
|
4633
|
-
const systemPrompt = await ctx.ui.editor("System prompt", "")
|
|
4634
|
-
if (systemPrompt === undefined) return
|
|
4635
|
-
|
|
4636
|
-
const content = buildNewAgentFile({
|
|
4637
|
-
description,
|
|
4638
|
-
tools,
|
|
4639
|
-
model,
|
|
4640
|
-
thinking: thinkingChoice === "inherit" ? undefined : thinkingChoice,
|
|
4641
|
-
systemPrompt,
|
|
4642
|
-
})
|
|
4643
|
-
|
|
4644
|
-
mkdirSync(targetDir, { recursive: true })
|
|
4645
|
-
const targetPath = join(targetDir, `${name}.md`)
|
|
4646
|
-
|
|
4647
|
-
if (existsSync(targetPath)) {
|
|
4648
|
-
const overwrite = await ctx.ui.confirm(
|
|
4649
|
-
"Overwrite",
|
|
4650
|
-
`${targetPath} already exists. Overwrite?`,
|
|
4651
|
-
)
|
|
4652
|
-
if (!overwrite) return
|
|
4653
|
-
}
|
|
4654
|
-
|
|
4655
|
-
const { writeFileSync } = await import("node:fs")
|
|
4656
|
-
writeFileSync(targetPath, content, "utf-8")
|
|
4657
|
-
reloadCustomAgents()
|
|
4658
|
-
ctx.ui.notify(`Created ${targetPath}`, "info")
|
|
4659
|
-
}
|
|
4660
|
-
|
|
4661
4051
|
/**
|
|
4662
4052
|
* Every settings mutation writes this WHOLE object back to disk, so a field
|
|
4663
4053
|
* missing here is erased from the user's subagents.json the next time they
|
|
@@ -4672,6 +4062,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4672
4062
|
maxConcurrent: manager.getMaxConcurrent(),
|
|
4673
4063
|
// 0 = unlimited, and the default — see SubagentsSettings.
|
|
4674
4064
|
maxConcurrentForeground: manager.getMaxConcurrentForeground(),
|
|
4065
|
+
maxConcurrentNested: manager.getMaxConcurrentNested(),
|
|
4675
4066
|
// 0 = unlimited — per SubagentsSettings.defaultMaxTurns docstring and
|
|
4676
4067
|
// normalizeMaxTurns() in agent-runner.ts (which maps 0 → undefined).
|
|
4677
4068
|
defaultMaxTurns: getDefaultMaxTurns() ?? 0,
|
|
@@ -4726,6 +4117,35 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4726
4117
|
const _settingsSnapshotIsComplete: _NoMissingSettingsKeys = true
|
|
4727
4118
|
void _settingsSnapshotIsComplete
|
|
4728
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
|
+
|
|
4729
4149
|
/**
|
|
4730
4150
|
* Whether a package gate lets anything through. `undefined` is the unset
|
|
4731
4151
|
* default and reads as `true`; an empty allowlist matches nothing, like
|
|
@@ -4755,18 +4175,42 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4755
4175
|
: `${base} Currently limited to an empty list, so nothing loads.`
|
|
4756
4176
|
}
|
|
4757
4177
|
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
"
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
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
|
+
}
|
|
4765
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
|
+
*/
|
|
4766
4208
|
async function showSettings(ctx: ExtensionCommandContext) {
|
|
4209
|
+
let scope: SettingsScope = defaultSettingsScope(process.cwd())
|
|
4767
4210
|
function buildItems(): SettingItem[] {
|
|
4768
4211
|
const mc = manager.getMaxConcurrent()
|
|
4769
4212
|
const mcf = manager.getMaxConcurrentForeground()
|
|
4213
|
+
const mcn = manager.getMaxConcurrentNested()
|
|
4770
4214
|
const dmt = getDefaultMaxTurns() ?? 0
|
|
4771
4215
|
const gt = getGraceTurns()
|
|
4772
4216
|
const msd = getMaxSubagentDepth()
|
|
@@ -4778,11 +4222,14 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4778
4222
|
const fallbackValue = getFallbackSubagent() ?? "general-purpose"
|
|
4779
4223
|
const fallbackValues = [...new Set([...getAvailableTypes(), NO_FALLBACK])]
|
|
4780
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.
|
|
4781
4227
|
return [
|
|
4782
4228
|
{
|
|
4783
4229
|
id: "maxConcurrent",
|
|
4784
|
-
label: "Max concurrency",
|
|
4785
|
-
description:
|
|
4230
|
+
label: "Max background concurrency",
|
|
4231
|
+
description:
|
|
4232
|
+
"Max concurrent background agents; extras wait in a queue (Enter to type)",
|
|
4786
4233
|
currentValue: String(mc),
|
|
4787
4234
|
values: [String(mc)],
|
|
4788
4235
|
},
|
|
@@ -4790,10 +4237,26 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4790
4237
|
id: "maxConcurrentForeground",
|
|
4791
4238
|
label: "Max foreground concurrency",
|
|
4792
4239
|
description:
|
|
4793
|
-
"Max concurrent foreground (blocking) agents (0 = unlimited, Enter to type)",
|
|
4240
|
+
"Max concurrent foreground (blocking) agents; extras wait in a queue (0 = unlimited, Enter to type)",
|
|
4794
4241
|
currentValue: String(mcf),
|
|
4795
4242
|
values: [String(mcf)],
|
|
4796
4243
|
},
|
|
4244
|
+
{
|
|
4245
|
+
id: "maxConcurrentNested",
|
|
4246
|
+
label: "Max nested concurrency",
|
|
4247
|
+
description:
|
|
4248
|
+
"Max concurrent nested agents (started by subagents); extras are refused (0 = unlimited, Enter to type)",
|
|
4249
|
+
currentValue: String(mcn),
|
|
4250
|
+
values: [String(mcn)],
|
|
4251
|
+
},
|
|
4252
|
+
{
|
|
4253
|
+
id: "maxSubagentDepth",
|
|
4254
|
+
label: "Nested depth",
|
|
4255
|
+
description:
|
|
4256
|
+
"Hard cap on nested delegation — main is 0, its subagents 1 (0/1 = nesting off, even with allowed_subagents; Enter to type)",
|
|
4257
|
+
currentValue: String(msd),
|
|
4258
|
+
values: [String(msd)],
|
|
4259
|
+
},
|
|
4797
4260
|
{
|
|
4798
4261
|
id: "defaultMaxTurns",
|
|
4799
4262
|
label: "Default max turns",
|
|
@@ -4809,14 +4272,6 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4809
4272
|
currentValue: String(gt),
|
|
4810
4273
|
values: [String(gt)],
|
|
4811
4274
|
},
|
|
4812
|
-
{
|
|
4813
|
-
id: "maxSubagentDepth",
|
|
4814
|
-
label: "Nested depth",
|
|
4815
|
-
description:
|
|
4816
|
-
"Hard cap on nested delegation — main is 0, its subagents 1 (0/1 = nesting off, Enter to type)",
|
|
4817
|
-
currentValue: String(msd),
|
|
4818
|
-
values: [String(msd)],
|
|
4819
|
-
},
|
|
4820
4275
|
{
|
|
4821
4276
|
id: "joinMode",
|
|
4822
4277
|
label: "Join mode",
|
|
@@ -4834,6 +4289,37 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4834
4289
|
currentValue: getBackgroundByDefault() ? "on" : "off",
|
|
4835
4290
|
values: ["on", "off"],
|
|
4836
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
|
+
},
|
|
4837
4323
|
{
|
|
4838
4324
|
id: "schedulingEnabled",
|
|
4839
4325
|
label: "Scheduling",
|
|
@@ -4851,6 +4337,30 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4851
4337
|
currentValue: isWorkflowsEnabled() ? "on" : "off",
|
|
4852
4338
|
values: ["on", "off"],
|
|
4853
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
|
+
},
|
|
4854
4364
|
{
|
|
4855
4365
|
id: "packageAgents",
|
|
4856
4366
|
label: "Package agents",
|
|
@@ -4877,14 +4387,6 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4877
4387
|
: "off",
|
|
4878
4388
|
values: ["on", "off"],
|
|
4879
4389
|
},
|
|
4880
|
-
{
|
|
4881
|
-
id: "scopeModels",
|
|
4882
|
-
label: "Scope models",
|
|
4883
|
-
description:
|
|
4884
|
-
"Validate subagent models against scoped models (/scoped-models)",
|
|
4885
|
-
currentValue: isScopeModelsEnabled() ? "on" : "off",
|
|
4886
|
-
values: ["on", "off"],
|
|
4887
|
-
},
|
|
4888
4390
|
{
|
|
4889
4391
|
id: "strictAgentFiles",
|
|
4890
4392
|
label: "Strict agent files",
|
|
@@ -4893,21 +4395,6 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4893
4395
|
currentValue: strictAgentFiles ? "on" : "off",
|
|
4894
4396
|
values: ["on", "off"],
|
|
4895
4397
|
},
|
|
4896
|
-
{
|
|
4897
|
-
id: "disableDefaultAgents",
|
|
4898
|
-
label: "Disable defaults",
|
|
4899
|
-
description:
|
|
4900
|
-
"Hide built-in agents (general-purpose, Explore, Plan) — custom agents are unaffected",
|
|
4901
|
-
currentValue: isDefaultsDisabled() ? "on" : "off",
|
|
4902
|
-
values: ["on", "off"],
|
|
4903
|
-
},
|
|
4904
|
-
{
|
|
4905
|
-
id: "fallbackSubagent",
|
|
4906
|
-
label: "Fallback agent",
|
|
4907
|
-
description: `Agent used when subagent_type is unknown, disabled, or ambiguous; "${NO_FALLBACK}" rejects the call instead (strict dispatch)`,
|
|
4908
|
-
currentValue: fallbackValue,
|
|
4909
|
-
values: fallbackValues,
|
|
4910
|
-
},
|
|
4911
4398
|
{
|
|
4912
4399
|
id: "outputTranscript",
|
|
4913
4400
|
label: "Output transcript",
|
|
@@ -4917,19 +4404,27 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4917
4404
|
values: ["on", "off"],
|
|
4918
4405
|
},
|
|
4919
4406
|
{
|
|
4920
|
-
id: "
|
|
4921
|
-
label: "
|
|
4407
|
+
id: "widgetMode",
|
|
4408
|
+
label: "Widget",
|
|
4922
4409
|
description:
|
|
4923
|
-
"
|
|
4924
|
-
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",
|
|
4925
4420
|
values: ["on", "off"],
|
|
4926
4421
|
},
|
|
4927
4422
|
{
|
|
4928
|
-
id: "
|
|
4929
|
-
label: "
|
|
4423
|
+
id: "showModel",
|
|
4424
|
+
label: "Show model",
|
|
4930
4425
|
description:
|
|
4931
|
-
"
|
|
4932
|
-
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",
|
|
4933
4428
|
values: ["on", "off"],
|
|
4934
4429
|
},
|
|
4935
4430
|
{
|
|
@@ -4940,14 +4435,6 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4940
4435
|
currentValue: isShowCostEnabled() ? "on" : "off",
|
|
4941
4436
|
values: ["on", "off"],
|
|
4942
4437
|
},
|
|
4943
|
-
{
|
|
4944
|
-
id: "showModel",
|
|
4945
|
-
label: "Show model",
|
|
4946
|
-
description:
|
|
4947
|
-
"Name the model driving each agent, and the thinking level it is running at, on the widget's running rows. The Agent tool result and the conversation viewer show the pair either way — this adds it to the widget, where the row is already dense.",
|
|
4948
|
-
currentValue: isShowModelEnabled() ? "on" : "off",
|
|
4949
|
-
values: ["on", "off"],
|
|
4950
|
-
},
|
|
4951
4438
|
{
|
|
4952
4439
|
id: "viewerMarkdown",
|
|
4953
4440
|
label: "Viewer markdown",
|
|
@@ -4957,54 +4444,29 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
4957
4444
|
values: ["off", "assistant", "all"],
|
|
4958
4445
|
},
|
|
4959
4446
|
{
|
|
4960
|
-
id: "
|
|
4961
|
-
label: "
|
|
4962
|
-
description:
|
|
4963
|
-
"Claude Code-style main+subagents list below the editor (↓/← to navigate, Enter to view)",
|
|
4964
|
-
currentValue: isFleetViewEnabled() ? "on" : "off",
|
|
4965
|
-
values: ["on", "off"],
|
|
4966
|
-
},
|
|
4967
|
-
{
|
|
4968
|
-
id: "agentMentions",
|
|
4969
|
-
label: "Agent mentions",
|
|
4970
|
-
description:
|
|
4971
|
-
"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.",
|
|
4972
|
-
currentValue: getAgentMentionMode(),
|
|
4973
|
-
values: ["model", "direct", "off"],
|
|
4974
|
-
},
|
|
4975
|
-
{
|
|
4976
|
-
id: "rememberAgents",
|
|
4977
|
-
label: "Remember agents",
|
|
4447
|
+
id: "reportUsage",
|
|
4448
|
+
label: "Report usage to session",
|
|
4978
4449
|
description:
|
|
4979
|
-
"
|
|
4980
|
-
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",
|
|
4981
4452
|
values: ["on", "off"],
|
|
4982
4453
|
},
|
|
4983
|
-
{
|
|
4984
|
-
id: "widgetMode",
|
|
4985
|
-
label: "Widget",
|
|
4986
|
-
description:
|
|
4987
|
-
"Above-editor agent widget: all = every agent; background = hide foreground (they already render inline); off = hide the widget.",
|
|
4988
|
-
currentValue: getWidgetMode(),
|
|
4989
|
-
values: ["all", "background", "off"],
|
|
4990
|
-
},
|
|
4991
|
-
{
|
|
4992
|
-
id: "toolDescriptionMode",
|
|
4993
|
-
label: "Tool description",
|
|
4994
|
-
description:
|
|
4995
|
-
"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}})",
|
|
4996
|
-
currentValue: getToolDescriptionMode(),
|
|
4997
|
-
values: ["full", "compact", "custom"],
|
|
4998
|
-
},
|
|
4999
4454
|
]
|
|
5000
4455
|
}
|
|
5001
4456
|
|
|
5002
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
|
+
}
|
|
5003
4465
|
if (id === "maxConcurrent") {
|
|
5004
4466
|
const n = parseInt(value, 10)
|
|
5005
4467
|
if (n >= 1) {
|
|
5006
4468
|
manager.setMaxConcurrent(n)
|
|
5007
|
-
notifyApplied(ctx, `Max concurrency set to ${n}`)
|
|
4469
|
+
notifyApplied(ctx, target, `Max background concurrency set to ${n}`)
|
|
5008
4470
|
}
|
|
5009
4471
|
} else if (id === "maxConcurrentForeground") {
|
|
5010
4472
|
// 0 is meaningful here, unlike maxConcurrent above: it means unlimited.
|
|
@@ -5013,25 +4475,38 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5013
4475
|
manager.setMaxConcurrentForeground(n)
|
|
5014
4476
|
notifyApplied(
|
|
5015
4477
|
ctx,
|
|
4478
|
+
target,
|
|
5016
4479
|
n === 0
|
|
5017
4480
|
? "Max foreground concurrency set to unlimited"
|
|
5018
4481
|
: `Max foreground concurrency set to ${n}`,
|
|
5019
4482
|
)
|
|
5020
4483
|
}
|
|
4484
|
+
} else if (id === "maxConcurrentNested") {
|
|
4485
|
+
const n = parseInt(value, 10)
|
|
4486
|
+
if (n >= 0) {
|
|
4487
|
+
manager.setMaxConcurrentNested(n)
|
|
4488
|
+
notifyApplied(
|
|
4489
|
+
ctx,
|
|
4490
|
+
target,
|
|
4491
|
+
n === 0
|
|
4492
|
+
? "Max nested concurrency set to unlimited"
|
|
4493
|
+
: `Max nested concurrency set to ${n}`,
|
|
4494
|
+
)
|
|
4495
|
+
}
|
|
5021
4496
|
} else if (id === "defaultMaxTurns") {
|
|
5022
4497
|
const n = parseInt(value, 10)
|
|
5023
4498
|
if (n === 0) {
|
|
5024
4499
|
setDefaultMaxTurns(undefined)
|
|
5025
|
-
notifyApplied(ctx, "Default max turns set to unlimited")
|
|
4500
|
+
notifyApplied(ctx, target, "Default max turns set to unlimited")
|
|
5026
4501
|
} else if (n >= 1) {
|
|
5027
4502
|
setDefaultMaxTurns(n)
|
|
5028
|
-
notifyApplied(ctx, `Default max turns set to ${n}`)
|
|
4503
|
+
notifyApplied(ctx, target, `Default max turns set to ${n}`)
|
|
5029
4504
|
}
|
|
5030
4505
|
} else if (id === "graceTurns") {
|
|
5031
4506
|
const n = parseInt(value, 10)
|
|
5032
4507
|
if (n >= 1) {
|
|
5033
4508
|
setGraceTurns(n)
|
|
5034
|
-
notifyApplied(ctx, `Grace turns set to ${n}`)
|
|
4509
|
+
notifyApplied(ctx, target, `Grace turns set to ${n}`)
|
|
5035
4510
|
}
|
|
5036
4511
|
} else if (id === "maxSubagentDepth") {
|
|
5037
4512
|
const n = parseInt(value, 10)
|
|
@@ -5039,19 +4514,21 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5039
4514
|
setMaxSubagentDepth(n)
|
|
5040
4515
|
notifyApplied(
|
|
5041
4516
|
ctx,
|
|
4517
|
+
target,
|
|
5042
4518
|
n <= 1
|
|
5043
|
-
? "Nested delegation disabled"
|
|
4519
|
+
? "Nested delegation disabled for every agent, including those with allowed_subagents"
|
|
5044
4520
|
: `Nested depth set to ${n}. Applies to agents started from now on.`,
|
|
5045
4521
|
)
|
|
5046
4522
|
}
|
|
5047
4523
|
} else if (id === "joinMode") {
|
|
5048
4524
|
setDefaultJoinMode(value as JoinMode)
|
|
5049
|
-
notifyApplied(ctx, `Default join mode set to ${value}`)
|
|
4525
|
+
notifyApplied(ctx, target, `Default join mode set to ${value}`)
|
|
5050
4526
|
} else if (id === "backgroundByDefault") {
|
|
5051
4527
|
const enabled = value === "on"
|
|
5052
4528
|
setBackgroundByDefault(enabled)
|
|
5053
4529
|
notifyApplied(
|
|
5054
4530
|
ctx,
|
|
4531
|
+
target,
|
|
5055
4532
|
enabled
|
|
5056
4533
|
? "Agent calls run in the background unless they pass run_in_background: false"
|
|
5057
4534
|
: "Agent calls block and return inline unless they pass run_in_background: true",
|
|
@@ -5068,6 +4545,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5068
4545
|
if (!enabled) scheduler.stop() // immediate kill — outstanding fires stop ticking
|
|
5069
4546
|
notifyApplied(
|
|
5070
4547
|
ctx,
|
|
4548
|
+
target,
|
|
5071
4549
|
`Scheduling ${enabled ? "enabled" : "disabled"}. Tool spec change takes effect on next pi session.`,
|
|
5072
4550
|
)
|
|
5073
4551
|
}
|
|
@@ -5085,18 +4563,24 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5085
4563
|
// lose work the user never asked to discard.
|
|
5086
4564
|
notifyApplied(
|
|
5087
4565
|
ctx,
|
|
4566
|
+
target,
|
|
5088
4567
|
`Workflows ${enabled ? "enabled" : "disabled"}. Tool spec change takes effect on next pi session.`,
|
|
5089
4568
|
)
|
|
5090
4569
|
}
|
|
5091
4570
|
} else if (id === "scopeModels") {
|
|
5092
4571
|
const enabled = value === "on"
|
|
5093
4572
|
setScopeModelsEnabled(enabled)
|
|
5094
|
-
notifyApplied(
|
|
4573
|
+
notifyApplied(
|
|
4574
|
+
ctx,
|
|
4575
|
+
target,
|
|
4576
|
+
`Scope models ${enabled ? "enabled" : "disabled"}`,
|
|
4577
|
+
)
|
|
5095
4578
|
} else if (id === "strictAgentFiles") {
|
|
5096
4579
|
const enabled = value === "on"
|
|
5097
4580
|
strictAgentFiles = enabled
|
|
5098
4581
|
notifyApplied(
|
|
5099
4582
|
ctx,
|
|
4583
|
+
target,
|
|
5100
4584
|
`Strict agent files ${enabled ? "enabled" : "disabled"}. Takes effect on next pi session.`,
|
|
5101
4585
|
)
|
|
5102
4586
|
} else if (id === "disableDefaultAgents") {
|
|
@@ -5104,12 +4588,14 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5104
4588
|
setDisableDefaultAgents(enabled)
|
|
5105
4589
|
notifyApplied(
|
|
5106
4590
|
ctx,
|
|
4591
|
+
target,
|
|
5107
4592
|
`Default agents ${enabled ? "disabled" : "enabled"}. Tool spec change takes effect on next pi session.`,
|
|
5108
4593
|
)
|
|
5109
4594
|
} else if (id === "fallbackSubagent") {
|
|
5110
4595
|
setFallbackSubagent(value)
|
|
5111
4596
|
notifyApplied(
|
|
5112
4597
|
ctx,
|
|
4598
|
+
target,
|
|
5113
4599
|
value === NO_FALLBACK
|
|
5114
4600
|
? "Unknown or disabled agent types will now be rejected"
|
|
5115
4601
|
: `Unknown agent types will fall back to ${value}`,
|
|
@@ -5119,6 +4605,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5119
4605
|
setOutputTranscriptDefault(enabled)
|
|
5120
4606
|
notifyApplied(
|
|
5121
4607
|
ctx,
|
|
4608
|
+
target,
|
|
5122
4609
|
`Output transcript ${enabled ? "enabled" : "disabled"} by default`,
|
|
5123
4610
|
)
|
|
5124
4611
|
} else if (id === "worktreeIsolation") {
|
|
@@ -5128,6 +4615,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5128
4615
|
// the isolation parameter only appears/disappears next session.
|
|
5129
4616
|
notifyApplied(
|
|
5130
4617
|
ctx,
|
|
4618
|
+
target,
|
|
5131
4619
|
`Worktree isolation ${enabled ? "enabled" : "disabled"}. Tool parameter updates on next pi session.`,
|
|
5132
4620
|
)
|
|
5133
4621
|
} else if (id === "packageAgents" || id === "packageWorkflows") {
|
|
@@ -5153,12 +4641,14 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5153
4641
|
: ""
|
|
5154
4642
|
notifyApplied(
|
|
5155
4643
|
ctx,
|
|
4644
|
+
target,
|
|
5156
4645
|
`${label} ${enabled ? "enabled" : "disabled"}.${replaced}${specNote}`,
|
|
5157
4646
|
)
|
|
5158
4647
|
} else if (id === "toolDescriptionMode") {
|
|
5159
4648
|
setToolDescriptionMode(value as ToolDescriptionMode)
|
|
5160
4649
|
notifyApplied(
|
|
5161
4650
|
ctx,
|
|
4651
|
+
target,
|
|
5162
4652
|
`Tool description set to ${value}. Takes effect on next pi session.`,
|
|
5163
4653
|
)
|
|
5164
4654
|
} else if (id === "reportUsage") {
|
|
@@ -5166,6 +4656,7 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5166
4656
|
setReportUsage(enabled)
|
|
5167
4657
|
notifyApplied(
|
|
5168
4658
|
ctx,
|
|
4659
|
+
target,
|
|
5169
4660
|
enabled
|
|
5170
4661
|
? "Subagent usage now counted in this session's totals"
|
|
5171
4662
|
: "Subagent usage no longer counted in this session's totals",
|
|
@@ -5173,23 +4664,36 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5173
4664
|
} else if (id === "showCost") {
|
|
5174
4665
|
const enabled = value === "on"
|
|
5175
4666
|
setShowCost(enabled)
|
|
5176
|
-
notifyApplied(
|
|
4667
|
+
notifyApplied(
|
|
4668
|
+
ctx,
|
|
4669
|
+
target,
|
|
4670
|
+
`Cost display ${enabled ? "enabled" : "disabled"}`,
|
|
4671
|
+
)
|
|
5177
4672
|
} else if (id === "showModel") {
|
|
5178
4673
|
const enabled = value === "on"
|
|
5179
4674
|
setShowModel(enabled)
|
|
5180
|
-
notifyApplied(
|
|
4675
|
+
notifyApplied(
|
|
4676
|
+
ctx,
|
|
4677
|
+
target,
|
|
4678
|
+
`Model display ${enabled ? "enabled" : "disabled"}`,
|
|
4679
|
+
)
|
|
5181
4680
|
} else if (id === "viewerMarkdown") {
|
|
5182
4681
|
setViewerMarkdown(value as ViewerMarkdownMode)
|
|
5183
|
-
notifyApplied(ctx, `Viewer markdown set to ${value}`)
|
|
4682
|
+
notifyApplied(ctx, target, `Viewer markdown set to ${value}`)
|
|
5184
4683
|
} else if (id === "fleetView") {
|
|
5185
4684
|
const enabled = value === "on"
|
|
5186
4685
|
setFleetViewEnabled(enabled)
|
|
5187
|
-
notifyApplied(
|
|
4686
|
+
notifyApplied(
|
|
4687
|
+
ctx,
|
|
4688
|
+
target,
|
|
4689
|
+
`Fleet view ${enabled ? "enabled" : "disabled"}`,
|
|
4690
|
+
)
|
|
5188
4691
|
} else if (id === "agentMentions") {
|
|
5189
4692
|
const mode = value as AgentMentionMode
|
|
5190
4693
|
setAgentMentionMode(mode)
|
|
5191
4694
|
notifyApplied(
|
|
5192
4695
|
ctx,
|
|
4696
|
+
target,
|
|
5193
4697
|
mode === "off"
|
|
5194
4698
|
? "Agent mentions disabled"
|
|
5195
4699
|
: mode === "model"
|
|
@@ -5201,102 +4705,81 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5201
4705
|
setRememberAgents(enabled)
|
|
5202
4706
|
notifyApplied(
|
|
5203
4707
|
ctx,
|
|
4708
|
+
target,
|
|
5204
4709
|
`Remember agents ${enabled ? "enabled" : "disabled"}`,
|
|
5205
4710
|
)
|
|
5206
4711
|
} else if (id === "widgetMode") {
|
|
5207
4712
|
setWidgetMode(value as WidgetMode)
|
|
5208
|
-
notifyApplied(ctx, `Widget set to ${value}`)
|
|
4713
|
+
notifyApplied(ctx, target, `Widget set to ${value}`)
|
|
5209
4714
|
}
|
|
5210
4715
|
}
|
|
5211
4716
|
|
|
5212
|
-
|
|
5213
|
-
//
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
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",
|
|
5229
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
|
+
}
|
|
5230
4755
|
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
return
|
|
5254
|
-
}
|
|
5255
|
-
list.handleInput?.(data)
|
|
5256
|
-
},
|
|
5257
|
-
}
|
|
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"
|
|
5258
4778
|
},
|
|
5259
|
-
)
|
|
5260
|
-
|
|
5261
|
-
// If a numeric field ID was returned, prompt for typed input
|
|
5262
|
-
if (result && NUMERIC_IDS.has(result)) {
|
|
5263
|
-
const current =
|
|
5264
|
-
result === "maxConcurrent"
|
|
5265
|
-
? String(manager.getMaxConcurrent())
|
|
5266
|
-
: result === "maxConcurrentForeground"
|
|
5267
|
-
? String(manager.getMaxConcurrentForeground())
|
|
5268
|
-
: result === "defaultMaxTurns"
|
|
5269
|
-
? String(getDefaultMaxTurns() ?? 0)
|
|
5270
|
-
: result === "maxSubagentDepth"
|
|
5271
|
-
? String(getMaxSubagentDepth())
|
|
5272
|
-
: String(getGraceTurns())
|
|
5273
|
-
|
|
5274
|
-
const label =
|
|
5275
|
-
result === "maxConcurrent"
|
|
5276
|
-
? "Max concurrency (1+)"
|
|
5277
|
-
: result === "maxConcurrentForeground"
|
|
5278
|
-
? "Max foreground concurrency (0 = unlimited)"
|
|
5279
|
-
: result === "defaultMaxTurns"
|
|
5280
|
-
? "Default max turns (0 = unlimited)"
|
|
5281
|
-
: result === "maxSubagentDepth"
|
|
5282
|
-
? "Nested depth (0/1 = nesting off)"
|
|
5283
|
-
: "Grace turns (1+)"
|
|
5284
|
-
|
|
5285
|
-
// Loop until user enters a valid integer or cancels (Esc / null).
|
|
5286
|
-
// Silently trims whitespace; rejects non-numeric input by re-prompting.
|
|
5287
|
-
let input: string | undefined = await ctx.ui.input(label, current)
|
|
5288
|
-
while (input != null) {
|
|
5289
|
-
const trimmed = input.trim()
|
|
5290
|
-
const n = Number(trimmed)
|
|
5291
|
-
if (trimmed !== "" && Number.isInteger(n)) {
|
|
5292
|
-
applyValue(result, String(n))
|
|
5293
|
-
await showSettings(ctx)
|
|
5294
|
-
return
|
|
5295
|
-
}
|
|
5296
|
-
// Invalid — re-prompt with the user's last entry so they can edit it
|
|
5297
|
-
input = await ctx.ui.input(label, trimmed)
|
|
5298
|
-
}
|
|
5299
4779
|
}
|
|
4780
|
+
await ctx.ui.custom<undefined>((tui, theme, kb, done) =>
|
|
4781
|
+
createSettingsPage(deps, tui, theme, kb, () => done(undefined)),
|
|
4782
|
+
)
|
|
5300
4783
|
}
|
|
5301
4784
|
|
|
5302
4785
|
// Persist the current snapshot, emit `subagents:settings_changed`, and surface
|
|
@@ -5316,33 +4799,22 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5316
4799
|
ctx: ExtensionCommandContext | undefined,
|
|
5317
4800
|
changeMsg: string,
|
|
5318
4801
|
): void {
|
|
5319
|
-
const { message, level } =
|
|
5320
|
-
snapshotSettings(),
|
|
5321
|
-
changeMsg,
|
|
5322
|
-
(event, payload) => pi.events.emit(event, payload),
|
|
5323
|
-
)
|
|
4802
|
+
const { message, level } = saveSnapshot(changeMsg)
|
|
5324
4803
|
// `ctx` is absent only on the fleet path between sessions, where
|
|
5325
4804
|
// `currentCtx` has been cleared and there is no UI to carry the warning to.
|
|
5326
4805
|
// The write still happens.
|
|
5327
4806
|
if (level === "warning") ctx?.ui.notify(message, level)
|
|
5328
4807
|
}
|
|
5329
4808
|
|
|
5330
|
-
function notifyApplied(
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
)
|
|
4809
|
+
function notifyApplied(
|
|
4810
|
+
ctx: ExtensionCommandContext,
|
|
4811
|
+
target: SettingsTarget,
|
|
4812
|
+
successMsg: string,
|
|
4813
|
+
) {
|
|
4814
|
+
const { message, level } = saveSnapshot(successMsg, target)
|
|
5336
4815
|
ctx.ui.notify(message, level)
|
|
5337
4816
|
}
|
|
5338
4817
|
|
|
5339
|
-
pi.registerCommand("agents", {
|
|
5340
|
-
description: "Manage agents",
|
|
5341
|
-
handler: async (_args, ctx) => {
|
|
5342
|
-
await showAgentsMenu(ctx)
|
|
5343
|
-
},
|
|
5344
|
-
})
|
|
5345
|
-
|
|
5346
4818
|
/**
|
|
5347
4819
|
* What `/agents → Workflows` and the fleet list's `workflow` rows need from
|
|
5348
4820
|
* here. One object, built once: both entry points open the same inspector,
|
|
@@ -5362,4 +4834,22 @@ Write the file using the write tool. Only write the file, nothing else.`
|
|
|
5362
4834
|
fleet.setWorkflowSource(fleetWorkflows, (id) =>
|
|
5363
4835
|
openWorkflowFromFleet(id, workflowMenuDeps),
|
|
5364
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
|
+
})
|
|
5365
4855
|
}
|