@nanobpm/nano-coder 0.47.1 → 0.47.2

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/bin/nano-coder CHANGED
@@ -1,10 +1,13 @@
1
1
  #!/usr/bin/env node
2
- // Launcher used only when the postinstall step could not replace this file with
3
- // the native binary (e.g. `npm install --ignore-scripts`). It adds a Node process
4
- // in front of nano-coder; the native install avoids that overhead.
2
+ // JS launcher for nano-coder. On its first run it best-effort replaces itself
3
+ // with the native binary (so later invocations run without a Node process in
4
+ // front), then runs the binary for the current invocation. If the swap fails
5
+ // (e.g. a read-only global prefix) the launcher stays and keeps working — every
6
+ // run just pays the small Node startup cost.
5
7
  'use strict';
8
+ const fs = require('node:fs');
6
9
  const { spawnSync } = require('node:child_process');
7
- const { binaryPath } = require('../lib/platform.js');
10
+ const { binaryPath, launcher } = require('../lib/platform.js');
8
11
 
9
12
  let bin;
10
13
  try {
@@ -13,6 +16,20 @@ try {
13
16
  console.error(`nano-coder: ${err.message}`);
14
17
  process.exit(1);
15
18
  }
19
+
20
+ // Best-effort self-replacement with the native binary. Errors (unwritable
21
+ // install dir, antivirus lock, ...) are swallowed: the current invocation below
22
+ // still runs the binary through this launcher, and the swap is retried on the
23
+ // next run.
24
+ try {
25
+ const tmp = `${launcher}.tmp-${process.pid}`;
26
+ fs.copyFileSync(bin, tmp);
27
+ fs.chmodSync(tmp, 0o755);
28
+ fs.renameSync(tmp, launcher);
29
+ } catch {
30
+ // keep the launcher
31
+ }
32
+
16
33
  const r = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' });
17
34
  if (r.error) {
18
35
  console.error(`nano-coder: failed to run ${bin}: ${r.error.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nanobpm/nano-coder",
3
- "version": "0.47.1",
3
+ "version": "0.47.2",
4
4
  "description": "A 6MB coding agent. Run a fleet on your laptop.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -21,19 +21,15 @@
21
21
  "files": [
22
22
  "bin/",
23
23
  "lib/",
24
- "install.js",
25
24
  "README.md"
26
25
  ],
27
- "scripts": {
28
- "postinstall": "node install.js"
29
- },
30
26
  "engines": {
31
27
  "node": ">=18"
32
28
  },
33
29
  "optionalDependencies": {
34
- "@nanobpm/nano-coder-darwin-arm64": "0.47.1",
35
- "@nanobpm/nano-coder-darwin-x64": "0.47.1",
36
- "@nanobpm/nano-coder-linux-arm64": "0.47.1",
37
- "@nanobpm/nano-coder-linux-x64": "0.47.1"
30
+ "@nanobpm/nano-coder-darwin-arm64": "0.47.2",
31
+ "@nanobpm/nano-coder-darwin-x64": "0.47.2",
32
+ "@nanobpm/nano-coder-linux-arm64": "0.47.2",
33
+ "@nanobpm/nano-coder-linux-x64": "0.47.2"
38
34
  }
39
35
  }
package/install.js DELETED
@@ -1,16 +0,0 @@
1
- 'use strict';
2
- // Replace the JS launcher with the native binary so `nano-coder` runs without a
3
- // Node process in front of it. Best-effort: on any failure the launcher stays
4
- // and still works.
5
- const fs = require('node:fs');
6
- const { binaryPath, launcher } = require('./lib/platform.js');
7
-
8
- try {
9
- const bin = binaryPath();
10
- const tmp = `${launcher}.tmp-${process.pid}`;
11
- fs.copyFileSync(bin, tmp);
12
- fs.chmodSync(tmp, 0o755);
13
- fs.renameSync(tmp, launcher);
14
- } catch (err) {
15
- console.warn(`nano-coder: keeping the Node launcher (${err.message})`);
16
- }