-
Notifications
You must be signed in to change notification settings - Fork 2
v0.10: AI Chat with Bedrock, ECS task-definitions, resource pagination #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… docs search (#126) * Add AI chat overlay with Bedrock Converse API (#123) - internal/ai/: bedrock client, tools (6), session persistence - chat_overlay.go: modal UI with viewport + textinput - Context-aware: knows current service/resource/log group - Config: ai.model, ai.max_sessions in config.yaml - Keybind: A opens chat overlay * Enhance AI chat, add ECS task-definitions, improve filter UX - AI Chat: add ECS cluster context, fix tool input parsing, improve logging - Add ECS task-definitions resource type with navigation from clusters/services/tasks - ServiceBrowser: change filter to fuzzy match (was substring) - Fix ghost content on filter change with tea.ClearScreen (ServiceBrowser, LogView) - Update docs: add AI Chat keybinding (A key) to README and keybindings.md * Fix AI chat code review issues - bedrock.go: add ctx to processStream, handle stream.Close error, log json errors - chat_overlay.go: use ui helpers, apperrors.Wrap, check executor nil, fix tool msg handling - modal.go: add ModalWidthChat constant - app.go: use ModalWidthChat instead of hardcoded 80 - session.go: simplify prune error handling * Use ConverseStream for real-time AI response + refactor - chat_overlay.go: use ConverseStream instead of sync Converse API - Split into chat_overlay.go, chat_overlay_render.go, chat_overlay_prompt.go - tools.go: extract getResource helper to reduce GetDAO->Get->Unwrap repetition - Streaming handles text deltas, tool_use accumulation, multi-round tool calls * Add extended thinking, search_aws_docs, fix Data field in 62 resources AI Chat improvements: - Extended thinking support with collapsed display during streaming - Rename isThinking to isStreaming for clarity - Consistent AI: + newline format in streaming/final - Scroll to thinking block on expand Tools: - Implement search_aws_docs using AWS Documentation Search API - Return top 5 results with title, URL, context Resource fixes: - Add missing Data field to BaseResource in 62 dao.go files - Enables Raw() to return resource data for AI get_resource_detail * Fix AI chat multi-turn conversation with tool calls - Use []ContentBlock instead of string for Message.Content (Bedrock API) - Preserve streamMessages across turns instead of rebuilding from UI state - Only add non-empty ContentBlocks to prevent 'content.0 is blank' error - Fix toolUse/toolResult pairing for multi-turn tool conversations * Add AI chat list/diff context modes + multi-profile support * Add collapsible tool call params in AI chat (default collapsed) * AI chat: disable session persistence by default, increase max_sessions to 100 - Add save_sessions config option (default: false) for privacy - Increase DefaultAIMaxSessions 10 -> 100 - Document AI config in docs/configuration.md * Add AI module tests and Bedrock IAM permissions docs * Fix code review issues: remove duplicate DefaultModel, use parent ctx in searchDocs, revert ServiceBrowser to substring filter * Fix review issues: slice copy, log.Warn, ctx shadow, use go-runewidth * Fix race condition: remove duplicate streamMessages assignment in startStream * Add chat session history UI (Ctrl+H) and fix nav key conflicts - Session history: Ctrl+H opens history, j/k select, enter load, n new - Save sessions only when first message added (not on open) - Show (tool limit reached) when max tool rounds hit - Log pruneOldSessions errors at debug level - Change nav key d→D for task-definitions/data-sources (conflicts with detail view) * fix TestSessionPruning: add message to trigger file save * Fix review: nil guard loadSession, log session errors, warn negative thinking_budget * SecurityHub findings filter toggle + AI context expansion - Add 'r' key toggle for SecurityHub findings (active only / all) - Default: show only ACTIVE + non-RESOLVED findings - Add include_resolved param to query_resources AI tool - Pass toggle state to AI via system prompt + result message - Add expandable context params in AI chat (click to toggle) - Add Toggle/Toggler interface for reusable list-level toggles - Add DocsSearch timeout to config (timeouts.docs_search) - Fix: stop stream when loading session history - Fix: show session save failure in StatusLine (3s) - Fix: set IsError on tool input JSON parse failure * ai: make max_tool_rounds configurable (default 15) * ai: use UUID for session ID, add debug log on load failure * Fix code review issues: stream cancellation, file permissions, docs - Add stream cancellation to prevent goroutine leaks when closing chat overlay - Change AI session file permissions from 0644 to 0600 (security) - Add D key to keybindings.md for Data Sources/Task Definitions navigation - Move google/uuid and mattn/go-runewidth to direct dependencies in go.mod - Change log.Debug to log.Warn for session save failures * Fix: save tool use/result to session for persistence - Save assistant msg with ToolUse to session before tool exec - Save user msg with ToolResult to session after tool exec - Remove duplicate assistant msg append in handleToolExecute - Fixes session resume forgetting tool execution history * AI chat: fix profile ID handling, strengthen list mode instructions - Use internal profile IDs (__sdk_default__, etc) for LLM tool calls - Add formatProfileName() for UI display conversion - Clarify list mode: query ALL regions × ALL profiles explicitly - Add IMPORTANT directives to ensure complete cross-context queries * AI chat: region/profile context complete Config: - Add ai.profile/ai.region to config.yaml for Bedrock-specific credentials - NewClient() uses AI config to override default profile/region Context fields: - Rename: Regions→UserRegions, Profile→ResourceProfile - Add: UserProfiles for multi-profile support - Distinguish user selections (User*) from specific resource context (Resource*) Tools: - Use ProfileSelectionFromID() to convert profile IDs for AWS SDK Views: - Preserve resource wrappers (RegionalResource/ProfiledResource) on refresh - Use UnwrapResource() consistently for accessing underlying resource data Fixes: - ResourceRegion empty bug (contextForResource unwrap, mergeResources wrapper loss) - Profile ID conversion (__sdk_default__ → ProfileSelectionFromID) * Refactor: share mergeResources across views Move mergeResources from detail_view to view.go for reusability. Future-proofs DiffView for wrapper preservation when refresh added. - Addresses code review finding: design inconsistency - Enables consistent wrapper preservation pattern * AI chat: tool call limit, resource pagination, session pruning optimization 3 improvements for v0.10: 1. Tool call counter (防御層) - Config: ai.max_tool_calls_per_query (default: 50) - Limit per query (not session) to prevent LLM runaway - Reset on new user message 2. Resource limit relaxation (利便性) - query_resources: default 100 (was 50), max 2000 - Add offset param for pagination - SecurityHub large findings support 3. Session pruning optimization (性能) - Session ID: 20060102-150405-uuid (was 2006-01-02-uuid) - pruneOldSessions: filename sort (was JSON parse + UpdatedAt sort) - 1000x faster (~0.1ms vs ~100ms), works well even at 100+ sessions * Docs: add max_tool_calls_per_query config * Fix: toolCallCount naming, reset in loadSession, profile ID handling - Rename apiCallCount -> toolCallCount (clearer per-query scope) - Add toolCallCount reset in loadSession() (consistency with newSession) - Use ProfileSelectionFromID in bedrock.go (handle __sdk_default__) * Docs: AI chat feature w/ screenshot, usage guide - README: add AI chat screenshot section, fix keybinding (A not Ctrl+L) - docs/ai-chat.md: new doc w/ setup, usage, tools, examples - docs/configuration.md: add ai.profile/region fields - docs/images/ai-chat.png: screenshot showing security analysis * Fix: code review critical issues (imports, race, perms, tool limit) - Fix import order (goimports) in session.go, file.go, chat_overlay*.go - Fix race condition: add mutex for stream cancellation - Fix session dir permissions: 0755 -> 0700 (prevent info leak) - Fix tool call limit bypass: check limit inside loop, not just entry - Note: pagination bounds checking already implemented (line 322-324) Addresses code review: #126 (comment) * Fix: session pruning by mtime, streamCancel race condition Session pruning improvements: - Use file modification time instead of filename for pruning - Ensures recently updated sessions are not deleted - Maintains performance (no JSON parsing required) Race condition fix: - Protect streamCancel assignment with mutex in startStream() - Previously only cancelStream() was protected Addresses PR review: #126 (comment) * Docs: simplify ai-chat.md, remove tool details and examples - Remove detailed tool descriptions (list_resources, query_resources, etc.) - Remove example queries section - Add concise 'What the AI Can Do' section - Keep essential: setup, keyboard shortcuts, troubleshooting - Users can ask the AI directly how to use it Changed from 221 to 147 lines (-74 lines) * Docs: update IAM permissions for all Bedrock models - Change Resource from anthropic.claude-* to * (support all models) - Add note: Marketplace permissions required for first-time usage only - claws supports any Bedrock model via ai.model config * Fix: return error flag for invalid pagination offset When offset exceeds resource count, return isError=true so LLM recognizes it as an error condition. Addresses code review: #126 (comment)
PR Review: v0.10 - AI Chat with Bedrock, ECS task-definitions, resource paginationSummaryThis is a substantial feature release adding AI chat functionality with AWS Bedrock integration, ECS task definitions support, and resource pagination. The code is well-structured and follows good practices. ✅ StrengthsArchitecture & Code Quality
Security
Performance
|
Summary
Major feature release adding AI chat functionality with AWS Bedrock integration.
Features
AI Chat (Issue #123)
Akey) - Bedrock Converse API with streaming responsesCtrl+H) - Browse and resume past conversationslist_resources- List available resource typesquery_resources- Query AWS resources (pagination: limit 100 default, 2000 max)get_resource_detail- Get resource detailstail_logs- Fetch CloudWatch logssearch_aws_docs- Search AWS documentationECS Task Definitions
ecs/task-definitionsResource Enhancements
Datafield to 62 resources for AI contextConfiguration
New
aisection in config.yaml:Documentation
docs/ai-chat.md- AI Chat setup and usage guidedocs/iam-permissions.md- Bedrock permissionsdocs/configuration.md- AI config sectionTesting
Code Quality
internal/ai/module with bedrock.go, session.go, tools.goapperrors.Wrap()Breaking Changes
None - all changes are additive.
Related