pokey / command-server

Secure VSCode communication channel designed for voice coding
MIT License
16 stars 9 forks source link
voice vscode vscode-extension

command-server README

Adds support for running arbitrary commands via file-based RPC. Designed for use with voice-control systems such as Talon.

Features

On startup, creates a directory in the default tmp directory, called vscode-command-server-${userName}, where ${userName} is the username. Then waits for the command-server.runCommand command to be issued, which will trigger the command server to read the request.json file in the communication directory, execute the command requested there, and write the response to response.json. Note that we write the JSON response on a single line, with a trailing newline, so that the client can repeatedly try to read the file until it finds a final newline to indicate that the write is complete.

Note that the command server will refuse to execute a command if the request file is older than 3 seconds.

Requests look as follows:

{
  "commandId": "some-command-id",
  "args": ["some-argument"]
}

See Request and Response types for supported request / response parameters.

Upon receiving the above, this extension would run the command some-command-id with argument "some-argument".

If you'd like the server to wait for the command to finish before responding, pass waitForFinish=true.

If you'd like the server to wait for the command to finish and then respond with the command return value encoded as JSON, pass expectResponse=true.

Python example

Have a look at talon-vscode-command-client.

Commands

Contributes the following commands:

Keyboard shortcuts

Key Command
Ctrl/Cmd + Shift + F17 Run command

Configuration

Contributes the following settings:

command-server.allowList

Allows user to specify the allowed commands using glob syntax, eg:

{
  "command-server.allowList": ["workbench.*"]
}

Defaults to ["*"] (allows everything).

command-server.denyList

Allows user to specify the denied commands using glob syntax, eg:

{
  "command-server.denyList": ["workbench.*"]
}

Defaults to [] (doesn't deny anything).

Troubleshooting

Known issues

Change Log

See CHANGELOG.md.