jbai-cli 1.2.0 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -175,7 +175,7 @@ jbai doctor
175
175
  |------|-----------------|
176
176
  | Claude Code | `npm i -g @anthropic-ai/claude-code` |
177
177
  | Codex | `npm i -g @openai/codex` |
178
- | Aider | `pip install aider-chat` |
178
+ | Aider | `pipx install aider-chat` |
179
179
  | OpenCode | `go install github.com/opencode-ai/opencode@latest` |
180
180
 
181
181
  ## Token Management
@@ -33,13 +33,16 @@ if (superMode) {
33
33
  }
34
34
 
35
35
  // Set environment for Claude Code
36
+ // Only set API_KEY (not AUTH_TOKEN) to avoid conflicts
36
37
  const env = {
37
38
  ...process.env,
38
39
  ANTHROPIC_BASE_URL: endpoints.anthropic,
39
- ANTHROPIC_API_KEY: token,
40
- ANTHROPIC_AUTH_TOKEN: token
40
+ ANTHROPIC_API_KEY: token
41
41
  };
42
42
 
43
+ // Remove any existing auth token that might conflict
44
+ delete env.ANTHROPIC_AUTH_TOKEN;
45
+
43
46
  const child = spawn('claude', finalArgs, {
44
47
  stdio: 'inherit',
45
48
  env
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const { spawn } = require('child_process');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const os = require('os');
4
7
  const config = require('../lib/config');
5
8
 
6
9
  const token = config.getToken();
@@ -15,6 +18,7 @@ if (config.isTokenExpired(token)) {
15
18
  }
16
19
 
17
20
  const endpoints = config.getEndpoints();
21
+ const environment = config.getEnvironment();
18
22
  let args = process.argv.slice(2);
19
23
 
20
24
  // Check for super mode (--super, --yolo, -s)
@@ -22,28 +26,84 @@ const superFlags = ['--super', '--yolo', '-s'];
22
26
  const superMode = args.some(a => superFlags.includes(a));
23
27
  args = args.filter(a => !superFlags.includes(a));
24
28
 
29
+ // Setup OpenCode config with JetBrains provider
30
+ const configDir = path.join(os.homedir(), '.config', 'opencode');
31
+ const configFile = path.join(configDir, 'opencode.json');
32
+
33
+ if (!fs.existsSync(configDir)) {
34
+ fs.mkdirSync(configDir, { recursive: true });
35
+ }
36
+
37
+ // Create or update OpenCode config with JetBrains provider
38
+ const providerName = environment === 'staging' ? 'jbai-staging' : 'jbai';
39
+ let opencodeConfig = {};
40
+
41
+ if (fs.existsSync(configFile)) {
42
+ try {
43
+ opencodeConfig = JSON.parse(fs.readFileSync(configFile, 'utf-8'));
44
+ } catch {
45
+ opencodeConfig = {};
46
+ }
47
+ }
48
+
49
+ // Ensure provider section exists
50
+ if (!opencodeConfig.provider) {
51
+ opencodeConfig.provider = {};
52
+ }
53
+
54
+ // Environment variable name for the token
55
+ const envVarName = environment === 'staging' ? 'GRAZIE_STAGING_TOKEN' : 'GRAZIE_API_TOKEN';
56
+
57
+ // Add/update JetBrains provider with custom header (using env var reference)
58
+ opencodeConfig.provider[providerName] = {
59
+ npm: '@ai-sdk/anthropic',
60
+ name: `JetBrains AI (${environment})`,
61
+ options: {
62
+ baseURL: endpoints.anthropic,
63
+ apiKey: `{env:${envVarName}}`,
64
+ headers: {
65
+ 'Grazie-Authenticate-JWT': `{env:${envVarName}}`
66
+ }
67
+ },
68
+ models: {}
69
+ };
70
+
71
+ // Add Claude models
72
+ config.MODELS.claude.available.forEach(model => {
73
+ opencodeConfig.provider[providerName].models[model] = {
74
+ name: model
75
+ };
76
+ });
77
+
78
+ // Write config
79
+ fs.writeFileSync(configFile, JSON.stringify(opencodeConfig, null, 2));
80
+
25
81
  // Check if model specified
26
82
  const hasModel = args.includes('--model') || args.includes('-m');
27
- let finalArgs = hasModel ? args : ['--model', config.MODELS.claude.default, ...args];
83
+ let finalArgs = [];
84
+
85
+ if (!hasModel) {
86
+ // Use provider/model format for OpenCode
87
+ finalArgs.push('--model', `${providerName}/${config.MODELS.claude.default}`);
88
+ }
28
89
 
29
90
  // Add super mode flags
30
91
  if (superMode) {
31
- finalArgs = ['--yes', ...finalArgs];
92
+ finalArgs.push('--yes');
32
93
  console.log('🚀 Super mode: --yes (auto-confirm) enabled');
33
94
  }
34
95
 
35
- // Set environment for OpenCode
36
- const env = {
96
+ finalArgs.push(...args);
97
+
98
+ // Set the token in environment variable for OpenCode config to reference
99
+ const childEnv = {
37
100
  ...process.env,
38
- ANTHROPIC_BASE_URL: endpoints.anthropic,
39
- ANTHROPIC_API_KEY: token,
40
- OPENAI_API_BASE: endpoints.openai,
41
- OPENAI_API_KEY: token
101
+ [envVarName]: token
42
102
  };
43
103
 
44
104
  const child = spawn('opencode', finalArgs, {
45
105
  stdio: 'inherit',
46
- env
106
+ env: childEnv
47
107
  });
48
108
 
49
109
  child.on('error', (err) => {
package/bin/jbai.js CHANGED
@@ -21,7 +21,7 @@ const TOOLS = {
21
21
  aider: {
22
22
  name: 'Aider',
23
23
  command: 'aider',
24
- install: 'pip install aider-chat',
24
+ install: 'pipx install aider-chat',
25
25
  check: 'aider --version'
26
26
  },
27
27
  opencode: {
package/lib/config.js CHANGED
@@ -136,7 +136,7 @@ const TOOLS = {
136
136
  aider: {
137
137
  name: 'Aider',
138
138
  command: 'aider',
139
- install: 'pip install aider-chat'
139
+ install: 'pipx install aider-chat'
140
140
  },
141
141
  opencode: {
142
142
  name: 'OpenCode',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jbai-cli",
3
- "version": "1.2.0",
3
+ "version": "1.2.4",
4
4
  "description": "CLI wrappers to use AI coding tools (Claude Code, Codex, Aider, OpenCode) with JetBrains AI Platform",
5
5
  "keywords": [
6
6
  "jetbrains",