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