kfc-code-cli 0.0.1-alpha.10 → 0.0.1-alpha.11

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.
Files changed (2) hide show
  1. package/dist/main.mjs +126 -22
  2. package/package.json +1 -1
package/dist/main.mjs CHANGED
@@ -95697,6 +95697,121 @@ function strArg(args, ...keys) {
95697
95697
  return "";
95698
95698
  }
95699
95699
  //#endregion
95700
+ //#region src/tui/components/messages/tool-renderers/truncated.ts
95701
+ const renderTruncated = (_toolCall, result, ctx) => {
95702
+ if (!result.output) return [];
95703
+ const tint = result.is_error ? chalk.hex(ctx.colors.error) : chalk.dim;
95704
+ const lines = result.output.split("\n");
95705
+ if (ctx.expanded) return [new Text(tint(result.output), 2, 0)];
95706
+ const shown = lines.slice(0, 3);
95707
+ const remaining = lines.length - shown.length;
95708
+ const out = [new Text(tint(shown.join("\n")), 2, 0)];
95709
+ if (remaining > 0) out.push(new Text(chalk.dim(`... (${String(remaining)} more lines, ctrl+o to expand)`), 2, 0));
95710
+ return out;
95711
+ };
95712
+ //#endregion
95713
+ //#region src/tui/components/messages/tool-renderers/media.ts
95714
+ const PATH_TAG_RE = /^<(image|video)\s+path="([^"]+)">$/;
95715
+ const ORIGINAL_SIZE_RE = /original size\s+(\d+x\d+px)/;
95716
+ const DATA_URL_RE = /^data:([^;]+);base64,(.*)$/s;
95717
+ function bytesFromBase64(b64) {
95718
+ const len = b64.length;
95719
+ if (len === 0) return 0;
95720
+ const padding = b64.endsWith("==") ? 2 : b64.endsWith("=") ? 1 : 0;
95721
+ return Math.floor(len * 3 / 4) - padding;
95722
+ }
95723
+ function parseReadMediaOutput(output) {
95724
+ let parsed;
95725
+ try {
95726
+ parsed = JSON.parse(output);
95727
+ } catch {
95728
+ return null;
95729
+ }
95730
+ if (!Array.isArray(parsed)) return null;
95731
+ let kind;
95732
+ let path;
95733
+ let mimeType;
95734
+ let bytes;
95735
+ let url;
95736
+ let originalSize;
95737
+ let foundMedia = false;
95738
+ for (const raw of parsed) {
95739
+ if (typeof raw !== "object" || raw === null) continue;
95740
+ const part = raw;
95741
+ const type = part["type"];
95742
+ if (type === "text" && typeof part["text"] === "string") {
95743
+ const text = part["text"];
95744
+ const tag = PATH_TAG_RE.exec(text);
95745
+ if (tag) {
95746
+ kind = tag[1];
95747
+ path = tag[2];
95748
+ continue;
95749
+ }
95750
+ const size = ORIGINAL_SIZE_RE.exec(text);
95751
+ if (size) originalSize = size[1];
95752
+ continue;
95753
+ }
95754
+ if (type === "image_url" || type === "video_url") {
95755
+ foundMedia = true;
95756
+ kind = type === "image_url" ? "image" : "video";
95757
+ const holder = part[type === "image_url" ? "imageUrl" : "videoUrl"];
95758
+ if (typeof holder === "object" && holder !== null) {
95759
+ const u = holder["url"];
95760
+ if (typeof u === "string") {
95761
+ const data = DATA_URL_RE.exec(u);
95762
+ if (data && data[1] !== void 0 && data[2] !== void 0) {
95763
+ mimeType = data[1];
95764
+ bytes = bytesFromBase64(data[2]);
95765
+ } else url = u;
95766
+ }
95767
+ }
95768
+ }
95769
+ }
95770
+ if (!foundMedia || kind === void 0) return null;
95771
+ const summary = { kind };
95772
+ if (path !== void 0) summary.path = path;
95773
+ if (mimeType !== void 0) summary.mimeType = mimeType;
95774
+ if (bytes !== void 0) summary.bytes = bytes;
95775
+ if (url !== void 0) summary.url = url;
95776
+ if (originalSize !== void 0) summary.originalSize = originalSize;
95777
+ return summary;
95778
+ }
95779
+ function formatBytes$1(bytes) {
95780
+ if (bytes < 1024) return `${String(bytes)} B`;
95781
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
95782
+ return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
95783
+ }
95784
+ function metaSegments(summary) {
95785
+ const segs = [];
95786
+ if (summary.mimeType !== void 0) segs.push(summary.mimeType);
95787
+ if (summary.bytes !== void 0) segs.push(formatBytes$1(summary.bytes));
95788
+ if (summary.originalSize !== void 0) segs.push(summary.originalSize);
95789
+ return segs;
95790
+ }
95791
+ const readMediaChip = (_toolCall, result) => {
95792
+ if (result.is_error) return "";
95793
+ const summary = parseReadMediaOutput(result.output);
95794
+ if (summary === null) return "";
95795
+ const meta = metaSegments(summary);
95796
+ if (meta.length === 0) return summary.url !== void 0 ? `${summary.kind} · uploaded` : summary.kind;
95797
+ return `${summary.kind} (${meta.join(", ")})`;
95798
+ };
95799
+ const readMediaSummary = (toolCall, result, ctx) => {
95800
+ if (result.is_error) return renderTruncated(toolCall, result, ctx);
95801
+ const summary = parseReadMediaOutput(result.output);
95802
+ if (summary === null) return renderTruncated(toolCall, result, ctx);
95803
+ if (!ctx.expanded) return [];
95804
+ const dim = chalk.dim;
95805
+ const out = [];
95806
+ if (summary.path !== void 0) out.push(new Text(` ${dim(summary.path)}`, 0, 0));
95807
+ const meta = metaSegments(summary);
95808
+ const tail = [summary.kind];
95809
+ if (meta.length > 0) tail.push(meta.join(", "));
95810
+ if (summary.url !== void 0) tail.push(summary.url);
95811
+ out.push(new Text(` ${dim(tail.join(" · "))}`, 0, 0));
95812
+ return out;
95813
+ };
95814
+ //#endregion
95700
95815
  //#region src/tui/components/messages/tool-renderers/chip.ts
95701
95816
  function countNonEmptyLines(text) {
95702
95817
  if (text.length === 0) return 0;
@@ -95772,6 +95887,7 @@ const REGISTRY = {
95772
95887
  Edit: editChip,
95773
95888
  Write: writeChip,
95774
95889
  Read: readChip,
95890
+ ReadMediaFile: readMediaChip,
95775
95891
  Grep: grepChip,
95776
95892
  Glob: globChip,
95777
95893
  FetchURL: fetchChip,
@@ -95781,19 +95897,6 @@ function pickChip(toolName) {
95781
95897
  return REGISTRY[toolName];
95782
95898
  }
95783
95899
  //#endregion
95784
- //#region src/tui/components/messages/tool-renderers/truncated.ts
95785
- const renderTruncated = (_toolCall, result, ctx) => {
95786
- if (!result.output) return [];
95787
- const tint = result.is_error ? chalk.hex(ctx.colors.error) : chalk.dim;
95788
- const lines = result.output.split("\n");
95789
- if (ctx.expanded) return [new Text(tint(result.output), 2, 0)];
95790
- const shown = lines.slice(0, 3);
95791
- const remaining = lines.length - shown.length;
95792
- const out = [new Text(tint(shown.join("\n")), 2, 0)];
95793
- if (remaining > 0) out.push(new Text(chalk.dim(`... (${String(remaining)} more lines, ctrl+o to expand)`), 2, 0));
95794
- return out;
95795
- };
95796
- //#endregion
95797
95900
  //#region src/tui/components/messages/tool-renderers/summary.ts
95798
95901
  const GLANCE_SAMPLES = 3;
95799
95902
  function withGlance(glance) {
@@ -95859,6 +95962,7 @@ const globSummary = withGlance(globGlance);
95859
95962
  function pickResultRenderer(toolName) {
95860
95963
  switch (toolName) {
95861
95964
  case "Read": return readSummary;
95965
+ case "ReadMediaFile": return readMediaSummary;
95862
95966
  case "Grep": return grepSummary;
95863
95967
  case "Glob": return globSummary;
95864
95968
  case "FetchURL": return fetchSummary;
@@ -95981,6 +96085,12 @@ function parseArgsPreview(value) {
95981
96085
  }
95982
96086
  return result;
95983
96087
  }
96088
+ const PATH_KEYS = new Set(["path", "file_path"]);
96089
+ function truncateArgValue(key, value) {
96090
+ if (value.length <= MAX_ARG_LENGTH) return value;
96091
+ if (PATH_KEYS.has(key)) return "…" + value.slice(value.length - (MAX_ARG_LENGTH - 1));
96092
+ return value.slice(0, MAX_ARG_LENGTH - 3) + "...";
96093
+ }
95984
96094
  function extractKeyArgument(toolName, args) {
95985
96095
  const candidates = {
95986
96096
  Bash: ["command"],
@@ -95995,10 +96105,7 @@ function extractKeyArgument(toolName, args) {
95995
96105
  }[toolName] ?? Object.keys(args);
95996
96106
  for (const key of candidates) {
95997
96107
  const val = args[key];
95998
- if (typeof val === "string" && val.length > 0) {
95999
- const firstLine = val.split("\n")[0] ?? val;
96000
- return firstLine.length <= MAX_ARG_LENGTH ? firstLine : firstLine.slice(0, MAX_ARG_LENGTH - 3) + "...";
96001
- }
96108
+ if (typeof val === "string" && val.length > 0) return truncateArgValue(key, val.split("\n")[0] ?? val);
96002
96109
  }
96003
96110
  return null;
96004
96111
  }
@@ -96274,7 +96381,6 @@ var ToolCallComponent = class extends Container {
96274
96381
  const prefix = i === 0 ? "$ " : " ";
96275
96382
  this.addChild(new Text(chalk.dim(prefix + line), 2, 0));
96276
96383
  }
96277
- return;
96278
96384
  }
96279
96385
  }
96280
96386
  buildPlanPreview() {
@@ -98817,10 +98923,7 @@ function userPartToText(part) {
98817
98923
  }
98818
98924
  function outputToText(output) {
98819
98925
  if (typeof output === "string") return output;
98820
- if (Array.isArray(output)) return output.map((part) => {
98821
- if (isObject(part) && part["type"] === "text") return stringValue(part["text"]) ?? "";
98822
- return JSON.stringify(part);
98823
- }).join("");
98926
+ if (Array.isArray(output)) return JSON.stringify(output);
98824
98927
  return output === void 0 ? "" : JSON.stringify(output);
98825
98928
  }
98826
98929
  function subToolKey(agentId, toolCallId) {
@@ -100887,6 +100990,7 @@ function headerFor(toolName) {
100887
100990
  case "Write": return "Write this file?";
100888
100991
  case "Edit": return "Apply these edits?";
100889
100992
  case "TaskStop": return "Stop this task?";
100993
+ case "ExitPlanMode": return "Ready to build with this plan?";
100890
100994
  default: return `Approve ${toolName}?`;
100891
100995
  }
100892
100996
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kfc-code-cli",
3
- "version": "0.0.1-alpha.10",
3
+ "version": "0.0.1-alpha.11",
4
4
  "description": "KFC crazy ",
5
5
  "license": "MIT",
6
6
  "bin": {