@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
|
|
1
|
+
import * as c from "node:path";
|
|
2
2
|
import * as u from "node:fs/promises";
|
|
3
|
-
import { fileURLToPath as
|
|
4
|
-
import { readFileSync as
|
|
5
|
-
import { createHash as
|
|
6
|
-
import * as
|
|
7
|
-
import * as
|
|
8
|
-
import { promisify as
|
|
9
|
-
const
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
for (let e = 0; e <
|
|
13
|
-
const r =
|
|
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 (
|
|
16
|
-
const i =
|
|
17
|
-
i && !i.startsWith("--") && !
|
|
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
|
-
|
|
20
|
+
js.has(r) || r.startsWith("--") || t.push(r);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return t;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
return e ? e === "help" ? { 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
|
|
30
|
-
const
|
|
29
|
+
async function U(s) {
|
|
30
|
+
const t = s.fsImpl ?? u;
|
|
31
31
|
try {
|
|
32
|
-
return (await
|
|
32
|
+
return (await t.stat(s.path)).isFile();
|
|
33
33
|
} catch {
|
|
34
34
|
return !1;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
async function
|
|
38
|
-
const
|
|
37
|
+
async function xs(s) {
|
|
38
|
+
const t = s.fsImpl ?? u;
|
|
39
39
|
let e;
|
|
40
40
|
try {
|
|
41
|
-
e = await
|
|
41
|
+
e = await t.readFile(s.path, "utf8");
|
|
42
42
|
} catch {
|
|
43
|
-
return { ok: !1, issue: { code: "missing_host_config", 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:
|
|
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:
|
|
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
|
|
59
|
-
let e =
|
|
60
|
-
for (const r of
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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 (
|
|
74
|
-
return r.push({ code: "unsupported_host_bootstrap", host:
|
|
75
|
-
const
|
|
76
|
-
await
|
|
77
|
-
const
|
|
78
|
-
if (!
|
|
79
|
-
return r.push(
|
|
80
|
-
const a =
|
|
81
|
-
if (
|
|
82
|
-
|
|
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
|
|
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
|
|
90
|
-
const
|
|
91
|
-
|
|
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:
|
|
94
|
-
key:
|
|
95
|
-
expected:
|
|
96
|
-
actual:
|
|
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
|
|
103
|
-
const e =
|
|
129
|
+
function T(s, t) {
|
|
130
|
+
const e = c.dirname(O(s));
|
|
104
131
|
return [
|
|
105
|
-
|
|
106
|
-
|
|
132
|
+
c.resolve(e, "..", "assets", "builtins", t),
|
|
133
|
+
c.resolve(e, "..", "..", "assets", "builtins", t)
|
|
107
134
|
];
|
|
108
135
|
}
|
|
109
|
-
async function
|
|
110
|
-
const
|
|
136
|
+
async function F(s) {
|
|
137
|
+
const t = s.fsImpl ?? u;
|
|
111
138
|
let e;
|
|
112
|
-
for (const r of
|
|
139
|
+
for (const r of s.candidates)
|
|
113
140
|
try {
|
|
114
|
-
return await
|
|
141
|
+
return await t.readFile(r, "utf8");
|
|
115
142
|
} catch (i) {
|
|
116
143
|
e = i;
|
|
117
144
|
}
|
|
118
|
-
throw new Error(`Failed to load ${
|
|
145
|
+
throw new Error(`Failed to load ${s.assetLabel} from candidates: ${s.candidates.join(", ")} (${String(e)})`);
|
|
119
146
|
}
|
|
120
|
-
async function
|
|
121
|
-
const
|
|
122
|
-
`) ?
|
|
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
|
|
152
|
+
if (await t.readFile(s.path, "utf8") === e)
|
|
126
153
|
return !1;
|
|
127
154
|
} catch {
|
|
128
155
|
}
|
|
129
|
-
return await
|
|
156
|
+
return await t.mkdir(c.dirname(s.path), { recursive: !0 }), await t.writeFile(s.path, e, "utf8"), !0;
|
|
130
157
|
}
|
|
131
|
-
const
|
|
132
|
-
function
|
|
133
|
-
return
|
|
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
|
|
136
|
-
const e =
|
|
162
|
+
async function Is(s, t = {}) {
|
|
163
|
+
const e = t.fs ?? u;
|
|
137
164
|
let r = !1;
|
|
138
|
-
for (const i of
|
|
139
|
-
const
|
|
140
|
-
candidates:
|
|
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
|
-
}),
|
|
144
|
-
r = r ||
|
|
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: [...
|
|
173
|
+
return { installed: [...V], changed: r };
|
|
147
174
|
}
|
|
148
|
-
async function $
|
|
149
|
-
const e =
|
|
150
|
-
if (
|
|
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
|
|
153
|
-
candidates:
|
|
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
|
|
157
|
-
candidates:
|
|
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
|
-
}),
|
|
161
|
-
return { installed: !0, changed:
|
|
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
|
|
164
|
-
return !!
|
|
190
|
+
function ns(s) {
|
|
191
|
+
return !!s && typeof s == "object" && !Array.isArray(s);
|
|
165
192
|
}
|
|
166
|
-
function
|
|
167
|
-
const e = t
|
|
168
|
-
if (
|
|
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
|
|
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
|
|
174
|
-
const
|
|
203
|
+
async function Ps(s) {
|
|
204
|
+
const t = s.fsImpl ?? u;
|
|
175
205
|
try {
|
|
176
|
-
const e = await
|
|
206
|
+
const e = await t.readFile(s.path, "utf8");
|
|
177
207
|
try {
|
|
178
208
|
const r = JSON.parse(e);
|
|
179
|
-
return
|
|
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
|
|
194
|
-
const
|
|
223
|
+
async function Us(s) {
|
|
224
|
+
const t = s.fsImpl ?? u, e = `${JSON.stringify(s.value, null, 2)}
|
|
195
225
|
`;
|
|
196
|
-
return
|
|
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
|
|
199
|
-
const
|
|
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 ${
|
|
232
|
+
`Invalid OpenClaw config JSON at ${s.hostConfigPath}: ${e.parseError ?? "unknown parse error"}`
|
|
203
233
|
);
|
|
204
|
-
const r = e.object, i =
|
|
205
|
-
let
|
|
206
|
-
return n.enabled !== !0 && (
|
|
207
|
-
fsImpl:
|
|
208
|
-
path:
|
|
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
|
|
214
|
-
const e =
|
|
215
|
-
let
|
|
216
|
-
return
|
|
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:
|
|
253
|
+
hostConfigRepaired: n
|
|
220
254
|
};
|
|
221
255
|
}
|
|
222
|
-
async function
|
|
223
|
-
if (
|
|
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:
|
|
264
|
+
issues: [{ code: "unsupported_host_bootstrap", host: s.host }]
|
|
231
265
|
}
|
|
232
266
|
};
|
|
233
|
-
const e =
|
|
267
|
+
const e = t.fs ?? u, r = await Rs(
|
|
234
268
|
{
|
|
235
|
-
host:
|
|
236
|
-
skillsDir:
|
|
237
|
-
pluginDir:
|
|
238
|
-
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
|
|
275
|
+
), i = await is(
|
|
242
276
|
{
|
|
243
|
-
host:
|
|
244
|
-
skillsDir:
|
|
245
|
-
pluginDir:
|
|
246
|
-
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
|
|
258
|
-
const e = new Set(
|
|
259
|
-
|
|
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
|
-
|
|
262
|
-
),
|
|
263
|
-
(
|
|
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(
|
|
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:
|
|
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:
|
|
315
|
+
path: c.join(s.skillsDir, "rrskill-preference", "SKILL.md")
|
|
282
316
|
},
|
|
283
317
|
{
|
|
284
318
|
name: "plugin_index",
|
|
285
|
-
ok: !i.has(
|
|
286
|
-
message: i.has(
|
|
287
|
-
path:
|
|
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(
|
|
292
|
-
message: i.has(
|
|
293
|
-
path:
|
|
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: !
|
|
298
|
-
message:
|
|
299
|
-
path:
|
|
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
|
|
342
|
+
async function Ts(s, t = {}, e = {}) {
|
|
309
343
|
const r = e.fs ?? u, i = {
|
|
310
|
-
skillsDir:
|
|
311
|
-
pluginDir:
|
|
312
|
-
hostConfigPath:
|
|
344
|
+
skillsDir: s.skillsDir,
|
|
345
|
+
pluginDir: s.pluginDir,
|
|
346
|
+
hostConfigPath: s.hostConfigPath
|
|
313
347
|
};
|
|
314
|
-
if (
|
|
348
|
+
if (s.host !== "openclaw")
|
|
315
349
|
return {
|
|
316
350
|
ok: !0,
|
|
317
|
-
host:
|
|
351
|
+
host: s.host,
|
|
318
352
|
bootstrapSupported: !1,
|
|
319
353
|
fixed: !1,
|
|
320
|
-
dryRun:
|
|
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: `${
|
|
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
|
|
371
|
+
const n = await is(s, {
|
|
338
372
|
fs: r
|
|
339
373
|
});
|
|
340
|
-
if (
|
|
374
|
+
if (n.ok)
|
|
341
375
|
return {
|
|
342
376
|
ok: !0,
|
|
343
|
-
host:
|
|
377
|
+
host: s.host,
|
|
344
378
|
bootstrapSupported: !0,
|
|
345
379
|
fixed: !1,
|
|
346
|
-
dryRun:
|
|
347
|
-
checks:
|
|
380
|
+
dryRun: t.dryRun ?? !1,
|
|
381
|
+
checks: b(s, []),
|
|
348
382
|
issues: [],
|
|
349
383
|
nextCommands: [],
|
|
350
384
|
paths: i,
|
|
351
|
-
verification:
|
|
385
|
+
verification: n
|
|
352
386
|
};
|
|
353
|
-
if (
|
|
387
|
+
if (t.dryRun)
|
|
354
388
|
return {
|
|
355
389
|
ok: !1,
|
|
356
|
-
host:
|
|
390
|
+
host: s.host,
|
|
357
391
|
bootstrapSupported: !0,
|
|
358
392
|
fixed: !1,
|
|
359
393
|
dryRun: !0,
|
|
360
|
-
checks:
|
|
361
|
-
issues:
|
|
394
|
+
checks: b(s, n.issues),
|
|
395
|
+
issues: n.issues,
|
|
362
396
|
nextCommands: ["rrskill bootstrap --host openclaw"],
|
|
363
397
|
paths: i,
|
|
364
|
-
verification:
|
|
398
|
+
verification: n
|
|
365
399
|
};
|
|
366
|
-
if (
|
|
367
|
-
const
|
|
400
|
+
if (t.fix) {
|
|
401
|
+
const o = await H(s, {
|
|
368
402
|
fs: r
|
|
369
403
|
});
|
|
370
404
|
return {
|
|
371
|
-
ok:
|
|
372
|
-
host:
|
|
405
|
+
ok: o.verification.ok,
|
|
406
|
+
host: s.host,
|
|
373
407
|
bootstrapSupported: !0,
|
|
374
408
|
fixed: !0,
|
|
375
409
|
dryRun: !1,
|
|
376
|
-
checks:
|
|
377
|
-
|
|
378
|
-
|
|
410
|
+
checks: b(
|
|
411
|
+
s,
|
|
412
|
+
o.verification.ok ? [] : o.verification.issues
|
|
379
413
|
),
|
|
380
|
-
issues:
|
|
381
|
-
nextCommands:
|
|
414
|
+
issues: o.verification.ok ? [] : o.verification.issues,
|
|
415
|
+
nextCommands: o.verification.ok ? [] : ["rrskill bootstrap --host openclaw"],
|
|
382
416
|
paths: i,
|
|
383
|
-
verification:
|
|
417
|
+
verification: o.verification
|
|
384
418
|
};
|
|
385
419
|
}
|
|
386
420
|
return {
|
|
387
421
|
ok: !1,
|
|
388
|
-
host:
|
|
422
|
+
host: s.host,
|
|
389
423
|
bootstrapSupported: !0,
|
|
390
424
|
fixed: !1,
|
|
391
425
|
dryRun: !1,
|
|
392
|
-
checks:
|
|
393
|
-
issues:
|
|
426
|
+
checks: b(s, n.issues),
|
|
427
|
+
issues: n.issues,
|
|
394
428
|
nextCommands: ["rrskill bootstrap --host openclaw"],
|
|
395
429
|
paths: i,
|
|
396
|
-
verification:
|
|
430
|
+
verification: n
|
|
397
431
|
};
|
|
398
432
|
}
|
|
399
|
-
function
|
|
400
|
-
return
|
|
433
|
+
function Fs(s) {
|
|
434
|
+
return s.HOME ?? s.USERPROFILE ?? process.env.HOME ?? process.env.USERPROFILE ?? process.cwd();
|
|
401
435
|
}
|
|
402
|
-
function
|
|
403
|
-
const e =
|
|
436
|
+
function G(s, t) {
|
|
437
|
+
const e = s?.trim();
|
|
404
438
|
if (e)
|
|
405
|
-
return e === "~" ?
|
|
439
|
+
return e === "~" ? t : e.startsWith("~/") ? c.resolve(t, e.slice(2)) : c.resolve(e);
|
|
406
440
|
}
|
|
407
|
-
function
|
|
408
|
-
for (const e of
|
|
409
|
-
const r =
|
|
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
|
|
415
|
-
if (typeof
|
|
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 ${
|
|
451
|
+
`Invalid rrskill config at ${t}: root must be a JSON object`
|
|
418
452
|
);
|
|
419
|
-
return
|
|
453
|
+
return s;
|
|
420
454
|
}
|
|
421
|
-
async function
|
|
422
|
-
const
|
|
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 =
|
|
458
|
+
const r = await u.readFile(e, "utf8"), i = Ns(JSON.parse(r), e);
|
|
425
459
|
return {
|
|
426
460
|
configPath: e,
|
|
427
|
-
host:
|
|
428
|
-
stateDir:
|
|
429
|
-
|
|
430
|
-
|
|
461
|
+
host: A(i, ["host"]),
|
|
462
|
+
stateDir: G(
|
|
463
|
+
A(i, ["stateDir", "state_dir"]),
|
|
464
|
+
t
|
|
431
465
|
),
|
|
432
|
-
skillsSearchUrl:
|
|
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
|
|
479
|
+
const zs = "openclaw", Ms = "--host", Z = {
|
|
446
480
|
"--openclaw": "openclaw",
|
|
447
481
|
"--codex": "codex",
|
|
448
482
|
"--claude-code": "claude-code"
|
|
449
|
-
},
|
|
483
|
+
}, os = [
|
|
450
484
|
"openclaw",
|
|
451
485
|
"codex",
|
|
452
486
|
"claude-code"
|
|
453
|
-
],
|
|
454
|
-
function
|
|
455
|
-
if (!
|
|
487
|
+
], Js = new Set(os), Bs = new Set(ts);
|
|
488
|
+
function qs(s) {
|
|
489
|
+
if (!s)
|
|
456
490
|
return;
|
|
457
|
-
const
|
|
458
|
-
if (
|
|
459
|
-
return
|
|
491
|
+
const t = s.trim().toLowerCase();
|
|
492
|
+
if (t && Js.has(t))
|
|
493
|
+
return t;
|
|
460
494
|
}
|
|
461
|
-
function
|
|
462
|
-
if (
|
|
495
|
+
function R(s, t) {
|
|
496
|
+
if (s === void 0)
|
|
463
497
|
return;
|
|
464
|
-
const e =
|
|
498
|
+
const e = qs(s);
|
|
465
499
|
if (e)
|
|
466
500
|
return e;
|
|
467
|
-
const r =
|
|
501
|
+
const r = s.trim();
|
|
468
502
|
if (r)
|
|
469
503
|
throw new Error(
|
|
470
|
-
`Unsupported host "${r}" from ${
|
|
504
|
+
`Unsupported host "${r}" from ${t}. Supported hosts: ${os.join(", ")}`
|
|
471
505
|
);
|
|
472
506
|
}
|
|
473
|
-
function
|
|
474
|
-
const
|
|
475
|
-
if (
|
|
507
|
+
function Ks(s) {
|
|
508
|
+
const t = s.indexOf(Ms);
|
|
509
|
+
if (t < 0)
|
|
476
510
|
return;
|
|
477
|
-
const e = t
|
|
478
|
-
if (!(!e || e.startsWith("--") ||
|
|
511
|
+
const e = s[t + 1];
|
|
512
|
+
if (!(!e || e.startsWith("--") || Bs.has(e)))
|
|
479
513
|
return e;
|
|
480
514
|
}
|
|
481
|
-
function
|
|
482
|
-
const
|
|
483
|
-
if (
|
|
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(
|
|
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
|
|
491
|
-
const
|
|
492
|
-
|
|
524
|
+
function Vs(s) {
|
|
525
|
+
const t = Ws(s.argv), e = R(
|
|
526
|
+
Ks(s.argv),
|
|
493
527
|
"--host"
|
|
494
528
|
);
|
|
495
|
-
if (
|
|
529
|
+
if (t && e && t !== e)
|
|
496
530
|
throw new Error(
|
|
497
|
-
`Conflicting host flags: ${
|
|
531
|
+
`Conflicting host flags: ${t} vs ${e}`
|
|
498
532
|
);
|
|
499
|
-
const r = e ??
|
|
533
|
+
const r = e ?? t;
|
|
500
534
|
if (r)
|
|
501
535
|
return r;
|
|
502
|
-
const i =
|
|
536
|
+
const i = R(s.env.RRSKILL_HOST, "RRSKILL_HOST");
|
|
503
537
|
if (i)
|
|
504
538
|
return i;
|
|
505
|
-
const
|
|
506
|
-
return
|
|
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
|
|
509
|
-
const
|
|
510
|
-
return { homeDir:
|
|
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
|
|
546
|
+
const Zs = {
|
|
513
547
|
name: "openclaw",
|
|
514
|
-
getDefaultPaths({ homeDir:
|
|
548
|
+
getDefaultPaths({ homeDir: s }) {
|
|
515
549
|
return {
|
|
516
|
-
skillsDir: `${
|
|
517
|
-
pluginDir: `${
|
|
518
|
-
hostConfigPath: `${
|
|
550
|
+
skillsDir: `${s}/.openclaw/workspace/skills`,
|
|
551
|
+
pluginDir: `${s}/.openclaw/extensions/rrskill`,
|
|
552
|
+
hostConfigPath: `${s}/.openclaw/openclaw.json`
|
|
519
553
|
};
|
|
520
554
|
}
|
|
521
|
-
},
|
|
555
|
+
}, Qs = {
|
|
522
556
|
name: "codex",
|
|
523
|
-
getDefaultPaths({ homeDir:
|
|
524
|
-
const e =
|
|
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: `${
|
|
562
|
+
hostConfigPath: `${s}/.codex/config.toml`
|
|
529
563
|
};
|
|
530
564
|
}
|
|
531
|
-
},
|
|
565
|
+
}, Xs = {
|
|
532
566
|
name: "claude-code",
|
|
533
|
-
getDefaultPaths({ homeDir:
|
|
534
|
-
const e =
|
|
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: `${
|
|
572
|
+
hostConfigPath: `${s}/.claude/settings.json`
|
|
539
573
|
};
|
|
540
574
|
}
|
|
541
575
|
};
|
|
542
|
-
async function
|
|
543
|
-
const
|
|
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:
|
|
546
|
-
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:
|
|
588
|
+
config: t
|
|
555
589
|
};
|
|
556
590
|
}
|
|
557
|
-
const
|
|
558
|
-
function
|
|
591
|
+
const Ys = ".rrskill_lock.json";
|
|
592
|
+
function z() {
|
|
559
593
|
return { version: 1, skills: {} };
|
|
560
594
|
}
|
|
561
|
-
function
|
|
562
|
-
return
|
|
595
|
+
function as(s) {
|
|
596
|
+
return c.join(s, Ys);
|
|
563
597
|
}
|
|
564
|
-
function
|
|
565
|
-
const e =
|
|
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="${
|
|
601
|
+
throw new Error(`Refusing to write outside skillsDir: slug="${t}"`);
|
|
568
602
|
return r;
|
|
569
603
|
}
|
|
570
|
-
function
|
|
571
|
-
return typeof
|
|
604
|
+
function D(s) {
|
|
605
|
+
return typeof s == "object" && s !== null;
|
|
572
606
|
}
|
|
573
|
-
function
|
|
574
|
-
if (!
|
|
575
|
-
const e = typeof
|
|
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: (
|
|
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:
|
|
613
|
+
return { slug: e, installedAt: r, source: n };
|
|
580
614
|
}
|
|
581
|
-
function
|
|
582
|
-
if (!
|
|
583
|
-
if (
|
|
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 [
|
|
586
|
-
const
|
|
587
|
-
|
|
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
|
|
592
|
-
if (
|
|
593
|
-
return
|
|
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,
|
|
596
|
-
const
|
|
597
|
-
|
|
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
|
|
602
|
-
const
|
|
635
|
+
async function q(s) {
|
|
636
|
+
const t = as(s.skillsDir);
|
|
603
637
|
try {
|
|
604
|
-
const e = await
|
|
605
|
-
return
|
|
638
|
+
const e = await s.fs.readFile(t, "utf8"), r = JSON.parse(e);
|
|
639
|
+
return st(r);
|
|
606
640
|
} catch (e) {
|
|
607
|
-
if ((
|
|
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
|
|
612
|
-
const
|
|
613
|
-
await
|
|
614
|
-
const e = `${
|
|
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
|
|
650
|
+
await s.fs.writeFile(e, r, "utf8"), await s.fs.rename(e, t);
|
|
617
651
|
}
|
|
618
|
-
function
|
|
652
|
+
function us(s, t) {
|
|
619
653
|
return {
|
|
620
654
|
version: 1,
|
|
621
655
|
skills: {
|
|
622
|
-
...
|
|
623
|
-
[
|
|
656
|
+
...s.skills,
|
|
657
|
+
[t.slug]: t
|
|
624
658
|
}
|
|
625
659
|
};
|
|
626
660
|
}
|
|
627
|
-
function
|
|
661
|
+
function tt() {
|
|
628
662
|
return /* @__PURE__ */ new Date();
|
|
629
663
|
}
|
|
630
|
-
async function
|
|
631
|
-
const
|
|
632
|
-
await
|
|
633
|
-
const e =
|
|
634
|
-
await
|
|
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:
|
|
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
|
|
642
|
-
const r = e.fs ?? u, i = e.now ??
|
|
643
|
-
let
|
|
644
|
-
if (e.searchSkills && (
|
|
645
|
-
throw new Error(`No exact registry match for slug "${
|
|
646
|
-
const
|
|
647
|
-
let
|
|
648
|
-
e.downloadSkill ? (await r.mkdir(
|
|
649
|
-
const a = await
|
|
650
|
-
slug:
|
|
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:
|
|
686
|
+
source: { type: "registry", version: l }
|
|
653
687
|
});
|
|
654
|
-
return await
|
|
655
|
-
slug:
|
|
656
|
-
targetDir:
|
|
657
|
-
registryMatch:
|
|
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
|
|
661
|
-
const 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
|
|
665
|
-
return e.searchSkills({ query:
|
|
698
|
+
async function nt(s, t, e) {
|
|
699
|
+
return e.searchSkills({ query: t });
|
|
666
700
|
}
|
|
667
|
-
async function
|
|
668
|
-
const e =
|
|
669
|
-
if (!
|
|
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
|
|
672
|
-
let
|
|
673
|
-
for (const a of
|
|
674
|
-
const f =
|
|
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
|
|
677
|
-
|
|
678
|
-
const
|
|
679
|
-
|
|
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 ??
|
|
718
|
+
version: d.version ?? p?.source?.version
|
|
685
719
|
}
|
|
686
|
-
}), await
|
|
720
|
+
}), await cs({ skillsDir: s.skillsDir, fs: e, lockfile: l });
|
|
687
721
|
}
|
|
688
|
-
return { upgraded:
|
|
722
|
+
return { upgraded: o };
|
|
689
723
|
}
|
|
690
|
-
function
|
|
691
|
-
let
|
|
724
|
+
function at(s) {
|
|
725
|
+
let t = c.dirname(O(s));
|
|
692
726
|
for (; ; ) {
|
|
693
|
-
const e =
|
|
727
|
+
const e = c.join(t, "package.json");
|
|
694
728
|
try {
|
|
695
|
-
return JSON.parse(
|
|
729
|
+
return JSON.parse(ws(e, "utf8"));
|
|
696
730
|
} catch {
|
|
697
|
-
const r =
|
|
698
|
-
if (r ===
|
|
731
|
+
const r = c.dirname(t);
|
|
732
|
+
if (r === t)
|
|
699
733
|
return {};
|
|
700
|
-
|
|
734
|
+
t = r;
|
|
701
735
|
}
|
|
702
736
|
}
|
|
703
737
|
}
|
|
704
|
-
function
|
|
705
|
-
const
|
|
738
|
+
function lt(s = {}) {
|
|
739
|
+
const t = at(import.meta.url);
|
|
706
740
|
return {
|
|
707
|
-
packageName:
|
|
708
|
-
version:
|
|
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
|
|
714
|
-
function
|
|
715
|
-
return typeof
|
|
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
|
|
718
|
-
for (const e of
|
|
719
|
-
const r =
|
|
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
|
|
758
|
+
function P(s) {
|
|
725
759
|
try {
|
|
726
|
-
return new URL(
|
|
760
|
+
return new URL(s);
|
|
727
761
|
} catch {
|
|
728
762
|
return;
|
|
729
763
|
}
|
|
730
764
|
}
|
|
731
|
-
function
|
|
732
|
-
const i =
|
|
733
|
-
return
|
|
734
|
-
(
|
|
735
|
-
) ||
|
|
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
|
|
738
|
-
const
|
|
739
|
-
if (
|
|
740
|
-
const r = await fetch(
|
|
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 ||
|
|
785
|
+
reference: r.url || s
|
|
752
786
|
};
|
|
753
787
|
}
|
|
754
|
-
if (
|
|
755
|
-
const r =
|
|
788
|
+
if (t?.protocol === "file:") {
|
|
789
|
+
const r = O(t);
|
|
756
790
|
return {
|
|
757
791
|
payload: await u.readFile(r, "utf8"),
|
|
758
|
-
reference:
|
|
792
|
+
reference: t.toString()
|
|
759
793
|
};
|
|
760
794
|
}
|
|
761
|
-
const e =
|
|
795
|
+
const e = c.resolve(s);
|
|
762
796
|
return {
|
|
763
797
|
payload: await u.readFile(e, "utf8"),
|
|
764
|
-
reference:
|
|
798
|
+
reference: ks(e).toString()
|
|
765
799
|
};
|
|
766
800
|
}
|
|
767
|
-
function
|
|
768
|
-
if (
|
|
801
|
+
function ht(s, t) {
|
|
802
|
+
if (s)
|
|
769
803
|
try {
|
|
770
|
-
return new URL(
|
|
804
|
+
return new URL(s, t).toString();
|
|
771
805
|
} catch {
|
|
772
806
|
return;
|
|
773
807
|
}
|
|
774
808
|
}
|
|
775
|
-
function
|
|
776
|
-
const r =
|
|
809
|
+
function fs(s, t, e) {
|
|
810
|
+
const r = t?.trim().toLowerCase();
|
|
777
811
|
if (!r)
|
|
778
812
|
return;
|
|
779
|
-
const i =
|
|
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
|
|
786
|
-
const e =
|
|
819
|
+
function gt(s, t) {
|
|
820
|
+
const e = h(s, ["slug"]);
|
|
787
821
|
if (!e)
|
|
788
822
|
return;
|
|
789
|
-
const r =
|
|
790
|
-
|
|
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
|
-
]) ??
|
|
796
|
-
|
|
829
|
+
]) ?? h(s, ["skillUrl", "downloadUrl", "packageUrl", "url"]),
|
|
830
|
+
t
|
|
797
831
|
);
|
|
798
832
|
return {
|
|
799
833
|
slug: e,
|
|
800
|
-
title:
|
|
801
|
-
description:
|
|
802
|
-
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:
|
|
805
|
-
source:
|
|
838
|
+
sha256: h(r, ["sha256"]) ?? h(s, ["sha256", "checksum"]),
|
|
839
|
+
source: h(s, ["source", "platform"])
|
|
806
840
|
};
|
|
807
841
|
}
|
|
808
|
-
function
|
|
842
|
+
function mt(s, t, e) {
|
|
809
843
|
let r;
|
|
810
844
|
try {
|
|
811
|
-
r = JSON.parse(
|
|
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 (!
|
|
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 =
|
|
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
|
|
829
|
-
|
|
830
|
-
),
|
|
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(
|
|
867
|
+
(d) => d.toLowerCase().includes(n)
|
|
834
868
|
) : !0);
|
|
835
|
-
return { query: e, results:
|
|
836
|
-
}
|
|
837
|
-
function
|
|
838
|
-
return async ({ query:
|
|
839
|
-
const e =
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
), { payload: r, reference: i } = await
|
|
845
|
-
return
|
|
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
|
|
882
|
+
async function ds(s, t) {
|
|
849
883
|
const e = [];
|
|
850
|
-
let
|
|
851
|
-
for (let f =
|
|
852
|
-
if (
|
|
853
|
-
|
|
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 (
|
|
890
|
+
if (o < 0)
|
|
857
891
|
throw new Error("Downloaded skill package is not a valid zip archive.");
|
|
858
|
-
const
|
|
859
|
-
let a =
|
|
860
|
-
await u.mkdir(
|
|
861
|
-
for (let f = 0; f <
|
|
862
|
-
if (
|
|
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 =
|
|
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 +
|
|
903
|
+
a + 46 + m
|
|
870
904
|
);
|
|
871
|
-
a += 46 +
|
|
872
|
-
const
|
|
873
|
-
if (!
|
|
874
|
-
throw new Error(`Unsafe zip path entry detected: ${
|
|
875
|
-
const
|
|
876
|
-
if (
|
|
877
|
-
throw new Error(`Unsafe zip path entry detected: ${
|
|
878
|
-
if (
|
|
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
|
|
883
|
-
|
|
884
|
-
|
|
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 (
|
|
887
|
-
await u.mkdir(
|
|
920
|
+
if (y.endsWith("/")) {
|
|
921
|
+
await u.mkdir(_, { recursive: !0 });
|
|
888
922
|
continue;
|
|
889
923
|
}
|
|
890
|
-
let
|
|
924
|
+
let L;
|
|
891
925
|
if (d === 0)
|
|
892
|
-
|
|
926
|
+
L = Buffer.from(W);
|
|
893
927
|
else if (d === 8)
|
|
894
|
-
|
|
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 (
|
|
900
|
-
throw new Error(`Zip entry size mismatch for ${
|
|
901
|
-
await u.mkdir(
|
|
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
|
|
906
|
-
await u.rm(
|
|
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
|
|
909
|
-
if ((await u.stat(
|
|
910
|
-
return await
|
|
911
|
-
const i = await u.readFile(
|
|
912
|
-
|
|
913
|
-
const
|
|
914
|
-
|
|
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
|
|
918
|
-
return await
|
|
951
|
+
const o = await ds(i, n);
|
|
952
|
+
return await M(n, t), o;
|
|
919
953
|
} finally {
|
|
920
|
-
await u.rm(
|
|
954
|
+
await u.rm(n, { recursive: !0, force: !0 });
|
|
921
955
|
}
|
|
922
956
|
}
|
|
923
|
-
async function
|
|
924
|
-
const r = await fetch(
|
|
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
|
-
|
|
935
|
-
const
|
|
936
|
-
|
|
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
|
|
940
|
-
return await
|
|
973
|
+
const o = await ds(i, n);
|
|
974
|
+
return await M(n, t), o;
|
|
941
975
|
} finally {
|
|
942
|
-
await u.rm(
|
|
976
|
+
await u.rm(n, { recursive: !0, force: !0 });
|
|
943
977
|
}
|
|
944
978
|
}
|
|
945
|
-
async function
|
|
946
|
-
const r = (await
|
|
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 "${
|
|
982
|
+
throw new Error(`No exact registry match for slug "${t}"`);
|
|
949
983
|
return r;
|
|
950
984
|
}
|
|
951
|
-
async function
|
|
952
|
-
const e =
|
|
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 "${
|
|
989
|
+
`Registry skill "${t.slug}" does not define a skillUrl/packageUrl`
|
|
956
990
|
);
|
|
957
|
-
const i =
|
|
991
|
+
const i = P(r), n = e.sha256, o = i?.protocol === "http:" || i?.protocol === "https:" ? await yt(
|
|
958
992
|
r,
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
) : await
|
|
962
|
-
i?.protocol === "file:" ?
|
|
963
|
-
|
|
964
|
-
|
|
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:
|
|
968
|
-
targetDir:
|
|
969
|
-
writtenFiles:
|
|
1001
|
+
slug: t.slug,
|
|
1002
|
+
targetDir: t.targetDir,
|
|
1003
|
+
writtenFiles: o,
|
|
970
1004
|
version: e.version
|
|
971
1005
|
};
|
|
972
1006
|
}
|
|
973
|
-
function
|
|
974
|
-
return async (
|
|
1007
|
+
function Dt(s) {
|
|
1008
|
+
return async (t) => St(s, t);
|
|
975
1009
|
}
|
|
976
|
-
class
|
|
1010
|
+
class w extends Error {
|
|
977
1011
|
code;
|
|
978
1012
|
hint;
|
|
979
1013
|
nextCommands;
|
|
980
|
-
constructor(
|
|
981
|
-
super(
|
|
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
|
|
985
|
-
const
|
|
986
|
-
return
|
|
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
|
|
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
|
|
1025
|
-
const
|
|
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
|
|
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
|
-
...
|
|
1078
|
+
...t
|
|
1045
1079
|
].join(`
|
|
1046
|
-
`) :
|
|
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
|
-
...
|
|
1090
|
+
...t
|
|
1057
1091
|
].join(`
|
|
1058
|
-
`) :
|
|
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
|
-
...
|
|
1101
|
+
...t
|
|
1068
1102
|
].join(`
|
|
1069
|
-
`) :
|
|
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
|
-
...
|
|
1112
|
+
...t
|
|
1079
1113
|
].join(`
|
|
1080
|
-
`) :
|
|
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
|
-
...
|
|
1123
|
+
...t
|
|
1090
1124
|
].join(`
|
|
1091
|
-
`) :
|
|
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
|
-
...
|
|
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
|
-
...
|
|
1150
|
+
...t
|
|
1117
1151
|
].join(`
|
|
1118
1152
|
`);
|
|
1119
1153
|
}
|
|
1120
|
-
function
|
|
1121
|
-
process.stdout.write(`${JSON.stringify(
|
|
1154
|
+
function J(s) {
|
|
1155
|
+
process.stdout.write(`${JSON.stringify(s, null, 2)}
|
|
1122
1156
|
`);
|
|
1123
1157
|
}
|
|
1124
|
-
function
|
|
1125
|
-
process.stdout.write(
|
|
1126
|
-
`) ?
|
|
1158
|
+
function B(s) {
|
|
1159
|
+
process.stdout.write(s.endsWith(`
|
|
1160
|
+
`) ? s : `${s}
|
|
1127
1161
|
`);
|
|
1128
1162
|
}
|
|
1129
|
-
function
|
|
1130
|
-
if (
|
|
1131
|
-
|
|
1163
|
+
function k(s, t, e) {
|
|
1164
|
+
if (t === "json") {
|
|
1165
|
+
J(s);
|
|
1132
1166
|
return;
|
|
1133
1167
|
}
|
|
1134
|
-
|
|
1168
|
+
B(e(s));
|
|
1135
1169
|
}
|
|
1136
|
-
function
|
|
1170
|
+
function Et(s) {
|
|
1137
1171
|
return [
|
|
1138
|
-
`${
|
|
1139
|
-
`Update via ${
|
|
1140
|
-
...
|
|
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
|
|
1145
|
-
return
|
|
1146
|
-
const e =
|
|
1147
|
-
return `${
|
|
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
|
|
1152
|
-
const
|
|
1153
|
-
return
|
|
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
|
|
1157
|
-
return
|
|
1190
|
+
function bt(s) {
|
|
1191
|
+
return s.length === 0 ? "No skills installed." : s.join(`
|
|
1158
1192
|
`);
|
|
1159
1193
|
}
|
|
1160
|
-
function
|
|
1161
|
-
return
|
|
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
|
|
1165
|
-
const
|
|
1166
|
-
|
|
1167
|
-
`Builtins installed: ${
|
|
1168
|
-
`Plugin installed: ${
|
|
1169
|
-
`Host config repaired: ${
|
|
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
|
|
1172
|
-
...
|
|
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
|
-
),
|
|
1209
|
+
), t.join(`
|
|
1176
1210
|
`);
|
|
1177
1211
|
}
|
|
1178
|
-
function
|
|
1179
|
-
const
|
|
1180
|
-
|
|
1181
|
-
`Bootstrap supported: ${
|
|
1182
|
-
`Fixed: ${
|
|
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
|
|
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
|
|
1188
|
-
return
|
|
1221
|
+
function $(s, ...t) {
|
|
1222
|
+
return s.some((e) => t.includes(e));
|
|
1189
1223
|
}
|
|
1190
|
-
function
|
|
1191
|
-
const e =
|
|
1224
|
+
function Pt(s, t) {
|
|
1225
|
+
const e = s.indexOf(t);
|
|
1192
1226
|
if (e < 0)
|
|
1193
1227
|
return;
|
|
1194
|
-
const r =
|
|
1228
|
+
const r = s[e + 1];
|
|
1195
1229
|
if (!(!r || r.startsWith("--")))
|
|
1196
1230
|
return r;
|
|
1197
1231
|
}
|
|
1198
|
-
function
|
|
1199
|
-
if (
|
|
1232
|
+
function ps(s, t = "json") {
|
|
1233
|
+
if ($(s, "--json"))
|
|
1200
1234
|
return "json";
|
|
1201
|
-
const e =
|
|
1235
|
+
const e = Pt(s, "--output");
|
|
1202
1236
|
if (!e) {
|
|
1203
|
-
if (
|
|
1204
|
-
throw new
|
|
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
|
|
1244
|
+
return t;
|
|
1211
1245
|
}
|
|
1212
1246
|
if (e === "json" || e === "text")
|
|
1213
1247
|
return e;
|
|
1214
|
-
throw new
|
|
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
|
|
1222
|
-
if (
|
|
1223
|
-
|
|
1255
|
+
function Y(s, t) {
|
|
1256
|
+
if (s instanceof w && t === "json") {
|
|
1257
|
+
J({
|
|
1224
1258
|
ok: !1,
|
|
1225
1259
|
error: {
|
|
1226
|
-
code:
|
|
1227
|
-
message:
|
|
1228
|
-
hint:
|
|
1260
|
+
code: s.code,
|
|
1261
|
+
message: s.message,
|
|
1262
|
+
hint: s.hint
|
|
1229
1263
|
},
|
|
1230
|
-
next_commands:
|
|
1264
|
+
next_commands: s.nextCommands
|
|
1231
1265
|
});
|
|
1232
1266
|
return;
|
|
1233
1267
|
}
|
|
1234
|
-
if (
|
|
1235
|
-
const r = [`Error: ${
|
|
1236
|
-
if (
|
|
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
|
|
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 =
|
|
1247
|
-
if (
|
|
1248
|
-
|
|
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
|
|
1262
|
-
const
|
|
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
|
|
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) ? (
|
|
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
|
|
1309
|
+
const a = await Q({ argv: s, env: process.env }), f = await Ts(
|
|
1276
1310
|
a,
|
|
1277
1311
|
{
|
|
1278
|
-
fix:
|
|
1279
|
-
dryRun:
|
|
1312
|
+
fix: $(s, "--fix"),
|
|
1313
|
+
dryRun: $(s, "--dry-run")
|
|
1280
1314
|
}
|
|
1281
1315
|
);
|
|
1282
|
-
return
|
|
1316
|
+
return k(f, t, Ot), f.ok ? 0 : 1;
|
|
1283
1317
|
}
|
|
1284
1318
|
if (e.command === "version")
|
|
1285
|
-
return
|
|
1286
|
-
const
|
|
1287
|
-
if (e.command === "install" &&
|
|
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
|
|
1323
|
+
await H(n);
|
|
1290
1324
|
} catch {
|
|
1291
1325
|
}
|
|
1292
|
-
const
|
|
1326
|
+
const o = kt({ config: n.config, env: n.env }), l = Dt(o);
|
|
1293
1327
|
if (e.command === "bootstrap") {
|
|
1294
|
-
const a = await
|
|
1295
|
-
return
|
|
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
|
|
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
|
|
1307
|
-
return
|
|
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
|
|
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
|
|
1319
|
-
return
|
|
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
|
|
1323
|
-
return
|
|
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
|
|
1327
|
-
return
|
|
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 (
|
|
1333
|
-
const
|
|
1334
|
-
|
|
1335
|
-
process.exitCode =
|
|
1336
|
-
}).catch((
|
|
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 =
|
|
1373
|
+
e = ps(s, "text");
|
|
1340
1374
|
} catch (r) {
|
|
1341
|
-
|
|
1375
|
+
Y(r, "text"), process.exitCode = 1;
|
|
1342
1376
|
return;
|
|
1343
1377
|
}
|
|
1344
|
-
|
|
1378
|
+
Y(t, e), process.exitCode = 1;
|
|
1345
1379
|
});
|
|
1346
1380
|
}
|
|
1347
1381
|
export {
|
|
1348
|
-
|
|
1382
|
+
Es as buildCliArgv
|
|
1349
1383
|
};
|