@notrico/pi-fold 0.0.0-stage → 3.0.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/LICENSE +21 -0
  3. package/README.md +71 -2
  4. package/docs/implementation.md +47 -0
  5. package/docs/performance.md +118 -0
  6. package/docs/renderer-reference.md +110 -0
  7. package/index.ts +53 -0
  8. package/package.json +55 -4
  9. package/scripts/performance-review.mjs +273 -0
  10. package/scripts/preview-work-strip.mjs +84 -0
  11. package/scripts/preview.mjs +232 -0
  12. package/scripts/retained-memory-review.mjs +46 -0
  13. package/scripts/test.mjs +21 -0
  14. package/src/action-intent.ts +93 -0
  15. package/src/display-card.ts +64 -0
  16. package/src/display-line-cache.ts +26 -0
  17. package/src/display-mode.ts +33 -0
  18. package/src/fold-command.ts +61 -0
  19. package/src/inspection.ts +87 -0
  20. package/src/modern-code-content.ts +131 -0
  21. package/src/modern-code-pane.ts +101 -0
  22. package/src/modern-native-tools.ts +79 -0
  23. package/src/modern-prompts-adapter.ts +41 -0
  24. package/src/modern-prompts.ts +185 -0
  25. package/src/modern-recorded-pane.ts +68 -0
  26. package/src/modern-rich-text.ts +48 -0
  27. package/src/modern-skill-prompts.ts +152 -0
  28. package/src/modern-subagent-groups.ts +158 -0
  29. package/src/modern-subagent-messages.ts +176 -0
  30. package/src/modern-subagent-spacing.ts +35 -0
  31. package/src/modern-subagents.ts +52 -0
  32. package/src/modern-thinking-adapter.ts +85 -0
  33. package/src/modern-thinking.ts +236 -0
  34. package/src/modern-tool-content.ts +28 -0
  35. package/src/modern-tool-images.ts +63 -0
  36. package/src/modern-tool-pane.ts +208 -0
  37. package/src/modern-tools.ts +509 -0
  38. package/src/modern-workflows.ts +209 -0
  39. package/src/native-method-chain.ts +31 -0
  40. package/src/permission-presentation.ts +280 -0
  41. package/src/recorded-summary.ts +13 -0
  42. package/src/work-strip-subagents.ts +221 -0
  43. package/src/work-strip-view.ts +104 -0
  44. package/src/work-strip.ts +443 -0
  45. package/tests/action-intent.test.mjs +44 -0
  46. package/tests/codemode.test.mjs +365 -0
  47. package/tests/display-cache-lifecycle.test.mjs +55 -0
  48. package/tests/display-line-cache.test.mjs +48 -0
  49. package/tests/display-mode.test.mjs +25 -0
  50. package/tests/fixtures/preview-fixture.ts +81 -0
  51. package/tests/fold-command.test.mjs +150 -0
  52. package/tests/fold-shortcut.test.mjs +143 -0
  53. package/tests/input-focus.test.mjs +95 -0
  54. package/tests/inspection.test.mjs +50 -0
  55. package/tests/mixed-thinking.test.mjs +319 -0
  56. package/tests/modern-prompts.test.mjs +84 -0
  57. package/tests/modern-skill-prompts.test.mjs +174 -0
  58. package/tests/modern-subagent-groups.test.mjs +132 -0
  59. package/tests/modern-subagent-messages.test.mjs +137 -0
  60. package/tests/modern-thinking.test.mjs +202 -0
  61. package/tests/modern-tools.test.mjs +908 -0
  62. package/tests/modern-workflows.test.mjs +147 -0
  63. package/tests/ordinary-prompts.test.mjs +167 -0
  64. package/tests/permission-presentation.test.mjs +257 -0
  65. package/tests/preview-example.test.mjs +171 -0
  66. package/tests/reload-lifecycle.test.mjs +161 -0
  67. package/tests/subagent-spacing.test.mjs +34 -0
  68. package/tests/test-runtime.mjs +58 -0
  69. package/tests/work-strip-final-surface.test.mjs +271 -0
  70. package/tests/work-strip-hierarchy.test.mjs +258 -0
  71. package/tests/work-strip-preview.test.mjs +120 -0
  72. package/tests/work-strip-spacing.test.mjs +208 -0
  73. package/tests/work-strip-subagents.test.mjs +236 -0
  74. package/tests/work-strip.test.mjs +148 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,129 @@
1
+ # Release notes
2
+
3
+ ## 3.0.0 — Pi Fold
4
+
5
+ - Rename the public interface to Pi Fold and combine display mode, collapse/expand, and shortcut controls under `/fold`.
6
+ - Remove `/compact-rendering` and `/work` without aliases. Use `/fold on|off|toggle|status`, `/fold collapse|expand`, and `/fold shortcut on|off`. `/inspect` and Ctrl+Alt+W remain available.
7
+ - Rename the npm package to `@notrico/pi-fold` and the repository to `pi-fold`. Remove the old package installation before installing the new name.
8
+ - Make Ctrl+Alt+W toggle completed work: collapse if any section is expanded, otherwise expand. Active and waiting sections stay unchanged.
9
+ - Refresh public documentation and remove private deployment history.
10
+ - Keep thinking, DDD, and tool expansion equally compact. Omit an exactly repeated opening title only when the full summary remains visible; preserve source text and paragraph spacing.
11
+ - Explicit collapse resets nested actions, Details, thinking, workflows, codemode, and retained attention panes in completed or historical work. Automatic folding preserves manual pane state.
12
+
13
+ ## 2.5.3 — Stable live alignment and clearer source layout
14
+
15
+ - Keep live work commentary indented until the turn settles; place confirmed final replies at the main margin.
16
+ - Separate runtime modules, tests, scripts, and documentation. Keep the root Pi entry point and update preview, benchmark, and package paths.
17
+
18
+ ## 2.5.2 — Less work on redraw
19
+
20
+ - Cache repeated formatted lines within entry and accounting limits; clear the shared cache at extension lifecycle boundaries.
21
+ - Avoid repeated completed-work summaries and temporary arrays during redraw. Share the display-mode contract across renderers.
22
+ - Keep the concise README and add measured layout overhead. Include the performance report and reproduction scripts in the package.
23
+ - Preserve the existing UI behavior; the live-commentary alignment change remains separate.
24
+
25
+ ## 2.5.1 — Public npm package
26
+
27
+ - Add npm publication metadata and the Pi gallery discovery keyword.
28
+ - Document standalone Git installation, removal, compatibility, and quick controls.
29
+ - Keep renderer behavior identical to 2.5.0.
30
+
31
+ ## 2.5.0 — Clearer conversation hierarchy
32
+
33
+ - Keep work children indented, including visible questions, decisions, failures and DDD notices. Use quieter routine headings and collapse-all controls.
34
+ - Omit work strips for replies without execution activity. Preserve elapsed labels where recorded and use Work details when duration is unavailable.
35
+ - Give settled final replies a faint neutral surface with the same vertical padding as user prompts. Preserve native content and consistent outer spacing.
36
+ - Collapse long prompts around their original opening and ending. Combine explicit skill invocation and optional user text into one blue prompt card with inspectable skill content.
37
+ - Preserve native fallback, prompt-jump anchors, editor controls, images, reload and resume. All 24 suites passed on both test machines; the user approved both terminal previews.
38
+
39
+ ## 2.4.0 — Work strips
40
+
41
+ - Keep intermediate replies and compact activity visible during execution, then fold completed work under one elapsed-time strip while retaining the final reply and decision evidence.
42
+ - Derive the live step from recorded content. Wait for native settlement and the prompt's background descendants; preserve manual expansion and defer automatic folding in scrollback.
43
+ - Compact DDD notices with full inspection and conservative handling of missing severity. Retain chronological expansion, nested inspection, native-off behavior, and editor controls.
44
+ - Preserve native outside spacing with each visible block, including skill cards and summaries. Drop gaps with hidden blocks and retain internal card spacing without adding duplicate gaps.
45
+ - Store validated display-only completion records for resume/reload. Older turns without records remain open. Coordinate execution status with Pi Statusline without changing saved footer preferences.
46
+ - Add isolated native-runtime playback and regressions for settlement, descendants, replay, decisions, focus, and scrollback. All 20 suites passed on both test machines. The user approved both terminal previews on 20 October 2026.
47
+
48
+ ## 2.3.3 — Single-round thinking summaries
49
+
50
+ - Give a single recorded thinking round a short extractive summary and an aligned disclosure arrow. Expand directly into bounded content without a second round heading.
51
+ - Compact one hidden thinking run beside a visible reply while preserving native reply rendering, ordering, and terminal markers. Keep native fallback for unsupported layouts, failures, and expansion overrides.
52
+ - Track shared streaming content changes and retain grouping boundaries, mouse controls, editor focus, and lifecycle cleanup. All 16 suites passed on both test machines; the user approved both terminal previews.
53
+
54
+ ## 2.3.2 — Preserve compact history after reload
55
+
56
+ - Keep historical tool rows attached when Pi rebuilds chat before the new renderer receives session start. Restore compact Bash, MCP, and codemode history after `/reload`.
57
+ - Reconnect replayed rows after rebuilding groups. Retain stale-row protection for session switches and shutdown.
58
+ - Add a regression using native chat replay and tool components, with synthetic records and no tool execution.
59
+
60
+ ## 2.3.1 — Expand inline images
61
+
62
+ - Keep image-bearing codemode results in the compact summary and bounded text pane, with image counts and metadata. Preserve Pi's native image components and recorded content.
63
+ - Remove the duplicate heading on standalone image reads. Preserve separate image actions and native rendering when compact mode is off.
64
+ - Show native inline images only in expanded compact blocks, with bounded preview dimensions and a readable fallback when native images are disabled or unavailable. Preserve exact native rendering when compact mode is off.
65
+ - Remove repeated image announcements, question/answer headings, and codemode timing. Keep exact image acknowledgements and metadata in Details.
66
+ - Add native-component regression cases and visible synthetic image examples for terminal review.
67
+
68
+ ## 2.3.0 — Workflow folding and operation summaries
69
+
70
+ - Collapse complete assistant workflow fences without changing their execution source or surrounding prose. Expand through the existing inspection controls.
71
+ - Add short recorded-operation summaries to ordinary action groups and codemode; retain counts, error states, exact arguments, and output. No model calls are added.
72
+ - Remove the duplicate codemode heading from expanded content.
73
+
74
+ ## 2.2.1 — Guide lookup grouping
75
+
76
+ - Collapse consecutive completed subagent guide calls into one guide-lookup group. Keep runtime updates in their own groups and preserve failures, running calls, and visible conversation boundaries.
77
+ - Show the requested guide topic in each expandable action instead of the generic Result recorded label. Exact content and arguments remain available.
78
+
79
+ ## 2.2.0 — Grouped subagent history
80
+
81
+ - Group consecutive routine subagent updates and combine explicitly matched decision exchanges; keep failures and pending decisions separate. Use compact expandable rows for subagent calls and recognized asynchronous notices. Keep native Fleet and execution controls.
82
+ - Distinguish launch acknowledgements, queued steering, delivery, decisions, replies, and completion. Preserve exact recorded content and Details.
83
+ - Add native fallback, replay, lifecycle, focus, and bounded-output checks plus inert preview examples.
84
+
85
+ ## 2.1.2 — Distinct codemode labels
86
+
87
+ - Use native teal for the `codemode` label, with muted nested-call counts and timing. Keep ordinary action headings blue.
88
+ - Keep failed scripts red and handled nested problems in warning color. Preserve expansion, focus, native syntax colors, and exact records.
89
+ - Retain factual count-based summaries when the recorded call has no intention metadata. No extra model calls or inferred script descriptions.
90
+
91
+ ## 2.1.1 — Clear question history and output categories
92
+
93
+ - Highlight recorded answers inline with their options and tighten question spacing. Preserve custom answers and meaningful diagnostics without duplicate Answer sections.
94
+ - Use bold purple question headings aligned with other actions, without a background or vertical rail. Keep green selected answers, blue ordinary action/`codemode` headings, muted thinking, and red failures.
95
+ - Preserve distinct keyboard focus, native subagent/Fleet rendering, exact transcripts, bounded inspection, and existing controls.
96
+ - Use Pi's `codemode` spelling in current documentation and preview text.
97
+
98
+ ## 2.1.0 — Content-first inspection and bounded code mode
99
+
100
+ - Show useful action content first, keep exact arguments under independently expandable Details, and remove gaps between sibling actions. Preserve readable question history.
101
+ - Render supported code-mode scripts, nested calls, errors, output, timing, and costs incrementally as the user scrolls. Retain all recorded content and metadata.
102
+ - Preserve editor return, native-off display, and fallback for unsupported result shapes. Handle streaming updates, theme changes, and timer cleanup.
103
+ - Aggregate result blocks/calls once per update; cache visited rows. Long multiline syntax colors can differ at chunk boundaries.
104
+ - Verify the combined preview in a local terminal and over mosh/tmux before publication.
105
+
106
+ ## 2.0.1 — Readable inspection and concise summaries
107
+
108
+ - Show compact operation labels for embedded scripts and short failure categories. Keep exact commands and errors in expanded details.
109
+ - Label groups as `N actions` and omit redundant success labels, including code mode.
110
+ - Restore native syntax colors for expanded source, commands, and diffs. Format Markdown files and recorded thinking while keeping shell output literal.
111
+ - Keep formatting work bounded to visited content and preserve transcript data, focus controls, and separate native code-mode inspection.
112
+
113
+ ## 2.0.0 — Compact activity for Pi 1.3.0
114
+
115
+ - Group consecutive successful completed calls behind neutral one-line summaries. Running calls, failures, questions, and background notices remain separate.
116
+ - Expand individual actions inline with bounded scrolling. Single actions open directly to their output; questions retain readable question, choices, answer, and status without raw object dumps.
117
+ - Give code mode a separate collapsible summary with script outcome and nested-call status. Preserve native highlighted code, results, timing, and cost inside the expanded viewport.
118
+ - Group recorded thinking into independently expandable rounds. Collapse recognized prompt templates with descriptions or excerpts; retain the original text on expansion.
119
+ - Add `/inspect` with a native picker, visible focus, and viewport reveal. Typing or Escape returns control to the editor; mouse expansion does not capture prompt submission. Keep `/compact-rendering` and retire legacy `/blocks`.
120
+ - Preserve stock pi-subagents/Fleet UI, native images, stored messages, model inputs, and execution policy.
121
+ - Add a permission presentation interface with concise summaries, exact lazy Details, and a single approval decision. Caller approval policies remain unchanged.
122
+ - Fix synchronous redraw loops, native component cache reuse, shell timer cleanup, and misleading completion labels.
123
+ - Replace Pi 1.1 adapters with guarded Pi 1.3 integration, native regression suites, and an isolated preview with no model, shell, or database execution.
124
+
125
+ Expanded code-mode content uses native formatting internally; its visible viewport is bounded. Native compatibility guards fall back to stock display on unsupported shapes.
126
+
127
+ ## 1.19.3
128
+
129
+ Previous Pi 1.1 implementation. Its source and release history remain available in Git.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 notrico
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,72 @@
1
- # Temporary Holding Version
1
+ # Pi Fold
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Follow the work. Unfold the details.
4
+
5
+ A Pi extension that keeps progress visible while the agent works, then folds the steps into a **Worked for …** strip. The final reply stays in view, and you can expand the strip whenever you want the details.
6
+
7
+ - **Follow the work.** Tool calls, thinking, and subagent updates stay organized under each prompt.
8
+ - **Find the answer.** Final replies get a subtle background. Questions, decisions, and unresolved errors remain visible when work is folded.
9
+ - **Open what you need.** Inspect tool output, code, diffs, and recorded images. Long prompts and skill text fold too.
10
+
11
+ Replies without tool or subagent activity skip the work strip.
12
+
13
+ ## Install
14
+
15
+ Tested with **Pi 1.3.0** and **Node.js 22.19.0 or later**. Other Pi versions are not verified; version-sensitive features fall back to native rendering.
16
+
17
+ ```sh
18
+ pi install npm:@notrico/pi-fold@3.0.0
19
+ ```
20
+
21
+ Restart Pi, or run `/reload` when the session and its background work are idle.
22
+
23
+ If a configuration manager already installs this extension, update it there to avoid duplicate copies.
24
+
25
+ ## Everyday controls
26
+
27
+ | To… | Use… |
28
+ | --- | --- |
29
+ | Open the Pi Fold menu | `/fold` |
30
+ | Enable Pi Fold | `/fold on` |
31
+ | Open a block | Click its arrow, or use `/inspect` |
32
+ | Return to typing | Esc |
33
+ | Toggle completed work sections | Ctrl+Alt+W |
34
+ | Collapse work sections | `/fold collapse` |
35
+ | Expand work sections | `/fold expand` |
36
+ | Show native Pi rendering | `/fold off` |
37
+
38
+ Use `/fold status` to check the mode. `/fold toggle` switches between Pi Fold and native display.
39
+
40
+ Ctrl+Alt+W collapses completed work if any section or retained detail pane is expanded; otherwise it expands completed work. Collapse also closes manually opened actions and details. After collapse, expanding a work section starts with its detail panes closed. Active and waiting sections stay unchanged by collapse and the shortcut. To disable the shortcut, use `/fold shortcut off`.
41
+
42
+ Upgrading from `pi-compact-renderer`? Remove its existing install source before installing `@notrico/pi-fold` so Pi loads one copy. Version 3 replaces `/compact-rendering` and `/work` with `/fold`; the old commands are removed.
43
+
44
+ ## A few things to know
45
+
46
+ This changes the transcript's appearance. It preserves the original messages and does not reduce token usage or make extra model calls.
47
+
48
+ Image previews depend on your terminal. When images cannot display, you get a text fallback. Keyboard inspection works over mosh/tmux.
49
+
50
+ Compact thinking groups need Pi's `hideThinkingBlock: true` setting. Ctrl+T still switches to Pi's full thinking display. Compatibility with other transcript-rendering extensions has not been verified.
51
+
52
+ For detailed behavior, all keyboard controls, and test/preview instructions, see the [renderer reference](https://github.com/rrrrrrrrrricoxi/pi-fold/blob/main/docs/renderer-reference.md).
53
+
54
+ ## Performance
55
+
56
+ Across two benchmark machines, median warm layout for a synthetic 400-turn transcript fell from **9.5–12.6 ms to 3.3–4.9 ms**. Added layout time versus compact rendering disabled was **3.1–4.6 ms**; retained fixture memory increased by about **0.14 MiB** versus the prior renderer.
57
+
58
+ Measured on macOS arm64 with Pi 1.3.0, Node 26.11.1, and a 100-column layout. These are layout benchmarks, not live typing or terminal latency. See [methods, cache limits, and results](https://github.com/rrrrrrrrrricoxi/pi-fold/blob/main/docs/performance.md).
59
+
60
+ ## Development
61
+
62
+ Runtime modules live in `src/`, regression checks in `tests/`, preview and benchmark runners in `scripts/`, and detailed notes in `docs/`. `index.ts` is the Pi entry point.
63
+
64
+ Run `npm test`, `npm run preview:work`, or `npm run benchmark`. See the [renderer reference](docs/renderer-reference.md) for runtime setup.
65
+
66
+ ## Uninstall
67
+
68
+ ```sh
69
+ pi remove npm:@notrico/pi-fold@3.0.0
70
+ ```
71
+
72
+ [MIT license](LICENSE) · [Report an issue](https://github.com/rrrrrrrrrricoxi/pi-fold/issues)
@@ -0,0 +1,47 @@
1
+ # Pi Fold implementation
2
+
3
+ Pi Fold changes transcript presentation. It does not replace tool executors, change permissions, rewrite recorded messages, or make model calls. See the [reference](renderer-reference.md) for display behavior and the [performance report](performance.md) for measured overhead.
4
+
5
+ ## Entry point and lifecycle
6
+
7
+ `index.ts` creates one display mode and registers the tool, thinking, prompt, skill, workflow, permission, subagent, work-strip, and inspection modules. Registrations return cleanup functions. Disposal runs them in reverse order and clears the shared display cache.
8
+
9
+ Adapters that depend on native component internals are guarded for Pi 1.3.0 and expected component shapes. Unsupported shapes retain native presentation. Mode changes, session switches, reloads, and shutdown release inspection focus and timers. Registration ownership prevents duplicate adapters after reload.
10
+
11
+ ## Transcript projection
12
+
13
+ `src/work-strip.ts` projects native chat children during rendering and preserves the canonical child list. Native lifecycle hooks attach message identity and distinguish replay from live input. Live commentary stays indented until a terminal reply is confirmed. Only that final reply receives the neutral padded surface at the main margin.
14
+
15
+ `src/work-strip-subagents.ts` tracks prompt-owned root runs and descendants through read-only status events. Dispatch completion is not child completion. Unknown or omitted child status remains unresolved. `src/work-strip-view.ts` validates display-only completion entries against the current branch and owns each strip's disclosure state.
16
+
17
+ Completion requires a terminal assistant message with visible text and settled background work. Empty terminal responses do not promote earlier commentary to a final reply. Older turns without completion evidence show Work details without an invented duration. Manual expansion and scrollback take precedence over automatic folding.
18
+
19
+ Ctrl+Alt+W toggles eligible completed and historical sections together. If any is expanded, it collapses them; otherwise it expands them. Working and waiting sections stay unchanged. Explicit `/fold collapse` and `/fold expand` remain separate controls. Native shortcut dispatch preserves dialog and editor input ownership.
20
+
21
+ Native top-level spacers belong to the next canonical content block. Projection retains them with visible blocks and discards them with hidden blocks. Components that own internal spacing retain it. Expanded work children share an indentation level; final replies and user prompts share the main gutter.
22
+
23
+ ## Bounded rendering
24
+
25
+ Tool panes retain original source and result references. Ordinary source formatting is bounded to 2,048 characters per call; codemode formats visited text in chunks of at most 1,024 characters. Painting advances through a bounded viewport instead of formatting all output. Long multiline syntax and Markdown structure can differ across chunk boundaries.
26
+
27
+ Codemode validates result shapes and computes scalar call/count/cost aggregates once per update revision. This pass is proportional to block and nested-call counts, separate from viewport painting. Repaint and unchanged invalidation reuse aggregates and row caches; width, theme, and result changes invalidate the affected views. Shared cache accounting and retention limits are described in the performance report.
28
+
29
+ Known errors, warnings, and truncation indicators remain visible. Exact arguments, acknowledgements, diagnostics, and raw output remain inspectable. Unsupported result shapes use native presentation. Image previews use native capability detection and show a text fallback when the terminal cannot display images.
30
+
31
+ ## Input ownership
32
+
33
+ Only explicit inspection acquires keyboard focus. Escape or unhandled editing input releases inspection before forwarding to the native editor. Mouse expansion does not capture editor input. `/inspect` uses the native picker and reveals the selected block through the existing scroll view.
34
+
35
+ Permission presentation preserves the original decision and policy. Its Details view uses Left/Right paging because native fullscreen handling can intercept PageUp/PageDown before extension input. Ordinary transcript panes use their own advertised navigation keys.
36
+
37
+ ## Compatibility identifiers
38
+
39
+ The package and public name are `@notrico/pi-fold` and Pi Fold. Existing `compact-renderer:*` event names, global symbols, and saved completion-entry identifiers remain stable. They are integration and persistence contracts, not display labels. Renaming them would disconnect companion extensions, lose saved display evidence, or prevent an older registration from being disposed during reload.
40
+
41
+ The `compact-renderer:work-strip:v1` and query events let a footer temporarily omit duplicate execution state and timing. Disposal releases ownership without changing saved footer preferences. The benchmark report schema and inspection widget keys also remain stable for existing consumers and cleanup.
42
+
43
+ ## Verification
44
+
45
+ `tests/` exercises native components and isolated fixtures, including lifecycle changes, native fallback, input focus, mixed work states, spacing, ANSI surfaces, Unicode, narrow widths, images, and bounded large-output inspection. `scripts/preview-work-strip.mjs` runs an isolated native TUI with recorded examples and synthetic lifecycle playback. It does not run models, tools, shell commands, or network requests.
46
+
47
+ Automated checks do not replace terminal appearance review. Stage the packed candidate and review keyboard interaction, expansion, final replies, and editor restoration before publishing UI changes.
@@ -0,0 +1,118 @@
1
+ # Renderer performance pass
2
+
3
+ Evaluated against renderer 2.5.0, commit `848a4a5`, with Pi 1.3.0 and Node
4
+ 26.11.1 on two macOS arm64 machines, labeled A and B below. No installed configuration was changed.
5
+
6
+ ## Changes
7
+
8
+ - Track the latest work turn without allocating an array of all turns.
9
+ - Search turn rows backwards without copying and reversing them.
10
+ - Do not calculate summaries for completed/history headings, which do not display
11
+ summaries. Continue calculating live, waiting, interrupted and error summaries.
12
+ - Cache repeated activity-line truncation and background formatting by exact
13
+ input, width and styling bytes. A theme change in place therefore changes the
14
+ key. Native Markdown, layout, image handling and mouse coordinates still run.
15
+ - Retain strings only. Limit the shared cache to 4,096 entries and 2 MiB of
16
+ accounting charges, including input/output strings and an entry allowance.
17
+ This is not a hard JavaScript heap limit. Oversized lines bypass the cache.
18
+ - The top-level extension owns cache cleanup at registration, session transitions
19
+ and disposal. Work strips no longer manage this shared resource. Evicted text
20
+ is reformatted when needed. Original transcript content is never removed.
21
+ - Reuse the shared `DisplayMode` interface in all eight display consumers instead
22
+ of repeating its definition.
23
+
24
+ Production changes: 77 added lines and 27 removed lines, or 50 net new lines.
25
+ The cache is 26 lines. Tests and measurement scripts are counted separately.
26
+
27
+ ## Layout results
28
+
29
+ Seven samples, eight warm redraws per sample, width 100. Values below are the
30
+ median batch duration divided by eight, in milliseconds per redraw. The latest
31
+ comparison uses a shared source-module graph, matching extension singleton
32
+ ownership. Both baseline and optimized source use the same measurement scripts.
33
+
34
+ | Host | Turns | Before | After | Compact disabled, after |
35
+ | --- | ---: | ---: | ---: | ---: |
36
+ | Machine A | 48 | 1.642 | 0.479 | 0.054 |
37
+ | Machine A | 400 | 12.649 | 4.904 | 0.301 |
38
+ | Machine B | 48 | 1.093 | 0.411 | 0.031 |
39
+ | Machine B | 400 | 9.514 | 3.295 | 0.207 |
40
+
41
+ At 400 turns, added median layout time is 4.603 ms on Machine A and 3.088 ms on Machine B.
42
+ Both meet the initial 5 ms target in this fixture. The largest of seven optimized
43
+ batch samples, divided by eight, was 5.294 ms on Machine A and 3.664 ms on Machine B. These
44
+ are batch measurements, not individual-frame latency percentiles.
45
+
46
+ ## Retained memory
47
+
48
+ Five fixture samples per case, explicit GC, with an event-loop yield before
49
+ measuring disposal. Compare the same harness against baseline and optimized
50
+ source. Figures include native fixture components and renderer state.
51
+
52
+ | Host | Compact fixture | Before | After | Added |
53
+ | --- | --- | ---: | ---: | ---: |
54
+ | Machine A | 48 turns | 0.736 MiB | 0.757 MiB | 0.021 MiB |
55
+ | Machine A | 400 turns | 5.663 MiB | 5.806 MiB | 0.143 MiB |
56
+ | Machine B | 48 turns | 0.736 MiB | 0.757 MiB | 0.021 MiB |
57
+ | Machine B | 400 turns | 5.663 MiB | 5.805 MiB | 0.142 MiB |
58
+
59
+ A separate warmed formatting stress case retained approximately 2.16 MiB after
60
+ 10,000 distinct lines and remained approximately 2.16 MiB after another 20,000.
61
+ After clearing the cache, the measured heap delta was under 10 KiB on both hosts.
62
+ This supports bounded retention for the tested case; it is not a general leak
63
+ proof or a guarantee about V8 memory accounting.
64
+
65
+ ## Verification
66
+
67
+ All 26 regression suites pass on both hosts. Coverage includes streaming work
68
+ settlement, subagents, prompt/skill disclosure, keyboard focus, native reload,
69
+ spacing, neutral final surfaces, Unicode, ANSI resets and images.
70
+
71
+ The cache tests cover reuse, entry/byte limits, eviction, oversized bypass,
72
+ clearing, changing content, terminal widths, selection and in-place theme
73
+ changes. The root lifecycle test uses actual extension registration to verify
74
+ registration cleanup, session transitions, shutdown, stale callbacks and failed
75
+ startup. It also verifies reuse of the same shared cache between redraws. Synthetic transcript output hashes match baseline exactly for both
76
+ 48- and 400-turn fixtures, with compact mode enabled and disabled.
77
+
78
+ Run:
79
+
80
+ ```sh
81
+ npm test
82
+ node --expose-gc scripts/performance-review.mjs --samples 7 --scales 48,400
83
+ node --expose-gc scripts/retained-memory-review.mjs
84
+ ```
85
+
86
+ For baseline comparison, use the measurement scripts in `renderer/` and the root `test-runtime.mjs` from tag `v2.5.2`. Copy those files into a separate checkout of `848a4a5`; that helper matches the baseline’s flat source layout. Keep baseline production sources unchanged. The commands above run the current layout.
87
+
88
+ ## Limits and deferred work
89
+
90
+ These measurements cover synthetic synchronous component layout, not terminal
91
+ transport, emulator painting, live typing latency, model calls or tool execution.
92
+ The disabled comparison still has extension registration wrappers installed.
93
+ The timing fixture registers tools and work strips, not every renderer feature.
94
+ Automated image regressions pass, but image-heavy performance was not measured.
95
+ The memory case is not a long-running interactive-session soak test.
96
+
97
+ The full-history projection scan remains. Broad grouping changes, native
98
+ compatibility-layer consolidation, image-cache changes and input scheduling are
99
+ deferred: this pass meets the initial measured target without changing those
100
+ contracts or the UI design.
101
+
102
+ ## Pre-integration cleanup decisions
103
+
104
+ Implemented the two changes with clear ownership benefits and low behavior risk:
105
+
106
+ 1. The extension root owns shared cache lifecycle; individual display features
107
+ no longer clear a resource used by other features.
108
+ 2. Display consumers use the existing `DisplayMode` type. This adds no runtime
109
+ behavior and keeps the contract in one place.
110
+
111
+ Deferred adapter unification and focus routing. Those changes require separate
112
+ checks for wrapper removal order, reload, keyboard routing and dialog ownership.
113
+ No measured result requires them in this patch.
114
+
115
+ Keep separate tool/code/recorded-text panes and distinct grouping rules: their
116
+ interaction and boundary rules differ. Keep the bounded cache, native fallbacks
117
+ and subagent monitor. Combining these solely to reduce file or line counts would
118
+ move complexity into conditionals rather than remove it.
@@ -0,0 +1,110 @@
1
+ # Pi Fold reference
2
+
3
+ Detailed display behavior, keyboard controls, integration notes, and development previews. For installation and a quick introduction, see the [README](../README.md).
4
+
5
+ ## Git installation
6
+
7
+ As an alternative to npm:
8
+
9
+ ```sh
10
+ pi install git:github.com/rrrrrrrrrricoxi/pi-fold@v3.0.0
11
+ ```
12
+
13
+ Remove it with the matching source:
14
+
15
+ ```sh
16
+ pi remove git:github.com/rrrrrrrrrricoxi/pi-fold@v3.0.0
17
+ ```
18
+
19
+ ## Display
20
+
21
+ - Questions use a bold purple heading, aligned with ordinary action headings, without a background or vertical rail. Recorded answers use a green checkmark inline with the options. Ordinary action headings stay blue. The `codemode` label uses native teal (`syntaxVariable`), while counts and timing stay muted; handled nested problems retain warning color; thinking headings stay muted and failures stay red. Expanded content remains unfilled. Keyboard focus has its own selection highlight. User prompts keep their blue surface. Subagent transcript activity uses the same compact headings and inspection controls.
22
+ - Running actions remain separate. Only successful completed actions join a group, within visible conversation boundaries.
23
+ - Successful group headings use “4 actions”; singleton headings show only the operation. Shell interpreter scripts use labels such as “Run Node.js script,” with a literal script filename when reliably available. Inline source stays in Arguments. Known errors show a short category such as “Path too long”; exact errors stay in Output/Details. Labels describe recorded operations and do not infer a script’s purpose.
24
+ - Expanded source and diffs use Pi’s syntax colors. Recorded thinking and Markdown files use bounded Markdown rendering; shell stdout and unknown text remain literal. Formatting reads at most 2,048 source characters per block. Markdown uses one source line per block, so multiline tables, paragraphs, and cross-line inline formatting are not fully reconstructed. Very long code blocks can lose lexer context at block boundaries. The original recorded source remains unchanged.
25
+ - A single-action card opens directly to useful content without repeating a numbered action row. Successful native `write` actions show submitted content with syntax colors from the path. Only the exact standard acknowledgement is moved under Details. Reads and unknown tools keep their output visible. Known ordinary-tool OS diagnostics can show a short code/category while Details retains the exact error; unknown/custom failures keep full visible output. Status marks follow the title.
26
+ - Open a group to see tightly stacked actions without blank rows between siblings. Several actions and their inline Details can remain expanded independently in the same scrollable pane. Details contains exact arguments, secondary diagnostics, and any acknowledgement/error moved from the main content. Short scalar fields share a line; null and empty values remain explicit. Empty diagnostic objects do not add a section.
27
+ - Errors, cancellations, unanswered questions, and background notices stay separate. Expanded question cards show the full question, nonempty context, and tight option rows with descriptions inline. A checkmark, native success color, and bold text mark recorded selections; custom or unmatched answers remain visible on their own marked row. Only answered records receive answer marks. Other states appear once in the header, with meaningful diagnostics retained; the exact standard cancellation message is omitted. Question cards omit duplicate headings and raw Arguments/Details objects; stored transcripts retain the original data.
28
+ - Consecutive completed subagent guide lookups form a separate guide group, with each requested topic shown on expansion. Consecutive routine subagent calls and recognized asynchronous notices form one compact update group. Failures and pending decisions stay separate. A decision request, successful supervisor reply, and acknowledgement combine only when their explicit request identity matches within the same uninterrupted exchange. Expansion shows the question and highlights the supervisor reply; this is not attributed to the user. Visible assistant replies, user messages, unrelated decisions, errors, and other actions stop grouping. Launch acknowledgements, queued steering, decision requests, replies, and completion notices retain their recorded meanings. Decision requests use purple headings; failures use red headings. Expansion shows recorded content first; Details retains exact arguments and identifiers. Unknown notification shapes and compact mode off retain native rendering. Fleet, execution, scheduling, and steering controls remain native. codemode has its own collapsible card, separate from consecutive successful actions. Its expanded body uses bounded chunks with native JavaScript colors, nested-call status colors, durations, and model cost in USD. Source, recorded call arguments/errors, output, and metadata remain scroll-accessible. Long multiline code can have different syntax colors across chunk boundaries. Shape validation and scalar call/count/cost aggregation run once per explicit update revision; they are separate from bounded viewport painting. Valid image results retain the compact codemode summary and bounded text inspection, with image counts. Image previews appear only when the compact block is expanded, using Pi's native image objects and terminal capability checks. See Inline images below. Unsupported shapes and compact mode off retain the stock native renderer. Standalone image reads stay separate and use one compact heading.
29
+ - Recorded thinking rounds can group across tools. Replies, questions, errors, and other visible boundaries separate groups. Each round has a short title taken from its recorded heading or first sentence and expands independently. The pane shows the full recorded text on demand; it does not generate summaries or make model calls.
30
+ - Recognized prompt templates show their command and authored description, or a bounded excerpt when no description is available. Expansion reveals the original text inline. Ordinary submitted prompts longer than eight rendered lines show a bounded opening and ending, separated by a muted “⋯ Show more” control. The opening stops at its first paragraph break; the ending uses the last paragraph. Long paragraphs use bounded excerpts. A blank row separates each excerpt from the control. Expansion preserves all recorded text and formatting and places “▴ Show less” at the bottom; short prompts stay open. Skill invocations share the blue prompt card, with click, `/inspect`, and native Ctrl+O expansion.
31
+
32
+ Thinking groups require Pi's native `hideThinkingBlock: true` preference. **Ctrl+T** still switches to Pi's full thinking display. Unsupported Pi versions or component shapes show native content instead of hiding it.
33
+
34
+ Completed action groups and `codemode` show short operation summaries derived from recorded tool names and bounded arguments. These phrases describe supported operations, such as reading files or checking Git changes; they do not infer an unrecorded business goal. Unknown scripts retain a generic label. No extra model call is made. Expanded codemode starts with its source instead of repeating the outer title.
35
+
36
+ Complete assistant `js workflow` or `javascript workflow` fences collapse into a separate **Subagent workflow** row. Surrounding prose remains visible. `/inspect` or a header click opens bounded, syntax-highlighted source; Esc or typing returns to the editor. This changes display only: the subagent runtime still receives the exact original assistant message. Unsupported or incomplete shapes retain native display.
37
+
38
+ ## Work strips
39
+
40
+ A user prompt gets a work strip only when it has tool or subagent activity. Text-only and thinking-only turns have no strip. During execution, intermediate replies and compact actions remain visible in the same work gutter. The newest reply keeps this indentation until the turn and its owned background work settle; only a confirmed final reply returns to the main margin. The strip shows elapsed time and a short current-step label extracted from recorded prose or operations. After native settlement and completion of that prompt's background descendants, it folds to **Worked for …** and leaves the terminal assistant reply visible. It makes no model calls and does not infer completion from reply wording.
41
+
42
+ Questions, recorded answers, supervisor decisions, unresolved errors, and unknown notices remain visible when the section is folded. Routine DDD notices can fold only when their producer explicitly marks them `severity: notice`; current DDD records without severity remain separate compact rows. Expand a DDD row to read its recorded text. Thinking and DDD content follow their headers with the same compact spacing as tools. A complete opening title or summary line is omitted from the compact body only when it exactly repeats the full visible summary and other content remains. Recorded paragraph spacing stays intact; native mode retains the original text.
43
+
44
+ Click a strip or select Work in `/inspect` to expand its chronological contents. Work steps, questions, decisions, errors, subagent updates, and DDD notices are indented beneath the strip. Attention rows retain this indentation when the strip is collapsed; final replies stay at the transcript margin. Routine headings use quiet metadata so model replies remain easy to scan. Nested inspection opens the owning strip first. Manual expansion stays open. Automatic folding waits while you are in scrollback and resumes when you return to the latest output. Interrupted or incomplete turns stay open. Native Ctrl+T and compact-off controls remain available.
45
+
46
+ Settled final replies use the theme's neutral surface (`toolPendingBg`), including direct answers with no work strip. Intermediate replies remain unfilled. The card matches user-prompt padding: one filled row above and below the reply, with the same text gutter. Native Markdown, paragraph spacing, and graphics stay intact; the outside block gap remains separate.
47
+
48
+ Explicit skill invocations use one blue prompt card. A muted, expandable `/skill:name` heading comes first, followed by the optional user message. Expanding reveals the recorded skill text; the prompt remains a user input boundary, including skill-only submissions. Model-initiated reads of skill files remain ordinary work activity. Compact-off restores Pi's separate native skill and prompt cards.
49
+
50
+ Completion is saved as a display-only custom entry, separate from original messages and model context. Resume and reload restore validated completion records. Older turns without this evidence remain open under **Work details**, with no invented duration. Unsupported runtimes retain native rendering.
51
+
52
+ Run `/fold collapse` to collapse completed and historical work sections. Ctrl+Alt+W toggles these sections: if any section or retained nested pane is expanded, collapse them all; otherwise expand them all. Explicit collapse also closes nested actions, Details, thinking, codemode, workflows, and subagent/DDD attention panes, and resets their scroll positions. Reopening a work section starts with nested panes closed. Automatic folding preserves manual pane expansion. Active and waiting work stays unchanged by the shortcut. `/fold expand` opens all sections. `/fold shortcut off` disables the session shortcut; `/fold` opens these choices.
53
+
54
+ When the current turn has a supported work strip, Pi Statusline can omit duplicate execution state and elapsed time through the `compact-renderer:work-strip:v1` event. Its Execution display preference supports Automatic (follow strip ownership), Show (honor enabled execution fields even with a strip), and Hide (omit both state and elapsed time). Other footer fields and native Fleet controls remain unchanged. Compact-off and renderer disposal release this temporary ownership without changing saved preferences.
55
+
56
+ ### Work-strip preview
57
+
58
+ Run `PI_RUNTIME=/path/to/runtime node scripts/preview-work-strip.mjs`. Optionally set `PI_PREVIEW_STATUSLINE=/path/to/pi-statusline/index.ts` to include the matching footer. `/fixture-work` plays ten seconds of invented progress through native display events; no model or tool executes. Check automatic folding, manual expansion, scrollback, `/inspect`, prompt navigation, and normal typing after Esc.
59
+
60
+ ## Controls
61
+
62
+ `/fold` opens the Pi Fold menu for display mode, collapse/expand, and shortcut settings. Typed `on`, `off`, `toggle`, `status`, `collapse`, `expand`, and `shortcut on|off` are available. Version 3 removes the old `/compact-rendering` and `/work` commands without aliases. This display mode is session-local and starts enabled.
63
+
64
+ `/inspect` opens a native picker for tool groups, subagent notices, thinking groups, and prompt cards. Selection brings the block into view, highlights its header and selected item, and shows an inspection status in the footer.
65
+
66
+ | Surface | Controls after selection |
67
+ | --- | --- |
68
+ | Tool groups | For a single action, Enter opens/closes the card. For groups, Left/Right selects an action and Enter opens/closes its content. Tab or Shift+Tab switches between the selected action and its Details; Enter toggles that target. Up/Down scroll; Home returns to the first action. |
69
+ | Thinking | Left/Right selects a round; Enter opens/closes its recorded text; Up/Down scroll; Home returns to the first round. Ctrl+T retains native visibility control. |
70
+ | Prompt cards | Enter opens/closes the original text. |
71
+ | Permission | Up/Down chooses Allow once, Deny, or Details; Enter selects; `d` toggles Details; Esc denies. Deny is selected initially. With Details open, Left/Right pages and Home/End jumps. |
72
+
73
+ Esc returns to the editor. Typing, pasting, or using an editor key also releases inspection; the next Enter submits normally. Clicking or scrolling a card changes its display without taking keyboard focus. Compact activity keeps a one-cell gutter without top/bottom padding; only keyboard selections receive a background. Expanded ordinary actions show useful content with exact arguments and secondary data under inline Details; questions use readable history only; unfocused cards omit repeated control/count footers.
74
+
75
+ Alt+G, Alt+T, and Alt+I remain optional shortcuts for tools, thinking, and prompts when the terminal sends Alt key sequences. On macOS, Option may instead type characters. Those characters remain ordinary input; use `/inspect` without changing terminal settings.
76
+
77
+ Mouse controls support tool and thinking headers, individual action and Details expansion, wheel scrolling inside open panes, and prompt headers. Short content stays above Details. For long content, Details inspection uses a bounded viewport anchor with “content above ↑”; Up, scrolling upward at that anchor, or Home returns to content. Escape or typing releases keyboard inspection and restores the content view. Tab remains native in the editor. Terminal mouse support depends on the terminal and transport. Keyboard controls remain available over mosh/tmux. Detailed keyboard hints appear on the focused pane. Arrows are captured only while a pane has focus. In fullscreen Pi, PageUp/PageDown scroll the transcript before extension controls receive them; use the arrows shown above for pane content. Opening a native question or approval releases transcript focus.
78
+
79
+ ## Permission presentation seam
80
+
81
+ A caller that already decided approval is required may emit `pi:permission-presentation:v1` with `{version:1, mode:'tui', action, target, reason, details, ui, signal?, offer}`. The first synchronous `offer(() => Promise<boolean>)` wins. The caller invokes that presenter once; absent presenters use the caller's native fallback. A claimed dialog failure or cancellation denies without opening a second prompt.
82
+
83
+ The renderer presents the caller's action, target, reason, and exact Details. Large fields have explicit shortened summaries and lazy Details navigation. Policies stay in the safety/MCP callers. Print/RPC and incompatible UI contexts keep the caller's fallback. Ordinary read approvals are not added here.
84
+
85
+ ## Verification and preview
86
+
87
+ Use Node and a Pi 1.3.0 runtime:
88
+
89
+ ```sh
90
+ PI_RUNTIME=/path/to/runtime npm test
91
+ PI_RUNTIME=/path/to/runtime node scripts/preview.mjs
92
+ ```
93
+
94
+ The runtime directory contains `node_modules/@earendil-works/pi-coding-agent` and `@earendil-works/pi-tui`. The default is `~/.local/state/pi-config/current/runtime`. Tests use actual native components and isolated fixtures. Coverage includes repeated synchronous redraw, separate native component caches, shell timer cleanup, status transitions, lifecycle changes, stock subagent rendering, Unicode, narrow widths, and bounded work on large outputs. No model or database calls are needed.
95
+
96
+ The preview runs the actual Pi TUI with invented recorded messages in a temporary home. It blocks model, shell, tool, and network requests. The fixture begins with two writes, two reads, and a separate missing-file error. It also includes a long ordinary Bash/Node script singleton, a separate long-path failure, and four grouped source/diff/Markdown/script actions. codemode uses bounded native-style JavaScript highlighting, nested calls, timing, and cost display; every recorded call and price is synthetic. Ctrl+O expands codemode and skill disclosures. `/fixture-permission` opens an inert approval example. `/fixture-question` opens the installed pi-questions choice UI; `/fixture-question text` opens its free-text UI. Answers perform no operation. The question UI uses the current Pi Config package by default; set `PI_QUESTIONS_PATH=/path/to/pi-questions/index.ts` to use another source. If unavailable, the preview reports that limit and still shows recorded question cards.
97
+
98
+ The final preview examples include a codemode result with three synthetic PNGs and a long JSON output, plus a separate image read. The preview enables native images and uses a visible 640×320 cyan/purple/green test chart. It creates one image in its temporary fixture directory so the fallback path is real; cleanup removes it. No recorded tool or script executes. Check expanded images in an image-capable terminal and the text fallback over mosh/tmux, then collapse and verify normal typing after Esc.
99
+
100
+ The preview does not load host credentials or change active Pi deployments. Use Ctrl+D to exit. Set `PI_PROMPT_JUMP_PATH=/path/to/pi-prompt-jump` to include the separate navigation package and inspect its behavior with the three invented user prompts.
101
+
102
+ The adapters for thinking, prompt component identity, viewport positioning, and native shell timers are isolated and gated to Pi 1.3.0. Future versions require review; passing these tests does not certify a different runtime or every terminal. Legacy 1.x implementation and development history remain in Git rather than as a second shipped renderer.
103
+
104
+ ## Inline images
105
+
106
+ In compact mode, expanding an image read or image-bearing codemode reveals the recorded images below the text pane. Collapsing the block hides them again. Images and fallback text align with the expanded content and Details column. Standard image-read acknowledgements and MIME metadata remain in Details; the main view does not repeat them. Each preview uses Pi's native image component, keeps its aspect ratio, and is limited to 60 columns and 12 rows (or half the terminal height, if smaller). Several images can therefore add more than one preview's height. The text pane remains independently bounded.
107
+
108
+ The renderer respects Pi's show-images setting and terminal capability detection. Pi 1.3.0 supports Kitty images in compatible terminals and disables image protocols under tmux. On that route, or when images are disabled, the expanded block shows a short fallback. A direct image read retains its recorded path; Pi makes absolute paths clickable only when native hyperlink support is available. Remote paths still refer to the remote host. codemode does not invent a file path for an in-memory image.
109
+
110
+ Compact mode off preserves native image display and sizing. The image adapter is gated to Pi 1.3.0 and restores the native component's options after each compact paint. It does not alter image data, terminal settings, tmux settings, or saved transcripts.
package/index.ts ADDED
@@ -0,0 +1,53 @@
1
+ import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
2
+ import { clearDisplayLineCache } from './src/display-card.ts';
3
+ import { createDisplayMode } from './src/display-mode.ts';
4
+ import { registerModernTools } from './src/modern-tools.ts';
5
+ import { registerModernThinking } from './src/modern-thinking.ts';
6
+ import { registerModernPrompts } from './src/modern-prompts.ts';
7
+ import { registerModernSkillPrompts } from './src/modern-skill-prompts.ts';
8
+ import { registerModernWorkflows } from './src/modern-workflows.ts';
9
+ import { registerModernSubagentMessages } from './src/modern-subagent-messages.ts';
10
+ import { registerInspection } from './src/inspection.ts';
11
+ import { registerPermissionPresentation } from './src/permission-presentation.ts';
12
+ import { registerWorkStrip } from './src/work-strip.ts';
13
+ import { registerFoldCommand } from './src/fold-command.ts';
14
+
15
+ export default function piFold(pi: ExtensionAPI): void {
16
+ clearDisplayLineCache();
17
+ const mode = createDisplayMode();
18
+ const disposers: Array<() => void> = [];
19
+ let disposed = false;
20
+ const dispose = () => {
21
+ if (disposed) return;
22
+ disposed = true;
23
+ const errors: unknown[] = [];
24
+ for (const cleanup of [...disposers].reverse()) {
25
+ try { cleanup(); } catch (error) { errors.push(error); }
26
+ }
27
+ mode.dispose();
28
+ clearDisplayLineCache();
29
+ if (errors.length) throw new AggregateError(errors, 'Pi Fold cleanup failed');
30
+ };
31
+ try {
32
+ // All display features share the cache; its lifetime belongs to the extension.
33
+ for (const event of ['session_start', 'session_tree', 'session_compact', 'session_before_switch'] as const) {
34
+ const off = pi.on(event, () => { if (!disposed) clearDisplayLineCache(); });
35
+ if (typeof off === 'function') disposers.push(off);
36
+ }
37
+ disposers.push(registerModernTools(pi, mode));
38
+ disposers.push(registerModernThinking(pi, mode));
39
+ disposers.push(registerModernPrompts(pi, mode));
40
+ disposers.push(registerModernSkillPrompts(pi, mode));
41
+ disposers.push(registerModernWorkflows(pi, mode));
42
+ disposers.push(registerPermissionPresentation(pi, mode));
43
+ disposers.push(registerModernSubagentMessages(pi, mode));
44
+ const work = registerWorkStrip(pi, mode);
45
+ disposers.push(work.dispose);
46
+ disposers.push(registerFoldCommand(pi, mode, work));
47
+ disposers.push(registerInspection(pi, mode));
48
+ } catch (error) {
49
+ dispose();
50
+ throw error;
51
+ }
52
+ pi.on('session_shutdown', dispose);
53
+ }