foundry-mcp 0.3.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. foundry_mcp/__init__.py +7 -0
  2. foundry_mcp/cli/__init__.py +80 -0
  3. foundry_mcp/cli/__main__.py +9 -0
  4. foundry_mcp/cli/agent.py +96 -0
  5. foundry_mcp/cli/commands/__init__.py +37 -0
  6. foundry_mcp/cli/commands/cache.py +137 -0
  7. foundry_mcp/cli/commands/dashboard.py +148 -0
  8. foundry_mcp/cli/commands/dev.py +446 -0
  9. foundry_mcp/cli/commands/journal.py +377 -0
  10. foundry_mcp/cli/commands/lifecycle.py +274 -0
  11. foundry_mcp/cli/commands/modify.py +824 -0
  12. foundry_mcp/cli/commands/plan.py +633 -0
  13. foundry_mcp/cli/commands/pr.py +393 -0
  14. foundry_mcp/cli/commands/review.py +652 -0
  15. foundry_mcp/cli/commands/session.py +479 -0
  16. foundry_mcp/cli/commands/specs.py +856 -0
  17. foundry_mcp/cli/commands/tasks.py +807 -0
  18. foundry_mcp/cli/commands/testing.py +676 -0
  19. foundry_mcp/cli/commands/validate.py +982 -0
  20. foundry_mcp/cli/config.py +98 -0
  21. foundry_mcp/cli/context.py +259 -0
  22. foundry_mcp/cli/flags.py +266 -0
  23. foundry_mcp/cli/logging.py +212 -0
  24. foundry_mcp/cli/main.py +44 -0
  25. foundry_mcp/cli/output.py +122 -0
  26. foundry_mcp/cli/registry.py +110 -0
  27. foundry_mcp/cli/resilience.py +178 -0
  28. foundry_mcp/cli/transcript.py +217 -0
  29. foundry_mcp/config.py +850 -0
  30. foundry_mcp/core/__init__.py +144 -0
  31. foundry_mcp/core/ai_consultation.py +1636 -0
  32. foundry_mcp/core/cache.py +195 -0
  33. foundry_mcp/core/capabilities.py +446 -0
  34. foundry_mcp/core/concurrency.py +898 -0
  35. foundry_mcp/core/context.py +540 -0
  36. foundry_mcp/core/discovery.py +1603 -0
  37. foundry_mcp/core/error_collection.py +728 -0
  38. foundry_mcp/core/error_store.py +592 -0
  39. foundry_mcp/core/feature_flags.py +592 -0
  40. foundry_mcp/core/health.py +749 -0
  41. foundry_mcp/core/journal.py +694 -0
  42. foundry_mcp/core/lifecycle.py +412 -0
  43. foundry_mcp/core/llm_config.py +1350 -0
  44. foundry_mcp/core/llm_patterns.py +510 -0
  45. foundry_mcp/core/llm_provider.py +1569 -0
  46. foundry_mcp/core/logging_config.py +374 -0
  47. foundry_mcp/core/metrics_persistence.py +584 -0
  48. foundry_mcp/core/metrics_registry.py +327 -0
  49. foundry_mcp/core/metrics_store.py +641 -0
  50. foundry_mcp/core/modifications.py +224 -0
  51. foundry_mcp/core/naming.py +123 -0
  52. foundry_mcp/core/observability.py +1216 -0
  53. foundry_mcp/core/otel.py +452 -0
  54. foundry_mcp/core/otel_stubs.py +264 -0
  55. foundry_mcp/core/pagination.py +255 -0
  56. foundry_mcp/core/progress.py +317 -0
  57. foundry_mcp/core/prometheus.py +577 -0
  58. foundry_mcp/core/prompts/__init__.py +464 -0
  59. foundry_mcp/core/prompts/fidelity_review.py +546 -0
  60. foundry_mcp/core/prompts/markdown_plan_review.py +511 -0
  61. foundry_mcp/core/prompts/plan_review.py +623 -0
  62. foundry_mcp/core/providers/__init__.py +225 -0
  63. foundry_mcp/core/providers/base.py +476 -0
  64. foundry_mcp/core/providers/claude.py +460 -0
  65. foundry_mcp/core/providers/codex.py +619 -0
  66. foundry_mcp/core/providers/cursor_agent.py +642 -0
  67. foundry_mcp/core/providers/detectors.py +488 -0
  68. foundry_mcp/core/providers/gemini.py +405 -0
  69. foundry_mcp/core/providers/opencode.py +616 -0
  70. foundry_mcp/core/providers/opencode_wrapper.js +302 -0
  71. foundry_mcp/core/providers/package-lock.json +24 -0
  72. foundry_mcp/core/providers/package.json +25 -0
  73. foundry_mcp/core/providers/registry.py +607 -0
  74. foundry_mcp/core/providers/test_provider.py +171 -0
  75. foundry_mcp/core/providers/validation.py +729 -0
  76. foundry_mcp/core/rate_limit.py +427 -0
  77. foundry_mcp/core/resilience.py +600 -0
  78. foundry_mcp/core/responses.py +934 -0
  79. foundry_mcp/core/review.py +366 -0
  80. foundry_mcp/core/security.py +438 -0
  81. foundry_mcp/core/spec.py +1650 -0
  82. foundry_mcp/core/task.py +1289 -0
  83. foundry_mcp/core/testing.py +450 -0
  84. foundry_mcp/core/validation.py +2081 -0
  85. foundry_mcp/dashboard/__init__.py +32 -0
  86. foundry_mcp/dashboard/app.py +119 -0
  87. foundry_mcp/dashboard/components/__init__.py +17 -0
  88. foundry_mcp/dashboard/components/cards.py +88 -0
  89. foundry_mcp/dashboard/components/charts.py +234 -0
  90. foundry_mcp/dashboard/components/filters.py +136 -0
  91. foundry_mcp/dashboard/components/tables.py +195 -0
  92. foundry_mcp/dashboard/data/__init__.py +11 -0
  93. foundry_mcp/dashboard/data/stores.py +433 -0
  94. foundry_mcp/dashboard/launcher.py +289 -0
  95. foundry_mcp/dashboard/views/__init__.py +12 -0
  96. foundry_mcp/dashboard/views/errors.py +217 -0
  97. foundry_mcp/dashboard/views/metrics.py +174 -0
  98. foundry_mcp/dashboard/views/overview.py +160 -0
  99. foundry_mcp/dashboard/views/providers.py +83 -0
  100. foundry_mcp/dashboard/views/sdd_workflow.py +255 -0
  101. foundry_mcp/dashboard/views/tool_usage.py +139 -0
  102. foundry_mcp/prompts/__init__.py +9 -0
  103. foundry_mcp/prompts/workflows.py +525 -0
  104. foundry_mcp/resources/__init__.py +9 -0
  105. foundry_mcp/resources/specs.py +591 -0
  106. foundry_mcp/schemas/__init__.py +38 -0
  107. foundry_mcp/schemas/sdd-spec-schema.json +386 -0
  108. foundry_mcp/server.py +164 -0
  109. foundry_mcp/tools/__init__.py +10 -0
  110. foundry_mcp/tools/unified/__init__.py +71 -0
  111. foundry_mcp/tools/unified/authoring.py +1487 -0
  112. foundry_mcp/tools/unified/context_helpers.py +98 -0
  113. foundry_mcp/tools/unified/documentation_helpers.py +198 -0
  114. foundry_mcp/tools/unified/environment.py +939 -0
  115. foundry_mcp/tools/unified/error.py +462 -0
  116. foundry_mcp/tools/unified/health.py +225 -0
  117. foundry_mcp/tools/unified/journal.py +841 -0
  118. foundry_mcp/tools/unified/lifecycle.py +632 -0
  119. foundry_mcp/tools/unified/metrics.py +777 -0
  120. foundry_mcp/tools/unified/plan.py +745 -0
  121. foundry_mcp/tools/unified/pr.py +294 -0
  122. foundry_mcp/tools/unified/provider.py +629 -0
  123. foundry_mcp/tools/unified/review.py +685 -0
  124. foundry_mcp/tools/unified/review_helpers.py +299 -0
  125. foundry_mcp/tools/unified/router.py +102 -0
  126. foundry_mcp/tools/unified/server.py +580 -0
  127. foundry_mcp/tools/unified/spec.py +808 -0
  128. foundry_mcp/tools/unified/task.py +2202 -0
  129. foundry_mcp/tools/unified/test.py +370 -0
  130. foundry_mcp/tools/unified/verification.py +520 -0
  131. foundry_mcp-0.3.3.dist-info/METADATA +337 -0
  132. foundry_mcp-0.3.3.dist-info/RECORD +135 -0
  133. foundry_mcp-0.3.3.dist-info/WHEEL +4 -0
  134. foundry_mcp-0.3.3.dist-info/entry_points.txt +3 -0
  135. foundry_mcp-0.3.3.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,623 @@
1
+ """
2
+ Plan review prompts for AI consultation workflows.
3
+
4
+ This module provides prompt templates for two categories of plan review:
5
+
6
+ 1. **PLAN_REVIEW_*_V1 Templates** (PromptTemplate instances):
7
+ - PLAN_REVIEW_FULL_V1: Comprehensive 6-dimension review
8
+ - PLAN_REVIEW_QUICK_V1: Critical blockers and questions focus
9
+ - PLAN_REVIEW_SECURITY_V1: Security-focused review
10
+ - PLAN_REVIEW_FEASIBILITY_V1: Technical complexity and risk assessment
11
+ - SYNTHESIS_PROMPT_V1: Multi-model response synthesis
12
+
13
+ 2. **Legacy Templates** (string templates):
14
+ - review_spec: Comprehensive spec review
15
+ - review_phase: Phase-specific review
16
+ - security_review: Security-focused review
17
+ - feasibility_review: Feasibility assessment
18
+ - quick_review: Fast high-level review
19
+
20
+ Each PLAN_REVIEW_* template expects spec_content, spec_id, and title context.
21
+ """
22
+
23
+ from __future__ import annotations
24
+
25
+ from typing import Any, Dict, List
26
+
27
+ from foundry_mcp.core.prompts import PromptBuilder, PromptRegistry, PromptTemplate
28
+
29
+
30
+ # =============================================================================
31
+ # Response Schema for PLAN_REVIEW Templates
32
+ # =============================================================================
33
+
34
+ _RESPONSE_SCHEMA = """
35
+ # Review Summary
36
+
37
+ ## Critical Blockers
38
+ Issues that must be fixed before implementation can begin.
39
+
40
+ - **[Category]** <Issue title>
41
+ - **Description:** <What's wrong>
42
+ - **Impact:** <Consequences if not fixed>
43
+ - **Fix:** <Specific actionable recommendation>
44
+
45
+ ## Major Suggestions
46
+ Significant improvements that enhance quality, maintainability, or design.
47
+
48
+ - **[Category]** <Issue title>
49
+ - **Description:** <What's wrong>
50
+ - **Impact:** <Consequences if not addressed>
51
+ - **Fix:** <Specific actionable recommendation>
52
+
53
+ ## Minor Suggestions
54
+ Smaller improvements and optimizations.
55
+
56
+ - **[Category]** <Issue title>
57
+ - **Description:** <What could be better>
58
+ - **Fix:** <Specific actionable recommendation>
59
+
60
+ ## Questions
61
+ Clarifications needed or ambiguities to resolve.
62
+
63
+ - **[Category]** <Question>
64
+ - **Context:** <Why this matters>
65
+ - **Needed:** <What information would help>
66
+
67
+ ## Praise
68
+ What the spec does well.
69
+
70
+ - **[Category]** <What works well>
71
+ - **Why:** <What makes this effective>
72
+
73
+ ---
74
+
75
+ **Important**:
76
+ - Use category tags: [Completeness], [Architecture], [Data Model], [Interface Design], [Security], [Verification]
77
+ - Include all sections even if empty (write "None identified" for empty sections)
78
+ - Be specific and actionable in all feedback
79
+ - For clarity issues, use Questions section rather than creating a separate category
80
+ - Attribution: In multi-model reviews, prefix items with "Flagged by [model-name]:" when applicable
81
+ """
82
+
83
+
84
+ # =============================================================================
85
+ # System Prompts
86
+ # =============================================================================
87
+
88
+ _PLAN_REVIEW_SYSTEM_PROMPT = """You are an expert software architect conducting a technical review.
89
+ Your task is to provide constructive, actionable feedback on software specifications.
90
+
91
+ Guidelines:
92
+ - Be thorough and specific - examine all aspects of the design
93
+ - Identify both strengths and opportunities for improvement
94
+ - Ask clarifying questions for ambiguities
95
+ - Propose alternatives when better approaches exist
96
+ - Focus on impact and prioritize feedback by potential consequences
97
+ - Be collaborative, not adversarial"""
98
+
99
+
100
+ # =============================================================================
101
+ # PLAN_REVIEW_FULL_V1
102
+ # =============================================================================
103
+
104
+ PLAN_REVIEW_FULL_V1 = PromptTemplate(
105
+ id="PLAN_REVIEW_FULL_V1",
106
+ version="1.0",
107
+ system_prompt=_PLAN_REVIEW_SYSTEM_PROMPT,
108
+ user_template="""You are conducting a comprehensive technical review of a software specification.
109
+
110
+ **Spec**: {spec_id}
111
+ **Title**: {title}
112
+ **Review Type**: Full (comprehensive analysis)
113
+
114
+ **Your role**: You are a collaborative senior peer helping refine the design and identify opportunities for improvement.
115
+
116
+ **Critical: Provide Constructive Feedback**
117
+
118
+ Effective reviews combine critical analysis with actionable guidance.
119
+
120
+ **Your evaluation guidelines**:
121
+ 1. **Be thorough and specific** - Examine all aspects of the design
122
+ 2. **Identify both strengths and opportunities** - Note what works well and what could improve
123
+ 3. **Ask clarifying questions** - Highlight ambiguities that need resolution
124
+ 4. **Propose alternatives** - Show better approaches when they exist
125
+ 5. **Be actionable** - Provide specific, implementable recommendations
126
+ 6. **Focus on impact** - Prioritize feedback by potential consequences
127
+
128
+ **Effective feedback patterns**:
129
+ - "Consider whether this approach handles X, Y, Z edge cases"
130
+ - "These estimates may be optimistic because..."
131
+ - "Strong design choice here because..."
132
+ - "Clarification needed: how does this handle scenario X?"
133
+
134
+ **Evaluate across 6 technical dimensions:**
135
+
136
+ 1. **Completeness** - Identify missing sections, undefined requirements, ambiguous tasks
137
+ 2. **Architecture** - Find design issues, coupling concerns, missing abstractions, scalability considerations
138
+ 3. **Data Model** - Evaluate data structures, relationships, consistency, migration strategies
139
+ 4. **Interface Design** - Review API contracts, component boundaries, integration patterns
140
+ 5. **Security** - Identify authentication, authorization, data protection, and vulnerability concerns
141
+ 6. **Verification** - Find testing gaps, missing verification steps, coverage opportunities
142
+
143
+ **SPECIFICATION TO REVIEW:**
144
+
145
+ {spec_content}
146
+
147
+ ---
148
+
149
+ **Required Output Format** (Markdown):
150
+ {response_schema}
151
+
152
+ **Remember**: Your goal is to **help create robust, well-designed software**. Be specific, actionable, and balanced in your feedback. Identify both critical blockers and positive aspects of the design.""",
153
+ required_context=["spec_content", "spec_id", "title"],
154
+ optional_context=["response_schema"],
155
+ metadata={
156
+ "author": "foundry-mcp",
157
+ "category": "plan_review",
158
+ "workflow": "PLAN_REVIEW",
159
+ "review_type": "full",
160
+ "dimensions": [
161
+ "Completeness",
162
+ "Architecture",
163
+ "Data Model",
164
+ "Interface Design",
165
+ "Security",
166
+ "Verification",
167
+ ],
168
+ "description": "Comprehensive 6-dimension specification review",
169
+ },
170
+ )
171
+
172
+
173
+ # =============================================================================
174
+ # PLAN_REVIEW_QUICK_V1
175
+ # =============================================================================
176
+
177
+ PLAN_REVIEW_QUICK_V1 = PromptTemplate(
178
+ id="PLAN_REVIEW_QUICK_V1",
179
+ version="1.0",
180
+ system_prompt=_PLAN_REVIEW_SYSTEM_PROMPT,
181
+ user_template="""You are conducting a quick technical review of a software specification.
182
+
183
+ **Spec**: {spec_id}
184
+ **Title**: {title}
185
+ **Review Type**: Quick (focus on blockers and questions)
186
+
187
+ **Your role**: Identify critical blockers and key questions that need resolution before implementation.
188
+
189
+ **Focus on finding:**
190
+
191
+ 1. **Critical Blockers**: What would prevent implementation from starting?
192
+ - Missing required sections or requirements
193
+ - Undefined dependencies or integrations
194
+ - Unresolved technical decisions
195
+ - Incomplete acceptance criteria
196
+
197
+ 2. **Key Questions**: What needs clarification?
198
+ - Ambiguous requirements or acceptance criteria
199
+ - Unclear technical approaches
200
+ - Missing context or rationale
201
+ - Edge cases not addressed
202
+
203
+ **Evaluation areas**:
204
+ - **Completeness**: Are all necessary sections and requirements present?
205
+ - **Questions**: What clarifications are needed?
206
+
207
+ **SPECIFICATION TO REVIEW:**
208
+
209
+ {spec_content}
210
+
211
+ ---
212
+
213
+ **Required Output Format** (Markdown):
214
+ {response_schema}
215
+
216
+ **Note**: Focus primarily on Critical Blockers and Questions sections. Brief notes for other sections are sufficient.""",
217
+ required_context=["spec_content", "spec_id", "title"],
218
+ optional_context=["response_schema"],
219
+ metadata={
220
+ "author": "foundry-mcp",
221
+ "category": "plan_review",
222
+ "workflow": "PLAN_REVIEW",
223
+ "review_type": "quick",
224
+ "focus": ["Critical Blockers", "Questions"],
225
+ "description": "Quick review focusing on blockers and clarifications",
226
+ },
227
+ )
228
+
229
+
230
+ # =============================================================================
231
+ # PLAN_REVIEW_SECURITY_V1
232
+ # =============================================================================
233
+
234
+ PLAN_REVIEW_SECURITY_V1 = PromptTemplate(
235
+ id="PLAN_REVIEW_SECURITY_V1",
236
+ version="1.0",
237
+ system_prompt="""You are a security specialist reviewing software specifications.
238
+ Your task is to identify security vulnerabilities, risks, and recommend mitigations.
239
+
240
+ Guidelines:
241
+ - Focus on authentication, authorization, and data protection
242
+ - Identify injection risks and common vulnerabilities
243
+ - Consider OWASP Top 10 and industry security standards
244
+ - Provide specific, actionable remediation recommendations
245
+ - Prioritize findings by risk severity""",
246
+ user_template="""You are conducting a security review of a software specification.
247
+
248
+ **Spec**: {spec_id}
249
+ **Title**: {title}
250
+ **Review Type**: Security (focus on vulnerabilities and risks)
251
+
252
+ **Your role**: Security specialist helping identify and mitigate potential vulnerabilities.
253
+
254
+ **Focus on security considerations:**
255
+
256
+ 1. **Authentication & Authorization**:
257
+ - Are authentication mechanisms properly designed?
258
+ - Is authorization enforced at appropriate boundaries?
259
+ - Does access control follow principle of least privilege?
260
+
261
+ 2. **Data Protection**:
262
+ - Is input validation comprehensive?
263
+ - Are secrets managed securely?
264
+ - Is data encrypted at rest and in transit?
265
+ - Do error messages avoid leaking sensitive information?
266
+
267
+ 3. **Common Vulnerabilities**:
268
+ - Are injection attacks (SQL, command, XSS, CSRF) prevented?
269
+ - Are security headers and protections in place?
270
+ - Is rate limiting and DoS protection addressed?
271
+ - Are insecure defaults avoided?
272
+
273
+ 4. **Audit & Compliance**:
274
+ - Is audit logging sufficient for security events?
275
+ - Are privacy concerns addressed?
276
+ - Are relevant compliance requirements considered?
277
+
278
+ **Evaluation areas**:
279
+ - **Security**: Authentication, authorization, data protection, vulnerability prevention
280
+ - **Architecture**: Security-relevant design decisions
281
+ - **Data Model**: Data sensitivity, encryption, access patterns
282
+
283
+ **SPECIFICATION TO REVIEW:**
284
+
285
+ {spec_content}
286
+
287
+ ---
288
+
289
+ **Required Output Format** (Markdown):
290
+ {response_schema}
291
+
292
+ **Note**: Focus primarily on Security category feedback. Include Critical Blockers for any security issues that must be addressed before implementation.""",
293
+ required_context=["spec_content", "spec_id", "title"],
294
+ optional_context=["response_schema"],
295
+ metadata={
296
+ "author": "foundry-mcp",
297
+ "category": "plan_review",
298
+ "workflow": "PLAN_REVIEW",
299
+ "review_type": "security",
300
+ "focus": [
301
+ "Authentication",
302
+ "Authorization",
303
+ "Data Protection",
304
+ "Vulnerabilities",
305
+ ],
306
+ "description": "Security-focused review for vulnerabilities and risks",
307
+ },
308
+ )
309
+
310
+
311
+ # =============================================================================
312
+ # PLAN_REVIEW_FEASIBILITY_V1
313
+ # =============================================================================
314
+
315
+ PLAN_REVIEW_FEASIBILITY_V1 = PromptTemplate(
316
+ id="PLAN_REVIEW_FEASIBILITY_V1",
317
+ version="1.0",
318
+ system_prompt="""You are a pragmatic senior engineer assessing technical feasibility.
319
+ Your task is to identify implementation challenges, risks, and hidden complexity.
320
+
321
+ Guidelines:
322
+ - Identify non-obvious technical challenges
323
+ - Evaluate dependency availability and stability
324
+ - Assess resource and timeline realism
325
+ - Highlight areas of concentrated complexity
326
+ - Suggest risk mitigations and alternatives""",
327
+ user_template="""You are conducting a technical complexity review of a software specification.
328
+
329
+ **Spec**: {spec_id}
330
+ **Title**: {title}
331
+ **Review Type**: Technical Complexity (focus on implementation challenges)
332
+
333
+ **Your role**: Pragmatic engineer helping identify technical challenges and implementation risks.
334
+
335
+ **Focus on technical considerations:**
336
+
337
+ 1. **Hidden Complexity**:
338
+ - What technical challenges might not be obvious?
339
+ - Where does complexity concentrate?
340
+ - What edge cases increase difficulty?
341
+
342
+ 2. **Dependencies & Integration**:
343
+ - Are all required dependencies identified?
344
+ - Are external services/APIs available and documented?
345
+ - Are integration points well-defined?
346
+ - What dependency risks exist?
347
+
348
+ 3. **Technical Constraints**:
349
+ - What technical limitations could impact the design?
350
+ - Are performance requirements achievable?
351
+ - Are there scalability considerations?
352
+ - What infrastructure requirements exist?
353
+
354
+ 4. **Implementation Risks**:
355
+ - What could go wrong during implementation?
356
+ - Where are the highest-risk technical areas?
357
+ - What mitigation strategies are needed?
358
+
359
+ **Evaluation areas**:
360
+ - **Completeness**: Are technical requirements fully specified?
361
+ - **Architecture**: Is the technical approach sound?
362
+ - **Data Model**: Are data complexity factors addressed?
363
+ - **Interface Design**: Are integration points well-defined?
364
+
365
+ **SPECIFICATION TO REVIEW:**
366
+
367
+ {spec_content}
368
+
369
+ ---
370
+
371
+ **Required Output Format** (Markdown):
372
+ {response_schema}
373
+
374
+ **Note**: Focus on technical challenges and risks. Identify Major Suggestions for areas of hidden complexity and Critical Blockers for missing technical requirements.""",
375
+ required_context=["spec_content", "spec_id", "title"],
376
+ optional_context=["response_schema"],
377
+ metadata={
378
+ "author": "foundry-mcp",
379
+ "category": "plan_review",
380
+ "workflow": "PLAN_REVIEW",
381
+ "review_type": "feasibility",
382
+ "focus": ["Complexity", "Dependencies", "Risks"],
383
+ "description": "Technical feasibility and risk assessment",
384
+ },
385
+ )
386
+
387
+
388
+ # =============================================================================
389
+ # SYNTHESIS_PROMPT_V1
390
+ # =============================================================================
391
+
392
+ SYNTHESIS_PROMPT_V1 = PromptTemplate(
393
+ id="SYNTHESIS_PROMPT_V1",
394
+ version="1.0",
395
+ system_prompt="""You are an expert at synthesizing multiple technical reviews.
396
+ Your task is to consolidate diverse perspectives into actionable consensus.
397
+
398
+ Guidelines:
399
+ - Attribute findings to specific models
400
+ - Identify areas of agreement and disagreement
401
+ - Prioritize by consensus strength
402
+ - Preserve unique insights from each model
403
+ - Create actionable, consolidated recommendations""",
404
+ user_template="""You are synthesizing {num_models} independent AI reviews of a specification.
405
+
406
+ **Specification**: {title} (`{spec_id}`)
407
+
408
+ **Your Task**: Read all reviews below and create a comprehensive synthesis.
409
+
410
+ **Required Output** (Markdown format):
411
+
412
+ ```markdown
413
+ # Synthesis
414
+
415
+ ## Overall Assessment
416
+ - **Consensus Level**: Strong/Moderate/Weak/Conflicted (based on agreement across models)
417
+
418
+ ## Critical Blockers
419
+ Issues that must be fixed before implementation (identified by multiple models):
420
+ - **[Category]** Issue title - flagged by: [model names]
421
+ - Impact: ...
422
+ - Recommended fix: ...
423
+
424
+ ## Major Suggestions
425
+ Significant improvements that enhance quality, maintainability, or design:
426
+ - **[Category]** Issue title - flagged by: [model names]
427
+ - Description: ...
428
+ - Recommended fix: ...
429
+
430
+ ## Questions for Author
431
+ Clarifications needed (common questions across models):
432
+ - **[Category]** Question - flagged by: [model names]
433
+ - Context: Why this matters
434
+
435
+ ## Design Strengths
436
+ What the spec does well (areas of agreement):
437
+ - **[Category]** Strength - noted by: [model names]
438
+ - Why this is effective
439
+
440
+ ## Points of Agreement
441
+ - What all/most models agree on
442
+
443
+ ## Points of Disagreement
444
+ - Where models conflict
445
+ - Your assessment of the disagreement
446
+
447
+ ## Synthesis Notes
448
+ - Overall themes across reviews
449
+ - Actionable next steps
450
+ ```
451
+
452
+ **Important**:
453
+ - Attribute issues to specific models (e.g., "flagged by: gemini, codex")
454
+ - Note where models agree vs. disagree
455
+ - Focus on synthesizing actionable feedback across all reviews
456
+
457
+ ---
458
+
459
+ {model_reviews}""",
460
+ required_context=["spec_id", "title", "num_models", "model_reviews"],
461
+ optional_context=[],
462
+ metadata={
463
+ "author": "foundry-mcp",
464
+ "category": "plan_review",
465
+ "workflow": "PLAN_REVIEW",
466
+ "review_type": "synthesis",
467
+ "description": "AI-powered synthesis of multiple model responses",
468
+ },
469
+ )
470
+
471
+
472
+ # =============================================================================
473
+ # Template Registries
474
+ # =============================================================================
475
+
476
+
477
+ # PLAN_REVIEW_* templates registry (PromptTemplate instances)
478
+ PLAN_REVIEW_TEMPLATES: Dict[str, PromptTemplate] = {
479
+ "PLAN_REVIEW_FULL_V1": PLAN_REVIEW_FULL_V1,
480
+ "PLAN_REVIEW_QUICK_V1": PLAN_REVIEW_QUICK_V1,
481
+ "PLAN_REVIEW_SECURITY_V1": PLAN_REVIEW_SECURITY_V1,
482
+ "PLAN_REVIEW_FEASIBILITY_V1": PLAN_REVIEW_FEASIBILITY_V1,
483
+ "SYNTHESIS_PROMPT_V1": SYNTHESIS_PROMPT_V1,
484
+ }
485
+
486
+
487
+ # =============================================================================
488
+ # Legacy String Templates (for backwards compatibility)
489
+ # =============================================================================
490
+
491
+ # Legacy templates have been removed. Use PLAN_REVIEW_* templates.
492
+
493
+
494
+ # =============================================================================
495
+ # Template Registries
496
+ # =============================================================================
497
+
498
+
499
+ # PLAN_REVIEW_* templates registry (PromptTemplate instances)
500
+ PLAN_REVIEW_TEMPLATES: Dict[str, PromptTemplate] = {
501
+ "PLAN_REVIEW_FULL_V1": PLAN_REVIEW_FULL_V1,
502
+ "PLAN_REVIEW_QUICK_V1": PLAN_REVIEW_QUICK_V1,
503
+ "PLAN_REVIEW_SECURITY_V1": PLAN_REVIEW_SECURITY_V1,
504
+ "PLAN_REVIEW_FEASIBILITY_V1": PLAN_REVIEW_FEASIBILITY_V1,
505
+ "SYNTHESIS_PROMPT_V1": SYNTHESIS_PROMPT_V1,
506
+ }
507
+
508
+
509
+ # =============================================================================
510
+ # Prompt Builder Implementation
511
+ # =============================================================================
512
+
513
+
514
+ class PlanReviewPromptBuilder(PromptBuilder):
515
+ """
516
+ Prompt builder for SDD plan review workflows.
517
+
518
+ Provides access to PLAN_REVIEW_* templates (PromptTemplate instances).
519
+
520
+ PLAN_REVIEW Templates:
521
+ - PLAN_REVIEW_FULL_V1: Comprehensive 6-dimension review
522
+ - PLAN_REVIEW_QUICK_V1: Critical blockers and questions focus
523
+ - PLAN_REVIEW_SECURITY_V1: Security-focused review
524
+ - PLAN_REVIEW_FEASIBILITY_V1: Technical complexity assessment
525
+ - SYNTHESIS_PROMPT_V1: Multi-model response synthesis
526
+ """
527
+
528
+ def __init__(self) -> None:
529
+ """Initialize the builder with all templates."""
530
+ self._registry = PromptRegistry()
531
+ # Register PLAN_REVIEW_* templates
532
+ for template in PLAN_REVIEW_TEMPLATES.values():
533
+ self._registry.register(template)
534
+
535
+ def build(self, prompt_id: str, context: Dict[str, Any]) -> str:
536
+ """
537
+ Build a plan review prompt.
538
+
539
+ Args:
540
+ prompt_id: Template ID (PLAN_REVIEW_* or SYNTHESIS_PROMPT_V1)
541
+ context: Context dict with required variables
542
+
543
+ Returns:
544
+ Rendered prompt string
545
+
546
+ Raises:
547
+ ValueError: If prompt_id not found or required context missing
548
+ """
549
+ # Check if it's a PLAN_REVIEW_* template
550
+ if prompt_id in PLAN_REVIEW_TEMPLATES:
551
+ render_context = dict(context)
552
+ # Add default response schema if not provided
553
+ if "response_schema" not in render_context:
554
+ render_context["response_schema"] = _RESPONSE_SCHEMA
555
+ return self._registry.render(prompt_id, render_context)
556
+
557
+ # Unknown prompt_id
558
+ all_ids = sorted(list(PLAN_REVIEW_TEMPLATES.keys()))
559
+ raise ValueError(f"Unknown prompt_id '{prompt_id}'. Available: {all_ids}")
560
+
561
+ def list_prompts(self) -> List[str]:
562
+ """
563
+ Return all available prompt IDs.
564
+
565
+ Returns:
566
+ Sorted list of all prompt IDs (PLAN_REVIEW_*)
567
+ """
568
+ return sorted(list(PLAN_REVIEW_TEMPLATES.keys()))
569
+
570
+ def get_template(self, prompt_id: str) -> PromptTemplate:
571
+ """
572
+ Get a PLAN_REVIEW_* template by ID for inspection.
573
+
574
+ Args:
575
+ prompt_id: Template identifier (must be a PLAN_REVIEW_* template)
576
+
577
+ Returns:
578
+ The PromptTemplate
579
+
580
+ Raises:
581
+ KeyError: If not found or not a PLAN_REVIEW_* template
582
+ """
583
+ if prompt_id not in PLAN_REVIEW_TEMPLATES:
584
+ available = sorted(PLAN_REVIEW_TEMPLATES.keys())
585
+ raise KeyError(
586
+ f"Template '{prompt_id}' not found. "
587
+ f"Only PLAN_REVIEW_* templates can be inspected. Available: {available}"
588
+ )
589
+ return self._registry.get_required(prompt_id)
590
+
591
+
592
+ # =============================================================================
593
+ # Helper Functions
594
+ # =============================================================================
595
+
596
+
597
+ def get_response_schema() -> str:
598
+ """
599
+ Get the standard response schema for plan reviews.
600
+
601
+ Returns:
602
+ Response schema markdown string
603
+ """
604
+ return _RESPONSE_SCHEMA
605
+
606
+
607
+ # =============================================================================
608
+ # Module Exports
609
+ # =============================================================================
610
+
611
+ __all__ = [
612
+ # PLAN_REVIEW_* templates
613
+ "PLAN_REVIEW_FULL_V1",
614
+ "PLAN_REVIEW_QUICK_V1",
615
+ "PLAN_REVIEW_SECURITY_V1",
616
+ "PLAN_REVIEW_FEASIBILITY_V1",
617
+ "SYNTHESIS_PROMPT_V1",
618
+ "PLAN_REVIEW_TEMPLATES",
619
+ # Builder
620
+ "PlanReviewPromptBuilder",
621
+ # Helpers
622
+ "get_response_schema",
623
+ ]