pi-studio 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  All notable changes to `pi-studio` are documented here.
4
4
 
5
+ ## [0.4.3] — 2026-03-04
6
+
7
+ ### Added
8
+ - **Export right preview as PDF** action in Studio response controls, using server-side pandoc + LaTeX (`xelatex`) for high-quality math/typesetting output.
9
+ - Footer metadata now includes model **and thinking level** (e.g., `provider/model (xhigh)`) plus terminal/session label.
10
+ - Footer braille-dot activity spinner (`⠋⠙⠹…`) driven by existing websocket lifecycle state.
11
+
12
+ ### Changed
13
+ - Footer layout is now two-line and less crowded: status/meta on the left with shortcuts aligned to the right.
14
+ - Status text is now user-facing (removed `WS:` jargon and redundant `Ready` wording).
15
+
5
16
  ## [0.4.2] — 2026-03-03
6
17
 
7
18
  ### Added
@@ -77,7 +88,18 @@ All notable changes to `pi-studio` are documented here.
77
88
 
78
89
  ## [Unreleased]
79
90
 
91
+ ## [0.5.0] — 2026-03-05
92
+
80
93
  ### Added
94
+ - Response history browser controls in Studio response actions (`Prev response` / `Next response` + `History: i/n`) with read-only browsing of prior assistant responses.
95
+ - New response action: **Load response prompt into editor** (loads the user prompt that generated the currently selected history response, when available).
96
+ - Annotation mode toggle (`Annotations: On|Off`) with explicit send behavior:
97
+ - **On**: keep/send `[an: ...]` markers
98
+ - **Off**: strip `[an: ...]` markers before Run/Critique
99
+ - New editor action: **Save .annotated.md** (saves full editor text, including annotation markers).
100
+ - Startup npm update check with terminal notification when installed version is behind npm latest.
101
+ - Footer now shows live context usage (`used / window` and `%`) when available.
102
+ - Footer action: **Compact context** button to trigger pi compaction directly from Studio.
81
103
  - Single-workspace flow (no mode switching): always-on **Editor** pane + **Response** pane.
82
104
  - Explicit annotation scaffold action: **Insert annotation header** (upserts header and source metadata in-editor).
83
105
  - Clear top-level critique controls: **Critique editor text** + **Critique focus**.
@@ -101,6 +123,9 @@ All notable changes to `pi-studio` are documented here.
101
123
  - Client-side Mermaid rendering for fenced `mermaid` code blocks in both Preview panes.
102
124
 
103
125
  ### Changed
126
+ - Browser tab title now mirrors runtime metadata: `pi Studio · <terminal/session> · <model>`.
127
+ - Inserted annotation scaffold now includes explicit syntax line: `annotation syntax: [an: your note]`.
128
+ - Editor preview rendering now follows annotation mode (`On` highlights `[an: ...]` markers; `Off` hides them by stripping before preview render).
104
129
  - Removed Annotate/Critique tabs and related mode state.
105
130
  - Right pane now always shows the latest assistant output (reply or critique).
106
131
  - Response badge now reports response type + timestamp (`assistant response` / `assistant critique`).
@@ -119,6 +144,8 @@ All notable changes to `pi-studio` are documented here.
119
144
  - Hardened Studio preview HTTP handling and added client-side preview-request timeout to avoid stuck "Rendering preview…" states.
120
145
 
121
146
  ### Fixed
147
+ - Fixed runtime model label staleness in Studio footer/state broadcasts by tracking canonical model metadata separately from command context.
148
+ - Tightened editor/raw-highlight scroll synchronization for long documents and viewport changes (extra sync on keyup/mouseup/resize + post-update resync).
122
149
  - Studio boot blocker caused by unescaped preview HTML class-string quotes in inline script output.
123
150
  - `hydrateLatestAssistant` now infers response kind from hydrated markdown instead of reusing stale prior kind.
124
151
  - Added explicit `return` at end of `send_to_editor_request` handler for safer future handler additions.
@@ -127,9 +154,6 @@ All notable changes to `pi-studio` are documented here.
127
154
  - Preview sanitization now preserves MathML profile and strips MathML annotation tags to avoid duplicate raw TeX text beside rendered equations.
128
155
  - Preview now shows an inline warning when Mermaid is unavailable or diagram rendering fails, instead of failing silently.
129
156
 
130
- ### Changed
131
- - Added npm metadata fields (`repository`, `homepage`, `bugs`) so npm package page links to GitHub.
132
-
133
157
  ## [0.1.0-alpha.1] - 2026-02-26
134
158
 
135
159
  Initial alpha baseline.
package/README.md CHANGED
@@ -1,104 +1,57 @@
1
1
  # pi-studio
2
2
 
3
- Experimental extension for [pi](https://github.com/badlogic/pi-mono) that opens a local browser workspace for annotating model responses/files, running edited prompts, and requesting critiques.
3
+ Experimental extension for [pi](https://github.com/badlogic/pi-mono) that opens a local browser workspace with editor and response panes for interacting with pi: annotating model responses/files, running edited prompts, requesting critiques, browsing history, and rendering previews.
4
4
 
5
5
  ## Screenshots
6
6
 
7
- **Markdown workspace — dark** (syntax-highlighted editor + rendered preview with Julia code block, inline math, blockquotes)
7
+ **Dark**
8
8
 
9
- ![Dark workspace](./assets/screenshots/dark-workspace.png)
9
+ ![Pi Studio workspace (dark)](./assets/screenshots/dark-workspace.png)
10
10
 
11
- **Markdown workspace — light**
11
+ **Light**
12
12
 
13
- ![Light workspace](./assets/screenshots/light-workspace.png)
13
+ ![Pi Studio workspace (light)](./assets/screenshots/light-workspace.png)
14
14
 
15
- **Math rendering dark** (LaTeX source → MathML: PDEs, matrices, display equations)
15
+ ## What it does
16
16
 
17
- ![Dark math](./assets/screenshots/dark-math.png)
18
-
19
- **Structured critique dark** (assessment + numbered critiques with rendered math, "Edited since response" sync badge)
20
-
21
- ![Dark critique](./assets/screenshots/dark-critique.png)
22
-
23
- **Math rendering light**
24
-
25
- ![Light math](./assets/screenshots/light-math.png)
26
-
27
- **Mermaid diagrams — dark** (fenced mermaid block → rendered flowchart with theme-aware colors)
28
-
29
- ![Dark mermaid](./assets/screenshots/dark-mermaid.png)
30
-
31
- **Code mode — dark** (TypeScript file loaded with language auto-detected from extension)
32
-
33
- ![Dark code mode](./assets/screenshots/dark-code-mode.png)
34
-
35
- **Code mode — light**
36
-
37
- ![Light code mode](./assets/screenshots/light-code-mode.png)
38
-
39
- **Focus mode — dark** (editor pane full-screen, `Cmd/Ctrl+Esc` or `F10` to toggle, `Esc` to exit)
40
-
41
- ![Dark focus mode](./assets/screenshots/dark-focus-mode.png)
42
-
43
- ## Features
44
-
45
- - Single workspace: Editor (left) + Response (right)
46
- - **Run editor text** sends editor content as-is
47
- - **Insert annotation header** adds/updates annotated-reply scaffold
48
- - **Critique editor text** requests structured critique (auto/writing/code focus)
49
- - Response load helpers:
50
- - non-critique: **Load response into editor**
51
- - critique: **Load critique notes into editor** / **Load full critique into editor**
52
- - File/editor actions: **Save editor as…**, **Save editor**, **Load file content**, **Send to pi editor**, **Load from pi editor**
53
- - View toggles: panel header dropdowns for `Editor (Raw|Preview)` and `Response (Raw|Preview) | Editor (Preview)`
54
- - **Editor Preview in response pane**: side-by-side source/rendered view (Overleaf-style) — select `Right: Editor (Preview)` to render editor text in the right pane with live updates
55
- - Preview mode supports MathML equations and Mermaid fenced diagrams
56
- - **Language-aware syntax highlighting** with selectable language mode:
57
- - Markdown (default): headings, links, code fences, lists, quotes, inline code
58
- - Code languages: JavaScript, TypeScript, Python, Bash, JSON, Rust, C, C++, Julia, Fortran, R, MATLAB, LaTeX, Diff
59
- - Keywords, strings, comments, numbers, and variables highlighted using theme syntax color tokens
60
- - **Diff highlighting**: added/removed lines shown with green/red backgrounds in both raw and preview modes
61
- - Language auto-detected from file extension on file load; manually selectable via `Lang:` dropdown
62
- - Applies to both editor Raw view (highlight overlay) and fenced code blocks in markdown
63
- - Preview mode renders syntax-highlighted code when a non-markdown language is selected
64
- - **LaTeX file support**: `.tex`/`.latex` files detected by content, rendered via pandoc with proper title block (title, author, date, abstract) styling
65
- - **Diff file support**: `.diff`/`.patch` files rendered with coloured add/remove line backgrounds
66
- - **Image embedding**: images in markdown and LaTeX files embedded as base64 data URIs via pandoc `--embed-resources`, with no external file serving required
67
- - **Working directory**: "Set working dir" button for uploaded files — resolves relative image paths and enables "Save editor" for uploaded content
68
- - **Live theme sync**: changing the pi theme in the terminal updates the studio browser UI automatically (polled every 2 seconds)
69
- - Separate syntax highlight toggles for editor and response Raw views, with local preference persistence
70
- - Keyboard shortcuts: `Cmd/Ctrl+Enter` runs **Run editor text** when editor pane is active; `Cmd/Ctrl+Esc` / `F10` toggles focus mode; `Esc` exits focus mode
71
- - Footer status reflects Studio/terminal activity phases (connecting, ready, submitting, terminal activity)
72
- - Theme-aware browser UI derived from current pi theme
73
- - View mode selectors integrated into panel headers for a cleaner layout
17
+ - Opens a two-pane browser workspace: **Editor** (left) + **Response/Editor Preview** (right)
18
+ - Runs editor text directly, or asks for structured critique (auto/writing/code focus)
19
+ - Browses response history (`Prev/Next`) and loads either:
20
+ - response text
21
+ - critique notes/full critique
22
+ - the prompt that generated a selected response
23
+ - Supports an annotation workflow for `[an: ...]` markers:
24
+ - inserts/removes the annotated-reply header
25
+ - shows/hides annotation markers in preview
26
+ - strips markers before send (optional)
27
+ - saves `.annotated.md`
28
+ - Renders Markdown/LaTeX/code previews (math + Mermaid), theme-synced with pi
29
+ - Exports right-pane preview as PDF (pandoc + LaTeX)
30
+ - Shows model/session/context usage in the footer, plus a compact-context action
74
31
 
75
32
  ## Commands
76
33
 
77
34
  | Command | Description |
78
- |---------|-------------|
79
- | `/studio` | Open studio with last assistant response (fallback: blank) |
80
- | `/studio <path>` | Open studio with file preloaded |
81
- | `/studio --last` | Force load from last assistant response |
82
- | `/studio --blank` | Force blank editor start |
35
+ |---|---|
36
+ | `/studio` | Open with last assistant response (fallback: blank) |
37
+ | `/studio <path>` | Open with file preloaded |
38
+ | `/studio --last` | Force last response |
39
+ | `/studio --blank` | Force blank editor |
83
40
  | `/studio --status` | Show studio server status |
84
41
  | `/studio --stop` | Stop studio server |
85
- | `/studio --help` | Show command help |
42
+ | `/studio --help` | Show help |
86
43
 
87
44
  ## Install
88
45
 
89
- From GitHub:
90
-
91
- ```bash
92
- pi install https://github.com/omaclaren/pi-studio
93
- ```
94
-
95
- From npm:
96
-
97
46
  ```bash
47
+ # npm
98
48
  pi install npm:pi-studio
49
+
50
+ # GitHub
51
+ pi install https://github.com/omaclaren/pi-studio
99
52
  ```
100
53
 
101
- Run without installing:
54
+ Run once without installing:
102
55
 
103
56
  ```bash
104
57
  pi -e https://github.com/omaclaren/pi-studio
@@ -106,18 +59,11 @@ pi -e https://github.com/omaclaren/pi-studio
106
59
 
107
60
  ## Notes
108
61
 
109
- - Local-only server (`127.0.0.1`) with rotating session tokens.
110
- - One studio request at a time.
111
- - Pi Studio supports both markdown workflows (model responses, plans, and notes) and code file editing with language-aware syntax highlighting.
112
- - Studio URLs include a token query parameter; avoid sharing full Studio URLs.
113
- - Preview panes render markdown via `pandoc` (`gfm+tex_math_dollars` → HTML5 + MathML), including pandoc code syntax highlighting, sanitized in-browser with `dompurify`. LaTeX files are rendered from `latex` input format with title block styling.
114
- - Images referenced in markdown or via `\includegraphics` in LaTeX are embedded as base64 data URIs when a file path or working directory is available. For uploaded files without a working directory set, a notice suggests setting one.
115
- - Preview markdown/code colors are mapped from active theme markdown (`md*`) and syntax (`syntax*`) tokens for closer terminal-vs-browser parity.
116
- - Mermaid fenced `mermaid` code blocks are rendered client-side in preview mode (Mermaid v11 loaded from jsDelivr), with palette-driven defaults for better theme fit.
117
- - If Mermaid cannot load or a diagram fails to render, preview shows an inline warning and keeps source text visible.
118
- - Preview rendering normalizes Obsidian wiki-image syntax (`![[path]]`, `![[path|alt]]`) into standard markdown images.
119
- - Install pandoc for full preview rendering (`brew install pandoc` on macOS).
120
- - If `pandoc` is unavailable, preview falls back to plain markdown text with an inline warning.
62
+ - Local-only server (`127.0.0.1`) with rotating tokenized URLs.
63
+ - Studio is designed as a complement to terminal pi, not a replacement.
64
+ - Full preview/PDF quality depends on `pandoc` (and `xelatex` for PDF):
65
+ - `brew install pandoc`
66
+ - install TeX Live/MacTeX for PDF export
121
67
 
122
68
  ## License
123
69
 
package/WORKFLOW.md CHANGED
@@ -15,13 +15,14 @@ Studio uses a **single workspace** (no tab/mode switching):
15
15
 
16
16
  ## Core actions
17
17
 
18
- ## 1) Insert annotation header (optional prep)
18
+ ## 1) Insert annotated reply header (optional prep)
19
19
 
20
20
  Adds/updates an `annotated-reply` compatible scaffold in the editor:
21
21
 
22
22
  ```md
23
23
  annotated reply below:
24
24
  original source: <last model response | file <path> | studio editor>
25
+ annotation syntax: [an: your note]
25
26
 
26
27
  ---
27
28
 
@@ -32,7 +33,7 @@ Studio does **not** auto-send this scaffold; it is an explicit editor transform.
32
33
 
33
34
  ## 2) Run editor text (plain send)
34
35
 
35
- Sends current editor text to the model unchanged.
36
+ Sends current editor text to the model. If `Annotations: Hidden`, `[an: ...]` markers are stripped before send.
36
37
 
37
38
  ## 3) Critique editor text (structured review request)
38
39
 
@@ -77,8 +78,8 @@ Rules:
77
78
  - Header actions: **Save As…**, **Save file** (file-backed), **Load file in editor**
78
79
  - Header view toggles: `Left: Editor (Raw|Preview)`, `Right: Response (Raw|Preview) | Editor (Preview)`
79
80
  - Preview mode uses server-side `pandoc` rendering (math-aware) with plain-markdown fallback when renderer is unavailable.
80
- - Editor actions: **Insert annotation header**, **Run editor text**, **Critique editor text** (+ critique focus), **Send to pi editor**, **Copy editor text**
81
- - Response actions include `Auto-update response: On|Off` + **Get latest response**
81
+ - Editor actions: **Insert/Remove annotated reply header**, **Annotations: On|Hidden**, **Strip annotations…**, **Run editor text**, **Critique editor text** (+ critique focus), **Send to pi editor**, **Copy editor text**, **Save .annotated.md**
82
+ - Response actions include `Auto-update response: On|Off`, **Get latest response**, response-history browse (`Prev/Next`), and **Load response prompt into editor**
82
83
  - Source badge: `blank | last model response | file <path> | upload`
83
84
  - Response badge: `none | assistant response | assistant critique` (+ timestamp)
84
85
  - Sync badge: `No response loaded | In sync with response | Edited since response`
@@ -89,7 +90,7 @@ Rules:
89
90
  ## Acceptance criteria
90
91
 
91
92
  1. `/studio --last` opens with editor loaded and no required mode selection.
92
- 2. **Run editor text** sends the current editor content as-is and returns response to right pane.
93
+ 2. **Run editor text** respects annotation mode (`On` send as-is, `Off` strip `[an: ...]`) and returns response to right pane.
93
94
  3. **Insert annotation header** updates the scaffold source metadata without duplicating headers.
94
95
  4. **Critique editor text** runs on current editor text and returns structured package when model complies.
95
96
  5. Structured critique helpers (`Load critique (notes)` / `Load critique (full)`) enable only when critique structure is present.