@corbat-tech/coding-standards-mcp 1.0.3 → 1.1.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/README.md +153 -341
- package/dist/agent.d.ts +5 -6
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +95 -217
- package/dist/agent.js.map +1 -1
- package/dist/errors.d.ts +58 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +112 -0
- package/dist/errors.js.map +1 -0
- package/dist/guardrails.d.ts +35 -0
- package/dist/guardrails.d.ts.map +1 -0
- package/dist/guardrails.js +303 -0
- package/dist/guardrails.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +36 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +63 -0
- package/dist/logger.js.map +1 -0
- package/dist/metrics.d.ts +40 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +97 -0
- package/dist/metrics.js.map +1 -0
- package/dist/profiles.d.ts +1 -1
- package/dist/profiles.d.ts.map +1 -1
- package/dist/profiles.js +239 -108
- package/dist/profiles.js.map +1 -1
- package/dist/prompts.js +1 -1
- package/dist/prompts.js.map +1 -1
- package/dist/tools/definitions.d.ts +104 -0
- package/dist/tools/definitions.d.ts.map +1 -0
- package/dist/tools/definitions.js +171 -0
- package/dist/tools/definitions.js.map +1 -0
- package/dist/tools/handlers/get-context.d.ts +12 -0
- package/dist/tools/handlers/get-context.d.ts.map +1 -0
- package/dist/tools/handlers/get-context.js +118 -0
- package/dist/tools/handlers/get-context.js.map +1 -0
- package/dist/tools/handlers/health.d.ts +11 -0
- package/dist/tools/handlers/health.d.ts.map +1 -0
- package/dist/tools/handlers/health.js +57 -0
- package/dist/tools/handlers/health.js.map +1 -0
- package/dist/tools/handlers/index.d.ts +11 -0
- package/dist/tools/handlers/index.d.ts.map +1 -0
- package/dist/tools/handlers/index.js +11 -0
- package/dist/tools/handlers/index.js.map +1 -0
- package/dist/tools/handlers/init.d.ts +12 -0
- package/dist/tools/handlers/init.d.ts.map +1 -0
- package/dist/tools/handlers/init.js +102 -0
- package/dist/tools/handlers/init.js.map +1 -0
- package/dist/tools/handlers/profiles.d.ts +11 -0
- package/dist/tools/handlers/profiles.d.ts.map +1 -0
- package/dist/tools/handlers/profiles.js +25 -0
- package/dist/tools/handlers/profiles.js.map +1 -0
- package/dist/tools/handlers/search.d.ts +12 -0
- package/dist/tools/handlers/search.d.ts.map +1 -0
- package/dist/tools/handlers/search.js +58 -0
- package/dist/tools/handlers/search.js.map +1 -0
- package/dist/tools/handlers/validate.d.ts +12 -0
- package/dist/tools/handlers/validate.d.ts.map +1 -0
- package/dist/tools/handlers/validate.js +76 -0
- package/dist/tools/handlers/validate.js.map +1 -0
- package/dist/tools/index.d.ts +22 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +72 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/schemas.d.ts +29 -0
- package/dist/tools/schemas.d.ts.map +1 -0
- package/dist/tools/schemas.js +20 -0
- package/dist/tools/schemas.js.map +1 -0
- package/dist/tools.js +2 -2
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +141 -71
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +92 -40
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/profiles/examples/microservice-kafka.yaml +122 -0
- package/profiles/examples/startup-fast.yaml +67 -0
- package/profiles/examples/strict-enterprise.yaml +62 -0
- package/profiles/templates/angular.yaml +614 -0
- package/profiles/templates/csharp-dotnet.yaml +529 -0
- package/profiles/templates/flutter.yaml +547 -0
- package/profiles/templates/go.yaml +1276 -0
- package/profiles/templates/java-spring-backend.yaml +326 -0
- package/profiles/templates/kotlin-spring.yaml +417 -0
- package/profiles/templates/nextjs.yaml +536 -0
- package/profiles/templates/nodejs.yaml +594 -0
- package/profiles/templates/python.yaml +546 -0
- package/profiles/templates/react.yaml +456 -0
- package/profiles/templates/rust.yaml +508 -0
- package/profiles/templates/vue.yaml +483 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool Definitions.
|
|
3
|
+
*
|
|
4
|
+
* This file contains ONLY the tool definitions (name, description, inputSchema).
|
|
5
|
+
* Handler logic is in separate files under handlers/.
|
|
6
|
+
*
|
|
7
|
+
* Design principles:
|
|
8
|
+
* - One primary tool (get_context) that does everything
|
|
9
|
+
* - Supporting tools for specific use cases
|
|
10
|
+
* - Names are short and intuitive
|
|
11
|
+
* - Descriptions are optimized for LLM understanding
|
|
12
|
+
*/
|
|
13
|
+
export declare const tools: ({
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: "object";
|
|
18
|
+
properties: {
|
|
19
|
+
task: {
|
|
20
|
+
type: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
project_dir: {
|
|
24
|
+
type: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
code?: undefined;
|
|
28
|
+
task_type?: undefined;
|
|
29
|
+
query?: undefined;
|
|
30
|
+
};
|
|
31
|
+
required: string[];
|
|
32
|
+
};
|
|
33
|
+
} | {
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: "object";
|
|
38
|
+
properties: {
|
|
39
|
+
code: {
|
|
40
|
+
type: string;
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
task_type: {
|
|
44
|
+
type: string;
|
|
45
|
+
enum: string[];
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
task?: undefined;
|
|
49
|
+
project_dir?: undefined;
|
|
50
|
+
query?: undefined;
|
|
51
|
+
};
|
|
52
|
+
required: string[];
|
|
53
|
+
};
|
|
54
|
+
} | {
|
|
55
|
+
name: string;
|
|
56
|
+
description: string;
|
|
57
|
+
inputSchema: {
|
|
58
|
+
type: "object";
|
|
59
|
+
properties: {
|
|
60
|
+
query: {
|
|
61
|
+
type: string;
|
|
62
|
+
description: string;
|
|
63
|
+
};
|
|
64
|
+
task?: undefined;
|
|
65
|
+
project_dir?: undefined;
|
|
66
|
+
code?: undefined;
|
|
67
|
+
task_type?: undefined;
|
|
68
|
+
};
|
|
69
|
+
required: string[];
|
|
70
|
+
};
|
|
71
|
+
} | {
|
|
72
|
+
name: string;
|
|
73
|
+
description: string;
|
|
74
|
+
inputSchema: {
|
|
75
|
+
type: "object";
|
|
76
|
+
properties: {
|
|
77
|
+
task?: undefined;
|
|
78
|
+
project_dir?: undefined;
|
|
79
|
+
code?: undefined;
|
|
80
|
+
task_type?: undefined;
|
|
81
|
+
query?: undefined;
|
|
82
|
+
};
|
|
83
|
+
required?: undefined;
|
|
84
|
+
};
|
|
85
|
+
} | {
|
|
86
|
+
name: string;
|
|
87
|
+
description: string;
|
|
88
|
+
inputSchema: {
|
|
89
|
+
type: "object";
|
|
90
|
+
properties: {
|
|
91
|
+
project_dir: {
|
|
92
|
+
type: string;
|
|
93
|
+
description: string;
|
|
94
|
+
};
|
|
95
|
+
task?: undefined;
|
|
96
|
+
code?: undefined;
|
|
97
|
+
task_type?: undefined;
|
|
98
|
+
query?: undefined;
|
|
99
|
+
};
|
|
100
|
+
required: string[];
|
|
101
|
+
};
|
|
102
|
+
})[];
|
|
103
|
+
export type ToolName = 'get_context' | 'validate' | 'search' | 'profiles' | 'health' | 'init';
|
|
104
|
+
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/tools/definitions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkKjB,CAAC;AAGF,MAAM,MAAM,QAAQ,GAAG,aAAa,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool Definitions.
|
|
3
|
+
*
|
|
4
|
+
* This file contains ONLY the tool definitions (name, description, inputSchema).
|
|
5
|
+
* Handler logic is in separate files under handlers/.
|
|
6
|
+
*
|
|
7
|
+
* Design principles:
|
|
8
|
+
* - One primary tool (get_context) that does everything
|
|
9
|
+
* - Supporting tools for specific use cases
|
|
10
|
+
* - Names are short and intuitive
|
|
11
|
+
* - Descriptions are optimized for LLM understanding
|
|
12
|
+
*/
|
|
13
|
+
export const tools = [
|
|
14
|
+
// PRIMARY TOOL - Everything in one call
|
|
15
|
+
{
|
|
16
|
+
name: 'get_context',
|
|
17
|
+
description: `Returns coding standards, guardrails, and workflow for implementing a task.
|
|
18
|
+
|
|
19
|
+
WHEN TO USE:
|
|
20
|
+
- ALWAYS call this FIRST before writing any code
|
|
21
|
+
- When starting a new feature, bugfix, or refactor
|
|
22
|
+
- When unsure about project conventions
|
|
23
|
+
|
|
24
|
+
RETURNS:
|
|
25
|
+
- Detected stack (Java/Python/TypeScript/Go/Rust/etc)
|
|
26
|
+
- Task type classification (feature/bugfix/refactor/test/security/performance)
|
|
27
|
+
- MUST rules (mandatory guidelines)
|
|
28
|
+
- AVOID rules (anti-patterns to prevent)
|
|
29
|
+
- Code quality thresholds (max lines, coverage %)
|
|
30
|
+
- Naming conventions (classes, methods, files)
|
|
31
|
+
- Recommended TDD workflow
|
|
32
|
+
|
|
33
|
+
EXAMPLE: get_context({ task: "Create payment service", project_dir: "/path/to/project" })`,
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {
|
|
37
|
+
task: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
description: 'What you\'re implementing (e.g., "Create payment service", "Fix login bug")',
|
|
40
|
+
},
|
|
41
|
+
project_dir: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
description: 'Project directory for auto-detection of stack and .corbat.json config (optional)',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
required: ['task'],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
// VALIDATE - Check code against standards
|
|
50
|
+
{
|
|
51
|
+
name: 'validate',
|
|
52
|
+
description: `Validate code against coding standards. Returns validation criteria and checklist.
|
|
53
|
+
|
|
54
|
+
WHEN TO USE:
|
|
55
|
+
- After writing code, before committing
|
|
56
|
+
- During code review
|
|
57
|
+
- To check if code follows project standards
|
|
58
|
+
|
|
59
|
+
RETURNS:
|
|
60
|
+
- Code quality thresholds (max method lines, coverage)
|
|
61
|
+
- Guardrails for the task type
|
|
62
|
+
- Naming convention checks
|
|
63
|
+
- Review checklist (CRITICAL/WARNINGS/Score)
|
|
64
|
+
|
|
65
|
+
EXAMPLE: validate({ code: "public class UserService { ... }", task_type: "feature" })`,
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {
|
|
69
|
+
code: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
description: 'The code to validate',
|
|
72
|
+
},
|
|
73
|
+
task_type: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
enum: ['feature', 'bugfix', 'refactor', 'test'],
|
|
76
|
+
description: 'Type of task for context-aware validation (optional)',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
required: ['code'],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
// SEARCH - Find specific topics in documentation
|
|
83
|
+
{
|
|
84
|
+
name: 'search',
|
|
85
|
+
description: `Search standards documentation for specific topics.
|
|
86
|
+
|
|
87
|
+
WHEN TO USE:
|
|
88
|
+
- Looking for specific technology guidance (kafka, docker, kubernetes)
|
|
89
|
+
- Need detailed information on a pattern or practice
|
|
90
|
+
- Exploring available standards
|
|
91
|
+
|
|
92
|
+
EXAMPLE QUERIES: "kafka", "testing", "docker", "logging", "metrics", "archunit", "flyway"
|
|
93
|
+
|
|
94
|
+
RETURNS: Up to 5 matching results with excerpts from documentation.`,
|
|
95
|
+
inputSchema: {
|
|
96
|
+
type: 'object',
|
|
97
|
+
properties: {
|
|
98
|
+
query: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
description: 'Search query (e.g., "kafka", "testing", "docker")',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
required: ['query'],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
// PROFILES - List available profiles
|
|
107
|
+
{
|
|
108
|
+
name: 'profiles',
|
|
109
|
+
description: `List all available coding standards profiles.
|
|
110
|
+
|
|
111
|
+
RETURNS: List of profiles with ID and description. Profiles include:
|
|
112
|
+
- java-spring-backend: Enterprise Java with Hexagonal Architecture
|
|
113
|
+
- nodejs: Node.js/TypeScript with Clean Architecture
|
|
114
|
+
- react, vue, angular: Frontend frameworks
|
|
115
|
+
- python: FastAPI/Django
|
|
116
|
+
- go, rust: Systems programming
|
|
117
|
+
- And more...
|
|
118
|
+
|
|
119
|
+
Use profile ID in .corbat.json or get_context will auto-detect.`,
|
|
120
|
+
inputSchema: {
|
|
121
|
+
type: 'object',
|
|
122
|
+
properties: {},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
// HEALTH - Server status
|
|
126
|
+
{
|
|
127
|
+
name: 'health',
|
|
128
|
+
description: `Check server status, loaded profiles, and usage metrics.
|
|
129
|
+
|
|
130
|
+
RETURNS:
|
|
131
|
+
- Server status (OK/ERROR)
|
|
132
|
+
- Version
|
|
133
|
+
- Load time
|
|
134
|
+
- Profiles loaded
|
|
135
|
+
- Standards documents count
|
|
136
|
+
- Usage metrics (tool calls, most used profile)`,
|
|
137
|
+
inputSchema: {
|
|
138
|
+
type: 'object',
|
|
139
|
+
properties: {},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
// INIT - Generate .corbat.json
|
|
143
|
+
{
|
|
144
|
+
name: 'init',
|
|
145
|
+
description: `Generate a .corbat.json configuration file for a project.
|
|
146
|
+
|
|
147
|
+
WHEN TO USE:
|
|
148
|
+
- Setting up Corbat for a new project
|
|
149
|
+
- Want to customize coding standards for a project
|
|
150
|
+
- Need to see available profiles and options
|
|
151
|
+
|
|
152
|
+
Analyzes the project directory and suggests optimal configuration based on detected stack.
|
|
153
|
+
|
|
154
|
+
RETURNS:
|
|
155
|
+
- Detected stack information
|
|
156
|
+
- Suggested .corbat.json content
|
|
157
|
+
- Available profiles list
|
|
158
|
+
- Setup instructions`,
|
|
159
|
+
inputSchema: {
|
|
160
|
+
type: 'object',
|
|
161
|
+
properties: {
|
|
162
|
+
project_dir: {
|
|
163
|
+
type: 'string',
|
|
164
|
+
description: 'Project directory to analyze',
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
required: ['project_dir'],
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
];
|
|
171
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/tools/definitions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,wCAAwC;IACxC;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE;;;;;;;;;;;;;;;;0FAgByE;QACtF,WAAW,EAAE;YACX,IAAI,EAAE,QAAiB;YACvB,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,6EAA6E;iBAC3F;gBACD,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,kFAAkF;iBAChG;aACF;YACD,QAAQ,EAAE,CAAC,MAAM,CAAC;SACnB;KACF;IAED,0CAA0C;IAC1C;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE;;;;;;;;;;;;;sFAaqE;QAClF,WAAW,EAAE;YACX,IAAI,EA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Handler for the get_context tool.
|
|
3
|
+
* Returns complete coding standards context for a task.
|
|
4
|
+
*/
|
|
5
|
+
export declare function handleGetContext(args: Record<string, unknown>): Promise<{
|
|
6
|
+
content: Array<{
|
|
7
|
+
type: 'text';
|
|
8
|
+
text: string;
|
|
9
|
+
}>;
|
|
10
|
+
isError?: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=get-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-context.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/get-context.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA4HhF"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { classifyTaskType, detectProjectStack, getGuardrails, getProjectRules, loadProjectConfig, } from '../../agent.js';
|
|
2
|
+
import { config } from '../../config.js';
|
|
3
|
+
import { getProfile, listProfiles } from '../../profiles.js';
|
|
4
|
+
import { GetContextSchema } from '../schemas.js';
|
|
5
|
+
/**
|
|
6
|
+
* Handler for the get_context tool.
|
|
7
|
+
* Returns complete coding standards context for a task.
|
|
8
|
+
*/
|
|
9
|
+
export async function handleGetContext(args) {
|
|
10
|
+
const { task, project_dir } = GetContextSchema.parse(args);
|
|
11
|
+
// Classify task type
|
|
12
|
+
const taskType = classifyTaskType(task);
|
|
13
|
+
// Auto-detect project stack if directory provided
|
|
14
|
+
let detectedStack = null;
|
|
15
|
+
let projectConfig = null;
|
|
16
|
+
if (project_dir) {
|
|
17
|
+
detectedStack = await detectProjectStack(project_dir);
|
|
18
|
+
projectConfig = await loadProjectConfig(project_dir);
|
|
19
|
+
}
|
|
20
|
+
// Determine profile (priority: project config > detected > default)
|
|
21
|
+
const profileId = projectConfig?.profile || detectedStack?.suggestedProfile || config.defaultProfile;
|
|
22
|
+
const profile = await getProfile(profileId);
|
|
23
|
+
if (!profile) {
|
|
24
|
+
const availableProfiles = await listProfiles();
|
|
25
|
+
return {
|
|
26
|
+
content: [
|
|
27
|
+
{
|
|
28
|
+
type: 'text',
|
|
29
|
+
text: `Profile "${profileId}" not found.\n\nAvailable profiles:\n${availableProfiles.map((p) => `- ${p.id}`).join('\n')}\n\nRun \`corbat-init\` in your project to create a custom profile.`,
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
isError: true,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
// Get guardrails and rules
|
|
36
|
+
const guardrails = await getGuardrails(taskType, projectConfig);
|
|
37
|
+
const projectRules = getProjectRules(taskType, projectConfig);
|
|
38
|
+
// Build concise, scannable output
|
|
39
|
+
const lines = [`# Context for: ${task}`, '', '---', ''];
|
|
40
|
+
// Stack Detection (concise)
|
|
41
|
+
if (detectedStack) {
|
|
42
|
+
const stackParts = [detectedStack.language];
|
|
43
|
+
if (detectedStack.framework)
|
|
44
|
+
stackParts.push(detectedStack.framework);
|
|
45
|
+
if (detectedStack.buildTool)
|
|
46
|
+
stackParts.push(detectedStack.buildTool);
|
|
47
|
+
lines.push(`**Stack:** ${stackParts.join(' · ')}`);
|
|
48
|
+
}
|
|
49
|
+
lines.push(`**Task type:** ${taskType.toUpperCase()}`);
|
|
50
|
+
lines.push(`**Profile:** ${profileId}`);
|
|
51
|
+
lines.push('');
|
|
52
|
+
// Guardrails (essential, concise)
|
|
53
|
+
lines.push('---', '', '## Guardrails', '');
|
|
54
|
+
lines.push('**MUST:**');
|
|
55
|
+
for (const rule of guardrails.mandatory.slice(0, 5)) {
|
|
56
|
+
lines.push(`- ${rule}`);
|
|
57
|
+
}
|
|
58
|
+
lines.push('');
|
|
59
|
+
lines.push('**AVOID:**');
|
|
60
|
+
for (const rule of guardrails.avoid.slice(0, 4)) {
|
|
61
|
+
lines.push(`- ${rule}`);
|
|
62
|
+
}
|
|
63
|
+
lines.push('');
|
|
64
|
+
// Project-specific rules (if any)
|
|
65
|
+
if (projectRules.length > 0) {
|
|
66
|
+
lines.push('**PROJECT RULES:**');
|
|
67
|
+
for (const rule of projectRules) {
|
|
68
|
+
lines.push(`- ${rule}`);
|
|
69
|
+
}
|
|
70
|
+
lines.push('');
|
|
71
|
+
}
|
|
72
|
+
// Quick Reference (most important settings)
|
|
73
|
+
lines.push('---', '', '## Quick Reference', '');
|
|
74
|
+
if (profile.codeQuality) {
|
|
75
|
+
lines.push(`- Max method lines: ${profile.codeQuality.maxMethodLines}`);
|
|
76
|
+
lines.push(`- Max class lines: ${profile.codeQuality.maxClassLines}`);
|
|
77
|
+
lines.push(`- Min test coverage: ${profile.codeQuality.minimumTestCoverage}%`);
|
|
78
|
+
}
|
|
79
|
+
if (profile.architecture) {
|
|
80
|
+
lines.push(`- Architecture: ${profile.architecture.type}`);
|
|
81
|
+
}
|
|
82
|
+
if (profile.ddd?.enabled) {
|
|
83
|
+
lines.push('- DDD: Enabled');
|
|
84
|
+
}
|
|
85
|
+
if (profile.testing) {
|
|
86
|
+
lines.push(`- Testing: ${profile.testing.framework || 'standard'}`);
|
|
87
|
+
}
|
|
88
|
+
lines.push('');
|
|
89
|
+
// Naming conventions (concise)
|
|
90
|
+
if (profile.naming) {
|
|
91
|
+
lines.push('---', '', '## Naming', '');
|
|
92
|
+
const naming = profile.naming;
|
|
93
|
+
if (naming.general && typeof naming.general === 'object') {
|
|
94
|
+
for (const [key, value] of Object.entries(naming.general)) {
|
|
95
|
+
lines.push(`- **${key}:** ${value}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (naming.suffixes && typeof naming.suffixes === 'object') {
|
|
99
|
+
lines.push('');
|
|
100
|
+
lines.push('**Suffixes:**');
|
|
101
|
+
for (const [key, value] of Object.entries(naming.suffixes)) {
|
|
102
|
+
lines.push(`- ${key}: \`${value}\``);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
lines.push('');
|
|
106
|
+
}
|
|
107
|
+
// Workflow reminder (brief)
|
|
108
|
+
lines.push('---', '', '## Workflow', '');
|
|
109
|
+
lines.push('```');
|
|
110
|
+
lines.push('1. CLARIFY → Ask if unclear');
|
|
111
|
+
lines.push('2. PLAN → Task checklist');
|
|
112
|
+
lines.push('3. BUILD → TDD: Test → Code → Refactor');
|
|
113
|
+
lines.push('4. VERIFY → Tests pass, linter clean');
|
|
114
|
+
lines.push('5. REVIEW → Self-check as expert');
|
|
115
|
+
lines.push('```');
|
|
116
|
+
return { content: [{ type: 'text', text: lines.join('\n') }] };
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=get-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-context.js","sourceRoot":"","sources":["../../../src/tools/handlers/get-context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,IAA6B;IAE7B,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE3D,qBAAqB;IACrB,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAExC,kDAAkD;IAClD,IAAI,aAAa,GAAG,IAAI,CAAC;IACzB,IAAI,aAAa,GAAG,IAAI,CAAC;IAEzB,IAAI,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
|
|
1
|
+
/**
|
|
2
|
+
* Handler for the health tool.
|
|
3
|
+
* Returns server status, loaded configuration, and usage metrics.
|
|
4
|
+
*/
|
|
5
|
+
export declare function handleHealth(): Promise<{
|
|
6
|
+
content: Array<{
|
|
7
|
+
type: 'text';
|
|
8
|
+
text: string;
|
|
9
|
+
}>;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/health.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAwDhG"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { config } from '../../config.js';
|
|
2
|
+
import { getMetrics } from '../../metrics.js';
|
|
3
|
+
import { listProfiles, loadStandards } from '../../profiles.js';
|
|
4
|
+
/**
|
|
5
|
+
* Handler for the health tool.
|
|
6
|
+
* Returns server status, loaded configuration, and usage metrics.
|
|
7
|
+
*/
|
|
8
|
+
export async function handleHealth() {
|
|
9
|
+
const startTime = Date.now();
|
|
10
|
+
try {
|
|
11
|
+
const profiles = await listProfiles();
|
|
12
|
+
const standards = await loadStandards();
|
|
13
|
+
const loadTimeMs = Date.now() - startTime;
|
|
14
|
+
const metrics = getMetrics();
|
|
15
|
+
const lines = [
|
|
16
|
+
'# Corbat MCP Health',
|
|
17
|
+
'',
|
|
18
|
+
'**Status:** OK',
|
|
19
|
+
`**Version:** ${config.serverVersion}`,
|
|
20
|
+
`**Uptime:** ${metrics.uptimeFormatted}`,
|
|
21
|
+
`**Load time:** ${loadTimeMs}ms`,
|
|
22
|
+
'',
|
|
23
|
+
'## Resources',
|
|
24
|
+
'',
|
|
25
|
+
`- **Profiles:** ${profiles.length}`,
|
|
26
|
+
`- **Standards:** ${standards.length} documents`,
|
|
27
|
+
`- **Default profile:** ${config.defaultProfile}`,
|
|
28
|
+
'',
|
|
29
|
+
];
|
|
30
|
+
// Only show metrics section if there have been calls
|
|
31
|
+
if (metrics.totalToolCalls > 0) {
|
|
32
|
+
lines.push('## Metrics', '');
|
|
33
|
+
lines.push(`- **Total tool calls:** ${metrics.totalToolCalls}`);
|
|
34
|
+
if (metrics.mostUsedTool) {
|
|
35
|
+
lines.push(`- **Most used tool:** ${metrics.mostUsedTool}`);
|
|
36
|
+
}
|
|
37
|
+
if (metrics.mostUsedProfile) {
|
|
38
|
+
lines.push(`- **Most used profile:** ${metrics.mostUsedProfile}`);
|
|
39
|
+
}
|
|
40
|
+
if (metrics.mostCommonTaskType) {
|
|
41
|
+
lines.push(`- **Most common task:** ${metrics.mostCommonTaskType}`);
|
|
42
|
+
}
|
|
43
|
+
if (metrics.errors > 0) {
|
|
44
|
+
lines.push(`- **Errors:** ${metrics.errors}`);
|
|
45
|
+
}
|
|
46
|
+
lines.push('');
|
|
47
|
+
}
|
|
48
|
+
return { content: [{ type: 'text', text: lines.join('\n') }] };
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
52
|
+
return {
|
|
53
|
+
content: [{ type: 'text', text: `# Corbat MCP Health\n\n**Status:** ERROR\n**Error:** ${errorMessage}` }],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../../src/tools/handlers/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBA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AAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;YACtE,CAAC;YAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvB,KAAK,CAAC,IAAI,CAAC,iBAAiB,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YAChD,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;IACjE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,wDAAwD,YAAY,EAAE,EAAE,CAAC;SAC1G,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool handlers index.
|
|
3
|
+
* Re-exports all handlers for centralized access.
|
|
4
|
+
*/
|
|
5
|
+
export { handleGetContext } from './get-context.js';
|
|
6
|
+
export { handleHealth } from './health.js';
|
|
7
|
+
export { handleInit } from './init.js';
|
|
8
|
+
export { handleProfiles } from './profiles.js';
|
|
9
|
+
export { handleSearch } from './search.js';
|
|
10
|
+
export { handleValidate } from './validate.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool handlers index.
|
|
3
|
+
* Re-exports all handlers for centralized access.
|
|
4
|
+
*/
|
|
5
|
+
export { handleGetContext } from './get-context.js';
|
|
6
|
+
export { handleHealth } from './health.js';
|
|
7
|
+
export { handleInit } from './init.js';
|
|
8
|
+
export { handleProfiles } from './profiles.js';
|
|
9
|
+
export { handleSearch } from './search.js';
|
|
10
|
+
export { handleValidate } from './validate.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/handlers/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler for the init tool.
|
|
3
|
+
* Analyzes project and generates suggested .corbat.json configuration.
|
|
4
|
+
*/
|
|
5
|
+
export declare function handleInit(args: Record<string, unknown>): Promise<{
|
|
6
|
+
content: Array<{
|
|
7
|
+
type: 'text';
|
|
8
|
+
text: string;
|
|
9
|
+
}>;
|
|
10
|
+
isError?: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/tools/handlers/init.ts"],"names":[],"mappings":"AAiEA;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAiDhF"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { detectProjectStack } from '../../agent.js';
|
|
2
|
+
import { listProfiles } from '../../profiles.js';
|
|
3
|
+
import { InitSchema } from '../schemas.js';
|
|
4
|
+
/**
|
|
5
|
+
* Generate suggested .corbat.json configuration based on detected stack.
|
|
6
|
+
*/
|
|
7
|
+
function generateSuggestedConfig(stack) {
|
|
8
|
+
if (!stack) {
|
|
9
|
+
return {
|
|
10
|
+
profile: 'minimal',
|
|
11
|
+
autoInject: true,
|
|
12
|
+
rules: {
|
|
13
|
+
always: ['Follow project coding conventions'],
|
|
14
|
+
onNewFile: ['Add appropriate file header comments'],
|
|
15
|
+
onTest: ['Follow AAA pattern (Arrange-Act-Assert)'],
|
|
16
|
+
onRefactor: ['Ensure tests pass before and after refactoring'],
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const config = {
|
|
21
|
+
profile: stack.suggestedProfile,
|
|
22
|
+
autoInject: true,
|
|
23
|
+
};
|
|
24
|
+
// Add language-specific rules
|
|
25
|
+
const rules = {
|
|
26
|
+
always: [],
|
|
27
|
+
onNewFile: [],
|
|
28
|
+
onTest: [],
|
|
29
|
+
onRefactor: [],
|
|
30
|
+
};
|
|
31
|
+
if (stack.language === 'Java') {
|
|
32
|
+
rules.always.push('Use constructor injection for dependencies');
|
|
33
|
+
rules.onNewFile.push('Add Javadoc for public classes and methods');
|
|
34
|
+
rules.onTest.push('Use @DisplayName for readable test names');
|
|
35
|
+
}
|
|
36
|
+
else if (stack.language === 'TypeScript' || stack.language === 'JavaScript') {
|
|
37
|
+
rules.always.push('Use strict TypeScript configuration');
|
|
38
|
+
rules.onNewFile.push('Export types alongside implementations');
|
|
39
|
+
rules.onTest.push('Mock external dependencies');
|
|
40
|
+
}
|
|
41
|
+
else if (stack.language === 'Python') {
|
|
42
|
+
rules.always.push('Use type hints for function signatures');
|
|
43
|
+
rules.onNewFile.push('Add module docstring');
|
|
44
|
+
rules.onTest.push('Use pytest fixtures for setup');
|
|
45
|
+
}
|
|
46
|
+
else if (stack.language === 'Go') {
|
|
47
|
+
rules.always.push('Follow effective Go guidelines');
|
|
48
|
+
rules.onNewFile.push('Add package documentation');
|
|
49
|
+
rules.onTest.push('Use table-driven tests');
|
|
50
|
+
}
|
|
51
|
+
if (rules.always.length > 0 || rules.onNewFile.length > 0) {
|
|
52
|
+
config.rules = rules;
|
|
53
|
+
}
|
|
54
|
+
return config;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Handler for the init tool.
|
|
58
|
+
* Analyzes project and generates suggested .corbat.json configuration.
|
|
59
|
+
*/
|
|
60
|
+
export async function handleInit(args) {
|
|
61
|
+
const { project_dir } = InitSchema.parse(args);
|
|
62
|
+
// Detect project stack
|
|
63
|
+
const stack = await detectProjectStack(project_dir);
|
|
64
|
+
// Get available profiles
|
|
65
|
+
const profiles = await listProfiles();
|
|
66
|
+
const profileIds = profiles.map((p) => p.id);
|
|
67
|
+
// Generate suggested config
|
|
68
|
+
const suggestedConfig = generateSuggestedConfig(stack);
|
|
69
|
+
const lines = ['# Corbat MCP Configuration', '', '## Detected Stack', ''];
|
|
70
|
+
if (stack) {
|
|
71
|
+
lines.push(`- **Language:** ${stack.language}`);
|
|
72
|
+
if (stack.framework) {
|
|
73
|
+
lines.push(`- **Framework:** ${stack.framework}`);
|
|
74
|
+
}
|
|
75
|
+
if (stack.buildTool) {
|
|
76
|
+
lines.push(`- **Build Tool:** ${stack.buildTool}`);
|
|
77
|
+
}
|
|
78
|
+
lines.push(`- **Suggested Profile:** ${stack.suggestedProfile}`);
|
|
79
|
+
lines.push(`- **Confidence:** ${stack.confidence}`);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
lines.push('Could not auto-detect stack. Using minimal profile.');
|
|
83
|
+
}
|
|
84
|
+
lines.push('', '## Suggested .corbat.json', '');
|
|
85
|
+
lines.push('```json');
|
|
86
|
+
lines.push(JSON.stringify(suggestedConfig, null, 2));
|
|
87
|
+
lines.push('```');
|
|
88
|
+
lines.push('', '## How to Use', '');
|
|
89
|
+
lines.push(`1. Save the above JSON to \`${project_dir}/.corbat.json\``);
|
|
90
|
+
lines.push('2. Customize rules and profile as needed');
|
|
91
|
+
lines.push('3. Run `get_context` to get standards for your tasks');
|
|
92
|
+
lines.push('', '## Available Profiles', '');
|
|
93
|
+
for (const id of profileIds.slice(0, 10)) {
|
|
94
|
+
const isSelected = id === suggestedConfig.profile ? ' **(selected)**' : '';
|
|
95
|
+
lines.push(`- ${id}${isSelected}`);
|
|
96
|
+
}
|
|
97
|
+
if (profileIds.length > 10) {
|
|
98
|
+
lines.push(`- ... and ${profileIds.length - 10} more`);
|
|
99
|
+
}
|
|
100
|
+
return { content: [{ type: 'text', text: lines.join('\n') }] };
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=init.js.map
|