@gengjiawen/os-init 1.26.1 → 1.26.3
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/CHANGELOG.md +15 -0
- package/README.md +3 -4
- package/bin/bin.js +6 -8
- package/build/all-agents.d.ts +0 -1
- package/build/codex.d.ts +1 -2
- package/build/codex.js +12 -13
- package/libs/all-agents.test.ts +0 -1
- package/libs/all-agents.ts +1 -1
- package/libs/codex.test.ts +35 -6
- package/libs/codex.ts +18 -16
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.26.3](https://github.com/gengjiawen/os-init/compare/v1.26.2...v1.26.3) (2026-06-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* disable codex update check on startup ([43a4c68](https://github.com/gengjiawen/os-init/commit/43a4c68eede37d2b5d73ee199d8dded86f6a61b9))
|
|
9
|
+
* use codex bearer token config ([38a49de](https://github.com/gengjiawen/os-init/commit/38a49de58af44040507ee87205f326a5fa5eeacb))
|
|
10
|
+
|
|
11
|
+
## [1.26.2](https://github.com/gengjiawen/os-init/compare/v1.26.1...v1.26.2) (2026-06-11)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* set codex reasoning effort to high ([0211fab](https://github.com/gengjiawen/os-init/commit/0211fab79a984ba7b12ead089ce80aa3cf1116d8))
|
|
17
|
+
|
|
3
18
|
## [1.26.1](https://github.com/gengjiawen/os-init/compare/v1.26.0...v1.26.1) (2026-06-05)
|
|
4
19
|
|
|
5
20
|
|
package/README.md
CHANGED
|
@@ -135,13 +135,12 @@ Configures Claude Code with your API key. This command will:
|
|
|
135
135
|
### Configure Codex CLI
|
|
136
136
|
|
|
137
137
|
```bash
|
|
138
|
-
pnpx @gengjiawen/os-init set-codex <
|
|
138
|
+
pnpx @gengjiawen/os-init set-codex <BEARER_TOKEN>
|
|
139
139
|
```
|
|
140
140
|
|
|
141
|
-
Configures Codex CLI with your
|
|
141
|
+
Configures Codex CLI with your bearer token. This command will:
|
|
142
142
|
|
|
143
|
-
- Write `~/.codex/config.toml`
|
|
144
|
-
- Write `~/.codex/auth.json`
|
|
143
|
+
- Write `~/.codex/config.toml` with `experimental_bearer_token`
|
|
145
144
|
- Install global tool: `@openai/codex`
|
|
146
145
|
|
|
147
146
|
### Configure OpenCode CLI
|
package/bin/bin.js
CHANGED
|
@@ -56,18 +56,17 @@ program
|
|
|
56
56
|
|
|
57
57
|
program
|
|
58
58
|
.command('set-codex')
|
|
59
|
-
.description('setup codex cli config
|
|
60
|
-
.argument('<
|
|
61
|
-
.action(async (
|
|
62
|
-
if (!
|
|
63
|
-
console.error('Missing required argument: <
|
|
59
|
+
.description('setup codex cli config')
|
|
60
|
+
.argument('<bearerToken>', 'Bearer token to set for Codex')
|
|
61
|
+
.action(async (bearerToken) => {
|
|
62
|
+
if (!bearerToken || String(bearerToken).trim().length === 0) {
|
|
63
|
+
console.error('Missing required argument: <bearerToken>')
|
|
64
64
|
program.help({ error: true })
|
|
65
65
|
return
|
|
66
66
|
}
|
|
67
67
|
try {
|
|
68
|
-
const { configPath
|
|
68
|
+
const { configPath } = writeCodexConfig(bearerToken)
|
|
69
69
|
console.log(`Codex config written to: ${configPath}`)
|
|
70
|
-
console.log(`Codex auth written to: ${authPath}`)
|
|
71
70
|
await installCodexDeps()
|
|
72
71
|
} catch (err) {
|
|
73
72
|
console.error('Failed to setup Codex:', err.message)
|
|
@@ -132,7 +131,6 @@ program
|
|
|
132
131
|
|
|
133
132
|
console.log('\nCodex:')
|
|
134
133
|
console.log(` Config written to: ${result.codex.configPath}`)
|
|
135
|
-
console.log(` Auth written to: ${result.codex.authPath}`)
|
|
136
134
|
|
|
137
135
|
if (result.opencode) {
|
|
138
136
|
console.log('\nOpenCode:')
|
package/build/all-agents.d.ts
CHANGED
package/build/codex.d.ts
CHANGED
package/build/codex.js
CHANGED
|
@@ -12,19 +12,20 @@ const CODEX_BASE_URL = 'https://ai.gengjiawen.com/api/openai';
|
|
|
12
12
|
function getCodexConfigDir() {
|
|
13
13
|
return path.join(os.homedir(), '.codex');
|
|
14
14
|
}
|
|
15
|
-
function getCodexConfigTomlTemplate() {
|
|
15
|
+
function getCodexConfigTomlTemplate(bearerToken) {
|
|
16
16
|
return `model_provider = "jw"
|
|
17
17
|
model = "gpt-5.5"
|
|
18
|
-
model_reasoning_effort = "
|
|
19
|
-
plan_mode_reasoning_effort = "
|
|
18
|
+
model_reasoning_effort = "high"
|
|
19
|
+
plan_mode_reasoning_effort = "high"
|
|
20
20
|
model_auto_compact_token_limit = 131072
|
|
21
21
|
disable_response_storage = true
|
|
22
|
-
|
|
22
|
+
check_for_update_on_startup = false
|
|
23
23
|
|
|
24
24
|
[model_providers.jw]
|
|
25
25
|
name = "jw"
|
|
26
26
|
base_url = "${CODEX_BASE_URL}"
|
|
27
27
|
wire_api = "responses"
|
|
28
|
+
experimental_bearer_token = ${JSON.stringify(bearerToken)}
|
|
28
29
|
`;
|
|
29
30
|
}
|
|
30
31
|
function isTomlTable(value) {
|
|
@@ -50,26 +51,24 @@ function stripModelCatalogJsonFromToml(content) {
|
|
|
50
51
|
.filter((line) => !/^\s*model_catalog_json\s*=/.test(line))
|
|
51
52
|
.join('\n');
|
|
52
53
|
}
|
|
53
|
-
function getMergedCodexConfig(existingContent) {
|
|
54
|
+
function getMergedCodexConfig(existingContent, bearerToken) {
|
|
54
55
|
const sanitizedContent = stripModelCatalogJsonFromToml(existingContent);
|
|
55
56
|
const existingConfig = TOML.parse(sanitizedContent);
|
|
56
|
-
const templateConfig = TOML.parse(getCodexConfigTomlTemplate());
|
|
57
|
+
const templateConfig = TOML.parse(getCodexConfigTomlTemplate(bearerToken));
|
|
57
58
|
delete existingConfig.service_tier;
|
|
58
59
|
delete existingConfig.model_catalog_json;
|
|
60
|
+
delete existingConfig.preferred_auth_method;
|
|
59
61
|
return TOML.stringify(mergeTomlTables(existingConfig, templateConfig));
|
|
60
62
|
}
|
|
61
|
-
function writeCodexConfig(
|
|
63
|
+
function writeCodexConfig(bearerToken) {
|
|
62
64
|
const configDir = getCodexConfigDir();
|
|
63
65
|
(0, utils_1.ensureDir)(configDir);
|
|
64
66
|
const configPath = path.join(configDir, 'config.toml');
|
|
65
67
|
const configContent = fs.existsSync(configPath)
|
|
66
|
-
? getMergedCodexConfig(fs.readFileSync(configPath, 'utf8'))
|
|
67
|
-
: getCodexConfigTomlTemplate();
|
|
68
|
+
? getMergedCodexConfig(fs.readFileSync(configPath, 'utf8'), bearerToken)
|
|
69
|
+
: getCodexConfigTomlTemplate(bearerToken);
|
|
68
70
|
fs.writeFileSync(configPath, configContent);
|
|
69
|
-
|
|
70
|
-
const authContent = JSON.stringify({ OPENAI_API_KEY: apiKey }, null, 2);
|
|
71
|
-
fs.writeFileSync(authPath, authContent);
|
|
72
|
-
return { configPath, authPath };
|
|
71
|
+
return { configPath };
|
|
73
72
|
}
|
|
74
73
|
async function installCodexDeps() {
|
|
75
74
|
const packages = ['@openai/codex'];
|
package/libs/all-agents.test.ts
CHANGED
|
@@ -39,7 +39,6 @@ describe('writeAllAgentsConfig', () => {
|
|
|
39
39
|
|
|
40
40
|
expect(fs.existsSync(result.claude.settingsPath)).toBe(true)
|
|
41
41
|
expect(fs.existsSync(result.codex.configPath)).toBe(true)
|
|
42
|
-
expect(fs.existsSync(result.codex.authPath)).toBe(true)
|
|
43
42
|
expect(result.opencode).toBeUndefined()
|
|
44
43
|
})
|
|
45
44
|
|
package/libs/all-agents.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface AllAgentsOptions {
|
|
|
16
16
|
|
|
17
17
|
export interface AllAgentsResult {
|
|
18
18
|
claude: { settingsPath: string; vscodeSettingsPath: string }
|
|
19
|
-
codex: { configPath: string
|
|
19
|
+
codex: { configPath: string }
|
|
20
20
|
opencode?: { configPath: string }
|
|
21
21
|
}
|
|
22
22
|
|
package/libs/codex.test.ts
CHANGED
|
@@ -23,15 +23,37 @@ describe('writeCodexConfig', () => {
|
|
|
23
23
|
fs.rmSync(tempHome, { recursive: true, force: true })
|
|
24
24
|
})
|
|
25
25
|
|
|
26
|
-
test('writes config with 128k auto compact threshold', () => {
|
|
26
|
+
test('writes config with bearer token and 128k auto compact threshold', () => {
|
|
27
27
|
const result = writeCodexConfig('test-api-key')
|
|
28
|
+
const configPath = path.join(tempHome, '.codex', 'config.toml')
|
|
29
|
+
const authPath = path.join(tempHome, '.codex', 'auth.json')
|
|
28
30
|
const config = TOML.parse(fs.readFileSync(result.configPath, 'utf8')) as {
|
|
29
31
|
model_auto_compact_token_limit: number
|
|
32
|
+
model_providers: {
|
|
33
|
+
jw: {
|
|
34
|
+
experimental_bearer_token: string
|
|
35
|
+
}
|
|
36
|
+
}
|
|
30
37
|
}
|
|
31
38
|
|
|
39
|
+
expect(result.configPath).toBe(configPath)
|
|
32
40
|
expect(config.model_auto_compact_token_limit).toBe(131072)
|
|
41
|
+
expect(config.model_providers.jw.experimental_bearer_token).toBe(
|
|
42
|
+
'test-api-key'
|
|
43
|
+
)
|
|
33
44
|
expect(config).not.toHaveProperty('model_catalog_json')
|
|
34
|
-
expect(fs.existsSync(
|
|
45
|
+
expect(fs.existsSync(authPath)).toBe(false)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
test('writes codex reasoning efforts as high', () => {
|
|
49
|
+
const result = writeCodexConfig('test-api-key')
|
|
50
|
+
const config = TOML.parse(fs.readFileSync(result.configPath, 'utf8')) as {
|
|
51
|
+
model_reasoning_effort: string
|
|
52
|
+
plan_mode_reasoning_effort: string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
expect(config.model_reasoning_effort).toBe('high')
|
|
56
|
+
expect(config.plan_mode_reasoning_effort).toBe('high')
|
|
35
57
|
})
|
|
36
58
|
|
|
37
59
|
test('merges template keys and keeps custom config', () => {
|
|
@@ -54,11 +76,11 @@ custom_model = "keep-me"
|
|
|
54
76
|
const config = TOML.parse(fs.readFileSync(configPath, 'utf8')) as {
|
|
55
77
|
custom_flag: boolean
|
|
56
78
|
model: string
|
|
57
|
-
preferred_auth_method: string
|
|
58
79
|
model_providers: {
|
|
59
80
|
jw: {
|
|
60
81
|
base_url: string
|
|
61
82
|
custom_model: string
|
|
83
|
+
experimental_bearer_token: string
|
|
62
84
|
name: string
|
|
63
85
|
}
|
|
64
86
|
}
|
|
@@ -68,11 +90,14 @@ custom_model = "keep-me"
|
|
|
68
90
|
expect(config).not.toHaveProperty('model_catalog_json')
|
|
69
91
|
expect(config.custom_flag).toBe(true)
|
|
70
92
|
expect(config.model).toBe('gpt-5.5')
|
|
71
|
-
expect(config
|
|
93
|
+
expect(config).not.toHaveProperty('preferred_auth_method')
|
|
72
94
|
expect(config.model_providers.jw.base_url).toBe(
|
|
73
95
|
'https://ai.gengjiawen.com/api/openai'
|
|
74
96
|
)
|
|
75
97
|
expect(config.model_providers.jw.custom_model).toBe('keep-me')
|
|
98
|
+
expect(config.model_providers.jw.experimental_bearer_token).toBe(
|
|
99
|
+
'test-api-key'
|
|
100
|
+
)
|
|
76
101
|
expect(config.model_providers.jw.name).toBe('jw')
|
|
77
102
|
})
|
|
78
103
|
|
|
@@ -84,6 +109,7 @@ custom_model = "keep-me"
|
|
|
84
109
|
fs.writeFileSync(
|
|
85
110
|
configPath,
|
|
86
111
|
`service_tier = "slow"
|
|
112
|
+
preferred_auth_method = "apikey"
|
|
87
113
|
|
|
88
114
|
[model_providers.jw]
|
|
89
115
|
base_url = "https://example.com"
|
|
@@ -93,19 +119,22 @@ base_url = "https://example.com"
|
|
|
93
119
|
writeCodexConfig('test-api-key')
|
|
94
120
|
const config = TOML.parse(fs.readFileSync(configPath, 'utf8')) as {
|
|
95
121
|
model: string
|
|
96
|
-
preferred_auth_method: string
|
|
97
122
|
model_providers: {
|
|
98
123
|
jw: {
|
|
99
124
|
name: string
|
|
100
125
|
base_url: string
|
|
126
|
+
experimental_bearer_token: string
|
|
101
127
|
}
|
|
102
128
|
}
|
|
103
129
|
}
|
|
104
130
|
|
|
105
131
|
expect(config.model).toBe('gpt-5.5')
|
|
106
132
|
expect(config).not.toHaveProperty('model_catalog_json')
|
|
107
|
-
expect(config
|
|
133
|
+
expect(config).not.toHaveProperty('preferred_auth_method')
|
|
108
134
|
expect(config.model_providers.jw.name).toBe('jw')
|
|
135
|
+
expect(config.model_providers.jw.experimental_bearer_token).toBe(
|
|
136
|
+
'test-api-key'
|
|
137
|
+
)
|
|
109
138
|
expect(config).not.toHaveProperty('service_tier')
|
|
110
139
|
})
|
|
111
140
|
|
package/libs/codex.ts
CHANGED
|
@@ -14,19 +14,20 @@ function getCodexConfigDir(): string {
|
|
|
14
14
|
return path.join(os.homedir(), '.codex')
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function getCodexConfigTomlTemplate(): string {
|
|
17
|
+
function getCodexConfigTomlTemplate(bearerToken: string): string {
|
|
18
18
|
return `model_provider = "jw"
|
|
19
19
|
model = "gpt-5.5"
|
|
20
|
-
model_reasoning_effort = "
|
|
21
|
-
plan_mode_reasoning_effort = "
|
|
20
|
+
model_reasoning_effort = "high"
|
|
21
|
+
plan_mode_reasoning_effort = "high"
|
|
22
22
|
model_auto_compact_token_limit = 131072
|
|
23
23
|
disable_response_storage = true
|
|
24
|
-
|
|
24
|
+
check_for_update_on_startup = false
|
|
25
25
|
|
|
26
26
|
[model_providers.jw]
|
|
27
27
|
name = "jw"
|
|
28
28
|
base_url = "${CODEX_BASE_URL}"
|
|
29
29
|
wire_api = "responses"
|
|
30
|
+
experimental_bearer_token = ${JSON.stringify(bearerToken)}
|
|
30
31
|
`
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -65,35 +66,36 @@ function stripModelCatalogJsonFromToml(content: string): string {
|
|
|
65
66
|
.join('\n')
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
function getMergedCodexConfig(
|
|
69
|
+
function getMergedCodexConfig(
|
|
70
|
+
existingContent: string,
|
|
71
|
+
bearerToken: string
|
|
72
|
+
): string {
|
|
69
73
|
const sanitizedContent = stripModelCatalogJsonFromToml(existingContent)
|
|
70
74
|
const existingConfig = TOML.parse(sanitizedContent) as TomlTable
|
|
71
|
-
const templateConfig = TOML.parse(
|
|
75
|
+
const templateConfig = TOML.parse(
|
|
76
|
+
getCodexConfigTomlTemplate(bearerToken)
|
|
77
|
+
) as TomlTable
|
|
72
78
|
delete existingConfig.service_tier
|
|
73
79
|
delete existingConfig.model_catalog_json
|
|
80
|
+
delete existingConfig.preferred_auth_method
|
|
74
81
|
|
|
75
82
|
return TOML.stringify(mergeTomlTables(existingConfig, templateConfig))
|
|
76
83
|
}
|
|
77
84
|
|
|
78
|
-
/** Write Codex config.toml
|
|
79
|
-
export function writeCodexConfig(
|
|
85
|
+
/** Write Codex config.toml */
|
|
86
|
+
export function writeCodexConfig(bearerToken: string): {
|
|
80
87
|
configPath: string
|
|
81
|
-
authPath: string
|
|
82
88
|
} {
|
|
83
89
|
const configDir = getCodexConfigDir()
|
|
84
90
|
ensureDir(configDir)
|
|
85
91
|
|
|
86
92
|
const configPath = path.join(configDir, 'config.toml')
|
|
87
93
|
const configContent = fs.existsSync(configPath)
|
|
88
|
-
? getMergedCodexConfig(fs.readFileSync(configPath, 'utf8'))
|
|
89
|
-
: getCodexConfigTomlTemplate()
|
|
94
|
+
? getMergedCodexConfig(fs.readFileSync(configPath, 'utf8'), bearerToken)
|
|
95
|
+
: getCodexConfigTomlTemplate(bearerToken)
|
|
90
96
|
fs.writeFileSync(configPath, configContent)
|
|
91
97
|
|
|
92
|
-
|
|
93
|
-
const authContent = JSON.stringify({ OPENAI_API_KEY: apiKey }, null, 2)
|
|
94
|
-
fs.writeFileSync(authPath, authContent)
|
|
95
|
-
|
|
96
|
-
return { configPath, authPath }
|
|
98
|
+
return { configPath }
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
/** Install Codex dependency */
|