MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / InstructionPath

Function InstructionPath

internal/entities/apps.go:299–333  ·  view source on GitHub ↗

InstructionPath returns the concrete install path for an instruction identified by app and level. For user-level installs the returned path has ~ expanded via pathutil.Expand. For project-level installs the projectDir must be a non-empty existing directory; the returned path substitutes

(app string, level InstallLevel, projectDir string)

Source from the content-addressed store, hash-verified

297// projectDir must be a non-empty existing directory; the returned path
298// substitutes <project> with the project dir.
299func InstructionPath(app string, level InstallLevel, projectDir string) (string, error) {
300 paths, ok := instructionApps[app]
301 if !ok {
302 return "", fmt.Errorf("entities: app %q does not support instructions", app)
303 }
304 switch level {
305 case InstallLevelUser:
306 if paths.UserPath == "" {
307 return "", fmt.Errorf("entities: app %q has no user-level instruction path", app)
308 }
309 return pathutil.Expand(paths.UserPath), nil
310 case InstallLevelProject:
311 if paths.ProjectPath == "" {
312 return "", fmt.Errorf("entities: app %q has no project-level instruction path", app)
313 }
314 if projectDir == "" {
315 return "", fmt.Errorf("entities: project directory is required for project-level install")
316 }
317 projectDir = pathutil.Expand(projectDir)
318 info, err := os.Stat(projectDir)
319 if err != nil {
320 return "", fmt.Errorf("entities: project directory %q: %w", projectDir, err)
321 }
322 if !info.IsDir() {
323 return "", fmt.Errorf("entities: %q is not a directory", projectDir)
324 }
325 absDir, err := filepath.Abs(projectDir)
326 if err != nil {
327 return "", fmt.Errorf("entities: cannot resolve %q: %w", projectDir, err)
328 }
329 return strings.Replace(paths.ProjectPath, "<project>", absDir, 1), nil
330 default:
331 return "", fmt.Errorf("entities: unsupported install level %q", level)
332 }
333}
334
335// InstallInstruction writes the instruction entity's content to the target
336// path determined by app and level. For user-level installs the path is

Calls 1

ExpandFunction · 0.92