@mdvp/cli 1.8.3 → 1.9.1

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 (2) hide show
  1. package/cli.mjs +27 -3
  2. package/package.json +1 -1
package/cli.mjs CHANGED
@@ -82,10 +82,27 @@ function apiPost(path, data, apiKey, baseUrl = API) {
82
82
  })
83
83
  }
84
84
 
85
- async function cmdAudit(domain, { json, raw, apiKey }) {
85
+ function toTextFormat(site, bd) {
86
+ const sorted = [...bd].sort((a, b) => a.s - b.s)
87
+ const worst = sorted.slice(0, 3).map(b => `${b.c}:${b.s}`).join(' ')
88
+ const best = sorted.slice(-3).reverse().map(b => `${b.c}:${b.s}`).join(' ')
89
+ const all = Object.keys(CATS).map(c => {
90
+ const s = bd.find(b => b.c === c)?.s ?? 0
91
+ return `${c}:${s}`
92
+ }).join(' ')
93
+ const base = `https://designsense.tixo-digital.workers.dev/dataset/${site.id}/file`
94
+ return [
95
+ `MDVP/1.0 ${site.id} ${site.grade} ${site.overall_score}/100 label:${site.label}`,
96
+ `scores: ${all}`,
97
+ `worst: ${worst} best: ${best}`,
98
+ `assets: ${base}/desktop-1440.jpg ${base}/scroll.webm ${base}/console.json`,
99
+ ].join('\n')
100
+ }
101
+
102
+ async function cmdAudit(domain, { json, raw, text, apiKey }) {
86
103
  domain = parseDomain(domain)
87
104
 
88
- if ((json || raw) && !apiKey) {
105
+ if ((json || raw || text) && !apiKey) {
89
106
  console.error(`${RED}--json and --raw require an API key (costs 1 credit).${R}`)
90
107
  console.error(`${DIM}Run: npx @mdvp/cli login or npx @mdvp/cli balance${R}`)
91
108
  process.exit(1)
@@ -163,6 +180,12 @@ async function cmdAudit(domain, { json, raw, apiKey }) {
163
180
  return
164
181
  }
165
182
 
183
+ if (text) {
184
+ console.log(toTextFormat(site, bd))
185
+ if (apiKey) await apiPost("/audit/charge", { domain, type: "json", amount: 0.10 }, apiKey).catch(() => {})
186
+ return
187
+ }
188
+
166
189
  if (json) {
167
190
  const output = {
168
191
  id: site.id,
@@ -239,7 +262,7 @@ async function cmdLogin() {
239
262
  async function cmdBalance({ json, apiKey }) {
240
263
  if (!apiKey) { console.error(`${RED}No API key. Run: npx mdvp login${R}`); process.exit(1) }
241
264
  const d = await new Promise((resolve, reject) => {
242
- get(`${API}/token/balance`, { headers: { Accept: "application/json", "x-api-key": apiKey } }, (res) => {
265
+ httpsGet(`${API}/token/balance`, { headers: { Accept: "application/json", "x-api-key": apiKey } }, (res) => {
243
266
  let body = ""
244
267
  res.on("data", (c) => (body += c))
245
268
  res.on("end", () => resolve(JSON.parse(body)))
@@ -402,6 +425,7 @@ async function main() {
402
425
  const opts = {
403
426
  json: flags.has("--json"),
404
427
  raw: flags.has("--raw"),
428
+ text: flags.has("--text"), // LLM-optimized compact format
405
429
  apiKey: cfg.apiKey ?? null,
406
430
  local: flags.has("--local"),
407
431
  daemon: flags.has("--daemon") || flags.has("-d"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdvp/cli",
3
- "version": "1.8.3",
3
+ "version": "1.9.1",
4
4
  "description": "Machine Design Vision Protocol — gives agents eyes to understand design quality",
5
5
  "bin": {
6
6
  "mdvp": "./cli.mjs"