Skip to content

Commit 1173bd7

Browse files
committed
feat: Add better eror handling whne repos does not have the correct structure
1 parent c2a360a commit 1173bd7

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/constant.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const REPO_ROOT_PROMPT_PATH = 'prompts/';
2+
export const REPO_SYNC_CHAT_MODE_PATH = `${REPO_ROOT_PROMPT_PATH}chatmode/`;
3+
export const REPO_SYNC_INSTRUCTIONS_PATH = `${REPO_ROOT_PROMPT_PATH}instructions/`;
4+
export const REPO_SYNC_PROMPT_PATH = `${REPO_ROOT_PROMPT_PATH}prompt/`;

src/syncManager.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Logger } from './utils/logger';
55
import { NotificationManager } from './utils/notifications';
66
import { GitHubApiManager, GitHubTreeItem } from './utils/github';
77
import { FileSystemManager } from './utils/fileSystem';
8-
8+
import { REPO_SYNC_CHAT_MODE_PATH, REPO_SYNC_INSTRUCTIONS_PATH, REPO_SYNC_PROMPT_PATH, } from './constant';
99
export interface SyncResult {
1010
success: boolean;
1111
itemsUpdated: number;
@@ -140,13 +140,13 @@ export class SyncManager {
140140

141141
// Build list of allowed paths based on settings
142142
if (this.config.syncChatmode) {
143-
allowedPaths.push('prompts/chatmode/');
143+
allowedPaths.push(REPO_SYNC_CHAT_MODE_PATH);
144144
}
145145
if (this.config.syncInstructions) {
146-
allowedPaths.push('prompts/instructions/');
146+
allowedPaths.push(REPO_SYNC_INSTRUCTIONS_PATH);
147147
}
148148
if (this.config.syncPrompt) {
149-
allowedPaths.push('prompts/prompt/');
149+
allowedPaths.push(REPO_SYNC_PROMPT_PATH);
150150
}
151151

152152
// If no types are selected, return empty array
@@ -221,6 +221,19 @@ export class SyncManager {
221221

222222
// Filter relevant files
223223
const relevantFiles = this.filterRelevantFiles(tree.tree);
224+
225+
if(relevantFiles.length === 0) {
226+
this.logger.warn(`No relevant files found to sync in ${repoUrl} based on current settings`);
227+
const promptLocation = `${REPO_SYNC_CHAT_MODE_PATH}, ${REPO_SYNC_INSTRUCTIONS_PATH}, ${REPO_SYNC_PROMPT_PATH}`;
228+
results.push({
229+
repository: repoUrl,
230+
success: false,
231+
itemsUpdated: 0,
232+
error: `No relevant files found, make sure prompts are in valid directories: ${promptLocation}`
233+
});
234+
errors.push(`${repoUrl}: No relevant files found`);
235+
continue;
236+
}
224237
this.logger.debug(`Found ${relevantFiles.length} relevant files to sync for ${repoUrl}`);
225238

226239
// Sync files

0 commit comments

Comments
 (0)