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

Function ContextPartsFromDir

agent/agentcontextconfig/api.go:178–199  ·  view source on GitHub ↗

ContextPartsFromDir reads instruction files and discovers skills from a specific directory, using default file names. This is used by the CLI chat context commands to read context from an arbitrary directory without consulting agent env vars.

(dir string)

Source from the content-addressed store, hash-verified

176// by the CLI chat context commands to read context from an arbitrary
177// directory without consulting agent env vars.
178func ContextPartsFromDir(dir string) []codersdk.ChatMessagePart {
179 var parts []codersdk.ChatMessagePart
180
181 if entry, found := readInstructionFileFromDir(dir, DefaultInstructionsFile); found {
182 parts = append(parts, entry)
183 }
184
185 // Reuse ResolvePaths so CLI skill discovery follows the same
186 // project-relative path handling as agent config resolution.
187 skillParts := discoverSkills(
188 ResolvePaths(strings.Join([]string{DefaultSkillsDir, "skills"}, ","), dir),
189 DefaultSkillMetaFile,
190 )
191 parts = append(parts, skillParts...)
192
193 // Guarantee non-nil slice.
194 if parts == nil {
195 parts = []codersdk.ChatMessagePart{}
196 }
197
198 return parts
199}
200
201// MCPConfigFiles returns the resolved MCP configuration file
202// paths for the agent's MCP manager.

Callers 2

chatContextAddCommandMethod · 0.92
TestContextPartsFromDirFunction · 0.92

Calls 3

discoverSkillsFunction · 0.85
ResolvePathsFunction · 0.85

Tested by 1

TestContextPartsFromDirFunction · 0.74