slopie 1.7.0 → 1.7.5
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/bin/audit-splash.js +71 -0
- package/bin/potsherd.js +2 -0
- package/bin/slopie.js +2 -0
- package/dist/audit-native-worker.js +477 -767
- package/dist/audit-native-worker.js.map +4 -4
- package/dist/potsherd.js +18928 -20414
- package/dist/potsherd.js.map +4 -4
- package/package.json +2 -6
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Instant first frame for `slopie audit`.
|
|
2
|
+
//
|
|
3
|
+
// Loading the CLI bundle takes ~300 ms. For the interactive audit we paint a
|
|
4
|
+
// skeleton frame first (in well under 100 ms), so the screen responds at once;
|
|
5
|
+
// the real wallboard takes over the alternate screen as soon as it loads and
|
|
6
|
+
// calls `globalThis.__slopieSplash.handOff()`.
|
|
7
|
+
//
|
|
8
|
+
// If anything else ends up writing (an error, --help), the alternate screen is
|
|
9
|
+
// left first so the message stays visible, and the terminal is always restored
|
|
10
|
+
// on exit.
|
|
11
|
+
|
|
12
|
+
const PLAIN_FLAGS = new Set(['--json', '--plain', '--export', '--legacy', '--sweep', '--verify', '--help', '-h', '--version', '-V']);
|
|
13
|
+
|
|
14
|
+
export function auditSplash(argv = process.argv.slice(2)) {
|
|
15
|
+
const { stdin, stdout, stderr } = process;
|
|
16
|
+
if (argv[0] !== 'audit' || argv.some(arg => PLAIN_FLAGS.has(arg.split('=')[0]))) return;
|
|
17
|
+
if (!stdin.isTTY || !stdout.isTTY || process.env.SLOPIE_NO_SPLASH === '1') return;
|
|
18
|
+
const columns = stdout.columns || 80;
|
|
19
|
+
const rows = stdout.rows || 24;
|
|
20
|
+
if (columns < 40 || rows < 12) return;
|
|
21
|
+
|
|
22
|
+
const color = !('NO_COLOR' in process.env) && !argv.includes('--no-color') && process.env.TERM !== 'dumb';
|
|
23
|
+
const ascii = argv.includes('--ascii');
|
|
24
|
+
const paint = (code, text) => (color ? `\x1b[${code}m${text}\x1b[0m` : text);
|
|
25
|
+
const orange = '1;38;5;215';
|
|
26
|
+
const gray = '38;5;248';
|
|
27
|
+
const dark = '38;5;241';
|
|
28
|
+
|
|
29
|
+
const width = Math.min(132, columns - 4);
|
|
30
|
+
const margin = ' '.repeat(Math.floor((columns - width) / 2));
|
|
31
|
+
const status = 'reading your history…';
|
|
32
|
+
const block = ascii ? '.' : '░';
|
|
33
|
+
const lines = [];
|
|
34
|
+
lines[0] = margin + paint(orange, 'slopie') + ' '.repeat(Math.max(1, width - 6 - status.length)) + paint(gray, status);
|
|
35
|
+
for (let i = 2; i <= 4; i++) lines[i] = margin + paint(dark, block.repeat(20));
|
|
36
|
+
lines[5] = margin + paint(gray, 'what your tokens would cost at API prices');
|
|
37
|
+
lines[rows - 1] = margin + paint(orange, ascii ? '-' : '⠋') + ' ' + paint(gray, 'starting…');
|
|
38
|
+
|
|
39
|
+
let out = '\x1b[?1049h\x1b[H\x1b[2J\x1b[?25l';
|
|
40
|
+
lines.forEach((line, row) => {
|
|
41
|
+
if (line) out += `\x1b[${row + 1};1H${line}`;
|
|
42
|
+
});
|
|
43
|
+
stdout.write(out);
|
|
44
|
+
try { stdin.setRawMode(true); } catch { /* not a raw-capable tty */ }
|
|
45
|
+
|
|
46
|
+
let active = true;
|
|
47
|
+
const originalOut = stdout.write.bind(stdout);
|
|
48
|
+
const originalErr = stderr.write.bind(stderr);
|
|
49
|
+
const leave = () => {
|
|
50
|
+
if (!active) return;
|
|
51
|
+
active = false;
|
|
52
|
+
stdout.write = originalOut;
|
|
53
|
+
stderr.write = originalErr;
|
|
54
|
+
try { stdin.setRawMode(false); } catch { /* ignore */ }
|
|
55
|
+
originalOut('\x1b[0m\x1b[?25h\x1b[?1049l');
|
|
56
|
+
};
|
|
57
|
+
// Anything other than the wallboard writing first means we must get out of the way.
|
|
58
|
+
stdout.write = (...args) => { leave(); return stdout.write(...args); };
|
|
59
|
+
stderr.write = (...args) => { leave(); return stderr.write(...args); };
|
|
60
|
+
process.once('exit', leave);
|
|
61
|
+
|
|
62
|
+
globalThis.__slopieSplash = {
|
|
63
|
+
handOff() {
|
|
64
|
+
if (!active) return;
|
|
65
|
+
active = false;
|
|
66
|
+
stdout.write = originalOut;
|
|
67
|
+
stderr.write = originalErr;
|
|
68
|
+
process.off('exit', leave);
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
package/bin/potsherd.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// The published entry point. `dist/potsherd.js` is a single bundled file so
|
|
3
3
|
// that `npx potsherd audit` needs no workspace resolution and no build step.
|
|
4
|
+
import {auditSplash} from './audit-splash.js';
|
|
5
|
+
auditSplash();
|
|
4
6
|
import('../dist/potsherd.js').catch((err) => {
|
|
5
7
|
console.error('potsherd failed to start:', err?.message ?? err);
|
|
6
8
|
// NOT `npm i -g potsherd`: the package is unpublished, so that is a 404
|
package/bin/slopie.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Public Slopie launcher; storage and the potsherd launcher remain compatible.
|
|
3
3
|
process.env['POTSHERD_CLI_PUBLIC_NAME']='slopie';
|
|
4
|
+
import {auditSplash} from './audit-splash.js';
|
|
5
|
+
auditSplash();
|
|
4
6
|
import('../dist/potsherd.js').catch((err)=>{
|
|
5
7
|
console.error('slopie failed to start:',err?.message??err);
|
|
6
8
|
console.error('this usually means the package did not build. try: pnpm install && pnpm build');
|