
Security News
New React Server Components Vulnerabilities: DoS and Source Code Exposure
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.
@aigne/example-afs-system-fs
Advanced tools
A demonstration of using AIGNE Framework with AFS SystemFS module
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 AIGNE File System (AFS) interface.
AIGNE File System (AFS) is a virtual file system abstraction that provides AI agents with unified access to various storage backends. For comprehensive documentation, see AFS Documentation.
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?"
git clone https://github.com/AIGNE-io/aigne-framework
cd aigne-framework/examples/afs-system-fs
pnpm install
Setup your OpenAI API key in the .env.local file:
OPENAI_API_KEY="" # Set your OpenAI API key here
You can use different AI models by setting the MODEL environment variable along with the corresponding API key. The framework supports multiple providers:
MODEL="openai:gpt-4.1" with OPENAI_API_KEYMODEL="anthropic:claude-3-7-sonnet-latest" with ANTHROPIC_API_KEYMODEL="gemini:gemini-2.0-flash" with GEMINI_API_KEYMODEL="bedrock:us.amazon.nova-premier-v1:0" with AWS credentialsMODEL="deepseek:deepseek-chat" with DEEPSEEK_API_KEYMODEL="openrouter:openai/gpt-4o" with OPEN_ROUTER_API_KEYMODEL="xai:grok-2-latest" with XAI_API_KEYMODEL="ollama:llama3.2" with OLLAMA_DEFAULT_BASE_URLFor detailed configuration examples, please refer to the .env.local.example file in this directory.
# 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
This example uses the SystemFS module from @aigne/afs-system-fs to mount your local file system into the AIGNE File System (AFS). This allows AI agents to interact with your files through a standardized interface.
The SystemFS module provides these AFS operations:
// List files in root directory
await systemFS.list("")
// List files recursively with depth limit
await systemFS.list("", { recursive: true, maxDepth: 2 })
// List with sorting and limits
await systemFS.list("", {
orderBy: [['path', 'asc']],
limit: 10
})
// Read file content
const file = await systemFS.read("README.md")
console.log(file.content) // File contents as string
// Read directory metadata
const dir = await systemFS.read("src")
console.log(dir.metadata.type) // "directory"
// Write a text file
await systemFS.write("notes.txt", {
content: "My notes",
summary: "Personal notes file"
})
// Write JSON data
await systemFS.write("config.json", {
content: { setting: "value" },
metadata: { format: "json" }
})
// Search for text in files
const results = await systemFS.search("", "TODO")
// Search with regex patterns
const matches = await systemFS.search("", "function\\s+\\w+")
// Limit search results
const limited = await systemFS.search("", "error", { limit: 5 })
Try these commands to explore the file system capabilities:
# 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'"
# Start interactive mode
npx -y @aigne/example-afs-system-fs --path . --chat
Then try asking:
# 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.
Just following code snippet shows how to mount a local directory using SystemFS:
AIAgent.from({
...,
afs: new AFS().use(
new SystemFS({ mount: '/source', path: '/PATH/TO/Bitcoin/Project', description: 'Codebase of Bitcoin project' }),
),
afsConfig: {
injectHistory: true,
},
}),
User Question: What's the purpose of this project?
{
"toolCalls": [
{
"id": "call_nBAfMjqt6ufoR22ToRvwbvQ6",
"type": "function",
"function": {
"name": "afs_list",
"arguments": {
"path": "/",
"options": {
"recursive": false
}
}
}
}
]
}
The agent will call the afs_list tool to list the files in the root directory
{
"status": "success",
"tool": "afs_list",
"options": {
"recursive": false
},
"list": [
{
"id": "/README.md",
"path": "/source/README.md",
"createdAt": "2025-10-30T14:03:49.961Z",
"updatedAt": "2025-10-30T14:03:49.961Z",
"metadata": {
"type": "file",
"size": 3489,
"mode": 33188
}
},
// ... other files
]
}
Then use afs_read to read specific file content
{
"toolCalls": [
{
"id": "call_73i8vwuHKXt2igXGdyeEws7F",
"type": "function",
"function": {
"name": "afs_read",
"arguments": {
"path": "/source/README.md"
}
}
}
]
}
Finally, prompt builder will combine the retrieved file content and construct the final message for the agent to answer the user question.
{
"messages": [
{
"role": "system",
"content": "You are an ...",
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "What's the purpose of this project?"
}
]
},
{
"role": "agent",
"toolCalls": [
{
"id": "call_TLvilbEhXqg3WFsFAKqm69W9",
"type": "function",
"function": {
"name": "afs_list",
"arguments": {
"path": "/source",
"options": {
"recursive": false
}
}
}
}
]
},
{
"role": "tool",
"content": "... list result ...", // Here would be the actual list result
"toolCallId": "call_TLvilbEhXqg3WFsFAKqm69W9"
},
{
"role": "agent",
"toolCalls": [
{
"id": "call_73i8vwuHKXt2igXGdyeEws7F",
"type": "function",
"function": {
"name": "afs_read",
"arguments": {
"path": "/source/README.md"
}
}
}
]
},
{
"role": "tool",
"content": "... read file content ...", // Here would be the actual file content
"toolCallId": "call_73i8vwuHKXt2igXGdyeEws7F"
}
]
}
The final answer from the agent would be:
This repository is Bitcoin Core — the reference implementation of the Bitcoin protocol. Its purpose is to provide a full-node Bitcoin client that:
* Connects to the Bitcoin peer-to-peer network, downloads blocks and transactions, and fully validates them against consensus rules (so you don’t have to trust others).
* Acts as a reference implementation of Bitcoin protocol behavior used by wallets, services, and other implementations.
* Includes an optional wallet and a GUI (and an RPC interface) for interacting with the node.
* Provides developer tooling, tests (unit, integration, regression), and documentation to maintain security and correctness.
For an overview see the README (https://bitcoincore.org) and to get ready-to-run binaries use https://bitcoincore.org/en/download/. The project is released under the MIT license.
FAQs
A demonstration of using AIGNE Framework with AFS SystemFS module
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.
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.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.