hintshell 0.3.7 → 0.3.11
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 +29 -6
- package/package.json +1 -1
- package/scripts/npm-install.js +7 -1
- package/scripts/npm-install.test.js +15 -3
- package/scripts/npm-stop.js +1 -2
- package/scripts/test-overlay-interactive.ps1 +119 -0
package/README.md
CHANGED
|
@@ -62,13 +62,9 @@ HintShell uses `fzf` to render the suggestion picker on Bash/Zsh (including **Gi
|
|
|
62
62
|
- **Windows PowerShell**: No extra dependencies for the real-time overlay.
|
|
63
63
|
|
|
64
64
|
### 2. Install HintShell
|
|
65
|
-
Install via
|
|
65
|
+
Install via npm to get the latest pre-built binaries for your platform. Add `--foreground-scripts` to show the binary download, extraction, and setup output (this is also what `hs update` uses):
|
|
66
66
|
```bash
|
|
67
|
-
npm install -g hintshell@latest
|
|
68
|
-
|
|
69
|
-
or
|
|
70
|
-
|
|
71
|
-
npm i -g hintshell@latest --foreground-scripts
|
|
67
|
+
npm install -g hintshell@latest --foreground-scripts
|
|
72
68
|
```
|
|
73
69
|
|
|
74
70
|
### 3. Initialize Shell Integration
|
|
@@ -113,6 +109,33 @@ HINTSHELL_DISABLE_AUTO_BASH=1 bash
|
|
|
113
109
|
|
|
114
110
|
> **Preview limitation:** the live wrapper requires an ANSI-capable terminal. For full-screen terminal applications, bypass the wrapper and open them from a normal Bash session.
|
|
115
111
|
|
|
112
|
+
### Git Bash Fast in VS Code
|
|
113
|
+
|
|
114
|
+
A VS Code Git Bash profile using `--norc --noprofile` intentionally skips `~/.bashrc`, so it also skips HintShell's standard Bash hook. Create a separate, minimal rcfile instead:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
hs init --git-bash-fast
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The command creates `~/.hintshell/git-bash-fast.bashrc`, which keeps the green/yellow prompt, initializes HintShell, and does **not** source your aliases, plugins, `.bashrc`, or `.bash_profile`. It prints a `Git Bash Fast + HintShell` profile for VS Code. Add that profile to user settings and select it manually; HintShell does not edit `settings.json` or change `terminal.integrated.defaultProfile.windows`.
|
|
121
|
+
|
|
122
|
+
The emitted profile has this shape (the rcfile path reflects your own user directory):
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
"terminal.integrated.profiles.windows": {
|
|
126
|
+
"Git Bash Fast + HintShell": {
|
|
127
|
+
"path": "C:\\Users\\<you>\\.hintshell\\bin\\hintshell.exe",
|
|
128
|
+
"args": ["bash", "--rcfile", "/c/Users/<you>/.hintshell/git-bash-fast.bashrc", "-i"],
|
|
129
|
+
"env": {
|
|
130
|
+
"TERM": "xterm-256color"
|
|
131
|
+
},
|
|
132
|
+
"icon": "terminal-bash"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
The live overlay needs VS Code's ANSI-capable integrated terminal and Windows ConPTY. Select the original `Git Bash Fast` profile for a session without HintShell. Within the dedicated profile, set `HINTSHELL_DISABLE_AUTO_BASH=1` before starting Bash to bypass the wrapper for a session.
|
|
138
|
+
|
|
116
139
|
### macOS Bash / Zsh live overlay
|
|
117
140
|
|
|
118
141
|
On macOS, `hs init` configures the realtime overlay automatically for interactive Bash and Zsh sessions. For Bash login shells, it also adds a managed block to `~/.bash_profile` that loads `~/.bashrc`, so the overlay starts in macOS Terminal and iTerm2 without manual profile edits.
|
package/package.json
CHANGED
package/scripts/npm-install.js
CHANGED
|
@@ -57,7 +57,13 @@ function getDownloadUrl(target, ext) {
|
|
|
57
57
|
|
|
58
58
|
function downloadFile(url, dest, options = {}) {
|
|
59
59
|
const requestTimeoutMs = options.requestTimeoutMs ?? REQUEST_TIMEOUT_MS;
|
|
60
|
-
|
|
60
|
+
let parsedUrl;
|
|
61
|
+
try {
|
|
62
|
+
parsedUrl = new URL(url);
|
|
63
|
+
} catch {
|
|
64
|
+
return Promise.reject(new Error(`Download failed: invalid URL ${url}`));
|
|
65
|
+
}
|
|
66
|
+
if (parsedUrl.protocol === "file:") {
|
|
61
67
|
return new Promise((resolve, reject) => {
|
|
62
68
|
fs.copyFile(fileURLToPath(url), dest, (error) => (error ? reject(error) : resolve()));
|
|
63
69
|
});
|
|
@@ -18,11 +18,23 @@ function listen(handler) {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
test("Windows stop script
|
|
21
|
+
test("Windows stop script stops only live wrapper processes", () => {
|
|
22
22
|
const script = fs.readFileSync(path.join(__dirname, "npm-stop.js"), "utf8");
|
|
23
23
|
assert.match(script, /hintshell-core\.exe/);
|
|
24
|
-
assert.match(script, /hintshell\.exe/);
|
|
25
|
-
assert.match(script, /
|
|
24
|
+
assert.match(script, /Name = 'hintshell\.exe'/);
|
|
25
|
+
assert.match(script, /CommandLine -match/);
|
|
26
|
+
assert.match(script, /CommandLine -match .*bash/);
|
|
27
|
+
assert.doesNotMatch(script, /taskkill", \["\/F", "\/IM", "hintshell\.exe"\]/);
|
|
28
|
+
assert.doesNotMatch(script, /Get-Process -Name 'hintshell', 'hintshell-core'/);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("PowerShell update exposes npm lifecycle progress without duplicate init", () => {
|
|
32
|
+
const module = fs.readFileSync(
|
|
33
|
+
path.join(__dirname, "..", "integrations", "powershell", "HintShellModule", "HintShellModule.psm1"),
|
|
34
|
+
"utf8"
|
|
35
|
+
);
|
|
36
|
+
assert.match(module, /npm install -g hintshell@latest --foreground-scripts --fetch-timeout=30000 --fetch-retries=1/);
|
|
37
|
+
assert.doesNotMatch(module, /Ensuring local install \(hintshell init\)/);
|
|
26
38
|
});
|
|
27
39
|
|
|
28
40
|
test("isolated tests skip global process control", () => {
|
package/scripts/npm-stop.js
CHANGED
|
@@ -47,11 +47,10 @@ function stopRunningDaemon(reason) {
|
|
|
47
47
|
|
|
48
48
|
if (IS_WIN) {
|
|
49
49
|
run("taskkill", ["/F", "/IM", "hintshell-core.exe"]);
|
|
50
|
-
run("taskkill", ["/F", "/IM", "hintshell.exe"]);
|
|
51
50
|
run("powershell", [
|
|
52
51
|
"-NoProfile",
|
|
53
52
|
"-Command",
|
|
54
|
-
"Get-
|
|
53
|
+
"Get-CimInstance Win32_Process -Filter \"Name = 'hintshell.exe'\" | Where-Object { $_.CommandLine -match '\\s+bash(?:\\s|$)' } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }",
|
|
55
54
|
]);
|
|
56
55
|
} else {
|
|
57
56
|
run("pkill", ["-f", "hintshell-core"]);
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
$ErrorActionPreference = 'Stop'
|
|
2
|
+
$repo = Split-Path $PSScriptRoot -Parent
|
|
3
|
+
Set-Location $repo
|
|
4
|
+
|
|
5
|
+
# This is intentionally an operator-driven test. PowerShell cannot safely synthesize
|
|
6
|
+
# real terminal keystrokes from this script, so each behavior is confirmed manually.
|
|
7
|
+
if (-not [Environment]::UserInteractive -or -not $Host.UI.RawUI -or [Console]::IsInputRedirected -or [Console]::IsOutputRedirected) {
|
|
8
|
+
Write-Host 'FAIL interactive terminal required (run this from a real pwsh console).' -ForegroundColor Red
|
|
9
|
+
exit 2
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
$moduleRoot = Join-Path $repo 'integrations/powershell/HintShellModule'
|
|
13
|
+
$manifest = Join-Path $moduleRoot 'HintShellModule.psd1'
|
|
14
|
+
$moduleFile = Join-Path $moduleRoot 'HintShellModule.psm1'
|
|
15
|
+
$sourceFiles = @(
|
|
16
|
+
$moduleFile,
|
|
17
|
+
(Join-Path $moduleRoot 'HintShellDaemon.ps1'),
|
|
18
|
+
(Join-Path $moduleRoot 'HintShellOverlay.ps1'),
|
|
19
|
+
(Join-Path $moduleRoot 'HintShellHandlers.ps1')
|
|
20
|
+
)
|
|
21
|
+
$timeoutMs = 1200
|
|
22
|
+
$moduleName = 'HintShellModule'
|
|
23
|
+
$oldHintshellHome = $env:HINTSHELL_HOME
|
|
24
|
+
$oldHintshellDataHome = $env:HINTSHELL_DATA_HOME
|
|
25
|
+
$tempHome = Join-Path ([IO.Path]::GetTempPath()) ("hintshell-overlay-regression-{0}" -f ([guid]::NewGuid().ToString('N')))
|
|
26
|
+
$tempDataHome = Join-Path $tempHome 'data'
|
|
27
|
+
$results = [System.Collections.Generic.List[object]]::new()
|
|
28
|
+
$imported = $false
|
|
29
|
+
|
|
30
|
+
function Read-HSOperatorLine {
|
|
31
|
+
Write-Host 'Enter the requested test input below, then press Enter. The command is captured only and is not executed by this harness.' -ForegroundColor DarkGray
|
|
32
|
+
return [Microsoft.PowerShell.PSConsoleReadLine]::ReadLine($Host.Runspace, $ExecutionContext, $null)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function Add-OperatorResult {
|
|
36
|
+
param([string]$Name, [string]$Instruction)
|
|
37
|
+
Write-Host "`n[$Name]" -ForegroundColor Cyan
|
|
38
|
+
Write-Host $Instruction
|
|
39
|
+
$capturedLine = Read-HSOperatorLine
|
|
40
|
+
Write-Host "Captured input: <$capturedLine>" -ForegroundColor DarkGray
|
|
41
|
+
do {
|
|
42
|
+
$answer = (Read-Host 'Result: P=pass, F=fail, S=skip').Trim().ToUpperInvariant()
|
|
43
|
+
} while ($answer -notin @('P', 'F', 'S'))
|
|
44
|
+
$results.Add([pscustomobject]@{ Name = $Name; Result = $answer })
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
Write-Host 'HintShell interactive overlay regression test' -ForegroundColor White
|
|
49
|
+
Write-Host 'Run only in a disposable interactive pwsh session. This script does not automate keystrokes.' -ForegroundColor Yellow
|
|
50
|
+
|
|
51
|
+
foreach ($source in $sourceFiles) {
|
|
52
|
+
if (-not (Test-Path -LiteralPath $source -PathType Leaf)) { throw "Missing source: $source" }
|
|
53
|
+
$tokens = $null; $errors = $null
|
|
54
|
+
$null = [System.Management.Automation.Language.Parser]::ParseFile($source, [ref]$tokens, [ref]$errors)
|
|
55
|
+
if ($errors -and $errors.Count -gt 0) { throw "Parse failed: $source" }
|
|
56
|
+
Write-Host "OK parse $source" -ForegroundColor Green
|
|
57
|
+
}
|
|
58
|
+
$moduleText = Get-Content -LiteralPath $moduleFile -Raw
|
|
59
|
+
if ($moduleText -notmatch 'Test-HSDaemonAlive\s+-TimeoutMs') { throw 'Daemon timeout source check failed' }
|
|
60
|
+
if ($timeoutMs -lt 100 -or $timeoutMs -gt 10000) { throw "Timeout sanity check failed: $timeoutMs ms" }
|
|
61
|
+
Write-Host "OK source/timeout sanity (daemon timeout=$timeoutMs ms)" -ForegroundColor Green
|
|
62
|
+
|
|
63
|
+
$psReadLine = Get-Module -ListAvailable -Name PSReadLine | Select-Object -First 1
|
|
64
|
+
if (-not $psReadLine) { throw 'PSReadLine is not available' }
|
|
65
|
+
Import-Module PSReadLine -ErrorAction Stop
|
|
66
|
+
if (-not ('Microsoft.PowerShell.PSConsoleReadLine' -as [type])) { throw 'PSReadLine console type unavailable' }
|
|
67
|
+
Write-Host "OK PSReadLine available/imported ($($psReadLine.Version))" -ForegroundColor Green
|
|
68
|
+
|
|
69
|
+
New-Item -ItemType Directory -Path $tempHome -Force | Out-Null
|
|
70
|
+
New-Item -ItemType Directory -Path $tempDataHome -Force | Out-Null
|
|
71
|
+
$env:HINTSHELL_HOME = $tempHome
|
|
72
|
+
$env:HINTSHELL_DATA_HOME = $tempDataHome
|
|
73
|
+
Import-Module $manifest -Force -DisableNameChecking -ErrorAction Stop
|
|
74
|
+
$imported = $true
|
|
75
|
+
Start-HintShell -Force -Quiet
|
|
76
|
+
Write-Host 'OK HintShell module imported and startup completed.' -ForegroundColor Green
|
|
77
|
+
|
|
78
|
+
Add-OperatorResult 'Slow typing' 'Type a short command one character at a time, pausing between keys. Confirm suggestions/overlay remain stable and the line stays editable.'
|
|
79
|
+
Add-OperatorResult 'Fast typing' 'Type a short command quickly. Confirm the overlay does not corrupt, lag indefinitely, or consume characters.'
|
|
80
|
+
Add-OperatorResult 'Single-line paste' 'Paste one short command. Confirm it is inserted as one line and does not trigger one suggestion request per pasted character.'
|
|
81
|
+
Add-OperatorResult 'Multiline paste' 'Paste text containing a newline. Confirm multiline input remains usable and the overlay is suppressed or behaves safely.'
|
|
82
|
+
Add-OperatorResult 'Enter with daemon available' 'Type a harmless command such as `Write-Output overlay-test`, press Enter, and confirm the line is accepted once without a stuck overlay. The harness captures it but does not execute it.'
|
|
83
|
+
|
|
84
|
+
Write-Host "`n[Daemon unavailable]" -ForegroundColor Cyan
|
|
85
|
+
Write-Host 'The next command stops this test daemon through the module cleanup path. Do not stop unrelated HintShell daemons.'
|
|
86
|
+
hs stop
|
|
87
|
+
Add-OperatorResult 'Enter with daemon unavailable' 'Type a harmless command such as `Write-Output overlay-test-offline`, press Enter, and confirm the line is accepted once without a stuck overlay. The harness captures it but does not execute it.'
|
|
88
|
+
|
|
89
|
+
Write-Host "`nRestarting module startup for cleanup-path verification..." -ForegroundColor DarkGray
|
|
90
|
+
Import-Module $manifest -Force -DisableNameChecking -ErrorAction Stop
|
|
91
|
+
Start-HintShell -Force -Quiet
|
|
92
|
+
Write-Host 'OK module can start again after unavailable-daemon case.' -ForegroundColor Green
|
|
93
|
+
|
|
94
|
+
$failed = @($results | Where-Object Result -eq 'F')
|
|
95
|
+
$skipped = @($results | Where-Object Result -eq 'S')
|
|
96
|
+
if ($failed.Count -gt 0) {
|
|
97
|
+
Write-Host "`nFAIL operator checks: $($failed.Name -join ', ')" -ForegroundColor Red
|
|
98
|
+
exit 1
|
|
99
|
+
}
|
|
100
|
+
if ($skipped.Count -gt 0) {
|
|
101
|
+
Write-Host "`nFAIL incomplete operator checks (skipped): $($skipped.Name -join ', ')" -ForegroundColor Red
|
|
102
|
+
exit 1
|
|
103
|
+
}
|
|
104
|
+
Write-Host "`nPASS all $($results.Count) interactive overlay checks" -ForegroundColor Green
|
|
105
|
+
exit 0
|
|
106
|
+
} catch {
|
|
107
|
+
Write-Host "`nFAIL $($_.Exception.Message)" -ForegroundColor Red
|
|
108
|
+
exit 1
|
|
109
|
+
} finally {
|
|
110
|
+
if ($imported) {
|
|
111
|
+
try { Stop-HintShell } catch { Write-Host "Cleanup warning: $($_.Exception.Message)" -ForegroundColor Yellow }
|
|
112
|
+
Remove-Module $moduleName -Force -ErrorAction SilentlyContinue
|
|
113
|
+
}
|
|
114
|
+
if ($null -eq $oldHintshellHome) { Remove-Item Env:HINTSHELL_HOME -ErrorAction SilentlyContinue }
|
|
115
|
+
else { $env:HINTSHELL_HOME = $oldHintshellHome }
|
|
116
|
+
if ($null -eq $oldHintshellDataHome) { Remove-Item Env:HINTSHELL_DATA_HOME -ErrorAction SilentlyContinue }
|
|
117
|
+
else { $env:HINTSHELL_DATA_HOME = $oldHintshellDataHome }
|
|
118
|
+
if (Test-Path -LiteralPath $tempHome) { Remove-Item -LiteralPath $tempHome -Recurse -Force -ErrorAction SilentlyContinue }
|
|
119
|
+
}
|