Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/release-baml-language.yml
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,13 @@ jobs:
if [[ "$vsix" != "$dest" ]]; then
mv "$vsix" "$dest"
fi
- name: Reject bundled native binaries
- name: Validate VSIX contents
run: |
set -euo pipefail
vsix="typescript2/app-vscode-ext/baml-language-${{ needs.plan.outputs.version }}.vsix"
unzip -l "$vsix" | tee vsix-list.txt
unzip -Z1 "$vsix" | tee vsix-list.txt
grep -Fxq 'extension/readme.md' vsix-list.txt
grep -Fxq 'extension/baml-logo.png' vsix-list.txt
! grep -E 'dist/baml-cli|baml-cli|baml-pack-host' vsix-list.txt
- uses: actions/upload-artifact@v4
with:
Expand Down
18 changes: 16 additions & 2 deletions scripts/baml-language-version
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,20 @@ def replace_regex(path: Path, pattern: str, replacement: str) -> None:
path.write_text(new_text, encoding="utf-8")


def replace_json_version(path: Path, version: str) -> None:
text = path.read_text(encoding="utf-8")
new_text, count = re.subn(
r'^(\s*"version"\s*:\s*)"[^"]*"(?P<comma>,?)$',
lambda match: f'{match.group(1)}"{version}"{match.group("comma")}',
text,
count=1,
flags=re.MULTILINE,
)
if count != 1:
fail(f"could not update expected version surface in {path.relative_to(ROOT)}")
path.write_text(new_text, encoding="utf-8")


def stamp(plan: ReleasePlan) -> None:
BAML_VERSION_RS.parent.mkdir(parents=True, exist_ok=True)
BAML_VERSION_RS.write_text(
Expand Down Expand Up @@ -647,10 +661,10 @@ def stamp(plan: ReleasePlan) -> None:
r'^version = ".*"$',
f'version = "{plan.crates_io_version}"',
)
replace_regex(VSIX_PACKAGE, r'^ "version": ".*",$', f' "version": "{plan.canonical_version}",')
replace_json_version(VSIX_PACKAGE, plan.canonical_version)
for package in NPM_PACKAGES:
if package.exists():
replace_regex(package, r'^ "version": ".*",$', f' "version": "{plan.canonical_version}",')
replace_json_version(package, plan.canonical_version)
replace_regex(
GO_RUNTIME_VERSION,
r'^const DefaultRuntimeVersion = ".*"$',
Expand Down
23 changes: 22 additions & 1 deletion scripts/tests/test_baml_language_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def make_fixture(self, version: str) -> None:
):
self.write(
package,
json.dumps({"version": version, "name": "fixture"}, indent=2)
json.dumps({"name": "fixture", "version": version}, indent=2)
+ "\n",
)
self.write(
Expand Down Expand Up @@ -265,6 +265,27 @@ def test_prerelease_plan_and_stamp_cover_every_shipping_sdk(self) -> None:
self.run_tool("check")
self.assertEqual(set(self.surface_versions().values()), {"1.2.3"})

def test_replace_json_version_preserves_optional_comma(self) -> None:
package = self.write(
"package.json",
'{\n "name": "fixture",\n "version": "1.2.3",\n "private": true\n}\n',
)
version_tool_module().replace_json_version(package, "2.3.4")
self.assertEqual(
package.read_text(encoding="utf-8"),
'{\n "name": "fixture",\n "version": "2.3.4",\n "private": true\n}\n',
)

package.write_text(
'{\n "name": "fixture",\n "version": "1.2.3"\n}\n',
encoding="utf-8",
)
version_tool_module().replace_json_version(package, "2.3.4")
self.assertEqual(
package.read_text(encoding="utf-8"),
'{\n "name": "fixture",\n "version": "2.3.4"\n}\n',
)

def test_exact_named_field_checks_reject_loose_version_text(self) -> None:
rust_version = (
self.root
Expand Down
32 changes: 32 additions & 0 deletions typescript2/app-vscode-ext/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# BAML

BAML language support for Visual Studio Code and Cursor, including syntax
highlighting, hover information, completions, diagnostics, go-to-definition,
and the BAML playground.

## Installation

This extension is distributed with the BAML toolchain and installed from the
command line using `baml ide install`. Its version is matched to the active
BAML toolchain.

## Updating

If your machine's active toolchain tracks the `canary` or `nightly` channel,
update the toolchain and reinstall its matching extension:

```bash
# Visual Studio Code
baml toolchain update && baml ide install --code

# Cursor
baml toolchain update && baml ide install --cursor
```

An exact-version toolchain does not advance automatically. Select or install
the newer toolchain first, then run the appropriate `baml ide install` command
again.

## Documentation

See the [BAML quickstart](https://boundaryml.com/quickstart).
Binary file added typescript2/app-vscode-ext/baml-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
157 changes: 87 additions & 70 deletions typescript2/app-vscode-ext/package.json
Original file line number Diff line number Diff line change
@@ -1,114 +1,131 @@
{
"name": "baml-language",
"displayName": "BAML",
"description": "BAML language support — syntax highlighting, hover, completions, diagnostics, go-to-definition",
"version": "0.15.0",
"publisher": "Boundary",
"private": true,
"type": "commonjs",
"engines": {
"vscode": ">=1.63.0"
},
"categories": [
"Programming Languages"
],
"main": "./dist/extension.js",
"activationEvents": [
"onLanguage:baml"
],
"categories": [
"Programming Languages"
],
"contributes": {
"languages": [
{
"id": "baml",
"aliases": ["BAML", "baml"],
"extensions": [".baml"],
"configuration": "./language-configuration.json"
}
],
"grammars": [
{
"language": "baml",
"scopeName": "source.baml",
"path": "./syntaxes/baml.tmLanguage.json"
}
],
"configurationDefaults": {
"[baml]": {
"editor.semanticHighlighting.enabled": true
},
"editor.semanticTokenColorCustomizations": {
"rules": {
"namespace:baml": "#808080CC"
}
}
},
"commands": [
{
"category": "BAML",
"command": "baml.openPlayground",
"title": "Open Playground",
"category": "BAML"
"title": "Open Playground"
},
{
"category": "BAML",
"command": "baml.openLogs",
"title": "Open Logs",
"category": "BAML"
"title": "Open Logs"
},
{
"category": "BAML",
"command": "baml.restartLanguageServer",
"title": "Restart Language Server",
"category": "BAML"
"title": "Restart Language Server"
},
{
"category": "BAML",
"command": "baml.stopLanguageServer",
"title": "Stop Language Server",
"category": "BAML"
"title": "Stop Language Server"
},
{
"category": "BAML",
"command": "baml.startLanguageServer",
"title": "Start Language Server",
"category": "BAML"
"title": "Start Language Server"
}
],
"configuration": {
"type": "object",
"title": "BAML",
"properties": {
"baml.cliPath": {
"type": ["string", "null"],
"default": null,
"description": "Path to the baml wrapper. If not set, uses 'baml' on PATH.",
"scope": "machine-overridable"
"scope": "machine-overridable",
"type": [
"string",
"null"
]
},
"baml.trace.server": {
"scope": "window",
"type": "string",
"enum": ["off", "messages", "verbose"],
"default": "off",
"description": "Logging level between the VS Code extension and the language server."
"description": "Logging level between the VS Code extension and the language server.",
"enum": [
"off",
"messages",
"verbose"
],
"scope": "window",
"type": "string"
}
},
"title": "BAML",
"type": "object"
},
"configurationDefaults": {
"[baml]": {
"editor.semanticHighlighting.enabled": true
},
"editor.semanticTokenColorCustomizations": {
"rules": {
"namespace:baml": "#808080CC"
}
}
}
},
"scripts": {
"sync:grammar": "pnpm --filter @b/pkg-grammar build",
"predev": "pnpm run sync:grammar",
"dev": "tsup --watch --sourcemap",
"prebuild": "pnpm run sync:grammar",
"build": "pnpm run typecheck && tsup",
"build:cli": "cargo build -p baml_cli --manifest-path ../../baml_language/Cargo.toml",
"typecheck": "tsc --noEmit",
"test": "vitest",
"test:run": "vitest run"
},
"grammars": [
{
"language": "baml",
"path": "./syntaxes/baml.tmLanguage.json",
"scopeName": "source.baml"
}
],
"languages": [
{
"aliases": [
"BAML",
"baml"
],
"configuration": "./language-configuration.json",
"extensions": [
".baml"
],
"icon": {
"dark": "./baml-logo.png",
"light": "./baml-logo.png"
},
"id": "baml"
}
]
},
"dependencies": {
"vscode-languageclient": "^9.0.0"
},
"description": "BAML, the Programming Language for AI.",
"devDependencies": {
"@b/pkg-grammar": "workspace:*",
"@types/node": "^22.0.0",
"@types/vscode": "^1.63.0",
"tsup": "^8.0.0",
"typescript": "^5.7.0",
"vitest": "^4.0.16"
}
},
"displayName": "BAML",
"engines": {
"vscode": ">=1.63.0"
},
"icon": "baml-logo.png",
"main": "./dist/extension.js",
"name": "baml-language",
"private": true,
"publisher": "Boundary",
"scripts": {
"build": "pnpm run typecheck && tsup",
"build:cli": "cargo build -p baml_cli --manifest-path ../../baml_language/Cargo.toml",
"dev": "tsup --watch --sourcemap",
"prebuild": "pnpm run sync:grammar",
"predev": "pnpm run sync:grammar",
"sync:grammar": "pnpm --filter @b/pkg-grammar build",
"test": "vitest",
"test:run": "vitest run",
"typecheck": "tsc --noEmit"
},
"type": "commonjs",
"version": "0.15.0"
}
Loading