ferix-code 0.0.2-beta.14 → 0.0.2-beta.16

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/index.js +66 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -71,7 +71,7 @@ import { Command } from "commander";
71
71
  // package.json
72
72
  var package_default = {
73
73
  name: "ferix-code",
74
- version: "0.0.2-beta.14",
74
+ version: "0.0.2-beta.16",
75
75
  description: "Composable RALPH loops for AI coding agents - v2 with Effect",
76
76
  type: "module",
77
77
  bin: {
@@ -1059,32 +1059,49 @@ init_esm_shims();
1059
1059
  init_esm_shims();
1060
1060
  import pc13 from "picocolors";
1061
1061
  var brightWhite = (s) => pc13.bold(pc13.white(s));
1062
+ function normalizeToolName(tool) {
1063
+ return tool.toLowerCase();
1064
+ }
1065
+ function getInputValue(obj, key) {
1066
+ if (obj[key] !== void 0) {
1067
+ return obj[key];
1068
+ }
1069
+ const camelKey = key.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
1070
+ if (obj[camelKey] !== void 0) {
1071
+ return obj[camelKey];
1072
+ }
1073
+ const snakeKey = key.replace(/([A-Z])/g, "_$1").toLowerCase();
1074
+ if (obj[snakeKey] !== void 0) {
1075
+ return obj[snakeKey];
1076
+ }
1077
+ return void 0;
1078
+ }
1062
1079
  function createToolDisplayRegistry() {
1063
1080
  const configs = /* @__PURE__ */ new Map();
1064
1081
  const defaultColor = pc13.white;
1065
1082
  return {
1066
1083
  register(config) {
1067
- configs.set(config.tool, config);
1084
+ configs.set(normalizeToolName(config.tool), config);
1068
1085
  },
1069
1086
  getInputKey(tool) {
1070
- return configs.get(tool)?.inputKey;
1087
+ return configs.get(normalizeToolName(tool))?.inputKey;
1071
1088
  },
1072
1089
  getColor(tool) {
1073
- return configs.get(tool)?.color ?? defaultColor;
1090
+ return configs.get(normalizeToolName(tool))?.color ?? defaultColor;
1074
1091
  },
1075
1092
  getMaxLength(tool) {
1076
- return configs.get(tool)?.maxLength ?? MAX_TOOL_INPUT_LENGTH;
1093
+ return configs.get(normalizeToolName(tool))?.maxLength ?? MAX_TOOL_INPUT_LENGTH;
1077
1094
  },
1078
1095
  formatInput(tool, input) {
1079
1096
  if (!input || typeof input !== "object") {
1080
1097
  return "";
1081
1098
  }
1082
- const config = configs.get(tool);
1099
+ const config = configs.get(normalizeToolName(tool));
1083
1100
  if (!config) {
1084
1101
  return "";
1085
1102
  }
1086
1103
  const obj = input;
1087
- const value = obj[config.inputKey];
1104
+ const value = getInputValue(obj, config.inputKey);
1088
1105
  if (!value) {
1089
1106
  return "";
1090
1107
  }
@@ -4024,12 +4041,42 @@ function isTextContent2(json) {
4024
4041
  function isStepFinish(json) {
4025
4042
  return typeof json === "object" && json !== null && "type" in json && json.type === "step_finish";
4026
4043
  }
4044
+ function isToolUse2(json) {
4045
+ if (typeof json !== "object" || json === null) {
4046
+ return false;
4047
+ }
4048
+ const obj = json;
4049
+ if (obj.type !== "tool_use") {
4050
+ return false;
4051
+ }
4052
+ if (typeof obj.part !== "object" || obj.part === null) {
4053
+ return false;
4054
+ }
4055
+ const part = obj.part;
4056
+ if (typeof part.tool !== "string") {
4057
+ return false;
4058
+ }
4059
+ if (typeof part.state !== "object" || part.state === null) {
4060
+ return false;
4061
+ }
4062
+ return true;
4063
+ }
4027
4064
  function extractText2(json) {
4028
4065
  if (isTextContent2(json)) {
4029
4066
  return json.text;
4030
4067
  }
4031
4068
  return null;
4032
4069
  }
4070
+ function extractToolInfo2(json) {
4071
+ if (isToolUse2(json)) {
4072
+ return {
4073
+ type: "complete",
4074
+ name: json.part.tool,
4075
+ partialJson: JSON.stringify(json.part.state.input)
4076
+ };
4077
+ }
4078
+ return null;
4079
+ }
4033
4080
 
4034
4081
  // src/layers/llm/stream-opencode.ts
4035
4082
  function processOpenCodeEvent(json, outputChunks, _toolState, emit) {
@@ -4039,6 +4086,18 @@ function processOpenCodeEvent(json, outputChunks, _toolState, emit) {
4039
4086
  emit.single({ _tag: "Text", text });
4040
4087
  return;
4041
4088
  }
4089
+ const toolInfo = extractToolInfo2(json);
4090
+ if (toolInfo && toolInfo.type === "complete") {
4091
+ emit.single({ _tag: "ToolStart", tool: toolInfo.name });
4092
+ if (toolInfo.partialJson) {
4093
+ const input = safeParseJson(toolInfo.partialJson);
4094
+ if (input !== null) {
4095
+ emit.single({ _tag: "ToolUse", tool: toolInfo.name, input });
4096
+ }
4097
+ }
4098
+ emit.single({ _tag: "ToolEnd", tool: toolInfo.name });
4099
+ return;
4100
+ }
4042
4101
  if (isStepFinish(json)) {
4043
4102
  return;
4044
4103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ferix-code",
3
- "version": "0.0.2-beta.14",
3
+ "version": "0.0.2-beta.16",
4
4
  "description": "Composable RALPH loops for AI coding agents - v2 with Effect",
5
5
  "type": "module",
6
6
  "bin": {