# Profile 管理 [English](boot.md) | 中文 [boot 包组](../../packages/boot/README.zh.md)负责 launcher 提供的 profile 访问与插件管理器。[插件管理器](../../packages/boot/plugin-manager/README.zh.md)文档说明持久化、重载与包操作行为。 ## 管理记录 `PluginEntryId` 标识一个 Loader 条目;调用方从 `listPlugins` 获取,不自行拼接 patch id。 `PluginInfo` 包含模块标识、实际启停状态和 fiber 阶段,以及唯一的 `patchId` 或 `readOnlyReason`。 `BundleInfo` 包含包名、可选的安装版本、组合层选择状态、删除可用性及可选的解析错误。 `InstallBundleOptions.enabled` 默认为 true。False 表示安装但不选择该组合包层。 `ChangeResult.changed` 独立报告磁盘修改,`application` 为 `applied`、`restart-required`、`overridden` 或 `failed`。`message` 描述结果。可选的 `packageResult` 记录 pnpm 退出码、有界输出、截断标记与完整诊断日志路径。 ## Cordis API Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — the language sides differ only in locale-specific paired document paths. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.zh.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md). ### `ctx.hmr` — `Hmr` Hot reload service with Cordis-compatible module configuration and events. ```ts cordis-catalog /** Serialize a caller-owned mutation with all automatic reload paths. * @param operation Work that must not overlap module or configuration replacement. * @returns The operation result after its asynchronous work completes. */ runExclusive(operation: () => Promise): Promise /** Watch a configuration path through the same queue as module replacement. * @param filename Absolute path, which may not exist yet. * @param refresh Rebuilds configuration from its current files and awaits Loader completion. * @returns Disposer closing this registration and waiting for its pending refresh. */ async watchConfig(filename: string, refresh: () => Promise): Promise<() => Promise> /** Read direct module dependency URLs from the active Node loader. * @param url Module URL. * @returns Linked module URLs, or an empty list for an uncached module. */ async getLinked(url: string): Promise ``` Source: [`packages/boot/hmr/src/index.ts`](../../packages/boot/hmr/src/index.ts) ### `ctx.pluginManager` — `PluginManager` Manage profile files and apply their declared reload lifecycle. ```ts cordis-catalog /** Read current plugins, including why a row cannot be changed through the profile patch. * @returns Current runtime entries with persistent patch targets. */ @Remote async listPlugins(): Promise /** Read installed bundles and bundles supplied by this dsh installation. * @returns Package versions, activation selections and removal availability. */ @Remote listBundles(): Promise /** Persist a plugin entry's desired enablement and apply it on live profiles. * @param id Loader entry identity returned by listPlugins. * @param enabled Whether the plugin should run. * @returns Saved and runtime outcomes, including higher-priority overrides. */ @Remote setPluginEnabled(id: PluginEntryId, enabled: boolean): Promise /** Select or remove a bundle layer while retaining installed dependencies. * @param name Bundle package name. * @param enabled Whether the bundle contributes its patch layer. * @returns Persisted and runtime outcomes. */ @Remote setBundleEnabled(name: string, enabled: boolean): Promise /** Install a package using the same pnpm implementation as dsh plugin. * @param spec One package spec, including local paths relative to the invocation directory. * @param options Whether to activate the installed bundle; defaults to true. * @returns Package-manager diagnostics and observed activation outcome. */ @Remote installBundle(spec: string, options?: InstallBundleOptions): Promise /** Unload and remove a profile-owned bundle dependency through dsh plugin's pnpm path. * @param name Installed dependency name. * @returns Removal diagnostics and the remaining profile state. */ @Remote removeBundle(name: string): Promise ``` Source: [`packages/boot/plugin-manager/src/index.ts`](../../packages/boot/plugin-manager/src/index.ts) ### `ctx.profileContext` — `ProfileContext` Current profile facts; scheduling and mutation belong to their callers. Source: [`packages/boot/app-boot/src/profile-context.ts`](../../packages/boot/app-boot/src/profile-context.ts) ### `hmr/*` events #### `hmr/change` — emit A watched file has no module or configuration handler. ```ts cordis-catalog /** A watched file has no module or configuration handler. * @mode emit * @param url Canonical file URL. */ 'hmr/change'(url: string): void ``` Source: [`packages/boot/hmr/src/index.ts`](../../packages/boot/hmr/src/index.ts) #### `hmr/reload` — emit Module replacements have finished loading. ```ts cordis-catalog /** Module replacements have finished loading. * @mode emit * @param reloads Replaced plugins and their module locations. */ 'hmr/reload'(reloads: Map): void ``` Source: [`packages/boot/hmr/src/index.ts`](../../packages/boot/hmr/src/index.ts)