pi-sakura-cyberdeck 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to pi-sakura-cyberdeck. Pi >= 1.5.0 shows new package entries
4
4
  once after updating; run `/sakura-changelog` on any supported Pi to read this file.
5
5
 
6
+ ## [1.5.3] - 2026-11-28
7
+
8
+ ### Highlights
9
+
10
+ - **Tagged thinking trails**: inline `<thinking>…</thinking>` (and `<think>` / `<thought>`) tags
11
+ written into assistant replies now render as a `✦ Thought trail`.
12
+ - **npm Trusted Publishing (OIDC)**: automated GitHub Actions CI and OIDC release publishing with
13
+ provenance attestations.
14
+
15
+ ### Fixed
16
+
17
+ - Reasoning that a model writes into its answer as `<thinking>…</thinking>` (also `<think>` and
18
+ `<thought>`), as Gemini often does behind OpenAI-compatible endpoints, is now shown as a
19
+ `✦ Thought trail` instead of literal tags. Only tags at the start of a line outside fenced code
20
+ count; an unclosed tag is a trail while streaming and stays literal once the message is final.
21
+ Display-only, and `/zentui thinking-trail off` keeps Pi's stock rendering.
22
+
23
+ ### Development
24
+
25
+ - Added GitHub Actions CI (`ci.yml`) and npm Trusted Publishing via OIDC (`publish.yml`) with
26
+ automatic provenance.
27
+
6
28
  ## [1.5.2] - 2026-11-18
7
29
 
8
30
  ### Highlights
package/README.md CHANGED
@@ -7,7 +7,7 @@ Lightweight Sakura Macaron visual pack for [Pi](https://pi.dev): a pastel theme,
7
7
  ## Quick start
8
8
 
9
9
  ```bash
10
- pi install git:github.com/beautifulrem/pi-sakura-cyberdeck
10
+ pi install npm:pi-sakura-cyberdeck
11
11
  ```
12
12
 
13
13
  Then pick the theme in `/settings` → **sakura-macaron** and restart Pi once. Details: [Install](#install).
@@ -18,7 +18,7 @@ Then pick the theme in `/settings` → **sakura-macaron** and restart Pi once. D
18
18
  <sub>Real Pi 1.5.2 session rendered by this pack (scripted demo model; GohuFont uni14 Nerd Font Mono).</sub>
19
19
  </p>
20
20
 
21
- **v1.5.2** — frames every tool card (image results included), brings back Pi's bash-mode and scroll cues in the Sakura editor frame, and hardens the footer, settings, changelog viewer, matrix rain and shimmer. See [what changed](#152).
21
+ **v1.5.3** — turns inline `<thinking>` / `<think>` / `<thought>` tags in replies into Thought trails, and publishes to npm via GitHub Actions OIDC Trusted Publishing. See [what changed](#153).
22
22
 
23
23
  ## What’s inside
24
24
 
@@ -95,6 +95,7 @@ Other editor extensions (e.g. `pi-fff`) keep their input and autocomplete inside
95
95
  - One step per thinking paragraph, first line only; rails/`◇` in the sakura gradient, body in the thinking tint
96
96
  - Wrapped rows keep their `│` rail, including long inline code, URLs, backticks and math; each digest row is literal text rather than reparsed Markdown. Long trails cap at 16 rows, then `╰─ … +N more`. Very narrow widths fall back to Pi's normal thinking render.
97
97
  - Display-only via Pi's public markdown transformer; the session and model context keep the full thinking text
98
+ - Reasoning a model writes into its answer as `<thinking>…</thinking>` (also `<think>` / `<thought>`, common with Gemini) gets the same trail; only line-start tags outside code fences count
98
99
 
99
100
  ## Requirements
100
101
 
@@ -107,10 +108,20 @@ Other editor extensions (e.g. `pi-fff`) keep their input and autocomplete inside
107
108
 
108
109
  ## Install
109
110
 
111
+ From npm:
112
+
113
+ ```bash
114
+ pi install npm:pi-sakura-cyberdeck
115
+ ```
116
+
117
+ From Git:
118
+
110
119
  ```bash
111
120
  pi install git:github.com/beautifulrem/pi-sakura-cyberdeck
112
121
  ```
113
122
 
123
+ Pi treats the npm and Git sources as different packages, so install from one only. To switch, `pi remove` the old source first.
124
+
114
125
  Local:
115
126
 
116
127
  ```bash
@@ -123,18 +134,22 @@ Then `/settings` → theme **sakura-macaron** (Pi 0.99 defaults to its `system`
123
134
 
124
135
  ### Updating
125
136
 
126
- For an unpinned Git installation:
137
+ For an unpinned installation:
127
138
 
128
139
  ```bash
140
+ pi update npm:pi-sakura-cyberdeck
141
+ # or, if you installed from Git
129
142
  pi update git:github.com/beautifulrem/pi-sakura-cyberdeck
130
143
  ```
131
144
 
132
145
  Restart Pi after updating. Pi **>= 1.5.0** shows what changed under **Extension Updates** on the next fresh launch (its own package-changelog notice, condensed when `collapseChangelog` is set). On older Pi versions, use `/sakura-changelog`; the command always opens the full changelog inside Pi. See also [CHANGELOG.md](CHANGELOG.md).
133
146
 
134
- Pi does not push package updates automatically. Users who pinned a tag or commit must explicitly select the new version:
147
+ Pi does not push package updates automatically. Users who pinned a version, tag or commit must explicitly select the new version:
135
148
 
136
149
  ```bash
137
- pi install git:github.com/beautifulrem/pi-sakura-cyberdeck@v1.2.0
150
+ pi install npm:pi-sakura-cyberdeck@1.5.3
151
+ # or
152
+ pi install git:github.com/beautifulrem/pi-sakura-cyberdeck@v1.5.3
138
153
  ```
139
154
 
140
155
  Notes for 1.2.0:
@@ -160,13 +175,13 @@ Or start with `pi --tui-mode fullscreen`. Pack styling (editor chrome, footer, s
160
175
 
161
176
  ### Load only some pieces
162
177
 
163
- Pi can filter a package's resources. Replace the plain source string in `~/.pi/agent/settings.json` with an object:
178
+ Pi can filter a package's resources. Replace the plain source string in `~/.pi/agent/settings.json` with an object. Keep `source` exactly as it is in your settings (a Git source, or an npm version pin such as `npm:pi-sakura-cyberdeck@1.5.3`); changing it installs a different package rather than filtering the one you have.
164
179
 
165
180
  ```jsonc
166
181
  {
167
182
  "packages": [
168
183
  {
169
- "source": "git:github.com/beautifulrem/pi-sakura-cyberdeck",
184
+ "source": "npm:pi-sakura-cyberdeck",
170
185
  // everything except the startup header and matrix rain
171
186
  "extensions": ["extensions/*/index.ts", "!extensions/header/index.ts", "!extensions/matrix/index.ts"]
172
187
  }
@@ -224,20 +239,17 @@ Avoid stacking with `pi-zentui`, `pi-powerline-footer`, stock `pi-claude-shimmer
224
239
 
225
240
  Full history: [CHANGELOG.md](CHANGELOG.md) (also available in Pi via `/sakura-changelog`).
226
241
 
227
- ### 1.5.2
242
+ ### 1.5.3
228
243
 
229
- - Tool cards with image results (`read` of a PNG on a vision model, browser screenshots) are framed
230
- like every other card; terminal image rows only gain the left rail.
231
- - The framed editor shows Pi's bash-mode colour while the prompt starts with `!`, and keeps the
232
- `↑/↓ N more` scroll labels. Sent prompts keep Pi's OSC 133 prompt markers at line start.
233
- - Footer: right side (context, tokens, cost) survives narrow terminals; virtual models show context;
234
- literal `|` separators keep neighbouring colours; another extension's footer is never removed;
235
- fewer git/runtime probes.
236
- - Settings, `/sakura-changelog`, matrix rain and shimmer fixes. See [CHANGELOG.md](CHANGELOG.md).
244
+ - Reasoning that a model writes into its answer as `<thinking>…</thinking>` (also `<think>` and
245
+ `<thought>`, common with Gemini behind OpenAI-compatible endpoints) is now shown as a
246
+ `✦ Thought trail` instead of literal tags (display-only; `/zentui thinking-trail off` keeps
247
+ Pi's stock rendering).
248
+ - Added GitHub Actions CI and npm Trusted Publishing (OIDC) with automatic provenance.
237
249
 
238
250
  ### Earlier versions
239
251
 
240
- See [CHANGELOG.md](CHANGELOG.md) for 1.0.0 – 1.5.1.
252
+ See [CHANGELOG.md](CHANGELOG.md) for 1.0.0 – 1.5.2.
241
253
 
242
254
  ## Development
243
255
 
package/README.zh-CN.md CHANGED
@@ -7,9 +7,11 @@
7
7
  ## 快速开始
8
8
 
9
9
  ```bash
10
- pi install git:github.com/beautifulrem/pi-sakura-cyberdeck
10
+ pi install npm:pi-sakura-cyberdeck
11
11
  ```
12
12
 
13
+ 也可以从 Git 安装:`pi install git:github.com/beautifulrem/pi-sakura-cyberdeck`。两种来源 Pi 会当成两个不同的包,只装一个;要换来源,先 `pi remove` 旧的。
14
+
13
15
  然后在 `/settings` 里把主题选成 **sakura-macaron**,重启一次 Pi。
14
16
 
15
17
  <p align="center">
@@ -36,7 +38,7 @@ pi install git:github.com/beautifulrem/pi-sakura-cyberdeck
36
38
  - **底栏**:上下文用量条、token 和费用统计与 Pi 自带底栏一致;显示 git 分支和运行时版本。`/zentui pulse on` 可在工作时让渐变动起来。
37
39
  - **工具卡片**:标题一条连续的樱花渐变,状态始终写明(`RUNNING` / `COMPLETE` / `FAILED`);`edit` 显示 `+N −M` 行数;工具输出保持 Pi 原样,不重新上色。
38
40
  - **Bash 命令头**:用 `❯` 提示符和 Pi 自带的 Shell 语法高亮,长命令折叠成五行。
39
- - **Thought trail**:把可见的思考过程压缩成树状摘要,每段一行;只影响显示,模型上下文保持完整。
41
+ - **Thought trail**:把可见的思考过程压缩成树状摘要,每段一行;只影响显示,模型上下文保持完整。模型(常见于 Gemini)把推理写进正文的 `<thinking>…</thinking>` 也会显示为 Thought trail。
40
42
 
41
43
  ## 要求
42
44
 
@@ -48,13 +50,13 @@ pi install git:github.com/beautifulrem/pi-sakura-cyberdeck
48
50
 
49
51
  ## 只加载部分组件
50
52
 
51
- 在 `~/.pi/agent/settings.json` 里把包来源写成对象,可以按需过滤:
53
+ 在 `~/.pi/agent/settings.json` 里把包来源写成对象,可以按需过滤。`source` 保持你设置里原来的写法(比如 Git 来源,或者 `npm:pi-sakura-cyberdeck@1.5.3` 这样锁定版本的写法);改了它就等于装了另一个包,而不是过滤现有的这个。
52
54
 
53
55
  ```jsonc
54
56
  {
55
57
  "packages": [
56
58
  {
57
- "source": "git:github.com/beautifulrem/pi-sakura-cyberdeck",
59
+ "source": "npm:pi-sakura-cyberdeck",
58
60
  // 不要启动画面和数字雨
59
61
  "extensions": ["extensions/*/index.ts", "!extensions/header/index.ts", "!extensions/matrix/index.ts"]
60
62
  }
@@ -124,7 +124,7 @@ const featureSettingDescriptions: Record<FeatureSettingId, string> = {
124
124
  messageStyle:
125
125
  "Style previous user messages, tool blocks, thinking labels and selector borders. Independent of the editor.",
126
126
  thinkingTrail:
127
- "Collapse visible thinking blocks into a compact \"✦ Thought trail\" digest. Display-only; Ctrl+T still toggles thinking.",
127
+ "Collapse visible thinking blocks (and <thinking> tags in replies) into a compact \"✦ Thought trail\" digest. Display-only; Ctrl+T still toggles thinking.",
128
128
  copyFriendly:
129
129
  "Hide editor and previous-message rail glyphs for cleaner native terminal selection.",
130
130
  };
@@ -14,6 +14,11 @@ import { renderSakuraGradient, renderSakuraGradientOpen } from "./gradient";
14
14
  *
15
15
  * We wrap step text ourselves (instead of letting Markdown wrap it) so every continuation
16
16
  * row keeps its `│`/` ` rail and the tree never breaks at a soft wrap.
17
+ *
18
+ * Some models (notably Gemini behind OpenAI-compatible endpoints) write their reasoning into
19
+ * the answer text as `<thinking>…</thinking>` instead of a structured thinking block. Pi then
20
+ * renders the tags literally. For `assistant` text we lift such tagged blocks into the same
21
+ * trail, again display-only.
17
22
  */
18
23
 
19
24
  const DEFAULT_WIDTH = 100;
@@ -101,11 +106,119 @@ export function buildThinkingTrail(markdown: string, availableWidth = DEFAULT_WI
101
106
  return lines.join(HARD_BREAK);
102
107
  }
103
108
 
109
+ export type TaggedSegment =
110
+ | { kind: "text"; text: string }
111
+ | { kind: "thinking"; body: string; raw: string; closed: boolean };
112
+
113
+ /** Tag names models use for inline reasoning. */
114
+ const THINKING_TAG = /^[ \t]{0,3}<(thinking|think|thought)>/i;
115
+ const FENCE_OPEN = /^[ ]{0,3}(`{3,}|~{3,})/;
116
+
117
+ function closesFence(line: string, fence: string): boolean {
118
+ const match = /^[ ]{0,3}(`{3,}|~{3,})[ \t]*$/.exec(line);
119
+ return !!match && match[1]![0] === fence[0] && match[1]!.length >= fence.length;
120
+ }
121
+
122
+ /**
123
+ * Split assistant text into plain text and `<thinking>` blocks. An opening tag only counts at
124
+ * the start of a line (up to three spaces of indent) outside fenced code, so prose or code that
125
+ * merely mentions the tag is left alone. Returns `undefined` when there is no tagged block.
126
+ */
127
+ export function splitTaggedThinking(markdown: string): TaggedSegment[] | undefined {
128
+ const segments: TaggedSegment[] = [];
129
+ let textStart = 0;
130
+ let pos = 0;
131
+ let fence: string | undefined;
132
+ let found = false;
133
+ while (pos < markdown.length) {
134
+ const newline = markdown.indexOf("\n", pos);
135
+ const end = newline === -1 ? markdown.length : newline;
136
+ const line = markdown.slice(pos, end);
137
+ if (fence) {
138
+ if (closesFence(line, fence)) fence = undefined;
139
+ } else {
140
+ const fenceOpen = FENCE_OPEN.exec(line);
141
+ const open = fenceOpen ? null : THINKING_TAG.exec(line);
142
+ if (fenceOpen) {
143
+ fence = fenceOpen[1];
144
+ } else if (open) {
145
+ found = true;
146
+ if (pos > textStart) segments.push({ kind: "text", text: markdown.slice(textStart, pos) });
147
+ const bodyStart = pos + open[0].length;
148
+ const close = new RegExp(`</${open[1]}\\s*>`, "i").exec(markdown.slice(bodyStart));
149
+ if (!close) {
150
+ segments.push({
151
+ kind: "thinking",
152
+ body: markdown.slice(bodyStart),
153
+ raw: markdown.slice(pos),
154
+ closed: false,
155
+ });
156
+ return segments;
157
+ }
158
+ const closeEnd = bodyStart + close.index + close[0].length;
159
+ segments.push({
160
+ kind: "thinking",
161
+ body: markdown.slice(bodyStart, bodyStart + close.index),
162
+ raw: markdown.slice(pos, closeEnd),
163
+ closed: true,
164
+ });
165
+ // Continue on whatever follows the closing tag, as if it began a line.
166
+ pos = textStart = closeEnd;
167
+ continue;
168
+ }
169
+ }
170
+ if (newline === -1) break;
171
+ pos = newline + 1;
172
+ }
173
+ if (!found) return undefined;
174
+ if (textStart < markdown.length) segments.push({ kind: "text", text: markdown.slice(textStart) });
175
+ return segments;
176
+ }
177
+
178
+ /** Drop the blank lines around a text piece, keeping leading indentation (indented code). */
179
+ function trimBlankLines(text: string): string {
180
+ return text.replace(/^(?:[ \t]*\r?\n)+/, "").trimEnd();
181
+ }
182
+
183
+ /**
184
+ * Replace `<thinking>` blocks in assistant text with trails. An unclosed block becomes a trail
185
+ * while streaming (the model is still thinking) and stays literal once the message is final.
186
+ */
187
+ export function buildTaggedThinkingTrail(
188
+ markdown: string,
189
+ availableWidth = DEFAULT_WIDTH,
190
+ isStreaming = false,
191
+ ): string | undefined {
192
+ const segments = splitTaggedThinking(markdown);
193
+ if (!segments) return undefined;
194
+ const pieces: string[] = [];
195
+ for (const segment of segments) {
196
+ if (segment.kind === "text") {
197
+ pieces.push(trimBlankLines(segment.text));
198
+ continue;
199
+ }
200
+ if (!segment.closed && !isStreaming) {
201
+ pieces.push(trimBlankLines(segment.raw));
202
+ continue;
203
+ }
204
+ // An empty `<thinking></thinking>` simply disappears.
205
+ if (thinkingSteps(segment.body).length === 0) continue;
206
+ const trail = buildThinkingTrail(segment.body, availableWidth);
207
+ // Too narrow for the rails: let Pi render the original text.
208
+ if (trail === undefined) return undefined;
209
+ pieces.push(trail);
210
+ }
211
+ return pieces.filter((piece) => piece.length > 0).join("\n\n");
212
+ }
213
+
104
214
  export function makeThinkingTrailTransformer(isEnabled: () => boolean): MarkdownTransformer {
105
215
  return (markdown: string, context: MarkdownTransformContext): string => {
106
- if (context.messageType !== "assistant-thinking") return markdown;
216
+ if (context.messageType !== "assistant-thinking" && context.messageType !== "assistant") return markdown;
107
217
  if (!isEnabled()) return markdown;
108
218
  try {
219
+ if (context.messageType === "assistant") {
220
+ return buildTaggedThinkingTrail(markdown, context.availableWidth, context.isStreaming) ?? markdown;
221
+ }
109
222
  return buildThinkingTrail(markdown, context.availableWidth) ?? markdown;
110
223
  } catch {
111
224
  // A transformer that throws keeps the partial output; return the original instead.
@@ -127,7 +240,7 @@ export function registerThinkingTrail(
127
240
  if (typeof pi.registerMarkdownTransformer !== "function") return;
128
241
  try {
129
242
  pi.registerMarkdownTransformer(makeThinkingTrailTransformer(isEnabled), {
130
- messageTypes: ["assistant-thinking"],
243
+ messageTypes: ["assistant-thinking", "assistant"],
131
244
  });
132
245
  } catch {
133
246
  // Older/alternate hosts: leave thinking rendering to Pi.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-sakura-cyberdeck",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "Lightweight Sakura Macaron visual pack for Pi: theme, cyberdeck header, macaron Zentui chrome, Claude-style shimmer, optional matrix rain.",
5
5
  "type": "module",
6
6
  "license": "MIT",