MCPcopy Create free account
hub / github.com/JordanCoin/codemap / RunContext

Function RunContext

cmd/context.go:80–106  ·  view source on GitHub ↗

RunContext handles the "codemap context" subcommand.

(args []string, root string)

Source from the content-addressed store, hash-verified

78
79// RunContext handles the "codemap context" subcommand.
80func RunContext(args []string, root string) {
81 fs := flag.NewFlagSet("context", flag.ContinueOnError)
82 forPrompt := fs.String("for", "", "Pre-classify intent for this prompt")
83 compact := fs.Bool("compact", false, "Minimal output for token-constrained agents")
84 if err := fs.Parse(args); err != nil {
85 os.Exit(1)
86 }
87
88 if fs.NArg() > 0 {
89 root = fs.Arg(0)
90 }
91
92 absRoot, err := filepath.Abs(root)
93 if err != nil {
94 fmt.Fprintf(os.Stderr, "Error: %v\n", err)
95 os.Exit(1)
96 }
97
98 envelope := buildContextEnvelope(absRoot, *forPrompt, *compact)
99
100 enc := json.NewEncoder(os.Stdout)
101 enc.SetIndent("", " ")
102 if err := enc.Encode(envelope); err != nil {
103 fmt.Fprintf(os.Stderr, "Error encoding context: %v\n", err)
104 os.Exit(1)
105 }
106}
107
108func buildContextEnvelope(root, prompt string, compact bool) ContextEnvelope {
109 projCfg := config.Load(root)

Callers 1

mainFunction · 0.92

Calls 2

buildContextEnvelopeFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected