@nonbot/cli 0.10.15 → 0.10.17
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/CHANGELOG.md +15 -0
- package/LICENSE +22 -11
- package/README.md +14 -1
- package/dist/commands/doctor.js +67 -24
- package/dist/commands/logs.js +1 -1
- package/dist/commands/mcp.js +409 -0
- package/dist/commands/run.js +1 -1
- package/dist/index.js +47 -15
- package/dist/lib/local-status.js +54 -0
- package/dist/lib/mcp-account.js +232 -0
- package/dist/lib/mcp-config.js +89 -11
- package/dist/lib/mcp-probe.js +226 -0
- package/dist/lib/mcp-trust.js +63 -0
- package/dist/lib/quickstart-menu.js +86 -0
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const MOUSE_ON = '\x1b[?1000h\x1b[?1006h';
|
|
2
|
+
const MOUSE_OFF = '\x1b[?1000l\x1b[?1006l';
|
|
3
|
+
const ASK_CURSOR = '\x1b[6n';
|
|
4
|
+
const CURSOR_REPORT = /\x1b\[(\d+);(\d+)R/;
|
|
5
|
+
const MOUSE_SGR = /\x1b\[<(\d+);(\d+);(\d+)([Mm])/g;
|
|
6
|
+
export function interpretInput(chunk, state, linesBelowHelp) {
|
|
7
|
+
let rest = chunk;
|
|
8
|
+
const cur = CURSOR_REPORT.exec(rest);
|
|
9
|
+
if (cur) {
|
|
10
|
+
state.helpRow = Number(cur[1]) - linesBelowHelp;
|
|
11
|
+
rest = rest.replace(CURSOR_REPORT, '');
|
|
12
|
+
}
|
|
13
|
+
let sawMouse = false;
|
|
14
|
+
for (const m of rest.matchAll(MOUSE_SGR)) {
|
|
15
|
+
sawMouse = true;
|
|
16
|
+
const button = Number(m[1]);
|
|
17
|
+
const y = Number(m[3]);
|
|
18
|
+
const press = m[4] === 'M';
|
|
19
|
+
if (press && button === 0 && state.helpRow !== null && y === state.helpRow)
|
|
20
|
+
return 'help';
|
|
21
|
+
}
|
|
22
|
+
rest = rest.replace(MOUSE_SGR, '');
|
|
23
|
+
if (rest === '')
|
|
24
|
+
return null;
|
|
25
|
+
if (sawMouse && rest.trim() === '')
|
|
26
|
+
return null;
|
|
27
|
+
if (/^[hH][\r\n]*$/.test(rest))
|
|
28
|
+
return 'help';
|
|
29
|
+
return 'exit';
|
|
30
|
+
}
|
|
31
|
+
export function linesBelow(printed, marker) {
|
|
32
|
+
const at = printed.indexOf(marker);
|
|
33
|
+
if (at < 0)
|
|
34
|
+
return 0;
|
|
35
|
+
const lineStart = printed.lastIndexOf('\n', at) + 1;
|
|
36
|
+
return (printed.slice(lineStart).match(/\n/g) ?? []).length;
|
|
37
|
+
}
|
|
38
|
+
export function menuIsInteractive(io, env = process.env) {
|
|
39
|
+
if (!io.stdin.isTTY || !io.stdout.isTTY)
|
|
40
|
+
return false;
|
|
41
|
+
if (env.CI || env.NONBOT_NO_MENU === '1')
|
|
42
|
+
return false;
|
|
43
|
+
return typeof io.stdin.setRawMode === 'function';
|
|
44
|
+
}
|
|
45
|
+
export function waitForMenuChoice(io, linesBelowHelp) {
|
|
46
|
+
const { stdin, stdout } = io;
|
|
47
|
+
const state = { helpRow: null };
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
let done = false;
|
|
50
|
+
const finish = (choice) => {
|
|
51
|
+
if (done)
|
|
52
|
+
return;
|
|
53
|
+
done = true;
|
|
54
|
+
stdin.off('data', onData);
|
|
55
|
+
process.off('SIGINT', onSig);
|
|
56
|
+
process.off('SIGTERM', onSig);
|
|
57
|
+
try {
|
|
58
|
+
stdout.write(MOUSE_OFF);
|
|
59
|
+
}
|
|
60
|
+
catch { }
|
|
61
|
+
try {
|
|
62
|
+
stdin.setRawMode(false);
|
|
63
|
+
}
|
|
64
|
+
catch { }
|
|
65
|
+
stdin.pause();
|
|
66
|
+
resolve(choice);
|
|
67
|
+
};
|
|
68
|
+
const onData = (buf) => {
|
|
69
|
+
const choice = interpretInput(buf.toString('utf-8'), state, linesBelowHelp);
|
|
70
|
+
if (choice)
|
|
71
|
+
finish(choice);
|
|
72
|
+
};
|
|
73
|
+
const onSig = () => finish('exit');
|
|
74
|
+
try {
|
|
75
|
+
stdin.setRawMode(true);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return resolve('exit');
|
|
79
|
+
}
|
|
80
|
+
stdin.resume();
|
|
81
|
+
stdin.on('data', onData);
|
|
82
|
+
process.once('SIGINT', onSig);
|
|
83
|
+
process.once('SIGTERM', onSig);
|
|
84
|
+
stdout.write(MOUSE_ON + ASK_CURSOR);
|
|
85
|
+
});
|
|
86
|
+
}
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.10.
|
|
1
|
+
export const VERSION = '0.10.17';
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nonbot/cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The local host for non.bot ▶ Run — opens a terminal on your machine and starts the work in your linked repo.",
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
7
7
|
"bin": {
|
|
8
8
|
"nonbot": "dist/index.js"
|
|
9
9
|
},
|