@withautonomi/ant 0.3.8

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 ADDED
@@ -0,0 +1,98 @@
1
+ # ant
2
+
3
+ The unified CLI for the [Autonomi](https://autonomi.com) network: store and retrieve data, and
4
+ manage local nodes.
5
+
6
+ This package distributes the same signed binary published on the
7
+ [ant-client releases page](https://github.com/WithAutonomi/ant-client/releases). It exists so
8
+ that `ant` can be installed anywhere npm reaches — including agent sandboxes and CI runners that
9
+ allow package-manager traffic but block direct binary downloads.
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ npm install -g @withautonomi/ant
15
+ ant --help
16
+ ```
17
+
18
+ The beta channel tracks pre-release builds:
19
+
20
+ ```sh
21
+ npm install -g @withautonomi/ant@beta
22
+ ```
23
+
24
+ ## Supported platforms
25
+
26
+ | Platform | Architecture |
27
+ |---|---|
28
+ | Linux | x86_64, ARM64 |
29
+ | macOS | x86_64, Apple silicon |
30
+ | Windows | x86_64 (also used on ARM64, under emulation) |
31
+
32
+ Linux builds are statically linked against musl, so they run on any distribution.
33
+
34
+ The binary lives in a per-platform companion package (`@withautonomi/ant-linux-x64` and friends)
35
+ declared as an optional dependency, so `npm install` downloads only the one your machine needs.
36
+ Installing with `--no-optional` or `--omit=optional` skips it and leaves `ant` unable to run.
37
+
38
+ ## Configuration
39
+
40
+ `ant` joins the network through a list of bootstrap peers. It works out of the box: the same
41
+ peer list published in the release archives is compiled into the binary, and is used whenever no
42
+ config file is present.
43
+
44
+ To customise the list, put your own `bootstrap_peers.toml` here — it takes precedence over the
45
+ built-in one:
46
+
47
+ | Platform | Path |
48
+ |---|---|
49
+ | Linux | `$XDG_CONFIG_HOME/ant/bootstrap_peers.toml`, or `~/.config/ant/bootstrap_peers.toml` |
50
+ | macOS | `~/Library/Application Support/ant/bootstrap_peers.toml` |
51
+ | Windows | `%APPDATA%\ant\bootstrap_peers.toml` |
52
+
53
+ Installing normally writes that file for you, but npm 12 blocks package install scripts by
54
+ default, so it often will not appear. Nothing breaks when it doesn't. If you want the file so you
55
+ can edit it, either install with
56
+
57
+ ```sh
58
+ npm install -g --allow-scripts=@withautonomi/ant @withautonomi/ant
59
+ ```
60
+
61
+ or copy it out of the installed platform package. Individual runs can always override everything
62
+ with `ant -b <multiaddr> …`.
63
+
64
+ ## Updating
65
+
66
+ ```sh
67
+ npm update -g @withautonomi/ant
68
+ ```
69
+
70
+ `ant update`, which self-replaces the binary for installs made from the release page, detects an
71
+ npm-managed install and tells you to use npm instead — otherwise npm's view of the installed
72
+ version would silently diverge from what is on disk, and the next `npm update` would roll you
73
+ back.
74
+
75
+ ## Uninstall
76
+
77
+ ```sh
78
+ npm uninstall -g @withautonomi/ant
79
+ ```
80
+
81
+ Your config directory is left alone. Delete it by hand if you want it gone.
82
+
83
+ ## Verifying what you installed
84
+
85
+ Packages are published from the ant-client release workflow with
86
+ [npm provenance](https://docs.npmjs.com/generating-provenance-statements), so npm records which
87
+ workflow run and commit produced each tarball. The binaries are copied verbatim from the release
88
+ archives, whose checksums and ML-DSA-65 signatures are verified during packaging, so they are
89
+ byte-identical to the corresponding GitHub release assets.
90
+
91
+ ## Other install methods
92
+
93
+ The release page, `install.sh` and `install.ps1` all still work and are unaffected by this
94
+ package. See the [project README](https://github.com/WithAutonomi/ant-client#readme).
95
+
96
+ ## Licence
97
+
98
+ MIT OR Apache-2.0
package/bin/ant.js ADDED
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ // Launcher for the `ant` binary installed by the matching platform package.
5
+ //
6
+ // A postinstall script could copy the binary here and let npm exec it directly, saving this
7
+ // process. It is deliberately not done that way: `npm install --ignore-scripts` is common in
8
+ // agent sandboxes and locked-down CI, and this package must work there. A JS launcher always
9
+ // runs, at the cost of Node's startup — negligible for a network-bound CLI.
10
+
11
+ const { spawnSync } = require('node:child_process');
12
+ const {
13
+ binaryPath,
14
+ packageName,
15
+ platformKey,
16
+ supportedPlatforms,
17
+ ensureExecutable,
18
+ } = require('../lib/resolve.js');
19
+
20
+ function fail(message) {
21
+ process.stderr.write(`ant: ${message}\n`);
22
+ process.exit(1);
23
+ }
24
+
25
+ const key = platformKey();
26
+ const binary = binaryPath(key);
27
+
28
+ if (!binary) {
29
+ const pkg = packageName(key);
30
+ if (!pkg) {
31
+ fail(
32
+ `no prebuilt binary for ${key}.\n` +
33
+ ` Supported platforms: ${supportedPlatforms().join(', ')}\n` +
34
+ ` Build from source instead: https://github.com/WithAutonomi/ant-client`
35
+ );
36
+ }
37
+ fail(
38
+ `the platform package ${pkg} is not installed.\n` +
39
+ ` Reinstall with: npm install -g @withautonomi/ant\n` +
40
+ ` Note that --no-optional and --omit=optional prevent the binary from being fetched.`
41
+ );
42
+ }
43
+
44
+ ensureExecutable(binary);
45
+
46
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: 'inherit' });
47
+
48
+ if (result.error) {
49
+ fail(`failed to run ${binary}: ${result.error.message}`);
50
+ }
51
+
52
+ // Re-raise rather than translating to an exit code, so callers see the CLI's own termination
53
+ // reason (a Ctrl-C on a long upload must look like a Ctrl-C to the shell).
54
+ if (result.signal) {
55
+ process.kill(process.pid, result.signal);
56
+ // Reached only if the signal is ignored or blocked.
57
+ process.exit(1);
58
+ }
59
+
60
+ process.exit(result.status === null ? 1 : result.status);
package/lib/resolve.js ADDED
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ // Shared platform resolution for the @withautonomi/ant meta package.
4
+ //
5
+ // The meta package carries no binary. Each supported platform has its own package holding the
6
+ // `ant` binary from the matching GitHub release archive, declared as an optionalDependency with
7
+ // `os`/`cpu` guards, so `npm install` fetches exactly one of them. This module answers "which
8
+ // one, and where did npm put it?".
9
+
10
+ const fs = require('node:fs');
11
+ const path = require('node:path');
12
+
13
+ // `${process.platform}-${process.arch}` -> platform package name.
14
+ //
15
+ // Mirrors the release matrix in .github/workflows/ant-cli-release.yml. If a target is added
16
+ // there, add it here, to PLATFORM_TARGETS in build-packages.sh, and to the optionalDependencies
17
+ // in package.json.tmpl.
18
+ const PACKAGES = {
19
+ 'darwin-arm64': '@withautonomi/ant-darwin-arm64',
20
+ 'darwin-x64': '@withautonomi/ant-darwin-x64',
21
+ 'linux-arm64': '@withautonomi/ant-linux-arm64',
22
+ 'linux-x64': '@withautonomi/ant-linux-x64',
23
+ 'win32-x64': '@withautonomi/ant-win32-x64',
24
+ // There is no native Windows ARM64 build. install.ps1 hands ARM64 users the x86_64 binary to
25
+ // run under emulation (install.ps1:160-162); npm does the same, via an extra `arm64` entry in
26
+ // the win32 package's `cpu` list.
27
+ 'win32-arm64': '@withautonomi/ant-win32-x64',
28
+ };
29
+
30
+ function platformKey() {
31
+ return `${process.platform}-${process.arch}`;
32
+ }
33
+
34
+ function packageName(key = platformKey()) {
35
+ return PACKAGES[key] || null;
36
+ }
37
+
38
+ function supportedPlatforms() {
39
+ return Object.keys(PACKAGES).sort();
40
+ }
41
+
42
+ // Absolute path to the installed platform package, or null if npm did not install one.
43
+ //
44
+ // Resolution is anchored at this file rather than the cwd so it follows the dependency edge from
45
+ // the meta package, which is what npm actually laid out — global installs, local installs and
46
+ // nested node_modules all work out of the same lookup.
47
+ function packageDir(key = platformKey()) {
48
+ const name = packageName(key);
49
+ if (!name) return null;
50
+ try {
51
+ return path.dirname(require.resolve(`${name}/package.json`, { paths: [__dirname] }));
52
+ } catch {
53
+ return null;
54
+ }
55
+ }
56
+
57
+ function binaryName() {
58
+ return process.platform === 'win32' ? 'ant.exe' : 'ant';
59
+ }
60
+
61
+ // Absolute path to the `ant` executable, or null if it is not installed.
62
+ function binaryPath(key = platformKey()) {
63
+ const dir = packageDir(key);
64
+ if (!dir) return null;
65
+ const file = path.join(dir, 'bin', binaryName());
66
+ return fs.existsSync(file) ? file : null;
67
+ }
68
+
69
+ // npm normally preserves the executable bit through pack/publish/install, but registries,
70
+ // mirrors and unusual umasks have all been known to drop it, and `--ignore-scripts` rules out
71
+ // fixing it at install time. Restoring it here costs one stat on a path we are about to exec
72
+ // anyway, and turns an opaque EACCES into a working command.
73
+ function ensureExecutable(file) {
74
+ if (process.platform === 'win32') return;
75
+ try {
76
+ fs.accessSync(file, fs.constants.X_OK);
77
+ return;
78
+ } catch {
79
+ // Not executable — fall through and try to fix it.
80
+ }
81
+ try {
82
+ fs.chmodSync(file, 0o755);
83
+ } catch {
84
+ // Best effort. If this fails the spawn below reports the real error.
85
+ }
86
+ }
87
+
88
+ module.exports = {
89
+ PACKAGES,
90
+ binaryName,
91
+ binaryPath,
92
+ ensureExecutable,
93
+ packageDir,
94
+ packageName,
95
+ platformKey,
96
+ supportedPlatforms,
97
+ };
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@withautonomi/ant",
3
+ "version": "0.3.8",
4
+ "description": "Unified CLI (`ant`) for the Autonomi network: store and retrieve data, and manage local nodes.",
5
+ "keywords": [
6
+ "autonomi",
7
+ "ant",
8
+ "cli",
9
+ "p2p",
10
+ "storage",
11
+ "decentralized"
12
+ ],
13
+ "homepage": "https://github.com/WithAutonomi/ant-client#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/WithAutonomi/ant-client/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/WithAutonomi/ant-client.git"
20
+ },
21
+ "license": "MIT OR Apache-2.0",
22
+ "bin": {
23
+ "ant": "bin/ant.js"
24
+ },
25
+ "scripts": {
26
+ "postinstall": "node postinstall.js"
27
+ },
28
+ "files": [
29
+ "bin/",
30
+ "lib/",
31
+ "postinstall.js",
32
+ "README.md"
33
+ ],
34
+ "engines": {
35
+ "node": ">=18"
36
+ },
37
+ "optionalDependencies": {
38
+ "@withautonomi/ant-darwin-arm64": "0.3.8",
39
+ "@withautonomi/ant-darwin-x64": "0.3.8",
40
+ "@withautonomi/ant-linux-arm64": "0.3.8",
41
+ "@withautonomi/ant-linux-x64": "0.3.8",
42
+ "@withautonomi/ant-win32-x64": "0.3.8"
43
+ }
44
+ }
package/postinstall.js ADDED
@@ -0,0 +1,85 @@
1
+ 'use strict';
2
+
3
+ // Installs bootstrap_peers.toml into the platform config directory.
4
+ //
5
+ // Deliberately mirrors install.sh:216-224 and install.ps1:189-198: same destination, and the
6
+ // file is written only when absent so a user's edited peer list is never overwritten. The
7
+ // source is the copy inside the platform package, which came verbatim from the release archive,
8
+ // so an npm install and an install.sh install leave the same bytes in the same place.
9
+ //
10
+ // ant-core only ever reads this file, never writes it. It is not required, though: npm 12
11
+ // blocks install scripts by default (and `--ignore-scripts` does the same on older npm), so this
12
+ // frequently does not run, and config::resolve_bootstrap_multiaddrs falls back to the seeds
13
+ // compiled into the binary rather than failing with NoBootstrapPeers. What this script adds is a
14
+ // real file the user can find and edit. See npm/README.md.
15
+ //
16
+ // This script must never fail the install. npm treats a non-zero postinstall as a failed
17
+ // install, and a missing peers file is recoverable while a failed install is not.
18
+
19
+ const fs = require('node:fs');
20
+ const os = require('node:os');
21
+ const path = require('node:path');
22
+
23
+ const { packageDir } = require('./lib/resolve.js');
24
+
25
+ const CONFIG_FILE = 'bootstrap_peers.toml';
26
+
27
+ function say(message) {
28
+ process.stdout.write(`@withautonomi/ant: ${message}\n`);
29
+ }
30
+
31
+ function warn(message) {
32
+ process.stderr.write(`@withautonomi/ant: ${message}\n`);
33
+ }
34
+
35
+ // Mirrors config_dir() in install.sh:59-67, Get-ConfigDir in install.ps1:149-151, and
36
+ // ant_core::config::config_dir() in ant-core/src/config.rs:32-45. All four must agree.
37
+ function configDir() {
38
+ if (process.platform === 'win32') {
39
+ const appData = process.env.APPDATA;
40
+ if (!appData) throw new Error('APPDATA is not set');
41
+ return path.join(appData, 'ant');
42
+ }
43
+ if (process.platform === 'darwin') {
44
+ return path.join(os.homedir(), 'Library', 'Application Support', 'ant');
45
+ }
46
+ const xdg = process.env.XDG_CONFIG_HOME;
47
+ return path.join(xdg && xdg.length > 0 ? xdg : path.join(os.homedir(), '.config'), 'ant');
48
+ }
49
+
50
+ function main() {
51
+ const dir = packageDir();
52
+ if (!dir) {
53
+ // No platform package: either an unsupported platform or --no-optional. bin/ant.js explains
54
+ // it properly when the command is actually run; do not fail the install over it here.
55
+ return;
56
+ }
57
+
58
+ const source = path.join(dir, CONFIG_FILE);
59
+ if (!fs.existsSync(source)) {
60
+ warn(`${CONFIG_FILE} is missing from the platform package; skipping bootstrap config.`);
61
+ return;
62
+ }
63
+
64
+ const destDir = configDir();
65
+ const dest = path.join(destDir, CONFIG_FILE);
66
+
67
+ if (fs.existsSync(dest)) {
68
+ say(`bootstrap config already exists at ${dest} - skipping`);
69
+ return;
70
+ }
71
+
72
+ fs.mkdirSync(destDir, { recursive: true });
73
+ fs.copyFileSync(source, dest);
74
+ say(`installed bootstrap config to ${dest}`);
75
+ }
76
+
77
+ try {
78
+ main();
79
+ } catch (err) {
80
+ warn(
81
+ `could not install ${CONFIG_FILE}: ${err.message}\n` +
82
+ ` ant is installed and usable; supply peers with 'ant -b <multiaddr> ...' or create the\n` +
83
+ ` file yourself. See https://github.com/WithAutonomi/ant-client#configuration`
84
+ );
85
+ }