Files
雷电芽衣 34ff4c1ea8 chore(go): audit providers kimi grok qwen letta
Move Kimi, Grok, and Qwen onto managed_runtime.go and shell_command.go;
share the encoded and shell command builders and the quoted Windows
legacy parser with Droid; split managed_changes.go; dedupe Letta's hook
entry filtering and stop swallowing settings read errors.

Claude-Session: https://claude.ai/code/session_01Agoc9bRVE9KL7mmWtey9Vq
2026-09-03 02:16:58 -04:00

85 lines
1.9 KiB
Go

package plugins
import "strings"
// extractElydoraScriptPath reads the legacy shared command-hook shape.
func extractElydoraScriptPath(hookArray any) string {
entries, _ := hookArray.([]any)
for _, entry := range entries {
object, ok := entry.(map[string]any)
if !ok {
continue
}
if hooks, ok := object["hooks"].([]any); ok {
for _, hook := range hooks {
handler, ok := hook.(map[string]any)
if !ok {
continue
}
if command, _ := handler["command"].(string); strings.Contains(
command,
"elydora",
) {
return extractPathFromNodeCommand(command)
}
}
}
if command, _ := object["command"].(string); strings.Contains(
command,
"elydora",
) {
return extractPathFromNodeCommand(command)
}
}
return ""
}
func extractPathFromNodeCommand(command string) string {
command = strings.TrimSpace(command)
if strings.HasPrefix(command, "node ") {
return strings.TrimSpace(command[5:])
}
return ""
}
func withoutElydoraEntries(hookArray any) []any {
entries, _ := hookArray.([]any)
kept := make([]any, 0, len(entries))
for _, entry := range entries {
if object, ok := entry.(map[string]any); ok && isElydoraHookEntry(object) {
continue
}
kept = append(kept, entry)
}
return kept
}
func hasElydoraEntry(hookArray any) bool {
entries, _ := hookArray.([]any)
for _, entry := range entries {
if object, ok := entry.(map[string]any); ok && isElydoraHookEntry(object) {
return true
}
}
return false
}
func isElydoraHookEntry(object map[string]any) bool {
if hooks, ok := object["hooks"].([]any); ok {
for _, hook := range hooks {
handler, ok := hook.(map[string]any)
if !ok {
continue
}
if command, _ := handler["command"].(string); strings.Contains(
command,
"elydora",
) {
return true
}
}
}
command, _ := object["command"].(string)
return strings.Contains(command, "elydora")
}