fix(instincts): align alias boundaries and disambiguate Go prose

This commit is contained in:
Afloat committed 2026-11-17 14:04:52 +08:00
1 parent 89a8bbc205
commit 4ffff8d4c7
2 files changed
+19 -7

No files matched your search

+9 -7
View File
@@ -113,10 +113,10 @@ function detectStackKeywords(projectRoot, projectInfo) {
function tokenize(value) {
return String(value || '')
.toLowerCase()
.replace(/\bc#(?![a-z0-9#])/g, 'csharp')
.replace(/\bf#(?![a-z0-9#])/g, 'fsharp')
.replace(/\bnext\.js\b/g, 'nextjs')
.replace(/\bnest\.js\b/g, 'nestjs')
.replace(/(^|[^a-z0-9])c#(?![a-z0-9#])/g, '$1csharp')
.replace(/(^|[^a-z0-9])f#(?![a-z0-9#])/g, '$1fsharp')
.replace(/(^|[^a-z0-9])next\.js(?![a-z0-9])/g, '$1nextjs')
.replace(/(^|[^a-z0-9])nest\.js(?![a-z0-9])/g, '$1nestjs')
.split(/[^a-z0-9]+/)
.filter(Boolean);
}
@@ -130,13 +130,15 @@ function tokenize(value) {
*/
function instinctMatchesStack(instinct, stackKeywords) {
if (!instinct || !stackKeywords || stackKeywords.size === 0) return false;
const tokens = new Set([
const explicitTokens = new Set([
...tokenize(instinct.domain),
...tokenize(instinct.trigger),
...tokenize(instinct.stack),
]);
const tokens = new Set([...explicitTokens, ...tokenize(instinct.trigger)]);
// In prose, the capitalized language name distinguishes Go from the verb.
const hasGoAlias = explicitTokens.has('go') || /(^|[^a-zA-Z0-9])Go(?![a-zA-Z0-9])/.test(String(instinct.trigger || ''));
for (const keyword of stackKeywords) {
if (tokens.has(keyword) || (keyword === 'golang' && tokens.has('go'))) return true;
if (tokens.has(keyword) || (keyword === 'golang' && hasGoAlias)) return true;
}
return false;
}