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

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 (87) hide show
  1. package/README.md +30 -9
  2. package/README_EN.md +30 -9
  3. package/cordis.patch.yml +6 -5
  4. package/lib/client-editor.js +10954 -395
  5. package/lib/client-mermaid.js +10835 -300
  6. package/lib/client-registry.js +4035 -2215
  7. package/lib/client-terminal.js +435 -292
  8. package/lib/client.js +4035 -2215
  9. package/lib/index.js +282 -47
  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 +21 -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-ja.d.ts +25 -0
  18. package/lib/types/client/locales.d.ts +39 -0
  19. package/lib/types/client/plugin-market-catalog.d.ts +25 -0
  20. package/lib/types/client/service.d.ts +1 -1
  21. package/lib/types/client/ui-tweaks/archive.d.ts +9 -28
  22. package/lib/types/client/ui-tweaks/branding.d.ts +1 -1
  23. package/lib/types/client/ui-tweaks/dom-text.d.ts +2 -0
  24. package/lib/types/client/ui-tweaks/index.d.ts +9 -1
  25. package/lib/types/client/ui-tweaks/sidebar-header.d.ts +6 -0
  26. package/lib/types/client/ui-tweaks/typography.d.ts +9 -0
  27. package/lib/types/config.d.ts +4 -3
  28. package/lib/types/context-types.d.ts +12 -14
  29. package/lib/types/login-page-script.d.ts +2 -0
  30. package/lib/types/login-route.d.ts +2 -0
  31. package/lib/types/plugin-market-api.d.ts +5 -0
  32. package/lib/types/plugin-market-shared.d.ts +59 -0
  33. package/lib/types/prefs-shared.d.ts +1 -1
  34. package/lib/types/pty-deps.d.ts +1 -1
  35. package/lib/types/ui-tweaks/config.d.ts +6 -7
  36. package/lib/types/ui-tweaks/index.d.ts +2 -3
  37. package/package.json +2 -2
  38. package/src/client/AccountMenu.tsx +12 -2
  39. package/src/client/BrowserView.tsx +1 -1
  40. package/src/client/DiffTab.tsx +1 -1
  41. package/src/client/EditorHost.tsx +1 -1
  42. package/src/client/FileTree.tsx +10 -5
  43. package/src/client/FreeWindow.tsx +2 -1
  44. package/src/client/GitView.tsx +7 -3
  45. package/src/client/LogoutConfirmDialog.tsx +39 -0
  46. package/src/client/PluginMarketSettingsSection.tsx +55 -0
  47. package/src/client/PluginMarketView.module.css +50 -0
  48. package/src/client/PluginMarketView.tsx +243 -0
  49. package/src/client/PluginProjectPicker.tsx +73 -0
  50. package/src/client/SideCardSection.tsx +2 -23
  51. package/src/client/Sidebar.tsx +2 -2
  52. package/src/client/TabBar.tsx +2 -4
  53. package/src/client/TextEditor.tsx +2 -1
  54. package/src/client/TreePanel.tsx +1 -2
  55. package/src/client/UsageHeatmapSection.tsx +1 -1
  56. package/src/client/api.ts +12 -0
  57. package/src/client/builtins/tabs.tsx +25 -5
  58. package/src/client/builtins/viewers.tsx +2 -1
  59. package/src/client/icons.tsx +57 -4
  60. package/src/client/index.tsx +10 -1
  61. package/src/client/intercept.tsx +1 -1
  62. package/src/client/locales-ja.ts +65 -0
  63. package/src/client/locales.ts +118 -1
  64. package/src/client/md-toc.tsx +1 -1
  65. package/src/client/mermaid.tsx +2 -1
  66. package/src/client/open-with-settings.tsx +1 -1
  67. package/src/client/plugin-market-catalog.ts +90 -0
  68. package/src/client/service.ts +1 -1
  69. package/src/client/sidebar.module.css +81 -19
  70. package/src/client/ui-tweaks/archive.tsx +118 -140
  71. package/src/client/ui-tweaks/branding.tsx +117 -49
  72. package/src/client/ui-tweaks/cachehit.tsx +24 -14
  73. package/src/client/ui-tweaks/dom-text.ts +12 -0
  74. package/src/client/ui-tweaks/index.tsx +75 -103
  75. package/src/client/ui-tweaks/sidebar-header.ts +73 -0
  76. package/src/client/ui-tweaks/typography.ts +38 -0
  77. package/src/config.ts +22 -2
  78. package/src/context-types.ts +5 -15
  79. package/src/index.ts +28 -21
  80. package/src/login-page-script.ts +107 -0
  81. package/src/login-route.ts +7 -4
  82. package/src/plugin-market-api.ts +88 -0
  83. package/src/plugin-market-shared.ts +30 -0
  84. package/src/prefs-shared.ts +1 -1
  85. package/src/pty-deps.ts +2 -2
  86. package/src/ui-tweaks/config.ts +12 -12
  87. 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
@@ -3063,8 +3221,24 @@ var CodingPlanCatalogue = class {
3063
3221
  }
3064
3222
  }
3065
3223
  };
3224
+ //#endregion
3225
+ //#region src/chatcode-update.ts
3226
+ /**
3227
+ * ChatCode self-update for the account menu's "check for updates / update now"
3228
+ * action. Mirrors the semantics of the upstream `yuanjing-wanma-cli /update`
3229
+ * flow (query the npm registry for the latest version, compare against the
3230
+ * globally installed version, then `npm install -f -g <pkg>@<latest>`), applied
3231
+ * to the CLI package this sidebar is responsible for.
3232
+ *
3233
+ * All subprocess work goes through `execFile` with a plain argv array (no
3234
+ * shell), the same posture the rest of the host uses. The npm registry (and
3235
+ * the global install target) is the machine running the DSH host, not the
3236
+ * browser.
3237
+ */
3238
+ /** CLI package the sidebar keeps up to date. */
3239
+ const CHATCODE_CLI_PKG = "@chatcode/chatcode-cli";
3066
3240
  /** The single package a "one-click update" upgrades. */
3067
- const CHATCODE_UPDATE_PACKAGES = ["@chatcode/chatcode-cli"];
3241
+ const CHATCODE_UPDATE_PACKAGES = [CHATCODE_CLI_PKG];
3068
3242
  /** npm registry used for both the version lookup and the global install. */
3069
3243
  const NPM_REGISTRY = "https://registry.npmjs.org";
3070
3244
  /** Windows ships npm as a `npm.cmd` shim, which `execFile` cannot spawn
@@ -3225,39 +3399,6 @@ async function performAllUpdates(checks) {
3225
3399
  return results;
3226
3400
  }
3227
3401
  //#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
3402
  //#region src/ui-tweaks/turn-outcome.ts
3262
3403
  /** Projection key the browser notifier reads through list-row `projectionValues`. */
3263
3404
  const TURN_OUTCOME_PROJECTION_KEY = "dshTurnOutcome";
@@ -5857,16 +5998,102 @@ function installMcpWeb(ctx, backend) {
5857
5998
  //#endregion
5858
5999
  //#region src/ui-tweaks/index.ts
5859
6000
  function apply$1(ctx) {
5860
- ctx.settings.register(UI_TWEAKS_SETTINGS_NAMESPACE, Config$1, { applies: "live" });
5861
6001
  installTurnOutcomeProjection(ctx);
5862
6002
  installUITweaksWeb(ctx, new UITweaksWebBackend(ctx));
5863
- const readConfig = () => ctx.settings.get(UI_TWEAKS_SETTINGS_NAMESPACE);
6003
+ const readConfig = () => {
6004
+ return ctx.settings.describe().find((candidate) => candidate.ns === "better-sidebar")?.value ?? {};
6005
+ };
5864
6006
  installGitWeb(ctx, new GitBackend(ctx, readConfig));
5865
6007
  installArchiveWeb(ctx, new ArchiveBackend(ctx));
5866
6008
  installMcpWeb(ctx, new McpBackend(ctx));
5867
6009
  ctx.logger.info("[ChatCode CLI UI Tweaks] settings namespace registered and Web routes mounted");
5868
6010
  }
5869
6011
  //#endregion
6012
+ //#region src/plugin-market-api.ts
6013
+ function buildPluginMarketApi(ctx, cwdOf) {
6014
+ const service = () => {
6015
+ const value = ctx.get("chatcodePluginMarket", false);
6016
+ if (!value) throw new SidebarError("chatcode-unavailable", "插件市场服务未挂载,请更新并启用 ChatCode config 插件。", 503);
6017
+ return value;
6018
+ };
6019
+ const scopeOf = (payload) => {
6020
+ const scope = requireString(payload, "scope");
6021
+ if (scope !== "project" && scope !== "user") throw new SidebarError("bad-request", "scope must be project or user");
6022
+ return scope;
6023
+ };
6024
+ const selectedProject = async (payload) => {
6025
+ if (typeof payload?.projectPath !== "string") throw new SidebarError("bad-request", "请先选择目标项目目录。");
6026
+ const path = requireString(payload, "projectPath");
6027
+ const qualified = process.platform !== "win32" || /^(?:[A-Za-z]:[\\/]|[\\/]{2}[^\\/]+[\\/][^\\/]+)/.test(path);
6028
+ if (!isAbsolute(path) || !qualified || path.includes("\0")) throw new SidebarError("bad-request", "请选择有效的项目目录。");
6029
+ const canonical = await realpath(path);
6030
+ if (!(await stat(canonical)).isDirectory()) throw new SidebarError("bad-request", "请选择项目文件夹。");
6031
+ return canonical;
6032
+ };
6033
+ const picker = () => {
6034
+ const value = ctx.get("directoryPicker", false);
6035
+ if (!value) throw new SidebarError("method-error", "目录选择器未挂载,请启用宿主目录选择插件。", 503);
6036
+ return value.capability();
6037
+ };
6038
+ const contextOf = async (payload) => {
6039
+ const sessionId = payload?.sessionId;
6040
+ if (sessionId === void 0 || sessionId === "") return { sessionId: "" };
6041
+ requireString(payload, "sessionId");
6042
+ return {
6043
+ sessionId,
6044
+ cwd: (await cwdOf(payload)).cwd
6045
+ };
6046
+ };
6047
+ const projectOf = async (payload) => {
6048
+ if (payload?.projectPath !== void 0) return selectedProject(payload);
6049
+ return (await contextOf(payload)).cwd;
6050
+ };
6051
+ return {
6052
+ "plugins.context": contextOf,
6053
+ "plugins.project.pick": async () => {
6054
+ const capability = picker();
6055
+ if (capability.kind === "browse") return { kind: "browse" };
6056
+ const path = await capability.pick(AbortSignal.timeout(12e4));
6057
+ return {
6058
+ kind: "native",
6059
+ path: path === null ? null : await selectedProject({ projectPath: path })
6060
+ };
6061
+ },
6062
+ "plugins.project.directories": async (payload) => {
6063
+ const capability = picker();
6064
+ if (capability.kind !== "browse") throw new SidebarError("method-error", "当前宿主使用系统文件夹选择窗口。");
6065
+ const path = payload?.path;
6066
+ return capability.list(path === void 0 ? void 0 : requireString(payload, "path"), AbortSignal.timeout(15e3));
6067
+ },
6068
+ "plugins.marketplaces": () => service().marketplaces(),
6069
+ "plugins.catalog": async (payload) => {
6070
+ const market = service();
6071
+ const id = requireString(payload, "marketplaceId");
6072
+ if (payload.includeMetadata !== true) return market.plugins(id);
6073
+ return market.catalog ? market.catalog(id) : {
6074
+ plugins: await market.plugins(id),
6075
+ warning: ""
6076
+ };
6077
+ },
6078
+ "plugins.installed": async (payload) => {
6079
+ const project = await projectOf(payload);
6080
+ const records = await service().installed(project ?? process.cwd());
6081
+ return project ? records : records.filter((record) => record.scope === "user");
6082
+ },
6083
+ "plugins.install": async (payload) => {
6084
+ const scope = scopeOf(payload);
6085
+ const project = scope === "project" ? await selectedProject(payload) : await projectOf(payload);
6086
+ return service().install(project ?? process.cwd(), requireString(payload, "pluginId"), scope);
6087
+ },
6088
+ "plugins.uninstall": async (payload) => {
6089
+ const scope = scopeOf(payload);
6090
+ const project = scope === "project" ? await selectedProject(payload) : await projectOf(payload);
6091
+ await service().uninstall(project ?? process.cwd(), requireString(payload, "pluginId"), scope);
6092
+ return { ok: true };
6093
+ }
6094
+ };
6095
+ }
6096
+ //#endregion
5870
6097
  //#region src/index.ts
5871
6098
  /**
5872
6099
  * dsh-better-sidebar host half: the /sidebar JSON API (explorer listing, file
@@ -6182,6 +6409,7 @@ function buildApi(ctx, ptyManager, agentPtyRegistry, resolved, terminalShell, ge
6182
6409
  parent: parentOf(cwd) ?? null
6183
6410
  };
6184
6411
  },
6412
+ ...buildPluginMarketApi(ctx, cwdOf),
6185
6413
  "fs.tree": async (payload) => {
6186
6414
  const { cwd } = await cwdOf(payload);
6187
6415
  return listDirectory(payload.path === void 0 ? cwd : await ensureWorkspacePath(cwd, requireString(payload, "path"), fenceEnabledOf(getSettings)), resolved.listLimit);
@@ -6318,6 +6546,7 @@ function buildApi(ctx, ptyManager, agentPtyRegistry, resolved, terminalShell, ge
6318
6546
  "chatcode.start": () => requireChatcodeAuth().startLogin(),
6319
6547
  "chatcode.cancel": (payload) => requireChatcodeAuth().cancelLogin(requireString(payload, "sessionId")).then(() => ({ ok: true })),
6320
6548
  "chatcode.logout": () => requireChatcodeAuth().logout().then(() => ({ ok: true })),
6549
+ "chatcode.installed-version": async () => ({ version: await installedGlobalVersion(CHATCODE_CLI_PKG) }),
6321
6550
  "chatcode.update.check": async () => ({ packages: await checkAllChatcodeUpdates() }),
6322
6551
  "chatcode.update.perform": async () => ({ results: await performAllUpdates(await checkAllChatcodeUpdates()) }),
6323
6552
  "release-note.current": (payload) => {
@@ -6468,7 +6697,6 @@ function apply(ctx, config) {
6468
6697
  };
6469
6698
  ctx.inject(["settings"], (sctx) => {
6470
6699
  const ns = SIDEBAR_PREFS_NS;
6471
- const scope = sctx.settings.register(ns, PrefsSchema);
6472
6700
  const viewOf = () => {
6473
6701
  const descriptor = sctx.settings.describe({ redactSecrets: true }).find((candidate) => candidate.ns === ns);
6474
6702
  return descriptor === void 0 ? {
@@ -6490,6 +6718,13 @@ function apply(ctx, config) {
6490
6718
  return viewOf();
6491
6719
  }
6492
6720
  };
6721
+ const scope = { get: () => {
6722
+ const value = viewOf().value;
6723
+ return {
6724
+ ...SIDEBAR_PREFS_DEFAULTS,
6725
+ ...typeof value === "object" && value !== null ? value : {}
6726
+ };
6727
+ } };
6493
6728
  syncToolsGate(scope);
6494
6729
  const syncOpenToolsGate = () => {
6495
6730
  if (scope.get().agentOpenTools) {
@@ -6504,7 +6739,7 @@ function apply(ctx, config) {
6504
6739
  }
6505
6740
  };
6506
6741
  syncOpenToolsGate();
6507
- scope.watch(() => {
6742
+ sctx.on("loader/volatile-update", () => {
6508
6743
  syncToolsGate(scope);
6509
6744
  syncOpenToolsGate();
6510
6745
  });
@@ -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;
@@ -195,6 +212,10 @@ export declare const api: {
195
212
  chatcodeLogout: () => Promise<{
196
213
  ok: true;
197
214
  }>;
215
+ /** The globally installed CLI version, read from npm global modules. */
216
+ chatcodeInstalledVersion: (signal?: AbortSignal) => Promise<{
217
+ version: string | null;
218
+ }>;
198
219
  /** Check both ChatCode packages (web + CLI) against the npm registry. */
199
220
  chatcodeUpdateCheck: (signal?: AbortSignal) => Promise<{
200
221
  packages: ChatCodeUpdateCheck[];
@@ -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
  /**
@@ -13,5 +13,30 @@
13
13
  * - Placeholders keep `{name}` verbatim (interpolation runs after lookup).
14
14
  * - English brand names (VS Code, Cursor, Zed, SSH) stay as-is.
15
15
  */
16
+ /** Japanese archive-management copy registered under the ui-tweaks namespace. */
17
+ export declare const uiTweaksArchiveJa: {
18
+ readonly archiveNav: "アーカイブ";
19
+ readonly archiveTitle: "アーカイブ済みセッション";
20
+ readonly archiveEmpty: "アーカイブ済みセッションはありません。";
21
+ readonly archiveRestore: "復元";
22
+ readonly archiveRestoring: "処理中…";
23
+ readonly archiveConfirmTitle: "セッションを完全に削除しますか?";
24
+ readonly archiveConfirmDescription: "所有するサブエージェントを含む {count} 件のセッション記録を完全に削除します。この操作は取り消せません。独立した分岐、ワークスペースのファイル、Git データは保持されます。";
25
+ readonly archiveCancel: "キャンセル";
26
+ readonly archiveDelete: "削除";
27
+ readonly archiveDeleteAll: "すべて削除";
28
+ readonly archiveSelectAll: "すべて選択";
29
+ readonly archiveSelectedCount: "{count} 件のセッションを選択中";
30
+ readonly archiveClearSelection: "選択を解除";
31
+ readonly archiveDeleteSelected: "選択したセッションを削除({count})";
32
+ readonly archiveDeleteFailed: "「{title}」:{error}";
33
+ readonly archiveRestoreAll: "すべて復元";
34
+ readonly archiveCount: "件のセッション";
35
+ readonly archiveUnavailable: "アーカイブを利用できません。";
36
+ readonly archiveLiveError: "このセッションは実行中です。完全に削除する前に閉じてください。";
37
+ readonly archiveDisabledHint: "アーカイブ管理は無効です。「UI 調整」で有効にすると、ここでアーカイブ済みセッションを復元または完全に削除できます。";
38
+ readonly archiveEnable: "アーカイブ管理を有効にする";
39
+ readonly archiveRestored: "復元しました。";
40
+ };
16
41
  /** The ja dictionary (key-set-equal to zh, enforced by the type annotation in locales.ts). */
17
42
  export declare const ja: Record<string, string>;