@ngockhoale/ukit 3.5.4 → 3.5.6

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/manifests/engineConformance.yaml +0 -13
  3. package/manifests/platform.full.yaml +25 -0
  4. package/package.json +3 -9
  5. package/src/cli/commands/indexTools.js +1 -0
  6. package/src/cli/commands/memory.js +44 -4
  7. package/src/core/applyPlan.js +25 -72
  8. package/src/core/diffPlan.js +38 -9
  9. package/src/core/managedTemplateMerge.js +146 -0
  10. package/src/core/memory/memoryCheckRun.js +13 -1
  11. package/src/core/memory/memoryFlags.js +5 -6
  12. package/src/core/memory/memoryHit.js +31 -15
  13. package/src/core/memory/policy.js +5 -0
  14. package/src/core/memory/recallEngine.js +39 -3
  15. package/src/core/memory/recallLanes.js +182 -0
  16. package/src/core/memory/retrieval.js +13 -1
  17. package/src/core/memory/store.js +17 -0
  18. package/src/core/memory/topicCommand.js +75 -0
  19. package/src/core/memory/topicPages.js +545 -0
  20. package/src/core/metadata.js +12 -8
  21. package/src/core/runInstallPipeline.js +16 -10
  22. package/src/core/runtimeConfig.js +59 -83
  23. package/src/core/uninstall.js +8 -1
  24. package/src/decision/registry.js +33 -16
  25. package/src/decision/runtimeDecide.js +5 -5
  26. package/src/index/buildIndex.js +287 -6
  27. package/src/index/languageTools.js +100 -0
  28. package/src/index/paths.js +2 -1
  29. package/src/index/queryIndex.js +174 -10
  30. package/src/index/routeResolver.js +2 -2
  31. package/src/index/semanticLane.js +269 -0
  32. package/src/learning/lessonClass.js +110 -0
  33. package/src/learning/patternProposals.js +111 -7
  34. package/src/learning/reeditMiner.js +104 -0
  35. package/src/learning/selfImprove.js +9 -1
  36. package/template_project/.claude/skills/canvas-design/SKILL.md +2 -2
  37. package/template_project/.claude/skills/canvas-design/canvas-fonts/{InstrumentSans-OFL.txt → InstrumentSerif-OFL.txt} +3 -3
  38. package/template_project/.claude/skills/canvas-design/scripts/fetch-fonts.mjs +148 -0
  39. package/template_project/.claude/ukit/index/embed-index.mjs +26 -0
  40. package/template_project/.claude/ukit/index/lib/index-core.mjs +561 -14
  41. package/template_project/.claude/ukit/index/lib/semantic-lane.mjs +269 -0
  42. package/template_project/.claude/ukit/index/query-index.mjs +9 -1
  43. package/template_project/.claude/ukit/index/refresh-index.mjs +11 -0
  44. package/template_project/.claude/ukit/index/route-resolver.mjs +2 -2
  45. package/template_project/.claude/ukit/runtime/memory-lanes.mjs +9 -2
  46. package/template_project/.claude/ukit/runtime/memory-policy.mjs +5 -0
  47. package/template_project/.claude/ukit/runtime/memory-recall.mjs +39 -3
  48. package/template_project/.claude/ukit/runtime/memory-topics.mjs +545 -0
  49. package/template_project/ukit/storage/config.json +19 -34
  50. package/manifests/instructionRules.yaml +0 -442
  51. package/template_project/.claude/skills/canvas-design/canvas-fonts/BricolageGrotesque-Bold.ttf +0 -0
  52. package/template_project/.claude/skills/canvas-design/canvas-fonts/BricolageGrotesque-OFL.txt +0 -93
  53. package/template_project/.claude/skills/canvas-design/canvas-fonts/BricolageGrotesque-Regular.ttf +0 -0
  54. package/template_project/.claude/skills/canvas-design/canvas-fonts/InstrumentSans-Bold.ttf +0 -0
  55. package/template_project/.claude/skills/canvas-design/canvas-fonts/InstrumentSans-BoldItalic.ttf +0 -0
  56. package/template_project/.claude/skills/canvas-design/canvas-fonts/InstrumentSans-Italic.ttf +0 -0
  57. package/template_project/.claude/skills/canvas-design/canvas-fonts/InstrumentSans-Regular.ttf +0 -0
  58. package/template_project/.claude/skills/canvas-design/canvas-fonts/InstrumentSerif-Italic.ttf +0 -0
  59. package/template_project/.claude/skills/canvas-design/canvas-fonts/JetBrainsMono-Bold.ttf +0 -0
  60. package/template_project/.claude/skills/canvas-design/canvas-fonts/Lora-Bold.ttf +0 -0
  61. package/template_project/.claude/skills/canvas-design/canvas-fonts/Lora-BoldItalic.ttf +0 -0
  62. package/template_project/.claude/skills/canvas-design/canvas-fonts/Lora-Italic.ttf +0 -0
  63. package/template_project/.claude/skills/canvas-design/canvas-fonts/Lora-OFL.txt +0 -93
  64. package/template_project/.claude/skills/canvas-design/canvas-fonts/Lora-Regular.ttf +0 -0
  65. package/template_project/.claude/skills/canvas-design/canvas-fonts/Outfit-Bold.ttf +0 -0
  66. package/template_project/.claude/skills/canvas-design/canvas-fonts/Tektur-Medium.ttf +0 -0
  67. package/template_project/.claude/skills/canvas-design/canvas-fonts/YoungSerif-OFL.txt +0 -93
  68. package/template_project/.claude/skills/canvas-design/canvas-fonts/YoungSerif-Regular.ttf +0 -0
@@ -150,11 +150,11 @@ const EXCLUDED_DIR_NAMES = new Set([
150
150
  '.venv',
151
151
  'venv',
152
152
  ]);
153
- const CODE_EXTENSIONS = new Set(['.js', '.mjs', '.cjs', '.ts', '.tsx', '.jsx', '.vue', '.sql']);
153
+ const CODE_EXTENSIONS = new Set(['.js', '.mjs', '.cjs', '.ts', '.tsx', '.jsx', '.vue', '.svelte', '.py', '.go', '.java', '.cs', '.php', '.rb', '.rs', '.sql']);
154
154
  const STYLE_EXTENSIONS = new Set(['.css', '.scss', '.sass', '.less']);
155
155
  // `.sh` is tracked but never parsed, like `.md`/`.json`/`.yaml` — it is matched
156
156
  // by path only. Without it every shipped hook script was invisible to the index.
157
- const TRACKED_EXTENSIONS = new Set(['.js', '.mjs', '.cjs', '.ts', '.tsx', '.jsx', '.vue', '.sql', '.json', '.yaml', '.yml', '.md', '.sh']);
157
+ const TRACKED_EXTENSIONS = new Set(['.js', '.mjs', '.cjs', '.ts', '.tsx', '.jsx', '.vue', '.svelte', '.py', '.go', '.java', '.cs', '.php', '.rb', '.rs', '.sql', '.json', '.yaml', '.yml', '.md', '.sh']);
158
158
  const DISCOVERED_EXTENSIONS = new Set([...TRACKED_EXTENSIONS, ...STYLE_EXTENSIONS]);
159
159
  export const DEFAULT_INDEX_CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1000;
160
160
  // Bumped only when the snapshot shape itself changes; consumers must reject
@@ -1586,7 +1586,7 @@ function findScriptClose(content, startIndex) {
1586
1586
  }
1587
1587
 
1588
1588
  export function extractScriptContent(filePath, content) {
1589
- if (!filePath.endsWith('.vue')) {
1589
+ if (!/\.(?:vue|svelte)$/.test(filePath)) {
1590
1590
  return content;
1591
1591
  }
1592
1592
 
@@ -1682,6 +1682,278 @@ function computeSignature(content, lineStartIndex) {
1682
1682
  return `${collapsed.slice(0, 199)}…`;
1683
1683
  }
1684
1684
 
1685
+ // ── Non-JS languages (3.5.5): line/indent/brace based, no parser. Rows are { name, type, index, parent? }.
1686
+ // Kinds follow the JS lane: exported/public top-level -> function|class, private -> local-*, members -> method,
1687
+ // interface/enum/struct/trait/type aliases -> type.
1688
+ const POLYGLOT_EXT = /\.(?:py|go|java|cs|php|rb|rs)$/i;
1689
+ const POLY_MEMBER_SKIP = new Set(['if', 'for', 'while', 'switch', 'catch', 'return', 'new', 'else', 'throw', 'using', 'lock', 'foreach', 'fixed', 'match', 'await', 'yield', 'do', 'try', 'sizeof', 'typeof', 'nameof', 'default', 'when', 'base', 'this']);
1690
+ const POLY_MODS = '(?:(?:public|protected|private|internal|static|final|abstract|sealed|partial|readonly|virtual|override|async|extern|unsafe|new|synchronized|native|strictfp|default|open)\\s+)*';
1691
+ const POLY_JAVA_TYPE_RE = new RegExp(`^[ \\t]*(?:@\\w+(?:\\([^)]*\\))?\\s+)*${POLY_MODS}(class|interface|enum|struct|record(?:\\s+(?:class|struct))?)\\s+([A-Za-z_]\\w*)`);
1692
+ const POLY_JAVA_METHOD_RE = new RegExp(`^[ \\t]*(?:@\\w+(?:\\([^)]*\\))?\\s+)*(?:<[^>]+>\\s+)?(?:[\\w.<>\\[\\],?]+\\s+)*?([A-Za-z_]\\w*)[ \\t]*(?:<[^>()]*>[ \\t]*)?\\(`);
1693
+ const POLY_PHP_TYPE_RE = /^[ \t]*(?:(?:abstract|final|readonly)\s+)*(class|interface|trait|enum)\s+([A-Za-z_]\w*)/;
1694
+ const POLY_PHP_FUNC_RE = /^[ \t]*(?:(?:public|protected|private|static|abstract|final)\s+)*function[ \t]+(?:&[ \t]*)?([A-Za-z_]\w*)/;
1695
+ const POLY_RS_PUB = '(?:pub(?:\\([^)]*\\))?\\s+)?';
1696
+ const POLY_RS_FN_RE = new RegExp(`^[ \\t]*(${POLY_RS_PUB})(?:(?:default|const|async|unsafe)\\s+)*(?:extern\\s+(?:"[^"]*"\\s+)?)?fn\\s+([A-Za-z_]\\w*)`);
1697
+ const POLY_RS_TYPE_RE = new RegExp(`^[ \\t]*${POLY_RS_PUB}(struct|enum|union|type)\\s+([A-Za-z_]\\w*)`);
1698
+ const POLY_RS_TRAIT_RE = new RegExp(`^[ \\t]*${POLY_RS_PUB}(?:unsafe\\s+)?trait\\s+([A-Za-z_]\\w*)`);
1699
+ // Bounds against pathological input (regex stalls): files above 512 KB (the content-lane per-file cap) are not
1700
+ // extracted, and any line over 2000 chars is blanked in place (offsets preserved) before the per-line patterns run.
1701
+ const POLY_MAX_FILE_CHARS = 512 * 1024;
1702
+ const POLY_MAX_LINE_CHARS = 2000;
1703
+ // impl header -> implemented type name, without a backtracking pattern: skip a balanced <generics>, then the
1704
+ // type after the first `for` (trait impl) or the first identifier (inherent impl).
1705
+ function polyRsImplName(line) {
1706
+ const head = /^[ \t]*(?:unsafe[ \t]+)?impl\b/.exec(line);
1707
+ if (!head) return null;
1708
+ let rest = line.slice(head[0].length).replace(/^[ \t]+/, '');
1709
+ if (rest[0] === '<') {
1710
+ let depth = 0;
1711
+ let k = 0;
1712
+ for (; k < rest.length; k += 1) {
1713
+ if (rest[k] === '<') depth += 1;
1714
+ else if (rest[k] === '>' && (depth -= 1) === 0) break;
1715
+ }
1716
+ rest = rest.slice(k + 1);
1717
+ }
1718
+ const cut = rest.search(/[{]|[ \t]where\b/);
1719
+ const header = cut < 0 ? rest : rest.slice(0, cut);
1720
+ const forAt = header.search(/(?:^|[ \t])for[ \t]/);
1721
+ const target = forAt < 0 ? header : header.slice(forAt).replace(/^[ \t]*for[ \t]+/, '');
1722
+ return /^[ \t]*([A-Za-z_]\w*)/.exec(target)?.[1] ?? null;
1723
+ }
1724
+ const POLY_RS_MOD_RE = new RegExp(`^[ \\t]*${POLY_RS_PUB}mod\\s+([A-Za-z_]\\w*)`);
1725
+
1726
+ // Same-length copy with comments (and, per mode, string bodies) blanked, so offsets/lines stay valid.
1727
+ // mode 0 = comments only, 1 = + "strings", 2 = + "strings" and 'chars'.
1728
+ function maskCLike(content, mode) {
1729
+ const out = content.split('');
1730
+ const n = content.length;
1731
+ const blank = (from, to) => {
1732
+ for (let k = from; k < to; k += 1) {
1733
+ if (out[k] !== '\n') out[k] = ' ';
1734
+ }
1735
+ };
1736
+ let i = 0;
1737
+ while (i < n) {
1738
+ const c = content[i];
1739
+ const d = content[i + 1];
1740
+ if (c === '/' && d === '/') {
1741
+ let end = content.indexOf('\n', i);
1742
+ if (end < 0) end = n;
1743
+ blank(i, end);
1744
+ i = end;
1745
+ } else if (c === '/' && d === '*') {
1746
+ let end = content.indexOf('*/', i + 2);
1747
+ end = end < 0 ? n : end + 2;
1748
+ blank(i, end);
1749
+ i = end;
1750
+ } else if ((mode >= 1 && c === '"') || (mode >= 2 && c === "'")) {
1751
+ let k = i + 1;
1752
+ while (k < n && content[k] !== c && content[k] !== '\n') {
1753
+ if (content[k] === '\\') k += 1;
1754
+ k += 1;
1755
+ }
1756
+ blank(i + 1, Math.min(k, n));
1757
+ i = k + 1;
1758
+ } else {
1759
+ i += 1;
1760
+ }
1761
+ }
1762
+ return out.join('');
1763
+ }
1764
+
1765
+ function extractIndentLanguageSymbols(filePath, content) {
1766
+ const isPy = /\.py$/i.test(filePath);
1767
+ const scopeRe = isPy ? /^([ \t]*)class[ \t]+([A-Za-z_]\w*)/ : /^([ \t]*)(?:module|class)[ \t]+([A-Z][\w:]*)/;
1768
+ const defRe = isPy ? /^([ \t]*)(?:async[ \t]+)?def[ \t]+([A-Za-z_]\w*)/ : /^([ \t]*)def[ \t]+(?:[A-Za-z_]\w*\.)?([A-Za-z_]\w*[?!=]?)/;
1769
+ const rows = [];
1770
+ const stack = [];
1771
+ let docQuote = null;
1772
+ let offset = 0;
1773
+ for (const line of content.split('\n')) {
1774
+ const lineStart = offset;
1775
+ offset += line.length + 1;
1776
+ const startedInDoc = docQuote !== null;
1777
+ if (isPy) {
1778
+ for (const quote of ['"""', "'''"]) {
1779
+ const count = line.split(quote).length - 1;
1780
+ if (count % 2 === 1) docQuote = docQuote === quote ? null : (docQuote ?? quote);
1781
+ }
1782
+ if (startedInDoc) continue;
1783
+ }
1784
+ const scope = scopeRe.exec(line);
1785
+ const def = scope ? null : defRe.exec(line);
1786
+ const m = scope ?? def;
1787
+ if (!m) continue;
1788
+ const indent = m[1].length;
1789
+ while (stack.length > 0 && stack[stack.length - 1].indent >= indent) stack.pop();
1790
+ const top = stack[stack.length - 1];
1791
+ const name = m[2];
1792
+ const index = lineStart + indent;
1793
+ if (scope) {
1794
+ if (!top || top.kind === 'scope') {
1795
+ rows.push({ name, type: isPy && name.startsWith('_') ? 'local-class' : 'class', index, parent: top?.name });
1796
+ }
1797
+ stack.push({ indent, kind: 'scope', name });
1798
+ } else {
1799
+ if (!top) {
1800
+ rows.push({ name, type: isPy && name.startsWith('_') ? 'local-function' : 'function', index });
1801
+ } else if (top.kind === 'scope') {
1802
+ rows.push({ name, type: 'method', index, parent: top.name });
1803
+ }
1804
+ stack.push({ indent, kind: 'def', name });
1805
+ }
1806
+ }
1807
+ return rows;
1808
+ }
1809
+
1810
+ function extractGoSymbols(content) {
1811
+ const text = maskCLike(content, 0);
1812
+ const rows = [];
1813
+ for (const m of text.matchAll(/^type[ \t]+([A-Za-z_]\w*)/gm)) {
1814
+ rows.push({ name: m[1], type: 'type', index: m.index });
1815
+ }
1816
+ for (const m of text.matchAll(/^func[ \t]+([A-Za-z_]\w*)[ \t]*[[(]/gm)) {
1817
+ rows.push({ name: m[1], type: /^[A-Z]/.test(m[1]) ? 'function' : 'local-function', index: m.index });
1818
+ }
1819
+ for (const m of text.matchAll(/^func[ \t]*\([ \t]*(?:[A-Za-z_]\w*[ \t]+)?(?:\*[ \t]*)?([A-Za-z_]\w*)(?:\[[^\]\n]*\])?[ \t]*\)[ \t]*([A-Za-z_]\w*)/gm)) {
1820
+ rows.push({ name: m[2], type: 'method', index: m.index, parent: m[1] });
1821
+ }
1822
+ return rows;
1823
+ }
1824
+
1825
+ // Java, C#, PHP and Rust: depth-tracked on a comment/string-masked copy. A container
1826
+ // (class, trait, impl, mod ...) owns the lines exactly one brace level below its declaration.
1827
+ function extractBraceLanguageSymbols(filePath, content) {
1828
+ const ext = filePath.slice(filePath.lastIndexOf('.') + 1).toLowerCase();
1829
+ const text = maskCLike(content, ext === 'rs' ? 1 : 2);
1830
+ const rows = [];
1831
+ const stack = [];
1832
+ let depth = 0;
1833
+ let offset = 0;
1834
+ for (const line of text.split('\n')) {
1835
+ const lineStart = offset;
1836
+ offset += line.length + 1;
1837
+ while (stack.length > 0 && stack[stack.length - 1].opened && depth <= stack[stack.length - 1].depth) stack.pop();
1838
+ const top = stack[stack.length - 1];
1839
+ const atMember = top ? depth === top.depth + 1 : false;
1840
+ const index = lineStart + Math.max(0, line.search(/\S/));
1841
+ const pushContainer = (kind, name) => {
1842
+ if (line.includes(';') && !line.includes('{')) return;
1843
+ stack.push({ kind, name, depth, opened: false });
1844
+ };
1845
+
1846
+ if (ext === 'java' || ext === 'cs') {
1847
+ const typeMatch = POLY_JAVA_TYPE_RE.exec(line);
1848
+ if (typeMatch) {
1849
+ const kind = typeMatch[1].split(/\s/)[0];
1850
+ rows.push({ name: typeMatch[2], type: kind === 'class' ? 'class' : 'type', index, parent: top?.name });
1851
+ pushContainer(kind, typeMatch[2]);
1852
+ } else if (atMember) {
1853
+ const m = POLY_JAVA_METHOD_RE.exec(line);
1854
+ if (m && !POLY_MEMBER_SKIP.has(m[1]) && !(top.kind === 'enum' && /^[A-Z0-9_]+$/.test(m[1]))) {
1855
+ rows.push({ name: m[1], type: 'method', index, parent: top.name });
1856
+ }
1857
+ }
1858
+ } else if (ext === 'php') {
1859
+ const typeMatch = POLY_PHP_TYPE_RE.exec(line);
1860
+ const fn = typeMatch ? null : POLY_PHP_FUNC_RE.exec(line);
1861
+ if (typeMatch) {
1862
+ rows.push({ name: typeMatch[2], type: typeMatch[1] === 'class' ? 'class' : 'type', index, parent: top?.name });
1863
+ pushContainer(typeMatch[1], typeMatch[2]);
1864
+ } else if (fn && !top) {
1865
+ rows.push({ name: fn[1], type: 'function', index });
1866
+ } else if (fn && atMember) {
1867
+ rows.push({ name: fn[1], type: 'method', index, parent: top.name });
1868
+ }
1869
+ } else {
1870
+ const fn = POLY_RS_FN_RE.exec(line);
1871
+ const trait = fn ? null : POLY_RS_TRAIT_RE.exec(line);
1872
+ const impl = fn || trait ? null : polyRsImplName(line);
1873
+ const mod = fn || trait || impl ? null : POLY_RS_MOD_RE.exec(line);
1874
+ const typeMatch = fn || trait || impl || mod ? null : POLY_RS_TYPE_RE.exec(line);
1875
+ const atModuleLevel = top ? top.kind === 'mod' && atMember : depth === 0;
1876
+ if (fn) {
1877
+ const container = top && (top.kind === 'impl' || top.kind === 'trait');
1878
+ if (container && atMember) {
1879
+ rows.push({ name: fn[2], type: 'method', index, parent: top.name });
1880
+ } else if (atModuleLevel) {
1881
+ rows.push({ name: fn[2], type: fn[1].trim() ? 'function' : 'local-function', index });
1882
+ }
1883
+ } else if (trait) {
1884
+ if (atModuleLevel) rows.push({ name: trait[1], type: 'type', index });
1885
+ pushContainer('trait', trait[1]);
1886
+ } else if (impl) {
1887
+ pushContainer('impl', impl);
1888
+ } else if (mod) {
1889
+ pushContainer('mod', mod[1]);
1890
+ } else if (typeMatch && atModuleLevel) {
1891
+ rows.push({ name: typeMatch[2], type: 'type', index });
1892
+ }
1893
+ }
1894
+
1895
+ let maxDepth = depth;
1896
+ for (let k = 0; k < line.length; k += 1) {
1897
+ if (line[k] === '{') {
1898
+ depth += 1;
1899
+ if (depth > maxDepth) maxDepth = depth;
1900
+ } else if (line[k] === '}' && depth > 0) {
1901
+ depth -= 1;
1902
+ }
1903
+ }
1904
+ for (const entry of stack) {
1905
+ if (!entry.opened && maxDepth > entry.depth) entry.opened = true;
1906
+ }
1907
+ }
1908
+ return rows;
1909
+ }
1910
+
1911
+ function extractPolyglotSymbols(filePath, rawContent) {
1912
+ if (rawContent.length > POLY_MAX_FILE_CHARS) return [];
1913
+ const parts = rawContent.split('\n');
1914
+ const content = parts.some((l) => l.length > POLY_MAX_LINE_CHARS)
1915
+ ? parts.map((l) => (l.length > POLY_MAX_LINE_CHARS ? ' '.repeat(l.length) : l)).join('\n')
1916
+ : rawContent;
1917
+ const ext = filePath.slice(filePath.lastIndexOf('.') + 1).toLowerCase();
1918
+ let rows;
1919
+ if (ext === 'py' || ext === 'rb') rows = extractIndentLanguageSymbols(filePath, content);
1920
+ else if (ext === 'go') rows = extractGoSymbols(content);
1921
+ else rows = extractBraceLanguageSymbols(filePath, content);
1922
+ const seen = new Set();
1923
+ return rows.filter((row) => {
1924
+ const key = `${row.type}:${row.name}:${row.parent ?? ''}`;
1925
+ if (seen.has(key)) return false;
1926
+ seen.add(key);
1927
+ return true;
1928
+ });
1929
+ }
1930
+
1931
+ // `const x = (` also opens plain parenthesised expressions (`const n = (a ?? 0)`), so only a
1932
+ // parameter list whose closing paren is followed by `=>` (optionally after a return type) is a function.
1933
+ function findParenArrowDeclarations(content) {
1934
+ const found = [];
1935
+ for (const match of content.matchAll(/(?:const|let|var)\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*=\s*(?:async\s*)?\(/g)) {
1936
+ const open = match.index + match[0].length - 1;
1937
+ const limit = Math.min(content.length, open + 2000);
1938
+ let depth = 0;
1939
+ let close = -1;
1940
+ for (let i = open; i < limit; i += 1) {
1941
+ if (content[i] === '(') depth += 1;
1942
+ else if (content[i] === ')') {
1943
+ depth -= 1;
1944
+ if (depth === 0) {
1945
+ close = i;
1946
+ break;
1947
+ }
1948
+ }
1949
+ }
1950
+ if (close >= 0 && /^\s*(?::\s*[^;\n{}=]*?(?:=>\s*[^;\n{}=]*?)?)?=>/.test(content.slice(close + 1, close + 201))) {
1951
+ found.push({ name: match[1], index: match.index });
1952
+ }
1953
+ }
1954
+ return found;
1955
+ }
1956
+
1685
1957
  const CLASS_METHOD_SKIP = new Set(['if', 'for', 'while', 'switch', 'catch', 'function', 'return', 'with', 'constructor', 'super']);
1686
1958
 
1687
1959
  export function extractSymbols(filePath, content) {
@@ -1709,6 +1981,13 @@ export function extractSymbols(filePath, content) {
1709
1981
  }
1710
1982
  };
1711
1983
 
1984
+ if (POLYGLOT_EXT.test(filePath)) {
1985
+ for (const row of extractPolyglotSymbols(filePath, content)) {
1986
+ addSymbol(row.name, row.type, row.index, row.parent ? { parent: row.parent } : null);
1987
+ }
1988
+ return symbols;
1989
+ }
1990
+
1712
1991
  if (filePath.endsWith('.sql')) {
1713
1992
  // Capture the object name, skipping an optional schema qualifier (qas.fn_rpt_billing → fn_rpt_billing).
1714
1993
  const sqlIdent = '(?:(?:["`]?[A-Za-z_][A-Za-z0-9_$]*["`]?)\\s*\\.\\s*)?["`]?([A-Za-z_][A-Za-z0-9_$]*)["`]?';
@@ -1743,8 +2022,10 @@ export function extractSymbols(filePath, content) {
1743
2022
 
1744
2023
  addMatches(/export\s+(?:async\s+)?function\s+([A-Za-z_$][A-Za-z0-9_$]*)/g, 'function');
1745
2024
  addMatches(/export\s+class\s+([A-Za-z_$][A-Za-z0-9_$]*)/g, 'class');
1746
- addMatches(/(?:const|let|var)\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*=\s*(?:async\s*)?\(/g, 'callable');
1747
- addMatches(/(?:const|let|var)\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*=\s*(?:async\s*)?(?:\([^)]*\)|[A-Za-z_$][A-Za-z0-9_$]*)\s*=>/g, 'callable');
2025
+ for (const decl of findParenArrowDeclarations(content)) {
2026
+ addSymbol(decl.name, 'callable', decl.index);
2027
+ }
2028
+ addMatches(/(?:const|let|var)\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*=\s*(?:async\s+)?[A-Za-z_$][A-Za-z0-9_$]*\s*=>/g, 'callable');
1748
2029
  addMatches(/export\s+default\s+(?:async\s+)?function\s+([A-Za-z_$][A-Za-z0-9_$]*)/g, 'default-function');
1749
2030
  addMatches(/export\s+default\s+class\s+([A-Za-z_$][A-Za-z0-9_$]*)/g, 'default-class');
1750
2031
  addMatches(/export\s+default\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*(?:;|\n|$)/g, 'default-reference');
@@ -1757,7 +2038,7 @@ export function extractSymbols(filePath, content) {
1757
2038
  addMatches(/^[ \t]*(?:async\s+)?function\s*\*?\s*([A-Za-z_$][A-Za-z0-9_$]*)\s*[(<]/gm, 'local-function');
1758
2039
  addMatches(/^[ \t]*(?:const|let|var)\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*=\s*(?:async\s+)?function\b/gm, 'callable');
1759
2040
  addMatches(/^[ \t]*(?:abstract\s+)?class\s+([A-Za-z_$][A-Za-z0-9_$]*)/gm, 'local-class');
1760
- if (/\.(?:ts|tsx|mts|cts|vue)$/.test(filePath)) {
2041
+ if (/\.(?:ts|tsx|mts|cts|vue|svelte)$/.test(filePath)) {
1761
2042
  addMatches(/^[ \t]*(?:export\s+)?(?:declare\s+)?(?:const\s+)?(?:interface|enum)\s+([A-Za-z_$][A-Za-z0-9_$]*)/gm, 'type');
1762
2043
  addMatches(/^[ \t]*(?:export\s+)?(?:declare\s+)?type\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*(?:<[^=\n]*>)?\s*=/gm, 'type');
1763
2044
  }
@@ -19,6 +19,46 @@ const VIETNAMESE_PHRASE_ALIASES = [
19
19
  { regex: /\bthanh phan\b/gu, expansions: ['component'] },
20
20
  { regex: /\bkiem thu\b/gu, expansions: ['test', 'testing'] },
21
21
  { regex: /\bbo cuc\b/gu, expansions: ['layout'] },
22
+ // General programming vocabulary (diacritics folded; matches with or without accents).
23
+ { regex: /\bnhay cam\b/gu, expansions: ['sensitive'] },
24
+ { regex: /\bbi mat\b/gu, expansions: ['secret'] },
25
+ { regex: /\bgia tri\b/gu, expansions: ['value'] },
26
+ { regex: /\bvan ban\b/gu, expansions: ['text'] },
27
+ { regex: /\bsao luu\b/gu, expansions: ['backup'] },
28
+ { regex: /\bkhoi phuc\b/gu, expansions: ['restore', 'recover'] },
29
+ { regex: /\bdinh danh\b/gu, expansions: ['identity', 'id'] },
30
+ { regex: /\bdu an\b/gu, expansions: ['project'] },
31
+ { regex: /\bthu muc\b/gu, expansions: ['directory', 'dir', 'folder'] },
32
+ { regex: /\bphan loai\b/gu, expansions: ['classify', 'category'] },
33
+ { regex: /\buoc tinh\b/gu, expansions: ['estimate'] },
34
+ { regex: /\bcong chan\b/gu, expansions: ['gate', 'guard'] },
35
+ { regex: /\bcap nhat\b/gu, expansions: ['update'] },
36
+ { regex: /\bgo cai dat\b/gu, expansions: ['uninstall'] },
37
+ { regex: /\bcai dat\b/gu, expansions: ['install', 'setup'] },
38
+ { regex: /\bcau hinh\b/gu, expansions: ['config', 'configuration'] },
39
+ { regex: /\bbao cao\b/gu, expansions: ['report'] },
40
+ { regex: /\blich su\b/gu, expansions: ['history'] },
41
+ { regex: /\bnhat ky\b/gu, expansions: ['log'] },
42
+ { regex: /\bchi muc\b/gu, expansions: ['index'] },
43
+ { regex: /\bxu ly\b/gu, expansions: ['handle', 'process'] },
44
+ { regex: /\bphan tich\b/gu, expansions: ['parse', 'analyze'] },
45
+ { regex: /\bhet han\b/gu, expansions: ['expire', 'expiry'] },
46
+ { regex: /\bchup anh\b/gu, expansions: ['snapshot'] },
47
+ { regex: /\bhoan tac\b/gu, expansions: ['rollback', 'revert'] },
48
+ { regex: /\bnguoi dung\b/gu, expansions: ['user'] },
49
+ { regex: /\bthong bao\b/gu, expansions: ['notify', 'message'] },
50
+ { regex: /\bsap xep\b/gu, expansions: ['sort'] },
51
+ { regex: /\bdang ky\b/gu, expansions: ['register'] },
52
+ { regex: /\btham so\b/gu, expansions: ['argument', 'param', 'option'] },
53
+ { regex: /\bket qua\b/gu, expansions: ['result'] },
54
+ { regex: /\bmac dinh\b/gu, expansions: ['default'] },
55
+ { regex: /\bdau vao\b/gu, expansions: ['input'] },
56
+ { regex: /\bdau ra\b/gu, expansions: ['output'] },
57
+ { regex: /\bhang doi\b/gu, expansions: ['queue'] },
58
+ { regex: /\bma hoa\b/gu, expansions: ['encode', 'encrypt'] },
59
+ { regex: /\bgiai ma\b/gu, expansions: ['decode', 'decrypt'] },
60
+ { regex: /\bbo nho\b/gu, expansions: ['memory'] },
61
+ { regex: /\bcanh bao\b/gu, expansions: ['warning', 'warn'] },
22
62
  ];
23
63
 
24
64
  const VIETNAMESE_TOKEN_ALIASES = new Map([
@@ -40,8 +80,58 @@ const VIETNAMESE_TOKEN_ALIASES = new Map([
40
80
  ['soat', ['review', 'audit']],
41
81
  ['trien', ['implement', 'build', 'ship']],
42
82
  ['khai', ['implement', 'build', 'ship']],
83
+ ['kho', ['store', 'storage']],
84
+ ['ghi', ['write', 'record']],
85
+ ['doc', ['read']],
86
+ ['luu', ['save', 'store', 'persist']],
87
+ ['tim', ['find', 'search', 'resolve']],
88
+ ['hong', ['broken', 'repair']],
89
+ ['phut', ['minute', 'minutes']],
90
+ ['ham', ['function']],
91
+ ['bien', ['variable']],
92
+ ['lop', ['class']],
93
+ ['lenh', ['command']],
94
+ ['chay', ['run', 'execute']],
95
+ ['phien', ['session']],
96
+ ['loc', ['filter']],
97
+ ['gui', ['send', 'dispatch']],
98
+ ['khoa', ['lock']],
99
+ ['huy', ['cancel', 'abort']],
100
+ ['quyet', ['decision']],
43
101
  ]);
44
102
 
103
+ // Query-time light stemming: adds the singular/base form of an English query word so
104
+ // 'files' reaches `file`, 'checks' reaches `check`, 'written' reaches `write`. Added next
105
+ // to the original token, never in place of it, and never applied to indexed text.
106
+ const IRREGULAR_STEMS = new Map([
107
+ ['written', 'write'], ['wrote', 'write'], ['built', 'build'], ['ran', 'run'], ['saved', 'save'],
108
+ ['found', 'find'], ['sent', 'send'], ['made', 'make'], ['read', 'read'], ['began', 'begin'],
109
+ ]);
110
+
111
+ const STEM_MIN_QUERY_TOKENS = 5;
112
+
113
+ function stemToken(token) {
114
+ if (!/^[a-z]+$/.test(token) || token.length < 4) {
115
+ return null;
116
+ }
117
+ if (IRREGULAR_STEMS.has(token)) {
118
+ return IRREGULAR_STEMS.get(token);
119
+ }
120
+ let stem = null;
121
+ if (token.endsWith('ies') && token.length > 4) {
122
+ stem = `${token.slice(0, -3)}y`;
123
+ } else if (/(?:ches|shes|xes|sses)$/.test(token)) {
124
+ stem = token.slice(0, -2);
125
+ } else if (token.endsWith('s') && !/(?:ss|us|is|as|os)$/.test(token)) {
126
+ stem = token.slice(0, -1);
127
+ } else if (token.endsWith('ing') && token.length > 5) {
128
+ stem = token.slice(0, -3);
129
+ } else if (token.endsWith('ed') && token.length > 4) {
130
+ stem = token.endsWith('ied') ? `${token.slice(0, -3)}y` : token.slice(0, -2);
131
+ }
132
+ return stem && stem.length >= 3 && stem !== token ? stem : null;
133
+ }
134
+
45
135
  export function buildRouteSignalText(...values) {
46
136
  const baseText = values
47
137
  .map((value) => String(value || '').trim())
@@ -73,6 +163,16 @@ export function buildSearchDescriptor(value, { expandVietnameseAliases = false }
73
163
  for (const token of collectVietnameseAliasTokens(foldedLower, tokens)) {
74
164
  tokens.add(token);
75
165
  }
166
+ // Stems only for question-like queries: identifier-style queries (findRelatedItemIds,
167
+ // collectVietnameseAliasTokens) must keep matching exact tokens.
168
+ if (tokens.size >= STEM_MIN_QUERY_TOKENS) {
169
+ for (const token of [...tokens]) {
170
+ const stem = stemToken(token);
171
+ if (stem && !GENERIC_STOPWORDS.has(stem)) {
172
+ tokens.add(stem);
173
+ }
174
+ }
175
+ }
76
176
  }
77
177
 
78
178
  return {
@@ -21,7 +21,7 @@ export const INDEX_ARTIFACTS = {
21
21
  // files or the new extractions silently vanish.
22
22
  // v10: symbols.json gains unexported function/class ('local-function', 'local-class'),
23
23
  // function-expression consts, class 'method' rows and TS interface/enum/type ('type') rows.
24
- export const INDEX_SCHEMA_VERSION = 10;
24
+ export const INDEX_SCHEMA_VERSION = 11;
25
25
 
26
26
  export function getIndexDir(rootDir) {
27
27
  return path.join(rootDir, '.cache', 'index');
@@ -62,5 +62,6 @@ export function isLikelyTestFilePath(filePath) {
62
62
  || lower.endsWith('.spec.jsx')
63
63
  || lower.endsWith('.spec.mjs')
64
64
  || lower.endsWith('.spec.cjs')
65
+ || /(?:_test\.(?:go|py|rb|rs)|_spec\.rb|(?:^|\/)test_[^/]+\.py|[a-z0-9]Tests?\.(?:java|cs))$/.test(filePath)
65
66
  );
66
67
  }