-
Notifications
You must be signed in to change notification settings - Fork 270
Add JetBrains Junie CLI shell plugin #604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eddumelendez
wants to merge
1
commit into
1Password:main
Choose a base branch
from
eddumelendez:jetbrains-junie-cli
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+147
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package junie | ||
|
|
||
| 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://junie.jetbrains.com/docs/environment-variables.html"), | ||
| ManagementURL: sdk.URL("https://junie.jetbrains.com/cli"), | ||
| Fields: []schema.CredentialField{ | ||
| { | ||
| Name: fieldname.APIKey, | ||
| MarkdownDescription: "Junie API key used to authenticate to JetBrains Junie CLI.", | ||
| Secret: true, | ||
| }, | ||
| }, | ||
| DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping), | ||
| Importer: importer.TryEnvVarPair(defaultEnvVarMapping), | ||
| } | ||
| } | ||
|
|
||
| var defaultEnvVarMapping = map[string]sdk.FieldName{ | ||
| "JUNIE_API_KEY": fieldname.APIKey, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package junie | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/1Password/shell-plugins/sdk" | ||
| "github.com/1Password/shell-plugins/sdk/plugintest" | ||
| "github.com/1Password/shell-plugins/sdk/schema/fieldname" | ||
| ) | ||
|
|
||
| func TestAPIKeyProvisioner(t *testing.T) { | ||
| plugintest.TestProvisioner(t, APIKey().DefaultProvisioner, map[string]plugintest.ProvisionCase{ | ||
| "junie api key": { | ||
| ItemFields: map[sdk.FieldName]string{ | ||
| fieldname.APIKey: "perm-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE", | ||
| }, | ||
| ExpectedOutput: sdk.ProvisionOutput{ | ||
| Environment: map[string]string{ | ||
| "JUNIE_API_KEY": "perm-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE", | ||
| }, | ||
| }, | ||
| }, | ||
| "does not provision provider api keys": { | ||
| ItemFields: map[sdk.FieldName]string{ | ||
| sdk.FieldName("Anthropic API Key"): "sk-ant-api03-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE", | ||
| sdk.FieldName("OpenAI API Key"): "sk-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE", | ||
| sdk.FieldName("Google API Key"): "AI-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE", | ||
| sdk.FieldName("Grok API Key"): "xai-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE", | ||
| sdk.FieldName("OpenRouter API Key"): "sk-or-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE", | ||
| }, | ||
| ExpectedOutput: sdk.ProvisionOutput{ | ||
| Environment: map[string]string{}, | ||
| }, | ||
| }, | ||
| "does not provision project or task runtime inputs": { | ||
| ItemFields: map[sdk.FieldName]string{ | ||
| fieldname.Project: "/tmp/example-project", | ||
| sdk.FieldName("Task"): "Review and fix any code quality issues in the latest commit", | ||
| }, | ||
| ExpectedOutput: sdk.ProvisionOutput{ | ||
| Environment: map[string]string{}, | ||
| }, | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| func TestAPIKeyImporter(t *testing.T) { | ||
| plugintest.TestImporter(t, APIKey().Importer, map[string]plugintest.ImportCase{ | ||
| "junie api key environment": { | ||
| Environment: map[string]string{ | ||
| "JUNIE_API_KEY": "perm-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE", | ||
| }, | ||
| ExpectedCandidates: []sdk.ImportCandidate{ | ||
| { | ||
| Fields: map[sdk.FieldName]string{ | ||
| fieldname.APIKey: "perm-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| "provider api key environment": { | ||
| Environment: map[string]string{ | ||
| "JUNIE_ANTHROPIC_API_KEY": "sk-ant-api03-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE", | ||
| "JUNIE_OPENAI_API_KEY": "sk-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE", | ||
| "JUNIE_GOOGLE_API_KEY": "AI-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE", | ||
| "JUNIE_GROK_API_KEY": "xai-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE", | ||
| "JUNIE_OPENROUTER_API_KEY": "sk-or-yEyY18xzH5IiiORdCDzstp1h2xrxCydfh9tjFveUyEXAMPLE", | ||
| }, | ||
| ExpectedCandidates: []sdk.ImportCandidate{}, | ||
| }, | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package junie | ||
|
|
||
| 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 JunieCLI() schema.Executable { | ||
| return schema.Executable{ | ||
| Name: "JetBrains Junie CLI", | ||
| Runs: []string{"junie"}, | ||
| DocsURL: sdk.URL("https://junie.jetbrains.com/docs/junie-cli-usage.html"), | ||
| NeedsAuth: needsauth.NotForHelpOrVersion(), | ||
| Uses: []schema.CredentialUsage{ | ||
| { | ||
| Name: credname.APIKey, | ||
| }, | ||
| }, | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package junie | ||
|
|
||
| import ( | ||
| "github.com/1Password/shell-plugins/sdk" | ||
| "github.com/1Password/shell-plugins/sdk/schema" | ||
| ) | ||
|
|
||
| func New() schema.Plugin { | ||
| return schema.Plugin{ | ||
| Name: "junie", | ||
| Platform: schema.PlatformInfo{ | ||
| Name: "JetBrains Junie", | ||
| Homepage: sdk.URL("https://junie.jetbrains.com"), | ||
| }, | ||
| Credentials: []schema.CredentialType{ | ||
| APIKey(), | ||
| }, | ||
| Executables: []schema.Executable{ | ||
| JunieCLI(), | ||
| }, | ||
| } | ||
| } | ||
|
Comment on lines
+8
to
+22
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Junie have specific env vars to authenticate against providers via BYOK. See https://junie.jetbrains.com/docs/environment-variables.html#provider-api-keys
Is there any way to implement it in the shell plugins? I have been also looking into support OpenCode which relies on env vars from providers as well.