fix(npmextra): update to new format

This commit is contained in:
2025-12-13 11:42:39 +00:00
parent f8d0895aab
commit 3b1c84d7e8
18 changed files with 1951 additions and 1801 deletions

View File

@@ -39,13 +39,13 @@ export class ContextCache {
}
// Ensure cache directory exists
await plugins.smartfile.fs.ensureDir(this.cacheDir);
await plugins.fsInstance.directory(this.cacheDir).recursive().create();
// Load cache index if it exists
try {
const indexExists = await plugins.smartfile.fs.fileExists(this.cacheIndexPath);
const indexExists = await plugins.fsInstance.file(this.cacheIndexPath).exists();
if (indexExists) {
const indexContent = await plugins.smartfile.fs.toStringSync(this.cacheIndexPath);
const indexContent = await plugins.fsInstance.file(this.cacheIndexPath).encoding('utf8').read() as string;
const indexData = JSON.parse(indexContent) as ICacheEntry[];
if (Array.isArray(indexData)) {
for (const entry of indexData) {
@@ -278,7 +278,7 @@ export class ContextCache {
try {
const entries = Array.from(this.cache.values());
const content = JSON.stringify(entries, null, 2);
await plugins.smartfile.memory.toFs(content, this.cacheIndexPath);
await plugins.fsInstance.file(this.cacheIndexPath).encoding('utf8').write(content);
} catch (error) {
console.warn('Failed to persist cache index:', error.message);
}