@agent-ix/quire-cli 0.38.3 → 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/README.md CHANGED
@@ -1,49 +1,16 @@
1
1
  # @agent-ix/quire-cli
2
2
 
3
- Prebuilt distribution of [`quire`](https://github.com/agent-ix/quire-cli), a
4
- static CLI over [`quire-rs`](https://github.com/agent-ix/quire-rs) for parsing,
5
- extracting, looking up, editing, validating, and inspecting Markdown artifacts.
6
-
7
- This npm package is a thin launcher. The actual binary ships in a per-platform
8
- optional dependency (`@agent-ix/quire-cli-<os>-<arch>`); npm installs only the
9
- one matching your machine. No source build and no `quire-rs` checkout is
10
- required.
3
+ Static CLI over quire-rs (parse, extract, lookup, edit, validate, schema, lint) for Markdown artifacts.
11
4
 
12
5
  ## Install
13
6
 
14
- This package is published to **GitHub Packages**, so point the `@agent-ix` scope
15
- at that registry. In `.npmrc`:
16
-
17
- ```
18
- @agent-ix:registry=https://npm.pkg.github.com
19
- //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
20
- ```
21
-
22
- Then:
23
-
24
- ```bash
7
+ ```sh
25
8
  npm install -g @agent-ix/quire-cli
26
- quire --help
27
9
  ```
28
10
 
29
- Or run without installing:
11
+ This installs a small launcher plus the prebuilt `quire` binary for your
12
+ platform as an optional dependency. Run it with:
30
13
 
31
- ```bash
32
- npx @agent-ix/quire-cli parse README.md
14
+ ```sh
15
+ quire --help
33
16
  ```
34
-
35
- ## Supported platforms
36
-
37
- | os / arch | Rust target |
38
- |-----------------|---------------------------------|
39
- | linux-x64 | `x86_64-unknown-linux-musl` |
40
- | linux-arm64 | `aarch64-unknown-linux-musl` |
41
- | darwin-arm64 | `aarch64-apple-darwin` |
42
- | win32-x64 | `x86_64-pc-windows-msvc` |
43
-
44
- Linux x64 covers both Intel and AMD servers; win32-x64 covers both Intel and AMD
45
- Windows machines. macOS support targets Apple Silicon. The Linux binaries are
46
- statically linked against musl.
47
-
48
- See the [main repository](https://github.com/agent-ix/quire-cli) for command
49
- documentation.
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ // Generic thin launcher, copied verbatim into every generated launcher
5
+ // package by pack.mjs. It carries no per-project knowledge: everything it
6
+ // needs (the binary name, the package name prefix, the optional self-update
7
+ // intercept command, and the closed set of supported platforms) comes from
8
+ // its own package.json at runtime.
9
+ //
10
+ // Behavior:
11
+ // - Resolve `<name>-<platform>-<arch>/bin/<binary>[.exe]` via
12
+ // require.resolve, restricted to declared optionalDependencies.
13
+ // - chmod 0755 best-effort on POSIX, then spawn with inherited stdio.
14
+ // - Forward SIGINT/SIGTERM/SIGHUP received by the launcher to the child.
15
+ // - Mirror the child's exit status, or re-raise its terminating signal.
16
+ // - If nativeLauncher.selfUpdateCommand is set and matches argv[2], print
17
+ // an update hint and exit 1 without spawning anything.
18
+
19
+ const { spawn } = require("node:child_process");
20
+ const fs = require("node:fs");
21
+ const os = require("node:os");
22
+ const packageJson = require("../package.json");
23
+
24
+ const PLATFORM = process.platform; // 'linux' | 'darwin' | 'win32' | ...
25
+ const ARCH = process.arch; // 'x64' | 'arm64' | ...
26
+ const NAME = packageJson.name;
27
+ const NATIVE_LAUNCHER = packageJson.nativeLauncher || {};
28
+ const BINARY = NATIVE_LAUNCHER.binary;
29
+ const SELF_UPDATE_COMMAND = NATIVE_LAUNCHER.selfUpdateCommand || "";
30
+ const PACKAGE_PREFIX = `${NAME}-`;
31
+ const OPTIONAL_DEPENDENCIES = packageJson.optionalDependencies || {};
32
+
33
+ if (!BINARY) {
34
+ process.stderr.write(`${NAME}: package.json is missing nativeLauncher.binary\n`);
35
+ process.exit(1);
36
+ }
37
+
38
+ if (SELF_UPDATE_COMMAND && process.argv[2] === SELF_UPDATE_COMMAND) {
39
+ process.stderr.write(
40
+ `${BINARY} was installed with npm; update it with: npm install -g ${NAME}@latest\n`
41
+ );
42
+ process.exit(1);
43
+ }
44
+
45
+ function resolveBinary() {
46
+ const key = `${PLATFORM}-${ARCH}`;
47
+ const pkg = `${PACKAGE_PREFIX}${key}`;
48
+ if (!Object.prototype.hasOwnProperty.call(OPTIONAL_DEPENDENCIES, pkg)) {
49
+ const supported = Object.keys(OPTIONAL_DEPENDENCIES)
50
+ .filter((name) => name.startsWith(PACKAGE_PREFIX))
51
+ .map((name) => name.slice(PACKAGE_PREFIX.length))
52
+ .sort();
53
+ throw new Error(
54
+ `${NAME}: unsupported platform "${key}".\n` +
55
+ `Prebuilt binaries exist for: ${supported.join(", ")}.\n` +
56
+ `Build ${BINARY} from source for this platform instead.`
57
+ );
58
+ }
59
+ const binName = PLATFORM === "win32" ? `${BINARY}.exe` : BINARY;
60
+ try {
61
+ return require.resolve(`${pkg}/bin/${binName}`);
62
+ } catch (_) {
63
+ throw new Error(
64
+ `${NAME}: the prebuilt binary package "${pkg}" is not installed.\n` +
65
+ `It is an optional dependency — reinstall without --no-optional, or\n` +
66
+ `add "${pkg}" explicitly. (--ignore-optional / CPU-VM mismatches skip\n` +
67
+ `it, and so does a prebuilt package that does not match this\n` +
68
+ `system's libc, e.g. a glibc build installed on a musl system.)`
69
+ );
70
+ }
71
+ }
72
+
73
+ let bin;
74
+ try {
75
+ bin = resolveBinary();
76
+ } catch (err) {
77
+ process.stderr.write(String(err.message) + "\n");
78
+ process.exit(1);
79
+ }
80
+
81
+ // npm does not always preserve the executable bit through publish/install;
82
+ // best-effort restore it on POSIX before exec.
83
+ if (PLATFORM !== "win32") {
84
+ try {
85
+ fs.chmodSync(bin, 0o755);
86
+ } catch (_) {
87
+ /* non-fatal: the file may already be executable or read-only */
88
+ }
89
+ }
90
+
91
+ const FORWARD_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
92
+
93
+ const child = spawn(bin, process.argv.slice(2), { stdio: "inherit" });
94
+
95
+ function forwardSignal(signal) {
96
+ try {
97
+ child.kill(signal);
98
+ } catch (_) {
99
+ /* the child may already have exited */
100
+ }
101
+ }
102
+
103
+ for (const signal of FORWARD_SIGNALS) {
104
+ process.on(signal, forwardSignal);
105
+ }
106
+
107
+ function stopForwardingSignals() {
108
+ for (const signal of FORWARD_SIGNALS) {
109
+ process.removeListener(signal, forwardSignal);
110
+ }
111
+ }
112
+
113
+ child.on("error", (err) => {
114
+ stopForwardingSignals();
115
+ process.stderr.write(`${NAME}: failed to launch binary: ${err.message}\n`);
116
+ process.exit(1);
117
+ });
118
+
119
+ child.on("exit", (code, signal) => {
120
+ stopForwardingSignals();
121
+
122
+ if (signal) {
123
+ // Re-raise the child's terminating signal so callers observe the same
124
+ // signal-driven exit. For a signal whose default disposition is to
125
+ // terminate (SIGTERM, SIGINT, SIGHUP, ...) this ends the process right
126
+ // here. For one Node ignores by default (e.g. SIGPIPE), execution
127
+ // continues past the kill call, so fall back to the shell-convention
128
+ // exit code (128 + signal number).
129
+ process.kill(process.pid, signal);
130
+ setImmediate(() => {
131
+ const signalNumber = os.constants.signals[signal];
132
+ process.exit(128 + (typeof signalNumber === "number" ? signalNumber : 0));
133
+ });
134
+ return;
135
+ }
136
+
137
+ process.exit(code === null ? 1 : code);
138
+ });
package/package.json CHANGED
@@ -1,41 +1,36 @@
1
1
  {
2
- "author": "Agent IX <kreneskyp@gmail.com>",
3
- "bin": {
4
- "quire": "bin/quire.js"
5
- },
2
+ "name": "@agent-ix/quire-cli",
3
+ "version": "0.39.0",
6
4
  "description": "Static CLI over quire-rs (parse, extract, lookup, edit, validate, schema, lint) for Markdown artifacts.",
7
- "engines": {
8
- "node": ">=16"
5
+ "homepage": "https://github.com/agent-ix/quire-cli#readme",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/agent-ix/quire-cli.git"
9
+ },
10
+ "license": "AGPL-3.0-or-later",
11
+ "type": "commonjs",
12
+ "bin": {
13
+ "quire": "bin/launcher.js"
9
14
  },
10
15
  "files": [
11
16
  "bin/",
12
17
  "LICENSE"
13
18
  ],
14
- "homepage": "https://github.com/agent-ix/quire-cli#readme",
15
- "keywords": [
16
- "quire",
17
- "cli",
18
- "markdown",
19
- "spec",
20
- "filament",
21
- "agent-ix"
22
- ],
23
- "license": "AGPL-3.0-or-later",
24
- "name": "@agent-ix/quire-cli",
19
+ "engines": {
20
+ "node": ">=16"
21
+ },
25
22
  "optionalDependencies": {
26
- "@agent-ix/quire-cli-darwin-arm64": "0.38.3",
27
- "@agent-ix/quire-cli-linux-arm64": "0.38.3",
28
- "@agent-ix/quire-cli-linux-x64": "0.38.3",
29
- "@agent-ix/quire-cli-win32-x64": "0.38.3"
23
+ "@agent-ix/quire-cli-darwin-arm64": "0.39.0",
24
+ "@agent-ix/quire-cli-linux-arm64": "0.39.0",
25
+ "@agent-ix/quire-cli-linux-x64": "0.39.0",
26
+ "@agent-ix/quire-cli-win32-x64": "0.39.0"
30
27
  },
31
28
  "publishConfig": {
32
- "access": "public",
33
- "registry": "https://registry.npmjs.org/"
34
- },
35
- "repository": {
36
- "type": "git",
37
- "url": "git+https://github.com/agent-ix/quire-cli.git"
29
+ "registry": "https://registry.npmjs.org/",
30
+ "access": "public"
38
31
  },
39
- "type": "commonjs",
40
- "version": "0.38.3"
32
+ "nativeLauncher": {
33
+ "binary": "quire",
34
+ "selfUpdateCommand": "update"
35
+ }
41
36
  }
package/bin/quire.js DELETED
@@ -1,72 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- // Thin launcher: resolve the prebuilt `quire` binary that matches this
5
- // platform/arch (shipped as an optional dependency) and exec it transparently,
6
- // forwarding argv, stdio, and the exit status / terminating signal.
7
-
8
- const { spawnSync } = require("node:child_process");
9
- const fs = require("node:fs");
10
- const packageJson = require("../package.json");
11
-
12
- const PLATFORM = process.platform; // 'linux' | 'darwin' | 'win32' | ...
13
- const ARCH = process.arch; // 'x64' | 'arm64' | ...
14
- const PACKAGE_PREFIX = "@agent-ix/quire-cli-";
15
- const OPTIONAL_DEPENDENCIES = packageJson.optionalDependencies || {};
16
-
17
- function resolveBinary() {
18
- const key = `${PLATFORM}-${ARCH}`;
19
- const pkg = `${PACKAGE_PREFIX}${key}`;
20
- if (!Object.prototype.hasOwnProperty.call(OPTIONAL_DEPENDENCIES, pkg)) {
21
- const supported = Object.keys(OPTIONAL_DEPENDENCIES)
22
- .filter((name) => name.startsWith(PACKAGE_PREFIX))
23
- .map((name) => name.slice(PACKAGE_PREFIX.length))
24
- .sort();
25
- throw new Error(
26
- `quire-cli: unsupported platform "${key}".\n` +
27
- `Prebuilt binaries exist for: ${supported.join(", ")}.\n` +
28
- `Build from source instead: https://github.com/agent-ix/quire-cli`
29
- );
30
- }
31
- const binName = PLATFORM === "win32" ? "quire.exe" : "quire";
32
- try {
33
- return require.resolve(`${pkg}/bin/${binName}`);
34
- } catch (_) {
35
- throw new Error(
36
- `quire-cli: the prebuilt binary package "${pkg}" is not installed.\n` +
37
- `It is an optional dependency — reinstall without --no-optional, or\n` +
38
- `add "${pkg}" explicitly. (--ignore-optional / CPU-VM mismatches skip it.)`
39
- );
40
- }
41
- }
42
-
43
- let bin;
44
- try {
45
- bin = resolveBinary();
46
- } catch (err) {
47
- process.stderr.write(String(err.message) + "\n");
48
- process.exit(1);
49
- }
50
-
51
- // npm does not always preserve the executable bit through publish/install;
52
- // best-effort restore it on POSIX before exec.
53
- if (PLATFORM !== "win32") {
54
- try {
55
- fs.chmodSync(bin, 0o755);
56
- } catch (_) {
57
- /* non-fatal: the file may already be executable or read-only */
58
- }
59
- }
60
-
61
- const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
62
-
63
- if (result.error) {
64
- process.stderr.write(`quire-cli: failed to launch binary: ${result.error.message}\n`);
65
- process.exit(1);
66
- }
67
- if (result.signal) {
68
- // Re-raise the child's terminating signal so callers observe the same
69
- // signal-driven exit (e.g. SIGABRT -> 134 on a panic, per FR-007).
70
- process.kill(process.pid, result.signal);
71
- }
72
- process.exit(result.status === null ? 1 : result.status);