@seventysixty/codefacility-bridge 1.0.1 → 1.0.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.
Files changed (2) hide show
  1. package/index.js +32 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -60,11 +60,23 @@ const PROVIDERS = {
60
60
  openai: {
61
61
  command: 'codex',
62
62
  credPaths: [
63
+ // Various locations the Codex CLI may store config/keys
63
64
  path.join(HOME, '.codex', 'config.json'),
65
+ path.join(HOME, '.codex', 'config'),
66
+ path.join(HOME, '.codex', '.env'),
64
67
  path.join(HOME, '.config', 'codex', 'config.json'),
68
+ path.join(HOME, '.config', 'codex', 'config'),
69
+ path.join(HOME, '.openai', 'config.json'),
70
+ path.join(HOME, '.openai', 'credentials'),
65
71
  path.join(HOME, 'AppData', 'Roaming', 'codex', 'config.json'),
72
+ path.join(HOME, 'AppData', 'Roaming', 'OpenAI', 'config.json'),
66
73
  ],
67
- envVars: ['OPENAI_API_KEY'],
74
+ // Also check the .codex directory itself — if it exists with any files, CLI was configured
75
+ credDirs: [
76
+ path.join(HOME, '.codex'),
77
+ path.join(HOME, '.config', 'codex'),
78
+ ],
79
+ envVars: ['OPENAI_API_KEY', 'OPENAI_ACCESS_TOKEN'],
68
80
  },
69
81
  google: {
70
82
  command: 'gemini',
@@ -125,10 +137,7 @@ function credFileExists(credPaths) {
125
137
  for (const credPath of credPaths) {
126
138
  try {
127
139
  const stat = fs.statSync(credPath)
128
- // File must exist and have actual content (> 10 bytes)
129
140
  if (stat.isFile() && stat.size > 10) {
130
- // For JSON credential files, verify the content is parseable
131
- // and contains at least one key — not just an empty object
132
141
  try {
133
142
  const content = fs.readFileSync(credPath, 'utf8')
134
143
  const parsed = JSON.parse(content)
@@ -136,13 +145,23 @@ function credFileExists(credPaths) {
136
145
  return true
137
146
  }
138
147
  } catch {
139
- // Not JSON (e.g. TOML config) — size check is enough
148
+ // Not JSON (TOML/plain text config) — size check is enough
140
149
  return true
141
150
  }
142
151
  }
143
- } catch {
144
- // File doesn't exist or can't be read — try the next path
145
- }
152
+ } catch { /* file doesn't exist, try next */ }
153
+ }
154
+ return false
155
+ }
156
+
157
+ function credDirHasFiles(credDirs) {
158
+ if (!credDirs) return false
159
+ for (const dir of credDirs) {
160
+ try {
161
+ const entries = fs.readdirSync(dir)
162
+ // Directory exists and contains at least one file — CLI was configured
163
+ if (entries.length > 0) return true
164
+ } catch { /* dir doesn't exist */ }
146
165
  }
147
166
  return false
148
167
  }
@@ -161,7 +180,11 @@ async function checkProvider(providerId) {
161
180
  const { ok, version } = await runVersion(def.command)
162
181
  if (!ok) return { installed: false, authenticated: false }
163
182
 
164
- const authenticated = credFileExists(def.credPaths) || envVarSet(def.envVars)
183
+ const authenticated =
184
+ credFileExists(def.credPaths) ||
185
+ credDirHasFiles(def.credDirs) ||
186
+ envVarSet(def.envVars)
187
+
165
188
  const result = { installed: true, authenticated }
166
189
  if (version) result.version = version
167
190
  return result
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seventysixty/codefacility-bridge",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "CodeFacility local bridge — verifies AI CLI installations on the user's machine",
5
5
  "main": "index.js",
6
6
  "bin": {