a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
64 lines
2.2 KiB
Go
64 lines
2.2 KiB
Go
// wakeup.go — `gortex wakeup` command. Emits the same ~500-token
|
|
// markdown digest the gortex_wakeup MCP tool produces, so users
|
|
// without an MCP transport (web ChatGPT, raw API, hosted Codex) can
|
|
// paste it into a chat session at startup. Routes through the daemon
|
|
// that owns the repo so the digest reflects the warm graph.
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
wakeupPath string
|
|
wakeupMaxTokens int
|
|
wakeupTopCommunities int
|
|
wakeupTopHotspots int
|
|
wakeupTopEntries int
|
|
)
|
|
|
|
var wakeupCmd = &cobra.Command{
|
|
Use: "wakeup",
|
|
Short: "Emit a ~500-token markdown codebase digest (for paste-into-chat use)",
|
|
Long: `Prints a paste-ready markdown digest of the repo the daemon owns:
|
|
the language mix, top communities, load-bearing hotspots, and entry
|
|
points — capped at approximately --max-tokens (default 500).
|
|
|
|
Designed for users who can't run the MCP server: web ChatGPT, raw API
|
|
callers, hosted Codex. Routes through the daemon that tracks the repo
|
|
(requires a running daemon).
|
|
|
|
Examples:
|
|
|
|
gortex wakeup # markdown to stdout, default budget
|
|
gortex wakeup --max-tokens 800 # larger budget
|
|
gortex wakeup --path /tmp/myrepo # a tracked tree`,
|
|
RunE: runWakeup,
|
|
}
|
|
|
|
func init() {
|
|
wakeupCmd.Flags().StringVar(&wakeupPath, "path", ".", "repository path to digest (the daemon must track it)")
|
|
wakeupCmd.Flags().IntVar(&wakeupMaxTokens, "max-tokens", 500, "approximate output token budget")
|
|
wakeupCmd.Flags().IntVar(&wakeupTopCommunities, "top-communities", 4, "communities to include")
|
|
wakeupCmd.Flags().IntVar(&wakeupTopHotspots, "top-hotspots", 5, "hotspots to include")
|
|
wakeupCmd.Flags().IntVar(&wakeupTopEntries, "top-entry-points", 5, "entry points to include")
|
|
rootCmd.AddCommand(wakeupCmd)
|
|
}
|
|
|
|
func runWakeup(cmd *cobra.Command, _ []string) error {
|
|
out, err := requireDaemonTool(wakeupPath, "gortex_wakeup", map[string]any{
|
|
"max_tokens": wakeupMaxTokens,
|
|
"top_communities": wakeupTopCommunities,
|
|
"top_hotspots": wakeupTopHotspots,
|
|
"top_entry_points": wakeupTopEntries,
|
|
"format": "markdown",
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = fmt.Fprint(cmd.OutOrStdout(), string(out))
|
|
return err
|
|
}
|