Unified Agent + reusable Go agent core.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: remove dead code batch A

Lyric b1f8cd9a bd916fa6

+1 -303
-42
agent/engine.go
··· 217 217 }) 218 218 } 219 219 220 - func (e *Engine) loadedSkillNames() map[string]bool { 221 - out := make(map[string]bool) 222 - spec := e.spec 223 - if len(spec.Blocks) == 0 { 224 - return out 225 - } 226 - for _, blk := range spec.Blocks { 227 - title := strings.TrimSpace(blk.Title) 228 - if title == "" { 229 - continue 230 - } 231 - name := title 232 - id := "" 233 - if i := strings.LastIndexByte(title, '('); i >= 0 && strings.HasSuffix(title, ")") { 234 - name = strings.TrimSpace(title[:i]) 235 - id = strings.TrimSpace(strings.TrimSuffix(title[i+1:], ")")) 236 - } 237 - if strings.TrimSpace(name) != "" { 238 - out[strings.ToLower(name)] = true 239 - } 240 - if strings.TrimSpace(id) != "" { 241 - out[strings.ToLower(id)] = true 242 - } 243 - } 244 - return out 245 - } 246 - 247 220 func missingFiles(paths []string) []string { 248 221 if len(paths) == 0 { 249 222 return nil ··· 273 246 sort.Strings(out) 274 247 return out 275 248 } 276 - 277 - func isHeartbeatMeta(meta map[string]any) bool { 278 - if len(meta) == 0 { 279 - return false 280 - } 281 - if v, ok := meta["trigger"]; ok { 282 - if s, ok := v.(string); ok && strings.TrimSpace(strings.ToLower(s)) == "heartbeat" { 283 - return true 284 - } 285 - } 286 - if _, ok := meta["heartbeat"]; ok { 287 - return true 288 - } 289 - return false 290 - }
+1 -34
cmd/mistermorph/contactscmd/contacts.go
··· 1 1 package contactscmd 2 2 3 - import ( 4 - "strings" 5 - "time" 6 - 7 - "github.com/quailyquaily/mistermorph/contacts" 8 - "github.com/quailyquaily/mistermorph/internal/pathutil" 9 - "github.com/quailyquaily/mistermorph/internal/statepaths" 10 - "github.com/spf13/cobra" 11 - "github.com/spf13/viper" 12 - ) 3 + import "github.com/spf13/cobra" 13 4 14 5 func New() *cobra.Command { 15 6 cmd := &cobra.Command{ ··· 19 10 cmd.PersistentFlags().String("dir", "", "Contacts state directory (defaults to file_state_dir/contacts)") 20 11 return cmd 21 12 } 22 - 23 - func serviceFromCmd(cmd *cobra.Command) *contacts.Service { 24 - dir, _ := cmd.Flags().GetString("dir") 25 - dir = strings.TrimSpace(dir) 26 - if dir == "" { 27 - dir = statepaths.ContactsDir() 28 - } else { 29 - dir = pathutil.ExpandHomePath(dir) 30 - } 31 - return contacts.NewServiceWithOptions( 32 - contacts.NewFileStore(dir), 33 - contacts.ServiceOptions{ 34 - FailureCooldown: configuredContactsFailureCooldown(), 35 - }, 36 - ) 37 - } 38 - 39 - func configuredContactsFailureCooldown() time.Duration { 40 - v := viper.GetDuration("contacts.proactive.failure_cooldown") 41 - if v <= 0 { 42 - return 72 * time.Hour 43 - } 44 - return v 45 - }
-4
cmd/mistermorph/guard_config.go
··· 11 11 "github.com/spf13/viper" 12 12 ) 13 13 14 - func guardFromViper(log *slog.Logger) *guard.Guard { 15 - return buildGuardFromConfig(loadGuardConfigFromViper(), log) 16 - } 17 - 18 14 type guardConfigSnapshot struct { 19 15 Enabled bool 20 16 Config guard.Config
-4
cmd/mistermorph/install.go
··· 326 326 return string(data), nil 327 327 } 328 328 329 - func patchInitConfig(cfg string, dir string) string { 330 - return patchInitConfigWithSetup(cfg, dir, nil) 331 - } 332 - 333 329 func patchInitConfigWithSetup(cfg string, dir string, setup *installConfigSetup) string { 334 330 if strings.TrimSpace(cfg) == "" { 335 331 return cfg
-4
cmd/mistermorph/registry.go
··· 14 14 "github.com/spf13/viper" 15 15 ) 16 16 17 - func registryFromViper() *tools.Registry { 18 - return buildRegistryFromConfig(loadRegistryConfigFromViper(), slog.Default()) 19 - } 20 - 21 17 type registryConfig struct { 22 18 UserAgent string 23 19 SecretsEnabled bool
-40
cmd/mistermorph/skillscmd/skills_install_builtin.go
··· 14 14 "os" 15 15 "path/filepath" 16 16 "sort" 17 - "strconv" 18 17 "strings" 19 18 "time" 20 19 ··· 1065 1064 return strings.TrimSpace(v) 1066 1065 } 1067 1066 return "" 1068 - } 1069 - 1070 - func sanitizeSkillDirName(name string) string { 1071 - name = strings.TrimSpace(name) 1072 - if name == "" { 1073 - return "" 1074 - } 1075 - // Prefer stable, simple directory names. 1076 - name = strings.ToLower(name) 1077 - var b strings.Builder 1078 - for _, r := range name { 1079 - switch { 1080 - case r >= 'a' && r <= 'z': 1081 - b.WriteRune(r) 1082 - case r >= '0' && r <= '9': 1083 - b.WriteRune(r) 1084 - case r == '-' || r == '_' || r == '.': 1085 - b.WriteRune(r) 1086 - case r == ' ': 1087 - b.WriteByte('-') 1088 - default: 1089 - // drop 1090 - } 1091 - } 1092 - out := strings.Trim(b.String(), "-") 1093 - if out == "" { 1094 - return "" 1095 - } 1096 - // Cap length to something reasonable for a directory name. 1097 - if len(out) > 80 { 1098 - out = out[:80] 1099 - out = strings.TrimRight(out, "-") 1100 - } 1101 - // Avoid windows reserved device names (defensive). 1102 - switch out { 1103 - case "con", "prn", "aux", "nul": 1104 - out = out + "-" + strconv.FormatInt(time.Now().Unix(), 10) 1105 - } 1106 - return out 1107 1067 } 1108 1068 1109 1069 func validateSkillDirName(name string) (string, error) {
-10
contacts/file_store.go
··· 1156 1156 return out 1157 1157 } 1158 1158 1159 - func clamp(v float64, min float64, max float64) float64 { 1160 - if v < min { 1161 - return min 1162 - } 1163 - if v > max { 1164 - return max 1165 - } 1166 - return v 1167 - } 1168 - 1169 1159 func busInboxRecordKey(channel string, platformMessageID string) (string, error) { 1170 1160 normalizedChannel, err := normalizeBusChannel(channel) 1171 1161 if err != nil {
-4
internal/llmutil/llmutil.go
··· 162 162 } 163 163 } 164 164 165 - func toolsEmulationModeFromViper() (string, error) { 166 - return toolsEmulationModeFromValue(RuntimeValuesFromViper().ToolsEmulationMode) 167 - } 168 - 169 165 func toolsEmulationModeFromValue(raw string) (string, error) { 170 166 mode := strings.ToLower(strings.TrimSpace(raw)) 171 167 if mode == "" {
-9
secrets/types.go
··· 292 292 return false 293 293 } 294 294 295 - func intInSlice(n int, haystack []int) bool { 296 - for _, x := range haystack { 297 - if x == n { 298 - return true 299 - } 300 - } 301 - return false 302 - } 303 - 304 295 func parseURLPrefixRules(prefixes []string, profileID string) ([]URLPrefixRule, error) { 305 296 var out []URLPrefixRule 306 297 seen := make(map[string]bool, len(prefixes))
-152
tools/builtin/params.go
··· 1 1 package builtin 2 2 3 3 import ( 4 - "fmt" 5 4 "math" 6 5 "strconv" 7 6 "strings" 8 - "time" 9 7 ) 10 - 11 - func parseIntDefault(raw any, fallback int) int { 12 - switch v := raw.(type) { 13 - case int: 14 - return v 15 - case int8: 16 - return int(v) 17 - case int16: 18 - return int(v) 19 - case int32: 20 - return int(v) 21 - case int64: 22 - return int(v) 23 - case float32: 24 - return int(v) 25 - case float64: 26 - return int(v) 27 - case string: 28 - text := strings.TrimSpace(v) 29 - if text == "" { 30 - return fallback 31 - } 32 - n, err := strconv.Atoi(text) 33 - if err != nil { 34 - return fallback 35 - } 36 - return n 37 - default: 38 - return fallback 39 - } 40 - } 41 - 42 - func parseBoolDefault(raw any, fallback bool) bool { 43 - switch v := raw.(type) { 44 - case bool: 45 - return v 46 - case string: 47 - text := strings.TrimSpace(strings.ToLower(v)) 48 - if text == "" { 49 - return fallback 50 - } 51 - if text == "1" || text == "true" || text == "yes" || text == "y" { 52 - return true 53 - } 54 - if text == "0" || text == "false" || text == "no" || text == "n" { 55 - return false 56 - } 57 - return fallback 58 - default: 59 - return fallback 60 - } 61 - } 62 - 63 - func parseFloatDefault(raw any, fallback float64) float64 { 64 - switch v := raw.(type) { 65 - case float64: 66 - return v 67 - case float32: 68 - return float64(v) 69 - case int: 70 - return float64(v) 71 - case int64: 72 - return float64(v) 73 - case string: 74 - text := strings.TrimSpace(v) 75 - if text == "" { 76 - return fallback 77 - } 78 - n, err := strconv.ParseFloat(text, 64) 79 - if err != nil { 80 - return fallback 81 - } 82 - return n 83 - default: 84 - return fallback 85 - } 86 - } 87 - 88 - func parseDuration(raw any, fallback time.Duration) (time.Duration, error) { 89 - switch v := raw.(type) { 90 - case nil: 91 - return fallback, nil 92 - case string: 93 - text := strings.TrimSpace(v) 94 - if text == "" { 95 - return fallback, nil 96 - } 97 - d, err := time.ParseDuration(text) 98 - if err != nil { 99 - return 0, err 100 - } 101 - return d, nil 102 - case float64: 103 - if math.IsNaN(v) || math.IsInf(v, 0) { 104 - return 0, fmt.Errorf("invalid duration number") 105 - } 106 - return time.Duration(v) * time.Second, nil 107 - case int: 108 - return time.Duration(v) * time.Second, nil 109 - case int64: 110 - return time.Duration(v) * time.Second, nil 111 - default: 112 - return fallback, nil 113 - } 114 - } 115 - 116 - func parseStringSlice(raw any) []string { 117 - switch v := raw.(type) { 118 - case []string: 119 - out := make([]string, 0, len(v)) 120 - for _, item := range v { 121 - s := strings.TrimSpace(item) 122 - if s == "" { 123 - continue 124 - } 125 - out = append(out, s) 126 - } 127 - return out 128 - case []any: 129 - out := make([]string, 0, len(v)) 130 - for _, item := range v { 131 - s, _ := item.(string) 132 - s = strings.TrimSpace(s) 133 - if s == "" { 134 - continue 135 - } 136 - out = append(out, s) 137 - } 138 - return out 139 - default: 140 - return nil 141 - } 142 - } 143 - 144 - func dedupeStrings(values []string) []string { 145 - if len(values) == 0 { 146 - return nil 147 - } 148 - out := make([]string, 0, len(values)) 149 - seen := map[string]bool{} 150 - for _, raw := range values { 151 - v := strings.TrimSpace(raw) 152 - if v == "" || seen[v] { 153 - continue 154 - } 155 - seen[v] = true 156 - out = append(out, v) 157 - } 158 - return out 159 - } 160 8 161 9 func asInt64(v any) (int64, bool) { 162 10 switch x := v.(type) {