Skip to content

Commit 62d0f00

Browse files
committed
Fixed builds.
1 parent 315d560 commit 62d0f00

File tree

34 files changed

+1885
-1637
lines changed

34 files changed

+1885
-1637
lines changed

compose.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
services:
33
repository-manager-mcp:
4-
image: docker.io/knucklessg1/repository-manager:latest
5-
# build:
6-
# context: . # Debug
7-
# dockerfile: debug.Dockerfile
4+
# image: docker.io/knucklessg1/repository-manager:latest
5+
build:
6+
context: . # Debug
7+
dockerfile: debug.Dockerfile
88
container_name: repository-manager-mcp
99
hostname: repository-manager-mcp
1010
command: [ "repository-manager-mcp" ]
@@ -23,25 +23,25 @@ services:
2323
environment:
2424
- "PYTHONUNBUFFERED=1"
2525
- "HOST=0.0.0.0"
26-
- "PORT=8017"
26+
- "PORT=8047"
2727
- "TRANSPORT=streamable-http"
2828
- "REPOSITORY_MANAGER_WORKSPACE=/workspace"
2929
- "REPOSITORY_MANAGER_THREADS=12"
3030
- "REPOSITORY_MANAGER_DEFAULT_BRANCH=True"
3131
ports:
32-
- "8017:8017"
32+
- "8047:8047"
3333
healthcheck:
34-
test: [ "CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8017/health')" ]
34+
test: [ "CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8047/health')" ]
3535
interval: 30s
3636
timeout: 10s
3737
retries: 3
3838
start_period: 10s
3939

4040
repository-manager-agent:
41-
image: docker.io/knucklessg1/repository-manager:latest
42-
# build:
43-
# context: . # Debug
44-
# dockerfile: debug.Dockerfile
41+
# image: docker.io/knucklessg1/repository-manager:latest
42+
build:
43+
context: . # Debug
44+
dockerfile: debug.Dockerfile
4545
container_name: repository-manager-agent
4646
hostname: repository-manager-agent
4747
command: [ "repository-manager-agent" ]
@@ -60,12 +60,11 @@ services:
6060
restart: always
6161
env_file:
6262
- .env
63-
6463
environment:
6564
- "PYTHONUNBUFFERED=1"
6665
- "HOST=0.0.0.0"
67-
- "PORT=9017"
68-
- "MCP_URL=http://repository-manager-mcp:8017/mcp"
66+
- "PORT=9047"
67+
- "MCP_URL=http://repository-manager-mcp:8047/mcp"
6968
- "PROVIDER=openai"
7069
- "LLM_BASE_URL=${LLM_BASE_URL:-http://host.docker.internal:1234/v1}"
7170
- "LLM_API_KEY=${LLM_API_KEY:-llama}"
@@ -74,9 +73,9 @@ services:
7473
- "ENABLE_WEB_UI=True"
7574
- "REPOSITORY_MANAGER_WORKSPACE=/workspace"
7675
ports:
77-
- "9017:9017"
76+
- "9047:9047"
7877
healthcheck:
79-
test: [ "CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:9017/health')" ]
78+
test: [ "CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:9047/health')" ]
8079
interval: 30s
8180
timeout: 10s
8281
retries: 3

repository_manager/mcp_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"mcpServers": {
33
"repository-manager": {
4-
"url": "${MCP_URL:-http://localhost:8007/mcp}",
4+
"url": "${MCP_URL:-http://repository-manager-mcp:8017/mcp}",
55
"timeout": 300000
66
}
77
}

repository_manager/models.py

Lines changed: 113 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,42 @@
1-
import os
21
import json
3-
from typing import List, Optional
2+
3+
from typing import List, Optional, Any, Union
44
from pydantic import BaseModel, Field, field_validator
55

66

7+
class AgentResponse(BaseModel):
8+
thoughts: str = Field(
9+
..., description="Your internal reasoning and analysis of the situation."
10+
)
11+
plan: List[str] = Field(
12+
..., description="A step-by-step checklist of what you are about to do."
13+
)
14+
action_taken: str = Field(
15+
..., description="Summary of the actual tool calls or actions performed."
16+
)
17+
final_output: str = Field(..., description="The response to the user.")
18+
19+
20+
class StepResult(BaseModel):
21+
"""Generic container for agent steps."""
22+
23+
thoughts: str
24+
plan: List[str]
25+
output: Any
26+
27+
28+
class PlanStepResult(BaseModel):
29+
thoughts: str
30+
plan: List[str]
31+
output: Union["ImplementationPlan", "Clarification", "Task", str]
32+
33+
34+
class TaskStepResult(BaseModel):
35+
thoughts: str
36+
plan: List[str]
37+
output: "Task"
38+
39+
740
class Task(BaseModel):
841
id: int = Field(..., description="Unique identifier for the task, e.g. 1, 2, 3")
942
description: str = Field(
@@ -12,20 +45,19 @@ class Task(BaseModel):
1245
acceptance_criteria: List[str] = Field(
1346
..., description="List of testable conditions for completion"
1447
)
15-
passes: bool = Field(
16-
default=False, description="Flag indicating if the task is complete"
17-
)
1848
dependencies: Optional[List[int]] = Field(
1949
default=None, description="List of other task IDs this depends on"
2050
)
2151
notes: Optional[str] = Field(
22-
default=None, description="Additional notes or learnings from the agent"
52+
default=None,
53+
description="Learnings and findings from the agent from their work on this task",
2354
)
24-
priority: Optional[str] = Field(
25-
default=None, description="Priority level: high, medium, low"
55+
attempt_count: int = Field(
56+
default=0, description="Number of attempts made to complete this task"
2657
)
27-
execution_history: List[str] = Field(
28-
default_factory=list, description="Log of tool calls and execution steps"
58+
status: str = Field(
59+
default="pending",
60+
description="Status: pending, in_progress, implemented, verified, failed",
2961
)
3062

3163
@field_validator("dependencies", mode="before")
@@ -64,62 +96,92 @@ def ensure_list_of_strings(cls, v):
6496
return [v]
6597

6698

67-
class PRD(BaseModel):
68-
project: str = Field(
69-
...,
70-
description="The name of the project. This will also be used as the folder in the workspace. (Always lowercase)",
71-
)
72-
workspace: Optional[str] = Field(
73-
default=os.environ.get("REPOSITORY_MANAGER_WORKSPACE", "/documents"),
74-
description="The workspace location of the project",
75-
)
99+
class ImplementationPlan(BaseModel):
76100
summary: str = Field(
77-
default="", description="High-level summary of the project/feature"
78-
)
79-
description: str = Field(
80-
default="", description="Detailed description of the project/feature"
101+
default="", description="High-level summary of the implementation plan"
81102
)
103+
description: str = Field(default="", description="Detailed description of the plan")
82104
guardrails: List[str] = Field(
83105
default_factory=list, description="Global rules or constraints"
84106
)
85-
stories: List[Task] = Field(..., description="List of tasks/stories")
107+
tasks: List[Task] = Field(..., description="List of tasks to implement")
86108
iteration_count: int = Field(
87109
default=0, description="Number of iterations completed"
88110
)
89111

90-
@field_validator("stories", mode="before")
91-
def ensure_list_stories(cls, v):
112+
@field_validator("tasks", mode="before")
113+
def ensure_list_tasks(cls, v):
92114
if isinstance(v, list):
93115
return v
94116
return [v]
95117

96-
@field_validator("project", mode="before")
97-
def ensure_project_lowercase(cls, v):
98-
if isinstance(v, str):
99-
return v.lower()
100-
else:
101-
return str(v).lower()
102-
103118
def is_complete(self) -> bool:
104-
"""Check if all tasks are marked as passed."""
105-
return all(task.passes for task in self.stories)
106-
107-
def get_next_task(self) -> Optional[Task]:
108-
"""Get the next undone task that has all dependencies satisfied."""
109-
for task in self.stories:
110-
if not task.passes:
111-
if task.dependencies is None or all(
112-
self.stories[dep - 1].passes
113-
for dep in task.dependencies
114-
if dep - 1 < len(self.stories)
115-
):
116-
return task
117-
return None
118-
119-
120-
class ElicitationRequest(BaseModel):
119+
"""Check if all tasks are marked as verified."""
120+
return all(task.status == "verified" for task in self.tasks)
121+
122+
def get_next_tasks(self) -> List[Task]:
123+
"""Get all runnable tasks that have dependencies satisfied."""
124+
runnable = []
125+
completed_ids = {t.id for t in self.tasks if t.status == "verified"}
126+
127+
for task in self.tasks:
128+
if task.status not in ["verified", "in_progress", "implemented"]:
129+
# Check dependencies
130+
deps_met = True
131+
if task.dependencies:
132+
for dep_id in task.dependencies:
133+
if dep_id not in completed_ids:
134+
deps_met = False
135+
break
136+
if deps_met:
137+
runnable.append(task)
138+
return runnable
139+
140+
def to_markdown(self) -> str:
141+
"""Generate a markdown representation of the implementation plan."""
142+
md = []
143+
md.append(f"# Implementation Plan - {self.iteration_count} Iterations\n")
144+
md.append(f"**Summary:** {self.summary}\n")
145+
md.append(f"**Description:** {self.description}\n")
146+
147+
if self.guardrails:
148+
md.append("## Guardrails")
149+
for g in self.guardrails:
150+
md.append(f"- {g}")
151+
md.append("")
152+
153+
md.append("## Tasks")
154+
for task in self.tasks:
155+
status_icon = {
156+
"pending": "⏳",
157+
"in_progress": "🚧",
158+
"implemented": "✅",
159+
"verified": "🏁",
160+
"failed": "❌",
161+
}.get(task.status, "❓")
162+
163+
md.append(f"### {status_icon} Task {task.id}: {task.description}")
164+
md.append(f"**Status:** {task.status} | **Attempts:** {task.attempt_count}")
165+
166+
if task.dependencies:
167+
md.append(f"**Dependencies:** {task.dependencies}")
168+
169+
if task.acceptance_criteria:
170+
md.append("**Acceptance Criteria:**")
171+
for ac in task.acceptance_criteria:
172+
md.append(f"- {ac}")
173+
174+
if task.notes:
175+
md.append(f"\n**Notes:**\n{task.notes}")
176+
177+
md.append("\n---")
178+
179+
return "\n".join(md)
180+
181+
182+
class Clarification(BaseModel):
121183
"""
122-
Represents a request for more information from the user (Product Manager -> User).
184+
Represents a request for clarification from the user (Architect -> User).
123185
"""
124186

125187
question: str = Field(..., description="The question to ask the user.")

repository_manager/prompts.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
CORE_SYSTEM_PROMPT = """
2+
You are an elite Software Systems Architect and Engineer. You are not just a coding assistant; you are an autonomous agent responsible for the end-to-end quality, maintainability, and correctness of the code you write.
3+
4+
# 1. Operational Philosophy
5+
- **Thoughtfulness over Speed**: Do not rush to write code. deep understanding of the existing system is required before any modification.
6+
- **Verification is Mandatory**: Never assume your code works. You must verify every change with concrete evidence (running tests, executing the script, checking logs).
7+
- **Manage your Context**: You are responsible for maintaining a clear mental model of the task. Break down complex user requests into smaller, manageable steps.
8+
9+
# 2. The Implementation Protocol
10+
You must follow this strict protocol for every non-trivial task:
11+
12+
## Phase 1: Exploration & Planning
13+
1. **Analyze**: Read the relevant files to understand the current state. Do not guess file contents.
14+
2. **Plan**: Before writing any code, formulate a clear `Implementation Plan`. This plan should detail:
15+
- Files to be modified.
16+
- New dependencies or functions required.
17+
- Potential risks or breaking changes.
18+
- A step-by-step verification strategy.
19+
20+
## Phase 2: Execution
21+
1. **Incremental Changes**: Make small, focussed edits. Avoid rewriting entire files unless necessary.
22+
2. **Linting & Style**: Adhere to the project's existing coding standards (formatting, typing, docstrings).
23+
3. **Safety**: Do not delete code without understanding who uses it.
24+
25+
## Phase 3: Verification
26+
1. **Prove It**: You must run the code you just wrote.
27+
2. **Debug**: If it fails, read the error, analyze the cause, fix it, and try again. Do not ask the user for help unless you are truly stuck.
28+
3. **Cleanup**: Remove any temporary test files or debug artifacts you created.
29+
30+
# 3. Communication Style
31+
- **Be Concise but Complete**: Use Markdown. Use headings.
32+
- **Reference Files**: Always reference files using the `[basename](path)` format.
33+
- **Show Your Work**: When you make a decision, briefly explain *why* (e.g., "I chose `httpx` over `requests` because we need async support").
34+
- **Transparency**: If you are unsure, admit it and propose a way to find out (e.g., "I need to check the documentation for X before proceeding").
35+
36+
# 4. Tool Usage Rules
37+
- **File Reading**: Always read the file before editing it to ensure you have the latest version.
38+
- **Command Execution**: When running commands, assume you are in a standard Linux environment. catch stderr output.
39+
"""
40+
41+
ARCHITECT_SYSTEM_PROMPT = """
42+
You are the Chief Architect.
43+
Your Goal: Design a robust, scalable technical solution and create a detailed Implementation Plan.
44+
45+
Capabilities:
46+
- **Design**: Analyze user requests and existing codebase to design the best solution.
47+
- **Plan**: Create a comprehensive `ImplementationPlan` with clear, independent `Tasks`.
48+
- **Review**: Review the plan with the user (`Clarification`) if requirements are ambiguous.
49+
50+
Process:
51+
1. **Analyze**: Understand the request. Check `list_projects` to see if the project exists.
52+
2. **Draft Plan**: Create an `ImplementationPlan` object.
53+
- `summary` should be a concise title for the work (e.g., "Refactor Auth Layer").
54+
- `description` should provide technical context and goals.
55+
- `tasks` should be granular and independent where possible to allow parallel execution.
56+
- Define strict `guardrails` and `acceptance_criteria` for each task.
57+
3. **Refine**: If you need user input, return a `Clarification` object.
58+
4. **Finalize**: Return the approved `ImplementationPlan`. DO NOT return a string representation of the plan. Return the object itself.
59+
"""
60+
61+
ENGINEER_SYSTEM_PROMPT = """
62+
You are a Senior Software Engineer.
63+
Your Goal: Implement a single `Task` from the `ImplementationPlan` with high quality and speed.
64+
65+
Workflow:
66+
1. **Context**: You receive a specific `Task` and the overall `ImplementationPlan`.
67+
2. **Explore**:
68+
- Use `search_codebase` to find relevant code patterns.
69+
- Use `find_files` to locate specific files.
70+
- Use `read_file` to understand the current implementation.
71+
3. **Develop**:
72+
- Use `text_editor` (create) for new files.
73+
- Use `replace_in_file` for safe, surgical edits to existing files.
74+
- Use `git_action` (or specialized tools) to manage the repository.
75+
- Use `run_pre_commit` to ensure code quality.
76+
4. **Self-Correction**:
77+
- If a step fails, debug it immediately.
78+
- Do not return `passes=True` until you are confident.
79+
5. **Documentation**:
80+
- Update README.md or other documentation as part of your task if relevant.
81+
82+
Output:
83+
- Return the updated `Task` object.
84+
- Provide a summary of your work in the `notes` field.
85+
- Ensure the task is fully implemented.
86+
"""
87+
88+
QA_SYSTEM_PROMPT = """
89+
You are the Lead QA Engineer.
90+
Your Goal: strictly verify that a completed `Task` meets its `acceptance_criteria`.
91+
92+
Workflow:
93+
1. **Inspect**: Read the code changes made by the Engineer.
94+
2. **Verify**:
95+
- Run tests (if available).
96+
- Run the code/script manually to prove it works.
97+
- Check `run_pre_commit` status.
98+
3. **Report**:
99+
- If successful, set `status="verified"`.
100+
- If failed, set `status="failed"` and provide detailed `notes` on what failed and how to fix it.
101+
"""

0 commit comments

Comments
 (0)