ByteNoteByteNote

字节笔记本

2026年6月21日

Oracle:把 Prompt 和文件打包,让 GPT/Claude/Gemini 用真实上下文回答

API中转
¥120

本文介绍 Oracle,一个由 Peter Steinberger(steipete)开源的 CLI 工具。它的核心作用是把你的 prompt 和项目文件打包成一份结构化上下文,然后交给 GPT、Claude、Gemini 等 AI 模型回答。它支持 API 模式和浏览器自动化模式,也可以同时询问多个模型。

项目简介

Oracle 是一个面向开发者日常工作的 AI 上下文管理工具,仓库地址为 steipete/oracle。它解决了一个很实际的问题:当你想让 AI 帮你 review 代码、排查 bug、写架构文档时,怎么把"当前项目的相关文件"高效地喂给模型。

Oracle 的做法是:你指定 prompt 和文件路径,它自动把内容组装成一个 markdown bundle,然后通过 API 或浏览器自动化发送给 AI。截至本文,该项目在 GitHub 上已获得约 2.8k stars,主要使用 TypeScript(约 94.5%)编写。

核心特性

  • 上下文打包:把 prompt 和一组文件/目录组合成适合大模型阅读的 bundle。
  • 多模型支持:支持 GPT-5.5 Pro、GPT-5.4、GPT-5.2、GPT-5.1、Gemini 3.1 Pro、Gemini 3.5 Flash、Claude Sonnet 4.6、Claude Opus 4.1 等。
  • 多模型并行:一次运行可以同时问多个模型,并汇总结果。
  • API 模式:直接使用 OpenAI、Anthropic、Gemini 的 API Key,稳定可靠。
  • 浏览器模式:无需 API Key,自动化操作 ChatGPT 或 Gemini 网页版。
  • 会话管理:API 和浏览器会话都可以保存、继续、查看状态。
  • MCP 支持:可以作为 MCP server,被 Claude Code、Codex、Cursor 等工具调用。
  • Codex Skill:提供开箱即用的 Codex skill,方便在 Codex 中调用。

技术栈

  • TypeScript — 核心实现
  • Node.js 24+ — 运行环境
  • Playwright / Puppeteer 风格浏览器自动化 — 浏览器模式
  • pnpm — 包管理

安装指南

前置要求

  • Node.js 24 或更高版本
  • 至少一个 API Key(API 模式),或已登录的 ChatGPT/Gemini 浏览器会话(浏览器模式)

安装方式

bash
# npm 全局安装
npm install -g @steipete/oracle

# 或使用 Homebrew
brew install steipete/tap/oracle

# 不安装,直接用 npx
npx -y @steipete/oracle --help

快速开始

API 模式

bash
# 设置环境变量
export OPENAI_API_KEY="sk-..."

# 最小运行
npx -y @steipete/oracle \
  -p "Write a concise architecture note for the storage adapters" \
  --file src/storage/README.md

浏览器模式(macOS,无需 API Key)

bash
# 首次登录:创建独立的自动化浏览器 profile 并登录 ChatGPT
npx -y @steipete/oracle --engine browser --browser-manual-login \
  --browser-keep-browser --browser-input-timeout 120000 \
  -p "HI"

# 后续运行:复用已登录的 profile
npx -y @steipete/oracle --engine browser --browser-manual-login \
  --browser-auto-reattach-delay 5s \
  --browser-auto-reattach-interval 3s \
  --browser-auto-reattach-timeout 60s \
  -p "your prompt"

使用示例

复制 bundle 手动粘贴到 ChatGPT

bash
npx -y @steipete/oracle --render --copy \
  -p "Review the TS data layer for schema drift" \
  --file "src/**/*.ts,*/*.test.ts"

多模型 API 运行

bash
npx -y @steipete/oracle \
  -p "Cross-check the data layer assumptions" \
  --models gpt-5.1-pro,gemini-3-pro \
  --file "src/**/*.ts"

检查 provider 路由和可用性

bash
npx -y @steipete/oracle doctor --providers --models gpt-5.4,claude-4.6-sonnet,gemini-3-pro
npx -y @steipete/oracle --preflight --models gpt-5.4,gemini-3-pro

多模型顾问面板

bash
npx -y @steipete/oracle \
  --models gpt-5.5-pro,gemini-3-pro,claude-4.6-sonnet \
  --allow-partial --write-output /tmp/panel.md \
  -p "Review the naming options" \
  --file docs/naming.md

继续已有会话

bash
# 从浏览器会话继续
npx -y @steipete/oracle \
  --followup <browser-session-id> \
  -p "Follow-up: review this additional file in the same conversation." \
  --file "server/src/strategy/plan.ts"

# 从 API Responses API 继续
npx -y @steipete/oracle --engine api --model gpt-5.2-pro \
  --followup resp_abc1234567890 \
  -p "Continue from this response" \
  --file docs/notes.md

会话管理

bash
# 查看最近 72 小时会话
npx -y @steipete/oracle status --hours 72

# 渲染某个会话
npx -y @steipete/oracle session <id> --render

# 重启某个会话
npx -y @steipete/oracle restart <id>

与 AI 工具集成

Codex Skill

bash
mkdir -p ~/.codex/skills
cp -R skills/oracle ~/.codex/skills/oracle

Claude Code / MCP

在同一台 Mac 上,如果已有登录的 ChatGPT 浏览器,可以生成 MCP 配置:

bash
oracle bridge claude-config --local-browser > .mcp.json

Cursor MCP

创建 .cursor/mcp.json

json
{
  "oracle": {
    "command": "oracle-mcp",
    "args": []
  }
}

注意事项

  • 浏览器模式是实验性的:API 模式更稳定,浏览器模式适合没有 API Key 或想使用 ChatGPT Pro 等网页专属功能的场景。
  • 权限与安全:浏览器自动化会控制 Chrome,首次使用建议加 --dry-run summary 预览行为。
  • 共享桌面环境:如果多人/多个 agent 共享同一台机器上的 Chrome profile,建议使用 --remote-chrome 指向一个已开启 remote debugging 的 Chrome 实例。
  • 长时间运行:GPT-5.5 Pro 等模型的浏览器回复可能很慢,使用 --heartbeatoracle statusoracle session <id> 查看进度,避免重复启动。
  • 文件大小控制:Oracle 有文件大小保护和 glob 排除机制,可以用 --files-report 查看每个文件的 token 占用。
  • 隐私:bundle 会包含你指定的文件内容,注意不要传入敏感凭证或私密数据。

项目链接

分享: