@stevezhou/sisu 0.2.0 → 0.2.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/README.md +3 -0
- package/dist/logo.js +17 -3
- package/dist/main.js +9 -2
- package/dist/runtime/launch.js +2 -0
- package/package.json +6 -3
- package/scripts/install-pager.js +156 -0
- package/scripts/postinstall.js +18 -0
package/README.md
CHANGED
|
@@ -10,8 +10,11 @@ One login. Cloud quota. Local runtime. Auth lives in `~/.sisu`, shared with SiSu
|
|
|
10
10
|
npm install -g @stevezhou/sisu
|
|
11
11
|
sisu --help
|
|
12
12
|
sisu login
|
|
13
|
+
sisu
|
|
13
14
|
```
|
|
14
15
|
|
|
16
|
+
`npm install -g` is the same shape as `@xai-official/grok`: a small JS package. On macOS Apple Silicon the postinstall pulls the prebuilt Grok Build TUI into `~/.sisu/bin`. Other platforms keep the Node TUI until those binaries are published.
|
|
17
|
+
|
|
15
18
|
Requires Node.js 20 or newer. `npx sisu` works without a global install.
|
|
16
19
|
|
|
17
20
|
## Login
|
package/dist/logo.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SISU_STILL_PHASE = exports.sisuTreeLines = exports.sisuTreeArt = exports.sisuMarkLines = exports.sisuMarkArt = void 0;
|
|
3
|
+
exports.SISU_STILL_PHASE = exports.SISU_BRAND = exports.sisuTreeLines = exports.sisuTreeArt = exports.sisuMarkLines = exports.sisuMarkArt = void 0;
|
|
4
4
|
exports.sisuMobiusArt = sisuMobiusArt;
|
|
5
5
|
exports.sisuWordmark = sisuWordmark;
|
|
6
|
+
exports.sisuProductSurfaces = sisuProductSurfaces;
|
|
6
7
|
exports.displayWidth = displayWidth;
|
|
7
8
|
exports.sisuSplashFrame = sisuSplashFrame;
|
|
8
9
|
exports.sisuSplashHeight = sisuSplashHeight;
|
|
@@ -22,7 +23,12 @@ const theme_1 = require("./pager/theme");
|
|
|
22
23
|
const RESET = '\x1b[0m';
|
|
23
24
|
const INK = '\x1b[38;2;220;214;204m';
|
|
24
25
|
const INK_DIM = '\x1b[38;2;140;132;120m';
|
|
25
|
-
|
|
26
|
+
exports.SISU_BRAND = {
|
|
27
|
+
zh: '思溯',
|
|
28
|
+
en: 'SiSu',
|
|
29
|
+
headline: '思有所溯',
|
|
30
|
+
};
|
|
31
|
+
const HEADLINE = exports.SISU_BRAND.headline;
|
|
26
32
|
function sisuMobiusArt(columns = 80, phase = 0, color = false) {
|
|
27
33
|
return (0, mobius_1.renderMobiusFrame)({
|
|
28
34
|
cols: (0, mobius_1.mobiusFrameWidth)(columns),
|
|
@@ -32,7 +38,15 @@ function sisuMobiusArt(columns = 80, phase = 0, color = false) {
|
|
|
32
38
|
});
|
|
33
39
|
}
|
|
34
40
|
function sisuWordmark() {
|
|
35
|
-
return [
|
|
41
|
+
return [exports.SISU_BRAND.zh, exports.SISU_BRAND.en.toUpperCase()].join('\n');
|
|
42
|
+
}
|
|
43
|
+
/** First-surface copy: splash, welcome, help, about. */
|
|
44
|
+
function sisuProductSurfaces() {
|
|
45
|
+
return {
|
|
46
|
+
splash: stripAnsi(sisuSplash(72, false)),
|
|
47
|
+
welcome: sisuWelcomeCopy(false, false).join('\n'),
|
|
48
|
+
helpAbout: `sisu — ${exports.SISU_BRAND.en} · ${exports.SISU_BRAND.zh} · ${exports.SISU_BRAND.headline}`,
|
|
49
|
+
};
|
|
36
50
|
}
|
|
37
51
|
function displayWidth(text) {
|
|
38
52
|
return (0, theme_1.visibleWidth)(text);
|
package/dist/main.js
CHANGED
|
@@ -5,10 +5,12 @@ exports.helpText = helpText;
|
|
|
5
5
|
exports.runCli = runCli;
|
|
6
6
|
const commands_1 = require("./commands");
|
|
7
7
|
const http_1 = require("./http");
|
|
8
|
+
const client_1 = require("./client");
|
|
9
|
+
const logo_1 = require("./logo");
|
|
8
10
|
const store_1 = require("./store");
|
|
9
11
|
const tui_1 = require("./tui");
|
|
10
12
|
function helpText() {
|
|
11
|
-
return
|
|
13
|
+
return `${(0, logo_1.sisuProductSurfaces)().helpAbout}
|
|
12
14
|
|
|
13
15
|
One login. Cloud quota. Local workspace.
|
|
14
16
|
|
|
@@ -31,7 +33,8 @@ Usage:
|
|
|
31
33
|
sisu history
|
|
32
34
|
sisu thread <conversation-id>
|
|
33
35
|
sisu training --on|--off
|
|
34
|
-
sisu
|
|
36
|
+
sisu interactive TUI (思溯 / SiSu · 思有所溯)
|
|
37
|
+
sisu --version
|
|
35
38
|
sisu help
|
|
36
39
|
|
|
37
40
|
Auth and workspaces live in $SISU_HOME (default ~/.sisu), shared with Desktop.
|
|
@@ -72,6 +75,10 @@ async function runCli(argv, deps = {}) {
|
|
|
72
75
|
printHelp();
|
|
73
76
|
return 0;
|
|
74
77
|
}
|
|
78
|
+
if (command === '--version' || command === '-V' || command === 'version') {
|
|
79
|
+
process.stdout.write(`sisu ${client_1.SISU_CLIENT_VERSION} — ${logo_1.SISU_BRAND.zh} ${logo_1.SISU_BRAND.en} · ${logo_1.SISU_BRAND.headline}\n`);
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
75
82
|
if (!command || command === 'tui') {
|
|
76
83
|
return (0, tui_1.runTui)((0, tui_1.defaultTuiIo)());
|
|
77
84
|
}
|
package/dist/runtime/launch.js
CHANGED
|
@@ -19,8 +19,10 @@ function grokBuildBinaryCandidates() {
|
|
|
19
19
|
const env = (process.env.SISU_GROK_BIN || '').trim();
|
|
20
20
|
const root = (0, suite_1.grokBuildRoot)();
|
|
21
21
|
const packaged = path_1.default.resolve(__dirname, '..', 'bin', 'xai-grok-pager');
|
|
22
|
+
const npmInstalled = path_1.default.join((0, store_1.getSisuHome)(), 'bin', process.platform === 'win32' ? 'xai-grok-pager.exe' : 'xai-grok-pager');
|
|
22
23
|
return [
|
|
23
24
|
env,
|
|
25
|
+
npmInstalled,
|
|
24
26
|
packaged,
|
|
25
27
|
path_1.default.join(root, 'target', 'release', 'xai-grok-pager'),
|
|
26
28
|
path_1.default.join(root, 'target', 'debug', 'xai-grok-pager'),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stevezhou/sisu",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "SiSu CLI —
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "SiSu CLI — 思溯 / SiSu · 思有所溯",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"homepage": "https://www.sisu.chat",
|
|
7
7
|
"bugs": {
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
"files": [
|
|
24
24
|
"dist",
|
|
25
25
|
"README.md",
|
|
26
|
-
"NOTICE"
|
|
26
|
+
"NOTICE",
|
|
27
|
+
"scripts/postinstall.js",
|
|
28
|
+
"scripts/install-pager.js"
|
|
27
29
|
],
|
|
28
30
|
"publishConfig": {
|
|
29
31
|
"access": "public"
|
|
@@ -32,6 +34,7 @@
|
|
|
32
34
|
"build": "tsc",
|
|
33
35
|
"prepack": "tsc",
|
|
34
36
|
"prepublishOnly": "npm test",
|
|
37
|
+
"postinstall": "node scripts/postinstall.js",
|
|
35
38
|
"test": "jest --runInBand",
|
|
36
39
|
"typecheck": "tsc --noEmit"
|
|
37
40
|
},
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Install the grok-build pager the same way @xai-official/grok does:
|
|
3
|
+
* tiny npm package + platform binary (brotli) unpacked into ~/.sisu/bin.
|
|
4
|
+
*/
|
|
5
|
+
const fs = require('fs')
|
|
6
|
+
const https = require('https')
|
|
7
|
+
const os = require('os')
|
|
8
|
+
const path = require('path')
|
|
9
|
+
const zlib = require('zlib')
|
|
10
|
+
|
|
11
|
+
const SUPPORTED = new Set(['darwin-arm64'])
|
|
12
|
+
const BIN = process.platform === 'win32' ? 'xai-grok-pager.exe' : 'xai-grok-pager'
|
|
13
|
+
|
|
14
|
+
function readVersion() {
|
|
15
|
+
try {
|
|
16
|
+
return require('../package.json').version
|
|
17
|
+
} catch {
|
|
18
|
+
return ''
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function sisuHome() {
|
|
23
|
+
const override = (process.env.SISU_HOME || '').trim()
|
|
24
|
+
if (override) return override
|
|
25
|
+
return path.join(os.homedir(), '.sisu')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function pagerBinDir() {
|
|
29
|
+
return path.join(sisuHome(), 'bin')
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function pagerBinPath() {
|
|
33
|
+
return path.join(pagerBinDir(), BIN)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function platformKey() {
|
|
37
|
+
return `${process.platform}-${process.arch}`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function releaseAssetUrl(version, key) {
|
|
41
|
+
return `https://github.com/hyzhou1990/sisu-cli/releases/download/v${version}/xai-grok-pager-${key}.br`
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function pagerStampPath(dest) {
|
|
45
|
+
return `${dest}.version`
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function installedPagerVersion(dest) {
|
|
49
|
+
try {
|
|
50
|
+
return fs.readFileSync(pagerStampPath(dest), 'utf8').trim()
|
|
51
|
+
} catch {
|
|
52
|
+
return ''
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function writeBinary(bytes, dest) {
|
|
57
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true, mode: 0o700 })
|
|
58
|
+
const tmp = `${dest}.tmp.${process.pid}`
|
|
59
|
+
fs.writeFileSync(tmp, bytes)
|
|
60
|
+
if (process.platform !== 'win32') fs.chmodSync(tmp, 0o755)
|
|
61
|
+
fs.renameSync(tmp, dest)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function writePagerStamp(dest, version) {
|
|
65
|
+
if (!version) return
|
|
66
|
+
fs.writeFileSync(pagerStampPath(dest), `${version}\n`, { encoding: 'utf8', mode: 0o644 })
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function decodePayload(buf) {
|
|
70
|
+
try {
|
|
71
|
+
return zlib.brotliDecompressSync(buf)
|
|
72
|
+
} catch {
|
|
73
|
+
return buf
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function download(url) {
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
const req = https.get(url, { headers: { 'User-Agent': 'sisu-cli' } }, (res) => {
|
|
80
|
+
if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
81
|
+
res.resume()
|
|
82
|
+
download(res.headers.location).then(resolve, reject)
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
if (res.statusCode !== 200) {
|
|
86
|
+
res.resume()
|
|
87
|
+
reject(new Error(`download ${url} failed (${res.statusCode})`))
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
const chunks = []
|
|
91
|
+
res.on('data', (chunk) => chunks.push(chunk))
|
|
92
|
+
res.on('end', () => resolve(Buffer.concat(chunks)))
|
|
93
|
+
res.on('error', reject)
|
|
94
|
+
})
|
|
95
|
+
req.on('error', reject)
|
|
96
|
+
req.setTimeout(120_000, () => {
|
|
97
|
+
req.destroy(new Error('download timed out'))
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async function installPager(options = {}) {
|
|
103
|
+
const key = options.platform || platformKey()
|
|
104
|
+
const version = options.version || readVersion()
|
|
105
|
+
const dest = options.dest || pagerBinPath()
|
|
106
|
+
if (!SUPPORTED.has(key)) {
|
|
107
|
+
return { ok: false, skipped: true, reason: `no prebuilt pager for ${key}` }
|
|
108
|
+
}
|
|
109
|
+
const have = fs.existsSync(dest)
|
|
110
|
+
const stamped = have ? installedPagerVersion(dest) : ''
|
|
111
|
+
if (!options.force && have && version && stamped === version) {
|
|
112
|
+
return { ok: true, dest, skipped: true, reason: 'already installed' }
|
|
113
|
+
}
|
|
114
|
+
if (options.file) {
|
|
115
|
+
const raw = decodePayload(fs.readFileSync(options.file))
|
|
116
|
+
writeBinary(raw, dest)
|
|
117
|
+
writePagerStamp(dest, version)
|
|
118
|
+
return { ok: true, dest }
|
|
119
|
+
}
|
|
120
|
+
if (!version) return { ok: false, reason: 'missing package version' }
|
|
121
|
+
const url = options.url || releaseAssetUrl(version, key)
|
|
122
|
+
const payload = await download(url)
|
|
123
|
+
writeBinary(decodePayload(payload), dest)
|
|
124
|
+
writePagerStamp(dest, version)
|
|
125
|
+
return { ok: true, dest, url }
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
module.exports = {
|
|
129
|
+
SUPPORTED,
|
|
130
|
+
decodePayload,
|
|
131
|
+
installPager,
|
|
132
|
+
installedPagerVersion,
|
|
133
|
+
pagerBinPath,
|
|
134
|
+
pagerStampPath,
|
|
135
|
+
platformKey,
|
|
136
|
+
releaseAssetUrl,
|
|
137
|
+
writeBinary,
|
|
138
|
+
writePagerStamp,
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (require.main === module) {
|
|
142
|
+
installPager({ force: process.argv.includes('--force') }).then(
|
|
143
|
+
(result) => {
|
|
144
|
+
if (result.ok) {
|
|
145
|
+
if (!result.skipped) process.stdout.write(`installed grok pager to ${result.dest}\n`)
|
|
146
|
+
process.exit(0)
|
|
147
|
+
}
|
|
148
|
+
process.stderr.write(`sisu pager: ${result.reason}\n`)
|
|
149
|
+
process.exit(result.skipped ? 0 : 1)
|
|
150
|
+
},
|
|
151
|
+
(error) => {
|
|
152
|
+
process.stderr.write(`sisu pager: ${error instanceof Error ? error.message : String(error)}\n`)
|
|
153
|
+
process.exit(1)
|
|
154
|
+
},
|
|
155
|
+
)
|
|
156
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Best-effort: fetch the grok-build pager like @xai-official/grok postinstall.
|
|
3
|
+
* Never fail `npm install` — Node TUI still works without the binary.
|
|
4
|
+
*/
|
|
5
|
+
const { installPager } = require('./install-pager')
|
|
6
|
+
|
|
7
|
+
installPager().then(
|
|
8
|
+
(result) => {
|
|
9
|
+
if (result.ok && !result.skipped) {
|
|
10
|
+
process.stdout.write(`sisu: grok pager -> ${result.dest}\n`)
|
|
11
|
+
} else if (!result.ok && result.reason) {
|
|
12
|
+
process.stdout.write(`sisu: ${result.reason} (Node TUI still works)\n`)
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
(error) => {
|
|
16
|
+
process.stdout.write(`sisu: pager download skipped (${error instanceof Error ? error.message : String(error)})\n`)
|
|
17
|
+
},
|
|
18
|
+
)
|