@corbat-tech/coding-standards-mcp 1.0.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.
- package/LICENSE +21 -0
- package/README.md +371 -0
- package/assets/demo.gif +0 -0
- package/dist/agent.d.ts +53 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +629 -0
- package/dist/agent.js.map +1 -0
- package/dist/cli/init.d.ts +3 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +651 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/config.d.ts +73 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +105 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/profiles.d.ts +39 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +526 -0
- package/dist/profiles.js.map +1 -0
- package/dist/prompts-legacy.d.ts +25 -0
- package/dist/prompts-legacy.d.ts.map +1 -0
- package/dist/prompts-legacy.js +600 -0
- package/dist/prompts-legacy.js.map +1 -0
- package/dist/prompts-v2.d.ts +30 -0
- package/dist/prompts-v2.d.ts.map +1 -0
- package/dist/prompts-v2.js +310 -0
- package/dist/prompts-v2.js.map +1 -0
- package/dist/prompts.d.ts +30 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +310 -0
- package/dist/prompts.js.map +1 -0
- package/dist/resources.d.ts +18 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +95 -0
- package/dist/resources.js.map +1 -0
- package/dist/tools-legacy.d.ts +196 -0
- package/dist/tools-legacy.d.ts.map +1 -0
- package/dist/tools-legacy.js +1230 -0
- package/dist/tools-legacy.js.map +1 -0
- package/dist/tools-v2.d.ts +92 -0
- package/dist/tools-v2.d.ts.map +1 -0
- package/dist/tools-v2.js +410 -0
- package/dist/tools-v2.js.map +1 -0
- package/dist/tools.d.ts +92 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +410 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +3054 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +515 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/retry.d.ts +44 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +74 -0
- package/dist/utils/retry.js.map +1 -0
- package/package.json +79 -0
- package/profiles/README.md +199 -0
- package/profiles/custom/.gitkeep +2 -0
- package/profiles/templates/_template.yaml +159 -0
- package/profiles/templates/angular.yaml +494 -0
- package/profiles/templates/java-spring-backend.yaml +512 -0
- package/profiles/templates/minimal.yaml +102 -0
- package/profiles/templates/nodejs.yaml +338 -0
- package/profiles/templates/python.yaml +340 -0
- package/profiles/templates/react.yaml +331 -0
- package/profiles/templates/vue.yaml +598 -0
- package/standards/architecture/ddd.md +173 -0
- package/standards/architecture/hexagonal.md +97 -0
- package/standards/cicd/github-actions.md +567 -0
- package/standards/clean-code/naming.md +175 -0
- package/standards/clean-code/principles.md +179 -0
- package/standards/containerization/dockerfile.md +419 -0
- package/standards/database/selection-guide.md +443 -0
- package/standards/documentation/guidelines.md +189 -0
- package/standards/event-driven/domain-events.md +527 -0
- package/standards/kubernetes/deployment.md +518 -0
- package/standards/observability/guidelines.md +665 -0
- package/standards/project-setup/initialization-checklist.md +650 -0
- package/standards/spring-boot/best-practices.md +598 -0
- package/standards/testing/guidelines.md +559 -0
- package/standards/workflow/llm-development-workflow.md +542 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { classifyTaskType, detectProjectStack, getGuardrails, getProjectRules, loadProjectConfig } from './agent.js';
|
|
2
|
+
import { config } from './config.js';
|
|
3
|
+
import { getProfile } from './profiles.js';
|
|
4
|
+
/**
|
|
5
|
+
* SIMPLIFIED PROMPT DEFINITIONS (2 prompts instead of 7)
|
|
6
|
+
*
|
|
7
|
+
* Design principles:
|
|
8
|
+
* - One prompt for implementation
|
|
9
|
+
* - One prompt for review
|
|
10
|
+
* - Both are comprehensive but concise
|
|
11
|
+
*/
|
|
12
|
+
export const prompts = [
|
|
13
|
+
{
|
|
14
|
+
name: 'implement',
|
|
15
|
+
description: 'Guide implementation with coding standards, guardrails, and structured workflow. Use for any feature, fix, or task.',
|
|
16
|
+
arguments: [
|
|
17
|
+
{
|
|
18
|
+
name: 'task',
|
|
19
|
+
description: 'What to implement (e.g., "Create payment service", "Fix login bug")',
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'project_dir',
|
|
24
|
+
description: 'Project directory for auto-detection (optional)',
|
|
25
|
+
required: false,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'review',
|
|
31
|
+
description: 'Review code against coding standards. Finds issues, suggests improvements, gives compliance score.',
|
|
32
|
+
arguments: [
|
|
33
|
+
{
|
|
34
|
+
name: 'code',
|
|
35
|
+
description: 'The code to review',
|
|
36
|
+
required: true,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'role',
|
|
40
|
+
description: 'Expert role: architect, backend, security, performance (optional)',
|
|
41
|
+
required: false,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
/**
|
|
47
|
+
* Handle prompt requests.
|
|
48
|
+
*/
|
|
49
|
+
export async function handleGetPrompt(name, args) {
|
|
50
|
+
switch (name) {
|
|
51
|
+
case 'implement':
|
|
52
|
+
return handleImplementPrompt(args);
|
|
53
|
+
case 'review':
|
|
54
|
+
return handleReviewPrompt(args);
|
|
55
|
+
default:
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Implementation prompt - comprehensive but concise.
|
|
61
|
+
*/
|
|
62
|
+
async function handleImplementPrompt(args) {
|
|
63
|
+
const task = args?.task;
|
|
64
|
+
if (!task)
|
|
65
|
+
return null;
|
|
66
|
+
const projectDir = args?.project_dir;
|
|
67
|
+
// Classify task
|
|
68
|
+
const taskType = classifyTaskType(task);
|
|
69
|
+
// Auto-detect if project dir provided
|
|
70
|
+
let detectedStack = null;
|
|
71
|
+
let projectConfig = null;
|
|
72
|
+
if (projectDir) {
|
|
73
|
+
detectedStack = await detectProjectStack(projectDir);
|
|
74
|
+
projectConfig = await loadProjectConfig(projectDir);
|
|
75
|
+
}
|
|
76
|
+
// Get profile
|
|
77
|
+
const profileId = projectConfig?.profile || detectedStack?.suggestedProfile || config.defaultProfile;
|
|
78
|
+
const profile = await getProfile(profileId);
|
|
79
|
+
if (!profile)
|
|
80
|
+
return null;
|
|
81
|
+
// Get guardrails
|
|
82
|
+
const guardrails = getGuardrails(taskType, projectConfig);
|
|
83
|
+
const projectRules = getProjectRules(taskType, projectConfig);
|
|
84
|
+
// Build prompt
|
|
85
|
+
const lines = [
|
|
86
|
+
'# CORBAT IMPLEMENTATION GUIDE',
|
|
87
|
+
'',
|
|
88
|
+
'---',
|
|
89
|
+
'',
|
|
90
|
+
'## Task',
|
|
91
|
+
'',
|
|
92
|
+
`**${task}**`,
|
|
93
|
+
'',
|
|
94
|
+
`Type: ${taskType.toUpperCase()} | Profile: ${profileId}`,
|
|
95
|
+
];
|
|
96
|
+
// Stack info
|
|
97
|
+
if (detectedStack) {
|
|
98
|
+
const stack = [detectedStack.language, detectedStack.framework, detectedStack.buildTool]
|
|
99
|
+
.filter(Boolean)
|
|
100
|
+
.join(' · ');
|
|
101
|
+
lines.push(`Stack: ${stack}`);
|
|
102
|
+
}
|
|
103
|
+
lines.push('');
|
|
104
|
+
// Guardrails (critical)
|
|
105
|
+
lines.push('---', '', '## Guardrails', '');
|
|
106
|
+
lines.push('**MUST:**');
|
|
107
|
+
for (const rule of guardrails.mandatory) {
|
|
108
|
+
lines.push(`- ${rule}`);
|
|
109
|
+
}
|
|
110
|
+
lines.push('');
|
|
111
|
+
lines.push('**AVOID:**');
|
|
112
|
+
for (const rule of guardrails.avoid) {
|
|
113
|
+
lines.push(`- ${rule}`);
|
|
114
|
+
}
|
|
115
|
+
lines.push('');
|
|
116
|
+
// Project rules
|
|
117
|
+
if (projectRules.length > 0) {
|
|
118
|
+
lines.push('**PROJECT RULES:**');
|
|
119
|
+
for (const rule of projectRules) {
|
|
120
|
+
lines.push(`- ${rule}`);
|
|
121
|
+
}
|
|
122
|
+
lines.push('');
|
|
123
|
+
}
|
|
124
|
+
// Code quality
|
|
125
|
+
if (profile.codeQuality) {
|
|
126
|
+
lines.push('---', '', '## Code Quality', '');
|
|
127
|
+
lines.push(`- Max method: ${profile.codeQuality.maxMethodLines} lines`);
|
|
128
|
+
lines.push(`- Max class: ${profile.codeQuality.maxClassLines} lines`);
|
|
129
|
+
lines.push(`- Coverage: ${profile.codeQuality.minimumTestCoverage}%+`);
|
|
130
|
+
lines.push('');
|
|
131
|
+
}
|
|
132
|
+
// Architecture
|
|
133
|
+
if (profile.architecture) {
|
|
134
|
+
lines.push('---', '', '## Architecture', '');
|
|
135
|
+
lines.push(`Pattern: **${profile.architecture.type}**`);
|
|
136
|
+
if (profile.architecture.layers) {
|
|
137
|
+
lines.push('');
|
|
138
|
+
lines.push('Layers:');
|
|
139
|
+
for (const layer of profile.architecture.layers) {
|
|
140
|
+
const deps = layer.allowedDependencies.length > 0 ? `→ ${layer.allowedDependencies.join(', ')}` : '(no dependencies)';
|
|
141
|
+
lines.push(`- **${layer.name}** ${deps}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
lines.push('');
|
|
145
|
+
}
|
|
146
|
+
// Naming conventions (concise)
|
|
147
|
+
if (profile.naming) {
|
|
148
|
+
lines.push('---', '', '## Naming', '');
|
|
149
|
+
const naming = profile.naming;
|
|
150
|
+
if (naming.general && typeof naming.general === 'object') {
|
|
151
|
+
for (const [key, value] of Object.entries(naming.general)) {
|
|
152
|
+
lines.push(`- ${key}: ${value}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (naming.suffixes && typeof naming.suffixes === 'object') {
|
|
156
|
+
lines.push('');
|
|
157
|
+
for (const [key, value] of Object.entries(naming.suffixes)) {
|
|
158
|
+
lines.push(`- ${key}: \`${value}\``);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
lines.push('');
|
|
162
|
+
}
|
|
163
|
+
// Workflow
|
|
164
|
+
lines.push('---', '', '## Workflow', '');
|
|
165
|
+
lines.push(`
|
|
166
|
+
Follow these phases:
|
|
167
|
+
|
|
168
|
+
### 1. CLARIFY
|
|
169
|
+
- Analyze requirements
|
|
170
|
+
- ASK if anything is unclear
|
|
171
|
+
- Confirm understanding
|
|
172
|
+
|
|
173
|
+
### 2. PLAN
|
|
174
|
+
Create task checklist:
|
|
175
|
+
\`\`\`
|
|
176
|
+
[ ] Task 1
|
|
177
|
+
[ ] Write test
|
|
178
|
+
[ ] Implement
|
|
179
|
+
[ ] Task 2
|
|
180
|
+
...
|
|
181
|
+
\`\`\`
|
|
182
|
+
|
|
183
|
+
### 3. BUILD (TDD)
|
|
184
|
+
For each task:
|
|
185
|
+
1. RED - Write failing test
|
|
186
|
+
2. GREEN - Minimum code to pass
|
|
187
|
+
3. REFACTOR - Clean up
|
|
188
|
+
|
|
189
|
+
### 4. VERIFY
|
|
190
|
+
- [ ] Code compiles
|
|
191
|
+
- [ ] Tests pass
|
|
192
|
+
- [ ] Linter clean
|
|
193
|
+
|
|
194
|
+
### 5. REVIEW
|
|
195
|
+
Self-review as expert:
|
|
196
|
+
- CRITICAL issues (must fix)
|
|
197
|
+
- RECOMMENDED improvements
|
|
198
|
+
- Score 1-10
|
|
199
|
+
`);
|
|
200
|
+
lines.push('---', '', '**BEGIN with Phase 1 (CLARIFY).** Ask questions if unclear, otherwise proceed to PLAN.');
|
|
201
|
+
return {
|
|
202
|
+
messages: [
|
|
203
|
+
{
|
|
204
|
+
role: 'user',
|
|
205
|
+
content: { type: 'text', text: lines.join('\n') },
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Review prompt - expert code review.
|
|
212
|
+
*/
|
|
213
|
+
async function handleReviewPrompt(args) {
|
|
214
|
+
const code = args?.code;
|
|
215
|
+
if (!code)
|
|
216
|
+
return null;
|
|
217
|
+
const role = args?.role || 'senior developer';
|
|
218
|
+
const profileId = config.defaultProfile;
|
|
219
|
+
const profile = await getProfile(profileId);
|
|
220
|
+
if (!profile)
|
|
221
|
+
return null;
|
|
222
|
+
// Role descriptions
|
|
223
|
+
const roleDescriptions = {
|
|
224
|
+
architect: 'Software Architect (15+ years) - focus on design, patterns, scalability',
|
|
225
|
+
backend: 'Senior Backend Developer (15+ years) - focus on APIs, performance, clean code',
|
|
226
|
+
security: 'Security Engineer (15+ years) - focus on vulnerabilities, OWASP, secure coding',
|
|
227
|
+
performance: 'Performance Engineer (15+ years) - focus on optimization, profiling, bottlenecks',
|
|
228
|
+
frontend: 'Senior Frontend Developer (15+ years) - focus on components, state, UX',
|
|
229
|
+
};
|
|
230
|
+
const roleDesc = roleDescriptions[role.toLowerCase()] || `Senior ${role} Expert (15+ years)`;
|
|
231
|
+
const lines = [
|
|
232
|
+
'# EXPERT CODE REVIEW',
|
|
233
|
+
'',
|
|
234
|
+
`**Role:** ${roleDesc}`,
|
|
235
|
+
'',
|
|
236
|
+
'You are reviewing this code FROM SCRATCH with no prior knowledge.',
|
|
237
|
+
'',
|
|
238
|
+
'---',
|
|
239
|
+
'',
|
|
240
|
+
'## Code',
|
|
241
|
+
'',
|
|
242
|
+
'```',
|
|
243
|
+
code,
|
|
244
|
+
'```',
|
|
245
|
+
'',
|
|
246
|
+
'---',
|
|
247
|
+
'',
|
|
248
|
+
'## Standards to Apply',
|
|
249
|
+
'',
|
|
250
|
+
];
|
|
251
|
+
// Code quality
|
|
252
|
+
if (profile.codeQuality) {
|
|
253
|
+
lines.push('**Thresholds:**');
|
|
254
|
+
lines.push(`- Method: max ${profile.codeQuality.maxMethodLines} lines`);
|
|
255
|
+
lines.push(`- Class: max ${profile.codeQuality.maxClassLines} lines`);
|
|
256
|
+
lines.push(`- Parameters: max ${profile.codeQuality.maxMethodParameters}`);
|
|
257
|
+
lines.push(`- Coverage: ${profile.codeQuality.minimumTestCoverage}%+`);
|
|
258
|
+
lines.push('');
|
|
259
|
+
}
|
|
260
|
+
// Architecture
|
|
261
|
+
if (profile.architecture) {
|
|
262
|
+
lines.push(`**Architecture:** ${profile.architecture.type}`);
|
|
263
|
+
lines.push('');
|
|
264
|
+
}
|
|
265
|
+
// Naming
|
|
266
|
+
if (profile.naming) {
|
|
267
|
+
lines.push('**Naming:**');
|
|
268
|
+
const naming = profile.naming;
|
|
269
|
+
if (naming.general && typeof naming.general === 'object') {
|
|
270
|
+
for (const [key, value] of Object.entries(naming.general)) {
|
|
271
|
+
lines.push(`- ${key}: ${value}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
lines.push('');
|
|
275
|
+
}
|
|
276
|
+
lines.push('---', '', '## Your Review', '');
|
|
277
|
+
lines.push(`
|
|
278
|
+
### 1. CRITICAL ISSUES (must fix)
|
|
279
|
+
- Bugs, security vulnerabilities
|
|
280
|
+
- Architecture violations
|
|
281
|
+
- Performance problems
|
|
282
|
+
- Data integrity risks
|
|
283
|
+
|
|
284
|
+
### 2. WARNINGS (should fix)
|
|
285
|
+
- Style violations
|
|
286
|
+
- Missing best practices
|
|
287
|
+
- Readability issues
|
|
288
|
+
- Missing tests
|
|
289
|
+
|
|
290
|
+
### 3. SUGGESTIONS (nice to have)
|
|
291
|
+
- Refactoring opportunities
|
|
292
|
+
- Alternative patterns
|
|
293
|
+
- Future improvements
|
|
294
|
+
|
|
295
|
+
### 4. SCORE
|
|
296
|
+
- Rating: X/10
|
|
297
|
+
- Summary: [key concerns and strengths]
|
|
298
|
+
|
|
299
|
+
Be thorough and specific. Reference line numbers when possible.
|
|
300
|
+
`);
|
|
301
|
+
return {
|
|
302
|
+
messages: [
|
|
303
|
+
{
|
|
304
|
+
role: 'user',
|
|
305
|
+
content: { type: 'text', text: lines.join('\n') },
|
|
306
|
+
},
|
|
307
|
+
],
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
//# sourceMappingURL=prompts-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts-v2.js","sourceRoot":"","sources":["../src/prompts-v2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,aAAa,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACrH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EACT,qHAAqH;QACvH,SAAS,EAAE;YACT;gBACE,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,qEAAqE;gBAClF,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,iDAAiD;gBAC9D,QAAQ,EAAE,KAAK;aAChB;SACF;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,oGAAoG;QACjH,SAAS,EAAE;YACT;gBACE,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,oBAAoB;gBACjC,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,mEAAmE;gBAChF,QAAQ,EAAE,KAAK;aAChB;SACF;KACF;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAAY,EACZ,IAAwC;I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AAC;IAED,OAAO;QACL,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;aAClD;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SIMPLIFIED PROMPT DEFINITIONS (2 prompts instead of 7)
|
|
3
|
+
*
|
|
4
|
+
* Design principles:
|
|
5
|
+
* - One prompt for implementation
|
|
6
|
+
* - One prompt for review
|
|
7
|
+
* - Both are comprehensive but concise
|
|
8
|
+
*/
|
|
9
|
+
export declare const prompts: {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
arguments: {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
required: boolean;
|
|
16
|
+
}[];
|
|
17
|
+
}[];
|
|
18
|
+
/**
|
|
19
|
+
* Handle prompt requests.
|
|
20
|
+
*/
|
|
21
|
+
export declare function handleGetPrompt(name: string, args: Record<string, string> | undefined): Promise<{
|
|
22
|
+
messages: Array<{
|
|
23
|
+
role: 'user';
|
|
24
|
+
content: {
|
|
25
|
+
type: 'text';
|
|
26
|
+
text: string;
|
|
27
|
+
};
|
|
28
|
+
}>;
|
|
29
|
+
} | null>;
|
|
30
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO;;;;;;;;GAkCnB,CAAC;AAEF;;GAEG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GACvC,OAAO,CAAC;IACT,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC,CAAC;CAC5E,GAAG,IAAI,CAAC,CASR"}
|
package/dist/prompts.js
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { classifyTaskType, detectProjectStack, getGuardrails, getProjectRules, loadProjectConfig } from './agent.js';
|
|
2
|
+
import { config } from './config.js';
|
|
3
|
+
import { getProfile } from './profiles.js';
|
|
4
|
+
/**
|
|
5
|
+
* SIMPLIFIED PROMPT DEFINITIONS (2 prompts instead of 7)
|
|
6
|
+
*
|
|
7
|
+
* Design principles:
|
|
8
|
+
* - One prompt for implementation
|
|
9
|
+
* - One prompt for review
|
|
10
|
+
* - Both are comprehensive but concise
|
|
11
|
+
*/
|
|
12
|
+
export const prompts = [
|
|
13
|
+
{
|
|
14
|
+
name: 'implement',
|
|
15
|
+
description: 'Guide implementation with coding standards, guardrails, and structured workflow. Use for any feature, fix, or task.',
|
|
16
|
+
arguments: [
|
|
17
|
+
{
|
|
18
|
+
name: 'task',
|
|
19
|
+
description: 'What to implement (e.g., "Create payment service", "Fix login bug")',
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'project_dir',
|
|
24
|
+
description: 'Project directory for auto-detection (optional)',
|
|
25
|
+
required: false,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'review',
|
|
31
|
+
description: 'Review code against coding standards. Finds issues, suggests improvements, gives compliance score.',
|
|
32
|
+
arguments: [
|
|
33
|
+
{
|
|
34
|
+
name: 'code',
|
|
35
|
+
description: 'The code to review',
|
|
36
|
+
required: true,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'role',
|
|
40
|
+
description: 'Expert role: architect, backend, security, performance (optional)',
|
|
41
|
+
required: false,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
/**
|
|
47
|
+
* Handle prompt requests.
|
|
48
|
+
*/
|
|
49
|
+
export async function handleGetPrompt(name, args) {
|
|
50
|
+
switch (name) {
|
|
51
|
+
case 'implement':
|
|
52
|
+
return handleImplementPrompt(args);
|
|
53
|
+
case 'review':
|
|
54
|
+
return handleReviewPrompt(args);
|
|
55
|
+
default:
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Implementation prompt - comprehensive but concise.
|
|
61
|
+
*/
|
|
62
|
+
async function handleImplementPrompt(args) {
|
|
63
|
+
const task = args?.task;
|
|
64
|
+
if (!task)
|
|
65
|
+
return null;
|
|
66
|
+
const projectDir = args?.project_dir;
|
|
67
|
+
// Classify task
|
|
68
|
+
const taskType = classifyTaskType(task);
|
|
69
|
+
// Auto-detect if project dir provided
|
|
70
|
+
let detectedStack = null;
|
|
71
|
+
let projectConfig = null;
|
|
72
|
+
if (projectDir) {
|
|
73
|
+
detectedStack = await detectProjectStack(projectDir);
|
|
74
|
+
projectConfig = await loadProjectConfig(projectDir);
|
|
75
|
+
}
|
|
76
|
+
// Get profile
|
|
77
|
+
const profileId = projectConfig?.profile || detectedStack?.suggestedProfile || config.defaultProfile;
|
|
78
|
+
const profile = await getProfile(profileId);
|
|
79
|
+
if (!profile)
|
|
80
|
+
return null;
|
|
81
|
+
// Get guardrails
|
|
82
|
+
const guardrails = getGuardrails(taskType, projectConfig);
|
|
83
|
+
const projectRules = getProjectRules(taskType, projectConfig);
|
|
84
|
+
// Build prompt
|
|
85
|
+
const lines = [
|
|
86
|
+
'# CORBAT IMPLEMENTATION GUIDE',
|
|
87
|
+
'',
|
|
88
|
+
'---',
|
|
89
|
+
'',
|
|
90
|
+
'## Task',
|
|
91
|
+
'',
|
|
92
|
+
`**${task}**`,
|
|
93
|
+
'',
|
|
94
|
+
`Type: ${taskType.toUpperCase()} | Profile: ${profileId}`,
|
|
95
|
+
];
|
|
96
|
+
// Stack info
|
|
97
|
+
if (detectedStack) {
|
|
98
|
+
const stack = [detectedStack.language, detectedStack.framework, detectedStack.buildTool]
|
|
99
|
+
.filter(Boolean)
|
|
100
|
+
.join(' · ');
|
|
101
|
+
lines.push(`Stack: ${stack}`);
|
|
102
|
+
}
|
|
103
|
+
lines.push('');
|
|
104
|
+
// Guardrails (critical)
|
|
105
|
+
lines.push('---', '', '## Guardrails', '');
|
|
106
|
+
lines.push('**MUST:**');
|
|
107
|
+
for (const rule of guardrails.mandatory) {
|
|
108
|
+
lines.push(`- ${rule}`);
|
|
109
|
+
}
|
|
110
|
+
lines.push('');
|
|
111
|
+
lines.push('**AVOID:**');
|
|
112
|
+
for (const rule of guardrails.avoid) {
|
|
113
|
+
lines.push(`- ${rule}`);
|
|
114
|
+
}
|
|
115
|
+
lines.push('');
|
|
116
|
+
// Project rules
|
|
117
|
+
if (projectRules.length > 0) {
|
|
118
|
+
lines.push('**PROJECT RULES:**');
|
|
119
|
+
for (const rule of projectRules) {
|
|
120
|
+
lines.push(`- ${rule}`);
|
|
121
|
+
}
|
|
122
|
+
lines.push('');
|
|
123
|
+
}
|
|
124
|
+
// Code quality
|
|
125
|
+
if (profile.codeQuality) {
|
|
126
|
+
lines.push('---', '', '## Code Quality', '');
|
|
127
|
+
lines.push(`- Max method: ${profile.codeQuality.maxMethodLines} lines`);
|
|
128
|
+
lines.push(`- Max class: ${profile.codeQuality.maxClassLines} lines`);
|
|
129
|
+
lines.push(`- Coverage: ${profile.codeQuality.minimumTestCoverage}%+`);
|
|
130
|
+
lines.push('');
|
|
131
|
+
}
|
|
132
|
+
// Architecture
|
|
133
|
+
if (profile.architecture) {
|
|
134
|
+
lines.push('---', '', '## Architecture', '');
|
|
135
|
+
lines.push(`Pattern: **${profile.architecture.type}**`);
|
|
136
|
+
if (profile.architecture.layers) {
|
|
137
|
+
lines.push('');
|
|
138
|
+
lines.push('Layers:');
|
|
139
|
+
for (const layer of profile.architecture.layers) {
|
|
140
|
+
const deps = layer.allowedDependencies.length > 0 ? `→ ${layer.allowedDependencies.join(', ')}` : '(no dependencies)';
|
|
141
|
+
lines.push(`- **${layer.name}** ${deps}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
lines.push('');
|
|
145
|
+
}
|
|
146
|
+
// Naming conventions (concise)
|
|
147
|
+
if (profile.naming) {
|
|
148
|
+
lines.push('---', '', '## Naming', '');
|
|
149
|
+
const naming = profile.naming;
|
|
150
|
+
if (naming.general && typeof naming.general === 'object') {
|
|
151
|
+
for (const [key, value] of Object.entries(naming.general)) {
|
|
152
|
+
lines.push(`- ${key}: ${value}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (naming.suffixes && typeof naming.suffixes === 'object') {
|
|
156
|
+
lines.push('');
|
|
157
|
+
for (const [key, value] of Object.entries(naming.suffixes)) {
|
|
158
|
+
lines.push(`- ${key}: \`${value}\``);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
lines.push('');
|
|
162
|
+
}
|
|
163
|
+
// Workflow
|
|
164
|
+
lines.push('---', '', '## Workflow', '');
|
|
165
|
+
lines.push(`
|
|
166
|
+
Follow these phases:
|
|
167
|
+
|
|
168
|
+
### 1. CLARIFY
|
|
169
|
+
- Analyze requirements
|
|
170
|
+
- ASK if anything is unclear
|
|
171
|
+
- Confirm understanding
|
|
172
|
+
|
|
173
|
+
### 2. PLAN
|
|
174
|
+
Create task checklist:
|
|
175
|
+
\`\`\`
|
|
176
|
+
[ ] Task 1
|
|
177
|
+
[ ] Write test
|
|
178
|
+
[ ] Implement
|
|
179
|
+
[ ] Task 2
|
|
180
|
+
...
|
|
181
|
+
\`\`\`
|
|
182
|
+
|
|
183
|
+
### 3. BUILD (TDD)
|
|
184
|
+
For each task:
|
|
185
|
+
1. RED - Write failing test
|
|
186
|
+
2. GREEN - Minimum code to pass
|
|
187
|
+
3. REFACTOR - Clean up
|
|
188
|
+
|
|
189
|
+
### 4. VERIFY
|
|
190
|
+
- [ ] Code compiles
|
|
191
|
+
- [ ] Tests pass
|
|
192
|
+
- [ ] Linter clean
|
|
193
|
+
|
|
194
|
+
### 5. REVIEW
|
|
195
|
+
Self-review as expert:
|
|
196
|
+
- CRITICAL issues (must fix)
|
|
197
|
+
- RECOMMENDED improvements
|
|
198
|
+
- Score 1-10
|
|
199
|
+
`);
|
|
200
|
+
lines.push('---', '', '**BEGIN with Phase 1 (CLARIFY).** Ask questions if unclear, otherwise proceed to PLAN.');
|
|
201
|
+
return {
|
|
202
|
+
messages: [
|
|
203
|
+
{
|
|
204
|
+
role: 'user',
|
|
205
|
+
content: { type: 'text', text: lines.join('\n') },
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Review prompt - expert code review.
|
|
212
|
+
*/
|
|
213
|
+
async function handleReviewPrompt(args) {
|
|
214
|
+
const code = args?.code;
|
|
215
|
+
if (!code)
|
|
216
|
+
return null;
|
|
217
|
+
const role = args?.role || 'senior developer';
|
|
218
|
+
const profileId = config.defaultProfile;
|
|
219
|
+
const profile = await getProfile(profileId);
|
|
220
|
+
if (!profile)
|
|
221
|
+
return null;
|
|
222
|
+
// Role descriptions
|
|
223
|
+
const roleDescriptions = {
|
|
224
|
+
architect: 'Software Architect (15+ years) - focus on design, patterns, scalability',
|
|
225
|
+
backend: 'Senior Backend Developer (15+ years) - focus on APIs, performance, clean code',
|
|
226
|
+
security: 'Security Engineer (15+ years) - focus on vulnerabilities, OWASP, secure coding',
|
|
227
|
+
performance: 'Performance Engineer (15+ years) - focus on optimization, profiling, bottlenecks',
|
|
228
|
+
frontend: 'Senior Frontend Developer (15+ years) - focus on components, state, UX',
|
|
229
|
+
};
|
|
230
|
+
const roleDesc = roleDescriptions[role.toLowerCase()] || `Senior ${role} Expert (15+ years)`;
|
|
231
|
+
const lines = [
|
|
232
|
+
'# EXPERT CODE REVIEW',
|
|
233
|
+
'',
|
|
234
|
+
`**Role:** ${roleDesc}`,
|
|
235
|
+
'',
|
|
236
|
+
'You are reviewing this code FROM SCRATCH with no prior knowledge.',
|
|
237
|
+
'',
|
|
238
|
+
'---',
|
|
239
|
+
'',
|
|
240
|
+
'## Code',
|
|
241
|
+
'',
|
|
242
|
+
'```',
|
|
243
|
+
code,
|
|
244
|
+
'```',
|
|
245
|
+
'',
|
|
246
|
+
'---',
|
|
247
|
+
'',
|
|
248
|
+
'## Standards to Apply',
|
|
249
|
+
'',
|
|
250
|
+
];
|
|
251
|
+
// Code quality
|
|
252
|
+
if (profile.codeQuality) {
|
|
253
|
+
lines.push('**Thresholds:**');
|
|
254
|
+
lines.push(`- Method: max ${profile.codeQuality.maxMethodLines} lines`);
|
|
255
|
+
lines.push(`- Class: max ${profile.codeQuality.maxClassLines} lines`);
|
|
256
|
+
lines.push(`- Parameters: max ${profile.codeQuality.maxMethodParameters}`);
|
|
257
|
+
lines.push(`- Coverage: ${profile.codeQuality.minimumTestCoverage}%+`);
|
|
258
|
+
lines.push('');
|
|
259
|
+
}
|
|
260
|
+
// Architecture
|
|
261
|
+
if (profile.architecture) {
|
|
262
|
+
lines.push(`**Architecture:** ${profile.architecture.type}`);
|
|
263
|
+
lines.push('');
|
|
264
|
+
}
|
|
265
|
+
// Naming
|
|
266
|
+
if (profile.naming) {
|
|
267
|
+
lines.push('**Naming:**');
|
|
268
|
+
const naming = profile.naming;
|
|
269
|
+
if (naming.general && typeof naming.general === 'object') {
|
|
270
|
+
for (const [key, value] of Object.entries(naming.general)) {
|
|
271
|
+
lines.push(`- ${key}: ${value}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
lines.push('');
|
|
275
|
+
}
|
|
276
|
+
lines.push('---', '', '## Your Review', '');
|
|
277
|
+
lines.push(`
|
|
278
|
+
### 1. CRITICAL ISSUES (must fix)
|
|
279
|
+
- Bugs, security vulnerabilities
|
|
280
|
+
- Architecture violations
|
|
281
|
+
- Performance problems
|
|
282
|
+
- Data integrity risks
|
|
283
|
+
|
|
284
|
+
### 2. WARNINGS (should fix)
|
|
285
|
+
- Style violations
|
|
286
|
+
- Missing best practices
|
|
287
|
+
- Readability issues
|
|
288
|
+
- Missing tests
|
|
289
|
+
|
|
290
|
+
### 3. SUGGESTIONS (nice to have)
|
|
291
|
+
- Refactoring opportunities
|
|
292
|
+
- Alternative patterns
|
|
293
|
+
- Future improvements
|
|
294
|
+
|
|
295
|
+
### 4. SCORE
|
|
296
|
+
- Rating: X/10
|
|
297
|
+
- Summary: [key concerns and strengths]
|
|
298
|
+
|
|
299
|
+
Be thorough and specific. Reference line numbers when possible.
|
|
300
|
+
`);
|
|
301
|
+
return {
|
|
302
|
+
messages: [
|
|
303
|
+
{
|
|
304
|
+
role: 'user',
|
|
305
|
+
content: { type: 'text', text: lines.join('\n') },
|
|
306
|
+
},
|
|
307
|
+
],
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,aAAa,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACrH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EACT,qHAAqH;QACvH,SAAS,EAAE;YACT;gBACE,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,qEAAqE;gBAClF,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,iDAAiD;gBAC9D,QAAQ,EAAE,KAAK;aAChB;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