Skip to content

Filesystem Discovery & Search

Saksham Garg edited this page Oct 14, 2026 · 1 revision

Filesystem Discovery & Search

Overview

DESK introduces a filesystem discovery and search system that allows AI agents to locate files and directories on the user's computer.

The system is designed to provide filesystem awareness without giving the AI unrestricted access to the computer's storage.

In its current implementation, filesystem search is read-only. DESK can enumerate filesystem entries, inspect basic metadata, and search for filenames or directory names. It does not read file contents, modify files, or maintain a persistent search index.

The filesystem implementation is primarily contained in:

1. Design Philosophy

DESK separates AI reasoning from local filesystem execution.

An AI agent can determine that a user wants to locate a file. DESK is responsible for determining where to search, traversing the filesystem, handling errors, and returning the results.

The basic principle is:

The AI requests a search. DESK controls how that search is performed.

This keeps filesystem operations within DESK's execution layer rather than allowing the model to choose arbitrary filesystem roots.

The current implementation focuses on three objectives:

  • Read-only access: Search and discovery do not modify files.
  • Controlled search scope: DESK determines the locations searched by an agent action.
  • Cross-platform operation: Filesystem handling accounts for differences between Windows, Linux, and macOS.

2. Current Capabilities

Filesystem discovery

DESK can identify filesystem roots and enumerate filesystem entries.

The discovery layer can retrieve:

  • Entry names and absolute paths.
  • Entry types, such as files, directories, and symbolic links.
  • File sizes in bytes when the entry is a regular file.
  • Basic information about the operating system, home directory, and discovered roots.

Filesystem enumeration is performed incrementally, yielding entries as they are discovered rather than requiring the entire filesystem listing to be stored in memory.

Directory listing

The list_directory(path) function lists the entries directly inside a specified directory.

Each entry includes its name, path, type, and size where applicable. The result also includes the number of entries and any directory-level error encountered.

Entries are sorted by name, without treating letter case as significant for the primary sort order.

Directory listing does not open or read the contents of the files it finds.

Filename search

The search_filesystem(name, roots, partial_match=False) function searches for files and directories by name.

Two matching modes are supported:

Mode Behaviour
Exact match Matches the complete filename or directory name.
Partial match Matches names containing the supplied search text.

Matching is case-insensitive. For example, a search for report.pdf can match Report.pdf.

Search results include matching paths, entry types, file sizes where applicable, the number of matches, the locations searched, and information about errors encountered during traversal.

Every search performs a fresh enumeration. Results are not retrieved from a persistent filesystem index or cached search database.

Agent integration

Filesystem search is exposed through DESK's structured agent-action system using the search_filesystem action.

An illustrative action request is:

{
  "action": "search_filesystem",
  "name": "report.pdf",
  "partial_match": false
}

The agent supplies the search term and matching preference. DESK discovers the approved search roots and performs the search.

The agent does not supply the filesystem roots used by this action. This prevents the model from directly expanding the search scope through its action parameters.

When matches are found, DESK returns their paths to the conversation. To keep responses manageable, at most 20 matching paths are displayed, with an indication when additional matches exist.

3. Search Scope and Platform Support

The agent's search action does not indiscriminately begin at the system root. Instead, DESK discovers a set of approved search locations based on the host operating system.

Windows

DESK searches the user's home directory and discovers other available logical drives.

The root of the drive containing the user's home directory is not added as a separate search root. This avoids turning an ordinary search into a redundant scan of the entire system drive.

Other available logical drives can be included.

Linux

DESK searches the user's home directory and discovers eligible mounted storage locations.

The mounted-storage discovery logic distinguishes between ordinary storage and virtual or system filesystems. It excludes standard system mountpoints and virtual filesystems, and considers eligible device-backed and supported network-mounted filesystems.

A mounted parent location that contains the user's home directory is not added separately when the home directory is already the approved search root.

macOS

DESK searches the user's home directory and discovers mounted volumes beneath /Volumes.

Only entries identified as mounted directories are included as additional volume roots.

Important distinction

The lower-level filesystem module can discover the operating system's filesystem root on POSIX systems and can recursively enumerate explicitly supplied roots.

However, the agent-facing filename search uses the separate, platform-specific search-root discovery logic described above. These are different layers of the implementation.

4. Traversal and Error Handling

Filesystem traversal must account for locations that cannot be accessed, entries that change while being scanned, and filesystem structures that should not be followed recursively.

DESK handles these situations as follows.

Symbolic links and junctions

Symbolic links are reported as filesystem entries but are not followed during recursive traversal. Windows junctions are also excluded from recursive descent where the runtime can identify them.

This helps prevent traversal from following links into unrelated locations or repeatedly visiting the same directory structure.

Repeated directories

Directory device and inode identities are tracked during enumeration to help prevent the same directory from being visited repeatedly.

Search results are also deduplicated by normalized path.

Inaccessible locations

Filesystem permissions, disconnected storage, and other operating-system errors can prevent access to particular entries or directories.

Instead of necessarily stopping the entire search, DESK records errors and continues where possible.

Search results include a completion status:

  • complete: true indicates that no traversal errors were recorded.
  • complete: false indicates that some locations could not be fully searched.

A search that returns no matches should therefore be interpreted alongside its completion status. An incomplete search does not prove that the requested file does not exist.

5. Search Results

The search function returns a structured result containing:

Field Purpose
query The original search term.
match_mode Whether matching was exact or partial.
snapshot_at The UTC timestamp at which the search began.
searched_roots The roots included in the search.
entries_scanned The number of entries processed during enumeration.
matches The matching entries and their metadata.
match_count The number of unique matching paths.
errors Locations and errors recorded during traversal.
complete Whether traversal completed without recorded errors.

The timestamp identifies when the search snapshot began. It does not imply that the filesystem remains unchanged after that point.

6. Safety and Limitations

The filesystem system is intentionally limited to discovery and search in its current implementation.

Current safeguards and boundaries:

  • Filesystem search does not read file contents.
  • Filesystem search does not create, edit, rename, move, or delete files.
  • The agent-facing action does not accept arbitrary search roots from the model.
  • Symbolic links and identifiable junctions are not recursively followed.
  • Errors are reported rather than silently treated as proof that no file exists.
  • The agent's chat response limits the number of displayed paths to avoid excessive output.

Current limitations:

  • Search is based on filenames and directory names, not text inside files.
  • Every search performs a fresh traversal rather than using an indexed database.
  • Large directories, slow storage devices, and network-mounted locations can make searches take longer.
  • Permissions and disconnected or unavailable storage can result in incomplete searches.
  • The filesystem module's discovery and enumeration capabilities do not mean that every possible filesystem operation is exposed to AI agents.

This release should not be described as unrestricted filesystem control. Its current agent-facing filesystem capability is a controlled, read-only search operation.

7. Architecture

The filesystem workflow can be summarized as follows:

User Request
     |
     v
AI Agent
     |
     | Structured search_filesystem action
     v
DESK Agent Actions
     |
     | Validate search parameters
     | Discover approved roots
     v
Filesystem Search
     |
     | Fresh recursive enumeration
     | Filename matching
     | Error collection
     v
Structured Search Results
     |
     v
Conversation Response

The architecture keeps the model's request separate from the operating-system-specific details of filesystem traversal.

8. Implementation Reference

File Responsibility
[core/filesystem.py](https://github.com/Saksham-garg2008/DESK/blob/main/core/filesystem.py) Root discovery, directory listing, entry metadata, and recursive enumeration.
[core/filesystem_search.py](https://github.com/Saksham-garg2008/DESK/blob/main/core/filesystem_search.py) Fresh filename searches, matching modes, deduplication, and completion reporting.
[core/agent_actions.py](https://github.com/Saksham-garg2008/DESK/blob/main/core/agent_actions.py) Platform-specific search-root discovery, input validation, and agent-action integration.
[core/agent_protocol.py](https://github.com/Saksham-garg2008/DESK/blob/main/core/agent_protocol.py) Structured agent-action extraction and compatibility with single-action requests.

Conclusion

The filesystem release gives DESK a foundation for understanding where files and directories are located on a user's computer.

Rather than immediately introducing unrestricted file manipulation, the implementation begins with controlled discovery, metadata inspection, and filename search. This establishes a clear separation between AI reasoning and local execution while keeping the current capability read-only.

The filesystem module can support future development, but any additional operations should be documented according to their actual implementation and safeguards.

Project: [DESK on GitHub](https://github.com/Saksham-garg2008/DESK)
Releases: [DESK Releases](https://github.com/Saksham-garg2008/DESK/releases)

Clone this wiki locally