@greenrenge/skills 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +99 -2
- package/bin/cli.mjs +525 -0
- package/bin/lib/onboard.mjs +1168 -0
- package/bin/lib/probe.mjs +631 -0
- package/catalog.json +590 -0
- package/package.json +50 -4
- package/skills/deck-story/SKILL.md +258 -0
- package/skills/deck-story/check-svg-text.mjs +94 -0
- package/skills/deck-story/check.mjs +348 -0
- package/skills/diagram-router/LICENSE +21 -0
- package/skills/diagram-router/SKILL.md +193 -0
- package/skills/diagram-router/THIRD_PARTY_NOTICES.md +15 -0
- package/skills/diagram-router/references/channels.md +213 -0
- package/skills/diagram-router/references/evals.md +85 -0
- package/skills/diagram-router/references/gathering.md +101 -0
- package/skills/diagram-router/references/prior-art.md +65 -0
- package/skills/diagram-router/references/routing.md +166 -0
- package/skills/diagram-router/skill-release.json +17 -0
- package/skills/frontend-design/SKILL.md +443 -0
- package/skills/frontend-design/references/rtl.md +72 -0
- package/skills/frontend-design/scripts/.upstream-sha +1 -0
- package/skills/frontend-design/scripts/LICENSE +21 -0
- package/skills/frontend-design/scripts/README.md +24 -0
- package/skills/frontend-design/scripts/gates.md +243 -0
- package/skills/frontend-design/scripts/sloplint-render.mjs +1283 -0
- package/skills/frontend-design/scripts/sloplint.mjs +4426 -0
- package/skills/open-code-review-rules/SKILL.md +59 -0
- package/skills/open-code-review-rules/references/ocr-allowlists.json +161 -0
- package/skills/open-code-review-rules/references/ocr-rule-semantics.md +39 -0
- package/skills/open-code-review-rules/scripts/verify_ocr_rules.py +836 -0
- package/skills/plain-english-mode/SKILL.md +41 -0
- package/skills/pr-diagram-portfolio/SKILL.md +75 -0
- package/skills/pr-diagram-portfolio/references/angle-framework.md +124 -0
- package/skills/pr-diagram-portfolio/references/portfolio-delivery.md +79 -0
- package/skills/pr-diagram-portfolio/scripts/restore_still_css.py +180 -0
- package/skills/pr-lens/LICENSE-upstream +21 -0
- package/skills/pr-lens/SKILL.md +99 -0
- package/skills/pr-lens/VENDOR.md +47 -0
- package/skills/pr-lens/package-lock.json +91 -0
- package/skills/pr-lens/package.json +9 -0
- package/skills/pr-lens/references/config.md +90 -0
- package/skills/pr-lens/references/example.graph.json +580 -0
- package/skills/pr-lens/references/graph-document.md +233 -0
- package/skills/pr-lens/skill-release.json +16 -0
- package/skills/security-remediation-epic/SKILL.md +316 -0
- package/skills/security-remediation-epic/prompt-template.md +33 -0
- package/skills/skill-maintainer/SKILL.md +99 -0
- package/skills/skill-maintainer/references/placement-and-coupling.md +43 -0
- package/skills/skill-maintainer/scripts/audit_skills.py +297 -0
- package/skills/t3-successor-handoff/SKILL.md +141 -0
- package/skills/t3-thread-bridge/SKILL.md +175 -0
- package/skills/t3-thread-bridge/references/launch-recipes.md +123 -0
- package/skills/t3-thread-bridge/references/ping-back.md +108 -0
- package/skills/t3-thread-bridge/scripts/thread_ledger.py +203 -0
- package/skills/t3-ticket-orchestrator/SKILL.md +304 -0
- package/skills/t3-ticket-orchestrator/references/proving-the-gates.md +63 -0
- package/skills/ticket-scheme/SKILL.md +144 -0
- package/skills/ulw-plan/SKILL.md +98 -0
- package/skills/ulw-plan/references/full-workflow.md +255 -0
- package/skills/ulw-plan/references/intent-clear.md +44 -0
- package/skills/ulw-plan/references/intent-unclear.md +44 -0
- package/skills/ulw-plan/scripts/plan-templates.mjs +180 -0
- package/skills/ulw-plan/scripts/scaffold-plan.mjs +187 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 GreenRenge
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,100 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @greenrenge/skills
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Curated portable agent skills, categorized bundles, host preflight checks, and an interactive onboarding CLI wrapped around [`skillfold`](https://www.npmjs.com/package/skillfold) for Claude Code, Codex, OpenCode, Cursor, Gemini, and T3 Code.
|
|
4
|
+
|
|
5
|
+
- **Categorized installs with dependency trees:** see exactly which category each skill belongs to and why transitive dependencies are pulled in.
|
|
6
|
+
- **OCR CLI, host-fact & Run-Contract onboarding:** automatically probes local runtimes/tools (`node`, `python3`, `git`, `gh`, `ocr`, `chromium`, `magick`, `playwright`, `wrangler`, `cf`, `osv-scanner`) and scaffolds personal user-scoped host facts (`~/.agents/rules/host-<hostname>.md`) or per-repo Run Contracts when selected skills need them.
|
|
7
|
+
- **Bundled + pinned upstream skills:** bundled skills ship directly inside this npm package (`npm:@greenrenge/skills/<skill>`); upstream skills are referenced via pinned `github:` commits so the package stays tiny and upstream licenses remain intact.
|
|
8
|
+
- **Lockfile-verified:** every install writes `skillfold.yaml` and `skillfold.lock` with integrity hashes.
|
|
9
|
+
|
|
10
|
+
## Quick start
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Guided interactive onboarding (category picker + dependency tree + host profile setup)
|
|
14
|
+
npx @greenrenge/skills onboard
|
|
15
|
+
# (or simply run `npx @greenrenge/skills` in an interactive terminal)
|
|
16
|
+
|
|
17
|
+
# Browse categories, bundles, and skills with dependency & host-fact badges
|
|
18
|
+
npx @greenrenge/skills list
|
|
19
|
+
|
|
20
|
+
# Inspect a category, bundle, or individual skill
|
|
21
|
+
npx @greenrenge/skills info diagrams
|
|
22
|
+
npx @greenrenge/skills info pr-diagram-portfolio
|
|
23
|
+
|
|
24
|
+
# Install a category or individual skill (transitive dependencies auto-expand)
|
|
25
|
+
npx @greenrenge/skills install diagrams
|
|
26
|
+
npx @greenrenge/skills install pr-diagram-portfolio
|
|
27
|
+
npx @greenrenge/skills install web-ui
|
|
28
|
+
|
|
29
|
+
# Install globally for your user profile
|
|
30
|
+
npx @greenrenge/skills install workflow diagrams --global
|
|
31
|
+
|
|
32
|
+
# Check your machine against installed skills (and scaffold missing host facts)
|
|
33
|
+
npx @greenrenge/skills doctor
|
|
34
|
+
npx @greenrenge/skills doctor --setup-ocr
|
|
35
|
+
npx @greenrenge/skills doctor --setup-host
|
|
36
|
+
|
|
37
|
+
# Stay in sync with new releases
|
|
38
|
+
npx @greenrenge/skills update
|
|
39
|
+
|
|
40
|
+
# Verify manifest, lockfile, and installed targets match (great in CI)
|
|
41
|
+
npx @greenrenge/skills check
|
|
42
|
+
|
|
43
|
+
# Remove a category, bundle, or skill
|
|
44
|
+
npx @greenrenge/skills remove web-ui
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## OCR CLI, Host facts & Run Contracts
|
|
48
|
+
|
|
49
|
+
Some skill categories need local tools or environment-specific facts:
|
|
50
|
+
|
|
51
|
+
- **Open Code Review (`ocr`) CLI** — used by the `ocr` category (`open-code-review`, `open-code-review-delegate`). `onboard` and `doctor --setup-ocr` detect missing `ocr` or unconfigured `~/.opencodereview/config.json`, offer to install `@alibaba-group/open-code-review` globally, and guide `ocr config provider` + `ocr llm test`.
|
|
52
|
+
|
|
53
|
+
- **Host Profile (`~/.agents/rules/host-<hostname>.md`)** — used by diagram/deck skills (`diagram-router`, `archify`, `stack-diagram`, `diagram-design`, `pr-lens`, `deck-story`) to locate your local headless Chromium/Chrome binary, PNG renderer fallback, and scratch temp dir. Always written to **user scope** (and linked into `~/.claude/rules/` if `~/.claude` exists) so machine-specific paths never leak into shared repositories.
|
|
54
|
+
- **Orchestrator Run Contract (`~/.agents/rules/<repo>-contract.md` or `docs/agents/orchestrator-contract.md`)** — used by `t3-ticket-orchestrator` to supply repo-specific `target_branch`, `bootstrap_command`, `verify_targets`, and gate paths.
|
|
55
|
+
|
|
56
|
+
Run `npx @greenrenge/skills onboard` or `npx @greenrenge/skills doctor --setup-host` to detect and generate these automatically.
|
|
57
|
+
|
|
58
|
+
## Direct `skillfold` usage
|
|
59
|
+
|
|
60
|
+
Because `package.json` declares an `"agentskills"` map, you can also use `skillfold` directly:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx skillfold add npm:@greenrenge/skills/diagram-router
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Skill categories
|
|
67
|
+
|
|
68
|
+
| Category | Opt-in | Skills | Notes |
|
|
69
|
+
|---|---|---|---|
|
|
70
|
+
| `workflow` — Core Workflow & Planning | no | `skill-maintainer`, `ulw-plan`, `plain-english-mode` | Skill maintenance, explore-first planning, and plain-English mode. |
|
|
71
|
+
| `ocr` — Code Review (OCR) | no | `open-code-review-rules`, `open-code-review`, `open-code-review-delegate` | AI-powered diff review and rule auditing with alibaba/open-code-review. Needs `ocr` CLI (`@alibaba-group/open-code-review`). |
|
|
72
|
+
| `diagrams` — Diagrams & Presentations | no | `diagram-router`, `pr-diagram-portfolio`, `deck-story`, `pr-lens`, `archify`, `stack-diagram`, `diagram-design` | Routed architecture, PR delta, portfolio, and slide-deck generation. Uses host profile (`~/.agents/rules/host-*.md`). |
|
|
73
|
+
| `orchestration` — Orchestration & Ticket Delivery | no | `ticket-scheme`, `t3-thread-bridge`, `t3-successor-handoff`, `t3-ticket-orchestrator`, `security-remediation-epic`, `to-spec`, `to-tickets`, `implement`, `tdd`, `code-review`, `handoff` | Spec-to-tickets scheme (with mattpocock/skills), T3 ticket orchestration, handoffs, and security remediation. Uses per-repo Run Contract. |
|
|
74
|
+
| `web-ui` — Frontend & Web UI | yes | `frontend-design`, `modern-web-guidance` | Anti-slop UI design system and modern browser Web API guidance. |
|
|
75
|
+
| `cloudflare` — Cloudflare Workers & CLI | yes | `agents-sdk`, `cf-cli`, `durable-objects`, `frameworks-on-cloudflare`, `nextjs-on-cloudflare`, `workers-best-practices`, `workers-development`, `wrangler` | Cloudflare cf CLI, Wrangler, Workers, Durable Objects, and Agents SDK. |
|
|
76
|
+
|
|
77
|
+
## Bundle aliases
|
|
78
|
+
|
|
79
|
+
| Alias | Expands to | Description |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| `core` | `workflow`, `ocr` | Alias for workflow + ocr. |
|
|
82
|
+
| `t3-orchestration` | `orchestration` | Alias for orchestration. |
|
|
83
|
+
| `all` | `workflow`, `ocr`, `diagrams`, `orchestration`, `web-ui`, `cloudflare` | Every portable category (workflow + ocr + diagrams + orchestration + web-ui + cloudflare). |
|
|
84
|
+
|
|
85
|
+
## Options
|
|
86
|
+
|
|
87
|
+
| Flag | Description |
|
|
88
|
+
|---|---|
|
|
89
|
+
| `--targets <list>` | Comma-separated targets: `claude`, `codex`, `cursor` (default: `claude,codex`) |
|
|
90
|
+
| `--dir <path>` | Target project directory (default: current working directory) |
|
|
91
|
+
| `-g, --global` | Operate on global `skillfold` config (`~/.config/skillfold`) |
|
|
92
|
+
| `--no-deps` | Do not auto-expand `dependsOn` skills during install |
|
|
93
|
+
| `--no-check` | Skip host preflight probe during install |
|
|
94
|
+
| `-y, --yes` | Non-interactive install (skip post-install host-fact prompts) |
|
|
95
|
+
| `--setup-ocr` | Interactively install & configure the `ocr` CLI (`onboard` / `doctor`) |
|
|
96
|
+
| `--setup-host` | Interactively scaffold `~/.agents/rules/host-<hostname>.md` (`onboard` / `doctor`) |
|
|
97
|
+
| `--setup-contract` | Interactively scaffold a `t3-ticket-orchestrator` Run Contract (`onboard` / `doctor`) |
|
|
98
|
+
| `--strict` | Exit non-zero from `doctor` when required tools are missing |
|
|
99
|
+
| `--force` | Pass `--force` to `skillfold install` / `update` |
|
|
100
|
+
| `--frozen` | Pass `--frozen` to `skillfold install` |
|
package/bin/cli.mjs
ADDED
|
@@ -0,0 +1,525 @@
|
|
|
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
|
+
*/
|
|
15
|
+
import { execFileSync } from "node:child_process";
|
|
16
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { dirname, join, resolve } from "node:path";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
19
|
+
import {
|
|
20
|
+
addSkillToManifest,
|
|
21
|
+
globalConfigRoot,
|
|
22
|
+
loadManifest,
|
|
23
|
+
MANIFEST_FILENAME,
|
|
24
|
+
removeSkillFromManifest,
|
|
25
|
+
TARGET_NAMES,
|
|
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
|
+
|
|
42
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
43
|
+
const PKG_ROOT = resolve(__dirname, "..");
|
|
44
|
+
const CATALOG_PATH = join(PKG_ROOT, "catalog.json");
|
|
45
|
+
const PKG_JSON_PATH = join(PKG_ROOT, "package.json");
|
|
46
|
+
|
|
47
|
+
const skillfoldEntry = fileURLToPath(import.meta.resolve("skillfold"));
|
|
48
|
+
const SKILLFOLD_BIN = join(dirname(skillfoldEntry), "cli.js");
|
|
49
|
+
|
|
50
|
+
const catalog = JSON.parse(readFileSync(CATALOG_PATH, "utf8"));
|
|
51
|
+
const pkgJson = JSON.parse(readFileSync(PKG_JSON_PATH, "utf8"));
|
|
52
|
+
|
|
53
|
+
function usage() {
|
|
54
|
+
console.log(`${c.bold(pkgJson.name)} v${pkgJson.version} — ${pkgJson.description}
|
|
55
|
+
|
|
56
|
+
Usage:
|
|
57
|
+
npx ${pkgJson.name} Start interactive onboarding (TTY)
|
|
58
|
+
npx ${pkgJson.name} onboard [options] Guided category picker + host facts setup
|
|
59
|
+
npx ${pkgJson.name} list List categories, bundles, and skills
|
|
60
|
+
npx ${pkgJson.name} info <bundle-or-skill> Show category, dependencies, and requirements
|
|
61
|
+
npx ${pkgJson.name} install <name...> [options] Install categories, bundles, or skills
|
|
62
|
+
npx ${pkgJson.name} doctor [name...] [options] Check host tools, host facts, and contracts
|
|
63
|
+
npx ${pkgJson.name} update [skill...] [options] Update installed skills via skillfold
|
|
64
|
+
npx ${pkgJson.name} remove <name...> [options] Remove skills and reconcile
|
|
65
|
+
npx ${pkgJson.name} check [options] Verify lockfile & targets via skillfold
|
|
66
|
+
|
|
67
|
+
Options:
|
|
68
|
+
--targets <list> Comma-separated targets: ${TARGET_NAMES.join(", ")} (default: claude,codex)
|
|
69
|
+
--dir <path> Target project directory (default: cwd)
|
|
70
|
+
-g, --global Operate on global skillfold config (~/.config/skillfold)
|
|
71
|
+
--no-deps Do not auto-expand dependsOn skills during install
|
|
72
|
+
--no-check Skip host preflight check during install
|
|
73
|
+
-y, --yes Non-interactive install (skip post-install host-fact prompts)
|
|
74
|
+
--setup-ocr Install & configure the ocr CLI (with onboard or doctor)
|
|
75
|
+
--setup-host Scaffold ~/.agents/rules/host-<hostname>.md (with onboard or doctor)
|
|
76
|
+
--setup-contract Scaffold an orchestrator Run Contract (with onboard or doctor)
|
|
77
|
+
--strict Exit non-zero from doctor if required tools are missing
|
|
78
|
+
--force Pass --force to skillfold install/update
|
|
79
|
+
--frozen Pass --frozen to skillfold install
|
|
80
|
+
--local Reference bundled skills by local path (testing)
|
|
81
|
+
-h, --help Show this help
|
|
82
|
+
-v, --version Show package version
|
|
83
|
+
`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function die(msg) {
|
|
87
|
+
console.error(`${c.red("error:")} ${msg}`);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function parseArgs(argv) {
|
|
92
|
+
const positionals = [];
|
|
93
|
+
const flags = {
|
|
94
|
+
global: false,
|
|
95
|
+
dir: null,
|
|
96
|
+
targets: null,
|
|
97
|
+
noDeps: false,
|
|
98
|
+
noCheck: false,
|
|
99
|
+
yes: false,
|
|
100
|
+
setupOcr: false,
|
|
101
|
+
setupHost: false,
|
|
102
|
+
setupContract: false,
|
|
103
|
+
strict: false,
|
|
104
|
+
force: false,
|
|
105
|
+
frozen: false,
|
|
106
|
+
local: false,
|
|
107
|
+
help: false,
|
|
108
|
+
version: false,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
for (let i = 0; i < argv.length; i++) {
|
|
112
|
+
const arg = argv[i];
|
|
113
|
+
if (arg === "-h" || arg === "--help") {
|
|
114
|
+
flags.help = true;
|
|
115
|
+
} else if (arg === "-v" || arg === "--version") {
|
|
116
|
+
flags.version = true;
|
|
117
|
+
} else if (arg === "-g" || arg === "--global") {
|
|
118
|
+
flags.global = true;
|
|
119
|
+
} else if (arg === "-y" || arg === "--yes") {
|
|
120
|
+
flags.yes = true;
|
|
121
|
+
} else if (arg === "--no-deps") {
|
|
122
|
+
flags.noDeps = true;
|
|
123
|
+
} else if (arg === "--no-check") {
|
|
124
|
+
flags.noCheck = true;
|
|
125
|
+
} else if (arg === "--setup-ocr") {
|
|
126
|
+
flags.setupOcr = true;
|
|
127
|
+
} else if (arg === "--setup-host") {
|
|
128
|
+
flags.setupHost = true;
|
|
129
|
+
} else if (arg === "--setup-contract") {
|
|
130
|
+
flags.setupContract = true;
|
|
131
|
+
} else if (arg === "--strict") {
|
|
132
|
+
flags.strict = true;
|
|
133
|
+
} else if (arg === "--force") {
|
|
134
|
+
flags.force = true;
|
|
135
|
+
} else if (arg === "--frozen") {
|
|
136
|
+
flags.frozen = true;
|
|
137
|
+
} else if (arg === "--local") {
|
|
138
|
+
flags.local = true;
|
|
139
|
+
} else if (arg === "--dir") {
|
|
140
|
+
flags.dir = argv[++i];
|
|
141
|
+
if (!flags.dir) die("--dir requires a path");
|
|
142
|
+
} else if (arg.startsWith("--dir=")) {
|
|
143
|
+
flags.dir = arg.slice("--dir=".length);
|
|
144
|
+
} else if (arg === "--targets") {
|
|
145
|
+
flags.targets = argv[++i];
|
|
146
|
+
if (!flags.targets) die("--targets requires a comma-separated list");
|
|
147
|
+
} else if (arg.startsWith("--targets=")) {
|
|
148
|
+
flags.targets = arg.slice("--targets=".length);
|
|
149
|
+
} else if (arg.startsWith("-")) {
|
|
150
|
+
die(`Unknown option: ${arg}`);
|
|
151
|
+
} else {
|
|
152
|
+
positionals.push(arg);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return { command: positionals[0], args: positionals.slice(1), flags };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function parseTargetsList(raw) {
|
|
159
|
+
if (!raw) return ["claude", "codex"];
|
|
160
|
+
const parts = raw
|
|
161
|
+
.split(",")
|
|
162
|
+
.map((s) => s.trim())
|
|
163
|
+
.filter(Boolean);
|
|
164
|
+
if (parts.length === 0) die("--targets must not be empty");
|
|
165
|
+
for (const t of parts) {
|
|
166
|
+
if (!TARGET_NAMES.includes(t)) {
|
|
167
|
+
die(`Unknown target "${t}". Expected one of: ${TARGET_NAMES.join(", ")}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return [...new Set(parts)];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function skillSource(name, { local = false } = {}) {
|
|
174
|
+
const skill = catalog.skills[name];
|
|
175
|
+
if (skill.kind === "bundled") {
|
|
176
|
+
if (local) {
|
|
177
|
+
return join(PKG_ROOT, "skills", name);
|
|
178
|
+
}
|
|
179
|
+
return `npm:${pkgJson.name}/${name}`;
|
|
180
|
+
}
|
|
181
|
+
return skill.source;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function resolveRoot(flags) {
|
|
185
|
+
if (flags.global) return globalConfigRoot();
|
|
186
|
+
return resolve(flags.dir ?? process.cwd());
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function ensureManifest(root, targets, explicitTargets) {
|
|
190
|
+
mkdirSync(root, { recursive: true });
|
|
191
|
+
const manifestPath = join(root, MANIFEST_FILENAME);
|
|
192
|
+
if (!existsSync(manifestPath)) {
|
|
193
|
+
const content = [
|
|
194
|
+
`# Managed via ${pkgJson.name} (skillfold)`,
|
|
195
|
+
`targets: [${targets.join(", ")}]`,
|
|
196
|
+
"",
|
|
197
|
+
].join("\n");
|
|
198
|
+
writeFileSync(manifestPath, content, "utf8");
|
|
199
|
+
return manifestPath;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (explicitTargets) {
|
|
203
|
+
const existing = readFileSync(manifestPath, "utf8");
|
|
204
|
+
const targetLine = `targets: [${targets.join(", ")}]`;
|
|
205
|
+
let updated;
|
|
206
|
+
if (/^targets:.*$/m.test(existing)) {
|
|
207
|
+
updated = existing.replace(/^targets:.*$/m, targetLine);
|
|
208
|
+
} else {
|
|
209
|
+
updated = `${targetLine}\n${existing}`;
|
|
210
|
+
}
|
|
211
|
+
writeFileSync(manifestPath, updated, "utf8");
|
|
212
|
+
}
|
|
213
|
+
return manifestPath;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function runSkillfold(sfArgs, flags) {
|
|
217
|
+
const cmdArgs = [SKILLFOLD_BIN, ...sfArgs];
|
|
218
|
+
if (flags.global) {
|
|
219
|
+
cmdArgs.push("--global");
|
|
220
|
+
} else if (flags.dir) {
|
|
221
|
+
cmdArgs.push("--dir", resolve(flags.dir));
|
|
222
|
+
}
|
|
223
|
+
if (flags.force && (sfArgs[0] === "install" || sfArgs[0] === "update")) {
|
|
224
|
+
cmdArgs.push("--force");
|
|
225
|
+
}
|
|
226
|
+
if (flags.frozen && sfArgs[0] === "install") {
|
|
227
|
+
cmdArgs.push("--frozen");
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
try {
|
|
231
|
+
execFileSync(process.execPath, cmdArgs, { stdio: "inherit" });
|
|
232
|
+
} catch (err) {
|
|
233
|
+
process.exit(typeof err.status === "number" ? err.status : 1);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function cmdList() {
|
|
238
|
+
console.log(renderCatalogList(catalog, pkgJson));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function cmdInfo(args) {
|
|
242
|
+
if (args.length !== 1) die("usage: info <bundle-or-skill>");
|
|
243
|
+
const rendered = renderSkillOrBundleInfo(args[0], catalog, (n) => skillSource(n));
|
|
244
|
+
if (!rendered) die(`Unknown bundle or skill "${args[0]}"`);
|
|
245
|
+
console.log(rendered);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async function cmdInstall(args, flags) {
|
|
249
|
+
if (args.length === 0) {
|
|
250
|
+
die(
|
|
251
|
+
'Specify at least one category, bundle, or skill (e.g. "install diagrams"), or run "onboard".',
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
let plan;
|
|
256
|
+
try {
|
|
257
|
+
plan = expandPlan(args, catalog, { includeDeps: !flags.noDeps });
|
|
258
|
+
} catch (err) {
|
|
259
|
+
die(err.message);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const targets = parseTargetsList(flags.targets);
|
|
263
|
+
const root = resolveRoot(flags);
|
|
264
|
+
const scope = flags.global ? "global" : "project";
|
|
265
|
+
|
|
266
|
+
console.log(renderInstallPlan(plan, catalog, { scope, targets, root }));
|
|
267
|
+
|
|
268
|
+
let probeResult = null;
|
|
269
|
+
let evalResult = null;
|
|
270
|
+
if (!flags.noCheck) {
|
|
271
|
+
const toolsNeeded = collectToolsToProbe(plan.ordered, catalog);
|
|
272
|
+
const projectDir = flags.global ? process.cwd() : root;
|
|
273
|
+
probeResult = probeHost({ projectDir, onlyTools: toolsNeeded });
|
|
274
|
+
evalResult = evaluateRequirements(plan.ordered, catalog, probeResult);
|
|
275
|
+
console.log("");
|
|
276
|
+
console.log(renderPreflightReport(evalResult, probeResult));
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const manifestPath = ensureManifest(root, targets, flags.targets !== null);
|
|
280
|
+
for (const name of plan.ordered) {
|
|
281
|
+
const src = skillSource(name, { local: flags.local });
|
|
282
|
+
addSkillToManifest(manifestPath, name, src);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
console.log("");
|
|
286
|
+
console.log(c.dim(`Updated ${manifestPath} (${plan.counts.total} skills). Running skillfold install...`));
|
|
287
|
+
runSkillfold(["install"], flags);
|
|
288
|
+
|
|
289
|
+
// Post-install OCR / host-fact / run-contract follow-up
|
|
290
|
+
if (evalResult && probeResult) {
|
|
291
|
+
const missingOcr = Boolean(evalResult.needsOcrSetup);
|
|
292
|
+
const missingHost = evalResult.needsHostFacts && !evalResult.hostProfileFound;
|
|
293
|
+
const missingContract = evalResult.needsRunContract && !evalResult.contractFound;
|
|
294
|
+
|
|
295
|
+
if (missingOcr || missingHost || missingContract) {
|
|
296
|
+
const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY && !flags.yes);
|
|
297
|
+
if (interactive) {
|
|
298
|
+
const prompter = createPrompter();
|
|
299
|
+
try {
|
|
300
|
+
if (missingOcr) {
|
|
301
|
+
await promptOcrSetupWizard(prompter, probeResult);
|
|
302
|
+
}
|
|
303
|
+
if (missingHost) {
|
|
304
|
+
console.log("");
|
|
305
|
+
const doHost = await prompter.confirm(
|
|
306
|
+
`Installed skills benefit from host facts. Scaffold ~/.agents/rules/host-${probeResult.host.shortHostname}.md now?`,
|
|
307
|
+
true,
|
|
308
|
+
);
|
|
309
|
+
if (doHost) await promptHostProfileWizard(prompter, probeResult);
|
|
310
|
+
}
|
|
311
|
+
if (missingContract) {
|
|
312
|
+
console.log("");
|
|
313
|
+
const doContract = await prompter.confirm(
|
|
314
|
+
"Selected orchestration/ticket skills need a Run Contract. Scaffold one now?",
|
|
315
|
+
true,
|
|
316
|
+
);
|
|
317
|
+
if (doContract) {
|
|
318
|
+
const defaultPlanSkill = plan.selectedSet.has("ticket-scheme") ? "ticket-scheme" : "";
|
|
319
|
+
await promptRunContractWizard(prompter, probeResult, { defaultPlanSkill });
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
} finally {
|
|
323
|
+
prompter.close();
|
|
324
|
+
}
|
|
325
|
+
} else {
|
|
326
|
+
console.log("");
|
|
327
|
+
if (missingOcr) {
|
|
328
|
+
console.log(
|
|
329
|
+
c.yellow(
|
|
330
|
+
`Tip: run "npx ${pkgJson.name} doctor --setup-ocr" to install and configure the ocr CLI (@alibaba-group/open-code-review).`,
|
|
331
|
+
),
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
if (missingHost) {
|
|
335
|
+
console.log(
|
|
336
|
+
c.yellow(
|
|
337
|
+
`Tip: run "npx ${pkgJson.name} doctor --setup-host" to scaffold ~/.agents/rules/host-${probeResult.host.shortHostname}.md.`,
|
|
338
|
+
),
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
if (missingContract) {
|
|
342
|
+
console.log(
|
|
343
|
+
c.yellow(
|
|
344
|
+
`Tip: run "npx ${pkgJson.name} doctor --setup-contract" to scaffold a Run Contract.`,
|
|
345
|
+
),
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
async function cmdDoctor(args, flags) {
|
|
354
|
+
const root = resolveRoot(flags);
|
|
355
|
+
const manifestPath = join(root, MANIFEST_FILENAME);
|
|
356
|
+
let skillNames = [];
|
|
357
|
+
let sourceLabel = "";
|
|
358
|
+
|
|
359
|
+
if (args.length > 0) {
|
|
360
|
+
try {
|
|
361
|
+
const plan = expandPlan(args, catalog, { includeDeps: !flags.noDeps });
|
|
362
|
+
skillNames = plan.ordered;
|
|
363
|
+
sourceLabel = `selection (${args.join(", ")})`;
|
|
364
|
+
} catch (err) {
|
|
365
|
+
die(err.message);
|
|
366
|
+
}
|
|
367
|
+
} else if (existsSync(manifestPath)) {
|
|
368
|
+
const manifest = loadManifest(manifestPath);
|
|
369
|
+
const declared = Object.keys(manifest.skills ?? {});
|
|
370
|
+
skillNames = declared.filter((name) => Boolean(catalog.skills[name]));
|
|
371
|
+
sourceLabel = manifestPath;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const projectDir = flags.global ? process.cwd() : root;
|
|
375
|
+
const toolsToProbe =
|
|
376
|
+
skillNames.length > 0 ? collectToolsToProbe(skillNames, catalog) : null;
|
|
377
|
+
if (toolsToProbe && flags.setupOcr) toolsToProbe.add("ocr");
|
|
378
|
+
const probeResult = probeHost({ projectDir, onlyTools: toolsToProbe });
|
|
379
|
+
|
|
380
|
+
console.log(`${c.bold(pkgJson.name)} v${pkgJson.version} — Doctor`);
|
|
381
|
+
if (sourceLabel) {
|
|
382
|
+
console.log(c.dim(`Checking ${skillNames.length} catalog skill(s) from ${sourceLabel}\n`));
|
|
383
|
+
} else {
|
|
384
|
+
console.log(c.dim("No skillfold.yaml found in target directory — auditing general host environment.\n"));
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const skillsToEvaluate =
|
|
388
|
+
skillNames.length > 0 ? skillNames : Object.keys(catalog.skills);
|
|
389
|
+
const evalResult = evaluateRequirements(skillsToEvaluate, catalog, probeResult);
|
|
390
|
+
console.log(renderPreflightReport(evalResult, probeResult));
|
|
391
|
+
|
|
392
|
+
if (flags.setupOcr || flags.setupHost || flags.setupContract) {
|
|
393
|
+
const prompter = createPrompter();
|
|
394
|
+
try {
|
|
395
|
+
if (flags.setupOcr) {
|
|
396
|
+
await promptOcrSetupWizard(prompter, probeResult);
|
|
397
|
+
}
|
|
398
|
+
if (flags.setupHost) {
|
|
399
|
+
await promptHostProfileWizard(prompter, probeResult);
|
|
400
|
+
}
|
|
401
|
+
if (flags.setupContract) {
|
|
402
|
+
const defaultPlanSkill = skillNames.includes("ticket-scheme") ? "ticket-scheme" : "";
|
|
403
|
+
await promptRunContractWizard(prompter, probeResult, { defaultPlanSkill });
|
|
404
|
+
}
|
|
405
|
+
} finally {
|
|
406
|
+
prompter.close();
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
if (flags.strict && evalResult.missingRequiredCount > 0) {
|
|
411
|
+
process.exit(1);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function cmdRemove(args, flags) {
|
|
416
|
+
if (args.length === 0) {
|
|
417
|
+
die('Specify at least one category, bundle, or skill to remove (e.g. "remove web-ui").');
|
|
418
|
+
}
|
|
419
|
+
let plan;
|
|
420
|
+
try {
|
|
421
|
+
plan = expandPlan(args, catalog, { includeDeps: false });
|
|
422
|
+
} catch (err) {
|
|
423
|
+
die(err.message);
|
|
424
|
+
}
|
|
425
|
+
const root = resolveRoot(flags);
|
|
426
|
+
const manifestPath = join(root, MANIFEST_FILENAME);
|
|
427
|
+
if (!existsSync(manifestPath)) {
|
|
428
|
+
die(`No ${MANIFEST_FILENAME} found in ${root}`);
|
|
429
|
+
}
|
|
430
|
+
const manifest = loadManifest(manifestPath);
|
|
431
|
+
let removed = 0;
|
|
432
|
+
for (const name of plan.ordered) {
|
|
433
|
+
if (manifest.skills[name] || manifest.compose?.[name]) {
|
|
434
|
+
removeSkillFromManifest(manifestPath, name);
|
|
435
|
+
console.log(` - removed ${name}`);
|
|
436
|
+
removed++;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
if (removed === 0) {
|
|
440
|
+
console.log("Nothing to remove (none of the named skills were declared in skillfold.yaml).");
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
console.log("");
|
|
444
|
+
runSkillfold(["install"], flags);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
async function main() {
|
|
448
|
+
const { command, args, flags } = parseArgs(process.argv.slice(2));
|
|
449
|
+
if (flags.version) {
|
|
450
|
+
console.log(pkgJson.version);
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if (flags.help) {
|
|
454
|
+
usage();
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
if (!command) {
|
|
459
|
+
if (process.stdin.isTTY && process.stdout.isTTY) {
|
|
460
|
+
await runOnboard({
|
|
461
|
+
catalog,
|
|
462
|
+
pkgJson,
|
|
463
|
+
flags,
|
|
464
|
+
resolveRoot,
|
|
465
|
+
parseTargetsList,
|
|
466
|
+
ensureManifest,
|
|
467
|
+
addSkillToManifest,
|
|
468
|
+
skillSource,
|
|
469
|
+
runSkillfold,
|
|
470
|
+
MANIFEST_FILENAME,
|
|
471
|
+
});
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
usage();
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
switch (command) {
|
|
479
|
+
case "onboard":
|
|
480
|
+
case "init":
|
|
481
|
+
await runOnboard({
|
|
482
|
+
catalog,
|
|
483
|
+
pkgJson,
|
|
484
|
+
flags,
|
|
485
|
+
resolveRoot,
|
|
486
|
+
parseTargetsList,
|
|
487
|
+
ensureManifest,
|
|
488
|
+
addSkillToManifest,
|
|
489
|
+
skillSource,
|
|
490
|
+
runSkillfold,
|
|
491
|
+
MANIFEST_FILENAME,
|
|
492
|
+
});
|
|
493
|
+
break;
|
|
494
|
+
case "list":
|
|
495
|
+
case "ls":
|
|
496
|
+
cmdList();
|
|
497
|
+
break;
|
|
498
|
+
case "info":
|
|
499
|
+
cmdInfo(args);
|
|
500
|
+
break;
|
|
501
|
+
case "install":
|
|
502
|
+
case "add":
|
|
503
|
+
await cmdInstall(args, flags);
|
|
504
|
+
break;
|
|
505
|
+
case "doctor":
|
|
506
|
+
case "preflight":
|
|
507
|
+
await cmdDoctor(args, flags);
|
|
508
|
+
break;
|
|
509
|
+
case "update":
|
|
510
|
+
case "sync":
|
|
511
|
+
runSkillfold(["update", ...args], flags);
|
|
512
|
+
break;
|
|
513
|
+
case "remove":
|
|
514
|
+
case "rm":
|
|
515
|
+
cmdRemove(args, flags);
|
|
516
|
+
break;
|
|
517
|
+
case "check":
|
|
518
|
+
runSkillfold(["check"], flags);
|
|
519
|
+
break;
|
|
520
|
+
default:
|
|
521
|
+
die(`Unknown command "${command}". Run with --help to see available commands.`);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
await main();
|