peekme 0.2.1
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/.gitignore +2 -0
- package/CHANGELOG.md +88 -0
- package/LICENSE-APACHE +176 -0
- package/LICENSE-MIT +21 -0
- package/README.md +196 -0
- package/binary-install.js +348 -0
- package/binary.js +124 -0
- package/install.js +4 -0
- package/npm-shrinkwrap.json +52 -0
- package/package.json +77 -0
- package/run-peekme.js +4 -0
package/.gitignore
ADDED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.1 (2026-09-28)
|
|
4
|
+
|
|
5
|
+
- You don't need Rust any more. peekme can be installed with npm (`npm i -g peekme`), with
|
|
6
|
+
Homebrew (`brew install gregorybolshakov/tap/peekme`) or with a shell script. Each release has
|
|
7
|
+
ready binaries for Linux and macOS, on x86_64 and ARM.
|
|
8
|
+
- Ctrl+Z works when peekme was started through another program, like the npm launcher. Before,
|
|
9
|
+
the terminal could wait forever.
|
|
10
|
+
|
|
11
|
+
## 0.2.0 (2026-09-28)
|
|
12
|
+
|
|
13
|
+
- peekme works with Claude Code too. Type `claude` as always, select text, press Alt+P.
|
|
14
|
+
`peekme install` now hooks `claude` next to `codex`. If you installed 0.1, run
|
|
15
|
+
`peekme install` once more.
|
|
16
|
+
- Claude Code explanations come from `claude -p` on Haiku with your Claude Code login. The
|
|
17
|
+
session is not saved. The context comes from the running session's transcript, and Alt+P
|
|
18
|
+
again sends the whole conversation (after asking, when it is big).
|
|
19
|
+
- In Claude Code's full screen mode peekme reads the selection from the OSC 52 copy Claude sends
|
|
20
|
+
when you release the mouse. In the classic mode it reads the X11 PRIMARY selection.
|
|
21
|
+
- Claude's input line stays live under the box, as with Codex. Ctrl+Z works with Claude too.
|
|
22
|
+
- The box is never drawn in the middle of an escape sequence from the agent. Before, if the
|
|
23
|
+
agent's output stopped inside one (a window title, say), part of it could show as text.
|
|
24
|
+
- While an explanation streams in, the box is redrawn at most about 30 times a second. This
|
|
25
|
+
sends much less to the terminal.
|
|
26
|
+
- `peekme doctor` checks both agents. Plain `peekme` runs Codex, or Claude Code when only that
|
|
27
|
+
is installed.
|
|
28
|
+
|
|
29
|
+
## 0.1.3 (2026-09-27)
|
|
30
|
+
|
|
31
|
+
- peekme uses the shared Codex server that Codex 0.157 runs in the background, instead of
|
|
32
|
+
starting its own. A session now costs a few MB instead of about 250 MB. The connection is
|
|
33
|
+
made on the first Alt+P and made again if it drops. Without the shared server, peekme starts
|
|
34
|
+
its own server as before. `PEEKME_OWN_SERVER=1` forces that.
|
|
35
|
+
- Alt+P again on a long chat shows the size first. Above about 40k tokens it asks for one more
|
|
36
|
+
Alt+P before it sends the whole conversation.
|
|
37
|
+
|
|
38
|
+
## 0.1.2 (2026-09-27)
|
|
39
|
+
|
|
40
|
+
- Works with Codex 0.157, which draws full screen and handles the mouse itself. peekme uses the
|
|
41
|
+
text Codex highlights when you drag. Moving the mouse no longer closes the box, the mouse
|
|
42
|
+
wheel scrolls it, and a click closes it and still reaches Codex.
|
|
43
|
+
- The Codex input line stays live under the box in full screen too, and the box closes by
|
|
44
|
+
itself when Codex asks for approval.
|
|
45
|
+
|
|
46
|
+
## 0.1.1 (2026-09-27)
|
|
47
|
+
|
|
48
|
+
- Text in the box is cleaned before it is drawn. The explanation, the selected text and error
|
|
49
|
+
messages can no longer send terminal control sequences, for example one that writes your
|
|
50
|
+
clipboard, or characters that reverse the order of the text.
|
|
51
|
+
|
|
52
|
+
## 0.1.0 (2026-09-26)
|
|
53
|
+
|
|
54
|
+
- `peekme install` makes `codex` open with peekme. It adds a shell function `codex` and a
|
|
55
|
+
`codex` link at the front of PATH. Aliases and scripts that call `codex` keep working.
|
|
56
|
+
`peekme uninstall` removes it and leaves your files as they were. `peekme doctor` checks the
|
|
57
|
+
setup and says what is in the way.
|
|
58
|
+
- The first plain `peekme` run asks once if it should set this up.
|
|
59
|
+
- Only Codex's interactive screen gets peekme. `codex exec`, `login`, `mcp` and the other
|
|
60
|
+
subcommands, and output to a pipe or a file, run plain Codex directly.
|
|
61
|
+
- peekme never wraps itself twice.
|
|
62
|
+
- Ctrl+Z works. Codex stops, you get your shell back, and `fg` brings it back. Before, Ctrl+Z
|
|
63
|
+
did nothing inside peekme.
|
|
64
|
+
- The Codex input line and status line stay live while the box is open. You can type, and
|
|
65
|
+
Enter sends the message and closes the box. If Codex needs more room, for example for an
|
|
66
|
+
approval question, the box closes by itself.
|
|
67
|
+
- If peekme can't start its terminal, it starts Codex directly. If something inside peekme
|
|
68
|
+
fails later, it logs the error, puts the screen back and keeps passing Codex through.
|
|
69
|
+
The log is in `~/.local/state/peekme/peekme.log`.
|
|
70
|
+
- The box gets smaller when the explanation is complete, so it takes only the rows it needs.
|
|
71
|
+
- A comma or a bracket after styled text no longer starts a new line in the box.
|
|
72
|
+
- The terminal cursor is hidden while the box is open. Before, it could show inside the box text.
|
|
73
|
+
|
|
74
|
+
## 0.0.1 (2026-09-26)
|
|
75
|
+
|
|
76
|
+
First working version.
|
|
77
|
+
|
|
78
|
+
- Runs Codex (or any command) in a pseudo-terminal. Output goes to the terminal unchanged and is
|
|
79
|
+
also kept in a terminal emulator in memory.
|
|
80
|
+
- Alt+P explains the text selected with the mouse (X11 PRIMARY selection). The box opens under
|
|
81
|
+
or above the text without clearing the screen. Works with the kitty keyboard protocol and with
|
|
82
|
+
any keyboard layout.
|
|
83
|
+
- Esc restores the screen from a copy and then sends the Codex output that arrived meanwhile.
|
|
84
|
+
- Explanations come from `codex app-server` with a temporary thread on the account's fast model,
|
|
85
|
+
so no API key is needed.
|
|
86
|
+
- The model gets the text around the selection with the selection marked, the request it
|
|
87
|
+
answers, a short list of earlier requests and earlier uses of the same words.
|
|
88
|
+
- Alt+P again on the same selection explains with the whole conversation.
|
package/LICENSE-APACHE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gregory Bolshakov
|
|
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
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# peekme
|
|
2
|
+
|
|
3
|
+
Peek me. Pick me. Select text in [Codex CLI](https://github.com/openai/codex) or
|
|
4
|
+
[Claude Code](https://github.com/anthropics/claude-code) output, press **Alt+P**, and a short
|
|
5
|
+
explanation opens right next to that text, inside the terminal. The other lines move to make
|
|
6
|
+
room, like Peek in VS Code. Esc closes it and the screen is exactly as before.
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
The explanation comes from a small, fast model and it knows the conversation. If you select
|
|
11
|
+
"its split panes" in an answer that recommends Kitty, it tells you it is about Kitty.
|
|
12
|
+
|
|
13
|
+
Status: 0.2.1. Tested on Linux with X11 and bash, with Codex 0.157 and Claude Code 2.1.283.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
You need Codex CLI or Claude Code (logged in). Both is fine too. Then install peekme in one of
|
|
18
|
+
these ways and run `peekme install`:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
npm i -g peekme # you have npm already if you installed an agent with it
|
|
22
|
+
brew install gregorybolshakov/tap/peekme # Homebrew, on macOS or Linux
|
|
23
|
+
cargo install peekme # builds it with Rust
|
|
24
|
+
peekme install
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Without npm, Homebrew or Rust, the script from the
|
|
28
|
+
[latest release](https://github.com/GregoryBolshakov/peekme/releases/latest) puts peekme in
|
|
29
|
+
`~/.local/bin`:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/GregoryBolshakov/peekme/releases/latest/download/peekme-installer.sh | sh
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Ready binaries are there too, for Linux and macOS on x86_64 and ARM. macOS is not tested yet.
|
|
36
|
+
|
|
37
|
+
After this, `codex` and `claude` open with peekme in every new terminal. You keep typing
|
|
38
|
+
`codex` or `claude`, and your aliases and scripts that call them keep working. `peekme install`
|
|
39
|
+
adds a short, marked block to your `~/.bashrc` or `~/.zshrc` (for fish, a file in
|
|
40
|
+
`~/.config/fish/conf.d`). If you install one of the agents later, it gets peekme too.
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
peekme doctor # check the setup, and see what is in the way if something is
|
|
44
|
+
peekme uninstall # remove the block, your files are as before
|
|
45
|
+
command codex # run plain Codex once
|
|
46
|
+
command claude # run plain Claude Code once
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The first time you run `peekme` on its own, it asks if it should do `peekme install` for you.
|
|
50
|
+
|
|
51
|
+
Upgrading from 0.1: run `peekme install` once more, so that `claude` gets peekme too.
|
|
52
|
+
|
|
53
|
+
## Use
|
|
54
|
+
|
|
55
|
+
Start Codex or Claude Code as always. Select text with the mouse as you normally do, then press
|
|
56
|
+
Alt+P. When the agent draws full screen (Codex since 0.157, Claude Code with
|
|
57
|
+
`"tui": "fullscreen"`), it makes the selection itself, and peekme uses that selection.
|
|
58
|
+
|
|
59
|
+
| Key | When | What it does |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| Alt+P | any time | explain the selected text |
|
|
62
|
+
| Alt+P again | box is open, same selection | explain again using the whole conversation |
|
|
63
|
+
| PgUp / PgDn, mouse wheel | box is open | scroll a long explanation |
|
|
64
|
+
| Esc | box is open | close the box |
|
|
65
|
+
| typing | box is open | goes to the agent's input line, the box stays open |
|
|
66
|
+
| Enter | box is open | sends your message and closes the box |
|
|
67
|
+
|
|
68
|
+
In Claude Code, Alt+P opens the model picker. With peekme it explains the selection instead.
|
|
69
|
+
`/model` still opens the model picker.
|
|
70
|
+
|
|
71
|
+
No API key is needed. peekme asks the agent's own CLI, with your existing login:
|
|
72
|
+
|
|
73
|
+
- Codex: its `app-server`, on a temporary thread that is not saved. Since Codex 0.157 a shared
|
|
74
|
+
Codex server runs in the background, and peekme uses it, so it adds only a few MB of memory.
|
|
75
|
+
Without that server it starts its own `codex app-server`, which takes about 250 MB.
|
|
76
|
+
- Claude Code: `claude -p` on Haiku, without tools and without saving the session, so nothing
|
|
77
|
+
appears in `/resume`. After the first explanation one `claude -p` waits in the background for
|
|
78
|
+
the next one, so it starts in about half a second. It takes about 210 MB.
|
|
79
|
+
|
|
80
|
+
It does use your plan, a little for each explanation. Nothing starts before the first Alt+P.
|
|
81
|
+
|
|
82
|
+
Only the interactive screen gets peekme: `codex`, `codex "prompt"`, `codex resume`,
|
|
83
|
+
`codex fork`, and `claude`, `claude "prompt"`, `claude --resume`, `claude -c`. Commands like
|
|
84
|
+
`codex exec`, `codex mcp`, `claude -p` or `claude mcp`, and anything with output going to a pipe
|
|
85
|
+
or a file, run the agent directly.
|
|
86
|
+
|
|
87
|
+
## How it works
|
|
88
|
+
|
|
89
|
+
The agent runs in a pseudo-terminal. Its output goes to your terminal unchanged, and the same
|
|
90
|
+
bytes also go to a terminal emulator in memory (`alacritty_terminal`). So peekme always knows
|
|
91
|
+
what is on your screen.
|
|
92
|
+
|
|
93
|
+
On Alt+P it takes the selection and finds it on the screen:
|
|
94
|
+
|
|
95
|
+
- Codex full screen: the text Codex highlighted.
|
|
96
|
+
- Claude Code full screen: Claude copies the selection with an OSC 52 escape sequence when you
|
|
97
|
+
release the mouse. peekme reads the text from that sequence as it passes through, and knows
|
|
98
|
+
where the drag ended. This also works over SSH.
|
|
99
|
+
- Otherwise: your terminal's mouse selection (the X11 PRIMARY selection).
|
|
100
|
+
|
|
101
|
+
Then it redraws only the rows next to the selection, with the box between them. Nothing is
|
|
102
|
+
cleared and there is no switch to another screen, so there is no flicker. The agent's input
|
|
103
|
+
line and status line under the box keep updating, so you can type while you read. Other output
|
|
104
|
+
that arrives while the box is open is kept aside.
|
|
105
|
+
|
|
106
|
+
On Esc it draws those rows again from a copy taken when the box opened. After that it sends the
|
|
107
|
+
kept output, so the terminal ends in the same state as if the box never existed. Tests check
|
|
108
|
+
this cell by cell on real Codex and Claude Code output.
|
|
109
|
+
|
|
110
|
+
### What the model gets
|
|
111
|
+
|
|
112
|
+
A few words alone are not enough ("Desktop app", which one?). The whole chat is too much and too
|
|
113
|
+
slow. So the model gets small parts, each with a size limit:
|
|
114
|
+
|
|
115
|
+
1. One line saying which agent this is and in which directory. This is enough for text from the
|
|
116
|
+
agent itself, like the startup tips.
|
|
117
|
+
2. The text around the selection, with the selection marked in place like `⟦this⟧`. peekme
|
|
118
|
+
finds it in the conversation by searching for the selection together with the words next to
|
|
119
|
+
it on screen. This way it finds the right place when the same words appear many times. If the
|
|
120
|
+
text is not in the conversation, it uses the screen.
|
|
121
|
+
3. Your request that this text answers, and one line for each of your earlier requests.
|
|
122
|
+
4. The first places in the conversation where the same words were used before.
|
|
123
|
+
|
|
124
|
+
The conversation comes from Codex's app-server, or from Claude Code's session transcript in
|
|
125
|
+
`~/.claude/projects` (peekme knows which one, because Claude registers its process id).
|
|
126
|
+
|
|
127
|
+
Usually this is 1 to 7 KB of text. When it is not enough, press Alt+P again and the model gets
|
|
128
|
+
the whole conversation. A long chat can be 5 to 30 times bigger than a normal explanation, so
|
|
129
|
+
above about 40k tokens peekme shows the size first and sends it only when you press Alt+P once
|
|
130
|
+
more.
|
|
131
|
+
|
|
132
|
+
## Settings
|
|
133
|
+
|
|
134
|
+
| Variable | Meaning |
|
|
135
|
+
|---|---|
|
|
136
|
+
| `PEEKME_MODEL` | model for Codex explanations. Default is the model your account lists as fast |
|
|
137
|
+
| `PEEKME_CODEX_BIN` | codex binary to use for explanations. Default is `codex` |
|
|
138
|
+
| `PEEKME_OWN_SERVER` | set to 1 to start peekme's own `codex app-server` instead of using the shared one |
|
|
139
|
+
| `PEEKME_CLAUDE_MODEL` | model for Claude Code explanations. Default is `haiku` |
|
|
140
|
+
| `PEEKME_CLAUDE_BIN` | claude binary to use for explanations. Default is `claude` |
|
|
141
|
+
| `PEEKME_SELECTION` | use this text instead of the mouse selection, for testing |
|
|
142
|
+
|
|
143
|
+
### How `codex` and `claude` get peekme
|
|
144
|
+
|
|
145
|
+
`peekme install` does two things:
|
|
146
|
+
|
|
147
|
+
1. It defines shell functions `codex` and `claude` in your shell setup. A function wins over
|
|
148
|
+
anything on PATH, so it keeps working when nvm, mise, Homebrew or an agent's installer
|
|
149
|
+
change PATH later. Aliases that call `codex` or `claude` go through it too.
|
|
150
|
+
2. It puts `codex` and `claude` links to peekme in `~/.local/share/peekme/bin` at the front of
|
|
151
|
+
PATH, so scripts that run them also get peekme. If some tool puts its own directory in front
|
|
152
|
+
of it later, only scripts lose peekme, and `peekme doctor` tells you which directory it is.
|
|
153
|
+
|
|
154
|
+
Both find the real agent on PATH themselves, so updating the agent changes nothing. If you
|
|
155
|
+
remove peekme, the functions fall back to plain `codex` and `claude`.
|
|
156
|
+
|
|
157
|
+
To use peekme with another program, run `peekme -- COMMAND`.
|
|
158
|
+
|
|
159
|
+
## Limits
|
|
160
|
+
|
|
161
|
+
- Only text that is on screen now. Text that scrolled up into the terminal history can't be
|
|
162
|
+
selected yet.
|
|
163
|
+
- In full screen mode selection works anywhere, also over SSH, because peekme reads the
|
|
164
|
+
selection from the agent. Otherwise peekme needs the terminal's selection, which it reads on
|
|
165
|
+
Linux with X11 only. On Wayland it works through XWayland, and on macOS it reads the
|
|
166
|
+
clipboard, not tested.
|
|
167
|
+
- Claude Code full screen: if `copyOnSelect` is off, Claude does not report the selection. Then
|
|
168
|
+
only a Shift+drag selection works (read from X11 PRIMARY).
|
|
169
|
+
- An explanation takes about 1 to 2 seconds to start arriving.
|
|
170
|
+
- `peekme install` is tested with bash. zsh uses the same block and should work the same way,
|
|
171
|
+
but it is not tested yet. The fish setup is not tested either.
|
|
172
|
+
|
|
173
|
+
## Development
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
cargo test
|
|
177
|
+
cargo clippy --all-targets
|
|
178
|
+
cargo run --example vtdump -- capture.bin 120 40 [offset]
|
|
179
|
+
cargo run --example peek_text -- "<screen text>" "<selection>" [--deep] [--claude [--pid PID]]
|
|
180
|
+
python3 spikes/capture.py out.bin 120 40 "<script>" -- peekme claude
|
|
181
|
+
python3 spikes/flicker_test.py
|
|
182
|
+
python3 spikes/explain_probe.py
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
`vtdump` replays a captured byte stream and prints the screen. `peek_text` runs one explanation
|
|
186
|
+
without a terminal and prints the exact prompt. `capture.py` runs a command in a pseudo-terminal,
|
|
187
|
+
sends keys and mouse events from a script and saves everything it prints. `flicker_test.py`
|
|
188
|
+
shows if your terminal flickers when a program switches screens. `explain_probe.py` makes one
|
|
189
|
+
explanation request to `codex app-server` and prints timings.
|
|
190
|
+
|
|
191
|
+
Each agent has its own folder in `src/` (`codex/`, `claude/`): how its selection is read, where
|
|
192
|
+
its conversation comes from, and which model explains. The rest is shared.
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
MIT or Apache-2.0, at your choice.
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
const {
|
|
2
|
+
createWriteStream,
|
|
3
|
+
existsSync,
|
|
4
|
+
mkdirSync,
|
|
5
|
+
mkdtemp,
|
|
6
|
+
rmSync,
|
|
7
|
+
} = require("fs");
|
|
8
|
+
const { join, sep } = require("path");
|
|
9
|
+
const { spawnSync } = require("child_process");
|
|
10
|
+
const { tmpdir } = require("os");
|
|
11
|
+
|
|
12
|
+
const https = require("node:https");
|
|
13
|
+
const http = require("node:http");
|
|
14
|
+
|
|
15
|
+
const tmpDir = tmpdir();
|
|
16
|
+
|
|
17
|
+
const error = (msg) => {
|
|
18
|
+
console.error(msg);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function getProxyForUrl(urlString) {
|
|
23
|
+
const url = new URL(urlString);
|
|
24
|
+
const isHttps = url.protocol === "https:";
|
|
25
|
+
|
|
26
|
+
const noProxy = process.env.NO_PROXY || process.env.no_proxy || "";
|
|
27
|
+
if (noProxy === "*") return null;
|
|
28
|
+
if (noProxy) {
|
|
29
|
+
const hostname = url.hostname.toLowerCase();
|
|
30
|
+
const noProxyList = noProxy.split(",").map((s) => s.trim().toLowerCase());
|
|
31
|
+
for (const entry of noProxyList) {
|
|
32
|
+
if (hostname === entry || hostname.endsWith("." + entry)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const proxyEnv = isHttps
|
|
39
|
+
? process.env.HTTPS_PROXY || process.env.https_proxy
|
|
40
|
+
: process.env.HTTP_PROXY || process.env.http_proxy;
|
|
41
|
+
|
|
42
|
+
if (!proxyEnv) return null;
|
|
43
|
+
|
|
44
|
+
const proxyUrl = new URL(proxyEnv);
|
|
45
|
+
|
|
46
|
+
let auth = null;
|
|
47
|
+
if (proxyUrl.username || proxyUrl.password) {
|
|
48
|
+
auth = `${proxyUrl.username}:${proxyUrl.password}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
hostname: proxyUrl.hostname,
|
|
53
|
+
port: proxyUrl.port || (proxyUrl.protocol === "https:" ? 443 : 80),
|
|
54
|
+
auth: auth,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function connectThroughProxy(proxy, target) {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
const headers = {};
|
|
61
|
+
if (proxy.auth) {
|
|
62
|
+
headers["Proxy-Authorization"] =
|
|
63
|
+
"Basic " + Buffer.from(proxy.auth).toString("base64");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const connectReq = http.request({
|
|
67
|
+
hostname: proxy.hostname,
|
|
68
|
+
port: proxy.port,
|
|
69
|
+
method: "CONNECT",
|
|
70
|
+
path: `${target.hostname}:${target.port || 443}`,
|
|
71
|
+
headers,
|
|
72
|
+
});
|
|
73
|
+
connectReq.on("connect", (res, socket) => {
|
|
74
|
+
if (res.statusCode === 200) {
|
|
75
|
+
resolve(socket);
|
|
76
|
+
} else {
|
|
77
|
+
reject(new Error(`Proxy CONNECT failed with status ${res.statusCode}`));
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
connectReq.on("error", reject);
|
|
81
|
+
connectReq.end();
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function download(urlString, maxRedirects) {
|
|
86
|
+
if (maxRedirects === undefined) maxRedirects = 5;
|
|
87
|
+
return new Promise((resolve, reject) => {
|
|
88
|
+
if (maxRedirects < 0) {
|
|
89
|
+
return reject(new Error("Too many redirects"));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const parsed = new URL(urlString);
|
|
93
|
+
const isHttps = parsed.protocol === "https:";
|
|
94
|
+
const mod = isHttps ? https : http;
|
|
95
|
+
const proxy = getProxyForUrl(urlString);
|
|
96
|
+
|
|
97
|
+
const doRequest = (extraOptions) => {
|
|
98
|
+
const options = Object.assign(
|
|
99
|
+
{
|
|
100
|
+
hostname: parsed.hostname,
|
|
101
|
+
port: parsed.port || (isHttps ? 443 : 80),
|
|
102
|
+
path: parsed.pathname + parsed.search,
|
|
103
|
+
method: "GET",
|
|
104
|
+
headers: { "User-Agent": "cargo-dist-npm-installer" },
|
|
105
|
+
},
|
|
106
|
+
extraOptions || {},
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
if (proxy && !isHttps) {
|
|
110
|
+
// HTTP through HTTP proxy: request the full URL via the proxy
|
|
111
|
+
options.hostname = proxy.hostname;
|
|
112
|
+
options.port = proxy.port;
|
|
113
|
+
options.path = urlString;
|
|
114
|
+
if (proxy.auth) {
|
|
115
|
+
options.headers["Proxy-Authorization"] =
|
|
116
|
+
"Basic " + Buffer.from(proxy.auth).toString("base64");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const req = mod.request(options, (res) => {
|
|
121
|
+
if (
|
|
122
|
+
res.statusCode >= 300 &&
|
|
123
|
+
res.statusCode < 400 &&
|
|
124
|
+
res.headers.location
|
|
125
|
+
) {
|
|
126
|
+
res.resume();
|
|
127
|
+
const nextUrl = new URL(res.headers.location, urlString).toString();
|
|
128
|
+
return download(nextUrl, maxRedirects - 1).then(resolve, reject);
|
|
129
|
+
}
|
|
130
|
+
if (res.statusCode < 200 || res.statusCode >= 300) {
|
|
131
|
+
res.resume();
|
|
132
|
+
return reject(new Error(`HTTP ${res.statusCode} from ${urlString}`));
|
|
133
|
+
}
|
|
134
|
+
resolve(res);
|
|
135
|
+
});
|
|
136
|
+
req.on("error", reject);
|
|
137
|
+
req.end();
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
if (proxy && isHttps) {
|
|
141
|
+
connectThroughProxy(proxy, parsed).then(
|
|
142
|
+
(socket) => doRequest({ socket, agent: false }),
|
|
143
|
+
reject,
|
|
144
|
+
);
|
|
145
|
+
} else {
|
|
146
|
+
doRequest();
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
class Package {
|
|
152
|
+
constructor(platform, name, url, filename, zipExt, binaries) {
|
|
153
|
+
let errors = [];
|
|
154
|
+
if (typeof url !== "string") {
|
|
155
|
+
errors.push("url must be a string");
|
|
156
|
+
} else {
|
|
157
|
+
try {
|
|
158
|
+
new URL(url);
|
|
159
|
+
} catch (e) {
|
|
160
|
+
errors.push(e);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (name && typeof name !== "string") {
|
|
164
|
+
errors.push("package name must be a string");
|
|
165
|
+
}
|
|
166
|
+
if (!name) {
|
|
167
|
+
errors.push("You must specify the name of your package");
|
|
168
|
+
}
|
|
169
|
+
if (binaries && typeof binaries !== "object") {
|
|
170
|
+
errors.push("binaries must be a string => string map");
|
|
171
|
+
}
|
|
172
|
+
if (!binaries) {
|
|
173
|
+
errors.push("You must specify the binaries in the package");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (errors.length > 0) {
|
|
177
|
+
let errorMsg =
|
|
178
|
+
"One or more of the parameters you passed to the Binary constructor are invalid:\n";
|
|
179
|
+
errors.forEach((error) => {
|
|
180
|
+
errorMsg += error;
|
|
181
|
+
});
|
|
182
|
+
errorMsg +=
|
|
183
|
+
'\n\nCorrect usage: new Package("my-binary", "https://example.com/binary/download.tar.gz", {"my-binary": "my-binary"})';
|
|
184
|
+
error(errorMsg);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
this.platform = platform;
|
|
188
|
+
this.url = url;
|
|
189
|
+
this.name = name;
|
|
190
|
+
this.filename = filename;
|
|
191
|
+
this.zipExt = zipExt;
|
|
192
|
+
this.installDirectory = join(__dirname, "node_modules", ".bin_real");
|
|
193
|
+
this.binaries = binaries;
|
|
194
|
+
|
|
195
|
+
if (!existsSync(this.installDirectory)) {
|
|
196
|
+
mkdirSync(this.installDirectory, { recursive: true });
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
exists() {
|
|
201
|
+
for (const binaryName in this.binaries) {
|
|
202
|
+
const binRelPath = this.binaries[binaryName];
|
|
203
|
+
const binPath = join(this.installDirectory, binRelPath);
|
|
204
|
+
if (!existsSync(binPath)) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
install(suppressLogs = false) {
|
|
212
|
+
if (this.exists()) {
|
|
213
|
+
if (!suppressLogs) {
|
|
214
|
+
console.error(
|
|
215
|
+
`${this.name} is already installed, skipping installation.`,
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
return Promise.resolve();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
try {
|
|
222
|
+
rmSync(this.installDirectory, { recursive: true, force: true });
|
|
223
|
+
} catch {
|
|
224
|
+
// ignore - directory may not exist
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
mkdirSync(this.installDirectory, { recursive: true });
|
|
228
|
+
|
|
229
|
+
if (!suppressLogs) {
|
|
230
|
+
console.error(`Downloading release from ${this.url}`);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return download(this.url)
|
|
234
|
+
.then((res) => {
|
|
235
|
+
return new Promise((resolve, reject) => {
|
|
236
|
+
mkdtemp(`${tmpDir}${sep}`, (err, directory) => {
|
|
237
|
+
if (err) return reject(err);
|
|
238
|
+
let tempFile = join(directory, this.filename);
|
|
239
|
+
const sink = res.pipe(createWriteStream(tempFile));
|
|
240
|
+
sink.on("error", (err) => reject(err));
|
|
241
|
+
sink.on("close", () => {
|
|
242
|
+
if (/\.tar\.*/.test(this.zipExt)) {
|
|
243
|
+
const result = spawnSync("tar", [
|
|
244
|
+
"xf",
|
|
245
|
+
tempFile,
|
|
246
|
+
// The tarballs are stored with a leading directory
|
|
247
|
+
// component; we strip one component in the
|
|
248
|
+
// shell installers too.
|
|
249
|
+
"--strip-components",
|
|
250
|
+
"1",
|
|
251
|
+
"-C",
|
|
252
|
+
this.installDirectory,
|
|
253
|
+
]);
|
|
254
|
+
if (result.status == 0) {
|
|
255
|
+
resolve();
|
|
256
|
+
} else if (result.error) {
|
|
257
|
+
reject(result.error);
|
|
258
|
+
} else {
|
|
259
|
+
reject(
|
|
260
|
+
new Error(
|
|
261
|
+
`An error occurred untarring the artifact: stdout: ${result.stdout}; stderr: ${result.stderr}`,
|
|
262
|
+
),
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
} else if (this.zipExt == ".zip") {
|
|
266
|
+
let result;
|
|
267
|
+
if (this.platform.artifactName.includes("windows")) {
|
|
268
|
+
// Windows does not have "unzip" by default on many installations, instead
|
|
269
|
+
// we use Expand-Archive from powershell
|
|
270
|
+
result = spawnSync("powershell.exe", [
|
|
271
|
+
"-NoProfile",
|
|
272
|
+
"-NonInteractive",
|
|
273
|
+
"-Command",
|
|
274
|
+
`& {
|
|
275
|
+
param([string]$LiteralPath, [string]$DestinationPath)
|
|
276
|
+
Expand-Archive -LiteralPath $LiteralPath -DestinationPath $DestinationPath -Force
|
|
277
|
+
}`,
|
|
278
|
+
tempFile,
|
|
279
|
+
this.installDirectory,
|
|
280
|
+
]);
|
|
281
|
+
} else {
|
|
282
|
+
result = spawnSync("unzip", [
|
|
283
|
+
"-q",
|
|
284
|
+
tempFile,
|
|
285
|
+
"-d",
|
|
286
|
+
this.installDirectory,
|
|
287
|
+
]);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (result.status == 0) {
|
|
291
|
+
resolve();
|
|
292
|
+
} else if (result.error) {
|
|
293
|
+
reject(result.error);
|
|
294
|
+
} else {
|
|
295
|
+
reject(
|
|
296
|
+
new Error(
|
|
297
|
+
`An error occurred unzipping the artifact: stdout: ${result.stdout}; stderr: ${result.stderr}`,
|
|
298
|
+
),
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
} else {
|
|
302
|
+
reject(
|
|
303
|
+
new Error(`Unrecognized file extension: ${this.zipExt}`),
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
})
|
|
310
|
+
.then(() => {
|
|
311
|
+
if (!suppressLogs) {
|
|
312
|
+
console.error(`${this.name} has been installed!`);
|
|
313
|
+
}
|
|
314
|
+
})
|
|
315
|
+
.catch((e) => {
|
|
316
|
+
error(`Error fetching release: ${e.message}`);
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
run(binaryName) {
|
|
321
|
+
const promise = !this.exists() ? this.install(true) : Promise.resolve();
|
|
322
|
+
|
|
323
|
+
promise
|
|
324
|
+
.then(() => {
|
|
325
|
+
const [, , ...args] = process.argv;
|
|
326
|
+
|
|
327
|
+
const options = { cwd: process.cwd(), stdio: "inherit" };
|
|
328
|
+
|
|
329
|
+
const binRelPath = this.binaries[binaryName];
|
|
330
|
+
if (!binRelPath) {
|
|
331
|
+
error(`${binaryName} is not a known binary in ${this.name}`);
|
|
332
|
+
}
|
|
333
|
+
const binPath = join(this.installDirectory, binRelPath);
|
|
334
|
+
const result = spawnSync(binPath, args, options);
|
|
335
|
+
|
|
336
|
+
if (result.error) {
|
|
337
|
+
error(result.error);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
process.exit(result.status);
|
|
341
|
+
})
|
|
342
|
+
.catch((e) => {
|
|
343
|
+
error(e.message);
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
module.exports.Package = Package;
|
package/binary.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const { Package } = require("./binary-install");
|
|
2
|
+
const os = require("os");
|
|
3
|
+
const libc = require("detect-libc");
|
|
4
|
+
|
|
5
|
+
const error = (msg) => {
|
|
6
|
+
console.error(msg);
|
|
7
|
+
process.exit(1);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
name,
|
|
12
|
+
artifactDownloadUrls,
|
|
13
|
+
supportedPlatforms,
|
|
14
|
+
glibcMinimum,
|
|
15
|
+
} = require("./package.json");
|
|
16
|
+
|
|
17
|
+
// FIXME: implement NPM installer handling of fallback download URLs
|
|
18
|
+
const artifactDownloadUrl = artifactDownloadUrls[0];
|
|
19
|
+
const builderGlibcMajorVersion = glibcMinimum.major;
|
|
20
|
+
const builderGlibcMinorVersion = glibcMinimum.series;
|
|
21
|
+
|
|
22
|
+
const getPlatform = () => {
|
|
23
|
+
const rawOsType = os.type();
|
|
24
|
+
const rawArchitecture = os.arch();
|
|
25
|
+
|
|
26
|
+
// We want to use rust-style target triples as the canonical key
|
|
27
|
+
// for a platform, so translate the "os" library's concepts into rust ones
|
|
28
|
+
let osType = "";
|
|
29
|
+
switch (rawOsType) {
|
|
30
|
+
case "Windows_NT":
|
|
31
|
+
osType = "pc-windows-msvc";
|
|
32
|
+
break;
|
|
33
|
+
case "Darwin":
|
|
34
|
+
osType = "apple-darwin";
|
|
35
|
+
break;
|
|
36
|
+
case "Linux":
|
|
37
|
+
osType = "unknown-linux-gnu";
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let arch = "";
|
|
42
|
+
switch (rawArchitecture) {
|
|
43
|
+
case "x64":
|
|
44
|
+
arch = "x86_64";
|
|
45
|
+
break;
|
|
46
|
+
case "arm64":
|
|
47
|
+
arch = "aarch64";
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (rawOsType === "Linux") {
|
|
52
|
+
if (libc.familySync() == "musl") {
|
|
53
|
+
osType = "unknown-linux-musl-dynamic";
|
|
54
|
+
} else if (libc.isNonGlibcLinuxSync()) {
|
|
55
|
+
console.warn(
|
|
56
|
+
"Your libc is neither glibc nor musl; trying static musl binary instead",
|
|
57
|
+
);
|
|
58
|
+
osType = "unknown-linux-musl-static";
|
|
59
|
+
} else {
|
|
60
|
+
let libcVersion = libc.versionSync();
|
|
61
|
+
let splitLibcVersion = libcVersion.split(".");
|
|
62
|
+
let libcMajorVersion = splitLibcVersion[0];
|
|
63
|
+
let libcMinorVersion = splitLibcVersion[1];
|
|
64
|
+
if (
|
|
65
|
+
libcMajorVersion != builderGlibcMajorVersion ||
|
|
66
|
+
libcMinorVersion < builderGlibcMinorVersion
|
|
67
|
+
) {
|
|
68
|
+
// We can't run the glibc binaries, but we can run the static musl ones
|
|
69
|
+
// if they exist
|
|
70
|
+
console.warn(
|
|
71
|
+
"Your glibc isn't compatible; trying static musl binary instead",
|
|
72
|
+
);
|
|
73
|
+
osType = "unknown-linux-musl-static";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Assume the above succeeded and build a target triple to look things up with.
|
|
79
|
+
// If any of it failed, this lookup will fail and we'll handle it like normal.
|
|
80
|
+
let targetTriple = `${arch}-${osType}`;
|
|
81
|
+
let platform = supportedPlatforms[targetTriple];
|
|
82
|
+
|
|
83
|
+
if (!platform) {
|
|
84
|
+
error(
|
|
85
|
+
`Platform with type "${rawOsType}" and architecture "${rawArchitecture}" is not supported by ${name}.\nYour system must be one of the following:\n\n${Object.keys(
|
|
86
|
+
supportedPlatforms,
|
|
87
|
+
).join(",")}`,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return platform;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const getPackage = () => {
|
|
95
|
+
const platform = getPlatform();
|
|
96
|
+
const url = `${artifactDownloadUrl}/${platform.artifactName}`;
|
|
97
|
+
let filename = platform.artifactName;
|
|
98
|
+
let ext = platform.zipExt;
|
|
99
|
+
let binary = new Package(platform, name, url, filename, ext, platform.bins);
|
|
100
|
+
|
|
101
|
+
return binary;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const install = (suppressLogs) => {
|
|
105
|
+
if (!artifactDownloadUrl || artifactDownloadUrl.length === 0) {
|
|
106
|
+
console.warn("in demo mode, not installing binaries");
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const pkg = getPackage();
|
|
110
|
+
|
|
111
|
+
return pkg.install(suppressLogs);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const run = (binaryName) => {
|
|
115
|
+
const pkg = getPackage();
|
|
116
|
+
|
|
117
|
+
pkg.run(binaryName);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
module.exports = {
|
|
121
|
+
install,
|
|
122
|
+
run,
|
|
123
|
+
getPackage,
|
|
124
|
+
};
|
package/install.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"lockfileVersion": 3,
|
|
3
|
+
"name": "peekme",
|
|
4
|
+
"packages": {
|
|
5
|
+
"": {
|
|
6
|
+
"bin": {
|
|
7
|
+
"peekme": "run-peekme.js"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"detect-libc": "^2.1.2"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"prettier": "^3.8.3"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=14.14",
|
|
17
|
+
"npm": ">=6"
|
|
18
|
+
},
|
|
19
|
+
"hasInstallScript": true,
|
|
20
|
+
"license": "MIT OR Apache-2.0",
|
|
21
|
+
"name": "peekme",
|
|
22
|
+
"version": "0.2.1"
|
|
23
|
+
},
|
|
24
|
+
"node_modules/detect-libc": {
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=8"
|
|
27
|
+
},
|
|
28
|
+
"integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
|
|
29
|
+
"license": "Apache-2.0",
|
|
30
|
+
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
|
|
31
|
+
"version": "2.1.2"
|
|
32
|
+
},
|
|
33
|
+
"node_modules/prettier": {
|
|
34
|
+
"bin": {
|
|
35
|
+
"prettier": "bin/prettier.cjs"
|
|
36
|
+
},
|
|
37
|
+
"dev": true,
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=14"
|
|
40
|
+
},
|
|
41
|
+
"funding": {
|
|
42
|
+
"url": "https://github.com/prettier/prettier?sponsor=1"
|
|
43
|
+
},
|
|
44
|
+
"integrity": "sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==",
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.3.tgz",
|
|
47
|
+
"version": "3.8.3"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"requires": true,
|
|
51
|
+
"version": "0.2.1"
|
|
52
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"artifactDownloadUrls": [
|
|
3
|
+
"https://github.com/GregoryBolshakov/peekme/releases/download/v0.2.1"
|
|
4
|
+
],
|
|
5
|
+
"author": "Gregory Bolshakov",
|
|
6
|
+
"bin": {
|
|
7
|
+
"peekme": "run-peekme.js"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"detect-libc": "^2.1.2"
|
|
11
|
+
},
|
|
12
|
+
"description": "Select text in Codex CLI or Claude Code output and get a short explanation right under it, inside the terminal",
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"prettier": "^3.8.3"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=14.14",
|
|
18
|
+
"npm": ">=6"
|
|
19
|
+
},
|
|
20
|
+
"glibcMinimum": {
|
|
21
|
+
"major": 2,
|
|
22
|
+
"series": 35
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/GregoryBolshakov/peekme",
|
|
25
|
+
"keywords": [
|
|
26
|
+
"command-line-utilities",
|
|
27
|
+
"codex",
|
|
28
|
+
"claude",
|
|
29
|
+
"terminal",
|
|
30
|
+
"cli",
|
|
31
|
+
"explain"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT OR Apache-2.0",
|
|
34
|
+
"name": "peekme",
|
|
35
|
+
"preferUnplugged": true,
|
|
36
|
+
"repository": "https://github.com/GregoryBolshakov/peekme",
|
|
37
|
+
"scripts": {
|
|
38
|
+
"fmt": "prettier --write **/*.js",
|
|
39
|
+
"fmt:check": "prettier --check **/*.js",
|
|
40
|
+
"postinstall": "node ./install.js"
|
|
41
|
+
},
|
|
42
|
+
"supportedPlatforms": {
|
|
43
|
+
"aarch64-apple-darwin": {
|
|
44
|
+
"artifactName": "peekme-aarch64-apple-darwin.tar.xz",
|
|
45
|
+
"bins": {
|
|
46
|
+
"peekme": "peekme"
|
|
47
|
+
},
|
|
48
|
+
"zipExt": ".tar.xz"
|
|
49
|
+
},
|
|
50
|
+
"aarch64-unknown-linux-gnu": {
|
|
51
|
+
"artifactName": "peekme-aarch64-unknown-linux-gnu.tar.xz",
|
|
52
|
+
"bins": {
|
|
53
|
+
"peekme": "peekme"
|
|
54
|
+
},
|
|
55
|
+
"zipExt": ".tar.xz"
|
|
56
|
+
},
|
|
57
|
+
"x86_64-apple-darwin": {
|
|
58
|
+
"artifactName": "peekme-x86_64-apple-darwin.tar.xz",
|
|
59
|
+
"bins": {
|
|
60
|
+
"peekme": "peekme"
|
|
61
|
+
},
|
|
62
|
+
"zipExt": ".tar.xz"
|
|
63
|
+
},
|
|
64
|
+
"x86_64-unknown-linux-gnu": {
|
|
65
|
+
"artifactName": "peekme-x86_64-unknown-linux-gnu.tar.xz",
|
|
66
|
+
"bins": {
|
|
67
|
+
"peekme": "peekme"
|
|
68
|
+
},
|
|
69
|
+
"zipExt": ".tar.xz"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"version": "0.2.1",
|
|
73
|
+
"volta": {
|
|
74
|
+
"node": "18.14.1",
|
|
75
|
+
"npm": "9.5.0"
|
|
76
|
+
}
|
|
77
|
+
}
|
package/run-peekme.js
ADDED