@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
|
|
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
|
-
function
|
|
68
|
-
return Array.isArray(
|
|
67
|
+
function Ls(s, t) {
|
|
68
|
+
return Array.isArray(s) && s.some((e) => e === t);
|
|
69
69
|
}
|
|
70
|
-
async function
|
|
71
|
-
const e =
|
|
72
|
-
for (const
|
|
73
|
-
const
|
|
74
|
-
await
|
|
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 (
|
|
77
|
-
return r.push({ code: "unsupported_host_bootstrap", host:
|
|
78
|
-
const n =
|
|
79
|
-
await
|
|
80
|
-
const
|
|
81
|
-
if (!
|
|
82
|
-
return r.push(
|
|
83
|
-
const a =
|
|
84
|
-
if (
|
|
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:
|
|
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:
|
|
109
|
+
r.push({ code: "missing_host_plugin_entry", path: s.hostConfigPath });
|
|
92
110
|
else {
|
|
93
|
-
const
|
|
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
|
|
99
|
-
const
|
|
100
|
-
|
|
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:
|
|
103
|
-
key:
|
|
104
|
-
expected:
|
|
105
|
-
actual:
|
|
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
|
|
112
|
-
const e =
|
|
129
|
+
function T(s, t) {
|
|
130
|
+
const e = c.dirname(O(s));
|
|
113
131
|
return [
|
|
114
|
-
|
|
115
|
-
|
|
132
|
+
c.resolve(e, "..", "assets", "builtins", t),
|
|
133
|
+
c.resolve(e, "..", "..", "assets", "builtins", t)
|
|
116
134
|
];
|
|
117
135
|
}
|
|
118
|
-
async function
|
|
119
|
-
const
|
|
136
|
+
async function F(s) {
|
|
137
|
+
const t = s.fsImpl ?? u;
|
|
120
138
|
let e;
|
|
121
|
-
for (const r of
|
|
139
|
+
for (const r of s.candidates)
|
|
122
140
|
try {
|
|
123
|
-
return await
|
|
141
|
+
return await t.readFile(r, "utf8");
|
|
124
142
|
} catch (i) {
|
|
125
143
|
e = i;
|
|
126
144
|
}
|
|
127
|
-
throw new Error(`Failed to load ${
|
|
145
|
+
throw new Error(`Failed to load ${s.assetLabel} from candidates: ${s.candidates.join(", ")} (${String(e)})`);
|
|
128
146
|
}
|
|
129
|
-
async function
|
|
130
|
-
const
|
|
131
|
-
`) ?
|
|
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
|
|
152
|
+
if (await t.readFile(s.path, "utf8") === e)
|
|
135
153
|
return !1;
|
|
136
154
|
} catch {
|
|
137
155
|
}
|
|
138
|
-
return await
|
|
156
|
+
return await t.mkdir(c.dirname(s.path), { recursive: !0 }), await t.writeFile(s.path, e, "utf8"), !0;
|
|
139
157
|
}
|
|
140
|
-
const
|
|
141
|
-
function
|
|
142
|
-
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";
|
|
143
161
|
}
|
|
144
|
-
async function
|
|
145
|
-
const e =
|
|
162
|
+
async function Is(s, t = {}) {
|
|
163
|
+
const e = t.fs ?? u;
|
|
146
164
|
let r = !1;
|
|
147
|
-
for (const i of
|
|
148
|
-
const n = await
|
|
149
|
-
candidates:
|
|
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 =
|
|
153
|
-
r = r ||
|
|
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: [...
|
|
173
|
+
return { installed: [...V], changed: r };
|
|
156
174
|
}
|
|
157
|
-
async function
|
|
158
|
-
const e =
|
|
159
|
-
if (
|
|
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
|
|
162
|
-
candidates:
|
|
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
|
|
166
|
-
candidates:
|
|
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 =
|
|
170
|
-
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 };
|
|
171
189
|
}
|
|
172
|
-
function
|
|
173
|
-
return !!
|
|
190
|
+
function ns(s) {
|
|
191
|
+
return !!s && typeof s == "object" && !Array.isArray(s);
|
|
174
192
|
}
|
|
175
|
-
function
|
|
176
|
-
const e = t
|
|
177
|
-
if (
|
|
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
|
|
198
|
+
return s[t] = r, r;
|
|
181
199
|
}
|
|
182
|
-
function
|
|
183
|
-
return Array.isArray(
|
|
200
|
+
function Os(s) {
|
|
201
|
+
return Array.isArray(s) ? s.filter((t) => typeof t == "string") : [];
|
|
184
202
|
}
|
|
185
|
-
async function
|
|
186
|
-
const
|
|
203
|
+
async function Ps(s) {
|
|
204
|
+
const t = s.fsImpl ?? u;
|
|
187
205
|
try {
|
|
188
|
-
const e = await
|
|
206
|
+
const e = await t.readFile(s.path, "utf8");
|
|
189
207
|
try {
|
|
190
208
|
const r = JSON.parse(e);
|
|
191
|
-
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" };
|
|
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
|
|
206
|
-
const
|
|
223
|
+
async function Us(s) {
|
|
224
|
+
const t = s.fsImpl ?? u, e = `${JSON.stringify(s.value, null, 2)}
|
|
207
225
|
`;
|
|
208
|
-
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);
|
|
209
227
|
}
|
|
210
|
-
async function
|
|
211
|
-
const
|
|
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 ${
|
|
232
|
+
`Invalid OpenClaw config JSON at ${s.hostConfigPath}: ${e.parseError ?? "unknown parse error"}`
|
|
215
233
|
);
|
|
216
|
-
const r = e.object, i =
|
|
217
|
-
let
|
|
218
|
-
return n.includes("rrskill") ? i.allow !== n && (i.allow = n,
|
|
219
|
-
fsImpl:
|
|
220
|
-
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,
|
|
221
239
|
value: r,
|
|
222
240
|
prevRawText: e.rawText
|
|
223
241
|
}) : !1;
|
|
224
242
|
}
|
|
225
|
-
async function
|
|
226
|
-
const 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
|
|
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
|
|
235
|
-
if (
|
|
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:
|
|
264
|
+
issues: [{ code: "unsupported_host_bootstrap", host: s.host }]
|
|
243
265
|
}
|
|
244
266
|
};
|
|
245
|
-
const e =
|
|
267
|
+
const e = t.fs ?? u, r = await Rs(
|
|
246
268
|
{
|
|
247
|
-
host:
|
|
248
|
-
skillsDir:
|
|
249
|
-
pluginDir:
|
|
250
|
-
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
|
|
275
|
+
), i = await is(
|
|
254
276
|
{
|
|
255
|
-
host:
|
|
256
|
-
skillsDir:
|
|
257
|
-
pluginDir:
|
|
258
|
-
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
|
|
270
|
-
const e = new Set(
|
|
271
|
-
|
|
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
|
-
|
|
274
|
-
), n =
|
|
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:
|
|
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:
|
|
315
|
+
path: c.join(s.skillsDir, "rrskill-preference", "SKILL.md")
|
|
294
316
|
},
|
|
295
317
|
{
|
|
296
318
|
name: "plugin_index",
|
|
297
|
-
ok: !i.has(
|
|
298
|
-
message: i.has(
|
|
299
|
-
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")
|
|
300
322
|
},
|
|
301
323
|
{
|
|
302
324
|
name: "plugin_manifest",
|
|
303
|
-
ok: !i.has(
|
|
304
|
-
message: i.has(
|
|
305
|
-
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")
|
|
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:
|
|
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
|
|
342
|
+
async function Ts(s, t = {}, e = {}) {
|
|
321
343
|
const r = e.fs ?? u, i = {
|
|
322
|
-
skillsDir:
|
|
323
|
-
pluginDir:
|
|
324
|
-
hostConfigPath:
|
|
344
|
+
skillsDir: s.skillsDir,
|
|
345
|
+
pluginDir: s.pluginDir,
|
|
346
|
+
hostConfigPath: s.hostConfigPath
|
|
325
347
|
};
|
|
326
|
-
if (
|
|
348
|
+
if (s.host !== "openclaw")
|
|
327
349
|
return {
|
|
328
350
|
ok: !0,
|
|
329
|
-
host:
|
|
351
|
+
host: s.host,
|
|
330
352
|
bootstrapSupported: !1,
|
|
331
353
|
fixed: !1,
|
|
332
|
-
dryRun:
|
|
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: `${
|
|
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
|
|
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:
|
|
377
|
+
host: s.host,
|
|
356
378
|
bootstrapSupported: !0,
|
|
357
379
|
fixed: !1,
|
|
358
|
-
dryRun:
|
|
359
|
-
checks:
|
|
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 (
|
|
387
|
+
if (t.dryRun)
|
|
366
388
|
return {
|
|
367
389
|
ok: !1,
|
|
368
|
-
host:
|
|
390
|
+
host: s.host,
|
|
369
391
|
bootstrapSupported: !0,
|
|
370
392
|
fixed: !1,
|
|
371
393
|
dryRun: !0,
|
|
372
|
-
checks:
|
|
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 (
|
|
379
|
-
const o = await
|
|
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:
|
|
406
|
+
host: s.host,
|
|
385
407
|
bootstrapSupported: !0,
|
|
386
408
|
fixed: !0,
|
|
387
409
|
dryRun: !1,
|
|
388
|
-
checks:
|
|
389
|
-
|
|
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:
|
|
422
|
+
host: s.host,
|
|
401
423
|
bootstrapSupported: !0,
|
|
402
424
|
fixed: !1,
|
|
403
425
|
dryRun: !1,
|
|
404
|
-
checks:
|
|
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
|
|
412
|
-
return
|
|
433
|
+
function Fs(s) {
|
|
434
|
+
return s.HOME ?? s.USERPROFILE ?? process.env.HOME ?? process.env.USERPROFILE ?? process.cwd();
|
|
413
435
|
}
|
|
414
|
-
function
|
|
415
|
-
const e =
|
|
436
|
+
function G(s, t) {
|
|
437
|
+
const e = s?.trim();
|
|
416
438
|
if (e)
|
|
417
|
-
return e === "~" ?
|
|
439
|
+
return e === "~" ? t : e.startsWith("~/") ? c.resolve(t, e.slice(2)) : c.resolve(e);
|
|
418
440
|
}
|
|
419
|
-
function
|
|
420
|
-
for (const e of
|
|
421
|
-
const r =
|
|
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
|
|
427
|
-
if (typeof
|
|
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 ${
|
|
451
|
+
`Invalid rrskill config at ${t}: root must be a JSON object`
|
|
430
452
|
);
|
|
431
|
-
return
|
|
453
|
+
return s;
|
|
432
454
|
}
|
|
433
|
-
async function
|
|
434
|
-
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");
|
|
435
457
|
try {
|
|
436
|
-
const r = await u.readFile(e, "utf8"), i =
|
|
458
|
+
const r = await u.readFile(e, "utf8"), i = Ns(JSON.parse(r), e);
|
|
437
459
|
return {
|
|
438
460
|
configPath: e,
|
|
439
|
-
host:
|
|
440
|
-
stateDir:
|
|
441
|
-
|
|
442
|
-
|
|
461
|
+
host: A(i, ["host"]),
|
|
462
|
+
stateDir: G(
|
|
463
|
+
A(i, ["stateDir", "state_dir"]),
|
|
464
|
+
t
|
|
443
465
|
),
|
|
444
|
-
skillsSearchUrl:
|
|
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
|
|
479
|
+
const zs = "openclaw", Ms = "--host", Z = {
|
|
458
480
|
"--openclaw": "openclaw",
|
|
459
481
|
"--codex": "codex",
|
|
460
482
|
"--claude-code": "claude-code"
|
|
461
|
-
},
|
|
483
|
+
}, os = [
|
|
462
484
|
"openclaw",
|
|
463
485
|
"codex",
|
|
464
486
|
"claude-code"
|
|
465
|
-
],
|
|
466
|
-
function
|
|
467
|
-
if (!
|
|
487
|
+
], Js = new Set(os), Bs = new Set(ts);
|
|
488
|
+
function qs(s) {
|
|
489
|
+
if (!s)
|
|
468
490
|
return;
|
|
469
|
-
const
|
|
470
|
-
if (
|
|
471
|
-
return
|
|
491
|
+
const t = s.trim().toLowerCase();
|
|
492
|
+
if (t && Js.has(t))
|
|
493
|
+
return t;
|
|
472
494
|
}
|
|
473
|
-
function
|
|
474
|
-
if (
|
|
495
|
+
function R(s, t) {
|
|
496
|
+
if (s === void 0)
|
|
475
497
|
return;
|
|
476
|
-
const e =
|
|
498
|
+
const e = qs(s);
|
|
477
499
|
if (e)
|
|
478
500
|
return e;
|
|
479
|
-
const r =
|
|
501
|
+
const r = s.trim();
|
|
480
502
|
if (r)
|
|
481
503
|
throw new Error(
|
|
482
|
-
`Unsupported host "${r}" from ${
|
|
504
|
+
`Unsupported host "${r}" from ${t}. Supported hosts: ${os.join(", ")}`
|
|
483
505
|
);
|
|
484
506
|
}
|
|
485
|
-
function
|
|
486
|
-
const
|
|
487
|
-
if (
|
|
507
|
+
function Ks(s) {
|
|
508
|
+
const t = s.indexOf(Ms);
|
|
509
|
+
if (t < 0)
|
|
488
510
|
return;
|
|
489
|
-
const e = t
|
|
490
|
-
if (!(!e || e.startsWith("--") ||
|
|
511
|
+
const e = s[t + 1];
|
|
512
|
+
if (!(!e || e.startsWith("--") || Bs.has(e)))
|
|
491
513
|
return e;
|
|
492
514
|
}
|
|
493
|
-
function
|
|
494
|
-
const
|
|
495
|
-
if (
|
|
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(
|
|
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
|
|
503
|
-
const
|
|
504
|
-
|
|
524
|
+
function Vs(s) {
|
|
525
|
+
const t = Ws(s.argv), e = R(
|
|
526
|
+
Ks(s.argv),
|
|
505
527
|
"--host"
|
|
506
528
|
);
|
|
507
|
-
if (
|
|
529
|
+
if (t && e && t !== e)
|
|
508
530
|
throw new Error(
|
|
509
|
-
`Conflicting host flags: ${
|
|
531
|
+
`Conflicting host flags: ${t} vs ${e}`
|
|
510
532
|
);
|
|
511
|
-
const r = e ??
|
|
533
|
+
const r = e ?? t;
|
|
512
534
|
if (r)
|
|
513
535
|
return r;
|
|
514
|
-
const i =
|
|
536
|
+
const i = R(s.env.RRSKILL_HOST, "RRSKILL_HOST");
|
|
515
537
|
if (i)
|
|
516
538
|
return i;
|
|
517
|
-
const n =
|
|
518
|
-
return o ||
|
|
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
|
|
521
|
-
const
|
|
522
|
-
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 };
|
|
523
545
|
}
|
|
524
|
-
const
|
|
546
|
+
const Zs = {
|
|
525
547
|
name: "openclaw",
|
|
526
|
-
getDefaultPaths({ homeDir:
|
|
548
|
+
getDefaultPaths({ homeDir: s }) {
|
|
527
549
|
return {
|
|
528
|
-
skillsDir: `${
|
|
529
|
-
pluginDir: `${
|
|
530
|
-
hostConfigPath: `${
|
|
550
|
+
skillsDir: `${s}/.openclaw/workspace/skills`,
|
|
551
|
+
pluginDir: `${s}/.openclaw/extensions/rrskill`,
|
|
552
|
+
hostConfigPath: `${s}/.openclaw/openclaw.json`
|
|
531
553
|
};
|
|
532
554
|
}
|
|
533
|
-
},
|
|
555
|
+
}, Qs = {
|
|
534
556
|
name: "codex",
|
|
535
|
-
getDefaultPaths({ homeDir:
|
|
536
|
-
const e =
|
|
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: `${
|
|
562
|
+
hostConfigPath: `${s}/.codex/config.toml`
|
|
541
563
|
};
|
|
542
564
|
}
|
|
543
|
-
},
|
|
565
|
+
}, Xs = {
|
|
544
566
|
name: "claude-code",
|
|
545
|
-
getDefaultPaths({ homeDir:
|
|
546
|
-
const e =
|
|
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: `${
|
|
572
|
+
hostConfigPath: `${s}/.claude/settings.json`
|
|
551
573
|
};
|
|
552
574
|
}
|
|
553
575
|
};
|
|
554
|
-
async function
|
|
555
|
-
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 });
|
|
556
578
|
return {
|
|
557
|
-
argv:
|
|
558
|
-
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:
|
|
588
|
+
config: t
|
|
567
589
|
};
|
|
568
590
|
}
|
|
569
|
-
const
|
|
570
|
-
function
|
|
591
|
+
const Ys = ".rrskill_lock.json";
|
|
592
|
+
function z() {
|
|
571
593
|
return { version: 1, skills: {} };
|
|
572
594
|
}
|
|
573
|
-
function
|
|
574
|
-
return
|
|
595
|
+
function as(s) {
|
|
596
|
+
return c.join(s, Ys);
|
|
575
597
|
}
|
|
576
|
-
function
|
|
577
|
-
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}`;
|
|
578
600
|
if (!r.startsWith(i))
|
|
579
|
-
throw new Error(`Refusing to write outside skillsDir: slug="${
|
|
601
|
+
throw new Error(`Refusing to write outside skillsDir: slug="${t}"`);
|
|
580
602
|
return r;
|
|
581
603
|
}
|
|
582
|
-
function
|
|
583
|
-
return typeof
|
|
604
|
+
function D(s) {
|
|
605
|
+
return typeof s == "object" && s !== null;
|
|
584
606
|
}
|
|
585
|
-
function
|
|
586
|
-
if (!
|
|
587
|
-
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 ? {
|
|
588
610
|
type: "registry",
|
|
589
|
-
version: (
|
|
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
|
|
594
|
-
if (!
|
|
595
|
-
if (
|
|
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(
|
|
598
|
-
const
|
|
599
|
-
|
|
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
|
|
604
|
-
if (
|
|
605
|
-
return
|
|
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(
|
|
608
|
-
const o =
|
|
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
|
|
614
|
-
const
|
|
635
|
+
async function q(s) {
|
|
636
|
+
const t = as(s.skillsDir);
|
|
615
637
|
try {
|
|
616
|
-
const e = await
|
|
617
|
-
return
|
|
638
|
+
const e = await s.fs.readFile(t, "utf8"), r = JSON.parse(e);
|
|
639
|
+
return st(r);
|
|
618
640
|
} catch (e) {
|
|
619
|
-
if ((
|
|
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
|
|
624
|
-
const
|
|
625
|
-
await
|
|
626
|
-
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)}
|
|
627
649
|
`;
|
|
628
|
-
await
|
|
650
|
+
await s.fs.writeFile(e, r, "utf8"), await s.fs.rename(e, t);
|
|
629
651
|
}
|
|
630
|
-
function
|
|
652
|
+
function us(s, t) {
|
|
631
653
|
return {
|
|
632
654
|
version: 1,
|
|
633
655
|
skills: {
|
|
634
|
-
...
|
|
635
|
-
[
|
|
656
|
+
...s.skills,
|
|
657
|
+
[t.slug]: t
|
|
636
658
|
}
|
|
637
659
|
};
|
|
638
660
|
}
|
|
639
|
-
function
|
|
661
|
+
function tt() {
|
|
640
662
|
return /* @__PURE__ */ new Date();
|
|
641
663
|
}
|
|
642
|
-
async function
|
|
643
|
-
const
|
|
644
|
-
await
|
|
645
|
-
const e =
|
|
646
|
-
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(
|
|
647
669
|
e,
|
|
648
|
-
`${JSON.stringify({ slug:
|
|
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
|
|
654
|
-
const r = e.fs ?? u, i = e.now ??
|
|
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:
|
|
657
|
-
throw new Error(`No exact registry match for slug "${
|
|
658
|
-
const o =
|
|
659
|
-
let
|
|
660
|
-
e.downloadSkill ? (await r.mkdir(o, { recursive: !0 }),
|
|
661
|
-
const a = await
|
|
662
|
-
slug:
|
|
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:
|
|
686
|
+
source: { type: "registry", version: l }
|
|
665
687
|
});
|
|
666
|
-
return await
|
|
667
|
-
slug:
|
|
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
|
|
673
|
-
const 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
|
|
677
|
-
return e.searchSkills({ query:
|
|
698
|
+
async function nt(s, t, e) {
|
|
699
|
+
return e.searchSkills({ query: t });
|
|
678
700
|
}
|
|
679
|
-
async function
|
|
680
|
-
const e =
|
|
681
|
-
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)
|
|
682
704
|
return { upgraded: [] };
|
|
683
705
|
const o = [];
|
|
684
|
-
let
|
|
706
|
+
let l = i;
|
|
685
707
|
for (const a of n) {
|
|
686
|
-
const f =
|
|
708
|
+
const f = ls(s.skillsDir, a);
|
|
687
709
|
await e.mkdir(f, { recursive: !0 });
|
|
688
|
-
const d = await
|
|
710
|
+
const d = await t.downloadSkill({ slug: a, targetDir: f });
|
|
689
711
|
o.push(a);
|
|
690
|
-
const p =
|
|
691
|
-
|
|
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
|
|
720
|
+
}), await cs({ skillsDir: s.skillsDir, fs: e, lockfile: l });
|
|
699
721
|
}
|
|
700
722
|
return { upgraded: o };
|
|
701
723
|
}
|
|
702
|
-
function
|
|
703
|
-
let
|
|
724
|
+
function at(s) {
|
|
725
|
+
let t = c.dirname(O(s));
|
|
704
726
|
for (; ; ) {
|
|
705
|
-
const e =
|
|
727
|
+
const e = c.join(t, "package.json");
|
|
706
728
|
try {
|
|
707
|
-
return JSON.parse(
|
|
729
|
+
return JSON.parse(ws(e, "utf8"));
|
|
708
730
|
} catch {
|
|
709
|
-
const r =
|
|
710
|
-
if (r ===
|
|
731
|
+
const r = c.dirname(t);
|
|
732
|
+
if (r === t)
|
|
711
733
|
return {};
|
|
712
|
-
|
|
734
|
+
t = r;
|
|
713
735
|
}
|
|
714
736
|
}
|
|
715
737
|
}
|
|
716
|
-
function
|
|
717
|
-
const
|
|
738
|
+
function lt(s = {}) {
|
|
739
|
+
const t = at(import.meta.url);
|
|
718
740
|
return {
|
|
719
|
-
packageName:
|
|
720
|
-
version:
|
|
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
|
|
726
|
-
function
|
|
727
|
-
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);
|
|
728
750
|
}
|
|
729
|
-
function h(
|
|
730
|
-
for (const e of
|
|
731
|
-
const r =
|
|
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
|
|
758
|
+
function P(s) {
|
|
737
759
|
try {
|
|
738
|
-
return new URL(
|
|
760
|
+
return new URL(s);
|
|
739
761
|
} catch {
|
|
740
762
|
return;
|
|
741
763
|
}
|
|
742
764
|
}
|
|
743
|
-
function
|
|
744
|
-
const i =
|
|
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
|
-
(
|
|
747
|
-
) || o.searchParams.set("search", e), i.includes("{limit}") || ["limit", "size"].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;
|
|
748
770
|
}
|
|
749
|
-
async function
|
|
750
|
-
const
|
|
751
|
-
if (
|
|
752
|
-
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, {
|
|
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 ||
|
|
785
|
+
reference: r.url || s
|
|
764
786
|
};
|
|
765
787
|
}
|
|
766
|
-
if (
|
|
767
|
-
const r =
|
|
788
|
+
if (t?.protocol === "file:") {
|
|
789
|
+
const r = O(t);
|
|
768
790
|
return {
|
|
769
791
|
payload: await u.readFile(r, "utf8"),
|
|
770
|
-
reference:
|
|
792
|
+
reference: t.toString()
|
|
771
793
|
};
|
|
772
794
|
}
|
|
773
|
-
const e =
|
|
795
|
+
const e = c.resolve(s);
|
|
774
796
|
return {
|
|
775
797
|
payload: await u.readFile(e, "utf8"),
|
|
776
|
-
reference:
|
|
798
|
+
reference: ks(e).toString()
|
|
777
799
|
};
|
|
778
800
|
}
|
|
779
|
-
function
|
|
780
|
-
if (
|
|
801
|
+
function ht(s, t) {
|
|
802
|
+
if (s)
|
|
781
803
|
try {
|
|
782
|
-
return new URL(
|
|
804
|
+
return new URL(s, t).toString();
|
|
783
805
|
} catch {
|
|
784
806
|
return;
|
|
785
807
|
}
|
|
786
808
|
}
|
|
787
|
-
function
|
|
788
|
-
const r =
|
|
809
|
+
function fs(s, t, e) {
|
|
810
|
+
const r = t?.trim().toLowerCase();
|
|
789
811
|
if (!r)
|
|
790
812
|
return;
|
|
791
|
-
const i =
|
|
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
|
|
798
|
-
const e = h(
|
|
819
|
+
function gt(s, t) {
|
|
820
|
+
const e = h(s, ["slug"]);
|
|
799
821
|
if (!e)
|
|
800
822
|
return;
|
|
801
|
-
const r =
|
|
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(
|
|
808
|
-
|
|
829
|
+
]) ?? h(s, ["skillUrl", "downloadUrl", "packageUrl", "url"]),
|
|
830
|
+
t
|
|
809
831
|
);
|
|
810
832
|
return {
|
|
811
833
|
slug: e,
|
|
812
|
-
title: h(
|
|
813
|
-
description: h(
|
|
814
|
-
version: h(r, ["version"]) ?? h(
|
|
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(
|
|
817
|
-
source: h(
|
|
838
|
+
sha256: h(r, ["sha256"]) ?? h(s, ["sha256", "checksum"]),
|
|
839
|
+
source: h(s, ["source", "platform"])
|
|
818
840
|
};
|
|
819
841
|
}
|
|
820
|
-
function
|
|
842
|
+
function mt(s, t, e) {
|
|
821
843
|
let r;
|
|
822
844
|
try {
|
|
823
|
-
r = JSON.parse(
|
|
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 (!
|
|
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 =
|
|
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
|
-
|
|
842
|
-
),
|
|
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:
|
|
848
|
-
}
|
|
849
|
-
function
|
|
850
|
-
return async ({ query:
|
|
851
|
-
const e =
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
), { payload: r, reference: i } = await
|
|
857
|
-
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);
|
|
858
880
|
};
|
|
859
881
|
}
|
|
860
|
-
async function
|
|
882
|
+
async function ds(s, t) {
|
|
861
883
|
const e = [];
|
|
862
884
|
let o = -1;
|
|
863
|
-
for (let f =
|
|
864
|
-
if (
|
|
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
|
|
871
|
-
let a =
|
|
872
|
-
await u.mkdir(
|
|
873
|
-
for (let f = 0; f <
|
|
874
|
-
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)
|
|
875
897
|
throw new Error(
|
|
876
898
|
"Downloaded skill package has an invalid zip central directory."
|
|
877
899
|
);
|
|
878
|
-
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(
|
|
879
901
|
"utf8",
|
|
880
902
|
a + 46,
|
|
881
|
-
a + 46 +
|
|
903
|
+
a + 46 + m
|
|
882
904
|
);
|
|
883
|
-
a += 46 +
|
|
884
|
-
const
|
|
885
|
-
if (!
|
|
886
|
-
throw new Error(`Unsafe zip path entry detected: ${
|
|
887
|
-
const
|
|
888
|
-
if (
|
|
889
|
-
throw new Error(`Unsafe zip path entry detected: ${
|
|
890
|
-
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)
|
|
891
913
|
throw new Error(
|
|
892
914
|
"Downloaded skill package has an invalid zip local header."
|
|
893
915
|
);
|
|
894
|
-
const
|
|
895
|
-
|
|
896
|
-
|
|
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 (
|
|
899
|
-
await u.mkdir(
|
|
920
|
+
if (y.endsWith("/")) {
|
|
921
|
+
await u.mkdir(_, { recursive: !0 });
|
|
900
922
|
continue;
|
|
901
923
|
}
|
|
902
|
-
let
|
|
924
|
+
let L;
|
|
903
925
|
if (d === 0)
|
|
904
|
-
|
|
926
|
+
L = Buffer.from(W);
|
|
905
927
|
else if (d === 8)
|
|
906
|
-
|
|
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 (
|
|
912
|
-
throw new Error(`Zip entry size mismatch for ${
|
|
913
|
-
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);
|
|
914
936
|
}
|
|
915
937
|
return e;
|
|
916
938
|
}
|
|
917
|
-
async function
|
|
918
|
-
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 });
|
|
919
941
|
}
|
|
920
|
-
async function
|
|
921
|
-
if ((await u.stat(
|
|
922
|
-
return await
|
|
923
|
-
const i = await u.readFile(
|
|
924
|
-
|
|
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
|
-
|
|
948
|
+
c.join(ss.tmpdir(), "rrskill-registry-stage-")
|
|
927
949
|
);
|
|
928
950
|
try {
|
|
929
|
-
const o = await
|
|
930
|
-
return await
|
|
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
|
|
936
|
-
const r = await fetch(
|
|
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
|
-
|
|
968
|
+
fs(i, e, s);
|
|
947
969
|
const n = await u.mkdtemp(
|
|
948
|
-
|
|
970
|
+
c.join(ss.tmpdir(), "rrskill-registry-stage-")
|
|
949
971
|
);
|
|
950
972
|
try {
|
|
951
|
-
const o = await
|
|
952
|
-
return await
|
|
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
|
|
958
|
-
const r = (await
|
|
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 "${
|
|
982
|
+
throw new Error(`No exact registry match for slug "${t}"`);
|
|
961
983
|
return r;
|
|
962
984
|
}
|
|
963
|
-
async function
|
|
964
|
-
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;
|
|
965
987
|
if (!r)
|
|
966
988
|
throw new Error(
|
|
967
|
-
`Registry skill "${
|
|
989
|
+
`Registry skill "${t.slug}" does not define a skillUrl/packageUrl`
|
|
968
990
|
);
|
|
969
|
-
const i =
|
|
991
|
+
const i = P(r), n = e.sha256, o = i?.protocol === "http:" || i?.protocol === "https:" ? await yt(
|
|
970
992
|
r,
|
|
971
|
-
|
|
993
|
+
t.targetDir,
|
|
972
994
|
n
|
|
973
|
-
) : await
|
|
974
|
-
i?.protocol === "file:" ?
|
|
975
|
-
|
|
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:
|
|
980
|
-
targetDir:
|
|
1001
|
+
slug: t.slug,
|
|
1002
|
+
targetDir: t.targetDir,
|
|
981
1003
|
writtenFiles: o,
|
|
982
1004
|
version: e.version
|
|
983
1005
|
};
|
|
984
1006
|
}
|
|
985
|
-
function
|
|
986
|
-
return async (
|
|
1007
|
+
function Dt(s) {
|
|
1008
|
+
return async (t) => St(s, t);
|
|
987
1009
|
}
|
|
988
|
-
class
|
|
1010
|
+
class w extends Error {
|
|
989
1011
|
code;
|
|
990
1012
|
hint;
|
|
991
1013
|
nextCommands;
|
|
992
|
-
constructor(
|
|
993
|
-
super(
|
|
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
|
|
997
|
-
const
|
|
998
|
-
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;
|
|
999
1021
|
}
|
|
1000
|
-
function
|
|
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
|
|
1037
|
-
const
|
|
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
|
|
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
|
-
...
|
|
1078
|
+
...t
|
|
1057
1079
|
].join(`
|
|
1058
|
-
`) :
|
|
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
|
-
...
|
|
1090
|
+
...t
|
|
1069
1091
|
].join(`
|
|
1070
|
-
`) :
|
|
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
|
-
...
|
|
1101
|
+
...t
|
|
1080
1102
|
].join(`
|
|
1081
|
-
`) :
|
|
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
|
-
...
|
|
1112
|
+
...t
|
|
1091
1113
|
].join(`
|
|
1092
|
-
`) :
|
|
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
|
-
...
|
|
1123
|
+
...t
|
|
1102
1124
|
].join(`
|
|
1103
|
-
`) :
|
|
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
|
-
...
|
|
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
|
-
...
|
|
1150
|
+
...t
|
|
1129
1151
|
].join(`
|
|
1130
1152
|
`);
|
|
1131
1153
|
}
|
|
1132
|
-
function
|
|
1133
|
-
process.stdout.write(`${JSON.stringify(
|
|
1154
|
+
function J(s) {
|
|
1155
|
+
process.stdout.write(`${JSON.stringify(s, null, 2)}
|
|
1134
1156
|
`);
|
|
1135
1157
|
}
|
|
1136
|
-
function
|
|
1137
|
-
process.stdout.write(
|
|
1138
|
-
`) ?
|
|
1158
|
+
function B(s) {
|
|
1159
|
+
process.stdout.write(s.endsWith(`
|
|
1160
|
+
`) ? s : `${s}
|
|
1139
1161
|
`);
|
|
1140
1162
|
}
|
|
1141
|
-
function
|
|
1142
|
-
if (
|
|
1143
|
-
|
|
1163
|
+
function k(s, t, e) {
|
|
1164
|
+
if (t === "json") {
|
|
1165
|
+
J(s);
|
|
1144
1166
|
return;
|
|
1145
1167
|
}
|
|
1146
|
-
|
|
1168
|
+
B(e(s));
|
|
1147
1169
|
}
|
|
1148
|
-
function
|
|
1170
|
+
function Et(s) {
|
|
1149
1171
|
return [
|
|
1150
|
-
`${
|
|
1151
|
-
`Update via ${
|
|
1152
|
-
...
|
|
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
|
|
1157
|
-
return
|
|
1158
|
-
const e =
|
|
1159
|
-
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}`;
|
|
1160
1182
|
}).join(`
|
|
1161
1183
|
`);
|
|
1162
1184
|
}
|
|
1163
|
-
function
|
|
1164
|
-
const
|
|
1165
|
-
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(`
|
|
1166
1188
|
`);
|
|
1167
1189
|
}
|
|
1168
|
-
function
|
|
1169
|
-
return
|
|
1190
|
+
function bt(s) {
|
|
1191
|
+
return s.length === 0 ? "No skills installed." : s.join(`
|
|
1170
1192
|
`);
|
|
1171
1193
|
}
|
|
1172
|
-
function
|
|
1173
|
-
return
|
|
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
|
|
1177
|
-
const
|
|
1178
|
-
|
|
1179
|
-
`Builtins installed: ${
|
|
1180
|
-
`Plugin installed: ${
|
|
1181
|
-
`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"}`
|
|
1182
1204
|
];
|
|
1183
|
-
return
|
|
1184
|
-
...
|
|
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
|
-
),
|
|
1209
|
+
), t.join(`
|
|
1188
1210
|
`);
|
|
1189
1211
|
}
|
|
1190
|
-
function
|
|
1191
|
-
const
|
|
1192
|
-
|
|
1193
|
-
`Bootstrap supported: ${
|
|
1194
|
-
`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"}`
|
|
1195
1217
|
];
|
|
1196
|
-
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(`
|
|
1197
1219
|
`);
|
|
1198
1220
|
}
|
|
1199
|
-
function
|
|
1200
|
-
return
|
|
1221
|
+
function $(s, ...t) {
|
|
1222
|
+
return s.some((e) => t.includes(e));
|
|
1201
1223
|
}
|
|
1202
|
-
function
|
|
1203
|
-
const e =
|
|
1224
|
+
function Pt(s, t) {
|
|
1225
|
+
const e = s.indexOf(t);
|
|
1204
1226
|
if (e < 0)
|
|
1205
1227
|
return;
|
|
1206
|
-
const r =
|
|
1228
|
+
const r = s[e + 1];
|
|
1207
1229
|
if (!(!r || r.startsWith("--")))
|
|
1208
1230
|
return r;
|
|
1209
1231
|
}
|
|
1210
|
-
function
|
|
1211
|
-
if (
|
|
1232
|
+
function ps(s, t = "json") {
|
|
1233
|
+
if ($(s, "--json"))
|
|
1212
1234
|
return "json";
|
|
1213
|
-
const e =
|
|
1235
|
+
const e = Pt(s, "--output");
|
|
1214
1236
|
if (!e) {
|
|
1215
|
-
if (
|
|
1216
|
-
throw new
|
|
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
|
|
1244
|
+
return t;
|
|
1223
1245
|
}
|
|
1224
1246
|
if (e === "json" || e === "text")
|
|
1225
1247
|
return e;
|
|
1226
|
-
throw new
|
|
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
|
|
1234
|
-
if (
|
|
1235
|
-
|
|
1255
|
+
function Y(s, t) {
|
|
1256
|
+
if (s instanceof w && t === "json") {
|
|
1257
|
+
J({
|
|
1236
1258
|
ok: !1,
|
|
1237
1259
|
error: {
|
|
1238
|
-
code:
|
|
1239
|
-
message:
|
|
1240
|
-
hint:
|
|
1260
|
+
code: s.code,
|
|
1261
|
+
message: s.message,
|
|
1262
|
+
hint: s.hint
|
|
1241
1263
|
},
|
|
1242
|
-
next_commands:
|
|
1264
|
+
next_commands: s.nextCommands
|
|
1243
1265
|
});
|
|
1244
1266
|
return;
|
|
1245
1267
|
}
|
|
1246
|
-
if (
|
|
1247
|
-
const r = [`Error: ${
|
|
1248
|
-
if (
|
|
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
|
|
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 =
|
|
1259
|
-
if (
|
|
1260
|
-
|
|
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
|
|
1274
|
-
const
|
|
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
|
|
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) ? (
|
|
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
|
|
1309
|
+
const a = await Q({ argv: s, env: process.env }), f = await Ts(
|
|
1288
1310
|
a,
|
|
1289
1311
|
{
|
|
1290
|
-
fix:
|
|
1291
|
-
dryRun:
|
|
1312
|
+
fix: $(s, "--fix"),
|
|
1313
|
+
dryRun: $(s, "--dry-run")
|
|
1292
1314
|
}
|
|
1293
1315
|
);
|
|
1294
|
-
return
|
|
1316
|
+
return k(f, t, Ot), f.ok ? 0 : 1;
|
|
1295
1317
|
}
|
|
1296
1318
|
if (e.command === "version")
|
|
1297
|
-
return
|
|
1298
|
-
const n = await
|
|
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
|
|
1323
|
+
await H(n);
|
|
1302
1324
|
} catch {
|
|
1303
1325
|
}
|
|
1304
|
-
const o =
|
|
1326
|
+
const o = kt({ config: n.config, env: n.env }), l = Dt(o);
|
|
1305
1327
|
if (e.command === "bootstrap") {
|
|
1306
|
-
const a = await
|
|
1307
|
-
return
|
|
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
|
|
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
|
|
1319
|
-
return
|
|
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
|
|
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
|
|
1331
|
-
return
|
|
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
|
|
1335
|
-
return
|
|
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
|
|
1339
|
-
return
|
|
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 (
|
|
1345
|
-
const
|
|
1346
|
-
|
|
1347
|
-
process.exitCode =
|
|
1348
|
-
}).catch((
|
|
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 =
|
|
1373
|
+
e = ps(s, "text");
|
|
1352
1374
|
} catch (r) {
|
|
1353
|
-
|
|
1375
|
+
Y(r, "text"), process.exitCode = 1;
|
|
1354
1376
|
return;
|
|
1355
1377
|
}
|
|
1356
|
-
|
|
1378
|
+
Y(t, e), process.exitCode = 1;
|
|
1357
1379
|
});
|
|
1358
1380
|
}
|
|
1359
1381
|
export {
|
|
1360
|
-
|
|
1382
|
+
Es as buildCliArgv
|
|
1361
1383
|
};
|