@stevezhou/sisu 0.1.6 → 0.1.8

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/dist/logo.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sisuTreeLines = exports.sisuTreeArt = exports.sisuMarkLines = exports.sisuMarkArt = void 0;
3
+ exports.SISU_STILL_PHASE = exports.sisuTreeLines = exports.sisuTreeArt = exports.sisuMarkLines = exports.sisuMarkArt = void 0;
4
4
  exports.sisuMobiusArt = sisuMobiusArt;
5
5
  exports.sisuWordmark = sisuWordmark;
6
6
  exports.displayWidth = displayWidth;
@@ -18,19 +18,10 @@ Object.defineProperty(exports, "sisuTreeArt", { enumerable: true, get: function
18
18
  Object.defineProperty(exports, "sisuTreeLines", { enumerable: true, get: function () { return tree_1.sisuTreeLines; } });
19
19
  const mark_2 = require("./mark");
20
20
  const mobius_1 = require("./mobius");
21
- const tree_2 = require("./tree");
22
21
  const RESET = '\x1b[0m';
23
- const TERRACOTTA = '\x1b[38;2;184;90;58m';
24
22
  const INK = '\x1b[38;2;220;214;204m';
25
23
  const INK_DIM = '\x1b[38;2;140;132;120m';
26
24
  const HEADLINE = '思有所溯';
27
- const TAGLINE = '为科研而生的工作台——记录退到思考之后,不打扰任何一念。';
28
- const COLOPHON = [
29
- '对话、文献与数据,落笔成档',
30
- '每个结论,都能沿枝回到它的根',
31
- '众人的知识彼此嫁接,长成一片林',
32
- ];
33
- const NUMERALS = ['一', '二', '三'];
34
25
  function sisuMobiusArt(columns = 80, phase = 0, color = false) {
35
26
  return (0, mobius_1.renderMobiusFrame)({
36
27
  cols: (0, mobius_1.mobiusFrameWidth)(columns),
@@ -78,17 +69,6 @@ function lockup(color) {
78
69
  const latin = paint('SiSu', INK_DIM, color);
79
70
  return [`${inf} ${name}`, ` ${latin}`];
80
71
  }
81
- function colophon(columns, color) {
82
- const lines = [];
83
- for (let i = 0; i < COLOPHON.length; i += 1) {
84
- const num = paint(NUMERALS[i], TERRACOTTA, color);
85
- const body = paint(COLOPHON[i], INK_DIM, color);
86
- const line = `${num} ${body}`;
87
- if (displayWidth(line) + 2 <= columns)
88
- lines.push(line);
89
- }
90
- return lines;
91
- }
92
72
  function padLeft(text, n) {
93
73
  return `${' '.repeat(Math.max(0, n))}${text}`;
94
74
  }
@@ -97,69 +77,31 @@ function center(text, width) {
97
77
  const pad = Math.max(0, Math.floor((width - vis) / 2));
98
78
  return padLeft(text, pad);
99
79
  }
100
- function copyColumn(columns, color, compact) {
101
- const indent = 2;
102
- const lines = [
103
- ...lockup(color).map((line) => padLeft(line, indent)),
104
- '',
105
- padLeft(paint(HEADLINE, INK, color), indent),
106
- ];
107
- if (!compact && displayWidth(TAGLINE) + indent <= columns) {
108
- lines.push(padLeft(paint(TAGLINE, INK_DIM, color), indent));
109
- }
110
- if (!compact) {
111
- const notes = colophon(columns, color);
112
- if (notes.length) {
113
- lines.push('');
114
- for (const note of notes)
115
- lines.push(padLeft(note, indent));
116
- }
117
- }
118
- return lines;
119
- }
120
- function treeColumn(columns, color, phase, grow) {
121
- const raw = (0, tree_2.sisuTreeLines)(columns, phase, grow);
122
- const painted = (0, tree_2.sisuTreeArt)(columns, color, phase, grow).split('\n');
123
- const treeWidth = raw.reduce((max, line) => Math.max(max, line.length), 0);
124
- const pad = Math.max(0, Math.floor((columns - treeWidth) / 2));
125
- return painted.map((line, i) => {
126
- const vis = raw[i]?.length ?? displayWidth(line);
127
- return padLeft(`${line}${' '.repeat(Math.max(0, treeWidth - vis))}`, pad);
128
- });
80
+ function centerBlock(lines, width) {
81
+ return lines.map((line) => center(line, width));
129
82
  }
130
- const STILL_PHASE = 2.05;
83
+ exports.SISU_STILL_PHASE = 0.85;
84
+ const STILL_PHASE = exports.SISU_STILL_PHASE;
131
85
  /**
132
- * Login-page splash. `phase` orbits the camera; `grow` is 0..1 paint progress.
86
+ * Möbius splash. `phase` slides the half-twist around the single face.
133
87
  * Line count is stable for a given width so the intro can rewrite in place.
134
88
  */
135
- function sisuSplashFrame(columns = 80, color = true, phase = STILL_PHASE, grow = 1) {
89
+ function sisuSplashFrame(columns = 80, color = true, phase = STILL_PHASE, _grow = 1) {
136
90
  const width = Math.max(20, Math.floor(columns));
137
- const compact = width < 52;
138
- const copy = copyColumn(width, color, compact);
139
- if (width >= 72) {
140
- const gap = 3;
141
- const leftBudget = Math.min(44, Math.floor(width * 0.42));
142
- const leftCopy = copyColumn(leftBudget, color, true);
143
- const leftW = Math.max(...leftCopy.map((line) => displayWidth(line)), 22);
144
- const rightW = Math.max(28, width - leftW - gap);
145
- const right = treeColumn(rightW, color, phase, grow);
146
- const rows = Math.max(leftCopy.length, right.length);
147
- const merged = [];
148
- for (let i = 0; i < rows; i += 1) {
149
- const left = leftCopy[i] ?? '';
150
- const pad = Math.max(0, leftW + gap - displayWidth(left));
151
- merged.push(`${left}${' '.repeat(pad)}${right[i] ?? ''}`);
152
- }
153
- const notes = colophon(width, color);
154
- if (notes.length) {
155
- merged.push('');
156
- for (const note of notes)
157
- merged.push(padLeft(note, 2));
158
- }
159
- return merged.join('\n');
160
- }
161
- const tree = treeColumn(width, color, phase, grow);
162
- return [...copy, '', ...tree].join('\n');
91
+ const ringW = (0, mobius_1.mobiusFrameWidth)(width);
92
+ const ring = (0, mobius_1.renderMobiusFrame)({
93
+ cols: ringW,
94
+ rows: (0, mobius_1.mobiusFrameHeight)(width),
95
+ phase,
96
+ color,
97
+ }).split('\n');
98
+ const pad = Math.max(0, Math.floor((width - ringW) / 2));
99
+ const art = ring.map((line) => padLeft(line, pad));
100
+ const caption = centerBlock([
101
+ `${infinityMark(color)} ${paint('思溯', INK, color)} ${paint('SiSu', INK_DIM, color)}`,
102
+ paint(HEADLINE, INK, color),
103
+ ], width);
104
+ return [...art, '', ...caption].join('\n');
163
105
  }
164
106
  function sisuSplashHeight(columns = 80) {
165
107
  return sisuSplashFrame(columns, false).split('\n').length;
package/dist/main.js CHANGED
@@ -28,7 +28,7 @@ Usage:
28
28
  sisu history
29
29
  sisu thread <conversation-id>
30
30
  sisu training --on|--off
31
- sisu interactive TUI (3D welcome tree)
31
+ sisu interactive TUI (Möbius splash)
32
32
  sisu help
33
33
 
34
34
  Auth and workspaces live in $SISU_HOME (default ~/.sisu), shared with Desktop.
package/dist/mobius.js CHANGED
@@ -1,22 +1,23 @@
1
1
  "use strict";
2
- /** Volumetric Möbius ring: half-twist ribbon with thickness, perspective, and lighting. */
2
+ /** Volumetric Möbius: lemniscate centerline, half-twist ribbon, traveling glint. */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.mobiusRgb = mobiusRgb;
5
5
  exports.mobiusPoint = mobiusPoint;
6
+ exports.logoPoint = logoPoint;
6
7
  exports.renderMobiusFrame = renderMobiusFrame;
7
8
  exports.mobiusFrameHeight = mobiusFrameHeight;
8
9
  exports.mobiusFrameWidth = mobiusFrameWidth;
9
10
  const RESET = '\x1b[0m';
10
11
  const SHADE_RAMP = ' .:-=+*#%@';
11
- const RADIUS = 1.88;
12
- const HALF_WIDTH = 0.34;
13
- const THICKNESS = 0.08;
12
+ const SCALE = 1.72;
13
+ const HALF_WIDTH = 0.3;
14
+ const THICKNESS = 0.045;
14
15
  const CELL_ASPECT = 0.5;
15
- const CAM = 8.6;
16
- const FOCAL = 5.1;
17
- const KEY = norm([-0.58, 0.78, 0.24]);
18
- const FILL = norm([0.48, 0.12, 0.86]);
19
- const VIEW = [0, 0.12, 1];
16
+ const CAM = 6.4;
17
+ const FOCAL = 5.2;
18
+ const KEY = norm([-0.55, 0.7, 0.45]);
19
+ const FILL = norm([0.52, 0.1, 0.85]);
20
+ const VIEW = [0, 0.06, 1];
20
21
  function clamp(value, lo, hi) {
21
22
  return Math.max(lo, Math.min(hi, value));
22
23
  }
@@ -37,7 +38,7 @@ function cross(a, b) {
37
38
  function dot(a, b) {
38
39
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
39
40
  }
40
- /** Brand gradient along the band: blue → purple → gold, matching sisu-mark. */
41
+ /** Brand gradient along the band: blue → purple → gold. */
41
42
  function mobiusRgb(t) {
42
43
  const u = ((t / (Math.PI * 2)) % 1 + 1) % 1;
43
44
  if (u < 0.5) {
@@ -68,24 +69,10 @@ function rotateY(x, z, angle) {
68
69
  const s = Math.sin(angle);
69
70
  return [x * c + z * s, -x * s + z * c];
70
71
  }
71
- function rotateZ(x, y, angle) {
72
- const c = Math.cos(angle);
73
- const s = Math.sin(angle);
74
- return [x * c - y * s, x * s + y * c];
75
- }
76
- function transform(x, y, z, tilt, spin) {
77
- // Spin around the ring axis so the half-twist travels; then a fixed 3/4 view.
78
- ;
79
- [x, y] = rotateZ(x, y, spin);
80
- [y, z] = rotateX(y, z, tilt);
81
- [x, z] = rotateY(x, z, 0.32);
82
- return [x, y, z];
83
- }
84
72
  /**
85
- * Standard Möbius strip: a ring of radius R with a half-twist in the width.
86
- * After one full trip around θ, the normal flips — one-sided surface.
73
+ * Circular Möbius (unit tests): after one full trip around θ the width flips.
87
74
  */
88
- function mobiusPoint(theta, width, radius = RADIUS, halfWidth = HALF_WIDTH) {
75
+ function mobiusPoint(theta, width, radius = 1.88, halfWidth = 0.34) {
89
76
  const twist = theta / 2;
90
77
  const ring = radius + width * halfWidth * Math.cos(twist);
91
78
  return [
@@ -94,24 +81,45 @@ function mobiusPoint(theta, width, radius = RADIUS, halfWidth = HALF_WIDTH) {
94
81
  width * halfWidth * Math.sin(twist),
95
82
  ];
96
83
  }
97
- function mobiusNormal(theta, width, radius = RADIUS, halfWidth = HALF_WIDTH) {
98
- const twist = theta / 2;
99
- const c = Math.cos(theta);
100
- const s = Math.sin(theta);
101
- const c2 = Math.cos(twist);
102
- const s2 = Math.sin(twist);
103
- const ring = radius + width * halfWidth * c2;
104
- const dTheta = [
105
- -ring * s - width * halfWidth * 0.5 * s2 * c,
106
- ring * c - width * halfWidth * 0.5 * s2 * s,
107
- width * halfWidth * 0.5 * c2,
108
- ];
109
- const dWidth = [
110
- halfWidth * c2 * c,
111
- halfWidth * c2 * s,
112
- halfWidth * s2,
113
- ];
114
- return norm(cross(dTheta, dWidth));
84
+ /** Gerono lemniscate the of the SiSu mark. */
85
+ function lemniscate(t) {
86
+ return [SCALE * Math.sin(t), SCALE * Math.sin(t) * Math.cos(t), 0];
87
+ }
88
+ function lemniscateTangent(t) {
89
+ return norm([Math.cos(t), Math.cos(2 * t), 0]);
90
+ }
91
+ /**
92
+ * Ribbon around the ∞: width offset in a frame that half-twists once per lap.
93
+ * phase slides the twist so the single face travels without a seam.
94
+ */
95
+ function logoPoint(t, width, phase = 0) {
96
+ const [cx, cy, cz] = lemniscate(t);
97
+ const tangent = lemniscateTangent(t);
98
+ const binormal = [0, 0, 1];
99
+ const normal = norm(cross(binormal, tangent));
100
+ const twist = (t + phase) / 2;
101
+ const ox = normal[0] * Math.cos(twist) + binormal[0] * Math.sin(twist);
102
+ const oy = normal[1] * Math.cos(twist) + binormal[1] * Math.sin(twist);
103
+ const oz = normal[2] * Math.cos(twist) + binormal[2] * Math.sin(twist);
104
+ const w = width * HALF_WIDTH;
105
+ return [cx + ox * w, cy + oy * w, cz + oz * w];
106
+ }
107
+ function logoNormal(t, phase) {
108
+ const tangent = lemniscateTangent(t);
109
+ const binormal = [0, 0, 1];
110
+ const normal = norm(cross(binormal, tangent));
111
+ const twist = (t + phase) / 2;
112
+ return norm([
113
+ normal[0] * Math.cos(twist) + binormal[0] * Math.sin(twist),
114
+ normal[1] * Math.cos(twist) + binormal[1] * Math.sin(twist),
115
+ normal[2] * Math.cos(twist) + binormal[2] * Math.sin(twist),
116
+ ]);
117
+ }
118
+ function transform(x, y, z, tilt, yaw) {
119
+ ;
120
+ [y, z] = rotateX(y, z, tilt);
121
+ [x, z] = rotateY(x, z, yaw);
122
+ return [x, y, z];
115
123
  }
116
124
  function shadeChar(shade) {
117
125
  return SHADE_RAMP[Math.round(clamp(shade, 0, 1) * (SHADE_RAMP.length - 1))] || '@';
@@ -122,125 +130,93 @@ function renderMobiusFrame(options = {}) {
122
130
  const phase = options.phase ?? 0;
123
131
  const color = options.color !== false;
124
132
  const grid = Array.from({ length: rows }, () => Array(cols).fill(null));
125
- const tilt = 0.88;
126
- const samples = [];
127
- const thetaSteps = 580;
133
+ const tilt = 0.42;
134
+ const yaw = 0.18 * Math.sin(phase * 0.5);
135
+ const thetaSteps = 520;
136
+ const scale = Math.min((cols - 2) / 4.15, (rows - 2) / (2.15 * CELL_ASPECT));
128
137
  for (let i = 0; i < thetaSteps; i += 1) {
129
138
  const theta = (i / thetaSteps) * Math.PI * 2;
130
139
  for (let j = -4; j <= 4; j += 1) {
131
140
  const width = j / 4;
132
- const base = mobiusPoint(theta, width);
133
- const n0 = mobiusNormal(theta, width);
134
- // Faces of the thin solid, plus the mid-surface; skip the interior fill.
141
+ const base = logoPoint(theta, width, phase);
142
+ const n0 = logoNormal(theta, phase);
135
143
  const thicks = j === -4 || j === 4 ? [-1, 0, 1] : [-1, 1];
136
- for (const k of thicks) {
137
- const thick = k;
144
+ for (const thick of thicks) {
138
145
  let x = base[0] + n0[0] * thick * THICKNESS;
139
146
  let y = base[1] + n0[1] * thick * THICKNESS;
140
147
  let z = base[2] + n0[2] * thick * THICKNESS;
141
- let nx = n0[0];
142
- let ny = n0[1];
143
- let nz = n0[2];
144
- if (thick < 0) {
145
- nx = -nx;
146
- ny = -ny;
147
- nz = -nz;
148
- }
149
- ;
150
- [x, y, z] = transform(x, y, z, tilt, phase);
151
- [nx, ny, nz] = transform(nx, ny, nz, tilt, phase);
148
+ let nx = thick < 0 ? -n0[0] : n0[0];
149
+ let ny = thick < 0 ? -n0[1] : n0[1];
150
+ let nz = thick < 0 ? -n0[2] : n0[2];
151
+ [x, y, z] = transform(x, y, z, tilt, yaw);
152
+ [nx, ny, nz] = transform(nx, ny, nz, tilt, yaw);
153
+ if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z))
154
+ continue;
152
155
  let normal = [nx, ny, nz];
153
156
  const facing = dot(normal, VIEW);
154
157
  const back = facing < 0;
155
158
  if (back)
156
159
  normal = [-normal[0], -normal[1], -normal[2]];
157
160
  const depth = CAM - z;
158
- if (depth < 0.35)
161
+ if (depth < 0.4 || !Number.isFinite(depth))
159
162
  continue;
160
163
  const px = (x * FOCAL) / depth;
161
164
  const py = (y * FOCAL) / depth;
165
+ if (!Number.isFinite(px) || !Number.isFinite(py))
166
+ continue;
162
167
  const lambert = Math.max(0, dot(normal, KEY));
163
168
  const fill = Math.max(0, dot(normal, FILL)) * 0.2;
164
- const camFill = Math.max(0, dot(normal, VIEW)) * 0.22;
169
+ const camFill = Math.max(0, dot(normal, VIEW)) * 0.2;
165
170
  const half = norm([KEY[0] + VIEW[0], KEY[1] + VIEW[1], KEY[2] + VIEW[2]]);
166
- const spec = Math.pow(Math.max(0, dot(normal, half)), 28);
167
- const edge = Math.max(Math.abs(width), Math.abs(thick));
168
- const rim = Math.pow(1 - Math.abs(dot(normal, VIEW)), 2.2) * (0.1 + 0.5 * Math.pow(edge, 2));
169
- const ambient = back ? 0.09 : 0.18;
170
- const lit = ambient + lambert * (back ? 0.3 : 0.74) + fill + camFill + spec * 0.5 + rim;
171
- const shade = clamp(Math.pow(lit, 1.2), 0.07, 1);
172
- samples.push({
173
- px,
174
- py,
175
- depth,
176
- shade,
177
- spec,
178
- t: theta + (back ? Math.PI : 0),
179
- });
171
+ const spec = Math.pow(Math.max(0, dot(normal, half)), 26);
172
+ const edge = Math.abs(width);
173
+ const rim = Math.pow(1 - Math.abs(dot(normal, VIEW)), 2.2) * (0.12 + 0.45 * edge * edge);
174
+ const rider = Math.pow(Math.max(0, Math.cos(theta - phase)), 18);
175
+ const ambient = back ? 0.1 : 0.2;
176
+ const lit = ambient + lambert * (back ? 0.32 : 0.7) + fill + camFill + spec * 0.45 + rim + rider * 0.55;
177
+ const shade = clamp(Math.pow(lit, 1.12), 0.07, 1);
178
+ const fog = 0.5 + 0.5 * clamp(1 - (depth - 5.2) / 3.4, 0, 1);
179
+ const col = Math.round(px * scale + (cols - 1) / 2);
180
+ const row = Math.round(-py * scale * CELL_ASPECT + (rows - 1) / 2);
181
+ if (col < 0 || col >= cols || row < 0 || row >= rows)
182
+ continue;
183
+ const prev = grid[row][col];
184
+ if (!prev || depth < prev.z) {
185
+ grid[row][col] = {
186
+ z: depth,
187
+ shade: clamp(shade * fog, 0.06, 1),
188
+ t: theta + phase,
189
+ spec: (spec + rider) * fog,
190
+ };
191
+ }
180
192
  }
181
193
  }
182
194
  }
183
- let minX = Infinity;
184
- let maxX = -Infinity;
185
- let minY = Infinity;
186
- let maxY = -Infinity;
187
- let minD = Infinity;
188
- let maxD = -Infinity;
189
- for (const sample of samples) {
190
- const sx = sample.px;
191
- const sy = sample.py * CELL_ASPECT;
192
- if (sx < minX)
193
- minX = sx;
194
- if (sx > maxX)
195
- maxX = sx;
196
- if (sy < minY)
197
- minY = sy;
198
- if (sy > maxY)
199
- maxY = sy;
200
- if (sample.depth < minD)
201
- minD = sample.depth;
202
- if (sample.depth > maxD)
203
- maxD = sample.depth;
204
- }
205
- const spanX = Math.max(0.001, maxX - minX);
206
- const spanY = Math.max(0.001, maxY - minY);
207
- const scale = Math.min((cols - 4) / spanX, (rows - 2) / spanY);
208
- const midX = (minX + maxX) / 2;
209
- const midY = (minY + maxY) / 2;
210
- const depthSpan = Math.max(0.001, maxD - minD);
211
- for (const sample of samples) {
212
- const fog = 0.4 + 0.6 * (1 - (sample.depth - minD) / depthSpan);
213
- const col = Math.round((sample.px - midX) * scale + (cols - 1) / 2);
214
- const row = Math.round(-((sample.py * CELL_ASPECT) - midY) * scale + (rows - 1) / 2);
215
- if (col < 0 || col >= cols || row < 0 || row >= rows)
216
- continue;
217
- const prev = grid[row][col];
218
- if (!prev || sample.depth < prev.z) {
219
- grid[row][col] = {
220
- z: sample.depth,
221
- shade: clamp(sample.shade * fog, 0.06, 1),
222
- t: sample.t,
223
- spec: sample.spec * fog,
224
- };
225
- }
226
- }
227
- return grid.map((line) => line.map((cell) => {
195
+ return grid
196
+ .map((line) => line
197
+ .map((cell) => {
228
198
  if (!cell)
229
199
  return ' ';
230
200
  const ch = shadeChar(cell.shade);
231
201
  if (!color)
232
202
  return ch;
233
203
  let [r, g, b] = mobiusRgb(cell.t);
234
- const lift = 0.18 + cell.shade * 0.95 + cell.spec * 0.7;
204
+ const lift = 0.2 + cell.shade * 0.92 + cell.spec * 0.55;
235
205
  r = clamp(Number.isFinite(r * lift) ? Math.round(r * lift) : 180, 0, 255);
236
206
  g = clamp(Number.isFinite(g * lift) ? Math.round(g * lift) : 180, 0, 255);
237
207
  b = clamp(Number.isFinite(b * lift) ? Math.round(b * lift) : 180, 0, 255);
238
208
  return `${ansiRgb(r, g, b)}${ch}${RESET}`;
239
- }).join('')).join('\n');
209
+ })
210
+ .join(''))
211
+ .join('\n');
240
212
  }
241
213
  function mobiusFrameHeight(columns = 80) {
242
- return columns < 56 ? 13 : 20;
214
+ return columns < 52 ? 11 : columns < 72 ? 15 : 18;
243
215
  }
244
216
  function mobiusFrameWidth(columns = 80) {
245
- return columns < 56 ? 44 : Math.min(76, Math.max(56, columns - 4));
217
+ if (columns < 52)
218
+ return Math.max(32, columns);
219
+ if (columns < 72)
220
+ return Math.min(60, columns);
221
+ return Math.min(72, columns);
246
222
  }
package/dist/pager/app.js CHANGED
@@ -7,10 +7,10 @@ const store_1 = require("../store");
7
7
  const input_1 = require("./input");
8
8
  const model_1 = require("./model");
9
9
  const history_1 = require("./history");
10
+ const logo_1 = require("../logo");
10
11
  const render_1 = require("./render");
11
12
  const ALT_ENTER = '\x1b[?1049h\x1b[?25l';
12
13
  const ALT_LEAVE = '\x1b[?1049l\x1b[?25h';
13
- const CLEAR_HOME = '\x1b[2J\x1b[H';
14
14
  function formatChromeStatus(email, quota, conversationId) {
15
15
  const who = (email || '').trim();
16
16
  if (!who) {
@@ -103,10 +103,21 @@ async function runPager(io, transport, options = {}) {
103
103
  let processing = false;
104
104
  const pending = [];
105
105
  let unsubscribe = () => undefined;
106
- const paint = () => {
106
+ const paint = (phase = logo_1.SISU_STILL_PHASE) => {
107
107
  if (!running)
108
108
  return;
109
- io.write(`${CLEAR_HOME}${(0, render_1.renderPager)(state, cols, rows, theme)}`);
109
+ io.write(`\x1b[H${(0, render_1.renderPager)(state, cols, rows, theme, { phase })}`);
110
+ };
111
+ const playIntro = async () => {
112
+ const frames = Math.max(2, options.introFrames ?? 32);
113
+ const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
114
+ for (let i = 0; i < frames; i += 1) {
115
+ if (!running)
116
+ return;
117
+ const u = i / (frames - 1);
118
+ paint(logo_1.SISU_STILL_PHASE + u * Math.PI * 2);
119
+ await sleep(38);
120
+ }
110
121
  };
111
122
  let removeTerm = () => undefined;
112
123
  let settle;
@@ -123,6 +134,8 @@ async function runPager(io, transport, options = {}) {
123
134
  try {
124
135
  io.enterRaw();
125
136
  io.write(ALT_ENTER);
137
+ if (options.intro)
138
+ await playIntro();
126
139
  const onTerm = () => finish(0);
127
140
  process.on('SIGTERM', onTerm);
128
141
  removeTerm = () => {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.stripAnsi = void 0;
4
4
  exports.renderPager = renderPager;
5
5
  const logo_1 = require("../logo");
6
+ const mobius_1 = require("../mobius");
6
7
  const model_1 = require("./model");
7
8
  const theme_1 = require("./theme");
8
9
  Object.defineProperty(exports, "stripAnsi", { enumerable: true, get: function () { return theme_1.stripAnsi; } });
@@ -105,18 +106,19 @@ function center(text, width, vis = (0, logo_1.displayWidth)(text)) {
105
106
  const padLeft = Math.max(0, Math.floor((width - vis) / 2));
106
107
  return `${' '.repeat(padLeft)}${text}`;
107
108
  }
108
- function welcomeLines(guest, width, height, _theme) {
109
+ function welcomeLines(guest, width, bodyBudget, phase) {
109
110
  const copy = (0, logo_1.sisuWelcomeCopy)(guest, true).map((line) => center(line, width));
110
- const treeCols = height >= 18 && width >= 48 ? Math.min(width, 72) : width >= 36 ? 44 : 28;
111
- const raw = (0, logo_1.sisuTreeLines)(treeCols);
112
- const painted = (0, logo_1.sisuTreeArt)(treeCols, true).split('\n');
113
- const treeWidth = raw.reduce((max, line) => Math.max(max, line.length), 0);
114
- const treePad = Math.max(0, Math.floor((width - treeWidth) / 2));
115
- const tree = painted.map((line, i) => {
116
- const vis = raw[i]?.length ?? (0, logo_1.displayWidth)(line);
117
- return `${' '.repeat(treePad)}${line}${' '.repeat(Math.max(0, treeWidth - vis))}`;
118
- });
119
- return [...copy, '', ...tree];
111
+ const ringRoom = Math.max(0, bodyBudget - copy.length - 1);
112
+ if (ringRoom < 4 || width < 28)
113
+ return copy;
114
+ const ringW = (0, mobius_1.mobiusFrameWidth)(width >= 48 ? Math.min(width, 72) : Math.min(width, 44));
115
+ const ringH = Math.min((0, mobius_1.mobiusFrameHeight)(ringW), ringRoom);
116
+ const painted = (0, logo_1.sisuMobiusArt)(ringW, phase, true).split('\n').slice(0, ringH);
117
+ const pad = Math.max(0, Math.floor((width - ringW) / 2));
118
+ const ring = painted.map((line) => `${' '.repeat(pad)}${line}`);
119
+ if (bodyBudget >= 16)
120
+ return [...ring, '', ...copy];
121
+ return [...copy, '', ...ring];
120
122
  }
121
123
  function slashMenuLines(state, theme) {
122
124
  if (!state.slashOpen)
@@ -133,7 +135,7 @@ function slashMenuLines(state, theme) {
133
135
  * Fixed-grid frame: always `rows` lines, each `cols` visible cells.
134
136
  * Colors are 24-bit SGR; measure width with stripAnsi / visibleWidth.
135
137
  */
136
- function renderPager(state, cols, rows, themeName = 'dark') {
138
+ function renderPager(state, cols, rows, themeName = 'dark', view = {}) {
137
139
  const theme = (0, theme_1.getTheme)(themeName);
138
140
  const height = Math.max(0, rows);
139
141
  const width = Math.max(0, cols);
@@ -146,7 +148,9 @@ function renderPager(state, cols, rows, themeName = 'dark') {
146
148
  const slash = slashMenuLines(state, theme);
147
149
  const slashTake = Math.min(slash.length, bodyBudget);
148
150
  const guest = !(state.statusLine || '').trim() || (state.statusLine || '').includes('not signed in');
149
- const welcome = isIdleWelcome(state) ? welcomeLines(guest, width, height, theme) : [];
151
+ const welcome = isIdleWelcome(state)
152
+ ? welcomeLines(guest, width, bodyBudget, view.phase ?? logo_1.SISU_STILL_PHASE)
153
+ : [];
150
154
  const welcomeTake = Math.min(welcome.length, Math.max(0, bodyBudget - slashTake));
151
155
  const scrollBudget = bodyBudget - slashTake - welcomeTake;
152
156
  const laid = layoutScrollback(state, width, theme);
package/dist/tui.js CHANGED
@@ -49,10 +49,7 @@ async function playMobiusIntro(io, options = {}) {
49
49
  io.write('\x1b[?25h');
50
50
  io.write(`\n${(0, logo_1.sisuWordmark)()}\n\n`);
51
51
  }
52
- function easeOutCubic(t) {
53
- return 1 - (1 - t) ** 3;
54
- }
55
- /** Grow the 溯源之树, then orbit so lighting and occlusion read as volume. */
52
+ /** Slide the half-twist around the ∞ so the single face loops. */
56
53
  async function playTreeIntro(io, options = {}) {
57
54
  const columns = options.columns ?? process.stdout.columns ?? 80;
58
55
  const frames = Math.max(2, options.frames ?? 36);
@@ -62,9 +59,8 @@ async function playTreeIntro(io, options = {}) {
62
59
  io.write('\x1b[?25l');
63
60
  for (let i = 0; i < frames; i += 1) {
64
61
  const u = i / (frames - 1);
65
- const grow = easeOutCubic(Math.min(1, u / 0.58));
66
- const phase = 0.12 + u * 2.35;
67
- const art = (0, logo_1.sisuSplashFrame)(columns, color, phase, grow);
62
+ const phase = u * Math.PI * 2;
63
+ const art = (0, logo_1.sisuSplashFrame)(columns, color, phase);
68
64
  if (i === 0)
69
65
  io.write(`${art}\n`);
70
66
  else
@@ -199,17 +195,20 @@ async function runTui(io, deps = {}) {
199
195
  const columns = deps.columns ?? process.stdout.columns ?? 80;
200
196
  const animate = deps.animate ?? shouldAnimateSplash();
201
197
  try {
202
- if (animate) {
203
- await playTreeIntro(io, {
204
- columns,
205
- color: deps.color ?? true,
206
- sleep: deps.sleep,
207
- });
208
- }
209
- else {
210
- io.write(`${(0, logo_1.sisuSplash)(columns, true)}\n`);
211
- }
212
198
  const account = auth();
199
+ const usePager = Boolean(deps.pager || shouldUsePager(deps));
200
+ if (!usePager) {
201
+ if (animate) {
202
+ await playTreeIntro(io, {
203
+ columns,
204
+ color: deps.color ?? true,
205
+ sleep: deps.sleep,
206
+ });
207
+ }
208
+ else {
209
+ io.write(`${(0, logo_1.sisuSplash)(columns, true)}\n`);
210
+ }
211
+ }
213
212
  const startWebLogin = async (notify) => {
214
213
  return webLogin({
215
214
  onStart: (info) => {
@@ -218,13 +217,15 @@ async function runTui(io, deps = {}) {
218
217
  },
219
218
  }, http);
220
219
  };
221
- if (deps.pager || shouldUsePager(deps)) {
220
+ if (usePager) {
222
221
  io.close?.();
223
222
  const transport = (0, transport_1.createFastApiTransport)(http);
224
223
  return await (deps.pager ?? app_1.runPager)((0, stdio_1.stdioPagerIo)(), transport, {
225
224
  columns,
226
225
  email: account?.email,
227
226
  login: startWebLogin,
227
+ intro: animate,
228
+ sleep: deps.sleep,
228
229
  quota: async () => (0, commands_1.formatQuota)(await (0, commands_1.fetchBalance)(http)),
229
230
  status: () => status(http),
230
231
  ls: () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stevezhou/sisu",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "SiSu CLI — one login, cloud quota, local workspace",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://www.sisu.chat",