dsh-plugin 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.en.md +5 -5
  2. package/README.md +5 -5
  3. package/client/client.js +4772 -1659
  4. package/client/client.js.map +1 -1
  5. package/lib/http/routes.js +451 -28
  6. package/lib/index.js +5 -1
  7. package/lib/services/{install-types.js → install/install-types.js} +8 -2
  8. package/lib/services/install/install.js +4 -0
  9. package/lib/services/install/npm-check.js +55 -0
  10. package/lib/services/{npm-resolve.js → install/npm-resolve.js} +11 -5
  11. package/lib/services/{preflight.js → install/preflight.js} +23 -7
  12. package/lib/services/{task-queue.js → install/task-queue.js} +166 -71
  13. package/lib/services/loader.js +60 -1
  14. package/lib/services/log.js +138 -0
  15. package/lib/services/probe.js +157 -0
  16. package/lib/services/{installed-versions.js → profile/installed-versions.js} +5 -1
  17. package/lib/services/{pending-restart.js → profile/pending-restart.js} +1 -1
  18. package/lib/services/{profile.js → profile/profile.js} +59 -4
  19. package/lib/services/{progress.js → profile/progress.js} +4 -0
  20. package/lib/services/settings.js +60 -0
  21. package/lib/types/http/routes.d.ts +1 -1
  22. package/lib/types/index.d.ts +5 -1
  23. package/lib/types/services/{install-types.d.ts → install/install-types.d.ts} +13 -4
  24. package/lib/types/services/{install.d.ts → install/install.d.ts} +9 -5
  25. package/lib/types/services/install/npm-check.d.ts +12 -0
  26. package/lib/types/services/{npm-resolve.d.ts → install/npm-resolve.d.ts} +2 -1
  27. package/lib/types/services/{task-queue.d.ts → install/task-queue.d.ts} +5 -1
  28. package/lib/types/services/loader.d.ts +14 -4
  29. package/lib/types/services/log.d.ts +49 -0
  30. package/lib/types/services/probe.d.ts +30 -0
  31. package/lib/types/services/{pending-restart.d.ts → profile/pending-restart.d.ts} +9 -3
  32. package/lib/types/services/{profile.d.ts → profile/profile.d.ts} +6 -2
  33. package/lib/types/services/{progress.d.ts → profile/progress.d.ts} +4 -0
  34. package/lib/types/services/settings.d.ts +24 -0
  35. package/package.json +1 -1
  36. package/src/client/components/PluginHubSection.tsx +346 -121
  37. package/src/client/components/{CatalogList.tsx → catalog/CatalogList.tsx} +15 -7
  38. package/src/client/components/{PluginCard.tsx → catalog/PluginCard.tsx} +10 -5
  39. package/src/client/components/layout/CatalogControls.tsx +80 -0
  40. package/src/client/components/{CatalogHeader.tsx → layout/CatalogHeader.tsx} +8 -4
  41. package/src/client/components/{CategoryTabs.tsx → layout/CategoryTabs.tsx} +7 -3
  42. package/src/client/components/layout/SectionTabs.tsx +60 -0
  43. package/src/client/components/{AboutModal.tsx → modals/AboutModal.tsx} +11 -7
  44. package/src/client/components/{HubUpdateModal.tsx → modals/HubUpdateModal.tsx} +9 -5
  45. package/src/client/components/modals/InstalledDetailModal.tsx +193 -0
  46. package/src/client/components/modals/LogsModal.tsx +301 -0
  47. package/src/client/components/modals/LogsPathModal.tsx +161 -0
  48. package/src/client/components/{NotificationsModal.tsx → modals/NotificationsModal.tsx} +51 -20
  49. package/src/client/components/{ProgressView.tsx → modals/ProgressView.tsx} +6 -2
  50. package/src/client/components/{modals.tsx → modals/modals.tsx} +121 -40
  51. package/src/client/components/{Dropdown.tsx → ui/Dropdown.tsx} +18 -6
  52. package/src/client/components/ui/Toggle.tsx +28 -0
  53. package/src/client/components/ui/icons.tsx +343 -0
  54. package/src/client/components/views/CustomInstallView.tsx +250 -0
  55. package/src/client/components/views/DiagnosticsView.tsx +172 -0
  56. package/src/client/components/views/InstalledView.tsx +328 -0
  57. package/src/client/components/views/LogsView.tsx +150 -0
  58. package/src/client/components/views/MarketView.tsx +66 -0
  59. package/src/client/components/views/SettingsView.tsx +273 -0
  60. package/src/client/data/catalog.ts +38 -0
  61. package/src/client/data/host.ts +107 -0
  62. package/src/client/data/hub.ts +41 -0
  63. package/src/client/hooks/useCatalog.ts +77 -117
  64. package/src/client/hooks/useIncrementalList.ts +46 -0
  65. package/src/client/hooks/useLanguage.ts +40 -0
  66. package/src/client/hooks/useSettings.ts +90 -0
  67. package/src/client/hooks/useTaskQueue.ts +168 -47
  68. package/src/client/index.tsx +4 -0
  69. package/src/client/locales.ts +365 -39
  70. package/src/client/logic/constants.ts +87 -0
  71. package/src/client/{lib → logic}/failures.ts +99 -74
  72. package/src/client/{lib → logic}/format.ts +4 -0
  73. package/src/client/logic/install-command.ts +56 -0
  74. package/src/client/logic/installed.ts +207 -0
  75. package/src/client/logic/normalize.ts +52 -0
  76. package/src/client/{lib → logic}/renderMarkdown.ts +4 -0
  77. package/src/client/logic/urls.ts +125 -0
  78. package/src/client/styles/CustomInstallView.module.css +191 -0
  79. package/src/client/styles/DiagnosticsView.module.css +231 -0
  80. package/src/client/styles/Dropdown.module.css +46 -41
  81. package/src/client/styles/Header.module.css +105 -133
  82. package/src/client/styles/InstalledView.module.css +447 -0
  83. package/src/client/styles/List.module.css +11 -1
  84. package/src/client/styles/LogsView.module.css +503 -0
  85. package/src/client/styles/Modal.module.css +357 -71
  86. package/src/client/styles/SectionTabs.module.css +142 -0
  87. package/src/client/styles/SettingsView.module.css +232 -0
  88. package/src/client/styles/Toggle.module.css +60 -0
  89. package/src/client/styles/tokens.module.css +6 -1
  90. package/src/client/types.ts +28 -4
  91. package/src/server/http/routes.ts +426 -28
  92. package/src/server/index.ts +5 -1
  93. package/src/server/services/{install-types.ts → install/install-types.ts} +13 -5
  94. package/src/server/services/{install.ts → install/install.ts} +9 -5
  95. package/src/server/services/install/npm-check.ts +53 -0
  96. package/src/server/services/{npm-resolve.ts → install/npm-resolve.ts} +11 -5
  97. package/src/server/services/{preflight.ts → install/preflight.ts} +24 -7
  98. package/src/server/services/{task-queue.ts → install/task-queue.ts} +168 -68
  99. package/src/server/services/loader.ts +59 -1
  100. package/src/server/services/log.ts +167 -0
  101. package/src/server/services/probe.ts +157 -0
  102. package/src/server/services/{installed-versions.ts → profile/installed-versions.ts} +5 -1
  103. package/src/server/services/{pending-restart.ts → profile/pending-restart.ts} +9 -3
  104. package/src/server/services/{profile.ts → profile/profile.ts} +58 -4
  105. package/src/server/services/{progress.ts → profile/progress.ts} +4 -0
  106. package/src/server/services/settings.ts +79 -0
  107. package/lib/services/install.js +0 -4
  108. package/src/client/components/CatalogControls.tsx +0 -104
  109. package/src/client/components/icons.tsx +0 -125
  110. package/src/client/lib/catalog.ts +0 -272
  111. package/src/client/lib/env.ts +0 -16
  112. /package/lib/types/services/{preflight.d.ts → install/preflight.d.ts} +0 -0
  113. /package/lib/types/services/{installed-versions.d.ts → profile/installed-versions.d.ts} +0 -0
@@ -1,7 +1,3 @@
1
- /**
2
- * 运行中 loader 的读取与停用:卸载成功后对匹配条目做 live-disable,
3
- * 使卸载立即生效(刷新页面不再加载已卸载的 client bundle,也无需重启)。
4
- */
5
1
  /**
6
2
  * 运行中 loader 的最小接口:卸载成功后即时移除条目用。
7
3
  * 对应官方 `ctx.loader`(cordis-plugin-loader 的 Loader 服务)的读取面与移除面。
@@ -31,6 +27,12 @@ export declare function dumpLoaderEntries(loader: LoaderHandle | undefined): Arr
31
27
  id: string;
32
28
  name?: string;
33
29
  }>;
30
+ /**
31
+ * 判断某 npm 包名是否已加载进运行中 loader(宽匹配:条目名存在别名变体)。
32
+ * 官方 `ctx.loader.entries()` 遍历整棵树(reference.md §1.3),条目名 == 插件作者声明的名字。
33
+ * 安装完成但未重启时条目不在 loader → 返回 false,UI 据此标「待重启/未加载」。
34
+ */
35
+ export declare function isEntryLoaded(loader: LoaderHandle | undefined, name: string): boolean;
34
36
  /**
35
37
  * 卸载成功后从运行中 loader 停用指定包的条目。做法:按 name 扫描
36
38
  * `loader.entries()`(含嵌套子树),对每个匹配条目
@@ -43,3 +45,11 @@ export declare function dumpLoaderEntries(loader: LoaderHandle | undefined): Arr
43
45
  * 宿主关键包(@deepseek-ai/* 与本插件自身)一律跳过。
44
46
  */
45
47
  export declare function removeLoadedEntry(loader: LoaderHandle, name: string): Promise<boolean>;
48
+ /**
49
+ * 判断某已安装包是否是真正的 dsh 插件(宿主会加载 / 值得提示「待重启」):
50
+ * 1) 包名已写进 profile 的 `dsh.profile.bundles`(宿主启动时按清单加载);
51
+ * 2) 或包内 package.json 声明了 dsh 配置(`dsh.bundle` / `dsh.profile` 等)或 dsh 相关 keywords。
52
+ * 两者都满足不了(如 GitHub 官方示例仓库 octocat/Hello-World)说明它不是 dsh 插件,
53
+ * 装上也不会被宿主加载——UI 据此不再提示「待重启」,避免误导用户反复重启一个不会生效的东西。
54
+ */
55
+ export declare function isDshPlugin(profile: string, name: string): boolean;
@@ -0,0 +1,49 @@
1
+ export type LogCategory = 'install' | 'uninstall' | 'update' | 'diagnostics' | 'settings' | 'system';
2
+ export type LogLevel = 'debug' | 'info' | 'success' | 'warn' | 'error';
3
+ export interface LogEntry {
4
+ /** 毫秒时间戳 */
5
+ at: number;
6
+ level: LogLevel;
7
+ category: LogCategory;
8
+ /** 机器可读事件码,如 install.start / settings.update */
9
+ event: string;
10
+ /** 人类可读描述 */
11
+ message: string;
12
+ }
13
+ /** 日志保留上限:超过后在读取时裁剪为最近 MAX_LOG_LINES 条 */
14
+ export declare const MAX_LOG_LINES = 2000;
15
+ export interface ReadLogOptions {
16
+ /** 分页偏移(过滤后倒序) */
17
+ offset?: number;
18
+ limit?: number;
19
+ category?: LogCategory | 'all';
20
+ level?: LogLevel | 'all';
21
+ /** 关键词:大小写不敏感,匹配事件码或描述 */
22
+ query?: string;
23
+ }
24
+ export interface ReadLogResult {
25
+ /** 倒序(最新在前) */
26
+ entries: LogEntry[];
27
+ /** 过滤后的总条数(分页前) */
28
+ total: number;
29
+ }
30
+ /**
31
+ * 把用户填写的日志位置覆盖解析成实际文件路径:
32
+ * 以 .log 结尾视为文件本身,否则视为目录并在其中写 hub.log;相对路径按当前目录归一化。
33
+ */
34
+ export declare function customLogFile(override: string): string;
35
+ /**
36
+ * 真正默认的日志文件路径:`~/.dsh/profiles/<profile>/hub.log`(不受设置覆盖影响)。
37
+ * 弹窗「恢复默认」、目录选择器起点等需要「未自定义时的位置」都从这里取 ——
38
+ * 不同机器/平台(用户主目录不同)这个值都不同,必须动态计算而非写死。
39
+ */
40
+ export declare function defaultLogFilePath(profile: string): string;
41
+ /**
42
+ * 当前生效的日志文件路径:设置里填了 logPath 用自定义位置(目录或文件),
43
+ * 否则默认 `~/.dsh/profiles/<profile>/hub.log`。默认位置永远合法可用,无需用户干预。
44
+ */
45
+ export declare function logFilePath(profile: string): string;
46
+ /** 追加一条系统日志(JSONL 一行一条)。 */
47
+ export declare function appendLog(profile: string, entry: LogEntry): void;
48
+ /** 读取系统日志(按时间正序,最新在末尾),超上限就地裁剪;支持过滤与分页。 */
49
+ export declare function readLog(profile: string, opts?: ReadLogOptions): ReadLogResult;
@@ -0,0 +1,30 @@
1
+ export interface ProbeResult {
2
+ /** 是否可达(HTTP 状态码 100–399) */
3
+ ok: boolean;
4
+ /** 毫秒耗时;失败为 null */
5
+ ms: number | null;
6
+ /** HTTP 状态码;失败为 null */
7
+ status: number | null;
8
+ }
9
+ /**
10
+ * 操作系统级代理(macOS 系统网络设置 / Windows Internet 设置)。
11
+ * Node 内置 http(s) 不读系统代理,浏览器挂的代理 Node 看不见 —— 这里读出来
12
+ * 作为默认代理,保证「浏览器能开、安装/诊断就能通」。
13
+ * Linux 没有统一的系统代理入口,返回 null(交给环境变量 / 设置里的代理)。
14
+ */
15
+ export declare function systemProxy(): string | null;
16
+ /**
17
+ * 探测一个 HTTPS 目标:proxy 非空注入给 curl 子进程走代理,否则直连。
18
+ * 供系统诊断 /diagnostics 使用;目标 URL 非法返回不可达。
19
+ */
20
+ export declare function probeUrl(url: string, proxy: string, timeoutMs: number): Promise<ProbeResult>;
21
+ /**
22
+ * curl 子进程抓取响应体(与 probeUrl 同一套代理 env 注入)。
23
+ * 供服务端 /catalog 代理路由使用:目录/统计数据经此拉到服务端再转给浏览器,
24
+ * 使「目录数据请求走设置里的代理」与 npm / git 安装通道口径一致。
25
+ * 失败(curl 不存在 / 连接失败 / 超时 / 非零退出)时 ok=false,全程不抛错。
26
+ */
27
+ export declare function fetchViaCurl(url: string, proxy: string, timeoutMs: number): Promise<{
28
+ ok: boolean;
29
+ body: string;
30
+ }>;
@@ -1,9 +1,15 @@
1
- /** 待重启列表的内存态管理(宿主进程一重启自然清空)。 */
2
- import type { PendingRestart } from './install-types.ts';
1
+ /**
2
+ * DSH-Plugin Hub — the community plugin marketplace for DeepSeek Harness.
3
+ * Website: https://dsh-plugin.org
4
+ * GitHub: https://github.com/dshplugin/dsh-plugin-hub
5
+ *
6
+ * 待重启列表的内存态管理(宿主进程一重启自然清空)。
7
+ */
8
+ import type { PendingRestart } from '../install/install-types.ts';
3
9
  /**
4
10
  * 登记一条待重启记录(同一目标去重)。
5
11
  * - 卸载:目标刚装完未重启(已有待重启记录)→ 宿主从未加载过它,卸完磁盘已干净、
6
- * loader 无残留,无需再提醒重启,直接移除该条;否则(此前已被宿主加载过)登记「卸载后待重启清理」。
12
+ * loader 无残留,无需再提醒重启,直接移除该条;否则(已被宿主加载过)登记「卸载后待重启清理」。
7
13
  * - 安装:已有记录则刷新为安装语义(如卸载后未重启又重装),否则新登记。
8
14
  */
9
15
  export declare function addPendingRestart(target: string, kind: 'install' | 'uninstall'): void;
@@ -2,13 +2,17 @@
2
2
  export declare function readProfileArg(fallback?: string): string;
3
3
  /** Resolve a profile directory (`DSH_HOME` or `~/.dsh`). */
4
4
  export declare function profileDirectory(profile: string): string;
5
- /** Build a safe `github:<owner>/<repo>` target, or null when the repo is unsafe. */
5
+ /** Build a safe explicit HTTPS Git target, or null when the repo is unsafe. */
6
6
  export declare function githubTarget(repo: string): string | null;
7
+ export declare function installTargetOf(value: string): string;
8
+ export declare function globalNpmPackagesOf(value: string): string[] | null;
9
+ /** Extract an owner/repo identity from a catalog value or an installed Git spec. */
10
+ export declare function githubRepoOf(value: string): string | null;
7
11
  /** Validate an npm package name (uninstall target grammar). */
8
12
  export declare function validPackageName(name: string): boolean;
9
13
  /**
10
14
  * The exact `allowBuilds` key pnpm printed in its
11
- * `ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED` hint. For `github:` installs pnpm
15
+ * `ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED` hint. For Git installs pnpm
12
16
  * matches against `name@<resolved fetch URL>` — the URL it actually fetches,
13
17
  * e.g. `https://codeload.github.com/<owner>/<repo>/tar.gz/<commit>` — not the
14
18
  * `git+ssh://`/branch spec. A bare name or a `git+` spec does not match, so
@@ -1,4 +1,8 @@
1
1
  /**
2
+ * DSH-Plugin Hub — the community plugin marketplace for DeepSeek Harness.
3
+ * Website: https://dsh-plugin.org
4
+ * GitHub: https://github.com/dshplugin/dsh-plugin-hub
5
+ *
2
6
  * Pure progress-estimation helpers shared by the install runner.
3
7
  *
4
8
  * The dsh CLI wraps pnpm, which refreshes its `Progress: …` line in place
@@ -0,0 +1,24 @@
1
+ export interface HubSettings {
2
+ /** 启动时检查目录插件更新,发现可更新时在通知中心提示(安装不自动进行) */
3
+ checkUpdatesOnStart: boolean;
4
+ /** npm 镜像源 registry 地址(空串 = 官方 https://registry.npmjs.org) */
5
+ npmRegistry: string;
6
+ /** HTTP(S) 代理地址,用于 npm / git / 目录请求(空串 = 直连) */
7
+ proxy: string;
8
+ /** 启用命令行安装 NPM 包(默认开;关掉后输入 npm 包名安装被拦截) */
9
+ enableNpmInstall: boolean;
10
+ /** 启用命令行安装 GitHub 源码(默认开;关掉后输入 GitHub 地址安装被拦截) */
11
+ enableGitInstall: boolean;
12
+ /** 启用命令行粘贴 dsh plugin 命令安装(默认开;关掉后命令输入被禁用) */
13
+ enableDshInstall: boolean;
14
+ /** 日志存放位置覆盖(空串 = 默认 ~/.dsh/profiles/<profile>/hub.log;可填目录或 .log 文件路径) */
15
+ logPath: string;
16
+ }
17
+ export declare const DEFAULT_SETTINGS: HubSettings;
18
+ export declare function settingsFile(profile: string): string;
19
+ /** 读取当前 profile 的设置;文件缺失/损坏时回退默认值(只读路径绝不抛错)。 */
20
+ export declare function loadSettings(profile: string): HubSettings;
21
+ /** 合并并持久化设置(部分更新),返回合并后的完整设置。 */
22
+ export declare function saveSettings(profile: string, patch: Partial<HubSettings>): HubSettings;
23
+ /** 重置为默认设置:删除设置文件,下次读取全部回退默认值(陈旧/白名单外键一并清除)。 */
24
+ export declare function resetSettings(profile: string): HubSettings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "A community plugin marketplace for DeepSeek Harness, built to the official plugin spec — browse, search and install 4000+ human-curated community plugins without leaving the app. · DeepSeek Harness 社区插件市场(遵循官方开发规范):4000+ 人工精选社区插件,每日更新。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",