@xynogen/pix-display 0.1.6 → 0.1.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-display",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Pi core extension — paste chip rendering and thinking block display",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -13,10 +13,7 @@
13
13
  * The display rewrite is purely visual (render layer); buffer is untouched.
14
14
  */
15
15
 
16
- import type {
17
- ExtensionAPI,
18
- KeybindingsManager,
19
- } from "@earendil-works/pi-coding-agent";
16
+ import type { ExtensionAPI, KeybindingsManager } from "@earendil-works/pi-coding-agent";
20
17
  import { CustomEditor } from "@earendil-works/pi-coding-agent";
21
18
  import type { EditorTheme, TUI } from "@earendil-works/pi-tui";
22
19
  import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
@@ -97,10 +94,7 @@ type ExpandPasteHandler = { expandPasteMarkers(text: string): string };
97
94
 
98
95
  // Mirror of the base Editor's paste-marker grammar, per-id at expand time.
99
96
  function markerReFor(pasteId: number): RegExp {
100
- return new RegExp(
101
- `\\[paste #${pasteId}( (\\+\\d+ lines|\\d+ chars))?\\]`,
102
- "g",
103
- );
97
+ return new RegExp(`\\[paste #${pasteId}( (\\+\\d+ lines|\\d+ chars))?\\]`, "g");
104
98
  }
105
99
 
106
100
  /**
@@ -109,10 +103,7 @@ function markerReFor(pasteId: number): RegExp {
109
103
  * boundary per blob (text and image alike) so adjacent pastes can't merge
110
104
  * into one indistinguishable wall in the model-facing text.
111
105
  */
112
- export function expandPasteMarkers(
113
- text: string,
114
- pastes: Map<number, string>,
115
- ): string {
106
+ export function expandPasteMarkers(text: string, pastes: Map<number, string>): string {
116
107
  let result = text;
117
108
  for (const [pasteId, pasteContent] of pastes) {
118
109
  result = result.replace(
@@ -162,35 +153,22 @@ export function restyleMarkers(line: string, imageIds: Set<number>): string {
162
153
  // Strip cursor inversion codes the TUI embeds when the cursor
163
154
  // intersects a marker — plain MARKER_RE handles the rest.
164
155
  const clean = line.includes("\x1b") ? line.replace(CURSOR_RE, "") : line;
165
- return clean.replace(
166
- MARKER_RE,
167
- (_full, idStr, _g2, _g3, linesStr, charsStr) => {
168
- const id = Number.parseInt(idStr, 10);
169
- if (imageIds.has(id)) {
170
- return chip(FG_BLUE, icon("paste.image"), "image", `#${id}`);
171
- }
172
- if (linesStr) {
173
- return chip(FG_GREEN, icon("paste.text"), "text", `${linesStr} lines`);
174
- }
175
- if (charsStr) {
176
- return chip(
177
- FG_GREEN,
178
- icon("paste.text"),
179
- "text",
180
- `${compactNumber(charsStr)} chars`,
181
- );
182
- }
183
- return chip(FG_GREEN, icon("paste.text"), "text", `#${id}`);
184
- },
185
- );
156
+ return clean.replace(MARKER_RE, (_full, idStr, _g2, _g3, linesStr, charsStr) => {
157
+ const id = Number.parseInt(idStr, 10);
158
+ if (imageIds.has(id)) {
159
+ return chip(FG_BLUE, icon("paste.image"), "image", `#${id}`);
160
+ }
161
+ if (linesStr) {
162
+ return chip(FG_GREEN, icon("paste.text"), "text", `${linesStr} lines`);
163
+ }
164
+ if (charsStr) {
165
+ return chip(FG_GREEN, icon("paste.text"), "text", `${compactNumber(charsStr)} chars`);
166
+ }
167
+ return chip(FG_GREEN, icon("paste.text"), "text", `#${id}`);
168
+ });
186
169
  }
187
170
 
188
- function chip(
189
- color: string,
190
- icon: string,
191
- label: string,
192
- meta: string,
193
- ): string {
171
+ function chip(color: string, icon: string, label: string, meta: string): string {
194
172
  return `${color}${BOLD}${icon} ${label}${RST}${FG_DIM} ${meta}${RST}`;
195
173
  }
196
174
 
@@ -228,9 +206,7 @@ class ChipEditor extends CustomEditor {
228
206
  const replaced = replaceImagePaths(text, internals, this.imageIds);
229
207
  // Append a trailing space when the insertion ends with a paste marker so
230
208
  // the cursor lands after the chip rather than inside it.
231
- super.insertTextAtCursor(
232
- endsWithMarker(replaced) ? `${replaced} ` : replaced,
233
- );
209
+ super.insertTextAtCursor(endsWithMarker(replaced) ? `${replaced} ` : replaced);
234
210
  }
235
211
 
236
212
  /**
@@ -243,8 +219,7 @@ class ChipEditor extends CustomEditor {
243
219
  private patchExpandPasteMarkers(): void {
244
220
  const internals = this as unknown as ExpandInternals;
245
221
  const self = this as unknown as ExpandPasteHandler;
246
- self.expandPasteMarkers = (text: string): string =>
247
- expandPasteMarkers(text, internals.pastes);
222
+ self.expandPasteMarkers = (text: string): string => expandPasteMarkers(text, internals.pastes);
248
223
  }
249
224
 
250
225
  private patchHandlePaste(): void {
package/src/thinking.ts CHANGED
@@ -131,10 +131,7 @@ function splitThinking(text: string): Block[] {
131
131
  const openMatch = OPEN_TAIL_RE.exec(rest);
132
132
  if (openMatch) {
133
133
  // Leading text may still carry orphan tags (e.g. a stray `</think>`).
134
- pushText(
135
- blocks,
136
- openMatch.input.slice(0, openMatch.index).replace(ORPHAN_TAG_RE, ""),
137
- );
134
+ pushText(blocks, openMatch.input.slice(0, openMatch.index).replace(ORPHAN_TAG_RE, ""));
138
135
  pushThinking(blocks, (openMatch[2] ?? "").replace(ORPHAN_TAG_RE, ""));
139
136
  } else {
140
137
  // Strip any orphan tags from the trailing text.