pi-startup-redraw-fix 0.1.1 → 0.1.3

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +80 -66
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.3] - 2026-03-04
4
+
5
+ ### Fixed
6
+ - Use absolute GitHub raw URL for README image to fix npm display
7
+
8
+ ## [0.1.2] - 2026-03-04
9
+
10
+ ### Changed
11
+ - Rewrote README.md with professional documentation standards
12
+ - Added comprehensive feature documentation, configuration reference, and usage examples
13
+
3
14
  ## 0.1.1
4
15
 
5
16
  - Added `asset/` to the npm `files` whitelist so README image assets are included in package tarballs.
package/README.md CHANGED
@@ -1,63 +1,74 @@
1
1
  # pi-startup-redraw-fix
2
2
 
3
- Startup redraw / full-clear ordering fix for the Pi coding agent.
3
+ A Pi coding agent extension that patches terminal full-clear escape sequence ordering to prevent startup redraw glitches in certain terminal emulators.
4
4
 
5
- This extension patches the terminal “full clear” escape sequence emitted during startup so the screen/scrollback clear happens in a stable order, avoiding redraw glitches in some terminal setups.
5
+ ![Terminal startup fix demonstration](https://raw.githubusercontent.com/MasuRii/pi-startup-redraw-fix/main/asset/pi-startup-redraw-fix.png)
6
6
 
7
- ![alt text](asset/pi-startup-redraw-fix.png)
7
+ ## Table of Contents
8
+
9
+ - [Features](#features)
10
+ - [Installation](#installation)
11
+ - [Usage](#usage)
12
+ - [Configuration](#configuration)
13
+ - [Technical Details](#technical-details)
14
+ - [Troubleshooting](#troubleshooting)
15
+ - [Development](#development)
16
+ - [License](#license)
8
17
 
9
18
  ## Features
10
19
 
11
- - Normalizes the startup full-clear escape sequence order:
12
- - **From:** `\x1b[3J\x1b[2J\x1b[H`
13
- - **To:** `\x1b[H\x1b[2J\x1b[3J`
14
- - Applies the patch **once per Node process** by monkey-patching `ProcessTerminal.prototype.write`.
15
- - On `session_start`, shows a **UI warning** (when UI is available) if patching failed.
20
+ - **Escape Sequence Normalization** — Reorders the startup full-clear sequence from `\x1b[3J\x1b[2J\x1b[H` to `\x1b[H\x1b[2J\x1b[3J` for stable screen clearing
21
+ - **Idempotent Patching** — Applies the patch once per Node process via `ProcessTerminal.prototype.write` monkey-patching with internal flag guard
22
+ - **Failure Notifications** — Displays a UI warning on `session_start` if the patch failed to apply
16
23
 
17
24
  ## Installation
18
25
 
19
- ### Local extension folder
26
+ ### Extension Folder (Recommended)
20
27
 
21
- Place this folder in one of Pis auto-discovered extension locations:
28
+ Place the extension folder in one of Pi's auto-discovered extension locations:
22
29
 
23
- - Global: `~/.pi/agent/extensions/pi-startup-redraw-fix`
24
- - Project: `.pi/extensions/pi-startup-redraw-fix`
30
+ | Location | Path |
31
+ |----------|------|
32
+ | Global | `~/.pi/agent/extensions/pi-startup-redraw-fix` |
33
+ | Project | `.pi/extensions/pi-startup-redraw-fix` |
25
34
 
26
- If you keep it elsewhere, add the path to your Pi settings `extensions` array.
35
+ Alternatively, add the path to your Pi settings `extensions` array.
27
36
 
28
- ### As an npm package
37
+ ### npm Package
29
38
 
30
39
  ```bash
31
40
  pi install npm:pi-startup-redraw-fix
32
41
  ```
33
42
 
34
- Or from git:
43
+ ### Git Repository
35
44
 
36
45
  ```bash
37
46
  pi install git:github.com/MasuRii/pi-startup-redraw-fix
38
47
  ```
39
48
 
40
- (For development or non-Pi environments, `npm i pi-startup-redraw-fix` also works.)
41
-
42
49
  ## Usage
43
50
 
44
- This extension has **no commands**.
51
+ This extension operates automatically with **no commands required**.
45
52
 
46
- When the extension is loaded, it immediately attempts to patch `ProcessTerminal.prototype.write`. On each new session (`session_start`), if Pi has a UI and the patch did not apply, it emits a warning notification.
53
+ When loaded, the extension immediately patches `ProcessTerminal.prototype.write` to intercept and normalize terminal clear sequences. If the patch fails, a warning notification appears at each session start (when UI is available).
47
54
 
48
55
  ## Configuration
49
56
 
50
- ### Enable / disable
57
+ Configuration is stored at `config.json` alongside the extension:
51
58
 
52
- Runtime config is stored alongside the extension at:
59
+ ```
60
+ ~/.pi/agent/extensions/pi-startup-redraw-fix/config.json
61
+ ```
53
62
 
54
- - `~/.pi/agent/extensions/pi-startup-redraw-fix/config.json`
63
+ A template is provided at `config/config.example.json`.
55
64
 
56
- A starter template is included at:
65
+ ### Options
57
66
 
58
- - `config/config.example.json`
67
+ | Option | Type | Default | Description |
68
+ |--------|------|---------|-------------|
69
+ | `enabled` | boolean | `true` | Enable or disable the extension |
59
70
 
60
- Minimal config:
71
+ ### Example Configuration
61
72
 
62
73
  ```json
63
74
  {
@@ -65,74 +76,77 @@ Minimal config:
65
76
  }
66
77
  ```
67
78
 
68
- Notes:
79
+ > **Note:** If your Pi build does not honor the `enabled` flag, disable the extension by removing it from your Pi settings `extensions` list or uninstalling it.
69
80
 
70
- - In environments where Pi honors an extension-local `enabled` flag, set `"enabled": false` to disable the extension.
71
- - If your Pi build does not use `enabled` for extension loading, disable by removing the extension from your Pi settings `extensions` list (or by uninstalling it).
81
+ ## Technical Details
72
82
 
73
- ## How it works (high level)
83
+ ### How It Works
74
84
 
75
- Pis TUI uses `@mariozechner/pi-tui`’s `ProcessTerminal` to write escape sequences to the terminal.
85
+ Pi's TUI uses `@mariozechner/pi-tui`'s `ProcessTerminal` class to write escape sequences to the terminal. This extension wraps `ProcessTerminal.prototype.write` to normalize the clear sequence order:
76
86
 
77
- This extension:
87
+ | Original Sequence | Fixed Sequence |
88
+ |-------------------|----------------|
89
+ | `ESC[3J` (clear scrollback) | `ESC[H` (cursor home) |
90
+ | `ESC[2J` (clear screen) | `ESC[2J` (clear screen) |
91
+ | `ESC[H` (cursor home) | `ESC[3J` (clear scrollback) |
78
92
 
79
- 1. Wraps `ProcessTerminal.prototype.write`.
80
- 2. For each write, replaces any occurrence of the exact “broken” full-clear sequence:
81
- - `ESC [ 3 J` (clear scrollback)
82
- - `ESC [ 2 J` (clear screen)
83
- - `ESC [ H` (cursor home)
84
- 3. With the “fixed” order:
85
- - `ESC [ H` (cursor home)
86
- - `ESC [ 2 J` (clear screen)
87
- - `ESC [ 3 J` (clear scrollback)
93
+ The reordering ensures the cursor moves home before clearing, which resolves redraw glitches on certain terminal emulators.
88
94
 
89
- The patch is guarded by an internal flag so it is **idempotent** (loading the extension multiple times will not stack-wrap `write`).
95
+ ### Architecture
90
96
 
91
- ## Limitations / compatibility
97
+ | File | Purpose |
98
+ |------|---------|
99
+ | `index.ts` | Root entrypoint for Pi auto-discovery |
100
+ | `src/index.ts` | Extension bootstrap and session warning handler |
101
+ | `src/terminal-clear-patch.ts` | Monkey-patch implementation with idempotency guard |
102
+ | `src/normalize-clear-sequence.ts` | String replacement utility |
103
+ | `src/constants.ts` | Escape sequence definitions |
92
104
 
93
- - Only affects data written via `ProcessTerminal.prototype.write`.
94
- - Only rewrites the **exact** byte sequence `\x1b[3J\x1b[2J\x1b[H`.
95
- - If your terminal redraw issue is caused by different escape sequences, this extension will not help.
96
- - If `ProcessTerminal.write` is not available (or the underlying API changes), the patch will fail and you’ll see a warning on `session_start` (when UI is available).
105
+ ### Limitations
97
106
 
98
- ## Troubleshooting
107
+ - Only affects data written via `ProcessTerminal.prototype.write`
108
+ - Only rewrites the exact byte sequence `\x1b[3J\x1b[2J\x1b[H`
109
+ - Will not help if redraw issues are caused by different escape sequences
110
+ - Patch fails if `ProcessTerminal.write` is unavailable or the API changes
99
111
 
100
- ### I see a warning: “failed to patch terminal clear sequence …”
112
+ ## Troubleshooting
101
113
 
102
- This warning is shown on `session_start` when:
114
+ ### Warning: "failed to patch terminal clear sequence …"
103
115
 
104
- - Pi has a UI (`ctx.hasUI`), and
105
- - the extension could not patch `ProcessTerminal.prototype.write`.
116
+ This warning appears on `session_start` when the extension cannot patch `ProcessTerminal.prototype.write`.
106
117
 
107
- Common causes:
118
+ **Possible Causes:**
108
119
 
109
- - Incompatible Pi / `@mariozechner/pi-tui` version where `ProcessTerminal.write` is missing or changed.
110
- - Another extension or runtime modified the terminal layer in an unexpected way.
120
+ - Incompatible Pi or `@mariozechner/pi-tui` version where `ProcessTerminal.write` is missing or changed
121
+ - Another extension modified the terminal layer unexpectedly
111
122
 
112
- What to try:
123
+ **Solutions:**
113
124
 
114
- 1. Update Pi and your extensions.
115
- 2. Temporarily disable other terminal/TUI-related extensions to identify conflicts.
116
- 3. Verify the extension is actually being loaded (installed to an auto-discovery folder or referenced in your Pi settings).
125
+ 1. Update Pi and all extensions to latest versions
126
+ 2. Temporarily disable other terminal/TUI-related extensions to identify conflicts
127
+ 3. Verify the extension is loaded from an auto-discovery folder or referenced in Pi settings
117
128
 
118
129
  ## Development
119
130
 
120
131
  ```bash
132
+ # Build TypeScript
121
133
  npm run build
134
+
135
+ # Run linter
122
136
  npm run lint
137
+
138
+ # Run tests
123
139
  npm run test
140
+
141
+ # Run all checks
124
142
  npm run check
125
143
  ```
126
144
 
127
- ## Project layout
145
+ ### Requirements
128
146
 
129
- - `index.ts` root entrypoint (kept for Pi auto-discovery / package export)
130
- - `src/index.ts` extension bootstrap + `session_start` warning notification
131
- - `src/terminal-clear-patch.ts` — `ProcessTerminal.prototype.write` monkey-patch + idempotency guard
132
- - `src/normalize-clear-sequence.ts` — string rewrite helper
133
- - `src/constants.ts` — escape sequence constants
134
- - `config/config.example.json` — starter config template
147
+ - Node.js 20
148
+ - Peer dependencies: `@mariozechner/pi-coding-agent`, `@mariozechner/pi-tui`
135
149
 
136
150
  ## License
137
151
 
138
- MIT
152
+ [MIT](LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-startup-redraw-fix",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Pi extension that patches terminal full-clear ordering to avoid startup redraw glitches.",
5
5
  "type": "module",
6
6
  "main": "./index.ts",