@vfarcic/dot-ai 0.66.0 → 0.67.0

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.
@@ -20,6 +20,29 @@ export interface Interaction {
20
20
  success: boolean;
21
21
  timestamp?: Date;
22
22
  }
23
+ export type ImpactLevel = 'HIGH' | 'MEDIUM' | 'LOW';
24
+ export type ClarificationCategory = 'TECHNICAL_SPECIFICATIONS' | 'ARCHITECTURAL_CONTEXT' | 'OPERATIONAL_REQUIREMENTS' | 'SECURITY_COMPLIANCE' | 'ORGANIZATIONAL_ALIGNMENT';
25
+ export interface ClarificationOpportunity {
26
+ category: ClarificationCategory;
27
+ missingContext: string;
28
+ impactLevel: ImpactLevel;
29
+ reasoning: string;
30
+ suggestedQuestions?: string[];
31
+ patternAlignment?: string;
32
+ }
33
+ export interface IntentAnalysisResult {
34
+ clarificationOpportunities: ClarificationOpportunity[];
35
+ overallAssessment: {
36
+ enhancementPotential: ImpactLevel;
37
+ primaryGaps: string[];
38
+ recommendedFocus: string;
39
+ };
40
+ intentQuality: {
41
+ currentSpecificity: string;
42
+ strengthAreas: string[];
43
+ improvementAreas: string[];
44
+ };
45
+ }
23
46
  export declare class ClaudeIntegration {
24
47
  private client;
25
48
  private apiKey;
@@ -50,6 +73,14 @@ export declare class ClaudeIntegration {
50
73
  analyzeError(error: string, _context?: any): Promise<string>;
51
74
  suggestImprovements(_manifest: string): Promise<string[]>;
52
75
  processUserInput(input: string, context?: any): Promise<any>;
76
+ /**
77
+ * Analyze user intent for clarification opportunities
78
+ *
79
+ * @param intent User's deployment intent
80
+ * @param organizationalPatterns Available organizational patterns context
81
+ * @returns Analysis result with clarification opportunities
82
+ */
83
+ analyzeIntentForClarification(intent: string, organizationalPatterns?: string): Promise<IntentAnalysisResult>;
53
84
  isInitialized(): boolean;
54
85
  }
55
86
  //# sourceMappingURL=claude.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"claude.d.ts","sourceRoot":"","s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GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAazD,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IA2BlE;;;;;;OAMG;IACG,6BAA6B,CAAC,MAAM,EAAE,MAAM,EAAE,sBAAsB,GAAE,MAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAkEvH,aAAa,IAAI,OAAO;CAGzB"}
@@ -318,6 +318,70 @@ spec:
318
318
  suggestions: ['Start by exploring your cluster resources']
319
319
  };
320
320
  }
321
+ /**
322
+ * Analyze user intent for clarification opportunities
323
+ *
324
+ * @param intent User's deployment intent
325
+ * @param organizationalPatterns Available organizational patterns context
326
+ * @returns Analysis result with clarification opportunities
327
+ */
328
+ async analyzeIntentForClarification(intent, organizationalPatterns = '') {
329
+ if (!this.client) {
330
+ throw new Error('Claude client not initialized');
331
+ }
332
+ try {
333
+ // Load intent analysis prompt template
334
+ const promptPath = path.join(__dirname, '..', '..', 'prompts', 'intent-analysis.md');
335
+ const template = fs.readFileSync(promptPath, 'utf8');
336
+ // Replace template variables
337
+ const analysisPrompt = template
338
+ .replaceAll('{intent}', intent)
339
+ .replaceAll('{organizational_patterns}', organizationalPatterns || 'No specific organizational patterns available');
340
+ // Send to Claude for analysis
341
+ const response = await this.sendMessage(analysisPrompt, 'intent-analysis');
342
+ // Parse JSON response with robust error handling
343
+ let jsonContent = response.content;
344
+ // Try to find JSON object wrapped in code blocks
345
+ const codeBlockMatch = response.content.match(/```(?:json)?\s*(\{[\s\S]*?\})\s*```/);
346
+ if (codeBlockMatch) {
347
+ jsonContent = codeBlockMatch[1];
348
+ }
349
+ else {
350
+ // Try to find JSON object that starts with { and find the matching closing }
351
+ const jsonMatch = response.content.match(/\{[\s\S]*\}/);
352
+ if (jsonMatch) {
353
+ jsonContent = jsonMatch[0];
354
+ }
355
+ }
356
+ // Parse the JSON
357
+ const analysisResult = JSON.parse(jsonContent);
358
+ // Validate the response structure
359
+ if (!analysisResult.clarificationOpportunities || !Array.isArray(analysisResult.clarificationOpportunities)) {
360
+ throw new Error('Invalid analysis result structure: missing clarificationOpportunities array');
361
+ }
362
+ if (!analysisResult.overallAssessment || !analysisResult.intentQuality) {
363
+ throw new Error('Invalid analysis result structure: missing overallAssessment or intentQuality');
364
+ }
365
+ return analysisResult;
366
+ }
367
+ catch (error) {
368
+ // If parsing fails or API call fails, return a fallback minimal analysis
369
+ console.warn('Intent analysis failed, returning minimal analysis:', error);
370
+ return {
371
+ clarificationOpportunities: [],
372
+ overallAssessment: {
373
+ enhancementPotential: 'LOW',
374
+ primaryGaps: [],
375
+ recommendedFocus: 'Proceed with original intent - analysis unavailable'
376
+ },
377
+ intentQuality: {
378
+ currentSpecificity: 'Unable to analyze - using original intent',
379
+ strengthAreas: ['User provided clear deployment intent'],
380
+ improvementAreas: []
381
+ }
382
+ };
383
+ }
384
+ }
321
385
  isInitialized() {
322
386
  return this.client !== null;
323
387
  }
@@ -8,12 +8,14 @@ export declare const RECOMMEND_TOOL_NAME = "recommend";
8
8
  export declare const RECOMMEND_TOOL_DESCRIPTION = "Deploy, create, setup, install, or run applications, infrastructure, and services on Kubernetes with AI recommendations. Describe what you want to deploy.";
9
9
  export declare const RECOMMEND_TOOL_INPUT_SCHEMA: {
10
10
  intent: z.ZodString;
11
+ final: z.ZodOptional<z.ZodBoolean>;
11
12
  };
12
13
  /**
13
14
  * Direct MCP tool handler for recommend functionality
14
15
  */
15
16
  export declare function handleRecommendTool(args: {
16
17
  intent: string;
18
+ final?: boolean;
17
19
  }, dotAI: DotAI, logger: Logger, requestId: string): Promise<{
18
20
  content: {
19
21
  type: 'text';
@@ -1 +1 @@
1
- {"version":3,"file":"recommend.d.ts","sourceRoot":"","sources":["../../src/tools/recommend.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,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exports.RECOMMEND_TOOL_DESCRIPTION = 'Deploy, create, setup, install, or run applications, infrastructure, and services on Kubernetes with AI recommendations. Describe what you want to deploy.';
53
53
  // Zod schema for MCP registration
54
54
  exports.RECOMMEND_TOOL_INPUT_SCHEMA = {
55
- intent: zod_1.z.string().min(1).max(1000).describe('What the user wants to deploy, create, setup, install, or run on Kubernetes. Examples: "deploy web application", "create PostgreSQL database", "setup Redis cache", "install Prometheus monitoring", "configure Ingress controller", "provision storage volumes", "launch MongoDB operator", "run Node.js API", "setup CI/CD pipeline", "create load balancer", "install Grafana dashboard", "deploy React frontend"')
55
+ intent: zod_1.z.string().min(1).max(1000).describe('What the user wants to deploy, create, setup, install, or run on Kubernetes. Examples: "deploy web application", "create PostgreSQL database", "setup Redis cache", "install Prometheus monitoring", "configure Ingress controller", "provision storage volumes", "launch MongoDB operator", "run Node.js API", "setup CI/CD pipeline", "create load balancer", "install Grafana dashboard", "deploy React frontend"'),
56
+ final: zod_1.z.boolean().optional().describe('Set to true to skip intent clarification and proceed directly with recommendations. If false or omitted, the tool will analyze the intent and provide clarification questions to help improve recommendation quality.')
56
57
  };
57
58
  /**
58
- * Validate intent meaningfulness using AI
59
+ * Analyze intent for clarification opportunities using AI
59
60
  */
60
- async function validateIntentWithAI(intent, claudeIntegration) {
61
+ async function analyzeIntentForClarification(intent, claudeIntegration, logger) {
61
62
  try {
62
- // Load prompt template
63
- const promptPath = path.join(__dirname, '..', '..', 'prompts', 'intent-validation.md');
64
- const template = fs.readFileSync(promptPath, 'utf8');
65
- // Replace template variables
66
- const validationPrompt = template.replace('{intent}', intent);
67
- // Send to Claude for validation
68
- const response = await claudeIntegration.sendMessage(validationPrompt, 'intent-validation');
69
- // Parse JSON response with robust error handling
70
- let jsonContent = response.content;
71
- // Try to find JSON object wrapped in code blocks
72
- const codeBlockMatch = response.content.match(/```(?:json)?\s*(\{[\s\S]*?\})\s*```/);
73
- if (codeBlockMatch) {
74
- jsonContent = codeBlockMatch[1];
75
- }
76
- else {
77
- // Try to find JSON object that starts with { and find the matching closing }
78
- const startIndex = response.content.indexOf('{');
79
- if (startIndex !== -1) {
80
- let braceCount = 0;
81
- let endIndex = startIndex;
82
- for (let i = startIndex; i < response.content.length; i++) {
83
- if (response.content[i] === '{')
84
- braceCount++;
85
- if (response.content[i] === '}')
86
- braceCount--;
87
- if (braceCount === 0) {
88
- endIndex = i;
89
- break;
90
- }
91
- }
92
- if (braceCount === 0) {
93
- jsonContent = response.content.substring(startIndex, endIndex + 1);
94
- }
95
- }
96
- }
97
- const validation = JSON.parse(jsonContent.trim());
98
- // Validate response structure
99
- if (typeof validation.isSpecific !== 'boolean' ||
100
- typeof validation.reason !== 'string' ||
101
- !Array.isArray(validation.suggestions)) {
102
- throw new Error('AI response has invalid structure');
103
- }
104
- // If intent is not specific enough, throw error with suggestions
105
- if (!validation.isSpecific) {
106
- const suggestions = validation.suggestions.length
107
- ? validation.suggestions.map((s) => `• ${s}`).join('\n')
108
- : '• Include specific technology (Node.js, PostgreSQL, React, etc.)\n• Describe the purpose or function\n• Add context about requirements';
109
- throw new Error(`Intent needs more specificity: ${validation.reason}\n\n` +
110
- `Suggestions to improve your intent:\n${suggestions}\n\n` +
111
- `Original intent: "${intent}"`);
112
- }
63
+ // Use the Claude service method for intent analysis
64
+ const analysisResult = await claudeIntegration.analyzeIntentForClarification(intent);
65
+ return analysisResult;
113
66
  }
114
67
  catch (error) {
115
- // If it's our validation error, re-throw it
116
- if (error instanceof Error && error.message.includes('Intent needs more specificity')) {
117
- throw error;
118
- }
119
- // For other errors (AI service issues, JSON parsing, etc.),
120
- // continue without blocking the user - log the issue but don't fail
121
- console.warn('Intent validation failed, continuing with original intent:', error);
122
- return;
68
+ logger.warn?.('Intent analysis failed, proceeding without clarification', {
69
+ error: error instanceof Error ? error.message : String(error)
70
+ });
71
+ // Return minimal analysis that indicates no clarification available
72
+ return {
73
+ clarificationOpportunities: [],
74
+ overallAssessment: {
75
+ enhancementPotential: 'LOW',
76
+ primaryGaps: [],
77
+ recommendedFocus: 'Proceeding with original intent - analysis unavailable'
78
+ },
79
+ intentQuality: {
80
+ currentSpecificity: 'Analysis unavailable',
81
+ strengthAreas: ['User provided deployment intent'],
82
+ improvementAreas: []
83
+ }
84
+ };
123
85
  }
124
86
  }
125
87
  /**
@@ -197,38 +159,66 @@ async function handleRecommendTool(args, dotAI, logger, requestId) {
197
159
  ]
198
160
  }, error instanceof Error ? error : new Error(String(error)));
199
161
  }
200
- // Ensure cluster connectivity before proceeding
201
- await (0, cluster_utils_1.ensureClusterConnection)(dotAI, logger, requestId, 'RecommendTool');
202
162
  logger.info('Starting resource recommendation process', {
203
163
  requestId,
204
164
  intent: args.intent,
205
165
  hasApiKey: !!claudeApiKey
206
166
  });
207
- // Validate intent specificity with AI before expensive resource discovery
208
- logger.debug('Validating intent specificity', { requestId, intent: args.intent });
209
- try {
210
- const claudeIntegration = new claude_1.ClaudeIntegration(claudeApiKey);
211
- await validateIntentWithAI(args.intent, claudeIntegration);
212
- logger.debug('Intent validation passed', { requestId });
213
- }
214
- catch (error) {
215
- if (error instanceof Error && error.message.includes('Intent needs more specificity')) {
216
- // This is a validation error that should be returned to the user
217
- throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.VALIDATION, error_handling_1.ErrorSeverity.MEDIUM, error.message, {
218
- operation: 'intent_validation',
219
- component: 'RecommendTool',
167
+ // Initialize Claude integration for potential clarification analysis
168
+ const claudeIntegration = new claude_1.ClaudeIntegration(claudeApiKey);
169
+ // Check if intent clarification is needed (unless final=true)
170
+ if (!args.final) {
171
+ logger.debug('Analyzing intent for clarification opportunities', { requestId, intent: args.intent });
172
+ const analysisResult = await analyzeIntentForClarification(args.intent, claudeIntegration, logger);
173
+ // If clarification opportunities exist, return them to the client agent
174
+ if (analysisResult.clarificationOpportunities &&
175
+ analysisResult.clarificationOpportunities.length > 0 &&
176
+ analysisResult.overallAssessment.enhancementPotential !== 'LOW') {
177
+ // Convert analysis to structured questions for client agent
178
+ const questions = analysisResult.clarificationOpportunities
179
+ .filter((opp) => opp.impactLevel === 'HIGH' || opp.impactLevel === 'MEDIUM')
180
+ .slice(0, 5) // Limit to 5 most important questions
181
+ .map((opp, index) => ({
182
+ id: `clarification-${index + 1}`,
183
+ question: opp.suggestedQuestions?.[0] || `Can you provide more details about ${opp.missingContext.toLowerCase()}?`,
184
+ category: opp.category,
185
+ reasoning: opp.reasoning,
186
+ examples: opp.suggestedQuestions?.slice(1) || []
187
+ }));
188
+ const clarificationResponse = {
189
+ status: 'clarification_available',
190
+ intent: args.intent,
191
+ analysis: {
192
+ enhancementPotential: analysisResult.overallAssessment.enhancementPotential,
193
+ recommendedFocus: analysisResult.overallAssessment.recommendedFocus,
194
+ currentSpecificity: analysisResult.intentQuality.currentSpecificity,
195
+ strengthAreas: analysisResult.intentQuality.strengthAreas,
196
+ improvementAreas: analysisResult.intentQuality.improvementAreas
197
+ },
198
+ questions,
199
+ agentInstructions: 'Present these clarification questions to help the user provide a more specific intent. When the user provides a refined intent (or confirms the current intent is sufficient), call the recommend tool again with final: true to proceed with recommendations.'
200
+ };
201
+ logger.debug('Returning clarification questions', {
220
202
  requestId,
221
- input: { intent: args.intent },
222
- suggestedActions: [
223
- 'Provide more specific details about your deployment',
224
- 'Include technology stack information',
225
- 'Describe the purpose or function of what you want to deploy'
203
+ questionsCount: questions.length,
204
+ enhancementPotential: analysisResult.overallAssessment.enhancementPotential
205
+ });
206
+ return {
207
+ content: [
208
+ {
209
+ type: 'text',
210
+ text: JSON.stringify(clarificationResponse, null, 2)
211
+ }
226
212
  ]
227
- }, error);
213
+ };
228
214
  }
229
- // For other errors, log but continue (don't block user due to AI service issues)
230
- logger.warn('Intent validation failed, continuing with recommendation', { requestId, error: error instanceof Error ? error.message : 'Unknown error' });
215
+ logger.debug('No significant clarification opportunities found, proceeding with recommendations', { requestId });
231
216
  }
217
+ else {
218
+ logger.debug('Skipping intent clarification (final=true), proceeding directly with recommendations', { requestId });
219
+ }
220
+ // Ensure cluster connectivity before proceeding with recommendations
221
+ await (0, cluster_utils_1.ensureClusterConnection)(dotAI, logger, requestId, 'RecommendTool');
232
222
  // Initialize AI-powered ResourceRecommender
233
223
  const rankingConfig = { claudeApiKey };
234
224
  const recommender = new schema_1.ResourceRecommender(rankingConfig);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vfarcic/dot-ai",
3
- "version": "0.66.0",
3
+ "version": "0.67.0",
4
4
  "description": "Universal Kubernetes application deployment agent with MCP interface",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,122 @@
1
+ # Intent Analysis for Clarification Opportunities
2
+
3
+ You are an expert Kubernetes deployment consultant analyzing user intents to identify opportunities for clarification that would lead to better deployment recommendations.
4
+
5
+ ## User Intent
6
+ {intent}
7
+
8
+ ## Organizational Patterns Context
9
+ {organizational_patterns}
10
+
11
+ ## Analysis Framework
12
+
13
+ Analyze the user's intent for **clarification opportunities** that would significantly improve the quality and relevance of deployment recommendations. Focus on identifying missing context that, when provided, would lead to more targeted and appropriate solutions.
14
+
15
+ ### Clarification Categories
16
+
17
+ **1. TECHNICAL SPECIFICATIONS**
18
+ - Specific technology versions, frameworks, or implementations
19
+ - Performance requirements (CPU, memory, throughput, latency)
20
+ - Scalability expectations (traffic patterns, growth projections)
21
+ - Storage requirements (data persistence, volume sizes, access patterns)
22
+
23
+ **2. ARCHITECTURAL CONTEXT**
24
+ - Application architecture patterns (microservices, monolith, serverless)
25
+ - Integration requirements (databases, external services, APIs)
26
+ - Communication patterns (synchronous, asynchronous, event-driven)
27
+ - Deployment patterns (blue-green, rolling, canary)
28
+
29
+ **3. OPERATIONAL REQUIREMENTS**
30
+ - Environment targets (development, staging, production)
31
+ - High availability and disaster recovery needs
32
+ - Monitoring and observability requirements
33
+ - Backup and maintenance procedures
34
+
35
+ **4. SECURITY & COMPLIANCE**
36
+ - Authentication and authorization requirements
37
+ - Data classification and encryption needs
38
+ - Compliance frameworks (GDPR, HIPAA, SOC2, PCI-DSS)
39
+ - Network security policies and isolation requirements
40
+
41
+ **5. ORGANIZATIONAL ALIGNMENT**
42
+ - Team responsibilities and ownership models
43
+ - Existing infrastructure integration points
44
+ - Budget and resource constraints
45
+ - Timeline and rollout preferences
46
+
47
+ ### Opportunity Assessment
48
+
49
+ For each category, evaluate:
50
+ - **Missing Context**: What specific information is absent?
51
+ - **Impact Level**: How much would this information improve recommendations?
52
+ - **Question Potential**: Can this be addressed with a clear, actionable question?
53
+ - **Pattern Alignment**: Does this relate to organizational patterns or standards?
54
+
55
+ ### Question Generation Priorities
56
+
57
+ **HIGH PRIORITY**: Missing context that would fundamentally change the recommended solution
58
+ **MEDIUM PRIORITY**: Information that would optimize the deployment for the user's environment
59
+ **LOW PRIORITY**: Nice-to-have details that provide minor refinements
60
+
61
+ ## Organizational Pattern Integration
62
+
63
+ Use the provided organizational patterns to inform your analysis:
64
+ - Identify alignment opportunities with existing patterns
65
+ - Recognize potential governance requirements
66
+ - Consider standard approaches within the organization
67
+ - Highlight areas where clarification could ensure compliance
68
+
69
+ ## Analysis Guidelines
70
+
71
+ **DO NOT suggest clarification for:**
72
+ - Information that is clearly implied by the intent
73
+ - Standard Kubernetes configurations that have sensible defaults
74
+ - Details that don't significantly impact solution recommendations
75
+ - Overly technical specifics that most users wouldn't know
76
+
77
+ **DO suggest clarification for:**
78
+ - Ambiguous requirements that could lead to multiple valid interpretations
79
+ - Missing context that would change the fundamental solution approach
80
+ - Organizational-specific requirements that align with provided patterns
81
+ - Performance, security, or compliance needs that aren't specified
82
+
83
+ ## Response Format
84
+
85
+ Respond with ONLY a JSON object in this exact format:
86
+
87
+ ```json
88
+ {
89
+ "clarificationOpportunities": [
90
+ {
91
+ "category": "TECHNICAL_SPECIFICATIONS|ARCHITECTURAL_CONTEXT|OPERATIONAL_REQUIREMENTS|SECURITY_COMPLIANCE|ORGANIZATIONAL_ALIGNMENT",
92
+ "missingContext": "Specific description of what context is missing",
93
+ "impactLevel": "HIGH|MEDIUM|LOW",
94
+ "reasoning": "Why this clarification would improve recommendations",
95
+ "suggestedQuestions": [
96
+ "Specific question that could gather this information",
97
+ "Alternative question approach for the same context"
98
+ ],
99
+ "patternAlignment": "How this relates to organizational patterns (if applicable)"
100
+ }
101
+ ],
102
+ "overallAssessment": {
103
+ "enhancementPotential": "HIGH|MEDIUM|LOW",
104
+ "primaryGaps": ["Most important missing context area 1", "Most important missing context area 2"],
105
+ "recommendedFocus": "The single most valuable clarification opportunity"
106
+ },
107
+ "intentQuality": {
108
+ "currentSpecificity": "Assessment of how specific the intent currently is",
109
+ "strengthAreas": ["What aspects of the intent are already clear"],
110
+ "improvementAreas": ["What aspects would benefit most from clarification"]
111
+ }
112
+ }
113
+ ```
114
+
115
+ ## Important Notes
116
+
117
+ - Focus on **meaningful clarification opportunities** that would lead to measurably better recommendations
118
+ - Consider the **user's perspective** - suggest questions they can actually answer
119
+ - **Prioritize ruthlessly** - only suggest clarification that provides significant value
120
+ - **Leverage organizational patterns** to identify governance and compliance opportunities
121
+ - **Be practical** - ensure suggested questions are actionable and specific
122
+ - **Quality over quantity** - fewer high-impact opportunities are better than many low-impact ones
@@ -58,9 +58,21 @@ Complete the PRD implementation workflow including branch management, pull reque
58
58
  ### 4. Review and Merge Process
59
59
  - [ ] **Check ongoing processes**: Use `gh pr checks [pr-number]` to check for any ongoing CI/CD, security analysis, or automated reviews (CodeRabbit, CodeQL, etc.)
60
60
  - [ ] **Check PR details**: Use `gh pr view [pr-number]` to check for human review comments and PR metadata
61
+ - [ ] **Review all automated feedback**: Check PR comments section for automated code review feedback (bots, linters, analyzers)
62
+ - Look for actionable suggestions about code quality, security, performance, or maintainability
63
+ - Check for recommendations about test coverage, error handling, or architectural improvements
64
+ - Review suggestions for refactoring, type safety, or code organization
65
+ - [ ] **Assess feedback priority**: Categorize review feedback
66
+ - **Critical**: Security issues, breaking changes, test failures - MUST address before merge
67
+ - **Important**: Code quality, maintainability, performance - SHOULD address for production readiness
68
+ - **Optional**: Style preferences, minor optimizations - MAY address based on project standards
61
69
  - [ ] **Wait for completion**: Do NOT merge if checks show pending processes or PR comments indicate reviews still in progress
62
- - [ ] **Address review feedback**: Make any required changes from code review (both automated and human)
70
+ - [ ] **Address review feedback**: Make required changes from code review (both automated and human)
71
+ - Create additional commits on the feature branch to address feedback
72
+ - Update tests if needed to cover suggested improvements
73
+ - Document any feedback that was intentionally not addressed and why
63
74
  - [ ] **Verify all checks pass**: Ensure all CI/CD, tests, security analysis, and automated processes are complete and passing
75
+ - [ ] **Final review**: Confirm the PR addresses the original PRD requirements and maintains code quality
64
76
  - [ ] **Merge to main**: Complete the pull request merge only after all feedback addressed and processes complete
65
77
  - [ ] **Verify deployment**: Ensure feature works in production environment
66
78
  - [ ] **Monitor for issues**: Watch for any post-deployment problems
@@ -1,74 +0,0 @@
1
- # Intent Validation for Kubernetes Deployment Recommendations
2
-
3
- You are a Kubernetes expert analyzing user intents for deployment recommendations. Evaluate whether this intent provides enough specificity to generate meaningful Kubernetes deployment recommendations.
4
-
5
- ## User Intent
6
- {intent}
7
-
8
- ## Evaluation Criteria
9
-
10
- An intent is **TOO VAGUE OR GENERIC** if it:
11
- - Completely generic terms without context (e.g., just "app", "something", "service" alone)
12
- - Single action words without objects (e.g., "deploy", "create", "setup", "run" alone)
13
- - Meaningless requests (e.g., "help", "please", "can you")
14
- - Extremely short without any technical context (1-2 words like "database", "container")
15
-
16
- An intent is **SPECIFIC ENOUGH** if it includes ANY of:
17
- - Specific technology or framework (Node.js, PostgreSQL, Redis, React, Python, Prometheus, Grafana, etc.)
18
- - Clear architectural pattern (stateless app, microservice, web server, REST API, operator, etc.)
19
- - Application type or purpose (frontend, backend, database, cache, queue, monitoring, storage, etc.)
20
- - Infrastructure component (load balancer, ingress controller, persistent storage, networking, etc.)
21
- - Deployment context that helps understand Kubernetes resource needs
22
-
23
- **IMPORTANT**: Be generous in accepting intents. Focus on rejecting only truly meaningless requests. Terms like "stateless app", "web application", "microservice", "database cluster" provide sufficient Kubernetes deployment context.
24
-
25
- ## Examples
26
-
27
- **TOO VAGUE:**
28
- - "create an app" (no architectural or technical context)
29
- - "deploy something" (completely generic)
30
- - "database" (single word, no context)
31
- - "help" (not a deployment request)
32
- - "app" (single word)
33
- - "setup" (action without object)
34
-
35
- **SPECIFIC ENOUGH:**
36
- - "stateless app" (architectural pattern + type)
37
- - "web application" (clear application type)
38
- - "microservice" (architectural pattern)
39
- - "REST API" (clear service type)
40
- - "database cluster" (type + deployment pattern)
41
- - "Node.js application" (technology + type)
42
- - "frontend service" (purpose + type)
43
- - "cache service" (purpose + type)
44
- - "PostgreSQL database" (technology + infrastructure type)
45
- - "Redis cache" (technology + infrastructure purpose)
46
- - "Prometheus monitoring" (technology + infrastructure purpose)
47
- - "Ingress controller" (infrastructure component + type)
48
- - "MongoDB operator" (technology + operator pattern)
49
- - "load balancer" (infrastructure component)
50
- - "persistent storage" (infrastructure capability)
51
- - "CI/CD pipeline" (workflow automation)
52
-
53
- ## Response Format
54
-
55
- Respond with ONLY a JSON object in this exact format:
56
-
57
- ```json
58
- {
59
- "isSpecific": boolean,
60
- "reason": "brief explanation of why it is or isn't specific enough",
61
- "suggestions": [
62
- "specific suggestion 1 to improve the intent",
63
- "specific suggestion 2 to improve the intent",
64
- "specific suggestion 3 to improve the intent"
65
- ]
66
- }
67
- ```
68
-
69
- **IMPORTANT:**
70
- - Your response must be ONLY the JSON object, nothing else
71
- - If `isSpecific` is true, still provide 3 suggestions for making it even more detailed
72
- - If `isSpecific` is false, provide 3 concrete suggestions to make it deployable
73
- - Keep suggestions practical and actionable
74
- - Focus on what technologies, purposes, or contexts are missing