Spaces:
Running
Running
Asish Karthikeya Gogineni commited on
Commit ·
911f32b
1
Parent(s): 2156541
Update: Fix reset button, refine prompts, and enhance frontend UI
Browse files- code_chatbot/prompts.py +257 -140
- frontend/src/app/globals.css +82 -25
- frontend/src/app/layout.tsx +71 -54
- pages/1_⚡_Code_Studio.py +6 -1
- update_imports.py +84 -0
code_chatbot/prompts.py
CHANGED
|
@@ -1,63 +1,257 @@
|
|
| 1 |
# prompts.py - Enhanced Prompts for Code Chatbot
|
|
|
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
-
|
| 18 |
-
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
1. **NO HTML**: Use only Markdown. Do NOT generate HTML tags like <div> or <span>. Do NOT render "source chips".
|
| 37 |
-
2. **NO HALLUCINATION**: Only cite files that exist in the retrieved context.
|
| 38 |
-
3. **NO LECTURES**: Don't explain general programming concepts unless asked.
|
| 39 |
"""
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
| 44 |
|
| 45 |
-
|
| 46 |
-
1. **Analyze Context**: Use the provided code snippets to answer the question.
|
| 47 |
-
2. **Be Direct**: Start immediately with the answer. Avoid "Based on the code..." intros.
|
| 48 |
-
3. **Cite Evidence**: Every claim must reference a file path.
|
| 49 |
-
4. **Show Code**: Include relevant snippets.
|
| 50 |
-
5. **No Fluff**: Skip general summaries unless requested.
|
| 51 |
|
| 52 |
-
**RETRIEVED CODE CONTEXT:**
|
| 53 |
{context}
|
| 54 |
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
|
| 58 |
-
-
|
| 59 |
-
-
|
| 60 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
"""
|
| 62 |
|
| 63 |
QUERY_EXPANSION_PROMPT = """Given a user question about a codebase, generate 3-5 diverse search queries optimized for semantic code search.
|
|
@@ -69,22 +263,12 @@ QUERY_EXPANSION_PROMPT = """Given a user question about a codebase, generate 3-5
|
|
| 69 |
2. **Conceptual/Semantic**: High-level concepts, feature names, problem domains
|
| 70 |
3. **Related Systems**: Connected components, dependencies, integrations
|
| 71 |
4. **Configuration/Setup**: Environment setup, constants, configuration files
|
| 72 |
-
5. **Usage Examples**: Test files, example usage, API endpoints
|
| 73 |
-
|
| 74 |
-
**Query Strategy:**
|
| 75 |
-
- Mix specific technical terms with natural language
|
| 76 |
-
- Include variations of terminology (e.g., "authentication", "auth", "login")
|
| 77 |
-
- Consider both questions ("how does X work") and keywords ("X implementation")
|
| 78 |
-
- Target different levels of abstraction (high-level concepts → specific details)
|
| 79 |
|
| 80 |
**Output Format** (one query per line, no numbering):
|
| 81 |
[query 1]
|
| 82 |
[query 2]
|
| 83 |
[query 3]
|
| 84 |
-
[query 4]
|
| 85 |
-
[query 5]
|
| 86 |
-
|
| 87 |
-
Generate 3-5 queries based on question complexity:
|
| 88 |
"""
|
| 89 |
|
| 90 |
ANSWER_SYNTHESIS_PROMPT = """Synthesize these search results into a concise answer.
|
|
@@ -103,8 +287,6 @@ ANSWER_SYNTHESIS_PROMPT = """Synthesize these search results into a concise answ
|
|
| 103 |
Provide your answer:
|
| 104 |
"""
|
| 105 |
|
| 106 |
-
# Additional utility prompts for specific scenarios
|
| 107 |
-
|
| 108 |
CODE_MODIFICATION_PROMPT = """You are suggesting code modifications for the codebase: {repo_name}.
|
| 109 |
|
| 110 |
**User Request:** {user_request}
|
|
@@ -121,7 +303,7 @@ Provide a concrete implementation that:
|
|
| 121 |
|
| 122 |
**Output Format:**
|
| 123 |
## Implementation Approach
|
| 124 |
-
[Brief explanation
|
| 125 |
|
| 126 |
## Code Changes
|
| 127 |
|
|
@@ -134,15 +316,9 @@ Provide a concrete implementation that:
|
|
| 134 |
[your implementation with comments]
|
| 135 |
````
|
| 136 |
|
| 137 |
-
### [Additional files if needed]
|
| 138 |
-
|
| 139 |
## Integration Notes
|
| 140 |
-
- [
|
| 141 |
-
- [Any configuration or dependency updates needed]
|
| 142 |
- [Testing considerations]
|
| 143 |
-
|
| 144 |
-
## Edge Cases Handled
|
| 145 |
-
- [List important edge cases your code addresses]
|
| 146 |
"""
|
| 147 |
|
| 148 |
ARCHITECTURE_EXPLANATION_PROMPT = """Explain the architecture and design patterns used in {repo_name} for: {topic}
|
|
@@ -155,7 +331,6 @@ ARCHITECTURE_EXPLANATION_PROMPT = """Explain the architecture and design pattern
|
|
| 155 |
2. **Design Patterns**: Specific patterns used (MVC, Repository, Factory, etc.)
|
| 156 |
3. **Data Flow**: How information moves through the system
|
| 157 |
4. **Key Decisions**: Why this architecture was chosen
|
| 158 |
-
5. **Diagram** (text-based): Visual representation of component relationships
|
| 159 |
|
| 160 |
Format with clear sections and reference specific files.
|
| 161 |
"""
|
|
@@ -163,11 +338,6 @@ Format with clear sections and reference specific files.
|
|
| 163 |
# =============================================================================
|
| 164 |
# GROQ-OPTIMIZED PROMPTS (For Llama and smaller models)
|
| 165 |
# =============================================================================
|
| 166 |
-
# These prompts are specifically designed for smaller LLMs that need:
|
| 167 |
-
# - More explicit, step-by-step instructions
|
| 168 |
-
# - Clearer output format specifications
|
| 169 |
-
# - More examples and constraints
|
| 170 |
-
# - Simpler language and shorter sections
|
| 171 |
|
| 172 |
GROQ_SYSTEM_PROMPT_AGENT = """You are a code assistant for the repository: {repo_name}.
|
| 173 |
|
|
@@ -183,7 +353,6 @@ RULES:
|
|
| 183 |
1. **Be Concise**: Get straight to the point.
|
| 184 |
2. **Cite Files**: Always mention file paths.
|
| 185 |
3. **Show Code**: Use snippets to prove your answer.
|
| 186 |
-
4. **No Fluff**: Avoid "Here is a detailed breakdown...". Just give the breakdown.
|
| 187 |
"""
|
| 188 |
|
| 189 |
GROQ_SYSTEM_PROMPT_LINEAR_RAG = """You are a code expert for: {repo_name}
|
|
@@ -201,90 +370,42 @@ Use these snippets to answer the question CONCISELY.
|
|
| 201 |
"""
|
| 202 |
|
| 203 |
GROQ_QUERY_EXPANSION_PROMPT = """Turn this question into 3 search queries for a code search engine.
|
| 204 |
-
|
| 205 |
Question: {question}
|
| 206 |
-
|
| 207 |
-
Rules:
|
| 208 |
-
- Make queries short (2-5 words each)
|
| 209 |
-
- Include function/class names if mentioned
|
| 210 |
-
- Mix technical terms and simple descriptions
|
| 211 |
-
|
| 212 |
Output exactly 3 queries, one per line:
|
| 213 |
"""
|
| 214 |
|
| 215 |
GROQ_ANSWER_SYNTHESIS_PROMPT = """Combine these code search results into one clear answer.
|
| 216 |
-
|
| 217 |
USER QUESTION: {question}
|
| 218 |
-
|
| 219 |
SEARCH RESULTS:
|
| 220 |
{retrieved_context}
|
| 221 |
|
| 222 |
-
|
| 223 |
-
1. Read all the search results
|
| 224 |
-
2. Find the most relevant code for the question
|
| 225 |
-
3. Write ONE unified answer
|
| 226 |
-
|
| 227 |
-
FORMAT YOUR ANSWER EXACTLY LIKE THIS:
|
| 228 |
-
|
| 229 |
## Direct Answer
|
| 230 |
-
[
|
| 231 |
|
| 232 |
## Key Files
|
| 233 |
-
- `
|
| 234 |
-
- `file2.py` - [what it does]
|
| 235 |
|
| 236 |
## Main Code
|
| 237 |
```python
|
| 238 |
-
[
|
| 239 |
```
|
| 240 |
-
|
| 241 |
-
## How It Works
|
| 242 |
-
1. [Step 1]
|
| 243 |
-
2. [Step 2]
|
| 244 |
-
3. [Step 3]
|
| 245 |
-
|
| 246 |
-
RULES:
|
| 247 |
-
- Keep answer under 300 words
|
| 248 |
-
- Only use code from the search results
|
| 249 |
-
- Be specific about file names and line numbers
|
| 250 |
"""
|
| 251 |
|
| 252 |
GROQ_CODE_MODIFICATION_PROMPT = """You need to suggest code changes for: {repo_name}
|
| 253 |
-
|
| 254 |
USER REQUEST: {user_request}
|
| 255 |
-
|
| 256 |
EXISTING CODE:
|
| 257 |
{existing_code}
|
| 258 |
|
| 259 |
-
INSTRUCTIONS:
|
| 260 |
-
1. Look at the existing code style
|
| 261 |
-
2. Write new code that matches the style
|
| 262 |
-
3. Explain where to put the new code
|
| 263 |
-
|
| 264 |
OUTPUT FORMAT:
|
| 265 |
-
|
| 266 |
## What I'll Change
|
| 267 |
-
[
|
| 268 |
|
| 269 |
## New Code
|
| 270 |
```python
|
| 271 |
# Add to: path/to/file.py
|
| 272 |
-
|
| 273 |
-
[your code here - match existing style]
|
| 274 |
```
|
| 275 |
-
|
| 276 |
-
## Where to Add It
|
| 277 |
-
- File: `path/to/file.py`
|
| 278 |
-
- Location: After line X / In function Y / At the end
|
| 279 |
-
|
| 280 |
-
## What It Does
|
| 281 |
-
1. [First thing]
|
| 282 |
-
2. [Second thing]
|
| 283 |
-
|
| 284 |
-
RULES:
|
| 285 |
-
- Match the existing code style exactly
|
| 286 |
-
- Include all necessary imports
|
| 287 |
-
- Handle errors properly
|
| 288 |
"""
|
| 289 |
|
| 290 |
# =============================================================================
|
|
@@ -292,16 +413,7 @@ RULES:
|
|
| 292 |
# =============================================================================
|
| 293 |
|
| 294 |
def get_prompt_for_provider(prompt_name: str, provider: str = "gemini") -> str:
|
| 295 |
-
"""Get the appropriate prompt based on LLM provider.
|
| 296 |
-
|
| 297 |
-
Args:
|
| 298 |
-
prompt_name: Name of the prompt (e.g., "system_agent", "linear_rag")
|
| 299 |
-
provider: LLM provider ("gemini", "groq", etc.)
|
| 300 |
-
|
| 301 |
-
Returns:
|
| 302 |
-
The appropriate prompt string for the provider
|
| 303 |
-
"""
|
| 304 |
-
# Prompt mapping for different providers
|
| 305 |
prompt_map = {
|
| 306 |
"system_agent": {
|
| 307 |
"gemini": SYSTEM_PROMPT_AGENT,
|
|
@@ -331,6 +443,11 @@ def get_prompt_for_provider(prompt_name: str, provider: str = "gemini") -> str:
|
|
| 331 |
}
|
| 332 |
|
| 333 |
if prompt_name not in prompt_map:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
raise ValueError(f"Unknown prompt name: {prompt_name}")
|
| 335 |
|
| 336 |
prompts = prompt_map[prompt_name]
|
|
|
|
| 1 |
# prompts.py - Enhanced Prompts for Code Chatbot
|
| 2 |
+
# Inspired by CodeFalcon
|
| 3 |
|
| 4 |
+
# =============================================================================
|
| 5 |
+
# SPECIFICATION TEMPLATES (CodeFalcon)
|
| 6 |
+
# =============================================================================
|
| 7 |
|
| 8 |
+
PO_FRIENDLY_TEMPLATE = """You are a Product Manager creating specifications for stakeholders.
|
| 9 |
|
| 10 |
+
Based on the following codebase context, create PO-friendly specifications:
|
| 11 |
+
|
| 12 |
+
{context}
|
| 13 |
+
|
| 14 |
+
{query}
|
| 15 |
+
|
| 16 |
+
## Your Task:
|
| 17 |
+
Analyze the provided code and extract the actual functionality, features, and business logic present. Generate a comprehensive, business-focused specification based on what you find in the code.
|
| 18 |
+
|
| 19 |
+
**Focus on capturing what's actually in the code:**
|
| 20 |
+
- What functionality does this code implement?
|
| 21 |
+
- What features are available to users?
|
| 22 |
+
- What business logic or workflows are present?
|
| 23 |
+
- What integrations or external services are used?
|
| 24 |
+
- What data is being processed or managed?
|
| 25 |
+
- How do different parts of the system work together to deliver features?
|
| 26 |
+
- What are the key system components and their relationships?
|
| 27 |
+
|
| 28 |
+
## Guidelines:
|
| 29 |
+
- **Be flexible**: Only include sections that are relevant to the actual code provided
|
| 30 |
+
- **Extract meaning**: Focus on understanding and explaining what the code does, not forcing it into predefined categories
|
| 31 |
+
- Use business language, avoid technical jargon where possible
|
| 32 |
+
- Focus on "what" and "why", not "how"
|
| 33 |
+
- Think from the end-user and stakeholder perspective
|
| 34 |
+
- Be clear and concise
|
| 35 |
+
- Use bullet points and sections for readability
|
| 36 |
+
- If certain information isn't present in the code, don't make assumptions - just document what's there
|
| 37 |
+
|
| 38 |
+
Generate the specification based on the actual code provided:
|
|
|
|
|
|
|
|
|
|
| 39 |
"""
|
| 40 |
|
| 41 |
+
DEV_SPECS_TEMPLATE = """You are a Senior Software Architect creating technical specifications.
|
| 42 |
+
|
| 43 |
+
Based on the following codebase context, create comprehensive developer specifications:
|
| 44 |
+
|
| 45 |
+
{context}
|
| 46 |
+
|
| 47 |
+
{query}
|
| 48 |
+
|
| 49 |
+
## Your Role:
|
| 50 |
+
You are an expert software architect and technical analyst. Your task is to analyze the provided code and create a comprehensive technical specification that captures the actual implementation, architecture, and functionality present in the code.
|
| 51 |
+
|
| 52 |
+
## Your Task:
|
| 53 |
+
Analyze the code deeply and document what's actually there. Focus on extracting and explaining:
|
| 54 |
+
|
| 55 |
+
**Core Implementation Details:**
|
| 56 |
+
- What is the actual architecture and structure of this code?
|
| 57 |
+
- What components, classes, functions, or modules are present?
|
| 58 |
+
- What design patterns or architectural approaches are used?
|
| 59 |
+
- What is the data flow and state management?
|
| 60 |
+
|
| 61 |
+
**File Dependencies & Relationships:**
|
| 62 |
+
- What files import or depend on other files in the codebase?
|
| 63 |
+
- What is the dependency hierarchy and module structure?
|
| 64 |
+
- Which files are entry points vs. utility/helper files?
|
| 65 |
+
- What shared modules or common dependencies exist?
|
| 66 |
+
- How do different parts of the codebase interact with each other?
|
| 67 |
+
- Are there circular dependencies or tightly coupled modules?
|
| 68 |
+
|
| 69 |
+
**Technical Functionality:**
|
| 70 |
+
- What specific features and capabilities does this code implement?
|
| 71 |
+
- What APIs, services, or external integrations are used?
|
| 72 |
+
- What data structures and models are defined?
|
| 73 |
+
- What business logic and algorithms are implemented?
|
| 74 |
+
|
| 75 |
+
**Key Technical Aspects:**
|
| 76 |
+
- Technology stack and frameworks used
|
| 77 |
+
- External dependencies and third-party libraries
|
| 78 |
+
- Internal module dependencies and imports
|
| 79 |
+
- Configuration and environment setup
|
| 80 |
+
- Error handling and validation logic
|
| 81 |
+
- Security considerations (if present)
|
| 82 |
+
- Performance optimizations (if present)
|
| 83 |
+
|
| 84 |
+
## Guidelines:
|
| 85 |
+
- **Be adaptive**: Structure your specification based on what's actually in the code
|
| 86 |
+
- **Extract real functionality**: Document what the code actually does, not what you think it should do
|
| 87 |
+
- **Be thorough but flexible**: Include all relevant technical details, but don't force information into predefined sections if it doesn't fit
|
| 88 |
+
- **Organize logically**: Group related functionality together in a way that makes sense for this specific codebase
|
| 89 |
+
- Use clear headings and bullet points for readability
|
| 90 |
+
- Include code examples where helpful
|
| 91 |
+
- Document APIs, services, and data structures as they appear in the code
|
| 92 |
+
- Note any assumptions or ambiguities you encounter
|
| 93 |
+
|
| 94 |
+
## Suggested Sections (use what's relevant):
|
| 95 |
+
- **Overview**: What this code does at a high level
|
| 96 |
+
- **Architecture**: Components, modules, services, and their relationships
|
| 97 |
+
- **File Structure & Dependencies**:
|
| 98 |
+
- Module organization and file hierarchy
|
| 99 |
+
- Import/export relationships between files
|
| 100 |
+
- Dependency graph (which files depend on which)
|
| 101 |
+
- Entry points and core modules
|
| 102 |
+
- Shared utilities and common dependencies
|
| 103 |
+
- **Key Features**: Main functionality implemented
|
| 104 |
+
- **Data Models**: Interfaces, types, classes defined
|
| 105 |
+
- **API Integration**: External services and endpoints used
|
| 106 |
+
- **Business Logic**: Key algorithms and workflows
|
| 107 |
+
- **State Management**: How data flows through the application
|
| 108 |
+
- **Configuration**: Environment variables, settings, feature flags
|
| 109 |
+
- **Technical Notes**: Important implementation details, patterns used
|
| 110 |
+
**Important**: Focus on extracting and documenting the actual meaning and functionality from the code. Don't force the code into predefined templates - let the code guide the structure of your specification.
|
| 111 |
+
**When documenting UI components or screens:**
|
| 112 |
+
- Describe the actual UI elements and their purpose
|
| 113 |
+
- Explain conditional logic (visibility, enabled/disabled states)
|
| 114 |
+
- Document event handlers and what they trigger
|
| 115 |
+
- Note any loading states or asynchronous operations
|
| 116 |
+
- Explain data binding and how data flows to the UI
|
| 117 |
+
**When documenting APIs and services:**
|
| 118 |
+
- List the service/API calls found in the code
|
| 119 |
+
- Document endpoints, HTTP methods, and parameters
|
| 120 |
+
- Describe request and response structures as they appear in the code
|
| 121 |
+
- Explain the purpose and context of each API call
|
| 122 |
+
- Note any error handling or retry logic
|
| 123 |
+
**When documenting components:**
|
| 124 |
+
- List inputs, outputs, and dependencies
|
| 125 |
+
- Explain initialization and lifecycle hooks
|
| 126 |
+
- Document key methods and their purpose
|
| 127 |
+
- Describe state management and data flow
|
| 128 |
+
- Note any important business logic or conditions
|
| 129 |
+
|
| 130 |
+
**When analyzing file dependencies:**
|
| 131 |
+
- Identify all import statements and what they import from
|
| 132 |
+
- Map out which files depend on which other files
|
| 133 |
+
- Note any external package dependencies
|
| 134 |
+
- Identify shared utilities or common modules used across multiple files
|
| 135 |
+
- Highlight the main entry points and how they connect to other modules
|
| 136 |
+
- Create a dependency flow showing how modules interact
|
| 137 |
+
- Note any potential issues like circular dependencies or tight coupling
|
| 138 |
+
|
| 139 |
+
## Analysis Approach:
|
| 140 |
+
- Analyze all provided code files thoroughly
|
| 141 |
+
- Map out the relationships and dependencies between files
|
| 142 |
+
- Extract the actual functionality, logic, and structure present
|
| 143 |
+
- Document what you find, not what you expect to find
|
| 144 |
+
- If information is incomplete, note what's present and what's missing
|
| 145 |
+
- Focus on understanding and explaining the code's purpose and behavior
|
| 146 |
+
- Pay special attention to how different files and modules work together
|
| 147 |
+
|
| 148 |
+
## Final Note:
|
| 149 |
+
Your goal is to create a clear, comprehensive technical specification that accurately reflects what's in the code. Be thorough, be accurate, and let the code guide your documentation structure.
|
| 150 |
+
|
| 151 |
+
Generate the technical specification now:
|
| 152 |
+
"""
|
| 153 |
|
| 154 |
+
USER_STORIES_TEMPLATE = """You are a Product Owner creating user stories from code.
|
| 155 |
|
| 156 |
+
Based on the following codebase context, create user stories:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
|
|
|
|
| 158 |
{context}
|
| 159 |
|
| 160 |
+
{query}
|
| 161 |
+
|
| 162 |
+
## Your Task:
|
| 163 |
+
Analyze the provided code and extract user-facing functionality to create meaningful user stories. Focus on understanding what users can do with this application based on the actual code implementation.
|
| 164 |
+
|
| 165 |
+
## What to Extract:
|
| 166 |
+
- User interactions and workflows present in the code
|
| 167 |
+
- Features and capabilities available to users
|
| 168 |
+
- User roles and permissions (if present)
|
| 169 |
+
- Business rules and validation logic
|
| 170 |
+
- User interface elements and their purpose
|
| 171 |
+
- Data that users can view, create, update, or delete
|
| 172 |
+
|
| 173 |
+
## User Story Format:
|
| 174 |
+
For each piece of user-facing functionality found, create a user story using this format:
|
| 175 |
+
|
| 176 |
+
**As a** [type of user]
|
| 177 |
+
**I want to** [perform some action]
|
| 178 |
+
**So that** [I can achieve some goal]
|
| 179 |
+
|
| 180 |
+
**Acceptance Criteria:**
|
| 181 |
+
- Given [context], when [action], then [expected result]
|
| 182 |
+
- [Additional criteria as needed]
|
| 183 |
|
| 184 |
+
## Guidelines:
|
| 185 |
+
- Base stories on actual functionality in the code, not assumptions
|
| 186 |
+
- Focus on user value and business outcomes
|
| 187 |
+
- Keep stories independent and testable
|
| 188 |
+
- Include relevant acceptance criteria from the code logic
|
| 189 |
+
- Group related stories by feature or workflow
|
| 190 |
+
- If user roles aren't explicit in the code, use generic "user" or infer from context
|
| 191 |
+
|
| 192 |
+
Generate user stories based on the actual code provided:
|
| 193 |
+
"""
|
| 194 |
+
|
| 195 |
+
def get_spec_template(spec_type: str) -> str:
|
| 196 |
+
"""Get the appropriate template for spec type"""
|
| 197 |
+
templates = {
|
| 198 |
+
'po_friendly': PO_FRIENDLY_TEMPLATE,
|
| 199 |
+
'dev_specs': DEV_SPECS_TEMPLATE,
|
| 200 |
+
'user_stories': USER_STORIES_TEMPLATE
|
| 201 |
+
}
|
| 202 |
+
return templates.get(spec_type, DEV_SPECS_TEMPLATE)
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
# =============================================================================
|
| 206 |
+
# EXISTING SYSTEM PROMPTS (Updated with CodeFalcon Style)
|
| 207 |
+
# =============================================================================
|
| 208 |
+
|
| 209 |
+
# Replacing SYSTEM_PROMPT_AGENT with a modified CHAT_SYSTEM_PROMPT
|
| 210 |
+
SYSTEM_PROMPT_AGENT = """You are Codebase Agent (powered by CodeFalcon intelligence), specialized in understanding and explaining codebases.
|
| 211 |
+
|
| 212 |
+
You are interacting with the codebase: {repo_name}
|
| 213 |
+
|
| 214 |
+
Your responsibilities:
|
| 215 |
+
1. Answer questions about the code clearly and accurately
|
| 216 |
+
2. Explain how features work based on the code
|
| 217 |
+
3. Help users understand architecture and design decisions
|
| 218 |
+
4. Provide code examples when helpful
|
| 219 |
+
5. Suggest improvements when asked
|
| 220 |
+
|
| 221 |
+
**CAPABILITIES**:
|
| 222 |
+
- **Code Analysis**: Explain logic, trace data flow, identifying patterns.
|
| 223 |
+
- **Tool Usage**: Use `search_codebase`, `read_file`, `find_callers` to retrieve context.
|
| 224 |
+
|
| 225 |
+
**Guidelines**:
|
| 226 |
+
- Be concise but thorough
|
| 227 |
+
- Use the retrieved code context to support your answers
|
| 228 |
+
- If you're not sure, say so - don't make up information
|
| 229 |
+
- Provide code examples from the actual codebase when relevant
|
| 230 |
+
- Explain technical concepts clearly
|
| 231 |
+
"""
|
| 232 |
+
|
| 233 |
+
# Replacing SYSTEM_PROMPT_LINEAR_RAG with CodeFalcon's CHAT_SYSTEM_PROMPT
|
| 234 |
+
# Note: Removed {chat_history} placeholder as it is handled by the message list
|
| 235 |
+
SYSTEM_PROMPT_LINEAR_RAG = """You are Codebase Agent (powered by CodeFalcon prompts), specialized in understanding and explaining codebases.
|
| 236 |
+
|
| 237 |
+
You have access to the codebase: {repo_name}
|
| 238 |
+
|
| 239 |
+
Your responsibilities:
|
| 240 |
+
1. Answer questions about the code clearly and accurately
|
| 241 |
+
2. Explain how features work based on the code
|
| 242 |
+
3. Help users understand architecture and design decisions
|
| 243 |
+
4. Provide code examples when helpful
|
| 244 |
+
5. Suggest improvements when asked
|
| 245 |
+
|
| 246 |
+
Guidelines:
|
| 247 |
+
- Be concise but thorough
|
| 248 |
+
- Use the retrieved code context to support your answers
|
| 249 |
+
- If you're not sure, say so - don't make up information
|
| 250 |
+
- Provide code examples from the actual codebase when relevant
|
| 251 |
+
- Explain technical concepts clearly
|
| 252 |
+
|
| 253 |
+
Retrieved code context:
|
| 254 |
+
{context}
|
| 255 |
"""
|
| 256 |
|
| 257 |
QUERY_EXPANSION_PROMPT = """Given a user question about a codebase, generate 3-5 diverse search queries optimized for semantic code search.
|
|
|
|
| 263 |
2. **Conceptual/Semantic**: High-level concepts, feature names, problem domains
|
| 264 |
3. **Related Systems**: Connected components, dependencies, integrations
|
| 265 |
4. **Configuration/Setup**: Environment setup, constants, configuration files
|
| 266 |
+
5. **Usage Examples**: Test files, example usage, API endpoints
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
|
| 268 |
**Output Format** (one query per line, no numbering):
|
| 269 |
[query 1]
|
| 270 |
[query 2]
|
| 271 |
[query 3]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
"""
|
| 273 |
|
| 274 |
ANSWER_SYNTHESIS_PROMPT = """Synthesize these search results into a concise answer.
|
|
|
|
| 287 |
Provide your answer:
|
| 288 |
"""
|
| 289 |
|
|
|
|
|
|
|
| 290 |
CODE_MODIFICATION_PROMPT = """You are suggesting code modifications for the codebase: {repo_name}.
|
| 291 |
|
| 292 |
**User Request:** {user_request}
|
|
|
|
| 303 |
|
| 304 |
**Output Format:**
|
| 305 |
## Implementation Approach
|
| 306 |
+
[Brief explanation]
|
| 307 |
|
| 308 |
## Code Changes
|
| 309 |
|
|
|
|
| 316 |
[your implementation with comments]
|
| 317 |
````
|
| 318 |
|
|
|
|
|
|
|
| 319 |
## Integration Notes
|
| 320 |
+
- [Configuration/Dependency updates]
|
|
|
|
| 321 |
- [Testing considerations]
|
|
|
|
|
|
|
|
|
|
| 322 |
"""
|
| 323 |
|
| 324 |
ARCHITECTURE_EXPLANATION_PROMPT = """Explain the architecture and design patterns used in {repo_name} for: {topic}
|
|
|
|
| 331 |
2. **Design Patterns**: Specific patterns used (MVC, Repository, Factory, etc.)
|
| 332 |
3. **Data Flow**: How information moves through the system
|
| 333 |
4. **Key Decisions**: Why this architecture was chosen
|
|
|
|
| 334 |
|
| 335 |
Format with clear sections and reference specific files.
|
| 336 |
"""
|
|
|
|
| 338 |
# =============================================================================
|
| 339 |
# GROQ-OPTIMIZED PROMPTS (For Llama and smaller models)
|
| 340 |
# =============================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
|
| 342 |
GROQ_SYSTEM_PROMPT_AGENT = """You are a code assistant for the repository: {repo_name}.
|
| 343 |
|
|
|
|
| 353 |
1. **Be Concise**: Get straight to the point.
|
| 354 |
2. **Cite Files**: Always mention file paths.
|
| 355 |
3. **Show Code**: Use snippets to prove your answer.
|
|
|
|
| 356 |
"""
|
| 357 |
|
| 358 |
GROQ_SYSTEM_PROMPT_LINEAR_RAG = """You are a code expert for: {repo_name}
|
|
|
|
| 370 |
"""
|
| 371 |
|
| 372 |
GROQ_QUERY_EXPANSION_PROMPT = """Turn this question into 3 search queries for a code search engine.
|
|
|
|
| 373 |
Question: {question}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
Output exactly 3 queries, one per line:
|
| 375 |
"""
|
| 376 |
|
| 377 |
GROQ_ANSWER_SYNTHESIS_PROMPT = """Combine these code search results into one clear answer.
|
|
|
|
| 378 |
USER QUESTION: {question}
|
|
|
|
| 379 |
SEARCH RESULTS:
|
| 380 |
{retrieved_context}
|
| 381 |
|
| 382 |
+
FORMAT:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
## Direct Answer
|
| 384 |
+
[Answer]
|
| 385 |
|
| 386 |
## Key Files
|
| 387 |
+
- `file.py`
|
|
|
|
| 388 |
|
| 389 |
## Main Code
|
| 390 |
```python
|
| 391 |
+
[snippet]
|
| 392 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
"""
|
| 394 |
|
| 395 |
GROQ_CODE_MODIFICATION_PROMPT = """You need to suggest code changes for: {repo_name}
|
|
|
|
| 396 |
USER REQUEST: {user_request}
|
|
|
|
| 397 |
EXISTING CODE:
|
| 398 |
{existing_code}
|
| 399 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 400 |
OUTPUT FORMAT:
|
|
|
|
| 401 |
## What I'll Change
|
| 402 |
+
[Summary]
|
| 403 |
|
| 404 |
## New Code
|
| 405 |
```python
|
| 406 |
# Add to: path/to/file.py
|
| 407 |
+
[code]
|
|
|
|
| 408 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 409 |
"""
|
| 410 |
|
| 411 |
# =============================================================================
|
|
|
|
| 413 |
# =============================================================================
|
| 414 |
|
| 415 |
def get_prompt_for_provider(prompt_name: str, provider: str = "gemini") -> str:
|
| 416 |
+
"""Get the appropriate prompt based on LLM provider."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 417 |
prompt_map = {
|
| 418 |
"system_agent": {
|
| 419 |
"gemini": SYSTEM_PROMPT_AGENT,
|
|
|
|
| 443 |
}
|
| 444 |
|
| 445 |
if prompt_name not in prompt_map:
|
| 446 |
+
# Fallback for specs
|
| 447 |
+
if prompt_name == "po_friendly": return PO_FRIENDLY_TEMPLATE
|
| 448 |
+
if prompt_name == "dev_specs": return DEV_SPECS_TEMPLATE
|
| 449 |
+
if prompt_name == "user_stories": return USER_STORIES_TEMPLATE
|
| 450 |
+
|
| 451 |
raise ValueError(f"Unknown prompt name: {prompt_name}")
|
| 452 |
|
| 453 |
prompts = prompt_map[prompt_name]
|
frontend/src/app/globals.css
CHANGED
|
@@ -2,53 +2,110 @@
|
|
| 2 |
|
| 3 |
/* Theme tokens */
|
| 4 |
@theme {
|
| 5 |
-
--color-background: #
|
| 6 |
--color-foreground: #E2E8F0;
|
| 7 |
-
--color-card: rgba(15, 23, 42, 0.
|
| 8 |
-
--color-
|
|
|
|
|
|
|
| 9 |
--color-secondary: #8B5CF6;
|
| 10 |
-
|
| 11 |
-
--color-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
}
|
| 14 |
|
|
|
|
|
|
|
|
|
|
| 15 |
body {
|
| 16 |
-
background:
|
| 17 |
color: var(--color-foreground);
|
| 18 |
-
font-family:
|
| 19 |
min-height: 100vh;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
}
|
| 21 |
|
| 22 |
/* Scrollbar */
|
| 23 |
::-webkit-scrollbar {
|
| 24 |
-
width:
|
| 25 |
-
height: 8px;
|
| 26 |
}
|
| 27 |
|
| 28 |
::-webkit-scrollbar-track {
|
| 29 |
-
background:
|
| 30 |
-
border-radius: 4px;
|
| 31 |
}
|
| 32 |
|
| 33 |
::-webkit-scrollbar-thumb {
|
| 34 |
-
background: rgba(
|
| 35 |
-
border-radius:
|
| 36 |
}
|
| 37 |
|
| 38 |
::-webkit-scrollbar-thumb:hover {
|
| 39 |
-
background: rgba(
|
| 40 |
}
|
| 41 |
|
| 42 |
-
/*
|
| 43 |
-
|
| 44 |
-
background:
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
}
|
| 50 |
|
| 51 |
-
|
| 52 |
-
font-family:
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
}
|
|
|
|
| 2 |
|
| 3 |
/* Theme tokens */
|
| 4 |
@theme {
|
| 5 |
+
--color-background: #030305;
|
| 6 |
--color-foreground: #E2E8F0;
|
| 7 |
+
--color-card: rgba(15, 23, 42, 0.4);
|
| 8 |
+
--color-card-border: rgba(255, 255, 255, 0.08);
|
| 9 |
+
--color-primary: #00F4FF;
|
| 10 |
+
/* Neon Cyan */
|
| 11 |
--color-secondary: #8B5CF6;
|
| 12 |
+
/* Electric Violet */
|
| 13 |
+
--color-accent: #FF00E6;
|
| 14 |
+
/* Magenta Glow */
|
| 15 |
+
--color-muted: #64748B;
|
| 16 |
+
|
| 17 |
+
--font-display: 'Space Grotesk', sans-serif;
|
| 18 |
+
--font-body: 'Inter', sans-serif;
|
| 19 |
+
|
| 20 |
+
--animate-aurora: aurora 10s infinite linear;
|
| 21 |
+
--animate-pulse-glow: pulse-glow 2s infinite ease-in-out;
|
| 22 |
}
|
| 23 |
|
| 24 |
+
/* Custom Fonts */
|
| 25 |
+
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');
|
| 26 |
+
|
| 27 |
body {
|
| 28 |
+
background-color: var(--color-background);
|
| 29 |
color: var(--color-foreground);
|
| 30 |
+
font-family: var(--font-body);
|
| 31 |
min-height: 100vh;
|
| 32 |
+
overflow-x: hidden;
|
| 33 |
+
position: relative;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/* Background Aurora Effect */
|
| 37 |
+
.bg-aurora {
|
| 38 |
+
position: fixed;
|
| 39 |
+
top: 0;
|
| 40 |
+
left: 0;
|
| 41 |
+
width: 100vw;
|
| 42 |
+
height: 100vh;
|
| 43 |
+
z-index: -1;
|
| 44 |
+
background:
|
| 45 |
+
radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 40%),
|
| 46 |
+
radial-gradient(circle at 90% 80%, rgba(0, 244, 255, 0.1) 0%, transparent 40%),
|
| 47 |
+
radial-gradient(ellipse at 50% 50%, rgba(3, 3, 5, 1) 20%, transparent 100%);
|
| 48 |
+
filter: blur(80px);
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/* Grain Overly for Texture */
|
| 52 |
+
.bg-grain {
|
| 53 |
+
position: fixed;
|
| 54 |
+
top: 0;
|
| 55 |
+
left: 0;
|
| 56 |
+
width: 100%;
|
| 57 |
+
height: 100%;
|
| 58 |
+
z-index: -1;
|
| 59 |
+
opacity: 0.03;
|
| 60 |
+
pointer-events: none;
|
| 61 |
+
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacit='1'/%3E%3C/svg%3E");
|
| 62 |
}
|
| 63 |
|
| 64 |
/* Scrollbar */
|
| 65 |
::-webkit-scrollbar {
|
| 66 |
+
width: 6px;
|
|
|
|
| 67 |
}
|
| 68 |
|
| 69 |
::-webkit-scrollbar-track {
|
| 70 |
+
background: transparent;
|
|
|
|
| 71 |
}
|
| 72 |
|
| 73 |
::-webkit-scrollbar-thumb {
|
| 74 |
+
background: rgba(255, 255, 255, 0.1);
|
| 75 |
+
border-radius: 10px;
|
| 76 |
}
|
| 77 |
|
| 78 |
::-webkit-scrollbar-thumb:hover {
|
| 79 |
+
background: rgba(255, 255, 255, 0.2);
|
| 80 |
}
|
| 81 |
|
| 82 |
+
/* Utilities */
|
| 83 |
+
.glass {
|
| 84 |
+
background: rgba(20, 20, 30, 0.4);
|
| 85 |
+
backdrop-filter: blur(12px);
|
| 86 |
+
-webkit-backdrop-filter: blur(12px);
|
| 87 |
+
border: 1px solid rgba(255, 255, 255, 0.05);
|
| 88 |
+
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
|
| 89 |
}
|
| 90 |
|
| 91 |
+
.text-display {
|
| 92 |
+
font-family: var(--font-display);
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
.text-glow {
|
| 96 |
+
text-shadow: 0 0 20px rgba(0, 244, 255, 0.5);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
@keyframes pulse-glow {
|
| 100 |
+
|
| 101 |
+
0%,
|
| 102 |
+
100% {
|
| 103 |
+
opacity: 0.5;
|
| 104 |
+
transform: scale(1);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
50% {
|
| 108 |
+
opacity: 1;
|
| 109 |
+
transform: scale(1.05);
|
| 110 |
+
}
|
| 111 |
}
|
frontend/src/app/layout.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { motion, AnimatePresence } from 'framer-motion';
|
|
| 4 |
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
| 5 |
import Link from 'next/link';
|
| 6 |
import { usePathname } from 'next/navigation';
|
|
|
|
| 7 |
import './globals.css';
|
| 8 |
|
| 9 |
const queryClient = new QueryClient();
|
|
@@ -15,28 +16,24 @@ export default function RootLayout({
|
|
| 15 |
}) {
|
| 16 |
return (
|
| 17 |
<html lang="en" className="dark">
|
| 18 |
-
<
|
| 19 |
-
<link
|
| 20 |
-
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"
|
| 21 |
-
rel="stylesheet"
|
| 22 |
-
/>
|
| 23 |
-
</head>
|
| 24 |
-
<body className="antialiased">
|
| 25 |
<QueryClientProvider client={queryClient}>
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
<Sidebar />
|
| 29 |
|
| 30 |
-
|
| 31 |
-
<main className="flex-1 flex flex-col">
|
| 32 |
<AnimatePresence mode="wait">
|
| 33 |
<motion.div
|
| 34 |
key="content"
|
| 35 |
-
initial={{ opacity: 0,
|
| 36 |
-
animate={{ opacity: 1,
|
| 37 |
-
exit={{ opacity: 0,
|
| 38 |
-
transition={{ duration: 0.
|
| 39 |
-
className="flex-1"
|
| 40 |
>
|
| 41 |
{children}
|
| 42 |
</motion.div>
|
|
@@ -49,65 +46,85 @@ export default function RootLayout({
|
|
| 49 |
);
|
| 50 |
}
|
| 51 |
|
| 52 |
-
// Sidebar Component
|
| 53 |
function Sidebar() {
|
| 54 |
const pathname = usePathname();
|
| 55 |
|
| 56 |
return (
|
| 57 |
<motion.aside
|
| 58 |
-
initial={{ x: -
|
| 59 |
animate={{ x: 0, opacity: 1 }}
|
| 60 |
-
|
| 61 |
-
className="w-64 bg-slate-900/60 backdrop-blur-xl border-r border-white/10 p-4 flex flex-col"
|
| 62 |
>
|
| 63 |
-
{/*
|
| 64 |
-
<div className="
|
| 65 |
-
<div className="
|
| 66 |
-
<
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
</
|
| 72 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
</div>
|
| 74 |
</div>
|
| 75 |
|
| 76 |
-
{/*
|
| 77 |
-
<nav className="flex-1 space-y-2">
|
| 78 |
-
<NavItem href="/" icon=
|
| 79 |
-
<NavItem href="/chat" icon=
|
| 80 |
-
<NavItem href="/search" icon=
|
| 81 |
-
<
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
| 83 |
</nav>
|
| 84 |
|
| 85 |
{/* Footer */}
|
| 86 |
-
<div className="
|
| 87 |
-
<div className="
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
</div>
|
| 90 |
</div>
|
| 91 |
</motion.aside>
|
| 92 |
);
|
| 93 |
}
|
| 94 |
|
| 95 |
-
function NavItem({ href, icon, label, active }: { href: string; icon:
|
| 96 |
return (
|
| 97 |
<Link href={href}>
|
| 98 |
-
<
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
:
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
<
|
| 107 |
-
|
| 108 |
-
{
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
</Link>
|
| 112 |
);
|
| 113 |
}
|
|
|
|
| 4 |
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
| 5 |
import Link from 'next/link';
|
| 6 |
import { usePathname } from 'next/navigation';
|
| 7 |
+
import { LayoutGrid, MessageSquare, Search, Box, Sparkles, FolderOpen } from 'lucide-react';
|
| 8 |
import './globals.css';
|
| 9 |
|
| 10 |
const queryClient = new QueryClient();
|
|
|
|
| 16 |
}) {
|
| 17 |
return (
|
| 18 |
<html lang="en" className="dark">
|
| 19 |
+
<body className="antialiased selection:bg-cyan-500/30">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
<QueryClientProvider client={queryClient}>
|
| 21 |
+
{/* Ambient Backgrounds */}
|
| 22 |
+
<div className="bg-aurora" />
|
| 23 |
+
<div className="bg-grain" />
|
| 24 |
+
|
| 25 |
+
<div className="min-h-screen flex text-slate-200 font-sans">
|
| 26 |
<Sidebar />
|
| 27 |
|
| 28 |
+
<main className="flex-1 flex flex-col relative z-10 overflow-hidden">
|
|
|
|
| 29 |
<AnimatePresence mode="wait">
|
| 30 |
<motion.div
|
| 31 |
key="content"
|
| 32 |
+
initial={{ opacity: 0, filter: 'blur(10px)' }}
|
| 33 |
+
animate={{ opacity: 1, filter: 'blur(0px)' }}
|
| 34 |
+
exit={{ opacity: 0, filter: 'blur(10px)' }}
|
| 35 |
+
transition={{ duration: 0.4, ease: [0.22, 1, 0.36, 1] }}
|
| 36 |
+
className="flex-1 flex flex-col"
|
| 37 |
>
|
| 38 |
{children}
|
| 39 |
</motion.div>
|
|
|
|
| 46 |
);
|
| 47 |
}
|
| 48 |
|
|
|
|
| 49 |
function Sidebar() {
|
| 50 |
const pathname = usePathname();
|
| 51 |
|
| 52 |
return (
|
| 53 |
<motion.aside
|
| 54 |
+
initial={{ x: -20, opacity: 0 }}
|
| 55 |
animate={{ x: 0, opacity: 1 }}
|
| 56 |
+
className="w-[280px] glass h-screen sticky top-0 flex flex-col border-r border-white/5 z-20"
|
|
|
|
| 57 |
>
|
| 58 |
+
{/* Brand */}
|
| 59 |
+
<div className="p-8">
|
| 60 |
+
<div className="flex items-center gap-3">
|
| 61 |
+
<div className="relative">
|
| 62 |
+
<div className="w-10 h-10 rounded-xl bg-gradient-to-tr from-cyan-500 to-violet-600 flex items-center justify-center shadow-lg shadow-cyan-500/20">
|
| 63 |
+
<span className="text-xl">🦅</span>
|
| 64 |
+
</div>
|
| 65 |
+
<div className="absolute inset-0 bg-cyan-400 blur-lg opacity-40 animate-pulse" />
|
| 66 |
+
</div>
|
| 67 |
+
<div>
|
| 68 |
+
<h1 className="font-bold text-lg text-white tracking-tight font-display">
|
| 69 |
+
CodeFalcon
|
| 70 |
+
</h1>
|
| 71 |
+
<p className="text-[10px] uppercase tracking-widest text-cyan-400 font-semibold">
|
| 72 |
+
Agent V2.0
|
| 73 |
+
</p>
|
| 74 |
+
</div>
|
| 75 |
</div>
|
| 76 |
</div>
|
| 77 |
|
| 78 |
+
{/* Nav */}
|
| 79 |
+
<nav className="flex-1 px-4 space-y-2">
|
| 80 |
+
<NavItem href="/" icon={<LayoutGrid size={20} />} label="Overview" active={pathname === '/'} />
|
| 81 |
+
<NavItem href="/chat" icon={<MessageSquare size={20} />} label="Agent Chat" active={pathname === '/chat'} />
|
| 82 |
+
<NavItem href="/search" icon={<Search size={20} />} label="Deep Search" active={pathname === '/search'} />
|
| 83 |
+
<nav className="mt-8 px-4 text-xs font-semibold text-slate-500 uppercase tracking-wider">
|
| 84 |
+
Tools
|
| 85 |
+
</nav>
|
| 86 |
+
<NavItem href="/refactor" icon={<Box size={20} />} label="Refactor" active={pathname === '/refactor'} />
|
| 87 |
+
<NavItem href="/generate" icon={<Sparkles size={20} />} label="Generate" active={pathname === '/generate'} />
|
| 88 |
</nav>
|
| 89 |
|
| 90 |
{/* Footer */}
|
| 91 |
+
<div className="p-6 border-t border-white/5">
|
| 92 |
+
<div className="flex items-center gap-3 p-3 rounded-lg bg-white/5 border border-white/5">
|
| 93 |
+
<div className="w-8 h-8 rounded-full bg-gradient-to-r from-slate-700 to-slate-600 flex items-center justify-center text-xs">
|
| 94 |
+
JD
|
| 95 |
+
</div>
|
| 96 |
+
<div className="flex-1 min-w-0">
|
| 97 |
+
<p className="text-sm font-medium text-white truncate">Connected</p>
|
| 98 |
+
<p className="text-xs text-emerald-400">● Online</p>
|
| 99 |
+
</div>
|
| 100 |
</div>
|
| 101 |
</div>
|
| 102 |
</motion.aside>
|
| 103 |
);
|
| 104 |
}
|
| 105 |
|
| 106 |
+
function NavItem({ href, icon, label, active }: { href: string; icon: React.ReactNode; label: string; active: boolean }) {
|
| 107 |
return (
|
| 108 |
<Link href={href}>
|
| 109 |
+
<div className="relative group">
|
| 110 |
+
{active && (
|
| 111 |
+
<motion.div
|
| 112 |
+
layoutId="activeNav"
|
| 113 |
+
className="absolute inset-0 bg-gradient-to-r from-cyan-500/10 to-violet-500/10 rounded-xl border border-cyan-500/20"
|
| 114 |
+
transition={{ type: "spring", stiffness: 300, damping: 30 }}
|
| 115 |
+
/>
|
| 116 |
+
)}
|
| 117 |
+
<div className={`
|
| 118 |
+
relative flex items-center gap-3 px-4 py-3 rounded-xl transition-all duration-300
|
| 119 |
+
${active ? 'text-cyan-400' : 'text-slate-400 group-hover:text-slate-200 group-hover:bg-white/5'}
|
| 120 |
+
`}>
|
| 121 |
+
{icon}
|
| 122 |
+
<span className="font-medium">{label}</span>
|
| 123 |
+
{active && (
|
| 124 |
+
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-cyan-400 shadow-[0_0_8px_rgba(34,211,238,0.8)]" />
|
| 125 |
+
)}
|
| 126 |
+
</div>
|
| 127 |
+
</div>
|
| 128 |
</Link>
|
| 129 |
);
|
| 130 |
}
|
pages/1_⚡_Code_Studio.py
CHANGED
|
@@ -46,7 +46,12 @@ with col_panel:
|
|
| 46 |
)
|
| 47 |
|
| 48 |
st.divider()
|
| 49 |
-
if st.button("🏠
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
st.switch_page("app.py")
|
| 51 |
|
| 52 |
with tab_search:
|
|
|
|
| 46 |
)
|
| 47 |
|
| 48 |
st.divider()
|
| 49 |
+
if st.button("🏠 Index New Codebase", use_container_width=True):
|
| 50 |
+
st.session_state.processed_files = False
|
| 51 |
+
st.session_state.chat_engine = None
|
| 52 |
+
st.session_state.indexed_files = None
|
| 53 |
+
st.session_state.workspace_root = None
|
| 54 |
+
st.session_state.selected_file = None
|
| 55 |
st.switch_page("app.py")
|
| 56 |
|
| 57 |
with tab_search:
|
update_imports.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import re
|
| 3 |
+
|
| 4 |
+
# Mapping of old imports to new imports
|
| 5 |
+
# Format: "old_module": "new_module"
|
| 6 |
+
# We'll use regex to match "from old_module" and "import old_module"
|
| 7 |
+
replacements = {
|
| 8 |
+
# Services
|
| 9 |
+
"code_chatbot.ast_analysis": "backend.app.services.ast_analysis",
|
| 10 |
+
"code_chatbot.rag": "backend.app.services.rag_engine",
|
| 11 |
+
"code_chatbot.indexer": "backend.app.services.indexer",
|
| 12 |
+
"code_chatbot.agent_workflow": "backend.app.services.agent_workflow",
|
| 13 |
+
"code_chatbot.llm_retriever": "backend.app.services.llm_retriever",
|
| 14 |
+
"code_chatbot.graph_rag": "backend.app.services.graph_rag",
|
| 15 |
+
"code_chatbot.db_connection": "backend.app.services.db_connection",
|
| 16 |
+
"code_chatbot.mcp_server": "backend.app.services.mcp_server",
|
| 17 |
+
"code_chatbot.mcp_client": "backend.app.services.mcp_client",
|
| 18 |
+
|
| 19 |
+
# Utils
|
| 20 |
+
"code_chatbot.chunker": "backend.app.utils.chunking",
|
| 21 |
+
"code_chatbot.tools": "backend.app.utils.tools",
|
| 22 |
+
"code_chatbot.universal_ingestor": "backend.app.utils.universal_ingestor",
|
| 23 |
+
"code_chatbot.rate_limiter": "backend.app.utils.rate_limiter",
|
| 24 |
+
"code_chatbot.prompts": "backend.app.utils.prompts",
|
| 25 |
+
"code_chatbot.path_obfuscator": "backend.app.utils.path_obfuscator",
|
| 26 |
+
"code_chatbot.merkle_tree": "backend.app.utils.merkle_tree",
|
| 27 |
+
"code_chatbot.indexing_progress": "backend.app.utils.indexing_progress",
|
| 28 |
+
"code_chatbot.reranker": "backend.app.utils.reranker",
|
| 29 |
+
"code_chatbot.retriever_wrapper": "backend.app.utils.retriever_wrapper",
|
| 30 |
+
|
| 31 |
+
# Models
|
| 32 |
+
"code_chatbot.code_symbols": "backend.app.models.code_symbols",
|
| 33 |
+
|
| 34 |
+
# Config
|
| 35 |
+
"code_chatbot.config": "backend.app.config",
|
| 36 |
+
|
| 37 |
+
# Routers - careful with regex here
|
| 38 |
+
"api.routes.chat": "backend.app.routers.chat",
|
| 39 |
+
"api.routes.health": "backend.app.routers.health",
|
| 40 |
+
"api.routes.index": "backend.app.routers.index",
|
| 41 |
+
|
| 42 |
+
# Catch-all for other api/code_chatbot imports if any remain
|
| 43 |
+
# "code_chatbot": "backend.app", # Too risky? Maybe specific modules first
|
| 44 |
+
|
| 45 |
+
# Internal Relative Imports Fix (harder, but let's try absolute first)
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
# Directories to scan
|
| 49 |
+
scan_dirs = ["backend/app", "tests"]
|
| 50 |
+
if os.path.exists("app.py"):
|
| 51 |
+
scan_dirs.append("app.py")
|
| 52 |
+
|
| 53 |
+
for root_path in scan_dirs:
|
| 54 |
+
if os.path.isfile(root_path):
|
| 55 |
+
files = [root_path]
|
| 56 |
+
root = os.path.dirname(root_path)
|
| 57 |
+
else:
|
| 58 |
+
files = []
|
| 59 |
+
for r, d, f in os.walk(root_path):
|
| 60 |
+
for file in f:
|
| 61 |
+
if file.endswith(".py"):
|
| 62 |
+
files.append(os.path.join(r, file))
|
| 63 |
+
|
| 64 |
+
for file_path in files:
|
| 65 |
+
with open(file_path, "r") as f:
|
| 66 |
+
content = f.read()
|
| 67 |
+
|
| 68 |
+
original_content = content
|
| 69 |
+
|
| 70 |
+
for old, new in replacements.items():
|
| 71 |
+
# Replace "from X import Y"
|
| 72 |
+
content = re.sub(f"from {old}([ .])", f"from {new}\\1", content)
|
| 73 |
+
content = re.sub(f"from {old}$", f"from {new}", content) # End of line
|
| 74 |
+
|
| 75 |
+
# Replace "import X"
|
| 76 |
+
content = re.sub(f"import {old}([ .])", f"import {new}\\1", content)
|
| 77 |
+
content = re.sub(f"import {old}$", f"import {new}", content)
|
| 78 |
+
|
| 79 |
+
if content != original_content:
|
| 80 |
+
print(f"Updating imports in {file_path}")
|
| 81 |
+
with open(file_path, "w") as f:
|
| 82 |
+
f.write(content)
|
| 83 |
+
|
| 84 |
+
print("Import update script completed.")
|