@gengjiawen/os-init 1.22.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 +2 -2
- package/CHANGELOG.md +19 -0
- package/bin/bin.js +3 -36
- package/build/all-agents.d.ts +0 -4
- package/build/all-agents.js +23 -5
- package/build/claude-code.js +7 -1
- package/build/codex.js +1 -1
- package/build/index.d.ts +0 -1
- package/build/index.js +1 -4
- package/build/opencode.js +0 -1
- package/libs/all-agents.test.ts +64 -7
- package/libs/all-agents.ts +35 -12
- package/libs/claude-code.test.ts +34 -0
- package/libs/claude-code.ts +14 -4
- package/libs/codex.test.ts +7 -7
- package/libs/codex.ts +1 -1
- package/libs/index.ts +0 -3
- package/libs/opencode.test.ts +0 -3
- package/libs/opencode.ts +0 -1
- package/macOS-init.md +1 -1
- package/package.json +2 -2
- package/build/gemini-cli.d.ts +0 -5
- package/build/gemini-cli.js +0 -52
- package/libs/gemini-cli.ts +0 -69
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-
|
|
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., `
|
|
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,24 @@
|
|
|
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
|
+
|
|
10
|
+
## [1.23.0](https://github.com/gengjiawen/os-init/compare/v1.22.0...v1.23.0) (2026-04-24)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* bump default Codex model to gpt-5.5 ([7104f50](https://github.com/gengjiawen/os-init/commit/7104f50d2e3af71e48aa0e88306b36d686fffb42))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* combine set-agents dependency installs ([5edbad1](https://github.com/gengjiawen/os-init/commit/5edbad1689d834cb8ead4cfc8e05a15e015c2c2f))
|
|
21
|
+
|
|
3
22
|
## [1.22.0](https://github.com/gengjiawen/os-init/compare/v1.21.0...v1.22.0) (2026-04-17)
|
|
4
23
|
|
|
5
24
|
|
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
|
|
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
|
|
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
|
|
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
|
|
package/build/all-agents.d.ts
CHANGED
|
@@ -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>;
|
package/build/all-agents.js
CHANGED
|
@@ -4,8 +4,9 @@ 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");
|
|
8
|
+
const execa_1 = require("execa");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
9
10
|
async function writeAllAgentsConfig(apiKey, options = {}) {
|
|
10
11
|
const claudeResult = (0, claude_code_1.writeClaudeConfig)(apiKey);
|
|
11
12
|
const codexResult = await (0, codex_1.writeCodexConfig)(apiKey);
|
|
@@ -15,14 +16,31 @@ async function writeAllAgentsConfig(apiKey, options = {}) {
|
|
|
15
16
|
};
|
|
16
17
|
if (options.full) {
|
|
17
18
|
result.opencode = (0, opencode_1.writeOpencodeConfig)(apiKey);
|
|
18
|
-
result.gemini = (0, gemini_cli_1.writeGeminiConfig)(apiKey);
|
|
19
19
|
}
|
|
20
20
|
return result;
|
|
21
21
|
}
|
|
22
22
|
async function installAllAgentsDeps(options = {}) {
|
|
23
|
-
const
|
|
23
|
+
const packages = ['@anthropic-ai/claude-code', '@openai/codex'];
|
|
24
24
|
if (options.full) {
|
|
25
|
-
|
|
25
|
+
packages.push('opencode-ai');
|
|
26
26
|
}
|
|
27
|
-
await
|
|
27
|
+
const usePnpm = await (0, utils_1.commandExists)('pnpm');
|
|
28
|
+
if (usePnpm) {
|
|
29
|
+
console.log('pnpm detected. Installing agent dependencies with pnpm...');
|
|
30
|
+
await (0, execa_1.execa)('pnpm', [
|
|
31
|
+
'--allow-build=@anthropic-ai/claude-code',
|
|
32
|
+
'add',
|
|
33
|
+
'-g',
|
|
34
|
+
'--force',
|
|
35
|
+
...packages,
|
|
36
|
+
], {
|
|
37
|
+
stdio: 'inherit',
|
|
38
|
+
env: utils_1.PNPM_INSTALL_ENV,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.log('pnpm not found. Falling back to npm...');
|
|
43
|
+
await (0, execa_1.execa)('npm', ['install', '-g', ...packages], { stdio: 'inherit' });
|
|
44
|
+
}
|
|
45
|
+
console.log('Agent dependencies installed successfully.');
|
|
28
46
|
}
|
package/build/claude-code.js
CHANGED
|
@@ -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', [
|
|
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/codex.js
CHANGED
|
@@ -24,7 +24,7 @@ function getCodexModelCatalogConfigPath() {
|
|
|
24
24
|
}
|
|
25
25
|
function getCodexConfigTomlTemplate() {
|
|
26
26
|
return `model_provider = "jw"
|
|
27
|
-
model = "gpt-5.
|
|
27
|
+
model = "gpt-5.5"
|
|
28
28
|
model_reasoning_effort = "xhigh"
|
|
29
29
|
plan_mode_reasoning_effort = "xhigh"
|
|
30
30
|
model_auto_compact_token_limit = 131072
|
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.
|
|
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
package/libs/all-agents.test.ts
CHANGED
|
@@ -6,15 +6,18 @@ jest.mock('execa', () => ({
|
|
|
6
6
|
execa: jest.fn(),
|
|
7
7
|
}))
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { execa } from 'execa'
|
|
10
|
+
import { installAllAgentsDeps, writeAllAgentsConfig } from './all-agents'
|
|
10
11
|
|
|
11
12
|
describe('writeAllAgentsConfig', () => {
|
|
12
13
|
let tempHome: string
|
|
13
14
|
let homedirSpy: jest.SpiedFunction<typeof os.homedir>
|
|
14
15
|
let originalAppData: string | undefined
|
|
15
16
|
let originalFetch: typeof global.fetch | undefined
|
|
17
|
+
const execaMock = jest.mocked(execa)
|
|
16
18
|
|
|
17
19
|
beforeEach(() => {
|
|
20
|
+
jest.clearAllMocks()
|
|
18
21
|
tempHome = fs.mkdtempSync(path.join(os.tmpdir(), 'os-init-all-agents-'))
|
|
19
22
|
homedirSpy = jest.spyOn(os, 'homedir').mockReturnValue(tempHome)
|
|
20
23
|
originalAppData = process.env.APPDATA
|
|
@@ -22,7 +25,7 @@ describe('writeAllAgentsConfig', () => {
|
|
|
22
25
|
process.env.APPDATA = path.join(tempHome, 'AppData', 'Roaming')
|
|
23
26
|
global.fetch = jest.fn().mockResolvedValue({
|
|
24
27
|
ok: true,
|
|
25
|
-
json: async () => ({ models: [{ id: 'gpt-5.
|
|
28
|
+
json: async () => ({ models: [{ id: 'gpt-5.5' }] }),
|
|
26
29
|
}) as unknown as typeof global.fetch
|
|
27
30
|
})
|
|
28
31
|
|
|
@@ -49,16 +52,70 @@ describe('writeAllAgentsConfig', () => {
|
|
|
49
52
|
expect(fs.existsSync(result.codex.authPath)).toBe(true)
|
|
50
53
|
expect(fs.existsSync(result.codex.catalogPath)).toBe(true)
|
|
51
54
|
expect(result.opencode).toBeUndefined()
|
|
52
|
-
expect(result.gemini).toBeUndefined()
|
|
53
55
|
})
|
|
54
56
|
|
|
55
|
-
test('includes OpenCode
|
|
57
|
+
test('includes OpenCode config when full option is enabled', async () => {
|
|
56
58
|
const result = await writeAllAgentsConfig('test-api-key', { full: true })
|
|
57
59
|
|
|
58
60
|
expect(result.opencode).toBeDefined()
|
|
59
61
|
expect(fs.existsSync(result.opencode!.configPath)).toBe(true)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
test('installs Claude and Codex in one pnpm command', async () => {
|
|
65
|
+
execaMock
|
|
66
|
+
.mockResolvedValueOnce({ failed: false } as never)
|
|
67
|
+
.mockResolvedValueOnce({} as never)
|
|
68
|
+
|
|
69
|
+
await installAllAgentsDeps()
|
|
70
|
+
|
|
71
|
+
expect(execaMock).toHaveBeenNthCalledWith(1, 'pnpm', ['--version'], {
|
|
72
|
+
stdio: 'ignore',
|
|
73
|
+
reject: false,
|
|
74
|
+
})
|
|
75
|
+
expect(execaMock).toHaveBeenNthCalledWith(
|
|
76
|
+
2,
|
|
77
|
+
'pnpm',
|
|
78
|
+
[
|
|
79
|
+
'--allow-build=@anthropic-ai/claude-code',
|
|
80
|
+
'add',
|
|
81
|
+
'-g',
|
|
82
|
+
'--force',
|
|
83
|
+
'@anthropic-ai/claude-code',
|
|
84
|
+
'@openai/codex',
|
|
85
|
+
],
|
|
86
|
+
{
|
|
87
|
+
stdio: 'inherit',
|
|
88
|
+
env: {
|
|
89
|
+
PNPM_CONFIG_ENABLE_PRE_POST_SCRIPTS: 'true',
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
expect(execaMock).toHaveBeenCalledTimes(2)
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
test('installs all requested agents in one npm command when pnpm is unavailable', async () => {
|
|
97
|
+
execaMock
|
|
98
|
+
.mockRejectedValueOnce(new Error('pnpm not found'))
|
|
99
|
+
.mockResolvedValueOnce({} as never)
|
|
100
|
+
|
|
101
|
+
await installAllAgentsDeps({ full: true })
|
|
102
|
+
|
|
103
|
+
expect(execaMock).toHaveBeenNthCalledWith(1, 'pnpm', ['--version'], {
|
|
104
|
+
stdio: 'ignore',
|
|
105
|
+
reject: false,
|
|
106
|
+
})
|
|
107
|
+
expect(execaMock).toHaveBeenNthCalledWith(
|
|
108
|
+
2,
|
|
109
|
+
'npm',
|
|
110
|
+
[
|
|
111
|
+
'install',
|
|
112
|
+
'-g',
|
|
113
|
+
'@anthropic-ai/claude-code',
|
|
114
|
+
'@openai/codex',
|
|
115
|
+
'opencode-ai',
|
|
116
|
+
],
|
|
117
|
+
{ stdio: 'inherit' }
|
|
118
|
+
)
|
|
119
|
+
expect(execaMock).toHaveBeenCalledTimes(2)
|
|
63
120
|
})
|
|
64
121
|
})
|
package/libs/all-agents.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { writeClaudeConfig
|
|
2
|
-
import { writeCodexConfig
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { writeClaudeConfig } from './claude-code'
|
|
2
|
+
import { writeCodexConfig } from './codex'
|
|
3
|
+
import { writeOpencodeConfig } from './opencode'
|
|
4
|
+
import { execa } from 'execa'
|
|
5
|
+
import { commandExists, PNPM_INSTALL_ENV } from './utils'
|
|
5
6
|
|
|
6
7
|
export interface AllAgentsOptions {
|
|
7
|
-
/** When true, also include OpenCode
|
|
8
|
+
/** When true, also include OpenCode in the combined setup. */
|
|
8
9
|
full?: boolean
|
|
9
10
|
}
|
|
10
11
|
|
|
@@ -12,10 +13,9 @@ export interface AllAgentsResult {
|
|
|
12
13
|
claude: { settingsPath: string; vscodeSettingsPath: string }
|
|
13
14
|
codex: { configPath: string; authPath: string; catalogPath: string }
|
|
14
15
|
opencode?: { configPath: string }
|
|
15
|
-
gemini?: { envPath: string; settingsPath: string }
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
/** Write configuration for the combined setup (Claude Code + Codex; optional OpenCode
|
|
18
|
+
/** Write configuration for the combined setup (Claude Code + Codex; optional OpenCode with --full). */
|
|
19
19
|
export async function writeAllAgentsConfig(
|
|
20
20
|
apiKey: string,
|
|
21
21
|
options: AllAgentsOptions = {}
|
|
@@ -30,19 +30,42 @@ export async function writeAllAgentsConfig(
|
|
|
30
30
|
|
|
31
31
|
if (options.full) {
|
|
32
32
|
result.opencode = writeOpencodeConfig(apiKey)
|
|
33
|
-
result.gemini = writeGeminiConfig(apiKey)
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
return result
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
/** Install dependencies for the combined setup (Claude Code + Codex; optional OpenCode
|
|
38
|
+
/** Install dependencies for the combined setup (Claude Code + Codex; optional OpenCode with --full). */
|
|
40
39
|
export async function installAllAgentsDeps(
|
|
41
40
|
options: AllAgentsOptions = {}
|
|
42
41
|
): Promise<void> {
|
|
43
|
-
const
|
|
42
|
+
const packages = ['@anthropic-ai/claude-code', '@openai/codex']
|
|
44
43
|
if (options.full) {
|
|
45
|
-
|
|
44
|
+
packages.push('opencode-ai')
|
|
46
45
|
}
|
|
47
|
-
|
|
46
|
+
|
|
47
|
+
const usePnpm = await commandExists('pnpm')
|
|
48
|
+
|
|
49
|
+
if (usePnpm) {
|
|
50
|
+
console.log('pnpm detected. Installing agent dependencies with pnpm...')
|
|
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
|
+
)
|
|
65
|
+
} else {
|
|
66
|
+
console.log('pnpm not found. Falling back to npm...')
|
|
67
|
+
await execa('npm', ['install', '-g', ...packages], { stdio: 'inherit' })
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.log('Agent dependencies installed successfully.')
|
|
48
71
|
}
|
package/libs/claude-code.test.ts
CHANGED
|
@@ -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
|
})
|
package/libs/claude-code.ts
CHANGED
|
@@ -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(
|
|
156
|
-
|
|
157
|
-
|
|
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/codex.test.ts
CHANGED
|
@@ -22,7 +22,7 @@ describe('writeCodexConfig', () => {
|
|
|
22
22
|
|
|
23
23
|
function mockCatalogFetch(
|
|
24
24
|
catalog: { models: Array<Record<string, unknown>> } = {
|
|
25
|
-
models: [{ id: 'gpt-5.
|
|
25
|
+
models: [{ id: 'gpt-5.5' }],
|
|
26
26
|
}
|
|
27
27
|
): jest.Mock {
|
|
28
28
|
const fetchMock = jest.fn().mockResolvedValue({
|
|
@@ -95,7 +95,7 @@ custom_model = "keep-me"
|
|
|
95
95
|
|
|
96
96
|
expect(config).not.toHaveProperty('service_tier')
|
|
97
97
|
expect(config.custom_flag).toBe(true)
|
|
98
|
-
expect(config.model).toBe('gpt-5.
|
|
98
|
+
expect(config.model).toBe('gpt-5.5')
|
|
99
99
|
expect(config.model_catalog_json).toBe(getExpectedModelCatalogConfigPath())
|
|
100
100
|
expect(config.preferred_auth_method).toBe('apikey')
|
|
101
101
|
expect(config.model_providers.jw.base_url).toBe(
|
|
@@ -132,7 +132,7 @@ base_url = "https://example.com"
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
expect(config.model).toBe('gpt-5.
|
|
135
|
+
expect(config.model).toBe('gpt-5.5')
|
|
136
136
|
expect(config.model_catalog_json).toBe(getExpectedModelCatalogConfigPath())
|
|
137
137
|
expect(config.preferred_auth_method).toBe('apikey')
|
|
138
138
|
expect(config.model_providers.jw.name).toBe('jw')
|
|
@@ -142,8 +142,8 @@ base_url = "https://example.com"
|
|
|
142
142
|
test('refreshes remote model catalog after writing config', async () => {
|
|
143
143
|
const fetchMock = mockCatalogFetch({
|
|
144
144
|
models: [
|
|
145
|
-
{ id: 'gpt-5.
|
|
146
|
-
{ id: 'gpt-5.
|
|
145
|
+
{ id: 'gpt-5.5' },
|
|
146
|
+
{ id: 'gpt-5.5-mini' },
|
|
147
147
|
{ id: 'gpt-5.3-codex' },
|
|
148
148
|
],
|
|
149
149
|
})
|
|
@@ -167,8 +167,8 @@ base_url = "https://example.com"
|
|
|
167
167
|
|
|
168
168
|
expect(catalog).toEqual({
|
|
169
169
|
models: [
|
|
170
|
-
{ id: 'gpt-5.
|
|
171
|
-
{ id: 'gpt-5.
|
|
170
|
+
{ id: 'gpt-5.5' },
|
|
171
|
+
{ id: 'gpt-5.5-mini' },
|
|
172
172
|
{ id: 'gpt-5.3-codex' },
|
|
173
173
|
],
|
|
174
174
|
})
|
package/libs/codex.ts
CHANGED
|
@@ -29,7 +29,7 @@ function getCodexModelCatalogConfigPath(): string {
|
|
|
29
29
|
|
|
30
30
|
function getCodexConfigTomlTemplate(): string {
|
|
31
31
|
return `model_provider = "jw"
|
|
32
|
-
model = "gpt-5.
|
|
32
|
+
model = "gpt-5.5"
|
|
33
33
|
model_reasoning_effort = "xhigh"
|
|
34
34
|
plan_mode_reasoning_effort = "xhigh"
|
|
35
35
|
model_auto_compact_token_limit = 131072
|
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
|
|
package/libs/opencode.test.ts
CHANGED
|
@@ -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
package/macOS-init.md
CHANGED
|
@@ -25,7 +25,7 @@ brew install jordanbaird-ice
|
|
|
25
25
|
sudo git lfs install --system
|
|
26
26
|
npm i -g pnpm yarn && pnpm setup
|
|
27
27
|
pnpm i -g vite 7zip-bin-full
|
|
28
|
-
sudo ln -s "$(NODE_PATH="$(pnpm root -g)" node -p "require('7zip-bin-full').
|
|
28
|
+
sudo ln -s "$(NODE_PATH="$(pnpm root -g)" node -p "require('7zip-bin-full').path7z")" /usr/local/bin/7z
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gengjiawen/os-init",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.23.1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"bin": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"lint-staged": "^15.2.2",
|
|
47
47
|
"nodemon": "3.1.4",
|
|
48
48
|
"prettier": "3.5.3",
|
|
49
|
-
"rimraf": "6.1.
|
|
49
|
+
"rimraf": "6.1.3",
|
|
50
50
|
"ts-jest": "29.4.9",
|
|
51
51
|
"ts-node": "^10.9.1",
|
|
52
52
|
"typescript": "5.6.3"
|
package/build/gemini-cli.d.ts
DELETED
package/build/gemini-cli.js
DELETED
|
@@ -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
|
-
}
|
package/libs/gemini-cli.ts
DELETED
|
@@ -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
|
-
}
|