@rrskill/cli 0.1.4 → 0.1.6

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/index.js CHANGED
@@ -1,182 +1,212 @@
1
- import * as l from "node:path";
1
+ import * as c from "node:path";
2
2
  import * as u from "node:fs/promises";
3
- import { fileURLToPath as _, pathToFileURL as kt } from "node:url";
4
- import { readFileSync as wt } from "node:fs";
5
- import { createHash as yt } from "node:crypto";
6
- import * as Q from "node:os";
7
- import * as vt from "node:zlib";
8
- import { promisify as St } from "node:util";
9
- const X = ["search", "install", "list", "upgrade", "bootstrap", "doctor", "version"], Y = new Set(X), Dt = "--host", xt = "--output", jt = /* @__PURE__ */ new Set([Dt, xt]), Ct = /* @__PURE__ */ new Set(["--openclaw", "--codex", "--claude-code"]);
10
- function tt(t) {
11
- const s = [];
12
- for (let e = 0; e < t.length; e += 1) {
13
- const r = t[e];
3
+ import { fileURLToPath as O, pathToFileURL as ks } from "node:url";
4
+ import { readFileSync as ws } from "node:fs";
5
+ import { createHash as ys } from "node:crypto";
6
+ import * as ss from "node:os";
7
+ import * as vs from "node:zlib";
8
+ import { promisify as Ss } from "node:util";
9
+ const ts = ["search", "install", "list", "upgrade", "bootstrap", "doctor", "version"], es = new Set(ts), Ds = "--host", _s = "--output", Cs = /* @__PURE__ */ new Set([Ds, _s]), js = /* @__PURE__ */ new Set(["--openclaw", "--codex", "--claude-code"]);
10
+ function rs(s) {
11
+ const t = [];
12
+ for (let e = 0; e < s.length; e += 1) {
13
+ const r = s[e];
14
14
  if (r) {
15
- if (jt.has(r)) {
16
- const i = t[e + 1];
17
- i && !i.startsWith("--") && !Y.has(i) && (e += 1);
15
+ if (Cs.has(r)) {
16
+ const i = s[e + 1];
17
+ i && !i.startsWith("--") && !es.has(i) && (e += 1);
18
18
  continue;
19
19
  }
20
- Ct.has(r) || r.startsWith("--") || s.push(r);
20
+ js.has(r) || r.startsWith("--") || t.push(r);
21
21
  }
22
22
  }
23
- return s;
23
+ return t;
24
24
  }
25
- function Et(t) {
26
- const s = tt(t), e = s[0] ?? "";
27
- return e ? e === "help" ? { command: "help" } : Y.has(e) ? { command: e } : s.length === 1 ? { command: "install", slug: e } : { command: "unknown", input: e } : { command: "help" };
25
+ function Es(s) {
26
+ const t = rs(s), e = t[0] ?? "";
27
+ return e ? e === "help" ? { command: "help" } : es.has(e) ? { command: e } : t.length === 1 ? { command: "install", slug: e } : { command: "unknown", input: e } : { command: "help" };
28
28
  }
29
- async function b(t) {
30
- const s = t.fsImpl ?? u;
29
+ async function U(s) {
30
+ const t = s.fsImpl ?? u;
31
31
  try {
32
- return (await s.stat(t.path)).isFile();
32
+ return (await t.stat(s.path)).isFile();
33
33
  } catch {
34
34
  return !1;
35
35
  }
36
36
  }
37
- async function _t(t) {
38
- const s = t.fsImpl ?? u;
37
+ async function xs(s) {
38
+ const t = s.fsImpl ?? u;
39
39
  let e;
40
40
  try {
41
- e = await s.readFile(t.path, "utf8");
41
+ e = await t.readFile(s.path, "utf8");
42
42
  } catch {
43
- return { ok: !1, issue: { code: "missing_host_config", path: t.path } };
43
+ return { ok: !1, issue: { code: "missing_host_config", path: s.path } };
44
44
  }
45
45
  try {
46
46
  const r = JSON.parse(e);
47
47
  return r && typeof r == "object" && !Array.isArray(r) ? { ok: !0, value: r } : {
48
48
  ok: !1,
49
- issue: { code: "invalid_host_config_json", path: t.path, error: "root is not a JSON object" }
49
+ issue: { code: "invalid_host_config_json", path: s.path, error: "root is not a JSON object" }
50
50
  };
51
51
  } catch (r) {
52
52
  return {
53
53
  ok: !1,
54
- issue: { code: "invalid_host_config_json", path: t.path, error: r instanceof Error ? r.message : String(r) }
54
+ issue: { code: "invalid_host_config_json", path: s.path, error: r instanceof Error ? r.message : String(r) }
55
55
  };
56
56
  }
57
57
  }
58
- function B(t, s) {
59
- let e = t;
60
- for (const r of s) {
58
+ function v(s, t) {
59
+ let e = s;
60
+ for (const r of t) {
61
61
  if (!e || typeof e != "object")
62
62
  return;
63
63
  e = e[r];
64
64
  }
65
65
  return e;
66
66
  }
67
- async function st(t, s = {}) {
68
- const e = s.fs ?? u, r = [], i = ["find-skills", "rrskill-preference"];
69
- for (const f of i) {
70
- const d = l.join(t.skillsDir, f, "SKILL.md");
71
- await b({ fsImpl: e, path: d }) || r.push({ code: "missing_builtin_skill", slug: f, path: d });
67
+ function Ls(s, t) {
68
+ return Array.isArray(s) && s.some((e) => e === t);
69
+ }
70
+ async function is(s, t = {}) {
71
+ const e = t.fs ?? u, r = [], i = ["find-skills", "rrskill-preference"];
72
+ for (const m of i) {
73
+ const g = c.join(s.skillsDir, m, "SKILL.md");
74
+ await U({ fsImpl: e, path: g }) || r.push({ code: "missing_builtin_skill", slug: m, path: g });
72
75
  }
73
- if (t.host !== "openclaw")
74
- return r.push({ code: "unsupported_host_bootstrap", host: t.host }), { ok: !1, issues: r };
75
- const o = l.join(t.pluginDir, "index.ts"), n = l.join(t.pluginDir, "openclaw.plugin.json");
76
- await b({ fsImpl: e, path: o }) || r.push({ code: "missing_plugin_file", path: o }), await b({ fsImpl: e, path: n }) || r.push({ code: "missing_plugin_file", path: n });
77
- const c = await _t({ fsImpl: e, path: t.hostConfigPath });
78
- if (!c.ok)
79
- return r.push(c.issue), { ok: !1, issues: r };
80
- const a = B(c.value, ["plugins", "entries", "rrskill"]);
81
- if (!a || typeof a != "object")
82
- r.push({ code: "missing_host_plugin_entry", path: t.hostConfigPath });
76
+ if (s.host !== "openclaw")
77
+ return r.push({ code: "unsupported_host_bootstrap", host: s.host }), { ok: !1, issues: r };
78
+ const n = c.join(s.pluginDir, "index.ts"), o = c.join(s.pluginDir, "openclaw.plugin.json");
79
+ await U({ fsImpl: e, path: n }) || r.push({ code: "missing_plugin_file", path: n }), await U({ fsImpl: e, path: o }) || r.push({ code: "missing_plugin_file", path: o });
80
+ const l = await xs({ fsImpl: e, path: s.hostConfigPath });
81
+ if (!l.ok)
82
+ return r.push(l.issue), { ok: !1, issues: r };
83
+ const a = v(l.value, ["plugins", "entries", "rrskill"]), f = v(l.value, ["plugins", "allow"]), d = v(l.value, ["plugins", "installs", "rrskill", "source"]), p = v(l.value, ["plugins", "installs", "rrskill", "sourcePath"]), C = v(l.value, ["plugins", "installs", "rrskill", "installPath"]);
84
+ if (Ls(f, "rrskill") || r.push({
85
+ code: "host_plugin_policy_mismatch",
86
+ path: s.hostConfigPath,
87
+ key: "plugins.allow",
88
+ expected: 'array containing "rrskill"',
89
+ actual: f
90
+ }), d !== "path" && r.push({
91
+ code: "host_plugin_policy_mismatch",
92
+ path: s.hostConfigPath,
93
+ key: "plugins.installs.rrskill.source",
94
+ expected: "path",
95
+ actual: d
96
+ }), p !== s.pluginDir && r.push({
97
+ code: "host_plugin_policy_mismatch",
98
+ path: s.hostConfigPath,
99
+ key: "plugins.installs.rrskill.sourcePath",
100
+ expected: s.pluginDir,
101
+ actual: p
102
+ }), C !== s.pluginDir && r.push({
103
+ code: "host_plugin_policy_mismatch",
104
+ path: s.hostConfigPath,
105
+ key: "plugins.installs.rrskill.installPath",
106
+ expected: s.pluginDir,
107
+ actual: C
108
+ }), !a || typeof a != "object")
109
+ r.push({ code: "missing_host_plugin_entry", path: s.hostConfigPath });
83
110
  else {
84
- const f = [
111
+ const m = [
85
112
  { key: ["plugins", "entries", "rrskill", "enabled"], expected: !0 },
86
113
  { key: ["plugins", "entries", "rrskill", "config", "primaryCli"], expected: "rrskill" },
87
114
  { key: ["plugins", "entries", "rrskill", "config", "primaryLabel"], expected: "official-registry" }
88
115
  ];
89
- for (const d of f) {
90
- const h = B(c.value, d.key);
91
- h !== d.expected && r.push({
116
+ for (const g of m) {
117
+ const j = v(l.value, g.key);
118
+ j !== g.expected && r.push({
92
119
  code: "host_plugin_policy_mismatch",
93
- path: t.hostConfigPath,
94
- key: d.key.join("."),
95
- expected: d.expected,
96
- actual: h
120
+ path: s.hostConfigPath,
121
+ key: g.key.join("."),
122
+ expected: g.expected,
123
+ actual: j
97
124
  });
98
125
  }
99
126
  }
100
127
  return { ok: r.length === 0, issues: r };
101
128
  }
102
- function O(t, s) {
103
- const e = l.dirname(_(t));
129
+ function T(s, t) {
130
+ const e = c.dirname(O(s));
104
131
  return [
105
- l.resolve(e, "..", "assets", "builtins", s),
106
- l.resolve(e, "..", "..", "assets", "builtins", s)
132
+ c.resolve(e, "..", "assets", "builtins", t),
133
+ c.resolve(e, "..", "..", "assets", "builtins", t)
107
134
  ];
108
135
  }
109
- async function P(t) {
110
- const s = t.fsImpl ?? u;
136
+ async function F(s) {
137
+ const t = s.fsImpl ?? u;
111
138
  let e;
112
- for (const r of t.candidates)
139
+ for (const r of s.candidates)
113
140
  try {
114
- return await s.readFile(r, "utf8");
141
+ return await t.readFile(r, "utf8");
115
142
  } catch (i) {
116
143
  e = i;
117
144
  }
118
- throw new Error(`Failed to load ${t.assetLabel} from candidates: ${t.candidates.join(", ")} (${String(e)})`);
145
+ throw new Error(`Failed to load ${s.assetLabel} from candidates: ${s.candidates.join(", ")} (${String(e)})`);
119
146
  }
120
- async function U(t) {
121
- const s = t.fsImpl ?? u, e = t.content.endsWith(`
122
- `) ? t.content : `${t.content}
147
+ async function N(s) {
148
+ const t = s.fsImpl ?? u, e = s.content.endsWith(`
149
+ `) ? s.content : `${s.content}
123
150
  `;
124
151
  try {
125
- if (await s.readFile(t.path, "utf8") === e)
152
+ if (await t.readFile(s.path, "utf8") === e)
126
153
  return !1;
127
154
  } catch {
128
155
  }
129
- return await s.mkdir(l.dirname(t.path), { recursive: !0 }), await s.writeFile(t.path, e, "utf8"), !0;
156
+ return await t.mkdir(c.dirname(s.path), { recursive: !0 }), await t.writeFile(s.path, e, "utf8"), !0;
130
157
  }
131
- const q = ["find-skills", "rrskill-preference"];
132
- function Lt(t) {
133
- return t === "find-skills" ? "skills/find-skills.md" : "skills/rrskill-preference.md";
158
+ const V = ["find-skills", "rrskill-preference"];
159
+ function bs(s) {
160
+ return s === "find-skills" ? "skills/find-skills.md" : "skills/rrskill-preference.md";
134
161
  }
135
- async function bt(t, s = {}) {
136
- const e = s.fs ?? u;
162
+ async function Is(s, t = {}) {
163
+ const e = t.fs ?? u;
137
164
  let r = !1;
138
- for (const i of q) {
139
- const o = await P({
140
- candidates: O(import.meta.url, Lt(i)),
165
+ for (const i of V) {
166
+ const n = await F({
167
+ candidates: T(import.meta.url, bs(i)),
141
168
  fsImpl: e,
142
169
  assetLabel: "built-in skill asset"
143
- }), n = l.join(t.skillsDir, i, "SKILL.md"), c = await U({ path: n, content: o, fsImpl: e });
144
- r = r || c;
170
+ }), o = c.join(s.skillsDir, i, "SKILL.md"), l = await N({ path: o, content: n, fsImpl: e });
171
+ r = r || l;
145
172
  }
146
- return { installed: [...q], changed: r };
173
+ return { installed: [...V], changed: r };
147
174
  }
148
- async function $t(t, s = {}) {
149
- const e = s.fs ?? u;
150
- if (t.host !== "openclaw")
175
+ async function $s(s, t = {}) {
176
+ const e = t.fs ?? u;
177
+ if (s.host !== "openclaw")
151
178
  return { installed: !1, changed: !1 };
152
- const r = await P({
153
- candidates: O(import.meta.url, "plugins/openclaw/index.ts"),
179
+ const r = await F({
180
+ candidates: T(import.meta.url, "plugins/openclaw/index.ts"),
154
181
  fsImpl: e,
155
182
  assetLabel: "built-in plugin asset"
156
- }), i = await P({
157
- candidates: O(import.meta.url, "plugins/openclaw/openclaw.plugin.json"),
183
+ }), i = await F({
184
+ candidates: T(import.meta.url, "plugins/openclaw/openclaw.plugin.json"),
158
185
  fsImpl: e,
159
186
  assetLabel: "built-in plugin asset"
160
- }), o = l.join(t.pluginDir, "index.ts"), n = l.join(t.pluginDir, "openclaw.plugin.json"), c = await U({ path: o, content: r, fsImpl: e }), a = await U({ path: n, content: i, fsImpl: e });
161
- return { installed: !0, changed: c || a };
187
+ }), n = c.join(s.pluginDir, "index.ts"), o = c.join(s.pluginDir, "openclaw.plugin.json"), l = await N({ path: n, content: r, fsImpl: e }), a = await N({ path: o, content: i, fsImpl: e });
188
+ return { installed: !0, changed: l || a };
162
189
  }
163
- function et(t) {
164
- return !!t && typeof t == "object" && !Array.isArray(t);
190
+ function ns(s) {
191
+ return !!s && typeof s == "object" && !Array.isArray(s);
165
192
  }
166
- function x(t, s) {
167
- const e = t[s];
168
- if (et(e))
193
+ function S(s, t) {
194
+ const e = s[t];
195
+ if (ns(e))
169
196
  return e;
170
197
  const r = {};
171
- return t[s] = r, r;
198
+ return s[t] = r, r;
199
+ }
200
+ function Os(s) {
201
+ return Array.isArray(s) ? s.filter((t) => typeof t == "string") : [];
172
202
  }
173
- async function It(t) {
174
- const s = t.fsImpl ?? u;
203
+ async function Ps(s) {
204
+ const t = s.fsImpl ?? u;
175
205
  try {
176
- const e = await s.readFile(t.path, "utf8");
206
+ const e = await t.readFile(s.path, "utf8");
177
207
  try {
178
208
  const r = JSON.parse(e);
179
- return et(r) ? { object: r, exists: !0, parseOk: !0, rawText: e } : { object: {}, exists: !0, parseOk: !1, rawText: e, parseError: "root is not a JSON object" };
209
+ return ns(r) ? { object: r, exists: !0, parseOk: !0, rawText: e } : { object: {}, exists: !0, parseOk: !1, rawText: e, parseError: "root is not a JSON object" };
180
210
  } catch (r) {
181
211
  return {
182
212
  object: {},
@@ -190,60 +220,64 @@ async function It(t) {
190
220
  return { object: {}, exists: !1, parseOk: !1 };
191
221
  }
192
222
  }
193
- async function Ot(t) {
194
- const s = t.fsImpl ?? u, e = `${JSON.stringify(t.value, null, 2)}
223
+ async function Us(s) {
224
+ const t = s.fsImpl ?? u, e = `${JSON.stringify(s.value, null, 2)}
195
225
  `;
196
- return t.prevRawText !== void 0 && t.prevRawText === e ? !1 : (await s.mkdir(l.dirname(t.path), { recursive: !0 }), await s.writeFile(t.path, e, "utf8"), !0);
226
+ return s.prevRawText !== void 0 && s.prevRawText === e ? !1 : (await t.mkdir(c.dirname(s.path), { recursive: !0 }), await t.writeFile(s.path, e, "utf8"), !0);
197
227
  }
198
- async function Pt(t) {
199
- const s = t.fsImpl ?? u, e = await It({ fsImpl: s, path: t.hostConfigPath });
228
+ async function As(s) {
229
+ const t = s.fsImpl ?? u, e = await Ps({ fsImpl: t, path: s.hostConfigPath });
200
230
  if (e.exists && !e.parseOk)
201
231
  throw new Error(
202
- `Invalid OpenClaw config JSON at ${t.hostConfigPath}: ${e.parseError ?? "unknown parse error"}`
232
+ `Invalid OpenClaw config JSON at ${s.hostConfigPath}: ${e.parseError ?? "unknown parse error"}`
203
233
  );
204
- const r = e.object, i = x(r, "plugins"), o = x(i, "entries"), n = x(o, "rrskill"), c = x(n, "config");
205
- let a = !e.exists || !e.parseOk;
206
- return n.enabled !== !0 && (n.enabled = !0, a = !0), c.primaryCli !== "rrskill" && (c.primaryCli = "rrskill", a = !0), c.primaryLabel !== "official-registry" && (c.primaryLabel = "official-registry", a = !0), a ? Ot({
207
- fsImpl: s,
208
- path: t.hostConfigPath,
234
+ const r = e.object, i = S(r, "plugins"), n = Os(i.allow), o = S(i, "installs"), l = S(o, "rrskill"), a = S(i, "entries"), f = S(a, "rrskill"), d = S(f, "config");
235
+ let p = !e.exists || !e.parseOk;
236
+ return n.includes("rrskill") ? i.allow !== n && (i.allow = n, p = !0) : (i.allow = [...n, "rrskill"], p = !0), l.source !== "path" && (l.source = "path", p = !0), l.sourcePath !== s.pluginDir && (l.sourcePath = s.pluginDir, p = !0), l.installPath !== s.pluginDir && (l.installPath = s.pluginDir, p = !0), f.enabled !== !0 && (f.enabled = !0, p = !0), d.primaryCli !== "rrskill" && (d.primaryCli = "rrskill", p = !0), d.primaryLabel !== "official-registry" && (d.primaryLabel = "official-registry", p = !0), p ? Us({
237
+ fsImpl: t,
238
+ path: s.hostConfigPath,
209
239
  value: r,
210
240
  prevRawText: e.rawText
211
241
  }) : !1;
212
242
  }
213
- async function Ut(t, s = {}) {
214
- const e = s.fs ?? u, r = await bt({ skillsDir: t.skillsDir }, { fs: e }), i = await $t({ host: t.host, pluginDir: t.pluginDir }, { fs: e });
215
- let o = !1;
216
- return t.host === "openclaw" && (o = await Pt({ fsImpl: e, hostConfigPath: t.hostConfigPath })), {
243
+ async function Rs(s, t = {}) {
244
+ const e = t.fs ?? u, r = await Is({ skillsDir: s.skillsDir }, { fs: e }), i = await $s({ host: s.host, pluginDir: s.pluginDir }, { fs: e });
245
+ let n = !1;
246
+ return s.host === "openclaw" && (n = await As({
247
+ fsImpl: e,
248
+ hostConfigPath: s.hostConfigPath,
249
+ pluginDir: s.pluginDir
250
+ })), {
217
251
  builtinsInstalled: r.installed,
218
252
  pluginInstalled: i.installed,
219
- hostConfigRepaired: o
253
+ hostConfigRepaired: n
220
254
  };
221
255
  }
222
- async function R(t, s = {}) {
223
- if (t.host !== "openclaw")
256
+ async function H(s, t = {}) {
257
+ if (s.host !== "openclaw")
224
258
  return {
225
259
  builtinsInstalled: [],
226
260
  pluginInstalled: !1,
227
261
  hostConfigRepaired: !1,
228
262
  verification: {
229
263
  ok: !1,
230
- issues: [{ code: "unsupported_host_bootstrap", host: t.host }]
264
+ issues: [{ code: "unsupported_host_bootstrap", host: s.host }]
231
265
  }
232
266
  };
233
- const e = s.fs ?? u, r = await Ut(
267
+ const e = t.fs ?? u, r = await Rs(
234
268
  {
235
- host: t.host,
236
- skillsDir: t.skillsDir,
237
- pluginDir: t.pluginDir,
238
- hostConfigPath: t.hostConfigPath
269
+ host: s.host,
270
+ skillsDir: s.skillsDir,
271
+ pluginDir: s.pluginDir,
272
+ hostConfigPath: s.hostConfigPath
239
273
  },
240
274
  { fs: e }
241
- ), i = await st(
275
+ ), i = await is(
242
276
  {
243
- host: t.host,
244
- skillsDir: t.skillsDir,
245
- pluginDir: t.pluginDir,
246
- hostConfigPath: t.hostConfigPath
277
+ host: s.host,
278
+ skillsDir: s.skillsDir,
279
+ pluginDir: s.pluginDir,
280
+ hostConfigPath: s.hostConfigPath
247
281
  },
248
282
  { fs: e }
249
283
  );
@@ -254,49 +288,49 @@ async function R(t, s = {}) {
254
288
  verification: i
255
289
  };
256
290
  }
257
- function j(t, s) {
258
- const e = new Set(s.map((n) => n.code)), r = new Set(
259
- s.filter((n) => n.code === "missing_builtin_skill").map((n) => n.slug)
291
+ function b(s, t) {
292
+ const e = new Set(t.map((o) => o.code)), r = new Set(
293
+ t.filter((o) => o.code === "missing_builtin_skill").map((o) => o.slug)
260
294
  ), i = new Set(
261
- s.filter((n) => n.code === "missing_plugin_file").map((n) => n.path)
262
- ), o = s.some(
263
- (n) => [
295
+ t.filter((o) => o.code === "missing_plugin_file").map((o) => o.path)
296
+ ), n = t.some(
297
+ (o) => [
264
298
  "missing_host_config",
265
299
  "invalid_host_config_json",
266
300
  "missing_host_plugin_entry",
267
301
  "host_plugin_policy_mismatch"
268
- ].includes(n.code)
302
+ ].includes(o.code)
269
303
  );
270
304
  return [
271
305
  {
272
306
  name: "builtin_find-skills",
273
307
  ok: !r.has("find-skills"),
274
308
  message: r.has("find-skills") ? "missing built-in skill" : "built-in skill installed",
275
- path: l.join(t.skillsDir, "find-skills", "SKILL.md")
309
+ path: c.join(s.skillsDir, "find-skills", "SKILL.md")
276
310
  },
277
311
  {
278
312
  name: "builtin_rrskill-preference",
279
313
  ok: !r.has("rrskill-preference"),
280
314
  message: r.has("rrskill-preference") ? "missing built-in skill" : "built-in skill installed",
281
- path: l.join(t.skillsDir, "rrskill-preference", "SKILL.md")
315
+ path: c.join(s.skillsDir, "rrskill-preference", "SKILL.md")
282
316
  },
283
317
  {
284
318
  name: "plugin_index",
285
- ok: !i.has(l.join(t.pluginDir, "index.ts")),
286
- message: i.has(l.join(t.pluginDir, "index.ts")) ? "missing OpenClaw plugin entry file" : "OpenClaw plugin entry file present",
287
- path: l.join(t.pluginDir, "index.ts")
319
+ ok: !i.has(c.join(s.pluginDir, "index.ts")),
320
+ message: i.has(c.join(s.pluginDir, "index.ts")) ? "missing OpenClaw plugin entry file" : "OpenClaw plugin entry file present",
321
+ path: c.join(s.pluginDir, "index.ts")
288
322
  },
289
323
  {
290
324
  name: "plugin_manifest",
291
- ok: !i.has(l.join(t.pluginDir, "openclaw.plugin.json")),
292
- message: i.has(l.join(t.pluginDir, "openclaw.plugin.json")) ? "missing OpenClaw plugin manifest" : "OpenClaw plugin manifest present",
293
- path: l.join(t.pluginDir, "openclaw.plugin.json")
325
+ ok: !i.has(c.join(s.pluginDir, "openclaw.plugin.json")),
326
+ message: i.has(c.join(s.pluginDir, "openclaw.plugin.json")) ? "missing OpenClaw plugin manifest" : "OpenClaw plugin manifest present",
327
+ path: c.join(s.pluginDir, "openclaw.plugin.json")
294
328
  },
295
329
  {
296
330
  name: "host_config",
297
- ok: !o,
298
- message: o ? "OpenClaw host config is missing or does not match rrskill policy" : "OpenClaw host config matches rrskill policy",
299
- path: t.hostConfigPath
331
+ ok: !n,
332
+ message: n ? "OpenClaw host config is missing or does not match rrskill policy" : "OpenClaw host config matches rrskill policy",
333
+ path: s.hostConfigPath
300
334
  },
301
335
  {
302
336
  name: "bootstrap_supported",
@@ -305,19 +339,19 @@ function j(t, s) {
305
339
  }
306
340
  ];
307
341
  }
308
- async function Rt(t, s = {}, e = {}) {
342
+ async function Ts(s, t = {}, e = {}) {
309
343
  const r = e.fs ?? u, i = {
310
- skillsDir: t.skillsDir,
311
- pluginDir: t.pluginDir,
312
- hostConfigPath: t.hostConfigPath
344
+ skillsDir: s.skillsDir,
345
+ pluginDir: s.pluginDir,
346
+ hostConfigPath: s.hostConfigPath
313
347
  };
314
- if (t.host !== "openclaw")
348
+ if (s.host !== "openclaw")
315
349
  return {
316
350
  ok: !0,
317
- host: t.host,
351
+ host: s.host,
318
352
  bootstrapSupported: !1,
319
353
  fixed: !1,
320
- dryRun: s.dryRun ?? !1,
354
+ dryRun: t.dryRun ?? !1,
321
355
  checks: [
322
356
  {
323
357
  name: "cli_available",
@@ -327,109 +361,109 @@ async function Rt(t, s = {}, e = {}) {
327
361
  {
328
362
  name: "bootstrap_supported",
329
363
  ok: !0,
330
- message: `${t.host} currently uses CLI-only initialization; bootstrap repair is not implemented`
364
+ message: `${s.host} currently uses CLI-only initialization; bootstrap repair is not implemented`
331
365
  }
332
366
  ],
333
367
  issues: [],
334
368
  nextCommands: ["rrskill search <query>", "rrskill install <slug>"],
335
369
  paths: i
336
370
  };
337
- const o = await st(t, {
371
+ const n = await is(s, {
338
372
  fs: r
339
373
  });
340
- if (o.ok)
374
+ if (n.ok)
341
375
  return {
342
376
  ok: !0,
343
- host: t.host,
377
+ host: s.host,
344
378
  bootstrapSupported: !0,
345
379
  fixed: !1,
346
- dryRun: s.dryRun ?? !1,
347
- checks: j(t, []),
380
+ dryRun: t.dryRun ?? !1,
381
+ checks: b(s, []),
348
382
  issues: [],
349
383
  nextCommands: [],
350
384
  paths: i,
351
- verification: o
385
+ verification: n
352
386
  };
353
- if (s.dryRun)
387
+ if (t.dryRun)
354
388
  return {
355
389
  ok: !1,
356
- host: t.host,
390
+ host: s.host,
357
391
  bootstrapSupported: !0,
358
392
  fixed: !1,
359
393
  dryRun: !0,
360
- checks: j(t, o.issues),
361
- issues: o.issues,
394
+ checks: b(s, n.issues),
395
+ issues: n.issues,
362
396
  nextCommands: ["rrskill bootstrap --host openclaw"],
363
397
  paths: i,
364
- verification: o
398
+ verification: n
365
399
  };
366
- if (s.fix) {
367
- const n = await R(t, {
400
+ if (t.fix) {
401
+ const o = await H(s, {
368
402
  fs: r
369
403
  });
370
404
  return {
371
- ok: n.verification.ok,
372
- host: t.host,
405
+ ok: o.verification.ok,
406
+ host: s.host,
373
407
  bootstrapSupported: !0,
374
408
  fixed: !0,
375
409
  dryRun: !1,
376
- checks: j(
377
- t,
378
- n.verification.ok ? [] : n.verification.issues
410
+ checks: b(
411
+ s,
412
+ o.verification.ok ? [] : o.verification.issues
379
413
  ),
380
- issues: n.verification.ok ? [] : n.verification.issues,
381
- nextCommands: n.verification.ok ? [] : ["rrskill bootstrap --host openclaw"],
414
+ issues: o.verification.ok ? [] : o.verification.issues,
415
+ nextCommands: o.verification.ok ? [] : ["rrskill bootstrap --host openclaw"],
382
416
  paths: i,
383
- verification: n.verification
417
+ verification: o.verification
384
418
  };
385
419
  }
386
420
  return {
387
421
  ok: !1,
388
- host: t.host,
422
+ host: s.host,
389
423
  bootstrapSupported: !0,
390
424
  fixed: !1,
391
425
  dryRun: !1,
392
- checks: j(t, o.issues),
393
- issues: o.issues,
426
+ checks: b(s, n.issues),
427
+ issues: n.issues,
394
428
  nextCommands: ["rrskill bootstrap --host openclaw"],
395
429
  paths: i,
396
- verification: o
430
+ verification: n
397
431
  };
398
432
  }
399
- function At(t) {
400
- return t.HOME ?? t.USERPROFILE ?? process.env.HOME ?? process.env.USERPROFILE ?? process.cwd();
433
+ function Fs(s) {
434
+ return s.HOME ?? s.USERPROFILE ?? process.env.HOME ?? process.env.USERPROFILE ?? process.cwd();
401
435
  }
402
- function K(t, s) {
403
- const e = t?.trim();
436
+ function G(s, t) {
437
+ const e = s?.trim();
404
438
  if (e)
405
- return e === "~" ? s : e.startsWith("~/") ? l.resolve(s, e.slice(2)) : l.resolve(e);
439
+ return e === "~" ? t : e.startsWith("~/") ? c.resolve(t, e.slice(2)) : c.resolve(e);
406
440
  }
407
- function $(t, s) {
408
- for (const e of s) {
409
- const r = t[e];
441
+ function A(s, t) {
442
+ for (const e of t) {
443
+ const r = s[e];
410
444
  if (typeof r == "string" && r.trim())
411
445
  return r.trim();
412
446
  }
413
447
  }
414
- function Tt(t, s) {
415
- if (typeof t != "object" || t === null || Array.isArray(t))
448
+ function Ns(s, t) {
449
+ if (typeof s != "object" || s === null || Array.isArray(s))
416
450
  throw new Error(
417
- `Invalid rrskill config at ${s}: root must be a JSON object`
451
+ `Invalid rrskill config at ${t}: root must be a JSON object`
418
452
  );
419
- return t;
453
+ return s;
420
454
  }
421
- async function Ft(t) {
422
- const s = At(t.env), e = K(t.env.RRSKILL_CONFIG_PATH, s) ?? l.resolve(s, ".rrskill", "config.json");
455
+ async function Hs(s) {
456
+ const t = Fs(s.env), e = G(s.env.RRSKILL_CONFIG_PATH, t) ?? c.resolve(t, ".rrskill", "config.json");
423
457
  try {
424
- const r = await u.readFile(e, "utf8"), i = Tt(JSON.parse(r), e);
458
+ const r = await u.readFile(e, "utf8"), i = Ns(JSON.parse(r), e);
425
459
  return {
426
460
  configPath: e,
427
- host: $(i, ["host"]),
428
- stateDir: K(
429
- $(i, ["stateDir", "state_dir"]),
430
- s
461
+ host: A(i, ["host"]),
462
+ stateDir: G(
463
+ A(i, ["stateDir", "state_dir"]),
464
+ t
431
465
  ),
432
- skillsSearchUrl: $(i, [
466
+ skillsSearchUrl: A(i, [
433
467
  "skillsSearchUrl",
434
468
  "skills_search_url"
435
469
  ])
@@ -442,108 +476,108 @@ async function Ft(t) {
442
476
  ) : r;
443
477
  }
444
478
  }
445
- const Nt = "openclaw", Ht = "--host", W = {
479
+ const zs = "openclaw", Ms = "--host", Z = {
446
480
  "--openclaw": "openclaw",
447
481
  "--codex": "codex",
448
482
  "--claude-code": "claude-code"
449
- }, rt = [
483
+ }, os = [
450
484
  "openclaw",
451
485
  "codex",
452
486
  "claude-code"
453
- ], zt = new Set(rt), Mt = new Set(X);
454
- function Jt(t) {
455
- if (!t)
487
+ ], Js = new Set(os), Bs = new Set(ts);
488
+ function qs(s) {
489
+ if (!s)
456
490
  return;
457
- const s = t.trim().toLowerCase();
458
- if (s && zt.has(s))
459
- return s;
491
+ const t = s.trim().toLowerCase();
492
+ if (t && Js.has(t))
493
+ return t;
460
494
  }
461
- function I(t, s) {
462
- if (t === void 0)
495
+ function R(s, t) {
496
+ if (s === void 0)
463
497
  return;
464
- const e = Jt(t);
498
+ const e = qs(s);
465
499
  if (e)
466
500
  return e;
467
- const r = t.trim();
501
+ const r = s.trim();
468
502
  if (r)
469
503
  throw new Error(
470
- `Unsupported host "${r}" from ${s}. Supported hosts: ${rt.join(", ")}`
504
+ `Unsupported host "${r}" from ${t}. Supported hosts: ${os.join(", ")}`
471
505
  );
472
506
  }
473
- function Bt(t) {
474
- const s = t.indexOf(Ht);
475
- if (s < 0)
507
+ function Ks(s) {
508
+ const t = s.indexOf(Ms);
509
+ if (t < 0)
476
510
  return;
477
- const e = t[s + 1];
478
- if (!(!e || e.startsWith("--") || Mt.has(e)))
511
+ const e = s[t + 1];
512
+ if (!(!e || e.startsWith("--") || Bs.has(e)))
479
513
  return e;
480
514
  }
481
- function qt(t) {
482
- const s = t.filter((r) => r in W).map((r) => W[r]);
483
- if (s.length === 0)
515
+ function Ws(s) {
516
+ const t = s.filter((r) => r in Z).map((r) => Z[r]);
517
+ if (t.length === 0)
484
518
  return;
485
- const e = Array.from(new Set(s));
519
+ const e = Array.from(new Set(t));
486
520
  if (e.length > 1)
487
521
  throw new Error(`Conflicting host flags: ${e.join(", ")}`);
488
522
  return e[0];
489
523
  }
490
- function Kt(t) {
491
- const s = qt(t.argv), e = I(
492
- Bt(t.argv),
524
+ function Vs(s) {
525
+ const t = Ws(s.argv), e = R(
526
+ Ks(s.argv),
493
527
  "--host"
494
528
  );
495
- if (s && e && s !== e)
529
+ if (t && e && t !== e)
496
530
  throw new Error(
497
- `Conflicting host flags: ${s} vs ${e}`
531
+ `Conflicting host flags: ${t} vs ${e}`
498
532
  );
499
- const r = e ?? s;
533
+ const r = e ?? t;
500
534
  if (r)
501
535
  return r;
502
- const i = I(t.env.RRSKILL_HOST, "RRSKILL_HOST");
536
+ const i = R(s.env.RRSKILL_HOST, "RRSKILL_HOST");
503
537
  if (i)
504
538
  return i;
505
- const o = t.config.configPath ? `config ${t.config.configPath}` : "config", n = I(t.config.host, o);
506
- return n || Nt;
539
+ const n = s.config.configPath ? `config ${s.config.configPath}` : "config", o = R(s.config.host, n);
540
+ return o || zs;
507
541
  }
508
- function Wt(t) {
509
- const s = t.env.HOME ?? t.env.USERPROFILE ?? process.env.HOME ?? process.env.USERPROFILE ?? process.cwd(), e = t.config.stateDir ?? `${s}/.rrskill`;
510
- return { homeDir: s, stateDir: e };
542
+ function Gs(s) {
543
+ const t = s.env.HOME ?? s.env.USERPROFILE ?? process.env.HOME ?? process.env.USERPROFILE ?? process.cwd(), e = s.config.stateDir ?? `${t}/.rrskill`;
544
+ return { homeDir: t, stateDir: e };
511
545
  }
512
- const Vt = {
546
+ const Zs = {
513
547
  name: "openclaw",
514
- getDefaultPaths({ homeDir: t }) {
548
+ getDefaultPaths({ homeDir: s }) {
515
549
  return {
516
- skillsDir: `${t}/.openclaw/workspace/skills`,
517
- pluginDir: `${t}/.openclaw/extensions/rrskill`,
518
- hostConfigPath: `${t}/.openclaw/openclaw.json`
550
+ skillsDir: `${s}/.openclaw/workspace/skills`,
551
+ pluginDir: `${s}/.openclaw/extensions/rrskill`,
552
+ hostConfigPath: `${s}/.openclaw/openclaw.json`
519
553
  };
520
554
  }
521
- }, Gt = {
555
+ }, Qs = {
522
556
  name: "codex",
523
- getDefaultPaths({ homeDir: t, stateDir: s }) {
524
- const e = s ?? `${t}/.rrskill`;
557
+ getDefaultPaths({ homeDir: s, stateDir: t }) {
558
+ const e = t ?? `${s}/.rrskill`;
525
559
  return {
526
560
  skillsDir: `${e}/hosts/codex/skills`,
527
561
  pluginDir: `${e}/hosts/codex/plugin`,
528
- hostConfigPath: `${t}/.codex/config.toml`
562
+ hostConfigPath: `${s}/.codex/config.toml`
529
563
  };
530
564
  }
531
- }, Zt = {
565
+ }, Xs = {
532
566
  name: "claude-code",
533
- getDefaultPaths({ homeDir: t, stateDir: s }) {
534
- const e = s ?? `${t}/.rrskill`;
567
+ getDefaultPaths({ homeDir: s, stateDir: t }) {
568
+ const e = t ?? `${s}/.rrskill`;
535
569
  return {
536
570
  skillsDir: `${e}/hosts/claude-code/skills`,
537
571
  pluginDir: `${e}/hosts/claude-code/plugin`,
538
- hostConfigPath: `${t}/.claude/settings.json`
572
+ hostConfigPath: `${s}/.claude/settings.json`
539
573
  };
540
574
  }
541
575
  };
542
- async function V(t) {
543
- const s = await Ft({ env: t.env }), e = Kt({ argv: t.argv, env: t.env, config: s }), r = Wt({ env: t.env, config: s }), i = e === "openclaw" ? Vt.getDefaultPaths({ homeDir: r.homeDir, stateDir: r.stateDir }) : e === "codex" ? Gt.getDefaultPaths({ homeDir: r.homeDir, stateDir: r.stateDir }) : Zt.getDefaultPaths({ homeDir: r.homeDir, stateDir: r.stateDir });
576
+ async function Q(s) {
577
+ const t = await Hs({ env: s.env }), e = Vs({ argv: s.argv, env: s.env, config: t }), r = Gs({ env: s.env, config: t }), i = e === "openclaw" ? Zs.getDefaultPaths({ homeDir: r.homeDir, stateDir: r.stateDir }) : e === "codex" ? Qs.getDefaultPaths({ homeDir: r.homeDir, stateDir: r.stateDir }) : Xs.getDefaultPaths({ homeDir: r.homeDir, stateDir: r.stateDir });
544
578
  return {
545
- argv: t.argv,
546
- env: t.env,
579
+ argv: s.argv,
580
+ env: s.env,
547
581
  host: e,
548
582
  distribution: "npm",
549
583
  stateDir: r.stateDir,
@@ -551,193 +585,193 @@ async function V(t) {
551
585
  pluginDir: i.pluginDir,
552
586
  hostConfigPath: i.hostConfigPath,
553
587
  paths: r,
554
- config: s
588
+ config: t
555
589
  };
556
590
  }
557
- const Qt = ".rrskill_lock.json";
558
- function A() {
591
+ const Ys = ".rrskill_lock.json";
592
+ function z() {
559
593
  return { version: 1, skills: {} };
560
594
  }
561
- function it(t) {
562
- return l.join(t, Qt);
595
+ function as(s) {
596
+ return c.join(s, Ys);
563
597
  }
564
- function nt(t, s) {
565
- const e = l.resolve(t), r = l.resolve(e, s), i = e.endsWith(l.sep) ? e : `${e}${l.sep}`;
598
+ function ls(s, t) {
599
+ const e = c.resolve(s), r = c.resolve(e, t), i = e.endsWith(c.sep) ? e : `${e}${c.sep}`;
566
600
  if (!r.startsWith(i))
567
- throw new Error(`Refusing to write outside skillsDir: slug="${s}"`);
601
+ throw new Error(`Refusing to write outside skillsDir: slug="${t}"`);
568
602
  return r;
569
603
  }
570
- function w(t) {
571
- return typeof t == "object" && t !== null;
604
+ function D(s) {
605
+ return typeof s == "object" && s !== null;
572
606
  }
573
- function G(t, s) {
574
- if (!w(s)) return;
575
- const e = typeof s.slug == "string" ? s.slug : t, r = typeof s.installedAt == "string" ? s.installedAt : void 0, i = typeof s.version == "string" ? s.version : void 0, o = w(s.source) || i ? {
607
+ function X(s, t) {
608
+ if (!D(t)) return;
609
+ const e = typeof t.slug == "string" ? t.slug : s, r = typeof t.installedAt == "string" ? t.installedAt : void 0, i = typeof t.version == "string" ? t.version : void 0, n = D(t.source) || i ? {
576
610
  type: "registry",
577
- version: (w(s.source) && typeof s.source.version == "string" ? s.source.version : void 0) ?? i
611
+ version: (D(t.source) && typeof t.source.version == "string" ? t.source.version : void 0) ?? i
578
612
  } : void 0;
579
- return { slug: e, installedAt: r, source: o };
613
+ return { slug: e, installedAt: r, source: n };
580
614
  }
581
- function Xt(t) {
582
- if (!w(t)) return A();
583
- if (t.version === 1 && w(t.skills)) {
615
+ function st(s) {
616
+ if (!D(s)) return z();
617
+ if (s.version === 1 && D(s.skills)) {
584
618
  const i = {};
585
- for (const [o, n] of Object.entries(t.skills)) {
586
- const c = G(o, n);
587
- c && (i[o] = c);
619
+ for (const [n, o] of Object.entries(s.skills)) {
620
+ const l = X(n, o);
621
+ l && (i[n] = l);
588
622
  }
589
623
  return { version: 1, skills: i };
590
624
  }
591
- const s = Object.hasOwn(t, "version"), e = Object.hasOwn(t, "skills");
592
- if (s || e)
593
- return A();
625
+ const t = Object.hasOwn(s, "version"), e = Object.hasOwn(s, "skills");
626
+ if (t || e)
627
+ return z();
594
628
  const r = {};
595
- for (const [i, o] of Object.entries(t)) {
596
- const n = G(i, o);
597
- n && (r[i] = n);
629
+ for (const [i, n] of Object.entries(s)) {
630
+ const o = X(i, n);
631
+ o && (r[i] = o);
598
632
  }
599
633
  return { version: 1, skills: r };
600
634
  }
601
- async function H(t) {
602
- const s = it(t.skillsDir);
635
+ async function q(s) {
636
+ const t = as(s.skillsDir);
603
637
  try {
604
- const e = await t.fs.readFile(s, "utf8"), r = JSON.parse(e);
605
- return Xt(r);
638
+ const e = await s.fs.readFile(t, "utf8"), r = JSON.parse(e);
639
+ return st(r);
606
640
  } catch (e) {
607
- if ((w(e) && typeof e.code == "string" ? e.code : void 0) === "ENOENT") return A();
641
+ if ((D(e) && typeof e.code == "string" ? e.code : void 0) === "ENOENT") return z();
608
642
  throw e;
609
643
  }
610
644
  }
611
- async function ot(t) {
612
- const s = it(t.skillsDir);
613
- await t.fs.mkdir(t.skillsDir, { recursive: !0 });
614
- const e = `${s}.tmp`, r = `${JSON.stringify(t.lockfile, null, 2)}
645
+ async function cs(s) {
646
+ const t = as(s.skillsDir);
647
+ await s.fs.mkdir(s.skillsDir, { recursive: !0 });
648
+ const e = `${t}.tmp`, r = `${JSON.stringify(s.lockfile, null, 2)}
615
649
  `;
616
- await t.fs.writeFile(e, r, "utf8"), await t.fs.rename(e, s);
650
+ await s.fs.writeFile(e, r, "utf8"), await s.fs.rename(e, t);
617
651
  }
618
- function at(t, s) {
652
+ function us(s, t) {
619
653
  return {
620
654
  version: 1,
621
655
  skills: {
622
- ...t.skills,
623
- [s.slug]: s
656
+ ...s.skills,
657
+ [t.slug]: t
624
658
  }
625
659
  };
626
660
  }
627
- function Yt() {
661
+ function tt() {
628
662
  return /* @__PURE__ */ new Date();
629
663
  }
630
- async function ts(t) {
631
- const s = t.fsImpl ?? u;
632
- await s.mkdir(t.targetDir, { recursive: !0 });
633
- const e = l.join(t.targetDir, "rrskill.json");
634
- await s.writeFile(
664
+ async function et(s) {
665
+ const t = s.fsImpl ?? u;
666
+ await t.mkdir(s.targetDir, { recursive: !0 });
667
+ const e = c.join(s.targetDir, "rrskill.json");
668
+ await t.writeFile(
635
669
  e,
636
- `${JSON.stringify({ slug: t.slug, installedBy: "rrskill-cli", schema: 1 }, null, 2)}
670
+ `${JSON.stringify({ slug: s.slug, installedBy: "rrskill-cli", schema: 1 }, null, 2)}
637
671
  `,
638
672
  "utf8"
639
673
  );
640
674
  }
641
- async function ss(t, s, e = {}) {
642
- const r = e.fs ?? u, i = e.now ?? Yt;
643
- let o;
644
- if (e.searchSkills && (o = (await e.searchSkills({ query: s })).results.find((h) => h.slug === s), !o))
645
- throw new Error(`No exact registry match for slug "${s}"`);
646
- const n = nt(t.skillsDir, s);
647
- let c = o?.version;
648
- e.downloadSkill ? (await r.mkdir(n, { recursive: !0 }), c = (await e.downloadSkill({ slug: s, targetDir: n, registrySkill: o })).version ?? c) : await ts({ slug: s, targetDir: n, fsImpl: r });
649
- const a = await H({ skillsDir: t.skillsDir, fs: r }), f = at(a, {
650
- slug: s,
675
+ async function rt(s, t, e = {}) {
676
+ const r = e.fs ?? u, i = e.now ?? tt;
677
+ let n;
678
+ if (e.searchSkills && (n = (await e.searchSkills({ query: t })).results.find((p) => p.slug === t), !n))
679
+ throw new Error(`No exact registry match for slug "${t}"`);
680
+ const o = ls(s.skillsDir, t);
681
+ let l = n?.version;
682
+ e.downloadSkill ? (await r.mkdir(o, { recursive: !0 }), l = (await e.downloadSkill({ slug: t, targetDir: o, registrySkill: n })).version ?? l) : await et({ slug: t, targetDir: o, fsImpl: r });
683
+ const a = await q({ skillsDir: s.skillsDir, fs: r }), f = us(a, {
684
+ slug: t,
651
685
  installedAt: i().toISOString(),
652
- source: { type: "registry", version: c }
686
+ source: { type: "registry", version: l }
653
687
  });
654
- return await ot({ skillsDir: t.skillsDir, fs: r, lockfile: f }), {
655
- slug: s,
656
- targetDir: n,
657
- registryMatch: o
688
+ return await cs({ skillsDir: s.skillsDir, fs: r, lockfile: f }), {
689
+ slug: t,
690
+ targetDir: o,
691
+ registryMatch: n
658
692
  };
659
693
  }
660
- async function es(t, s = {}) {
661
- const e = s.fs ?? u, r = await H({ skillsDir: t.skillsDir, fs: e });
694
+ async function it(s, t = {}) {
695
+ const e = t.fs ?? u, r = await q({ skillsDir: s.skillsDir, fs: e });
662
696
  return Object.keys(r.skills).sort();
663
697
  }
664
- async function rs(t, s, e) {
665
- return e.searchSkills({ query: s });
698
+ async function nt(s, t, e) {
699
+ return e.searchSkills({ query: t });
666
700
  }
667
- async function is(t, s = {}) {
668
- const e = s.fs ?? u, r = s.now ?? (() => /* @__PURE__ */ new Date()), i = await H({ skillsDir: t.skillsDir, fs: e }), o = Object.keys(i.skills).sort();
669
- if (!s.downloadSkill)
701
+ async function ot(s, t = {}) {
702
+ const e = t.fs ?? u, r = t.now ?? (() => /* @__PURE__ */ new Date()), i = await q({ skillsDir: s.skillsDir, fs: e }), n = Object.keys(i.skills).sort();
703
+ if (!t.downloadSkill)
670
704
  return { upgraded: [] };
671
- const n = [];
672
- let c = i;
673
- for (const a of o) {
674
- const f = nt(t.skillsDir, a);
705
+ const o = [];
706
+ let l = i;
707
+ for (const a of n) {
708
+ const f = ls(s.skillsDir, a);
675
709
  await e.mkdir(f, { recursive: !0 });
676
- const d = await s.downloadSkill({ slug: a, targetDir: f });
677
- n.push(a);
678
- const h = c.skills[a];
679
- c = at(c, {
710
+ const d = await t.downloadSkill({ slug: a, targetDir: f });
711
+ o.push(a);
712
+ const p = l.skills[a];
713
+ l = us(l, {
680
714
  slug: a,
681
715
  installedAt: r().toISOString(),
682
716
  source: {
683
717
  type: "registry",
684
- version: d.version ?? h?.source?.version
718
+ version: d.version ?? p?.source?.version
685
719
  }
686
- }), await ot({ skillsDir: t.skillsDir, fs: e, lockfile: c });
720
+ }), await cs({ skillsDir: s.skillsDir, fs: e, lockfile: l });
687
721
  }
688
- return { upgraded: n };
722
+ return { upgraded: o };
689
723
  }
690
- function ns(t) {
691
- let s = l.dirname(_(t));
724
+ function at(s) {
725
+ let t = c.dirname(O(s));
692
726
  for (; ; ) {
693
- const e = l.join(s, "package.json");
727
+ const e = c.join(t, "package.json");
694
728
  try {
695
- return JSON.parse(wt(e, "utf8"));
729
+ return JSON.parse(ws(e, "utf8"));
696
730
  } catch {
697
- const r = l.dirname(s);
698
- if (r === s)
731
+ const r = c.dirname(t);
732
+ if (r === t)
699
733
  return {};
700
- s = r;
734
+ t = r;
701
735
  }
702
736
  }
703
737
  }
704
- function os(t = {}) {
705
- const s = ns(import.meta.url);
738
+ function lt(s = {}) {
739
+ const t = at(import.meta.url);
706
740
  return {
707
- packageName: t.packageName ?? s.name ?? "rrskill",
708
- version: t.version ?? s.version ?? "0.0.0-dev",
741
+ packageName: s.packageName ?? t.name ?? "rrskill",
742
+ version: s.version ?? t.version ?? "0.0.0-dev",
709
743
  updateVia: "npm",
710
744
  instructions: ["npm install -g rrskill@latest", "npm install -g @rrskill/cli@latest"]
711
745
  };
712
746
  }
713
- const as = St(vt.inflateRaw), ls = "https://api.rrskill.ai/skills?page=1&size={limit}&search={query}&orderBy=downloadCount&order=desc", cs = 20;
714
- function C(t) {
715
- return typeof t == "object" && t !== null && !Array.isArray(t);
747
+ const ct = Ss(vs.inflateRaw), ut = "https://api.rrskill.ai/skills?page=1&size={limit}&search={query}&orderBy=downloadCount&order=desc", ft = 20;
748
+ function I(s) {
749
+ return typeof s == "object" && s !== null && !Array.isArray(s);
716
750
  }
717
- function p(t, s) {
718
- for (const e of s) {
719
- const r = t[e];
751
+ function h(s, t) {
752
+ for (const e of t) {
753
+ const r = s[e];
720
754
  if (typeof r == "string" && r.trim())
721
755
  return r.trim();
722
756
  }
723
757
  }
724
- function L(t) {
758
+ function P(s) {
725
759
  try {
726
- return new URL(t);
760
+ return new URL(s);
727
761
  } catch {
728
762
  return;
729
763
  }
730
764
  }
731
- function us(t, s, e, r) {
732
- const i = s.RRSKILL_SKILLS_SEARCH_URL?.trim() || s.RRSKILL_SEARCH_URL?.trim() || t.skillsSearchUrl?.trim() || ls, o = i.replaceAll("{query}", encodeURIComponent(e)).replaceAll("{limit}", String(r)), n = L(o);
733
- return n && ["http:", "https:"].includes(n.protocol) ? (i.includes("{query}") || ["search", "q", "keyword", "slug"].some(
734
- (c) => n.searchParams.has(c)
735
- ) || n.searchParams.set("search", e), i.includes("{limit}") || ["limit", "size"].some((c) => n.searchParams.has(c)) || n.searchParams.set("limit", String(r)), n.toString()) : o;
765
+ function dt(s, t, e, r) {
766
+ const i = t.RRSKILL_SKILLS_SEARCH_URL?.trim() || t.RRSKILL_SEARCH_URL?.trim() || s.skillsSearchUrl?.trim() || ut, n = i.replaceAll("{query}", encodeURIComponent(e)).replaceAll("{limit}", String(r)), o = P(n);
767
+ return o && ["http:", "https:"].includes(o.protocol) ? (i.includes("{query}") || ["search", "q", "keyword", "slug"].some(
768
+ (l) => o.searchParams.has(l)
769
+ ) || o.searchParams.set("search", e), i.includes("{limit}") || ["limit", "size"].some((l) => o.searchParams.has(l)) || o.searchParams.set("limit", String(r)), o.toString()) : n;
736
770
  }
737
- async function fs(t) {
738
- const s = L(t);
739
- if (s?.protocol === "http:" || s?.protocol === "https:") {
740
- const r = await fetch(t, {
771
+ async function pt(s) {
772
+ const t = P(s);
773
+ if (t?.protocol === "http:" || t?.protocol === "https:") {
774
+ const r = await fetch(s, {
741
775
  headers: {
742
776
  accept: "application/json"
743
777
  }
@@ -748,180 +782,180 @@ async function fs(t) {
748
782
  );
749
783
  return {
750
784
  payload: await r.text(),
751
- reference: r.url || t
785
+ reference: r.url || s
752
786
  };
753
787
  }
754
- if (s?.protocol === "file:") {
755
- const r = _(s);
788
+ if (t?.protocol === "file:") {
789
+ const r = O(t);
756
790
  return {
757
791
  payload: await u.readFile(r, "utf8"),
758
- reference: s.toString()
792
+ reference: t.toString()
759
793
  };
760
794
  }
761
- const e = l.resolve(t);
795
+ const e = c.resolve(s);
762
796
  return {
763
797
  payload: await u.readFile(e, "utf8"),
764
- reference: kt(e).toString()
798
+ reference: ks(e).toString()
765
799
  };
766
800
  }
767
- function ds(t, s) {
768
- if (t)
801
+ function ht(s, t) {
802
+ if (s)
769
803
  try {
770
- return new URL(t, s).toString();
804
+ return new URL(s, t).toString();
771
805
  } catch {
772
806
  return;
773
807
  }
774
808
  }
775
- function lt(t, s, e) {
776
- const r = s?.trim().toLowerCase();
809
+ function fs(s, t, e) {
810
+ const r = t?.trim().toLowerCase();
777
811
  if (!r)
778
812
  return;
779
- const i = yt("sha256").update(t).digest("hex").toLowerCase();
813
+ const i = ys("sha256").update(s).digest("hex").toLowerCase();
780
814
  if (i !== r)
781
815
  throw new Error(
782
816
  `SHA256 mismatch for ${e}: expected ${r}, got ${i}`
783
817
  );
784
818
  }
785
- function ps(t, s) {
786
- const e = p(t, ["slug"]);
819
+ function gt(s, t) {
820
+ const e = h(s, ["slug"]);
787
821
  if (!e)
788
822
  return;
789
- const r = C(t.currentVersion) ? t.currentVersion : {}, i = ds(
790
- p(r, [
823
+ const r = I(s.currentVersion) ? s.currentVersion : {}, i = ht(
824
+ h(r, [
791
825
  "skillUrl",
792
826
  "downloadUrl",
793
827
  "packageUrl",
794
828
  "url"
795
- ]) ?? p(t, ["skillUrl", "downloadUrl", "packageUrl", "url"]),
796
- s
829
+ ]) ?? h(s, ["skillUrl", "downloadUrl", "packageUrl", "url"]),
830
+ t
797
831
  );
798
832
  return {
799
833
  slug: e,
800
- title: p(t, ["displayName", "name", "title"]) ?? e,
801
- description: p(t, ["summary", "description"]),
802
- version: p(r, ["version"]) ?? p(t, ["version"]),
834
+ title: h(s, ["displayName", "name", "title"]) ?? e,
835
+ description: h(s, ["summary", "description"]),
836
+ version: h(r, ["version"]) ?? h(s, ["version"]),
803
837
  skillUrl: i,
804
- sha256: p(r, ["sha256"]) ?? p(t, ["sha256", "checksum"]),
805
- source: p(t, ["source", "platform"])
838
+ sha256: h(r, ["sha256"]) ?? h(s, ["sha256", "checksum"]),
839
+ source: h(s, ["source", "platform"])
806
840
  };
807
841
  }
808
- function hs(t, s, e) {
842
+ function mt(s, t, e) {
809
843
  let r;
810
844
  try {
811
- r = JSON.parse(t);
845
+ r = JSON.parse(s);
812
846
  } catch (a) {
813
847
  throw new Error(
814
848
  `Search response is not valid JSON: ${a instanceof Error ? a.message : String(a)}`
815
849
  );
816
850
  }
817
- if (!C(r))
851
+ if (!I(r))
818
852
  throw new Error("Search API response must be a JSON object.");
819
853
  let i = r.results;
820
854
  if (!Array.isArray(i)) {
821
- const a = C(r.data) ? r.data : void 0;
855
+ const a = I(r.data) ? r.data : void 0;
822
856
  a && Array.isArray(a.records) && (i = a.records);
823
857
  }
824
858
  if (!Array.isArray(i))
825
859
  throw new Error(
826
860
  'Search API response must include "results" or "data.records" array.'
827
861
  );
828
- const o = e.trim().toLowerCase(), n = !["http:", "https:"].includes(
829
- L(s)?.protocol ?? ""
830
- ), c = i.filter(C).map((a) => ps(a, s)).filter((a) => a !== void 0).filter((a) => n && o ? [a.slug, a.title, a.description].filter(
862
+ const n = e.trim().toLowerCase(), o = !["http:", "https:"].includes(
863
+ P(t)?.protocol ?? ""
864
+ ), l = i.filter(I).map((a) => gt(a, t)).filter((a) => a !== void 0).filter((a) => o && n ? [a.slug, a.title, a.description].filter(
831
865
  (d) => !!d
832
866
  ).some(
833
- (d) => d.toLowerCase().includes(o)
867
+ (d) => d.toLowerCase().includes(n)
834
868
  ) : !0);
835
- return { query: e, results: c };
836
- }
837
- function ms(t) {
838
- return async ({ query: s }) => {
839
- const e = us(
840
- t.config,
841
- t.env,
842
- s,
843
- cs
844
- ), { payload: r, reference: i } = await fs(e);
845
- return hs(r, i, s);
869
+ return { query: e, results: l };
870
+ }
871
+ function kt(s) {
872
+ return async ({ query: t }) => {
873
+ const e = dt(
874
+ s.config,
875
+ s.env,
876
+ t,
877
+ ft
878
+ ), { payload: r, reference: i } = await pt(e);
879
+ return mt(r, i, t);
846
880
  };
847
881
  }
848
- async function ct(t, s) {
882
+ async function ds(s, t) {
849
883
  const e = [];
850
- let n = -1;
851
- for (let f = t.length - 22; f >= Math.max(0, t.length - 65557); f -= 1)
852
- if (t.readUInt32LE(f) === 101010256) {
853
- n = f;
884
+ let o = -1;
885
+ for (let f = s.length - 22; f >= Math.max(0, s.length - 65557); f -= 1)
886
+ if (s.readUInt32LE(f) === 101010256) {
887
+ o = f;
854
888
  break;
855
889
  }
856
- if (n < 0)
890
+ if (o < 0)
857
891
  throw new Error("Downloaded skill package is not a valid zip archive.");
858
- const c = t.readUInt16LE(n + 10);
859
- let a = t.readUInt32LE(n + 16);
860
- await u.mkdir(s, { recursive: !0 });
861
- for (let f = 0; f < c; f += 1) {
862
- if (t.readUInt32LE(a) !== 33639248)
892
+ const l = s.readUInt16LE(o + 10);
893
+ let a = s.readUInt32LE(o + 16);
894
+ await u.mkdir(t, { recursive: !0 });
895
+ for (let f = 0; f < l; f += 1) {
896
+ if (s.readUInt32LE(a) !== 33639248)
863
897
  throw new Error(
864
898
  "Downloaded skill package has an invalid zip central directory."
865
899
  );
866
- const d = t.readUInt16LE(a + 10), h = t.readUInt32LE(a + 20), ft = t.readUInt32LE(a + 24), z = t.readUInt16LE(a + 28), dt = t.readUInt16LE(a + 30), pt = t.readUInt16LE(a + 32), v = t.readUInt32LE(a + 42), S = t.toString(
900
+ const d = s.readUInt16LE(a + 10), p = s.readUInt32LE(a + 20), C = s.readUInt32LE(a + 24), m = s.readUInt16LE(a + 28), g = s.readUInt16LE(a + 30), j = s.readUInt16LE(a + 32), E = s.readUInt32LE(a + 42), x = s.toString(
867
901
  "utf8",
868
902
  a + 46,
869
- a + 46 + z
903
+ a + 46 + m
870
904
  );
871
- a += 46 + z + dt + pt;
872
- const k = S.replaceAll("\\", "/");
873
- if (!k || k.startsWith("/") || k.includes("../"))
874
- throw new Error(`Unsafe zip path entry detected: ${S}`);
875
- const y = l.resolve(s, k), ht = s.endsWith(l.sep) ? s : `${s}${l.sep}`;
876
- if (y !== s && !y.startsWith(ht))
877
- throw new Error(`Unsafe zip path entry detected: ${S}`);
878
- if (t.readUInt32LE(v) !== 67324752)
905
+ a += 46 + m + g + j;
906
+ const y = x.replaceAll("\\", "/");
907
+ if (!y || y.startsWith("/") || y.includes("../"))
908
+ throw new Error(`Unsafe zip path entry detected: ${x}`);
909
+ const _ = c.resolve(t, y), hs = t.endsWith(c.sep) ? t : `${t}${c.sep}`;
910
+ if (_ !== t && !_.startsWith(hs))
911
+ throw new Error(`Unsafe zip path entry detected: ${x}`);
912
+ if (s.readUInt32LE(E) !== 67324752)
879
913
  throw new Error(
880
914
  "Downloaded skill package has an invalid zip local header."
881
915
  );
882
- const mt = t.readUInt16LE(v + 26), gt = t.readUInt16LE(v + 28), M = v + 30 + mt + gt, J = t.subarray(
883
- M,
884
- M + h
916
+ const gs = s.readUInt16LE(E + 26), ms = s.readUInt16LE(E + 28), K = E + 30 + gs + ms, W = s.subarray(
917
+ K,
918
+ K + p
885
919
  );
886
- if (k.endsWith("/")) {
887
- await u.mkdir(y, { recursive: !0 });
920
+ if (y.endsWith("/")) {
921
+ await u.mkdir(_, { recursive: !0 });
888
922
  continue;
889
923
  }
890
- let D;
924
+ let L;
891
925
  if (d === 0)
892
- D = Buffer.from(J);
926
+ L = Buffer.from(W);
893
927
  else if (d === 8)
894
- D = Buffer.from(await as(J));
928
+ L = Buffer.from(await ct(W));
895
929
  else
896
930
  throw new Error(
897
931
  `Unsupported zip compression method: ${d}`
898
932
  );
899
- if (D.length !== ft)
900
- throw new Error(`Zip entry size mismatch for ${S}`);
901
- await u.mkdir(l.dirname(y), { recursive: !0 }), await u.writeFile(y, D), e.push(k);
933
+ if (L.length !== C)
934
+ throw new Error(`Zip entry size mismatch for ${x}`);
935
+ await u.mkdir(c.dirname(_), { recursive: !0 }), await u.writeFile(_, L), e.push(y);
902
936
  }
903
937
  return e;
904
938
  }
905
- async function T(t, s) {
906
- await u.rm(s, { recursive: !0, force: !0 }), await u.mkdir(l.dirname(s), { recursive: !0 }), await u.cp(t, s, { recursive: !0 });
939
+ async function M(s, t) {
940
+ await u.rm(t, { recursive: !0, force: !0 }), await u.mkdir(c.dirname(t), { recursive: !0 }), await u.cp(s, t, { recursive: !0 });
907
941
  }
908
- async function gs(t, s, e) {
909
- if ((await u.stat(t)).isDirectory())
910
- return await T(t, s), [];
911
- const i = await u.readFile(t);
912
- lt(i, e, t);
913
- const o = await u.mkdtemp(
914
- l.join(Q.tmpdir(), "rrskill-registry-stage-")
942
+ async function wt(s, t, e) {
943
+ if ((await u.stat(s)).isDirectory())
944
+ return await M(s, t), [];
945
+ const i = await u.readFile(s);
946
+ fs(i, e, s);
947
+ const n = await u.mkdtemp(
948
+ c.join(ss.tmpdir(), "rrskill-registry-stage-")
915
949
  );
916
950
  try {
917
- const n = await ct(i, o);
918
- return await T(o, s), n;
951
+ const o = await ds(i, n);
952
+ return await M(n, t), o;
919
953
  } finally {
920
- await u.rm(o, { recursive: !0, force: !0 });
954
+ await u.rm(n, { recursive: !0, force: !0 });
921
955
  }
922
956
  }
923
- async function ks(t, s, e) {
924
- const r = await fetch(t, {
957
+ async function yt(s, t, e) {
958
+ const r = await fetch(s, {
925
959
  headers: {
926
960
  accept: "application/zip,application/octet-stream,*/*"
927
961
  }
@@ -931,61 +965,61 @@ async function ks(t, s, e) {
931
965
  `Skill download failed: ${r.status} ${r.statusText}`
932
966
  );
933
967
  const i = Buffer.from(await r.arrayBuffer());
934
- lt(i, e, t);
935
- const o = await u.mkdtemp(
936
- l.join(Q.tmpdir(), "rrskill-registry-stage-")
968
+ fs(i, e, s);
969
+ const n = await u.mkdtemp(
970
+ c.join(ss.tmpdir(), "rrskill-registry-stage-")
937
971
  );
938
972
  try {
939
- const n = await ct(i, o);
940
- return await T(o, s), n;
973
+ const o = await ds(i, n);
974
+ return await M(n, t), o;
941
975
  } finally {
942
- await u.rm(o, { recursive: !0, force: !0 });
976
+ await u.rm(n, { recursive: !0, force: !0 });
943
977
  }
944
978
  }
945
- async function ws(t, s) {
946
- const r = (await t({ query: s })).results.find((i) => i.slug === s);
979
+ async function vt(s, t) {
980
+ const r = (await s({ query: t })).results.find((i) => i.slug === t);
947
981
  if (!r)
948
- throw new Error(`No exact registry match for slug "${s}"`);
982
+ throw new Error(`No exact registry match for slug "${t}"`);
949
983
  return r;
950
984
  }
951
- async function ys(t, s) {
952
- const e = s.registrySkill?.slug === s.slug ? s.registrySkill : await ws(t, s.slug), r = e.skillUrl;
985
+ async function St(s, t) {
986
+ const e = t.registrySkill?.slug === t.slug ? t.registrySkill : await vt(s, t.slug), r = e.skillUrl;
953
987
  if (!r)
954
988
  throw new Error(
955
- `Registry skill "${s.slug}" does not define a skillUrl/packageUrl`
989
+ `Registry skill "${t.slug}" does not define a skillUrl/packageUrl`
956
990
  );
957
- const i = L(r), o = e.sha256, n = i?.protocol === "http:" || i?.protocol === "https:" ? await ks(
991
+ const i = P(r), n = e.sha256, o = i?.protocol === "http:" || i?.protocol === "https:" ? await yt(
958
992
  r,
959
- s.targetDir,
960
- o
961
- ) : await gs(
962
- i?.protocol === "file:" ? _(i) : l.resolve(r),
963
- s.targetDir,
964
- o
993
+ t.targetDir,
994
+ n
995
+ ) : await wt(
996
+ i?.protocol === "file:" ? O(i) : c.resolve(r),
997
+ t.targetDir,
998
+ n
965
999
  );
966
1000
  return {
967
- slug: s.slug,
968
- targetDir: s.targetDir,
969
- writtenFiles: n,
1001
+ slug: t.slug,
1002
+ targetDir: t.targetDir,
1003
+ writtenFiles: o,
970
1004
  version: e.version
971
1005
  };
972
1006
  }
973
- function vs(t) {
974
- return async (s) => ys(t, s);
1007
+ function Dt(s) {
1008
+ return async (t) => St(s, t);
975
1009
  }
976
- class g extends Error {
1010
+ class w extends Error {
977
1011
  code;
978
1012
  hint;
979
1013
  nextCommands;
980
- constructor(s) {
981
- super(s.message), this.code = s.code, this.hint = s.hint, this.nextCommands = s.nextCommands ?? [];
1014
+ constructor(t) {
1015
+ super(t.message), this.code = t.code, this.hint = t.hint, this.nextCommands = t.nextCommands ?? [];
982
1016
  }
983
1017
  }
984
- function Ss() {
985
- const t = process.argv[1] ?? "";
986
- return t ? ["rrskill.js", "rrskill"].includes(l.basename(t)) ? !0 : import.meta.url === `file://${t}` : !1;
1018
+ function _t() {
1019
+ const s = process.argv[1] ?? "";
1020
+ return s ? ["rrskill.js", "rrskill"].includes(c.basename(s)) ? !0 : import.meta.url === `file://${s}` : !1;
987
1021
  }
988
- function Ds() {
1022
+ function Ct() {
989
1023
  return [
990
1024
  "rrskill CLI",
991
1025
  "",
@@ -1021,8 +1055,8 @@ function Ds() {
1021
1055
  ].join(`
1022
1056
  `);
1023
1057
  }
1024
- function xs(t) {
1025
- const s = [
1058
+ function jt(s) {
1059
+ const t = [
1026
1060
  "",
1027
1061
  "Global options:",
1028
1062
  " --host <name>",
@@ -1032,7 +1066,7 @@ function xs(t) {
1032
1066
  " --output <json|text>",
1033
1067
  " --json"
1034
1068
  ];
1035
- return t === "search" ? [
1069
+ return s === "search" ? [
1036
1070
  "rrskill search",
1037
1071
  "",
1038
1072
  "Usage:",
@@ -1041,9 +1075,9 @@ function xs(t) {
1041
1075
  "Examples:",
1042
1076
  " rrskill search react",
1043
1077
  " rrskill search browser automation --host codex",
1044
- ...s
1078
+ ...t
1045
1079
  ].join(`
1046
- `) : t === "install" ? [
1080
+ `) : s === "install" ? [
1047
1081
  "rrskill install",
1048
1082
  "",
1049
1083
  "Usage:",
@@ -1053,9 +1087,9 @@ function xs(t) {
1053
1087
  "Examples:",
1054
1088
  " rrskill install web-search",
1055
1089
  " rrskill web-search --host codex",
1056
- ...s
1090
+ ...t
1057
1091
  ].join(`
1058
- `) : t === "list" ? [
1092
+ `) : s === "list" ? [
1059
1093
  "rrskill list",
1060
1094
  "",
1061
1095
  "Usage:",
@@ -1064,9 +1098,9 @@ function xs(t) {
1064
1098
  "Examples:",
1065
1099
  " rrskill list",
1066
1100
  " rrskill list --host claude-code",
1067
- ...s
1101
+ ...t
1068
1102
  ].join(`
1069
- `) : t === "upgrade" ? [
1103
+ `) : s === "upgrade" ? [
1070
1104
  "rrskill upgrade",
1071
1105
  "",
1072
1106
  "Usage:",
@@ -1075,9 +1109,9 @@ function xs(t) {
1075
1109
  "Examples:",
1076
1110
  " rrskill upgrade",
1077
1111
  " rrskill upgrade --host codex",
1078
- ...s
1112
+ ...t
1079
1113
  ].join(`
1080
- `) : t === "bootstrap" ? [
1114
+ `) : s === "bootstrap" ? [
1081
1115
  "rrskill bootstrap",
1082
1116
  "",
1083
1117
  "Usage:",
@@ -1086,9 +1120,9 @@ function xs(t) {
1086
1120
  "Examples:",
1087
1121
  " rrskill bootstrap --host openclaw",
1088
1122
  " rrskill bootstrap --openclaw",
1089
- ...s
1123
+ ...t
1090
1124
  ].join(`
1091
- `) : t === "doctor" ? [
1125
+ `) : s === "doctor" ? [
1092
1126
  "rrskill doctor",
1093
1127
  "",
1094
1128
  "Usage:",
@@ -1102,7 +1136,7 @@ function xs(t) {
1102
1136
  " rrskill doctor --host openclaw",
1103
1137
  " rrskill doctor --host openclaw --fix",
1104
1138
  " rrskill doctor --host openclaw --dry-run --output json",
1105
- ...s
1139
+ ...t
1106
1140
  ].join(`
1107
1141
  `) : [
1108
1142
  "rrskill version",
@@ -1113,129 +1147,129 @@ function xs(t) {
1113
1147
  "Examples:",
1114
1148
  " rrskill version",
1115
1149
  " rrskill version --output json",
1116
- ...s
1150
+ ...t
1117
1151
  ].join(`
1118
1152
  `);
1119
1153
  }
1120
- function F(t) {
1121
- process.stdout.write(`${JSON.stringify(t, null, 2)}
1154
+ function J(s) {
1155
+ process.stdout.write(`${JSON.stringify(s, null, 2)}
1122
1156
  `);
1123
1157
  }
1124
- function N(t) {
1125
- process.stdout.write(t.endsWith(`
1126
- `) ? t : `${t}
1158
+ function B(s) {
1159
+ process.stdout.write(s.endsWith(`
1160
+ `) ? s : `${s}
1127
1161
  `);
1128
1162
  }
1129
- function m(t, s, e) {
1130
- if (s === "json") {
1131
- F(t);
1163
+ function k(s, t, e) {
1164
+ if (t === "json") {
1165
+ J(s);
1132
1166
  return;
1133
1167
  }
1134
- N(e(t));
1168
+ B(e(s));
1135
1169
  }
1136
- function js(t) {
1170
+ function Et(s) {
1137
1171
  return [
1138
- `${t.packageName} ${t.version}`,
1139
- `Update via ${t.updateVia}:`,
1140
- ...t.instructions.map((s) => ` ${s}`)
1172
+ `${s.packageName} ${s.version}`,
1173
+ `Update via ${s.updateVia}:`,
1174
+ ...s.instructions.map((t) => ` ${t}`)
1141
1175
  ].join(`
1142
1176
  `);
1143
1177
  }
1144
- function Cs(t) {
1145
- return t.results.length === 0 ? `No skills found for "${t.query}".` : t.results.map((s) => {
1146
- const e = s.version ? `@${s.version}` : "", r = s.title && s.title !== s.slug ? ` - ${s.title}` : "";
1147
- return `${s.slug}${e}${r}`;
1178
+ function xt(s) {
1179
+ return s.results.length === 0 ? `No skills found for "${s.query}".` : s.results.map((t) => {
1180
+ const e = t.version ? `@${t.version}` : "", r = t.title && t.title !== t.slug ? ` - ${t.title}` : "";
1181
+ return `${t.slug}${e}${r}`;
1148
1182
  }).join(`
1149
1183
  `);
1150
1184
  }
1151
- function Es(t) {
1152
- const s = [`Installed ${t.slug}`, `Target: ${t.targetDir}`];
1153
- return t.registryMatch?.version && s.push(`Version: ${t.registryMatch.version}`), s.join(`
1185
+ function Lt(s) {
1186
+ const t = [`Installed ${s.slug}`, `Target: ${s.targetDir}`];
1187
+ return s.registryMatch?.version && t.push(`Version: ${s.registryMatch.version}`), t.join(`
1154
1188
  `);
1155
1189
  }
1156
- function _s(t) {
1157
- return t.length === 0 ? "No skills installed." : t.join(`
1190
+ function bt(s) {
1191
+ return s.length === 0 ? "No skills installed." : s.join(`
1158
1192
  `);
1159
1193
  }
1160
- function Ls(t) {
1161
- return t.upgraded.length === 0 ? "No skills upgraded." : ["Upgraded skills:", ...t.upgraded.map((s) => ` ${s}`)].join(`
1194
+ function It(s) {
1195
+ return s.upgraded.length === 0 ? "No skills upgraded." : ["Upgraded skills:", ...s.upgraded.map((t) => ` ${t}`)].join(`
1162
1196
  `);
1163
1197
  }
1164
- function bs(t) {
1165
- const s = [
1166
- t.verification.ok ? "Bootstrap succeeded." : "Bootstrap failed.",
1167
- `Builtins installed: ${t.builtinsInstalled.length === 0 ? "none" : t.builtinsInstalled.join(", ")}`,
1168
- `Plugin installed: ${t.pluginInstalled ? "yes" : "no"}`,
1169
- `Host config repaired: ${t.hostConfigRepaired ? "yes" : "no"}`
1198
+ function $t(s) {
1199
+ const t = [
1200
+ s.verification.ok ? "Bootstrap succeeded." : "Bootstrap failed.",
1201
+ `Builtins installed: ${s.builtinsInstalled.length === 0 ? "none" : s.builtinsInstalled.join(", ")}`,
1202
+ `Plugin installed: ${s.pluginInstalled ? "yes" : "no"}`,
1203
+ `Host config repaired: ${s.hostConfigRepaired ? "yes" : "no"}`
1170
1204
  ];
1171
- return t.verification.ok || s.push(
1172
- ...t.verification.issues.map(
1205
+ return s.verification.ok || t.push(
1206
+ ...s.verification.issues.map(
1173
1207
  (e) => "code" in e ? `Issue: ${e.code}` : `Issue: ${JSON.stringify(e)}`
1174
1208
  )
1175
- ), s.join(`
1209
+ ), t.join(`
1176
1210
  `);
1177
1211
  }
1178
- function $s(t) {
1179
- const s = [
1180
- t.ok ? `Doctor OK for ${t.host}.` : `Doctor found issues for ${t.host}.`,
1181
- `Bootstrap supported: ${t.bootstrapSupported ? "yes" : "no"}`,
1182
- `Fixed: ${t.fixed ? "yes" : "no"}`
1212
+ function Ot(s) {
1213
+ const t = [
1214
+ s.ok ? `Doctor OK for ${s.host}.` : `Doctor found issues for ${s.host}.`,
1215
+ `Bootstrap supported: ${s.bootstrapSupported ? "yes" : "no"}`,
1216
+ `Fixed: ${s.fixed ? "yes" : "no"}`
1183
1217
  ];
1184
- return t.checks.length > 0 && s.push(...t.checks.map((e) => `[${e.ok ? "ok" : "fail"}] ${e.name}: ${e.message}`)), t.nextCommands.length > 0 && s.push("Next commands:", ...t.nextCommands.map((e) => ` ${e}`)), s.join(`
1218
+ return s.checks.length > 0 && t.push(...s.checks.map((e) => `[${e.ok ? "ok" : "fail"}] ${e.name}: ${e.message}`)), s.nextCommands.length > 0 && t.push("Next commands:", ...s.nextCommands.map((e) => ` ${e}`)), t.join(`
1185
1219
  `);
1186
1220
  }
1187
- function E(t, ...s) {
1188
- return t.some((e) => s.includes(e));
1221
+ function $(s, ...t) {
1222
+ return s.some((e) => t.includes(e));
1189
1223
  }
1190
- function Is(t, s) {
1191
- const e = t.indexOf(s);
1224
+ function Pt(s, t) {
1225
+ const e = s.indexOf(t);
1192
1226
  if (e < 0)
1193
1227
  return;
1194
- const r = t[e + 1];
1228
+ const r = s[e + 1];
1195
1229
  if (!(!r || r.startsWith("--")))
1196
1230
  return r;
1197
1231
  }
1198
- function ut(t, s = "json") {
1199
- if (E(t, "--json"))
1232
+ function ps(s, t = "json") {
1233
+ if ($(s, "--json"))
1200
1234
  return "json";
1201
- const e = Is(t, "--output");
1235
+ const e = Pt(s, "--output");
1202
1236
  if (!e) {
1203
- if (t.includes("--output"))
1204
- throw new g({
1237
+ if (s.includes("--output"))
1238
+ throw new w({
1205
1239
  code: "missing_output_mode",
1206
1240
  message: "--output requires a value.",
1207
1241
  hint: "rrskill --output <json|text>",
1208
1242
  nextCommands: ["rrskill --help"]
1209
1243
  });
1210
- return s;
1244
+ return t;
1211
1245
  }
1212
1246
  if (e === "json" || e === "text")
1213
1247
  return e;
1214
- throw new g({
1248
+ throw new w({
1215
1249
  code: "invalid_output_mode",
1216
1250
  message: `Unsupported output mode "${e}".`,
1217
1251
  hint: "rrskill --output <json|text>",
1218
1252
  nextCommands: ["rrskill --help"]
1219
1253
  });
1220
1254
  }
1221
- function Z(t, s) {
1222
- if (t instanceof g && s === "json") {
1223
- F({
1255
+ function Y(s, t) {
1256
+ if (s instanceof w && t === "json") {
1257
+ J({
1224
1258
  ok: !1,
1225
1259
  error: {
1226
- code: t.code,
1227
- message: t.message,
1228
- hint: t.hint
1260
+ code: s.code,
1261
+ message: s.message,
1262
+ hint: s.hint
1229
1263
  },
1230
- next_commands: t.nextCommands
1264
+ next_commands: s.nextCommands
1231
1265
  });
1232
1266
  return;
1233
1267
  }
1234
- if (t instanceof g) {
1235
- const r = [`Error: ${t.message}`];
1236
- if (t.hint && r.push(` ${t.hint}`), t.nextCommands.length > 0) {
1268
+ if (s instanceof w) {
1269
+ const r = [`Error: ${s.message}`];
1270
+ if (s.hint && r.push(` ${s.hint}`), s.nextCommands.length > 0) {
1237
1271
  r.push("Next commands:");
1238
- for (const i of t.nextCommands)
1272
+ for (const i of s.nextCommands)
1239
1273
  r.push(` ${i}`);
1240
1274
  }
1241
1275
  process.stderr.write(`${r.join(`
@@ -1243,9 +1277,9 @@ function Z(t, s) {
1243
1277
  `);
1244
1278
  return;
1245
1279
  }
1246
- const e = t instanceof Error ? t.message : String(t);
1247
- if (s === "json") {
1248
- F({
1280
+ const e = s instanceof Error ? s.message : String(s);
1281
+ if (t === "json") {
1282
+ J({
1249
1283
  ok: !1,
1250
1284
  error: {
1251
1285
  code: "unexpected_error",
@@ -1258,10 +1292,10 @@ function Z(t, s) {
1258
1292
  process.stderr.write(`${e}
1259
1293
  `);
1260
1294
  }
1261
- async function Os(t) {
1262
- const s = ut(t, "json"), e = Et(t), r = tt(t), i = E(t, "--help", "-h");
1295
+ async function Ut(s) {
1296
+ const t = ps(s, "json"), e = Es(s), r = rs(s), i = $(s, "--help", "-h");
1263
1297
  if (e.command === "unknown")
1264
- throw new g({
1298
+ throw new w({
1265
1299
  code: "unknown_command",
1266
1300
  message: `Unknown command "${e.input}".`,
1267
1301
  hint: "rrskill --help",
@@ -1269,81 +1303,81 @@ async function Os(t) {
1269
1303
  });
1270
1304
  if (e.command === "help" || i) {
1271
1305
  const a = e.command === "help" ? r[1] : e.command !== "install" ? e.command : void 0;
1272
- return a && ["search", "install", "list", "upgrade", "bootstrap", "doctor", "version"].includes(a) ? (N(xs(a)), 0) : (N(Ds()), 0);
1306
+ return a && ["search", "install", "list", "upgrade", "bootstrap", "doctor", "version"].includes(a) ? (B(jt(a)), 0) : (B(Ct()), 0);
1273
1307
  }
1274
1308
  if (e.command === "doctor") {
1275
- const a = await V({ argv: t, env: process.env }), f = await Rt(
1309
+ const a = await Q({ argv: s, env: process.env }), f = await Ts(
1276
1310
  a,
1277
1311
  {
1278
- fix: E(t, "--fix"),
1279
- dryRun: E(t, "--dry-run")
1312
+ fix: $(s, "--fix"),
1313
+ dryRun: $(s, "--dry-run")
1280
1314
  }
1281
1315
  );
1282
- return m(f, s, $s), f.ok ? 0 : 1;
1316
+ return k(f, t, Ot), f.ok ? 0 : 1;
1283
1317
  }
1284
1318
  if (e.command === "version")
1285
- return m(os(), s, js), 0;
1286
- const o = await V({ argv: t, env: process.env });
1287
- if (e.command === "install" && o.host === "openclaw")
1319
+ return k(lt(), t, Et), 0;
1320
+ const n = await Q({ argv: s, env: process.env });
1321
+ if (e.command === "install" && n.host === "openclaw")
1288
1322
  try {
1289
- await R(o);
1323
+ await H(n);
1290
1324
  } catch {
1291
1325
  }
1292
- const n = ms({ config: o.config, env: o.env }), c = vs(n);
1326
+ const o = kt({ config: n.config, env: n.env }), l = Dt(o);
1293
1327
  if (e.command === "bootstrap") {
1294
- const a = await R(o);
1295
- return m(a, s, bs), a.verification.ok ? 0 : 1;
1328
+ const a = await H(n);
1329
+ return k(a, t, $t), a.verification.ok ? 0 : 1;
1296
1330
  }
1297
1331
  if (e.command === "search") {
1298
1332
  const a = r.slice(1).join(" ").trim();
1299
1333
  if (!a)
1300
- throw new g({
1334
+ throw new w({
1301
1335
  code: "missing_search_query",
1302
1336
  message: "Search query is required.",
1303
1337
  hint: "rrskill search <query>",
1304
1338
  nextCommands: ["rrskill search react"]
1305
1339
  });
1306
- const f = await rs(o, a, { searchSkills: n });
1307
- return m(f, s, Cs), 0;
1340
+ const f = await nt(n, a, { searchSkills: o });
1341
+ return k(f, t, xt), 0;
1308
1342
  }
1309
1343
  if (e.command === "install") {
1310
1344
  const a = "slug" in e ? e.slug : r[1]?.trim();
1311
1345
  if (!a)
1312
- throw new g({
1346
+ throw new w({
1313
1347
  code: "missing_skill_slug",
1314
1348
  message: "Skill slug is required.",
1315
1349
  hint: "rrskill install <slug>",
1316
1350
  nextCommands: ["rrskill install web-search"]
1317
1351
  });
1318
- const f = await ss(o, a, { searchSkills: n, downloadSkill: c });
1319
- return m(f, s, Es), 0;
1352
+ const f = await rt(n, a, { searchSkills: o, downloadSkill: l });
1353
+ return k(f, t, Lt), 0;
1320
1354
  }
1321
1355
  if (e.command === "list") {
1322
- const a = await es(o);
1323
- return m(a, s, _s), 0;
1356
+ const a = await it(n);
1357
+ return k(a, t, bt), 0;
1324
1358
  }
1325
1359
  if (e.command === "upgrade") {
1326
- const a = await is(o, { downloadSkill: c });
1327
- return m(a, s, Ls), 0;
1360
+ const a = await ot(n, { downloadSkill: l });
1361
+ return k(a, t, It), 0;
1328
1362
  }
1329
1363
  return process.stderr.write(`Command "${e.command}" is not implemented yet.
1330
1364
  `), 1;
1331
1365
  }
1332
- if (Ss()) {
1333
- const t = process.argv.slice(2);
1334
- Os(t).then((s) => {
1335
- process.exitCode = s;
1336
- }).catch((s) => {
1366
+ if (_t()) {
1367
+ const s = process.argv.slice(2);
1368
+ Ut(s).then((t) => {
1369
+ process.exitCode = t;
1370
+ }).catch((t) => {
1337
1371
  let e = "text";
1338
1372
  try {
1339
- e = ut(t, "text");
1373
+ e = ps(s, "text");
1340
1374
  } catch (r) {
1341
- Z(r, "text"), process.exitCode = 1;
1375
+ Y(r, "text"), process.exitCode = 1;
1342
1376
  return;
1343
1377
  }
1344
- Z(s, e), process.exitCode = 1;
1378
+ Y(t, e), process.exitCode = 1;
1345
1379
  });
1346
1380
  }
1347
1381
  export {
1348
- Et as buildCliArgv
1382
+ Es as buildCliArgv
1349
1383
  };