@chatcode/cco-better-sidebar 0.18.0-alpha.4 → 0.18.0-rc.11

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 (83) hide show
  1. package/README.md +24 -5
  2. package/README_EN.md +24 -5
  3. package/cordis.patch.yml +6 -5
  4. package/lib/client-editor.js +10920 -363
  5. package/lib/client-mermaid.js +10806 -271
  6. package/lib/client-registry.js +3733 -2150
  7. package/lib/client-terminal.js +398 -257
  8. package/lib/client.js +3734 -2151
  9. package/lib/index.js +264 -46
  10. package/lib/types/client/LogoutConfirmDialog.d.ts +5 -0
  11. package/lib/types/client/PluginMarketSettingsSection.d.ts +7 -0
  12. package/lib/types/client/PluginMarketView.d.ts +7 -0
  13. package/lib/types/client/PluginProjectPicker.d.ts +13 -0
  14. package/lib/types/client/api.d.ts +17 -0
  15. package/lib/types/client/builtins/tabs.d.ts +13 -1
  16. package/lib/types/client/icons.d.ts +26 -8
  17. package/lib/types/client/locales.d.ts +39 -0
  18. package/lib/types/client/plugin-market-catalog.d.ts +25 -0
  19. package/lib/types/client/service.d.ts +1 -1
  20. package/lib/types/client/ui-tweaks/archive.d.ts +3 -7
  21. package/lib/types/client/ui-tweaks/branding.d.ts +1 -1
  22. package/lib/types/client/ui-tweaks/index.d.ts +3 -3
  23. package/lib/types/client/ui-tweaks/sidebar-header.d.ts +6 -0
  24. package/lib/types/client/ui-tweaks/typography.d.ts +9 -0
  25. package/lib/types/config.d.ts +4 -3
  26. package/lib/types/context-types.d.ts +12 -14
  27. package/lib/types/login-page-script.d.ts +2 -0
  28. package/lib/types/login-route.d.ts +2 -0
  29. package/lib/types/plugin-market-api.d.ts +5 -0
  30. package/lib/types/plugin-market-shared.d.ts +59 -0
  31. package/lib/types/prefs-shared.d.ts +1 -1
  32. package/lib/types/pty-deps.d.ts +1 -1
  33. package/lib/types/ui-tweaks/config.d.ts +6 -7
  34. package/lib/types/ui-tweaks/index.d.ts +2 -3
  35. package/package.json +2 -2
  36. package/src/client/AccountMenu.tsx +12 -2
  37. package/src/client/BrowserView.tsx +1 -1
  38. package/src/client/DiffTab.tsx +1 -1
  39. package/src/client/EditorHost.tsx +1 -1
  40. package/src/client/FileTree.tsx +10 -5
  41. package/src/client/FreeWindow.tsx +2 -1
  42. package/src/client/GitView.tsx +7 -3
  43. package/src/client/LogoutConfirmDialog.tsx +39 -0
  44. package/src/client/PluginMarketSettingsSection.tsx +55 -0
  45. package/src/client/PluginMarketView.module.css +50 -0
  46. package/src/client/PluginMarketView.tsx +243 -0
  47. package/src/client/PluginProjectPicker.tsx +73 -0
  48. package/src/client/SideCardSection.tsx +2 -23
  49. package/src/client/Sidebar.tsx +2 -2
  50. package/src/client/TabBar.tsx +2 -4
  51. package/src/client/TextEditor.tsx +2 -1
  52. package/src/client/TreePanel.tsx +1 -2
  53. package/src/client/UsageHeatmapSection.tsx +1 -1
  54. package/src/client/api.ts +9 -0
  55. package/src/client/builtins/tabs.tsx +25 -5
  56. package/src/client/builtins/viewers.tsx +2 -1
  57. package/src/client/icons.tsx +57 -4
  58. package/src/client/index.tsx +10 -1
  59. package/src/client/intercept.tsx +1 -1
  60. package/src/client/locales-ja.ts +39 -0
  61. package/src/client/locales.ts +118 -1
  62. package/src/client/md-toc.tsx +1 -1
  63. package/src/client/mermaid.tsx +2 -1
  64. package/src/client/open-with-settings.tsx +1 -1
  65. package/src/client/plugin-market-catalog.ts +90 -0
  66. package/src/client/service.ts +1 -1
  67. package/src/client/sidebar.module.css +81 -19
  68. package/src/client/ui-tweaks/archive.tsx +6 -56
  69. package/src/client/ui-tweaks/branding.tsx +36 -29
  70. package/src/client/ui-tweaks/index.tsx +42 -105
  71. package/src/client/ui-tweaks/sidebar-header.ts +73 -0
  72. package/src/client/ui-tweaks/typography.ts +38 -0
  73. package/src/config.ts +22 -2
  74. package/src/context-types.ts +5 -15
  75. package/src/index.ts +24 -20
  76. package/src/login-page-script.ts +107 -0
  77. package/src/login-route.ts +7 -4
  78. package/src/plugin-market-api.ts +88 -0
  79. package/src/plugin-market-shared.ts +30 -0
  80. package/src/prefs-shared.ts +1 -1
  81. package/src/pty-deps.ts +2 -2
  82. package/src/ui-tweaks/config.ts +12 -12
  83. package/src/ui-tweaks/index.ts +7 -13
package/lib/index.js CHANGED
@@ -3,6 +3,7 @@ import { mkdir, open, opendir, readFile, readdir, realpath, rename, rm, stat, wr
3
3
  import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
4
4
  import { WebSocket, WebSocketServer } from "ws";
5
5
  import z from "schemastery";
6
+ import z$1 from "@deepseek-ai/schemastery";
6
7
  import { createHash, randomUUID } from "node:crypto";
7
8
  import { once } from "node:events";
8
9
  import { chmodSync, createWriteStream, existsSync, readFileSync, realpathSync, statSync } from "node:fs";
@@ -11,9 +12,41 @@ import { execFile, spawn } from "node:child_process";
11
12
  import { SettingsConflictError } from "@deepseek-ai/dsh-settings";
12
13
  import { homedir, userInfo } from "node:os";
13
14
  import { defineTool } from "@deepseek-ai/dsh-tools";
14
- import z$1 from "@deepseek-ai/schemastery";
15
15
  import { workspaceDomainState } from "@deepseek-ai/dsh-workspace";
16
16
  import { YAMLMap, YAMLSeq, parse, parseDocument, stringify } from "yaml";
17
+ //#region src/ui-tweaks/config.ts
18
+ /**
19
+ * dsh-ui-tweaks configuration: conversation font size (px), markdown table
20
+ * style, and feature toggles. Every field
21
+ * defaults at the schema boundary, so a hand-edited settings document and the
22
+ * Settings panel stay consistent.
23
+ * @module dsh-ui-tweaks/config
24
+ */
25
+ /** Settings document namespace owned by this plugin. */
26
+ const UI_TWEAKS_SETTINGS_NAMESPACE = "better-sidebar";
27
+ /** Configuration schema with documented defaults. */
28
+ const Config$1 = z$1.object({
29
+ fontSize: z$1.number().min(10).max(32).default(14),
30
+ codeFontScale: z$1.number().min(50).max(150).default(81),
31
+ codeFontSize: z$1.number().min(8).max(32),
32
+ lineHeight: z$1.number().min(0).max(64).default(16),
33
+ tableStyle: z$1.union(["default", "claude"]).default("default"),
34
+ gitBarEnabled: z$1.boolean().default(false),
35
+ archiveManagerEnabled: z$1.boolean().default(false),
36
+ mcpManagerEnabled: z$1.boolean().default(false),
37
+ initCommandEnabled: z$1.boolean().default(false),
38
+ whaleIndicatorEnabled: z$1.boolean().default(false),
39
+ preciseCacheHitEnabled: z$1.boolean().default(false),
40
+ notificationsEnabled: z$1.boolean().default(false),
41
+ notifyOnlyWhenHidden: z$1.boolean().default(true),
42
+ notifyOnComplete: z$1.boolean().default(true),
43
+ notifyOnInteraction: z$1.boolean().default(true),
44
+ notifyTitleFlash: z$1.boolean().default(true),
45
+ notifySystemNotification: z$1.boolean().default(true),
46
+ notifySound: z$1.boolean().default(false),
47
+ suggestModel: z$1.string()
48
+ });
49
+ //#endregion
17
50
  //#region src/prefs-shared.ts
18
51
  /**
19
52
  * Shared "Side card" preference vocabulary (types + constants), consumed by
@@ -23,7 +56,7 @@ import { YAMLMap, YAMLSeq, parse, parseDocument, stringify } from "yaml";
23
56
  * the browser bundle never pulls the schema runtime in.
24
57
  */
25
58
  /** The user-settings namespace holding the side card preferences. */
26
- const SIDEBAR_PREFS_NS = "dsh-better-sidebar";
59
+ const SIDEBAR_PREFS_NS = "better-sidebar";
27
60
  /** Fallback prefs used whenever the settings document is unreachable or malformed. */
28
61
  const SIDEBAR_PREFS_DEFAULTS = {
29
62
  openByDefault: false,
@@ -65,7 +98,7 @@ const SIDEBAR_PREFS_DEFAULTS = {
65
98
  * @module dsh-better-sidebar/config
66
99
  */
67
100
  /** Schemastery schema for the plugin configuration. */
68
- const Config = z.object({
101
+ const HostConfig = z.object({
69
102
  readLimit: z.number().step(1).min(1).default(524288),
70
103
  mediaLimit: z.number().step(1).min(1).default(20971520),
71
104
  uploadLimit: z.number().step(1).min(1).default(134217728),
@@ -148,6 +181,20 @@ const PrefsSchema = z.object({
148
181
  viewersEnabled: z.dict(z.boolean()).default({}),
149
182
  pluginSettings: z.dict(z.dict(z.any())).default({})
150
183
  });
184
+ function live(schema) {
185
+ Reflect.set(schema.meta, "volatile", true);
186
+ return schema;
187
+ }
188
+ function liveFields(schema) {
189
+ if (schema.type !== "object" || schema.dict === void 0) throw new TypeError("Live settings schema must be an object");
190
+ return Object.fromEntries(Object.entries(schema.dict).map(([key, field]) => [key, live(field)]));
191
+ }
192
+ /** One entry schema: deployment fields stay fixed while sidebar and UI preferences are live-editable. */
193
+ const Config = z.object({
194
+ ...HostConfig.dict,
195
+ ...liveFields(PrefsSchema),
196
+ ...liveFields(Config$1)
197
+ });
151
198
  //#endregion
152
199
  //#region src/wire.ts
153
200
  /** One API failure with its wire code and HTTP status. */
@@ -818,13 +865,124 @@ function registerBundleRoute(ctx, fence) {
818
865
  });
819
866
  }
820
867
  //#endregion
868
+ //#region src/login-page-script.ts
869
+ /** Standalone sign-in recovery; each document starts once and always keeps a usable reopen action. */
870
+ const CHATCODE_LOGIN_PAGE_SCRIPT = String.raw`
871
+ (() => {
872
+ const message = document.getElementById('message');
873
+ const button = document.getElementById('login');
874
+ const fallback = document.getElementById('login-fallback');
875
+ const link = document.getElementById('login-link');
876
+ const current = new URL(location.href);
877
+ const returnTo = (() => {
878
+ const value = current.searchParams.get('return');
879
+ if (!value || !value.startsWith('/') || value.startsWith('//')) return '/';
880
+ const target = new URL(value, location.origin);
881
+ return target.origin === location.origin ? target.pathname + target.search + target.hash : '/';
882
+ })();
883
+ let busy = false, checking = false, attempted = false, recheck = false, attempt, popup;
884
+ const call = async name => {
885
+ const response = await fetch('/sidebar/api/' + name, {
886
+ method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}',
887
+ });
888
+ const data = await response.json();
889
+ if (!response.ok || !data.ok) throw new Error('操作失败');
890
+ return data.value;
891
+ };
892
+ const showMessage = (text, error = false) => {
893
+ message.textContent = text;
894
+ message.classList.toggle('error', error);
895
+ };
896
+ async function login() {
897
+ if (busy) return;
898
+ attempted = true;
899
+ busy = true;
900
+ button.disabled = true;
901
+ button.textContent = '正在打开登录页…';
902
+ let tab = null;
903
+ try { tab = window.open('', '_blank'); if (tab) tab.opener = null; } catch {}
904
+ try {
905
+ if (!attempt) {
906
+ const started = await call('chatcode.start');
907
+ const url = new URL(started.url);
908
+ if (!['http:', 'https:'].includes(url.protocol) || typeof started.sessionId !== 'string') throw new Error('登录地址无效');
909
+ attempt = { sessionId: started.sessionId, url: url.href };
910
+ }
911
+ link.href = attempt.url;
912
+ link.textContent = attempt.url;
913
+ fallback.hidden = false;
914
+ if (tab && !tab.closed) {
915
+ try { tab.location.href = attempt.url; popup = tab; } catch { try { tab.close(); } catch {} }
916
+ }
917
+ showMessage('请在登录页完成登录;若网页已关闭,可随时重新打开。');
918
+ } catch {
919
+ try { if (tab) tab.close(); } catch {}
920
+ showMessage('登录页打开失败,请重试。', true);
921
+ } finally {
922
+ busy = false;
923
+ button.disabled = false;
924
+ button.textContent = attempt ? '重新打开登录页' : '去登录';
925
+ }
926
+ }
927
+ async function status() {
928
+ if (checking || busy) return;
929
+ checking = true;
930
+ const observedAttempt = attempt, observedStarted = attempted;
931
+ try {
932
+ const state = await call('chatcode.status');
933
+ if (busy || attempt !== observedAttempt || attempted !== observedStarted) return;
934
+ if (state.available && state.validation === 'valid' && !state.expired) {
935
+ try { if (popup) popup.close(); window.focus(); } catch {}
936
+ location.replace(returnTo);
937
+ return;
938
+ }
939
+ if (!state.available) {
940
+ recheck = true;
941
+ button.textContent = '重新检测';
942
+ showMessage('登录服务暂不可用,请稍后重试。', true);
943
+ return;
944
+ }
945
+ if (state.configured && state.validation === 'unavailable') {
946
+ recheck = true;
947
+ button.textContent = '重新检测';
948
+ showMessage('暂时无法验证已有账号,请检查网络后重新检测。', true);
949
+ return;
950
+ }
951
+ recheck = false;
952
+ button.textContent = attempt ? '重新打开登录页' : '去登录';
953
+ if (attempt && (state.login?.sessionId !== attempt.sessionId || state.login.state !== 'pending')) {
954
+ attempt = undefined;
955
+ fallback.hidden = true;
956
+ link.removeAttribute('href');
957
+ link.textContent = '';
958
+ button.textContent = '去登录';
959
+ showMessage('登录请求已失效,请重新登录。');
960
+ }
961
+ if (!attempted) await login();
962
+ } catch {
963
+ recheck = true;
964
+ button.textContent = '重新检测';
965
+ showMessage('无法读取登录状态,请稍后重试。', true);
966
+ } finally {
967
+ checking = false;
968
+ if (!busy) button.disabled = false;
969
+ }
970
+ }
971
+ button.addEventListener('click', () => { void (recheck ? status() : login()); });
972
+ void status();
973
+ setInterval(() => { void status(); }, 2000);
974
+ })();
975
+ `;
976
+ //#endregion
821
977
  //#region src/login-route.ts
822
978
  const assetPath = join(dirname(fileURLToPath(import.meta.url)), "..", "assets", "logo.svg");
823
- function page(logo) {
979
+ /** Render the standalone login gate with one automatic attempt and persistent manual recovery. */
980
+ function renderChatcodeLoginPage(logo) {
824
981
  return `<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>请登录 ChatCode</title><style>
825
982
  *{box-sizing:border-box}body{margin:0;min-width:320px;min-height:100vh;display:grid;place-items:center;font-family:Inter,"Microsoft YaHei",system-ui,sans-serif;color:#172b4d;background:radial-gradient(circle at 18% 18%,#e5edff 0,transparent 30rem),linear-gradient(135deg,#edf2fb,#dfe8f7)}.card{width:min(490px,calc(100vw - 40px));padding:34px 44px 36px;border:1px solid #dce4ef;border-radius:18px;background:#fff;box-shadow:0 20px 48px rgba(36,62,103,.18),0 2px 8px rgba(36,62,103,.06)}.brand{display:flex;align-items:center;justify-content:center;gap:12px;padding-bottom:27px;border-bottom:1px solid #edf0f5}.brand img{width:34px;height:34px}.brand strong{font-size:22px;letter-spacing:-.02em}.content{padding-top:40px;text-align:center}.content h1{margin:0;font-size:28px;line-height:1.3;font-weight:650}.content p{min-height:24px;margin:12px 0 30px;color:#71809a;font-size:14px;line-height:1.7}.action{width:100%;min-height:46px;border:0;border-radius:8px;background:#9B0B09;color:#fff;font:600 15px/1 Inter,"Microsoft YaHei",sans-serif;cursor:pointer;box-shadow:0 8px 18px rgba(155,11,9,.25);transition:transform .18s ease,box-shadow .18s ease,background .18s ease}.action:hover:not(:disabled){transform:translateY(-2px);background:#b20d0a;box-shadow:0 12px 24px rgba(155,11,9,.38)}.action:focus-visible{outline:3px solid #f0b7b5;outline-offset:3px}.action:disabled{cursor:default;opacity:.7}.error{color:#b42318}@media(max-width:480px){.card{padding:30px 26px}.content{padding-top:32px}}
826
- </style></head><body><main class="card"><div class="brand"><img src="data:image/svg+xml;base64,${logo}" alt=""><strong>ChatCode</strong></div><section class="content"><h1>请登录 ChatCode</h1><p id="message">请登录后继续使用。</p><button id="login" class="action" type="button">去登录</button></section></main><script>
827
- const message=document.getElementById('message'),button=document.getElementById('login');const current=new URL(location.href);const returnTo=(()=>{const v=current.searchParams.get('return');return v&&v.startsWith('/')&&!v.startsWith('//')?v:'/'} )();const call=async(name,body={})=>{const r=await fetch('/sidebar/api/'+name,{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify(body)});const d=await r.json();if(!r.ok||!d.ok)throw new Error(d.error?.message||'操作失败');return d.value};let waiting=false;async function status(){try{const s=await call('chatcode.status');if(s.available&&s.validation==='valid'&&!s.expired){location.replace(returnTo);return}if(waiting)message.textContent='正在等待浏览器完成登录…'}catch{message.textContent='无法读取登录状态,请稍后重试。';message.classList.add('error')}}async function login(){const tab=window.open('','_blank');button.disabled=true;button.textContent='正在打开登录页…';message.classList.remove('error');try{const s=await call('chatcode.start');waiting=true;if(tab&&!tab.closed){tab.opener=null;tab.location.href=s.url;message.textContent='请在新打开的浏览器窗口完成登录…'}else{message.innerHTML='浏览器拦截了登录窗口,请 <a href="'+s.url+'" target="_blank" rel="noopener noreferrer">打开登录页</a> 后完成登录。'}}catch{try{tab&&tab.close()}catch{}button.disabled=false;button.textContent='去登录';message.textContent='登录页打开失败,请重试。';message.classList.add('error')}}button.addEventListener('click',login);status();setInterval(status,2000);
983
+ .login-fallback{margin:18px 0 0;color:#71809a;font-size:12px;line-height:1.7;overflow-wrap:anywhere}.login-fallback a{display:block;margin-top:4px;color:#315da8;text-underline-offset:3px}
984
+ </style></head><body><main class="card"><div class="brand"><img src="data:image/svg+xml;base64,${logo}" alt=""><strong>ChatCode</strong></div><section class="content"><h1>请登录 ChatCode</h1><p id="message" aria-live="polite">正在检查登录状态…</p><button id="login" class="action" type="button" disabled>正在检查登录状态…</button><div id="login-fallback" class="login-fallback" hidden>若登录网页已关闭或未弹出,可再次访问:<a id="login-link" target="_blank" rel="noopener noreferrer"></a></div></section></main><script>
985
+ ${CHATCODE_LOGIN_PAGE_SCRIPT}
828
986
  <\/script></body></html>`;
829
987
  }
830
988
  function registerLoginRoute(ctx, fence) {
@@ -849,7 +1007,7 @@ function registerLoginRoute(ctx, fence) {
849
1007
  "cache-control": "no-store",
850
1008
  "content-security-policy": "default-src 'self'; img-src 'self' data:; style-src 'unsafe-inline'; script-src 'unsafe-inline'"
851
1009
  });
852
- res.end(req.method === "HEAD" ? void 0 : page(logo));
1010
+ res.end(req.method === "HEAD" ? void 0 : renderChatcodeLoginPage(logo));
853
1011
  } catch {
854
1012
  res.writeHead(500);
855
1013
  res.end("login page unavailable");
@@ -1361,7 +1519,7 @@ async function cherryPick(cwd, hash, selected) {
1361
1519
  * agent terminal tools are simply not registered.
1362
1520
  *
1363
1521
  * Version contract: the plugin must stay in sync with DSH core —
1364
- * `@deepseek-ai/dsh-subprocess-local` declares `"node-pty": "^1.1.0"` in
1522
+ * `@deepseek-ai/dsh-subprocess-local` declares `"node-pty": "1.2.0-beta.15"` in
1365
1523
  * its `dependencies`. Both sides then resolve the SAME pnpm store entry
1366
1524
  * (same range, same integrity → one native binding, no drift). Do NOT
1367
1525
  * switch to a fork (e.g. @lydell/node-pty) or a different range without
@@ -1372,7 +1530,7 @@ async function cherryPick(cwd, hash, selected) {
1372
1530
  * range DSH core declares (`@deepseek-ai/dsh-subprocess-local`): the same
1373
1531
  * range keeps pnpm resolving both to one physical package.
1374
1532
  */
1375
- const DSH_NODE_PTY_RANGE = "^1.1.0";
1533
+ const DSH_NODE_PTY_RANGE = "1.2.0-beta.15";
1376
1534
  /**
1377
1535
  * The WebSocket close-code-1011 reason the host sends when node-pty is
1378
1536
  * unavailable. The client recognizes this exact marker and fetches the full
@@ -3225,39 +3383,6 @@ async function performAllUpdates(checks) {
3225
3383
  return results;
3226
3384
  }
3227
3385
  //#endregion
3228
- //#region src/ui-tweaks/config.ts
3229
- /**
3230
- * dsh-ui-tweaks configuration: conversation font size (px), markdown table
3231
- * style, and feature toggles. Every field
3232
- * defaults at the schema boundary, so a hand-edited settings document and the
3233
- * Settings panel stay consistent.
3234
- * @module dsh-ui-tweaks/config
3235
- */
3236
- /** Settings document namespace owned by this plugin. */
3237
- const UI_TWEAKS_SETTINGS_NAMESPACE = "ui-tweaks";
3238
- /** Configuration schema with documented defaults. */
3239
- const Config$1 = z$1.object({
3240
- fontSize: z$1.number().min(10).max(32).default(16),
3241
- codeFontScale: z$1.number().min(50).max(150).default(81),
3242
- codeFontSize: z$1.number().min(8).max(32),
3243
- lineHeight: z$1.number().min(0).max(64).default(16),
3244
- tableStyle: z$1.union(["default", "claude"]).default("default"),
3245
- gitBarEnabled: z$1.boolean().default(false),
3246
- archiveManagerEnabled: z$1.boolean().default(false),
3247
- mcpManagerEnabled: z$1.boolean().default(false),
3248
- initCommandEnabled: z$1.boolean().default(false),
3249
- whaleIndicatorEnabled: z$1.boolean().default(false),
3250
- preciseCacheHitEnabled: z$1.boolean().default(false),
3251
- notificationsEnabled: z$1.boolean().default(false),
3252
- notifyOnlyWhenHidden: z$1.boolean().default(true),
3253
- notifyOnComplete: z$1.boolean().default(true),
3254
- notifyOnInteraction: z$1.boolean().default(true),
3255
- notifyTitleFlash: z$1.boolean().default(true),
3256
- notifySystemNotification: z$1.boolean().default(true),
3257
- notifySound: z$1.boolean().default(false),
3258
- suggestModel: z$1.string()
3259
- });
3260
- //#endregion
3261
3386
  //#region src/ui-tweaks/turn-outcome.ts
3262
3387
  /** Projection key the browser notifier reads through list-row `projectionValues`. */
3263
3388
  const TURN_OUTCOME_PROJECTION_KEY = "dshTurnOutcome";
@@ -5857,16 +5982,102 @@ function installMcpWeb(ctx, backend) {
5857
5982
  //#endregion
5858
5983
  //#region src/ui-tweaks/index.ts
5859
5984
  function apply$1(ctx) {
5860
- ctx.settings.register(UI_TWEAKS_SETTINGS_NAMESPACE, Config$1, { applies: "live" });
5861
5985
  installTurnOutcomeProjection(ctx);
5862
5986
  installUITweaksWeb(ctx, new UITweaksWebBackend(ctx));
5863
- const readConfig = () => ctx.settings.get(UI_TWEAKS_SETTINGS_NAMESPACE);
5987
+ const readConfig = () => {
5988
+ return ctx.settings.describe().find((candidate) => candidate.ns === "better-sidebar")?.value ?? {};
5989
+ };
5864
5990
  installGitWeb(ctx, new GitBackend(ctx, readConfig));
5865
5991
  installArchiveWeb(ctx, new ArchiveBackend(ctx));
5866
5992
  installMcpWeb(ctx, new McpBackend(ctx));
5867
5993
  ctx.logger.info("[ChatCode CLI UI Tweaks] settings namespace registered and Web routes mounted");
5868
5994
  }
5869
5995
  //#endregion
5996
+ //#region src/plugin-market-api.ts
5997
+ function buildPluginMarketApi(ctx, cwdOf) {
5998
+ const service = () => {
5999
+ const value = ctx.get("chatcodePluginMarket", false);
6000
+ if (!value) throw new SidebarError("chatcode-unavailable", "插件市场服务未挂载,请更新并启用 ChatCode config 插件。", 503);
6001
+ return value;
6002
+ };
6003
+ const scopeOf = (payload) => {
6004
+ const scope = requireString(payload, "scope");
6005
+ if (scope !== "project" && scope !== "user") throw new SidebarError("bad-request", "scope must be project or user");
6006
+ return scope;
6007
+ };
6008
+ const selectedProject = async (payload) => {
6009
+ if (typeof payload?.projectPath !== "string") throw new SidebarError("bad-request", "请先选择目标项目目录。");
6010
+ const path = requireString(payload, "projectPath");
6011
+ const qualified = process.platform !== "win32" || /^(?:[A-Za-z]:[\\/]|[\\/]{2}[^\\/]+[\\/][^\\/]+)/.test(path);
6012
+ if (!isAbsolute(path) || !qualified || path.includes("\0")) throw new SidebarError("bad-request", "请选择有效的项目目录。");
6013
+ const canonical = await realpath(path);
6014
+ if (!(await stat(canonical)).isDirectory()) throw new SidebarError("bad-request", "请选择项目文件夹。");
6015
+ return canonical;
6016
+ };
6017
+ const picker = () => {
6018
+ const value = ctx.get("directoryPicker", false);
6019
+ if (!value) throw new SidebarError("method-error", "目录选择器未挂载,请启用宿主目录选择插件。", 503);
6020
+ return value.capability();
6021
+ };
6022
+ const contextOf = async (payload) => {
6023
+ const sessionId = payload?.sessionId;
6024
+ if (sessionId === void 0 || sessionId === "") return { sessionId: "" };
6025
+ requireString(payload, "sessionId");
6026
+ return {
6027
+ sessionId,
6028
+ cwd: (await cwdOf(payload)).cwd
6029
+ };
6030
+ };
6031
+ const projectOf = async (payload) => {
6032
+ if (payload?.projectPath !== void 0) return selectedProject(payload);
6033
+ return (await contextOf(payload)).cwd;
6034
+ };
6035
+ return {
6036
+ "plugins.context": contextOf,
6037
+ "plugins.project.pick": async () => {
6038
+ const capability = picker();
6039
+ if (capability.kind === "browse") return { kind: "browse" };
6040
+ const path = await capability.pick(AbortSignal.timeout(12e4));
6041
+ return {
6042
+ kind: "native",
6043
+ path: path === null ? null : await selectedProject({ projectPath: path })
6044
+ };
6045
+ },
6046
+ "plugins.project.directories": async (payload) => {
6047
+ const capability = picker();
6048
+ if (capability.kind !== "browse") throw new SidebarError("method-error", "当前宿主使用系统文件夹选择窗口。");
6049
+ const path = payload?.path;
6050
+ return capability.list(path === void 0 ? void 0 : requireString(payload, "path"), AbortSignal.timeout(15e3));
6051
+ },
6052
+ "plugins.marketplaces": () => service().marketplaces(),
6053
+ "plugins.catalog": async (payload) => {
6054
+ const market = service();
6055
+ const id = requireString(payload, "marketplaceId");
6056
+ if (payload.includeMetadata !== true) return market.plugins(id);
6057
+ return market.catalog ? market.catalog(id) : {
6058
+ plugins: await market.plugins(id),
6059
+ warning: ""
6060
+ };
6061
+ },
6062
+ "plugins.installed": async (payload) => {
6063
+ const project = await projectOf(payload);
6064
+ const records = await service().installed(project ?? process.cwd());
6065
+ return project ? records : records.filter((record) => record.scope === "user");
6066
+ },
6067
+ "plugins.install": async (payload) => {
6068
+ const scope = scopeOf(payload);
6069
+ const project = scope === "project" ? await selectedProject(payload) : await projectOf(payload);
6070
+ return service().install(project ?? process.cwd(), requireString(payload, "pluginId"), scope);
6071
+ },
6072
+ "plugins.uninstall": async (payload) => {
6073
+ const scope = scopeOf(payload);
6074
+ const project = scope === "project" ? await selectedProject(payload) : await projectOf(payload);
6075
+ await service().uninstall(project ?? process.cwd(), requireString(payload, "pluginId"), scope);
6076
+ return { ok: true };
6077
+ }
6078
+ };
6079
+ }
6080
+ //#endregion
5870
6081
  //#region src/index.ts
5871
6082
  /**
5872
6083
  * dsh-better-sidebar host half: the /sidebar JSON API (explorer listing, file
@@ -6182,6 +6393,7 @@ function buildApi(ctx, ptyManager, agentPtyRegistry, resolved, terminalShell, ge
6182
6393
  parent: parentOf(cwd) ?? null
6183
6394
  };
6184
6395
  },
6396
+ ...buildPluginMarketApi(ctx, cwdOf),
6185
6397
  "fs.tree": async (payload) => {
6186
6398
  const { cwd } = await cwdOf(payload);
6187
6399
  return listDirectory(payload.path === void 0 ? cwd : await ensureWorkspacePath(cwd, requireString(payload, "path"), fenceEnabledOf(getSettings)), resolved.listLimit);
@@ -6468,7 +6680,6 @@ function apply(ctx, config) {
6468
6680
  };
6469
6681
  ctx.inject(["settings"], (sctx) => {
6470
6682
  const ns = SIDEBAR_PREFS_NS;
6471
- const scope = sctx.settings.register(ns, PrefsSchema);
6472
6683
  const viewOf = () => {
6473
6684
  const descriptor = sctx.settings.describe({ redactSecrets: true }).find((candidate) => candidate.ns === ns);
6474
6685
  return descriptor === void 0 ? {
@@ -6490,6 +6701,13 @@ function apply(ctx, config) {
6490
6701
  return viewOf();
6491
6702
  }
6492
6703
  };
6704
+ const scope = { get: () => {
6705
+ const value = viewOf().value;
6706
+ return {
6707
+ ...SIDEBAR_PREFS_DEFAULTS,
6708
+ ...typeof value === "object" && value !== null ? value : {}
6709
+ };
6710
+ } };
6493
6711
  syncToolsGate(scope);
6494
6712
  const syncOpenToolsGate = () => {
6495
6713
  if (scope.get().agentOpenTools) {
@@ -6504,7 +6722,7 @@ function apply(ctx, config) {
6504
6722
  }
6505
6723
  };
6506
6724
  syncOpenToolsGate();
6507
- scope.watch(() => {
6725
+ sctx.on("loader/volatile-update", () => {
6508
6726
  syncToolsGate(scope);
6509
6727
  syncOpenToolsGate();
6510
6728
  });
@@ -0,0 +1,5 @@
1
+ /** Native modal supplies an inert background and default Cancel focus until a choice is made. */
2
+ export declare function LogoutConfirmDialog({ onCancel, onConfirm }: {
3
+ onCancel: () => void;
4
+ onConfirm: () => void;
5
+ }): JSX.Element;
@@ -0,0 +1,7 @@
1
+ import type { Context } from '../context-types.ts';
2
+ import type { PluginMarketCatalog } from './plugin-market-catalog.ts';
3
+ export declare function PluginMarketSettingsSection({ ctx, catalog }: {
4
+ ctx: Context;
5
+ catalog: PluginMarketCatalog;
6
+ }): JSX.Element;
7
+ export declare function registerPluginMarketSettings(ctx: Context, catalog: PluginMarketCatalog): void;
@@ -0,0 +1,7 @@
1
+ import { type SessionScope } from './api.ts';
2
+ import type { PluginMarketCatalog } from './plugin-market-catalog.ts';
3
+ export declare function PluginMarketView({ scope, visible, catalog }: {
4
+ scope: SessionScope;
5
+ visible: boolean;
6
+ catalog: PluginMarketCatalog;
7
+ }): JSX.Element;
@@ -0,0 +1,13 @@
1
+ import type { PluginProjectPick } from '../plugin-market-shared.ts';
2
+ export interface PluginProjectRequest {
3
+ result: Promise<PluginProjectPick>;
4
+ controller: AbortController;
5
+ finish: (path: string | null) => void;
6
+ }
7
+ export declare function PluginProjectPicker({ request, initialPath, onPicked, onCancel, onError }: {
8
+ request: PluginProjectRequest;
9
+ initialPath?: string;
10
+ onPicked: (path: string) => void;
11
+ onCancel: () => void;
12
+ onError: (message: string) => void;
13
+ }): JSX.Element | null;
@@ -1,4 +1,5 @@
1
1
  import type { BrowserProbeResult } from './browser.ts';
2
+ import type { MarketplaceCatalog, MarketplacePlugin, InstalledMarketplacePlugin, PluginMarketScope, PluginProjectPick, PluginProjectDirectories } from '../plugin-market-shared.ts';
2
3
  /** One wire failure. */
3
4
  export declare class SidebarApiError extends Error {
4
5
  readonly code: string;
@@ -184,6 +185,22 @@ export interface SessionScope {
184
185
  }
185
186
  /** The sidebar API surface (session scope threaded through every call). */
186
187
  export declare const api: {
188
+ pluginMarketContext: (scope: SessionScope, signal?: AbortSignal) => Promise<{
189
+ sessionId: string;
190
+ cwd?: string;
191
+ }>;
192
+ pluginProjectPick: (signal?: AbortSignal) => Promise<PluginProjectPick>;
193
+ pluginProjectDirectories: (path?: string, signal?: AbortSignal) => Promise<PluginProjectDirectories>;
194
+ pluginMarketplaces: (signal?: AbortSignal) => Promise<MarketplaceCatalog>;
195
+ pluginCatalog: (marketplaceId: string, signal?: AbortSignal) => Promise<MarketplacePlugin[] | {
196
+ plugins: MarketplacePlugin[];
197
+ warning: string;
198
+ }>;
199
+ pluginsInstalled: (scope: SessionScope, signal?: AbortSignal, projectPath?: string) => Promise<InstalledMarketplacePlugin[]>;
200
+ pluginInstall: (scope: SessionScope, pluginId: string, installScope: PluginMarketScope, projectPath?: string) => Promise<InstalledMarketplacePlugin>;
201
+ pluginUninstall: (scope: SessionScope, pluginId: string, installScope: PluginMarketScope, projectPath?: string) => Promise<{
202
+ ok: true;
203
+ }>;
187
204
  chatcodeStatus: (signal?: AbortSignal) => Promise<ChatCodeAuthState>;
188
205
  chatcodeStart: () => Promise<{
189
206
  sessionId: string;
@@ -1,4 +1,14 @@
1
+ /**
2
+ * The 6 built-in tab descriptors: the plugin registers its own pages
3
+ * (editor / git / terminal / browser / diff / plugin-market) through
4
+ * the same {@link BetterSidebarService} external plugins use — eating its
5
+ * own dogfood. The terminal descriptor owns its quota (`TERMINAL_LIMIT`)
6
+ * and mints `terminal:<uuid>` ids through `createTab`; the browser mints
7
+ * `browser:<n>` the same way (no quota). The editor IS the files window
8
+ * (the old standalone explorer merged into it).
9
+ */
1
10
  import type { Context } from '../../context-types.ts';
11
+ import { type PluginMarketCatalog } from '../plugin-market-catalog.ts';
2
12
  import type { TabDescriptor } from '../service.ts';
3
13
  /** How many UI-owned terminals may be open at once (agent-owned ones are uncapped). */
4
14
  export declare const TERMINAL_LIMIT = 3;
@@ -6,6 +16,8 @@ export declare const TERMINAL_LIMIT = 3;
6
16
  export interface BuiltinTabOptions {
7
17
  /** Returns the display title for newly opened terminal tabs. */
8
18
  terminalTitle?: () => string;
19
+ /** Shared app-lifetime catalog; production supplies the activation's store. */
20
+ pluginMarketCatalog?: PluginMarketCatalog;
9
21
  }
10
- /** The 5 built-in tab descriptors. */
22
+ /** The 6 built-in tab descriptors. */
11
23
  export declare function builtinTabs(ctx: Context, options?: BuiltinTabOptions): readonly TabDescriptor[];
@@ -1,11 +1,29 @@
1
- /**
2
- * Icons the sidebar needs beyond the primitives set: a terminal glyph (the
3
- * icon library has none), a diff glyph, and the two panel-toggle glyphs for
4
- * the top-right cluster. Per-tab icons live on the tab descriptors
5
- * (`descriptor.icon`), not in a type-keyed switch — the icon mapping was
6
- * registry-ized with the tab types.
7
- */
8
- import type { IconProps } from '@deepseek-ai/dsh-client-ui-primitives';
1
+ export interface IconProps {
2
+ size?: number;
3
+ className?: string;
4
+ }
5
+ export declare const IconListPenOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
6
+ export declare const IconRefreshOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
7
+ export declare const IconRefreshOutline14: ({ size, className }: IconProps) => import("react").JSX.Element;
8
+ export declare const IconChevronRightOutline14: ({ size, className }: IconProps) => import("react").JSX.Element;
9
+ export declare const IconChevronLeftOutline14: ({ size, className }: IconProps) => import("react").JSX.Element;
10
+ export declare const IconChevronDownOutline14: ({ size, className }: IconProps) => import("react").JSX.Element;
11
+ export declare const IconCodeOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
12
+ export declare const IconCopyOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
13
+ export declare const IconDownloadOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
14
+ export declare const IconLinkOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
15
+ export declare const IconLinkOutline14: ({ size, className }: IconProps) => import("react").JSX.Element;
16
+ export declare const IconBranchOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
17
+ export declare const IconTrashOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
18
+ export declare const IconWarningOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
19
+ export declare const IconCloseFill14: ({ size, className }: IconProps) => import("react").JSX.Element;
20
+ export declare const IconCloseOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
21
+ export declare const IconLoadingOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
22
+ export declare const IconPlusOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
23
+ export declare const IconSettingsOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
24
+ export declare const IconFolderOpen16: ({ size, className }: IconProps) => import("react").JSX.Element;
25
+ export declare const IconPanelLeftOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
26
+ export declare const IconCheckOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
9
27
  /** User-manual glyph: an open book in the sidebar's 1.5px outline style. */
10
28
  export declare const IconBookOutline16: ({ size, className }: IconProps) => import("react").JSX.Element;
11
29
  /**
@@ -22,8 +22,47 @@
22
22
  */
23
23
  /** The zh dictionary (also registered into the ChatCode CLI locale registry under {@link LOCALE_NS}). */
24
24
  export declare const zh: {
25
+ pluginMarketTitle: string;
26
+ pluginMarketProjectDirectory: string;
27
+ pluginMarketInstalledTab: string;
28
+ pluginMarketRefresh: string;
29
+ pluginMarketLoading: string;
30
+ pluginMarketRefreshing: string;
31
+ pluginMarketEmpty: string;
32
+ pluginMarketBack: string;
33
+ pluginMarketInstall: string;
34
+ pluginMarketUninstall: string;
35
+ pluginMarketProject: string;
36
+ pluginMarketUser: string;
37
+ pluginMarketInstalled: string;
38
+ pluginMarketUninstalled: string;
39
+ pluginMarketSubtitle: string;
40
+ pluginMarketChooseProject: string;
41
+ pluginMarketProjectHint: string;
42
+ pluginMarketChoosingDirectory: string;
43
+ pluginMarketAwaitingConfirmation: string;
44
+ pluginMarketConfirmProjectInstall: string;
45
+ pluginMarketConfirmProjectDescription: string;
46
+ pluginMarketConfirmInstall: string;
47
+ pluginMarketInstalledAt: string;
48
+ pluginMarketInstallPath: string;
49
+ pluginMarketDirectoryPath: string;
50
+ pluginMarketOpenDirectory: string;
51
+ pluginMarketSelectDirectory: string;
52
+ pluginMarketHomeDirectory: string;
53
+ pluginMarketDirectoryTruncated: string;
54
+ pluginMarketSearch: string;
55
+ pluginMarketDefault: string;
56
+ pluginMarketBrowse: string;
57
+ pluginMarketNoDescription: string;
58
+ pluginMarketInstalling: string;
59
+ pluginMarketUninstalling: string;
60
+ pluginMarketInstallProgress: string;
61
+ pluginMarketUninstallProgress: string;
25
62
  accountMenuSettings: string;
26
63
  accountMenuLogout: string;
64
+ accountMenuLogoutConfirmTitle: string;
65
+ accountMenuLogoutConfirmDescription: string;
27
66
  accountMenuLabel: string;
28
67
  updateMenu: string;
29
68
  updateNav: string;
@@ -0,0 +1,25 @@
1
+ import type { MarketplaceCatalog, MarketplacePlugin } from '../plugin-market-shared.ts';
2
+ interface Entry<T> {
3
+ readonly status: 'loading' | 'ready' | 'error';
4
+ readonly data?: T;
5
+ readonly error?: string;
6
+ readonly warning?: string;
7
+ }
8
+ interface Snapshot {
9
+ readonly markets?: Entry<MarketplaceCatalog>;
10
+ readonly plugins: Readonly<Record<string, Entry<MarketplacePlugin[]>>>;
11
+ readonly refresh?: {
12
+ readonly status: 'loading' | 'ready' | 'error';
13
+ readonly error?: string;
14
+ };
15
+ }
16
+ export interface PluginMarketCatalog {
17
+ subscribe(listener: () => void): () => void;
18
+ getSnapshot(): Snapshot;
19
+ start(): void;
20
+ ensure(marketplaceId: string): void;
21
+ refresh(marketplaceId?: string): void;
22
+ dispose(): void;
23
+ }
24
+ export declare function createPluginMarketCatalog(): PluginMarketCatalog;
25
+ export {};
@@ -418,7 +418,7 @@ export declare function matchUrlTarget(tabs: readonly TabDescriptor[], url: URL)
418
418
  * The plugin version this service instance reports. Keep in lockstep with
419
419
  * `package.json`'s version — `tests/service.spec.ts` asserts the pair.
420
420
  */
421
- export declare const SIDEBAR_SERVICE_VERSION = "0.18.0-alpha.0";
421
+ export declare const SIDEBAR_SERVICE_VERSION = "0.18.0-alpha.4";
422
422
  /**
423
423
  * Monotonic capability list consumers use to gate new API usage (features
424
424
  * are never removed). Each string names a v0.12.0+ capability: