proper-base 0.5.1 → 0.7.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/README.md +44 -13
- package/UPDATES.md +129 -0
- package/index.ts +107 -108
- package/package.json +5 -5
- package/src/auto-update/availability.ts +132 -0
- package/src/auto-update/index.ts +403 -0
- package/src/auto-update/inventory.mjs +96 -0
- package/src/auto-update/readiness.ts +94 -0
- package/src/auto-update/runtime.ts +268 -0
- package/src/auto-update/settings.ts +146 -0
- package/src/base-keybindings.ts +114 -0
- package/src/clipboard-selection.ts +310 -0
- package/src/fast-mode.ts +83 -14
- package/src/footer-colors.ts +114 -13
- package/src/host-interop.ts +49 -0
- package/src/image-preview.ts +75 -66
- package/src/overlay-scroll.ts +130 -0
- package/src/proactive-delegation.ts +110 -0
- package/src/prompt-display-host.ts +136 -0
- package/src/prompt-display.ts +44 -82
- package/src/prompt-sections.ts +16 -0
- package/src/session-list.ts +132 -21
- package/src/skill-context.ts +52 -14
- package/src/startup-defaults.ts +4 -122
- package/src/sticky-defaults.ts +196 -0
- package/src/transient-retry.ts +5 -1
- package/src/wheel-scroll.ts +24 -27
- package/src/widget-transcript.ts +120 -0
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Baseline [Pi](https://pi.dev) behavior for quieter transcripts, automatic
|
|
4
4
|
session titles, model-preserving `/clear`, project prompt history, prompt
|
|
5
5
|
editing, fullscreen navigation, image handling, cancellation, autocomplete,
|
|
6
|
-
and
|
|
6
|
+
footer layout, and deferred automatic updates.
|
|
7
7
|
|
|
8
8
|
## User-facing features
|
|
9
9
|
|
|
@@ -25,14 +25,27 @@ and footer layout.
|
|
|
25
25
|
those only when you press Ctrl+S in the picker, and because Pi re-derives the
|
|
26
26
|
thinking level from the saved default on every model switch, an unsaved level
|
|
27
27
|
is otherwise lost mid-session at the next `/model`, Ctrl+P, or `/clear`.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
`"stickyDefaults": false`
|
|
28
|
+
Automatic model-switch clamps do not redefine that choice, and the router's
|
|
29
|
+
`llm-router/auto` placeholder persists neither itself nor its forced `off`.
|
|
30
|
+
Resuming a session does not redefine the model. Set `"stickyDefaults": false`
|
|
31
|
+
in `~/.pi/agent/proper-base.json` to turn this off.
|
|
31
32
|
- Prompt-template expansions remain model-facing, while the transcript shows
|
|
32
33
|
the slash command you typed, such as `/implement-ready epic-1 4`.
|
|
33
34
|
- CLIProxyAPI `empty_stream` failures become normal retryable network errors, so
|
|
34
35
|
Pi applies its existing retry budget and backoff.
|
|
35
36
|
|
|
37
|
+
### Automatic updates
|
|
38
|
+
|
|
39
|
+
- Pi's native background checks record available updates. proper-base installs
|
|
40
|
+
them on the next supported launch, with live progress and safe restart.
|
|
41
|
+
- No recorded updates means no additional update checks or inventory at startup.
|
|
42
|
+
- `/settings` → **Automatic updates** persists enable/disable. `--no-auto-update`
|
|
43
|
+
and `PROPER_UPDATER_OFF=1` still override it for a launch.
|
|
44
|
+
- Automatic updating requires npm Pi on Linux/macOS with Node 22.19+; automation
|
|
45
|
+
and unsupported installations are skipped. No separate package is needed.
|
|
46
|
+
|
|
47
|
+
See [update behavior, safety limits, and migration](./UPDATES.md).
|
|
48
|
+
|
|
36
49
|
### Prompt editing and cancellation
|
|
37
50
|
|
|
38
51
|
| Input | Behavior |
|
|
@@ -116,12 +129,25 @@ pinned while Pi scrolls the transcript above them.
|
|
|
116
129
|
| Home, End, PageUp, PageDown | Stay assigned to the prompt editor. |
|
|
117
130
|
| Ctrl+Shift+Home or End | Jump the transcript to its top or bottom. |
|
|
118
131
|
| Ctrl+Shift+PageUp or PageDown | Scroll the transcript by one page. |
|
|
132
|
+
|
|
133
|
+
Wheel and transcript scroll keys keep working while an `ask_user_question`
|
|
134
|
+
questionnaire or other overlay has focus, so earlier context stays reachable.
|
|
119
135
|
| Double-click | Select a complete one-line URL, path, flag, qualified identifier, or quoted value when possible. |
|
|
120
136
|
|
|
137
|
+
Copying fullscreen Markdown paragraphs and blockquotes removes display margins,
|
|
138
|
+
quote borders, and screen-width line breaks. Real newlines, paragraph boundaries,
|
|
139
|
+
and code indentation stay intact. Works with copy-on-select and Pi's configured
|
|
140
|
+
copy shortcut. Lists, tables, and unmatched custom output keep native copying.
|
|
141
|
+
|
|
121
142
|
Scrolling away from current output adds a `↓ jump to bottom` row above the
|
|
122
143
|
prompt. Clicking it returns to the newest output without disabling scrollbar
|
|
123
144
|
dragging.
|
|
124
145
|
|
|
146
|
+
Extension widgets that Pi would pin above the prompt (for example the
|
|
147
|
+
pi-subagents async-agents card) render at the end of the transcript instead, so
|
|
148
|
+
they scroll with the session and shrink as their content does rather than
|
|
149
|
+
holding rows they no longer need.
|
|
150
|
+
|
|
125
151
|
The transcript's top-right corner carries muted `↑` and `↓` arrows that walk
|
|
126
152
|
the viewport between your own prompts. Clicking `↓` past the last prompt scrolls
|
|
127
153
|
to the bottom. While you are scrolled up, a dimmer `position/total` reading sits
|
|
@@ -140,9 +166,9 @@ as `editorMouse` and `sessionRail`.
|
|
|
140
166
|
Ctrl+V and Ctrl+Shift+V both use Pi's image-or-text clipboard action. Readable
|
|
141
167
|
clipboard image paths appear as short `[image N]` markers. Image-capable
|
|
142
168
|
terminals render compact previews; text-only terminals show marker source paths.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
for a tiny preview. `sharp` ships prebuilt macOS arm64/x64 and Linux binaries, so
|
|
169
|
+
Source metadata and bytes are read asynchronously; oversized sources become
|
|
170
|
+
pixel-bounded PNG thumbnails through `sharp` instead of blocking the editor or
|
|
171
|
+
transmitting the full image for a tiny preview. `sharp` ships prebuilt macOS arm64/x64 and Linux binaries, so
|
|
146
172
|
no external image command is required. Pi's accent braille loader animates while conversion runs; the
|
|
147
173
|
marker and path appear only if conversion is unavailable or fails. When terminal
|
|
148
174
|
focus returns, active Kitty previews are retransmitted so a lost terminal-side
|
|
@@ -171,7 +197,9 @@ the model a one-line already-loaded note instead of a second copy; a body that
|
|
|
171
197
|
changed with its arguments is sent in full. After a compaction, the newest body
|
|
172
198
|
of each dropped skill is restored on the first user turn following the summary,
|
|
173
199
|
truncated to a character ceiling per skill and in total so the restored text
|
|
174
|
-
cannot re-trigger the compaction that just ran.
|
|
200
|
+
cannot re-trigger the compaction that just ran. Restoration honors the latest
|
|
201
|
+
context edit on the active branch: omitted or replaced skill text is not
|
|
202
|
+
resurrected, while replacement skill bodies remain eligible. Only the outbound copy changes,
|
|
175
203
|
so saved sessions, exports, resumes, and branches retain the originals.
|
|
176
204
|
|
|
177
205
|
### Footer
|
|
@@ -184,7 +212,7 @@ highlight. Custom replacement footers are not changed.
|
|
|
184
212
|
|
|
185
213
|
## Install
|
|
186
214
|
|
|
187
|
-
Node 22.19 or newer is required. The package is tested against Pi 0.
|
|
215
|
+
Node 22.19 or newer is required. The package is tested against Pi 0.87.0.
|
|
188
216
|
|
|
189
217
|
From npm:
|
|
190
218
|
|
|
@@ -199,10 +227,9 @@ pi install /path/to/proper-pi-extensions/proper-base
|
|
|
199
227
|
```
|
|
200
228
|
|
|
201
229
|
Pi supplies the core `@earendil-works/pi-coding-agent` and
|
|
202
|
-
`@earendil-works/pi-tui` peer packages.
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
prepares the development checks below.
|
|
230
|
+
`@earendil-works/pi-tui` peer packages. `sharp` is a runtime dependency for
|
|
231
|
+
image previews. Run `npm install` for a local checkout; it also prepares the
|
|
232
|
+
development checks below. There is no build step or install-time npm script.
|
|
206
233
|
|
|
207
234
|
This package replaces the former local `proper-customs` identity. Keep only one
|
|
208
235
|
registration. Existing data under the legacy `proper-history` path remains
|
|
@@ -210,6 +237,10 @@ compatible.
|
|
|
210
237
|
|
|
211
238
|
## Compatibility
|
|
212
239
|
|
|
240
|
+
Restart Pi once when upgrading from releases with permanent host patches.
|
|
241
|
+
Those releases did not retain original methods or bindings for restoration.
|
|
242
|
+
New installations restore owned patches on unload and support reload takeover.
|
|
243
|
+
|
|
213
244
|
- Fullscreen behavior uses Pi's native `tuiMode: "fullscreen"` renderer.
|
|
214
245
|
- Questionnaire cancellation activates only when `ask_user_question` is
|
|
215
246
|
installed.
|
package/UPDATES.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Automatic updates
|
|
2
|
+
|
|
3
|
+
Built into proper-base. Records Pi's existing background update checks, then installs available updates
|
|
4
|
+
on the next interactive launch. With nothing recorded, startup does no updater
|
|
5
|
+
checks, inventory, or installation. During installation, shows one live status
|
|
6
|
+
line, a short changed-version summary, and actionable warnings.
|
|
7
|
+
Restarts Pi when installed code changes and the launch can be replayed safely.
|
|
8
|
+
No LLM calls, shell wrapper, or extra runtime dependencies.
|
|
9
|
+
|
|
10
|
+
## Availability
|
|
11
|
+
|
|
12
|
+
Included with proper-base; no separate extension installation is needed.
|
|
13
|
+
Automatic updating requires Pi 0.86+, Node 22.19+, and an npm-installed Pi under
|
|
14
|
+
`lib/node_modules` on Linux or macOS. Other proper-base features retain their
|
|
15
|
+
existing platform support.
|
|
16
|
+
|
|
17
|
+
If you installed the former standalone proper-updater, remove its registration
|
|
18
|
+
from Pi's package list. Existing `proper-updater.*` preferences, lock files,
|
|
19
|
+
readiness records, environment overrides, and process guards remain compatible;
|
|
20
|
+
no state migration is required.
|
|
21
|
+
|
|
22
|
+
## Startup behavior
|
|
23
|
+
|
|
24
|
+
- First launch: Pi performs its usual background checks and shows native update
|
|
25
|
+
notices. This extension records positive results only, without extra checks.
|
|
26
|
+
When automatic updates are enabled, the launcher is supported, and readiness
|
|
27
|
+
is saved, notices say: **Restart Pi to install detected updates.** Otherwise
|
|
28
|
+
they retain Pi's manual update commands.
|
|
29
|
+
- Next launch: previously recorded updates trigger Pi's native `update --self`,
|
|
30
|
+
`update --extensions`, or `update --all`. No record means no updater widget,
|
|
31
|
+
inventory subprocess, installer, or restart.
|
|
32
|
+
- Shows the current operation and elapsed seconds: reading installed versions,
|
|
33
|
+
checking packages, updating a package or batch, checking/updating Pi, verifying
|
|
34
|
+
installed versions, and preparing restart. No typing hint or raw installer logs.
|
|
35
|
+
- Runs once per process, not on `/reload`, `/new`, `/resume`, or `/fork`.
|
|
36
|
+
- Pi and global-package notices apply across working directories. Project notices
|
|
37
|
+
apply only when relaunching that same project with trust still granted.
|
|
38
|
+
Global-only notices never authorize project installation. Updates may include
|
|
39
|
+
proper-base itself; the extension never independently grants project trust.
|
|
40
|
+
- Readiness lives under `<agentDir>/proper-updater-ready/` as empty files with
|
|
41
|
+
per-process random identifiers and hashed project paths. Successful verified
|
|
42
|
+
runs clear only the records they handled; failures retain records for retry.
|
|
43
|
+
Notices from the current process are never consumed by that process.
|
|
44
|
+
- Preserves npm version pins and git refs. Pi may reconcile a managed git clone
|
|
45
|
+
to its configured ref. Local paths and directly loaded extension files are
|
|
46
|
+
not pulled or rewritten. Edit local checkouts, not Pi-managed git clones.
|
|
47
|
+
- Compares Pi versions, npm versions, git commits, and npm dependency lock
|
|
48
|
+
fingerprints. No change means no restart and no success notification.
|
|
49
|
+
- Checks installed state even after an update fails, because Pi can update
|
|
50
|
+
packages before self-update fails. A failure is never reported as fully current.
|
|
51
|
+
- Uses one lock per Pi agent directory. A concurrent launch skips updates with
|
|
52
|
+
a warning instead of racing npm/git. After a crash, inspect the PID in
|
|
53
|
+
`proper-updater.lock` and remove that file only when its owner has exited.
|
|
54
|
+
- Update subprocesses time out after 3 minutes. Inventory and restart probes
|
|
55
|
+
have shorter deadlines. Termination includes installer descendants.
|
|
56
|
+
|
|
57
|
+
Availability observation wraps Pi's existing package-check method and Pi-version
|
|
58
|
+
notification methods through its virtual host exports. Native checks remain
|
|
59
|
+
intact. Eligible notices replace only the instruction line, preserving versions,
|
|
60
|
+
package lists, release notes, and changelog links. These are not a public update-event API; incompatible method
|
|
61
|
+
shapes disable automatic updates with a warning. No notification or failed check
|
|
62
|
+
is not proof of being up to date. Native checks skip pinned/missing sources, so
|
|
63
|
+
this extension does not proactively repair those installations without a notice.
|
|
64
|
+
|
|
65
|
+
Native Pi updates download and execute code from sources you already installed.
|
|
66
|
+
Automatic updates are enabled by default in proper-base and can be disabled
|
|
67
|
+
in `/settings` before a subsequent launch installs anything. New
|
|
68
|
+
package versions can change behavior or break compatibility. No rollback is
|
|
69
|
+
provided; offline, failed, pinned, or skipped updates cannot guarantee latest.
|
|
70
|
+
|
|
71
|
+
## Restart safety
|
|
72
|
+
|
|
73
|
+
On a safe launch, Pi shuts down normally first: terminal restoration and all
|
|
74
|
+
extension cleanup handlers finish before Node replaces the process. PID,
|
|
75
|
+
working directory, Node arguments, Pi options, environment, and the selected
|
|
76
|
+
persisted session are preserved. A PID-scoped one-shot marker prevents an
|
|
77
|
+
update/restart loop and is removed before descendants inherit it.
|
|
78
|
+
|
|
79
|
+
Pi has no public restart API. This implementation relies on Pi 0.86's graceful
|
|
80
|
+
quit ending in `process.exit(0)` and Node's experimental `process.execve`.
|
|
81
|
+
The restart executable is checked against the installed version before quitting.
|
|
82
|
+
|
|
83
|
+
Automatic restart is deferred, with a warning, when:
|
|
84
|
+
|
|
85
|
+
- You type during updates, have an editor draft, or have active/queued work.
|
|
86
|
+
- The launch includes a prompt, `@file`, `--resume`, `--fork`, `--session-id`,
|
|
87
|
+
unknown extension flags, or invalid arguments.
|
|
88
|
+
- A selected session cannot be verified on disk, or the updated executable
|
|
89
|
+
fails its version probe.
|
|
90
|
+
|
|
91
|
+
Previously recorded updates still install for those interactive launches. Restart manually to activate
|
|
92
|
+
them. Signals cancel update work and suppress any pending automatic restart.
|
|
93
|
+
|
|
94
|
+
RPC, print/JSON, SDK hosts, non-TTY invocations, Windows, Bun, pnpm paths,
|
|
95
|
+
installer-managed releases, and unrecognized launchers do not auto-update.
|
|
96
|
+
This avoids corrupting protocols, replaying piped input, or restarting an old
|
|
97
|
+
immutable executable. Use `pi update --all` between runs for these environments.
|
|
98
|
+
|
|
99
|
+
## Disable
|
|
100
|
+
|
|
101
|
+
Open `/settings` and set **Automatic updates** to **false**. The choice persists
|
|
102
|
+
across launches as an empty `<agentDir>/proper-updater.disabled` marker. Set it
|
|
103
|
+
back to **true** to re-enable. An unreadable preference disables installation
|
|
104
|
+
with a warning; failed writes leave the previous setting unchanged.
|
|
105
|
+
|
|
106
|
+
Disabling also stops recording new availability in this session, but does not
|
|
107
|
+
interrupt an installer already running. Existing readiness records are retained.
|
|
108
|
+
Re-enabling does not install immediately; the next launch can consume those
|
|
109
|
+
records. When disabled, Pi's own checks and manual update notices remain intact.
|
|
110
|
+
|
|
111
|
+
For a single launch, these overrides still take precedence over the setting:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
pi --no-auto-update
|
|
115
|
+
PROPER_UPDATER_OFF=1 pi
|
|
116
|
+
pi --offline
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
`PI_OFFLINE` is also respected. The `/settings` entry uses a guarded native-menu
|
|
120
|
+
adapter and coexists with proper-base's settings; flags remain available if a
|
|
121
|
+
future Pi version changes that menu. Update output is captured, not dumped into chat or model context;
|
|
122
|
+
run `pi update --all` yourself to see detailed failure output.
|
|
123
|
+
|
|
124
|
+
## Development
|
|
125
|
+
|
|
126
|
+
Updater code lives in `src/auto-update/`; its tests run with the rest of
|
|
127
|
+
proper-base's suite. Tests use temporary settings and fake subprocesses. They never update your Pi
|
|
128
|
+
installation or installed extensions. A subprocess test verifies native process
|
|
129
|
+
replacement; real registry updates and terminal rendering remain manual checks.
|
package/index.ts
CHANGED
|
@@ -15,10 +15,11 @@ import {
|
|
|
15
15
|
type ExtensionAPI,
|
|
16
16
|
type ExtensionContext,
|
|
17
17
|
getAgentDir,
|
|
18
|
+
type MarkdownTransformer,
|
|
18
19
|
SessionManager,
|
|
19
20
|
} from "@earendil-works/pi-coding-agent";
|
|
20
21
|
import { matchesKey } from "@earendil-works/pi-tui";
|
|
21
|
-
|
|
22
|
+
import { registerAutoUpdates } from "./src/auto-update/index.ts";
|
|
22
23
|
import {
|
|
23
24
|
installAutocompleteDetails,
|
|
24
25
|
installInlineSlashAutocomplete,
|
|
@@ -26,7 +27,9 @@ import {
|
|
|
26
27
|
modelThinkingCommand,
|
|
27
28
|
sortModelAutocompleteDescending,
|
|
28
29
|
} from "./src/autocomplete-details.ts";
|
|
30
|
+
import { installBaseKeybindings } from "./src/base-keybindings.ts";
|
|
29
31
|
import { installClipboardLeakGuard } from "./src/clipboard-guard.ts";
|
|
32
|
+
import { installClipboardSelection } from "./src/clipboard-selection.ts";
|
|
30
33
|
import { commitGuardReason } from "./src/commit-guard.ts";
|
|
31
34
|
import { installEditorMouseGuard } from "./src/editor-mouse.ts";
|
|
32
35
|
import {
|
|
@@ -56,21 +59,26 @@ import {
|
|
|
56
59
|
} from "./src/image-preview.ts";
|
|
57
60
|
import { installJumpToBottom } from "./src/jump-to-bottom.ts";
|
|
58
61
|
import { installOsc8LinkIds } from "./src/osc8-link-ids.ts";
|
|
62
|
+
import { installOverlayScroll } from "./src/overlay-scroll.ts";
|
|
63
|
+
import {
|
|
64
|
+
applyProactiveDelegation,
|
|
65
|
+
readProactiveDelegationEnabled,
|
|
66
|
+
} from "./src/proactive-delegation.ts";
|
|
59
67
|
import {
|
|
60
68
|
createPromptDisplay,
|
|
61
69
|
PROMPT_DISPLAY_ENTRY,
|
|
62
70
|
} from "./src/prompt-display.ts";
|
|
71
|
+
import { installPromptDisplayHost } from "./src/prompt-display-host.ts";
|
|
63
72
|
import { installPromptJump } from "./src/prompt-jump.ts";
|
|
73
|
+
import { appendPromptSection } from "./src/prompt-sections.ts";
|
|
64
74
|
import { installRecorder } from "./src/recorder.ts";
|
|
65
75
|
import { installSelectionDismiss } from "./src/selection-dismiss.ts";
|
|
66
76
|
import { installFastSessionList } from "./src/session-list.ts";
|
|
67
77
|
import { installSettings, type SettingsController } from "./src/settings.ts";
|
|
68
78
|
import { pinSkillContext } from "./src/skill-context.ts";
|
|
69
79
|
import { installSmartSelection } from "./src/smart-selection.ts";
|
|
70
|
-
import {
|
|
71
|
-
|
|
72
|
-
persistDefaultThinkingLevel,
|
|
73
|
-
} from "./src/startup-defaults.ts";
|
|
80
|
+
import { stickyDefaultsEnabled } from "./src/startup-defaults.ts";
|
|
81
|
+
import { installStickyDefaultsAdapter } from "./src/sticky-defaults.ts";
|
|
74
82
|
import {
|
|
75
83
|
appendPrompt,
|
|
76
84
|
compactIfNeeded,
|
|
@@ -83,6 +91,7 @@ import {
|
|
|
83
91
|
} from "./src/transcript-cleanup.ts";
|
|
84
92
|
import { normalizeCpaTransientError } from "./src/transient-retry.ts";
|
|
85
93
|
import { installWheelScrollLines } from "./src/wheel-scroll.ts";
|
|
94
|
+
import { installWidgetTranscript } from "./src/widget-transcript.ts";
|
|
86
95
|
|
|
87
96
|
/** Prompts seeded into the editor. Older prompts past this point are dropped. */
|
|
88
97
|
const MAX_ENTRIES = 200;
|
|
@@ -99,76 +108,6 @@ type EditorFactory = NonNullable<
|
|
|
99
108
|
>;
|
|
100
109
|
|
|
101
110
|
type TaggedFactory = EditorFactory & { [WRAPPED]?: EditorFactory | null };
|
|
102
|
-
type EditorKeybindings = Parameters<EditorFactory>[2];
|
|
103
|
-
|
|
104
|
-
const FULLSCREEN_KEYBINDINGS = Symbol.for(
|
|
105
|
-
"pi-proper-base.fullscreen-keybindings",
|
|
106
|
-
);
|
|
107
|
-
const LEGACY_FULLSCREEN_KEYBINDINGS = Symbol.for(
|
|
108
|
-
"pi-proper-customs.fullscreen-keybindings",
|
|
109
|
-
);
|
|
110
|
-
const FULLSCREEN_KEYS = {
|
|
111
|
-
"tui.altScreen.pageUp": "ctrl+shift+pageUp",
|
|
112
|
-
"tui.altScreen.pageDown": "ctrl+shift+pageDown",
|
|
113
|
-
"tui.altScreen.top": "ctrl+shift+home",
|
|
114
|
-
"tui.altScreen.bottom": "ctrl+shift+end",
|
|
115
|
-
} as const;
|
|
116
|
-
|
|
117
|
-
type KeybindingController = { apply(): void };
|
|
118
|
-
type PatchedKeybindings = EditorKeybindings & {
|
|
119
|
-
[FULLSCREEN_KEYBINDINGS]?: true | KeybindingController;
|
|
120
|
-
[LEGACY_FULLSCREEN_KEYBINDINGS]?: true | KeybindingController;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
function installKeybindings(keybindings: EditorKeybindings): void {
|
|
124
|
-
const patched = keybindings as PatchedKeybindings;
|
|
125
|
-
const apply = () => {
|
|
126
|
-
const imagePasteKeys = [
|
|
127
|
-
...new Set([
|
|
128
|
-
...keybindings.getKeys("app.clipboard.pasteImage"),
|
|
129
|
-
"ctrl+v" as const,
|
|
130
|
-
"ctrl+shift+v" as const,
|
|
131
|
-
]),
|
|
132
|
-
];
|
|
133
|
-
// Shift+Enter is already Pi's `tui.input.newLine` default; only Alt+Enter
|
|
134
|
-
// needs adding, and only because it must leave `app.message.followUp`.
|
|
135
|
-
const newLineKeys = [
|
|
136
|
-
...new Set([
|
|
137
|
-
...keybindings.getKeys("tui.input.newLine"),
|
|
138
|
-
"alt+enter" as const,
|
|
139
|
-
]),
|
|
140
|
-
];
|
|
141
|
-
const followUpKeys = keybindings
|
|
142
|
-
.getKeys("app.message.followUp")
|
|
143
|
-
.filter((key) => key !== "alt+enter");
|
|
144
|
-
keybindings.setUserBindings({
|
|
145
|
-
...keybindings.getUserBindings(),
|
|
146
|
-
...FULLSCREEN_KEYS,
|
|
147
|
-
"app.clipboard.pasteImage": imagePasteKeys,
|
|
148
|
-
"tui.input.newLine": newLineKeys,
|
|
149
|
-
"app.message.followUp": followUpKeys,
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
const existing =
|
|
153
|
-
patched[FULLSCREEN_KEYBINDINGS] ?? patched[LEGACY_FULLSCREEN_KEYBINDINGS];
|
|
154
|
-
if (existing && existing !== true) {
|
|
155
|
-
existing.apply = apply;
|
|
156
|
-
patched[FULLSCREEN_KEYBINDINGS] = existing;
|
|
157
|
-
delete patched[LEGACY_FULLSCREEN_KEYBINDINGS];
|
|
158
|
-
existing.apply();
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const reload = keybindings.reload.bind(keybindings);
|
|
163
|
-
const controller: KeybindingController = { apply };
|
|
164
|
-
keybindings.reload = () => {
|
|
165
|
-
reload();
|
|
166
|
-
controller.apply();
|
|
167
|
-
};
|
|
168
|
-
patched[FULLSCREEN_KEYBINDINGS] = controller;
|
|
169
|
-
delete patched[LEGACY_FULLSCREEN_KEYBINDINGS];
|
|
170
|
-
controller.apply();
|
|
171
|
-
}
|
|
172
111
|
|
|
173
112
|
type EditorTui = Parameters<EditorFactory>[0] & {
|
|
174
113
|
scrollToBottom?(): void;
|
|
@@ -262,7 +201,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
262
201
|
installClipboardLeakGuard();
|
|
263
202
|
enableScribeCapabilities();
|
|
264
203
|
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Session listing]]
|
|
265
|
-
installFastSessionList(
|
|
204
|
+
const removeFastSessionList = installFastSessionList(
|
|
205
|
+
SessionManager,
|
|
206
|
+
getAgentDir(),
|
|
207
|
+
);
|
|
208
|
+
const stickyDefaults = installStickyDefaultsAdapter(() =>
|
|
209
|
+
stickyDefaultsEnabled(getAgentDir()),
|
|
210
|
+
);
|
|
266
211
|
|
|
267
212
|
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Fast tier scopes]]
|
|
268
213
|
const fastOverlay = new FastOverlay(getAgentDir());
|
|
@@ -276,6 +221,14 @@ export default function (pi: ExtensionAPI) {
|
|
|
276
221
|
ctx.ui.notify("Usage: /fast-global", "error");
|
|
277
222
|
return;
|
|
278
223
|
}
|
|
224
|
+
const environmentOverride = fastOverlay.globalEnvironmentOverride();
|
|
225
|
+
if (environmentOverride !== undefined) {
|
|
226
|
+
ctx.ui.notify(
|
|
227
|
+
`Cannot toggle global Fast mode while CLIPROXYAPI_FAST=${environmentOverride ? "true" : "false"} overrides the saved setting.`,
|
|
228
|
+
"warning",
|
|
229
|
+
);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
279
232
|
let enabled: boolean;
|
|
280
233
|
try {
|
|
281
234
|
enabled = fastOverlay.toggleGlobal();
|
|
@@ -295,17 +248,26 @@ export default function (pi: ExtensionAPI) {
|
|
|
295
248
|
});
|
|
296
249
|
|
|
297
250
|
let removeFooterColors: (() => void) | undefined;
|
|
251
|
+
let removeKeybindings: (() => void) | undefined;
|
|
252
|
+
let removeWheelScroll: (() => void) | undefined;
|
|
253
|
+
// ctx.ui.addAutocompleteProvider() returns void and stacks permanently, so
|
|
254
|
+
// re-registering on every session_start would leave one live provider per
|
|
255
|
+
// session load. Register the model sort exactly once.
|
|
256
|
+
let autocompleteInstalled = false;
|
|
298
257
|
let removeJumpToBottom: (() => void) | undefined;
|
|
299
258
|
let removePromptJump: (() => void) | undefined;
|
|
300
259
|
let settings: SettingsController | undefined;
|
|
301
260
|
let removeEditorMouseGuard: (() => void) | undefined;
|
|
302
261
|
let removePromptClear: (() => void) | undefined;
|
|
303
262
|
let removeSmartSelection: (() => void) | undefined;
|
|
263
|
+
let removeClipboardSelection: (() => void) | undefined;
|
|
304
264
|
let removeSelectionDismiss: (() => void) | undefined;
|
|
265
|
+
let removeOverlayScroll: (() => void) | undefined;
|
|
305
266
|
let removeOsc8LinkIds: (() => void) | undefined;
|
|
306
267
|
let imagePreview: ImagePreviewController | undefined;
|
|
307
268
|
let removeTerminalInput: (() => void) | undefined;
|
|
308
269
|
let transcriptCleanup: TranscriptCleanupController | undefined;
|
|
270
|
+
let removeWidgetTranscript: (() => void) | undefined;
|
|
309
271
|
let activeEditor: PromptEditor | undefined;
|
|
310
272
|
let activeTui: EditorTui | undefined;
|
|
311
273
|
let submittedPrompt: string | undefined;
|
|
@@ -315,13 +277,16 @@ export default function (pi: ExtensionAPI) {
|
|
|
315
277
|
let sessionTitlePending = false;
|
|
316
278
|
const promptDisplay = createPromptDisplay();
|
|
317
279
|
|
|
318
|
-
|
|
319
|
-
pi.registerMarkdownTransformer?.((markdown, context) => {
|
|
320
|
-
if (context.messageType === "user")
|
|
321
|
-
return promptDisplay.transform(markdown);
|
|
280
|
+
const markdownTransformer: MarkdownTransformer = (markdown, context) => {
|
|
322
281
|
if (context.messageType !== "assistant") return markdown;
|
|
323
282
|
return markdown.replace(SESSION_TITLE_DISPLAY_PATTERN, "");
|
|
324
|
-
}
|
|
283
|
+
};
|
|
284
|
+
pi.registerMarkdownTransformer?.(markdownTransformer);
|
|
285
|
+
const promptDisplayHost = installPromptDisplayHost(
|
|
286
|
+
promptDisplay,
|
|
287
|
+
() => pi.getCommands(),
|
|
288
|
+
markdownTransformer,
|
|
289
|
+
);
|
|
325
290
|
|
|
326
291
|
const findPendingEntry = (ctx: ExtensionContext) => {
|
|
327
292
|
if (!pendingPrompt?.messageTimestamp) return undefined;
|
|
@@ -435,25 +400,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
435
400
|
},
|
|
436
401
|
});
|
|
437
402
|
|
|
438
|
-
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Sticky startup defaults]]
|
|
439
|
-
pi.on("model_select", (event) => {
|
|
440
|
-
if (event.source === "restore") return;
|
|
441
|
-
persistDefaultModel(getAgentDir(), event.model);
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
pi.on("thinking_level_select", (event, ctx) => {
|
|
445
|
-
persistDefaultThinkingLevel(
|
|
446
|
-
getAgentDir(),
|
|
447
|
-
event.level,
|
|
448
|
-
ctx.model ?? undefined,
|
|
449
|
-
);
|
|
450
|
-
});
|
|
451
|
-
|
|
452
403
|
pi.on("input", (event) => {
|
|
453
404
|
if (event.source === "interactive") {
|
|
454
405
|
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Pinned transcript scrolling]]
|
|
455
406
|
if (event.text.trim()) activeTui?.scrollToBottom?.();
|
|
456
|
-
promptDisplay.captureInput(event.text, pi.getCommands());
|
|
457
407
|
}
|
|
458
408
|
if (
|
|
459
409
|
event.source === "interactive" &&
|
|
@@ -474,7 +424,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
474
424
|
|
|
475
425
|
pi.on("message_start", (event) => {
|
|
476
426
|
if (event.message.role === "user") {
|
|
477
|
-
promptDisplay.captureUser(event.message);
|
|
478
427
|
if (pendingPrompt) {
|
|
479
428
|
pendingPrompt.messageTimestamp = event.message.timestamp;
|
|
480
429
|
}
|
|
@@ -510,15 +459,29 @@ export default function (pi: ExtensionAPI) {
|
|
|
510
459
|
if (messages !== event.messages) return { messages };
|
|
511
460
|
});
|
|
512
461
|
|
|
462
|
+
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Proactive delegation]]
|
|
463
|
+
pi.on("before_agent_start", (event, ctx) => {
|
|
464
|
+
if (!readProactiveDelegationEnabled(getAgentDir())) return;
|
|
465
|
+
const tools =
|
|
466
|
+
event.systemPromptOptions?.selectedTools ?? pi.getActiveTools?.() ?? [];
|
|
467
|
+
applyProactiveDelegation(
|
|
468
|
+
event.systemPromptOptions,
|
|
469
|
+
tools.includes("subagent"),
|
|
470
|
+
ctx.scopedModels.map((scoped) => scoped.model),
|
|
471
|
+
);
|
|
472
|
+
});
|
|
473
|
+
|
|
513
474
|
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Automatic session title]]
|
|
514
475
|
pi.on("before_agent_start", (event) => {
|
|
515
476
|
if (!sessionTitlePending || pi.getSessionName?.()) {
|
|
516
477
|
sessionTitlePending = false;
|
|
517
478
|
return;
|
|
518
479
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
480
|
+
appendPromptSection(
|
|
481
|
+
event.systemPromptOptions,
|
|
482
|
+
"proper_base_title",
|
|
483
|
+
SESSION_TITLE_INSTRUCTION,
|
|
484
|
+
);
|
|
522
485
|
});
|
|
523
486
|
|
|
524
487
|
pi.on("message_end", (event) => {
|
|
@@ -622,8 +585,15 @@ export default function (pi: ExtensionAPI) {
|
|
|
622
585
|
});
|
|
623
586
|
|
|
624
587
|
pi.on("session_shutdown", () => {
|
|
588
|
+
removeFastSessionList();
|
|
589
|
+
stickyDefaults.restore();
|
|
590
|
+
removeKeybindings?.();
|
|
591
|
+
removeKeybindings = undefined;
|
|
592
|
+
removeWheelScroll?.();
|
|
593
|
+
removeWheelScroll = undefined;
|
|
625
594
|
removeFooterColors?.();
|
|
626
595
|
removeFooterColors = undefined;
|
|
596
|
+
fastOverlay.stopDisplayRefresh();
|
|
627
597
|
removeJumpToBottom?.();
|
|
628
598
|
removeJumpToBottom = undefined;
|
|
629
599
|
removePromptJump?.();
|
|
@@ -636,14 +606,20 @@ export default function (pi: ExtensionAPI) {
|
|
|
636
606
|
removePromptClear = undefined;
|
|
637
607
|
removeSmartSelection?.();
|
|
638
608
|
removeSmartSelection = undefined;
|
|
609
|
+
removeClipboardSelection?.();
|
|
610
|
+
removeClipboardSelection = undefined;
|
|
639
611
|
removeSelectionDismiss?.();
|
|
640
612
|
removeSelectionDismiss = undefined;
|
|
613
|
+
removeOverlayScroll?.();
|
|
614
|
+
removeOverlayScroll = undefined;
|
|
641
615
|
removeOsc8LinkIds?.();
|
|
642
616
|
removeOsc8LinkIds = undefined;
|
|
643
617
|
imagePreview?.dispose();
|
|
644
618
|
imagePreview = undefined;
|
|
645
619
|
removeTerminalInput?.();
|
|
646
620
|
removeTerminalInput = undefined;
|
|
621
|
+
removeWidgetTranscript?.();
|
|
622
|
+
removeWidgetTranscript = undefined;
|
|
647
623
|
transcriptCleanup?.uninstall();
|
|
648
624
|
transcriptCleanup = undefined;
|
|
649
625
|
activeEditor = undefined;
|
|
@@ -652,13 +628,14 @@ export default function (pi: ExtensionAPI) {
|
|
|
652
628
|
pendingPrompt = undefined;
|
|
653
629
|
restoreRequest = undefined;
|
|
654
630
|
sessionTitlePending = false;
|
|
655
|
-
|
|
631
|
+
promptDisplayHost.dispose();
|
|
656
632
|
});
|
|
657
633
|
|
|
658
634
|
pi.on("session_start", async (_event, ctx) => {
|
|
635
|
+
stickyDefaults.activate(ctx.sessionManager);
|
|
659
636
|
// Session Fast never survives into a new or restored session.
|
|
660
637
|
fastOverlay.resetSession();
|
|
661
|
-
|
|
638
|
+
promptDisplayHost.activate(ctx.sessionManager);
|
|
662
639
|
sessionTitlePending =
|
|
663
640
|
!pi.getSessionName?.() &&
|
|
664
641
|
!ctx.sessionManager
|
|
@@ -699,9 +676,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
699
676
|
ctx.ui.setEditorText(promptText);
|
|
700
677
|
return undefined;
|
|
701
678
|
});
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
679
|
+
if (!autocompleteInstalled) {
|
|
680
|
+
autocompleteInstalled = true;
|
|
681
|
+
ctx.ui.addAutocompleteProvider?.((current) =>
|
|
682
|
+
sortModelAutocompleteDescending(current, () => pi.getThinkingLevel?.()),
|
|
683
|
+
);
|
|
684
|
+
}
|
|
705
685
|
|
|
706
686
|
const store = storePath(getAgentDir(), ctx.cwd);
|
|
707
687
|
compactIfNeeded(store);
|
|
@@ -735,19 +715,26 @@ export default function (pi: ExtensionAPI) {
|
|
|
735
715
|
// with extensions that provide their own editor.
|
|
736
716
|
const base = resolveBase(ctx.ui.getEditorComponent());
|
|
737
717
|
const factory: TaggedFactory = (tui, theme, keybindings) => {
|
|
738
|
-
|
|
718
|
+
removeKeybindings?.();
|
|
719
|
+
removeKeybindings = installBaseKeybindings(keybindings);
|
|
739
720
|
const editor =
|
|
740
721
|
base?.(tui, theme, keybindings) ??
|
|
741
722
|
new CustomEditor(tui, theme, keybindings);
|
|
742
723
|
activeEditor = editor as PromptEditor;
|
|
743
724
|
activeTui = tui;
|
|
744
725
|
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Wheel scroll rate]]
|
|
745
|
-
|
|
726
|
+
removeWheelScroll?.();
|
|
727
|
+
removeWheelScroll = installWheelScrollLines(tui);
|
|
746
728
|
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Settled transcript]]
|
|
747
729
|
transcriptCleanup?.uninstall();
|
|
748
730
|
transcriptCleanup = installTranscriptCleanup(tui, ctx);
|
|
731
|
+
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Transcript widgets]]
|
|
732
|
+
removeWidgetTranscript?.();
|
|
733
|
+
removeWidgetTranscript = installWidgetTranscript(tui, editor);
|
|
749
734
|
removeSmartSelection?.();
|
|
750
735
|
removeSmartSelection = installSmartSelection(tui);
|
|
736
|
+
removeClipboardSelection?.();
|
|
737
|
+
removeClipboardSelection = installClipboardSelection(tui);
|
|
751
738
|
removeSelectionDismiss?.();
|
|
752
739
|
// The copy action reads the active selection after this listener runs,
|
|
753
740
|
// so its keystroke must not dismiss the selection it is about to copy.
|
|
@@ -756,6 +743,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
756
743
|
.getKeys("app.message.copy")
|
|
757
744
|
.some((key) => matchesKey(data, key)),
|
|
758
745
|
);
|
|
746
|
+
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Overlay transcript scrolling]]
|
|
747
|
+
removeOverlayScroll?.();
|
|
748
|
+
removeOverlayScroll = installOverlayScroll(tui);
|
|
759
749
|
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Hyperlink identity]]
|
|
760
750
|
removeOsc8LinkIds?.();
|
|
761
751
|
removeOsc8LinkIds = installOsc8LinkIds(tui);
|
|
@@ -803,6 +793,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
803
793
|
modelSupported: fastOverlay.supportsModel(ctx.model ?? undefined),
|
|
804
794
|
});
|
|
805
795
|
ctx.ui.notify(notice.message, notice.level);
|
|
796
|
+
tui.requestRender();
|
|
806
797
|
return true;
|
|
807
798
|
}
|
|
808
799
|
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Model thinking argument]]
|
|
@@ -821,7 +812,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
821
812
|
);
|
|
822
813
|
installAutocompleteDetails(editor, tui, theme);
|
|
823
814
|
removeFooterColors?.();
|
|
824
|
-
|
|
815
|
+
fastOverlay.stopDisplayRefresh();
|
|
816
|
+
removeFooterColors = installFooterColors(tui, ctx, () =>
|
|
817
|
+
fastOverlay.isEffectiveForDisplay(ctx.model ?? undefined),
|
|
818
|
+
);
|
|
819
|
+
if (removeFooterColors) {
|
|
820
|
+
fastOverlay.startDisplayRefresh(() => tui.requestRender());
|
|
821
|
+
}
|
|
825
822
|
for (const prompt of seeded) historyGuard?.add(prompt);
|
|
826
823
|
return editor;
|
|
827
824
|
};
|
|
@@ -829,4 +826,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
829
826
|
|
|
830
827
|
ctx.ui.setEditorComponent(factory);
|
|
831
828
|
});
|
|
829
|
+
// Base setup and cleanup must register before the updater's lifecycle hooks.
|
|
830
|
+
registerAutoUpdates(pi);
|
|
832
831
|
}
|