@gitsense/gsc-utils 0.1.0 → 0.2.0

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.
@@ -6807,7 +6807,11 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
6807
6807
  // To keep things simple we are going to require the source and target header line count to be the same.
6808
6808
  // By doing so, we can can just add the line count to the hunks
6809
6809
  if (sourceHeaderLineCount !== targetHeaderLineCount) {
6810
- throw new Error('Source and target header line count must be the same');
6810
+ // Some LLMs will not generate a Parent-UUID for the first version so we won't make this
6811
+ // fatal if the sourceHeader does not have a Parent-UUID
6812
+ if (sourceHeaderLineCount.includes('Parent-UUID')) {
6813
+ throw new Error('Source and target header line count must be the same');
6814
+ }
6811
6815
  }
6812
6816
 
6813
6817
  const cleanSourceContent = sourceContent.trimEnd();
@@ -6817,7 +6821,7 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
6817
6821
  const unadjustedDiffPatch = jsdiff$1.createTwoFilesPatch('Original', 'Modified', cleanSourceContent, cleanTargetContent, '', '', { context: 3, stripTrailingCr: true });
6818
6822
 
6819
6823
  // 3. Post-process Diff to Adjust Line Numbers and Add NNN: Prefixes
6820
- const diffLines = unadjustedDiffPatch.split('\n');
6824
+ const diffLines = unadjustedDiffPatch.split('\n').filter(line => !line.includes('\'));
6821
6825
 
6822
6826
  for (let i = 0; i < diffLines.length; i++) {
6823
6827
  const line = diffLines[i];
@@ -6827,6 +6831,7 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
6827
6831
 
6828
6832
  // Hunk header: @@ -oldStart,oldCount +newStart,newCount @@
6829
6833
  const match = line.match(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
6834
+
6830
6835
  if (match) {
6831
6836
  let oldStart = parseInt(match[1], 10);
6832
6837
  let oldCount = match[2] ? parseInt(match[2], 10) : 1;
@@ -6805,7 +6805,11 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
6805
6805
  // To keep things simple we are going to require the source and target header line count to be the same.
6806
6806
  // By doing so, we can can just add the line count to the hunks
6807
6807
  if (sourceHeaderLineCount !== targetHeaderLineCount) {
6808
- throw new Error('Source and target header line count must be the same');
6808
+ // Some LLMs will not generate a Parent-UUID for the first version so we won't make this
6809
+ // fatal if the sourceHeader does not have a Parent-UUID
6810
+ if (sourceHeaderLineCount.includes('Parent-UUID')) {
6811
+ throw new Error('Source and target header line count must be the same');
6812
+ }
6809
6813
  }
6810
6814
 
6811
6815
  const cleanSourceContent = sourceContent.trimEnd();
@@ -6815,7 +6819,7 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
6815
6819
  const unadjustedDiffPatch = jsdiff$1.createTwoFilesPatch('Original', 'Modified', cleanSourceContent, cleanTargetContent, '', '', { context: 3, stripTrailingCr: true });
6816
6820
 
6817
6821
  // 3. Post-process Diff to Adjust Line Numbers and Add NNN: Prefixes
6818
- const diffLines = unadjustedDiffPatch.split('\n');
6822
+ const diffLines = unadjustedDiffPatch.split('\n').filter(line => !line.includes('\'));
6819
6823
 
6820
6824
  for (let i = 0; i < diffLines.length; i++) {
6821
6825
  const line = diffLines[i];
@@ -6825,6 +6829,7 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
6825
6829
 
6826
6830
  // Hunk header: @@ -oldStart,oldCount +newStart,newCount @@
6827
6831
  const match = line.match(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
6832
+
6828
6833
  if (match) {
6829
6834
  let oldStart = parseInt(match[1], 10);
6830
6835
  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.0",
4
4
  "description": "Utilities for GitSense Chat (GSC)",
5
5
  "main": "dist/gsc-utils.cjs.js",
6
6
  "module": "dist/gsc-utils.esm.js",
@@ -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;