@giantswarm-io/pro 1.7.3 → 1.7.4
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/package.json +1 -1
- package/src/lib/items.js +19 -1
- package/src/lib/mcp/tools.js +32 -4
- package/src/lib/project.js +17 -0
- package/src/lib/utils.js +16 -6
package/package.json
CHANGED
package/src/lib/items.js
CHANGED
|
@@ -10,7 +10,8 @@ import { fetchPaginated, graphQLWithAuth } from './api.js';
|
|
|
10
10
|
import {
|
|
11
11
|
LIST_ITEMS_QUERY,
|
|
12
12
|
ISSUE_DETAIL_QUERY,
|
|
13
|
-
UPDATE_ITEM_FIELD_MUTATION
|
|
13
|
+
UPDATE_ITEM_FIELD_MUTATION,
|
|
14
|
+
CLEAR_ITEM_FIELD_MUTATION
|
|
14
15
|
} from './project.js';
|
|
15
16
|
import { listFields, findMatchingOption } from './fields.js';
|
|
16
17
|
import { logger } from './logger.js';
|
|
@@ -448,3 +449,20 @@ export async function updateItemField(itemId, fieldId, value, boardId, token) {
|
|
|
448
449
|
value
|
|
449
450
|
}, token);
|
|
450
451
|
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Clear (unset) a field value directly via GraphQL mutation.
|
|
455
|
+
* Works uniformly for single-select, iteration, and date fields.
|
|
456
|
+
* @param {string} itemId - ID of the item to update
|
|
457
|
+
* @param {string} fieldId - ID of the field to clear
|
|
458
|
+
* @param {string} boardId - The GitHub project node ID
|
|
459
|
+
* @param {string} [token] - Optional per-request GitHub token
|
|
460
|
+
* @returns {Promise<Object>} - Clear result
|
|
461
|
+
*/
|
|
462
|
+
export async function clearItemField(itemId, fieldId, boardId, token) {
|
|
463
|
+
return await graphQLWithAuth(CLEAR_ITEM_FIELD_MUTATION, {
|
|
464
|
+
projectId: boardId,
|
|
465
|
+
itemId: itemId,
|
|
466
|
+
fieldId: fieldId
|
|
467
|
+
}, token);
|
|
468
|
+
}
|
package/src/lib/mcp/tools.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* - list_issue_comments: Fetch comments across multiple board items in one call
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { listItems, getItemByID, updateItemField } from '../items.js';
|
|
17
|
+
import { listItems, getItemByID, updateItemField, clearItemField } from '../items.js';
|
|
18
18
|
import { findFieldByName, findMatchingOption, findMatchingIteration } from '../fields.js';
|
|
19
19
|
import { graphQLWithAuth } from '../api.js';
|
|
20
20
|
import { findMissingLabels, addLabelsToIssue, removeLabelFromIssue } from '../rest-api.js';
|
|
@@ -249,7 +249,7 @@ export async function handleGetIssueDetails(args, extra) {
|
|
|
249
249
|
|
|
250
250
|
export const updateIssueFieldTool = {
|
|
251
251
|
name: 'update_issue_field',
|
|
252
|
-
description: 'Update a field value for an issue on a project board. Supports single-select fields (Status, Kind, Team, etc.) and iteration fields (Quarter). Also supports date fields (Start Date, Target Date) when a specific date is known. The server resolves field and option names to internal IDs automatically.',
|
|
252
|
+
description: 'Update a field value for an issue on a project board. Supports single-select fields (Status, Kind, Team, etc.) and iteration fields (Quarter). Also supports date fields (Start Date, Target Date) when a specific date is known. The server resolves field and option names to internal IDs automatically. To clear/unset a field instead of setting it, pass `clear: true` (and omit `value`) -- this works for single-select, iteration, and date fields.',
|
|
253
253
|
inputSchema: {
|
|
254
254
|
type: 'object',
|
|
255
255
|
properties: {
|
|
@@ -263,7 +263,11 @@ export const updateIssueFieldTool = {
|
|
|
263
263
|
},
|
|
264
264
|
value: {
|
|
265
265
|
type: 'string',
|
|
266
|
-
description: 'The value to set. For single-select/iteration fields: option name with case-insensitive matching (e.g. "Q2 2026"). For date fields: "YYYY-MM-DD" format.'
|
|
266
|
+
description: 'The value to set. For single-select/iteration fields: option name with case-insensitive matching (e.g. "Q2 2026"). For date fields: "YYYY-MM-DD" format. Required unless `clear` is true.'
|
|
267
|
+
},
|
|
268
|
+
clear: {
|
|
269
|
+
type: 'boolean',
|
|
270
|
+
description: 'Set to true to clear/unset the field value instead of setting it (e.g. remove an item\'s Quarter). When true, `value` is ignored. Works for single-select, iteration, and date fields.'
|
|
267
271
|
},
|
|
268
272
|
board: {
|
|
269
273
|
type: 'string',
|
|
@@ -271,7 +275,7 @@ export const updateIssueFieldTool = {
|
|
|
271
275
|
description: 'Which board the item belongs to. Defaults to "roadmap".'
|
|
272
276
|
}
|
|
273
277
|
},
|
|
274
|
-
required: ['itemId', 'fieldName'
|
|
278
|
+
required: ['itemId', 'fieldName']
|
|
275
279
|
}
|
|
276
280
|
};
|
|
277
281
|
|
|
@@ -289,6 +293,30 @@ export async function handleUpdateIssueField(args, extra) {
|
|
|
289
293
|
};
|
|
290
294
|
}
|
|
291
295
|
|
|
296
|
+
// Clear path -- clearProjectV2ItemFieldValue takes only the field ID and
|
|
297
|
+
// works uniformly across single-select, iteration, and date fields, so it
|
|
298
|
+
// short-circuits before the per-type value resolution below.
|
|
299
|
+
if (args.clear === true) {
|
|
300
|
+
await clearItemField(args.itemId, field.id, boardId, token);
|
|
301
|
+
return {
|
|
302
|
+
content: [{
|
|
303
|
+
type: 'text',
|
|
304
|
+
text: JSON.stringify({
|
|
305
|
+
success: true,
|
|
306
|
+
itemId: args.itemId,
|
|
307
|
+
field: args.fieldName,
|
|
308
|
+
cleared: true
|
|
309
|
+
})
|
|
310
|
+
}]
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (typeof args.value !== 'string' || args.value.trim() === '') {
|
|
315
|
+
return {
|
|
316
|
+
error: `A value is required to update field '${args.fieldName}'. Pass a value, or set clear: true to unset the field.`
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
292
320
|
let value;
|
|
293
321
|
let resolvedName;
|
|
294
322
|
|
package/src/lib/project.js
CHANGED
|
@@ -237,6 +237,22 @@ mutation UpdateProjectV2ItemField($projectId: ID!, $itemId: ID!, $fieldId: ID!,
|
|
|
237
237
|
}
|
|
238
238
|
`;
|
|
239
239
|
|
|
240
|
+
const CLEAR_ITEM_FIELD_MUTATION = `
|
|
241
|
+
mutation ClearProjectV2ItemField($projectId: ID!, $itemId: ID!, $fieldId: ID!) {
|
|
242
|
+
clearProjectV2ItemFieldValue(
|
|
243
|
+
input: {
|
|
244
|
+
projectId: $projectId,
|
|
245
|
+
itemId: $itemId,
|
|
246
|
+
fieldId: $fieldId
|
|
247
|
+
}
|
|
248
|
+
) {
|
|
249
|
+
projectV2Item {
|
|
250
|
+
id
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
`;
|
|
255
|
+
|
|
240
256
|
const ISSUE_DETAIL_QUERY = `
|
|
241
257
|
query($id: ID!) {
|
|
242
258
|
node(id: $id) {
|
|
@@ -492,6 +508,7 @@ export {
|
|
|
492
508
|
LIST_ITEMS_OVERVIEW_QUERY,
|
|
493
509
|
LIST_FIELDS_QUERY,
|
|
494
510
|
UPDATE_ITEM_FIELD_MUTATION,
|
|
511
|
+
CLEAR_ITEM_FIELD_MUTATION,
|
|
495
512
|
ISSUE_DETAIL_QUERY,
|
|
496
513
|
CREATE_ISSUE_MUTATION,
|
|
497
514
|
ADD_ITEM_TO_PROJECT_MUTATION,
|
package/src/lib/utils.js
CHANGED
|
@@ -6,7 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Normalize a field value for consistent comparison.
|
|
9
|
-
* Converts to lowercase,
|
|
9
|
+
* Converts to lowercase, treats separators as equivalent, strips punctuation
|
|
10
|
+
* and emojis while preserving letters (including accented/Unicode letters) and
|
|
11
|
+
* numbers, and trims whitespace.
|
|
12
|
+
*
|
|
13
|
+
* Separators (`/`, `-`, `_`, and whitespace runs) all collapse to a single
|
|
14
|
+
* space so that values naming the same option/iteration but using different
|
|
15
|
+
* separator styles compare equal, e.g. "Q4/2026", "Q4-2026", "Q4_2026", and
|
|
16
|
+
* "Q4 2026" all normalize to "q4 2026". This is applied symmetrically to both
|
|
17
|
+
* the caller value and the board's option/iteration titles.
|
|
10
18
|
*
|
|
11
19
|
* @param {string} value - Field value to normalize
|
|
12
20
|
* @returns {string} - Normalized field value for comparison
|
|
@@ -14,10 +22,12 @@
|
|
|
14
22
|
export function normalizeFieldValue(value) {
|
|
15
23
|
if (!value) return '';
|
|
16
24
|
return value.toLowerCase()
|
|
17
|
-
//
|
|
18
|
-
.replace(/[
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
// Treat slash, hyphen, underscore, and whitespace as interchangeable separators
|
|
26
|
+
.replace(/[/\-\s_]+/g, ' ')
|
|
27
|
+
// Keep letters (incl. accented/Unicode), numbers, and spaces;
|
|
28
|
+
// strip everything else -- punctuation, emojis, and other symbols.
|
|
29
|
+
.replace(/[^\p{L}\p{N}\s]/gu, '')
|
|
30
|
+
// Collapse any whitespace introduced above and trim
|
|
31
|
+
.replace(/\s+/g, ' ')
|
|
22
32
|
.trim();
|
|
23
33
|
}
|