@tianmucreations/jeeves 0.2.0 → 0.2.1
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/index.js +1 -1
- package/package.json +3 -3
- package/dist/components/AlternateScreen.js +0 -74
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ if (!process.stdin.isTTY) {
|
|
|
27
27
|
const program = new Command();
|
|
28
28
|
program
|
|
29
29
|
.name('jeeves')
|
|
30
|
-
.version('0.2.
|
|
30
|
+
.version('0.2.1')
|
|
31
31
|
.description('A plain-English terminal assistant.')
|
|
32
32
|
.argument('[prompt]', 'optional prompt to start with')
|
|
33
33
|
.action((prompt) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tianmucreations/jeeves",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A clean terminal assistant. Plain English in, job done. Works with any model.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tianmucreations",
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"homepage": "https://tianmucreations.com",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/tianmucreations/
|
|
12
|
+
"url": "git+https://github.com/tianmucreations/Jeeves.git"
|
|
13
13
|
},
|
|
14
14
|
"bugs": {
|
|
15
|
-
"url": "https://github.com/tianmucreations/
|
|
15
|
+
"url": "https://github.com/tianmucreations/Jeeves/issues"
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"files": [
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useInsertionEffect } from 'react';
|
|
3
|
-
import { Box, useStdout } from 'ink';
|
|
4
|
-
import { createRequire } from 'node:module';
|
|
5
|
-
// signal-exit is the cleanup hook the mechanism prescribes: it runs on process
|
|
6
|
-
// exit AND on every termination signal, before the default signal action - so
|
|
7
|
-
// the terminal is handed back on every exit path: normal exit, Ctrl+C, SIGTERM,
|
|
8
|
-
// hangup. Already present in the tree as Ink's own dependency; declared ours.
|
|
9
|
-
const onSignalExit = createRequire(import.meta.url)('signal-exit');
|
|
10
|
-
const CLEAR_SCREEN = '\x1b[2J';
|
|
11
|
-
const HOME_CURSOR = '\x1b[H';
|
|
12
|
-
const ERASE_SCROLLBACK = '\x1b[3J';
|
|
13
|
-
const ENTER_ALT_SCREEN = '\x1b[?1049h';
|
|
14
|
-
const LEAVE_ALT_SCREEN = '\x1b[?1049l';
|
|
15
|
-
const HIDE_CURSOR = '\x1b[?25l';
|
|
16
|
-
const SHOW_CURSOR = '\x1b[?25h';
|
|
17
|
-
let altScreenActive = false;
|
|
18
|
-
let cleanupRegistered = false;
|
|
19
|
-
function write(data) {
|
|
20
|
-
try {
|
|
21
|
-
process.stdout.write(data);
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
// A closed stream must never crash the takeover or the exit path.
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
// Claude Code's Ink fork exposes this on the render instance; stock Ink has no
|
|
28
|
-
// such method, so the notification lives here: the flag that says the alternate
|
|
29
|
-
// screen owns the terminal, consulted by every exit path below.
|
|
30
|
-
export function setAltScreenActive(active, mouseTracking) {
|
|
31
|
-
altScreenActive = active;
|
|
32
|
-
// Mouse tracking is deliberately left off: it would break click-drag text
|
|
33
|
-
// selection in Terminal.app, and the app already owns scrolling by key.
|
|
34
|
-
void mouseTracking;
|
|
35
|
-
}
|
|
36
|
-
// Hands the terminal back. Safe to call from anywhere, any number of times.
|
|
37
|
-
export function leaveAltScreen() {
|
|
38
|
-
if (!altScreenActive)
|
|
39
|
-
return;
|
|
40
|
-
altScreenActive = false;
|
|
41
|
-
// 1049l restores the shell's screen; the scrollback erase follows because
|
|
42
|
-
// macOS Terminal.app archives the app's own frames into the scrollback the
|
|
43
|
-
// moment the alternate screen is handed back, and they must not linger.
|
|
44
|
-
write(LEAVE_ALT_SCREEN + ERASE_SCROLLBACK + SHOW_CURSOR);
|
|
45
|
-
}
|
|
46
|
-
// The terminal must be restored on every exit path. Registered once for the
|
|
47
|
-
// whole process; the callback fires after Ink's own teardown (registered
|
|
48
|
-
// earlier), so frame cleanup lands on the alternate screen before we leave it.
|
|
49
|
-
function registerCleanup() {
|
|
50
|
-
if (cleanupRegistered)
|
|
51
|
-
return;
|
|
52
|
-
cleanupRegistered = true;
|
|
53
|
-
onSignalExit(() => leaveAltScreen(), { alwaysLast: false });
|
|
54
|
-
}
|
|
55
|
-
export function AlternateScreen({ children }) {
|
|
56
|
-
const { stdout } = useStdout();
|
|
57
|
-
// Entered once, before the first frame. Claude Code's order is erase
|
|
58
|
-
// scrollback, clear, home, switch - but macOS Terminal.app implements the
|
|
59
|
-
// clear (2J) by pushing the cleared screen INTO the scrollback, so erasing
|
|
60
|
-
// first lets the shell's last screen survive as scrollable history (measured:
|
|
61
|
-
// the banner came back on scroll). Clearing first and erasing the scrollback
|
|
62
|
-
// second kills both the old history and the clear's own snapshot; on terminals
|
|
63
|
-
// that clear without archiving, both orders are equivalent. The cursor is
|
|
64
|
-
// hidden for the same reason Ink's own mode hides it.
|
|
65
|
-
useInsertionEffect(() => {
|
|
66
|
-
write(CLEAR_SCREEN + HOME_CURSOR + ERASE_SCROLLBACK + ENTER_ALT_SCREEN + HIDE_CURSOR);
|
|
67
|
-
setAltScreenActive(true, false);
|
|
68
|
-
registerCleanup();
|
|
69
|
-
}, []);
|
|
70
|
-
const rows = Math.max(stdout.rows ?? 24, 8);
|
|
71
|
-
// The alternate screen has no native scrollback, so the app owns its own
|
|
72
|
-
// scrolling: everything is constrained to the terminal's row count.
|
|
73
|
-
return (_jsx(Box, { height: rows, flexDirection: "column", overflow: "hidden", children: children }));
|
|
74
|
-
}
|