hintshell 0.3.8 → 0.3.12

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
@@ -109,6 +109,33 @@ HINTSHELL_DISABLE_AUTO_BASH=1 bash
109
109
 
110
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.
111
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
+
112
139
  ### macOS Bash / Zsh live overlay
113
140
 
114
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hintshell",
3
- "version": "0.3.8",
3
+ "version": "0.3.12",
4
4
  "description": "Local, context-aware real-time command suggestions for PowerShell, Bash, and Zsh.",
5
5
  "keywords": [
6
6
  "shell-assistant",
@@ -28,13 +28,18 @@ test("Windows stop script stops only live wrapper processes", () => {
28
28
  assert.doesNotMatch(script, /Get-Process -Name 'hintshell', 'hintshell-core'/);
29
29
  });
30
30
 
31
- test("PowerShell update exposes npm lifecycle progress without duplicate init", () => {
31
+ test("PowerShell update checks npm version before lifecycle work and retains module helpers", () => {
32
32
  const module = fs.readFileSync(
33
33
  path.join(__dirname, "..", "integrations", "powershell", "HintShellModule", "HintShellModule.psm1"),
34
34
  "utf8"
35
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\)/);
36
+ assert.match(module, /function script:Get-HSInstalledVersion/);
37
+ assert.match(module, /function script:Get-HSLatestNpmVersion/);
38
+ assert.match(module, /npm view hintshell@latest version --fetch-timeout=30000 --fetch-retries=1/);
39
+ assert.match(module, /already the latest version/);
40
+ assert.match(module, /if \(\$installedVersion -and \$latestVersion -and \$installedVersion -eq \$latestVersion\)[\s\S]*?return[\s\S]*?Stopping daemon/);
41
+ assert.doesNotMatch(module, /Remove-Module HintShellModule -Force/);
42
+ assert.doesNotMatch(module, /Reloading module \+ starting daemon/);
38
43
  });
39
44
 
40
45
  test("isolated tests skip global process control", () => {
@@ -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
+ }