@cyanheads/git-mcp-server 2.1.0 → 2.1.2
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 +8 -11
- package/dist/config/index.js +7 -7
- package/dist/index.js +35 -21
- package/dist/mcp-server/server.js +72 -56
- package/dist/mcp-server/tools/gitAdd/index.js +1 -1
- package/dist/mcp-server/tools/gitAdd/logic.js +88 -39
- package/dist/mcp-server/tools/gitAdd/registration.js +17 -14
- package/dist/mcp-server/tools/gitBranch/index.js +1 -1
- package/dist/mcp-server/tools/gitBranch/logic.js +213 -85
- package/dist/mcp-server/tools/gitBranch/registration.js +16 -13
- package/dist/mcp-server/tools/gitCheckout/index.js +1 -1
- package/dist/mcp-server/tools/gitCheckout/logic.js +85 -145
- package/dist/mcp-server/tools/gitCheckout/registration.js +16 -14
- package/dist/mcp-server/tools/gitCherryPick/index.js +1 -1
- package/dist/mcp-server/tools/gitCherryPick/logic.js +100 -41
- package/dist/mcp-server/tools/gitCherryPick/registration.js +21 -14
- package/dist/mcp-server/tools/gitClean/index.js +1 -1
- package/dist/mcp-server/tools/gitClean/logic.js +93 -41
- package/dist/mcp-server/tools/gitClean/registration.js +19 -16
- package/dist/mcp-server/tools/gitClearWorkingDir/index.js +1 -1
- package/dist/mcp-server/tools/gitClearWorkingDir/logic.js +14 -11
- package/dist/mcp-server/tools/gitClearWorkingDir/registration.js +19 -13
- package/dist/mcp-server/tools/gitClone/index.js +1 -1
- package/dist/mcp-server/tools/gitClone/logic.js +89 -30
- package/dist/mcp-server/tools/gitClone/registration.js +15 -12
- package/dist/mcp-server/tools/gitCommit/index.js +1 -1
- package/dist/mcp-server/tools/gitCommit/logic.js +198 -76
- package/dist/mcp-server/tools/gitCommit/registration.js +23 -20
- package/dist/mcp-server/tools/gitDiff/index.js +1 -1
- package/dist/mcp-server/tools/gitDiff/logic.js +124 -44
- package/dist/mcp-server/tools/gitDiff/registration.js +16 -14
- package/dist/mcp-server/tools/gitFetch/index.js +1 -1
- package/dist/mcp-server/tools/gitFetch/logic.js +78 -49
- package/dist/mcp-server/tools/gitFetch/registration.js +16 -14
- package/dist/mcp-server/tools/gitInit/index.js +1 -1
- package/dist/mcp-server/tools/gitInit/logic.js +88 -34
- package/dist/mcp-server/tools/gitInit/registration.js +32 -18
- package/dist/mcp-server/tools/gitLog/index.js +1 -1
- package/dist/mcp-server/tools/gitLog/logic.js +133 -47
- package/dist/mcp-server/tools/gitLog/registration.js +16 -14
- package/dist/mcp-server/tools/gitMerge/index.js +1 -1
- package/dist/mcp-server/tools/gitMerge/logic.js +102 -61
- package/dist/mcp-server/tools/gitMerge/registration.js +17 -14
- package/dist/mcp-server/tools/gitPull/index.js +1 -1
- package/dist/mcp-server/tools/gitPull/logic.js +90 -69
- package/dist/mcp-server/tools/gitPull/registration.js +16 -14
- package/dist/mcp-server/tools/gitPush/index.js +1 -1
- package/dist/mcp-server/tools/gitPush/logic.js +116 -100
- package/dist/mcp-server/tools/gitPush/registration.js +16 -14
- package/dist/mcp-server/tools/gitRebase/index.js +1 -1
- package/dist/mcp-server/tools/gitRebase/logic.js +121 -82
- package/dist/mcp-server/tools/gitRebase/registration.js +21 -14
- package/dist/mcp-server/tools/gitRemote/index.js +1 -1
- package/dist/mcp-server/tools/gitRemote/logic.js +108 -52
- package/dist/mcp-server/tools/gitRemote/registration.js +14 -11
- package/dist/mcp-server/tools/gitReset/index.js +1 -1
- package/dist/mcp-server/tools/gitReset/logic.js +65 -37
- package/dist/mcp-server/tools/gitReset/registration.js +14 -12
- package/dist/mcp-server/tools/gitSetWorkingDir/index.js +1 -1
- package/dist/mcp-server/tools/gitSetWorkingDir/logic.js +74 -34
- package/dist/mcp-server/tools/gitSetWorkingDir/registration.js +18 -11
- package/dist/mcp-server/tools/gitShow/index.js +1 -1
- package/dist/mcp-server/tools/gitShow/logic.js +78 -35
- package/dist/mcp-server/tools/gitShow/registration.js +17 -12
- package/dist/mcp-server/tools/gitStash/index.js +1 -1
- package/dist/mcp-server/tools/gitStash/logic.js +143 -58
- package/dist/mcp-server/tools/gitStash/registration.js +19 -12
- package/dist/mcp-server/tools/gitStatus/index.js +1 -1
- package/dist/mcp-server/tools/gitStatus/logic.js +100 -58
- package/dist/mcp-server/tools/gitStatus/registration.js +15 -12
- package/dist/mcp-server/tools/gitTag/index.js +1 -1
- package/dist/mcp-server/tools/gitTag/logic.js +124 -51
- package/dist/mcp-server/tools/gitTag/registration.js +14 -11
- package/dist/mcp-server/tools/gitWorktree/index.js +1 -1
- package/dist/mcp-server/tools/gitWorktree/logic.js +204 -95
- package/dist/mcp-server/tools/gitWorktree/registration.js +14 -11
- package/dist/mcp-server/tools/gitWrapupInstructions/index.js +1 -1
- package/dist/mcp-server/tools/gitWrapupInstructions/logic.js +23 -11
- package/dist/mcp-server/tools/gitWrapupInstructions/registration.js +14 -12
- package/dist/mcp-server/transports/httpTransport.js +187 -79
- package/dist/mcp-server/transports/stdioTransport.js +14 -8
- package/dist/types-global/errors.js +9 -4
- package/dist/utils/index.js +4 -4
- package/dist/utils/internal/errorHandler.js +62 -40
- package/dist/utils/internal/index.js +3 -3
- package/dist/utils/internal/logger.js +97 -54
- package/dist/utils/internal/requestContext.js +7 -5
- package/dist/utils/metrics/index.js +1 -1
- package/dist/utils/metrics/tokenCounter.js +18 -14
- package/dist/utils/parsing/dateParser.js +5 -5
- package/dist/utils/parsing/index.js +2 -2
- package/dist/utils/parsing/jsonParser.js +20 -11
- package/dist/utils/security/idGenerator.js +8 -10
- package/dist/utils/security/index.js +3 -3
- package/dist/utils/security/rateLimiter.js +16 -14
- package/dist/utils/security/sanitization.js +139 -82
- package/package.json +45 -23
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { logger } from
|
|
3
|
-
import { getGitStatus } from
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { logger } from "../../../utils/index.js"; // Added logger
|
|
3
|
+
import { getGitStatus } from "../gitStatus/logic.js"; // Corrected path
|
|
4
4
|
// Define the input schema
|
|
5
5
|
export const GitWrapupInstructionsInputSchema = z.object({
|
|
6
|
-
acknowledgement: z.enum([
|
|
7
|
-
required_error:
|
|
6
|
+
acknowledgement: z.enum(["Y", "y", "Yes", "yes"], {
|
|
7
|
+
required_error: "Acknowledgement is required.",
|
|
8
8
|
description: 'Acknowledgement that you have permission (implicit allowed, explicit preferred) from the user to initiate this tool. Must be "Y" or "Yes" (case-insensitive).',
|
|
9
9
|
}),
|
|
10
|
-
updateAgentMetaFiles: z
|
|
10
|
+
updateAgentMetaFiles: z
|
|
11
|
+
.enum(["Y", "y", "Yes", "yes"])
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("If set to 'Y' or 'Yes', include an extra instruction to review and update agent-specific meta files like .clinerules or claude.md if present. Only use this if the user explicitly requested it."),
|
|
11
14
|
});
|
|
12
15
|
// The predefined instructions string.
|
|
13
16
|
const WRAPUP_INSTRUCTIONS = `
|
|
@@ -17,6 +20,8 @@ Perform all actions for our git wrapup workflow:
|
|
|
17
20
|
3. Update the CHANGELOG with concise, descriptive entries detailing all modifications, clearly indicating their purpose (e.g., bug fix, feature implementation, refactoring). Include specific metrics or identifiers where applicable, such as issue numbers or pull request links, to provide context and traceability for each change. This will help maintain a clear history of changes and their impacts on the project.
|
|
18
21
|
4. Proceed to commit all changes; based on your review of the git_diff and readme, group these changes into logical, atomic commits, each accompanied by a clear and descriptive message adhering to Conventional Commits standards (e.g. "docs(readme): updated readme to include xyz."). Note the 'git_commit' tool allows you to also stage the files while commiting. Ensure commit messages accurately convey the scope and impact of the changes, incorporating specific metrics or identifiers where applicable.
|
|
19
22
|
Note: Be sure to set 'git_set_working_dir' if not already set.
|
|
23
|
+
|
|
24
|
+
Instructions: Now write a concise list of what you must do to complete the git wrapup workflow, then perform all actions. Do not push unless requested.
|
|
20
25
|
`;
|
|
21
26
|
/**
|
|
22
27
|
* Core logic for the git_wrapup_instructions tool.
|
|
@@ -30,8 +35,11 @@ export async function getWrapupInstructions(input,
|
|
|
30
35
|
// The context is now expected to be enhanced by the registration layer
|
|
31
36
|
// to include session-specific methods like getWorkingDirectory.
|
|
32
37
|
context) {
|
|
38
|
+
const operation = "getWrapupInstructions";
|
|
39
|
+
logger.debug(`Executing ${operation}`, { ...context, input });
|
|
33
40
|
let finalInstructions = WRAPUP_INSTRUCTIONS;
|
|
34
|
-
if (input.updateAgentMetaFiles &&
|
|
41
|
+
if (input.updateAgentMetaFiles &&
|
|
42
|
+
["Y", "y", "Yes", "yes"].includes(input.updateAgentMetaFiles)) {
|
|
35
43
|
finalInstructions += ` Extra request: review and update if needed the .clinerules and claude.md files if present.`;
|
|
36
44
|
}
|
|
37
45
|
let statusResult = undefined;
|
|
@@ -42,16 +50,20 @@ context) {
|
|
|
42
50
|
// The `getGitStatus` function expects `path` and a context with `getWorkingDirectory`.
|
|
43
51
|
// Passing `path: '.'` signals `getGitStatus` to use the working directory from the context.
|
|
44
52
|
// The `registration.ts` for this tool will be responsible for ensuring `context.getWorkingDirectory` is correctly supplied.
|
|
45
|
-
statusResult = await getGitStatus({ path:
|
|
53
|
+
statusResult = await getGitStatus({ path: "." }, context);
|
|
46
54
|
}
|
|
47
55
|
catch (error) {
|
|
48
|
-
logger.warning(`Failed to get git status while generating wrapup instructions (working dir: ${workingDir}). Tool will proceed without it.`, {
|
|
56
|
+
logger.warning(`Failed to get git status while generating wrapup instructions (working dir: ${workingDir}). Tool will proceed without it.`, {
|
|
57
|
+
...context,
|
|
58
|
+
tool: "gitWrapupInstructions",
|
|
59
|
+
originalError: error.message,
|
|
60
|
+
});
|
|
49
61
|
statusError = error instanceof Error ? error.message : String(error);
|
|
50
62
|
}
|
|
51
63
|
}
|
|
52
64
|
else {
|
|
53
|
-
logger.info(
|
|
54
|
-
statusError =
|
|
65
|
+
logger.info("No working directory set for session, skipping git status for wrapup instructions.", { ...context, tool: "gitWrapupInstructions" });
|
|
66
|
+
statusError = "No working directory set for session, git status skipped.";
|
|
55
67
|
}
|
|
56
68
|
return {
|
|
57
69
|
instructions: finalInstructions,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseErrorCode } from
|
|
2
|
-
import { ErrorHandler, logger, requestContextService } from
|
|
3
|
-
import { getWrapupInstructions, GitWrapupInstructionsInputSchema, } from
|
|
1
|
+
import { BaseErrorCode } from "../../../types-global/errors.js";
|
|
2
|
+
import { ErrorHandler, logger, requestContextService, } from "../../../utils/index.js";
|
|
3
|
+
import { getWrapupInstructions, GitWrapupInstructionsInputSchema, } from "./logic.js";
|
|
4
4
|
let _getWorkingDirectory;
|
|
5
5
|
let _getSessionId;
|
|
6
6
|
/**
|
|
@@ -12,10 +12,10 @@ let _getSessionId;
|
|
|
12
12
|
export function initializeGitWrapupInstructionsStateAccessors(getWdFn, getSidFn) {
|
|
13
13
|
_getWorkingDirectory = getWdFn;
|
|
14
14
|
_getSessionId = getSidFn;
|
|
15
|
-
logger.info(
|
|
15
|
+
logger.info("State accessors initialized for git_wrapup_instructions tool registration.");
|
|
16
16
|
}
|
|
17
|
-
const TOOL_NAME =
|
|
18
|
-
const TOOL_DESCRIPTION =
|
|
17
|
+
const TOOL_NAME = "git_wrapup_instructions";
|
|
18
|
+
const TOOL_DESCRIPTION = "Provides a standard Git wrap-up workflow. This involves reviewing changes with `git_diff`, updating documentation (README, CHANGELOG), and making logical, descriptive commits using the `git_commit` tool. The tool's response also includes the current `git status` output. You should set the working directory using `git_set_working_dir` before running this tool.";
|
|
19
19
|
/**
|
|
20
20
|
* Registers the git_wrapup_instructions tool with the MCP server.
|
|
21
21
|
*
|
|
@@ -25,14 +25,16 @@ const TOOL_DESCRIPTION = 'Provides a standard Git wrap-up workflow. This involve
|
|
|
25
25
|
*/
|
|
26
26
|
export const registerGitWrapupInstructionsTool = async (server) => {
|
|
27
27
|
if (!_getWorkingDirectory || !_getSessionId) {
|
|
28
|
-
throw new Error(
|
|
28
|
+
throw new Error("State accessors for git_wrapup_instructions must be initialized before registration.");
|
|
29
29
|
}
|
|
30
|
-
const operation =
|
|
30
|
+
const operation = "registerGitWrapupInstructionsTool";
|
|
31
31
|
// Context for the registration operation itself
|
|
32
|
-
const registrationOpContext = requestContextService.createRequestContext({
|
|
32
|
+
const registrationOpContext = requestContextService.createRequestContext({
|
|
33
|
+
operation,
|
|
34
|
+
});
|
|
33
35
|
await ErrorHandler.tryCatch(async () => {
|
|
34
36
|
server.tool(TOOL_NAME, TOOL_DESCRIPTION, GitWrapupInstructionsInputSchema.shape, async (validatedArgs, callContext) => {
|
|
35
|
-
const toolOperation =
|
|
37
|
+
const toolOperation = "tool:git_wrapup_instructions";
|
|
36
38
|
// Create a base RequestContext for this specific tool call,
|
|
37
39
|
// potentially linking to the callContext provided by the McpServer.
|
|
38
40
|
// Pass callContext directly; createRequestContext will handle it appropriately
|
|
@@ -60,9 +62,9 @@ export const registerGitWrapupInstructionsTool = async (server) => {
|
|
|
60
62
|
// Call the core logic function with validated arguments and the prepared logicContext.
|
|
61
63
|
const result = await getWrapupInstructions(validatedArgs, logicContext);
|
|
62
64
|
const resultContent = {
|
|
63
|
-
type:
|
|
65
|
+
type: "text",
|
|
64
66
|
text: JSON.stringify(result, null, 2),
|
|
65
|
-
contentType:
|
|
67
|
+
contentType: "application/json",
|
|
66
68
|
};
|
|
67
69
|
logger.info(`Tool ${TOOL_NAME} executed successfully, returning JSON`, logicContext);
|
|
68
70
|
return { content: [resultContent] };
|