pindeck 3.0.0-beta.1 → 3.0.0-beta.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.
- package/README.md +267 -45
- package/cli.mjs +6 -3
- package/lib/agent-process.mjs +7 -3
- package/lib/agent-tools.mjs +32 -9
- package/lib/capabilities.mjs +121 -0
- package/lib/claude.mjs +7 -3
- package/lib/codex.mjs +4 -2
- package/lib/deck-files.mjs +94 -0
- package/lib/eids.mjs +101 -8
- package/lib/frameworks.mjs +59 -0
- package/lib/instructions.mjs +74 -0
- package/lib/models.mjs +2 -1
- package/lib/pdf-render.jxa.js +5 -3
- package/lib/pdf.mjs +4 -2
- package/lib/platform-notice.mjs +6 -6
- package/lib/pptx-render.mjs +78 -9
- package/lib/system-prompt.md +5 -3
- package/lib/waveform.mjs +9 -3
- package/package.json +6 -3
- package/public/bridge.js +248 -69
- package/public/editor.css +1 -0
- package/public/editor.js +85 -24
- package/public/index.html +2 -2
- package/server.mjs +660 -173
package/README.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# PinDeck
|
|
2
2
|
|
|
3
|
-
> **macOS
|
|
3
|
+
> **macOS, and Linux as a beta · Version 3 beta preview** (`3.0.0-beta.3`). On Linux, PinDeck runs as a
|
|
4
|
+
> headless server that you use from your Mac's browser through an SSH tunnel (see
|
|
5
|
+
> [Running on a Linux server](#running-on-a-linux-server-beta)). Windows is not supported. The beta is on
|
|
6
|
+
> npm’s `beta` channel and the [`v3-beta`](https://github.com/ehabets/PinDeck/tree/v3-beta) branch; stable
|
|
7
|
+
> releases (`npx pindeck`) stay on 2.x. See installation below.
|
|
4
8
|
|
|
5
|
-
**Pin it. Say it. Done.** PinDeck is a local
|
|
9
|
+
**Pin it. Say it. Done.** PinDeck is a local editor for HTML slide decks (reveal.js): the slides on
|
|
6
10
|
the left, the slide in the middle, and a chat with Claude Code or OpenAI Codex on the right. You click elements to
|
|
7
11
|
pin them, write what to change, and the selected assistant edits the HTML and CSS. The slide updates in place.
|
|
8
12
|
|
|
@@ -19,8 +23,8 @@ checked the layout; the next request, still being typed, refers to the new pins
|
|
|
19
23
|
* **Edit by hand, too.** Move, resize and nudge elements with snapping, edit text in place (math stays
|
|
20
24
|
TeX), write speaker notes, add, hide, move and delete slides. One undo history covers your edits and
|
|
21
25
|
the assistant's.
|
|
22
|
-
* **Stay on brand.** `brand.css` is locked: the assistant edits
|
|
23
|
-
its own work with PinDeck's layout command.
|
|
26
|
+
* **Stay on brand.** `brand.css` is locked: the assistant edits the deck, its styles and other files of the
|
|
27
|
+
deck folder, never `brand.css` or `vendor/`, and checks its own work with PinDeck's layout command.
|
|
24
28
|
* **Bring material in.** Attach figures, audio and PDFs to a message, or import slides from PowerPoint
|
|
25
29
|
into the deck's own layouts.
|
|
26
30
|
* **Get it out.** Present from the browser, or export a handout or presentation PDF.
|
|
@@ -28,17 +32,20 @@ checked the layout; the next request, still being typed, refers to the new pins
|
|
|
28
32
|
|
|
29
33
|
## Quick start
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
Runs on macOS, and on Linux as a beta. The npm package declares `"os": ["darwin", "linux"]`, so normal
|
|
36
|
+
npm installation rejects other operating systems. Overriding that check does not make those platforms
|
|
37
|
+
supported. Running the server from a cloned repository on another OS shows a local support notice
|
|
38
|
+
instead of opening the deck or starting a backend.
|
|
32
39
|
|
|
33
|
-
Install the
|
|
40
|
+
Install the beta from npm:
|
|
34
41
|
|
|
35
42
|
```bash
|
|
36
43
|
npx pindeck@beta /path/to/deck
|
|
37
44
|
# Or select this exact beta:
|
|
38
|
-
npx pindeck@3.0.0-beta.
|
|
45
|
+
npx pindeck@3.0.0-beta.3 /path/to/deck
|
|
39
46
|
```
|
|
40
47
|
|
|
41
|
-
|
|
48
|
+
Or run it from the `v3-beta` branch, which includes the example deck:
|
|
42
49
|
|
|
43
50
|
```bash
|
|
44
51
|
git clone --branch v3-beta --single-branch https://github.com/ehabets/PinDeck.git PinDeck-v3
|
|
@@ -46,16 +53,19 @@ cd PinDeck-v3
|
|
|
46
53
|
node server.mjs ocean-example
|
|
47
54
|
```
|
|
48
55
|
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
Use `npx pindeck@latest /path/to/deck` for the stable release; the beta channel does not replace it.
|
|
57
|
+
Releases, with notes for each beta, are on [GitHub](https://github.com/ehabets/PinDeck/releases).
|
|
51
58
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
Then open <http://127.0.0.1:5180/>.
|
|
59
|
+
Then open the login link PinDeck prints (`PinDeck: http://127.0.0.1:5180/login?code=...`). It works
|
|
60
|
+
once and logs this browser in; for a new one, run `pindeck login` (or `node server.mjs login`).
|
|
55
61
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
`
|
|
62
|
+
The deck is a file (`pindeck path/to/talk.html`) or a folder, which opens its `index.html`; without
|
|
63
|
+
one, the current folder. Several decks can share a folder, each with its own chat and undo history;
|
|
64
|
+
they share the folder's `theme.css` and `brand.css`, and the assistant edits only the deck that is open.
|
|
65
|
+
PinDeck adds element ids to the deck file when it opens it (see below), so try it on a copy of a deck
|
|
66
|
+
first. Options: `--port 5180`, `--provider claude|codex`, `--model <name>` (for this run only; otherwise the
|
|
67
|
+
model in `~/.pindeck-v3/config.json`), `--asset-root <folder>` (see [Files outside the deck folder](#files-outside-the-deck-folder)),
|
|
68
|
+
`--help`. Runtime files (chat history, screenshots, backups) are kept in `~/.pindeck-v3/` (change with
|
|
59
69
|
`PINDECK_HOME`), not in the deck. `ocean-example/` is a complete example deck to start from.
|
|
60
70
|
|
|
61
71
|
## Compatibility and requirements
|
|
@@ -65,17 +75,19 @@ Options: `--port 5180`, `--provider claude|codex`, `--model <name>` (for this ru
|
|
|
65
75
|
The corresponding executable must be on `PATH`; `CLAUDE_BIN` and `CODEX_BIN` can override its path.
|
|
66
76
|
Only the selected backend is required for editing. Model and effort availability comes from that
|
|
67
77
|
backend and account, and may differ from the provider’s website or desktop app.
|
|
68
|
-
* **Platforms:** macOS
|
|
69
|
-
`"os": ["darwin"]`, so normal npm
|
|
70
|
-
overridden; bypassing it does not make
|
|
71
|
-
platforms
|
|
72
|
-
possible v4 feature, not part of this beta.
|
|
73
|
-
* **Screenshots and PDF export:** require
|
|
74
|
-
* **PDF input through Codex:**
|
|
75
|
-
`osascript
|
|
76
|
-
|
|
78
|
+
* **Platforms:** macOS, and Linux as a beta (see [Running on a Linux server](#running-on-a-linux-server-beta)).
|
|
79
|
+
Windows is not supported. The npm package declares `"os": ["darwin", "linux"]`, so normal npm
|
|
80
|
+
installation rejects other operating systems. This check can be overridden; bypassing it does not make
|
|
81
|
+
those platforms supported. Source launches on unsupported platforms show a local support page without
|
|
82
|
+
opening the deck or starting a backend. Native Windows support is a possible v4 feature, not part of this beta.
|
|
83
|
+
* **Screenshots and PDF export:** require Chrome, Chromium, Edge or Brave where the server runs.
|
|
84
|
+
* **PDF input through Codex:** pages are rendered with macOS PDFKit, or Poppler on Linux. Page-text
|
|
85
|
+
extraction uses `osascript` and is macOS-only; on Linux Codex reads the rendered page image. Claude uses
|
|
86
|
+
its native PDF-reading capabilities.
|
|
77
87
|
* **PowerPoint import:** basic `.pptx` parsing uses Node.js; rendered slide pictures require
|
|
78
|
-
PowerPoint or Keynote on macOS.
|
|
88
|
+
PowerPoint or Keynote on macOS, or LibreOffice and Poppler on Linux.
|
|
89
|
+
* **Linux tools:** Poppler, LibreOffice and ffmpeg, each optional; features that need a missing one are
|
|
90
|
+
switched off with the reason shown in the editor.
|
|
79
91
|
|
|
80
92
|
The initial live editing checks used Codex CLI **0.144.1** and Claude Code **2.1.289**.
|
|
81
93
|
Further live checks on macOS passed with Codex CLI **0.162.1** and Claude Code **2.1.301**:
|
|
@@ -89,7 +101,8 @@ errors; PinDeck does not fall back to broader permissions. Recheck backend compa
|
|
|
89
101
|
|
|
90
102
|
## Preparing a deck
|
|
91
103
|
|
|
92
|
-
PinDeck works with reveal.js decks whose slides are `<section>` elements inside `.slides
|
|
104
|
+
PinDeck works with reveal.js decks whose slides are `<section>` elements inside `.slides`, and with other
|
|
105
|
+
decks that name their slides (see [Decks made without reveal.js](#decks-made-without-revealjs)). Two
|
|
93
106
|
optional `<meta>` tags in the deck's `<head>` tell it about the design:
|
|
94
107
|
|
|
95
108
|
```html
|
|
@@ -104,6 +117,40 @@ numbers will jump where a slide is hidden.
|
|
|
104
117
|
Without them PinDeck runs no footer check and locks only `.slide-foot` and `.logo`. A file called
|
|
105
118
|
`brand.css` in the deck folder is locked for both backends. See `ocean-example/` for a complete deck.
|
|
106
119
|
|
|
120
|
+
### Decks made without reveal.js
|
|
121
|
+
|
|
122
|
+
A deck with a script of its own, or made with a framework whose slides are elements of their own
|
|
123
|
+
(Shower, deck.js, a hand-written deck), can be edited too once it names its slides in its `<head>`:
|
|
124
|
+
|
|
125
|
+
```html
|
|
126
|
+
<meta name="pindeck:slides" content="main.deck > section.slide"> <!-- a CSS selector for the slides -->
|
|
127
|
+
<meta name="pindeck:size" content="1440x1080"> <!-- their size in px -->
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The selector may use tag names, `#id`, `.class`, `[attr]` and `[attr="value"]`, joined by spaces or `>`,
|
|
131
|
+
and a list of them separated by commas. In the editor, PinDeck shows the slides itself, one at a time and
|
|
132
|
+
scaled to the window, and switches off the deck's own scaling, slide keys and inert or hidden marks while
|
|
133
|
+
you edit; that changes nothing in the deck file. Everything in [Working with it](#working-with-it) works as
|
|
134
|
+
with a reveal.js deck, with these differences:
|
|
135
|
+
|
|
136
|
+
* Build steps (`.fragment`) belong to reveal.js: other decks show every element at once.
|
|
137
|
+
* Hidden slides (`data-visibility="hidden"`) are left out of PinDeck's PDF exports; whether presenting
|
|
138
|
+
skips them is up to the deck's own script.
|
|
139
|
+
* Speaker notes are an `<aside class="notes">` in the slide, as in reveal.js. PinDeck hides them in the
|
|
140
|
+
editor; the deck's CSS should hide them too (`aside.notes { display: none }`).
|
|
141
|
+
* **Present** opens the deck at `#<slide id>`, or `#<number>` (counting from 1) for a slide without an id.
|
|
142
|
+
Present may open on the first slide if the deck does not go to slides by their address.
|
|
143
|
+
* **+ New slide** models a new slide on the deck's own (see [Making your own template](#making-your-own-template)):
|
|
144
|
+
a content slide gets placeholder bullets in a `.slide-body`; without one it has only its title. A new or
|
|
145
|
+
duplicated slide does not take the original's `id`.
|
|
146
|
+
|
|
147
|
+
Both tags are needed: PinDeck opens the slides at the given size for screenshots and PDF pages. A missing
|
|
148
|
+
size, or a selector that finds no slides or that PinDeck cannot read, is reported before anything changes.
|
|
149
|
+
While PinDeck runs, it reads the tags again for every screenshot, PDF and assistant session; the editor
|
|
150
|
+
reads them when the slide reloads. If a tag stops working meanwhile, the editor shows the same message and
|
|
151
|
+
the assistant is told. A session already running keeps the slide selector it started with; **New chat**
|
|
152
|
+
starts one with the new selector.
|
|
153
|
+
|
|
107
154
|
## Making your own template
|
|
108
155
|
|
|
109
156
|
PinDeck has no template generator; a template is simply a deck folder. Start from a copy of the example:
|
|
@@ -120,10 +167,24 @@ cp -R ocean-example my-template
|
|
|
120
167
|
3. **`index.html`:** the footer text in the `data-` attributes of `<div class="reveal">`, and the
|
|
121
168
|
`pindeck:footer-top` and `pindeck:locked` meta tags if the footer or the brand elements move.
|
|
122
169
|
`deck.js` holds the math macros, the footer markup and the audio player.
|
|
123
|
-
4. **`README.md` and `
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
does
|
|
170
|
+
4. **`README.md`, `CLAUDE.md` and `AGENTS.md`:** both backends follow the deck's `CLAUDE.md` and
|
|
171
|
+
`AGENTS.md`, so describe the new classes and rules there; the assistant can read `README.md` for details.
|
|
172
|
+
Refer to PinDeck's commands as "the PinDeck CLI command given in the system prompt", as the
|
|
173
|
+
example's `CLAUDE.md` does; PinDeck tells the assistant the right path wherever the deck is. An older
|
|
174
|
+
`node ../cli.mjs` in a deck's `CLAUDE.md` is replaced with that command.
|
|
175
|
+
|
|
176
|
+
**Instructions for the assistant.** PinDeck gives both backends the deck folder's own `CLAUDE.md` and
|
|
177
|
+
`AGENTS.md`. It does not load such files from parent folders, as Claude Code and Codex do in a terminal:
|
|
178
|
+
those are usually written for coding (run the tests, commit), which PinDeck's assistant cannot do; they
|
|
179
|
+
would change with where the deck happens to sit; and on a shared server a parent folder may be writable
|
|
180
|
+
by others. To share rules between decks, say so in the deck's own file, in one of two ways:
|
|
181
|
+
|
|
182
|
+
- **Import:** `Follow @../shared/STYLE.md for wording.` includes that file's text. Paths are relative to
|
|
183
|
+
the file they are in (or absolute, or `~/...`); imported files may import others, up to 5 levels,
|
|
184
|
+
each file once, 200 KB in all. Only text files are imported; an e-mail address, an `@name` that is
|
|
185
|
+
not a file, and anything in code are left as written.
|
|
186
|
+
- **Pointer:** `The style rules are in ../shared/STYLE.md; read them first.` The assistant reads the file
|
|
187
|
+
when it needs it.
|
|
127
188
|
|
|
128
189
|
**New slide** and the PowerPoint import model new slides on the deck's own: keep a slide with class
|
|
129
190
|
`title-slide`, one with `section-slide`, and a content slide with `.slide-head` (`h2`, optionally a
|
|
@@ -200,6 +261,72 @@ Attached PDFs are handled page by page using PDFKit on macOS: extracted text plu
|
|
|
200
261
|
PDF reading/rendering through this bridge is currently macOS-only. Audio is embedded by path and is
|
|
201
262
|
not transcribed. Read operations have a 12 MB limit; long text can be read in chunks.
|
|
202
263
|
|
|
264
|
+
### Files outside the deck folder
|
|
265
|
+
|
|
266
|
+
A deck can use files from a folder around it, such as a style sheet or figures shared by several
|
|
267
|
+
talks: start PinDeck with `--asset-root <folder>` (repeatable), or list the folders in config.json as
|
|
268
|
+
`"assetRoots": ["~/talks"]`. When the folder contains the deck, PinDeck serves the deck from inside
|
|
269
|
+
it, so relative paths such as `../shared/style.css` work, in the editor, in screenshots and in PDF
|
|
270
|
+
exports. Claude may read those files but does not edit them.
|
|
271
|
+
|
|
272
|
+
Symlinks: PinDeck serves a file only if, with symlinks followed, it lies inside the deck folder or an
|
|
273
|
+
asset root. A symlink in the deck that leads anywhere else is refused (403). To use a symlinked
|
|
274
|
+
library folder, add the folder it points to as an asset root; it does not have to contain the deck.
|
|
275
|
+
|
|
276
|
+
## Running on a Linux server (beta)
|
|
277
|
+
|
|
278
|
+
PinDeck can run on a Linux machine where the deck lives, with the editor in your Mac's browser. The
|
|
279
|
+
deck, PinDeck, the backend (Claude Code or Codex) and the deck's git clone all stay on the server; the browser only shows the
|
|
280
|
+
editor. The server listens on 127.0.0.1 there, as on a Mac, and an SSH tunnel brings that port to your Mac.
|
|
281
|
+
|
|
282
|
+
On the server you need Node 20 or later (22 or 24 recommended), git if the deck is in a repository, and
|
|
283
|
+
the `claude` or `codex` CLI installed and logged in under your account there, if you want the chat. Without one,
|
|
284
|
+
editing by hand still works. Then, in one SSH session on the server:
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
node server.mjs path/to/deck --port 5180
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
and on your Mac, in another terminal (`myserver` is your usual SSH host):
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
ssh -N -T -o ExitOnForwardFailure=yes -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -L 127.0.0.1:5180:127.0.0.1:5180 myserver
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Open the login link PinDeck printed on the server in the Mac's browser. The local port may differ from
|
|
297
|
+
the server's: with `-L 127.0.0.1:8080:127.0.0.1:5180`, change 5180 in the link to 8080. PinDeck accepts any
|
|
298
|
+
port, as long as the address is `127.0.0.1` or `localhost`. If the tunnel drops, a message you have already sent keeps running on the
|
|
299
|
+
server. Restart the tunnel and the editor reconnects and shows the files as they are then; it never sends a
|
|
300
|
+
message twice. If PinDeck restarts, the editor asks you to log in again: run `node server.mjs login
|
|
301
|
+
path/to/deck` on the server for a new link.
|
|
302
|
+
|
|
303
|
+
Other users of a shared server cannot open the editor or read the deck through PinDeck: the token that
|
|
304
|
+
protects it is only in your browser's cookie and in PinDeck's own files in `~/.pindeck` (readable only by
|
|
305
|
+
you), never in a page or on a command line.
|
|
306
|
+
|
|
307
|
+
What works on Linux in this beta: editing by hand, speaker notes, slides, pins, the chat with Claude or Codex,
|
|
308
|
+
Undo/Redo, live reload when files change on the server, layout checks, attaching figures, audio and
|
|
309
|
+
PDFs, `git-setup` and the PowerPoint import. Some features use programs on the server, and are on when
|
|
310
|
+
they are installed (on Debian or Ubuntu: `sudo apt install poppler-utils libreoffice-impress ffmpeg`):
|
|
311
|
+
|
|
312
|
+
| Feature | Needs |
|
|
313
|
+
|---|---|
|
|
314
|
+
| Screenshots, layout checks without an open editor, PDF export | Chrome or Chromium (`PINDECK_LINUX_CHROME=0` turns these off) |
|
|
315
|
+
| Pictures of PDF pages (`pdf-figure`) | Poppler (`pdftoppm`, `pdfinfo`) |
|
|
316
|
+
| Pictures of PowerPoint slides in the import (thumbnails, diagrams) | LibreOffice (`soffice`) and Poppler |
|
|
317
|
+
| Waveforms of audio other than WAV in the import | ffmpeg |
|
|
318
|
+
|
|
319
|
+
Without them the editor says what is missing (hover over "Server: Linux (beta)"), and the assistant is told
|
|
320
|
+
which commands are not available. LibreOffice may draw some slides a little differently from PowerPoint;
|
|
321
|
+
the pictures are references and figures, the slides themselves are rebuilt from the file. Chromium from snap may not be
|
|
322
|
+
allowed to use hidden folders in your home folder such as `~/.pindeck-v3`; if screenshots fail with it, set
|
|
323
|
+
`PINDECK_HOME` to a folder that is not hidden, or install Chrome or Chromium from a package.
|
|
324
|
+
|
|
325
|
+
Run one PinDeck per deck. While PinDeck or the assistant is working on a deck, do not edit it with other tools
|
|
326
|
+
or switch git branches at the same time. Stop first, or wait until the assistant has finished. PinDeck notices
|
|
327
|
+
changes made by other programs and reloads, and it refuses Undo, Redo or an edit that would overwrite
|
|
328
|
+
them. Its checks cannot rule out every race with a program that writes at the same moment.
|
|
329
|
+
|
|
203
330
|
## Keeping the ids out of git
|
|
204
331
|
|
|
205
332
|
PinDeck adds `data-eid` attributes to the deck it opens. If the deck is in git, run once per clone:
|
|
@@ -231,9 +358,9 @@ show and commit as usual. Clones without the filter configured simply see the fi
|
|
|
231
358
|
| Speaker notes | The **Notes** field under the slide shows the current slide's notes (the speaker view, `S`, shows them when presenting). Type to change them; they are saved when you click elsewhere or press `⌘Enter`, and `Esc` puts back what was there. A slide without notes gets them; emptying the field removes them. Notes with formatting other than line breaks are edited as HTML. Drag the line above the notes to give them more or less room (double-click it for the default size); collapse them with their header. |
|
|
232
359
|
| Move a slide | Drag it up or down in the slide list; an orange line shows where it will go. It moves with its notes and the comment above it, and `⌘Z` puts it back. Slides inside vertical stacks cannot be moved yet. |
|
|
233
360
|
| Hide a slide | The eye on a slide in the list, or `H`. A hidden slide stays in the deck and in PinDeck (greyed out, with a banner) but is skipped when presenting and in PDFs; **Export ▾** can include hidden slides. Show it the same way. |
|
|
234
|
-
| Model and effort | Choose a discovered Claude or OpenAI model in the chat header, then use the separate reasoning-effort selector. Provider changes offer an optional handover; same-provider changes continue the conversation. |
|
|
361
|
+
| Model and effort | Choose a discovered Claude or OpenAI model in the chat header, then use the separate reasoning-effort selector. Provider changes offer an optional handover; same-provider changes continue the conversation. The choice is saved in `~/.pindeck-v3/config.json`. |
|
|
235
362
|
| Attach figures and audio | **+** in the chat, then **File…**, drag and drop onto the chat or a slide, or paste an image. Files are saved in `<deck>/figures/` straight away; audio also gets a waveform SVG. Then ask the assistant, e.g. "put this figure on a new slide after 4". Removing an attachment before sending deletes the file again. |
|
|
236
|
-
| Attach a PDF | The same way: a figure or table to take over, or a paper or report with more details. PDFs stay outside the deck (in `~/.pindeck-v3`); the assistant reads them, rebuilds tables as HTML, and renders a figure (a page or a cropped part of one) into `<deck>/figures/` as PNG with `cli.mjs pdf-figure` (macOS). E.g. "put Fig. 3 of this paper on slide 7" or "add the results of Table 2 to slide 9". |
|
|
363
|
+
| Attach a PDF | The same way: a figure or table to take over, or a paper or report with more details. PDFs stay outside the deck (in `~/.pindeck-v3`); the assistant reads them, rebuilds tables as HTML, and renders a figure (a page or a cropped part of one) into `<deck>/figures/` as PNG with `cli.mjs pdf-figure` (macOS, or Linux with Poppler). E.g. "put Fig. 3 of this paper on slide 7" or "add the results of Table 2 to slide 9". |
|
|
237
364
|
| Export PDF | **Export ▾** in the toolbar. **Handout PDF**: one page per slide, build steps shown complete. **Presentation PDF**: one page per click, so a slide with two build steps gives three pages. Files go to `<deck>/export/`. Needs Chrome or Chromium. |
|
|
238
365
|
| Navigate | Slide list, `←` `→`, or the toolbar. **Present** opens the deck in a new tab. |
|
|
239
366
|
|
|
@@ -305,34 +432,50 @@ Without PowerPoint or Keynote (or on other systems than macOS) only the text and
|
|
|
305
432
|
* **Layout instead of screenshots.** With each message the editor measures the current slide and
|
|
306
433
|
every pinned slide in your browser: position and size of every element, font sizes, and issues
|
|
307
434
|
(content below the footer rule, outside the slide, overlaps, clipped text). The assistant gets this as
|
|
308
|
-
text. To check its own work it runs
|
|
435
|
+
text. To check its own work it runs the PinDeck CLI's `layout <slide>...` (`--issues` for the
|
|
309
436
|
issues only). Screenshots are
|
|
310
437
|
only taken when you tick the box or the assistant needs a visual judgement.
|
|
311
|
-
* **One selected backend.** Claude runs as a long-lived stream-json process; Codex runs as a
|
|
312
|
-
app-server over stdio.
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
438
|
+
* **One selected backend.** Claude runs as a long-lived `claude -p` stream-json process; Codex runs as a
|
|
439
|
+
local app-server over stdio. Both run in the deck folder under your own login, with the instructions
|
|
440
|
+
from `lib/system-prompt.md` and the deck's `CLAUDE.md` and `AGENTS.md`. Codex model and effort changes
|
|
441
|
+
reuse the active thread writer and apply to the next turn. Claude changes and provider switches prepare
|
|
442
|
+
a replacement process before retiring the old one. Events from replaced sessions are ignored.
|
|
443
|
+
* **Permissions.** The assistant may read files, edit and create files in the deck folder, and run the
|
|
444
|
+
editor's CLI. Nothing else: no other commands, and no edits to `brand.css`, `vendor/`, `.git/` or, for a
|
|
445
|
+
named deck file, the other decks in its folder. Claude Code loads no settings files and no MCP servers,
|
|
446
|
+
so no allow rule in your own, the deck's or a parent folder's settings widens this. Codex has no shell
|
|
447
|
+
and no file access of its own: it reads and edits through PinDeck's own tools, which apply the same
|
|
448
|
+
rules and refuse symlinks out of the deck. If `brand.css` changes during a turn anyway, the server
|
|
449
|
+
restores it and says so in the chat.
|
|
450
|
+
* **Undo.** The server keeps a copy of every file a change touched, from before and after it (an AI
|
|
451
|
+
turn, which may change, create or delete several files of the deck, or a hand edit). Files over 2 MB
|
|
452
|
+
are not copied: the chat says when a turn changed one, and Undo leaves it as it is. Hidden files,
|
|
453
|
+
`vendor/` and `export/` are not part of undo. Undo and redo walk that history and tell the assistant on
|
|
454
|
+
the next message. They first check that the files are still as that change left them; if something
|
|
455
|
+
else changed them since, they do nothing and say which file differs, rather than overwrite that work.
|
|
456
|
+
* **Saving.** Every file PinDeck writes into the deck is written to a temporary file next to it and then
|
|
457
|
+
renamed into place, so other programs never see half a file. Each change from the editor carries the
|
|
458
|
+
revision of the files it was made on; if the files have changed since, the change is refused, the
|
|
459
|
+
slide reloads, and edited text can be copied from the message to type in again.
|
|
319
460
|
|
|
320
461
|
## Files
|
|
321
462
|
|
|
322
463
|
| File | Purpose |
|
|
323
464
|
|---|---|
|
|
324
|
-
| `server.mjs` | Local server (127.0.0.1 only, random token per run): UI, deck files, events, backend session, undo, CLI endpoints
|
|
465
|
+
| `server.mjs` | Local server (127.0.0.1 only, random token per run, one-time login links): UI, deck files, events, backend session, undo, CLI endpoints, `login`. |
|
|
325
466
|
| `cli.mjs` | `layout`, `shot`, `slides`, `pdf handout` / `pdf presentation` and `pdf-figure` commands for the backends (and for you), and `git-setup`. |
|
|
326
467
|
| `public/` | The editor page, and `bridge.js`, which is injected into the deck in edit mode (never saved to it). |
|
|
327
468
|
| `lib/pptx.mjs`, `lib/zip.mjs`, `lib/xml.mjs` | Reading `.pptx` files (no dependencies): slides, text, shapes and their positions, notes. |
|
|
328
469
|
| `lib/pptx-import.mjs` | Turns PowerPoint slides into slides of the deck: figures, tables, build steps, audio, layout, HTML in the deck's style. |
|
|
329
470
|
| `lib/waveform.mjs` | Waveform SVGs for imported audio. |
|
|
330
471
|
| `lib/omml.mjs` | PowerPoint equations (Office Math) to TeX. |
|
|
331
|
-
| `lib/pptx-render.mjs`, `lib/pdf-render.jxa.js` | Slide pictures: PowerPoint or Keynote saves a PDF
|
|
472
|
+
| `lib/pptx-render.mjs`, `lib/pdf-render.jxa.js` | Slide and PDF pictures: PowerPoint or Keynote (macOS) or LibreOffice (Linux) saves a PDF; macOS PDFKit or Poppler renders pages and regions of it. |
|
|
332
473
|
| `lib/pdf.mjs` | PDF export: reveal.js print layout in headless Chrome, then print to PDF. |
|
|
333
474
|
| `lib/eids.mjs` | Adds the `data-eid` attributes by editing the HTML as text. |
|
|
334
475
|
| `lib/claude.mjs`, `lib/codex.mjs`, `lib/agent-process.mjs` | Backend adapters and JSON-line transport. |
|
|
335
476
|
| `lib/models.mjs`, `lib/agent-tools.mjs` | Model/settings normalization, handover, and restricted Codex tools. |
|
|
477
|
+
| `lib/capabilities.mjs` | What this server can do on this system (macOS, Linux), for the editor, the API, the CLI and the assistant. |
|
|
478
|
+
| `lib/deck-files.mjs` | Atomic writes and the revision of the deck's files. |
|
|
336
479
|
| `lib/system-prompt.md` | What the assistant is told about the editor. |
|
|
337
480
|
| `CONTRIBUTING.md` | How to report bugs and contribute. |
|
|
338
481
|
| `docs/` | Images for this README. |
|
|
@@ -340,17 +483,96 @@ Without PowerPoint or Keynote (or on other systems than macOS) only the text and
|
|
|
340
483
|
|
|
341
484
|
## Current Limitations
|
|
342
485
|
|
|
486
|
+
* reveal.js decks, and decks that name their slides with `<meta name="pindeck:slides">` (see [Decks made
|
|
487
|
+
without reveal.js](#decks-made-without-revealjs)). Any other deck made with another framework (Marp, Slidev,
|
|
488
|
+
impress.js, remark, Spectacle, Shower, deck.js, bespoke.js) is recognised and refused with its name before
|
|
489
|
+
PinDeck changes anything.
|
|
343
490
|
* Text inside inline SVG diagrams cannot be edited in place; pin it and ask the assistant.
|
|
344
491
|
* Parts of an inline SVG move with the whole SVG; inline text (bold, spans) moves with its block.
|
|
345
492
|
* No indenting or outdenting of bullets with `Tab` yet, and `Backspace` at the start of a bullet does not merge it with the one above; ask the assistant for those.
|
|
346
493
|
* Moves are offsets (`translate`), so the space an element came from stays reserved. Ask the assistant to turn hand edits into proper CSS when a layout should really change.
|
|
347
494
|
* The undo history lives on the server and starts fresh when PinDeck restarts.
|
|
495
|
+
* One writer at a time: PinDeck is not made for editing the same deck from two editors or tools at once.
|
|
496
|
+
* Linux (beta): pictures of PDF pages and PowerPoint slides, and waveforms of non-WAV audio, need
|
|
497
|
+
Poppler, LibreOffice and ffmpeg on the server (see [Running on a Linux server](#running-on-a-linux-server-beta)).
|
|
348
498
|
|
|
349
499
|
## Versions
|
|
350
500
|
|
|
501
|
+
* **3.0.0-beta.3**: everything from 2.10.0, for both assistants.
|
|
502
|
+
- Decks made without reveal.js: a deck that names its slides with `<meta name="pindeck:slides">`
|
|
503
|
+
and their size with `<meta name="pindeck:size">` is edited like a reveal.js deck (contributed by
|
|
504
|
+
Zeyu Xu). Claude and Codex are both told what the deck's slides are.
|
|
505
|
+
- Screenshots fill the picture instead of being letterboxed into a shorter page.
|
|
506
|
+
|
|
507
|
+
* **3.0.0-beta.2**: everything from 2.9 and 2.10, with Codex brought up to it.
|
|
508
|
+
- Security: the fix from 2.9. The editor page no longer contains the token, and the deck needs it
|
|
509
|
+
too, so other users of the same machine cannot read either. PinDeck prints a one-time login link at
|
|
510
|
+
start (`pindeck login` prints a new one). Update from beta.1.
|
|
511
|
+
- Linux as a beta, safe saving, Undo/Redo that refuses to overwrite outside changes, decks with their
|
|
512
|
+
own file names, `--asset-root`, `@imports` in the deck's `CLAUDE.md` and `AGENTS.md`, and the other
|
|
513
|
+
2.9 and 2.10 changes (see below).
|
|
514
|
+
- Both assistants may edit and create other files of the deck, never `brand.css`, `vendor/`, `.git/`
|
|
515
|
+
or other decks in the folder; one Undo takes back a whole turn. Codex creates files with a new
|
|
516
|
+
`pindeck_write` tool and edits through PinDeck's safe saving.
|
|
517
|
+
- Claude may run only PinDeck's own commands (layout, shot, slides, pdf, pdf-figure), each named.
|
|
518
|
+
- Starting with `--provider codex` and no saved model now picks Codex's default model, also while
|
|
519
|
+
the model lists are still loading.
|
|
520
|
+
- Stopping PinDeck waits for every backend process, including those that list models.
|
|
521
|
+
|
|
351
522
|
* **3.0.0-beta.1**: Claude and Codex adapters, discovered model/effort menu, explicit provider
|
|
352
523
|
switching with optional handover, curated model lists, a separate effort selector with per-model
|
|
353
|
-
preferences, restricted Codex tools, and separate v3 runtime state.
|
|
524
|
+
preferences, restricted Codex tools, and separate v3 runtime state. On npm as `pindeck@beta`.
|
|
525
|
+
|
|
526
|
+
* **2.10**: decks with their own file names and shared files, decks made without reveal.js, and Claude
|
|
527
|
+
working on the whole deck.
|
|
528
|
+
- A deck file by name: `pindeck path/to/talk.html` (a folder still opens its `index.html`). Several
|
|
529
|
+
decks can share a folder, each with its own chat and undo history.
|
|
530
|
+
- Claude may edit and create other files of the deck (scripts, style sheets, notes), never
|
|
531
|
+
`brand.css`, `vendor/` or other decks in the folder. One Undo takes back everything a turn changed,
|
|
532
|
+
created or deleted; files over 2 MB are not copied, and the chat says so.
|
|
533
|
+
- Files outside the deck folder: `--asset-root <folder>` (or `"assetRoots"` in config.json) serves
|
|
534
|
+
the deck from inside that folder, so paths such as `../shared/style.css` work in the editor,
|
|
535
|
+
screenshots and PDF exports. A symlink that leads out of the deck and its asset roots is refused.
|
|
536
|
+
- Shared instructions: the deck's `CLAUDE.md` and `AGENTS.md` may import other files with `@path`.
|
|
537
|
+
`CLAUDE.md` files in parent folders are still not loaded, on purpose (see the README).
|
|
538
|
+
- Decks made without reveal.js (a script of their own, Shower, deck.js, a hand-written deck): a deck
|
|
539
|
+
that names its slides with `<meta name="pindeck:slides">` (a CSS selector) and their size with
|
|
540
|
+
`<meta name="pindeck:size">` is edited like a reveal.js deck, with screenshots at the slide size and
|
|
541
|
+
one PDF page per slide (contributed by Zeyu Xu). Decks made with other slide frameworks (Marp,
|
|
542
|
+
Slidev, impress.js, remark and others) without these tags are recognised and refused with their
|
|
543
|
+
name, before PinDeck changes anything; the message says how to add the tags.
|
|
544
|
+
- Screenshots fill the picture: headless Chrome lays the page out shorter than its window, which
|
|
545
|
+
left the slide letterboxed in some Chrome versions (reported by Zeyu Xu).
|
|
546
|
+
- Linux: pictures of PDF pages with Poppler, the PowerPoint import with slide pictures from
|
|
547
|
+
LibreOffice, and waveforms of non-WAV audio with ffmpeg, each when installed.
|
|
548
|
+
|
|
549
|
+
* **2.9**: Linux as a beta, and safer editing.
|
|
550
|
+
- Linux (beta): PinDeck runs as a headless server, used from a Mac's browser through an SSH tunnel,
|
|
551
|
+
with Claude Code running on the server. The tunnel may use another local port than the server.
|
|
552
|
+
Screenshots, layout checks without an open editor and PDF export work when Chrome or Chromium is
|
|
553
|
+
found (`PINDECK_LINUX_CHROME=0` turns them off). Features a system cannot provide are switched off,
|
|
554
|
+
with the reason shown in the editor. Changes made to the deck by other programs are seen every
|
|
555
|
+
time, also after a file was replaced by a rename.
|
|
556
|
+
- Security: the editor page no longer contains the token, and the deck needs it too, so other users
|
|
557
|
+
of the same machine cannot read either. PinDeck prints a one-time login link at start
|
|
558
|
+
(`pindeck login` prints a new one), which keeps the token in an HttpOnly cookie named after the
|
|
559
|
+
server's port; headless Chrome logs in the same way, so the token is never on a command line. After
|
|
560
|
+
a restart, log in again with a new link.
|
|
561
|
+
- Saving is atomic; edits made on files that changed meanwhile are refused, and Undo/Redo no longer
|
|
562
|
+
overwrite changes made outside PinDeck.
|
|
563
|
+
- Audio and video play in Safari: deck files are sent with their length and byte ranges, and ogg,
|
|
564
|
+
opus, m4a, aac, flac and mov get their media types.
|
|
565
|
+
- Claude gets the right CLI command for decks outside the PinDeck folder; the example's `CLAUDE.md`
|
|
566
|
+
no longer names a path. The deck's `AGENTS.md` reaches Claude along with its `CLAUDE.md`.
|
|
567
|
+
- macOS: pictures of PDF pages (`pdf-figure`) and of PowerPoint slides have a white page instead of a
|
|
568
|
+
transparent one, so dark text no longer disappears on a dark slide.
|
|
569
|
+
- Screenshots and PDF exports are no longer now and then reported as failed although Chrome wrote them.
|
|
570
|
+
- `git-setup` works for decks behind symlinks or with spaces in their path. The tests run on Linux
|
|
571
|
+
and macOS in CI, including a real Chrome.
|
|
572
|
+
|
|
573
|
+
* **2.8.2**: declares macOS-only support in npm metadata and the README to prevent accidental
|
|
574
|
+
installation on unsupported operating systems. Source launches on other platforms show a support
|
|
575
|
+
notice without opening the deck.
|
|
354
576
|
|
|
355
577
|
* **2.8.1**: fixes from a review. Speaker notes that fail to load leave the field empty and locked, instead
|
|
356
578
|
of showing the previous slide's notes and saving your edits over them. A save that fails because the
|
package/cli.mjs
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
from the top left), as PNG: without a name in the screenshots
|
|
14
14
|
folder to look at, with one saved into the deck
|
|
15
15
|
|
|
16
|
-
node cli.mjs git-setup [deck] keep PinDeck's data-eid ids out of git (no server needed)
|
|
16
|
+
node cli.mjs git-setup [deck] keep PinDeck's data-eid ids out of git (no server needed; a folder or deck file)
|
|
17
17
|
|
|
18
18
|
<slide> is a slide id (data-eid), a slide number (1-based) or "current". */
|
|
19
19
|
|
|
@@ -31,14 +31,17 @@ const arg = rest[0];
|
|
|
31
31
|
on where PinDeck is installed; git config is per clone, so run this once in each clone. */
|
|
32
32
|
if (cmd === "git-setup") {
|
|
33
33
|
const FILTER = `sed 's/ data-eid="[^"]*"//g'`;
|
|
34
|
-
|
|
34
|
+
let deck = path.resolve(arg || ".");
|
|
35
|
+
try { if (!fs.statSync(deck).isDirectory()) deck = path.dirname(deck); } catch {} // a deck file: its folder
|
|
36
|
+
try { deck = fs.realpathSync(deck); } catch {} // git reports the real path; a symlinked path would not match
|
|
35
37
|
const git = (...a) => execFileSync("git", ["-C", deck, ...a], { encoding: "utf8" }).trim();
|
|
36
38
|
let root;
|
|
37
39
|
try { root = git("rev-parse", "--show-toplevel"); }
|
|
38
40
|
catch { console.error(`${deck} is not inside a git repository.`); process.exit(1); }
|
|
39
41
|
git("config", "filter.pindeck-ids.clean", FILTER);
|
|
40
42
|
const rel = path.relative(root, deck).split(path.sep).join("/");
|
|
41
|
-
|
|
43
|
+
// .gitattributes patterns end at whitespace: spaces in folder names are written as [[:space:]]
|
|
44
|
+
const pattern = `${rel ? rel.replace(/\s/g, "[[:space:]]") + "/" : ""}*.html`;
|
|
42
45
|
const attrFile = path.join(root, ".gitattributes");
|
|
43
46
|
const attrs = fs.existsSync(attrFile) ? fs.readFileSync(attrFile, "utf8") : "";
|
|
44
47
|
const line = `${pattern} filter=pindeck-ids`;
|
package/lib/agent-process.mjs
CHANGED
|
@@ -6,6 +6,7 @@ export class AgentProcess {
|
|
|
6
6
|
Object.assign(this, { onMessage, onExit });
|
|
7
7
|
this.pending = new Map(); this.seq = 0; this.closed = false; this.stderr = '';
|
|
8
8
|
this.proc = spawn(binary, args, { cwd, env: { ...process.env, ...env }, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
9
|
+
this.exited = new Promise(resolve => this.proc.once('close', resolve).once('error', () => this.proc.pid === undefined && resolve()));
|
|
9
10
|
readline.createInterface({ input: this.proc.stdout }).on('line', line => {
|
|
10
11
|
if (this.closed) return;
|
|
11
12
|
let m; try { m = JSON.parse(line); } catch { return; }
|
|
@@ -39,11 +40,14 @@ export class AgentProcess {
|
|
|
39
40
|
for (const p of this.pending.values()) { clearTimeout(p.timer); p.reject(error); }
|
|
40
41
|
this.pending.clear(); this.onExit(error);
|
|
41
42
|
}
|
|
43
|
+
/* End of input first (the CLI finishes and exits), SIGTERM after 1.5 s, SIGKILL after 4 s.
|
|
44
|
+
Resolves once the process has exited, so shutdown can wait for it. */
|
|
42
45
|
stop() {
|
|
43
46
|
this.end(new Error('Agent stopped.'));
|
|
44
|
-
this.proc.stdin.destroy(); this.proc.kill('SIGTERM');
|
|
45
47
|
const proc = this.proc;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
if (proc.exitCode !== null || proc.signalCode !== null || proc.pid === undefined) return Promise.resolve();
|
|
49
|
+
proc.stdin.end();
|
|
50
|
+
const term = setTimeout(() => proc.kill('SIGTERM'), 1500), kill = setTimeout(() => proc.kill('SIGKILL'), 4000);
|
|
51
|
+
return this.exited.finally(() => { clearTimeout(term); clearTimeout(kill); });
|
|
48
52
|
}
|
|
49
53
|
}
|
package/lib/agent-tools.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import fs from 'node:fs';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { execFile } from 'node:child_process';
|
|
5
5
|
import { promisify } from 'node:util';
|
|
6
|
+
import { writeAtomic } from './deck-files.mjs';
|
|
6
7
|
const exec = promisify(execFile);
|
|
7
8
|
const text = value => ({ type: 'inputText', text: String(value) });
|
|
8
9
|
const schema = properties => ({ type: 'object', properties, additionalProperties: false });
|
|
@@ -10,22 +11,35 @@ const str = { type: 'string' };
|
|
|
10
11
|
export const renderedImagePath = result => result.match(/^(.+\.png) \(\d+ × \d+ px\)/m)?.[1];
|
|
11
12
|
export const deckTools = [
|
|
12
13
|
{ type: 'function', name: 'pindeck_read', description: 'Read a deck text file, attached image, screenshot, or PDF page. For PDFs supply a 1-based page; returns page text and its rendered image. For text use offset to read beyond the first 120000 characters.', inputSchema: { ...schema({ path: str, page: { type: 'integer', minimum: 1 }, offset: { type: 'integer', minimum: 0 } }), required: ['path'] } },
|
|
13
|
-
{ type: 'function', name: 'pindeck_edit', description: 'Replace one exact unique text occurrence in
|
|
14
|
+
{ type: 'function', name: 'pindeck_edit', description: 'Replace one exact unique text occurrence in a file of the deck folder: the deck file, theme.css or another of its files. Read the file first. brand.css, vendor/, .git/ and other decks in the folder are locked.', inputSchema: { ...schema({ path: str, oldText: str, newText: str }), required: ['path', 'oldText', 'newText'] } },
|
|
15
|
+
{ type: 'function', name: 'pindeck_write', description: 'Create a new file in the deck folder (missing folders are created), or replace all of an existing one. Prefer pindeck_edit for changes to existing files. The same files are locked as for pindeck_edit.', inputSchema: { ...schema({ path: str, content: str }), required: ['path', 'content'] } },
|
|
14
16
|
{ type: 'function', name: 'pindeck_command', description: 'Run a PinDeck command: layout, shot, slides, pdf, or pdf-figure. Pass individual arguments in an array, never a shell command. Use pindeck_read on returned image paths.', inputSchema: { ...schema({ command: { enum: ['layout', 'shot', 'slides', 'pdf', 'pdf-figure'] }, args: { type: 'array', items: str, maxItems: 100 } }), required: ['command', 'args'] } },
|
|
15
17
|
];
|
|
16
|
-
|
|
18
|
+
/* Codex may read the deck, screenshots, attached PDFs and asset roots, and write any file of the deck folder
|
|
19
|
+
except the locked ones: the same rules as Claude's --allowedTools / --disallowedTools. locked: patterns
|
|
20
|
+
such as brand.css or vendor/** (or a function returning them, as the other decks in the folder change);
|
|
21
|
+
env: an object or a function (the server's address is known only once it listens). */
|
|
22
|
+
export function createDeckTools({ deckDir, readDirs = [], cliFile, env, pdfTextFile, locked = ['brand.css', 'vendor/**', '.git/**'] }) {
|
|
17
23
|
const deck = fs.realpathSync(deckDir);
|
|
18
|
-
|
|
24
|
+
// looked up when used: the state folders (screenshots, attachments) are created once the server listens
|
|
25
|
+
const roots = () => [deck, ...readDirs.flatMap(d => { try { return [fs.realpathSync(d)]; } catch { return []; } })];
|
|
19
26
|
const inside = (root, file) => file === root || file.startsWith(root + path.sep);
|
|
27
|
+
const envNow = () => (typeof env === 'function' ? env() : env);
|
|
28
|
+
const isLocked = rel => (typeof locked === 'function' ? locked() : locked)
|
|
29
|
+
.some(p => p.endsWith('/**') ? rel === p.slice(0, -3) || rel.startsWith(p.slice(0, -2)) : rel === p);
|
|
20
30
|
function checked(file, write = false) {
|
|
21
31
|
if (typeof file !== 'string' || !file || file.includes('\0')) throw new Error('Invalid file path.');
|
|
22
32
|
const full = path.resolve(deck, file);
|
|
23
|
-
if (write
|
|
33
|
+
if (write) {
|
|
34
|
+
const rel = path.relative(deck, full).split(path.sep).join('/');
|
|
35
|
+
if (!rel || !inside(deck, full)) throw new Error('Only files inside the deck folder can be edited.');
|
|
36
|
+
if (isLocked(rel)) throw new Error(`${rel} is locked: it cannot be edited in PinDeck.`);
|
|
37
|
+
}
|
|
24
38
|
// Check every component, including missing-file parents, to reject symlink escapes.
|
|
25
39
|
let existing = full;
|
|
26
40
|
while (!fs.existsSync(existing)) { const parent = path.dirname(existing); if (parent === existing) throw new Error('Missing file.'); existing = parent; }
|
|
27
41
|
const real = fs.realpathSync(existing);
|
|
28
|
-
if (!roots.some(root => inside(root, real)) || (write && real !== existing)) throw new Error('File is outside the permitted directories or is a symlink.');
|
|
42
|
+
if (!(write ? [deck] : roots()).some(root => inside(root, real)) || (write && real !== existing)) throw new Error('File is outside the permitted directories or is a symlink.');
|
|
29
43
|
if (write && fs.existsSync(full) && (fs.lstatSync(full).isSymbolicLink() || fs.statSync(full).nlink !== 1)) throw new Error('Linked files cannot be edited.');
|
|
30
44
|
return full;
|
|
31
45
|
}
|
|
@@ -41,7 +55,7 @@ export function createDeckTools({ deckDir, readDirs = [], cliFile, env, pdfTextF
|
|
|
41
55
|
if (!inside(figures, full) || (fs.existsSync(full) && (fs.lstatSync(full).isSymbolicLink() || fs.statSync(full).nlink !== 1))) throw new Error('Linked or invalid output file.');
|
|
42
56
|
}
|
|
43
57
|
}
|
|
44
|
-
const { stdout } = await exec(process.execPath, [cliFile, name, ...args], { cwd: deck, env: { ...process.env, ...
|
|
58
|
+
const { stdout } = await exec(process.execPath, [cliFile, name, ...args], { cwd: deck, env: { ...process.env, ...envNow() }, signal, timeout: 120000, maxBuffer: 2 * 1024 * 1024 });
|
|
45
59
|
return stdout;
|
|
46
60
|
}
|
|
47
61
|
async function read(file, page, offset, signal) {
|
|
@@ -63,7 +77,7 @@ export function createDeckTools({ deckDir, readDirs = [], cliFile, env, pdfTextF
|
|
|
63
77
|
const data = fs.readFileSync(full);
|
|
64
78
|
const mime = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.gif': 'image/gif' }[ext];
|
|
65
79
|
if (mime) return [{ type: 'inputImage', imageUrl: `data:${mime};base64,${data.toString('base64')}` }];
|
|
66
|
-
if (!['.html', '.css', '.md', '.txt', '.svg', '.json', '.js', '.mjs', '.csv'].includes(ext)) throw new Error('Read supports text, PNG/JPEG/WebP/GIF images, and rendered PDF pages. Audio is embedded by path, not transcribed.');
|
|
80
|
+
if (!['.html', '.htm', '.css', '.md', '.txt', '.svg', '.json', '.js', '.mjs', '.csv'].includes(ext)) throw new Error('Read supports text, PNG/JPEG/WebP/GIF images, and rendered PDF pages. Audio is embedded by path, not transcribed.');
|
|
67
81
|
const start = Number.isInteger(offset) && offset >= 0 ? offset : 0;
|
|
68
82
|
return [text(data.toString('utf8').slice(start, start + 120000))];
|
|
69
83
|
}
|
|
@@ -77,8 +91,17 @@ export function createDeckTools({ deckDir, readDirs = [], cliFile, env, pdfTextF
|
|
|
77
91
|
const old = fs.readFileSync(full, 'utf8');
|
|
78
92
|
if (old.indexOf(args.oldText) < 0 || old.indexOf(args.oldText) !== old.lastIndexOf(args.oldText)) throw new Error('oldText must match exactly once. Re-read the file.');
|
|
79
93
|
signal?.throwIfAborted();
|
|
80
|
-
|
|
81
|
-
return [text('Edited ' + path.
|
|
94
|
+
writeAtomic(full, old.replace(args.oldText, () => args.newText));
|
|
95
|
+
return [text('Edited ' + path.relative(deck, full))];
|
|
96
|
+
}
|
|
97
|
+
if (name === 'pindeck_write') {
|
|
98
|
+
const full = checked(args.path, true);
|
|
99
|
+
if (typeof args.content !== 'string' || args.content.length > 2e6) throw new Error('Supply the file content as text (at most 2 MB).');
|
|
100
|
+
if (fs.existsSync(full) && !fs.statSync(full).isFile()) throw new Error('That path is a folder, not a file.');
|
|
101
|
+
signal?.throwIfAborted();
|
|
102
|
+
fs.mkdirSync(path.dirname(full), { recursive: true });
|
|
103
|
+
writeAtomic(full, args.content);
|
|
104
|
+
return [text('Wrote ' + path.relative(deck, full))];
|
|
82
105
|
}
|
|
83
106
|
throw new Error('Unknown PinDeck tool.');
|
|
84
107
|
};
|