sigmap 8.31.0 → 8.32.1

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.
@@ -1,5 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ const { capWithNotice } = require('../util/truncate');
4
+
5
+ // Ceiling sits above the default `maxSigsPerFile` so the configured budget
6
+ // governs output rather than a literal buried here, and omissions are disclosed (#576).
7
+ const PER_FILE_LIMIT = 25;
8
+
3
9
  /**
4
10
  * Extract signatures from Ruby source code.
5
11
  * @param {string} src - Raw file content
@@ -34,7 +40,7 @@ function extract(src) {
34
40
  sigs.push(`def ${m[1]}${params}${retStr}`);
35
41
  }
36
42
 
37
- return sigs.slice(0, 25);
43
+ return capWithNotice(sigs, PER_FILE_LIMIT, 'signatures');
38
44
  }
39
45
 
40
46
  function normalizeParams(params) {
@@ -1,6 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  const { lineAt, withAnchor } = require('./line-anchor');
4
+ const { capWithNotice } = require('../util/truncate');
5
+
6
+ // Ceiling sits above the default `maxSigsPerFile` so the configured budget
7
+ // governs output rather than a literal buried here, and omissions are disclosed (#576).
8
+ const PER_FILE_LIMIT = 25;
4
9
 
5
10
  /**
6
11
  * Extract signatures from Rust source code.
@@ -70,7 +75,7 @@ function extract(src) {
70
75
  sigs.push(hinted(withAnchor(`pub ${asyncKw}fn ${m[1]}(${normalizeParams(m[2])})${retStr}`, s, e), m[1]));
71
76
  }
72
77
 
73
- return sigs.slice(0, 25);
78
+ return capWithNotice(sigs, PER_FILE_LIMIT, 'signatures');
74
79
  }
75
80
 
76
81
  function extractBlock(src, startIndex) {
@@ -1,6 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const { lineAt, withAnchor } = require('./line-anchor');
4
+ const { capWithNotice, capMembersWithNotice } = require('../util/truncate');
5
+
6
+ // Ceilings sit above the default `maxSigsPerFile` so the configured budget
7
+ // governs output rather than a literal buried here, and omissions are disclosed
8
+ // — an undisclosed cap looks like a class that simply has eight methods (#576).
9
+ const MEMBER_LIMIT = 8;
10
+ const PER_FILE_LIMIT = 25;
4
11
 
5
12
  /**
6
13
  * Extract signatures from Scala source code.
@@ -27,7 +34,8 @@ function extract(src) {
27
34
  const block = extractBlock(stripped, bodyStart);
28
35
  sigs.push(withAnchor(`${kind} ${m[1]}`, lineAt(stripped, m.index), lineAt(stripped, bodyStart + block.length)));
29
36
  for (const fn of extractMembers(block)) {
30
- sigs.push(withAnchor(` ${fn.text}`, lineAt(stripped, bodyStart + fn.declIdx), lineAt(stripped, bodyStart + fn.endIdx)));
37
+ // The disclosure marker carries no offsets; anchor it at the class body.
38
+ sigs.push(withAnchor(` ${fn.text}`, lineAt(stripped, bodyStart + (fn.declIdx || 0)), lineAt(stripped, bodyStart + (fn.endIdx || 0))));
31
39
  }
32
40
  }
33
41
 
@@ -41,7 +49,7 @@ function extract(src) {
41
49
  sigs.push(withAnchor(`def ${m[1]}${params}${retStr}`, line, line));
42
50
  }
43
51
 
44
- return sigs.slice(0, 25);
52
+ return capWithNotice(sigs, PER_FILE_LIMIT, 'signatures');
45
53
  }
46
54
 
47
55
  function extractBlock(src, startIndex) {
@@ -68,7 +76,7 @@ function extractMembers(block) {
68
76
  endIdx: m.index + m[0].length,
69
77
  });
70
78
  }
71
- return members.slice(0, 8);
79
+ return capMembersWithNotice(members, MEMBER_LIMIT);
72
80
  }
73
81
 
74
82
  function normalizeParams(params) {
@@ -1,5 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ const { capWithNotice } = require('../util/truncate');
4
+
5
+ // Ceiling sits above the default `maxSigsPerFile` so the configured budget
6
+ // governs output rather than a literal buried here, and omissions are disclosed (#576).
7
+ const PER_FILE_LIMIT = 25;
8
+
3
9
  /**
4
10
  * Extract signatures from shell scripts (bash, zsh, fish).
5
11
  * @param {string} src - Raw file content
@@ -37,7 +43,7 @@ function extract(src) {
37
43
  }
38
44
  }
39
45
 
40
- return sigs.slice(0, 25);
46
+ return capWithNotice(sigs, PER_FILE_LIMIT, 'signatures');
41
47
  }
42
48
 
43
49
  module.exports = { extract };
@@ -1,5 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ const { capWithNotice } = require('../util/truncate');
4
+
5
+ // Ceiling sits above the default `maxSigsPerFile` so the configured budget
6
+ // governs output rather than a literal buried here, and omissions are disclosed (#576).
7
+ const PER_FILE_LIMIT = 25;
8
+
3
9
  /**
4
10
  * Extract signatures from Svelte components.
5
11
  * @param {string} src - Raw file content
@@ -42,7 +48,7 @@ function extract(src) {
42
48
  sigs.push(`$: ${m[1]}`);
43
49
  }
44
50
 
45
- return sigs.slice(0, 25);
51
+ return capWithNotice(sigs, PER_FILE_LIMIT, 'signatures');
46
52
  }
47
53
 
48
54
  function normalizeParams(params) {
@@ -1,6 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const { lineAt, withAnchor } = require('./line-anchor');
4
+ const { capWithNotice, capMembersWithNotice } = require('../util/truncate');
5
+
6
+ // Ceilings sit above the default `maxSigsPerFile` so the configured budget
7
+ // governs output rather than a literal buried here, and omissions are disclosed
8
+ // — an undisclosed cap looks like a class that simply has eight methods (#576).
9
+ const MEMBER_LIMIT = 8;
10
+ const PER_FILE_LIMIT = 25;
4
11
 
5
12
  /**
6
13
  * Extract signatures from Swift source code.
@@ -36,7 +43,8 @@ function extract(src) {
36
43
  const block = extractBlock(stripped, bodyStart);
37
44
  sigs.push(withAnchor(`${m[1]} ${m[2]}`, lineAt(stripped, m.index), lineAt(stripped, bodyStart + block.length)));
38
45
  for (const fn of extractMembers(block)) {
39
- sigs.push(withAnchor(` ${fn.text}`, lineAt(stripped, bodyStart + fn.declIdx), lineAt(stripped, bodyStart + fn.endIdx)));
46
+ // The disclosure marker carries no offsets; anchor it at the class body.
47
+ sigs.push(withAnchor(` ${fn.text}`, lineAt(stripped, bodyStart + (fn.declIdx || 0)), lineAt(stripped, bodyStart + (fn.endIdx || 0))));
40
48
  }
41
49
  }
42
50
 
@@ -48,7 +56,7 @@ function extract(src) {
48
56
  sigs.push(withAnchor(`${asyncKw}func ${m[1]}(${normalizeParams(m[2])})${retStr}`, s, e));
49
57
  }
50
58
 
51
- return sigs.slice(0, 25);
59
+ return capWithNotice(sigs, PER_FILE_LIMIT, 'signatures');
52
60
  }
53
61
 
54
62
  function extractBlock(src, startIndex) {
@@ -74,7 +82,7 @@ function extractMembers(block) {
74
82
  endIdx: m.index + m[0].length,
75
83
  });
76
84
  }
77
- return members.slice(0, 8);
85
+ return capMembersWithNotice(members, MEMBER_LIMIT);
78
86
  }
79
87
 
80
88
  function normalizeParams(params) {
@@ -1,5 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ const { capWithNotice } = require('../util/truncate');
4
+
5
+ // Ceiling discloses what it drops rather than truncating silently (#583).
6
+ const PER_FILE_LIMIT = 40;
7
+
3
8
  /**
4
9
  * Extract signatures from TOML configuration files.
5
10
  * Focuses on section/table names and high-value keys.
@@ -36,7 +41,7 @@ function extract(src) {
36
41
  }
37
42
  }
38
43
 
39
- return Array.from(new Set(sigs)).slice(0, 40);
44
+ return capWithNotice(Array.from(new Set(sigs)), PER_FILE_LIMIT, 'entries');
40
45
  }
41
46
 
42
47
  module.exports = { extract };
@@ -1,5 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ const { capWithNotice } = require('../util/truncate');
4
+
5
+ // Ceiling discloses what it drops rather than truncating silently (#583).
6
+ const PER_FILE_LIMIT = 50;
7
+
3
8
  /**
4
9
  * Extract React component signatures from .tsx files.
5
10
  * Captures component props interfaces, hooks usage, and exports.
@@ -54,7 +59,7 @@ function extract(src) {
54
59
  sigs.push(`handler on${h}`);
55
60
  }
56
61
 
57
- return Array.from(new Set(sigs)).slice(0, 50);
62
+ return capWithNotice(Array.from(new Set(sigs)), PER_FILE_LIMIT, 'signatures');
58
63
  }
59
64
 
60
65
  module.exports = { extract };
@@ -1,5 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ const { capWithNotice } = require('../util/truncate');
4
+
5
+ // Ceiling sits above the default `maxSigsPerFile` so the configured budget
6
+ // governs output rather than a literal buried here, and omissions are disclosed (#576).
7
+ const PER_FILE_LIMIT = 25;
8
+
3
9
  /**
4
10
  * Extract signatures from YAML configuration files.
5
11
  * @param {string} src - Raw file content
@@ -53,7 +59,7 @@ function extract(src) {
53
59
  }
54
60
  }
55
61
 
56
- return sigs.slice(0, 25);
62
+ return capWithNotice(sigs, PER_FILE_LIMIT, 'signatures');
57
63
  }
58
64
 
59
65
  module.exports = { extract };
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: '8.31.0',
21
+ version: '8.32.1',
22
22
  description: 'SigMap MCP server — code signatures on demand',
23
23
  };
24
24
 
@@ -1,80 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Extract signatures from Vue single-file components.
5
- * @param {string} src - Raw file content
6
- * @returns {string[]} Array of signature strings
7
- */
8
- function extract(src) {
9
- if (!src || typeof src !== 'string') return [];
10
- const sigs = [];
11
-
12
- // Extract component name from filename hint if present or defineComponent
13
- const nameMatch = src.match(/name\s*:\s*['"](\w+)['"]/);
14
- if (nameMatch) sigs.push(`component ${nameMatch[1]}`);
15
-
16
- // Extract <script> block
17
- const scriptMatch = src.match(/<script(?:\s[^>]*)?>(?:\s*)([\s\S]*?)<\/script>/i);
18
- if (!scriptMatch) return sigs;
19
-
20
- const script = scriptMatch[1]
21
- .replace(/\/\/.*$/gm, '')
22
- .replace(/\/\*[\s\S]*?\*\//g, '');
23
-
24
- // Props
25
- const propsMatch = script.match(/props\s*:\s*(\{[\s\S]*?\})/);
26
- if (propsMatch) {
27
- const propNames = [];
28
- for (const m of propsMatch[1].matchAll(/^\s+(\w+)\s*:/gm)) {
29
- propNames.push(m[1]);
30
- }
31
- if (propNames.length > 0) sigs.push(`props: [${propNames.join(', ')}]`);
32
- }
33
-
34
- // Methods in options API
35
- const methodsMatch = script.match(/methods\s*:\s*\{([\s\S]*?)\},?\s*(?:computed|watch|mounted|created|data|\})/);
36
- if (methodsMatch) {
37
- for (const m of methodsMatch[1].matchAll(/^\s+(?:async\s+)?(\w+)\s*\(([^)]*)\)(?:\s*:\s*([^{=\n]+))?/gm)) {
38
- if (m[1].startsWith('_')) continue;
39
- const asyncKw = m[0].includes('async') ? 'async ' : '';
40
- const retStr = m[3] ? ` → ${normalizeType(m[3])}` : '';
41
- sigs.push(` ${asyncKw}${m[1]}(${normalizeParams(m[2])})${retStr}`);
42
- }
43
- }
44
-
45
- // Top-level functions in <script> (e.g., composition API helpers)
46
- for (const m of script.matchAll(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)\s*\(([^)]*)\)(?:\s*:\s*([^{=\n]+))?/gm)) {
47
- if (m[1].startsWith('_')) continue;
48
- const asyncKw = m[0].includes('async') ? 'async ' : '';
49
- const retStr = m[3] ? ` → ${normalizeType(m[3])}` : '';
50
- sigs.push(`${asyncKw}function ${m[1]}(${normalizeParams(m[2])})${retStr}`);
51
- }
52
-
53
- // defineProps (Composition API)
54
- const definePropsMatch = script.match(/defineProps(?:<[^>]*>)?\s*\(\s*(\{[\s\S]*?\})\s*\)/);
55
- if (definePropsMatch) {
56
- const propNames = [];
57
- for (const m of definePropsMatch[1].matchAll(/^\s+(\w+)\s*:/gm)) {
58
- propNames.push(m[1]);
59
- }
60
- if (propNames.length > 0) sigs.push(`defineProps: [${propNames.join(', ')}]`);
61
- }
62
-
63
- // Emits
64
- const emitsMatch = script.match(/(?:defineEmits|emits)\s*(?::\s*|\(\s*)(\[[\s\S]*?\])/);
65
- if (emitsMatch) sigs.push(`emits: ${emitsMatch[1].replace(/\s+/g, ' ')}`);
66
-
67
- return sigs.slice(0, 25);
68
- }
69
-
70
- function normalizeParams(params) {
71
- if (!params) return '';
72
- return params.trim().replace(/\s+/g, ' ');
73
- }
74
-
75
- function normalizeType(type) {
76
- if (!type) return '';
77
- return type.trim().replace(/[;\s]+$/g, '').replace(/\s+/g, ' ').slice(0, 25);
78
- }
79
-
80
- module.exports = { extract };