pi-studio 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,68 @@
1
+ # Changelog
2
+
3
+ All notable changes to `pi-studio` are documented here.
4
+
5
+ ## [Unreleased]
6
+
7
+ ### Added
8
+ - Single-workspace flow (no mode switching): always-on **Editor** pane + **Response** pane.
9
+ - Explicit annotation scaffold action: **Insert annotation header** (upserts header and source metadata in-editor).
10
+ - Clear top-level critique controls: **Critique editor text** + **Critique focus**.
11
+ - Unified response actions:
12
+ - **Load response into editor** (for non-critique responses)
13
+ - **Load critique (notes)**
14
+ - **Load critique (full)**
15
+ - **Copy response**
16
+ - Independent Markdown/Preview toggles for Editor and right pane.
17
+ - `Auto-update response: On|Off` + `Get latest response` controls for terminal/editor-composability.
18
+ - Source action: **Run editor text** to submit current editor text directly to the model.
19
+ - Active-pane focus mode with keyboard shortcuts (`Cmd/Ctrl+Esc` or `F10` to toggle, `Esc` to exit), plus in-UI footer hint.
20
+ - Theme-aware Studio browser palette derived from active pi theme tokens (bg/text/border/accent + status colors).
21
+ - Server-side `pandoc` preview rendering endpoint for Studio panes (`gfm+tex_math_dollars` → HTML5 + MathML).
22
+ - Math delimiter normalization before preview rendering for `\(...\)` and `\[...\]` syntax (fence-aware).
23
+ - **Load file in editor** action in top controls (browser file picker into editor).
24
+ - README screenshot gallery for dark/light workspace and critique/annotation views.
25
+
26
+ ### Changed
27
+ - Removed Annotate/Critique tabs and related mode state.
28
+ - Right pane now always shows the latest assistant output (reply or critique).
29
+ - Response badge now reports response type + timestamp (`assistant response` / `assistant critique`).
30
+ - Editor sync badge now tracks relation to latest response (`No response loaded`, `In sync with response`, `Edited since response`).
31
+ - Footer continues to show explicit WS phase (`Connecting`, `Ready`, `Submitting`, `Disconnected`) alongside status text.
32
+ - Running text and preparing annotated scaffolds are now separate explicit actions (no hidden header wrapping on send).
33
+ - Critique-specific load actions now focus on notes/full views and are only shown for structured critique responses.
34
+ - Studio still live-updates latest response when assistant output arrives outside studio requests (e.g., manual send from pi editor).
35
+ - Preview pane typography/style now follows the higher-fidelity `/preview-browser` rendering style more closely.
36
+ - Hardened Studio preview HTTP handling and added client-side preview-request timeout to avoid stuck "Rendering preview…" states.
37
+
38
+ ### Fixed
39
+ - Studio boot blocker caused by unescaped preview HTML class-string quotes in inline script output.
40
+ - `hydrateLatestAssistant` now infers response kind from hydrated markdown instead of reusing stale prior kind.
41
+ - Added explicit `return` at end of `send_to_editor_request` handler for safer future handler additions.
42
+ - `respondText` now includes `X-Content-Type-Options: nosniff` for consistency with JSON responses.
43
+ - If `dompurify` is unavailable, preview now falls back to escaped plain markdown instead of injecting unsanitized HTML.
44
+ - Preview sanitization now preserves MathML profile and strips MathML annotation tags to avoid duplicate raw TeX text beside rendered equations.
45
+
46
+ ## [0.1.0-alpha.1] - 2026-02-26
47
+
48
+ Initial alpha baseline.
49
+
50
+ ### Added
51
+ - `/studio` browser workflow with local HTTP + WebSocket server.
52
+ - Startup modes: `/studio`, `/studio --last`, `/studio --blank`, `/studio <path>`.
53
+ - Browser actions: **Apply Document**, **Save As**, **Save Over**, **Send to pi editor**, **Copy**.
54
+ - Studio server controls: `/studio --status`, `/studio --stop`, `/studio --help`.
55
+ - Source-state handling (blank / file / last response) and badge updates.
56
+
57
+ ### Changed
58
+ - More robust loading of last assistant response from session state.
59
+ - Initial document is server-rendered into the page for resilient preload behavior.
60
+ - Last response auto-render now only applies when response appears structured for critique UI.
61
+ - Improved status messaging for connection/format states.
62
+
63
+ ### Fixed
64
+ - WebSocket reject-path HTTP line endings now use proper CRLF (`\r\n`).
65
+ - Browser-side script escaping/runtime issues that could leave UI stuck at boot/connecting.
66
+ - Section parsing logic hardened to avoid fragile regex escaping behavior.
67
+
68
+ [0.1.0-alpha.1]: https://github.com/omaclaren/pi-studio/releases/tag/v0.1.0-alpha.1
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # pi-studio
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.
4
+
5
+ Status: experimental alpha.
6
+
7
+ ## Screenshots
8
+
9
+ **Dark workspace**
10
+
11
+ ![Dark workspace](./assets/screenshots/dark-workspace.png)
12
+
13
+ **Dark critique flow**
14
+
15
+ ![Dark critique flow](./assets/screenshots/dark-critique.png)
16
+
17
+ **Light workspace**
18
+
19
+ ![Light workspace](./assets/screenshots/light-workspace.png)
20
+
21
+ **Dark annotation editing**
22
+
23
+ ![Dark annotation editing](./assets/screenshots/dark-annotation.png)
24
+
25
+ ## Features
26
+
27
+ - Single workspace: Editor (left) + Response (right)
28
+ - **Run editor text** sends editor content as-is
29
+ - **Insert annotation header** adds/updates annotated-reply scaffold
30
+ - **Critique editor text** requests structured critique (auto/writing/code focus)
31
+ - Response load helpers:
32
+ - non-critique: **Load response into editor**
33
+ - critique: **Load critique (notes)** / **Load critique (full)**
34
+ - File actions: **Save As…**, **Save Over**, **Load file in editor**
35
+ - View toggles: `Editor: Markdown|Preview`, `Response: Markdown|Preview`
36
+ - Theme-aware browser UI based on current pi theme
37
+
38
+ ## Commands
39
+
40
+ | Command | Description |
41
+ |---------|-------------|
42
+ | `/studio` | Open studio with last assistant response (fallback: blank) |
43
+ | `/studio <path>` | Open studio with file preloaded |
44
+ | `/studio --last` | Force load from last assistant response |
45
+ | `/studio --blank` | Force blank editor start |
46
+ | `/studio --status` | Show studio server status |
47
+ | `/studio --stop` | Stop studio server |
48
+ | `/studio --help` | Show command help |
49
+
50
+ ## Install
51
+
52
+ From GitHub:
53
+
54
+ ```bash
55
+ pi install https://github.com/omaclaren/pi-studio
56
+ ```
57
+
58
+ From npm:
59
+
60
+ ```bash
61
+ pi install npm:pi-studio
62
+ ```
63
+
64
+ Run without installing:
65
+
66
+ ```bash
67
+ pi -e https://github.com/omaclaren/pi-studio
68
+ ```
69
+
70
+ ## Notes
71
+
72
+ - Local-only server (`127.0.0.1`) with rotating session tokens.
73
+ - One studio request at a time.
74
+ - Studio URLs include a token query parameter; avoid sharing full Studio URLs.
75
+ - Preview panes render markdown via `pandoc` (`gfm+tex_math_dollars` → HTML5 + MathML), sanitized in-browser with `dompurify`.
76
+ - Install pandoc for full preview rendering (`brew install pandoc` on macOS).
77
+ - If `pandoc` is unavailable, preview falls back to plain markdown text with an inline warning.
78
+ - Some screenshots may show the Grammarly browser widget. Grammarly is a separate browser extension and is not part of pi-studio, but it works alongside it.
79
+
80
+ ## License
81
+
82
+ MIT
package/WORKFLOW.md ADDED
@@ -0,0 +1,105 @@
1
+ # pi-studio workflow spec (v0.2 draft)
2
+
3
+ ## Goal
4
+
5
+ Keep Studio simple while supporting both loops:
6
+
7
+ 1. **User → model feedback** (annotated reply)
8
+ 2. **Model → user critique** (structured critique package)
9
+
10
+ Studio uses a **single workspace** (no tab/mode switching):
11
+ - left pane: **Editor**
12
+ - right pane: **Response**
13
+
14
+ ---
15
+
16
+ ## Core actions
17
+
18
+ ## 1) Insert annotation header (optional prep)
19
+
20
+ Adds/updates an `annotated-reply` compatible scaffold in the editor:
21
+
22
+ ```md
23
+ annotated reply below:
24
+ original source: <last model response | file <path> | studio editor>
25
+
26
+ ---
27
+
28
+ <your text>
29
+ ```
30
+
31
+ Studio does **not** auto-send this scaffold; it is an explicit editor transform.
32
+
33
+ ## 2) Run editor text (plain send)
34
+
35
+ Sends current editor text to the model unchanged.
36
+
37
+ ## 3) Critique editor text (structured review request)
38
+
39
+ Critiques current editor text and expects/handles structured output:
40
+ - `## Assessment`
41
+ - `## Critiques` with `**C1**`, `**C2**`, ...
42
+ - `## Document` with `{C1}`, `{C2}`, ... markers
43
+
44
+ ---
45
+
46
+ ## Response handling
47
+
48
+ Right pane always shows the **latest assistant response** (reply or critique).
49
+
50
+ When response is structured critique, Studio enables additional helpers:
51
+ - **Load critique (notes)** (`## Assessment` + `## Critiques`)
52
+ - **Load critique (full)** (`## Assessment` + `## Critiques` + `## Document`)
53
+
54
+ For non-critique responses:
55
+ - **Load response into editor**
56
+
57
+ Always available:
58
+ - **Copy response**
59
+
60
+ ---
61
+
62
+ ## State model (minimal)
63
+
64
+ - `idle`
65
+ - `submitting`
66
+ - `error`
67
+
68
+ Rules:
69
+ - one in-flight request at a time
70
+ - preserve editor draft across all actions
71
+ - latest assistant message can be auto-followed or manually pulled
72
+
73
+ ---
74
+
75
+ ## Required UI elements
76
+
77
+ - Header actions: **Save As…**, **Save Over** (file-backed), **Load file in editor**
78
+ - Header view toggles: `Editor: Markdown|Preview`, `Response: Markdown|Preview`
79
+ - 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**
81
+ - Response actions include `Auto-update response: On|Off` + **Get latest response**
82
+ - Source badge: `blank | last model response | file <path> | upload`
83
+ - Response badge: `none | assistant response | assistant critique` (+ timestamp)
84
+ - Sync badge: `No response loaded | In sync with response | Edited since response`
85
+ - Footer WS/status phases: `Connecting`, `Ready`, `Submitting`, `Disconnected`
86
+
87
+ ---
88
+
89
+ ## Acceptance criteria
90
+
91
+ 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
+ 3. **Insert annotation header** updates the scaffold source metadata without duplicating headers.
94
+ 4. **Critique editor text** runs on current editor text and returns structured package when model complies.
95
+ 5. Structured critique helpers (`Load critique (notes)` / `Load critique (full)`) enable only when critique structure is present.
96
+ 6. Loading response/critique back into editor never loses draft unexpectedly.
97
+ 7. Terminal↔studio roundtrip remains intact (save, editor handoff, reopen).
98
+
99
+ ---
100
+
101
+ ## Non-goals (for now)
102
+
103
+ - Multi-document tabs
104
+ - Multi-user collaboration
105
+ - Heavy schema validation