@spenceriam/impulse 0.36.0 → 1.0.1

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/impulse CHANGED
@@ -47,40 +47,30 @@ function findBinary() {
47
47
  const { platform, arch } = detectPlatformAndArch();
48
48
  const packageName = `@spenceriam/impulse-${platform}-${arch}`;
49
49
  const binaryName = platform === "windows" ? "impulse.exe" : "impulse";
50
- const packageCandidates = [packageName];
51
50
 
52
- // On Windows ARM64, allow fallback to the x64 package for Prism emulation.
53
- if (platform === "windows" && arch === "arm64") {
54
- packageCandidates.push("@spenceriam/impulse-windows-x64");
55
- }
56
-
57
- for (const candidate of packageCandidates) {
58
- try {
59
- const packageJsonPath = require.resolve(`${candidate}/package.json`);
60
- const packageDir = dirname(packageJsonPath);
61
- const binaryPath = join(packageDir, "bin", binaryName);
62
-
63
- if (!existsSync(binaryPath)) {
64
- continue;
65
- }
51
+ try {
52
+ const packageJsonPath = require.resolve(`${packageName}/package.json`);
53
+ const packageDir = dirname(packageJsonPath);
54
+ const binaryPath = join(packageDir, "bin", binaryName);
66
55
 
67
- return binaryPath;
68
- } catch (_error) {
69
- // Try next candidate package.
56
+ if (!existsSync(binaryPath)) {
57
+ throw new Error(`Binary not found at ${binaryPath}`);
70
58
  }
71
- }
72
59
 
73
- // Check if symlinked binary exists in same directory
74
- const localBinary = join(__dirname, binaryName);
75
- if (existsSync(localBinary)) {
76
- return localBinary;
60
+ return binaryPath;
61
+ } catch (error) {
62
+ // Check if symlinked binary exists in same directory
63
+ const localBinary = join(__dirname, binaryName);
64
+ if (existsSync(localBinary)) {
65
+ return localBinary;
66
+ }
67
+
68
+ throw new Error(
69
+ `Could not find IMPULSE binary for ${platform}-${arch}.\n` +
70
+ `Package ${packageName} may not be installed.\n` +
71
+ `Try reinstalling: npm install -g @spenceriam/impulse`
72
+ );
77
73
  }
78
-
79
- throw new Error(
80
- `Could not find IMPULSE binary for ${platform}-${arch}.\n` +
81
- `Checked packages: ${packageCandidates.join(", ")}.\n` +
82
- `Try reinstalling: npm install -g @spenceriam/impulse`
83
- );
84
74
  }
85
75
 
86
76
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spenceriam/impulse",
3
- "version": "0.36.0",
4
- "description": "Terminal-based AI coding agent powered by Z.ai's Coding Plan",
3
+ "version": "1.0.1",
4
+ "description": "Provider-flexible terminal AI coding agent",
5
5
  "license": "MIT",
6
6
  "bin": {
7
7
  "impulse": "./bin/impulse"
@@ -21,11 +21,10 @@
21
21
  "access": "public"
22
22
  },
23
23
  "optionalDependencies": {
24
- "@spenceriam/impulse-linux-x64": "0.36.0",
25
- "@spenceriam/impulse-linux-arm64": "0.36.0",
26
- "@spenceriam/impulse-darwin-x64": "0.36.0",
27
- "@spenceriam/impulse-darwin-arm64": "0.36.0",
28
- "@spenceriam/impulse-windows-x64": "0.36.0",
29
- "@spenceriam/impulse-windows-arm64": "0.36.0"
24
+ "@spenceriam/impulse-linux-x64": "1.0.1",
25
+ "@spenceriam/impulse-linux-arm64": "1.0.1",
26
+ "@spenceriam/impulse-darwin-x64": "1.0.1",
27
+ "@spenceriam/impulse-darwin-arm64": "1.0.1",
28
+ "@spenceriam/impulse-windows-x64": "1.0.1"
30
29
  }
31
30
  }
package/postinstall.mjs CHANGED
@@ -54,14 +54,14 @@ function findBinary() {
54
54
  "darwin-x64",
55
55
  "darwin-arm64",
56
56
  "windows-x64",
57
- "windows-arm64",
58
57
  ];
59
58
 
60
59
  const combo = `${platform}-${arch}`;
61
60
  if (!supportedCombos.includes(combo)) {
62
61
  throw new Error(
63
62
  `Unsupported platform: ${platform}-${arch}\n` +
64
- `IMPULSE currently supports: ${supportedCombos.join(", ")}`
63
+ `IMPULSE currently supports: ${supportedCombos.join(", ")}\n` +
64
+ `Windows ARM64 support is pending Bun's cross-compile target.`
65
65
  );
66
66
  }
67
67
 
@@ -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
  });