@pikibun/tui 0.0.0-stage → 0.39.0
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/LICENSE +21 -0
- package/README.md +42 -2
- package/app/app.json +4 -0
- package/app/assets/src/assets/logo.png +0 -0
- package/app/bundle.js +127 -0
- package/app/bundle.js.map +1 -0
- package/app/capabilities.json +1 -0
- package/bin/pikibun-tui.js +130 -0
- package/package.json +38 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"network":{"hosts":["*"],"http":[]},"process":{"execute":["zsh","bash","sh","cmd","schtasks","wsl"],"exit":true,"env":["SHELL","USER","LOGNAME","TERM","XDG_RUNTIME_DIR","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_STATE_HOME","XDG_CACHE_HOME","PATHEXT","ComSpec","APPDATA","LOCALAPPDATA","ProgramFiles","ProgramData","SystemDrive","windir","USERNAME","USERDOMAIN","COMPUTERNAME","DISPLAY","WAYLAND_DISPLAY","XAUTHORITY","DBUS_SESSION_BUS_ADDRESS","XDG_SESSION_TYPE","XDG_CURRENT_DESKTOP","PIKIBUN_MXC_RUNTIME","SSH_AUTH_SOCK","SSH_AGENT_PID","HTTPS_PROXY","https_proxy","HTTP_PROXY","http_proxy","ALL_PROXY","all_proxy","NO_PROXY","no_proxy"]},"fs":{"read":["${dataDir}/updates","${dataDir}/cli"],"write":["${dataDir}/updates"]},"webview":{"hosts":["*"]},"statusBar":true,"clipboard":true,"picker":true,"notifications":true,"audio":true,"application":true,"homeDir":true,"host":["page.*"],"openUrl":true}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// packages/tui/src/bin.ts
|
|
4
|
+
import path2 from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
// packages/tui/src/launcher.ts
|
|
8
|
+
import { spawn } from "node:child_process";
|
|
9
|
+
import { accessSync, chmodSync, constants, mkdirSync, readFileSync } from "node:fs";
|
|
10
|
+
import { createRequire } from "node:module";
|
|
11
|
+
import { constants as osConstants, homedir } from "node:os";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
var TUI_HOSTS = ["linux-x64", "linux-arm64", "darwin-arm64", "darwin-x64", "win32-x64", "win32-arm64"];
|
|
14
|
+
var USAGE = `Usage: pikibun-tui [options]
|
|
15
|
+
|
|
16
|
+
Pikibun in this terminal: sign in, your sessions and their chats, as in the Pikibun app.
|
|
17
|
+
|
|
18
|
+
Options:
|
|
19
|
+
--no-mouse Leave the mouse to the terminal and its own text selection
|
|
20
|
+
--points-per-cell <WxH> The size of one terminal Cell in points (8x16 by default)
|
|
21
|
+
--fps Show the frame rate and frame times (Ctrl+H then P toggles it)
|
|
22
|
+
--log-file <path> Where the log goes (Ctrl+H then E shows it)
|
|
23
|
+
--data-dir <path> Where the app keeps its sign-ins and settings
|
|
24
|
+
--help Show this help
|
|
25
|
+
--version Show the installed version
|
|
26
|
+
|
|
27
|
+
Keys: Tab and the arrows move between controls, Enter presses, Escape goes back, Ctrl+S searches the screen,
|
|
28
|
+
F10 opens the menu bar, and Ctrl+C copies a selection or quits.
|
|
29
|
+
`;
|
|
30
|
+
function hostKey(platform = process.platform, arch = process.arch) {
|
|
31
|
+
const key = `${platform}-${arch}`;
|
|
32
|
+
return TUI_HOSTS.includes(key) ? key : null;
|
|
33
|
+
}
|
|
34
|
+
var hostPackage = (host) => `@pikibun/tui-${host}`;
|
|
35
|
+
var hostBinary = (platform = process.platform) => platform === "win32" ? "nsh-tui-host.exe" : "nsh-tui-host";
|
|
36
|
+
function findHost(options) {
|
|
37
|
+
const env = options.env ?? process.env;
|
|
38
|
+
if (env.PIKIBUN_TUI_HOST) return { path: env.PIKIBUN_TUI_HOST };
|
|
39
|
+
const platform = options.platform ?? process.platform;
|
|
40
|
+
const arch = options.arch ?? process.arch;
|
|
41
|
+
const host = hostKey(platform, arch);
|
|
42
|
+
if (!host) {
|
|
43
|
+
return { error: `Pikibun's terminal app has no build for ${platform}-${arch}: it runs on Linux, macOS and Windows, on x64 and arm64.` };
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
return { path: options.resolve(`${hostPackage(host)}/bin/${hostBinary(platform)}`) };
|
|
47
|
+
} catch {
|
|
48
|
+
return {
|
|
49
|
+
error: `${hostPackage(host)}, this computer's part of Pikibun's terminal app, isn't installed. npm installs it with @pikibun/tui unless optional dependencies are left out (--omit=optional, --no-optional, or npm's omit setting): install @pikibun/tui again without that, for example npm install -g @pikibun/tui --include=optional.`
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function logFile(env = process.env, platform = process.platform, home = homedir()) {
|
|
54
|
+
if (platform === "darwin") return path.join(home, "Library", "Logs", "Pikibun", "tui.log");
|
|
55
|
+
if (platform === "win32") return path.win32.join(env.LOCALAPPDATA || path.win32.join(home, "AppData", "Local"), "Pikibun", "Logs", "tui.log");
|
|
56
|
+
return path.join(env.XDG_STATE_HOME || path.join(home, ".local", "state"), "pikibun", "tui.log");
|
|
57
|
+
}
|
|
58
|
+
var named = (args, option) => args.some((arg) => arg === option || arg.startsWith(`${option}=`));
|
|
59
|
+
function hostArguments(args, bundle, log) {
|
|
60
|
+
return ["--bundle", bundle, ...named(args, "--log-file") ? [] : ["--log-file", log], ...args];
|
|
61
|
+
}
|
|
62
|
+
function exitCode(code, signal) {
|
|
63
|
+
if (code !== null) return code;
|
|
64
|
+
const number = signal ? osConstants.signals[signal] : void 0;
|
|
65
|
+
return number ? 128 + number : 1;
|
|
66
|
+
}
|
|
67
|
+
function executable(file) {
|
|
68
|
+
if (process.platform === "win32") return;
|
|
69
|
+
try {
|
|
70
|
+
accessSync(file, constants.X_OK);
|
|
71
|
+
} catch {
|
|
72
|
+
chmodSync(file, 493);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async function main(args, root) {
|
|
76
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
77
|
+
process.stdout.write(USAGE);
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
if (args.includes("--version") || args.includes("-v")) {
|
|
81
|
+
process.stdout.write(`${JSON.parse(readFileSync(path.join(root, "package.json"), "utf8")).version}
|
|
82
|
+
`);
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
86
|
+
process.stderr.write("pikibun-tui draws in a terminal: run it in one (its input and output aren't a terminal here).\n");
|
|
87
|
+
return 1;
|
|
88
|
+
}
|
|
89
|
+
const require2 = createRequire(path.join(root, "package.json"));
|
|
90
|
+
const found = findHost({ resolve: (id) => require2.resolve(id) });
|
|
91
|
+
if ("error" in found) {
|
|
92
|
+
process.stderr.write(`${found.error}
|
|
93
|
+
`);
|
|
94
|
+
return 1;
|
|
95
|
+
}
|
|
96
|
+
const log = logFile();
|
|
97
|
+
try {
|
|
98
|
+
executable(found.path);
|
|
99
|
+
if (!named(args, "--log-file")) mkdirSync(path.dirname(log), { recursive: true });
|
|
100
|
+
} catch (error) {
|
|
101
|
+
process.stderr.write(`Pikibun's terminal app can't start: ${error instanceof Error ? error.message : String(error)}
|
|
102
|
+
`);
|
|
103
|
+
return 1;
|
|
104
|
+
}
|
|
105
|
+
const child = spawn(found.path, hostArguments(args, path.join(root, "app", "bundle.js"), log), { stdio: "inherit" });
|
|
106
|
+
const ignore = () => {
|
|
107
|
+
};
|
|
108
|
+
const forward = (signal) => () => {
|
|
109
|
+
child.kill(signal);
|
|
110
|
+
};
|
|
111
|
+
const forwarded = ["SIGTERM", "SIGHUP"].map((signal) => [signal, forward(signal)]);
|
|
112
|
+
process.on("SIGINT", ignore);
|
|
113
|
+
for (const [signal, handler] of forwarded) process.on(signal, handler);
|
|
114
|
+
try {
|
|
115
|
+
return await new Promise((resolve) => {
|
|
116
|
+
child.once("error", (error) => {
|
|
117
|
+
process.stderr.write(`Pikibun's terminal app can't start: ${error.message}
|
|
118
|
+
`);
|
|
119
|
+
resolve(1);
|
|
120
|
+
});
|
|
121
|
+
child.once("exit", (code, signal) => resolve(exitCode(code, signal)));
|
|
122
|
+
});
|
|
123
|
+
} finally {
|
|
124
|
+
process.off("SIGINT", ignore);
|
|
125
|
+
for (const [signal, handler] of forwarded) process.off(signal, handler);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// packages/tui/src/bin.ts
|
|
130
|
+
process.exitCode = await main(process.argv.slice(2), path2.dirname(path2.dirname(fileURLToPath(import.meta.url))));
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikibun/tui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.39.0",
|
|
4
|
+
"description": "Pikibun in your terminal: the Pikibun app, drawn in the terminal by Native Shell.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://pikibun.com",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/OpenCara/pikibun.git",
|
|
10
|
+
"directory": "packages/tui"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"pikibun",
|
|
14
|
+
"pi",
|
|
15
|
+
"agent",
|
|
16
|
+
"tui",
|
|
17
|
+
"terminal"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"bin": {
|
|
21
|
+
"pikibun-tui": "bin/pikibun-tui.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"bin",
|
|
25
|
+
"app",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
},
|
|
32
|
+
"optionalDependencies": {
|
|
33
|
+
"@pikibun/tui-linux-x64": "0.39.0",
|
|
34
|
+
"@pikibun/tui-linux-arm64": "0.39.0",
|
|
35
|
+
"@pikibun/tui-darwin-arm64": "0.39.0",
|
|
36
|
+
"@pikibun/tui-darwin-x64": "0.39.0",
|
|
37
|
+
"@pikibun/tui-win32-x64": "0.39.0",
|
|
38
|
+
"@pikibun/tui-win32-arm64": "0.39.0"
|
|
39
|
+
}
|
|
40
|
+
}
|