Skip to content

Commit 68289ea

Browse files
committed
feat: add local CLI config workflows
1 parent 679e3ee commit 68289ea

44 files changed

Lines changed: 9995 additions & 849 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,34 @@ func (a *App) UpdateLocalProjectedUsageSettings(input LocalProjectedUsageSetting
278278
}, nil
279279
}
280280

281+
func (a *App) GetCodexFeatureConfig() (*CodexFeatureConfigSnapshot, error) {
282+
result, err := a.core.GetCodexFeatureConfig()
283+
if err != nil {
284+
return nil, err
285+
}
286+
return mapCodexFeatureConfigSnapshot(result), nil
287+
}
288+
289+
func (a *App) PreviewCodexFeatureConfig(input SaveCodexFeatureConfigInput) (*CodexFeatureConfigPreview, error) {
290+
result, err := a.core.PreviewCodexFeatureConfig(wailsapp.SaveCodexFeatureConfigInput{
291+
Values: input.Values,
292+
})
293+
if err != nil {
294+
return nil, err
295+
}
296+
return mapCodexFeatureConfigPreview(result), nil
297+
}
298+
299+
func (a *App) SaveCodexFeatureConfig(input SaveCodexFeatureConfigInput) (*CodexFeatureConfigPreview, error) {
300+
result, err := a.core.SaveCodexFeatureConfig(wailsapp.SaveCodexFeatureConfigInput{
301+
Values: input.Values,
302+
})
303+
if err != nil {
304+
return nil, err
305+
}
306+
return mapCodexFeatureConfigPreview(result), nil
307+
}
308+
281309
func (a *App) StartCodexOAuth() (*OAuthStartResult, error) {
282310
result, err := a.core.StartCodexOAuth()
283311
if err != nil {
@@ -486,6 +514,20 @@ func (a *App) ApplyRelayServiceConfigToLocal(apiKey string, baseURL string, mode
486514
}, nil
487515
}
488516

517+
func (a *App) ApplyClaudeCodeAPIKeyConfigToLocal(apiKey string, baseURL string, model string) (*ClaudeCodeLocalApplyResult, error) {
518+
result, err := a.core.ApplyClaudeCodeAPIKeyConfigToLocal(apiKey, baseURL, model)
519+
if err != nil {
520+
return nil, err
521+
}
522+
523+
return &ClaudeCodeLocalApplyResult{
524+
ClaudeConfigDirPath: result.ClaudeConfigDirPath,
525+
SettingsPath: result.SettingsPath,
526+
Warnings: append([]string(nil), result.Warnings...),
527+
Conflicts: append([]string(nil), result.Conflicts...),
528+
}, nil
529+
}
530+
489531
func (a *App) CreateCodexAPIKey(input CreateCodexAPIKeyInput) error {
490532
return a.core.CreateCodexAPIKey(wailsapp.CreateCodexAPIKeyInput{
491533
APIKey: input.APIKey,

app_mappers.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,78 @@ func mapLocalProjectedUsageResponse(result *wailsapp.LocalProjectedUsageResponse
7575
}
7676
}
7777

78+
func mapCodexFeatureConfigSnapshot(result *wailsapp.CodexFeatureConfigSnapshot) *CodexFeatureConfigSnapshot {
79+
if result == nil {
80+
return &CodexFeatureConfigSnapshot{
81+
Definitions: []CodexFeatureDefinition{},
82+
Values: map[string]bool{},
83+
UnknownValues: map[string]bool{},
84+
Warnings: []string{},
85+
}
86+
}
87+
88+
definitions := make([]CodexFeatureDefinition, 0, len(result.Definitions))
89+
for _, definition := range result.Definitions {
90+
definitions = append(definitions, CodexFeatureDefinition{
91+
Key: definition.Key,
92+
Description: definition.Description,
93+
Stage: definition.Stage,
94+
DefaultEnabled: definition.DefaultEnabled,
95+
CanonicalKey: definition.CanonicalKey,
96+
LegacyAlias: definition.LegacyAlias,
97+
})
98+
}
99+
100+
return &CodexFeatureConfigSnapshot{
101+
CodexHomePath: result.CodexHomePath,
102+
ConfigPath: result.ConfigPath,
103+
Exists: result.Exists,
104+
Definitions: definitions,
105+
Values: cloneBoolMap(result.Values),
106+
UnknownValues: cloneBoolMap(result.UnknownValues),
107+
Raw: result.Raw,
108+
Warnings: append([]string(nil), result.Warnings...),
109+
}
110+
}
111+
112+
func mapCodexFeatureConfigPreview(result *wailsapp.CodexFeatureConfigPreview) *CodexFeatureConfigPreview {
113+
if result == nil {
114+
return &CodexFeatureConfigPreview{
115+
Changes: []CodexFeatureConfigChange{},
116+
Warnings: []string{},
117+
}
118+
}
119+
120+
changes := make([]CodexFeatureConfigChange, 0, len(result.Changes))
121+
for _, change := range result.Changes {
122+
changes = append(changes, CodexFeatureConfigChange{
123+
Key: change.Key,
124+
Type: change.Type,
125+
PreviousEnabled: change.PreviousEnabled,
126+
NextEnabled: change.NextEnabled,
127+
})
128+
}
129+
130+
return &CodexFeatureConfigPreview{
131+
ConfigPath: result.ConfigPath,
132+
WillCreate: result.WillCreate,
133+
Changes: changes,
134+
Preview: result.Preview,
135+
Warnings: append([]string(nil), result.Warnings...),
136+
}
137+
}
138+
139+
func cloneBoolMap(source map[string]bool) map[string]bool {
140+
if len(source) == 0 {
141+
return map[string]bool{}
142+
}
143+
cloned := make(map[string]bool, len(source))
144+
for key, value := range source {
145+
cloned[key] = value
146+
}
147+
return cloned
148+
}
149+
78150
func mapSessionManagementSnapshot(result *wailsapp.SessionManagementSnapshot) *SessionManagementSnapshot {
79151
if result == nil {
80152
return &SessionManagementSnapshot{

app_types.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,13 @@ type RelayLocalApplyResult struct {
227227
ConfigPath string `json:"configPath"`
228228
}
229229

230+
type ClaudeCodeLocalApplyResult struct {
231+
ClaudeConfigDirPath string `json:"claudeConfigDirPath"`
232+
SettingsPath string `json:"settingsPath"`
233+
Warnings []string `json:"warnings,omitempty"`
234+
Conflicts []string `json:"conflicts,omitempty"`
235+
}
236+
230237
type UsageStatisticsResponse struct {
231238
Usage map[string]interface{} `json:"usage"`
232239
FailedRequests int64 `json:"failedRequests,omitempty"`
@@ -258,6 +265,45 @@ type LocalProjectedUsageSettings struct {
258265
RefreshIntervalMinutes int `json:"refreshIntervalMinutes"`
259266
}
260267

268+
type CodexFeatureDefinition struct {
269+
Key string `json:"key"`
270+
Description string `json:"description,omitempty"`
271+
Stage string `json:"stage"`
272+
DefaultEnabled bool `json:"defaultEnabled"`
273+
CanonicalKey string `json:"canonicalKey,omitempty"`
274+
LegacyAlias bool `json:"legacyAlias,omitempty"`
275+
}
276+
277+
type CodexFeatureConfigSnapshot struct {
278+
CodexHomePath string `json:"codexHomePath"`
279+
ConfigPath string `json:"configPath"`
280+
Exists bool `json:"exists"`
281+
Definitions []CodexFeatureDefinition `json:"definitions"`
282+
Values map[string]bool `json:"values"`
283+
UnknownValues map[string]bool `json:"unknownValues,omitempty"`
284+
Raw string `json:"raw"`
285+
Warnings []string `json:"warnings"`
286+
}
287+
288+
type SaveCodexFeatureConfigInput struct {
289+
Values map[string]bool `json:"values"`
290+
}
291+
292+
type CodexFeatureConfigChange struct {
293+
Key string `json:"key"`
294+
Type string `json:"type"`
295+
PreviousEnabled *bool `json:"previousEnabled,omitempty"`
296+
NextEnabled bool `json:"nextEnabled"`
297+
}
298+
299+
type CodexFeatureConfigPreview struct {
300+
ConfigPath string `json:"configPath"`
301+
WillCreate bool `json:"willCreate"`
302+
Changes []CodexFeatureConfigChange `json:"changes"`
303+
Preview string `json:"preview"`
304+
Warnings []string `json:"warnings"`
305+
}
306+
261307
type UpdateSessionProviderMapping struct {
262308
SourceProvider string `json:"sourceProvider"`
263309
TargetProvider string `json:"targetProvider"`

0 commit comments

Comments
 (0)