# dsh-commandcode-usage-monitor 项目设施与维护手册 > 本文档按 `codebase-documenter` 思路编写,面向“上游维护 / 快速拾取”场景。 > 它把 README、现有 docs、源码与 DSH 基础编码流程整合成一份可执行的设施手册。 ## 1. 项目元信息 | 项 | 值 | | --- | --- | | 包名 | `dsh-commandcode-usage-monitor` | | 版本 | `0.1.0` | | 类型 | DSH(DeepSeek Harness)组合包 / 插件 | | 定位 | Host 侧抓取 Command Code `/alpha/*` 用量/额度接口,Browser 侧提供侧边栏挂件与设置页仪表盘 | | 运行环境 | Node.js `>=22`、ESM、TypeScript | | 许可证 | MIT | | 发布入口 | npm:`dsh-commandcode-usage-monitor` | | 安装命令 | `dsh plugin --profile web add dsh-commandcode-usage-monitor` | 核心亮点: - Host 侧保守抓取 `/alpha/whoami`、`/alpha/usage/summary`、`/alpha/billing/credits`、`/alpha/billing/subscriptions`。 - Host 内存 `UsageStore` 保存最新快照与每轮消耗,浏览器只读同源 JSON,不接触明文 API Key。 - 浏览器端注册 `sidebar.footer.action` 小挂件与 `settings.section` 设置页,中英双语。 --- ## 2. 完整技术栈 ### 2.1 Host / 后端侧 | 领域 | 技术 | 说明 | | --- | --- | --- | | 运行时 | Node.js `>=22` | ESM,`"type": "module"` | | 语言 | TypeScript `6.x` | `strict`,`moduleResolution: Bundler`,允许 `.ts` 后缀 import | | 插件框架 | `@deepseek-ai/cordis` `^4.0.1` | Cordis 插件/Fiber 生命周期、依赖注入、`ctx.effect` 自动清理 | | 配置 | `@deepseek-ai/schemastery` `^3.18.1` | `Config` interface + 同名 Schema | | 命令 | `@deepseek-ai/dsh-commands` | `/commandcode-usage` 斜杠命令 | | 凭据 | `@deepseek-ai/dsh-credentials` | `ctx.credentials` 可选服务;`credentialRef` | | Web 路由 | `@deepseek-ai/dsh-host-webserver` | `ctx.webServer.register(route)`,`WebRoute` 类型 | | 启动环境 | `@deepseek-ai/dsh-launch-environment` | `launchEnvironmentOf(ctx).get(envName)` | | 设置 | `@deepseek-ai/dsh-settings` | `installSettingsSection` / `settingsNamespace` | | 构建 | `tsc` + `tsdown` | `tsc` 产类型声明到 `lib/types`,`tsdown` 产 Host `/ Browser` bundle | | 测试 | `node:test` + `tsx` | Node 内置 test runner 直接跑 TS | ### 2.2 Browser / 前端侧 | 领域 | 技术 | 说明 | | --- | --- | --- | | UI | React `18` | 函数组件 + hooks | | 客户端基座 | `@deepseek-ai/dsh-client-store` | DSH `0.1.2-alpha.1` 平台模块表中的 store | | 客户端类型 | `@deepseek-ai/cordis` | `ClientContext` 即 `Context` 的类型别名 | | 连接 | `@deepseek-ai/dsh-client-connection` | `ctx.connection` | | 设置 UI | `@deepseek-ai/dsh-client-ui-settings` | `settings.section` 槽位、`SettingsScope`/`SettingsScopeSpec` | | 侧边栏 UI | `@deepseek-ai/dsh-client-ui-sidebar` | `sidebar.footer.action` 槽位 | | 槽位渲染器 | `@deepseek-ai/dsh-client-ui-renderer` | 提供 `ctx.slots` | | 槽位类型 | `@deepseek-ai/dsh-client-ui-slots` | `PropsLocale`、`PropsRuntime`、`InjectFace` | | 多语言 | `@deepseek-ai/dsh-client-locale` | `ctx.locale.register` | > 注:本分支 `0.1.2-comp` 面向 DSH 本地源码 `0.1.2-alpha.1`(`dsh-client-runtime` 已拆为 `dsh-client-store` / `dsh-client-ui-renderer`)。`main` 分支仍面向 npm 发布版 `0.1.1-rc.2`。 | 样式 | CSS Modules + `lightningcss` | 构建期编译 `.module.css`,注入 `