| 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 | } |
| Josh Bleecher Snyder | 112b923 | 2025-05-23 11:26:33 -0700 | [diff] [blame] | 26 | |
| 27 | type sessionIDCtxKeyType string |
| 28 | |
| 29 | const sessionIDCtxKey sessionIDCtxKeyType = "sessionID" |
| 30 | |
| 31 | func WithSessionID(ctx context.Context, sessionID string) context.Context { |
| 32 | return context.WithValue(ctx, sessionIDCtxKey, sessionID) |
| 33 | } |
| 34 | |
| 35 | func SessionID(ctx context.Context) string { |
| 36 | sessionID, _ := ctx.Value(sessionIDCtxKey).(string) |
| 37 | return sessionID |
| 38 | } |