@gengjiawen/os-init 1.26.2 → 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 CHANGED
@@ -1,5 +1,13 @@
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
+
3
11
  ## [1.26.2](https://github.com/gengjiawen/os-init/compare/v1.26.1...v1.26.2) (2026-06-11)
4
12
 
5
13
 
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 <API_KEY>
138
+ pnpx @gengjiawen/os-init set-codex <BEARER_TOKEN>
139
139
  ```
140
140
 
141
- Configures Codex CLI with your API key. This command will:
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 and auth')
60
- .argument('<apiKey>', 'API key to set for Codex')
61
- .action(async (apiKey) => {
62
- if (!apiKey || String(apiKey).trim().length === 0) {
63
- console.error('Missing required argument: <apiKey>')
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, authPath } = writeCodexConfig(apiKey)
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:')
@@ -8,7 +8,6 @@ export interface AllAgentsResult {
8
8
  };
9
9
  codex: {
10
10
  configPath: string;
11
- authPath: string;
12
11
  };
13
12
  opencode?: {
14
13
  configPath: string;
package/build/codex.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- export declare function writeCodexConfig(apiKey: string): {
1
+ export declare function writeCodexConfig(bearerToken: string): {
2
2
  configPath: string;
3
- authPath: string;
4
3
  };
5
4
  export declare function installCodexDeps(): Promise<void>;
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
18
  model_reasoning_effort = "high"
19
19
  plan_mode_reasoning_effort = "high"
20
20
  model_auto_compact_token_limit = 131072
21
21
  disable_response_storage = true
22
- preferred_auth_method = "apikey"
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(apiKey) {
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
- const authPath = path.join(configDir, 'auth.json');
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'];
@@ -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
 
@@ -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; authPath: string }
19
+ codex: { configPath: string }
20
20
  opencode?: { configPath: string }
21
21
  }
22
22
 
@@ -23,15 +23,26 @@ 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(result.authPath)).toBe(true)
45
+ expect(fs.existsSync(authPath)).toBe(false)
35
46
  })
36
47
 
37
48
  test('writes codex reasoning efforts as high', () => {
@@ -65,11 +76,11 @@ custom_model = "keep-me"
65
76
  const config = TOML.parse(fs.readFileSync(configPath, 'utf8')) as {
66
77
  custom_flag: boolean
67
78
  model: string
68
- preferred_auth_method: string
69
79
  model_providers: {
70
80
  jw: {
71
81
  base_url: string
72
82
  custom_model: string
83
+ experimental_bearer_token: string
73
84
  name: string
74
85
  }
75
86
  }
@@ -79,11 +90,14 @@ custom_model = "keep-me"
79
90
  expect(config).not.toHaveProperty('model_catalog_json')
80
91
  expect(config.custom_flag).toBe(true)
81
92
  expect(config.model).toBe('gpt-5.5')
82
- expect(config.preferred_auth_method).toBe('apikey')
93
+ expect(config).not.toHaveProperty('preferred_auth_method')
83
94
  expect(config.model_providers.jw.base_url).toBe(
84
95
  'https://ai.gengjiawen.com/api/openai'
85
96
  )
86
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
+ )
87
101
  expect(config.model_providers.jw.name).toBe('jw')
88
102
  })
89
103
 
@@ -95,6 +109,7 @@ custom_model = "keep-me"
95
109
  fs.writeFileSync(
96
110
  configPath,
97
111
  `service_tier = "slow"
112
+ preferred_auth_method = "apikey"
98
113
 
99
114
  [model_providers.jw]
100
115
  base_url = "https://example.com"
@@ -104,19 +119,22 @@ base_url = "https://example.com"
104
119
  writeCodexConfig('test-api-key')
105
120
  const config = TOML.parse(fs.readFileSync(configPath, 'utf8')) as {
106
121
  model: string
107
- preferred_auth_method: string
108
122
  model_providers: {
109
123
  jw: {
110
124
  name: string
111
125
  base_url: string
126
+ experimental_bearer_token: string
112
127
  }
113
128
  }
114
129
  }
115
130
 
116
131
  expect(config.model).toBe('gpt-5.5')
117
132
  expect(config).not.toHaveProperty('model_catalog_json')
118
- expect(config.preferred_auth_method).toBe('apikey')
133
+ expect(config).not.toHaveProperty('preferred_auth_method')
119
134
  expect(config.model_providers.jw.name).toBe('jw')
135
+ expect(config.model_providers.jw.experimental_bearer_token).toBe(
136
+ 'test-api-key'
137
+ )
120
138
  expect(config).not.toHaveProperty('service_tier')
121
139
  })
122
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
20
  model_reasoning_effort = "high"
21
21
  plan_mode_reasoning_effort = "high"
22
22
  model_auto_compact_token_limit = 131072
23
23
  disable_response_storage = true
24
- preferred_auth_method = "apikey"
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(existingContent: string): string {
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(getCodexConfigTomlTemplate()) as TomlTable
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 and auth.json */
79
- export function writeCodexConfig(apiKey: string): {
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
- const authPath = path.join(configDir, 'auth.json')
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 */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gengjiawen/os-init",
3
3
  "private": false,
4
- "version": "1.26.2",
4
+ "version": "1.26.3",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "bin": {