引言
2025 年 12 月,一篇题为《Agentic File System Abstraction for Context Engineering》的论文提出了一个优雅的想法:将 Unix 哲学”一切皆文件”应用于生成式 AI 的上下文管理。
读完这篇论文后,我意识到这正是我们 Deep Research 工作流所需要的架构升级。本文首先解读论文的核心思想,然后展示我们如何将其应用到一个真实的 vibecoding 工具横向对比调研项目中。
论文核心思想
问题背景
随着生成式 AI 重塑软件系统设计,核心挑战已从模型微调转向上下文工程(Context Engineering):
如何系统性地捕获、组织和治理外部知识、记忆、工具和人类输入,以实现可信赖的推理?
现有方法(提示工程、RAG、工具集成等)存在以下问题:
- 碎片化:各种方法各自为战,缺乏统一抽象
- 瞬态性:产生的上下文工件无法持久化,缺乏可追溯性
- 上下文腐烂:长期对话中知识漂移,难以审计
核心创新:文件系统抽象
论文提出将 Unix 文件系统哲学 应用于上下文工程:
| Unix 概念 | AI 上下文对应 |
|---|---|
| 文件 | 上下文元素(知识、记忆、工具) |
| 目录层次 | 上下文组织结构 |
| 挂载点 | 异构数据源统一接口 |
| 元数据(inode) | 时间戳、来源、访问控制 |
| 日志(journal) | 交互事务记录 |
三层持久化架构
论文设计了三层上下文仓库:
┌─────────────────────────────────────────┐
│ History ( immutable ) │ ← 全局永久记录
│ /context/history/ │
├─────────────────────────────────────────┤
│ Memory ( persistent ) │ ← Agent/会话特定
│ /context/memory/agentID/ │
├─────────────────────────────────────────┤
│ Scratchpad ( transient ) │ ← 临时工作区
│ /context/pad/taskID/ │
└─────────────────────────────────────────┘
- History:原始交互记录,不可变,带完整元数据
- Memory:经摘要/嵌入/索引后的结构化视图
- Scratchpad:推理过程中的临时假设,任务结束后可归档
上下文工程流水线
论文提出三阶段流水线:
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ Constructor │ → │ Updater │ → │ Evaluator │
│ (构建器) │ │ (更新器) │ │ (评估器) │
└──────────────────┘ └──────────────────┘ └──────────────────┘
↓ ↓ ↓
选择 + 压缩 注入到 token 窗口 验证 + 归档
生成 manifest 增量流式加载 人工审核触发
实现:AIGNE 框架
论文在开源框架 AIGNE 中实现了该架构,核心模块包括:
- SystemFS:虚拟文件系统,支持 list/read/write/search
- AFSHistory:历史记录存储(SQLite)
- UserProfileMemory:用户画像记忆
- MCP 集成:通过 Model Context Protocol 挂载外部服务
我们的工作流:Deep Research for Vibecoding Tools
项目背景
我们正在进行一个 17 个 vibecoding 工具的横向对比调研,包括:
- AI-first IDE:Cursor, Windsurf, Zed
- IDE 插件:GitHub Copilot, Continue.dev, Cody, Tabnine, JetBrains AI, Amazon CodeWhisperer, Qodo
- Web 平台:Bolt.new, v0.dev, Lovable, Replit Agent, Emergent, Magic Patterns, AskCodi
每个工具需要调研 60+ 字段,涵盖基本信息、技术特性、平台支持、性能指标、用户体验、商业模式、安全性等维度。
原有架构的局限
在引入论文理念之前,我们的工作流是:
outline.yaml → 分批启动 agent → 搜索 → 抓取 → 输出 JSON → 验证
存在的问题:
- 无状态:每批次不知道之前批次的发现
- 不可追溯:不知道某个结论来自哪次搜索
- 无法复用:已完成的知识无法用于后续批次
- 质量控制弱:仅有字段完整性检查
架构改造方案
新目录结构
基于论文理念,我们设计了新的目录结构:
vibecoding-tools-comparison/
├── outline.yaml # 调研主题和 items
├── fields.yaml # 字段定义
├── metadata.json # 全局元数据(新增)
│
├── context/ # 上下文仓库(新增)
│ ├── history/
│ │ ├── searches/ # 搜索历史(谁搜了什么)
│ │ ├── fetches/ # 抓取历史(哪些网页被读了)
│ │ └── interactions/ # 交互记录(人工审核)
│ ├── memory/
│ │ ├── items/ # 调研对象记忆
│ │ ├── fields/ # 字段定义记忆
│ │ └── facts/ # 原子事实(可追溯来源)
│ └── pad/
│ └── batch_{n}/ # 批次工作区(临时笔记)
│
├── pipeline/ # 流水线组件(新增)
│ ├── constructor/
│ │ └── manifest_batch_{n}.json
│ └── evaluator/
│ └── evaluation_batch_{n}.json
│
├── results/ # 调研结果
│ └── *.json
│
└── report.md # 最终报告
核心模块实现
我们用 Python 实现了论文中的核心概念:
1. ContextRepository(上下文仓库)
class ContextRepository:
def __init__(self, topic_dir: Path):
self.topic_dir = topic_dir
self.context_dir = topic_dir / "context"
self.history_dir = self.context_dir / "history"
self.memory_dir = self.context_dir / "memory"
self.pad_dir = self.context_dir / "pad"
# 创建三层目录结构
self._init_directories()
def log_search(self, search: SearchHistory):
"""记录搜索历史(不可变)"""
path = self.history_dir / "searches" / f"{search.search_id}.json"
# ... 写入 JSON
def save_memory_item(self, item: MemoryItem):
"""保存或更新记忆项(可更新)"""
slug = item.name.lower().replace(' ', '_')
path = self.memory_dir / "items" / f"{slug}.json"
# ... 版本控制 + 合并 facts
def create_scratchpad(self, batch_id: int) -> ScratchpadNote:
"""创建批次工作区(临时)"""
return ScratchpadNote(batch_id=batch_id, status="active")
2. ContextConstructor(上下文构建器)
class ContextConstructor:
def select_context(self, outline, fields, batch_size=3) -> ContextManifest:
# 1. 获取待调研 items
all_items = outline.get('items', [])
# 2. 检查 Memory 中已有的 facts
existing_facts = self.repo.query_memory(item_names)
# 3. 选择本批次 items(跳过已完成的)
pending_items = [item for item in all_items
if item['name'] not in existing_facts]
batch_items = pending_items[:batch_size]
# 4. 生成 manifest
manifest = ContextManifest(
selected_items=[item['name'] for item in batch_items],
existing_facts={k: v.facts for k, v in existing_facts.items()},
fields_to_fill=required_fields,
token_budget=128000,
estimated_tokens=self._estimate_tokens(batch_items)
)
return manifest
Manifest 示例:
{
"selected_items": ["Cursor", "Windsurf", "Zed"],
"existing_facts": {
"Cursor": {
"company": "Anysphere",
"pricing": "$20/user/month"
}
},
"fields_to_fill": ["company", "pricing", "release_date", ...],
"token_budget": 128000,
"estimated_tokens": 4500
}
3. ContextEvaluator(上下文评估器)
class ContextEvaluator:
def evaluate(self, item_name, json_output, fields_path) -> EvaluationResult:
# 1. 字段完整性检查
coverage_rate = self._check_coverage(json_output, fields_path)
# 2. 一致性检查(与已有 Memory 对比)
consistency_score = self._check_consistency(json_output, item_name)
# 3. 幻觉检测
hallucinations = self._detect_hallucinations(json_output)
# 4. 计算置信度
confidence = self._calculate_confidence(coverage_rate, consistency_score)
# 5. 判断是否需要人工审核
requires_review = (
confidence < 0.6 or
len(hallucinations) > 2 or
coverage_rate < 0.7
)
return EvaluationResult(
item=item_name,
coverage_rate=coverage_rate,
consistency_score=consistency_score,
hallucinations=hallucinations,
confidence=confidence,
requires_human_review=requires_review
)
评估结果示例:
{
"item": "Cursor",
"coverage_rate": 0.92,
"consistency_score": 0.88,
"hallucinations": [],
"confidence": 0.90,
"requires_human_review": false
}
完整执行流程
┌─────────────────────────────────────────────────────────┐
│ Step 1: 定位 Outline │
│ - 读取 outline.yaml(17 个 items) │
│ - 读取 fields.yaml(60+ 字段) │
└─────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────┐
│ Step 2: 初始化 ContextRepository │
│ - 创建 context/history/ │
│ - 创建 context/memory/ │
│ - 创建 context/pad/ │
└─────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────┐
│ Step 3: 断点续传检查 │
│ - 查询 memory/items/ 下已完成的 JSON │
│ - 跳过已完成的 items │
│ - 显示进度:已完成 X / 总共 Y │
└─────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────┐
│ Step 4: 分批执行(带上下文工程) │
│ │
│ 4.1 Constructor 阶段 │
│ - 选择本批次 3 个 items │
│ - 查询 Memory 中已有事实 │
│ - 生成 Context Manifest │
│ │
│ 4.2 Updater 阶段 │
│ - 加载 Manifest 中的上下文片段 │
│ - 构建最终 prompt(注入已有知识) │
│ - 传递给子 agent │
│ │
│ 4.3 Agent 执行 │
│ - 基于已有上下文进行有针对性的搜索 │
│ - 验证并补充缺失信息 │
│ - 输出结构化 JSON │
│ │
│ 4.4 Evaluator 阶段 │
│ - 检查字段完整性(覆盖率) │
│ - 检查一致性(与已有 Memory 对比) │
│ - 检测幻觉(低置信度、矛盾信息) │
│ - 触发人工审核(低置信度) │
│ - 更新 Memory(新知识持久化) │
└─────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────┐
│ Step 5: 等待与监控 │
│ - 显示进度:当前批次 X / Y | 总进度 A / B (Z%) │
│ - 询问用户是否继续下一批 │
└─────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────┐
│ Step 6: 汇总报告 │
│ - 完成数量:X / Y │
│ - 需要人工审核:列出 items 和原因 │
│ - 下一步:运行 /research-report 生成最终报告 │
└─────────────────────────────────────────────────────────┘
关键改进与收益
1. 可追溯性(Traceability)
改造前:
- 只知道 JSON 文件存在
- 不知道某个结论来自哪次搜索
改造后:
// context/history/searches/20260304_114500_cursor.json
{
"timestamp": "2026-03-04T11:45:00Z",
"item": "Cursor",
"queries": [
"Cursor AI IDE 2025 2026 review",
"Cursor vs Windsurf comparison",
"Cursor pricing 2026"
],
"sources_searched": ["general-web", "github-debug", "chinese-tech"],
"raw_results_count": 47,
"search_id": "a3f2b8c1d4e5"
}
收益:支持完整审计和问题回溯
2. 知识复用(Knowledge Reuse)
改造前:
- 每批次从零开始
- 无法利用已有发现
改造后:
# Constructor 自动查询 Memory
existing_facts = repo.query_memory(["Cursor", "Windsurf", "Zed"])
# 注入到 agent prompt
prompt = f"""
## 已有知识(来自 Memory)
{json.dumps(existing_facts, ensure_ascii=False, indent=2)}
## 待调研 Items: {', '.join(batch_items)}
"""
收益:后续批次可以基于已有知识进行更有针对性的搜索
3. 质量控制(Quality Control)
改造前:
- 仅有字段完整性检查
改造后:
# Evaluator 多维度评估
coverage_rate = check_coverage(json_output, fields) # 字段覆盖率
consistency = check_consistency(json_output, item_name) # 与已有知识一致性
hallucinations = detect_hallucinations(json_output) # 幻觉检测
confidence = calculate_confidence(...) # 综合置信度
# 自动触发人工审核
if confidence < 0.6 or len(hallucinations) > 2:
trigger_human_review()
收益:自动识别低质量输出,减少错误传播
4. 人在回路(Human-in-the-Loop)
改造前:
- 仅在批次之间确认
改造后:
// context/pad/batch_1/notes.json
{
"batch": 1,
"items_processed": ["Cursor", "Windsurf", "Zed"],
"intermediate_findings": [
"Cursor 和 Windsurf 都支持多模型切换",
"Zed 的性能优势明显但 AI 功能较少"
],
"questions_for_next_batch": [
"需要确认 Bolt.new 的定价策略",
"v0.dev 是否支持后端代码生成"
],
"status": "completed"
}
收益:人类作为验证者和共同推理者参与全过程
量化对比
| 指标 | 改造前 | 改造后 | 改进幅度 |
|---|---|---|---|
| 可追溯性 | 文件存在检查 | History + Lineage + 版本控制 | ⬆️⬆️⬆️ |
| 断点续传 | 基础 | Memory 查询 + 版本验证 | ⬆️⬆️ |
| 质量控制 | 字段完整性 | 覆盖率 + 一致性 + 幻觉检测 | ⬆️⬆️⬆️ |
| 人机协作 | 批次确认 | 自动触发式审核 + Scratchpad | ⬆️⬆️ |
| 可复用性 | 硬编码路径 | 统一文件系统抽象 | ⬆️⬆️ |
| 审计能力 | 无 | 完整事务日志 + 回放支持 | ⬆️⬆️⬆️ |
实施路线图
Phase 1: 基础结构(本周)
- ✅ 创建架构设计文档
- ✅ 实现上下文工程模块(1000+ 行 Python)
- ✅ 更新 SKILL.md 文档
- 集成到
/research-deep执行流程
Phase 2: 流水线集成(下周)
- Constructor:manifest 生成和保存
- Updater:上下文注入到 agent prompt
- Evaluator:自动验证和人工审核触发
Phase 3: 高级功能(后续)
- 向量搜索(semantic search)
- 知识图谱存储
- Dashboard(查看 History/Memory/Metadata)
- API 接口(查询已有事实)
代码与资源
开源实现
我们的完整实现已开源:
- 上下文工程模块:
~/clawd/skills/research-deep/context_engineering.py - 架构设计文档:
~/clawd/vibecoding-tools-comparison/ARCHITECTURE.md - Deep Research Skill:
~/clawd/skills/research-deep/SKILL.md
论文资源
- 论文:Agentic File System Abstraction for Context Engineering
- AIGNE 框架:https://github.com/AIGNE-io/aigne-framework
总结
论文《Agentic File System Abstraction for Context Engineering》提供了一个优雅的架构抽象,将 Unix 文件系统哲学应用于 AI 上下文管理。
我们将这一理念应用到 Deep Research 工作流中,实现了:
- ✅ 三层持久化存储(History / Memory / Scratchpad)
- ✅ 上下文工程流水线(Constructor / Updater / Evaluator)
- ✅ 完整的可追溯性(搜索历史、交互记录、谱系追踪)
- ✅ 自动质量控制(幻觉检测、一致性检查、触发式人工审核)
- ✅ 人在回路设计(Scratchpad、人工审核触发)
这不仅提升了 vibecoding 工具调研的质量和效率,也为其他 AI 密集型工作流提供了一个可复用的架构模板。
下一步:我们将继续完善 Phase 2 的流水线集成,并在真实的 17 工具调研项目中验证这一架构的有效性。敬请期待后续的实战报告!
参考资料
- Xu, X., et al. (2025). Agentic File System Abstraction for Context Engineering. arXiv:2512.05470. https://arxiv.org/abs/2512.05470
- AIGNE Framework. https://github.com/AIGNE-io/aigne-framework
- Model Context Protocol. https://modelcontextprotocol.io/
- Unix Philosophy. https://en.wikipedia.org/wiki/Unix_philosophy