Ver código fonte

feat: simplify claude prompt and add git push requirements #12

Claude 9 meses atrás
pai
commit
dfdf2d6d8c
1 arquivos alterados com 19 adições e 55 exclusões
  1. 19 55
      client/src/claude-client.ts

+ 19 - 55
client/src/claude-client.ts

@@ -19,7 +19,13 @@ export class ClaudeClient {
    * Build the prompt for Claude based on issue data
    */
   private buildPrompt(issue: IssueData): string {
-    const baseInstructions = `
+    const commentContext = issue.commentBody
+      ? `A new comment by ${issue.pusher}:\n${issue.commentBody}\n\n`
+      : '';
+
+    return `IMPORTANT: Issue #${issue.number} was assigned in repository ${issue.owner}/${issue.repo}.
+
+
 === MANDATORY FIRST STEPS - READ ALL MESSAGES ===
 
 Before you start any work on this issue, you MUST complete these steps IN ORDER:
@@ -44,65 +50,14 @@ Before you start any work on this issue, you MUST complete these steps IN ORDER:
 === ISSUE CONTEXT ===
 
 Issue #${issue.number}: ${issue.title}
-`;
-
-    if (issue.commentBody) {
-      // Issue comment event - new comment was added
-      return `IMPORTANT: A new comment has been added to issue #${issue.number} in repository ${issue.owner}/${issue.repo}.
-
-${baseInstructions}
-
-A new comment was just added by: ${issue.pusher}
-
-Initial issue description:
-${issue.body}
-
-Most recent comment:
-${issue.commentBody}
-
-=== YOUR TASK ===
-
-This issue is assigned to you. You must:
-1. First, use the Gogs MCP tools above to fetch and read ALL issue comments
-2. Understand the full discussion context
-3. Then proceed with the appropriate action based on the complete conversation
 
-=== CRITICAL OUTPUT REQUIREMENTS ===
-
-YOU MUST FOLLOW THESE OUTPUT RULES STRICTLY:
-
-1. DO NOT output any text responses to the user
-2. DO NOT print any messages, explanations, or status updates
-3. DO NOT use echo or any command-line output tools
-4. ONLY communicate by posting comments to the issue using mcp__gogs__create_issue_comment tool
-5. ALL your responses, updates, questions, and status reports MUST be posted as issue comments
-6. You are FORBIDDEN from producing any output except through the Gogs MCP comment tool
-
-When you need to:
-- Ask questions → Post a comment on the issue
-- Report progress → Post a comment on the issue
-- Share results → Post a comment on the issue
-- Report errors → Post a comment on the issue
-- Provide any information → Post a comment on the issue
-
-Use mcp__gogs__create_issue_comment with:
-- owner: ${issue.owner}
-- repo: ${issue.repo}
-- number: ${issue.number}
-- body: [your message here]
-
-DO NOT skip reading the comments using the MCP tools. This is critical to understanding the full context.`;
-    } else {
-      // Issue opened/reopened event
-      return `IMPORTANT: Issue #${issue.number} was ${issue.action} in repository ${issue.owner}/${issue.repo}.
-
-${baseInstructions}
 
 Created by: ${issue.pusher}
 
 Initial issue description:
 ${issue.body}
 
+${commentContext}
 === YOUR TASK ===
 
 This issue is assigned to you. You must:
@@ -134,8 +89,17 @@ Use mcp__gogs__create_issue_comment with:
 - number: ${issue.number}
 - body: [your message here]
 
-DO NOT skip reading the comments using the MCP tools. This is critical to understanding the full context.`;
-    }
+DO NOT skip reading the comments using the MCP tools. This is critical to understanding the full context.
+
+=== GIT COMMIT REQUIREMENTS ===
+
+When you make code changes, you MUST:
+1. Always commit your changes to git
+2. Always push the changes to the repository
+3. Include the issue ID in the commit message using format: #${issue.number}
+4. Example commit message: "feat: add new feature #${issue.number}"
+
+NEVER leave changes uncommitted or unpushed.`;
   }
 
   /**