Add AI chat agent support with Claude integration#103
Conversation
…andler Implement the backend foundation for ProcessGit chatbot integration: - modules/chat/types.go: Define all types for chat config (YAML), conversations, Claude API requests, SSE events - modules/chat/config.go: YAML config parser with file discovery (agent.chat.yaml), validation, defaults, and API key resolution - modules/chat/history.go: Git-based conversation storage with buffered writes, index management, and conversation lifecycle - modules/setting/chat.go: Chat settings (enabled, rate limits, budget) - routers/web/repo/chat.go: Chat API endpoint with SSE streaming, rate limiting, budget enforcement, and Claude API proxy with MCP tool support - Route registration in web.go for POST /chat, GET /chat/agents, GET /chat/history https://claude.ai/code/session_01WemnwGzTGVxxrRnRB6vX63
Frontend: - ChatPanel.vue: Full chat UI with SSE streaming, quick questions, tool call indicators, typing animation, and status bar - ViewFileTreeItem.vue: Detect chat agent files, show robot icon and friendly name, click opens chat panel instead of file viewer - ViewFileTreeStore.ts: Add chatAgentName field, openChatPanel method - repo-view-file-tree.ts: Mount/unmount ChatPanel on open-chat-agent event Backend: - tree.go: Annotate TreeViewNode with chatAgentName when file matches agent.chat.yaml pattern and config is valid Tests: - integration_test.go: Claude API request format, tool allow/deny lists, multi-turn conversations, SSE events, JSON round-trip, cost estimation Docs: - docs/chat-agents.md: Complete reference for agent.chat.yaml format, API endpoints, configuration, and troubleshooting https://claude.ai/code/session_01WemnwGzTGVxxrRnRB6vX63
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a4c24d4947
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| userID := "anonymous" | ||
| userName := "Anonymous" | ||
| if ctx.Doer != nil { | ||
| userID = fmt.Sprintf("%d", ctx.Doer.ID) |
There was a problem hiding this comment.
Enforce access.visibility before accepting anonymous chat requests
cfg.Access.Visibility is never enforced here: the handler assigns unauthenticated callers the synthetic user anonymous and continues normally. Because the /chat routes are registered with optSignInIgnoreCsrf in routers/web/web.go, public repositories can be queried without login even when the config default is visibility: authenticated, allowing anonymous users to consume model budget and bypass the intended access policy.
Useful? React with 👍 / 👎.
| ctx.Resp.Header().Set("Connection", "keep-alive") | ||
| ctx.Resp.Header().Set("X-Accel-Buffering", "no") | ||
|
|
||
| assistantContent, toolCalls, usage, err := streamClaudeResponse(ctx.Resp, apiKey, claudeReq) |
There was a problem hiding this comment.
Dispatch chat requests by configured LLM provider
This code always sends requests through the Claude/Anthropic path, regardless of cfg.LLM.Provider. Since config validation explicitly allows openai and ollama, those agents will still be serialized as Claude payloads and posted with Anthropic headers, causing runtime failures for non-Anthropic providers even though their configs are accepted.
Useful? React with 👍 / 👎.
| if cfg.History.Enabled { | ||
| buf := chat.GetBuffer(ctx.Repo.Repository.ID) | ||
| buf.BufferConversation(conv) |
There was a problem hiding this comment.
Flush buffered conversations to persistent history storage
When history.enabled is set, conversations are only placed into an in-memory buffer; there is no production call site that drains/flushed this buffer to git (repo-wide search shows DrainConversations used only in tests). That means conversation history is never persisted and is lost on restart, so the history feature does not function as documented.
Useful? React with 👍 / 👎.
| // Create mount point | ||
| chatMountEl = document.createElement('div'); | ||
| chatMountEl.className = 'chat-panel-container'; | ||
| repoViewContent.innerHTML = ''; |
There was a problem hiding this comment.
Preserve repo content when mounting the chat panel
Opening a chat agent clears the entire .repo-view-content container with innerHTML = '', but closing chat only unmounts/removes the chat node and never restores what was removed. In practice, after a user opens and closes the panel, the repository content area stays blank until they reload or navigate away.
Useful? React with 👍 / 👎.
Summary
This PR introduces a comprehensive AI chat agent system for ProcessGit repositories, enabling interactive AI-powered assistance through a chat interface. Users can now create
agent.chat.yamlconfiguration files in their repositories to define custom chat agents powered by Claude (with extensibility for other LLM providers).Key Features
ChatPanel.vue) providing a modern chat interface with streaming responses, quick questions, conversation management, and usage trackingagent.chat.yaml) supporting:Technical Implementation
modules/chat/package with configuration loading, conversation management, Claude API integration, and history persistence/chat,/chat/agents,/chat/history) inrouters/web/repo/chat.gomodules/setting/chat.goConfiguration Example
Validation
config_test.go,history_test.go,integration_test.go)Testing
Closes #[issue-number]
https://claude.ai/code/session_01WemnwGzTGVxxrRnRB6vX63