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 { ...@@ -40,7 +40,8 @@ export class RuleIndexer {
const isGlobalRule = r.rule.tags.includes('global') || const isGlobalRule = r.rule.tags.includes('global') ||
r.rule.tags.includes('base') || r.rule.tags.includes('base') ||
r.rule.id.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) { if (isGlobalRule) {
globalResults.push(r); globalResults.push(r);
} }
......
...@@ -139,9 +139,12 @@ export class Scorer { ...@@ -139,9 +139,12 @@ export class Scorer {
(0.12 * sTag) + (0.12 * sTag) +
(0.08 * sPriority); (0.08 * sPriority);
const finalScore = Math.max(0, weightedScore + boost - penalty); 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 { return {
rule, rule,
score: finalScore, score: adjustedScore,
scoreBreakdown: { scoreBreakdown: {
text: sText, text: sText,
path: sPath, path: sPath,
......
...@@ -62,7 +62,8 @@ export class RuleIndexer { ...@@ -62,7 +62,8 @@ export class RuleIndexer {
const isGlobalRule = r.rule.tags.includes('global') || const isGlobalRule = r.rule.tags.includes('global') ||
r.rule.tags.includes('base') || r.rule.tags.includes('base') ||
r.rule.id.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) { if (isGlobalRule) {
globalResults.push(r); globalResults.push(r);
......
...@@ -177,9 +177,13 @@ export class Scorer { ...@@ -177,9 +177,13 @@ export class Scorer {
const finalScore = Math.max(0, weightedScore + boost - penalty); 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 { return {
rule, rule,
score: finalScore, score: adjustedScore,
scoreBreakdown: { scoreBreakdown: {
text: sText, text: sText,
path: sPath, 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