fuzzrunx 0.1.7 → 0.2.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 +56 -43
- package/bin/fuzzrun.js +6 -6
- package/package.json +2 -1
- package/scripts/postinstall.js +36 -36
- package/scripts/postuninstall.js +10 -10
- package/src/cli.js +903 -535
- package/src/installer.js +201 -201
- package/test/cli.test.js +139 -0
package/README.md
CHANGED
|
@@ -2,34 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
Auto-correct mistyped commands/subcommands and re-run them automatically (no prompt) when the fix is high-confidence (edit distance 1 or the CLI provides a single suggestion). Base command corrections skip dangerous commands like `rm` or `mv`.
|
|
4
4
|
|
|
5
|
-
### Quick run
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
node bin/fuzzrun.js git commmmit -m "msg"
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Install (npm):
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
npm i -g fuzzrunx
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
On install, FuzzRun auto-enables shell hooks and will print:
|
|
18
|
-
`FuzzRun is automatically enabled. Run "fuzzrun disable" to deactivate.`
|
|
19
|
-
|
|
20
|
-
If you want to skip auto-enable, set `FUZZRUN_SKIP_ENABLE=1` during install.
|
|
21
|
-
If auto-enable didn't run (scripts disabled or local install), running any command with `fuzzrun` will attempt a one-time auto-enable unless `FUZZRUN_SKIP_ENABLE=1` is set.
|
|
22
|
-
On uninstall, FuzzRun automatically removes its shell hooks.
|
|
23
|
-
|
|
24
|
-
### Bash/Zsh hook (auto-run on typos)
|
|
25
|
-
|
|
26
|
-
Add to your shell rc:
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
FUZZRUN_BIN="/absolute/path/to/bin/fuzzrun.js"
|
|
30
|
-
fuzzrun() { node "$FUZZRUN_BIN" "$@"; }
|
|
31
|
-
command_not_found_handle() { fuzzrun "$@"; }
|
|
32
|
-
git() { fuzzrun git "$@"; } # optional: wrap git to auto-fix subcommands
|
|
5
|
+
### Quick run
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
node bin/fuzzrun.js git commmmit -m "msg"
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Install (npm):
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
npm i -g fuzzrunx
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
On install, FuzzRun auto-enables shell hooks and will print:
|
|
18
|
+
`FuzzRun is automatically enabled. Run "fuzzrun disable" to deactivate.`
|
|
19
|
+
|
|
20
|
+
If you want to skip auto-enable, set `FUZZRUN_SKIP_ENABLE=1` during install.
|
|
21
|
+
If auto-enable didn't run (scripts disabled or local install), running any command with `fuzzrun` will attempt a one-time auto-enable unless `FUZZRUN_SKIP_ENABLE=1` is set.
|
|
22
|
+
On uninstall, FuzzRun automatically removes its shell hooks.
|
|
23
|
+
|
|
24
|
+
### Bash/Zsh hook (auto-run on typos)
|
|
25
|
+
|
|
26
|
+
Add to your shell rc:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
FUZZRUN_BIN="/absolute/path/to/bin/fuzzrun.js"
|
|
30
|
+
fuzzrun() { node "$FUZZRUN_BIN" "$@"; }
|
|
31
|
+
command_not_found_handle() { fuzzrun "$@"; }
|
|
32
|
+
git() { fuzzrun git "$@"; } # optional: wrap git to auto-fix subcommands
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
Notes: `command_not_found_handle` is bash-only; on zsh use `command_not_found_handler`. Keep `FUZZRUN_BIN` absolute.
|
|
@@ -38,20 +38,32 @@ Notes: `command_not_found_handle` is bash-only; on zsh use `command_not_found_ha
|
|
|
38
38
|
|
|
39
39
|
Append to `Documents\PowerShell\Microsoft.PowerShell_profile.ps1`:
|
|
40
40
|
|
|
41
|
-
```powershell
|
|
42
|
-
$fuzzrun = "C:\Users\HP\fuzzRun\bin\fuzzrun.js" # update path
|
|
43
|
-
function global:fuzzrun { node $fuzzrun @args }
|
|
44
|
-
$ExecutionContext.InvokeCommand.CommandNotFoundAction = {
|
|
41
|
+
```powershell
|
|
42
|
+
$fuzzrun = "C:\Users\HP\fuzzRun\bin\fuzzrun.js" # update path
|
|
43
|
+
function global:fuzzrun { node $fuzzrun @args }
|
|
44
|
+
$ExecutionContext.InvokeCommand.CommandNotFoundAction = {
|
|
45
45
|
param($commandName, $eventArgs)
|
|
46
46
|
fuzzrun $commandName @($eventArgs.Arguments)
|
|
47
47
|
}
|
|
48
|
-
function global:git { fuzzrun git @args } # optional git wrapper
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Manage hooks
|
|
52
|
-
- `fuzzrun enable` (add hooks to your shell profile)
|
|
53
|
-
- `fuzzrun disable` (remove hooks)
|
|
54
|
-
- `fuzzrun status` (show which profiles are enabled)
|
|
48
|
+
function global:git { fuzzrun git @args } # optional git wrapper
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Manage hooks
|
|
52
|
+
- `fuzzrun enable` (add hooks to your shell profile)
|
|
53
|
+
- `fuzzrun disable` (remove hooks)
|
|
54
|
+
- `fuzzrun status` (show which profiles are enabled)
|
|
55
|
+
|
|
56
|
+
### Preview & stats
|
|
57
|
+
- `fuzzrun explain <command...>` — show the fix it *would* apply without running anything (dry-run). `fuzzrun --dry-run <command...>` works too.
|
|
58
|
+
- `fuzzrun stats` — see how many commands FuzzRun has rescued, broken down by type, plus your most frequent typos.
|
|
59
|
+
|
|
60
|
+
FuzzRun **learns**: every accepted correction is remembered in `~/.fuzzrun/state.json`, and that history is used to break ambiguous ties in favor of fixes you've chosen before.
|
|
61
|
+
|
|
62
|
+
### Output & prompting
|
|
63
|
+
- Corrections are printed in color with a `⚡` marker. Set `NO_COLOR=1` (or `FUZZRUN_NO_COLOR=1`) to disable color; `FUZZRUN_FORCE_COLOR=1` to force it.
|
|
64
|
+
- By default, edit-distance-1 fixes auto-run and weaker (distance ≥ 2) fixes ask first.
|
|
65
|
+
- `FUZZRUN_PROMPT=1` — always ask before applying any fix.
|
|
66
|
+
- `FUZZRUN_YES=1` — never ask; auto-run every fix.
|
|
55
67
|
|
|
56
68
|
### How it works
|
|
57
69
|
- Runs the command once; if it fails with "command not found" or "unknown subcommand", tries a one-edit-away fix or the CLI's own suggestion and re-runs automatically.
|
|
@@ -59,11 +71,12 @@ function global:git { fuzzrun git @args } # optional git wrapper
|
|
|
59
71
|
- Skips auto-run when risky flags are present (`--force`, `--hard`, `-rf`, etc.) and blocks dangerous bases (`rm`, `mv`, `dd`, etc.).
|
|
60
72
|
- Subcommand suggestions are preloaded for popular CLIs (git, npm/yarn/pnpm, pip, docker, kubectl, gh) plus "did you mean" parsing.
|
|
61
73
|
- Context-aware fixes for `git checkout/switch <branch>` and `npm/yarn/pnpm run <script>` after a failure.
|
|
74
|
+
- Fuzzy flag correction for common long flags (e.g. `git commit --mesage` → `--message`); never corrects *into* a destructive flag.
|
|
62
75
|
|
|
63
|
-
### Config
|
|
64
|
-
- `FUZZRUN_MAX_DISTANCE=1` (set to 2 if you want more aggressive matching)
|
|
65
|
-
- `FUZZRUN_ALLOW_ANY_SUBCOMMANDS=1` (allow subcommand fixes for any base that prints suggestions)
|
|
66
|
-
- `FUZZRUN_PREFER_BASES=git,npm,docker` (breaks ties in favor of preferred commands)
|
|
76
|
+
### Config
|
|
77
|
+
- `FUZZRUN_MAX_DISTANCE=1` (set to 2 if you want more aggressive matching)
|
|
78
|
+
- `FUZZRUN_ALLOW_ANY_SUBCOMMANDS=1` (allow subcommand fixes for any base that prints suggestions)
|
|
79
|
+
- `FUZZRUN_PREFER_BASES=git,npm,docker` (breaks ties in favor of preferred commands)
|
|
67
80
|
|
|
68
81
|
### Limits
|
|
69
82
|
- Only one retry; only unique matches; no prompt.
|
package/bin/fuzzrun.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
const { main } = require('../src/cli');
|
|
5
|
-
|
|
6
|
-
main();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { main } = require('../src/cli');
|
|
5
|
+
|
|
6
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fuzzrunx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Auto-correct mistyped commands and subcommands and re-run them safely.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"fuzzrun": "bin/fuzzrun.js"
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"start": "node bin/fuzzrun.js",
|
|
12
|
+
"test": "node --test",
|
|
12
13
|
"postinstall": "node scripts/postinstall.js",
|
|
13
14
|
"postuninstall": "node scripts/postuninstall.js"
|
|
14
15
|
}
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const os = require('os');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const installer = require('../src/installer');
|
|
7
|
-
|
|
8
|
-
const skip = process.env.FUZZRUN_SKIP_ENABLE === '1';
|
|
9
|
-
|
|
10
|
-
function getStatePath() {
|
|
11
|
-
return path.join(os.homedir(), '.fuzzrun', 'state.json');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function writeState(next) {
|
|
15
|
-
const filePath = getStatePath();
|
|
16
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
17
|
-
fs.writeFileSync(filePath, JSON.stringify(next, null, 2), 'utf8');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (skip) {
|
|
21
|
-
process.stderr.write('fuzzrun: auto-enable skipped\n');
|
|
22
|
-
process.exit(0);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const foregroundScripts =
|
|
26
|
-
process.env.npm_config_foreground_scripts === 'true' ||
|
|
27
|
-
process.env.npm_config_foreground_scripts === '1';
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
installer.enable({});
|
|
31
|
-
process.stderr.write('FuzzRun is automatically enabled. Run "fuzzrun disable" to deactivate.\n');
|
|
32
|
-
writeState({ bannerShown: foregroundScripts, enableSucceeded: true });
|
|
33
|
-
} catch (err) {
|
|
34
|
-
process.stderr.write(`fuzzrun: auto-enable failed: ${err.message}\n`);
|
|
35
|
-
writeState({ bannerShown: false, enableSucceeded: false, lastError: err.message });
|
|
36
|
-
}
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const installer = require('../src/installer');
|
|
7
|
+
|
|
8
|
+
const skip = process.env.FUZZRUN_SKIP_ENABLE === '1';
|
|
9
|
+
|
|
10
|
+
function getStatePath() {
|
|
11
|
+
return path.join(os.homedir(), '.fuzzrun', 'state.json');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function writeState(next) {
|
|
15
|
+
const filePath = getStatePath();
|
|
16
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
17
|
+
fs.writeFileSync(filePath, JSON.stringify(next, null, 2), 'utf8');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (skip) {
|
|
21
|
+
process.stderr.write('fuzzrun: auto-enable skipped\n');
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const foregroundScripts =
|
|
26
|
+
process.env.npm_config_foreground_scripts === 'true' ||
|
|
27
|
+
process.env.npm_config_foreground_scripts === '1';
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
installer.enable({});
|
|
31
|
+
process.stderr.write('FuzzRun is automatically enabled. Run "fuzzrun disable" to deactivate.\n');
|
|
32
|
+
writeState({ bannerShown: foregroundScripts, enableSucceeded: true });
|
|
33
|
+
} catch (err) {
|
|
34
|
+
process.stderr.write(`fuzzrun: auto-enable failed: ${err.message}\n`);
|
|
35
|
+
writeState({ bannerShown: false, enableSucceeded: false, lastError: err.message });
|
|
36
|
+
}
|
package/scripts/postuninstall.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const installer = require('../src/installer');
|
|
4
|
-
|
|
5
|
-
try {
|
|
6
|
-
installer.disable();
|
|
7
|
-
process.stderr.write('FuzzRun hooks removed. Restart your terminal if needed.\n');
|
|
8
|
-
} catch (err) {
|
|
9
|
-
process.stderr.write(`fuzzrun: postuninstall cleanup failed: ${err.message}\n`);
|
|
10
|
-
}
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const installer = require('../src/installer');
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
installer.disable();
|
|
7
|
+
process.stderr.write('FuzzRun hooks removed. Restart your terminal if needed.\n');
|
|
8
|
+
} catch (err) {
|
|
9
|
+
process.stderr.write(`fuzzrun: postuninstall cleanup failed: ${err.message}\n`);
|
|
10
|
+
}
|