@greenrenge/skills 0.1.0 → 0.3.0
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/README.md +84 -23
- package/bin/cli.mjs +414 -123
- package/bin/lib/onboard.mjs +1179 -0
- package/bin/lib/probe.mjs +782 -0
- package/bin/lib/recipes/index.mjs +57 -0
- package/bin/lib/recipes/security-cron.mjs +1140 -0
- package/catalog.json +501 -51
- package/package.json +10 -8
- package/skills/security-remediation-epic/prompt-template.md +87 -20
- package/skills/ticket-orchestrator/SKILL.md +349 -0
- package/skills/ticket-orchestrator/references/proving-the-gates.md +63 -0
- package/skills/ticket-scheme/SKILL.md +144 -0
package/bin/cli.mjs
CHANGED
|
@@ -1,66 +1,141 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CLI wrapper around skillfold for @greenrenge/skills.
|
|
4
|
+
*
|
|
5
|
+
* Commands:
|
|
6
|
+
* onboard | init Interactive categorized onboarding & host setup
|
|
7
|
+
* list List categories, bundles, and skills with dependencies
|
|
8
|
+
* info <bundle-or-skill> Inspect bundle/skill category, deps, and requirements
|
|
9
|
+
* install <bundle-or-skill...> [opts] Add & install skills (categorized tree + preflight)
|
|
10
|
+
* doctor [bundle-or-skill...] [opts] Probe host tools, host facts, and Run Contracts
|
|
11
|
+
* update [skill...] [opts] Refresh installed skills via skillfold update
|
|
12
|
+
* remove <bundle-or-skill...> [opts] Remove skills from skillfold.yaml and reconcile
|
|
13
|
+
* check [opts] Verify manifest, lockfile, and targets via skillfold check
|
|
14
|
+
*/
|
|
2
15
|
import { execFileSync } from "node:child_process";
|
|
3
16
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
17
|
import { dirname, join, resolve } from "node:path";
|
|
5
18
|
import { fileURLToPath } from "node:url";
|
|
6
19
|
import {
|
|
7
|
-
MANIFEST_FILENAME,
|
|
8
|
-
TARGET_NAMES,
|
|
9
20
|
addSkillToManifest,
|
|
10
21
|
globalConfigRoot,
|
|
11
22
|
loadManifest,
|
|
23
|
+
MANIFEST_FILENAME,
|
|
12
24
|
removeSkillFromManifest,
|
|
25
|
+
TARGET_NAMES,
|
|
13
26
|
} from "skillfold";
|
|
27
|
+
import {
|
|
28
|
+
c,
|
|
29
|
+
createPrompter,
|
|
30
|
+
expandPlan,
|
|
31
|
+
promptHostProfileWizard,
|
|
32
|
+
promptOcrSetupWizard,
|
|
33
|
+
promptRunContractWizard,
|
|
34
|
+
renderCatalogList,
|
|
35
|
+
renderInstallPlan,
|
|
36
|
+
renderPreflightReport,
|
|
37
|
+
renderSkillOrBundleInfo,
|
|
38
|
+
runOnboard,
|
|
39
|
+
} from "./lib/onboard.mjs";
|
|
40
|
+
import { collectToolsToProbe, evaluateRequirements, probeHost } from "./lib/probe.mjs";
|
|
41
|
+
import { hasRecipe, renderRecipesList, runRecipe } from "./lib/recipes/index.mjs";
|
|
14
42
|
|
|
15
43
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
16
44
|
const PKG_ROOT = resolve(__dirname, "..");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
45
|
+
const CATALOG_PATH = join(PKG_ROOT, "catalog.json");
|
|
46
|
+
const PKG_JSON_PATH = join(PKG_ROOT, "package.json");
|
|
19
47
|
|
|
20
48
|
const skillfoldEntry = fileURLToPath(import.meta.resolve("skillfold"));
|
|
21
49
|
const SKILLFOLD_BIN = join(dirname(skillfoldEntry), "cli.js");
|
|
22
50
|
|
|
51
|
+
const catalog = JSON.parse(readFileSync(CATALOG_PATH, "utf8"));
|
|
52
|
+
const pkgJson = JSON.parse(readFileSync(PKG_JSON_PATH, "utf8"));
|
|
53
|
+
|
|
23
54
|
function usage() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
npx ${name}
|
|
29
|
-
npx ${name}
|
|
30
|
-
npx ${name}
|
|
31
|
-
npx ${name}
|
|
32
|
-
npx ${name}
|
|
33
|
-
npx ${name}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
--
|
|
41
|
-
--
|
|
42
|
-
--
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
console.log(`${c.bold(pkgJson.name)} v${pkgJson.version} — ${pkgJson.description}
|
|
56
|
+
|
|
57
|
+
Usage:
|
|
58
|
+
npx ${pkgJson.name} Start interactive onboarding (TTY)
|
|
59
|
+
npx ${pkgJson.name} onboard [options] Guided category picker + host facts setup
|
|
60
|
+
npx ${pkgJson.name} setup [recipe] [options] Run a dedicated workflow recipe (e.g. security-cron)
|
|
61
|
+
npx ${pkgJson.name} security-cron [options] Shortcut for "setup security-cron"
|
|
62
|
+
npx ${pkgJson.name} list List categories, bundles, and skills
|
|
63
|
+
npx ${pkgJson.name} info <bundle-or-skill> Show category, dependencies, and requirements
|
|
64
|
+
npx ${pkgJson.name} install <name...> [options] Install categories, bundles, or skills
|
|
65
|
+
npx ${pkgJson.name} doctor [name...] [options] Check host tools, host facts, and contracts
|
|
66
|
+
npx ${pkgJson.name} update [skill...] [options] Update installed skills via skillfold
|
|
67
|
+
npx ${pkgJson.name} remove <name...> [options] Remove skills and reconcile
|
|
68
|
+
npx ${pkgJson.name} check [options] Verify lockfile & targets via skillfold
|
|
69
|
+
|
|
70
|
+
Options:
|
|
71
|
+
--targets <list> Comma-separated targets: ${TARGET_NAMES.join(", ")} (default: claude,codex)
|
|
72
|
+
--dir <path> Target project directory (default: cwd)
|
|
73
|
+
-g, --global Operate on global skillfold config (~/.config/skillfold)
|
|
74
|
+
--no-deps Do not auto-expand dependsOn skills during install
|
|
75
|
+
--no-check Skip host preflight check during install
|
|
76
|
+
-y, --yes Non-interactive install (skip post-install host-fact prompts)
|
|
77
|
+
--setup-ocr Install & configure the ocr CLI (with onboard or doctor)
|
|
78
|
+
--setup-host Scaffold ~/.agents/rules/host-<hostname>.md (with onboard or doctor)
|
|
79
|
+
--setup-contract Scaffold an orchestrator Run Contract (with onboard or doctor)
|
|
80
|
+
--strict Exit non-zero from doctor if required tools are missing
|
|
81
|
+
--force Pass --force to skillfold install/update
|
|
82
|
+
--frozen Pass --frozen to skillfold install
|
|
83
|
+
--local Reference bundled skills by local path (testing)
|
|
84
|
+
|
|
85
|
+
Recipe options (for setup / security-cron):
|
|
86
|
+
--harness <name> t3 | claude | codex | opencode | generic
|
|
87
|
+
--schedule <type> t3 | claude-code | os-cron | github-actions | prompt-only
|
|
88
|
+
--cron "<expr>" 5-field cron expression (default: "0 2 * * 1")
|
|
89
|
+
--time "<HH:MM>" Explicit time-of-day override (e.g. 04:00)
|
|
90
|
+
--severity <level> Fix floor: critical | high | medium | low (default: medium)
|
|
91
|
+
--tracker <mode> local | github-issues (default: local)
|
|
92
|
+
--repo <owner/repo> Override detected GitHub owner/repo slug
|
|
93
|
+
--branch <name> Override detected default branch
|
|
94
|
+
--label <name> Optional PR review bot label
|
|
95
|
+
--with-ocr Include open-code-review + rules overlay
|
|
96
|
+
--no-ocr Exclude open-code-review overlay
|
|
97
|
+
--os-scheduler <m> auto | systemd | launchd | crontab (with --schedule os-cron)
|
|
98
|
+
--install-schedule Write generated systemd/launchd unit into user scheduler dir
|
|
99
|
+
--skip-install Generate prompt/schedule files without running skillfold install
|
|
100
|
+
-h, --help Show this help
|
|
101
|
+
-v, --version Show package version
|
|
102
|
+
`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function die(msg) {
|
|
106
|
+
console.error(`${c.red("error:")} ${msg}`);
|
|
107
|
+
process.exit(1);
|
|
52
108
|
}
|
|
53
109
|
|
|
54
110
|
function parseArgs(argv) {
|
|
55
111
|
const positionals = [];
|
|
56
112
|
const flags = {
|
|
57
|
-
targets: null,
|
|
58
|
-
dir: null,
|
|
59
113
|
global: false,
|
|
114
|
+
dir: null,
|
|
115
|
+
targets: null,
|
|
60
116
|
noDeps: false,
|
|
117
|
+
noCheck: false,
|
|
118
|
+
yes: false,
|
|
119
|
+
setupOcr: false,
|
|
120
|
+
setupHost: false,
|
|
121
|
+
setupContract: false,
|
|
122
|
+
strict: false,
|
|
61
123
|
force: false,
|
|
62
124
|
frozen: false,
|
|
63
125
|
local: false,
|
|
126
|
+
harness: null,
|
|
127
|
+
schedule: null,
|
|
128
|
+
cron: null,
|
|
129
|
+
time: null,
|
|
130
|
+
severity: null,
|
|
131
|
+
tracker: null,
|
|
132
|
+
repo: null,
|
|
133
|
+
branch: null,
|
|
134
|
+
label: null,
|
|
135
|
+
withOcr: null,
|
|
136
|
+
osScheduler: null,
|
|
137
|
+
installSchedule: false,
|
|
138
|
+
skipInstall: false,
|
|
64
139
|
help: false,
|
|
65
140
|
version: false,
|
|
66
141
|
};
|
|
@@ -73,8 +148,20 @@ function parseArgs(argv) {
|
|
|
73
148
|
flags.version = true;
|
|
74
149
|
} else if (arg === "-g" || arg === "--global") {
|
|
75
150
|
flags.global = true;
|
|
151
|
+
} else if (arg === "-y" || arg === "--yes") {
|
|
152
|
+
flags.yes = true;
|
|
76
153
|
} else if (arg === "--no-deps") {
|
|
77
154
|
flags.noDeps = true;
|
|
155
|
+
} else if (arg === "--no-check") {
|
|
156
|
+
flags.noCheck = true;
|
|
157
|
+
} else if (arg === "--setup-ocr") {
|
|
158
|
+
flags.setupOcr = true;
|
|
159
|
+
} else if (arg === "--setup-host") {
|
|
160
|
+
flags.setupHost = true;
|
|
161
|
+
} else if (arg === "--setup-contract") {
|
|
162
|
+
flags.setupContract = true;
|
|
163
|
+
} else if (arg === "--strict") {
|
|
164
|
+
flags.strict = true;
|
|
78
165
|
} else if (arg === "--force") {
|
|
79
166
|
flags.force = true;
|
|
80
167
|
} else if (arg === "--frozen") {
|
|
@@ -91,6 +178,42 @@ function parseArgs(argv) {
|
|
|
91
178
|
if (!flags.targets) die("--targets requires a comma-separated list");
|
|
92
179
|
} else if (arg.startsWith("--targets=")) {
|
|
93
180
|
flags.targets = arg.slice("--targets=".length);
|
|
181
|
+
} else if (arg === "--with-ocr") {
|
|
182
|
+
flags.withOcr = true;
|
|
183
|
+
} else if (arg === "--no-ocr") {
|
|
184
|
+
flags.withOcr = false;
|
|
185
|
+
} else if (arg === "--install-schedule") {
|
|
186
|
+
flags.installSchedule = true;
|
|
187
|
+
} else if (arg === "--skip-install") {
|
|
188
|
+
flags.skipInstall = true;
|
|
189
|
+
} else if (
|
|
190
|
+
[
|
|
191
|
+
"--harness",
|
|
192
|
+
"--schedule",
|
|
193
|
+
"--cron",
|
|
194
|
+
"--time",
|
|
195
|
+
"--severity",
|
|
196
|
+
"--tracker",
|
|
197
|
+
"--repo",
|
|
198
|
+
"--branch",
|
|
199
|
+
"--label",
|
|
200
|
+
"--os-scheduler",
|
|
201
|
+
].includes(arg)
|
|
202
|
+
) {
|
|
203
|
+
const val = argv[++i];
|
|
204
|
+
if (!val) die(`${arg} requires a value`);
|
|
205
|
+
const key =
|
|
206
|
+
arg === "--os-scheduler" ? "osScheduler" : arg.slice(2);
|
|
207
|
+
flags[key] = val;
|
|
208
|
+
} else if (
|
|
209
|
+
/^--(harness|schedule|cron|time|severity|tracker|repo|branch|label|os-scheduler)=/.test(
|
|
210
|
+
arg,
|
|
211
|
+
)
|
|
212
|
+
) {
|
|
213
|
+
const eq = arg.indexOf("=");
|
|
214
|
+
const k = arg.slice(2, eq);
|
|
215
|
+
const v = arg.slice(eq + 1);
|
|
216
|
+
flags[k === "os-scheduler" ? "osScheduler" : k] = v;
|
|
94
217
|
} else if (arg.startsWith("-")) {
|
|
95
218
|
die(`Unknown option: ${arg}`);
|
|
96
219
|
} else {
|
|
@@ -100,11 +223,6 @@ function parseArgs(argv) {
|
|
|
100
223
|
return { command: positionals[0], args: positionals.slice(1), flags };
|
|
101
224
|
}
|
|
102
225
|
|
|
103
|
-
function die(msg) {
|
|
104
|
-
console.error(`error: ${msg}`);
|
|
105
|
-
process.exit(1);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
226
|
function parseTargetsList(raw) {
|
|
109
227
|
if (!raw) return ["claude", "codex"];
|
|
110
228
|
const parts = raw
|
|
@@ -120,45 +238,6 @@ function parseTargetsList(raw) {
|
|
|
120
238
|
return [...new Set(parts)];
|
|
121
239
|
}
|
|
122
240
|
|
|
123
|
-
function expandNames(names, { includeDeps = true } = {}) {
|
|
124
|
-
const ordered = [];
|
|
125
|
-
const seen = new Set();
|
|
126
|
-
const stack = new Set();
|
|
127
|
-
|
|
128
|
-
function visit(name) {
|
|
129
|
-
if (seen.has(name)) return;
|
|
130
|
-
if (stack.has(name)) die(`Cycle detected while expanding "${name}"`);
|
|
131
|
-
stack.add(name);
|
|
132
|
-
|
|
133
|
-
if (catalog.bundles[name]) {
|
|
134
|
-
for (const item of catalog.bundles[name].items) {
|
|
135
|
-
visit(item);
|
|
136
|
-
}
|
|
137
|
-
stack.delete(name);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const skill = catalog.skills[name];
|
|
142
|
-
if (!skill) {
|
|
143
|
-
const bundleNames = Object.keys(catalog.bundles).join(", ");
|
|
144
|
-
die(`Unknown skill or bundle "${name}". Run "list" to inspect available bundles (${bundleNames}) and skills.`);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (includeDeps && Array.isArray(skill.dependsOn)) {
|
|
148
|
-
for (const dep of skill.dependsOn) {
|
|
149
|
-
visit(dep);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
stack.delete(name);
|
|
154
|
-
seen.add(name);
|
|
155
|
-
ordered.push(name);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
for (const n of names) visit(n);
|
|
159
|
-
return ordered;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
241
|
function skillSource(name, { local = false } = {}) {
|
|
163
242
|
const skill = catalog.skills[name];
|
|
164
243
|
if (skill.kind === "bundled") {
|
|
@@ -224,67 +303,193 @@ function runSkillfold(sfArgs, flags) {
|
|
|
224
303
|
}
|
|
225
304
|
|
|
226
305
|
function cmdList() {
|
|
227
|
-
console.log(
|
|
228
|
-
console.log("Bundles:");
|
|
229
|
-
for (const [name, bundle] of Object.entries(catalog.bundles)) {
|
|
230
|
-
const expanded = expandNames([name], { includeDeps: false });
|
|
231
|
-
console.log(` ${name.padEnd(18)} (${expanded.length} skills) ${bundle.description}`);
|
|
232
|
-
}
|
|
233
|
-
console.log("\nSkills:");
|
|
234
|
-
for (const [name, skill] of Object.entries(catalog.skills)) {
|
|
235
|
-
const tag = skill.kind === "bundled" ? "[bundled] " : "[upstream]";
|
|
236
|
-
const deps = skill.dependsOn?.length ? ` (deps: ${skill.dependsOn.join(", ")})` : "";
|
|
237
|
-
console.log(` ${name.padEnd(28)} ${tag} ${skill.description}${deps}`);
|
|
238
|
-
}
|
|
306
|
+
console.log(renderCatalogList(catalog, pkgJson));
|
|
239
307
|
}
|
|
240
308
|
|
|
241
309
|
function cmdInfo(args) {
|
|
242
310
|
if (args.length !== 1) die("usage: info <bundle-or-skill>");
|
|
243
|
-
const
|
|
244
|
-
if (
|
|
245
|
-
|
|
246
|
-
const resolved = expandNames([name], { includeDeps: true });
|
|
247
|
-
console.log(`Bundle: ${name}`);
|
|
248
|
-
console.log(`Description: ${b.description}`);
|
|
249
|
-
console.log(`Items: ${b.items.join(", ")}`);
|
|
250
|
-
console.log(`Expanded skills (${resolved.length}): ${resolved.join(", ")}`);
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
const s = catalog.skills[name];
|
|
254
|
-
if (!s) die(`Unknown bundle or skill "${name}"`);
|
|
255
|
-
console.log(`Skill: ${name}`);
|
|
256
|
-
console.log(`Kind: ${s.kind}`);
|
|
257
|
-
console.log(`Source: ${skillSource(name)}`);
|
|
258
|
-
console.log(`Description: ${s.description}`);
|
|
259
|
-
if (s.dependsOn?.length) {
|
|
260
|
-
console.log(`Depends on: ${s.dependsOn.join(", ")}`);
|
|
261
|
-
}
|
|
311
|
+
const rendered = renderSkillOrBundleInfo(args[0], catalog, (n) => skillSource(n));
|
|
312
|
+
if (!rendered) die(`Unknown bundle or skill "${args[0]}"`);
|
|
313
|
+
console.log(rendered);
|
|
262
314
|
}
|
|
263
315
|
|
|
264
|
-
function cmdInstall(args, flags) {
|
|
316
|
+
async function cmdInstall(args, flags) {
|
|
265
317
|
if (args.length === 0) {
|
|
266
|
-
die(
|
|
318
|
+
die(
|
|
319
|
+
'Specify at least one category, bundle, or skill (e.g. "install diagrams"), or run "onboard".',
|
|
320
|
+
);
|
|
267
321
|
}
|
|
268
|
-
|
|
322
|
+
|
|
323
|
+
let plan;
|
|
324
|
+
try {
|
|
325
|
+
plan = expandPlan(args, catalog, { includeDeps: !flags.noDeps });
|
|
326
|
+
} catch (err) {
|
|
327
|
+
die(err.message);
|
|
328
|
+
}
|
|
329
|
+
|
|
269
330
|
const targets = parseTargetsList(flags.targets);
|
|
270
331
|
const root = resolveRoot(flags);
|
|
271
|
-
const
|
|
332
|
+
const scope = flags.global ? "global" : "project";
|
|
333
|
+
|
|
334
|
+
console.log(renderInstallPlan(plan, catalog, { scope, targets, root }));
|
|
335
|
+
|
|
336
|
+
let probeResult = null;
|
|
337
|
+
let evalResult = null;
|
|
338
|
+
if (!flags.noCheck) {
|
|
339
|
+
const toolsNeeded = collectToolsToProbe(plan.ordered, catalog);
|
|
340
|
+
const projectDir = flags.global ? process.cwd() : root;
|
|
341
|
+
probeResult = probeHost({ projectDir, onlyTools: toolsNeeded });
|
|
342
|
+
evalResult = evaluateRequirements(plan.ordered, catalog, probeResult);
|
|
343
|
+
console.log("");
|
|
344
|
+
console.log(renderPreflightReport(evalResult, probeResult));
|
|
345
|
+
}
|
|
272
346
|
|
|
273
|
-
|
|
274
|
-
for (const name of
|
|
347
|
+
const manifestPath = ensureManifest(root, targets, flags.targets !== null);
|
|
348
|
+
for (const name of plan.ordered) {
|
|
275
349
|
const src = skillSource(name, { local: flags.local });
|
|
276
350
|
addSkillToManifest(manifestPath, name, src);
|
|
277
|
-
console.log(` + ${name}: ${src}`);
|
|
278
351
|
}
|
|
352
|
+
|
|
279
353
|
console.log("");
|
|
354
|
+
console.log(c.dim(`Updated ${manifestPath} (${plan.counts.total} skills). Running skillfold install...`));
|
|
280
355
|
runSkillfold(["install"], flags);
|
|
356
|
+
|
|
357
|
+
// Post-install OCR / host-fact / run-contract follow-up
|
|
358
|
+
if (evalResult && probeResult) {
|
|
359
|
+
const missingOcr = Boolean(evalResult.needsOcrSetup);
|
|
360
|
+
const missingHost = evalResult.needsHostFacts && !evalResult.hostProfileFound;
|
|
361
|
+
const missingContract = evalResult.needsRunContract && !evalResult.contractFound;
|
|
362
|
+
|
|
363
|
+
if (missingOcr || missingHost || missingContract) {
|
|
364
|
+
const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY && !flags.yes);
|
|
365
|
+
if (interactive) {
|
|
366
|
+
const prompter = createPrompter();
|
|
367
|
+
try {
|
|
368
|
+
if (missingOcr) {
|
|
369
|
+
await promptOcrSetupWizard(prompter, probeResult);
|
|
370
|
+
}
|
|
371
|
+
if (missingHost) {
|
|
372
|
+
console.log("");
|
|
373
|
+
const doHost = await prompter.confirm(
|
|
374
|
+
`Installed skills benefit from host facts. Scaffold ~/.agents/rules/host-${probeResult.host.shortHostname}.md now?`,
|
|
375
|
+
true,
|
|
376
|
+
);
|
|
377
|
+
if (doHost) await promptHostProfileWizard(prompter, probeResult);
|
|
378
|
+
}
|
|
379
|
+
if (missingContract) {
|
|
380
|
+
console.log("");
|
|
381
|
+
const doContract = await prompter.confirm(
|
|
382
|
+
"Selected orchestration/ticket skills need a Run Contract. Scaffold one now?",
|
|
383
|
+
true,
|
|
384
|
+
);
|
|
385
|
+
if (doContract) {
|
|
386
|
+
const defaultPlanSkill = plan.selectedSet.has("ticket-scheme") ? "ticket-scheme" : "";
|
|
387
|
+
await promptRunContractWizard(prompter, probeResult, { defaultPlanSkill });
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
} finally {
|
|
391
|
+
prompter.close();
|
|
392
|
+
}
|
|
393
|
+
} else {
|
|
394
|
+
console.log("");
|
|
395
|
+
if (missingOcr) {
|
|
396
|
+
console.log(
|
|
397
|
+
c.yellow(
|
|
398
|
+
`Tip: run "npx ${pkgJson.name} doctor --setup-ocr" to install and configure the ocr CLI (@alibaba-group/open-code-review).`,
|
|
399
|
+
),
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
if (missingHost) {
|
|
403
|
+
console.log(
|
|
404
|
+
c.yellow(
|
|
405
|
+
`Tip: run "npx ${pkgJson.name} doctor --setup-host" to scaffold ~/.agents/rules/host-${probeResult.host.shortHostname}.md.`,
|
|
406
|
+
),
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
if (missingContract) {
|
|
410
|
+
console.log(
|
|
411
|
+
c.yellow(
|
|
412
|
+
`Tip: run "npx ${pkgJson.name} doctor --setup-contract" to scaffold a Run Contract.`,
|
|
413
|
+
),
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
async function cmdDoctor(args, flags) {
|
|
422
|
+
const root = resolveRoot(flags);
|
|
423
|
+
const manifestPath = join(root, MANIFEST_FILENAME);
|
|
424
|
+
let skillNames = [];
|
|
425
|
+
let sourceLabel = "";
|
|
426
|
+
|
|
427
|
+
if (args.length > 0) {
|
|
428
|
+
try {
|
|
429
|
+
const plan = expandPlan(args, catalog, { includeDeps: !flags.noDeps });
|
|
430
|
+
skillNames = plan.ordered;
|
|
431
|
+
sourceLabel = `selection (${args.join(", ")})`;
|
|
432
|
+
} catch (err) {
|
|
433
|
+
die(err.message);
|
|
434
|
+
}
|
|
435
|
+
} else if (existsSync(manifestPath)) {
|
|
436
|
+
const manifest = loadManifest(manifestPath);
|
|
437
|
+
const declared = Object.keys(manifest.skills ?? {});
|
|
438
|
+
skillNames = declared.filter((name) => Boolean(catalog.skills[name]));
|
|
439
|
+
sourceLabel = manifestPath;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
const projectDir = flags.global ? process.cwd() : root;
|
|
443
|
+
const toolsToProbe =
|
|
444
|
+
skillNames.length > 0 ? collectToolsToProbe(skillNames, catalog) : null;
|
|
445
|
+
if (toolsToProbe && flags.setupOcr) toolsToProbe.add("ocr");
|
|
446
|
+
const probeResult = probeHost({ projectDir, onlyTools: toolsToProbe });
|
|
447
|
+
|
|
448
|
+
console.log(`${c.bold(pkgJson.name)} v${pkgJson.version} — Doctor`);
|
|
449
|
+
if (sourceLabel) {
|
|
450
|
+
console.log(c.dim(`Checking ${skillNames.length} catalog skill(s) from ${sourceLabel}\n`));
|
|
451
|
+
} else {
|
|
452
|
+
console.log(c.dim("No skillfold.yaml found in target directory — auditing general host environment.\n"));
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
const skillsToEvaluate =
|
|
456
|
+
skillNames.length > 0 ? skillNames : Object.keys(catalog.skills);
|
|
457
|
+
const evalResult = evaluateRequirements(skillsToEvaluate, catalog, probeResult);
|
|
458
|
+
console.log(renderPreflightReport(evalResult, probeResult));
|
|
459
|
+
|
|
460
|
+
if (flags.setupOcr || flags.setupHost || flags.setupContract) {
|
|
461
|
+
const prompter = createPrompter();
|
|
462
|
+
try {
|
|
463
|
+
if (flags.setupOcr) {
|
|
464
|
+
await promptOcrSetupWizard(prompter, probeResult);
|
|
465
|
+
}
|
|
466
|
+
if (flags.setupHost) {
|
|
467
|
+
await promptHostProfileWizard(prompter, probeResult);
|
|
468
|
+
}
|
|
469
|
+
if (flags.setupContract) {
|
|
470
|
+
const defaultPlanSkill = skillNames.includes("ticket-scheme") ? "ticket-scheme" : "";
|
|
471
|
+
await promptRunContractWizard(prompter, probeResult, { defaultPlanSkill });
|
|
472
|
+
}
|
|
473
|
+
} finally {
|
|
474
|
+
prompter.close();
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
if (flags.strict && evalResult.missingRequiredCount > 0) {
|
|
479
|
+
process.exit(1);
|
|
480
|
+
}
|
|
281
481
|
}
|
|
282
482
|
|
|
283
483
|
function cmdRemove(args, flags) {
|
|
284
484
|
if (args.length === 0) {
|
|
285
|
-
die('Specify at least one bundle or skill to remove (e.g. "remove web-ui").');
|
|
485
|
+
die('Specify at least one category, bundle, or skill to remove (e.g. "remove web-ui").');
|
|
486
|
+
}
|
|
487
|
+
let plan;
|
|
488
|
+
try {
|
|
489
|
+
plan = expandPlan(args, catalog, { includeDeps: false });
|
|
490
|
+
} catch (err) {
|
|
491
|
+
die(err.message);
|
|
286
492
|
}
|
|
287
|
-
const skills = expandNames(args, { includeDeps: false });
|
|
288
493
|
const root = resolveRoot(flags);
|
|
289
494
|
const manifestPath = join(root, MANIFEST_FILENAME);
|
|
290
495
|
if (!existsSync(manifestPath)) {
|
|
@@ -292,7 +497,7 @@ function cmdRemove(args, flags) {
|
|
|
292
497
|
}
|
|
293
498
|
const manifest = loadManifest(manifestPath);
|
|
294
499
|
let removed = 0;
|
|
295
|
-
for (const name of
|
|
500
|
+
for (const name of plan.ordered) {
|
|
296
501
|
if (manifest.skills[name] || manifest.compose?.[name]) {
|
|
297
502
|
removeSkillFromManifest(manifestPath, name);
|
|
298
503
|
console.log(` - removed ${name}`);
|
|
@@ -307,18 +512,80 @@ function cmdRemove(args, flags) {
|
|
|
307
512
|
runSkillfold(["install"], flags);
|
|
308
513
|
}
|
|
309
514
|
|
|
310
|
-
function main() {
|
|
515
|
+
async function main() {
|
|
311
516
|
const { command, args, flags } = parseArgs(process.argv.slice(2));
|
|
312
517
|
if (flags.version) {
|
|
313
518
|
console.log(pkgJson.version);
|
|
314
519
|
return;
|
|
315
520
|
}
|
|
316
|
-
if (flags.help
|
|
521
|
+
if (flags.help) {
|
|
522
|
+
usage();
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (!command) {
|
|
527
|
+
if (process.stdin.isTTY && process.stdout.isTTY) {
|
|
528
|
+
await runOnboard({
|
|
529
|
+
catalog,
|
|
530
|
+
pkgJson,
|
|
531
|
+
flags,
|
|
532
|
+
resolveRoot,
|
|
533
|
+
parseTargetsList,
|
|
534
|
+
ensureManifest,
|
|
535
|
+
addSkillToManifest,
|
|
536
|
+
skillSource,
|
|
537
|
+
runSkillfold,
|
|
538
|
+
MANIFEST_FILENAME,
|
|
539
|
+
});
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
317
542
|
usage();
|
|
318
543
|
return;
|
|
319
544
|
}
|
|
320
545
|
|
|
321
546
|
switch (command) {
|
|
547
|
+
case "onboard":
|
|
548
|
+
case "init":
|
|
549
|
+
await runOnboard({
|
|
550
|
+
catalog,
|
|
551
|
+
pkgJson,
|
|
552
|
+
flags,
|
|
553
|
+
resolveRoot,
|
|
554
|
+
parseTargetsList,
|
|
555
|
+
ensureManifest,
|
|
556
|
+
addSkillToManifest,
|
|
557
|
+
skillSource,
|
|
558
|
+
runSkillfold,
|
|
559
|
+
MANIFEST_FILENAME,
|
|
560
|
+
});
|
|
561
|
+
break;
|
|
562
|
+
case "setup":
|
|
563
|
+
case "recipe":
|
|
564
|
+
case "recipes": {
|
|
565
|
+
const recipeName = args[0];
|
|
566
|
+
if (!recipeName) {
|
|
567
|
+
console.log(renderRecipesList(catalog, pkgJson));
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
try {
|
|
571
|
+
await runRecipe(recipeName, {
|
|
572
|
+
catalog,
|
|
573
|
+
pkgJson,
|
|
574
|
+
flags,
|
|
575
|
+
args: args.slice(1),
|
|
576
|
+
resolveRoot,
|
|
577
|
+
parseTargetsList,
|
|
578
|
+
ensureManifest,
|
|
579
|
+
addSkillToManifest,
|
|
580
|
+
skillSource,
|
|
581
|
+
runSkillfold,
|
|
582
|
+
MANIFEST_FILENAME,
|
|
583
|
+
});
|
|
584
|
+
} catch (err) {
|
|
585
|
+
die(err.message);
|
|
586
|
+
}
|
|
587
|
+
break;
|
|
588
|
+
}
|
|
322
589
|
case "list":
|
|
323
590
|
case "ls":
|
|
324
591
|
cmdList();
|
|
@@ -328,7 +595,11 @@ function main() {
|
|
|
328
595
|
break;
|
|
329
596
|
case "install":
|
|
330
597
|
case "add":
|
|
331
|
-
cmdInstall(args, flags);
|
|
598
|
+
await cmdInstall(args, flags);
|
|
599
|
+
break;
|
|
600
|
+
case "doctor":
|
|
601
|
+
case "preflight":
|
|
602
|
+
await cmdDoctor(args, flags);
|
|
332
603
|
break;
|
|
333
604
|
case "update":
|
|
334
605
|
case "sync":
|
|
@@ -342,8 +613,28 @@ function main() {
|
|
|
342
613
|
runSkillfold(["check"], flags);
|
|
343
614
|
break;
|
|
344
615
|
default:
|
|
616
|
+
if (hasRecipe(command, catalog)) {
|
|
617
|
+
try {
|
|
618
|
+
await runRecipe(command, {
|
|
619
|
+
catalog,
|
|
620
|
+
pkgJson,
|
|
621
|
+
flags,
|
|
622
|
+
args,
|
|
623
|
+
resolveRoot,
|
|
624
|
+
parseTargetsList,
|
|
625
|
+
ensureManifest,
|
|
626
|
+
addSkillToManifest,
|
|
627
|
+
skillSource,
|
|
628
|
+
runSkillfold,
|
|
629
|
+
MANIFEST_FILENAME,
|
|
630
|
+
});
|
|
631
|
+
} catch (err) {
|
|
632
|
+
die(err.message);
|
|
633
|
+
}
|
|
634
|
+
break;
|
|
635
|
+
}
|
|
345
636
|
die(`Unknown command "${command}". Run with --help to see available commands.`);
|
|
346
637
|
}
|
|
347
638
|
}
|
|
348
639
|
|
|
349
|
-
main();
|
|
640
|
+
await main();
|