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