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 +20 -0
- package/README.md +133 -91
- package/package.json +1 -1
- package/src/clipboard.ts +385 -117
- package/src/commands.ts +79 -79
- package/src/index.ts +252 -260
- package/src/inline-user-preview.ts +354 -345
- package/src/keybindings.ts +21 -15
- package/src/recent-images.ts +508 -437
- package/src/temp-file.ts +82 -82
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
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-

|
|
7
|
+

|
|
10
8
|
|
|
11
9
|
## Features
|
|
12
10
|
|
|
13
|
-
- **Clipboard
|
|
14
|
-
- **Recent image picker**
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
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
|
|
32
|
+
### Extension folder
|
|
23
33
|
|
|
24
34
|
Place this folder in one of these locations:
|
|
25
35
|
|
|
26
|
-
| Scope
|
|
27
|
-
|
|
28
|
-
| Global
|
|
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
|
|
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
|
|
59
|
+
#### Paste from clipboard
|
|
50
60
|
|
|
51
61
|
```text
|
|
52
62
|
/paste-image clipboard
|
|
53
63
|
```
|
|
54
64
|
|
|
55
|
-
|
|
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]`)
|
|
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
|
-
>
|
|
73
|
+
> Remove all markers from the draft before sending if you want to discard pending images.
|
|
64
74
|
|
|
65
|
-
#### Paste from
|
|
75
|
+
#### Paste from recent images
|
|
66
76
|
|
|
67
77
|
```text
|
|
68
78
|
/paste-image recent
|
|
69
79
|
```
|
|
70
80
|
|
|
71
|
-
|
|
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
|
-
|
|
89
|
+
Selecting an entry queues that image for your next message.
|
|
79
90
|
|
|
80
|
-
### Keyboard
|
|
91
|
+
### Keyboard shortcuts
|
|
81
92
|
|
|
82
|
-
|
|
|
83
|
-
|
|
84
|
-
| `Alt+V`
|
|
85
|
-
| `Ctrl+Alt+V`
|
|
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
|
|
100
|
+
### Environment variables
|
|
90
101
|
|
|
91
|
-
| Variable
|
|
92
|
-
|
|
93
|
-
| `PI_IMAGE_TOOLS_RECENT_DIRS`
|
|
94
|
-
| `PI_IMAGE_TOOLS_RECENT_CACHE_DIR
|
|
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
|
-
|
|
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
|
-
###
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
129
|
+
See `config/config.example.json` for the same template.
|
|
132
130
|
|
|
133
|
-
|
|
131
|
+
## Default recent-image search locations
|
|
134
132
|
|
|
135
|
-
|
|
133
|
+
### Windows
|
|
136
134
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
|
|
143
|
-
- Warnings displayed if Sixel is unavailable
|
|
140
|
+
### Linux
|
|
144
141
|
|
|
145
|
-
|
|
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
|
-
|
|
148
|
+
### macOS
|
|
148
149
|
|
|
149
|
-
1.
|
|
150
|
-
2.
|
|
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
|
-
|
|
156
|
+
Supported image formats:
|
|
157
|
+
- `.png`
|
|
158
|
+
- `.jpg`
|
|
159
|
+
- `.jpeg`
|
|
160
|
+
- `.webp`
|
|
161
|
+
- `.gif`
|
|
162
|
+
- `.bmp`
|
|
153
163
|
|
|
154
|
-
|
|
164
|
+
## Rendering details
|
|
155
165
|
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
192
|
+
## Project structure
|
|
161
193
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
|
|
|
179
|
-
|
|
|
180
|
-
|
|
|
181
|
-
|
|
|
182
|
-
| Sixel warning
|
|
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
|
|
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
|
-
#
|
|
238
|
+
# Full verification
|
|
197
239
|
npm run check
|
|
198
240
|
```
|
|
199
241
|
|