Skip to content

Commit cbed67e

Browse files
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 <mason@onkernel.com>
1 parent bed5719 commit cbed67e

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Update CLI Coverage
2+
3+
on:
4+
push:
5+
branches: [main]
6+
# Or trigger on releases:
7+
# release:
8+
# types: [published]
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
update-cli-coverage:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout SDK repo
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 2
21+
22+
- name: Install Cursor CLI
23+
run: |
24+
curl https://cursor.com/install -fsS | bash
25+
echo "$HOME/.cursor/bin" >> $GITHUB_PATH
26+
27+
- name: Configure git identity
28+
run: |
29+
git config --global user.name "Cursor Agent"
30+
git config --global user.email "cursor-agent@onkernel.com"
31+
32+
- name: Setup Go
33+
uses: actions/setup-go@v5
34+
with:
35+
go-version: '1.22'
36+
37+
- name: Clone API repo
38+
env:
39+
GH_TOKEN: ${{ secrets.CLI_REPO_PAT }}
40+
run: |
41+
gh repo clone kernel/kernel /tmp/kernel-api -- --depth=1
42+
43+
- name: Clone CLI repo
44+
env:
45+
GH_TOKEN: ${{ secrets.CLI_REPO_PAT }}
46+
run: |
47+
gh repo clone kernel/cli /tmp/kernel-cli
48+
49+
- name: Update CLI coverage
50+
env:
51+
CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
52+
GH_TOKEN: ${{ secrets.CLI_REPO_PAT }}
53+
BRANCH_PREFIX: cli-coverage-update
54+
run: |
55+
cursor-agent -p "You are a CLI updater that implements missing CLI commands based on SDK updates.
56+
57+
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).
58+
59+
# Context
60+
- SDK Repo: ${{ github.repository }} (current directory)
61+
- Commit SHA: ${{ github.sha }}
62+
- Commit Author: ${{ github.event.head_commit.author.username || github.actor }}
63+
- API Repo Location: /tmp/kernel-api
64+
- CLI Repo Location: /tmp/kernel-cli
65+
- Update Branch Prefix: cli-coverage-update
66+
67+
# Background
68+
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.
69+
70+
# Source Files
71+
- SDK: Current directory - check for new/changed methods in the Go SDK
72+
- API Spec: /tmp/kernel-api/packages/api/stainless.yaml - SDK configuration with resources and methods
73+
- API Spec: /tmp/kernel-api/packages/api/openapi.yaml - Full OpenAPI specification
74+
- CLI: /tmp/kernel-cli - Existing CLI commands
75+
76+
# Task
77+
1. Check the recent commit(s) to this SDK repo to see what methods were added/changed:
78+
git log -1 --name-only
79+
git diff HEAD~1 --name-only
80+
2. Read the stainless.yaml to understand the full resource/method structure
81+
3. Check the CLI repo at /tmp/kernel-cli to see what commands already exist:
82+
- Look at cmd/ directory structure for existing commands
83+
- Identify which SDK methods have CLI command equivalents
84+
4. Identify coverage gaps - SDK methods that don't have CLI equivalents
85+
5. If updates are needed:
86+
- Implement the missing CLI commands in /tmp/kernel-cli following existing patterns
87+
- Update go.mod to use the latest SDK version if needed
88+
- Run \`go build ./...\` to verify the code compiles
89+
- Run \`go mod tidy\` to clean up dependencies
90+
- Create/update a branch: cli-coverage-update/${{ github.sha }}
91+
- Push changes to the CLI repo
92+
- Create an issue or PR in kernel/cli with the changes
93+
- Tag the commit author as a reviewer
94+
6. If no updates needed, output 'CLI coverage is up to date' and exit
95+
96+
# Mapping Guide
97+
Use these mappings to implement CLI commands:
98+
- client.Resource.Create() -> kernel resource create
99+
- client.Resource.List() -> kernel resource list
100+
- client.Resource.Get() -> kernel resource get
101+
- client.Resource.Delete() -> kernel resource delete
102+
- client.Resource.Update() -> kernel resource update
103+
- client.Resource.Sub.Action() -> kernel resource sub action
104+
105+
# Implementation Guidelines
106+
- Follow the existing CLI code patterns in /tmp/kernel-cli
107+
- Use cobra for command definitions
108+
- Use the Kernel Go SDK (this repo) for API calls
109+
- Include proper flag definitions with descriptions
110+
- Add help text for commands
111+
- Handle errors appropriately
112+
- Match the style of existing commands
113+
114+
# Output Format (if updates made)
115+
After pushing changes, create an issue or use gh to post information:
116+
117+
Title: 'CLI: Add commands for new SDK methods'
118+
119+
Body:
120+
'This PR adds CLI commands for the following SDK methods added in kernel/kernel-go-sdk@<commit>:
121+
122+
- \`kernel <resource> <action>\` for \`client.Resource.Action()\`
123+
124+
Reviewer: @<commit_author>'
125+
126+
# Constraints
127+
- Only implement genuinely missing CLI functionality
128+
- Internal/admin methods may not need CLI commands
129+
- Streaming methods may have different CLI implementations
130+
- If no new public methods were added, make no changes
131+
- Ensure code compiles before pushing
132+
" --model opus-4.5 --force --output-format=text

0 commit comments

Comments
 (0)