diff --git a/.github/workflows/release-baml-language.yml b/.github/workflows/release-baml-language.yml index 5723fe7485c..4dc6c00483d 100644 --- a/.github/workflows/release-baml-language.yml +++ b/.github/workflows/release-baml-language.yml @@ -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: diff --git a/scripts/baml-language-version b/scripts/baml-language-version index 1595176c834..dce4cf5716f 100755 --- a/scripts/baml-language-version +++ b/scripts/baml-language-version @@ -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,?)$', + 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( @@ -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 = ".*"$', diff --git a/scripts/tests/test_baml_language_version.py b/scripts/tests/test_baml_language_version.py index 06cf2d83a49..274f0b67cc7 100644 --- a/scripts/tests/test_baml_language_version.py +++ b/scripts/tests/test_baml_language_version.py @@ -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( @@ -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 diff --git a/typescript2/app-vscode-ext/README.md b/typescript2/app-vscode-ext/README.md new file mode 100644 index 00000000000..895168548a7 --- /dev/null +++ b/typescript2/app-vscode-ext/README.md @@ -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). diff --git a/typescript2/app-vscode-ext/baml-logo.png b/typescript2/app-vscode-ext/baml-logo.png new file mode 100644 index 00000000000..ed480f93bde Binary files /dev/null and b/typescript2/app-vscode-ext/baml-logo.png differ diff --git a/typescript2/app-vscode-ext/package.json b/typescript2/app-vscode-ext/package.json index 29af3c1c826..4c55529115b 100644 --- a/typescript2/app-vscode-ext/package.json +++ b/typescript2/app-vscode-ext/package.json @@ -1,108 +1,103 @@ { - "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", @@ -110,5 +105,27 @@ "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" }