mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-03 19:25:19 +02:00
enable coding agents if they are available by default
This commit is contained in:
parent
e7c7d0e90f
commit
c213274723
1 changed files with 17 additions and 12 deletions
|
|
@ -2,6 +2,7 @@ import fs from 'fs/promises';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { WorkDir } from '../config/config.js';
|
import { WorkDir } from '../config/config.js';
|
||||||
import { CodeModeConfig } from './types.js';
|
import { CodeModeConfig } from './types.js';
|
||||||
|
import { checkCodeModeAgentStatus } from './status.js';
|
||||||
|
|
||||||
export interface ICodeModeConfigRepo {
|
export interface ICodeModeConfigRepo {
|
||||||
getConfig(): Promise<CodeModeConfig>;
|
getConfig(): Promise<CodeModeConfig>;
|
||||||
|
|
@ -10,27 +11,31 @@ export interface ICodeModeConfigRepo {
|
||||||
|
|
||||||
export class FSCodeModeConfigRepo implements ICodeModeConfigRepo {
|
export class FSCodeModeConfigRepo implements ICodeModeConfigRepo {
|
||||||
private readonly configPath = path.join(WorkDir, 'config', 'code-mode.json');
|
private readonly configPath = path.join(WorkDir, 'config', 'code-mode.json');
|
||||||
private readonly defaultConfig: CodeModeConfig = { enabled: false };
|
private agentReadyPromise: Promise<boolean> | null = null;
|
||||||
|
|
||||||
constructor() {
|
// Reuse the existing agent check (Claude Code / Codex installed + signed in),
|
||||||
this.ensureConfigFile();
|
// cached for the process lifetime so we probe (shell + keychain) at most once
|
||||||
}
|
// per session rather than on every getConfig call.
|
||||||
|
private agentReady(): Promise<boolean> {
|
||||||
private async ensureConfigFile(): Promise<void> {
|
if (!this.agentReadyPromise) {
|
||||||
try {
|
this.agentReadyPromise = checkCodeModeAgentStatus()
|
||||||
await fs.access(this.configPath);
|
.then((s) =>
|
||||||
} catch {
|
(s.claude.installed && s.claude.signedIn)
|
||||||
await fs.mkdir(path.dirname(this.configPath), { recursive: true });
|
|| (s.codex.installed && s.codex.signedIn))
|
||||||
await fs.writeFile(this.configPath, JSON.stringify(this.defaultConfig, null, 2));
|
.catch(() => false);
|
||||||
}
|
}
|
||||||
|
return this.agentReadyPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getConfig(): Promise<CodeModeConfig> {
|
async getConfig(): Promise<CodeModeConfig> {
|
||||||
try {
|
try {
|
||||||
|
// The file only exists once the user has explicitly toggled code mode
|
||||||
|
// in settings — always honor that choice.
|
||||||
const content = await fs.readFile(this.configPath, 'utf8');
|
const content = await fs.readFile(this.configPath, 'utf8');
|
||||||
return CodeModeConfig.parse(JSON.parse(content));
|
return CodeModeConfig.parse(JSON.parse(content));
|
||||||
} catch {
|
} catch {
|
||||||
return this.defaultConfig;
|
// No explicit choice yet: enable automatically when a coding agent is ready.
|
||||||
|
return { enabled: await this.agentReady() };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue