@adonis0123/skill-development 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/install-skill.js +47 -0
  2. package/package.json +1 -1
package/install-skill.js CHANGED
@@ -115,6 +115,47 @@ function readSkillConfig(dir) {
115
115
  }
116
116
  return JSON.parse(import_fs.default.readFileSync(configPath, "utf-8"));
117
117
  }
118
+ function parseYamlFrontmatter(content) {
119
+ const match = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
120
+ if (!match) {
121
+ return null;
122
+ }
123
+ const [, frontmatterStr, body] = match;
124
+ const frontmatter = {};
125
+ const lines = frontmatterStr.split("\n");
126
+ for (const line of lines) {
127
+ const match2 = line.match(/^(\w+):\s*(.*)$/);
128
+ if (match2) {
129
+ const [, key, value] = match2;
130
+ frontmatter[key] = value.replace(/^["']|["']$/g, "").trim();
131
+ }
132
+ }
133
+ return { frontmatter, body };
134
+ }
135
+ function patchSkillMdName(skillMdPath, name) {
136
+ try {
137
+ const content = import_fs.default.readFileSync(skillMdPath, "utf-8");
138
+ const parsed = parseYamlFrontmatter(content);
139
+ if (!parsed) {
140
+ console.warn(" \u26A0 Warning: SKILL.md has no frontmatter, skipping name patch");
141
+ return;
142
+ }
143
+ const { frontmatter, body } = parsed;
144
+ frontmatter.name = name;
145
+ const frontmatterLines = Object.entries(frontmatter).map(
146
+ ([key, value]) => `${key}: ${value}`
147
+ );
148
+ const newContent = `---
149
+ ${frontmatterLines.join("\n")}
150
+ ---
151
+ ${body}`;
152
+ import_fs.default.writeFileSync(skillMdPath, newContent, "utf-8");
153
+ console.log(` \u2713 Patched SKILL.md name: ${name}`);
154
+ } catch (error) {
155
+ const message = error instanceof Error ? error.message : String(error);
156
+ console.warn(` \u26A0 Warning: Failed to patch SKILL.md name: ${message}`);
157
+ }
158
+ }
118
159
 
119
160
  // shared/src/claude-settings.ts
120
161
  var import_fs2 = __toESM(require("fs"));
@@ -279,8 +320,14 @@ function installToTarget(target, config, sourceDir, isRemote) {
279
320
  }
280
321
  import_fs3.default.copyFileSync(skillMdSource, import_path3.default.join(targetDir, "SKILL.md"));
281
322
  console.log(" \u2713 Copied SKILL.md");
323
+ if (isRemote && config.remoteSource) {
324
+ patchSkillMdName(import_path3.default.join(targetDir, "SKILL.md"), config.name);
325
+ }
282
326
  const filesToCopy = config.files || {};
283
327
  for (const [source, dest] of Object.entries(filesToCopy)) {
328
+ if (source === "SKILL.md") {
329
+ continue;
330
+ }
284
331
  const sourcePath = import_path3.default.join(sourceDir, source);
285
332
  if (!import_fs3.default.existsSync(sourcePath)) {
286
333
  console.warn(` \u26A0 Warning: ${source} not found, skipping`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonis0123/skill-development",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Claude Code Skill - 技能开发指南,提供创建有效技能的完整流程和最佳实践。安装时自动从 Anthropic 官方仓库拉取最新版本。",
5
5
  "scripts": {
6
6
  "postinstall": "node install-skill.js",