Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.21"
".": "0.1.0-alpha.22"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 16
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-0eed0c3c47bb630ed692f2de1c5228e3e1a29f52489851aecc0b9f9f3b5bce61.yml
openapi_spec_hash: c62aa08b1662b81b6ede9e298e4f1882
config_hash: 8a921dfc8d183e865a02718de6783412
config_hash: bbdd4dc9facc32f740ec0d46d9938d3e
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 0.1.0-alpha.22 (2025-06-26)

Full Changelog: [v0.1.0-alpha.21...v0.1.0-alpha.22](https://github.com/stainless-api/stainless-api-cli/compare/v0.1.0-alpha.21...v0.1.0-alpha.22)

### Features

* add mcp command ([82f9ac7](https://github.com/stainless-api/stainless-api-cli/commit/82f9ac79d3025e10cab1f91f790d72ed75b30cb1))
* **api:** manual updates ([8809e1c](https://github.com/stainless-api/stainless-api-cli/commit/8809e1c1b087b2f87e57f20d341b0f19786e1d31))


### Bug Fixes

* change stainlessv0 import to stainless ([bb69895](https://github.com/stainless-api/stainless-api-cli/commit/bb698955e7a0107b45d4eef6d9fcdbcf820899dc))


### Chores

* update go sdk ([18af766](https://github.com/stainless-api/stainless-api-cli/commit/18af766bf7046273ff3e4d7ae0194962d7b6a8e2))

## 0.1.0-alpha.21 (2025-06-23)

Full Changelog: [v0.1.0-alpha.20...v0.1.0-alpha.21](https://github.com/stainless-api/stainless-api-cli/compare/v0.1.0-alpha.20...v0.1.0-alpha.21)
Expand Down
2 changes: 1 addition & 1 deletion cmd/stl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func main() {
app := cmd.Command
if err := app.Run(context.Background(), os.Args); err != nil {
var apierr *stainlessv0.Error
var apierr *stainless.Error
if errors.As(err, &apierr) {
fmt.Printf("%s\n", cmd.ColorizeJSON(apierr.RawJSON(), os.Stderr))
} else {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/charmbracelet/lipgloss v1.1.0
github.com/logrusorgru/aurora/v4 v4.0.0
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/stainless-api/stainless-api-go v0.10.0
github.com/stainless-api/stainless-api-go v0.11.0
github.com/tidwall/gjson v1.17.0
github.com/tidwall/pretty v1.2.1
github.com/tidwall/sjson v1.2.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/stainless-api/stainless-api-go v0.10.0 h1:OYfOwfvAmGtr+7aaV8WaxYoYtVIcj8nzQBQyuTocHOc=
github.com/stainless-api/stainless-api-go v0.10.0/go.mod h1:9Q2t8xq6EFgw8HYOsVxqKEfSDVe9eqCoh1zC0HMRwTY=
github.com/stainless-api/stainless-api-go v0.11.0 h1:2pIgtdXL0Dc8KX/drzVfm/Qiws+dga4rMZ4rYGBF5SQ=
github.com/stainless-api/stainless-api-go v0.11.0/go.mod h1:9Q2t8xq6EFgw8HYOsVxqKEfSDVe9eqCoh1zC0HMRwTY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
Expand Down
18 changes: 9 additions & 9 deletions pkg/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
// targetInfo holds information about a build target
type targetInfo struct {
name string
status stainlessv0.BuildTargetStatus
status stainless.BuildTargetStatus
}

// getCompletedTargets extracts completed targets from a build response
func getCompletedTargets(buildRes stainlessv0.BuildObject) []targetInfo {
func getCompletedTargets(buildRes stainless.BuildObject) []targetInfo {
targets := []targetInfo{}

// Check each target and add it to the list if it's completed or in postgen
Expand Down Expand Up @@ -89,7 +89,7 @@ func getCompletedTargets(buildRes stainlessv0.BuildObject) []targetInfo {
}

// isTargetCompleted checks if a target is in a completed state
func isTargetCompleted(status stainlessv0.BuildTargetStatus) bool {
func isTargetCompleted(status stainless.BuildTargetStatus) bool {
return status == "completed" || status == "postgen"
}

Expand Down Expand Up @@ -311,7 +311,7 @@ func handleBuildsCreate(ctx context.Context, cmd *cli.Command) error {
return err
}
Progress("Creating build...")
params := stainlessv0.BuildNewParams{}
params := stainless.BuildNewParams{}
res, err := cc.client.Builds.New(
context.TODO(),
params,
Expand Down Expand Up @@ -418,7 +418,7 @@ func handleBuildsRetrieve(ctx context.Context, cmd *cli.Command) error {
}

// pullBuildOutputs pulls the outputs for a completed build
func pullBuildOutputs(ctx context.Context, client stainlessv0.Client, res stainlessv0.BuildObject) error {
func pullBuildOutputs(ctx context.Context, client stainless.Client, res stainless.BuildObject) error {
// Get all targets
allTargets := getCompletedTargets(res)

Expand All @@ -443,9 +443,9 @@ func pullBuildOutputs(ctx context.Context, client stainlessv0.Client, res stainl
// Get the output details
outputRes, err := client.Builds.TargetOutputs.Get(
ctx,
stainlessv0.BuildTargetOutputGetParams{
stainless.BuildTargetOutputGetParams{
BuildID: res.ID,
Target: stainlessv0.BuildTargetOutputGetParamsTarget(target),
Target: stainless.BuildTargetOutputGetParamsTarget(target),
Type: "source",
Output: "git",
},
Expand Down Expand Up @@ -559,7 +559,7 @@ func pullOutput(output, url, ref, targetDir string) error {

func handleBuildsList(ctx context.Context, cmd *cli.Command) error {
cc := getAPICommandContext(cmd)
params := stainlessv0.BuildListParams{}
params := stainless.BuildListParams{}
res, err := cc.client.Builds.List(
context.TODO(),
params,
Expand All @@ -575,7 +575,7 @@ func handleBuildsList(ctx context.Context, cmd *cli.Command) error {

func handleBuildsCompare(ctx context.Context, cmd *cli.Command) error {
cc := getAPICommandContext(cmd)
params := stainlessv0.BuildCompareParams{}
params := stainless.BuildCompareParams{}
res, err := cc.client.Builds.Compare(
context.TODO(),
params,
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/builddiagnostic.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var buildsDiagnosticsList = cli.Command{

func handleBuildsDiagnosticsList(ctx context.Context, cmd *cli.Command) error {
cc := getAPICommandContext(cmd)
params := stainlessv0.BuildDiagnosticListParams{}
params := stainless.BuildDiagnosticListParams{}
res, err := cc.client.Builds.Diagnostics.List(
context.TODO(),
cmd.Value("build-id").(string),
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/buildtargetoutput.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var buildsTargetOutputsRetrieve = cli.Command{

func handleBuildsTargetOutputsRetrieve(ctx context.Context, cmd *cli.Command) error {
cc := getAPICommandContext(cmd)
params := stainlessv0.BuildTargetOutputGetParams{}
params := stainless.BuildTargetOutputGetParams{}
res, err := cc.client.Builds.TargetOutputs.Get(
context.TODO(),
params,
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ var Command = cli.Command{
&orgsList,
},
},

&mcpCommand,
},
EnableShellCompletion: true,
HideHelpCommand: true,
Expand Down
55 changes: 55 additions & 0 deletions pkg/cmd/mcp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package cmd

import (
"context"
"fmt"
"os"
"os/exec"

"github.com/urfave/cli/v3"
)

var mcpCommand = cli.Command{
Name: "mcp",
Usage: "Run Stainless MCP server",
Description: "Wrapper around @stainless-api/mcp@latest with environment variables set",
Action: handleMCP,
ArgsUsage: "[MCP_ARGS...]",
HideHelpCommand: true,
SkipFlagParsing: true,
}

func handleMCP(ctx context.Context, cmd *cli.Command) error {
args := []string{"-y", "@stainless-api/mcp@latest"}

if cmd.Args().Len() > 0 {
args = append(args, cmd.Args().Slice()...)
}

env := os.Environ()

// Set STAINLESS_API_KEY if not already in environment
if apiKey := os.Getenv("STAINLESS_API_KEY"); apiKey == "" {
authConfig, err := LoadAuthConfig()
if err == nil && authConfig != nil && authConfig.AccessToken != "" {
env = append(env, fmt.Sprintf("STAINLESS_API_KEY=%s", authConfig.AccessToken))
}
}

// Set STAINLESS_PROJECT from workspace config if available
var config WorkspaceConfig
found, err := config.Find()
if err == nil && found && config.Project != "" {
env = append(env, fmt.Sprintf("STAINLESS_PROJECT=%s", config.Project))
}

npmCmd := exec.CommandContext(ctx, "npx", args...)
npmCmd.Env = env
npmCmd.Stdout = os.Stdout
npmCmd.Stderr = os.Stderr
npmCmd.Stdin = os.Stdin

return npmCmd.Run()
}
14 changes: 7 additions & 7 deletions pkg/cmd/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func handleProjectsCreate(ctx context.Context, cmd *cli.Command) error {
}
}

params := stainlessv0.ProjectNewParams{}
params := stainless.ProjectNewParams{}
res, err := cc.client.Projects.New(
context.TODO(),
params,
Expand Down Expand Up @@ -349,9 +349,9 @@ func handleProjectsCreate(ctx context.Context, cmd *cli.Command) error {

func handleProjectsRetrieve(ctx context.Context, cmd *cli.Command) error {
cc := getAPICommandContext(cmd)
params := stainlessv0.ProjectGetParams{}
params := stainless.ProjectGetParams{}
if cmd.IsSet("project") {
params.Project = stainlessv0.String(cmd.Value("project").(string))
params.Project = stainless.String(cmd.Value("project").(string))
}
res, err := cc.client.Projects.Get(
context.TODO(),
Expand All @@ -368,9 +368,9 @@ func handleProjectsRetrieve(ctx context.Context, cmd *cli.Command) error {

func handleProjectsUpdate(ctx context.Context, cmd *cli.Command) error {
cc := getAPICommandContext(cmd)
params := stainlessv0.ProjectUpdateParams{}
params := stainless.ProjectUpdateParams{}
if cmd.IsSet("project") {
params.Project = stainlessv0.String(cmd.Value("project").(string))
params.Project = stainless.String(cmd.Value("project").(string))
}
res, err := cc.client.Projects.Update(
context.TODO(),
Expand All @@ -387,7 +387,7 @@ func handleProjectsUpdate(ctx context.Context, cmd *cli.Command) error {

func handleProjectsList(ctx context.Context, cmd *cli.Command) error {
cc := getAPICommandContext(cmd)
params := stainlessv0.ProjectListParams{}
params := stainless.ProjectListParams{}
res, err := cc.client.Projects.List(
context.TODO(),
params,
Expand All @@ -402,7 +402,7 @@ func handleProjectsList(ctx context.Context, cmd *cli.Command) error {
}

// fetchUserOrgs retrieves the list of organizations the user has access to
func fetchUserOrgs(client stainlessv0.Client, ctx context.Context) []string {
func fetchUserOrgs(client stainless.Client, ctx context.Context) []string {
res, err := client.Orgs.List(ctx)
if err != nil {
// Return empty slice if we can't fetch orgs
Expand Down
8 changes: 4 additions & 4 deletions pkg/cmd/projectbranch.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ var projectsBranchesRetrieve = cli.Command{

func handleProjectsBranchesCreate(ctx context.Context, cmd *cli.Command) error {
cc := getAPICommandContext(cmd)
params := stainlessv0.ProjectBranchNewParams{}
params := stainless.ProjectBranchNewParams{}
if cmd.IsSet("project") {
params.Project = stainlessv0.String(cmd.Value("project").(string))
params.Project = stainless.String(cmd.Value("project").(string))
}
res, err := cc.client.Projects.Branches.New(
context.TODO(),
Expand All @@ -83,9 +83,9 @@ func handleProjectsBranchesCreate(ctx context.Context, cmd *cli.Command) error {

func handleProjectsBranchesRetrieve(ctx context.Context, cmd *cli.Command) error {
cc := getAPICommandContext(cmd)
params := stainlessv0.ProjectBranchGetParams{}
params := stainless.ProjectBranchGetParams{}
if cmd.IsSet("project") {
params.Project = stainlessv0.String(cmd.Value("project").(string))
params.Project = stainless.String(cmd.Value("project").(string))
}
res, err := cc.client.Projects.Branches.Get(
context.TODO(),
Expand Down
8 changes: 4 additions & 4 deletions pkg/cmd/projectconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ var projectsConfigsGuess = cli.Command{

func handleProjectsConfigsRetrieve(ctx context.Context, cmd *cli.Command) error {
cc := getAPICommandContext(cmd)
params := stainlessv0.ProjectConfigGetParams{}
params := stainless.ProjectConfigGetParams{}
if cmd.IsSet("project") {
params.Project = stainlessv0.String(cmd.Value("project").(string))
params.Project = stainless.String(cmd.Value("project").(string))
}
res := []byte{}
_, err := cc.client.Projects.Configs.Get(
Expand All @@ -81,9 +81,9 @@ func handleProjectsConfigsRetrieve(ctx context.Context, cmd *cli.Command) error

func handleProjectsConfigsGuess(ctx context.Context, cmd *cli.Command) error {
cc := getAPICommandContext(cmd)
params := stainlessv0.ProjectConfigGuessParams{}
params := stainless.ProjectConfigGuessParams{}
if cmd.IsSet("project") {
params.Project = stainlessv0.String(cmd.Value("project").(string))
params.Project = stainless.String(cmd.Value("project").(string))
}
res := []byte{}
_, err := cc.client.Projects.Configs.Guess(
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func getDefaultRequestOptions(cmd *cli.Command) []option.RequestOption {
}

type apiCommandContext struct {
client stainlessv0.Client
client stainless.Client
cmd *cli.Command
}

Expand Down Expand Up @@ -136,7 +136,7 @@ func (c apiCommandContext) AsMiddleware() option.Middleware {
}

func getAPICommandContext(cmd *cli.Command) *apiCommandContext {
client := stainlessv0.NewClient(getDefaultRequestOptions(cmd)...)
client := stainless.NewClient(getDefaultRequestOptions(cmd)...)
return &apiCommandContext{client, cmd}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ type projectInfo struct {

// fetchUserProjects retrieves the list of projects the user has access to
func fetchUserProjects(ctx context.Context) map[string]projectInfo {
client := stainlessv0.NewClient(getClientOptions()...)
params := stainlessv0.ProjectListParams{}
client := stainless.NewClient(getClientOptions()...)
params := stainless.ProjectListParams{}

res, err := client.Projects.List(ctx, params)
if err != nil {
Expand Down