rejectSharedPlanPath reports whether requestedPath targets the shared home-root plan file and, if so, returns a rejection response that points callers at the chat-specific plan path.
( requestedPath string, home string, chatPath string, planPathErr error, )
| 10 | // home-root plan file and, if so, returns a rejection response that |
| 11 | // points callers at the chat-specific plan path. |
| 12 | func rejectSharedPlanPath( |
| 13 | requestedPath string, |
| 14 | home string, |
| 15 | chatPath string, |
| 16 | planPathErr error, |
| 17 | ) (fantasy.ToolResponse, bool) { |
| 18 | if planPathErr != nil { |
| 19 | // When the resolver fails, we cannot determine the actual |
| 20 | // home directory. Fall back to rejecting only the exact |
| 21 | // legacy shared path (case-insensitive) rather than every |
| 22 | // file named plan.md. |
| 23 | if !looksLikeLegacySharedPlanPath(requestedPath) { |
| 24 | return fantasy.ToolResponse{}, false |
| 25 | } |
| 26 | |
| 27 | return fantasy.NewTextErrorResponse( |
| 28 | planPathVerificationMessage(requestedPath), |
| 29 | ), true |
| 30 | } |
| 31 | |
| 32 | if !LooksLikeHomePlanFile(requestedPath, home) && !looksLikeLegacySharedPlanPath(requestedPath) { |
| 33 | return fantasy.ToolResponse{}, false |
| 34 | } |
| 35 | |
| 36 | return fantasy.NewTextErrorResponse( |
| 37 | sharedPlanPathMessage(requestedPath, chatPath), |
| 38 | ), true |
| 39 | } |
| 40 | |
| 41 | func sharedPlanPathMessage(requestedPath, chatPath string) string { |
| 42 | return fmt.Sprintf( |