MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / composeEnv

Function composeEnv

src/workspaces/adapters/codex.ts:234–255  ·  view source on GitHub ↗

* Set `CODEX_HOME` only when workspace has its own `.codex/` directory * (override mode). Otherwise codex falls back to its own `~/.codex/`, * which is its normal behavior in any uninvolved project. The "reset * to default" UI action deletes the entire `.codex/` directory so the * adapte

(ctx: SpawnContext)

Source from the content-addressed store, hash-verified

232 * file (not OpenAlice's internal state).
233 */
234 composeEnv(ctx: SpawnContext): Record<string, string> {
235 const result: Record<string, string> = {};
236 const workspaceCodex = join(ctx.cwd, '.codex');
237 if (!existsSync(workspaceCodex)) return result;
238 result['CODEX_HOME'] = workspaceCodex;
239 const envFile = join(workspaceCodex, 'env.json');
240 if (existsSync(envFile)) {
241 try {
242 const parsed: unknown = JSON.parse(readFileSync(envFile, 'utf8'));
243 if (parsed && typeof parsed === 'object') {
244 for (const [k, v] of Object.entries(parsed as Record<string, unknown>)) {
245 if (typeof v === 'string' && /^[A-Za-z_][A-Za-z0-9_]*$/.test(k)) {
246 result[k] = v;
247 }
248 }
249 }
250 } catch {
251 // ignore parse errors; file is user-editable and v1 doesn't surface
252 }
253 }
254 return result;
255 },
256
257 async bootstrap(ctx: BootstrapContext): Promise<void> {
258 await ensureTrustedProject(ctx.cwd);

Callers

nothing calls this directly

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected