@leroylabs/cli 0.1.7 → 0.1.8
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/package.json +1 -1
- package/src/format.mjs +28 -0
- package/src/live-ui.mjs +19 -1
package/package.json
CHANGED
package/src/format.mjs
CHANGED
|
@@ -25,6 +25,32 @@ function record(value) {
|
|
|
25
25
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
export function unavailableSymbolGuidance(response) {
|
|
29
|
+
if (response?.status !== "unavailable") return null;
|
|
30
|
+
const assumptions = record(response.assumptions);
|
|
31
|
+
if (assumptions.availability_code !== "symbol_not_covered") return null;
|
|
32
|
+
const request = record(response.request);
|
|
33
|
+
const symbol = typeof request.symbol === "string" ? request.symbol : null;
|
|
34
|
+
if (!symbol) return null;
|
|
35
|
+
const suggestedSymbol = typeof assumptions.suggested_symbol === "string"
|
|
36
|
+
? assumptions.suggested_symbol.toUpperCase()
|
|
37
|
+
: null;
|
|
38
|
+
return { symbol, suggestedSymbol };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function formatUnavailableSymbolGuidance(response, colorEnabled) {
|
|
42
|
+
const guidance = unavailableSymbolGuidance(response);
|
|
43
|
+
if (!guidance) return null;
|
|
44
|
+
return [
|
|
45
|
+
`${style("✕", ["bold", "red"], colorEnabled)} ${style(`${guidance.symbol} is not currently covered by Leroy.`, ["white"], colorEnabled)}`,
|
|
46
|
+
...(guidance.suggestedSymbol ? [
|
|
47
|
+
"",
|
|
48
|
+
` ${style(`Did you mean ${guidance.suggestedSymbol}?`, ["white"], colorEnabled)}`,
|
|
49
|
+
` ${color(`Retry: leroy evaluate ${guidance.suggestedSymbol}`, "neutral", colorEnabled)}`,
|
|
50
|
+
] : []),
|
|
51
|
+
].join("\n");
|
|
52
|
+
}
|
|
53
|
+
|
|
28
54
|
function finite(value) {
|
|
29
55
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
30
56
|
}
|
|
@@ -586,6 +612,8 @@ function formatGridEvaluation(response, { colorEnabled = true } = {}) {
|
|
|
586
612
|
}
|
|
587
613
|
|
|
588
614
|
export function formatEvaluation(response, { colorEnabled = true, setup = false, verbose = false, compact = false, layout = "ledger" } = {}) {
|
|
615
|
+
const unavailableSymbol = formatUnavailableSymbolGuidance(response, colorEnabled);
|
|
616
|
+
if (unavailableSymbol) return unavailableSymbol;
|
|
589
617
|
if (layout === "grid") {
|
|
590
618
|
const { status } = memoryStatus(response);
|
|
591
619
|
return status === "artifact_unavailable"
|
package/src/live-ui.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { stdin as processInput, stdout as processOutput } from "node:process";
|
|
2
2
|
|
|
3
3
|
import { ansiForeground, LEROY_COLORS } from "./colors.mjs";
|
|
4
|
-
import { buildEvaluationViewModel } from "./format.mjs";
|
|
4
|
+
import { buildEvaluationViewModel, unavailableSymbolGuidance } from "./format.mjs";
|
|
5
5
|
|
|
6
6
|
const MAX_CARD_WIDTH = 67;
|
|
7
7
|
const MIN_CARD_WIDTH = 64;
|
|
@@ -366,6 +366,24 @@ export function renderEvidenceView(response, { colorEnabled = true, columns = 80
|
|
|
366
366
|
? new Date(updatedAt).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })
|
|
367
367
|
: "—";
|
|
368
368
|
const liveTone = phase === "error" ? "red" : phase === "checking" ? "yellow" : "green";
|
|
369
|
+
const unavailableGuidance = unavailableSymbolGuidance(response);
|
|
370
|
+
if (unavailableGuidance) {
|
|
371
|
+
const lines = renderLoadingSteps({
|
|
372
|
+
symbol: unavailableGuidance.symbol,
|
|
373
|
+
progress,
|
|
374
|
+
colorEnabled,
|
|
375
|
+
columns,
|
|
376
|
+
}).split("\n");
|
|
377
|
+
lines.push("");
|
|
378
|
+
lines.push(`${layout.padding}${tone("✕", "red", colorEnabled, true)} ${tone(`${unavailableGuidance.symbol} is not currently covered by Leroy.`, "white", colorEnabled)}`);
|
|
379
|
+
if (unavailableGuidance.suggestedSymbol) {
|
|
380
|
+
lines.push("");
|
|
381
|
+
lines.push(`${layout.padding} ${tone(`Did you mean ${unavailableGuidance.suggestedSymbol}?`, "white", colorEnabled)}`);
|
|
382
|
+
lines.push(`${layout.padding} ${tone(`Retry: leroy evaluate ${unavailableGuidance.suggestedSymbol}`, "neutral", colorEnabled)}`);
|
|
383
|
+
}
|
|
384
|
+
lines.push("", "");
|
|
385
|
+
return lines.join("\n");
|
|
386
|
+
}
|
|
369
387
|
if (view.status === "artifact_unavailable") {
|
|
370
388
|
const lines = ["", ""];
|
|
371
389
|
lines.push(`${layout.padding}${tone("!", liveTone, colorEnabled, true)} ${tone("Market Memory unavailable", "white", colorEnabled)}`);
|