@spenceriam/impulse 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/package.json +7 -7
  2. package/postinstall.mjs +28 -29
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spenceriam/impulse",
3
- "version": "1.0.0",
4
- "description": "Terminal-based AI coding agent powered by Z.ai's Coding Plan",
3
+ "version": "1.0.2",
4
+ "description": "Provider-flexible terminal AI coding agent",
5
5
  "license": "MIT",
6
6
  "bin": {
7
7
  "impulse": "./bin/impulse"
@@ -21,10 +21,10 @@
21
21
  "access": "public"
22
22
  },
23
23
  "optionalDependencies": {
24
- "@spenceriam/impulse-linux-x64": "1.0.0",
25
- "@spenceriam/impulse-linux-arm64": "1.0.0",
26
- "@spenceriam/impulse-darwin-x64": "1.0.0",
27
- "@spenceriam/impulse-darwin-arm64": "1.0.0",
28
- "@spenceriam/impulse-windows-x64": "1.0.0"
24
+ "@spenceriam/impulse-linux-x64": "1.0.2",
25
+ "@spenceriam/impulse-linux-arm64": "1.0.2",
26
+ "@spenceriam/impulse-darwin-x64": "1.0.2",
27
+ "@spenceriam/impulse-darwin-arm64": "1.0.2",
28
+ "@spenceriam/impulse-windows-x64": "1.0.2"
29
29
  }
30
30
  }
package/postinstall.mjs CHANGED
@@ -88,23 +88,27 @@ function prepareBinDirectory(binaryName) {
88
88
  fs.mkdirSync(binDir, { recursive: true });
89
89
  }
90
90
 
91
- if (fs.existsSync(targetPath)) {
92
- fs.unlinkSync(targetPath);
93
- }
94
-
95
91
  return { binDir, targetPath };
96
92
  }
97
93
 
98
94
  function symlinkBinary(sourcePath, targetPath) {
99
- // Ensure source binary is executable (npm tarball doesn't preserve execute bit)
100
95
  try {
101
96
  fs.chmodSync(sourcePath, 0o755);
102
97
  } catch (e) {
103
98
  // Ignore chmod errors (may not have permission)
104
99
  }
105
-
106
- fs.symlinkSync(sourcePath, targetPath);
107
- console.log(`IMPULSE binary symlinked: ${targetPath} -> ${sourcePath}`);
100
+
101
+ const tempPath = targetPath + ".tmp-" + process.pid;
102
+
103
+ fs.symlinkSync(sourcePath, tempPath);
104
+
105
+ try {
106
+ fs.renameSync(tempPath, targetPath);
107
+ } catch (renameError) {
108
+ // Clean up temp symlink on failure
109
+ try { fs.unlinkSync(tempPath); } catch (e) {}
110
+ throw renameError;
111
+ }
108
112
 
109
113
  if (!fs.existsSync(targetPath)) {
110
114
  throw new Error(`Failed to symlink binary to ${targetPath}`);
@@ -112,29 +116,24 @@ function symlinkBinary(sourcePath, targetPath) {
112
116
  }
113
117
 
114
118
  async function main() {
115
- try {
116
- if (os.platform() === "win32") {
117
- console.log("Windows detected: using packaged executable");
118
- return;
119
- }
120
-
121
- const { binaryPath, binaryName } = findBinary();
122
- const { targetPath } = prepareBinDirectory(binaryName);
123
-
124
- // Create symlink to the platform-specific binary
125
- symlinkBinary(binaryPath, targetPath);
126
-
127
- console.log(`IMPULSE installed successfully!`);
128
- } catch (error) {
129
- console.error("Failed to setup IMPULSE binary:", error.message);
130
- console.error("You may need to install Bun and run IMPULSE directly:");
131
- console.error(" curl -fsSL https://bun.sh/install | bash");
132
- console.error(" bun x @spenceriam/impulse");
133
- process.exit(1);
119
+ if (os.platform() === "win32") {
120
+ console.log("Windows detected: using packaged executable");
121
+ return;
134
122
  }
123
+
124
+ const { binaryPath, binaryName } = findBinary();
125
+ const { targetPath } = prepareBinDirectory(binaryName);
126
+
127
+ symlinkBinary(binaryPath, targetPath);
128
+
129
+ console.log(`IMPULSE binary symlinked: ${targetPath} -> ${binaryPath}`);
130
+ console.log(`IMPULSE installed successfully!`);
135
131
  }
136
132
 
137
133
  main().catch((error) => {
138
- console.error("Postinstall script error:", error.message);
139
- process.exit(0);
134
+ console.error("Failed to setup IMPULSE binary:", error.message);
135
+ console.error("You may need to install Bun and run IMPULSE directly:");
136
+ console.error(" curl -fsSL https://bun.sh/install | bash");
137
+ console.error(" bun x @spenceriam/impulse");
138
+ process.exit(1);
140
139
  });