@naseej/blox 1.12.0 → 1.13.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/dist/run.js +2587 -816
- package/dist/sdk.js +44 -4
- package/package.json +5 -2
- package/readme.md +28 -1
package/dist/sdk.js
CHANGED
|
@@ -70,7 +70,8 @@ var isNonInteractive = () => nonInteractiveFlag || !process.stdin.isTTY;
|
|
|
70
70
|
|
|
71
71
|
// src/config/runtime.ts
|
|
72
72
|
var isDebugMode = () => !!import_extra_typings2.program.opts()?.debug;
|
|
73
|
-
var
|
|
73
|
+
var forceMinimalMode = false;
|
|
74
|
+
var isMinimalMode = () => forceMinimalMode || !!import_extra_typings2.program.opts()?.minimal;
|
|
74
75
|
|
|
75
76
|
// src/shared/terminal/index.ts
|
|
76
77
|
var import_ansis = __toESM(require("ansis"));
|
|
@@ -196,15 +197,54 @@ var multiselect = async (opts) => {
|
|
|
196
197
|
|
|
197
198
|
// src/shared/spinner.ts
|
|
198
199
|
var import_prompts4 = require("@clack/prompts");
|
|
200
|
+
var import_string_width = __toESM(require("string-width"));
|
|
201
|
+
var SPINNER_RESERVED_COLUMNS = 7;
|
|
202
|
+
var ANSI_PATTERN = /\u001B\[[0-9;]*[A-Za-z]/y;
|
|
203
|
+
var segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
204
|
+
var fitToTerminal = (msg, columns = process.stdout.columns) => {
|
|
205
|
+
if (!columns) return msg;
|
|
206
|
+
const max = Math.max(columns - SPINNER_RESERVED_COLUMNS, 10);
|
|
207
|
+
if ((0, import_string_width.default)(msg) <= max) return msg;
|
|
208
|
+
let out = "";
|
|
209
|
+
let visible = 0;
|
|
210
|
+
let hasAnsi = false;
|
|
211
|
+
for (let i = 0; i < msg.length; ) {
|
|
212
|
+
ANSI_PATTERN.lastIndex = i;
|
|
213
|
+
const match = ANSI_PATTERN.exec(msg);
|
|
214
|
+
if (match) {
|
|
215
|
+
out += match[0];
|
|
216
|
+
i += match[0].length;
|
|
217
|
+
hasAnsi = true;
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
const next = msg.indexOf("\x1B", i + 1);
|
|
221
|
+
const chunk = msg.slice(i, next === -1 ? void 0 : next);
|
|
222
|
+
let consumed = 0;
|
|
223
|
+
let full = true;
|
|
224
|
+
for (const { segment } of segmenter.segment(chunk)) {
|
|
225
|
+
const w = (0, import_string_width.default)(segment);
|
|
226
|
+
if (visible + w > max - 1) {
|
|
227
|
+
full = false;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
out += segment;
|
|
231
|
+
visible += w;
|
|
232
|
+
consumed += segment.length;
|
|
233
|
+
}
|
|
234
|
+
if (!full) break;
|
|
235
|
+
i += consumed;
|
|
236
|
+
}
|
|
237
|
+
return `${out}${hasAnsi ? "\x1B[0m" : ""}\u2026`;
|
|
238
|
+
};
|
|
199
239
|
var spinner = () => {
|
|
200
|
-
const s = (0, import_prompts4.spinner)();
|
|
201
240
|
const minimal = isMinimalMode() || isDebugMode();
|
|
241
|
+
const s = minimal ? void 0 : (0, import_prompts4.spinner)();
|
|
202
242
|
const stop = (msg = "error", code) => {
|
|
203
243
|
minimal ? code ? import_prompts2.log.error(msg) : import_prompts2.log.step(msg || "success") : s.stop(code ? fmt.red(msg) : fmt.green(msg), code);
|
|
204
244
|
};
|
|
205
245
|
return {
|
|
206
246
|
start: (msg) => {
|
|
207
|
-
minimal ? import_prompts2.log.step(`${msg || "start"}...`) : s.start(msg);
|
|
247
|
+
minimal ? import_prompts2.log.step(`${msg || "start"}...`) : s.start(msg && fitToTerminal(msg));
|
|
208
248
|
},
|
|
209
249
|
stop,
|
|
210
250
|
success: (msg = "success") => {
|
|
@@ -217,7 +257,7 @@ var spinner = () => {
|
|
|
217
257
|
stop(msg, 0);
|
|
218
258
|
},
|
|
219
259
|
message: (msg) => {
|
|
220
|
-
minimal ? import_prompts2.log.message(msg) : s.message(msg);
|
|
260
|
+
minimal ? import_prompts2.log.message(msg) : s.message(fitToTerminal(msg));
|
|
221
261
|
}
|
|
222
262
|
};
|
|
223
263
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naseej/blox",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "blox cli",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./sdk": {
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"postinstall": "patch-package"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
+
"@modelcontextprotocol/client": "2.4.0",
|
|
50
51
|
"@playwright/test": "^1.59.1",
|
|
51
52
|
"@tsconfig/node20": "^20.1.4",
|
|
52
53
|
"@types/cross-spawn": "^6.0.6",
|
|
@@ -79,9 +80,9 @@
|
|
|
79
80
|
"@clack/core": "0.3.5",
|
|
80
81
|
"@clack/prompts": "0.8.2",
|
|
81
82
|
"@commander-js/extra-typings": "12.1.0",
|
|
83
|
+
"@modelcontextprotocol/server": "2.4.0",
|
|
82
84
|
"ansis": "3.3.2",
|
|
83
85
|
"commander": "12.1.0",
|
|
84
|
-
"typescript": "^5.7.2",
|
|
85
86
|
"cross-spawn": "^7.0.6",
|
|
86
87
|
"dayjs": "1.11.13",
|
|
87
88
|
"ejs": "^3.1.10",
|
|
@@ -93,6 +94,8 @@
|
|
|
93
94
|
"lodash": "^4.17.21",
|
|
94
95
|
"ms": "2.1.3",
|
|
95
96
|
"semver": "^7.7.4",
|
|
97
|
+
"string-width": "^7.2.0",
|
|
98
|
+
"typescript": "^5.7.2",
|
|
96
99
|
"zod": "^4.4.3"
|
|
97
100
|
}
|
|
98
101
|
}
|
package/readme.md
CHANGED
|
@@ -51,6 +51,7 @@ Available commands:
|
|
|
51
51
|
- `blox upgrade`: upgrade BLOX CLI
|
|
52
52
|
- `blox skills`: run BLOX CLI skills commands
|
|
53
53
|
- `blox doctor`: diagnose and optionally repair BLOX workspace issues
|
|
54
|
+
- `blox mcp`: run the BLOX MCP server over stdio for MCP-compatible clients
|
|
54
55
|
|
|
55
56
|
## Projects with applications
|
|
56
57
|
|
|
@@ -442,11 +443,37 @@ Exit codes:
|
|
|
442
443
|
- `1`: invalid findings remain, or a repair failed
|
|
443
444
|
- `2`: a check could not complete reliably
|
|
444
445
|
|
|
446
|
+
### mcp
|
|
447
|
+
|
|
448
|
+
Start the BLOX MCP server for one BLOX project. MCP-compatible clients launch it as a subprocess and own its lifecycle:
|
|
449
|
+
|
|
450
|
+
```sh
|
|
451
|
+
blox mcp # serve the project containing the current directory
|
|
452
|
+
blox mcp --cwd /projects/my-dashboard # serve an explicit project
|
|
453
|
+
blox mcp --cwd ../my-dashboard # relative paths resolve against the current directory
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
One server serves one project. The project is resolved and validated once at startup: `--cwd` (default: the current directory) must exist, be readable, and be inside a BLOX project (the nearest `.blox`, so a subdirectory or `apps/<name>` works). Otherwise the server exits with a non-zero code and an error on stderr; it never falls back to another directory. Start one server per project.
|
|
457
|
+
|
|
458
|
+
The server uses stdio transport. Stdout is reserved for MCP protocol messages; logs and diagnostics go to stderr. It exposes block-focused tools for project context, installed/available block discovery, block inspection, block addition and removal, project updates, and doctor checks, plus read-only `blox://` resources for the configured project (including a `blox://blocks/{name}` template for block details). Application management is not exposed yet.
|
|
459
|
+
|
|
460
|
+
Tools operate on the configured project; they do not need a project path. The optional `cwd` tool argument must stay inside the project (relative paths resolve against the project root; `..` and symlinks leading outside are rejected with `OUTSIDE_PROJECT`), and `app` targets an application under `apps/`. MCP roots are not used. `update_project` accepts `dryRun: true` to return a read-only plan (current vs. target registry versions, breaking changes, blockers) without changing files or git state. `remove_blocks` also accepts `dryRun: true` (paths, dependents, lifecycle hooks, blockers); a real removal requires a clean git working tree, checks the whole batch before deleting anything, refuses blocks other blocks depend on unless `force: true`, rolls back on failure, and never removes applications.
|
|
461
|
+
|
|
462
|
+
Example client configuration:
|
|
463
|
+
|
|
464
|
+
```json
|
|
465
|
+
{
|
|
466
|
+
"mcpServers": {
|
|
467
|
+
"blox": { "command": "blox", "args": ["mcp", "--cwd", "/projects/my-dashboard"] }
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
```
|
|
471
|
+
|
|
445
472
|
## Features
|
|
446
473
|
|
|
447
474
|
### Non-interactive Use and JSON Output
|
|
448
475
|
|
|
449
|
-
All commands except `blox skills` support two independent flags:
|
|
476
|
+
All commands except `blox skills` and `blox mcp` support two independent flags:
|
|
450
477
|
|
|
451
478
|
- **`--non-interactive`** controls interaction: nothing is ever prompted; missing required arguments are reported together and the command exits non-zero.
|
|
452
479
|
- **`--json`** controls output format: the CLI writes one JSON envelope to stdout while prompts, progress, warnings, and diagnostics go to stderr.
|