pi-jarvis 1.4.0 → 1.6.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/AGENTS.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Project Scope
4
4
  - `pi-jarvis` is a Pi extension that opens a `/jarvis` side-conversation overlay.
5
- - Core runtime files: `index.ts`, `side-session.ts`, `overlay.ts`, `model-picker.ts`, `jarvis-config.ts`, `session-ref.ts`.
5
+ - Core runtime files: `index.ts`, `side-session.ts`, `native-mcp.ts`, `overlay.ts`, `overlay-layout.ts`, `draft-editor.ts`, `transcript-viewport.ts`, `model-picker.ts`, `jarvis-config.ts`, `session-ref.ts`.
6
6
  - Current baseline: Pi 1.0.0 (`@earendil-works` packages), Node.js >=22.19.0. Older Pi hosts are not supported.
7
7
 
8
8
  ## Current `/jarvis-model` and `/jarvis-thinking` Behavior
@@ -20,16 +20,40 @@
20
20
  - `follow-main` thinking follows the main thinking level regardless of model selection, except xAI `/jarvis` models force thinking `off`.
21
21
  - `/compact`, `/tree`, and `/new` entered inside `/jarvis` operate on the isolated `/jarvis` side-session, not the main Pi session.
22
22
  - `Note main` and `Redirect` stay disabled when the active `/jarvis` model is incompatible with bridge tools.
23
- - Published package keeps Pi runtime packages as optional peers, not bundled dependencies. MCP adapter auto-loading is disabled: the published adapter does not declare Pi 1.0 support; native MCP is not enabled. Repo tools expose only read/bash/edit/write.
23
+ - Published packages keep Pi runtime packages as optional peers, not bundled dependencies. Never load the legacy MCP adapter. Version 1.6.0 adds native MCP to Repo tools opt-in alongside read/bash/edit/write.
24
24
  - Physical models delegate to the host's public registry for auth and dispatch. Virtual/router models explicitly reject; do not access the registry's private backing runtime.
25
25
  - Side resources/settings honor `ctx.isProjectTrusted()`. Local tool execution and bridge delivery recheck live permissions; closing the overlay revokes them and cancels pending confirmations.
26
26
  - Use `agent_settled`, not `agent_end`, for final idle state. Main context must honor Pi context-edit/compaction projection.
27
27
  - Runtime disposal must not detach the overlay's bridge subscription. Queue ownership must survive side `/new` but not main-session replacement; failed/uncertain sends are not auto-retried.
28
28
 
29
+ ## Overlay UX (1.5.0)
30
+ - Compact header by default; Ctrl+O expands diagnostics, PageUp/PageDown scroll transcript, Ctrl+End follows live, Ctrl+L dismisses notices.
31
+ - Use Pi's public multiline Editor. Enter sends; Shift+Enter/Ctrl+J inserts newline. Preserve indentation and reject unsafe/oversized drafts (64 KiB) explicitly.
32
+ - Bridge-owned in-memory drafts survive close/reopen. Bridge reset clears draft/recall on side `/new` or main/side-reference replacement; side-tree navigation only resets scroll.
33
+ - Consume bracketed paste before global shortcuts and confirmation keys; pasted content must not toggle permissions or approve a redirect.
34
+ - Queue count excludes active work; processing includes boot and complete queue settlement. Keep activity separate from scrollback and never replay uncertain sends.
35
+ - Bound overlay history (500 entries, 512K UTF-16 units total, 64K per entry) with explicit omission notices; never truncate persisted history.
36
+
37
+ ## Native MCP (1.6.0)
38
+ - Use Pi's root-exported native factories, not private registry/runtime/transport internals. Jarvis owns separate configured-server connections; main-only extension registrations are not inherited.
39
+ - No native startup/credential expansion while initially off. Respect project trust, enabled states, native tool exposures, and live Repo tools permission for direct/deferred/codemode/resource execution.
40
+ - Revocation invalidates permission generations, hides owned tools, aborts calls and invokes owned native shutdown. Stale prepared tools and late registrations cannot regain access after re-enable.
41
+ - Pi cancellation is best effort: already-started handshake/authentication/remote work may finish or time out after shutdown is requested. Do not promise immediate child teardown, rollback, or sandboxing.
42
+ - Keep server administration in main Pi. Disable codemode model helpers (`models: false`); preserve independent Note main/Redirect gates and the overlay-owned bridge subscription.
43
+ - Tests use temporary agent/workspace directories and local fixture servers only; never start real user MCP servers or resolve real credentials during validation.
44
+
45
+ ## Git and Release Policy
46
+ - Every new commit MUST have an annotated **stable version tag `vX.Y.Z`**. No `dev`, alpha, beta, release-candidate, build-metadata, or SHA-only tags. This is a released extension, not a prerelease channel.
47
+ - Before committing, choose the next unused stable version and update package metadata, lockfile, README, and a dated changelog entry together. Tag every commit, including intermediate and merge commits; never leave a new commit untagged. Run `npm run check:tags`, then push the commit and version tag atomically. Do not move or replace existing tags or rewrite shared history.
48
+ - Prefer fast-forwarding the exact validated commits to `main`; a new merge commit also requires its own version bump and tag. Every pushed `vX.Y.Z` tag triggers validated GitHub release packaging; npm publication remains manual.
49
+ - Stable-only CI enforcement starts after historical baseline `4b6b4e6`, preserving already-pushed history. Branch/PR jobs validate on Node 22.19.0 and 24 and reject missing, lightweight, prerelease, or SHA-only version coverage. Each new tag must match that commit's package metadata, lockfile, README, and changelog.
50
+ - Existing release assets must not be overwritten with differing bytes. See `RELEASING.md` for branch/tag protection and merge/fork constraints; CI alone cannot prevent administrator bypass.
51
+
29
52
  ## Validation
30
53
  - Run `npm test` for full validation.
31
54
  - Run `npm run build` before release packaging.
32
55
  - Run `npm run verify:release` to validate npm pack payload and release metadata expectations.
56
+ - Run `npm run check:tags` after tagging commits to validate annotated-tag policy.
33
57
 
34
58
  ## Docs To Keep In Sync
35
59
  - `README.md`
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  [![Pi extension](https://img.shields.io/badge/Pi-extension-06b6d4?style=for-the-badge)](https://github.com/crustyhacker/pi-jarvis)
14
14
  [![TypeScript](https://img.shields.io/badge/TypeScript-powered-2563eb?style=for-the-badge)](./package.json)
15
15
 
16
- <p><strong>Current version:</strong> 1.4.0</p>
16
+ <p><strong>Current version:</strong> 1.6.0</p>
17
17
 
18
18
  <p>
19
19
  <strong>Persistent side session</strong> ·
@@ -60,7 +60,7 @@ The main Pi session should stay on the critical path.
60
60
  | **Permission-gated tools** | Local `read`, `bash`, `edit`, and `write` stay off until you enable them |
61
61
  | **Safe main-session handoff** | `Note main` is quiet; `Redirect` is confirmation-gated |
62
62
  | **Independent model control** | Follow the main model or pin `/jarvis` to a separate model |
63
- | **Cleaner UX** | Thinking-step streaming is collapsed into a cleaner animated fallback |
63
+ | **Cleaner UX** | Compact header, scrollable history, multiline drafts, and independent activity/queue feedback |
64
64
 
65
65
  ---
66
66
 
@@ -120,7 +120,7 @@ pi install npm:pi-jarvis
120
120
 
121
121
  This package is meant to run **inside a Pi installation** that already provides the Pi runtime packages. Those host packages are declared as optional peers so npm does not install a second copy of the full Pi/AI provider stack just to add this extension.
122
122
 
123
- Requires **Pi 1.0.0** and **Node.js 22.19.0 or newer**. This release supports local repository tools only: automatic `pi-mcp-adapter` loading is disabled because the published adapter does not declare Pi 1.0 support. Native MCP integration is not yet enabled; the overlay reports MCP as unavailable.
123
+ Requires **Pi 1.0.0** and **Node.js 22.19.0 or newer**. Version **1.6.0** supports local repository tools and opt-in native Pi MCP as described below; it does not load the legacy `pi-mcp-adapter` or bundle another Pi runtime.
124
124
 
125
125
  ### 2) Restart or reload Pi
126
126
 
@@ -218,7 +218,7 @@ The overlay header exposes three controls, all **off by default**:
218
218
 
219
219
  | Control | What it does | Safety model |
220
220
  |---|---|---|
221
- | `Repo tools` | Enables local `read`, `bash`, `edit`, and `write` | Explicit opt-in |
221
+ | `Repo tools` | Enables local `read`, `bash`, `edit`, and `write`, plus configured native MCP | Explicit opt-in |
222
222
  | `Note main` | Sends a concise, non-interrupting note to the main session | Explicit opt-in |
223
223
  | `Redirect` | Sends a redirecting instruction to the main session | Explicit opt-in + per-send confirmation |
224
224
 
@@ -226,6 +226,30 @@ The overlay header exposes three controls, all **off by default**:
226
226
 
227
227
  Long redirects are paged: review every page with Up/Down or PageUp/PageDown before pressing Y. Resize if the terminal is too small to review safely. Configured Pi selection keybindings are respected.
228
228
 
229
+ ### Keyboard and drafts
230
+
231
+ Version **1.5.0** adds compact diagnostics, scrollback, and a multiline draft editor.
232
+
233
+ | Key | Action |
234
+ |---|---|
235
+ | Enter | Send the draft; toggle a focused permission control |
236
+ | Shift+Enter / Ctrl+J | Insert a newline |
237
+ | Tab / Shift+Tab | Cycle between the editor and permission controls |
238
+ | Space | Toggle a focused permission control |
239
+ | PageUp / PageDown | Scroll conversation history; reaching the bottom resumes live following |
240
+ | Ctrl+End | Jump back to live output |
241
+ | Ctrl+O | Expand/collapse model, main-context delta, and access details |
242
+ | Ctrl+L | Dismiss notices |
243
+ | Escape | Close; during redirect review, cancel the confirmation instead |
244
+
245
+ The compact header keeps main status, the side model, main focus, and permissions visible. Activity and waiting-message counts remain visible while reading older output; counts exclude the active request. The latest notice appears separately; expand details for more of a long notice.
246
+
247
+ The multiline editor uses Pi's public editor and configured editing keybindings. Up/Down move within a draft; Up at the beginning of the first line (or in an empty editor) recalls prompts. Down past recalled prompts restores the draft. Pasted indentation and newlines are preserved, with Pi's normal tab-to-spaces normalization. Oversized drafts (over 64 KiB) and terminal-control payloads are rejected explicitly, never silently truncated or sent.
248
+
249
+ Unsent drafts survive closing and reopening `/jarvis` in the same running Pi session. They are not saved to disk. Side `/new`, main-session replacement, and switching to an unrelated side-session reference clear them; navigating the side tree only resets the transcript view. Closing still revokes every permission.
250
+
251
+ Scrollback follows new output until you scroll up. To bound rendering work, the overlay retains up to 500 recent entries and 512K UTF-16 code units of source text, with a 64K-unit per-entry limit. Omitted content is marked explicitly; these display limits do not modify persisted conversation history. Resizing preserves the reading position on a best-effort basis.
252
+
229
253
  ### Permission flow
230
254
 
231
255
  ```mermaid
@@ -235,7 +259,7 @@ flowchart TD
235
259
  A --> D[Redirect off]
236
260
 
237
261
  B -->|enable| E[Jarvis may use local tools]
238
- E --> H[MCP unavailable in this release]
262
+ E --> H[Configured native MCP]
239
263
 
240
264
  C -->|enable| I[Jarvis may send a quiet note to main]
241
265
  D -->|enable| J[Jarvis may request redirect sends]
@@ -321,7 +345,18 @@ This repository's validation baseline is **Pi 1.0.0**, using host-provided `@ear
321
345
 
322
346
  Physical models use the main host's public model registry for requests and credentials, including custom providers and runtime-only authentication. **Virtual/router models are not supported**: Pi's public extension registry does not expose session-aware virtual routing. Pin `/jarvis-model <provider/physical-model>` if the main session uses a virtual model.
323
347
 
324
- MCP is deliberately unavailable in this release. A future native integration needs execution-time permission checks for direct, deferred, and nested tool calls; installing the old adapter does not enable it.
348
+ ### Native MCP
349
+
350
+ Pi already provides MCP; Jarvis 1.6.0 opts its separate SDK session into Pi's native factories when Repo tools is enabled.
351
+
352
+ - **Repo tools is the opt-in for both local tools and native MCP.** While initially off, Jarvis does not start MCP connections or expand MCP configuration credentials/commands.
353
+ - Enabling it starts **separate, side-owned connections** to configured servers from the active agent directory's `mcp.json` and, only when trusted, the project's `.pi/mcp.json`. Main-session connections are neither reused nor disconnected. Servers registered only by main-session extensions are not automatically inherited.
354
+ - Native direct, deferred/tool-search, codemode, and resource tools keep Pi's configured exposure. Jarvis rechecks live permission and session lifetime for calls, including nested calls and previously prepared tool references. Server annotations are hints, not permission grants.
355
+ - Disabling Repo tools, closing the overlay, or disposing the side runtime invalidates that permission generation, hides its tools, aborts owned call signals, and requests native disconnection. Re-enabling creates a fresh generation rather than reviving stale calls.
356
+ - **Cancellation is best effort, not rollback or a sandbox.** Pi may allow already-started connection handshakes, authentication refresh/cleanup, or remote operations to finish or time out after revocation. A pending native handshake may outlive the shutdown request until Pi finishes or times it out.
357
+ - Manage servers and OAuth sign-in in **main Pi** (`/mcp` or `pi mcp ...`), not through a side-session administration command. Jarvis does not register a side `/mcp` manager. Codemode's classifier/image-model helpers are disabled in the side session.
358
+
359
+ Use narrowly scoped credentials and trust your configured servers. Enabling Repo tools permits the configured MCP capabilities; it is not a read-only grant.
325
360
 
326
361
  ---
327
362
 
@@ -357,6 +392,20 @@ Preview and verify the npm payload contract:
357
392
  npm run verify:release
358
393
  ```
359
394
 
395
+ Check the mandatory annotated **version-number** tag policy for committed history:
396
+
397
+ ```bash
398
+ npm run check:tags
399
+ ```
400
+
401
+ ### Release automation
402
+
403
+ GitHub Actions validate branch pushes and pull requests on Node 22.19.0 and 24. They require an annotated **stable `vX.Y.Z` tag** on every reachable post-policy-baseline commit and run tests, build, and package verification. Every commit bumps the matching package and documentation versions; prerelease (`dev`, alpha, beta, RC), build-metadata, and SHA-only tags do not qualify. Fork PR jobs are read-only.
404
+
405
+ A matching annotated **`vX.Y.Z`** tag runs exact-tag validation and creates a GitHub release with the validated npm tarball. **npm publication stays manual**; no npm publishing token is configured. Existing assets are verified, never overwritten with different bytes.
406
+
407
+ CI reports violations; protected-branch/tag rules must be configured separately for enforcement. See [RELEASING.md](https://github.com/crustyhacker/pi-jarvis/blob/main/RELEASING.md) for atomic tagged pushes, fork/merge handling, reruns, and manual npm publication.
408
+
360
409
  ---
361
410
 
362
411
  ## License
@@ -0,0 +1,53 @@
1
+ import type { Theme } from "@earendil-works/pi-coding-agent";
2
+ import { type Focusable, type TUI } from "@earendil-works/pi-tui";
3
+ export declare const MAX_DRAFT_BYTES: number;
4
+ export interface JarvisDraftEditorCallbacks {
5
+ onSubmit: (text: string) => void;
6
+ onChange: (text: string) => void;
7
+ /** Without a handler, rejected text raises an explicit error instead. */
8
+ onError?: (message: string) => void;
9
+ }
10
+ /** A content-only, bounded viewport around Pi's public multiline Editor. */
11
+ export declare class JarvisDraftEditor implements Focusable {
12
+ private readonly tui;
13
+ private readonly callbacks;
14
+ private readonly editor;
15
+ private disposed;
16
+ private submitted;
17
+ private inPaste;
18
+ private pasteBuffer;
19
+ private pasteTail;
20
+ private pasteRejected;
21
+ private pasteDiscard;
22
+ private startTail;
23
+ constructor(tui: TUI, theme: Theme, callbacks: JarvisDraftEditorCallbacks, initialText?: string);
24
+ get focused(): boolean;
25
+ set focused(value: boolean);
26
+ /** Includes all pasted text, never a display-only paste placeholder. */
27
+ getText(): string;
28
+ /** Silent programmatic replacement/restore; does not publish onChange. */
29
+ setText(text: string): void;
30
+ addToHistory(text: string): void;
31
+ /**
32
+ * Route this BEFORE confirmation/global shortcuts. Returns true when the
33
+ * entire packet was consumed as paste framing/content, never as keys.
34
+ * Discard is sticky through the paste, even if confirmation later closes.
35
+ */
36
+ handlePasteInput(data: string, discard?: boolean): boolean;
37
+ /** Carry only framing across a thread reset, discarding all old paste text. */
38
+ inheritPasteDrain(previous: JarvisDraftEditor): void;
39
+ handleInput(data: string): void;
40
+ /** Crops around the public cursor marker, including one-cell viewports. */
41
+ render(width: number, maxLines: number): string[];
42
+ invalidate(): void;
43
+ dispose(): void;
44
+ private error;
45
+ private acceptText;
46
+ private textError;
47
+ private appendPaste;
48
+ private resetPaste;
49
+ private insertText;
50
+ private dispatch;
51
+ private publishChange;
52
+ }
53
+ //# sourceMappingURL=draft-editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draft-editor.d.ts","sourceRoot":"","sources":["../draft-editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAEwC,KAAK,SAAS,EAAmB,KAAK,GAAG,EACvF,MAAM,wBAAwB,CAAC;AAEhC,eAAO,MAAM,eAAe,QAAY,CAAC;AAEzC,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,yEAAyE;IACzE,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AA2BD,4EAA4E;AAC5E,qBAAa,iBAAkB,YAAW,SAAS;IAYjD,OAAO,CAAC,QAAQ,CAAC,GAAG;IAEpB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAb3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAM;IACzB,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,SAAS,CAAM;gBAGL,GAAG,EAAE,GAAG,EACzB,KAAK,EAAE,KAAK,EACK,SAAS,EAAE,0BAA0B,EACtD,WAAW,SAAK;IAkBjB,IAAI,OAAO,IAAI,OAAO,CAAgC;IACtD,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAAoD;IAE9E,wEAAwE;IACxE,OAAO,IAAI,MAAM;IAEjB,0EAA0E;IAC1E,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAO3B,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAahC;;;;OAIG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,OAAO;IA2CxD,+EAA+E;IAC/E,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAQpD,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK/B,2EAA2E;IAC3E,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IA+BjD,UAAU,IAAI,IAAI;IAMlB,OAAO,IAAI,IAAI;IAQf,OAAO,CAAC,KAAK;IAMb,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,SAAS;IAYjB,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,QAAQ;IA2ChB,OAAO,CAAC,aAAa;CAKrB"}
@@ -0,0 +1,303 @@
1
+ import { CURSOR_MARKER, Editor, decodeKittyPrintable, getKeybindings, isKeyRelease, matchesKey, parseKey, sliceByColumn, truncateToWidth, visibleWidth, } from "@earendil-works/pi-tui";
2
+ export const MAX_DRAFT_BYTES = 64 * 1024;
3
+ const PASTE_START = "\x1b[200~";
4
+ const PASTE_END = "\x1b[201~";
5
+ const EDITOR_ACTIONS = [
6
+ "tui.editor.cursorUp", "tui.editor.cursorDown", "tui.editor.historyPrevious", "tui.editor.historyNext",
7
+ "tui.editor.cursorLeft", "tui.editor.cursorRight", "tui.editor.cursorWordLeft", "tui.editor.cursorWordRight",
8
+ "tui.editor.cursorLineStart", "tui.editor.cursorLineEnd", "tui.editor.jumpForward", "tui.editor.jumpBackward",
9
+ "tui.editor.pageUp", "tui.editor.pageDown", "tui.editor.deleteCharBackward", "tui.editor.deleteCharForward",
10
+ "tui.editor.deleteWordBackward", "tui.editor.deleteWordForward", "tui.editor.deleteToLineStart",
11
+ "tui.editor.deleteToLineEnd", "tui.editor.yank", "tui.editor.yankPop", "tui.editor.undo",
12
+ "tui.input.newLine", "tui.input.submit", "tui.input.tab", "tui.input.copy",
13
+ ];
14
+ // Only used for the size preflight. Actual normalization belongs to Pi's public
15
+ // setText/insertTextAtCursor APIs (CRLF/CR -> LF, tabs -> four spaces).
16
+ function normalizedBytes(text) {
17
+ return Buffer.byteLength(text.replace(/\r\n?/g, "\n").replace(/\t/g, " "), "utf8");
18
+ }
19
+ function delimiterTail(text, delimiter) {
20
+ for (let size = Math.min(text.length, delimiter.length - 1); size > 0; size--) {
21
+ if (text.endsWith(delimiter.slice(0, size)))
22
+ return size;
23
+ }
24
+ return 0;
25
+ }
26
+ /** A content-only, bounded viewport around Pi's public multiline Editor. */
27
+ export class JarvisDraftEditor {
28
+ tui;
29
+ callbacks;
30
+ editor;
31
+ disposed = false;
32
+ submitted = false;
33
+ inPaste = false;
34
+ pasteBuffer = "";
35
+ pasteTail = "";
36
+ pasteRejected = false;
37
+ pasteDiscard = false;
38
+ startTail = "";
39
+ constructor(tui, theme, callbacks, initialText = "") {
40
+ this.tui = tui;
41
+ this.callbacks = callbacks;
42
+ this.editor = new Editor(tui, {
43
+ borderColor: (text) => theme.fg("borderMuted", text),
44
+ selectList: {
45
+ selectedPrefix: (text) => theme.fg("accent", text),
46
+ selectedText: (text) => theme.fg("accent", text),
47
+ description: (text) => theme.fg("muted", text),
48
+ scrollInfo: (text) => theme.fg("dim", text),
49
+ noMatch: (text) => theme.fg("muted", text),
50
+ },
51
+ }, { paddingX: 0 });
52
+ // Pi submits a trimmed value. Capture the full pre-submit draft in
53
+ // dispatch instead; let Pi still own clearing and its undo lifecycle.
54
+ this.editor.onSubmit = () => { this.submitted = true; };
55
+ this.setText(initialText);
56
+ }
57
+ get focused() { return this.editor.focused; }
58
+ set focused(value) { this.editor.focused = !this.disposed && value; }
59
+ /** Includes all pasted text, never a display-only paste placeholder. */
60
+ getText() { return this.editor.getExpandedText(); }
61
+ /** Silent programmatic replacement/restore; does not publish onChange. */
62
+ setText(text) {
63
+ if (this.disposed || !this.acceptText(text))
64
+ return;
65
+ this.resetPaste();
66
+ this.editor.setText(text);
67
+ this.invalidate();
68
+ }
69
+ addToHistory(text) {
70
+ if (this.disposed || !this.acceptText(text))
71
+ return;
72
+ // addToHistory itself does not normalize line endings/tabs. Normalize
73
+ // through a temporary public Editor without changing this draft/cursor.
74
+ const normalizer = new Editor(this.tui, {
75
+ borderColor: (value) => value,
76
+ selectList: { selectedPrefix: (v) => v, selectedText: (v) => v, description: (v) => v,
77
+ scrollInfo: (v) => v, noMatch: (v) => v },
78
+ });
79
+ normalizer.setText(text);
80
+ this.editor.addToHistory(normalizer.getExpandedText());
81
+ }
82
+ /**
83
+ * Route this BEFORE confirmation/global shortcuts. Returns true when the
84
+ * entire packet was consumed as paste framing/content, never as keys.
85
+ * Discard is sticky through the paste, even if confirmation later closes.
86
+ */
87
+ handlePasteInput(data, discard = false) {
88
+ if (this.disposed || !data)
89
+ return false;
90
+ if (!this.inPaste) {
91
+ const pendingStart = Boolean(this.startTail);
92
+ const packet = this.startTail + data;
93
+ const start = packet.indexOf(PASTE_START);
94
+ const tail = delimiterTail(packet, PASTE_START);
95
+ // A lone Escape remains an ordinary close/cancel key outside paste.
96
+ if (start < 0 && !pendingStart && tail <= 1)
97
+ return false;
98
+ this.pasteDiscard ||= discard;
99
+ this.startTail = "";
100
+ if (start < 0) {
101
+ if (tail > 1)
102
+ this.startTail = packet.slice(packet.length - tail);
103
+ else
104
+ this.resetPaste(); // Consume, don't replay a malformed opener.
105
+ return true;
106
+ }
107
+ this.inPaste = true;
108
+ // No ambiguous keyboard prefix in a framing packet gets replayed.
109
+ data = packet.slice(start + PASTE_START.length);
110
+ }
111
+ else {
112
+ this.pasteDiscard ||= discard;
113
+ }
114
+ if (this.pasteDiscard)
115
+ this.pasteBuffer = "";
116
+ const packet = this.pasteTail + data;
117
+ this.pasteTail = "";
118
+ const end = packet.indexOf(PASTE_END);
119
+ if (end < 0) {
120
+ const tail = delimiterTail(packet, PASTE_END);
121
+ this.pasteTail = packet.slice(packet.length - tail);
122
+ if (!this.pasteDiscard)
123
+ this.appendPaste(packet.slice(0, packet.length - tail));
124
+ return true;
125
+ }
126
+ if (!this.pasteDiscard)
127
+ this.appendPaste(packet.slice(0, end));
128
+ const paste = this.pasteBuffer;
129
+ const rejected = this.pasteRejected || this.pasteDiscard;
130
+ this.resetPaste();
131
+ // Public insertion avoids Pi marker-ID collisions with literal markers,
132
+ // stale history, and recursively expanded IDs. Anything attached AFTER
133
+ // the terminator is dropped, including Enter or confirmation shortcuts.
134
+ if (!rejected)
135
+ this.insertText(paste);
136
+ return true;
137
+ }
138
+ /** Carry only framing across a thread reset, discarding all old paste text. */
139
+ inheritPasteDrain(previous) {
140
+ this.resetPaste();
141
+ this.inPaste = previous.inPaste;
142
+ this.startTail = previous.startTail;
143
+ this.pasteTail = previous.pasteTail;
144
+ this.pasteDiscard = this.inPaste || Boolean(this.startTail);
145
+ }
146
+ handleInput(data) {
147
+ if (this.disposed || !data || this.handlePasteInput(data))
148
+ return;
149
+ this.dispatch(data);
150
+ }
151
+ /** Crops around the public cursor marker, including one-cell viewports. */
152
+ render(width, maxLines) {
153
+ width = Number.isFinite(width) ? Math.max(0, Math.floor(width)) : 0;
154
+ maxLines = Number.isFinite(maxLines) ? Math.max(0, Math.floor(maxLines)) : 0;
155
+ if (this.disposed || !width || !maxLines)
156
+ return [];
157
+ const focused = this.focused;
158
+ let lines;
159
+ // Obtain cursor geometry even while unfocused, then remove the marker.
160
+ // Width >=3 avoids Pi's one-column wide-grapheme wrapping edge case.
161
+ this.editor.focused = true;
162
+ try {
163
+ lines = this.editor.render(Math.max(3, width)).slice(1, -1);
164
+ }
165
+ finally {
166
+ this.editor.focused = focused;
167
+ }
168
+ const cursor = Math.max(0, lines.findIndex((line) => line.includes(CURSOR_MARKER)));
169
+ const start = Math.max(0, Math.min(cursor - Math.floor(maxLines / 2), lines.length - maxLines));
170
+ return lines.slice(start, start + maxLines).map((line) => {
171
+ const marker = line.indexOf(CURSOR_MARKER);
172
+ if (visibleWidth(line) > width && marker >= 0) {
173
+ const before = line.slice(0, marker);
174
+ const beforeWidth = visibleWidth(before);
175
+ const prefix = sliceByColumn(before, Math.max(0, beforeWidth - width + 1), width - 1, true);
176
+ let suffix = sliceByColumn(line.slice(marker + CURSOR_MARKER.length), 0, width - visibleWidth(prefix), true);
177
+ // A wide cursor grapheme cannot fit in one cell; retain a visible
178
+ // cursor cell rather than dropping either the cursor or its marker.
179
+ if (!visibleWidth(suffix))
180
+ suffix = "\x1b[7m \x1b[0m";
181
+ line = prefix + CURSOR_MARKER + suffix;
182
+ }
183
+ else {
184
+ line = truncateToWidth(line, width, "");
185
+ }
186
+ return focused ? line : line.replaceAll(CURSOR_MARKER, "");
187
+ });
188
+ }
189
+ invalidate() {
190
+ if (this.disposed)
191
+ return;
192
+ this.editor.invalidate();
193
+ this.tui.requestRender();
194
+ }
195
+ dispose() {
196
+ if (this.disposed)
197
+ return;
198
+ this.focused = false;
199
+ this.disposed = true;
200
+ this.resetPaste();
201
+ this.editor.onSubmit = undefined;
202
+ }
203
+ error(message) {
204
+ if (this.callbacks.onError)
205
+ this.callbacks.onError(message);
206
+ else
207
+ throw new Error(message);
208
+ return false;
209
+ }
210
+ acceptText(text, existingBytes = 0) {
211
+ const rejection = this.textError(text, existingBytes);
212
+ return rejection ? this.error(rejection) : true;
213
+ }
214
+ textError(text, existingBytes = 0) {
215
+ // Reject complete text operations instead of leaking printable tails of
216
+ // ANSI/OSC/APC sequences. LF/CR/tabs are data and Pi normalizes them.
217
+ if (/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/.test(text)) {
218
+ return "Draft rejected: terminal control characters are not allowed.";
219
+ }
220
+ if (existingBytes + normalizedBytes(text) > MAX_DRAFT_BYTES) {
221
+ return "Draft rejected: maximum size is 64 KiB. Nothing was truncated or sent.";
222
+ }
223
+ return undefined;
224
+ }
225
+ appendPaste(text) {
226
+ if (this.pasteRejected)
227
+ return;
228
+ this.pasteBuffer += text;
229
+ if (normalizedBytes(this.pasteBuffer) + Buffer.byteLength(this.getText(), "utf8") > MAX_DRAFT_BYTES) {
230
+ this.pasteRejected = true;
231
+ this.pasteBuffer = "";
232
+ this.error("Paste rejected: draft maximum size is 64 KiB. Nothing was truncated or sent.");
233
+ }
234
+ }
235
+ resetPaste() {
236
+ this.inPaste = false;
237
+ this.pasteBuffer = this.pasteTail = this.startTail = "";
238
+ this.pasteRejected = this.pasteDiscard = false;
239
+ }
240
+ insertText(text) {
241
+ const before = this.getText();
242
+ if (!this.acceptText(text, Buffer.byteLength(before, "utf8")))
243
+ return false;
244
+ this.editor.insertTextAtCursor(text);
245
+ this.publishChange(before);
246
+ return true;
247
+ }
248
+ dispatch(data) {
249
+ if (isKeyRelease(data))
250
+ return;
251
+ const kb = getKeybindings();
252
+ const action = EDITOR_ACTIONS.some((id) => kb.matches(data, id));
253
+ const legacyNewline = data === "\x1b\r" || data === "\x1b[13;2~";
254
+ const extraEditingKey = matchesKey(data, "shift+backspace") || matchesKey(data, "shift+delete");
255
+ const key = parseKey(data);
256
+ // Pi exposes a Kitty printable decoder and a protocol-independent key
257
+ // parser. The latter also recognizes xterm modifyOtherKeys characters;
258
+ // use its identity only for preflight, leaving actual decoding to Pi.
259
+ const printable = decodeKittyPrintable(data) ?? (key === "space" || key === "shift+space" ? " " :
260
+ key?.length === 1 ? key : key?.startsWith("shift+") && key.length === 7 ? key.slice(-1) : undefined);
261
+ if (!action && !legacyNewline && !extraEditingKey && printable === undefined) {
262
+ // Unknown escape/control packets are not text. Bulk printable input,
263
+ // including unframed multiline text, uses Pi's normalized insertion.
264
+ if (data.startsWith("\x1b") || (data.length === 1 && data.charCodeAt(0) < 32))
265
+ return;
266
+ if (/[\r\n\t]/.test(data)) {
267
+ this.insertText(data);
268
+ return;
269
+ }
270
+ }
271
+ const before = this.getText();
272
+ if (printable !== undefined || (!action && !legacyNewline && !extraEditingKey)) {
273
+ if (!this.acceptText(printable ?? data, Buffer.byteLength(before, "utf8")))
274
+ return;
275
+ }
276
+ if ((kb.matches(data, "tui.input.newLine") || legacyNewline || data === "\n") &&
277
+ !this.acceptText("\n", Buffer.byteLength(before, "utf8")))
278
+ return;
279
+ this.submitted = false;
280
+ this.editor.handleInput(data);
281
+ const after = this.getText();
282
+ // Defensive guard for Pi actions such as yank/undo/history. All external
283
+ // text is already checked; reject any unexpected expanded oversize edit.
284
+ const rejection = this.textError(after);
285
+ if (rejection) {
286
+ this.editor.setText(before);
287
+ this.invalidate();
288
+ this.error(rejection);
289
+ return;
290
+ }
291
+ const submitted = this.submitted;
292
+ this.publishChange(before);
293
+ if (submitted && before.trim())
294
+ this.callbacks.onSubmit(before);
295
+ }
296
+ publishChange(before) {
297
+ const after = this.getText();
298
+ if (after !== before)
299
+ this.callbacks.onChange(after);
300
+ this.invalidate();
301
+ }
302
+ }
303
+ //# sourceMappingURL=draft-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draft-editor.js","sourceRoot":"","sources":["../draft-editor.ts"],"names":[],"mappings":"AACA,OAAO,EACN,aAAa,EAAE,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAC/F,aAAa,EAAE,eAAe,EAAE,YAAY,GAC5C,MAAM,wBAAwB,CAAC;AAEhC,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC;AASzC,MAAM,WAAW,GAAG,WAAW,CAAC;AAChC,MAAM,SAAS,GAAG,WAAW,CAAC;AAC9B,MAAM,cAAc,GAA0B;IAC7C,qBAAqB,EAAE,uBAAuB,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,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;IAEO,aAAa,CAAC,MAAc;QACnC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC7B,IAAI,KAAK,KAAK,MAAM;YAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrD,IAAI,CAAC,UAAU,EAAE,CAAC;IACnB,CAAC;CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,YAAY,EAGjB,MAAM,iCAAiC,CAAC;AAkGzC,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAqhB9D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,YAAY,EAGjB,MAAM,iCAAiC,CAAC;AAkGzC,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAwhB9D"}