feat: add ai commands to terminal#782
Open
mateonunez wants to merge 4 commits into
Open
Conversation
Add `ai` and `@ai-sdk/anthropic` packages for AI-powered terminal commands with streaming support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> https://claude.ai/code/session_01FXuX3ypbwddUC3rFvYTneT
Integrate Vercel AI SDK with Anthropic Claude to add intelligent terminal commands: `ask`, `explain`, `summarize`, and `tldr`. Key changes: - API route (app/api/ai/chat) with streaming text responses - Rich system prompt as AIt (Mateo's digital alter ego) with live Spotify/GitHub context injection - Command system extended to support arguments and streaming output - Terminal state manages streaming text with real-time chunk rendering - Input blocked during active AI streaming - Commands registered under new "AI" group in help output Usage: `ask what tech stack do you use?`, `tldr your open source work`, `explain your approach to testing`, `summarize` Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> https://claude.ai/code/session_01FXuX3ypbwddUC3rFvYTneT
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> https://claude.ai/code/session_01FXuX3ypbwddUC3rFvYTneT
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The outer div's keydown handler was intercepting space keypresses (to focus the input) even when the input already had focus, preventing users from typing spaces. Skip the handler when the event originates from the input element. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> https://claude.ai/code/session_01FXuX3ypbwddUC3rFvYTneT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds AI-powered commands to the terminal, enabling users to interact with an Anthropic Claude model for chat, explanations, summaries, and TLDRs. It introduces streaming output for commands, improves the command execution flow to support streaming responses, and enhances the terminal UI to display streamed AI output in real time. Several supporting changes were made to the command context, state management, and command formatting to support these new capabilities.
AI Integration and New Commands:
Added new AI commands (
ask,explain,summarize,tldr) that send prompts to an Anthropic Claude model and stream responses back to the terminal, using context built from Spotify and GitHub data sources. (components/mate/terminal/commands/ai.ts,components/mate/terminal/commands/index.ts,.env.local.example) [1] Fed41041R1, [2] [3]Implemented an API route (
app/api/ai/chat/route.ts) to handle chat requests, validate prompts, and stream text responses from Anthropic. (app/api/ai/chat/route.ts)Streaming Output Support:
Enhanced terminal state and tools to support streaming text, including new methods to append and finalize streamed output. (
components/mate/terminal/command-context.tsx,components/mate/terminal/hooks/use-terminal-state.ts,components/mate/terminal/terminal.tsx) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]Updated the terminal UI to display streaming output with a visual indicator and prevent new input while streaming is active. (
components/mate/terminal/terminal.tsx,components/mate/terminal/hooks/use-terminal-input.ts) [1] [2] [3] [4]Command Execution and Typing Improvements:
components/mate/terminal/hooks/use-command-runner.tsx,components/mate/terminal/hooks/use-command-executor.ts,components/mate/terminal/types/commands.ts) [1] [2] [3] [4] [5]Command Formatting:
components/mate/terminal/utils/formatting.ts)