AgentFlow adds first-class editor support for .af templates in VS Code.
Instead of relying on a large TextMate grammar, the extension starts the AgentFlow language server so the editor stays aligned with the real parser and tokenizer used by af gen prompts.
Powered by af lsp:
- diagnostics from the parser and
af lint, with their codes (AF001…) - Format Document with
af fmt - go to definition:
- a variable to its first typed use
- a loop alias to its loop
- a
.titleor.toolto its generated Go - a
.routequery to the sqlc method that runs it
- rename for variables and loop aliases
- hovers for variables, operators,
.toolparameters, and.routebindings, showing where each query argument comes from: path, caller, body or query string - completions for directives (section-aware), variables, types,
.paramtypes and operators - document symbols for prompts, variables, tools and routes
- semantic highlighting
From the extension:
-
a TextMate grammar for prompts, conditionals, loops,
.tool/.param,.output/.fieldand.routesections, used while semantic tokens load -
snippets for
.title,.tool,.output,.route, conditionals and loops -
commands:
- AgentFlow: Generate Go Code (
af gen prompts) - AgentFlow: Check Generated Code (
af check) - AgentFlow: Install Agent Skills (
af skills install) - AgentFlow: Eject Runtime (
af eject) - AgentFlow: Create Demo Project
- AgentFlow: Restart Language Server
They run af the way your workspace does:
go tool afwhengo.modpins it, otherwiseaf. - AgentFlow: Generate Go Code (
-
bracket matching and auto-closing for AgentFlow tags
Language servers older than af v0.13 don't lint or format. For those, the extension runs af lint --format json and af fmt itself. Upgrade af for definition, rename and the rest.
Install the AgentFlow CLI first:
go install github.com/omniaura/agentflow/cmd/af@latestIf you pin AgentFlow as a project-scoped Go tool instead, the extension detects that automatically from the workspace go.mod and switches to go tool af lsp --mode stdio when the default launch settings are still in place.
Install from the VS Code Marketplace once published, or package it locally:
- Clone
https://github.com/omniaura/agentflow-vscode - Run
bun install - Run
bun run package - In VS Code, use
Extensions: Install from VSIX... - Select the generated
.vsixfile
bun test srcruns the unit tests.AF_BIN=/path/to/af AF_WORKSPACE=/path/to/agentflow/examples/routes AF_EXPECT=modern xvfb-run -a node test/integration/runTest.jsruns the integration suite in a real VS Code. Dropxvfb-run -aon a desktop.
Releases are automated with Release Please. Merge conventional commits into main, let Release Please open the version bump PR, and merge that PR to publish a new Marketplace release.
The workflow also uploads the built .vsix to the matching GitHub release.
VS Code Marketplace publishing still requires a VSCE_PAT secret today. There is no native GitHub OIDC trusted publishing flow for vsce, so this repo uses a publisher token rather than npm-style trusted publishing.
The extension starts the AgentFlow language server with these defaults:
agentflow.languageServer.command:afagentflow.languageServer.args:['lsp', '--mode', 'stdio']
When those defaults are unchanged, the extension checks the active workspace's go.mod. If it finds the AgentFlow tool directive, it automatically switches to:
agentflow.languageServer.command:goagentflow.languageServer.args:['tool', 'af', 'lsp', '--mode', 'stdio']
If you set custom command or args values yourself, the extension respects them and skips auto-detection.
You can also enable client tracing with agentflow.languageServer.trace.server.
Use VS Code's Format Document command in .af files. The language server formats with the same code as af fmt. With servers older than af v0.13, the extension runs af fmt itself instead, and writes formatter errors to the AgentFlow output channel without modifying the open document.
The language server publishes parser and af lint diagnostics, with their codes, as you edit. With servers older than af v0.13, the extension runs af lint --format json itself on open, save and debounced edits instead.
Run AgentFlow: Create Demo Project from the command palette to select an empty folder and scaffold a runnable demo project. The extension shells out to af demo init <selected-folder>, so the AgentFlow CLI remains the single source of truth for emitted demo files.
After the folder opens, run:
af gen prompts --dir prompts
go run .AgentFlow templates support:
- titles with
.title Prompt Name - variables such as
<!user.name> - typed variables such as
<!count int>and<!enabled bool> - conditional blocks such as
<?user.premium>...</user.premium> - optional
<else>branches - comparison operators:
eq,ne,gt,lt,gte,lte
Example:
.title Review Summary
Hello <!user.name>
<?score gte 90>
Ship it.
<else>
Needs another pass.
</score>
bun install
bun run compile
bun run packageTo test locally, press F5 in VS Code to launch an Extension Development Host.
Issues and pull requests are welcome at https://github.com/omniaura/agentflow-vscode.
MIT. See LICENSE.