@ganju/utils 0.0.13 → 0.0.14

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/dist/constants.js CHANGED
@@ -815,7 +815,7 @@ const RESOURCE_SEARCH_COMMON_TERM_MIN = 5;
815
815
  const RESOURCE_SEARCH_RERANK_CANDIDATES = 30;
816
816
  const RESOURCE_SEARCH_RERANK_MODEL = '@cf/baai/bge-reranker-base';
817
817
  const RESOURCE_HANDLER_SLEEP_AFTER = '10m';
818
- const DOCS_URL = 'https://docs.ganju.ai';
818
+ const DOCS_URL = 'https://ganju.ai/docs/';
819
819
  const BASE64_DATA_URI_RE = /data:image\/[a-zA-Z0-9+\-.]+;base64,[A-Za-z0-9+/=\s]+/g;
820
820
  const RAW_BASE64_BLOB_RE = /[A-Za-z0-9+/]{512,}={0,2}/g;
821
821
  const CHUNK_SEPARATORS = [
@@ -1 +1 @@
1
- {"version":3,"file":"toolLint.d.ts","sourceRoot":"","sources":["../src/toolLint.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE;QACZ,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,aAAa,CAAC,EAAE,OAAO,CAAC;KACzB,CAAC;CACH;AAED,eAAO,MAAM,eAAe,+JAQlB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5D,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,YAAY,CAAC;IAGnB,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,KAAK,CAAC,EAAE,MA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AC,EAAE,MAAM,CAAC;IAGf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAI9B,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;IAGxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAID,eAAO,MAAM,gCAAgC,KAAK,CAAC;AAKnD,eAAO,MAAM,mBAAmB,KAAK,CAAC;AA2JtC;;;GAGG;AACH,eAAO,MAAM,SAAS,GACpB,OAAO,YAAY,EAAE,EACrB,UAAS,eAAoB,KAC5B,eAAe,EA8FjB,CAAC"}
package/dist/toolLint.js CHANGED
@@ -44,8 +44,11 @@ const fold = (text) => text
44
44
  // Wording that tells a model WHEN to call a tool rather than only what it does
45
45
  // — English, Spanish and Portuguese, the languages descriptions here are
46
46
  // written in. Loose on purpose: a false "says when" costs nothing, a false
47
- // "doesn't" nags someone whose description is fine.
48
- const USAGE_GUIDANCE = /\b(use|uses|using|call|calls|when|whenever|before|after|instead|only if|if the user|if you|for questions|usa|usala|usalo|usar|llama|llamala|llamar|cuando|antes de|despues de|en lugar de|si el usuario|quando|use-a|utilize|chame)\b/;
47
+ // "doesn't" nags someone whose description is fine. But not so loose that
48
+ // words about how a tool works count: "uses the Stripe API" and "makes an API
49
+ // call" say nothing about when to reach for it, so "call" counts only as an
50
+ // instruction ("call this…", "call it…").
51
+ const USAGE_GUIDANCE = /\b(use|call (?:this|it)|when|whenever|before|after|instead|only if|if the user|if you|for questions|usa|usala|usalo|usar|llama|llamala|llamar|cuando|antes de|despues de|en lugar de|si el usuario|quando|use-a|utilize|chame)\b/;
49
52
  const STOPWORDS = new Set([
50
53
  'the',
51
54
  'and',
@@ -87,8 +90,19 @@ const STOPWORDS = new Set([
87
90
  const contentWords = (text) => new Set(fold(text)
88
91
  .split(/[^a-z0-9]+/)
89
92
  .filter(word => word.length >= 3 && !STOPWORDS.has(word)));
93
+ // A proxied tool is named `<server prefix>__<remote name>`. The prefix says
94
+ // which connection it came from, not what it does, so `search_repositories`
95
+ // and `github__search_repositories` are the same tool to a model. Kept here
96
+ // rather than imported from constants (MCP_PROXY_TOOL_NAME_SEP), since this
97
+ // file imports nothing.
98
+ const PROXY_NAME_SEP = '__';
99
+ const withoutProxyPrefix = (name) => {
100
+ const at = name.lastIndexOf(PROXY_NAME_SEP);
101
+ const bare = at === -1 ? name : name.slice(at + PROXY_NAME_SEP.length);
102
+ return bare || name;
103
+ };
90
104
  // `lookupOrder`, `lookup-order` and `order_lookup` name the same thing.
91
- const nameTokens = (name) => name
105
+ const nameTokens = (name) => withoutProxyPrefix(name)
92
106
  .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
93
107
  .toLowerCase()
94
108
  .split(/[^a-z0-9]+/)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ganju/utils",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "Shared constants, schemas and helpers for Ganju",
5
5
  "license": "Apache-2.0",
6
6
  "author": "MontoyaAndres <andresmontoyafcb@gmail.com>",
package/src/constants.ts CHANGED
@@ -967,7 +967,7 @@ const RESOURCE_SEARCH_RERANK_MODEL = '@cf/baai/bge-reranker-base';
967
967
 
968
968
  const RESOURCE_HANDLER_SLEEP_AFTER = '10m';
969
969
 
970
- const DOCS_URL = 'https://docs.ganju.ai';
970
+ const DOCS_URL = 'https://ganju.ai/docs/';
971
971
 
972
972
  const BASE64_DATA_URI_RE =
973
973
  /data:image\/[a-zA-Z0-9+\-.]+;base64,[A-Za-z0-9+/=\s]+/g;
package/src/toolLint.ts CHANGED
@@ -93,9 +93,12 @@ const fold = (text: string): string =>
93
93
  // Wording that tells a model WHEN to call a tool rather than only what it does
94
94
  // — English, Spanish and Portuguese, the languages descriptions here are
95
95
  // written in. Loose on purpose: a false "says when" costs nothing, a false
96
- // "doesn't" nags someone whose description is fine.
96
+ // "doesn't" nags someone whose description is fine. But not so loose that
97
+ // words about how a tool works count: "uses the Stripe API" and "makes an API
98
+ // call" say nothing about when to reach for it, so "call" counts only as an
99
+ // instruction ("call this…", "call it…").
97
100
  const USAGE_GUIDANCE =
98
- /\b(use|uses|using|call|calls|when|whenever|before|after|instead|only if|if the user|if you|for questions|usa|usala|usalo|usar|llama|llamala|llamar|cuando|antes de|despues de|en lugar de|si el usuario|quando|use-a|utilize|chame)\b/;
101
+ /\b(use|call (?:this|it)|when|whenever|before|after|instead|only if|if the user|if you|for questions|usa|usala|usalo|usar|llama|llamala|llamar|cuando|antes de|despues de|en lugar de|si el usuario|quando|use-a|utilize|chame)\b/;
99
102
 
100
103
  const STOPWORDS = new Set([
101
104
  'the',
@@ -143,9 +146,22 @@ const contentWords = (text: string): Set<string> =>
143
146
  .filter(word => word.length >= 3 && !STOPWORDS.has(word))
144
147
  );
145
148
 
149
+ // A proxied tool is named `<server prefix>__<remote name>`. The prefix says
150
+ // which connection it came from, not what it does, so `search_repositories`
151
+ // and `github__search_repositories` are the same tool to a model. Kept here
152
+ // rather than imported from constants (MCP_PROXY_TOOL_NAME_SEP), since this
153
+ // file imports nothing.
154
+ const PROXY_NAME_SEP = '__';
155
+
156
+ const withoutProxyPrefix = (name: string): string => {
157
+ const at = name.lastIndexOf(PROXY_NAME_SEP);
158
+ const bare = at === -1 ? name : name.slice(at + PROXY_NAME_SEP.length);
159
+ return bare || name;
160
+ };
161
+
146
162
  // `lookupOrder`, `lookup-order` and `order_lookup` name the same thing.
147
163
  const nameTokens = (name: string): string =>
148
- name
164
+ withoutProxyPrefix(name)
149
165
  .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
150
166
  .toLowerCase()
151
167
  .split(/[^a-z0-9]+/)