From bb9dc4950e19bbc99743d9a9fe2d6c9846b5d6fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?AI=E4=B8=8D=E6=AD=A2=E8=AF=AD?= <12096460+jnMetaCode@users.noreply.github.com> Date: Tue, 5 May 2026 19:32:20 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20plugin=20manifest=20=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E8=87=AA=E5=8A=A8=E8=B7=9F=20package.json=20=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前 .claude-plugin/plugin.json 和 .cursor-plugin/plugin.json 的 version 字段一直停在 1.1.8,落后于 npm 1.1.9 / 1.2.0 / 1.2.1——每次发版都要手改。 - 新增 scripts/sync-plugin-version.js:用正则替换 version 字段一行, 保留两个 manifest 的原排版(数组单行/多行、缩进等),无 diff 噪音 - 在 package.json 挂 npm version 钩子:bump 后自动同步并 git add 到 version commit 里,从此不会再漏 - 把当前两个 manifest 从 1.1.8 一次性修到 1.2.1 --- .claude-plugin/plugin.json | 2 +- .cursor-plugin/plugin.json | 2 +- package.json | 3 +++ scripts/sync-plugin-version.js | 30 ++++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 scripts/sync-plugin-version.js diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index b3767a7..404d466 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "superpowers-zh", "description": "AI 编程超能力中文增强版:20 个 skills(14 翻译 + 6 中国原创),支持 Claude Code / Hermes Agent / Cursor / Claw Code 等 17 款工具", - "version": "1.1.8", + "version": "1.2.1", "author": { "name": "jnMetaCode", "url": "https://github.com/jnMetaCode" diff --git a/.cursor-plugin/plugin.json b/.cursor-plugin/plugin.json index c28e9b7..d4383cf 100644 --- a/.cursor-plugin/plugin.json +++ b/.cursor-plugin/plugin.json @@ -2,7 +2,7 @@ "name": "superpowers-zh", "displayName": "Superpowers 中文版", "description": "AI 编程超能力中文增强版:20 个 skills(14 翻译 + 6 中国原创),支持 Cursor / Claude Code / Hermes Agent / Claw Code 等 17 款工具", - "version": "1.1.8", + "version": "1.2.1", "author": { "name": "jnMetaCode", "url": "https://github.com/jnMetaCode" diff --git a/package.json b/package.json index 43da296..f216d5f 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,9 @@ "bin": { "superpowers-zh": "bin/superpowers-zh.js" }, + "scripts": { + "version": "node scripts/sync-plugin-version.js && git add .claude-plugin/plugin.json .cursor-plugin/plugin.json" + }, "files": [ "bin/", "skills/", diff --git a/scripts/sync-plugin-version.js b/scripts/sync-plugin-version.js new file mode 100644 index 0000000..ee2581d --- /dev/null +++ b/scripts/sync-plugin-version.js @@ -0,0 +1,30 @@ +#!/usr/bin/env node +// 把 package.json 的 version 同步到 plugin manifest +// 由 npm version 钩子触发,跑在 version commit 创建之前 +import { readFileSync, writeFileSync } from 'fs'; +import { resolve, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +const root = resolve(dirname(fileURLToPath(import.meta.url)), '..'); +const pkg = JSON.parse(readFileSync(resolve(root, 'package.json'), 'utf8')); +const targets = [ + '.claude-plugin/plugin.json', + '.cursor-plugin/plugin.json', +]; + +let touched = 0; +for (const rel of targets) { + const path = resolve(root, rel); + const text = readFileSync(path, 'utf8'); + const json = JSON.parse(text); + if (json.version === pkg.version) continue; + // 只替换顶层 version 字段一行,保留原文件其他字段的格式(数组单行/多行、缩进等) + const updated = text.replace(/("version":\s*")[^"]+(")/, `$1${pkg.version}$2`); + if (updated === text) { + throw new Error(`未能在 ${rel} 中定位 version 字段`); + } + writeFileSync(path, updated, 'utf8'); + console.log(` ${rel}: ${json.version} -> ${pkg.version}`); + touched++; +} +if (touched === 0) console.log(` plugin manifests already at ${pkg.version}`);