From cbed67e33c2d0159da55dcabfd8fcea5ae5cf1cb Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 16 Jan 2026 19:48:10 +0000 Subject: [PATCH 1/4] Add workflow to update CLI coverage on SDK changes This workflow triggers when PRs are merged to main (Stainless SDK updates). It uses Cursor Agent to: - Compare SDK methods with existing CLI commands - Identify coverage gaps - Implement missing CLI commands in kernel/cli - Create a branch and PR with the changes Co-authored-by: mason --- .github/workflows/update-cli-coverage.yml | 132 ++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 .github/workflows/update-cli-coverage.yml diff --git a/.github/workflows/update-cli-coverage.yml b/.github/workflows/update-cli-coverage.yml new file mode 100644 index 0000000..f03a38b --- /dev/null +++ b/.github/workflows/update-cli-coverage.yml @@ -0,0 +1,132 @@ +name: Update CLI Coverage + +on: + push: + branches: [main] + # Or trigger on releases: + # release: + # types: [published] + +permissions: + contents: read + +jobs: + update-cli-coverage: + runs-on: ubuntu-latest + steps: + - name: Checkout SDK repo + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Install Cursor CLI + run: | + curl https://cursor.com/install -fsS | bash + echo "$HOME/.cursor/bin" >> $GITHUB_PATH + + - name: Configure git identity + run: | + git config --global user.name "Cursor Agent" + git config --global user.email "cursor-agent@onkernel.com" + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + + - name: Clone API repo + env: + GH_TOKEN: ${{ secrets.CLI_REPO_PAT }} + run: | + gh repo clone kernel/kernel /tmp/kernel-api -- --depth=1 + + - name: Clone CLI repo + env: + GH_TOKEN: ${{ secrets.CLI_REPO_PAT }} + run: | + gh repo clone kernel/cli /tmp/kernel-cli + + - name: Update CLI coverage + env: + CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }} + GH_TOKEN: ${{ secrets.CLI_REPO_PAT }} + BRANCH_PREFIX: cli-coverage-update + run: | + cursor-agent -p "You are a CLI updater that implements missing CLI commands based on SDK updates. + + The GitHub CLI is available as \`gh\` and authenticated via GH_TOKEN. Git is available. You have write access to the CLI repository (kernel/cli). + + # Context + - SDK Repo: ${{ github.repository }} (current directory) + - Commit SHA: ${{ github.sha }} + - Commit Author: ${{ github.event.head_commit.author.username || github.actor }} + - API Repo Location: /tmp/kernel-api + - CLI Repo Location: /tmp/kernel-cli + - Update Branch Prefix: cli-coverage-update + + # Background + The Go SDK (this repo) was just updated by Stainless with new API methods. The CLI (kernel/cli) needs to be updated to expose these new methods as CLI commands. + + # Source Files + - SDK: Current directory - check for new/changed methods in the Go SDK + - API Spec: /tmp/kernel-api/packages/api/stainless.yaml - SDK configuration with resources and methods + - API Spec: /tmp/kernel-api/packages/api/openapi.yaml - Full OpenAPI specification + - CLI: /tmp/kernel-cli - Existing CLI commands + + # Task + 1. Check the recent commit(s) to this SDK repo to see what methods were added/changed: + git log -1 --name-only + git diff HEAD~1 --name-only + 2. Read the stainless.yaml to understand the full resource/method structure + 3. Check the CLI repo at /tmp/kernel-cli to see what commands already exist: + - Look at cmd/ directory structure for existing commands + - Identify which SDK methods have CLI command equivalents + 4. Identify coverage gaps - SDK methods that don't have CLI equivalents + 5. If updates are needed: + - Implement the missing CLI commands in /tmp/kernel-cli following existing patterns + - Update go.mod to use the latest SDK version if needed + - Run \`go build ./...\` to verify the code compiles + - Run \`go mod tidy\` to clean up dependencies + - Create/update a branch: cli-coverage-update/${{ github.sha }} + - Push changes to the CLI repo + - Create an issue or PR in kernel/cli with the changes + - Tag the commit author as a reviewer + 6. If no updates needed, output 'CLI coverage is up to date' and exit + + # Mapping Guide + Use these mappings to implement CLI commands: + - client.Resource.Create() -> kernel resource create + - client.Resource.List() -> kernel resource list + - client.Resource.Get() -> kernel resource get + - client.Resource.Delete() -> kernel resource delete + - client.Resource.Update() -> kernel resource update + - client.Resource.Sub.Action() -> kernel resource sub action + + # Implementation Guidelines + - Follow the existing CLI code patterns in /tmp/kernel-cli + - Use cobra for command definitions + - Use the Kernel Go SDK (this repo) for API calls + - Include proper flag definitions with descriptions + - Add help text for commands + - Handle errors appropriately + - Match the style of existing commands + + # Output Format (if updates made) + After pushing changes, create an issue or use gh to post information: + + Title: 'CLI: Add commands for new SDK methods' + + Body: + 'This PR adds CLI commands for the following SDK methods added in kernel/kernel-go-sdk@: + + - \`kernel \` for \`client.Resource.Action()\` + + Reviewer: @' + + # Constraints + - Only implement genuinely missing CLI functionality + - Internal/admin methods may not need CLI commands + - Streaming methods may have different CLI implementations + - If no new public methods were added, make no changes + - Ensure code compiles before pushing + " --model opus-4.5 --force --output-format=text From 432e5848bb2d4a2cae8b455e351bd6f00fa1bd36 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 16 Jan 2026 20:06:06 +0000 Subject: [PATCH 2/4] Ensure CLI always uses latest Go SDK version - Add step to extract SDK version (from git tag or commit SHA) - Pass SDK module path and version to Cursor Agent - Make SDK version update the primary task (step 1) - Always create PR even if only SDK version changes (no new commands) - Update PR templates to show SDK version changes Co-authored-by: mason --- .github/workflows/update-cli-coverage.yml | 84 ++++++++++++++++++----- 1 file changed, 67 insertions(+), 17 deletions(-) diff --git a/.github/workflows/update-cli-coverage.yml b/.github/workflows/update-cli-coverage.yml index f03a38b..4e49151 100644 --- a/.github/workflows/update-cli-coverage.yml +++ b/.github/workflows/update-cli-coverage.yml @@ -46,6 +46,24 @@ jobs: run: | gh repo clone kernel/cli /tmp/kernel-cli + - name: Get SDK version info + id: sdk-version + run: | + # Get the latest tag if available, otherwise use commit SHA + LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + if [ -n "$LATEST_TAG" ]; then + echo "version=$LATEST_TAG" >> $GITHUB_OUTPUT + echo "SDK version: $LATEST_TAG" + else + echo "version=${{ github.sha }}" >> $GITHUB_OUTPUT + echo "SDK version: ${{ github.sha }} (no tag)" + fi + + # Get the module path from go.mod + MODULE_PATH=$(head -1 go.mod | awk '{print $2}') + echo "module=$MODULE_PATH" >> $GITHUB_OUTPUT + echo "SDK module: $MODULE_PATH" + - name: Update CLI coverage env: CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }} @@ -58,6 +76,8 @@ jobs: # Context - SDK Repo: ${{ github.repository }} (current directory) + - SDK Module: ${{ steps.sdk-version.outputs.module }} + - SDK Version: ${{ steps.sdk-version.outputs.version }} - Commit SHA: ${{ github.sha }} - Commit Author: ${{ github.event.head_commit.author.username || github.actor }} - API Repo Location: /tmp/kernel-api @@ -74,24 +94,37 @@ jobs: - CLI: /tmp/kernel-cli - Existing CLI commands # Task - 1. Check the recent commit(s) to this SDK repo to see what methods were added/changed: + 1. ALWAYS update the CLI to use the latest Go SDK version: + - Go to /tmp/kernel-cli + - Update go.mod to require the latest SDK: ${{ steps.sdk-version.outputs.module }}@${{ steps.sdk-version.outputs.version }} + - Run: go get ${{ steps.sdk-version.outputs.module }}@${{ steps.sdk-version.outputs.version }} + - Run: go mod tidy + - This ensures the CLI always uses the latest SDK, even if no new commands are added + + 2. Check the recent commit(s) to this SDK repo to see what methods were added/changed: git log -1 --name-only git diff HEAD~1 --name-only - 2. Read the stainless.yaml to understand the full resource/method structure - 3. Check the CLI repo at /tmp/kernel-cli to see what commands already exist: + + 3. Read the stainless.yaml to understand the full resource/method structure + + 4. Check the CLI repo at /tmp/kernel-cli to see what commands already exist: - Look at cmd/ directory structure for existing commands - Identify which SDK methods have CLI command equivalents - 4. Identify coverage gaps - SDK methods that don't have CLI equivalents - 5. If updates are needed: + + 5. Identify coverage gaps - SDK methods that don't have CLI equivalents + + 6. If new commands are needed: - Implement the missing CLI commands in /tmp/kernel-cli following existing patterns - - Update go.mod to use the latest SDK version if needed - Run \`go build ./...\` to verify the code compiles - - Run \`go mod tidy\` to clean up dependencies + + 7. Create and push changes (SDK version update + any new commands): - Create/update a branch: cli-coverage-update/${{ github.sha }} + - Commit with message describing SDK version bump and any new commands - Push changes to the CLI repo - Create an issue or PR in kernel/cli with the changes - Tag the commit author as a reviewer - 6. If no updates needed, output 'CLI coverage is up to date' and exit + + 8. If only SDK version was updated (no new commands), still create the PR with title 'CLI: Update Go SDK to ' # Mapping Guide Use these mappings to implement CLI commands: @@ -111,22 +144,39 @@ jobs: - Handle errors appropriately - Match the style of existing commands - # Output Format (if updates made) - After pushing changes, create an issue or use gh to post information: + # Output Format + After pushing changes, create a PR using gh: + + If new commands were added: + Title: 'CLI: Update SDK to and add new commands' + Body: + 'This PR updates the Go SDK to ${{ steps.sdk-version.outputs.version }} and adds CLI commands for the following new SDK methods: + + ## SDK Update + - Updated kernel-go-sdk from to ${{ steps.sdk-version.outputs.version }} + + ## New Commands + - \`kernel \` for \`client.Resource.Action()\` - Title: 'CLI: Add commands for new SDK methods' + Triggered by: kernel/kernel-go-sdk@${{ github.sha }} + Reviewer: @' - Body: - 'This PR adds CLI commands for the following SDK methods added in kernel/kernel-go-sdk@: + If only SDK version update (no new commands): + Title: 'CLI: Update Go SDK to ${{ steps.sdk-version.outputs.version }}' + Body: + 'This PR updates the Go SDK dependency to the latest version. - - \`kernel \` for \`client.Resource.Action()\` + ## SDK Update + - Updated kernel-go-sdk from to ${{ steps.sdk-version.outputs.version }} - Reviewer: @' + Triggered by: kernel/kernel-go-sdk@${{ github.sha }} + Reviewer: @' # Constraints - - Only implement genuinely missing CLI functionality + - ALWAYS update the SDK version in go.mod - this is the primary purpose + - Only implement genuinely missing CLI functionality for new commands - Internal/admin methods may not need CLI commands - Streaming methods may have different CLI implementations - - If no new public methods were added, make no changes + - Even if no new commands are needed, still create a PR for the SDK version bump - Ensure code compiles before pushing " --model opus-4.5 --force --output-format=text From 6796f5da352fab208b6524c2bdfa02c620a031e0 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 16 Jan 2026 21:58:41 +0000 Subject: [PATCH 3/4] Address PR review feedback from raf - Use actions/checkout@v6 with fetch-tags: true (fix tag detection) - Use kernel.sh email domain - Use go-version: 'stable' instead of hardcoded version - Update wording: 'may contain new API methods' - Include new SDK method parameters in coverage gaps - Support new commands OR flags - Use evergreen branch (cli-coverage-update) instead of per-commit branches - Create/update evergreen PR instead of creating new PRs each time Co-authored-by: mason --- .github/workflows/update-cli-coverage.yml | 42 +++++++++++++---------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/.github/workflows/update-cli-coverage.yml b/.github/workflows/update-cli-coverage.yml index 4e49151..56406c3 100644 --- a/.github/workflows/update-cli-coverage.yml +++ b/.github/workflows/update-cli-coverage.yml @@ -15,9 +15,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout SDK repo - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 2 + fetch-tags: true - name: Install Cursor CLI run: | @@ -27,12 +28,12 @@ jobs: - name: Configure git identity run: | git config --global user.name "Cursor Agent" - git config --global user.email "cursor-agent@onkernel.com" + git config --global user.email "cursor-agent@kernel.sh" - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '1.22' + go-version: 'stable' - name: Clone API repo env: @@ -85,7 +86,7 @@ jobs: - Update Branch Prefix: cli-coverage-update # Background - The Go SDK (this repo) was just updated by Stainless with new API methods. The CLI (kernel/cli) needs to be updated to expose these new methods as CLI commands. + The Go SDK (this repo) was just updated by Stainless, and may contain new API methods. The CLI (kernel/cli) needs to be updated to expose these new methods as CLI commands. # Source Files - SDK: Current directory - check for new/changed methods in the Go SDK @@ -111,20 +112,20 @@ jobs: - Look at cmd/ directory structure for existing commands - Identify which SDK methods have CLI command equivalents - 5. Identify coverage gaps - SDK methods that don't have CLI equivalents + 5. Identify coverage gaps - SDK methods that don't have CLI equivalents, or new SDK method parameters that aren't exposed via the CLI - 6. If new commands are needed: - - Implement the missing CLI commands in /tmp/kernel-cli following existing patterns + 6. If new commands or flags are needed: + - Implement them in /tmp/kernel-cli following existing patterns - Run \`go build ./...\` to verify the code compiles 7. Create and push changes (SDK version update + any new commands): - - Create/update a branch: cli-coverage-update/${{ github.sha }} + - Create/update the evergreen branch: cli-coverage-update (always use this single branch name) - Commit with message describing SDK version bump and any new commands - - Push changes to the CLI repo - - Create an issue or PR in kernel/cli with the changes + - Force push changes to the CLI repo (since we're updating an evergreen branch) + - Create or update an evergreen PR in kernel/cli (check if PR already exists for this branch first) - Tag the commit author as a reviewer - 8. If only SDK version was updated (no new commands), still create the PR with title 'CLI: Update Go SDK to ' + 8. If only SDK version was updated (no new commands), still update the evergreen PR with title 'CLI: Update Go SDK to ' # Mapping Guide Use these mappings to implement CLI commands: @@ -145,17 +146,22 @@ jobs: - Match the style of existing commands # Output Format - After pushing changes, create a PR using gh: + After pushing changes, create or update an evergreen PR using gh: - If new commands were added: - Title: 'CLI: Update SDK to and add new commands' + 1. Check if a PR already exists for the cli-coverage-update branch: + gh pr list --repo kernel/cli --head cli-coverage-update --json number + + 2. If PR exists, update it. If not, create a new one. + + If new commands or flags were added: + Title: 'CLI: Update SDK to and add new commands/flags' Body: - 'This PR updates the Go SDK to ${{ steps.sdk-version.outputs.version }} and adds CLI commands for the following new SDK methods: + 'This PR updates the Go SDK to ${{ steps.sdk-version.outputs.version }} and adds CLI commands/flags for new SDK methods. ## SDK Update - - Updated kernel-go-sdk from to ${{ steps.sdk-version.outputs.version }} + - Updated kernel-go-sdk to ${{ steps.sdk-version.outputs.version }} - ## New Commands + ## New Commands/Flags - \`kernel \` for \`client.Resource.Action()\` Triggered by: kernel/kernel-go-sdk@${{ github.sha }} @@ -167,7 +173,7 @@ jobs: 'This PR updates the Go SDK dependency to the latest version. ## SDK Update - - Updated kernel-go-sdk from to ${{ steps.sdk-version.outputs.version }} + - Updated kernel-go-sdk to ${{ steps.sdk-version.outputs.version }} Triggered by: kernel/kernel-go-sdk@${{ github.sha }} Reviewer: @' From f1e6ffc8352c405647fb9d4d07299a465a241bad Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 16 Jan 2026 22:00:54 +0000 Subject: [PATCH 4/4] Fix: use setup-go@v6 (not checkout@v6) Co-authored-by: mason --- .github/workflows/update-cli-coverage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-cli-coverage.yml b/.github/workflows/update-cli-coverage.yml index 56406c3..f70578c 100644 --- a/.github/workflows/update-cli-coverage.yml +++ b/.github/workflows/update-cli-coverage.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout SDK repo - uses: actions/checkout@v6 + uses: actions/checkout@v4 with: fetch-depth: 2 fetch-tags: true @@ -31,7 +31,7 @@ jobs: git config --global user.email "cursor-agent@kernel.sh" - name: Setup Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version: 'stable'