remove stale native tasks on marketplace sync

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-22 17:55:14 +00:00
co-authored by Claude Opus 4.6
parent b3f1d10bc1
commit 039ea7ae71
3 changed files with 19 additions and 2 deletions
+8 -1
View File
@@ -2,7 +2,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { DATA_PATH } from './data-path';
import { parseSeedVersion } from './sync-version';
import { upsertNativeTask } from 'officerdb';
import { upsertNativeTask, deleteNativeTasksNotIn } from 'officerdb';
const MARKETPLACE_URL = process.env.MARKETPLACE_URL ?? 'https://marketplace.officer.dev';
const GLOBAL_TOOLS_DIR = join(DATA_PATH, 'tools');
@@ -169,6 +169,13 @@ export async function syncMarketplaceTasks(): Promise<void> {
console.log(`[marketplace] Synced task: ${task.dirName} (v${task.version})`);
}
// Delete native tasks that no longer exist in the marketplace
const activeDirNames = allTasks.map((t) => t.dirName);
const deleted = await deleteNativeTasksNotIn(activeDirNames);
for (const row of deleted) {
console.log(`[marketplace] Removed task: ${row.dirName}`);
}
} catch (err) {
console.error('[marketplace] Failed to sync tasks:', err instanceof Error ? err.message : err);
}