MCPcopy Index your code
hub / github.com/coder/coder / Resolve

Function Resolve

agent/agentcontextconfig/api.go:139–172  ·  view source on GitHub ↗

Resolve reads instruction files, discovers skills, and resolves MCP config file paths for the given config and working directory.

(workingDir string, cfg Config)

Source from the content-addressed store, hash-verified

137// resolves MCP config file paths for the given config and
138// working directory.
139func Resolve(workingDir string, cfg Config) (workspacesdk.ContextConfigResponse, []string) {
140 resolvedInstructionsDirs := ResolvePaths(cfg.InstructionsDirs, workingDir)
141 resolvedSkillsDirs := ResolvePaths(cfg.SkillsDirs, workingDir)
142
143 // Read instruction files from each configured directory.
144 parts := readInstructionFiles(resolvedInstructionsDirs, cfg.InstructionsFile)
145
146 // Also check the working directory for the instruction file,
147 // unless it was already covered by InstructionsDirs.
148 if workingDir != "" {
149 seenDirs := make(map[string]struct{}, len(resolvedInstructionsDirs))
150 for _, d := range resolvedInstructionsDirs {
151 seenDirs[d] = struct{}{}
152 }
153 if _, ok := seenDirs[workingDir]; !ok {
154 if entry, found := readInstructionFileFromDir(workingDir, cfg.InstructionsFile); found {
155 parts = append(parts, entry)
156 }
157 }
158 }
159
160 // Discover skills from each configured skills directory.
161 skillParts := discoverSkills(resolvedSkillsDirs, cfg.SkillMetaFile)
162 parts = append(parts, skillParts...)
163
164 // Guarantee non-nil slice to signal agent support.
165 if parts == nil {
166 parts = []codersdk.ChatMessagePart{}
167 }
168
169 return workspacesdk.ContextConfigResponse{
170 Parts: parts,
171 }, ResolvePaths(cfg.MCPConfigFiles, workingDir)
172}
173
174// ContextPartsFromDir reads instruction files and discovers skills
175// from a specific directory, using default file names. This is used

Callers 4

TestResolveFunction · 0.92
MCPConfigFilesMethod · 0.85
handleGetMethod · 0.85

Calls 4

ResolvePathsFunction · 0.85
readInstructionFilesFunction · 0.85
discoverSkillsFunction · 0.85

Tested by 2

TestResolveFunction · 0.74