@gitsense/gsc-utils 0.2.10 → 0.2.12

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.
@@ -48,12 +48,12 @@ function unescapeCodeBlocks(content) {
48
48
 
49
49
  /**
50
50
  * Gets template messages from a specific message type directory
51
- * @param {string} dirname- The directory containting the template messages directory
52
- * @param {string} messageType - The type of messages to retrieve (e.g., 'notes', 'draft')
51
+ * @param {string} dirname- The directory containting the template messages directory or the message directory itself
52
+ * @param {string|mull} messageType - The type of messages to retrieve (e.g., 'notes', 'draft')
53
53
  * @returns {Array} An array of message objects with role and content properties
54
54
  */
55
55
  function getChatTemplateMessages$1(dirname, messageType) {
56
- const messagesDir = path$6.join(dirname, messageType);
56
+ const messagesDir = messageType ? path$6.join(dirname, messageType) : dirname;
57
57
  const messages = [];
58
58
 
59
59
  try {
@@ -101,7 +101,7 @@ function getChatTemplateMessages$1(dirname, messageType) {
101
101
 
102
102
  return messages;
103
103
  } catch (error) {
104
- console.error(`Error reading messages from ${messageType}:`, error);
104
+ console.error(`Error reading messages from ${messageType || dirname}:`, error);
105
105
  return [];
106
106
  }
107
107
  }
@@ -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';
@@ -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: 65b39008-da68-462e-bcac-27db873c9ddc
11835
+ * Parent-UUID: 4f0bc5b4-acc6-44e4-8344-db9e3df89c0d
11836
+ * Version: 1.2.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), Gemini 2.5 Flash (v1.2.0)
11841
11841
  */
11842
11842
 
11843
11843
  const fs$1 = require$$0.promises;
@@ -11872,7 +11872,7 @@ function getProviderConfig$1(config, providerName) {
11872
11872
  if (!config || !config.providers || !Array.isArray(config.providers)) {
11873
11873
  return null;
11874
11874
  }
11875
- return config.providers.find(p => p.name === providerName) || null;
11875
+ return config.providers.find(p => p.name.toLowerCase() === providerName.toLowerCase()) || null;
11876
11876
  }
11877
11877
 
11878
11878
  /**
@@ -11893,7 +11893,7 @@ function getModelProviderDetails$1(config, modelName, providerName) {
11893
11893
  return null;
11894
11894
  }
11895
11895
 
11896
- return modelEntry.providers.find(p => p.name === providerName) || null;
11896
+ return modelEntry.providers.find(p => p.name.toLowerCase() === providerName.toLowerCase()) || null;
11897
11897
  }
11898
11898
 
11899
11899
  /**
@@ -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.find(p => p.name.toLowerCase() === modelEntry.providers[0].name.toLowerCase()) || null;
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
  /*
@@ -46,12 +46,12 @@ function unescapeCodeBlocks(content) {
46
46
 
47
47
  /**
48
48
  * Gets template messages from a specific message type directory
49
- * @param {string} dirname- The directory containting the template messages directory
50
- * @param {string} messageType - The type of messages to retrieve (e.g., 'notes', 'draft')
49
+ * @param {string} dirname- The directory containting the template messages directory or the message directory itself
50
+ * @param {string|mull} messageType - The type of messages to retrieve (e.g., 'notes', 'draft')
51
51
  * @returns {Array} An array of message objects with role and content properties
52
52
  */
53
53
  function getChatTemplateMessages$1(dirname, messageType) {
54
- const messagesDir = path$6.join(dirname, messageType);
54
+ const messagesDir = messageType ? path$6.join(dirname, messageType) : dirname;
55
55
  const messages = [];
56
56
 
57
57
  try {
@@ -99,7 +99,7 @@ function getChatTemplateMessages$1(dirname, messageType) {
99
99
 
100
100
  return messages;
101
101
  } catch (error) {
102
- console.error(`Error reading messages from ${messageType}:`, error);
102
+ console.error(`Error reading messages from ${messageType || dirname}:`, error);
103
103
  return [];
104
104
  }
105
105
  }
@@ -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';
@@ -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: 65b39008-da68-462e-bcac-27db873c9ddc
11833
+ * Parent-UUID: 4f0bc5b4-acc6-44e4-8344-db9e3df89c0d
11834
+ * Version: 1.2.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), Gemini 2.5 Flash (v1.2.0)
11839
11839
  */
11840
11840
 
11841
11841
  const fs$1 = require$$0.promises;
@@ -11870,7 +11870,7 @@ function getProviderConfig$1(config, providerName) {
11870
11870
  if (!config || !config.providers || !Array.isArray(config.providers)) {
11871
11871
  return null;
11872
11872
  }
11873
- return config.providers.find(p => p.name === providerName) || null;
11873
+ return config.providers.find(p => p.name.toLowerCase() === providerName.toLowerCase()) || null;
11874
11874
  }
11875
11875
 
11876
11876
  /**
@@ -11891,7 +11891,7 @@ function getModelProviderDetails$1(config, modelName, providerName) {
11891
11891
  return null;
11892
11892
  }
11893
11893
 
11894
- return modelEntry.providers.find(p => p.name === providerName) || null;
11894
+ return modelEntry.providers.find(p => p.name.toLowerCase() === providerName.toLowerCase()) || null;
11895
11895
  }
11896
11896
 
11897
11897
  /**
@@ -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.find(p => p.name.toLowerCase() === modelEntry.providers[0].name.toLowerCase()) || null;
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.10",
3
+ "version": "0.2.12",
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: 65b39008-da68-462e-bcac-27db873c9ddc
4
+ * Parent-UUID: 4f0bc5b4-acc6-44e4-8344-db9e3df89c0d
5
+ * Version: 1.2.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), Gemini 2.5 Flash (v1.2.0)
10
10
  */
11
11
 
12
12
 
@@ -42,7 +42,7 @@ function getProviderConfig(config, providerName) {
42
42
  if (!config || !config.providers || !Array.isArray(config.providers)) {
43
43
  return null;
44
44
  }
45
- return config.providers.find(p => p.name === providerName) || null;
45
+ return config.providers.find(p => p.name.toLowerCase() === providerName.toLowerCase()) || null;
46
46
  }
47
47
 
48
48
  /**
@@ -63,7 +63,7 @@ function getModelProviderDetails(config, modelName, providerName) {
63
63
  return null;
64
64
  }
65
65
 
66
- return modelEntry.providers.find(p => p.name === providerName) || null;
66
+ return modelEntry.providers.find(p => p.name.toLowerCase() === providerName.toLowerCase()) || null;
67
67
  }
68
68
 
69
69
  /**
@@ -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.find(p => p.name.toLowerCase() === modelEntry.providers[0].name.toLowerCase()) || null;
101
+ }
102
+
81
103
  module.exports = {
82
104
  loadConfig,
83
105
  getProviderConfig,
84
106
  getModelProviderDetails,
85
- getApiKeyName
107
+ getApiKeyName,
108
+ getProviderForModel
86
109
  };
@@ -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';
@@ -40,12 +40,12 @@ function unescapeCodeBlocks(content) {
40
40
 
41
41
  /**
42
42
  * Gets template messages from a specific message type directory
43
- * @param {string} dirname- The directory containting the template messages directory
44
- * @param {string} messageType - The type of messages to retrieve (e.g., 'notes', 'draft')
43
+ * @param {string} dirname- The directory containting the template messages directory or the message directory itself
44
+ * @param {string|mull} messageType - The type of messages to retrieve (e.g., 'notes', 'draft')
45
45
  * @returns {Array} An array of message objects with role and content properties
46
46
  */
47
47
  function getChatTemplateMessages(dirname, messageType) {
48
- const messagesDir = path.join(dirname, messageType);
48
+ const messagesDir = messageType ? path.join(dirname, messageType) : dirname;
49
49
  const messages = [];
50
50
 
51
51
  try {
@@ -93,7 +93,7 @@ function getChatTemplateMessages(dirname, messageType) {
93
93
 
94
94
  return messages;
95
95
  } catch (error) {
96
- console.error(`Error reading messages from ${messageType}:`, error);
96
+ console.error(`Error reading messages from ${messageType || dirname}:`, error);
97
97
  return [];
98
98
  }
99
99
  }