@gitsense/gsc-utils 0.2.29 → 0.2.31
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.
- package/dist/gsc-utils.cjs.js +217 -40
- package/dist/gsc-utils.esm.js +217 -40
- package/package.json +1 -1
- package/src/CodeBlockUtils/index.js +9 -5
- package/src/CodeBlockUtils/traceableCodeParser.js +140 -0
- package/src/GitSenseChatUtils.js +2 -0
- package/src/PatchUtils/constants.js +9 -5
- package/src/PatchUtils/patchExtractor.js +29 -7
- package/src/PatchUtils/patchParser.js +10 -6
- package/src/PatchUtils/patchProcessor.js +18 -15
package/dist/gsc-utils.cjs.js
CHANGED
|
@@ -1125,7 +1125,7 @@ var headerUtils = {
|
|
|
1125
1125
|
* @param {string} text - The input text
|
|
1126
1126
|
* @returns {Object} Object containing arrays of opening and closing fence positions: { openingPositions: Array, closingPositions: Array }
|
|
1127
1127
|
*/
|
|
1128
|
-
function findAllCodeFences$
|
|
1128
|
+
function findAllCodeFences$5(text) {
|
|
1129
1129
|
const openingPositions = [];
|
|
1130
1130
|
const closingPositions = [];
|
|
1131
1131
|
|
|
@@ -1359,7 +1359,7 @@ function findCodeBlockByUUID$2(messageText, blockUUID) {
|
|
|
1359
1359
|
}
|
|
1360
1360
|
|
|
1361
1361
|
var blockExtractor = {
|
|
1362
|
-
findAllCodeFences: findAllCodeFences$
|
|
1362
|
+
findAllCodeFences: findAllCodeFences$5,
|
|
1363
1363
|
matchFencesAndExtractBlocks: matchFencesAndExtractBlocks$4,
|
|
1364
1364
|
extractCodeBlocksWithUUIDs: extractCodeBlocksWithUUIDs$1,
|
|
1365
1365
|
findCodeBlockByUUID: findCodeBlockByUUID$2
|
|
@@ -1542,13 +1542,13 @@ var versionUtils = {
|
|
|
1542
1542
|
|
|
1543
1543
|
/**
|
|
1544
1544
|
* Component: PatchUtils Constants
|
|
1545
|
-
* Block-UUID:
|
|
1546
|
-
* Parent-UUID:
|
|
1547
|
-
* Version: 2.
|
|
1548
|
-
* Description: Contains shared constants and regular expressions used by the enhanced patch utilities.
|
|
1545
|
+
* Block-UUID: 83ba7eaa-36b3-41f3-bd07-130c0266301e
|
|
1546
|
+
* Parent-UUID: c6747054-2c8b-461f-910d-0fd725d9a350
|
|
1547
|
+
* Version: 2.2.0
|
|
1548
|
+
* Description: Contains shared constants and regular expressions used by the enhanced patch utilities. Updated required metadata fields to include Component, Language, and Created-at.
|
|
1549
1549
|
* Language: JavaScript
|
|
1550
1550
|
* Created-at: 2025-05-14T16:55:00.000Z
|
|
1551
|
-
* Authors: Gemini 2.5 Flash Thinking (v1.0.0), Claude 3.7 Sonnet (v2.0.0), Qwen 3 Coder 480B - Cerebras (v2.1.0)
|
|
1551
|
+
* Authors: Gemini 2.5 Flash Thinking (v1.0.0), Claude 3.7 Sonnet (v2.0.0), Qwen 3 Coder 480B - Cerebras (v2.1.0), GLM-4.7 (v2.2.0)
|
|
1552
1552
|
*/
|
|
1553
1553
|
|
|
1554
1554
|
// Traditional patch markers
|
|
@@ -1578,13 +1578,13 @@ var constants$2 = {
|
|
|
1578
1578
|
|
|
1579
1579
|
/**
|
|
1580
1580
|
* Component: PatchUtils Parser
|
|
1581
|
-
|
|
1582
|
-
* Parent-UUID:
|
|
1583
|
-
* Version: 1.
|
|
1584
|
-
* Description: Handles parsing, validation, extraction, and detection of traditional unified diff patches and abbreviated patches. Extracts metadata and raw diff content.
|
|
1581
|
+
* Block-UUID: 334a0473-da2d-4859-b8a5-f867e3d88a28
|
|
1582
|
+
* Parent-UUID: ce634df9-ff99-482a-a261-56ab34a2546e
|
|
1583
|
+
* Version: 1.3.0
|
|
1584
|
+
* Description: Handles parsing, validation, extraction, and detection of traditional unified diff patches and abbreviated patches. Extracts metadata and raw diff content. Updated validation to require Component and Language.
|
|
1585
1585
|
* Language: JavaScript
|
|
1586
1586
|
* Created-at: 2025-04-18T02:59:04.322Z
|
|
1587
|
-
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Qwen 3 Coder 480B - Cerebras (v1.2.0)
|
|
1587
|
+
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Qwen 3 Coder 480B - Cerebras (v1.2.0), GLM-4.7 (v1.3.0)
|
|
1588
1588
|
*/
|
|
1589
1589
|
|
|
1590
1590
|
const { isValidVersion } = versionUtils; // Assuming SharedUtils is one level up
|
|
@@ -1689,13 +1689,17 @@ function extractPatchMetadata$1(patchText) {
|
|
|
1689
1689
|
*/
|
|
1690
1690
|
function validatePatchMetadata$1(metadata) {
|
|
1691
1691
|
const errors = [];
|
|
1692
|
+
// Updated to include Component and Language
|
|
1692
1693
|
const requiredFields = [
|
|
1694
|
+
'Component',
|
|
1693
1695
|
'Source-Block-UUID',
|
|
1694
1696
|
'Target-Block-UUID',
|
|
1695
1697
|
'Source-Version',
|
|
1696
1698
|
'Target-Version',
|
|
1697
1699
|
'Description',
|
|
1698
|
-
'
|
|
1700
|
+
'Language',
|
|
1701
|
+
'Authors',
|
|
1702
|
+
'Created-at'
|
|
1699
1703
|
];
|
|
1700
1704
|
|
|
1701
1705
|
for (const field of requiredFields) {
|
|
@@ -6677,13 +6681,13 @@ function escapeHTML(s) {
|
|
|
6677
6681
|
|
|
6678
6682
|
/**
|
|
6679
6683
|
* Component: PatchUtils Processor
|
|
6680
|
-
* Block-UUID:
|
|
6681
|
-
* Parent-UUID:
|
|
6682
|
-
* Version: 1.
|
|
6683
|
-
* Description: Handles applying, creating, and converting patches. Applies traditional unified diffs, cleaning line number prefixes from diff content before using jsdiff.
|
|
6684
|
+
* Block-UUID: 58698895-c540-4be0-94b0-53dfcd0e1235
|
|
6685
|
+
* Parent-UUID: 96ec8bca-9fc3-441b-b81f-6fefc840c626
|
|
6686
|
+
* Version: 1.4.0
|
|
6687
|
+
* Description: Handles applying, creating, and converting patches. Applies traditional unified diffs, cleaning line number prefixes from diff content before using jsdiff. Updated patch metadata formatting to include Component, Language, and Created-at.
|
|
6684
6688
|
* Language: JavaScript
|
|
6685
6689
|
* Created-at: 2025-07-20T17:24:16.836Z
|
|
6686
|
-
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Claude 3.7 Sonnet (v1.2.0), Gemini 2.5 Flash (v1.2.0), Gemini 2.5 Flash Thinking (v1.3.0)
|
|
6690
|
+
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Claude 3.7 Sonnet (v1.2.0), Gemini 2.5 Flash (v1.2.0), Gemini 2.5 Flash Thinking (v1.3.0), GLM-4.7 (v1.4.0)
|
|
6687
6691
|
*/
|
|
6688
6692
|
|
|
6689
6693
|
const parser$1 = patchParser;
|
|
@@ -6978,9 +6982,9 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
|
|
|
6978
6982
|
// 4. Assemble Final Patch
|
|
6979
6983
|
const formattedMetadata = _formatPatchMetadata(patchMetadata);
|
|
6980
6984
|
const formatted = `${formattedMetadata}\n\n\n`+
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6985
|
+
`# --- PATCH START MARKER ---\n`+
|
|
6986
|
+
`${adjustedDiffPatch}\n`+
|
|
6987
|
+
`# --- PATCH END MARKER ---`;
|
|
6984
6988
|
|
|
6985
6989
|
return {
|
|
6986
6990
|
formatted,
|
|
@@ -6997,12 +7001,18 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
|
|
|
6997
7001
|
* @private
|
|
6998
7002
|
*/
|
|
6999
7003
|
function _formatPatchMetadata(metadata) {
|
|
7000
|
-
// --- Function body from original PatchUtils._formatPatchMetadata ---
|
|
7001
|
-
// --- (Copied Verbatim) ---
|
|
7002
7004
|
const lines = ['# Patch Metadata'];
|
|
7005
|
+
// Updated order to match system prompt requirements
|
|
7003
7006
|
const metadataOrder = [
|
|
7004
|
-
'
|
|
7005
|
-
'
|
|
7007
|
+
'Component',
|
|
7008
|
+
'Source-Block-UUID',
|
|
7009
|
+
'Target-Block-UUID',
|
|
7010
|
+
'Source-Version',
|
|
7011
|
+
'Target-Version',
|
|
7012
|
+
'Description',
|
|
7013
|
+
'Language',
|
|
7014
|
+
'Created-at',
|
|
7015
|
+
'Authors'
|
|
7006
7016
|
];
|
|
7007
7017
|
|
|
7008
7018
|
// Add ordered metadata
|
|
@@ -7020,7 +7030,6 @@ function _formatPatchMetadata(metadata) {
|
|
|
7020
7030
|
}
|
|
7021
7031
|
|
|
7022
7032
|
return lines.join('\n');
|
|
7023
|
-
// --- End of Function Body ---
|
|
7024
7033
|
}
|
|
7025
7034
|
|
|
7026
7035
|
var patchProcessor = {
|
|
@@ -8097,13 +8106,13 @@ var diagnosticReporter$1 = {
|
|
|
8097
8106
|
|
|
8098
8107
|
/**
|
|
8099
8108
|
* Component: PatchUtils Patch Extractor
|
|
8100
|
-
* Block-UUID:
|
|
8101
|
-
* Parent-UUID:
|
|
8102
|
-
* Version: 1.
|
|
8103
|
-
* Description: Extracts individual hunks from a patch and cleans line numbers from content.
|
|
8109
|
+
* Block-UUID: d937fa30-196e-4221-9508-717f509f43d4
|
|
8110
|
+
* Parent-UUID: ad8cda91-244b-4f47-9847-d6c0d93424fc
|
|
8111
|
+
* Version: 1.1.0
|
|
8112
|
+
* Description: Extracts individual hunks from a patch and cleans line numbers from content. Updated reconstructPatch to format metadata in the specific order required by the system prompt.
|
|
8104
8113
|
* Language: JavaScript
|
|
8105
8114
|
* Created-at: 2025-05-14T16:50:00.000Z
|
|
8106
|
-
* Authors: Claude 3.7 Sonnet (v1.0.0)
|
|
8115
|
+
* Authors: Claude 3.7 Sonnet (v1.0.0), GLM-4.7 (v1.1.0)
|
|
8107
8116
|
*/
|
|
8108
8117
|
|
|
8109
8118
|
const { removeLineNumbers: removeLineNumbers$4 } = lineNumberFormatter;
|
|
@@ -8243,11 +8252,33 @@ function extractAndCleanHunks$1(patchText) {
|
|
|
8243
8252
|
* @returns {string} Reconstructed patch
|
|
8244
8253
|
*/
|
|
8245
8254
|
function reconstructPatch$1(metadata, hunks) {
|
|
8246
|
-
// Format metadata
|
|
8255
|
+
// Format metadata in the specific order required by the system prompt
|
|
8247
8256
|
let result = '# Patch Metadata\n';
|
|
8257
|
+
|
|
8258
|
+
const metadataOrder = [
|
|
8259
|
+
'Component',
|
|
8260
|
+
'Source-Block-UUID',
|
|
8261
|
+
'Target-Block-UUID',
|
|
8262
|
+
'Source-Version',
|
|
8263
|
+
'Target-Version',
|
|
8264
|
+
'Description',
|
|
8265
|
+
'Language',
|
|
8266
|
+
'Created-at',
|
|
8267
|
+
'Authors'
|
|
8268
|
+
];
|
|
8269
|
+
|
|
8270
|
+
// Add ordered metadata
|
|
8271
|
+
metadataOrder.forEach(key => {
|
|
8272
|
+
if (metadata[key]) {
|
|
8273
|
+
result += `# ${key}: ${metadata[key]}\n`;
|
|
8274
|
+
}
|
|
8275
|
+
});
|
|
8248
8276
|
|
|
8277
|
+
// Add any other metadata not in the preferred order
|
|
8249
8278
|
for (const [key, value] of Object.entries(metadata)) {
|
|
8250
|
-
|
|
8279
|
+
if (!metadataOrder.includes(key)) {
|
|
8280
|
+
result += `# ${key}: ${value}\n`;
|
|
8281
|
+
}
|
|
8251
8282
|
}
|
|
8252
8283
|
|
|
8253
8284
|
// Add patch markers and hunks
|
|
@@ -9442,7 +9473,7 @@ var JsonUtils$2 = {
|
|
|
9442
9473
|
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Gemini 2.5 Pro (v1.2.0), Gemini 2.5 Flash Thinking (v1.3.0), Gemini 2.5 Flash Thinking (v1.4.0), Qwen 3 Coder 480B - Cerebras (v1.5.0)
|
|
9443
9474
|
*/
|
|
9444
9475
|
|
|
9445
|
-
const { findAllCodeFences: findAllCodeFences$
|
|
9476
|
+
const { findAllCodeFences: findAllCodeFences$4, matchFencesAndExtractBlocks: matchFencesAndExtractBlocks$3 } = blockExtractor;
|
|
9446
9477
|
const { parseHeader: parseHeader$2 } = headerUtils;
|
|
9447
9478
|
const { validateUUID: validateUUID$2 } = uuidUtils;
|
|
9448
9479
|
const AnalysisBlockUtils$2 = AnalysisBlockUtils$3;
|
|
@@ -9797,7 +9828,7 @@ function processCodeBlocks$5(text, options = { silent: false, validatePatches: f
|
|
|
9797
9828
|
}
|
|
9798
9829
|
|
|
9799
9830
|
// Step 1: Find all fence positions
|
|
9800
|
-
const { openingPositions, closingPositions } = findAllCodeFences$
|
|
9831
|
+
const { openingPositions, closingPositions } = findAllCodeFences$4(text);
|
|
9801
9832
|
|
|
9802
9833
|
// Step 2: Match fences to get potential block boundaries
|
|
9803
9834
|
const { completeBlocks, incompleteBlocks, warnings: extractorWarnings } = matchFencesAndExtractBlocks$3(
|
|
@@ -10429,6 +10460,146 @@ Plain text block.
|
|
|
10429
10460
|
// (Removed the check `if (typeof module !== 'undefined' && module.exports)` as it's standard in Node)
|
|
10430
10461
|
var markerRemover = { removeCodeBlockMarkers: removeCodeBlockMarkers$2 };
|
|
10431
10462
|
|
|
10463
|
+
/**
|
|
10464
|
+
* Component: CodeBlockUtils Traceable Code Parser
|
|
10465
|
+
* Block-UUID: 8a4b2c1d-9e6f-4a3b-8c7d-1e2f3a4b5c6d
|
|
10466
|
+
* Parent-UUID: N/A
|
|
10467
|
+
* Version: 1.0.0
|
|
10468
|
+
* Description: Parses the `Traceable Code` metadata lines preceding code blocks to extract pre-generated UUIDs and version flags for backend validation.
|
|
10469
|
+
* Language: JavaScript
|
|
10470
|
+
* Created-at: 2026-01-26T17:50:00.000Z
|
|
10471
|
+
* Authors: GLM-4.7 (v1.0.0)
|
|
10472
|
+
*/
|
|
10473
|
+
|
|
10474
|
+
const { findAllCodeFences: findAllCodeFences$3 } = blockExtractor;
|
|
10475
|
+
|
|
10476
|
+
/**
|
|
10477
|
+
* Parses `Traceable Code` metadata lines for all code blocks found in a message.
|
|
10478
|
+
* It scans the text for code blocks and looks for the specific traceable header
|
|
10479
|
+
* immediately preceding each block.
|
|
10480
|
+
*
|
|
10481
|
+
* @param {string} messageText - The full message text containing code blocks.
|
|
10482
|
+
* @param {Object} [options] - Optional configuration.
|
|
10483
|
+
* @param {boolean} [options.silent=true] - If false, logs warnings to console.
|
|
10484
|
+
* @returns {TraceableCodeParseResult[]} An array of results, where each index
|
|
10485
|
+
* corresponds to a code block found in the message.
|
|
10486
|
+
*/
|
|
10487
|
+
function parseTraceableCodeHeaders$2(messageText, options = { silent: true }) {
|
|
10488
|
+
if (typeof messageText !== 'string') {
|
|
10489
|
+
if (!options.silent) {
|
|
10490
|
+
console.warn('parseTraceableCodeHeaders: messageText must be a string.');
|
|
10491
|
+
}
|
|
10492
|
+
return [];
|
|
10493
|
+
}
|
|
10494
|
+
|
|
10495
|
+
// Step 1: Find all code fence positions
|
|
10496
|
+
const { openingPositions } = findAllCodeFences$3(messageText);
|
|
10497
|
+
const results = [];
|
|
10498
|
+
|
|
10499
|
+
// Step 2: Iterate through each code block to find its preceding traceable line
|
|
10500
|
+
openingPositions.forEach((fence, index) => {
|
|
10501
|
+
const textBeforeFence = messageText.substring(0, fence.position);
|
|
10502
|
+
const lines = textBeforeFence.split('\n');
|
|
10503
|
+
|
|
10504
|
+
let foundLine = null;
|
|
10505
|
+
let searchLimit = 10; // Look back up to 10 lines to find the header
|
|
10506
|
+
|
|
10507
|
+
// Iterate backwards from the fence
|
|
10508
|
+
for (let i = lines.length - 1; i >= 0 && searchLimit > 0; i--) {
|
|
10509
|
+
const line = lines[i].trim();
|
|
10510
|
+
|
|
10511
|
+
// Skip file path lines (e.g., `path/to/file.js`)
|
|
10512
|
+
if (line.startsWith('`') && line.endsWith('`')) {
|
|
10513
|
+
continue;
|
|
10514
|
+
}
|
|
10515
|
+
|
|
10516
|
+
// Skip empty lines
|
|
10517
|
+
if (line === '') {
|
|
10518
|
+
continue;
|
|
10519
|
+
}
|
|
10520
|
+
|
|
10521
|
+
// Check for the traceable code marker
|
|
10522
|
+
if (line.includes('**Traceable Code:**')) {
|
|
10523
|
+
foundLine = line;
|
|
10524
|
+
break;
|
|
10525
|
+
}
|
|
10526
|
+
}
|
|
10527
|
+
|
|
10528
|
+
if (foundLine) {
|
|
10529
|
+
const parsedData = parseTraceableLine(foundLine);
|
|
10530
|
+
results.push({
|
|
10531
|
+
blockIndex: index,
|
|
10532
|
+
found: true,
|
|
10533
|
+
rawLine: foundLine,
|
|
10534
|
+
data: parsedData.data,
|
|
10535
|
+
errors: parsedData.errors
|
|
10536
|
+
});
|
|
10537
|
+
} else {
|
|
10538
|
+
results.push({
|
|
10539
|
+
blockIndex: index,
|
|
10540
|
+
found: false,
|
|
10541
|
+
rawLine: null,
|
|
10542
|
+
data: null,
|
|
10543
|
+
errors: []
|
|
10544
|
+
});
|
|
10545
|
+
}
|
|
10546
|
+
});
|
|
10547
|
+
|
|
10548
|
+
return results;
|
|
10549
|
+
}
|
|
10550
|
+
|
|
10551
|
+
/**
|
|
10552
|
+
* Internal helper to parse a single traceable code line.
|
|
10553
|
+
* @param {string} line - The raw line containing the traceable code metadata.
|
|
10554
|
+
* @returns {Object} { data: Object, errors: Array }
|
|
10555
|
+
*/
|
|
10556
|
+
function parseTraceableLine(line) {
|
|
10557
|
+
// Helper to extract value for a specific key
|
|
10558
|
+
// Handles keys like **Key:** value, ignoring HTML entities like
|
|
10559
|
+
const extract = (key) => {
|
|
10560
|
+
// Regex matches **Key:** followed by any characters until the next ** or end of line
|
|
10561
|
+
// We strip HTML entities and extra whitespace from the result
|
|
10562
|
+
const regex = new RegExp(`\\*\\*${key}:\\*\\*\\s*([^*]+)`, 'i');
|
|
10563
|
+
const match = line.match(regex);
|
|
10564
|
+
if (match) {
|
|
10565
|
+
return match[1].trim().replace(/ /g, '').trim();
|
|
10566
|
+
}
|
|
10567
|
+
return null;
|
|
10568
|
+
};
|
|
10569
|
+
|
|
10570
|
+
const isTraceableStr = extract('Traceable Code');
|
|
10571
|
+
const isNewVersionStr = extract('New Version');
|
|
10572
|
+
const currentParentUUID = extract('Current Parent-UUID');
|
|
10573
|
+
const newParentUUID = extract('New Parent-UUID');
|
|
10574
|
+
const newBlockUUID = extract('New Block-UUID');
|
|
10575
|
+
|
|
10576
|
+
const errors = [];
|
|
10577
|
+
|
|
10578
|
+
// Basic validation of extracted values
|
|
10579
|
+
if (!isTraceableStr || !['Yes', 'No'].includes(isTraceableStr)) {
|
|
10580
|
+
errors.push({ type: 'invalid_value', message: 'Invalid or missing Traceable Code value (expected Yes/No).' });
|
|
10581
|
+
}
|
|
10582
|
+
|
|
10583
|
+
if (!isNewVersionStr || !['Yes', 'No', 'N/A'].includes(isNewVersionStr)) {
|
|
10584
|
+
errors.push({ type: 'invalid_value', message: 'Invalid or missing New Version value (expected Yes/No/N/A).' });
|
|
10585
|
+
}
|
|
10586
|
+
|
|
10587
|
+
return {
|
|
10588
|
+
data: {
|
|
10589
|
+
isTraceable: isTraceableStr === 'Yes',
|
|
10590
|
+
isNewVersion: isNewVersionStr === 'Yes',
|
|
10591
|
+
currentParentUUID: currentParentUUID,
|
|
10592
|
+
newParentUUID: newParentUUID,
|
|
10593
|
+
newBlockUUID: newBlockUUID
|
|
10594
|
+
},
|
|
10595
|
+
errors: errors
|
|
10596
|
+
};
|
|
10597
|
+
}
|
|
10598
|
+
|
|
10599
|
+
var traceableCodeParser = {
|
|
10600
|
+
parseTraceableCodeHeaders: parseTraceableCodeHeaders$2
|
|
10601
|
+
};
|
|
10602
|
+
|
|
10432
10603
|
/**
|
|
10433
10604
|
* Component: CodeBlockUtils Update Code Block
|
|
10434
10605
|
* Block-UUID: 6a7b8c9d-0e1f-42a3-b4c5-d6e7f8a9b0c1
|
|
@@ -10801,13 +10972,13 @@ var lineageTracer = {
|
|
|
10801
10972
|
|
|
10802
10973
|
/**
|
|
10803
10974
|
* Component: CodeBlockUtils Index
|
|
10804
|
-
* Block-UUID:
|
|
10805
|
-
* Parent-UUID:
|
|
10806
|
-
* Version: 1.
|
|
10975
|
+
* Block-UUID: bf718ee3-fdb2-4fd1-85b8-418b24291179
|
|
10976
|
+
* Parent-UUID: 98684aa5-d597-41b6-a7fd-cc16482aafdc
|
|
10977
|
+
* Version: 1.6.0
|
|
10807
10978
|
* Description: Aggregates and exports all utilities related to code block processing from the CodeBlockUtils module. Serves as the main entry point for this module.
|
|
10808
10979
|
* Language: JavaScript
|
|
10809
|
-
* Created-at:
|
|
10810
|
-
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Claude 3.7 Sonnet (v1.2.0), Gemini 2.5 Pro (v1.3.0), Gemini 2.5 Flash Thinking (v1.4.0), Qwen 3 Coder 480B - Cerebras (v1.5.0)
|
|
10980
|
+
* Created-at: 2026-01-26T17:51:57.427Z
|
|
10981
|
+
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Claude 3.7 Sonnet (v1.2.0), Gemini 2.5 Pro (v1.3.0), Gemini 2.5 Flash Thinking (v1.4.0), Qwen 3 Coder 480B - Cerebras (v1.5.0), GLM-4.7 (v1.6.0)
|
|
10811
10982
|
*/
|
|
10812
10983
|
|
|
10813
10984
|
// Import from individual utility files
|
|
@@ -10821,6 +10992,7 @@ const { detectCodeBlockRelationships: detectCodeBlockRelationships$1, detectInco
|
|
|
10821
10992
|
const { extractContinuationInfo: extractContinuationInfo$1, generateContinuationPrompt: generateContinuationPrompt$1 } = continuationUtils;
|
|
10822
10993
|
const { parseCodeBlocks: parseCommentDelimitedBlocks$1 } = headerParser;
|
|
10823
10994
|
const { removeCodeBlockMarkers: removeCodeBlockMarkers$1 } = markerRemover;
|
|
10995
|
+
const { parseTraceableCodeHeaders: parseTraceableCodeHeaders$1 } = traceableCodeParser;
|
|
10824
10996
|
const { updateCodeBlockByIndex: updateCodeBlockByIndex$1, updateCodeBlockByUUID, updateCodeBlock, updateCodeBlockInMessage, deleteCodeBlockByIndex: deleteCodeBlockByIndex$1 } = updateCodeBlock_1;
|
|
10825
10997
|
const { formatWithLineNumbers: formatWithLineNumbers$1, formatBlockWithLineNumbers: formatBlockWithLineNumbers$1, formatBlocksWithLineNumbers: formatBlocksWithLineNumbers$1, removeLineNumbers: removeLineNumbers$1 } = lineNumberFormatter;
|
|
10826
10998
|
const { getLineage: getLineage$1 } = lineageTracer;
|
|
@@ -10868,6 +11040,9 @@ var CodeBlockUtils$7 = {
|
|
|
10868
11040
|
// Marker Removal
|
|
10869
11041
|
removeCodeBlockMarkers: removeCodeBlockMarkers$1,
|
|
10870
11042
|
|
|
11043
|
+
// Traceable Code Parsing
|
|
11044
|
+
parseTraceableCodeHeaders: parseTraceableCodeHeaders$1,
|
|
11045
|
+
|
|
10871
11046
|
// Code Block Updating Utilities
|
|
10872
11047
|
updateCodeBlockByIndex: updateCodeBlockByIndex$1,
|
|
10873
11048
|
updateCodeBlockByUUID,
|
|
@@ -26287,6 +26462,7 @@ const {
|
|
|
26287
26462
|
updateCodeBlockByIndex,
|
|
26288
26463
|
deleteCodeBlockByIndex,
|
|
26289
26464
|
getLineage,
|
|
26465
|
+
parseTraceableCodeHeaders,
|
|
26290
26466
|
} = CodeBlockUtils;
|
|
26291
26467
|
|
|
26292
26468
|
const {
|
|
@@ -26644,6 +26820,7 @@ var GitSenseChatUtils_1 = {
|
|
|
26644
26820
|
formatBlockWithLineNumbers,
|
|
26645
26821
|
formatBlocksWithLineNumbers,
|
|
26646
26822
|
removeLineNumbers,
|
|
26823
|
+
parseTraceableCodeHeaders,
|
|
26647
26824
|
|
|
26648
26825
|
// Other Utilities (from CodeBlockUtils)
|
|
26649
26826
|
removeCodeBlockMarkers,
|
package/dist/gsc-utils.esm.js
CHANGED
|
@@ -1123,7 +1123,7 @@ var headerUtils = {
|
|
|
1123
1123
|
* @param {string} text - The input text
|
|
1124
1124
|
* @returns {Object} Object containing arrays of opening and closing fence positions: { openingPositions: Array, closingPositions: Array }
|
|
1125
1125
|
*/
|
|
1126
|
-
function findAllCodeFences$
|
|
1126
|
+
function findAllCodeFences$5(text) {
|
|
1127
1127
|
const openingPositions = [];
|
|
1128
1128
|
const closingPositions = [];
|
|
1129
1129
|
|
|
@@ -1357,7 +1357,7 @@ function findCodeBlockByUUID$2(messageText, blockUUID) {
|
|
|
1357
1357
|
}
|
|
1358
1358
|
|
|
1359
1359
|
var blockExtractor = {
|
|
1360
|
-
findAllCodeFences: findAllCodeFences$
|
|
1360
|
+
findAllCodeFences: findAllCodeFences$5,
|
|
1361
1361
|
matchFencesAndExtractBlocks: matchFencesAndExtractBlocks$4,
|
|
1362
1362
|
extractCodeBlocksWithUUIDs: extractCodeBlocksWithUUIDs$1,
|
|
1363
1363
|
findCodeBlockByUUID: findCodeBlockByUUID$2
|
|
@@ -1540,13 +1540,13 @@ var versionUtils = {
|
|
|
1540
1540
|
|
|
1541
1541
|
/**
|
|
1542
1542
|
* Component: PatchUtils Constants
|
|
1543
|
-
* Block-UUID:
|
|
1544
|
-
* Parent-UUID:
|
|
1545
|
-
* Version: 2.
|
|
1546
|
-
* Description: Contains shared constants and regular expressions used by the enhanced patch utilities.
|
|
1543
|
+
* Block-UUID: 83ba7eaa-36b3-41f3-bd07-130c0266301e
|
|
1544
|
+
* Parent-UUID: c6747054-2c8b-461f-910d-0fd725d9a350
|
|
1545
|
+
* Version: 2.2.0
|
|
1546
|
+
* Description: Contains shared constants and regular expressions used by the enhanced patch utilities. Updated required metadata fields to include Component, Language, and Created-at.
|
|
1547
1547
|
* Language: JavaScript
|
|
1548
1548
|
* Created-at: 2025-05-14T16:55:00.000Z
|
|
1549
|
-
* Authors: Gemini 2.5 Flash Thinking (v1.0.0), Claude 3.7 Sonnet (v2.0.0), Qwen 3 Coder 480B - Cerebras (v2.1.0)
|
|
1549
|
+
* Authors: Gemini 2.5 Flash Thinking (v1.0.0), Claude 3.7 Sonnet (v2.0.0), Qwen 3 Coder 480B - Cerebras (v2.1.0), GLM-4.7 (v2.2.0)
|
|
1550
1550
|
*/
|
|
1551
1551
|
|
|
1552
1552
|
// Traditional patch markers
|
|
@@ -1576,13 +1576,13 @@ var constants$2 = {
|
|
|
1576
1576
|
|
|
1577
1577
|
/**
|
|
1578
1578
|
* Component: PatchUtils Parser
|
|
1579
|
-
|
|
1580
|
-
* Parent-UUID:
|
|
1581
|
-
* Version: 1.
|
|
1582
|
-
* Description: Handles parsing, validation, extraction, and detection of traditional unified diff patches and abbreviated patches. Extracts metadata and raw diff content.
|
|
1579
|
+
* Block-UUID: 334a0473-da2d-4859-b8a5-f867e3d88a28
|
|
1580
|
+
* Parent-UUID: ce634df9-ff99-482a-a261-56ab34a2546e
|
|
1581
|
+
* Version: 1.3.0
|
|
1582
|
+
* Description: Handles parsing, validation, extraction, and detection of traditional unified diff patches and abbreviated patches. Extracts metadata and raw diff content. Updated validation to require Component and Language.
|
|
1583
1583
|
* Language: JavaScript
|
|
1584
1584
|
* Created-at: 2025-04-18T02:59:04.322Z
|
|
1585
|
-
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Qwen 3 Coder 480B - Cerebras (v1.2.0)
|
|
1585
|
+
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Qwen 3 Coder 480B - Cerebras (v1.2.0), GLM-4.7 (v1.3.0)
|
|
1586
1586
|
*/
|
|
1587
1587
|
|
|
1588
1588
|
const { isValidVersion } = versionUtils; // Assuming SharedUtils is one level up
|
|
@@ -1687,13 +1687,17 @@ function extractPatchMetadata$1(patchText) {
|
|
|
1687
1687
|
*/
|
|
1688
1688
|
function validatePatchMetadata$1(metadata) {
|
|
1689
1689
|
const errors = [];
|
|
1690
|
+
// Updated to include Component and Language
|
|
1690
1691
|
const requiredFields = [
|
|
1692
|
+
'Component',
|
|
1691
1693
|
'Source-Block-UUID',
|
|
1692
1694
|
'Target-Block-UUID',
|
|
1693
1695
|
'Source-Version',
|
|
1694
1696
|
'Target-Version',
|
|
1695
1697
|
'Description',
|
|
1696
|
-
'
|
|
1698
|
+
'Language',
|
|
1699
|
+
'Authors',
|
|
1700
|
+
'Created-at'
|
|
1697
1701
|
];
|
|
1698
1702
|
|
|
1699
1703
|
for (const field of requiredFields) {
|
|
@@ -6675,13 +6679,13 @@ function escapeHTML(s) {
|
|
|
6675
6679
|
|
|
6676
6680
|
/**
|
|
6677
6681
|
* Component: PatchUtils Processor
|
|
6678
|
-
* Block-UUID:
|
|
6679
|
-
* Parent-UUID:
|
|
6680
|
-
* Version: 1.
|
|
6681
|
-
* Description: Handles applying, creating, and converting patches. Applies traditional unified diffs, cleaning line number prefixes from diff content before using jsdiff.
|
|
6682
|
+
* Block-UUID: 58698895-c540-4be0-94b0-53dfcd0e1235
|
|
6683
|
+
* Parent-UUID: 96ec8bca-9fc3-441b-b81f-6fefc840c626
|
|
6684
|
+
* Version: 1.4.0
|
|
6685
|
+
* Description: Handles applying, creating, and converting patches. Applies traditional unified diffs, cleaning line number prefixes from diff content before using jsdiff. Updated patch metadata formatting to include Component, Language, and Created-at.
|
|
6682
6686
|
* Language: JavaScript
|
|
6683
6687
|
* Created-at: 2025-07-20T17:24:16.836Z
|
|
6684
|
-
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Claude 3.7 Sonnet (v1.2.0), Gemini 2.5 Flash (v1.2.0), Gemini 2.5 Flash Thinking (v1.3.0)
|
|
6688
|
+
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Claude 3.7 Sonnet (v1.2.0), Gemini 2.5 Flash (v1.2.0), Gemini 2.5 Flash Thinking (v1.3.0), GLM-4.7 (v1.4.0)
|
|
6685
6689
|
*/
|
|
6686
6690
|
|
|
6687
6691
|
const parser$1 = patchParser;
|
|
@@ -6976,9 +6980,9 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
|
|
|
6976
6980
|
// 4. Assemble Final Patch
|
|
6977
6981
|
const formattedMetadata = _formatPatchMetadata(patchMetadata);
|
|
6978
6982
|
const formatted = `${formattedMetadata}\n\n\n`+
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6983
|
+
`# --- PATCH START MARKER ---\n`+
|
|
6984
|
+
`${adjustedDiffPatch}\n`+
|
|
6985
|
+
`# --- PATCH END MARKER ---`;
|
|
6982
6986
|
|
|
6983
6987
|
return {
|
|
6984
6988
|
formatted,
|
|
@@ -6995,12 +6999,18 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
|
|
|
6995
6999
|
* @private
|
|
6996
7000
|
*/
|
|
6997
7001
|
function _formatPatchMetadata(metadata) {
|
|
6998
|
-
// --- Function body from original PatchUtils._formatPatchMetadata ---
|
|
6999
|
-
// --- (Copied Verbatim) ---
|
|
7000
7002
|
const lines = ['# Patch Metadata'];
|
|
7003
|
+
// Updated order to match system prompt requirements
|
|
7001
7004
|
const metadataOrder = [
|
|
7002
|
-
'
|
|
7003
|
-
'
|
|
7005
|
+
'Component',
|
|
7006
|
+
'Source-Block-UUID',
|
|
7007
|
+
'Target-Block-UUID',
|
|
7008
|
+
'Source-Version',
|
|
7009
|
+
'Target-Version',
|
|
7010
|
+
'Description',
|
|
7011
|
+
'Language',
|
|
7012
|
+
'Created-at',
|
|
7013
|
+
'Authors'
|
|
7004
7014
|
];
|
|
7005
7015
|
|
|
7006
7016
|
// Add ordered metadata
|
|
@@ -7018,7 +7028,6 @@ function _formatPatchMetadata(metadata) {
|
|
|
7018
7028
|
}
|
|
7019
7029
|
|
|
7020
7030
|
return lines.join('\n');
|
|
7021
|
-
// --- End of Function Body ---
|
|
7022
7031
|
}
|
|
7023
7032
|
|
|
7024
7033
|
var patchProcessor = {
|
|
@@ -8095,13 +8104,13 @@ var diagnosticReporter$1 = {
|
|
|
8095
8104
|
|
|
8096
8105
|
/**
|
|
8097
8106
|
* Component: PatchUtils Patch Extractor
|
|
8098
|
-
* Block-UUID:
|
|
8099
|
-
* Parent-UUID:
|
|
8100
|
-
* Version: 1.
|
|
8101
|
-
* Description: Extracts individual hunks from a patch and cleans line numbers from content.
|
|
8107
|
+
* Block-UUID: d937fa30-196e-4221-9508-717f509f43d4
|
|
8108
|
+
* Parent-UUID: ad8cda91-244b-4f47-9847-d6c0d93424fc
|
|
8109
|
+
* Version: 1.1.0
|
|
8110
|
+
* Description: Extracts individual hunks from a patch and cleans line numbers from content. Updated reconstructPatch to format metadata in the specific order required by the system prompt.
|
|
8102
8111
|
* Language: JavaScript
|
|
8103
8112
|
* Created-at: 2025-05-14T16:50:00.000Z
|
|
8104
|
-
* Authors: Claude 3.7 Sonnet (v1.0.0)
|
|
8113
|
+
* Authors: Claude 3.7 Sonnet (v1.0.0), GLM-4.7 (v1.1.0)
|
|
8105
8114
|
*/
|
|
8106
8115
|
|
|
8107
8116
|
const { removeLineNumbers: removeLineNumbers$4 } = lineNumberFormatter;
|
|
@@ -8241,11 +8250,33 @@ function extractAndCleanHunks$1(patchText) {
|
|
|
8241
8250
|
* @returns {string} Reconstructed patch
|
|
8242
8251
|
*/
|
|
8243
8252
|
function reconstructPatch$1(metadata, hunks) {
|
|
8244
|
-
// Format metadata
|
|
8253
|
+
// Format metadata in the specific order required by the system prompt
|
|
8245
8254
|
let result = '# Patch Metadata\n';
|
|
8255
|
+
|
|
8256
|
+
const metadataOrder = [
|
|
8257
|
+
'Component',
|
|
8258
|
+
'Source-Block-UUID',
|
|
8259
|
+
'Target-Block-UUID',
|
|
8260
|
+
'Source-Version',
|
|
8261
|
+
'Target-Version',
|
|
8262
|
+
'Description',
|
|
8263
|
+
'Language',
|
|
8264
|
+
'Created-at',
|
|
8265
|
+
'Authors'
|
|
8266
|
+
];
|
|
8267
|
+
|
|
8268
|
+
// Add ordered metadata
|
|
8269
|
+
metadataOrder.forEach(key => {
|
|
8270
|
+
if (metadata[key]) {
|
|
8271
|
+
result += `# ${key}: ${metadata[key]}\n`;
|
|
8272
|
+
}
|
|
8273
|
+
});
|
|
8246
8274
|
|
|
8275
|
+
// Add any other metadata not in the preferred order
|
|
8247
8276
|
for (const [key, value] of Object.entries(metadata)) {
|
|
8248
|
-
|
|
8277
|
+
if (!metadataOrder.includes(key)) {
|
|
8278
|
+
result += `# ${key}: ${value}\n`;
|
|
8279
|
+
}
|
|
8249
8280
|
}
|
|
8250
8281
|
|
|
8251
8282
|
// Add patch markers and hunks
|
|
@@ -9440,7 +9471,7 @@ var JsonUtils$2 = {
|
|
|
9440
9471
|
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Gemini 2.5 Pro (v1.2.0), Gemini 2.5 Flash Thinking (v1.3.0), Gemini 2.5 Flash Thinking (v1.4.0), Qwen 3 Coder 480B - Cerebras (v1.5.0)
|
|
9441
9472
|
*/
|
|
9442
9473
|
|
|
9443
|
-
const { findAllCodeFences: findAllCodeFences$
|
|
9474
|
+
const { findAllCodeFences: findAllCodeFences$4, matchFencesAndExtractBlocks: matchFencesAndExtractBlocks$3 } = blockExtractor;
|
|
9444
9475
|
const { parseHeader: parseHeader$2 } = headerUtils;
|
|
9445
9476
|
const { validateUUID: validateUUID$2 } = uuidUtils;
|
|
9446
9477
|
const AnalysisBlockUtils$2 = AnalysisBlockUtils$3;
|
|
@@ -9795,7 +9826,7 @@ function processCodeBlocks$5(text, options = { silent: false, validatePatches: f
|
|
|
9795
9826
|
}
|
|
9796
9827
|
|
|
9797
9828
|
// Step 1: Find all fence positions
|
|
9798
|
-
const { openingPositions, closingPositions } = findAllCodeFences$
|
|
9829
|
+
const { openingPositions, closingPositions } = findAllCodeFences$4(text);
|
|
9799
9830
|
|
|
9800
9831
|
// Step 2: Match fences to get potential block boundaries
|
|
9801
9832
|
const { completeBlocks, incompleteBlocks, warnings: extractorWarnings } = matchFencesAndExtractBlocks$3(
|
|
@@ -10427,6 +10458,146 @@ Plain text block.
|
|
|
10427
10458
|
// (Removed the check `if (typeof module !== 'undefined' && module.exports)` as it's standard in Node)
|
|
10428
10459
|
var markerRemover = { removeCodeBlockMarkers: removeCodeBlockMarkers$2 };
|
|
10429
10460
|
|
|
10461
|
+
/**
|
|
10462
|
+
* Component: CodeBlockUtils Traceable Code Parser
|
|
10463
|
+
* Block-UUID: 8a4b2c1d-9e6f-4a3b-8c7d-1e2f3a4b5c6d
|
|
10464
|
+
* Parent-UUID: N/A
|
|
10465
|
+
* Version: 1.0.0
|
|
10466
|
+
* Description: Parses the `Traceable Code` metadata lines preceding code blocks to extract pre-generated UUIDs and version flags for backend validation.
|
|
10467
|
+
* Language: JavaScript
|
|
10468
|
+
* Created-at: 2026-01-26T17:50:00.000Z
|
|
10469
|
+
* Authors: GLM-4.7 (v1.0.0)
|
|
10470
|
+
*/
|
|
10471
|
+
|
|
10472
|
+
const { findAllCodeFences: findAllCodeFences$3 } = blockExtractor;
|
|
10473
|
+
|
|
10474
|
+
/**
|
|
10475
|
+
* Parses `Traceable Code` metadata lines for all code blocks found in a message.
|
|
10476
|
+
* It scans the text for code blocks and looks for the specific traceable header
|
|
10477
|
+
* immediately preceding each block.
|
|
10478
|
+
*
|
|
10479
|
+
* @param {string} messageText - The full message text containing code blocks.
|
|
10480
|
+
* @param {Object} [options] - Optional configuration.
|
|
10481
|
+
* @param {boolean} [options.silent=true] - If false, logs warnings to console.
|
|
10482
|
+
* @returns {TraceableCodeParseResult[]} An array of results, where each index
|
|
10483
|
+
* corresponds to a code block found in the message.
|
|
10484
|
+
*/
|
|
10485
|
+
function parseTraceableCodeHeaders$2(messageText, options = { silent: true }) {
|
|
10486
|
+
if (typeof messageText !== 'string') {
|
|
10487
|
+
if (!options.silent) {
|
|
10488
|
+
console.warn('parseTraceableCodeHeaders: messageText must be a string.');
|
|
10489
|
+
}
|
|
10490
|
+
return [];
|
|
10491
|
+
}
|
|
10492
|
+
|
|
10493
|
+
// Step 1: Find all code fence positions
|
|
10494
|
+
const { openingPositions } = findAllCodeFences$3(messageText);
|
|
10495
|
+
const results = [];
|
|
10496
|
+
|
|
10497
|
+
// Step 2: Iterate through each code block to find its preceding traceable line
|
|
10498
|
+
openingPositions.forEach((fence, index) => {
|
|
10499
|
+
const textBeforeFence = messageText.substring(0, fence.position);
|
|
10500
|
+
const lines = textBeforeFence.split('\n');
|
|
10501
|
+
|
|
10502
|
+
let foundLine = null;
|
|
10503
|
+
let searchLimit = 10; // Look back up to 10 lines to find the header
|
|
10504
|
+
|
|
10505
|
+
// Iterate backwards from the fence
|
|
10506
|
+
for (let i = lines.length - 1; i >= 0 && searchLimit > 0; i--) {
|
|
10507
|
+
const line = lines[i].trim();
|
|
10508
|
+
|
|
10509
|
+
// Skip file path lines (e.g., `path/to/file.js`)
|
|
10510
|
+
if (line.startsWith('`') && line.endsWith('`')) {
|
|
10511
|
+
continue;
|
|
10512
|
+
}
|
|
10513
|
+
|
|
10514
|
+
// Skip empty lines
|
|
10515
|
+
if (line === '') {
|
|
10516
|
+
continue;
|
|
10517
|
+
}
|
|
10518
|
+
|
|
10519
|
+
// Check for the traceable code marker
|
|
10520
|
+
if (line.includes('**Traceable Code:**')) {
|
|
10521
|
+
foundLine = line;
|
|
10522
|
+
break;
|
|
10523
|
+
}
|
|
10524
|
+
}
|
|
10525
|
+
|
|
10526
|
+
if (foundLine) {
|
|
10527
|
+
const parsedData = parseTraceableLine(foundLine);
|
|
10528
|
+
results.push({
|
|
10529
|
+
blockIndex: index,
|
|
10530
|
+
found: true,
|
|
10531
|
+
rawLine: foundLine,
|
|
10532
|
+
data: parsedData.data,
|
|
10533
|
+
errors: parsedData.errors
|
|
10534
|
+
});
|
|
10535
|
+
} else {
|
|
10536
|
+
results.push({
|
|
10537
|
+
blockIndex: index,
|
|
10538
|
+
found: false,
|
|
10539
|
+
rawLine: null,
|
|
10540
|
+
data: null,
|
|
10541
|
+
errors: []
|
|
10542
|
+
});
|
|
10543
|
+
}
|
|
10544
|
+
});
|
|
10545
|
+
|
|
10546
|
+
return results;
|
|
10547
|
+
}
|
|
10548
|
+
|
|
10549
|
+
/**
|
|
10550
|
+
* Internal helper to parse a single traceable code line.
|
|
10551
|
+
* @param {string} line - The raw line containing the traceable code metadata.
|
|
10552
|
+
* @returns {Object} { data: Object, errors: Array }
|
|
10553
|
+
*/
|
|
10554
|
+
function parseTraceableLine(line) {
|
|
10555
|
+
// Helper to extract value for a specific key
|
|
10556
|
+
// Handles keys like **Key:** value, ignoring HTML entities like
|
|
10557
|
+
const extract = (key) => {
|
|
10558
|
+
// Regex matches **Key:** followed by any characters until the next ** or end of line
|
|
10559
|
+
// We strip HTML entities and extra whitespace from the result
|
|
10560
|
+
const regex = new RegExp(`\\*\\*${key}:\\*\\*\\s*([^*]+)`, 'i');
|
|
10561
|
+
const match = line.match(regex);
|
|
10562
|
+
if (match) {
|
|
10563
|
+
return match[1].trim().replace(/ /g, '').trim();
|
|
10564
|
+
}
|
|
10565
|
+
return null;
|
|
10566
|
+
};
|
|
10567
|
+
|
|
10568
|
+
const isTraceableStr = extract('Traceable Code');
|
|
10569
|
+
const isNewVersionStr = extract('New Version');
|
|
10570
|
+
const currentParentUUID = extract('Current Parent-UUID');
|
|
10571
|
+
const newParentUUID = extract('New Parent-UUID');
|
|
10572
|
+
const newBlockUUID = extract('New Block-UUID');
|
|
10573
|
+
|
|
10574
|
+
const errors = [];
|
|
10575
|
+
|
|
10576
|
+
// Basic validation of extracted values
|
|
10577
|
+
if (!isTraceableStr || !['Yes', 'No'].includes(isTraceableStr)) {
|
|
10578
|
+
errors.push({ type: 'invalid_value', message: 'Invalid or missing Traceable Code value (expected Yes/No).' });
|
|
10579
|
+
}
|
|
10580
|
+
|
|
10581
|
+
if (!isNewVersionStr || !['Yes', 'No', 'N/A'].includes(isNewVersionStr)) {
|
|
10582
|
+
errors.push({ type: 'invalid_value', message: 'Invalid or missing New Version value (expected Yes/No/N/A).' });
|
|
10583
|
+
}
|
|
10584
|
+
|
|
10585
|
+
return {
|
|
10586
|
+
data: {
|
|
10587
|
+
isTraceable: isTraceableStr === 'Yes',
|
|
10588
|
+
isNewVersion: isNewVersionStr === 'Yes',
|
|
10589
|
+
currentParentUUID: currentParentUUID,
|
|
10590
|
+
newParentUUID: newParentUUID,
|
|
10591
|
+
newBlockUUID: newBlockUUID
|
|
10592
|
+
},
|
|
10593
|
+
errors: errors
|
|
10594
|
+
};
|
|
10595
|
+
}
|
|
10596
|
+
|
|
10597
|
+
var traceableCodeParser = {
|
|
10598
|
+
parseTraceableCodeHeaders: parseTraceableCodeHeaders$2
|
|
10599
|
+
};
|
|
10600
|
+
|
|
10430
10601
|
/**
|
|
10431
10602
|
* Component: CodeBlockUtils Update Code Block
|
|
10432
10603
|
* Block-UUID: 6a7b8c9d-0e1f-42a3-b4c5-d6e7f8a9b0c1
|
|
@@ -10799,13 +10970,13 @@ var lineageTracer = {
|
|
|
10799
10970
|
|
|
10800
10971
|
/**
|
|
10801
10972
|
* Component: CodeBlockUtils Index
|
|
10802
|
-
* Block-UUID:
|
|
10803
|
-
* Parent-UUID:
|
|
10804
|
-
* Version: 1.
|
|
10973
|
+
* Block-UUID: bf718ee3-fdb2-4fd1-85b8-418b24291179
|
|
10974
|
+
* Parent-UUID: 98684aa5-d597-41b6-a7fd-cc16482aafdc
|
|
10975
|
+
* Version: 1.6.0
|
|
10805
10976
|
* Description: Aggregates and exports all utilities related to code block processing from the CodeBlockUtils module. Serves as the main entry point for this module.
|
|
10806
10977
|
* Language: JavaScript
|
|
10807
|
-
* Created-at:
|
|
10808
|
-
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Claude 3.7 Sonnet (v1.2.0), Gemini 2.5 Pro (v1.3.0), Gemini 2.5 Flash Thinking (v1.4.0), Qwen 3 Coder 480B - Cerebras (v1.5.0)
|
|
10978
|
+
* Created-at: 2026-01-26T17:51:57.427Z
|
|
10979
|
+
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Claude 3.7 Sonnet (v1.2.0), Gemini 2.5 Pro (v1.3.0), Gemini 2.5 Flash Thinking (v1.4.0), Qwen 3 Coder 480B - Cerebras (v1.5.0), GLM-4.7 (v1.6.0)
|
|
10809
10980
|
*/
|
|
10810
10981
|
|
|
10811
10982
|
// Import from individual utility files
|
|
@@ -10819,6 +10990,7 @@ const { detectCodeBlockRelationships: detectCodeBlockRelationships$1, detectInco
|
|
|
10819
10990
|
const { extractContinuationInfo: extractContinuationInfo$1, generateContinuationPrompt: generateContinuationPrompt$1 } = continuationUtils;
|
|
10820
10991
|
const { parseCodeBlocks: parseCommentDelimitedBlocks$1 } = headerParser;
|
|
10821
10992
|
const { removeCodeBlockMarkers: removeCodeBlockMarkers$1 } = markerRemover;
|
|
10993
|
+
const { parseTraceableCodeHeaders: parseTraceableCodeHeaders$1 } = traceableCodeParser;
|
|
10822
10994
|
const { updateCodeBlockByIndex: updateCodeBlockByIndex$1, updateCodeBlockByUUID, updateCodeBlock, updateCodeBlockInMessage, deleteCodeBlockByIndex: deleteCodeBlockByIndex$1 } = updateCodeBlock_1;
|
|
10823
10995
|
const { formatWithLineNumbers: formatWithLineNumbers$1, formatBlockWithLineNumbers: formatBlockWithLineNumbers$1, formatBlocksWithLineNumbers: formatBlocksWithLineNumbers$1, removeLineNumbers: removeLineNumbers$1 } = lineNumberFormatter;
|
|
10824
10996
|
const { getLineage: getLineage$1 } = lineageTracer;
|
|
@@ -10866,6 +11038,9 @@ var CodeBlockUtils$7 = {
|
|
|
10866
11038
|
// Marker Removal
|
|
10867
11039
|
removeCodeBlockMarkers: removeCodeBlockMarkers$1,
|
|
10868
11040
|
|
|
11041
|
+
// Traceable Code Parsing
|
|
11042
|
+
parseTraceableCodeHeaders: parseTraceableCodeHeaders$1,
|
|
11043
|
+
|
|
10869
11044
|
// Code Block Updating Utilities
|
|
10870
11045
|
updateCodeBlockByIndex: updateCodeBlockByIndex$1,
|
|
10871
11046
|
updateCodeBlockByUUID,
|
|
@@ -26285,6 +26460,7 @@ const {
|
|
|
26285
26460
|
updateCodeBlockByIndex,
|
|
26286
26461
|
deleteCodeBlockByIndex,
|
|
26287
26462
|
getLineage,
|
|
26463
|
+
parseTraceableCodeHeaders,
|
|
26288
26464
|
} = CodeBlockUtils;
|
|
26289
26465
|
|
|
26290
26466
|
const {
|
|
@@ -26642,6 +26818,7 @@ var GitSenseChatUtils_1 = {
|
|
|
26642
26818
|
formatBlockWithLineNumbers,
|
|
26643
26819
|
formatBlocksWithLineNumbers,
|
|
26644
26820
|
removeLineNumbers,
|
|
26821
|
+
parseTraceableCodeHeaders,
|
|
26645
26822
|
|
|
26646
26823
|
// Other Utilities (from CodeBlockUtils)
|
|
26647
26824
|
removeCodeBlockMarkers,
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Component: CodeBlockUtils Index
|
|
3
|
-
* Block-UUID:
|
|
4
|
-
* Parent-UUID:
|
|
5
|
-
* Version: 1.
|
|
3
|
+
* Block-UUID: bf718ee3-fdb2-4fd1-85b8-418b24291179
|
|
4
|
+
* Parent-UUID: 98684aa5-d597-41b6-a7fd-cc16482aafdc
|
|
5
|
+
* Version: 1.6.0
|
|
6
6
|
* Description: Aggregates and exports all utilities related to code block processing from the CodeBlockUtils module. Serves as the main entry point for this module.
|
|
7
7
|
* Language: JavaScript
|
|
8
|
-
* Created-at:
|
|
9
|
-
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Claude 3.7 Sonnet (v1.2.0), Gemini 2.5 Pro (v1.3.0), Gemini 2.5 Flash Thinking (v1.4.0), Qwen 3 Coder 480B - Cerebras (v1.5.0)
|
|
8
|
+
* Created-at: 2026-01-26T17:51:57.427Z
|
|
9
|
+
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Claude 3.7 Sonnet (v1.2.0), Gemini 2.5 Pro (v1.3.0), Gemini 2.5 Flash Thinking (v1.4.0), Qwen 3 Coder 480B - Cerebras (v1.5.0), GLM-4.7 (v1.6.0)
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
|
|
@@ -21,6 +21,7 @@ const { detectCodeBlockRelationships, detectIncompleteCodeBlock, extractFilePath
|
|
|
21
21
|
const { extractContinuationInfo, generateContinuationPrompt } = require('./continuationUtils');
|
|
22
22
|
const { parseCodeBlocks: parseCommentDelimitedBlocks } = require('./headerParser');
|
|
23
23
|
const { removeCodeBlockMarkers } = require('./markerRemover');
|
|
24
|
+
const { parseTraceableCodeHeaders } = require('./traceableCodeParser');
|
|
24
25
|
const { updateCodeBlockByIndex, updateCodeBlockByUUID, updateCodeBlock, updateCodeBlockInMessage, deleteCodeBlockByIndex } = require('./updateCodeBlock');
|
|
25
26
|
const { formatWithLineNumbers, formatBlockWithLineNumbers, formatBlocksWithLineNumbers, removeLineNumbers } = require('./lineNumberFormatter');
|
|
26
27
|
const { getLineage } = require('./lineageTracer');
|
|
@@ -68,6 +69,9 @@ module.exports = {
|
|
|
68
69
|
// Marker Removal
|
|
69
70
|
removeCodeBlockMarkers,
|
|
70
71
|
|
|
72
|
+
// Traceable Code Parsing
|
|
73
|
+
parseTraceableCodeHeaders,
|
|
74
|
+
|
|
71
75
|
// Code Block Updating Utilities
|
|
72
76
|
updateCodeBlockByIndex,
|
|
73
77
|
updateCodeBlockByUUID,
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component: CodeBlockUtils Traceable Code Parser
|
|
3
|
+
* Block-UUID: 8a4b2c1d-9e6f-4a3b-8c7d-1e2f3a4b5c6d
|
|
4
|
+
* Parent-UUID: N/A
|
|
5
|
+
* Version: 1.0.0
|
|
6
|
+
* Description: Parses the `Traceable Code` metadata lines preceding code blocks to extract pre-generated UUIDs and version flags for backend validation.
|
|
7
|
+
* Language: JavaScript
|
|
8
|
+
* Created-at: 2026-01-26T17:50:00.000Z
|
|
9
|
+
* Authors: GLM-4.7 (v1.0.0)
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const { findAllCodeFences } = require('./blockExtractor');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Parses `Traceable Code` metadata lines for all code blocks found in a message.
|
|
17
|
+
* It scans the text for code blocks and looks for the specific traceable header
|
|
18
|
+
* immediately preceding each block.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} messageText - The full message text containing code blocks.
|
|
21
|
+
* @param {Object} [options] - Optional configuration.
|
|
22
|
+
* @param {boolean} [options.silent=true] - If false, logs warnings to console.
|
|
23
|
+
* @returns {TraceableCodeParseResult[]} An array of results, where each index
|
|
24
|
+
* corresponds to a code block found in the message.
|
|
25
|
+
*/
|
|
26
|
+
function parseTraceableCodeHeaders(messageText, options = { silent: true }) {
|
|
27
|
+
if (typeof messageText !== 'string') {
|
|
28
|
+
if (!options.silent) {
|
|
29
|
+
console.warn('parseTraceableCodeHeaders: messageText must be a string.');
|
|
30
|
+
}
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Step 1: Find all code fence positions
|
|
35
|
+
const { openingPositions } = findAllCodeFences(messageText);
|
|
36
|
+
const results = [];
|
|
37
|
+
|
|
38
|
+
// Step 2: Iterate through each code block to find its preceding traceable line
|
|
39
|
+
openingPositions.forEach((fence, index) => {
|
|
40
|
+
const textBeforeFence = messageText.substring(0, fence.position);
|
|
41
|
+
const lines = textBeforeFence.split('\n');
|
|
42
|
+
|
|
43
|
+
let foundLine = null;
|
|
44
|
+
let searchLimit = 10; // Look back up to 10 lines to find the header
|
|
45
|
+
|
|
46
|
+
// Iterate backwards from the fence
|
|
47
|
+
for (let i = lines.length - 1; i >= 0 && searchLimit > 0; i--) {
|
|
48
|
+
const line = lines[i].trim();
|
|
49
|
+
|
|
50
|
+
// Skip file path lines (e.g., `path/to/file.js`)
|
|
51
|
+
if (line.startsWith('`') && line.endsWith('`')) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Skip empty lines
|
|
56
|
+
if (line === '') {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Check for the traceable code marker
|
|
61
|
+
if (line.includes('**Traceable Code:**')) {
|
|
62
|
+
foundLine = line;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (foundLine) {
|
|
68
|
+
const parsedData = parseTraceableLine(foundLine);
|
|
69
|
+
results.push({
|
|
70
|
+
blockIndex: index,
|
|
71
|
+
found: true,
|
|
72
|
+
rawLine: foundLine,
|
|
73
|
+
data: parsedData.data,
|
|
74
|
+
errors: parsedData.errors
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
results.push({
|
|
78
|
+
blockIndex: index,
|
|
79
|
+
found: false,
|
|
80
|
+
rawLine: null,
|
|
81
|
+
data: null,
|
|
82
|
+
errors: []
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return results;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Internal helper to parse a single traceable code line.
|
|
92
|
+
* @param {string} line - The raw line containing the traceable code metadata.
|
|
93
|
+
* @returns {Object} { data: Object, errors: Array }
|
|
94
|
+
*/
|
|
95
|
+
function parseTraceableLine(line) {
|
|
96
|
+
// Helper to extract value for a specific key
|
|
97
|
+
// Handles keys like **Key:** value, ignoring HTML entities like
|
|
98
|
+
const extract = (key) => {
|
|
99
|
+
// Regex matches **Key:** followed by any characters until the next ** or end of line
|
|
100
|
+
// We strip HTML entities and extra whitespace from the result
|
|
101
|
+
const regex = new RegExp(`\\*\\*${key}:\\*\\*\\s*([^*]+)`, 'i');
|
|
102
|
+
const match = line.match(regex);
|
|
103
|
+
if (match) {
|
|
104
|
+
return match[1].trim().replace(/ /g, '').trim();
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const isTraceableStr = extract('Traceable Code');
|
|
110
|
+
const isNewVersionStr = extract('New Version');
|
|
111
|
+
const currentParentUUID = extract('Current Parent-UUID');
|
|
112
|
+
const newParentUUID = extract('New Parent-UUID');
|
|
113
|
+
const newBlockUUID = extract('New Block-UUID');
|
|
114
|
+
|
|
115
|
+
const errors = [];
|
|
116
|
+
|
|
117
|
+
// Basic validation of extracted values
|
|
118
|
+
if (!isTraceableStr || !['Yes', 'No'].includes(isTraceableStr)) {
|
|
119
|
+
errors.push({ type: 'invalid_value', message: 'Invalid or missing Traceable Code value (expected Yes/No).' });
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!isNewVersionStr || !['Yes', 'No', 'N/A'].includes(isNewVersionStr)) {
|
|
123
|
+
errors.push({ type: 'invalid_value', message: 'Invalid or missing New Version value (expected Yes/No/N/A).' });
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
data: {
|
|
128
|
+
isTraceable: isTraceableStr === 'Yes',
|
|
129
|
+
isNewVersion: isNewVersionStr === 'Yes',
|
|
130
|
+
currentParentUUID: currentParentUUID,
|
|
131
|
+
newParentUUID: newParentUUID,
|
|
132
|
+
newBlockUUID: newBlockUUID
|
|
133
|
+
},
|
|
134
|
+
errors: errors
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
module.exports = {
|
|
139
|
+
parseTraceableCodeHeaders
|
|
140
|
+
};
|
package/src/GitSenseChatUtils.js
CHANGED
|
@@ -118,6 +118,7 @@ const {
|
|
|
118
118
|
updateCodeBlockByIndex,
|
|
119
119
|
deleteCodeBlockByIndex,
|
|
120
120
|
getLineage,
|
|
121
|
+
parseTraceableCodeHeaders,
|
|
121
122
|
} = CodeBlockUtils;
|
|
122
123
|
|
|
123
124
|
const {
|
|
@@ -475,6 +476,7 @@ module.exports = {
|
|
|
475
476
|
formatBlockWithLineNumbers,
|
|
476
477
|
formatBlocksWithLineNumbers,
|
|
477
478
|
removeLineNumbers,
|
|
479
|
+
parseTraceableCodeHeaders,
|
|
478
480
|
|
|
479
481
|
// Other Utilities (from CodeBlockUtils)
|
|
480
482
|
removeCodeBlockMarkers,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Component: PatchUtils Constants
|
|
3
|
-
* Block-UUID:
|
|
4
|
-
* Parent-UUID:
|
|
5
|
-
* Version: 2.
|
|
6
|
-
* Description: Contains shared constants and regular expressions used by the enhanced patch utilities.
|
|
3
|
+
* Block-UUID: 83ba7eaa-36b3-41f3-bd07-130c0266301e
|
|
4
|
+
* Parent-UUID: c6747054-2c8b-461f-910d-0fd725d9a350
|
|
5
|
+
* Version: 2.2.0
|
|
6
|
+
* Description: Contains shared constants and regular expressions used by the enhanced patch utilities. Updated required metadata fields to include Component, Language, and Created-at.
|
|
7
7
|
* Language: JavaScript
|
|
8
8
|
* Created-at: 2025-05-14T16:55:00.000Z
|
|
9
|
-
* Authors: Gemini 2.5 Flash Thinking (v1.0.0), Claude 3.7 Sonnet (v2.0.0), Qwen 3 Coder 480B - Cerebras (v2.1.0)
|
|
9
|
+
* Authors: Gemini 2.5 Flash Thinking (v1.0.0), Claude 3.7 Sonnet (v2.0.0), Qwen 3 Coder 480B - Cerebras (v2.1.0), GLM-4.7 (v2.2.0)
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
|
|
@@ -46,12 +46,16 @@ const ABBREVIATED_PATCH_END_MARKER = '# --- ABBREVIATED PATCH END MARKER ---';
|
|
|
46
46
|
const PATCH_METADATA_HEADER = '# Patch Metadata';
|
|
47
47
|
|
|
48
48
|
// Required metadata fields
|
|
49
|
+
// Updated to match the latest system prompt requirements
|
|
49
50
|
const REQUIRED_METADATA_FIELDS = [
|
|
51
|
+
'Component',
|
|
50
52
|
'Source-Block-UUID',
|
|
51
53
|
'Target-Block-UUID',
|
|
52
54
|
'Source-Version',
|
|
53
55
|
'Target-Version',
|
|
54
56
|
'Description',
|
|
57
|
+
'Language',
|
|
58
|
+
'Created-at',
|
|
55
59
|
'Authors'
|
|
56
60
|
];
|
|
57
61
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Component: PatchUtils Patch Extractor
|
|
3
|
-
* Block-UUID:
|
|
4
|
-
* Parent-UUID:
|
|
5
|
-
* Version: 1.
|
|
6
|
-
* Description: Extracts individual hunks from a patch and cleans line numbers from content.
|
|
3
|
+
* Block-UUID: d937fa30-196e-4221-9508-717f509f43d4
|
|
4
|
+
* Parent-UUID: ad8cda91-244b-4f47-9847-d6c0d93424fc
|
|
5
|
+
* Version: 1.1.0
|
|
6
|
+
* Description: Extracts individual hunks from a patch and cleans line numbers from content. Updated reconstructPatch to format metadata in the specific order required by the system prompt.
|
|
7
7
|
* Language: JavaScript
|
|
8
8
|
* Created-at: 2025-05-14T16:50:00.000Z
|
|
9
|
-
* Authors: Claude 3.7 Sonnet (v1.0.0)
|
|
9
|
+
* Authors: Claude 3.7 Sonnet (v1.0.0), GLM-4.7 (v1.1.0)
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
|
|
@@ -147,11 +147,33 @@ function extractAndCleanHunks(patchText) {
|
|
|
147
147
|
* @returns {string} Reconstructed patch
|
|
148
148
|
*/
|
|
149
149
|
function reconstructPatch(metadata, hunks) {
|
|
150
|
-
// Format metadata
|
|
150
|
+
// Format metadata in the specific order required by the system prompt
|
|
151
151
|
let result = '# Patch Metadata\n';
|
|
152
|
+
|
|
153
|
+
const metadataOrder = [
|
|
154
|
+
'Component',
|
|
155
|
+
'Source-Block-UUID',
|
|
156
|
+
'Target-Block-UUID',
|
|
157
|
+
'Source-Version',
|
|
158
|
+
'Target-Version',
|
|
159
|
+
'Description',
|
|
160
|
+
'Language',
|
|
161
|
+
'Created-at',
|
|
162
|
+
'Authors'
|
|
163
|
+
];
|
|
164
|
+
|
|
165
|
+
// Add ordered metadata
|
|
166
|
+
metadataOrder.forEach(key => {
|
|
167
|
+
if (metadata[key]) {
|
|
168
|
+
result += `# ${key}: ${metadata[key]}\n`;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
152
171
|
|
|
172
|
+
// Add any other metadata not in the preferred order
|
|
153
173
|
for (const [key, value] of Object.entries(metadata)) {
|
|
154
|
-
|
|
174
|
+
if (!metadataOrder.includes(key)) {
|
|
175
|
+
result += `# ${key}: ${value}\n`;
|
|
176
|
+
}
|
|
155
177
|
}
|
|
156
178
|
|
|
157
179
|
// Add patch markers and hunks
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Component: PatchUtils Parser
|
|
3
|
-
|
|
4
|
-
* Parent-UUID:
|
|
5
|
-
* Version: 1.
|
|
6
|
-
* Description: Handles parsing, validation, extraction, and detection of traditional unified diff patches and abbreviated patches. Extracts metadata and raw diff content.
|
|
3
|
+
* Block-UUID: 334a0473-da2d-4859-b8a5-f867e3d88a28
|
|
4
|
+
* Parent-UUID: ce634df9-ff99-482a-a261-56ab34a2546e
|
|
5
|
+
* Version: 1.3.0
|
|
6
|
+
* Description: Handles parsing, validation, extraction, and detection of traditional unified diff patches and abbreviated patches. Extracts metadata and raw diff content. Updated validation to require Component and Language.
|
|
7
7
|
* Language: JavaScript
|
|
8
8
|
* Created-at: 2025-04-18T02:59:04.322Z
|
|
9
|
-
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Qwen 3 Coder 480B - Cerebras (v1.2.0)
|
|
9
|
+
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Qwen 3 Coder 480B - Cerebras (v1.2.0), GLM-4.7 (v1.3.0)
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
|
|
@@ -117,13 +117,17 @@ function extractPatchMetadata(patchText) {
|
|
|
117
117
|
*/
|
|
118
118
|
function validatePatchMetadata(metadata) {
|
|
119
119
|
const errors = [];
|
|
120
|
+
// Updated to include Component and Language
|
|
120
121
|
const requiredFields = [
|
|
122
|
+
'Component',
|
|
121
123
|
'Source-Block-UUID',
|
|
122
124
|
'Target-Block-UUID',
|
|
123
125
|
'Source-Version',
|
|
124
126
|
'Target-Version',
|
|
125
127
|
'Description',
|
|
126
|
-
'
|
|
128
|
+
'Language',
|
|
129
|
+
'Authors',
|
|
130
|
+
'Created-at'
|
|
127
131
|
];
|
|
128
132
|
|
|
129
133
|
for (const field of requiredFields) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Component: PatchUtils Processor
|
|
3
|
-
* Block-UUID:
|
|
4
|
-
* Parent-UUID:
|
|
5
|
-
* Version: 1.
|
|
6
|
-
* Description: Handles applying, creating, and converting patches. Applies traditional unified diffs, cleaning line number prefixes from diff content before using jsdiff.
|
|
3
|
+
* Block-UUID: 58698895-c540-4be0-94b0-53dfcd0e1235
|
|
4
|
+
* Parent-UUID: 96ec8bca-9fc3-441b-b81f-6fefc840c626
|
|
5
|
+
* Version: 1.4.0
|
|
6
|
+
* Description: Handles applying, creating, and converting patches. Applies traditional unified diffs, cleaning line number prefixes from diff content before using jsdiff. Updated patch metadata formatting to include Component, Language, and Created-at.
|
|
7
7
|
* Language: JavaScript
|
|
8
8
|
* Created-at: 2025-07-20T17:24:16.836Z
|
|
9
|
-
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Claude 3.7 Sonnet (v1.2.0), Gemini 2.5 Flash (v1.2.0), Gemini 2.5 Flash Thinking (v1.3.0)
|
|
9
|
+
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Pro (v1.1.0), Claude 3.7 Sonnet (v1.2.0), Gemini 2.5 Flash (v1.2.0), Gemini 2.5 Flash Thinking (v1.3.0), GLM-4.7 (v1.4.0)
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
|
|
@@ -345,9 +345,9 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
|
|
|
345
345
|
// 4. Assemble Final Patch
|
|
346
346
|
const formattedMetadata = _formatPatchMetadata(patchMetadata);
|
|
347
347
|
const formatted = `${formattedMetadata}\n\n\n`+
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
348
|
+
`# --- PATCH START MARKER ---\n`+
|
|
349
|
+
`${adjustedDiffPatch}\n`+
|
|
350
|
+
`# --- PATCH END MARKER ---`;
|
|
351
351
|
|
|
352
352
|
return {
|
|
353
353
|
formatted,
|
|
@@ -364,12 +364,18 @@ function createPatchFromCodeBlocks(CodeBlockUtils, sourceCodeBlockText, targetCo
|
|
|
364
364
|
* @private
|
|
365
365
|
*/
|
|
366
366
|
function _formatPatchMetadata(metadata) {
|
|
367
|
-
// --- Function body from original PatchUtils._formatPatchMetadata ---
|
|
368
|
-
// --- (Copied Verbatim) ---
|
|
369
367
|
const lines = ['# Patch Metadata'];
|
|
368
|
+
// Updated order to match system prompt requirements
|
|
370
369
|
const metadataOrder = [
|
|
371
|
-
'
|
|
372
|
-
'
|
|
370
|
+
'Component',
|
|
371
|
+
'Source-Block-UUID',
|
|
372
|
+
'Target-Block-UUID',
|
|
373
|
+
'Source-Version',
|
|
374
|
+
'Target-Version',
|
|
375
|
+
'Description',
|
|
376
|
+
'Language',
|
|
377
|
+
'Created-at',
|
|
378
|
+
'Authors'
|
|
373
379
|
];
|
|
374
380
|
|
|
375
381
|
// Add ordered metadata
|
|
@@ -387,7 +393,6 @@ function _formatPatchMetadata(metadata) {
|
|
|
387
393
|
}
|
|
388
394
|
|
|
389
395
|
return lines.join('\n');
|
|
390
|
-
// --- End of Function Body ---
|
|
391
396
|
}
|
|
392
397
|
|
|
393
398
|
module.exports = {
|
|
@@ -395,5 +400,3 @@ module.exports = {
|
|
|
395
400
|
createPatch,
|
|
396
401
|
createPatchFromCodeBlocks,
|
|
397
402
|
};
|
|
398
|
-
|
|
399
|
-
|