@konductro/codex-plugin 2.5.0-rc.1 → 2.6.0
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/README.md +12 -3
- package/package.json +1 -1
- package/servers/konductro-api.js +298 -18
package/README.md
CHANGED
|
@@ -89,8 +89,16 @@ Tools are called automatically by Codex based on natural language. You do not in
|
|
|
89
89
|
| Tool | What it does |
|
|
90
90
|
|---|---|
|
|
91
91
|
| `create_work_item` | Create a story, task or bug in the project this repo belongs to |
|
|
92
|
-
| `update_work_item` | Change the title, description
|
|
92
|
+
| `update_work_item` | Change the title, description, acceptance criteria or repository of a work item you own |
|
|
93
93
|
| `delete_work_item` | Delete a task or bug that has not been started |
|
|
94
|
+
| `list_work_items` | List and search a project's work items, with filters (status group, sprint, assignee, kind, priority, title or key) and paging |
|
|
95
|
+
| `list_sprints` | List a project's sprints, newest first |
|
|
96
|
+
| `approve_work_item` | Approve a draft work item (SDM only) |
|
|
97
|
+
| `unapprove_work_item` | Move an approved work item back to draft (SDM only) |
|
|
98
|
+
| `assign_work_item` | Assign a work item to a person, yourself, or nobody (SDM only) |
|
|
99
|
+
| `assign_decomposition` | Assign who decomposes a story into tasks (SDM only) |
|
|
100
|
+
| `add_to_sprint` | Add work items to a sprint; a story brings its approved tasks (SDM only) |
|
|
101
|
+
| `remove_from_sprint` | Take a work item out of a sprint (SDM only) |
|
|
94
102
|
|
|
95
103
|
The project is resolved from the repository's git remote, so you are never asked for a
|
|
96
104
|
project identifier.
|
|
@@ -98,8 +106,9 @@ project identifier.
|
|
|
98
106
|
**Everything created lands in Draft** and still needs an SDM's approval before it can be
|
|
99
107
|
worked on.
|
|
100
108
|
|
|
101
|
-
**`update_work_item` can change
|
|
102
|
-
|
|
109
|
+
**`update_work_item` can change four fields and no others** (title, description, acceptance criteria, repository).
|
|
110
|
+
Status and the rest are not on the schema: assign with `assign_work_item`, sprint with `add_to_sprint`
|
|
111
|
+
and `remove_from_sprint`, approval with `approve_work_item`. Sending
|
|
103
112
|
`acceptanceCriteria` replaces the whole list rather than appending to it. The `changed`
|
|
104
113
|
list it reports back is the fields that were written, not the ones that turned out to
|
|
105
114
|
differ, so re-sending a value unchanged still shows up in it.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konductro/codex-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Codex plugin for the Konductro platform: technical analysis, delivery tasks, repository profiling, and prototype workflows.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
package/servers/konductro-api.js
CHANGED
|
@@ -94,6 +94,9 @@ async function konductroFetch(path, options = {}) {
|
|
|
94
94
|
err.details = parsed?.details ?? null;
|
|
95
95
|
// KON-897: AREA_EXISTS names the area that already has the name.
|
|
96
96
|
err.areaId = parsed?.areaId ?? null;
|
|
97
|
+
// KON-946: REPO_AMBIGUOUS / REPO_NOT_IN_PROJECT carry the matching projects at the top
|
|
98
|
+
// level of the body ({ key, name, client }), not under details.
|
|
99
|
+
err.projects = parsed?.projects ?? null;
|
|
97
100
|
throw err;
|
|
98
101
|
}
|
|
99
102
|
|
|
@@ -207,6 +210,8 @@ async function workItemCall(fn) {
|
|
|
207
210
|
isError: true,
|
|
208
211
|
};
|
|
209
212
|
}
|
|
213
|
+
const repoProjects = repoProjectsText(err);
|
|
214
|
+
if (repoProjects) return { content: [{ type: 'text', text: repoProjects }] }; // a question for the developer, not a failure: see isError above
|
|
210
215
|
const refusal = refusalText(err);
|
|
211
216
|
if (refusal) return { content: [{ type: 'text', text: refusal }] };
|
|
212
217
|
|
|
@@ -218,9 +223,26 @@ async function workItemCall(fn) {
|
|
|
218
223
|
}
|
|
219
224
|
}
|
|
220
225
|
|
|
226
|
+
/**
|
|
227
|
+
* KON-946: a repository can be linked to more than one project. Keyed on code, never on
|
|
228
|
+
* message text. The agent must never pick a project itself: filing in the wrong project is
|
|
229
|
+
* silent and found later by someone else.
|
|
230
|
+
*/
|
|
231
|
+
function repoProjectsText(err) {
|
|
232
|
+
if (err.code !== 'REPO_AMBIGUOUS' && err.code !== 'REPO_NOT_IN_PROJECT') return null;
|
|
233
|
+
const list = (err.projects ?? [])
|
|
234
|
+
.map((p) => `- ${p.name} (key ${p.key}${p.client ? `, client ${p.client}` : ''})`)
|
|
235
|
+
.join('\n');
|
|
236
|
+
if (err.code === 'REPO_AMBIGUOUS') {
|
|
237
|
+
return `This repository is linked to more than one project:\n${list}\n\nNOTHING WAS DONE. Ask the developer which project to use, listing these by name, then call this tool again with projectKey set to the chosen project's key. Do not choose one yourself.`;
|
|
238
|
+
}
|
|
239
|
+
return `${err.message}\n\nThis repository is linked to:\n${list}\n\nNOTHING WAS DONE. Ask the developer which of these projects they meant, then call this tool again with projectKey set to that project's key.`;
|
|
240
|
+
}
|
|
241
|
+
|
|
221
242
|
/** Resolve the project from the repo's git remote, so no project id is ever asked for. */
|
|
222
|
-
async function projectFromRepo(repoUrl) {
|
|
223
|
-
const
|
|
243
|
+
async function projectFromRepo(repoUrl, projectKey) {
|
|
244
|
+
const keyParam = projectKey ? `&projectKey=${encodeURIComponent(projectKey)}` : '';
|
|
245
|
+
const repo = await konductroFetch(`/api/cli/repo-by-url?url=${encodeURIComponent(repoUrl)}${keyParam}`);
|
|
224
246
|
return repo;
|
|
225
247
|
}
|
|
226
248
|
|
|
@@ -881,8 +903,9 @@ server.tool(
|
|
|
881
903
|
text += `### Context Pack\n\n${ctx.ticket.contextPack}\n\n`;
|
|
882
904
|
}
|
|
883
905
|
|
|
884
|
-
// Developer Notes
|
|
885
|
-
// task,
|
|
906
|
+
// Developer Notes: present when context is fetched on a story or a standalone
|
|
907
|
+
// bug itself. For a task, or a bug filed under a story, the notes that matter
|
|
908
|
+
// are the parent story's, rendered below.
|
|
886
909
|
if (ctx.ticket.developerNotes) {
|
|
887
910
|
text += `### Developer Notes\n\n${ctx.ticket.developerNotes}\n\n`;
|
|
888
911
|
}
|
|
@@ -948,12 +971,12 @@ server.tool(
|
|
|
948
971
|
}
|
|
949
972
|
);
|
|
950
973
|
|
|
951
|
-
// Tool: Append a developer note to a story (KON-313)
|
|
974
|
+
// Tool: Append a developer note to a story or standalone bug (KON-313, KON-919)
|
|
952
975
|
server.tool(
|
|
953
976
|
'append_story_developer_note',
|
|
954
|
-
"Append a note to
|
|
977
|
+
"Append a note to the developer notes in Konductro, so context you worked out is there for whoever picks up the work next, including the tester. Notes live on a STORY or a STANDALONE BUG (a bug with no parent story). On a story or a standalone bug, pass its own key. On a task, or on a bug filed under a story, pass the parent story's key, which get_ticket_context prints in its Parent Story heading. Pass the current task's key as taskKey so the entry is attributable; leave it out when you are working the standalone bug itself. Send only your new note — the endpoint appends it, and Konductro stamps the author, timestamp and task itself, so do not include a heading, a timestamp, a separator, or any notes you read earlier.",
|
|
955
978
|
{
|
|
956
|
-
storyId: z.string().describe(
|
|
979
|
+
storyId: z.string().describe("The story or standalone bug to append to: key (e.g. KON-283) or UUID. Not a task, and not a bug filed under a story: for those, pass the parent story's key."),
|
|
957
980
|
note: z.string().describe('The new note only, as markdown. No heading, timestamp or separator.'),
|
|
958
981
|
taskKey: z.string().optional().describe("The key of the task this note came from (e.g. KON-313), when there is one"),
|
|
959
982
|
},
|
|
@@ -977,7 +1000,7 @@ server.tool(
|
|
|
977
1000
|
// Tool: Create a work item
|
|
978
1001
|
server.tool(
|
|
979
1002
|
'create_work_item',
|
|
980
|
-
"Create a story, task or bug in the Konductro project this repository belongs to. Anything created this way lands in DRAFT and still needs an SDM's approval before it can be worked — say so when you report back, so nobody thinks it is ready to start. A task needs a parent story, and is created in the repository repoUrl resolves to; a bug needs no parent and is filed standalone. Creating STORIES is governed by the project's story access setting and may be refused; filing bugs and creating tasks are not affected by it. Pass the repository's git remote (git remote get-url origin) — the project is resolved from it,
|
|
1003
|
+
"Create a story, task or bug in the Konductro project this repository belongs to. Anything created this way lands in DRAFT and still needs an SDM's approval before it can be worked — say so when you report back, so nobody thinks it is ready to start. A task needs a parent story, and is created in the repository repoUrl resolves to; a bug needs no parent and is filed standalone. Creating STORIES is governed by the project's story access setting and may be refused; filing bugs and creating tasks are not affected by it. Pass the repository's git remote (git remote get-url origin) — the project is resolved from it. If the repository is linked to more than one project, the call is refused and lists them: ask the developer which one, then call again with projectKey. If the developer names a project up front (for example \"file a bug in Weza\"), pass its key as projectKey. Never guess a project.",
|
|
981
1004
|
{
|
|
982
1005
|
repoUrl: z.string().describe('The git remote URL of this repository (run: git remote get-url origin)'),
|
|
983
1006
|
kind: z.enum(['story', 'task', 'bug']).describe('What to create'),
|
|
@@ -985,9 +1008,10 @@ server.tool(
|
|
|
985
1008
|
description: z.string().describe('What this is and why, in markdown'),
|
|
986
1009
|
acceptanceCriteria: z.array(z.string()).optional().describe('Observable behaviour, one per item. Omit for a bug unless you have them.'),
|
|
987
1010
|
parentKey: z.string().optional().describe('For a TASK, the parent story key (e.g. KON-451). ONLY a task may have a parent. A story or a bug sent with a parentKey is REFUSED and nothing is created, rather than being filed top-level as though it had worked.'),
|
|
1011
|
+
projectKey: z.string().optional().describe("The project's ticket key (e.g. WEZA) when the repository is linked to more than one project; leave out otherwise"),
|
|
988
1012
|
repositoryId: z.string().optional().describe('For a TASK, the repository UUID it will be built in. Leave this out — it defaults to the repository repoUrl resolves to, which is the one you are standing in. Only set it for a task that will be built in a DIFFERENT repository on the same project, and then you need that repo\'s UUID from Konductro.'),
|
|
989
1013
|
},
|
|
990
|
-
async ({ repoUrl, kind, title, description, acceptanceCriteria, parentKey, repositoryId }) => workItemCall(async () => {
|
|
1014
|
+
async ({ repoUrl, kind, title, description, acceptanceCriteria, parentKey, projectKey, repositoryId }) => workItemCall(async () => {
|
|
991
1015
|
// The backend's body schema DECLARES parentKey, so .strict() does not reject it — it
|
|
992
1016
|
// is accepted and then dropped for anything that is not a task, because the route
|
|
993
1017
|
// reads it only inside the task branch and calls createBug / createStory without it
|
|
@@ -1008,7 +1032,7 @@ server.tool(
|
|
|
1008
1032
|
return `Refused: only a task can be created under a parent, and NOTHING WAS CREATED. ${why}`;
|
|
1009
1033
|
}
|
|
1010
1034
|
|
|
1011
|
-
const repo = await projectFromRepo(repoUrl);
|
|
1035
|
+
const repo = await projectFromRepo(repoUrl, projectKey);
|
|
1012
1036
|
|
|
1013
1037
|
// Creating a task would otherwise be a dead end. The backend requires repositoryId as
|
|
1014
1038
|
// a UUID, and nothing a developer can reach hands one out — get_decomposition_context
|
|
@@ -1043,20 +1067,25 @@ server.tool(
|
|
|
1043
1067
|
// Tool: Update a work item
|
|
1044
1068
|
server.tool(
|
|
1045
1069
|
'update_work_item',
|
|
1046
|
-
"Change the title, description
|
|
1070
|
+
"Change the title, description, acceptance criteria or repository of a work item you own in Konductro — one assigned to you, that you are the developer on, or that you created. THESE FOUR FIELDS ARE ALL YOU CAN CHANGE HERE: status and everything else must be changed in Konductro. For assignee use assign_work_item, for sprint use add_to_sprint and remove_from_sprint, for approval use approve_work_item and unapprove_work_item (those are SDM-only). repository is the repository's exact name (or UUID) within the work item's project. Editing a STORY is governed by the project's story access setting and may be refused, or may be applied and then held for an SDM to review; editing a task is not affected by it. Send only the fields you are actually changing.",
|
|
1047
1071
|
{
|
|
1048
1072
|
key: z.string().describe('The work item key (e.g. KON-451) or UUID'),
|
|
1049
1073
|
title: z.string().optional().describe('The new title'),
|
|
1050
1074
|
description: z.string().optional().describe('The new description, in markdown'),
|
|
1051
1075
|
acceptanceCriteria: z.array(z.string()).optional().describe('The FULL new list, not just the additions — it replaces what is there'),
|
|
1076
|
+
repository: z.string().optional().describe("The repository this item is built in: its exact name (case-insensitive) or its UUID, within the item's project"),
|
|
1052
1077
|
},
|
|
1053
|
-
async ({ key, title, description, acceptanceCriteria }) =>
|
|
1078
|
+
async ({ key, title, description, acceptanceCriteria, repository }) => planningCall(async () => {
|
|
1054
1079
|
const body = {};
|
|
1055
1080
|
if (title !== undefined) body.title = title;
|
|
1056
1081
|
if (description !== undefined) body.description = description;
|
|
1057
1082
|
if (acceptanceCriteria !== undefined) body.acceptanceCriteria = acceptanceCriteria;
|
|
1083
|
+
if (repository !== undefined) {
|
|
1084
|
+
if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(repository.trim())) body.repositoryId = repository.trim();
|
|
1085
|
+
else body.repository = repository.trim();
|
|
1086
|
+
}
|
|
1058
1087
|
if (Object.keys(body).length === 0) {
|
|
1059
|
-
return 'Nothing to change — pass at least one of title, description or
|
|
1088
|
+
return 'Nothing to change — pass at least one of title, description, acceptanceCriteria or repository.';
|
|
1060
1089
|
}
|
|
1061
1090
|
|
|
1062
1091
|
const result = await konductroFetch(`/api/cli/tickets/${encodeURIComponent(key)}/work-item`, {
|
|
@@ -1084,7 +1113,7 @@ server.tool(
|
|
|
1084
1113
|
// Tool: Delete a work item
|
|
1085
1114
|
server.tool(
|
|
1086
1115
|
'delete_work_item',
|
|
1087
|
-
"Delete a task or a bug from Konductro that has not been started. Bugs count: Konductro stores a bug as a task, so a developer's own unstarted bug can be deleted here. Stories cannot — deleting one takes its tasks with it and there is no restore, so archive a story in Konductro instead. Neither can a bug QA filed against a failed test criterion, which is part of that test record rather than yours. Nothing that has started can be deleted by anyone: that means anything carrying a branch, or anything past sprint planning, since only draft, approved and in_sprint items still qualify. Close those out in Konductro instead. Beyond that you may delete an item you are assigned to, are the developer on, or created; an SDM
|
|
1116
|
+
"Delete a task or a bug from Konductro that has not been started. Bugs count: Konductro stores a bug as a task, so a developer's own unstarted bug can be deleted here. Stories cannot — deleting one takes its tasks with it and there is no restore, so archive a story in Konductro instead. Neither can a bug QA filed against a failed test criterion, which is part of that test record rather than yours. Nothing that has started can be deleted by anyone: that means anything carrying a branch, or anything past sprint planning, since only draft, approved and in_sprint items still qualify. Close those out in Konductro instead. Beyond that you may delete an item you are assigned to, are the developer on, or created; an SDM or architect on the project may delete any item that qualifies. This is permanent and there is no undo, so be sure the developer asked for it.",
|
|
1088
1117
|
{
|
|
1089
1118
|
key: z.string().describe('The task or bug key (e.g. KON-452) or UUID'),
|
|
1090
1119
|
},
|
|
@@ -1095,6 +1124,253 @@ server.tool(
|
|
|
1095
1124
|
})
|
|
1096
1125
|
);
|
|
1097
1126
|
|
|
1127
|
+
// ─── KON-953..956: list, approve, assign and sprint tools ───────────────────
|
|
1128
|
+
//
|
|
1129
|
+
// The planning actions an SDM would otherwise do in the browser. Backend contract: KON-951
|
|
1130
|
+
// (approve, assign) and KON-952 (list, sprints, repository). Project comes from the git
|
|
1131
|
+
// remote, or projectKey when the repository is linked to more than one project.
|
|
1132
|
+
|
|
1133
|
+
// Refusals these tools can get. Each is a correct final answer, not a failure, so it is
|
|
1134
|
+
// returned as text (not isError). Keyed on code, never on message text.
|
|
1135
|
+
const PLANNING_REFUSALS = {
|
|
1136
|
+
INSUFFICIENT_PROJECT_ROLE: 'Refused: this needs a project role you do not hold on this project (approving, assigning and sprint changes are SDM-only). Ask an SDM on the project, or ask to be given the role.',
|
|
1137
|
+
NOT_PROJECT_MEMBER: 'Refused: you are not a member of this project. Ask an SDM to add you to the project team.',
|
|
1138
|
+
INVALID_TRANSITION: null,
|
|
1139
|
+
INVALID_ASSIGNEE: null,
|
|
1140
|
+
ALREADY_DECOMPOSED: 'Refused: this story has already been decomposed, so its decomposition cannot be assigned again.',
|
|
1141
|
+
SAME_ASSIGNEE: 'Refused: that person is already assigned this decomposition.',
|
|
1142
|
+
NO_CLI_TOKEN: 'Refused: the new assignee has no CLI token yet, so they could not pick the decomposition up from their CLI. Ask them to create one in Konductro under their profile.',
|
|
1143
|
+
TICKET_IN_PROGRESS: 'Refused: work has already started on this item, so it cannot be taken out of the sprint.',
|
|
1144
|
+
PARENT_STORY_DRAFT: null,
|
|
1145
|
+
REPOSITORY_NOT_IN_PROJECT: 'Refused: that repository is not linked to this work item\'s project.',
|
|
1146
|
+
REPOSITORY_AMBIGUOUS: 'Refused: more than one repository in this project has that name. Pass the repository UUID instead.',
|
|
1147
|
+
INVALID_QUERY: null,
|
|
1148
|
+
NOT_FOUND: null,
|
|
1149
|
+
};
|
|
1150
|
+
|
|
1151
|
+
/** workItemCall, but the refusals above are answered with a clear sentence instead of an error. */
|
|
1152
|
+
async function planningCall(fn) {
|
|
1153
|
+
return workItemCall(async () => {
|
|
1154
|
+
try {
|
|
1155
|
+
return await fn();
|
|
1156
|
+
} catch (err) {
|
|
1157
|
+
if (err.code && Object.prototype.hasOwnProperty.call(PLANNING_REFUSALS, err.code)) {
|
|
1158
|
+
const fixed = PLANNING_REFUSALS[err.code];
|
|
1159
|
+
const sentence = fixed ?? (/[.!?]$/.test(err.message) ? err.message : `${err.message}.`);
|
|
1160
|
+
return `${fixed ? fixed : `Refused (${err.code}): ${sentence}`} NOTHING WAS CHANGED.`;
|
|
1161
|
+
}
|
|
1162
|
+
throw err;
|
|
1163
|
+
}
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
const projectKeyField = z.string().optional().describe("The project's ticket key (e.g. WEZA) when the repository is linked to more than one project; leave out otherwise");
|
|
1168
|
+
const repoUrlField = z.string().describe('The git remote URL of this repository (run: git remote get-url origin). The project is resolved from it.');
|
|
1169
|
+
|
|
1170
|
+
function ticketRef(id) {
|
|
1171
|
+
return encodeURIComponent(String(id).trim());
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
function cell(v) {
|
|
1175
|
+
return String(v ?? '-').replace(/\|/g, '/').replace(/\s+/g, ' ');
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
server.tool(
|
|
1179
|
+
'list_work_items',
|
|
1180
|
+
"List and search the work items (stories, tasks, bugs) of the Konductro project this repository belongs to. Any project member may use it. Pass the repository's git remote; if the repository is linked to more than one project the call lists them and asks you to choose: ask the developer which, then call again with projectKey. Never guess a project. All filters are optional and combine. status takes one status or a group: backlog (draft, approved), in_progress (queued, assigned, in_progress, pr_open, needs_attention, fix_required, merged), in_qa (ready_for_qa, internal_qa, client_uat, uat, verified), done (done, deployed). Results come 50 at a time, ordered by ticket number; use offset to page.",
|
|
1181
|
+
{
|
|
1182
|
+
repoUrl: repoUrlField,
|
|
1183
|
+
projectKey: projectKeyField,
|
|
1184
|
+
q: z.string().optional().describe('Case-insensitive text in the title, or a ticket key such as KON-12 or 12'),
|
|
1185
|
+
kind: z.enum(['story', 'task', 'bug']).optional().describe('Work type'),
|
|
1186
|
+
level: z.enum(['story', 'task']).optional().describe('Hierarchy level'),
|
|
1187
|
+
status: z.string().optional().describe('One status (e.g. approved) or a group: backlog, in_progress, in_qa, done'),
|
|
1188
|
+
sprint: z.string().optional().describe('A sprint id, "active" for the active sprint, or "none" for items in no sprint'),
|
|
1189
|
+
phase: z.string().optional().describe('A phase id'),
|
|
1190
|
+
assignee: z.string().optional().describe('An email, "me", or "unassigned"'),
|
|
1191
|
+
priority: z.enum(['critical', 'high', 'medium', 'low', 'unset']).optional().describe('Priority'),
|
|
1192
|
+
archived: z.enum(['only', 'include']).optional().describe('Archived items are hidden unless you pass this'),
|
|
1193
|
+
limit: z.number().int().min(1).max(100).optional().describe('Page size, 1 to 100 (default 50)'),
|
|
1194
|
+
offset: z.number().int().min(0).optional().describe('How many to skip, for the next page'),
|
|
1195
|
+
},
|
|
1196
|
+
async ({ repoUrl, projectKey, ...filters }) => planningCall(async () => {
|
|
1197
|
+
const repo = await projectFromRepo(repoUrl, projectKey);
|
|
1198
|
+
const qs = new URLSearchParams();
|
|
1199
|
+
for (const [k, v] of Object.entries(filters)) {
|
|
1200
|
+
if (v !== undefined && v !== '') qs.set(k, String(v));
|
|
1201
|
+
}
|
|
1202
|
+
const res = await konductroFetch(`/api/cli/projects/${repo.projectId}/work-items?${qs.toString()}`);
|
|
1203
|
+
const projectName = repo.project?.name ?? 'the project';
|
|
1204
|
+
if (!res.items || res.items.length === 0) {
|
|
1205
|
+
return `No work items in ${projectName} match those filters.`;
|
|
1206
|
+
}
|
|
1207
|
+
const rows = res.items.map((i) => [
|
|
1208
|
+
i.key,
|
|
1209
|
+
i.kind,
|
|
1210
|
+
i.status + (i.archived ? ' (archived)' : ''),
|
|
1211
|
+
i.priority ?? '-',
|
|
1212
|
+
i.assignee?.name ?? i.assignee?.email ?? 'unassigned',
|
|
1213
|
+
i.sprint?.name ?? '-',
|
|
1214
|
+
i.parentKey ?? '-',
|
|
1215
|
+
i.title,
|
|
1216
|
+
].map(cell).join(' | '));
|
|
1217
|
+
const first = res.offset + 1;
|
|
1218
|
+
const last = res.offset + res.items.length;
|
|
1219
|
+
let text = `## ${projectName}: work items ${first} to ${last} of ${res.total}\n\n`;
|
|
1220
|
+
text += 'Key | Kind | Status | Priority | Assignee | Sprint | Parent | Title\n--- | --- | --- | --- | --- | --- | --- | ---\n';
|
|
1221
|
+
text += rows.join('\n');
|
|
1222
|
+
text += res.hasMore
|
|
1223
|
+
? `\n\nMore results: call again with offset ${res.offset + res.limit} (same filters).`
|
|
1224
|
+
: '\n\nThat is all of them.';
|
|
1225
|
+
return text;
|
|
1226
|
+
}),
|
|
1227
|
+
);
|
|
1228
|
+
|
|
1229
|
+
server.tool(
|
|
1230
|
+
'list_sprints',
|
|
1231
|
+
"List the sprints of the Konductro project this repository belongs to, newest first, with status, goal and dates. Any project member may use it. Pass the repository's git remote; if the repository is linked to more than one project the call lists them: ask the developer which, then call again with projectKey. Use it to find a sprint before add_to_sprint.",
|
|
1232
|
+
{
|
|
1233
|
+
repoUrl: repoUrlField,
|
|
1234
|
+
projectKey: projectKeyField,
|
|
1235
|
+
},
|
|
1236
|
+
async ({ repoUrl, projectKey }) => planningCall(async () => {
|
|
1237
|
+
const repo = await projectFromRepo(repoUrl, projectKey);
|
|
1238
|
+
const res = await konductroFetch(`/api/cli/projects/${repo.projectId}/sprints`);
|
|
1239
|
+
const projectName = repo.project?.name ?? 'the project';
|
|
1240
|
+
if (!res.sprints || res.sprints.length === 0) return `${projectName} has no sprints.`;
|
|
1241
|
+
const day = (d) => (d ? String(d).slice(0, 10) : '-');
|
|
1242
|
+
const rows = res.sprints.map((s) => [s.name, s.status, `${day(s.startDate)} to ${day(s.endDate)}`, s.goal ?? '-', s.id].map(cell).join(' | '));
|
|
1243
|
+
return `## ${projectName}: sprints\n\nName | Status | Dates | Goal | Id\n--- | --- | --- | --- | ---\n${rows.join('\n')}`;
|
|
1244
|
+
}),
|
|
1245
|
+
);
|
|
1246
|
+
|
|
1247
|
+
server.tool(
|
|
1248
|
+
'approve_work_item',
|
|
1249
|
+
"Approve a work item in Konductro: moves it from draft to approved, exactly as the Approve button does. SDM on the project only; anyone else is refused with a sentence saying so. Only a draft can be approved; any other status is refused and named. Works for a story, task or bug.",
|
|
1250
|
+
{
|
|
1251
|
+
key: z.string().describe('The work item key (e.g. KON-451) or UUID'),
|
|
1252
|
+
},
|
|
1253
|
+
async ({ key }) => planningCall(async () => {
|
|
1254
|
+
const r = await konductroFetch(`/api/cli/tickets/${ticketRef(key)}/approve`, { method: 'POST' });
|
|
1255
|
+
return `Approved ${r.key}: "${r.title}" moved from ${r.previousStatus} to ${r.status}.`;
|
|
1256
|
+
}),
|
|
1257
|
+
);
|
|
1258
|
+
|
|
1259
|
+
server.tool(
|
|
1260
|
+
'unapprove_work_item',
|
|
1261
|
+
"Take a work item back from approved to draft in Konductro. SDM on the project only; anyone else is refused with a sentence saying so. Only an approved item can be moved back; any other status is refused and named. Works for a story, task or bug.",
|
|
1262
|
+
{
|
|
1263
|
+
key: z.string().describe('The work item key (e.g. KON-451) or UUID'),
|
|
1264
|
+
},
|
|
1265
|
+
async ({ key }) => planningCall(async () => {
|
|
1266
|
+
const r = await konductroFetch(`/api/cli/tickets/${ticketRef(key)}/unapprove`, { method: 'POST' });
|
|
1267
|
+
return `Un-approved ${r.key}: "${r.title}" moved from ${r.previousStatus} back to ${r.status}.`;
|
|
1268
|
+
}),
|
|
1269
|
+
);
|
|
1270
|
+
|
|
1271
|
+
server.tool(
|
|
1272
|
+
'assign_work_item',
|
|
1273
|
+
"Assign a work item to a person, or unassign it. SDM on the project only; anyone else is refused with a sentence saying so. assignee is their email, their user id, or \"me\" for yourself; leave it out to unassign. The person must be a member of the item's project. Assigning a draft or approved item also moves it to assigned, and the assignee is notified (unless you assign yourself). This is the work assignment; to assign a story's decomposition use assign_decomposition.",
|
|
1274
|
+
{
|
|
1275
|
+
key: z.string().describe('The work item key (e.g. KON-451) or UUID'),
|
|
1276
|
+
assignee: z.string().optional().describe('Email or user id of the assignee, or "me". Leave out to unassign.'),
|
|
1277
|
+
},
|
|
1278
|
+
async ({ key, assignee }) => planningCall(async () => {
|
|
1279
|
+
const who = assignee === undefined || assignee.trim() === '' ? null : assignee.trim();
|
|
1280
|
+
const r = await konductroFetch(`/api/cli/tickets/${ticketRef(key)}/assign`, {
|
|
1281
|
+
method: 'POST',
|
|
1282
|
+
body: JSON.stringify({ assignee: who }),
|
|
1283
|
+
});
|
|
1284
|
+
return r.assigneeId
|
|
1285
|
+
? `Assigned ${r.key}: "${r.title}" to ${r.assigneeName ?? r.assigneeId}. Status is now ${r.status}.`
|
|
1286
|
+
: `Unassigned ${r.key}: "${r.title}". Status is ${r.status}.`;
|
|
1287
|
+
}),
|
|
1288
|
+
);
|
|
1289
|
+
|
|
1290
|
+
server.tool(
|
|
1291
|
+
'assign_decomposition',
|
|
1292
|
+
"Assign who decomposes a story into tasks in Konductro (the /decompose work). SDM on the project only; anyone else is refused with a sentence saying so. Stories only. assignee is an email, a user id or \"me\", and must be a project member with a CLI token. If a decomposition is already assigned and not yet submitted it is reassigned. Refused once the story has been decomposed.",
|
|
1293
|
+
{
|
|
1294
|
+
key: z.string().describe('The story key (e.g. KON-451) or UUID'),
|
|
1295
|
+
assignee: z.string().describe('Email or user id of the person who will decompose it, or "me"'),
|
|
1296
|
+
},
|
|
1297
|
+
async ({ key, assignee }) => planningCall(async () => {
|
|
1298
|
+
const r = await konductroFetch(`/api/cli/stories/${ticketRef(key)}/decomposition-assignment`, {
|
|
1299
|
+
method: 'POST',
|
|
1300
|
+
body: JSON.stringify({ assignee }),
|
|
1301
|
+
});
|
|
1302
|
+
return `${r.reassigned ? 'Reassigned' : 'Assigned'} the decomposition of ${r.key} to ${assignee}. Decomposition status: ${r.decompositionStatus}.`;
|
|
1303
|
+
}),
|
|
1304
|
+
);
|
|
1305
|
+
|
|
1306
|
+
server.tool(
|
|
1307
|
+
'add_to_sprint',
|
|
1308
|
+
"Add work items to a sprint in Konductro. SDM on the project only; anyone else is refused with a sentence saying so. Pass item keys and a sprint name or id (list_sprints shows them). A STORY is not added itself: its APPROVED tasks are, and the answer says which tasks came along; tasks that are not approved are skipped and reported. Items already in a sprint, finished, or whose parent story is still draft are reported, not silently dropped.",
|
|
1309
|
+
{
|
|
1310
|
+
repoUrl: repoUrlField,
|
|
1311
|
+
projectKey: projectKeyField,
|
|
1312
|
+
keys: z.array(z.string()).min(1).describe('Work item keys (e.g. KON-451) or UUIDs; stories and tasks may be mixed'),
|
|
1313
|
+
sprint: z.string().describe('The sprint name (exact, case-insensitive) or id'),
|
|
1314
|
+
override: z.boolean().optional().describe('Only when the developer asked to move items out of another sprint'),
|
|
1315
|
+
},
|
|
1316
|
+
async ({ repoUrl, projectKey, keys, sprint, override }) => planningCall(async () => {
|
|
1317
|
+
const repo = await projectFromRepo(repoUrl, projectKey);
|
|
1318
|
+
const { sprints } = await konductroFetch(`/api/cli/projects/${repo.projectId}/sprints`);
|
|
1319
|
+
const wanted = sprint.trim().toLowerCase();
|
|
1320
|
+
let match = sprints.filter((s) => s.id === sprint.trim());
|
|
1321
|
+
if (match.length === 0) match = sprints.filter((s) => s.name.trim().toLowerCase() === wanted);
|
|
1322
|
+
if (match.length === 0) {
|
|
1323
|
+
return `Refused: no sprint named or with id "${sprint}" in this project. NOTHING WAS CHANGED. Sprints here: ${sprints.map((s) => s.name).join(', ') || 'none'}.`;
|
|
1324
|
+
}
|
|
1325
|
+
if (match.length > 1) {
|
|
1326
|
+
return `Refused: more than one sprint is named "${sprint}". NOTHING WAS CHANGED. Ask the developer which, then call again with the sprint id: ${match.map((s) => `${s.name} (${s.status}, ${s.id})`).join('; ')}.`;
|
|
1327
|
+
}
|
|
1328
|
+
const body = { items: keys.map((k) => k.trim()) };
|
|
1329
|
+
if (override) body.override = true;
|
|
1330
|
+
const r = await konductroFetch(`/api/cli/projects/${repo.projectId}/sprints/${match[0].id}/tickets`, {
|
|
1331
|
+
method: 'POST',
|
|
1332
|
+
body: JSON.stringify(body),
|
|
1333
|
+
});
|
|
1334
|
+
const n = (a) => (Array.isArray(a) ? a.length : 0);
|
|
1335
|
+
const label = (list) => list.map((t) => (typeof t === 'string' ? t : t.key ?? (t.ticketNumber ? `#${t.ticketNumber}` : t.id))).join(', ');
|
|
1336
|
+
let text = `Added ${r.added} item${r.added === 1 ? '' : 's'} to sprint "${r.sprint?.name ?? match[0].name}".`;
|
|
1337
|
+
for (const s of r.expandedStories ?? []) {
|
|
1338
|
+
text += `\nStory ${s.key} ("${s.title}") was not added itself: its ${s.tasksAdded} approved task${s.tasksAdded === 1 ? '' : 's'} came along instead.`;
|
|
1339
|
+
}
|
|
1340
|
+
if (n(r.assigned)) text += `\nAdded: ${label(r.assigned)}.`;
|
|
1341
|
+
if (n(r.skippedNotApproved)) text += `\nSkipped, not approved yet (approve first): ${label(r.skippedNotApproved)}.`;
|
|
1342
|
+
if (n(r.alreadyAssigned)) text += `\nAlready in another sprint, left alone: ${label(r.alreadyAssigned)}.`;
|
|
1343
|
+
if (n(r.alreadyInSprint)) text += `\nAlready in this sprint: ${label(r.alreadyInSprint)}.`;
|
|
1344
|
+
if (n(r.skippedDone)) text += `\nSkipped, already done: ${label(r.skippedDone)}.`;
|
|
1345
|
+
if (n(r.unresolved)) text += `\nNot found in this project, so not added: ${r.unresolved.map((u) => (typeof u === 'string' ? u : `${u.id} (${u.reason})`)).join(', ')}.`;
|
|
1346
|
+
if (r.added === 0) text += '\nNothing was eligible, so nothing changed.';
|
|
1347
|
+
return text;
|
|
1348
|
+
}),
|
|
1349
|
+
);
|
|
1350
|
+
|
|
1351
|
+
server.tool(
|
|
1352
|
+
'remove_from_sprint',
|
|
1353
|
+
"Take a work item out of a sprint in Konductro. SDM on the project only; anyone else is refused with a sentence saying so. Refused once work has started on the item. Pass the item key and the sprint name or id it is in.",
|
|
1354
|
+
{
|
|
1355
|
+
repoUrl: repoUrlField,
|
|
1356
|
+
projectKey: projectKeyField,
|
|
1357
|
+
key: z.string().describe('The work item key (e.g. KON-451) or UUID'),
|
|
1358
|
+
sprint: z.string().describe('The sprint name (exact, case-insensitive) or id'),
|
|
1359
|
+
},
|
|
1360
|
+
async ({ repoUrl, projectKey, key, sprint }) => planningCall(async () => {
|
|
1361
|
+
const repo = await projectFromRepo(repoUrl, projectKey);
|
|
1362
|
+
const { sprints } = await konductroFetch(`/api/cli/projects/${repo.projectId}/sprints`);
|
|
1363
|
+
const wanted = sprint.trim().toLowerCase();
|
|
1364
|
+
let match = sprints.filter((s) => s.id === sprint.trim());
|
|
1365
|
+
if (match.length === 0) match = sprints.filter((s) => s.name.trim().toLowerCase() === wanted);
|
|
1366
|
+
if (match.length !== 1) {
|
|
1367
|
+
return `Refused: ${match.length === 0 ? `no sprint named or with id "${sprint}"` : `more than one sprint is named "${sprint}"`} in this project. NOTHING WAS CHANGED. Use list_sprints and pass the sprint id.`;
|
|
1368
|
+
}
|
|
1369
|
+
const r = await konductroFetch(`/api/cli/projects/${repo.projectId}/sprints/${match[0].id}/tickets/${ticketRef(key)}`, { method: 'DELETE' });
|
|
1370
|
+
return `Removed ${r.key ?? key} from sprint "${match[0].name}".`;
|
|
1371
|
+
}),
|
|
1372
|
+
);
|
|
1373
|
+
|
|
1098
1374
|
// Tool: Start work on a ticket
|
|
1099
1375
|
server.tool(
|
|
1100
1376
|
'start_work',
|
|
@@ -1219,7 +1495,7 @@ server.tool(
|
|
|
1219
1495
|
return {
|
|
1220
1496
|
content: [{
|
|
1221
1497
|
type: 'text',
|
|
1222
|
-
text: `## Repository Profile Submitted\n\n${result.message}\n\n- Repository: ${result.repoName}\n- Profile ID: ${result.profileId}`,
|
|
1498
|
+
text: `## Repository Profile Submitted\n\n${result.message}\n\n- Repository: ${result.repoName}\n- Profile ID: ${result.profileId}${typeof result.projectsUpdated === 'number' ? `\n- Saved for ${result.projectsUpdated} project${result.projectsUpdated === 1 ? '' : 's'}` : ''}`,
|
|
1223
1499
|
}],
|
|
1224
1500
|
};
|
|
1225
1501
|
} catch (err) {
|
|
@@ -1236,11 +1512,12 @@ server.tool(
|
|
|
1236
1512
|
// Tool: Find prototypes for a project (by git remote URL)
|
|
1237
1513
|
server.tool(
|
|
1238
1514
|
'find_project_prototypes',
|
|
1239
|
-
'Find available UX prototypes for a project by matching the git remote URL to a Konductro project',
|
|
1515
|
+
'Find available UX prototypes for a project by matching the git remote URL to a Konductro project. If the repository is linked to more than one project the call is refused and lists them: ask the developer which one, then call again with projectKey. Never guess a project.',
|
|
1240
1516
|
{
|
|
1241
1517
|
repoUrl: z.string().describe('The git remote URL of the repository (e.g. from git remote get-url origin)'),
|
|
1518
|
+
projectKey: z.string().optional().describe("The project's ticket key (e.g. WEZA) when the repository is linked to more than one project; leave out otherwise"),
|
|
1242
1519
|
},
|
|
1243
|
-
async ({ repoUrl }) => {
|
|
1520
|
+
async ({ repoUrl, projectKey }) => {
|
|
1244
1521
|
if (!KONDUCTRO_URL || !CLI_TOKEN) {
|
|
1245
1522
|
return {
|
|
1246
1523
|
content: [{
|
|
@@ -1251,7 +1528,8 @@ server.tool(
|
|
|
1251
1528
|
}
|
|
1252
1529
|
|
|
1253
1530
|
try {
|
|
1254
|
-
const
|
|
1531
|
+
const keyParam = projectKey ? `&projectKey=${encodeURIComponent(projectKey)}` : '';
|
|
1532
|
+
const result = await konductroFetch(`/api/cli/project-prototypes?repoUrl=${encodeURIComponent(repoUrl)}${keyParam}`);
|
|
1255
1533
|
|
|
1256
1534
|
if (!result.prototypes || result.prototypes.length === 0) {
|
|
1257
1535
|
return {
|
|
@@ -1277,6 +1555,8 @@ server.tool(
|
|
|
1277
1555
|
}],
|
|
1278
1556
|
};
|
|
1279
1557
|
} catch (err) {
|
|
1558
|
+
const repoProjects = repoProjectsText(err);
|
|
1559
|
+
if (repoProjects) return { content: [{ type: 'text', text: repoProjects }] }; // a question for the developer, not a failure: see isError above
|
|
1280
1560
|
return {
|
|
1281
1561
|
content: [{
|
|
1282
1562
|
type: 'text',
|