@mdvp/cli 1.3.1 → 1.4.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/cli.mjs +10 -3
- package/package.json +3 -3
package/cli.mjs
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { homedir } from "os"
|
|
3
3
|
import { readFileSync, writeFileSync, mkdirSync } from "fs"
|
|
4
|
-
import { get, request } from "https"
|
|
4
|
+
import { get as httpsGet, request as httpsRequest } from "https"
|
|
5
|
+
import { get as httpGet, request as httpRequest } from "http"
|
|
5
6
|
import { createInterface } from "readline"
|
|
6
7
|
|
|
8
|
+
function pickModule(url) {
|
|
9
|
+
return url.startsWith("http://") ? { get: httpGet, request: httpRequest } : { get: httpsGet, request: httpsRequest }
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
const API = "https://designsense.tixo-digital.workers.dev"
|
|
8
13
|
const CONFIG_DIR = `${homedir()}/.mdvp`
|
|
9
14
|
const CONFIG_FILE = `${CONFIG_DIR}/config.json`
|
|
@@ -37,9 +42,10 @@ function saveConfig(data) {
|
|
|
37
42
|
writeFileSync(CONFIG_FILE, JSON.stringify(data, null, 2))
|
|
38
43
|
}
|
|
39
44
|
|
|
40
|
-
function apiGet(path) {
|
|
45
|
+
function apiGet(path, baseUrl = API) {
|
|
46
|
+
const { get } = pickModule(baseUrl)
|
|
41
47
|
return new Promise((resolve, reject) => {
|
|
42
|
-
get(`${
|
|
48
|
+
get(`${baseUrl}${path}`, { headers: { Accept: "application/json" } }, (res) => {
|
|
43
49
|
let body = ""
|
|
44
50
|
res.on("data", (c) => (body += c))
|
|
45
51
|
res.on("end", () => {
|
|
@@ -51,6 +57,7 @@ function apiGet(path) {
|
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
function apiPost(path, data, apiKey, baseUrl = API) {
|
|
60
|
+
const { request } = pickModule(baseUrl)
|
|
54
61
|
return new Promise((resolve, reject) => {
|
|
55
62
|
const body = JSON.stringify(data)
|
|
56
63
|
const req = request(`${baseUrl}${path}`, {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdvp/cli",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Machine Design Vision Protocol
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "Machine Design Vision Protocol \u2014 gives agents eyes to understand design quality",
|
|
5
5
|
"bin": {
|
|
6
6
|
"mdvp": "./cli.mjs"
|
|
7
7
|
},
|
|
@@ -23,4 +23,4 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://mdvp.tixo-digital.workers.dev",
|
|
25
25
|
"license": "MIT"
|
|
26
|
-
}
|
|
26
|
+
}
|