summaryrefslogtreecommitdiff
path: root/packages/cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src')
-rw-r--r--packages/cli/src/ui/components/InputPrompt.tsx6
-rw-r--r--packages/cli/src/ui/components/messages/UserMessage.tsx2
-rw-r--r--packages/cli/src/ui/utils/markdownUtilities.ts51
3 files changed, 17 insertions, 42 deletions
diff --git a/packages/cli/src/ui/components/InputPrompt.tsx b/packages/cli/src/ui/components/InputPrompt.tsx
index 153b4701..40956647 100644
--- a/packages/cli/src/ui/components/InputPrompt.tsx
+++ b/packages/cli/src/ui/components/InputPrompt.tsx
@@ -14,11 +14,7 @@ interface InputPromptProps {
}
export const InputPrompt: React.FC<InputPromptProps> = ({ onSubmit }) => {
- const [value, setValue] = React.useState(
- "I'd like to update my web fetch tool to be a little smarter about the content it fetches from web pages. Instead of returning the entire HTML to the LLM I was extract the body text and other important information to reduce the amount of tokens we need to use.",
- );
- // const [value, setValue] = React.useState('Add "Hello World" to the top of README.md');
- // const [value, setValue] = React.useState('show me "Hello World" in as many langauges as you can think of');
+ const [value, setValue] = React.useState('');
const { isFocused } = useFocus({ autoFocus: true });
diff --git a/packages/cli/src/ui/components/messages/UserMessage.tsx b/packages/cli/src/ui/components/messages/UserMessage.tsx
index a83ffea7..b73fb200 100644
--- a/packages/cli/src/ui/components/messages/UserMessage.tsx
+++ b/packages/cli/src/ui/components/messages/UserMessage.tsx
@@ -17,7 +17,7 @@ export const UserMessage: React.FC<UserMessageProps> = ({ text }) => {
const prefixWidth = prefix.length;
return (
- <Box flexDirection="row">
+ <Box flexDirection="row" marginY={1}>
<Box width={prefixWidth}>
<Text color={Colors.Gray}>{prefix}</Text>
</Box>
diff --git a/packages/cli/src/ui/utils/markdownUtilities.ts b/packages/cli/src/ui/utils/markdownUtilities.ts
index d16b7a51..94492b8c 100644
--- a/packages/cli/src/ui/utils/markdownUtilities.ts
+++ b/packages/cli/src/ui/utils/markdownUtilities.ts
@@ -163,45 +163,24 @@ export const findSafeSplitPoint = (
}
// idealMaxLength is NOT inside a code block.
- // Search backwards from idealMaxLength for a double newline (\n\n) not in a code block.
- for (let i = Math.min(idealMaxLength, content.length) - 1; i > 0; i--) {
- if (content[i] === '\n' && content[i - 1] === '\n') {
- const potentialSplitPoint = i + 1;
- if (potentialSplitPoint <= idealMaxLength) {
- if (!isIndexInsideCodeBlock(content, potentialSplitPoint)) {
- return potentialSplitPoint;
- }
- }
+ // Search forwards from idealMaxLength for the next double newline (\n\n) not in a code block.
+ let searchStartIndex = idealMaxLength;
+ while (searchStartIndex < content.length) {
+ const dnlIndex = content.indexOf('\n\n', searchStartIndex);
+ if (dnlIndex === -1) {
+ // No more double newlines found after idealMaxLength
+ break;
}
- }
- // If no safe double newline, look for a single newline (\n)
- for (let i = Math.min(idealMaxLength, content.length) - 1; i >= 0; i--) {
- if (content[i] === '\n') {
- const potentialSplitPoint = i + 1;
- if (potentialSplitPoint <= idealMaxLength) {
- if (!isIndexInsideCodeBlock(content, potentialSplitPoint)) {
- return potentialSplitPoint;
- }
- }
+ const potentialSplitPoint = dnlIndex + 2;
+ if (!isIndexInsideCodeBlock(content, potentialSplitPoint)) {
+ return potentialSplitPoint;
}
- }
- // Fallback logic if no prior safe split was found
- if (!isIndexInsideCodeBlock(content, idealMaxLength)) {
- return idealMaxLength;
- } else {
- // This should ideally not be reached frequently if prior logic is sound.
- // enclosingBlockStartForIdealMax would have been set if idealMaxLength was in a block.
- // If somehow it's still in a block, attempt to use the start of that block.
- const lastResortBlockStart = findEnclosingCodeBlockStart(
- content,
- idealMaxLength,
- ); // Re-check
- if (lastResortBlockStart !== -1) {
- return lastResortBlockStart;
- }
- // Absolute fallback: if idealMaxLength is in a block and we can't find its start (very unlikely)
- return 0;
+ searchStartIndex = potentialSplitPoint; // Continue search after the found \n\n
}
+
+ // If no safe double newline found after idealMaxLength, return content.length
+ // to keep the entire content as one piece.
+ return content.length;
};