@@ -3,6 +3,12 @@ name: Update CLI Coverage
33on :
44 push :
55 branches : [main]
6+ workflow_dispatch :
7+ inputs :
8+ pr_number :
9+ description : ' PR number to use for context (leave empty to use most recent merged PR)'
10+ required : false
11+ type : string
612 # Or trigger on releases:
713 # release:
814 # types: [published]
@@ -14,11 +20,49 @@ jobs:
1420 update-cli-coverage :
1521 runs-on : ubuntu-latest
1622 steps :
23+ - name : Get PR info for manual dispatch
24+ id : pr-info
25+ if : github.event_name == 'workflow_dispatch'
26+ env :
27+ GH_TOKEN : ${{ secrets.GH_TOKEN }}
28+ run : |
29+ if [ -n "${{ inputs.pr_number }}" ]; then
30+ # Use provided PR number
31+ PR_NUMBER="${{ inputs.pr_number }}"
32+ echo "Using provided PR number: $PR_NUMBER"
33+ else
34+ # Get most recent merged PR
35+ PR_NUMBER=$(gh pr list --repo ${{ github.repository }} --state merged --limit 1 --json number --jq '.[0].number')
36+ echo "Using most recent merged PR: $PR_NUMBER"
37+ fi
38+
39+ if [ -z "$PR_NUMBER" ]; then
40+ echo "No PR found, will use HEAD commit"
41+ echo "has_pr=false" >> $GITHUB_OUTPUT
42+ else
43+ # Get PR details
44+ PR_DATA=$(gh pr view "$PR_NUMBER" --repo ${{ github.repository }} --json mergeCommit,author,title)
45+ MERGE_SHA=$(echo "$PR_DATA" | jq -r '.mergeCommit.oid // empty')
46+ PR_AUTHOR=$(echo "$PR_DATA" | jq -r '.author.login // empty')
47+ PR_TITLE=$(echo "$PR_DATA" | jq -r '.title // empty')
48+
49+ echo "PR #$PR_NUMBER: $PR_TITLE"
50+ echo "Merge commit: $MERGE_SHA"
51+ echo "Author: $PR_AUTHOR"
52+
53+ echo "has_pr=true" >> $GITHUB_OUTPUT
54+ echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
55+ echo "merge_sha=$MERGE_SHA" >> $GITHUB_OUTPUT
56+ echo "pr_author=$PR_AUTHOR" >> $GITHUB_OUTPUT
57+ fi
58+
1759 - name : Checkout SDK repo
1860 uses : actions/checkout@v4
1961 with :
2062 fetch-depth : 2
2163 fetch-tags : true
64+ # For manual dispatch with a specific PR, checkout the merge commit
65+ ref : ${{ steps.pr-info.outputs.merge_sha || github.sha }}
2266
2367 - name : Install Cursor CLI
2468 run : |
@@ -56,14 +100,22 @@ jobs:
56100 echo "version=$LATEST_TAG" >> $GITHUB_OUTPUT
57101 echo "SDK version: $LATEST_TAG"
58102 else
59- echo "version=${{ github.sha }}" >> $GITHUB_OUTPUT
60- echo "SDK version: ${{ github.sha }} (no tag)"
103+ CURRENT_SHA="${{ steps.pr-info.outputs.merge_sha || github.sha }}"
104+ echo "version=$CURRENT_SHA" >> $GITHUB_OUTPUT
105+ echo "SDK version: $CURRENT_SHA (no tag)"
61106 fi
62107
63108 # Get the module path from go.mod
64109 MODULE_PATH=$(head -1 go.mod | awk '{print $2}')
65110 echo "module=$MODULE_PATH" >> $GITHUB_OUTPUT
66111 echo "SDK module: $MODULE_PATH"
112+
113+ # Determine the commit author (from PR info for manual dispatch, or from push event)
114+ if [ -n "${{ steps.pr-info.outputs.pr_author }}" ]; then
115+ echo "author=${{ steps.pr-info.outputs.pr_author }}" >> $GITHUB_OUTPUT
116+ else
117+ echo "author=${{ github.event.head_commit.author.username || github.actor }}" >> $GITHUB_OUTPUT
118+ fi
67119
68120 - name : Update CLI coverage
69121 env :
79131 - SDK Repo: ${{ github.repository }} (current directory)
80132 - SDK Module: ${{ steps.sdk-version.outputs.module }}
81133 - SDK Version: ${{ steps.sdk-version.outputs.version }}
82- - Commit SHA: ${{ github.sha }}
83- - Commit Author: ${{ github.event.head_commit.author.username || github.actor }}
134+ - Commit SHA: ${{ steps.pr-info.outputs.merge_sha || github.sha }}
135+ - Commit Author: ${{ steps.sdk-version.outputs.author }}
136+ - Trigger: ${{ github.event_name }} ${{ inputs.pr_number && format('(PR #{0})', inputs.pr_number) || '' }}
84137 - API Repo Location: /tmp/kernel-api
85138 - CLI Repo Location: /tmp/kernel-cli
86139 - Update Branch Prefix: cli-coverage-update
@@ -89,59 +142,103 @@ jobs:
89142 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.
90143
91144 # Source Files
92- - SDK: Current directory - check for new/changed methods in the Go SDK
145+ - SDK api.md: Current directory - READ THIS FILE FIRST. This is the authoritative list of all SDK methods and their signatures.
146+ - SDK *.go files: Current directory - Contains param structs (e.g., BrowserNewParams, DeploymentListParams) with all available options/fields.
93147 - API Spec: /tmp/kernel-api/packages/api/stainless.yaml - SDK configuration with resources and methods
94148 - API Spec: /tmp/kernel-api/packages/api/openapi.yaml - Full OpenAPI specification
95149 - CLI: /tmp/kernel-cli - Existing CLI commands
96150
97151 # Task
98- 1. ALWAYS update the CLI to use the latest Go SDK version:
99- - Go to /tmp/kernel-cli
100- - Update go.mod to require the latest SDK: ${{ steps.sdk-version.outputs.module }}@${{ steps.sdk-version.outputs.version }}
101- - Run: go get ${{ steps.sdk-version.outputs.module }}@${{ steps.sdk-version.outputs.version }}
102- - Run: go mod tidy
103- - This ensures the CLI always uses the latest SDK, even if no new commands are added
104152
105- 2. Check the recent commit(s) to this SDK repo to see what methods were added/changed:
106- git log -1 --name-only
107- git diff HEAD~1 --name-only
108-
109- 3. Read the stainless.yaml to understand the full resource/method structure
110-
111- 4. Check the CLI repo at /tmp/kernel-cli to see what commands already exist:
112- - Look at cmd/ directory structure for existing commands
113- - Identify which SDK methods have CLI command equivalents
114-
115- 5. Identify coverage gaps - SDK methods that don't have CLI equivalents, or new SDK method parameters that aren't exposed via the CLI
116-
117- 6. If new commands or flags are needed:
118- - Implement them in /tmp/kernel-cli following existing patterns
119- - Run \`go build ./...\` to verify the code compiles
120-
121- 7. Create and push changes (SDK version update + any new commands):
122- - Create/update the evergreen branch: cli-coverage-update (always use this single branch name)
123- - Commit with message describing SDK version bump and any new commands
124- - Force push changes to the CLI repo (since we're updating an evergreen branch)
125- - Create or update an evergreen PR in kernel/cli (check if PR already exists for this branch first)
126- - Tag the commit author as a reviewer
127-
128- 8. If only SDK version was updated (no new commands), still update the evergreen PR with title 'CLI: Update Go SDK to <version>'
129-
130- # Mapping Guide
131- Use these mappings to implement CLI commands:
132- - client.Resource.Create() -> kernel resource create
153+ ## Step 1: Update SDK Version (ALWAYS DO THIS FIRST)
154+ - Go to /tmp/kernel-cli
155+ - Update go.mod to require the latest SDK: ${{ steps.sdk-version.outputs.module }}@${{ steps.sdk-version.outputs.version }}
156+ - Run: go get ${{ steps.sdk-version.outputs.module }}@${{ steps.sdk-version.outputs.version }}
157+ - Run: go mod tidy
158+ - This ensures the CLI always uses the latest SDK, even if no new commands are added
159+
160+ ## Step 2: Full SDK Method Enumeration (CRITICAL - DO NOT SKIP)
161+ You MUST perform a complete enumeration of ALL SDK methods and their parameters. Do NOT rely only on recent commits.
162+
163+ 2a. Read the api.md file in the SDK repo root. This file lists EVERY SDK method in the format:
164+ - \`client.Resource.Method(ctx, params)\` with links to param types
165+ Extract a complete list of all methods.
166+
167+ 2b. For EACH SDK method, read the corresponding param type from the Go source files.
168+ For example:
169+ - BrowserNewParams in browser.go -> lists all fields like \`Proxy\`, \`Profile\`, \`Viewport\`, etc.
170+ - DeploymentNewParams in deployment.go -> lists all fields like \`AppName\`, \`Region\`, \`EnvVars\`, etc.
171+ Each field in a Params struct represents an option that could be a CLI flag.
172+
173+ 2c. Build a complete SDK coverage matrix:
174+ | SDK Method | SDK Param Type | SDK Param Fields |
175+ |------------|----------------|------------------|
176+ | client.Browsers.New | BrowserNewParams | Proxy, Profile, Viewport, Extensions, ... |
177+ | client.Browsers.List | BrowserListParams | Limit, Offset, IncludeDeleted, ... |
178+ | client.Deployments.New | DeploymentNewParams | AppName, Region, EnvVars, ... |
179+ | ... | ... | ... |
180+
181+ ## Step 3: Full CLI Command Enumeration (CRITICAL - DO NOT SKIP)
182+ Enumerate ALL existing CLI commands and their flags.
183+
184+ 3a. Look at cmd/ directory structure for existing commands
185+ 3b. For each command file, extract:
186+ - The command name/path (e.g., \`kernel browser create\`)
187+ - All flags defined for that command
188+ 3c. Build a CLI coverage matrix:
189+ | CLI Command | CLI Flags |
190+ |-------------|-----------|
191+ | kernel browser create | --proxy, --profile, --viewport, ... |
192+ | kernel browser list | --limit, --offset, ... |
193+ | ... | ... |
194+
195+ ## Step 4: Gap Analysis (CRITICAL - DO NOT SKIP)
196+ Compare the SDK matrix (Step 2) with the CLI matrix (Step 3) to identify:
197+
198+ 4a. Missing commands: SDK methods with NO corresponding CLI command
199+ 4b. Missing flags: SDK param fields with NO corresponding CLI flag
200+ 4c. Create a gap report:
201+ ## Missing Commands
202+ - client.Browsers.LoadExtensions -> needs \`kernel browser load-extensions\`
203+ - client.Proxies.Check -> needs \`kernel proxy check\`
204+
205+ ## Missing Flags
206+ - BrowserNewParams.SomeNewField -> \`kernel browser create\` needs --some-new-field
207+ - DeploymentListParams.Status -> \`kernel deployment list\` needs --status
208+
209+ ## Step 5: Implement Missing Coverage
210+ For each gap identified in Step 4:
211+ - Implement missing commands following existing patterns
212+ - Add missing flags to existing commands
213+ - Run \`go build ./...\` to verify the code compiles
214+
215+ ## Step 6: Commit and Push
216+ - Create/update the evergreen branch: cli-coverage-update (always use this single branch name)
217+ - Commit with message describing SDK version bump and any new commands/flags
218+ - Force push changes to the CLI repo (since we're updating an evergreen branch)
219+ - Create or update an evergreen PR in kernel/cli
220+
221+ # SDK Method -> CLI Command Mapping Guide
222+ - client.Resource.New() -> kernel resource create
133223 - client.Resource.List() -> kernel resource list
134224 - client.Resource.Get() -> kernel resource get
135225 - client.Resource.Delete() -> kernel resource delete
136226 - client.Resource.Update() -> kernel resource update
137227 - client.Resource.Sub.Action() -> kernel resource sub action
228+ - client.Resource.CustomAction() -> kernel resource custom-action
229+
230+ # SDK Param Field -> CLI Flag Mapping Guide
231+ - CamelCaseField -> --camel-case-field
232+ - TimeoutSeconds -> --timeout-seconds
233+ - IncludeDeleted -> --include-deleted
234+ - Nested structs: Viewport.Width -> --viewport-width or separate flags
138235
139236 # Implementation Guidelines
140237 - Follow the existing CLI code patterns in /tmp/kernel-cli
141238 - Use cobra for command definitions
142239 - Use the Kernel Go SDK (this repo) for API calls
143- - Include proper flag definitions with descriptions
144- - Add help text for commands
240+ - Include proper flag definitions with descriptions matching SDK field comments
241+ - Add help text for commands matching SDK method comments
145242 - Handle errors appropriately
146243 - Match the style of existing commands
147244
@@ -161,28 +258,38 @@ jobs:
161258 ## SDK Update
162259 - Updated kernel-go-sdk to ${{ steps.sdk-version.outputs.version }}
163260
164- ## New Commands/Flags
261+ ## Coverage Analysis
262+ This PR was generated by performing a full enumeration of SDK methods and CLI commands.
263+
264+ ## New Commands
165265 - \`kernel <resource> <action>\` for \`client.Resource.Action()\`
166266
167- Triggered by: kernel/kernel-go-sdk@${{ github.sha }}
267+ ## New Flags
268+ - \`--flag-name\` for \`ResourceParams.FieldName\`
269+
270+ Triggered by: kernel/kernel-go-sdk@${{ steps.pr-info.outputs.merge_sha || github.sha }}
168271 Reviewer: @<commit_author>'
169272
170- If only SDK version update (no new commands ):
273+ If only SDK version update (no coverage gaps found ):
171274 Title: 'CLI: Update Go SDK to ${{ steps.sdk-version.outputs.version }}'
172275 Body:
173276 'This PR updates the Go SDK dependency to the latest version.
174277
175278 ## SDK Update
176279 - Updated kernel-go-sdk to ${{ steps.sdk-version.outputs.version }}
177280
178- Triggered by: kernel/kernel-go-sdk@${{ github.sha }}
281+ ## Coverage Analysis
282+ A full enumeration of SDK methods and CLI commands was performed. No coverage gaps were found.
283+
284+ Triggered by: kernel/kernel-go-sdk@${{ steps.pr-info.outputs.merge_sha || github.sha }}
179285 Reviewer: @<commit_author>'
180286
181287 # Constraints
182288 - ALWAYS update the SDK version in go.mod - this is the primary purpose
183- - Only implement genuinely missing CLI functionality for new commands
289+ - ALWAYS perform the full enumeration (Steps 2-4) - this is critical for finding gaps
290+ - Only implement genuinely missing CLI functionality
184291 - Internal/admin methods may not need CLI commands
185292 - Streaming methods may have different CLI implementations
186- - Even if no new commands are needed , still create a PR for the SDK version bump
293+ - Even if no coverage gaps are found , still create a PR for the SDK version bump
187294 - Ensure code compiles before pushing
188295 " --model opus-4.5 --force --output-format=text
0 commit comments