From 76e36e539a05b3e06e42e4ca030fbf33a0e33cc7 Mon Sep 17 00:00:00 2001 From: QQ Date: Wed, 11 Nov 2026 11:07:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20src/index.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 47d5da1..bc99f22 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,8 +13,10 @@ import { CloudClient } from './api.ts' import type { CloudMemoryContext, SessionEventLike, SessionLike } from './context-types.ts' import { Reporter } from './reporter.ts' import { createRoutes } from './routes.ts' -import { SettingsStore } from './store.ts' +import { join } from 'node:path' +import { SettingsStore, dshHome } from './store.ts' import { SkillSync } from './skill-sync.ts' +import { SkillAdmin, skillsHoldingDir, skillsTrashDir } from './skill-admin.ts' import { createMemoryTools, createSkillTools } from './tools.ts' /** Package name; also the client bundle id. */ @@ -24,7 +26,7 @@ export const name = 'dsh-cloud-memory' export const inject = ['webServer'] /** Version reported by the status card. */ -const VERSION = '0.3.0' +const VERSION = '0.4.0' /** How often the skill directory is reconciled with the cloud center. */ const SKILL_SYNC_INTERVAL_MS = 15 * 60_000 @@ -62,6 +64,16 @@ export function apply(ctx: CloudMemoryContext, config: unknown): void { skillsDir: settings().skillsDir, }), log: (message) => logger.info(message), + holdingDir: () => skillsHoldingDir(), + }) + + const skillAdmin = new SkillAdmin({ + skillsRoot: () => skillSync.skillsRoot(), + holdingDir: () => skillsHoldingDir(), + trashDir: () => skillsTrashDir(), + syncStatePath: () => join(dshHome(), 'cloud-memory-skills.json'), + syncRunning: () => skillSync.stats().running, + log: (message) => logger.info(message), }) // Announce at most once per activation so a missing token is obvious in logs. const effective = settings() @@ -111,7 +123,7 @@ export function apply(ctx: CloudMemoryContext, config: unknown): void { if (webServer === undefined) { logger.warn('webServer service unavailable; the configuration page stays disabled') } else { - const routes = createRoutes({ version: VERSION, store, reporter, client: () => client, skills: () => skillSync.stats() }) + const routes = createRoutes({ version: VERSION, store, reporter, client: () => client, skills: () => skillSync.stats(), admin: skillAdmin }) for (const route of routes) { ctx.effect(() => webServer.register(route), `dsh-cloud-memory: route ${route.path}`) }