dsh-config-manager 0.1.37 → 0.1.38

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 (38) hide show
  1. package/lib/client.d.ts +173 -1
  2. package/lib/client.js +2247 -906
  3. package/lib/client.js.map +1 -1
  4. package/lib/index.js +175 -1
  5. package/lib/index.js.map +1 -1
  6. package/lib/market/git-file-writer.d.ts +86 -0
  7. package/lib/market/git-file-writer.js +269 -0
  8. package/lib/market/git-file-writer.js.map +1 -0
  9. package/lib/market/github-repos.d.ts +122 -0
  10. package/lib/market/github-repos.js +407 -0
  11. package/lib/market/github-repos.js.map +1 -0
  12. package/lib/market/my-repo.d.ts +131 -0
  13. package/lib/market/my-repo.js +389 -0
  14. package/lib/market/my-repo.js.map +1 -0
  15. package/lib/ui/i18n.d.ts +9 -0
  16. package/lib/ui/i18n.js +19 -0
  17. package/lib/ui/i18n.js.map +1 -1
  18. package/package.json +1 -1
  19. package/src/client/ConfigManagerSection.tsx +2 -2
  20. package/src/client/client-types.ts +2 -0
  21. package/src/client/index.ts +4 -2
  22. package/src/client/market/MarketPanel.tsx +66 -7
  23. package/src/client/market/MyConfigsView.tsx +745 -0
  24. package/src/client/market/market-api.test.ts +29 -0
  25. package/src/client/market/market-api.ts +5 -2
  26. package/src/client/market/market-locales.ts +118 -0
  27. package/src/client/market/my-configs-api.ts +163 -0
  28. package/src/client/market/my-configs-view.test.ts +289 -0
  29. package/src/client/market/my-configs-view.ts +304 -0
  30. package/src/client/run-store.ts +13 -0
  31. package/src/index.ts +163 -1
  32. package/src/market/git-file-writer.test.ts +249 -0
  33. package/src/market/git-file-writer.ts +336 -0
  34. package/src/market/github-repos.test.ts +400 -0
  35. package/src/market/github-repos.ts +481 -0
  36. package/src/market/my-repo.test.ts +472 -0
  37. package/src/market/my-repo.ts +516 -0
  38. package/src/ui/i18n.ts +19 -0
package/lib/client.d.ts CHANGED
@@ -527,6 +527,15 @@ declare const uiZh: {
527
527
  readonly 'marketPublish.repoWhitespace': "仓库地址不能包含空白字符";
528
528
  readonly 'marketPublish.repoScheme': "仓库地址必须为 http(s) 链接";
529
529
  readonly 'marketPublish.repoUserinfo': "仓库地址不能包含用户名或密码(userinfo);凭据请通过 DSH credentials 提供";
530
+ readonly 'myConfigs.autoField': "系统自动";
531
+ readonly 'myConfigs.field.id': "条目 ID";
532
+ readonly 'myConfigs.field.author': "作者";
533
+ readonly 'myConfigs.field.version': "版本";
534
+ readonly 'myConfigs.field.updatedAt': "更新时间";
535
+ readonly 'myConfigs.status.notListed': "未收录";
536
+ readonly 'myConfigs.status.pendingPr': "PR 待审核";
537
+ readonly 'myConfigs.status.listed': "已收录";
538
+ readonly 'myConfigs.form.errorName': "名称不能为空";
530
539
  };
531
540
  type UiTextKey = keyof typeof uiZh;
532
541
  /** UI 翻译函数:key → 当前语言文案({param} 插值;未知键回退 zh/键名)。 */
@@ -1166,8 +1175,11 @@ declare class MarketApi {
1166
1175
  /** 浏览内置市场(合并 index + 本地缓存状态 → 条目列表带 cacheState) */
1167
1176
  browse(): Promise<MarketBrowseResponse>;
1168
1177
  /** 下载 + 校验单条目(dry-run 预览:拉取 → §6 校验 → analyzeImport → createImportPlan)。
1178
+ * repo 可选:条目来源仓库(作者自托管)。自托管条目(官方 index 带 repo 引用、或「我的配置」
1179
+ * 未收录条目)内容文件在作者自己的公开仓库,必须显式传 repo 才能从正确来源拉取;
1180
+ * 缺省 = 市场仓库(官方同仓条目)。
1169
1181
  * 真正落盘由用户对预览确认后走现有 executeImportPlan(confirm:true 安全阀 + 回滚)。 */
1170
- download(itemId: string): Promise<MarketDownloadResult>;
1182
+ download(itemId: string, repo?: string): Promise<MarketDownloadResult>;
1171
1183
  /** 发布向导:由「上传 zip + 用户填写元数据」生成市场条目包(L2 manifest + SHA-256 + sections),
1172
1184
  * 供 UI 展示/复制与引导推送。零写入配置(发布目录在受控临时区);不含任何凭据字段。 */
1173
1185
  prepare(payload: MarketPreparePayload): Promise<MarketPrepareResponse>;
@@ -1175,6 +1187,104 @@ declare class MarketApi {
1175
1187
  downloadPublishUrl(zipPath: string): string;
1176
1188
  }
1177
1189
  //#endregion
1190
+ //#region src/market/my-repo.d.ts
1191
+ /** 条目收录状态:未收录(本地独有)| PR 待审核(带 PR 链接)| 已收录(官方市场 index 含该 id) */
1192
+ type MyItemStatus = 'not-listed' | 'pr-pending' | 'listed';
1193
+ /** 上传表单:仅用户填写的描述性内容;id/author/version/updatedAt/repoUrl 全自动 */
1194
+ interface MyRepoForm {
1195
+ /** 配置名(预填 zip 文件名,可改);id 由其派生稳定 slug */
1196
+ name: string;
1197
+ description?: string;
1198
+ categories?: string[];
1199
+ }
1200
+ /** upload / update 返回(ok=false 时携带已脱敏 error + errorCode) */
1201
+ interface UploadResult {
1202
+ ok: boolean;
1203
+ itemId: string;
1204
+ version: string;
1205
+ sha256: string;
1206
+ sections: SectionId[];
1207
+ /** 用户公开仓库 URL(https://github.com/<login>/dsh-configs) */
1208
+ repoUrl: string;
1209
+ prNumber: number | null;
1210
+ prUrl: string | null;
1211
+ warnings: string[];
1212
+ /** ok=false 时:可展示错误(已脱敏,无 token 形态) */
1213
+ error?: string;
1214
+ /** ok=false 时:错误分类码(unauthorized/prepare_failed/...;无则 'internal') */
1215
+ errorCode?: string;
1216
+ }
1217
+ /** listItems 条目:用户仓库 index.json 条目 + 收录状态 */
1218
+ interface MyItemEntry {
1219
+ id: string;
1220
+ name: string;
1221
+ version?: string;
1222
+ description?: string;
1223
+ author?: string;
1224
+ updatedAt?: string;
1225
+ categories?: string[];
1226
+ status: MyItemStatus;
1227
+ /** status=pr-pending 时:PR 链接 */
1228
+ prUrl?: string;
1229
+ /** 用户公开仓库 URL */
1230
+ repoUrl: string;
1231
+ }
1232
+ //#endregion
1233
+ //#region src/client/market/my-configs-api.d.ts
1234
+ /**
1235
+ * POST /me/status 响应:登录态 + 用户配置仓库状态(设计文档 §4.2)。
1236
+ * 仅非敏感展示位:login 用户名可回显;token 值永不回传浏览器。
1237
+ */
1238
+ interface MyMeStatusResponse {
1239
+ loggedIn: boolean;
1240
+ /** GitHub 登录名(展示 @login 用) */
1241
+ login?: string;
1242
+ /** 用户自己的配置仓库 URL(无则尚未创建) */
1243
+ repoUrl?: string;
1244
+ /** 配置仓库是否已存在(false = 尚未创建过) */
1245
+ repoExists?: boolean;
1246
+ }
1247
+ /**
1248
+ * 一键上传/更新请求体中的表单(设计文档 §2.4 用户输入最小化):
1249
+ * 仅 name(必填,预填 zip 文件名可改)/ description(可选)/ categories(可选);
1250
+ * id / author / version / updatedAt 全部系统自动生成,不在表单里。
1251
+ * categories 为数组(UI 层先经 parseCategories 解析逗号分隔文本)。
1252
+ * **与 Host 半 my-repo.ts 的 MyRepoForm 同构**(对齐导出,避免漂移)。
1253
+ */
1254
+ type MyConfigsFormPayload = MyRepoForm;
1255
+ /**
1256
+ * POST /me/upload | /me/update 响应(**对齐 host 半 my-repo.ts 的 UploadResult**)。
1257
+ * ok=false 时 itemId/version/sha256 可为空串,warnings/error/errorCode 携带可展示信息(已脱敏)。
1258
+ */
1259
+ type MyUploadResult = UploadResult;
1260
+ /** POST /me/items 响应:用户仓库的全部条目(空仓库 → 空数组)。
1261
+ * 条目 = Host 侧 MyItemEntry(含收录状态 status + prUrl + repoUrl,§4.5 在 Host 判定)。 */
1262
+ interface MyItemsResponse {
1263
+ items: MyItemEntry[];
1264
+ }
1265
+ /**
1266
+ * 「我的配置」浏览器半数据入口(MarketPanel 的「我的配置」子视图注入业务面)。
1267
+ * 登录(GitHub device flow)不在此类 —— 复用 SyncApi.githubStart/githubPoll/githubCancel。
1268
+ */
1269
+ declare class MyConfigsApi {
1270
+ readonly t: UiT;
1271
+ constructor(t?: UiT);
1272
+ /** 读取登录态 + 用户配置仓库状态(token 失效 → Host 返回 401/未登录,UI 引导重新登录) */
1273
+ meStatus(): Promise<MyMeStatusResponse>;
1274
+ /** 一键上传:校验 → 建/复用仓库 → 写入用户仓库 → fork → 改官方 index → 提收录 PR */
1275
+ meUpload(payload: {
1276
+ zipPath: string;
1277
+ form: MyConfigsFormPayload;
1278
+ }): Promise<MyUploadResult>;
1279
+ /** 读取已上传条目列表(用户仓库 index.json;每条目含 Host 侧判定的收录状态) */
1280
+ meItems(): Promise<MyItemsResponse>;
1281
+ /** 一键更新:version 自动 +1,复用/重开收录 PR */
1282
+ meUpdate(payload: {
1283
+ zipPath: string;
1284
+ form: MyConfigsFormPayload;
1285
+ }): Promise<MyUploadResult>;
1286
+ }
1287
+ //#endregion
1178
1288
  //#region src/client/client-types.d.ts
1179
1289
  /** 本插件 Client 半的注入业务面:每个 settings.section 注册项都拿到同一个 api 实例 */
1180
1290
  interface ConfigManagerSectionInjected {
@@ -1185,6 +1295,8 @@ interface ConfigManagerSectionInjected {
1185
1295
  syncT: import('@deepseek-ai/dsh-client-ui-slots').TranslateNS<'config-manager-sync'>;
1186
1296
  /** 配置市场 API(备份与迁移页第 5 个 tab 使用,主 section 注册时注入) */
1187
1297
  marketApi: MarketApi;
1298
+ /** 「我的配置」API(MarketPanel 的「我的配置」子视图使用,主 section 注册时注入) */
1299
+ myConfigsApi: MyConfigsApi;
1188
1300
  /** 配置市场 locale(config-manager-market 命名空间,主 section 注册时注入) */
1189
1301
  marketT: import('@deepseek-ai/dsh-client-ui-slots').TranslateNS<'config-manager-market'>;
1190
1302
  }
@@ -1618,6 +1730,62 @@ declare const zh: {
1618
1730
  readonly 'publish.submit.repoMissing': "收录引用需要托管仓库 URL——请先在上一步「生成条目包」中填写。";
1619
1731
  readonly 'publish.copied': "已复制";
1620
1732
  readonly 'publish.copyFailed': "复制失败,请手动选择文本复制";
1733
+ readonly 'myconfigs.tab.browse': "浏览市场";
1734
+ readonly 'myconfigs.tab.myconfigs': "我的配置";
1735
+ readonly 'myconfigs.back': "返回市场";
1736
+ readonly 'myconfigs.login.title': "GitHub 登录";
1737
+ readonly 'myconfigs.login.hint': "登录后即可一键上传配置到你的公开仓库(自动创建 <login>/dsh-configs)并提交官方市场收录(目标仓库固定,不可修改)。";
1738
+ readonly 'myconfigs.login.checking': "正在检查登录状态…";
1739
+ readonly 'myconfigs.login.loggedInAs': "已登录:{login}";
1740
+ readonly 'myconfigs.login.targetRepo': "收录目标(固定):{repo}";
1741
+ readonly 'myconfigs.login.repoMissing': "配置仓库尚未创建,首次上传将自动创建(公开)";
1742
+ readonly 'myconfigs.login.repoReady': "配置仓库:{repo}";
1743
+ readonly 'myconfigs.login.start': "使用 GitHub 登录";
1744
+ readonly 'myconfigs.login.relogin': "重新登录";
1745
+ readonly 'myconfigs.login.cancel': "取消登录";
1746
+ readonly 'myconfigs.login.userCode': "一次性代码:{code}";
1747
+ readonly 'myconfigs.login.openAuth': "打开授权页";
1748
+ readonly 'myconfigs.upload.title': "一键上传";
1749
+ readonly 'myconfigs.upload.selectHint': "选择导出的配置 zip(先在「导出」tab 生成备份文件,再回到这里选择)。市场通道永不携带秘密——包含密钥的备份将被拒绝。";
1750
+ readonly 'myconfigs.upload.select': "选择 ZIP…";
1751
+ readonly 'myconfigs.upload.reselect': "重新选择";
1752
+ readonly 'myconfigs.upload.selected': "已选择:{name}";
1753
+ readonly 'myconfigs.upload.validate': "开始校验";
1754
+ readonly 'myconfigs.upload.validating': "校验中…";
1755
+ readonly 'myconfigs.upload.validateOk': "校验通过:内容合法、不含密钥";
1756
+ readonly 'myconfigs.upload.validateSecrets': "包含密钥:市场通道永不携带秘密,拒绝上传";
1757
+ readonly 'myconfigs.upload.validateInvalid': "内容校验未通过,无法上传";
1758
+ readonly 'myconfigs.upload.form.title': "条目信息";
1759
+ readonly 'myconfigs.upload.form.name': "名称";
1760
+ readonly 'myconfigs.upload.form.nameHint': "预填 zip 文件名,可修改";
1761
+ readonly 'myconfigs.upload.form.description': "描述(可选)";
1762
+ readonly 'myconfigs.upload.form.categories': "类别(可选,逗号分隔)";
1763
+ readonly 'myconfigs.upload.form.autoHint': "以下字段由系统自动生成:";
1764
+ readonly 'myconfigs.upload.run': "一键上传";
1765
+ readonly 'myconfigs.upload.running': "上传中…";
1766
+ readonly 'myconfigs.update.title': "更新配置";
1767
+ readonly 'myconfigs.update.hint': "版本将自动 +1,已预填原条目信息(名称可改)。";
1768
+ readonly 'myconfigs.update.run': "一键更新";
1769
+ readonly 'myconfigs.update.running': "更新中…";
1770
+ readonly 'myconfigs.result.title': "上传/更新完成";
1771
+ readonly 'myconfigs.result.version': "版本 {version}";
1772
+ readonly 'myconfigs.result.sha256': "SHA-256:{hash}";
1773
+ readonly 'myconfigs.result.sections': "分区:{sections}";
1774
+ readonly 'myconfigs.result.repo': "配置仓库";
1775
+ readonly 'myconfigs.result.openRepo': "打开仓库";
1776
+ readonly 'myconfigs.result.pr': "收录 PR #{number}";
1777
+ readonly 'myconfigs.result.openPr': "查看 PR";
1778
+ readonly 'myconfigs.list.title': "已上传";
1779
+ readonly 'myconfigs.list.empty': "尚未上传任何配置";
1780
+ readonly 'myconfigs.list.loading': "正在读取…";
1781
+ readonly 'myconfigs.list.refresh': "刷新";
1782
+ readonly 'myconfigs.list.summary': "共 {total} 条 · {listed} 已收录 · {pending} 待审核 · {none} 未收录";
1783
+ readonly 'myconfigs.list.openRepo': "打开仓库";
1784
+ readonly 'myconfigs.item.update': "更新";
1785
+ readonly 'myconfigs.item.install': "装回本地";
1786
+ readonly 'myconfigs.item.openPr': "查看收录 PR";
1787
+ readonly 'myconfigs.error.loadStatus': "登录状态读取失败";
1788
+ readonly 'myconfigs.error.loadItems': "已上传列表读取失败";
1621
1789
  readonly 'common.cancel': "取消";
1622
1790
  readonly 'common.close': "关闭";
1623
1791
  readonly 'common.retry': "重试";
@@ -1653,8 +1821,12 @@ interface SyncSettingsViewProps {
1653
1821
  //#region src/client/market/MarketPanel.d.ts
1654
1822
  interface MarketPanelProps {
1655
1823
  api: MarketApi;
1824
+ /** 「我的配置」API(/me/* 端点:登录态/一键上传/查看已上传/一键更新;登录复用 SyncApi.github*) */
1825
+ myConfigsApi: MyConfigsApi;
1656
1826
  /** 确认导入复用的主 ConfigManagerApi(executeImportPlan:安全阀 + 回滚) */
1657
1827
  importApi: ConfigManagerApi;
1828
+ /** GitHub 登录 API(「我的配置」登录卡复用 sync github device flow,同 token 槽) */
1829
+ syncApi: SyncApi;
1658
1830
  t: TranslateNS<'config-manager-market'>;
1659
1831
  }
1660
1832
  //#endregion