Skip to content

Commit 3bb2282

Browse files
committed
feat: add codex workspace management tools
1 parent 367c5a8 commit 3bb2282

53 files changed

Lines changed: 15204 additions & 177 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: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http"
88
"time"
99

10+
"github.com/linhay/gettokens/internal/codexbinary"
1011
"github.com/linhay/gettokens/internal/sidecar"
1112
"github.com/linhay/gettokens/internal/updater"
1213
wailsapp "github.com/linhay/gettokens/internal/wailsapp"
@@ -220,6 +221,38 @@ func (a *App) GetCodexSessionManagementSnapshot() (*SessionManagementSnapshot, e
220221
return mapSessionManagementSnapshot(result), nil
221222
}
222223

224+
func (a *App) GetCodexBinarySnapshot() (*codexbinary.Snapshot, error) {
225+
return a.core.GetCodexBinarySnapshot()
226+
}
227+
228+
func (a *App) RefreshCodexBinaryAvailable() (*codexbinary.Snapshot, error) {
229+
return a.core.RefreshCodexBinaryAvailable()
230+
}
231+
232+
func (a *App) ImportCodexBinary(input codexbinary.ImportLocalInput) (*codexbinary.InstallResult, error) {
233+
return a.core.ImportCodexBinary(input)
234+
}
235+
236+
func (a *App) DownloadCodexBinary(input codexbinary.DownloadInput) (*codexbinary.DownloadResult, error) {
237+
return a.core.DownloadCodexBinary(input)
238+
}
239+
240+
func (a *App) EnableCodexBinaryManagedPath() (*codexbinary.EnableManagedPathResult, error) {
241+
return a.core.EnableCodexBinaryManagedPath()
242+
}
243+
244+
func (a *App) UseCodexBinary(input codexbinary.UseInput) (*codexbinary.UseResult, error) {
245+
return a.core.UseCodexBinary(input)
246+
}
247+
248+
func (a *App) GetCodexBinaryVersionNotes(input codexbinary.VersionNotesInput) (*codexbinary.VersionNotesView, error) {
249+
return a.core.GetCodexBinaryVersionNotes(input)
250+
}
251+
252+
func (a *App) GetCodexBinaryDoctor() (*codexbinary.DoctorSummary, error) {
253+
return a.core.GetCodexBinaryDoctor()
254+
}
255+
223256
func (a *App) RefreshCodexSessionManagementSnapshot() (*SessionManagementSnapshot, error) {
224257
result, err := a.core.RefreshCodexSessionManagementSnapshot()
225258
if err != nil {
@@ -306,6 +339,77 @@ func (a *App) SaveCodexFeatureConfig(input SaveCodexFeatureConfigInput) (*CodexF
306339
return mapCodexFeatureConfigPreview(result), nil
307340
}
308341

342+
func (a *App) GetCodexSkillsSnapshot() (*CodexSkillsSnapshot, error) {
343+
result, err := a.core.GetCodexSkillsSnapshot()
344+
if err != nil {
345+
return nil, err
346+
}
347+
return mapCodexSkillsSnapshot(result), nil
348+
}
349+
350+
func (a *App) SaveCodexSkillEnabled(input SaveCodexSkillEnabledInput) (*SaveCodexSkillEnabledResult, error) {
351+
result, err := a.core.SaveCodexSkillEnabled(wailsapp.SaveCodexSkillEnabledInput{
352+
Path: input.Path,
353+
Enabled: input.Enabled,
354+
})
355+
if err != nil {
356+
return nil, err
357+
}
358+
return &SaveCodexSkillEnabledResult{
359+
ConfigPath: result.ConfigPath,
360+
Preview: result.Preview,
361+
}, nil
362+
}
363+
364+
func (a *App) GetCodexMcpServers() (*CodexMcpServersSnapshot, error) {
365+
result, err := a.core.GetCodexMcpServers()
366+
if err != nil {
367+
return nil, err
368+
}
369+
return mapCodexMcpServersSnapshot(result), nil
370+
}
371+
372+
func (a *App) SaveCodexMcpServer(input SaveCodexMcpServerInput) (*SaveCodexMcpServerResult, error) {
373+
result, err := a.core.SaveCodexMcpServer(wailsapp.SaveCodexMcpServerInput{
374+
Server: mapWailsCodexMcpServer(input.Server),
375+
})
376+
if err != nil {
377+
return nil, err
378+
}
379+
return mapCodexMcpSaveResult(result), nil
380+
}
381+
382+
func (a *App) OpenCodexConfigToml() (*OpenCodexConfigTomlResult, error) {
383+
result, err := a.core.OpenCodexConfigToml()
384+
if err != nil {
385+
return nil, err
386+
}
387+
return &OpenCodexConfigTomlResult{ConfigPath: result.ConfigPath}, nil
388+
}
389+
390+
func (a *App) GetCodexConfigToml() (*CodexConfigTomlDocument, error) {
391+
result, err := a.core.GetCodexConfigToml()
392+
if err != nil {
393+
return nil, err
394+
}
395+
return &CodexConfigTomlDocument{
396+
ConfigPath: result.ConfigPath,
397+
Content: result.Content,
398+
Exists: result.Exists,
399+
}, nil
400+
}
401+
402+
func (a *App) SaveCodexConfigToml(input SaveCodexConfigTomlInput) (*SaveCodexConfigTomlResult, error) {
403+
result, err := a.core.SaveCodexConfigToml(wailsapp.SaveCodexConfigTomlInput{Content: input.Content})
404+
if err != nil {
405+
return nil, err
406+
}
407+
return &SaveCodexConfigTomlResult{
408+
ConfigPath: result.ConfigPath,
409+
Content: result.Content,
410+
}, nil
411+
}
412+
309413
func (a *App) StartCodexOAuth() (*OAuthStartResult, error) {
310414
result, err := a.core.StartCodexOAuth()
311415
if err != nil {

app_mappers.go

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,125 @@ func mapCodexFeatureConfigPreview(result *wailsapp.CodexFeatureConfigPreview) *C
138138
}
139139
}
140140

141+
func mapCodexSkillsSnapshot(result *wailsapp.CodexSkillsSnapshot) *CodexSkillsSnapshot {
142+
if result == nil {
143+
return &CodexSkillsSnapshot{Roots: []CodexSkillRoot{}, Skills: []CodexSkillRecord{}, Warnings: []string{}}
144+
}
145+
roots := make([]CodexSkillRoot, 0, len(result.Roots))
146+
for _, root := range result.Roots {
147+
roots = append(roots, CodexSkillRoot{
148+
Label: root.Label,
149+
Path: root.Path,
150+
SourceKind: root.SourceKind,
151+
Exists: root.Exists,
152+
})
153+
}
154+
skills := make([]CodexSkillRecord, 0, len(result.Skills))
155+
for _, skill := range result.Skills {
156+
files := make([]CodexSkillFile, 0, len(skill.Files))
157+
for _, file := range skill.Files {
158+
files = append(files, CodexSkillFile{Path: file.Path, Kind: file.Kind})
159+
}
160+
skills = append(skills, CodexSkillRecord{
161+
ID: skill.ID,
162+
Name: skill.Name,
163+
Description: skill.Description,
164+
Enabled: skill.Enabled,
165+
RootLabel: skill.RootLabel,
166+
RootPath: skill.RootPath,
167+
SourceKind: skill.SourceKind,
168+
Origin: skill.Origin,
169+
VersionLabel: skill.VersionLabel,
170+
Files: files,
171+
SkillMarkdown: skill.SkillMarkdown,
172+
PreviewMarkdown: skill.PreviewMarkdown,
173+
Warnings: append([]string(nil), skill.Warnings...),
174+
})
175+
}
176+
return &CodexSkillsSnapshot{
177+
CodexHomePath: result.CodexHomePath,
178+
ConfigPath: result.ConfigPath,
179+
Roots: roots,
180+
Skills: skills,
181+
Warnings: append([]string(nil), result.Warnings...),
182+
}
183+
}
184+
185+
func mapCodexMcpServersSnapshot(result *wailsapp.CodexMcpServersSnapshot) *CodexMcpServersSnapshot {
186+
if result == nil {
187+
return &CodexMcpServersSnapshot{Servers: []CodexMcpServer{}, Warnings: []string{}}
188+
}
189+
servers := make([]CodexMcpServer, 0, len(result.Servers))
190+
for _, server := range result.Servers {
191+
servers = append(servers, mapCodexMcpServer(server))
192+
}
193+
return &CodexMcpServersSnapshot{
194+
CodexHomePath: result.CodexHomePath,
195+
ConfigPath: result.ConfigPath,
196+
Exists: result.Exists,
197+
Servers: servers,
198+
Warnings: append([]string(nil), result.Warnings...),
199+
}
200+
}
201+
202+
func mapCodexMcpServer(server wailsapp.CodexMcpServer) CodexMcpServer {
203+
env := make([]CodexMcpEnvRow, 0, len(server.Env))
204+
for _, row := range server.Env {
205+
env = append(env, CodexMcpEnvRow{Key: row.Key, Value: row.Value})
206+
}
207+
return CodexMcpServer{
208+
ID: server.ID,
209+
Label: server.Label,
210+
Enabled: server.Enabled,
211+
Transport: server.Transport,
212+
Command: server.Command,
213+
Args: append([]string(nil), server.Args...),
214+
URL: server.URL,
215+
Env: env,
216+
BearerTokenEnvVar: server.BearerTokenEnvVar,
217+
SourcePath: server.SourcePath,
218+
Status: server.Status,
219+
Warnings: append([]string(nil), server.Warnings...),
220+
}
221+
}
222+
223+
func mapWailsCodexMcpServer(server CodexMcpServer) wailsapp.CodexMcpServer {
224+
env := make([]wailsapp.CodexMcpEnvRow, 0, len(server.Env))
225+
for _, row := range server.Env {
226+
env = append(env, wailsapp.CodexMcpEnvRow{Key: row.Key, Value: row.Value})
227+
}
228+
return wailsapp.CodexMcpServer{
229+
ID: server.ID,
230+
Label: server.Label,
231+
Enabled: server.Enabled,
232+
Transport: server.Transport,
233+
Command: server.Command,
234+
Args: append([]string(nil), server.Args...),
235+
URL: server.URL,
236+
Env: env,
237+
BearerTokenEnvVar: server.BearerTokenEnvVar,
238+
SourcePath: server.SourcePath,
239+
Status: server.Status,
240+
Warnings: append([]string(nil), server.Warnings...),
241+
}
242+
}
243+
244+
func mapCodexMcpSaveResult(result *wailsapp.SaveCodexMcpServerResult) *SaveCodexMcpServerResult {
245+
if result == nil {
246+
return &SaveCodexMcpServerResult{Changes: []CodexMcpChange{}}
247+
}
248+
changes := make([]CodexMcpChange, 0, len(result.Changes))
249+
for _, change := range result.Changes {
250+
changes = append(changes, CodexMcpChange{Key: change.Key, Before: change.Before, After: change.After})
251+
}
252+
return &SaveCodexMcpServerResult{
253+
ConfigPath: result.ConfigPath,
254+
Server: mapCodexMcpServer(result.Server),
255+
Preview: result.Preview,
256+
Changes: changes,
257+
}
258+
}
259+
141260
func cloneBoolMap(source map[string]bool) map[string]bool {
142261
if len(source) == 0 {
143262
return map[string]bool{}

app_types.go

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,116 @@ type CodexFeatureConfigPreview struct {
317317
Warnings []string `json:"warnings"`
318318
}
319319

320+
type CodexSkillFile struct {
321+
Path string `json:"path"`
322+
Kind string `json:"kind"`
323+
}
324+
325+
type CodexSkillRecord struct {
326+
ID string `json:"id"`
327+
Name string `json:"name"`
328+
Description string `json:"description,omitempty"`
329+
Enabled bool `json:"enabled"`
330+
RootLabel string `json:"rootLabel"`
331+
RootPath string `json:"rootPath"`
332+
SourceKind string `json:"sourceKind"`
333+
Origin string `json:"origin"`
334+
VersionLabel string `json:"versionLabel,omitempty"`
335+
Files []CodexSkillFile `json:"files"`
336+
SkillMarkdown string `json:"skillMarkdown"`
337+
PreviewMarkdown string `json:"previewMarkdown"`
338+
Warnings []string `json:"warnings,omitempty"`
339+
}
340+
341+
type CodexSkillRoot struct {
342+
Label string `json:"label"`
343+
Path string `json:"path"`
344+
SourceKind string `json:"sourceKind"`
345+
Exists bool `json:"exists"`
346+
}
347+
348+
type CodexSkillsSnapshot struct {
349+
CodexHomePath string `json:"codexHomePath"`
350+
ConfigPath string `json:"configPath"`
351+
Roots []CodexSkillRoot `json:"roots"`
352+
Skills []CodexSkillRecord `json:"skills"`
353+
Warnings []string `json:"warnings,omitempty"`
354+
}
355+
356+
type SaveCodexSkillEnabledInput struct {
357+
Path string `json:"path"`
358+
Enabled bool `json:"enabled"`
359+
}
360+
361+
type SaveCodexSkillEnabledResult struct {
362+
ConfigPath string `json:"configPath"`
363+
Preview string `json:"preview"`
364+
}
365+
366+
type CodexMcpEnvRow struct {
367+
Key string `json:"key"`
368+
Value string `json:"value"`
369+
}
370+
371+
type CodexMcpServer struct {
372+
ID string `json:"id"`
373+
Label string `json:"label"`
374+
Enabled bool `json:"enabled"`
375+
Transport string `json:"transport"`
376+
Command string `json:"command,omitempty"`
377+
Args []string `json:"args,omitempty"`
378+
URL string `json:"url,omitempty"`
379+
Env []CodexMcpEnvRow `json:"env,omitempty"`
380+
BearerTokenEnvVar string `json:"bearerTokenEnvVar,omitempty"`
381+
SourcePath string `json:"sourcePath"`
382+
Status string `json:"status"`
383+
Warnings []string `json:"warnings,omitempty"`
384+
}
385+
386+
type CodexMcpServersSnapshot struct {
387+
CodexHomePath string `json:"codexHomePath"`
388+
ConfigPath string `json:"configPath"`
389+
Exists bool `json:"exists"`
390+
Servers []CodexMcpServer `json:"servers"`
391+
Warnings []string `json:"warnings,omitempty"`
392+
}
393+
394+
type SaveCodexMcpServerInput struct {
395+
Server CodexMcpServer `json:"server"`
396+
}
397+
398+
type CodexMcpChange struct {
399+
Key string `json:"key"`
400+
Before string `json:"before"`
401+
After string `json:"after"`
402+
}
403+
404+
type SaveCodexMcpServerResult struct {
405+
ConfigPath string `json:"configPath"`
406+
Server CodexMcpServer `json:"server"`
407+
Preview string `json:"preview"`
408+
Changes []CodexMcpChange `json:"changes"`
409+
}
410+
411+
type OpenCodexConfigTomlResult struct {
412+
ConfigPath string `json:"configPath"`
413+
}
414+
415+
type CodexConfigTomlDocument struct {
416+
ConfigPath string `json:"configPath"`
417+
Content string `json:"content"`
418+
Exists bool `json:"exists"`
419+
}
420+
421+
type SaveCodexConfigTomlInput struct {
422+
Content string `json:"content"`
423+
}
424+
425+
type SaveCodexConfigTomlResult struct {
426+
ConfigPath string `json:"configPath"`
427+
Content string `json:"content"`
428+
}
429+
320430
type UpdateSessionProviderMapping struct {
321431
SourceProvider string `json:"sourceProvider"`
322432
TargetProvider string `json:"targetProvider"`

0 commit comments

Comments
 (0)