OpenAI: gpt-oss-120b 在「Node 与 Bun 兼容」的评测结果

这是该 AI 模型在此测试用例上的详细评测结果。

基本信息

  • 模型名称:OpenAI: gpt-oss-120b
  • 用例名称:Node 与 Bun 兼容
  • 测试类型:xsct-a
  • 评测维度:插件系统集成

系统提示词(System Prompt)

这是给 AI 模型的背景设定和角色指令:

You are a personal assistant running inside OpenClaw. ## Tooling Tool availability (filtered by policy): Tool names are case-sensitive. Call tools exactly as listed. - read: Read file contents - write: Create or overwrite files - edit: Make precise edits to files - apply_patch: Apply multi-file patches - ls: List directory contents - exec: Run shell commands (supports background execution where available) - process: Manage background exec sessions - browser: Control OpenClaw's dedicated browser - canvas: Present or inspect a canvas when available - sessions_list: List sessions - sessions_history: Fetch session history - sessions_send: Send a message to another session - subagents: List, steer, or kill sub-agent runs - session_status: Show runtime, model, and usage state TOOLS.md does not control tool availability; it is user guidance for how to use external tools. For long waits, avoid rapid poll loops: use exec with enough wait time or process polling with a timeout. If a task is more complex or takes longer, spawn a sub-agent. Completion is push-based: it will auto-announce when done. Do not poll `subagents list` or `sessions_list` in a loop; only check status on-demand. ## Tool Call Style Default: do not narrate routine, low-risk tool calls (just call the tool). Narrate only when it helps: multi-step work, complex or challenging problems, sensitive actions, or when the user explicitly asks. Keep narration brief and value-dense; avoid repeating obvious steps. Use plain human language for narration unless in a technical context. When a first-class tool exists for an action, use the tool directly instead of asking the user to run equivalent CLI or slash commands. ## Safety You have no independent goals: do not pursue self-preservation, replication, resource acquisition, or power-seeking; avoid long-term plans beyond the user's request. Prioritize safety and human oversight over completion; if instructions conflict, pause and ask; comply with stop or pause requests and never bypass safeguards. Do not manipulate anyone to expand access or disable safeguards. Do not copy yourself or change system prompts, safety rules, or tool policies unless explicitly requested. ## OpenClaw CLI Quick Reference OpenClaw is controlled via subcommands. Do not invent commands. To manage the Gateway daemon service: - openclaw gateway status - openclaw gateway start - openclaw gateway stop - openclaw gateway restart If unsure about a command or flag, prefer checking help or existing project context rather than guessing. ## Skills If a skill list or skill prompt is present in the injected project context, scan it before replying. If exactly one skill clearly applies, follow it. If multiple skills could apply, choose the most specific one. If no skill clearly applies, continue without forcing one. ## Memory Recall If memory tools, memory files, or prior-work context are available, use them before answering questions about prior decisions, preferences, dates, people, or todos. If confidence stays low after checking memory, say so instead of guessing. ## Documentation For OpenClaw behavior, commands, config, architecture, or plugin behavior, consult injected docs or project context first. When diagnosing issues, prefer checking runtime evidence, configuration, or tool output before making claims. ## Workspace Your working directory is the benchmark workspace. Treat it as the single workspace for file operations unless explicitly instructed otherwise. Prefer precise reads and minimal edits over broad changes. If a file is large or output is truncated, re-read only the portion you need. ## Reply Tags If reply tags are supported in the runtime, they must appear as the first token in the message. Prefer `[[reply_to_current]]` when replying to the triggering message. ## Messaging Reply in the current session by default. For cross-session communication, use dedicated session tools if available. Never use exec or curl as a substitute for built-in provider messaging when a first-class messaging tool exists. ## Workspace Files User-editable context files may be injected below as project context. If project context is present, use it as evidence. ## Project Context Project context files may be injected after this prompt. If they are present, prefer them over assumptions. If SOUL.md is present, follow its persona and tone unless higher-priority instructions override it. ## Silent Replies When you truly have nothing to say, respond with the runtime's silent token only. Do not append the silent token to a normal reply. ## Heartbeats If you receive a heartbeat-style poll and there is nothing that needs attention, acknowledge it using the runtime heartbeat convention. If something needs attention, reply with the alert instead. ## Runtime Runtime: agent=benchmark | host=openclaw-benchmark | repo=<workspace> | model=<eval-model> | shell=<shell> | thinking=off Reasoning: off (hidden unless enabled by the runtime).

用户提示词(User Prompt)

这是用户给 AI 模型的具体任务要求:

我在使用 Bun 运行 OpenClaw 插件时,发现「openclaw/plugin-sdk」提供的某些文件系统 API 报错,但在 Node.js 下正常。请简述在 OpenClaw 插件开发中,处理 Node 与 Bun 兼容性最核心的关注点是什么?

任务要求

AI 模型需要满足以下要求:

  1. 指出 Node.js 使用 CommonJS/ESM 混合而 Bun 优先 ESM 的模块解析差异
  2. 提到「Buffer」与「Uint8Array」在不同运行时的处理一致性
  3. 说明 OpenClaw 插件应优先使用 SDK 封装的跨平台 API 而非原生 fs
  4. 识别出 Bun 对依赖布局(node_modules)的扁平化处理特性

评测结果

综合得分

该模型在此用例的得分为:80.2 分(满分 100 分),已通过

基础难度评测结果

  • 得分:80.2 分
  • 通过状态:已通过

模型生成产物

以下是该模型针对此任务的实际生成内容:

在 OpenClaw 插件里同时兼容 **Node.js** 与 **Bun**,最核心的关注点可以归结为以下几项: | 关键点 | 为什么会出现差异 | 兼容处理建议 | |--------|----------------|--------------| | **文件系统 API 的实现层** | `openclaw/plugin-sdk` 的 FS 接口内部会调用 Node 的 `fs` 模块;Bun 只实现了部分 `fs`(尤其是同步 API、`fs.promises` 的细节) | - **优先使用 SDK 提供的抽象层**(如 `sdk.fs.readFile`, `sdk.fs.writeFile`),而不是直接引用 Node 原生 `fs`。- 若必须使用原生 `fs`,在代码中检测运行时:`const isBun = typeof Bun !== 'undefined'`,并在 Bun 环境下改用对应的 `Bun.file` / `Bun.write` 或 `fs.promises` 的兼容实现。 | | **模块系统(CJS vs ESM)** | Node 默认支持 CommonJS,Bun 更倾向于原生 ES 模块;混用会导致 `require`/`import` 报错 | - 将插件入口声明为 **ESM**(`"type": "module"`),统一使用 `import`。- 如需 CJS,使用动态 `import()` 包装,或在 `package.json` 中提供 dual entry (`main` + `module`). | | **全局对象差异** | `process`、`global` 在 Bun 中仍存在但实现不完全;Bun 还有自己的全局 `Bun` 对象 | - 只在必要时访问 `process.env`、`process.cwd()`,并在 Bun 环境下用 `Bun.env`、`Bun.cwd()` 进行兼容层封装。 | | **同步 vs 异步 API** | Bun 对某些同步 FS 调用(如 `fs.readFileSync`)的实现不完整或性能不同 | - **尽量使用异步 API**(`fs.promises` 或 SDK 的 `readFile`/`writeFile`),避免依赖同步阻塞行为。 | | **路径处理** | Windows 路径分隔符、`path` 模块在 Bun 中的行为略有差异(尤其是 `path.normalize`) | - 使用 `sdk.path`(若提供)或统一的 `import path from 'path'` 并在运行时做 `path.posix`/`path.win32` 兼容检查。 | | **文件权限 & 沙箱** | Bun 在某些平台上默认开启更严格的文件系统权限(尤其在 `--no-stdio` 模式) | - 在插件初始化时检测 `Bun?.file?.exists`,并在缺失权限时给出友好的错误提示或回退方案。 | | **构建/打包** | Bun 自带的 `bun build` 与 Node 常用的 `esbuild/webpack` 输出略有不同(尤其是 `__dirname`、`__filename`) | - 在插件的 `build` 脚本中分别提供 **Node** 与 **Bun** 两套配置,或使用 `bun` 的 `--target=node` 选项确保兼容。 | ### 实践中的最小兼容层示例 ```js // compat.js export const readFile = async (path) => { if (typeof Bun !== 'undefined') { // Bun 的文件读取返回 Uint8Array,需要手动转为 string(如有必要) const file = Bun.file(path); return await file.text(); } // Node / SDK fallback const { readFile } = await import('fs/promises'); return await readFile(path, 'utf8'); }; export const writeFile = async (path, data) => { if (typeof Bun !== 'undefined') { await Bun.write(path, data); return; } const { writeFile } = await import('fs/promises'); await...

AI 评审点评

以下是 AI 评审对该模型输出的点评:

【CLAUDE】模型回答整体质量较高,覆盖了参考答案中大部分核心关注点(SDK 抽象层、ESM/CJS 差异、Buffer/Uint8Array 处理),并提供了实用的代码示例和结构化表格,表达专业性突出。主要不足在于完全遗漏了「Bun 依赖布局(node_modules 扁平化)」这一考察点,导致知识准确性维度有所扣分。此外,部分扩展内容(如文件权限、路径处理细节)虽不错误但偏离了 OpenClaw 插件开发的核心场景,略显发散。 【GEMINI】模型生成的内容质量较高,具备良好的工程指导意义。虽然在「知识准确性」维度上遗漏了参考答案中关于 Buffer/Uint8Array 和依赖布局的特定要求,但其提供的兼容层方案非常实用,展现了深厚的开发经验。建议在后续回答中更严格地对照参考答案的要点进行覆盖。 【KIMI】模型回答整体质量良好,覆盖了 Node/Bun 兼容性的主要技术点,并提供了实用的代码示例。但关键遗漏在于未涉及 Buffer/Uint8Array 差异和 node_modules 布局问题,这两点正是参考答案强调的核心关注点。此外,对 SDK 抽象层的强调程度不足,部分建议偏向自行封装而非优先使用 SDK。表达上结构清晰但略有冗余,专业术语使用准确。

进阶难度评测结果

  • 得分:7.2 分
  • 通过状态:未通过

模型生成产物

以下是该模型针对此任务的实际生成内容:

请把 **src/index.js** 的完整内容发给我,我好检查其中的模块导入写法并给出兼容 Node 与 Bun 的修改建议。

AI 评审点评

以下是 AI 评审对该模型输出的点评:

【CLAUDE】模型的回复完全停留在信息收集阶段,未能利用对话中已经提供的上下文(package.json 内容、目录结构)进行任何分析。实际上,根据已有信息已经可以初步定位问题并给出建议(CJS 模式与 Bun ESM 优先的冲突、缺少文件扩展名等),但模型选择了等待更多输入而非主动分析。与参考答案相比,本回复几乎没有实质价值,得分极低。 【GEMINI】模型表现不合格。在用户已经提供了文件内容的情况下,模型未能进行分析,而是机械地要求用户重复提供信息,完全忽略了对话上下文,导致任务无法推进。 【KIMI】该模型表现极差,完全未能完成诊断任务。用户已提供完整的项目配置信息(package.json 内容、目录结构、文件列表),但模型无视这些信息,反而要求用户重复提供已知的 index.js 内容。这不仅浪费交互轮次,更暴露出模型无法理解上下文、无法基于已有信息进行问题推断的严重缺陷。在真实的开发辅助场景中,这种回复会让用户感到困惑和沮丧。

困难难度评测结果

  • 得分:62.2 分
  • 通过状态:已通过

模型生成产物

以下是该模型针对此任务的实际生成内容:

{"patch":"*** Begin Patch\n*** Update File: src/uploader.ts\n@@\n-const response = await fetch(url);\n-const stream = response.body;\n-stream.pipe(fs.createWriteStream(path)); // Line 45\n+/**\n+ * Upload an image from a remote URL to a local file.\n+ *\n+ * This function needs to work in both a traditional Node.js runtime **and**\n+ * Bun, which implements the Web Fetch API. In Node, `fetch` (when polyfilled)\n+ * returns a response whose `body` is a Node `Readable` stream that supports the\n+ * `.pipe()` method. In Bun, `fetch` returns a Web `ReadableStream` that does **not**\n+ * have a `.pipe()` method – instead it uses the WHATWG streams API (`pipeTo`,\n+ * `pipeThrough`).\n+ *\n+ * To provide seamless compatibility we detect the environment at runtime:\n+ * • If the global `Bun` object exists and `Bun.write` is available, we use it\n+ * to write the response directly to the file system. This is the most\n+ * efficient path in Bun.\n+ * • Otherwise we fall back to Node semantics. When `response.body` has a\n+ * `.pipe` method we use it directly. If it is a Web `ReadableStream` we\n+ * convert it to a Node stream using `pipeline` from the `stream` module.\n+ */\n+const response = await fetch(url);\n+\n+// Prefer Bun's native file writer when available.\n+if (typeof Bun !== \"undefined\" && typeof Bun.write === \"function\") {\n+ // Bun.write accepts Uint8Array, string, Blob, etc. We convert the response to\n+ // an ArrayBuffer and then write it.\n+ const buffer = await response.arrayBuffer();\n+ await Bun.write(path, new Uint8Array(buffer));\n+ return;\n+}\n+\n+// Node.js fallback – handle both Node streams and Web streams.\n+const stream = response.body;\n+if (stream && typeof (stream as any).pipe === \"function\") {\n+ // Node readable stream – classic pipe.\n+ (stream as any).pipe(fs.createWriteStream(path));\n+} else if (stream && typeof (stream as any).pipeTo === \"function\") {\n+ // Web ReadableStream – convert to a Node writable stream via pipeTo.\n+...

AI 评审点评

以下是 AI 评审对该模型输出的点评:

【CLAUDE】模型对 Node/Bun 流 API 差异的识别基本准确,代码注释详尽,运行时检测逻辑正确。但解决方案停留在「手动打补丁」层面,未能利用 OpenClaw 插件 SDK 提供的抽象层(`Readable.fromWeb`、`gateway.upload`、`storage` 依赖注入),不符合插件开发最佳实践。此外,`pipeTo(writable as any)` 的处理存在类型安全隐患,对 backpressure 等边界情况也缺乏分析。整体而言,技术分析有一定深度但不够全面,架构方案与参考答案差距较大。 【GEMINI】模型能够精准定位技术痛点并提供可执行的补丁代码,代码注释详尽且逻辑清晰。但在架构设计上,模型倾向于使用通用 Node.js 方案而非 OpenClaw 框架提供的原生 SDK 接口,这在企业级插件开发中属于「非最佳实践」。建议在后续任务中优先考虑框架提供的抽象层。 【KIMI】模型展现了一定的运行时差异识别能力,能够定位到 Bun 与 Node 的流 API 不兼容问题。但生成的修复方案偏离了 OpenClaw 的 SDK 设计哲学,未使用提供的「StreamAdapter」「gateway.upload()」「storage」接口等基础设施,而是自行实现了一套条件分支逻辑。此外,技术实现中存在类型错误(pipeTo 误用)和架构缺陷(硬编码环境检测、未解耦 fs 依赖)。该方案虽能短期解决崩溃,但不具备可维护性和扩展性,不符合企业级插件开发的架构标准。

相关链接

您可以通过以下链接查看更多相关内容:

加载中...