Files
wrong-notebook/.gitignore
margrop af2521ffa7 refactor: AI 额度与凭据改为可替换的扩展接口
新增 AI 账户接口 AiAccountProvider(src/lib/ai/account.ts),集中四件事:调用前的额度判断、按用户的 AI 配置、每次补全的用量记录、用户删除后的清理。默认实现即原有行为:每日次数上限(管理员不受限)、全站共用 AI 配置、用量写入 AiCompletion。

- consumeAiQuota 在 AI 数据授权检查之后交给 authorize 判断,实现出错时放行并记日志;授权检查仍由上游负责,扩展不能跳过
- getAIService 先取 resolveConfig:返回 OpenAI 兼容配置时按该地址、密钥和模型请求,并发名额与 API Key 无关
- 自助注销、管理员删除用户、系统初始化删除用户成功后通知 onUserDeleted,出错不影响删除
- 构建时用 AI_ACCOUNT_EXTENSION 指定实现文件,next.config.ts 经 Turbopack resolveAlias 把 @wrong-notebook/ai-account 指向它;Vitest 固定使用默认实现
- 私有实现约定放在 src/extensions/local/,加入 .gitignore 与上传前检查的私有路径

文档补充 FORK_EXTENSION_POINTS.md 的 AI 账户一节、.env.example 与 AGENTS.md 约定;测试覆盖扩展拒绝与出错、单独配置、删除通知(含真实 SQLite)和上传前检查。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 14:18:09 +08:00

89 lines
1.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions
# testing
/coverage
# next.js
/.next/
/out/
# pdfjs 静态资源(构建前由 scripts/copy-pdfjs-assets.mjs 从 pdfjs-dist 复制)
/public/pdfjs/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# 构建时注入的私有扩展(见 doc/FORK_EXTENSION_POINTS.md),不入库
/src/extensions/local/
# env files (can opt-in for committing if needed)
.env*
!.env.example
# vercel
.vercel
# typescript
*.tsbuildinfoconfig
*.tsbuildinfo
next-env.d.ts
/src/generated/prisma
# App config (contains secrets)
/config/app-config.json
/config/minimax-code.json
/config/background-tasks.json
/config/tts-cache/
dist-scripts
# Playwright
/playwright-report/
/test-results/
/blob-report/
/playwright/.cache/
# Local Database
*.db
*.db-journal
*.sqlite
*.sqlite-journal
# Logs & Output
*.log
test_output*.txt
upload_test_output*.txt
# data
/data/
.next-prebuilt/
# Deployment script checks
__pycache__/
*.pyc
# 安装包构建产物
/dist/
scripts/data/