Skip to content

Commit 6f34e8c

Browse files
committed
Refactor config handling and update documentation
- Move runtime settings to VS Code config (kfc.* namespace) - Simplify project config to only handle paths in kfc-settings.json - Update README to clarify configuration structure - Remove unused config interfaces and methods from config-manager - Add note about fixed settings file location This change separates project-specific path configuration from runtime settings, making the extension more maintainable and user-configurable through VS Code settings UI.
1 parent 7dd3668 commit 6f34e8c

File tree

4 files changed

+82
-366
lines changed

4 files changed

+82
-366
lines changed

.codex/settings/kfc-settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"paths": {
3+
"specs": ".codex/specs",
4+
"steering": ".codex/steering",
5+
"settings": ".codex/settings",
6+
"prompts": ".codex/prompts"
7+
}
8+
}

README.md

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ Core commands registered by the extension:
146146

147147
## Configuration
148148

149-
Settings are stored in `.codex/settings/kfc-settings.json`:
149+
Project-local settings are stored in `.codex/settings/kfc-settings.json` and only contain paths. UI visibility and Codex runtime options live in VS Code settings under the `kfc.*` namespace.
150+
151+
Minimal settings file:
150152

151153
```json
152154
{
@@ -155,26 +157,15 @@ Settings are stored in `.codex/settings/kfc-settings.json`:
155157
"steering": ".codex/steering",
156158
"settings": ".codex/settings",
157159
"prompts": ".codex/prompts"
158-
},
159-
"views": {
160-
"specs": { "visible": true },
161-
"steering": { "visible": true },
162-
"prompts": { "visible": true },
163-
"mcp": { "visible": false },
164-
"hooks": { "visible": false },
165-
"agents": { "visible": false },
166-
"settings": { "visible": false }
167-
},
168-
"codex": {
169-
"path": "codex",
170-
"defaultApprovalMode": "interactive",
171-
"defaultModel": "gpt-5",
172-
"timeout": 30000,
173-
"terminalDelay": 1000
174160
}
175161
}
176162
```
177163

164+
Notes:
165+
- Only the `paths.*` values are honored by the extension at runtime.
166+
- Changing `paths.*` may require a window reload to take effect.
167+
- The location of `kfc-settings.json` itself is fixed to `.codex/settings/kfc-settings.json` (editing `paths.settings` does not relocate the file).
168+
178169
## Workspace Structure
179170

180171
The extension creates the following structure in your workspace:

src/utils/config-manager.ts

Lines changed: 5 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,16 @@
11
import * as path from 'path';
22
import * as vscode from 'vscode';
3-
import { CONFIG_FILE_NAME, DEFAULT_PATHS, DEFAULT_VIEW_VISIBILITY } from '../constants';
4-
5-
export enum ApprovalMode {
6-
Interactive = 'interactive',
7-
AutoEdit = 'auto-edit',
8-
FullAuto = 'full-auto'
9-
}
10-
11-
export interface CodexConfig {
12-
path: string;
13-
defaultApprovalMode: ApprovalMode;
14-
defaultModel?: string;
15-
timeout: number;
16-
terminalDelay: number;
17-
}
18-
19-
export interface MigrationConfig {
20-
backupOriginalFiles: boolean;
21-
migrationCompleted: boolean;
22-
}
3+
import { CONFIG_FILE_NAME, DEFAULT_PATHS } from '../constants';
234

5+
// Minimal project-local settings persisted under .codex/settings/kfc-settings.json
6+
// Only "paths" are honored by the extension. Other runtime configs live in VS Code settings (kfc.*).
247
export interface KfcSettings {
258
paths: {
269
specs: string;
2710
steering: string;
2811
settings: string;
2912
prompts: string;
3013
};
31-
views: {
32-
specs: { visible: boolean; };
33-
steering: { visible: boolean; };
34-
mcp: { visible: boolean; };
35-
hooks: { visible: boolean; };
36-
prompts: { visible: boolean; };
37-
settings: { visible: boolean; };
38-
};
39-
codex?: CodexConfig;
40-
migration?: MigrationConfig;
4114
}
4215

4316
export class ConfigManager {
@@ -108,34 +81,7 @@ export class ConfigManager {
10881

10982
private getDefaultSettings(): KfcSettings {
11083
return {
111-
paths: { ...DEFAULT_PATHS },
112-
views: {
113-
specs: { visible: DEFAULT_VIEW_VISIBILITY.specs },
114-
steering: { visible: DEFAULT_VIEW_VISIBILITY.steering },
115-
mcp: { visible: DEFAULT_VIEW_VISIBILITY.mcp },
116-
hooks: { visible: DEFAULT_VIEW_VISIBILITY.hooks },
117-
prompts: { visible: DEFAULT_VIEW_VISIBILITY.prompts },
118-
settings: { visible: DEFAULT_VIEW_VISIBILITY.settings }
119-
},
120-
codex: this.getDefaultCodexConfig(),
121-
migration: this.getDefaultMigrationConfig()
122-
};
123-
}
124-
125-
private getDefaultCodexConfig(): CodexConfig {
126-
return {
127-
path: 'codex',
128-
defaultApprovalMode: ApprovalMode.Interactive,
129-
defaultModel: 'gpt-5',
130-
timeout: 30000,
131-
terminalDelay: 1000
132-
};
133-
}
134-
135-
private getDefaultMigrationConfig(): MigrationConfig {
136-
return {
137-
backupOriginalFiles: true,
138-
migrationCompleted: false
84+
paths: { ...DEFAULT_PATHS }
13985
};
14086
}
14187

@@ -162,135 +108,5 @@ export class ConfigManager {
162108
this.settings = settings;
163109
}
164110

165-
// Codex Configuration Methods
166-
getCodexConfig(): CodexConfig {
167-
const settings = this.getSettings();
168-
return settings.codex || this.getDefaultCodexConfig();
169-
}
170-
171-
async updateCodexConfig(config: Partial<CodexConfig>): Promise<void> {
172-
const settings = this.getSettings();
173-
settings.codex = { ...this.getCodexConfig(), ...config };
174-
await this.saveSettings(settings);
175-
}
176-
177-
async validateCodexPath(codexPath?: string): Promise<{ isValid: boolean; error?: string; }> {
178-
const pathToCheck = codexPath || this.getCodexConfig().path;
179-
180-
try {
181-
// Check if codex command is available
182-
const { spawn } = require('child_process');
183-
184-
return new Promise((resolve) => {
185-
const process = spawn(pathToCheck, ['--version'], {
186-
stdio: 'pipe',
187-
timeout: 5000
188-
});
189-
190-
let output = '';
191-
process.stdout?.on('data', (data: Buffer) => {
192-
output += data.toString();
193-
});
194-
195-
process.on('close', (code: number) => {
196-
if (code === 0) {
197-
resolve({ isValid: true });
198-
} else {
199-
resolve({
200-
isValid: false,
201-
error: `Codex CLI returned exit code ${code}`
202-
});
203-
}
204-
});
205-
206-
process.on('error', (error: Error) => {
207-
resolve({
208-
isValid: false,
209-
error: `Failed to execute Codex CLI: ${error.message}`
210-
});
211-
});
212-
});
213-
} catch (error) {
214-
return {
215-
isValid: false,
216-
error: `Error validating Codex path: ${error instanceof Error ? error.message : 'Unknown error'}`
217-
};
218-
}
219-
}
220-
221-
// Migration Methods
222-
getMigrationConfig(): MigrationConfig {
223-
const settings = this.getSettings();
224-
return settings.migration || this.getDefaultMigrationConfig();
225-
}
226-
227-
async updateMigrationConfig(config: Partial<MigrationConfig>): Promise<void> {
228-
const settings = this.getSettings();
229-
settings.migration = { ...this.getMigrationConfig(), ...config };
230-
await this.saveSettings(settings);
231-
}
232-
233-
// Approval Mode Management
234-
async setApprovalMode(mode: ApprovalMode): Promise<void> {
235-
await this.updateCodexConfig({ defaultApprovalMode: mode });
236-
}
237-
238-
getApprovalMode(): ApprovalMode {
239-
return this.getCodexConfig().defaultApprovalMode;
240-
}
241-
242-
// Codex CLI Availability Check
243-
async checkCodexAvailability(): Promise<{ available: boolean; version?: string; error?: string; }> {
244-
const validation = await this.validateCodexPath();
245-
246-
if (!validation.isValid) {
247-
return {
248-
available: false,
249-
error: validation.error
250-
};
251-
}
252-
253-
try {
254-
const codexPath = this.getCodexConfig().path;
255-
const { spawn } = require('child_process');
256-
257-
return new Promise((resolve) => {
258-
const process = spawn(codexPath, ['--version'], {
259-
stdio: 'pipe',
260-
timeout: 5000
261-
});
262-
263-
let output = '';
264-
process.stdout?.on('data', (data: Buffer) => {
265-
output += data.toString();
266-
});
267-
268-
process.on('close', (code: number) => {
269-
if (code === 0) {
270-
// Extract version from output
271-
const versionMatch = output.match(/(\d+\.\d+\.\d+)/);
272-
const version = versionMatch ? versionMatch[1] : 'unknown';
273-
resolve({ available: true, version });
274-
} else {
275-
resolve({
276-
available: false,
277-
error: `Codex CLI returned exit code ${code}`
278-
});
279-
}
280-
});
281-
282-
process.on('error', (error: Error) => {
283-
resolve({
284-
available: false,
285-
error: `Failed to check Codex version: ${error.message}`
286-
});
287-
});
288-
});
289-
} catch (error) {
290-
return {
291-
available: false,
292-
error: `Error checking Codex availability: ${error instanceof Error ? error.message : 'Unknown error'}`
293-
};
294-
}
295-
}
111+
// (Intentionally minimal) — legacy config sections (views/codex/migration) have been removed.
296112
}

0 commit comments

Comments
 (0)