hintshell 0.2.0 → 0.3.0

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
@@ -3,7 +3,7 @@
3
3
  </p>
4
4
 
5
5
  <h1 align="center">HintShell</h1>
6
- <p align="center"><strong>Next-Gen AI-Ready Real-time Command Suggestions for Your Terminal</strong></p>
6
+ <p align="center"><strong>Local, Context-Aware Real-time Command Suggestions for Your Terminal</strong></p>
7
7
 
8
8
  <p align="center">
9
9
  <a href="https://www.npmjs.com/package/hintshell"><img src="https://img.shields.io/npm/v/hintshell?color=CB3837&label=npm" alt="NPM Version" /></a>
@@ -14,14 +14,20 @@
14
14
  </p>
15
15
 
16
16
  <p align="center">
17
- HintShell is an <strong>AI-ready productivity engine</strong> that <strong>embeds into your existing shell</strong> (PowerShell, Bash, or Zsh). It provides <strong>context-aware command suggestions</strong> in real-time, drastically reducing context-switching and boosting developer workflow efficiency. Built with <strong>Rust</strong> for maximum performance and minimum footprint.
17
+ HintShell is a <strong>local command-suggestion engine</strong> that <strong>embeds into your existing shell</strong> (PowerShell, Bash, or Zsh). It combines your command history with bounded context from the current directory and workspace, then presents suggestions without replacing native shell completion. Built with <strong>Rust</strong> for a small, responsive footprint.
18
18
  </p>
19
19
 
20
+ <p align="center">
21
+ <img src="assets/image1.png" alt="HintShell live suggestions in Git Bash" width="860" />
22
+ </p>
23
+ <p align="center">
24
+ <img src="assets/image2.png" alt="HintShell contextual suggestions in Git Bash" width="860" />
25
+ </p>
20
26
  ---
21
27
 
22
28
  ## ⚡ Why HintShell?
23
29
 
24
- Most shells offer basic, single-line autocomplete. HintShell replaces that with a <strong>smart, interactive suggestion panel</strong> — a context-aware UI/UX upgrade right inside your terminal. It's the <strong>modern alternative to PSReadLine and zsh-autosuggestions</strong>.
30
+ Most shells offer basic, single-line autocomplete. HintShell adds a <strong>smart, interactive suggestion panel</strong> while keeping each shell authoritative for its own completion behavior: Bash and PSReadLine still own path and flag completion, and HintShell only supplies advisory command suggestions.
25
31
 
26
32
  | Feature | HintShell | PowerShell <br>(PSReadLine) | Zsh <br>(zsh-autosuggestions) | Bash | Git Bash | Fish |
27
33
  |---|:---:|:---:|:---:|:---:|:---:|:---:|
@@ -78,26 +84,71 @@ source ~/.bashrc
78
84
 
79
85
  ## 📖 Usage
80
86
 
87
+ ### Git Bash (Windows)
88
+
89
+ After `hs init`, opening a normal interactive Git Bash session automatically starts `hintshell bash`, which renders a local live overlay as you type. `fzf` is not required for this live mode.
90
+
91
+ - **↑ / ↓** navigate HintShell suggestions; **Esc** closes the overlay; **Enter** executes through Git Bash.
92
+ - **Tab** accepts only a compatible command suggestion. Path input such as `cd src/comp`, flags such as `git --ver`, and empty overlays are forwarded to Bash's native completion.
93
+ - The overlay adapts near the bottom of the terminal: it shows fewer rows when space is limited and stays hidden when a complete frame would scroll the terminal.
94
+ - To bypass the wrapper for one shell, run:
95
+
96
+ ```bash
97
+ HINTSHELL_DISABLE_AUTO_BASH=1 bash
98
+ ```
99
+
100
+ - Set `HINTSHELL_BASH` to an explicit `bash.exe` path. Set `HINTSHELL_DISABLE_LIVE_OVERLAY=1` to reject the wrapper in unsupported terminals.
101
+
102
+ > **Preview limitation:** the live wrapper targets ANSI-capable Windows Terminal and mintty. For full-screen terminal applications, bypass the wrapper and open them from a normal Git Bash session.
103
+
104
+ ### Zsh / Bash (macOS/Linux)
105
+
106
+ **Tab-to-Suggest** uses `fzf` when available. Type `git ` and press **Tab** to open a ranked command picker; **Enter** fills the command line. If `fzf` is unavailable, HintShell uses the top matching command without emitting an executable-path error.
107
+
108
+ ### Context-aware suggestions
109
+
110
+ Each request includes the current working directory and shell. HintShell merges bounded contextual candidates with local and global history, then ranks the combined list once.
111
+
112
+ - Paths for supported argument positions, including `cd`, `pushd`, `mkdir`, `rmdir`, `cat`, `rg`, `git add`, and `docker build`.
113
+ - Git branches/remotes, npm-family scripts, Docker entities, SSH hosts, and zoxide directories when the command and local runtime are available.
114
+ - Local-history matches are boosted only for the active directory; prefix quality remains more important than contextual or fuzzy matches.
115
+ - Filesystem scans, workspace detection, and external commands are bounded, cached where appropriate, and fail closed. Context candidates never write themselves to command history.
116
+
81
117
  ### PowerShell (Windows/Unix)
82
- **Real-time Overlay**: Suggestions appear automatically as a floating panel beneath your cursor as you type.
118
+ **Real-time Overlay**: Suggestions appear automatically as a floating panel beneath your cursor as you type.
83
119
  - **↑ / ↓** : Navigate
84
120
  - **Tab** : Accept
85
121
  - **Esc** : Close
86
122
 
87
- ### Zsh / Bash (macOS/Linux/Git Bash)
88
- **Tab-to-Suggest**: To avoid conflicts with `zsh-autosuggestions`, HintShell activates when you press **Tab**.
89
- - **Type `git ` + Tab** : Opens a fuzzy picker with frequencies.
90
- - **Enter** : Select and fill the command line.
123
+ ---
91
124
 
92
- > **Git Bash note:** HintShell resolves `fzf` to a real executable (e.g. under WinGet Packages). If you previously saw `Permission denied` on `WinGet/Links/fzf`, reinstall/update to **0.2.0+**, run `hs init` (or reload `~/.bashrc`), and open a new terminal.
125
+ ## ✨ What's new in 0.3.0
93
126
 
94
- ---
127
+ - Context-aware suggestions merge local/global history with path, workspace, Git, npm, Docker, SSH, and zoxide candidates.
128
+ - Git Bash launches the live overlay automatically after `hs init`; Bash retains authority for path and flag completion.
129
+ - The live overlay scrolls long result sets and avoids stale rendering at the bottom of the terminal. See [CHANGELOG.md](./CHANGELOG.md).
130
+
131
+ ## 🔄 Updating
132
+
133
+ While the daemon is running, Windows locks `hintshell-core.exe`. Use:
95
134
 
96
- ## ✨ What's new in 0.2.0
135
+ ```bash
136
+ # Recommended
137
+ hs update
138
+
139
+ # Or raw npm — postinstall stops the daemon and runs init
140
+ npm i -g hintshell@latest
141
+ ```
142
+
143
+ If you still hit a file lock (`os error 32` / "being used by another process"):
144
+
145
+ ```bash
146
+ hs stop
147
+ # or: taskkill /F /IM hintshell-core.exe
148
+ npm i -g hintshell@latest
149
+ hintshell init
150
+ ```
97
151
 
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
152
  ## 🗑️ Uninstallation
102
153
 
103
154
  If you need to remove HintShell, it now comes with a clean uninstaller that handles everything for you:
@@ -119,7 +170,7 @@ npm uninstall -g hintshell
119
170
  hs status # Check if the daemon is running and see stats
120
171
  hs start # Manually start the daemon
121
172
  hs stop # Stop the daemon
122
- hs update # Check for new versions
173
+ hs update # Stop daemon, npm install -g, init, restart
123
174
  hs uninstall # Completely remove shell integration and binaries
124
175
  ```
125
176
 
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "hintshell",
3
- "version": "0.2.0",
4
- "description": "Next-gen AI-ready real-time command suggestions for your terminal. Smart, context-aware autocomplete for PowerShell, Bash, and Zsh.",
3
+ "version": "0.3.0",
4
+ "description": "Local, context-aware real-time command suggestions for PowerShell, Bash, and Zsh.",
5
5
  "keywords": [
6
- "ai-shell",
6
+ "shell-assistant",
7
7
  "shell-assistant",
8
8
  "terminal-autocomplete",
9
9
  "cli-productivity",
@@ -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();