@tk103331/oni3 0.0.0-stage → 0.3.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/README.md +16 -2
- package/bin/oni3.js +19 -0
- package/lib/install.js +119 -0
- package/package.json +36 -4
- package/scripts/install.js +10 -0
package/README.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# oni3 (npm)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Installs the [Oni3](https://github.com/tk103331/oni3) binary for your platform
|
|
4
|
+
and exposes the `oni3` command.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install -g oni3
|
|
8
|
+
|
|
9
|
+
oni3 # interactive TUI (last agent / built-in agent)
|
|
10
|
+
oni3 agent --agent minimax_agent
|
|
11
|
+
oni3 acp --agent minimax_agent
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Supported platforms are macOS, Linux and Windows on `x64` and `arm64`. The
|
|
15
|
+
platform binary is downloaded from the GitHub release matching this package
|
|
16
|
+
version on first install (or first run). Homebrew and `go install` are also
|
|
17
|
+
supported.
|
package/bin/oni3.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { spawnSync } = require('child_process');
|
|
5
|
+
|
|
6
|
+
let bin;
|
|
7
|
+
try {
|
|
8
|
+
bin = require('../lib/install').ensureBinarySync();
|
|
9
|
+
} catch (err) {
|
|
10
|
+
console.error(`oni3: ${err.message}`);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const result = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' });
|
|
15
|
+
if (result.error) {
|
|
16
|
+
console.error(`oni3: ${result.error.message}`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/lib/install.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { execFileSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
const REPO = 'tk103331/oni3';
|
|
8
|
+
const BINARY = 'oni3';
|
|
9
|
+
|
|
10
|
+
const OS_MAP = { darwin: 'darwin', linux: 'linux', win32: 'windows' };
|
|
11
|
+
const ARCH_MAP = { x64: 'amd64', arm64: 'arm64' };
|
|
12
|
+
|
|
13
|
+
function platformTarget() {
|
|
14
|
+
const os = OS_MAP[process.platform];
|
|
15
|
+
const arch = ARCH_MAP[process.arch];
|
|
16
|
+
if (!os || !arch) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return { os, arch };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function version() {
|
|
23
|
+
return require('../package.json').version;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function vendorDir() {
|
|
27
|
+
return path.join(__dirname, '..', 'vendor');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// assetName mirrors the goreleaser archive naming:
|
|
31
|
+
// oni3_<version>_<os>_<arch>.tar.gz, and .zip on Windows.
|
|
32
|
+
function assetName(v) {
|
|
33
|
+
const target = platformTarget();
|
|
34
|
+
if (!target) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const ext = target.os === 'windows' ? 'zip' : 'tar.gz';
|
|
38
|
+
return `${BINARY}_${v}_${target.os}_${target.arch}.${ext}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function binaryPath() {
|
|
42
|
+
const target = platformTarget();
|
|
43
|
+
if (!target) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const name = target.os === 'windows' ? `${BINARY}.exe` : BINARY;
|
|
47
|
+
return path.join(vendorDir(), name);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function download(url, dest) {
|
|
51
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
52
|
+
const tmp = `${dest}.tmp`;
|
|
53
|
+
try {
|
|
54
|
+
execFileSync('curl', ['-fsSL', url, '-o', tmp], { stdio: 'ignore' });
|
|
55
|
+
} catch (curlErr) {
|
|
56
|
+
try {
|
|
57
|
+
execFileSync('wget', ['-qO', tmp, url], { stdio: 'ignore' });
|
|
58
|
+
} catch (wgetErr) {
|
|
59
|
+
fs.rmSync(tmp, { force: true });
|
|
60
|
+
throw new Error(`failed to download ${url} (curl/wget unavailable)`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
fs.chmodSync(tmp, 0o644);
|
|
64
|
+
fs.renameSync(tmp, dest);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function extract(archive, dir) {
|
|
68
|
+
if (archive.endsWith('.zip')) {
|
|
69
|
+
// Windows: bsdtar ships with Windows 10 1803+ and reads zip archives.
|
|
70
|
+
// PowerShell's Expand-Archive is the fallback for older systems.
|
|
71
|
+
try {
|
|
72
|
+
execFileSync('tar', ['-xf', archive, '-C', dir], { stdio: 'ignore' });
|
|
73
|
+
return;
|
|
74
|
+
} catch (tarErr) {
|
|
75
|
+
try {
|
|
76
|
+
execFileSync(
|
|
77
|
+
'powershell',
|
|
78
|
+
['-NoProfile', '-Command', `Expand-Archive -LiteralPath '${archive}' -DestinationPath '${dir}' -Force`],
|
|
79
|
+
{ stdio: 'ignore' }
|
|
80
|
+
);
|
|
81
|
+
return;
|
|
82
|
+
} catch (psErr) {
|
|
83
|
+
throw new Error(`failed to extract ${archive} (tar and PowerShell unavailable): ${psErr.message}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
// Only unpack the binary; the archive also carries the docs.
|
|
89
|
+
execFileSync('tar', ['-xzf', archive, '-C', dir], { stdio: 'ignore' });
|
|
90
|
+
} catch (err) {
|
|
91
|
+
throw new Error(`failed to extract ${archive} (tar unavailable): ${err.message}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ensureBinarySync returns the path to the platform binary, downloading and
|
|
96
|
+
// unpacking the release archive on first use.
|
|
97
|
+
function ensureBinarySync() {
|
|
98
|
+
const target = platformTarget();
|
|
99
|
+
if (!target) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
`unsupported platform ${process.platform}/${process.arch}; install with Homebrew or go install instead`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
const dest = binaryPath();
|
|
105
|
+
if (fs.existsSync(dest)) {
|
|
106
|
+
return dest;
|
|
107
|
+
}
|
|
108
|
+
const v = version();
|
|
109
|
+
const archiveName = assetName(v);
|
|
110
|
+
const url = `https://github.com/${REPO}/releases/download/v${v}/${archiveName}`;
|
|
111
|
+
const archive = path.join(vendorDir(), archiveName);
|
|
112
|
+
download(url, archive);
|
|
113
|
+
extract(archive, vendorDir());
|
|
114
|
+
fs.rmSync(archive, { force: true });
|
|
115
|
+
fs.chmodSync(dest, 0o755);
|
|
116
|
+
return dest;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
module.exports = { ensureBinarySync, binaryPath, platformTarget, assetName, version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tk103331/oni3",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Oni3 — AI Agent TUI with tools, MCP and ACP support, built on Eino",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"oni3": "bin/oni3.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"lib",
|
|
12
|
+
"scripts",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"postinstall": "node scripts/install.js"
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=16"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/tk103331/oni3.git"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/tk103331/oni3",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/tk103331/oni3/issues"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"ai",
|
|
31
|
+
"agent",
|
|
32
|
+
"cli",
|
|
33
|
+
"tui",
|
|
34
|
+
"acp",
|
|
35
|
+
"oni3",
|
|
36
|
+
"eino"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Best-effort binary download during `npm install`. Failure is non-fatal:
|
|
4
|
+
// the launcher retries the download on first run.
|
|
5
|
+
try {
|
|
6
|
+
require('../lib/install').ensureBinarySync();
|
|
7
|
+
} catch (err) {
|
|
8
|
+
console.warn(`[oni3] binary download skipped: ${err.message}`);
|
|
9
|
+
console.warn('[oni3] it will be retried on first run');
|
|
10
|
+
}
|