This example demonstrates how to create a chatbot that can interact with your local file system using the AIGNE Framework and AIGNE CLI. The example utilizes the SystemFS module to provide file system access to AI agents through the AFS (AIGNE File System) interface.
Prerequisites
Node.js (>=20.0) and npm installed on your machine
An OpenAI API key for interacting with OpenAI's services
Optional dependencies (if running the example from source code):
export OPENAI_API_KEY=YOUR_OPENAI_API_KEY # Set your OpenAI API key# Mount your current directory and chat with the bot about your files
npx -y @aigne/example-afs-system-fs --path . --chat
# Mount a specific directory (e.g., your documents)
npx -y @aigne/example-afs-system-fs --path ~/Documents --mount /docs --description "My Documents" --chat
# Ask questions about files without interactive mode
npx -y @aigne/example-afs-system-fs --path . --input "What files are in the current directory?"
cd aigne-framework/examples/afs-system-fs
pnpm install
Setup Environment Variables
Setup your OpenAI API key in the .env.local file:
OPENAI_API_KEY=""# Set your OpenAI API key here
Using Different Models
You can use different AI models by setting the MODEL environment variable along with the corresponding API key. The framework supports multiple providers:
OpenAI: MODEL="openai:gpt-4.1" with OPENAI_API_KEY
Anthropic: MODEL="anthropic:claude-3-7-sonnet-latest" with ANTHROPIC_API_KEY
Google Gemini: MODEL="gemini:gemini-2.0-flash" with GEMINI_API_KEY
AWS Bedrock: MODEL="bedrock:us.amazon.nova-premier-v1:0" with AWS credentials
DeepSeek: MODEL="deepseek:deepseek-chat" with DEEPSEEK_API_KEY
OpenRouter: MODEL="openrouter:openai/gpt-4o" with OPEN_ROUTER_API_KEY
xAI: MODEL="xai:grok-2-latest" with XAI_API_KEY
Ollama: MODEL="ollama:llama3.2" with OLLAMA_DEFAULT_BASE_URL
For detailed configuration examples, please refer to the .env.local.example file in this directory.
Run the Example
# Run with your current directory
pnpm start --path .
# Run with a specific directory and custom mount point
pnpm start --path ~/Documents --mount /docs --description "My Documents"# Run in interactive chat mode
pnpm start --path . --chat
How SystemFS Works
This example uses the SystemFS module from @aigne/afs-system-fs to mount your local file system into the AFS (AIGNE File System). This allows AI agents to interact with your files through a standardized interface.
Key Features
File Operations: List, read, write, and search files in mounted directories
Recursive Directory Traversal: Navigate through subdirectories with depth control
Fast Text Search: Uses ripgrep for blazing-fast content search across files
Metadata Support: Access file timestamps, sizes, types, and custom metadata
Path Safety: Sandboxed access limited to mounted directories
Available Operations
The SystemFS module provides these AFS operations:
list(path, options?) - List directory contents
// List files in root directoryawait systemFS.list("")
// List files recursively with depth limitawait systemFS.list("", { recursive: true, maxDepth: 2 })
// List with sorting and limitsawait systemFS.list("", {
orderBy: [['path', 'asc']],
limit: 10
})
// Search for text in filesconst results = await systemFS.search("", "TODO")
// Search with regex patternsconst matches = await systemFS.search("", "function\\s+\\w+")
// Limit search resultsconst limited = await systemFS.search("", "error", { limit: 5 })
Example Usage
Try these commands to explore the file system capabilities:
Basic File Operations
# List all files in current directory
npx -y @aigne/example-afs-system-fs --path . --input "List all files in the root directory"# Read a specific file
npx -y @aigne/example-afs-system-fs --path . --input "Read the contents of package.json"# Search for specific content
npx -y @aigne/example-afs-system-fs --path . --input "Find all files containing the word 'example'"
"Create a new file called notes.txt with some content"
"List all files recursively with a depth limit of 2"
Advanced Usage
# Mount multiple directories or specific paths
npx -y @aigne/example-afs-system-fs --path ~/Projects --mount /projects --description "My coding projects" --chat
The chatbot can help you navigate, search, read, and organize files in your mounted directories through natural language commands.
FAQs
A demonstration of using AIGNE Framework with AFS SystemFS module
The npm package @aigne/example-afs-system-fs receives a total of 20 weekly downloads. As such, @aigne/example-afs-system-fs popularity was classified as not popular.
We found that @aigne/example-afs-system-fs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 2 open source maintainers collaborating on the project.
Package last updated on 15 Oct 2025
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Impostor NuGet package Tracer.Fody.NLog typosquats Tracer.Fody and its author, using homoglyph tricks, and exfiltrates Stratis wallet JSON/passwords to a Russian IP address.