tycode_core/file/mod.rs
1//! The file module provides a structured, secure interface to file system operations.
2//!
3//! ## Architecture
4//!
5//! ### access.rs
6//! Provides low-level file system access with safety guards:
7//! - Ignores critical safety risks (e.g., .git directories, dot directories)
8//! - Respects .gitignore patterns via the `ignore` crate's WalkBuilder (files in ignored locations appear non-existent)
9//! - Offers core APIs: read_file, write_file, delete_file, list_directory
10//! - All I/O goes through this layer; nothing uses std::fs directly
11//! - File discovery uses ignore::WalkBuilder to traverse directories while respecting ignore patterns and size limits
12//!
13//! ### context.rs
14//! Provides types and helpers to build AI message context:
15//! - Provides directory listing and contents of all tracked files
16//!
17//! ### manager.rs
18//! Ties everything together and offers high-level APIs:
19//! - Coordinates access.rs, security.rs for safe file modifications
20//!
21//! ## Multiple workspaces and Obfuscation
22//! Tycode supports multiple workspaces (typically multiple git root projects
23//! open in the same vscode window). This introduces complexity - each
24//! workspace likely has its own .gitignore and we need a way to address files
25//! between workspaces. To keep things simple for the AI agents, we present a
26//! file system as if each workspace is its own root. For example, two
27//! workspaces 'asdf' and 'zxcv' would be presented as `/asdf/src/file.rs` and
28//! `zxcv/src/mod.rs` (for example). resolver.rs is responsible for mapping
29//! from these fake root directories to real directories. This also hides real
30//! directories (for example user names) from AI providers.
31
32pub mod access;
33pub mod config;
34pub mod find;
35pub mod manager;
36pub mod modify;
37pub mod read_only;
38pub mod resolver;