()
| 55 | current = parent |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | if root := config.FindLuminaRoot(""); root != "" { |
| 60 | candidate := config.LuminaResourcePath(root, apppaths.LegacySystemDirName, apppaths.SystemPromptFileName) |
| 61 | if fileExists(candidate) { |
| 62 | return candidate |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | _, filename, _, ok := runtime.Caller(0) |
| 67 | if !ok { |
| 68 | return apppaths.ProjectSystemPrompt(".") |
| 69 | } |
| 70 | |
| 71 | current := filepath.Dir(filename) |
| 72 | |
| 73 | for i := 0; i < 6; i++ { |
| 74 | candidate := apppaths.ProjectSystemPrompt(current) |
| 75 | if fileExists(candidate) { |
| 76 | return candidate |
| 77 | } |
| 78 | |
| 79 | parent := filepath.Dir(current) |
| 80 | if parent == current { |
| 81 | break |
| 82 | } |
| 83 | |
| 84 | current = parent |
| 85 | } |
| 86 | |
| 87 | return filepath.Join( |
| 88 | filepath.Dir(filename), |
| 89 | "..", |
| 90 | apppaths.ProjectLocalDirName, |
| 91 | apppaths.LegacySystemDirName, |
| 92 | apppaths.SystemPromptFileName, |
| 93 | ) |
| 94 | } |
| 95 | |
| 96 | func resolveTemplatePathForCWD(cwd string) string { |
| 97 | if path, ok := projectTemplatePathForCWD(cwd); ok { |
| 98 | return path |
| 99 | } |
| 100 | return getTemplatePath() |
| 101 | } |
| 102 | |
| 103 | func projectTemplatePathForCWD(cwd string) (string, bool) { |
no test coverage detected