@gitsense/gsc-utils 0.1.0 → 0.2.1

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.
@@ -530,13 +530,21 @@ function isNewAnalyzerChat(chat, model) {
530
530
  /**
531
531
  * Determines if the current chat session appears to be an "Analyze" session.
532
532
  * @param {object} chat - The chat object.
533
- * @param {string} model - Optional model.
534
533
  * @returns {boolean} True if the chat matches the Overview Builder pattern, false otherwise.
535
534
  */
536
- function isAnalyzeChat(chat, model) {
535
+ function isAnalyzeChat(chat) {
537
536
  return chat.type === 'analyze';
538
537
  }
539
538
 
539
+ /**
540
+ * Determines if the current chat session appears to be an "Analyze Builder" session.
541
+ * @param {object} chat - The chat object.
542
+ * @returns {boolean} True if the chat matches the Overview Builder pattern, false otherwise.
543
+ */
544
+ function isAnalyzeBuilderChat(chat) {
545
+ return chat.type === 'analyze-builder';
546
+ }
547
+
540
548
  /**
541
549
  * Determines if the current chat session appears to be an "Ask" session.
542
550
  * @param {object} chat - The chat object.
@@ -588,6 +596,7 @@ var ChatUtils$1 = {
588
596
  isAskChat,
589
597
  isNewAnalyzerChat,
590
598
  isAnalyzeChat,
599
+ isAnalyzeBuilderChat,
591
600
  isPlanChat,
592
601
  isCodeChat,
593
602
  getChatMessages: getChatMessages$1
@@ -6807,7 +6816,11 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
6807
6816
  // To keep things simple we are going to require the source and target header line count to be the same.
6808
6817
  // By doing so, we can can just add the line count to the hunks
6809
6818
  if (sourceHeaderLineCount !== targetHeaderLineCount) {
6810
- throw new Error('Source and target header line count must be the same');
6819
+ // Some LLMs will not generate a Parent-UUID for the first version so we won't make this
6820
+ // fatal if the sourceHeader does not have a Parent-UUID
6821
+ if (sourceHeaderLineCount.includes('Parent-UUID')) {
6822
+ throw new Error('Source and target header line count must be the same');
6823
+ }
6811
6824
  }
6812
6825
 
6813
6826
  const cleanSourceContent = sourceContent.trimEnd();
@@ -6817,7 +6830,7 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
6817
6830
  const unadjustedDiffPatch = jsdiff$1.createTwoFilesPatch('Original', 'Modified', cleanSourceContent, cleanTargetContent, '', '', { context: 3, stripTrailingCr: true });
6818
6831
 
6819
6832
  // 3. Post-process Diff to Adjust Line Numbers and Add NNN: Prefixes
6820
- const diffLines = unadjustedDiffPatch.split('\n');
6833
+ const diffLines = unadjustedDiffPatch.split('\n').filter(line => !line.includes('\'));
6821
6834
 
6822
6835
  for (let i = 0; i < diffLines.length; i++) {
6823
6836
  const line = diffLines[i];
@@ -6827,6 +6840,7 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
6827
6840
 
6828
6841
  // Hunk header: @@ -oldStart,oldCount +newStart,newCount @@
6829
6842
  const match = line.match(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
6843
+
6830
6844
  if (match) {
6831
6845
  let oldStart = parseInt(match[1], 10);
6832
6846
  let oldCount = match[2] ? parseInt(match[2], 10) : 1;
@@ -528,13 +528,21 @@ function isNewAnalyzerChat(chat, model) {
528
528
  /**
529
529
  * Determines if the current chat session appears to be an "Analyze" session.
530
530
  * @param {object} chat - The chat object.
531
- * @param {string} model - Optional model.
532
531
  * @returns {boolean} True if the chat matches the Overview Builder pattern, false otherwise.
533
532
  */
534
- function isAnalyzeChat(chat, model) {
533
+ function isAnalyzeChat(chat) {
535
534
  return chat.type === 'analyze';
536
535
  }
537
536
 
537
+ /**
538
+ * Determines if the current chat session appears to be an "Analyze Builder" session.
539
+ * @param {object} chat - The chat object.
540
+ * @returns {boolean} True if the chat matches the Overview Builder pattern, false otherwise.
541
+ */
542
+ function isAnalyzeBuilderChat(chat) {
543
+ return chat.type === 'analyze-builder';
544
+ }
545
+
538
546
  /**
539
547
  * Determines if the current chat session appears to be an "Ask" session.
540
548
  * @param {object} chat - The chat object.
@@ -586,6 +594,7 @@ var ChatUtils$1 = {
586
594
  isAskChat,
587
595
  isNewAnalyzerChat,
588
596
  isAnalyzeChat,
597
+ isAnalyzeBuilderChat,
589
598
  isPlanChat,
590
599
  isCodeChat,
591
600
  getChatMessages: getChatMessages$1
@@ -6805,7 +6814,11 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
6805
6814
  // To keep things simple we are going to require the source and target header line count to be the same.
6806
6815
  // By doing so, we can can just add the line count to the hunks
6807
6816
  if (sourceHeaderLineCount !== targetHeaderLineCount) {
6808
- throw new Error('Source and target header line count must be the same');
6817
+ // Some LLMs will not generate a Parent-UUID for the first version so we won't make this
6818
+ // fatal if the sourceHeader does not have a Parent-UUID
6819
+ if (sourceHeaderLineCount.includes('Parent-UUID')) {
6820
+ throw new Error('Source and target header line count must be the same');
6821
+ }
6809
6822
  }
6810
6823
 
6811
6824
  const cleanSourceContent = sourceContent.trimEnd();
@@ -6815,7 +6828,7 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
6815
6828
  const unadjustedDiffPatch = jsdiff$1.createTwoFilesPatch('Original', 'Modified', cleanSourceContent, cleanTargetContent, '', '', { context: 3, stripTrailingCr: true });
6816
6829
 
6817
6830
  // 3. Post-process Diff to Adjust Line Numbers and Add NNN: Prefixes
6818
- const diffLines = unadjustedDiffPatch.split('\n');
6831
+ const diffLines = unadjustedDiffPatch.split('\n').filter(line => !line.includes('\'));
6819
6832
 
6820
6833
  for (let i = 0; i < diffLines.length; i++) {
6821
6834
  const line = diffLines[i];
@@ -6825,6 +6838,7 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
6825
6838
 
6826
6839
  // Hunk header: @@ -oldStart,oldCount +newStart,newCount @@
6827
6840
  const match = line.match(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
6841
+
6828
6842
  if (match) {
6829
6843
  let oldStart = parseInt(match[1], 10);
6830
6844
  let oldCount = match[2] ? parseInt(match[2], 10) : 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitsense/gsc-utils",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Utilities for GitSense Chat (GSC)",
5
5
  "main": "dist/gsc-utils.cjs.js",
6
6
  "module": "dist/gsc-utils.esm.js",
package/src/ChatUtils.js CHANGED
@@ -62,13 +62,21 @@ function isNewAnalyzerChat(chat, model) {
62
62
  /**
63
63
  * Determines if the current chat session appears to be an "Analyze" session.
64
64
  * @param {object} chat - The chat object.
65
- * @param {string} model - Optional model.
66
65
  * @returns {boolean} True if the chat matches the Overview Builder pattern, false otherwise.
67
66
  */
68
- function isAnalyzeChat(chat, model) {
67
+ function isAnalyzeChat(chat) {
69
68
  return chat.type === 'analyze';
70
69
  }
71
70
 
71
+ /**
72
+ * Determines if the current chat session appears to be an "Analyze Builder" session.
73
+ * @param {object} chat - The chat object.
74
+ * @returns {boolean} True if the chat matches the Overview Builder pattern, false otherwise.
75
+ */
76
+ function isAnalyzeBuilderChat(chat) {
77
+ return chat.type === 'analyze-builder';
78
+ }
79
+
72
80
  /**
73
81
  * Determines if the current chat session appears to be an "Ask" session.
74
82
  * @param {object} chat - The chat object.
@@ -120,6 +128,7 @@ module.exports = {
120
128
  isAskChat,
121
129
  isNewAnalyzerChat,
122
130
  isAnalyzeChat,
131
+ isAnalyzeBuilderChat,
123
132
  isPlanChat,
124
133
  isCodeChat,
125
134
  getChatMessages
@@ -289,7 +289,11 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
289
289
  // To keep things simple we are going to require the source and target header line count to be the same.
290
290
  // By doing so, we can can just add the line count to the hunks
291
291
  if (sourceHeaderLineCount !== targetHeaderLineCount) {
292
- throw new Error('Source and target header line count must be the same');
292
+ // Some LLMs will not generate a Parent-UUID for the first version so we won't make this
293
+ // fatal if the sourceHeader does not have a Parent-UUID
294
+ if (sourceHeaderLineCount.includes('Parent-UUID')) {
295
+ throw new Error('Source and target header line count must be the same');
296
+ }
293
297
  }
294
298
 
295
299
  const cleanSourceContent = sourceContent.trimEnd();
@@ -299,7 +303,7 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
299
303
  const unadjustedDiffPatch = jsdiff.createTwoFilesPatch('Original', 'Modified', cleanSourceContent, cleanTargetContent, '', '', { context: 3, stripTrailingCr: true });
300
304
 
301
305
  // 3. Post-process Diff to Adjust Line Numbers and Add NNN: Prefixes
302
- const diffLines = unadjustedDiffPatch.split('\n');
306
+ const diffLines = unadjustedDiffPatch.split('\n').filter(line => !line.includes('\'));
303
307
  const outputLines = [];
304
308
  const outputDiffLines = [];
305
309
 
@@ -311,6 +315,7 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
311
315
 
312
316
  // Hunk header: @@ -oldStart,oldCount +newStart,newCount @@
313
317
  const match = line.match(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
318
+
314
319
  if (match) {
315
320
  let oldStart = parseInt(match[1], 10);
316
321
  let oldCount = match[2] ? parseInt(match[2], 10) : 1;