From ff98909ab4d361e6af05057a847ca6c001f1b8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Wed, 17 Jun 2026 21:52:06 -0600 Subject: [PATCH] Add Cline shell plugin --- plugins/cline/api_key.go | 31 +++++++++++++++++++++++++ plugins/cline/api_key_test.go | 43 +++++++++++++++++++++++++++++++++++ plugins/cline/cline.go | 26 +++++++++++++++++++++ plugins/cline/plugin.go | 22 ++++++++++++++++++ 4 files changed, 122 insertions(+) create mode 100644 plugins/cline/api_key.go create mode 100644 plugins/cline/api_key_test.go create mode 100644 plugins/cline/cline.go create mode 100644 plugins/cline/plugin.go diff --git a/plugins/cline/api_key.go b/plugins/cline/api_key.go new file mode 100644 index 00000000..54a512be --- /dev/null +++ b/plugins/cline/api_key.go @@ -0,0 +1,31 @@ +package cline + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/importer" + "github.com/1Password/shell-plugins/sdk/provision" + "github.com/1Password/shell-plugins/sdk/schema" + "github.com/1Password/shell-plugins/sdk/schema/credname" + "github.com/1Password/shell-plugins/sdk/schema/fieldname" +) + +func APIKey() schema.CredentialType { + return schema.CredentialType{ + Name: credname.APIKey, + DocsURL: sdk.URL("https://docs.cline.bot/api/authentication"), + ManagementURL: sdk.URL("https://app.cline.bot"), + Fields: []schema.CredentialField{ + { + Name: fieldname.APIKey, + MarkdownDescription: "Cline API key used to authenticate to the Cline CLI.", + Secret: true, + }, + }, + DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping), + Importer: importer.TryEnvVarPair(defaultEnvVarMapping), + } +} + +var defaultEnvVarMapping = map[string]sdk.FieldName{ + "CLINE_API_KEY": fieldname.APIKey, +} diff --git a/plugins/cline/api_key_test.go b/plugins/cline/api_key_test.go new file mode 100644 index 00000000..a3f2bedf --- /dev/null +++ b/plugins/cline/api_key_test.go @@ -0,0 +1,43 @@ +package cline + +import ( + "testing" + + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/plugintest" + "github.com/1Password/shell-plugins/sdk/schema/fieldname" +) + +const exampleAPIKey = "abcdef1234567890abcdef1234567890" + +func TestAPIKeyProvisioner(t *testing.T) { + plugintest.TestProvisioner(t, APIKey().DefaultProvisioner, map[string]plugintest.ProvisionCase{ + "default": { + ItemFields: map[sdk.FieldName]string{ + fieldname.APIKey: exampleAPIKey, + }, + ExpectedOutput: sdk.ProvisionOutput{ + Environment: map[string]string{ + "CLINE_API_KEY": exampleAPIKey, + }, + }, + }, + }) +} + +func TestAPIKeyImporter(t *testing.T) { + plugintest.TestImporter(t, APIKey().Importer, map[string]plugintest.ImportCase{ + "environment": { + Environment: map[string]string{ + "CLINE_API_KEY": exampleAPIKey, + }, + ExpectedCandidates: []sdk.ImportCandidate{ + { + Fields: map[sdk.FieldName]string{ + fieldname.APIKey: exampleAPIKey, + }, + }, + }, + }, + }) +} diff --git a/plugins/cline/cline.go b/plugins/cline/cline.go new file mode 100644 index 00000000..7a3aa347 --- /dev/null +++ b/plugins/cline/cline.go @@ -0,0 +1,26 @@ +package cline + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/needsauth" + "github.com/1Password/shell-plugins/sdk/schema" + "github.com/1Password/shell-plugins/sdk/schema/credname" +) + +func ClineCLI() schema.Executable { + return schema.Executable{ + Name: "Cline CLI", + Runs: []string{"cline"}, + DocsURL: sdk.URL("https://docs.cline.bot"), + NeedsAuth: needsauth.IfAll( + needsauth.NotForHelpOrVersion(), + needsauth.NotWithoutArgs(), + needsauth.NotWhenContainsArgs("auth"), + ), + Uses: []schema.CredentialUsage{ + { + Name: credname.APIKey, + }, + }, + } +} diff --git a/plugins/cline/plugin.go b/plugins/cline/plugin.go new file mode 100644 index 00000000..49632611 --- /dev/null +++ b/plugins/cline/plugin.go @@ -0,0 +1,22 @@ +package cline + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/schema" +) + +func New() schema.Plugin { + return schema.Plugin{ + Name: "cline", + Platform: schema.PlatformInfo{ + Name: "Cline", + Homepage: sdk.URL("https://cline.bot"), + }, + Credentials: []schema.CredentialType{ + APIKey(), + }, + Executables: []schema.Executable{ + ClineCLI(), + }, + } +}