File tree Expand file tree Collapse file tree 4 files changed +125
-0
lines changed Expand file tree Collapse file tree 4 files changed +125
-0
lines changed Original file line number Diff line number Diff line change 1+ package anthropic
2+
3+ import (
4+ "github.com/1Password/shell-plugins/sdk"
5+ "github.com/1Password/shell-plugins/sdk/importer"
6+ "github.com/1Password/shell-plugins/sdk/provision"
7+ "github.com/1Password/shell-plugins/sdk/schema"
8+ "github.com/1Password/shell-plugins/sdk/schema/credname"
9+ "github.com/1Password/shell-plugins/sdk/schema/fieldname"
10+ )
11+
12+ func APIKey () schema.CredentialType {
13+ return schema.CredentialType {
14+ Name : credname .APIKey ,
15+ DocsURL : sdk .URL ("https://docs.anthropic.com/en/home" ),
16+ ManagementURL : sdk .URL ("https://console.anthropic.com/settings/keys" ),
17+ Fields : []schema.CredentialField {
18+ {
19+ Name : fieldname .APIKey ,
20+ MarkdownDescription : "API Key used to authenticate to the Anthropic API." ,
21+ Secret : true ,
22+ Composition : & schema.ValueComposition {
23+ Prefix : "sk-ant-" ,
24+ Charset : schema.Charset {
25+ Uppercase : true ,
26+ Lowercase : true ,
27+ Digits : true ,
28+ Symbols : true ,
29+ },
30+ },
31+ },
32+ },
33+ DefaultProvisioner : provision .EnvVars (defaultEnvVarMapping ),
34+ Importer : importer .TryEnvVarPair (defaultEnvVarMapping ),
35+ }
36+ }
37+
38+ var defaultEnvVarMapping = map [string ]sdk.FieldName {
39+ "ANTHROPIC_API_KEY" : fieldname .APIKey ,
40+ }
Original file line number Diff line number Diff line change 1+ package anthropic
2+
3+ import (
4+ "testing"
5+
6+ "github.com/1Password/shell-plugins/sdk"
7+ "github.com/1Password/shell-plugins/sdk/plugintest"
8+ "github.com/1Password/shell-plugins/sdk/schema/fieldname"
9+ )
10+
11+ func TestAPIKeyProvisioner (t * testing.T ) {
12+ plugintest .TestProvisioner (t , APIKey ().DefaultProvisioner , map [string ]plugintest.ProvisionCase {
13+ "default" : {
14+ ItemFields : map [sdk.FieldName ]string {
15+ fieldname .APIKey : "sk-ant-api03-6ZuKEYkQUs5tduCvwiQ7YmfDlx2h13q3ovHLfHX2NAXiUA81ixbluqFo4CfUqmodkho4HvYAmlYk0wuIFTLV5w-EXAMPLE" ,
16+ },
17+ ExpectedOutput : sdk.ProvisionOutput {
18+ Environment : map [string ]string {
19+ "ANTHROPIC_API_KEY" : "sk-ant-api03-6ZuKEYkQUs5tduCvwiQ7YmfDlx2h13q3ovHLfHX2NAXiUA81ixbluqFo4CfUqmodkho4HvYAmlYk0wuIFTLV5w-EXAMPLE" ,
20+ },
21+ },
22+ },
23+ })
24+ }
25+
26+ func TestAPIKeyImporter (t * testing.T ) {
27+ plugintest .TestImporter (t , APIKey ().Importer , map [string ]plugintest.ImportCase {
28+ "environment" : {
29+ Environment : map [string ]string {
30+ "ANTHROPIC_API_KEY" : "sk-ant-api03-6ZuKEYkQUs5tduCvwiQ7YmfDlx2h13q3ovHLfHX2NAXiUA81ixbluqFo4CfUqmodkho4HvYAmlYk0wuIFTLV5w-EXAMPLE" ,
31+ },
32+ ExpectedCandidates : []sdk.ImportCandidate {
33+ {
34+ Fields : map [sdk.FieldName ]string {
35+ fieldname .APIKey : "sk-ant-api03-6ZuKEYkQUs5tduCvwiQ7YmfDlx2h13q3ovHLfHX2NAXiUA81ixbluqFo4CfUqmodkho4HvYAmlYk0wuIFTLV5w-EXAMPLE" ,
36+ },
37+ },
38+ },
39+ },
40+ })
41+ }
Original file line number Diff line number Diff line change 1+ package anthropic
2+
3+ import (
4+ "github.com/1Password/shell-plugins/sdk"
5+ "github.com/1Password/shell-plugins/sdk/needsauth"
6+ "github.com/1Password/shell-plugins/sdk/schema"
7+ "github.com/1Password/shell-plugins/sdk/schema/credname"
8+ )
9+
10+ func ClaudeCodeCLI () schema.Executable {
11+ return schema.Executable {
12+ Name : "Claude Code" ,
13+ Runs : []string {"claude" },
14+ DocsURL : sdk .URL ("https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview" ),
15+ NeedsAuth : needsauth .NotForHelpOrVersion (),
16+ Uses : []schema.CredentialUsage {
17+ {
18+ Name : credname .APIKey ,
19+ },
20+ },
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ package anthropic
2+
3+ import (
4+ "github.com/1Password/shell-plugins/sdk"
5+ "github.com/1Password/shell-plugins/sdk/schema"
6+ )
7+
8+ func New () schema.Plugin {
9+ return schema.Plugin {
10+ Name : "anthropic" ,
11+ Platform : schema.PlatformInfo {
12+ Name : "Anthropic" ,
13+ Homepage : sdk .URL ("https://anthropic.com" ),
14+ },
15+ Credentials : []schema.CredentialType {
16+ APIKey (),
17+ },
18+ Executables : []schema.Executable {
19+ ClaudeCodeCLI (),
20+ },
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments