diff --git a/.github/workflows/publish_java.yml b/.github/workflows/publish_java.yml index 7e2af139c..fbf48b2ac 100644 --- a/.github/workflows/publish_java.yml +++ b/.github/workflows/publish_java.yml @@ -39,7 +39,7 @@ on: jobs: publish-java: runs-on: ubuntu-latest - # Only run for releases tagged with dotprompt-java- prefix (per release-please config) + # Only run for releases tagged with dotprompt-java- prefix if: startsWith(github.event.release.tag_name, 'dotprompt-java-') permissions: contents: read diff --git a/.github/workflows/publish_rust.yml b/.github/workflows/publish_rust.yml index 79a9381e8..2c02944d8 100644 --- a/.github/workflows/publish_rust.yml +++ b/.github/workflows/publish_rust.yml @@ -26,7 +26,7 @@ on: jobs: publish-cargo: runs-on: ubuntu-latest - # Only run for releases tagged with dotprompt-rs- prefix (per release-please config) + # Only run for releases tagged with dotprompt-rs- prefix if: startsWith(github.event.release.tag_name, 'dotprompt-rs-') permissions: contents: read diff --git a/.release-please-config.json b/.release-please-config.json deleted file mode 100644 index 2ab8f7299..000000000 --- a/.release-please-config.json +++ /dev/null @@ -1,125 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", - "bump-minor-pre-major": true, - "bump-patch-for-minor-pre-major": true, - "draft": false, - "prerelease": false, - "include-component-in-tag": true, - "include-v-in-tag": false, - "pull-request-title-pattern": "chore(release): ${component} ${version}", - "separate-pull-requests": true, - "skip-github-release": false, - "plugins": ["node-workspace"], - "packages": { - "js": { - "release-type": "node", - "component": "dotprompt" - }, - "python/dotpromptz": { - "release-type": "python", - "package-name": "dotpromptz", - "component": "dotpromptz", - "extra-files": [ - { - "type": "toml", - "path": "pyproject.toml", - "jsonpath": "$.project.version" - }, - { - "type": "toml", - "path": "tests/smoke/pyproject.toml", - "jsonpath": "$.project.version" - } - ] - }, - "python/handlebars": { - "release-type": "python", - "package-name": "dotpromptz-handlebars", - "component": "dotpromptz-handlebars", - "extra-files": [ - { - "type": "toml", - "path": "pyproject.toml", - "jsonpath": "$.project.version" - } - ] - }, - "go": { - "release-type": "go", - "component": "dotprompt-go" - }, - "rs": { - "release-type": "rust", - "component": "dotprompt-rs", - "extra-files": [ - { - "type": "toml", - "path": "dotprompt/Cargo.toml", - "jsonpath": "$.package.version" - }, - { - "type": "toml", - "path": "smoke/Cargo.toml", - "jsonpath": "$.package.version" - } - ] - }, - "java": { - "release-type": "simple", - "component": "dotprompt-java" - }, - "dart/dotprompt": { - "release-type": "dart", - "component": "dotprompt-dart", - "extra-files": [ - { - "type": "yaml", - "path": "pubspec.yaml", - "jsonpath": "$.version" - } - ] - }, - "bazel/rules_dart": { - "release-type": "simple", - "component": "rules_dart", - "extra-files": ["MODULE.bazel", ".bcr/metadata.json"] - }, - "bazel/rules_flutter": { - "release-type": "simple", - "component": "rules_flutter", - "extra-files": ["MODULE.bazel", ".bcr/metadata.json"] - }, - "packages/vscode": { - "release-type": "node", - "component": "dotprompt-vscode" - }, - "packages/vim": { - "release-type": "simple", - "component": "dotprompt-vim" - }, - "packages/emacs": { - "release-type": "simple", - "component": "dotprompt-emacs" - }, - "packages/monaco": { - "release-type": "node", - "component": "dotprompt-monaco" - }, - "packages/codemirror": { - "release-type": "node", - "component": "dotprompt-codemirror" - }, - "packages/jetbrains": { - "release-type": "simple", - "component": "dotprompt-jetbrains" - }, - "packages/treesitter": { - "release-type": "node", - "component": "tree-sitter-dotprompt" - }, - "packages/promptly": { - "release-type": "node", - "component": "promptly" - } - } -} diff --git a/.release-please-manifest.json b/.release-please-manifest.json deleted file mode 100644 index 4ebd2576b..000000000 --- a/.release-please-manifest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "js": "0.2.9", - "python/dotpromptz": "1.0.0", - "python/handlebars": "1.0.0", - "go": "0.2.1", - "java": "0.1.0", - "dart/dotprompt": "0.0.1", - "bazel/rules_dart": "0.1.0", - "bazel/rules_flutter": "0.1.0", - "rs": "0.1.0", - "packages/vscode": "0.0.1", - "packages/vim": "0.1.0", - "packages/emacs": "0.1.0", - "packages/monaco": "0.1.0", - "packages/codemirror": "0.1.0", - "packages/jetbrains": "0.2.0", - "packages/treesitter": "0.1.0", - "packages/promptly": "0.1.0" -} diff --git a/dart/dotprompt/CHANGELOG.md b/dart/dotprompt/CHANGELOG.md index b980e3923..bb007cb59 100644 --- a/dart/dotprompt/CHANGELOG.md +++ b/dart/dotprompt/CHANGELOG.md @@ -4,6 +4,35 @@ All notable changes to dotprompt-dart will be documented in this file. ## [Unreleased] +## [2.0.1] - 2026-11-18 + +### Security + +- Markers emitted by the `role`, `history`, `section` and `media` helpers now + carry a random per-render nonce, and only markers with that nonce are + honored. Previously a value interpolated into a template (for example user + input) could contain a literal `<<>>` marker and forge + system or model turns, media parts with arbitrary URLs, history placement, or + pending section parts + ([#643](https://github.com/google/dotprompt/pull/643)). +- Media and section marker bodies match across newlines, and media URLs keep + spaces, so user-supplied values don't break the marker and leak it as text. + +### Changed + +- Literal `<<>>` markers written in templates, passed in input, + or returned by custom helpers are no longer interpreted. Use the `{{role}}`, + `{{history}}`, `{{section}}` and `{{media}}` helpers. +- Rendered output is now split by marker position instead of line by line: + several markers on one line are all honored, text after `{{history}}` on the + same line goes after the history, and output made only of markers yields no + messages. +- The marker-building and marker-parsing methods on `RoleHelper`, + `HistoryHelper`, `SectionHelper` and `MediaHelper` take the render nonce and + are annotated `@internal`; they're implementation details of `Dotprompt` + rendering, not a public API. Their `markerPrefix`, `markerSuffix`, + `containsMarker` and `extract*` members were removed. + ## [2.0.0] - 2026-10-04 Picoschema now follows the spec and behaves like the other runtimes. Schemas diff --git a/dart/dotprompt/pubspec.yaml b/dart/dotprompt/pubspec.yaml index 7df7111c0..2aa6fb5b6 100644 --- a/dart/dotprompt/pubspec.yaml +++ b/dart/dotprompt/pubspec.yaml @@ -18,7 +18,7 @@ name: dotprompt description: >- Dotprompt for Dart: parse and render .prompt files (YAML frontmatter + Handlebars templates) for Generative AI. -version: 2.0.0 +version: 2.0.1 license: Apache-2.0 homepage: https://github.com/google/dotprompt repository: https://github.com/google/dotprompt diff --git a/docs/contributing/coding_guidelines.md b/docs/contributing/coding_guidelines.md index e952db3a7..1fb82dcb2 100644 --- a/docs/contributing/coding_guidelines.md +++ b/docs/contributing/coding_guidelines.md @@ -492,8 +492,8 @@ Include the Apache 2.0 license header at the top of each file (update year as ne ## Git Commit Message Guidelines Use [Conventional Commits](https://www.conventionalcommits.org/) format with the -package name as the scope. This ensures release-please correctly attributes -commits to packages and generates accurate changelogs. +package name as the scope, so commits are attributed to the right package when +writing changelogs. ### Format @@ -522,8 +522,7 @@ commits to packages and generates accurate changelogs. ### Commit Scopes (Package Names) -**IMPORTANT**: Use the exact scope from the table below. These match the package -names in `.release-please-config.json` and are used to generate release PRs. +**IMPORTANT**: Use the exact scope from the table below. | Scope | Package/Directory | Description | |-------|-------------------|-------------| diff --git a/docs/contributing/releases.md b/docs/contributing/releases.md index 0cbfde536..42ec6df70 100644 --- a/docs/contributing/releases.md +++ b/docs/contributing/releases.md @@ -1,105 +1,34 @@ # Making Releases -This repository uses -[release-please](https://github.com/googleapis/release-please) for managing -releases across multiple packages. Release-please automates versioning and -changelog generation based on [Conventional -Commits](https://www.conventionalcommits.org/). - -## Monorepo Structure - -The repository is configured to manage releases independently for the following -packages: - -* `js/` - JavaScript implementation of dotprompt -* `python/dotpromptz/` - Python implementation of dotprompt -* `python/handlebars/` - Pure-Python Handlebars engine (`dotpromptz-handlebars`) -* `go/` - Go implementation of dotprompt -* `java/` - Java implementation of dotprompt - -## How It Works - -1. When commits are pushed to `main`, `release-please` automatically creates or - updates release PRs for each package that has changes. -2. Each package has its own release PR and will be versioned independently. -3. When a release PR is merged, `release-please` will: - * Create a new release with appropriate tags. - * Update the package version. - * Generate changelog entries. - -## Commit Message Format - -To ensure proper versioning, commit messages should follow the [Conventional -Commits](https://www.conventionalcommits.org/) format: - -``` -(): - -[optional body] - -[optional footer(s)] -``` - -### Types - -* `feat`: A new feature (triggers a minor version bump) -* `fix`: A bug fix (triggers a patch version bump) -* `docs`: Documentation changes -* `style`: Code style changes (formatting, etc.) -* `refactor`: Code changes that neither fix bugs nor add features -* `perf`: Performance improvements -* `test`: Adding or updating tests -* `build`: Changes to build system or dependencies -* `ci`: Changes to CI configuration -* `chore`: Other changes that don't modify source code -* `revert`: Reverting a previous commit - -### Scopes - -To target specific packages, use these scopes: - -* `js`: For changes to the JavaScript implementation -* `py`: For changes affecting all Python packages -* `py/dotpromptz`: For changes to the Python dotpromptz package -* `py/handlebars`: For changes to the Python Handlebars engine -* `go`: For changes to the Go implementation -* `java`: For changes to the Java implementation -* `deps`: For dependency updates - -### Examples - -``` -feat(js): add new template helper function - -fix(py/dotpromptz): resolve issue with template parsing - -docs(go): update API documentation - -build(py/handlebars): update build configuration -``` - -## Breaking Changes - -For breaking changes, add `BREAKING CHANGE:` in the commit message body or -footer: - -``` -feat(js): change API interface - -BREAKING CHANGE: The `render` method now returns a Promise instead of a string -``` - -This will trigger a major version bump for the affected package. - -## Manual Release - -If you need to manually trigger a release, you can: - -1. Create a new release PR by running the release-please GitHub Action workflow - manually -2. Or push a commit to main with the appropriate conventional commit message - -## Checking Release Status - -The `.release-please-manifest.json` file tracks the current version of each -package. +Releases are manual: each package is versioned and published on its own. Bump +the version and changelog in a PR, merge it, then publish from `main`. + +Commit messages still follow [Conventional +Commits](https://www.conventionalcommits.org/) with the package scopes listed +in `GEMINI.md`; they drive changelog entries and make it easy to see what +changed per package. + +## Choosing a version + +* `fix`: patch bump. +* `feat`: minor bump. +* Breaking change: major bump, or minor while the package is still `0.x`. + +Mind downstream ranges. For example, Genkit depends on `dotprompt ^1.x` (npm) +and `dotprompt ^2.x` (pub.dev), so a fix shipped as a new major version won't +reach existing Genkit installs. + +## Per package + +| Package | Bump | Publish | +|---------|------|---------| +| `dotprompt` (npm, `js/`) | `js/package.json` | Run the **Release JS** workflow (`releaseTag`: `latest` or `next`). It publishes the version in `js/package.json`. | +| `dotpromptz` (PyPI, `python/dotpromptz/`) | `pyproject.toml`, `CHANGELOG.md`; then `uv lock` in `python/` and `scripts/export_requirements` | Create a GitHub release tagged `dotpromptz-X.Y.Z`. `publish_python_dotpromptz_package.yml` checks the tag against `pyproject.toml` and publishes. | +| `dotpromptz-handlebars` (PyPI, `python/handlebars/`) | same as above | GitHub release tagged `dotpromptz-handlebars-X.Y.Z` (`publish_python_handlebarrz_package.yml`). | +| `dotprompt` (pub.dev, `dart/dotprompt/`) | `pubspec.yaml`, `CHANGELOG.md` | `dart pub publish` from `dart/dotprompt/`. | +| Go module (`go/`) | `CHANGELOG.md` (optional) | Not tagged; consumers use pseudo-versions (`go get github.com/google/dotprompt/go@main`). If tags are ever added they must be `go/vX.Y.Z`, and from then on `@latest` resolves to the newest tag. | +| VS Code extension | `packages/vscode/package.json` | GitHub release tagged `dotprompt-vscode-X.Y.Z` (`vscode_publish.yml`). | +| Monaco, CodeMirror, tree-sitter (npm) | the package's `package.json` | Published by `web_editors.yml` / `treesitter.yml` when a push to `main` modifies that `package.json`. | +| JetBrains plugin | `plugin.xml` | Published by `ide_plugins.yml` when a push to `main` modifies `plugin.xml`. | +| `promptly` (npm) | `rs/promptly` | Push a `promptly-vX.Y.Z` tag (`promptly-npm.yml`). | +| Rust crate, Java library | `rs/dotprompt/Cargo.toml`, `java/com/google/dotprompt/BUILD.bazel` | Not published yet. `publish_rust.yml` / `publish_java.yml` run on GitHub releases tagged `dotprompt-rs-X.Y.Z` / `dotprompt-java-X.Y.Z`. | diff --git a/java/README.md b/java/README.md index ec7a33caa..4d1252c8a 100644 --- a/java/README.md +++ b/java/README.md @@ -69,25 +69,13 @@ Configure these secrets in the repository settings (Settings → Secrets and var ## Release Process -Releases are managed by [release-please](https://github.com/googleapis/release-please). +Releases are manual (see `docs/contributing/releases.md`): -### Automated Flow - -1. **Commit changes** to `main` using conventional commit messages with the `java` scope: - ``` - feat(java): add new template helper - fix(java): resolve parsing issue - ``` - -2. **Release-please creates a PR** automatically with: - * Updated version in `BUILD.bazel` - * Generated `CHANGELOG.md` - -3. **Merge the release PR** when ready. - -4. **Publishing is automated** via `.github/workflows/publish_java.yml`: - * Triggers on release creation - * Signs and uploads to Maven Central +1. **Bump the version** in the `maven_coordinates` of `dotprompt_pkg` in + `java/com/google/dotprompt/BUILD.bazel` in a PR, and merge it. +2. **Create a GitHub release** tagged `dotprompt-java-X.Y.Z`. +3. **Publishing is automated** via `.github/workflows/publish_java.yml`, which + triggers on the release, signs and uploads to Maven Central. ### Verification diff --git a/java/com/google/dotprompt/BUILD.bazel b/java/com/google/dotprompt/BUILD.bazel index 6f7f0363d..914a595ee 100644 --- a/java/com/google/dotprompt/BUILD.bazel +++ b/java/com/google/dotprompt/BUILD.bazel @@ -44,9 +44,7 @@ java_library( java_export( name = "dotprompt_pkg", - # x-release-please-start-version maven_coordinates = "com.google.dotprompt:dotprompt:0.1.0", - # x-release-please-end pom_template = "pom_template.xml", visibility = ["//visibility:public"], runtime_deps = [":dotprompt"], diff --git a/js/package.json b/js/package.json index d0451ab32..07bd2a87a 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "dotprompt", - "version": "1.1.2", + "version": "1.1.3", "description": "Dotprompt: Executable GenAI Prompt Templates", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/python/dotpromptz/CHANGELOG.md b/python/dotpromptz/CHANGELOG.md index dc7bb83b2..bb5ca827a 100644 --- a/python/dotpromptz/CHANGELOG.md +++ b/python/dotpromptz/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [1.0.1](https://github.com/google/dotprompt/compare/dotpromptz-1.0.0...dotpromptz-1.0.1) (2026-11-18) + +### Security + +* **render:** markers emitted by the `role`, `history`, `section` and `media` helpers now carry a random per-render nonce, and only markers with that nonce are honored. Previously a value interpolated into a template (for example user input, including through `{{{x}}}` and `{{json x}}`) could contain a literal `<<>>` marker and forge system or model turns, media parts with arbitrary URLs, history placement, or pending section parts ([#642](https://github.com/google/dotprompt/pull/642)). +* **render:** media and section marker bodies match across newlines, so a user-supplied media URL or section name containing a newline stays intact instead of leaking the raw marker into the text. + +### Compatibility + +* Literal `<<>>` markers written in templates, passed in input, or returned by custom helpers are no longer interpreted. Use the `{{role}}`, `{{history}}`, `{{section}}` and `{{media}}` helpers. +* `dotpromptz.parse.to_messages`, `to_parts` and `message_sources_to_messages` take a required keyword-only `nonce`; old positional calls raise `TypeError`. Rendering through `Dotprompt` is unchanged. +* The pre-nonce marker constants (`ROLE_MARKER_PREFIX`, ...), regexes and `split_by_*` helpers stay importable from `dotpromptz.parse`, and `parse_part` / `parse_media_part` / `parse_section_part` still accept the old input forms. These legacy paths are deprecated (they emit `DeprecationWarning`) and aren't used for rendering. + ## [1.0.0](https://github.com/google/dotprompt/compare/dotpromptz-0.2.0...dotpromptz-1.0.0) (2026-11-11) ### Dependencies diff --git a/python/dotpromptz/pyproject.toml b/python/dotpromptz/pyproject.toml index 49036c6be..8ca7176dd 100644 --- a/python/dotpromptz/pyproject.toml +++ b/python/dotpromptz/pyproject.toml @@ -48,7 +48,7 @@ license = "Apache-2.0" name = "dotpromptz" readme = "README.md" requires-python = ">=3.10" -version = "1.0.0" +version = "1.0.1" [build-system] build-backend = "hatchling.build" diff --git a/python/uv.lock b/python/uv.lock index 2cc60d51a..f5941908e 100644 --- a/python/uv.lock +++ b/python/uv.lock @@ -869,7 +869,7 @@ lint = [{ name = "ruff", specifier = ">=0.9.2" }] [[package]] name = "dotpromptz" -version = "1.0.0" +version = "1.0.1" source = { editable = "dotpromptz" } dependencies = [ { name = "aiofiles" }, diff --git a/scripts/lint b/scripts/lint index a60204696..d1172ce1c 100755 --- a/scripts/lint +++ b/scripts/lint @@ -25,9 +25,6 @@ fi TOP_DIR=$(git rev-parse --show-toplevel) PY_DIR="${TOP_DIR}/python" -# Validate release-please configuration -"${TOP_DIR}/scripts/validate_release_please_config" - uv run --directory "${PY_DIR}" ruff check --select I --fix --preview --unsafe-fixes . # Static type checking with ty (Astral/Ruff) and pyrefly (Meta). diff --git a/scripts/validate_release_please_config b/scripts/validate_release_please_config deleted file mode 100755 index cd3cede3a..000000000 --- a/scripts/validate_release_please_config +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2026 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Validates .release-please-config.json against the official JSON schema. -# -# Usage: -# scripts/validate_release_please_config -# -# Requirements: -# - Node.js and npx (for ajv-cli) -# OR -# - Python 3 with jsonschema package - -set -euo pipefail - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" - -CONFIG_FILE="${REPO_ROOT}/.release-please-config.json" -SCHEMA_URL="https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json" - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -NC='\033[0m' # No Color - -echo "Validating release-please config..." -echo " Config: ${CONFIG_FILE}" -echo " Schema: ${SCHEMA_URL}" -echo "" - -# Check if config file exists -if [[ ! -f "${CONFIG_FILE}" ]]; then - echo -e "${RED}Error: Config file not found: ${CONFIG_FILE}${NC}" - exit 1 -fi - -# Try using ajv-cli (Node.js) first, then fall back to Python -validate_with_ajv() { - echo "Using ajv-cli for validation..." - - # Download schema to temp file - SCHEMA_FILE=$(mktemp) - trap "rm -f ${SCHEMA_FILE}" EXIT - - curl -sL "${SCHEMA_URL}" -o "${SCHEMA_FILE}" - - # Run ajv validation - npx ajv-cli validate -s "${SCHEMA_FILE}" -d "${CONFIG_FILE}" --strict=false -} - -validate_with_python() { - echo "Using Python jsonschema for validation..." - - python3 - "${CONFIG_FILE}" "${SCHEMA_URL}" << 'PYTHON_SCRIPT' -import json -import sys -import urllib.request - -def main(): - config_file = sys.argv[1] - schema_url = sys.argv[2] - - # Load config - with open(config_file, 'r') as f: - config = json.load(f) - - # Download schema - with urllib.request.urlopen(schema_url) as response: - schema = json.loads(response.read().decode('utf-8')) - - # Validate - try: - from jsonschema import validate, ValidationError, Draft7Validator - - # Use Draft7 validator as specified in the schema - validator = Draft7Validator(schema) - errors = list(validator.iter_errors(config)) - - if errors: - print(f"\n❌ Validation failed with {len(errors)} error(s):\n") - for i, error in enumerate(errors, 1): - path = " -> ".join(str(p) for p in error.absolute_path) or "(root)" - print(f" {i}. Path: {path}") - print(f" Error: {error.message}") - print() - sys.exit(1) - else: - print("\n✅ Config is valid!") - sys.exit(0) - - except ImportError: - print("Error: jsonschema package not installed.") - print("Install with: pip install jsonschema") - sys.exit(2) - -if __name__ == "__main__": - main() -PYTHON_SCRIPT -} - -validate_with_check_jsonschema() { - echo "Using check-jsonschema for validation..." - - # check-jsonschema can fetch the schema directly from URL - check-jsonschema --schemafile "${SCHEMA_URL}" "${CONFIG_FILE}" -} - -# Try different validation methods -if command -v check-jsonschema &> /dev/null; then - if validate_with_check_jsonschema; then - echo -e "\n${GREEN}✅ release-please config is valid!${NC}" - exit 0 - else - echo -e "\n${RED}❌ release-please config validation failed!${NC}" - exit 1 - fi -elif command -v npx &> /dev/null; then - if validate_with_ajv; then - echo -e "\n${GREEN}✅ release-please config is valid!${NC}" - exit 0 - else - echo -e "\n${RED}❌ release-please config validation failed!${NC}" - exit 1 - fi -elif command -v python3 &> /dev/null; then - if validate_with_python; then - echo -e "\n${GREEN}✅ release-please config is valid!${NC}" - exit 0 - else - echo -e "\n${RED}❌ release-please config validation failed!${NC}" - exit 1 - fi -else - echo -e "${YELLOW}Warning: No JSON schema validator found.${NC}" - echo "Install one of the following:" - echo " - check-jsonschema: pip install check-jsonschema" - echo " - ajv-cli: npm install -g ajv-cli" - echo " - jsonschema (Python): pip install jsonschema" - exit 2 -fi