@nexusbloom/cli 0.2.12 → 0.3.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/README.md +96 -19
- package/package.json +2 -1
- package/src/abbr.js +111 -0
- package/src/index.js +278 -940
- package/src/list.js +107 -0
- package/src/paths.js +42 -0
- package/src/run.js +380 -0
- package/src/tools.js +561 -0
- package/src/ui.js +371 -0
package/README.md
CHANGED
|
@@ -8,15 +8,31 @@ CLI tool for NexusBloom — run tools and workflows from your terminal.
|
|
|
8
8
|
npm install -g @nexusbloom/cli
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Quick Start
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
# List available tools
|
|
14
|
+
# List available tools (interactive pagination, 10 per page)
|
|
15
15
|
nxb list
|
|
16
16
|
|
|
17
|
+
# Search with pagination
|
|
18
|
+
nxb list -s ssl
|
|
19
|
+
|
|
20
|
+
# Non-interactive mode (single page dump)
|
|
21
|
+
nxb list --no-interactive
|
|
22
|
+
|
|
23
|
+
# JSON output (all commands)
|
|
24
|
+
nxb --json list
|
|
25
|
+
|
|
26
|
+
# Show tool abbreviations (paginated)
|
|
27
|
+
nxb abbr
|
|
28
|
+
|
|
17
29
|
# Search tools
|
|
18
30
|
nxb search "ssl"
|
|
31
|
+
```
|
|
19
32
|
|
|
33
|
+
## Running Tools
|
|
34
|
+
|
|
35
|
+
```bash
|
|
20
36
|
# Run a tool (remote API, requires API key)
|
|
21
37
|
nxb run ssl-certificate-checker domain=example.com --key YOUR_API_KEY
|
|
22
38
|
|
|
@@ -26,46 +42,107 @@ nxb run css-gradient-generator --input '{"colors":["#ff6b6b","#4ecdc4"],"angle":
|
|
|
26
42
|
# Run with file input
|
|
27
43
|
nxb run css-gradient-generator --file ./gradient-input.json
|
|
28
44
|
|
|
29
|
-
# Run a tool locally (fetches + caches tool source, executes
|
|
45
|
+
# Run a tool locally (fetches + caches tool source, executes on your machine)
|
|
30
46
|
nxb run ssl-certificate-checker domain=example.com --local
|
|
31
47
|
|
|
48
|
+
# Interactive runner (select tool → pick inputs → auto-build command)
|
|
49
|
+
nxb run
|
|
50
|
+
|
|
32
51
|
# Pipe stdin through a tool
|
|
33
52
|
echo '{"domain":"example.com"}' | nxb transform ssl-certificate-checker
|
|
53
|
+
```
|
|
34
54
|
|
|
35
|
-
|
|
36
|
-
nxb chat "check if my website example.com is secure"
|
|
55
|
+
## Discovery
|
|
37
56
|
|
|
38
|
-
|
|
57
|
+
```bash
|
|
58
|
+
# Show tool schema and details
|
|
39
59
|
nxb info ssl-certificate-checker
|
|
40
60
|
|
|
41
|
-
#
|
|
61
|
+
# Show abbreviations (useful for quick tool references)
|
|
62
|
+
nxb abbr
|
|
63
|
+
nxb abbr ip # Filter abbreviations by query
|
|
64
|
+
|
|
65
|
+
# Interactive pagination for lists
|
|
66
|
+
nxb list # Browse pages with prev / next / done
|
|
67
|
+
nxb list -s validate # Filtered + paginated
|
|
68
|
+
|
|
69
|
+
# Search (full-text across slugs, names, descriptions, tags)
|
|
70
|
+
nxb search "validate"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Configuration
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Set config values
|
|
77
|
+
nxb config set key YOUR_KEY # Set an API key
|
|
78
|
+
nxb config set default-tool ssl-scanner # Set default tool
|
|
79
|
+
|
|
80
|
+
# Get config values
|
|
81
|
+
nxb config get key # Get specific value
|
|
82
|
+
nxb config get # List all config values
|
|
83
|
+
|
|
84
|
+
# Environment variables (alternative to config)
|
|
85
|
+
# NEXUSBLOOM_API_KEY — API key (can also use `--key`)
|
|
86
|
+
# NEXUSBLOOM_API_URL — API base URL (default: https://nexusbloom.dev)
|
|
87
|
+
# NEXUSBLOOM_SUPABASE_URL — Supabase URL (for fallback fetching)
|
|
88
|
+
# NEXUSBLOOM_SUPABASE_ANON_KEY — Supabase anon key (for fallback fetching)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Local Tool Cache
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# List cached tools
|
|
42
95
|
nxb cache list
|
|
96
|
+
|
|
97
|
+
# Clear the local tool cache
|
|
43
98
|
nxb cache clear
|
|
44
99
|
```
|
|
45
100
|
|
|
101
|
+
## Scaffolding
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Interactive tool creation
|
|
105
|
+
nxb create
|
|
106
|
+
|
|
107
|
+
# Non-interactive tool creation
|
|
108
|
+
nxb create --slug my-tool --name "My Tool" --desc "Does something useful"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## JSON Input Generation
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Generate JSON template with defaults
|
|
115
|
+
nxb json --template data-generator
|
|
116
|
+
|
|
117
|
+
# Interactive JSON generation (prompts for each field)
|
|
118
|
+
nxb json --template css-gradient-generator -i
|
|
119
|
+
|
|
120
|
+
# Set specific fields
|
|
121
|
+
nxb json --template data-generator -s count=10 format=csv
|
|
122
|
+
|
|
123
|
+
# Full pipeline example
|
|
124
|
+
nxb json --template data-generator -s count=3 | nxb run data-generator --input @-
|
|
125
|
+
```
|
|
126
|
+
|
|
46
127
|
## Options
|
|
47
128
|
|
|
48
129
|
| Flag | Description |
|
|
49
130
|
|------|-------------|
|
|
50
|
-
| `--json` | Output results in JSON format |
|
|
51
|
-
| `--
|
|
52
|
-
| `--input <json>` | Inline JSON input (e.g. `'{"domain":"example.com"}'`) |
|
|
53
|
-
| `--file <path>` | Read input from a JSON file |
|
|
54
|
-
| `--local` | Execute coreLogic locally (fetches + caches tool source) |
|
|
131
|
+
| `--json` | Output results in JSON format (global flag, place before subcommand) |
|
|
132
|
+
| `--no-interactive` | Disable interactive pagination for `list`/`abbr` |
|
|
55
133
|
|
|
56
|
-
##
|
|
134
|
+
## Interactive Mode Features
|
|
57
135
|
|
|
58
|
-
- `
|
|
59
|
-
- `
|
|
136
|
+
- **Paginated browsing**: `nxb list` and `nxb abbr` show 10 items per page with prev/next navigation
|
|
137
|
+
- **Interactive runner**: `nxb run` without a slug opens a tool selector, then prompts for each input field, then builds and executes the command
|
|
138
|
+
- **Abbreviation resolution**: Tool slugs can be typed using auto-generated abbreviations (e.g. `scc` for `ssl-certificate-checker`)
|
|
60
139
|
|
|
61
140
|
## Local Execution
|
|
62
141
|
|
|
63
|
-
The `--local` flag fetches the tool's v2 source code from the NexusBloom API,
|
|
64
|
-
caches it locally, and executes the `coreLogic()` function directly on your
|
|
65
|
-
machine. This is useful for:
|
|
142
|
+
The `--local` flag fetches the tool's v2 source code from the NexusBloom API, caches it locally, and executes the `coreLogic()` function directly on your machine. This is useful for:
|
|
66
143
|
|
|
67
144
|
- Offline use (after initial fetch)
|
|
68
145
|
- Faster repeated execution (cached)
|
|
69
146
|
- Privacy-sensitive inputs (data stays on your machine)
|
|
70
147
|
|
|
71
|
-
Use `nxb cache clear` to clear the local cache.
|
|
148
|
+
Use `nxb cache clear` to clear the local source cache.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexusbloom/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "NexusBloom CLI — run tools and workflows from your terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"node": ">=18"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
+
"@inquirer/prompts": "^8.7.2",
|
|
21
22
|
"chalk": "^5.3.0",
|
|
22
23
|
"commander": "^12.0.0",
|
|
23
24
|
"ora": "^8.0.0",
|
package/src/abbr.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* abbr.js — `nxb abbr` command.
|
|
3
|
+
*
|
|
4
|
+
* Displays the tool abbreviation map in a paginated, table-style view.
|
|
5
|
+
*
|
|
6
|
+
* nxb abbr — interactive pagination (10/page)
|
|
7
|
+
* nxb abbr ip — filter by query (matches slug, abbr, or name)
|
|
8
|
+
* nxb abbr --json — raw JSON
|
|
9
|
+
* nxb abbr --no-interactive — single dump
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import chalk from "chalk";
|
|
13
|
+
import { fetchTools, resolveToolSlug, generateAbbreviations } from "./tools.js";
|
|
14
|
+
import { renderHeader, renderTable, paginate, paginateInteractive, typeBadge, PAGE_SIZE, renderPageInfo } from "./ui.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Render a single page of abbreviations as a table.
|
|
18
|
+
*/
|
|
19
|
+
function renderAbbrPage(result, abbrMap) {
|
|
20
|
+
if (result.total === 0) {
|
|
21
|
+
console.log(chalk.yellow(" No tools available. Set NEXUSBLOOM_SUPABASE_ANON_KEY or deploy the API."));
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const rows = result.items.map((t, i) => ({
|
|
26
|
+
"#": chalk.gray(result.startIndex + i + 1),
|
|
27
|
+
abbr: chalk.green.bold(abbrMap[t.slug] || ""),
|
|
28
|
+
slug: chalk.cyan(t.slug),
|
|
29
|
+
name: t.name || "",
|
|
30
|
+
type: typeBadge(t),
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
const cols = [
|
|
34
|
+
{ key: "#", header: "#", width: 4 },
|
|
35
|
+
{ key: "abbr", header: "Abbr", width: 10, align: "center" },
|
|
36
|
+
{ key: "slug", header: "Slug", width: 28 },
|
|
37
|
+
{ key: "name", header: "Tool", width: 30 },
|
|
38
|
+
{ key: "type", header: "Type", width: 10, align: "center" },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
renderTable(cols, rows, { headColor: "bold" });
|
|
42
|
+
console.log();
|
|
43
|
+
renderPageInfo(result);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function abbrAction(opts = {}) {
|
|
47
|
+
const { query, json: jsonMode, interactive = true, force = false, offline = false } = opts;
|
|
48
|
+
|
|
49
|
+
const tools = await fetchTools({ force, offline });
|
|
50
|
+
|
|
51
|
+
// Build abbreviation map
|
|
52
|
+
const abbrMap = generateAbbreviations(tools.map((t) => t.slug));
|
|
53
|
+
|
|
54
|
+
// Filter
|
|
55
|
+
let filtered = tools;
|
|
56
|
+
if (query) {
|
|
57
|
+
const q = query.toLowerCase();
|
|
58
|
+
filtered = tools.filter((t) => {
|
|
59
|
+
const abbr = abbrMap[t.slug];
|
|
60
|
+
return (
|
|
61
|
+
abbr?.toLowerCase().includes(q) ||
|
|
62
|
+
t.slug.toLowerCase().includes(q) ||
|
|
63
|
+
(t.name || "").toLowerCase().includes(q) ||
|
|
64
|
+
(t.short_description || "").toLowerCase().includes(q)
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (filtered.length === 0 && !jsonMode) {
|
|
70
|
+
console.log(chalk.yellow(` No abbreviations${query ? ` matching "${query}"` : ``}.`));
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// JSON mode
|
|
75
|
+
if (jsonMode) {
|
|
76
|
+
const output = filtered.reduce((acc, t) => {
|
|
77
|
+
acc[t.slug] = abbrMap[t.slug];
|
|
78
|
+
return acc;
|
|
79
|
+
}, {});
|
|
80
|
+
console.log(JSON.stringify({ abbreviations: output, count: filtered.length }, null, 2));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Non-interactive single dump
|
|
85
|
+
if (!interactive) {
|
|
86
|
+
renderHeader("Tool Abbreviations", { subtitle: `${filtered.length} tool${filtered.length === 1 ? "" : "s"} available` });
|
|
87
|
+
const result = paginate(filtered, filtered.length, 1);
|
|
88
|
+
renderAbbrPage(result, abbrMap);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Interactive paginated view
|
|
93
|
+
renderHeader("Tool Abbreviations", {
|
|
94
|
+
subtitle: `${filtered.length} abbreviation${filtered.length === 1 ? "" : "s"} available`,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
await paginateInteractive(
|
|
98
|
+
filtered,
|
|
99
|
+
PAGE_SIZE,
|
|
100
|
+
(result) => {
|
|
101
|
+
console.clear();
|
|
102
|
+
renderHeader("Tool Abbreviations", {
|
|
103
|
+
subtitle: `${result.total} abbreviation${result.total === 1 ? "" : "s"} · page ${chalk.cyan(result.page)} of ${chalk.cyan(result.totalPages)}`,
|
|
104
|
+
});
|
|
105
|
+
renderAbbrPage(result, abbrMap);
|
|
106
|
+
},
|
|
107
|
+
{}
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export default abbrAction;
|