Skip to content

Actions

Actions are typed async functions that send a request to the IDE host and return a Promise with the result. They use bridge.request() internally and work identically in VS Code and JetBrains.

import {
listProjectFiles,
runCommand,
notify,
readProjectFile,
writeProjectFile,
runScript,
} from '@unextension/bridge'

Returns a list of file paths in the current project, relative to the project root.

const files = await listProjectFiles()
// ['src/index.ts', 'src/main.css', 'package.json', ...]
const tsFiles = await listProjectFiles({ pattern: '**/*.ts' })
// ['src/index.ts', 'src/routes/panel.tsx', ...]
OptionTypeDefaultDescription
patternstring'**/*'Glob pattern to filter files

The following directories are always excluded: node_modules, .git, .idea, .gradle, build, out, dist.

Promise<string[]> — array of relative file paths.


Runs a shell command on the IDE host machine and returns its output.

const result = await runCommand('git status')
console.log(result.stdout) // 'On branch main...'
console.log(result.exitCode) // 0
// Use a specific shell
const result2 = await runCommand('Get-Date', { shell: 'powershell' })
ParameterTypeDescription
commandstringThe shell command to execute
optionsRunCommandOptionsOptional shell configuration
OptionTypeDefaultDescription
shellShell'cmd' on Windows, 'sh' on UnixShell to use

'cmd' · 'powershell' · 'bash' · 'sh' · 'zsh' · 'fish'

Promise<RunCommandResult>

FieldTypeDescription
stdoutstringStandard output
stderrstringStandard error
exitCodenumberProcess exit code

Shows a native IDE notification.

await notify('Build complete!')
await notify('File not found', 'warning')
await notify('Compilation failed', 'error')
ParameterTypeDefaultDescription
messagestringThe notification text
levelNotifyLevel'info'Severity level

'info' · 'warning' · 'error'

Promise<void>


Reads the content of a file relative to the project root.

const result = await readProjectFile('package.json')
const pkg = JSON.parse(result.content)
console.log(pkg.name)
ParameterTypeDescription
pathstringFile path relative to the project root

Promise<ReadProjectFileResult>

FieldTypeDescription
contentstringFile content as a UTF-8 string
encoding'utf8'Always 'utf8'

Writes content to a file relative to the project root. Creates the file and any missing parent directories if they don’t exist.

await writeProjectFile('src/generated/routes.ts', generatedCode)
await writeProjectFile('notes.txt', 'Hello from the extension!')
ParameterTypeDescription
pathstringFile path relative to the project root
contentstringUTF-8 string content to write

Promise<WriteProjectFileResult>

FieldTypeDescription
successbooleanWhether the write succeeded

Runs a Node.js script from the extension’s scripts/ folder on the IDE host machine. The script has full access to the host filesystem and any installed Node.js modules.

const result = await runScript('hello', { from: 'my-view' })
console.log(result.result) // whatever the script returned as JSON
console.log(result.exitCode) // 0
ParameterTypeDescription
namestringScript filename without .js extension
payloadunknownOptional data passed to the script

Promise<RunScriptResult>

FieldTypeDescription
resultunknownParsed JSON output from the script’s stdout
exitCodenumberProcess exit code
stderrstringStandard error output

See Scripts for how to create and bundle scripts.


See the AGENTS.md checklist for the full steps to add a new action across the bridge, VS Code target, JetBrains target, and KitchenSink test component.