From 09fbd90768eb1862ae88aaa2c09656ac6ed464d0 Mon Sep 17 00:00:00 2001 From: Cascade Bot Date: Mon, 16 Mar 2026 17:30:27 +0000 Subject: [PATCH] chore: remove dead files and unused barrel index re-exports --- src/agents/index.ts | 2 - src/agents/shared/taskPrompts.ts | 79 ------ src/config/index.ts | 19 -- src/db/index.ts | 2 - src/db/schema/credentials.ts | 3 - src/gadgets/index.ts | 14 - src/trello/index.ts | 1 - tests/unit/agents/shared/taskPrompts.test.ts | 274 ------------------- 8 files changed, 394 deletions(-) delete mode 100644 src/agents/index.ts delete mode 100644 src/agents/shared/taskPrompts.ts delete mode 100644 src/config/index.ts delete mode 100644 src/db/index.ts delete mode 100644 src/db/schema/credentials.ts delete mode 100644 src/gadgets/index.ts delete mode 100644 src/trello/index.ts delete mode 100644 tests/unit/agents/shared/taskPrompts.test.ts diff --git a/src/agents/index.ts b/src/agents/index.ts deleted file mode 100644 index 295f930c..00000000 --- a/src/agents/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { runAgent, registerEngine } from './registry.js'; -export { getSystemPrompt } from './prompts/index.js'; diff --git a/src/agents/shared/taskPrompts.ts b/src/agents/shared/taskPrompts.ts deleted file mode 100644 index 051d7506..00000000 --- a/src/agents/shared/taskPrompts.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Shared task prompt builders for prompts NOT managed via the YAML profile system. - * - * Task prompts managed through YAML profiles (workItem, commentResponse, review, - * ci, prCommentResponse) are now .eta templates in `src/agents/prompts/task-templates/` - * rendered via `renderTaskPrompt()` in the profile builder. - * - * This module retains only the two prompts called directly by trigger handlers/agents, - * not through the profile system: `buildCheckFailurePrompt` and `buildDebugPrompt`. - */ - -import { parseRepoFullName } from '../../utils/repo.js'; - -/** - * Prompt for the respond-to-ci agent (llmist backend format — includes GitHub context). - * Used by agents/base.ts when the trigger type is 'check-failure'. - */ -export function buildCheckFailurePrompt(prContext: { - prNumber: number; - prBranch: string; - repoFullName: string; - headSha: string; -}): string { - const { owner, repo } = parseRepoFullName(prContext.repoFullName); - - return `You are on branch \`${prContext.prBranch}\` for PR #${prContext.prNumber}. - -Your task is to fix the failing checks and push your changes. - -## Instructions - -1. **Investigate failures**: Use Tmux to run: - \`gh run list --branch ${prContext.prBranch} --limit 5 --json databaseId,conclusion,status,workflowName\` - -2. **Get failure details**: Find failed run ID and run: - \`gh run view --log-failed\` - -3. **Analyze error types**: - - Lint errors: Run \`npm run lint\` or \`pnpm run lint\` - - Type errors: Run \`npm run typecheck\` - - Test failures: Run \`npm test\` - - Build errors: Run \`npm run build\` - -4. **Fix issues**: Make targeted fixes following existing codebase patterns - -5. **Verify locally**: Run the same checks that failed in CI before pushing - -6. **Commit and push**: - \`\`\`bash - git add . - git commit -m "fix: address failing checks" - git push - \`\`\` - -The push will re-trigger checks automatically. - -## GitHub Context -Owner: ${owner} -Repo: ${repo} -PR: #${prContext.prNumber} -Branch: ${prContext.prBranch}`; -} - -/** - * Prompt for the debug agent analyzing session logs. - */ -export function buildDebugPrompt(debugContext: { - logDir: string; - originalWorkItemName: string; - originalWorkItemUrl: string; - detectedAgentType: string; -}): string { - return `Analyze the ${debugContext.detectedAgentType} agent session logs in directory: ${debugContext.logDir} - -Original work item: "${debugContext.originalWorkItemName}" -Link: ${debugContext.originalWorkItemUrl} - -Start by listing the contents of the log directory, then read and analyze the logs to identify issues.`; -} diff --git a/src/config/index.ts b/src/config/index.ts deleted file mode 100644 index 52423c33..00000000 --- a/src/config/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -export { loadEnvConfig, loadEnvConfigSafe, type EnvConfig } from './env.js'; -export { getProjectGitHubToken } from './projects.js'; -export { - loadConfig, - findProjectByBoardId, - findProjectByRepo, - findProjectById, - getIntegrationCredential, - getIntegrationCredentialOrNull, - getOrgCredential, - getAllProjectCredentials, - invalidateConfigCache, -} from './provider.js'; -export { validateConfig, ProjectConfigSchema, CascadeConfigSchema } from './schema.js'; -export { - getStatusUpdateConfig, - formatStatusMessage, - type StatusUpdateConfig, -} from './statusUpdateConfig.js'; diff --git a/src/db/index.ts b/src/db/index.ts deleted file mode 100644 index 143646b6..00000000 --- a/src/db/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { getDb, closeDb } from './client.js'; -export * from './schema/index.js'; diff --git a/src/db/schema/credentials.ts b/src/db/schema/credentials.ts deleted file mode 100644 index 7038427b..00000000 --- a/src/db/schema/credentials.ts +++ /dev/null @@ -1,3 +0,0 @@ -// Legacy credentials table has been removed. -// All credentials are now project-scoped in the project_credentials table. -// See src/db/schema/projectCredentials.ts diff --git a/src/gadgets/index.ts b/src/gadgets/index.ts deleted file mode 100644 index af9d5ec1..00000000 --- a/src/gadgets/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -// File editing gadgets -export { FileSearchAndReplace } from './FileSearchAndReplace.js'; -export { FileMultiEdit } from './FileMultiEdit.js'; -export { WriteFile } from './WriteFile.js'; - -// Verification gadgets -export { VerifyChanges } from './VerifyChanges.js'; - -// Search gadgets -export { RipGrep } from './RipGrep.js'; -export { AstGrep } from './AstGrep.js'; - -// GitHub gadgets -export { GetPRDetails, GetPRComments, ReplyToReviewComment } from './github/index.js'; diff --git a/src/trello/index.ts b/src/trello/index.ts deleted file mode 100644 index eac7447a..00000000 --- a/src/trello/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { trelloClient, type TrelloCard, type TrelloComment } from './client.js'; diff --git a/tests/unit/agents/shared/taskPrompts.test.ts b/tests/unit/agents/shared/taskPrompts.test.ts deleted file mode 100644 index c158c172..00000000 --- a/tests/unit/agents/shared/taskPrompts.test.ts +++ /dev/null @@ -1,274 +0,0 @@ -import { describe, expect, it } from 'vitest'; - -import { - renderCustomPrompt, - renderInlineTaskPrompt, -} from '../../../../src/agents/prompts/index.js'; -import { - buildCheckFailurePrompt, - buildDebugPrompt, -} from '../../../../src/agents/shared/taskPrompts.js'; - -// ============================================================================ -// Inline task prompt template tests (task prompts are now in YAML definitions) -// ============================================================================ - -// Task prompts that were previously in .eta files are now inline in agent definitions. -// These tests verify renderInlineTaskPrompt works correctly with the new inline format. - -// Sample task prompt templates (matching what's in the YAML files) -const WORK_ITEM_TEMPLATE = - 'Analyze and process the work item with ID: <%= it.workItemId %>. The work item data has been pre-loaded.'; - -const COMMENT_RESPONSE_TEMPLATE = `A user (@<%= it.commentAuthor %>) mentioned you in a comment on work item <%= it.workItemId %>. - -Their comment: ---- -<%= it.commentText %> ---- - -The work item data (title, description, checklists, attachments, comments) has been pre-loaded above. -Read the user's comment carefully and classify it: if they ask a question or request clarification, reply with a thorough answer via PostComment (do not modify the plan). If they request plan changes, make surgical, targeted updates. If the comment contains both a question and a change request, do both. Default to plan updates when intent is ambiguous.`; - -const REVIEW_TEMPLATE = `Review PR #<%= it.prNumber %>. - -Examine the code changes carefully and submit your review using CreatePRReview.`; - -const CI_TEMPLATE = `You are on the branch \`<%= it.prBranch %>\` for PR #<%= it.prNumber %>. - -CI checks have failed. Analyze the failures and fix them.`; - -const PR_COMMENT_RESPONSE_TEMPLATE = `You are on the branch \`<%= it.prBranch %>\` for PR #<%= it.prNumber %>. - -A user commented on this PR and mentioned you. Respond to their comment. -<% if (it.commentPath) { -%> -File: <%= it.commentPath %> -<% } -%> - -Their comment: ---- -<%= it.commentBody %> ---- - -Read the comment carefully and respond accordingly. If they ask for code changes, make the changes, commit, and push. If they ask a question, reply with a PR comment. Default to surgical, targeted changes unless they clearly ask for something broader.`; - -describe('workItem task template', () => { - it('includes the work item ID', () => { - const prompt = renderInlineTaskPrompt(WORK_ITEM_TEMPLATE, { workItemId: 'abc123' }); - expect(prompt).toContain('abc123'); - }); - - it('asks the agent to process the work item', () => { - const prompt = renderInlineTaskPrompt(WORK_ITEM_TEMPLATE, { workItemId: 'wi-99' }); - expect(prompt).toContain('work item'); - }); -}); - -describe('commentResponse task template', () => { - it('includes work item ID, comment text, and author', () => { - const prompt = renderInlineTaskPrompt(COMMENT_RESPONSE_TEMPLATE, { - workItemId: 'wi-42', - commentText: 'Please add tests', - commentAuthor: 'alice', - }); - expect(prompt).toContain('wi-42'); - expect(prompt).toContain('Please add tests'); - expect(prompt).toContain('@alice'); - }); - - it('instructs surgical updates for plan changes', () => { - const prompt = renderInlineTaskPrompt(COMMENT_RESPONSE_TEMPLATE, { - workItemId: 'wi-1', - commentText: 'Fix the typo', - commentAuthor: 'bob', - }); - expect(prompt).toContain('surgical'); - }); - - it('mentions that work item data is pre-loaded', () => { - const prompt = renderInlineTaskPrompt(COMMENT_RESPONSE_TEMPLATE, { - workItemId: 'wi-1', - commentText: 'Update docs', - commentAuthor: 'carol', - }); - expect(prompt).toContain('pre-loaded'); - }); - - it('instructs to classify the comment', () => { - const prompt = renderInlineTaskPrompt(COMMENT_RESPONSE_TEMPLATE, { - workItemId: 'wi-1', - commentText: 'Why this approach?', - commentAuthor: 'dave', - }); - expect(prompt).toContain('classify'); - }); - - it('instructs question-only replies via PostComment without plan modification', () => { - const prompt = renderInlineTaskPrompt(COMMENT_RESPONSE_TEMPLATE, { - workItemId: 'wi-1', - commentText: 'Why this approach?', - commentAuthor: 'dave', - }); - expect(prompt).toContain('question'); - expect(prompt).toContain('PostComment'); - expect(prompt).toContain('do not modify the plan'); - }); - - it('defaults to plan updates when intent is ambiguous', () => { - const prompt = renderInlineTaskPrompt(COMMENT_RESPONSE_TEMPLATE, { - workItemId: 'wi-1', - commentText: 'Some comment', - commentAuthor: 'eve', - }); - expect(prompt).toContain('Default to plan updates when intent is ambiguous'); - }); -}); - -describe('review task template', () => { - it('includes the PR number', () => { - const prompt = renderInlineTaskPrompt(REVIEW_TEMPLATE, { prNumber: 42 }); - expect(prompt).toContain('PR #42'); - }); - - it('instructs to use CreatePRReview', () => { - const prompt = renderInlineTaskPrompt(REVIEW_TEMPLATE, { prNumber: 7 }); - expect(prompt).toContain('CreatePRReview'); - }); -}); - -describe('ci task template', () => { - it('includes branch and PR number', () => { - const prompt = renderInlineTaskPrompt(CI_TEMPLATE, { prBranch: 'fix/ci-errors', prNumber: 99 }); - expect(prompt).toContain('fix/ci-errors'); - expect(prompt).toContain('PR #99'); - }); - - it('mentions CI checks have failed', () => { - const prompt = renderInlineTaskPrompt(CI_TEMPLATE, { prBranch: 'main', prNumber: 1 }); - expect(prompt).toContain('CI checks have failed'); - }); -}); - -describe('prCommentResponse task template', () => { - it('includes PR number, branch, and comment body', () => { - const prompt = renderInlineTaskPrompt(PR_COMMENT_RESPONSE_TEMPLATE, { - prBranch: 'feat/new', - prNumber: 55, - commentBody: 'Can you fix the typo?', - }); - expect(prompt).toContain('PR #55'); - expect(prompt).toContain('feat/new'); - expect(prompt).toContain('Can you fix the typo?'); - }); - - it('includes file path when provided', () => { - const prompt = renderInlineTaskPrompt(PR_COMMENT_RESPONSE_TEMPLATE, { - prBranch: 'feat/new', - prNumber: 55, - commentBody: 'Fix this line', - commentPath: 'src/utils.ts', - }); - expect(prompt).toContain('src/utils.ts'); - }); - - it('omits file path when not provided', () => { - const prompt = renderInlineTaskPrompt(PR_COMMENT_RESPONSE_TEMPLATE, { - prBranch: 'feat/new', - prNumber: 55, - commentBody: 'Looks good overall!', - }); - expect(prompt).not.toContain('File:'); - }); - - it('omits file path when empty string provided', () => { - const prompt = renderInlineTaskPrompt(PR_COMMENT_RESPONSE_TEMPLATE, { - prBranch: 'feat/new', - prNumber: 55, - commentBody: 'LGTM', - commentPath: '', - }); - expect(prompt).not.toContain('File:'); - }); - - it('instructs surgical changes by default', () => { - const prompt = renderInlineTaskPrompt(PR_COMMENT_RESPONSE_TEMPLATE, { - prBranch: 'main', - prNumber: 1, - commentBody: 'Please refactor', - }); - expect(prompt).toContain('surgical'); - }); -}); - -// ============================================================================ -// Edge cases: DB partials and error handling -// ============================================================================ - -describe('renderInlineTaskPrompt edge cases', () => { - it('renders DB task prompt override with partials via renderCustomPrompt', () => { - const dbPartials = new Map([['custom', 'DB partial content']]); - const result = renderCustomPrompt('Task: <%~ include("partials/custom") %>', {}, dbPartials); - expect(result).toContain('DB partial content'); - }); - - it('renders basic template without partials', () => { - const template = 'Process work item <%= it.workItemId %>'; - const prompt = renderInlineTaskPrompt(template, { workItemId: 'wi-123' }); - expect(prompt).toBe('Process work item wi-123'); - }); -}); - -// ============================================================================ -// Direct-call prompts (not part of YAML profile system) -// ============================================================================ - -describe('buildCheckFailurePrompt', () => { - const prContext = { - prNumber: 33, - prBranch: 'fix/flaky-test', - repoFullName: 'acme/widgets', - headSha: 'abc123', - }; - - it('includes PR number and branch', () => { - const prompt = buildCheckFailurePrompt(prContext); - expect(prompt).toContain('PR #33'); - expect(prompt).toContain('fix/flaky-test'); - }); - - it('includes owner and repo from repoFullName', () => { - const prompt = buildCheckFailurePrompt(prContext); - expect(prompt).toContain('acme'); - expect(prompt).toContain('widgets'); - }); - - it('provides investigation steps', () => { - const prompt = buildCheckFailurePrompt(prContext); - expect(prompt).toContain('gh run list'); - expect(prompt).toContain('gh run view'); - }); -}); - -describe('buildDebugPrompt', () => { - const debugContext = { - logDir: '/tmp/logs/abc', - originalWorkItemName: 'Fix the login bug', - originalWorkItemUrl: 'https://trello.com/c/abc', - detectedAgentType: 'implementation', - }; - - it('includes the log directory', () => { - const prompt = buildDebugPrompt(debugContext); - expect(prompt).toContain('/tmp/logs/abc'); - }); - - it('includes the original work item name', () => { - const prompt = buildDebugPrompt(debugContext); - expect(prompt).toContain('Fix the login bug'); - }); - - it('includes the detected agent type', () => { - const prompt = buildDebugPrompt(debugContext); - expect(prompt).toContain('implementation'); - }); -});