mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-01-30 06:12:06 +00:00
Merge pull request #28 from connor-tyndall/feat/interactive-assistant-feature-management
feat: Enable assistant chat to create and manage features
This commit is contained in:
67
server/services/assistant_chat_session.py
Normal file → Executable file
67
server/services/assistant_chat_session.py
Normal file → Executable file
@@ -29,13 +29,23 @@ logger = logging.getLogger(__name__)
|
||||
# Root directory of the project
|
||||
ROOT_DIR = Path(__file__).parent.parent.parent
|
||||
|
||||
# Read-only feature MCP tools (no mark_passing, skip, create_bulk)
|
||||
# Read-only feature MCP tools
|
||||
READONLY_FEATURE_MCP_TOOLS = [
|
||||
"mcp__features__feature_get_stats",
|
||||
"mcp__features__feature_get_next",
|
||||
"mcp__features__feature_get_for_regression",
|
||||
]
|
||||
|
||||
# Feature management tools (create/skip but not mark_passing)
|
||||
FEATURE_MANAGEMENT_TOOLS = [
|
||||
"mcp__features__feature_create",
|
||||
"mcp__features__feature_create_bulk",
|
||||
"mcp__features__feature_skip",
|
||||
]
|
||||
|
||||
# Combined list for assistant
|
||||
ASSISTANT_FEATURE_TOOLS = READONLY_FEATURE_MCP_TOOLS + FEATURE_MANAGEMENT_TOOLS
|
||||
|
||||
# Read-only built-in tools (no Write, Edit, Bash)
|
||||
READONLY_BUILTIN_TOOLS = [
|
||||
"Read",
|
||||
@@ -60,17 +70,30 @@ def get_system_prompt(project_name: str, project_dir: Path) -> str:
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to read app_spec.txt: {e}")
|
||||
|
||||
return f"""You are a helpful project assistant for the "{project_name}" project.
|
||||
return f"""You are a helpful project assistant and backlog manager for the "{project_name}" project.
|
||||
|
||||
Your role is to help users understand the codebase, answer questions about features, and explain how code works. You have READ-ONLY access to the project files.
|
||||
Your role is to help users understand the codebase, answer questions about features, and manage the project backlog. You can READ files and CREATE/MANAGE features, but you cannot modify source code.
|
||||
|
||||
IMPORTANT: You CANNOT modify any files. You can only:
|
||||
## What You CAN Do
|
||||
|
||||
**Codebase Analysis (Read-Only):**
|
||||
- Read and analyze source code files
|
||||
- Search for patterns in the codebase
|
||||
- Look up documentation online
|
||||
- Check feature progress and status
|
||||
|
||||
If the user asks you to make changes, politely explain that you're a read-only assistant and they should use the main coding agent for modifications.
|
||||
**Feature Management:**
|
||||
- Create new features/test cases in the backlog
|
||||
- Skip features to deprioritize them (move to end of queue)
|
||||
- View feature statistics and progress
|
||||
|
||||
## What You CANNOT Do
|
||||
|
||||
- Modify, create, or delete source code files
|
||||
- Mark features as passing (that requires actual implementation by the coding agent)
|
||||
- Run bash commands or execute code
|
||||
|
||||
If the user asks you to modify code, explain that you're a project assistant and they should use the main coding agent for implementation.
|
||||
|
||||
## Project Specification
|
||||
|
||||
@@ -78,14 +101,35 @@ If the user asks you to make changes, politely explain that you're a read-only a
|
||||
|
||||
## Available Tools
|
||||
|
||||
You have access to these read-only tools:
|
||||
**Code Analysis:**
|
||||
- **Read**: Read file contents
|
||||
- **Glob**: Find files by pattern (e.g., "**/*.tsx")
|
||||
- **Grep**: Search file contents with regex
|
||||
- **WebFetch/WebSearch**: Look up documentation online
|
||||
|
||||
**Feature Management:**
|
||||
- **feature_get_stats**: Get feature completion progress
|
||||
- **feature_get_next**: See the next pending feature
|
||||
- **feature_get_for_regression**: See passing features
|
||||
- **feature_get_for_regression**: See passing features for testing
|
||||
- **feature_create**: Create a single feature in the backlog
|
||||
- **feature_create_bulk**: Create multiple features at once
|
||||
- **feature_skip**: Move a feature to the end of the queue
|
||||
|
||||
## Creating Features
|
||||
|
||||
When a user asks to add a feature, gather the following information:
|
||||
1. **Category**: A grouping like "Authentication", "API", "UI", "Database"
|
||||
2. **Name**: A concise, descriptive name
|
||||
3. **Description**: What the feature should do
|
||||
4. **Steps**: How to verify/implement the feature (as a list)
|
||||
|
||||
You can ask clarifying questions if the user's request is vague, or make reasonable assumptions for simple requests.
|
||||
|
||||
**Example interaction:**
|
||||
User: "Add a feature for S3 sync"
|
||||
You: I'll create that feature. Let me add it to the backlog...
|
||||
[calls feature_create with appropriate parameters]
|
||||
You: Done! I've added "S3 Sync Integration" to your backlog. It's now visible on the kanban board.
|
||||
|
||||
## Guidelines
|
||||
|
||||
@@ -93,7 +137,8 @@ You have access to these read-only tools:
|
||||
2. When explaining code, reference specific file paths and line numbers
|
||||
3. Use the feature tools to answer questions about project progress
|
||||
4. Search the codebase to find relevant information before answering
|
||||
5. If you're unsure, say so rather than guessing"""
|
||||
5. When creating features, confirm what was created
|
||||
6. If you're unsure about details, ask for clarification"""
|
||||
|
||||
|
||||
class AssistantChatSession:
|
||||
@@ -144,14 +189,14 @@ class AssistantChatSession:
|
||||
self.conversation_id = conv.id
|
||||
yield {"type": "conversation_created", "conversation_id": self.conversation_id}
|
||||
|
||||
# Build permissions list for read-only access
|
||||
# Build permissions list for assistant access (read + feature management)
|
||||
permissions_list = [
|
||||
"Read(./**)",
|
||||
"Glob(./**)",
|
||||
"Grep(./**)",
|
||||
"WebFetch",
|
||||
"WebSearch",
|
||||
*READONLY_FEATURE_MCP_TOOLS,
|
||||
*ASSISTANT_FEATURE_TOOLS,
|
||||
]
|
||||
|
||||
# Create security settings file
|
||||
@@ -191,7 +236,7 @@ class AssistantChatSession:
|
||||
model="claude-opus-4-5-20251101",
|
||||
cli_path=system_cli,
|
||||
system_prompt=system_prompt,
|
||||
allowed_tools=[*READONLY_BUILTIN_TOOLS, *READONLY_FEATURE_MCP_TOOLS],
|
||||
allowed_tools=[*READONLY_BUILTIN_TOOLS, *ASSISTANT_FEATURE_TOOLS],
|
||||
mcp_servers=mcp_servers,
|
||||
permission_mode="bypassPermissions",
|
||||
max_turns=100,
|
||||
|
||||
Reference in New Issue
Block a user