@stefafafan/skm 0.1.1 → 0.1.2

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.
package/dist/src/index.js CHANGED
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.main = main;
7
+ const promises_1 = require("node:fs/promises");
8
+ const node_path_1 = __importDefault(require("node:path"));
4
9
  const add_1 = require("./commands/add");
5
10
  const init_1 = require("./commands/init");
6
11
  const inspect_1 = require("./commands/inspect");
@@ -44,6 +49,7 @@ function parseArgv(argv) {
44
49
  all: false,
45
50
  force: false,
46
51
  help: false,
52
+ version: false,
47
53
  };
48
54
  for (let index = 0; index < argv.length; index += 1) {
49
55
  const token = argv[index];
@@ -58,6 +64,10 @@ function parseArgv(argv) {
58
64
  parsed.help = true;
59
65
  continue;
60
66
  }
67
+ if (token === "--version" || token === "-v") {
68
+ parsed.version = true;
69
+ continue;
70
+ }
61
71
  if (token === "--project") {
62
72
  parsed.scope = "project";
63
73
  continue;
@@ -92,6 +102,9 @@ async function dispatch(parsed, cwd, env) {
92
102
  if (parsed.command === "help") {
93
103
  return buildHelpResult(parsed.positional[0]);
94
104
  }
105
+ if (parsed.version) {
106
+ return buildVersionResult();
107
+ }
95
108
  if (parsed.help) {
96
109
  return buildHelpResult(parsed.command);
97
110
  }
@@ -184,12 +197,21 @@ async function dispatch(parsed, cwd, env) {
184
197
  scope: parsed.scope,
185
198
  canonicalName: parsed.positional[0],
186
199
  });
200
+ case "version":
201
+ return buildVersionResult();
187
202
  default:
188
203
  throw new errors_1.SkmError(`Unknown command: ${parsed.command}`, 2);
189
204
  }
190
205
  }
191
206
  function buildHelpResult(command) {
192
207
  switch (command) {
208
+ case "version":
209
+ return {
210
+ kind: "help",
211
+ title: "skm version",
212
+ usage: "skm version",
213
+ sections: [{ title: "Aliases", lines: ["- --version", "- -v"] }],
214
+ };
193
215
  case "add":
194
216
  return {
195
217
  kind: "help",
@@ -308,14 +330,34 @@ function buildHelpResult(command) {
308
330
  "- update [name]",
309
331
  "- list",
310
332
  "- inspect <name>",
333
+ "- version",
311
334
  "- help [command]",
312
335
  ],
313
336
  },
314
337
  {
315
338
  title: "Global options",
316
- lines: ["- --help, -h", "- --project", "- --global"],
339
+ lines: ["- --help, -h", "- --version, -v", "- --project", "- --global"],
317
340
  },
318
341
  ],
319
342
  };
320
343
  }
321
344
  }
345
+ async function buildVersionResult() {
346
+ return {
347
+ kind: "version",
348
+ version: await readPackageVersion(),
349
+ };
350
+ }
351
+ let cachedPackageVersion;
352
+ async function readPackageVersion() {
353
+ if (cachedPackageVersion) {
354
+ return cachedPackageVersion;
355
+ }
356
+ const packageJsonPath = node_path_1.default.resolve(__dirname, "..", "..", "package.json");
357
+ const packageJson = JSON.parse(await (0, promises_1.readFile)(packageJsonPath, "utf8"));
358
+ if (!packageJson.version) {
359
+ throw new errors_1.SkmError(`Missing version in ${packageJsonPath}`, 1);
360
+ }
361
+ cachedPackageVersion = packageJson.version;
362
+ return cachedPackageVersion;
363
+ }
@@ -18,7 +18,7 @@ async function materializeSkill(options) {
18
18
  }
19
19
  await (0, fs_1.copyDirectory)(options.sourceDir, outputDir);
20
20
  if (options.strategy === "wrap") {
21
- const wrapped = await wrapSkillMarkdown(node_path_1.default.join(outputDir, "SKILL.md"), options.canonicalName, options.manifestSource, options.resolved);
21
+ const wrapped = await wrapSkillMarkdown(node_path_1.default.join(outputDir, "SKILL.md"), options.canonicalName);
22
22
  await (0, promises_1.writeFile)(node_path_1.default.join(outputDir, "SKILL.md"), wrapped);
23
23
  }
24
24
  else if (!(await (0, fs_1.pathExists)(node_path_1.default.join(outputDir, "SKILL.md")))) {
@@ -26,9 +26,8 @@ async function materializeSkill(options) {
26
26
  }
27
27
  return outputDir;
28
28
  }
29
- async function wrapSkillMarkdown(skillMdPath, canonicalName, manifestSource, resolved) {
29
+ async function wrapSkillMarkdown(skillMdPath, canonicalName) {
30
30
  const raw = await (0, promises_1.readFile)(skillMdPath, "utf8");
31
- const provenanceComment = `\n\n<!-- Generated by skm from ${manifestSource} @ ${resolved} -->\n`;
32
31
  if (!raw.startsWith("---\n")) {
33
32
  return [
34
33
  "---",
@@ -37,13 +36,12 @@ async function wrapSkillMarkdown(skillMdPath, canonicalName, manifestSource, res
37
36
  "---",
38
37
  "",
39
38
  raw.trimEnd(),
40
- provenanceComment.trimEnd(),
41
39
  "",
42
40
  ].join("\n");
43
41
  }
44
42
  const endIndex = raw.indexOf("\n---", 4);
45
43
  if (endIndex === -1) {
46
- return `${raw.trimEnd()}${provenanceComment}`;
44
+ return `${raw.trimEnd()}\n`;
47
45
  }
48
46
  const frontmatter = raw.slice(4, endIndex).split("\n");
49
47
  const body = raw.slice(endIndex + 5).replace(/^\n/, "");
@@ -58,13 +56,5 @@ async function wrapSkillMarkdown(skillMdPath, canonicalName, manifestSource, res
58
56
  if (!replacedName) {
59
57
  nextFrontmatter.unshift(`name: ${canonicalName}`);
60
58
  }
61
- return [
62
- "---",
63
- ...nextFrontmatter,
64
- "---",
65
- "",
66
- body.trimEnd(),
67
- provenanceComment.trimEnd(),
68
- "",
69
- ].join("\n");
59
+ return ["---", ...nextFrontmatter, "---", "", body.trimEnd(), ""].join("\n");
70
60
  }
@@ -28,5 +28,7 @@ function renderCliResultAsText(result) {
28
28
  }
29
29
  return `${lines.join("\n")}\n`;
30
30
  }
31
+ case "version":
32
+ return `${result.version}\n`;
31
33
  }
32
34
  }
@@ -25,6 +25,8 @@ function createResultView(ink, result) {
25
25
  return createInspectView(ink, result);
26
26
  case "help":
27
27
  return createHelpView(ink, result);
28
+ case "version":
29
+ return createVersionView(ink, result);
28
30
  }
29
31
  }
30
32
  function createSummaryView(ink, result) {
@@ -59,6 +61,10 @@ function createHelpView(ink, result) {
59
61
  ...section.lines.map((line, lineIndex) => react_1.default.createElement(Text, { key: `section-line-${index}-${lineIndex}` }, line)),
60
62
  ]));
61
63
  }
64
+ function createVersionView(ink, result) {
65
+ const { Box, Text } = ink;
66
+ return react_1.default.createElement(Box, { flexDirection: "column" }, react_1.default.createElement(Text, { color: "green", bold: true }, "skm"), react_1.default.createElement(Text, null, result.version));
67
+ }
62
68
  function createSkillSummary(ink, skill, index) {
63
69
  const { Box, Text } = ink;
64
70
  return react_1.default.createElement(Box, { key: `skill-${index}`, flexDirection: "column", marginLeft: 2 }, react_1.default.createElement(Text, { bold: true }, `${skill.name}${skill.status ? ` (${skill.status})` : ""}`), ...(skill.previousName
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stefafafan/skm",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "description": "A package manager for AI Agent Skills. Supports installation, version management, and renaming of skills. Can be used for both global and project specific skill management.",
6
6
  "keywords": [