feat: 新增卸载脚本与统一版本管理

uninstall.mjs 一键清理 installed.json/managed 副本/含密钥配置目录(--yes/--dry-run,幂等);scripts/bump-version.mjs 以 package.json 为唯一版本来源同步 kimi.plugin.json,挂 npm version 钩子;vision.mjs VERSION 运行时读 package.json,并修复 modelsEndpoint 对 /chat/completions 结尾的边界。1.0.5 → 1.0.6。
This commit is contained in:
billowliu2 committed 2026-08-02 16:40:57 +08:00
1 parent 8a5d41ebca
commit 839a66ff5d
5 files changed
+263 -5

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env node
// kimi-eyes — 版本同步脚本。package.json 是唯一版本来源。
//
// 用法:
// node scripts/bump-version.mjs 从 package.json 同步 kimi.plugin.json
// node scripts/bump-version.mjs 1.0.6 更新 package.json 并同步 kimi.plugin.json
//
// 作为 npm "version" 钩子运行时(npm version xxx 改完包版本后自动触发),
// 无需参数,自动把新版本同步到 kimi.plugin.json。
// mcp/vision.mjs 的 VERSION 在运行时直接读取 package.json,无需同步。
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const root = path.resolve(__dirname, '..');
const pkgPath = path.join(root, 'package.json');
const pluginPath = path.join(root, 'kimi.plugin.json');
const SEMVER = /^\d+\.\d+\.\d+$/;
function readJson(p) {
return JSON.parse(fs.readFileSync(p, 'utf8'));
}
function writeJson(p, obj) {
fs.writeFileSync(p, `${JSON.stringify(obj, null, 2)}\n`, 'utf8');
}
const arg = process.argv[2];
const pkg = readJson(pkgPath);
if (arg) {
if (!SEMVER.test(arg)) {
console.error(`[bump-version] 非法版本号: ${arg}(需要 semver 格式,如 1.0.6)`);
process.exit(1);
}
pkg.version = arg;
writeJson(pkgPath, pkg);
console.log(`[bump-version] package.json -> ${arg}`);
} else {
console.log(`[bump-version] package.json 当前版本: ${pkg.version}`);
}
// 同步到 kimi.plugin.json
const plugin = readJson(pluginPath);
if (plugin.version === pkg.version) {
console.log(`[bump-version] kimi.plugin.json 已一致 (${pkg.version})`);
} else {
plugin.version = pkg.version;
writeJson(pluginPath, plugin);
console.log(`[bump-version] kimi.plugin.json -> ${pkg.version}`);
}