Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
filesystem.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
12#pragma once
13
17
18#include <filesystem>
19#include <memory>
20#include <string>
21#include <unordered_map>
22#include <vector>
23
24namespace entropic {
25
31public:
38 void record_read(const std::string& path, size_t hash);
39
47 bool was_read_unchanged(const std::string& path,
48 size_t current_hash) const;
49
56 bool was_read(const std::string& path) const;
57
58private:
59 std::unordered_map<std::string, size_t> reads_;
60};
61
62// Forward declarations for tool classes
63class ReadFileTool;
64class WriteFileTool;
65class EditFileTool;
66class GlobTool;
67class GrepTool;
69
75public:
84 FilesystemServer(const std::filesystem::path& root_dir,
86 const std::string& data_dir,
87 int model_context_bytes = 0);
88
90
97 bool skip_duplicate_check(const std::string& tool_name) const override;
98
105 bool set_working_dir(const std::string& path) override;
106
112 const std::filesystem::path& root_dir() const;
113
120
126 const FilesystemConfig& config() const;
127
133 int max_read_bytes() const;
134
142 std::filesystem::path resolve_path(const std::string& requested) const;
143
154 const IgnoreMatcher& ignore() const;
155
156private:
163 void create_fs_tools(const std::string& data_dir);
164
170 void register_fs_tools();
171
172 std::filesystem::path root_dir_;
173 FilesystemConfig config_;
174 int max_read_bytes_ = 0;
175 FileAccessTracker tracker_;
176 IgnoreMatcher ignore_;
177
178 // Owned tool instances
179 std::unique_ptr<ReadFileTool> read_file_;
180 std::unique_ptr<WriteFileTool> write_file_;
181 std::unique_ptr<EditFileTool> edit_file_;
182 std::unique_ptr<GlobTool> glob_;
183 std::unique_ptr<GrepTool> grep_;
184 std::unique_ptr<ListDirectoryTool> list_dir_;
185};
186
187} // namespace entropic
Tool for in-place file editing (string replace or insert).
Tracks file read state for read-before-write enforcement.
Definition filesystem.h:30
bool was_read(const std::string &path) const
Check if a file was ever read.
void record_read(const std::string &path, size_t hash)
Record that a file was read.
bool was_read_unchanged(const std::string &path, size_t current_hash) const
Check if a file was read and content unchanged.
Filesystem MCP server with read-before-write enforcement.
Definition filesystem.h:74
int max_read_bytes() const
Get max read bytes (size gate).
const IgnoreMatcher & ignore() const
Get the ignore matcher (#15, v2.1.4).
bool skip_duplicate_check(const std::string &tool_name) const override
read_file must always execute (updates FileAccessTracker).
bool set_working_dir(const std::string &path) override
Set working directory (changes root_dir).
~FilesystemServer() override
Destructor (default, unique_ptr cleanup).
std::filesystem::path resolve_path(const std::string &requested) const
Resolve and validate a path against root.
const FilesystemConfig & config() const
Get the filesystem config.
FileAccessTracker & tracker()
Get the file access tracker.
const std::filesystem::path & root_dir() const
Get the root directory.
Tool for recursive file pattern matching.
Tool for regex content search across files.
gitignore-style path matcher (#15, v2.1.4).
Tool for listing directory contents.
Concrete base class for MCP servers (80% logic).
Definition server_base.h:66
Tool for reading file contents with line numbering.
Tool for writing file contents with read-before-write.
Configuration structs with defaults.
Path-relative ignore matching honoring .gitignore + .explorerignore.
Activate model on GPU (WARM → ACTIVE).
MCPServerBase concrete base class + ServerResponse.
Filesystem MCP server configuration.
Definition config.h:410