@gengjiawen/os-init 1.23.0 → 1.23.1

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/AGENTS.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Project Structure
4
4
 
5
- - `bin/`: Node CLI entrypoint (`bin/bin.js`) and command definitions (e.g., `set-codex`, `set-gemini`).
5
+ - `bin/`: Node CLI entrypoint (`bin/bin.js`) and command definitions (e.g., `set-codex`, `set-opencode`).
6
6
  - `libs/`: TypeScript source for config writers/installers and setup utilities (main exports in `libs/index.ts`).
7
7
  - `build/`: Compiled JS + `.d.ts` output from `tsc` (`outDir`), consumed by the CLI and published to npm.
8
8
  - `dev-setup/`: Optional Docker-based dev environment (sshd + compose) for remote/portable workflows.
@@ -22,7 +22,7 @@ Use `pnpm` (CI uses it).
22
22
 
23
23
  - Formatting: Prettier (no semicolons, single quotes). Run `pnpm format` before pushing.
24
24
  - TypeScript: strict options are enabled; prefer explicit, typed helpers over `any`.
25
- - Naming: files are kebab-case in `libs/` (e.g., `gemini-cli.ts`); exported functions are `camelCase`.
25
+ - Naming: files are kebab-case in `libs/` (e.g., `opencode.ts`); exported functions are `camelCase`.
26
26
 
27
27
  ## Testing Guidelines
28
28
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.23.1](https://github.com/gengjiawen/os-init/compare/v1.23.0...v1.23.1) (2026-04-24)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * allow claude postinstall with pnpm ([f494b78](https://github.com/gengjiawen/os-init/commit/f494b78134025992863a2272432d64348fd4532e))
9
+
3
10
  ## [1.23.0](https://github.com/gengjiawen/os-init/compare/v1.22.0...v1.23.0) (2026-04-24)
4
11
 
5
12
 
package/bin/bin.js CHANGED
@@ -7,8 +7,6 @@ const {
7
7
  installDeps,
8
8
  writeCodexConfig,
9
9
  installCodexDeps,
10
- writeGeminiConfig,
11
- installGeminiDeps,
12
10
  writeOpencodeConfig,
13
11
  installOpencodeDeps,
14
12
  writeAllAgentsConfig,
@@ -78,30 +76,6 @@ program
78
76
  console.log('Codex is ready. use `codex` in terminal to start building')
79
77
  })
80
78
 
81
- program
82
- .command('set-gemini')
83
- .description('setup Gemini CLI config and auth')
84
- .argument('<apiKey>', 'API key to set for Gemini CLI')
85
- .action(async (apiKey) => {
86
- if (!apiKey || String(apiKey).trim().length === 0) {
87
- console.error('Missing required argument: <apiKey>')
88
- program.help({ error: true })
89
- return
90
- }
91
- try {
92
- const { envPath, settingsPath } = writeGeminiConfig(apiKey)
93
- console.log(`Gemini CLI env written to: ${envPath}`)
94
- console.log(`Gemini CLI settings written to: ${settingsPath}`)
95
- await installGeminiDeps()
96
- } catch (err) {
97
- console.error('Failed to setup Gemini CLI:', err.message)
98
- process.exit(1)
99
- }
100
- console.log(
101
- 'Gemini CLI is ready. use `gemini` in terminal to start building'
102
- )
103
- })
104
-
105
79
  program
106
80
  .command('set-opencode')
107
81
  .description('setup OpenCode CLI config and auth')
@@ -128,10 +102,10 @@ program
128
102
  program
129
103
  .command('set-agents')
130
104
  .description(
131
- 'setup Claude Code and Codex at once (use --full to include OpenCode and Gemini CLI)'
105
+ 'setup Claude Code and Codex at once (use --full to include OpenCode)'
132
106
  )
133
107
  .argument('<apiKey>', 'API key to set for agents')
134
- .option('--full', 'Also setup OpenCode and Gemini CLI')
108
+ .option('--full', 'Also setup OpenCode')
135
109
  .action(async (apiKey, options) => {
136
110
  if (!apiKey || String(apiKey).trim().length === 0) {
137
111
  console.error('Missing required argument: <apiKey>')
@@ -144,7 +118,7 @@ program
144
118
  try {
145
119
  console.log(
146
120
  full
147
- ? 'Setting up Claude Code + Codex + OpenCode + Gemini CLI...\n'
121
+ ? 'Setting up Claude Code + Codex + OpenCode...\n'
148
122
  : 'Setting up Claude Code + Codex...\n'
149
123
  )
150
124
 
@@ -166,12 +140,6 @@ program
166
140
  console.log(` Config written to: ${result.opencode.configPath}`)
167
141
  }
168
142
 
169
- if (result.gemini) {
170
- console.log('\nGemini CLI:')
171
- console.log(` Env written to: ${result.gemini.envPath}`)
172
- console.log(` Settings written to: ${result.gemini.settingsPath}`)
173
- }
174
-
175
143
  console.log('\nInstalling dependencies...')
176
144
  await installAllAgentsDeps({ full })
177
145
  } catch (err) {
@@ -184,7 +152,6 @@ program
184
152
  console.log(' - Use `codex` for Codex')
185
153
  if (full) {
186
154
  console.log(' - Use `opencode` for OpenCode')
187
- console.log(' - Use `gemini` for Gemini CLI')
188
155
  }
189
156
  })
190
157
 
@@ -14,10 +14,6 @@ export interface AllAgentsResult {
14
14
  opencode?: {
15
15
  configPath: string;
16
16
  };
17
- gemini?: {
18
- envPath: string;
19
- settingsPath: string;
20
- };
21
17
  }
22
18
  export declare function writeAllAgentsConfig(apiKey: string, options?: AllAgentsOptions): Promise<AllAgentsResult>;
23
19
  export declare function installAllAgentsDeps(options?: AllAgentsOptions): Promise<void>;
@@ -4,7 +4,6 @@ exports.writeAllAgentsConfig = writeAllAgentsConfig;
4
4
  exports.installAllAgentsDeps = installAllAgentsDeps;
5
5
  const claude_code_1 = require("./claude-code");
6
6
  const codex_1 = require("./codex");
7
- const gemini_cli_1 = require("./gemini-cli");
8
7
  const opencode_1 = require("./opencode");
9
8
  const execa_1 = require("execa");
10
9
  const utils_1 = require("./utils");
@@ -17,19 +16,24 @@ async function writeAllAgentsConfig(apiKey, options = {}) {
17
16
  };
18
17
  if (options.full) {
19
18
  result.opencode = (0, opencode_1.writeOpencodeConfig)(apiKey);
20
- result.gemini = (0, gemini_cli_1.writeGeminiConfig)(apiKey);
21
19
  }
22
20
  return result;
23
21
  }
24
22
  async function installAllAgentsDeps(options = {}) {
25
23
  const packages = ['@anthropic-ai/claude-code', '@openai/codex'];
26
24
  if (options.full) {
27
- packages.push('opencode-ai', '@google/gemini-cli');
25
+ packages.push('opencode-ai');
28
26
  }
29
27
  const usePnpm = await (0, utils_1.commandExists)('pnpm');
30
28
  if (usePnpm) {
31
29
  console.log('pnpm detected. Installing agent dependencies with pnpm...');
32
- await (0, execa_1.execa)('pnpm', ['add', '-g', ...packages], {
30
+ await (0, execa_1.execa)('pnpm', [
31
+ '--allow-build=@anthropic-ai/claude-code',
32
+ 'add',
33
+ '-g',
34
+ '--force',
35
+ ...packages,
36
+ ], {
33
37
  stdio: 'inherit',
34
38
  env: utils_1.PNPM_INSTALL_ENV,
35
39
  });
@@ -103,7 +103,13 @@ async function installDeps() {
103
103
  const usePnpm = await (0, utils_1.commandExists)('pnpm');
104
104
  if (usePnpm) {
105
105
  console.log('pnpm detected. Installing dependencies with pnpm...');
106
- await (0, execa_1.execa)('pnpm', ['add', '-g', ...packages], {
106
+ await (0, execa_1.execa)('pnpm', [
107
+ '--allow-build=@anthropic-ai/claude-code',
108
+ 'add',
109
+ '-g',
110
+ '--force',
111
+ ...packages,
112
+ ], {
107
113
  stdio: 'inherit',
108
114
  env: utils_1.PNPM_INSTALL_ENV,
109
115
  });
package/build/index.d.ts CHANGED
@@ -3,7 +3,6 @@ export declare function writeRaycastConfig(apiKey: string): {
3
3
  };
4
4
  export { writeClaudeConfig, installDeps } from './claude-code';
5
5
  export { writeCodexConfig, installCodexDeps } from './codex';
6
- export { writeGeminiConfig, installGeminiDeps } from './gemini-cli';
7
6
  export { writeOpencodeConfig, installOpencodeDeps } from './opencode';
8
7
  export { writeAllAgentsConfig, installAllAgentsDeps } from './all-agents';
9
8
  export { setupDevEnvironment } from './dev-setup';
package/build/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.downloadMihomoBinary = exports.writeMihomoConfig = exports.setupAndroidEnvironment = exports.setupDevEnvironment = exports.installAllAgentsDeps = exports.writeAllAgentsConfig = exports.installOpencodeDeps = exports.writeOpencodeConfig = exports.installGeminiDeps = exports.writeGeminiConfig = exports.installCodexDeps = exports.writeCodexConfig = exports.installDeps = exports.writeClaudeConfig = void 0;
3
+ exports.downloadMihomoBinary = exports.writeMihomoConfig = exports.setupAndroidEnvironment = exports.setupDevEnvironment = exports.installAllAgentsDeps = exports.writeAllAgentsConfig = exports.installOpencodeDeps = exports.writeOpencodeConfig = exports.installCodexDeps = exports.writeCodexConfig = exports.installDeps = exports.writeClaudeConfig = void 0;
4
4
  exports.writeRaycastConfig = writeRaycastConfig;
5
5
  const fs = require("fs");
6
6
  const path = require("path");
@@ -44,9 +44,6 @@ Object.defineProperty(exports, "installDeps", { enumerable: true, get: function
44
44
  var codex_1 = require("./codex");
45
45
  Object.defineProperty(exports, "writeCodexConfig", { enumerable: true, get: function () { return codex_1.writeCodexConfig; } });
46
46
  Object.defineProperty(exports, "installCodexDeps", { enumerable: true, get: function () { return codex_1.installCodexDeps; } });
47
- var gemini_cli_1 = require("./gemini-cli");
48
- Object.defineProperty(exports, "writeGeminiConfig", { enumerable: true, get: function () { return gemini_cli_1.writeGeminiConfig; } });
49
- Object.defineProperty(exports, "installGeminiDeps", { enumerable: true, get: function () { return gemini_cli_1.installGeminiDeps; } });
50
47
  var opencode_1 = require("./opencode");
51
48
  Object.defineProperty(exports, "writeOpencodeConfig", { enumerable: true, get: function () { return opencode_1.writeOpencodeConfig; } });
52
49
  Object.defineProperty(exports, "installOpencodeDeps", { enumerable: true, get: function () { return opencode_1.installOpencodeDeps; } });
package/build/opencode.js CHANGED
@@ -15,7 +15,6 @@ const OPENCODE_MODEL_IDS = [
15
15
  'kimi',
16
16
  'minimax',
17
17
  'deepseek',
18
- 'gemini-flash',
19
18
  ];
20
19
  const OPENCODE_BASE_URL = 'https://ai.gengjiawen.com/api/openai/v1';
21
20
  function createOpencodeModelConfig(modelId) {
@@ -52,17 +52,13 @@ describe('writeAllAgentsConfig', () => {
52
52
  expect(fs.existsSync(result.codex.authPath)).toBe(true)
53
53
  expect(fs.existsSync(result.codex.catalogPath)).toBe(true)
54
54
  expect(result.opencode).toBeUndefined()
55
- expect(result.gemini).toBeUndefined()
56
55
  })
57
56
 
58
- test('includes OpenCode and Gemini config when full option is enabled', async () => {
57
+ test('includes OpenCode config when full option is enabled', async () => {
59
58
  const result = await writeAllAgentsConfig('test-api-key', { full: true })
60
59
 
61
60
  expect(result.opencode).toBeDefined()
62
61
  expect(fs.existsSync(result.opencode!.configPath)).toBe(true)
63
- expect(result.gemini).toBeDefined()
64
- expect(fs.existsSync(result.gemini!.envPath)).toBe(true)
65
- expect(fs.existsSync(result.gemini!.settingsPath)).toBe(true)
66
62
  })
67
63
 
68
64
  test('installs Claude and Codex in one pnpm command', async () => {
@@ -79,7 +75,14 @@ describe('writeAllAgentsConfig', () => {
79
75
  expect(execaMock).toHaveBeenNthCalledWith(
80
76
  2,
81
77
  'pnpm',
82
- ['add', '-g', '@anthropic-ai/claude-code', '@openai/codex'],
78
+ [
79
+ '--allow-build=@anthropic-ai/claude-code',
80
+ 'add',
81
+ '-g',
82
+ '--force',
83
+ '@anthropic-ai/claude-code',
84
+ '@openai/codex',
85
+ ],
83
86
  {
84
87
  stdio: 'inherit',
85
88
  env: {
@@ -110,7 +113,6 @@ describe('writeAllAgentsConfig', () => {
110
113
  '@anthropic-ai/claude-code',
111
114
  '@openai/codex',
112
115
  'opencode-ai',
113
- '@google/gemini-cli',
114
116
  ],
115
117
  { stdio: 'inherit' }
116
118
  )
@@ -1,12 +1,11 @@
1
1
  import { writeClaudeConfig } from './claude-code'
2
2
  import { writeCodexConfig } from './codex'
3
- import { writeGeminiConfig } from './gemini-cli'
4
3
  import { writeOpencodeConfig } from './opencode'
5
4
  import { execa } from 'execa'
6
5
  import { commandExists, PNPM_INSTALL_ENV } from './utils'
7
6
 
8
7
  export interface AllAgentsOptions {
9
- /** When true, also include OpenCode and Gemini CLI in the combined setup. */
8
+ /** When true, also include OpenCode in the combined setup. */
10
9
  full?: boolean
11
10
  }
12
11
 
@@ -14,10 +13,9 @@ export interface AllAgentsResult {
14
13
  claude: { settingsPath: string; vscodeSettingsPath: string }
15
14
  codex: { configPath: string; authPath: string; catalogPath: string }
16
15
  opencode?: { configPath: string }
17
- gemini?: { envPath: string; settingsPath: string }
18
16
  }
19
17
 
20
- /** Write configuration for the combined setup (Claude Code + Codex; optional OpenCode + Gemini CLI with --full). */
18
+ /** Write configuration for the combined setup (Claude Code + Codex; optional OpenCode with --full). */
21
19
  export async function writeAllAgentsConfig(
22
20
  apiKey: string,
23
21
  options: AllAgentsOptions = {}
@@ -32,29 +30,38 @@ export async function writeAllAgentsConfig(
32
30
 
33
31
  if (options.full) {
34
32
  result.opencode = writeOpencodeConfig(apiKey)
35
- result.gemini = writeGeminiConfig(apiKey)
36
33
  }
37
34
 
38
35
  return result
39
36
  }
40
37
 
41
- /** Install dependencies for the combined setup (Claude Code + Codex; optional OpenCode + Gemini CLI with --full). */
38
+ /** Install dependencies for the combined setup (Claude Code + Codex; optional OpenCode with --full). */
42
39
  export async function installAllAgentsDeps(
43
40
  options: AllAgentsOptions = {}
44
41
  ): Promise<void> {
45
42
  const packages = ['@anthropic-ai/claude-code', '@openai/codex']
46
43
  if (options.full) {
47
- packages.push('opencode-ai', '@google/gemini-cli')
44
+ packages.push('opencode-ai')
48
45
  }
49
46
 
50
47
  const usePnpm = await commandExists('pnpm')
51
48
 
52
49
  if (usePnpm) {
53
50
  console.log('pnpm detected. Installing agent dependencies with pnpm...')
54
- await execa('pnpm', ['add', '-g', ...packages], {
55
- stdio: 'inherit',
56
- env: PNPM_INSTALL_ENV,
57
- })
51
+ await execa(
52
+ 'pnpm',
53
+ [
54
+ '--allow-build=@anthropic-ai/claude-code',
55
+ 'add',
56
+ '-g',
57
+ '--force',
58
+ ...packages,
59
+ ],
60
+ {
61
+ stdio: 'inherit',
62
+ env: PNPM_INSTALL_ENV,
63
+ }
64
+ )
58
65
  } else {
59
66
  console.log('pnpm not found. Falling back to npm...')
60
67
  await execa('npm', ['install', '-g', ...packages], { stdio: 'inherit' })
@@ -7,6 +7,8 @@ jest.mock('execa', () => ({
7
7
  }))
8
8
 
9
9
  import { writeClaudeConfig } from './claude-code'
10
+ import { installDeps } from './claude-code'
11
+ import { execa } from 'execa'
10
12
 
11
13
  function getVSCodeUserSettingsPath(homeDir: string): string {
12
14
  if (process.platform === 'darwin') {
@@ -103,4 +105,36 @@ describe('writeClaudeConfig', () => {
103
105
  `VSCode settings is not valid JSONC: ${vscodeSettingsPath}. Please fix it and retry.`
104
106
  )
105
107
  })
108
+
109
+ test('allows Claude postinstall build when installing with pnpm', async () => {
110
+ const execaMock = jest.mocked(execa)
111
+ execaMock
112
+ .mockResolvedValueOnce({ failed: false } as never)
113
+ .mockResolvedValueOnce({} as never)
114
+
115
+ await installDeps()
116
+
117
+ expect(execaMock).toHaveBeenNthCalledWith(1, 'pnpm', ['--version'], {
118
+ stdio: 'ignore',
119
+ reject: false,
120
+ })
121
+ expect(execaMock).toHaveBeenNthCalledWith(
122
+ 2,
123
+ 'pnpm',
124
+ [
125
+ '--allow-build=@anthropic-ai/claude-code',
126
+ 'add',
127
+ '-g',
128
+ '--force',
129
+ '@anthropic-ai/claude-code',
130
+ ],
131
+ {
132
+ stdio: 'inherit',
133
+ env: {
134
+ PNPM_CONFIG_ENABLE_PRE_POST_SCRIPTS: 'true',
135
+ },
136
+ }
137
+ )
138
+ expect(execaMock).toHaveBeenCalledTimes(2)
139
+ })
106
140
  })
@@ -152,10 +152,20 @@ export async function installDeps(): Promise<void> {
152
152
 
153
153
  if (usePnpm) {
154
154
  console.log('pnpm detected. Installing dependencies with pnpm...')
155
- await execa('pnpm', ['add', '-g', ...packages], {
156
- stdio: 'inherit',
157
- env: PNPM_INSTALL_ENV,
158
- })
155
+ await execa(
156
+ 'pnpm',
157
+ [
158
+ '--allow-build=@anthropic-ai/claude-code',
159
+ 'add',
160
+ '-g',
161
+ '--force',
162
+ ...packages,
163
+ ],
164
+ {
165
+ stdio: 'inherit',
166
+ env: PNPM_INSTALL_ENV,
167
+ }
168
+ )
159
169
  } else {
160
170
  console.log('pnpm not found. Falling back to npm...')
161
171
  await execa('npm', ['install', '-g', ...packages], { stdio: 'inherit' })
package/libs/index.ts CHANGED
@@ -52,9 +52,6 @@ export { writeClaudeConfig, installDeps } from './claude-code'
52
52
  // Re-export codex functionality
53
53
  export { writeCodexConfig, installCodexDeps } from './codex'
54
54
 
55
- // Re-export gemini-cli functionality
56
- export { writeGeminiConfig, installGeminiDeps } from './gemini-cli'
57
-
58
55
  // Re-export opencode functionality
59
56
  export { writeOpencodeConfig, installOpencodeDeps } from './opencode'
60
57
 
@@ -64,9 +64,6 @@ describe('writeOpencodeConfig', () => {
64
64
  expect(config.provider.MyCustomProvider.models.deepseek).toEqual(
65
65
  expectedModelConfig('deepseek')
66
66
  )
67
- expect(config.provider.MyCustomProvider.models['gemini-flash']).toEqual(
68
- expectedModelConfig('gemini-flash')
69
- )
70
67
  expect(config.model).toBe('MyCustomProvider/code')
71
68
  expect(config.small_model).toBe('MyCustomProvider/code')
72
69
  })
package/libs/opencode.ts CHANGED
@@ -12,7 +12,6 @@ const OPENCODE_MODEL_IDS = [
12
12
  'kimi',
13
13
  'minimax',
14
14
  'deepseek',
15
- 'gemini-flash',
16
15
  ]
17
16
  const OPENCODE_BASE_URL = 'https://ai.gengjiawen.com/api/openai/v1'
18
17
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gengjiawen/os-init",
3
3
  "private": false,
4
- "version": "1.23.0",
4
+ "version": "1.23.1",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "bin": {
@@ -1,5 +0,0 @@
1
- export declare function writeGeminiConfig(apiKey: string): {
2
- envPath: string;
3
- settingsPath: string;
4
- };
5
- export declare function installGeminiDeps(): Promise<void>;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeGeminiConfig = writeGeminiConfig;
4
- exports.installGeminiDeps = installGeminiDeps;
5
- const fs = require("fs");
6
- const path = require("path");
7
- const os = require("os");
8
- const execa_1 = require("execa");
9
- const utils_1 = require("./utils");
10
- function getGeminiConfigDir() {
11
- return path.join(os.homedir(), '.gemini');
12
- }
13
- const GEMINI_ENV_TEMPLATE = `GOOGLE_GEMINI_BASE_URL=https://ai.gengjiawen.com/api/gemini
14
- GEMINI_API_KEY=API_KEY_PLACEHOLDER
15
- GEMINI_MODEL=gemini-3-pro-preview
16
- `;
17
- const GEMINI_SETTINGS_TEMPLATE = {
18
- ide: {
19
- enabled: true,
20
- },
21
- security: {
22
- auth: {
23
- selectedType: 'gemini-api-key',
24
- },
25
- },
26
- };
27
- function writeGeminiConfig(apiKey) {
28
- const configDir = getGeminiConfigDir();
29
- (0, utils_1.ensureDir)(configDir);
30
- const envPath = path.join(configDir, '.env');
31
- const envContent = GEMINI_ENV_TEMPLATE.replace('API_KEY_PLACEHOLDER', apiKey);
32
- fs.writeFileSync(envPath, envContent);
33
- const settingsPath = path.join(configDir, 'settings.json');
34
- fs.writeFileSync(settingsPath, JSON.stringify(GEMINI_SETTINGS_TEMPLATE, null, 2));
35
- return { envPath, settingsPath };
36
- }
37
- async function installGeminiDeps() {
38
- const usePnpm = await (0, utils_1.commandExists)('pnpm');
39
- const geminiPackage = '@google/gemini-cli';
40
- if (usePnpm) {
41
- console.log('pnpm detected. Installing Gemini CLI with pnpm...');
42
- await (0, execa_1.execa)('pnpm', ['add', '-g', geminiPackage], {
43
- stdio: 'inherit',
44
- env: utils_1.PNPM_INSTALL_ENV,
45
- });
46
- }
47
- else {
48
- console.log('pnpm not found. Falling back to npm...');
49
- await (0, execa_1.execa)('npm', ['install', '-g', geminiPackage], { stdio: 'inherit' });
50
- }
51
- console.log('Gemini CLI installed successfully.');
52
- }
@@ -1,69 +0,0 @@
1
- import * as fs from 'fs'
2
- import * as path from 'path'
3
- import * as os from 'os'
4
- import { execa } from 'execa'
5
- import { ensureDir, commandExists, PNPM_INSTALL_ENV } from './utils'
6
-
7
- /** Return Gemini CLI configuration directory path */
8
- function getGeminiConfigDir(): string {
9
- return path.join(os.homedir(), '.gemini')
10
- }
11
-
12
- /** Template for Gemini CLI .env file */
13
- const GEMINI_ENV_TEMPLATE = `GOOGLE_GEMINI_BASE_URL=https://ai.gengjiawen.com/api/gemini
14
- GEMINI_API_KEY=API_KEY_PLACEHOLDER
15
- GEMINI_MODEL=gemini-3-pro-preview
16
- `
17
-
18
- /** Template for Gemini CLI settings.json */
19
- const GEMINI_SETTINGS_TEMPLATE = {
20
- ide: {
21
- enabled: true,
22
- },
23
- security: {
24
- auth: {
25
- selectedType: 'gemini-api-key',
26
- },
27
- },
28
- }
29
-
30
- /** Write Gemini CLI config files (.env and settings.json) */
31
- export function writeGeminiConfig(apiKey: string): {
32
- envPath: string
33
- settingsPath: string
34
- } {
35
- const configDir = getGeminiConfigDir()
36
- ensureDir(configDir)
37
-
38
- // Write .env file
39
- const envPath = path.join(configDir, '.env')
40
- const envContent = GEMINI_ENV_TEMPLATE.replace('API_KEY_PLACEHOLDER', apiKey)
41
- fs.writeFileSync(envPath, envContent)
42
-
43
- // Write settings.json file
44
- const settingsPath = path.join(configDir, 'settings.json')
45
- fs.writeFileSync(
46
- settingsPath,
47
- JSON.stringify(GEMINI_SETTINGS_TEMPLATE, null, 2)
48
- )
49
-
50
- return { envPath, settingsPath }
51
- }
52
-
53
- /** Install Gemini CLI dependency */
54
- export async function installGeminiDeps(): Promise<void> {
55
- const usePnpm = await commandExists('pnpm')
56
- const geminiPackage = '@google/gemini-cli'
57
-
58
- if (usePnpm) {
59
- console.log('pnpm detected. Installing Gemini CLI with pnpm...')
60
- await execa('pnpm', ['add', '-g', geminiPackage], {
61
- stdio: 'inherit',
62
- env: PNPM_INSTALL_ENV,
63
- })
64
- } else {
65
- console.log('pnpm not found. Falling back to npm...')
66
- await execa('npm', ['install', '-g', geminiPackage], { stdio: 'inherit' })
67
- }
68
- console.log('Gemini CLI installed successfully.')
69
- }