Files
OpenCode 68a9071cf1 feat: reconcile local master with origin (exa/hot-platform hunters, leaks ledger, latest results)
Local branch had diverged from origin/master (sibling commits on the same base). Rewrote local history linearly on top of origin/master, folding in all local content: exa/hot-platform discovery hunters, leaks ledger, nightly sweep orchestrator, updated .gitignore and skill docs, plus the latest hunt output and vault state. Remote-only files (vault keys, channel scripts) were restored rather than dropped, so the resulting tree is a full union of both sides.
2026-08-07 12:53:47 +08:00

1 line
4.1 KiB
JSON

{"repo": "baldie-dev/zerophagecli", "files": {"main.go": {"4b69fb86293f1f7f7c486633b303e3fbb00a3c58": {"t": 1786068293.3928635, "n": 3583, "h": "95fad632a17f65ac", "c": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\n\ttea \"github.com/charmbracelet/bubbletea\"\n\n\t\"baldy/zerophage/agent\"\n\t\"baldy/zerophage/llm\"\n\t\"baldy/zerophage/prompts\"\n\t\"baldy/zerophage/ui\"\n)\n\nfunc main() {\n\tvar newSession bool\n\tvar configPath string\n\targs := os.Args[1:]\n\tfor i := 0; i < len(args); i++ {\n\t\tswitch args[i] {\n\t\tcase \"--new\":\n\t\t\tnewSession = true\n\t\t\targs = append(args[:i], args[i+1:]...)\n\t\t\ti--\n\t\tcase \"--config\":\n\t\t\tif i+1 >= len(args) {\n\t\t\t\tfmt.Fprintln(os.Stderr, \"error: --config requires a file path argument\")\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\t\t\tconfigPath = args[i+1]\n\t\t\targs = append(args[:i], args[i+2:]...)\n\t\t\ti--\n\t\t}\n\t}\n\tif len(args) != 1 {\n\t\tfmt.Fprintf(os.Stderr, \"Usage: %s [--new] [--config <config_file>] <target>\\n\", os.Args[0])\n\t\tfmt.Fprintf(os.Stderr, \" --new: purge the previous session before starting\\n\")\n\t\tfmt.Fprintf(os.Stderr, \" --config <file>: JSON config file with default settings\\n\")\n\t\tfmt.Fprintf(os.Stderr, \" target: path to directory with source code\\n\")\n\t\tos.Exit(1)\n\t}\n\n\ttarget := args[0]\n\n\t// Load .env file if present; existing environment variables take precedence.\n\tloadDotEnv(\".env\")\n\n\tinfo, err := os.Stat(target)\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"error: cannot access target %q: %v\\n\", target, err)\n\t\tos.Exit(1)\n\t}\n\tif !info.IsDir() {\n\t\tfmt.Fprintf(os.Stderr, \"error: target %q is not a directory\\n\", target)\n\t\tos.Exit(1)\n\t}\n\n\tif newSession {\n\t\tagent.ClearAllSessions(target)\n\t}\n\n\tapiKey := os.Getenv(\"DEEPSEEK_API_KEY\")\n\tif apiKey == \"\" {\n\t\tfmt.Fprintln(os.Stderr, \"error: DEEPSEEK_API_KEY environment variable is not set\")\n\t\tos.Exit(1)\n\t}\n\n\tsmartModel := os.Getenv(\"DEEPSEEK_SMART\")\n\tif smartModel == \"\" {\n\t\tsmartModel = string(llm.DefaultSmartModel)\n\t}\n\tquickModel := os.Getenv(\"DEEPSEEK_QUICK\")\n\tif quickModel == \"\" {\n\t\tquickModel = string(llm.DefaultQuickModel)\n\t}\n\n\tclient := llm.NewClient(apiKey, smartModel, quickModel)\n\n\t// Load optional user config file.\n\t// If --config was not specified, try the default \"zerophage.config.json\" in the current directory.\n\tif configPath == \"\" {\n\t\tif _, statErr := os.Stat(\"zerophage.config.json\"); statErr == nil {\n\t\t\tconfigPath = \"zerophage.config.json\"\n\t\t}\n\t}\n\tvar appCfg *agent.AppConfig\n\tif configPath != \"\" {\n\t\tvar cfgErr error\n\t\tappCfg, cfgErr = agent.LoadAppConfig(configPath)\n\t\tif cfgErr != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"error: %v\\n\", cfgErr)\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n\n\tag, err := agent.New(client, target, prompts.FS, appCfg)\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"error: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\tdefer ag.Close()\n\n\tmanager := agent.NewConversationManager(ag, client, target, prompts.FS, appCfg)\n\tmanager.RestoreFromIndex()\n\n\tp := tea.NewProgram(ui.New(target, manager), tea.WithAltScreen())\n\tif _, err := p.Run(); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"error: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n}\n\n// loadDotEnv reads key=value pairs from the given file and sets them as\n// environment variables. Lines starting with '#' and empty lines are ignored.\n// Existing environment variables are not overwritten.\nfunc loadDotEnv(path string) {\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn // silently ignore missing file\n\t}\n\tdefer f.Close()\n\n\tscanner := bufio.NewScanner(f)\n\tfor scanner.Scan() {\n\t\tline := strings.TrimSpace(scanner.Text())\n\t\tif line == \"\" || strings.HasPrefix(line, \"#\") {\n\t\t\tcontinue\n\t\t}\n\t\tkey, value, ok := strings.Cut(line, \"=\")\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\t\tkey = strings.TrimSpace(key)\n\t\tvalue = strings.Trim(strings.TrimSpace(value), `\"`)\n\t\tif key != \"\" && os.Getenv(key) == \"\" {\n\t\t\tos.Setenv(key, value)\n\t\t}\n\t}\n}\n"}}}}