@gitsense/gsc-utils 0.2.35 → 0.2.37
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 +329 -130
- package/dist/gsc-utils.esm.js +329 -130
- package/package.json +1 -1
- package/src/CLIContractUtils.js +184 -0
- package/src/CodeBlockUtils/blockProcessor.js +1 -1
- package/src/DomUtils.js +11 -5
- package/src/GitSenseChatUtils.js +13 -3
package/dist/gsc-utils.esm.js
CHANGED
|
@@ -9962,7 +9962,7 @@ function fixTextCodeBlocks$2(text) {
|
|
|
9962
9962
|
const [fieldPart, valuePart] = line.split(':').map(p => p.trim());
|
|
9963
9963
|
|
|
9964
9964
|
// Skip if N/A or contains unexpected characters
|
|
9965
|
-
if (valuePart === 'N/A' || valuePart.match(/\
|
|
9965
|
+
if (valuePart === 'N/A' || !valuePart.match(/\w-/)) {
|
|
9966
9966
|
return line;
|
|
9967
9967
|
}
|
|
9968
9968
|
// Validate UUID
|
|
@@ -11001,7 +11001,7 @@ const { formatWithLineNumbers: formatWithLineNumbers$1, formatBlockWithLineNumbe
|
|
|
11001
11001
|
const { getLineage: getLineage$1 } = lineageTracer;
|
|
11002
11002
|
|
|
11003
11003
|
// Export all imported items
|
|
11004
|
-
var CodeBlockUtils$
|
|
11004
|
+
var CodeBlockUtils$8 = {
|
|
11005
11005
|
// Constants
|
|
11006
11006
|
COMMENT_STYLES: COMMENT_STYLES$1,
|
|
11007
11007
|
|
|
@@ -11061,6 +11061,302 @@ var CodeBlockUtils$7 = {
|
|
|
11061
11061
|
removeLineNumbers: removeLineNumbers$1,
|
|
11062
11062
|
};
|
|
11063
11063
|
|
|
11064
|
+
/**
|
|
11065
|
+
* Component: Date Utilities
|
|
11066
|
+
* Block-UUID: fef3b0f4-8055-4690-9336-e68a9cc33a61
|
|
11067
|
+
* Parent-UUID: 716e5ce9-84df-4f12-89e7-4a28e4a39a81
|
|
11068
|
+
* Version: 1.0.0
|
|
11069
|
+
* Description: Date formatting and manipulation utilities for GitSense Chat
|
|
11070
|
+
* Language: JavaScript
|
|
11071
|
+
* Created-at: 2025-10-11T23:26:20.815Z
|
|
11072
|
+
* Authors: Claude-3.5-Sonnet (v1.0.0), Qwen 3 Coder 480B - Cerebras (v1.0.0)
|
|
11073
|
+
*/
|
|
11074
|
+
|
|
11075
|
+
/**
|
|
11076
|
+
* Ensures a date string has a timezone indicator
|
|
11077
|
+
* @param {string} dateString - Date string in format "YYYY-MM-DD(T| )HH:mm:ss.SSS"
|
|
11078
|
+
* @returns {string} Date string with 'Z' timezone indicator if not present
|
|
11079
|
+
*/
|
|
11080
|
+
function normalizeDateTime$1(dateString) {
|
|
11081
|
+
return dateString.includes('Z') ? dateString : dateString + 'Z';
|
|
11082
|
+
}
|
|
11083
|
+
|
|
11084
|
+
/**
|
|
11085
|
+
* Calculates the time difference between now and a given date
|
|
11086
|
+
* @param {string} dateString - Date string to compare against current time
|
|
11087
|
+
* @returns {number} Difference in seconds
|
|
11088
|
+
*/
|
|
11089
|
+
function getTimeDifference$1(dateString) {
|
|
11090
|
+
const now = new Date();
|
|
11091
|
+
const date = new Date(normalizeDateTime$1(dateString));
|
|
11092
|
+
return Math.floor((now - date) / 1000);
|
|
11093
|
+
}
|
|
11094
|
+
|
|
11095
|
+
/**
|
|
11096
|
+
* Formats a time difference in seconds to a human-readable string
|
|
11097
|
+
* @param {number} diff - Time difference in seconds
|
|
11098
|
+
* @returns {string} Formatted string (e.g., "5s ago", "2m ago", "3h ago", "2d ago")
|
|
11099
|
+
*/
|
|
11100
|
+
function formatTimeDifference$1(diff) {
|
|
11101
|
+
if (diff < 60) {
|
|
11102
|
+
return `${diff}s ago`;
|
|
11103
|
+
} else if (diff < 3600) {
|
|
11104
|
+
const minutes = Math.floor(diff / 60);
|
|
11105
|
+
return `${minutes}m ago`;
|
|
11106
|
+
} else if (diff < 86400) {
|
|
11107
|
+
const hours = Math.floor(diff / 3600);
|
|
11108
|
+
return `${hours}h ago`;
|
|
11109
|
+
} else {
|
|
11110
|
+
const days = Math.floor(diff / 86400);
|
|
11111
|
+
return `${days}d ago`;
|
|
11112
|
+
}
|
|
11113
|
+
}
|
|
11114
|
+
|
|
11115
|
+
/**
|
|
11116
|
+
* Formats a date string into a relative time string
|
|
11117
|
+
* @param {string} dateString - Date string to format
|
|
11118
|
+
* @returns {string} Formatted relative time string
|
|
11119
|
+
*/
|
|
11120
|
+
function formatAge$1(dateString) {
|
|
11121
|
+
if (!dateString) {
|
|
11122
|
+
return 'N/A';
|
|
11123
|
+
}
|
|
11124
|
+
|
|
11125
|
+
try {
|
|
11126
|
+
const diff = getTimeDifference$1(dateString);
|
|
11127
|
+
return formatTimeDifference$1(diff);
|
|
11128
|
+
} catch (error) {
|
|
11129
|
+
console.error('Error formatting date:', error);
|
|
11130
|
+
return 'Invalid date';
|
|
11131
|
+
}
|
|
11132
|
+
}
|
|
11133
|
+
|
|
11134
|
+
/**
|
|
11135
|
+
* Validates a date string format
|
|
11136
|
+
* @param {string} dateString - Date string to validate
|
|
11137
|
+
* @returns {boolean} True if date string is valid
|
|
11138
|
+
*/
|
|
11139
|
+
function isValidDateString$1(dateString) {
|
|
11140
|
+
if (!dateString) return false;
|
|
11141
|
+
|
|
11142
|
+
const pattern = /^\d{4}-\d{2}-\d{2}(T| )\d{2}:\d{2}:\d{2}\.\d{3}Z?$/;
|
|
11143
|
+
if (!pattern.test(dateString)) return false;
|
|
11144
|
+
|
|
11145
|
+
const date = new Date(normalizeDateTime$1(dateString));
|
|
11146
|
+
return date instanceof Date && !isNaN(date);
|
|
11147
|
+
}
|
|
11148
|
+
|
|
11149
|
+
/**
|
|
11150
|
+
* Compares two date strings
|
|
11151
|
+
* @param {string} dateA - First date string
|
|
11152
|
+
* @param {string} dateB - Second date string
|
|
11153
|
+
* @returns {number} -1 if dateA is earlier, 0 if equal, 1 if dateA is later
|
|
11154
|
+
*/
|
|
11155
|
+
function compareDates$1(dateA, dateB) {
|
|
11156
|
+
if (!isValidDateString$1(dateA) || !isValidDateString$1(dateB)) {
|
|
11157
|
+
throw new Error(`Invalid date string format. A: ${dateA} B: ${dateB})`);
|
|
11158
|
+
}
|
|
11159
|
+
|
|
11160
|
+
const timeA = new Date(normalizeDateTime$1(dateA)).getTime();
|
|
11161
|
+
const timeB = new Date(normalizeDateTime$1(dateB)).getTime();
|
|
11162
|
+
|
|
11163
|
+
if (timeA < timeB) return -1;
|
|
11164
|
+
if (timeA > timeB) return 1;
|
|
11165
|
+
return 0;
|
|
11166
|
+
}
|
|
11167
|
+
|
|
11168
|
+
var DateUtils$1 = {
|
|
11169
|
+
formatAge: formatAge$1,
|
|
11170
|
+
isValidDateString: isValidDateString$1,
|
|
11171
|
+
compareDates: compareDates$1,
|
|
11172
|
+
normalizeDateTime: normalizeDateTime$1,
|
|
11173
|
+
getTimeDifference: getTimeDifference$1,
|
|
11174
|
+
formatTimeDifference: formatTimeDifference$1
|
|
11175
|
+
};
|
|
11176
|
+
|
|
11177
|
+
/**
|
|
11178
|
+
* Component: CLI Contract Utilities
|
|
11179
|
+
* Block-UUID: a57b72a0-0d95-44a2-8f3f-ab6ee84b3197
|
|
11180
|
+
* Parent-UUID: 9050e244-793a-4dc6-8571-b96f38927f69
|
|
11181
|
+
* Version: 1.1.0
|
|
11182
|
+
* Description: Utilities for parsing GitSense Chat CLI contract messages and determining save modes for code blocks.
|
|
11183
|
+
* Language: JavaScript
|
|
11184
|
+
* Created-at: 2026-02-27T02:26:15.078Z
|
|
11185
|
+
* Authors: GLM-4.7 (v1.0.0), GLM-4.7 (v1.1.0)
|
|
11186
|
+
*/
|
|
11187
|
+
|
|
11188
|
+
const CodeBlockUtils$7 = CodeBlockUtils$8;
|
|
11189
|
+
|
|
11190
|
+
/**
|
|
11191
|
+
* Parses a contract message object to extract the contract data.
|
|
11192
|
+
* Handles cases where data might be in 'content' (as JSON string) or 'metadata'.
|
|
11193
|
+
*
|
|
11194
|
+
* @param {Object} message - The chat message object.
|
|
11195
|
+
* @returns {Object|null} The parsed contract data object or null if invalid.
|
|
11196
|
+
*/
|
|
11197
|
+
function parseContractMessage(message) {
|
|
11198
|
+
if (!message) {
|
|
11199
|
+
return null;
|
|
11200
|
+
}
|
|
11201
|
+
|
|
11202
|
+
// We expect the message type to be 'gsc-cli-contract'
|
|
11203
|
+
if (message.type !== 'gsc-cli-contract') {
|
|
11204
|
+
return null;
|
|
11205
|
+
}
|
|
11206
|
+
|
|
11207
|
+
const content = message.message || '';
|
|
11208
|
+
const lines = content.split('\n');
|
|
11209
|
+
|
|
11210
|
+
const contractData = {};
|
|
11211
|
+
let inTable = false;
|
|
11212
|
+
let foundHeader = false;
|
|
11213
|
+
|
|
11214
|
+
for (let i = 0; i < lines.length; i++) {
|
|
11215
|
+
const line = lines[i].trim();
|
|
11216
|
+
|
|
11217
|
+
// Check for the CLI Contract header
|
|
11218
|
+
if (line.startsWith('### CLI Contract')) {
|
|
11219
|
+
foundHeader = true;
|
|
11220
|
+
continue;
|
|
11221
|
+
}
|
|
11222
|
+
|
|
11223
|
+
// If we haven't found the header yet, keep looking
|
|
11224
|
+
if (!foundHeader) {
|
|
11225
|
+
continue;
|
|
11226
|
+
}
|
|
11227
|
+
|
|
11228
|
+
// Check for table separator (e.g., | :--- | :--- |)
|
|
11229
|
+
if (line.includes('---')) {
|
|
11230
|
+
inTable = true;
|
|
11231
|
+
continue;
|
|
11232
|
+
}
|
|
11233
|
+
|
|
11234
|
+
// Parse table rows
|
|
11235
|
+
if (inTable && line.startsWith('|')) {
|
|
11236
|
+
// Remove leading/trailing pipes and split by pipe
|
|
11237
|
+
const parts = line.substring(1, line.length - 1).split('|').map(p => p.trim());
|
|
11238
|
+
|
|
11239
|
+
if (parts.length >= 2) {
|
|
11240
|
+
const key = parts[0].replace(/\*\*/g, '').toLowerCase(); // Remove bold markdown and normalize
|
|
11241
|
+
const value = parts[1];
|
|
11242
|
+
|
|
11243
|
+
if (key === 'uuid') contractData.uuid = value;
|
|
11244
|
+
else if (key === 'expires at') contractData.expiresAt = value;
|
|
11245
|
+
else if (key === 'status') contractData.status = value;
|
|
11246
|
+
else if (key === 'description') contractData.description = value;
|
|
11247
|
+
}
|
|
11248
|
+
}
|
|
11249
|
+
}
|
|
11250
|
+
|
|
11251
|
+
return contractData;
|
|
11252
|
+
}
|
|
11253
|
+
|
|
11254
|
+
/**
|
|
11255
|
+
* Checks if a message is a contract message.
|
|
11256
|
+
*
|
|
11257
|
+
* @param {Object} message - The chat message object.
|
|
11258
|
+
* @returns {boolean} True if the message is a contract message.
|
|
11259
|
+
*/
|
|
11260
|
+
function isContractMessage(message) {
|
|
11261
|
+
return message && message.type === 'gsc-cli-contract';
|
|
11262
|
+
}
|
|
11263
|
+
|
|
11264
|
+
/**
|
|
11265
|
+
* Determines if a contract is currently active based on its expiration time.
|
|
11266
|
+
*
|
|
11267
|
+
* @param {Object} contractData - The contract data object (must contain expiresAt).
|
|
11268
|
+
* @returns {boolean} True if the contract is active, false otherwise.
|
|
11269
|
+
*/
|
|
11270
|
+
function isContractActive(contractData) {
|
|
11271
|
+
if (!contractData || !contractData.expiresAt) {
|
|
11272
|
+
return false;
|
|
11273
|
+
}
|
|
11274
|
+
|
|
11275
|
+
const now = Date.now();
|
|
11276
|
+
const expiresAt = new Date(contractData.expiresAt).getTime();
|
|
11277
|
+
|
|
11278
|
+
return now < expiresAt;
|
|
11279
|
+
}
|
|
11280
|
+
|
|
11281
|
+
/**
|
|
11282
|
+
* Determines the save mode (update vs new-file) based on the code content.
|
|
11283
|
+
* Parses the code block header to check for a Parent-UUID.
|
|
11284
|
+
*
|
|
11285
|
+
* @param {string} rawCodeContent - The full content of the code block (including header).
|
|
11286
|
+
* @returns {Object} An object { mode: 'update'|'new-file', metadata: Object }.
|
|
11287
|
+
*/
|
|
11288
|
+
function determineSaveMode(rawCodeContent) {
|
|
11289
|
+
const { blocks } = CodeBlockUtils$7.processCodeBlocks(rawCodeContent, { silent: true });
|
|
11290
|
+
|
|
11291
|
+
if (!blocks || blocks.length === 0) {
|
|
11292
|
+
return { mode: 'unknown', metadata: null };
|
|
11293
|
+
}
|
|
11294
|
+
|
|
11295
|
+
const block = blocks[0];
|
|
11296
|
+
const header = block.header || {};
|
|
11297
|
+
const parentUUID = header['Parent-UUID'];
|
|
11298
|
+
|
|
11299
|
+
let mode = 'new-file';
|
|
11300
|
+
|
|
11301
|
+
// If Parent-UUID exists and is not N/A, it's an update
|
|
11302
|
+
if (parentUUID && parentUUID !== 'N/A') {
|
|
11303
|
+
mode = 'update';
|
|
11304
|
+
}
|
|
11305
|
+
|
|
11306
|
+
return {
|
|
11307
|
+
mode,
|
|
11308
|
+
metadata: {
|
|
11309
|
+
blockUUID: header['Block-UUID'],
|
|
11310
|
+
parentUUID: parentUUID,
|
|
11311
|
+
language: block.language
|
|
11312
|
+
}
|
|
11313
|
+
};
|
|
11314
|
+
}
|
|
11315
|
+
|
|
11316
|
+
/**
|
|
11317
|
+
* Extracts key metadata from a code block content.
|
|
11318
|
+
*
|
|
11319
|
+
* @param {string} rawCodeContent - The full content of the code block.
|
|
11320
|
+
* @returns {Object|null} Metadata object or null if parsing fails.
|
|
11321
|
+
*/
|
|
11322
|
+
function extractCodeMetadata(rawCodeContent) {
|
|
11323
|
+
const result = determineSaveMode(rawCodeContent);
|
|
11324
|
+
return result.metadata;
|
|
11325
|
+
}
|
|
11326
|
+
|
|
11327
|
+
/**
|
|
11328
|
+
* Formats the remaining time until expiration.
|
|
11329
|
+
*
|
|
11330
|
+
* @param {string|Date} expiresAt - The expiration timestamp.
|
|
11331
|
+
* @returns {string} Formatted string (e.g., "45m", "2h", "1d").
|
|
11332
|
+
*/
|
|
11333
|
+
function formatTimeRemaining(expiresAt) {
|
|
11334
|
+
const now = Date.now();
|
|
11335
|
+
const expiry = new Date(expiresAt).getTime();
|
|
11336
|
+
const diffMs = expiry - now;
|
|
11337
|
+
|
|
11338
|
+
if (diffMs <= 0) return 'Expired';
|
|
11339
|
+
|
|
11340
|
+
const diffMins = Math.floor(diffMs / 60000);
|
|
11341
|
+
|
|
11342
|
+
if (diffMins < 60) return `${diffMins}m`;
|
|
11343
|
+
|
|
11344
|
+
const diffHours = Math.floor(diffMins / 60);
|
|
11345
|
+
if (diffHours < 24) return `${diffHours}h`;
|
|
11346
|
+
|
|
11347
|
+
const diffDays = Math.floor(diffHours / 24);
|
|
11348
|
+
return `${diffDays}d`;
|
|
11349
|
+
}
|
|
11350
|
+
|
|
11351
|
+
var CLIContractUtils$1 = {
|
|
11352
|
+
parseContractMessage,
|
|
11353
|
+
isContractMessage,
|
|
11354
|
+
isContractActive,
|
|
11355
|
+
determineSaveMode,
|
|
11356
|
+
extractCodeMetadata,
|
|
11357
|
+
formatTimeRemaining
|
|
11358
|
+
};
|
|
11359
|
+
|
|
11064
11360
|
/*
|
|
11065
11361
|
* Component: ContextUtils
|
|
11066
11362
|
* Block-UUID: 534c348d-a11f-4de6-ad15-f33068d51fb8
|
|
@@ -11072,7 +11368,7 @@ var CodeBlockUtils$7 = {
|
|
|
11072
11368
|
* Authors: Gemini 2.5 Flash Thinking (v1.0.0), Gemini 2.5 Flash (v1.1.0), Qwen 3 Coder 480B - Cerebras (v1.2.0), Qwen 3 Coder 480B - Cerebras (v1.3.0), Qwen 3 Coder 480B - Cerebras (v1.4.0)
|
|
11073
11369
|
*/
|
|
11074
11370
|
|
|
11075
|
-
const CodeBlockUtils$6 = CodeBlockUtils$
|
|
11371
|
+
const CodeBlockUtils$6 = CodeBlockUtils$8;
|
|
11076
11372
|
const MessageUtils$2 = MessageUtils$3;
|
|
11077
11373
|
|
|
11078
11374
|
/**
|
|
@@ -11532,7 +11828,7 @@ var constants = {
|
|
|
11532
11828
|
* Authors: Gemini 2.5 Flash (v1.0.0)
|
|
11533
11829
|
*/
|
|
11534
11830
|
|
|
11535
|
-
const CodeBlockUtils$5 = CodeBlockUtils$
|
|
11831
|
+
const CodeBlockUtils$5 = CodeBlockUtils$8;
|
|
11536
11832
|
const GSToolBlockUtils$1 = GSToolBlockUtils$3;
|
|
11537
11833
|
const JsonUtils$1 = JsonUtils$2;
|
|
11538
11834
|
const { ANALYZE_HEADER_PREFIX } = constants;
|
|
@@ -11842,7 +12138,7 @@ const fs$7 = require$$0.promises;
|
|
|
11842
12138
|
const path$5 = require$$1;
|
|
11843
12139
|
const { getAnalyzerInstructionsContent: getAnalyzerInstructionsContent$2 } = instructionLoader;
|
|
11844
12140
|
const { preprocessJsonForValidation: preprocessJsonForValidation$4 } = jsonParser;
|
|
11845
|
-
const CodeBlockUtils$4 = CodeBlockUtils$
|
|
12141
|
+
const CodeBlockUtils$4 = CodeBlockUtils$8;
|
|
11846
12142
|
|
|
11847
12143
|
/**
|
|
11848
12144
|
* Reads and parses the config.json file in a directory.
|
|
@@ -12149,7 +12445,7 @@ var saver = {
|
|
|
12149
12445
|
|
|
12150
12446
|
const fs$5 = require$$0.promises;
|
|
12151
12447
|
const path$3 = require$$1;
|
|
12152
|
-
const CodeBlockUtils$3 = CodeBlockUtils$
|
|
12448
|
+
const CodeBlockUtils$3 = CodeBlockUtils$8;
|
|
12153
12449
|
const { preprocessJsonForValidation: preprocessJsonForValidation$3 } = jsonParser;
|
|
12154
12450
|
|
|
12155
12451
|
/**
|
|
@@ -12627,7 +12923,7 @@ var defaultPromptLoader = {
|
|
|
12627
12923
|
|
|
12628
12924
|
const fs$2 = require$$0.promises;
|
|
12629
12925
|
const path = require$$1;
|
|
12630
|
-
const CodeBlockUtils$2 = CodeBlockUtils$
|
|
12926
|
+
const CodeBlockUtils$2 = CodeBlockUtils$8;
|
|
12631
12927
|
const { preprocessJsonForValidation: preprocessJsonForValidation$2 } = jsonParser;
|
|
12632
12928
|
const { isValidDirName: isValidDirName$1 } = discovery;
|
|
12633
12929
|
const { readConfig } = discovery;
|
|
@@ -12813,7 +13109,7 @@ var updater = {
|
|
|
12813
13109
|
*/
|
|
12814
13110
|
|
|
12815
13111
|
require$$0.promises;
|
|
12816
|
-
const CodeBlockUtils$1 = CodeBlockUtils$
|
|
13112
|
+
const CodeBlockUtils$1 = CodeBlockUtils$8;
|
|
12817
13113
|
const { preprocessJsonForValidation: preprocessJsonForValidation$1 } = jsonParser;
|
|
12818
13114
|
const { isValidDirName } = discovery;
|
|
12819
13115
|
const { saveConfiguration: saveConfiguration$1 } = saver;
|
|
@@ -13020,119 +13316,6 @@ var LLMUtils$1 = {
|
|
|
13020
13316
|
estimateTokens: estimateTokens$1,
|
|
13021
13317
|
};
|
|
13022
13318
|
|
|
13023
|
-
/**
|
|
13024
|
-
* Component: Date Utilities
|
|
13025
|
-
* Block-UUID: fef3b0f4-8055-4690-9336-e68a9cc33a61
|
|
13026
|
-
* Parent-UUID: 716e5ce9-84df-4f12-89e7-4a28e4a39a81
|
|
13027
|
-
* Version: 1.0.0
|
|
13028
|
-
* Description: Date formatting and manipulation utilities for GitSense Chat
|
|
13029
|
-
* Language: JavaScript
|
|
13030
|
-
* Created-at: 2025-10-11T23:26:20.815Z
|
|
13031
|
-
* Authors: Claude-3.5-Sonnet (v1.0.0), Qwen 3 Coder 480B - Cerebras (v1.0.0)
|
|
13032
|
-
*/
|
|
13033
|
-
|
|
13034
|
-
/**
|
|
13035
|
-
* Ensures a date string has a timezone indicator
|
|
13036
|
-
* @param {string} dateString - Date string in format "YYYY-MM-DD(T| )HH:mm:ss.SSS"
|
|
13037
|
-
* @returns {string} Date string with 'Z' timezone indicator if not present
|
|
13038
|
-
*/
|
|
13039
|
-
function normalizeDateTime$1(dateString) {
|
|
13040
|
-
return dateString.includes('Z') ? dateString : dateString + 'Z';
|
|
13041
|
-
}
|
|
13042
|
-
|
|
13043
|
-
/**
|
|
13044
|
-
* Calculates the time difference between now and a given date
|
|
13045
|
-
* @param {string} dateString - Date string to compare against current time
|
|
13046
|
-
* @returns {number} Difference in seconds
|
|
13047
|
-
*/
|
|
13048
|
-
function getTimeDifference$1(dateString) {
|
|
13049
|
-
const now = new Date();
|
|
13050
|
-
const date = new Date(normalizeDateTime$1(dateString));
|
|
13051
|
-
return Math.floor((now - date) / 1000);
|
|
13052
|
-
}
|
|
13053
|
-
|
|
13054
|
-
/**
|
|
13055
|
-
* Formats a time difference in seconds to a human-readable string
|
|
13056
|
-
* @param {number} diff - Time difference in seconds
|
|
13057
|
-
* @returns {string} Formatted string (e.g., "5s ago", "2m ago", "3h ago", "2d ago")
|
|
13058
|
-
*/
|
|
13059
|
-
function formatTimeDifference$1(diff) {
|
|
13060
|
-
if (diff < 60) {
|
|
13061
|
-
return `${diff}s ago`;
|
|
13062
|
-
} else if (diff < 3600) {
|
|
13063
|
-
const minutes = Math.floor(diff / 60);
|
|
13064
|
-
return `${minutes}m ago`;
|
|
13065
|
-
} else if (diff < 86400) {
|
|
13066
|
-
const hours = Math.floor(diff / 3600);
|
|
13067
|
-
return `${hours}h ago`;
|
|
13068
|
-
} else {
|
|
13069
|
-
const days = Math.floor(diff / 86400);
|
|
13070
|
-
return `${days}d ago`;
|
|
13071
|
-
}
|
|
13072
|
-
}
|
|
13073
|
-
|
|
13074
|
-
/**
|
|
13075
|
-
* Formats a date string into a relative time string
|
|
13076
|
-
* @param {string} dateString - Date string to format
|
|
13077
|
-
* @returns {string} Formatted relative time string
|
|
13078
|
-
*/
|
|
13079
|
-
function formatAge$1(dateString) {
|
|
13080
|
-
if (!dateString) {
|
|
13081
|
-
return 'N/A';
|
|
13082
|
-
}
|
|
13083
|
-
|
|
13084
|
-
try {
|
|
13085
|
-
const diff = getTimeDifference$1(dateString);
|
|
13086
|
-
return formatTimeDifference$1(diff);
|
|
13087
|
-
} catch (error) {
|
|
13088
|
-
console.error('Error formatting date:', error);
|
|
13089
|
-
return 'Invalid date';
|
|
13090
|
-
}
|
|
13091
|
-
}
|
|
13092
|
-
|
|
13093
|
-
/**
|
|
13094
|
-
* Validates a date string format
|
|
13095
|
-
* @param {string} dateString - Date string to validate
|
|
13096
|
-
* @returns {boolean} True if date string is valid
|
|
13097
|
-
*/
|
|
13098
|
-
function isValidDateString$1(dateString) {
|
|
13099
|
-
if (!dateString) return false;
|
|
13100
|
-
|
|
13101
|
-
const pattern = /^\d{4}-\d{2}-\d{2}(T| )\d{2}:\d{2}:\d{2}\.\d{3}Z?$/;
|
|
13102
|
-
if (!pattern.test(dateString)) return false;
|
|
13103
|
-
|
|
13104
|
-
const date = new Date(normalizeDateTime$1(dateString));
|
|
13105
|
-
return date instanceof Date && !isNaN(date);
|
|
13106
|
-
}
|
|
13107
|
-
|
|
13108
|
-
/**
|
|
13109
|
-
* Compares two date strings
|
|
13110
|
-
* @param {string} dateA - First date string
|
|
13111
|
-
* @param {string} dateB - Second date string
|
|
13112
|
-
* @returns {number} -1 if dateA is earlier, 0 if equal, 1 if dateA is later
|
|
13113
|
-
*/
|
|
13114
|
-
function compareDates$1(dateA, dateB) {
|
|
13115
|
-
if (!isValidDateString$1(dateA) || !isValidDateString$1(dateB)) {
|
|
13116
|
-
throw new Error(`Invalid date string format. A: ${dateA} B: ${dateB})`);
|
|
13117
|
-
}
|
|
13118
|
-
|
|
13119
|
-
const timeA = new Date(normalizeDateTime$1(dateA)).getTime();
|
|
13120
|
-
const timeB = new Date(normalizeDateTime$1(dateB)).getTime();
|
|
13121
|
-
|
|
13122
|
-
if (timeA < timeB) return -1;
|
|
13123
|
-
if (timeA > timeB) return 1;
|
|
13124
|
-
return 0;
|
|
13125
|
-
}
|
|
13126
|
-
|
|
13127
|
-
var DateUtils$1 = {
|
|
13128
|
-
formatAge: formatAge$1,
|
|
13129
|
-
isValidDateString: isValidDateString$1,
|
|
13130
|
-
compareDates: compareDates$1,
|
|
13131
|
-
normalizeDateTime: normalizeDateTime$1,
|
|
13132
|
-
getTimeDifference: getTimeDifference$1,
|
|
13133
|
-
formatTimeDifference: formatTimeDifference$1
|
|
13134
|
-
};
|
|
13135
|
-
|
|
13136
13319
|
/**
|
|
13137
13320
|
* Component: Formatter Utilities
|
|
13138
13321
|
* Block-UUID: 8512c809-87b0-4f90-af9d-b3dca204c4de
|
|
@@ -13190,13 +13373,13 @@ var FormatterUtils$1 = {
|
|
|
13190
13373
|
|
|
13191
13374
|
/**
|
|
13192
13375
|
* Component: DomUtils Helper Functions
|
|
13193
|
-
* Block-UUID:
|
|
13194
|
-
* Parent-UUID:
|
|
13195
|
-
* Version: 1.3.
|
|
13376
|
+
* Block-UUID: 9a4d426c-b445-4e39-a96f-543e2a6f372c
|
|
13377
|
+
* Parent-UUID: 18b5e5b0-7433-42cb-a76e-58b34850829e
|
|
13378
|
+
* Version: 1.3.3
|
|
13196
13379
|
* Description: Provides helper functions for creating and manipulating DOM elements. Updated to support the 'multiple' attribute for input elements.
|
|
13197
13380
|
* Language: JavaScript
|
|
13198
|
-
* Created-at:
|
|
13199
|
-
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Flash (v1.1.0), Qwen 3 Coder 480B - Cerebras (v1.2.0), GLM-4.6 (v1.2.1), GLM-4.6 (v1.3.0), GLM-4.6 (v1.3.1), GLM-4.7 (v1.3.2)
|
|
13381
|
+
* Created-at: 2026-03-17T17:15:41.151Z
|
|
13382
|
+
* Authors: Gemini 2.5 Pro (v1.0.0), Gemini 2.5 Flash (v1.1.0), Qwen 3 Coder 480B - Cerebras (v1.2.0), GLM-4.6 (v1.2.1), GLM-4.6 (v1.3.0), GLM-4.6 (v1.3.1), GLM-4.7 (v1.3.2), Gemini 2.5 Flash (v1.3.3)
|
|
13200
13383
|
*/
|
|
13201
13384
|
|
|
13202
13385
|
function createElement(type, params) {
|
|
@@ -13343,6 +13526,9 @@ const h$1 = {
|
|
|
13343
13526
|
createArticle: (params) => {
|
|
13344
13527
|
return createElement("article", params);
|
|
13345
13528
|
},
|
|
13529
|
+
createBlockquote: (params) => {
|
|
13530
|
+
return createElement("blockquote", params);
|
|
13531
|
+
},
|
|
13346
13532
|
createBr: () => {
|
|
13347
13533
|
return createElement("br");
|
|
13348
13534
|
},
|
|
@@ -13362,6 +13548,9 @@ const h$1 = {
|
|
|
13362
13548
|
createDetail: (params) => {
|
|
13363
13549
|
return createElement("details", params);
|
|
13364
13550
|
},
|
|
13551
|
+
createDetails: (params) => {
|
|
13552
|
+
return createElement("details", params);
|
|
13553
|
+
},
|
|
13365
13554
|
createDiv: (params) => {
|
|
13366
13555
|
return createElement("div", params);
|
|
13367
13556
|
},
|
|
@@ -26375,15 +26564,16 @@ var CompactChatUtils$1 = {
|
|
|
26375
26564
|
* Component: GitSenseChatUtils
|
|
26376
26565
|
* Block-UUID: c1b6c4d3-7959-4eb6-8022-6cd7aa59240d
|
|
26377
26566
|
* Parent-UUID: 1793b3a8-4881-4306-bfdf-673eef503679
|
|
26378
|
-
* Version: 2.
|
|
26379
|
-
* Description: Interface class for GitSense Chat utilities providing a unified API for code block parsing (markdown), extraction, and patch operations. Integrates functionalities from CodeBlockUtils and PatchUtils modules, and now includes ConfigUtils, EnvUtils, ObjectUtils, MetaRawResultUtils, and
|
|
26567
|
+
* Version: 2.8.0
|
|
26568
|
+
* Description: Interface class for GitSense Chat utilities providing a unified API for code block parsing (markdown), extraction, and patch operations. Integrates functionalities from CodeBlockUtils and PatchUtils modules, and now includes ConfigUtils, EnvUtils, ObjectUtils, MetaRawResultUtils, CompactChatUtils, and CLIContractUtils.
|
|
26380
26569
|
* Language: JavaScript
|
|
26381
26570
|
* Created-at: 2025-10-17T17:13:04.663Z
|
|
26382
|
-
* Authors: Claude 3.7 Sonnet (v1.0.0), Gemini 2.5 Pro (v2.0.0), Gemini 2.5 Pro (v2.1.0), Gemini 2.5 Pro (v2.1.1), Gemini 2.5 Flash (v2.1.2), Gemini 2.5 Flash (v2.1.3), Gemini 2.5 Flash (v2.1.4), Qwen 3 Coder 480B - Cerebras (v2.1.5), Qwen 3 Coder 480B - Cerebras (v2.2.0), Qwen 3 Coder 480B - Cerebras (v2.2.1), Claude Haiku 4.5 (v2.3.0), Qwen 3 Coder 480B - Cerebras (v2.4.0), Qwen 3 Coder 480B - Cerebras (v2.5.0), GLM-4.6 (v2.6.0), GLM-4.6 (v2.7.0)
|
|
26571
|
+
* Authors: Claude 3.7 Sonnet (v1.0.0), Gemini 2.5 Pro (v2.0.0), Gemini 2.5 Pro (v2.1.0), Gemini 2.5 Pro (v2.1.1), Gemini 2.5 Flash (v2.1.2), Gemini 2.5 Flash (v2.1.3), Gemini 2.5 Flash (v2.1.4), Qwen 3 Coder 480B - Cerebras (v2.1.5), Qwen 3 Coder 480B - Cerebras (v2.2.0), Qwen 3 Coder 480B - Cerebras (v2.2.1), Claude Haiku 4.5 (v2.3.0), Qwen 3 Coder 480B - Cerebras (v2.4.0), Qwen 3 Coder 480B - Cerebras (v2.5.0), GLM-4.6 (v2.6.0), GLM-4.6 (v2.7.0), GLM-4.7 (v2.8.0)
|
|
26383
26572
|
*/
|
|
26384
26573
|
|
|
26385
26574
|
const ChatUtils = ChatUtils$2;
|
|
26386
|
-
const
|
|
26575
|
+
const CLIContractUtils = CLIContractUtils$1;
|
|
26576
|
+
const CodeBlockUtils = CodeBlockUtils$8;
|
|
26387
26577
|
const ContextUtils = ContextUtils$2;
|
|
26388
26578
|
const MessageUtils = MessageUtils$3;
|
|
26389
26579
|
const AnalysisBlockUtils = AnalysisBlockUtils$3;
|
|
@@ -26799,6 +26989,7 @@ var GitSenseChatUtils_1 = {
|
|
|
26799
26989
|
GSToolBlockUtils,
|
|
26800
26990
|
JsonUtils,
|
|
26801
26991
|
ConfigUtils,
|
|
26992
|
+
CLIContractUtils,
|
|
26802
26993
|
DateUtils,
|
|
26803
26994
|
LanguageNameUtils,
|
|
26804
26995
|
FormatterUtils,
|
|
@@ -26949,6 +27140,14 @@ var GitSenseChatUtils_1 = {
|
|
|
26949
27140
|
parseTableRow,
|
|
26950
27141
|
parseSize,
|
|
26951
27142
|
parseTokens,
|
|
27143
|
+
|
|
27144
|
+
// Contract Utilities (from CLIContractUtils)
|
|
27145
|
+
parseContractMessage: CLIContractUtils.parseContractMessage,
|
|
27146
|
+
isContractMessage: CLIContractUtils.isContractMessage,
|
|
27147
|
+
isContractActive: CLIContractUtils.isContractActive,
|
|
27148
|
+
determineSaveMode: CLIContractUtils.determineSaveMode,
|
|
27149
|
+
extractCodeMetadata: CLIContractUtils.extractCodeMetadata,
|
|
27150
|
+
formatTimeRemaining: CLIContractUtils.formatTimeRemaining,
|
|
26952
27151
|
};
|
|
26953
27152
|
|
|
26954
27153
|
var GitSenseChatUtils$1 = /*@__PURE__*/getDefaultExportFromCjs(GitSenseChatUtils_1);
|