@nomad-e/bluma-cli 0.0.20 → 0.0.22
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/main.js +93 -38
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -7,7 +7,7 @@ import { v4 as uuidv42 } from "uuid";
|
|
|
7
7
|
|
|
8
8
|
// src/app/ui/App.tsx
|
|
9
9
|
import { useState as useState4, useEffect as useEffect3, useRef, useCallback, memo as memo4 } from "react";
|
|
10
|
-
import { Box as
|
|
10
|
+
import { Box as Box14, Text as Text13, Static } from "ink";
|
|
11
11
|
|
|
12
12
|
// src/app/ui/layout.tsx
|
|
13
13
|
import { Box, Text } from "ink";
|
|
@@ -2469,15 +2469,44 @@ import updateNotifier from "update-notifier";
|
|
|
2469
2469
|
import { readPackageUp } from "read-package-up";
|
|
2470
2470
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
2471
2471
|
import path9 from "path";
|
|
2472
|
+
import fs8 from "fs";
|
|
2473
|
+
function findPackageJsonNearest(startDir) {
|
|
2474
|
+
let dir = startDir;
|
|
2475
|
+
for (let i = 0; i < 6; i++) {
|
|
2476
|
+
const candidate = path9.join(dir, "package.json");
|
|
2477
|
+
if (fs8.existsSync(candidate)) {
|
|
2478
|
+
try {
|
|
2479
|
+
const raw = fs8.readFileSync(candidate, "utf8");
|
|
2480
|
+
const parsed = JSON.parse(raw);
|
|
2481
|
+
if (parsed?.name && parsed?.version) return parsed;
|
|
2482
|
+
} catch {
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
const parent = path9.dirname(dir);
|
|
2486
|
+
if (parent === dir) break;
|
|
2487
|
+
dir = parent;
|
|
2488
|
+
}
|
|
2489
|
+
return null;
|
|
2490
|
+
}
|
|
2472
2491
|
async function checkForUpdates() {
|
|
2473
2492
|
try {
|
|
2474
2493
|
if (process.env.BLUMA_FORCE_UPDATE_MSG) {
|
|
2475
2494
|
return String(process.env.BLUMA_FORCE_UPDATE_MSG);
|
|
2476
2495
|
}
|
|
2477
|
-
const
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2496
|
+
const binPath = process.argv?.[1];
|
|
2497
|
+
let pkg;
|
|
2498
|
+
if (binPath && fs8.existsSync(binPath)) {
|
|
2499
|
+
const candidatePkg = findPackageJsonNearest(path9.dirname(binPath));
|
|
2500
|
+
if (candidatePkg?.name && candidatePkg?.version) {
|
|
2501
|
+
pkg = candidatePkg;
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
if (!pkg) {
|
|
2505
|
+
const __filename = fileURLToPath3(import.meta.url);
|
|
2506
|
+
const __dirname = path9.dirname(__filename);
|
|
2507
|
+
const result = await readPackageUp({ cwd: __dirname });
|
|
2508
|
+
pkg = result?.packageJson;
|
|
2509
|
+
}
|
|
2481
2510
|
if (!pkg?.name || !pkg?.version) return null;
|
|
2482
2511
|
const isCI = Boolean(process.env.CI);
|
|
2483
2512
|
const isNoCache = process.env.BLUMA_UPDATE_NO_CACHE === "1";
|
|
@@ -2499,8 +2528,37 @@ async function checkForUpdates() {
|
|
|
2499
2528
|
}
|
|
2500
2529
|
}
|
|
2501
2530
|
|
|
2502
|
-
// src/app/ui/
|
|
2531
|
+
// src/app/ui/components/UpdateNotice.tsx
|
|
2532
|
+
import { Box as Box13, Text as Text12 } from "ink";
|
|
2503
2533
|
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2534
|
+
function parseUpdateMessage(msg) {
|
|
2535
|
+
const lines = msg.split(/\r?\n/).map((l) => l.trim());
|
|
2536
|
+
const first = lines[0] || "";
|
|
2537
|
+
const hintLine = lines.slice(1).join(" ") || "";
|
|
2538
|
+
const nameMatch = first.match(/Update available for\s+([^!]+)!/i);
|
|
2539
|
+
const versionMatch = first.match(/!\s*([^\s]+)\s*→\s*([^\s]+)/);
|
|
2540
|
+
const name = nameMatch?.[1]?.trim();
|
|
2541
|
+
const current = versionMatch?.[1]?.trim();
|
|
2542
|
+
const latest = versionMatch?.[2]?.trim();
|
|
2543
|
+
return {
|
|
2544
|
+
name,
|
|
2545
|
+
current,
|
|
2546
|
+
latest,
|
|
2547
|
+
hint: hintLine || void 0
|
|
2548
|
+
};
|
|
2549
|
+
}
|
|
2550
|
+
var UpdateNotice = ({ message }) => {
|
|
2551
|
+
const { name, current, latest, hint } = parseUpdateMessage(message);
|
|
2552
|
+
return /* @__PURE__ */ jsxs11(Box13, { flexDirection: "column", marginBottom: 1, children: [
|
|
2553
|
+
/* @__PURE__ */ jsx13(Text12, { color: "yellow", bold: true, children: "Update Available" }),
|
|
2554
|
+
name && current && latest ? /* @__PURE__ */ jsx13(Text12, { color: "gray", children: `${name}: ${current} \u2192 ${latest}` }) : /* @__PURE__ */ jsx13(Text12, { color: "gray", children: message }),
|
|
2555
|
+
hint ? /* @__PURE__ */ jsx13(Text12, { color: "gray", children: hint }) : null
|
|
2556
|
+
] });
|
|
2557
|
+
};
|
|
2558
|
+
var UpdateNotice_default = UpdateNotice;
|
|
2559
|
+
|
|
2560
|
+
// src/app/ui/App.tsx
|
|
2561
|
+
import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2504
2562
|
var AppComponent = ({ eventBus: eventBus2, sessionId: sessionId2 }) => {
|
|
2505
2563
|
const agentInstance = useRef(null);
|
|
2506
2564
|
const [history, setHistory] = useState4([]);
|
|
@@ -2529,7 +2587,7 @@ var AppComponent = ({ eventBus: eventBus2, sessionId: sessionId2 }) => {
|
|
|
2529
2587
|
...prev,
|
|
2530
2588
|
{
|
|
2531
2589
|
id: prev.length,
|
|
2532
|
-
component: /* @__PURE__ */
|
|
2590
|
+
component: /* @__PURE__ */ jsx14(Text13, { color: "yellow", children: "-- Task cancelled by dev. --" })
|
|
2533
2591
|
}
|
|
2534
2592
|
]);
|
|
2535
2593
|
}, [isProcessing, eventBus2]);
|
|
@@ -2546,11 +2604,11 @@ var AppComponent = ({ eventBus: eventBus2, sessionId: sessionId2 }) => {
|
|
|
2546
2604
|
...prev,
|
|
2547
2605
|
{
|
|
2548
2606
|
id: prev.length,
|
|
2549
|
-
component: /* @__PURE__ */
|
|
2607
|
+
component: /* @__PURE__ */ jsx14(Box14, { marginBottom: 1, children: /* @__PURE__ */ jsx14(Text13, { color: "white", dimColor: true, children: text }) })
|
|
2550
2608
|
},
|
|
2551
2609
|
{
|
|
2552
2610
|
id: prev.length + 1,
|
|
2553
|
-
component: /* @__PURE__ */
|
|
2611
|
+
component: /* @__PURE__ */ jsx14(SlashCommands_default, { input: text, setHistory, agentRef: agentInstance })
|
|
2554
2612
|
}
|
|
2555
2613
|
]);
|
|
2556
2614
|
setIsProcessing(false);
|
|
@@ -2564,8 +2622,8 @@ var AppComponent = ({ eventBus: eventBus2, sessionId: sessionId2 }) => {
|
|
|
2564
2622
|
id: prev.length,
|
|
2565
2623
|
component: (
|
|
2566
2624
|
// Uma única Box para o espaçamento
|
|
2567
|
-
/* @__PURE__ */
|
|
2568
|
-
/* @__PURE__ */
|
|
2625
|
+
/* @__PURE__ */ jsx14(Box14, { marginBottom: 1, children: /* @__PURE__ */ jsxs12(Text13, { color: "white", dimColor: true, children: [
|
|
2626
|
+
/* @__PURE__ */ jsxs12(Text13, { color: "white", children: [
|
|
2569
2627
|
">",
|
|
2570
2628
|
" "
|
|
2571
2629
|
] }),
|
|
@@ -2600,7 +2658,7 @@ var AppComponent = ({ eventBus: eventBus2, sessionId: sessionId2 }) => {
|
|
|
2600
2658
|
[]
|
|
2601
2659
|
);
|
|
2602
2660
|
useEffect3(() => {
|
|
2603
|
-
setHistory([{ id: 0, component: /* @__PURE__ */
|
|
2661
|
+
setHistory([{ id: 0, component: /* @__PURE__ */ jsx14(Header, {}) }]);
|
|
2604
2662
|
const initializeAgent = async () => {
|
|
2605
2663
|
try {
|
|
2606
2664
|
agentInstance.current = new Agent(sessionId2, eventBus2);
|
|
@@ -2652,7 +2710,7 @@ var AppComponent = ({ eventBus: eventBus2, sessionId: sessionId2 }) => {
|
|
|
2652
2710
|
if (prev.length < 2) {
|
|
2653
2711
|
newHistory.push({
|
|
2654
2712
|
id: 1,
|
|
2655
|
-
component: /* @__PURE__ */
|
|
2713
|
+
component: /* @__PURE__ */ jsx14(
|
|
2656
2714
|
SessionInfo,
|
|
2657
2715
|
{
|
|
2658
2716
|
sessionId: sessionId2,
|
|
@@ -2673,10 +2731,7 @@ var AppComponent = ({ eventBus: eventBus2, sessionId: sessionId2 }) => {
|
|
|
2673
2731
|
...prev,
|
|
2674
2732
|
{
|
|
2675
2733
|
id: prev.length,
|
|
2676
|
-
component: /* @__PURE__ */
|
|
2677
|
-
/* @__PURE__ */ jsx13(Text12, { color: "white", bold: true, children: "Update Available" }),
|
|
2678
|
-
/* @__PURE__ */ jsx13(Text12, { color: "gray", children: msg })
|
|
2679
|
-
] })
|
|
2734
|
+
component: /* @__PURE__ */ jsx14(UpdateNotice_default, { message: msg })
|
|
2680
2735
|
}
|
|
2681
2736
|
]);
|
|
2682
2737
|
}
|
|
@@ -2690,10 +2745,10 @@ var AppComponent = ({ eventBus: eventBus2, sessionId: sessionId2 }) => {
|
|
|
2690
2745
|
}
|
|
2691
2746
|
let newComponent = null;
|
|
2692
2747
|
if (parsed.type === "debug") {
|
|
2693
|
-
newComponent = /* @__PURE__ */
|
|
2748
|
+
newComponent = /* @__PURE__ */ jsx14(Text13, { color: "gray", children: parsed.message });
|
|
2694
2749
|
} else if (parsed.type === "protocol_violation") {
|
|
2695
|
-
newComponent = /* @__PURE__ */
|
|
2696
|
-
|
|
2750
|
+
newComponent = /* @__PURE__ */ jsxs12(
|
|
2751
|
+
Box14,
|
|
2697
2752
|
{
|
|
2698
2753
|
borderStyle: "round",
|
|
2699
2754
|
borderColor: "yellow",
|
|
@@ -2701,19 +2756,19 @@ var AppComponent = ({ eventBus: eventBus2, sessionId: sessionId2 }) => {
|
|
|
2701
2756
|
marginBottom: 1,
|
|
2702
2757
|
paddingX: 1,
|
|
2703
2758
|
children: [
|
|
2704
|
-
/* @__PURE__ */
|
|
2705
|
-
/* @__PURE__ */
|
|
2706
|
-
/* @__PURE__ */
|
|
2759
|
+
/* @__PURE__ */ jsx14(Text13, { color: "yellow", bold: true, children: "Protocol Violation" }),
|
|
2760
|
+
/* @__PURE__ */ jsx14(Text13, { color: "gray", children: parsed.content }),
|
|
2761
|
+
/* @__PURE__ */ jsx14(Text13, { color: "yellow", children: parsed.message })
|
|
2707
2762
|
]
|
|
2708
2763
|
}
|
|
2709
2764
|
);
|
|
2710
2765
|
} else if (parsed.type === "error") {
|
|
2711
|
-
newComponent = /* @__PURE__ */
|
|
2766
|
+
newComponent = /* @__PURE__ */ jsxs12(Text13, { color: "red", children: [
|
|
2712
2767
|
"\u274C ",
|
|
2713
2768
|
parsed.message
|
|
2714
2769
|
] });
|
|
2715
2770
|
} else if (parsed.type === "tool_call") {
|
|
2716
|
-
newComponent = /* @__PURE__ */
|
|
2771
|
+
newComponent = /* @__PURE__ */ jsx14(
|
|
2717
2772
|
ToolCallDisplay,
|
|
2718
2773
|
{
|
|
2719
2774
|
toolName: parsed.tool_name,
|
|
@@ -2722,7 +2777,7 @@ var AppComponent = ({ eventBus: eventBus2, sessionId: sessionId2 }) => {
|
|
|
2722
2777
|
}
|
|
2723
2778
|
);
|
|
2724
2779
|
} else if (parsed.type === "tool_result") {
|
|
2725
|
-
newComponent = /* @__PURE__ */
|
|
2780
|
+
newComponent = /* @__PURE__ */ jsx14(
|
|
2726
2781
|
ToolResultDisplay,
|
|
2727
2782
|
{
|
|
2728
2783
|
toolName: parsed.tool_name,
|
|
@@ -2730,15 +2785,15 @@ var AppComponent = ({ eventBus: eventBus2, sessionId: sessionId2 }) => {
|
|
|
2730
2785
|
}
|
|
2731
2786
|
);
|
|
2732
2787
|
} else if (parsed.type === "dev_overlay") {
|
|
2733
|
-
newComponent = /* @__PURE__ */
|
|
2734
|
-
/* @__PURE__ */
|
|
2788
|
+
newComponent = /* @__PURE__ */ jsx14(Box14, { marginBottom: 1, children: /* @__PURE__ */ jsxs12(Text13, { color: "gray", children: [
|
|
2789
|
+
/* @__PURE__ */ jsxs12(Text13, { color: "blue", children: [
|
|
2735
2790
|
">",
|
|
2736
2791
|
" "
|
|
2737
2792
|
] }),
|
|
2738
2793
|
parsed.payload
|
|
2739
2794
|
] }) });
|
|
2740
2795
|
} else if (parsed.type === "log") {
|
|
2741
|
-
newComponent = /* @__PURE__ */
|
|
2796
|
+
newComponent = /* @__PURE__ */ jsxs12(Text13, { color: "gray", children: [
|
|
2742
2797
|
"\u2139\uFE0F ",
|
|
2743
2798
|
parsed.message,
|
|
2744
2799
|
parsed.payload ? `: ${parsed.payload}` : ""
|
|
@@ -2768,12 +2823,12 @@ var AppComponent = ({ eventBus: eventBus2, sessionId: sessionId2 }) => {
|
|
|
2768
2823
|
}, [eventBus2, sessionId2, handleConfirmation]);
|
|
2769
2824
|
const renderInteractiveComponent = () => {
|
|
2770
2825
|
if (mcpStatus !== "connected") {
|
|
2771
|
-
return /* @__PURE__ */
|
|
2772
|
-
|
|
2826
|
+
return /* @__PURE__ */ jsx14(
|
|
2827
|
+
Box14,
|
|
2773
2828
|
{
|
|
2774
2829
|
borderStyle: "round",
|
|
2775
2830
|
borderColor: "black",
|
|
2776
|
-
children: /* @__PURE__ */
|
|
2831
|
+
children: /* @__PURE__ */ jsx14(
|
|
2777
2832
|
SessionInfoConnectingMCP_default,
|
|
2778
2833
|
{
|
|
2779
2834
|
sessionId: sessionId2,
|
|
@@ -2785,7 +2840,7 @@ var AppComponent = ({ eventBus: eventBus2, sessionId: sessionId2 }) => {
|
|
|
2785
2840
|
);
|
|
2786
2841
|
}
|
|
2787
2842
|
if (pendingConfirmation) {
|
|
2788
|
-
return /* @__PURE__ */
|
|
2843
|
+
return /* @__PURE__ */ jsx14(
|
|
2789
2844
|
ConfirmationPrompt,
|
|
2790
2845
|
{
|
|
2791
2846
|
toolCalls: pendingConfirmation,
|
|
@@ -2797,9 +2852,9 @@ var AppComponent = ({ eventBus: eventBus2, sessionId: sessionId2 }) => {
|
|
|
2797
2852
|
}
|
|
2798
2853
|
);
|
|
2799
2854
|
}
|
|
2800
|
-
return /* @__PURE__ */
|
|
2801
|
-
isProcessing && !pendingConfirmation && /* @__PURE__ */
|
|
2802
|
-
/* @__PURE__ */
|
|
2855
|
+
return /* @__PURE__ */ jsxs12(Box14, { flexDirection: "column", children: [
|
|
2856
|
+
isProcessing && !pendingConfirmation && /* @__PURE__ */ jsx14(WorkingTimer, {}),
|
|
2857
|
+
/* @__PURE__ */ jsx14(
|
|
2803
2858
|
InputPrompt,
|
|
2804
2859
|
{
|
|
2805
2860
|
onSubmit: handleSubmit,
|
|
@@ -2809,8 +2864,8 @@ var AppComponent = ({ eventBus: eventBus2, sessionId: sessionId2 }) => {
|
|
|
2809
2864
|
)
|
|
2810
2865
|
] });
|
|
2811
2866
|
};
|
|
2812
|
-
return /* @__PURE__ */
|
|
2813
|
-
/* @__PURE__ */
|
|
2867
|
+
return /* @__PURE__ */ jsxs12(Box14, { flexDirection: "column", children: [
|
|
2868
|
+
/* @__PURE__ */ jsx14(Static, { items: history, children: (item) => /* @__PURE__ */ jsx14(Box14, { children: item.component }, item.id) }),
|
|
2814
2869
|
renderInteractiveComponent()
|
|
2815
2870
|
] });
|
|
2816
2871
|
};
|