sigmap 5.1.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/mcp/server.js CHANGED
@@ -18,7 +18,7 @@ const { readContext, searchSignatures, getMap, createCheckpoint, getRouting, exp
18
18
 
19
19
  const SERVER_INFO = {
20
20
  name: 'sigmap',
21
- version: '5.1.0',
21
+ version: '5.3.0',
22
22
  description: 'SigMap MCP server — code signatures on demand',
23
23
  };
24
24
 
@@ -17,6 +17,7 @@
17
17
  * // results: [{ file, score, sigs, tokens }]
18
18
  */
19
19
 
20
+ const { loadWeights } = require('../learning/weights');
20
21
  const { tokenize, STOP_WORDS } = require('./tokenizer');
21
22
 
22
23
  // ---------------------------------------------------------------------------
@@ -97,6 +98,7 @@ function scoreFile(filePath, sigs, queryTokens, weights) {
97
98
  * @param {number} [opts.recencyBoost=1.5] - multiplier for recent files
98
99
  * @param {Set<string>} [opts.recencySet] - set of recently-changed file paths
99
100
  * @param {object} [opts.weights] - override scoring weights
101
+ * @param {string} [opts.cwd] - project root for learned ranking weights
100
102
  * @returns {{ file: string, score: number, sigs: string[], tokens: number }[]}
101
103
  */
102
104
  function rank(query, sigIndex, opts) {
@@ -107,6 +109,7 @@ function rank(query, sigIndex, opts) {
107
109
  const recencyMultiplier = (opts && opts.recencyBoost) || DEFAULT_WEIGHTS.recencyBoost;
108
110
  const recencySet = (opts && opts.recencySet) || null;
109
111
  const weights = (opts && opts.weights) ? Object.assign({}, DEFAULT_WEIGHTS, opts.weights) : DEFAULT_WEIGHTS;
112
+ const learnedWeights = opts && opts.cwd ? loadWeights(opts.cwd) : null;
110
113
 
111
114
  const queryTokens = tokenize(query);
112
115
  if (queryTokens.length === 0) {
@@ -128,6 +131,10 @@ function rank(query, sigIndex, opts) {
128
131
  score *= recencyMultiplier;
129
132
  }
130
133
 
134
+ if (learnedWeights && score > 0) {
135
+ score *= learnedWeights[file] || 1.0;
136
+ }
137
+
131
138
  scored.push({
132
139
  file,
133
140
  score,