pi-better-harness 0.65.1 → 0.66.0
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 +14 -0
- package/README.md +16 -12
- package/extensions/minimal-output/index.ts +1 -1
- package/extensions/native-compaction/index.ts +5 -3
- package/extensions/settings/commands.ts +56 -46
- package/extensions/settings/copy.ts +0 -5
- package/extensions/settings/index.ts +8 -7
- package/extensions/settings/menu.ts +117 -36
- package/extensions/settings/page.ts +51 -21
- package/extensions/settings/registry.ts +3 -0
- package/extensions/shared-navigator-panels.ts +11 -1
- package/lib/codex-model-prompt.mjs +3 -1
- package/lib/install-settings.mjs +10 -0
- package/lib/instructions.mjs +4 -10
- package/node_modules/pi-better-background-tasks/package.json +2 -2
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-arm64.json +1 -1
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/darwin-x64.json +1 -1
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-arm64.json +1 -1
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/linux-x64.json +1 -1
- package/node_modules/pi-better-background-tasks/runtime-client/artifacts/win32-x64.json +1 -1
- package/node_modules/pi-better-background-tasks/src/shared-harness-commands.ts +56 -46
- package/node_modules/pi-better-background-tasks/src/shared-harness-copy.ts +0 -5
- package/node_modules/pi-better-background-tasks/src/shared-harness-menu.ts +117 -36
- package/node_modules/pi-better-background-tasks/src/shared-harness-page.ts +51 -21
- package/node_modules/pi-better-background-tasks/src/shared-harness-registry.ts +3 -0
- package/node_modules/pi-better-background-tasks/src/shared-navigator-panels.ts +11 -1
- package/node_modules/pi-better-background-tasks/src/shared-navigator.ts +111 -16
- package/node_modules/pi-better-goal/package.json +1 -1
- package/node_modules/pi-better-goal/src/index.ts +1 -1
- package/node_modules/pi-better-goal/src/settings-page.ts +22 -49
- package/node_modules/pi-better-goal/src/shared-harness-commands.ts +56 -46
- package/node_modules/pi-better-goal/src/shared-harness-copy.ts +0 -5
- package/node_modules/pi-better-goal/src/shared-harness-menu.ts +117 -36
- package/node_modules/pi-better-goal/src/shared-harness-page.ts +51 -21
- package/node_modules/pi-better-goal/src/shared-harness-registry.ts +3 -0
- package/node_modules/pi-better-goal/src/shared-navigator-panels.ts +11 -1
- package/node_modules/pi-better-sandbox/package.json +1 -1
- package/node_modules/pi-better-sandbox/permissions-page.ts +17 -11
- package/node_modules/pi-better-sandbox/rules-page.ts +6 -2
- package/node_modules/pi-better-sandbox/shared-harness-commands.ts +56 -46
- package/node_modules/pi-better-sandbox/shared-harness-copy.ts +0 -5
- package/node_modules/pi-better-sandbox/shared-harness-menu.ts +117 -36
- package/node_modules/pi-better-sandbox/shared-harness-page.ts +51 -21
- package/node_modules/pi-better-sandbox/shared-harness-registry.ts +3 -0
- package/node_modules/pi-better-subagents/index.ts +38 -30
- package/node_modules/pi-better-subagents/package.json +2 -2
- package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-arm64.json +1 -1
- package/node_modules/pi-better-subagents/runtime-client/artifacts/darwin-x64.json +1 -1
- package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-arm64.json +1 -1
- package/node_modules/pi-better-subagents/runtime-client/artifacts/linux-x64.json +1 -1
- package/node_modules/pi-better-subagents/runtime-client/artifacts/win32-x64.json +1 -1
- package/node_modules/pi-better-subagents/settings-page.ts +27 -22
- package/node_modules/pi-better-subagents/shared-harness-commands.ts +56 -46
- package/node_modules/pi-better-subagents/shared-harness-copy.ts +0 -5
- package/node_modules/pi-better-subagents/shared-harness-menu.ts +117 -36
- package/node_modules/pi-better-subagents/shared-harness-page.ts +51 -21
- package/node_modules/pi-better-subagents/shared-harness-registry.ts +3 -0
- package/node_modules/pi-better-subagents/shared-navigator-panels.ts +11 -1
- package/node_modules/pi-better-subagents/shared-navigator.ts +111 -16
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.66.0] - 2026-12-04
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Open **OpenAI Optimization** in `/harness-settings` to change two independent switches. **Responses compaction** defaults to On. **Model instruction (Beta)** defaults to Off and applies to the next prompt for a matching OpenAI model.
|
|
8
|
+
- Edit Subagent settings directly under **Agents**. Open **Sandbox** from its own tab. Settings stay in a fixed-height menu with grouped rows and arrow-key scrolling.
|
|
9
|
+
- Click the layout switch at the right edge of the Navigator to change between **Flat** and **Tree**, or press **v** while the Navigator has focus.
|
|
10
|
+
|
|
11
|
+
## [0.65.2] - 2026-12-04
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Interactive Pi sessions fold tool calls by default. Choose **Normal** under **Tool output** in `/harness-settings` to see full output. Harness respects saved preferences.
|
|
16
|
+
|
|
3
17
|
## [0.65.1] - 2026-12-04
|
|
4
18
|
|
|
5
19
|
### Fixed
|
package/README.md
CHANGED
|
@@ -22,10 +22,11 @@ Both Harness install methods include the shared server for subagents and backgro
|
|
|
22
22
|
|
|
23
23
|
## Official Codex model prompts
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
When **Model instruction (Beta)** is on for a matching model on `openai` or `openai-codex`, Harness loads OpenAI's exact
|
|
26
26
|
`model_messages.instructions_template` alongside Pi's own instructions. Both
|
|
27
27
|
foreground and isolated worker sessions use the packaged catalog. No local
|
|
28
28
|
Codex installation, network request or Codex model cache is required.
|
|
29
|
+
The switch under **OpenAI Optimization** in `/harness-settings` defaults to Off. Changes apply on the next prompt.
|
|
29
30
|
In the Web console, open **Prompts → Model templates** to read the original
|
|
30
31
|
template by release and model. Select a connected session under **Source** to
|
|
31
32
|
read its loaded version. The viewer includes the upstream commit and SHA-256.
|
|
@@ -180,9 +181,9 @@ need interactive confirmation. Full policy: [pi-better-sandbox](https://github.c
|
|
|
180
181
|
|
|
181
182
|
## Minimal Tool Output
|
|
182
183
|
|
|
183
|
-
|
|
184
|
-
`/harness-settings
|
|
185
|
-
|
|
184
|
+
In the interactive TUI, **Tool output** defaults to **Compact**. Choose **Normal** in
|
|
185
|
+
`/harness-settings` for ordinary tool output.
|
|
186
|
+
|
|
186
187
|
Minimal mode folds each tool call into a single-line header, including running
|
|
187
188
|
calls. The tool-specific icon and tool name share a state color: accent while
|
|
188
189
|
running, muted when completed, and error-colored when failed. In fullscreen Pi, a soft highlight travels through the entire visible running tool name and its
|
|
@@ -213,7 +214,7 @@ tool icons sit centered in a three-column gutter. Click the disclosure again to
|
|
|
213
214
|
block; native expanded call/result clicks collapse individual details. Regular
|
|
214
215
|
terminals keep mouse input for terminal selection and scrollback; Ctrl+O expands
|
|
215
216
|
all original tool details in both modes and folds them again on the next toggle.
|
|
216
|
-
|
|
217
|
+
Error result bodies are also
|
|
217
218
|
hidden in minimal mode and remain available when expanded.
|
|
218
219
|
|
|
219
220
|
Minimal mode also covers Harness tools: Subagents, Background Tasks, Goal, Todo,
|
|
@@ -223,7 +224,7 @@ bodies. Finished calls fold into the same disclosure blocks as built-in tools;
|
|
|
223
224
|
expanding them restores their original package renderers. Goal and Todo widgets
|
|
224
225
|
and the background-work navigator are independent UI surfaces and remain visible.
|
|
225
226
|
|
|
226
|
-
|
|
227
|
+
Changing tool output saves the choice in
|
|
227
228
|
global `settings.json` under `piBetterHarness.toolOutput`, as well as the current
|
|
228
229
|
session. New sessions inherit it; resumed branches retain their own saved choice.
|
|
229
230
|
This is a version-sensitive internal TUI adapter,
|
|
@@ -241,16 +242,18 @@ pi -e ./packages/pi-better-harness/extensions/minimal-output/index.ts
|
|
|
241
242
|
|
|
242
243
|
Open `/harness-settings` or `/better-harness-settings` for the same menu.
|
|
243
244
|
Use ←/→ or Tab/Shift+Tab to switch tabs, ↑/↓ to select a row, and Enter or Space to open or change it.
|
|
244
|
-
Esc returns from a page to the row that opened it. The slash menu also offers `/goal` and `/subagents`.
|
|
245
|
+
The navigation stays in place while the selection scrolls. Esc returns from a page to the row that opened it. The slash menu also offers `/goal` and `/subagents`.
|
|
245
246
|
|
|
246
247
|
| Tab | Settings and actions |
|
|
247
248
|
| --- | --- |
|
|
248
249
|
| Goals | Goal execution, Todo display and actions, project ledgers, workflow ownership and dynamic workflows |
|
|
249
|
-
| Agents |
|
|
250
|
+
| Agents | Delegation, concurrency, run limits, skills, agent catalog and history |
|
|
251
|
+
| Sandbox | Sandbox activation, permissions, protected paths and diagnostics |
|
|
250
252
|
| Background | Current activity, wait reviews and completion delivery |
|
|
251
|
-
| Display |
|
|
253
|
+
| Display | Pinned panels, tool output and animation |
|
|
252
254
|
| Supervision | Supervisor mode, scenarios and recovery commitments |
|
|
253
|
-
|
|
|
255
|
+
| OpenAI Optimization | Responses compaction and Model instruction (Beta) |
|
|
256
|
+
| Prompts | Recaps, prompt editor and prompt experiments |
|
|
254
257
|
| Remote | Connect to a host, pull a session or move it to a host |
|
|
255
258
|
| Audio | Read a reply or selected text aloud and stop playback |
|
|
256
259
|
|
|
@@ -258,7 +261,8 @@ The menu shows actions from loaded extensions. Remote appears when remote sessio
|
|
|
258
261
|
Audio appears when `pi-better-read-aloud` is installed. For scripts and direct access, both settings
|
|
259
262
|
aliases accept an action and its arguments, for example `/harness-settings sandbox deny list`.
|
|
260
263
|
|
|
261
|
-
|
|
264
|
+
Click **Flat / Tree** at the right of the Navigator or press **v** while it has focus to switch layouts.
|
|
265
|
+
**Flat** (the default) keeps the Subagents
|
|
262
266
|
and Background Tasks groups and includes tasks launched by subagents. Tree puts
|
|
263
267
|
Main and subagents at the same level, with each agent's background tasks indented
|
|
264
268
|
beneath it. Switching applies immediately and saves `piBetterHarness.navigatorView`.
|
|
@@ -308,7 +312,7 @@ survive sessions and upgrades.
|
|
|
308
312
|
|
|
309
313
|
### OpenAI native compaction
|
|
310
314
|
|
|
311
|
-
|
|
315
|
+
**Responses compaction** under **OpenAI Optimization** defaults to On. Manual `/compact` and automatic compaction use the provider’s native compressor. Switching it off applies to future compactions. It supports GPT models on OpenAI Responses and Codex Responses routes. If the standalone endpoint is unavailable, Harness tries the Responses compaction trigger. Routes without either capability use Pi’s summary.
|
|
312
316
|
|
|
313
317
|
Pi saves the complete compacted window in the session journal alongside the boundary of the recent messages it kept. Restarting before that write leaves the previous history available for retry. After the write, Pi can reopen the session and reuse the saved window. Switching to another route restores the original Pi history for that route.
|
|
314
318
|
|
|
@@ -19,7 +19,7 @@ function minimalOutputExtension(pi: ExtensionAPI): void {
|
|
|
19
19
|
if (value !== undefined && (value?.version !== 1 || typeof value.enabled !== "boolean")) {
|
|
20
20
|
throw new Error("Invalid tool-output default in global settings.json.");
|
|
21
21
|
}
|
|
22
|
-
return initialDefault = value?.enabled
|
|
22
|
+
return initialDefault = value?.enabled !== false;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function collapseTools(ctx: ExtensionContext): void {
|
|
@@ -32,10 +32,12 @@ function archivedPrefix(branch: SessionEntry[], checkpoint: Checkpoint) {
|
|
|
32
32
|
...branch.slice(Math.max(0, start), cut).filter(entry => entry.type !== "compaction").flatMap(sessionEntryToContextMessages)];
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
const enabled = () => readHarnessSetting(key) !== false;
|
|
36
|
+
|
|
35
37
|
export const nativeCompactionSetting = {
|
|
36
|
-
id: "native-compaction", label: "
|
|
38
|
+
id: "native-compaction", label: "Responses compaction", values: ["Off", "On"],
|
|
37
39
|
description: "Use native compaction for GPT models on supported Responses endpoints. Applies to future compactions.",
|
|
38
|
-
get: () =>
|
|
40
|
+
get: () => enabled() ? "On" : "Off",
|
|
39
41
|
change: (value: string) => { updateHarnessSetting(key, () => value === "On"); },
|
|
40
42
|
};
|
|
41
43
|
|
|
@@ -62,7 +64,7 @@ export default function registerNativeCompaction(pi: ExtensionAPI) {
|
|
|
62
64
|
preparation.previousSummary = undefined;
|
|
63
65
|
};
|
|
64
66
|
try {
|
|
65
|
-
if (!supportsCompaction(model) ||
|
|
67
|
+
if (!supportsCompaction(model) || !enabled()) {
|
|
66
68
|
restoreForPi();
|
|
67
69
|
return;
|
|
68
70
|
}
|
|
@@ -3,64 +3,71 @@ import type { MenuItem } from "./menu.ts";
|
|
|
3
3
|
|
|
4
4
|
type Command = Parameters<ExtensionAPI["registerCommand"]>[1];
|
|
5
5
|
type Operation = [label: string, args: string, input?: string];
|
|
6
|
-
type Feature = { name: string; tab: string; label: string; operations?: Operation[]
|
|
6
|
+
type Feature = { name: string; tab: string; label: string; operations?: Record<string, Operation[]>; link?: string };
|
|
7
7
|
|
|
8
8
|
export const settingsNames = ["harness-settings", "better-harness-settings"] as const;
|
|
9
9
|
const features: Feature[] = [
|
|
10
|
-
{ name: "goal", tab: "Goals", label: "Goal execution settings", link: "goal", operations: [["Execution settings", "settings"]] },
|
|
11
|
-
{ name: "todo", tab: "Goals", label: "Current Todo", operations: [
|
|
10
|
+
{ name: "goal", tab: "Goals", label: "Goal execution settings", link: "goal", operations: { "Execution": [["Execution settings", "settings"]] } },
|
|
11
|
+
{ name: "todo", tab: "Goals", label: "Current Todo", operations: { "Display": [
|
|
12
12
|
["Show", "show"], ["Hide", "hide"], ["Expand", "expand"], ["Collapse", "collapse"],
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
["
|
|
13
|
+
], "Pinning": [
|
|
14
|
+
["Automatic pinning", "pin auto"], ["Pin", "pin on"], ["Unpin", "pin off"],
|
|
15
|
+
], "Layout": [
|
|
16
|
+
["Resize split", "split", "Left:right ratio"],
|
|
17
|
+
], "Contents": [
|
|
18
|
+
["Clear Todo", "clear"],
|
|
19
|
+
] } },
|
|
20
|
+
{ name: "ledger", tab: "Goals", label: "Project ledgers", operations: { "Ledgers": [
|
|
21
|
+
["List ledgers", "list"], ["Show attached ledger", "show"],
|
|
22
|
+
], "Attachment": [
|
|
23
|
+
["Attach", "attach", "Ledger ID"],
|
|
17
24
|
["Switch", "switch", "Ledger ID"], ["Detach", "detach"],
|
|
18
|
-
] },
|
|
19
|
-
{ name: "workflow", tab: "Goals", label: "Skill workflow", operations: [["Inspect owner", ""], ["Clear ownership", "clear"]] },
|
|
20
|
-
{ name: "dynamic-workflow", tab: "Goals", label: "Start or continue dynamic workflow", operations: [
|
|
25
|
+
] } },
|
|
26
|
+
{ name: "workflow", tab: "Goals", label: "Skill workflow", operations: { "Ownership": [["Inspect owner", ""], ["Clear ownership", "clear"]] } },
|
|
27
|
+
{ name: "dynamic-workflow", tab: "Goals", label: "Start or continue dynamic workflow", operations: { "Task": [
|
|
21
28
|
["Use current task", ""], ["Give instructions", "", "Workflow instructions"],
|
|
22
|
-
] },
|
|
23
|
-
{ name: "subagents", tab: "Agents", label: "Subagent settings", link: "subagents", operations: [["Open settings", "settings"]] },
|
|
24
|
-
{ name: "subagents", tab: "Agents", label: "Historical subagent waits", operations: [["Inspect historical waits", "history"]] },
|
|
29
|
+
] } },
|
|
30
|
+
{ name: "subagents", tab: "Agents", label: "Subagent settings", link: "subagents", operations: { "Settings": [["Open settings", "settings"]] } },
|
|
31
|
+
{ name: "subagents", tab: "Agents", label: "Historical subagent waits", operations: { "History": [["Inspect historical waits", "history"]] } },
|
|
25
32
|
{ name: "agents", tab: "Agents", label: "Agent catalog", link: "agents" },
|
|
26
|
-
{ name: "
|
|
27
|
-
|
|
28
|
-
["Import from Codex", "import-codex"], ["Reload catalog", "reload"],
|
|
29
|
-
] },
|
|
30
|
-
{ name: "sandbox", tab: "Agents", label: "Sandbox settings", link: "sandbox" },
|
|
31
|
-
{ name: "sandbox", tab: "Agents", label: "Sandbox activation", operations: [
|
|
33
|
+
{ name: "sandbox", tab: "Sandbox", label: "Sandbox settings", link: "sandbox" },
|
|
34
|
+
{ name: "sandbox", tab: "Sandbox", label: "Sandbox activation", operations: { "Session": [
|
|
32
35
|
["Show status", "status"], ["Enable for session", "on"], ["Disable for session", "off"],
|
|
36
|
+
], "Defaults": [
|
|
33
37
|
["Enable by default", "default on"], ["Disable by default", "default off"],
|
|
34
|
-
] },
|
|
35
|
-
{ name: "sandbox", tab: "
|
|
38
|
+
] } },
|
|
39
|
+
{ name: "sandbox", tab: "Sandbox", label: "Sandbox rules and diagnostics", operations: { "Protected paths": [
|
|
36
40
|
["Protected paths", "rules"], ["List protected paths", "deny list"], ["Protect path", "deny add", "Path"],
|
|
37
41
|
["Remove protected path", "deny remove", "Path"], ["Restore packaged rules", "deny reset"],
|
|
42
|
+
], "Diagnostics": [
|
|
38
43
|
["Diagnostics status", "diagnostics status"], ["Diagnostics summary", "diagnostics summary"],
|
|
39
44
|
["Enable diagnostics", "diagnostics on"], ["Disable diagnostics", "diagnostics off"], ["Export diagnostics", "diagnostics export"],
|
|
40
|
-
] },
|
|
45
|
+
] } },
|
|
41
46
|
{ name: "better-activity", tab: "Background", label: "Inspect current activity" },
|
|
42
|
-
{ name: "tool-output", tab: "Display", label: "Tool output", link: "tool-output", operations: [["Compact", "minimal"], ["Normal", "normal"]] },
|
|
43
|
-
{ name: "supervisor-followup", tab: "Supervision", label: "Recovery commitments", operations: [
|
|
47
|
+
{ name: "tool-output", tab: "Display", label: "Tool output", link: "tool-output", operations: { "Transcript": [["Compact", "minimal"], ["Normal", "normal"]] } },
|
|
48
|
+
{ name: "supervisor-followup", tab: "Supervision", label: "Recovery commitments", operations: { "Commitments": [
|
|
44
49
|
["View commitments", ""], ["Schedule a reminder", "remind", "Commitment ID and minutes"],
|
|
45
|
-
] },
|
|
50
|
+
] } },
|
|
46
51
|
{ name: "recap-prompt", tab: "Prompts", label: "Recap prompt", link: "recap-prompt" },
|
|
47
52
|
{ name: "prompt-manager", tab: "Prompts", label: "Prompt manager", link: "prompt-manager" },
|
|
48
53
|
{ name: "prompt-capture", tab: "Prompts", label: "Capture next response" },
|
|
49
|
-
{ name: "prompt-task-capture", tab: "Prompts", label: "Capture task", operations: [["Capture", "", "Task manifest path"]] },
|
|
50
|
-
{ name: "prompt-import", tab: "Prompts", label: "Load evaluation cases", operations: [
|
|
54
|
+
{ name: "prompt-task-capture", tab: "Prompts", label: "Capture task", operations: { "Capture": [["Capture", "", "Task manifest path"]] } },
|
|
55
|
+
{ name: "prompt-import", tab: "Prompts", label: "Load evaluation cases", operations: { "Cases": [
|
|
51
56
|
["Load bundled cases", ""], ["Import reviewed suite", "", "Suite file path"],
|
|
52
|
-
] },
|
|
53
|
-
{ name: "prompt-export", tab: "Prompts", label: "Export reviewed replay", operations: [["Export", "", "New case file path"]] },
|
|
54
|
-
{ name: "prompt-learning", tab: "Prompts", label: "Case-based proposals", operations: [
|
|
57
|
+
] } },
|
|
58
|
+
{ name: "prompt-export", tab: "Prompts", label: "Export reviewed replay", operations: { "Replay": [["Export", "", "New case file path"]] } },
|
|
59
|
+
{ name: "prompt-learning", tab: "Prompts", label: "Case-based proposals", operations: { "Proposals": [
|
|
55
60
|
["Enable for this session", "on"], ["Disable", "off"], ["Discard pending proposal", "discard"],
|
|
56
|
-
] },
|
|
57
|
-
{ name: "remote", tab: "Remote", label: "Remote sessions", operations: [
|
|
58
|
-
["Connect", "connect"], ["List hosts", "list"],
|
|
59
|
-
]
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
] } },
|
|
62
|
+
{ name: "remote", tab: "Remote", label: "Remote sessions", operations: { "Hosts": [
|
|
63
|
+
["Connect", "connect"], ["List hosts", "list"],
|
|
64
|
+
], "Sessions": [
|
|
65
|
+
["Pull a session", "pull"],
|
|
66
|
+
] } },
|
|
67
|
+
{ name: "detach", tab: "Remote", label: "Move session to host", operations: { "Session": [["Move session", "", "SSH alias and optional destination flags"]] } },
|
|
68
|
+
{ name: "read-aloud", tab: "Audio", label: "Read aloud", operations: { "Playback": [
|
|
62
69
|
["Read latest reply", ""], ["Read text", "", "Text to read"],
|
|
63
|
-
] },
|
|
70
|
+
] } },
|
|
64
71
|
{ name: "read-aloud-stop", tab: "Audio", label: "Stop playback" },
|
|
65
72
|
];
|
|
66
73
|
|
|
@@ -81,16 +88,19 @@ function menuActions(commands: Map<string, Command>): HarnessAction[] {
|
|
|
81
88
|
async run(ctx: ExtensionCommandContext) {
|
|
82
89
|
let args = "";
|
|
83
90
|
if (feature.operations) {
|
|
84
|
-
const choices = feature.operations
|
|
85
|
-
|
|
91
|
+
const choices = Object.entries(feature.operations).flatMap(([group, operations]) =>
|
|
92
|
+
operations.map(operation => ({ label: operation[0], group, operation })));
|
|
93
|
+
let selected: (typeof choices)[number] | undefined = choices[0];
|
|
86
94
|
if (choices.length > 1) {
|
|
87
|
-
const
|
|
88
|
-
|
|
95
|
+
const { chooseSettingsOption } = await import("./menu.ts");
|
|
96
|
+
const label = await chooseSettingsOption(ctx, feature.label, choices);
|
|
97
|
+
selected = choices.find(choice => choice.label === label);
|
|
89
98
|
}
|
|
90
|
-
if (!
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
if (!selected) return false;
|
|
100
|
+
const [, argument, input] = selected.operation;
|
|
101
|
+
args = argument;
|
|
102
|
+
if (input) {
|
|
103
|
+
const text = (await ctx.ui.input(input))?.trim();
|
|
94
104
|
if (!text) return false;
|
|
95
105
|
args = [args, text].filter(Boolean).join(" ");
|
|
96
106
|
}
|
|
@@ -158,7 +168,7 @@ export function harnessMenu(pi: ExtensionAPI): MenuHost {
|
|
|
158
168
|
const links = registry.list();
|
|
159
169
|
const controls = registry.controls();
|
|
160
170
|
const available = availableActions(actions, links, controls);
|
|
161
|
-
selected = await chooseHarnessSetting(ctx, links, selected, undefined, controls,
|
|
171
|
+
selected = await chooseHarnessSetting(ctx, links, selected, undefined, controls, available);
|
|
162
172
|
if (!selected) return;
|
|
163
173
|
try {
|
|
164
174
|
const action = available.find(item => item.id === selected);
|
|
@@ -38,11 +38,6 @@ export const controlCopy = new Map<string, SettingCopy>([
|
|
|
38
38
|
label: "Pin work panels",
|
|
39
39
|
description: "Keeps the work panels above the editor as the conversation scrolls. Off lets them scroll with the conversation on supported Pi versions.",
|
|
40
40
|
}],
|
|
41
|
-
["navigator-view", {
|
|
42
|
-
label: "Navigator layout",
|
|
43
|
-
description: "Tree nests tasks under their agent. Flat list groups rows by work type.",
|
|
44
|
-
values: { tree: "Tree", flatten: "Flat list" },
|
|
45
|
-
}],
|
|
46
41
|
["tool-output", {
|
|
47
42
|
description: "Normal shows the usual tool transcript. Compact groups completed calls and hides their details until you expand the group.",
|
|
48
43
|
values: { Minimal: "Compact" },
|
|
@@ -8,13 +8,16 @@ import { chooseHarnessSetting } from "./page.ts";
|
|
|
8
8
|
import { createSettingsRegistry } from "./registry.ts";
|
|
9
9
|
import { changeCallbackSetting, getCallbackSettings, saveCallbackDefault } from "pi-better-background-tasks/src/shared-callback-batcher.ts";
|
|
10
10
|
|
|
11
|
-
import { getNavigatorView, loadNavigatorView, setNavigatorView } from "pi-better-background-tasks/src/shared-navigator.ts";
|
|
12
|
-
|
|
13
11
|
export default function harnessSettingsExtension(pi: ExtensionAPI): void {
|
|
14
12
|
registerNativeCompaction(pi);
|
|
15
13
|
const registry = createSettingsRegistry(pi);
|
|
16
|
-
const
|
|
17
|
-
|
|
14
|
+
const templateKey = "openaiModelInstructionTemplate";
|
|
15
|
+
const modelInstructionTemplate = {
|
|
16
|
+
id: "model-instruction-template", label: "Model instruction (Beta)", values: ["Off", "On"],
|
|
17
|
+
description: "Include the official Codex instructions for matching OpenAI models. Changes apply on the next prompt.",
|
|
18
|
+
get: () => readHarnessSetting(templateKey) === true ? "On" : "Off",
|
|
19
|
+
change(value: string) { updateHarnessSetting(templateKey, () => value === "On"); },
|
|
20
|
+
};
|
|
18
21
|
const supervisorMode = {
|
|
19
22
|
id: "supervisor-mode", label: "Supervisor mode (Beta)", values: ["Off", "On"],
|
|
20
23
|
description: "Run the selected scenarios for sessions sharing this agent directory. Turning the mode off keeps your selections.",
|
|
@@ -24,12 +27,10 @@ export default function harnessSettingsExtension(pi: ExtensionAPI): void {
|
|
|
24
27
|
},
|
|
25
28
|
change(value: string) { setSupervisorEnabled(value === "On"); },
|
|
26
29
|
};
|
|
27
|
-
pi.on("session_start", () => { try { loadNavigatorView(); } catch { /* settings command reports read errors */ } });
|
|
28
30
|
pi.on("session_start", () => registry.refresh());
|
|
29
31
|
pi.on("session_shutdown", () => registry.dispose());
|
|
30
32
|
|
|
31
33
|
harnessMenu(pi).open = async (ctx, actions) => {
|
|
32
|
-
loadNavigatorView();
|
|
33
34
|
registry.refresh();
|
|
34
35
|
let selected: string | undefined;
|
|
35
36
|
const reported = new Set<string>();
|
|
@@ -56,7 +57,7 @@ export default function harnessSettingsExtension(pi: ExtensionAPI): void {
|
|
|
56
57
|
get: readSettings,
|
|
57
58
|
change: mode => changeCallbackSetting(pi, ctx, mode),
|
|
58
59
|
save: () => saveCallbackDefault(readSettings().mode),
|
|
59
|
-
}, [...controls, nativeCompactionSetting, supervisorMode],
|
|
60
|
+
}, [...controls, nativeCompactionSetting, modelInstructionTemplate, supervisorMode], [
|
|
60
61
|
...available,
|
|
61
62
|
{ id: "supervisor:scenarios", label: "Supervisor scenarios", kind: "page",
|
|
62
63
|
description: "Choose which scenarios run when Supervisor mode is on." },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import
|
|
1
|
+
import type { ExtensionCommandContext, Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import * as Tui from "@earendil-works/pi-tui";
|
|
3
3
|
|
|
4
4
|
export interface MenuItem {
|
|
5
5
|
id: string;
|
|
@@ -8,11 +8,46 @@ export interface MenuItem {
|
|
|
8
8
|
value?: string;
|
|
9
9
|
description?: string;
|
|
10
10
|
tab?: string;
|
|
11
|
+
group?: string;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export interface MenuSection {
|
|
14
15
|
title: string;
|
|
15
16
|
items: MenuItem[];
|
|
17
|
+
createPane?(options: Omit<PaneOptions, "requestRender">): MenuPane;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface MenuPane {
|
|
21
|
+
focused: boolean;
|
|
22
|
+
readonly editing: boolean;
|
|
23
|
+
render(width: number): string[];
|
|
24
|
+
handleInput(data: string): void;
|
|
25
|
+
invalidate(): void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface PaneOptions {
|
|
29
|
+
theme: Theme;
|
|
30
|
+
height(): number;
|
|
31
|
+
items: MenuItem[];
|
|
32
|
+
selected?: string | undefined;
|
|
33
|
+
activate(item: MenuItem): void;
|
|
34
|
+
back(): void;
|
|
35
|
+
requestRender(): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function settingsHeight(terminalRows: number): number {
|
|
39
|
+
return Math.max(1, Math.floor(terminalRows * 2 / 3));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Keep the footer in place while selection moves through the scrollable rows.
|
|
43
|
+
export function settingsViewport(height: number, header: string[], body: string[], selectedStart: number, selectedEnd: number, footer: string[]) {
|
|
44
|
+
const selectedHeight = Math.min(height, Math.max(1, selectedEnd - selectedStart));
|
|
45
|
+
const head = header.slice(0, Math.max(0, height - selectedHeight));
|
|
46
|
+
const foot = footer.slice(0, Math.max(0, height - head.length - selectedHeight));
|
|
47
|
+
const room = height - head.length - foot.length;
|
|
48
|
+
const start = Math.max(0, Math.min(body.length - room, selectedEnd - room));
|
|
49
|
+
const visible = body.slice(start, start + room);
|
|
50
|
+
return [...head, ...visible, ...Array<string>(room - visible.length).fill(""), ...foot];
|
|
16
51
|
}
|
|
17
52
|
|
|
18
53
|
const verbs = { toggle: "toggle", choice: "change", page: "open", editor: "edit" };
|
|
@@ -20,7 +55,7 @@ const verbs = { toggle: "toggle", choice: "change", page: "open", editor: "edit"
|
|
|
20
55
|
export function createSettingsMenu(options: {
|
|
21
56
|
title: string;
|
|
22
57
|
sections: MenuSection[];
|
|
23
|
-
selected?: string;
|
|
58
|
+
selected?: string | undefined;
|
|
24
59
|
theme: Theme;
|
|
25
60
|
height: () => number;
|
|
26
61
|
activate: (item: MenuItem) => void;
|
|
@@ -32,6 +67,20 @@ export function createSettingsMenu(options: {
|
|
|
32
67
|
const positions = tabs.map(section => Math.max(0, section.items.findIndex(item => item.id === options.selected)));
|
|
33
68
|
const activeItem = () => tabs[tab]?.items[positions[tab] ?? 0];
|
|
34
69
|
let feedback = "";
|
|
70
|
+
let focused = false;
|
|
71
|
+
const panes = new Map<MenuSection, MenuPane>();
|
|
72
|
+
function pane() {
|
|
73
|
+
const section = tabs[tab];
|
|
74
|
+
if (!section?.createPane) return undefined;
|
|
75
|
+
let content = panes.get(section);
|
|
76
|
+
if (!content) {
|
|
77
|
+
content = section.createPane({ theme, height: () => Math.max(1, settingsHeight(options.height()) - 3),
|
|
78
|
+
items: section.items, selected: options.selected, activate: options.activate, back: options.back });
|
|
79
|
+
content.focused = focused;
|
|
80
|
+
panes.set(section, content);
|
|
81
|
+
}
|
|
82
|
+
return content;
|
|
83
|
+
}
|
|
35
84
|
|
|
36
85
|
function tabBar(width: number): string {
|
|
37
86
|
const labels = tabs.map((section, i) => i === tab ? theme.inverse(` ${section.title} `) : theme.fg("muted", section.title));
|
|
@@ -39,13 +88,13 @@ export function createSettingsMenu(options: {
|
|
|
39
88
|
const line = () => [start > 0 ? "‹" : "", ...labels.slice(start, end), end < tabs.length ? "›" : ""].filter(Boolean).join(" ");
|
|
40
89
|
while (start > 0) {
|
|
41
90
|
start--;
|
|
42
|
-
if (visibleWidth(line()) > width) { start++; break; }
|
|
91
|
+
if (Tui.visibleWidth(line()) > width) { start++; break; }
|
|
43
92
|
}
|
|
44
93
|
while (end < tabs.length) {
|
|
45
94
|
end++;
|
|
46
|
-
if (visibleWidth(line()) > width) { end--; break; }
|
|
95
|
+
if (Tui.visibleWidth(line()) > width) { end--; break; }
|
|
47
96
|
}
|
|
48
|
-
return truncateToWidth(line(), width, "…");
|
|
97
|
+
return Tui.truncateToWidth(line(), width, "…");
|
|
49
98
|
}
|
|
50
99
|
|
|
51
100
|
function renderItem(item: MenuItem, active: boolean, width: number, labelWidth: number): string[] {
|
|
@@ -54,26 +103,39 @@ export function createSettingsMenu(options: {
|
|
|
54
103
|
const link = item.kind === "page" || item.kind === "editor";
|
|
55
104
|
const trailing = active && !link ? theme.inverse(value) : theme.fg(active ? "accent" : "muted", value);
|
|
56
105
|
const label = (active ? "> " : " ") + theme.fg(active ? "accent" : "text", item.label);
|
|
57
|
-
if (labelWidth + visibleWidth(value) + 4 <= width) {
|
|
58
|
-
return [label + " ".repeat(labelWidth - visibleWidth(item.label) + 2) + trailing];
|
|
106
|
+
if (labelWidth + Tui.visibleWidth(value) + 4 <= width) {
|
|
107
|
+
return [label + " ".repeat(labelWidth - Tui.visibleWidth(item.label) + 2) + trailing];
|
|
59
108
|
}
|
|
60
|
-
return [truncateToWidth(label, width, "…"), truncateToWidth(" " + trailing, width, "…")];
|
|
109
|
+
return [Tui.truncateToWidth(label, width, "…"), Tui.truncateToWidth(" " + trailing, width, "…")];
|
|
61
110
|
}
|
|
62
111
|
|
|
63
112
|
return {
|
|
64
113
|
report(text: string, error = false) { feedback = theme.fg(error ? "error" : "text", text); },
|
|
65
|
-
|
|
114
|
+
get hasPane() { return !!tabs[tab]?.createPane; },
|
|
115
|
+
get focused() { return focused; },
|
|
116
|
+
set focused(value: boolean) { focused = value; const current = panes.get(tabs[tab]!); if (current) current.focused = value; },
|
|
117
|
+
invalidate() { panes.get(tabs[tab]!)?.invalidate(); },
|
|
66
118
|
handleInput(data: string) {
|
|
67
|
-
const kb = getKeybindings();
|
|
68
|
-
if (kb.matches(data, "tui.select.cancel")) { options.back(); return; }
|
|
119
|
+
const kb = Tui.getKeybindings();
|
|
69
120
|
const section = tabs[tab];
|
|
121
|
+
const current = pane();
|
|
122
|
+
const left = Tui.matchesKey(data, "left") || Tui.matchesKey(data, "shift+tab");
|
|
123
|
+
const right = Tui.matchesKey(data, "right") || Tui.matchesKey(data, "tab");
|
|
124
|
+
if ((left || right) && tabs.length > 1 && !current?.editing) {
|
|
125
|
+
if (current) current.focused = false;
|
|
126
|
+
tab = (tab + (left ? -1 : 1) + tabs.length) % tabs.length;
|
|
127
|
+
const next = pane();
|
|
128
|
+
if (next) next.focused = focused;
|
|
129
|
+
feedback = "";
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (current) { current.handleInput(data); return; }
|
|
133
|
+
if (kb.matches(data, "tui.select.cancel")) { options.back(); return; }
|
|
70
134
|
if (!section) return;
|
|
71
135
|
const cursor = positions[tab]!;
|
|
72
|
-
if (
|
|
73
|
-
else if (matchesKey(data, "right") || matchesKey(data, "tab")) tab = (tab + 1) % tabs.length;
|
|
74
|
-
else if (kb.matches(data, "tui.select.up")) positions[tab] = (cursor + section.items.length - 1) % section.items.length;
|
|
136
|
+
if (kb.matches(data, "tui.select.up")) positions[tab] = (cursor + section.items.length - 1) % section.items.length;
|
|
75
137
|
else if (kb.matches(data, "tui.select.down")) positions[tab] = (cursor + 1) % section.items.length;
|
|
76
|
-
else if (kb.matches(data, "tui.select.confirm") || matchesKey(data, "space")) {
|
|
138
|
+
else if (kb.matches(data, "tui.select.confirm") || Tui.matchesKey(data, "space")) {
|
|
77
139
|
options.activate(section.items[cursor]!);
|
|
78
140
|
return;
|
|
79
141
|
} else return;
|
|
@@ -81,22 +143,35 @@ export function createSettingsMenu(options: {
|
|
|
81
143
|
},
|
|
82
144
|
render(width: number) {
|
|
83
145
|
const w = Math.max(1, width);
|
|
84
|
-
const title = theme.bold(theme.fg("text", options.title));
|
|
146
|
+
const title = Tui.truncateToWidth(theme.bold(theme.fg("text", options.title)), w, "…");
|
|
85
147
|
const item = activeItem();
|
|
86
148
|
const section = tabs[tab];
|
|
87
149
|
const cursor = positions[tab] ?? 0;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (height
|
|
150
|
+
const height = settingsHeight(options.height());
|
|
151
|
+
const header = [title, tabBar(w), ""];
|
|
152
|
+
const current = pane();
|
|
153
|
+
if (current) {
|
|
154
|
+
const lines = current.render(w);
|
|
155
|
+
return settingsViewport(height, header, lines, 0, Math.min(lines.length, Math.max(1, height - header.length)), []);
|
|
156
|
+
}
|
|
157
|
+
if (!item || !section) return settingsViewport(height, header, [Tui.truncateToWidth(" No settings available", w, "…")], 0, 1, []);
|
|
158
|
+
const labelWidth = Math.max(...section.items.map(row => Tui.visibleWidth(row.label)));
|
|
159
|
+
const body: string[] = [];
|
|
160
|
+
let selectedStart = 0, selectedEnd = 0;
|
|
161
|
+
for (const [i, row] of section.items.entries()) {
|
|
162
|
+
const heading = row.group && section.items[i - 1]?.group !== row.group;
|
|
163
|
+
if (heading) {
|
|
164
|
+
if (i > 0) body.push("");
|
|
165
|
+
body.push(theme.fg("muted", theme.bold(row.group!)));
|
|
166
|
+
}
|
|
167
|
+
if (i === cursor) selectedStart = body.length;
|
|
168
|
+
body.push(...renderItem(row, i === cursor, w, labelWidth));
|
|
169
|
+
if (i === cursor) selectedEnd = body.length;
|
|
170
|
+
}
|
|
96
171
|
const indent = " ";
|
|
97
|
-
const wrap = (s: string) => wrapTextWithAnsi(s, Math.max(1, w - indent.length)).map(line => indent + line);
|
|
172
|
+
const wrap = (s: string) => Tui.wrapTextWithAnsi(s, Math.max(1, w - indent.length)).map(line => indent + line);
|
|
98
173
|
const help = item.description ? wrap(item.description) : [];
|
|
99
|
-
const kb = getKeybindings();
|
|
174
|
+
const kb = Tui.getKeybindings();
|
|
100
175
|
const key = (binding: "tui.select.confirm" | "tui.select.cancel") => {
|
|
101
176
|
const name = kb.getKeys(binding)[0] ?? "";
|
|
102
177
|
return name === "escape" ? "Esc" : name.length > 1 ? name.charAt(0).toUpperCase() + name.slice(1) : name;
|
|
@@ -104,20 +179,26 @@ export function createSettingsMenu(options: {
|
|
|
104
179
|
const confirm = key("tui.select.confirm");
|
|
105
180
|
const cancel = key("tui.select.cancel");
|
|
106
181
|
const action = [confirm, confirm === "Space" ? "" : "Space"].filter(Boolean).join("/");
|
|
107
|
-
const hint = wrap([tabs.length > 1 ? "←/→ tab" : "", action + " to " + verbs[item.kind], cancel && cancel + " back"].filter(Boolean).join(" · "));
|
|
182
|
+
const hint = wrap([tabs.length > 1 ? "←/→ tab" : "", "↑/↓ scroll", action + " to " + verbs[item.kind], cancel && cancel + " back"].filter(Boolean).join(" · "));
|
|
108
183
|
const status = feedback ? wrap(feedback) : [];
|
|
109
|
-
const
|
|
110
|
-
const footRoom = Math.max(0, height - header.length - focused.length - 1);
|
|
184
|
+
const footRoom = Math.max(0, height - header.length - (selectedEnd - selectedStart) - 1);
|
|
111
185
|
const keys = [...status, ...hint.map(line => theme.fg("dim", line))].slice(0, footRoom);
|
|
112
186
|
const details = help.slice(0, Math.max(0, Math.min(Math.floor(height / 3), footRoom - keys.length - 1)));
|
|
113
187
|
const footer = [...details, ...(details.length ? [""] : []), ...keys];
|
|
114
188
|
if (footer.length) footer.unshift("");
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
while (first > 0 && used + lines[first - 1]!.length <= budget) used += lines[--first]!.length;
|
|
118
|
-
const body = lines.slice(first).flat().slice(0, budget);
|
|
119
|
-
return [...header, ...body, ...footer]
|
|
120
|
-
.map(line => truncateToWidth(line, w, "…"));
|
|
189
|
+
return settingsViewport(height, header, body, selectedStart, selectedEnd, footer)
|
|
190
|
+
.map(line => Tui.truncateToWidth(line, w, "…"));
|
|
121
191
|
},
|
|
122
192
|
};
|
|
123
193
|
}
|
|
194
|
+
|
|
195
|
+
export function chooseSettingsOption(ctx: ExtensionCommandContext, title: string, choices: { label: string; group: string }[]) {
|
|
196
|
+
if (ctx.mode !== "tui" || !ctx.ui.custom) return ctx.ui.select(title, choices.map(choice => choice.label));
|
|
197
|
+
return ctx.ui.custom<string | undefined>((tui, theme, _kb, done) => createSettingsMenu({
|
|
198
|
+
title, theme, height: () => tui.terminal?.rows ?? 32,
|
|
199
|
+
sections: [{ title: "Actions", items: choices.map(({ label, group }) => ({
|
|
200
|
+
id: label, label, kind: "page", group,
|
|
201
|
+
})) }],
|
|
202
|
+
activate: item => done(item.id), back: () => done(undefined),
|
|
203
|
+
}));
|
|
204
|
+
}
|