Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/agents/shared/promptContext.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getTrelloConfig } from '../../pm/config.js';
import { getJiraConfig, getTrelloConfig } from '../../pm/config.js';
import { getPMProvider } from '../../pm/index.js';
import type { ProjectConfig } from '../../types/index.js';
import type { PromptContext } from '../prompts/index.js';
Expand Down Expand Up @@ -30,7 +30,7 @@ export function buildPromptContext(
cardUrl: cardId ? pmProvider.getWorkItemUrl(cardId) : undefined,
projectId: project.id,
baseBranch: project.baseBranch,
storiesListId: getTrelloConfig(project)?.lists?.stories,
storiesListId: getTrelloConfig(project)?.lists?.stories ?? getJiraConfig(project)?.projectKey,
processedLabelId: getTrelloConfig(project)?.labels?.processed,
pmType: pmProvider.type,
workItemNoun: isJira ? 'issue' : 'card',
Expand Down
3 changes: 2 additions & 1 deletion src/backends/progressModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { LLMist, type ModelSpec } from 'llmist';

import { getAgentLabel } from '../config/agentMessages.js';
import { AGENT_ROLE_HINTS, getAgentLabel } from '../config/agentMessages.js';
import type { Todo } from '../gadgets/todo/storage.js';

export interface ProgressContext {
Expand Down Expand Up @@ -40,6 +40,7 @@ function formatProgressUserPrompt(context: ProgressContext): string {

const sections: string[] = [
`Agent: ${agentType}`,
`Agent role: ${AGENT_ROLE_HINTS[agentType] ?? 'Processes the request'}`,
`Progress header: **${emoji} ${label}** (${Math.round(elapsedMinutes)} min)`,
`Task: ${taskDescription.slice(0, 500)}`,
`Time elapsed: ${Math.round(elapsedMinutes)} minutes`,
Expand Down
19 changes: 19 additions & 0 deletions src/config/agentMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ export function getAgentLabel(agentType: string): { emoji: string; label: string
return AGENT_LABELS[agentType] ?? { emoji: '⚙️', label: 'Progress Update' };
}

/**
* Agent role hints — give LLMs context about what each agent type does.
*
* Used by:
* - ackMessageGenerator.ts — contextual acknowledgment messages
* - progressModel.ts — progress update generation
*/
export const AGENT_ROLE_HINTS: Record<string, string> = {
splitting: 'Breaks down a feature plan into smaller, ordered work items (subtasks)',
planning: 'Studies the codebase and designs a step-by-step implementation plan',
implementation: 'Writes code, runs tests, and prepares a pull request',
review: 'Reviews pull request changes for quality and correctness',
'respond-to-planning-comment': 'Reads user feedback and updates the plan accordingly',
'respond-to-review': 'Addresses code review feedback by making requested changes',
'respond-to-pr-comment': 'Reads a PR comment and takes action',
'respond-to-ci': 'Analyzes failed CI checks and works on a fix',
debug: 'Analyzes session logs to identify what went wrong',
};

/**
* Human-readable initial messages per agent type.
*
Expand Down
15 changes: 15 additions & 0 deletions src/pm/jira/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ export class JiraPMProvider implements PMProvider {
...(config.labels?.length ? { labels: config.labels } : {}),
});
const key = result.key ?? '';

// Transition to stories status if configured (mirrors Trello's stories list)
const storiesStatus = this.config.statuses?.stories;
if (storiesStatus) {
try {
await this.moveWorkItem(key, storiesStatus);
} catch (err) {
logger.warn('[JIRA] Failed to transition new issue to stories status', {
issueKey: key,
targetStatus: storiesStatus,
error: String(err),
});
}
}

return {
id: key,
title: config.title,
Expand Down
5 changes: 3 additions & 2 deletions src/router/ackMessageGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { LLMist, type ModelSpec } from 'llmist';

import { INITIAL_MESSAGES } from '../config/agentMessages.js';
import { AGENT_ROLE_HINTS, INITIAL_MESSAGES } from '../config/agentMessages.js';
import { CUSTOM_MODELS } from '../config/customModels.js';
import { getOrgCredential, loadConfig } from '../config/provider.js';
import { logger } from '../utils/logging.js';
Expand Down Expand Up @@ -240,7 +240,8 @@ async function callAckModel(
contextSnippet: string,
): Promise<string> {
const client = new LLMist({ customModels: CUSTOM_MODELS as ModelSpec[] });
const userPrompt = `Agent type: ${agentType}\n\nRequest context:\n${contextSnippet}`;
const roleHint = AGENT_ROLE_HINTS[agentType] ?? 'Processes the request';
const userPrompt = `Agent type: ${agentType}\nAgent role: ${roleHint}\n\nRequest context:\n${contextSnippet}`;

const result = await client.text.complete(userPrompt, {
model,
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/agents/shared/promptContext.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ describe('buildPromptContext', () => {
const ctx = buildPromptContext('PROJ-123', makeProject() as never);
expect(ctx.pmType).toBe('jira');
});

it('sets storiesListId to JIRA project key when no Trello config', () => {
const jiraProject = makeProject({
trello: undefined,
pm: { type: 'jira' },
jira: {
projectKey: 'BTS',
baseUrl: 'https://company.atlassian.net',
statuses: { todo: 'To Do' },
},
});
const ctx = buildPromptContext('BTS-148', jiraProject as never);
expect(ctx.storiesListId).toBe('BTS');
});
});

describe('with prContext', () => {
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/backends/progressModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,26 @@ describe('callProgressModel', () => {
expect(mockTextComplete).toHaveBeenCalledTimes(1);
expect(MockLLMist).toHaveBeenCalledTimes(1);
});

it('includes agent role hint in the user prompt', async () => {
mockTextComplete.mockResolvedValue('Progress update.');

await callProgressModel('test-model', makeContext({ agentType: 'splitting' }), []);

const userPrompt = mockTextComplete.mock.calls[0][0] as string;
expect(userPrompt).toContain('Agent: splitting');
expect(userPrompt).toContain(
'Agent role: Breaks down a feature plan into smaller, ordered work items (subtasks)',
);
});

it('uses fallback role hint for unknown agent types', async () => {
mockTextComplete.mockResolvedValue('Progress update.');

await callProgressModel('test-model', makeContext({ agentType: 'unknown-agent' }), []);

const userPrompt = mockTextComplete.mock.calls[0][0] as string;
expect(userPrompt).toContain('Agent: unknown-agent');
expect(userPrompt).toContain('Agent role: Processes the request');
});
});
47 changes: 47 additions & 0 deletions tests/unit/pm/jira/adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,53 @@ describe('JiraPMProvider', () => {
expect.not.objectContaining({ labels: expect.anything() }),
);
});

it('transitions new issue to stories status when configured', async () => {
const storiesProvider = new JiraPMProvider({
...mockConfig,
statuses: { ...mockConfig.statuses, stories: 'Stories' },
});
mockJiraClient.createIssue.mockResolvedValue({ key: 'PROJ-100' });
mockJiraClient.getTransitions.mockResolvedValue([
{ id: '31', name: 'Stories', to: { name: 'Stories' } },
]);
mockJiraClient.transitionIssue.mockResolvedValue(undefined);

await storiesProvider.createWorkItem({
containerId: 'PROJ',
title: 'Story task',
});

expect(mockJiraClient.getTransitions).toHaveBeenCalledWith('PROJ-100');
expect(mockJiraClient.transitionIssue).toHaveBeenCalledWith('PROJ-100', '31');
});

it('does not transition when stories status is not configured', async () => {
mockJiraClient.createIssue.mockResolvedValue({ key: 'PROJ-101' });

await provider.createWorkItem({
containerId: 'PROJ',
title: 'Regular task',
});

expect(mockJiraClient.getTransitions).not.toHaveBeenCalled();
});

it('logs warning and continues when stories transition fails', async () => {
const storiesProvider = new JiraPMProvider({
...mockConfig,
statuses: { ...mockConfig.statuses, stories: 'Stories' },
});
mockJiraClient.createIssue.mockResolvedValue({ key: 'PROJ-102' });
mockJiraClient.getTransitions.mockRejectedValue(new Error('API error'));

const result = await storiesProvider.createWorkItem({
containerId: 'PROJ',
title: 'Task with failing transition',
});

expect(result.id).toBe('PROJ-102');
});
});

describe('listWorkItems', () => {
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/router/ackMessageGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ vi.mock('../../../src/config/agentMessages.js', () => ({
'**📋 Splitting plan** — Reading the plan and splitting it into ordered work items...',
review: '**🔍 Reviewing code** — Examining the PR changes for quality and correctness...',
},
AGENT_ROLE_HINTS: {
splitting: 'Breaks down a feature plan into smaller, ordered work items (subtasks)',
implementation: 'Writes code, runs tests, and prepares a pull request',
review: 'Reviews pull request changes for quality and correctness',
},
}));

import { getOrgCredential, loadConfig } from '../../../src/config/provider.js';
Expand Down
1 change: 1 addition & 0 deletions web/src/components/projects/pm-wizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ const TRELLO_LABEL_SLOTS = ['readyToProcess', 'processing', 'processed', 'error'

const JIRA_STATUS_SLOTS = [
'splitting',
'stories',
'planning',
'todo',
'inProgress',
Expand Down