chore: remove dead code and fix unsafe patterns

- Remove unused context_build_messages() (superseded by direct cJSON in agent_loop)
- Remove unused llm_chat() and its helper extract_text_* functions (superseded by llm_chat_tools)
- Remove ota_manager.c from build (never called)
- Remove config_screen.c stub from build (no-op module)
- Remove unused PWR_KEY_State, Button_GPIO_Get_Level; drop config_screen dependency from button_driver
- Fix incorrect type cast in tool_get_time.c (char[64] cast to char**)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
crispyberry
2026-02-21 17:11:15 +08:00
parent 0b9e66aa4a
commit c06f706ffd
7 changed files with 23 additions and 241 deletions

View File

@@ -6,7 +6,6 @@
#include <stdio.h>
#include <string.h>
#include "esp_log.h"
#include "cJSON.h"
static const char *TAG = "context";
@@ -95,33 +94,3 @@ esp_err_t context_build_system_prompt(char *buf, size_t size)
ESP_LOGI(TAG, "System prompt built: %d bytes", (int)off);
return ESP_OK;
}
esp_err_t context_build_messages(const char *history_json, const char *user_message,
char *buf, size_t size)
{
/* Parse existing history */
cJSON *history = cJSON_Parse(history_json);
if (!history) {
history = cJSON_CreateArray();
}
/* Append current user message */
cJSON *user_msg = cJSON_CreateObject();
cJSON_AddStringToObject(user_msg, "role", "user");
cJSON_AddStringToObject(user_msg, "content", user_message);
cJSON_AddItemToArray(history, user_msg);
/* Serialize */
char *json_str = cJSON_PrintUnformatted(history);
cJSON_Delete(history);
if (json_str) {
strncpy(buf, json_str, size - 1);
buf[size - 1] = '\0';
free(json_str);
} else {
snprintf(buf, size, "[{\"role\":\"user\",\"content\":\"%s\"}]", user_message);
}
return ESP_OK;
}

View File

@@ -12,14 +12,3 @@
*/
esp_err_t context_build_system_prompt(char *buf, size_t size);
/**
* Build the complete messages JSON array for LLM call.
* Combines session history + current user message.
*
* @param history_json JSON array from session_get_history_json()
* @param user_message Current user message text
* @param buf Output buffer
* @param size Buffer size
*/
esp_err_t context_build_messages(const char *history_json, const char *user_message,
char *buf, size_t size);