@stevezhou/sisu 0.1.1 → 0.1.2

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/commands.js CHANGED
@@ -126,8 +126,15 @@ async function webLoginCommand(input = {}, http = http_1.defaultHttp) {
126
126
  }
127
127
  const started = await http(`${apiBase}/api/auth/cli/device`, { method: 'POST' });
128
128
  const startBody = await started.json().catch(() => ({}));
129
- if (!started.ok)
129
+ if (!started.ok) {
130
+ if (started.status === 404 || started.status === 405) {
131
+ throw new Error('Browser login is not on this server yet. Use: sisu login --email <email> --password <password>');
132
+ }
133
+ if (started.status === 503) {
134
+ throw new Error('Sign-in is temporarily unavailable. Try again in a moment.');
135
+ }
130
136
  throw new Error((0, http_1.errorDetail)(startBody, `device start failed (${started.status})`));
137
+ }
131
138
  const deviceCode = String(startBody.device_code || '');
132
139
  const userCode = String(startBody.user_code || '');
133
140
  const rawVerify = String(startBody.verification_uri_complete || startBody.verification_uri || '');
package/dist/pager/app.js CHANGED
@@ -12,12 +12,18 @@ const ALT_ENTER = '\x1b[?1049h\x1b[?25l';
12
12
  const ALT_LEAVE = '\x1b[?1049l\x1b[?25h';
13
13
  const CLEAR_HOME = '\x1b[2J\x1b[H';
14
14
  function formatChromeStatus(email, quota, conversationId) {
15
- const parts = [
16
- (email || '').trim() || 'not logged in',
17
- (quota || '').trim() || 'quota unavailable',
18
- conversationId || 'new',
19
- 'client=tui',
20
- ].filter((part) => part.length > 0);
15
+ const who = (email || '').trim();
16
+ if (!who) {
17
+ const conv = (conversationId || '').trim();
18
+ return conv && conv !== 'new' ? `sisu · not signed in · ${conv}` : 'sisu · not signed in';
19
+ }
20
+ const parts = [who];
21
+ const quotaText = (quota || '').trim();
22
+ if (quotaText && quotaText !== 'quota unavailable')
23
+ parts.push(quotaText);
24
+ const conv = (conversationId || '').trim();
25
+ if (conv && conv !== 'new')
26
+ parts.push(conv);
21
27
  return parts.join(' · ');
22
28
  }
23
29
  /** Short chrome fragment: `quota unlimited`, first `quota N pts`, or `quota unavailable`. */
@@ -89,9 +95,6 @@ async function runPager(io, transport, options = {}) {
89
95
  }
90
96
  };
91
97
  let state = withChrome((0, model_1.createPagerState)());
92
- if (!chromeEmail && options.login) {
93
- state = pushEntry(state, 'status', 'Not logged in. Type /login to sign in with your browser.');
94
- }
95
98
  let rest = '';
96
99
  let newConversation = false;
97
100
  let pickMode = false;
@@ -88,6 +88,25 @@ function windowAroundSelected(lines, entryOf, selected, budget, lastEntry) {
88
88
  const windowStart = Math.max(0, Math.min(start, end + 1 - budget));
89
89
  return lines.slice(windowStart, windowStart + budget);
90
90
  }
91
+ function isIdleWelcome(state) {
92
+ return !state.conversationId && state.entries.length === 0;
93
+ }
94
+ function welcomeLines(guest) {
95
+ if (guest) {
96
+ return [
97
+ 'SISU',
98
+ '',
99
+ 'Sign in to start a conversation.',
100
+ '/login open the browser',
101
+ '/help commands',
102
+ ];
103
+ }
104
+ return [
105
+ 'SISU',
106
+ '',
107
+ 'Ask anything, or type /help.',
108
+ ];
109
+ }
91
110
  function slashMenuLines(state) {
92
111
  if (!state.slashOpen)
93
112
  return [];
@@ -116,13 +135,17 @@ function renderPager(state, cols, rows, theme = 'dark') {
116
135
  const bodyBudget = Math.max(0, height - chrome);
117
136
  const slash = slashMenuLines(state);
118
137
  const slashTake = Math.min(slash.length, bodyBudget);
119
- const scrollBudget = bodyBudget - slashTake;
138
+ const guest = !(state.statusLine || '').trim() || (state.statusLine || '').includes('not signed in');
139
+ const welcome = isIdleWelcome(state) ? welcomeLines(guest).map((line) => (line ? ` ${line}` : '')) : [];
140
+ const welcomeTake = Math.min(welcome.length, Math.max(0, bodyBudget - slashTake));
141
+ const scrollBudget = bodyBudget - slashTake - welcomeTake;
120
142
  const laid = layoutScrollback(state, width);
121
143
  const lastEntry = Math.max(0, state.entries.length - 1);
122
144
  const visibleScroll = windowAroundSelected(laid.lines, laid.entryOf, state.selected, scrollBudget, lastEntry);
123
145
  const body = [];
124
- // Top-pad scrollback so newest content sits just above slash/status/prompt.
125
- while (body.length + visibleScroll.length < scrollBudget) {
146
+ body.push(...welcome.slice(0, welcomeTake));
147
+ // Top-pad remaining scrollback so live status sits just above slash/prompt.
148
+ while (body.length + visibleScroll.length < welcomeTake + scrollBudget) {
126
149
  body.push('');
127
150
  }
128
151
  body.push(...visibleScroll);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stevezhou/sisu",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "SiSu CLI — one login, cloud quota, local workspace",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://www.sisu.chat",