diff --git a/pkg/autonomy/engine.go b/pkg/autonomy/engine.go index 5ec520a..4a284ec 100644 --- a/pkg/autonomy/engine.go +++ b/pkg/autonomy/engine.go @@ -353,7 +353,7 @@ func schedulingScore(st *taskState, now time.Time) int { } func deriveResourceKeys(content string) []string { - raw := strings.TrimSpace(content) + raw := content if raw == "" { return nil } @@ -398,7 +398,7 @@ func parseExplicitResourceKeys(content string) []string { if end < 0 { return nil } - body := strings.TrimSpace(rest[:end]) + body := rest[:end] if body == "" { return nil } @@ -479,13 +479,13 @@ func (e *Engine) scanTodos() []todoItem { for _, line := range strings.Split(string(data), "\n") { t := strings.TrimSpace(line) if strings.HasPrefix(t, "- [ ]") { - content := strings.TrimSpace(strings.TrimPrefix(t, "- [ ]")) + content := strings.TrimPrefix(t, "- [ ]") priority, dueAt, normalized := parseTodoAttributes(content) merge(todoItem{ID: hashID(normalized), Content: normalized, Priority: priority, DueAt: dueAt}) continue } if strings.HasPrefix(strings.ToLower(t), "todo:") { - content := strings.TrimSpace(t[5:]) + content := t[5:] priority, dueAt, normalized := parseTodoAttributes(content) merge(todoItem{ID: hashID(normalized), Content: normalized, Priority: priority, DueAt: dueAt}) } @@ -499,7 +499,7 @@ func (e *Engine) scanTodos() []todoItem { if status == "done" { continue } - content := strings.TrimSpace(it.Content) + content := it.Content if content == "" { continue } @@ -511,7 +511,7 @@ func (e *Engine) scanTodos() []todoItem { if priority == "" { priority = "normal" } - merge(todoItem{ID: id, Content: content, Priority: priority, DueAt: strings.TrimSpace(it.DueAt)}) + merge(todoItem{ID: id, Content: content, Priority: priority, DueAt: it.DueAt}) } } @@ -571,7 +571,7 @@ func (e *Engine) sendFailureNotification(st *taskState, reason string) { e.bus.PublishOutbound(bus.OutboundMessage{ Channel: e.opts.DefaultNotifyChannel, ChatID: e.opts.DefaultNotifyChatID, - Content: fmt.Sprintf(tpl, shortTask(st.Content), strings.TrimSpace(reason), shortTask(st.Content)), + Content: fmt.Sprintf(tpl, shortTask(st.Content), reason, shortTask(st.Content)), }) } @@ -615,7 +615,7 @@ func (e *Engine) writeTriggerAudit(action string, st *taskState, errText string) "action": action, "session": "autonomy:" + st.ID, } - if strings.TrimSpace(errText) != "" { + if errText != "" { row["error"] = errText } if b, err := json.Marshal(row); err == nil { @@ -641,7 +641,7 @@ func (e *Engine) writeTriggerAudit(action string, st *taskState, errText string) act := strings.ToLower(strings.TrimSpace(action)) if act != "" { stats.Counts["autonomy:"+act]++ - reason := strings.ToLower(strings.TrimSpace(errText)) + reason := strings.ToLower(errText) if reason != "" { reason = strings.ReplaceAll(reason, " ", "_") reason = strings.ReplaceAll(reason, ":", "_") @@ -742,7 +742,7 @@ func (e *Engine) persistStateLocked() { func parseTodoAttributes(content string) (priority, dueAt, normalized string) { priority = "normal" - normalized = strings.TrimSpace(content) + normalized = content l := strings.ToLower(normalized) if strings.HasPrefix(l, "[high]") || strings.HasPrefix(l, "p1:") { priority = "high" @@ -763,7 +763,7 @@ func parseTodoAttributes(content string) (priority, dueAt, normalized string) { normalized = strings.TrimSpace(normalized[:idx]) } if normalized == "" { - normalized = strings.TrimSpace(content) + normalized = content } return priority, dueAt, normalized } @@ -939,7 +939,7 @@ func (e *Engine) isHighValueCompletion(st *taskState) bool { if strings.TrimSpace(st.DueAt) != "" { return true } - s := strings.ToLower(strings.TrimSpace(st.Content)) + s := strings.ToLower(st.Content) keywords := e.opts.ImportantKeywords if len(keywords) == 0 { keywords = []string{"urgent", "payment", "release", "deadline", "p0", "asap"} diff --git a/pkg/nodes/registry_server.go b/pkg/nodes/registry_server.go index b542f42..881b7d0 100644 --- a/pkg/nodes/registry_server.go +++ b/pkg/nodes/registry_server.go @@ -137,7 +137,7 @@ func (s *RegistryServer) handleHeartbeat(w http.ResponseWriter, r *http.Request) var body struct { ID string `json:"id"` } - if err := json.NewDecoder(r.Body).Decode(&body); err != nil || strings.TrimSpace(body.ID) == "" { + if err := json.NewDecoder(r.Body).Decode(&body); err != nil || body.ID == "" { http.Error(w, "id required", http.StatusBadRequest) return } @@ -593,7 +593,7 @@ func (s *RegistryServer) handleWebUINodes(w http.ResponseWriter, r *http.Request http.Error(w, "invalid json", http.StatusBadRequest) return } - action := strings.ToLower(strings.TrimSpace(body.Action)) + action := strings.ToLower(body.Action) if action != "delete" { http.Error(w, "unsupported action", http.StatusBadRequest) return @@ -602,7 +602,7 @@ func (s *RegistryServer) handleWebUINodes(w http.ResponseWriter, r *http.Request http.Error(w, "nodes manager unavailable", http.StatusInternalServerError) return } - id := strings.TrimSpace(body.ID) + id := body.ID ok := s.mgr.Remove(id) _ = json.NewEncoder(w).Encode(map[string]interface{}{"ok": true, "deleted": ok, "id": id}) default: @@ -665,7 +665,7 @@ func (s *RegistryServer) handleWebUISkills(w http.ResponseWriter, r *http.Reques http.Error(w, "unauthorized", http.StatusUnauthorized) return } - skillsDir := filepath.Join(strings.TrimSpace(s.workspacePath), "skills") + skillsDir := filepath.Join(s.workspacePath, "skills") if strings.TrimSpace(skillsDir) == "" { http.Error(w, "workspace not configured", http.StatusInternalServerError) return @@ -1225,7 +1225,7 @@ func (s *RegistryServer) handleWebUISessions(w http.ResponseWriter, r *http.Requ http.Error(w, "method not allowed", http.StatusMethodNotAllowed) return } - sessionsDir := filepath.Join(filepath.Dir(strings.TrimSpace(s.workspacePath)), "agents", "main", "sessions") + sessionsDir := filepath.Join(filepath.Dir(s.workspacePath), "agents", "main", "sessions") _ = os.MkdirAll(sessionsDir, 0755) type item struct { Key string `json:"key"` @@ -1269,7 +1269,7 @@ func (s *RegistryServer) handleWebUIMemory(w http.ResponseWriter, r *http.Reques http.Error(w, "unauthorized", http.StatusUnauthorized) return } - memoryDir := filepath.Join(strings.TrimSpace(s.workspacePath), "memory") + memoryDir := filepath.Join(s.workspacePath, "memory") _ = os.MkdirAll(memoryDir, 0755) switch r.Method { case http.MethodGet: @@ -1311,7 +1311,7 @@ func (s *RegistryServer) handleWebUIMemory(w http.ResponseWriter, r *http.Reques http.Error(w, "invalid json", http.StatusBadRequest) return } - clean := filepath.Clean(strings.TrimSpace(body.Path)) + clean := filepath.Clean(body.Path) if clean == "" || strings.HasPrefix(clean, "..") { http.Error(w, "invalid path", http.StatusBadRequest) return @@ -1323,7 +1323,7 @@ func (s *RegistryServer) handleWebUIMemory(w http.ResponseWriter, r *http.Reques } _ = json.NewEncoder(w).Encode(map[string]interface{}{"ok": true, "path": clean}) case http.MethodDelete: - path := filepath.Clean(strings.TrimSpace(r.URL.Query().Get("path"))) + path := filepath.Clean(r.URL.Query().Get("path")) if path == "" || strings.HasPrefix(path, "..") { http.Error(w, "invalid path", http.StatusBadRequest) return