feat: integrate settings service for auto-load CLAUDE.md functionality

- Updated API routes to accept an optional settings service for loading the autoLoadClaudeMd setting.
- Introduced a new settings helper utility for retrieving project-specific settings.
- Enhanced feature generation and spec generation processes to utilize the autoLoadClaudeMd setting.
- Refactored relevant route handlers to support the new settings integration across various endpoints.
This commit is contained in:
Kacper
2025-12-24 22:34:22 +01:00
parent 07bcb6b767
commit 3154121840
17 changed files with 212 additions and 39 deletions

View File

@@ -16,8 +16,12 @@ import {
createDeleteValidationHandler,
createMarkViewedHandler,
} from './routes/validation-endpoints.js';
import type { SettingsService } from '../../services/settings-service.js';
export function createGitHubRoutes(events: EventEmitter): Router {
export function createGitHubRoutes(
events: EventEmitter,
settingsService?: SettingsService
): Router {
const router = Router();
router.post('/check-remote', validatePathParams('projectPath'), createCheckGitHubRemoteHandler());
@@ -26,7 +30,7 @@ export function createGitHubRoutes(events: EventEmitter): Router {
router.post(
'/validate-issue',
validatePathParams('projectPath'),
createValidateIssueHandler(events)
createValidateIssueHandler(events, settingsService)
);
// Validation management endpoints

View File

@@ -23,6 +23,8 @@ import {
logError,
logger,
} from './validation-common.js';
import type { SettingsService } from '../../../services/settings-service.js';
import { getAutoLoadClaudeMdSetting } from '../../../lib/settings-helpers.js';
/** Valid model values for validation */
const VALID_MODELS: readonly AgentModel[] = ['opus', 'sonnet', 'haiku'] as const;
@@ -54,7 +56,8 @@ async function runValidation(
issueLabels: string[] | undefined,
model: AgentModel,
events: EventEmitter,
abortController: AbortController
abortController: AbortController,
settingsService?: SettingsService
): Promise<void> {
// Emit start event
const startEvent: IssueValidationEvent = {
@@ -76,12 +79,20 @@ async function runValidation(
// Build the prompt
const prompt = buildValidationPrompt(issueNumber, issueTitle, issueBody, issueLabels);
// Load autoLoadClaudeMd setting
const autoLoadClaudeMd = await getAutoLoadClaudeMdSetting(
projectPath,
settingsService,
'[ValidateIssue]'
);
// Create SDK options with structured output and abort controller
const options = createSuggestionsOptions({
cwd: projectPath,
model,
systemPrompt: ISSUE_VALIDATION_SYSTEM_PROMPT,
abortController,
autoLoadClaudeMd,
outputFormat: {
type: 'json_schema',
schema: issueValidationSchema as Record<string, unknown>,
@@ -190,7 +201,10 @@ async function runValidation(
* - System prompt guiding the validation process
* - Async execution with event emission
*/
export function createValidateIssueHandler(events: EventEmitter) {
export function createValidateIssueHandler(
events: EventEmitter,
settingsService?: SettingsService
) {
return async (req: Request, res: Response): Promise<void> => {
try {
const {
@@ -256,7 +270,8 @@ export function createValidateIssueHandler(events: EventEmitter) {
issueLabels,
model,
events,
abortController
abortController,
settingsService
)
.catch((error) => {
// Error is already handled inside runValidation (event emitted)