@gitsense/gsc-utils 0.2.7 → 0.2.8
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 +134 -52
- package/dist/gsc-utils.esm.js +134 -52
- package/package.json +1 -1
- package/src/AnalyzerUtils/defaultPromptLoader.js +75 -0
- package/src/AnalyzerUtils/index.js +5 -2
- package/src/GitSenseChatUtils.js +4 -0
package/dist/gsc-utils.cjs.js
CHANGED
|
@@ -18,8 +18,8 @@ function getDefaultExportFromCjs (x) {
|
|
|
18
18
|
* Authors: Claude 3.7 Sonnet (v1.0.0), Gemini 2.5 Pro (v1.1.0), Gemini 2.5 Flash Thinking (v1.2.0)
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
const fs$
|
|
22
|
-
const path$
|
|
21
|
+
const fs$8 = require$$0;
|
|
22
|
+
const path$6 = require$$1;
|
|
23
23
|
const ANALYZE_MESSAGE_REGEXP = /^# Analyze - `([^`]+)`\n/;
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -53,12 +53,12 @@ function unescapeCodeBlocks(content) {
|
|
|
53
53
|
* @returns {Array} An array of message objects with role and content properties
|
|
54
54
|
*/
|
|
55
55
|
function getChatTemplateMessages$1(dirname, messageType) {
|
|
56
|
-
const messagesDir = path$
|
|
56
|
+
const messagesDir = path$6.join(dirname, messageType);
|
|
57
57
|
const messages = [];
|
|
58
58
|
|
|
59
59
|
try {
|
|
60
60
|
// Read all files in the directory
|
|
61
|
-
const files = fs$
|
|
61
|
+
const files = fs$8.readdirSync(messagesDir);
|
|
62
62
|
|
|
63
63
|
// Sort files numerically (1.md, 2.md, etc.)
|
|
64
64
|
const sortedFiles = files.sort((a, b) => {
|
|
@@ -69,9 +69,9 @@ function getChatTemplateMessages$1(dirname, messageType) {
|
|
|
69
69
|
|
|
70
70
|
// Process each file
|
|
71
71
|
for (const file of sortedFiles) {
|
|
72
|
-
if (path$
|
|
73
|
-
const filePath = path$
|
|
74
|
-
const fileContent = fs$
|
|
72
|
+
if (path$6.extname(file) === '.md') {
|
|
73
|
+
const filePath = path$6.join(messagesDir, file);
|
|
74
|
+
const fileContent = fs$8.readFileSync(filePath, 'utf8');
|
|
75
75
|
|
|
76
76
|
// Split by triple newline to separate metadata from content
|
|
77
77
|
const parts = fileContent.split('\n\n\n');
|
|
@@ -10925,8 +10925,8 @@ var dataValidator = {
|
|
|
10925
10925
|
* Authors: Gemini 2.5 Flash (v1.0.0)
|
|
10926
10926
|
*/
|
|
10927
10927
|
|
|
10928
|
-
const fs$
|
|
10929
|
-
const path$
|
|
10928
|
+
const fs$7 = require$$0.promises;
|
|
10929
|
+
const path$5 = require$$1;
|
|
10930
10930
|
|
|
10931
10931
|
/**
|
|
10932
10932
|
* Reads and parses the config.json file in a directory.
|
|
@@ -10935,9 +10935,9 @@ const path$4 = require$$1;
|
|
|
10935
10935
|
* or null if the file doesn't exist or is invalid.
|
|
10936
10936
|
*/
|
|
10937
10937
|
async function readConfig$1(dirPath) {
|
|
10938
|
-
const configPath = path$
|
|
10938
|
+
const configPath = path$5.join(dirPath, 'config.json');
|
|
10939
10939
|
try {
|
|
10940
|
-
const fileContent = await fs$
|
|
10940
|
+
const fileContent = await fs$7.readFile(configPath, 'utf8');
|
|
10941
10941
|
return JSON.parse(fileContent);
|
|
10942
10942
|
} catch (error) {
|
|
10943
10943
|
if (error.code !== 'ENOENT') {
|
|
@@ -10974,41 +10974,41 @@ async function getAnalyzers$2(analyzeMessagesBasePath) {
|
|
|
10974
10974
|
const analyzers = [];
|
|
10975
10975
|
|
|
10976
10976
|
try {
|
|
10977
|
-
const analyzerEntries = await fs$
|
|
10977
|
+
const analyzerEntries = await fs$7.readdir(analyzeMessagesBasePath, { withFileTypes: true });
|
|
10978
10978
|
|
|
10979
10979
|
for (const analyzerEntry of analyzerEntries) {
|
|
10980
10980
|
if (analyzerEntry.isDirectory() && isValidDirName(analyzerEntry.name)) {
|
|
10981
10981
|
const analyzerName = analyzerEntry.name;
|
|
10982
|
-
const analyzerPath = path$
|
|
10982
|
+
const analyzerPath = path$5.join(analyzeMessagesBasePath, analyzerName);
|
|
10983
10983
|
const analyzerConfig = await readConfig$1(analyzerPath);
|
|
10984
10984
|
const analyzerLabel = analyzerConfig?.label || analyzerName;
|
|
10985
10985
|
|
|
10986
|
-
const contentEntries = await fs$
|
|
10986
|
+
const contentEntries = await fs$7.readdir(analyzerPath, { withFileTypes: true });
|
|
10987
10987
|
|
|
10988
10988
|
for (const contentEntry of contentEntries) {
|
|
10989
10989
|
if (contentEntry.isDirectory() && isValidDirName(contentEntry.name)) {
|
|
10990
10990
|
const contentType = contentEntry.name;
|
|
10991
|
-
const contentPath = path$
|
|
10991
|
+
const contentPath = path$5.join(analyzerPath, contentType);
|
|
10992
10992
|
const contentConfig = await readConfig$1(contentPath);
|
|
10993
10993
|
const contentLabel = contentConfig?.label || contentType;
|
|
10994
10994
|
|
|
10995
|
-
const instructionsEntries = await fs$
|
|
10995
|
+
const instructionsEntries = await fs$7.readdir(contentPath, { withFileTypes: true });
|
|
10996
10996
|
|
|
10997
10997
|
for (const instructionsEntry of instructionsEntries) {
|
|
10998
10998
|
if (instructionsEntry.isDirectory() && isValidDirName(instructionsEntry.name)) {
|
|
10999
10999
|
const instructionsType = instructionsEntry.name;
|
|
11000
|
-
const instructionsPath = path$
|
|
11000
|
+
const instructionsPath = path$5.join(contentPath, instructionsType);
|
|
11001
11001
|
const instructionsConfig = await readConfig$1(instructionsPath);
|
|
11002
11002
|
const instructionsLabel = instructionsConfig?.label || instructionsType;
|
|
11003
11003
|
|
|
11004
11004
|
// Check for the existence of 1.md to confirm a valid analyzer configuration
|
|
11005
|
-
const instructionsFilePath = path$
|
|
11005
|
+
const instructionsFilePath = path$5.join(instructionsPath, '1.md');
|
|
11006
11006
|
try {
|
|
11007
|
-
await fs$
|
|
11007
|
+
await fs$7.access(instructionsFilePath); // Check if file exists and is accessible
|
|
11008
11008
|
|
|
11009
11009
|
// If analyzerName starts with 'tutorial-', check its last modified time.
|
|
11010
11010
|
if (analyzerName.startsWith('tutorial-')) {
|
|
11011
|
-
const stats = await fs$
|
|
11011
|
+
const stats = await fs$7.stat(instructionsFilePath);
|
|
11012
11012
|
const lastModified = stats.mtime.getTime(); // Get timestamp in milliseconds
|
|
11013
11013
|
const sixtyMinutesAgo = Date.now() - (60 * 60 * 1000); // Current time - 60 minutes in ms
|
|
11014
11014
|
|
|
@@ -11062,8 +11062,8 @@ var discovery = {
|
|
|
11062
11062
|
* Authors: Gemini 2.5 Flash Thinking (v1.0.0), Gemini 2.5 Flash Thinking (v1.1.0)
|
|
11063
11063
|
*/
|
|
11064
11064
|
|
|
11065
|
-
const fs$
|
|
11066
|
-
const path$
|
|
11065
|
+
const fs$6 = require$$0.promises;
|
|
11066
|
+
const path$4 = require$$1;
|
|
11067
11067
|
|
|
11068
11068
|
/**
|
|
11069
11069
|
* Saves or updates an analyzer configuration.
|
|
@@ -11118,18 +11118,18 @@ async function saveConfiguration$1(analyzeMessagesBasePath, analyzerId, instruct
|
|
|
11118
11118
|
}
|
|
11119
11119
|
|
|
11120
11120
|
// 3. Construct directory paths
|
|
11121
|
-
const analyzerDir = path$
|
|
11122
|
-
const contentDir = path$
|
|
11123
|
-
const instructionsDir = path$
|
|
11124
|
-
const instructionsFilePath = path$
|
|
11121
|
+
const analyzerDir = path$4.join(analyzeMessagesBasePath, analyzerName);
|
|
11122
|
+
const contentDir = path$4.join(analyzerDir, contentType);
|
|
11123
|
+
const instructionsDir = path$4.join(contentDir, instructionsType);
|
|
11124
|
+
const instructionsFilePath = path$4.join(instructionsDir, '1.md');
|
|
11125
11125
|
|
|
11126
11126
|
try {
|
|
11127
11127
|
// 4. Create directories recursively
|
|
11128
|
-
await fs$
|
|
11128
|
+
await fs$6.mkdir(instructionsDir, { recursive: true });
|
|
11129
11129
|
|
|
11130
11130
|
// 5. Save instructions content to 1.md
|
|
11131
11131
|
const finalContent = `; role: assistant\n\n\n${instructionsContent}`;
|
|
11132
|
-
await fs$
|
|
11132
|
+
await fs$6.writeFile(instructionsFilePath, finalContent, 'utf8');
|
|
11133
11133
|
|
|
11134
11134
|
// 6. Optionally create/Update config.json files
|
|
11135
11135
|
if (ensureConfigs) {
|
|
@@ -11155,11 +11155,11 @@ async function saveConfiguration$1(analyzeMessagesBasePath, analyzerId, instruct
|
|
|
11155
11155
|
* @param {string} label - The label to ensure is in the config.json.
|
|
11156
11156
|
*/
|
|
11157
11157
|
async function ensureConfigJson(dirPath, label) {
|
|
11158
|
-
const configPath = path$
|
|
11158
|
+
const configPath = path$4.join(dirPath, 'config.json');
|
|
11159
11159
|
let config = {};
|
|
11160
11160
|
|
|
11161
11161
|
try {
|
|
11162
|
-
const fileContent = await fs$
|
|
11162
|
+
const fileContent = await fs$6.readFile(configPath, 'utf8');
|
|
11163
11163
|
config = JSON.parse(fileContent);
|
|
11164
11164
|
} catch (error) {
|
|
11165
11165
|
// If file doesn't exist or parsing fails, start with an empty config
|
|
@@ -11176,7 +11176,7 @@ async function ensureConfigJson(dirPath, label) {
|
|
|
11176
11176
|
}
|
|
11177
11177
|
|
|
11178
11178
|
// Write the updated config back to the file
|
|
11179
|
-
await fs$
|
|
11179
|
+
await fs$6.writeFile(configPath, JSON.stringify(config, null, 4), 'utf8');
|
|
11180
11180
|
}
|
|
11181
11181
|
|
|
11182
11182
|
|
|
@@ -11195,8 +11195,8 @@ var saver = {
|
|
|
11195
11195
|
* Authors: Gemini 2.5 Flash (v1.0.0)
|
|
11196
11196
|
*/
|
|
11197
11197
|
|
|
11198
|
-
const fs$
|
|
11199
|
-
const path$
|
|
11198
|
+
const fs$5 = require$$0.promises;
|
|
11199
|
+
const path$3 = require$$1;
|
|
11200
11200
|
const CodeBlockUtils$1 = CodeBlockUtils$4;
|
|
11201
11201
|
|
|
11202
11202
|
/**
|
|
@@ -11282,10 +11282,10 @@ async function getAnalyzerSchema$2(analyzeMessagesBasePath, analyzerId) {
|
|
|
11282
11282
|
}
|
|
11283
11283
|
const [analyzerName, contentType, instructionsType] = parts;
|
|
11284
11284
|
|
|
11285
|
-
const instructionsFilePath = path$
|
|
11285
|
+
const instructionsFilePath = path$3.join(analyzeMessagesBasePath, analyzerName, contentType, instructionsType, '1.md');
|
|
11286
11286
|
|
|
11287
11287
|
try {
|
|
11288
|
-
const fileContent = await fs$
|
|
11288
|
+
const fileContent = await fs$5.readFile(instructionsFilePath, 'utf8');
|
|
11289
11289
|
const { blocks } = CodeBlockUtils$1.extractCodeBlocks(fileContent, { silent: true });
|
|
11290
11290
|
const jsonBlocks = blocks.filter(block => block.type === 'code' && block.language === 'json');
|
|
11291
11291
|
|
|
@@ -11356,8 +11356,8 @@ var schemaLoader = {
|
|
|
11356
11356
|
* Authors: Gemini 2.5 Flash (v1.0.0)
|
|
11357
11357
|
*/
|
|
11358
11358
|
|
|
11359
|
-
const fs$
|
|
11360
|
-
const path$
|
|
11359
|
+
const fs$4 = require$$0.promises;
|
|
11360
|
+
const path$2 = require$$1;
|
|
11361
11361
|
const { readConfig } = discovery; // Import helper from discovery
|
|
11362
11362
|
|
|
11363
11363
|
/**
|
|
@@ -11367,7 +11367,7 @@ const { readConfig } = discovery; // Import helper from discovery
|
|
|
11367
11367
|
*/
|
|
11368
11368
|
async function isDirectoryEmpty(dirPath) {
|
|
11369
11369
|
try {
|
|
11370
|
-
const files = await fs$
|
|
11370
|
+
const files = await fs$4.readdir(dirPath);
|
|
11371
11371
|
return files.length === 0 || (files.length === 1 && files[0] === 'config.json');
|
|
11372
11372
|
} catch (error) {
|
|
11373
11373
|
if (error.code === 'ENOENT') {
|
|
@@ -11398,10 +11398,10 @@ async function deleteAnalyzer$2(analyzeMessagesBasePath, analyzerId) {
|
|
|
11398
11398
|
}
|
|
11399
11399
|
const [analyzerName, contentType, instructionsType] = parts;
|
|
11400
11400
|
|
|
11401
|
-
const analyzerDir = path$
|
|
11402
|
-
const contentDir = path$
|
|
11403
|
-
const instructionsDir = path$
|
|
11404
|
-
const instructionsFilePath = path$
|
|
11401
|
+
const analyzerDir = path$2.join(analyzeMessagesBasePath, analyzerName);
|
|
11402
|
+
const contentDir = path$2.join(analyzerDir, contentType);
|
|
11403
|
+
const instructionsDir = path$2.join(contentDir, instructionsType);
|
|
11404
|
+
const instructionsFilePath = path$2.join(instructionsDir, '1.md');
|
|
11405
11405
|
|
|
11406
11406
|
try {
|
|
11407
11407
|
// 1. Check for protection at all levels
|
|
@@ -11422,7 +11422,7 @@ async function deleteAnalyzer$2(analyzeMessagesBasePath, analyzerId) {
|
|
|
11422
11422
|
|
|
11423
11423
|
// 2. Delete the 1.md file
|
|
11424
11424
|
try {
|
|
11425
|
-
await fs$
|
|
11425
|
+
await fs$4.unlink(instructionsFilePath);
|
|
11426
11426
|
} catch (error) {
|
|
11427
11427
|
if (error.code === 'ENOENT') {
|
|
11428
11428
|
return { success: false, message: `Analyzer instructions file not found: ${instructionsFilePath}. It may have already been deleted.` };
|
|
@@ -11436,7 +11436,7 @@ async function deleteAnalyzer$2(analyzeMessagesBasePath, analyzerId) {
|
|
|
11436
11436
|
// Check and delete instructions directory
|
|
11437
11437
|
if (await isDirectoryEmpty(instructionsDir)) {
|
|
11438
11438
|
try {
|
|
11439
|
-
await fs$
|
|
11439
|
+
await fs$4.rmdir(instructionsDir);
|
|
11440
11440
|
deletedDirs.push(instructionsDir);
|
|
11441
11441
|
} catch (error) {
|
|
11442
11442
|
console.warn(`Warning: Could not remove empty instructions directory ${instructionsDir}: ${error.message}`);
|
|
@@ -11446,7 +11446,7 @@ async function deleteAnalyzer$2(analyzeMessagesBasePath, analyzerId) {
|
|
|
11446
11446
|
// Check and delete content directory
|
|
11447
11447
|
if (await isDirectoryEmpty(contentDir)) {
|
|
11448
11448
|
try {
|
|
11449
|
-
await fs$
|
|
11449
|
+
await fs$4.rmdir(contentDir);
|
|
11450
11450
|
deletedDirs.push(contentDir);
|
|
11451
11451
|
} catch (error) {
|
|
11452
11452
|
console.warn(`Warning: Could not remove empty content directory ${contentDir}: ${error.message}`);
|
|
@@ -11456,7 +11456,7 @@ async function deleteAnalyzer$2(analyzeMessagesBasePath, analyzerId) {
|
|
|
11456
11456
|
// Check and delete analyzer directory
|
|
11457
11457
|
if (await isDirectoryEmpty(analyzerDir)) {
|
|
11458
11458
|
try {
|
|
11459
|
-
await fs$
|
|
11459
|
+
await fs$4.rmdir(analyzerDir);
|
|
11460
11460
|
deletedDirs.push(analyzerDir);
|
|
11461
11461
|
} catch (error) {
|
|
11462
11462
|
console.warn(`Warning: Could not remove empty analyzer directory ${analyzerDir}: ${error.message}`);
|
|
@@ -11485,8 +11485,8 @@ var management = {
|
|
|
11485
11485
|
* Authors: Gemini 2.5 Flash (v1.0.0)
|
|
11486
11486
|
*/
|
|
11487
11487
|
|
|
11488
|
-
const fs$
|
|
11489
|
-
const path = require$$1;
|
|
11488
|
+
const fs$3 = require$$0.promises;
|
|
11489
|
+
const path$1 = require$$1;
|
|
11490
11490
|
|
|
11491
11491
|
/**
|
|
11492
11492
|
* Retrieves the raw Markdown content of the analyzer's '1.md' instruction file.
|
|
@@ -11512,10 +11512,10 @@ async function getAnalyzerInstructionsContent$2(analyzeMessagesBasePath, analyze
|
|
|
11512
11512
|
}
|
|
11513
11513
|
const [analyzerName, contentType, instructionsType] = parts;
|
|
11514
11514
|
|
|
11515
|
-
const instructionsFilePath = path.join(analyzeMessagesBasePath, analyzerName, contentType, instructionsType, '1.md');
|
|
11515
|
+
const instructionsFilePath = path$1.join(analyzeMessagesBasePath, analyzerName, contentType, instructionsType, '1.md');
|
|
11516
11516
|
|
|
11517
11517
|
try {
|
|
11518
|
-
const fileContent = await fs$
|
|
11518
|
+
const fileContent = await fs$3.readFile(instructionsFilePath, 'utf8');
|
|
11519
11519
|
return fileContent;
|
|
11520
11520
|
} catch (error) {
|
|
11521
11521
|
if (error.code === 'ENOENT') {
|
|
@@ -11532,15 +11532,90 @@ var instructionLoader = {
|
|
|
11532
11532
|
getAnalyzerInstructionsContent: getAnalyzerInstructionsContent$2
|
|
11533
11533
|
};
|
|
11534
11534
|
|
|
11535
|
+
/*
|
|
11536
|
+
* Component: AnalyzerUtils Default Prompt Loader
|
|
11537
|
+
* Block-UUID: 0b1c2d3e-4f5a-6b7c-8d9e-0f1a2b3c4d5f
|
|
11538
|
+
* Parent-UUID: N/A
|
|
11539
|
+
* Version: 1.0.0
|
|
11540
|
+
* Description: Provides utility functions for loading shared, default prompt components (system and start messages).
|
|
11541
|
+
* Language: JavaScript
|
|
11542
|
+
* Created-at: 2025-08-29T03:30:28.771Z
|
|
11543
|
+
* Authors: Gemini 2.5 Flash (v1.0.0)
|
|
11544
|
+
*/
|
|
11545
|
+
|
|
11546
|
+
const fs$2 = require$$0.promises;
|
|
11547
|
+
const path = require$$1;
|
|
11548
|
+
|
|
11549
|
+
/**
|
|
11550
|
+
* Retrieves the raw Markdown content of the shared system message ('_shared/system/1.md').
|
|
11551
|
+
*
|
|
11552
|
+
* @param {string} analyzeMessagesBasePath - The absolute path to the base directory containing analyzer message files (e.g., 'messages/analyze').
|
|
11553
|
+
* @returns {Promise<string|null>} A promise that resolves with the full Markdown content, or null if not found/invalid.
|
|
11554
|
+
*/
|
|
11555
|
+
async function getSystemMessageContent$2(analyzeMessagesBasePath) {
|
|
11556
|
+
if (typeof analyzeMessagesBasePath !== 'string' || analyzeMessagesBasePath.trim() === '') {
|
|
11557
|
+
console.error('Error: analyzeMessagesBasePath is required for getSystemMessageContent.');
|
|
11558
|
+
return null;
|
|
11559
|
+
}
|
|
11560
|
+
|
|
11561
|
+
const systemMessageFilePath = path.join(analyzeMessagesBasePath, '_shared', 'system', '1.md');
|
|
11562
|
+
|
|
11563
|
+
try {
|
|
11564
|
+
const fileContent = await fs$2.readFile(systemMessageFilePath, 'utf8');
|
|
11565
|
+
return fileContent;
|
|
11566
|
+
} catch (error) {
|
|
11567
|
+
if (error.code === 'ENOENT') {
|
|
11568
|
+
console.warn(`Default system message file not found: ${systemMessageFilePath}.`);
|
|
11569
|
+
return null;
|
|
11570
|
+
} else {
|
|
11571
|
+
console.error(`Error reading default system message file ${systemMessageFilePath}: ${error.message}`);
|
|
11572
|
+
throw error;
|
|
11573
|
+
}
|
|
11574
|
+
}
|
|
11575
|
+
}
|
|
11576
|
+
|
|
11577
|
+
/**
|
|
11578
|
+
* Retrieves the raw Markdown content of the shared start message ('_shared/start/1.md').
|
|
11579
|
+
*
|
|
11580
|
+
* @param {string} analyzeMessagesBasePath - The absolute path to the base directory containing analyzer message files (e.g., 'messages/analyze').
|
|
11581
|
+
* @returns {Promise<string|null>} A promise that resolves with the full Markdown content, or null if not found/invalid.
|
|
11582
|
+
*/
|
|
11583
|
+
async function getStartMessageContent$2(analyzeMessagesBasePath) {
|
|
11584
|
+
if (typeof analyzeMessagesBasePath !== 'string' || analyzeMessagesBasePath.trim() === '') {
|
|
11585
|
+
console.error('Error: analyzeMessagesBasePath is required for getStartMessageContent.');
|
|
11586
|
+
return null;
|
|
11587
|
+
}
|
|
11588
|
+
|
|
11589
|
+
const startMessageFilePath = path.join(analyzeMessagesBasePath, '_shared', 'start', '1.md');
|
|
11590
|
+
|
|
11591
|
+
try {
|
|
11592
|
+
const fileContent = await fs$2.readFile(startMessageFilePath, 'utf8');
|
|
11593
|
+
return fileContent;
|
|
11594
|
+
} catch (error) {
|
|
11595
|
+
if (error.code === 'ENOENT') {
|
|
11596
|
+
console.warn(`Default start message file not found: ${startMessageFilePath}.`);
|
|
11597
|
+
return null;
|
|
11598
|
+
} else {
|
|
11599
|
+
console.error(`Error reading default start message file ${startMessageFilePath}: ${error.message}`);
|
|
11600
|
+
throw error;
|
|
11601
|
+
}
|
|
11602
|
+
}
|
|
11603
|
+
}
|
|
11604
|
+
|
|
11605
|
+
var defaultPromptLoader = {
|
|
11606
|
+
getSystemMessageContent: getSystemMessageContent$2,
|
|
11607
|
+
getStartMessageContent: getStartMessageContent$2
|
|
11608
|
+
};
|
|
11609
|
+
|
|
11535
11610
|
/*
|
|
11536
11611
|
* Component: AnalyzerUtils Index
|
|
11537
11612
|
* Block-UUID: b403b6a1-230b-4247-8cd6-2a3d068f4bbf
|
|
11538
11613
|
* Parent-UUID: N/A
|
|
11539
|
-
* Version: 1.
|
|
11614
|
+
* Version: 1.2.0
|
|
11540
11615
|
* Description: Aggregates and exports all utility functions from the AnalyzerUtils module.
|
|
11541
11616
|
* Language: JavaScript
|
|
11542
11617
|
* Created-at: 2025-08-28T15:56:40.319Z
|
|
11543
|
-
* Authors: Gemini 2.5 Flash (v1.0.0), Gemini 2.5 Flash (v1.1.0)
|
|
11618
|
+
* Authors: Gemini 2.5 Flash (v1.0.0), Gemini 2.5 Flash (v1.1.0), Gemini 2.5 Flash (v1.2.0)
|
|
11544
11619
|
*/
|
|
11545
11620
|
|
|
11546
11621
|
const { buildChatIdToPathMap: buildChatIdToPathMap$1 } = contextMapper;
|
|
@@ -11551,6 +11626,7 @@ const { saveConfiguration } = saver;
|
|
|
11551
11626
|
const { getAnalyzerSchema: getAnalyzerSchema$1 } = schemaLoader;
|
|
11552
11627
|
const { deleteAnalyzer: deleteAnalyzer$1 } = management;
|
|
11553
11628
|
const { getAnalyzerInstructionsContent: getAnalyzerInstructionsContent$1 } = instructionLoader;
|
|
11629
|
+
const { getSystemMessageContent: getSystemMessageContent$1, getStartMessageContent: getStartMessageContent$1 } = defaultPromptLoader; // NEW: Import default prompt loaders
|
|
11554
11630
|
|
|
11555
11631
|
var AnalyzerUtils$1 = {
|
|
11556
11632
|
buildChatIdToPathMap: buildChatIdToPathMap$1,
|
|
@@ -11561,6 +11637,8 @@ var AnalyzerUtils$1 = {
|
|
|
11561
11637
|
deleteAnalyzer: deleteAnalyzer$1,
|
|
11562
11638
|
getAnalyzerInstructionsContent: getAnalyzerInstructionsContent$1,
|
|
11563
11639
|
saveConfiguration,
|
|
11640
|
+
getSystemMessageContent: getSystemMessageContent$1,
|
|
11641
|
+
getStartMessageContent: getStartMessageContent$1
|
|
11564
11642
|
};
|
|
11565
11643
|
|
|
11566
11644
|
/**
|
|
@@ -11831,6 +11909,8 @@ const {
|
|
|
11831
11909
|
getAnalyzerSchema,
|
|
11832
11910
|
deleteAnalyzer,
|
|
11833
11911
|
getAnalyzerInstructionsContent,
|
|
11912
|
+
getSystemMessageContent,
|
|
11913
|
+
getStartMessageContent,
|
|
11834
11914
|
saveAnalyzerConfiguration,
|
|
11835
11915
|
} = AnalyzerUtils;
|
|
11836
11916
|
|
|
@@ -12166,6 +12246,8 @@ var GitSenseChatUtils_1 = {
|
|
|
12166
12246
|
getAnalyzerSchema,
|
|
12167
12247
|
deleteAnalyzer,
|
|
12168
12248
|
getAnalyzerInstructionsContent,
|
|
12249
|
+
getSystemMessageContent,
|
|
12250
|
+
getStartMessageContent,
|
|
12169
12251
|
|
|
12170
12252
|
// ChatUtils
|
|
12171
12253
|
getChatMessages,
|
package/dist/gsc-utils.esm.js
CHANGED
|
@@ -16,8 +16,8 @@ function getDefaultExportFromCjs (x) {
|
|
|
16
16
|
* Authors: Claude 3.7 Sonnet (v1.0.0), Gemini 2.5 Pro (v1.1.0), Gemini 2.5 Flash Thinking (v1.2.0)
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
const fs$
|
|
20
|
-
const path$
|
|
19
|
+
const fs$8 = require$$0;
|
|
20
|
+
const path$6 = require$$1;
|
|
21
21
|
const ANALYZE_MESSAGE_REGEXP = /^# Analyze - `([^`]+)`\n/;
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -51,12 +51,12 @@ function unescapeCodeBlocks(content) {
|
|
|
51
51
|
* @returns {Array} An array of message objects with role and content properties
|
|
52
52
|
*/
|
|
53
53
|
function getChatTemplateMessages$1(dirname, messageType) {
|
|
54
|
-
const messagesDir = path$
|
|
54
|
+
const messagesDir = path$6.join(dirname, messageType);
|
|
55
55
|
const messages = [];
|
|
56
56
|
|
|
57
57
|
try {
|
|
58
58
|
// Read all files in the directory
|
|
59
|
-
const files = fs$
|
|
59
|
+
const files = fs$8.readdirSync(messagesDir);
|
|
60
60
|
|
|
61
61
|
// Sort files numerically (1.md, 2.md, etc.)
|
|
62
62
|
const sortedFiles = files.sort((a, b) => {
|
|
@@ -67,9 +67,9 @@ function getChatTemplateMessages$1(dirname, messageType) {
|
|
|
67
67
|
|
|
68
68
|
// Process each file
|
|
69
69
|
for (const file of sortedFiles) {
|
|
70
|
-
if (path$
|
|
71
|
-
const filePath = path$
|
|
72
|
-
const fileContent = fs$
|
|
70
|
+
if (path$6.extname(file) === '.md') {
|
|
71
|
+
const filePath = path$6.join(messagesDir, file);
|
|
72
|
+
const fileContent = fs$8.readFileSync(filePath, 'utf8');
|
|
73
73
|
|
|
74
74
|
// Split by triple newline to separate metadata from content
|
|
75
75
|
const parts = fileContent.split('\n\n\n');
|
|
@@ -10923,8 +10923,8 @@ var dataValidator = {
|
|
|
10923
10923
|
* Authors: Gemini 2.5 Flash (v1.0.0)
|
|
10924
10924
|
*/
|
|
10925
10925
|
|
|
10926
|
-
const fs$
|
|
10927
|
-
const path$
|
|
10926
|
+
const fs$7 = require$$0.promises;
|
|
10927
|
+
const path$5 = require$$1;
|
|
10928
10928
|
|
|
10929
10929
|
/**
|
|
10930
10930
|
* Reads and parses the config.json file in a directory.
|
|
@@ -10933,9 +10933,9 @@ const path$4 = require$$1;
|
|
|
10933
10933
|
* or null if the file doesn't exist or is invalid.
|
|
10934
10934
|
*/
|
|
10935
10935
|
async function readConfig$1(dirPath) {
|
|
10936
|
-
const configPath = path$
|
|
10936
|
+
const configPath = path$5.join(dirPath, 'config.json');
|
|
10937
10937
|
try {
|
|
10938
|
-
const fileContent = await fs$
|
|
10938
|
+
const fileContent = await fs$7.readFile(configPath, 'utf8');
|
|
10939
10939
|
return JSON.parse(fileContent);
|
|
10940
10940
|
} catch (error) {
|
|
10941
10941
|
if (error.code !== 'ENOENT') {
|
|
@@ -10972,41 +10972,41 @@ async function getAnalyzers$2(analyzeMessagesBasePath) {
|
|
|
10972
10972
|
const analyzers = [];
|
|
10973
10973
|
|
|
10974
10974
|
try {
|
|
10975
|
-
const analyzerEntries = await fs$
|
|
10975
|
+
const analyzerEntries = await fs$7.readdir(analyzeMessagesBasePath, { withFileTypes: true });
|
|
10976
10976
|
|
|
10977
10977
|
for (const analyzerEntry of analyzerEntries) {
|
|
10978
10978
|
if (analyzerEntry.isDirectory() && isValidDirName(analyzerEntry.name)) {
|
|
10979
10979
|
const analyzerName = analyzerEntry.name;
|
|
10980
|
-
const analyzerPath = path$
|
|
10980
|
+
const analyzerPath = path$5.join(analyzeMessagesBasePath, analyzerName);
|
|
10981
10981
|
const analyzerConfig = await readConfig$1(analyzerPath);
|
|
10982
10982
|
const analyzerLabel = analyzerConfig?.label || analyzerName;
|
|
10983
10983
|
|
|
10984
|
-
const contentEntries = await fs$
|
|
10984
|
+
const contentEntries = await fs$7.readdir(analyzerPath, { withFileTypes: true });
|
|
10985
10985
|
|
|
10986
10986
|
for (const contentEntry of contentEntries) {
|
|
10987
10987
|
if (contentEntry.isDirectory() && isValidDirName(contentEntry.name)) {
|
|
10988
10988
|
const contentType = contentEntry.name;
|
|
10989
|
-
const contentPath = path$
|
|
10989
|
+
const contentPath = path$5.join(analyzerPath, contentType);
|
|
10990
10990
|
const contentConfig = await readConfig$1(contentPath);
|
|
10991
10991
|
const contentLabel = contentConfig?.label || contentType;
|
|
10992
10992
|
|
|
10993
|
-
const instructionsEntries = await fs$
|
|
10993
|
+
const instructionsEntries = await fs$7.readdir(contentPath, { withFileTypes: true });
|
|
10994
10994
|
|
|
10995
10995
|
for (const instructionsEntry of instructionsEntries) {
|
|
10996
10996
|
if (instructionsEntry.isDirectory() && isValidDirName(instructionsEntry.name)) {
|
|
10997
10997
|
const instructionsType = instructionsEntry.name;
|
|
10998
|
-
const instructionsPath = path$
|
|
10998
|
+
const instructionsPath = path$5.join(contentPath, instructionsType);
|
|
10999
10999
|
const instructionsConfig = await readConfig$1(instructionsPath);
|
|
11000
11000
|
const instructionsLabel = instructionsConfig?.label || instructionsType;
|
|
11001
11001
|
|
|
11002
11002
|
// Check for the existence of 1.md to confirm a valid analyzer configuration
|
|
11003
|
-
const instructionsFilePath = path$
|
|
11003
|
+
const instructionsFilePath = path$5.join(instructionsPath, '1.md');
|
|
11004
11004
|
try {
|
|
11005
|
-
await fs$
|
|
11005
|
+
await fs$7.access(instructionsFilePath); // Check if file exists and is accessible
|
|
11006
11006
|
|
|
11007
11007
|
// If analyzerName starts with 'tutorial-', check its last modified time.
|
|
11008
11008
|
if (analyzerName.startsWith('tutorial-')) {
|
|
11009
|
-
const stats = await fs$
|
|
11009
|
+
const stats = await fs$7.stat(instructionsFilePath);
|
|
11010
11010
|
const lastModified = stats.mtime.getTime(); // Get timestamp in milliseconds
|
|
11011
11011
|
const sixtyMinutesAgo = Date.now() - (60 * 60 * 1000); // Current time - 60 minutes in ms
|
|
11012
11012
|
|
|
@@ -11060,8 +11060,8 @@ var discovery = {
|
|
|
11060
11060
|
* Authors: Gemini 2.5 Flash Thinking (v1.0.0), Gemini 2.5 Flash Thinking (v1.1.0)
|
|
11061
11061
|
*/
|
|
11062
11062
|
|
|
11063
|
-
const fs$
|
|
11064
|
-
const path$
|
|
11063
|
+
const fs$6 = require$$0.promises;
|
|
11064
|
+
const path$4 = require$$1;
|
|
11065
11065
|
|
|
11066
11066
|
/**
|
|
11067
11067
|
* Saves or updates an analyzer configuration.
|
|
@@ -11116,18 +11116,18 @@ async function saveConfiguration$1(analyzeMessagesBasePath, analyzerId, instruct
|
|
|
11116
11116
|
}
|
|
11117
11117
|
|
|
11118
11118
|
// 3. Construct directory paths
|
|
11119
|
-
const analyzerDir = path$
|
|
11120
|
-
const contentDir = path$
|
|
11121
|
-
const instructionsDir = path$
|
|
11122
|
-
const instructionsFilePath = path$
|
|
11119
|
+
const analyzerDir = path$4.join(analyzeMessagesBasePath, analyzerName);
|
|
11120
|
+
const contentDir = path$4.join(analyzerDir, contentType);
|
|
11121
|
+
const instructionsDir = path$4.join(contentDir, instructionsType);
|
|
11122
|
+
const instructionsFilePath = path$4.join(instructionsDir, '1.md');
|
|
11123
11123
|
|
|
11124
11124
|
try {
|
|
11125
11125
|
// 4. Create directories recursively
|
|
11126
|
-
await fs$
|
|
11126
|
+
await fs$6.mkdir(instructionsDir, { recursive: true });
|
|
11127
11127
|
|
|
11128
11128
|
// 5. Save instructions content to 1.md
|
|
11129
11129
|
const finalContent = `; role: assistant\n\n\n${instructionsContent}`;
|
|
11130
|
-
await fs$
|
|
11130
|
+
await fs$6.writeFile(instructionsFilePath, finalContent, 'utf8');
|
|
11131
11131
|
|
|
11132
11132
|
// 6. Optionally create/Update config.json files
|
|
11133
11133
|
if (ensureConfigs) {
|
|
@@ -11153,11 +11153,11 @@ async function saveConfiguration$1(analyzeMessagesBasePath, analyzerId, instruct
|
|
|
11153
11153
|
* @param {string} label - The label to ensure is in the config.json.
|
|
11154
11154
|
*/
|
|
11155
11155
|
async function ensureConfigJson(dirPath, label) {
|
|
11156
|
-
const configPath = path$
|
|
11156
|
+
const configPath = path$4.join(dirPath, 'config.json');
|
|
11157
11157
|
let config = {};
|
|
11158
11158
|
|
|
11159
11159
|
try {
|
|
11160
|
-
const fileContent = await fs$
|
|
11160
|
+
const fileContent = await fs$6.readFile(configPath, 'utf8');
|
|
11161
11161
|
config = JSON.parse(fileContent);
|
|
11162
11162
|
} catch (error) {
|
|
11163
11163
|
// If file doesn't exist or parsing fails, start with an empty config
|
|
@@ -11174,7 +11174,7 @@ async function ensureConfigJson(dirPath, label) {
|
|
|
11174
11174
|
}
|
|
11175
11175
|
|
|
11176
11176
|
// Write the updated config back to the file
|
|
11177
|
-
await fs$
|
|
11177
|
+
await fs$6.writeFile(configPath, JSON.stringify(config, null, 4), 'utf8');
|
|
11178
11178
|
}
|
|
11179
11179
|
|
|
11180
11180
|
|
|
@@ -11193,8 +11193,8 @@ var saver = {
|
|
|
11193
11193
|
* Authors: Gemini 2.5 Flash (v1.0.0)
|
|
11194
11194
|
*/
|
|
11195
11195
|
|
|
11196
|
-
const fs$
|
|
11197
|
-
const path$
|
|
11196
|
+
const fs$5 = require$$0.promises;
|
|
11197
|
+
const path$3 = require$$1;
|
|
11198
11198
|
const CodeBlockUtils$1 = CodeBlockUtils$4;
|
|
11199
11199
|
|
|
11200
11200
|
/**
|
|
@@ -11280,10 +11280,10 @@ async function getAnalyzerSchema$2(analyzeMessagesBasePath, analyzerId) {
|
|
|
11280
11280
|
}
|
|
11281
11281
|
const [analyzerName, contentType, instructionsType] = parts;
|
|
11282
11282
|
|
|
11283
|
-
const instructionsFilePath = path$
|
|
11283
|
+
const instructionsFilePath = path$3.join(analyzeMessagesBasePath, analyzerName, contentType, instructionsType, '1.md');
|
|
11284
11284
|
|
|
11285
11285
|
try {
|
|
11286
|
-
const fileContent = await fs$
|
|
11286
|
+
const fileContent = await fs$5.readFile(instructionsFilePath, 'utf8');
|
|
11287
11287
|
const { blocks } = CodeBlockUtils$1.extractCodeBlocks(fileContent, { silent: true });
|
|
11288
11288
|
const jsonBlocks = blocks.filter(block => block.type === 'code' && block.language === 'json');
|
|
11289
11289
|
|
|
@@ -11354,8 +11354,8 @@ var schemaLoader = {
|
|
|
11354
11354
|
* Authors: Gemini 2.5 Flash (v1.0.0)
|
|
11355
11355
|
*/
|
|
11356
11356
|
|
|
11357
|
-
const fs$
|
|
11358
|
-
const path$
|
|
11357
|
+
const fs$4 = require$$0.promises;
|
|
11358
|
+
const path$2 = require$$1;
|
|
11359
11359
|
const { readConfig } = discovery; // Import helper from discovery
|
|
11360
11360
|
|
|
11361
11361
|
/**
|
|
@@ -11365,7 +11365,7 @@ const { readConfig } = discovery; // Import helper from discovery
|
|
|
11365
11365
|
*/
|
|
11366
11366
|
async function isDirectoryEmpty(dirPath) {
|
|
11367
11367
|
try {
|
|
11368
|
-
const files = await fs$
|
|
11368
|
+
const files = await fs$4.readdir(dirPath);
|
|
11369
11369
|
return files.length === 0 || (files.length === 1 && files[0] === 'config.json');
|
|
11370
11370
|
} catch (error) {
|
|
11371
11371
|
if (error.code === 'ENOENT') {
|
|
@@ -11396,10 +11396,10 @@ async function deleteAnalyzer$2(analyzeMessagesBasePath, analyzerId) {
|
|
|
11396
11396
|
}
|
|
11397
11397
|
const [analyzerName, contentType, instructionsType] = parts;
|
|
11398
11398
|
|
|
11399
|
-
const analyzerDir = path$
|
|
11400
|
-
const contentDir = path$
|
|
11401
|
-
const instructionsDir = path$
|
|
11402
|
-
const instructionsFilePath = path$
|
|
11399
|
+
const analyzerDir = path$2.join(analyzeMessagesBasePath, analyzerName);
|
|
11400
|
+
const contentDir = path$2.join(analyzerDir, contentType);
|
|
11401
|
+
const instructionsDir = path$2.join(contentDir, instructionsType);
|
|
11402
|
+
const instructionsFilePath = path$2.join(instructionsDir, '1.md');
|
|
11403
11403
|
|
|
11404
11404
|
try {
|
|
11405
11405
|
// 1. Check for protection at all levels
|
|
@@ -11420,7 +11420,7 @@ async function deleteAnalyzer$2(analyzeMessagesBasePath, analyzerId) {
|
|
|
11420
11420
|
|
|
11421
11421
|
// 2. Delete the 1.md file
|
|
11422
11422
|
try {
|
|
11423
|
-
await fs$
|
|
11423
|
+
await fs$4.unlink(instructionsFilePath);
|
|
11424
11424
|
} catch (error) {
|
|
11425
11425
|
if (error.code === 'ENOENT') {
|
|
11426
11426
|
return { success: false, message: `Analyzer instructions file not found: ${instructionsFilePath}. It may have already been deleted.` };
|
|
@@ -11434,7 +11434,7 @@ async function deleteAnalyzer$2(analyzeMessagesBasePath, analyzerId) {
|
|
|
11434
11434
|
// Check and delete instructions directory
|
|
11435
11435
|
if (await isDirectoryEmpty(instructionsDir)) {
|
|
11436
11436
|
try {
|
|
11437
|
-
await fs$
|
|
11437
|
+
await fs$4.rmdir(instructionsDir);
|
|
11438
11438
|
deletedDirs.push(instructionsDir);
|
|
11439
11439
|
} catch (error) {
|
|
11440
11440
|
console.warn(`Warning: Could not remove empty instructions directory ${instructionsDir}: ${error.message}`);
|
|
@@ -11444,7 +11444,7 @@ async function deleteAnalyzer$2(analyzeMessagesBasePath, analyzerId) {
|
|
|
11444
11444
|
// Check and delete content directory
|
|
11445
11445
|
if (await isDirectoryEmpty(contentDir)) {
|
|
11446
11446
|
try {
|
|
11447
|
-
await fs$
|
|
11447
|
+
await fs$4.rmdir(contentDir);
|
|
11448
11448
|
deletedDirs.push(contentDir);
|
|
11449
11449
|
} catch (error) {
|
|
11450
11450
|
console.warn(`Warning: Could not remove empty content directory ${contentDir}: ${error.message}`);
|
|
@@ -11454,7 +11454,7 @@ async function deleteAnalyzer$2(analyzeMessagesBasePath, analyzerId) {
|
|
|
11454
11454
|
// Check and delete analyzer directory
|
|
11455
11455
|
if (await isDirectoryEmpty(analyzerDir)) {
|
|
11456
11456
|
try {
|
|
11457
|
-
await fs$
|
|
11457
|
+
await fs$4.rmdir(analyzerDir);
|
|
11458
11458
|
deletedDirs.push(analyzerDir);
|
|
11459
11459
|
} catch (error) {
|
|
11460
11460
|
console.warn(`Warning: Could not remove empty analyzer directory ${analyzerDir}: ${error.message}`);
|
|
@@ -11483,8 +11483,8 @@ var management = {
|
|
|
11483
11483
|
* Authors: Gemini 2.5 Flash (v1.0.0)
|
|
11484
11484
|
*/
|
|
11485
11485
|
|
|
11486
|
-
const fs$
|
|
11487
|
-
const path = require$$1;
|
|
11486
|
+
const fs$3 = require$$0.promises;
|
|
11487
|
+
const path$1 = require$$1;
|
|
11488
11488
|
|
|
11489
11489
|
/**
|
|
11490
11490
|
* Retrieves the raw Markdown content of the analyzer's '1.md' instruction file.
|
|
@@ -11510,10 +11510,10 @@ async function getAnalyzerInstructionsContent$2(analyzeMessagesBasePath, analyze
|
|
|
11510
11510
|
}
|
|
11511
11511
|
const [analyzerName, contentType, instructionsType] = parts;
|
|
11512
11512
|
|
|
11513
|
-
const instructionsFilePath = path.join(analyzeMessagesBasePath, analyzerName, contentType, instructionsType, '1.md');
|
|
11513
|
+
const instructionsFilePath = path$1.join(analyzeMessagesBasePath, analyzerName, contentType, instructionsType, '1.md');
|
|
11514
11514
|
|
|
11515
11515
|
try {
|
|
11516
|
-
const fileContent = await fs$
|
|
11516
|
+
const fileContent = await fs$3.readFile(instructionsFilePath, 'utf8');
|
|
11517
11517
|
return fileContent;
|
|
11518
11518
|
} catch (error) {
|
|
11519
11519
|
if (error.code === 'ENOENT') {
|
|
@@ -11530,15 +11530,90 @@ var instructionLoader = {
|
|
|
11530
11530
|
getAnalyzerInstructionsContent: getAnalyzerInstructionsContent$2
|
|
11531
11531
|
};
|
|
11532
11532
|
|
|
11533
|
+
/*
|
|
11534
|
+
* Component: AnalyzerUtils Default Prompt Loader
|
|
11535
|
+
* Block-UUID: 0b1c2d3e-4f5a-6b7c-8d9e-0f1a2b3c4d5f
|
|
11536
|
+
* Parent-UUID: N/A
|
|
11537
|
+
* Version: 1.0.0
|
|
11538
|
+
* Description: Provides utility functions for loading shared, default prompt components (system and start messages).
|
|
11539
|
+
* Language: JavaScript
|
|
11540
|
+
* Created-at: 2025-08-29T03:30:28.771Z
|
|
11541
|
+
* Authors: Gemini 2.5 Flash (v1.0.0)
|
|
11542
|
+
*/
|
|
11543
|
+
|
|
11544
|
+
const fs$2 = require$$0.promises;
|
|
11545
|
+
const path = require$$1;
|
|
11546
|
+
|
|
11547
|
+
/**
|
|
11548
|
+
* Retrieves the raw Markdown content of the shared system message ('_shared/system/1.md').
|
|
11549
|
+
*
|
|
11550
|
+
* @param {string} analyzeMessagesBasePath - The absolute path to the base directory containing analyzer message files (e.g., 'messages/analyze').
|
|
11551
|
+
* @returns {Promise<string|null>} A promise that resolves with the full Markdown content, or null if not found/invalid.
|
|
11552
|
+
*/
|
|
11553
|
+
async function getSystemMessageContent$2(analyzeMessagesBasePath) {
|
|
11554
|
+
if (typeof analyzeMessagesBasePath !== 'string' || analyzeMessagesBasePath.trim() === '') {
|
|
11555
|
+
console.error('Error: analyzeMessagesBasePath is required for getSystemMessageContent.');
|
|
11556
|
+
return null;
|
|
11557
|
+
}
|
|
11558
|
+
|
|
11559
|
+
const systemMessageFilePath = path.join(analyzeMessagesBasePath, '_shared', 'system', '1.md');
|
|
11560
|
+
|
|
11561
|
+
try {
|
|
11562
|
+
const fileContent = await fs$2.readFile(systemMessageFilePath, 'utf8');
|
|
11563
|
+
return fileContent;
|
|
11564
|
+
} catch (error) {
|
|
11565
|
+
if (error.code === 'ENOENT') {
|
|
11566
|
+
console.warn(`Default system message file not found: ${systemMessageFilePath}.`);
|
|
11567
|
+
return null;
|
|
11568
|
+
} else {
|
|
11569
|
+
console.error(`Error reading default system message file ${systemMessageFilePath}: ${error.message}`);
|
|
11570
|
+
throw error;
|
|
11571
|
+
}
|
|
11572
|
+
}
|
|
11573
|
+
}
|
|
11574
|
+
|
|
11575
|
+
/**
|
|
11576
|
+
* Retrieves the raw Markdown content of the shared start message ('_shared/start/1.md').
|
|
11577
|
+
*
|
|
11578
|
+
* @param {string} analyzeMessagesBasePath - The absolute path to the base directory containing analyzer message files (e.g., 'messages/analyze').
|
|
11579
|
+
* @returns {Promise<string|null>} A promise that resolves with the full Markdown content, or null if not found/invalid.
|
|
11580
|
+
*/
|
|
11581
|
+
async function getStartMessageContent$2(analyzeMessagesBasePath) {
|
|
11582
|
+
if (typeof analyzeMessagesBasePath !== 'string' || analyzeMessagesBasePath.trim() === '') {
|
|
11583
|
+
console.error('Error: analyzeMessagesBasePath is required for getStartMessageContent.');
|
|
11584
|
+
return null;
|
|
11585
|
+
}
|
|
11586
|
+
|
|
11587
|
+
const startMessageFilePath = path.join(analyzeMessagesBasePath, '_shared', 'start', '1.md');
|
|
11588
|
+
|
|
11589
|
+
try {
|
|
11590
|
+
const fileContent = await fs$2.readFile(startMessageFilePath, 'utf8');
|
|
11591
|
+
return fileContent;
|
|
11592
|
+
} catch (error) {
|
|
11593
|
+
if (error.code === 'ENOENT') {
|
|
11594
|
+
console.warn(`Default start message file not found: ${startMessageFilePath}.`);
|
|
11595
|
+
return null;
|
|
11596
|
+
} else {
|
|
11597
|
+
console.error(`Error reading default start message file ${startMessageFilePath}: ${error.message}`);
|
|
11598
|
+
throw error;
|
|
11599
|
+
}
|
|
11600
|
+
}
|
|
11601
|
+
}
|
|
11602
|
+
|
|
11603
|
+
var defaultPromptLoader = {
|
|
11604
|
+
getSystemMessageContent: getSystemMessageContent$2,
|
|
11605
|
+
getStartMessageContent: getStartMessageContent$2
|
|
11606
|
+
};
|
|
11607
|
+
|
|
11533
11608
|
/*
|
|
11534
11609
|
* Component: AnalyzerUtils Index
|
|
11535
11610
|
* Block-UUID: b403b6a1-230b-4247-8cd6-2a3d068f4bbf
|
|
11536
11611
|
* Parent-UUID: N/A
|
|
11537
|
-
* Version: 1.
|
|
11612
|
+
* Version: 1.2.0
|
|
11538
11613
|
* Description: Aggregates and exports all utility functions from the AnalyzerUtils module.
|
|
11539
11614
|
* Language: JavaScript
|
|
11540
11615
|
* Created-at: 2025-08-28T15:56:40.319Z
|
|
11541
|
-
* Authors: Gemini 2.5 Flash (v1.0.0), Gemini 2.5 Flash (v1.1.0)
|
|
11616
|
+
* Authors: Gemini 2.5 Flash (v1.0.0), Gemini 2.5 Flash (v1.1.0), Gemini 2.5 Flash (v1.2.0)
|
|
11542
11617
|
*/
|
|
11543
11618
|
|
|
11544
11619
|
const { buildChatIdToPathMap: buildChatIdToPathMap$1 } = contextMapper;
|
|
@@ -11549,6 +11624,7 @@ const { saveConfiguration } = saver;
|
|
|
11549
11624
|
const { getAnalyzerSchema: getAnalyzerSchema$1 } = schemaLoader;
|
|
11550
11625
|
const { deleteAnalyzer: deleteAnalyzer$1 } = management;
|
|
11551
11626
|
const { getAnalyzerInstructionsContent: getAnalyzerInstructionsContent$1 } = instructionLoader;
|
|
11627
|
+
const { getSystemMessageContent: getSystemMessageContent$1, getStartMessageContent: getStartMessageContent$1 } = defaultPromptLoader; // NEW: Import default prompt loaders
|
|
11552
11628
|
|
|
11553
11629
|
var AnalyzerUtils$1 = {
|
|
11554
11630
|
buildChatIdToPathMap: buildChatIdToPathMap$1,
|
|
@@ -11559,6 +11635,8 @@ var AnalyzerUtils$1 = {
|
|
|
11559
11635
|
deleteAnalyzer: deleteAnalyzer$1,
|
|
11560
11636
|
getAnalyzerInstructionsContent: getAnalyzerInstructionsContent$1,
|
|
11561
11637
|
saveConfiguration,
|
|
11638
|
+
getSystemMessageContent: getSystemMessageContent$1,
|
|
11639
|
+
getStartMessageContent: getStartMessageContent$1
|
|
11562
11640
|
};
|
|
11563
11641
|
|
|
11564
11642
|
/**
|
|
@@ -11829,6 +11907,8 @@ const {
|
|
|
11829
11907
|
getAnalyzerSchema,
|
|
11830
11908
|
deleteAnalyzer,
|
|
11831
11909
|
getAnalyzerInstructionsContent,
|
|
11910
|
+
getSystemMessageContent,
|
|
11911
|
+
getStartMessageContent,
|
|
11832
11912
|
saveAnalyzerConfiguration,
|
|
11833
11913
|
} = AnalyzerUtils;
|
|
11834
11914
|
|
|
@@ -12164,6 +12244,8 @@ var GitSenseChatUtils_1 = {
|
|
|
12164
12244
|
getAnalyzerSchema,
|
|
12165
12245
|
deleteAnalyzer,
|
|
12166
12246
|
getAnalyzerInstructionsContent,
|
|
12247
|
+
getSystemMessageContent,
|
|
12248
|
+
getStartMessageContent,
|
|
12167
12249
|
|
|
12168
12250
|
// ChatUtils
|
|
12169
12251
|
getChatMessages,
|
package/package.json
CHANGED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Component: AnalyzerUtils Default Prompt Loader
|
|
3
|
+
* Block-UUID: 0b1c2d3e-4f5a-6b7c-8d9e-0f1a2b3c4d5f
|
|
4
|
+
* Parent-UUID: N/A
|
|
5
|
+
* Version: 1.0.0
|
|
6
|
+
* Description: Provides utility functions for loading shared, default prompt components (system and start messages).
|
|
7
|
+
* Language: JavaScript
|
|
8
|
+
* Created-at: 2025-08-29T03:30:28.771Z
|
|
9
|
+
* Authors: Gemini 2.5 Flash (v1.0.0)
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const fs = require('fs').promises;
|
|
14
|
+
const path = require('path');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves the raw Markdown content of the shared system message ('_shared/system/1.md').
|
|
18
|
+
*
|
|
19
|
+
* @param {string} analyzeMessagesBasePath - The absolute path to the base directory containing analyzer message files (e.g., 'messages/analyze').
|
|
20
|
+
* @returns {Promise<string|null>} A promise that resolves with the full Markdown content, or null if not found/invalid.
|
|
21
|
+
*/
|
|
22
|
+
async function getSystemMessageContent(analyzeMessagesBasePath) {
|
|
23
|
+
if (typeof analyzeMessagesBasePath !== 'string' || analyzeMessagesBasePath.trim() === '') {
|
|
24
|
+
console.error('Error: analyzeMessagesBasePath is required for getSystemMessageContent.');
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const systemMessageFilePath = path.join(analyzeMessagesBasePath, '_shared', 'system', '1.md');
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const fileContent = await fs.readFile(systemMessageFilePath, 'utf8');
|
|
32
|
+
return fileContent;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (error.code === 'ENOENT') {
|
|
35
|
+
console.warn(`Default system message file not found: ${systemMessageFilePath}.`);
|
|
36
|
+
return null;
|
|
37
|
+
} else {
|
|
38
|
+
console.error(`Error reading default system message file ${systemMessageFilePath}: ${error.message}`);
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves the raw Markdown content of the shared start message ('_shared/start/1.md').
|
|
46
|
+
*
|
|
47
|
+
* @param {string} analyzeMessagesBasePath - The absolute path to the base directory containing analyzer message files (e.g., 'messages/analyze').
|
|
48
|
+
* @returns {Promise<string|null>} A promise that resolves with the full Markdown content, or null if not found/invalid.
|
|
49
|
+
*/
|
|
50
|
+
async function getStartMessageContent(analyzeMessagesBasePath) {
|
|
51
|
+
if (typeof analyzeMessagesBasePath !== 'string' || analyzeMessagesBasePath.trim() === '') {
|
|
52
|
+
console.error('Error: analyzeMessagesBasePath is required for getStartMessageContent.');
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const startMessageFilePath = path.join(analyzeMessagesBasePath, '_shared', 'start', '1.md');
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const fileContent = await fs.readFile(startMessageFilePath, 'utf8');
|
|
60
|
+
return fileContent;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
if (error.code === 'ENOENT') {
|
|
63
|
+
console.warn(`Default start message file not found: ${startMessageFilePath}.`);
|
|
64
|
+
return null;
|
|
65
|
+
} else {
|
|
66
|
+
console.error(`Error reading default start message file ${startMessageFilePath}: ${error.message}`);
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
module.exports = {
|
|
73
|
+
getSystemMessageContent,
|
|
74
|
+
getStartMessageContent
|
|
75
|
+
};
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Component: AnalyzerUtils Index
|
|
3
3
|
* Block-UUID: b403b6a1-230b-4247-8cd6-2a3d068f4bbf
|
|
4
4
|
* Parent-UUID: N/A
|
|
5
|
-
* Version: 1.
|
|
5
|
+
* Version: 1.2.0
|
|
6
6
|
* Description: Aggregates and exports all utility functions from the AnalyzerUtils module.
|
|
7
7
|
* Language: JavaScript
|
|
8
8
|
* Created-at: 2025-08-28T15:56:40.319Z
|
|
9
|
-
* Authors: Gemini 2.5 Flash (v1.0.0), Gemini 2.5 Flash (v1.1.0)
|
|
9
|
+
* Authors: Gemini 2.5 Flash (v1.0.0), Gemini 2.5 Flash (v1.1.0), Gemini 2.5 Flash (v1.2.0)
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
|
|
@@ -18,6 +18,7 @@ const { saveConfiguration } = require('./saver');
|
|
|
18
18
|
const { getAnalyzerSchema } = require('./schemaLoader');
|
|
19
19
|
const { deleteAnalyzer } = require('./management');
|
|
20
20
|
const { getAnalyzerInstructionsContent } = require('./instructionLoader');
|
|
21
|
+
const { getSystemMessageContent, getStartMessageContent } = require('./defaultPromptLoader'); // NEW: Import default prompt loaders
|
|
21
22
|
|
|
22
23
|
module.exports = {
|
|
23
24
|
buildChatIdToPathMap,
|
|
@@ -28,4 +29,6 @@ module.exports = {
|
|
|
28
29
|
deleteAnalyzer,
|
|
29
30
|
getAnalyzerInstructionsContent,
|
|
30
31
|
saveConfiguration,
|
|
32
|
+
getSystemMessageContent,
|
|
33
|
+
getStartMessageContent
|
|
31
34
|
};
|
package/src/GitSenseChatUtils.js
CHANGED
|
@@ -63,6 +63,8 @@ const {
|
|
|
63
63
|
getAnalyzerSchema,
|
|
64
64
|
deleteAnalyzer,
|
|
65
65
|
getAnalyzerInstructionsContent,
|
|
66
|
+
getSystemMessageContent,
|
|
67
|
+
getStartMessageContent,
|
|
66
68
|
saveAnalyzerConfiguration,
|
|
67
69
|
} = AnalyzerUtils;
|
|
68
70
|
|
|
@@ -398,6 +400,8 @@ module.exports = {
|
|
|
398
400
|
getAnalyzerSchema,
|
|
399
401
|
deleteAnalyzer,
|
|
400
402
|
getAnalyzerInstructionsContent,
|
|
403
|
+
getSystemMessageContent,
|
|
404
|
+
getStartMessageContent,
|
|
401
405
|
|
|
402
406
|
// ChatUtils
|
|
403
407
|
getChatMessages,
|