greenline-works-mcp-server 0.3.1 → 0.3.3

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/PROMPTS.md CHANGED
@@ -21,13 +21,16 @@ Steps:
21
21
  1. Call greenline_get_board with board "<BOARD_PUBLIC_ID>" (response_format: "json") to confirm the board exists.
22
22
  2. Call greenline_list_board_columns for the board (response_format: "json"). Each column is wrapped as
23
23
  { ColumnItem: ... }; the WIP limit is ColumnItem.maxWIP and the lower bound is ColumnItem.minWIP.
24
- Treat a null or 0 maxWIP as "no limit set" and skip that column for WIP checks.
25
- 3. Call greenline_list_cards for the board with count: 100 (response_format: "json"); while has_more is
26
- true, fetch the next page so every card is counted. Group cards by their column.
24
+ Collect the columnId of every column whose maxWIP is set (not null or 0) - only those need cards.
25
+ 3. Call greenline_list_cards for the board with columns set to those columnIds (comma-separated),
26
+ count: 100, response_format: "json". Fetch further pages until a page comes back short or empty;
27
+ do not rely on has_more alone. Group cards by columnId, never by column title - boards can have
28
+ identically named columns under different parents.
27
29
  4. Compare each limited column's card count against its maxWIP and note violations.
28
- 5. A card is aging when it has sat in its current column for more than 7 days. Check candidates
29
- (cards in work columns, oldest lastActionAt first) with greenline_get_card_metrics for their time in
30
- column - do not call metrics for every card on the board.
30
+ 5. A card is aging when it has sat in its current column for more than 7 days. Check the
31
+ oldest few candidates per work column (by lastActionAt) with greenline_get_card_metrics. In the
32
+ metrics, the current column is the segment with endAt null - its totalTime reads 0, so compute the
33
+ days from its startAt.
31
34
 
32
35
  Output format:
33
36
  - WIP violations: column name - limit N, actual M.
@@ -69,8 +72,9 @@ Arguments: `board`, `hours`
69
72
  Draft a standup update (yesterday / today / blockers) from recent movement on GreenLine board <BOARD_PUBLIC_ID>.
70
73
 
71
74
  Steps:
72
- 1. Call greenline_list_cards for the board with count: 100 (response_format: "json"); while has_more is
73
- true, fetch the next page.
75
+ 1. Call greenline_list_cards for the board with count: 100 (response_format: "json"). Fetch further
76
+ pages until a page comes back short or empty (do not rely on has_more alone), and stop after five
77
+ pages - on a larger board, ask for a narrower scope instead.
74
78
  2. Preselect from the list itself: cards whose doneAt falls in the last 48 hours (yesterday), cards
75
79
  in work columns with recent lastActionAt (today), and cards with blocked: true (blockers - the
76
80
  blockedReason is already on the card, no extra calls needed).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greenline-works-mcp-server",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Model Context Protocol server for the GreenLine public API",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.greenline.works/mcp",
package/src/constants.js CHANGED
@@ -8,7 +8,7 @@ const DEFAULT_PAGE_SIZE = 20;
8
8
  const MAX_PAGE_SIZE = 100;
9
9
 
10
10
  const SERVER_NAME = 'greenline-works-mcp-server';
11
- const SERVER_VERSION = '0.3.1';
11
+ const SERVER_VERSION = '0.3.3';
12
12
 
13
13
  const REQUEST_TIMEOUT_MS = 30000;
14
14
 
@@ -0,0 +1,134 @@
1
+ // Converts the markdown LLM clients naturally produce into the HTML the API accepts.
2
+ //
3
+ // The public API takes rich text as an HTML string — POST /comments, POST /tasks and the
4
+ // checklist tasks[] all validate `required|string` on it — so markdown must become HTML here
5
+ // rather than a delta. The server converts that HTML to its stored delta (utils/quill.js),
6
+ // which preserves inline <code> and multi-line <pre> as of 8.8.0.
7
+ //
8
+ // Input that already contains HTML is returned untouched, so a client following the documented
9
+ // format is never double-converted.
10
+
11
+ const SUPPORTED_TAG = /<(?:p|br|strong|em|u|s|a|ul|ol|li|h[1-3]|blockquote|pre|code)\b[^>]*>/i;
12
+ const containsHtml = text => SUPPORTED_TAG.test(text);
13
+
14
+ const escapeHtml = text => text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
15
+
16
+ const renderMarkers = text =>
17
+ text
18
+ .replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>')
19
+ .replace(/__([^_]+)__/g, '<strong>$1</strong>')
20
+ .replace(/(^|[^*])\*([^*\s][^*]*)\*/g, '$1<em>$2</em>')
21
+ .replace(/(^|[^_])_([^_\s][^_]*)_/g, '$1<em>$2</em>')
22
+ .replace(/~~([^~]+)~~/g, '<s>$1</s>')
23
+ .replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g, '<a href="$2">$1</a>');
24
+
25
+ // Code spans are split out before the other markers so they cannot mangle their contents —
26
+ // `run_a_test` is a name, not italics.
27
+ const renderInline = text =>
28
+ escapeHtml(text)
29
+ .split(/(`[^`]+`)/)
30
+ .map(part =>
31
+ part.length > 2 && part.startsWith('`') && part.endsWith('`')
32
+ ? `<code>${part.slice(1, -1)}</code>`
33
+ : renderMarkers(part)
34
+ )
35
+ .join('');
36
+
37
+ const UNORDERED = /^(\s*)[-*+]\s+(.*)$/;
38
+ const ORDERED = /^(\s*)\d+[.)]\s+(.*)$/;
39
+ const HEADING = /^(#{1,3})\s+(.*)$/;
40
+ const QUOTE = /^>\s?(.*)$/;
41
+ const FENCE = /^\s*```/;
42
+
43
+ const markdownToHtml = value => {
44
+ if (typeof value !== 'string' || !value.trim()) return value;
45
+ if (containsHtml(value)) return value;
46
+
47
+ const lines = value.replace(/\r\n/g, '\n').split('\n');
48
+ const out = [];
49
+ let list = null;
50
+ let paragraph = [];
51
+ let fenced = false;
52
+ let fence = [];
53
+
54
+ const closeList = () => {
55
+ if (list) {
56
+ out.push(`</${list}>`);
57
+ list = null;
58
+ }
59
+ };
60
+ const closeParagraph = () => {
61
+ if (paragraph.length) {
62
+ out.push(`<p>${renderInline(paragraph.join(' '))}</p>`);
63
+ paragraph = [];
64
+ }
65
+ };
66
+ const closeFence = () => {
67
+ out.push(`<pre>${fence.map(escapeHtml).join('\n')}</pre>`);
68
+ fence = [];
69
+ };
70
+ const openList = kind => {
71
+ if (list !== kind) {
72
+ closeList();
73
+ out.push(`<${kind}>`);
74
+ list = kind;
75
+ }
76
+ };
77
+
78
+ for (const line of lines) {
79
+ if (FENCE.test(line)) {
80
+ closeParagraph();
81
+ closeList();
82
+ if (fenced) closeFence();
83
+ fenced = !fenced;
84
+ continue;
85
+ }
86
+ if (fenced) {
87
+ fence.push(line);
88
+ continue;
89
+ }
90
+ if (!line.trim()) {
91
+ closeParagraph();
92
+ closeList();
93
+ continue;
94
+ }
95
+
96
+ const heading = line.match(HEADING);
97
+ if (heading) {
98
+ closeParagraph();
99
+ closeList();
100
+ out.push(`<h${heading[1].length}>${renderInline(heading[2])}</h${heading[1].length}>`);
101
+ continue;
102
+ }
103
+
104
+ const quote = line.match(QUOTE);
105
+ if (quote) {
106
+ closeParagraph();
107
+ closeList();
108
+ out.push(`<blockquote>${renderInline(quote[1])}</blockquote>`);
109
+ continue;
110
+ }
111
+
112
+ const unordered = line.match(UNORDERED);
113
+ const ordered = unordered ? null : line.match(ORDERED);
114
+ if (unordered || ordered) {
115
+ closeParagraph();
116
+ openList(unordered ? 'ul' : 'ol');
117
+ out.push(`<li>${renderInline((unordered || ordered)[2])}</li>`);
118
+ continue;
119
+ }
120
+
121
+ paragraph.push(line.trim());
122
+ }
123
+
124
+ closeParagraph();
125
+ closeList();
126
+ // An unterminated fence still carries its lines.
127
+ if (fenced && fence.length) closeFence();
128
+ return out.join('');
129
+ };
130
+
131
+ // Every rich-text field on the API is an HTML string; markdown is converted, HTML passes through.
132
+ const richTextBody = (field, value) => ({ [field]: markdownToHtml(value) });
133
+
134
+ module.exports = { markdownToHtml, richTextBody, containsHtml };
package/src/prompts.js CHANGED
@@ -18,13 +18,16 @@ const boardReviewText = (board, agingDays) =>
18
18
  `1. Call greenline_get_board with board "${board}" (response_format: "json") to confirm the board exists.`,
19
19
  '2. Call greenline_list_board_columns for the board (response_format: "json"). Each column is wrapped as',
20
20
  ' { ColumnItem: ... }; the WIP limit is ColumnItem.maxWIP and the lower bound is ColumnItem.minWIP.',
21
- ' Treat a null or 0 maxWIP as "no limit set" and skip that column for WIP checks.',
22
- `3. Call greenline_list_cards for the board with count: 100 (response_format: "json"); while has_more is`,
23
- ' true, fetch the next page so every card is counted. Group cards by their column.',
21
+ ' Collect the columnId of every column whose maxWIP is set (not null or 0) - only those need cards.',
22
+ '3. Call greenline_list_cards for the board with columns set to those columnIds (comma-separated),',
23
+ ' count: 100, response_format: "json". Fetch further pages until a page comes back short or empty;',
24
+ ' do not rely on has_more alone. Group cards by columnId, never by column title - boards can have',
25
+ ' identically named columns under different parents.',
24
26
  "4. Compare each limited column's card count against its maxWIP and note violations.",
25
- `5. A card is aging when it has sat in its current column for more than ${agingDays} days. Check candidates`,
26
- ' (cards in work columns, oldest lastActionAt first) with greenline_get_card_metrics for their time in',
27
- ' column - do not call metrics for every card on the board.',
27
+ `5. A card is aging when it has sat in its current column for more than ${agingDays} days. Check the`,
28
+ ' oldest few candidates per work column (by lastActionAt) with greenline_get_card_metrics. In the',
29
+ ' metrics, the current column is the segment with endAt null - its totalTime reads 0, so compute the',
30
+ ' days from its startAt.',
28
31
  '',
29
32
  'Output format:',
30
33
  '- WIP violations: column name - limit N, actual M.',
@@ -56,8 +59,9 @@ const standupSummaryText = (board, hours) =>
56
59
  `Draft a standup update (yesterday / today / blockers) from recent movement on GreenLine board ${board}.`,
57
60
  '',
58
61
  'Steps:',
59
- `1. Call greenline_list_cards for the board with count: 100 (response_format: "json"); while has_more is`,
60
- ' true, fetch the next page.',
62
+ `1. Call greenline_list_cards for the board with count: 100 (response_format: "json"). Fetch further`,
63
+ ' pages until a page comes back short or empty (do not rely on has_more alone), and stop after five',
64
+ ' pages - on a larger board, ask for a narrower scope instead.',
61
65
  `2. Preselect from the list itself: cards whose doneAt falls in the last ${hours} hours (yesterday), cards`,
62
66
  ' in work columns with recent lastActionAt (today), and cards with blocked: true (blockers - the',
63
67
  ' blockedReason is already on the card, no extra calls needed).',
@@ -1,7 +1,7 @@
1
1
  const { z } = require('zod');
2
2
  const { makeApiRequest, safeRun } = require('../client');
3
3
  const { responseFormatField, ResponseFormat, toJsonString, truncateIfNeeded, RICH_TEXT_HELP } = require('../format');
4
- const { richTextBody } = require('../markdown-delta');
4
+ const { richTextBody } = require('../markdown');
5
5
  const { objectIdField, boardPublicIdField, pageField, countField, isoDateField } = require('../schemas');
6
6
 
7
7
  const READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true };
@@ -1,7 +1,7 @@
1
1
  const { z } = require('zod');
2
2
  const { makeApiRequest, safeRun } = require('../client');
3
3
  const { responseFormatField, ResponseFormat, toJsonString, truncateIfNeeded, RICH_TEXT_HELP } = require('../format');
4
- const { richTextBody } = require('../markdown-delta');
4
+ const { richTextBody } = require('../markdown');
5
5
  const { objectIdField } = require('../schemas');
6
6
 
7
7
  const READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true };
@@ -2,7 +2,7 @@ const { z } = require('zod');
2
2
  const { makeApiRequest, safeRun } = require('../client');
3
3
  const { isoDateField, objectIdField } = require('../schemas');
4
4
  const { RICH_TEXT_HELP } = require('../format');
5
- const { richTextBody } = require('../markdown-delta');
5
+ const { richTextBody } = require('../markdown');
6
6
 
7
7
  const WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true };
8
8
  const IDEMPOTENT_WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true };
@@ -1,94 +0,0 @@
1
- // Converts the markdown LLM clients naturally produce into a Quill Delta, so the API receives the
2
- // stored format directly. Inline: `code`, **bold**, __bold__, *em*, _em_, ~~strike~~, [text](url).
3
- // Blocks: #-### headings, -/*/+ and 1. lists (2-space nesting -> indent), > quotes, ``` fences ->
4
- // code-block lines, blank-line paragraph breaks. Input that already contains HTML is passed through
5
- // in the plain field for the server to convert (richTextBody).
6
-
7
- const SUPPORTED_TAG = /<(?:p|br|strong|em|u|s|a|ul|ol|li|h[1-3]|blockquote|pre|code)\b[^>]*>/i;
8
- const containsHtml = text => SUPPORTED_TAG.test(text);
9
-
10
- const INLINE_TOKEN =
11
- /(`[^`]+`)|(\*\*[^*]+?\*\*)|(__[^_]+?__)|(~~[^~]+?~~)|(\[([^\]]+)\]\((https?:\/\/[^)\s]+)\))|((?<![\w*])\*[^*\s][^*]*?\*(?![\w*]))|((?<![\w_])_[^_\s][^_]*?_(?![\w_]))/;
12
-
13
- const runsFromText = text => {
14
- const runs = [];
15
- let rest = text;
16
- while (rest) {
17
- const match = rest.match(INLINE_TOKEN);
18
- if (!match) {
19
- runs.push({ insert: rest });
20
- break;
21
- }
22
- if (match.index > 0) runs.push({ insert: rest.slice(0, match.index) });
23
- const token = match[0];
24
- if (match[1]) runs.push({ insert: token.slice(1, -1), attributes: { code: true } });
25
- else if (match[2] || match[3]) runs.push({ insert: token.slice(2, -2), attributes: { bold: true } });
26
- else if (match[4]) runs.push({ insert: token.slice(2, -2), attributes: { strike: true } });
27
- else if (match[5]) runs.push({ insert: match[6], attributes: { link: match[7] } });
28
- else runs.push({ insert: token.slice(1, -1), attributes: { italic: true } });
29
- rest = rest.slice(match.index + token.length);
30
- }
31
- return runs;
32
- };
33
-
34
- const markdownToDelta = markdown => {
35
- const ops = [];
36
- const lines = String(markdown).replace(/\r\n/g, '\n').split('\n');
37
- let paragraph = [];
38
- let fenced = false;
39
-
40
- const flushParagraph = () => {
41
- if (!paragraph.length) return;
42
- ops.push(...runsFromText(paragraph.join(' ')), { insert: '\n' });
43
- paragraph = [];
44
- };
45
-
46
- for (const line of lines) {
47
- if (/^\s*```/.test(line)) {
48
- flushParagraph();
49
- fenced = !fenced;
50
- continue;
51
- }
52
- if (fenced) {
53
- if (line) ops.push({ insert: line });
54
- ops.push({ insert: '\n', attributes: { 'code-block': true } });
55
- continue;
56
- }
57
- if (!line.trim()) {
58
- flushParagraph();
59
- continue;
60
- }
61
- const heading = line.match(/^(#{1,3})\s+(.*)$/);
62
- if (heading) {
63
- flushParagraph();
64
- ops.push(...runsFromText(heading[2]), { insert: '\n', attributes: { header: heading[1].length } });
65
- continue;
66
- }
67
- const quote = line.match(/^>\s?(.*)$/);
68
- if (quote) {
69
- flushParagraph();
70
- ops.push(...runsFromText(quote[1]), { insert: '\n', attributes: { blockquote: true } });
71
- continue;
72
- }
73
- const unordered = line.match(/^(\s*)[-*+]\s+(.*)$/);
74
- const ordered = unordered ? null : line.match(/^(\s*)\d+[.)]\s+(.*)$/);
75
- if (unordered || ordered) {
76
- flushParagraph();
77
- const [, lead, text] = unordered || ordered;
78
- const attributes = { list: unordered ? 'bullet' : 'ordered' };
79
- const indent = Math.min(Math.floor(lead.length / 2), 8);
80
- if (indent) attributes.indent = indent;
81
- ops.push(...runsFromText(text), { insert: '\n', attributes });
82
- continue;
83
- }
84
- paragraph.push(line.trim());
85
- }
86
- flushParagraph();
87
- return ops.length ? { ops } : { ops: [{ insert: '\n' }] };
88
- };
89
-
90
- // HTML goes through unchanged for the server to convert; anything else is markdown.
91
- const richTextBody = (field, value) =>
92
- containsHtml(value) ? { [field]: value } : { [`${field}Delta`]: markdownToDelta(value) };
93
-
94
- module.exports = { markdownToDelta, richTextBody, containsHtml };