tools system - web-fetch

This commit is contained in:
2026-02-24 00:06:32 +00:00
parent 2126f3912e
commit 071e2decc3
8 changed files with 561 additions and 4 deletions
+33
View File
@@ -0,0 +1,33 @@
import { readdirSync, existsSync, mkdirSync, cpSync } from 'node:fs';
import { join } from 'node:path';
import { SEED_PATH, DATA_PATH } from './data-path';
const SEED_EXTENSIONS_DIR = join(SEED_PATH, 'extensions');
const GLOBAL_EXTENSIONS_DIR = join(DATA_PATH, 'extensions');
export function syncSeedExtensions(): void {
if (!existsSync(SEED_EXTENSIONS_DIR)) return;
mkdirSync(GLOBAL_EXTENSIONS_DIR, { recursive: true });
const seedEntries = readdirSync(SEED_EXTENSIONS_DIR, { withFileTypes: true });
for (const entry of seedEntries) {
if (!entry.isDirectory()) continue;
const seedExtensionDir = join(SEED_EXTENSIONS_DIR, entry.name);
const entryFile = join(seedExtensionDir, 'index.ts');
if (!existsSync(entryFile)) continue;
const targetDir = join(GLOBAL_EXTENSIONS_DIR, entry.name);
if (existsSync(targetDir)) {
// Extension already exists in DATA_PATH — always overwrite (managed by us, not the user)
cpSync(seedExtensionDir, targetDir, { recursive: true });
continue;
}
cpSync(seedExtensionDir, targetDir, { recursive: true });
console.log(`[extensions] Synced seed extension: ${entry.name}`);
}
}