@mdvp/cli 1.8.2 → 1.9.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 (2) hide show
  1. package/cli.mjs +28 -3
  2. package/package.json +1 -1
package/cli.mjs CHANGED
@@ -12,7 +12,8 @@ function pickModule(url) {
12
12
  const API = "https://designsense.tixo-digital.workers.dev"
13
13
  const CONFIG_DIR = `${homedir()}/.mdvp`
14
14
  const CONFIG_FILE = `${CONFIG_DIR}/config.json`
15
- const VERSION = "1.2.0"
15
+ const PKG = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf8"))
16
+ const VERSION = PKG.version
16
17
 
17
18
  const CATS = {
18
19
  spacing: "Spacing", typography: "Typography", color: "Color",
@@ -81,10 +82,27 @@ function apiPost(path, data, apiKey, baseUrl = API) {
81
82
  })
82
83
  }
83
84
 
84
- 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 }) {
85
103
  domain = parseDomain(domain)
86
104
 
87
- if ((json || raw) && !apiKey) {
105
+ if ((json || raw || text) && !apiKey) {
88
106
  console.error(`${RED}--json and --raw require an API key (costs 1 credit).${R}`)
89
107
  console.error(`${DIM}Run: npx @mdvp/cli login or npx @mdvp/cli balance${R}`)
90
108
  process.exit(1)
@@ -162,6 +180,12 @@ async function cmdAudit(domain, { json, raw, apiKey }) {
162
180
  return
163
181
  }
164
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
+
165
189
  if (json) {
166
190
  const output = {
167
191
  id: site.id,
@@ -401,6 +425,7 @@ async function main() {
401
425
  const opts = {
402
426
  json: flags.has("--json"),
403
427
  raw: flags.has("--raw"),
428
+ text: flags.has("--text"), // LLM-optimized compact format
404
429
  apiKey: cfg.apiKey ?? null,
405
430
  local: flags.has("--local"),
406
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.2",
3
+ "version": "1.9.0",
4
4
  "description": "Machine Design Vision Protocol — gives agents eyes to understand design quality",
5
5
  "bin": {
6
6
  "mdvp": "./cli.mjs"