One File Chat
English
One File Chat is a VS Code extension that stores each conversation as a plain .filechat.json file.
Instead of hiding chat history inside a private database, it keeps conversations in your workspace so they can be versioned, copied, branched, reviewed, and shared like any other project file.
Screenshot

Highlights
- One file per conversation, opened with a custom editor inside VS Code
- Conversations are saved directly to disk instead of a hidden app database
- Explorer sidebar shows chat sessions sorted by recent activity
- Retry and rewrite create new branches instead of overwriting existing history
- Per-message version history with preview, restore, copy, and delete actions
- Markdown rendering with LaTeX math support via
$...$ and $$...$$
- Image and file attachments through picker, paste, drag and drop, or local Markdown links
- Session-level model selection, common config, system prompt, and message template
- Pi-powered model runtime for normalized streaming, reasoning, usage, and provider compatibility
Who It's For
One File Chat is built for people who want AI conversations to behave like project artifacts.
- Keep prompt history next to code, docs, and assets
- Track conversations with Git
- Preserve alternate branches of a discussion
- Use your own OpenAI-compatible provider instead of a locked-in hosted chat UI
Quick Start
- Install the extension.
- Run the command
One File Chat: New Chat File.
- Open the model picker and choose either a One File Chat model or a Pi model.
- Start chatting.
For One File Chat models, create .filechat/key.json in one of the locations below. A Pi-only setup does not require key.json.
One File Chat configuration is resolved in this order:
- Chat file directory
- Workspace root
- User home directory
Marketplace Setup And Model Sources
The Marketplace extension includes the Pi runtime. It does not include accounts or credentials.
- One File Chat lists OpenAI-compatible models from
.filechat/key.json and uses the API key and request options defined there.
- Pi lists the authenticated models already available to the Pi CLI through Pi's official settings, package, extension, authentication, and model APIs. Configure providers or sign in with the Pi CLI; One File Chat does not duplicate Pi's login or configuration UI.
- The first visit to the Pi tab and the refresh button both read local state only. Refresh rebuilds the Pi runtime from local settings, authentication, installed extensions, and cached model catalogs without initiating a remote catalog update.
- Reasoning-capable Pi models expose their officially supported levels. Clicking the model expands those levels; selection happens only after a level is chosen. The default badge marks Pi's nearest supported level to Medium.
- A saved model that is no longer available remains visible as unavailable and sending stays disabled until it is refreshed or replaced.
key.json Example
{
"providers": {
"openai": {
"label": "OpenAI",
"transport": "openai-compatible",
"api_key": "${env:OPENAI_API_KEY}",
"api_base": "https://api.openai.com/v1",
"models": [
{
"id": "gpt-4.1-mini",
"label": "GPT-4.1 Mini"
},
{
"id": "gpt-5.4",
"label": "GPT-5.4",
"options": [
{
"id": "high",
"label": "High",
"config": {
"reasoning_effort": "high"
}
}
]
}
]
}
}
}
Notes:
openai-compatible is currently the supported transport
api_key and api_base support ${env:NAME} expansion
- Model selection is saved back to the chat file so sessions can resume with the same setup
Common Commands
One File Chat: New Chat File
One File Chat: Manage Chat Config
One File Chat: Manage Common Config
One File Chat: Refresh Sessions
Attachments And Storage
- Attachments are stored under
.filechat/assets/ next to the chat file
- Supported image types:
png, jpg, jpeg, webp, gif
- There is no fixed per-message attachment count limit; practical limits depend on the selected model, provider API, and runtime environment
- Non-image attachments are sent as file metadata by default instead of inlining the full file body into the prompt
Common Configs
You can define reusable session presets in .filechat/common_configs.json, including shared system prompts and message templates. The session config panel in the chat view lets you inspect, switch, and save those values per conversation.
Current Scope
- Version 0.2.1 routes model requests through the bundled Pi
ModelRuntime
- One File Chat and Pi models share the same runtime but remain separate model sources, so identical Provider and model IDs cannot collide
- Existing OpenAI-compatible One File Chat providers, including gateways such as LiteLLM Proxy, are registered with Pi in memory; they are never merged into Pi settings
- Pi agent sessions and tools are not enabled: One File Chat remains responsible for the conversation, prompt, attachments, and persistence
- Chat file format continues to evolve, with compatibility prioritized for existing data
- Assistant-generated Markdown images are best-effort persisted as local assets
- Requires VS Code 1.105 or newer
Pi Trust Boundary
- Pi configuration and authentication are accessed only through Pi's official APIs; One File Chat does not directly parse or write Pi configuration files
- Only already-installed Pi extension packages are loaded. Missing or version-mismatched packages are reported and never installed automatically
- Trusted workspaces may load both global and project Pi extensions. Untrusted workspaces load global extensions only
- One File Chat does not create a Pi
AgentSession or enable Pi tools, skills, prompt templates, context files, themes, or default system prompts
- Only authenticated models returned as available by Pi are shown
- Each workspace gets an independent Pi model service. Files outside a workspace use their containing directory
Development
npm install
npm run compile
Development requires Node.js 22.19 or newer.
Press F5 in VS Code to launch an Extension Development Host.
License
MIT
中文
One File Chat 是一个把每段对话直接保存成 .filechat.json 文件的 VS Code 扩展。
它不会把聊天历史藏进私有数据库,而是把会话留在你的工作区里,让它们像普通项目文件一样可版本管理、可复制、可分支、可审阅、可共享。
截图

亮点
- 一文件一会话:每个
.filechat.json 文件都会直接用 VS Code 自定义编辑器打开
- 会话直接落盘:聊天内容保存到磁盘,而不是隐藏在应用私有数据库里
- 会话列表:Explorer 侧边栏会按最近更新时间展示聊天文件
- 分支而不是覆盖:重试和改写会生成新分支,不会覆盖已有历史
- 单消息版本历史:支持预览、恢复、复制和删除历史版本
- Markdown 与数学公式:支持 Markdown 渲染,以及
$...$ 和 $$...$$ LaTeX 数学公式
- 图片与文件附件:支持文件选择、粘贴、拖拽,以及本地 Markdown 链接吸收
- 会话级配置:每个聊天都可以单独设置模型选择、通用配置、system prompt 和 message template
- Pi 模型运行时:统一处理流式输出、reasoning、用量与 Provider 兼容
适合谁
One File Chat 适合想把 AI 对话当成项目资产来管理的人。
- 想把提示词历史和代码、文档、资源放在一起管理
- 想让聊天记录参与 Git、备份和协作
- 需要保留同一轮对话的多个分支和重试结果
- 想使用自己的 OpenAI-compatible 服务,而不是绑定单一聊天客户端
快速开始
- 安装扩展。
- 运行命令
One File Chat: New Chat File。
- 打开模型选择器,选择“One File Chat”模型或“Pi”模型。
- 开始聊天。
使用 One File Chat 模型时,在以下任意位置创建 .filechat/key.json。仅使用 Pi 时不需要 key.json。
One File Chat 配置查找顺序如下:
- 聊天文件所在目录
- 工作区根目录
- 用户 HOME 目录
Marketplace 使用与模型来源
Marketplace 版扩展已内置 Pi 运行时,但不附带任何账户或凭据。
- One File Chat 页展示
.filechat/key.json 中的 OpenAI-compatible 模型,并使用其中定义的 API Key 与请求参数。
- Pi 页通过 Pi 官方的设置、包、扩展、认证和模型接口,展示 Pi CLI 当前已经认证可用的模型。Provider 配置和登录仍在 Pi CLI 中完成,One File Chat 不复制 Pi 的登录或配置界面。
- 第一次打开 Pi 页和手动刷新都只读取本地状态,不联网。刷新会根据本地设置、认证、已安装扩展和缓存模型目录重新构建 Pi 运行时,不会主动更新远端模型目录。
- 支持 reasoning 的 Pi 模型会展示官方思考档位。点击模型时先展开档位,选择具体档位后才选中模型;“默认”标记表示 Pi 钳制后最接近“中”的支持档位。
- 已保存但失效的模型不会被静默替换;界面会保留并标记其不可用,重新刷新或选择前不能发送。
key.json 示例
{
"providers": {
"openai": {
"label": "OpenAI",
"transport": "openai-compatible",
"api_key": "${env:OPENAI_API_KEY}",
"api_base": "https://api.openai.com/v1",
"models": [
{
"id": "gpt-4.1-mini",
"label": "GPT-4.1 Mini"
},
{
"id": "gpt-5.4",
"label": "GPT-5.4",
"options": [
{
"id": "high",
"label": "High",
"config": {
"reasoning_effort": "high"
}
}
]
}
]
}
}
}
说明:
- 当前支持的 transport 是
openai-compatible
api_key 和 api_base 支持 ${env:NAME} 环境变量展开
- 模型选择会写回聊天文件,便于下次恢复同一会话设置
常用命令
One File Chat: New Chat File
One File Chat: Manage Chat Config
One File Chat: Manage Common Config
One File Chat: Refresh Sessions
附件与存储
- 附件会保存在聊天文件同目录下的
.filechat/assets/
- 支持的图片类型:
png、jpg、jpeg、webp、gif
- 单条消息的附件数量不设固定上限,实际可用范围取决于所选模型、提供方接口与运行环境
- 非图片附件默认只向模型发送文件元信息,不会把整份文件正文直接内联进 prompt
通用配置
你可以在 .filechat/common_configs.json 里定义可复用的会话预设,例如共享的 system prompt 和 message template。聊天页里的会话配置面板可以直接查看、切换和保存这些设置。
当前范围
- 0.2.1 起,所有模型请求都通过扩展内置的 Pi
ModelRuntime
- One File Chat 模型与 Pi 模型共用运行时,但保留独立来源,因此 Provider ID 和模型 ID 完全相同时也不会冲突
- 现有 OpenAI-compatible One File Chat Provider(包括 LiteLLM Proxy 等兼容网关)仅在内存中注册给 Pi,不会拼接或写入 Pi 设置
- 不启用 Pi AgentSession 和工具;会话、提示词、附件与持久化仍由 One File Chat 负责
- 聊天文件格式会继续演进,但优先保证已有数据可读
- 助手返回的 Markdown 图片会尽量落盘为本地资源
- 需要 VS Code 1.105 或更高版本
Pi 信任边界
- Pi 配置与认证仅通过 Pi 官方接口访问;One File Chat 不直接解析或写入 Pi 配置文件
- 只加载已经安装的 Pi 扩展包;缺失或版本不匹配时仅提示,绝不自动安装
- 可信工作区可以加载全局和项目 Pi 扩展;未信任工作区只加载全局扩展
- 不创建 Pi
AgentSession,也不启用 Pi 工具、skills、提示词模板、上下文文件、主题或默认 system prompt
- 只展示 Pi 返回的已认证可用模型
- 每个工作区使用独立的 Pi 模型服务;工作区外文件使用其所在目录
开发
npm install
npm run compile
开发环境需要 Node.js 22.19 或更高版本。
在 VS Code 中按 F5 启动 Extension Development Host。
License
MIT