pi-ele-picker 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +106 -2
- package/client/picker.js +614 -0
- package/dist/index.cjs +106 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +79 -0
- package/dist/index.js.map +1 -0
- package/extensions/pi-picker.ts +350 -0
- package/package.json +74 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lute
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,107 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pi-ele-picker
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Pick an element in your running page, describe the change you want (text + screenshots), and send it to a running [pi](https://github.com/earendil-works/pi) session — either into the pi input box for review, or submitted straight away as a real user turn.
|
|
4
|
+
|
|
5
|
+
The picker lives entirely inside a Shadow DOM, so it never leaks styles into — or inherits styles from — your app.
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
browser page ──(same-origin /__pi_picker__/config)──▶ Vite plugin ──▶ reads ~/.pi/agent/pi-picker/*.json
|
|
11
|
+
│ (discovers the live bridge)
|
|
12
|
+
└──(POST http://127.0.0.1:<port>/pick)────────────────────────────────▶ pi bridge extension
|
|
13
|
+
│
|
|
14
|
+
writes to the pi input box
|
|
15
|
+
or submits a user turn
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`pi-ele-picker` has **two halves**, and you need both:
|
|
19
|
+
|
|
20
|
+
| Half | What it is | Where it runs |
|
|
21
|
+
|---|---|---|
|
|
22
|
+
| **pi bridge extension** | a pi extension that serves `POST /pick` on loopback | inside your pi session |
|
|
23
|
+
| **Vite plugin** | injects the picker + a discovery endpoint into your dev page | in your Vite dev server |
|
|
24
|
+
|
|
25
|
+
They meet in the middle through the bridge registry (`~/.pi/agent/pi-picker/<pid>.json`).
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
### 1. The pi bridge extension (once per machine)
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pi install npm:pi-ele-picker
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
This registers the bridge extension (`extensions/pi-picker.ts` from this package) with pi. Check it with `pi list`.
|
|
36
|
+
|
|
37
|
+
<details>
|
|
38
|
+
<summary>Manual install (if you don't use the pi package manager)</summary>
|
|
39
|
+
|
|
40
|
+
Copy the extension file that ships in this package into pi's extension directory:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
mkdir -p ~/.pi/agent/extensions
|
|
44
|
+
cp node_modules/pi-ele-picker/extensions/pi-picker.ts ~/.pi/agent/extensions/pi-picker.ts
|
|
45
|
+
```
|
|
46
|
+
</details>
|
|
47
|
+
|
|
48
|
+
### 2. The Vite plugin (per project)
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm i -D pi-ele-picker
|
|
52
|
+
# pnpm add -D pi-ele-picker
|
|
53
|
+
# yarn add -D pi-ele-picker
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
// vite.config.ts
|
|
58
|
+
import { defineConfig } from 'vite';
|
|
59
|
+
import piElePicker from 'pi-ele-picker';
|
|
60
|
+
|
|
61
|
+
export default defineConfig({
|
|
62
|
+
plugins: [piElePicker()],
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Then run the dev server **and start pi in the same directory** (the bridge is matched by working directory). A **🎯 pi 选择器** launcher appears in the page.
|
|
67
|
+
|
|
68
|
+
### Options
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
piElePicker({
|
|
72
|
+
// Directory whose pi bridge to discover; must match the cwd the pi session
|
|
73
|
+
// was started in. Defaults to process.cwd().
|
|
74
|
+
root: process.cwd(),
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Requirements
|
|
79
|
+
|
|
80
|
+
- Node.js >= 18, Vite >= 4.
|
|
81
|
+
- [pi](https://github.com/earendil-works/pi) with the bridge extension installed (step 1 above).
|
|
82
|
+
- Start pi in the same directory you run Vite from, so the bridge is matched to the project.
|
|
83
|
+
|
|
84
|
+
## Using the picker
|
|
85
|
+
|
|
86
|
+
The launcher starts in the **bottom-right** corner and stays out of the way:
|
|
87
|
+
|
|
88
|
+
- **Draggable** — grab it and drop it anywhere; the position is remembered per browser (`localStorage`).
|
|
89
|
+
- **Fades when idle** (opacity `0.5`) and returns to full opacity on hover.
|
|
90
|
+
- The panel always opens **next to the launcher**, flipping sides and clamping to stay on screen.
|
|
91
|
+
|
|
92
|
+
1. Click **🎯 pi 选择器** and pick an element on the page.
|
|
93
|
+
2. Describe the change (paste or attach screenshots if you like).
|
|
94
|
+
3. Choose a delivery mode:
|
|
95
|
+
- **写入pi输入框** — pre-fills the current pi input box with the composed prompt; you edit and press Enter.
|
|
96
|
+
- **直接发送** — submits the composed prompt as a real user turn immediately (queued as a follow-up if pi is mid-turn).
|
|
97
|
+
|
|
98
|
+
## Notes
|
|
99
|
+
|
|
100
|
+
- The Vite plugin only runs during `vite dev` (`apply: 'serve'`); it has no effect on builds.
|
|
101
|
+
- Discovery is per-project: the bridge whose `cwd` matches `root` (and whose process is still alive) is selected, so several projects/sessions can run side by side without cross-talk.
|
|
102
|
+
- If pi restarts while a page is open (new random port + token), the next send re-discovers the bridge and retries once automatically — no page refresh needed.
|
|
103
|
+
- The bridge never auto-submits on its own: **写入pi输入框** only fills the editor; **直接发送** is an explicit user action in the page.
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
MIT
|