Skip to content

feat: 支持配置「使用密钥」弹窗的 AI 工具配置替换规则#2299

Open
Wars wants to merge 1 commit intoWei-Shaw:mainfrom
Wars:feat-configurable-use-key-rules
Open

feat: 支持配置「使用密钥」弹窗的 AI 工具配置替换规则#2299
Wars wants to merge 1 commit intoWei-Shaw:mainfrom
Wars:feat-configurable-use-key-rules

Conversation

@Wars
Copy link
Copy Markdown

@Wars Wars commented May 8, 2026

Summary

  • 新增管理端「AI 工具配置替换规则」,支持按平台和工具维护普通字符串替换规则
  • 将规则通过公开设置下发到用户侧
  • 在「使用密钥」弹窗生成 AI 工具配置后,按规则顺序替换配置内容
  • 规则支持多行文本替换,仅作用于配置内容,不修改文件路径和提示信息
  • 调整 KeysView 到 UseKeyModal 的数据流,确保弹窗使用当前页面已加载的 public settings,避免全局缓存未加载时跳过规则
  • 补充后端、管理端设置页和「使用密钥」弹窗相关测试

Demo

例如需要调整生成给 Codex 的配置窗口参数,可以新增一条多行替换规则:

平台 工具 查找内容 替换为
OpenAI Codex model_context_window = 1000000
model_auto_compact_token_limit = 900000
model_context_window = 200000
model_auto_compact_token_limit = 200000

替换后,「使用密钥」弹窗生成的 Codex 配置会从:

model_context_window = 1000000
model_auto_compact_token_limit = 900000

变为:

model_context_window = 200000
model_auto_compact_token_limit = 200000

Testing

  • git diff --check
  • go test -tags=unit ./internal/service ./internal/handler ./internal/handler/admin ./internal/handler/dto -run 'Test(SettingService_GetPublicSettings_ExposesAIToolRewriteRules|SettingHandler_GetPublicSettings_ExposesAIToolRewriteRules|SettingHandler_UpdateSettings_(PersistsAIToolRewriteRules|RejectsInvalidAIToolRewriteRules|RejectsTooManyAIToolRewriteRules)|PublicSettingsInjectionPayload_SchemaDoesNotDrift)' -count=1
  • node_modules/.bin/vitest run src/components/keys/__tests__/UseKeyModal.spec.ts src/views/admin/__tests__/SettingsView.spec.ts
  • node_modules/.bin/vue-tsc --noEmit -p tsconfig.json

Notes

  • 替换规则会通过公开设置下发,管理端已提示不要填写 API Key、Token 等敏感信息

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@Wars
Copy link
Copy Markdown
Author

Wars commented May 8, 2026

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant