|
|
@@ -3,7 +3,7 @@
|
|
|
*/
|
|
|
|
|
|
import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
|
-import { writeFileSync } from 'fs';
|
|
|
+import { writeFileSync, readFileSync, existsSync } from 'fs';
|
|
|
import { join } from 'path';
|
|
|
import { ClaudeClientConfig, IssueData, IssueHandlerResult } from './types.js';
|
|
|
import { Config } from './config.js';
|
|
|
@@ -15,6 +15,25 @@ export class ClaudeClient {
|
|
|
this.config = config;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Read the CLAUDE.md memory file if it exists
|
|
|
+ */
|
|
|
+ private readMemoryFile(): string {
|
|
|
+ const memoryFilePath = join(this.config.workingDirectory, 'CLAUDE.md');
|
|
|
+
|
|
|
+ if (existsSync(memoryFilePath)) {
|
|
|
+ try {
|
|
|
+ const content = readFileSync(memoryFilePath, 'utf-8');
|
|
|
+ return content;
|
|
|
+ } catch (error) {
|
|
|
+ console.warn(`Warning: Could not read CLAUDE.md: ${error}`);
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Build the prompt for Claude based on issue data
|
|
|
*/
|
|
|
@@ -23,7 +42,13 @@ export class ClaudeClient {
|
|
|
? `A new comment by ${issue.pusher}:\n${issue.commentBody}\n\n`
|
|
|
: '';
|
|
|
|
|
|
+ const memoryContent = this.readMemoryFile();
|
|
|
+ const memorySection = memoryContent
|
|
|
+ ? `\n=== PROJECT MEMORY (CLAUDE.md) ===\n\nThe following is the project memory file that contains important context about this repository.\nYou MUST read and understand this information as it contains project-specific guidelines, architecture details, and development patterns.\n\n${memoryContent}\n\n`
|
|
|
+ : '';
|
|
|
+
|
|
|
return `IMPORTANT: Issue #${issue.number} was assigned in repository ${issue.owner}/${issue.repo}.
|
|
|
+${memorySection}
|
|
|
|
|
|
|
|
|
=== MANDATORY FIRST STEPS - READ ALL MESSAGES ===
|