refactor(agents): share leadership role detector, use word-boundary match
P2-23: 'lead' in system-prompt.ts matched 'cleaner' / 'leaderboard' via substring .includes(). Hoist LEADERSHIP_ROLE_KEYWORDS into a shared agent-role-helpers.ts module; tokenize input on non-alphanum to require whole-word match. P3-54: Same keyword list was duplicated in automation-skills with drift (missing 'ceo', different members). Both sites now call through the shared helper.
This commit is contained in:
1 parent
ba6ba8360b
commit
2df921ca88
6 files changed
+89
-34
No files matched your search
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Role-classification helpers used across prompt construction and skill
|
||||
* auto-assignment. Keeping a single keyword list here prevents drift
|
||||
* between system-prompt.ts and automation-skills.ts.
|
||||
*
|
||||
* Matching uses word-boundary tokenization instead of substring search,
|
||||
* so "lead" does not match "cleaner" or "leaderboard".
|
||||
*/
|
||||
|
||||
export const LEADERSHIP_ROLE_KEYWORDS = [
|
||||
"chief",
|
||||
"cto",
|
||||
"cmo",
|
||||
"coo",
|
||||
"cfo",
|
||||
"ceo",
|
||||
"vp",
|
||||
"vice",
|
||||
"president",
|
||||
"head",
|
||||
"director",
|
||||
"manager",
|
||||
"lead",
|
||||
] as const;
|
||||
|
||||
function tokenize(text: string): string[] {
|
||||
return text.toLowerCase().match(/[a-z0-9]+/g) ?? [];
|
||||
}
|
||||
|
||||
export function roleMatchesLeadershipKeywords(role: string, title?: string | null): boolean {
|
||||
const tokens = new Set(tokenize(`${role} ${title ?? ""}`));
|
||||
return LEADERSHIP_ROLE_KEYWORDS.some((keyword) => tokens.has(keyword));
|
||||
}
|
||||
Reference in new issue
Block a user