Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 5 additions & 23 deletions internal/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"
)

// Check represents a single health check result.
Expand Down Expand Up @@ -108,7 +109,7 @@ func checkClaudeHooks(dir string) Check {
}
for _, p := range paths {
if data, err := os.ReadFile(p); err == nil {
if containsChitin(data) {
if strings.Contains(string(data), "chitin") {
return Check{Name: "Claude Code hooks", OK: true, Detail: p, Critical: false}
}
}
Expand All @@ -123,7 +124,7 @@ func checkCopilotHooks(dir string) Check {
}
for _, p := range paths {
if data, err := os.ReadFile(p); err == nil {
if containsChitin(data) {
if strings.Contains(string(data), "chitin") {
return Check{Name: "Copilot hooks", OK: true, Detail: p, Critical: false}
}
}
Expand All @@ -138,7 +139,7 @@ func checkCodexHooks(dir string) Check {
}
for _, p := range paths {
if data, err := os.ReadFile(p); err == nil {
if containsChitin(data) {
if strings.Contains(string(data), "chitin") {
return Check{Name: "Codex hooks", OK: true, Detail: p, Critical: false}
}
}
Expand All @@ -153,7 +154,7 @@ func checkGeminiHooks(dir string) Check {
}
for _, p := range paths {
if data, err := os.ReadFile(p); err == nil {
if containsChitin(data) {
if strings.Contains(string(data), "chitin") {
return Check{Name: "Gemini hooks", OK: true, Detail: p, Critical: false}
}
}
Expand All @@ -169,25 +170,6 @@ func checkIdentity(dir string) Check {
return Check{Name: "Agent identity", OK: false, Detail: "no .chitin-identity file", Critical: false}
}

func containsChitin(data []byte) bool {
// Simple check: does the config reference chitin?
s := string(data)
return len(s) > 0 && contains(s, "chitin")
}

func contains(s, substr string) bool {
return len(s) >= len(substr) && searchString(s, substr)
}

func searchString(s, substr string) bool {
for i := 0; i <= len(s)-len(substr); i++ {
if s[i:i+len(substr)] == substr {
return true
}
}
return false
}

func homeDir() string {
home, err := os.UserHomeDir()
if err != nil {
Expand Down
Loading