Skip to content

Commit 8e896d7

Browse files
Merge upstream/main (auto-sync feat/copilot)
- efa200e feat(cli): add `fetch_codex_models` command for dynamic Codex model fetching - 412d344 feat(logging): add `RequestID` support in home request logging - a0bb1f3 feat(logging): add file-backed sources for request logging - 167edfe feat(auth): add support for websockets in auth file parsing and patching
2 parents a11deee + 167edfe commit 8e896d7

13 files changed

Lines changed: 1836 additions & 173 deletions

File tree

cmd/fetch_antigravity_models/main.go

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
//
99
// Flags:
1010
//
11-
// --auths-dir <path> Directory containing auth JSON files (default: "auths")
11+
// --auths-dir <path> Directory containing auth JSON files (default: config auth-dir)
12+
// --config <path> Config file path (default: "config.yaml")
1213
// --output <path> Output JSON file path (default: "antigravity_models.json")
1314
// --pretty Pretty-print the output JSON (default: true)
1415
package main
@@ -25,8 +26,10 @@ import (
2526
"strings"
2627
"time"
2728

29+
"github.com/router-for-me/CLIProxyAPI/v7/internal/config"
2830
"github.com/router-for-me/CLIProxyAPI/v7/internal/logging"
2931
"github.com/router-for-me/CLIProxyAPI/v7/internal/misc"
32+
"github.com/router-for-me/CLIProxyAPI/v7/internal/util"
3033
sdkauth "github.com/router-for-me/CLIProxyAPI/v7/sdk/auth"
3134
coreauth "github.com/router-for-me/CLIProxyAPI/v7/sdk/cliproxy/auth"
3235
"github.com/router-for-me/CLIProxyAPI/v7/sdk/proxyutil"
@@ -66,23 +69,49 @@ type modelEntry struct {
6669

6770
func main() {
6871
var authsDir string
72+
var configPath string
6973
var outputPath string
7074
var pretty bool
7175

72-
flag.StringVar(&authsDir, "auths-dir", "auths", "Directory containing auth JSON files")
76+
flag.StringVar(&authsDir, "auths-dir", "", "Directory containing auth JSON files (overrides config auth-dir)")
77+
flag.StringVar(&configPath, "config", "", "Configure File Path")
7378
flag.StringVar(&outputPath, "output", "antigravity_models.json", "Output JSON file path")
7479
flag.BoolVar(&pretty, "pretty", true, "Pretty-print the output JSON")
7580
flag.Parse()
81+
authsDirOverridden := false
82+
flag.Visit(func(f *flag.Flag) {
83+
if f.Name == "auths-dir" {
84+
authsDirOverridden = true
85+
}
86+
})
7687

77-
// Resolve relative paths against the working directory.
7888
wd, err := os.Getwd()
7989
if err != nil {
8090
fmt.Fprintf(os.Stderr, "error: cannot get working directory: %v\n", err)
8191
os.Exit(1)
8292
}
83-
if !filepath.IsAbs(authsDir) {
93+
94+
if strings.TrimSpace(configPath) == "" {
95+
configPath = filepath.Join(wd, "config.yaml")
96+
}
97+
cfg, err := config.LoadConfigOptional(configPath, false)
98+
if err != nil {
99+
fmt.Fprintf(os.Stderr, "error: failed to load config file %s: %v\n", configPath, err)
100+
os.Exit(1)
101+
}
102+
if cfg == nil {
103+
cfg = &config.Config{}
104+
}
105+
106+
if !authsDirOverridden {
107+
authsDir = cfg.AuthDir
108+
} else if strings.TrimSpace(authsDir) != "" && !strings.HasPrefix(strings.TrimSpace(authsDir), "~") && !filepath.IsAbs(authsDir) {
84109
authsDir = filepath.Join(wd, authsDir)
85110
}
111+
if authsDir, err = util.ResolveAuthDir(authsDir); err != nil {
112+
fmt.Fprintf(os.Stderr, "error: failed to resolve auth directory: %v\n", err)
113+
os.Exit(1)
114+
}
86115
if !filepath.IsAbs(outputPath) {
87116
outputPath = filepath.Join(wd, outputPath)
88117
}

0 commit comments

Comments
 (0)