Commit 5bb65263 authored by LongLD's avatar LongLD

feat: enhance global rule identification and scoring adjustments

parent 63883452
......@@ -40,7 +40,8 @@ export class RuleIndexer {
const isGlobalRule = r.rule.tags.includes('global') ||
r.rule.tags.includes('base') ||
r.rule.id.includes('base') ||
r.rule.relativePath === 'base.md';
r.rule.relativePath === 'base.md' ||
r.rule.path.endsWith('base.md');
if (isGlobalRule) {
globalResults.push(r);
}
......
......@@ -139,9 +139,12 @@ export class Scorer {
(0.12 * sTag) +
(0.08 * sPriority);
const finalScore = Math.max(0, weightedScore + boost - penalty);
// Ensure global rules have minimum score to always appear
const isGlobalRule = rule.tags.includes('global') || rule.tags.includes('base') || rule.id.includes('base') || rule.path.endsWith('base.md');
const adjustedScore = isGlobalRule ? Math.max(finalScore, 0.08) : finalScore;
return {
rule,
score: finalScore,
score: adjustedScore,
scoreBreakdown: {
text: sText,
path: sPath,
......
......@@ -62,7 +62,8 @@ export class RuleIndexer {
const isGlobalRule = r.rule.tags.includes('global') ||
r.rule.tags.includes('base') ||
r.rule.id.includes('base') ||
r.rule.relativePath === 'base.md';
r.rule.relativePath === 'base.md' ||
r.rule.path.endsWith('base.md');
if (isGlobalRule) {
globalResults.push(r);
......
......@@ -177,9 +177,13 @@ export class Scorer {
const finalScore = Math.max(0, weightedScore + boost - penalty);
// Ensure global rules have minimum score to always appear
const isGlobalRule = rule.tags.includes('global') || rule.tags.includes('base') || rule.id.includes('base') || rule.path.endsWith('base.md');
const adjustedScore = isGlobalRule ? Math.max(finalScore, 0.08) : finalScore;
return {
rule,
score: finalScore,
score: adjustedScore,
scoreBreakdown: {
text: sText,
path: sPath,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment