First implementation of Plimi

This commit is contained in:
achraf
2026-06-02 19:32:51 +02:00
commit be635b1828
136 changed files with 13663 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
import type { ToolInput } from "../../core/io/input-types";
import type { ToolResult } from "../../core/io/output-types";
import type { TextCaseOptions } from "./index";
export async function runTextCase(
input: ToolInput,
options: TextCaseOptions
): Promise<ToolResult> {
const text = input.text || "";
if (!text) {
throw new Error("No text provided.");
}
// A simple tokenizer that splits by whitespace or punctuation
const words = text.match(/[A-Z]+(?![a-z])|[A-Z]?[a-z]+|\d+/g) || [];
const outputStr = (() => {
switch (options.to) {
case "UPPERCASE":
return text.toUpperCase();
case "lowercase":
return text.toLowerCase();
case "camelCase":
return words.map((w, i) => {
const lower = w.toLowerCase();
return i === 0 ? lower : lower.charAt(0).toUpperCase() + lower.slice(1);
}).join("");
case "snake_case":
return words.map(w => w.toLowerCase()).join("_");
case "kebab-case":
return words.map(w => w.toLowerCase()).join("-");
default:
return text;
}
})();
return {
type: "text",
value: outputStr,
};
}