| Earl Lee | 2e463fb | 2025-04-17 11:22:22 -0700 | [diff] [blame] | 1 | // Package claudetool provides tools for Claude AI models. |
| 2 | // |
| 3 | // When adding, removing, or modifying tools in this package, |
| 4 | // remember to update the tool display template in termui/termui.go |
| 5 | // to ensure proper tool output formatting. |
| 6 | package claudetool |
| 7 | |
| 8 | import ( |
| Earl Lee | 2e463fb | 2025-04-17 11:22:22 -0700 | [diff] [blame] | 9 | "context" |
| Earl Lee | 2e463fb | 2025-04-17 11:22:22 -0700 | [diff] [blame] | 10 | ) |
| 11 | |
| 12 | type workingDirCtxKeyType string |
| 13 | |
| 14 | const workingDirCtxKey workingDirCtxKeyType = "workingDir" |
| 15 | |
| 16 | func WithWorkingDir(ctx context.Context, wd string) context.Context { |
| 17 | return context.WithValue(ctx, workingDirCtxKey, wd) |
| 18 | } |
| 19 | |
| 20 | func WorkingDir(ctx context.Context) string { |
| 21 | // If cmd.Dir is empty, it uses the current working directory, |
| 22 | // so we can use that as a fallback. |
| 23 | wd, _ := ctx.Value(workingDirCtxKey).(string) |
| 24 | return wd |
| 25 | } |