hintshell 0.2.0 → 0.2.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/README.md CHANGED
@@ -93,11 +93,33 @@ source ~/.bashrc
93
93
 
94
94
  ---
95
95
 
96
- ## ✨ What's new in 0.2.0
96
+ ## ✨ What's new in 0.2.1
97
+
98
+ - Daemon single-instance + IDE terminal reliability (no stacked `hintshell-core`, IPC health checks).
99
+ - Safe update while running: `npm i -g hintshell@latest` / `hs update` stop the daemon before replacing Windows binaries.
100
+ - Clearer start/status/update logs. See [CHANGELOG.md](./CHANGELOG.md).
101
+
102
+ ## 🔄 Updating
103
+
104
+ While the daemon is running, Windows locks `hintshell-core.exe`. Use:
105
+
106
+ ```bash
107
+ # Recommended
108
+ hs update
109
+
110
+ # Or raw npm — postinstall stops the daemon and runs init
111
+ npm i -g hintshell@latest
112
+ ```
113
+
114
+ If you still hit a file lock (`os error 32` / "being used by another process"):
115
+
116
+ ```bash
117
+ hs stop
118
+ # or: taskkill /F /IM hintshell-core.exe
119
+ npm i -g hintshell@latest
120
+ hintshell init
121
+ ```
97
122
 
98
- - PowerShell: multi-line paste no longer covers the buffer with the suggestion panel; narrow terminals use a compact layout.
99
- - Git Bash / Bash / Zsh: reliable fzf picker (WinGet Links shim fix) and init that prefers `~/.hintshell` over npm shims.
100
- - See [CHANGELOG.md](./CHANGELOG.md) for the full list.
101
123
  ## 🗑️ Uninstallation
102
124
 
103
125
  If you need to remove HintShell, it now comes with a clean uninstaller that handles everything for you:
@@ -119,7 +141,7 @@ npm uninstall -g hintshell
119
141
  hs status # Check if the daemon is running and see stats
120
142
  hs start # Manually start the daemon
121
143
  hs stop # Stop the daemon
122
- hs update # Check for new versions
144
+ hs update # Stop daemon, npm install -g, init, restart
123
145
  hs uninstall # Completely remove shell integration and binaries
124
146
  ```
125
147
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hintshell",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Next-gen AI-ready real-time command suggestions for your terminal. Smart, context-aware autocomplete for PowerShell, Bash, and Zsh.",
5
5
  "keywords": [
6
6
  "ai-shell",
@@ -3,17 +3,21 @@
3
3
  /**
4
4
  * npm postinstall script for HintShell
5
5
  * Downloads the correct platform-specific binary from GitHub Releases.
6
+ *
7
+ * Windows note: running hintshell-core locks the .exe. We stop the daemon
8
+ * before extracting / before hintshell init copies into ~/.hintshell.
6
9
  */
7
10
 
8
11
  const https = require("https");
9
12
  const fs = require("fs");
10
13
  const path = require("path");
11
- const { execSync } = require("child_process");
14
+ const { execSync, spawnSync } = require("child_process");
12
15
  const os = require("os");
13
16
 
14
17
  const REPO = "philau2512/hintshell";
15
18
  const VERSION = require("../package.json").version;
16
19
  const TAG = `v${VERSION}`;
20
+ const IS_WIN = os.platform() === "win32";
17
21
 
18
22
  const PLATFORM_MAP = {
19
23
  "win32-x64": "x86_64-pc-windows-msvc",
@@ -53,7 +57,10 @@ function downloadFile(url, dest) {
53
57
  }
54
58
  const file = fs.createWriteStream(dest);
55
59
  res.pipe(file);
56
- file.on("finish", () => { file.close(); resolve(); });
60
+ file.on("finish", () => {
61
+ file.close();
62
+ resolve();
63
+ });
57
64
  file.on("error", reject);
58
65
  }).on("error", reject);
59
66
  };
@@ -62,16 +69,96 @@ function downloadFile(url, dest) {
62
69
  }
63
70
 
64
71
  function extractArchive(archivePath, destDir) {
65
- const platform = os.platform();
66
- if (platform === "win32") {
72
+ if (os.platform() === "win32") {
67
73
  // Windows 10+ has tar (bsdtar) built-in which fully supports zip files.
68
- // It avoids execution policy and auto-load module issues from PowerShell's Expand-Archive.
69
74
  execSync(`tar -xf "${archivePath}" -C "${destDir}"`, { stdio: "inherit" });
70
75
  } else {
71
76
  execSync(`tar xzf "${archivePath}" -C "${destDir}"`, { stdio: "inherit" });
72
77
  }
73
78
  }
74
79
 
80
+ function binName(base) {
81
+ return IS_WIN ? `${base}.exe` : base;
82
+ }
83
+
84
+ /**
85
+ * Stop running daemon so Windows can overwrite vendor/ and ~/.hintshell binaries.
86
+ * Best-effort: never throw.
87
+ */
88
+ function stopRunningDaemon(reason) {
89
+ console.log(`🛑 Stopping HintShell daemon (${reason})...`);
90
+ const home = os.homedir();
91
+ const candidates = [
92
+ path.join(home, ".hintshell", "bin", binName("hintshell")),
93
+ path.join(home, ".hintshell", "module", binName("hintshell")),
94
+ path.join(__dirname, "..", "vendor", binName("hintshell")),
95
+ ];
96
+
97
+ for (const cli of candidates) {
98
+ if (!fs.existsSync(cli)) continue;
99
+ try {
100
+ spawnSync(cli, ["stop"], {
101
+ encoding: "utf8",
102
+ timeout: 8000,
103
+ windowsHide: true,
104
+ });
105
+ break;
106
+ } catch (_) {
107
+ /* try next */
108
+ }
109
+ }
110
+
111
+ // Always force-kill leftovers (Windows file lock on hintshell-core.exe)
112
+ try {
113
+ if (IS_WIN) {
114
+ spawnSync("taskkill", ["/F", "/IM", "hintshell-core.exe"], {
115
+ stdio: "ignore",
116
+ windowsHide: true,
117
+ timeout: 5000,
118
+ });
119
+ spawnSync(
120
+ "powershell",
121
+ [
122
+ "-NoProfile",
123
+ "-Command",
124
+ "Get-Process -Name 'hintshell-core' -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue",
125
+ ],
126
+ { stdio: "ignore", windowsHide: true, timeout: 5000 }
127
+ );
128
+ } else {
129
+ spawnSync("pkill", ["-f", "hintshell-core"], {
130
+ stdio: "ignore",
131
+ timeout: 5000,
132
+ });
133
+ }
134
+ } catch (_) {
135
+ /* ignore */
136
+ }
137
+
138
+ // Brief wait so OS releases file handles
139
+ const until = Date.now() + 400;
140
+ while (Date.now() < until) {
141
+ /* spin — avoid Atomics/SharedArrayBuffer quirks */
142
+ }
143
+
144
+ console.log(" Daemon stop attempted (IPC + force kill).");
145
+ }
146
+
147
+ function runInit(vendorDir) {
148
+ const cli = path.join(vendorDir, binName("hintshell"));
149
+ if (!fs.existsSync(cli)) {
150
+ console.log("⚠️ vendor CLI missing; skip auto-init. Run: hintshell init");
151
+ return;
152
+ }
153
+ console.log("📦 Running hintshell init (copy into ~/.hintshell + hooks)...");
154
+ try {
155
+ execSync(`"${cli}" init`, { stdio: "inherit", windowsHide: true });
156
+ } catch (err) {
157
+ console.error("⚠️ hintshell init failed. Run manually: hintshell init");
158
+ if (err && err.message) console.error(` ${err.message}`);
159
+ }
160
+ }
161
+
75
162
  async function main() {
76
163
  const platformKey = getPlatformKey();
77
164
  const target = PLATFORM_MAP[platformKey];
@@ -87,9 +174,12 @@ async function main() {
87
174
  const installDir = path.join(__dirname, "..", "vendor");
88
175
  const archivePath = path.join(os.tmpdir(), `hintshell-${target}${ext}`);
89
176
 
90
- console.log(`📦 Installing HintShell for ${platformKey}...`);
177
+ console.log(`📦 Installing HintShell ${VERSION} for ${platformKey}...`);
91
178
  console.log(` Downloading from: ${url}`);
92
179
 
180
+ // CRITICAL: release Windows locks before replacing vendor/*.exe
181
+ stopRunningDaemon("before npm extract");
182
+
93
183
  fs.mkdirSync(installDir, { recursive: true });
94
184
 
95
185
  try {
@@ -108,16 +198,34 @@ async function main() {
108
198
  }
109
199
  }
110
200
 
111
- // Cleanup
112
- fs.unlinkSync(archivePath);
201
+ try {
202
+ fs.unlinkSync(archivePath);
203
+ } catch (_) {
204
+ /* ignore */
205
+ }
206
+
207
+ console.log(`✅ HintShell package binaries ready in vendor/`);
208
+
209
+ // Copy into ~/.hintshell so profile/hooks use the new build (not stale bin/)
210
+ // Skip when HINTSHELL_SKIP_INIT=1 (CI / packaging)
211
+ if (process.env.HINTSHELL_SKIP_INIT !== "1") {
212
+ stopRunningDaemon("before hintshell init");
213
+ runInit(installDir);
214
+ } else {
215
+ console.log(` HINTSHELL_SKIP_INIT=1 — skipped auto init.`);
216
+ console.log(` Run 'hintshell init' to configure your shell.`);
217
+ }
113
218
 
114
- console.log(`✅ HintShell installed successfully!`);
115
- console.log(` Run 'hintshell init' to configure your shell.`);
219
+ console.log(`✅ HintShell install/update finished.`);
116
220
  } catch (err) {
117
221
  console.error(`❌ Installation failed: ${err.message}`);
118
- console.error(` You can manually download from: https://github.com/${REPO}/releases`);
222
+ console.error(
223
+ ` Tip: stop daemon first: hs stop (or taskkill /F /IM hintshell-core.exe)`
224
+ );
225
+ console.error(` Then: npm i -g hintshell@latest && hintshell init`);
226
+ console.error(` Manual download: https://github.com/${REPO}/releases`);
119
227
  process.exit(1);
120
228
  }
121
229
  }
122
230
 
123
- main();
231
+ main();