automagik-genie
Version:
Self-evolving AI agent orchestration framework with Model Context Protocol support
77 lines (76 loc) • 2.36 kB
JavaScript
;
/**
* Task Title Formatter - Standardized naming for Forge tasks
*
* Format: [SOURCE] [#ISSUE] DESCRIPTION
* - SOURCE: [M] (MCP) or [C] (CLI) - auto-generated by system
* - ISSUE: [#NNN] - optional, auto-filled when parameter provided
* - DESCRIPTION: human-readable task summary
*
* Examples:
* - [M] [#395] Review task name format
* - [C] [#400] Fix authentication bug
* - [M] Generate test coverage report
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatTaskTitle = formatTaskTitle;
exports.parseTaskTitle = parseTaskTitle;
exports.extractIssueFromWish = extractIssueFromWish;
/**
* Format task title with auto-generated prefixes
*
* @param source MCP or CLI (system-determined)
* @param description Human-readable task summary (agent-provided)
* @param issue Optional GitHub issue number
* @returns Formatted title string
*/
function formatTaskTitle(source, description, issue) {
const sourcePrefix = source === 'MCP' ? '[M]' : '[C]';
const issuePrefix = issue ? ` [#${issue}]` : '';
return `${sourcePrefix}${issuePrefix} ${description}`;
}
/**
* Parse task title into components
*
* @param title Full task title string
* @returns Parsed components
*/
function parseTaskTitle(title) {
// Pattern: [M|C] [#ISSUE] DESCRIPTION
// Issue is optional
const withIssue = /^\[([MC])\]\s+\[#(\d+)\]\s+(.+)$/;
const withoutIssue = /^\[([MC])\]\s+(.+)$/;
let match = title.match(withIssue);
if (match) {
return {
source: match[1] === 'M' ? 'MCP' : 'CLI',
issue: parseInt(match[2], 10),
description: match[3],
raw: title
};
}
match = title.match(withoutIssue);
if (match) {
return {
source: match[1] === 'M' ? 'MCP' : 'CLI',
description: match[2],
raw: title
};
}
return {
source: 'UNKNOWN',
description: title,
raw: title
};
}
/**
* Extract GitHub issue number from wish directory name
* Wish directories follow pattern: NNN-slug/
*
* @param wishName Wish directory name (e.g., "395-task-naming-taxonomy")
* @returns Issue number or undefined
*/
function extractIssueFromWish(wishName) {
const match = wishName.match(/^(\d+)-/);
return match ? parseInt(match[1], 10) : undefined;
}