proper-base 0.6.0 → 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 +36 -13
- package/UPDATES.md +129 -0
- package/index.ts +76 -111
- package/package.json +4 -3
- 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 +73 -12
- package/src/footer-colors.ts +55 -3
- package/src/host-interop.ts +49 -0
- package/src/image-preview.ts +75 -66
- package/src/proactive-delegation.ts +33 -14
- 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/wheel-scroll.ts +24 -27
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 |
|
|
@@ -121,6 +134,11 @@ Wheel and transcript scroll keys keep working while an `ask_user_question`
|
|
|
121
134
|
questionnaire or other overlay has focus, so earlier context stays reachable.
|
|
122
135
|
| Double-click | Select a complete one-line URL, path, flag, qualified identifier, or quoted value when possible. |
|
|
123
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
|
+
|
|
124
142
|
Scrolling away from current output adds a `↓ jump to bottom` row above the
|
|
125
143
|
prompt. Clicking it returns to the newest output without disabling scrollbar
|
|
126
144
|
dragging.
|
|
@@ -148,9 +166,9 @@ as `editorMouse` and `sessionRail`.
|
|
|
148
166
|
Ctrl+V and Ctrl+Shift+V both use Pi's image-or-text clipboard action. Readable
|
|
149
167
|
clipboard image paths appear as short `[image N]` markers. Image-capable
|
|
150
168
|
terminals render compact previews; text-only terminals show marker source paths.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
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
|
|
154
172
|
no external image command is required. Pi's accent braille loader animates while conversion runs; the
|
|
155
173
|
marker and path appear only if conversion is unavailable or fails. When terminal
|
|
156
174
|
focus returns, active Kitty previews are retransmitted so a lost terminal-side
|
|
@@ -179,7 +197,9 @@ the model a one-line already-loaded note instead of a second copy; a body that
|
|
|
179
197
|
changed with its arguments is sent in full. After a compaction, the newest body
|
|
180
198
|
of each dropped skill is restored on the first user turn following the summary,
|
|
181
199
|
truncated to a character ceiling per skill and in total so the restored text
|
|
182
|
-
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,
|
|
183
203
|
so saved sessions, exports, resumes, and branches retain the originals.
|
|
184
204
|
|
|
185
205
|
### Footer
|
|
@@ -192,7 +212,7 @@ highlight. Custom replacement footers are not changed.
|
|
|
192
212
|
|
|
193
213
|
## Install
|
|
194
214
|
|
|
195
|
-
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.
|
|
196
216
|
|
|
197
217
|
From npm:
|
|
198
218
|
|
|
@@ -207,10 +227,9 @@ pi install /path/to/proper-pi-extensions/proper-base
|
|
|
207
227
|
```
|
|
208
228
|
|
|
209
229
|
Pi supplies the core `@earendil-works/pi-coding-agent` and
|
|
210
|
-
`@earendil-works/pi-tui` peer packages.
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
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.
|
|
214
233
|
|
|
215
234
|
This package replaces the former local `proper-customs` identity. Keep only one
|
|
216
235
|
registration. Existing data under the legacy `proper-history` path remains
|
|
@@ -218,6 +237,10 @@ compatible.
|
|
|
218
237
|
|
|
219
238
|
## Compatibility
|
|
220
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
|
+
|
|
221
244
|
- Fullscreen behavior uses Pi's native `tuiMode: "fullscreen"` renderer.
|
|
222
245
|
- Questionnaire cancellation activates only when `ask_user_question` is
|
|
223
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 {
|
|
@@ -65,17 +68,17 @@ import {
|
|
|
65
68
|
createPromptDisplay,
|
|
66
69
|
PROMPT_DISPLAY_ENTRY,
|
|
67
70
|
} from "./src/prompt-display.ts";
|
|
71
|
+
import { installPromptDisplayHost } from "./src/prompt-display-host.ts";
|
|
68
72
|
import { installPromptJump } from "./src/prompt-jump.ts";
|
|
73
|
+
import { appendPromptSection } from "./src/prompt-sections.ts";
|
|
69
74
|
import { installRecorder } from "./src/recorder.ts";
|
|
70
75
|
import { installSelectionDismiss } from "./src/selection-dismiss.ts";
|
|
71
76
|
import { installFastSessionList } from "./src/session-list.ts";
|
|
72
77
|
import { installSettings, type SettingsController } from "./src/settings.ts";
|
|
73
78
|
import { pinSkillContext } from "./src/skill-context.ts";
|
|
74
79
|
import { installSmartSelection } from "./src/smart-selection.ts";
|
|
75
|
-
import {
|
|
76
|
-
|
|
77
|
-
persistDefaultThinkingLevel,
|
|
78
|
-
} from "./src/startup-defaults.ts";
|
|
80
|
+
import { stickyDefaultsEnabled } from "./src/startup-defaults.ts";
|
|
81
|
+
import { installStickyDefaultsAdapter } from "./src/sticky-defaults.ts";
|
|
79
82
|
import {
|
|
80
83
|
appendPrompt,
|
|
81
84
|
compactIfNeeded,
|
|
@@ -105,76 +108,6 @@ type EditorFactory = NonNullable<
|
|
|
105
108
|
>;
|
|
106
109
|
|
|
107
110
|
type TaggedFactory = EditorFactory & { [WRAPPED]?: EditorFactory | null };
|
|
108
|
-
type EditorKeybindings = Parameters<EditorFactory>[2];
|
|
109
|
-
|
|
110
|
-
const FULLSCREEN_KEYBINDINGS = Symbol.for(
|
|
111
|
-
"pi-proper-base.fullscreen-keybindings",
|
|
112
|
-
);
|
|
113
|
-
const LEGACY_FULLSCREEN_KEYBINDINGS = Symbol.for(
|
|
114
|
-
"pi-proper-customs.fullscreen-keybindings",
|
|
115
|
-
);
|
|
116
|
-
const FULLSCREEN_KEYS = {
|
|
117
|
-
"tui.altScreen.pageUp": "ctrl+shift+pageUp",
|
|
118
|
-
"tui.altScreen.pageDown": "ctrl+shift+pageDown",
|
|
119
|
-
"tui.altScreen.top": "ctrl+shift+home",
|
|
120
|
-
"tui.altScreen.bottom": "ctrl+shift+end",
|
|
121
|
-
} as const;
|
|
122
|
-
|
|
123
|
-
type KeybindingController = { apply(): void };
|
|
124
|
-
type PatchedKeybindings = EditorKeybindings & {
|
|
125
|
-
[FULLSCREEN_KEYBINDINGS]?: true | KeybindingController;
|
|
126
|
-
[LEGACY_FULLSCREEN_KEYBINDINGS]?: true | KeybindingController;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
function installKeybindings(keybindings: EditorKeybindings): void {
|
|
130
|
-
const patched = keybindings as PatchedKeybindings;
|
|
131
|
-
const apply = () => {
|
|
132
|
-
const imagePasteKeys = [
|
|
133
|
-
...new Set([
|
|
134
|
-
...keybindings.getKeys("app.clipboard.pasteImage"),
|
|
135
|
-
"ctrl+v" as const,
|
|
136
|
-
"ctrl+shift+v" as const,
|
|
137
|
-
]),
|
|
138
|
-
];
|
|
139
|
-
// Shift+Enter is already Pi's `tui.input.newLine` default; only Alt+Enter
|
|
140
|
-
// needs adding, and only because it must leave `app.message.followUp`.
|
|
141
|
-
const newLineKeys = [
|
|
142
|
-
...new Set([
|
|
143
|
-
...keybindings.getKeys("tui.input.newLine"),
|
|
144
|
-
"alt+enter" as const,
|
|
145
|
-
]),
|
|
146
|
-
];
|
|
147
|
-
const followUpKeys = keybindings
|
|
148
|
-
.getKeys("app.message.followUp")
|
|
149
|
-
.filter((key) => key !== "alt+enter");
|
|
150
|
-
keybindings.setUserBindings({
|
|
151
|
-
...keybindings.getUserBindings(),
|
|
152
|
-
...FULLSCREEN_KEYS,
|
|
153
|
-
"app.clipboard.pasteImage": imagePasteKeys,
|
|
154
|
-
"tui.input.newLine": newLineKeys,
|
|
155
|
-
"app.message.followUp": followUpKeys,
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
|
-
const existing =
|
|
159
|
-
patched[FULLSCREEN_KEYBINDINGS] ?? patched[LEGACY_FULLSCREEN_KEYBINDINGS];
|
|
160
|
-
if (existing && existing !== true) {
|
|
161
|
-
existing.apply = apply;
|
|
162
|
-
patched[FULLSCREEN_KEYBINDINGS] = existing;
|
|
163
|
-
delete patched[LEGACY_FULLSCREEN_KEYBINDINGS];
|
|
164
|
-
existing.apply();
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const reload = keybindings.reload.bind(keybindings);
|
|
169
|
-
const controller: KeybindingController = { apply };
|
|
170
|
-
keybindings.reload = () => {
|
|
171
|
-
reload();
|
|
172
|
-
controller.apply();
|
|
173
|
-
};
|
|
174
|
-
patched[FULLSCREEN_KEYBINDINGS] = controller;
|
|
175
|
-
delete patched[LEGACY_FULLSCREEN_KEYBINDINGS];
|
|
176
|
-
controller.apply();
|
|
177
|
-
}
|
|
178
111
|
|
|
179
112
|
type EditorTui = Parameters<EditorFactory>[0] & {
|
|
180
113
|
scrollToBottom?(): void;
|
|
@@ -268,7 +201,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
268
201
|
installClipboardLeakGuard();
|
|
269
202
|
enableScribeCapabilities();
|
|
270
203
|
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Session listing]]
|
|
271
|
-
installFastSessionList(
|
|
204
|
+
const removeFastSessionList = installFastSessionList(
|
|
205
|
+
SessionManager,
|
|
206
|
+
getAgentDir(),
|
|
207
|
+
);
|
|
208
|
+
const stickyDefaults = installStickyDefaultsAdapter(() =>
|
|
209
|
+
stickyDefaultsEnabled(getAgentDir()),
|
|
210
|
+
);
|
|
272
211
|
|
|
273
212
|
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Fast tier scopes]]
|
|
274
213
|
const fastOverlay = new FastOverlay(getAgentDir());
|
|
@@ -282,6 +221,14 @@ export default function (pi: ExtensionAPI) {
|
|
|
282
221
|
ctx.ui.notify("Usage: /fast-global", "error");
|
|
283
222
|
return;
|
|
284
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
|
+
}
|
|
285
232
|
let enabled: boolean;
|
|
286
233
|
try {
|
|
287
234
|
enabled = fastOverlay.toggleGlobal();
|
|
@@ -301,12 +248,19 @@ export default function (pi: ExtensionAPI) {
|
|
|
301
248
|
});
|
|
302
249
|
|
|
303
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;
|
|
304
257
|
let removeJumpToBottom: (() => void) | undefined;
|
|
305
258
|
let removePromptJump: (() => void) | undefined;
|
|
306
259
|
let settings: SettingsController | undefined;
|
|
307
260
|
let removeEditorMouseGuard: (() => void) | undefined;
|
|
308
261
|
let removePromptClear: (() => void) | undefined;
|
|
309
262
|
let removeSmartSelection: (() => void) | undefined;
|
|
263
|
+
let removeClipboardSelection: (() => void) | undefined;
|
|
310
264
|
let removeSelectionDismiss: (() => void) | undefined;
|
|
311
265
|
let removeOverlayScroll: (() => void) | undefined;
|
|
312
266
|
let removeOsc8LinkIds: (() => void) | undefined;
|
|
@@ -323,13 +277,16 @@ export default function (pi: ExtensionAPI) {
|
|
|
323
277
|
let sessionTitlePending = false;
|
|
324
278
|
const promptDisplay = createPromptDisplay();
|
|
325
279
|
|
|
326
|
-
|
|
327
|
-
pi.registerMarkdownTransformer?.((markdown, context) => {
|
|
328
|
-
if (context.messageType === "user")
|
|
329
|
-
return promptDisplay.transform(markdown);
|
|
280
|
+
const markdownTransformer: MarkdownTransformer = (markdown, context) => {
|
|
330
281
|
if (context.messageType !== "assistant") return markdown;
|
|
331
282
|
return markdown.replace(SESSION_TITLE_DISPLAY_PATTERN, "");
|
|
332
|
-
}
|
|
283
|
+
};
|
|
284
|
+
pi.registerMarkdownTransformer?.(markdownTransformer);
|
|
285
|
+
const promptDisplayHost = installPromptDisplayHost(
|
|
286
|
+
promptDisplay,
|
|
287
|
+
() => pi.getCommands(),
|
|
288
|
+
markdownTransformer,
|
|
289
|
+
);
|
|
333
290
|
|
|
334
291
|
const findPendingEntry = (ctx: ExtensionContext) => {
|
|
335
292
|
if (!pendingPrompt?.messageTimestamp) return undefined;
|
|
@@ -443,25 +400,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
443
400
|
},
|
|
444
401
|
});
|
|
445
402
|
|
|
446
|
-
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Sticky startup defaults]]
|
|
447
|
-
pi.on("model_select", (event) => {
|
|
448
|
-
if (event.source === "restore") return;
|
|
449
|
-
persistDefaultModel(getAgentDir(), event.model);
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
pi.on("thinking_level_select", (event, ctx) => {
|
|
453
|
-
persistDefaultThinkingLevel(
|
|
454
|
-
getAgentDir(),
|
|
455
|
-
event.level,
|
|
456
|
-
ctx.model ?? undefined,
|
|
457
|
-
);
|
|
458
|
-
});
|
|
459
|
-
|
|
460
403
|
pi.on("input", (event) => {
|
|
461
404
|
if (event.source === "interactive") {
|
|
462
405
|
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Pinned transcript scrolling]]
|
|
463
406
|
if (event.text.trim()) activeTui?.scrollToBottom?.();
|
|
464
|
-
promptDisplay.captureInput(event.text, pi.getCommands());
|
|
465
407
|
}
|
|
466
408
|
if (
|
|
467
409
|
event.source === "interactive" &&
|
|
@@ -482,7 +424,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
482
424
|
|
|
483
425
|
pi.on("message_start", (event) => {
|
|
484
426
|
if (event.message.role === "user") {
|
|
485
|
-
promptDisplay.captureUser(event.message);
|
|
486
427
|
if (pendingPrompt) {
|
|
487
428
|
pendingPrompt.messageTimestamp = event.message.timestamp;
|
|
488
429
|
}
|
|
@@ -523,12 +464,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
523
464
|
if (!readProactiveDelegationEnabled(getAgentDir())) return;
|
|
524
465
|
const tools =
|
|
525
466
|
event.systemPromptOptions?.selectedTools ?? pi.getActiveTools?.() ?? [];
|
|
526
|
-
|
|
527
|
-
event.
|
|
467
|
+
applyProactiveDelegation(
|
|
468
|
+
event.systemPromptOptions,
|
|
528
469
|
tools.includes("subagent"),
|
|
529
470
|
ctx.scopedModels.map((scoped) => scoped.model),
|
|
530
471
|
);
|
|
531
|
-
if (systemPrompt !== undefined) return { systemPrompt };
|
|
532
472
|
});
|
|
533
473
|
|
|
534
474
|
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Automatic session title]]
|
|
@@ -537,9 +477,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
537
477
|
sessionTitlePending = false;
|
|
538
478
|
return;
|
|
539
479
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
480
|
+
appendPromptSection(
|
|
481
|
+
event.systemPromptOptions,
|
|
482
|
+
"proper_base_title",
|
|
483
|
+
SESSION_TITLE_INSTRUCTION,
|
|
484
|
+
);
|
|
543
485
|
});
|
|
544
486
|
|
|
545
487
|
pi.on("message_end", (event) => {
|
|
@@ -643,8 +585,15 @@ export default function (pi: ExtensionAPI) {
|
|
|
643
585
|
});
|
|
644
586
|
|
|
645
587
|
pi.on("session_shutdown", () => {
|
|
588
|
+
removeFastSessionList();
|
|
589
|
+
stickyDefaults.restore();
|
|
590
|
+
removeKeybindings?.();
|
|
591
|
+
removeKeybindings = undefined;
|
|
592
|
+
removeWheelScroll?.();
|
|
593
|
+
removeWheelScroll = undefined;
|
|
646
594
|
removeFooterColors?.();
|
|
647
595
|
removeFooterColors = undefined;
|
|
596
|
+
fastOverlay.stopDisplayRefresh();
|
|
648
597
|
removeJumpToBottom?.();
|
|
649
598
|
removeJumpToBottom = undefined;
|
|
650
599
|
removePromptJump?.();
|
|
@@ -657,6 +606,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
657
606
|
removePromptClear = undefined;
|
|
658
607
|
removeSmartSelection?.();
|
|
659
608
|
removeSmartSelection = undefined;
|
|
609
|
+
removeClipboardSelection?.();
|
|
610
|
+
removeClipboardSelection = undefined;
|
|
660
611
|
removeSelectionDismiss?.();
|
|
661
612
|
removeSelectionDismiss = undefined;
|
|
662
613
|
removeOverlayScroll?.();
|
|
@@ -677,13 +628,14 @@ export default function (pi: ExtensionAPI) {
|
|
|
677
628
|
pendingPrompt = undefined;
|
|
678
629
|
restoreRequest = undefined;
|
|
679
630
|
sessionTitlePending = false;
|
|
680
|
-
|
|
631
|
+
promptDisplayHost.dispose();
|
|
681
632
|
});
|
|
682
633
|
|
|
683
634
|
pi.on("session_start", async (_event, ctx) => {
|
|
635
|
+
stickyDefaults.activate(ctx.sessionManager);
|
|
684
636
|
// Session Fast never survives into a new or restored session.
|
|
685
637
|
fastOverlay.resetSession();
|
|
686
|
-
|
|
638
|
+
promptDisplayHost.activate(ctx.sessionManager);
|
|
687
639
|
sessionTitlePending =
|
|
688
640
|
!pi.getSessionName?.() &&
|
|
689
641
|
!ctx.sessionManager
|
|
@@ -724,9 +676,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
724
676
|
ctx.ui.setEditorText(promptText);
|
|
725
677
|
return undefined;
|
|
726
678
|
});
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
679
|
+
if (!autocompleteInstalled) {
|
|
680
|
+
autocompleteInstalled = true;
|
|
681
|
+
ctx.ui.addAutocompleteProvider?.((current) =>
|
|
682
|
+
sortModelAutocompleteDescending(current, () => pi.getThinkingLevel?.()),
|
|
683
|
+
);
|
|
684
|
+
}
|
|
730
685
|
|
|
731
686
|
const store = storePath(getAgentDir(), ctx.cwd);
|
|
732
687
|
compactIfNeeded(store);
|
|
@@ -760,14 +715,16 @@ export default function (pi: ExtensionAPI) {
|
|
|
760
715
|
// with extensions that provide their own editor.
|
|
761
716
|
const base = resolveBase(ctx.ui.getEditorComponent());
|
|
762
717
|
const factory: TaggedFactory = (tui, theme, keybindings) => {
|
|
763
|
-
|
|
718
|
+
removeKeybindings?.();
|
|
719
|
+
removeKeybindings = installBaseKeybindings(keybindings);
|
|
764
720
|
const editor =
|
|
765
721
|
base?.(tui, theme, keybindings) ??
|
|
766
722
|
new CustomEditor(tui, theme, keybindings);
|
|
767
723
|
activeEditor = editor as PromptEditor;
|
|
768
724
|
activeTui = tui;
|
|
769
725
|
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Wheel scroll rate]]
|
|
770
|
-
|
|
726
|
+
removeWheelScroll?.();
|
|
727
|
+
removeWheelScroll = installWheelScrollLines(tui);
|
|
771
728
|
// @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Settled transcript]]
|
|
772
729
|
transcriptCleanup?.uninstall();
|
|
773
730
|
transcriptCleanup = installTranscriptCleanup(tui, ctx);
|
|
@@ -776,6 +733,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
776
733
|
removeWidgetTranscript = installWidgetTranscript(tui, editor);
|
|
777
734
|
removeSmartSelection?.();
|
|
778
735
|
removeSmartSelection = installSmartSelection(tui);
|
|
736
|
+
removeClipboardSelection?.();
|
|
737
|
+
removeClipboardSelection = installClipboardSelection(tui);
|
|
779
738
|
removeSelectionDismiss?.();
|
|
780
739
|
// The copy action reads the active selection after this listener runs,
|
|
781
740
|
// so its keystroke must not dismiss the selection it is about to copy.
|
|
@@ -853,9 +812,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
853
812
|
);
|
|
854
813
|
installAutocompleteDetails(editor, tui, theme);
|
|
855
814
|
removeFooterColors?.();
|
|
815
|
+
fastOverlay.stopDisplayRefresh();
|
|
856
816
|
removeFooterColors = installFooterColors(tui, ctx, () =>
|
|
857
|
-
fastOverlay.
|
|
817
|
+
fastOverlay.isEffectiveForDisplay(ctx.model ?? undefined),
|
|
858
818
|
);
|
|
819
|
+
if (removeFooterColors) {
|
|
820
|
+
fastOverlay.startDisplayRefresh(() => tui.requestRender());
|
|
821
|
+
}
|
|
859
822
|
for (const prompt of seeded) historyGuard?.add(prompt);
|
|
860
823
|
return editor;
|
|
861
824
|
};
|
|
@@ -863,4 +826,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
863
826
|
|
|
864
827
|
ctx.ui.setEditorComponent(factory);
|
|
865
828
|
});
|
|
829
|
+
// Base setup and cleanup must register before the updater's lifecycle hooks.
|
|
830
|
+
registerAutoUpdates(pi);
|
|
866
831
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "proper-base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Baseline Pi behavior for session naming, history, prompt editing, fullscreen navigation, and footer styling",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"index.ts",
|
|
38
38
|
"src",
|
|
39
39
|
"README.md",
|
|
40
|
+
"UPDATES.md",
|
|
40
41
|
"LICENSE"
|
|
41
42
|
],
|
|
42
43
|
"scripts": {
|
|
@@ -53,8 +54,8 @@
|
|
|
53
54
|
"@earendil-works/pi-tui": "*"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
|
-
"@earendil-works/pi-coding-agent": "
|
|
57
|
-
"@earendil-works/pi-tui": "
|
|
57
|
+
"@earendil-works/pi-coding-agent": "latest",
|
|
58
|
+
"@earendil-works/pi-tui": "latest",
|
|
58
59
|
"@types/node": "25.9.5",
|
|
59
60
|
"typescript": "6.0.2"
|
|
60
61
|
},
|