toolcraft 0.0.18 → 0.0.20
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/cli.js +32 -34
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +3 -3
- package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.d.ts +3 -3
- package/node_modules/@poe-code/config-mutations/dist/template/render.d.ts +0 -1
- package/node_modules/@poe-code/config-mutations/dist/template/render.js +2 -22
- package/node_modules/@poe-code/config-mutations/package.json +1 -4
- package/node_modules/@poe-code/design-system/dist/acp/components.js +15 -13
- package/node_modules/@poe-code/design-system/dist/components/color.d.ts +31 -0
- package/node_modules/@poe-code/design-system/dist/components/color.js +101 -0
- package/node_modules/@poe-code/design-system/dist/components/index.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/components/index.js +2 -0
- package/node_modules/@poe-code/design-system/dist/components/logger.js +2 -2
- package/node_modules/@poe-code/design-system/dist/components/symbols.js +3 -3
- package/node_modules/@poe-code/design-system/dist/components/table.js +191 -40
- package/node_modules/@poe-code/design-system/dist/components/template.d.ts +6 -0
- package/node_modules/@poe-code/design-system/dist/components/template.js +271 -0
- package/node_modules/@poe-code/design-system/dist/components/text.js +3 -3
- package/node_modules/@poe-code/design-system/dist/dashboard/buffer.js +12 -12
- package/node_modules/@poe-code/design-system/dist/index.d.ts +4 -0
- package/node_modules/@poe-code/design-system/dist/index.js +2 -0
- package/node_modules/@poe-code/design-system/dist/internal/color-support.d.ts +9 -0
- package/node_modules/@poe-code/design-system/dist/internal/color-support.js +12 -0
- package/node_modules/@poe-code/design-system/dist/prompts/index.d.ts +1 -1
- package/node_modules/@poe-code/design-system/dist/prompts/index.js +5 -4
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/cancel.js +2 -2
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/intro.js +2 -2
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/log.js +4 -4
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/note.js +5 -5
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/outro.js +2 -2
- package/node_modules/@poe-code/design-system/dist/prompts/primitives/spinner.js +3 -3
- package/node_modules/@poe-code/design-system/dist/static/menu.js +5 -5
- package/node_modules/@poe-code/design-system/dist/static/spinner.js +8 -8
- package/node_modules/@poe-code/design-system/dist/tokens/colors.js +29 -29
- package/node_modules/@poe-code/design-system/dist/tokens/typography.js +6 -6
- package/node_modules/@poe-code/design-system/package.json +5 -3
- package/package.json +2 -5
package/dist/cli.js
CHANGED
|
@@ -942,28 +942,16 @@ function formatCommandRows(group, scope, casing, globalLongOptionFlags) {
|
|
|
942
942
|
description: child.description ?? ""
|
|
943
943
|
}));
|
|
944
944
|
}
|
|
945
|
-
function
|
|
946
|
-
const
|
|
945
|
+
function formatGlobalOptionsLine(ctx) {
|
|
946
|
+
const flags = [];
|
|
947
947
|
if (ctx.presetsEnabled) {
|
|
948
|
-
|
|
949
|
-
flags: "--preset <path>",
|
|
950
|
-
description: "Load parameter defaults from a JSON file"
|
|
951
|
-
});
|
|
948
|
+
flags.push("--preset <path>");
|
|
952
949
|
}
|
|
953
|
-
|
|
954
|
-
flags: "--yes",
|
|
955
|
-
description: "Accept defaults, skip prompts"
|
|
956
|
-
}, {
|
|
957
|
-
flags: "--output <format>",
|
|
958
|
-
description: "Output format: rich, md, json."
|
|
959
|
-
});
|
|
950
|
+
flags.push("--yes", "--output <format>");
|
|
960
951
|
if (ctx.showVersion) {
|
|
961
|
-
|
|
962
|
-
flags: "--version",
|
|
963
|
-
description: "Show version"
|
|
964
|
-
});
|
|
952
|
+
flags.push("--version");
|
|
965
953
|
}
|
|
966
|
-
return
|
|
954
|
+
return `${text.section("Options:")} ${flags.join(" ")}`;
|
|
967
955
|
}
|
|
968
956
|
function collectSchemaGlobalFieldRows(group, scope, casing, globalLongOptionFlags) {
|
|
969
957
|
const seen = new Map();
|
|
@@ -1023,11 +1011,14 @@ function renderGroupHelp(group, breadcrumb, scope, casing, globalOptions, rootUs
|
|
|
1023
1011
|
sections.push(`${text.sectionHeader("Commands")}\n${formatHelpCommandList(commandRows)}`);
|
|
1024
1012
|
}
|
|
1025
1013
|
if (isRoot) {
|
|
1026
|
-
const
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1014
|
+
const schemaGlobalRows = collectSchemaGlobalFieldRows(group, scope, casing, globalLongOptionFlags);
|
|
1015
|
+
const builtInLine = formatGlobalOptionsLine(globalOptions);
|
|
1016
|
+
if (schemaGlobalRows.length > 0) {
|
|
1017
|
+
sections.push(`${text.sectionHeader("Options")}\n${formatHelpOptionList(schemaGlobalRows)}\n${builtInLine}`);
|
|
1018
|
+
}
|
|
1019
|
+
else {
|
|
1020
|
+
sections.push(builtInLine);
|
|
1021
|
+
}
|
|
1031
1022
|
}
|
|
1032
1023
|
return renderHelpDocument({
|
|
1033
1024
|
breadcrumb,
|
|
@@ -1177,12 +1168,12 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
|
|
|
1177
1168
|
return group;
|
|
1178
1169
|
}
|
|
1179
1170
|
function addGlobalOptions(command, presetsEnabled) {
|
|
1171
|
+
const options = [];
|
|
1180
1172
|
if (presetsEnabled) {
|
|
1181
|
-
|
|
1173
|
+
options.push(new Option("--preset <path>", "Load parameter defaults from a JSON file."));
|
|
1182
1174
|
}
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
.option("--output <format>", "Output format.", (value) => {
|
|
1175
|
+
options.push(new Option("--yes", "Accept defaults and skip prompts."));
|
|
1176
|
+
options.push(new Option("--output <format>", "Output format.").argParser((value) => {
|
|
1186
1177
|
if (value === "rich" || value === "md" || value === "json") {
|
|
1187
1178
|
return value;
|
|
1188
1179
|
}
|
|
@@ -1193,11 +1184,15 @@ function addGlobalOptions(command, presetsEnabled) {
|
|
|
1193
1184
|
candidates: ["rich", "markdown", "json"],
|
|
1194
1185
|
threshold: 3
|
|
1195
1186
|
}));
|
|
1196
|
-
})
|
|
1197
|
-
|
|
1187
|
+
}));
|
|
1188
|
+
options.push(new Option("--debug [mode]", "Print stack traces for unexpected errors.")
|
|
1198
1189
|
.preset("trim")
|
|
1199
|
-
.argParser(parseDebugStackMode))
|
|
1200
|
-
|
|
1190
|
+
.argParser(parseDebugStackMode));
|
|
1191
|
+
options.push(new Option("--verbose", "Print detailed runtime diagnostics."));
|
|
1192
|
+
for (const option of options) {
|
|
1193
|
+
option.hideHelp(true);
|
|
1194
|
+
command.addOption(option);
|
|
1195
|
+
}
|
|
1201
1196
|
}
|
|
1202
1197
|
function parseDebugStackMode(value) {
|
|
1203
1198
|
if (value === true || value === "trim") {
|
|
@@ -1235,6 +1230,9 @@ function formatResolvedValue(value) {
|
|
|
1235
1230
|
}
|
|
1236
1231
|
return JSON.stringify(value);
|
|
1237
1232
|
}
|
|
1233
|
+
function fieldPromptLabel(field) {
|
|
1234
|
+
return field.positionalIndex === undefined ? field.optionFlag : `<${field.displayPath}>`;
|
|
1235
|
+
}
|
|
1238
1236
|
async function promptForField(field) {
|
|
1239
1237
|
const schema = field.schema;
|
|
1240
1238
|
if (schema.kind === "enum") {
|
|
@@ -1245,7 +1243,7 @@ async function promptForField(field) {
|
|
|
1245
1243
|
value
|
|
1246
1244
|
}));
|
|
1247
1245
|
const selected = await select({
|
|
1248
|
-
message: field.description ?? field
|
|
1246
|
+
message: field.description ?? fieldPromptLabel(field),
|
|
1249
1247
|
options,
|
|
1250
1248
|
initialValue: field.hasDefault ? field.defaultValue : undefined
|
|
1251
1249
|
});
|
|
@@ -1257,7 +1255,7 @@ async function promptForField(field) {
|
|
|
1257
1255
|
}
|
|
1258
1256
|
if (field.schema.kind === "boolean") {
|
|
1259
1257
|
const selected = await confirm({
|
|
1260
|
-
message: field
|
|
1258
|
+
message: fieldPromptLabel(field),
|
|
1261
1259
|
initialValue: field.hasDefault ? Boolean(field.defaultValue) : undefined
|
|
1262
1260
|
});
|
|
1263
1261
|
if (isCancel(selected)) {
|
|
@@ -1267,7 +1265,7 @@ async function promptForField(field) {
|
|
|
1267
1265
|
return selected;
|
|
1268
1266
|
}
|
|
1269
1267
|
const entered = await promptText({
|
|
1270
|
-
message: field
|
|
1268
|
+
message: fieldPromptLabel(field),
|
|
1271
1269
|
initialValue: field.hasDefault && field.defaultValue !== undefined
|
|
1272
1270
|
? formatResolvedValue(field.defaultValue)
|
|
1273
1271
|
: undefined
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { renderTemplate } from "@poe-code/design-system";
|
|
2
2
|
import { getConfigFormat, detectFormat } from "../formats/index.js";
|
|
3
3
|
import { resolvePath } from "./path-utils.js";
|
|
4
4
|
import { isNotFound, readFileIfExists, pathExists, createTimestamp } from "../fs-utils.js";
|
|
@@ -481,7 +481,7 @@ async function applyTemplateWrite(mutation, context, options) {
|
|
|
481
481
|
const templateContext = mutation.context
|
|
482
482
|
? resolveValue(mutation.context, options)
|
|
483
483
|
: {};
|
|
484
|
-
const rendered =
|
|
484
|
+
const rendered = renderTemplate(template, templateContext);
|
|
485
485
|
const existed = await pathExists(context.fs, targetPath);
|
|
486
486
|
if (!context.dryRun) {
|
|
487
487
|
await context.fs.writeFile(targetPath, rendered, { encoding: "utf8" });
|
|
@@ -513,7 +513,7 @@ async function applyTemplateMerge(mutation, context, options, formatName) {
|
|
|
513
513
|
const templateContext = mutation.context
|
|
514
514
|
? resolveValue(mutation.context, options)
|
|
515
515
|
: {};
|
|
516
|
-
const rendered =
|
|
516
|
+
const rendered = renderTemplate(template, templateContext);
|
|
517
517
|
// Parse rendered template
|
|
518
518
|
let templateDoc;
|
|
519
519
|
try {
|
|
@@ -4,7 +4,7 @@ export interface WriteOptions {
|
|
|
4
4
|
target: ValueResolver<string>;
|
|
5
5
|
/** Template ID to load via template loader */
|
|
6
6
|
templateId: string;
|
|
7
|
-
/** Context to pass to
|
|
7
|
+
/** Context to pass to renderTemplate() */
|
|
8
8
|
context?: ValueResolver<ConfigObject>;
|
|
9
9
|
/** Optional human-readable label for logging */
|
|
10
10
|
label?: string;
|
|
@@ -14,7 +14,7 @@ export interface MergeTomlOptions {
|
|
|
14
14
|
target: ValueResolver<string>;
|
|
15
15
|
/** Template ID to load via template loader */
|
|
16
16
|
templateId: string;
|
|
17
|
-
/** Context to pass to
|
|
17
|
+
/** Context to pass to renderTemplate() */
|
|
18
18
|
context?: ValueResolver<ConfigObject>;
|
|
19
19
|
/** Optional human-readable label for logging */
|
|
20
20
|
label?: string;
|
|
@@ -24,7 +24,7 @@ export interface MergeJsonOptions {
|
|
|
24
24
|
target: ValueResolver<string>;
|
|
25
25
|
/** Template ID to load via template loader */
|
|
26
26
|
templateId: string;
|
|
27
|
-
/** Context to pass to
|
|
27
|
+
/** Context to pass to renderTemplate() */
|
|
28
28
|
context?: ValueResolver<ConfigObject>;
|
|
29
29
|
/** Optional human-readable label for logging */
|
|
30
30
|
label?: string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export type TemplateVariables = Record<string, string | number | boolean | string[]>;
|
|
2
2
|
/**
|
|
3
3
|
* Render a mustache template with the given variables.
|
|
4
|
-
* Arrays are automatically joined with newlines.
|
|
5
4
|
* HTML escaping is disabled.
|
|
6
5
|
*/
|
|
7
6
|
export declare function renderTemplate(template: string, variables: TemplateVariables): string;
|
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
// Disable HTML escaping - we're rendering prompts, not HTML
|
|
3
|
-
const originalEscape = Mustache.escape;
|
|
1
|
+
import { renderTemplate as renderDesignTemplate } from "@poe-code/design-system";
|
|
4
2
|
/**
|
|
5
3
|
* Render a mustache template with the given variables.
|
|
6
|
-
* Arrays are automatically joined with newlines.
|
|
7
4
|
* HTML escaping is disabled.
|
|
8
5
|
*/
|
|
9
6
|
export function renderTemplate(template, variables) {
|
|
10
|
-
|
|
11
|
-
const processed = {};
|
|
12
|
-
for (const [key, value] of Object.entries(variables)) {
|
|
13
|
-
if (Array.isArray(value)) {
|
|
14
|
-
processed[key] = value.join("\n");
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
processed[key] = value;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
// Temporarily disable HTML escaping
|
|
21
|
-
Mustache.escape = (text) => text;
|
|
22
|
-
try {
|
|
23
|
-
return Mustache.render(template, processed);
|
|
24
|
-
}
|
|
25
|
-
finally {
|
|
26
|
-
Mustache.escape = originalEscape;
|
|
27
|
-
}
|
|
7
|
+
return renderDesignTemplate(template, variables, { escape: "none" });
|
|
28
8
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { color } from "../components/color.js";
|
|
2
2
|
import { resolveOutputFormat } from "../internal/output-format.js";
|
|
3
3
|
import { renderMarkdown } from "../terminal-markdown/index.js";
|
|
4
4
|
import { getAcpWriter } from "./writer.js";
|
|
@@ -10,20 +10,22 @@ function truncate(text, maxLength) {
|
|
|
10
10
|
return `${text.slice(0, maxLength - 3)}...`;
|
|
11
11
|
}
|
|
12
12
|
const KIND_COLORS = {
|
|
13
|
-
exec: (text) =>
|
|
14
|
-
edit: (text) =>
|
|
15
|
-
read: (text) =>
|
|
16
|
-
search: (text) =>
|
|
17
|
-
think: (text) =>
|
|
18
|
-
other: (text) =>
|
|
13
|
+
exec: (text) => color.yellow(text),
|
|
14
|
+
edit: (text) => color.magenta(text),
|
|
15
|
+
read: (text) => color.cyan(text),
|
|
16
|
+
search: (text) => color.blue(text),
|
|
17
|
+
think: (text) => color.dim(text),
|
|
18
|
+
other: (text) => color.dim(text)
|
|
19
19
|
};
|
|
20
20
|
function colorForKind(kind) {
|
|
21
|
-
return KIND_COLORS[kind] ?? ((text) =>
|
|
21
|
+
return KIND_COLORS[kind] ?? ((text) => color.dim(text));
|
|
22
22
|
}
|
|
23
23
|
function writeLine(line) {
|
|
24
24
|
getAcpWriter()(line);
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
function agentPrefix() {
|
|
27
|
+
return `${color.green.bold("✓")} agent: `;
|
|
28
|
+
}
|
|
27
29
|
function formatCost(costUsd) {
|
|
28
30
|
return new Intl.NumberFormat("en-US", {
|
|
29
31
|
style: "currency",
|
|
@@ -43,7 +45,7 @@ export function renderAgentMessage(text) {
|
|
|
43
45
|
return;
|
|
44
46
|
}
|
|
45
47
|
const rendered = renderMarkdown(text).trimEnd();
|
|
46
|
-
writeLine(`${
|
|
48
|
+
writeLine(`${agentPrefix()}${rendered}`);
|
|
47
49
|
}
|
|
48
50
|
export function renderToolStart(kind, title) {
|
|
49
51
|
const format = resolveOutputFormat();
|
|
@@ -81,7 +83,7 @@ export function renderReasoning(text) {
|
|
|
81
83
|
writeLine(JSON.stringify({ event: "reasoning", text }));
|
|
82
84
|
return;
|
|
83
85
|
}
|
|
84
|
-
writeLine(
|
|
86
|
+
writeLine(color.dim(` ✓ ${truncate(text, 80)}`));
|
|
85
87
|
}
|
|
86
88
|
export function renderUsage(tokens) {
|
|
87
89
|
const format = resolveOutputFormat();
|
|
@@ -105,7 +107,7 @@ export function renderUsage(tokens) {
|
|
|
105
107
|
return;
|
|
106
108
|
}
|
|
107
109
|
writeLine("");
|
|
108
|
-
writeLine(
|
|
110
|
+
writeLine(color.green(`✓ tokens: ${tokens.input} in${cached} → ${tokens.output} out${cost}`));
|
|
109
111
|
}
|
|
110
112
|
export function renderError(message) {
|
|
111
113
|
const format = resolveOutputFormat();
|
|
@@ -117,5 +119,5 @@ export function renderError(message) {
|
|
|
117
119
|
writeLine(JSON.stringify({ event: "error", message }));
|
|
118
120
|
return;
|
|
119
121
|
}
|
|
120
|
-
writeLine(
|
|
122
|
+
writeLine(color.red(`✗ ${message}`));
|
|
121
123
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface Color {
|
|
2
|
+
(text: string): string;
|
|
3
|
+
reset: Color;
|
|
4
|
+
bold: Color;
|
|
5
|
+
dim: Color;
|
|
6
|
+
italic: Color;
|
|
7
|
+
underline: Color;
|
|
8
|
+
inverse: Color;
|
|
9
|
+
strikethrough: Color;
|
|
10
|
+
black: Color;
|
|
11
|
+
red: Color;
|
|
12
|
+
green: Color;
|
|
13
|
+
yellow: Color;
|
|
14
|
+
blue: Color;
|
|
15
|
+
magenta: Color;
|
|
16
|
+
cyan: Color;
|
|
17
|
+
white: Color;
|
|
18
|
+
gray: Color;
|
|
19
|
+
magentaBright: Color;
|
|
20
|
+
cyanBright: Color;
|
|
21
|
+
bgRed: Color;
|
|
22
|
+
bgGreen: Color;
|
|
23
|
+
bgYellow: Color;
|
|
24
|
+
bgBlue: Color;
|
|
25
|
+
bgMagenta: Color;
|
|
26
|
+
hex: (value: string) => Color;
|
|
27
|
+
rgb: (red: number, green: number, blue: number) => Color;
|
|
28
|
+
bgHex: (value: string) => Color;
|
|
29
|
+
bgRgb: (red: number, green: number, blue: number) => Color;
|
|
30
|
+
}
|
|
31
|
+
export declare const color: Color;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { supportsColor } from "../internal/color-support.js";
|
|
2
|
+
const reset = "\x1b[0m";
|
|
3
|
+
const ansiStyles = {
|
|
4
|
+
reset: { open: reset },
|
|
5
|
+
bold: { open: "\x1b[1m" },
|
|
6
|
+
dim: { open: "\x1b[2m" },
|
|
7
|
+
italic: { open: "\x1b[3m" },
|
|
8
|
+
underline: { open: "\x1b[4m" },
|
|
9
|
+
inverse: { open: "\x1b[7m" },
|
|
10
|
+
strikethrough: { open: "\x1b[9m" },
|
|
11
|
+
black: { open: "\x1b[30m" },
|
|
12
|
+
red: { open: "\x1b[31m" },
|
|
13
|
+
green: { open: "\x1b[32m" },
|
|
14
|
+
yellow: { open: "\x1b[33m" },
|
|
15
|
+
blue: { open: "\x1b[34m" },
|
|
16
|
+
magenta: { open: "\x1b[35m" },
|
|
17
|
+
cyan: { open: "\x1b[36m" },
|
|
18
|
+
white: { open: "\x1b[37m" },
|
|
19
|
+
gray: { open: "\x1b[90m" },
|
|
20
|
+
magentaBright: { open: "\x1b[95m" },
|
|
21
|
+
cyanBright: { open: "\x1b[96m" },
|
|
22
|
+
bgRed: { open: "\x1b[41m" },
|
|
23
|
+
bgGreen: { open: "\x1b[42m" },
|
|
24
|
+
bgYellow: { open: "\x1b[43m" },
|
|
25
|
+
bgBlue: { open: "\x1b[44m" },
|
|
26
|
+
bgMagenta: { open: "\x1b[45m" }
|
|
27
|
+
};
|
|
28
|
+
const styleNames = Object.keys(ansiStyles);
|
|
29
|
+
function replaceAll(value, search, replacement) {
|
|
30
|
+
return value.split(search).join(replacement);
|
|
31
|
+
}
|
|
32
|
+
function applyStyles(text, styles) {
|
|
33
|
+
if (!supportsColor() || styles.length === 0) {
|
|
34
|
+
return text;
|
|
35
|
+
}
|
|
36
|
+
const open = styles.map((style) => style.open).join("");
|
|
37
|
+
const output = text.includes(reset) ? replaceAll(text, reset, `${reset}${open}`) : text;
|
|
38
|
+
return `${open}${output}${reset}`;
|
|
39
|
+
}
|
|
40
|
+
function clampRgb(value) {
|
|
41
|
+
if (Number.isNaN(value)) {
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
return Math.min(255, Math.max(0, Math.round(value)));
|
|
45
|
+
}
|
|
46
|
+
function hexChannel(value, offset) {
|
|
47
|
+
return Number.parseInt(value.slice(offset, offset + 2), 16);
|
|
48
|
+
}
|
|
49
|
+
function normalizeHex(value) {
|
|
50
|
+
const normalized = value.startsWith("#") ? value.slice(1) : value;
|
|
51
|
+
if (normalized.length === 3) {
|
|
52
|
+
const red = normalized[0];
|
|
53
|
+
const green = normalized[1];
|
|
54
|
+
const blue = normalized[2];
|
|
55
|
+
return [
|
|
56
|
+
Number.parseInt(`${red}${red}`, 16),
|
|
57
|
+
Number.parseInt(`${green}${green}`, 16),
|
|
58
|
+
Number.parseInt(`${blue}${blue}`, 16)
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
if (normalized.length === 6) {
|
|
62
|
+
return [
|
|
63
|
+
hexChannel(normalized, 0),
|
|
64
|
+
hexChannel(normalized, 2),
|
|
65
|
+
hexChannel(normalized, 4)
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
return [0, 0, 0];
|
|
69
|
+
}
|
|
70
|
+
function rgbStyle(red, green, blue) {
|
|
71
|
+
return {
|
|
72
|
+
open: `\x1b[38;2;${clampRgb(red)};${clampRgb(green)};${clampRgb(blue)}m`
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function bgRgbStyle(red, green, blue) {
|
|
76
|
+
return {
|
|
77
|
+
open: `\x1b[48;2;${clampRgb(red)};${clampRgb(green)};${clampRgb(blue)}m`
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function createColor(styles = []) {
|
|
81
|
+
const builder = ((text) => applyStyles(String(text), styles));
|
|
82
|
+
for (const name of styleNames) {
|
|
83
|
+
Object.defineProperty(builder, name, {
|
|
84
|
+
configurable: true,
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: () => createColor([...styles, ansiStyles[name]])
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
builder.hex = (value) => {
|
|
90
|
+
const [red, green, blue] = normalizeHex(value);
|
|
91
|
+
return createColor([...styles, rgbStyle(red, green, blue)]);
|
|
92
|
+
};
|
|
93
|
+
builder.rgb = (red, green, blue) => createColor([...styles, rgbStyle(red, green, blue)]);
|
|
94
|
+
builder.bgHex = (value) => {
|
|
95
|
+
const [red, green, blue] = normalizeHex(value);
|
|
96
|
+
return createColor([...styles, bgRgbStyle(red, green, blue)]);
|
|
97
|
+
};
|
|
98
|
+
builder.bgRgb = (red, green, blue) => createColor([...styles, bgRgbStyle(red, green, blue)]);
|
|
99
|
+
return builder;
|
|
100
|
+
}
|
|
101
|
+
export const color = createColor();
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { text } from "./text.js";
|
|
2
|
+
export { color } from "./color.js";
|
|
3
|
+
export type { Color } from "./color.js";
|
|
2
4
|
export { symbols } from "./symbols.js";
|
|
3
5
|
export { createLogger, logger } from "./logger.js";
|
|
4
6
|
export type { LoggerOutput } from "./logger.js";
|
|
@@ -8,3 +10,5 @@ export { formatCommandNotFound } from "./command-errors.js";
|
|
|
8
10
|
export { formatCommandNotFoundPanel } from "./command-errors.js";
|
|
9
11
|
export { renderTable } from "./table.js";
|
|
10
12
|
export type { TableColumn, RenderTableOptions } from "./table.js";
|
|
13
|
+
export { renderTemplate } from "./template.js";
|
|
14
|
+
export type { RenderTemplateOptions, TemplateEscape } from "./template.js";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { text } from "./text.js";
|
|
2
|
+
export { color } from "./color.js";
|
|
2
3
|
export { symbols } from "./symbols.js";
|
|
3
4
|
export { createLogger, logger } from "./logger.js";
|
|
4
5
|
export { helpFormatter, formatColumns, formatCommand, formatUsage, formatOption, formatCommandList, formatOptionList } from "./help-formatter.js";
|
|
5
6
|
export { formatCommandNotFound } from "./command-errors.js";
|
|
6
7
|
export { formatCommandNotFoundPanel } from "./command-errors.js";
|
|
7
8
|
export { renderTable } from "./table.js";
|
|
9
|
+
export { renderTemplate } from "./template.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { color } from "./color.js";
|
|
2
2
|
import { log } from "../prompts/primitives/log.js";
|
|
3
3
|
import { symbols } from "./symbols.js";
|
|
4
4
|
export function createLogger(emitter) {
|
|
@@ -53,7 +53,7 @@ export function createLogger(emitter) {
|
|
|
53
53
|
emitter(message);
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
log.message(message, { symbol: symbol ??
|
|
56
|
+
log.message(message, { symbol: symbol ?? color.gray("│") });
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { color } from "./color.js";
|
|
2
2
|
import { resolveOutputFormat } from "../internal/output-format.js";
|
|
3
3
|
import { getTheme } from "../internal/theme-detect.js";
|
|
4
4
|
export const symbols = {
|
|
@@ -8,7 +8,7 @@ export const symbols = {
|
|
|
8
8
|
return "info";
|
|
9
9
|
if (format === "markdown")
|
|
10
10
|
return "(i)";
|
|
11
|
-
return
|
|
11
|
+
return color.magenta("●");
|
|
12
12
|
},
|
|
13
13
|
get success() {
|
|
14
14
|
const format = resolveOutputFormat();
|
|
@@ -16,7 +16,7 @@ export const symbols = {
|
|
|
16
16
|
return "success";
|
|
17
17
|
if (format === "markdown")
|
|
18
18
|
return "[ok]";
|
|
19
|
-
return
|
|
19
|
+
return color.magenta("◆");
|
|
20
20
|
},
|
|
21
21
|
get resolved() {
|
|
22
22
|
const format = resolveOutputFormat();
|