Skip to content

Commit 1d0b5fe

Browse files
authored
Merge pull request #604 from eddumelendez/jetbrains-junie-cli
Add JetBrains Junie CLI shell plugin
2 parents 8d29da8 + 9bab9d6 commit 1d0b5fe

4 files changed

Lines changed: 150 additions & 0 deletions

File tree

plugins/junie/api_key.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package junie
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://junie.jetbrains.com/docs/environment-variables.html"),
16+
ManagementURL: sdk.URL("https://junie.jetbrains.com/cli"),
17+
Fields: []schema.CredentialField{
18+
{
19+
Name: fieldname.APIKey,
20+
MarkdownDescription: "Junie API key used to authenticate to JetBrains Junie CLI.",
21+
Secret: true,
22+
},
23+
},
24+
DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping),
25+
Importer: importer.TryEnvVarPair(defaultEnvVarMapping),
26+
}
27+
}
28+
29+
var defaultEnvVarMapping = map[string]sdk.FieldName{
30+
"JUNIE_API_KEY": fieldname.APIKey,
31+
}

plugins/junie/api_key_test.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package junie
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+
"junie api key": {
14+
ItemFields: map[sdk.FieldName]string{
15+
fieldname.APIKey: "perm-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE",
16+
},
17+
ExpectedOutput: sdk.ProvisionOutput{
18+
Environment: map[string]string{
19+
"JUNIE_API_KEY": "perm-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE",
20+
},
21+
},
22+
},
23+
"does not provision provider api keys": {
24+
ItemFields: map[sdk.FieldName]string{
25+
sdk.FieldName("Anthropic API Key"): "sk-ant-api03-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE",
26+
sdk.FieldName("OpenAI API Key"): "sk-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE",
27+
sdk.FieldName("Google API Key"): "AI-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE",
28+
sdk.FieldName("Grok API Key"): "xai-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE",
29+
sdk.FieldName("OpenRouter API Key"): "sk-or-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE",
30+
},
31+
ExpectedOutput: sdk.ProvisionOutput{
32+
Environment: map[string]string{},
33+
},
34+
},
35+
"does not provision project or task runtime inputs": {
36+
ItemFields: map[sdk.FieldName]string{
37+
fieldname.Project: "/tmp/example-project",
38+
sdk.FieldName("Task"): "Review and fix any code quality issues in the latest commit",
39+
},
40+
ExpectedOutput: sdk.ProvisionOutput{
41+
Environment: map[string]string{},
42+
},
43+
},
44+
})
45+
}
46+
47+
func TestAPIKeyImporter(t *testing.T) {
48+
plugintest.TestImporter(t, APIKey().Importer, map[string]plugintest.ImportCase{
49+
"junie api key environment": {
50+
Environment: map[string]string{
51+
"JUNIE_API_KEY": "perm-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE",
52+
},
53+
ExpectedCandidates: []sdk.ImportCandidate{
54+
{
55+
Fields: map[sdk.FieldName]string{
56+
fieldname.APIKey: "perm-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE",
57+
},
58+
},
59+
},
60+
},
61+
"provider api key environment": {
62+
Environment: map[string]string{
63+
"JUNIE_ANTHROPIC_API_KEY": "sk-ant-api03-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE",
64+
"JUNIE_OPENAI_API_KEY": "sk-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE",
65+
"JUNIE_GOOGLE_API_KEY": "AI-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE",
66+
"JUNIE_GROK_API_KEY": "xai-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE",
67+
"JUNIE_OPENROUTER_API_KEY": "sk-or-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE",
68+
},
69+
ExpectedCandidates: []sdk.ImportCandidate{},
70+
},
71+
})
72+
}

plugins/junie/junie.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package junie
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 JunieCLI() schema.Executable {
11+
return schema.Executable{
12+
Name: "JetBrains Junie CLI",
13+
Runs: []string{"junie"},
14+
DocsURL: sdk.URL("https://junie.jetbrains.com/docs/junie-cli-usage.html"),
15+
NeedsAuth: needsauth.IfAll(
16+
needsauth.NotForHelpOrVersion(),
17+
needsauth.NotWithoutArgs(),
18+
),
19+
Uses: []schema.CredentialUsage{
20+
{
21+
Name: credname.APIKey,
22+
},
23+
},
24+
}
25+
}

plugins/junie/plugin.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package junie
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: "junie",
11+
Platform: schema.PlatformInfo{
12+
Name: "JetBrains Junie",
13+
Homepage: sdk.URL("https://junie.jetbrains.com"),
14+
},
15+
Credentials: []schema.CredentialType{
16+
APIKey(),
17+
},
18+
Executables: []schema.Executable{
19+
JunieCLI(),
20+
},
21+
}
22+
}

0 commit comments

Comments
 (0)