Files
fusion/packages/core/src/task-prefix.ts
gsxdsm aae76cecc3 Address PR review feedback (#1741)
- Close first TaskStore before creating second in interactive registration (P1)
- Revert defaultWorkflowId default to undefined; set explicitly in onboarding only (P1)
- Add alpha-only filter + 2-char min to interactive prefix input (P2)
- Move suggestTaskPrefix to @fusion/core, share between CLI and dashboard (P2)
- Fix suggestTaskPrefix JSDoc to match implementation (P2)
2026-06-24 10:45:21 -07:00

18 lines
849 B
TypeScript

/**
* FNXC:TaskPrefix 2026-06-24-18:00:
* Derive a task prefix from a project name. Strips non-alpha characters, uppercases,
* and takes the first 2-4 characters. Falls back to "FN" for names with fewer than
* 2 letters. Used during project onboarding (CLI and dashboard) so each project gets
* a recognizable prefix for task IDs (e.g. "MYPR" for "my-project").
*
* Note: the result is the first 2-4 letters of the cleaned (alpha-only, uppercased)
* name, NOT the initials of each word. For "my-project" the result is "MYPR"
* (first 4 of "MYPROJECT"), not "MP".
*/
export function suggestTaskPrefix(projectName: string): string {
const cleaned = projectName.replace(/[^a-zA-Z]/g, "").toUpperCase();
if (cleaned.length >= 2 && cleaned.length <= 4) return cleaned;
if (cleaned.length > 4) return cleaned.slice(0, 4);
return "FN";
}