diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 7c31fce..aa84875 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.21" + ".": "0.1.0-alpha.22" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 97ade5f..4fad24e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a9995f..4e55127 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/cmd/stl/main.go b/cmd/stl/main.go index 2c96a42..a7c8974 100644 --- a/cmd/stl/main.go +++ b/cmd/stl/main.go @@ -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 { diff --git a/go.mod b/go.mod index 5ff5d87..807af24 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 9bbbb15..87af32c 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/pkg/cmd/build.go b/pkg/cmd/build.go index fed7706..376e77c 100644 --- a/pkg/cmd/build.go +++ b/pkg/cmd/build.go @@ -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 @@ -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" } @@ -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, @@ -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) @@ -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", }, @@ -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, @@ -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, diff --git a/pkg/cmd/builddiagnostic.go b/pkg/cmd/builddiagnostic.go index 705a0b7..99bd69b 100644 --- a/pkg/cmd/builddiagnostic.go +++ b/pkg/cmd/builddiagnostic.go @@ -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), diff --git a/pkg/cmd/buildtargetoutput.go b/pkg/cmd/buildtargetoutput.go index ed3d6e3..c9a404b 100644 --- a/pkg/cmd/buildtargetoutput.go +++ b/pkg/cmd/buildtargetoutput.go @@ -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, diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go index 640064f..3a548e8 100644 --- a/pkg/cmd/cmd.go +++ b/pkg/cmd/cmd.go @@ -95,6 +95,8 @@ var Command = cli.Command{ &orgsList, }, }, + + &mcpCommand, }, EnableShellCompletion: true, HideHelpCommand: true, diff --git a/pkg/cmd/mcp.go b/pkg/cmd/mcp.go new file mode 100644 index 0000000..52e9bbd --- /dev/null +++ b/pkg/cmd/mcp.go @@ -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() +} diff --git a/pkg/cmd/project.go b/pkg/cmd/project.go index 43ec011..57fe96b 100644 --- a/pkg/cmd/project.go +++ b/pkg/cmd/project.go @@ -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, @@ -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(), @@ -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(), @@ -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, @@ -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 diff --git a/pkg/cmd/projectbranch.go b/pkg/cmd/projectbranch.go index 89a216a..db251f1 100644 --- a/pkg/cmd/projectbranch.go +++ b/pkg/cmd/projectbranch.go @@ -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(), @@ -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(), diff --git a/pkg/cmd/projectconfig.go b/pkg/cmd/projectconfig.go index 9114a40..afe66ab 100644 --- a/pkg/cmd/projectconfig.go +++ b/pkg/cmd/projectconfig.go @@ -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( @@ -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( diff --git a/pkg/cmd/util.go b/pkg/cmd/util.go index a305694..634c31b 100644 --- a/pkg/cmd/util.go +++ b/pkg/cmd/util.go @@ -40,7 +40,7 @@ func getDefaultRequestOptions(cmd *cli.Command) []option.RequestOption { } type apiCommandContext struct { - client stainlessv0.Client + client stainless.Client cmd *cli.Command } @@ -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} } diff --git a/pkg/cmd/workspace.go b/pkg/cmd/workspace.go index 84f40d7..fdb2119 100644 --- a/pkg/cmd/workspace.go +++ b/pkg/cmd/workspace.go @@ -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 {