@microsoft/inshellisense 0.0.1-rc.9 → 0.0.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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) Microsoft Corporation.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
package/README.md CHANGED
@@ -6,27 +6,68 @@
6
6
 
7
7
  ## Getting Started
8
8
 
9
- ### Requirements
10
-
11
- - Node.js 20.X, 18.X, 16.X (16.6.0 >=)
12
-
13
9
  ### Installation
14
10
 
11
+ **npm (recommended)**
15
12
  ```shell
16
13
  npm install -g @microsoft/inshellisense
14
+ is init
15
+ ```
16
+ **homebrew (macOS/linux)**
17
+ ```shell
18
+ brew tap microsoft/inshellisense https://github.com/microsoft/inshellisense
19
+ brew install inshellisense
20
+ is init
21
+ ```
22
+
23
+ ### Updating
24
+
25
+ ```shell
26
+ npm install -g @microsoft/inshellisense # OR brew upgrade inshellisense
27
+ is reinit
17
28
  ```
18
29
 
19
30
  ### Quickstart
20
31
 
21
- After completing the installation, you can run `is` to start the autocomplete session for your desired shell. Additionally, inshellisense is also aliased under `inshellisense` after installation.
32
+ After completing the installation, run `is doctor` to verify your installation was successful. You can run `is` to start the autocomplete session for your desired shell. Additionally, inshellisense is also aliased under `inshellisense` after installation.
33
+
34
+ ### Shell Plugin
35
+
36
+ If you'd like to automatically start inshellisense when you open your shell, run the respective command for your shell. After running the command, inshellisense will automatically open when you start any new shell session:
37
+
38
+ ```shell
39
+ # bash
40
+ is init bash >> ~/.bashrc
41
+
42
+ # zsh
43
+ is init zsh >> ~/.zshrc
44
+
45
+ # fish
46
+ is init fish >> ~/.config/fish/config.fish
47
+
48
+ # pwsh
49
+ is init pwsh | Add-Content $profile
50
+
51
+ # powershell
52
+ is init powershell | Add-Content $profile
53
+
54
+ # xonsh
55
+ is init xonsh >> ~/.xonshrc
56
+
57
+ # nushell
58
+ is init nu | save $nu.env-path --append
59
+ ```
60
+
61
+ > [!NOTE]
62
+ > When updating your shell configuration in the future, make sure the inshellisense plugin is the last command in the file. Including commands after it may break the configuration (ex. initializing your shell plugin manager after the inshellisense plugin)
22
63
 
23
64
  ### Usage
24
65
 
25
- | Action | Command |
26
- | ------------------------------------- | ------- |
27
- | Start | `is` |
28
- | Stop | `exit` |
29
- | Check If Inside Inshellisense Session | `is -c` |
66
+ | Action | Command | Description |
67
+ | ------------------------------------- | ------- | ------------------------------------------------ |
68
+ | Start | `is` | Start inshellisense session on the current shell |
69
+ | Stop | `exit` | Stop inshellisense session on the current shell |
70
+ | Check If Inside Inshellisense Session | `is -c` | Check if shell inside inshellisense session |
30
71
 
31
72
  #### Keybindings
32
73
 
@@ -50,10 +91,11 @@ inshellisense supports the following shells:
50
91
  - [powershell](https://learn.microsoft.com/en-us/powershell/scripting/windows-powershell/starting-windows-powershell) (Windows Powershell)
51
92
  - [cmd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd) _(experimental)_
52
93
  - [xonsh](https://xon.sh/)
94
+ - [nushell](https://www.nushell.sh/)
53
95
 
54
96
  ## Configuration
55
97
 
56
- All configuration is done through a [toml](https://toml.io/) file located at `~/.inshellisenserc`. The [JSON schema](https://json-schema.org/) for the configuration file can be found [here](https://github.com/microsoft/inshellisense/blob/main/src/utils/config.ts).
98
+ All configuration is done through a [toml](https://toml.io/) file. You can create this file at `~/.inshellisenserc` or, for XDG compliance, at `~/.config/inshellisense/rc.toml`. The [JSON schema](https://json-schema.org/) for the configuration file can be found [here](https://github.com/microsoft/inshellisense/blob/main/src/utils/config.ts).
57
99
 
58
100
  ### Keybindings
59
101
 
@@ -62,7 +104,7 @@ You can customize the keybindings for inshellisense by adding a `bindings` secti
62
104
  ```toml
63
105
  [bindings.acceptSuggestion]
64
106
  key = "tab"
65
- # shift and tab are optional and default to false
107
+ # shift and ctrl are optional and default to false
66
108
  shift = false
67
109
  ctrl = false
68
110
 
@@ -78,17 +120,35 @@ key = "escape"
78
120
 
79
121
  Key names are matched against the Node.js [keypress](https://nodejs.org/api/readline.html#readlineemitkeypresseventsstream-interface) events.
80
122
 
81
- ### Custom Prompts (Windows)
123
+ ### Alias Expansion
124
+
125
+ Inshellisense supports expanding aliases for bash/zsh shells. You can enable alias expansion in your config file:
126
+
127
+ ```toml
128
+ useAliases = true
129
+ ```
130
+
131
+ ### NerdFonts
82
132
 
83
- If you are using a custom prompt in your shell (anything that is not the default PS1), you will need to set up a custom prompt in the inshellisense config file. This is because Windows strips details from your prompt which are required for inshellisense to work. To do this, update your config file in your home directory and add the following configuration:
133
+ If you are using a [NerdFont](https://www.nerdfonts.com/) patched font, you can enable the NerdFonts support in your config file:
84
134
 
85
135
  ```toml
86
- [[prompt.bash]]
87
- regex = "(?<prompt>^>\\s*)" # the prompt match group will be used to detect the prompt
88
- postfix = ">" # the postfix is the last expected character in your prompt
136
+ useNerdFont = true
89
137
  ```
90
138
 
91
- This example adds custom prompt detection for bash where the prompt is expected to be only `> `. You can add similar configurations for other shells as well as well as multiple configurations for each shell.
139
+ ### Max Suggestions
140
+
141
+ You can change the maximum number of suggestions displayed in the autocomplete list at one time in your config file:
142
+
143
+
144
+ ```toml
145
+ maxSuggestions = 10
146
+ ```
147
+
148
+
149
+ ## Unsupported Specs
150
+
151
+ Specs for the `az`, `gcloud`, & `aws` CLIs are not supported in inshellisense due to their large size.
92
152
 
93
153
  ## Contributing
94
154
 
package/SECURITY.md CHANGED
@@ -1,41 +1,41 @@
1
- <!-- BEGIN MICROSOFT SECURITY.MD V0.0.9 BLOCK -->
2
-
3
- ## Security
4
-
5
- Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin).
6
-
7
- If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below.
8
-
9
- ## Reporting Security Issues
10
-
11
- **Please do not report security vulnerabilities through public GitHub issues.**
12
-
13
- Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report).
14
-
15
- If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp).
16
-
17
- You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
18
-
19
- Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20
-
21
- * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22
- * Full paths of source file(s) related to the manifestation of the issue
23
- * The location of the affected source code (tag/branch/commit or direct URL)
24
- * Any special configuration required to reproduce the issue
25
- * Step-by-step instructions to reproduce the issue
26
- * Proof-of-concept or exploit code (if possible)
27
- * Impact of the issue, including how an attacker might exploit the issue
28
-
29
- This information will help us triage your report more quickly.
30
-
31
- If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs.
32
-
33
- ## Preferred Languages
34
-
35
- We prefer all communications to be in English.
36
-
37
- ## Policy
38
-
39
- Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd).
40
-
41
- <!-- END MICROSOFT SECURITY.MD BLOCK -->
1
+ <!-- BEGIN MICROSOFT SECURITY.MD V0.0.9 BLOCK -->
2
+
3
+ ## Security
4
+
5
+ Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin).
6
+
7
+ If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below.
8
+
9
+ ## Reporting Security Issues
10
+
11
+ **Please do not report security vulnerabilities through public GitHub issues.**
12
+
13
+ Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report).
14
+
15
+ If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp).
16
+
17
+ You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
18
+
19
+ Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20
+
21
+ * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22
+ * Full paths of source file(s) related to the manifestation of the issue
23
+ * The location of the affected source code (tag/branch/commit or direct URL)
24
+ * Any special configuration required to reproduce the issue
25
+ * Step-by-step instructions to reproduce the issue
26
+ * Proof-of-concept or exploit code (if possible)
27
+ * Impact of the issue, including how an attacker might exploit the issue
28
+
29
+ This information will help us triage your report more quickly.
30
+
31
+ If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs.
32
+
33
+ ## Preferred Languages
34
+
35
+ We prefer all communications to be in English.
36
+
37
+ ## Policy
38
+
39
+ Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd).
40
+
41
+ <!-- END MICROSOFT SECURITY.MD BLOCK -->
package/bin.js ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+
5
+ const { spawnSync } = require("child_process");
6
+ const path = require("path");
7
+
8
+ const platform = process.platform;
9
+ const arch = process.arch;
10
+
11
+ const platformArch = `${platform}-${arch}`;
12
+ const packageName = `@microsoft/inshellisense-${platformArch}`;
13
+ const binaryName = platform === "win32" ? `inshellisense-${platformArch}.exe` : `inshellisense-${platformArch}`;
14
+
15
+ try {
16
+ const platformPkgPath = require.resolve(`${packageName}/package.json`);
17
+ const platformPkgDir = path.dirname(platformPkgPath);
18
+ const binaryPath = path.join(platformPkgDir, binaryName);
19
+
20
+ const result = spawnSync(binaryPath, process.argv.slice(2), {
21
+ stdio: "inherit",
22
+ shell: false,
23
+ });
24
+
25
+ process.exit(result.status ?? 1);
26
+ } catch (err) {
27
+ console.error(`inshellisense: Platform ${platformArch} is not supported.`);
28
+ console.error(err.message);
29
+ process.exit(1);
30
+ }
package/package.json CHANGED
@@ -1,31 +1,8 @@
1
1
  {
2
2
  "name": "@microsoft/inshellisense",
3
- "version": "0.0.1-rc.9",
3
+ "version": "0.0.1",
4
4
  "description": "IDE style command line auto complete",
5
- "type": "module",
6
- "engines": {
7
- "node": ">=16.6.0 <21.0.0"
8
- },
9
- "bin": {
10
- "inshellisense": "./build/index.js",
11
- "is": "./build/index.js"
12
- },
13
- "files": [
14
- "build/**",
15
- "shell/**",
16
- "*.md",
17
- "LICENSE"
18
- ],
19
- "scripts": {
20
- "build": "tsc",
21
- "dev": "node --loader ts-node/esm src/index.ts -V",
22
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
23
- "test:e2e": "tui-test",
24
- "lint": "eslint src/ --ext .ts,.tsx && prettier src/ --check",
25
- "lint:fix": "eslint src/ --ext .ts,.tsx --fix && prettier src/ --write",
26
- "debug": "node --inspect --loader ts-node/esm src/index.ts -V",
27
- "pre-commit": "lint-staged"
28
- },
5
+ "license": "MIT",
29
6
  "repository": {
30
7
  "type": "git",
31
8
  "url": "git+https://github.com/microsoft/inshellisense.git"
@@ -33,54 +10,24 @@
33
10
  "author": {
34
11
  "name": "Microsoft Corporation"
35
12
  },
36
- "license": "MIT",
37
13
  "bugs": {
38
14
  "url": "https://github.com/microsoft/inshellisense/issues"
39
15
  },
40
- "homepage": "https://github.com/microsoft/inshellisense#readme",
41
- "dependencies": {
42
- "@homebridge/node-pty-prebuilt-multiarch": "^0.11.12",
43
- "@withfig/autocomplete": "2.651.0",
44
- "ajv": "^8.12.0",
45
- "ansi-escapes": "^6.2.0",
46
- "ansi-styles": "^6.2.1",
47
- "chalk": "^5.3.0",
48
- "color-convert": "^2.0.1",
49
- "commander": "^11.0.0",
50
- "find-process": "^1.4.7",
51
- "toml": "^3.0.0",
52
- "wcwidth": "^1.0.1",
53
- "which": "^4.0.0",
54
- "wrap-ansi": "^8.1.0",
55
- "xterm-headless": "^5.3.0"
56
- },
57
- "devDependencies": {
58
- "@microsoft/tui-test": "^0.0.1-rc.3",
59
- "@tsconfig/node18": "^18.2.2",
60
- "@types/color-convert": "^2.0.3",
61
- "@types/jest": "^29.5.5",
62
- "@types/react": "^18.2.24",
63
- "@types/wcwidth": "^1.0.2",
64
- "@types/which": "^3.0.3",
65
- "@typescript-eslint/eslint-plugin": "^6.7.4",
66
- "@typescript-eslint/parser": "^6.7.4",
67
- "@withfig/autocomplete-types": "^1.28.0",
68
- "eslint": "^8.51.0",
69
- "eslint-config-prettier": "^9.0.0",
70
- "eslint-plugin-header": "^3.1.1",
71
- "eslint-plugin-react": "^7.33.2",
72
- "husky": "^9.0.11",
73
- "jest": "^29.7.0",
74
- "lint-staged": "^15.2.2",
75
- "prettier": "3.0.3",
76
- "ts-jest": "^29.1.1",
77
- "ts-node": "^10.9.2",
78
- "typescript": "^5.2.2"
16
+ "bin": {
17
+ "is": "bin.js",
18
+ "inshellisense": "bin.js"
79
19
  },
80
- "lint-staged": {
81
- "{,src/**/}*.{ts,tsx}": [
82
- "eslint --fix",
83
- "prettier --write"
84
- ]
20
+ "files": [
21
+ "*.md",
22
+ "LICENSE",
23
+ "bin.js"
24
+ ],
25
+ "optionalDependencies": {
26
+ "@microsoft/inshellisense-darwin-x64": "0.0.1",
27
+ "@microsoft/inshellisense-darwin-arm64": "0.0.1",
28
+ "@microsoft/inshellisense-linux-x64": "0.0.1",
29
+ "@microsoft/inshellisense-linux-arm64": "0.0.1",
30
+ "@microsoft/inshellisense-win32-x64": "0.0.1",
31
+ "@microsoft/inshellisense-win32-arm64": "0.0.1"
85
32
  }
86
- }
33
+ }
@@ -1,16 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- import os from "node:os";
4
- import { Command } from "commander";
5
- import { getSuggestions } from "../runtime/runtime.js";
6
- import { Shell } from "../utils/shell.js";
7
- const action = async (input) => {
8
- const suggestions = await getSuggestions(input, process.cwd(), os.platform() === "win32" ? Shell.Cmd : Shell.Bash);
9
- process.stdout.write(JSON.stringify(suggestions));
10
- process.exit(0);
11
- };
12
- const cmd = new Command("complete");
13
- cmd.description(`generates a completion for the provided input`);
14
- cmd.argument("<input>");
15
- cmd.action(action);
16
- export default cmd;
@@ -1,32 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- import { render, renderConfirmation } from "../ui/ui-root.js";
4
- import { Shell, supportedShells as shells, setupZshDotfiles, setupBashPreExec } from "../utils/shell.js";
5
- import { inferShell } from "../utils/shell.js";
6
- import { loadConfig } from "../utils/config.js";
7
- import log from "../utils/log.js";
8
- export const supportedShells = shells.join(", ");
9
- export const action = (program) => async (options) => {
10
- const inISTerm = process.env.ISTERM === "1";
11
- if (options.check || inISTerm) {
12
- process.stdout.write(renderConfirmation(inISTerm));
13
- return;
14
- }
15
- if (options.verbose)
16
- await log.enable();
17
- await loadConfig(program);
18
- const shell = options.shell ?? (await inferShell());
19
- if (shell == null) {
20
- program.error(`Unable to identify shell, use the -s/--shell option to provide your shell`, { exitCode: 1 });
21
- }
22
- if (!shells.map((s) => s.valueOf()).includes(shell)) {
23
- program.error(`Unsupported shell: '${shell}', supported shells: ${supportedShells}`, { exitCode: 1 });
24
- }
25
- if (shell == Shell.Zsh) {
26
- await setupZshDotfiles();
27
- }
28
- else if (shell == Shell.Bash) {
29
- await setupBashPreExec();
30
- }
31
- await render(shell, options.test ?? false);
32
- };
@@ -1,11 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- import { Command } from "commander";
4
- import { render } from "../ui/ui-uninstall.js";
5
- const action = async () => {
6
- await render();
7
- };
8
- const cmd = new Command("uninstall");
9
- cmd.description(`removes all configuration for inshellisense`);
10
- cmd.action(action);
11
- export default cmd;
package/build/index.js DELETED
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env node
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- /* eslint-disable header/header */
5
- import { Command, Option } from "commander";
6
- import complete from "./commands/complete.js";
7
- import uninstall from "./commands/uninstall.js";
8
- import { action, supportedShells } from "./commands/root.js";
9
- import { getVersion } from "./utils/version.js";
10
- const program = new Command();
11
- const hiddenOption = (flags, description) => {
12
- const option = new Option(flags, description);
13
- option.hidden = true;
14
- return option;
15
- };
16
- program
17
- .name("inshellisense")
18
- .description("IDE style command line auto complete")
19
- .version(await getVersion(), "-v, --version", "output the current version")
20
- .action(action(program))
21
- .option("-s, --shell <shell>", `shell to use for command execution, supported shells: ${supportedShells}`)
22
- .option("-c, --check", `check if shell is in an inshellisense session`)
23
- .addOption(hiddenOption("-T, --test", "used to make e2e tests reproducible across machines"))
24
- .option("-V, --verbose", `enable verbose logging`)
25
- .showHelpAfterError("(add --help for additional information)");
26
- program.addCommand(complete);
27
- program.addCommand(uninstall);
28
- program.parse();