feat: change default naming to pascal (#136)

This commit is contained in:
Charles Packer
2025-11-29 18:30:17 -08:00
committed by GitHub
parent 7ee5634021
commit b0291597f3
12 changed files with 716 additions and 31 deletions

View File

@@ -1,20 +1,28 @@
// Import useInput from vendored Ink for bracketed paste support
import { Box, Text, useInput } from "ink";
import { useState } from "react";
import { useMemo, useState } from "react";
import { colors } from "./colors";
type ToolsetId =
| "codex"
| "codex_snake"
| "default"
| "gemini"
| "gemini_snake";
interface ToolsetOption {
id: "codex" | "default" | "gemini";
id: ToolsetId;
label: string;
description: string;
tools: string[];
isFeatured?: boolean;
}
const toolsets: ToolsetOption[] = [
{
id: "default",
label: "Default Tools",
description: "Anthropic-style tools optimized for Claude models",
description: "Toolset optimized for Claude models",
tools: [
"Bash",
"BashOutput",
@@ -27,11 +35,27 @@ const toolsets: ToolsetOption[] = [
"TodoWrite",
"Write",
],
isFeatured: true,
},
{
id: "codex",
label: "Codex Tools",
description: "OpenAI-style tools optimized for GPT models",
description: "Toolset optimized for GPT/Codex models",
tools: [
"ShellCommand",
"Shell",
"ReadFile",
"ListDir",
"GrepFiles",
"ApplyPatch",
"UpdatePlan",
],
isFeatured: true,
},
{
id: "codex_snake",
label: "Codex Tools (snake_case)",
description: "Toolset optimized for GPT/Codex models (snake_case)",
tools: [
"shell_command",
"shell",
@@ -45,7 +69,24 @@ const toolsets: ToolsetOption[] = [
{
id: "gemini",
label: "Gemini Tools",
description: "Google-style tools optimized for Gemini models",
description: "Toolset optimized for Gemini models",
tools: [
"RunShellCommand",
"ReadFileGemini",
"ListDirectory",
"GlobGemini",
"SearchFileContent",
"Replace",
"WriteFileGemini",
"WriteTodos",
"ReadManyFiles",
],
isFeatured: true,
},
{
id: "gemini_snake",
label: "Gemini Tools (snake_case)",
description: "Toolset optimized for Gemini models (snake_case)",
tools: [
"run_shell_command",
"read_file_gemini",
@@ -61,8 +102,8 @@ const toolsets: ToolsetOption[] = [
];
interface ToolsetSelectorProps {
currentToolset?: "codex" | "default" | "gemini";
onSelect: (toolsetId: "codex" | "default" | "gemini") => void;
currentToolset?: ToolsetId;
onSelect: (toolsetId: ToolsetId) => void;
onCancel: () => void;
}
@@ -71,17 +112,39 @@ export function ToolsetSelector({
onSelect,
onCancel,
}: ToolsetSelectorProps) {
const [showAll, setShowAll] = useState(false);
const [selectedIndex, setSelectedIndex] = useState(0);
const featuredToolsets = useMemo(
() => toolsets.filter((toolset) => toolset.isFeatured),
[],
);
const visibleToolsets = useMemo(() => {
if (showAll) return toolsets;
if (featuredToolsets.length > 0) return featuredToolsets;
return toolsets.slice(0, 3);
}, [featuredToolsets, showAll]);
const hasHiddenToolsets = visibleToolsets.length < toolsets.length;
const hasShowAllOption = !showAll && hasHiddenToolsets;
const totalItems = visibleToolsets.length + (hasShowAllOption ? 1 : 0);
useInput((_input, key) => {
if (key.upArrow) {
setSelectedIndex((prev) => Math.max(0, prev - 1));
} else if (key.downArrow) {
setSelectedIndex((prev) => Math.min(toolsets.length - 1, prev + 1));
setSelectedIndex((prev) => Math.min(totalItems - 1, prev + 1));
} else if (key.return) {
const selectedToolset = toolsets[selectedIndex];
if (selectedToolset) {
onSelect(selectedToolset.id);
if (hasShowAllOption && selectedIndex === visibleToolsets.length) {
setShowAll(true);
setSelectedIndex(0);
} else {
const selectedToolset = visibleToolsets[selectedIndex];
if (selectedToolset) {
onSelect(selectedToolset.id);
}
}
} else if (key.escape) {
onCancel();
@@ -97,7 +160,7 @@ export function ToolsetSelector({
</Box>
<Box flexDirection="column">
{toolsets.map((toolset, index) => {
{visibleToolsets.map((toolset, index) => {
const isSelected = index === selectedIndex;
const isCurrent = toolset.id === currentToolset;
@@ -134,6 +197,20 @@ export function ToolsetSelector({
</Box>
);
})}
{hasShowAllOption && (
<Box flexDirection="row" gap={1}>
<Text
color={
selectedIndex === visibleToolsets.length
? colors.selector.itemHighlighted
: undefined
}
>
{selectedIndex === visibleToolsets.length ? "" : " "}
</Text>
<Text dimColor>Show all toolsets</Text>
</Box>
)}
</Box>
</Box>
);