Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cli/src/constants/themes/alpha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ export const alphaTheme: Theme = {
lineNumber: "cyan",
},

markdown: {
text: "white",
heading: "yellow",
strong: "white",
em: "white",
code: "green",
blockquote: "gray",
link: "cyan",
list: "white",
},

ui: {
border: {
default: "gray",
Expand Down
11 changes: 11 additions & 0 deletions cli/src/constants/themes/ansi-light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export const ansiLightTheme: Theme = {
lineNumber: "gray",
},

markdown: {
text: "#444",
heading: "blue",
strong: "#000",
em: "#444",
code: "green",
blockquote: "gray",
link: "blue",
list: "#444",
},

ui: {
border: {
default: "#e1e4e8",
Expand Down
11 changes: 11 additions & 0 deletions cli/src/constants/themes/ansi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export const ansiTheme: Theme = {
lineNumber: "gray",
},

markdown: {
text: "white",
heading: "cyan",
strong: "white",
em: "white",
code: "green",
blockquote: "gray",
link: "cyan",
list: "white",
},

ui: {
border: {
default: "gray",
Expand Down
11 changes: 11 additions & 0 deletions cli/src/constants/themes/atom-one-dark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export const atomOneDarkTheme: Theme = {
lineNumber: "#5c6370",
},

markdown: {
text: "#abb2bf",
heading: "#61aeee",
strong: "#ffffff",
em: "#abb2bf",
code: "#98c379",
blockquote: "#5c6370",
link: "#61aeee",
list: "#abb2bf",
},

ui: {
border: {
default: "#5c6370",
Expand Down
11 changes: 11 additions & 0 deletions cli/src/constants/themes/ayu-dark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export const ayuDarkTheme: Theme = {
lineNumber: "#646A71",
},

markdown: {
text: "#aeaca6",
heading: "#FFB454",
strong: "#ffffff",
em: "#aeaca6",
code: "#AAD94C",
blockquote: "#646A71",
link: "#59C2FF",
list: "#aeaca6",
},

ui: {
border: {
default: "#3D4149",
Expand Down
11 changes: 11 additions & 0 deletions cli/src/constants/themes/ayu-light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export const ayuLightTheme: Theme = {
lineNumber: "#a6aaaf",
},

markdown: {
text: "#5c6166",
heading: "#55b4d4",
strong: "#000000",
em: "#5c6166",
code: "#86b300",
blockquote: "#a6aaaf",
link: "#55b4d4",
list: "#5c6166",
},

ui: {
border: {
default: "#e1e4e8",
Expand Down
11 changes: 11 additions & 0 deletions cli/src/constants/themes/dark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export const darkTheme: Theme = {
lineNumber: "#858585",
},

markdown: {
text: "#cccccc",
heading: "#faf74f",
strong: "#ffffff",
em: "#d4d4d4",
code: "#89d185",
blockquote: "#858585",
link: "#3794ff",
list: "#cccccc",
},

ui: {
border: {
default: "#3c3c3c",
Expand Down
11 changes: 11 additions & 0 deletions cli/src/constants/themes/dracula.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export const draculaTheme: Theme = {
lineNumber: "#6272a4",
},

markdown: {
text: "#a3afb7",
heading: "#ff79c6",
strong: "#ffffff",
em: "#a3afb7",
code: "#50fa7b",
blockquote: "#6272a4",
link: "#8be9fd",
list: "#a3afb7",
},

ui: {
border: {
default: "#6272a4",
Expand Down
11 changes: 11 additions & 0 deletions cli/src/constants/themes/github-dark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export const githubDarkTheme: Theme = {
lineNumber: "#8b949e",
},

markdown: {
text: "#c9d1d9",
heading: "#58a6ff",
strong: "#ffffff",
em: "#c9d1d9",
code: "#3fb950",
blockquote: "#8b949e",
link: "#58a6ff",
list: "#c9d1d9",
},

ui: {
border: {
default: "#30363d",
Expand Down
11 changes: 11 additions & 0 deletions cli/src/constants/themes/github-light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export const githubLightTheme: Theme = {
lineNumber: "#999",
},

markdown: {
text: "#24292e",
heading: "#0086b3",
strong: "#000000",
em: "#24292e",
code: "#008080",
blockquote: "#998",
link: "#0086b3",
list: "#24292e",
},

ui: {
border: {
default: "#e1e4e8",
Expand Down
11 changes: 11 additions & 0 deletions cli/src/constants/themes/googlecode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export const googleCodeTheme: Theme = {
lineNumber: "#5f6368",
},

markdown: {
text: "#444",
heading: "#066",
strong: "#000",
em: "#444",
code: "#080",
blockquote: "#5f6368",
link: "#066",
list: "#444",
},

ui: {
border: {
default: "#e1e4e8",
Expand Down
11 changes: 11 additions & 0 deletions cli/src/constants/themes/light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export const lightTheme: Theme = {
lineNumber: "#237893",
},

markdown: {
text: "#616161",
heading: "#000000",
strong: "#000000",
em: "#616161",
code: "#388a34",
blockquote: "#717171",
link: "#006ab1",
list: "#616161",
},

ui: {
border: {
default: "#cecece",
Expand Down
11 changes: 11 additions & 0 deletions cli/src/constants/themes/shades-of-purple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export const shadesOfPurpleTheme: Theme = {
lineNumber: "#726c86",
},

markdown: {
text: "#e3dfff",
heading: "#4d21fc",
strong: "#ffffff",
em: "#e3dfff",
code: "#A5FF90",
blockquote: "#726c86",
link: "#a1feff",
list: "#e3dfff",
},

ui: {
border: {
default: "#a599e9",
Expand Down
11 changes: 11 additions & 0 deletions cli/src/constants/themes/xcode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export const xcodeTheme: Theme = {
lineNumber: "#c0c0c0",
},

markdown: {
text: "#444",
heading: "#0E0EFF",
strong: "#000",
em: "#444",
code: "#007400",
blockquote: "#c0c0c0",
link: "#0E0EFF",
list: "#444",
},

ui: {
border: {
default: "#e1e4e8",
Expand Down
12 changes: 12 additions & 0 deletions cli/src/types/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ export interface Theme {
lineNumber: string
}

/** Markdown rendering colors */
markdown: {
text: string
heading: string
strong: string
em: string
code: string
blockquote: string
link: string
list: string
}

/** UI structure colors */
ui: {
border: {
Expand Down
21 changes: 19 additions & 2 deletions cli/src/ui/components/MarkdownText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import React, { useState, useEffect, useRef, useCallback } from "react"
import { Text } from "ink"
import { parse, setOptions } from "marked"
import TerminalRenderer, { type TerminalRendererOptions } from "marked-terminal"
import type { Theme } from "../../types/theme.js"

export type MarkdownTextProps = TerminalRendererOptions & {
children: string
theme?: Theme
}

/**
Expand Down Expand Up @@ -108,7 +110,7 @@ const calculateAdaptiveSpeed = (
* @param options - Optional TerminalRenderer configuration
* @returns Rendered markdown text with typewriter animation for streaming content
*/
export const MarkdownText: React.FC<MarkdownTextProps> = ({ children, ...options }) => {
export const MarkdownText: React.FC<MarkdownTextProps> = ({ children, theme, ...options }) => {
// State for displayed text (what user sees)
const [displayedText, setDisplayedText] = useState("")

Expand Down Expand Up @@ -238,9 +240,24 @@ export const MarkdownText: React.FC<MarkdownTextProps> = ({ children, ...options
}

try {
// Merge theme colors with user options if theme is provided
const rendererOptions: TerminalRendererOptions = theme
? {
...options,
text: theme.markdown.text,
heading: theme.markdown.heading,
strong: theme.markdown.strong,
em: theme.markdown.em,
code: theme.markdown.code,
blockquote: theme.markdown.blockquote,
link: theme.markdown.link,
list: theme.markdown.list,
}
: options

// Configure marked to use the terminal renderer
setOptions({
renderer: new TerminalRenderer(options),
renderer: new TerminalRenderer(rendererOptions),
})

// Parse markdown on the displayed text (efficient - only once per update)
Expand Down
2 changes: 1 addition & 1 deletion cli/src/ui/messages/extension/say/SayReasoningMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const SayReasoningMessage: React.FC<MessageComponentProps> = ({ message }
</Box>
{message.text && (
<Box marginTop={1}>
<MarkdownText>{message.text}</MarkdownText>
<MarkdownText theme={theme}>{message.text}</MarkdownText>
{message.partial && (
<Text color={theme.ui.text.dimmed} dimColor>
{" "}
Expand Down