用途:在 Bun 运行时下做开发时使用,围绕 Bun 原生 API 和零依赖模式展开,涵盖包管理、脚本执行、测试、构建,以及 SQLite、HTTP 服务、WebSocket、文件与 Shell 操作、密码哈希、环境变量和性能工具。不适用于仅 Node.js 模式、跨运行时库或非 Bun 项目。
主要能力:包管理与运行命令如 bun install、bun add zod、bun run src/index.ts、bun --watch index.ts;测试用 bun test、bun test --watch、bun test --coverage;构建用 bun build ./index.ts --outfile dist/bundle.js,加 --compile 可生成独立可执行文件,支持 --target 交叉编译。数据用 bun:sqlite 的 Database 与 prepare 预编译语句、transaction 事务;服务用 Bun.serve 或配合 Hono;文件用 Bun.file 与 Bun.write;Shell 用 $ 模板;密码用 Bun.password.hash/verify,推荐 argon2id;环境变量经 Bun.env 读取并用 Zod 校验。
使用与限制:查询始终用参数而非字符串拼接,多语句操作使用事务,密码不得明文,环境变量启动时校验,用完关闭数据库连接。优先使用 Bun 原生 API 替代对应 Node.js 写法。资料还提到 sqlite-patterns.md、server-patterns.md、testing.md 等参考文件及 database-crud.md、file-uploads.md 示例,具体内容暂未提供。