solvdex 1.0.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.
Files changed (113) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +274 -0
  3. package/dist/hooks/error-lookup.d.ts +4 -0
  4. package/dist/hooks/error-lookup.d.ts.map +1 -0
  5. package/dist/hooks/error-lookup.js +92 -0
  6. package/dist/hooks/error-lookup.js.map +1 -0
  7. package/dist/hooks/post-task.d.ts +15 -0
  8. package/dist/hooks/post-task.d.ts.map +1 -0
  9. package/dist/hooks/post-task.js +246 -0
  10. package/dist/hooks/post-task.js.map +1 -0
  11. package/dist/hooks/prompt-enrich.d.ts +16 -0
  12. package/dist/hooks/prompt-enrich.d.ts.map +1 -0
  13. package/dist/hooks/prompt-enrich.js +141 -0
  14. package/dist/hooks/prompt-enrich.js.map +1 -0
  15. package/dist/hooks/session-start-cli.d.ts +3 -0
  16. package/dist/hooks/session-start-cli.d.ts.map +1 -0
  17. package/dist/hooks/session-start-cli.js +81 -0
  18. package/dist/hooks/session-start-cli.js.map +1 -0
  19. package/dist/hooks/session-start.d.ts +4 -0
  20. package/dist/hooks/session-start.d.ts.map +1 -0
  21. package/dist/hooks/session-start.js +134 -0
  22. package/dist/hooks/session-start.js.map +1 -0
  23. package/dist/src/audit.d.ts +63 -0
  24. package/dist/src/audit.d.ts.map +1 -0
  25. package/dist/src/audit.js +229 -0
  26. package/dist/src/audit.js.map +1 -0
  27. package/dist/src/cache.d.ts +54 -0
  28. package/dist/src/cache.d.ts.map +1 -0
  29. package/dist/src/cache.js +167 -0
  30. package/dist/src/cache.js.map +1 -0
  31. package/dist/src/config.d.ts +52 -0
  32. package/dist/src/config.d.ts.map +1 -0
  33. package/dist/src/config.js +175 -0
  34. package/dist/src/config.js.map +1 -0
  35. package/dist/src/entry.d.ts +154 -0
  36. package/dist/src/entry.d.ts.map +1 -0
  37. package/dist/src/entry.js +469 -0
  38. package/dist/src/entry.js.map +1 -0
  39. package/dist/src/errors.d.ts +65 -0
  40. package/dist/src/errors.d.ts.map +1 -0
  41. package/dist/src/errors.js +121 -0
  42. package/dist/src/errors.js.map +1 -0
  43. package/dist/src/frontmatter.d.ts +28 -0
  44. package/dist/src/frontmatter.d.ts.map +1 -0
  45. package/dist/src/frontmatter.js +111 -0
  46. package/dist/src/frontmatter.js.map +1 -0
  47. package/dist/src/index.d.ts +35 -0
  48. package/dist/src/index.d.ts.map +1 -0
  49. package/dist/src/index.js +188 -0
  50. package/dist/src/index.js.map +1 -0
  51. package/dist/src/maturity.d.ts +31 -0
  52. package/dist/src/maturity.d.ts.map +1 -0
  53. package/dist/src/maturity.js +96 -0
  54. package/dist/src/maturity.js.map +1 -0
  55. package/dist/src/quality.d.ts +23 -0
  56. package/dist/src/quality.d.ts.map +1 -0
  57. package/dist/src/quality.js +236 -0
  58. package/dist/src/quality.js.map +1 -0
  59. package/dist/src/search.d.ts +35 -0
  60. package/dist/src/search.d.ts.map +1 -0
  61. package/dist/src/search.js +263 -0
  62. package/dist/src/search.js.map +1 -0
  63. package/dist/src/similarity.d.ts +42 -0
  64. package/dist/src/similarity.d.ts.map +1 -0
  65. package/dist/src/similarity.js +111 -0
  66. package/dist/src/similarity.js.map +1 -0
  67. package/dist/src/stats.d.ts +56 -0
  68. package/dist/src/stats.d.ts.map +1 -0
  69. package/dist/src/stats.js +198 -0
  70. package/dist/src/stats.js.map +1 -0
  71. package/dist/src/templates.d.ts +63 -0
  72. package/dist/src/templates.d.ts.map +1 -0
  73. package/dist/src/templates.js +347 -0
  74. package/dist/src/templates.js.map +1 -0
  75. package/dist/src/transfer.d.ts +92 -0
  76. package/dist/src/transfer.d.ts.map +1 -0
  77. package/dist/src/transfer.js +215 -0
  78. package/dist/src/transfer.js.map +1 -0
  79. package/dist/src/types.d.ts +270 -0
  80. package/dist/src/types.d.ts.map +1 -0
  81. package/dist/src/types.js +153 -0
  82. package/dist/src/types.js.map +1 -0
  83. package/dist/src/validate.d.ts +90 -0
  84. package/dist/src/validate.d.ts.map +1 -0
  85. package/dist/src/validate.js +295 -0
  86. package/dist/src/validate.js.map +1 -0
  87. package/hooks/error-lookup.ts +110 -0
  88. package/hooks/hooks.json +49 -0
  89. package/hooks/post-task.ts +309 -0
  90. package/hooks/prompt-enrich.ts +162 -0
  91. package/hooks/session-start-cli.ts +96 -0
  92. package/hooks/session-start.ts +159 -0
  93. package/package.json +40 -0
  94. package/scripts/error-lookup.py +64 -0
  95. package/scripts/post-task.py +60 -0
  96. package/scripts/prompt-enrich.py +64 -0
  97. package/scripts/session-start.py +64 -0
  98. package/skills/wiki/SKILL.md +61 -0
  99. package/skills/wiki-add/SKILL.md +90 -0
  100. package/skills/wiki-browse/SKILL.md +108 -0
  101. package/skills/wiki-capture/SKILL.md +265 -0
  102. package/skills/wiki-explorer/SKILL.md +223 -0
  103. package/skills/wiki-export/SKILL.md +101 -0
  104. package/skills/wiki-fix/SKILL.md +86 -0
  105. package/skills/wiki-flag/SKILL.md +47 -0
  106. package/skills/wiki-import/SKILL.md +128 -0
  107. package/skills/wiki-init/SKILL.md +72 -0
  108. package/skills/wiki-scan/SKILL.md +98 -0
  109. package/skills/wiki-search/SKILL.md +86 -0
  110. package/skills/wiki-stats/SKILL.md +129 -0
  111. package/skills/wiki-status/SKILL.md +78 -0
  112. package/skills/wiki-test-trigger/SKILL.md +173 -0
  113. package/skills/wiki-validate/SKILL.md +62 -0
@@ -0,0 +1,469 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.slugify = slugify;
37
+ exports.createEntry = createEntry;
38
+ exports.readEntry = readEntry;
39
+ exports.updateEntry = updateEntry;
40
+ exports.listEntries = listEntries;
41
+ exports.deleteEntry = deleteEntry;
42
+ exports.checkDuplicate = checkDuplicate;
43
+ exports.recordEntryUsage = recordEntryUsage;
44
+ exports.getRelatedEntries = getRelatedEntries;
45
+ exports.setRelatedEntries = setRelatedEntries;
46
+ exports.createEntryWithValidation = createEntryWithValidation;
47
+ // src/entry.ts
48
+ const fs = __importStar(require("fs"));
49
+ const path = __importStar(require("path"));
50
+ const glob_1 = require("glob");
51
+ const frontmatter_js_1 = require("./frontmatter.js");
52
+ const config_js_1 = require("./config.js");
53
+ const quality_js_1 = require("./quality.js");
54
+ const similarity_js_1 = require("./similarity.js");
55
+ const maturity_js_1 = require("./maturity.js");
56
+ const errors_js_1 = require("./errors.js");
57
+ const cache_js_1 = require("./cache.js");
58
+ /**
59
+ * Converts a title to a URL-friendly slug.
60
+ *
61
+ * @param title - The title to convert
62
+ * @returns A lowercase, hyphenated slug
63
+ */
64
+ function slugify(title) {
65
+ return title
66
+ .toLowerCase()
67
+ .trim()
68
+ .replace(/[^\w\s-]/g, '') // Remove non-word chars (except spaces and hyphens)
69
+ .replace(/\s+/g, '-') // Replace spaces with hyphens
70
+ .replace(/-+/g, '-') // Replace multiple hyphens with single hyphen
71
+ .replace(/^-+|-+$/g, ''); // Remove leading/trailing hyphens
72
+ }
73
+ /**
74
+ * Generates the current date in ISO format (YYYY-MM-DD).
75
+ *
76
+ * @returns Current date string
77
+ */
78
+ function getCurrentDate() {
79
+ return new Date().toISOString().split('T')[0];
80
+ }
81
+ /**
82
+ * Converts a content record to markdown body.
83
+ *
84
+ * @param content - Record of heading -> content
85
+ * @returns Formatted markdown string
86
+ */
87
+ function contentRecordToMarkdown(content) {
88
+ const sections = [];
89
+ for (const [heading, body] of Object.entries(content)) {
90
+ sections.push(`# ${heading}\n\n${body}`);
91
+ }
92
+ return sections.join('\n\n');
93
+ }
94
+ /**
95
+ * Creates a new wiki entry.
96
+ *
97
+ * @param projectRoot - The root directory of the project
98
+ * @param options - Options for creating the entry
99
+ * @returns The created WikiEntry
100
+ * @throws Error if wiki is not initialized or category is invalid
101
+ */
102
+ function createEntry(projectRoot, options) {
103
+ if (!(0, config_js_1.wikiExists)(projectRoot)) {
104
+ throw new errors_js_1.WikiNotInitializedError(projectRoot);
105
+ }
106
+ const { category, title, tags, content, trigger, autoCapture, stub, source, confidence, context } = options;
107
+ const slug = slugify(title);
108
+ const wikiPath = (0, config_js_1.getWikiPath)(projectRoot);
109
+ const categoryDir = path.join(wikiPath, category);
110
+ const entryPath = path.join(categoryDir, `${slug}.md`);
111
+ // Create category directory if it doesn't exist
112
+ if (!fs.existsSync(categoryDir)) {
113
+ fs.mkdirSync(categoryDir, { recursive: true });
114
+ }
115
+ const now = getCurrentDate();
116
+ const auditEntry = {
117
+ date: now,
118
+ action: 'created',
119
+ by: autoCapture ? 'claude' : 'user'
120
+ };
121
+ // Add audit context - use provided context, or default based on capture method
122
+ if (context) {
123
+ auditEntry.context = context;
124
+ }
125
+ else if (autoCapture) {
126
+ auditEntry.context = 'auto-captured';
127
+ }
128
+ const frontmatter = {
129
+ title,
130
+ created: now,
131
+ updated: now,
132
+ status: 'active',
133
+ confidence: confidence || (0, maturity_js_1.getConfidenceForMaturity)('captured'),
134
+ maturity: 'captured', // All entries start as captured
135
+ tags,
136
+ audit: [auditEntry],
137
+ use_count: 0 // Initialize use counter
138
+ };
139
+ // Add optional fields
140
+ if (trigger) {
141
+ frontmatter.trigger = trigger;
142
+ }
143
+ if (autoCapture !== undefined) {
144
+ frontmatter.auto_captured = autoCapture;
145
+ }
146
+ if (stub !== undefined) {
147
+ frontmatter.stub = stub;
148
+ }
149
+ if (source) {
150
+ frontmatter.source = source;
151
+ }
152
+ const markdownContent = contentRecordToMarkdown(content);
153
+ const fileContent = (0, frontmatter_js_1.stringifyFrontmatter)(frontmatter, markdownContent);
154
+ (0, errors_js_1.wrapFileOperation)('create', entryPath, () => fs.writeFileSync(entryPath, fileContent, 'utf-8'));
155
+ // Return relative path from wiki directory
156
+ const relativePath = path.relative(wikiPath, entryPath);
157
+ return {
158
+ path: relativePath,
159
+ category,
160
+ slug,
161
+ frontmatter,
162
+ content: markdownContent
163
+ };
164
+ }
165
+ /**
166
+ * Reads an existing wiki entry.
167
+ *
168
+ * @param projectRoot - The root directory of the project
169
+ * @param entryPath - Relative path to the entry from the wiki directory
170
+ * @returns The WikiEntry if found, null otherwise
171
+ */
172
+ function readEntry(projectRoot, entryPath) {
173
+ const wikiPath = (0, config_js_1.getWikiPath)(projectRoot);
174
+ const fullPath = path.join(wikiPath, entryPath);
175
+ if (!fs.existsSync(fullPath)) {
176
+ return null;
177
+ }
178
+ // CHECK CACHE FIRST
179
+ const cached = (0, cache_js_1.getCachedEntry)(fullPath);
180
+ if (cached) {
181
+ return cached;
182
+ }
183
+ // Cache miss - read from disk with error wrapping
184
+ const fileContent = (0, errors_js_1.wrapFileOperation)('read', fullPath, () => fs.readFileSync(fullPath, 'utf-8'));
185
+ const { frontmatter, content } = (0, frontmatter_js_1.parseFrontmatter)(fileContent);
186
+ // Extract category and slug from path
187
+ const pathParts = entryPath.split(path.sep);
188
+ const category = pathParts[0];
189
+ const slug = path.basename(entryPath, '.md');
190
+ const entry = {
191
+ path: entryPath,
192
+ category,
193
+ slug,
194
+ frontmatter,
195
+ content
196
+ };
197
+ // CACHE BEFORE RETURNING
198
+ (0, cache_js_1.setCachedEntry)(fullPath, entry);
199
+ return entry;
200
+ }
201
+ /**
202
+ * Updates an existing wiki entry.
203
+ *
204
+ * @param projectRoot - The root directory of the project
205
+ * @param entryPath - Relative path to the entry from the wiki directory
206
+ * @param updates - Fields to update
207
+ * @param auditContext - Context for the audit trail entry
208
+ * @returns The updated WikiEntry
209
+ * @throws Error if entry does not exist
210
+ */
211
+ function updateEntry(projectRoot, entryPath, updates, auditContext) {
212
+ const existing = readEntry(projectRoot, entryPath);
213
+ if (!existing) {
214
+ const wikiPath = (0, config_js_1.getWikiPath)(projectRoot);
215
+ const fullPath = path.join(wikiPath, entryPath);
216
+ throw new errors_js_1.EntryNotFoundError(fullPath, projectRoot);
217
+ }
218
+ const now = getCurrentDate();
219
+ // Create updated frontmatter
220
+ const updatedFrontmatter = {
221
+ ...existing.frontmatter,
222
+ updated: now
223
+ };
224
+ // Apply updates
225
+ if (updates.title !== undefined) {
226
+ updatedFrontmatter.title = updates.title;
227
+ }
228
+ if (updates.tags !== undefined) {
229
+ updatedFrontmatter.tags = updates.tags;
230
+ }
231
+ if (updates.status !== undefined) {
232
+ updatedFrontmatter.status = updates.status;
233
+ }
234
+ if (updates.confidence !== undefined) {
235
+ updatedFrontmatter.confidence = updates.confidence;
236
+ }
237
+ if (updates.trigger !== undefined) {
238
+ updatedFrontmatter.trigger = updates.trigger;
239
+ }
240
+ // Determine audit action based on updates
241
+ let action = 'updated';
242
+ if (updates.status === 'flagged') {
243
+ action = 'flagged';
244
+ }
245
+ else if (updates.status === 'deprecated') {
246
+ action = 'deprecated';
247
+ }
248
+ // Add audit entry
249
+ const auditEntry = {
250
+ date: now,
251
+ action,
252
+ by: auditContext.by
253
+ };
254
+ if (auditContext.reason) {
255
+ auditEntry.reason = auditContext.reason;
256
+ }
257
+ if (auditContext.context) {
258
+ auditEntry.context = auditContext.context;
259
+ }
260
+ updatedFrontmatter.audit = [...existing.frontmatter.audit, auditEntry];
261
+ // Determine content
262
+ const updatedContent = updates.content !== undefined ? updates.content : existing.content;
263
+ // Write updated entry
264
+ const wikiPath = (0, config_js_1.getWikiPath)(projectRoot);
265
+ const fullPath = path.join(wikiPath, entryPath);
266
+ const fileContent = (0, frontmatter_js_1.stringifyFrontmatter)(updatedFrontmatter, updatedContent);
267
+ (0, errors_js_1.wrapFileOperation)('write', fullPath, () => fs.writeFileSync(fullPath, fileContent, 'utf-8'));
268
+ // Invalidate cache after update
269
+ (0, cache_js_1.invalidateCache)(fullPath);
270
+ return {
271
+ path: entryPath,
272
+ category: existing.category,
273
+ slug: existing.slug,
274
+ frontmatter: updatedFrontmatter,
275
+ content: updatedContent
276
+ };
277
+ }
278
+ /**
279
+ * Lists all wiki entries with optional filtering.
280
+ *
281
+ * @param projectRoot - The root directory of the project
282
+ * @param options - Optional filters for category, status, or tags
283
+ * @returns Array of WikiEntry objects matching the filters
284
+ */
285
+ async function listEntries(projectRoot, options = {}) {
286
+ const wikiPath = (0, config_js_1.getWikiPath)(projectRoot);
287
+ if (!fs.existsSync(wikiPath)) {
288
+ return [];
289
+ }
290
+ // Determine glob pattern based on category filter
291
+ let pattern;
292
+ if (options.category) {
293
+ pattern = path.join(wikiPath, options.category, '*.md');
294
+ }
295
+ else {
296
+ pattern = path.join(wikiPath, '**', '*.md');
297
+ }
298
+ const files = await (0, glob_1.glob)(pattern, { nodir: true });
299
+ const entries = [];
300
+ for (const filePath of files) {
301
+ const relativePath = path.relative(wikiPath, filePath);
302
+ // Skip config files and overview files
303
+ if (relativePath.startsWith('.') || relativePath.includes('_overview.md')) {
304
+ continue;
305
+ }
306
+ const entry = readEntry(projectRoot, relativePath);
307
+ if (!entry || !entry.frontmatter.updated) {
308
+ continue;
309
+ }
310
+ // Apply status filter
311
+ if (options.status && entry.frontmatter.status !== options.status) {
312
+ continue;
313
+ }
314
+ // Apply tags filter (entry must have all specified tags)
315
+ if (options.tags && options.tags.length > 0) {
316
+ const hasAllTags = options.tags.every(tag => entry.frontmatter.tags.includes(tag));
317
+ if (!hasAllTags) {
318
+ continue;
319
+ }
320
+ }
321
+ entries.push(entry);
322
+ }
323
+ // Sort by updated date, most recent first
324
+ entries.sort((a, b) => b.frontmatter.updated.localeCompare(a.frontmatter.updated));
325
+ return entries;
326
+ }
327
+ /**
328
+ * Deletes a wiki entry.
329
+ *
330
+ * @param projectRoot - The root directory of the project
331
+ * @param entryPath - Relative path to the entry from the wiki directory
332
+ * @returns True if the entry was deleted, false if it didn't exist
333
+ */
334
+ function deleteEntry(projectRoot, entryPath) {
335
+ const wikiPath = (0, config_js_1.getWikiPath)(projectRoot);
336
+ const fullPath = path.join(wikiPath, entryPath);
337
+ if (!fs.existsSync(fullPath)) {
338
+ return false;
339
+ }
340
+ (0, errors_js_1.wrapFileOperation)('delete', fullPath, () => fs.unlinkSync(fullPath));
341
+ // Invalidate cache after delete
342
+ (0, cache_js_1.invalidateCache)(fullPath);
343
+ return true;
344
+ }
345
+ /**
346
+ * Checks for duplicate entries before creating.
347
+ *
348
+ * @param projectRoot - The root directory of the project
349
+ * @param title - The title of the new entry
350
+ * @param tags - The tags of the new entry
351
+ * @param category - The category of the new entry
352
+ * @returns DuplicateCheckResult
353
+ */
354
+ async function checkDuplicate(projectRoot, title, tags, category) {
355
+ const entries = await listEntries(projectRoot, { category });
356
+ return (0, similarity_js_1.checkForDuplicate)(title, tags, category, entries);
357
+ }
358
+ /**
359
+ * Records that an entry was used/accessed.
360
+ * Updates last_used timestamp, increments use_count, and checks for maturity promotion.
361
+ *
362
+ * @param projectRoot - The root directory of the project
363
+ * @param entryPath - Relative path to the entry
364
+ * @returns Updated WikiEntry
365
+ */
366
+ function recordEntryUsage(projectRoot, entryPath) {
367
+ const entry = readEntry(projectRoot, entryPath);
368
+ if (!entry)
369
+ return null;
370
+ const wikiPath = (0, config_js_1.getWikiPath)(projectRoot);
371
+ const fullPath = path.join(wikiPath, entryPath);
372
+ const now = getCurrentDate();
373
+ // Increment use count
374
+ const newUseCount = (entry.frontmatter.use_count || 0) + 1;
375
+ // Calculate what maturity should be (remove maturity field to force fresh calculation)
376
+ const currentMaturity = entry.frontmatter.maturity || 'captured';
377
+ const { maturity: _, ...frontmatterWithoutMaturity } = entry.frontmatter;
378
+ const calculatedMaturity = (0, maturity_js_1.calculateMaturity)({
379
+ ...frontmatterWithoutMaturity,
380
+ use_count: newUseCount
381
+ });
382
+ // Check if we should promote
383
+ const shouldPromote = (0, maturity_js_1.shouldPromoteMaturity)(currentMaturity, calculatedMaturity);
384
+ // Flagged entries don't get promoted (frozen)
385
+ const canPromote = shouldPromote && entry.frontmatter.status !== 'flagged';
386
+ // Update frontmatter
387
+ const updatedFrontmatter = {
388
+ ...entry.frontmatter,
389
+ last_used: now,
390
+ use_count: newUseCount
391
+ };
392
+ // Apply maturity promotion if eligible
393
+ if (canPromote) {
394
+ updatedFrontmatter.maturity = calculatedMaturity;
395
+ updatedFrontmatter.confidence = (0, maturity_js_1.getConfidenceForMaturity)(calculatedMaturity);
396
+ updatedFrontmatter.updated = now;
397
+ // Add audit entry for promotion
398
+ const promotionAudit = {
399
+ date: now,
400
+ action: 'maturity_promoted',
401
+ by: 'system',
402
+ context: `Auto-promoted: ${currentMaturity} → ${calculatedMaturity} (${newUseCount} uses)`
403
+ };
404
+ updatedFrontmatter.audit = [...entry.frontmatter.audit, promotionAudit];
405
+ }
406
+ // Write updated entry
407
+ const fileContent = (0, frontmatter_js_1.stringifyFrontmatter)(updatedFrontmatter, entry.content);
408
+ (0, errors_js_1.wrapFileOperation)('write', fullPath, () => fs.writeFileSync(fullPath, fileContent, 'utf-8'));
409
+ (0, cache_js_1.invalidateCache)(fullPath);
410
+ return {
411
+ ...entry,
412
+ frontmatter: updatedFrontmatter
413
+ };
414
+ }
415
+ /**
416
+ * Finds and returns related entries for a given entry.
417
+ *
418
+ * @param projectRoot - The root directory of the project
419
+ * @param entryPath - Relative path to the entry
420
+ * @param maxResults - Maximum number of related entries
421
+ * @returns Array of related entry paths
422
+ */
423
+ async function getRelatedEntries(projectRoot, entryPath, maxResults = 5) {
424
+ const entry = readEntry(projectRoot, entryPath);
425
+ if (!entry)
426
+ return [];
427
+ // Return stored relations if available
428
+ if (entry.frontmatter.related_entries && entry.frontmatter.related_entries.length > 0) {
429
+ return entry.frontmatter.related_entries;
430
+ }
431
+ // Otherwise compute dynamically
432
+ const allEntries = await listEntries(projectRoot);
433
+ return (0, similarity_js_1.findRelatedEntries)(entry, allEntries, maxResults);
434
+ }
435
+ /**
436
+ * Updates the related_entries field for an entry.
437
+ *
438
+ * @param projectRoot - The root directory of the project
439
+ * @param entryPath - Relative path to the entry
440
+ * @param relatedPaths - Array of related entry paths
441
+ */
442
+ function setRelatedEntries(projectRoot, entryPath, _relatedPaths) {
443
+ return updateEntry(projectRoot, entryPath, {}, { by: 'system', context: 'updated related entries' });
444
+ }
445
+ /**
446
+ * Creates a new wiki entry and validates its quality.
447
+ * This is a convenience wrapper around createEntry that also runs quality checks.
448
+ * Optionally checks for duplicates before creating.
449
+ *
450
+ * @param projectRoot - The root directory of the project
451
+ * @param options - Options for creating the entry
452
+ * @returns The created WikiEntry, quality issues, and duplicate check result
453
+ * @throws Error if wiki is not initialized
454
+ */
455
+ async function createEntryWithValidation(projectRoot, options) {
456
+ // Check for duplicates unless skipped
457
+ let duplicateCheck;
458
+ if (!options.skipDuplicateCheck) {
459
+ duplicateCheck = await checkDuplicate(projectRoot, options.title, options.tags, options.category);
460
+ }
461
+ const entry = createEntry(projectRoot, options);
462
+ const qualityIssues = (0, quality_js_1.validateEntryQuality)(projectRoot, entry.path);
463
+ return {
464
+ entry,
465
+ qualityIssues,
466
+ duplicateCheck
467
+ };
468
+ }
469
+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C,KAAK;QAAE,OAAO,EAAE,CAAC;IAEtB,uCAAuC;IACvC,IAAI,KAAK,CAAC,WAAW,CAAC,eAAe,IAAI,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtF,OAAO,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC;IAC3C,CAAC;IAED,gCAAgC;IAChC,MAAM,UAAU,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,CAAC;IAClD,OAAO,IAAA,kCAAkB,EAAC,KAAK,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAC/B,WAAmB,EACnB,SAAiB,EACjB,aAAuB;IAEvB,OAAO,WAAW,CAChB,WAAW,EACX,SAAS,EACT,EAAE,EACF,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,yBAAyB,EAAE,CACrD,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,yBAAyB,CAC7C,WAAmB,EACnB,OAA2B;IAE3B,sCAAsC;IACtC,IAAI,cAAgD,CAAC;IACrD,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAChC,cAAc,GAAG,MAAM,cAAc,CACnC,WAAW,EACX,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,QAAQ,CACjB,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,WAAW,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAChD,MAAM,aAAa,GAAG,IAAA,iCAAoB,EAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEpE,OAAO;QACL,KAAK;QACL,aAAa;QACb,cAAc;KACf,CAAC;AACJ,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Custom error classes for Solvdex
3
+ * Provides typed errors with context for better debugging
4
+ */
5
+ /**
6
+ * Base error class for all Solvdex errors
7
+ */
8
+ export declare class SolvdexError extends Error {
9
+ context: Record<string, unknown>;
10
+ constructor(message: string, context?: Record<string, unknown>);
11
+ }
12
+ /**
13
+ * Thrown when wiki operations are attempted on a non-initialized wiki
14
+ */
15
+ export declare class WikiNotInitializedError extends SolvdexError {
16
+ constructor(projectRoot: string);
17
+ }
18
+ /**
19
+ * Thrown when a wiki entry cannot be found
20
+ */
21
+ export declare class EntryNotFoundError extends SolvdexError {
22
+ constructor(entryPath: string, projectRoot: string);
23
+ }
24
+ /**
25
+ * Thrown when validation fails
26
+ */
27
+ export declare class ValidationError extends SolvdexError {
28
+ constructor(message: string, validationErrors: Array<string>);
29
+ }
30
+ /**
31
+ * Thrown when file system operations fail
32
+ */
33
+ export declare class FileSystemError extends SolvdexError {
34
+ constructor(operation: 'read' | 'write' | 'delete' | 'create', filePath: string, originalError: unknown);
35
+ }
36
+ /**
37
+ * Thrown when wiki configuration is invalid or cannot be loaded
38
+ */
39
+ export declare class ConfigError extends SolvdexError {
40
+ constructor(message: string, configPath: string);
41
+ }
42
+ /**
43
+ * Thrown when frontmatter parsing or validation fails
44
+ */
45
+ export declare class FrontmatterError extends SolvdexError {
46
+ constructor(message: string, filePath: string);
47
+ }
48
+ /**
49
+ * Thrown when regex pattern compilation or matching fails
50
+ */
51
+ export declare class RegexError extends SolvdexError {
52
+ constructor(pattern: string, reason: string);
53
+ }
54
+ /**
55
+ * Thrown when cache operations fail
56
+ */
57
+ export declare class CacheError extends SolvdexError {
58
+ constructor(message: string, operation: string);
59
+ }
60
+ /**
61
+ * Helper function to wrap file operations with proper error handling
62
+ * Catches errors and throws FileSystemError with context
63
+ */
64
+ export declare function wrapFileOperation<T>(operation: 'read' | 'write' | 'delete' | 'create', filePath: string, fn: () => T): T;
65
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;G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CAAC,CAMH"}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ /**
3
+ * Custom error classes for Solvdex
4
+ * Provides typed errors with context for better debugging
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.CacheError = exports.RegexError = exports.FrontmatterError = exports.ConfigError = exports.FileSystemError = exports.ValidationError = exports.EntryNotFoundError = exports.WikiNotInitializedError = exports.SolvdexError = void 0;
8
+ exports.wrapFileOperation = wrapFileOperation;
9
+ /**
10
+ * Base error class for all Solvdex errors
11
+ */
12
+ class SolvdexError extends Error {
13
+ context;
14
+ constructor(message, context) {
15
+ super(message);
16
+ this.name = 'SolvdexError';
17
+ this.context = context || {};
18
+ // Maintains proper stack trace for where our error was thrown (only available on V8)
19
+ if (Error.captureStackTrace) {
20
+ Error.captureStackTrace(this, this.constructor);
21
+ }
22
+ }
23
+ }
24
+ exports.SolvdexError = SolvdexError;
25
+ /**
26
+ * Thrown when wiki operations are attempted on a non-initialized wiki
27
+ */
28
+ class WikiNotInitializedError extends SolvdexError {
29
+ constructor(projectRoot) {
30
+ super(`Wiki not initialized at ${projectRoot}`, { projectRoot });
31
+ this.name = 'WikiNotInitializedError';
32
+ }
33
+ }
34
+ exports.WikiNotInitializedError = WikiNotInitializedError;
35
+ /**
36
+ * Thrown when a wiki entry cannot be found
37
+ */
38
+ class EntryNotFoundError extends SolvdexError {
39
+ constructor(entryPath, projectRoot) {
40
+ super(`Entry not found: ${entryPath}`, { entryPath, projectRoot });
41
+ this.name = 'EntryNotFoundError';
42
+ }
43
+ }
44
+ exports.EntryNotFoundError = EntryNotFoundError;
45
+ /**
46
+ * Thrown when validation fails
47
+ */
48
+ class ValidationError extends SolvdexError {
49
+ constructor(message, validationErrors) {
50
+ super(message, { validationErrors });
51
+ this.name = 'ValidationError';
52
+ }
53
+ }
54
+ exports.ValidationError = ValidationError;
55
+ /**
56
+ * Thrown when file system operations fail
57
+ */
58
+ class FileSystemError extends SolvdexError {
59
+ constructor(operation, filePath, originalError) {
60
+ super(`File system ${operation} failed: ${filePath}`, {
61
+ operation,
62
+ filePath,
63
+ originalError,
64
+ });
65
+ this.name = 'FileSystemError';
66
+ }
67
+ }
68
+ exports.FileSystemError = FileSystemError;
69
+ /**
70
+ * Thrown when wiki configuration is invalid or cannot be loaded
71
+ */
72
+ class ConfigError extends SolvdexError {
73
+ constructor(message, configPath) {
74
+ super(message, { configPath });
75
+ this.name = 'ConfigError';
76
+ }
77
+ }
78
+ exports.ConfigError = ConfigError;
79
+ /**
80
+ * Thrown when frontmatter parsing or validation fails
81
+ */
82
+ class FrontmatterError extends SolvdexError {
83
+ constructor(message, filePath) {
84
+ super(message, { filePath });
85
+ this.name = 'FrontmatterError';
86
+ }
87
+ }
88
+ exports.FrontmatterError = FrontmatterError;
89
+ /**
90
+ * Thrown when regex pattern compilation or matching fails
91
+ */
92
+ class RegexError extends SolvdexError {
93
+ constructor(pattern, reason) {
94
+ super(`Regex error: ${reason}`, { pattern, reason });
95
+ this.name = 'RegexError';
96
+ }
97
+ }
98
+ exports.RegexError = RegexError;
99
+ /**
100
+ * Thrown when cache operations fail
101
+ */
102
+ class CacheError extends SolvdexError {
103
+ constructor(message, operation) {
104
+ super(message, { operation });
105
+ this.name = 'CacheError';
106
+ }
107
+ }
108
+ exports.CacheError = CacheError;
109
+ /**
110
+ * Helper function to wrap file operations with proper error handling
111
+ * Catches errors and throws FileSystemError with context
112
+ */
113
+ function wrapFileOperation(operation, filePath, fn) {
114
+ try {
115
+ return fn();
116
+ }
117
+ catch (error) {
118
+ throw new FileSystemError(operation, filePath, error);
119
+ }
120
+ }
121
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgHH,8CAUC;AAxHD;;GAEG;AACH,MAAa,YAAa,SAAQ,KAAK;IACrC,OAAO,CAA0B;IAEjC,YAAY,OAAe,EAAE,OAAiC;QAC5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