@@ -34,6 +34,20 @@ const (
3434 ShellTypePowerShell
3535)
3636
37+// CrushEnvMarkers returns a fresh slice of the environment variables that
38+// Crush unconditionally sets on every shell it spawns — both the interactive
39+// bash tool's [Shell] and the hook runner's [Run] calls. Tools that want to
40+// detect "am I being invoked by an AI agent?" can check any of these.
41+// Keeping them in one place guarantees the two shell surfaces cannot drift.
42+// A fresh slice is returned on every call so callers may append freely.
43+func CrushEnvMarkers() []string {
44+ return []string{
45+ "CRUSH=1",
46+ "AGENT=crush",
47+ "AI_AGENT=crush",
48+ }
49+}
50+
3751// Logger interface for optional logging
3852type Logger interface {
3953 InfoPersist(msg string, keysAndValues ...any)
@@ -81,12 +95,7 @@ func NewShell(opts *Options) *Shell {
8195 }
8296
8397 // Allow tools to detect execution by Crush.
84− env = append(
85− env,
86− "CRUSH=1",
87− "AGENT=crush",
88− "AI_AGENT=crush",
89− )
98+ env = append(env, CrushEnvMarkers()...)
9099
91100 logger := opts.Logger
92101 if logger == nil {