chore: avoid hardcoding file paths via MIMI_SPIFFS_BASE
Use MIMI_SPIFFS_BASE to centralize file path definitions, making the base path configurable instead of hardcoded. Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "tool_registry.h"
|
||||
#include "mimi_config.h"
|
||||
#include "tools/tool_web_search.h"
|
||||
#include "tools/tool_get_time.h"
|
||||
#include "tools/tool_files.h"
|
||||
@@ -83,10 +84,10 @@ esp_err_t tool_registry_init(void)
|
||||
/* Register read_file */
|
||||
mimi_tool_t rf = {
|
||||
.name = "read_file",
|
||||
.description = "Read a file from SPIFFS storage. Path must start with /spiffs/.",
|
||||
.description = "Read a file from SPIFFS storage. Path must start with " MIMI_SPIFFS_BASE "/.",
|
||||
.input_schema_json =
|
||||
"{\"type\":\"object\","
|
||||
"\"properties\":{\"path\":{\"type\":\"string\",\"description\":\"Absolute path starting with /spiffs/\"}},"
|
||||
"\"properties\":{\"path\":{\"type\":\"string\",\"description\":\"Absolute path starting with " MIMI_SPIFFS_BASE "/\"}},"
|
||||
"\"required\":[\"path\"]}",
|
||||
.execute = tool_read_file_execute,
|
||||
};
|
||||
@@ -95,10 +96,10 @@ esp_err_t tool_registry_init(void)
|
||||
/* Register write_file */
|
||||
mimi_tool_t wf = {
|
||||
.name = "write_file",
|
||||
.description = "Write or overwrite a file on SPIFFS storage. Path must start with /spiffs/.",
|
||||
.description = "Write or overwrite a file on SPIFFS storage. Path must start with " MIMI_SPIFFS_BASE "/.",
|
||||
.input_schema_json =
|
||||
"{\"type\":\"object\","
|
||||
"\"properties\":{\"path\":{\"type\":\"string\",\"description\":\"Absolute path starting with /spiffs/\"},"
|
||||
"\"properties\":{\"path\":{\"type\":\"string\",\"description\":\"Absolute path starting with " MIMI_SPIFFS_BASE "/\"},"
|
||||
"\"content\":{\"type\":\"string\",\"description\":\"File content to write\"}},"
|
||||
"\"required\":[\"path\",\"content\"]}",
|
||||
.execute = tool_write_file_execute,
|
||||
@@ -111,7 +112,7 @@ esp_err_t tool_registry_init(void)
|
||||
.description = "Find and replace text in a file on SPIFFS. Replaces first occurrence of old_string with new_string.",
|
||||
.input_schema_json =
|
||||
"{\"type\":\"object\","
|
||||
"\"properties\":{\"path\":{\"type\":\"string\",\"description\":\"Absolute path starting with /spiffs/\"},"
|
||||
"\"properties\":{\"path\":{\"type\":\"string\",\"description\":\"Absolute path starting with " MIMI_SPIFFS_BASE "/\"},"
|
||||
"\"old_string\":{\"type\":\"string\",\"description\":\"Text to find\"},"
|
||||
"\"new_string\":{\"type\":\"string\",\"description\":\"Replacement text\"}},"
|
||||
"\"required\":[\"path\",\"old_string\",\"new_string\"]}",
|
||||
@@ -125,7 +126,7 @@ esp_err_t tool_registry_init(void)
|
||||
.description = "List files on SPIFFS storage, optionally filtered by path prefix.",
|
||||
.input_schema_json =
|
||||
"{\"type\":\"object\","
|
||||
"\"properties\":{\"prefix\":{\"type\":\"string\",\"description\":\"Optional path prefix filter, e.g. /spiffs/memory/\"}},"
|
||||
"\"properties\":{\"prefix\":{\"type\":\"string\",\"description\":\"Optional path prefix filter, e.g. " MIMI_SPIFFS_BASE "/memory/\"}},"
|
||||
"\"required\":[]}",
|
||||
.execute = tool_list_dir_execute,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user