skillmkt 0.0.0-stage → 0.1.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.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +213 -2
  3. package/client/bin/skillmkt.js +84 -0
  4. package/client/commands/audit.js +34 -0
  5. package/client/commands/build.js +61 -0
  6. package/client/commands/config.js +34 -0
  7. package/client/commands/conflicts.js +14 -0
  8. package/client/commands/decide.js +19 -0
  9. package/client/commands/diff.js +52 -0
  10. package/client/commands/doctor.js +109 -0
  11. package/client/commands/download.js +35 -0
  12. package/client/commands/init.js +82 -0
  13. package/client/commands/install.js +169 -0
  14. package/client/commands/list.js +56 -0
  15. package/client/commands/merge.js +49 -0
  16. package/client/commands/outdated.js +34 -0
  17. package/client/commands/registry.js +42 -0
  18. package/client/commands/remove.js +48 -0
  19. package/client/commands/resolve.js +76 -0
  20. package/client/commands/rollback.js +30 -0
  21. package/client/commands/search.js +46 -0
  22. package/client/commands/serve.js +99 -0
  23. package/client/commands/show.js +52 -0
  24. package/client/commands/sync.js +54 -0
  25. package/client/commands/targets.js +75 -0
  26. package/client/commands/update.js +39 -0
  27. package/client/commands/upgrade.js +75 -0
  28. package/client/lib/ai.js +67 -0
  29. package/client/lib/audit.js +87 -0
  30. package/client/lib/autoarb.js +26 -0
  31. package/client/lib/conflicts.js +65 -0
  32. package/client/lib/ctx.js +68 -0
  33. package/client/lib/daemon.js +47 -0
  34. package/client/lib/dashboard.js +29 -0
  35. package/client/lib/decide.js +43 -0
  36. package/client/lib/evidence.js +56 -0
  37. package/client/lib/githash.js +36 -0
  38. package/client/lib/hub.js +125 -0
  39. package/client/lib/llm.js +85 -0
  40. package/client/lib/package.js +73 -0
  41. package/client/lib/project.js +97 -0
  42. package/client/lib/prompt.js +22 -0
  43. package/client/lib/ref.js +37 -0
  44. package/client/lib/registries/github.js +106 -0
  45. package/client/lib/registries/index.js +37 -0
  46. package/client/lib/registries/rfc.js +42 -0
  47. package/client/lib/registries/skillssh.js +59 -0
  48. package/client/lib/render.js +53 -0
  49. package/client/lib/rules.js +36 -0
  50. package/client/lib/scanner.js +158 -0
  51. package/client/lib/state.js +50 -0
  52. package/client/lib/yamlls.js +14 -0
  53. package/client/public/app.js +63 -0
  54. package/client/public/index.html +21 -0
  55. package/package.json +44 -4
  56. package/pipeline/lib/env.js +40 -0
  57. package/pipeline/lib/gh.js +53 -0
  58. package/pipeline/lib/llm.js +108 -0
  59. package/pipeline/lib/util.js +103 -0
  60. package/skill/SKILL.md +270 -0
  61. package/skill/references/a11y.md +82 -0
  62. package/skill/references/code.md +415 -0
  63. package/skill/references/color.md +84 -0
  64. package/skill/references/copy.md +197 -0
  65. package/skill/references/imagery.md +157 -0
  66. package/skill/references/layout.md +404 -0
  67. package/skill/references/motion.md +104 -0
  68. package/skill/references/process.md +303 -0
  69. package/skill/references/type.md +84 -0
  70. package/skill/rules-manifest.yml +13092 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 terry2010
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,214 @@
1
- # Temporary Holding Version
1
+ # awesome-skill-market
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Deslop AI-generated UI. Manage, merge, audit and secure agent skills.** awesome-skill-market is a **skill manager** and automated **skill merge** pipeline that distills the best agent design skills — taste-skill, Hallmark, Anthropic's frontend-design, Vercel's web-design-guidelines — into a single, continuously-updated `SKILL.md` for Claude Code, Cursor, Codex, OpenCode, Pi, Devin and other coding agents. Instead of installing 2–10 overlapping skills whose rules fight each other, you install one arbitrated skill where every conflict has been detected, screenshotted, and decided. On top of the merger it adds a local-first **skill audit** layer and **skill security** controls — static injection checks, capability stripping, version pinning — for every skill on your machine.
4
+
5
+ [![ci](https://github.com/terry2010/awesome-skill-market/actions/workflows/ci.yml/badge.svg)](https://github.com/terry2010/awesome-skill-market/actions/workflows/ci.yml)
6
+ [![license: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
7
+ [![conflicts](https://img.shields.io/github/issues-search/terry2010/awesome-skill-market?query=label%3Aconflict&label=arbitration%20queue)](https://github.com/terry2010/awesome-skill-market/issues?q=label%3Aconflict)
8
+
9
+ ## Why does AI-generated UI all look the same?
10
+
11
+ Ask any coding agent for a landing page and you get the same output: purple-to-blue gradients, glassmorphism cards, Inter, emoji-as-icons, eyebrow labels over every heading. This "AI slop" aesthetic happens because every model converges on the mean of its training data. The community fix is **agent skills** — `SKILL.md` files full of design rules that steer the model away from defaults.
12
+
13
+ The problem: the best skills contradict each other. taste-skill bans gradients entirely; ui-ux-pro-max ships 194 gradient palettes. Hallmark forbids eyebrow labels; other guides rely on them. Install several and the agent picks whichever rule it read last — you get slop with extra steps.
14
+
15
+ ## What awesome-skill-market does differently
16
+
17
+ > 📐 Full product design (skill manager + merger + audit + market): [`docs/DESIGN.md`](docs/DESIGN.md)
18
+
19
+ It doesn't add another opinion. It **referees** the existing ones:
20
+
21
+ | Step | What happens |
22
+ |---|---|
23
+ | `sync` | Pins upstream skill repos by SHA (`upstream.lock.json`) and watches for changes |
24
+ | `extract` | A local LLM normalizes every upstream doc into a flat rule schema (`extracted/*.yml`) — rewritten, never copied |
25
+ | `synthesize` | Per-domain LLM consolidation rewrites thousands of rules into canonical sets (chunked ~50, recursive, `SYNTH_POOL` concurrency); deterministic near-dup fold; genuinely contradictory pairs become `conflicts/*.yml` |
26
+ | `arbitrate` | An independent arbiter (fresh context) auto-resolves conflicts whose suggestions are sound, dismisses false conflicts, and escalates only true value tradeoffs to humans |
27
+ | `evidence` | The model builds minimal A/B HTML fixtures; Playwright screenshots them so humans judge **rendered output, not prose** |
28
+ | `issues` | One GitHub issue per remaining conflict — rule table, AI analysis, screenshot evidence, decision instructions |
29
+ | `decide` | Human arbitration lands in `decisions/*.yml` — the repo's real asset |
30
+ | `build` | Regenerates `skill/` (SKILL.md + per-scope references + rules manifest) and bumps version |
31
+
32
+ Pending conflicts hold **both** sides out of the merged output — contradictions never silently ship.
33
+
34
+ ## Quickstart — two ways in
35
+
36
+ ### A) Just use the merged skill (most people)
37
+
38
+ No model, no pipeline, no keys. `skill/` is the finished product — a standard [Agent Skills](https://agentskills.io) package (`SKILL.md` + `references/`), so it drops into any agent that reads skills.
39
+
40
+ **One command — installs to every agent it detects:**
41
+
42
+ ```bash
43
+ npx skills add terry2010/awesome-skill-market -g # global; add -a claude-code codex opencode pi to pick targets
44
+ ```
45
+
46
+ **Manual install** — the directory name must be `deslop` (it must match the `name:` field in SKILL.md):
47
+
48
+ ```bash
49
+ git clone https://github.com/terry2010/awesome-skill-market
50
+ S=awesome-skill-market/skill
51
+
52
+ cp -r $S ~/.agents/skills/deslop # Codex · Devin · Pi · OpenCode (all scan this path)
53
+ ln -sfn $PWD/$S ~/.claude/skills/deslop # Claude Code (symlinks fine)
54
+ cp -r $S ~/.codex/skills/deslop # Codex legacy path — enable [features] skills = true in config.toml
55
+ cp -r $S ~/.pi/agent/skills/deslop # Pi user-level (or: pi --skill $S)
56
+ cp -r $S ~/.config/devin/skills/deslop # Devin user-level
57
+ cp -r $S ~/.config/opencode/skills/deslop # OpenCode user-level
58
+ ```
59
+
60
+ | Agent | Project dir | Global dir | Notes |
61
+ |---|---|---|---|
62
+ | Claude Code | `.claude/skills/` | `~/.claude/skills/` | follows symlinks; scans one level only |
63
+ | Codex | `.agents/skills/` | `~/.agents/skills/` or `~/.codex/skills/` | **skips symlinks** — copy, or use `npx skills add --copy` |
64
+ | OpenCode | `.opencode/skills/` | `~/.config/opencode/skills/` | also auto-scans `.claude/skills` and `.agents/skills` |
65
+ | Pi | `.pi/skills/` | `~/.pi/agent/skills/` | also `pi --skill <dir>` per-run, `/skill:deslop` to force |
66
+ | Devin | `.devin/skills/` | `~/.config/devin/skills/` | also scans `~/.agents/skills`; `devin skills list` to verify |
67
+
68
+ **Loading model:** the agent only pays ~100 tokens (frontmatter) until a UI task triggers it; then `SKILL.md` (~14k tokens) loads, and the relevant `references/<domain>.md` loads on demand — never the whole corpus.
69
+
70
+ `git pull` + copy again to update (symlinked installs update for free). The generated skill carries `sources` provenance on every rule.
71
+
72
+ ### B) Run the pipeline yourself (self-host)
73
+
74
+ ```bash
75
+ git clone https://github.com/terry2010/awesome-skill-market && cd awesome-skill-market
76
+ npm run setup # deps + Playwright chromium
77
+ cp .env.example .env # configure below
78
+ gh auth login # needs issue + push access
79
+ npm run daemon # foreground loop: sync→extract→merge→evidence→issues→poll→build→push
80
+ ```
81
+
82
+ `.env` knobs:
83
+
84
+ | Var | What |
85
+ |---|---|
86
+ | `OMLX_BASE_URL` / `OMLX_API_KEY` / `OMLX_MODEL` | Any OpenAI-compatible chat endpoint — local (omlx, llama.cpp, vLLM, Ollama) or hosted |
87
+ | `GITHUB_REPO` | **Your own repo** (`you/awesome-skill-market`) — conflict issues get filed here |
88
+ | `GITHUB_BRANCH` | `main` |
89
+ | `DAEMON_INTERVAL_MIN` | Cycle interval, default 30 |
90
+
91
+ Loop variants: `npm run once` (single cycle) · `npm run once -- --no-llm` (skip model steps; still harvests issue votes and rebuilds). Track different upstreams by editing `config/upstreams.json`. Manual stages: `npm run synthesize` (incremental — unchanged domains are skipped via digest; `--domain color` for one) · `node pipeline/arbitrate.js` (auto-resolve pending conflicts) · `SYNTH_POOL=2 npm run synthesize` (lower LLM concurrency).
92
+
93
+ ## How is this different from installing taste-skill / Impeccable / Hallmark directly?
94
+
95
+ | | Individual skills | awesome-skill-market |
96
+ |---|---|---|
97
+ | Rule conflicts | Resolved at runtime, silently, per-session | Resolved once, on the record, by a human |
98
+ | Rule inventory | Frozen at install | Re-extracted on every upstream commit |
99
+ | Conflict visibility | Invisible — you never know rules fought | Every conflict is a public, screenshotted issue |
100
+ | Coverage | One author's taste | Union of N upstreams minus arbitrated contradictions |
101
+ | Auditability | Read the markdown, guess the effect | Every rule carries `sources` provenance + decision links |
102
+
103
+ ## Architecture
104
+
105
+ ```
106
+ upstream repos ─sync→ work/upstream (pinned SHAs)
107
+ ─extract→ extracted/*.yml (LLM-normalized rules; committed snapshots)
108
+ ─synthesize→ merged/rules.yml (canonical set)
109
+ conflicts/*.yml (held out while pending)
110
+ auto-arbiter (fresh-context second opinion)
111
+ evidence/conf-*/ (A/B fixtures + screenshots)
112
+ GitHub issues (human arbitration queue)
113
+ humans ─decisions/*.yml→ arbitration records (the durable asset)
114
+ ─build→ skill/ (SKILL.md + references/ + manifest)
115
+ ```
116
+
117
+ LLM steps run **locally** in a foreground daemon (`npm run daemon`, Ctrl-C to stop). CI on GitHub runs only deterministic checks: unit tests, YAML schema validation, and a build-reproducibility gate (`build --check` diffs regenerated output against the committed `skill/`).
118
+
119
+ ## Arbitrate a conflict
120
+
121
+ **Fastest path — reply on the issue.** Look at the A/B screenshots, then comment:
122
+
123
+ | Reply | Effect |
124
+ |---|---|
125
+ | `a` or `b` | Ship that side (`a - gradients break print` adds a reason) |
126
+ | `merge merged rule text` | Ship your merge |
127
+ | `custom rule text` | Ship a fully custom rule |
128
+
129
+ Only owner/member/collaborator comments count. Each daemon cycle polls open `conflict` issues, writes `decisions/conf-NNNN.yml`, confirms in a comment, closes the issue, and rebuilds the skill.
130
+
131
+ CLI still works for richer entries (`alternatives_rejected`, explicit provenance):
132
+
133
+ ```bash
134
+ npm run decide -- conf-0001 --resolution A --reason "gradients break our print stylesheet"
135
+ ```
136
+
137
+ Resolutions: `A` | `B` | `merge` | `custom` (latter two need `--custom "merged rule text"`). `--reason` is mandatory — overturning a decision requires new evidence, which prevents arbitration ping-pong. Overturn anytime by deciding again (reopen the issue and reply again, or re-run `decide`); `supersedes` keeps the history.
138
+
139
+ ## FAQ
140
+
141
+ **Is this an anti-slop skill itself?**
142
+ It's the pipeline that produces one. The output (`skill/`) is a self-contained anti-AI-slop design skill; the repo around it is the machinery that keeps it merged, evidenced, and arbitrated.
143
+
144
+ **Why local LLM + CI instead of GitHub Actions runners?**
145
+ The merge calls an OpenAI-compatible endpoint (`OMLX_BASE_URL`, e.g. an omlx/llama.cpp/vLLM server). Hosted CI can't reach `localhost`, so the daemon runs where the model runs; CI stays a pure verification gate.
146
+
147
+ **Does it work with models other than Ornith?**
148
+ Any chat-completions endpoint works — set `OMLX_BASE_URL`/`OMLX_MODEL`/`OMLX_API_KEY`. Reasoning models are supported (`enable_thinking` is toggled per pipeline stage).
149
+
150
+ **What happens if two upstreams truly contradict?**
151
+ Both rules are held out of the merged skill, an issue is filed with A/B screenshots, and a human decision (`decisions/conf-NNNN.yml`) determines which side ships — or a scoped merge of both.
152
+
153
+ **License?** MIT. Extracted rule text is rewritten (not verbatim) and every merged rule carries upstream `sources` provenance.
154
+
155
+ ## Links
156
+
157
+ - Output skill: [`skill/SKILL.md`](skill/SKILL.md)
158
+ - Arbitration queue: [issues labeled `conflict`](https://github.com/terry2010/awesome-skill-market/issues?q=label%3Aconflict)
159
+ - Upstreams: [taste-skill](https://github.com/Leonxlnx/taste-skill) · [hallmark](https://github.com/Nutlope/hallmark) · [frontend-design](https://github.com/anthropics/skills) · [web-design-guidelines](https://github.com/vercel-labs/agent-skills)
160
+
161
+ ---
162
+
163
+ # skillmkt — the CLI
164
+
165
+ `skillmkt` is the local-first skill manager from this project: install/adopt skills into `~/.skillmkt`, audit them before install, project copies into every agent's skill directory, detect upstream updates, merge skills with an arbitration queue, and review everything in a local web panel.
166
+
167
+ ```bash
168
+ npm i -g skillmkt # Node ≥ 22
169
+ skillmkt doctor # environment check
170
+ skillmkt search design # skills.sh official API
171
+ skillmkt install vercel-labs/agent-skills --path web-design-guidelines
172
+ skillmkt install ~/.codex/skills/my-local-skill # adopt an existing dir
173
+ skillmkt list # matrix: managed / external / drifted
174
+ skillmkt update && skillmkt outdated # apt semantics
175
+ skillmkt upgrade my-skill
176
+ skillmkt merge a b # extract → dedupe → conflict queue
177
+ skillmkt resolve --auto # LLM arbiter; leftover tradeoffs go to web UI
178
+ skillmkt build # pending conflicts stay OUT of the output
179
+ skillmkt serve # local web panel (skills/conflicts/review/setup)
180
+ ```
181
+
182
+ ## 中国用户 / China mirrors
183
+
184
+ ```bash
185
+ # 1. 装 CLI(npmmirror 最稳)
186
+ npm i -g skillmkt --registry=https://registry.npmmirror.com
187
+
188
+ # 2. GitHub 拉取走镜像前缀(任意 ghproxy 风格反代均可)
189
+ export SKILLMKT_FETCH_MIRROR=https://gh-proxy.com
190
+ # (或 config.yml 里写 fetch_mirror: https://gh-proxy.com)
191
+
192
+ # 3. skills.sh 搜索不可达时:自建反代后指过去
193
+ export SKILLMKT_SEARCH_API=https://your-mirror.example.com
194
+ # (SKILLS_API_URL 兼容官方 npx skills 的同名变量)
195
+
196
+ # 4. 可选:把 clawhub 配为额外 registry(内容池与 skills.sh 不同)
197
+ skillmkt registry add --type clawhub --url https://clawhub.ai --name clawhub
198
+ skillmkt search design --registry clawhub
199
+ ```
200
+
201
+ Fetch fallback order: GitHub tarball (`gh` → codeload → mirror prefix) → jsdelivr per-file. Search fallback: skills.sh official `/api/search` → `SKILLMKT_SEARCH_API`/`SKILLS_API_URL` mirror → `gh search code filename:SKILL.md` → local library only.
202
+
203
+ ## LLM features (optional, local-first)
204
+
205
+ Semantic diff, LLM audit, auto-arbitration and merge explanations use any OpenAI-compatible endpoint — **never required** for deterministic operation:
206
+
207
+ ```bash
208
+ export OMLX_BASE_URL=http://localhost:8001/v1
209
+ export OMLX_MODEL=your-model
210
+ export OMLX_API_KEY=env:MY_KEY # env: references only — no keys in config
211
+ skillmkt diff my-skill --semantic
212
+ skillmkt audit --all --llm
213
+ skillmkt resolve --auto # confident verdicts auto-apply; real tradeoffs stay pending
214
+ ```
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env node
2
+ // skillmkt — local-first agent skill manager
3
+ import { makeCtx, withState } from '../lib/ctx.js';
4
+ import { hubExists } from '../lib/hub.js';
5
+
6
+ const COMMANDS = {
7
+ init: 'init', config: 'config', doctor: 'doctor',
8
+ search: 'search', find: 'search', f: 'search', s: 'search',
9
+ list: 'list', ls: 'list',
10
+ show: 'show', view: 'show', info: 'show',
11
+ install: 'install', i: 'install', add: 'install',
12
+ remove: 'remove', uninstall: 'remove', un: 'remove', rm: 'remove',
13
+ targets: 'targets', sync: 'sync', audit: 'audit',
14
+ update: 'update', outdated: 'outdated', upgrade: 'upgrade',
15
+ download: 'download', diff: 'diff', rollback: 'rollback',
16
+ conflicts: 'conflicts', resolve: 'resolve', decide: 'decide',
17
+ merge: 'merge', build: 'build',
18
+ pack: 'pack', publish: 'publish', registry: 'registry', serve: 'serve',
19
+ };
20
+
21
+ const HELP = `skillmkt — local-first agent skill manager
22
+
23
+ usage: skillmkt <cmd> [args] [--json] [--hub <path>] [--dry-run] [--ui|--cli]
24
+
25
+ core: init config doctor search list show install remove targets sync
26
+ version: update outdated upgrade download diff rollback
27
+ merge: conflicts resolve decide merge build
28
+ dist: audit pack publish registry serve
29
+
30
+ bare run = dashboard. docs: docs/CLI.md`;
31
+
32
+ async function bareRun(ctx) {
33
+ if (!hubExists(ctx.hub)) {
34
+ if (!ctx.tty) {
35
+ console.error("run 'skillmkt init' to get started");
36
+ process.exit(1);
37
+ }
38
+ const mod = await import('../commands/init.js');
39
+ return mod.run(ctx);
40
+ }
41
+ const { renderDashboard } = await import('../lib/dashboard.js');
42
+ return renderDashboard(ctx);
43
+ }
44
+
45
+ async function main() {
46
+ const ctx = makeCtx(process.argv.slice(2));
47
+ const [cmd, ...args] = ctx.positional;
48
+ ctx.args = args;
49
+
50
+ if (ctx.flags.raw.help || ctx.flags.raw.h) { console.log(HELP); process.exit(0); }
51
+ if (ctx.flags.raw.version || ctx.flags.raw.V) {
52
+ const pkg = (await import('../../package.json', { with: { type: 'json' } })).default;
53
+ console.log(pkg.version);
54
+ process.exit(0);
55
+ }
56
+
57
+ if (!cmd) return bareRun(ctx);
58
+
59
+ const name = COMMANDS[cmd];
60
+ if (!name) {
61
+ console.error(`unknown command: ${cmd}\n\n${HELP}`);
62
+ process.exit(1);
63
+ }
64
+
65
+ let mod;
66
+ try {
67
+ mod = await import(`../commands/${name}.js`);
68
+ } catch (e) {
69
+ if (e.code === 'ERR_MODULE_NOT_FOUND') {
70
+ console.error(`${name}: not implemented yet`);
71
+ process.exit(1);
72
+ }
73
+ throw e;
74
+ }
75
+ withState(ctx);
76
+ const code = await mod.run(ctx);
77
+ process.exit(typeof code === 'number' ? code : 0);
78
+ }
79
+
80
+ main().catch((e) => {
81
+ console.error(`skillmkt: ${e.message}`);
82
+ if (process.env.DEBUG) console.error(e.stack);
83
+ process.exit(1);
84
+ });
@@ -0,0 +1,34 @@
1
+ // audit [name|--all] — 重跑静态审核刷新 scans/;--llm 附加语义审(批次6 全量)
2
+ import path from 'node:path';
3
+ import fs from 'node:fs';
4
+ import { auditDir, writeScan } from '../lib/audit.js';
5
+ import { llmAudit } from '../lib/ai.js';
6
+ import { walk } from '../lib/package.js';
7
+ import { ok, warn, fail, info } from '../lib/render.js';
8
+
9
+ export async function run(ctx) {
10
+ const flags = ctx.flags.raw;
11
+ const skills = ctx.library.skills || {};
12
+ const names = flags.all ? Object.keys(skills) : ctx.args;
13
+ if (!names.length) { fail('usage: skillmkt audit <name|--all> [--llm]'); return 1; }
14
+ let worst = 'clean';
15
+ const order = { clean: 0, suspicious: 1, stripped: 1, malicious: 2 };
16
+ for (const name of names) {
17
+ const dir = path.join(ctx.hub, 'skills', name);
18
+ if (!fs.existsSync(dir)) { warn(`未受管: ${name}`); continue; }
19
+ const r = auditDir(dir, { strip: false });
20
+ // --llm:additive 语义审(静态结论之上,降级安全)
21
+ if (flags.llm && ctx.llm) {
22
+ const files = [...walk(dir)].filter((p) => /\.(md|txt|js|sh|py)$/i.test(p))
23
+ .map((p) => ({ path: path.relative(dir, p), content: fs.readFileSync(p, 'utf8') }));
24
+ const lr = await llmAudit(ctx.llm, { name, files }).catch(() => null);
25
+ if (lr) { r.llm = lr; info(` llm: ${lr.verdict}${lr.reasons?.length ? ` — ${lr.reasons.join('; ')}` : ''}`); }
26
+ else warn(' llm audit 不可用——保留静态结论');
27
+ }
28
+ writeScan(ctx.hub, name, r);
29
+ if (order[r.verdict] > order[worst]) worst = r.verdict;
30
+ info(`${name}: ${r.verdict}${r.findings.length ? ` (${r.findings.length} findings)` : ''}`);
31
+ }
32
+ ok('audit done');
33
+ return worst === 'malicious' ? 2 : 0;
34
+ }
@@ -0,0 +1,61 @@
1
+ // build [--check] [--out dir] — merged/rules.yml + decisions → 产物 SKILL.md
2
+ // pending 冲突双边按 rule hash 排除(不是 id——id 会随重抽漂移)
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { loadConflicts } from '../lib/conflicts.js';
6
+ import { activeDecisions } from '../lib/decide.js';
7
+ import { readYAML } from '../../pipeline/lib/util.js';
8
+ import { ok, warn, fail, info } from '../lib/render.js';
9
+ import { mergedDir } from './merge.js';
10
+
11
+ export function buildSkill(hub) {
12
+ const mPath = path.join(mergedDir(hub), 'rules.yml');
13
+ if (!fs.existsSync(mPath)) return null;
14
+ const merged = readYAML(mPath);
15
+ const decisions = activeDecisions(hub);
16
+ const pending = loadConflicts(hub, { pendingOnly: true });
17
+ const blocked = new Set(pending.flatMap((c) => c.sides.map((s) => s.hash)));
18
+ // 已决 hash:keep-x 排除另一方;merge 排除双方(custom 文本单独注入);dismissed 双边保留
19
+ const decidedRm = new Set(), customs = [];
20
+ const allConflicts = loadConflicts(hub);
21
+ for (const [fp, d] of decisions) {
22
+ const c = allConflicts.find((x) => x.fingerprint === fp);
23
+ if (!c) continue;
24
+ if (d.resolution === 'keep-a') decidedRm.add(c.sides[1].hash);
25
+ else if (d.resolution === 'keep-b') decidedRm.add(c.sides[0].hash);
26
+ else if (d.resolution === 'merge') { c.sides.forEach((s) => decidedRm.add(s.hash)); if (d.custom) customs.push({ text: d.custom, sources: c.sides.map((s) => s.source) }); }
27
+ }
28
+ const kept = (merged.rules || []).filter((r) => !blocked.has(r.hash) && !decidedRm.has(r.hash));
29
+ return { merged, kept, customs, pending: pending.length };
30
+ }
31
+
32
+ export async function run(ctx) {
33
+ const b = buildSkill(ctx.hub);
34
+ if (!b) { fail('无 merged/rules.yml — 先 skillmkt merge'); return 1; }
35
+ const { merged, kept, customs, pending } = b;
36
+ // 渲染:域分组 + provenance 注释
37
+ const byDom = new Map();
38
+ for (const r of kept) { (byDom.get(r.domain) || byDom.set(r.domain, []).get(r.domain)).push(r); }
39
+ let md = `---\nname: ${merged.name}\ndescription: merged skill (${merged.sources.join(' + ')})\nversion: 0.1.0\n---\n\n# ${merged.name}\n\n> merged from: ${merged.sources.join(', ')} · ${kept.length} rules · ${pending} pending conflicts excluded\n`;
40
+ for (const [dom, rules] of byDom) {
41
+ md += `\n## ${dom}\n`;
42
+ for (const r of rules) md += `\n- ${r.text} <!-- ${r.source}:${r.id} -->`;
43
+ md += '\n';
44
+ }
45
+ if (customs.length) {
46
+ md += '\n## merged-decisions\n';
47
+ for (const c of customs) md += `\n- ${c.text} <!-- merge:${c.sources.join('+')} -->`;
48
+ md += '\n';
49
+ }
50
+ const outDir = ctx.flags.raw.out ? path.resolve(ctx.flags.raw.out) : path.join(mergedDir(ctx.hub), 'skill-out');
51
+ if (ctx.flags.raw.check) {
52
+ const f = path.join(outDir, 'SKILL.md');
53
+ const same = fs.existsSync(f) && fs.readFileSync(f, 'utf8') === md;
54
+ console.log(same ? 'build --check: ok' : 'build --check: STALE');
55
+ return same ? 0 : 1;
56
+ }
57
+ fs.mkdirSync(outDir, { recursive: true });
58
+ fs.writeFileSync(path.join(outDir, 'SKILL.md'), md);
59
+ ok(`built ${outDir}/SKILL.md — ${kept.length} rules${pending ? `,⚠ ${pending} pending 双边已排除` : ''}`);
60
+ return pending ? 3 : 0;
61
+ }
@@ -0,0 +1,34 @@
1
+ // config — get/set/list config.yml 点路径键(脚本友好)
2
+ import { readConfig, writeConfig, setConfigKey, getConfigKey, ensureHub } from '../lib/hub.js';
3
+ import { ok, fail, info } from '../lib/render.js';
4
+ import YAML from 'yaml';
5
+
6
+ export async function run(ctx) {
7
+ const [sub, key, ...rest] = ctx.args;
8
+ ensureHub(ctx.hub);
9
+ const raw = readConfig(ctx.hub)._raw;
10
+
11
+ if (sub === 'get') {
12
+ const v = getConfigKey(raw, key);
13
+ if (v === undefined) { fail(`unknown key: ${key}`); return 1; }
14
+ console.log(typeof v === 'object' ? YAML.stringify(v).trim() : String(v));
15
+ return 0;
16
+ }
17
+ if (sub === 'set') {
18
+ const value = rest.join(' ');
19
+ if (!key || value === '') { fail('usage: config set <key> <value>'); return 1; }
20
+ // 数字/布尔/JSON 智能转型
21
+ let v = value;
22
+ try { v = JSON.parse(value); } catch { /* string */ }
23
+ setConfigKey(raw, key, v);
24
+ writeConfig(ctx.hub, raw);
25
+ ok(`${key} = ${YAML.stringify(v).trim()}`);
26
+ return 0;
27
+ }
28
+ if (sub === 'list' || !sub) {
29
+ console.log(YAML.stringify(raw).trim() || '# empty');
30
+ return 0;
31
+ }
32
+ fail('usage: skillmkt config [list] | get <key> | set <key> <value>');
33
+ return 1;
34
+ }
@@ -0,0 +1,14 @@
1
+ // conflicts — 队列列表;pending>0 exit3;--json
2
+ import { loadConflicts } from '../lib/conflicts.js';
3
+ import { table } from '../lib/render.js';
4
+
5
+ export async function run(ctx) {
6
+ const all = loadConflicts(ctx.hub);
7
+ const pending = all.filter((c) => c.status === 'pending');
8
+ if (ctx.flags.json) { console.log(JSON.stringify(all, null, 2)); return pending.length ? 3 : 0; }
9
+ if (!all.length) { console.log('no conflicts recorded — run: skillmkt merge <a> <b>'); return 0; }
10
+ table(all.map((c) => ({ id: c.id, status: c.status, domain: c.domain || '-', A: `${c.sides[0].source}:${c.sides[0].hash}`, B: `${c.sides[1].source}:${c.sides[1].hash}` })),
11
+ [{ key: 'id', title: 'id' }, { key: 'status', title: 'status' }, { key: 'domain', title: 'domain' }, { key: 'A', title: 'A' }, { key: 'B', title: 'B' }]);
12
+ if (pending.length) console.log(`\n${pending.length} pending — skillmkt resolve`);
13
+ return pending.length ? 3 : 0;
14
+ }
@@ -0,0 +1,19 @@
1
+ // decide <id> --resolution keep-a|keep-b|merge|dismissed --reason "…" [--custom text]
2
+ import { loadConflicts, writeConflict } from '../lib/conflicts.js';
3
+ import { decide } from '../lib/decide.js';
4
+ import { ok, fail } from '../lib/render.js';
5
+
6
+ export async function run(ctx) {
7
+ const [id] = ctx.args;
8
+ const { resolution, reason, custom } = ctx.flags.raw;
9
+ if (!id || !resolution || !reason) { fail('usage: skillmkt decide <conf-id> --resolution keep-a|keep-b|merge|dismissed --reason "…" [--custom text]'); return 1; }
10
+ const c = loadConflicts(ctx.hub).find((x) => x.id === id);
11
+ if (!c) { fail(`not found: ${id}`); return 1; }
12
+ if (!['keep-a', 'keep-b', 'merge', 'dismissed'].includes(resolution)) { fail(`bad resolution: ${resolution}`); return 1; }
13
+ if (resolution === 'merge' && !custom) { fail('resolution=merge 需要 --custom 提供合并文本'); return 1; }
14
+ decide(ctx.hub, c, { resolution, custom, reason, by: process.env.USER || 'cli' });
15
+ c.status = 'resolved';
16
+ writeConflict(ctx.hub, c);
17
+ ok(`${id} → ${resolution}`);
18
+ return 0;
19
+ }
@@ -0,0 +1,52 @@
1
+ // diff — lock pin vs 上游:默认结构 diff(文件/节增删);--semantic 留待 LLM(批次6 接管)
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { fetchSkill } from '../lib/registries/github.js';
5
+ import { fetchMirror } from '../lib/registries/index.js';
6
+ import { walk, treeHash } from '../lib/package.js';
7
+ import { gitTreeHash } from '../lib/githash.js';
8
+ import { info, warn, fail } from '../lib/render.js';
9
+ import { semanticDiff } from '../lib/ai.js';
10
+
11
+ function sectionsOf(dir) {
12
+ const f = path.join(dir, 'SKILL.md');
13
+ if (!fs.existsSync(f)) return [];
14
+ return fs.readFileSync(f, 'utf8').split('\n').filter((l) => /^#{1,4}\s/.test(l)).map((l) => l.replace(/^#+\s*/, '').trim());
15
+ }
16
+
17
+ export async function run(ctx) {
18
+ const name = ctx.args[0];
19
+ const s = ctx.library.skills?.[name];
20
+ if (!s) { fail(`未受管: ${name}`); return 1; }
21
+ const src = s.source || {};
22
+ if (src.registry !== 'github' || !src.ref) { fail(`${name}: 无上游可比`); return 1; }
23
+
24
+ const [owner, repo] = src.ref.split('/');
25
+ const localDir = path.join(ctx.hub, 'skills', name);
26
+ const got = await fetchSkill({ owner, repo, ref: null, path: src.path || null, mirror: fetchMirror(ctx) });
27
+
28
+ const localFiles = new Set([...walk(localDir)].map((p) => path.relative(localDir, p)));
29
+ const remoteFiles = new Set([...walk(got.dir)].map((p) => path.relative(got.dir, p)));
30
+ const added = [...remoteFiles].filter((f) => !localFiles.has(f));
31
+ const removed = [...localFiles].filter((f) => !remoteFiles.has(f));
32
+ const changed = [...remoteFiles].filter((f) => localFiles.has(f)).filter((f) => {
33
+ try { return fs.readFileSync(path.join(localDir, f)).compare(fs.readFileSync(path.join(got.dir, f))) !== 0; } catch { return false; }
34
+ });
35
+ const lSec = sectionsOf(localDir), rSec = sectionsOf(got.dir);
36
+ const secAdded = rSec.filter((x) => !lSec.includes(x));
37
+ const secRemoved = lSec.filter((x) => !rSec.includes(x));
38
+
39
+ const report = { name, sha: got.sha, files: { added, removed, changed }, sections: { added: secAdded, removed: secRemoved } };
40
+ if (ctx.flags.json) { console.log(JSON.stringify(report, null, 2)); return 0; }
41
+
42
+ info(`${name}: pin ${src.pin?.slice(0, 7) ?? '-'} → upstream ${got.sha.slice(0, 7)}`);
43
+ info(`files: +${added.length} -${removed.length} ~${changed.length}`);
44
+ if (secAdded.length) info(`sections +: ${secAdded.join(' | ')}`);
45
+ if (secRemoved.length) info(`sections -: ${secRemoved.join(' | ')}`);
46
+ if (ctx.flags.raw.semantic) {
47
+ if (!ctx.llm) { warn('--semantic 需要 LLM(config.llm 或 OMLX_*)——以上为结构 diff'); return 0; }
48
+ const summary = await semanticDiff(ctx.llm, { name, added, removed, changed, secAdded, secRemoved }).catch(() => null);
49
+ info(summary ? `semantic: ${summary}` : 'semantic: LLM 不可用——结构 diff 如上');
50
+ }
51
+ return 0;
52
+ }
@@ -0,0 +1,109 @@
1
+ // doctor — 环境健康检查(npm doctor 语义 + flutter 式工具链矩阵)
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { ok, warn, fail, info } from '../lib/render.js';
5
+ import { hubExists } from '../lib/hub.js';
6
+ import { scanSkillDir } from '../lib/scanner.js';
7
+ import { readSkillDir, treeHash } from '../lib/package.js';
8
+ import { execFileSync } from 'node:child_process';
9
+
10
+ const NODE_MIN = 22;
11
+
12
+ async function ping(url, ms = 3000) {
13
+ const ctrl = new AbortController();
14
+ const t = setTimeout(() => ctrl.abort(), ms);
15
+ try {
16
+ const res = await fetch(url, { method: 'HEAD', signal: ctrl.signal });
17
+ return res.status;
18
+ } catch { return 0; } finally { clearTimeout(t); }
19
+ }
20
+
21
+ // lock vs 实测投影漂移
22
+ function driftCheck(ctx) {
23
+ const drift = [];
24
+ for (const [name, entry] of Object.entries(ctx.lock.skills || {})) {
25
+ for (const [target, t] of Object.entries(entry.targets || {})) {
26
+ let dir = null;
27
+ if (target.startsWith('custom:')) dir = target.slice(7);
28
+ else {
29
+ const h = ctx.harnesses.find((x) => x.id === target);
30
+ dir = h?.dirs.find((d) => d.exists)?.path ?? h?.dirs[0]?.path;
31
+ }
32
+ if (!dir) continue;
33
+ const skillDir = path.join(dir, name);
34
+ if (!fs.existsSync(skillDir)) { drift.push({ name, target, issue: 'missing' }); continue; }
35
+ const actual = treeHash(skillDir);
36
+ if (actual !== t.hash) drift.push({ name, target, issue: 'content-differs' });
37
+ }
38
+ }
39
+ return drift;
40
+ }
41
+
42
+ export async function run(ctx) {
43
+ const checks = [];
44
+ const say = (okFlag, msg, extra) => {
45
+ checks.push({ ok: okFlag, msg, ...(extra || {}) });
46
+ (okFlag === true ? ok : okFlag === 'warn' ? warn : fail)(msg);
47
+ };
48
+
49
+ // node 版本
50
+ const major = +process.versions.node.split('.')[0];
51
+ say(major >= NODE_MIN, `node ${process.versions.node}${major < NODE_MIN ? ` — need ≥${NODE_MIN}` : ''}`);
52
+
53
+ // hub
54
+ const exists = hubExists(ctx.hub);
55
+ let writable = false;
56
+ try { fs.mkdirSync(ctx.hub, { recursive: true }); fs.accessSync(ctx.hub, fs.constants.W_OK); writable = true; } catch {}
57
+ say(writable, `hub ${ctx.hub} ${exists ? '' : '(skeleton only) '}${writable ? '(writable)' : '(NOT WRITABLE)'}`);
58
+
59
+ // harness 矩阵
60
+ const hrows = [];
61
+ for (const h of ctx.harnesses) {
62
+ const dir = h.dirs.find((d) => d.exists) ?? h.dirs[0];
63
+ const skills = dir?.exists ? scanSkillDir(dir.path).length : 0;
64
+ const note = h.detectOnly ? 'detect-only' : h.state === 'available' ? 'bin only — dir will create'
65
+ : h.state === 'likely' ? 'dir only — 装过?' : h.state === 'absent' ? '' : `${skills} skills`;
66
+ hrows.push({ id: h.id, dir: dir?.path ?? '-', state: h.state, note });
67
+ }
68
+ const hInstalled = hrows.filter((r) => r.state === 'installed').length;
69
+ say(hInstalled > 0 || hrows.some((r) => r.state !== 'absent'), 'harnesses detected:');
70
+ for (const r of hrows) info(`${r.id.padEnd(12)} ${r.dir.padEnd(34)} ${r.state.padEnd(10)} ${r.note}`);
71
+
72
+ // registries 连通
73
+ const regs = ctx.config.registries;
74
+ const regNotes = [];
75
+ for (const r of regs) {
76
+ if (r.type === 'github') {
77
+ let gh = true;
78
+ try { execFileSync('gh', ['--version'], { stdio: 'ignore' }); } catch { gh = false; }
79
+ regNotes.push(`github${r.default ? ' (default)' : ''}${gh ? '' : ' — gh CLI missing!'}`);
80
+ if (!gh) say('warn', 'registry github: gh CLI not found');
81
+ } else if (r.url) {
82
+ const code = await ping(r.url);
83
+ regNotes.push(`${r.type} ${r.url}${code ? '' : ' — unreachable'}`);
84
+ if (!code) say('warn', `registry ${r.type} ${r.url}: unreachable`);
85
+ }
86
+ }
87
+ say(regNotes.length > 0, `registries: ${regNotes.join(', ') || 'none'}`);
88
+
89
+ // llm 已配状态(不探端口——探测只在 init/config)
90
+ if (ctx.llm) say(true, `llm configured: ${ctx.llm.model} @ ${ctx.llm.base_url}`);
91
+ else {
92
+ say('warn', 'llm not configured — LLM features disabled (audit/conflicts/diff 降级静态)');
93
+ info('→ 跑 skillmkt init 一键配置');
94
+ }
95
+
96
+ // drift
97
+ const drift = exists ? driftCheck(ctx) : [];
98
+ if (drift.length) say('warn', `projection drift: ${drift.length} (run: skillmkt sync)`);
99
+ else if (exists) say(true, 'projections in sync');
100
+
101
+ const bad = checks.filter((c) => c.ok === false).length;
102
+ const warns = checks.filter((c) => c.ok === 'warn').length;
103
+ if (ctx.flags.json) {
104
+ console.log(JSON.stringify({ node: process.versions.node, hub: ctx.hub, harnesses: hrows, drift, checks, ok: bad === 0 }, null, 2));
105
+ }
106
+ if (bad) { fail(`${bad} check(s) failed`); return 1; }
107
+ if (warns) info(`${warns} warning(s)`);
108
+ return 0;
109
+ }