jira-ai 0.3.19 → 0.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +21 -1
- package/dist/commands/list-colleagues.js +24 -0
- package/dist/commands/transition.js +51 -0
- package/dist/lib/formatters.js +19 -0
- package/dist/lib/jira-client.js +60 -0
- package/package.json +1 -1
- package/settings.yaml +1 -1
package/dist/cli.js
CHANGED
|
@@ -8,12 +8,14 @@ import { projectsCommand } from './commands/projects.js';
|
|
|
8
8
|
import { taskWithDetailsCommand } from './commands/task-with-details.js';
|
|
9
9
|
import { projectStatusesCommand } from './commands/project-statuses.js';
|
|
10
10
|
import { listIssueTypesCommand } from './commands/list-issue-types.js';
|
|
11
|
+
import { listColleaguesCommand } from './commands/list-colleagues.js';
|
|
11
12
|
import { runJqlCommand } from './commands/run-jql.js';
|
|
12
13
|
import { updateDescriptionCommand } from './commands/update-description.js';
|
|
13
14
|
import { addCommentCommand } from './commands/add-comment.js';
|
|
14
15
|
import { addLabelCommand } from './commands/add-label.js';
|
|
15
16
|
import { deleteLabelCommand } from './commands/delete-label.js';
|
|
16
17
|
import { createTaskCommand } from './commands/create-task.js';
|
|
18
|
+
import { transitionCommand } from './commands/transition.js';
|
|
17
19
|
import { getIssueStatisticsCommand } from './commands/get-issue-statistics.js';
|
|
18
20
|
import { aboutCommand } from './commands/about.js';
|
|
19
21
|
import { authCommand } from './commands/auth.js';
|
|
@@ -32,7 +34,7 @@ const program = new Command();
|
|
|
32
34
|
program
|
|
33
35
|
.name('jira-ai')
|
|
34
36
|
.description('CLI tool for interacting with Atlassian Jira')
|
|
35
|
-
.version('0.3.
|
|
37
|
+
.version('0.3.21')
|
|
36
38
|
.option('-o, --organization <alias>', 'Override the active Jira organization');
|
|
37
39
|
// Hook to handle the global option before any command runs
|
|
38
40
|
program.on('option:organization', (alias) => {
|
|
@@ -109,6 +111,17 @@ program
|
|
|
109
111
|
.command('projects')
|
|
110
112
|
.description('Show list of projects')
|
|
111
113
|
.action(withPermission('projects', projectsCommand));
|
|
114
|
+
// List colleagues command
|
|
115
|
+
program
|
|
116
|
+
.command('list-colleagues [project-key]')
|
|
117
|
+
.description('Show all colleagues in the project or organization')
|
|
118
|
+
.action(withPermission('list-colleagues', listColleaguesCommand, {
|
|
119
|
+
validateArgs: (args) => {
|
|
120
|
+
if (args[0]) {
|
|
121
|
+
validateOptions(ProjectKeySchema, args[0]);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}));
|
|
112
125
|
// Task with details command
|
|
113
126
|
program
|
|
114
127
|
.command('task-with-details <task-id>')
|
|
@@ -195,6 +208,13 @@ program
|
|
|
195
208
|
.requiredOption('--issue-type <type>', 'Issue type (e.g., Task, Epic, Subtask)')
|
|
196
209
|
.option('--parent <key>', 'Parent issue key (required for subtasks)')
|
|
197
210
|
.action(withPermission('create-task', createTaskCommand, { schema: CreateTaskSchema }));
|
|
211
|
+
// Transition command
|
|
212
|
+
program
|
|
213
|
+
.command('transition <task-id> <to-status>')
|
|
214
|
+
.description('Transition a Jira task to a new status')
|
|
215
|
+
.action(withPermission('transition', transitionCommand, {
|
|
216
|
+
validateArgs: (args) => validateOptions(IssueKeySchema, args[0])
|
|
217
|
+
}));
|
|
198
218
|
// Get issue statistics command
|
|
199
219
|
program
|
|
200
220
|
.command('get-issue-statistics <task-ids>')
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { getUsers } from '../lib/jira-client.js';
|
|
3
|
+
import { formatUsers } from '../lib/formatters.js';
|
|
4
|
+
import { ui } from '../lib/ui.js';
|
|
5
|
+
export async function listColleaguesCommand(projectKey) {
|
|
6
|
+
const message = projectKey
|
|
7
|
+
? `Fetching colleagues for project ${projectKey}...`
|
|
8
|
+
: 'Fetching all active colleagues...';
|
|
9
|
+
ui.startSpinner(message);
|
|
10
|
+
try {
|
|
11
|
+
const users = await getUsers(projectKey);
|
|
12
|
+
ui.succeedSpinner(chalk.green('Colleagues retrieved'));
|
|
13
|
+
if (users.length === 0) {
|
|
14
|
+
console.log(chalk.yellow('\nNo active colleagues found.'));
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
console.log(formatUsers(users));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
ui.failSpinner(chalk.red('Failed to fetch colleagues'));
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { getIssueTransitions, transitionIssue } from '../lib/jira-client.js';
|
|
3
|
+
import { CommandError } from '../lib/errors.js';
|
|
4
|
+
import { ui } from '../lib/ui.js';
|
|
5
|
+
export async function transitionCommand(taskId, toStatus) {
|
|
6
|
+
ui.startSpinner(`Fetching available transitions for ${taskId}...`);
|
|
7
|
+
try {
|
|
8
|
+
const transitions = await getIssueTransitions(taskId);
|
|
9
|
+
ui.stopSpinner();
|
|
10
|
+
const matchingTransitions = transitions.filter((t) => t.to.name.toLowerCase() === toStatus.toLowerCase());
|
|
11
|
+
if (matchingTransitions.length === 0) {
|
|
12
|
+
const availableStatuses = Array.from(new Set(transitions.map((t) => t.to.name))).join(', ');
|
|
13
|
+
throw new CommandError(`No transition found to status "${toStatus}" for issue ${taskId}.`, {
|
|
14
|
+
hints: [
|
|
15
|
+
`Available destination statuses: ${availableStatuses || 'None'}`,
|
|
16
|
+
'Check the status name and try again (it is case-insensitive).'
|
|
17
|
+
]
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (matchingTransitions.length > 1) {
|
|
21
|
+
const availableTransitions = matchingTransitions.map(t => `"${t.name}" (ID: ${t.id})`).join(', ');
|
|
22
|
+
throw new CommandError(`Multiple transitions found to status "${toStatus}" for issue ${taskId}.`, {
|
|
23
|
+
hints: [
|
|
24
|
+
`Ambiguous matches: ${availableTransitions}`,
|
|
25
|
+
'This command currently only supports unambiguous status matching.'
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const transition = matchingTransitions[0];
|
|
30
|
+
ui.startSpinner(`Transitioning ${taskId} to ${transition.to.name}...`);
|
|
31
|
+
await transitionIssue(taskId, transition.id);
|
|
32
|
+
ui.succeedSpinner(chalk.green(`Issue ${taskId} successfully transitioned to ${transition.to.name}.`));
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (error instanceof CommandError) {
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
const hints = [];
|
|
39
|
+
if (error.message?.includes('403')) {
|
|
40
|
+
hints.push('You may not have permission to transition this issue');
|
|
41
|
+
}
|
|
42
|
+
else if (error.message?.includes('required') || (error.response?.data?.errors && Object.keys(error.response.data.errors).length > 0)) {
|
|
43
|
+
hints.push('This transition might require mandatory fields that are not yet supported by this command.');
|
|
44
|
+
if (error.response?.data?.errors) {
|
|
45
|
+
const fields = Object.keys(error.response.data.errors).join(', ');
|
|
46
|
+
hints.push(`Missing fields: ${fields}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
throw new CommandError(`Failed to transition issue: ${error.message}`, { hints });
|
|
50
|
+
}
|
|
51
|
+
}
|
package/dist/lib/formatters.js
CHANGED
|
@@ -313,3 +313,22 @@ export function formatIssueStatistics(statsList) {
|
|
|
313
313
|
output += table.toString() + '\n';
|
|
314
314
|
return output;
|
|
315
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Format users list
|
|
318
|
+
*/
|
|
319
|
+
export function formatUsers(users) {
|
|
320
|
+
if (users.length === 0) {
|
|
321
|
+
return chalk.yellow('No users found.');
|
|
322
|
+
}
|
|
323
|
+
const table = createTable(['Display Name', 'Email', 'Account ID'], [30, 40, 30]);
|
|
324
|
+
users.forEach((user) => {
|
|
325
|
+
table.push([
|
|
326
|
+
chalk.cyan(user.displayName),
|
|
327
|
+
user.emailAddress || chalk.gray('N/A'),
|
|
328
|
+
chalk.gray(user.accountId),
|
|
329
|
+
]);
|
|
330
|
+
});
|
|
331
|
+
let output = '\n' + chalk.bold(`Colleagues (${users.length} total)`) + '\n\n';
|
|
332
|
+
output += table.toString() + '\n';
|
|
333
|
+
return output;
|
|
334
|
+
}
|
package/dist/lib/jira-client.js
CHANGED
|
@@ -394,3 +394,63 @@ export async function getIssueStatistics(issueIdOrKey) {
|
|
|
394
394
|
currentStatus: statusName,
|
|
395
395
|
};
|
|
396
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* Get available transitions for an issue
|
|
399
|
+
*/
|
|
400
|
+
export async function getIssueTransitions(issueIdOrKey) {
|
|
401
|
+
const client = getJiraClient();
|
|
402
|
+
const response = await client.issues.getTransitions({
|
|
403
|
+
issueIdOrKey,
|
|
404
|
+
});
|
|
405
|
+
return (response.transitions || []).map((t) => ({
|
|
406
|
+
id: t.id || '',
|
|
407
|
+
name: t.name || '',
|
|
408
|
+
to: {
|
|
409
|
+
id: t.to?.id || '',
|
|
410
|
+
name: t.to?.name || '',
|
|
411
|
+
},
|
|
412
|
+
}));
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Perform a transition on an issue
|
|
416
|
+
*/
|
|
417
|
+
export async function transitionIssue(issueIdOrKey, transitionId) {
|
|
418
|
+
const client = getJiraClient();
|
|
419
|
+
await client.issues.doTransition({
|
|
420
|
+
issueIdOrKey,
|
|
421
|
+
transition: {
|
|
422
|
+
id: transitionId,
|
|
423
|
+
},
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Get users, optionally filtered by project
|
|
428
|
+
*/
|
|
429
|
+
export async function getUsers(projectKey) {
|
|
430
|
+
const client = getJiraClient();
|
|
431
|
+
let users;
|
|
432
|
+
if (projectKey) {
|
|
433
|
+
users = await client.userSearch.findAssignableUsers({
|
|
434
|
+
project: projectKey,
|
|
435
|
+
maxResults: 1000,
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
users = await client.userSearch.findUsers({
|
|
440
|
+
query: '',
|
|
441
|
+
maxResults: 1000,
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
// Filter for active users
|
|
445
|
+
return users
|
|
446
|
+
.filter((user) => user.active && user.accountType === 'atlassian')
|
|
447
|
+
.map((user) => ({
|
|
448
|
+
accountId: user.accountId || '',
|
|
449
|
+
displayName: user.displayName || '',
|
|
450
|
+
emailAddress: user.emailAddress || '',
|
|
451
|
+
active: user.active || false,
|
|
452
|
+
timeZone: user.timeZone || '',
|
|
453
|
+
// @ts-ignore
|
|
454
|
+
host: client.config.host || 'N/A',
|
|
455
|
+
}));
|
|
456
|
+
}
|
package/package.json
CHANGED
package/settings.yaml
CHANGED
|
@@ -11,7 +11,7 @@ projects:
|
|
|
11
11
|
# - all
|
|
12
12
|
|
|
13
13
|
# Commands: List of allowed commands (use "all" to allow all commands)
|
|
14
|
-
# Available commands: me, projects, task-with-details, project-statuses, list-issue-types, run-jql, update-description, add-comment, create-task, get-issue-statistics, about
|
|
14
|
+
# Available commands: me, projects, task-with-details, project-statuses, list-issue-types, run-jql, update-description, add-comment, create-task, get-issue-statistics, about, transition, add-label-to-issue, delete-label-from-issue
|
|
15
15
|
commands:
|
|
16
16
|
- me
|
|
17
17
|
- get-issue-statistics
|