@gitsense/gsc-utils 0.2.17 → 0.2.19

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.
@@ -8797,21 +8797,22 @@ function formatToolBlock(toolData) {
8797
8797
  * @param {string} markdownContent - The original markdown string containing code blocks.
8798
8798
  * @param {string} toolName - The 'tool' property value of the target GitSense Chat Tool Block to replace.
8799
8799
  * @param {Object} newToolData - The new tool data object to insert into the block.
8800
+ * @param {Object} CodeBlockUtils - The CodeBlockUtils class to avoid a circular dependency since we can't require it.
8800
8801
  * @returns {string} The markdown content with the specified tool block updated.
8801
8802
  * @throws {Error} If the target tool block is not found or if CodeBlockUtils encounters an error.
8802
8803
  */
8803
- function replaceToolBlock(markdownContent, toolName, newToolData, processCodeBlocks, updateCodeBlockByIndex) {
8804
+ function replaceToolBlock(markdownContent, toolName, newToolData, CodeBlockUtils) {
8804
8805
  if (typeof markdownContent !== 'string' || !toolName || !newToolData) {
8805
8806
  throw new Error("Missing required parameters for replaceToolBlock.");
8806
8807
  }
8807
8808
 
8808
8809
  // We can't require them as this will create a circular dependency
8809
- if (!processCodeBlocks || !updateCodeBlockByIndex) {
8810
- throw new Error("Missing required dependencies processCodeBlocks and/or updateCodeBlockByIndex.");
8810
+ if (!CodeBlockUtils) {
8811
+ throw new Error("Missing required CodeBlockUtils dependency");
8811
8812
  }
8812
8813
 
8813
8814
  // 1. Process the markdown content to find all code blocks
8814
- const { blocks, warnings } = processCodeBlocks(markdownContent, { silent: true });
8815
+ const { blocks, warnings } = CodeBlockUtils.processCodeBlocks(markdownContent, { silent: true });
8815
8816
 
8816
8817
  let targetBlockIndex = -1;
8817
8818
 
@@ -8834,7 +8835,7 @@ function replaceToolBlock(markdownContent, toolName, newToolData, processCodeBlo
8834
8835
 
8835
8836
  // 4. Use CodeBlockUtils.updateCodeBlockByIndex to perform the replacement
8836
8837
  // The language for GitSense Tool Blocks is always 'txt'
8837
- const updatedMarkdown = updateCodeBlockByIndex(
8838
+ const updatedMarkdown = CodeBlockUtils.updateCodeBlockByIndex(
8838
8839
  markdownContent,
8839
8840
  targetBlockIndex,
8840
8841
  newContentBetweenFences,
@@ -10460,7 +10461,7 @@ const { updateCodeBlockByIndex: updateCodeBlockByIndex$1, updateCodeBlockByUUID,
10460
10461
  const { formatWithLineNumbers: formatWithLineNumbers$1, formatBlockWithLineNumbers: formatBlockWithLineNumbers$1, formatBlocksWithLineNumbers: formatBlocksWithLineNumbers$1, removeLineNumbers: removeLineNumbers$1 } = lineNumberFormatter;
10461
10462
 
10462
10463
  // Export all imported items
10463
- var CodeBlockUtils$4 = {
10464
+ var CodeBlockUtils$5 = {
10464
10465
  // Constants
10465
10466
  COMMENT_STYLES: COMMENT_STYLES$1,
10466
10467
 
@@ -10527,7 +10528,7 @@ var CodeBlockUtils$4 = {
10527
10528
  * Authors: Gemini 2.5 Flash Thinking (v1.0.0), Gemini 2.5 Flash (v1.1.0)
10528
10529
  */
10529
10530
 
10530
- const CodeBlockUtils$3 = CodeBlockUtils$4;
10531
+ const CodeBlockUtils$4 = CodeBlockUtils$5;
10531
10532
  const MessageUtils$2 = MessageUtils$3;
10532
10533
 
10533
10534
  /**
@@ -10666,7 +10667,7 @@ function parseContextSection$1(sectionText) {
10666
10667
  }
10667
10668
  });
10668
10669
 
10669
- const { blocks, warnings } = CodeBlockUtils$3.extractCodeBlocks(sectionText, { silent: true });
10670
+ const { blocks, warnings } = CodeBlockUtils$4.extractCodeBlocks(sectionText, { silent: true });
10670
10671
  const codeBlocks = blocks.filter(block => block.type === 'code');
10671
10672
 
10672
10673
  if (codeBlocks.length === 0) {
@@ -10932,7 +10933,7 @@ var constants = {
10932
10933
  * Authors: Gemini 2.5 Flash (v1.0.0)
10933
10934
  */
10934
10935
 
10935
- const CodeBlockUtils$2 = CodeBlockUtils$4;
10936
+ const CodeBlockUtils$3 = CodeBlockUtils$5;
10936
10937
  const GSToolBlockUtils$1 = GSToolBlockUtils$3;
10937
10938
  const JsonUtils$1 = JsonUtils$2;
10938
10939
  const { ANALYZE_HEADER_PREFIX } = constants;
@@ -10949,7 +10950,7 @@ const { ANALYZE_HEADER_PREFIX } = constants;
10949
10950
  */
10950
10951
  function processLLMAnalysisResponse$2(messageContent, stoppedStreaming) {
10951
10952
  const silent = { silent: true };
10952
- const { blocks, warnings } = CodeBlockUtils$2.extractCodeBlocks(messageContent, silent);
10953
+ const { blocks, warnings } = CodeBlockUtils$3.extractCodeBlocks(messageContent, silent);
10953
10954
 
10954
10955
  const analysisBlocks = [];
10955
10956
  const analysisMetadataBlocks = [];
@@ -11206,6 +11207,7 @@ var instructionLoader = {
11206
11207
  const fs$6 = require$$0.promises;
11207
11208
  const path$4 = require$$1;
11208
11209
  const { getAnalyzerInstructionsContent: getAnalyzerInstructionsContent$2 } = instructionLoader;
11210
+ const CodeBlockUtils$2 = CodeBlockUtils$5;
11209
11211
 
11210
11212
  /**
11211
11213
  * Reads and parses the config.json file in a directory.
@@ -11303,10 +11305,21 @@ async function getAnalyzers$2(analyzeMessagesBasePath, options = {}) {
11303
11305
  const analyzerId = `${analyzerName}::${contentType}::${instructionsType}`;
11304
11306
  const analyzerFullLabel = `${analyzerLabel} (${contentLabel} - ${instructionsLabel})`;
11305
11307
 
11306
- let descriptionContent = null;
11308
+ let description = null;
11307
11309
  if (includeDescription) {
11308
11310
  try {
11309
- descriptionContent = await getAnalyzerInstructionsContent$2(analyzeMessagesBasePath, analyzerId);
11311
+ const content = await getAnalyzerInstructionsContent$2(analyzeMessagesBasePath, analyzerId);
11312
+ const { blocks, warnings } = CodeBlockUtils$2.extractCodeBlocks(content, { silent: true });
11313
+ const jsonBlock = blocks.find(block => block.language === 'json');
11314
+
11315
+ if (jsonBlock && jsonBlock.content) {
11316
+ try {
11317
+ const json = JSON.parse(jsonBlock.content);
11318
+ description = json.description;
11319
+ } catch(error) {
11320
+ console.warn(`${analyzerId} contains an invalid JSON`);
11321
+ }
11322
+ }
11310
11323
  } catch (descError) {
11311
11324
  console.warn(`Warning: Could not load description for ${analyzerId}: ${descError.message}`);
11312
11325
  descriptionContent = null;
@@ -11318,7 +11331,7 @@ async function getAnalyzers$2(analyzeMessagesBasePath, options = {}) {
11318
11331
  label: analyzerFullLabel,
11319
11332
  name: analyzerName,
11320
11333
  protected: analyzerConfig?.protected || false,
11321
- ...(descriptionContent && { description: descriptionContent })
11334
+ description
11322
11335
  });
11323
11336
  } catch (error) {
11324
11337
  // If 1.md doesn't exist, this is not a complete analyzer configuration, skip.
@@ -11491,7 +11504,7 @@ var saver = {
11491
11504
 
11492
11505
  const fs$4 = require$$0.promises;
11493
11506
  const path$2 = require$$1;
11494
- const CodeBlockUtils$1 = CodeBlockUtils$4;
11507
+ const CodeBlockUtils$1 = CodeBlockUtils$5;
11495
11508
 
11496
11509
  /**
11497
11510
  * Deduces the JSON schema type and format/items from a string value pattern.
@@ -12120,7 +12133,7 @@ var EnvUtils$1 = {
12120
12133
  */
12121
12134
 
12122
12135
  const ChatUtils = ChatUtils$1;
12123
- const CodeBlockUtils = CodeBlockUtils$4;
12136
+ const CodeBlockUtils = CodeBlockUtils$5;
12124
12137
  const ContextUtils = ContextUtils$2;
12125
12138
  const MessageUtils = MessageUtils$3;
12126
12139
  const AnalysisBlockUtils = AnalysisBlockUtils$3;
@@ -8795,21 +8795,22 @@ function formatToolBlock(toolData) {
8795
8795
  * @param {string} markdownContent - The original markdown string containing code blocks.
8796
8796
  * @param {string} toolName - The 'tool' property value of the target GitSense Chat Tool Block to replace.
8797
8797
  * @param {Object} newToolData - The new tool data object to insert into the block.
8798
+ * @param {Object} CodeBlockUtils - The CodeBlockUtils class to avoid a circular dependency since we can't require it.
8798
8799
  * @returns {string} The markdown content with the specified tool block updated.
8799
8800
  * @throws {Error} If the target tool block is not found or if CodeBlockUtils encounters an error.
8800
8801
  */
8801
- function replaceToolBlock(markdownContent, toolName, newToolData, processCodeBlocks, updateCodeBlockByIndex) {
8802
+ function replaceToolBlock(markdownContent, toolName, newToolData, CodeBlockUtils) {
8802
8803
  if (typeof markdownContent !== 'string' || !toolName || !newToolData) {
8803
8804
  throw new Error("Missing required parameters for replaceToolBlock.");
8804
8805
  }
8805
8806
 
8806
8807
  // We can't require them as this will create a circular dependency
8807
- if (!processCodeBlocks || !updateCodeBlockByIndex) {
8808
- throw new Error("Missing required dependencies processCodeBlocks and/or updateCodeBlockByIndex.");
8808
+ if (!CodeBlockUtils) {
8809
+ throw new Error("Missing required CodeBlockUtils dependency");
8809
8810
  }
8810
8811
 
8811
8812
  // 1. Process the markdown content to find all code blocks
8812
- const { blocks, warnings } = processCodeBlocks(markdownContent, { silent: true });
8813
+ const { blocks, warnings } = CodeBlockUtils.processCodeBlocks(markdownContent, { silent: true });
8813
8814
 
8814
8815
  let targetBlockIndex = -1;
8815
8816
 
@@ -8832,7 +8833,7 @@ function replaceToolBlock(markdownContent, toolName, newToolData, processCodeBlo
8832
8833
 
8833
8834
  // 4. Use CodeBlockUtils.updateCodeBlockByIndex to perform the replacement
8834
8835
  // The language for GitSense Tool Blocks is always 'txt'
8835
- const updatedMarkdown = updateCodeBlockByIndex(
8836
+ const updatedMarkdown = CodeBlockUtils.updateCodeBlockByIndex(
8836
8837
  markdownContent,
8837
8838
  targetBlockIndex,
8838
8839
  newContentBetweenFences,
@@ -10458,7 +10459,7 @@ const { updateCodeBlockByIndex: updateCodeBlockByIndex$1, updateCodeBlockByUUID,
10458
10459
  const { formatWithLineNumbers: formatWithLineNumbers$1, formatBlockWithLineNumbers: formatBlockWithLineNumbers$1, formatBlocksWithLineNumbers: formatBlocksWithLineNumbers$1, removeLineNumbers: removeLineNumbers$1 } = lineNumberFormatter;
10459
10460
 
10460
10461
  // Export all imported items
10461
- var CodeBlockUtils$4 = {
10462
+ var CodeBlockUtils$5 = {
10462
10463
  // Constants
10463
10464
  COMMENT_STYLES: COMMENT_STYLES$1,
10464
10465
 
@@ -10525,7 +10526,7 @@ var CodeBlockUtils$4 = {
10525
10526
  * Authors: Gemini 2.5 Flash Thinking (v1.0.0), Gemini 2.5 Flash (v1.1.0)
10526
10527
  */
10527
10528
 
10528
- const CodeBlockUtils$3 = CodeBlockUtils$4;
10529
+ const CodeBlockUtils$4 = CodeBlockUtils$5;
10529
10530
  const MessageUtils$2 = MessageUtils$3;
10530
10531
 
10531
10532
  /**
@@ -10664,7 +10665,7 @@ function parseContextSection$1(sectionText) {
10664
10665
  }
10665
10666
  });
10666
10667
 
10667
- const { blocks, warnings } = CodeBlockUtils$3.extractCodeBlocks(sectionText, { silent: true });
10668
+ const { blocks, warnings } = CodeBlockUtils$4.extractCodeBlocks(sectionText, { silent: true });
10668
10669
  const codeBlocks = blocks.filter(block => block.type === 'code');
10669
10670
 
10670
10671
  if (codeBlocks.length === 0) {
@@ -10930,7 +10931,7 @@ var constants = {
10930
10931
  * Authors: Gemini 2.5 Flash (v1.0.0)
10931
10932
  */
10932
10933
 
10933
- const CodeBlockUtils$2 = CodeBlockUtils$4;
10934
+ const CodeBlockUtils$3 = CodeBlockUtils$5;
10934
10935
  const GSToolBlockUtils$1 = GSToolBlockUtils$3;
10935
10936
  const JsonUtils$1 = JsonUtils$2;
10936
10937
  const { ANALYZE_HEADER_PREFIX } = constants;
@@ -10947,7 +10948,7 @@ const { ANALYZE_HEADER_PREFIX } = constants;
10947
10948
  */
10948
10949
  function processLLMAnalysisResponse$2(messageContent, stoppedStreaming) {
10949
10950
  const silent = { silent: true };
10950
- const { blocks, warnings } = CodeBlockUtils$2.extractCodeBlocks(messageContent, silent);
10951
+ const { blocks, warnings } = CodeBlockUtils$3.extractCodeBlocks(messageContent, silent);
10951
10952
 
10952
10953
  const analysisBlocks = [];
10953
10954
  const analysisMetadataBlocks = [];
@@ -11204,6 +11205,7 @@ var instructionLoader = {
11204
11205
  const fs$6 = require$$0.promises;
11205
11206
  const path$4 = require$$1;
11206
11207
  const { getAnalyzerInstructionsContent: getAnalyzerInstructionsContent$2 } = instructionLoader;
11208
+ const CodeBlockUtils$2 = CodeBlockUtils$5;
11207
11209
 
11208
11210
  /**
11209
11211
  * Reads and parses the config.json file in a directory.
@@ -11301,10 +11303,21 @@ async function getAnalyzers$2(analyzeMessagesBasePath, options = {}) {
11301
11303
  const analyzerId = `${analyzerName}::${contentType}::${instructionsType}`;
11302
11304
  const analyzerFullLabel = `${analyzerLabel} (${contentLabel} - ${instructionsLabel})`;
11303
11305
 
11304
- let descriptionContent = null;
11306
+ let description = null;
11305
11307
  if (includeDescription) {
11306
11308
  try {
11307
- descriptionContent = await getAnalyzerInstructionsContent$2(analyzeMessagesBasePath, analyzerId);
11309
+ const content = await getAnalyzerInstructionsContent$2(analyzeMessagesBasePath, analyzerId);
11310
+ const { blocks, warnings } = CodeBlockUtils$2.extractCodeBlocks(content, { silent: true });
11311
+ const jsonBlock = blocks.find(block => block.language === 'json');
11312
+
11313
+ if (jsonBlock && jsonBlock.content) {
11314
+ try {
11315
+ const json = JSON.parse(jsonBlock.content);
11316
+ description = json.description;
11317
+ } catch(error) {
11318
+ console.warn(`${analyzerId} contains an invalid JSON`);
11319
+ }
11320
+ }
11308
11321
  } catch (descError) {
11309
11322
  console.warn(`Warning: Could not load description for ${analyzerId}: ${descError.message}`);
11310
11323
  descriptionContent = null;
@@ -11316,7 +11329,7 @@ async function getAnalyzers$2(analyzeMessagesBasePath, options = {}) {
11316
11329
  label: analyzerFullLabel,
11317
11330
  name: analyzerName,
11318
11331
  protected: analyzerConfig?.protected || false,
11319
- ...(descriptionContent && { description: descriptionContent })
11332
+ description
11320
11333
  });
11321
11334
  } catch (error) {
11322
11335
  // If 1.md doesn't exist, this is not a complete analyzer configuration, skip.
@@ -11489,7 +11502,7 @@ var saver = {
11489
11502
 
11490
11503
  const fs$4 = require$$0.promises;
11491
11504
  const path$2 = require$$1;
11492
- const CodeBlockUtils$1 = CodeBlockUtils$4;
11505
+ const CodeBlockUtils$1 = CodeBlockUtils$5;
11493
11506
 
11494
11507
  /**
11495
11508
  * Deduces the JSON schema type and format/items from a string value pattern.
@@ -12118,7 +12131,7 @@ var EnvUtils$1 = {
12118
12131
  */
12119
12132
 
12120
12133
  const ChatUtils = ChatUtils$1;
12121
- const CodeBlockUtils = CodeBlockUtils$4;
12134
+ const CodeBlockUtils = CodeBlockUtils$5;
12122
12135
  const ContextUtils = ContextUtils$2;
12123
12136
  const MessageUtils = MessageUtils$3;
12124
12137
  const AnalysisBlockUtils = AnalysisBlockUtils$3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitsense/gsc-utils",
3
- "version": "0.2.17",
3
+ "version": "0.2.19",
4
4
  "description": "Utilities for GitSense Chat (GSC)",
5
5
  "main": "dist/gsc-utils.cjs.js",
6
6
  "module": "dist/gsc-utils.esm.js",
@@ -13,6 +13,7 @@
13
13
  const fs = require('fs').promises;
14
14
  const path = require('path');
15
15
  const { getAnalyzerInstructionsContent } = require('./instructionLoader');
16
+ const CodeBlockUtils = require('../CodeBlockUtils');
16
17
 
17
18
  /**
18
19
  * Reads and parses the config.json file in a directory.
@@ -110,10 +111,21 @@ async function getAnalyzers(analyzeMessagesBasePath, options = {}) {
110
111
  const analyzerId = `${analyzerName}::${contentType}::${instructionsType}`;
111
112
  const analyzerFullLabel = `${analyzerLabel} (${contentLabel} - ${instructionsLabel})`;
112
113
 
113
- let descriptionContent = null;
114
+ let description = null;
114
115
  if (includeDescription) {
115
116
  try {
116
- descriptionContent = await getAnalyzerInstructionsContent(analyzeMessagesBasePath, analyzerId);
117
+ const content = await getAnalyzerInstructionsContent(analyzeMessagesBasePath, analyzerId);
118
+ const { blocks, warnings } = CodeBlockUtils.extractCodeBlocks(content, { silent: true });
119
+ const jsonBlock = blocks.find(block => block.language === 'json');
120
+
121
+ if (jsonBlock && jsonBlock.content) {
122
+ try {
123
+ const json = JSON.parse(jsonBlock.content);
124
+ description = json.description;
125
+ } catch(error) {
126
+ console.warn(`${analyzerId} contains an invalid JSON`);
127
+ }
128
+ }
117
129
  } catch (descError) {
118
130
  console.warn(`Warning: Could not load description for ${analyzerId}: ${descError.message}`);
119
131
  descriptionContent = null;
@@ -125,7 +137,7 @@ async function getAnalyzers(analyzeMessagesBasePath, options = {}) {
125
137
  label: analyzerFullLabel,
126
138
  name: analyzerName,
127
139
  protected: analyzerConfig?.protected || false,
128
- ...(descriptionContent && { description: descriptionContent })
140
+ description
129
141
  });
130
142
  } catch (error) {
131
143
  // If 1.md doesn't exist, this is not a complete analyzer configuration, skip.
@@ -114,21 +114,22 @@ function formatToolBlock(toolData) {
114
114
  * @param {string} markdownContent - The original markdown string containing code blocks.
115
115
  * @param {string} toolName - The 'tool' property value of the target GitSense Chat Tool Block to replace.
116
116
  * @param {Object} newToolData - The new tool data object to insert into the block.
117
+ * @param {Object} CodeBlockUtils - The CodeBlockUtils class to avoid a circular dependency since we can't require it.
117
118
  * @returns {string} The markdown content with the specified tool block updated.
118
119
  * @throws {Error} If the target tool block is not found or if CodeBlockUtils encounters an error.
119
120
  */
120
- function replaceToolBlock(markdownContent, toolName, newToolData, processCodeBlocks, updateCodeBlockByIndex) {
121
+ function replaceToolBlock(markdownContent, toolName, newToolData, CodeBlockUtils) {
121
122
  if (typeof markdownContent !== 'string' || !toolName || !newToolData) {
122
123
  throw new Error("Missing required parameters for replaceToolBlock.");
123
124
  }
124
125
 
125
126
  // We can't require them as this will create a circular dependency
126
- if (!processCodeBlocks || !updateCodeBlockByIndex) {
127
- throw new Error("Missing required dependencies processCodeBlocks and/or updateCodeBlockByIndex.");
127
+ if (!CodeBlockUtils) {
128
+ throw new Error("Missing required CodeBlockUtils dependency");
128
129
  }
129
130
 
130
131
  // 1. Process the markdown content to find all code blocks
131
- const { blocks, warnings } = processCodeBlocks(markdownContent, { silent: true });
132
+ const { blocks, warnings } = CodeBlockUtils.processCodeBlocks(markdownContent, { silent: true });
132
133
 
133
134
  let targetBlockIndex = -1;
134
135
 
@@ -151,7 +152,7 @@ function replaceToolBlock(markdownContent, toolName, newToolData, processCodeBlo
151
152
 
152
153
  // 4. Use CodeBlockUtils.updateCodeBlockByIndex to perform the replacement
153
154
  // The language for GitSense Tool Blocks is always 'txt'
154
- const updatedMarkdown = updateCodeBlockByIndex(
155
+ const updatedMarkdown = CodeBlockUtils.updateCodeBlockByIndex(
155
156
  markdownContent,
156
157
  targetBlockIndex,
157
158
  newContentBetweenFences,