MCPcopy Create free account
hub / github.com/diillson/chatcli / Create

Method Create

cli/context_adapter.go:74–97  ·  view source on GitHub ↗

Create builds and persists a context from the given sources.

(name, mode string, paths []string, description string, force bool)

Source from the content-addressed store, hash-verified

72
73// Create builds and persists a context from the given sources.
74func (a *contextPluginAdapter) Create(name, mode string, paths []string, description string, force bool) (string, error) {
75 mgr := a.manager()
76 if mgr == nil {
77 return "", fmt.Errorf("context manager unavailable in this session")
78 }
79 pmode, ok := validContextMode(mode)
80 if !ok {
81 return "", fmt.Errorf("invalid mode %q (valid: knowledge|full|summary|chunked|smart)", mode)
82 }
83 ctx, cancel := context.WithTimeout(context.Background(), contextOpTimeout)
84 defer cancel()
85 fc, err := mgr.CreateContext(ctx, name, description, paths, pmode, nil, force)
86 if err != nil {
87 return "", err
88 }
89 var b strings.Builder
90 fmt.Fprintf(&b, "Created context %q (mode=%s) — %d unit(s), %s.",
91 fc.Name, fc.Mode, fc.FileCount, humanMB(fc.TotalSize))
92 fmt.Fprintf(&b, "\nAttach it to use: @context attach {\"name\":%q}", fc.Name)
93 if pmode == ctxmgr.ModeKnowledge {
94 b.WriteString(" — then query with @knowledge (search/get).")
95 }
96 return b.String(), nil
97}
98
99// Attach attaches a named context to the session, applying RAG semantics.
100func (a *contextPluginAdapter) Attach(name string, ragTopK, priority int) (string, error) {

Calls 6

managerMethod · 0.95
validContextModeFunction · 0.85
humanMBFunction · 0.85
ErrorfMethod · 0.80
CreateContextMethod · 0.80
StringMethod · 0.45