@gethmy/mcp 2.3.2 → 2.3.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.
@@ -1,481 +0,0 @@
1
- import { createRequire } from "node:module";
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __toESM = (mod, isNodeMode, target) => {
8
- target = mod != null ? __create(__getProtoOf(mod)) : {};
9
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
- for (let key of __getOwnPropNames(mod))
11
- if (!__hasOwnProp.call(to, key))
12
- __defProp(to, key, {
13
- get: () => mod[key],
14
- enumerable: true
15
- });
16
- return to;
17
- };
18
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
- var __export = (target, all) => {
20
- for (var name in all)
21
- __defProp(target, name, {
22
- get: all[name],
23
- enumerable: true,
24
- configurable: true,
25
- set: (newValue) => all[name] = () => newValue
26
- });
27
- };
28
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
29
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
30
-
31
- // src/prompt-builder.ts
32
- var exports_prompt_builder = {};
33
- __export(exports_prompt_builder, {
34
- inferCategoryFromLabels: () => inferCategoryFromLabels,
35
- getRoleFraming: () => getRoleFraming,
36
- getAvailableVariants: () => getAvailableVariants,
37
- getAvailableCategories: () => getAvailableCategories,
38
- generatePrompt: () => generatePrompt
39
- });
40
- function inferCategoryFromLabels(labels) {
41
- for (const label of labels) {
42
- const normalizedName = label.name.toLowerCase().trim();
43
- if (LABEL_CATEGORY_MAP[normalizedName]) {
44
- return LABEL_CATEGORY_MAP[normalizedName];
45
- }
46
- for (const [key, category] of Object.entries(LABEL_CATEGORY_MAP)) {
47
- if (normalizedName.includes(key) || key.includes(normalizedName)) {
48
- return category;
49
- }
50
- }
51
- }
52
- return "custom";
53
- }
54
- function getRoleFraming(category) {
55
- return DEFAULT_ROLE_FRAMINGS[category];
56
- }
57
- function estimateTokens(text) {
58
- return Math.ceil(text.length / 4);
59
- }
60
- function formatSubtasks(subtasks) {
61
- if (subtasks.length === 0)
62
- return "";
63
- const completed = subtasks.filter((s) => s.completed).length;
64
- const lines = subtasks.map((s) => ` ${s.completed ? "[x]" : "[ ]"} ${s.title}`);
65
- return `
66
- ## Subtasks (${completed}/${subtasks.length} completed)
67
- ${lines.join(`
68
- `)}`;
69
- }
70
- function formatLabels(labels) {
71
- if (labels.length === 0)
72
- return "";
73
- return `
74
- **Labels:** ${labels.map((l) => l.name).join(", ")}`;
75
- }
76
- function formatLinkedCards(links) {
77
- if (!links || links.length === 0)
78
- return "";
79
- const lines = links.map((link) => {
80
- const prefix = link.direction === "outgoing" ? "->" : "<-";
81
- return ` ${prefix} #${link.target_card.short_id}: ${link.target_card.title} (${link.display_type})`;
82
- });
83
- return `
84
- ## Related Cards
85
- ${lines.join(`
86
- `)}`;
87
- }
88
- function generatePrompt(options) {
89
- const {
90
- card,
91
- column,
92
- variant,
93
- customConstraints,
94
- memories,
95
- assembledContext,
96
- assemblyId
97
- } = options;
98
- const contextOpts = {
99
- includeTitle: true,
100
- includeDescription: true,
101
- includeLabels: true,
102
- includeSubtasks: true,
103
- includeActivity: false,
104
- includeAssignee: true,
105
- includeDueDate: true,
106
- includePriority: true,
107
- includeLinks: true,
108
- includeColumn: true,
109
- ...options.contextOptions
110
- };
111
- const labels = card.labels || [];
112
- const subtasks = card.subtasks || [];
113
- const links = card.links || [];
114
- const category = inferCategoryFromLabels(labels);
115
- const roleFraming = getRoleFraming(category);
116
- const sections = [];
117
- sections.push(`# Role: ${roleFraming.role}
118
- `);
119
- sections.push(roleFraming.perspective);
120
- sections.push("");
121
- sections.push(VARIANT_INSTRUCTIONS[variant]);
122
- sections.push("");
123
- sections.push(`# Task: ${card.title}`);
124
- if (contextOpts.includeColumn && column) {
125
- sections.push(`**Status:** ${column.name}`);
126
- }
127
- if (contextOpts.includePriority) {
128
- sections.push(`**Priority:** ${card.priority}`);
129
- }
130
- if (contextOpts.includeDueDate && card.due_date) {
131
- sections.push(`**Due:** ${card.due_date}`);
132
- }
133
- if (contextOpts.includeAssignee && card.assignee) {
134
- sections.push(`**Assignee:** ${card.assignee.full_name || card.assignee.email}`);
135
- }
136
- if (contextOpts.includeLabels && labels.length > 0) {
137
- sections.push(formatLabels(labels));
138
- }
139
- if (contextOpts.includeDescription && card.description) {
140
- sections.push(`
141
- ## Description
142
- ${card.description}`);
143
- }
144
- if (contextOpts.includeSubtasks && subtasks.length > 0) {
145
- sections.push(formatSubtasks(subtasks));
146
- }
147
- if (contextOpts.includeLinks && links.length > 0) {
148
- sections.push(formatLinkedCards(links));
149
- }
150
- sections.push(`
151
- ## Focus Areas`);
152
- roleFraming.focus.forEach((f) => {
153
- sections.push(`- ${f}`);
154
- });
155
- sections.push(`- **Memory:** Store reusable knowledge via \`harmony_remember\`. Only store what a future agent couldn't easily discover from the code itself, applies beyond this specific card, and includes a "because" (not just what, but why).`);
156
- sections.push(` - GOOD: "BoardContext card state must use moveCard action, never direct setState — optimistic updates depend on action ordering"`);
157
- sections.push(` - GOOD: "Mobile bottom bar is 64px, overlaps fixed-position drawers — always add pb-16 to drawer content"`);
158
- sections.push(` - BAD: "Fixed the login button" (no reusable knowledge — the fix is in the code)`);
159
- sections.push(` - BAD: "Completed card #42" (ephemeral, auto-tracked by session)`);
160
- sections.push(`
161
- ## Suggested Outputs`);
162
- roleFraming.outputSuggestions.forEach((s) => {
163
- sections.push(`- ${s}`);
164
- });
165
- if (assembledContext) {
166
- sections.push(`
167
- ${assembledContext}`);
168
- } else if (memories && memories.length > 0) {
169
- sections.push(`
170
- ## Relevant Memories`);
171
- sections.push(`*${memories.length} memories recalled from knowledge graph:*`);
172
- for (const memory of memories) {
173
- const tags = memory.tags.length > 0 ? ` [${memory.tags.join(", ")}]` : "";
174
- sections.push(`
175
- ### ${memory.title} (${memory.type}, confidence: ${memory.confidence})${tags}`);
176
- sections.push(memory.content);
177
- }
178
- }
179
- const oneThingLine = synthesizeOneThing(card, subtasks, links, assembledContext);
180
- if (oneThingLine) {
181
- sections.push(`
182
- ## Recommended Next Step
183
- ${oneThingLine}`);
184
- }
185
- if (variant === "execute") {
186
- sections.push(`
187
- ## Progress Tracking
188
- Update your progress by calling \`harmony_update_agent_progress\` with \`currentTask\` describing what you're doing now:
189
- - After exploring the codebase and understanding requirements (~20%)
190
- - When you start implementing changes (~50%)
191
- - When you move to testing or verification (~80%)
192
- - When done, before ending the session (100%)
193
-
194
- Keep \`currentTask\` specific (e.g., "Refactoring auth middleware" not "Working on card").`);
195
- }
196
- if (customConstraints) {
197
- sections.push(`
198
- ## Additional Instructions
199
- ${customConstraints}`);
200
- }
201
- sections.push(`
202
- ---
203
- *Card #${card.short_id} | Generated for ${variant} mode*`);
204
- const prompt = sections.join(`
205
- `);
206
- const memoryCount = assembledContext ? (assembledContext.match(/^### /gm) || []).length : memories?.length || 0;
207
- return {
208
- prompt,
209
- variant,
210
- category,
211
- role: roleFraming.role,
212
- contextSummary: {
213
- hasDescription: !!card.description,
214
- labelCount: labels.length,
215
- subtaskCount: subtasks.length,
216
- completedSubtasks: subtasks.filter((s) => s.completed).length,
217
- linkedCardCount: links.length,
218
- memoryCount
219
- },
220
- tokenEstimate: estimateTokens(prompt),
221
- ...assemblyId && { assemblyId }
222
- };
223
- }
224
- function extractSessionInsights(assembledContext) {
225
- const result = {
226
- lastSessionStatus: null,
227
- lastSessionTask: null,
228
- lastSessionProgress: null,
229
- blockers: [],
230
- procedureNextStep: null
231
- };
232
- const sessionMatches = assembledContext.match(/### Session:.*?\n([\s\S]*?)(?=\n###|\n## |\n---|\n\*Assembly|$)/g);
233
- if (sessionMatches && sessionMatches.length > 0) {
234
- const latest = sessionMatches[0];
235
- if (/Completed work on/i.test(latest)) {
236
- result.lastSessionStatus = "completed";
237
- } else if (/Paused work on|status:\s*paused/i.test(latest)) {
238
- result.lastSessionStatus = "paused";
239
- }
240
- const taskMatch = latest.match(/Final task:\s*(.+)/);
241
- if (taskMatch)
242
- result.lastSessionTask = taskMatch[1].trim();
243
- const progressMatch = latest.match(/Progress:\s*(\d+)%/);
244
- if (progressMatch)
245
- result.lastSessionProgress = parseInt(progressMatch[1], 10);
246
- }
247
- const blockerMatches = assembledContext.match(/(?:blocker|blocked by|blocking):\s*(.+)/gi);
248
- if (blockerMatches) {
249
- result.blockers = blockerMatches.map((m) => m.replace(/(?:blocker|blocked by|blocking):\s*/i, "").trim());
250
- }
251
- const stepMatches = assembledContext.match(/^\d+\.\s+(?!.*\*\*\[key step\]\*\*.*✓)(.+?)(?:\s*\*\*\[key step\]\*\*)?$/gm);
252
- if (stepMatches && stepMatches.length > 0) {
253
- result.procedureNextStep = stepMatches[0].replace(/^\d+\.\s+/, "").replace(/\s*\*\*\[key step\]\*\*.*$/, "").trim();
254
- }
255
- return result;
256
- }
257
- function synthesizeOneThing(card, subtasks, links, assembledContext) {
258
- if (card.done)
259
- return null;
260
- const blockers = links.filter((l) => l.display_type === "is_blocked_by" && l.direction === "incoming");
261
- if (blockers.length > 0) {
262
- const blocker = blockers[0];
263
- return `Unblock first: resolve #${blocker.target_card.short_id} "${blocker.target_card.title}" which is blocking this card.`;
264
- }
265
- const session = assembledContext ? extractSessionInsights(assembledContext) : null;
266
- if (session?.blockers && session.blockers.length > 0) {
267
- return `Resolve blocker: ${session.blockers[0]}`;
268
- }
269
- if (session?.lastSessionStatus === "paused" && session.lastSessionTask) {
270
- const progress = session.lastSessionProgress ? ` (was ${session.lastSessionProgress}% complete)` : "";
271
- return `Resume previous session${progress}: "${session.lastSessionTask}".`;
272
- }
273
- if (subtasks.length > 0) {
274
- const completed = subtasks.filter((s) => s.completed).length;
275
- if (completed === subtasks.length) {
276
- return "All subtasks completed. Review the work and mark the card as done.";
277
- }
278
- const nextSubtask = subtasks.find((s) => !s.completed);
279
- if (nextSubtask) {
280
- return `Work on next subtask: "${nextSubtask.title}" (${completed}/${subtasks.length} done).`;
281
- }
282
- }
283
- if (session?.procedureNextStep) {
284
- return `Follow procedure: ${session.procedureNextStep}`;
285
- }
286
- if (session?.lastSessionStatus === "completed" && session.lastSessionTask) {
287
- return `Previous session completed ("${session.lastSessionTask}"). Review results and continue with remaining work.`;
288
- }
289
- if (card.due_date && (card.priority === "urgent" || card.priority === "high")) {
290
- return `High-priority task with deadline ${card.due_date}. Start implementation immediately.`;
291
- }
292
- if (card.description) {
293
- return "Analyze the description, identify the approach, and begin implementation.";
294
- }
295
- return null;
296
- }
297
- function getAvailableCategories() {
298
- return ["bug", "feature", "design", "review", "onboarding", "epic", "custom"];
299
- }
300
- function getAvailableVariants() {
301
- return ["analysis", "draft", "execute"];
302
- }
303
- var LABEL_CATEGORY_MAP, DEFAULT_ROLE_FRAMINGS, VARIANT_INSTRUCTIONS;
304
- var init_prompt_builder = __esm(() => {
305
- LABEL_CATEGORY_MAP = {
306
- bug: "bug",
307
- fix: "bug",
308
- hotfix: "bug",
309
- defect: "bug",
310
- issue: "bug",
311
- error: "bug",
312
- feature: "feature",
313
- enhancement: "feature",
314
- improvement: "feature",
315
- new: "feature",
316
- design: "design",
317
- ui: "design",
318
- ux: "design",
319
- frontend: "design",
320
- styling: "design",
321
- review: "review",
322
- "code review": "review",
323
- pr: "review",
324
- feedback: "review",
325
- onboarding: "onboarding",
326
- documentation: "onboarding",
327
- docs: "onboarding",
328
- guide: "onboarding",
329
- tutorial: "onboarding",
330
- epic: "epic",
331
- initiative: "epic",
332
- project: "epic",
333
- milestone: "epic"
334
- };
335
- DEFAULT_ROLE_FRAMINGS = {
336
- bug: {
337
- category: "bug",
338
- role: "Senior QA Engineer and Software Developer",
339
- perspective: "You are investigating and fixing a bug report.",
340
- focus: [
341
- "Root cause analysis",
342
- "Steps to reproduce",
343
- "Impact assessment",
344
- "Fix implementation",
345
- "Regression prevention",
346
- "Test cases to prevent recurrence"
347
- ],
348
- outputSuggestions: [
349
- "Bug triage summary",
350
- "Root cause explanation",
351
- "Fix implementation plan",
352
- "Test cases"
353
- ]
354
- },
355
- feature: {
356
- category: "feature",
357
- role: "Product Engineer",
358
- perspective: "You are implementing a new feature or enhancement.",
359
- focus: [
360
- "User requirements",
361
- "Technical specification",
362
- "Implementation approach",
363
- "Edge cases",
364
- "Acceptance criteria",
365
- "Integration points"
366
- ],
367
- outputSuggestions: [
368
- "Technical specification",
369
- "Implementation tasks",
370
- "Acceptance criteria checklist",
371
- "API design"
372
- ]
373
- },
374
- design: {
375
- category: "design",
376
- role: "UX Designer and Frontend Developer",
377
- perspective: "You are designing and implementing a user interface.",
378
- focus: [
379
- "User experience flow",
380
- "Visual design consistency",
381
- "Accessibility (WCAG)",
382
- "Responsive behavior",
383
- "Component architecture",
384
- "Interaction patterns"
385
- ],
386
- outputSuggestions: [
387
- "User flow diagram",
388
- "Component specifications",
389
- "Accessibility checklist",
390
- "Responsive breakpoints"
391
- ]
392
- },
393
- review: {
394
- category: "review",
395
- role: "Code Reviewer and Technical Lead",
396
- perspective: "You are reviewing code for quality, correctness, and maintainability.",
397
- focus: [
398
- "Code correctness",
399
- "Performance implications",
400
- "Security considerations",
401
- "Testing coverage",
402
- "Documentation",
403
- "Best practices adherence"
404
- ],
405
- outputSuggestions: [
406
- "Review checklist",
407
- "Suggested improvements",
408
- "Test scenarios",
409
- "Security audit"
410
- ]
411
- },
412
- onboarding: {
413
- category: "onboarding",
414
- role: "Technical Writer and Developer Advocate",
415
- perspective: "You are creating documentation or onboarding materials.",
416
- focus: [
417
- "Clear step-by-step instructions",
418
- "Prerequisites and setup",
419
- "Common pitfalls",
420
- "Examples and use cases",
421
- "Troubleshooting guide",
422
- "Related resources"
423
- ],
424
- outputSuggestions: [
425
- "Getting started guide",
426
- "Step-by-step tutorial",
427
- "FAQ section",
428
- "Troubleshooting guide"
429
- ]
430
- },
431
- epic: {
432
- category: "epic",
433
- role: "Technical Project Manager and Architect",
434
- perspective: "You are planning and coordinating a large initiative.",
435
- focus: [
436
- "Scope definition",
437
- "Task breakdown",
438
- "Dependencies",
439
- "Risk assessment",
440
- "Timeline considerations",
441
- "Success metrics"
442
- ],
443
- outputSuggestions: [
444
- "Epic breakdown into stories",
445
- "Dependency graph",
446
- "Risk mitigation plan",
447
- "Success criteria"
448
- ]
449
- },
450
- custom: {
451
- category: "custom",
452
- role: "Software Engineer",
453
- perspective: "You are working on a software task.",
454
- focus: [
455
- "Understanding requirements",
456
- "Implementation approach",
457
- "Quality considerations",
458
- "Testing strategy"
459
- ],
460
- outputSuggestions: [
461
- "Implementation plan",
462
- "Technical notes",
463
- "Task checklist"
464
- ]
465
- }
466
- };
467
- VARIANT_INSTRUCTIONS = {
468
- analysis: `ANALYSIS MODE: Analyze this task thoroughly. Identify requirements, constraints, edge cases, and potential challenges. Do NOT implement anything yet - focus on understanding and planning.`,
469
- draft: `DRAFT MODE: Create a detailed implementation plan with code structure, key decisions, and approach. Include pseudocode or skeleton code where helpful. This is for review before full implementation.`,
470
- execute: `EXECUTE MODE: Implement this task completely. Write production-ready code following best practices. Include necessary tests and documentation.`
471
- };
472
- });
473
- init_prompt_builder();
474
-
475
- export {
476
- inferCategoryFromLabels,
477
- getRoleFraming,
478
- getAvailableVariants,
479
- getAvailableCategories,
480
- generatePrompt
481
- };