repoburg 1.3.11 → 1.3.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.
@@ -1,5 +1,9 @@
1
1
  import { applySnippetPatch } from './index';
2
2
  import * as path from 'path';
3
+ import {
4
+ SPECIAL_PATCH_BEGIN_FILE_MARKER,
5
+ SPECIAL_PATCH_END_FILE_MARKER,
6
+ } from '../../src/llm-orchestration/parser/parsing.constants';
3
7
 
4
8
  const TS_WASM_PATH = path.join(
5
9
  __dirname,
@@ -99,7 +103,7 @@ export { calculate };
99
103
  expect(normalize(result)).toEqual(normalize(expectedResult));
100
104
  });
101
105
 
102
- it('should replace a beginning of the file @begin-of-file', async () => {
106
+ it(`should replace a beginning of the file ${SPECIAL_PATCH_BEGIN_FILE_MARKER}`, async () => {
103
107
  const sourceCode = `
104
108
  import { ModuleA } from './moduleA';
105
109
  import { ModuleB } from './moduleB';
@@ -107,7 +111,7 @@ import { ModuleB } from './moduleB';
107
111
  console.log('starting up');
108
112
  `;
109
113
  const patchCode = `
110
- // @begin-of-file
114
+ // ${SPECIAL_PATCH_BEGIN_FILE_MARKER}
111
115
  import groupBy from 'lodash';
112
116
  import { ModuleA } from './moduleA';
113
117
  `;
@@ -122,7 +126,7 @@ console.log('starting up');
122
126
  expect(normalize(result)).toEqual(normalize(expectedResult));
123
127
  });
124
128
 
125
- it('should handle @begin-of-file marker with variations', async () => {
129
+ it(`should handle ${SPECIAL_PATCH_BEGIN_FILE_MARKER} marker with variations`, async () => {
126
130
  const sourceCode = `
127
131
  import { ModuleA } from './moduleA';
128
132
  import { ModuleB } from './moduleB';
@@ -130,7 +134,7 @@ import { ModuleB } from './moduleB';
130
134
  console.log('starting up');
131
135
  `;
132
136
  const patchCode = `
133
- //@begin-of-file extra text
137
+ //${SPECIAL_PATCH_BEGIN_FILE_MARKER} extra text
134
138
  import groupBy from 'lodash';
135
139
  import { ModuleA } from './moduleA';
136
140
  `;
@@ -145,7 +149,7 @@ console.log('starting up');
145
149
  expect(normalize(result)).toEqual(normalize(expectedResult));
146
150
  });
147
151
 
148
- it('should replace a end of the file @end-of-file', async () => {
152
+ it(`should replace a end of the file ${SPECIAL_PATCH_END_FILE_MARKER}`, async () => {
149
153
  const sourceCode = `
150
154
  import fs from 'fs';
151
155
 
@@ -158,7 +162,7 @@ export { calculate };
158
162
  const patchCode = `
159
163
  export { calculate };
160
164
  export { sum };
161
- // @end-of-file
165
+ // ${SPECIAL_PATCH_END_FILE_MARKER}
162
166
  `;
163
167
  const expectedResult = `
164
168
  import fs from 'fs';
@@ -174,7 +178,7 @@ export { sum };
174
178
  expect(normalize(result)).toEqual(normalize(expectedResult));
175
179
  });
176
180
 
177
- it('should handle @end-of-file marker with variations', async () => {
181
+ it(`should handle ${SPECIAL_PATCH_END_FILE_MARKER} marker with variations`, async () => {
178
182
  const sourceCode = `
179
183
  import fs from 'fs';
180
184
 
@@ -187,7 +191,7 @@ export { calculate };
187
191
  const patchCode = `
188
192
  export { calculate };
189
193
  export { sum };
190
- //@end-of-file some extra text
194
+ //${SPECIAL_PATCH_END_FILE_MARKER} some extra text
191
195
  `;
192
196
  const expectedResult = `
193
197
  import fs from 'fs';
@@ -576,4 +580,4 @@ export function TransactionsPage() {
576
580
  );
577
581
  expect(normalize(result)).toEqual(normalize(expectedResult));
578
582
  });
579
- });
583
+ });
@@ -5,6 +5,10 @@ import {
5
5
  handleEndOfFilePatch,
6
6
  handleStandardPatch,
7
7
  } from './patcher';
8
+ import {
9
+ SPECIAL_PATCH_BEGIN_FILE_MARKER,
10
+ SPECIAL_PATCH_END_FILE_MARKER,
11
+ } from '../../src/llm-orchestration/parser/parsing.constants';
8
12
 
9
13
  export async function applySnippetPatch(
10
14
  sourceCode: string,
@@ -27,8 +31,12 @@ export async function applySnippetPatch(
27
31
  };
28
32
  let processedPatchCode = patchCode;
29
33
 
30
- const beginOfFileRegex = /\/\/\s*@begin-of-file.*/;
31
- const endOfFileRegex = /\/\/\s*@end-of-file.*/;
34
+ const beginOfFileRegex = new RegExp(
35
+ `//\\s*${SPECIAL_PATCH_BEGIN_FILE_MARKER}.*`,
36
+ );
37
+ const endOfFileRegex = new RegExp(
38
+ `//\\s*${SPECIAL_PATCH_END_FILE_MARKER}.*`,
39
+ );
32
40
 
33
41
  const hasBeginOfFile = beginOfFileRegex.test(patchCode);
34
42
  const hasEndOfFile = endOfFileRegex.test(patchCode);
@@ -1,5 +1,9 @@
1
1
  import type { Token } from './types';
2
2
  import { findAllSequences, formatAnchor } from './tokens';
3
+ import {
4
+ SPECIAL_PATCH_BEGIN_FILE_MARKER,
5
+ SPECIAL_PATCH_END_FILE_MARKER,
6
+ } from '../../src/llm-orchestration/parser/parsing.constants';
3
7
 
4
8
  interface PatchResult {
5
9
  replaceStart: number;
@@ -60,7 +64,9 @@ export function handleBeginOfFilePatch(
60
64
  originalPatchTokens: Token[],
61
65
  ): PatchResult {
62
66
  if (originalPatchTokens.length === 0) {
63
- throw new Error('Patch is empty after removing @begin-of-file marker.');
67
+ throw new Error(
68
+ `Patch is empty after removing ${SPECIAL_PATCH_BEGIN_FILE_MARKER} marker.`,
69
+ );
64
70
  }
65
71
 
66
72
  let patchAttempt = [...originalPatchTokens];
@@ -83,7 +89,7 @@ export function handleBeginOfFilePatch(
83
89
  }
84
90
 
85
91
  throw new Error(
86
- `Failed to apply @begin-of-file patch. Could not find a unique anchor, even after trimming tokens. Last known error: ${lastError?.message}`,
92
+ `Failed to apply ${SPECIAL_PATCH_BEGIN_FILE_MARKER} patch. Could not find a unique anchor, even after trimming tokens. Last known error: ${lastError?.message}`,
87
93
  );
88
94
  }
89
95
 
@@ -134,7 +140,9 @@ export function handleEndOfFilePatch(
134
140
  sourceCode: string,
135
141
  ): PatchResult {
136
142
  if (originalPatchTokens.length === 0) {
137
- throw new Error('Patch is empty after removing @end-of-file marker.');
143
+ throw new Error(
144
+ `Patch is empty after removing ${SPECIAL_PATCH_END_FILE_MARKER} marker.`,
145
+ );
138
146
  }
139
147
 
140
148
  let patchAttempt = [...originalPatchTokens];
@@ -158,7 +166,7 @@ export function handleEndOfFilePatch(
158
166
  }
159
167
 
160
168
  throw new Error(
161
- `Failed to apply @end-of-file patch. Could not find a unique anchor, even after trimming tokens. Last known error: ${lastError?.message}`,
169
+ `Failed to apply ${SPECIAL_PATCH_END_FILE_MARKER} patch. Could not find a unique anchor, even after trimming tokens. Last known error: ${lastError?.message}`,
162
170
  );
163
171
  }
164
172
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repoburg",
3
- "version": "1.3.11",
3
+ "version": "1.3.12",
4
4
  "description": "A local AI-powered software developer assistant that runs on your own machine.",
5
5
  "author": "Celal Ertug",
6
6
  "license": "SEE LICENSE IN LICENSE",