Files
clawpanel/scripts/sync-version.js
晴天 921c371934 feat: AI助手支持 Anthropic/Gemini 原生API + 修复Windows终端闪烁
- AI助手新增 API 类型选择器(OpenAI兼容 / Anthropic原生 / Google Gemini)
- 实现 Anthropic Messages API 流式调用 + 工具调用(tool_use/tool_result)
- 实现 Google Gemini streamGenerateContent + 工具调用(functionCall)
- 设置弹窗动态切换 placeholder 和提示文本
- 测试按钮和模型拉取适配三种 API 类型
- 修复 Windows 上 Gateway 状态轮询导致终端反复闪烁(execSync/spawn 加 windowsHide)
- 默认密码统一为 123456 + 改密码后自动移除顶部横幅
- 后端 API 增加暴力破解保护、配置缓存、请求体大小限制
2026-03-06 22:46:40 +08:00

78 lines
2.1 KiB
JavaScript
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.
#!/usr/bin/env node
/**
* 版本号同步脚本
* 以 package.json 为唯一版本源,同步到所有相关文件
*
* 用法:
* node scripts/sync-version.js # 同步当前版本
* node scripts/sync-version.js 0.6.0 # 先改 package.json 再同步
*/
import { readFileSync, writeFileSync } from 'fs'
import { resolve, dirname } from 'path'
import { fileURLToPath } from 'url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const root = resolve(__dirname, '..')
// 读取 package.json
const pkgPath = resolve(root, 'package.json')
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))
// 如果传入了新版本号,先更新 package.json
const newVersion = process.argv[2]
if (newVersion) {
if (!/^\d+\.\d+\.\d+/.test(newVersion)) {
console.error('❌ 版本号格式不对,应为 x.y.z')
process.exit(1)
}
pkg.version = newVersion
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
console.log(`✅ package.json → ${newVersion}`)
}
const version = pkg.version
// 同步目标文件
const targets = [
{
file: 'src-tauri/tauri.conf.json',
update(content) {
const obj = JSON.parse(content)
obj.version = version
return JSON.stringify(obj, null, 2) + '\n'
},
},
{
file: 'src-tauri/Cargo.toml',
update(content) {
return content.replace(/^version\s*=\s*"[^"]*"/m, `version = "${version}"`)
},
},
{
file: 'docs/index.html',
update(content) {
return content.replace(/"softwareVersion":\s*"[^"]*"/, `"softwareVersion": "${version}"`)
},
},
]
let changed = 0
for (const { file, update } of targets) {
const filepath = resolve(root, file)
try {
const before = readFileSync(filepath, 'utf8')
const after = update(before)
if (before !== after) {
writeFileSync(filepath, after)
console.log(`${file}${version}`)
changed++
} else {
console.log(` ${file} — 已是 ${version}`)
}
} catch (e) {
console.error(`${file}: ${e.message}`)
}
}
console.log(`\n版本 ${version}${changed ? `已同步 ${changed} 个文件` : '所有文件已是最新'}`)