utharnessly 0.1.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 +26 -0
- package/bin/utharnessly.js +115 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Utharness Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# utharnessly
|
|
2
|
+
|
|
3
|
+
`utharnessly` is the npm launcher for the [Utharness](https://github.com/uthumany/utharnessly) local-first agent terminal. It downloads the matching GitHub Release archive on first use, verifies the published SHA-256 checksum, caches the native Rust runtime and bundled Ink UI, and forwards CLI arguments to `utharness`.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx utharnessly --help
|
|
9
|
+
npx utharnessly --version
|
|
10
|
+
npx utharnessly
|
|
11
|
+
npm install --global utharnessly
|
|
12
|
+
utharness init
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The release launcher currently publishes Linux x64, macOS x64, and Windows x64 artifacts. Other architectures and operating systems should use the documented source-build or remote-host workflow in the repository installation guide.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
utharnessly update
|
|
19
|
+
utharnessly uninstall
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`uninstall` prints the package and cache removal commands; it does not silently mutate the global npm installation.
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
MIT. See the repository for the full license and development instructions.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { createWriteStream } from 'node:fs';
|
|
4
|
+
import { promises as fs } from 'node:fs';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { pipeline } from 'node:stream/promises';
|
|
8
|
+
import { execFile, spawn } from 'node:child_process';
|
|
9
|
+
import { promisify } from 'node:util';
|
|
10
|
+
|
|
11
|
+
const execFileAsync = promisify(execFile);
|
|
12
|
+
|
|
13
|
+
const VERSION = '0.1.0';
|
|
14
|
+
const REPOSITORY = 'uthumany/utharnessly';
|
|
15
|
+
const BASE_URL = (process.env.UTHARNESSLY_RELEASE_BASE_URL || `https://github.com/${REPOSITORY}/releases/download/v${VERSION}`).replace(/\/$/, '');
|
|
16
|
+
|
|
17
|
+
function platformAsset() {
|
|
18
|
+
const platform = process.platform;
|
|
19
|
+
const arch = process.arch;
|
|
20
|
+
if (platform === 'linux' && arch === 'x64') return ['utharnessly-linux-x64.tar.gz', 'tar.gz'];
|
|
21
|
+
if (platform === 'darwin' && arch === 'x64') return ['utharnessly-macos-x64.tar.gz', 'tar.gz'];
|
|
22
|
+
if (platform === 'win32' && arch === 'x64') return ['utharnessly-windows-x64.zip', 'zip'];
|
|
23
|
+
throw new Error(`No published utharnessly binary for ${platform}/${arch}. Supported release targets are Linux x64, macOS x64, and Windows x64; use the source instructions at https://github.com/${REPOSITORY} on other targets.`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function cacheRoot() {
|
|
27
|
+
const base = process.env.XDG_CACHE_HOME || (process.platform === 'win32' ? process.env.LOCALAPPDATA : path.join(os.homedir(), '.cache')) || os.tmpdir();
|
|
28
|
+
return path.join(base, 'utharnessly', VERSION);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function download(url, destination) {
|
|
32
|
+
const response = await fetch(url, { redirect: 'follow' });
|
|
33
|
+
if (!response.ok || !response.body) throw new Error(`download failed (${response.status}) for ${url}`);
|
|
34
|
+
await pipeline(response.body, createWriteStream(destination));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function verifyChecksum(archive, checksumFile) {
|
|
38
|
+
const contents = await fs.readFile(checksumFile, 'utf8');
|
|
39
|
+
const asset = path.basename(archive);
|
|
40
|
+
const line = contents.split(/\r?\n/).find((entry) => entry.includes(asset));
|
|
41
|
+
if (!line) throw new Error(`SHA256SUMS does not contain ${asset}`);
|
|
42
|
+
const expected = line.trim().split(/\s+/)[0].toLowerCase();
|
|
43
|
+
const hash = createHash('sha256').update(await fs.readFile(archive)).digest('hex');
|
|
44
|
+
if (hash !== expected) throw new Error(`checksum verification failed for ${asset}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function extractArchive(archive, format, destination) {
|
|
48
|
+
if (format === 'tar.gz') {
|
|
49
|
+
await execFileAsync('tar', ['-xzf', archive, '-C', destination]);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (format === 'zip') {
|
|
53
|
+
await execFileAsync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', `Expand-Archive -LiteralPath '${archive.replaceAll("'", "''")}' -DestinationPath '${destination.replaceAll("'", "''")}' -Force`]);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`unsupported archive format: ${format}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function ensureBinary(force = false) {
|
|
60
|
+
const [asset, format] = platformAsset();
|
|
61
|
+
const root = cacheRoot();
|
|
62
|
+
const binary = path.join(root, process.platform === 'win32' ? 'utharness.exe' : 'utharness');
|
|
63
|
+
if (!force) {
|
|
64
|
+
try { await fs.access(binary); return { binary, ui: path.join(root, 'ui') }; } catch {}
|
|
65
|
+
}
|
|
66
|
+
await fs.rm(root, { recursive: true, force: true });
|
|
67
|
+
await fs.mkdir(root, { recursive: true });
|
|
68
|
+
const temp = await fs.mkdtemp(path.join(os.tmpdir(), 'utharnessly-'));
|
|
69
|
+
const archive = path.join(temp, asset);
|
|
70
|
+
const checksums = path.join(temp, 'SHA256SUMS');
|
|
71
|
+
try {
|
|
72
|
+
process.stderr.write(`Downloading utharnessly v${VERSION} (${process.platform}/${process.arch})…\n`);
|
|
73
|
+
await download(`${BASE_URL}/${asset}`, archive);
|
|
74
|
+
await download(`${BASE_URL}/SHA256SUMS`, checksums);
|
|
75
|
+
await verifyChecksum(archive, checksums);
|
|
76
|
+
const extracted = path.join(temp, 'extracted');
|
|
77
|
+
await fs.mkdir(extracted);
|
|
78
|
+
await extractArchive(archive, format, extracted);
|
|
79
|
+
const packageRoot = (await fs.readdir(extracted, { withFileTypes: true })).find((entry) => entry.isDirectory() && entry.name.startsWith('utharnessly-'));
|
|
80
|
+
if (!packageRoot) throw new Error('release archive did not contain an utharnessly directory');
|
|
81
|
+
const sourceRoot = path.join(extracted, packageRoot.name);
|
|
82
|
+
await fs.copyFile(path.join(sourceRoot, path.basename(binary)), binary);
|
|
83
|
+
if (process.platform !== 'win32') await fs.chmod(binary, 0o755);
|
|
84
|
+
await fs.cp(path.join(sourceRoot, 'ui'), path.join(root, 'ui'), { recursive: true });
|
|
85
|
+
return { binary, ui: path.join(root, 'ui') };
|
|
86
|
+
} finally {
|
|
87
|
+
await fs.rm(temp, { recursive: true, force: true });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function run(binary, args) {
|
|
92
|
+
const child = spawn(binary, args, { stdio: 'inherit', env: { ...process.env, UTHARNESS_RUNTIME_BIN: binary } });
|
|
93
|
+
child.on('error', (error) => { console.error(`utharnessly: ${error.message}`); process.exitCode = 1; });
|
|
94
|
+
child.on('exit', (code, signal) => { process.exitCode = signal ? 1 : (code ?? 1); });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const args = process.argv.slice(2);
|
|
98
|
+
if (args.includes('--version') || args.includes('-V')) {
|
|
99
|
+
console.log(`utharnessly ${VERSION}`);
|
|
100
|
+
process.exit(0);
|
|
101
|
+
}
|
|
102
|
+
if (args[0] === 'update') {
|
|
103
|
+
try { await ensureBinary(true); console.log(`utharnessly ${VERSION} is ready.`); } catch (error) { console.error(`utharnessly update failed: ${error.message}`); process.exitCode = 1; }
|
|
104
|
+
} else if (args[0] === 'uninstall') {
|
|
105
|
+
console.log('Remove the npm package with: npm uninstall -g utharnessly');
|
|
106
|
+
console.log(`Remove the cached native runtime with: ${process.platform === 'win32' ? 'rmdir /s /q' : 'rm -rf'} "${cacheRoot()}"`);
|
|
107
|
+
} else {
|
|
108
|
+
try {
|
|
109
|
+
const { binary } = await ensureBinary();
|
|
110
|
+
run(binary, args);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.error(`utharnessly: ${error.message}`);
|
|
113
|
+
process.exitCode = 1;
|
|
114
|
+
}
|
|
115
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "utharnessly",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Cross-platform launcher for the utharness local-first agent terminal",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"private": false,
|
|
7
|
+
"type": "module",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=18"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"utharnessly": "bin/utharnessly.js",
|
|
13
|
+
"utharness": "bin/utharnessly.js"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"bin/utharnessly.js",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/uthumany/utharnessly.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/uthumany/utharnessly/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/uthumany/utharnessly",
|
|
28
|
+
"keywords": [
|
|
29
|
+
"cli",
|
|
30
|
+
"terminal",
|
|
31
|
+
"agent",
|
|
32
|
+
"rust",
|
|
33
|
+
"ink",
|
|
34
|
+
"tui"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"check": "node --check bin/utharnessly.js",
|
|
38
|
+
"pack:check": "npm pack --dry-run"
|
|
39
|
+
}
|
|
40
|
+
}
|