pterm 0.0.21 → 0.0.23

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 (4) hide show
  1. package/README.md +35 -0
  2. package/index.js +9 -0
  3. package/package.json +1 -1
  4. package/util.js +42 -0
package/README.md CHANGED
@@ -179,6 +179,41 @@ pterm search --q="text generation"
179
179
  pterm search "tts speech synthesis" --mode=balanced --min-match=2 --limit=8
180
180
  ```
181
181
 
182
+ ## registry search
183
+
184
+ Search the remote Pinokio registry.
185
+
186
+ ### syntax
187
+
188
+ ```
189
+ pterm registry search [query words...]
190
+ pterm registry search --q="<query>" [--limit=<n>] [--sort=relevance|popular|trending|latest|created|checkins|name] [--platform=mac|windows|linux] [--gpu=nvidia|amd|apple]
191
+ ```
192
+
193
+ - `--limit`: (optional) max number of app results to return.
194
+ - `--sort`: (optional) result ordering. Default is `relevance`.
195
+ - `--platform`: (optional) filter by observed platform support from public check-ins.
196
+ - `--gpu`: (optional) filter by observed GPU support from public check-ins.
197
+
198
+ By default, this command queries `https://api.pinokio.co/v1/search`. Override with `PINOKIO_REGISTRY_API_BASE`.
199
+
200
+ ### examples
201
+
202
+ ```
203
+ pterm registry search tts
204
+ ```
205
+
206
+ ```
207
+ pterm registry search "speech synthesis" --limit=5
208
+ ```
209
+
210
+ PINOKIO_REGISTRY_API_BASE=https://api.pinokio.co pterm registry search comfyui --platform=mac --gpu=apple
211
+ ```
212
+
213
+ ```
214
+ PINOKIO_REGISTRY_API_BASE=https://api.pinokio.co pterm registry search comfyui --sort=popular
215
+ ```
216
+
182
217
  ## which
183
218
 
184
219
  Resolve the executable path for a command name through Pinokio's environment.
package/index.js CHANGED
@@ -59,6 +59,13 @@ const isHttpUri = (value) => typeof value === "string" && /^https?:\/\//i.test(v
59
59
  await util.filepicker(argv)
60
60
  } else if (cmd === "download") {
61
61
  await util.download(argv)
62
+ } else if (cmd === "registry") {
63
+ const subcmd = argv._.length > 1 ? String(argv._[1]).toLowerCase() : ""
64
+ if (subcmd === "search") {
65
+ await util.registrySearch(argv)
66
+ } else {
67
+ console.error("supported subcommands: search")
68
+ }
62
69
  } else if (cmd === "search") {
63
70
  await util.search(argv)
64
71
  } else if (cmd === "stars") {
@@ -69,6 +76,8 @@ const isHttpUri = (value) => typeof value === "string" && /^https?:\/\//i.test(v
69
76
  await util.setStar(argv, false)
70
77
  } else if (cmd === "which") {
71
78
  await util.which(argv)
79
+ } else if (cmd === "home") {
80
+ await util.home(argv)
72
81
  } else if (cmd === "status") {
73
82
  await util.status(argv)
74
83
  } else if (cmd === "logs") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pterm",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
package/util.js CHANGED
@@ -7,6 +7,10 @@ class Util {
7
7
  process.stdout.write(JSON.stringify(payload, null, 2))
8
8
  process.stdout.write("\n")
9
9
  }
10
+ registryBase() {
11
+ const value = String(process.env.PINOKIO_REGISTRY_API_BASE || "https://api.pinokio.co").trim()
12
+ return value.replace(/\/$/, "")
13
+ }
10
14
  async search(argv) {
11
15
  const query = (argv._.slice(1).join(" ") || argv.q || "").trim()
12
16
  const params = { q: query }
@@ -33,6 +37,35 @@ class Util {
33
37
  })
34
38
  this.printJson(response.data)
35
39
  }
40
+ async registrySearch(argv) {
41
+ const query = (argv._.slice(2).join(" ") || argv.q || "").trim()
42
+ if (!query) {
43
+ console.error("required argument: <query>")
44
+ return
45
+ }
46
+ const params = { q: query }
47
+ const limitRaw = argv.limit
48
+ const sortRaw = typeof argv.sort === "string" ? argv.sort.trim().toLowerCase() : ""
49
+ const platformRaw = typeof argv.platform === "string" ? argv.platform.trim().toLowerCase() : ""
50
+ const gpuRaw = typeof argv.gpu === "string" ? argv.gpu.trim().toLowerCase() : ""
51
+ if (limitRaw !== undefined && limitRaw !== null && limitRaw !== "") {
52
+ const limit = Number.parseInt(String(limitRaw), 10)
53
+ if (Number.isFinite(limit) && limit > 0) {
54
+ params.limit = String(limit)
55
+ }
56
+ }
57
+ if (["relevance", "popular", "trending", "latest", "created", "checkins", "name"].includes(sortRaw)) {
58
+ params.sort = sortRaw
59
+ }
60
+ if (platformRaw === "mac" || platformRaw === "windows" || platformRaw === "linux") {
61
+ params.platform = platformRaw
62
+ }
63
+ if (gpuRaw === "nvidia" || gpuRaw === "amd" || gpuRaw === "apple") {
64
+ params.gpu = gpuRaw
65
+ }
66
+ const response = await axios.get(`${this.registryBase()}/v1/search`, { params })
67
+ this.printJson(response.data)
68
+ }
36
69
  async status(argv) {
37
70
  if (argv._.length <= 1) {
38
71
  console.error("required argument: <app_id>")
@@ -157,6 +190,15 @@ class Util {
157
190
  throw error
158
191
  }
159
192
  }
193
+ async home(argv) {
194
+ const response = await axios.get("http://localhost:42000/pinokio/home")
195
+ if (argv.json) {
196
+ this.printJson(response.data)
197
+ } else if (response.data && response.data.path) {
198
+ process.stdout.write(String(response.data.path))
199
+ process.stdout.write("\n")
200
+ }
201
+ }
160
202
  async filepicker(argv) {
161
203
  const rpc = new RPC("ws://localhost:42000")
162
204
  if (argv.path) {