diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d072f8c8..84c1f5d13 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -330,6 +330,16 @@ jobs: cd ui/goose-acp-client pnpm run lint + gdk-release-config-check: + name: Check GDK Release Configuration + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Check GDK crate membership and publication order + run: python3 crates/goose-sdk/scripts/gdk-release.py check-config + gdk-api-docs-check: name: Check GDK API Reference is Up-to-Date runs-on: ubuntu-latest diff --git a/.github/workflows/gdk-release-pr.yml b/.github/workflows/gdk-release-pr.yml new file mode 100644 index 000000000..76217007a --- /dev/null +++ b/.github/workflows/gdk-release-pr.yml @@ -0,0 +1,79 @@ +name: Prepare GDK release + +on: + push: + branches: + - main + - gdk-release-plz # Temporary: remove after validating this workflow + paths: + # BEGIN GDK CRATE PATHS + - "crates/goose-provider-types/**" + - "crates/goose-sdk-types/**" + - "crates/goose-download-manager/**" + - "crates/goose-local-inference/**" + - "crates/goose-providers/**" + - "crates/goose-agent/**" + - "crates/goose-context-management/**" + - "crates/goose-sdk/**" + # END GDK CRATE PATHS + - "release-plz.toml" + - "Cargo.lock" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: gdk-release-pr + cancel-in-progress: false + +jobs: + release-pr: + name: Create or update GDK release PR + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - name: Checkout code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + + - name: Activate Hermit + uses: cashapp/activate-hermit@cea9af7913204a965fd488637a8d1811bba2e616 # v1 + + - name: Create or update release PR + id: release-plz + uses: release-plz/action@b5543c19b03be9bd48852d20ca89f478b7723260 # v0.5.132 + with: + command: release-pr + config: release-plz.toml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Synchronize GDK release artifacts + if: steps.release-plz.outputs.prs_created == 'true' + env: + RELEASE_PR: ${{ steps.release-plz.outputs.pr }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + branch=$(jq -r '.head_branch' <<< "$RELEASE_PR") + git fetch origin "$branch" + git switch "$branch" + just --justfile crates/goose-sdk/justfile sync-release-artifacts + if git diff --quiet; then + exit 0 + fi + git add \ + crates/goose-sdk/python/pyproject.toml \ + documentation/src/data/gdk-api.json + git commit -m "chore: synchronize GDK release artifacts" + git push origin HEAD:"$branch" + + - name: Validate package versions + if: steps.release-plz.outputs.prs_created == 'true' + run: | + version=$(cargo metadata --no-deps --format-version 1 | jq -r \ + '.packages[] | select(.name == "goose-sdk") | .version') + just --justfile crates/goose-sdk/justfile check-version "$version" diff --git a/.github/workflows/gdk-release.yml b/.github/workflows/gdk-release.yml index 29af8b3de..c0fad09f4 100644 --- a/.github/workflows/gdk-release.yml +++ b/.github/workflows/gdk-release.yml @@ -4,18 +4,11 @@ on: push: tags: - "gdk-v*" - workflow_dispatch: - inputs: - version: - description: GDK version to publish (for example, 0.1.0-alpha.6) - required: true - type: string - permissions: contents: read concurrency: - group: gdk-release-${{ github.event_name == 'workflow_dispatch' && format('gdk-v{0}', inputs.version) || github.ref_name }} + group: gdk-release-${{ github.ref_name }} cancel-in-progress: false jobs: @@ -31,9 +24,7 @@ jobs: - name: Resolve release version id: version shell: bash - env: - INPUT_VERSION: ${{ inputs.version }} - run: echo "value=${INPUT_VERSION:-${GITHUB_REF_NAME#gdk-v}}" >> "$GITHUB_OUTPUT" + run: echo "value=${GITHUB_REF_NAME#gdk-v}" >> "$GITHUB_OUTPUT" - name: Install just uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4 diff --git a/crates/goose-sdk/justfile b/crates/goose-sdk/justfile index 10d998ac4..7f11adba5 100644 --- a/crates/goose-sdk/justfile +++ b/crates/goose-sdk/justfile @@ -100,15 +100,7 @@ crates-publish dry_run="true": fi; \ version=$(cargo metadata --no-deps --format-version 1 | python3 -c \ 'import json, sys; print(next(package["version"] for package in json.load(sys.stdin)["packages"] if package["name"] == "goose-sdk"))'); \ - for crate in \ - goose-provider-types \ - goose-sdk-types \ - goose-download-manager \ - goose-local-inference \ - goose-providers \ - goose-agent \ - goose-context-management \ - goose-sdk; do \ + while IFS= read -r crate; do \ if [ "{{dry_run}}" = "false" ]; then \ status=$(curl --silent --output /dev/null --write-out '%{http_code}' \ --user-agent 'goose-gdk-release (https://github.com/aaif-goose/goose)' \ @@ -134,141 +126,43 @@ crates-publish dry_run="true": sleep 10; \ done; \ fi; \ - done + done < <(python3 crates/goose-sdk/scripts/gdk-release.py crates) + +sync-release-artifacts: sync-package-versions + python3 documentation/automation/gdk-api/generate.py + +sync-package-versions: + #!/usr/bin/env bash + set -euo pipefail + python3 <<'PY' + import re + from pathlib import Path + + cargo_toml = Path("crates/goose-sdk/Cargo.toml").read_text() + rust_version = re.search(r'(?m)^version\s*=\s*"([^"]+)"', cargo_toml).group(1) + match = re.fullmatch(r"(\d+)\.(\d+)\.(\d+)(?:-alpha\.(\d+))?", rust_version) + if not match: + raise SystemExit(f"unsupported GDK version: {rust_version}") + + major, minor, patch, alpha = match.groups() + python_version = f"{major}.{minor}.{patch}" if alpha is None else f"{major}.{minor}.{patch}a{alpha}" + pyproject = Path("crates/goose-sdk/python/pyproject.toml") + text = pyproject.read_text() + updated, count = re.subn( + r'(?m)^(\[project\]\nname\s*=\s*"goose-sdk"\nversion\s*=\s*)"[^"]+"', + rf'\1"{python_version}"', + text, + count=1, + ) + if count != 1: + raise SystemExit(f"could not update [project] version in {pyproject}") + pyproject.write_text(updated) + print(f"Python package: {python_version}") + print(f"Maven artifact: {rust_version} (derived from goose-sdk/Cargo.toml)") + PY + +check-release-config: + python3 crates/goose-sdk/scripts/gdk-release.py check-config check-version rust_version: - #!/usr/bin/env bash - set -euo pipefail - python3 - "{{rust_version}}" <<'PY' - import re - import sys - from pathlib import Path - - rust_version = sys.argv[1] - match = re.fullmatch(r"(\d+)\.(\d+)\.(\d+)(?:-alpha\.(\d+))?", rust_version) - if not match: - raise SystemExit("version must look like 0.1.0 or 0.1.0-alpha.0") - - major, minor, patch, alpha = match.groups() - python_version = f"{major}.{minor}.{patch}" if alpha is None else f"{major}.{minor}.{patch}a{alpha}" - crate_names = [ - "goose-provider-types", - "goose-sdk-types", - "goose-download-manager", - "goose-local-inference", - "goose-providers", - "goose-agent", - "goose-context-management", - "goose-sdk", - ] - - def package_version(path: Path, section: str) -> str: - text = path.read_text() - section_match = re.search(rf"(?ms)^\[{re.escape(section)}\]\s*$(.*?)(?=^\[|\Z)", text) - if not section_match: - raise SystemExit(f"missing [{section}] in {path}") - version_match = re.search(r'^version\s*=\s*"([^"]+)"', section_match.group(1), re.MULTILINE) - if not version_match: - raise SystemExit(f"missing version in [{section}] in {path}") - return version_match.group(1) - - errors = [] - dependency_names = set(crate_names) - {"goose-sdk"} - for crate in crate_names: - path = Path("crates") / crate / "Cargo.toml" - text = path.read_text() - actual = package_version(path, "package") - if actual != rust_version: - errors.append(f"{path}: expected {rust_version}, found {actual}") - - for dependency in dependency_names: - for dependency_match in re.finditer( - rf'(?m)^{re.escape(dependency)}\s*=\s*' + re.escape("{") + r'([^}]*)' + re.escape("}"), text - ): - version_match = re.search(r'version\s*=\s*"([^"]+)"', dependency_match.group(1)) - if not version_match: - errors.append(f"{path}: {dependency} is missing a version requirement") - elif version_match.group(1) != rust_version: - errors.append( - f"{path}: {dependency} expected {rust_version}, " - f"found {version_match.group(1)}" - ) - - pyproject = Path("crates/goose-sdk/python/pyproject.toml") - actual_python = package_version(pyproject, "project") - if actual_python != python_version: - errors.append(f"{pyproject}: expected {python_version}, found {actual_python}") - - if errors: - raise SystemExit("\n".join(errors)) - - print(f"Validated Rust/Maven version {rust_version} and Python version {python_version}") - PY - -bump-version rust_version: - #!/usr/bin/env bash - set -euo pipefail - python3 - "{{rust_version}}" <<'PY' - import re - import sys - from pathlib import Path - - rust_version = sys.argv[1] - match = re.fullmatch(r"(\d+)\.(\d+)\.(\d+)(?:-alpha\.(\d+))?", rust_version) - if not match: - raise SystemExit("rust_version must look like 0.1.0 or 0.1.0-alpha.0") - - major, minor, patch, alpha = match.groups() - python_version = f"{major}.{minor}.{patch}" if alpha is None else f"{major}.{minor}.{patch}a{alpha}" - - crate_names = [ - "goose-provider-types", - "goose-sdk-types", - "goose-download-manager", - "goose-local-inference", - "goose-providers", - "goose-agent", - "goose-context-management", - "goose-sdk", - ] - crate_paths = {name: Path("crates") / name / "Cargo.toml" for name in crate_names} - - def replace_unique(path: Path, pattern: str, replacement: str) -> None: - text = path.read_text() - new_text, count = re.subn(pattern, replacement, text, count=1, flags=re.MULTILINE) - if count != 1: - raise SystemExit(f"expected one match for {pattern!r} in {path}") - path.write_text(new_text) - - for path in crate_paths.values(): - replace_unique(path, r'^version\s*=\s*"[^"]+"', f'version = "{rust_version}"') - - dependency_names = [ - "goose-provider-types", - "goose-sdk-types", - "goose-download-manager", - "goose-local-inference", - "goose-providers", - "goose-agent", - "goose-context-management", - ] - for path in crate_paths.values(): - text = path.read_text() - for dependency in dependency_names: - text = re.sub( - rf'({re.escape(dependency)}\s*=\s*[^\n]*version\s*=\s*)"[^"]+"', - rf'\1"{rust_version}"', - text, - ) - path.write_text(text) - - pyproject = Path("crates/goose-sdk/python/pyproject.toml") - replace_unique(pyproject, r'^version\s*=\s*"[^"]+"', f'version = "{python_version}"') - - print(f"Rust crates: {rust_version}") - print(f"Python package: {python_version}") - print(f"Maven artifact: {rust_version}") - PY - cargo update --workspace - cargo fmt --all - python3 documentation/automation/gdk-api/generate.py + python3 crates/goose-sdk/scripts/gdk-release.py check-version "{{rust_version}}" diff --git a/crates/goose-sdk/scripts/gdk-release.py b/crates/goose-sdk/scripts/gdk-release.py new file mode 100644 index 000000000..a9083aade --- /dev/null +++ b/crates/goose-sdk/scripts/gdk-release.py @@ -0,0 +1,156 @@ +#!/usr/bin/env python3 + +import argparse +import json +import re +import subprocess +import sys +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[3] +CONFIG = ROOT / "release-plz.toml" +SDK = "goose-sdk" + + +def gdk_crates() -> list[str]: + text = CONFIG.read_text() + package_sections = re.findall(r"(?ms)^\[\[package\]\]\s*$(.*?)(?=^\[|\Z)", text) + crates = [] + for section in package_sections: + name = re.search(r'^name\s*=\s*"([^"]+)"', section, re.MULTILINE) + release = re.search(r"^release\s*=\s*true\s*$", section, re.MULTILINE) + group = re.search(r'^version_group\s*=\s*"gdk"\s*$', section, re.MULTILINE) + if name and release and group: + crates.append(name.group(1)) + if not crates: + raise SystemExit("release-plz.toml does not define any GDK crates") + if len(crates) != len(set(crates)): + raise SystemExit("release-plz.toml contains duplicate GDK crates") + if SDK not in crates: + raise SystemExit(f"release-plz.toml GDK group must contain {SDK}") + return crates + + +def metadata() -> dict: + result = subprocess.run( + ["cargo", "metadata", "--no-deps", "--format-version", "1"], + cwd=ROOT, + check=True, + capture_output=True, + text=True, + ) + return json.loads(result.stdout) + + +def package_version(path: Path, section: str) -> str: + text = path.read_text() + section_match = re.search(rf"(?ms)^\[{re.escape(section)}\]\s*$(.*?)(?=^\[|\Z)", text) + if not section_match: + raise SystemExit(f"missing [{section}] in {path.relative_to(ROOT)}") + version_match = re.search(r'^version\s*=\s*"([^"]+)"', section_match.group(1), re.MULTILINE) + if not version_match: + raise SystemExit(f"missing version in [{section}] in {path.relative_to(ROOT)}") + return version_match.group(1) + + +def python_version(rust_version: str) -> str: + match = re.fullmatch(r"(\d+)\.(\d+)\.(\d+)(?:-alpha\.(\d+))?", rust_version) + if not match: + raise SystemExit("version must look like 0.1.0 or 0.1.0-alpha.0") + major, minor, patch, alpha = match.groups() + return f"{major}.{minor}.{patch}" if alpha is None else f"{major}.{minor}.{patch}a{alpha}" + + +def check_config() -> None: + crates = gdk_crates() + packages = {package["name"]: package for package in metadata()["packages"]} + errors = [] + for crate in crates: + if crate not in packages: + errors.append(f"release-plz.toml GDK crate is not a workspace package: {crate}") + + workflow = ROOT / ".github/workflows/gdk-release-pr.yml" + workflow_text = workflow.read_text() + begin_marker = " # BEGIN GDK CRATE PATHS\n" + end_marker = " # END GDK CRATE PATHS\n" + if workflow_text.count(begin_marker) != 1 or workflow_text.count(end_marker) != 1: + errors.append(f"{workflow.relative_to(ROOT)} must contain one GDK crate paths marker block") + else: + path_block = workflow_text.split(begin_marker, 1)[1].split(end_marker, 1)[0] + expected_block = "".join(f' - "crates/{crate}/**"\n' for crate in crates) + if path_block != expected_block: + errors.append( + f"{workflow.relative_to(ROOT)} GDK crate paths do not match release-plz.toml" + ) + + positions = {crate: index for index, crate in enumerate(crates)} + for crate in crates: + package = packages.get(crate) + if not package: + continue + for dependency in package["dependencies"]: + dependency_name = dependency["name"] + if dependency_name in positions and positions[dependency_name] >= positions[crate]: + errors.append( + f"release-plz.toml must list {dependency_name} before dependent crate {crate}" + ) + + if errors: + raise SystemExit("\n".join(errors)) + print(f"Validated {len(crates)} GDK crates and their publication order") + + +def check_version(rust_version: str) -> None: + crates = gdk_crates() + expected_python = python_version(rust_version) + errors = [] + dependency_names = set(crates) - {SDK} + for crate in crates: + path = ROOT / "crates" / crate / "Cargo.toml" + text = path.read_text() + actual = package_version(path, "package") + if actual != rust_version: + errors.append(f"{path.relative_to(ROOT)}: expected {rust_version}, found {actual}") + for dependency in dependency_names: + for match in re.finditer( + rf"(?m)^{re.escape(dependency)}\s*=\s*\{{([^}}]*)\}}", text + ): + version_match = re.search(r'version\s*=\s*"([^"]+)"', match.group(1)) + if not version_match: + errors.append(f"{path.relative_to(ROOT)}: {dependency} is missing a version requirement") + elif version_match.group(1) != rust_version: + errors.append( + f"{path.relative_to(ROOT)}: {dependency} expected {rust_version}, " + f"found {version_match.group(1)}" + ) + + pyproject = ROOT / "crates/goose-sdk/python/pyproject.toml" + actual_python = package_version(pyproject, "project") + if actual_python != expected_python: + errors.append( + f"{pyproject.relative_to(ROOT)}: expected {expected_python}, found {actual_python}" + ) + if errors: + raise SystemExit("\n".join(errors)) + print(f"Validated Rust/Maven version {rust_version} and Python version {expected_python}") + + +def main() -> None: + parser = argparse.ArgumentParser() + subparsers = parser.add_subparsers(dest="command", required=True) + subparsers.add_parser("crates") + subparsers.add_parser("check-config") + check = subparsers.add_parser("check-version") + check.add_argument("version") + args = parser.parse_args() + + if args.command == "crates": + print("\n".join(gdk_crates())) + elif args.command == "check-config": + check_config() + elif args.command == "check-version": + check_version(args.version) + + +if __name__ == "__main__": + main() diff --git a/documentation/.goose/memory/prompt_library_conversion.txt b/documentation/.goose/memory/prompt_library_conversion.txt deleted file mode 100644 index d3914fe22..000000000 --- a/documentation/.goose/memory/prompt_library_conversion.txt +++ /dev/null @@ -1,37 +0,0 @@ -# prompt-library conversion format-update documentation -Converted prompt library files from old format to new format for the following directories: -1. data/ - - incident-analysis.json - - name-column-split.json -2. design/ - - figma-to-code.json -3. legal/ - - regulatory-comparison.json -4. marketing/ - - budget-review.json - - retail-market-monitor.json -5. operations/ - - delivery-tracking-automation.json - - form-review-automation.json - - make-phone-call.json -6. sales/ - - product-region-availability.json - - sales-performance-analysis.json -7. miscellaneous/ - - performance-review-prep.json - - system-control-research.json - -Key conversion rules: -- title → title (kept same) -- description → description (kept same) -- prompt → example_prompt (kept same) -- variables → environmentVariables (moved under relevant extension) -- extensions properly formatted with: - - name - - command - - is_builtin - - link (for external extensions) - - environmentVariables array - -All files converted and saved to: /Users/rizel/Desktop/LivestreamDemos/goose/documentation/src/pages/prompt-library/data/prompts/ - diff --git a/release-plz.toml b/release-plz.toml new file mode 100644 index 000000000..457107187 --- /dev/null +++ b/release-plz.toml @@ -0,0 +1,46 @@ +[workspace] +release = false +pr_name = "chore(GDK): release{% if version %} v{{ version }}{% endif %}" +git_tag_enable = false +git_tag_name = "gdk-v{{ version }}" +git_release_enable = false + +[[package]] +name = "goose-provider-types" +release = true +version_group = "gdk" + +[[package]] +name = "goose-sdk-types" +release = true +version_group = "gdk" + +[[package]] +name = "goose-download-manager" +release = true +version_group = "gdk" + +[[package]] +name = "goose-local-inference" +release = true +version_group = "gdk" + +[[package]] +name = "goose-providers" +release = true +version_group = "gdk" + +[[package]] +name = "goose-agent" +release = true +version_group = "gdk" + +[[package]] +name = "goose-context-management" +release = true +version_group = "gdk" + +[[package]] +name = "goose-sdk" +release = true +version_group = "gdk"