dsh-score 0.1.3 → 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/CHANGELOG.md +6 -0
- package/README.es.md +15 -0
- package/README.hi.md +15 -0
- package/README.md +52 -0
- package/README.pt.md +15 -0
- package/README.zh.md +15 -0
- package/lib/index.js +398 -5
- package/lib/types/badge.d.ts +138 -0
- package/lib/types/badge.d.ts.map +1 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/tools.d.ts.map +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to this project are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.2.0] - 2026-08-26
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `score_badge` tool: an embeddable README badge (self-contained shields.io flat-style SVG, paste-ready endpoint URL, and Markdown embed snippet) plus a compact five-dimension JSON envelope (`schema: "dsh-score/badge/v1"`) for one scored target, from either a fresh `target` score or a stored score card `id` with an optional `refresh` cache bypass. A `no-evidence` dimension keeps its honest status and score 0 — the badge and JSON never fabricate a number.
|
|
13
|
+
|
|
8
14
|
## [0.1.3] - 2026-08-23
|
|
9
15
|
|
|
10
16
|
## [0.1.2] - 2026-08-22
|
package/README.es.md
CHANGED
|
@@ -104,6 +104,21 @@ Inicia un trabajo por lotes en segundo plano; la última línea nombra el id de
|
|
|
104
104
|
|
|
105
105
|
Devuelve una tarjeta (`sc_...`), una tabla (`lb_...`) o, sin id, la última tabla.
|
|
106
106
|
|
|
107
|
+
## Insignia y API JSON
|
|
108
|
+
|
|
109
|
+
`score_badge` genera una insignia embebible en README y el JSON de cinco dimensiones para un objetivo puntuado.
|
|
110
|
+
|
|
111
|
+
- **Insignia** — SVG plano de shields.io (campo `badge.svg` / `renderScoreBadge`), URL de endpoint documentada y fragmento Markdown de inserción.
|
|
112
|
+
- **JSON de cinco dimensiones** — `install`/`maintenance`/`documentation`/`security`/`compliance` con `status`/`score`/`weight`/`summary`, más el `total` ponderado y la `grade` (`schema: "dsh-score/badge/v1"`).
|
|
113
|
+
|
|
114
|
+
Inserta la insignia total:
|
|
115
|
+
|
|
116
|
+
```markdown
|
|
117
|
+

|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Una dimensión `no-evidence` conserva su estado honesto y puntúa 0 — la insignia y el JSON nunca inventan números.
|
|
121
|
+
|
|
107
122
|
## Permisos y datos
|
|
108
123
|
|
|
109
124
|
- Solo servicios públicos: `ctx.subprocess`, `ctx.jobs`, `ctx.storageDomain`, `ctx.tools`, `ctx.commands`.
|
package/README.hi.md
CHANGED
|
@@ -104,6 +104,21 @@ score(target: string, refresh?: boolean, background?: boolean)
|
|
|
104
104
|
|
|
105
105
|
एक कार्ड (`sc_...`), लीडरबोर्ड (`lb_...`), या बिना id के नवीनतम लीडरबोर्ड लौटाता है।
|
|
106
106
|
|
|
107
|
+
## बैज और JSON API
|
|
108
|
+
|
|
109
|
+
`score_badge` एक अंकित लक्ष्य के लिए README में एम्बेड करने योग्य बैज और पाँच-आयामी JSON उत्पन्न करता है।
|
|
110
|
+
|
|
111
|
+
- **बैज** — shields.io फ्लैट SVG (`badge.svg` फ़ील्ड / `renderScoreBadge`), दस्तावेज़ित endpoint URL, और Markdown एम्बेड स्निपेट।
|
|
112
|
+
- **पाँच-आयामी JSON** — `install`/`maintenance`/`documentation`/`security`/`compliance` प्रत्येक में `status`/`score`/`weight`/`summary`, साथ में भारित `total` और अक्षर `grade` (`schema: "dsh-score/badge/v1"`).
|
|
113
|
+
|
|
114
|
+
कुल बैज एम्बेड करें:
|
|
115
|
+
|
|
116
|
+
```markdown
|
|
117
|
+

|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`no-evidence` आयाम अपनी ईमानदार स्थिति और 0 स्कोर बनाए रखता है — बैज और JSON कभी संख्या नहीं गढ़ते।
|
|
121
|
+
|
|
107
122
|
## अनुमतियाँ और डेटा
|
|
108
123
|
|
|
109
124
|
- केवल सार्वजनिक सेवाएँ: `ctx.subprocess`, `ctx.jobs`, `ctx.storageDomain`, `ctx.tools`, `ctx.commands`।
|
package/README.md
CHANGED
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
- `score` tool — one target through the five-dimension pipeline; returns the structured risk card, or `{ kind: 'background', jobId }` with `background: true`.
|
|
37
37
|
- `/score` command — batch scoring of a whitespace/comma-separated target list as a `score-batch` background job over `ctx.jobs`, producing a leaderboard snapshot (JSON + Markdown).
|
|
38
38
|
- `score_report` tool — fetch any stored score card (`sc_...`), leaderboard (`lb_...`), or the latest leaderboard.
|
|
39
|
+
- `score_badge` tool — an embeddable README badge (shields.io flat SVG + endpoint URL) and the five-dimension JSON for one scored target.
|
|
39
40
|
- **Five dimensions** (weights configurable, defaults sum to 100): install success `25`, maintenance `20`, documentation `20`, security `20`, compliance `15`.
|
|
40
41
|
- **Evidence discipline** — every dimension records its audit links (`source`, sanitized `detail`, `observedAt`); a dimension without evidence reports `no-evidence` (score 0, excluded from the weighted total), never a fabricated number.
|
|
41
42
|
- Structured results — every record carries `schema: "dsh-score/v1"` with first-class fields; this is the machine-readable contract downstream tooling consumes.
|
|
@@ -107,6 +108,16 @@ Starts one background batch job; progress streams through the job output, and th
|
|
|
107
108
|
|
|
108
109
|
Returns a score card (`sc_...`), a leaderboard (`lb_...`), or — with no id — the latest leaderboard.
|
|
109
110
|
|
|
111
|
+
### `score_badge(target? | id?, refresh?)`
|
|
112
|
+
|
|
113
|
+
Generates an embeddable README badge and the five-dimension JSON for one target:
|
|
114
|
+
|
|
115
|
+
- `target` — score a GitHub repo or npm package (through the cache) and badge it; mutually exclusive with `id`.
|
|
116
|
+
- `id` — badge a stored score card (`sc_...`) without re-scoring.
|
|
117
|
+
- `refresh: true` — bypass the score cache (only applies to `target`).
|
|
118
|
+
|
|
119
|
+
Returns the badge (SVG + endpoint + Markdown embed) and the compact five-dimension JSON — see [Badge & JSON API](#badge--json-api).
|
|
120
|
+
|
|
110
121
|
### Structured result sample
|
|
111
122
|
|
|
112
123
|
```json
|
|
@@ -133,6 +144,47 @@ Returns a score card (`sc_...`), a leaderboard (`lb_...`), or — with no id —
|
|
|
133
144
|
|
|
134
145
|
Scoring: the total is a weighted average over dimensions that gathered evidence (no-evidence dimensions are excluded and renormalized); `A` ≥ 90, `B` ≥ 75, `C` ≥ 60, `D` ≥ 40, else `F`, and `N/A` when nothing had evidence.
|
|
135
146
|
|
|
147
|
+
## Badge & JSON API
|
|
148
|
+
|
|
149
|
+
`score_badge` generates an embeddable README badge and the five-dimension JSON for one scored target.
|
|
150
|
+
|
|
151
|
+
### Badge
|
|
152
|
+
|
|
153
|
+
Three forms, all derived from the same settled score card:
|
|
154
|
+
|
|
155
|
+
- **Endpoint** — a documented [shields.io](https://shields.io) static URL, paste-ready for a README image (zero self-hosting).
|
|
156
|
+
- **SVG** — a self-contained shields.io flat-style SVG (`badge.svg` field / `renderScoreBadge`) for offline or self-hosted READMEs.
|
|
157
|
+
- **Markdown** — the embed snippet combining both.
|
|
158
|
+
|
|
159
|
+
Embed the total badge in any README:
|
|
160
|
+
|
|
161
|
+
```markdown
|
|
162
|
+

|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Five-dimension JSON
|
|
166
|
+
|
|
167
|
+
The same call returns the compact JSON API envelope (`schema: "dsh-score/badge/v1"`):
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"schema": "dsh-score/badge/v1",
|
|
172
|
+
"target": { "kind": "repo", "spec": "github:owner/dsh-click#abc123" },
|
|
173
|
+
"scoredAt": "2026-08-16T00:00:00.000Z",
|
|
174
|
+
"total": 84,
|
|
175
|
+
"grade": "B",
|
|
176
|
+
"dimensions": {
|
|
177
|
+
"install": { "label": "install", "status": "no-evidence", "score": 0, "weight": 25, "summary": "no dsh-test-drive result recorded" },
|
|
178
|
+
"maintenance": { "label": "maintenance", "status": "pass", "score": 90, "weight": 20, "summary": "active (0 open issues)" },
|
|
179
|
+
"documentation": { "label": "docs", "status": "pass", "score": 85, "weight": 20, "summary": "README + CHANGELOG + SECURITY" },
|
|
180
|
+
"security": { "label": "security", "status": "warn", "score": 60, "weight": 20, "summary": "permissive license" },
|
|
181
|
+
"compliance": { "label": "compliance", "status": "pass", "score": 100, "weight": 15, "summary": "dsh.bundle.patch + dsh-plugin topic" }
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
A `no-evidence` dimension keeps its honest status and score 0 — the badge and JSON never fabricate a number.
|
|
187
|
+
|
|
136
188
|
## Permissions & data
|
|
137
189
|
|
|
138
190
|
- Only public services are consumed: `ctx.subprocess`, `ctx.jobs`, `ctx.storageDomain`, `ctx.tools`, `ctx.commands`.
|
package/README.pt.md
CHANGED
|
@@ -104,6 +104,21 @@ Inicia um job em lote em segundo plano; a última linha nomeia o id do ranking p
|
|
|
104
104
|
|
|
105
105
|
Retorna um cartão (`sc_...`), um ranking (`lb_...`) ou, sem id, o último ranking.
|
|
106
106
|
|
|
107
|
+
## Insígnia e API JSON
|
|
108
|
+
|
|
109
|
+
`score_badge` gera uma insígnia embebível em README e o JSON de cinco dimensões para um alvo pontuado.
|
|
110
|
+
|
|
111
|
+
- **Insígnia** — SVG plano do shields.io (campo `badge.svg` / `renderScoreBadge`), URL de endpoint documentada e trecho Markdown de incorporação.
|
|
112
|
+
- **JSON de cinco dimensões** — `install`/`maintenance`/`documentation`/`security`/`compliance` com `status`/`score`/`weight`/`summary`, além do `total` ponderado e da `grade` (`schema: "dsh-score/badge/v1"`).
|
|
113
|
+
|
|
114
|
+
Incorpore a insígnia total:
|
|
115
|
+
|
|
116
|
+
```markdown
|
|
117
|
+

|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Uma dimensão `no-evidence` mantém seu estado honesto e pontua 0 — a insígnia e o JSON nunca fabricam números.
|
|
121
|
+
|
|
107
122
|
## Permissões e dados
|
|
108
123
|
|
|
109
124
|
- Apenas serviços públicos: `ctx.subprocess`, `ctx.jobs`, `ctx.storageDomain`, `ctx.tools`, `ctx.commands`.
|
package/README.zh.md
CHANGED
|
@@ -106,6 +106,21 @@ score(target: string, refresh?: boolean, background?: boolean)
|
|
|
106
106
|
|
|
107
107
|
返回评分卡(`sc_...`)、排行榜(`lb_...`),或不传 id 时返回最新排行榜。
|
|
108
108
|
|
|
109
|
+
## 徽章与 JSON API
|
|
110
|
+
|
|
111
|
+
`score_badge` 为某个已评分目标生成可嵌入 README 的徽章与五维 JSON。
|
|
112
|
+
|
|
113
|
+
- **徽章**:shields.io 扁平 SVG(`badge.svg` 字段 / `renderScoreBadge`)、文档化端点 URL、以及 Markdown 嵌入片段。
|
|
114
|
+
- **五维 JSON**:`install`/`maintenance`/`documentation`/`security`/`compliance` 各自的 `status`/`score`/`weight`/`summary`,外加加权 `total` 与字母 `grade`(`schema: "dsh-score/badge/v1"`)。
|
|
115
|
+
|
|
116
|
+
嵌入总徽章:
|
|
117
|
+
|
|
118
|
+
```markdown
|
|
119
|
+

|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`no-evidence` 维度保持诚实状态并计 0 分——徽章与 JSON 绝不伪造数字。
|
|
123
|
+
|
|
109
124
|
## 权限与数据
|
|
110
125
|
|
|
111
126
|
- 只消费公开服务:`ctx.subprocess`、`ctx.jobs`、`ctx.storageDomain`、`ctx.tools`、`ctx.commands`。
|
package/lib/index.js
CHANGED
|
@@ -1001,7 +1001,7 @@ var ProbeDriver = class {
|
|
|
1001
1001
|
* The structured score records it as `score.pluginVersion`.
|
|
1002
1002
|
* @module dsh-score/version
|
|
1003
1003
|
*/
|
|
1004
|
-
const VERSION = "0.
|
|
1004
|
+
const VERSION = "0.2.0";
|
|
1005
1005
|
//#endregion
|
|
1006
1006
|
//#region src/score.ts
|
|
1007
1007
|
/**
|
|
@@ -1543,6 +1543,243 @@ const scoreDomainSpec = defineDomain({
|
|
|
1543
1543
|
}
|
|
1544
1544
|
});
|
|
1545
1545
|
//#endregion
|
|
1546
|
+
//#region src/badge.ts
|
|
1547
|
+
/**
|
|
1548
|
+
* Embeddable README badges and the five-dimension JSON API output. Pure,
|
|
1549
|
+
* zero-dependency functions over a settled {@link ScoreResult}: a shields.io
|
|
1550
|
+
* flat-style SVG generator (offline/self-hosted), a documented shields.io
|
|
1551
|
+
* endpoint URL, one badge for the weighted total plus one per dimension, and a
|
|
1552
|
+
* compact five-dimension JSON envelope for API consumers.
|
|
1553
|
+
*
|
|
1554
|
+
* Every output derives from an already-settled score card — a dimension with no
|
|
1555
|
+
* evidence renders `no-evidence` (grey, score 0) exactly as the card reports it;
|
|
1556
|
+
* nothing here fabricates a number.
|
|
1557
|
+
*
|
|
1558
|
+
* @module dsh-score/badge
|
|
1559
|
+
*/
|
|
1560
|
+
/** Discriminator of the badge JSON envelope (version 1). */
|
|
1561
|
+
const BADGE_SCHEMA = "dsh-score/badge/v1";
|
|
1562
|
+
/** shields.io flat-badge hex colors, keyed by their named endpoints. */
|
|
1563
|
+
const SHIELDS_HEX = {
|
|
1564
|
+
brightgreen: "#4c1",
|
|
1565
|
+
green: "#97ca00",
|
|
1566
|
+
yellow: "#dfb317",
|
|
1567
|
+
orange: "#fe7d37",
|
|
1568
|
+
red: "#e05d44",
|
|
1569
|
+
blue: "#007ec6",
|
|
1570
|
+
lightgrey: "#9f9f9f"
|
|
1571
|
+
};
|
|
1572
|
+
/** Compact human labels for the five dimensions (kept short for badge width). */
|
|
1573
|
+
const DIMENSION_BADGE_LABELS = {
|
|
1574
|
+
install: "install",
|
|
1575
|
+
maintenance: "maintenance",
|
|
1576
|
+
documentation: "docs",
|
|
1577
|
+
security: "security",
|
|
1578
|
+
compliance: "compliance"
|
|
1579
|
+
};
|
|
1580
|
+
/** shields.io badge color (hex) for a letter grade; grey for `N/A`. */
|
|
1581
|
+
function gradeColor(grade) {
|
|
1582
|
+
switch (grade) {
|
|
1583
|
+
case "A": return SHIELDS_HEX.brightgreen;
|
|
1584
|
+
case "B": return SHIELDS_HEX.green;
|
|
1585
|
+
case "C": return SHIELDS_HEX.yellow;
|
|
1586
|
+
case "D": return SHIELDS_HEX.orange;
|
|
1587
|
+
case "F": return SHIELDS_HEX.red;
|
|
1588
|
+
default: return SHIELDS_HEX.lightgrey;
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
/** shields.io badge color (hex) for a dimension status. */
|
|
1592
|
+
function statusColor(status) {
|
|
1593
|
+
switch (status) {
|
|
1594
|
+
case "pass": return SHIELDS_HEX.brightgreen;
|
|
1595
|
+
case "warn": return SHIELDS_HEX.orange;
|
|
1596
|
+
case "fail": return SHIELDS_HEX.red;
|
|
1597
|
+
default: return SHIELDS_HEX.lightgrey;
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
/** shields.io endpoint color name for a letter grade. */
|
|
1601
|
+
function gradeColorName(grade) {
|
|
1602
|
+
switch (grade) {
|
|
1603
|
+
case "A": return "brightgreen";
|
|
1604
|
+
case "B": return "green";
|
|
1605
|
+
case "C": return "yellow";
|
|
1606
|
+
case "D": return "orange";
|
|
1607
|
+
case "F": return "red";
|
|
1608
|
+
default: return "lightgrey";
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
/** shields.io endpoint color name for a dimension status. */
|
|
1612
|
+
function statusColorName(status) {
|
|
1613
|
+
switch (status) {
|
|
1614
|
+
case "pass": return "brightgreen";
|
|
1615
|
+
case "warn": return "orange";
|
|
1616
|
+
case "fail": return "red";
|
|
1617
|
+
default: return "lightgrey";
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
/** Escape text for safe SVG content interpolation. */
|
|
1621
|
+
function escapeXml(text) {
|
|
1622
|
+
return text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
1623
|
+
}
|
|
1624
|
+
/**
|
|
1625
|
+
* Render one shields.io flat-style badge as a self-contained SVG document.
|
|
1626
|
+
* Widths use a fixed 8px/char approximation and `textLength` force-fits the
|
|
1627
|
+
* text into its rect, so the badge never truncates regardless of the exact
|
|
1628
|
+
* font metrics. Safe to embed inline or save as a `.svg` file.
|
|
1629
|
+
*
|
|
1630
|
+
* @param label - left segment text.
|
|
1631
|
+
* @param message - right segment text.
|
|
1632
|
+
* @param color - right-segment fill color (hex or named).
|
|
1633
|
+
* @param labelColor - left-segment fill color (default grey `#555`).
|
|
1634
|
+
* @returns the SVG document string.
|
|
1635
|
+
*/
|
|
1636
|
+
function renderShieldsSvg(label, message, color, labelColor = "#555") {
|
|
1637
|
+
const labelText = escapeXml(label);
|
|
1638
|
+
const messageText = escapeXml(message);
|
|
1639
|
+
const labelPx = Math.max(labelText.length * 8, 12);
|
|
1640
|
+
const messagePx = Math.max(messageText.length * 8, 12);
|
|
1641
|
+
const labelWidth = labelPx + 10;
|
|
1642
|
+
const messageWidth = messagePx + 10;
|
|
1643
|
+
const totalWidth = labelWidth + messageWidth;
|
|
1644
|
+
const labelX = Math.round(labelWidth / 2 * 10);
|
|
1645
|
+
const messageX = Math.round((labelWidth + messageWidth / 2) * 10);
|
|
1646
|
+
const labelLength = labelPx * 10;
|
|
1647
|
+
const messageLength = messagePx * 10;
|
|
1648
|
+
return [
|
|
1649
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${totalWidth}" height="20" role="img" aria-label="${labelText}: ${messageText}">`,
|
|
1650
|
+
`<title>${labelText}: ${messageText}</title>`,
|
|
1651
|
+
"<linearGradient id=\"s\" x2=\"0\" y2=\"100%\">",
|
|
1652
|
+
"<stop offset=\"0\" stop-color=\"#bbb\" stop-opacity=\".1\"/>",
|
|
1653
|
+
"<stop offset=\"1\" stop-opacity=\".1\"/>",
|
|
1654
|
+
"</linearGradient>",
|
|
1655
|
+
"<clipPath id=\"r\">",
|
|
1656
|
+
`<rect width="${totalWidth}" height="20" rx="3" fill="#fff"/>`,
|
|
1657
|
+
"</clipPath>",
|
|
1658
|
+
"<g clip-path=\"url(#r)\">",
|
|
1659
|
+
`<rect width="${labelWidth}" height="20" fill="${labelColor}"/>`,
|
|
1660
|
+
`<rect x="${labelWidth}" width="${messageWidth}" height="20" fill="${color}"/>`,
|
|
1661
|
+
`<rect width="${totalWidth}" height="20" fill="url(#s)"/>`,
|
|
1662
|
+
"</g>",
|
|
1663
|
+
"<g fill=\"#fff\" text-anchor=\"middle\" font-family=\"Verdana,Geneva,DejaVu Sans,sans-serif\" text-rendering=\"geometricPrecision\" font-size=\"110\">",
|
|
1664
|
+
`<text aria-hidden="true" x="${labelX}" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="${labelLength}">${labelText}</text>`,
|
|
1665
|
+
`<text x="${labelX}" y="140" transform="scale(.1)" fill="#fff" textLength="${labelLength}">${labelText}</text>`,
|
|
1666
|
+
`<text aria-hidden="true" x="${messageX}" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="${messageLength}">${messageText}</text>`,
|
|
1667
|
+
`<text x="${messageX}" y="140" transform="scale(.1)" fill="#fff" textLength="${messageLength}">${messageText}</text>`,
|
|
1668
|
+
"</g>",
|
|
1669
|
+
"</svg>"
|
|
1670
|
+
].join("\n");
|
|
1671
|
+
}
|
|
1672
|
+
/**
|
|
1673
|
+
* Escape one badge-path segment for a shields.io static endpoint: dash →
|
|
1674
|
+
* `--`, underscore → `__`, space → `_`, then percent-encode `/` and `·` so the
|
|
1675
|
+
* path stays unambiguous (the escaping order is load-bearing).
|
|
1676
|
+
*/
|
|
1677
|
+
function shieldPathSegment(text) {
|
|
1678
|
+
return text.replaceAll("-", "--").replaceAll("_", "__").replaceAll(" ", "_").replaceAll("/", "%2F").replaceAll("·", "%C2%B7");
|
|
1679
|
+
}
|
|
1680
|
+
/**
|
|
1681
|
+
* The documented shields.io static-badge endpoint for one label/message pair.
|
|
1682
|
+
* This is the zero-hosting embed path: paste the URL into a README image and
|
|
1683
|
+
* shields.io renders it; {@link renderShieldsSvg} is the offline equivalent.
|
|
1684
|
+
*
|
|
1685
|
+
* @param label - left segment text.
|
|
1686
|
+
* @param message - right segment text.
|
|
1687
|
+
* @param color - shields.io named color (e.g. `brightgreen`).
|
|
1688
|
+
* @returns the shields.io badge URL.
|
|
1689
|
+
*/
|
|
1690
|
+
function shieldsEndpointUrl(label, message, color) {
|
|
1691
|
+
return `https://img.shields.io/badge/${shieldPathSegment(label)}-${shieldPathSegment(message)}-${color}`;
|
|
1692
|
+
}
|
|
1693
|
+
/** Total-badge message: letter grade and weighted total. */
|
|
1694
|
+
function totalMessage(result) {
|
|
1695
|
+
return `${result.grade} · ${result.total}/100`;
|
|
1696
|
+
}
|
|
1697
|
+
/** Build one badge surface for a label/message pair colored by a hex value. */
|
|
1698
|
+
function badgeSurface(label, message, colorHex, colorName) {
|
|
1699
|
+
const endpoint = shieldsEndpointUrl(label, message, colorName);
|
|
1700
|
+
return {
|
|
1701
|
+
endpoint,
|
|
1702
|
+
markdown: ``,
|
|
1703
|
+
svg: renderShieldsSvg(label, message, colorHex)
|
|
1704
|
+
};
|
|
1705
|
+
}
|
|
1706
|
+
/** One dimension's compact JSON representation. */
|
|
1707
|
+
function dimensionJson(result, dimension) {
|
|
1708
|
+
const score = result.dimensions[dimension];
|
|
1709
|
+
return {
|
|
1710
|
+
label: DIMENSION_BADGE_LABELS[dimension],
|
|
1711
|
+
status: score.status,
|
|
1712
|
+
score: score.score,
|
|
1713
|
+
weight: score.weight,
|
|
1714
|
+
summary: score.summary
|
|
1715
|
+
};
|
|
1716
|
+
}
|
|
1717
|
+
/**
|
|
1718
|
+
* The five-dimension JSON API envelope for one score card: the compact
|
|
1719
|
+
* per-dimension scores plus the total/grade and the embeddable badge surfaces.
|
|
1720
|
+
* A no-evidence dimension keeps its honest `no-evidence` status and score 0.
|
|
1721
|
+
*
|
|
1722
|
+
* @param result - a settled score card.
|
|
1723
|
+
* @returns the badge JSON envelope.
|
|
1724
|
+
*/
|
|
1725
|
+
function badgeJson(result) {
|
|
1726
|
+
const dimensions = Object.fromEntries(DIMENSIONS.map((dimension) => [dimension, dimensionJson(result, dimension)]));
|
|
1727
|
+
const dimensionBadges = Object.fromEntries(DIMENSIONS.map((dimension) => {
|
|
1728
|
+
const score = result.dimensions[dimension];
|
|
1729
|
+
const surface = badgeSurface(`dsh-score ${DIMENSION_BADGE_LABELS[dimension]}`, `${score.score}`, statusColor(score.status), statusColorName(score.status));
|
|
1730
|
+
return [dimension, {
|
|
1731
|
+
endpoint: surface.endpoint,
|
|
1732
|
+
markdown: surface.markdown
|
|
1733
|
+
}];
|
|
1734
|
+
}));
|
|
1735
|
+
return {
|
|
1736
|
+
schema: BADGE_SCHEMA,
|
|
1737
|
+
target: {
|
|
1738
|
+
kind: result.target.kind,
|
|
1739
|
+
spec: result.target.spec
|
|
1740
|
+
},
|
|
1741
|
+
scoredAt: result.scoredAt,
|
|
1742
|
+
pluginVersion: result.pluginVersion,
|
|
1743
|
+
total: result.total,
|
|
1744
|
+
grade: result.grade,
|
|
1745
|
+
verdict: result.verdict,
|
|
1746
|
+
dimensions,
|
|
1747
|
+
badge: badgeSurface("dsh-score", totalMessage(result), gradeColor(result.grade), gradeColorName(result.grade)),
|
|
1748
|
+
dimensionBadges
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
/**
|
|
1752
|
+
* Render the total/grade badge SVG for one score card (offline use).
|
|
1753
|
+
*
|
|
1754
|
+
* @param result - a settled score card.
|
|
1755
|
+
* @returns the SVG document string.
|
|
1756
|
+
*/
|
|
1757
|
+
function renderScoreBadge(result) {
|
|
1758
|
+
return renderShieldsSvg("dsh-score", totalMessage(result), gradeColor(result.grade));
|
|
1759
|
+
}
|
|
1760
|
+
/**
|
|
1761
|
+
* Render the per-dimension badge SVGs for one score card (offline use).
|
|
1762
|
+
*
|
|
1763
|
+
* @param result - a settled score card.
|
|
1764
|
+
* @returns SVGs keyed by dimension id.
|
|
1765
|
+
*/
|
|
1766
|
+
function renderDimensionBadges(result) {
|
|
1767
|
+
return Object.fromEntries(DIMENSIONS.map((dimension) => {
|
|
1768
|
+
const score = result.dimensions[dimension];
|
|
1769
|
+
return [dimension, renderShieldsSvg(`dsh-score ${DIMENSION_BADGE_LABELS[dimension]}`, `${score.score}`, statusColor(score.status))];
|
|
1770
|
+
}));
|
|
1771
|
+
}
|
|
1772
|
+
/**
|
|
1773
|
+
* The Markdown embed snippet for the total/grade badge (points at shields.io).
|
|
1774
|
+
*
|
|
1775
|
+
* @param result - a settled score card.
|
|
1776
|
+
* @returns a Markdown image line.
|
|
1777
|
+
*/
|
|
1778
|
+
function renderBadgeMarkdown(result) {
|
|
1779
|
+
const message = totalMessage(result);
|
|
1780
|
+
return `)})`;
|
|
1781
|
+
}
|
|
1782
|
+
//#endregion
|
|
1546
1783
|
//#region src/report.ts
|
|
1547
1784
|
/** Emoji/symbol mark for a dimension status. */
|
|
1548
1785
|
function statusMark(status) {
|
|
@@ -1739,6 +1976,84 @@ const leaderboardSchema = {
|
|
|
1739
1976
|
}
|
|
1740
1977
|
}
|
|
1741
1978
|
};
|
|
1979
|
+
/** JSON-schema fragment for one compact dimension entry of the badge JSON. */
|
|
1980
|
+
const dimensionScoreSummarySchema = {
|
|
1981
|
+
type: "object",
|
|
1982
|
+
additionalProperties: false,
|
|
1983
|
+
properties: {
|
|
1984
|
+
label: { type: "string" },
|
|
1985
|
+
status: { type: "string" },
|
|
1986
|
+
score: { type: "number" },
|
|
1987
|
+
weight: { type: "number" },
|
|
1988
|
+
summary: { type: "string" }
|
|
1989
|
+
}
|
|
1990
|
+
};
|
|
1991
|
+
/** JSON-schema fragment for the total badge surface (SVG + endpoint + markdown). */
|
|
1992
|
+
const badgeSurfaceSchema = {
|
|
1993
|
+
type: "object",
|
|
1994
|
+
additionalProperties: false,
|
|
1995
|
+
properties: {
|
|
1996
|
+
endpoint: { type: "string" },
|
|
1997
|
+
markdown: { type: "string" },
|
|
1998
|
+
svg: { type: "string" }
|
|
1999
|
+
}
|
|
2000
|
+
};
|
|
2001
|
+
/** JSON-schema fragment for one per-dimension badge (endpoint + markdown). */
|
|
2002
|
+
const badgeEndpointSchema = {
|
|
2003
|
+
type: "object",
|
|
2004
|
+
additionalProperties: false,
|
|
2005
|
+
properties: {
|
|
2006
|
+
endpoint: { type: "string" },
|
|
2007
|
+
markdown: { type: "string" }
|
|
2008
|
+
}
|
|
2009
|
+
};
|
|
2010
|
+
/** Full JSON-schema fragment for the `score_badge` five-dimension JSON output. */
|
|
2011
|
+
const badgeJsonSchema = {
|
|
2012
|
+
type: "object",
|
|
2013
|
+
additionalProperties: false,
|
|
2014
|
+
properties: {
|
|
2015
|
+
schema: {
|
|
2016
|
+
type: "string",
|
|
2017
|
+
const: BADGE_SCHEMA
|
|
2018
|
+
},
|
|
2019
|
+
target: {
|
|
2020
|
+
type: "object",
|
|
2021
|
+
additionalProperties: false,
|
|
2022
|
+
properties: {
|
|
2023
|
+
kind: { type: "string" },
|
|
2024
|
+
spec: { type: "string" }
|
|
2025
|
+
}
|
|
2026
|
+
},
|
|
2027
|
+
scoredAt: { type: "string" },
|
|
2028
|
+
pluginVersion: { type: "string" },
|
|
2029
|
+
total: { type: "number" },
|
|
2030
|
+
grade: { type: "string" },
|
|
2031
|
+
verdict: { type: "string" },
|
|
2032
|
+
dimensions: {
|
|
2033
|
+
type: "object",
|
|
2034
|
+
additionalProperties: false,
|
|
2035
|
+
properties: {
|
|
2036
|
+
install: dimensionScoreSummarySchema,
|
|
2037
|
+
maintenance: dimensionScoreSummarySchema,
|
|
2038
|
+
documentation: dimensionScoreSummarySchema,
|
|
2039
|
+
security: dimensionScoreSummarySchema,
|
|
2040
|
+
compliance: dimensionScoreSummarySchema
|
|
2041
|
+
}
|
|
2042
|
+
},
|
|
2043
|
+
badge: badgeSurfaceSchema,
|
|
2044
|
+
dimensionBadges: {
|
|
2045
|
+
type: "object",
|
|
2046
|
+
additionalProperties: false,
|
|
2047
|
+
properties: {
|
|
2048
|
+
install: badgeEndpointSchema,
|
|
2049
|
+
maintenance: badgeEndpointSchema,
|
|
2050
|
+
documentation: badgeEndpointSchema,
|
|
2051
|
+
security: badgeEndpointSchema,
|
|
2052
|
+
compliance: badgeEndpointSchema
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
};
|
|
1742
2057
|
/** Render one `score` result (score card or background handle). */
|
|
1743
2058
|
function renderScore(value) {
|
|
1744
2059
|
if (value.kind === "background") return [{
|
|
@@ -1757,6 +2072,37 @@ function renderReport(value) {
|
|
|
1757
2072
|
text: "rows" in value ? renderLeaderboard(value) : renderScoreCard(value)
|
|
1758
2073
|
}];
|
|
1759
2074
|
}
|
|
2075
|
+
/** Render one `score_badge` result: Markdown embed + the five-dimension JSON. */
|
|
2076
|
+
function renderBadge(value) {
|
|
2077
|
+
return [{
|
|
2078
|
+
type: "text",
|
|
2079
|
+
text: [
|
|
2080
|
+
"# Score badge",
|
|
2081
|
+
"",
|
|
2082
|
+
`- Target: \`${value.target.spec}\` — grade **${value.grade}** (${value.total}/100)`,
|
|
2083
|
+
`- Scored: ${value.scoredAt}`,
|
|
2084
|
+
"",
|
|
2085
|
+
"## Embed",
|
|
2086
|
+
"",
|
|
2087
|
+
value.badge.markdown,
|
|
2088
|
+
"",
|
|
2089
|
+
"## Five-dimension JSON",
|
|
2090
|
+
"",
|
|
2091
|
+
"```json",
|
|
2092
|
+
JSON.stringify({
|
|
2093
|
+
schema: value.schema,
|
|
2094
|
+
target: value.target,
|
|
2095
|
+
scoredAt: value.scoredAt,
|
|
2096
|
+
pluginVersion: value.pluginVersion,
|
|
2097
|
+
total: value.total,
|
|
2098
|
+
grade: value.grade,
|
|
2099
|
+
verdict: value.verdict,
|
|
2100
|
+
dimensions: value.dimensions
|
|
2101
|
+
}, null, 2),
|
|
2102
|
+
"```"
|
|
2103
|
+
].join("\n")
|
|
2104
|
+
}];
|
|
2105
|
+
}
|
|
1760
2106
|
/** The deadline for one foreground score: every probe deadline plus slack. */
|
|
1761
2107
|
function scoreDeadlineMs(config) {
|
|
1762
2108
|
return config.probeTimeoutMs * 10 + 6e4;
|
|
@@ -1768,7 +2114,7 @@ function requireOwner(exec) {
|
|
|
1768
2114
|
}
|
|
1769
2115
|
/** Build both tool definitions over the shared services. */
|
|
1770
2116
|
function allTools(services) {
|
|
1771
|
-
|
|
2117
|
+
const score = defineTool({
|
|
1772
2118
|
name: "score",
|
|
1773
2119
|
description: "Score one DeepSeek Harness plugin target (a GitHub repo spec or an npm package name) across five dimensions from REAL CLI evidence: install success (consuming dsh-test-drive results when present), maintenance activity, documentation completeness, security scan (license, secret leaks, malicious install scripts), and protocol compliance (dsh.bundle.patch + dsh-plugin topic). Every conclusion carries an evidence link and audit timestamp; a dimension without evidence is honestly reported as no-evidence, never fabricated. Returns a risk card with a weighted total and letter grade. Use background: true for a slow target.",
|
|
1774
2120
|
parameters: {
|
|
@@ -1817,7 +2163,8 @@ function allTools(services) {
|
|
|
1817
2163
|
refresh: args.refresh === true
|
|
1818
2164
|
});
|
|
1819
2165
|
}
|
|
1820
|
-
})
|
|
2166
|
+
});
|
|
2167
|
+
const scoreReport = defineTool({
|
|
1821
2168
|
name: "score_report",
|
|
1822
2169
|
description: "Fetch a stored score record by id: a score card (sc_...), a leaderboard (lb_...), or — with no id — the latest leaderboard. Returns the structured record and renders it as Markdown.",
|
|
1823
2170
|
parameters: { id: {
|
|
@@ -1849,7 +2196,53 @@ function allTools(services) {
|
|
|
1849
2196
|
}
|
|
1850
2197
|
throw new Error(`dsh-score: unknown report id ${args.id} (expected sc_... score or lb_... leaderboard)`);
|
|
1851
2198
|
}
|
|
1852
|
-
})
|
|
2199
|
+
});
|
|
2200
|
+
return [
|
|
2201
|
+
score,
|
|
2202
|
+
defineTool({
|
|
2203
|
+
name: "score_badge",
|
|
2204
|
+
description: "Generate an embeddable README badge and the five-dimension JSON for one plugin target. Scores the target through the cache (or fetches a stored score card by id) and returns a shields.io flat SVG badge, its documented endpoint URL, a Markdown embed snippet, and the compact five-dimension JSON (install/maintenance/documentation/security/compliance each with status, score, weight, summary) plus the weighted total and letter grade. A dimension without evidence is reported honestly as no-evidence (grey, score 0), never fabricated.",
|
|
2205
|
+
parameters: {
|
|
2206
|
+
target: {
|
|
2207
|
+
type: "string",
|
|
2208
|
+
description: "Plugin target to badge: a GitHub repo or an npm package name (mutually exclusive with id)."
|
|
2209
|
+
},
|
|
2210
|
+
id: {
|
|
2211
|
+
type: "string",
|
|
2212
|
+
description: "Stored score id (sc_...) to badge without re-scoring (mutually exclusive with target)."
|
|
2213
|
+
},
|
|
2214
|
+
refresh: {
|
|
2215
|
+
type: "boolean",
|
|
2216
|
+
description: "Bypass the score cache and re-score from fresh evidence (default false; only applies to target)."
|
|
2217
|
+
}
|
|
2218
|
+
},
|
|
2219
|
+
output: {
|
|
2220
|
+
schema: badgeJsonSchema,
|
|
2221
|
+
render: (_args, value) => renderBadge(value)
|
|
2222
|
+
},
|
|
2223
|
+
timeoutMs: scoreDeadlineMs(services.config),
|
|
2224
|
+
async execute(args, exec) {
|
|
2225
|
+
const hasTarget = args.target !== void 0 && args.target !== "";
|
|
2226
|
+
const hasId = args.id !== void 0 && args.id !== "";
|
|
2227
|
+
if (hasTarget === hasId) throw new Error("dsh-score: score_badge requires exactly one of target or id");
|
|
2228
|
+
let result;
|
|
2229
|
+
if (hasId) {
|
|
2230
|
+
const card = (await services.domain()).table("scores").get(String(args.id));
|
|
2231
|
+
if (card === void 0) throw new Error(`dsh-score: no score recorded with id ${String(args.id)}`);
|
|
2232
|
+
result = card;
|
|
2233
|
+
} else {
|
|
2234
|
+
const target = sanitizeTarget(String(args.target));
|
|
2235
|
+
if (target.length === 0) throw new Error("dsh-score: target must be a non-empty string");
|
|
2236
|
+
result = await services.runner.score(target, {
|
|
2237
|
+
signal: exec.signal,
|
|
2238
|
+
refresh: args.refresh === true
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
return badgeJson(result);
|
|
2242
|
+
}
|
|
2243
|
+
}),
|
|
2244
|
+
scoreReport
|
|
2245
|
+
];
|
|
1853
2246
|
}
|
|
1854
2247
|
//#endregion
|
|
1855
2248
|
//#region src/index.ts
|
|
@@ -1921,4 +2314,4 @@ function apply(ctx, config) {
|
|
|
1921
2314
|
});
|
|
1922
2315
|
}
|
|
1923
2316
|
//#endregion
|
|
1924
|
-
export { Config, DIMENSIONS, DOMAIN_NAME, DOMAIN_VERSION, LEADERBOARD_ID_PREFIX, LICENSE_ALLOWLIST, LeaderboardRecordSchema, MALICIOUS_SCRIPT_MARKERS, ProbeDriver, REDACTED, RESULT_SCHEMA, SCORE_BATCH_KIND, SCORE_KEY_PREFIX, SECRET_PATTERNS, ScoreResultSchema, ScoreRunner, VERSION, apply, classifyTarget, computeTotal, daysSince, evaluateAll, evaluateCompliance, evaluateDocumentation, evaluateInstall, evaluateMaintenance, evaluateSecurity, extractRepoFromNpmUrl, formatDuration, freshLeaderboardId, gradeOf, hasEvidence, inject, leaderboardSummary, licenseCompliance, name, parseFileList, parseGithubContent, parseLatestCommit, parseNpmShim, parseNpmView, parseOldestOpenIssue, parseRepoMeta, parseRepoRef, parseTargets, progressLine, readTestDriveEvidence, redactSecrets, renderLeaderboard, renderScoreCard, resolveConfig, rowOf, runBatch, sanitizeTarget, scanMaliciousScripts, scanSecretPatterns, scoreDomainSpec, scoreKey, startBatchJob, statusMark, tailText, totalsOf, verdictOf };
|
|
2317
|
+
export { BADGE_SCHEMA, Config, DIMENSIONS, DIMENSION_BADGE_LABELS, DOMAIN_NAME, DOMAIN_VERSION, LEADERBOARD_ID_PREFIX, LICENSE_ALLOWLIST, LeaderboardRecordSchema, MALICIOUS_SCRIPT_MARKERS, ProbeDriver, REDACTED, RESULT_SCHEMA, SCORE_BATCH_KIND, SCORE_KEY_PREFIX, SECRET_PATTERNS, ScoreResultSchema, ScoreRunner, VERSION, apply, badgeJson, classifyTarget, computeTotal, daysSince, evaluateAll, evaluateCompliance, evaluateDocumentation, evaluateInstall, evaluateMaintenance, evaluateSecurity, extractRepoFromNpmUrl, formatDuration, freshLeaderboardId, gradeColor, gradeOf, hasEvidence, inject, leaderboardSummary, licenseCompliance, name, parseFileList, parseGithubContent, parseLatestCommit, parseNpmShim, parseNpmView, parseOldestOpenIssue, parseRepoMeta, parseRepoRef, parseTargets, progressLine, readTestDriveEvidence, redactSecrets, renderBadgeMarkdown, renderDimensionBadges, renderLeaderboard, renderScoreBadge, renderScoreCard, renderShieldsSvg, resolveConfig, rowOf, runBatch, sanitizeTarget, scanMaliciousScripts, scanSecretPatterns, scoreDomainSpec, scoreKey, shieldsEndpointUrl, startBatchJob, statusColor, statusMark, tailText, totalsOf, verdictOf };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embeddable README badges and the five-dimension JSON API output. Pure,
|
|
3
|
+
* zero-dependency functions over a settled {@link ScoreResult}: a shields.io
|
|
4
|
+
* flat-style SVG generator (offline/self-hosted), a documented shields.io
|
|
5
|
+
* endpoint URL, one badge for the weighted total plus one per dimension, and a
|
|
6
|
+
* compact five-dimension JSON envelope for API consumers.
|
|
7
|
+
*
|
|
8
|
+
* Every output derives from an already-settled score card — a dimension with no
|
|
9
|
+
* evidence renders `no-evidence` (grey, score 0) exactly as the card reports it;
|
|
10
|
+
* nothing here fabricates a number.
|
|
11
|
+
*
|
|
12
|
+
* @module dsh-score/badge
|
|
13
|
+
*/
|
|
14
|
+
import type { Dimension, DimensionStatus, ScoreResult } from './result.js';
|
|
15
|
+
/** Discriminator of the badge JSON envelope (version 1). */
|
|
16
|
+
export declare const BADGE_SCHEMA: "dsh-score/badge/v1";
|
|
17
|
+
/** shields.io flat-badge hex colors, keyed by their named endpoints. */
|
|
18
|
+
declare const SHIELDS_HEX: {
|
|
19
|
+
readonly brightgreen: "#4c1";
|
|
20
|
+
readonly green: "#97ca00";
|
|
21
|
+
readonly yellow: "#dfb317";
|
|
22
|
+
readonly orange: "#fe7d37";
|
|
23
|
+
readonly red: "#e05d44";
|
|
24
|
+
readonly blue: "#007ec6";
|
|
25
|
+
readonly lightgrey: "#9f9f9f";
|
|
26
|
+
};
|
|
27
|
+
/** Type of one shields.io named color. */
|
|
28
|
+
type ShieldColor = keyof typeof SHIELDS_HEX;
|
|
29
|
+
/** Compact human labels for the five dimensions (kept short for badge width). */
|
|
30
|
+
export declare const DIMENSION_BADGE_LABELS: Record<Dimension, string>;
|
|
31
|
+
/** shields.io badge color (hex) for a letter grade; grey for `N/A`. */
|
|
32
|
+
export declare function gradeColor(grade: string): string;
|
|
33
|
+
/** shields.io badge color (hex) for a dimension status. */
|
|
34
|
+
export declare function statusColor(status: DimensionStatus): string;
|
|
35
|
+
/**
|
|
36
|
+
* Render one shields.io flat-style badge as a self-contained SVG document.
|
|
37
|
+
* Widths use a fixed 8px/char approximation and `textLength` force-fits the
|
|
38
|
+
* text into its rect, so the badge never truncates regardless of the exact
|
|
39
|
+
* font metrics. Safe to embed inline or save as a `.svg` file.
|
|
40
|
+
*
|
|
41
|
+
* @param label - left segment text.
|
|
42
|
+
* @param message - right segment text.
|
|
43
|
+
* @param color - right-segment fill color (hex or named).
|
|
44
|
+
* @param labelColor - left-segment fill color (default grey `#555`).
|
|
45
|
+
* @returns the SVG document string.
|
|
46
|
+
*/
|
|
47
|
+
export declare function renderShieldsSvg(label: string, message: string, color: string, labelColor?: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* The documented shields.io static-badge endpoint for one label/message pair.
|
|
50
|
+
* This is the zero-hosting embed path: paste the URL into a README image and
|
|
51
|
+
* shields.io renders it; {@link renderShieldsSvg} is the offline equivalent.
|
|
52
|
+
*
|
|
53
|
+
* @param label - left segment text.
|
|
54
|
+
* @param message - right segment text.
|
|
55
|
+
* @param color - shields.io named color (e.g. `brightgreen`).
|
|
56
|
+
* @returns the shields.io badge URL.
|
|
57
|
+
*/
|
|
58
|
+
export declare function shieldsEndpointUrl(label: string, message: string, color: ShieldColor | string): string;
|
|
59
|
+
/** One dimension in the five-dimension JSON envelope. */
|
|
60
|
+
export interface BadgeDimension {
|
|
61
|
+
/** Human label, see {@link DIMENSION_BADGE_LABELS}. */
|
|
62
|
+
label: string;
|
|
63
|
+
/** Verdict, see {@link DimensionStatus}. */
|
|
64
|
+
status: DimensionStatus;
|
|
65
|
+
/** Dimension score in 0..100 (0 when no evidence). */
|
|
66
|
+
score: number;
|
|
67
|
+
/** Weight used when summing the total. */
|
|
68
|
+
weight: number;
|
|
69
|
+
/** Sanitized one-line verdict. */
|
|
70
|
+
summary: string;
|
|
71
|
+
}
|
|
72
|
+
/** One badge surface (SVG plus its documented endpoint and Markdown embed). */
|
|
73
|
+
export interface BadgeSurface {
|
|
74
|
+
/** Documented shields.io endpoint URL. */
|
|
75
|
+
endpoint: string;
|
|
76
|
+
/** Markdown image embed pointing at the endpoint. */
|
|
77
|
+
markdown: string;
|
|
78
|
+
/** Offline/self-hosted SVG document. */
|
|
79
|
+
svg: string;
|
|
80
|
+
}
|
|
81
|
+
/** The five-dimension JSON API envelope returned to badge/API consumers. */
|
|
82
|
+
export interface BadgeJson {
|
|
83
|
+
/** Discriminator {@link BADGE_SCHEMA}. */
|
|
84
|
+
schema: typeof BADGE_SCHEMA;
|
|
85
|
+
/** Scored target. */
|
|
86
|
+
target: {
|
|
87
|
+
kind: ScoreResult['target']['kind'];
|
|
88
|
+
spec: string;
|
|
89
|
+
};
|
|
90
|
+
/** ISO-8601 audit timestamp of the underlying score. */
|
|
91
|
+
scoredAt: string;
|
|
92
|
+
/** Producer version. */
|
|
93
|
+
pluginVersion: string;
|
|
94
|
+
/** Weighted total, 0..100. */
|
|
95
|
+
total: number;
|
|
96
|
+
/** Letter grade. */
|
|
97
|
+
grade: string;
|
|
98
|
+
/** One-line sanitized summary. */
|
|
99
|
+
verdict: string;
|
|
100
|
+
/** Five dimension scores keyed by dimension id. */
|
|
101
|
+
dimensions: Record<Dimension, BadgeDimension>;
|
|
102
|
+
/** Total/grade badge (SVG, endpoint, Markdown embed). */
|
|
103
|
+
badge: BadgeSurface;
|
|
104
|
+
/** Per-dimension badge endpoints and Markdown embeds. */
|
|
105
|
+
dimensionBadges: Record<Dimension, Omit<BadgeSurface, 'svg'>>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The five-dimension JSON API envelope for one score card: the compact
|
|
109
|
+
* per-dimension scores plus the total/grade and the embeddable badge surfaces.
|
|
110
|
+
* A no-evidence dimension keeps its honest `no-evidence` status and score 0.
|
|
111
|
+
*
|
|
112
|
+
* @param result - a settled score card.
|
|
113
|
+
* @returns the badge JSON envelope.
|
|
114
|
+
*/
|
|
115
|
+
export declare function badgeJson(result: ScoreResult): BadgeJson;
|
|
116
|
+
/**
|
|
117
|
+
* Render the total/grade badge SVG for one score card (offline use).
|
|
118
|
+
*
|
|
119
|
+
* @param result - a settled score card.
|
|
120
|
+
* @returns the SVG document string.
|
|
121
|
+
*/
|
|
122
|
+
export declare function renderScoreBadge(result: ScoreResult): string;
|
|
123
|
+
/**
|
|
124
|
+
* Render the per-dimension badge SVGs for one score card (offline use).
|
|
125
|
+
*
|
|
126
|
+
* @param result - a settled score card.
|
|
127
|
+
* @returns SVGs keyed by dimension id.
|
|
128
|
+
*/
|
|
129
|
+
export declare function renderDimensionBadges(result: ScoreResult): Record<Dimension, string>;
|
|
130
|
+
/**
|
|
131
|
+
* The Markdown embed snippet for the total/grade badge (points at shields.io).
|
|
132
|
+
*
|
|
133
|
+
* @param result - a settled score card.
|
|
134
|
+
* @returns a Markdown image line.
|
|
135
|
+
*/
|
|
136
|
+
export declare function renderBadgeMarkdown(result: ScoreResult): string;
|
|
137
|
+
export {};
|
|
138
|
+
//# sourceMappingURL=badge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../src/badge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;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;IACxC,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,4EAA4E;AAC5E,MAAM,WAAW,SAAS;IACxB,0CAA0C;IAC1C,MAAM,EAAE,OAAO,YAAY,CAAA;IAC3B,qBAAqB;IACrB,MAAM,EAAE;QAAE,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IAC7D,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAA;IAChB,wBAAwB;IACxB,aAAa,EAAE,MAAM,CAAA;IACrB,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAA;IACf,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IAC7C,yDAAyD;IACzD,KAAK,EAAE,YAAY,CAAA;IACnB,yDAAyD;IACzD,eAAe,EAAE,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,CAAA;CAC9D;AA6BD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CA8BxD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAE5D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAOpF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAI/D"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export { VERSION } from './version.js';
|
|
|
27
27
|
export { Config, resolveConfig } from './config.js';
|
|
28
28
|
export { RESULT_SCHEMA, DIMENSIONS, computeTotal, hasEvidence, gradeOf, verdictOf, totalsOf, ScoreResultSchema, LeaderboardRecordSchema } from './result.js';
|
|
29
29
|
export type { Dimension, DimensionStatus, TargetKind, EvidenceLink, DimensionScore, ScoreResult, LeaderboardRow, LeaderboardRecord } from './result.js';
|
|
30
|
+
export { BADGE_SCHEMA, DIMENSION_BADGE_LABELS, gradeColor, statusColor, renderShieldsSvg, shieldsEndpointUrl, badgeJson, renderScoreBadge, renderDimensionBadges, renderBadgeMarkdown } from './badge.js';
|
|
31
|
+
export type { BadgeDimension, BadgeSurface, BadgeJson } from './badge.js';
|
|
30
32
|
export { sanitizeTarget, redactSecrets, scanSecretPatterns, tailText, REDACTED, SECRET_PATTERNS } from './sanitize.js';
|
|
31
33
|
export { classifyTarget, parseRepoRef, extractRepoFromNpmUrl, parseRepoMeta, parseLatestCommit, parseFileList, parseGithubContent, parseOldestOpenIssue, parseNpmView, parseNpmShim, ProbeDriver } from './probe.js';
|
|
32
34
|
export type { RepoRef, RepoFacts, NpmFacts, TargetEvidence, ProbeOutcome, ChildRunResult } from './probe.js';
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAMlD,OAAO,EAAE,MAAM,EAAiB,MAAM,aAAa,CAAA;AAOnD,eAAO,MAAM,IAAI,cAAc,CAAA;AAE/B;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,UAA8C,CAAA;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,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{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AAM7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAIxC,+DAA+D;AAC/D,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C,GAAG,EAAE,OAAO,CAAA;IACZ,MAAM,EAAE,cAAc,CAAA;IACtB,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC,CAAA;IACrD,MAAM,EAAE,WAAW,CAAA;CACpB;AAsLD,uEAAuE;AACvE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;CACd;AAgDD,4DAA4D;AAC5D,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,YAAY,qDAgI9C"}
|
package/lib/types/version.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-score",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Multi-dimensional quality scoring for DeepSeek Harness plugins: scores one repo or npm package across install success (consuming dsh-test-drive results), maintenance activity, documentation completeness, security scan, and protocol compliance — every conclusion backed by real CLI evidence with audit timestamps — and produces a JSON/Markdown leaderboard report",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|