Skip to content

Commit 0ced6b8

Browse files
author
mcp-release-bot
committed
fmt
1 parent 31f99b2 commit 0ced6b8

File tree

1 file changed

+111
-55
lines changed

1 file changed

+111
-55
lines changed

src/mcp_as_a_judge/workflow/workflow_guidance.py

Lines changed: 111 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ class PlanRequiredField(BaseModel):
6969
required: bool = Field(description="Whether this field is required")
7070
conditional_on: str | None = Field(
7171
default=None,
72-
description="Task metadata field this requirement depends on (e.g., 'design_patterns_enforcement')",
72+
description=(
73+
"Task metadata field this requirement depends on "
74+
"(e.g., 'design_patterns_enforcement')"
75+
),
7376
)
7477
example_value: str | None = Field(
7578
default=None, description="Example of what this field should contain"
@@ -94,43 +97,67 @@ class WorkflowGuidance(BaseModel):
9497
)
9598
preparation_needed: list[str] = Field(
9699
default_factory=list,
97-
description="List of things that need to be prepared before calling the recommended tool",
100+
description=(
101+
"List of things that need to be prepared before calling the "
102+
"recommended tool"
103+
),
98104
)
99105
guidance: str = Field(
100106
default="",
101107
description="Detailed step-by-step guidance for the AI assistant",
102108
)
103109

104-
# Research requirement determination for new tasks (only populated when task is CREATED)
110+
# Research requirement determination for new tasks
111+
# (only populated when task is CREATED)
105112
research_required: bool | None = Field(
106113
default=None,
107-
description="Whether research is required for this task (only determined for new CREATED tasks)",
114+
description=(
115+
"Whether research is required for this task "
116+
"(only determined for new CREATED tasks)"
117+
),
108118
)
109119
research_scope: str | None = Field(
110120
default=None,
111-
description="Research scope: 'none', 'light', or 'deep' (only determined for new CREATED tasks)",
121+
description=(
122+
"Research scope: 'none', 'light', or 'deep' "
123+
"(only determined for new CREATED tasks)"
124+
),
112125
)
113126
research_rationale: str | None = Field(
114127
default=None,
115-
description="Explanation of research requirements (only determined for new CREATED tasks)",
128+
description=(
129+
"Explanation of research requirements "
130+
"(only determined for new CREATED tasks)"
131+
),
116132
)
117133
internal_research_required: bool | None = Field(
118134
default=None,
119-
description="Whether internal codebase analysis is needed (only determined for new CREATED tasks)",
135+
description=(
136+
"Whether internal codebase analysis is needed "
137+
"(only determined for new CREATED tasks)"
138+
),
120139
)
121140
risk_assessment_required: bool | None = Field(
122141
default=None,
123-
description="Whether risk assessment is needed (only determined for new CREATED tasks)",
142+
description=(
143+
"Whether risk assessment is needed (only determined for new CREATED tasks)"
144+
),
124145
)
125146
design_patterns_enforcement: bool | None = Field(
126147
default=None,
127-
description="Whether design patterns are required (only determined for new CREATED tasks)",
148+
description=(
149+
"Whether design patterns are required "
150+
"(only determined for new CREATED tasks)"
151+
),
128152
)
129153

130-
# Structured plan requirements for judge_coding_plan (only populated when next_tool is judge_coding_plan)
154+
# Structured plan requirements for judge_coding_plan
155+
# (only populated when next_tool is judge_coding_plan)
131156
plan_required_fields: list[PlanRequiredField] = Field(
132157
default_factory=list,
133-
description="Structured specification of required fields for judge_coding_plan tool",
158+
description=(
159+
"Structured specification of required fields for judge_coding_plan tool"
160+
),
134161
)
135162

136163
# Backward compatibility property
@@ -170,7 +197,10 @@ class WorkflowGuidanceUserVars(BaseModel):
170197
)
171198
plan_required_fields_json: str = Field(
172199
default="[]",
173-
description="JSON array of required fields for judge_coding_plan (when next_tool is judge_coding_plan)",
200+
description=(
201+
"JSON array of required fields for judge_coding_plan "
202+
"(when next_tool is judge_coding_plan)"
203+
),
174204
)
175205

176206

@@ -211,14 +241,18 @@ async def calculate_next_stage(
211241
task_metadata
212242
):
213243
logger.info(
214-
f"Task size {task_metadata.task_size.value} - skipping planning phase, proceeding to implementation"
244+
f"Task size {task_metadata.task_size.value} - skipping planning "
245+
f"phase, proceeding to implementation"
215246
)
216-
# XS/S tasks skip planning but still need implementation → code review → testing → completion
247+
# XS/S tasks skip planning but still need implementation
248+
# → code review → testing → completion
217249
# For deterministic tests, do not prescribe next tool; provide guidance only
218250
return WorkflowGuidance(
219251
next_tool=None,
220252
reasoning=(
221-
f"Task size is {task_metadata.task_size.value.upper()} - planning phase can be skipped for simple fixes and minor features."
253+
f"Task size is {task_metadata.task_size.value.upper()} - "
254+
f"planning phase can be skipped for simple fixes and minor "
255+
f"features."
222256
),
223257
preparation_needed=[
224258
"Identify files to modify",
@@ -227,8 +261,11 @@ async def calculate_next_stage(
227261
],
228262
guidance=(
229263
f"{_load_todo_guidance()}"
230-
"Proceed directly to implementation. Once changes are complete and tests pass, continue with the workflow: "
231-
"call judge_code_change for code review, then judge_testing_implementation for testing validation, and finally judge_coding_task_completion for final validation."
264+
"Proceed directly to implementation. Once changes are complete "
265+
"and tests pass, continue with the workflow: call "
266+
"judge_code_change for code review, then "
267+
"judge_testing_implementation for testing validation, and "
268+
"finally judge_coding_task_completion for final validation."
232269
),
233270
)
234271

@@ -245,7 +282,10 @@ async def calculate_next_stage(
245282
],
246283
guidance=(
247284
f"{_load_todo_guidance()}"
248-
"Continue implementation. When ready, generate a unified Git diff that includes ALL modified files and call judge_code_change (include file_path only if a single file is modified)."
285+
"Continue implementation. When ready, generate a unified "
286+
"Git diff that includes ALL modified files and call "
287+
"judge_code_change (include file_path only if a single "
288+
"file is modified)."
249289
),
250290
)
251291
if task_metadata.state == TaskState.REVIEW_READY:
@@ -258,7 +298,9 @@ async def calculate_next_stage(
258298
],
259299
guidance=(
260300
f"{_load_todo_guidance()}"
261-
"Run tests and ensure they pass, then call judge_testing_implementation with a summary of tests and results."
301+
"Run tests and ensure they pass, then call "
302+
"judge_testing_implementation with a summary of tests "
303+
"and results."
262304
),
263305
)
264306
if task_metadata.state == TaskState.TESTING:
@@ -812,58 +854,72 @@ def _generate_plan_required_fields(
812854
PlanRequiredField(
813855
name="plan",
814856
type="string",
815-
description="Implementation plan with key steps" if task_metadata.task_size == TaskSize.M else "Detailed implementation plan with phases and steps",
857+
description="Implementation plan with key steps"
858+
if task_metadata.task_size == TaskSize.M
859+
else "Detailed implementation plan with phases and steps",
816860
required=True,
817-
example_value="1. Update config file, 2. Test changes" if task_metadata.task_size == TaskSize.M else "Phase 1: Project scaffolding..., Phase 2: Database setup...",
861+
example_value="1. Update config file, 2. Test changes"
862+
if task_metadata.task_size == TaskSize.M
863+
else "Phase 1: Project scaffolding..., Phase 2: Database setup...",
818864
),
819865
PlanRequiredField(
820866
name="design",
821867
type="string",
822-
description="Key technical approach and decisions" if task_metadata.task_size == TaskSize.M else "Architecture, components, data flow, and key technical decisions",
868+
description="Key technical approach and decisions"
869+
if task_metadata.task_size == TaskSize.M
870+
else "Architecture, components, data flow, and key technical decisions",
823871
required=True,
824-
example_value="Modify existing component to add new feature" if task_metadata.task_size == TaskSize.M else "Architecture: Next.js App Router with TypeScript, Components: AuthService, UserRepository...",
872+
example_value="Modify existing component to add new feature"
873+
if task_metadata.task_size == TaskSize.M
874+
else "Architecture: Next.js App Router with TypeScript, Components: AuthService, UserRepository...",
825875
),
826876
PlanRequiredField(
827877
name="research",
828878
type="string",
829-
description="Brief research summary and approach" if task_metadata.task_size == TaskSize.M else "Research findings and rationale for technology choices",
879+
description="Brief research summary and approach"
880+
if task_metadata.task_size == TaskSize.M
881+
else "Research findings and rationale for technology choices",
830882
required=True,
831-
example_value="Checked documentation for best practices" if task_metadata.task_size == TaskSize.M else "Auth.js provides secure OAuth integration with GitHub provider...",
883+
example_value="Checked documentation for best practices"
884+
if task_metadata.task_size == TaskSize.M
885+
else "Auth.js provides secure OAuth integration with GitHub provider...",
832886
),
833887
]
834888

835889
# Add complex fields only for Large/XL tasks
836890
if task_metadata.task_size in [TaskSize.L, TaskSize.XL]:
837-
required_fields.extend([
838-
PlanRequiredField(
839-
name="problem_domain",
840-
type="string",
841-
description="Concise statement of the problem domain and scope",
842-
required=True,
843-
example_value="GitHub OAuth authentication with user dashboard for Next.js application",
844-
),
845-
PlanRequiredField(
846-
name="problem_non_goals",
847-
type="list[str]",
848-
description="Explicit non-goals/boundaries to prevent scope creep",
849-
required=True,
850-
example_value='["Multi-provider authentication", "Admin panel", "Payment processing"]',
851-
),
852-
PlanRequiredField(
853-
name="library_plan",
854-
type="list[dict]",
855-
description="Library Selection Map: {purpose, selection, source, justification} for each dependency",
856-
required=True,
857-
example_value='[{"purpose": "Authentication", "selection": "Auth.js", "source": "external", "justification": "Industry standard OAuth implementation"}]',
858-
),
859-
PlanRequiredField(
860-
name="internal_reuse_components",
861-
type="list[dict]",
862-
description="Internal Reuse Map: {path, purpose, notes} for existing repo components",
863-
required=True,
864-
example_value='[{"path": "lib/db.ts", "purpose": "Database connection", "notes": "Existing Prisma setup"}] or [] with note "greenfield project"',
865-
),
866-
])
891+
required_fields.extend(
892+
[
893+
PlanRequiredField(
894+
name="problem_domain",
895+
type="string",
896+
description="Concise statement of the problem domain and scope",
897+
required=True,
898+
example_value="GitHub OAuth authentication with user dashboard for Next.js application",
899+
),
900+
PlanRequiredField(
901+
name="problem_non_goals",
902+
type="list[str]",
903+
description="Explicit non-goals/boundaries to prevent scope creep",
904+
required=True,
905+
example_value='["Multi-provider authentication", "Admin panel", "Payment processing"]',
906+
),
907+
PlanRequiredField(
908+
name="library_plan",
909+
type="list[dict]",
910+
description="Library Selection Map: {purpose, selection, source, justification} for each dependency",
911+
required=True,
912+
example_value='[{"purpose": "Authentication", "selection": "Auth.js", "source": "external", "justification": "Industry standard OAuth implementation"}]',
913+
),
914+
PlanRequiredField(
915+
name="internal_reuse_components",
916+
type="list[dict]",
917+
description="Internal Reuse Map: {path, purpose, notes} for existing repo components",
918+
required=True,
919+
example_value='[{"path": "lib/db.ts", "purpose": "Database connection", "notes": "Existing Prisma setup"}] or [] with note "greenfield project"',
920+
),
921+
]
922+
)
867923

868924
# Conditional fields based on task metadata
869925
if task_metadata.research_required:

0 commit comments

Comments
 (0)