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.
- package/LICENSE +21 -0
- package/README.md +274 -0
- package/dist/hooks/error-lookup.d.ts +4 -0
- package/dist/hooks/error-lookup.d.ts.map +1 -0
- package/dist/hooks/error-lookup.js +92 -0
- package/dist/hooks/error-lookup.js.map +1 -0
- package/dist/hooks/post-task.d.ts +15 -0
- package/dist/hooks/post-task.d.ts.map +1 -0
- package/dist/hooks/post-task.js +246 -0
- package/dist/hooks/post-task.js.map +1 -0
- package/dist/hooks/prompt-enrich.d.ts +16 -0
- package/dist/hooks/prompt-enrich.d.ts.map +1 -0
- package/dist/hooks/prompt-enrich.js +141 -0
- package/dist/hooks/prompt-enrich.js.map +1 -0
- package/dist/hooks/session-start-cli.d.ts +3 -0
- package/dist/hooks/session-start-cli.d.ts.map +1 -0
- package/dist/hooks/session-start-cli.js +81 -0
- package/dist/hooks/session-start-cli.js.map +1 -0
- package/dist/hooks/session-start.d.ts +4 -0
- package/dist/hooks/session-start.d.ts.map +1 -0
- package/dist/hooks/session-start.js +134 -0
- package/dist/hooks/session-start.js.map +1 -0
- package/dist/src/audit.d.ts +63 -0
- package/dist/src/audit.d.ts.map +1 -0
- package/dist/src/audit.js +229 -0
- package/dist/src/audit.js.map +1 -0
- package/dist/src/cache.d.ts +54 -0
- package/dist/src/cache.d.ts.map +1 -0
- package/dist/src/cache.js +167 -0
- package/dist/src/cache.js.map +1 -0
- package/dist/src/config.d.ts +52 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +175 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/entry.d.ts +154 -0
- package/dist/src/entry.d.ts.map +1 -0
- package/dist/src/entry.js +469 -0
- package/dist/src/entry.js.map +1 -0
- package/dist/src/errors.d.ts +65 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +121 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/frontmatter.d.ts +28 -0
- package/dist/src/frontmatter.d.ts.map +1 -0
- package/dist/src/frontmatter.js +111 -0
- package/dist/src/frontmatter.js.map +1 -0
- package/dist/src/index.d.ts +35 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +188 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/maturity.d.ts +31 -0
- package/dist/src/maturity.d.ts.map +1 -0
- package/dist/src/maturity.js +96 -0
- package/dist/src/maturity.js.map +1 -0
- package/dist/src/quality.d.ts +23 -0
- package/dist/src/quality.d.ts.map +1 -0
- package/dist/src/quality.js +236 -0
- package/dist/src/quality.js.map +1 -0
- package/dist/src/search.d.ts +35 -0
- package/dist/src/search.d.ts.map +1 -0
- package/dist/src/search.js +263 -0
- package/dist/src/search.js.map +1 -0
- package/dist/src/similarity.d.ts +42 -0
- package/dist/src/similarity.d.ts.map +1 -0
- package/dist/src/similarity.js +111 -0
- package/dist/src/similarity.js.map +1 -0
- package/dist/src/stats.d.ts +56 -0
- package/dist/src/stats.d.ts.map +1 -0
- package/dist/src/stats.js +198 -0
- package/dist/src/stats.js.map +1 -0
- package/dist/src/templates.d.ts +63 -0
- package/dist/src/templates.d.ts.map +1 -0
- package/dist/src/templates.js +347 -0
- package/dist/src/templates.js.map +1 -0
- package/dist/src/transfer.d.ts +92 -0
- package/dist/src/transfer.d.ts.map +1 -0
- package/dist/src/transfer.js +215 -0
- package/dist/src/transfer.js.map +1 -0
- package/dist/src/types.d.ts +270 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +153 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/validate.d.ts +90 -0
- package/dist/src/validate.d.ts.map +1 -0
- package/dist/src/validate.js +295 -0
- package/dist/src/validate.js.map +1 -0
- package/hooks/error-lookup.ts +110 -0
- package/hooks/hooks.json +49 -0
- package/hooks/post-task.ts +309 -0
- package/hooks/prompt-enrich.ts +162 -0
- package/hooks/session-start-cli.ts +96 -0
- package/hooks/session-start.ts +159 -0
- package/package.json +40 -0
- package/scripts/error-lookup.py +64 -0
- package/scripts/post-task.py +60 -0
- package/scripts/prompt-enrich.py +64 -0
- package/scripts/session-start.py +64 -0
- package/skills/wiki/SKILL.md +61 -0
- package/skills/wiki-add/SKILL.md +90 -0
- package/skills/wiki-browse/SKILL.md +108 -0
- package/skills/wiki-capture/SKILL.md +265 -0
- package/skills/wiki-explorer/SKILL.md +223 -0
- package/skills/wiki-export/SKILL.md +101 -0
- package/skills/wiki-fix/SKILL.md +86 -0
- package/skills/wiki-flag/SKILL.md +47 -0
- package/skills/wiki-import/SKILL.md +128 -0
- package/skills/wiki-init/SKILL.md +72 -0
- package/skills/wiki-scan/SKILL.md +98 -0
- package/skills/wiki-search/SKILL.md +86 -0
- package/skills/wiki-stats/SKILL.md +129 -0
- package/skills/wiki-status/SKILL.md +78 -0
- package/skills/wiki-test-trigger/SKILL.md +173 -0
- package/skills/wiki-validate/SKILL.md +62 -0
|
@@ -0,0 +1,229 @@
|
|
|
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.logAudit = logAudit;
|
|
37
|
+
exports.readAuditLog = readAuditLog;
|
|
38
|
+
exports.getEntryAuditHistory = getEntryAuditHistory;
|
|
39
|
+
exports.generateAuditReport = generateAuditReport;
|
|
40
|
+
// src/audit.ts
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const config_js_1 = require("./config.js");
|
|
44
|
+
const entry_js_1 = require("./entry.js");
|
|
45
|
+
const errors_js_1 = require("./errors.js");
|
|
46
|
+
const AUDIT_LOG_FILE = 'audit.log';
|
|
47
|
+
/**
|
|
48
|
+
* Returns the path to the audit log file.
|
|
49
|
+
*
|
|
50
|
+
* @param projectRoot - The root directory of the project
|
|
51
|
+
* @returns The path to the audit.log file
|
|
52
|
+
*/
|
|
53
|
+
function getAuditLogPath(projectRoot) {
|
|
54
|
+
return path.join((0, config_js_1.getWikiPath)(projectRoot), AUDIT_LOG_FILE);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Formats a date as YYYY-MM-DD HH:MM.
|
|
58
|
+
*
|
|
59
|
+
* @param date - The date to format
|
|
60
|
+
* @returns Formatted date string
|
|
61
|
+
*/
|
|
62
|
+
function formatTimestamp(date = new Date()) {
|
|
63
|
+
const year = date.getFullYear();
|
|
64
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
65
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
66
|
+
const hours = String(date.getHours()).padStart(2, '0');
|
|
67
|
+
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
68
|
+
return `${year}-${month}-${day} ${hours}:${minutes}`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Pads an action to a fixed width for consistent log formatting.
|
|
72
|
+
*
|
|
73
|
+
* @param action - The action to pad
|
|
74
|
+
* @returns Padded action string
|
|
75
|
+
*/
|
|
76
|
+
function padAction(action) {
|
|
77
|
+
return action.padEnd(10);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Parses a single audit log line into an AuditLogEntry.
|
|
81
|
+
*
|
|
82
|
+
* @param line - The log line to parse
|
|
83
|
+
* @returns Parsed AuditLogEntry or null if invalid
|
|
84
|
+
*/
|
|
85
|
+
function parseLogLine(line) {
|
|
86
|
+
const trimmedLine = line.trim();
|
|
87
|
+
if (!trimmedLine) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const parts = trimmedLine.split(' | ');
|
|
91
|
+
if (parts.length < 4) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
const [timestamp, actionRaw, entryPath, byPart] = parts;
|
|
95
|
+
const action = actionRaw.trim();
|
|
96
|
+
// Parse the "by" part which may contain details after a colon
|
|
97
|
+
const colonIndex = byPart.indexOf(':');
|
|
98
|
+
let by;
|
|
99
|
+
let details;
|
|
100
|
+
if (colonIndex !== -1) {
|
|
101
|
+
by = byPart.substring(0, colonIndex).trim();
|
|
102
|
+
details = byPart.substring(colonIndex + 1).trim();
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
by = byPart.trim();
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
timestamp: timestamp.trim(),
|
|
109
|
+
action,
|
|
110
|
+
entryPath: entryPath.trim(),
|
|
111
|
+
by,
|
|
112
|
+
details: details || undefined
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Logs an audit action to the audit log file.
|
|
117
|
+
*
|
|
118
|
+
* @param projectRoot - The root directory of the project
|
|
119
|
+
* @param action - The audit action (created, updated, validated, flagged, deprecated)
|
|
120
|
+
* @param entryPath - The path to the entry being audited
|
|
121
|
+
* @param by - Who performed the action (e.g., "user", "claude", "auto-capture")
|
|
122
|
+
* @param details - Optional additional details about the action
|
|
123
|
+
*/
|
|
124
|
+
function logAudit(projectRoot, action, entryPath, by, details) {
|
|
125
|
+
const logPath = getAuditLogPath(projectRoot);
|
|
126
|
+
const timestamp = formatTimestamp();
|
|
127
|
+
const paddedAction = padAction(action);
|
|
128
|
+
// Format: YYYY-MM-DD HH:MM | action | entryPath | by: details
|
|
129
|
+
let logLine = `${timestamp} | ${paddedAction} | ${entryPath} | ${by}`;
|
|
130
|
+
if (details) {
|
|
131
|
+
logLine += `: ${details}`;
|
|
132
|
+
}
|
|
133
|
+
logLine += '\n';
|
|
134
|
+
// Ensure the wiki directory exists
|
|
135
|
+
const wikiPath = (0, config_js_1.getWikiPath)(projectRoot);
|
|
136
|
+
if (!fs.existsSync(wikiPath)) {
|
|
137
|
+
(0, errors_js_1.wrapFileOperation)('create', wikiPath, () => fs.mkdirSync(wikiPath, { recursive: true }));
|
|
138
|
+
}
|
|
139
|
+
// Append to the log file
|
|
140
|
+
(0, errors_js_1.wrapFileOperation)('write', logPath, () => fs.appendFileSync(logPath, logLine, 'utf-8'));
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Reads audit log entries from the audit log file.
|
|
144
|
+
*
|
|
145
|
+
* @param projectRoot - The root directory of the project
|
|
146
|
+
* @param options - Optional filters (limit, entryPath)
|
|
147
|
+
* @returns Array of AuditLogEntry objects, most recent first
|
|
148
|
+
*/
|
|
149
|
+
function readAuditLog(projectRoot, options = {}) {
|
|
150
|
+
const logPath = getAuditLogPath(projectRoot);
|
|
151
|
+
if (!fs.existsSync(logPath)) {
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
const content = (0, errors_js_1.wrapFileOperation)('read', logPath, () => fs.readFileSync(logPath, 'utf-8'));
|
|
155
|
+
const lines = content.split('\n');
|
|
156
|
+
const entries = [];
|
|
157
|
+
for (const line of lines) {
|
|
158
|
+
const entry = parseLogLine(line);
|
|
159
|
+
if (entry) {
|
|
160
|
+
// Apply entryPath filter if specified
|
|
161
|
+
if (options.entryPath && entry.entryPath !== options.entryPath) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
entries.push(entry);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// Sort by timestamp, most recent first
|
|
168
|
+
entries.sort((a, b) => b.timestamp.localeCompare(a.timestamp));
|
|
169
|
+
// Apply limit if specified
|
|
170
|
+
if (options.limit && options.limit > 0) {
|
|
171
|
+
return entries.slice(0, options.limit);
|
|
172
|
+
}
|
|
173
|
+
return entries;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Gets the audit history for a specific wiki entry.
|
|
177
|
+
*
|
|
178
|
+
* @param projectRoot - The root directory of the project
|
|
179
|
+
* @param entryPath - The path to the entry
|
|
180
|
+
* @returns Array of AuditLogEntry objects for the entry, most recent first
|
|
181
|
+
*/
|
|
182
|
+
function getEntryAuditHistory(projectRoot, entryPath) {
|
|
183
|
+
return readAuditLog(projectRoot, { entryPath });
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Generates an audit summary report for the wiki.
|
|
187
|
+
*
|
|
188
|
+
* @param projectRoot - The root directory of the project
|
|
189
|
+
* @returns AuditReport with stats and recent activity
|
|
190
|
+
*/
|
|
191
|
+
async function generateAuditReport(projectRoot) {
|
|
192
|
+
// Get all entries for counting
|
|
193
|
+
const allEntries = await (0, entry_js_1.listEntries)(projectRoot);
|
|
194
|
+
const totalEntries = allEntries.length;
|
|
195
|
+
const activeCount = allEntries.filter(e => e.frontmatter.status === 'active').length;
|
|
196
|
+
const flaggedCount = allEntries.filter(e => e.frontmatter.status === 'flagged').length;
|
|
197
|
+
const deprecatedCount = allEntries.filter(e => e.frontmatter.status === 'deprecated').length;
|
|
198
|
+
// Get all audit log entries
|
|
199
|
+
const auditEntries = readAuditLog(projectRoot);
|
|
200
|
+
// Calculate last 7 days activity
|
|
201
|
+
const sevenDaysAgo = new Date();
|
|
202
|
+
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
|
|
203
|
+
const sevenDaysAgoStr = formatTimestamp(sevenDaysAgo);
|
|
204
|
+
const last7DaysActivity = {
|
|
205
|
+
created: 0,
|
|
206
|
+
updated: 0,
|
|
207
|
+
validated: 0,
|
|
208
|
+
flagged: 0,
|
|
209
|
+
deprecated: 0,
|
|
210
|
+
maturity_promoted: 0
|
|
211
|
+
};
|
|
212
|
+
for (const entry of auditEntries) {
|
|
213
|
+
// Compare timestamps (YYYY-MM-DD HH:MM format allows string comparison)
|
|
214
|
+
if (entry.timestamp >= sevenDaysAgoStr) {
|
|
215
|
+
last7DaysActivity[entry.action]++;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// Get recent activity (last 10 entries)
|
|
219
|
+
const recentActivity = auditEntries.slice(0, 10);
|
|
220
|
+
return {
|
|
221
|
+
totalEntries,
|
|
222
|
+
activeCount,
|
|
223
|
+
flaggedCount,
|
|
224
|
+
deprecatedCount,
|
|
225
|
+
last7DaysActivity,
|
|
226
|
+
recentActivity
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/audit.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+HA,4BA8BC;AASD,oCAqCC;AASD,o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,MAAM,CAAC;IACvF,MAAM,eAAe,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,KAAK,YAAY,CAAC,CAAC,MAAM,CAAC;IAE7F,4BAA4B;IAC5B,MAAM,YAAY,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;IAE/C,iCAAiC;IACjC,MAAM,YAAY,GAAG,IAAI,IAAI,EAAE,CAAC;IAChC,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IACjD,MAAM,eAAe,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;IAEtD,MAAM,iBAAiB,GAAgC;QACrD,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,SAAS,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC;QACV,UAAU,EAAE,CAAC;QACb,iBAAiB,EAAE,CAAC;KACrB,CAAC;IAEF,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE,CAAC;QACjC,wEAAwE;QACxE,IAAI,KAAK,CAAC,SAAS,IAAI,eAAe,EAAE,CAAC;YACvC,iBAAiB,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QACpC,CAAC;IACH,CAAC;IAED,wCAAwC;IACxC,MAAM,cAAc,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEjD,OAAO;QACL,YAAY;QACZ,WAAW;QACX,YAAY;QACZ,eAAe;QACf,iBAAiB;QACjB,cAAc;KACf,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LRU cache for WikiEntry objects with mtime validation
|
|
3
|
+
*
|
|
4
|
+
* Provides in-memory caching with:
|
|
5
|
+
* - LRU eviction when cache reaches max size (500 entries)
|
|
6
|
+
* - TTL expiration (5 minutes)
|
|
7
|
+
* - File modification time validation
|
|
8
|
+
* - Graceful error handling (non-critical, never throws)
|
|
9
|
+
*/
|
|
10
|
+
import type { WikiEntry } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Cache statistics for monitoring
|
|
13
|
+
*/
|
|
14
|
+
interface CacheStats {
|
|
15
|
+
size: number;
|
|
16
|
+
maxSize: number;
|
|
17
|
+
hits: number;
|
|
18
|
+
misses: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Gets cached entry if valid (exists, not expired, mtime matches)
|
|
22
|
+
* Returns null if cache miss, expired, or file modified
|
|
23
|
+
* Moves entry to end of Map for LRU tracking
|
|
24
|
+
*
|
|
25
|
+
* @param fullPath - Absolute file path
|
|
26
|
+
* @returns Cached WikiEntry or null
|
|
27
|
+
*/
|
|
28
|
+
export declare function getCachedEntry(fullPath: string): WikiEntry | null;
|
|
29
|
+
/**
|
|
30
|
+
* Adds entry to cache with current timestamp and mtime
|
|
31
|
+
* Evicts LRU entry if cache is full (500+ entries)
|
|
32
|
+
*
|
|
33
|
+
* @param fullPath - Absolute file path
|
|
34
|
+
* @param entry - WikiEntry to cache
|
|
35
|
+
*/
|
|
36
|
+
export declare function setCachedEntry(fullPath: string, entry: WikiEntry): void;
|
|
37
|
+
/**
|
|
38
|
+
* Removes specific entry from cache
|
|
39
|
+
*
|
|
40
|
+
* @param fullPath - Absolute file path
|
|
41
|
+
*/
|
|
42
|
+
export declare function invalidateCache(fullPath: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Removes all entries from cache
|
|
45
|
+
*/
|
|
46
|
+
export declare function clearCache(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Gets cache statistics for monitoring and debugging
|
|
49
|
+
*
|
|
50
|
+
* @returns Cache statistics including size, hits, and misses
|
|
51
|
+
*/
|
|
52
|
+
export declare function getCacheStats(): CacheStats;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAe5C;;GAEG;AACH,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AASD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAuDjE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAwCvE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAWtD;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAajC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAO1C"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LRU cache for WikiEntry objects with mtime validation
|
|
4
|
+
*
|
|
5
|
+
* Provides in-memory caching with:
|
|
6
|
+
* - LRU eviction when cache reaches max size (500 entries)
|
|
7
|
+
* - TTL expiration (5 minutes)
|
|
8
|
+
* - File modification time validation
|
|
9
|
+
* - Graceful error handling (non-critical, never throws)
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getCachedEntry = getCachedEntry;
|
|
13
|
+
exports.setCachedEntry = setCachedEntry;
|
|
14
|
+
exports.invalidateCache = invalidateCache;
|
|
15
|
+
exports.clearCache = clearCache;
|
|
16
|
+
exports.getCacheStats = getCacheStats;
|
|
17
|
+
const node_fs_1 = require("node:fs");
|
|
18
|
+
const errors_js_1 = require("./errors.js");
|
|
19
|
+
const MAX_CACHE_SIZE = 500;
|
|
20
|
+
const MAX_CACHE_AGE_MS = 300000; // 5 minutes
|
|
21
|
+
// In-memory cache storage (Map maintains insertion order for LRU)
|
|
22
|
+
const cache = new Map();
|
|
23
|
+
// Statistics tracking
|
|
24
|
+
let cacheHits = 0;
|
|
25
|
+
let cacheMisses = 0;
|
|
26
|
+
/**
|
|
27
|
+
* Gets cached entry if valid (exists, not expired, mtime matches)
|
|
28
|
+
* Returns null if cache miss, expired, or file modified
|
|
29
|
+
* Moves entry to end of Map for LRU tracking
|
|
30
|
+
*
|
|
31
|
+
* @param fullPath - Absolute file path
|
|
32
|
+
* @returns Cached WikiEntry or null
|
|
33
|
+
*/
|
|
34
|
+
function getCachedEntry(fullPath) {
|
|
35
|
+
try {
|
|
36
|
+
const cached = cache.get(fullPath);
|
|
37
|
+
if (!cached) {
|
|
38
|
+
cacheMisses++;
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const now = Date.now();
|
|
42
|
+
// Check TTL expiration
|
|
43
|
+
if (now - cached.timestamp > MAX_CACHE_AGE_MS) {
|
|
44
|
+
cache.delete(fullPath);
|
|
45
|
+
cacheMisses++;
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
// Check file modification time
|
|
49
|
+
let currentMtime;
|
|
50
|
+
try {
|
|
51
|
+
const stats = (0, node_fs_1.statSync)(fullPath);
|
|
52
|
+
currentMtime = stats.mtimeMs;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
// File may have been deleted or is inaccessible
|
|
56
|
+
cache.delete(fullPath);
|
|
57
|
+
cacheMisses++;
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
if (currentMtime !== cached.mtime) {
|
|
61
|
+
// File has been modified since caching
|
|
62
|
+
cache.delete(fullPath);
|
|
63
|
+
cacheMisses++;
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
// Valid cache hit - move to end for LRU tracking
|
|
67
|
+
// Note: delete + re-set is required to move entry to end of Map's insertion order
|
|
68
|
+
// This is the standard pattern for LRU caching with JavaScript Maps
|
|
69
|
+
cache.delete(fullPath);
|
|
70
|
+
cache.set(fullPath, cached);
|
|
71
|
+
cacheHits++;
|
|
72
|
+
return cached.entry;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
// Non-critical error - log and return null for graceful degradation
|
|
76
|
+
const err = new errors_js_1.CacheError(`Failed to get cached entry: ${error instanceof Error ? error.message : String(error)}`, 'get');
|
|
77
|
+
console.warn(`[Cache Warning] ${err.message}`, err.context);
|
|
78
|
+
cacheMisses++;
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Adds entry to cache with current timestamp and mtime
|
|
84
|
+
* Evicts LRU entry if cache is full (500+ entries)
|
|
85
|
+
*
|
|
86
|
+
* @param fullPath - Absolute file path
|
|
87
|
+
* @param entry - WikiEntry to cache
|
|
88
|
+
*/
|
|
89
|
+
function setCachedEntry(fullPath, entry) {
|
|
90
|
+
try {
|
|
91
|
+
// Get current file mtime
|
|
92
|
+
let mtime;
|
|
93
|
+
try {
|
|
94
|
+
const stats = (0, node_fs_1.statSync)(fullPath);
|
|
95
|
+
mtime = stats.mtimeMs;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
// Cannot cache if file is inaccessible
|
|
99
|
+
const err = new errors_js_1.CacheError(`Cannot cache entry - file stat failed: ${error instanceof Error ? error.message : String(error)}`, 'set');
|
|
100
|
+
console.warn(`[Cache Warning] ${err.message}`, err.context);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
// Evict LRU entry if cache is full
|
|
104
|
+
if (cache.size >= MAX_CACHE_SIZE) {
|
|
105
|
+
// Map.keys() returns in insertion order, first key is LRU
|
|
106
|
+
const firstKey = cache.keys().next().value;
|
|
107
|
+
if (firstKey !== undefined) {
|
|
108
|
+
cache.delete(firstKey);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Add new entry to cache (at end of Map)
|
|
112
|
+
cache.set(fullPath, {
|
|
113
|
+
entry,
|
|
114
|
+
mtime,
|
|
115
|
+
timestamp: Date.now()
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
// Non-critical error - log and continue without caching
|
|
120
|
+
const err = new errors_js_1.CacheError(`Failed to set cached entry: ${error instanceof Error ? error.message : String(error)}`, 'set');
|
|
121
|
+
console.warn(`[Cache Warning] ${err.message}`, err.context);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Removes specific entry from cache
|
|
126
|
+
*
|
|
127
|
+
* @param fullPath - Absolute file path
|
|
128
|
+
*/
|
|
129
|
+
function invalidateCache(fullPath) {
|
|
130
|
+
try {
|
|
131
|
+
cache.delete(fullPath);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
// Non-critical error - log and continue
|
|
135
|
+
const err = new errors_js_1.CacheError(`Failed to invalidate cache entry: ${error instanceof Error ? error.message : String(error)}`, 'invalidate');
|
|
136
|
+
console.warn(`[Cache Warning] ${err.message}`, err.context);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Removes all entries from cache
|
|
141
|
+
*/
|
|
142
|
+
function clearCache() {
|
|
143
|
+
try {
|
|
144
|
+
cache.clear();
|
|
145
|
+
cacheHits = 0;
|
|
146
|
+
cacheMisses = 0;
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
// Non-critical error - log and continue
|
|
150
|
+
const err = new errors_js_1.CacheError(`Failed to clear cache: ${error instanceof Error ? error.message : String(error)}`, 'clear');
|
|
151
|
+
console.warn(`[Cache Warning] ${err.message}`, err.context);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Gets cache statistics for monitoring and debugging
|
|
156
|
+
*
|
|
157
|
+
* @returns Cache statistics including size, hits, and misses
|
|
158
|
+
*/
|
|
159
|
+
function getCacheStats() {
|
|
160
|
+
return {
|
|
161
|
+
size: cache.size,
|
|
162
|
+
maxSize: MAX_CACHE_SIZE,
|
|
163
|
+
hits: cacheHits,
|
|
164
|
+
misses: cacheMisses
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/cache.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AA2CH,wCAuDC;AASD,wCAwCC;AAOD,0CAWC;AAKD,gCAaC;AAOD,sCAOC;AAnMD,qCAAmC;AAEnC,2CAAyC;AAEzC,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,gBAAgB,GAAG,MAAM,CAAC,CAAC,YAAY;AAqB7C,kEAAkE;AAClE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;AAE7C,sBAAsB;AACtB,IAAI,SAAS,GAAG,CAAC,CAAC;AAClB,IAAI,WAAW,GAAG,CAAC,CAAC;AAEpB;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,QAAgB;IAC7C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAEnC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,WAAW,EAAE,CAAC;YACd,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,uBAAuB;QACvB,IAAI,GAAG,GAAG,MAAM,CAAC,SAAS,GAAG,gBAAgB,EAAE,CAAC;YAC9C,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACvB,WAAW,EAAE,CAAC;YACd,OAAO,IAAI,CAAC;QACd,CAAC;QAED,+BAA+B;QAC/B,IAAI,YAAoB,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,KAAK,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C,IAAI,CAAC;QACH,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,wCAAwC;QACxC,MAAM,GAAG,GAAG,IAAI,sBAAU,CACxB,qCAAqC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAC7F,YAAY,CACb,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,mBAAmB,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU;IACxB,IAAI,CAAC;QACH,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,SAAS,GAAG,CAAC,CAAC;QACd,WAAW,GAAG,CAAC,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,wCAAwC;QACxC,MAAM,GAAG,GAAG,IAAI,sBAAU,CACxB,0BAA0B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAClF,OAAO,CACR,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,mBAAmB,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,aAAa;IAC3B,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,cAAc;QACvB,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,WAAW;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { WikiConfig } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get the default confidence level for a category.
|
|
4
|
+
* Returns 80 (HIGH) for gotchas, 50 (MEDIUM) for everything else.
|
|
5
|
+
* @param category - The category name
|
|
6
|
+
* @returns The default confidence level (0-100) for that category
|
|
7
|
+
*/
|
|
8
|
+
export declare function getDefaultConfidence(category: string): number;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the default configuration for a new wiki project.
|
|
11
|
+
* @param projectName - The name of the project
|
|
12
|
+
* @returns Default WikiConfig with all standard settings
|
|
13
|
+
*/
|
|
14
|
+
export declare function getDefaultConfig(projectName: string): WikiConfig;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the path to the .wiki directory for a project.
|
|
17
|
+
* @param projectRoot - The root directory of the project
|
|
18
|
+
* @returns The path to the .wiki directory
|
|
19
|
+
*/
|
|
20
|
+
export declare function getWikiPath(projectRoot: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the path to the wiki config file.
|
|
23
|
+
* @param projectRoot - The root directory of the project
|
|
24
|
+
* @returns The path to the .wiki-config.yaml file
|
|
25
|
+
*/
|
|
26
|
+
export declare function getConfigPath(projectRoot: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Checks if a wiki has been initialized for the project.
|
|
29
|
+
* @param projectRoot - The root directory of the project
|
|
30
|
+
* @returns True if the .wiki directory exists
|
|
31
|
+
*/
|
|
32
|
+
export declare function wikiExists(projectRoot: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Reads the wiki configuration from the project.
|
|
35
|
+
* @param projectRoot - The root directory of the project
|
|
36
|
+
* @returns The WikiConfig if it exists, or null if not
|
|
37
|
+
*/
|
|
38
|
+
export declare function readConfig(projectRoot: string): WikiConfig | null;
|
|
39
|
+
/**
|
|
40
|
+
* Writes the wiki configuration to the project.
|
|
41
|
+
* @param projectRoot - The root directory of the project
|
|
42
|
+
* @param config - The WikiConfig to write
|
|
43
|
+
*/
|
|
44
|
+
export declare function writeConfig(projectRoot: string, config: WikiConfig): void;
|
|
45
|
+
/**
|
|
46
|
+
* Adds a new category to the wiki configuration.
|
|
47
|
+
* @param projectRoot - The root directory of the project
|
|
48
|
+
* @param category - The category name to add
|
|
49
|
+
* @throws Error if the wiki is not initialized
|
|
50
|
+
*/
|
|
51
|
+
export declare function addCategory(projectRoot: string, category: string): void;
|
|
52
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAkC,MAAM,YAAY,CAAC;AAKxE;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE7D;AAGD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU,CAgChE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAmBjE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAezE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAUvE"}
|