@unityclaw/skills 1.0.2 → 1.0.3

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.
@@ -1,43 +1,51 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
1
  // src/index.ts
9
2
  import { spawn } from "child_process";
10
3
  import { cp, mkdir, readdir, readFile } from "fs/promises";
11
4
  import { existsSync, readdirSync } from "fs";
12
5
  import path from "path";
6
+ import { fileURLToPath } from "url";
13
7
  function getSkillsDir() {
14
- let currentDir;
15
- try {
16
- if (typeof import.meta !== "undefined" && import.meta.url) {
17
- const { fileURLToPath } = __require("url");
18
- currentDir = path.dirname(fileURLToPath(import.meta.url));
19
- } else if (typeof __dirname !== "undefined") {
20
- currentDir = __dirname;
21
- } else {
22
- currentDir = process.cwd();
23
- }
24
- } catch {
25
- currentDir = process.cwd();
26
- }
27
- let searchDir = currentDir;
28
- const root = path.parse(searchDir).root;
29
- while (searchDir !== root) {
8
+ const hasSkillDirs = (dir) => {
30
9
  try {
31
- const entries = readdirSync(searchDir);
32
- const hasSkills = entries.some((e) => /^unityclaw-/.test(e) || /^unityclaw-/.test(e));
33
- if (hasSkills) {
10
+ const entries = readdirSync(dir);
11
+ return entries.some((entry) => {
12
+ if (!/^unityclaw-/.test(entry)) return false;
13
+ return existsSync(path.join(dir, entry, "SKILL.md"));
14
+ });
15
+ } catch {
16
+ return false;
17
+ }
18
+ };
19
+ const findSkillsRoot = (startDir, maxDepth) => {
20
+ let searchDir = startDir;
21
+ let depth = 0;
22
+ while (depth < maxDepth) {
23
+ if (hasSkillDirs(searchDir)) {
34
24
  return searchDir;
35
25
  }
36
- } catch {
26
+ const parentDir = path.dirname(searchDir);
27
+ if (parentDir === searchDir) break;
28
+ searchDir = parentDir;
29
+ depth++;
30
+ }
31
+ return null;
32
+ };
33
+ let moduleDir = null;
34
+ try {
35
+ if (typeof __dirname !== "undefined") {
36
+ moduleDir = __dirname;
37
+ } else if (import.meta.url) {
38
+ moduleDir = path.dirname(fileURLToPath(import.meta.url));
37
39
  }
38
- searchDir = path.dirname(searchDir);
40
+ } catch {
41
+ }
42
+ if (moduleDir) {
43
+ const fromModuleDir = findSkillsRoot(moduleDir, 8);
44
+ if (fromModuleDir) return fromModuleDir;
39
45
  }
40
- return path.dirname(currentDir);
46
+ const fromCwd = findSkillsRoot(process.cwd(), 10);
47
+ if (fromCwd) return fromCwd;
48
+ return moduleDir ? path.dirname(moduleDir) : process.cwd();
41
49
  }
42
50
  async function parseSkill(skillPath) {
43
51
  try {
@@ -75,7 +83,7 @@ async function listSkills() {
75
83
  const entries = await readdir(skillsDir, { withFileTypes: true });
76
84
  for (const entry of entries) {
77
85
  if (!entry.isDirectory()) continue;
78
- if (!entry.name.startsWith("unityclaw-") && !entry.name.startsWith("unityclaw-")) continue;
86
+ if (!entry.name.startsWith("unityclaw-")) continue;
79
87
  if (entry.name === "src" || entry.name === "dist" || entry.name === "node_modules") continue;
80
88
  const skillFile = path.join(skillsDir, entry.name, "SKILL.md");
81
89
  if (existsSync(skillFile)) {
package/dist/cli.cjs CHANGED
@@ -32,35 +32,50 @@ var import_child_process = require("child_process");
32
32
  var import_promises = require("fs/promises");
33
33
  var import_fs = require("fs");
34
34
  var import_path = __toESM(require("path"), 1);
35
+ var import_url = require("url");
35
36
  var import_meta = {};
36
37
  function getSkillsDir() {
37
- let currentDir;
38
- try {
39
- if (typeof import_meta !== "undefined" && import_meta.url) {
40
- const { fileURLToPath } = require("url");
41
- currentDir = import_path.default.dirname(fileURLToPath(import_meta.url));
42
- } else if (typeof __dirname !== "undefined") {
43
- currentDir = __dirname;
44
- } else {
45
- currentDir = process.cwd();
46
- }
47
- } catch {
48
- currentDir = process.cwd();
49
- }
50
- let searchDir = currentDir;
51
- const root = import_path.default.parse(searchDir).root;
52
- while (searchDir !== root) {
38
+ const hasSkillDirs = (dir) => {
53
39
  try {
54
- const entries = (0, import_fs.readdirSync)(searchDir);
55
- const hasSkills = entries.some((e) => /^unityclaw-/.test(e) || /^unityclaw-/.test(e));
56
- if (hasSkills) {
40
+ const entries = (0, import_fs.readdirSync)(dir);
41
+ return entries.some((entry) => {
42
+ if (!/^unityclaw-/.test(entry)) return false;
43
+ return (0, import_fs.existsSync)(import_path.default.join(dir, entry, "SKILL.md"));
44
+ });
45
+ } catch {
46
+ return false;
47
+ }
48
+ };
49
+ const findSkillsRoot = (startDir, maxDepth) => {
50
+ let searchDir = startDir;
51
+ let depth = 0;
52
+ while (depth < maxDepth) {
53
+ if (hasSkillDirs(searchDir)) {
57
54
  return searchDir;
58
55
  }
59
- } catch {
56
+ const parentDir = import_path.default.dirname(searchDir);
57
+ if (parentDir === searchDir) break;
58
+ searchDir = parentDir;
59
+ depth++;
60
+ }
61
+ return null;
62
+ };
63
+ let moduleDir = null;
64
+ try {
65
+ if (typeof __dirname !== "undefined") {
66
+ moduleDir = __dirname;
67
+ } else if (import_meta.url) {
68
+ moduleDir = import_path.default.dirname((0, import_url.fileURLToPath)(import_meta.url));
60
69
  }
61
- searchDir = import_path.default.dirname(searchDir);
70
+ } catch {
71
+ }
72
+ if (moduleDir) {
73
+ const fromModuleDir = findSkillsRoot(moduleDir, 8);
74
+ if (fromModuleDir) return fromModuleDir;
62
75
  }
63
- return import_path.default.dirname(currentDir);
76
+ const fromCwd = findSkillsRoot(process.cwd(), 10);
77
+ if (fromCwd) return fromCwd;
78
+ return moduleDir ? import_path.default.dirname(moduleDir) : process.cwd();
64
79
  }
65
80
  async function parseSkill(skillPath) {
66
81
  try {
@@ -98,7 +113,7 @@ async function listSkills() {
98
113
  const entries = await (0, import_promises.readdir)(skillsDir, { withFileTypes: true });
99
114
  for (const entry of entries) {
100
115
  if (!entry.isDirectory()) continue;
101
- if (!entry.name.startsWith("unityclaw-") && !entry.name.startsWith("unityclaw-")) continue;
116
+ if (!entry.name.startsWith("unityclaw-")) continue;
102
117
  if (entry.name === "src" || entry.name === "dist" || entry.name === "node_modules") continue;
103
118
  const skillFile = import_path.default.join(skillsDir, entry.name, "SKILL.md");
104
119
  if ((0, import_fs.existsSync)(skillFile)) {
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  executeSkill,
4
4
  installSkills,
5
5
  listSkills
6
- } from "./chunk-4GBZWV4P.js";
6
+ } from "./chunk-FAGVVFFQ.js";
7
7
 
8
8
  // src/cli.ts
9
9
  import { program } from "commander";
package/dist/index.cjs CHANGED
@@ -43,35 +43,50 @@ var import_child_process = require("child_process");
43
43
  var import_promises = require("fs/promises");
44
44
  var import_fs = require("fs");
45
45
  var import_path = __toESM(require("path"), 1);
46
+ var import_url = require("url");
46
47
  var import_meta = {};
47
48
  function getSkillsDir() {
48
- let currentDir;
49
- try {
50
- if (typeof import_meta !== "undefined" && import_meta.url) {
51
- const { fileURLToPath } = require("url");
52
- currentDir = import_path.default.dirname(fileURLToPath(import_meta.url));
53
- } else if (typeof __dirname !== "undefined") {
54
- currentDir = __dirname;
55
- } else {
56
- currentDir = process.cwd();
57
- }
58
- } catch {
59
- currentDir = process.cwd();
60
- }
61
- let searchDir = currentDir;
62
- const root = import_path.default.parse(searchDir).root;
63
- while (searchDir !== root) {
49
+ const hasSkillDirs = (dir) => {
64
50
  try {
65
- const entries = (0, import_fs.readdirSync)(searchDir);
66
- const hasSkills = entries.some((e) => /^unityclaw-/.test(e) || /^unityclaw-/.test(e));
67
- if (hasSkills) {
51
+ const entries = (0, import_fs.readdirSync)(dir);
52
+ return entries.some((entry) => {
53
+ if (!/^unityclaw-/.test(entry)) return false;
54
+ return (0, import_fs.existsSync)(import_path.default.join(dir, entry, "SKILL.md"));
55
+ });
56
+ } catch {
57
+ return false;
58
+ }
59
+ };
60
+ const findSkillsRoot = (startDir, maxDepth) => {
61
+ let searchDir = startDir;
62
+ let depth = 0;
63
+ while (depth < maxDepth) {
64
+ if (hasSkillDirs(searchDir)) {
68
65
  return searchDir;
69
66
  }
70
- } catch {
67
+ const parentDir = import_path.default.dirname(searchDir);
68
+ if (parentDir === searchDir) break;
69
+ searchDir = parentDir;
70
+ depth++;
71
+ }
72
+ return null;
73
+ };
74
+ let moduleDir = null;
75
+ try {
76
+ if (typeof __dirname !== "undefined") {
77
+ moduleDir = __dirname;
78
+ } else if (import_meta.url) {
79
+ moduleDir = import_path.default.dirname((0, import_url.fileURLToPath)(import_meta.url));
71
80
  }
72
- searchDir = import_path.default.dirname(searchDir);
81
+ } catch {
82
+ }
83
+ if (moduleDir) {
84
+ const fromModuleDir = findSkillsRoot(moduleDir, 8);
85
+ if (fromModuleDir) return fromModuleDir;
73
86
  }
74
- return import_path.default.dirname(currentDir);
87
+ const fromCwd = findSkillsRoot(process.cwd(), 10);
88
+ if (fromCwd) return fromCwd;
89
+ return moduleDir ? import_path.default.dirname(moduleDir) : process.cwd();
75
90
  }
76
91
  async function parseSkill(skillPath) {
77
92
  try {
@@ -109,7 +124,7 @@ async function listSkills() {
109
124
  const entries = await (0, import_promises.readdir)(skillsDir, { withFileTypes: true });
110
125
  for (const entry of entries) {
111
126
  if (!entry.isDirectory()) continue;
112
- if (!entry.name.startsWith("unityclaw-") && !entry.name.startsWith("unityclaw-")) continue;
127
+ if (!entry.name.startsWith("unityclaw-")) continue;
113
128
  if (entry.name === "src" || entry.name === "dist" || entry.name === "node_modules") continue;
114
129
  const skillFile = import_path.default.join(skillsDir, entry.name, "SKILL.md");
115
130
  if ((0, import_fs.existsSync)(skillFile)) {
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  installSkills,
7
7
  listSkills,
8
8
  parseSkill
9
- } from "./chunk-4GBZWV4P.js";
9
+ } from "./chunk-FAGVVFFQ.js";
10
10
  export {
11
11
  executeSkill,
12
12
  getClaudeSkillsDir,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unityclaw/skills",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "UnityClaw Skills - Claude Code and OpenClaw skill definitions for AI-powered image/video generation, media analysis, and more",
5
5
  "type": "module",
6
6
  "bin": {