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

Function rejectSharedPlanPath

coderd/x/chatd/chattool/planpathmessage.go:12–39  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

10// home-root plan file and, if so, returns a rejection response that
11// points callers at the chat-specific plan path.
12func 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
41func sharedPlanPathMessage(requestedPath, chatPath string) string {
42 return fmt.Sprintf(

Callers 4

executeEditFilesToolFunction · 0.85
TestRejectSharedPlanPathFunction · 0.85
executeWriteFileToolFunction · 0.85
executeProposePlanToolFunction · 0.85

Calls 4

LooksLikeHomePlanFileFunction · 0.85
sharedPlanPathMessageFunction · 0.85

Tested by 1

TestRejectSharedPlanPathFunction · 0.68