feat: 新增領域時同步更新插件與市集的 README、manifest 並升版本

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
root
2026-10-14 05:32:29 +00:00
co-authored by Claude Sonnet 5.5
parent 9b3802d28a
commit 23343aed2f
3 changed files with 28 additions and 2 deletions
+26
View File
@@ -267,6 +267,32 @@ function cmdAddChapter(args: string[]): void {
touched.push(wikiSkill);
}
}
// 在 marketplace repo 內:同步市集 README、市集 manifest 與插件 manifest 的指令清單,並升一個修訂版本
const pluginDir = join(skillsDir, "..");
const repoRoot = join(pluginDir, "..", "..");
const edit = (file: string, fn: (s: string) => string): void => {
if (!existsSync(file)) return;
const before = read(file);
const after = fn(before);
if (after !== before) {
write(file, after);
touched.push(file);
}
};
const bump = (v: string): string => v.replace(/(\d+\.\d+\.)(\d+)/, (_, a, b) => a + (Number(b) + 1));
let version = "";
edit(join(pluginDir, ".claude-plugin", "plugin.json"), (j) => {
j = j.replace(/(:[a-z0-9-]+)(;\/jsc-wiki:book-search)/, `$1、:${key}$2`);
return j.replace(/("version": ")([^"]+)"/, (_, a, v) => `${a}${(version = bump(v))}"`);
});
edit(join(repoRoot, ".claude-plugin", "marketplace.json"), (j) =>
j.replace(/(system(?:、[a-z0-9-]+)*)( 指令)/, `$1、${key}$2`));
edit(join(repoRoot, "README.md"), (r) => {
r = r.replace(/(### \[jsc-wiki\]\(plugins\/jsc-wiki\) `)[^`]+`/, (_, a) => `${a}${version || "未知"}\``);
return r.replace(/(### \[jsc-wiki\][\s\S]*?`:[a-z0-9-]+`)( 等指令)/, `$1、\`:${key}\`$2`);
});
console.log(`已新增:${name.slice(0, -3)}(wiki 工作副本,尚未推送)`);
console.log(`已產生領域技能 /jsc-wiki:${key},變更的檔案:\n${touched.map((f) => " " + f).join("\n")}`);
console.log("提醒:技能檔在插件目錄,需 commit 進 jsc-marketplace repo 才會保留;重新載入插件後指令才會出現。");