更新 lib/index.js
This commit is contained in:
parent
498e617494
commit
e0aa005e58
38
lib/index.js
38
lib/index.js
|
|
@ -16,13 +16,17 @@ import { join } from 'node:path';
|
|||
import { SettingsStore, dshHome } from "./store.js";
|
||||
import { SkillSync, skillsStatePath } from "./skill-sync.js";
|
||||
import { SkillAdmin, skillsHoldingDir } from "./skill-admin.js";
|
||||
import { SkillGroupManager, detectSources } from "./skill-groups.js";
|
||||
import { ClaudePluginMarketplaceProvider, MarketService } from "./market.js";
|
||||
import { SkillUpdater } from "./skill-update.js";
|
||||
import { ClientRegistry } from "./clients.js";
|
||||
import { createMemoryTools, createSkillTools } from "./tools.js";
|
||||
/** Package name; also the client bundle id. */
|
||||
export const name = 'dsh-brain';
|
||||
/** Services required before `apply` runs. */
|
||||
export const inject = ['webServer'];
|
||||
/** Version reported by the status card. */
|
||||
const VERSION = '0.5.1';
|
||||
const VERSION = '0.8.0';
|
||||
/** How often the skill directory is reconciled with the cloud center. */
|
||||
const SKILL_SYNC_INTERVAL_MS = 15 * 60_000;
|
||||
/** How often queued reports are retried. */
|
||||
|
|
@ -63,6 +67,34 @@ export function apply(ctx, config) {
|
|||
syncRunning: () => skillSync.stats().running,
|
||||
log: (message) => logger.info(message),
|
||||
});
|
||||
// The tree's sources are detected per call so a directory created while the
|
||||
// process runs shows up on the next refresh.
|
||||
const skillGroups = new SkillGroupManager({
|
||||
sources: () => detectSources(),
|
||||
admin: skillAdmin,
|
||||
log: (message) => logger.info(message),
|
||||
});
|
||||
// One verified market source to start with: the Claude Code plugin marketplace
|
||||
// manifest that Anthropic publishes. Entry ids never carry a URL, so the card
|
||||
// cannot make the host fetch an arbitrary repository.
|
||||
const market = new MarketService([
|
||||
new ClaudePluginMarketplaceProvider({
|
||||
id: 'anthropic-skills',
|
||||
label: 'Anthropic Agent Skills',
|
||||
description: 'Anthropic 公开的 Claude 技能市场(.claude-plugin/marketplace.json)',
|
||||
repo: 'anthropics/skills',
|
||||
ref: 'main',
|
||||
}),
|
||||
]);
|
||||
const updater = new SkillUpdater({
|
||||
admin: skillAdmin,
|
||||
skillsRoot: () => skillSync.skillsRoot(),
|
||||
holdingDir: () => skillsHoldingDir(),
|
||||
syncRunning: () => skillSync.stats().running,
|
||||
log: (message) => logger.info(message),
|
||||
});
|
||||
// Cross-software / workspace inventory. Read-only for every client except DSH.
|
||||
const clients = new ClientRegistry();
|
||||
// Announce at most once per activation so a missing token is obvious in logs.
|
||||
const effective = settings();
|
||||
if (!effective.enabled) {
|
||||
|
|
@ -106,8 +138,8 @@ export function apply(ctx, config) {
|
|||
logger.warn('webServer service unavailable; the configuration page stays disabled');
|
||||
}
|
||||
else {
|
||||
const routes = createRoutes({ version: VERSION, store, reporter, client: () => client, skills: () => skillSync.stats(), admin: skillAdmin });
|
||||
routes.push(...createLegacyRoutes({ version: VERSION, store, reporter, client: () => client, skills: () => skillSync.stats(), admin: skillAdmin }));
|
||||
const routes = createRoutes({ version: VERSION, store, reporter, client: () => client, skills: () => skillSync.stats(), admin: skillAdmin, groups: skillGroups, market, sync: skillSync, updates: updater, clients });
|
||||
routes.push(...createLegacyRoutes({ version: VERSION, store, reporter, client: () => client, skills: () => skillSync.stats(), admin: skillAdmin, groups: skillGroups, market, sync: skillSync, updates: updater, clients }));
|
||||
for (const route of routes) {
|
||||
ctx.effect(() => webServer.register(route), `dsh-brain: route ${route.path}`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue