@mdfriday/foundry 25.7.1 → 25.7.3
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/README.md +4 -0
- package/dist/internal/application/incremental-build-coordinator.d.ts +69 -0
- package/dist/internal/application/incremental-build-coordinator.d.ts.map +1 -0
- package/dist/internal/application/incremental-build-coordinator.js +184 -0
- package/dist/internal/application/incremental-build-coordinator.js.map +1 -0
- package/dist/internal/application/incremental-ssg.d.ts +8 -0
- package/dist/internal/application/incremental-ssg.d.ts.map +1 -0
- package/dist/internal/application/incremental-ssg.js +23 -0
- package/dist/internal/application/incremental-ssg.js.map +1 -0
- package/dist/internal/application/ssg.d.ts +19 -1
- package/dist/internal/application/ssg.d.ts.map +1 -1
- package/dist/internal/application/ssg.js +28 -4
- package/dist/internal/application/ssg.js.map +1 -1
- package/dist/internal/application/test-incremental-ssg.d.ts +9 -0
- package/dist/internal/application/test-incremental-ssg.d.ts.map +1 -0
- package/dist/internal/application/test-incremental-ssg.js +80 -0
- package/dist/internal/application/test-incremental-ssg.js.map +1 -0
- package/dist/internal/application/test-ssg.d.ts.map +1 -1
- package/dist/internal/application/test-ssg.js +2 -2
- package/dist/internal/application/test-ssg.js.map +1 -1
- package/dist/internal/domain/content/entity/content.d.ts +6 -2
- package/dist/internal/domain/content/entity/content.d.ts.map +1 -1
- package/dist/internal/domain/content/entity/content.js +51 -16
- package/dist/internal/domain/content/entity/content.js.map +1 -1
- package/dist/internal/domain/content/entity/pagebuilder.d.ts.map +1 -1
- package/dist/internal/domain/content/entity/pagebuilder.js +5 -1
- package/dist/internal/domain/content/entity/pagebuilder.js.map +1 -1
- package/dist/internal/domain/content/entity/pagecollector.d.ts.map +1 -1
- package/dist/internal/domain/content/entity/pagecollector.js +10 -8
- package/dist/internal/domain/content/entity/pagecollector.js.map +1 -1
- package/dist/internal/domain/content/entity/pagesource.d.ts.map +1 -1
- package/dist/internal/domain/content/entity/pagesource.js +1 -2
- package/dist/internal/domain/content/entity/pagesource.js.map +1 -1
- package/dist/internal/domain/content/type.d.ts +3 -0
- package/dist/internal/domain/content/type.d.ts.map +1 -1
- package/dist/internal/domain/content/type.js.map +1 -1
- package/dist/internal/domain/content/vo/fileinfo.d.ts +1 -1
- package/dist/internal/domain/content/vo/fileinfo.d.ts.map +1 -1
- package/dist/internal/domain/content/vo/fileinfo.js +8 -3
- package/dist/internal/domain/content/vo/fileinfo.js.map +1 -1
- package/dist/internal/domain/content/vo/identity.d.ts +4 -0
- package/dist/internal/domain/content/vo/identity.d.ts.map +1 -1
- package/dist/internal/domain/content/vo/identity.js +17 -0
- package/dist/internal/domain/content/vo/identity.js.map +1 -1
- package/dist/internal/domain/fs/entity/basefs.d.ts.map +1 -1
- package/dist/internal/domain/fs/entity/basefs.js +21 -9
- package/dist/internal/domain/fs/entity/basefs.js.map +1 -1
- package/dist/internal/domain/fs/entity/fs.d.ts +1 -0
- package/dist/internal/domain/fs/entity/fs.d.ts.map +1 -1
- package/dist/internal/domain/fs/entity/fs.js +4 -0
- package/dist/internal/domain/fs/entity/fs.js.map +1 -1
- package/dist/internal/domain/fs/vo/file.d.ts +1 -0
- package/dist/internal/domain/fs/vo/file.d.ts.map +1 -1
- package/dist/internal/domain/fs/vo/file.js +6 -3
- package/dist/internal/domain/fs/vo/file.js.map +1 -1
- package/dist/internal/domain/fs/vo/fileinfo.d.ts.map +1 -1
- package/dist/internal/domain/fs/vo/fileinfo.js +1 -2
- package/dist/internal/domain/fs/vo/fileinfo.js.map +1 -1
- package/dist/internal/domain/fs/vo/filemeta.d.ts +0 -4
- package/dist/internal/domain/fs/vo/filemeta.d.ts.map +1 -1
- package/dist/internal/domain/fs/vo/filemeta.js +0 -9
- package/dist/internal/domain/fs/vo/filemeta.js.map +1 -1
- package/dist/internal/domain/fs/vo/incremental-file-collector.d.ts +3 -0
- package/dist/internal/domain/fs/vo/incremental-file-collector.d.ts.map +1 -0
- package/dist/internal/domain/fs/vo/incremental-file-collector.js +37 -0
- package/dist/internal/domain/fs/vo/incremental-file-collector.js.map +1 -0
- package/dist/internal/domain/fs/vo/walkway.d.ts.map +1 -1
- package/dist/internal/domain/fs/vo/walkway.js +1 -4
- package/dist/internal/domain/fs/vo/walkway.js.map +1 -1
- package/dist/internal/domain/markdown/entity/markdown.d.ts.map +1 -1
- package/dist/internal/domain/markdown/entity/markdown.js +2 -0
- package/dist/internal/domain/markdown/entity/markdown.js.map +1 -1
- package/dist/internal/domain/markdown/type.d.ts +1 -0
- package/dist/internal/domain/markdown/type.d.ts.map +1 -1
- package/dist/internal/domain/markdown/type.js.map +1 -1
- package/dist/internal/domain/markdown/vo/shortcode.d.ts +1 -0
- package/dist/internal/domain/markdown/vo/shortcode.d.ts.map +1 -1
- package/dist/internal/domain/markdown/vo/shortcode.js +5 -2
- package/dist/internal/domain/markdown/vo/shortcode.js.map +1 -1
- package/dist/internal/domain/paths/type.d.ts +2 -0
- package/dist/internal/domain/paths/type.d.ts.map +1 -1
- package/dist/internal/domain/paths/type.js +14 -0
- package/dist/internal/domain/paths/type.js.map +1 -1
- package/dist/internal/domain/site/entity/page.d.ts +4 -2
- package/dist/internal/domain/site/entity/page.d.ts.map +1 -1
- package/dist/internal/domain/site/entity/page.js +6 -0
- package/dist/internal/domain/site/entity/page.js.map +1 -1
- package/dist/internal/domain/site/entity/site.d.ts +2 -1
- package/dist/internal/domain/site/entity/site.d.ts.map +1 -1
- package/dist/internal/domain/site/entity/site.js +9 -1
- package/dist/internal/domain/site/entity/site.js.map +1 -1
- package/dist/internal/domain/template/entity/template.d.ts.map +1 -1
- package/dist/internal/domain/template/entity/template.js +7 -36
- package/dist/internal/domain/template/entity/template.js.map +1 -1
- package/dist/internal/domain/template/vo/info.d.ts +0 -13
- package/dist/internal/domain/template/vo/info.d.ts.map +1 -1
- package/dist/internal/domain/template/vo/info.js +0 -25
- package/dist/internal/domain/template/vo/info.js.map +1 -1
- package/dist/pkg/log/manager.js +1 -1
- package/dist/pkg/web/server/livereload-server.d.ts +23 -0
- package/dist/pkg/web/server/livereload-server.d.ts.map +1 -0
- package/dist/pkg/web/server/livereload-server.js +370 -0
- package/dist/pkg/web/server/livereload-server.js.map +1 -0
- package/dist/pkg/web/server/types.d.ts +25 -0
- package/dist/pkg/web/server/types.d.ts.map +1 -0
- package/dist/pkg/web/server/types.js +3 -0
- package/dist/pkg/web/server/types.js.map +1 -0
- package/dist/pkg/web/watcher/content-file-watcher.d.ts +20 -0
- package/dist/pkg/web/watcher/content-file-watcher.d.ts.map +1 -0
- package/dist/pkg/web/watcher/content-file-watcher.js +154 -0
- package/dist/pkg/web/watcher/content-file-watcher.js.map +1 -0
- package/dist/pkg/web/watcher/types.d.ts +18 -0
- package/dist/pkg/web/watcher/types.d.ts.map +1 -0
- package/dist/pkg/web/watcher/types.js +3 -0
- package/dist/pkg/web/watcher/types.js.map +1 -0
- package/package.json +7 -2
- package/dist/internal/domain/markdown/examples/obsidian-example.d.ts +0 -79
- package/dist/internal/domain/markdown/examples/obsidian-example.d.ts.map +0 -1
- package/dist/internal/domain/markdown/examples/obsidian-example.js +0 -302
- package/dist/internal/domain/markdown/examples/obsidian-example.js.map +0 -1
- package/dist/internal/domain/markdown/examples/shortcode.d.ts +0 -43
- package/dist/internal/domain/markdown/examples/shortcode.d.ts.map +0 -1
- package/dist/internal/domain/markdown/examples/shortcode.js +0 -99
- package/dist/internal/domain/markdown/examples/shortcode.js.map +0 -1
- package/dist/internal/domain/prompt/entity/collector.d.ts +0 -88
- package/dist/internal/domain/prompt/entity/collector.d.ts.map +0 -1
- package/dist/internal/domain/prompt/entity/collector.js +0 -254
- package/dist/internal/domain/prompt/entity/collector.js.map +0 -1
- package/dist/internal/domain/prompt/entity/finder.d.ts +0 -88
- package/dist/internal/domain/prompt/entity/finder.d.ts.map +0 -1
- package/dist/internal/domain/prompt/entity/finder.js +0 -293
- package/dist/internal/domain/prompt/entity/finder.js.map +0 -1
- package/dist/internal/domain/prompt/entity/hub.d.ts +0 -112
- package/dist/internal/domain/prompt/entity/hub.d.ts.map +0 -1
- package/dist/internal/domain/prompt/entity/hub.js +0 -259
- package/dist/internal/domain/prompt/entity/hub.js.map +0 -1
- package/dist/internal/domain/prompt/entity/prompt.d.ts +0 -133
- package/dist/internal/domain/prompt/entity/prompt.d.ts.map +0 -1
- package/dist/internal/domain/prompt/entity/prompt.js +0 -237
- package/dist/internal/domain/prompt/entity/prompt.js.map +0 -1
- package/dist/internal/domain/prompt/factory/prompt.d.ts +0 -55
- package/dist/internal/domain/prompt/factory/prompt.d.ts.map +0 -1
- package/dist/internal/domain/prompt/factory/prompt.js +0 -212
- package/dist/internal/domain/prompt/factory/prompt.js.map +0 -1
- package/dist/internal/domain/prompt/index.d.ts +0 -10
- package/dist/internal/domain/prompt/index.d.ts.map +0 -1
- package/dist/internal/domain/prompt/index.js +0 -72
- package/dist/internal/domain/prompt/index.js.map +0 -1
- package/dist/internal/domain/prompt/type.d.ts +0 -180
- package/dist/internal/domain/prompt/type.d.ts.map +0 -1
- package/dist/internal/domain/prompt/type.js +0 -23
- package/dist/internal/domain/prompt/type.js.map +0 -1
- package/dist/internal/domain/prompt/vo/file.d.ts +0 -103
- package/dist/internal/domain/prompt/vo/file.d.ts.map +0 -1
- package/dist/internal/domain/prompt/vo/file.js +0 -265
- package/dist/internal/domain/prompt/vo/file.js.map +0 -1
- package/dist/internal/domain/prompt/vo/rule.d.ts +0 -139
- package/dist/internal/domain/prompt/vo/rule.d.ts.map +0 -1
- package/dist/internal/domain/prompt/vo/rule.js +0 -268
- package/dist/internal/domain/prompt/vo/rule.js.map +0 -1
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Finder = void 0;
|
|
4
|
-
exports.newFinder = newFinder;
|
|
5
|
-
const type_1 = require("../type");
|
|
6
|
-
/**
|
|
7
|
-
* Finder entity for finding and retrieving prompts
|
|
8
|
-
* TypeScript version of Go's Finder struct
|
|
9
|
-
*/
|
|
10
|
-
class Finder {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.files = new Map();
|
|
13
|
-
this.contentCache = new Map();
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Set files map
|
|
17
|
-
*/
|
|
18
|
-
setFiles(files) {
|
|
19
|
-
this.files = files;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* 预加载所有文件内容到内存缓存(新增方法)
|
|
23
|
-
*/
|
|
24
|
-
async preloadAllContent() {
|
|
25
|
-
const promises = [];
|
|
26
|
-
console.log(`[DEBUG] Preloading content for ${this.files.size} files...`);
|
|
27
|
-
for (const [path, file] of this.files) {
|
|
28
|
-
console.log(`[DEBUG] Found file in collection: "${path}" -> ${file.name()}`);
|
|
29
|
-
promises.push(file.contentAsString().then(content => {
|
|
30
|
-
this.contentCache.set(path, content);
|
|
31
|
-
console.log(`[DEBUG] Cached content for: "${path}"`);
|
|
32
|
-
}).catch(error => {
|
|
33
|
-
console.error(`Failed to preload content for ${path}:`, error);
|
|
34
|
-
this.contentCache.set(path, ''); // 设置空内容避免后续错误
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
await Promise.all(promises);
|
|
38
|
-
console.log(`[DEBUG] Content cache keys: [${Array.from(this.contentCache.keys()).join(', ')}]`);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* 同步获取内容(新增方法)- 依赖预加载
|
|
42
|
-
*/
|
|
43
|
-
getContentSync(name) {
|
|
44
|
-
console.log(`[DEBUG] getContentSync called with: "${name}"`);
|
|
45
|
-
if (this.contentCache.has(name)) {
|
|
46
|
-
console.log(`[DEBUG] Found direct match for: "${name}"`);
|
|
47
|
-
return this.contentCache.get(name) || '';
|
|
48
|
-
}
|
|
49
|
-
// 尝试多种路径格式匹配
|
|
50
|
-
const pathVariants = [
|
|
51
|
-
name, // 原始路径
|
|
52
|
-
name.startsWith('/') ? name.substring(1) : name, // 移除前导斜杠
|
|
53
|
-
name.startsWith('prompts/') ? name.substring(8) : name, // 移除 "prompts/" 前缀
|
|
54
|
-
name.startsWith('/prompts/') ? name.substring(9) : name, // 移除 "/prompts/" 前缀
|
|
55
|
-
];
|
|
56
|
-
// 同时也尝试为不带前缀的路径添加前缀
|
|
57
|
-
if (!name.startsWith('prompts/') && !name.startsWith('/prompts/')) {
|
|
58
|
-
pathVariants.push(`prompts/${name}`);
|
|
59
|
-
pathVariants.push(`/prompts/${name}`);
|
|
60
|
-
}
|
|
61
|
-
// 移除重复项
|
|
62
|
-
const uniqueVariants = [...new Set(pathVariants)];
|
|
63
|
-
console.log(`[DEBUG] Trying path variants: [${uniqueVariants.join(', ')}]`);
|
|
64
|
-
for (const variant of uniqueVariants) {
|
|
65
|
-
console.log(`[DEBUG] Checking variant: "${variant}"`);
|
|
66
|
-
if (this.contentCache.has(variant)) {
|
|
67
|
-
console.log(`[DEBUG] Found match for variant: "${variant}"`);
|
|
68
|
-
return this.contentCache.get(variant) || '';
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// 如果缓存中没有找到,抛出错误
|
|
72
|
-
console.log(`[DEBUG] No match found for any variant of: "${name}"`);
|
|
73
|
-
console.log(`[DEBUG] Available cache keys: [${Array.from(this.contentCache.keys()).join(', ')}]`);
|
|
74
|
-
throw new Error(`Prompt not found: ${name}. Tried variants: ${uniqueVariants.join(', ')}`);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Get prompt raw content by name
|
|
78
|
-
*/
|
|
79
|
-
async promptRawContent(name) {
|
|
80
|
-
if (this.contentCache.has(name)) {
|
|
81
|
-
return this.contentCache.get(name) || '';
|
|
82
|
-
}
|
|
83
|
-
for (const [path, file] of this.files) {
|
|
84
|
-
if (path === name) {
|
|
85
|
-
try {
|
|
86
|
-
const content = await file.contentAsString();
|
|
87
|
-
this.contentCache.set(name, content);
|
|
88
|
-
return content;
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
92
|
-
throw new type_1.PromptError(`Failed to read content for prompt ${name}: ${message}`, 'CONTENT_READ_FAILED');
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
throw new type_1.PromptError(`Prompt not found: ${name}`, 'PROMPT_NOT_FOUND');
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Check if prompt exists
|
|
100
|
-
*/
|
|
101
|
-
hasPrompt(name) {
|
|
102
|
-
console.log(`[DEBUG] hasPrompt called with: "${name}"`);
|
|
103
|
-
// 直接检查
|
|
104
|
-
if (this.files.has(name)) {
|
|
105
|
-
console.log(`[DEBUG] hasPrompt: Found direct match for: "${name}"`);
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
// 尝试多种路径格式匹配(与 getContentSync 保持一致)
|
|
109
|
-
const pathVariants = [
|
|
110
|
-
name, // 原始路径
|
|
111
|
-
name.startsWith('/') ? name.substring(1) : name, // 移除前导斜杠
|
|
112
|
-
name.startsWith('prompts/') ? name.substring(8) : name, // 移除 "prompts/" 前缀
|
|
113
|
-
name.startsWith('/prompts/') ? name.substring(9) : name, // 移除 "/prompts/" 前缀
|
|
114
|
-
];
|
|
115
|
-
// 同时也尝试为不带前缀的路径添加前缀
|
|
116
|
-
if (!name.startsWith('prompts/') && !name.startsWith('/prompts/')) {
|
|
117
|
-
pathVariants.push(`prompts/${name}`);
|
|
118
|
-
pathVariants.push(`/prompts/${name}`);
|
|
119
|
-
}
|
|
120
|
-
// 移除重复项
|
|
121
|
-
const uniqueVariants = [...new Set(pathVariants)];
|
|
122
|
-
console.log(`[DEBUG] hasPrompt: Trying path variants: [${uniqueVariants.join(', ')}]`);
|
|
123
|
-
for (const variant of uniqueVariants) {
|
|
124
|
-
console.log(`[DEBUG] hasPrompt: Checking variant: "${variant}"`);
|
|
125
|
-
if (this.files.has(variant)) {
|
|
126
|
-
console.log(`[DEBUG] hasPrompt: Found match for variant: "${variant}"`);
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
console.log(`[DEBUG] hasPrompt: No match found for any variant of: "${name}"`);
|
|
131
|
-
console.log(`[DEBUG] hasPrompt: Available file keys: [${Array.from(this.files.keys()).join(', ')}]`);
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Get all prompts
|
|
136
|
-
*/
|
|
137
|
-
getAllPrompts() {
|
|
138
|
-
const prompts = [];
|
|
139
|
-
for (const [path, file] of this.files) {
|
|
140
|
-
prompts.push({
|
|
141
|
-
name: file.name(),
|
|
142
|
-
path,
|
|
143
|
-
content: '', // Content not loaded for performance
|
|
144
|
-
size: file.size(),
|
|
145
|
-
modTime: file.modTime(),
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
return prompts;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Search prompts by pattern
|
|
152
|
-
*/
|
|
153
|
-
searchPrompts(pattern) {
|
|
154
|
-
const results = [];
|
|
155
|
-
for (const [path, file] of this.files) {
|
|
156
|
-
if (pattern.test(path) || pattern.test(file.name())) {
|
|
157
|
-
results.push({
|
|
158
|
-
name: file.name(),
|
|
159
|
-
path,
|
|
160
|
-
content: '', // Content not loaded for performance
|
|
161
|
-
size: file.size(),
|
|
162
|
-
modTime: file.modTime(),
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return results;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Get prompt content with caching
|
|
170
|
-
*/
|
|
171
|
-
async getPromptContent(name) {
|
|
172
|
-
const file = this.files.get(name);
|
|
173
|
-
if (!file) {
|
|
174
|
-
throw new type_1.PromptError(`Prompt not found: ${name}`, 'PROMPT_NOT_FOUND');
|
|
175
|
-
}
|
|
176
|
-
try {
|
|
177
|
-
const content = await file.contentAsString();
|
|
178
|
-
const metadata = {
|
|
179
|
-
name: file.name(),
|
|
180
|
-
path: name,
|
|
181
|
-
content,
|
|
182
|
-
size: file.size(),
|
|
183
|
-
modTime: file.modTime(),
|
|
184
|
-
};
|
|
185
|
-
return { content, metadata };
|
|
186
|
-
}
|
|
187
|
-
catch (error) {
|
|
188
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
189
|
-
throw new type_1.PromptError(`Failed to get prompt content for ${name}: ${message}`, 'CONTENT_RETRIEVAL_FAILED');
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Get all prompt names
|
|
194
|
-
*/
|
|
195
|
-
getPromptNames() {
|
|
196
|
-
return Array.from(this.files.keys());
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Get prompts by extension
|
|
200
|
-
*/
|
|
201
|
-
getPromptsByExtension(extension) {
|
|
202
|
-
const results = [];
|
|
203
|
-
const normalizedExt = extension.startsWith('.') ? extension : `.${extension}`;
|
|
204
|
-
for (const [path, file] of this.files) {
|
|
205
|
-
if (file.getExtension().toLowerCase() === normalizedExt.toLowerCase()) {
|
|
206
|
-
results.push({
|
|
207
|
-
name: file.name(),
|
|
208
|
-
path,
|
|
209
|
-
content: '', // Content not loaded for performance
|
|
210
|
-
size: file.size(),
|
|
211
|
-
modTime: file.modTime(),
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
return results;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Get prompts modified after date
|
|
219
|
-
*/
|
|
220
|
-
getPromptsModifiedAfter(date) {
|
|
221
|
-
const results = [];
|
|
222
|
-
for (const [path, file] of this.files) {
|
|
223
|
-
if (file.modTime() > date) {
|
|
224
|
-
results.push({
|
|
225
|
-
name: file.name(),
|
|
226
|
-
path,
|
|
227
|
-
content: '', // Content not loaded for performance
|
|
228
|
-
size: file.size(),
|
|
229
|
-
modTime: file.modTime(),
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
return results;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Get largest prompts
|
|
237
|
-
*/
|
|
238
|
-
getLargestPrompts(limit = 10) {
|
|
239
|
-
const allPrompts = this.getAllPrompts();
|
|
240
|
-
return allPrompts
|
|
241
|
-
.sort((a, b) => b.size - a.size)
|
|
242
|
-
.slice(0, limit);
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Get finder statistics
|
|
246
|
-
*/
|
|
247
|
-
getStats() {
|
|
248
|
-
let totalSize = 0;
|
|
249
|
-
let lastModified = null;
|
|
250
|
-
const fileTypes = new Map();
|
|
251
|
-
for (const [, file] of this.files) {
|
|
252
|
-
totalSize += file.size();
|
|
253
|
-
if (!lastModified || file.modTime() > lastModified) {
|
|
254
|
-
lastModified = file.modTime();
|
|
255
|
-
}
|
|
256
|
-
const ext = file.getExtension().toLowerCase();
|
|
257
|
-
fileTypes.set(ext, (fileTypes.get(ext) || 0) + 1);
|
|
258
|
-
}
|
|
259
|
-
return {
|
|
260
|
-
totalPrompts: this.files.size,
|
|
261
|
-
totalSize,
|
|
262
|
-
averageSize: this.files.size > 0 ? totalSize / this.files.size : 0,
|
|
263
|
-
fileTypes,
|
|
264
|
-
lastModified,
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Clear all files
|
|
269
|
-
*/
|
|
270
|
-
clear() {
|
|
271
|
-
this.files.clear();
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Get files count
|
|
275
|
-
*/
|
|
276
|
-
size() {
|
|
277
|
-
return this.files.size;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Check if finder is empty
|
|
281
|
-
*/
|
|
282
|
-
isEmpty() {
|
|
283
|
-
return this.files.size === 0;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
exports.Finder = Finder;
|
|
287
|
-
/**
|
|
288
|
-
* Create a new Finder instance
|
|
289
|
-
*/
|
|
290
|
-
function newFinder() {
|
|
291
|
-
return new Finder();
|
|
292
|
-
}
|
|
293
|
-
//# sourceMappingURL=finder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"finder.js","sourceRoot":"","sources":["../../../../../internal/domain/prompt/entity/finder.ts"],"names":[],"mappings":";;;AA4VA,8BAEC;AA9VD,kCAAgE;AAGhE;;;GAGG;AACH,MAAa,MAAM;IAAnB;QACU,UAAK,GAAG,IAAI,GAAG,EAAgB,CAAC;QAChC,iBAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;IA8UnD,CAAC;IA5UC;;OAEG;IACH,QAAQ,CAAC,KAAwB;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB;QACrB,MAAM,QAAQ,GAAoB,EAAE,CAAC;QAErC,OAAO,CAAC,GAAG,CAAC,kCAAkC,IAAI,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,CAAC;QAE1E,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACtC,OAAO,CAAC,GAAG,CAAC,sCAAsC,IAAI,QAAQ,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC7E,QAAQ,CAAC,IAAI,CACX,IAAI,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;gBACpC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBACrC,OAAO,CAAC,GAAG,CAAC,gCAAgC,IAAI,GAAG,CAAC,CAAC;YACvD,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;gBACf,OAAO,CAAC,KAAK,CAAC,iCAAiC,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC;gBAC/D,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc;YACjD,CAAC,CAAC,CACH,CAAC;QACJ,CAAC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,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YAChC,CAAC;YAED,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,WAAW,EAAE,CAAC;YAC9C,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACpD,CAAC;QAED,OAAO;YACL,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;YAC7B,SAAS;YACT,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClE,SAAS;YACT,YAAY;SACb,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC;IAC/B,CAAC;CACF;AAhVD,wBAgVC;AAED;;GAEG;AACH,SAAgB,SAAS;IACvB,OAAO,IAAI,MAAM,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { PromptHub, PromptRule } from '../type';
|
|
2
|
-
import { Rule } from '../vo/rule';
|
|
3
|
-
/**
|
|
4
|
-
* Hub entity for managing prompt rules
|
|
5
|
-
* TypeScript version of Go's Hub struct
|
|
6
|
-
*/
|
|
7
|
-
export declare class Hub implements PromptHub {
|
|
8
|
-
private treeRules;
|
|
9
|
-
/**
|
|
10
|
-
* Get all tree rules
|
|
11
|
-
*/
|
|
12
|
-
getTreeRules(): Map<string, PromptRule>;
|
|
13
|
-
/**
|
|
14
|
-
* Add rule
|
|
15
|
-
*/
|
|
16
|
-
addRule(name: string, rule: PromptRule): void;
|
|
17
|
-
/**
|
|
18
|
-
* Remove rule
|
|
19
|
-
*/
|
|
20
|
-
removeRule(name: string): boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Check if rule exists
|
|
23
|
-
*/
|
|
24
|
-
hasRule(name: string): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Get rule by name
|
|
27
|
-
*/
|
|
28
|
-
getRule(name: string): Rule | null;
|
|
29
|
-
/**
|
|
30
|
-
* Get all rule names
|
|
31
|
-
*/
|
|
32
|
-
getRuleNames(): string[];
|
|
33
|
-
/**
|
|
34
|
-
* Apply rules to content
|
|
35
|
-
*/
|
|
36
|
-
applyRules(content: string, ruleNames?: string[]): string;
|
|
37
|
-
/**
|
|
38
|
-
* Apply rules with safe mode (catches errors)
|
|
39
|
-
*/
|
|
40
|
-
applyRulesSafely(content: string, ruleNames?: string[]): {
|
|
41
|
-
result: string;
|
|
42
|
-
errors: Array<{
|
|
43
|
-
ruleName: string;
|
|
44
|
-
error: string;
|
|
45
|
-
}>;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Get rules by tag
|
|
49
|
-
*/
|
|
50
|
-
getRulesByTag(tag: string): Rule[];
|
|
51
|
-
/**
|
|
52
|
-
* Get rules by pattern
|
|
53
|
-
*/
|
|
54
|
-
getRulesByPattern(pattern: RegExp): Rule[];
|
|
55
|
-
/**
|
|
56
|
-
* Clear all rules
|
|
57
|
-
*/
|
|
58
|
-
clearRules(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Get hub statistics
|
|
61
|
-
*/
|
|
62
|
-
getStats(): {
|
|
63
|
-
totalRules: number;
|
|
64
|
-
rulesByPriority: Map<number, number>;
|
|
65
|
-
rulesByTag: Map<string, number>;
|
|
66
|
-
averagePriority: number;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Validate all rules
|
|
70
|
-
*/
|
|
71
|
-
validateRules(): {
|
|
72
|
-
valid: number;
|
|
73
|
-
invalid: number;
|
|
74
|
-
errors: Array<{
|
|
75
|
-
ruleName: string;
|
|
76
|
-
error: string;
|
|
77
|
-
}>;
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Export rules configuration
|
|
81
|
-
*/
|
|
82
|
-
exportRules(): Array<{
|
|
83
|
-
name: string;
|
|
84
|
-
priority: number;
|
|
85
|
-
description: string;
|
|
86
|
-
tags: string[];
|
|
87
|
-
hasPattern: boolean;
|
|
88
|
-
hasTransform: boolean;
|
|
89
|
-
hasValidate: boolean;
|
|
90
|
-
}>;
|
|
91
|
-
/**
|
|
92
|
-
* Create a copy of this hub
|
|
93
|
-
*/
|
|
94
|
-
copy(): Hub;
|
|
95
|
-
/**
|
|
96
|
-
* Check if hub is empty
|
|
97
|
-
*/
|
|
98
|
-
isEmpty(): boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Get rule count
|
|
101
|
-
*/
|
|
102
|
-
size(): number;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Create a new Hub instance
|
|
106
|
-
*/
|
|
107
|
-
export declare function newHub(): Hub;
|
|
108
|
-
/**
|
|
109
|
-
* Create a Hub with predefined rules
|
|
110
|
-
*/
|
|
111
|
-
export declare function createHubWithCommonRules(): Hub;
|
|
112
|
-
//# sourceMappingURL=hub.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hub.d.ts","sourceRoot":"","sources":["../../../../../internal/domain/prompt/entity/hub.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAe,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC;;;GAGG;AACH,qBAAa,GAAI,YAAW,SAAS;IACnC,OAAO,CAAC,SAAS,CAA2B;IAE5C;;OAEG;IACH,YAAY,IAAI,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC;IAQvC;;OA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AC,CAAC;KACpD;IAuBD;;OAEG;IACH,WAAW,IAAI,KAAK,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,UAAU,EAAE,OAAO,CAAC;QACpB,YAAY,EAAE,OAAO,CAAC;QACtB,WAAW,EAAE,OAAO,CAAC;KACtB,CAAC;IA2BF;;OAEG;IACH,IAAI,IAAI,GAAG;IAUX;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,IAAI,IAAI,MAAM;CAGf;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,GAAG,CAE5B;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,GAAG,CA0B9C"}
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Hub = void 0;
|
|
4
|
-
exports.newHub = newHub;
|
|
5
|
-
exports.createHubWithCommonRules = createHubWithCommonRules;
|
|
6
|
-
const type_1 = require("../type");
|
|
7
|
-
const rule_1 = require("../vo/rule");
|
|
8
|
-
/**
|
|
9
|
-
* Hub entity for managing prompt rules
|
|
10
|
-
* TypeScript version of Go's Hub struct
|
|
11
|
-
*/
|
|
12
|
-
class Hub {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.treeRules = new Map();
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Get all tree rules
|
|
18
|
-
*/
|
|
19
|
-
getTreeRules() {
|
|
20
|
-
const result = new Map();
|
|
21
|
-
for (const [key, rule] of this.treeRules) {
|
|
22
|
-
result.set(key, rule);
|
|
23
|
-
}
|
|
24
|
-
return result;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Add rule
|
|
28
|
-
*/
|
|
29
|
-
addRule(name, rule) {
|
|
30
|
-
if (!(rule instanceof rule_1.Rule)) {
|
|
31
|
-
throw new type_1.PromptError(`Rule must be an instance of Rule class`, 'INVALID_RULE_TYPE');
|
|
32
|
-
}
|
|
33
|
-
this.treeRules.set(name, rule);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Remove rule
|
|
37
|
-
*/
|
|
38
|
-
removeRule(name) {
|
|
39
|
-
return this.treeRules.delete(name);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Check if rule exists
|
|
43
|
-
*/
|
|
44
|
-
hasRule(name) {
|
|
45
|
-
return this.treeRules.has(name);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Get rule by name
|
|
49
|
-
*/
|
|
50
|
-
getRule(name) {
|
|
51
|
-
return this.treeRules.get(name) || null;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Get all rule names
|
|
55
|
-
*/
|
|
56
|
-
getRuleNames() {
|
|
57
|
-
return Array.from(this.treeRules.keys());
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Apply rules to content
|
|
61
|
-
*/
|
|
62
|
-
applyRules(content, ruleNames) {
|
|
63
|
-
let result = content;
|
|
64
|
-
const rulesToApply = ruleNames
|
|
65
|
-
? ruleNames.map(name => this.treeRules.get(name)).filter(rule => rule !== undefined)
|
|
66
|
-
: Array.from(this.treeRules.values());
|
|
67
|
-
// Sort rules by priority (higher priority first)
|
|
68
|
-
rulesToApply.sort((a, b) => b.getPriority() - a.getPriority());
|
|
69
|
-
for (const rule of rulesToApply) {
|
|
70
|
-
if (rule.appliesTo(result)) {
|
|
71
|
-
try {
|
|
72
|
-
result = rule.apply(result);
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
76
|
-
throw new type_1.PromptError(`Failed to apply rule ${rule.name}: ${message}`, 'RULE_APPLICATION_FAILED');
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Apply rules with safe mode (catches errors)
|
|
84
|
-
*/
|
|
85
|
-
applyRulesSafely(content, ruleNames) {
|
|
86
|
-
let result = content;
|
|
87
|
-
const errors = [];
|
|
88
|
-
const rulesToApply = ruleNames
|
|
89
|
-
? ruleNames.map(name => this.treeRules.get(name)).filter(rule => rule !== undefined)
|
|
90
|
-
: Array.from(this.treeRules.values());
|
|
91
|
-
// Sort rules by priority (higher priority first)
|
|
92
|
-
rulesToApply.sort((a, b) => b.getPriority() - a.getPriority());
|
|
93
|
-
for (const rule of rulesToApply) {
|
|
94
|
-
if (rule.appliesTo(result)) {
|
|
95
|
-
try {
|
|
96
|
-
result = rule.apply(result);
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
100
|
-
errors.push({
|
|
101
|
-
ruleName: rule.name,
|
|
102
|
-
error: message
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return { result, errors };
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Get rules by tag
|
|
111
|
-
*/
|
|
112
|
-
getRulesByTag(tag) {
|
|
113
|
-
const results = [];
|
|
114
|
-
for (const rule of this.treeRules.values()) {
|
|
115
|
-
if (rule.hasTag(tag)) {
|
|
116
|
-
results.push(rule);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return results;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Get rules by pattern
|
|
123
|
-
*/
|
|
124
|
-
getRulesByPattern(pattern) {
|
|
125
|
-
const results = [];
|
|
126
|
-
for (const [name, rule] of this.treeRules) {
|
|
127
|
-
if (pattern.test(name) || pattern.test(rule.getDescription())) {
|
|
128
|
-
results.push(rule);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return results;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Clear all rules
|
|
135
|
-
*/
|
|
136
|
-
clearRules() {
|
|
137
|
-
this.treeRules.clear();
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Get hub statistics
|
|
141
|
-
*/
|
|
142
|
-
getStats() {
|
|
143
|
-
const rulesByPriority = new Map();
|
|
144
|
-
const rulesByTag = new Map();
|
|
145
|
-
let totalPriority = 0;
|
|
146
|
-
for (const rule of this.treeRules.values()) {
|
|
147
|
-
const priority = rule.getPriority();
|
|
148
|
-
totalPriority += priority;
|
|
149
|
-
rulesByPriority.set(priority, (rulesByPriority.get(priority) || 0) + 1);
|
|
150
|
-
for (const tag of rule.getTags()) {
|
|
151
|
-
rulesByTag.set(tag, (rulesByTag.get(tag) || 0) + 1);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return {
|
|
155
|
-
totalRules: this.treeRules.size,
|
|
156
|
-
rulesByPriority,
|
|
157
|
-
rulesByTag,
|
|
158
|
-
averagePriority: this.treeRules.size > 0 ? totalPriority / this.treeRules.size : 0,
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Validate all rules
|
|
163
|
-
*/
|
|
164
|
-
validateRules() {
|
|
165
|
-
let valid = 0;
|
|
166
|
-
let invalid = 0;
|
|
167
|
-
const errors = [];
|
|
168
|
-
for (const [name, rule] of this.treeRules) {
|
|
169
|
-
try {
|
|
170
|
-
// Try to apply rule to test content
|
|
171
|
-
const testContent = 'test content';
|
|
172
|
-
if (rule.appliesTo(testContent)) {
|
|
173
|
-
rule.apply(testContent);
|
|
174
|
-
}
|
|
175
|
-
valid++;
|
|
176
|
-
}
|
|
177
|
-
catch (error) {
|
|
178
|
-
invalid++;
|
|
179
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
180
|
-
errors.push({ ruleName: name, error: message });
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return { valid, invalid, errors };
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Export rules configuration
|
|
187
|
-
*/
|
|
188
|
-
exportRules() {
|
|
189
|
-
const exported = [];
|
|
190
|
-
for (const [name, rule] of this.treeRules) {
|
|
191
|
-
const summary = rule.getSummary();
|
|
192
|
-
exported.push({
|
|
193
|
-
name: name,
|
|
194
|
-
priority: summary.priority,
|
|
195
|
-
description: summary.description,
|
|
196
|
-
tags: summary.tags,
|
|
197
|
-
hasPattern: summary.hasPattern,
|
|
198
|
-
hasTransform: summary.hasTransform,
|
|
199
|
-
hasValidate: summary.hasValidate,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
return exported.sort((a, b) => b.priority - a.priority);
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Create a copy of this hub
|
|
206
|
-
*/
|
|
207
|
-
copy() {
|
|
208
|
-
const newHub = new Hub();
|
|
209
|
-
for (const [name, rule] of this.treeRules) {
|
|
210
|
-
newHub.addRule(name, rule.copy());
|
|
211
|
-
}
|
|
212
|
-
return newHub;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Check if hub is empty
|
|
216
|
-
*/
|
|
217
|
-
isEmpty() {
|
|
218
|
-
return this.treeRules.size === 0;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Get rule count
|
|
222
|
-
*/
|
|
223
|
-
size() {
|
|
224
|
-
return this.treeRules.size;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
exports.Hub = Hub;
|
|
228
|
-
/**
|
|
229
|
-
* Create a new Hub instance
|
|
230
|
-
*/
|
|
231
|
-
function newHub() {
|
|
232
|
-
return new Hub();
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Create a Hub with predefined rules
|
|
236
|
-
*/
|
|
237
|
-
function createHubWithCommonRules() {
|
|
238
|
-
const hub = new Hub();
|
|
239
|
-
// Add common rules (these would be imported from rule.ts)
|
|
240
|
-
// For now, we'll create simple rules inline
|
|
241
|
-
const trimRule = new rule_1.Rule({
|
|
242
|
-
name: 'trim-whitespace',
|
|
243
|
-
description: 'Remove leading and trailing whitespace',
|
|
244
|
-
priority: 10,
|
|
245
|
-
transform: (content) => content.trim(),
|
|
246
|
-
tags: ['formatting', 'cleanup'],
|
|
247
|
-
});
|
|
248
|
-
const normalizeRule = new rule_1.Rule({
|
|
249
|
-
name: 'normalize-line-endings',
|
|
250
|
-
description: 'Normalize line endings to LF',
|
|
251
|
-
priority: 20,
|
|
252
|
-
transform: (content) => content.replace(/\r\n/g, '\n').replace(/\r/g, '\n'),
|
|
253
|
-
tags: ['formatting', 'normalization'],
|
|
254
|
-
});
|
|
255
|
-
hub.addRule('trim', trimRule);
|
|
256
|
-
hub.addRule('normalize', normalizeRule);
|
|
257
|
-
return hub;
|
|
258
|
-
}
|
|
259
|
-
//# sourceMappingURL=hub.js.map
|