@spuentesp/zoanthrope 0.1.5 → 0.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spuentesp/zoanthrope",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "mcpName": "io.github.spuentesp/zoanthrope",
5
5
  "description": "Swarm coordination: file claims, agent presence, postboard intentions, filesystem leases, audit. MCP server + hook CLI.",
6
6
  "keywords": [
@@ -7,7 +7,7 @@ const test = require('node:test');
7
7
  const assert = require('node:assert');
8
8
  const path = require('path');
9
9
 
10
- const { assetName, binaryPath, targetFor } = require('./runtime');
10
+ const { assetName, binaryPath, targetFor, tarExecutable } = require('./runtime');
11
11
 
12
12
  test('targetFor maps win32-x64 to the MSVC target', () => {
13
13
  assert.strictEqual(targetFor('win32', 'x64'), 'x86_64-pc-windows-msvc');
@@ -55,3 +55,11 @@ test('targetFor rejects platforms with no prebuilt binary', () => {
55
55
  assert.throws(() => targetFor('win32', 'ia32'), /No prebuilt zoanthrope binary/);
56
56
  assert.throws(() => targetFor('freebsd', 'x64'), /No prebuilt zoanthrope binary/);
57
57
  });
58
+
59
+ test('Windows extraction uses System32 bsdtar, not the first tar on PATH', () => {
60
+ const env = { SystemRoot: 'C:\\Windows' };
61
+ assert.strictEqual(tarExecutable('win32', env, () => true), 'C:\\Windows\\System32\\tar.exe');
62
+ assert.strictEqual(tarExecutable('win32', env, () => false), 'tar');
63
+ assert.strictEqual(tarExecutable('win32', {}, () => true), 'tar');
64
+ assert.strictEqual(tarExecutable('linux', env, () => true), 'tar');
65
+ });
@@ -98,6 +98,21 @@ function verifyBinary(file, version) {
98
98
  }
99
99
  }
100
100
 
101
+
102
+ // On Windows the first `tar` on PATH (Git Bash's GNU tar on the shells
103
+ // GitHub runners use) fails on these archives with `gzip: stdin:
104
+ // unexpected end of file`. Windows ships bsdtar at System32\tar.exe;
105
+ // use it when present — same fix as the lain shim.
106
+ function tarExecutable(platform = process.platform, env = process.env, exists = fs.existsSync) {
107
+ if (platform !== 'win32') return 'tar';
108
+ const root = env.SystemRoot || env.SYSTEMROOT || env.windir || env.WINDIR;
109
+ if (root) {
110
+ const system = path.win32.join(root, 'System32', 'tar.exe');
111
+ if (exists(system)) return system;
112
+ }
113
+ return 'tar';
114
+ }
115
+
101
116
  function download(url, destination, redirects = 5) {
102
117
  return new Promise((resolve, reject) => {
103
118
  const request = https.get(url, { headers: { 'User-Agent': '@spuentesp/zoanthrope' } }, (response) => {
@@ -158,7 +173,7 @@ async function ensureBinary(options = {}) {
158
173
  await fetch(releaseUrl(version, 'SHA256SUMS'), sums);
159
174
  await fetch(releaseUrl(version, asset), archive);
160
175
  verifyArchive(archive, parseChecksum(fs.readFileSync(sums, 'utf8'), asset));
161
- execFileSync('tar', ['xzf', archive, '-C', temporary], { stdio: ['ignore', 'ignore', 'inherit'] });
176
+ execFileSync(tarExecutable(platform), ['xzf', archive, '-C', temporary], { stdio: ['ignore', 'ignore', 'inherit'] });
162
177
  // On win32 the archive root carries `zoanthrope.exe` (spawning an
163
178
  // extension-less file makes CreateProcess append .exe and miss the
164
179
  // real file); everywhere else the bare name.
@@ -199,6 +214,7 @@ module.exports = {
199
214
  releaseUrl,
200
215
  selectedVersion,
201
216
  sha256,
217
+ tarExecutable,
202
218
  targetFor,
203
219
  verifyArchive,
204
220
  verifyBinary,