Entropic 2.11.1
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
40
47 bool was_read(const std::string& path) const;
48
49private:
50 std::unordered_map<std::string, size_t> reads_;
51};
52
53// Forward declarations for tool classes
54class ReadFileTool;
55class WriteFileTool;
56class EditFileTool;
57class GlobTool;
58class GrepTool;
60
66public:
75 FilesystemServer(const std::filesystem::path& root_dir,
77 const std::string& data_dir,
78 int model_context_bytes = 0);
79
81
88 bool skip_duplicate_check(const std::string& tool_name) const override;
89
96 bool set_working_dir(const std::string& path) override;
97
103 const std::filesystem::path& root_dir() const;
104
111
117 const FilesystemConfig& config() const;
118
124 int max_read_bytes() const;
125
133 std::filesystem::path resolve_path(const std::string& requested) const;
134
145 const IgnoreMatcher& ignore() const;
146
147private:
154 void create_fs_tools(const std::string& data_dir);
155
161 void register_fs_tools();
162
163 std::filesystem::path root_dir_;
164 FilesystemConfig config_;
165 int max_read_bytes_ = 0;
166 FileAccessTracker tracker_;
167 IgnoreMatcher ignore_;
168
169 // Owned tool instances
170 std::unique_ptr<ReadFileTool> read_file_;
171 std::unique_ptr<WriteFileTool> write_file_;
172 std::unique_ptr<EditFileTool> edit_file_;
173 std::unique_ptr<GlobTool> glob_;
174 std::unique_ptr<GrepTool> grep_;
175 std::unique_ptr<ListDirectoryTool> list_dir_;
176};
177
178} // 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.
Filesystem MCP server with read-before-write enforcement.
Definition filesystem.h:65
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:629