@gitsense/gscb-git-tools 0.2.0 → 0.3.0
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/cjs/common/logger.js +97 -0
- package/dist/cjs/common/logger.js.map +1 -0
- package/dist/cjs/common/metadata-manager.js +196 -0
- package/dist/cjs/common/metadata-manager.js.map +1 -0
- package/dist/cjs/importer/chat-manager/chat-creator.js +90 -0
- package/dist/cjs/importer/chat-manager/chat-creator.js.map +1 -0
- package/dist/cjs/importer/chat-manager/chat-manager.js +179 -0
- package/dist/cjs/importer/chat-manager/chat-manager.js.map +1 -0
- package/dist/cjs/importer/chat-manager/constants.js +66 -0
- package/dist/cjs/importer/chat-manager/constants.js.map +1 -0
- package/dist/cjs/importer/chat-manager/group-manager.js +56 -0
- package/dist/cjs/importer/chat-manager/group-manager.js.map +1 -0
- package/dist/cjs/importer/chat-manager/hierarchy-manager.js +115 -0
- package/dist/cjs/importer/chat-manager/hierarchy-manager.js.map +1 -0
- package/dist/cjs/importer/chat-manager/message-manager.js +126 -0
- package/dist/cjs/importer/chat-manager/message-manager.js.map +1 -0
- package/dist/cjs/importer/constants.js +30 -0
- package/dist/cjs/importer/constants.js.map +1 -0
- package/dist/cjs/importer/core/directory-processor.js +343 -0
- package/dist/cjs/importer/core/directory-processor.js.map +1 -0
- package/dist/cjs/importer/core/error-handler.js +64 -0
- package/dist/cjs/importer/core/error-handler.js.map +1 -0
- package/dist/cjs/importer/core/import-processor.js +167 -0
- package/dist/cjs/importer/core/import-processor.js.map +1 -0
- package/dist/cjs/importer/core/importer.js +135 -0
- package/dist/cjs/importer/core/importer.js.map +1 -0
- package/dist/cjs/importer/core/utils.js +66 -0
- package/dist/cjs/importer/core/utils.js.map +1 -0
- package/dist/cjs/importer/file-processor.js +199 -0
- package/dist/cjs/importer/file-processor.js.map +1 -0
- package/dist/cjs/importer/language-utils.js +286 -0
- package/dist/cjs/importer/language-utils.js.map +1 -0
- package/dist/cjs/importer/tree-processor.js +119 -0
- package/dist/cjs/importer/tree-processor.js.map +1 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/esm/common/logger.js +95 -0
- package/dist/esm/common/logger.js.map +1 -0
- package/dist/esm/common/metadata-manager.js +194 -0
- package/dist/esm/common/metadata-manager.js.map +1 -0
- package/dist/esm/importer/chat-manager/chat-creator.js +88 -0
- package/dist/esm/importer/chat-manager/chat-creator.js.map +1 -0
- package/dist/esm/importer/chat-manager/chat-manager.js +177 -0
- package/dist/esm/importer/chat-manager/chat-manager.js.map +1 -0
- package/dist/esm/importer/chat-manager/constants.js +48 -0
- package/dist/esm/importer/chat-manager/constants.js.map +1 -0
- package/dist/esm/importer/chat-manager/group-manager.js +54 -0
- package/dist/esm/importer/chat-manager/group-manager.js.map +1 -0
- package/dist/esm/importer/chat-manager/hierarchy-manager.js +113 -0
- package/dist/esm/importer/chat-manager/hierarchy-manager.js.map +1 -0
- package/dist/esm/importer/chat-manager/message-manager.js +124 -0
- package/dist/esm/importer/chat-manager/message-manager.js.map +1 -0
- package/dist/esm/importer/constants.js +28 -0
- package/dist/esm/importer/constants.js.map +1 -0
- package/dist/esm/importer/core/directory-processor.js +337 -0
- package/dist/esm/importer/core/directory-processor.js.map +1 -0
- package/dist/esm/importer/core/error-handler.js +62 -0
- package/dist/esm/importer/core/error-handler.js.map +1 -0
- package/dist/esm/importer/core/import-processor.js +165 -0
- package/dist/esm/importer/core/import-processor.js.map +1 -0
- package/dist/esm/importer/core/importer.js +133 -0
- package/dist/esm/importer/core/importer.js.map +1 -0
- package/dist/esm/importer/core/utils.js +64 -0
- package/dist/esm/importer/core/utils.js.map +1 -0
- package/dist/esm/importer/file-processor.js +193 -0
- package/dist/esm/importer/file-processor.js.map +1 -0
- package/dist/esm/importer/language-utils.js +279 -0
- package/dist/esm/importer/language-utils.js.map +1 -0
- package/dist/esm/importer/tree-processor.js +113 -0
- package/dist/esm/importer/tree-processor.js.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.d.ts +215 -0
- package/package.json +1 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { GROUP_TYPE_GIT_REPOS, GROUP_TYPE_GIT_REPO_OWNER, GROUP_TYPE_GIT_REPO, CHAT_TYPE_GIT_REPOS, CHAT_NAME_GIT_REPOS, CHAT_TYPE_GIT_REPO_OWNER, CHAT_NAME_GIT_REPO_OWNER, CHAT_TYPE_GIT_REPO, CHAT_TYPE_GIT_REF, CHAT_NAME_GIT_REF } from './constants.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Component: Hierarchy Manager
|
|
5
|
+
* Block-UUID: 4d5e6f7a-8b9c-0d1e-2f3a-4b5c6d7e8f9a
|
|
6
|
+
* Parent-UUID: N/A
|
|
7
|
+
* Version: 1.0.0
|
|
8
|
+
* Purpose: Handles chat hierarchy setup and management
|
|
9
|
+
* Language: TypeScript
|
|
10
|
+
* Created-at: 2025-03-15T02:12:20.075Z
|
|
11
|
+
* Authors: together.ai - DeepSeek v3 (v1.0.0)
|
|
12
|
+
*/
|
|
13
|
+
class HierarchyManager {
|
|
14
|
+
dbClient;
|
|
15
|
+
gitRepo;
|
|
16
|
+
chatCreator;
|
|
17
|
+
groupManager;
|
|
18
|
+
logger;
|
|
19
|
+
constructor(dbClient, gitRepo, chatCreator, groupManager, logger) {
|
|
20
|
+
this.dbClient = dbClient;
|
|
21
|
+
this.gitRepo = gitRepo;
|
|
22
|
+
this.chatCreator = chatCreator;
|
|
23
|
+
this.groupManager = groupManager;
|
|
24
|
+
this.logger = logger;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Sets up the chat hierarchy for the repository.
|
|
28
|
+
* Creates or updates groups and chats for `git-repos`, `git-repo-owner`, `git-repo`, and `git-ref`.
|
|
29
|
+
* Returns the ID of the `git-ref` chat.
|
|
30
|
+
*/
|
|
31
|
+
async setupChatHierarchy(repoOwner, repoName, ref, refType) {
|
|
32
|
+
try {
|
|
33
|
+
// Step 1: Create or update groups
|
|
34
|
+
const reposGroupId = await this.groupManager.createOrUpdateGroup(GROUP_TYPE_GIT_REPOS, GROUP_TYPE_GIT_REPOS);
|
|
35
|
+
const repoOwnerGroupId = await this.groupManager.createOrUpdateGroup(GROUP_TYPE_GIT_REPO_OWNER, repoOwner);
|
|
36
|
+
const repoGroupId = await this.groupManager.createOrUpdateGroup(GROUP_TYPE_GIT_REPO, `${repoOwner}/${repoName}`);
|
|
37
|
+
// Step 2: Create or update chats
|
|
38
|
+
const reposChatId = await this.createOrUpdateReposChat(reposGroupId);
|
|
39
|
+
const repoOwnerChatId = await this.createOrUpdateRepoOwnerChat(reposChatId, repoOwnerGroupId, repoOwner);
|
|
40
|
+
const repoChatId = await this.createOrUpdateRepoChat(repoOwnerChatId, repoGroupId, repoOwner, repoName);
|
|
41
|
+
const refChatId = await this.createOrUpdateRefChat(repoChatId, repoGroupId, ref, refType);
|
|
42
|
+
return { refChatId, repoGroupId };
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
throw new Error(`Failed to setup chat hierarchy: ${error instanceof Error ? error.message : String(error)}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates or updates the `git-repos` chat.
|
|
50
|
+
*/
|
|
51
|
+
async createOrUpdateReposChat(groupId) {
|
|
52
|
+
const existingChat = await this.dbClient.getChatByTypeAndName(CHAT_TYPE_GIT_REPOS, CHAT_NAME_GIT_REPOS, groupId);
|
|
53
|
+
if (existingChat) {
|
|
54
|
+
return existingChat.id;
|
|
55
|
+
}
|
|
56
|
+
const meta = {
|
|
57
|
+
type: CHAT_TYPE_GIT_REPOS
|
|
58
|
+
};
|
|
59
|
+
return await this.chatCreator.createChat(CHAT_TYPE_GIT_REPOS, CHAT_NAME_GIT_REPOS, 0, groupId, meta);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Creates or updates the `git-repo-owner` chat.
|
|
63
|
+
*/
|
|
64
|
+
async createOrUpdateRepoOwnerChat(parentId, groupId, repoOwner) {
|
|
65
|
+
const chatName = CHAT_NAME_GIT_REPO_OWNER(repoOwner);
|
|
66
|
+
const existingChat = await this.dbClient.getChatByTypeAndName(CHAT_TYPE_GIT_REPO_OWNER, chatName, groupId);
|
|
67
|
+
const meta = {
|
|
68
|
+
type: CHAT_TYPE_GIT_REPO_OWNER,
|
|
69
|
+
owner: repoOwner
|
|
70
|
+
};
|
|
71
|
+
if (existingChat) {
|
|
72
|
+
return existingChat.id;
|
|
73
|
+
}
|
|
74
|
+
return await this.chatCreator.createChat(CHAT_TYPE_GIT_REPO_OWNER, chatName, parentId, groupId, meta, '', -1);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Creates or updates the `git-repo` chat.
|
|
78
|
+
*/
|
|
79
|
+
async createOrUpdateRepoChat(parentId, groupId, repoOwner, repoName) {
|
|
80
|
+
const chatName = repoName;
|
|
81
|
+
const existingChat = await this.dbClient.getChatByTypeAndName(CHAT_TYPE_GIT_REPO, chatName, groupId);
|
|
82
|
+
const repo = await this.gitRepo.getInfo();
|
|
83
|
+
const meta = {
|
|
84
|
+
type: CHAT_TYPE_GIT_REPO,
|
|
85
|
+
owner: repoOwner,
|
|
86
|
+
name: repoName,
|
|
87
|
+
path: repo.path
|
|
88
|
+
};
|
|
89
|
+
if (existingChat) {
|
|
90
|
+
return existingChat.id;
|
|
91
|
+
}
|
|
92
|
+
return await this.chatCreator.createChat(CHAT_TYPE_GIT_REPO, chatName, parentId, groupId, meta);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Creates or updates the `git-branch`, `git-commit`, or `git-tag` chat.
|
|
96
|
+
*/
|
|
97
|
+
async createOrUpdateRefChat(parentId, groupId, name, type) {
|
|
98
|
+
const chatType = type.match(/(commit|branch|tag)/) ? CHAT_TYPE_GIT_REF : null;
|
|
99
|
+
if (!chatType) {
|
|
100
|
+
throw new Error(`No chat type associated with ref type ${type}`);
|
|
101
|
+
}
|
|
102
|
+
const chatName = CHAT_NAME_GIT_REF(name);
|
|
103
|
+
const existingChat = await this.dbClient.getChatByTypeAndName(chatType, chatName, groupId);
|
|
104
|
+
if (existingChat) {
|
|
105
|
+
return existingChat.id;
|
|
106
|
+
}
|
|
107
|
+
const meta = { type, name, status: '' };
|
|
108
|
+
return await this.chatCreator.createChat(chatType, chatName, parentId, groupId, meta);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { HierarchyManager };
|
|
113
|
+
//# sourceMappingURL=hierarchy-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hierarchy-manager.js","sources":["../../../../src/importer/chat-manager/hierarchy-manager.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;AASG;MAsBU,gBAAgB,CAAA;AAEJ,IAAA,QAAA;AACA,IAAA,OAAA;AACA,IAAA,WAAA;AACA,IAAA,YAAA;AACA,IAAA,MAAA;IALrB,WACqB,CAAA,QAAwB,EACxB,OAAmB,EACnB,WAAwB,EACxB,YAA0B,EAC1B,MAAc,EAAA;QAJd,IAAQ,CAAA,QAAA,GAAR,QAAQ;QACR,IAAO,CAAA,OAAA,GAAP,OAAO;QACP,IAAW,CAAA,WAAA,GAAX,WAAW;QACX,IAAY,CAAA,YAAA,GAAZ,YAAY;QACZ,IAAM,CAAA,MAAA,GAAN,MAAM;;AAG3B;;;;AAIG;IACH,MAAM,kBAAkB,CAAC,SAAiB,EAAE,QAAgB,EAAE,GAAW,EAAE,OAAgB,EAAA;AACvF,QAAA,IAAI;;AAEA,YAAA,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;AAC5G,YAAA,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,yBAAy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;AACtF,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,GAAG,iBAAiB,GAAG,IAAI;QAE7E,IAAI,CAAC,QAAQ,EAAE;AACX,YAAA,MAAM,IAAI,KAAK,CAAC,yCAAyC,IAAI,CAAA,CAAE,CAAC;;QAGpE,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAU,CAAC;AAC9C,QAAA,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC;QAE1F,IAAI,YAAY,EAAE;YACd,OAAO,YAAY,CAAC,EAAG;;QAG3B,MAAM,IAAI,GAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;AACpD,QAAA,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;;AAE5F;;;;"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { CHAT_VISIBILITY_PUBLIC, MESSAGE_TYPE_REGULAR, DEFAULT_TEMPERATURE, DEFAULT_MODEL, MESSAGE_TYPE_CHAT_META } from './constants.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Component: Message Manager
|
|
5
|
+
* Block-UUID: 9b8c7d6e-5f4a-3b2c-1d0e-9f8e7d6c5b4a
|
|
6
|
+
* Parent-UUID: N/A
|
|
7
|
+
* Version: 1.1.0
|
|
8
|
+
* Purpose: Handles message creation, retrieval, and updates, including markdown table generation
|
|
9
|
+
* Language: TypeScript
|
|
10
|
+
* Created-at: 2025-03-15T02:07:30.618Z
|
|
11
|
+
* Updated-at: 2025-03-16T02:16:32.958Z
|
|
12
|
+
* Authors: together.ai - DeepSeek v3 (v1.0.0), OpenRouter - DeepSeek v3 (v1.1.0)
|
|
13
|
+
*/
|
|
14
|
+
class MessageManager {
|
|
15
|
+
dbClient;
|
|
16
|
+
logger;
|
|
17
|
+
constructor(dbClient, logger) {
|
|
18
|
+
this.dbClient = dbClient;
|
|
19
|
+
this.logger = logger;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a system message for a chat.
|
|
23
|
+
*/
|
|
24
|
+
async createSystemMessage(chatId) {
|
|
25
|
+
try {
|
|
26
|
+
return await this.dbClient.createMessage({
|
|
27
|
+
type: MESSAGE_TYPE_REGULAR,
|
|
28
|
+
visibility: CHAT_VISIBILITY_PUBLIC,
|
|
29
|
+
chatId,
|
|
30
|
+
parentId: 0,
|
|
31
|
+
level: 0,
|
|
32
|
+
role: 'system',
|
|
33
|
+
message: '',
|
|
34
|
+
priority: 0
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
throw new Error(`Failed to create system message for chat ${chatId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates the main message for a chat.
|
|
43
|
+
*/
|
|
44
|
+
async createMainMessage(chatId, parentId, chatType, message) {
|
|
45
|
+
if (!message) {
|
|
46
|
+
message = '';
|
|
47
|
+
}
|
|
48
|
+
return await this.dbClient.createMessage({
|
|
49
|
+
type: chatType,
|
|
50
|
+
visibility: CHAT_VISIBILITY_PUBLIC,
|
|
51
|
+
chatId,
|
|
52
|
+
parentId,
|
|
53
|
+
level: 2,
|
|
54
|
+
role: 'assistant',
|
|
55
|
+
message,
|
|
56
|
+
priority: 0,
|
|
57
|
+
sample: 1,
|
|
58
|
+
model: DEFAULT_MODEL,
|
|
59
|
+
temperature: DEFAULT_TEMPERATURE
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Creates the main message for a chat.
|
|
64
|
+
*/
|
|
65
|
+
async createChatMetaMessage(chatId, parentId) {
|
|
66
|
+
return await this.dbClient.createMessage({
|
|
67
|
+
type: MESSAGE_TYPE_CHAT_META,
|
|
68
|
+
visibility: CHAT_VISIBILITY_PUBLIC,
|
|
69
|
+
chatId,
|
|
70
|
+
parentId,
|
|
71
|
+
level: 2,
|
|
72
|
+
role: 'assistant',
|
|
73
|
+
message: '',
|
|
74
|
+
priority: 0,
|
|
75
|
+
sample: 1,
|
|
76
|
+
model: DEFAULT_MODEL,
|
|
77
|
+
temperature: DEFAULT_TEMPERATURE,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Retrieves a message by its ID.
|
|
82
|
+
*/
|
|
83
|
+
async getMessageById(messageId) {
|
|
84
|
+
try {
|
|
85
|
+
const message = await this.dbClient.getMessageById(messageId);
|
|
86
|
+
if (!message) {
|
|
87
|
+
throw new Error(`Message with ID ${messageId} not found`);
|
|
88
|
+
}
|
|
89
|
+
return message;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
throw new Error(`Failed to retrieve message ${messageId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Retrieves a message by chat ID and type.
|
|
97
|
+
*/
|
|
98
|
+
async getMessageByChatIdAndType(chatId, type) {
|
|
99
|
+
try {
|
|
100
|
+
const messages = await this.dbClient.getMessagesByChatIdAndType(chatId, type);
|
|
101
|
+
if (messages.length === 0) {
|
|
102
|
+
throw new Error(`No message of type '${type}' found for chat ${chatId}`);
|
|
103
|
+
}
|
|
104
|
+
return messages[0];
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
throw new Error(`Failed to retrieve message for chat ${chatId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Updates a message with new content.
|
|
112
|
+
*/
|
|
113
|
+
async updateMessage(messageId, updates) {
|
|
114
|
+
try {
|
|
115
|
+
await this.dbClient.updateMessage(messageId, updates);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
throw new Error(`Failed to update message ${messageId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export { MessageManager };
|
|
124
|
+
//# sourceMappingURL=message-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-manager.js","sources":["../../../../src/importer/chat-manager/message-manager.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;AAUG;MAQU,cAAc,CAAA;AAEF,IAAA,QAAA;AACA,IAAA,MAAA;IAFrB,WACqB,CAAA,QAAwB,EACxB,MAAc,EAAA;QADd,IAAQ,CAAA,QAAA,GAAR,QAAQ;QACR,IAAM,CAAA,MAAA,GAAN,MAAM;;AAG3B;;AAEG;IACH,MAAM,mBAAmB,CAAC,MAAc,EAAA;AACpC,QAAA,IAAI;AACA,YAAA,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC;AACrC,gBAAA,IAAI,EAAE,oBAAoB;AAC1B,gBAAA,UAAU,EAAE,sBAAsB;gBAClC,MAAM;AACN,gBAAA,QAAQ,EAAE,CAAC;AACX,gBAAA,KAAK,EAAE,CAAC;AACR,gBAAA,IAAI,EAAE,QAAQ;AACd,gBAAA,OAAO,EAAE,EAAE;AACX,gBAAA,QAAQ,EAAE;AACb,aAAA,CAAC;;QACJ,OAAO,KAAK,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,CAA4C,yCAAA,EAAA,MAAM,KAAK,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAE,CAAA,CAAC;;;AAIxI;;AAEG;IACH,MAAM,iBAAiB,CACnB,MAAc,EACd,QAAgB,EAChB,QAAqB,EACrB,OAAgB,EAAA;QAEhB,IAAI,CAAC,OAAO,EAAE;YACV,OAAO,GAAG,EAAE;;AAGhB,QAAA,OAAO,MAAM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;AAI7H;;AAEG;AACH,IAAA,MAAM,yBAAyB,CAAC,MAAc,EAAE,IAAY,EAAA;AACxD,QAAA,IAAI;AACA,YAAA,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,0BAA0B,CAAC,MAAM,EAAE,IAAI,CAAC;AAC7E,YAAA,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;gBACvB,MAAM,IAAI,KAAK,CAAC,CAAA,oBAAA,EAAuB,IAAI,CAAoB,iBAAA,EAAA,MAAM,CAAE,CAAA,CAAC;;AAE5E,YAAA,OAAO,QAAQ,CAAC,CAAC,CAAC;;QACpB,OAAO,KAAK,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,CAAuC,oCAAA,EAAA,MAAM,KAAK,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAE,CAAA,CAAC;;;AAInI;;AAEG;AACH,IAAA,MAAM,aAAa,CAAC,SAAiB,EAAE,OAAyB,EAAA;AAC5D,QAAA,IAAI;YACA,MAAM,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC;;QACvD,OAAO,KAAK,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,CAA4B,yBAAA,EAAA,SAAS,KAAK,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAE,CAAA,CAAC;;;AAG9H;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component: Constants
|
|
3
|
+
* Block-UUID: 4c2d1e0f-1a3b-4c5d-6e7f-8a9b0c1d2e3f
|
|
4
|
+
* Parent-UUID: N/A
|
|
5
|
+
* Version: 2.0.0
|
|
6
|
+
* Description: Update this to provide a proper file description
|
|
7
|
+
* Language: TypeScript
|
|
8
|
+
* Created-at: 2025-02-22T07:25:50.819Z
|
|
9
|
+
* Authors: OpenRouter - DeepSeek v3 (v1.0.0), Claude 3.5 Sonnet (v2.0.0)
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_OPTIONS = {
|
|
12
|
+
maxFileSize: 256 * 1024, // 256KB
|
|
13
|
+
skipPatterns: [
|
|
14
|
+
/\.min\.(js|css)$/,
|
|
15
|
+
/\.log$/,
|
|
16
|
+
/\.map$/,
|
|
17
|
+
/\.bundle\./,
|
|
18
|
+
/dist\//,
|
|
19
|
+
/build\//,
|
|
20
|
+
/vendor\//,
|
|
21
|
+
/node_modules\//
|
|
22
|
+
],
|
|
23
|
+
verbose: false,
|
|
24
|
+
skipBinaryFiles: true
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { DEFAULT_OPTIONS };
|
|
28
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../src/importer/constants.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;AASG;AAIU,MAAA,eAAe,GAAG;AAC3B,IAAA,WAAW,EAAE,GAAG,GAAG,IAAI;AACvB,IAAA,YAAY,EAAE;QACV,kBAAkB;QAClB,QAAQ;QACR,QAAQ;QACR,YAAY;QACZ,QAAQ;QACR,SAAS;QACT,UAAU;QACV;AACH,KAAA;AACD,IAAA,OAAO,EAAE,KAAK;AACd,IAAA,eAAe,EAAE;;;;;"}
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { Utils } from './utils.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Component: Directory Processor
|
|
6
|
+
* Block-UUID: 237b8cc5-5d1b-4285-82c4-0e1f49459f2c
|
|
7
|
+
* Parent-UUID: 31839e44-58af-43ea-baab-96674d745ad0
|
|
8
|
+
* Version: 8.0.0
|
|
9
|
+
* Purpose: Add hash comparison and token estimation for directories
|
|
10
|
+
* Language: TypeScript
|
|
11
|
+
* Created-at: 2025-03-15T05:58:33.811Z
|
|
12
|
+
* Updated-at: 2025-03-24T00:50:00.000Z
|
|
13
|
+
* Authors: Claude 3.5 Sonnet (v5.0.1), Bard, Claude 3.5 Sonnet (v6.0.0), Claude 3.7 Sonnet (v6.3.0),
|
|
14
|
+
* OpenRouter - Gemini Flash 2.0 (v6.4.0), OpenRouter - Gemini Flash 2.0 (v6.5.0),
|
|
15
|
+
* together.ai - DeepSeek v3 (v6.6.0), Claude 3.7 Sonnet (v6.7.0), together.ai - DeepSeek v3 (v6.8.0),
|
|
16
|
+
* together.ai - DeepSeek v3 (v7.0.0), together.ai - DeepSeek v3 (v8.0.0)
|
|
17
|
+
*/
|
|
18
|
+
class DirectoryProcessor {
|
|
19
|
+
dbClient;
|
|
20
|
+
gitRepo;
|
|
21
|
+
fileProcessor;
|
|
22
|
+
treeProcessor;
|
|
23
|
+
metadataManager;
|
|
24
|
+
chatManager;
|
|
25
|
+
logger;
|
|
26
|
+
constructor(dbClient, gitRepo, fileProcessor, treeProcessor, metadataManager, chatManager, logger) {
|
|
27
|
+
this.dbClient = dbClient;
|
|
28
|
+
this.gitRepo = gitRepo;
|
|
29
|
+
this.fileProcessor = fileProcessor;
|
|
30
|
+
this.treeProcessor = treeProcessor;
|
|
31
|
+
this.metadataManager = metadataManager;
|
|
32
|
+
this.chatManager = chatManager;
|
|
33
|
+
this.logger = logger;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Estimates tokens using 1.33 tokens per word.
|
|
37
|
+
*/
|
|
38
|
+
estimateTokens(text) {
|
|
39
|
+
const wordCount = text.split(/\s+/).filter(Boolean).length;
|
|
40
|
+
return Math.ceil(wordCount * 1.33);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Processes all files and directories in the repository, ensuring a proper parent-child relationship.
|
|
44
|
+
*/
|
|
45
|
+
async processFiles(rootChatId) {
|
|
46
|
+
try {
|
|
47
|
+
// Start processing from the root directory. Empty string is root.
|
|
48
|
+
return await this.processDirectory('', rootChatId);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new Error(`Failed to process files: ${error instanceof Error ? error.message : String(error)}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Processes entries (files and directories) that have changed between commits.
|
|
56
|
+
*/
|
|
57
|
+
async processChangedEntries(changedEntries, refChatId, repoGroupId) {
|
|
58
|
+
// Group entries by change type
|
|
59
|
+
const addedOrModifiedFiles = [];
|
|
60
|
+
const deletedFiles = [];
|
|
61
|
+
const deletedDirs = [];
|
|
62
|
+
for (const entry of changedEntries) {
|
|
63
|
+
// Normalize the path
|
|
64
|
+
const normalizedPath = this.normalizePath(entry.path);
|
|
65
|
+
// Skip files that match skip patterns if they're being added or modified
|
|
66
|
+
if (entry.entryType === 'file' && entry.changeType !== 'delete' &&
|
|
67
|
+
await this.fileProcessor.shouldSkipFile(normalizedPath)) {
|
|
68
|
+
this.logger.log(`Skipping file: ${normalizedPath}`);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
// Categorize the entry
|
|
72
|
+
if (entry.entryType === 'file') {
|
|
73
|
+
if (entry.changeType === 'delete') {
|
|
74
|
+
deletedFiles.push(normalizedPath);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
addedOrModifiedFiles.push(normalizedPath);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
if (entry.changeType === 'delete') {
|
|
82
|
+
deletedDirs.push(normalizedPath);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Process deleted files first
|
|
87
|
+
if (deletedFiles.length > 0) {
|
|
88
|
+
this.logger.log(`Processing ${deletedFiles.length} deleted files`);
|
|
89
|
+
await this.processDeletedFiles(deletedFiles, refChatId);
|
|
90
|
+
}
|
|
91
|
+
// Process deleted directories
|
|
92
|
+
if (deletedDirs.length > 0) {
|
|
93
|
+
this.logger.log(`Processing ${deletedDirs.length} deleted directories`);
|
|
94
|
+
await this.processDeletedDirectories(deletedDirs, refChatId);
|
|
95
|
+
}
|
|
96
|
+
// Group added/modified files by directory
|
|
97
|
+
const filesByDirectory = {};
|
|
98
|
+
for (const filePath of addedOrModifiedFiles) {
|
|
99
|
+
const dirPath = this.normalizePath(path.dirname(filePath));
|
|
100
|
+
if (!filesByDirectory[dirPath]) {
|
|
101
|
+
filesByDirectory[dirPath] = [];
|
|
102
|
+
}
|
|
103
|
+
filesByDirectory[dirPath].push(filePath);
|
|
104
|
+
}
|
|
105
|
+
// Process each directory's added/modified files
|
|
106
|
+
for (const [dirPath, files] of Object.entries(filesByDirectory)) {
|
|
107
|
+
this.logger.log(`Processing ${files.length} files in directory: ${dirPath}`);
|
|
108
|
+
// Find or create the directory chat
|
|
109
|
+
const dirChatId = await this.findOrCreateDirectoryChat(dirPath, refChatId, repoGroupId);
|
|
110
|
+
// Process each file in the directory
|
|
111
|
+
let orderWeight = 10;
|
|
112
|
+
for (const filePath of files) {
|
|
113
|
+
this.logger.log(`Processing file: ${filePath}`);
|
|
114
|
+
// FileProcessor will handle both new files and updates
|
|
115
|
+
await this.fileProcessor.processFile(filePath, dirChatId, orderWeight);
|
|
116
|
+
orderWeight += 10;
|
|
117
|
+
}
|
|
118
|
+
await this.metadataManager.updateDirectoryMetadata(dirChatId, dirPath, null);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Recursively processes a directory and its contents.
|
|
123
|
+
*/
|
|
124
|
+
async processDirectory(dirPath, parentChatId, treeSha = '') {
|
|
125
|
+
try {
|
|
126
|
+
// Used to define chat order
|
|
127
|
+
let orderWeight = 0;
|
|
128
|
+
// Create a chat for the current directory
|
|
129
|
+
const dirChatId = dirPath === ''
|
|
130
|
+
? parentChatId
|
|
131
|
+
: await this.treeProcessor.createDirectoryChat(dirPath, parentChatId, treeSha, orderWeight);
|
|
132
|
+
// List the contents of the directory
|
|
133
|
+
const entries = await this.gitRepo.listDirectory(dirPath);
|
|
134
|
+
// Separate directories and files, then sort alphabetically
|
|
135
|
+
const directories = entries
|
|
136
|
+
.filter(entry => entry.type === 'tree')
|
|
137
|
+
.sort((a, b) => b.path.localeCompare(a.path));
|
|
138
|
+
const files = entries
|
|
139
|
+
.filter(entry => entry.type === 'blob')
|
|
140
|
+
.sort((a, b) => a.path.localeCompare(b.path));
|
|
141
|
+
// Process directories and files
|
|
142
|
+
const childCommits = [];
|
|
143
|
+
for (const dir of directories) {
|
|
144
|
+
orderWeight += 10;
|
|
145
|
+
const childCommit = await this.processDirectory(dirPath + (dirPath === '' ? '' : '/') + dir.path, dirChatId, dir.oid);
|
|
146
|
+
if (childCommit)
|
|
147
|
+
childCommits.push(childCommit);
|
|
148
|
+
}
|
|
149
|
+
for (const file of files) {
|
|
150
|
+
const { path } = file;
|
|
151
|
+
if (await this.fileProcessor.shouldSkipFile(path))
|
|
152
|
+
continue;
|
|
153
|
+
orderWeight += 10;
|
|
154
|
+
const fileCommit = await this.fileProcessor.processFile(dirPath + (dirPath === '' ? '' : '/') + path, dirChatId, orderWeight);
|
|
155
|
+
if (fileCommit)
|
|
156
|
+
childCommits.push(fileCommit);
|
|
157
|
+
}
|
|
158
|
+
// Determine the latest commit for the directory
|
|
159
|
+
const latestCommit = Utils.getLatestCommit(childCommits);
|
|
160
|
+
// Skip update if the commit hash hasn't changed
|
|
161
|
+
const existingMeta = (await this.chatManager.getChatById(dirChatId))?.meta || {};
|
|
162
|
+
if (existingMeta.commit?.hash === latestCommit?.hash) {
|
|
163
|
+
this.logger.log(`Skipping update for directory '${dirPath}' (commit hash unchanged)`);
|
|
164
|
+
return latestCommit;
|
|
165
|
+
}
|
|
166
|
+
// Estimate tokens for directory metadata
|
|
167
|
+
const now = new Date().toISOString();
|
|
168
|
+
const metaTokens = this.estimateTokens(JSON.stringify({
|
|
169
|
+
type: 'git-tree',
|
|
170
|
+
tree: treeSha,
|
|
171
|
+
path: dirPath,
|
|
172
|
+
name: path.basename(dirPath),
|
|
173
|
+
commit: latestCommit,
|
|
174
|
+
status: 'imported'
|
|
175
|
+
}));
|
|
176
|
+
// Update the directory metadata
|
|
177
|
+
const update = {
|
|
178
|
+
status: 'imported',
|
|
179
|
+
importFinishedAt: now,
|
|
180
|
+
tokens: {
|
|
181
|
+
metadata: { estimate: metaTokens, estimatedAt: now }
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
if (dirPath !== '' && dirPath !== '.') {
|
|
185
|
+
update.commit = latestCommit;
|
|
186
|
+
}
|
|
187
|
+
await this.metadataManager.updateChatMetadata(dirChatId, { ...existingMeta, ...update });
|
|
188
|
+
return latestCommit;
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
console.trace();
|
|
192
|
+
throw new Error(`Failed to process directory '${dirPath}': ${error instanceof Error ? error.message : String(error)}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Processes deleted files.
|
|
197
|
+
*/
|
|
198
|
+
async processDeletedFiles(deletedFiles, refChatId) {
|
|
199
|
+
for (const filePath of deletedFiles) {
|
|
200
|
+
this.logger.log(`Processing deleted file: ${filePath}`);
|
|
201
|
+
// Find the directory chat for this file
|
|
202
|
+
const dirPath = this.normalizePath(path.dirname(filePath));
|
|
203
|
+
const dirChatId = await this.findDirectoryChat(dirPath, refChatId);
|
|
204
|
+
if (!dirChatId) {
|
|
205
|
+
this.logger.log(`Could not find directory chat for ${dirPath}, skipping deletion of ${filePath}`);
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
// Find the file chat
|
|
209
|
+
const fileName = path.basename(filePath);
|
|
210
|
+
const childChats = await this.dbClient.getChatsByParentId(dirChatId);
|
|
211
|
+
const fileChat = childChats.find(chat => chat.type === 'git-blob' &&
|
|
212
|
+
chat.name === fileName && chat.meta?.path === filePath);
|
|
213
|
+
if (!fileChat) {
|
|
214
|
+
this.logger.log(`Could not find chat for file ${filePath}, it may have been deleted already`);
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
// Mark the file as deleted
|
|
218
|
+
await this.metadataManager.markFileAsDeleted(fileChat.id, filePath);
|
|
219
|
+
await this.metadataManager.updateDirectoryMetadata(dirChatId, dirPath, null);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Processes deleted directories.
|
|
224
|
+
*/
|
|
225
|
+
async processDeletedDirectories(deletedDirs, refChatId) {
|
|
226
|
+
// Sort directories by depth (deepest first) to handle nested directories correctly
|
|
227
|
+
const sortedDirs = [...deletedDirs].sort((a, b) => b.split('/').length - a.split('/').length);
|
|
228
|
+
for (const dirPath of sortedDirs) {
|
|
229
|
+
this.logger.log(`Processing deleted directory: ${dirPath}`);
|
|
230
|
+
// Find the parent directory chat
|
|
231
|
+
const parentDirPath = this.normalizePath(path.dirname(dirPath));
|
|
232
|
+
const parentDirChatId = await this.findDirectoryChat(parentDirPath, refChatId);
|
|
233
|
+
if (!parentDirChatId) {
|
|
234
|
+
this.logger.log(`Could not find parent directory chat for ${parentDirPath}, skipping deletion of ${dirPath}`);
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
// Find the directory chat
|
|
238
|
+
const dirName = path.basename(dirPath);
|
|
239
|
+
const childChats = await this.dbClient.getChatsByParentId(parentDirChatId);
|
|
240
|
+
const dirChat = childChats.find(chat => chat.type === 'git-tree' &&
|
|
241
|
+
chat.name === dirName &&
|
|
242
|
+
chat.meta?.path === dirPath);
|
|
243
|
+
if (!dirChat) {
|
|
244
|
+
this.logger.log(`Could not find chat for directory ${dirPath}, it may have been deleted already`);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
// Delete the directory
|
|
248
|
+
await this.dbClient.deleteChat(dirChat.id);
|
|
249
|
+
// Mark the directory and all its contents as deleted
|
|
250
|
+
await this.metadataManager.markDirectoryAsDeleted(dirChat.id, dirPath);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Finds or creates a directory chat.
|
|
255
|
+
*/
|
|
256
|
+
async findOrCreateDirectoryChat(dirPath, refChatId, repoGroupId) {
|
|
257
|
+
// Normalize the input path
|
|
258
|
+
const normalizedDirPath = this.normalizePath(dirPath);
|
|
259
|
+
if (normalizedDirPath === '.' || normalizedDirPath === '') {
|
|
260
|
+
return refChatId;
|
|
261
|
+
}
|
|
262
|
+
// Split the path into components
|
|
263
|
+
const pathComponents = normalizedDirPath.split('/');
|
|
264
|
+
// Start from the root chat
|
|
265
|
+
let currentChatId = refChatId;
|
|
266
|
+
let currentPath = '';
|
|
267
|
+
// Traverse the path, creating directory chats as needed
|
|
268
|
+
for (const component of pathComponents) {
|
|
269
|
+
currentPath = currentPath ? `${currentPath}/${component}` : component;
|
|
270
|
+
const normalizedCurrentPath = this.normalizePath(currentPath);
|
|
271
|
+
// Try to find an existing chat for this directory
|
|
272
|
+
const childChats = await this.dbClient.getChatsByParentId(currentChatId);
|
|
273
|
+
const dirChat = childChats.find(chat => {
|
|
274
|
+
// Normalize the path from meta for comparison
|
|
275
|
+
const chatPath = this.normalizePath(chat.meta?.path || '');
|
|
276
|
+
return chat.type === 'git-tree' && chatPath === normalizedCurrentPath;
|
|
277
|
+
});
|
|
278
|
+
if (dirChat) {
|
|
279
|
+
currentChatId = dirChat.id;
|
|
280
|
+
this.logger.log(`Found existing directory chat for ${normalizedCurrentPath}: ${currentChatId}`);
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
// Create a new directory chat
|
|
284
|
+
this.logger.log(`Creating new directory chat for ${normalizedCurrentPath}`);
|
|
285
|
+
const treeSha = await this.gitRepo.getTreeSha(normalizedCurrentPath);
|
|
286
|
+
currentChatId = await this.treeProcessor.createDirectoryChat(normalizedCurrentPath, currentChatId, treeSha, 10) || 0;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return currentChatId;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Finds a directory chat by path.
|
|
293
|
+
*/
|
|
294
|
+
async findDirectoryChat(dirPath, rootChatId) {
|
|
295
|
+
// Normalize the input path
|
|
296
|
+
const normalizedDirPath = this.normalizePath(dirPath);
|
|
297
|
+
if (normalizedDirPath === '.' || normalizedDirPath === '') {
|
|
298
|
+
return rootChatId;
|
|
299
|
+
}
|
|
300
|
+
// Split the path into components
|
|
301
|
+
const pathComponents = normalizedDirPath.split('/');
|
|
302
|
+
// Start from the root chat
|
|
303
|
+
let currentChatId = rootChatId;
|
|
304
|
+
let currentPath = '';
|
|
305
|
+
// Traverse the path, looking for existing directory chats
|
|
306
|
+
for (const component of pathComponents) {
|
|
307
|
+
currentPath = currentPath ? `${currentPath}/${component}` : component;
|
|
308
|
+
const normalizedCurrentPath = this.normalizePath(currentPath);
|
|
309
|
+
// Try to find an existing chat for this directory
|
|
310
|
+
const childChats = await this.dbClient.getChatsByParentId(currentChatId);
|
|
311
|
+
const dirChat = childChats.find(chat => {
|
|
312
|
+
// Normalize the path from meta for comparison
|
|
313
|
+
const chatPath = this.normalizePath(chat.meta?.path || '');
|
|
314
|
+
return chat.type === 'git-tree' && chatPath === normalizedCurrentPath;
|
|
315
|
+
});
|
|
316
|
+
if (dirChat) {
|
|
317
|
+
currentChatId = dirChat.id;
|
|
318
|
+
this.logger.log(`Found existing directory chat for ${normalizedCurrentPath}: ${currentChatId}`);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
// If we can't find a directory at any level, return undefined
|
|
322
|
+
this.logger.log(`Could not find directory chat for ${normalizedCurrentPath}`);
|
|
323
|
+
return undefined;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return currentChatId;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Normalizes a file path.
|
|
330
|
+
*/
|
|
331
|
+
normalizePath(path) {
|
|
332
|
+
return path.replace(/\\/g, '/').replace(/\/+/g, '/').replace(/\/$/, '');
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export { DirectoryProcessor };
|
|
337
|
+
//# sourceMappingURL=directory-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-processor.js","sources":["../../../../src/importer/core/directory-processor.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;AAaG;MAaU,kBAAkB,CAAA;AAEN,IAAA,QAAA;AACA,IAAA,OAAA;AACA,IAAA,aAAA;AACA,IAAA,aAAA;AACA,IAAA,eAAA;AACA,IAAA,WAAA;AACA,IAAA,MAAA;AAPrB,IAAA,WAAA,CACqB,QAAwB,EACxB,OAAmB,EACnB,aAA4B,EAC5B,aAA4B,EAC5B,eAAgC,EAChC,WAAwB,EACxB,MAAc,EAAA;QANd,IAAQ,CAAA,QAAA,GAAR,QAAQ;QACR,IAAO,CAAA,OAAA,GAAP,OAAO;QACP,IAAa,CAAA,aAAA,GAAb,aAAa;QACb,IAAa,CAAA,aAAA,GAAb,aAAa;QACb,IAAe,CAAA,eAAA,GAAf,eAAe;QACf,IAAW,CAAA,WAAA,GAAX,WAAW;QACX,IAAM,CAAA,MAAA,GAAN,MAAM;;AAG3B;;AAEG;AACK,IAAA,cAAc,CAAC,IAAY,EAAA;AAC/B,QAAA,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM;QAC1D,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;;AAGtC;;AAEG;IACH,MAAM,YAAY,CAAC,UAAkB,EAAA;AACjC,QAAA,IAAI;;YAEA,OAAO,MAAM,IAAI,CAAC,gBAAgB,CAAC,EAAE,EAAE,UAAU,CAAC;;QACpD,OAAO,KAAK,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,CAAA,yBAAA,EAA4B,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAE,CAAA,CAAC;;;AAI7G;;AAEG;AACH,IAAA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