From 085e92a8ae488821fbdf9625f0ef20fc0bc49194 Mon Sep 17 00:00:00 2001 From: zhang Date: Wed, 18 Feb 2026 10:57:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(install):=20=E6=B6=88=E9=99=A4=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E5=81=9C=E9=A1=BF=EF=BC=8C=E6=94=B9=E4=B8=BA=E4=B8=80?= =?UTF-8?q?=E6=B0=94=E5=91=B5=E6=88=90=E6=8C=87=E4=BB=A4=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 generateCommandContent() 的「先读取 SKILL.md…然后执行」 两步分离模式改为一气呵成指令流: - 保留读取 SKILL.md(保留行为上下文如骨架填充指引) - 保留执行 run_skill.js(保留脚本功能) - 合并为有序步骤列表 + 「全程不要停顿」约束 - 消除 Claude 在 Read/Bash 工具调用间的停顿等待 - allowed-tools 恢复使用 SKILL.md 中定义的工具集 --- bin/install.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/bin/install.js b/bin/install.js index 69d3a6b..2a823f7 100755 --- a/bin/install.js +++ b/bin/install.js @@ -230,6 +230,12 @@ function scanInvocableSkills(skillsDir) { /** * 根据 SKILL.md 元数据生成 command .md 内容 + * + * 设计原则: + * - 读取 SKILL.md + 执行脚本合并为一气呵成的指令流 + * - 禁止「先…然后…」的分步模式,避免 Claude 在步骤间停顿 + * - 无脚本的 skill:仅读取 SKILL.md 作为知识库提供指导 + * * @param {Object} meta - parseFrontmatter 返回的元数据 * @param {string} skillRelPath - 相对于 skills/ 的路径(如 'tools/gen-docs') * @param {boolean} hasScripts - 是否有可执行脚本 @@ -253,24 +259,23 @@ function generateCommandContent(meta, skillRelPath, hasScripts) { lines.push(`allowed-tools: ${tools}`); lines.push('---'); lines.push(''); - lines.push('## 执行指南'); - lines.push(''); - lines.push('先读取完整的 Skill 定义获取详细规范:'); - lines.push(''); - lines.push('```'); - lines.push(skillPath); - lines.push('```'); if (hasScripts) { + // ── 有脚本的 skill:读取规范 + 执行脚本,一气呵成 ── + lines.push('以下所有步骤一气呵成,不要在步骤间停顿等待用户输入:'); lines.push(''); - lines.push('然后执行:'); + lines.push(`1. 读取规范:${skillPath}`); + lines.push(`2. 执行命令:\`node ~/.claude/skills/run_skill.js ${name} $ARGUMENTS\``); + lines.push('3. 按规范分析输出,完成后续动作'); lines.push(''); - lines.push('```bash'); - lines.push(`node ~/.claude/skills/run_skill.js ${name} $ARGUMENTS`); - lines.push('```'); + lines.push('全程不要停顿,不要询问是否继续。'); } else { + // ── 无脚本的 skill:知识库模式 ── + lines.push('读取以下秘典,根据内容为用户提供专业指导:'); lines.push(''); - lines.push('根据秘典内容为用户提供专业指导。'); + lines.push('```'); + lines.push(skillPath); + lines.push('```'); } lines.push('');