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)
| 176 | // by the CLI chat context commands to read context from an arbitrary |
| 177 | // directory without consulting agent env vars. |
| 178 | func 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. |