pi-image-tools 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.4] - 2026-03-07
4
+
5
+ ### Added
6
+ - Added Linux clipboard image support via `wl-paste` and `xclip` fallback readers.
7
+ - Added Linux and macOS default recent-image discovery locations so the recent picker works beyond Windows.
8
+ - Added non-Windows image paste shortcuts including `Ctrl+V` in addition to the existing alternate bindings.
9
+
10
+ ### Changed
11
+ - Updated README documentation to reflect current cross-platform support, clipboard backends, recent-image discovery behavior, and inline preview details.
12
+
13
+ ### Fixed
14
+ - Removed the Windows-only extension gate so supported non-Windows platforms can register commands and shortcuts.
15
+ - Preserved Kitty and iTerm inline image protocol rows during preview width fitting, alongside the existing Sixel-safe handling.
16
+ - Improved clipboard reader error handling so unsupported environments report missing backends more clearly.
17
+
18
+ ## [1.0.3] - 2026-03-04
19
+
20
+ ### Fixed
21
+ - Use absolute GitHub raw URL for README image to fix npm display
22
+
3
23
  ## [1.0.2] - 2026-03-04
4
24
 
5
25
  ### Changed
package/README.md CHANGED
@@ -2,33 +2,43 @@
2
2
 
3
3
  Image attachment and preview extension for the **Pi coding agent**.
4
4
 
5
- Quickly attach clipboard images or recent screenshots to your messages, with inline preview rendering in the TUI chat.
5
+ `pi-image-tools` lets you attach clipboard images or recent screenshots to your next user message, then preview them inline in the TUI before the message is sent.
6
6
 
7
- > ⚠️ **Windows-only:** This extension only registers commands and shortcuts on Windows (`win32`). On other platforms, it does nothing.
8
-
9
- ![pi-image-tools preview](asset/pi-image-tools.png)
7
+ ![pi-image-tools preview](https://raw.githubusercontent.com/MasuRii/pi-image-tools/main/asset/pi-image-tools.png)
10
8
 
11
9
  ## Features
12
10
 
13
- - **Clipboard paste** Attach images directly from your clipboard
14
- - **Recent image picker** Browse and select from recent screenshots
15
- - **Keyboard shortcuts** Fast paste with `Alt+V` or `Ctrl+Alt+V`
16
- - **Inline preview** See attached images rendered in the TUI (up to 3 per message)
17
- - **Sixel rendering** High-quality terminal graphics when available
18
- - **Automatic caching** Clipboard-pasted images appear in the recent picker
11
+ - **Clipboard image attach** with `/paste-image` and keyboard shortcuts
12
+ - **Recent image picker** for screenshots and cached clipboard images
13
+ - **Inline preview rendering** in the TUI chat before the message is sent
14
+ - **Cross-platform recent image discovery** for Windows, Linux, and macOS
15
+ - **Multiple clipboard backends** with platform-specific fallbacks
16
+ - **Recent-cache persistence** so clipboard images also appear in the recent picker
17
+ - **Terminal image safety** that preserves inline image protocol rows during width fitting
18
+
19
+ ## Platform support
20
+
21
+ | Platform | Clipboard paste | Recent image picker | Notes |
22
+ |----------|-----------------|---------------------|-------|
23
+ | Windows | Yes | Yes | Uses native clipboard module first, then PowerShell fallback |
24
+ | Linux | Yes | Yes | Requires a graphical session; uses `wl-paste` or `xclip`, then native module fallback |
25
+ | macOS | Yes* | Yes | Clipboard paste depends on `@mariozechner/clipboard` being available |
26
+ | Termux / headless Linux | No | Limited | Clipboard image paste is disabled without a graphical session |
27
+
28
+ \* macOS clipboard image support relies on the optional native clipboard module.
19
29
 
20
30
  ## Installation
21
31
 
22
- ### Extension Folder (Recommended)
32
+ ### Extension folder
23
33
 
24
34
  Place this folder in one of these locations:
25
35
 
26
- | Scope | Path |
27
- |---------|-------------------------------------------|
28
- | Global | `~/.pi/agent/extensions/pi-image-tools` |
29
- | Project | `.pi/extensions/pi-image-tools` |
36
+ | Scope | Path |
37
+ |-------|------|
38
+ | Global | `~/.pi/agent/extensions/pi-image-tools` |
39
+ | Project | `.pi/extensions/pi-image-tools` |
30
40
 
31
- Pi auto-discovers extensions in these paths.
41
+ Pi auto-discovers extensions in those paths.
32
42
 
33
43
  ### Via npm
34
44
 
@@ -46,81 +56,69 @@ pi install git:github.com/MasuRii/pi-image-tools
46
56
 
47
57
  ### Commands
48
58
 
49
- #### Paste from Clipboard
59
+ #### Paste from clipboard
50
60
 
51
61
  ```text
52
62
  /paste-image clipboard
53
63
  ```
54
64
 
55
- Or simply:
65
+ or simply:
56
66
 
57
67
  ```text
58
68
  /paste-image
59
69
  ```
60
70
 
61
- This reads an image from your clipboard and queues it for attachment. A marker (`[󰈟 Image Attached]`) appears in your draft. When you send the message, the marker is removed and the image is attached.
71
+ This reads an image from your clipboard and queues it for attachment. A marker (`[󰈟 Image Attached]`) is inserted into your draft. When you send the message, the marker is removed and the image payload is attached.
62
72
 
63
- > **Tip:** Remove all markers from your draft before sending to discard pending images.
73
+ > Remove all markers from the draft before sending if you want to discard pending images.
64
74
 
65
- #### Paste from Recent Images
75
+ #### Paste from recent images
66
76
 
67
77
  ```text
68
78
  /paste-image recent
69
79
  ```
70
80
 
71
- Opens an interactive picker showing recent screenshots and cached images:
81
+ This opens an interactive picker showing recent screenshots and cached clipboard images.
82
+
83
+ Example entry:
72
84
 
73
85
  ```text
74
86
  01. Screenshot 2026-03-02 142233.png • 2m ago • 412 KB • C:\Users\...\Pictures\Screenshots\...
75
- 02. IMG_20260301_120000.png • 1d ago • 1.2 MB • C:\Users\...\Desktop\...
76
87
  ```
77
88
 
78
- Select an image to queue it for your next message.
89
+ Selecting an entry queues that image for your next message.
79
90
 
80
- ### Keyboard Shortcuts
91
+ ### Keyboard shortcuts
81
92
 
82
- | Shortcut | Action |
83
- |----------------|---------------------------|
84
- | `Alt+V` | Paste image from clipboard|
85
- | `Ctrl+Alt+V` | Paste image from clipboard|
93
+ | Platform | Shortcuts |
94
+ |----------|-----------|
95
+ | Windows | `Alt+V`, `Ctrl+Alt+V` |
96
+ | Linux / macOS | `Ctrl+V`, `Alt+V`, `Ctrl+Alt+V` |
86
97
 
87
98
  ## Configuration
88
99
 
89
- ### Environment Variables
100
+ ### Environment variables
90
101
 
91
- | Variable | Description | Default |
92
- |----------------------------------|--------------------------------------------------|---------------------------------------|
93
- | `PI_IMAGE_TOOLS_RECENT_DIRS` | Semicolon-separated directories to search | See default locations below |
94
- | `PI_IMAGE_TOOLS_RECENT_CACHE_DIR`| Custom cache directory for clipboard images | `%TEMP%\pi-image-tools\recent-cache` |
102
+ | Variable | Description | Default |
103
+ |----------|-------------|---------|
104
+ | `PI_IMAGE_TOOLS_RECENT_DIRS` | Semicolon-separated directories to search for recent images | Platform defaults listed below |
105
+ | `PI_IMAGE_TOOLS_RECENT_CACHE_DIR` | Custom cache directory for clipboard-pasted images | OS temp dir + `pi-image-tools/recent-cache` |
95
106
 
96
- **Example:**
107
+ Example:
97
108
 
98
109
  ```powershell
99
110
  $env:PI_IMAGE_TOOLS_RECENT_DIRS = "C:\Users\me\Pictures\Screenshots;D:\Shares\Screens"
100
111
  ```
101
112
 
102
- ### Default Search Locations
103
-
104
- The recent picker searches these Windows paths:
105
-
106
- 1. **Cache directory** – Images previously pasted from clipboard
107
- 2. `~/Pictures/Screenshots`
108
- 3. `~/OneDrive/Pictures/Screenshots`
109
- 4. `~/Desktop` – Only files with screenshot-like names (`Screenshot*`, `Snip*`, `IMG_*`, etc.)
110
-
111
- ### Supported Image Formats
112
-
113
- `.png`, `.jpg`, `.jpeg`, `.webp`, `.gif`, `.bmp`
114
-
115
- ### Runtime Config
113
+ ### Runtime config
116
114
 
117
- A configuration file can be placed at:
115
+ A config file can be placed at:
118
116
 
119
117
  ```text
120
118
  ~/.pi/agent/extensions/pi-image-tools/config.json
121
119
  ```
122
120
 
123
- See `config/config.example.json` for the template:
121
+ Starter template:
124
122
 
125
123
  ```json
126
124
  {
@@ -128,72 +126,116 @@ See `config/config.example.json` for the template:
128
126
  }
129
127
  ```
130
128
 
131
- ## Technical Details
129
+ See `config/config.example.json` for the same template.
132
130
 
133
- ### Preview Rendering
131
+ ## Default recent-image search locations
134
132
 
135
- When you send a message with images, the extension renders an inline preview:
133
+ ### Windows
136
134
 
137
- | Mode | Description |
138
- |--------|------------------------------------------------------------------|
139
- | Sixel | High-quality graphics using PowerShell `Sixel` module (preferred)|
140
- | Native | Fallback using `@mariozechner/pi-tui` Image component |
135
+ 1. Cache directory for clipboard-pasted images
136
+ 2. `~/Pictures/Screenshots`
137
+ 3. `~/OneDrive/Pictures/Screenshots`
138
+ 4. `~/Desktop` filtered to screenshot-like names
141
139
 
142
- - Maximum **3 images** previewed per message
143
- - Warnings displayed if Sixel is unavailable
140
+ ### Linux
144
141
 
145
- ### Clipboard Access
142
+ 1. Cache directory for clipboard-pasted images
143
+ 2. `~/Pictures/Screenshots`
144
+ 3. `~/Pictures` filtered to screenshot-like names
145
+ 4. `~/Downloads` filtered to screenshot-like names
146
+ 5. `~/Desktop` filtered to screenshot-like names
146
147
 
147
- The extension uses multiple methods to read clipboard images:
148
+ ### macOS
148
149
 
149
- 1. **Native module** `@mariozechner/clipboard` (optional dependency)
150
- 2. **PowerShell fallback** Uses `System.Windows.Forms.Clipboard` via PowerShell
150
+ 1. Cache directory for clipboard-pasted images
151
+ 2. `~/Desktop` filtered to screenshot-like names
152
+ 3. `~/Downloads` filtered to screenshot-like names
153
+ 4. `~/Pictures/Screenshots`
154
+ 5. `~/Pictures` filtered to screenshot-like names
151
155
 
152
- ### Sixel Module Auto-Installation
156
+ Supported image formats:
157
+ - `.png`
158
+ - `.jpg`
159
+ - `.jpeg`
160
+ - `.webp`
161
+ - `.gif`
162
+ - `.bmp`
153
163
 
154
- The extension attempts to install the PowerShell `Sixel` module automatically (CurrentUser scope). If blocked by policy, install manually:
164
+ ## Rendering details
155
165
 
156
- ```powershell
157
- Install-Module -Name Sixel -Scope CurrentUser -Force -AllowClobber
158
- ```
166
+ ### Inline user preview
167
+
168
+ When you queue one or more images, the extension renders an inline preview inside the user message area.
169
+
170
+ Preview behavior:
171
+ - up to **3 images** are previewed per message
172
+ - Sixel rendering is attempted on Windows when available
173
+ - native TUI image rendering is used as the fallback
174
+ - inline width fitting now preserves Sixel, Kitty, and iTerm image protocol rows instead of truncating them like plain text
175
+
176
+ ### Clipboard readers
177
+
178
+ `pi-image-tools` uses the first available clipboard backend for the current platform:
179
+
180
+ - **Windows**
181
+ - `@mariozechner/clipboard`
182
+ - PowerShell `System.Windows.Forms.Clipboard`
183
+ - **Linux**
184
+ - `wl-paste` (`wl-clipboard`) in Wayland sessions
185
+ - `xclip` in X11 sessions
186
+ - `@mariozechner/clipboard` fallback
187
+ - **macOS**
188
+ - `@mariozechner/clipboard`
189
+
190
+ If a platform-specific reader exists but no image is currently on the clipboard, the command returns a normal “No image found in clipboard” message. If no usable reader exists at all, the extension surfaces a setup-oriented error.
159
191
 
160
- ### Architecture
192
+ ## Project structure
161
193
 
162
- | File | Purpose |
163
- |---------------------------|---------------------------------------------------|
164
- | `index.ts` | Root entrypoint for Pi auto-discovery |
165
- | `src/commands.ts` | `/paste-image` command registration |
166
- | `src/keybindings.ts` | Keyboard shortcut registration |
167
- | `src/clipboard.ts` | Clipboard image reading (native + PowerShell) |
168
- | `src/recent-images.ts` | Recent image discovery and cache management |
169
- | `src/image-preview.ts` | Preview building and Sixel conversion |
170
- | `src/inline-user-preview.ts` | TUI message patching for inline previews |
171
- | `src/temp-file.ts` | Temporary file management with cleanup |
172
- | `src/types.ts` | TypeScript type definitions |
194
+ ```text
195
+ pi-image-tools/
196
+ ├── index.ts # Root entrypoint for Pi auto-discovery
197
+ ├── src/
198
+ │ ├── index.ts # Extension bootstrap and message flow
199
+ │ ├── commands.ts # /paste-image command registration
200
+ │ ├── clipboard.ts # Cross-platform clipboard image reading
201
+ │ ├── recent-images.ts # Recent image discovery and cache management
202
+ │ ├── image-preview.ts # Preview building and Sixel/native rendering
203
+ │ ├── inline-user-preview.ts # Inline preview patching for user messages
204
+ │ ├── keybindings.ts # Keyboard shortcut registration
205
+ │ ├── temp-file.ts # Temporary file management and cleanup
206
+ │ └── types.ts # Shared TypeScript types
207
+ ├── config/
208
+ │ └── config.example.json # Starter runtime config
209
+ └── asset/
210
+ └── pi-image-tools.png # README preview image
211
+ ```
173
212
 
174
213
  ## Troubleshooting
175
214
 
176
215
  | Issue | Solution |
177
216
  |-------|----------|
178
- | Nothing happens on `/paste-image` | Ensure you're on Windows. This extension is Windows-only. |
179
- | "requires interactive TUI mode" | Run Pi in interactive TUI mode to use the recent picker. |
180
- | "No image found in clipboard" | Confirm you copied an actual image, not a file path or text. |
181
- | Recent picker is empty | Add directories via `PI_IMAGE_TOOLS_RECENT_DIRS` or paste images from clipboard first. |
182
- | Sixel warning shown | Install the Sixel module manually (see above) and restart Pi. |
217
+ | `No image found in clipboard` | Confirm you copied an actual image, not text or a file path |
218
+ | Linux clipboard paste fails | Make sure you are in a graphical session and install `wl-clipboard` or `xclip` |
219
+ | Recent picker is empty | Add directories via `PI_IMAGE_TOOLS_RECENT_DIRS` or paste images from clipboard first so they enter the recent cache |
220
+ | `/paste-image recent` says it requires interactive mode | Run Pi in interactive TUI mode |
221
+ | Sixel preview warning appears | On Windows, install the PowerShell `Sixel` module and restart Pi |
222
+
223
+ Manual Sixel installation:
224
+
225
+ ```powershell
226
+ Install-Module -Name Sixel -Scope CurrentUser -Force -AllowClobber
227
+ ```
183
228
 
184
229
  ## Development
185
230
 
186
231
  ```bash
187
- # Type-check (build)
232
+ # Type-check
188
233
  npm run build
189
234
 
190
- # Lint
191
- npm run lint
192
-
193
235
  # Run tests
194
236
  npm run test
195
237
 
196
- # All checks
238
+ # Full verification
197
239
  npm run check
198
240
  ```
199
241
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-image-tools",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Image attachment and rendering extension for Pi TUI",
5
5
  "type": "module",
6
6
  "main": "./index.ts",