hintshell 0.1.7 → 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 +36 -6
- package/package.json +1 -1
- package/scripts/npm-install.js +120 -12
- package/scripts/test-bashrc-load.sh +26 -0
- package/scripts/test-fzf-quiet.sh +24 -0
- package/scripts/test-fzf-resolve-bash.sh +27 -0
- package/scripts/test-overlay-layout.ps1 +41 -0
package/README.md
CHANGED
|
@@ -42,11 +42,12 @@ Most shells offer basic, single-line autocomplete. HintShell replaces that with
|
|
|
42
42
|
|
|
43
43
|
Follow these steps in order to get HintShell running on your machine.
|
|
44
44
|
|
|
45
|
-
### 1. Install Dependencies (macOS / Linux
|
|
46
|
-
HintShell uses `fzf` to render the suggestion picker on
|
|
45
|
+
### 1. Install Dependencies (macOS / Linux / Git Bash)
|
|
46
|
+
HintShell uses `fzf` to render the suggestion picker on Bash/Zsh (including **Git Bash** on Windows).
|
|
47
47
|
- **macOS**: `brew install fzf`
|
|
48
48
|
- **Linux (Ubuntu/Debian)**: `sudo apt install fzf`
|
|
49
|
-
- **Windows**:
|
|
49
|
+
- **Windows (Git Bash)**: `winget install junegunn.fzf` (or install fzf another way). PowerShell overlay does **not** require fzf.
|
|
50
|
+
- **Windows PowerShell**: No extra dependencies for the real-time overlay.
|
|
50
51
|
|
|
51
52
|
### 2. Install HintShell
|
|
52
53
|
Install via NPM to get the latest pre-built binaries for your platform:
|
|
@@ -83,13 +84,42 @@ source ~/.bashrc
|
|
|
83
84
|
- **Tab** : Accept
|
|
84
85
|
- **Esc** : Close
|
|
85
86
|
|
|
86
|
-
### Zsh / Bash (macOS/Linux)
|
|
87
|
+
### Zsh / Bash (macOS/Linux/Git Bash)
|
|
87
88
|
**Tab-to-Suggest**: To avoid conflicts with `zsh-autosuggestions`, HintShell activates when you press **Tab**.
|
|
88
|
-
- **Type `git ` + Tab** : Opens a fuzzy picker with frequencies
|
|
89
|
+
- **Type `git ` + Tab** : Opens a fuzzy picker with frequencies.
|
|
89
90
|
- **Enter** : Select and fill the command line.
|
|
90
91
|
|
|
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.
|
|
93
|
+
|
|
91
94
|
---
|
|
92
95
|
|
|
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
|
+
```
|
|
122
|
+
|
|
93
123
|
## 🗑️ Uninstallation
|
|
94
124
|
|
|
95
125
|
If you need to remove HintShell, it now comes with a clean uninstaller that handles everything for you:
|
|
@@ -111,7 +141,7 @@ npm uninstall -g hintshell
|
|
|
111
141
|
hs status # Check if the daemon is running and see stats
|
|
112
142
|
hs start # Manually start the daemon
|
|
113
143
|
hs stop # Stop the daemon
|
|
114
|
-
hs update #
|
|
144
|
+
hs update # Stop daemon, npm install -g, init, restart
|
|
115
145
|
hs uninstall # Completely remove shell integration and binaries
|
|
116
146
|
```
|
|
117
147
|
|
package/package.json
CHANGED
package/scripts/npm-install.js
CHANGED
|
@@ -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", () => {
|
|
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
|
-
|
|
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
|
-
|
|
112
|
-
|
|
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
|
|
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(
|
|
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();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
# Simulate what user does after fix
|
|
4
|
+
source "$HOME/.bashrc"
|
|
5
|
+
echo "which hintshell: $(which hintshell 2>/dev/null || true)"
|
|
6
|
+
echo "type resolve: $(type -t _hintshell_resolve_fzf 2>/dev/null || echo NOT_FOUND)"
|
|
7
|
+
if type -t _hintshell_resolve_fzf >/dev/null 2>&1; then
|
|
8
|
+
r="$(_hintshell_resolve_fzf 2>&1)"
|
|
9
|
+
echo "resolve: $r"
|
|
10
|
+
if printf '%s' "$r" | grep -qi 'Permission denied'; then
|
|
11
|
+
echo FAIL_permission
|
|
12
|
+
exit 1
|
|
13
|
+
fi
|
|
14
|
+
case "$r" in
|
|
15
|
+
*/Packages/*) echo OK ;;
|
|
16
|
+
*) echo FAIL_path; exit 1 ;;
|
|
17
|
+
esac
|
|
18
|
+
else
|
|
19
|
+
echo FAIL_no_function
|
|
20
|
+
# debug
|
|
21
|
+
echo "HINTSHELL_BIN=${HINTSHELL_BIN:-unset}"
|
|
22
|
+
ls -la /c/Users/ADMIN/.hintshell/bin/ 2>&1 | head -10
|
|
23
|
+
exit 1
|
|
24
|
+
fi
|
|
25
|
+
echo "grep Links in hook: $(/c/Users/ADMIN/.hintshell/bin/hintshell.exe hook bash 2>/dev/null | grep -c 'WinGet/Links' || true)"
|
|
26
|
+
echo ALL_OK
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
export PATH="/c/Users/ADMIN/.hintshell/bin:$PATH"
|
|
4
|
+
eval "$(hintshell hook bash 2>/dev/null)"
|
|
5
|
+
echo "type resolve: $(type -t _hintshell_resolve_fzf)"
|
|
6
|
+
# Capture all stderr+stdout from resolve — must not contain Permission denied
|
|
7
|
+
out="$(_hintshell_resolve_fzf 2>&1)" || true
|
|
8
|
+
echo "OUT=$out"
|
|
9
|
+
if printf '%s' "$out" | grep -qi 'Permission denied'; then
|
|
10
|
+
echo FAIL_leaked_error
|
|
11
|
+
exit 1
|
|
12
|
+
fi
|
|
13
|
+
case "$out" in
|
|
14
|
+
*/Packages/*) echo OK_packages_path ;;
|
|
15
|
+
*) echo "OTHER: $out"; exit 1 ;;
|
|
16
|
+
esac
|
|
17
|
+
# Force try Links path (must not print Permission denied)
|
|
18
|
+
err="$(_hintshell_try_fzf '/c/Users/ADMIN/AppData/Local/Microsoft/WinGet/Links/fzf' 2>&1)" || true
|
|
19
|
+
echo "TRY_LINKS=$err"
|
|
20
|
+
if printf '%s' "$err" | grep -qi 'Permission denied'; then
|
|
21
|
+
echo FAIL_links_leaked
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
echo ALL_OK
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
BIN="/d/Admin/Documents/PROJECTS/HintShell/target/release/hintshell.exe"
|
|
4
|
+
[[ -x "$BIN" ]] || BIN="/d/Admin/Documents/PROJECTS/HintShell/target/release/hintshell"
|
|
5
|
+
[[ -x "$BIN" ]] || { echo "FAIL: binary missing"; exit 1; }
|
|
6
|
+
|
|
7
|
+
# Load only fzf resolve helpers from generated hook
|
|
8
|
+
eval "$(
|
|
9
|
+
"$BIN" hook bash 2>/dev/null | awk '
|
|
10
|
+
/^_hintshell_try_fzf\(\)/ {p=1}
|
|
11
|
+
p {print}
|
|
12
|
+
/^}$/ && p && seen++ { if (seen>=2) exit }
|
|
13
|
+
'
|
|
14
|
+
)"
|
|
15
|
+
|
|
16
|
+
resolved="$(_hintshell_resolve_fzf)"
|
|
17
|
+
echo "RESOLVED=$resolved"
|
|
18
|
+
# Must not be the WinGet Links shim
|
|
19
|
+
case "$resolved" in
|
|
20
|
+
*/WinGet/Links/*)
|
|
21
|
+
echo "FAIL: still resolved to Links shim"
|
|
22
|
+
exit 1
|
|
23
|
+
;;
|
|
24
|
+
esac
|
|
25
|
+
ver="$("$resolved" --version 2>&1)"
|
|
26
|
+
echo "VERSION=$ver"
|
|
27
|
+
echo "OK fzf resolve"
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
$ErrorActionPreference = 'Stop'
|
|
2
|
+
$repo = Split-Path $PSScriptRoot -Parent
|
|
3
|
+
Set-Location $repo
|
|
4
|
+
|
|
5
|
+
$overlay = Join-Path $repo 'integrations/powershell/HintShellModule/HintShellOverlay.ps1'
|
|
6
|
+
$handlers = Join-Path $repo 'integrations/powershell/HintShellModule/HintShellHandlers.ps1'
|
|
7
|
+
|
|
8
|
+
foreach ($f in @($overlay, $handlers)) {
|
|
9
|
+
$tokens = $null; $errors = $null
|
|
10
|
+
$null = [System.Management.Automation.Language.Parser]::ParseFile($f, [ref]$tokens, [ref]$errors)
|
|
11
|
+
if ($errors -and $errors.Count -gt 0) {
|
|
12
|
+
Write-Host "FAIL $f"
|
|
13
|
+
$errors | ForEach-Object { Write-Host $_.ToString() }
|
|
14
|
+
exit 1
|
|
15
|
+
}
|
|
16
|
+
Write-Host "OK parse $f"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
. $overlay
|
|
20
|
+
function script:Invoke-HSDaemon { param($Query, $Limit) @() }
|
|
21
|
+
|
|
22
|
+
$w1 = Get-HSDisplayWidth -Text 'hello'
|
|
23
|
+
$w2 = Get-HSDisplayWidth -Text ([string][char]0x2500 * 5)
|
|
24
|
+
$t1 = Get-HSTruncateToWidth -Text ('x' * 20) -MaxCols 10
|
|
25
|
+
$ml1 = Test-HSMultilineBuffer -Typed ("git commit -m" + [char]10 + "foo")
|
|
26
|
+
$ml2 = Test-HSMultilineBuffer -Typed 'git status'
|
|
27
|
+
|
|
28
|
+
if ($w1 -ne 5) { throw "width hello=$w1" }
|
|
29
|
+
# U+2500 box-drawing is single-column in modern terminals
|
|
30
|
+
if ($w2 -ne 5) { throw "width box=$w2" }
|
|
31
|
+
if (-not $ml1) { throw 'multiline detect failed' }
|
|
32
|
+
if ($ml2) { throw 'single-line false positive' }
|
|
33
|
+
$tw = Get-HSDisplayWidth -Text $t1
|
|
34
|
+
if ($tw -gt 10) { throw "trunc too wide: $tw" }
|
|
35
|
+
|
|
36
|
+
# Layout budget uses safe console defaults when handle invalid (CI/headless)
|
|
37
|
+
$budget = Get-HSLayoutBudget -CursorTop 0
|
|
38
|
+
if ($budget.W -lt 20) { throw "W too small $($budget.W)" }
|
|
39
|
+
if ($budget.VpMax -lt 1) { throw "vpMax invalid $($budget.VpMax)" }
|
|
40
|
+
Write-Host "budget W=$($budget.W) compact=$($budget.Compact) vp=$($budget.VpMax) rows=$($budget.AvailableRows)"
|
|
41
|
+
Write-Host 'UNIT OK'
|