@gitsense/gsc-utils 0.2.9 → 0.2.11

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.
@@ -10750,14 +10750,14 @@ function formatContextContent$1(items, contentType, contentOption) {
10750
10750
  // Always include metadata for batch analysis context
10751
10751
  result +=
10752
10752
  `- Repo: ${itemRepo.fullName || 'N/A'}\n`+
10753
- `- Path: ${itemMeta.path || 'N/A'}\n`;
10753
+ `- Path: ${item.path || 'N/A'}\n`;
10754
10754
 
10755
10755
  // Size and Tokens are specific to 'file content'
10756
10756
  if (contentType === 'file content') {
10757
- result += `- Size: ${_formatBytes(itemMeta.size)}\n`;
10758
- result += `- Tokens: ${itemMeta.tokens?.content?.estimate || 'N/A'}\n`;
10757
+ result += `- Size: ${_formatBytes(item.size)}\n`;
10758
+ result += `- Tokens: ${item.tokenCount || 'N/A'}\n`;
10759
10759
  } else {
10760
- const type = itemMeta.type || 'unknown';
10760
+ const type = item.type || 'unknown';
10761
10761
  result += `- Type: ${type === 'git-blob' ? 'file' : type === 'git-tree' || type === 'git-ref' ? 'directory' : type }\n`;
10762
10762
  result += `- Tokens: ${itemMeta.tokens?.analysis?.[contentOption.toLowerCase()]?.estimate || 'N/A'}\n`;
10763
10763
  }
@@ -10774,7 +10774,7 @@ function formatContextContent$1(items, contentType, contentOption) {
10774
10774
  // For batch analysis, we want the full file content.
10775
10775
  // The `if (!escapedContent.includes('Component: New Analyzer Chat') && escapedContent.match(summary))`
10776
10776
  // logic is specific to the frontend's overview builder and should not be applied here.
10777
- result += "```"+(itemMeta.highlight || '')+"\n"+escapedContent+"\n```";
10777
+ result += "```"+(item.highlight || '')+"\n"+escapedContent+"\n```";
10778
10778
 
10779
10779
  if (index !== items.length - 1) {
10780
10780
  result += '\n---End of Item---\n';
@@ -10789,7 +10789,7 @@ var ContextUtils$2 = {
10789
10789
  parseContextSection: parseContextSection$1,
10790
10790
  extractContextSections: extractContextSections$1,
10791
10791
  extractContextItemsOverviewTableRows: extractContextItemsOverviewTableRows$1,
10792
- formatContextContent: formatContextContent$1, // Export the new method
10792
+ formatContextContent: formatContextContent$1,
10793
10793
  };
10794
10794
 
10795
10795
  /*
@@ -11831,13 +11831,13 @@ var LLMUtils$1 = {
11831
11831
 
11832
11832
  /*
11833
11833
  * Component: Config Utilities
11834
- * Block-UUID: 89016e46-9898-42f0-bef4-564e442cfaf3
11835
- * Parent-UUID: N/A
11836
- * Version: 1.0.0
11834
+ * Block-UUID: 4f0bc5b4-acc6-44e4-8344-db9e3df89c0d
11835
+ * Parent-UUID: 89016e46-9898-42f0-bef4-564e442cfaf3
11836
+ * Version: 1.1.0
11837
11837
  * Description: Provides utility functions for loading and accessing application configuration from data/chats.json.
11838
11838
  * Language: JavaScript
11839
- * Created-at: 2025-08-28T17:46:26.948Z
11840
- * Authors: Gemini 2.5 Flash (v1.0.0)
11839
+ * Created-at: 2025-09-02T04:04:42.681Z
11840
+ * Authors: Gemini 2.5 Flash (v1.0.0), Gemini 2.5 Flash (v1.1.0)
11841
11841
  */
11842
11842
 
11843
11843
  const fs$1 = require$$0.promises;
@@ -11908,11 +11908,34 @@ function getApiKeyName$1(config, providerName) {
11908
11908
  return providerConfig ? providerConfig.apiKeyName : null;
11909
11909
  }
11910
11910
 
11911
+ /**
11912
+ * Retrieves the first provider configuration for a given model name.
11913
+ * This method assumes only one provider is relevant per model, even if the configuration
11914
+ * lists multiple in a 'providers' array, and will return the first one found.
11915
+ *
11916
+ * @param {Object} config - The loaded configuration object.
11917
+ * @param {string} modelName - The user-friendly name of the model (e.g., "Gemini 2.5 Flash").
11918
+ * @returns {Object|null} The first provider's configuration object for the model, or null if not found.
11919
+ */
11920
+ function getProviderForModel(config, modelName) {
11921
+ if (!config || !config.models || !Array.isArray(config.models)) {
11922
+ return null;
11923
+ }
11924
+
11925
+ const modelEntry = config.models.find(m => m.name === modelName);
11926
+ if (!modelEntry || !modelEntry.providers || !Array.isArray(modelEntry.providers) || modelEntry.providers.length === 0) {
11927
+ return null;
11928
+ }
11929
+
11930
+ return modelEntry.providers[0];
11931
+ }
11932
+
11911
11933
  var ConfigUtils$1 = {
11912
11934
  loadConfig: loadConfig$1,
11913
11935
  getProviderConfig: getProviderConfig$1,
11914
11936
  getModelProviderDetails: getModelProviderDetails$1,
11915
- getApiKeyName: getApiKeyName$1
11937
+ getApiKeyName: getApiKeyName$1,
11938
+ getProviderForModel
11916
11939
  };
11917
11940
 
11918
11941
  /*
@@ -10748,14 +10748,14 @@ function formatContextContent$1(items, contentType, contentOption) {
10748
10748
  // Always include metadata for batch analysis context
10749
10749
  result +=
10750
10750
  `- Repo: ${itemRepo.fullName || 'N/A'}\n`+
10751
- `- Path: ${itemMeta.path || 'N/A'}\n`;
10751
+ `- Path: ${item.path || 'N/A'}\n`;
10752
10752
 
10753
10753
  // Size and Tokens are specific to 'file content'
10754
10754
  if (contentType === 'file content') {
10755
- result += `- Size: ${_formatBytes(itemMeta.size)}\n`;
10756
- result += `- Tokens: ${itemMeta.tokens?.content?.estimate || 'N/A'}\n`;
10755
+ result += `- Size: ${_formatBytes(item.size)}\n`;
10756
+ result += `- Tokens: ${item.tokenCount || 'N/A'}\n`;
10757
10757
  } else {
10758
- const type = itemMeta.type || 'unknown';
10758
+ const type = item.type || 'unknown';
10759
10759
  result += `- Type: ${type === 'git-blob' ? 'file' : type === 'git-tree' || type === 'git-ref' ? 'directory' : type }\n`;
10760
10760
  result += `- Tokens: ${itemMeta.tokens?.analysis?.[contentOption.toLowerCase()]?.estimate || 'N/A'}\n`;
10761
10761
  }
@@ -10772,7 +10772,7 @@ function formatContextContent$1(items, contentType, contentOption) {
10772
10772
  // For batch analysis, we want the full file content.
10773
10773
  // The `if (!escapedContent.includes('Component: New Analyzer Chat') && escapedContent.match(summary))`
10774
10774
  // logic is specific to the frontend's overview builder and should not be applied here.
10775
- result += "```"+(itemMeta.highlight || '')+"\n"+escapedContent+"\n```";
10775
+ result += "```"+(item.highlight || '')+"\n"+escapedContent+"\n```";
10776
10776
 
10777
10777
  if (index !== items.length - 1) {
10778
10778
  result += '\n---End of Item---\n';
@@ -10787,7 +10787,7 @@ var ContextUtils$2 = {
10787
10787
  parseContextSection: parseContextSection$1,
10788
10788
  extractContextSections: extractContextSections$1,
10789
10789
  extractContextItemsOverviewTableRows: extractContextItemsOverviewTableRows$1,
10790
- formatContextContent: formatContextContent$1, // Export the new method
10790
+ formatContextContent: formatContextContent$1,
10791
10791
  };
10792
10792
 
10793
10793
  /*
@@ -11829,13 +11829,13 @@ var LLMUtils$1 = {
11829
11829
 
11830
11830
  /*
11831
11831
  * Component: Config Utilities
11832
- * Block-UUID: 89016e46-9898-42f0-bef4-564e442cfaf3
11833
- * Parent-UUID: N/A
11834
- * Version: 1.0.0
11832
+ * Block-UUID: 4f0bc5b4-acc6-44e4-8344-db9e3df89c0d
11833
+ * Parent-UUID: 89016e46-9898-42f0-bef4-564e442cfaf3
11834
+ * Version: 1.1.0
11835
11835
  * Description: Provides utility functions for loading and accessing application configuration from data/chats.json.
11836
11836
  * Language: JavaScript
11837
- * Created-at: 2025-08-28T17:46:26.948Z
11838
- * Authors: Gemini 2.5 Flash (v1.0.0)
11837
+ * Created-at: 2025-09-02T04:04:42.681Z
11838
+ * Authors: Gemini 2.5 Flash (v1.0.0), Gemini 2.5 Flash (v1.1.0)
11839
11839
  */
11840
11840
 
11841
11841
  const fs$1 = require$$0.promises;
@@ -11906,11 +11906,34 @@ function getApiKeyName$1(config, providerName) {
11906
11906
  return providerConfig ? providerConfig.apiKeyName : null;
11907
11907
  }
11908
11908
 
11909
+ /**
11910
+ * Retrieves the first provider configuration for a given model name.
11911
+ * This method assumes only one provider is relevant per model, even if the configuration
11912
+ * lists multiple in a 'providers' array, and will return the first one found.
11913
+ *
11914
+ * @param {Object} config - The loaded configuration object.
11915
+ * @param {string} modelName - The user-friendly name of the model (e.g., "Gemini 2.5 Flash").
11916
+ * @returns {Object|null} The first provider's configuration object for the model, or null if not found.
11917
+ */
11918
+ function getProviderForModel(config, modelName) {
11919
+ if (!config || !config.models || !Array.isArray(config.models)) {
11920
+ return null;
11921
+ }
11922
+
11923
+ const modelEntry = config.models.find(m => m.name === modelName);
11924
+ if (!modelEntry || !modelEntry.providers || !Array.isArray(modelEntry.providers) || modelEntry.providers.length === 0) {
11925
+ return null;
11926
+ }
11927
+
11928
+ return modelEntry.providers[0];
11929
+ }
11930
+
11909
11931
  var ConfigUtils$1 = {
11910
11932
  loadConfig: loadConfig$1,
11911
11933
  getProviderConfig: getProviderConfig$1,
11912
11934
  getModelProviderDetails: getModelProviderDetails$1,
11913
- getApiKeyName: getApiKeyName$1
11935
+ getApiKeyName: getApiKeyName$1,
11936
+ getProviderForModel
11914
11937
  };
11915
11938
 
11916
11939
  /*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitsense/gsc-utils",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "Utilities for GitSense Chat (GSC)",
5
5
  "main": "dist/gsc-utils.cjs.js",
6
6
  "module": "dist/gsc-utils.esm.js",
@@ -1,12 +1,12 @@
1
1
  /*
2
2
  * Component: Config Utilities
3
- * Block-UUID: 89016e46-9898-42f0-bef4-564e442cfaf3
4
- * Parent-UUID: N/A
5
- * Version: 1.0.0
3
+ * Block-UUID: 4f0bc5b4-acc6-44e4-8344-db9e3df89c0d
4
+ * Parent-UUID: 89016e46-9898-42f0-bef4-564e442cfaf3
5
+ * Version: 1.1.0
6
6
  * Description: Provides utility functions for loading and accessing application configuration from data/chats.json.
7
7
  * Language: JavaScript
8
- * Created-at: 2025-08-28T17:46:26.948Z
9
- * Authors: Gemini 2.5 Flash (v1.0.0)
8
+ * Created-at: 2025-09-02T04:04:42.681Z
9
+ * Authors: Gemini 2.5 Flash (v1.0.0), Gemini 2.5 Flash (v1.1.0)
10
10
  */
11
11
 
12
12
 
@@ -78,9 +78,32 @@ function getApiKeyName(config, providerName) {
78
78
  return providerConfig ? providerConfig.apiKeyName : null;
79
79
  }
80
80
 
81
+ /**
82
+ * Retrieves the first provider configuration for a given model name.
83
+ * This method assumes only one provider is relevant per model, even if the configuration
84
+ * lists multiple in a 'providers' array, and will return the first one found.
85
+ *
86
+ * @param {Object} config - The loaded configuration object.
87
+ * @param {string} modelName - The user-friendly name of the model (e.g., "Gemini 2.5 Flash").
88
+ * @returns {Object|null} The first provider's configuration object for the model, or null if not found.
89
+ */
90
+ function getProviderForModel(config, modelName) {
91
+ if (!config || !config.models || !Array.isArray(config.models)) {
92
+ return null;
93
+ }
94
+
95
+ const modelEntry = config.models.find(m => m.name === modelName);
96
+ if (!modelEntry || !modelEntry.providers || !Array.isArray(modelEntry.providers) || modelEntry.providers.length === 0) {
97
+ return null;
98
+ }
99
+
100
+ return modelEntry.providers[0];
101
+ }
102
+
81
103
  module.exports = {
82
104
  loadConfig,
83
105
  getProviderConfig,
84
106
  getModelProviderDetails,
85
- getApiKeyName
107
+ getApiKeyName,
108
+ getProviderForModel
86
109
  };
@@ -295,14 +295,14 @@ function formatContextContent(items, contentType, contentOption) {
295
295
  // Always include metadata for batch analysis context
296
296
  result +=
297
297
  `- Repo: ${itemRepo.fullName || 'N/A'}\n`+
298
- `- Path: ${itemMeta.path || 'N/A'}\n`;
298
+ `- Path: ${item.path || 'N/A'}\n`;
299
299
 
300
300
  // Size and Tokens are specific to 'file content'
301
301
  if (contentType === 'file content') {
302
- result += `- Size: ${_formatBytes(itemMeta.size)}\n`;
303
- result += `- Tokens: ${itemMeta.tokens?.content?.estimate || 'N/A'}\n`;
302
+ result += `- Size: ${_formatBytes(item.size)}\n`;
303
+ result += `- Tokens: ${item.tokenCount || 'N/A'}\n`;
304
304
  } else {
305
- const type = itemMeta.type || 'unknown';
305
+ const type = item.type || 'unknown';
306
306
  result += `- Type: ${type === 'git-blob' ? 'file' : type === 'git-tree' || type === 'git-ref' ? 'directory' : type }\n`;
307
307
  result += `- Tokens: ${itemMeta.tokens?.analysis?.[contentOption.toLowerCase()]?.estimate || 'N/A'}\n`;
308
308
  }
@@ -319,7 +319,7 @@ function formatContextContent(items, contentType, contentOption) {
319
319
  // For batch analysis, we want the full file content.
320
320
  // The `if (!escapedContent.includes('Component: New Analyzer Chat') && escapedContent.match(summary))`
321
321
  // logic is specific to the frontend's overview builder and should not be applied here.
322
- result += "```"+(itemMeta.highlight || '')+"\n"+escapedContent+"\n```";
322
+ result += "```"+(item.highlight || '')+"\n"+escapedContent+"\n```";
323
323
 
324
324
  if (index !== items.length - 1) {
325
325
  result += '\n---End of Item---\n';
@@ -334,5 +334,5 @@ module.exports = {
334
334
  parseContextSection,
335
335
  extractContextSections,
336
336
  extractContextItemsOverviewTableRows,
337
- formatContextContent, // Export the new method
337
+ formatContextContent,
338
338
  };